diff --git a/.c3i/authorized_users.yml b/.c3i/authorized_users.yml new file mode 100644 index 0000000000000..4cc406ef0941d --- /dev/null +++ b/.c3i/authorized_users.yml @@ -0,0 +1,997 @@ +authorized_users: +- github-actions[bot] +- conan-center-bot +- c3i-dev +- uilianries +- SSE4 +- Croydon +- Johnnyxy +- solvingj +- ericLemanissier +- tru +- sztomi +- theodelrieu +- grafikrobot +- piponazo +- minimonium +- lasote +- danimtb +- memsharded +- jgsogo +- czoido +- jcar87 +- theirix +- madebr +- sourcedelica +- obiltschnig +- martinmoene +- tonka3000 +- leonardoarcari +- bmanga +- flexferrum +- gocarlos +- flostellbrink +- rvarago +- cqjjjzr +- akemimadoka +- bverhagen +- IceflowRE +- mjvk +- Morwenn +- Talkless +- sgiessl +- KristianJerpetjon +- paulbendixen +- datalogics-robb +- PinkySan +- keysight-daryl +- gunmetal313 +- rdeterre +- Hopobcn +- rikdev +- arcadien +- aostrowski +- reneme +- abbyssoul +- ledocc +- fpelliccioni +- PierreRamoin +- yipdw +- soporide +- detwiler +- hrantzsch +- figroc +- robert-shade +- KaoCC +- planetmarshall +- cirla +- vaerizk +- Dattax +- TimSimpson +- intelligide +- ericriff +- renatofilho +- puetzk +- calvingiles +- raffienficiaud +- chfanghr +- dvirtz +- greenjava +- apeterson-branch +- david-sinuela-pix4d +- BlueSolei +- AndWass +- SpaceIm +- prsolucoes +- yssource +- dheater +- GavinNL +- sourcedelica +- kf6kjg +- StefansM +- Psy-Kai +- LunarWatcher +- nicoguillier +- a4z +- p-podsiadly +- tarc +- n-bes +- Manu343726 +- greenrobot +- KingKili +- Adnn +- arnesor +- gummif +- btashton +- osfd +- maddanio +- likle +- mbodmer +- feragon +- claremacrae +- nicolastagliani +- samuelpmish +- Garcia6l20 +- RemySphere +- pleroux0 +- qchateau +- datalogics-kam +- tt4g +- akshit-sharma +- jargonzombies +- xqp +- alnkpa +- prince-chrismc +- bk2221 +- igl42 +- casabre +- Nipheris +- faker00t +- vvilpas +- fredrikslattman +- worldemar +- rurabori +- chhitz +- zod +- Twon +- miketsukerman +- mgoldshteyn +- dab0bby +- atilag +- floriansimon1 +- jjkoshy +- kasunch +- mapau +- igor-sadchenko +- fulara +- BNL-Corp +- pyrige +- ZaMaZaN4iK +- rudolfheszele +- philburr +- vishsangale +- Artalus +- vanwinkeljan +- renatoGarcia +- Nekto89 +- gonestco +- xyz1001 +- axalon900 +- jfalcou +- pss146 +- zhenlei +- datalogics-aarroyo +- serpent7776 +- AndrewMeadows +- neobrain +- oxycoder +- dvd0101 +- anagno +- odygrd +- datalogics-kam +- ChaosWars +- ash7777 +- csch0 +- daixian +- Murazaki +- garethsb-sony +- Austin299792 +- FranckRJ +- danielaparker +- 0x8000-0000 +- ah7675 +- jmarrec +- icraggs +- davidtazy +- kchmck +- PavelKisliak +- vvandrounik +- pavanbadugu +- isnullxbh +- Michanne +- markusgod +- syoliver +- daravi +- museghost +- pezcode +- hnOsmium0001 +- kaihowl +- deimi +- tomlankhorst +- frek818 +- ddalcino +- saukijan +- sandro97git +- hoxnox +- madduci +- goranbrkic +- mohamedghita +- rweickelt +- faithfracture +- wolfee001 +- empyrical +- birgerbr +- akosik-anyvision +- jeremy-coulon +- TheStormN +- gmgunter +- ibmibmibm +- daniellecandid +- AGreat1 +- ytimenkov +- memchk +- lederernc +- lkotsonis +- DrewImm +- martin-schulze-vireso +- wdobbe +- Flow-It +- burace17 +- sam-mosleh +- db4 +- jaspervandeven +- DavidZemon +- yelu +- bibermann +- baltendorf +- Mahe-Thomas +- Eremiell +- d70-t +- ufkesba +- frtru +- Janos95 +- siebenschlaefer +- marzer +- timblechmann +- dBagrat +- lemire +- talyz +- rconde01 +- SemyonDuB +- reuk +- ppetraki +- ZachClayburn +- SergiusTheBest +- kirandivekar +- jaredkeithwhite +- DavidAce +- zhangyoufu +- nqle +- rushikesh90 +- marcvilletard +- klimkin +- jheaff1 +- Bigpet +- derived-coder +- thclark +- sielicki +- helmesjo +- dskachan +- johanneskares +- GirtsR +- greeng3 +- mattgodbolt +- mathbunnyru +- ngerke +- TheLavaBlock +- greeng3 +- ItsBasi +- yamadapc +- afedechko +- pmqtt +- uyha +- GIGte +- ctapmex +- ohanar +- bernedom +- ericniebler +- mmha +- mjvankampen +- ivan-kulikov-dev +- ntagliani +- bnlcorp +- Alberto-Izquierdo +- an-tao +- p-ranav +- omaralvarez +- djcsdy +- pepsiman +- Fefer-Ivan +- iblancasa +- dongskyler +- MartinDelille +- samr +- cen1 +- stefan-floeren +- oleurodecision +- tbeu +- joxoby +- halfelf +- matt-42 +- sunnycase +- ldobinson +- xiaotianrandom +- mpusz +- Erlkoenig90 +- mzdun +- annulen +- fmorgner +- gmikhaile +- wwhuie +- kyllingstad +- desertfury +- yarrr-ru +- fschoenm +- bel2125 +- melak47 +- b1ackviking +- remysalim +- hosseinmoein +- illume +- srnwk +- boussaffawalid +- atrelinski +- Arenoros +- narcdev +- steinerthomas +- w4bremer +- ddark008 +- andioz +- OleksiiKyslynskyi +- verybigbadboy +- bobrofon +- newlawrence +- ThomasHauth +- nicraMarcin +- dankamongmen +- davehadley +- G3nna +- dertuxmalwieder +- arlyon +- remiburtin +- mplemay +- mys007 +- jwellbelove +- gopaldappdev +- ngrodzitski +- spjuanjoc +- hongyx11 +- morth +- selaci +- hdhauk +- libbylg +- cacay +- fatliverfreddy +- dnck +- balintfodor +- blackliner +- HeinrichJanzing +- Nick-Deubert-Bose +- ruanformigoni +- CAMOBAP +- jwillikers +- bowb +- dsakurai +- dooho-h +- dmn-star +- avantgardnerio +- ShuangLiu1992 +- justinmcbride +- resttime +- ubnt-kannan +- taoyouh +- skannan89 +- paulo-coutinho +- AndreyMlashkin +- AndyMender +- triangulumlabs +- Woazim +- shubhamck +- Lukas-Heiligenbrunner +- marius-meissner +- Mikayex +- n-stone +- IvanRibakov +- dfontenot +- JonasProgrammer +- plopp +- sebastian-bergt +- xguerin +- Dobiasd +- ChGen +- Jonathan-Eid +- ihsandemir +- Marks101 +- whuji +- jiangdawhy +- MichelleHetzel +- Pro +- anton-dirac +- petiaccja +- Expander +- kdsx +- wolfram77 +- dsakilesh +- mdavezac +- Jihadist +- anton-danielsson +- rawbby +- wuzhiguocarter +- GaryN4 +- TheSalvator +- fcelda +- toge +- maksim-0 +- blackencino +- lukaszlaszko +- pichi-router +- dernasherbrezon +- bsergean +- krzysztof-jusiak +- riebl +- ruilvo +- jhurliman +- ralfholly +- MaxSac +- Linux13524 +- IanE9 +- upsj +- Hippskill +- ksamelyuk +- doshisahil +- FlayaN +- uglyog +- alex-87 +- mologie +- ChatPion +- heyzooi +- Firefly35 +- maxmouchet +- dvj +- bitwizeshift +- ondrej-outrata +- rileylev +- ltjax +- sloriot +- wbitesi +- canmor +- whyman +- garethsb +- sixten-hilborn +- qoelet +- lawrence-koh +- adrianjrg +- ayeganov +- tetsuo-cpp +- AlvaroFS +- ivabrajer +- kebadopp +- qoo2p5 +- aapocketz +- mbeutel +- redradist +- accwebs +- ZombieRaccoon +- hoyes +- rtosman +- ivalery111 +- krsch +- jothepro +- Jean1995 +- tomas-krupa +- ollien +- tupini07 +- yuanliuus +- luismartingil +- mydatamodels +- pixsperdavid +- rockdreamer +- jpilet +- voidbar +- jayaramganapathy +- AJIOB +- th-lp +- penfeizhou +- tapia +- igormironchik +- rkozakban +- avsej +- jakecobb +- johnmcfarlane +- FernandoVelcic +- LHLaurini +- dotChris90 +- mymichu +- i-vovk +- lakinwecker +- hpesoj +- shiena +- aurelienpre +- lieser +- zspasztori +- HRenata +- alejandro-colomar +- leha-bot +- werto87 +- cguentherTUChemnitz +- mmatrosov +- cesenaLA +- chgans +- sabelka +- stefled +- PengZheng +- mez +- beckerhe +- serszab +- mtrzas +- zuut +- JohanZackrisson +- VladimirVR +- franramirez688 +- nicholas-kelly +- yemreinci +- alvarogarcia7 +- daniele77 +- Renari +- AlexanderLanin +- Guyutongxue +- rockandsalt +- thmahe +- slietzau +- fennibay +- Konard +- uselessgoddess +- espositofulvio +- Elnee +- tisonkun +- AshleyRoll +- inparallel +- vcampmany +- 3d4m-vladimir +- thesummer +- NolanC33 +- Chnossos +- spaque-qustodio +- maxis11 +- cqc-alec +- Zugzwanger +- maspri +- ghorbanzade +- pchamuczynski +- Sahnvour +- torfinnberset +- davidsanfal +- COM8 +- seladb +- vvarma +- smsm2014 +- jngrb +- dilawar +- cbachhuber +- mmatisko +- sparik +- samuel-emrys +- lordafzal +- jayvdb +- wwizz +- sh0 +- jtorresfabra +- Snowapril +- ryanseipp +- exief +- Lemiort +- tcanabrava +- k0ekk0ek +- gerd2s +- Divix55 +- hannahwhy +- zodinyac +- claudius-kienle +- choll +- erikzenker +- dannftk +- Jairard +- Nicky-D +- pgeler +- gmeeker +- gokhanettin +- emwap +- vbieleny +- FusionBolt +- krotitom-embedded +- SamsonBox +- SkillerRaptor +- KerstinKeller +- hemantkashniyal +- ThePirate42 +- jhabermas +- TheClonerx +- FMeinicke +- isidore +- corporategoth +- nightlark +- jpauwels +- LighthouseJ +- vbeffara +- ChrisRuff +- eigenwhat +- samvik +- xissburg +- SuTanTank +- bemehiser +- szavadsky +- nfrechette +- patmantru +- kenfred +- coryan +- ciclark2 +- serge1 +- PatSche +- Mo-Tay +- kexianda +- dvetutnev +- mwcondino +- YaZasnyal +- walterbrebels +- tuxu +- dev-plvlml +- woidpointer +- dkruempe +- ehds +- sase-cs +- idealvin +- seemk +- chausner +- loic-lopez +- PolyPik +- fdgStilla +- jputcu +- ivmai +- Speak2Erase +- miklelappo +- ivanvurbanov +- cc0der +- kubasz +- killzoner +- MathiasDanzeisen +- mosure +- avitevet +- AntonHorbach +- darcamo +- DonOregano +- sebastianbergt +- yuriy-mochurad +- jtcarnes +- ValentiWorkLearning +- eyalroz +- Zvicii +- SteelBlueVision +- Fettpet +- sobotklp +- andiwand +- pdavydov108 +- gjasny +- eirikb +- wpalfi +- vkes +- wouterz +- szigetics +- kovdan01 +- willadsen +- michalwidera +- FlexW +- wizardsd +- eeyrw +- nioncode +- Kr4is +- tonyseek +- kevswims +- Tarek-Hasan +- SerkanTuerker +- Carsten87 +- aacebedo +- maximiliank +- drmacdon +- somedevfox +- Zeeno-atl +- hardsetting +- friendlyanon +- MrLIk +- OrianeGourdyStilla +- chusitoo +- csegarragonz +- dean0x7d +- MauriceS-WTI +- Lorac +- sonicxml +- elazarl +- synacker +- jtbandes +- gouriano +- hiemstar +- Enhex +- luk1337 +- ChristianPanov +- JurajX +- pedro-alves-ferreira +- BenjaminNavarro +- sophieeihpos +- jowr +- aruizs +- pbreaux +- fardragon +- njacquemin1993 +- earonesty +- capnkenny +- kring +- sanblch +- winternet +- jlouazel +- JonathanGirardeau +- BishopJohnson +- Tzoockee +- PeteAudinate +- Cyriuz +- ArashPartow +- dpronin +- The-EDev +- artem-ogre +- krzysztofskorupski +- jt416 +- Pollux42 +- gracicot +- Siviuze +- ggulgulia +- ondrej-benus +- RubyNova +- HerrNamenlos123 +- naresh97 +- rnapier +- eerimoq +- bb010g +- paulocoutinhox +- WilliamBehrens +- greg7mdp +- ruurdadema +- steromano87 +- marsven +- DS-Serafin +- DS-Alex-AG +- cbeattie-tl +- '0x28' +- nmgwddj +- brandonmkunkel +- MykolaPu +- petamas +- icarusdes +- the-nic +- zjg +- rfn123 +- icedream2linxi +- MikeLankamp +- AnotherFoxGuy +- fdefelici +- basiliscos +- svenpilz +- sfackler +- AnticliMaxtic +- serghov +- erikogenvik +- dssimonspoerri +- bysnack +- hannesa2 +- Aypahyo +- chausner-audeering +- gleb-kov +- Yen5666 +- jkimblad +- impugachev +- sebhmg +- sujankota +- 5chmidti +- l2dy +- DamDsj +- Anokhi1994 +- mscofield0 +- alex-700 +- StellaSmith +- buresu +- yzsolt +- aborzunov +- jsantorek +- tmartiel +- rbrich +- HappySeaFox +- hlewin +- victor1234 +- nextsilicon-itay-bookstein +- ekondis +- luizgabriel +- kshehata +- dietssa +- simoncent +- staskau +- Iswenzz +- DAP-IT-Aachen +- VladyslavUsenko +- vdsbenoit +- Macfly +- hesham-essam +- mkviatkovskii +- sgoth +- hellozee +- Ryan-rsm-McKenzie +- bog-dan-ro +- dennisjosesilva +- bartop +- cameron-devine +- wadimklincov +- vectorsli +- paulharris +- pbailey-hf +- Cogitri +- Sil3ntStorm +- jstzwj +- eseiler +- npuichigo +- dfleury2 +- bigerl +- EKathe +- hmartinez82 +- sfc-gh-mpilman +- apogza +- ameysutavani +- sify21 +- eigenraven +- jay-tux +- baptisteesteban +- chenpengfei +- minlexx +- kou +- 0xbk +- dsche +- tk-tnz +- strangeQuark1041 +- tuduongquyet +- lbakman +- gogoprog +- mvhv +- FreePhoenix888 +- tuccio +- martinvl +- robomics +- EricDeng1001 +- agom +- tsondergaard +- xhuohai +- Mitron57 +- EstebanDugueperoux2 +- suhasHere +- Tradias +- NeXuS4Developer +- jellespijker +- bshoshany +- Chrismarsh +- ice0 +- krjakbrjak +- romariorios +- Latios96 +- 0xFireWolf +- ashkulz +- kenneth-jia +- jnordin20 +- jubalh +- joaotavora +- VestniK +- sheepgrass +- allen-zhou-dev +- daemyung +- szmyd +- lo1ol +- victorpaleologue +- FaerHack +- netheril96 +- atimin +- ssophie01 +- mietzen +- mourogurt +- hoisunng +- abouvier +- jadamwilson2 +- nilsnolde +- olivia76 +- CD3 +- ovostrikov +- t-8ch +- ingydotnet +- SirCosty +- mvoelkle-cern +- markferry +- mttbernardini +- ofiriluz +- ksmets +- jonathan-conder-sm +- Bueddl +- dornbirndevelops +- boofhead +- marcusl +- Makamitsu +- ulrichji +- kammce +- tomconder +- horusxnetworks +- Nomalah +- kambala-decapitator +- rainman110 +- jiangshipengv8 +- BjoernAtBosch +- dubvulture +- ZbigniewRA +- JorgenPo +- AlexRamallo +- kissandras +- scandyna +- jave27 +- mark0n +- kayoub5 +- topheg +- curoky +- datalogics-saharay +- sproberts92 +- madhat1 +- vince-cheung +- mariopil +- PikachuHyA +- System-Arch +- sorny92 +- cubanpit +- winterz +- Kidsunbo +- antony-jr +- tankeco +- ElliotMugner +- jfaust +- morningstar1 +- lrineau +- jwidauer +- partiallyderived +- Ahajha +- mjimenofluendo +- jiaoew1991 +- ramin-raeisi +- schoetbi +- psyinf +- Novakov +- maksim-petukhov +- roedhaetten +- nassipkali +- petrovito +- razielxyz +- da1910 +- RazielXYZ +- EmilienBINET +- Doome161 +- Sneder89 +- connorsmacd +- jshanab +- ghost +- zamazan4ik +- elliotcmorris +- Ignition +- je894591 +- AlexandrePTJ +- peterSW +- shiyj +- KGrzeg +- goodtune +- theartful +- Yuhanun +- feltech +- geirhei +- Clueliss +- andrewwasielewski +- chatpion +- kletoz +- agilemapper +- ZXfkSIE +- RubenRBS diff --git a/.c3i/config_v1.yml b/.c3i/config_v1.yml new file mode 100644 index 0000000000000..be12d2a2a3026 --- /dev/null +++ b/.c3i/config_v1.yml @@ -0,0 +1,190 @@ +--- +# Configuration for `https://github.com/conan-io/conan-center-index` repository +id: 'conan-io/conan-center-index' + +conan: + version: 1.53.0 + +artifactory: + url: "https://c3i.jfrog.io/c3i" + main_repo: "conan-center" + pull-request_repo_prefix: "c3i_PR" + pull-request_permission: "c3i-pr" + logs_repo: "misc" + cache_repo: "cache" + +github: + reviewers: "reviewers.yml" + authorized_users: "authorized_users.yml" + check_runs: + - "Lint changed files (YAML files)" + - "Lint changed conanfile.py (v2 migration)" + +# Requirements to merge a given pull-request: +# * status_checks refers to notifications coming from external tools (Jenkins, CLA,...) +# * check_runs refers to notifications from GH actions +status_checks: + - "license/cla" + - "continuous-integration/jenkins/pr-merge" + +slack: + credential_success_url: SLACK_SUCCESS_WEBHOOK_URL + ceredential_errors_url: SLACK_FAILURE_WEBHOOK_URL + +# Things related to Jenkins jobs +tasks: + conan_v2_run_export: true + write_comments: true + detailed_status_checks: true + update_labels: true + automatic_merge: + reviews_required_total: 2 # Reviews that a PR needs so it can be merged + reviews_required_team: 1 # Reviews from the Conan team that a PR needs so it can be merged + +# Profile configurations to build packages +configurations: + - id: linux-gcc + epochs: [0] + hrname: "Linux, GCC" + content: + - os: [ "Linux" ] + arch: [ "x86_64" ] + compiler: + - "gcc": + compiler.libcxx: [ "libstdc++11", "libstdc++" ] + compiler.version: [ "5", "7", "8", "9", "10" ] + build_type: [ "Release", "Debug" ] + - id: linux-gcc + epochs: [20211221, 20220120] + hrname: "Linux, GCC" + content: + - os: ["Linux"] + arch: ["x86_64"] + compiler: + - "gcc": + compiler.libcxx: ["libstdc++11", "libstdc++"] + compiler.version: ["5", "7", "8", "9", "10", "11"] + build_type: ["Release", "Debug"] + - id: linux-clang + epochs: [0] + hrname: "Linux, Clang" + content: + - os: [ "Linux" ] + arch: [ "x86_64" ] + compiler: + - "clang": + compiler.libcxx: [ "libstdc++", "libc++" ] + compiler.version: [ "11" ] + build_type: [ "Release", "Debug" ] + - id: linux-clang + epochs: [20211221, 20220120] + hrname: "Linux, Clang" + content: + - os: ["Linux"] + arch: ["x86_64"] + compiler: + - "clang": + compiler.libcxx: ["libstdc++", "libc++"] + compiler.version: ["11", "12", "13"] + build_type: ["Release", "Debug"] + - id: configs/macos-clang + epochs: [0, 20211221] + hrname: "macOS, Clang" + content: + - os: [ "Macos" ] + arch: [ "x86_64" ] + compiler: + - "apple-clang": + compiler.version: [ "11.0", "12.0" ] + compiler.libcxx: [ "libc++" ] + build_type: [ "Release", "Debug" ] + - id: configs/macos-clang + epochs: [20220120] + hrname: "macOS, Clang" + content: + - os: [ "Macos" ] + arch: [ "x86_64" ] + compiler: + - "apple-clang": + compiler.version: [ "11.0", "12.0", "13.0"] + compiler.libcxx: [ "libc++" ] + build_type: [ "Release", "Debug" ] + - id: configs/macos-m1-clang + epochs: [0, 20211221] + hrname: "macOS, Clang (M1/arm64)" + build_profile: + os: "Macos" + arch: "x86_64" + content: + - os: [ "Macos" ] + arch: [ "armv8" ] + compiler: + - "apple-clang": + compiler.version: [ "12.0" ] + compiler.libcxx: [ "libc++" ] + build_type: [ "Release", "Debug" ] + - id: configs/macos-m1-clang + epochs: [20220120] + hrname: "macOS, Clang (M1/arm64)" + build_profile: + os: "Macos" + arch: "x86_64" + content: + - os: [ "Macos" ] + arch: [ "armv8" ] + compiler: + - "apple-clang": + compiler.version: [ "12.0", "13.0" ] + compiler.libcxx: [ "libc++" ] + build_type: [ "Release", "Debug" ] + - id: configs/windows-visual_studio + epochs: [0, 20211221, 20220120] + hrname: "Windows, Visual Studio" + content: + - os: [ "Windows" ] + arch: [ "x86_64" ] + compiler: + - "Visual Studio": + compiler.version: [ "15", "16" ] + build_type: + - "Release": + compiler.runtime: [ "MT", "MD" ] + - "Debug": + compiler.runtime: [ "MTd", "MDd" ] + +jenkins: + url: "http://mb-jenkins-my-bloody-jenkins:8080" + +node_labels: + Windows: + x86_64: + "Visual Studio": + default: "windows20221024" + Macos: + x86_64: + "apple-clang": + default: "mac_apple_clang_${compiler.version}" + armv8: + "apple-clang": + default: "mac_apple_clang_${compiler.version}" + Linux: + x86_64: + "gcc": + default: "linux_gcc_${compiler.version}" + "11": "linux_gcc_${compiler.version}_ubuntu16.04" + "clang": + default: "linux_clang_${compiler.version}_ubuntu16.04" + "11": "linux_clang_${compiler.version}" + +pod_size: + # Map with references that need special memory resources to compile. + # - Can be only by name or by name/version. + # - name/version notation takes preference over the name only one + # - Both notations can be combined for the same reference name + large: + - "pcl" + - "duckdb" + - "cppfront" + xlarge: + - "llvm" + - "opengv" diff --git a/.c3i/config_v2.yml b/.c3i/config_v2.yml new file mode 100644 index 0000000000000..b6da2e1452249 --- /dev/null +++ b/.c3i/config_v2.yml @@ -0,0 +1,103 @@ +--- +# Configuration for `https://github.com/conan-io/conan-center-index-staging` repository (using Conan v2) +id: 'conan-io/conan-center-index-staging-v2' + +conan: + version: 2.0.0-pre + +artifactory: + url: "https://c3i.jfrog.io/c3i" + main_repo: "conan-center-v2" + pull-request_repo_prefix: "c3i_PR-v2" + pull-request_permission: "c3i-pr" + logs_repo: "misc-v2" + # cache_repo: "cache" + +github: + reviewers: "reviewers.yml" + authorized_users: "authorized_users.yml" + +# Requirements to merge a given pull-request: +# * status_checks refers to notifications coming from external tools (Jenkins, CLA,...) +# * check_runs refers to notifications from GH actions +#status_checks: +# - "license/cla" +# - "continuous-integration/jenkins/pr-merge" + +#slack: +# credential_success_url: SLACK_SUCCESS_WEBHOOK_URL +# ceredential_errors_url: SLACK_FAILURE_WEBHOOK_URL + +# Things related to Jenkins jobs: +tasks: + write_comments: false + detailed_status_checks: false + update_labels: false + automatic_merge: + reviews_required_total: 1000 # AutomaticMerge shouldn't run with this file, but just in case + reviews_required_team: 1000 # AutomaticMerge shouldn't run with this file, but just in case + +configurations: + - id: linux-gcc + epochs: [20220628] + hrname: "Linux, GCC" + build_profile: + os: "Linux" + content: + - os: ["Linux"] + arch: ["x86_64"] + compiler: + - "gcc": + compiler.libcxx: ["libstdc++11"] + compiler.version: ["11"] + build_type: ["Release"] + - id: configs/macos-clang + epochs: [20220628] + hrname: "macOS, Clang" + build_profile: + os: "Macos" + content: + - os: [ "Macos" ] + arch: [ "x86_64" ] + compiler: + - "apple-clang": + compiler.version: ["13" ] + compiler.libcxx: [ "libc++" ] + build_type: [ "Release"] + - id: configs/windows-msvc + epochs: [20220628] + hrname: "Windows, MSVC" + build_profile: + os: "Windows" + content: + - os: [ "Windows" ] + arch: [ "x86_64" ] + compiler: + - "msvc": + compiler.version: [ "192" ] + build_type: + - "Release": + compiler.runtime: [ "static", "dynamic" ] + compiler.runtime_type: [ "Release" ] + +jenkins: + url: "http://mb-jenkins-my-bloody-jenkins:8080" + +node_labels: + Windows: + x86_64: + "msvc": + default: "windows20221024" + Macos: + x86_64: + "apple-clang": + default: "mac_apple_clang_${compiler.version}" + armv8: + "apple-clang": + default: "mac_apple_clang_${compiler.version}" + Linux: + x86_64: + "gcc": + default: "linux_gcc_${compiler.version}_ubuntu16.04" + "clang": + default: "linux_clang_${compiler.version}_ubuntu16.04" diff --git a/.c3i/reviewers.yml b/.c3i/reviewers.yml new file mode 100644 index 0000000000000..e722f8b159e06 --- /dev/null +++ b/.c3i/reviewers.yml @@ -0,0 +1,74 @@ +reviewers: + # List with users whose review is taken into account so that a pull-request is merged. + # - : Name of the github user + # - : Either 'community' for community reviewers or 'team' for Conan reviewers. + # - : Make the bot proactively request the user's review of pull-requests ready for review. + - user: "danimtb" + type: "team" + request_reviews: true + - user: "lasote" + type: "team" + request_reviews: false + - user: "jgsogo" + type: "community" + request_reviews: false + - user: "czoido" + type: "team" + request_reviews: false + - user: "memsharded" + type: "team" + request_reviews: false + - user: "SSE4" + type: "community" + request_reviews: true + - user: "uilianries" + type: "team" + request_reviews: true + - user: "madebr" + type: "community" + request_reviews: false + - user: "SpaceIm" + type: "community" + request_reviews: false + - user: "theirix" + type: "community" + request_reviews: false + - user: "ericLemanissier" + type: "community" + request_reviews: false + - user: "prince-chrismc" + type: "team" + request_reviews: false + - user: "Croydon" + type: "community" + request_reviews: false + - user: "intelligide" + type: "community" + request_reviews: false + - user: "ericriff" + type: "community" + request_reviews: false + - user: "toge" + type: "community" + request_reviews: false + - user: "AndreyMlashkin" + type: "community" + request_reviews: false + - user: "MartinDelille" + type: "community" + request_reviews: false + - user: "jcar87" + type: "team" + request_reviews: true + - user: "franramirez688" + type: "team" + request_reviews: true + - user: "paulocoutinhox" + type: "community" + request_reviews: false + - user: "jwillikers" + type: "community" + request_reviews: false + - user: "RubenRBS" + type: "team" + request_reviews: false diff --git a/.c3i/v1.jenkins b/.c3i/v1.jenkins new file mode 100644 index 0000000000000..68f3504079ef2 --- /dev/null +++ b/.c3i/v1.jenkins @@ -0,0 +1,6 @@ +#!groovy + +@Library('c3i') _ + +String configurationFile = '.c3i/config_v1.yml' +cci.runBuild(this, configurationFile) diff --git a/.c3i/v2.jenkins b/.c3i/v2.jenkins new file mode 100644 index 0000000000000..865f167f1dcf0 --- /dev/null +++ b/.c3i/v2.jenkins @@ -0,0 +1,6 @@ +#!groovy + +@Library('c3i') _ + +String configurationFile = '.c3i/config_v2.yml' +cci.runBuild(this, configurationFile) diff --git a/.ecrc b/.ecrc new file mode 100644 index 0000000000000..7ea080a63ebc7 --- /dev/null +++ b/.ecrc @@ -0,0 +1,19 @@ +{ + "Version": "2.4.0", + "Verbose": false, + "Debug": false, + "IgnoreDefaults": false, + "SpacesAftertabs": false, + "NoColor": false, + "Exclude": ["^.idea/","^assets/","^docs/","^linter/","^recipes/","\\.md$"], + "AllowedContentTypes": [], + "PassedFiles": [], + "Disable": { + "EndOfLine": false, + "Indentation": false, + "InsertFinalNewline": false, + "TrimTrailingWhitespace": false, + "IndentSize": true, + "MaxLineLength": false + } +} diff --git a/.editorconfig b/.editorconfig index a0c12e281a351..ebe94002ed112 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,15 +7,28 @@ insert_final_newline = true indent_style = space tab_width = 4 trim_trailing_whitespace = true +indent_size = 4 -[*.py] +[{docs,linter,recipes}/**.py] max_line_length = 200 +[*.py] +max_line_length = 120 + [*.yml] tab_width = 2 +indent_size = 2 -[{Makefile,Makefile.am,Makefile.in}] +[dlproject.yaml] +tab_width = 4 +indent_size = 4 + +[{Makefile,Makefile.am,Makefile.in,*.mak}] indent_style = tab +indent_size = 8 -[*.{diff,patch}] +[*.{diff,patch,md}] trim_trailing_whitespace = false + +[*.md] +max_line_length = 80 diff --git a/.gitattributes b/.gitattributes index f0e8d5041ca21..2dfa5430db4d3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ *.cmake text eol=lf *.conf text eol=lf *.diff text eol=lf -*.md text eol=lf +*.md text eol=lf -whitespace *.patch text eol=lf *.py text eol=lf *.txt text eol=lf diff --git a/.gitattributes-merge b/.gitattributes-merge new file mode 100644 index 0000000000000..d0ab3b95b53f7 --- /dev/null +++ b/.gitattributes-merge @@ -0,0 +1,5 @@ +# Conflicts that should always resolve in favor of Datalogics +# See the section "Merge Strategies" at the end of +# https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Attributes +/README.md merge=ours +/.github/** merge=ours diff --git a/.github/ISSUE_TEMPLATE/center_conan_io.md b/.github/ISSUE_TEMPLATE/center_conan_io.md deleted file mode 100644 index f95bb699d0607..0000000000000 --- a/.github/ISSUE_TEMPLATE/center_conan_io.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: 'ConanCenter: Web UI Bugs Or Requests' -about: 'Bugs or feature requests for the Web UI of ConanCenter at https://conan.io/center' -title: '[conan.io/center] SHORT DESCRIPTION' -labels: conan.io/center ---- - - diff --git a/.github/ISSUE_TEMPLATE/package_bug.md b/.github/ISSUE_TEMPLATE/package_bug.md deleted file mode 100644 index 1aeb889806fdb..0000000000000 --- a/.github/ISSUE_TEMPLATE/package_bug.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -name: 'Package: Bug Report' -about: 'Report a bug, something does not work as it supposed to' -title: '[package] /: SHORT DESCRIPTION' -labels: bug ---- - - - -### Package and Environment Details (include every applicable attribute) - * Package Name/Version: **zlib/1.2.8** - * Operating System+version: **Linux Ubuntu 18.04** - * Compiler+version: **GCC 8** - * Docker image: **conanio/gcc8** - * Conan version: **conan 1.18.0** - * Python version: **Python 3.7.4** - - -### Conan profile (output of `conan profile show default` or `conan profile show ` if custom profile is in use) -``` -Put your profile output here -``` - - -### Steps to reproduce (Include if Applicable) - - - -### Logs (Include/Attach if Applicable) -
Click to expand log - -``` -Put your log output here -``` - -
diff --git a/.github/ISSUE_TEMPLATE/package_request.md b/.github/ISSUE_TEMPLATE/package_request.md deleted file mode 100644 index 2d23c97fae995..0000000000000 --- a/.github/ISSUE_TEMPLATE/package_request.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -name: 'Package: Completely New Recipe' -about: 'If would like to see a completely new recipe' -title: '[request] /' -labels: 'library request' ---- - -### Package Details - * Package Name/Version: **cmake/3.15.3** - * Website: **https://cmake.org/** - * Source code: **https://github.com/Kitware/CMake** - - -### Description Of The Library / Tool diff --git a/.github/ISSUE_TEMPLATE/package_upstream_update.md b/.github/ISSUE_TEMPLATE/package_upstream_update.md deleted file mode 100644 index 15db000618746..0000000000000 --- a/.github/ISSUE_TEMPLATE/package_upstream_update.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -name: 'Package: New Version' -about: 'If an existing package recipe needs an update for a new upstream version' -title: '[request] /' -labels: 'upstream update' ---- - -### Package Details - * Package Name/Version: **cmake/3.15.3** - * Changelog: **https://cmake.org/cmake/help/latest/release/3.15.html** - - -The above mentioned version is newly released by the upstream project and not yet available as a recipe. Please add this version. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md deleted file mode 100644 index 226701a9fa97c..0000000000000 --- a/.github/ISSUE_TEMPLATE/question.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: 'Question' -about: 'If something needs clarification' -title: '[question] SHORT DESCRIPTION' -labels: question ---- - - diff --git a/.github/ISSUE_TEMPLATE/service.md b/.github/ISSUE_TEMPLATE/service.md deleted file mode 100644 index d0b1cf7de1921..0000000000000 --- a/.github/ISSUE_TEMPLATE/service.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: 'Service: Infrastructure Bugs Or Requests' -about: 'Bug or feature requests for Conan Center Index itself' -title: '[service] SHORT DESCRIPTION' -labels: service ---- - - diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index edb988e0d2576..961ab760931ec 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,11 +1,13 @@ -Specify library name and version: **lib/1.0** +- _List changes here_ +- -This is also a good place to share with all of us **why you are submitting this PR** (specially if it is a new addition to ConanCenter): is it a dependency of other libraries you want to package? Are you the author of the library? Thanks! +#### Fulfills JIRA issue [EXAMPLE-1](https://jira.datalogics.com/browse/EXAMPLE-1) ---- +#### Checklist for approving this pull request -- [ ] I've read the [guidelines](https://github.com/conan-io/conan-center-index/blob/master/docs/how_to_add_packages.md) for contributing. -- [ ] I've followed the [PEP8](https://www.python.org/dev/peps/pep-0008/) style guides for Python code in the recipes. -- [ ] I've used the [latest](https://github.com/conan-io/conan/releases/latest) Conan client version. -- [ ] I've tried at least one configuration locally with the - [conan-center hook](https://github.com/conan-io/hooks.git) activated. +(**PR Author:** amend this with more conditions if necessary)\ +(**PR Reviewer:** ensure all following items are fulfilled before merging) + +- [ ] The **Pull Request Title** has JIRA issue number, a space, and then a short but descriptive summary. +- [ ] **Commit messages** are well formed: [A note about Git commit messages](http://www.tpope.net/node/106) +- [ ] **Automated tests pass**. diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index f3a08a0c9f04e..0000000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,61 +0,0 @@ -# Configuration for probot-stale - https://github.com/probot/stale - -# Number of days of inactivity before an Issue or Pull Request becomes stale -daysUntilStale: 30 - -# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. -# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. -daysUntilClose: 30 - -# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) -onlyLabels: [] - -# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable -exemptLabels: - - blocked - - infrastructure - -# Set to true to ignore issues in a project (defaults to false) -exemptProjects: false - -# Set to true to ignore issues in a milestone (defaults to false) -exemptMilestones: false - -# Set to true to ignore issues with an assignee (defaults to false) -exemptAssignees: false - -# Label to use when marking as stale -staleLabel: stale - -# Comment to post when marking as stale. Set to `false` to disable -markComment: > - This pull request has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. - -# Comment to post when removing the stale label. -# unmarkComment: > -# Your comment here. - -# Comment to post when closing a stale Issue or Pull Request. -closeComment: > - This pull request has been automatically closed because it has not had - recent activity. Thank you for your contributions. - -# Limit the number of actions per hour, from 1-30. Default is 30 -limitPerRun: 30 - -# Limit to only `issues` or `pulls` -only: pulls - -# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': -# pulls: -# daysUntilStale: 30 -# markComment: > -# This pull request has been automatically marked as stale because it has not had -# recent activity. It will be closed if no further activity occurs. Thank you -# for your contributions. - -# issues: -# exemptLabels: -# - confirmed diff --git a/.github/workflows/on-push-do-doco.yml b/.github/workflows/on-push-do-doco.yml deleted file mode 100644 index d2fe3bb1ca021..0000000000000 --- a/.github/workflows/on-push-do-doco.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: docs_markdown_toc -on: - push: - branches: - - master - paths: - - 'docs/**' - -jobs: - docs_markdown_toc: - runs-on: windows-latest - steps: - - uses: actions/checkout@v2 - - name: Run MarkdownSnippets - run: | - dotnet tool install --global MarkdownSnippets.Tool - mdsnippets ${GITHUB_WORKSPACE} \ - --convention InPlaceOverwrite \ - --exclude-directories 'recipes' \ - --toc-level 5 - shell: bash - - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 - with: - branch: action-doc-toc - commit-message: "[docs] Regenerate tables of contents" - title: "[docs] Regenerate tables of contents" - body: "Automatic update of the documentation TOCs." diff --git a/.gitignore b/.gitignore index 80fae2cee25cb..cc55400706e30 100644 --- a/.gitignore +++ b/.gitignore @@ -1,24 +1,250 @@ +# Conan specific +**/test_package/build/ +**/test_package/test_output/ +conan.lock +conanbuildinfo.txt +conaninfo.txt +graph_info.json +build/ + +# CMake +CMakeUserPresets.json + # IDEs .idea +.vs .vscode .project .pydevproject .settings/ .ropeproject/ -## emacs +.devcontainer/ + +# Created by https://www.toptal.com/developers/gitignore/api/vim,git,linux,macos,emacs,python,windows,pycharm,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=vim,git,linux,macos,emacs,python,windows,pycharm,visualstudiocode + +### Emacs ### +# -*- mode: gitignore; -*- *~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* +# Org-mode +.org-id-locations +*_archive -# Byte-compiled / optimized / DLL files / Cache +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data + + +### Git ### +# Created by git for backups. To disable backups in Git: +# $ git config --global mergetool.keepBackup false +*.orig + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +### Linux ### + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### Python ### +# Byte-compiled / optimized / DLL files __pycache__/ -test_package/__pycache__/ -test_package/build/ -build/ +**/test_package/__pycache__/ *.pyc *.py[cod] *$py.class -tmp/ -.DS_Store # C extensions *.so @@ -27,7 +253,6 @@ tmp/ .Python build/ develop-eggs/ -dist/ downloads/ eggs/ .eggs/ @@ -37,6 +262,7 @@ parts/ sdist/ var/ wheels/ +share/python-wheels/ *.egg-info/ .installed.cfg *.egg @@ -55,14 +281,17 @@ pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ +.nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover +*.py,cover .hypothesis/ .pytest_cache/ +cover/ # Translations *.mo @@ -72,6 +301,7 @@ coverage.xml *.log local_settings.py db.sqlite3 +db.sqlite3-journal # Flask stuff: instance/ @@ -84,16 +314,34 @@ instance/ docs/_build/ # PyBuilder +.pybuilder/ target/ # Jupyter Notebook .ipynb_checkpoints +# IPython +profile_default/ +ipython_config.py + # pyenv -.python-version +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ -# celery beat schedule file +# Celery stuff celerybeat-schedule +celerybeat.pid # SageMath parsed files *.sage.py @@ -111,11 +359,122 @@ venv.bak/ .spyderproject .spyproject +# Rope project settings +.ropeproject + # mkdocs documentation /site # mypy .mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# Support for Project snippet scope +!.vscode/*.code-snippets + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/vim,git,linux,macos,emacs,python,windows,pycharm,visualstudiocode + +# Byte-compiled / optimized / DLL files / Cache +test_package/__pycache__/ +test_package/build/ +*.pyc +tmp/ + +# pyenv +.python-version + +# Environments +python-env-* +requirements.txt # scons build files *.dblite + +# vim temp files +.*.sw? +.sw? +Session.vim +*~ +.undodir + +# Test outputs +/test-report.xml +/test-report.html + +/.mkenv + +# outputs from invoke tasks +/.merge-upstream-status +/.merge-staging-to-production-status diff --git a/.jenkins/Jenkinsfile b/.jenkins/Jenkinsfile deleted file mode 100644 index cfbb0949d9cc8..0000000000000 --- a/.jenkins/Jenkinsfile +++ /dev/null @@ -1,3 +0,0 @@ -@Library('c3i') _ - -c3iManager.runBuild(this) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000000..30c434af64316 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,76 @@ +exclude: | + (?x)^( + .idea/.*| + assets/.*| + docs/.*| + linter/.*| + recipes/.*| + CONTRIBUTING.md + )$ +default_stages: [commit, manual] +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + args: [ --markdown-linebreak-ext=md ] + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: double-quote-string-fixer + - id: check-docstring-first + - id: debug-statements + - repo: https://github.com/PyCQA/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + - repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort + name: isort (python) + - repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: 2.4.0 + hooks: + - id: editorconfig-checker + - repo: https://github.com/executablebooks/mdformat + rev: 0.7.14 # Use the ref you want to point at + hooks: + - id: mdformat + name: mdformat on non-.github files + exclude: ^.github/ + args: [ '--wrap', '80', '--number' ] + # Optionally add plugins + additional_dependencies: + - mdformat-gfm + - mdformat-frontmatter + - mdformat-footnote + - mdformat-toc + - id: mdformat + name: mdformat on .github files + files: ^.github/.*$ + # Don't wrap the templates in .github; they don't look good in the description + args: [ '--wrap', 'no', '--number' ] + # Optionally add plugins + additional_dependencies: + - mdformat-gfm + - mdformat-frontmatter + - mdformat-footnote + - mdformat-toc + # pylint has to be run from inside the virtual environment, so it has access to all + # the modules imported by a given Python modules. + # See: https://pylint.pycqa.org/en/latest/user_guide/installation/pre-commit-integration.html#pre-commit-integration + - repo: local + hooks: + - id: pylint + name: pylint + entry: pylint + language: system + types: [ python ] + # only tasks are linted at present + files: ^tasks/.*$ + args: + [ + "-rn", # only display messages + "-sn", # don't display the score + ] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000000..8ae9c79089ea4 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,486 @@ +def ENV_LOC = [:] +// Which nodes build tools. The linux-x64-tools-conan-center-index is an older machine +// that uses an earlier glibc, so the tools will run on every machine. +def BUILD_TOOLS=[ + 'aix-conan-center-index': true, + 'linux-x64-rhws6-conan-center-index': true, + 'linux-x64-rhel7-conan-center-index': true, + 'linux-arm-conan-center-index': true, + 'mac-x64-conan-center-index': true, + 'mac-arm-conan-center-index': true, + 'sparcsolaris-conan-center-index': true, + 'windows-conan-center-index': true, +] +def skipBuilding = false +// Don't upload things if the job name has 'test' in it +// Converting matcher to boolean with asBoolean() or find(): https://stackoverflow.com/a/35529715/11996393 +def upload_ok = ! (env.JOB_NAME =~ 'test').find() + +pipeline { + parameters { + choice(name: 'PLATFORM_FILTER', + choices: ['all', + 'linux-x64-rhws6-conan-center-index', + 'linux-x64-rhel7-conan-center-index', + 'linux-arm-conan-center-index', + 'mac-x64-conan-center-index', + 'mac-arm-conan-center-index', + 'sparcsolaris-conan-center-index', + 'windows-conan-center-index'], + description: 'Run on specific platform') + booleanParam defaultValue: false, description: 'Completely clean the workspace before building, including the Conan cache', name: 'CLEAN_WORKSPACE' + string(name: 'PYTEST_OPTIONS', defaultValue: '', + description: 'Additional parameters for pytest, for instance, work on just swig with -k swig. See: https://docs.pytest.org/en/7.1.x/how-to/usage.html') + booleanParam name: 'UPLOAD_ALL_RECIPES', defaultValue: false, + description: 'Upload all recipes, instead of only recipes that changed since the last merge' + booleanParam name: 'FORCE_TOOL_BUILD', defaultValue: false, + description: 'Force build of all tools. By default, Conan will download the tool and test it if it\'s already built' + booleanParam name: 'FORCE_TOOL_BUILD_WITH_REQUIREMENTS', defaultValue: false, + description: 'Force build of all tools, and their requirements. By default, Conan will download the tool and test it if it\'s already built' + booleanParam name: 'MERGE_UPSTREAM', defaultValue: false, + description: 'If building develop branch, merge changes from upstream, i.e., conan-io/conan-center-index' + booleanParam name: 'MERGE_STAGING_TO_PRODUCTION', defaultValue: false, + description: 'If building master branch, merge changes from the develop branch' + } + options{ + buildDiscarder logRotator(artifactDaysToKeepStr: '4', artifactNumToKeepStr: '10', daysToKeepStr: '7', numToKeepStr: '10') + disableConcurrentBuilds() + } + agent { + node { + label 'noarch-conan-center-index' + customWorkspace "workspace/${JOB_NAME.replaceAll('/','_')}_noarch/" + } + } + triggers { + // From the doc: @midnight actually means some time between 12:00 AM and 2:59 AM. + // This gives us automatic spreading out of jobs, so they don't cause load spikes. + parameterizedCron(env.BRANCH_NAME =~ 'develop' ? '@midnight % MERGE_UPSTREAM=true' : '@midnight') + } + environment { + CONAN_USER_HOME = "${WORKSPACE}" + CONAN_NON_INTERACTIVE = '1' + CONAN_PRINT_RUN_COMMANDS = '1' + // Disable FileTracker on Windows, which can give FTK1011 on long path names + TRACKFILEACCESS = 'false' + // Disable node reuse, which gives intermittent build errors on Windows + MSBUILDDISABLENODEREUSE = '1' + // AIX workaround. Avoids an issue caused by the jenkins java process which sets + // LIBPATH and causes errors downstream + LIBPATH = "randomval" + DL_CONAN_CENTER_INDEX = 'all' + TOX_TESTENV_PASSENV = 'CONAN_USER_HOME CONAN_NON_INTERACTIVE CONAN_PRINT_RUN_COMMANDS CONAN_LOGIN_USERNAME CONAN_PASSWORD TRACKFILEACCESS MSBUILDDISABLENODEREUSE' + // Create a personal access token on the devauto account on Octocat with repo and read:org access, and use it to + // create a secret text credential with the name github-cli-devauto-octocat-access-token + // See: https://cli.github.com/manual/gh_auth_login + GH_ENTERPRISE_TOKEN = credentials('github-cli-devauto-octocat-access-token') + // When using the token above 'gh help environment' says to also set GH_HOST + // https://cli.github.com/manual/gh_help_environment + GH_HOST = 'octocat.dlogics.com' + } + stages { + stage('Clean/reset Git checkout for release') { + when { + anyOf { + expression { params.CLEAN_WORKSPACE } + } + } + steps { + echo "Clean noarch" + script { + // Ensure that the checkout is clean and any changes + // to .gitattributes and .gitignore have been taken + // into effect + // + // The extra -f causes Git to delete even embedded Git + // repositories, which can happen if the Conan cache + // is in ./.conan, and a recipe (like SWIG) checks out + // its code with Git. + // + // See: https://git-scm.com/docs/git-clean#Documentation/git-clean.txt--f + if (isUnix()) { + sh """ + git rm -q -r . + git reset --hard HEAD + git clean -f -fdx + """ + } else { + // On Windows, 'git clean' can't handle long paths in .conan, + // so remove that first. + bat """ + if exist ${WORKSPACE}\\.conan\\ rmdir/s/q ${WORKSPACE}\\.conan + git rm -q -r . + git reset --hard HEAD + git clean -f -fdx + """ + } + } + } + } + stage('Set-Up Environment') { + steps { + printPlatformNameInStep('noarch') + echo "Set-Up Environment noarch" + script { + if (isUnix()) { + sh './mkenv.py --verbose' + ENV_LOC['noarch'] = sh ( + script: './mkenv.py --env-name', + returnStdout: true + ).trim() + } else { + // Using the mkenv.py script like this assumes the Python Launcher is + // installed on the Windows host. + // https://docs.python.org/3/using/windows.html#launcher + bat '.\\mkenv.py --verbose' + ENV_LOC['noarch'] = bat ( + // The @ prevents Windows from echoing the command itself into the stdout, + // which would corrupt the value of the returned data. + script: '@.\\mkenv.py --env-name', + returnStdout: true + ).trim() + } + } + } + } + stage('Set up Conan') { + steps { + sh """. ${ENV_LOC['noarch']}/bin/activate + invoke conan.login""" + } + } + stage('flake8') { + steps { + catchError(message: 'flake8 had errors', stageResult: 'FAILURE') { + script { + sh """. ${ENV_LOC['noarch']}/bin/activate + rm -f flake8.log + flake8 --format=pylint --output=flake8.log --tee""" + } + } + } + post { + always { + recordIssues(enabledForFailure: true, + tool: flake8(pattern: 'flake8.log'), + qualityGates: [[threshold: 1, type: 'TOTAL', unstable: false]]) + } + } + } + stage('Pre-commit checks') { + when { + changeRequest() + } + steps { + catchError(message: 'pre-commit had errors', stageResult: 'FAILURE') { + script { + if (isUnix()) { + sh """ + . ${ENV_LOC['noarch']}/bin/activate + invoke jenkins.pre-commit + """ + } else { + bat """ + CALL ${ENV_LOC['noarch']}\\Scripts\\activate + invoke jenkins.pre-commit + """ + } + } + } + } + } + stage('Merge from upstream') { + when { + expression { + // Merge upstream on develop-prefixed branches if forced by parameter + // The parametrized Cron timer sets MERGE_UPSTREAM at appropriate times. + env.BRANCH_NAME =~ 'develop' && params.MERGE_UPSTREAM + } + } + steps { + script { + sh """ + . ${ENV_LOC['noarch']}/bin/activate + invoke merge-upstream + """ + def merge_upstream_status = readFile(file: '.merge-upstream-status') + echo "merge-upstream status is ${merge_upstream_status}" + // If the status of the upstream merge is MERGED, then don't do anything + // else; Jenkins will notice the branch changed and re-run. + skipBuilding = merge_upstream_status == 'MERGED' + } + } + } + stage('Merge staging to production') { + when { + expression { + // Merge upstream on master-prefixed branches if forced by parameter + env.BRANCH_NAME =~ 'master' && params.MERGE_STAGING_TO_PRODUCTION + } + } + steps { + script { + sh """ + . ${ENV_LOC['noarch']}/bin/activate + invoke merge-staging-to-production + """ + def merge_staging_to_production_status = readFile(file: '.merge-staging-to-production-status') + echo "merge-staging-to-production status is ${merge_staging_to_production_status}" + // If the status of the merge is MERGED, then don't do anything + // else; Jenkins will notice the branch changed and re-run. + skipBuilding = merge_staging_to_production_status == 'MERGED' + } + } + } + stage('Upload new or changed recipes') { + when { + allOf { + expression { !skipBuilding && upload_ok } + not { changeRequest() } + } + } + steps { + script { + def remote + if (env.BRANCH_NAME =~ 'master') { + remote = 'conan-center-dl' + } else { + remote = 'conan-center-dl-staging' + } + def range + if (params.UPLOAD_ALL_RECIPES) { + range = '--all' + } else { + // make sure conan-io is available and up-to-date + sh "git remote | grep conan-io || git remote add conan-io https://github.com/conan-io/conan-center-index.git" + sh "git fetch conan-io" + // assuming this is due to a merge, upload recipes + // modified since just before the last merge. This is an + // incremental update to recipes, and will be much faster + // than uploading all 1100+ recipes. + range = "--since-before-last-merge --since-merge-from-branch=conan-io/master" + } + sh ". ${ENV_LOC['noarch']}/bin/activate; invoke upload-recipes --remote ${remote} ${range}" + } + } + } + stage('Per-platform') { + matrix { + agent { + node { + label "${NODE}" + customWorkspace "workspace/${JOB_NAME.replaceAll('/','_')}/" + } + } + when { anyOf { + expression { params.PLATFORM_FILTER == 'all' && !skipBuilding } + expression { params.PLATFORM_FILTER == env.NODE && !skipBuilding } + } } + axes { + axis { + name 'NODE' + values 'linux-x64-rhws6-conan-center-index', + 'linux-x64-rhel7-conan-center-index', + 'linux-arm-conan-center-index', + 'mac-x64-conan-center-index', + 'mac-arm-conan-center-index', + 'sparcsolaris-conan-center-index', + 'windows-conan-center-index' + } + } + environment { + CONAN_USER_HOME = "${WORKSPACE}" + DL_CONAN_CENTER_INDEX = productionOrStaging() + } + stages { + stage('Clean/reset Git checkout for release') { + when { + anyOf { + expression { params.CLEAN_WORKSPACE } + } + } + steps { + echo "Clean ${NODE}" + script { + // Ensure that the checkout is clean and any changes + // to .gitattributes and .gitignore have been taken + // into effect + if (isUnix()) { + sh """ + git rm -q -r . + git reset --hard HEAD + git clean -f -fdx + """ + } else { + // On Windows, 'git clean' can't handle long paths in .conan, + // so remove that first. + bat """ + if exist ${WORKSPACE}\\.conan\\ rmdir/s/q ${WORKSPACE}\\.conan + git rm -q -r . + git reset --hard HEAD + git clean -f -fdx + """ + } + } + } + } + stage('Set-Up Environment') { + steps { + printPlatformNameInStep(NODE) + echo "Set-Up Environment ${NODE}" + script { + if (isUnix()) { + sh './mkenv.py --verbose' + ENV_LOC[NODE] = sh ( + script: './mkenv.py --env-name', + returnStdout: true + ).trim() + } else { + // Using the mkenv.py script like this assumes the Python Launcher is + // installed on the Windows host. + // https://docs.python.org/3/using/windows.html#launcher + bat '.\\mkenv.py --verbose' + ENV_LOC[NODE] = bat ( + // The @ prevents Windows from echoing the command itself into the stdout, + // which would corrupt the value of the returned data. + script: '@.\\mkenv.py --env-name', + returnStdout: true + ).trim() + } + } + } + } + stage('Print environment') { + steps { + script { + if (isUnix()) { + sh "env" + } else { + bat "set" + } + } + } + } + stage('Set up Conan') { + steps { + script { + if (isUnix()) { + sh """. ${ENV_LOC[NODE]}/bin/activate + invoke conan.login""" + } else { + bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate + invoke conan.login""" + } + } + } + } + stage('build tools') { + when { + expression { BUILD_TOOLS[NODE] } + } + steps { + script { + def upload = "" + if (env.CHANGE_ID == null && upload_ok) { // i.e. not a pull request, and uploads are permitted + if (env.BRANCH_NAME =~ 'master') { + upload = '--upload-to conan-center-dl' + } else { + upload = '--upload-to conan-center-dl-staging' + } + } + def short_node = NODE.replace('-conan-center-index', '') + def force_build + if (params.FORCE_TOOL_BUILD_WITH_REQUIREMENTS) { + force_build = '--force-build with-requirements' + } else if (params.FORCE_TOOL_BUILD) { + force_build = '--force-build' + } else { + force_build = '' + } + def pytest_command = "pytest -k build_tool ${force_build} ${upload} --junitxml=build-tools.xml --html=${short_node}-build-tools.html ${params.PYTEST_OPTIONS}" + if (isUnix()) { + catchError(message: 'pytest had errors', stageResult: 'FAILURE') { + script { + // on macOS, /usr/local/bin is not in the path by default, and the + // Python binaries tox is looking for may be in there + sh """. ${ENV_LOC[NODE]}/bin/activate + (env PATH=\$PATH:/usr/local/bin ${pytest_command})""" + } + } + } + else { + catchError(message: 'pytest had errors', stageResult: 'FAILURE') { + script { + bat """CALL ${ENV_LOC[NODE]}\\Scripts\\activate + ${pytest_command}""" + } + } + } + } + } + post { + always { + catchError(message: 'testing had errors', stageResult: 'FAILURE') { + xunit ( + reduceLog: false, + tools: [ + JUnit(deleteOutputFiles: true, + failIfNotNew: true, + pattern: 'build-tools.xml', + skipNoTestFiles: true, + stopProcessingIfError: true) + ]) + archiveArtifacts allowEmptyArchive: true, artifacts: '*-build-tools.html', followSymlinks: false + } + } + } + } + } + } + } + } + post { + unsuccessful { + script { + if (env.CHANGE_ID == null) { // i.e. not a pull request; those notify in GitHub + slackSend(channel: "#conan", + message: "Unsuccessful build: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", + color: "danger") + } + } + } + fixed { + script { + if (env.CHANGE_ID == null) { // i.e. not a pull request; those notify in GitHub + slackSend(channel: "#conan", + message: "Build is now working: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", + color: "good") + } + } + } + } +} + +void productionOrStaging() { + if (env.CHANGE_ID == null) { + if (env.BRANCH_NAME =~ 'master') { + return 'production' + } else { + return 'staging' + } + } else { + if (env.CHANGE_BRANCH =~ 'master') { + return 'production' + } else { + return 'staging' + } + } +} + +void printPlatformNameInStep(String node) { + script { + stage("Building on ${node}") { + echo "Building on node: ${node}" + } + } +} diff --git a/README.md b/README.md index 4271f733a4c67..76568fee4314e 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,16 @@ -

- -

+# conan-center-index -Conan Center Index is the source index of recipes of the [ConanCenter](https://conan.io/center) package repository for [Conan](https://conan.io). +This is the Datalogics fork of +[conan-io/conan-center-index](https://github.com/conan-io/conan-center-index). -This repository includes a Continuous Integration system that will build automatically the Conan packages for the recipes submitted via -[Pull Request](https://github.com/conan-io/conan-center-index/pulls). +It contains curated branches, and Datalogics-local modifications of recipes. +It also has Invoke tasks and CI implementations that: -### Documentation +- Upload recipes to our own repositories on Artifactory. +- Pre-build tools with specific profiles and upload them to Artifactory. -All the documentation is available in this same repository in the [`docs/` subfolder](docs/README.md). +## DL Documentation -This is a list of shortcuts to some interesting topics: - -* :rocket: If you want to learn how to **contribute new recipes**, please read [docs/how_to_add_packages.md](docs/how_to_add_packages.md). -* :speech_balloon: **FAQ**: most common questions are listed in [docs/faqs.md](docs/faqs.md). -* :warning: The conan-center **hook errors** reported by CCI Bot can be found in the [docs/error_knowledge_base.md](docs/error_knowledge_base.md). -* :hammer_and_wrench: The internal changes related to infrastructure can be checked in [docs/changelog.md](docs/changelog.md). -* :world_map: There are various community lead initiatives which are outlined in [docs/community_resources.md](docs/community_resources.md). - -### Reporting Issues - -You can open issues in the [issue tracker](https://github.com/conan-io/conan-center-index/issues) to: - -* :bug: Report **bugs/issues** in a package: - - Use the `[package]` tag in the title of the issue to help identifying them. - - If you detect any issue or missing feature in a package, for example, a build failure or a recipe that not support a specific configuration. - - Specify the name and version (`zlib/1.2.11`) and any relevant details about the fail configuration: Applied profile, building machine... - -* :bulb: Request a **new library** to be added: - - Use the `[request]` label to search the library in the issue tracker in case the it was already requested. - - If not, use the same `[request]` tag in the title of the issue to help identifying them. - - Indicate the name and the version of the library you would like to have in the repository. Also links to the project's website, - source download/repository and in general any relevant information that helps creating a recipe for it. - -* :robot: Report **a failure** in the CI system: - - If you open a Pull Request and get an unexpected error you might comment in the failing PR. - - If the service or repository is down or failing, use the `[service]` tag in the title of a new issue to help identifying them. - -If your issue is not appropriate for a public discussion, please contact us via e-mail at `info@conan.io`. Thanks! - - -### License - -[MIT](LICENSE) +- [`merge-upstream` task](dl-docs/merge-upstream.md) + - [Automatically Resolved Merge Conflicts](dl-docs/auto-merge-conflict-resolution.md) diff --git a/dl-docs/auto-merge-conflict-resolution.md b/dl-docs/auto-merge-conflict-resolution.md new file mode 100644 index 0000000000000..f0fb362f0a9eb --- /dev/null +++ b/dl-docs/auto-merge-conflict-resolution.md @@ -0,0 +1,82 @@ +# Automatically resolved merge conflicts + +conan-center-index at DL is a fork of the conan-io/conan-center-index repo run +by the Conan project. There is some project metadata that has the same names ( +such as the `.github` directory and `README.md`), and as such, there is +potential for merge conflicts. + +The `invoke merge-upstream` task can automatically resolve some of those merge +conflicts. + + + +- [Files that both conan-io and Datalogics modify](#files-that-both-conan-io-and-datalogics-modify) + - [Why `.gitattributes-merge` and not `.gitattributes`?](#why-gitattributes-merge-and-not-gitattributes) + - [Verifying the coverage of `.gitattributes-merge`](#verifying-the-coverage-of-gitattributes-merge) +- [Files that Datalogics has deleted](#files-that-datalogics-has-deleted) +- [References](#references) + + + +## Files that both conan-io and Datalogics modify + +For files that both conan-io and Datalogics modify, add them to the +`.gitattributes-merge` file with an attribute of `merge=ours`. The +`invoke merge-upstream` task arranges for there to be a merge driver called +"ours", which resolves modify/modify conflicts in favor of "our" branch, i.e., +Datalogics. + +As an example, this file currently contains: + +``` +# Conflicts that should always resolve in favor of Datalogics +# See the section "Merge Strategies" at the end of +# https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Attributes +/README.md merge=ours +/.github/** merge=ours +``` + +### Why `.gitattributes-merge` and not `.gitattributes`? + +It's not possible to use custom merge drivers on GitHub, so if the `merge=ours` +attributes were put into the `.gitattributes` file, it would cause problems with +merges done by GitHub. To avoid breaking GitHub, this project uses the separate +file `.gitattributes-merge`, and uses the +[`core.attributesFile`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreattributesFile) +configuration option to add it to the list of attributes files. + +### Verifying the coverage of `.gitattributes-merge` + +To verify the coverage of `.gitattributes-merge`, use the +[`git check-attr`](https://git-scm.com/docs/git-check-attr) command to search +for the merge attributes on files. +[`git ls-files`](https://git-scm.com/docs/git-ls-files) lists files that are +part of the repository, and use `grep` to ignore files that have unspecified +merge attributes. + +```bash +$ git ls-files | git -c core.attributesFile=.gitattributes-merge check-attr --stdin merge | grep -v 'merge: unspecified' +.github/PULL_REQUEST_TEMPLATE.md: merge: ours +README.md: merge: ours +``` + +## Files that Datalogics has deleted + +If there are files that Datalogics has deleted, but conan-io has modified, those +files are automatically resolved in favor of Datalogics, by removing them. + +If we decide we need those files, one can bring them into the Datalogics fork by +using commands like the following: + +```shell +git remote add conan-io git@github.com:conan-io/conan-center-index.git +git fetch conan-io +git checkout conan-io/master -- +git commit +``` + +...and then making a pull request. + +## References + +- [Git documentation: 8.2 Customizing Git - Git Attributes](https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Attributes) diff --git a/dl-docs/merge-upstream.md b/dl-docs/merge-upstream.md new file mode 100644 index 0000000000000..2124769bf99d5 --- /dev/null +++ b/dl-docs/merge-upstream.md @@ -0,0 +1,102 @@ +# `merge-upstream` task + +The `invoke merge-upstream` task fetches the latest `master` branch from the +[`conan-io/conan-center-index`](https://github.com/conan-io/conan-center-index) +repository, and merges it into the `develop` branch. + + + +- [Operation](#operation) + - [Nuances](#nuances) +- [Configuration](#configuration) +- [When it runs](#when-it-runs) +- [See also](#see-also) + + + +## Operation + +1. Check for preconditions: The repository is not dirty, the `gh` + [GitHub CLI](https://cli.github.com/) command is installed, and the `gh` + command is logged in to Octocat. +2. Fetch the `master` branch from `conan-io/conan-center-index`. +3. Attempt to merge it into the `develop` branch, automatically resolving some + merge conflicts in favor of Datalogics' changes as specified in + `.gitattributes-merge`. +4. If there are any merge conflicts that resulted from the Conan project + modifying files that Datalogics deleted, resolve those in favor of the + Datalogics deletion. This means we can delete GitHub templates and the like, + so they don't affect the way we use our fork. +5. If merge conflicts remain, create a pull request in the current user's fork, + using a copy of the `master` branch at `conan-io/conan-center-index`. A + developer will have to review and resolve the merge conflicts, and approve + the PR. The assignee and reviewers for the pull request can be configured. +6. If there were no merge conflicts, then push the merge to the `develop` + branch. + +### Nuances + +- If there is already a pull request due to a merge conflict, and + `merge-upstream` discovers more new commits in `conan-io/conan-center-index`, + then it updates the pull request instead of making a new one. +- The credentials in the Jenkins job are passed by setting `GH_ENTERPRISE_TOKEN` + and `GH_HOST` in the environment. See the comment in the `Jenkinsfile` for how + to make a token and store it in Kepler. + +## Configuration + +The configuration is controlled by the `merge_upstream` key in `dlproject.yaml`. +Any unspecified values will get the following defaults. + +The defaults are: + +```yaml +merge_upstream: + cci: + url: git@github.com:conan-io/conan-center-index.git + branch: master + upstream: + host: octocat.dlogics.com + organization: datalogics + branch: develop + remote_name: merge-upstream-remote + pull_request: + host: octocat.dlogics.com + fork: + merge_branch_name: merge-from-conan-io + reviewers: [ ] + assignee: null + labels: + - from-conan-io +``` + +One use of this would be to use a personal fork for testing, to avoid polluting +the Datalogics organization repo: + +```yaml +merge_upstream: + upstream: + # Temporary overrides + organization: kam +``` + +## When it runs + +- When Jenkins builds the `develop` branch triggered by the `parameterizedCron` + statement in the `triggers` section of the `Jenkinsfile`, when the + `MERGE_UPSTREAM` parameter is set. As of this writing, the merge occurs + nightly. There's enough flexibility in the Cron triggers to permit, for + instance, only doing the merges on the weekends. +- By going to the `develop` branch of `conan-center-index` on Jenkins and doing + a **Build with parameters**, and clicking the **MERGE_UPSTREAM** parameter. +- By invoking `invoke merge-upstream` from the command line. This should only be + done when developing and testing; for everyday use, request the merge via + Jenkins. + +If Jenkins runs `invoke merge-upstream`, and the branch was successfully pushed, +it skips the rest of the job. Updating the `develop` branch will trigger a +following job with the new commits. + +## See also + +- [Automatically Resolved Merge Conflicts](auto-merge-conflict-resolution.md) diff --git a/dlproject.yaml b/dlproject.yaml new file mode 100644 index 0000000000000..f7a26a8395c5b --- /dev/null +++ b/dlproject.yaml @@ -0,0 +1,700 @@ +# Config file for the project. Used by the Invoke tasks, primarily. +config: + # Basic configuration variables + global: + # Base configurations, may be overridden by platform + + # Conan configuration. `conan config install` installs configuration file from this URL. + # See: https://docs.conan.io/en/latest/reference/commands/consumer/config.html#conan-config-install + # This is usually a pointer to a Git repo, from which it clones the repo. + # The config_args are passed to the 'git clone' command and can select + # a branch or tag + config_url: git@octocat.dlogics.com:datalogics/conan-config.git + config_args: --branch curated-conan-center-index + + # Conan profile that's used to configure the compiler + # default is the profile Conan makes in the user's home directory + profile: + - default + + # It's possible to use a list of profiles. + # For instance, this can be used to add a profile that has build + # tools in the [build_requires] section, making those tools available + # to the locally-built project via the conan.install task. + # + # Of course, the profile can be placed in a platform dictionary as well. + # profile: + # - default + # - build_tools + + # Multiple build configurations in the IDE + multi: false + + # Regex that indicates a release branch + stable_branch_pattern: release-.* + + # Which dependencies are built. Takes a number of keywords, also the names + # of packages, which can also contain a wildcard. + # See https://docs.conan.io/en/latest/reference/commands/consumer/install.html#build-options + # for the full list of options. + build: + - missing + + # CMake project generator + # Set this based on the build system the project uses + # (on Mac, this may be overridden to Xcode if bootstrap-xcode is run) + # Note: if unset, the Conan CMake build helper will choose the generator + # automatically, including using the correct Visual Studio generator on + # Windows + # cmake_generator: Unix Makefiles + + # options for the ConanMultiPackager + # These state which compilers and architectures are built when doing conan.package + packager: + # Build tools. This profile is installed to a temporary directory to + # provide tools for building packages via the + # conan.install-all-configurations or conan.package tasks. + # + # Optional. Add this to your project if you want to automatically + # include build tools. May also be customized per platform. + # build_tools: build_tools + + archs: + - x86_64 + apple_clang_versions: + # quirk: must be string + - "9.1" + visual_versions: + # Visual Studio + # quirk: must be integer + - 12 + # Specify the toolsets for which this package should be built. + # There is a key for each visual_version, which is a list of + # toolset designators. + # Quirk: The compiler version keys must be strings. + # visual_toolsets: + # "16": + # - v141 + visual_runtimes: + # Permitted runtime versions for Visual Studio. + - MT + - MD + - MTd + - MDd + # Set this to False to make the package set up the vcvars before the build. + # But beware, this can mess up some recipes, especially if toolsets are around. + exclude_vcvars_precommand: True + clang_versions: + # quirk: must be string + - "5.0" + # gcc_versions: + # # quirk: must be string + # - "7" + # cppstds: + # # quirk: must be string + # - "11" + # libcxx: + # # Permitted libcxx settings + # - stdlibc++ + shared: + # Permitted states for the shared option. + - True + - False + + # Build types. If missing, defaults to Debug and Release. + # build_types: + # - Debug + # - Release + + # You can also add additional options with values; all of these + # will be passed through to each package build. + # options: + # some_option: "some_value" + + # You can also add additional settings with values; all of these + # will be passed through to each package build. + # settings: + # some_setting: "some_value" + + # Allow making DLLs with static runtimes. + # Normally, that's not done, but set this to True to allow + # those special cases into the build matrix. + dll_with_static_runtime: False + + # Set to True if this is a pure C project + pure_c: False + + # Set to True if this project supports a header_only option + header_only: False + + # Configs based on platform information + # + # Keys can be (and are merged in this order) + # + # system + # system-machine + # system-version + # system-version-machine + # + # Where: + # system is macos, windows, or the name of the linux distribution (redhat includes centos) + # version is the major version number (major.minor on macos) + # machine is the processor architecture, i.e. x86_64 + # + # items from global and modify them here. + # When merging: + # Dictionary keys override the base + # Lists are appended + + macos-x86_64: + # Per-platform profiles can be set here. Profiles can be a string or a + # list of strings as seen below. By using a list, the build_tools + # profile can be added, and adds the build tools for development builds. + # + # profile: + # - apple-clang-10.0-macos-10.9 + # - build_tools + common: &macOSCommon + # Note: split build/host profiles aren't supported by recipes in Conan Center Index + # profile_build: + # - apple-clang-12.0-macos-10.9-cppstd-14 + build: + - missing + config: + Release: &macOSRelease + <<: *macOSCommon + build_folder: build-release + description: macOS Release + profile_host: + - apple-clang-13.0-intel-cppstd-14 + Debug: &macOSDebug + <<: *macOSRelease + build_folder: build + description: macOS Debug + settings: + - build_type=Debug + ReleaseTool: &macOSReleaseTool + <<: *macOSCommon + build_folder: build-release + description: macOS Release + profile_host: + - build-profile-macos-intel + DebugTool: &macOSDebugTool + include: + - ReleaseTool + build_folder: build + description: macOS Debug + settings: + - build_type=Debug + # If the entry is a string, it's taken to be the package name, + # else the entry can be a dictionary of package name and options + prebuilt_tools: + - cmake/[>=3.23.0] + - doxygen/1.9.1 + - doxygen/1.9.2 + - package: doxygen/1.9.1 + options: + - doxygen:enable_search=False + - package: doxygen/1.9.2 + options: + - doxygen:enable_search=False + - ninja/[~1.10.0] + - ninja/[>=1.0.0] + - b2/4.8.0 + - b2/4.9.2 + # Here, and afterward, building pcre without bzip2, because DLE + # sets that option in its conanfile.py. Currently, the only + # tool being built that uses bzip2 or pcre is SWIG. + # TODO: Should this be in the build-profile-* ? + - package: swig/1.3.40+dl.1 + options: + - pcre:with_bzip2=False + - package: swig/4.0.2+dl.2 + options: + - pcre:with_bzip2=False + prebuilt_tools_configs: + - ReleaseTool + + + macos-arm64: + # Per-platform profiles can be set here. Profiles can be a string or a + # list of strings as seen below. By using a list, the build_tools + # profile can be added, and adds the build tools for development builds. + # + # profile: + # - apple-clang-10.0-macos-10.9 + # - build_tools + config: + Release: + <<: *macOSCommon + build_folder: build-release + description: macOS Release + profile_host: + - apple-clang-13.0-arm-cppstd-14 + Debug: + <<: *macOSRelease + build_folder: build + description: macOS Debug + settings: + - build_type=Debug + ReleaseTool: + <<: *macOSCommon + build_folder: build-release + description: macOS Release + profile_host: + - build-profile-macos-arm + DebugTool: + include: + - ReleaseTool + build_folder: build + description: macOS Debug + settings: + - build_type=Debug + # If the entry is a string, it's taken to be the package name, + # else the entry can be a dictionary of package name and options + prebuilt_tools: + - cmake/[>=3.23.0] + - doxygen/1.9.1 + - doxygen/1.9.2 + - package: doxygen/1.9.1 + options: + - doxygen:enable_search=False + - package: doxygen/1.9.2 + options: + - doxygen:enable_search=False + - ninja/[~1.10.0] + - ninja/[>=1.0.0] + - b2/4.8.0 + - b2/4.9.2 + - package: swig/1.3.40+dl.1 + options: + - pcre:with_bzip2=False + - package: swig/4.0.2+dl.2 + options: + - pcre:with_bzip2=False + prebuilt_tools_configs: + - ReleaseTool + + + redhat-6-x86_64: + common: &redhatCommon + build: + - missing + config: &redhat6Config + Release: &redhatRelease + <<: *redhatCommon + build_folder: build-release + description: RedHat Release + profile_host: + - llvm-toolset-7-cppstd-14 + Debug: &redhatDebug + <<: *redhatRelease + build_folder: build-debug + description: RedHat Debug + settings: + - build_type=Debug + Release32: &redhatRelease32 + <<: *redhatCommon + build_folder: build-release-32 + description: RedHat Release 32 + profile_host: + - llvm-toolset-7-cppstd-14 + settings: + - arch=x86 + Debug32: &redhatDebug32 + <<: *redhatRelease32 + build_folder: build-debug-32 + description: RedHat Debug 32 + settings: + - build_type=Debug + ReleaseTool: &redhatReleaseTool + <<: *redhatCommon + build_folder: build-release-tool + description: RedHat Release Tool + profile_host: + - build-profile-linux-intel + DebugTool: &redhatDebugTool + include: ReleaseTool + build_folder: build-debug-tool + description: RedHat Debug Tool + settings: + - build_type=Debug + ReleaseTool32: &redhatReleaseTool32 + include: ReleaseTool + build_folder: build-release-tool-32 + description: RedHat Release Tool 32 + settings: + - arch=x86 + DebugTool32: &redhatDebugTool32 + include: ReleaseTool32 + build_folder: build-debug-tool-32 + description: RedHat Debug Tool 32 + settings: + - build_type=Debug + prebuilt_tools: &redhat6Tools + - package: cmake/[>=3.23.0] + - package: doxygen/1.9.1 + - package: doxygen/1.9.2 + - package: doxygen/1.9.1 + options: + - doxygen:enable_search=False + - package: doxygen/1.9.2 + options: + - doxygen:enable_search=False + - package: ninja/[~1.10.0] + - b2/4.8.0 + - b2/4.9.2 + - package: swig/1.3.40+dl.1 + options: + - pcre:with_bzip2=False + - package: swig/4.0.2+dl.2 + options: + - pcre:with_bzip2=False + prebuilt_tools_configs: + # Build 64-bit tools on RHEL 6, because they're used for 64-bit DLE for APDFL 15 + - ReleaseTool + + redhat-7-x86_64: + config: *redhat6Config + prebuilt_tools: + - ninja/[>=1.0.0] + prebuilt_tools_configs: + - ReleaseTool + + redhat-aarch64: + common: &redhatARMCommon + build: + - missing + config: + Release: &redhatARMRelease + <<: *redhatARMCommon + build_folder: build-release + description: RedHat Release + profile_host: + - llvm-toolset-7.0-armv8 + Debug: &redhatARMDebug + <<: *redhatARMRelease + build_folder: build-debug + description: RedHat Debug + settings: + - build_type=Debug + ReleaseTool: + build_folder: build-release-tool + description: RedHat Release + profile_host: + - build-profile-linux-arm + DebugTool: + build_folder: build-debug-tool + description: RedHat Debug + include: + - ReleaseTool + settings: + - build_type=Debug + prebuilt_tools: + - cmake/[>=3.23.0] + - doxygen/1.9.1 + - doxygen/1.9.2 + - package: doxygen/1.9.1 + options: + - doxygen:enable_search=False + - package: doxygen/1.9.2 + options: + - doxygen:enable_search=False + - ninja/[~1.10.0] + - ninja/[>=1.0.0] + - b2/4.8.0 + - b2/4.9.2 + - package: swig/1.3.40+dl.1 + options: + - pcre:with_bzip2=False + - package: swig/4.0.2+dl.2 + options: + - pcre:with_bzip2=False + prebuilt_tools_configs: + - ReleaseTool + + windows: + # Can set the generator differently on a per-machine basis (but automatic is + # better) + # cmake_generator: Visual Studio 12 2013 Win64 + multi: true + + # Can override packager build_tools on a per-platform basis: + # packager: + # build_tools: build_tools_windows + config: + Release: + build_folder: build-release + description: Windows Release + profile_host: visual-studio-16 + settings: + compiler.toolset=v141 + build: + - missing + Debug: &windowsDebug + include: Release + build_folder: build-debug + description: Windows Debug + settings: + - build_type=Debug + Release32: + include: Release + build_folder: build-release-32 + description: Windows Release 32 + settings: + - arch=x86 + Debug32: + include: Release32 + build_folder: build-debug-32 + description: Windows Debug 32 + settings: + - build_type=Debug + ReleaseTool: + build_folder: build-release-tool + description: Windows Release + profile_host: build-profile-windows-intel + DebugTool: + build_folder: build-debug-tool + description: Windows Debug Tool + include: + - ReleaseTool + settings: + - build-type=Debug + ReleaseTool32: + build_folder: build-release-32-tool + description: Windows Release 32 Tool + include: + - ReleaseTool + settings: + - arch=x86 + DebugTool32: + build_folder: build-debug-32-tool + description: Windows Debug 32 Tool + include: + - ReleaseTool32 + settings: + - build-type=Debug + default: *windowsDebug + prebuilt_tools: + - cmake/[>=3.23.0] + - package: doxygen/1.9.1 + configs: + # xapian-core doesn't work for cross-building x86_64 to x86 + - ReleaseTool + - package: doxygen/1.9.2 + configs: + # xapian-core doesn't work for cross-building x86_64 to x86 + - ReleaseTool + - package: doxygen/1.9.1 + options: + - doxygen:enable_search=False + - package: doxygen/1.9.2 + options: + - doxygen:enable_search=False + - ninja/[~1.10.0] + - ninja/[>=1.0.0] + - b2/4.8.0 + - b2/4.9.2 + - package: swig/1.3.40+dl.1 + options: + - pcre:with_bzip2=False + - package: swig/4.0.2+dl.2 + options: + - pcre:with_bzip2=False + - innoextract/1.9.0 + prebuilt_tools_configs: + - ReleaseTool + + aix: + common: &aixCommon + build: + - missing + config: + Release: &aixRelease + <<: *aixCommon + build_folder: build-release + description: AIX Release + profile_host: gcc-8-aix71-64 + Debug: &aixDebug + <<: *aixRelease + build_folder: build-debug + description: AIX Debug + settings: + - build_type=Debug + Release32: &aixRelease32 + <<: *aixRelease + build_folder: build-release-32 + description: AIX Release 32 + profile_host: gcc-8-aix71-32 + Debug32: &aixDebug32 + <<: *aixRelease32 + build_folder: build-debug-32 + description: AIX Debug 32 + settings: + - build_type=Debug + ReleaseTool: + <<: *aixCommon + build_folder: build-release-tool + description: AIX Release + profile_host: build-profile-aix-ppc + ReleaseToolGCC: + build_folder: build-release-tool + description: AIX Release Tool with GCC + profile_host: build-profile-aix-ppc-gcc + DebugTool: + build_folder: build-debug-tool + description: AIX Debug Tool + include: + - Debug + ReleaseTool32: + build_folder: build-release-tool-32 + description: AIX Release 32 Tool 32 + include: + - Release32 + DebugTool32: + build_folder: build-debug-tool-32 + description: AIX Debug 32 Tool + include: + - Debug32 + prebuilt_tools: + - package: cmake/[>=3.23.0] + options: + - cmake:with_openssl=False + configs: + - ReleaseTool + - package: doxygen/1.9.1 + options: + - doxygen:enable_search=False + - package: doxygen/1.9.2 + options: + - doxygen:enable_search=False + - package: ninja/[~1.10.0] + configs: + - ReleaseTool + - package: ninja/[>=1.0.0] + configs: + - ReleaseTool + - package: b2/4.8.0 + configs: + - ReleaseToolGCC + - package: b2/4.9.2 + configs: + - ReleaseToolGCC + - package: swig/1.3.40+dl.1 + options: + - pcre:with_bzip2=False + configs: + - ReleaseTool + - package: swig/4.0.2+dl.2 + options: + - pcre:with_bzip2=False + configs: + - ReleaseTool + prebuilt_tools_configs: + - ReleaseTool + - ReleaseToolGCC + + sunos: + common: &sparcCommon + build: + - missing + config: + Release: &sparcRelease + <<: *sparcCommon + build_folder: build-release + description: Sparc Release + profile_host: gcc-9-sparc-solaris + env_host: + - PATH=[/opt/cmake-3.19/bin] + Debug: &sparcDebug + <<: *sparcRelease + build_folder: build-debug + description: Sparc Debug + settings: + - build_type=Debug + Release32: &sparcRelease32 + <<: *sparcRelease + build_folder: build-release-32 + description: Sparc Release 32 + profile_host: gcc-9-sparc32-solaris + Debug32: &sparcDebug32 + <<: *sparcRelease32 + build_folder: build-debug-32 + description: Sparc Debug 32 + settings: + - build_type=Debug + ReleaseTool: + build_folder: build-release-tool + description: Sparc Release Tool + profile_host: build-profile-solaris-sparc + DebugTool: + build_folder: build-debug-tool + description: Sparc Debug Tool + include: + - ReleaseTool + settings: + - build_type=Debug + ReleaseTool32: + build_folder: build-release-tool-32 + description: Sparc Release 32 Tool 32 + profile_host: build-profile-solaris-sparc-32 + DebugTool32: + build_folder: build-debug-tool-32 + description: Sparc Debug 32 Tool + include: + - DebugTool32 + settings: + - build_type=Debug + prebuilt_tools: + - package: cmake/[>=3.23.0] + options: + - cmake:with_openssl=False + - package: doxygen/1.9.1 + options: + - doxygen:enable_search=False + - ninja/[~1.10.0] + - ninja/[>=1.0.0] + - b2/4.8.0 + - b2/4.9.2 + - package: swig/1.3.40+dl.1 + options: + - pcre:with_bzip2=False + - package: swig/4.0.2+dl.2 + options: + - pcre:with_bzip2=False + prebuilt_tools_configs: + - ReleaseTool + + byhost: + # Configs based on hostname. + # These are applied last. Consider this for only the most extreme cases + kamcentos6: +merge_upstream: + # Overrides the defaults in the MergeUpstreamConfig class in tasks/merge_upstream.py + # Note the use of nested dataclasses; use nested dictionaries here. + pull_request: + reviewers: [ kam ] + assignee: kam + # Defaults: + # cci: + # url: git@github.com:conan-io/conan-center-index.git + # branch: master + # upstream: + # host: octocat.dlogics.com + # organization: datalogics + # branch: develop + # remote_name: merge-upstream-remote + # pull_request: + # host: octocat.dlogics.com + # fork: + # merge_branch_name: merge-from-conan-io + # reviewers: [ ] + # assignee: null + # labels: + # - from-conan-io +merge_staging_to_production: + # Defaults: + # host: octocat.dlogics.com + # organization: datalogics + # staging_branch: develop + # production_branch: master diff --git a/docs/CONTRIBUTOR_LICENSE_AGREEMENT.md b/docs/CONTRIBUTOR_LICENSE_AGREEMENT.md new file mode 100644 index 0000000000000..39acf20a7aebd --- /dev/null +++ b/docs/CONTRIBUTOR_LICENSE_AGREEMENT.md @@ -0,0 +1,23 @@ +Conan-Center-Index project Contributor License Agreement +-------------------------------------------------------- + +The following terms are used throughout this agreement: + +- You - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any entity that controls or is controlled by the legal entity, or is under common control with it. +- Contribution - any type of work that is submitted to the repository, including any modifications or additions to existing work. +- Project - Conan-Center-Index project (https://github.com/conan-io/conan-center-index) +- Submitted - conveyed to a Project via a pull request, commit, issue, or any form of electronic, written, or verbal communication with the copyright owner, contributors or maintainers. + +1. Grant of Copyright License. + + Subject to the terms and conditions of this agreement, You grant to JFrog LTD, a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute your contributions and such derivative works. + +2. Grant of Patent License. + + Subject to the terms and conditions of this agreement, You grant to JFrog LTD, a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer your contributions, where such license applies only to those patent claims licensable by you that are necessarily infringed by your contribution or by combination of your contribution with the project to which this contribution was submitted. + + If any entity institutes patent litigation - including cross-claim or counterclaim in a lawsuit - against You alleging that your contribution or any project it was submitted to constitutes or is responsible for direct or contributory patent infringement, then any patent licenses granted to that entity under this agreement shall terminate as of the date such litigation is filed. + +3. Source of Contribution. + + Your contribution is either your original creation, based upon previous work that, to the best of your knowledge, is covered under an appropriate open source license and you have the right under that license to submit that work with modifications, whether created in whole or in part by you, or you have clearly identified the source of the contribution and any license or other restriction (like related patents, trademarks, and license agreements) of which you are personally aware. diff --git a/docs/README.md b/docs/README.md index 8d7f4cfe0f9c8..0c06266cf5f35 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,14 +1,23 @@ +This repository, ConanCenterIndex, contains recipes for the remote [JFrog ConanCenter](https://conan.io/center/). +This remote is added by default to a clean installation of the Conan client. Recipes are contributed by opening pull requests as explained in the sections below. +When pull requests are merged, the CI will upload the generated packages to the [ConanCenter](https://conan.io/center/) remote. + # Documentation * [Code of conduct](code_of_conduct.md) * [Changelog](changelog.md) * User documentation - + [Contributing to Conan Center Index](contributing.md) - + [Adding Packages to ConanCenter](how_to_add_packages.md) - + [Packaging policy](packaging_policy.md) - + [Supported platforms and configurations](supported_platforms_and_configurations.md) + + [Contributing to Conan Center Index](../CONTRIBUTING.md) + + [Developing Recipes Locally](developing_recipes_locally.md) + + [Adding Packages to ConanCenter](adding_packages/README.md) :point_left: Best place to learn how to contribute + [Errors from the conan-center hook (KB-Hxxx)](error_knowledge_base.md) + + [Review Process](review_process.md) + + [Labels](labels.md) + + [Supported platforms and configurations](supported_platforms_and_configurations.md) + + [Consuming Recipes](consuming_recipes.md) :information_source: Learn how to limit the impact of recipe changes + + [Community Resources](community_resources.md) + + [Preparing recipes for Conan 2.0](v2_migration.md) + [FAQs](faqs.md) diff --git a/docs/adding_packages/README.md b/docs/adding_packages/README.md new file mode 100644 index 0000000000000..b1f20c7adfcbc --- /dev/null +++ b/docs/adding_packages/README.md @@ -0,0 +1,254 @@ +# Adding Packages to ConanCenter + +ConanCenterIndex aims to provide the best quality packages of any open source project. +Any C/C++ project can be made available by contributing a "recipe". + +Getting started is easy. Try building an existing package with our [developing recipes](../developing_recipes_locally.md) tutorial. +To deepen you understanding, start with the [How to provide a good recipe](#how-to-provide-a-good-recipe) section. +You can follow the three steps (:one: :two: :three:) described below! :tada: + + +## Contents + + * [Request access](#request-access) + * [Inactivity and user removal](#inactivity-and-user-removal) + * [Submitting a Package](#submitting-a-package) + * [The Build Service](#the-build-service) + * [Recipe files structure](#recipe-files-structure) + * [`config.yml`](#configyml) + * [`conandata.yml`](#conandatayml) + * [The _recipe folder_: `conanfile.py`](#the-_recipe-folder_-conanfilepy) + * [Test Folders](#test-folders) + * [How to provide a good recipe](#how-to-provide-a-good-recipe) + * [Header Only](#header-only) + * [CMake](#cmake) + * [Components](#components) + * [Autotools](#autotools) + * [Components](#components-1) + * [No Upstream Build Scripts](#no-upstream-build-scripts) + * [System Packages](#system-packages) + * [Verifying Dependency Version](#verifying-dependency-version) + * [Verifying Dependency Options](#verifying-dependency-options) + * [Test the recipe locally](#test-the-recipe-locally) + * [Hooks](#hooks) + * [Linters](#linters) + +## Request access + +:one: The first step to add packages to ConanCenter is requesting access. To enroll in ConanCenter repository, please write a comment +requesting access in this GitHub [issue](https://github.com/conan-io/conan-center-index/issues/4). Feel free to introduce yourself and +your motivation to join ConanCenter community. + +This process helps ConanCenter against spam and malicious code. The process is not not automated on purpose and the requests are generally approved +on a weekly basis. + +> **Note** The requests are reviewed manually, checking the GitHub profile activity of the requester to avoid any misuse of the service. +> All interactions are subject to the expectations of the [code of conduct](../code_of_conduct.md). Any misuse or inappropriate behavior are subject +> to the same principals. + +When submitting a pull request for the first time, you will be prompted to sign the [CLA](../CONTRIBUTOR_LICENSE_AGREEMENT.md) for your code contributions. You can view your signed CLA's by going to and signing in. + +## Inactivity and user removal + +For security reasons related to the CI, when a user no longer contributes for a long period, it will be considered inactive and removed from the authorized user's list. +For now, it's configured for **4 months**, and it's computed based on the latest commit, not comments or opened issues. +After that time, the CI bot will ask to remove the user name from the authorized users' list through the access request PR, which occurs a few times every week. +In case you are interested in coming back, please, ask again to be included in the issue [#4](https://github.com/conan-io/conan-center-index/issues/4), the process will be precise like for newcomers. + +## Submitting a Package + +:two: To contribute a package, you can submit a [Pull Request](https://github.com/conan-io/conan-center-index/pulls) to this GitHub repository https://github.com/conan-io/conan-center-index. + +The specific steps to add new packages are: + +* Fork the [conan-center-index](https://github.com/conan-io/conan-center-index) git repository, and then clone it locally. +* Copy a template from [package_templates](../package_templates) folder in the recipes/ folder and rename it to the project name (it should be lower-case). Read templates [documentation](../package_templates/README.md) to find more information. +* Make sure you are using the latest [Conan client](https://conan.io/downloads) version, as recipes might evolve introducing features of the newer Conan releases. +* Commit and Push to GitHub then submit a pull request. +* Our automated build service will build 100+ different configurations, and provide messages that indicate if there were any issues found during the pull request on GitHub. + +:three: When the pull request is [reviewed and merged](../review_process.md), those packages are published to [JFrog ConanCenter](https://conan.io/center/) and available for everyone. + +### The Build Service + +The **build service** associated to this repo will generate binary packages automatically for the most common platforms and compilers. See [the Supported Platforms and Configurations page](../supported_platforms_and_configurations.md) for a list of generated configurations. For a C++ library, the system is currently generating more than 100 binary packages. + +> ⚠️ **Note**: This not a testing service, it is a binary building service for package **released**. Unit tests shouldn't be built nor run in recipes by default, see the [FAQs](../faqs.md#why-conancenter-does-not-build-and-execute-tests-in-recipes) for more. Before submitting a pull request, please ensure that it works locally for some configurations. + +- The CI bot will start a new build only after the author is approved. Your PR may be reviewed in the mean time, but is not guaranteed. +- The CI system will also report with messages in the PR any error in the process, even linking to the logs to see more details and debug. + +The pipeline will report errors and build logs by creating a comment in the pull-request after every commit. The message will include links to the logs for inspecting. + +Packages generated and uploaded by this build service don't include any _user_ or _channel_ (existing references with any `@user/channel` should be considered as deprecated in favor of packages without it). Once the packages are uploaded, you will be able to install them using the reference as `name/version` (requires Conan >= 1.21): `conan install cmake/3.18.2@`. + +## Recipe files structure + +Every entry in the `recipes` folder contains all the files required by Conan to create the binaries for all the versions of one library. Those +files don't depend on any other file in the repository (we are not using `python_requires`) and every pull-request can modify only one of those +folders at a time. + +This is the canonical structure of one of these folders, where the same `conanfile.py` recipe is suitable to build all the versions of the library: + +``` +. ++-- recipes +| +-- library_name/ +| +-- config.yml +| +-- all/ +| +-- conanfile.py +| +-- conandata.yml +| +-- patches/ +| +-- add-missing-string-header-2.0.0.patch +| +-- test_package/ +| +-- conanfile.py +| +-- CMakeLists.txt +| +-- test_package.cpp +| +-- test_v1_package/ +| +-- conanfile.py +| +-- CMakeLists.txt +``` + +If it becomes too complex to maintain the logic for all the versions in a single `conanfile.py`, it is possible to split the folder `all` into +two or more folders, dedicated to different versions, each one with its own `conanfile.py` recipe. In any case, those folders should replicate the +same structure. + +### `config.yml` + +This file lists the versions and the folders where they are located: + +```yml +versions: + "1.1.0": + folder: 1.x.x + "1.1.1": + folder: 1.x.x + "2.0.0": + folder: all + "2.1.0": + folder: all +``` + + +### `conandata.yml` + +This file lists **all the sources that are needed to build the package**: source code, patch files, license files,... any file that will be used by the recipe +should be listed here. The file is organized into two sections, `sources` and `patches`, each one of them contains the files that are required +for each version of the library. All the files that are downloaded from the internet should include a checksum, so we can validate that +they are not changed. + +A detailed breakdown of all the fields can be found in [conandata_yml_format.md](conandata_yml_format.md). We **strongly** encourage adding the [patch fields](conandata_yml_format.md#patches-fields) to help track where patches come from and what issue they solve. + +Inside the `conanfile.py` recipe, this data is available in a `self.conan_data` attribute that can be used as follows: + +```py +def export_sources(self): + export_conandata_patches(self) + +def source(self): + files.get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + +def build(self): + files.apply_conandata_patches(self) + [...] +``` + +### The _recipe folder_: `conanfile.py` + +The main files in this repository are the `conanfile.py` ones that contain the logic to build the libraries from sources for all the configurations, +as we said before there can be one single recipe suitable for all the versions inside the `all` folder, or there can be several recipes targeting +different versions in different folders. For maintenance reasons, we prefer to have only one recipe, but sometimes the extra effort doesn't worth +it and it makes sense to split and duplicate it, there is no common rule for it. + +Together with the recipe, there can be other files that are needed to build the library: patches, other files related to build systems, +... all these files will usually be listed in `exports_sources` and used during the build process. + +Also, **every `conanfile.py` should be accompanied by one or several folder to test the generated packages** as we will see below. + +### Test Folders + +All the packages in this repository need to be tested before they join ConanCenter. A `test_package/` folder with its corresponding `conanfile.py` and +a minimal project to test the package is strictly required. You can read about it in the +[Conan documentation](https://docs.conan.io/en/latest/creating_packages/getting_started.html). + +Learn more about the ConanCenterIndex requirements in the [test packages](test_packages.md) document. + +## How to provide a good recipe + +The [recipes](https://github.com/conan-io/conan-center-index/tree/master/recipes) available in CCI can be used as good examples, you can use them as the base for your recipe. However it is important to note Conan features change over time and our best practices evolve so some minor details may be out of date due to the vast number of recipes. + +### Header Only + +If you are looking for header-only projects, you can take a look on [header-only template](../package_templates/header_only). +Also, Conan Docs has a section about [how to package header-only libraries](https://docs.conan.io/en/latest/howtos/header_only.html). + +### CMake + +For C/C++ projects which use CMake for building, you can take a look on [cmake package template](../package_templates/cmake_package). + +#### Components + +Another common use case for CMake based projects, both header only and compiled, is _modeling components_ to match the `find_package` and export the correct targets from Conan's generators. A basic examples of this is [cpu_features](https://github.com/conan-io/conan-center-index/blob/master/recipes/cpu_features/all/conanfile.py), a moderate/intermediate example is [cpprestsdk](https://github.com/conan-io/conan-center-index/blob/master/recipes/cpprestsdk/all/conanfile.py), and a very complex example is [OpenCV](https://github.com/conan-io/conan-center-index/blob/master/recipes/opencv/4.x/conanfile.py). + +### Autotools + +However, if you need to use autotools for building, you can take a look on [libalsa](https://github.com/conan-io/conan-center-index/blob/master/recipes/libalsa/all/conanfile.py), [kmod](https://github.com/conan-io/conan-center-index/blob/master/recipes/kmod/all/conanfile.py), [libcap](https://github.com/conan-io/conan-center-index/blob/master/recipes/libcap/all/conanfile.py). + +#### Components + +Many projects offer **pkg-config**'s `*.pc` files which need to be modeled using components. A prime example of this is [Wayland](https://github.com/conan-io/conan-center-index/blob/master/recipes/wayland/all/conanfile.py). + +### No Upstream Build Scripts + +For cases where a project only offers source files, but not a build script, you can add CMake support, but first, contact the upstream and open a PR offering building support. If it's rejected because the author doesn't want any kind of build script, or the project is abandoned, CCI can accept your build script. Take a look at [Bzip2](https://github.com/conan-io/conan-center-index/blob/master/recipes/bzip2/all/CMakeLists.txt) and [DirectShowBaseClasses](https://github.com/conan-io/conan-center-index/blob/master/recipes/directshowbaseclasses/all/CMakeLists.txt) as examples. + +### System Packages + +> :information_source: For exceptional cases where only system packages can be used and a regular Conan package may result in an incompatible and fragile package, a separated system package may be created. See the [FAQs](../faqs.md#can-i-install-packages-from-the-system-package-manager) for more. + +The [SystemPackageTool](https://docs.conan.io/en/latest/reference/conanfile/methods.html#systempackagetool) can easily manage a system package manager (e.g. apt, +pacman, brew, choco) and install packages which are missing on Conan Center but available for most distributions. It is key to correctly fill in the `cpp_info` for the consumers of a system package to have access to whatever was installed. + +As example there is [xorg](https://github.com/conan-io/conan-center-index/blob/master/recipes/xorg/all/conanfile.py). Also, it will require an exception rule for [conan-center hook](https://github.com/conan-io/hooks#conan-center), a [pull request](https://github.com/conan-io/hooks/pulls) should be open to allow it over the KB-H032. + +### Verifying Dependency Version + +Some project requirements need to respect a version constraint. This can be enforced in a recipe by accessing the [`dependencies`](https://docs.conan.io/en/latest/reference/conanfile/dependencies.html) attribute. +An example of this can be found in the [fcl recipe](https://github.com/conan-io/conan-center-index/blob/1b6b496fe9a9be4714f8a0db45274c29b0314fe3/recipes/fcl/all/conanfile.py#L80). + +```py +def validate(self): + foobar = self.dependencies["foobar"] + if self.info.options.shared and Version(foobar.ref.version) < "1.2": + raise ConanInvalidConfiguration(f"{self.ref} requires 'foobar' >=1.2 to be built as shared.") +``` + +### Verifying Dependency Options + +Certain projects are dependant on the configuration (a.k.a options) of a dependency. This can be enforced in a recipe by accessing the [`options`](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#options) attribute. +An example of this can be found in the [sdl_image recipe](https://github.com/conan-io/conan-center-index/blob/1b6b496fe9a9be4714f8a0db45274c29b0314fe3/recipes/sdl_image/all/conanfile.py#L93). + +```py + def validate(self): + foobar = self.dependencies["foobar"] + if not foobar.options.enable_feature: + raise ConanInvalidConfiguration(f"The project {self.ref} requires foobar:enable_feature=True.") +``` + +## Test the recipe locally + +### Hooks + +The system will use the [conan-center hook](https://github.com/conan-io/hooks) to perform some quality checks. These are required for the +the CI to merge any pull request. + +Follow the [Developing Recipes Locally](../developing_recipes_locally.md#installing-the-conancenter-hooks) guide for instructions. + +Go to the [Error Knowledge Base](../error_knowledge_base.md) page to know more about Conan Center hook errors. +Some common errors related to Conan can be found on the [troubleshooting](https://docs.conan.io/en/latest/faq/troubleshooting.html) section. + +### Linters + +Linters are always executed by Github actions to validate parts of your recipe, for instance, if it uses migrated Conan tools imports. +All executed linters are documented in [linters.md](../linters.md). +Check the [Developing Recipes](../developing_recipes_locally.md#running-the-python-linters) page for running them locally. diff --git a/docs/adding_packages/build_and_package.md b/docs/adding_packages/build_and_package.md new file mode 100644 index 0000000000000..8918d1c833ea7 --- /dev/null +++ b/docs/adding_packages/build_and_package.md @@ -0,0 +1,36 @@ +# Build and Package + +This document gathers all the relevant information regarding the general lines to follow while writing either the `build()` or the `package()` methods. +Both methods often use build helpers to build binaries and install them into the `package_folder`. + + +## Contents + + * [Build Method](#build-method) + * [Package](#package) + +## Build Method + +* `build()` method should focus on build only, not installation. During the build, nothing should be written in `package` folder. Installation step should only occur in `package()` method. + +* The build itself should only rely on local files. Nothing should be downloaded from the internet during this step. If external files are required, they should come from `requirements` or `build_requirements` in addition to source files downloaded in `source()` or coming from the recipe itself. + +* Except for CMake and a working build toolchain (compiler, linker, archiver, etc.), the recipe should not assume that any other build tool is installed on the user-build machine (like Meson, autotools, or pkg-config). On Windows, the recipe should not assume that a shell is available (like MSYS2). Therefore, if the build method requires additional tools, they should be added to `build_requirements()`. + +* It is forbidden to run other conan client commands during build. In other words, if upstream build files call conan under the hood (through `cmake-conan` for example or any other logic), this logic must be removed. + +* Settings from profile should be honored (`build_type`, `compiler.libcxx`, `compiler.cppstd`, `compiler.runtime` etc). + +* These env vars from profile should be honored and properly propagated to underlying build system during the build: `CC`, `CXX`, `CFLAGS`, `CXXFLAGS`, `LDFLAGS`. + +## Package + +* CMake config files must be removed (they will be generated for consumers by `cmake_find_package`, `cmake_find_package_multi`, or `CMakeDeps` generators). Use `rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))` or `rm(self, "*.cmake", os.path.join(self.package_folder, "lib"))`. + +* pkg-config files must be removed (they will be generated for consumers by `pkg_config` or `PkgConfigDeps` generators). Use `rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))` or `rm(self, "*.pc", os.path.join(self.package_folder, "lib"))`. + +* On *nix systems, executables and shared libraries should have empty `RPATH`/`RUNPATH`/`LC_RPATH`. + +* On macOS, install name in `LC_ID_DYLIB` section of shared libs must be `@rpath/`. + +* Installed files must not contain absolute paths specific to build machine. Relative paths to other packages is also forbidden since relative paths of dependencies during build may not be the same for consumers. Hardcoded relative paths pointing to a location in the package itself are allowed. diff --git a/docs/adding_packages/conandata_yml_format.md b/docs/adding_packages/conandata_yml_format.md new file mode 100644 index 0000000000000..84338094c3568 --- /dev/null +++ b/docs/adding_packages/conandata_yml_format.md @@ -0,0 +1,243 @@ +# conandata.yml + +[conandata.yml](https://docs.conan.io/en/latest/reference/config_files/conandata.yml.html) is a [YAML](https://yaml.org/) +file to provide declarative data for the recipe (which is imperative). This is a built-in Conan feature (available since +1.22.0) without a fixed structure, but ConanCenter has a specific format to ensure quality of recipes. + +In the context of ConanCenterIndex, this file is _mandatory_ and consists of two main sections that will be explained in the +next sections with more detail: + +* `sources`: Library sources origin with their verification checksums. +* `patches`: A list of patches to apply and supporting information. See the [Patching Policy](sources_and_patches.md#policy-about-patching) for the criteria. + + +## Contents + + * [sources](#sources) + * [Mirrors](#mirrors) + * [Multiple Assets](#multiple-assets) + * [Different source archives per configuration](#different-source-archives-per-configuration) + * [Sources fields](#sources-fields) + * [url](#url) + * [sha256](#sha256) + * [patches](#patches) + * [Patches fields](#patches-fields) + * [patch_file](#patch_file) + * [patch_description](#patch_description) + * [patch_type](#patch_type) + * [official](#official) + * [vulnerability](#vulnerability) + * [portability](#portability) + * [conan](#conan) + * [bugfix](#bugfix) + * [patch_source](#patch_source) + * [base_path](#base_path) + +## sources + +`sources` is a top level dictionary, containing entries of sources and checksums for each of the supported versions. + +This is the entry that contains all the items that are downloaded from the internet and used in a recipe. This section contains one entry per version and each version should declare its own sources. + +> **Note**: For deciding which source to pick, see [Picking Sources](sources_and_patches.md#picking-the-sources) guide. + +This is a basic example of a regular library, it should satisfy most of the use cases: + +```yml +sources: + "1.2.11": + url: "..." + sha256: "..." + "1.2.12": + url: "..." + sha256: "..." +``` + +Every entry for a version consists in a dictionary with the `url` and the hashing algorithm of the artifact. `sha256` is required, but others like `sha1` or `md5` can be used as well. + +### Mirrors + +Sometimes it is useful to declare mirrors, use a list in the `url` field. Conan will try to download the artifacts from any of those mirrors. + +```yml +sources: + "1.2.11": + url: + - "https://zlib.net/zlib-1.2.11.tar.gz", + - "https://downloads.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz", + sha256: "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1" +``` + +Keep in mind all the mirrors have to provide the exactly same source (e.g. no repackaging), thus using the same hash sum. + +### Multiple Assets + +It's rare but some projects ship archives missing files that are required to build or specifically to ConanCenter requirements. +You can name each asset and download them in the `conanfile.py`'s `source()` referring to the names. + +```yml +sources: + "10.12.2": + "sources": + url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.12.2/ApprovalTests.v.10.12.2.hpp + sha256: 4c43d0ea98669e3d6fbb5810cc47b19adaf88cabb1421b488aa306b08c434131 + "license": + url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.12.2/LICENSE" + sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 +``` + +You can list as many assets you need and reference them by their index. But make sure you keep them in order if there is any specific +logic about handling. + +```yml +sources: + "10.12.2": + - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.12.2/ApprovalTests.v.10.12.2.hpp + sha256: 4c43d0ea98669e3d6fbb5810cc47b19adaf88cabb1421b488aa306b08c434131 + - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.12.2/LICENSE" + sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 +``` + +#### Different source archives per configuration + +This is the most advanced and sophisticated use-case, but not so common. Some projects may provide different sources for different platforms, it could be expressed as: + +```yml +sources: + "0066": + "Macos": # Operating system + "x86": # Architecture + - url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/MacIntel_OSX_AppleC_32bit/packages/cspice.tar.Z" + sha256: "9a4b5f674ea76821c43aa9140829da4091de646ef3ce40fd5be1d09d7c37b6b3" + "x86_64": + - url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/MacIntel_OSX_AppleC_64bit/packages/cspice.tar.Z" + sha256: "f5d48c4b0d558c5d71e8bf6fcdf135b0943210c1ff91f8191dfc447419a6b12e" +``` + +This approach requires a special code within [build](https://docs.conan.io/en/latest/reference/conanfile/methods.html#build) method to handle. + +### Sources fields + +#### url + +`url` contains a string specifying [URI](https://tools.ietf.org/html/rfc3986) where to download released sources. +Usually, `url` has a [https](https://tools.ietf.org/html/rfc2660) scheme, but other schemes, such as [ftp](https://tools.ietf.org/html/rfc959) are accepted as well. + +#### sha256 + +[sha256](https://tools.ietf.org/html/rfc6234) is a preferred method to specify hash sum for the released sources. It allows to check the integrity of sources downloaded. +You may use an [online service](https://hash.online-convert.com/sha256-generator) to compute `sha256` sum for the given `url`. +Also, you may use [sha256sum](https://linux.die.net/man/1/sha256sum) command ([windows](http://www.labtestproject.com/files/win/sha256sum/sha256sum.exe)). + +## patches + +Sometimes sources provided by project require patching for various reasons. The `conandata.yml` file is the right place to indicate this information as well. + +> **Note**: Under our mission to ensure quality, patches undergo extra scrutiny. **Make sure to review** our +> [Patching Policy](sources_and_patches.md#policy-about-patching) to understand the requirements before adding any. + +This section follows the same pattern as the `sources` above - one entry per version with a list of patches to apply. + +```yaml +patches: + "1.2.0": + - patch_file: "patches/1.2.0-002-link-core-with-find-library.patch" + patch_description: "Link CoreFoundation and CoreServices with find_library" + patch_type: "portability" + patch_source: "https://a-url-to-a-pull-request-mail-list-topic-issue-or-question" +``` + +### Patches fields + +Theres are necessary for Conan to work as well as provide key information to reviewers and consumers which need to understand +the reasoning behind patches. + +#### patch_file + +_Required_ + +Patch file that are committed to the ConanCenterIndex, go into the `patches` sub-directory (next to the `conanfile.py`). Such patch files usually have either `.diff` or `.patch` extension. The recommended way to generate such patches is [git format-patch](https://git-scm.com/docs/git-format-patch). The path to the patch is relative to the directory containing `conandata.yml` and `conanfile.py`. + +#### patch_description + +_Required_ + +`patch_description` is an arbitrary text describing the following aspects of the patch: + +* What does patch do (example - `add missing unistd.h header`) +* Why is it necessary (example - `port to Android`) +* How exactly does patch achieve that (example - `update configure.ac`) + +An example of a full patch description could be: `port to Android: update configure.ac adding missing unistd.h header`. + +#### patch_type + +_Required_ + +The `patch_type` field specifies the type of the patch. In ConanCenterIndex we currently accept only several kind of patches: + +##### official + +`patch_type: official` indicates the patch is distributed with source code itself. usually, this happens if release managers +failed to include a critical fix to the release, but it's too much burden for them to make a new release just because of that single fix. +[example](https://www.boost.org/users/history/version_1_72_0.html) (notice the `coroutine` patch). The [`patch_source`](#patch_source) +field shall point to the official distribution of the patch. + +##### vulnerability + +`patch_type: vulnerability`: Indicates a patch that addresses the security issue. The patch description should include the index of CVE +or CWE the patch addresses. Usually, original library projects do new releases fixing vulnerabilities for this kind of issues, but in some +cases they are either abandoned or inactive. The [`patch_source`](#patch_source) must be a commit to the official fix of the vulnerability. + +##### portability + +`patch_type: portability`: Indicates a patch that improves the portability of the library, e.g. adding supports of new architectures (ARM, Sparc, etc.), operating systems (FreeBSD, Android, etc.), compilers (Intel, MinGW, etc.), and other types of configurations which are not originally supported by the project. +In such cases, the patch could be adopted from another package repository (e.g. MSYS packages, Debian packages, Homebrew, FreeBSD ports, etc.). +Patches of this kind are preferred to be submitted upstream to the original project repository first, but it's not always possible. +Some projects simply do not accept patches for platforms they don't have a build/test infrastructure, or maybe they are just either abandoned or inactive. + +##### conan + +`patch_type: conan`: Indicates a patch that is Conan-specific, patches of such kind are usually not welcomed upstream at all, because they provide zero value outside of Conan. +Examples of such a patches may include modifications of build system files to allow dependencies provided by Conan instead of dependencies provided by projects themselves (e.g. as submodule or just 3rd-party sub-directory) or by the system package manager (rpm/deb). +Such patches may contain variables and targets generated only by Conan, but not generated normally by the build system (e.g. `CONAN_INCLUDE_DIRS`). + +##### bugfix + +> **Warning**: These will undergo extra scrutiny during review as they may modify the source code. + +`patch_type: bugfix`: Indicates a patch that backports an existing bug fix from the newer release or master branch (or equivalent, such as main/develop/trunk/etc). The [`patch_source`](#patch_source) may be a pull request, or bug within the project's issue tracker. +Backports are accepted only for bugs that break normal execution flow, never for feature requests. +Usually, the following kind of problems are good candidates for backports: + +* Program doesn't start at all. +* Crash (segmentation fault or access violation). +* Hang up or deadlock. +* Memory leak or resource leak in general. +* Garbage output. +* Abnormal termination without a crash (e.g. just exit code 1 at very beginning of the execution). +* Data corruption. +* Use of outdated or deprecated API or library. + +As sources with backports don't act exactly the same as the version officially released, it may be a source of confusion for the consumers who are relying on the buggy behavior (even if it's completely wrong). Therefore, it's required to introduce a new `cci.` version for such backports, so consumers may choose to use either official version, or modified version with backport(s) included. + +#### patch_source + +_Recommended_ + +`patch_source` is the URL from where patch was taken from. https scheme is preferred, but other URLs (e.g. git/svn/hg) are also accepted if there is no alternative. Types of patch sources are: + +* Link to the public commit in project hosting like GitHub/GitLab/BitBucket/Savanha/SourceForge/etc. +* Link to the Pull Request or equivalent (e.g. gerrit review). +* Link to the bug tracker (such as JIRA, BugZilla, etc.). +* Link to the mail list discussion. +* Link to the patch itself in another repository (e.g. MSYS, Debian, etc.). + +For the `patch_type: portability` there might be no patch source matching the definition above. Although we encourage contributors to submit all such portability fixes upstream first, it's not always possible (e.g. for projects no longer maintained). In that case, a link to the Conan issue is a valid patch source (if there is no issue, you may [create](https://github.com/conan-io/conan-center-index/issues/new/choose) one). +For the `patch_type: conan`, it doesn't make sense to submit patch upstream, so there will be no patch source. + +#### base_path + +_Optional_ + +Specifies a sub-directory in project's sources to apply patch. This directory is relative to the [source_folder](https://docs.conan.io/en/latest/reference/conanfile/attributes.html?highlight=source_folder#source-folder). Usually, it would be a `source_subfolder`, but could be a lower-level sub-directory (e.g. if it's a patch for a submodule). diff --git a/docs/adding_packages/conanfile_attributes.md b/docs/adding_packages/conanfile_attributes.md new file mode 100644 index 0000000000000..64d658a2e6303 --- /dev/null +++ b/docs/adding_packages/conanfile_attributes.md @@ -0,0 +1,153 @@ +# `ConanFile` Attributes + +The `ConanFile` class has a lot of different properties that can help consumers search for projects, help the client build packages for different configurations +or are known by ConanCenter's build service and have special meaning. + + +## Contents + + * [Order of methods and attributes](#order-of-methods-and-attributes) + * [License Attribute](#license-attribute) + * [Settings](#settings) + * [Options](#options) + * [Recommended Names](#recommended-names) + * [Predefined Options and Known Defaults](#predefined-options-and-known-defaults) + * [Options to Avoid](#options-to-avoid) + +## Order of methods and attributes + +Prefer the following order of documented methods in python code (`conanfile.py`, `test_package/conanfile.py`): + +For `conan create` the order is listed [here](https://docs.conan.io/en/latest/reference/commands/creator/create.html#methods-execution-order) +test packages recipes should append the following methods: + +- deploy +- test + +the order above resembles the execution order of methods on CI. therefore, for instance, `build` is always executed before `package` method, so `build` should appear before the +`package` in `conanfile.py`. + +## License Attribute + +The mandatory license attribute of each recipe **should** be a [SPDX license](https://spdx.org/licenses/) [short Identifiers](https://spdx.dev/ids/) when applicable. + +Where the SPDX guidelines do not apply, packages should do the following: + +- When no license is provided or it's under the ["public domain"](https://fairuse.stanford.edu/overview/public-domain/welcome/) - these are not a license by itself. Thus, we have [equivalent licenses](https://en.wikipedia.org/wiki/Public-domain-equivalent_license) that should be used instead. If a project fall under these criteria it should be identified as the [Unlicense](https://spdx.org/licenses/Unlicense) license. +- When a custom (e.g. project specific) license is given, the value should be set to `LicenseRef-` as a prefix, followed by the name of the file which contains the custom license. See [this example](https://github.com/conan-io/conan-center-index/blob/e604534bbe0ef56bdb1f8513b83404eff02aebc8/recipes/fft/all/conanfile.py#L8). For more details, [read this conversation](https://github.com/conan-io/conan-center-index/pull/4928/files#r596216206). + + +## Settings + +All recipes should list the four settings `os`, `arch`, `compiler` and `build_type` so Conan will compute a different package ID +for each combination. There are some particular cases for this general rule: + +* **Recipes for _header only_ libraries** might omit the `settings` attribute, but in any case they should add + + ```python + def package_id(self): + self.info.clear() + ``` + +* **Recipes that provide applications** (`b2`, `cmake`, `make`,...) that are generally used as a _build requires_, must list all + the settings as well, but they should remove the `compiler` one in the corresponding method unless the recipe provides also + libraries that are consumed by other packages: + + ```python + def package_id(self): + del self.info.settings.compiler + ``` + + Removing the `compiler` setting reduces the number of configurations generated by the CI, reducing the time and workload and, at the + same time, demonstrates the power of Conan behind the package ID logic. + + > **Note** Intentionally, the `build_type` setting should not be removed from the package ID in this case. Preserving this + > setting will ensure that the package ID for Debug and Release configurations will be different and both binaries can be + > available in the Conan cache at the same time. This enable consumers to switch from one configuration to the other in the case + > they want to run or to debug those executables. + +## Options + +Recipes can list any number of options with any meaning, and defaults are up to the recipe itself. The CI cannot enforce anything +in this direction. However, there are a couple of options that have a special meaning for the CI. + +### Recommended Names + +Adding options is often needed to toggle specific library features on/off. Regardless of the default, there is a strong preference for using positive naming for options. In order to avoid the fragmentation, we recommend using the following naming conventions for such options: + +- enable_ / disable_ +- with_ / without_ +- use_ + +The actual recipe code then may look like: + +```py + options = {"enable_locales": [True, False]} # Changes which files are compiled in to the library + default_options = {"enable_locales": True} +``` + +```py + options = {"with_zlib": [True, False]} # Will add a `self.requires` with more deps to link against + default_options = {"with_zlib": True} +``` + +```py + options = {"use_tzdb": [True, False]} # Might install more headers to expose more features + default_options = {"use_tzdb": True} +``` + +Having the same naming conventions for the options helps consumers. It allows users to specify options with wildcards: `-o *:with_threads=True`. Therefore, the `with_threads` options will be enabled for all packages in the graph that support it. + +### Predefined Options and Known Defaults + +ConanCenter supports many combinations, these are outline in the [supported configurations](../supported_platforms_and_configurations.md) document for each platform. +By default recipes should use `shared=False` with `fPIC=True`. If support, `header_only=False` is the default. + +Usage of each option should follow the rules: + +* `shared` (with values `True` or `False`). The CI inspects the recipe looking for this option. The **default should be `shared=False`** and will + generate all the configurations with values `shared=True` and `shared=False`. + + > **Note**: The CI applies `shared=True` only to the package being built, while every other requirement will `shared=False`. To consume everything as a shared library you will set `--build=always` and/or `-o *:shared=True`) + > It's important to keep this in mind when trying to consume shared packages from ConanCenter + > as their requirements were linked inside the shared library. See [FAQs](../faqs.md#how-to-consume-a-graph-of-shared-libraries) for more information. + +* `fPIC` (with values `True` or `False`). The **default should be `fPIC=True`** and will generate all the configurations with values `fPIC=True` and `fPIC=False`. + This option does not make sense on all the support configurations so it should be removed. + + ```python + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + ``` + +* `header_only` (with values `True` or `False`). The **default should be `header_only=False`**. If the CI detects this option, it will generate all the + configurations for the value `header_only=False` and add one more configuration with `header_only=True`. **Only one package** + will be generated for `header_only=True`, so it is crucial that the package is actually a _header only_ library, with header files only (no libraries or executables inside). + + Recipes with such option should include the following in their `package_id` method + + ```python + def package_id(self): + if self.options.header_only: + self.info.clear() + ``` + + ensuring that, when the option is active, the recipe ignores all the settings and only one package ID is generated. + +### Options to Avoid + +* `build_testing` should not be added, nor any other related unit test option. Options affect the package ID, therefore, testing should not be part of that. + Instead, use Conan config [skip_test](https://docs.conan.io/en/latest/reference/config_files/global_conf.html#tools-configurations) feature: + + ```python + def generate(self): + tc = CMakeToolChain(self) + tc.variables['BUILD_TESTING'] = not self.conf.get("tools.build:skip_test", default=true, check_type=bool) + ``` + + The `skip_test` configuration is supported by [CMake](https://docs.conan.io/en/latest/reference/build_helpers/cmake.html#test) and [Meson](https://docs.conan.io/en/latest/reference/build_helpers/meson.html#test). diff --git a/docs/adding_packages/dependencies.md b/docs/adding_packages/dependencies.md new file mode 100644 index 0000000000000..5fbec29972765 --- /dev/null +++ b/docs/adding_packages/dependencies.md @@ -0,0 +1,20 @@ +# Dependencies + +This section outlines all the practices and guidelines for the `requirements()` and `build_requirements()` methods. This includes everything from "vendored" dependencies to +when and how the versions could be changed. + + +## Contents + + * [Rules](#rules) + +## Rules + +* [Version range](https://docs.conan.io/en/latest/versioning/version_ranges.html) is not allowed. +* Specify explicit [RREV](https://docs.conan.io/en/latest/versioning/revisions.html) (recipe revision) of dependencies is not allowed. +* Vendoring in library source code should be removed (best effort) to avoid potential ODR violations. If upstream takes care to rename + symbols, it may be acceptable. +* Only ConanCenter recipes are allowed in `requires`/`requirements()` and `build_requires`/`build_requirements()`. +* If a requirement is conditional, this condition must not depend on [build context](https://docs.conan.io/en/1.35/devtools/build_requires.html#build-and-host-contexts). Build requirements don't have this constraint. +* Forcing options of dependencies inside a recipe should be avoided, except if it is mandatory for the library - in which case it must + be enforced through the `validate()` methods. diff --git a/docs/adding_packages/sources_and_patches.md b/docs/adding_packages/sources_and_patches.md new file mode 100644 index 0000000000000..5032bc50a5949 --- /dev/null +++ b/docs/adding_packages/sources_and_patches.md @@ -0,0 +1,199 @@ +# Sources and Patches + +This documents contains everything related to the `source()`. This includes picking sources, where they should come from and goes into when and how to modify sources. +These are a very important aspects and it helps us to establish the quality of the packages offered by ConanCenter. + + +## Contents + + * [Picking the Sources](#picking-the-sources) + * [Source immutability](#source-immutability) + * [Sources not accessible](#sources-not-accessible) + * [Supported Versions](#supported-versions) + * [Removing old versions](#removing-old-versions) + * [Adding old versions](#adding-old-versions) + * [Policy about patching](#policy-about-patching) + * [Format and Conventions](#format-and-conventions) + * [Exporting Patches](#exporting-patches) + * [Applying Patches](#applying-patches) + * [Rules](#rules) + * [Exceptions](#exceptions) + +## Picking the Sources + +This is one of the most important steps when contributing and the quality of the sources directly dictates the quality of the packages produced. +The **origin of sources** should come from an official origin like the library source code repository or the official +release/download webpage. If an official source archive is available, it should be preferred over an auto-generated archive. + +Recipes should always be **built from library sources**. It aims to provide packages that respect the complete setting model of Conan. +Where ever possible, downloading source files and compiling is mandated. Downloading pre-compiled binaries should be avoided. + +### Source immutability + +Downloaded source code must have a deterministic results where the exact same archive is download each time. See +[Conandata's `"sha"` fields](conandata_yml_format.md#sha256) for how this is achieved in ConanCenterIndex. + +The sources stored under `self.source_folder` should not be modified. This will enable local workflows to "keep sources" and avoid extra downloads. +Any patch should be applied to the copy of this source code when a build is executed (basically in `build()` method). See [Applying Patches](#applying-patches) +below for more information. + +### Sources not accessible + +Library sources that are not publicly available will not be allowed in this repository even if the license allows their redistribution. See +our [closed source FAQ answer for more](../faqs.md#how-to-package-libraries-that-depend-on-proprietary-closed-source-libraries). +If library sources cannot be downloaded from their official origin or cannot be consumed directly due to their +format, the recommendation is to contact the publisher and ask them to provide the sources in a way/format that can be consumed +programmatically. + +As a final option, in case you need to use those binaries as a "build require" for some library, we will consider adding it +as a system recipe (`/system`) and making those binaries available in the CI machines (if the license allows it). + +## Supported Versions + +In this repository we are building a subset of all the versions for a given library. This set of version changes over time as new versions +are released and old ones stop being used. + +We always welcome latest releases as soon as they are available, and from time to time we remove old versions mainly due to technical reasons: +the more versions we have, the more resources that are needed in the CI and the more time it takes to build each pull-request (also, the +more chances of failing because of unexpected errors). + +### Removing old versions + +The Conan Team may ask you to remove more if they are taking a lot of resources. When removing old versions, please follow these considerations: + +* keep one version for every major release +* for the latest major release, at least three versions should be available (latest three minor versions) + +Logic associated with removed revisions implies that entries in the `config.yml` and `conandata.yml` files should also be removed. If anyone needs to +recover them in the future, Git contains the full history and changes can be recovered from it. + +Please, note that even if those versions are removed from this repository, **the packages will always be accessible in ConanCenter remote** +associated to the recipe revision used to build them. + +### Adding old versions + +We love to hear why in the opening description of the pull requests you need this exact version. +We usually don't add old versions unless there is a specific request for it. Adding versions that are not used by author of the pull request reduces overall resources and time from [the build services](README.md#the-build-service). + +Take into account that the version might be removed in future pull requests according to the [guidelines above](#removing-old-versions). + +## Policy about patching + +The main guideline in ConanCenter is to provide already compiled binaries for a set of architectures in the least surprising way as possible, so Conan +can be plugged into existing projects trying to minimize the modifications needed. Packages from Conan Center should fulfill the expectations of anyone +reading the changelog of the library, the documentation, or any statement by the library maintainers. + +### Format and Conventions + +Patch files are preferred over programmatic `replace_in_file` statements. This makes it easier to review and prevent +unwanted side effects when new versions are added. They will be listed in [`conandata.yml`](conandata_yml_format.md) +file and exported together with the recipe. Patches must always include [patch fields](conandata_yml_format.md#patches-fields) +which are enforced by the [linters](../../linter/conandata_yaml_linter.py). + +Patches must be located in the recipe folder in a `patches/` sub-directory. + +There are a few recommendations about naming patches: + +* be descriptive but terse +* number them so they can be re-used +* note the specific version + +By clearly indicating what the patch does, when it's applied, and how it relates to existing patches, you can +help make the [review process](../review_process.md) easier for readers and help speed up your pull requests. + +### Exporting Patches + +It's ideal to minimize the number of files in a package to exactly what's required. When recipes support multiple +versions with differing patches, it's strongly encouraged to only export the patches used for that given recipe. + +Make sure the `export_sources` attribute is replaced by +[`conan.tools.files.export_conandata_patches`](https://docs.conan.io/en/latest/reference/conanfile/tools/files/patches.html?highlight=export_conandata_patches) +helper. + +```py +def export_sources(self): + export_conandata_patches(self) +``` + +### Applying Patches + +Patches can be applied in a separate method, the pattern name is `_patch_sources`. When applying patch files, +using [`conan.tools.files.apply_conandata_patches`](https://docs.conan.io/en/latest/reference/conanfile/tools/files/patches.html?highlight=apply_conandata_patches) +is the best option. + +```py +def build(self): + apply_conandata_patches(self) +``` + +For more complicated cases, +[`conan.tools.files.rm`](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-rm) +or [`conan.tools.files.replace_in_file`](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-replace-in-file) +are good choices. + +```py +def _patch_sources(self): + # remove bundled libfmt + rmdir(self, os.path.join(self.source_folder, "lib", "fmt")) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "${CMAKE_SOURCE_DIR}", "${CMAKE_CURRENT_SOURCE_DIR}") +``` + +### Rules + +These are the rules that apply to regular versions of Conan packages: + +**Build system patches.** In order to add libraries into ConanCenter sometimes +it is NEEDED to apply patches so they can consume existing packages +for requirements and binaries can be generated. These patches are totally +needed for the purpose of ConanCenter and Conan keeps adding features trying +to minimize these changes. + +**Source patches.** ConanCenter DOES NOT accept patches **backporting bugfixes or +features** from upcoming releases, they break the principle of minimum surprise, +they change the behavior of the library and it will no longer match the +documentation or the changelog originally delivered by the authors. + +However, ConanCenter DOES accept **working software patches**, these patches +are needed to generate the binaries for architectures not considered by +library maintainers, or to use some compilers or configurations. These patches +make it possible to generate binaries that cannot be generated otherwise, or +they can turn a crashing binary into a working software one (bugs, errors, or +faults are considered working software as long as they produce deterministic +results). + +Patches to sources to add support to newer versions of dependencies are +considered feature patches and they are not allowed either. They can +introduce new behaviors or bugs not considered when delivering the +library by maintainers. If a requirement is known not to work, the recipe +should raise a `ConanInvalidConfiguration` from the `validate()` method. + +**Vulnerability patches.** Patches published to CVE databases or declared as +vulnerabilities by the authors in non-mainstream libraries WILL be applied +to packages generated in Conan Center. + +**Official release patches.** If the library documents that a patch should be +applied to sources when building a tag/release from sources, ConanCenter WILL +apply that patch too. This is needed to match the documented behavior or the +binaries of that library offered by other means. +[Example here](https://www.boost.org/users/history/version_1_73_0.html). + +### Exceptions + +Exceptionally, we might find libraries that aren't actively developed and consumers +might benefit from having some bugfixes applied to previous versions while +waiting for the next release, or because the library is no longer maintained. These +are the rules for this exceptional scenario: + +* **new release**, based on some official release and clearly identifiable will + be created to apply these patches to: <>. +* **only patches backporting bugfixes** will be accepted after they have + been submitted to the upstream and there is a consensus that it's a bug and the patch is the solution. + +ConanCenter will build this patched release and serve its binaries like it does with +any other Conan reference. + +Notice that these <> releases are unique to ConanCenter +and they can get new patches or discard existing ones according to upstream +considerations. It means that these releases will modify their behavior without previous +notice, the documentation or changelog for these specific releases won't exist. Use +them carefully in your projects. diff --git a/docs/adding_packages/test_packages.md b/docs/adding_packages/test_packages.md new file mode 100644 index 0000000000000..f8524f848e577 --- /dev/null +++ b/docs/adding_packages/test_packages.md @@ -0,0 +1,111 @@ +# Test Packages + +This is the main way that ConanCenter is able to validate the contents of a package are valid. +It is required to provide a [`test_package/`](https://docs.conan.io/en/latest/reference/commands/creator/create.html?highlight=test_package) +sub-directory with every recipe. These are expected to work regardless of the options or settings used as this is what consumer will encounter when doing a `conan create` +themselves. It's possible to have ConanCenter run `conan test` on more then one `test folder` by using the `test_` prefix. + + +## Contents + + * [Files and Structure](#files-and-structure) + * [CMake targets](#cmake-targets) + * [Testing more generators with `test_`](#testing-more-generators-with-test_something) + * [Testing CMake variables from FindModules](#testing-cmake-variables-from-findmodules) + * [How it works](#how-it-works) + * [Minimalist Source Code](#minimalist-source-code) + +### Files and Structure + +See the [recipe files and structures](README.md#recipe-files-structure) for a visual. + +All ConanCenterIndex recipe should have a two [test_folders](https://docs.conan.io/en/latest/reference/commands/creator/create.html?highlight=test_folder) +One for the current CMake generator in `test_package/` and on for the deprecated generators in `test_v1_package/`. + +Please refer to the [Package Templates](../package_templates/) for the current practices about which files and what their content should be. + +### CMake targets + +When using CMake to test a package, the information should be consumed using the +[`CMakeDeps` generator](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmakedeps.html?highlight=cmakedeps). + +This typicall will look like a `CMakeLists.txt` which contain lines similar to + +```cmake +find_package(fmt REQUIRED CONFIG) +# ... +target_link_libraries(test_ranges PRIVATE fmt::fmt) +``` + +Refere to the [package template](https://github.com/conan-io/conan-center-index/blob/master/docs/package_templates/cmake_package/all/test_package/CMakeLists.txt) for more examples. + +> **Notes** It's still important to test targets provided by `cmake_find_package[_multi]` generators. +> It should help in the migration (and compatibility) with Conan v2. See [v1 test package template](https://github.com/conan-io/conan-center-index/blob/master/docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt) for details. +> You can see read [this conversation](https://github.com/conan-io/conan-center-index/issues/12888#issuecomment-1290817799) for more context. + +In ConanCenter we try to accurately represent the names of the targets and the information provided by CMake's modules and config files that some libraries +provide. If CMake or the library itself don't enforce any target name, the default ones provided by Conan should be recommended. The minimal project +in the `test_package` folder should serve as an example of the best way to consume the package, and targets are preferred over raw variables. + +This rule applies for the _global_ target and for components ones. The following snippet should serve as example: + +We encourage contributors to check that not only the _global_ target works properly, but also the ones for the components. It can be +done creating and linking different libraries and/or executables. + +### Testing more generators with `test_` + +The CI will explore all the folders and run the tests for the ones matching `test_*/conanfile.py` pattern. You can find the output of all +of them together in the testing logs. + +Sometimes it is useful to test the package using different build systems (CMake, Autotools,...). Instead of adding complex logic to one +`test_package/conanfile.py` file, it is better to add another `test_/conanfile.py` file with a minimal example for that build system. That +way the examples will be short and easy to understand and maintain. In some other situations it could be useful to test different Conan generators +(`cmake_find_package`, `CMakeDeps`,...) using different folders and `conanfile.py` files. + +When using more than one `test_` folder, create a different project for each of them to keep the content of the `conanfile.py` and the +project files as simple as possible, without the need of extra logic to handle different scenarios. + +``` +. ++-- recipes +| +-- library_name/ +| +-- config.yml +| +-- all/ +| +-- ... +| +-- test_package/ +| +-- ... +| +-- test_cmakedeps/ +| +-- conanfile.py +| +-- CMakeLists.txt +| +-- test_package.cpp +``` + +### Testing CMake variables from FindModules + +Recipes which provide [Find Modules](https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules) are strongly encouraged to +module the file name, targets and or variables. + +**We will provide better docs in the near future**, for now here are a few references: + +- Convo: https://github.com/conan-io/conan-center-index/pull/13511 +- early example: https://github.com/conan-io/conan-center-index/tree/master/recipes/libxml2/all/test_cmake_module_package +- Best reference: https://github.com/conan-io/conan-center-index/blob/master/recipes/expat/all/test_package_module/CMakeLists.txt#L9 + +### How it works + +The [build service](README.md#the-build-service) will explore all the folders and run the tests for the ones matching `test_*/conanfile.py` pattern. +You can find the output of all of them together in the testing logs. Only the end of the logs are posted even if an earlier "test folder" may have failed. + +> **Note**: If, for any reason, it is useful to write a test that should only be checked using Conan v1, you can do so by using the pattern +> `test_v1_*/conanfile.py` for the folder. Please, have a look to [linter notes](../v2_linter.md) to know how to prevent the linter from +> checking these files. + +Remember that the `test_` recipes should **test the package configuration that has just been generated** for the _host_ context, otherwise +it will fail in cross-building scenarios; before running executables, recipes should check +[`conan.tools.build.can_run`](https://docs.conan.io/en/latest/reference/conanfile/tools/build.html?highlight=can_run#conan-tools-build-can-run) + +### Minimalist Source Code + +The contents of `test_package.c` or `test_package.cpp` should be as minimal as possible, including a few headers at most with simple +instantiation of objects to ensure linkage and dependencies are correct. Any build system can be used to test the package, but +CMake or Meson are usually preferred. diff --git a/docs/changelog.md b/docs/changelog.md index 7ebb3d5c0af04..1c25e70b7d8ce 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,6 +1,373 @@ # Changelog -### 13-May-2021 - 17:20 CEST +### 09-December-2022 - 11:38 CET + +- [feature] Add environment variable to build with different Xcode/apple-clang compilers on Macos agents. +- [feature] Add `MACOSX_DEPLOYMENT_TARGET` and `SDKROOT` env variables to build stages on Macos. +- [feature] Add `LongPathsEnabled` registry key check on Windows to Validate Infrastructure job. +- [fix] Fix git user on commits when updating docs for supported platforms and configurations. +- [fix] Fix getting commit hash when writing GitHub error messages. +- [fix] Fix Conan v2 inspect command. +- [fix] Fix condition when waiting for another job to finish. + +### 14-November-2022 - 11:54 CET + +- [feature] Disable inactivity count for Access Request job. +- [feature] Add `github-actions[bot]` to permanent users list. +- [feature] No need to run ValidateInfrastructure job for Access Request and Reviewers update pull-requests. +- [fix] JobRelauncher retry property fix. + +### 07-November-2022 - 11:17 CET + +- [feature] Improve Access Request's pull-request description mentioning users. +- [fix] Access Request should not remove reviewers and maintainers. +- [fix] Access Request should count requests done on the same day as the pull request. +- [fix] Avoid posting pipeline title in GitHub messages if feedback is empty. + +### 27-October-2022 - 15:18 CEST + +- [feature] Add under maintenance check to AccessRequest and ScheduledExportCheck jobs. +- [feature] AccessRequest: Remove inactive users. +- [feature] Accept Major.Minor as bump version. +- [feature] Add message title to gihtub comments. +- [fix] Update maintainers list and fix output. +- [fix] Remove dummy files from tests. +- [fix] Make sure contributors are not removed in Access request PR. + +### 17-October-2022 - 10:33 CEST + +- [feature] Improve management of GitHub labels on pull requests. +- [feature] New EpochsSummary job to show epoch status for each reference. +- [feature] Save bot comments as labels as job artifacts for easier user feedback. +- [feature] Ability to wait for a job and merge bot messages from another pipeline: Allows to provide feedback to users in PRs from the Conan v2 pipeline in the future. +- [feature] Add timeout to AutomaticMerge job. +- [feature] Add note about Windows SDK on supported platforms documentation. +- [fix] Fix getting package IDs from Artifactory in the Conan v2 pipeline. +- [fix] Bump dependencies pull requests should only consider modified comments. +- [fix] ValidateInfrastructure job parameter for macos executors. + +### 20-September-2022 - 14:27 CEST + +- [feature] Handle scenarios where some files are removed. +- [feature] Simplify logic to detect references to be built in a pull request. +- [feature] Workaround in Conan v2 commands to list package IDs in a pull request. +- [feature] Bump minimum required Conan client version. +- [fix] When merging a pull request, check recipe revisions only against the pull-request repository. +- [fix] Do not consider GitHub check runs for pull requests opened by a bot. +- [fix] Consider files renamed in pull requests as "added" and "removed". +- [fix] Cover use-case when a pull request adds just one conanfile.py. +- [fix] Simplify assignment of GitHub labels. +- [fix] Use backquotes in GitHub comments. +- [fix] Fix promotion of packages with Conan v2. + +### 1-September-2022 - 10:21 CEST + +- [feature] Avoid `test_v?_package` folders that don't match the Conan version. +- [feature] Keep at least 3 days of job logs. +- [fix] Properly encode GitHub API URLs. +- [fix] Replace invalid chars when generating profiles. +- [refactor] Refactors around the GitHub classes implementation. + +### 18-August-2022 - 15:21 CEST + +- [fix] Conan v2: Check recipe revision only if it has been successfully exported. +- [feature]: Consider changes from `master` before merging a pull-request. If those changes result in a new recipe revision, the pull-request is triggered again. + +### 8-August-2022 - 11:25 CEST + +- [fix] Take into account status checks from GitHub actions before merging a pull-request. +- [feature] Double check that the recipe revision exported using Conan v2 matches the one exported by Conan v1. +- [feature] Fail if required Conan version is not available on Linux containers instead of falling back to latest. + +### 22-July-2022 - 12:13 CEST + +- [feature]: ValidateInfrastructure: Add check to verify CMake 3.21 is installed in Windows machines. +- [feature]: ValidateInfrastructure: Execute the validation when a pull-request is modifying configuration files. +- [feature]: Conan v2: Iterate `cppstd` values in profiles to build first match. +- [feature]: Conan v2: Apply `shared` option for the whole dependency graph. +- [feature]: Add `tools.apple.sdk_path` to configuration in Macos (required by new build helpers). +- [feature]: Set `tools.system.package_manager:mode=install` and `tools.system.package_manager:sudo=True` in configuration files (required by new system package manager helpers to mimic the behavior of old ones). +- [feature]: Upgrade required Conan versions to work with the library. Minimum versions tested are now `1.49.0` and `2.0.0b1`. +- [fix]: ValidateInfrastructure: Fix error message split. +- [bugfix]: Accept missing HTTP code for requests. + +### 06-July-2022 - 14:28 CEST + +- [feature]: Configure AccessRequest job to run on Mondays and Thursdays. +- [fix]: Improve Conan v2 export message. +- [fix]: Fix config parameters for RelaunchUnexpected job +- [fix]: Make AccessRequest job open PR against cci repo. +- [fix]: DSL: Remove old jobs by date only +- [refactor]: Refactor GitHub-related code utilities. + +### 27-June-2022 - 17:29 CEST + +- [fix] Fix "no changes detected" issue in some pull-requests. +- [fix] Avoid static builds with static runtime in MSVC compiler. +- [fix] Fix Conan v2 export checkout of sources. +- [fix] Conan v2: Avoid reading configuration entries that do not exist. +- [feature] Avoid failure in some jobs when the system is under maintenance. +- [feature] ValidateInfrastructure job now works for `msvc` & Visual Studio 2022. +- [feature] Conan v2: support hooks installation. +- [feature] Add more parameters to DSL scripts. + +### 08-June-2022 - 16:29 CEST + +- [feature] Allow changes in multiple folders (except for the `recipes` one). +- [feature] Detect changes made in a future `linters` folder. +- [feature] Validate configuration files in pull-requests that modifies them. +- [feature] Add support for more Conan v2 commands. +- [feature] DSL: Parameterize jenkinsfile path. +- [fix] DSL: Discard old builds to avoid consuming all inodes. +- [fix] Remove `under maintenance` label in pull requests. +- [fix] Add a detailed message for Conan v2 export. +- [fix] Abort `RelaunchUnexpectedError` job when the system is under maintenance. + +### 19-May-2022 - 15:52 CEST + +- [feature] Add Conan v2 export extra step in pull-request job. +- [feature] Tag pull-requests as "under maintenance" when the build service is not available. +- [config] Update Conan version to 1.47.0. +- [feature] Check right WinSDK in ValidateInfrastructure job. +- [fix] Fix access request job for authorized users. +- [feature] New Conan v2 commands: info and recipe revision. +- [feature] Store package ID cache at job level. + +### 10-May-2022 - 17:05 CEST + +- [fix] Exclude `shared=True` and runtime `MT/MTd` profile configuration from builds. +- [job] RelaunchUnexpectedError: a new job to automatically retrigger failed jobs. +- [feature] Ability to load the configuration file from an external source. +- [feature] Allow changes to files in the `.c3i` folder. +- [config] Move reviewers and approved users to configuration files. +- [config] Move automatic merge parameters to the configuration file. +- [config] Move GitHub activation to configuration file. +- [config] Remove default configuration. +- [feature] Added compatibility for more Conan 2 commands. +- [fix] Avoid regeneration of folder and multibranch jobs by the DSL cron job. + +### 28-April-2022 - 9:56 CEST + +- [config] Update Conan client to 1.46.2 +- [fix] Do not create GitHub pull-request statuses in advance. +- [fix] Move some Conan command calls to the wrapper. +- [feature] Added compatibility for Conan v2 export command. +- [config] Changed the required number of reviewers: 1 team and 1 community is enough + +### 21-April-2022 - 13:46 CEST + +- [feature] Updated Python version to > 3.7 in all build agents. +- [feature] Added CMake and Python versions to the infrastructure information. +- [config] Added new community reviewers. +- [feature] Moved Jenkins and Slack to the configuration file. +- [feature] Retry each build config if there is an unexpected error. +- [feature] Added logging to collect information about some jobs. +- [feature] Use a real build profile for cross-building configurations. +- [bugfix] Improve export error report. + +### 31-March-2022 - 11:55 CEST + +- [config] Upgrade Conan client version to 1.45.0. + +### 25-March-2022 - 09:54 CET + +- [feature] Updated CMake version to 3.20 only in MacOS machines. +- [feature] Collect requirements from test_package as well. +- [feature] Make the conan-center-bot write a comment after merging a `Bump version` or `Bump dependencies` labeled pull request. +- [feature] Allow SecheduledExportCheck job to report in any issue. +- [feature] DSL: Add cron triggers to some jobs. +- [feature] DSL: Disable concurrent builds on some jobs. +- [feature] Adapt paths for Ansible machines. +- [bugfix] Fix wrong log links in conan-center-bot message. +- [fix] Use consistent slashes in paths. +- [fix] Fix alert for job cancellation. + +### 09-March-2022 - 13:37 CET + +- [feature] Merge pull-requests that bump version automatically. +- [feature] Get requirements from `conan info --dry-build` command. +- [feature] Use reference with recipe revision for `conan info` commands. +- [feature] Add possibility to load the configuration from file. +- [fix] Fix DSL typo for access request job. +- [fix] Removed retries from pull-request builds (introduced long ago to avoid timeout issues). +- [refactor] Completely remove resource locking for executors. + +### 24-February-2022 - 14:03 CET + +- [fix] Fix encoding issues in `summary.html` file. +- [fix] Specify branch discovery in DSL for cci multibranch job. + +### 22-February-2022 - 10:26 CET + +- [feature] Merge pull-request that bump dependencies automatically. +- [feature] Notify about Visual Studio license status in ValidateInfrastructure. +- [config] Upgrade Conan client version to 1.44.1. +- [fix] Fix potential race condition calculating package IDs. + +### 16-February-2022 - 12:46 CET + +- [fix] Pin Artifactory client library version. + +### 10-February-2022 - 16:44 CET + +- [fix] Fix DSL parameters and TapaholesList name. +- [feature] Added ConanReference string conversion in call-stacks. +- [fix] Fix ValidateInfrastructure executors and labels count. + +### 04-February-2022 - 12:48 CET + +- [bugfix] Avoid race-conditions in Conan client instance. +- [hotfix] Race condition reading/writing a file. + +### 03-February-2022 - 17:01 CET + +- [feature] New label to identify pull-requests that are just bumping dependencies version. +- [bugfix] Fixed bugs with promotion and properties for references that don't build any binary. +- [feature] Add parameter to chose if documentation of supported platforms should be updated automatically. +- [feature] Improve Conan version regex to accept development versions + +### 26-January-2022 - 11:14 CET + +- [config] Add MacOS apple-clang 13.0 configuration to a new epoch. +- [feature] Handle `header_only=True` default option in recipes. +- [feature] Notify failed builds due to expired Visual Studio licenses. +- [feature] Tapaholes job now sets epoch as well. +- [fix] Throw error if configuration file to use is not found. +- [feature] Add missing DSL job descriptions. +- [feature] Child jobs use the same parent folder. +- [refactor] Remove resource locking. + +### 18-January-2022 - 16:49 CET + +- [config] Bump Conan client version to 1.43.3. + +### 29-December-2021 - 16:41 CET + +- [config] Add Linux GCC 11, Clang 12 & 13 configurations with new epoch feature. +- [config] Drop Linux GCC 6 and clang 10 configurations. +- [fix] Fixed some unexpected errors. +- [feature] Prepare pipeline to work with ansible provisioned machines. + +### 17-December-2021 - 09:56 CET + +- [feature] Introduce 'epoch' concept to build configurations as a strategy to build packages for new compilers. +- [feature] Allow pull-requests to build packages from different recipes for the same library. +- [feature] Profiles and logs from builds in the packages generated summary are now open in a new tab. +- [fix] Improve error reporting of mismatched revision in PRs. + +### 14-December-2021 - 09:13 CET + +- [config] Bump Conan client version to 1.43.0. + +### 01-December-2021 - 12:29 CET + +- [config] Bump Conan client version to 1.42.2. + +### 24-November-2021 - 17:49 CET + +- [feature] Return host requirements when computing package IDs. + +### 22-November-2021 - 17:53 CET + +- [feature] Cache computation of package IDs. + +### 15-November-2021 - 11:03 CET + +- [feature] Add `xlarge` pod size in Linux for building packages with higher memory requirements. + +### 11-November-2021 - 13:22 CET + +- [config] Bump Conan client version to 1.41.0 +- [fix] Identify PRs to `CONTRIBUTING.md` as changes in docs. +- [feature] Added Jenkins DSLs for job descriptions. +- [fix] Parse integer value when assigning properties. + +### 18-October-2021 - 17:05 CEST + +- [config] Upgrade Conan version to 1.40.4 +- [fix] Replace `Unauthorized User` label by `User-approval pending` +- [feat] Remove `os_build` and `arch_build` from generated profiles + +### 11-October-2021 - 12:14 CEST + +- [configs] Configurable Github statuses to check +- [configs] Pairing between configurations and workers (docker images, win/macos servers,...) is configurable in runtime. +- [feature] Early(iest) stop after failure: ignore any extra messages. It provides faster feedback for users. +- [feature] Skip stale pull-requests from automatic review requests. +- [feature] Add node-pool with more resources. It allows the CI to delegate certain builds that require higher RAM limits to it (configured manually). +- [fix] Removed EAP, now it should be named _"Access requests"_ everywhere +- [fix] Improved checks for infrastructure and configuration. It also fixes the auto-generated documentation for _"Supported platforms and configurations"_. +- [job] New job to remove dead branches from CI + +### 01-October-2021 - 13:08 CEST + +- [hotfix] Apply patch for (Added root certificate for Let's encrypt) + +### 21-September-2021 - 12:09 CEST + +- [config] Upgrade Conan version to 1.39.0. + +### 7-September-2021 - 16:49 CEST + +- [configs] Remove Visual Studio 2015 +- [configs] Remove Macos apple-clang 10 +- [configs] Remove Linux GCC 4.9 +- [configs] Linux Clang: keep only latest versions 10 and 11 +- [feature] Rename EAP to Access Request. +- [feature] Display merge error in pull-requests. + +### 6-September-2021 - 11:15 CEST + +- [feature] Display useful CI status notifications in Github pull requests. +- [feature] Upgrade Conan client version to 1.38.0. +- [feature] Move the Conan and Artifactory configuration out of the Jenkins library. +- [feature] Use separated files for the different profile configurations. + +### 3-August-2021 - 13:29 CEST + +- [feature] BuildSingleReference: Create packages for apple-clang armv8 (Apple M1) in pull-requests' builds. +- [feature] BuildSingleReference: Enforce empty workspace for Windows and MacOS nodes. +- [feature] Different approach to work with configuration files for profiles (internal modularibility). +- [feature] Allow jobs to use multiple configuration files for profiles. +- [fix] ValidateInfrastructure: Minor fixes to the automatic generation of "Supported platforms and configurations" documentation page. +- [fix] PromotePackages: Fix promotion of references that contain symbols. + +### 13-July-2021 - 10:24 CEST + +- [fix] DeleteRepo: Fix JFrog CLI commands. + +### 07-July-2021 - 08:36 CEST + +- [feature] UpgradeConan: Upgrade pip before installing Conan. +- [feature] Upgrade Conan client to the 1.37.2 version. + +### 02-July-2021 - 16:45 CEST + +- [feature] Do not run the CI for branches starting with `bot/...` (branches intended for automations). +- [feature] Remove all remotes when configuring the Conan client. +- [feature] ValidateInfrastructure: Update "Supported platforms and configurations" doc automatically. +- [fix] UpdateSearchIndex: Fix parsing of package data. +- [feature] BuildSingleReference: Add `MSBUILDDISABLENODEREUSE` environment variable for MSBuild to avoid errors when compiling in parallel. + +### 01-June-2021 - 08:59 CEST + +- [feature] RequestReviews: Add column to enable/disable review requests (any user). +- [testing] Use declared Conan version to run tests. +- [internal] Pay some technical debt. +- [internal] Simplify workflow, all packages already have properties. + +### 25-May-2021 - 13:42 CEST + +- [feature] AutomaticMerge: Skip pull-requests that fail to merge. + +### 24-May-2021 - 15:59 CEST + +- [feature] Start to crossbuild Apple M1 using two profiles approach (extra build). +- [feature] Detect and report when a PR has missing dependencies. +- [feature] Upgrade Conan version to 1.35.2. +- [feature] Use only one Artifactory repository per pull request. + +### 14-May-2021 - 17:24 CEST - [fix] Add `--dry-build` to `conan info` commands, it will expand also the build-requires that would have failed during the build stage. @@ -26,7 +393,7 @@ - [feature] Stop generating packages for apple-clang 9.1. - [feature] Raise error if `ConanInvalidConfiguration` is raised from `build()` method. - [feature] BuildSingleReference: All PRs use the new workflow. -- [feature] Allow modifications in the *.github* folder for GitHub bots and actions. +- [feature] Allow modifications in the _.github_ folder for GitHub bots and actions. - [feature] Use BuildSingleReference job to build packages (if needed) during a merge. - [feature] BuildSingleReference: Add build environment property to packages. - [feature] Tapaholes: Delete repositories after running jobs. @@ -243,27 +610,35 @@ - [fix] Fix checkExportSanity function ### 24-June-2020 - 10:55 CEST + - Updated Conan client to the 1.26.1 version in Windows and Mac agents. ### 18-June-2020 - 18:40 CEST + - Remove short paths limitation in all Windows agents. ### 04-June-2020 - 10:39 CEST + - Add `CONAN_SKIP_BROKEN_SYMLINKS_CHECK=1` in master jobs. ### 02-June-2020 - 13:06 CEST + - Avoid partial rebuilds in master jobs. Added `all_packages_done` property for every reference to track the completion of packages creation. ### 02-June-2020 - 00:02 CEST + - Updated CMake to 3.16.4 in Windows and Mac agents. ### 20-May-2020 - 10:34 CEST + - Updated Conan client to the 1.25.2 version in Windows and Mac agents. ### 14-May-2020 - 15:52 CEST + - Updated Conan client to 1.25.1 version in Windows and Mac agents. ### 13-May-2020 - 09:47 CEST (08e2be6) + - [refact] Simplify around ComputePackageID and CreatePackage - [refact] No need to pass 'winTmpPath' everywhere - Move the 'retryIze' call inside the scope of the node (Might improve [#1020](https://github.com/conan-io/conan-center-index/issues/1020)) diff --git a/docs/code_of_conduct.md b/docs/code_of_conduct.md index 72cfb41c92d5c..fe533ead1e99a 100644 --- a/docs/code_of_conduct.md +++ b/docs/code_of_conduct.md @@ -1,6 +1,5 @@ # Code of conduct - Try to be polite, CCI maintainers and contributors are really willing to help and we enjoy it. Please keep in mind these points: @@ -15,5 +14,4 @@ Please keep in mind these points: - You should not get bothered if you feel unattended, CCI is an Open Source project, not a commercial product. Try to explain what you really need and we will try to help you. - - For possible violations of the CoC, please report to info@conan.io **and** conancenter@jfrog.com + For possible violations of the CoC, please report to info@conan.io **and** conancenter@jfrog.com diff --git a/docs/community_resources.md b/docs/community_resources.md index a0bc0f2261897..265ae610b3327 100644 --- a/docs/community_resources.md +++ b/docs/community_resources.md @@ -5,21 +5,28 @@ This is a curated list of various bots and helpful tools that aim to making appr ## Contents + * [Social Media and More](#social-media-and-more) * [Bots](#bots) * [Tools](#tools) +## Social Media and More + +The community is very active on the [Cpplang's Slack channel](https://cpplang.slack.com/archives/C41CWV9HA), it's a great place to get help. + +If you are looking to stay up to date with the last Conan news, follow us on Twitter [@conan_io](https://twitter.com/conan_io) + ## Bots - [Updatable Recipes](https://github.com/qchateau/conan-center-bot): Automatically scans available recipes and checked for new upstream releases and tests one configuration - The results can be found here: https://qchateau.github.io/conan-center-bot/#/updatable - [Conflicting Pull Requests](https://github.com/ericLemanissier/conan-center-conflicting-prs): Checks all the open pull requests for those which edit the same recipe files and posts a message. - - The results can be found here: https://github.com/conan-io/conan-center-index/issues/3571 + - The results can be found here: https://ericlemanissier.github.io/conan-center-conflicting-prs/ - [Pending Review](https://github.com/prince-chrismc/conan-center-index-pending-review) - - The results can be found here: https://github.com/prince-chrismc/conan-center-index-pending-review/issues/1 + - The results can be found here: https://prince-chrismc.github.io/conan-center-index-pending-review/ - [System Package Checks](https://github.com/bincrafters/system-packages-checks): Builds automatically all `system` versions of recipes merged on CCI and being pull requested on a selection of Linux distributions and FreeBSD - - The results can be found here: https://github.com/bincrafters/system-packages-checks/actions?query=workflow%3ACI + - The results can be found here: https://bincrafters.github.io/system-packages-checks/ ## Tools diff --git a/docs/consuming_recipes.md b/docs/consuming_recipes.md new file mode 100644 index 0000000000000..ee80883fc7130 --- /dev/null +++ b/docs/consuming_recipes.md @@ -0,0 +1,71 @@ +# Consuming recipes + +ConanCenter has always maintained recipes consumers need to have an up to date client for the best experience. +The reason is there are constantly improvements and fixes being made, sometimes those require new Conan features +to be possible. There are usually waves of new features, patches and fixes that allow for even better quality recipes. + + +## Contents + + * [Breaking changes](#breaking-changes) + * [Isolate your project from upstream changes](#isolate-your-project-from-upstream-changes) + +## Breaking changes + +There can be several causes if a recipe (a new revision) might stopped to work in your project: + +- **Fixes in recipes** that modify the libraries they are creating: exported symbols, + compiler flags, generated files for your build system, CMake target names,... + + Every contributor tries to do their best and reviewers do an amazing work checking that the + changes are really improving recipes. +- **New Conan features (breaking syntax)** sometimes requires new attributes or statements in recipes. + If your Conan client is not new enough, + Conan will fail to parse the recipe and will raise a cryptic Python syntax error. + +- **New Conan Version**: Conan keeps evolving and adding new features, especially on its road to Conan 2.0, + and ConanCenter is committed in this [roadmap](v2_roadmap.md) as well, and tries to prepare the user base to these + new features in order to ease the migration to new versions. + + New recipe revisions can take into account changes that are introduced in new Conan client + version, sometimes these changes modify some experimental behavior without modifying recipe syntax. + +This use case is covered by the [`required_conan_version`](https://docs.conan.io/en/latest/reference/conanfile/other.html?highlight=required_conan_version#requiring-a-conan-version-for-the-recipe) feature. It will +substitute the syntax error by one nicer error provided by Conan client. + +To be sure that people using these new experimental features are using the required Conan version and testing the actual behavior +of those features (feedback about them is very important to Conan). + +## Isolate your project from upstream changes + +This has always been a concern from ConanCenter consumers. + +Conan is very flexible; you can add your own remote or modify your client’s configuration for more granularity. We see the majority of Conan users hosting their own remote, and only consuming packages from there. For production this is the recommended way to add some infrastructure to ensure stability. This is generally a good practice when relying on package managers - not just Conan. + +Here are a few choices: + +- [Running your own Conan Server](https://docs.conan.io/en/latest/uploading_packages/running_your_server.html) - great for local ad-hoc setups +- [Cache recipes in your own ArtifactoryCE](https://docs.conan.io/en/latest/uploading_packages/using_artifactory.html) - recommended for production environments + +Using your own ArtifactoryCE instance is easy. You can [deploy it on-premise](https://conan.io/downloads.html) or use a +[cloud provided solution](https://jfrog.com/community/start-free) for **free**. Your project should +[use only this remote](https://docs.conan.io/en/latest/reference/commands/misc/remote.html?highlight=add%20new) and new recipe +revisions are only pushed to your Artifactory after they have been validated in your project. + +The minimum solution, if still choosing to rely on ConanCenter directly, involves small changes to your client configuration by pinning the revision of every reference you consume in your project using using: + +- [recipe revision (RREV)](https://docs.conan.io/en/latest/versioning/revisions.html) can be added to each requirement. + Instead of `fmt/9.1.0` you can add a pound (or hashtag) to the end followed by the revision `fmt/9.1.0#c93359fba9fd21359d8db6f875d8a233`. + This feature needs to be enabled in Conan 1.x, see the [Activation Instructions](https://docs.conan.io/en/latest/versioning/revisions.html#how-to-activate-the-revisions) for details. +- [Lockfiles](https://docs.conan.io/en/latest/versioning/lockfiles.html) can be created with the `conan lock create` and read with by + adding `--lockfile=conan.lock` to `conan install` or `conan create` commands. See the [lockfile introduction](https://docs.conan.io/en/latest/versioning/lockfiles/introduction.html#) for more information. + +> **Warning** Please, be aware there are some known bugs related to lockfiles that are not being fixed in Conan v1.x - we are really excited for the 2.0 improvements to be widely used. + +Both of these give you better control and will allow you to choose when to upgrade your Conan client. + +--- + +This repository will keep evolving, and Conan will release new features. Even if these breaking +changes can cause some disruption, we think that they are needed and they contribute +to improve the overall experience in the C++ ecosystem. diff --git a/docs/contributing.md b/docs/contributing.md deleted file mode 100644 index 9e0d6b6271c42..0000000000000 --- a/docs/contributing.md +++ /dev/null @@ -1,59 +0,0 @@ -# Contributing to Conan Center Index - -The following summarizes the process for contributing to the CCI (Conan Center Index) project. - - -## Contents - - * [Community](#community) - * [Dev-flow & Pull Requests](#dev-flow--pull-requests) - * [Issues](#issues) - -## Community - -Conan Center Index is an Open Source MIT licensed project. -Conan Center Index is developed by the Conan maintainers and a great community of contributors. - -## Dev-flow & Pull Requests - -CCI follows the ["GitFlow"](https://datasift.github.io/gitflow/IntroducingGitFlow.html) branching model. -Issues are triaged and categorized mainly by type (package request, bug...) and priority (high, medium...) using GitHub - labels. - -To contribute follow the next steps: - -1. Comment in the corresponding issue that you want to contribute the package/fix proposed. If there is no open issue, we strongly suggest - to open one to gather feedback. -2. Check the [how_to_add_packages.md](how_to_add_packages.md) if are - contributing for a new package. -3. Fork the [CCI repository](https://github.com/conan-io/conan-center-index) and create a `package/xxx` branch from the `master` branch and develop - your fix/packages as discussed in previous step. -4. Try to keep your branch updated with the `master` branch to avoid conflicts. -5. Add the text (besides other comments): "fixes #IssueNumber" in the body of the PR, referring to the issue of step 1. - -The ``conan-io`` organization maintainers will review and help with the packaging. - -## Issues - -If you think you found a bug in CCI or in a recipe, open an issue indicating the following: - -- Explain the Conan version, Operating System, compiler and any other tool that could be related to the issue. -- Explain, as detailed as possible, how to reproduce the issue. Use git repository to contain code/recipes to reproduce issues, or a snippet. -- Include the expected behavior as well as what actually happened. -- Provide output captures (as text). -- Feel free to attach a screenshot or video illustrating the issue if you think it will be helpful. - -For any suggestion, feature request or question open an issue indicating the following: - -- Questions and support requests are always welcome. -- Use the [question] or [suggestion] tags in the title (provided by github issues templates). -- Try to explain the motivation, what are you trying to do, what is the pain it tries to solve. -- What do you expect from CCI. - -We use the following tags to control the status of the issues: - -- **infrastructure**: Waiting on tools or services belonging to the infra. -- **library request**: Request a new package to be created. -- **question**: Further information is requested . -- **upstream update**: Bump a new package version. -- **conan.io/center**: Issues and features related to Web UI . diff --git a/docs/developing_recipes_locally.md b/docs/developing_recipes_locally.md new file mode 100644 index 0000000000000..a9af9f6502351 --- /dev/null +++ b/docs/developing_recipes_locally.md @@ -0,0 +1,274 @@ +# Developing Recipes Locally + +Before you can contribute any code changes, you'll need to make sure you are familiar with the Conan client and have an environment that is conducive to developing recipes. + +This file is intended to provide all the commands you need to run in order to be an expert ConanCenter contributor. + + +## Contents + + * [Clone your fork](#clone-your-fork) + * [Setup your environment](#setup-your-environment) + * [Installing the ConanCenter Hooks](#installing-the-conancenter-hooks) + * [Updating conan hooks on your machine](#updating-conan-hooks-on-your-machine) + * [Basic Commands](#basic-commands) + * [Try it yourself](#try-it-yourself) + * [Debugging Failed Builds](#debugging-failed-builds) + * [Running the Python Linters](#running-the-python-linters) + * [Running the YAML Linters](#running-the-yaml-linters) + * [Yamllint](#yamllint) + * [Yamlschema](#yamlschema) + * [Testing the different `test__package`](#testing-the-different-test__package) + * [Testing more environments](#testing-more-environments) + * [Using Conan 2.0](#using-conan-20) + * [Installing Conan 2.0 beta](#installing-conan-20-beta) + * [Trying it out](#trying-it-out) + +## Clone your fork + +1. Follow the GitHub UI to [fork this repository](https://github.com/conan-io/conan-center-index/fork) +2. [Clone your fork](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) + +## Setup your environment + +1. Install a C++ development toolchain - ConanCenter's [build images](#testing-more-environments) are available +2. [Install the Conan client](https://docs.conan.io/en/latest/installation.html) - make sure to keep it up to date! +3. Install CMake - this is the only tool which is assumed to be present + [see FAQ](faqs.md#why-recipes-that-use-build-tools-like-cmake-that-have-packages-in-conan-center-do-not-use-it-as-a-build-require-by-default) for details. + +> **Note**: It's recommended to use a dedicated Python virtualenv when installing with `pip`. + +### Installing the ConanCenter Hooks + +The system will use the [conan-center hooks](https://github.com/conan-io/hooks) to perform some quality checks. You can install the hooks by running: + +```sh +conan config install https://github.com/conan-io/hooks.git -sf hooks -tf hooks +conan config set hooks.conan-center +``` + +> **Note**: Hooks are generally for package correctness and the pylinters are for the recipe syntax + +The hooks will show error messages but the `conan create` won’t fail unless you export the environment variable `CONAN_HOOK_ERROR_LEVEL=40`. +All hooks checks will print a similar message: + +```txt +[HOOK - conan-center.py] post_source(): [LIBCXX MANAGEMENT (KB-H011)] OK +[HOOK - conan-center.py] post_package(): ERROR: [PACKAGE LICENSE] No package licenses found +``` + +#### Updating conan hooks on your machine + +The hooks are updated from time to time, so it's worth keeping your own copy of the hooks updated regularly. To do this, simply run: + +```sh +conan config install +``` + +## Basic Commands + +We recommend working from the `recipes/project` folder itself. You can learn about the [recipe file structure](adding_packages/README.md#recipe-files-structure) to understand the folder and files located there. + +> **Note**: You can only change one recipe per pull request, and working from the [_recipe folder_](adding_packages/README.md#the-recipe-folder-conanfilepy) will help prevent making a few mistakes. The default for this folder is `all`, follow the link above to learn more. + +The [entire workflow of a recipe](https://docs.conan.io/en/latest/developing_packages/package_dev_flow.html) can be execute with the [`conan create`](https://docs.conan.io/en/latest/reference/commands/creator/create.html). This should look like: + +* `conan create all/conanfile.py 0.0.0@ -pr:b=default -pr:h=default` + +ConanCenter also has a few [support settings and options](supported_platforms_and_configurations.md) which highly recommend to test. For example +`conan create all/conanfile.py 0.0.0@ -o project:shared=True -s build_type=Debug` is a easy way to test more configurations ensuring the package is correct. + +### Try it yourself + +For instance you can create packages for `fmt` in various supported configurations by running: + +```sh +cd recipes/fmt +conan create all/conanfile.py fmt/9.0.0@ -pr:b=default -pr:h=default +conan create all/conanfile.py fmt/9.0.0@ -o fmt:header_only=True -pr:b=default -pr:h=default +conan create all/conanfile.py fmt/9.0.0@ -s build_type=Debug -o fmt:shared=True -pr:b=default -pr:h=default +``` + +## Debugging Failed Builds + +Some common errors related to Conan can be found on [troubleshooting](https://docs.conan.io/en/latest/faq/troubleshooting.html) section. +For ConanCenter Hook errors, go to the [Error Knowledge Base](error_knowledge_base.md) page to know more about those. + +To test with the same environment, the [build images](supported_platforms_and_configurations.md#build-images) are available. +Instructions for using these images can be found in [Testing more environments](#testing-more-environments) section. + +In ConanCenterIndex, the most common failure point is upstream build scripts tailored to their specific use cases. +It's not uncommon to [patch build scripts](adding_packages/sources_and_patches.md#rules) but make sure to read the +[patch policy](adding_packages/sources_and_patches.md#policy-about-patching). You are encouraged to submit pull requests upstream. + +## Running the Python Linters + +Linters are always executed by GitHub Actions to validate parts of your recipe, for instance, if it uses migrated Conan tools imports. + +It is possible to run the linter locally the same way it is being run [using Github actions](../.github/workflows/linter-conan-v2.yml) by: + +* (Recommended) Use a dedicated Python virtualenv. +* Ensure you have required tools installed: `conan` and `pylint` (better to uses fixed versions) + + ```sh + pip install conan~=1.0 pylint==2.14 + ``` + +* Set environment variable `PYTHONPATH` to the root of the repository + + ```sh + export PYTHONPATH=your/path/conan-center-index + ``` + +* Now you just need to execute the `pylint` commands: + + ```sh + # Lint a recipe: + pylint --rcfile=linter/pylintrc_recipe recipes/fmt/all/conanfile.py + + # Lint the test_package + pylint --rcfile=linter/pylintrc_testpackage recipes/fmt/all/test_package/conanfile.py + ``` + +## Running the YAML Linters + +There's two levels of YAML validation, first is syntax and the second is schema. +The style rules are located in [`linter/yamllint_rules.yml`](../linter/yamllint_rules.yml) and are used to ensure consistence. +The [`config.yml`](adding_packages/README.md#configyml) is required for the build infrastructure and the +[`conandata.yml` patch fields](adding_packages/conandata_yml_format.md#patches-fields) have required elements that are enforced with +schema validation. There's are to encourage the best possible quality of recipes and make reviewing faster. + +### Yamllint + +* (Recommended) Use a dedicated Python virtualenv. +* Ensure you have required tools installed: `yamllint` (better to uses fixed versions) + + ```sh + pip install yamllint==1.28 + ``` + +* Now you just need to execute the `yamllint` commands: + + ```sh + # Lint a recipe: + yamllint --config-file linter/yamllint_rules.yml -f standard recipes/fmt/all/conanfile.py + + # Lint the test_package (same command) + yamllint --config-file linter/yamllint_rules.yml -f standard recipes/fmt/all/test_package/conanfile.py + ``` + +### Yamlschema + +* (Recommended) Use a dedicated Python virtualenv. +* Ensure you have required tools installed: `strictyaml` and `argparse` (better to uses fixed versions) + + ```sh + pip install strictyaml==1.16 argparse==1.4 + ``` + +* Now you just need to execute the validation scripts: + + ```sh + # Lint a config.yml: + python3 linter/config_yaml_linter.py recipes/fmt/config.yml + + # Lint a conandata.yml + python3 linter/conandata_yaml_linter.py recipes/fmt/all/conandata.yml + ``` + +## Testing the different `test_*_package` + +This can be selected when calling `conan create` or separately with `conan test` + +```sh +# By adding the `-tf` argument +conan create recipes/fmt/all/conanfile.py 9.0.0@ -tf test_v1_package/ -pr:b=default -pr:h=default +``` + +```sh +# Passing test package's conanfile directly (make sure to export first) +conan test recipes/fmt/all/test_v1_package/conanfile.py fmt/9.0.0@ -pr:h=default -pr:b=default +``` + +## Testing more environments + +This can be difficult for some platforms given virtualization support. + +For Windows and MacOS users, you can test the Linux build environments with the Docker build images. + +Assuming you've already tested it locally and it's been successfully exported to your cache, you can: + +1. Creating a new profile. + * You can also download them from CCI build summary +2. Build missing packages + +Example. + +```sh +docker run -v/Users/barbarian/.conan:/home/conan/.conan conanio/gcc8 bash -c "conan profile new --detect gcc8" +docker run -v/Users/barbarian/.conan:/home/conan/.conan conanio/gcc8 bash -c "conan install -pr gcc8 fmt/9.0.0@ --build missing" +``` + +> **Note**: If you are running on Mac M1, the follow Docker argument is required: `--platform=linux/amd64` + +If you are working with packages that have system dependencies that are managed by Conan + +```sh +docker run -e CONAN_SYSREQUIRES_MODE=enabled conanio/gcc11-ubuntu16.04 conan install fmt/9.0.0@ -if build --build missing -c tools.system.package_manager:mode=install -c tools.system.package_manager:sudo=yes +``` + +## Using Conan 2.0 + +Everything you need to know about the methods, commands line, outputs can be found in the +[Conan 2.0 Migrations](https://docs.conan.io/en/latest/conan_v2.html) docs. + +This should be non-intrusive. Conan 2.0 by default has a different `CONAN_USER_HOME` location, which means that it has separate caches, profiles, and settings. +This will leave your Conan 1.0 setup completely intact when using Conan 2.0. + +> **Note**: There are substantial changes to the CLI so very few of the commands will remain the same. +> The new [Unified Command Pattern](https://docs.conan.io/en/latest/migrating_to_2.0/commands.html#unified-patterns-in-command-arguments), +> as an example, changes how settings and options are passed. + +### Installing Conan 2.0 beta + +Simply install Conan 2.0 with `pip install conan --upgrade --pre`. + +You can confirm the installation with: + +```sh +$ conan --version +Conan version 2.0.0-beta3 +$ conan config home +Current Conan home: /Users/barbarian/.conan2 +``` + +> **Note**: You will most likely see +> +> ```sh +> Initialized file: '/Users/barbarian/.conan2/settings.yml' +> Initialized file: '/Users/barbarian/.conan2/extensions/plugins/compatibility/compatibility.py' +> Initialized file: '/Users/barbarian/.conan2/extensions/plugins/compatibility/app_compat.py' +> Initialized file: '/Users/barbarian/.conan2/extensions/plugins/compatibility/cppstd_compat.py' +> Initialized file: '/Users/barbarian/.conan2/extensions/plugins/profile.py' +> ``` +> +> When running the client for the first time. + +You will need to setup profiles. This is one of the changes in 2.0. The default profile is now opt-in and no longer generated automatically. + +```sh +conan profile detect +``` + +> **Warning**: This is a best guess, you need to make sure it's correct. + +### Trying it out + +Try building an existing recipe. We'll repeat the 1.x example with `fmt` to build the same configurations: + +```sh +cd recipes/fmt +conan create all/conanfile.py --version 9.0.0 +conan create all/conanfile.py --version 9.0.0 -o fmt/9.0.0:header_only=True +conan create all/conanfile.py --version 9.0.0 -s build_type=Debug -o fmt/9.0.0:shared=True +``` diff --git a/docs/error_knowledge_base.md b/docs/error_knowledge_base.md index 7d9e55407263d..c58e8eba4b82b 100644 --- a/docs/error_knowledge_base.md +++ b/docs/error_knowledge_base.md @@ -1,21 +1,27 @@ # Errors from the conan-center hook (KB-Hxxx) - #### **#KB-H001: "DEPRECATED GLOBAL CPPSTD"** -`Conan > 1.15` deprecated the usage of the global ``cppstd`` setting in favor of ``compiler.cppstd``. As a subsetting of the compiler, it shouldn't be declared in the `conanfile.py`. +`Conan > 1.15` deprecated the usage of the global ``cppstd`` setting in favor of ``compiler.cppstd`` to [manage C++ standard](https://docs.conan.io/en/latest/howtos/manage_cpp_standard.html). As a subsetting of the compiler, it shouldn't be declared in the `conanfile.py`. #### **#KB-H002: "REFERENCE LOWERCASE"** -The package names in conan-center have to be lowercase. e.g: ``zlib/1.2.8`` +The package names in conan-center have to be [lowercase](https://github.com/conan-io/tribe/blob/main/design/017-lowercase-references.md). e.g: ``zlib/1.2.8``. #### **#KB-H003: "RECIPE METADATA"** -The recipe has to declare the following fields: [url](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#url), [license](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#license), [description](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#description) and [homepage](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#homepage). Also we recommend adding [topics](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#topics). +The recipe has to declare the following attributes: + +- [url](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#url) +- [license](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#license) +- [description](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#description) +- [homepage](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#homepage). + +Also we recommend adding [topics](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#topics) attribute. #### **#KB-H005: "HEADER_ONLY, NO COPY SOURCE"** -If the recipe calls `self.info.header_only()` in the `package_id()` method and doesn't declare settings, it should use the [no_copy_source](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#no-copy-source) attribute to avoid unnecessary copies of the source code. +If the recipe calls [self.info.header_only()](https://docs.conan.io/en/latest/howtos/header_only.html) in the [package_id()](https://docs.conan.io/en/latest/reference/conanfile/methods.html#package-id) method and doesn't declare settings, it should use the [no_copy_source](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#no-copy-source) attribute to avoid unnecessary copies of the source code. #### **#KB-H006: "FPIC OPTION"** @@ -53,13 +59,11 @@ class SomeRecipe(ConanFile): del self.options.fPIC ``` -Here we use `configure()` method, because user options are loaded after `config_options()` only. - +Here we use [configure()](https://docs.conan.io/en/latest/reference/conanfile/methods.html#configure-config-options) method, because user options are loaded after [config_options()](https://docs.conan.io/en/latest/reference/conanfile/methods.html#configure-config-options) only. #### **#KB-H008: "VERSION RANGES"** -It is not allowed to use version ranges for the recipes in Conan center, where the dependency graph should be deterministic. - +It is not allowed to use [version ranges](https://docs.conan.io/en/latest/versioning/version_ranges.html) for the recipes in Conan center, where the dependency graph should be deterministic. #### **#KB-H009: "RECIPE FOLDER SIZE"** @@ -67,7 +71,7 @@ The recipe folder (including the `test_package` folder) cannot exceed 256KB. #### **#KB-H010: "IMMUTABLE SOURCES"** -Create a file `conandata.yml` in the recipe folder containing the source code origins: +Create a file [conandata.yml](https://docs.conan.io/en/latest/reference/config_files/conandata.yml.html) in the recipe folder containing the source code origins: **_recipes/lib/1.2.0/conandata.yml_**: @@ -90,7 +94,7 @@ class SomeRecipe(ConanFile): #### **#KB-H011: "LIBCXX MANAGEMENT"** -If the library is detected as a pure C library (sources doesn't conatain any file with the following extensions: ["cc", "cpp", "cxx", "c++m", "cppm", "cxxm", "h++", "hh", "hxx", "hpp"]) then it has to remove the `compiler.libcxx` subsetting, because the cpp standard library shouldn't affect the binary ID: +If the library is detected as a pure C library (sources doesn't conatain any file with the following extensions: ["cc", "cpp", "cxx", "c++m", "cppm", "cxxm", "h++", "hh", "hxx", "hpp"]) then it has to remove the [compiler.libcxx](https://docs.conan.io/en/latest/reference/config_files/settings.yml.html#c-standard-libraries-aka-compiler-libcxx) subsetting, because the cpp standard library shouldn't affect the binary ID: ```python class SomeRecipe(ConanFile): @@ -108,7 +112,6 @@ The binary packages should contain a folder named `licenses` containing the cont The binary packages shouldn't contain any other files or folder except the following: `["lib", "bin", "include", "res", "licenses"]`. If you are packaging an application put all the contents inside the `bin` folder. - #### **#KB-H014: "MATCHING CONFIGURATION"** The binary package contains some file that not corresponds to the configuration of the package, for example, binary libraries for a header-only library, a DLL file when the `settings.os != Windows` and so on. The error message will contain information about the offending file. @@ -119,37 +122,42 @@ The binary package is shared (self.options.shared == True) but there is no `dll` #### **#KB-H016: "CMAKE-MODULES-CONFIG-FILES"** -The binary package cannot contain module or config CMake files ("Find*.cmake", "*Config.cmake", "*-config.cmake"). - +The binary package cannot contain module or config CMake files ("Find\*.cmake", "\*Config.cmake", "\*-config.cmake"). The package shouldn't contain specific build-system files to inform to the consumers how to link with it. -In order to make sure that the package will be consumed with any build-system, conan-center repository encourages to declare a `def package_info(self)` method with all the needed information about the package. +In order to make sure that the package will be consumed with any build-system, conan-center repository encourages to declare a [def package_info(self)](https://docs.conan.io/en/latest/reference/conanfile/methods.html#package-info) method with all the needed information about the package. The consumers of the package will be able to consume the packages using a specific [generators](https://docs.conan.io/en/latest/using_packages/conanfile_txt.html#generators) for the build system they use. +See also: [Why are CMake find/config files and pkg-config files not packaged?](faqs.md#why-are-cmake-findconfig-files-and-pkg-config-files-not-packaged). + #### **#KB-H017: "PDB FILES NOT ALLOWED"** -Because of the big size of the PDB files and the issues using them changing the original folders, the PDB files are not allowed to be packaged. +Because of the big size of the [PDB](https://github.com/Microsoft/microsoft-pdb) files (Program Databse, a debug information format) and the issues using them changing the original folders, the PDB files are not allowed to be packaged. + +See also: [Why PDB files are not allowed?](faqs.md#why-pdb-files-are-not-allowed). #### **#KB-H018: "LIBTOOL FILES PRESENCE"** -Packaging libtool files (*.la) instead of library files (*.a) is not allowed. +Packaging [libtool files](https://www.linuxfromscratch.org/blfs/view/svn/introduction/la-files.html) (\*.la) instead of library files (\*.a) is not allowed. #### **#KB-H019: "CMAKE FILE NOT IN BUILD FOLDERS"** -Some file with `*.cmake` extension has been found in a folder not declared in `cpp_info.builddirs`. +Some file with `*.cmake` extension has been found in a folder not declared in [cpp_info.builddirs](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#cpp-info). It is only allowed to put build files in `builddirs` because the generators might be able to include them when needed, but only if they are located in well known paths. #### **#KB-H020: "PC-FILES"** For the same reasons explained at [KB-H016](#KB-H016) it is not allowed to package `*.pc` files. +See also: [Why are CMake find/config files and pkg-config files not packaged?](faqs.md#why-are-cmake-findconfig-files-and-pkg-config-files-not-packaged). + #### **#KB-H021: "MS RUNTIME FILES"** For the legal reasons, and in order to reduce the size of packages, it's not allowed to package Microsoft Visual Studio runtime libraries, such as `msvcr80.dll`, `msvcp80.dll`, `vcruntime140.dll` and so on. #### **#KB-H022: "CPPSTD MANAGEMENT"** -If the library is detected as a pure C library (sources doesn't conatain any file with the following extensions: ["cc", "cpp", "cxx", "c++m", "cppm", "cxxm", "h++", "hh", "hxx", "hpp"]) then it has to remove the compiler.cppstd subsetting, because the cpp standard library shouldn't affect the binary ID: +If the library is detected as a pure C library (sources doesn't conatain any file with the following extensions: ["cc", "cpp", "cxx", "c++m", "cppm", "cxxm", "h++", "hh", "hxx", "hpp"]) then it has to remove the [compiler.cppstd](https://docs.conan.io/en/latest/howtos/manage_cpp_standard.html) subsetting, because the cpp standard library shouldn't affect the binary ID: ```python class SomeRecipe(ConanFile): @@ -174,7 +182,7 @@ There is a complete explanation in the [FAQ](faqs.md#should-recipes-export-a-rec #### **#KB-H024: "TEST PACKAGE FOLDER"** -The [test_package](https://docs.conan.io/en/latest/creating_packages/getting_started.html#the-test-package-folder) folder is required for every recipe in Conan Center Index. +The [test_package](https://docs.conan.io/en/latest/creating_packages/getting_started.html) folder is required for every recipe in Conan Center Index. ``` . conanfile.py @@ -205,7 +213,7 @@ class SomeRecipe(ConanFile): ... ``` -- Encoding: +- [Encoding](https://www.python.org/dev/peps/pep-0263/): ```python # -*- coding: utf-8 -*- # not allowed @@ -217,12 +225,12 @@ class SomeRecipe(ConanFile): #### **#KB-H027: "CONAN CENTER INDEX URL"** -The attribute `url` should point to the address where the recipe is located. -The current Conan Center Index address is https://github.com/conan-io/conan-center-index +The attribute [url](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#url) should point to the address where the recipe is located. +The current Conan Center Index address is #### **#KB-H028: "CMAKE MINIMUM VERSION"** -All CMake files added to recipe package should contain a minimal version (Not necessarily 2.8.11, it can be any version) available in the file: +All CMake files added to recipe package should contain a [minimal version](https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html) (Not necessarily 2.8.11, it can be any version) available in the file: ```cmake # CMakeLists.txt @@ -234,7 +242,7 @@ project(conanwrapper) #### **#KB-H029: "TEST PACKAGE - RUN ENVIRONMENT"** -The [RunEnvironment()](https://docs.conan.io/en/latest/reference/build_helpers/run_environment.html#runenvironment) build helper is no longer needed in the *test_package/conanfile.py*. It has been integrated by [run_environment](https://docs.conan.io/en/latest/devtools/running_packages.html#running-from-packages) parameter. +The [RunEnvironment()](https://docs.conan.io/en/latest/reference/build_helpers/run_environment.html#runenvironment) build helper is no longer needed in the `test_package/conanfile.py`. It has been integrated by [run_environment](https://docs.conan.io/en/latest/devtools/running_packages.html#running-from-packages) parameter. ```python # test_package/conanfile.py @@ -247,35 +255,19 @@ class TestConan(ConanFile): #### **#KB-H030: "CONANDATA.YML FORMAT"** -The structure of the *conandata.yml* file should follow this schema: - -```yml -sources: - "1.69.0": - url: "url1.69.0" - sha256: "sha1.69.0" - "1.70.0": - url: "url1.70.0" - sha256: "sha1.70.0" -patches: - "1.70.0": - - patch_file: "001-1.70.0.patch" - base_path: "source_subfolder/1.70.0" - - url: "https://fake_url.com/custom.patch" - sha256: "sha_custom" - base_path: "source_subfolder" - "1.71.0": - - patch_file: "001-1.71.0.patch" - base_path: "source_subfolder/1.71.0" -``` +The structure of the [conandata.yml](https://docs.conan.io/en/latest/reference/config_files/conandata.yml.html) file should follow the schema +defined in [Adding Packages - `Conandata.yml` Format](adding_packages/conandata_yml_format.md). #### **#KB-H031: "CONANDATA.YML REDUCE"** -This hook re-creates the information of the *conandata.yml* file, discarding the fields not relevant to the version of the package exported. This avoids creating new recipe revisions for every new change introduced in the file. +This [hook](https://docs.conan.io/en/latest/extending/hooks.html) re-creates the information of the [conandata.yml](https://docs.conan.io/en/latest/reference/config_files/conandata.yml.html) file, discarding the fields not relevant to the version of the package exported. This avoids creating new recipe revisions for every new change introduced in the file. Any additional field in the YAML file will raise an error. + #### **#KB-H032: "SYSTEM REQUIREMENTS"** -System requires can be used as an option when a Conan package is not available the same package can be installer system package manager. However, it can cause reproducibility problems, since the package may vary according the distribution or OS. Conan is not able to track its metadata, so that, installing system packages by recipe is not allowed. +[System requirements](https://docs.conan.io/en/latest/reference/conanfile/methods.html#systempackagetool) can be used as an option when a Conan package is not available ,the same package can be installed by system package manager. However, it can cause reproducibility problems, since the package may vary according the distribution or OS. Conan is not able to track its metadata, so that, installing system packages by recipe is not allowed. + +See also: [Can I install packages from the system package manager?](faqs.md#can-i-install-packages-from-the-system-package-manager). #### **#KB-H034: "TEST PACKAGE - NO IMPORTS()"** @@ -287,7 +279,9 @@ Since the entire community is maintaining all CCI recipes, putting just one name #### **#KB-H040: "NO TARGET NAME"** -According the Conan issue [#6269](https://github.com/conan-io/conan/issues/6269), the attribute `cpp_info.name` should be avoided for Conan Center Index in favor of `cpp_info.names["cmake_find_package"]` and `cpp_info.names["cmake_find_multi_package"]`. +According the Conan issue [#6269](https://github.com/conan-io/conan/issues/6269), the attribute `cpp_info.name` should be avoided for Conan Center Index in favor of `cpp_info.names["cmake_find_package"]` and `cpp_info.names["cmake_find_package_multi"]`. + +See also: [Migrating legacy cpp_info attributes to set_property()](https://docs.conan.io/en/latest/migrating_to_2.0/properties.html). #### **#KB-H041: "NO FINAL ENDLINE"** @@ -296,23 +290,21 @@ This avoids potential warnings/errors like `no new line at the end of file`. #### **#KB-H044: "NO REQUIRES.ADD()"** -Both `self.requires.add()` and `self.build_requires.add()` have been deprecated in favor of `self.requires()` and `self.build_requires()` which were introduced on Conan 1.x. Both `add()` were introduced during Conan 0.x and since Conan 1.23 they no longer follow the original behavior. +Both `self.requires.add()` and `self.build_requires.add()` have been deprecated in favor of [self.requires()](https://docs.conan.io/en/latest/reference/conanfile/methods.html#requirements) and [self.build_requires()](https://docs.conan.io/en/latest/reference/conanfile/methods.html#build-requirements) which were introduced on Conan 1.x. Both `add()` were introduced during Conan 0.x and since Conan 1.23 they no longer follow the original behavior. #### **#KB-H045: "DELETE OPTIONS"** The method `self.options.remove()` was introduced in Conan 0.x, however, Conan 1.x brings a more pythonic way for removing options from your recipe: `del self.options.` -#### **#KB-H046: "CMAKE VERBOSE MAKEFILE"** - -The CMake definition CMAKE_VERBOSE_MAKEFILE helps for debugging when developing, however, for regular CI build, it increases the log size and it's only required when problems occur and need to be verified. +See also: [configure(), config_options()](https://docs.conan.io/en/latest/reference/conanfile/methods.html#configure-config-options). -#### **#KB-H047: "NO ASCII CHARACTERS"** +#### **#KB-H046: "CMAKE VERBOSE MAKEFILE"** -According to PEP [263](https://www.python.org/dev/peps/pep-0263/), Unicode literals should only appear in Python code if the encoding is declared on one of the first two lines of the source file. Without such a declaration, any Unicode literal will cause a syntax error for Python 2 interpreters. +The CMake definition [CMAKE_VERBOSE_MAKEFILE](https://cmake.org/cmake/help/latest/variable/CMAKE_VERBOSE_MAKEFILE.html) helps for debugging when developing, however, for regular CI build, it increases the log size and it's only required when problems occur and need to be verified. #### **#KB-H048: "CMAKE VERSION REQUIRED"** -The file test_package/CMakeLists.txt should require CMake 3.1 by default: `cmake_minimum_required(VERSION 3.1)`. The CMake wrapper file can require CMake 2.8, because Conan recipe and the test package are totally separated. However, if `CMAKE_CXX_STANDARD` or `CXX_STANDARD` is explicit, CMake 3.1 is mandatory. +The file test_package/CMakeLists.txt should require CMake 3.1 by default: [cmake_minimum_required(VERSION 3.1)](https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html). The CMake wrapper file can require CMake 2.8, because Conan recipe and the test package are totally separated. However, if [CMAKE_CXX_STANDARD](https://cmake.org/cmake/help/latest/variable/CMAKE_CXX_STANDARD.html) or [CXX_STANDARD](https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html#prop_tgt:CXX_STANDARD) is explicit, CMake 3.1 is mandatory. #### **#KB-H049: "CMAKE WINDOWS EXPORT ALL SYMBOLS"** @@ -324,12 +316,167 @@ By default, all packages should be built as static library (the option ``shared` #### **#KB-H051: "DEFAULT OPTIONS AS DICTIONARY"** -The attribue `default_options` should be a dictionary, for example `default_options = {'shared': False, 'fPIC': True}`. +The attribue [default_options](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#default-options) should be a dictionary, for example `default_options = {'shared': False, 'fPIC': True}`. #### **#KB-H052: "CONFIG.YML HAS NEW VERSION"** -It's important to have new library version defined in both `config.yml` and `conandata.yml`, otherwise newly added version will not be checked and built by CI and will not be available for download. +It's important to have new library version defined in both [config.yml](adding_packages/README.md#the-version-folders) and [conandata.yml](https://docs.conan.io/en/latest/reference/config_files/conandata.yml.html), otherwise newly added version will not be checked and built by CI and will not be available for download. #### **#KB-H053: "PRIVATE IMPORTS"** -The recipe imports private Conan API, this is strongly discouraged - private imports are subjects to breaking changes. Avoid usage of private APIs, request to publically expose needed methods, if necessary. +The recipe imports private Conan API, this is strongly discouraged - private imports are subjects to breaking changes. Avoid usage of private APIs, +request to publicly expose needed methods, if necessary. + +#### **#KB-H054: "LIBRARY DOES NOT EXIST"** + +Libraries which are listed on [Components](https://docs.conan.io/en/latest/creating_packages/package_information.html#package-information-components) must be present in [libdirs](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#cpp-info). Check if the library name is correct, or if a library is only generated for a specific platform. + +#### **#KB-H055: "SINGLE REQUIRES"** + +Do not use [requirements()](https://docs.conan.io/en/latest/reference/conanfile/methods.html#requirements) method and [self.requires](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#requires) attribute together in the same recipe. +The duality creates a heterogeneous way of solving dependencies, making it difficult to review and susceptible to prone errors. + +#### **#KB-H056: "LICENSE PUBLIC DOMAIN"** + +See [License Attribute](adding_packages/conanfile_attributes.md#license-attribute) for details. + +#### **#KB-H057: "TOOLS RENAME"** + +The [rename()](https://docs.conan.io/en/latest/reference/conanfile/tools/files.html#conan-tools-rename) method will be the standard for Conan 2.0, and +also, it uses [robocopy](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy), which is safer on Windows. + +#### **#KB-H058: "ILLEGAL CHARACTERS"** + +Windows [naming conventions](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions) and [reserved](https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words) characters must be avoided for file naming, otherwise the will not be supported on Windows. + +#### **#KB-H059: "CLASS NAME"** + +Generic class names can cause review confusion. To keep a better naming, it should use `Conan`. + +#### **#KB-H060: "NO CRLF"** + +Files with [CRLF](https://en.wikipedia.org/wiki/Newline) as endline can cause CI errors when building a package, due the conversion to LF and false detection from CI as changed file. +The [.gitattributes](https://git-scm.com/docs/gitattributes) file lists which files should be converted to LF when commit. However, if you want to enforce it in your local copy, you may run: + + > git config --local core.autocrlf false + > git config --local core.eol lf + +The [core.autocrlf](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration) disabled means that git will not convert from CRLF to LF on commit. The [core.eol](https://git-scm.com/docs/git-config) sets the specific line ending to be used for every commit. + +#### **#KB-H062: "TOOLS CROSS BUILDING"** + +Replace all occurrences of `tools.cross_building(self.settings)` with [tools.cross_building(self)](https://docs.conan.io/en/latest/reference/tools.html#tools-cross-building). +When cross building, conan needs to compare [self.settings](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#settings) and [self.settings_build](https://docs.conan.io/en/latest/systems_cross_building/cross_building.html), which are attributes of `self`. + +#### **#KB-H064: "INVALID TOPICS"** + +An invalid [topic](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#topics) has been detected. Remove or rename it. +Right now, topic `conan` is considered redundant and it's not needed to explicitly list it within recipe. + +#### **#KB-H065: "NO REQUIRED_CONAN_VERSION"** + +The recipe misses [required_conan_version](https://docs.conan.io/en/latest/reference/conanfile/other.html#requiring-a-conan-version-for-the-recipe) attribute. +It may happen due to the usage of new features within recipe (such as `strip_root` parameter of the [tools.get](https://docs.conan.io/en/latest/reference/conanfile/tools/files/downloads.html#conan-tools-files-get) helper). +The policy of Conan Center Index to support only the latest version of the Conan Client, so it's safe to put the version Conan Center Index currently runs into the recipe. +Otherwise, it's not an easy task on its own to determine the minimal version that has to be specified: checking the Conan Client [Changelog](https://docs.conan.io/en/latest/changelog.html), one has to know in which Conan Client releases all the attributes, methods, build helpers, etc. used by the recipe were first introduced, and then select the most recent of them. +Consider adding the following code: + +```python +required_conan_version = ">=1.43.0" # use the version that Conan Center Index runs + +class SomeRecipe(ConanFile): + ... + +``` + +See also: [Submitting a Package](adding_packages/README.md#submitting-a-package). + +#### **#KB-H066: "SHORT_PATHS USAGE"** + +The recipe missess [short_paths](https://docs.conan.io/en/latest/reference/conanfile/attributes.html#short-paths) attribute. +It may happen due to the very long paths within source, build or package directories during the package creating. +Consider adding the following code: + +```python +class SomeRecipe(ConanFile): + ... + + short_paths = True +``` + +See also: [Maximum Path Length Limitation](https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd). + +#### **#KB-H068: "TEST_TYPE MANAGEMENT"** + +In Conan 2.0, see [migration guide](https://docs.conan.io/en/latest/migrating_to_2.0/recipes.html#changes-in-the-test-package-recipe), +the `test_package/conanfile.py` needs to declare the requirement being tested explicitly. To be prepared you +have to set the attribute `test_type="explicit"` (this will be ignored in 2.0) to make Conan activate the explicit +mode, then declaring the requirement using the `self.tested_reference_str` that contains the reference being tested. + +#### **#KB-H069: "TEST PACKAGE - NO DEFAULT OPTIONS"** + +This is to ensure the exact package that is built and uploaded is tested against. When `options` of `default_options` are modified in a +`test_package` it can possibly result in the graph being modified. The objective is to enforce quality of the packages and to avoid confusing +"missing packages" errors. + +#### **#KB-H070: "MANDATORY SETTINGS"** + +> :information_source: This rule was put in place as it was deemed safe for evaluation however there is room for improvement + +ConanCenter operates is profiles with a predefined list of settings, all of these much be present in the recipe to ensure `package_id`s are +computed correctly. Some libraries, for instance header-only, do not require all the settings and those should be deleted from the `package_id`. +This approach ensure consistency and reduces the learning curve. + +Recipes should include: + +```python +class SomeRecipe(ConanFile): + ... + + settings = "os", "compiler", "build_type", "arch" +``` + +- For header-only recipes ([example](https://github.com/conan-io/conan-center-index/blob/3a773e2d69ada3bd931252c43a48daf636ddfe87/recipes/eigen/all/conanfile.py#L35-L36)): + + ```python + def package_id(self): + self.info.header_only() + ``` + +There is the case when the package is header-only, but the options affects the generated artifact, (e.g. kanguru, pagmo2 ...), so you need to use `self.info.settings.clear()` instead. + +- For "tool" recipes ([example](https://github.com/conan-io/conan-center-index/blob/e604534bbe0ef56bdb1f8513b83404eff02aebc8/recipes/cmake/3.x.x/conanfile.py#L104-L105)) which only provide binaries, see [our packing policy](adding_packages/conanfile_attributes.md#settings) for more, should do as follows: + + ```python + def package_id(self): + del self.info.settings.compiler + ``` + +#### **#KB-H071: "INCLUDE PATH DOES NOT EXIST"** + +It's erroneous to leave the default `include` directory when it's not present. Consider adding: + +```python +def package_info(self): + self.cpp_info.includedirs = [] +``` + +#### **#KB-H072: "PYLINT EXECUTION"** + +Pylint is executed by default over all `conanfile.py` files in ConanCenterIndex and it should not be skipped. It's an important tool which helps us keep a standard level of acceptance. Otherwise, it would be incredibly hard to review all recipes and keep them to the same level of standards. + +#### **#KB-H073: "TEST V1 PACKAGE FOLDER"** + +The legacy content in test_package should not be removed. Instead, rename that folder to `test_v1_package` and create a new `test_package` folder following the [file structure](adding_packages/README.md#recipe-files-structure) related to Conan v2 and v1 compatibility. Also, you can obtain good examples of Conan v2 test packages from the [template packages](package_templates/README.md) folder. + +#### **#KB-H075: "REQUIREMENT OVERRIDE PARAMETER"** + +The [self.requires()](https://docs.conan.io/en/latest/reference/conanfile/methods.html#requirements) allows to override a dependency version, forcing to use that version imposed by the recipe only. As a side-effect, dependencies can use different versions of the same project at the same package, which may cause unpredicted errors, like ABI incompatibility. For that reason, the `override` parameter is forbidden and should not be used. Instead, all dependencies should align their package versions, even when it's necessary to open more pull requests to update dependency versions. + +## Deprecated errors + +The following errors from the hooks are deprecated and no longer reported: + +### **#KB-H047: "NO ASCII CHARACTERS"** + +According to PEP [263](https://www.python.org/dev/peps/pep-0263/), Unicode literals should only appear in Python code if the encoding is declared on one of the first two lines of the source file. Without such a declaration, any Unicode literal will cause a syntax error for Python 2 interpreters. diff --git a/docs/faqs.md b/docs/faqs.md index cccafc5a30d56..405ebcf4f7f82 100644 --- a/docs/faqs.md +++ b/docs/faqs.md @@ -15,14 +15,30 @@ This section gathers the most common questions from the community related to pac * [What version should packages use for libraries without official releases?](#what-version-should-packages-use-for-libraries-without-official-releases) * [Is the Jenkins orchestration library publicly available?](#is-the-jenkins-orchestration-library-publicly-available) * [Why not x86 binaries?](#why-not-x86-binaries) - * [But if there are no packages available, what will the x86 validation look like?](#but-if-there-are-no-packages-available-what-will-the-x86-validation-look-like) + * [But if there are no packages available, what will the x86 validation look like?](#but-if-there-are-no-packages-available-what-will-the-x86-validation-look-like) + * [Do static libraries tend to be compiled as PIC by default?](#do-static-libraries-tend-to-be-compiled-as-pic-by-default) * [Why PDB files are not allowed?](#why-pdb-files-are-not-allowed) - * [Why is there no option for PDB, as there is for fPIC?](#why-is-there-no-option-for-pdb-as-there-is-for-fpic) - * [Why _installer_ packages remove some settings from their package ID?](#why-_installer_-packages-remove-some-settings-from-their-package-id) - * [Can I remove an option from recipe](#can-i-remove-an-option-from-recipe) + * [Why is there no option for PDB, as there is for fPIC?](#why-is-there-no-option-for-pdb-as-there-is-for-fpic) + * [Doesn't this make debug builds useless?](#doesnt-this-make-debug-builds-useless) + * [Can I remove an option from a recipe?](#can-i-remove-an-option-from-a-recipe) * [Can I split a project into an installer and library package?](#can-i-split-a-project-into-an-installer-and-library-package) * [What license should I use for Public Domain?](#what-license-should-i-use-for-public-domain) - * [Why is a `tools.check_min_cppstd` call not enough?](#why-is-a-toolscheck_min_cppstd-call-not-enough) + * [What license should I use for a custom project specific license?](#what-license-should-i-use-for-a-custom-project-specific-license) + * [How do I flag a problem to a recipe consumer?](#how-do-i-flag-a-problem-to-a-recipe-consumer) + * [Why is a `build.check_min_cppstd` call not enough?](#why-is-a-buildcheck_min_cppstd-call-not-enough) + * [What is the policy for adding older versions of a package?](#what-is-the-policy-for-adding-older-versions-of-a-package) + * [What is the policy for removing older versions of a package?](#what-is-the-policy-for-removing-older-versions-of-a-package) + * [Can I install packages from the system package manager?](#can-i-install-packages-from-the-system-package-manager) + * [Why ConanCenter does not build and execute tests in recipes](#why-conancenter-does-not-build-and-execute-tests-in-recipes) + * [Why not add an option to build unit tests](#why-not-add-an-option-to-build-unit-tests) + * [What is the policy for supported python versions?](#what-is-the-policy-for-supported-python-versions) + * [How to package libraries that depend on proprietary closed-source libraries?](#how-to-package-libraries-that-depend-on-proprietary-closed-source-libraries) + * [How to protect my project from breaking changes in recipes?](#how-to-protect-my-project-from-breaking-changes-in-recipes) + * [Why are version ranges not allowed?](#why-are-version-ranges-not-allowed) + * [How to consume a graph of shared libraries?](#how-to-consume-a-graph-of-shared-libraries) + * [How to watch only specific recipes?](#how-to-watch-only-specific-recipes) + * [Is it possible to disable Pylint?](#is-it-possible-to-disable-pylint) + * [How long can I be inactive before being removed from the authorized users list?](#how-long-can-i-be-inactive-before-being-removed-from-the-authorized-users-list) ## What is the policy on recipe name collisions? @@ -36,9 +52,9 @@ For example, `GSL` is the name of `Guidelines Support Library` from Microsoft an ## What is the policy on creating packages from pre-compiled binaries? -The policy is that in the general case [recipes should build packages from sources](https://github.com/conan-io/conan-center-index/blob/master/docs/packaging_policy.md), because of reproducibility and security concerns. The implication is that the sources must be publicly available, and in a format that can be consumed programmatically. +The policy is that in the general case [recipes should build packages from sources](adding_packages/sources_and_patches.md#picking-the-sources), because of reproducibility and security concerns. The implication is that the sources must be publicly available, and in a format that can be consumed programmatically. -Check the link for further details. +See [Picking Sources](adding_packages/sources_and_patches.md#picking-the-sources) for more information. ## Should reference names use `-` or `_`? @@ -57,7 +73,7 @@ Conan has an abstraction over the packages build system and description by using In the past, we have found that the logic of some of the CMake's find/config or pkg-config files can lead to broken scenarios due to issues with: - Transitive dependencies: The find logic of CMake can lead to link libraries with system libraries instead of the ones specified in the conanfile. -- Different build type configurations: Usually those files are not prepared to handle multiconfiguration development while switching between release/debug build types for example. +- Different build type configurations: Usually those files are not prepared to handle multi-configuration development while switching between release/debug build types for example. - Absolute paths: Usually, those files include absolute paths that would make the package broken when shared and consumed. - Hardcoded versions of dependencies as well as build options that make overriding dependencies from the consumer not possible. @@ -93,7 +109,7 @@ Unless they are a general and extended utility in recipes (in which case, we sho ## What version should packages use for libraries without official releases? -The notation shown below is used for publishing packages where the original library does not make official releases. Thus, we use a format which includes the datestamp corresponding to the date of a commit: `cci.`. In order to create reproducible builds, we also "commit-lock" to the latest commit on that day. Otherwise, users would get inconsistent results over time when rebuilding the package. An example of this is the [RapidJSON](https://github.com/Tencent/rapidjson) library, where its package reference is `rapidjson/cci.20200410` and its sources are locked the latest commit on that date in [config.yml](https://github.com/conan-io/conan-center-index/blob/master/recipes/rapidjson/config.yml#L4). The prefix `cci.` is mandatory to distinguish as a virtual version provided by CCI. If you are interested to know about the origin, please, read [here](https://github.com/conan-io/conan-center-index/pull/1464). +The notation shown below is used for publishing packages where the original library does not make official releases. Thus, we use a format which includes the datestamp corresponding to the date of a commit: `cci.`. In order to create reproducible builds, we also "commit-lock" to the latest commit on that day (use UTC+00). Otherwise, users would get inconsistent results over time when rebuilding the package. An example of this is the [RapidJSON](https://github.com/Tencent/rapidjson) library, where its package reference is `rapidjson/cci.20200410` and its sources are locked the latest commit on that date in [conandata.yml](https://github.com/conan-io/conan-center-index/blob/master/recipes/rapidjson/all/conandata.yml#L5). The prefix `cci.` is mandatory to distinguish as a virtual version provided by CCI. If you are interested to know about the origin, please, read [here](https://github.com/conan-io/conan-center-index/pull/1464). ## Is the Jenkins orchestration library publicly available? @@ -108,32 +124,32 @@ As described in the [Supported platforms and configurations](supported_platforms * For security reasons, most companies build their own packages from sources, even if they already have a pre-built version available, which further reduces the need for extra configurations; * Each recipe results in around 130 packages, and this is only for x86_64, but not all packages are used, some settings remain with zero downloads throughout their life. So, imagine adding more settings that will rarely be used, but that will consume more resources as time and storage, this leaves us in an impractical situation. -#### But if there are no packages available, what will the x86 validation look like? +### But if there are no packages available, what will the x86 validation look like? As stated earlier, any increase in the number of configurations will result in an impractical scenario. In addition, more validations require more review time for a recipe, which would increase the time for all PRs, delaying the release of a new package. For these reasons, x86 is not validated by the CCI. We often receive new fixes and improvements to the recipes already available for x86_64, including help for other architectures like x86 and ARM. In addition, we also receive new cases of bugs, for recipes that do not work on a certain platform, but that are necessary for use, which is important to understand where we should put more effort. So we believe that the best way to maintain and add support for other architectures is through the community. +## Do static libraries tend to be compiled as PIC by default? + +Yes! You can learn more about default options in [Packaging Policy](adding_packages/conanfile_attributes.md#predefined-options-and-known-defaults). + ## Why PDB files are not allowed? The project initially decided not to support the PDB files primarily due to the size of the final package, which could add an exaggerated size and not even used by users. In addition, PDB files need the source code to perform the debugging and even follow the path in which it was created and not the one used by the user, which makes it difficult to use when compared to the regular development flow with the IDE. However, there are ways to get around this, one of them is through the [/Z7](https://docs.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format) compilation flag, which can be passed through [environment variables](https://docs.microsoft.com/en-us/cpp/build/reference/cl-environment-variables). You can use your [profile](https://docs.conan.io/en/latest/reference/profiles.html#package-settings-and-env-vars) to customize your compiler command line. -#### Why is there no option for PDB, as there is for fPIC? +### Why is there no option for PDB, as there is for fPIC? Adding one more common option, it seems the most simple and obvious solution, but it contains a side effect already seen with fPIC. It is necessary to manage the entire recipe, it has become a Boilerplate. So, adding PDB would be one more point to be reviewed for each recipe. In addition, in the future new options could arise, such as sanity or benchmark, further inflating the recipes. For this reason, a new option will not be added. However, the inclusion of the PDB files is discussed in issue [#1982](https://github.com/conan-io/conan-center-index/issues/1982) and there are some ideas for making this possible through a new feature. If you want to comment on the subject, please visit issue. -## Why _installer_ packages remove some settings from their package ID? - -There are some recipes in `conan-center-index` that provide packages that contain only executables (some examples are `b2`, `cmake` or `make`), these packages are used in -`conan-center-index` itself as `build_require` and they are consumed as utilities or tools by other users. In these contexts, the expectations are to consume an optimized binary (`build_type=Release`) and it is not important the compiler used to build it. +### Doesn't this make debug builds useless? -We decided that these packages (as long as they match the premises) should list all the settings needed to build, so building from sources will generate the expected binary, but they will **remove `compiler` setting inside the `package_id()` method**. As a consequence, the CI will generate packages only for one compiler reducing the workload in the pipeline and the number of possible package IDs. +No. The PDBs are only needed to debug dependency code. By providing the libraries you are able to link and build your application and debug your own code. +This is by far the more common scenario which we want to enable. -Note about `build_type`.- We retain the `build_type` setting to make it possible for the users to _debug_ these installer packages. We considered removing this settings and it would be possible to compile these packages in _debug_ mode, but if we remove it from the packageID, the compiled package would override the existing _release_ binary, and it'd be quite inconvenient for the users to compile the binary every time they need to switch from _debug_ to _release_. - -## Can I remove an option from recipe +## Can I remove an option from a recipe? It's preferable to leave all options (ie. not removing them) because it may break other packages which require those deleted options. Prefer the deprecation path with a mapping from old options to new ones: @@ -149,38 +165,52 @@ default_options = {"foobar": "deprecated"} def configure(self): if self.options.foobar != "deprecated": - self.out.warn("foobar option is deprecated, do not use anymore.") + self.output.warn("foobar option is deprecated, do not use anymore.") def package_id(self): del self.info.options.foobar ``` This is the safest way, users will be warned of deprecation and their projects will not risk breaking. -As aditional examples, take a look on follow recipes: [dcmtk](https://github.com/conan-io/conan-center-index/blob/5e6089005f0bb66cd16db7b0e5f37f5081c7820c/recipes/dcmtk/all/conanfile.py#L24), [gtsam](https://github.com/conan-io/conan-center-index/blob/f7f18ab050e5d97fac70932b0ba4c115a930958c/recipes/gtsam/all/conanfile.py#L40) +As additional examples, take a look on follow recipes: [dcmtk](https://github.com/conan-io/conan-center-index/blob/5e6089005f0bb66cd16db7b0e5f37f5081c7820c/recipes/dcmtk/all/conanfile.py#L24), [gtsam](https://github.com/conan-io/conan-center-index/blob/f7f18ab050e5d97fac70932b0ba4c115a930958c/recipes/gtsam/all/conanfile.py#L40) and [libcurl](https://github.com/conan-io/conan-center-index/blob/f834ee1c82564199fdd9ca2f95231693c1a7136a/recipes/libcurl/all/conanfile.py#L24). However, if logic is too complex (this is subjective and depends on the Conan review team) then just remove the option. After one month, we will welcome a PR removing the option that was deprecated. - ## Can I split a project into an installer and library package? No. Some projects provide more than a simple library, but also applications. For those projects, both libraries and executables should be kept together under the same Conan package. In the past, we tried to separate popular projects, like Protobuf, and it proved to be a complex and hard task to be maintained, requiring custom patches to disable parts of the building. Also, with the [context](https://docs.conan.io/en/latest/systems_cross_building/cross_building.html#conan-v1-24-and-newer) feature, we can use the same package as build requirement, for the same build platform, and as a regular requirement, for the host platform, when cross-building. It's recommended using 2 profiles in that case, one for build platform (where the compilation tools are being executed) and one for host platform (where the generated binaries will run). ## What license should I use for Public Domain? -[The Public Domain](https://fairuse.stanford.edu/overview/public-domain/welcome/) is not a license by itselt. Thus, we have [equivalent licenses](https://en.wikipedia.org/wiki/Public-domain-equivalent_license) to be used instead. By default, if a project uses Public Domain and there is no offcial license listed, you should use [Unlicense](https://spdx.org/licenses/Unlicense). +See [License Attribute](adding_packages/conanfile_attributes.md#license-attribute) for details. + +## What license should I use for a custom project specific license? + +See [License Attribute](adding_packages/conanfile_attributes.md#license-attribute) for details. + +## How do I flag a problem to a recipe consumer? + +Regardless of why, if the recipe detects a problem where binaries might not be generated correctly, an exception must be raised. This to prevent the publishing +incorrect packages which do not work as intended. Use `ConanInvalidConfiguration` which is specially support in ConanCenter. + +```py +raise ConanInvalidConfiguration(f"The project {self.ref} requires liba.enable_feature=True.") +``` + +You should not be using the `self.output.warn` and it is not enough to alter consumers or stop the build service. -## Why is a `tools.check_min_cppstd` call not enough? +## Why is a `build.check_min_cppstd` call not enough? Very often C++ projects require a minimum standard version, such as 14 or 17, in order to compile. Conan offers tools which enable checking the relevant setting is enabled and above this support for a certain version is present. Otherwise, it uses the compiler's default. ```python def configure(self): - tools.check_min_cppstd(self, 14) 👈 Wrong! + build.check_min_cppstd(self, 14) 👈 Wrong! ``` -This fails to cover the waste number of use cases for the following reasons: +This fails to cover the vast number of use cases for the following reasons: 1. `cppstd` is not configured in the `--detect`ed profiles generated by Conan, the majority of users simply do not have this setting. 2. A shocking number of projects override this setting within their respective build scripts, this setting does not get applied in those cases. @@ -189,8 +219,194 @@ This fails to cover the waste number of use cases for the following reasons: ```python def validate(self): # 👇 Correct - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 14) + if self.settings.compiler.cppstd: + build.check_min_cppstd(self, 14) +``` + +As a result, all calls to `build.check_min_cppstd` must be guarded by a check for the setting and the only way to ensure the C++ standard is to check the compiler's version to know if it offers sufficient support. An example of this can be found [here](https://github.com/conan-io/conan/issues/8002). + +## What is the policy for adding older versions of a package? + +See [Adding older versions](adding_packages/sources_and_patches.md#adding-old-versions) for details. + +## What is the policy for removing older versions of a package? + +See [Removing older versions](adding_packages/sources_and_patches.md#removing-old-versions) for details. + +## Can I install packages from the system package manager? + +It depends. You can not mix both regular projects with system packages, but you can provide package wrappers for system packages. However, Conan can not track system packages, like their version and options, which creates a fragile situation where affects libraries and binaries built in your package but can not be totally reproduced. +Also, system package managers require administrator permission to install packages, which is not always possible and may break limited users. Moreover, more than one Conan package may require the same system package and there is no way to track their mutual usage. + +The hook [KB-H032](error_knowledge_base.md#KB-H032) does not allow `system_requirement` nor `SystemPackageTool` in recipes, to avoid mixing both regular projects with +system packages at same recipe. + +There are exceptions where some projects are closer to system drivers or hardware and packaging as a regular library could result +in an incompatible Conan package. To deal with those cases, you are allowed to provide an exclusive Conan package which only installs system packages, see the [How-to](adding_packages/README.md#system-packages) for more. + +## Why ConanCenter does **not** build and execute tests in recipes + + + +There are different motivations: + +- time and resources: adding the build time required by the test suite plus execution time can increase our building times significantly across the 100+ configurations. +- ConanCenter is a service that builds binaries for the community for existing library versions, this is not an integration system to test the libraries. + +## Why not add an option to build unit tests + +- Adding a testing option will change the package ID, but will not provide different packaged binaries +- Use the configuration [skip_test](adding_packages/conanfile_attributes.md#options-to-avoid) to define the testing behavior. + +## What is the policy for supported python versions? + +`Python 2.7` and earlier is not supported by the ConanCenter, as it's already [EOL](https://www.python.org/doc/sunset-python-2/). + +`Python 3.6` and earlier is also not supported by the ConanCenter, as it's already [EOL](https://peps.python.org/pep-0494/#lifespan). + +Versions `Python 3.7+` onwards are currently supported by the infrastructure and the recipes. + +Our [docker images](https://github.com/conan-io/conan-docker-tools) use `Python 3.7.13+` ATM. + +Windows agents currently use `Python 3.7.9+`. macOS agents use version `Python 3.7.12+`. + +The version run by our agents and docker images is a subject to change, as security updates to the Python are released, or they enter EOL. + +Additional concerns about supported versions within conan ecosystem (not just ConanCenter, but client itself and other tools) are documented in [tribe](https://github.com/conan-io/tribe/pull/3). + +For ConanCenter, besides security, there are various concerns about critical features provided by the Python interpreter, include its syntax and the standard library, e.g.: + +- LZMA compression support +- Unicode awareness +- long-path awareness + +Right now, only the [CPython](https://github.com/python/cpython) flavor of the interpreter is supported (e.g. we never tested recipes work with IronPython, JPython, Cython, etc.). + +In addition, we support only 64-bit builds of the interpreter (amd64/x86_64 architecture) - 32-bit builds (x86) are not supported and not installed on the agents. + +There are no guarantees that recipes will work correctly in future Python versions having breaking changes to the interpreter, + as we don't test all the possible combinations (and probably will never be). Patches are welcomed if problems are found. + +## How to package libraries that depend on proprietary closed-source libraries? + +There are several popular software libraries provided by Intel: + +* [Intel Math Kernel Library (MKL)](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html) +* [Intel Integrated Performance Primitives (IPP)](https://www.intel.com/content/www/us/en/developer/tools/oneapi/ipp.html) +* [Intel Deep Neural Networking Library (DNN)](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onednn.html) + +these Intel libraries are widely used by various well-known open-source projects (e.g. [OpenCV](https://opencv.org/) or [TensorFlow](https://www.tensorflow.org/)). + +Unfortunately, these Intel libraries cannot be accepted into ConanCenter due to several important reasons: + +* they are closed-source and commercial products, ConanCenter cannot redistribute their binaries due to the license restrictions +* registration on the Intel portal is required in order to download the libraries, there are no permanent public direct download links +* they use graphical installers which are hard to automate within conan recipe + +instead, the libraries that depend on *MKL*, *IPP* or *DNN* should use the following references: + +* `intel-mkl/`, e.g. `intel-mkl/2021` +* `intel-ipp/`, e.g. `intel-ipp/2021` +* `intel-dnn/`, e.g. `intel-dnn/2021` + +**Note**: These references are not available in ConanCenter and will likely never be! it's the consumer's responsibility to provide the recipes for these libraries. + +Since these references will be never available in ConanCenter, they will be deactivated in the consuming recipes by default: + +```python + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_intel_mkl": [True, False]} + default_options = { + "shared": False, + "fPIC": True, + "with_intel_mkl": False} + + def requirements(self): + if self.options.with_intel_mkl: + self.requires("intel-mkl/2021") +``` + +If consumers activate the option explicitly (`with_intel_mkl=True`), Conan will fail because of the unknown reference. + +Consumers may use an [override](https://docs.conan.io/en/latest/using_packages/conanfile_txt.html#overriding-requirements) facility in order to use their own private references for Intel MKL, IPP or DNN libraries. + +For instance, if you have a private reference `intel-mkl/2021@mycompany/stable`, then you may use the following override in your `conanfile.txt`: + ``` +[requires] +intel-mkl/2021@mycompany/stable +``` + +## How to protect my project from breaking changes in recipes? + +This repository and the CI building recipes is continuously pushing to new Conan versions, +sometimes adopting new features as soon as they are released +([Conan client changelog](https://docs.conan.io/en/latest/changelog.html)). + +You should expect that latest revision of recipes can introduce breaking changes and new +features that will be broken unless you also upgrade Conan client (and sometimes you will +need to modify your project if the recipe changes the binaries, flags,... it provides). + +To isolate from these changes there are different strategies you can follow. +Keep reading in the [consuming recipes section](consuming_recipes.md#isolate-your-project-from-upstream-changes). + +## Why are version ranges not allowed? + +Version ranges are a useful Conan feature, find the documentation [here](https://docs.conan.io/en/latest/versioning/version_ranges.html). However, in the context of ConanCenter they pose a few key challenges, most notably: + +- Non-Deterministic `package-id` + +With version ranges the newest compatible package may yield a different package-id than the one built and published by ConanCenter resulting in frustrating error "no binaries found". For more context see [this excellent explanation](https://github.com/conan-io/conan-center-index/pull/8831#issuecomment-1024526780). + +- Build Reproducibility + +If consumers try to download and build the recipe at a later time, it may resolve to a different package version that may generate a different binary (that may or may not be compatible). In order to prevent these types of issues, we have decided to only allow exact requirements versions. This is a complicated issue, check [this thread](https://github.com/conan-io/conan-center-index/pull/9140#discussion_r795461547) for more. + +## How to consume a graph of shared libraries? + +When the CI builds packages with `shared=True`, it applies the option only to the package being created, but not to +the requirements. As the default value for the `shared` option is usually `False`, you can expect that the dynamic +library that has just being generated has linked all its requirements as static libraries. + +It is important to remark the default [package id mode](https://docs.conan.io/en/latest/creating_packages/define_abi_compatibility.html#versioning-schema) +used by Conan (which is the same default used by ConanCenter): `semver_direct_mode`. With this default only the major +version of the requirements is encoded in the package ID. + +The two previous behaviors together can lead to unexpected results for a user that want to consume a graph of +dependencies as shared libraries from ConanCenter. They might think that using `*:shared=True` in their profile is +enough, and indeed Conan will retrieve from ConanCenter all the dynamic libraries for all the graph of dependencies, but +**all of them will contain the logic of their respective requirements embedded in the dynamic library**, and this +logic is embedded at the time of building, so it might not match the version of the requirements that was resolved +by Conan, and for sure, the other dynamic libraries won't be used, only the ones linked directly by the consumer +project. See a more detailed [example here](https://github.com/conan-io/conan/issues/9712). + +In order to consume all those libraries as shared ones, building from sources is needed. This can be +easily achievable using `*:shared=True` in the _host_ profile and `--build` in the install command. With these inputs, +Conan will build from sources all the packages and use the shared libraries when linking. + +> **Note**: If you are hosting your own recipes, the proper solution for recipes would be to use something like +> [`shared_library_package_id`](https://docs.conan.io/en/latest/reference/conanfile/methods.html?highlight=shared_library_package_id#self-info-shared-library-package-id), +> that will encode this information in the package ID and ensure that any change in the static libraries that are +> embedded into a shared one is taken into account when computing the package ID. +> +> In this repository we are not using it, because it will lead to many missing packages, making it impossible +> for the CI to actually build consumers in PRs. + +## How to watch only specific recipes? + +The [Code Owners](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) feature requires +write permission for any listed user in the file `.github/CODEOWNERS`, which makes it impossible to be accepted by Conan. However, that file is still important as it can be re-used in +a future Github Action to parse and communicate users. Meanwhile, there is the project https://app.github-file-watcher.com/, +which is able to notify users, but only after merging to the master branch. Feel free to contribute to a new Github Action that +implements a file watcher feature. + +## Is it possible to disable Pylint? + +No. The [pylint](v2_linter.md) has an important role of keeping any recipe prepared for [Conan v2 migration](v2_migration.md). In case you are having +difficult to understand [linter errors](linters.md), please comment on your pull request about the problem to receive help from the community. + +## How long can I be inactive before being removed from the authorized users list? -As a result, all calls to `tools.check_min_cppstd` must be guarded by a check for the setting and the only way to ensure the C++ standard is to check the compiler's version to know if it offers sufficient support. An example of this can be found [here](https://github.com/conan-io/conan/issues/8002). +Please, read [Inactivity and user removal section](adding_packages/README.md#inactivity-and-user-removal). diff --git a/docs/how_to_add_packages.md b/docs/how_to_add_packages.md deleted file mode 100644 index e31be60277fc1..0000000000000 --- a/docs/how_to_add_packages.md +++ /dev/null @@ -1,205 +0,0 @@ -# Adding Packages to ConanCenter - - -## Contents - - * [Join the Early Access Program](#join-the-early-access-program) - * [More Information about Recipes](#more-information-about-recipes) - * [Before start](#before-start) - * [The recipe folder](#the-recipe-folder) - * [The version folder/s](#the-version-folders) - * [The conanfile.py and `test_package` folder](#the-conanfilepy-and-test_package-folder) - * [The `conandata.yml`](#the-conandatayml) - * [How to provide a good recipe](#how-to-provide-a-good-recipe) - * [Test the recipe locally](#test-the-recipe-locally) - * [Updating conan hooks on your machine](#updating-conan-hooks-on-your-machine) - * [Debugging failed builds](#debugging-failed-builds) - -## Join the Early Access Program - -The first step in adding packages to ConanCenter is requesting access to the Early Access Program. To enroll in EAP, please write a comment -requesting access in this GitHub [issue](https://github.com/conan-io/conan-center-index/issues/4). The EAP was designed to onboard authors -to the new process. - -All EAP requests are reviewed and approved (or denied) every week, thus your request can take one week to be approved, so don't worry. This -process helps conan-center-index against spam and malicious code. - -The contribution of packages is done via pull requests to the recipes found in this Github repository https://github.com/conan-io/conan-center-index. - -The specific steps to add new packages are: -* Fork the [conan-center-index](https://github.com/conan-io/conan-center-index) git repository, and then clone it. -* Create a new folder with the Conan package recipe (conanfile.py). -* Push to GitHub, and submit a pull request. -* Our automated build service will build 100+ different configurations, and provide messages that indicate if there were any issues found during the pull request on GitHub. - -When the pull request is reviewed and merged, those packages are published to [JFrog ConanCenter](https://conan.io/center/). - -## More Information about Recipes - -The [conan-center-index](https://github.com/conan-io/conan-center-index) (this repository) contains recipes for the remote [conan-center](https://conan.io/center/) repository. This remote is added by default to a clean installation of the Conan client. - -Recipes are contributed by opening pull-requests to this `conan-center-index` repository as it is explained in the section below. - -When pull requests are merged, the CI will upload the generated packages to [JFrog ConanCenter](https://conan.io/center/). Packages generated and uploaded by this build service don't include any _user_ or _channel_ (existing references with any `@user/channel` should be considered as deprecated in favor of packages without it). Once the packages are uploaded, you will be able to install them using the reference as `name/version` (requires Conan >= 1.21): `conan install cmake/3.18.2@`. - -The CI bot will start a new build only after being approved in EAP. Your PR can be reviewed in the middle time, but is not mandatory. - -The CI system will also report with messages in the PR any error in the process, even linking to the logs to see more details and debug. - -To contribute a Conan recipe into the `conan-center-index` repository you can submit a [Pull Request](https://github.com/conan-io/conan-center-index/pulls). The **build service** associated to this repo will generate binary packages automatically for the most common platforms and compilers. See [the Supported Platforms and Configurations page](supported_platforms_and_configurations.md) for a list of generated configurations. For a C++ library, the system is currently generating more than 100 binary packages. - -> ⚠️ **Note**: This not a testing service, it is a binary building service for package **releases**. Unit tests shouldn't be built nor run in recipes by default. Before submitting a pull request, please ensure that it works locally for some configurations. - -The pipeline will report errors and build logs by creating a comment in the pull-request after every commit. The message will include links to the logs for inspecting. - -### Before start - -Make sure you are using the latest [Conan client](https://conan.io/downloads) version, as recipes might evolve introducing features of the newer Conan releases. - - -### The recipe folder - -Create a new subfolder in the [recipes](https://github.com/conan-io/conan-center-index/tree/master/recipes) folder with the name of the package in lowercase. - -e.g: - -``` -. -+-- recipes -| +-- zlib -| +-- 1.2.8 -| +-- conanfile.py -| +-- test_package -| +-- 1.2.11 -| +-- conanfile.py -| +-- test_package -``` - -### The version folder/s - -The system supports to use the same recipe for several versions of the library and also to create different recipes for different versions - -- **1 version => 1 recipe** - - When the recipes change significantly between different library versions and reusing the recipe is not worth it, you can create a folder for each version and create inside both the “conanfile.py” and the “test_package” folder: - - ``` - . - +-- recipes - | +-- zlib - | +-- 1.2.8 - | +-- conanfile.py - | +-- test_package - - ``` - - -- **N versions => 1 recipe** - - Create a folder named `all` (just a convention) and put both the “conanfile.py” and the “test_package” folder there. With this approach, the “conanfile.py” won’t declare the `version` attribute. - - You will need to create a `config.yml` file to declare the matching between the versions and the folders. e.g: - - ``` - . - +-- recipes - | +-- mylibrary - | +-- all - | +-- conanfile.py - | +-- test_package - +-- config.yml - ``` - - **config.yml** file - - ``` - versions: - "1.1.0": - folder: all - "1.1.1": - folder: all - "1.1.2": - folder: all - ``` - -- **N versions => M recipes** - - This is the same approach as the previous one, you can use one recipe for a range of versions and a different one for another range of versions. Create the `config.yml` file and declare the folder for each version. - -### The conanfile.py and `test_package` folder - - In the folder/s created in the previous step, you have to create the `conanfile.py` and a [test_package](https://docs.conan.io/en/latest/creating_packages/getting_started.html#the-test-package-folder) folder. - -### The `conandata.yml` - - In the same directory than the `conanfile.py`, create a file named `conandata.yml`. This file has to be used in the recipe to indicate the origins of the source code. It must have an entry for each version, indicating the `URL` for downloading the source code and a checksum. - -``` -sources: - "1.1.0": - url: "https://www.url.org/source/mylib-1.0.0.tar.gz" - sha256: "8c48baf3babe0d505d16cfc0cf272589c66d3624264098213db0fb00034728e9" - "1.1.1": - url: "https://www.url.org/source/mylib-1.0.1.tar.gz" - sha256: "15b6393c20030aab02c8e2fe0243cb1d1d18062f6c095d67bca91871dc7f324a" -``` - -You must specify the checksum algorithm `sha256`. -If your sources are on GitHub, you can copy the link of the "Download ZIP" located in the "Clone or download" repository, make sure you are in the correct branch or TAG. - -Then in your `conanfile.py` method, it has to be used to download the sources: - -``` - def source(self): - tools.get(**self.conan_data["sources"][self.version]) -``` - -### How to provide a good recipe - -The [recipes](https://github.com/conan-io/conan-center-index/tree/master/recipes) available in CCI can be used as good examples, you can use them as the base for your recipe. - -If you are looking for header-only projects, you can take a look on [rapidjson](https://github.com/conan-io/conan-center-index/blob/master/recipes/rapidjson/all/conanfile.py), [rapidxml](https://github.com/conan-io/conan-center-index/blob/master/recipes/rapidxml/all/conanfile.py), and [nuklear](https://github.com/conan-io/conan-center-index/blob/master/recipes/nuklear/all/conanfile.py). Also, Conan Docs has a section about [how to package header-only libraries](https://docs.conan.io/en/latest/howtos/header_only.html). - -For C/C++ projects which use CMake for building, you can take a look on [szip](https://github.com/conan-io/conan-center-index/blob/master/recipes/szip/all/conanfile.py) and [recastnavigation](https://github.com/conan-io/conan-center-index/blob/master/recipes/recastnavigation/all/conanfile.py). - -Another common use case for CMake based projects, both header only and compiled, is _modeling components_ to match the `find_package` and export the correct targets from Conan's generators. A basic examples of this is [cpu_features](https://github.com/conan-io/conan-center-index/blob/master/recipes/cpu_features/all/conanfile.py), a moderate/intermediate example is [cpprestsdk](https://github.com/conan-io/conan-center-index/blob/master/recipes/cpprestsdk/all/conanfile.py), and a very complex example is [OpenCV](https://github.com/conan-io/conan-center-index/blob/master/recipes/opencv/4.x/conanfile.py). - -However, if you need to use autotools for building, you can take a look on [mpc](https://github.com/conan-io/conan-center-index/blob/master/recipes/mpc/all/conanfile.py), [libatomic_ops](https://github.com/conan-io/conan-center-index/blob/master/recipes/libatomic_ops/all/conanfile.py), [libev](https://github.com/conan-io/conan-center-index/blob/master/recipes/libev/all/conanfile.py). - -Many projects offer **pkg-config**'s `*.pc` files which need to be modeled using components. A prime example of this is [Wayland](https://github.com/conan-io/conan-center-index/blob/master/recipes/wayland/all/conanfile.py). - -For cases where a project only offers source files, but not a build script, you can add CMake support, but first, contact the upstream and open a PR offering building support. If it's rejected because the author doesn't want any kind of build script, or the project is abandoned, CCI can accept your build script. Take a look at [Bzip2](https://github.com/conan-io/conan-center-index/blob/master/recipes/bzip2/all/CMakeLists.txt) and [DirectShowBaseClasses](https://github.com/conan-io/conan-center-index/blob/master/recipes/directshowbaseclasses/all/CMakeLists.txt) as examples. - -Please be aware that ConanCenter only builds from sources and [pre-compiled binaries are not acceptable](https://github.com/conan-io/conan-center-index/blob/master/docs/packaging_policy.md) - -### Test the recipe locally - - The system will use the [conan-center hook](https://github.com/conan-io/hooks) to perform some quality checks. You can install the hook running: - -``` - $ conan config install https://github.com/conan-io/hooks.git -sf hooks -tf hooks - $ conan config set hooks.conan-center -``` - - The hook will show error messages but the `conan create` won’t fail unless you export the environment variable `CONAN_HOOK_ERROR_LEVEL=40`. - All hook checks will print a similar message: - - [HOOK - conan-center.py] post_source(): [LIBCXX MANAGEMENT (KB-H011)] OK - [HOOK - conan-center.py] post_package(): ERROR: [PACKAGE LICENSE] No package licenses found - -Call `conan create . lib/1.0@` in the folder of the recipe using the profile you want to test. For instance: - - cd conan-center-index/recipes/boost/all - conan create . 1.74.0@ - -### Updating conan hooks on your machine - -The hooks are updated from time to time, so it's worth keeping your own copy of the hooks updated regularly. To do this: - - conan config install - -### Debugging failed builds - - Go to the [Error Knowledge Base](error_knowledge_base.md) page to know more about Conan Center hook errors. - - Some common errors related to Conan can be found on [troubleshooting](https://docs.conan.io/en/latest/faq/troubleshooting.html) section. diff --git a/docs/labels.md b/docs/labels.md new file mode 100644 index 0000000000000..270b6b157a75a --- /dev/null +++ b/docs/labels.md @@ -0,0 +1,85 @@ +# Labels + +We use [GitHub labels](https://github.com/conan-io/conan-center-index/labels) to signal the status +of pull-requests and issues. Here you can find more information about the ones that have some +special meaning: + + +## Contents + + * [Bump dependencies](#bump-dependencies) + * [Bump version](#bump-version) + * [Infrastructure](#infrastructure) + * [Stale](#stale) + * [Unexpected Error](#unexpected-error) + * [User-approval pending](#user-approval-pending) + * [Library Request](#library-request) + * [Question](#question) + * [Upstream Update](#upstream-update) + * [conan.io/center](#conaniocenter) + +## Bump dependencies + +Label [`Bump dependencies`](https://github.com/conan-io/conan-center-index/pulls?q=is%3Aopen+is%3Apr+label%3A%22Bump+dependencies%22+) +is assigned by the bot to pull-requests that are just upgrading the version of the requirements that were already in the +recipe. + +> These pull-requests will be merged right away without requiring any approval (CI and CLA checks must have passed). + +If the pull request modifies anything else, the label won't be assigned, we need to be very careful about false positives. + +## Bump version + +Label [`Bump version`](https://github.com/conan-io/conan-center-index/pulls?q=is%3Aopen+is%3Apr+label%3A%22Bump+version%22) +is assigned by the bot to pull-requests that are just adding a new version of the library. The new version should satisfy +some extra conditions: sources should provide from the same URL domain as previous versions. +For now, only [SEMVER](https://semver.org/#semantic-versioning-200) and `` are acceptable version formats. + +> These pull-requests will be merged right away without requiring any approval (CI and CLA checks must have passed). + +If the pull request modifies anything else, the label won't be assigned, we need to be very careful about false positives. + +## Infrastructure + +Label [`infrastructure`](https://github.com/conan-io/conan-center-index/pulls?q=is%3Aopen+is%3Apr+label%3Ainfrastructure) is +manually assigned to pull requests that are waiting for something on the infrastructure side. Usually they are blocked and +cannot succeed because they need some tools, more memory,... these pull requests won't be marked as `stale`. + +## Stale + +Label [`stale`](https://github.com/conan-io/conan-center-index/pulls?q=is%3Aopen+is%3Apr+label%3Astale) is assigned to +pull requests without any activity during a long period of time. These pull requests will be closed if they don't get +any further activity. + +## Unexpected Error + +Label [`Unexpected Error`](https://github.com/conan-io/conan-center-index/pulls?q=is%3Aopen+is%3Apr+label%3A%22Unexpected+Error%22) +is assigned by the CI when the process finishes abnormally. +Usually it is some _random_ internal error and it won't happen next time the CI runs. +The CI will re-start your build automatically, the Github check `continuous-integration/jenkins/pr-merge` +will be changed to the status `Pending — This commit is being built` to signalize as running. + +> **Note**: Manually restarting a new build, by closing/opening the PR, will be added to the end of the CI build queue. + +## User-approval pending + +Label [`User-approval pending`](https://github.com/conan-io/conan-center-index/pulls?q=is%3Aopen+is%3Apr+label%3A%22User-approval+pending%22) +signals the pull request that have been submitted by an user who is not yet approved in ConanCenter. Once the user is +approved these pull requests will be triggered again automatically. + +## Library Request + +Request a new package to be created. + +## Question + +Further information is requested. Usually these are for issue where help is needed to solve a specific issue. These are a great way +to look for advice or recommendation about making changes to recipes. + +## Upstream Update + +Request a bump of a new package version. + +## conan.io/center + +Issues and features related to Web UI. diff --git a/docs/linters.md b/docs/linters.md new file mode 100644 index 0000000000000..b93f645337264 --- /dev/null +++ b/docs/linters.md @@ -0,0 +1,160 @@ +# ConanCenterIndex Linters + +Some linter configuration files are available in the folder [linter](../linter), which are executed by Github Actions +and are displayed during [code review](https://github.com/features/code-review) as annotations, to improve recipe quality. +They consume python scripts which are executed to fit CCI rules. Those scripts use [astroid](https://github.com/PyCQA/astroid) +and [pylint](https://pylint.pycqa.org/en/latest/) classes to parse Conan recipe files and manage their warnings and errors. + +Pylint by itself is not able to find ConanCenterIndex rules, so astroid is used to iterate over a conanfile's content and +validate CCI requirements. Pylint uses an [rcfile](https://pylint.pycqa.org/en/latest/user_guide/configuration/index.html) +to configure plugins, warnings and errors which should be enabled or disabled. + + +## Contents + + * [Understanding the different linters](#understanding-the-different-linters) + * [Running the linters locally](#running-the-linters-locally) + * [Pylint configuration files](#pylint-configuration-files) + * [Linter Warning and Errors](#linter-warning-and-errors) + * [E9006 - conan-import-conanfile: ConanFile should be imported from conan](#e9006---conan-import-conanfile-conanfile-should-be-imported-from-conan) + * [E9005 - conan-missing-name: Every conan recipe must contain the attribute name](#e9005---conan-missing-name-every-conan-recipe-must-contain-the-attribute-name) + * [E9004 - conan-package-name: Conan package names must be lower-case](#e9004---conan-package-name-conan-package-names-must-be-lower-case) + * [E9007 - conan-test-no-name: Do not add name attribute in test package recipes](#e9007---conan-test-no-name-do-not-add-name-attribute-in-test-package-recipes) + * [E9008 - conan-import-errors: Deprecated imports should be replaced by new imports](#e9008---conan-import-errors-deprecated-imports-should-be-replaced-by-new-imports) + * [E9009 - conan-import-error-conanexception: conans.errors is deprecated and conan.errors should be used instead](#e9009---conan-import-error-conanexception-conanserrors-is-deprecated-and-conanerrors-should-be-used-instead) + * [E9010 - conan-import-error-conaninvalidconfiguration: conans.errors is deprecated and conan.errors should be used instead](#e9010---conan-import-error-conaninvalidconfiguration-conanserrors-is-deprecated-and-conanerrors-should-be-used-instead) + * [E9011 - conan-import-tools: Importing conan.tools or conan.tools.xxx.zzz.yyy should be considered as private](#e9011---conan-import-tools-importing-conantools-or-conantoolsxxxzzzyyy-should-be-considered-as-private) + +## Understanding the different linters + +There's a three classes of linters currently in place for ConanCenterIndex + +- ConanCenter Hook - these are responsible for validating the structure of the recipes and packages. +- Pylint Linter - these are used to ensure the code quality and conventions of a recipes (i.e `conanfile.py`) +- Yaml Checks - stylistic guidance and schema validation check for support files and best practices + +## Running the linters locally + +Check the [Developing Recipes](developing_recipes_locally.md) for more information on each of the three linters. + +## Pylint configuration files + +- [Pylint Recipe](../linter/pylintrc_recipe): This `rcfile` lists plugins and rules to be executed over all recipes (not test package) and validate them. +- [Pylint Test Package Recipe](../linter/pylintrc_testpackage): This `rcfile` lists plugins and rules to be executed over all recipes in test package folders only: + +## Linter Warning and Errors + +Here is the list of current warning and errors provided by pylint, when using CCI configuration. + +### E9006 - conan-import-conanfile: ConanFile should be imported from conan + +```python +from conans import ConanFile +``` + +Should be replaced by: + +```python +from conan import Conanfile +``` + +### E9005 - conan-missing-name: Every conan recipe must contain the attribute name + +The attribute `name` is always expected. On the other hand, `version` should not be listed. + +```python +def BazConanfile(ConanFile): + name = "baz" +``` + +### E9004 - conan-package-name: Conan package names must be lower-case + +The package name is always lower-case, even when the upstream uses another format + +```python +def FoobarConanfile(ConanFile): + name = "foobar" +``` + +### E9007 - conan-test-no-name: Do not add name attribute in test package recipes + +The test package is not a recipe, thus, it should not have a name + +```python +def TestPackageConanFile(ConanFile): + name = "test_package" # Wrong! +``` + +### E9008 - conan-import-errors: Deprecated imports should be replaced by new imports + +Read [v2_linter](v2_linter.md) for a list of mappings of v1 to v2. +Regular imports from `conans.tools` are now updated: + +```python +from conans import tools +... + +tools.rmdir(os.path.join(self.package_folder, "shared")) +``` + +Should be replaced by specialized tools, prepared for Conan 2.0 + +```python +from conan.tools.files import rmdir +... + +rmdir(self, os.path.join(self.package_folder, "shared")) +``` + +### E9009 - conan-import-error-conanexception: conans.errors is deprecated and conan.errors should be used instead + +```python +from conans.errors import ConanException +``` + +Should be replaced by: + +```python +from conan.errors import ConanException +``` + +Only the namespace `conans` has been replaced by `conan`. + +### E9010 - conan-import-error-conaninvalidconfiguration: conans.errors is deprecated and conan.errors should be used instead + +```python +from conans.errors import ConanInvalidConfiguration +``` + +Should be replaced by: + +```python +from conan.errors import ConanInvalidConfiguration +``` + +Only the namespace `conans` has been replaced by `conan`. + +### E9011 - conan-import-tools: Importing conan.tools or conan.tools.xxx.zzz.yyy should be considered as private + +Documented on [conanfile.tools](https://docs.conan.io/en/latest/reference/conanfile/tools.html): +It's not allowed to use `tools.xxx` directly: + +```python +from conan import tools +... + +tools.scm.Version(self.version) +``` + +Neither sub modules: + +```python +from conan.tools.apple.apple import is_apple_os +``` + +Only modules under `conan.tools` and `conan.tools.xxx` are allowed: + +```python +from conan.tools.files import rmdir +from conan.tools import scm +```` diff --git a/docs/package_templates/README.md b/docs/package_templates/README.md new file mode 100644 index 0000000000000..76d696e57b0a0 --- /dev/null +++ b/docs/package_templates/README.md @@ -0,0 +1,27 @@ +## Package Templates + +A brief description about each template available: + +#### Autotools package + +It's listed under [autotools_package](autotools_package) folder. It fits projects which use `autotools` or `make` to be built. + +#### CMake package + +It's listed under [cmake_package](cmake_package) folder. It fits projects which use `CMake` to be built. + +#### Header only + +It's listed under [header_only](header_only) folder. It fits projects which only copy header and have the same package ID always. + +#### MSBuild package + +It's listed under [msbuild_package](msbuild_package) folder. It fits projects which use `msbuild` to be built. + +#### Prebuilt tool package + +It's listed under [prebuilt_tool_package](prebuilt_tool_package) folder. It fits projects which only copy generated binaries (executables and libraries). + +#### Meson package + +It's listed under [meson_package](meson_package) folder. It fits projects which use `Meson` to be built. diff --git a/docs/package_templates/autotools_package/all/conandata.yml b/docs/package_templates/autotools_package/all/conandata.yml new file mode 100644 index 0000000000000..0cb43769c334f --- /dev/null +++ b/docs/package_templates/autotools_package/all/conandata.yml @@ -0,0 +1,25 @@ +sources: + # Newer versions at the top + "1.2.0": + url: + - "https://mirror1.net/package-1.2.0.tar.gz" + - "https://mirror2.net/package-1.2.0.tar.gz" + sha256: "________________________________________________________________" + "1.1.0": + url: + - "https://mirror1.net/package-1.1.0.tar.gz" + - "https://mirror2.net/package-1.1.0.tar.gz" + sha256: "________________________________________________________________" +patches: + # Newer versions at the top + "1.1.0": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "correct the order of cmake min and project" + patch_type: "backport" + patch_source: "https://github.com/owner/package/pulls/42" + sha256: "________________________________________________________________" + - patch_file: "patches/0002-fix-linux.patch" + patch_description: "add missing header to support linux" + patch_type: "portability" + patch_source: "https://github.com/owner/package/issues/0" + sha256: "________________________________________________________________" diff --git a/docs/package_templates/autotools_package/all/conanfile.py b/docs/package_templates/autotools_package/all/conanfile.py new file mode 100644 index 0000000000000..6620e517ff6db --- /dev/null +++ b/docs/package_templates/autotools_package/all/conanfile.py @@ -0,0 +1,179 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.build import check_min_cppstd, cross_building +from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +import os + + +required_conan_version = ">=1.53.0" + +# +# INFO: Please, remove all comments before pushing your PR! +# + + +class PackageConan(ConanFile): + name = "package" + description = "short description" + # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ + # In case not listed there, use "LicenseRef-" + license = "" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/project/package" + # no "conan" and project name in topics. Use topics from the upstream listed on GH + topics = ("topic1", "topic2", "topic3") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_foobar": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_foobar": True, + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + # no exports_sources attribute, but export_sources(self) method instead + # this allows finer grain exportation of patches per version + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + # for plain C projects only + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + # src_folder must use the same source folder name the project + basic_layout(self, src_folder="src") + + def requirements(self): + # prefer self.requires method instead of requires attribute + self.requires("dependency/0.8.1") + if self.options.with_foobar: + self.requires("foobar/0.1.0") + + def validate(self): + # validate the minimum cpp standard supported. Only for C++ projects + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.info.settings.os not in ["Linux", "FreeBSD", "MacOS"]: + raise ConanInvalidConfiguration(f"{self.ref} is not supported on {self.info.settings.os}.") + + # if another tool than the compiler or autotools is required to build the project (pkgconf, bison, flex etc) + def build_requirements(self): + # only if we have to call autoreconf + self.tool_requires("libtool/x.y.z") + # only if upstream configure.ac relies on PKG_CHECK_MODULES macro + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/x.y.z") + # required to suppport windows as a build machine + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): + self.tool_requires("msys2/cci.latest") + # for msvc support to get compile & ar-lib scripts (may be avoided if shipped in source code of the library) + if is_msvc(self): + self.tool_requires("automake/x.y.z") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + # inject tool_requires env vars in build scope (not needed if there is no tool_requires) + env = VirtualBuildEnv(self) + env.generate() + # inject requires env vars in build scope + # it's required in case of native build when there is AutotoolsDeps & at least one dependency which might be shared, because configure tries to run a test executable + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") + # --fpic is automatically managed when 'fPIC'option is declared + # --enable/disable-shared is automatically managed when 'shared' option is declared + tc = AutotoolsToolchain(self) + # autotools usually uses 'yes' and 'no' to enable/disable options + yes_no = lambda v: "yes" if v else "no" + tc.configure_args.extend([ + f"--with-foobar={yes_no(self.options.with_foobar)}", + "--enable-tools=no", + "--enable-manpages=no", + ]) + tc.generate() + # generate pkg-config files of dependencies (useless if upstream configure.ac doesn't rely on PKG_CHECK_MODULES macro) + tc = PkgConfigDeps(self) + tc.generate() + # generate dependencies for autotools + tc = AutotoolsDeps(self) + tc.generate() + + # If Visual Studio is supported + if is_msvc(self): + env = Environment() + # get compile & ar-lib from automake (or eventually lib source code if available) + # it's not always required to wrap CC, CXX & AR with these scripts, it depends on how much love was put in + # upstream build files + compile_wrapper = unix_path(self, self._user_info_build["automake"].compile) + ar_wrapper = unix_path(self, self._user_info_build["automake"].ar_lib) + env.define("CC", f"{compile_wrapper} cl -nologo") + env.define("CXX", f"{compile_wrapper} cl -nologo") + env.define("LD", "link -nologo") + env.define("AR", f"{ar_wrapper} \"lib -nologo\"") + env.define("NM", "dumpbin -symbols") + env.define("OBJDUMP", ":") + env.define("RANLIB", ":") + env.define("STRIP", ":") + env.vars(self).save_script("conanbuild_msvc") + + def build(self): + # apply patches listed in conandata.yml + apply_conandata_patches(self) + autotools = Autotools(self) + # (optional) run autoreconf to regenerate configure file (libtool should be in tool_requires) + autotools.autoreconf() + # ./configure + toolchain file + autotools.configure() + autotools.make() + + def package(self): + copy(self, pattern="LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + + # some files extensions and folders are not allowed. Please, read the FAQs to get informed. + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + # In shared lib/executable files, autotools set install_name (macOS) to lib dir absolute path instead of @rpath, it's not relocatable, so fix it + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.libs = ["package_lib"] + + # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) + self.cpp_info.set_property("pkg_config_name", "package") + + # If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["dl", "m", "pthread"]) diff --git a/docs/package_templates/autotools_package/all/test_package/CMakeLists.txt b/docs/package_templates/autotools_package/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d5f12b4376cdb --- /dev/null +++ b/docs/package_templates/autotools_package/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) # if the project is pure C +# project(test_package LANGUAGES CXX) # if the project uses c++ + +find_package(package REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE package::package) +# In case the target project need a specific C++ standard +# target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/docs/package_templates/autotools_package/all/test_package/conanfile.py b/docs/package_templates/autotools_package/all/test_package/conanfile.py new file mode 100644 index 0000000000000..48499fa0989d9 --- /dev/null +++ b/docs/package_templates/autotools_package/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/docs/package_templates/autotools_package/all/test_package/test_package.c b/docs/package_templates/autotools_package/all/test_package/test_package.c new file mode 100644 index 0000000000000..f949b7f4a20f4 --- /dev/null +++ b/docs/package_templates/autotools_package/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include +#include +#include "package/foobar.h" // Make sure includes work as expected + + +int main(void) { + printf("Create a minimal usage for the target project here.\n"); + printf("Avoid big examples, bigger than 100 lines\n"); + printf("Avoid networking connections.\n"); + printf("Avoid background apps or servers.\n"); + printf("The propose is testing the generated artifacts only.\n"); + + foobar_print_version(); // Make sure to call something that will require linkage for compiled libraries + + return EXIT_SUCCESS; +} diff --git a/docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt b/docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e4a742eca89e3 --- /dev/null +++ b/docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) # if the project is pure C +# project(test_package LANGUAGES CXX) # if the project uses c++ + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(package REQUIRED CONFIG) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/docs/package_templates/autotools_package/all/test_v1_package/conanfile.py b/docs/package_templates/autotools_package/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/docs/package_templates/autotools_package/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/autotools_package/config.yml b/docs/package_templates/autotools_package/config.yml new file mode 100644 index 0000000000000..a885cbf942a74 --- /dev/null +++ b/docs/package_templates/autotools_package/config.yml @@ -0,0 +1,6 @@ +versions: + # Newer versions at the top + "1.2.0": + folder: all + "1.1.0": + folder: all diff --git a/docs/package_templates/cmake_package/all/conandata.yml b/docs/package_templates/cmake_package/all/conandata.yml new file mode 100644 index 0000000000000..0cb43769c334f --- /dev/null +++ b/docs/package_templates/cmake_package/all/conandata.yml @@ -0,0 +1,25 @@ +sources: + # Newer versions at the top + "1.2.0": + url: + - "https://mirror1.net/package-1.2.0.tar.gz" + - "https://mirror2.net/package-1.2.0.tar.gz" + sha256: "________________________________________________________________" + "1.1.0": + url: + - "https://mirror1.net/package-1.1.0.tar.gz" + - "https://mirror2.net/package-1.1.0.tar.gz" + sha256: "________________________________________________________________" +patches: + # Newer versions at the top + "1.1.0": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "correct the order of cmake min and project" + patch_type: "backport" + patch_source: "https://github.com/owner/package/pulls/42" + sha256: "________________________________________________________________" + - patch_file: "patches/0002-fix-linux.patch" + patch_description: "add missing header to support linux" + patch_type: "portability" + patch_source: "https://github.com/owner/package/issues/0" + sha256: "________________________________________________________________" diff --git a/docs/package_templates/cmake_package/all/conanfile.py b/docs/package_templates/cmake_package/all/conanfile.py new file mode 100644 index 0000000000000..13a2108b0e8f3 --- /dev/null +++ b/docs/package_templates/cmake_package/all/conanfile.py @@ -0,0 +1,167 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc_static_runtime, is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir, replace_in_file +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +import os + + +required_conan_version = ">=1.53.0" + +# +# INFO: Please, remove all comments before pushing your PR! +# + + +class PackageConan(ConanFile): + name = "package" + description = "short description" + # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ + # In case not listed there, use "LicenseRef-" + license = "" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/project/package" + # no "conan" and project name in topics. Use topics from the upstream listed on GH + topics = ("topic1", "topic2", "topic3") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _min_cppstd(self): + return 17 + + # in case the project requires C++14/17/20/... the minimum compiler version should be listed + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "clang": "7", + "apple-clang": "10", + } + + # no exports_sources attribute, but export_sources(self) method instead + # this allows finer grain exportation of patches per version + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + # for plain C projects only + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + # src_folder must use the same source folder name the project + cmake_layout(self, src_folder="src") + + def requirements(self): + # prefer self.requires method instead of requires attribute + self.requires("dependency/0.8.1") + + def validate(self): + # validate the minimum cpp standard supported. For C++ projects only + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + check_min_vs(self, 191) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + # in case it does not work in another configuration, it should validated here too + if is_msvc(self) and self.info.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} can not be built as shared on Visual Studio and msvc.") + + # if another tool than the compiler or CMake is required to build the project (pkgconf, bison, flex etc) + def build_requirements(self): + self.tool_requires("tool/x.y.z") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + # BUILD_SHARED_LIBS and POSITION_INDEPENDENT_CODE are automatically parsed when self.options.shared or self.options.fPIC exist + tc = CMakeToolchain(self) + # Boolean values are preferred instead of "ON"/"OFF" + tc.variables["PACKAGE_CUSTOM_DEFINITION"] = True + if is_msvc(self): + # don't use self.settings.compiler.runtime + tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) + # deps_cpp_info, deps_env_info and deps_user_info are no longer used + if self.dependencies["dependency"].options.foobar: + tc.variables["DEPENDENCY_LIBPATH"] = self.dependencies["dependency"].cpp_info.libdirs + # cache_variables should be used sparingly, example setting cmake policies + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + # In case there are dependencies listed on requirements, CMakeDeps should be used + tc = CMakeDeps(self) + tc.generate() + # In case there are dependencies listed on build_requirements, VirtualBuildEnv should be used + tc = VirtualBuildEnv(self) + tc.generate(scope="build") + + def _patch_sources(self): + apply_conandata_patches(self) + # remove bundled xxhash + rm(self, "whateer.*", os.path.join(self.source_folder, "lib")) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "...", "") + + def build(self): + self._patch_sources() # It can be apply_conandata_patches(self) only in case no more patches are needed + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + # some files extensions and folders are not allowed. Please, read the FAQs to get informed. + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + + def package_info(self): + self.cpp_info.libs = ["package_lib"] + + # if package has an official FindPACKAGE.cmake listed in https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules + # examples: bzip2, freetype, gdal, icu, libcurl, libjpeg, libpng, libtiff, openssl, sqlite3, zlib... + self.cpp_info.set_property("cmake_module_file_name", "PACKAGE") + self.cpp_info.set_property("cmake_module_target_name", "PACKAGE::PACKAGE") + # if package provides a CMake config file (package-config.cmake or packageConfig.cmake, with package::package target, usually installed in /lib/cmake//) + self.cpp_info.set_property("cmake_file_name", "package") + self.cpp_info.set_property("cmake_target_name", "package::package") + # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) + self.cpp_info.set_property("pkg_config_name", "package") + + # If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + self.cpp_info.system_libs.append("pthread") + self.cpp_info.system_libs.append("dl") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "PACKAGE" + self.cpp_info.filenames["cmake_find_package_multi"] = "package" + self.cpp_info.names["cmake_find_package"] = "PACKAGE" + self.cpp_info.names["cmake_find_package_multi"] = "package" diff --git a/docs/package_templates/cmake_package/all/test_package/CMakeLists.txt b/docs/package_templates/cmake_package/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..00e3c3ca60a6d --- /dev/null +++ b/docs/package_templates/cmake_package/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) # if the project is pure C +project(test_package CXX) # if the project uses c++ + +find_package(package REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE package::package) +# In case the target project need a specific C++ standard +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/docs/package_templates/cmake_package/all/test_package/conanfile.py b/docs/package_templates/cmake_package/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1111583fea732 --- /dev/null +++ b/docs/package_templates/cmake_package/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/docs/package_templates/cmake_package/all/test_package/test_package.cpp b/docs/package_templates/cmake_package/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..8e653f30a5476 --- /dev/null +++ b/docs/package_templates/cmake_package/all/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include +#include +#include "package/foobar.hpp" + + +int main(void) { + std::cout << "Create a minimal usage for the target project here." << std::endl; + std::cout << "Avoid big examples, bigger than 100 lines" << std::endl; + std::cout << "Avoid networking connections." << std::endl; + std::cout << "Avoid background apps or servers." << std::endl; + std::cout << "The propose is testing the generated artifacts only." << std::endl; + + foobar.print_version(); + + return EXIT_SUCCESS; +} diff --git a/docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt b/docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/docs/package_templates/cmake_package/all/test_v1_package/conanfile.py b/docs/package_templates/cmake_package/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/docs/package_templates/cmake_package/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/cmake_package/config.yml b/docs/package_templates/cmake_package/config.yml new file mode 100644 index 0000000000000..a885cbf942a74 --- /dev/null +++ b/docs/package_templates/cmake_package/config.yml @@ -0,0 +1,6 @@ +versions: + # Newer versions at the top + "1.2.0": + folder: all + "1.1.0": + folder: all diff --git a/docs/package_templates/header_only/all/conandata.yml b/docs/package_templates/header_only/all/conandata.yml new file mode 100644 index 0000000000000..0cb43769c334f --- /dev/null +++ b/docs/package_templates/header_only/all/conandata.yml @@ -0,0 +1,25 @@ +sources: + # Newer versions at the top + "1.2.0": + url: + - "https://mirror1.net/package-1.2.0.tar.gz" + - "https://mirror2.net/package-1.2.0.tar.gz" + sha256: "________________________________________________________________" + "1.1.0": + url: + - "https://mirror1.net/package-1.1.0.tar.gz" + - "https://mirror2.net/package-1.1.0.tar.gz" + sha256: "________________________________________________________________" +patches: + # Newer versions at the top + "1.1.0": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "correct the order of cmake min and project" + patch_type: "backport" + patch_source: "https://github.com/owner/package/pulls/42" + sha256: "________________________________________________________________" + - patch_file: "patches/0002-fix-linux.patch" + patch_description: "add missing header to support linux" + patch_type: "portability" + patch_source: "https://github.com/owner/package/issues/0" + sha256: "________________________________________________________________" diff --git a/docs/package_templates/header_only/all/conanfile.py b/docs/package_templates/header_only/all/conanfile.py new file mode 100644 index 0000000000000..1f987bd08a8da --- /dev/null +++ b/docs/package_templates/header_only/all/conanfile.py @@ -0,0 +1,117 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +import os + + +required_conan_version = ">=1.52.0" + + +class PackageConan(ConanFile): + name = "package" + description = "short description" + # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ + # In case not listed there, use "LicenseRef-" + license = "" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/project/package" + # no "conan" and project name in topics. Use topics from the upstream listed on GH + # Keep 'hearder-only' as topic + topics = ("topic1", "topic2", "topic3", "header-only") + settings = "os", "arch", "compiler", "build_type" # even for header only + no_copy_source = True # do not copy sources to build folder for header only projects, unless, need to apply patches + + @property + def _min_cppstd(self): + return 14 + + # in case the project requires C++14/17/20/... the minimum compiler version should be listed + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "15", + "msvc": "14.1", + "gcc": "5", + "clang": "5", + "apple-clang": "5.1", + } + + # no exports_sources attribute, but export_sources(self) method instead + # this allows finer grain exportation of patches per version + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + # src_folder must use the same source folder name the project + basic_layout(self, src_folder="src") + + def requirements(self): + # prefer self.requires method instead of requires attribute + # direct dependencies of header only libs are always transitive since they are included in public headers + self.requires("dependency/0.8.1", transitive_headers=True) + + # same package ID for any package + def package_id(self): + self.info.clear() + + def validate(self): + # FIXME: `self.settings` is not available in 2.0 but there are plenty of open issues about + # the migration point. For now we are only going to write valid 1.x recipes until we have a proper answer + if self.settings.compiler.get_safe("cppstd"): + # validate the minimum cpp standard supported when installing the package. For C++ projects only + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + # in case it does not work in another configuration, it should validated here too + if self.settings.os == "Windows": + raise ConanInvalidConfiguration(f"{self.ref} can not be used on Windows.") + + def source(self): + # download source package and extract to source folder + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + # not mandatory when there is no patch, but will suppress warning message about missing build() method + def build(self): + # The attribute no_copy_source should not be used when applying patches in build + apply_conandata_patches(self) + + # copy all files to the package folder + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy( + self, + pattern="*.h", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include"), + ) + + def package_info(self): + # folders not used for header-only + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + # if package has an official FindPACKAGE.cmake listed in https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules + # examples: bzip2, freetype, gdal, icu, libcurl, libjpeg, libpng, libtiff, openssl, sqlite3, zlib... + self.cpp_info.set_property("cmake_module_file_name", "PACKAGE") + self.cpp_info.set_property("cmake_module_target_name", "PACKAGE::PACKAGE") + # if package provides a CMake config file (package-config.cmake or packageConfig.cmake, with package::package target, usually installed in /lib/cmake//) + self.cpp_info.set_property("cmake_file_name", "package") + self.cpp_info.set_property("cmake_target_name", "package::package") + # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) + self.cpp_info.set_property("pkg_config_name", "package") + + # If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["dl", "m", "pthread"]) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "PACKAGE" + self.cpp_info.filenames["cmake_find_package_multi"] = "package" + self.cpp_info.names["cmake_find_package"] = "PACKAGE" + self.cpp_info.names["cmake_find_package_multi"] = "package" diff --git a/docs/package_templates/header_only/all/test_package/CMakeLists.txt b/docs/package_templates/header_only/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..58ff75575bd54 --- /dev/null +++ b/docs/package_templates/header_only/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) # if the project is pure C +project(test_package LANGUAGES CXX) # if the project uses c++ + +find_package(package REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE package::package) +# In case the target project need a specific C++ standard +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/docs/package_templates/header_only/all/test_package/conanfile.py b/docs/package_templates/header_only/all/test_package/conanfile.py new file mode 100644 index 0000000000000..48499fa0989d9 --- /dev/null +++ b/docs/package_templates/header_only/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/docs/package_templates/header_only/all/test_package/test_package.cpp b/docs/package_templates/header_only/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..8e653f30a5476 --- /dev/null +++ b/docs/package_templates/header_only/all/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include +#include +#include "package/foobar.hpp" + + +int main(void) { + std::cout << "Create a minimal usage for the target project here." << std::endl; + std::cout << "Avoid big examples, bigger than 100 lines" << std::endl; + std::cout << "Avoid networking connections." << std::endl; + std::cout << "Avoid background apps or servers." << std::endl; + std::cout << "The propose is testing the generated artifacts only." << std::endl; + + foobar.print_version(); + + return EXIT_SUCCESS; +} diff --git a/docs/package_templates/header_only/all/test_v1_package/CMakeLists.txt b/docs/package_templates/header_only/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0aeb3e1d92584 --- /dev/null +++ b/docs/package_templates/header_only/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) # if the project is pure C +project(test_package LANGUAGES CXX) # if the project uses c++ + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/docs/package_templates/header_only/all/test_v1_package/conanfile.py b/docs/package_templates/header_only/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/docs/package_templates/header_only/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/header_only/config.yml b/docs/package_templates/header_only/config.yml new file mode 100644 index 0000000000000..a885cbf942a74 --- /dev/null +++ b/docs/package_templates/header_only/config.yml @@ -0,0 +1,6 @@ +versions: + # Newer versions at the top + "1.2.0": + folder: all + "1.1.0": + folder: all diff --git a/docs/package_templates/meson_package/all/conandata.yml b/docs/package_templates/meson_package/all/conandata.yml new file mode 100644 index 0000000000000..9d0f08dfa76d4 --- /dev/null +++ b/docs/package_templates/meson_package/all/conandata.yml @@ -0,0 +1,24 @@ +sources: + # Newer versions at the top + "1.2.0": + url: + - "https://mirror1.net/package-1.2.0.tar.gz", + - "https://mirror2.net/package-1.2.0.tar.gz", + sha256: "________________________________________________________________" + "1.1.0": + - "https://mirror1.net/package-1.1.0.tar.gz", + - "https://mirror2.net/package-1.1.0.tar.gz", + sha256: "________________________________________________________________" +patches: + # Newer versions at the top + "1.1.0": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "correct the order of cmake min and project" + patch_type: "backport" + patch_source: "https://github.com/owner/package/pulls/42" + sha256: "________________________________________________________________" + - patch_file: "patches/0002-fix-linux.patch" + patch_description: "add missing header to support linux" + patch_type: "portability" + patch_source: "https://github.com/owner/package/issues/0" + sha256: "________________________________________________________________" diff --git a/docs/package_templates/meson_package/all/conanfile.py b/docs/package_templates/meson_package/all/conanfile.py new file mode 100644 index 0000000000000..3e9e0431e7ed9 --- /dev/null +++ b/docs/package_templates/meson_package/all/conanfile.py @@ -0,0 +1,156 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.build import check_min_cppstd +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.gnu import PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain, MesonDeps +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.scm import Version +import os + + +required_conan_version = ">=1.53.0" + +# +# INFO: Please, remove all comments before pushing your PR! +# + + +class PackageConan(ConanFile): + name = "package" + description = "short description" + # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ + # In case not listed there, use "LicenseRef-" + license = "" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/project/package" + # no "conan" and project name in topics. Use topics from the upstream listed on GH + topics = ("topic1", "topic2", "topic3") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _min_cppstd(self): + return 17 + + # in case the project requires C++14/17/20/... the minimum compiler version should be listed + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "clang": "7", + "apple-clang": "10", + } + + # no exports_sources attribute, but export_sources(self) method instead + # this allows finer grain exportation of patches per version + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + # for plain C projects only + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + # src_folder must use the same source folder name the project + basic_layout(self, src_folder="src") + + def requirements(self): + # prefer self.requires method instead of requires attribute + self.requires("dependency/0.8.1") + + def validate(self): + # validate the minimum cpp standard supported. For C++ projects only + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + check_min_vs(self, 191) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + # in case it does not work in another configuration, it should validated here too + if is_msvc(self) and self.info.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} can not be built as shared on Visual Studio and msvc.") + + # if another tool than the compiler or Meson is required to build the project (pkgconf, bison, flex etc) + def build_requirements(self): + # CCI policy assumes that Meson may not be installed on consumers machine + self.tool_requires("meson/0.63.3") + # pkgconf is largely used by Meson, it should be added in build requirement when there are dependencies + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/1.9.3") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + # default_library and b_staticpic are automatically parsed when self.options.shared and self.options.fpic exist + # buildtype is automatically parsed for self.settings + tc = MesonToolchain(self) + # In case need to pass definitions directly to the compiler + tc.preprocessor_definitions["MYDEFINE"] = "MYDEF_VALUE" + # Meson project options may vary their types + tc.project_options["tests"] = False + tc.generate() + # In case there are dependencies listed on requirements, PkgConfigDeps should be used + tc = PkgConfigDeps(self) + tc.generate() + # Sometimes, when PkgConfigDeps is not enough to find requirements, MesonDeps should solve it + tc = MesonDeps(self) + tc.generate() + # In case there are dependencies listed on build_requirements, VirtualBuildEnv should be used + tc = VirtualBuildEnv(self) + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # remove bundled xxhash + rm(self, "whateer.*", os.path.join(self.source_folder, "lib")) + replace_in_file(self, os.path.join(self.source_folder, "meson.build"), "...", "") + + def build(self): + self._patch_sources() # It can be apply_conandata_patches(self) only in case no more patches are needed + meson = Meson(self) + meson.configure() + meson.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + meson = Meson(self) + meson.install() + + # some files extensions and folders are not allowed. Please, read the FAQs to get informed. + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + + # In shared lib/executable files, meson set install_name (macOS) to lib dir absolute path instead of @rpath, it's not relocatable, so fix it + fix_apple_shared_install_name(self) + + def package_info(self): + # avoid collect_libs(), prefer explicit library name instead + self.cpp_info.libs = ["package_lib"] + # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) + self.cpp_info.set_property("pkg_config_name", "package") + # If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) diff --git a/docs/package_templates/meson_package/all/test_package/conanfile.py b/docs/package_templates/meson_package/all/test_package/conanfile.py new file mode 100644 index 0000000000000..287ce44d8a78e --- /dev/null +++ b/docs/package_templates/meson_package/all/test_package/conanfile.py @@ -0,0 +1,33 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "PkgConfigDeps", "MesonToolchain", "VirtualRunEnv", "VirtualBuildEnv" + test_type = "explicit" + + def layout(self): + basic_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.tool_requires("meson/0.63.3") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/1.9.3") + + def build(self): + meson = Meson(self) + meson.configure() + meson.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/docs/package_templates/meson_package/all/test_package/meson.build b/docs/package_templates/meson_package/all/test_package/meson.build new file mode 100644 index 0000000000000..481f6cfd116c1 --- /dev/null +++ b/docs/package_templates/meson_package/all/test_package/meson.build @@ -0,0 +1,5 @@ +project('test_package', 'cpp') +package_dep = dependency('package') +executable('test_package', + sources : ['test_package.cpp'], + dependencies : [package_dep]) diff --git a/docs/package_templates/meson_package/all/test_package/test_package.cpp b/docs/package_templates/meson_package/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..315875d954777 --- /dev/null +++ b/docs/package_templates/meson_package/all/test_package/test_package.cpp @@ -0,0 +1,18 @@ +#include +#include +#include "package/foobar.hpp" + + +int main(void) { + /* + * Create a minimal usage for the target project here. + * Avoid big examples, bigger than 100 lines. + * Avoid networking connections. + * Avoid background apps or servers. + * The propose is testing the generated artifacts only. + */ + + foobar.print_version(); + + return EXIT_SUCCESS; +} diff --git a/docs/package_templates/meson_package/all/test_v1_package/conanfile.py b/docs/package_templates/meson_package/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c5b074313827d --- /dev/null +++ b/docs/package_templates/meson_package/all/test_v1_package/conanfile.py @@ -0,0 +1,23 @@ +from conans import ConanFile, Meson +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "pkg_config" + + def build_requirements(self): + self.build_requires("meson/0.63.3") + self.build_requires("pkgconf/1.9.3") + + def build(self): + meson = Meson(self) + meson.configure(build_folder="bin", source_folder="../test_package") + meson.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/meson_package/config.yml b/docs/package_templates/meson_package/config.yml new file mode 100644 index 0000000000000..a885cbf942a74 --- /dev/null +++ b/docs/package_templates/meson_package/config.yml @@ -0,0 +1,6 @@ +versions: + # Newer versions at the top + "1.2.0": + folder: all + "1.1.0": + folder: all diff --git a/docs/package_templates/msbuild_package/all/conandata.yml b/docs/package_templates/msbuild_package/all/conandata.yml new file mode 100644 index 0000000000000..0cb43769c334f --- /dev/null +++ b/docs/package_templates/msbuild_package/all/conandata.yml @@ -0,0 +1,25 @@ +sources: + # Newer versions at the top + "1.2.0": + url: + - "https://mirror1.net/package-1.2.0.tar.gz" + - "https://mirror2.net/package-1.2.0.tar.gz" + sha256: "________________________________________________________________" + "1.1.0": + url: + - "https://mirror1.net/package-1.1.0.tar.gz" + - "https://mirror2.net/package-1.1.0.tar.gz" + sha256: "________________________________________________________________" +patches: + # Newer versions at the top + "1.1.0": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "correct the order of cmake min and project" + patch_type: "backport" + patch_source: "https://github.com/owner/package/pulls/42" + sha256: "________________________________________________________________" + - patch_file: "patches/0002-fix-linux.patch" + patch_description: "add missing header to support linux" + patch_type: "portability" + patch_source: "https://github.com/owner/package/issues/0" + sha256: "________________________________________________________________" diff --git a/docs/package_templates/msbuild_package/all/conanfile.py b/docs/package_templates/msbuild_package/all/conanfile.py new file mode 100644 index 0000000000000..ae7b3c4c2484c --- /dev/null +++ b/docs/package_templates/msbuild_package/all/conanfile.py @@ -0,0 +1,106 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc, vs_layout, MSBuildDeps, MSBuildToolchain, MSBuild, VCVars +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, replace_in_file +import os + + +required_conan_version = ">=1.53.0" + + +class PackageConan(ConanFile): + name = "package" + description = "short description" + # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ + # In case not listed there, use "LicenseRef-" + license = "" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/project/package" + # no "conan" and project name in topics. Use topics from the upstream listed on GH + topics = ("topic1", "topic2", "topic3") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + # no exports_sources attribute, but export_sources(self) method instead + # this allows finer grain exportation of patches per version + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + # for plain C projects only + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + vs_layout(self) + + def requirements(self): + # prefer self.requires method instead of requires attribute + self.requires("dependency/0.8.1") + + def validate(self): + # in case it does not work in another configuration, it should validated here too + if not is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} can be built only by Visual Studio and msvc.") + + # if another tool than the compiler or CMake is required to build the project (pkgconf, bison, flex etc) + def build_requirements(self): + self.tool_requires("tool/x.y.z") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = MSBuildToolchain(self) + tc.generate() + tc = MSBuildDeps(self) + tc.generate() + tc = VCVars(self) + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # remove bundled xxhash + rm(self, "whateer.*", os.path.join(self.source_folder, "lib")) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "...", "") + + def build(self): + self._patch_sources() # It can be apply_conandata_patches(self) only in case no more patches are needed + msbuild = MSBuild(self) + # customize to Release when RelWithDebInfo + msbuild.build_type = "Debug" if self.settings.build_type == "Debug" else "Release" + # use Win32 instead of the default value when building x86 + msbuild.platform = "Win32" if self.settings.arch == "x86" else msbuild.platform + # customize according the solution file and compiler version + msbuild.build(sln="project_2017.sln") + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy( + self, pattern="*.lib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False + ) + copy( + self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=self.build_folder, keep_path=False + ) + copy( + self, + pattern="*.h", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include"), + ) + + def package_info(self): + self.cpp_info.libs = ["package_lib"] diff --git a/docs/package_templates/msbuild_package/all/test_package/CMakeLists.txt b/docs/package_templates/msbuild_package/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b8db27ff53d5e --- /dev/null +++ b/docs/package_templates/msbuild_package/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) # if the project is pure C +project(test_package CXX) # if the project uses c++ + +find_package(package REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE package::package) diff --git a/docs/package_templates/msbuild_package/all/test_package/conanfile.py b/docs/package_templates/msbuild_package/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1111583fea732 --- /dev/null +++ b/docs/package_templates/msbuild_package/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/docs/package_templates/msbuild_package/all/test_package/test_package.cpp b/docs/package_templates/msbuild_package/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..8e653f30a5476 --- /dev/null +++ b/docs/package_templates/msbuild_package/all/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include +#include +#include "package/foobar.hpp" + + +int main(void) { + std::cout << "Create a minimal usage for the target project here." << std::endl; + std::cout << "Avoid big examples, bigger than 100 lines" << std::endl; + std::cout << "Avoid networking connections." << std::endl; + std::cout << "Avoid background apps or servers." << std::endl; + std::cout << "The propose is testing the generated artifacts only." << std::endl; + + foobar.print_version(); + + return EXIT_SUCCESS; +} diff --git a/docs/package_templates/msbuild_package/all/test_v1_package/CMakeLists.txt b/docs/package_templates/msbuild_package/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..983c9e84f7828 --- /dev/null +++ b/docs/package_templates/msbuild_package/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) # if the project is pure C +project(test_package CXX) # if the project uses c++ + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(package REQUIRED CONFIG) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/docs/package_templates/msbuild_package/all/test_v1_package/conanfile.py b/docs/package_templates/msbuild_package/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/docs/package_templates/msbuild_package/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/msbuild_package/config.yml b/docs/package_templates/msbuild_package/config.yml new file mode 100644 index 0000000000000..a885cbf942a74 --- /dev/null +++ b/docs/package_templates/msbuild_package/config.yml @@ -0,0 +1,6 @@ +versions: + # Newer versions at the top + "1.2.0": + folder: all + "1.1.0": + folder: all diff --git a/docs/package_templates/prebuilt_tool_package/all/conandata.yml b/docs/package_templates/prebuilt_tool_package/all/conandata.yml new file mode 100644 index 0000000000000..efcc89654623a --- /dev/null +++ b/docs/package_templates/prebuilt_tool_package/all/conandata.yml @@ -0,0 +1,28 @@ +sources: + # Newer versions at the top + "1.2.0": + "Windows": + "x86_64": + url: "https://example.com/download/windows/amd64/package-1.2.0.tar.gz" + sha256: "________________________________________________________________" + "Linux": + "x86_64": + url: "https://example.com/download/linux/amd64/package-1.2.0.tar.gz" + sha256: "________________________________________________________________" + "Macos": + "x86_64": + url: "https://example.com/download/osx/amd64/package-1.2.0.tar.gz" + sha256: "________________________________________________________________" + "1.1.0": + "Windows": + "x86_64": + url: "https://example.com/download/windows/amd64/package-1.1.0.tar.gz" + sha256: "________________________________________________________________" + "Linux": + "x86_64": + url: "https://example.com/download/linux/amd64/package-1.1.0.tar.gz" + sha256: "________________________________________________________________" + "Macos": + "x86_64": + url: "https://example.com/download/osx/amd64/package-1.1.0.tar.gz" + sha256: "________________________________________________________________" diff --git a/docs/package_templates/prebuilt_tool_package/all/conanfile.py b/docs/package_templates/prebuilt_tool_package/all/conanfile.py new file mode 100644 index 0000000000000..c8a5ae117ab52 --- /dev/null +++ b/docs/package_templates/prebuilt_tool_package/all/conanfile.py @@ -0,0 +1,64 @@ +from conan import ConanFile +from conan.tools.files import get, copy +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +import os + + +required_conan_version = ">=1.47.0" + + +class PackageConan(ConanFile): + name = "package" + description = "short description" + license = "" # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/project/package" + # no "conan" and project name in topics. Use "pre-built" for tooling packages + topics = ("topic1", "topic2", "topic3", "pre-built") + settings = "os", "arch", "compiler", "build_type" # even for pre-built executables + + # not needed but supress warning message from conan commands + def layout(self): + pass + + # specific compiler and build type, usually are not distributed by vendors + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type + + # in case some configuration is not supported + def validate(self): + if self.info.settings.os == "Macos" and Version(self.info.settings.os.version) < 11: + raise ConanInvalidConfiguration(f"{self.ref} requires OSX >=11.") + + # do not cache as source, instead, use build folder + def source(self): + pass + + # download the source here, than copy to package folder + def build(self): + get( + self, + **self.conan_data["sources"][self.version][str(self.settings.os)][str(self.settings.arch)], + destination=self.source_folder, + strip_root=True, + ) + + # copy all needed files to the package folder + def package(self): + # a license file is always mandatory + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="*.exe", dst=os.path.join(self.package_folder, "bin"), src=self.source_folder) + copy(self, pattern="foo", dst=os.path.join(self.package_folder, "bin"), src=self.source_folder) + + def package_info(self): + # folders not used for pre-built binaries + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + self.cpp_info.includedirs = [] + + # TODO: Legacy, to be removed on Conan 2.0 + bin_folder = os.path.join(self.package_folder, "bin") + self.env_info.PATH.append(bin_folder) diff --git a/docs/package_templates/prebuilt_tool_package/all/test_package/conanfile.py b/docs/package_templates/prebuilt_tool_package/all/test_package/conanfile.py new file mode 100644 index 0000000000000..8fc041e355c5b --- /dev/null +++ b/docs/package_templates/prebuilt_tool_package/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def test(self): + if can_run(self): + # self.run checks the command exit code + # the tool must be available on PATH + self.run("tool --version") diff --git a/docs/package_templates/prebuilt_tool_package/all/test_v1_package/conanfile.py b/docs/package_templates/prebuilt_tool_package/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..36fd085b2d6b7 --- /dev/null +++ b/docs/package_templates/prebuilt_tool_package/all/test_v1_package/conanfile.py @@ -0,0 +1,13 @@ +from conans import ConanFile +from conan.tools.build import can_run + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def test(self): + if can_run(self): + # self.run checks the command exit code + # the tool must be available on PATH, which is configured by self.env_info.PATH + self.run("tool --version", run_environment=True) diff --git a/docs/package_templates/prebuilt_tool_package/config.yml b/docs/package_templates/prebuilt_tool_package/config.yml new file mode 100644 index 0000000000000..a885cbf942a74 --- /dev/null +++ b/docs/package_templates/prebuilt_tool_package/config.yml @@ -0,0 +1,6 @@ +versions: + # Newer versions at the top + "1.2.0": + folder: all + "1.1.0": + folder: all diff --git a/docs/packaging_policy.md b/docs/packaging_policy.md deleted file mode 100644 index a7d07eb4f157a..0000000000000 --- a/docs/packaging_policy.md +++ /dev/null @@ -1,22 +0,0 @@ -# Packaging Policy - -This document gathers all the relevant information regarding the general lines to follow while creating new recipes that will eventually be -part of this repository. - -## Sources - -**Origin of sources:** Library sources should come from an official origin like the library source code repository or the official -release/download webpage. - -**Building from sources:** Recipes should always build packages from library sources. - -**Sources not accessible:** - -- Library sources that are not publicly available will not be allowed in this repository even if the license allows their redistribution. - -- If library sources cannot be downloaded from their official origin or cannot be consumed directly due to their - format, the recommendation is to contact the publisher and ask them to provide the sources in a way/format that can be consumed - programmatically. - -- In case of needing those binaries to use them as a "build require" for some library, we will consider following the approach of adding it - as a system recipe (`/system`) and making those binaries available in the CI machines (if the license allows it). diff --git a/docs/review_process.md b/docs/review_process.md index 7a0f18b710299..55eadf1bd0738 100644 --- a/docs/review_process.md +++ b/docs/review_process.md @@ -13,14 +13,12 @@ conan-center-index tries to make the process as smooth and simple as possible fo * [Avoiding conflicts](#avoiding-conflicts) * [Draft](#draft) * [Getting your pull request reviewed](#getting-your-pull-request-reviewed) - * [Official reviewers](#official-reviewers) - * [Community reviewers](#community-reviewers) - * [Rule of 3 reviews](#rule-of-3-reviews) + * [Rule of 2 reviews](#rule-of-2-reviews) * [Reviews from others](#reviews-from-others) * [Addressing review comments](#addressing-review-comments) * [Automatic Merges](#automatic-merges) * [Merge](#merge) - * [Upload](#upload) + * [Package available to consume](#package-available-to-consume) * [Updating web front end](#updating-web-front-end) * [Stale PRs](#stale-prs) @@ -28,7 +26,7 @@ conan-center-index tries to make the process as smooth and simple as possible fo In general, reviews are driven by the automated [bot](https://github.com/conan-center-bot). The bot is responsible for: -- Adding or removing labels (such as [No Beta User](https://github.com/conan-io/conan-center-index/pulls?q=is%3Apr+is%3Aopen+label%3A%22No+Beta+user%22) or [Docs](https://github.com/conan-io/conan-center-index/pulls?q=is%3Apr+is%3Aopen+label%3ADocs)). +- Adding or removing labels (such as [Bump version](https://github.com/conan-io/conan-center-index/pulls?q=is%3Apr+is%3Aopen+label%3A%22Bump+version%22) or [Docs](https://github.com/conan-io/conan-center-index/pulls?q=is%3Apr+is%3Aopen+label%3ADocs)). - Writing comments (most of the time, it's a build status, either failure with logs or success). - Merging pull requests. - Closing issues (after merging pull requests with GitHub keywords). @@ -38,7 +36,7 @@ In general, reviews are driven by the automated [bot](https://github.com/conan-c ## Green build The first important prerequisite is ensuring your PR is green (build is successful). -It requires a bit of patience, because there are many PRs are running, and we're building a lot of configurations for a numerous versions of libraries. +It requires a bit of patience, because there are many PRs running and we're building a lot of configurations for a numerous versions of libraries. Keep attention to the error messages from the bot, and address all the build failures. The bot tries to provide all the helpful information needed to understand and reproduce an issue, such as: @@ -51,68 +49,46 @@ If you struggle to fix build errors yourself, you may want to ask for help from ### Unexpected error Sometimes, build fails with `Unexpected error` message. This indicates an infrastructure problem, and usually it's unrelated to the changes within PR itself. -Keep in mind conan-center-index is still in "early access program", and there are still some instabilities. Especially, as we're using lots of external services, -which might be inaccessible (GitHub API, docker hub, etc.) and may result in intermittent failures. -So, what to do once `Unexpected error` was encountered? You may consider re-running the build by closing your pull request, waiting 15 seconds, and then re-opening it again. -Sometimes it's necessary to restart the build several times. -If an `Unexpected error` persists, tag [@jgsogo](https://github.com/jgsogo) and [@danimtb](https://github.com/danimtb) asking for the help with CI. -Alternatively, just [open a new issue](https://github.com/conan-io/conan-center-index/issues/new/choose). +To learn more, checkout the [label definition](labels.md#unexpected-error). ## Avoiding conflicts -It's recommended to rebase your changes on top of the master branch to avoid conflicts. -Right now, neither GitHub itself nor conan-center-bot notify about merge conflicts, so it's the contributor's responsibility to periodically check for the conflicts. -Obviously, PRs that have merge conflicts are never merged, and all the conflicts have to be resolved first. +Right now, neither GitHub itself nor conan-center-bot notify about merge conflicts, so it's the contributor's responsibility to periodically check for the conflicts. Pull Requests that have merge conflicts can't be merged, and all the conflicts have to be resolved first. + +Please [synchronize your branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork) to take into account the latest changes in the main branch. This is important for ConanCenter to ensure it is building the correct recipe revision, see [this comment](https://github.com/conan-io/conan-center-index/pull/8797#discussion_r781993233) for details. One trick is to look out for comments from the [Community's Conflict PR Bot](https://github.com/prince-chrismc/conan-center-index/blob/patch-41/docs/community_resources.md#bots) which can anticipate possible problems. ## Draft -Draft pull requests are also never merged. The same applies for PRs with the `WIP` keyword (stands for `Work in Progress`) in the title - GitHub considers them drafts as well. +Draft pull requests are also never merged, and they won't likely be reviewed. Once you're done with your changes, remember to convert from "Draft" to "Normal" pull request. ## Getting your pull request reviewed -Each PR must be reviewed by several reviewers before it will be merged. It cannot be just reviews from random people, we have two categories of reviewers: - -### Official reviewers - -The list includes only official Conan developers: - -- [@memsharded](https://github.com/memsharded) -- [@lasote](https://github.com/lasote) -- [@danimtb](https://github.com/danimtb) -- [@jgsogo](https://github.com/jgsogo) -- [@czoido](https://github.com/czoido) -- [@solvingj](https://github.com/solvingj) -- [@sse4](https://github.com/sse4) -- [@uilianries](https://github.com/uilianries) +Each PR must be reviewed by several reviewers before it will be merged. It cannot be just reviews from anyone, we have two categories of reviewers: -### Community reviewers +- Official reviewers: these are active team members who are responsible for developing Conan, ConanCenter, and ConanCenterIndex. +- Community reviewers: this list includes former Conan team members and ConanCenterIndex contributors who are very active and proven to be trusted - they frequently submit pull requests and provide their own useful reviews -The list includes conan-center-index contributors who are very active and proven to be trusted - they frequently submitted pull requests and provide their own useful reviews: +The list or reviewers, located [here](../.c3i/reviewers.yml), +is not constant and will change periodically based on contribution. +That also means **you can be included in this list** as well - submit PRs and provide reviews, and in time you may be added as a trusted contributor. -- [@madebr](https://github.com/madebr) -- [@SpaceIm](https://github.com/SpaceIm) -- [@ericLemanissier](https://github.com/ericLemanissier) -- [@prince-chrismc](https://github.com/prince-chrismc) -- [@Croydon](https://github.com/Croydon) -- [@intelligide](https://github.com/intelligide) -- [@theirix](https://github.com/theirix) -- [@gocarlos](https://github.com/gocarlos) -- [@mathbunnyru](https://github.com/mathbunnyru) +> **Note**: GitHubs user interface does not support such custom rules so you should not rely solely on the message it provides. -The list is not constant and will change periodically based on contribution. -That also means you can be included in this list as well - submit PRs and provide reviews, and in time you may be added as a trusted contributor. +### Rule of 2 reviews -### Rule of 3 reviews - -At least 3 reviews are required for an approval, and at least one of them has to be from the official reviewers. -So, it might be 1 official + 2 community, or 3 official, but it couldn't be just 3 community reviews. +At least 2 approving reviews are required, and at least one of them has to be from the official reviewers. +So, it might be 1 official + 1 community, or 2 official, but it couldn't be just 2 community reviews. Approvals are only counted if they are associated with the latest commit in the PR, while "Change requested" ones (from the Conan team) will persist even if there are new commits. Don't hesitate to dismiss old reviews if the issues have already been addressed. +> **Note** Pull requests labelled as [`Bump version`](https://github.com/conan-io/conan-center-index/pulls?q=is%3Aopen+is%3Apr+label%3A%22Bump+version%22) +> or [`Bump dependencies`](https://github.com/conan-io/conan-center-index/pulls?q=is%3Aopen+is%3Apr+label%3A%22Bump+dependencies%22+) are merged by +> the bot without requiring any approval. + ### Reviews from others -All reviews are still valuable and very helpful. Even if you're not listed as an official or community reviewer counted by the bot, your reviews are still welcome, so please do not hesitate to provide them. +All reviews are still valuable and very helpful. Even if you're not listed as an official or community reviewer, **your reviews are very welcome**, so please do not hesitate to provide them. ### Addressing review comments @@ -121,32 +97,36 @@ It doesn't always mean accepting all the suggestions, but at least providing a r ## Automatic Merges -The bot runs Automatic Merges every 30 minutes. Currently, it can only merge a single PR in this timeframe, so there is a theoretical limit of 48 PRs merged per day (in practice, it's even less for reasons listed below). +The bot runs Automatic Merges every 20 minutes. Currently, it can only merge a single PR in this timeframe, so there is a theoretical limit of ~70 PRs merged per day (in practice, it's even less for reasons listed below). PR is selected for the merge only if: -- Author is an added [beta user](https://github.com/conan-io/conan-center-index/issues/4). -- Author has signed CLA. -- PR is not a Draft or WIP. +- Author is already [approved](https://github.com/conan-io/conan-center-index/issues/4). +- Author has signed the [CLA](CONTRIBUTOR_LICENSE_AGREEMENT.md). +- PR is not a Draft. - PR has a green status (successful build). - PR doesn't have merge conflicts with `master` branch. -- PR has 3 approved reviews (as described above). +- PR has approved reviews (as described above). - PR does not have any [official reviewers](#official-reviewers) requesting changes - Master build is not running already (see below) -If these conditions are fulfilled, the PR is merged (associated issues are automatically closed), and then the build of master is launched. +If these conditions are fulfilled, the PR is merged (associated issues are automatically closed), and then the build of `master` is launched. + +The conan-center-bot will perform a [squash and merge](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-pull-request-commits). You don't need to rebase +your pull request, we ask you not to do it because it will dismiss any reviews and the reviewer will need to restart. ### Merge -After merging a pull request, if an actual merge happened (for instance, the recipe changed in PR was already updated in master by the time PR merged), -it will introduce a new recipe revision. Therefore, the build should be run one more time, so the master build is launched. +After merging a pull request, if an actual merge happened (for instance, the recipe changed in PR was already updated in `master` by the time PR merged), +it will introduce a new recipe revision. Therefore, the build should be run one more time, so the `master` build is launched. In reality this could happen frequently enough if there are multiple PRs aiming to update the same recipe (even if they touch different files in the same recipe). Such builds can take hours for big packages (like boost), blocking other merges for a while. -So we really appreciate it if changes in master to the same recipe are already merged into the proposed PR. +So we really appreciate it if changes in `master` to the same recipe are already merged into the proposed PR. -### Upload +### Package available to consume -Even if there is no new revision introduced, CI still needs to publish artifacts from the internal repository to ConanCenter, and it may also take hours for big enough packages. -This also blocks further merges until upload is finished. It also explains why new packages are not immediately available for consumption after the merge, and there is a grace period to wait for their availability. +New packages are promoted from the internal repository to ConanCenter. This process is an internal Artifactory promotion that is quite +fast, nevertheless there are some caches and CDNs that need to be invalidated and propagated before the package is finally available for consumption. +The process can take several minutes, so please, consider a *grace period* and understand that the package won't be available immediately. ### Updating web front end @@ -157,4 +137,4 @@ That may explain the fact there are moments when the information showed in the f ## Stale PRs -Conan Center Index uses [stale bot](https://github.com/probot/stale) to close abandoned pull requests. It's configured by [stale.yml](.github/stale.yml). When a pull request gets stale, we encourage anyone to take ownership of the PR (even submit changes to the author's branch if possible) so existing work doesn't get lost when the pull request is closed without merging. +Conan Center Index uses [stale bot](https://github.com/probot/stale) to close abandoned pull requests. It's configured by [stale.yml](../.github/stale.yml). When a pull request gets stale, we encourage anyone to take ownership of the PR (even submit changes to the author's branch if possible) so existing work doesn't get lost when the pull request is closed without merging. diff --git a/docs/reviewing.md b/docs/reviewing.md deleted file mode 100644 index c634370a7c1f5..0000000000000 --- a/docs/reviewing.md +++ /dev/null @@ -1,143 +0,0 @@ -# Reviewing policies - -The following policies are preferred during the review, but not mandatory: - - -## Contents - - * [Trailing white-spaces](#trailing-white-spaces) - * [Quotes](#quotes) - * [Subfolder Properties](#subfolder-properties) - * [Order of methods and attributes](#order-of-methods-and-attributes) - * [License Attribute](#license-attribute) - * [CMake](#cmake) - * [Caching Helper](#caching-helper) - * [Build Folder](#build-folder) - * [CMake Configure Method](#cmake-configure-method) - * [Test Package](#test-package) - * [Minimalistic Source Code](#minimalistic-source-code) - * [Verifying Components](#verifying-components) - * [Recommended feature options names](#recommended-feature-options-names) - -## Trailing white-spaces - -Avoid trailing white-space characters, if possible - -## Quotes - -If possible, try to avoid mixing single quotes (`'`) and double quotes (`"`) in python code (`conanfile.py`, `test_package/conanfile.py`). Consistency is preferred. - -## Subfolder Properties - -When extracting sources or performing out-of-source builds, it is preferable to use a _subfolder_ attribute, `_source_subfolder` and `_build_subfolder` respectively. - -For example doing this with property attributes for these variables: - -```py -@property -def _source_subfolder(self): - return "source_subfolder" - -@property -def _build_subfolder(self): - return "build_subfolder" -``` - -## Order of methods and attributes - -Prefer the following order of documented methods in python code (`conanfile.py`, `test_package/conanfile.py`): - -- init -- set_name -- set_version -- export -- export_sources -- config_options -- configure -- requirements -- package_id -- build_id -- build_requirements -- system_requirements -- source -- imports -- build -- package -- package_info -- deploy -- test - -the order above resembles the execution order of methods on CI. therefore, for instance, `build` is always executed before `package` method, so `build` should appear before the -`package` in `conanfile.py`. - -## License Attribute - -The mandatory license attribute of each recipe **should** be a [SPDX license](https://spdx.org/licenses/) [short Identifiers](https://spdx.dev/ids/) when applicable. - -## CMake - -When working with CMake based upstream projects it is prefered to follow these principals. They are not applicable to all projects so they can not be enforced. - -### Caching Helper - -Due to build times and the lenght to configure CMake multiple times, there is a strong motivation to cache the `CMake` build helper from Conan between the `build()` and `package()` methods. - -This can be done by adding a `_cmake` attribute to the `ConanFile` class. - -### Build Folder - -Ideally use out-of-source builds by calling `cmake.configure(build_folder=self._build_subfolder)` when ever possible. - -### CMake Configure Method - -Use a seperate method to handle the common patterns with using CMake based projects. This method is `_configure_cmake` and looks like the follow in the most basic cases: - -```py -def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["BUILD_STATIC"] = not self.options.shared - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake -``` - -## Test Package - -### Minimalistic Source Code - -The contents of `test_package.c` or `test_package.cpp` should be as minimal as possible, including a few headers at most with simple instatiation of objects to ensure linkage -and dependencies are correct. - -### Verifying Components - -When components are defined in the `package_info` in `conanfile.py` the following conditions are desired - -- use the `cmake_find_package` or `cmake_find_package_multi` generators in `test_package/conanfile.py` -- corresponding call to `find_package()` with the components _explicitly_ used in `target_link_libraries` - -### Recommended feature options names - -It's often needed to add options to toggle specific library features on/off. Regardless of the default, there is a strong preference for using positive naming for options. In order to avoid the fragmentation, we recommend to use the following naming conventions for such options: - -- enable_ / disable_ -- with_ / without_ -- use_ - -the actual recipe code then may look like: - -```py - options = {"use_tzdb": [True, False]} - default_options = {"use_tzdb": True} -``` - -```py - options = {"enable_locales": [True, False]} - default_options = {"enable_locales": True} -``` - -```py - options = {"with_zlib": [True, False]} - default_options = {"with_zlib": True} -``` - -having the same naming conventions for the options may help consumers, e.g. they will be able to specify options with wildcards: `-o *:with_threads=True`, therefore, `with_threads` options will be enabled for all packages in the graph that support it. diff --git a/docs/supported_platforms_and_configurations.md b/docs/supported_platforms_and_configurations.md index c73aa79ae85a7..d246cd963f72c 100644 --- a/docs/supported_platforms_and_configurations.md +++ b/docs/supported_platforms_and_configurations.md @@ -36,23 +36,33 @@ For more information see [conan-io/conan-docker-tools](https://github.com/conan- ## Windows +- Python: 3.7.9 +- CMake: 3.21.6 +- WinSDK: 10.0.20348 + > WinSDK version is rolled periodically as [discussed previously](https://github.com/conan-io/conan-center-index/issues/4450). + > Please open an issue in case it needs to be updated. - Compilers: Visual Studio: - - 2015 (14.0.25431.01 Update 3) - - 2017 (15.9.19+28307.1000) - - 2019 (16.4.4+29728.190) + + - 2017 (19.16.27048) + - 2019 (19.29.30146) + - Release (MT/MD) and Debug (MTd, MDd) - Architectures: x86_64 - Build types: Release, Debug - Runtimes: MT/MD (Release), MTd/MDd (Debug) - Options: - Shared, Static (option `"shared": [True, False]` in the recipe when available) - - Header Only (option `"header_only": [True, False]` is only added with the value True) + - Header Only (option `"header_only": [True, False]` if available) + +> :warning: The profile with the option `shared=True` and runtime `MT/MTd` is not built. ## Linux +- Python: 3.7.13 +- CMake: 3.15.7, 3.18.2 (same version expected after all use [new docker images](https://github.com/conan-io/conan-docker-tools/tree/master/modern)) - Compilers: - - GCC versions 4.9, 5, 6, 7, 8, 9, 10 - - Clang versions 3.9, 4.0, 5.0, 6.0, 7.0, 8, 9, 10, 11 + - GCC versions: 5, 7, 8, 9, 10, 11 + - Clang versions: 11, 12, 13 - C++ Standard Library (`libcxx`): - GCC compiler: `libstdc++`, `libstdc++11` - Clang compiler: `libstdc++`, `libc++` @@ -64,9 +74,11 @@ For more information see [conan-io/conan-docker-tools](https://github.com/conan- ## MacOS -- Compilers: Apple-clang versions 10.0, 11.0, 12.0 (three latest versions, we will rotate the older when a new compiler version is released) +- Python: 3.7.12 +- CMake: 3.20.1 +- Compilers: Apple-clang versions 11.0.3, 12.0.5, 13.0.0 - C++ Standard Library (`libcxx`): `libc++` -- Architectures: x86_64 +- Architectures: x86_64, armv8 - Build types: Release, Debug - Options: - Shared, Static (option ``"shared": [True, False]`` in the recipe when available) diff --git a/docs/v2_linter.md b/docs/v2_linter.md new file mode 100644 index 0000000000000..a2358f657f524 --- /dev/null +++ b/docs/v2_linter.md @@ -0,0 +1,71 @@ +# Linter to help migration to Conan v2 + + +## Contents + + * [Running the linter locally](#running-the-linter-locally) + * [Import ConanFile from `conan`](#import-conanfile-from-conan) + * [Import tools from `conan`](#import-tools-from-conan) + +On our [path to Conan v2](v2_roadmap.md) we are leveraging on custom Pylint rules. This +linter will run for every pull-request that is submitted to the repository and will +raise some warnings and errors that should be addressed in order to migrate the +recipes to Conan v2. + +It is important to note that these rules are targeting Conan v2 compatibility layer, their +purpose is to fail for v1 syntax that will be no longer available in v2. Even if the syntax +if perfectly valid in Conan v1, the recipe might fail here because it is not v2-compliant. + +> **Note** Some of the errored checks might be just plain Python syntax errors, while +> others might be related to the custom rules added by us. + +Here you can find some examples of the extra rules we are adding: + +## Running the linter locally + +Check the [Developing Recipes](developing_recipes_locally.md#running-the-python-linters) for details. + +## Import ConanFile from `conan` + +The module `conans` is deprecated in Conan v2. Now all the imports should be done from +module `conan`: + +```python +from conan import ConanFile +``` + +## Import tools from `conan` + +All v2-compatible tools are available in module `conan.tools` under different submodules. Recipes +should start to import their tools from this new module. Some of the new tools accept new +argument, please, check the [Conan documentation](https://docs.conan.io/en/latest/reference/conanfile/tools.html). + +Here is a list of different imports and their new equivalent (note that the interface for most of this functions changed, see their respective link to the documentation): + +| **Conan v1** | **Conan v2** | **Required Conan Version** | +|---|---|---| +| conans.tools.get | [conan.tools.files.get](https://docs.conan.io/en/latest/reference/conanfile/tools/files/downloads.html#conan-tools-files-get) | 1.41.0 | +| conans.tools.download | [conan.tools.files.download](https://docs.conan.io/en/latest/reference/conanfile/tools/files/downloads.html#conan-tools-files-download) | 1.41.0 | +| conans.tools.rmdir | [conan.tools.files.rmdir](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-rmdir) | 1.47.0 | +| conans.tools.patch | [conan.tools.files.patch](https://docs.conan.io/en/latest/reference/tools.html#tools-patch) | 1.35.0 | +| conans.tools.remove_files_by_mask | [conan.tools.files.rm](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-rm) | 1.50.0 | +| conans.copy | [conan.tools.files.copy](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-copy) | 1.46.0 | +| conans.tools.load | [conan.tools.files.load](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-load) | 1.35.0 | +| conans.tools.save | [conan.tools.files.save](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-save) | 1.35.0 | +| conans.tools.rename | [conan.tools.files.rename](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-rename) | 1.37.0 | +| conans.tools.replace_in_file | [conan.tools.files.replace_in_file](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-replace-in-file) | 1.46.0 | +| conans.tools.mkdir | [conan.tools.files.mkdir](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-mkdir) | 1.35.0 | +| conans.tools.chdir | [conan.tools.files.chdir](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-chdir) | 1.40.0 | +| conans.tools.unzip | [conan.tools.files.unzip](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-unzip) | 1.46.0 | +| conans.tools.collect_libs | [conan.tools.files.collect_libs](https://docs.conan.io/en/latest/reference/conanfile/tools/files/basic.html#conan-tools-files-collect-libs) | 1.46.0 | +| conans.tools.Version | [conan.tools.scm.Version](https://docs.conan.io/en/latest/reference/conanfile/tools/scm/other.html#version) | 1.46.0 | +| conans.tools.sha256sum | [conan.tools.files.check_sha256](https://docs.conan.io/en/latest/reference/conanfile/tools/files/checksum.html#conan-tools-files-check-sha256) | 1.46.0 | +| conans.tools.unix_path | [conan.tools.microsoft.unix_path](https://docs.conan.io/en/latest/reference/conanfile/tools/microsoft.html#conan-tools-microsoft-unix-path) | 1.47.0 | +| conans.tools.is_apple_os | [conan.tools.apple.is_apple_os](https://docs.conan.io/en/latest/reference/conanfile/tools/apple.html#is-apple-os) | 1.51.3 | +| conans.tools.cpu_count | [conan.tools.build.build_jobs](https://docs.conan.io/en/latest/reference/conanfile/tools/build.html#conan-tools-build-build-jobs) | 1.43.0 | +| conans.tools.check_min_cppstd | [conan.tools.build.check_min_cppstd](https://docs.conan.io/en/latest/reference/conanfile/tools/build.html#conan-tools-build-check-min-cppstd) | 1.50.0 | +| conans.tools.cross_building | [conan.tools.build.cross_building](https://docs.conan.io/en/latest/reference/conanfile/tools/build.html#conan-tools-build-cross-building) | 1.46.0 | +| conans.errors.ConanInvalidConfiguration | [conan.errors.ConanInvalidConfiguration](https://docs.conan.io/en/latest/migrating_to_2.0/recipes.html#migrating-the-recipes) | 1.47.0 | +| conans.errors.ConanException | [conan.errors.ConanException](https://docs.conan.io/en/latest/migrating_to_2.0/recipes.html#migrating-the-recipes) | 1.47.0 | + +--- diff --git a/docs/v2_migration.md b/docs/v2_migration.md new file mode 100644 index 0000000000000..3a8ebff66e879 --- /dev/null +++ b/docs/v2_migration.md @@ -0,0 +1,509 @@ +# Preparing recipes for Conan 2.0 + +Refer to [road to Conan v2](v2_roadmap.md) to know the steps that +will be taken in ConanCenter and this repository to start running +Conan v2 in pull requests. + + +## Contents + + * [Using Layout](#using-layout) + * [With New Generators](#with-new-generators) + * [With Multiple Build Helpers](#with-multiple-build-helpers) + * [CMakeToolchain](#cmaketoolchain) + * [New conf_info properties](#new-conf_info-properties) + * [New cpp_info set_property model](#new-cpp_info-set_property-model) + * [CMakeDeps](#cmakedeps) + * [Update required_conan_version to ">=1.43.0"](#update-required_conan_version-to-1430) + * [Translating .names information to cmake_target_name, cmake_module_target_name and cmake_file_name](#translating-names-information-to-cmake_target_name-cmake_module_target_name-and-cmake_file_name) + * [Translating .filenames information to cmake_file_name, cmake_module_file_name and cmake_find_mode](#translating-filenames-information-to-cmake_file_name-cmake_module_file_name-and-cmake_find_mode) + * [Understanding some workarounds with the .names attribute model in recipes](#understanding-some-workarounds-with-the-names-attribute-model-in-recipes) + * [Translating .build_modules to cmake_build_modules](#translating-build_modules-to-cmake_build_modules) + * [PkgConfigDeps](#pkgconfigdeps) + +> **Note**: Read about the [linter in pull requests](v2_linter.md) to learn how this is being enforced. + +It's time to start thinking seriously about Conan v2 and prepare recipes +for the incoming changes. Conan v2 comes with many +changes and improvements, you can read about them in the +[Conan documentation](https://docs.conan.io/en/latest/conan_v2.html). + +This document is a practical guide, offering extended information particular to Conan +Center Index recipes to get them ready to upgrade to Conan 2.0. + +## Using Layout + +All recipes should use a layout. Without one, more manual configuration of folders (e.g. source, build, etc) +and package structure will be required. + +### With New Generators + +When doing this there is no need to manually define `self._subfolder_[...]` in a recipe. +Simply use `self.source_folder` and `self.build_folder` instead of "subfolder properties" that used to be the norm. + +### With Multiple Build Helpers + +When different build tools are use, at least one layout needs to be set. + +```python + def layout(self): + if self._use_cmake(): + cmake_layout(self) + else: # using autotools + basic_layout(self) +``` + +The `src_folder` must be the same when using different layouts and should +not depend on settings or options. + +## CMakeToolchain + +The old `CMake.definition` should be replaced by `CMakeToolchain.variables` and moved to the `generate` method. +However, certain options need to be passed as `cache_variables`. You'll need to check project's `CMakeLists.txt` +as there are a few cases to look out for: + +- When an `option` is configured before `project()` is called. + + ```cmake + cmake_minimum_required(3.1) + option(BUILD_EXAMPLES "Build examples using foorbar") + project(foobar) + ``` + +- When an variable is declared with `CACHE`. + + ```cmake + cmake_minimum_required(3.1) + project(foobar) + set(USE_JPEG ON CACHE BOOL "include jpeg support?") + ``` + +For more information refere to the [CMakeToolchain docs](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmaketoolchain.html) +or check out the converstaion in conan-io/conan#11937 for the brave. + +## New conf_info properties + +As described in the documentation `self.user_info` has been depreated and you are now required to use +`self.conf_info` to define individual properties to expose to downstream recipes. +The [2.0 migrations docs](https://docs.conan.io/en/latest/migrating_to_2.0/recipes.html#removed-self-user-info) +should cover the technical details, however for ConanCenterIndex we need to make sure there are no collisions +`conf_info` must be named `user.:`. + +For usage options of `conf_info`, the [documenation](https://docs.conan.io/en/latest/reference/config_files/global_conf.html?highlight=conf_info#configuration-in-your-recipes) + +In ConanCenterIndex this will typically looks like: + +- defining a value + ```py + def package_info(self): + tool_path = os.path.join(self.package_folder, "bin", "tool") + self.conf_info.define("user.pkg:tool", tool_path) + ``` +- using a value + ```py + #generators = "VirtualBuildEnv", "VirtualRunEnv" + + def build_requirements(self): + self.tool_requires("tool/0.1") + + def build(self): + tool_path = self.conf_info.get("user.pkg:tool") + self.run(f"{tool_path} --build") + ``` +> **Note**: This should only be used when absolutely required. In the vast majority of cases, the new +> ["Environments"](https://docs.conan.io/en/latest/reference/conanfile/tools/env/environment.html?highlight=Virtual) +> will include the `self.cpp_info.bindirs` which will provide access to the tools in the correct scopes. + +## New cpp_info set_property model + +New Conan generators like +[CMakeDeps](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmakedeps.html) +and +[PkgConfigDeps](https://docs.conan.io/en/latest/reference/conanfile/tools/gnu/pkgconfigdeps.html), +don't listen to *cpp_info* ``.names``, ``.filenames`` or ``.build_modules`` attributes. +There is a new way of setting the *cpp_info* information with these +generators using the ``set_property(property_name, value)`` method. + +All the information in the recipes, already set with the current model, should be +translated to the new model. These two models **will live together in recipes** to make +recipes compatible **with both new and current generators** for some time. After a stable +Conan 2.0 version is released, and when the moment arrives that we don't support the +current generators anymore in Conan Center Index, those attributes (``.names``, +``.filenames`` etc.) will disappear from recipes, and only ``set_property`` methods will +stay. + +We will cover some cases of porting all the information set with the current model to the +new one. To read more about the properties available for each generator and how the +properties model work, please check the [Conan documentation](https://docs.conan.io/en/latest/conan_v2.html#editables-don-t-use-external-templates-any-more-new-layout-model). + +> **Note**: Please, remember that the **new** ``set_property`` and the **current** attributes +> model are *completely independent since Conan 1.43*. Setting ``set_property`` in recipes will +> not affect current CMake 1.X generators (``cmake``, ``cmake_multi``, ``cmake_find_package`` and +> ``cmake_find_package_multi``) at all. + +### CMakeDeps + +### Update required_conan_version to ">=1.43.0" + +If you set the property ``cmake_target_name`` in the recipe, the Conan minimum +required version should be updated to 1.43. + +```python + +required_conan_version = ">=1.43.0" + +class GdalConan(ConanFile): + name = "gdal" + ... +``` + +The reason for this change is that in Conan versions previous to 1.43 the +``cmake_target_name`` values were not the final CMake target names. Those values were +completed by Conan, adding namespaces automatically the final target names. After 1.43 +``cmake_target_name`` sets the **complete target name** that is added to the ``.cmake`` +files generated by Conan. Let's see an example: + +```python +class GdalConan(ConanFile): + name = "gdal" + ... + def package_info(self): + # Before 1.43 -> Conan adds GDAL:: namespace -> Creates target with name GDAL::GDAL + # self.cpp_info.set_property("cmake_target_name", "GDAL") + + # After 1.43 -> Conan creates target with name GDAL::GDAL + self.cpp_info.set_property("cmake_target_name", "GDAL::GDAL") +``` + +### Translating .names information to cmake_target_name, cmake_module_target_name and cmake_file_name + +To translate the ``.names`` information to the new model there are some important things to +take into account: + +* The value of the ``.names`` attribute value in recipes is just a part of the final + target name for CMake generators. Conan will complete the rest of the target name by + pre-pending a namespace (with ``::`` separator) to the ``.names`` value. This namespace takes + the same value as the ``.names`` value. Let's see an example: + +```python +class SomePkgConan(ConanFile): + name = "somepkg" + ... + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "some-pkg" + self.cpp_info.names["cmake_find_package_multi"] = "some-pkg" + ... +``` + +This recipe generates the target ``some-pkg::some-pkg`` for both the +``cmake_find_package`` and the ``cmake_find_package_multi`` generators. Also, please +remember that if no ``.names`` attribute were set, Conan would create the target +``somepkg::somepkg`` for both generators by default. + +As we explained before, the ``cmake_target_name`` sets the **complete target name**, so, +to translate this information to the new model we should add the following lines: + +```python +class SomePkgConan(ConanFile): + name = "somepkg" + ... + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "some-pkg" + self.cpp_info.names["cmake_find_package_multi"] = "some-pkg" + # CMakeDeps does NOT add any namespace automatically + self.cpp_info.set_property("cmake_target_name", "some-pkg::some-pkg") + ... +``` + +* If ``.filenames`` attribute is not set, it will fall back on the ``.names`` value to + generate the files. Both the ``Find.cmake`` and ``-config.cmake`` files that + store the dependencies will take the ``.names`` value to create the complete filename. + For the previous example, to translate all the information from the current model to the + new one, we should have added one more line setting the ``cmake_file_name`` value. + +```python +class SomePkgConan(ConanFile): + name = "somepkg" + ... + def package_info(self): + # These generators fallback the filenames for the .cmake files + # in the .names attribute value and generate + self.cpp_info.names["cmake_find_package"] = "some-pkg" # generates module file Findsome-pkg.cmake + self.cpp_info.names["cmake_find_package_multi"] = "some-pkg" # generates config file some-pkg-config.cmake + + self.cpp_info.set_property("cmake_target_name", "some-pkg::some-pkg") + self.cpp_info.set_property("cmake_file_name", "some-pkg") # generates config file some-pkg-config.cmake + ... +``` + +Please note that if we hadn't set the ``cmake_file_name`` property, the ``CMakeDeps`` +generator would have taken the package name to generate the filename for the config file +and the generated filename would have resulted ``somepkg-config.cmake`` instead of +``some-pkg-config.cmake``. + +* Some recipes in Conan Center Index define different ``.names`` values for ``cmake_find_package`` + and ``cmake_find_package_multi``. For these cases, besides ``cmake_target_name`` you should also set + the ``cmake_module_target_name`` and ``cmake_find_mode`` properties. Let's see an example: + +```python +class ExpatConan(ConanFile): + name = "expat" + ... + def package_info(self): + # creates EXPAT::EXPAT target for module files FindEXPAT.cmake + self.cpp_info.names["cmake_find_package"] = "EXPAT" + # creates expat::expat target for config files expat-config.cmake + self.cpp_info.names["cmake_find_package_multi"] = "expat" + ... +``` + +Should translate to the code above. Please note we have added the ``cmake_find_mode`` +property for the +[CMakeDeps](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmakedeps.html#properties) +generator with value ``both``. + +```python +class ExpatConan(ConanFile): + name = "expat" + ... + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "EXPAT" + self.cpp_info.names["cmake_find_package_multi"] = "expat" + + # creates EXPAT::EXPAT target for module files FindEXPAT.cmake + self.cpp_info.set_property("cmake_target_name", "EXPAT::EXPAT") + # creates expat::expat target for config files expat-config.cmake + self.cpp_info.set_property("cmake_module_target_name", "expat::expat") + + # generates module file FindEXPAT.cmake + self.cpp_info.set_property("cmake_file_name", "EXPAT") + # generates config file expat-config.cmake + self.cpp_info.set_property("cmake_module_file_name", "expat") + + # config is the default for CMakeDeps + # we set cmake_find_mode to both to generate both module and config files + self.cpp_info.set_property("cmake_find_mode", "both") + ... +``` + +> *Note**: There are more cases in which you probably want to set the +> ``cmake_find_mode`` property to ``both``. For example, for the libraries which [find +> modules files are included in the CMake +> distribution](https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules). + +### Translating .filenames information to cmake_file_name, cmake_module_file_name and cmake_find_mode + +Like in the ``.names`` case, there are some cases in Conan Center Index of recipes that +set different filenames for ``cmake_find_package`` and ``cmake_find_package_multi`` +generators. To translate that information to the ``set_property`` model we have to set the +``cmake_file_name`` and ``cmake_find_mode`` properties. Let's see an example: + +```python +class GlewConan(ConanFile): + name = "glew" + ... + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "GLEW" + self.cpp_info.names["cmake_find_package_multi"] = "GLEW" + self.cpp_info.filenames["cmake_find_package"] = "GLEW" # generates FindGLEW.cmake + self.cpp_info.filenames["cmake_find_package_multi"] = "glew" # generates glew-config.cmake + ... +``` + +In this case we have to set the ``cmake_find_mode`` property for the +[CMakeDeps](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmakedeps.html#properties) +generator with value ``both``. That will make CMakeDeps generator create both module and +config files for consumers (by default it generates just config files). + +```python +class GlewConan(ConanFile): + name = "glew" + ... + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "GLEW" + self.cpp_info.names["cmake_find_package_multi"] = "GLEW" + self.cpp_info.filenames["cmake_find_package"] = "GLEW" + self.cpp_info.filenames["cmake_find_package_multi"] = "glew" + + self.cpp_info.set_property("cmake_target_name", "GLEW::GLEW") + + self.cpp_info.set_property("cmake_file_name", "GLEW") # generates FindGLEW.cmake + self.cpp_info.set_property("cmake_module_file_name", "glew") # generates glew-config.cmake + + # generate both modules and config files + self.cpp_info.set_property("cmake_find_mode", "both") + ... +``` + +### Understanding some workarounds with the .names attribute model in recipes + +The ``.names`` model has some limitations. Because of this, there are some recurrent +workarounds in recipes to achieve things like setting absolute names for targets (without +the ``::`` namespace), or for setting a custom namespace. These workarounds can now be +undone with the ``set_property`` model because it allows setting arbitrary names for CMake +targets. Let's see some examples of these workarounds in recipes: + +* **Use of components to get arbitrary target names in recipes**. Some recipes add a component + whose only role is to get a target name that is not limited by the namespaces added by + the current generators automatically. For example, the [ktx + recipe](https://github.com/conan-io/conan-center-index/blob/5753f954027d9d04b6d05e326f2757ab6b1ac69c/recipes/ktx/all/conanfile.py) + uses this workaround to get a target with name ``KTX::ktx``. + +```python +class KtxConan(ConanFile): + name = "ktx" + ... + + def package_info(self): + # changes namespace to KTX:: + self.cpp_info.names["cmake_find_package"] = "KTX" + ... + # the target inherits the KTX:: namespace and sets the target KTX::ktx + self.cpp_info.components["libktx"].names["cmake_find_package"] = "ktx" + ... + # all the information is set via this "fake root" component + self.cpp_info.components["libktx"].libs = ["ktx"] + self.cpp_info.components["libktx"].defines = [ + "KTX_FEATURE_KTX1", "KTX_FEATURE_KTX2", "KTX_FEATURE_WRITE" + ] + ... +``` + +In these cases, the recommendation is to add the ``cmake_target_name`` property for both +the root and component ``cpp_info``. In the end the target that the consumer will get is +the one created for the component, but it will avoid creating an "unwanted" target if we +add the property just to the component or to the root ``cpp_info``. Please note that when +the migration to Conan 2.0 is done, there will be no need for that component anymore and +it should dissapear. At that moment, the information from the component will be set in the +root ``cpp_info`` and the ``self.cpp_info.components[]`` lines removed. + +```python +class KtxConan(ConanFile): + name = "ktx" + ... + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "KTX" + ... + # FIXME: Remove the libktx component in Conan 2.0, this is just needed for + # compatibility with current generators + self.cpp_info.components["libktx"].names["cmake_find_package"] = "ktx" + ... + self.cpp_info.components["libktx"].libs = ["ktx"] + self.cpp_info.components["libktx"].defines = [ + "KTX_FEATURE_KTX1", "KTX_FEATURE_KTX2", "KTX_FEATURE_WRITE" + ] + + # Set the root cpp_info target name as KTX::ktx for the root and the component + # In Conan 2.0 the component should be removed + # and those properties should be added to the root cpp_info instead + self.cpp_info.set_property("cmake_target_name", "KTX::ktx") + self.cpp_info.components["libktx"].set_property("cmake_target_name", "KTX::ktx") + ... +``` + +* **Use build modules to create aliases with arbitray names for targets**. Similar to the + previous example, some recipes use a build module with an alias to set an arbitrary + target name. Let's see the example of the [tensorflow-lite + recipe](https://github.com/conan-io/conan-center-index/blob/03b24bf128cbf15d23ed988b8d8ca0c0ba87d307/recipes/tensorflow-lite/all/conanfile.py), + that uses this workaround to define a ``tensorflow::tensorflowlite`` target. + +```python +class TensorflowLiteConan(ConanFile): + name = "tensorflow-lite" + ... + + def package_info(self): + # generate the target tensorflowlite::tensorflowlite + self.cpp_info.names["cmake_find_package"] = "tensorflowlite" + self.cpp_info.filenames["cmake_find_package"] = "tensorflowlite" + # this build module defines an alias tensorflow::tensorflowlite to the tensorflowlite::tensorflowlite generated target + self.cpp_info.build_modules["cmake_find_package"] = [os.path.join(self._module_subfolder, self._module_file)] + ... +``` + +To translate this information to the new model, just check which aliases are defined in the +build modules and define those for the new model. In this case it should be enough with +adding the ``tensorflow::tensorflowlite`` target with ``cmake_target_name`` to the root +cpp_info (besides the ``cmake_file_name``property). + +```python +class TensorflowLiteConan(ConanFile): + name = "tensorflow-lite" + ... + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "tensorflowlite" + self.cpp_info.filenames["cmake_find_package"] = "tensorflowlite" + self.cpp_info.build_modules["cmake_find_package"] = [os.path.join(self._module_subfolder, self._module_file)] + + # set the tensorflowlite::tensorflowlite target name directly for CMakeDeps with no need for aliases + self.cpp_info.set_property("cmake_target_name", "tensorflow::tensorflowlite") + self.cpp_info.set_property("cmake_file_name", "tensorflowlite") + ... +``` + +### Translating .build_modules to cmake_build_modules + +Previously we saw that some recipes use a build module with an alias to set an arbitrary target name. +But sometimes the declared ".build_modules" come from the original package that declares useful CMake functions, variables +etc. We need to use the property `cmake_build_modules` to declare a list of cmake files instead of using `cpp_info.build_modules`: + +```python +class PyBind11Conan(ConanFile): + name = "pybind11" + ... + + def package_info(self): + ... + for generator in ["cmake_find_package", "cmake_find_package_multi"]: + self.cpp_info.components["main"].build_modules[generator].append(os.path.join("lib", "cmake", "pybind11", "pybind11Common.cmake")) + ... + +``` + +To translate this information to the new model we declare the `cmake_build_modules` property in the `root cpp_info` object: + +```python +class PyBind11Conan(ConanFile): + name = "pybind11" + ... + + def package_info(self): + ... + self.cpp_info.set_property("cmake_build_modules", [os.path.join("lib", "cmake", "pybind11", "pybind11Common.cmake")]) + ... + +``` + +### PkgConfigDeps + +The case of ``PkgConfigDeps`` is much more straight forward than the ``CMakeDeps`` case. +This is because the current +[pkg_config](https://docs.conan.io/en/latest/reference/generators/pkg_config.html) +generator suports the new ``set_property`` model for most of the properties. Then, the current +model can be translated to the new one without having to leave the old attributes in the +recipes. Let's see an example: + +```python +class AprConan(ConanFile): + name = "apr" + ... + def package_info(self): + self.cpp_info.names["pkg_config"] = "apr-1" + ... +``` + +In this case, you can remove the ``.names`` attribute and just leave: + +```python +class AprConan(ConanFile): + name = "apr" + ... + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "apr-1") + ... +``` + +For more information about properties supported by ``PkgConfigDeps`` generator, please check the [Conan +documentation](https://docs.conan.io/en/latest/reference/conanfile/tools/gnu/pkgconfigdeps.html#properties). diff --git a/docs/v2_roadmap.md b/docs/v2_roadmap.md new file mode 100644 index 0000000000000..99e93b1464007 --- /dev/null +++ b/docs/v2_roadmap.md @@ -0,0 +1,144 @@ +# Road to Conan v2 + + +## Contents + + * [Short term](#short-term) + * [Prepare the CI infrastructure](#prepare-the-ci-infrastructure) + * [Export recipes using Conan v2 (warning)](#export-recipes-using-conan-v2-warning) + * [Prepare a syntax linter (CCI specific)](#prepare-a-syntax-linter-cci-specific) + * [Run an scheduled job exporting all recipes](#run-an-scheduled-job-exporting-all-recipes) + * [Mid term](#mid-term) + * [Add CI running Conan v2 (hidden)](#add-ci-running-conan-v2-hidden) + * [Show CI results to contributors (info)](#show-ci-results-to-contributors-info) + * [Linter - turn more warnings to errors](#linter---turn-more-warnings-to-errors) + * [Export using Conan v2 becomes an error](#export-using-conan-v2-becomes-an-error) + * [Long term](#long-term) + * [CI running v2 is reported (and required)](#ci-running-v2-is-reported-and-required) + * [Conan v2 remote](#conan-v2-remote) + * [Webpage with v2 information](#webpage-with-v2-information) + * [Future](#future) + +> **Note** This document is not a [guide about how to migrate recipes to Conan v2](v2_migration.md). + +> **Note** This is a working document that will be updated as we walk +> this path. There are no dates intentionally, and if any they should be +> considered as an estimation, there are still some unknowns to provide +> certain steps and dates. + +Conan v2 is under heavy development and it will be released in the +following months. It comes with many improvements that will benefit +recipes and users, and we are willing to adopt it. + +It is a new major version that will come with many breaking changes. Lot +of the features and syntax that we were used to in Conan v1 will no longer +be available and will be supersedes by improved alternatives. All these +alternatives should be backported to v1.x releases, so **there will be a +subset of features that will work using Conan v1 and v2**. + +**Our main goal in ConanCenter during this migration process is to ensure +that recipes work with v1 and v2** and to make the transition as smooth as +possible for contributors and users. In the end we will be providing +working recipes and binaries for both versions. + +This process will require a lot of work also in the internals, we will keep +communicating those changes and the relevant updates in the +[changelog](changelog.md). Here there are the main steps that we are +planning for the following months. + +## Short term + +### Prepare the CI infrastructure + +Workers for Conan v2 will be ready for Windows, Macos and Linux alternatives. +[Modern docker images](https://github.com/conan-io/conan-docker-tools/tree/master/modern) with Conan v2 are already +available to use, for example `conanio/gcc11-ubuntu16.04:2.0.0-pre`. +Note that we will be using tag name `2.0.0-pre` until there is an +actual Conan v2 release, this tag will use the latest pre-release +available (alpha, beta or release candidate). + +### Export recipes using Conan v2 (warning) + +We will start to run `conan export` using Conan v2 and the result will be +added to the comments by the bot. Failing this command won't make the +pull-request fail at this moment, but we expect contributors to start +gaining awareness about changes in Conan v2. + +### Prepare a syntax linter (CCI specific) + +We want to provide a Conan recipe's linter in this repository. We will add +warnings and errors to it following the pace dictated by the community. +The purpose is that this linter will fail pull-requests if there is any +error and, this way, we can start to migrate small (and easy) bits of +recipes... and ensure that future pull-requests don't introduce +regressions. + +This linter can (and surely will) implement some of the checks that are +being currently done by [hooks](https://github.com/conan-io/hooks), but +the purpose is not replace them: + +* hooks are really useful from the CLI, and are easier to install and run. +* linter provides much better output in GitHub interface. + +### Run an scheduled job exporting all recipes + +The same way we [export all the recipes every night using Conan v1](https://github.com/conan-io/conan-center-index/issues/2232), we will +run something similar using Conan v2 and report the results to an issue in +this repository. + +It will help us to know how many recipes are fixed at a given time and +think about efforts and impact of next steps. + +## Mid term + +### Add CI running Conan v2 (hidden) + +We will start working on a CI running Conan v2. Once recipes start to be +exported successfully, next step is to start building the packages. + +We are going to prepare the CI and start running it behind the scenes +(sorry, at this moment hidden to users) in order to understand and +experiment ourself some challenges that will come with Conan v2: syntax, +configuration defaults,... + +### Show CI results to contributors (info) + +Once the errors start to make sense, we will start to provide these outputs +in pull-requests (although successful builds using v2 won't be required to +merge). Again, we expect some contributors to be aware of these errors, +maybe try to fix those builds, and for sure report feedback. + +### Linter - turn more warnings to errors + +During all this time, the plan is to move linter warnings to errors, one +by one and taking into account the effort required to fix them. With the +help of the linter more recipes should start to work (just `conan export`) +using Conan v2. + +### Export using Conan v2 becomes an error + +When a significant number (TBD) of recipes start to be exported +successfully, we will turn those export warnings into actual errors and +they will be become required to merge the pull-requests + +## Long term + +### CI running v2 is reported (and required) + +Next step is to start running and reporting the results of the builds using +v2 for all the configurations, like we do for Conan v1. At this time all +pull-requests need to work with v1 and v2 to be merged. + +### Conan v2 remote + +TBD. Packages built using Conan v2 will become available for users + +### Webpage with v2 information + +ConanCenter webpage will start to show relevant information related to v2 +packages and, eventually, v2 information will be the only available. + +## Future + +After this process in completed, we will consider the deprecation and +decommission of the infrastructure to generate v1 packages. diff --git a/linter/__init__.py b/linter/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/linter/check_import_conanfile.py b/linter/check_import_conanfile.py new file mode 100644 index 0000000000000..bd5a90391b096 --- /dev/null +++ b/linter/check_import_conanfile.py @@ -0,0 +1,28 @@ + +from pylint.checkers import BaseChecker +from pylint.interfaces import IAstroidChecker +from astroid import nodes, Const, AssignName + + +class ImportConanFile(BaseChecker): + """ + Import ConanFile from new 'conan' module + """ + + __implements__ = IAstroidChecker + + name = "conan-import-conanfile" + msgs = { + "E9006": ( + "Import ConanFile from new module: `from conan import ConanFile`. Old import is deprecated in Conan v2.", + "conan-import-conanfile", + "Import ConanFile from new module: `from conan import ConanFile`. Old import is deprecated in Conan v2.", + ), + } + + def visit_importfrom(self, node: nodes.ImportFrom) -> None: + basename = node.modname + if basename == 'conans': + names = [name for name, _ in node.names] + if 'ConanFile' in names: + self.add_message("conan-import-conanfile", node=node) diff --git a/linter/check_import_errors.py b/linter/check_import_errors.py new file mode 100644 index 0000000000000..b6a0ac1aa9973 --- /dev/null +++ b/linter/check_import_errors.py @@ -0,0 +1,77 @@ + +from pylint.checkers import BaseChecker +from pylint.interfaces import IAstroidChecker +from astroid import nodes, Const, AssignName + + +class ImportErrors(BaseChecker): + """ + Import errors from new 'conan' module + """ + + __implements__ = IAstroidChecker + + name = "conan-import-errors" + msgs = { + "E9008": ( + "Import errors from new module: `from conan import errors`. Old import is deprecated in Conan v2.", + "conan-import-errors", + "Import errors from new module: `from conan import errors`. Old import is deprecated in Conan v2.", + ), + } + + def visit_importfrom(self, node: nodes.ImportFrom) -> None: + basename = node.modname + if basename == 'conans': + names = [name for name, _ in node.names] + if 'errors' in names: + self.add_message("conan-import-errors", node=node) + + +class ImportErrorsConanException(BaseChecker): + """ + Import errors from new 'conan' module + """ + + __implements__ = IAstroidChecker + + name = "conan-import-error-conanexception" + msgs = { + "E9009": ( + "Import ConanException from new module: `from conan.errors import ConanException`. Old import is deprecated in Conan v2.", + "conan-import-error-conanexception", + "Import ConanException from new module: `from conan.errors import ConanException`. Old import is deprecated in Conan v2.", + ), + } + + def visit_importfrom(self, node: nodes.ImportFrom) -> None: + basename = node.modname + if basename == 'conans.errors': + names = [name for name, _ in node.names] + if 'ConanException' in names: + self.add_message("conan-import-error-conanexception", node=node) + + +class ImportErrorsConanInvalidConfiguration(BaseChecker): + """ + Import errors from new 'conan' module + """ + + __implements__ = IAstroidChecker + + name = "conan-import-error-conaninvalidconfiguration" + msgs = { + "E9010": ( + "Import ConanInvalidConfiguration from new module: `from conan.errors import ConanInvalidConfiguration`. Old import is deprecated in Conan v2.", + "conan-import-error-conaninvalidconfiguration", + "Import ConanInvalidConfiguration from new module: `from conan.errors import ConanInvalidConfiguration`. Old import is deprecated in Conan v2.", + ), + } + + def visit_importfrom(self, node: nodes.ImportFrom) -> None: + basename = node.modname + if basename == 'conans.errors': + names = [name for name, _ in node.names] + if 'ConanInvalidConfiguration' in names: + self.add_message("conan-import-error-conaninvalidconfiguration", node=node) + diff --git a/linter/check_import_tools.py b/linter/check_import_tools.py new file mode 100644 index 0000000000000..1621c7b3dfd2a --- /dev/null +++ b/linter/check_import_tools.py @@ -0,0 +1,30 @@ +import re +from email.mime import base +from pylint.checkers import BaseChecker +from pylint.interfaces import IAstroidChecker +from astroid import nodes, Const, AssignName + + +class ImportTools(BaseChecker): + """ + Import tools following pattern 'from conan.tools.xxxx import yyyyy' + """ + + __implements__ = IAstroidChecker + + name = "conan-import-tools" + msgs = { + "E9011": ( + "Import tools following pattern 'from conan.tools.xxxx import yyyyy' (https://docs.conan.io/en/latest/reference/conanfile/tools.html).", + "conan-import-tools", + "Import tools following pattern 'from conan.tools.xxxx import yyyyy' (https://docs.conan.io/en/latest/reference/conanfile/tools.html).", + ), + } + + def visit_importfrom(self, node: nodes.ImportFrom) -> None: + basename = node.modname + names = [name for name, _ in node.names] + if basename == 'conan' and 'tools' in names: + self.add_message("conan-import-tools", node=node) + elif re.match(r'conan\.tools\.[^.]+\..+', basename): + self.add_message("conan-import-tools", node=node) diff --git a/linter/check_no_test_package_name.py b/linter/check_no_test_package_name.py new file mode 100644 index 0000000000000..6a927475b4bb9 --- /dev/null +++ b/linter/check_no_test_package_name.py @@ -0,0 +1,30 @@ +from pylint.checkers import BaseChecker +from pylint.interfaces import IAstroidChecker +from astroid import nodes, Const, AssignName + + +class NoPackageName(BaseChecker): + """ + Conanfile used for testing a package should NOT provide a name + """ + + __implements__ = IAstroidChecker + + name = "conan-test-package-name" + msgs = { + "E9007": ( + "No 'name' attribute in test_package conanfile", + "conan-test-no-name", + "No 'name' attribute in test_package conanfile." + ) + } + + def visit_classdef(self, node: nodes) -> None: + if node.basenames == ['ConanFile']: + for attr in node.body: + children = list(attr.get_children()) + if len(children) == 2 and \ + isinstance(children[0], AssignName) and \ + children[0].name == "name" and \ + isinstance(children[1], Const): + self.add_message("conan-test-no-name", node=attr, line=attr.lineno) diff --git a/linter/check_package_name.py b/linter/check_package_name.py new file mode 100644 index 0000000000000..d2901a6144fd1 --- /dev/null +++ b/linter/check_package_name.py @@ -0,0 +1,39 @@ +from pylint.checkers import BaseChecker +from pylint.interfaces import IAstroidChecker +from astroid import nodes, Const, AssignName + + +class PackageName(BaseChecker): + """ + All packages must have a lower-case name + """ + + __implements__ = IAstroidChecker + + name = "conan-package-name" + msgs = { + "E9004": ( + "Reference name should be all lowercase", + "conan-bad-name", + "Use only lower-case on the package name: `name = 'foobar'`." + ), + "E9005": ( + "Missing name attribute", + "conan-missing-name", + "The member attribute `name` must be declared: `name = 'foobar'`." + ) + } + + def visit_classdef(self, node: nodes) -> None: + if node.basenames == ['ConanFile']: + for attr in node.body: + children = list(attr.get_children()) + if len(children) == 2 and \ + isinstance(children[0], AssignName) and \ + children[0].name == "name" and \ + isinstance(children[1], Const): + value = children[1].as_string() + if value.lower() != value: + self.add_message("conan-bad-name", node=attr, line=attr.lineno) + return + self.add_message("conan-missing-name", node=node) diff --git a/linter/conandata_yaml_linter.py b/linter/conandata_yaml_linter.py new file mode 100644 index 0000000000000..b4a6a859fabe1 --- /dev/null +++ b/linter/conandata_yaml_linter.py @@ -0,0 +1,82 @@ +import argparse +from strictyaml import ( + load, + Map, + Str, + YAMLValidationError, + MapPattern, + Optional, + Seq, + Enum, + Any, +) +from yaml_linting import file_path + + +def main(): + parser = argparse.ArgumentParser( + description="Validate Conan's 'conandata.yaml' file to ConanCenterIndex's requirements." + ) + parser.add_argument( + "path", + nargs="?", + type=file_path, + help="file to validate.", + ) + args = parser.parse_args() + + patch_fields = Map( + { + "patch_file": Str(), + "patch_description": Str(), + "patch_type": Enum( + ["official", "conan", "portability", "bugfix", "vulnerability"] + ), + Optional("patch_source"): Str(), + Optional("sha256"): Str(), # Really uncommon + # No longer required for v2 recipes with layouts + Optional("base_path"): Str(), + } + ) + schema = Map( + { + "sources": MapPattern(Str(), Any(), minimum_keys=1), + Optional("patches"): MapPattern(Str(), Seq(patch_fields), minimum_keys=1), + } + ) + + with open(args.path) as f: + content = f.read() + + try: + parsed = load(content, schema) + + if "patches" in parsed: + for version in parsed["patches"]: + patches = parsed["patches"][version] + for i, patch in enumerate(patches): + type = parsed["patches"][version][i]["patch_type"] + if ( + type in ["official", "bugfix", "vulnerability"] + and not "patch_source" in patch + ): + print( + f"::warning file={args.path},line={type.start_line},endline={type.end_line}," + f"title=conandata.yml schema warning" + "::'patch_type' should have 'patch_source' as per https://github.com/conan-io/conan-center-index/blob/master/docs/conandata_yml_format.md#patches-fields" + " it is expected to have a source (e.g. a URL) to where it originates from to help with reviewing and consumers to evaluate patches\n" + ) + except YAMLValidationError as error: + e = error.__str__().replace("\n", "%0A") + print( + f"::error file={args.path},line={error.context_mark.line},endline={error.problem_mark.line}," + f"title=conandata.yml schema error" + f"::{e}\n" + ) + except BaseException as error: + e = error.__str__().replace("\n", "%0A") + print(f"::error ::{e}") + + +if __name__ == "__main__": + main() diff --git a/linter/conanv2_test_transition.py b/linter/conanv2_test_transition.py new file mode 100644 index 0000000000000..105891a947bd0 --- /dev/null +++ b/linter/conanv2_test_transition.py @@ -0,0 +1,20 @@ +""" + +Pylint plugin/rules for test_package folder in Conan Center Index + +""" + +from pylint.lint import PyLinter +from linter.check_import_conanfile import ImportConanFile +from linter.check_no_test_package_name import NoPackageName +from linter.check_import_errors import ImportErrorsConanException, ImportErrorsConanInvalidConfiguration, ImportErrors +from linter.check_import_tools import ImportTools + + +def register(linter: PyLinter) -> None: + linter.register_checker(NoPackageName(linter)) + linter.register_checker(ImportConanFile(linter)) + linter.register_checker(ImportErrors(linter)) + linter.register_checker(ImportErrorsConanException(linter)) + linter.register_checker(ImportErrorsConanInvalidConfiguration(linter)) + linter.register_checker(ImportTools(linter)) diff --git a/linter/conanv2_transition.py b/linter/conanv2_transition.py new file mode 100644 index 0000000000000..8c79054c05c25 --- /dev/null +++ b/linter/conanv2_transition.py @@ -0,0 +1,20 @@ +""" + +Pylint plugin/rules for conanfiles in Conan Center Index + +""" + +from pylint.lint import PyLinter +from linter.check_package_name import PackageName +from linter.check_import_conanfile import ImportConanFile +from linter.check_import_errors import ImportErrorsConanException, ImportErrorsConanInvalidConfiguration, ImportErrors +from linter.check_import_tools import ImportTools + + +def register(linter: PyLinter) -> None: + linter.register_checker(PackageName(linter)) + linter.register_checker(ImportConanFile(linter)) + linter.register_checker(ImportErrors(linter)) + linter.register_checker(ImportErrorsConanException(linter)) + linter.register_checker(ImportErrorsConanInvalidConfiguration(linter)) + linter.register_checker(ImportTools(linter)) diff --git a/linter/config_yaml_linter.py b/linter/config_yaml_linter.py new file mode 100644 index 0000000000000..29807e6ce3b99 --- /dev/null +++ b/linter/config_yaml_linter.py @@ -0,0 +1,37 @@ +import argparse +from strictyaml import load, Map, Str, YAMLValidationError, MapPattern +from yaml_linting import file_path + + +def main(): + parser = argparse.ArgumentParser( + description="Validate ConanCenterIndex's 'config.yaml' file." + ) + parser.add_argument( + "path", + nargs="?", + type=file_path, + help="file to validate.", + ) + args = parser.parse_args() + + schema = Map( + {"versions": MapPattern(Str(), Map({"folder": Str()}), minimum_keys=1)} + ) + + with open(args.path) as f: + content = f.read() + + try: + load(content, schema) + except YAMLValidationError as error: + e = error.__str__().replace("\n", "%0A") + print( + f"::error file={args.path},line={error.context_mark.line},endline={error.problem_mark.line}," + f"title=config.yml schema error" + f"::{e}\n" + ) + + +if __name__ == "__main__": + main() diff --git a/linter/pylintrc_recipe b/linter/pylintrc_recipe new file mode 100644 index 0000000000000..a6a0c3e21aea7 --- /dev/null +++ b/linter/pylintrc_recipe @@ -0,0 +1,30 @@ +[MASTER] +load-plugins=linter.conanv2_transition, + linter.transform_conanfile, + linter.transform_imports + +py-version=3.6 +recursive=no +suggestion-mode=yes +unsafe-load-any-extension=no + +[MESSAGES CONTROL] +disable=fixme, + line-too-long, + missing-module-docstring, + missing-function-docstring, + missing-class-docstring, + invalid-name, + wrong-import-order, # TODO: Remove + import-outside-toplevel # TODO: Remove + +enable=conan-bad-name, + conan-missing-name, + conan-import-conanfile + +[REPORTS] +evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error) / statement) * 10)) +output-format=text +reports=no +score=no + diff --git a/linter/pylintrc_testpackage b/linter/pylintrc_testpackage new file mode 100644 index 0000000000000..70d2a6ad14864 --- /dev/null +++ b/linter/pylintrc_testpackage @@ -0,0 +1,27 @@ +[MASTER] +load-plugins=linter.conanv2_test_transition, + linter.transform_conanfile, + linter.transform_imports +py-version=3.6 +recursive=no +suggestion-mode=yes +unsafe-load-any-extension=no + +[MESSAGES CONTROL] +disable=fixme, + line-too-long, + missing-module-docstring, + missing-function-docstring, + missing-class-docstring, + invalid-name, + wrong-import-order, # TODO: Remove + import-outside-toplevel # TODO: Remove + +enable=conan-test-no-name, + conan-import-conanfile + +[REPORTS] +evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error) / statement) * 10)) +output-format=text +reports=no +score=no diff --git a/linter/recipe_linter.json b/linter/recipe_linter.json new file mode 100644 index 0000000000000..0b9ff4566b051 --- /dev/null +++ b/linter/recipe_linter.json @@ -0,0 +1,43 @@ +{ + "problemMatcher": [ + { + "owner": "recipe_linter_fatals", + "severity": "error", + "pattern": [ + { + "regexp": "(\\S+):(\\d+): \\[(F\\d+\\(\\S+\\)),\\s(.+?)?\\](.+)", + "file": 1, + "line": 2, + "message": 5, + "code": 3 + } + ] + }, + { + "owner": "recipe_linter_errors", + "severity": "error", + "pattern": [ + { + "regexp": "(\\S+):(\\d+): \\[(E\\d+\\(\\S+\\)),\\s(.+?)?\\](.+)", + "file": 1, + "line": 2, + "message": 5, + "code": 3 + } + ] + }, + { + "owner": "recipe_linter_warnings", + "severity": "warning", + "pattern": [ + { + "regexp": "(\\S+):(\\d+): \\[(W\\d+\\(\\S+\\)),\\s(.+?)?\\](.+)", + "file": 1, + "line": 2, + "message": 5, + "code": 3 + } + ] + } + ] +} diff --git a/linter/transform_conanfile.py b/linter/transform_conanfile.py new file mode 100644 index 0000000000000..8e33d368643b1 --- /dev/null +++ b/linter/transform_conanfile.py @@ -0,0 +1,74 @@ + +# Class ConanFile doesn't declare all the valid members and functions, +# some are injected by Conan dynamically to the class. + +import textwrap +import astroid +from astroid.builder import AstroidBuilder +from astroid.manager import AstroidManager + + +def _settings_transform(): + module = AstroidBuilder(AstroidManager()).string_build( + textwrap.dedent(""" + class Settings(object): + os = None + arch = None + compiler = None + build_type = None + """) + ) + return module['Settings'] + +def _user_info_build_transform(): + module = AstroidBuilder(AstroidManager()).string_build( + textwrap.dedent(""" + class UserInfoBuild(defaultdict): + pass + """) + ) + return module['UserInfoBuild'] + + +def register(_): + pass + +def transform_conanfile(node): + """Transform definition of ConanFile class so dynamic fields are visible to pylint""" + + str_class = astroid.builtin_lookup("str") + dict_class = astroid.builtin_lookup("dict") + info_class = astroid.MANAGER.ast_from_module_name("conans.model.info").lookup( + "ConanInfo") + build_requires_class = astroid.MANAGER.ast_from_module_name( + "conans.client.graph.graph_manager").lookup("_RecipeBuildRequires") + file_copier_class = astroid.MANAGER.ast_from_module_name( + "conans.client.file_copier").lookup("FileCopier") + file_importer_class = astroid.MANAGER.ast_from_module_name( + "conans.client.importer").lookup("_FileImporter") + python_requires_class = astroid.MANAGER.ast_from_module_name( + "conans.client.graph.python_requires").lookup("PyRequires") + + dynamic_fields = { + "conan_data": str_class, + "build_requires": build_requires_class, + "tool_requires": build_requires_class, + "info_build": info_class, + "user_info_build": [_user_info_build_transform()], + "info": info_class, + "copy": file_copier_class, + "copy_deps": file_importer_class, + "python_requires": [str_class, python_requires_class], + "recipe_folder": str_class, + "settings_build": [_settings_transform()], + "settings_target": [_settings_transform()], + "conf": dict_class, + } + + for f, t in dynamic_fields.items(): + node.locals[f] = [i for i in t] + + +astroid.MANAGER.register_transform( + astroid.ClassDef, transform_conanfile, + lambda node: node.qname() == "conans.model.conan_file.ConanFile") diff --git a/linter/transform_imports.py b/linter/transform_imports.py new file mode 100644 index 0000000000000..78b72e4b16880 --- /dev/null +++ b/linter/transform_imports.py @@ -0,0 +1,46 @@ + +import astroid +from pylint.lint import PyLinter + +""" +Here we are transforming the imports to mimic future Conan v2 release. With +these changes, built-in checks in Pylint will raise with different errors, so +we are modifying the messages to point users in the right direction. +""" + + +def register(linter: PyLinter): + msge1101 = linter.msgs_store._messages_definitions["E1101"] + msge1101.msg += ". Please, check https://github.com/conan-io/conan-center-index/blob/master/docs/v2_linter.md" + linter.msgs_store.register_message(msge1101) + + msge0611 = linter.msgs_store._messages_definitions["E0611"] + msge0611.msg += ". Please, check https://github.com/conan-io/conan-center-index/blob/master/docs/v2_linter.md" + linter.msgs_store.register_message(msge0611) + +def transform_tools(module): + """ Transform import module """ + if 'get' in module.locals: + del module.locals['get'] + if 'cross_building' in module.locals: + del module.locals['cross_building'] + if 'rmdir' in module.locals: + del module.locals['rmdir'] + if 'Version' in module.locals: + del module.locals['Version'] + +def transform_errors(module): + pass + #if 'ConanInvalidConfiguration' in module.locals: + # del module.locals['ConanInvalidConfiguration'] + #if 'ConanException' in module.locals: + # del module.locals['ConanException'] + + +astroid.MANAGER.register_transform( + astroid.Module, transform_tools, + lambda node: node.qname() == "conans.tools") + +astroid.MANAGER.register_transform( + astroid.Module, transform_errors, + lambda node: node.qname() == "conans.errors") diff --git a/linter/yaml_linting.py b/linter/yaml_linting.py new file mode 100644 index 0000000000000..8b61d99ba39f9 --- /dev/null +++ b/linter/yaml_linting.py @@ -0,0 +1,9 @@ +import argparse + + +def file_path(a_string): + from os.path import isfile + + if not isfile(a_string): + raise argparse.ArgumentTypeError(f"{a_string} does not point to a file") + return a_string diff --git a/linter/yamllint_matcher.json b/linter/yamllint_matcher.json new file mode 100644 index 0000000000000..42a3ef93b5956 --- /dev/null +++ b/linter/yamllint_matcher.json @@ -0,0 +1,22 @@ +{ + "problemMatcher": [ + { + "owner": "yamllint_matcher", + "pattern": [ + { + "regexp": "^(.*\\.ya?ml)$", + "file": 1 + }, + { + "regexp": "^\\s{2}(\\d+):(\\d+)\\s+(error|warning)\\s+(.*?)\\s+\\((.*)\\)$", + "line": 1, + "column": 2, + "severity": 3, + "message": 4, + "code": 5, + "loop": true + } + ] + } + ] +} diff --git a/linter/yamllint_rules.yml b/linter/yamllint_rules.yml new file mode 100644 index 0000000000000..7c0ce102ddc36 --- /dev/null +++ b/linter/yamllint_rules.yml @@ -0,0 +1,26 @@ +extends: default +rules: + document-start: + level: error + present: false + document-end: + level: error + present: false + empty-values: + forbid-in-block-mappings: true + forbid-in-flow-mappings: true + line-length: disable + indentation: + level: error + new-line-at-end-of-file: + level: error + trailing-spaces: + level: error + comments: + level: error + comments-indentation: + level: error + new-lines: + type: unix + key-duplicates: + level: error diff --git a/mkenv.py b/mkenv.py new file mode 100755 index 0000000000000..9c6b49ba4f102 --- /dev/null +++ b/mkenv.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import importlib +import os +import subprocess +import sys + +if sys.version_info[:2] < (3, 9): + # Don't allow anything but Python 3.9 or higher + raise SystemError('Only Python 3.9+ is allowed') + +MKENV_IMPL = 'mkenv_impl' +HERE = os.path.dirname(os.path.abspath(__file__)) +MKENV_SUBDIR = '.mkenv' +MKENV_REPO = os.environ.get('DL_MKENV_REPO', 'git@octocat.dlogics.com:datalogics/mkenv.git') +MKENV_BRANCH = os.environ.get('DL_MKENV_BRANCH', 'main') +DL_MKENV_ENVIRONMENT_OVERRIDE = 'DL_MKENV_REPO' in os.environ or 'DL_MKENV_BRANCH' in os.environ +# The oldest Git v2 we have on our machines is 2.3, and it seems to work for mkenv. +GIT_REQUIRED = (2, 3) + + +def run(command_args, verbose=False, check=True, capture_output=False, *args, **kwargs): + if verbose: + print(' '.join(command_args), file=sys.stderr) + redirect_stderr = subprocess.PIPE if capture_output else None + redirect_stdout = subprocess.PIPE if capture_output else sys.stderr + return subprocess.run(command_args, check=check, stdout=redirect_stdout, stderr=redirect_stderr, + *args, **kwargs) + + +def get_mkenv_impl_from_git(): + old_sys_path = sys.path.copy() + try: + mkenv_dir = os.path.join(HERE, MKENV_SUBDIR) + # snipe the verbose flag from the argv to decide how chatty to be about the + # git commands + verbose = '-v' in sys.argv or '--verbose' in sys.argv + + # Check git version + completed = run(['git', 'version'], capture_output=True, check=True) + git_version = completed.stdout.decode().strip().split()[2] + # Windows has string stuff after the first three numbers, hence the [:3] + git_version_split = [int(x) for x in git_version.split('.')[:3]] + if tuple(git_version_split[:len(GIT_REQUIRED)]) < GIT_REQUIRED: + ver_string = '.'.join(str(x) for x in GIT_REQUIRED) + sys.exit(f'*** Git version {ver_string} or newer required, found {git_version}; ' + f' older versions are no longer supported') + + if os.path.isdir(mkenv_dir) and not os.path.islink(mkenv_dir): + # In case the repo wasn't initialized...initializing it again actually doesn't hurt anything + run(['git', '-C', mkenv_dir, 'init']) + completion = run(['git', '-C', mkenv_dir, 'remote', 'set-url', 'origin', MKENV_REPO], verbose=verbose, + check=False) + if completion.returncode != 0: + completion = run(['git', '-C', mkenv_dir, 'remote', 'add', 'origin', MKENV_REPO], verbose=verbose) + run(['git', '-C', mkenv_dir, 'fetch', 'origin'], verbose=verbose) + run(['git', '-C', mkenv_dir, 'checkout', MKENV_BRANCH], verbose=verbose) + run(['git', '-C', mkenv_dir, 'reset', '--hard', f'origin/{MKENV_BRANCH}'], verbose=verbose) + elif os.path.exists(mkenv_dir): + sys.exit('*** .mkenv is not a directory; remove it and try again.') + else: + run(['git', 'clone', MKENV_REPO, MKENV_SUBDIR, '--branch', MKENV_BRANCH], verbose=verbose) + sys.path.insert(0, mkenv_dir) + mkenv_impl = importlib.import_module(MKENV_IMPL) + return mkenv_impl + finally: + sys.path[:] = old_sys_path + + +def main(): + mkenv_impl = None + + if not DL_MKENV_ENVIRONMENT_OVERRIDE: + # Use local module only if exists and not overridden by environment + old_sys_path = sys.path.copy() + sys.path.insert(0, HERE) + try: + mkenv_impl = importlib.import_module(MKENV_IMPL) + except ModuleNotFoundError: + pass + finally: + sys.path[:] = old_sys_path + + if mkenv_impl is None: + mkenv_impl = get_mkenv_impl_from_git() + return mkenv_impl.main(HERE) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/pylintrc b/pylintrc new file mode 100644 index 0000000000000..60823e8b7c9ed --- /dev/null +++ b/pylintrc @@ -0,0 +1,628 @@ +[MAIN] + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Load and enable all available extensions. Use --list-extensions to see a list +# all available extensions. +#enable-all-extensions= + +# In error mode, messages with a category besides ERROR or FATAL are +# suppressed, and no reports are done by default. Error mode is compatible with +# disabling specific errors. +#errors-only= + +# Always return a 0 (non-error) status code, even if lint errors are found. +# This is primarily useful in continuous integration scripts. +#exit-zero= + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. +extension-pkg-allow-list= + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. (This is an alternative name to extension-pkg-allow-list +# for backward compatibility.) +extension-pkg-whitelist= + +# Return non-zero exit code if any of these messages/categories are detected, +# even if score is above --fail-under value. Syntax same as enable. Messages +# specified are enabled, while categories only check already-enabled messages. +fail-on= + +# Specify a score threshold under which the program will exit with error. +fail-under=10 + +# Interpret the stdin as a python script, whose filename needs to be passed as +# the module_or_package argument. +#from-stdin= + +# Files or directories to be skipped. They should be base names, not paths. +ignore=.git,.tox,.idea,.conan,recipes,.github,docs,linter,.mkenv,mkenv.py,.cache,tests + +# Add files or directories matching the regular expressions patterns to the +# ignore-list. The regex matches against paths and can be in Posix or Windows +# format. Because '\' represents the directory delimiter on Windows systems, it +# can't be used as an escape character. +ignore-paths= + +# Files or directories matching the regular expression patterns are skipped. +# The regex matches against base names, not paths. The default value ignores +# Emacs file locks +ignore-patterns=^(\.#|python-env-) + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis). It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use, and will cap the count on Windows to +# avoid hangs. +jobs=1 + +# Control the amount of potential inferred values when inferring a single +# object. This can help the performance when dealing with large functions or +# complex, nested conditions. +limit-inference-results=100 + +# List of plugins (as comma separated values of python module names) to load, +# usually to register additional checkers. +load-plugins= + pylint.extensions.confusing_elif, + pylint.extensions.for_any_all, + pylint.extensions.consider_ternary_expression, + pylint.extensions.check_elif, + pylint.extensions.private_import, + pylint.extensions.redefined_variable_type, + pylint.extensions.overlapping_exceptions, + pylint.extensions.redefined_loop_name, + pylint.extensions.set_membership, + pylint.extensions.typing + +# Pickle collected data for later comparisons. +persistent=yes + +# Minimum Python version to use for version dependent checks. Will default to +# the version used to run pylint. +py-version=3.9 + +# Discover python modules and packages in the file system subtree. +recursive=no + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages. +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + +# In verbose mode, extra non-checker-related info will be displayed. +#verbose= + + +[REPORTS] + +# Python expression which should return a score less than or equal to 10. You +# have access to the variables 'fatal', 'error', 'warning', 'refactor', +# 'convention', and 'info' which contain the number of messages in each +# category, as well as 'statement' which is the total number of statements +# analyzed. This score is used by the global evaluation report (RP0004). +evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +msg-template= + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +#output-format= + +# Tells whether to display a full report or only the messages. +reports=no + +# Activate the evaluation score. +score=yes + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, +# UNDEFINED. +confidence=HIGH, + CONTROL_FLOW, + INFERENCE, + INFERENCE_FAILURE, + UNDEFINED + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then re-enable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=raw-checker-failed, + bad-inline-option, + locally-disabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + use-symbolic-message-instead + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable=c-extension-no-member + + +[LOGGING] + +# The type of string formatting that logging methods do. `old` means using % +# formatting, `new` is for `{}` formatting. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 + +# Spelling dictionary name. Available dictionaries: none. To make it work, +# install the 'python-enchant' package. +spelling-dict= + +# List of comma separated words that should be considered directives if they +# appear at the beginning of a comment and should not be checked. +spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy: + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains the private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to the private dictionary (see the +# --spelling-private-dict-file option) instead of raising a message. +spelling-store-unknown-words=no + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + +# Regular expression of note tags to take in consideration. +notes-rgx= + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of symbolic message names to ignore for Mixin members. +ignored-checks-for-mixins=no-member, + not-async-context-manager, + not-context-manager, + attribute-defined-outside-init + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + +# Regex pattern to define which classes are considered mixins. +mixin-class-rgx=.*[Mm]ixin + +# List of decorators that change the signature of a decorated function. +signature-mutators= + + +[CLASSES] + +# Warn about protected attribute access inside special methods +check-protected-access-in-special-methods=no + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp, + __post_init__ + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=cls + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid defining new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of names allowed to shadow builtins +allowed-redefined-builtins= + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expected to +# not be used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=120 + +# Maximum number of lines in a module. +max-module-lines=1000 + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[IMPORTS] + +# List of modules that can be imported at any level, not just the top level +# one. +allow-any-import-level= + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules= + +# Output a graph (.gv or any supported image format) of external dependencies +# to the given file (report RP0402 must not be disabled). +ext-import-graph= + +# Output a graph (.gv or any supported image format) of all (i.e. internal and +# external) dependencies to the given file (report RP0402 must not be +# disabled). +import-graph= + +# Output a graph (.gv or any supported image format) of internal dependencies +# to the given file (report RP0402 must not be disabled). +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + +# Couples of modules and preferred modules, separated by a comma. +preferred-modules= + + +[METHOD_ARGS] + +# List of qualified names (i.e., library.method) which require a timeout +# parameter e.g. 'requests.api.get,requests.api.post' +timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when caught. +overgeneral-exceptions=BaseException, + Exception + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit,argparse.parse_error + + +[SIMILARITIES] + +# Comments are removed from the similarity computation +ignore-comments=yes + +# Docstrings are removed from the similarity computation +ignore-docstrings=yes + +# Imports are removed from the similarity computation +ignore-imports=yes + +# Signatures are removed from the similarity computation +ignore-signatures=yes + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[DESIGN] + +# List of regular expressions of class ancestor names to ignore when counting +# public methods (see R0903) +exclude-too-few-public-methods= + +# List of qualified class names to ignore when counting class parents (see +# R0901) +ignored-parents= + +# Maximum number of arguments for function / method. +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in an if statement (see R0916). +max-bool-expr=5 + +# Maximum number of branch for function / method body. +max-branches=12 + +# Maximum number of locals for function / method body. +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +# Maximum number of return / yield for function / method body. +max-returns=6 + +# Maximum number of statements in function / method body. +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[STRING] + +# This flag controls whether inconsistent-quotes generates a warning when the +# character used as a quote delimiter is used inconsistently within a module. +check-quote-consistency=no + +# This flag controls whether the implicit-str-concat should generate a warning +# on implicit string concatenation in sequences defined over several lines. +check-str-concat-over-line-jumps=no + + +[BASIC] + +# Naming style matching correct argument names. +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style. If left empty, argument names will be checked with the set +# naming style. +#argument-rgx= + +# Naming style matching correct attribute names. +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. If left empty, attribute names will be checked with the set naming +# style. +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma. +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Bad variable names regexes, separated by a comma. If names match any regex, +# they will always be refused +bad-names-rgxs= + +# Naming style matching correct class attribute names. +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. If left empty, class attribute names will be checked +# with the set naming style. +#class-attribute-rgx= + +# Naming style matching correct class constant names. +class-const-naming-style=UPPER_CASE + +# Regular expression matching correct class constant names. Overrides class- +# const-naming-style. If left empty, class constant names will be checked with +# the set naming style. +#class-const-rgx= + +# Naming style matching correct class names. +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming- +# style. If left empty, class names will be checked with the set naming style. +#class-rgx= + +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style. If left empty, constant names will be checked with the set naming +# style. +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names. +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style. If left empty, function names will be checked with the set +# naming style. +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + Run, + _ + +# Good variable names regexes, separated by a comma. If names match any regex, +# they will always be accepted +good-names-rgxs= + +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=no + +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. If left empty, inline iteration names will be checked +# with the set naming style. +#inlinevar-rgx= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style. If left empty, method names will be checked with the set naming style. +#method-rgx= + +# Naming style matching correct module names. +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style. If left empty, module names will be checked with the set naming style. +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty + +# Regular expression matching correct type variable names. If left empty, type +# variable names will be checked with the set naming style. +#typevar-rgx= + +# Naming style matching correct variable names. +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. If left empty, variable names will be checked with the set +# naming style. +#variable-rgx= diff --git a/recipes/7zip/19.00/conanfile.py b/recipes/7zip/19.00/conanfile.py index 3ac8391b6b7bd..d18ee2242a6e7 100644 --- a/recipes/7zip/19.00/conanfile.py +++ b/recipes/7zip/19.00/conanfile.py @@ -1,54 +1,63 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import download, chdir, replace_in_file +from conans import tools, AutoToolsBuildEnvironment import os -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.47.0" -class Package7Zip(ConanFile): + +class SevenZipConan(ConanFile): name = "7zip" - version = "19.00" url = "https://github.com/conan-io/conan-center-index" description = "7-Zip is a file archiver with a high compression ratio" license = ("LGPL-2.1", "BSD-3-Clause", "Unrar") homepage = "https://www.7-zip.org" - topics = ("conan", "7zip", "zip", "compression", "decompression") + topics = ("7zip", "zip", "compression", "decompression") settings = "os", "arch", "compiler" - def configure(self): + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def validate(self): if self.settings.os != "Windows": raise ConanInvalidConfiguration("Only Windows supported") if self.settings.arch not in ("x86", "x86_64"): raise ConanInvalidConfiguration("Unsupported architecture") + def build_requirements(self): + self.build_requires("lzma_sdk/9.20") + + if self.settings.compiler != "Visual Studio" and self._settings_build.os == "Windows" and "make" not in os.environ.get("CONAN_MAKE_PROGRAM", ""): + self.build_requires("make/4.3") + + def package_id(self): + del self.info.settings.compiler + + def _uncompress_7z(self, filename): + self.run(f"7zr x {filename}") + def source(self): from six.moves.urllib.parse import urlparse url = self.conan_data["sources"][self.version]["url"] filename = os.path.basename(urlparse(url).path) sha256 = self.conan_data["sources"][self.version]["sha256"] - tools.download(url, filename) - tools.check_sha256(filename, sha256) + download(self, url, filename, sha256) self._uncompress_7z(filename) os.unlink(filename) - def build_requirements(self): - self.build_requires("lzma_sdk/9.20") - - if self.settings.compiler != "Visual Studio" and tools.os_info.is_windows and "make" not in os.environ.get("CONAN_MAKE_PROGRAM", ""): - self.build_requires("make/4.2.1") - - def _uncompress_7z(self, filename): - self.run("7zr x {}".format(filename)) - @property def _msvc_platform(self): return { - 'x86_64': 'x64', - 'x86': 'x86', + "x86_64": "x64", + "x86": "x86", }[str(self.settings.arch)] def _build_msvc(self): with tools.vcvars(self.settings): - with tools.chdir(os.path.join("CPP", "7zip")): - self.run("nmake /f makefile PLATFORM=%s" % self._msvc_platform) + with chdir(self, os.path.join("CPP", "7zip")): + self.run(f"nmake /f makefile PLATFORM={self._msvc_platform}") def _build_autotools(self): # TODO: Enable non-Windows methods in configure @@ -57,15 +66,15 @@ def _build_autotools(self): if self.settings.os == "Windows" and self.settings.compiler == "gcc": extra_env["IS_MINGW"] = "1" with tools.environment_append(extra_env): - with tools.chdir(os.path.join("CPP", "7zip", "Bundles", "LzmaCon")): + with chdir(self, os.path.join("CPP", "7zip", "Bundles", "LzmaCon")): autotools.make(args=["-f", "makefile.gcc"], target="all") def _patch_sources(self): if self.settings.compiler == "Visual Studio": fn = os.path.join("CPP", "Build.mak") os.chmod(fn, 0o644) - tools.replace_in_file(fn, "-MT", "-{}".format(str(self.settings.compiler.runtime))) - tools.replace_in_file(fn, "-MD", "-{}".format(str(self.settings.compiler.runtime))) + replace_in_file(self, fn, "-MT", f"-{self.settings.compiler.runtime}") + replace_in_file(self, fn, "-MD", f"-{self.settings.compiler.runtime}") def build(self): self._patch_sources() @@ -83,10 +92,10 @@ def package(self): # TODO: Package the libraries: binaries and headers (add the rest of settings) - def package_id(self): - del self.info.settings.compiler - def package_info(self): bin_path = os.path.join(self.package_folder, "bin") - self.output.info('Appending PATH environment variable: %s' % bin_path) + self.output.info(f"Appending PATH environment variable: {bin_path}") self.env_info.path.append(bin_path) + + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/7zip/19.00/test_package/conanfile.py b/recipes/7zip/19.00/test_package/conanfile.py index ede37f6971af7..f6a6ccb388a8e 100644 --- a/recipes/7zip/19.00/test_package/conanfile.py +++ b/recipes/7zip/19.00/test_package/conanfile.py @@ -1,9 +1,9 @@ from conans import ConanFile, tools -class TestPackage(ConanFile): +class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - + def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run("7z.exe") diff --git a/recipes/7zip/config.yml b/recipes/7zip/config.yml new file mode 100644 index 0000000000000..46489517ceb78 --- /dev/null +++ b/recipes/7zip/config.yml @@ -0,0 +1,3 @@ +versions: + "19.00": + folder: "19.00" diff --git a/recipes/box2d/2.4.x/CMakeLists.txt b/recipes/aaf/all/CMakeLists.txt similarity index 100% rename from recipes/box2d/2.4.x/CMakeLists.txt rename to recipes/aaf/all/CMakeLists.txt diff --git a/recipes/aaf/all/conandata.yml b/recipes/aaf/all/conandata.yml new file mode 100644 index 0000000000000..6deeda4a0cea7 --- /dev/null +++ b/recipes/aaf/all/conandata.yml @@ -0,0 +1,26 @@ +sources: + "1.2.0": + url: "https://downloads.sourceforge.net/project/aaf/AAF-src/1.2.0/AAF-src-1.2.0.tar.gz" + sha256: "02789b22c96a6f0da112ba990967a8b3fe7228b0435db8ea328d88f9e424086d" +patches: + "1.2.0": + - patch_file: "patches/1.2.0-001-simpler-cmakelists.patch" + base_path: "source_subfolder" + patch_type: "conan" + patch_description: "Simplify CMakeLists.txt" + - patch_file: "patches/1.2.0-002-link-core-with-find-library.patch" + base_path: "source_subfolder" + patch_type: "portability" + patch_description: "Link CoreFoundation and CoreServices with find_library" + - patch_file: "patches/1.2.0-003-remove-register-keyword.patch" + base_path: "source_subfolder" + patch_type: "portability" + patch_description: "Remove deprecated use of register keyword for c++11 builds" + - patch_file: "patches/1.2.0-004-remove-expat.patch" + base_path: "source_subfolder" + patch_type: "conan" + patch_description: "Remove expat dependency directory" + - patch_file: "patches/1.2.0-005-remove-libjpeg.patch" + base_path: "source_subfolder" + patch_type: "conan" + patch_description: "Remove libjpeg dependency directory" diff --git a/recipes/aaf/all/conanfile.py b/recipes/aaf/all/conanfile.py new file mode 100644 index 0000000000000..ab1bf99fe216b --- /dev/null +++ b/recipes/aaf/all/conanfile.py @@ -0,0 +1,90 @@ +from conan.tools.files import apply_conandata_patches +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os +import glob + + +class AafConan(ConanFile): + name = "aaf" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://sourceforge.net/projects/aaf/" + description = "A cross-platform SDK for AAF. AAF is a metadata management system and file format for use in professional multimedia creation and authoring." + topics = ("aaf", "multimedia", "crossplatform") + license = "AAFSDKPSL-2.0" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake", "cmake_find_package" + settings = "os", "compiler", "build_type", "arch" + options = { + "structured_storage": [True, False], + } + default_options = { + "structured_storage": False, + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def requirements(self): + self.requires("expat/2.4.1") + self.requires("libjpeg/9d") + if self.settings.os in ("FreeBSD", "Linux"): + self.requires("libuuid/1.0.3") + + def validate(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + raise ConanInvalidConfiguration("ARM v8 not supported") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def build(self): + apply_conandata_patches(self) + + cmake = CMake(self) + + if tools.is_apple_os(self.settings.os): + cmake.definitions["PLATFORM"] = "apple-clang" + elif self.settings.compiler == "Visual Studio": + cmake.definitions["PLATFORM"] = "vc" + else: + cmake.definitions["PLATFORM"] = self.settings.os + + cmake.definitions["ARCH"] = "x86_64" # ARCH is used only for setting the output directory. So itsvalue does not matter here. + cmake.definitions["AAF_NO_STRUCTURED_STORAGE"] = not self.options.structured_storage + cmake.configure(build_folder=self._build_subfolder) + cmake.build() + + def package(self): + self.copy("out/shared/include/*.h", dst="include", src=self._source_subfolder, keep_path=False) + self.copy("out/target/*/*/RefImpl/*.dll", dst="bin", src=self._source_subfolder, keep_path=False) + self.copy("out/target/*/*/RefImpl/*.lib", dst="lib", src=self._source_subfolder, keep_path=False) + self.copy("out/target/*/*/RefImpl/*.so", dst="lib", src=self._source_subfolder, keep_path=False) + self.copy("out/target/*/*/RefImpl/*.dylib", dst="lib", src=self._source_subfolder, keep_path=False) + self.copy("out/target/*/*/RefImpl/*.a", dst="lib", src=self._source_subfolder, keep_path=False) + self.copy("LEGAL/AAFSDKPSL.TXT", dst="licenses", src=self._source_subfolder, keep_path=False) + + if tools.is_apple_os(self.settings.os): + with tools.chdir(os.path.join(self.package_folder, "lib")): + for dylib in glob.glob("*.dylib"): + command = "install_name_tool -id {0} {1}".format(os.path.basename(dylib), dylib) + self.output.info(command) + self.run(command) + + def package_info(self): + if self.settings.os == "Windows": + if self.settings.build_type == "Release": + self.cpp_info.libs = ["AAF", "AAFIID", "AAFCOAPI"] + else: + self.cpp_info.libs = ["AAFD", "AAFIIDD", "AAFCOAPI"] + else: + self.cpp_info.libs = ["aaflib", "aafiid", "com-api"] + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs = ["dl"] + if self.settings.os == 'Macos': + self.cpp_info.frameworks = ['CoreServices', 'CoreFoundation'] diff --git a/recipes/aaf/all/patches/1.2.0-001-simpler-cmakelists.patch b/recipes/aaf/all/patches/1.2.0-001-simpler-cmakelists.patch new file mode 100644 index 0000000000000..35894ccd93c36 --- /dev/null +++ b/recipes/aaf/all/patches/1.2.0-001-simpler-cmakelists.patch @@ -0,0 +1,36 @@ +commit b84775c16e49bf84a021a281fcdb86ac1ecca319 +Author: Martin Delille +Date: Tue Aug 3 11:26:55 2021 +0200 + + Simpler CMakeLists.txt + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e77cb93cc..a7474dc2f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -58,25 +58,14 @@ set(AAFSDK_OUT_DIR "${AAFSDK_ROOT}/out" CACHE STRING "Path to AAFSDK output dire + + project(AAF-SDK LANGUAGES CXX) + +-enable_testing() +- + include(pdefs) + include(cdefs) + include(common) + include(ss) + +-add_subdirectory(DevUtils) +-add_subdirectory(examples) +-add_subdirectory(examples2) + add_subdirectory(ref-impl) +-add_subdirectory(test) +-add_subdirectory(Utilities) + + add_custom_target(Everything) + add_dependencies(Everything + MakeSDK +- MakeSDKExamples +- MakeSDKExamples2 +- MakeSDKTests +- MakeSDKUtilities + ) diff --git a/recipes/aaf/all/patches/1.2.0-002-link-core-with-find-library.patch b/recipes/aaf/all/patches/1.2.0-002-link-core-with-find-library.patch new file mode 100644 index 0000000000000..4032271f93828 --- /dev/null +++ b/recipes/aaf/all/patches/1.2.0-002-link-core-with-find-library.patch @@ -0,0 +1,51 @@ +commit a72ae1b4486769c76bb40683388ee52845c09bfe +Author: Martin Delille +Date: Sat Jul 17 18:22:17 2021 +0200 + + Link CoreFoundation and CoreServices with find_library + +diff --git a/build/cdefs.cmake b/build/cdefs.cmake +index e1b924599..7096b3464 100644 +--- a/build/cdefs.cmake ++++ b/build/cdefs.cmake +@@ -36,10 +36,6 @@ cmake_minimum_required(VERSION 3.0.2) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG") + if(APPLE) +- set(LINKER_FLAGS "-framework CoreFoundation -framework CoreServices") +- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}") +- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}") +- set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${LINKER_FLAGS}") + elseif(WIN32) + add_definitions( + -D_WIN32 +diff --git a/ref-impl/src/com-api/CMakeLists.txt b/ref-impl/src/com-api/CMakeLists.txt +index d092d9ad2..f0afde40a 100644 +--- a/ref-impl/src/com-api/CMakeLists.txt ++++ b/ref-impl/src/com-api/CMakeLists.txt +@@ -236,11 +236,25 @@ target_include_directories(comapi PRIVATE + ${AAFSDK_ROOT}/ref-impl/src/impl + ) + ++if(APPLE) ++ find_library(CORE_FOUNDATION CoreFoundation) ++ if (NOT CORE_FOUNDATION) ++ message(FATAL_ERROR "CoreFoundation not found") ++ endif() ++ ++ find_library(CORE_SERVICES CoreServices) ++ if (NOT CORE_SERVICES) ++ message(FATAL_ERROR "CoreServices not found") ++ endif() ++endif() ++ + target_link_libraries(comapi PRIVATE + Impl + OM + expat + ss ++ ${CORE_FOUNDATION} ++ ${CORE_SERVICES} + ) + + target_compile_definitions(comapi PUBLIC -DAAFCOAPI) diff --git a/recipes/aaf/all/patches/1.2.0-003-remove-register-keyword.patch b/recipes/aaf/all/patches/1.2.0-003-remove-register-keyword.patch new file mode 100644 index 0000000000000..10819079ff8e5 --- /dev/null +++ b/recipes/aaf/all/patches/1.2.0-003-remove-register-keyword.patch @@ -0,0 +1,46 @@ +diff --git a/ref-impl/plugins/AAFPluginUtils.cpp b/ref-impl/plugins/AAFPluginUtils.cpp +index daa02cadf..5c6767ba4 100755 +--- a/ref-impl/plugins/AAFPluginUtils.cpp ++++ b/ref-impl/plugins/AAFPluginUtils.cpp +@@ -96,7 +96,7 @@ aafBool aafIsEqualGUID( const GUID& guid1, const GUID& guid2 ) + void AAFByteSwap16( + aafInt16 * wp) /* IN/OUT -- Byte swap this value */ + { +- register unsigned char *cp = (unsigned char *) wp; ++ unsigned char *cp = (unsigned char *) wp; + int t; + + t = cp[1]; +@@ -122,7 +122,7 @@ void AAFByteSwap16( + void AAFByteSwap32( + aafInt32 *lp) /* IN/OUT -- Byte swap this value */ + { +- register unsigned char *cp = (unsigned char *) lp; ++ unsigned char *cp = (unsigned char *) lp; + int t; + + t = cp[3]; +@@ -151,7 +151,7 @@ void AAFByteSwap32( + void AAFByteSwap64( + aafInt64 *lp) /* IN/OUT -- Byte swap this value */ + { +- register unsigned char *cp = (unsigned char *) lp; ++ unsigned char *cp = (unsigned char *) lp; + int t; + + t = cp[7]; +diff --git a/ref-impl/src/impl/aafTable.cpp b/ref-impl/src/impl/aafTable.cpp +index 8f18b8e6a..16f231403 100644 +--- a/ref-impl/src/impl/aafTable.cpp ++++ b/ref-impl/src/impl/aafTable.cpp +@@ -1068,8 +1068,8 @@ static aafBool cmpSensitive( void *temp1, void *temp2) + + static aafBool cmpInsensitive( void *temp1, void *temp2) + { +- register char *a = (char *)temp1; +- register char *b = (char *)temp2; ++ char *a = (char *)temp1; ++ char *b = (char *)temp2; + + for ( ; (*a != '\0') && (*b != '\0'); a++, b++) + { diff --git a/recipes/aaf/all/patches/1.2.0-004-remove-expat.patch b/recipes/aaf/all/patches/1.2.0-004-remove-expat.patch new file mode 100644 index 0000000000000..0ced3c8afbed8 --- /dev/null +++ b/recipes/aaf/all/patches/1.2.0-004-remove-expat.patch @@ -0,0 +1,49 @@ +commit a9b8fe86b3d8659e02653a4a502827a6f779e4ba +Author: Martin Delille +Date: Thu Sep 2 16:38:59 2021 +0200 + + Remove expat + +diff --git a/ref-impl/CMakeLists.txt b/ref-impl/CMakeLists.txt +index b1fe34c52..8f4df30b9 100644 +--- a/ref-impl/CMakeLists.txt ++++ b/ref-impl/CMakeLists.txt +@@ -37,7 +37,6 @@ project(MakeSDK LANGUAGES CXX) + + add_subdirectory(aafiid) + add_subdirectory(aaflib) +-add_subdirectory(expat) + add_subdirectory(libjpeg) + add_subdirectory(plugins) + add_subdirectory(src/com-api) +diff --git a/ref-impl/src/OM/CMakeLists.txt b/ref-impl/src/OM/CMakeLists.txt +index e0c5be195..1210f4d99 100644 +--- a/ref-impl/src/OM/CMakeLists.txt ++++ b/ref-impl/src/OM/CMakeLists.txt +@@ -158,9 +158,13 @@ target_include_directories(OM PRIVATE + # HACK (see OMStructuredStorage.h): Required with OM_USE_SCHEMASOFT_SS and OM_USE_GSF_SS + ${AAFSDK_ROOT}/ss-impl/ref + # AAF-XML stored format support requires the expat library which is bundled with the AAF SDK. +- ${AAFSDK_ROOT}/ref-impl/expat ++ #${AAFSDK_ROOT}/ref-impl/expat + ) + ++find_package(EXPAT REQUIRED) ++ ++target_link_libraries(OM PUBLIC EXPAT::EXPAT) ++ + target_compile_definitions(OM PUBLIC + XML_STATIC + $<$:OM_DEBUG> +diff --git a/ref-impl/src/com-api/CMakeLists.txt b/ref-impl/src/com-api/CMakeLists.txt +index f0afde40a..e60955f7f 100644 +--- a/ref-impl/src/com-api/CMakeLists.txt ++++ b/ref-impl/src/com-api/CMakeLists.txt +@@ -251,7 +251,6 @@ endif() + target_link_libraries(comapi PRIVATE + Impl + OM +- expat + ss + ${CORE_FOUNDATION} + ${CORE_SERVICES} diff --git a/recipes/aaf/all/patches/1.2.0-005-remove-libjpeg.patch b/recipes/aaf/all/patches/1.2.0-005-remove-libjpeg.patch new file mode 100644 index 0000000000000..231aa193faf47 --- /dev/null +++ b/recipes/aaf/all/patches/1.2.0-005-remove-libjpeg.patch @@ -0,0 +1,46 @@ +commit 03d84af50a106955f3af7a8f27b9b2f77fa9ddb7 +Author: Martin Delille +Date: Thu Sep 2 16:45:22 2021 +0200 + + Remove libjpeg + +diff --git a/ref-impl/CMakeLists.txt b/ref-impl/CMakeLists.txt +index 8f4df30b9..cdcf808de 100644 +--- a/ref-impl/CMakeLists.txt ++++ b/ref-impl/CMakeLists.txt +@@ -37,7 +37,6 @@ project(MakeSDK LANGUAGES CXX) + + add_subdirectory(aafiid) + add_subdirectory(aaflib) +-add_subdirectory(libjpeg) + add_subdirectory(plugins) + add_subdirectory(src/com-api) + add_subdirectory(src/impl) +diff --git a/ref-impl/plugins/CMakeLists.txt b/ref-impl/plugins/CMakeLists.txt +index a9ed0163f..0570e0b98 100644 +--- a/ref-impl/plugins/CMakeLists.txt ++++ b/ref-impl/plugins/CMakeLists.txt +@@ -71,6 +71,8 @@ add_library(AAFStandardCodecs SHARED + ../src/OM/utf8.cpp + ) + ++find_package(JPEG REQUIRED) ++ + target_include_directories(AAFStandardCodecs PUBLIC + . + ../include/OM +@@ -79,12 +81,13 @@ target_include_directories(AAFStandardCodecs PUBLIC + ../src/impl + ../src/OM + ../../Utilities/Include ++ ${JPEG_RES_DIRS} + ) + + target_link_libraries(AAFStandardCodecs PRIVATE + AAFIID + AAFLIB +- libjpeg ++ JPEG::JPEG + ) + + if(MSVC) diff --git a/recipes/aaf/all/test_package/CMakeLists.txt b/recipes/aaf/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2e676c42d531c --- /dev/null +++ b/recipes/aaf/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_executable(example example.cpp) +target_link_libraries(example CONAN_PKG::aaf) diff --git a/recipes/aaf/all/test_package/conanfile.py b/recipes/aaf/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3f6584e95145b --- /dev/null +++ b/recipes/aaf/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/aaf/all/test_package/example.cpp b/recipes/aaf/all/test_package/example.cpp new file mode 100644 index 0000000000000..038a079789844 --- /dev/null +++ b/recipes/aaf/all/test_package/example.cpp @@ -0,0 +1,12 @@ +#include "AAF.h" +#include "AAFResult.h" + +int main() { + HRESULT hr = AAFLoad(NULL); + + if (AAFRESULT_SUCCEEDED(hr)) { + return 0; + } else { + return -1; + } +} diff --git a/recipes/aaf/config.yml b/recipes/aaf/config.yml new file mode 100644 index 0000000000000..b8ea8afb5a353 --- /dev/null +++ b/recipes/aaf/config.yml @@ -0,0 +1,3 @@ +versions: + "1.2.0": + folder: "all" diff --git a/recipes/aaplus/all/conandata.yml b/recipes/aaplus/all/conandata.yml new file mode 100644 index 0000000000000..f1c7c0805bfae --- /dev/null +++ b/recipes/aaplus/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "2.41": + url: "http://www.naughter.com/download/aaplus_v2.41.zip" + sha256: "7aede2802f3542c91eeefa0cdd4419911c7547073c84a6faa4bf31f6b6f172da" +patches: + "2.41": + - patch_file: "patches/0001-fix-cmake.patch" diff --git a/recipes/aaplus/all/conanfile.py b/recipes/aaplus/all/conanfile.py new file mode 100644 index 0000000000000..82bc050c7cb95 --- /dev/null +++ b/recipes/aaplus/all/conanfile.py @@ -0,0 +1,107 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, load, save +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.53.0" + + +class Aaplusconan(ConanFile): + name = "aaplus" + description = ( + "AA+ is a C++ implementation for the algorithms as presented in the " + "book \"Astronomical Algorithms\" by Jean Meeus" + ) + license = "Unlicense" + topics = ("aa+", "astronomy", "astronomical-algorithms", "orbital-mechanics") + homepage = "http://www.naughter.com/aa.html" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _min_cppstd(self): + return "17" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8", + "clang": "9", + "apple-clang": "11", + "Visual Studio": "16", + "msvc": "192", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + compiler_version = Version(self.info.settings.compiler.version) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.", + ) + + if self.info.settings.compiler == "clang" and (compiler_version >= "10" and compiler_version < "12"): + raise ConanInvalidConfiguration( + "AA+ cannot handle clang 10 and 11 due to filesystem being under experimental namespace" + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license()) + cmake = CMake(self) + cmake.install() + + def _extract_license(self): + aaplus_header = load(self, os.path.join(self.source_folder, "AA+.h")) + begin = aaplus_header.find("Copyright") + end = aaplus_header.find("*/", begin) + return aaplus_header[begin:end] + + def package_info(self): + self.cpp_info.libs = ["aaplus"] + if not self.options.shared: + if self.settings.os == "Windows": + self.cpp_info.system_libs.append("ws2_32") + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "9": + self.cpp_info.system_libs.append("stdc++fs") diff --git a/recipes/aaplus/all/patches/0001-fix-cmake.patch b/recipes/aaplus/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..fa9d9680f0b14 --- /dev/null +++ b/recipes/aaplus/all/patches/0001-fix-cmake.patch @@ -0,0 +1,117 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,9 +1,7 @@ ++cmake_minimum_required(VERSION 3.8) + PROJECT (AstronomicalAlgorithms) + +-cmake_minimum_required(VERSION 3.8) + +-SET(CMAKE_CXX_STANDARD 17) +-SET(CMAKE_CXX_STANDARD_REQUIRED ON) + + #----------------------------------------------------------------------------- + # Output directories. +@@ -133,12 +131,11 @@ SET ( SRCS_LIB + AAVSOP87_SAT.cpp + AAVSOP87_URA.cpp + AAVSOP87_VEN.cpp +- stdafx.cpp + ) + + #----------------------------------------------------------------------------- + SET ( INCS +-# AA+.h ++ AA+.h + AA2DCoordinate.h + AA3DCoordinate.h + AAAberration.h +@@ -149,6 +146,8 @@ SET ( INCS + AADefines.h + AADiameters.h + AADynamicalTime.h ++ AAELP2000.h ++ AAELPMPP02.h + AAEarth.h + AAEaster.h + AAEclipses.h +@@ -157,6 +156,7 @@ SET ( INCS + AAElliptical.h + AAEquationOfTime.h + AAEquinoxesAndSolstices.h ++ AAEquinoxesAndSolstices2.h + AAFK5.h + AAGalileanMoons.h + AAGlobe.h +@@ -170,10 +170,15 @@ SET ( INCS + AAMoon.h + AAMoonIlluminatedFraction.h + AAMoonMaxDeclinations.h ++ AAMoonMaxDeclinations2.h + AAMoonNodes.h ++ AAMoonNodes2.h + AAMoonPerigeeApogee.h ++ AAMoonPerigeeApogee2.h + AAMoonPhases.h ++ AAMoonPhases2.h + AAMoslemCalendar.h ++ AANearParabolic.h + AANeptune.h + AANodes.h + AANutation.h +@@ -192,6 +197,7 @@ SET ( INCS + AAPrecession.h + AARefraction.h + AARiseTransitSet.h ++ AARiseTransitSet2.h + AASaturn.h + AASaturnMoons.h + AASaturnRings.h +@@ -252,7 +258,6 @@ SET ( INCS + AAVSOP87_SAT.h + AAVSOP87_URA.h + AAVSOP87_VEN.h +- stdafx.h + ) + + SET ( SRCS +@@ -262,18 +267,32 @@ SET ( SRCS + #----------------------------------------------------------------------------- + # Executables. + #----------------------------------------------------------------------------- +-ADD_EXECUTABLE(AATest ${SRCS} ) + + #----------------------------------------------------------------------------- + # Libraries. +-ADD_LIBRARY(aaplus-static STATIC ${SRCS_LIB} ${INCS}) +-SET_TARGET_PROPERTIES(aaplus-static PROPERTIES OUTPUT_NAME "aaplus") ++add_library(aaplus ${SRCS_LIB}) ++target_compile_features(aaplus PUBLIC cxx_std_17) ++target_link_libraries(aaplus PRIVATE ++ $<$:ws2_32> ++ $<$,$,9.0>>:stdc++fs> ++) ++if(BUILD_SHARED_LIBS) ++ set_target_properties(aaplus PROPERTIES ++ CXX_VISIBILITY_PRESET hidden ++ VISIBILITY_INLINES_HIDDEN TRUE ++ ) ++ if(WIN32) ++ target_compile_definitions(aaplus PRIVATE "AAPLUS_EXT_CLASS=__declspec(dllexport)") ++ else() ++ target_compile_definitions(aaplus PRIVATE "AAPLUS_EXT_CLASS=__attribute__((visibility(\"default\")))") ++ endif() ++endif() + +-ADD_LIBRARY(aaplus-shared SHARED ${SRCS_LIB} ${INCS}) +-SET_TARGET_PROPERTIES(aaplus-shared PROPERTIES OUTPUT_NAME "aaplus") + +-install(TARGETS aaplus-shared aaplus-static +- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" ) ++install(TARGETS aaplus ++ RUNTIME DESTINATION bin ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib) ++install(FILES ${INCS} DESTINATION include) + +-TARGET_LINK_LIBRARIES(AATest aaplus-static) + diff --git a/recipes/aaplus/all/test_package/CMakeLists.txt b/recipes/aaplus/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..709ce7a5f945a --- /dev/null +++ b/recipes/aaplus/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(aaplus REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE aaplus::aaplus) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/aaplus/all/test_package/conanfile.py b/recipes/aaplus/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/aaplus/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aaplus/all/test_package/test_package.cpp b/recipes/aaplus/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f186e11473bc6 --- /dev/null +++ b/recipes/aaplus/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include + +#include + +int main() { + std::cout << CAAVSOP87_Mercury::A(2451545.0) << std::endl; + return 0; +} diff --git a/recipes/aaplus/all/test_v1_package/CMakeLists.txt b/recipes/aaplus/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/aaplus/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/aaplus/all/test_v1_package/conanfile.py b/recipes/aaplus/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/aaplus/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aaplus/config.yml b/recipes/aaplus/config.yml new file mode 100644 index 0000000000000..9e92b3b5d3553 --- /dev/null +++ b/recipes/aaplus/config.yml @@ -0,0 +1,3 @@ +versions: + "2.41": + folder: all diff --git a/recipes/abseil/all/CMakeLists.txt b/recipes/abseil/all/CMakeLists.txt deleted file mode 100644 index 8bdaa1e47bfa0..0000000000000 --- a/recipes/abseil/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/abseil/all/abi_trick/abi.h.in b/recipes/abseil/all/abi_trick/abi.h.in new file mode 100644 index 0000000000000..ea1ab395976cb --- /dev/null +++ b/recipes/abseil/all/abi_trick/abi.h.in @@ -0,0 +1,5 @@ +#cmakedefine01 USE_STD_STRING_VIEW +#cmakedefine01 USE_STD_ANY +#cmakedefine01 USE_STD_OPTIONAL +#cmakedefine01 USE_STD_VARIANT + diff --git a/recipes/abseil/all/abi_trick/conan_abi_test.cmake b/recipes/abseil/all/abi_trick/conan_abi_test.cmake new file mode 100644 index 0000000000000..cebf60c355a8d --- /dev/null +++ b/recipes/abseil/all/abi_trick/conan_abi_test.cmake @@ -0,0 +1,44 @@ +get_target_property(ABSL_INCLUDES absl::config INTERFACE_INCLUDE_DIRECTORIES) +set(CMAKE_REQUIRED_INCLUDES ${ABSL_INCLUDES}) + +check_cxx_source_compiles(" +#include \"absl/base/config.h\" +#if defined(ABSL_HAVE_STD_STRING_VIEW) && ABSL_HAVE_STD_STRING_VIEW == 1 +int main() {} +#else +#error \"no std::string_view\" +#endif +" +USE_STD_STRING_VIEW) + +check_cxx_source_compiles(" +#include \"absl/base/config.h\" +#if defined(ABSL_HAVE_STD_ANY) && ABSL_HAVE_STD_ANY == 1 +int main() {} +#else +#error \"no std::any\" +#endif +" +USE_STD_ANY) + +check_cxx_source_compiles(" +#include \"absl/base/config.h\" +#if defined(ABSL_HAVE_STD_OPTIONAL) && ABSL_HAVE_STD_OPTIONAL == 1 +int main() {} +#else +#error \"no std::optional\" +#endif +" +USE_STD_OPTIONAL) + +check_cxx_source_compiles(" +#include \"absl/base/config.h\" +#if defined(ABSL_HAVE_STD_VARIANT) && ABSL_HAVE_STD_VARIANT == 1 +int main() {} +#else +#error \"no std::variant\" +#endif +" +USE_STD_VARIANT) + +configure_file(${CMAKE_CURRENT_LIST_DIR}/abi.h.in ${PROJECT_BINARY_DIR}/abi.h) diff --git a/recipes/abseil/all/conandata.yml b/recipes/abseil/all/conandata.yml index 3911ef26dd89d..854838a18a2e8 100644 --- a/recipes/abseil/all/conandata.yml +++ b/recipes/abseil/all/conandata.yml @@ -1,38 +1,45 @@ sources: - "20200205": - sha256: 3c554df4909c5c55a6d251f6eadc2c78ff20db5ad4471fd9cbf8085c51b76797 - url: https://github.com/abseil/abseil-cpp/archive/08a7e7bf972c8451855a5022f2faf3d3655db015.tar.gz - "20200225.2": - url: "https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz" - sha256: "f41868f7a938605c92936230081175d1eae87f6ea2c248f41077c8f88316f111" - "20200225.3": - url: "https://github.com/abseil/abseil-cpp/archive/20200225.3.tar.gz" - sha256: "66d4d009050f39c104b03f79bdca9d930c4964016f74bf24867a43fbdbd00d23" - "20200923": - url: "https://github.com/abseil/abseil-cpp/archive/20200923.tar.gz" - sha256: "b3744a4f7a249d5eaf2309daad597631ce77ea62e0fc6abffbab4b4c3dc0fc08" - "20200923.1": - url: "https://github.com/abseil/abseil-cpp/archive/20200923.1.tar.gz" - sha256: "808350c4d7238315717749bab0067a1acd208023d41eaf0c7360f29cc8bc8f21" - "20200923.2": - url: "https://github.com/abseil/abseil-cpp/archive/20200923.2.tar.gz" - sha256: "bf3f13b13a0095d926b25640e060f7e13881bd8a792705dd9e161f3c2b9aa976" + "20220623.1": + url: "https://github.com/abseil/abseil-cpp/archive/20220623.1.tar.gz" + sha256: "91ac87d30cc6d79f9ab974c51874a704de9c2647c40f6932597329a282217ba8" + "20220623.0": + url: "https://github.com/abseil/abseil-cpp/archive/20220623.0.tar.gz" + sha256: "4208129b49006089ba1d6710845a45e31c59b0ab6bff9e5788a87f55c5abd602" + "20211102.0": + url: "https://github.com/abseil/abseil-cpp/archive/20211102.0.tar.gz" + sha256: "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4" + "20210324.2": + url: "https://github.com/abseil/abseil-cpp/archive/20210324.2.tar.gz" + sha256: "59b862f50e710277f8ede96f083a5bb8d7c9595376146838b9580be90374ee1f" "20200923.3": url: "https://github.com/abseil/abseil-cpp/archive/20200923.3.tar.gz" sha256: "ebe2ad1480d27383e4bf4211e2ca2ef312d5e6a09eba869fd2e8a5c5d553ded2" - "20210324.0": - url: "https://github.com/abseil/abseil-cpp/archive/refs/tags/20210324.0.tar.gz" - sha256: "dd7db6815204c2a62a2160e32c55e97113b0a0178b2f090d6bab5ce36111db4b" - "20210324.1": - url: "https://github.com/abseil/abseil-cpp/archive/refs/tags/20210324.1.tar.gz" - sha256: "441db7c09a0565376ecacf0085b2d4c2bbedde6115d7773551bc116212c2a8d6" + "20200225.3": + url: "https://github.com/abseil/abseil-cpp/archive/20200225.3.tar.gz" + sha256: "66d4d009050f39c104b03f79bdca9d930c4964016f74bf24867a43fbdbd00d23" patches: - "20200205": - - patch_file: "patches/cmake-install.patch" - base_path: "source_subfolder" - "20200225.2": - - patch_file: "patches/cmake-install.patch" - base_path: "source_subfolder" + "20220623.1": + - patch_file: "patches/0003-absl-string-libm.patch" + - patch_file: "patches/0005-has-unique-object-representations.patch" + patch_description: "Workaround bug in GCC 7.2" + patch_source: "https://github.com/abseil/abseil-cpp/pull/1250" + patch_type: "portability" + "20220623.0": + - patch_file: "patches/0003-absl-string-libm.patch" + - patch_file: "patches/0005-has-unique-object-representations.patch" + patch_description: "Workaround bug in GCC 7.2" + patch_source: "https://github.com/abseil/abseil-cpp/pull/1250" + patch_type: "portability" + "20211102.0": + - patch_file: "patches/0003-absl-string-libm.patch" + "20210324.2": + - patch_file: "patches/0003-absl-string-libm.patch" + - patch_file: "patches/0004-cpp-standard-20210324.patch" + "20200923.3": + - patch_file: "patches/0003-absl-string-libm.patch" + - patch_file: "patches/0004-cpp-standard-20200923.patch" "20200225.3": - - patch_file: "patches/cmake-install.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-cmake-install.patch" + - patch_file: "patches/0002-missing-numeric_limits.h.patch" + - patch_file: "patches/0003-absl-string-libm.patch" + - patch_file: "patches/0004-cpp-standard-20200225.patch" diff --git a/recipes/abseil/all/conanfile.py b/recipes/abseil/all/conanfile.py index 770bb400c5e0b..28ebfb4eb5aa3 100644 --- a/recipes/abseil/all/conanfile.py +++ b/recipes/abseil/all/conanfile.py @@ -1,80 +1,129 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import check_min_cppstd, cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, load, replace_in_file, rmdir, save +from conan.tools.microsoft import is_msvc import json import os import re +import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.51.3" -class ConanRecipe(ConanFile): +class AbseilConan(ConanFile): name = "abseil" - description = "Abseil Common Libraries (C++) from Google" topics = ("algorithm", "container", "google", "common", "utility") - homepage = "https://github.com/abseil/abseil-cpp" url = "https://github.com/conan-io/conan-center-index" - license = "Apache-2.0" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - short_paths = True - settings = "os", "arch", "compiler", "build_type" - options = {"fPIC": [True, False]} - default_options = {"fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - _cmake = None + short_paths = True - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + copy(self, "abi_trick/*", self.recipe_folder, self.export_sources_folder) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + if self.info.options.shared and is_msvc(self): + # upstream tries its best to export symbols, but it's broken for the moment + raise ConanInvalidConfiguration("abseil shared not availabe for Visual Studio (yet)") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - if not self.settings.compiler.cppstd: - self._cmake.definitions["CMAKE_CXX_STANDARD"] = 11 - self._cmake.definitions["ABSL_ENABLE_INSTALL"] = True - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ABSL_ENABLE_INSTALL"] = True + tc.variables["ABSL_PROPAGATE_CXX_STD"] = True + tc.variables["BUILD_TESTING"] = False + # We force CMP0067 policy to NEW for our abi trick in _patch_sources() + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0067"] = "NEW" + if is_msvc(self): + # see https://github.com/abseil/abseil-cpp/issues/649 + tc.preprocessor_definitions["_HAS_DEPRECATED_RESULT_OF"] = 1 + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + # In case of cross-build, set CMAKE_SYSTEM_PROCESSOR if not set by toolchain or user + if cross_building(self): + toolchain_file = os.path.join(self.generators_folder, "conan_toolchain.cmake") + cmake_system_processor_block = textwrap.dedent("""\ + if(NOT CMAKE_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR {}) + endif() + """.format(str(self.settings.arch))) + save(self, toolchain_file, cmake_system_processor_block, append=True) + + # Trick to capture ABI + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + abi_trick_block = textwrap.dedent("""\ + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../abi_trick") + include(conan_abi_test) + """) + save(self, cmakelists, abi_trick_block, append=True) def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure() + abi_file = _ABIFile(self, os.path.join(self.build_folder, "abi.h")) + abi_file.replace_in_options_file(os.path.join(self.source_folder, "absl", "base", "options.h")) cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + # Load components hierarchy before removing CMake files generated by abseil installation cmake_folder = os.path.join(self.package_folder, "lib", "cmake") - self._create_components_file_from_cmake_target_file(os.path.join(cmake_folder, "absl", "abslTargets.cmake")) - tools.rmdir(cmake_folder) + absl_targets_file = os.path.join(cmake_folder, "absl", "abslTargets.cmake") + components = self._load_components_from_cmake_target_file(absl_targets_file) + rmdir(self, cmake_folder) + + # Create a json helper file in order to populate package_info() at consume time + self._create_components_file(self._components_helper_filepath, components) - def _create_components_file_from_cmake_target_file(self, absl_target_file_path): + # Create a build-module that will propagate the required cxx_std to consumers of this recipe's targets + # TODO: Revisit with feedback from https://github.com/conan-io/conan/issues/10281 + self._create_cxx_std_module_file(self._cxx_std_module_filepath, components) + + def _load_components_from_cmake_target_file(self, absl_target_file_path): components = {} - abs_target_file = open(absl_target_file_path, "r") - abs_target_content = abs_target_file.read() - abs_target_file.close() + abs_target_content = load(self, absl_target_file_path) cmake_functions = re.findall(r"(?Padd_library|set_target_properties)[\n|\s]*\([\n|\s]*(?P[^)]*)\)", abs_target_content) for (cmake_function_name, cmake_function_args) in cmake_functions: @@ -89,7 +138,7 @@ def _create_components_file_from_cmake_target_file(self, absl_target_file_path): if cmake_function_name == "add_library": cmake_imported_target_type = cmake_function_args[1] if cmake_imported_target_type in ["STATIC", "SHARED"]: - components[potential_lib_name]["libs"] = [potential_lib_name] + components[potential_lib_name]["libs"] = [potential_lib_name] if cmake_target_nonamespace != "abseil_dll" else [] elif cmake_function_name == "set_target_properties": target_properties = re.findall(r"(?PINTERFACE_COMPILE_DEFINITIONS|INTERFACE_INCLUDE_DIRECTORIES|INTERFACE_LINK_LIBRARIES)[\n|\s]+(?P.+)", cmake_function_args[2]) for target_property in target_properties: @@ -100,16 +149,18 @@ def _create_components_file_from_cmake_target_file(self, absl_target_file_path): if dependency.startswith("absl::"): # abseil targets components[potential_lib_name].setdefault("requires", []).append(dependency.replace("absl::", "absl_")) else: # system libs or frameworks - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: if dependency == "Threads::Threads": components[potential_lib_name].setdefault("system_libs", []).append("pthread") + elif "-lm" in dependency: + components[potential_lib_name].setdefault("system_libs", []).append("m") elif "-lrt" in dependency: components[potential_lib_name].setdefault("system_libs", []).append("rt") elif self.settings.os == "Windows": for system_lib in ["bcrypt", "advapi32", "dbghelp"]: if system_lib in dependency: components[potential_lib_name].setdefault("system_libs", []).append(system_lib) - elif self.settings.os == "Macos": + elif is_apple_os(self): for framework in ["CoreFoundation"]: if framework in dependency: components[potential_lib_name].setdefault("frameworks", []).append(framework) @@ -118,30 +169,76 @@ def _create_components_file_from_cmake_target_file(self, absl_target_file_path): for definition in values_list: components[potential_lib_name].setdefault("defines", []).append(definition) - # Save components informations in json file - with open(self._components_helper_filepath, "w") as json_file: - json.dump(components, json_file, indent=4) + return components + + def _create_components_file(self, output_file, components): + content = json.dumps(components, indent=4) + save(self, output_file, content) @property def _components_helper_filepath(self): return os.path.join(self.package_folder, "lib", "components.json") + def _create_cxx_std_module_file(self, output_file, components): + content = "" + cxx_std_required = _ABIFile(self, os.path.join(self.build_folder, "abi.h")).cxx_std() + for _, values in components.items(): + cmake_target = values["cmake_target"] + content += f"target_compile_features(absl::{cmake_target} INTERFACE cxx_std_{cxx_std_required})\n" + save(self, output_file, content) + + @property + def _cxx_std_module_filepath(self): + return os.path.join(self.package_folder, "lib", "cmake", "conan_trick", "cxx_std.cmake") + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "absl") + + components_json_file = load(self, self._components_helper_filepath) + abseil_components = json.loads(components_json_file) + for pkgconfig_name, values in abseil_components.items(): + cmake_target = values["cmake_target"] + self.cpp_info.components[pkgconfig_name].set_property("cmake_target_name", "absl::{}".format(cmake_target)) + self.cpp_info.components[pkgconfig_name].set_property("pkg_config_name", pkgconfig_name) + self.cpp_info.components[pkgconfig_name].libs = values.get("libs", []) + self.cpp_info.components[pkgconfig_name].defines = values.get("defines", []) + self.cpp_info.components[pkgconfig_name].system_libs = values.get("system_libs", []) + self.cpp_info.components[pkgconfig_name].frameworks = values.get("frameworks", []) + self.cpp_info.components[pkgconfig_name].requires = values.get("requires", []) + if is_msvc(self) and self.settings.compiler.get_safe("cppstd") == "20": + self.cpp_info.components[pkgconfig_name].defines.extend([ + "_HAS_DEPRECATED_RESULT_OF", + "_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING", + ]) + + self.cpp_info.components[pkgconfig_name].names["cmake_find_package"] = cmake_target + self.cpp_info.components[pkgconfig_name].names["cmake_find_package_multi"] = cmake_target + self.cpp_info.names["cmake_find_package"] = "absl" self.cpp_info.names["cmake_find_package_multi"] = "absl" - def _register_components(): - components_json_file = tools.load(self._components_helper_filepath) - abseil_components = json.loads(components_json_file) - for pkgconfig_name, values in abseil_components.items(): - cmake_target = values["cmake_target"] - self.cpp_info.components[pkgconfig_name].names["cmake_find_package"] = cmake_target - self.cpp_info.components[pkgconfig_name].names["cmake_find_package_multi"] = cmake_target - self.cpp_info.components[pkgconfig_name].names["pkg_config"] = pkgconfig_name - self.cpp_info.components[pkgconfig_name].libs = values.get("libs", []) - self.cpp_info.components[pkgconfig_name].defines = values.get("defines", []) - self.cpp_info.components[pkgconfig_name].system_libs = values.get("system_libs", []) - self.cpp_info.components[pkgconfig_name].frameworks = values.get("frameworks", []) - self.cpp_info.components[pkgconfig_name].requires = values.get("requires", []) - - _register_components() + self.cpp_info.set_property("cmake_build_modules", [self._cxx_std_module_filepath]) + self.cpp_info.components["absl_config"].build_modules["cmake_find_package"] = [self._cxx_std_module_filepath] + self.cpp_info.components["absl_config"].build_modules["cmake_find_package_multi"] = [self._cxx_std_module_filepath] + + +class _ABIFile: + abi = {} + + def __init__(self, conanfile, filepath): + self.conanfile = conanfile + abi_h = load(self.conanfile, filepath) + for line in abi_h.splitlines(): + if line.startswith("#define"): + tokens = line.split() + if len(tokens) == 3: + self.abi[tokens[1]] = tokens[2] + + def replace_in_options_file(self, options_filepath): + for name, value in self.abi.items(): + replace_in_file(self.conanfile, options_filepath, + "#define ABSL_OPTION_{} 2".format(name), + "#define ABSL_OPTION_{} {}".format(name, value)) + + def cxx_std(self): + return 17 if any([v == "1" for k, v in self.abi.items()]) else 11 diff --git a/recipes/abseil/all/patches/0001-cmake-install.patch b/recipes/abseil/all/patches/0001-cmake-install.patch new file mode 100644 index 0000000000000..a3b8fb54c4699 --- /dev/null +++ b/recipes/abseil/all/patches/0001-cmake-install.patch @@ -0,0 +1,14 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -41,9 +41,9 @@ + # when absl is included as subproject (i.e. using add_subdirectory(abseil-cpp)) + # in the source tree of a project that uses it, install rules are disabled. + if(NOT "^${CMAKE_SOURCE_DIR}$" STREQUAL "^${PROJECT_SOURCE_DIR}$") +- set(ABSL_ENABLE_INSTALL FALSE) ++ option(ABSL_ENABLE_INSTALL "Enable install rule" OFF) + else() +- set(ABSL_ENABLE_INSTALL TRUE) ++ option(ABSL_ENABLE_INSTALL "Enable install rule" ON) + endif() + + list(APPEND CMAKE_MODULE_PATH diff --git a/recipes/abseil/all/patches/0002-missing-numeric_limits.h.patch b/recipes/abseil/all/patches/0002-missing-numeric_limits.h.patch new file mode 100644 index 0000000000000..b21d60b80ba1b --- /dev/null +++ b/recipes/abseil/all/patches/0002-missing-numeric_limits.h.patch @@ -0,0 +1,11 @@ +--- absl/synchronization/internal/graphcycles.cc ++++ absl/synchronization/internal/graphcycles.cc +@@ -34,7 +34,7 @@ + #ifndef ABSL_LOW_LEVEL_ALLOC_MISSING + + #include "absl/synchronization/internal/graphcycles.h" +- ++#include + #include + #include + #include "absl/base/internal/hide_ptr.h" diff --git a/recipes/abseil/all/patches/0003-absl-string-libm.patch b/recipes/abseil/all/patches/0003-absl-string-libm.patch new file mode 100644 index 0000000000000..8c69d423c871f --- /dev/null +++ b/recipes/abseil/all/patches/0003-absl-string-libm.patch @@ -0,0 +1,15 @@ +--- a/absl/strings/CMakeLists.txt ++++ b/absl/strings/CMakeLists.txt +@@ -14,9 +14,12 @@ + # limitations under the License. + # + ++find_library(LIBM m) + absl_cc_library( + NAME + strings ++ LINKOPTS ++ $<$:-lm> + HDRS + "ascii.h" + "charconv.h" diff --git a/recipes/abseil/all/patches/0004-cpp-standard-20200225.patch b/recipes/abseil/all/patches/0004-cpp-standard-20200225.patch new file mode 100644 index 0000000000000..00042089d1476 --- /dev/null +++ b/recipes/abseil/all/patches/0004-cpp-standard-20200225.patch @@ -0,0 +1,15 @@ +--- a/CMake/AbseilHelpers.cmake ++++ b/CMake/AbseilHelpers.cmake +@@ -204,8 +204,12 @@ function(absl_cc_library) + endif() + + # INTERFACE libraries can't have the CXX_STANDARD property set ++ if(ABSL_PROPAGATE_CXX_STD) ++ target_compile_features(${_NAME} PUBLIC cxx_std_11) ++ else() + set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD}) + set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) ++ endif() + + # When being installed, we lose the absl_ prefix. We want to put it back + # to have properly named lib files. This is a no-op when we are not being diff --git a/recipes/abseil/all/patches/0004-cpp-standard-20200923.patch b/recipes/abseil/all/patches/0004-cpp-standard-20200923.patch new file mode 100644 index 0000000000000..cabbdbc8eaa57 --- /dev/null +++ b/recipes/abseil/all/patches/0004-cpp-standard-20200923.patch @@ -0,0 +1,15 @@ +--- a/CMake/AbseilHelpers.cmake ++++ b/CMake/AbseilHelpers.cmake +@@ -206,8 +206,12 @@ function(absl_cc_library) + endif() + + # INTERFACE libraries can't have the CXX_STANDARD property set ++ if(ABSL_PROPAGATE_CXX_STD) ++ target_compile_features(${_NAME} PUBLIC cxx_std_11) ++ else() + set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD}) + set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) ++ endif() + + # When being installed, we lose the absl_ prefix. We want to put it back + # to have properly named lib files. This is a no-op when we are not being diff --git a/recipes/abseil/all/patches/0004-cpp-standard-20210324.patch b/recipes/abseil/all/patches/0004-cpp-standard-20210324.patch new file mode 100644 index 0000000000000..fab934c4ee8b8 --- /dev/null +++ b/recipes/abseil/all/patches/0004-cpp-standard-20210324.patch @@ -0,0 +1,15 @@ +--- a/CMake/AbseilHelpers.cmake ++++ b/CMake/AbseilHelpers.cmake +@@ -254,8 +254,12 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n") + endif() + + # INTERFACE libraries can't have the CXX_STANDARD property set ++ if(ABSL_PROPAGATE_CXX_STD) ++ target_compile_features(${_NAME} PUBLIC cxx_std_11) ++ else() + set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD}) + set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) ++ endif() + + # When being installed, we lose the absl_ prefix. We want to put it back + # to have properly named lib files. This is a no-op when we are not being diff --git a/recipes/abseil/all/patches/0005-has-unique-object-representations.patch b/recipes/abseil/all/patches/0005-has-unique-object-representations.patch new file mode 100644 index 0000000000000..2a8dffe536382 --- /dev/null +++ b/recipes/abseil/all/patches/0005-has-unique-object-representations.patch @@ -0,0 +1,11 @@ +--- a/absl/hash/internal/hash.h 2022-06-24 06:22:47.000000000 +1200 ++++ b/absl/hash/internal/hash.h 2022-07-28 17:00:02.241173356 +1200 +@@ -444,7 +444,7 @@ + // On other platforms, we assume that pointers-to-members do not have + // padding. + #ifdef __cpp_lib_has_unique_object_representations +- static_assert(std::has_unique_object_representations_v); ++ static_assert(std::has_unique_object_representations::value); + #endif // __cpp_lib_has_unique_object_representations + return n; + #endif diff --git a/recipes/abseil/all/patches/cmake-install.patch b/recipes/abseil/all/patches/cmake-install.patch deleted file mode 100644 index 3c5a3706e17ad..0000000000000 --- a/recipes/abseil/all/patches/cmake-install.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -41,9 +41,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - # when absl is included as subproject (i.e. using add_subdirectory(abseil-cpp)) - # in the source tree of a project that uses it, install rules are disabled. - if(NOT "^${CMAKE_SOURCE_DIR}$" STREQUAL "^${PROJECT_SOURCE_DIR}$") -- set(ABSL_ENABLE_INSTALL FALSE) -+ option(ABSL_ENABLE_INSTALL "Enable install rule" OFF) - else() -- set(ABSL_ENABLE_INSTALL TRUE) -+ option(ABSL_ENABLE_INSTALL "Enable install rule" ON) - endif() - - list(APPEND CMAKE_MODULE_PATH diff --git a/recipes/abseil/all/test_package/CMakeLists.txt b/recipes/abseil/all/test_package/CMakeLists.txt index 71e49b2dc0b2c..04ceb34a1e4bd 100644 --- a/recipes/abseil/all/test_package/CMakeLists.txt +++ b/recipes/abseil/all/test_package/CMakeLists.txt @@ -1,16 +1,38 @@ -cmake_minimum_required(VERSION 3.1.0) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +find_package(absl REQUIRED CONFIG) # Test components -find_package(absl REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) -# Test also global target +if(cxx_std_14 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + add_executable(${PROJECT_NAME}_14 test_package.cpp) + target_link_libraries(${PROJECT_NAME}_14 PRIVATE absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) + target_compile_features(${PROJECT_NAME}_14 PRIVATE cxx_std_14) +endif() +if(cxx_std_17 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + add_executable(${PROJECT_NAME}_17 test_package.cpp) + target_link_libraries(${PROJECT_NAME}_17 PRIVATE absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) + target_compile_features(${PROJECT_NAME}_17 PRIVATE cxx_std_17) +endif() +# old abseil used std::result_of (which was removed in C++20) https://github.com/abseil/abseil-cpp/issues/649 +if(CXX20_SUPPORTED) + if(cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + add_executable(${PROJECT_NAME}_20 test_package.cpp) + target_link_libraries(${PROJECT_NAME}_20 PRIVATE absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) + target_compile_features(${PROJECT_NAME}_20 PRIVATE cxx_std_20) + endif() + if(cxx_std_23 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + add_executable(${PROJECT_NAME}_23 test_package.cpp) + target_link_libraries(${PROJECT_NAME}_23 PRIVATE absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) + target_compile_features(${PROJECT_NAME}_23 PRIVATE cxx_std_23) + endif() +endif() + +# Test also (unofficial) global target add_executable(${PROJECT_NAME}_global test_package.cpp) -target_link_libraries(${PROJECT_NAME}_global CONAN_PKG::abseil) -set_property(TARGET ${PROJECT_NAME}_global PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME}_global PRIVATE abseil::abseil) +target_compile_features(${PROJECT_NAME}_global PRIVATE cxx_std_11) diff --git a/recipes/abseil/all/test_package/conanfile.py b/recipes/abseil/all/test_package/conanfile.py index 517a673f756cc..eab050e1bc9ef 100644 --- a/recipes/abseil/all/test_package/conanfile.py +++ b/recipes/abseil/all/test_package/conanfile.py @@ -1,9 +1,24 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.scm import Version import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CXX20_SUPPORTED"] = Version(self.dependencies["abseil"].ref.version) > "20210324.2" + tc.generate() def build(self): cmake = CMake(self) @@ -11,8 +26,8 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run("%s -s" % bin_path, run_environment=True) - bin_global_path = os.path.join("bin", "test_package_global") - self.run("%s -s" % bin_global_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(f"{bin_path} -s", env="conanrun") + bin_global_path = os.path.join(self.cpp.build.bindirs[0], "test_package_global") + self.run(f"{bin_global_path} -s", env="conanrun") diff --git a/recipes/abseil/all/test_package/test_package.cpp b/recipes/abseil/all/test_package/test_package.cpp index 0cdc47cb3c724..b3813a81e4e81 100644 --- a/recipes/abseil/all/test_package/test_package.cpp +++ b/recipes/abseil/all/test_package/test_package.cpp @@ -9,6 +9,7 @@ #include "absl/container/flat_hash_set.h" #include "absl/numeric/int128.h" #include "absl/time/time.h" +#include "absl/types/variant.h" int main() { @@ -46,4 +47,10 @@ int main() absl::Time t1 = absl::Now(); absl::Time t2 = absl::Time(); absl::Time t3 = absl::UnixEpoch(); + + absl::variant v1 = absl::variant(); + absl::bad_variant_access e1; + + std::string const year = absl::FormatTime("%Y", absl::Now(), absl::UTCTimeZone()); + std::cout << "year " << year << std::endl; } diff --git a/recipes/abseil/all/test_v1_package/CMakeLists.txt b/recipes/abseil/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..fe7c8fa13bf23 --- /dev/null +++ b/recipes/abseil/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(absl REQUIRED CONFIG) + +# Test components +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +if(cxx_std_14 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + add_executable(${PROJECT_NAME}_14 ../test_package/test_package.cpp) + target_link_libraries(${PROJECT_NAME}_14 PRIVATE absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) + target_compile_features(${PROJECT_NAME}_14 PRIVATE cxx_std_14) +endif() +if(cxx_std_17 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + add_executable(${PROJECT_NAME}_17 ../test_package/test_package.cpp) + target_link_libraries(${PROJECT_NAME}_17 PRIVATE absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) + target_compile_features(${PROJECT_NAME}_17 PRIVATE cxx_std_17) +endif() +# old abseil used std::result_of (which was removed in C++20) https://github.com/abseil/abseil-cpp/issues/649 +if(CXX20_SUPPORTED) + if(cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + add_executable(${PROJECT_NAME}_20 ../test_package/test_package.cpp) + target_link_libraries(${PROJECT_NAME}_20 PRIVATE absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) + target_compile_features(${PROJECT_NAME}_20 PRIVATE cxx_std_20) + endif() + if(cxx_std_23 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + add_executable(${PROJECT_NAME}_23 ../test_package/test_package.cpp) + target_link_libraries(${PROJECT_NAME}_23 PRIVATE absl::strings absl::flat_hash_map absl::flat_hash_set absl::int128 absl::time) + target_compile_features(${PROJECT_NAME}_23 PRIVATE cxx_std_23) + endif() +endif() + +# Test also global target +add_executable(${PROJECT_NAME}_global ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME}_global PRIVATE CONAN_PKG::abseil) +target_compile_features(${PROJECT_NAME}_global PRIVATE cxx_std_11) diff --git a/recipes/abseil/all/test_v1_package/conanfile.py b/recipes/abseil/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5c87f554bbab2 --- /dev/null +++ b/recipes/abseil/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["CXX20_SUPPORTED"] = tools.Version(self.deps_cpp_info["abseil"].version) > "20210324.2" + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(f"{bin_path} -s", run_environment=True) + bin_global_path = os.path.join("bin", "test_package_global") + self.run(f"{bin_global_path} -s", run_environment=True) diff --git a/recipes/abseil/config.yml b/recipes/abseil/config.yml index 2db2d35a22269..450d16d77019e 100644 --- a/recipes/abseil/config.yml +++ b/recipes/abseil/config.yml @@ -1,19 +1,13 @@ versions: - "20200205": + "20220623.1": folder: all - "20200225.2": + "20220623.0": folder: all - "20200225.3": - folder: all - "20200923": - folder: all - "20200923.1": + "20211102.0": folder: all - "20200923.2": + "20210324.2": folder: all "20200923.3": folder: all - "20210324.0": - folder: all - "20210324.1": + "20200225.3": folder: all diff --git a/recipes/absent/all/conandata.yml b/recipes/absent/all/conandata.yml index 5ab6cfbf7848a..474b5d79c89ae 100644 --- a/recipes/absent/all/conandata.yml +++ b/recipes/absent/all/conandata.yml @@ -1,16 +1,16 @@ sources: - "0.0.1": - sha256: 4fa1e40cc06c2147f5308e63f51a8785fcc41515b6a6a7c280459d005f1c0aeb - url: https://github.com/rvarago/absent/archive/0.0.1.tar.gz - "0.1.0": - sha256: 32be167191d695f7663cd6043b226c83798aeb617504ad6c82ddf3b3fdb08498 - url: https://github.com/rvarago/absent/archive/0.1.0.tar.gz - "0.2.0": - sha256: f3a587f1a5bdd74e4363378201e56c362830a62f0f92f1872038e71b7a1462c7 - url: https://github.com/rvarago/absent/archive/0.2.0.tar.gz - "0.3.0": - sha256: ac6d1b9cc2e57318eab1252bf5aa13c7bac25e316285a687c61dfdfa71e71e8d - url: https://github.com/rvarago/absent/archive/0.3.0.tar.gz "0.3.1": - sha256: fe0a96303c6438f1095273b093e56c8f10a3b79dea86676b59aec94e6ed89224 - url: https://github.com/rvarago/absent/archive/0.3.1.tar.gz + url: "https://github.com/rvarago/absent/archive/0.3.1.tar.gz" + sha256: "fe0a96303c6438f1095273b093e56c8f10a3b79dea86676b59aec94e6ed89224" + "0.3.0": + url: "https://github.com/rvarago/absent/archive/0.3.0.tar.gz" + sha256: "ac6d1b9cc2e57318eab1252bf5aa13c7bac25e316285a687c61dfdfa71e71e8d" + "0.2.0": + url: "https://github.com/rvarago/absent/archive/0.2.0.tar.gz" + sha256: "f3a587f1a5bdd74e4363378201e56c362830a62f0f92f1872038e71b7a1462c7" + "0.1.0": + url: "https://github.com/rvarago/absent/archive/0.1.0.tar.gz" + sha256: "32be167191d695f7663cd6043b226c83798aeb617504ad6c82ddf3b3fdb08498" + "0.0.1": + url: "https://github.com/rvarago/absent/archive/0.0.1.tar.gz" + sha256: "4fa1e40cc06c2147f5308e63f51a8785fcc41515b6a6a7c280459d005f1c0aeb" diff --git a/recipes/absent/all/conanfile.py b/recipes/absent/all/conanfile.py index 1e7a9d0acb314..bdc5f5e18836b 100644 --- a/recipes/absent/all/conanfile.py +++ b/recipes/absent/all/conanfile.py @@ -2,48 +2,64 @@ from conans.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.43.0" + class AbsentConan(ConanFile): name = "absent" - description = "A small C++17 library meant to simplify the composition of nullable types in a generic, type-safe, and declarative way" + description = ( + "A small C++17 library meant to simplify the composition of nullable " + "types in a generic, type-safe, and declarative way" + ) homepage = "https://github.com/rvarago/absent" url = "https://github.com/conan-io/conan-center-index" license = "MIT" topics = ("nullable-types", "composition", "monadic-interface", "declarative-programming") no_copy_source = True - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" generators = "cmake" @property def _source_subfolder(self): return "source_subfolder" - def _supports_cpp17(self): - supported_compilers = [("gcc", "7"), ("clang", "5"), ("apple-clang", "10"), ("Visual Studio", "15.7")] - compiler = self.settings.compiler - version = tools.Version(compiler.version) - return any(compiler == sc[0] and version >= sc[1] for sc in supported_compilers) - - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["BUILD_TESTS"] = "OFF" - cmake.configure(source_folder=self._source_subfolder) - return cmake + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "clang": "5", + "apple-clang": "10", + "Visual Studio": "15.7", + } - def configure(self): + def validate(self): if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, "17") - elif not self._supports_cpp17(): - raise ConanInvalidConfiguration("Absent requires C++17 support") + + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + "{} requires C++17, which your compiler does not support.".format(self.name) + ) def package_id(self): self.info.header_only() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_TESTS"] = "OFF" + cmake.configure(source_folder=self._source_subfolder) + return cmake def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) @@ -52,9 +68,19 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "absent") + self.cpp_info.set_property("cmake_target_name", "rvarago::absent") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["absentlib"].bindirs = [] + self.cpp_info.components["absentlib"].frameworkdirs = [] + self.cpp_info.components["absentlib"].libdirs = [] + self.cpp_info.components["absentlib"].resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.filenames["cmake_find_package"] = "absent" self.cpp_info.filenames["cmake_find_package_multi"] = "absent" self.cpp_info.names["cmake_find_package"] = "rvarago" self.cpp_info.names["cmake_find_package_multi"] = "rvarago" self.cpp_info.components["absentlib"].names["cmake_find_package"] = "absent" self.cpp_info.components["absentlib"].names["cmake_find_package_multi"] = "absent" + self.cpp_info.components["absentlib"].set_property("cmake_target_name", "rvarago::absent") diff --git a/recipes/absent/all/test_package/CMakeLists.txt b/recipes/absent/all/test_package/CMakeLists.txt index d53ec3bc47d60..fe998526125cb 100644 --- a/recipes/absent/all/test_package/CMakeLists.txt +++ b/recipes/absent/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.8) project(test_package LANGUAGES CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(absent REQUIRED CONFIG) diff --git a/recipes/absent/all/test_package/conanfile.py b/recipes/absent/all/test_package/conanfile.py index 7e2dfe859bb27..38f4483872d47 100644 --- a/recipes/absent/all/test_package/conanfile.py +++ b/recipes/absent/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/absent/config.yml b/recipes/absent/config.yml index baa7fb144f2b6..4c4c018d5454b 100644 --- a/recipes/absent/config.yml +++ b/recipes/absent/config.yml @@ -1,11 +1,11 @@ versions: - "0.0.1": + "0.3.1": folder: all - "0.1.0": + "0.3.0": folder: all "0.2.0": folder: all - "0.3.0": + "0.1.0": folder: all - "0.3.1": + "0.0.1": folder: all diff --git a/recipes/accellera-uvm-systemc/all/conandata.yml b/recipes/accellera-uvm-systemc/all/conandata.yml new file mode 100644 index 0000000000000..682dede9ac02c --- /dev/null +++ b/recipes/accellera-uvm-systemc/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0-beta4": + url: "https://www.accellera.org/images/downloads/standards/systemc/uvm-systemc-1.0-beta4.tar.gz" + sha256: "7b7d9167ab590204ec3a4aae0626d7103b3af47865311e05a7187396d7628276" diff --git a/recipes/accellera-uvm-systemc/all/conanfile.py b/recipes/accellera-uvm-systemc/all/conanfile.py new file mode 100644 index 0000000000000..98ed0d0f6aa37 --- /dev/null +++ b/recipes/accellera-uvm-systemc/all/conanfile.py @@ -0,0 +1,88 @@ +from conan import ConanFile +from conans import AutoToolsBuildEnvironment +from conan.tools.files import get, rmdir, rm, copy, rename +from conan.tools.scm import Version +from conan.tools.build import check_min_cppstd +from conan.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.50.0" + +class UvmSystemC(ConanFile): + name = "accellera-uvm-systemc" + description = """Universal Verification Methodology for SystemC""" + homepage = "https://systemc.org/about/systemc-verification/uvm-systemc-faq" + url = "https://github.com/conan-io/conan-center-index" + license = "Apache-2.0" + topics = ("systemc", "verification", "tlm", "uvm") + settings = "os", "compiler", "build_type", "arch" + options = { + "fPIC": [True, False], + "shared": [True, False], + } + default_options = { + "fPIC": True, + "shared": False, + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def build_requirements(self): + self.tool_requires("cmake/3.24.0") + self.tool_requires("systemc/2.3.3") + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.os == "Macos": + raise ConanInvalidConfiguration("Macos build not supported") + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("Windows build not yet supported") + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "7": + raise ConanInvalidConfiguration("GCC < version 7 is not supported") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + def build(self): + autotools = AutoToolsBuildEnvironment(self) + args = [f"--with-systemc={self.deps_cpp_info['systemc'].rootpath}"] + if self.options.shared: + args.extend(["--enable-shared", "--disable-static"]) + else: + args.extend(["--enable-static", "--disable-shared"]) + autotools.configure(configure_dir=self._source_subfolder, args=args) + autotools.make() + + def package(self): + copy(self, "LICENSE", src=os.path.join(self.build_folder, self._source_subfolder), dst=os.path.join(self.package_folder, "licenses")) + copy(self, "NOTICE", src=os.path.join(self.build_folder, self._source_subfolder), dst=os.path.join(self.package_folder, "licenses")) + copy(self, "COPYING", src=os.path.join(self.build_folder, self._source_subfolder), dst=os.path.join(self.package_folder, "licenses")) + autotools = AutoToolsBuildEnvironment(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "docs")) + rmdir(self, os.path.join(self.package_folder, "examples")) + rm(self, "AUTHORS", self.package_folder) + rm(self, "COPYING", self.package_folder) + rm(self, "ChangeLog", self.package_folder) + rm(self, "LICENSE", self.package_folder) + rm(self, "NOTICE", self.package_folder) + rm(self, "NEWS", self.package_folder) + rm(self, "RELEASENOTES", self.package_folder) + rm(self, "README", self.package_folder) + rm(self, "INSTALL", self.package_folder) + rename(self, os.path.join(self.package_folder, "lib-linux64"), os.path.join(self.package_folder, "lib")) + rm(self, "libuvm-systemc.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.libs = ["uvm-systemc"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["m"] diff --git a/recipes/accellera-uvm-systemc/all/test_package/CMakeLists.txt b/recipes/accellera-uvm-systemc/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..29a5f29bd6062 --- /dev/null +++ b/recipes/accellera-uvm-systemc/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(accellera-uvm-systemc REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} example.cpp) +target_link_libraries(${PROJECT_NAME} accellera-uvm-systemc::accellera-uvm-systemc) diff --git a/recipes/accellera-uvm-systemc/all/test_package/conanfile.py b/recipes/accellera-uvm-systemc/all/test_package/conanfile.py new file mode 100644 index 0000000000000..7c46504cf008f --- /dev/null +++ b/recipes/accellera-uvm-systemc/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake +from conan.tools.build import cross_building + +class UvmSystemcTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/accellera-uvm-systemc/all/test_package/example.cpp b/recipes/accellera-uvm-systemc/all/test_package/example.cpp new file mode 100644 index 0000000000000..db58543c27400 --- /dev/null +++ b/recipes/accellera-uvm-systemc/all/test_package/example.cpp @@ -0,0 +1,12 @@ +#include "uvmsc/base/uvm_version.h" +#include + +using namespace uvm; + +int main(int, char*[]) +{ + std::cout << "uvm-systemc version " << uvm_revision_string() << " loaded successfully."; + + return 0; +} + diff --git a/recipes/accellera-uvm-systemc/config.yml b/recipes/accellera-uvm-systemc/config.yml new file mode 100644 index 0000000000000..da7de76e639d1 --- /dev/null +++ b/recipes/accellera-uvm-systemc/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0-beta4": + folder: "all" diff --git a/recipes/access_private/all/conandata.yml b/recipes/access_private/all/conandata.yml new file mode 100644 index 0000000000000..cb7e88313a5f0 --- /dev/null +++ b/recipes/access_private/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20210621": + url: "https://github.com/martong/access_private/archive/c65d54b17bf7b212cb4df867edf143f2ebb0186a.zip" + sha256: "d4af97cdc5b652b05ae71fb310b98c488e1f987a5e31216e4ec41a6d3c758449" diff --git a/recipes/access_private/all/conanfile.py b/recipes/access_private/all/conanfile.py new file mode 100644 index 0000000000000..da35dc6ea7e6e --- /dev/null +++ b/recipes/access_private/all/conanfile.py @@ -0,0 +1,48 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class AccessPrivateConan(ConanFile): + name = "access_private" + description = "Access private members and statics of a C++ class" + license = "MIT" + topics = ("access", "private", "header-only") + homepage = "https://github.com/martong/access_private" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "access_private.hpp", + src=os.path.join(self.source_folder, "include"), + dst=os.path.join(self.package_folder, "include", "access_private")) + + def package_info(self): + self.cpp_info.includedirs.append(os.path.join("include", "access_private")) + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/access_private/all/test_package/CMakeLists.txt b/recipes/access_private/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6d981e9b4484e --- /dev/null +++ b/recipes/access_private/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(access_private REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE access_private::access_private) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/access_private/all/test_package/conanfile.py b/recipes/access_private/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/access_private/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/access_private/all/test_package/test_package.cpp b/recipes/access_private/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7c4f5cf312459 --- /dev/null +++ b/recipes/access_private/all/test_package/test_package.cpp @@ -0,0 +1,17 @@ +#include + +class A { + int m_i = 3; +}; + +ACCESS_PRIVATE_FIELD(A, int, m_i) + +int main() +{ + const A a; + const int val = access_private::m_i(a); + if (val == 3) { + return 0; + } + return -1; +} diff --git a/recipes/access_private/all/test_v1_package/CMakeLists.txt b/recipes/access_private/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..01b3a8050e773 --- /dev/null +++ b/recipes/access_private/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(access_private REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE access_private::access_private) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/access_private/all/test_v1_package/conanfile.py b/recipes/access_private/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/access_private/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/access_private/config.yml b/recipes/access_private/config.yml new file mode 100644 index 0000000000000..e589b8d1685bc --- /dev/null +++ b/recipes/access_private/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210621": + folder: all diff --git a/recipes/acl/all/conandata.yml b/recipes/acl/all/conandata.yml new file mode 100644 index 0000000000000..d7d40a7f305a3 --- /dev/null +++ b/recipes/acl/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.3.1": + url: "http://download.savannah.nongnu.org/releases/acl/acl-2.3.1.tar.xz" + sha256: "C0234042E17F11306C23C038B08E5E070EDB7BE44BEF6697FB8734DCFF1C66B1" diff --git a/recipes/acl/all/conanfile.py b/recipes/acl/all/conanfile.py new file mode 100644 index 0000000000000..c02a3661c6741 --- /dev/null +++ b/recipes/acl/all/conanfile.py @@ -0,0 +1,78 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +import os +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + +class AclConan(ConanFile): + name = "acl" + description = "Commands for Manipulating POSIX Access Control Lists" + topics = ("conan", "acl", "POSIX") + license = "GPL-2.0-or-later" + homepage = "https://savannah.nongnu.org/projects/acl/" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + requires = ["libattr/2.5.1"] + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _doc_folder(self): + return os.path.join( + self._source_subfolder, + "doc" + ) + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("libacl is just supported for Linux") + + def configure(self): + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, + destination=self._source_subfolder) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self) + conf_args = [] + if self.options.shared: + conf_args.extend(["--enable-shared", "--disable-static"]) + else: + conf_args.extend(["--disable-shared", "--enable-static"]) + self._autotools.configure(configure_dir=self._source_subfolder, args=conf_args) + return self._autotools + + def build(self): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + autotools = self._configure_autotools() + autotools.install() + self.copy("COPYING", dst="licenses", src=self._doc_folder) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.names["pkg_config"] = "libacl" + self.cpp_info.libs = ["acl"] diff --git a/recipes/acl/all/test_package/CMakeLists.txt b/recipes/acl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5304f940f246f --- /dev/null +++ b/recipes/acl/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(example C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/acl/all/test_package/conanfile.py b/recipes/acl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0bddc9f2bdfc8 --- /dev/null +++ b/recipes/acl/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/acl/all/test_package/test_package.c b/recipes/acl/all/test_package/test_package.c new file mode 100644 index 0000000000000..7fa01aad7d2b2 --- /dev/null +++ b/recipes/acl/all/test_package/test_package.c @@ -0,0 +1,95 @@ +/* + Copyright (C) 2009 Andreas Gruenbacher + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include +#include +#include +#include +#include + +const char *progname; + +int main(int argc, char *argv[]) +{ + int n, ret = 0; + + progname = basename(argv[0]); + + if (argc == 1) { + printf("%s -- get access control lists of files\n" + "Usage: %s file ...\n", + progname, progname); + return 0; + } + + for (n = 1; n < argc; n++) { + struct stat st; + acl_t acl, default_acl; + char *acl_text, *default_acl_text, *token; + + if (stat(argv[n], &st) != 0) { + fprintf(stderr, "%s: %s: %s\n", + progname, argv[n], strerror(errno)); + ret = 1; + continue; + } + + acl = acl_get_file(argv[n], ACL_TYPE_ACCESS); + if (acl == NULL) { + fprintf(stderr, "%s: getting acl of %s: %s\n", + progname, argv[n], strerror(errno)); + ret = 1; + continue; + } + acl_text = acl_to_text(acl, NULL); + acl_free(acl); + + if (S_ISDIR(st.st_mode)) { + default_acl = acl_get_file(argv[n], ACL_TYPE_DEFAULT); + if (default_acl == NULL) { + acl_free(acl_text); + fprintf(stderr, "%s: getting default acl " + "of %s: %s\n", progname, argv[n], + strerror(errno)); + ret = 1; + continue; + } + default_acl_text = acl_to_text(default_acl, NULL); + acl_free(default_acl); + } + + printf("# file: %s\n" + "# owner: %d\n" + "# group: %d\n" + "%s", + argv[n], st.st_uid, st.st_gid, acl_text); + + if (S_ISDIR(st.st_mode)) { + token = strtok(default_acl_text, "\n"); + while (token) { + printf("default:%s\n", token); + token = strtok(NULL, "\n"); + } + acl_free(default_acl_text); + } + printf("\n"); + + acl_free(acl_text); + } + return ret; +} diff --git a/recipes/acl/config.yml b/recipes/acl/config.yml new file mode 100644 index 0000000000000..215bc57fe4993 --- /dev/null +++ b/recipes/acl/config.yml @@ -0,0 +1,3 @@ +versions: + "2.3.1": + folder: all diff --git a/recipes/ade/all/conandata.yml b/recipes/ade/all/conandata.yml new file mode 100644 index 0000000000000..954c10dfe2c1d --- /dev/null +++ b/recipes/ade/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "0.1.2a": + url: "https://github.com/opencv/ade/archive/refs/tags/v0.1.2a.tar.gz" + sha256: "c022a688b0554017e46e1cbdeb0105e625ca090fc3755c15df8c4451a304e084" + "0.1.1f": + url: "https://github.com/opencv/ade/archive/refs/tags/v0.1.1f.tar.gz" + sha256: "c316680efbb5dd3ac4e10bb8cea345cf26a6a25ebc22418f8f0b8ca931a550e9" diff --git a/recipes/ade/all/conanfile.py b/recipes/ade/all/conanfile.py new file mode 100644 index 0000000000000..7a3013131f30c --- /dev/null +++ b/recipes/ade/all/conanfile.py @@ -0,0 +1,88 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file, rmdir, save +import os +import textwrap + +required_conan_version = ">=1.50.0" + + +class AdeConan(ConanFile): + name = "ade" + license = "Apache-2.0" + homepage = "https://github.com/opencv/ade" + url = "https://github.com/conan-io/conan-center-index" + description = "Graph construction, manipulation, and processing framework" + topics = ("graphs", "opencv") + + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + } + default_options = { + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), " if(UNIX)", " if(UNIX OR CYGWIN OR MINGW OR MSYS)") + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "share")) + + # TODO: to remove in conan v2 once legacy generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"ade": "ade::ade"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "ade") + self.cpp_info.set_property("cmake_target_name", "ade") + self.cpp_info.libs = ["ade"] + if self.settings.os == "Windows" and self.settings.compiler == "gcc": + self.cpp_info.system_libs.append("ssp") + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/ade/all/test_package/CMakeLists.txt b/recipes/ade/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c573b9026dcbc --- /dev/null +++ b/recipes/ade/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(ade REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ade) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/ade/all/test_package/conanfile.py b/recipes/ade/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/ade/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/ade/all/test_package/test_package.cpp b/recipes/ade/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..524d173220d96 --- /dev/null +++ b/recipes/ade/all/test_package/test_package.cpp @@ -0,0 +1,5 @@ +#include "ade/graph.hpp" + +int main() { + ade::Graph graph; +} diff --git a/recipes/ade/all/test_v1_package/CMakeLists.txt b/recipes/ade/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9e81f90ccede3 --- /dev/null +++ b/recipes/ade/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ade REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ade) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/ade/all/test_v1_package/conanfile.py b/recipes/ade/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/ade/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ade/config.yml b/recipes/ade/config.yml new file mode 100644 index 0000000000000..cbf2f373fb630 --- /dev/null +++ b/recipes/ade/config.yml @@ -0,0 +1,5 @@ +versions: + "0.1.2a": + folder: "all" + "0.1.1f": + folder: "all" diff --git a/recipes/aeron/all/conandata.yml b/recipes/aeron/all/conandata.yml index c5c0b382cc0bf..6c6ca05f4d274 100644 --- a/recipes/aeron/all/conandata.yml +++ b/recipes/aeron/all/conandata.yml @@ -1,4 +1,16 @@ sources: + "1.35.1": + url: "https://github.com/real-logic/aeron/archive/1.35.1.tar.gz" + sha256: "19b0f27c2cbc27b422e26a533e4a04a60592217e1c70fdbdd48a92a7b932cccb" + "1.34.0": + url: https://github.com/real-logic/aeron/archive/refs/tags/1.34.0.tar.gz + sha256: "e475f895f0f75654bc7e25e21169d656401f446bf63a03d4efd931deb60246ca" + "1.33.1": + url: https://github.com/real-logic/aeron/archive/refs/tags/1.33.1.tar.gz + sha256: "a4d936ba82d3aefa0342056680790246620f67de4e275fdd07a013dee795233d" + "1.32.0": + url: https://github.com/real-logic/aeron/archive/refs/tags/1.32.0.tar.gz + sha256: "998ca14c895cd154345c85298b7c2e2ef76aef45b10c742030fd3a32065b9b1c" "1.31.2": url: https://github.com/real-logic/aeron/archive/refs/tags/1.31.2.tar.gz sha256: "3edcf01415298aa053cd9e9637405cb8f7b940545bb52a563592dab2b35389ea" diff --git a/recipes/aeron/all/conanfile.py b/recipes/aeron/all/conanfile.py index 0c6323421bf21..a437a1c1fb57a 100644 --- a/recipes/aeron/all/conanfile.py +++ b/recipes/aeron/all/conanfile.py @@ -5,6 +5,9 @@ from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.33.0" + + class AeronConan(ConanFile): name = "aeron" description = "Efficient reliable UDP unicast, UDP multicast, and IPC message transport" @@ -65,11 +68,12 @@ def validate(self): raise ConanInvalidConfiguration( "{} requires {} compiler {} or newer [is: {}]".format(self.name, compiler, minimal_version[compiler], compiler_version) ) + if self.settings.os == "Macos" and self.settings.arch == "armv8": + raise ConanInvalidConfiguration("This platform (os=Macos arch=armv8) is not yet supported by this recipe") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: diff --git a/recipes/aeron/all/test_package/conanfile.py b/recipes/aeron/all/test_package/conanfile.py index 80ba70c7c9cbb..3ee36e2493a5f 100644 --- a/recipes/aeron/all/test_package/conanfile.py +++ b/recipes/aeron/all/test_package/conanfile.py @@ -13,5 +13,4 @@ def build(self): def test(self): if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/aeron/config.yml b/recipes/aeron/config.yml index e47eea05e6ffa..33785dfd3b513 100644 --- a/recipes/aeron/config.yml +++ b/recipes/aeron/config.yml @@ -1,3 +1,11 @@ versions: + "1.35.1": + folder: all + "1.34.0": + folder: all + "1.33.1": + folder: all + "1.32.0": + folder: all "1.31.2": folder: all diff --git a/recipes/ags/all/conandata.yml b/recipes/ags/all/conandata.yml index e0c73eaacf2a6..80c23a11369cc 100644 --- a/recipes/ags/all/conandata.yml +++ b/recipes/ags/all/conandata.yml @@ -5,3 +5,6 @@ sources: "6.0": url: https://github.com/GPUOpen-LibrariesAndSDKs/AGS_SDK/archive/v6.0.tar.gz sha256: 3278ae381b1169f2f70be4412e351a427686cca9728dd6870fbb0c26d8d33b5b + "6.0.1": + url: https://github.com/GPUOpen-LibrariesAndSDKs/AGS_SDK/archive/v6.0.1.tar.gz + sha256: 7827e3c48b09a216b539c70d861e49580d57ae5fb6808f34dcf97067281c2a52 diff --git a/recipes/ags/all/conanfile.py b/recipes/ags/all/conanfile.py index c73cd2e94dcec..ce3253516ac16 100644 --- a/recipes/ags/all/conanfile.py +++ b/recipes/ags/all/conanfile.py @@ -3,6 +3,9 @@ from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.33.0" + + class AGSConan(ConanFile): name = "ags" description = "The AMD GPU Services (AGS) library provides software developers with the ability to query AMD GPU " \ @@ -47,9 +50,8 @@ def configure(self): raise ConanInvalidConfiguration("ags doesn't support arch: {}".format(self.settings.arch)) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "AGS_SDK-{}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _convert_msvc_version_to_vs_version(self, msvc_version): vs_versions = { diff --git a/recipes/ags/all/test_package/CMakeLists.txt b/recipes/ags/all/test_package/CMakeLists.txt index 8567975a6992d..523fab4f02b6a 100644 --- a/recipes/ags/all/test_package/CMakeLists.txt +++ b/recipes/ags/all/test_package/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.1) project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} CONAN_PKG::ags) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) diff --git a/recipes/ags/all/test_package/conanfile.py b/recipes/ags/all/test_package/conanfile.py index a59a26a52c8dc..c08206c505563 100644 --- a/recipes/ags/all/test_package/conanfile.py +++ b/recipes/ags/all/test_package/conanfile.py @@ -13,5 +13,4 @@ def build(self): def test(self): if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/ags/config.yml b/recipes/ags/config.yml index 52e20bc4cf9f7..a799261020b31 100644 --- a/recipes/ags/config.yml +++ b/recipes/ags/config.yml @@ -3,3 +3,5 @@ versions: folder: all "6.0": folder: all + "6.0.1": + folder: all diff --git a/recipes/alac/all/CMakeLists.txt b/recipes/alac/all/CMakeLists.txt new file mode 100644 index 0000000000000..fe2d89ad21170 --- /dev/null +++ b/recipes/alac/all/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.8) +project(alac LANGUAGES C CXX) + +include(GNUInstallDirs) + +file(GLOB ALAC_LIB_SRCS ${ALAC_SRC_DIR}/codec/*.c ${ALAC_SRC_DIR}/codec/*.cpp) +file(GLOB ALAC_LIB_PUBLIC_HDRS ${ALAC_SRC_DIR}/codec/ALAC*.h) + +add_library(alac ${ALAC_LIB_SRCS}) +target_include_directories(alac PUBLIC ${ALAC_SRC_DIR}/codec) +set_property(TARGET alac PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS TRUE) +target_compile_definitions(alac + PRIVATE + $,TARGET_OS_MAC=1,TARGET_OS_MAC=0> +) + +install(FILES ${ALAC_LIB_PUBLIC_HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(TARGETS alac + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +if(ALAC_BUILD_UTILITY) + file(GLOB ALAC_CONVERTER_SRCS ${ALAC_SRC_DIR}/convert-utility/*.cpp) + + add_executable(alacconvert ${ALAC_CONVERTER_SRCS}) + target_link_libraries(alacconvert PRIVATE alac) + target_compile_definitions(alacconvert + PRIVATE + $,TARGET_OS_WIN32=1,TARGET_OS_WIN32=0> + ) + + install(TARGETS alacconvert DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/recipes/alac/all/conandata.yml b/recipes/alac/all/conandata.yml new file mode 100644 index 0000000000000..1645b0ea50086 --- /dev/null +++ b/recipes/alac/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20121212": + url: "https://github.com/macosforge/alac/archive/3814718153165b15b30804f525d3c4e93cf86300.zip" + sha256: "17636c24343e43a6543a0fc513945e331b0bef6d813139e20464316acf4d985d" diff --git a/recipes/alac/all/conanfile.py b/recipes/alac/all/conanfile.py new file mode 100644 index 0000000000000..03e8814c8b1fd --- /dev/null +++ b/recipes/alac/all/conanfile.py @@ -0,0 +1,71 @@ +from conan import ConanFile, conan_version +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.52.0" + + +class AlacConan(ConanFile): + name = "alac" + description = "The Apple Lossless Audio Codec (ALAC) is a lossless audio " \ + "codec developed by Apple and deployed on all of its platforms and devices." + license = "Apache-2.0" + topics = ("alac", "audio-codec") + homepage = "https://macosforge.github.io/alac" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "utility": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "utility": True, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ALAC_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["ALAC_BUILD_UTILITY"] = self.options.utility + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["alac"] + + if Version(conan_version).major < 2 and self.options.utility: + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/alac/all/test_package/CMakeLists.txt b/recipes/alac/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..237396b4c3323 --- /dev/null +++ b/recipes/alac/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(alac REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE alac::alac) diff --git a/recipes/alac/all/test_package/conanfile.py b/recipes/alac/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/alac/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/alac/all/test_package/test_package.cpp b/recipes/alac/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..99c6a42ec8058 --- /dev/null +++ b/recipes/alac/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + ALACEncoder encoder; + return 0; +} diff --git a/recipes/alac/all/test_v1_package/CMakeLists.txt b/recipes/alac/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6e042a1c74181 --- /dev/null +++ b/recipes/alac/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(alac REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE alac::alac) diff --git a/recipes/alac/all/test_v1_package/conanfile.py b/recipes/alac/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/alac/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/alac/config.yml b/recipes/alac/config.yml new file mode 100644 index 0000000000000..f7d9052aae4d6 --- /dev/null +++ b/recipes/alac/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20121212": + folder: all diff --git a/recipes/alembic/all/CMakeLists.txt b/recipes/alembic/all/CMakeLists.txt new file mode 100644 index 0000000000000..6963462d91a16 --- /dev/null +++ b/recipes/alembic/all/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +find_package(OpenEXR REQUIRED) + +add_subdirectory("source_subfolder") diff --git a/recipes/alembic/all/conandata.yml b/recipes/alembic/all/conandata.yml new file mode 100644 index 0000000000000..76ff4d49ed9fe --- /dev/null +++ b/recipes/alembic/all/conandata.yml @@ -0,0 +1,14 @@ +sources: + "1.8.3": + url: "https://github.com/alembic/alembic/archive/1.8.3.tar.gz" + sha256: "b0bc74833bff118a869e81e6acb810a58797e77ef63143954b2f8e817c7f65cb" + "1.8.2": + url: "https://github.com/alembic/alembic/archive/refs/tags/1.8.2.tar.gz" + sha256: "3f1c466ee1600578689b32b1f2587066d3259704ec7ed1fcf80c324d01274f48" +patches: + "1.8.3": + - patch_file: "patches/cmake-compiler-directories-1.8.2.patch" + base_path: "source_subfolder" + "1.8.2": + - patch_file: "patches/cmake-compiler-directories-1.8.2.patch" + base_path: "source_subfolder" diff --git a/recipes/alembic/all/conanfile.py b/recipes/alembic/all/conanfile.py new file mode 100644 index 0000000000000..e03670713f2da --- /dev/null +++ b/recipes/alembic/all/conanfile.py @@ -0,0 +1,106 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.43.0" + + +class AlembicConan(ConanFile): + name = "alembic" + license = "BSD-3-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/alembic/alembic" + description = "Open framework for storing and sharing scene data." + topics = ("3d", "scene", "geometry", "graphics") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_hdf5": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_hdf5": False, + } + + generators = "cmake", "cmake_find_package" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("openexr/2.5.7") + if self.options.with_hdf5: + self.requires("hdf5/1.12.0") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["USE_ARNOLD"] = False + self._cmake.definitions["USE_MAYA"] = False + self._cmake.definitions["USE_PRMAN"] = False + self._cmake.definitions["USE_PYALEMBIC"] = False + self._cmake.definitions["USE_BINARIES"] = False + self._cmake.definitions["USE_EXAMPLES"] = False + self._cmake.definitions["USE_HDF5"] = self.options.with_hdf5 + self._cmake.definitions["USE_TESTS"] = False + self._cmake.definitions["ALEMBIC_BUILD_LIBS"] = True + self._cmake.definitions["ALEMBIC_ILMBASE_LINK_STATIC"] = True # for -DOPENEXR_DLL, handled by OpenEXR package + self._cmake.definitions["ALEMBIC_SHARED_LIBS"] = self.options.shared + self._cmake.definitions["ALEMBIC_USING_IMATH_3"] = False + self._cmake.definitions["ALEMBIC_ILMBASE_FOUND"] = 1 + self._cmake.definitions["ALEMBIC_ILMBASE_LIBS"] = "OpenEXR::OpenEXR" + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses", keep_path=False) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Alembic") + self.cpp_info.set_property("cmake_target_name", "Alembic::Alembic") + self.cpp_info.libs = ["Alembic"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "Alembic" + self.cpp_info.names["cmake_find_package_multi"] = "Alembic" diff --git a/recipes/alembic/all/patches/cmake-compiler-directories-1.8.2.patch b/recipes/alembic/all/patches/cmake-compiler-directories-1.8.2.patch new file mode 100644 index 0000000000000..855dbf19d51cc --- /dev/null +++ b/recipes/alembic/all/patches/cmake-compiler-directories-1.8.2.patch @@ -0,0 +1,67 @@ +diff '--color=auto' -Naur ./CMakeLists.txt ./CMakeLists.txt +--- ./CMakeLists.txt 2021-08-23 14:34:04.141208518 +0300 ++++ ./CMakeLists.txt 2021-08-23 14:42:28.163384280 +0300 +@@ -115,8 +115,8 @@ + + # if not set fall back to VFX reference platform 2018 to 2020 + IF ("${CMAKE_CXX_STANDARD}" STREQUAL "") +- MESSAGE("Defaulting CMAKE_CXX_STANDARD to 14") +- SET(CMAKE_CXX_STANDARD 14) ++ MESSAGE("Defaulting CMAKE_CXX_STANDARD to 11") ++ SET(CMAKE_CXX_STANDARD 11) + SET(CMAKE_CXX_STANDARD_REQUIRED ON) + ENDIF() + +@@ -127,7 +127,7 @@ + + # Set some debug vs opt flags + if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND NOT MSVC) +- add_definitions(-Wall -Werror -Wextra -Wno-unused-parameter -Wno-deprecated) ++ add_definitions(-Wall -Wextra -Wno-unused-parameter -Wno-deprecated) + if((CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0) OR + CMAKE_CXX_COMPILER_ID MATCHES "CLANG") + add_definitions( -Wno-error=implicit-fallthrough) +@@ -210,9 +210,6 @@ + FIND_PACKAGE(Doxygen) + ENDIF() + +-# IlmBase +-INCLUDE("./cmake/AlembicIlmBase.cmake") +- + # HDF5 + IF (USE_HDF5) + FIND_PACKAGE(ZLIB REQUIRED) +@@ -228,7 +225,7 @@ + # Alembic + IF (ALEMBIC_BUILD_LIBS) + ADD_SUBDIRECTORY(lib) +- INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/lib" "${PROJECT_BINARY_DIR}/lib") ++ INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/lib" "${PROJECT_BINARY_DIR}/lib") + ADD_LIBRARY( Alembic::Alembic ALIAS Alembic ) + ELSE() + FIND_PACKAGE(Alembic REQUIRED CONFIG HINTS ${ALEMBIC_ROOT}) +diff '--color=auto' -Naur ./lib/Alembic/CMakeLists.txt ./lib/Alembic/CMakeLists.txt +--- ./lib/Alembic/CMakeLists.txt 2021-08-23 14:34:04.155208355 +0300 ++++ ./lib/Alembic/CMakeLists.txt 2021-08-23 14:43:52.417413762 +0300 +@@ -52,7 +52,7 @@ + + TARGET_INCLUDE_DIRECTORIES(Alembic + PUBLIC +- $ ++ $ + $ + $/include> + ${ALEMBIC_ILMBASE_INCLUDE_DIRECTORY} +@@ -81,9 +81,9 @@ + SET( ALEMBIC_LIB_INSTALL_DIR lib CACHE PATH "Where to install the Alembic libs") + INSTALL(TARGETS Alembic + EXPORT AlembicTargets +- LIBRARY DESTINATION ${ALEMBIC_LIB_INSTALL_DIR} +- ARCHIVE DESTINATION ${ALEMBIC_LIB_INSTALL_DIR} +- RUNTIME DESTINATION ${ALEMBIC_LIB_INSTALL_DIR}) ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + #-****************************************************************************** + # PACKAGE EXPORTS diff --git a/recipes/alembic/all/test_package/CMakeLists.txt b/recipes/alembic/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6bec164e6563c --- /dev/null +++ b/recipes/alembic/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Alembic REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} Alembic::Alembic) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/alembic/all/test_package/conanfile.py b/recipes/alembic/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3da371b660e0a --- /dev/null +++ b/recipes/alembic/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/alembic/all/test_package/test_package.cpp b/recipes/alembic/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..91c73696e1465 --- /dev/null +++ b/recipes/alembic/all/test_package/test_package.cpp @@ -0,0 +1,24 @@ +#include + +#include +#include +#include + +void write() +{ + Alembic::Abc::OArchive archive(Alembic::AbcCoreOgawa::WriteArchive(), "Collection.abc"); + Alembic::Abc::OObject root(archive, Alembic::Abc::kTop); + Alembic::Abc::OObject test(root, "test"); +} + +void read() +{ + Alembic::Abc::IArchive archive(Alembic::AbcCoreOgawa::ReadArchive(), "Collection.abc"); + Alembic::Abc::IObject test(archive.getTop(), "test"); +} + +int main() { + write(); + read(); + return EXIT_SUCCESS; +} diff --git a/recipes/alembic/config.yml b/recipes/alembic/config.yml new file mode 100644 index 0000000000000..68197c279a4ee --- /dev/null +++ b/recipes/alembic/config.yml @@ -0,0 +1,5 @@ +versions: + "1.8.3": + folder: all + "1.8.2": + folder: all diff --git a/recipes/alpaca/all/conandata.yml b/recipes/alpaca/all/conandata.yml new file mode 100644 index 0000000000000..4be0a369c7f9a --- /dev/null +++ b/recipes/alpaca/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.2.1": + url: "https://github.com/p-ranav/alpaca/archive/refs/tags/v0.2.1.tar.gz" + sha256: "05d49a2dc9c6a9e07c0cbc4e26caec273a8666270c82d7c3f0ede4f3a9258f4e" diff --git a/recipes/alpaca/all/conanfile.py b/recipes/alpaca/all/conanfile.py new file mode 100644 index 0000000000000..a7227d4427d29 --- /dev/null +++ b/recipes/alpaca/all/conanfile.py @@ -0,0 +1,69 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import get, copy +from conan.tools.layout import basic_layout +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.scm import Version +import os + + +required_conan_version = ">=1.52.0" + + +class AlpacaConan(ConanFile): + name = "alpaca" + description = "Serialization library written in C++17 - Pack C++ structs into a compact byte-array without any macros or boilerplate code" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/p-ranav/alpaca" + topics = ("reflection", "checksum", "serialization", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8", + "clang": "7", + "apple-clang": "12", + } + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + check_min_vs(self, 192) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy( + self, + pattern="*.h", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include"), + ) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + self.cpp_info.set_property("pkg_config_name", "alpaca") diff --git a/recipes/alpaca/all/test_package/CMakeLists.txt b/recipes/alpaca/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..790a5eaae638a --- /dev/null +++ b/recipes/alpaca/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(alpaca REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE alpaca::alpaca) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/alpaca/all/test_package/conanfile.py b/recipes/alpaca/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e845ae751a301 --- /dev/null +++ b/recipes/alpaca/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/alpaca/all/test_package/test_package.cpp b/recipes/alpaca/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..0134e1d6e0d2d --- /dev/null +++ b/recipes/alpaca/all/test_package/test_package.cpp @@ -0,0 +1,35 @@ +#include + +struct Config { + std::string device; + std::pair resolution; + std::array K_matrix; + std::vector distortion_coeffients; + std::map> parameters; +}; + +int main() { + // Construct the object + Config c{"/dev/video0", {640, 480}, + {223.28249888247538, 0.0, 152.30570853111396, + 0.0, 223.8756535707556, 124.5606000035353, + 0.0, 0.0, 1.0}, + {-0.44158343539568284, 0.23861463831967872, 0.0016338407443826572, + 0.0034950038632981604, -0.05239245892096022}, + {{"start_server", bool{true}}, + {"max_depth", uint16_t{5}}, + {"model_path", std::string{"foo/bar.pt"}}}}; + + // Serialize + std::vector bytes; + auto bytes_written = alpaca::serialize(c, bytes); + + // Deserialize + std::error_code ec; + auto object = alpaca::deserialize(bytes, ec); + if (ec) { + return 1; + } + return 0; +} + diff --git a/recipes/alpaca/all/test_v1_package/CMakeLists.txt b/recipes/alpaca/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0aeb3e1d92584 --- /dev/null +++ b/recipes/alpaca/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) # if the project is pure C +project(test_package LANGUAGES CXX) # if the project uses c++ + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/alpaca/all/test_v1_package/conanfile.py b/recipes/alpaca/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/alpaca/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/alpaca/config.yml b/recipes/alpaca/config.yml new file mode 100644 index 0000000000000..f975c1e3261f7 --- /dev/null +++ b/recipes/alpaca/config.yml @@ -0,0 +1,3 @@ +versions: + "0.2.1": + folder: all diff --git a/recipes/amgcl/all/conandata.yml b/recipes/amgcl/all/conandata.yml new file mode 100644 index 0000000000000..97da314dcfe0d --- /dev/null +++ b/recipes/amgcl/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "1.4.3": + url: "https://github.com/ddemidov/amgcl/archive/1.4.3.tar.gz" + sha256: "e920d5767814ce697d707d1f359a16c9b9eb79eba28fe19e14c18c2a505fe0ad" + "1.4.2": + url: "https://github.com/ddemidov/amgcl/archive/1.4.2.tar.gz" + sha256: "db0de6b75e6c205f44542c3ac8d9935c8357a58072963228d0bb11a54181aea8" + "1.4.0": + url: "https://github.com/ddemidov/amgcl/archive/refs/tags/1.4.0.tar.gz" + sha256: 018b824396494c8958faa6337cebcaba48a2584d828f279eef0bbf9e05f900a7 diff --git a/recipes/amgcl/all/conanfile.py b/recipes/amgcl/all/conanfile.py new file mode 100644 index 0000000000000..684b4b4d4041e --- /dev/null +++ b/recipes/amgcl/all/conanfile.py @@ -0,0 +1,34 @@ +from conans import ConanFile, CMake, tools +import os + + +class UncrustifyConan(ConanFile): + name = "amgcl" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/ddemidov/amgcl" + topics = ("mathematics", "opencl", "openmp", "cuda", "amg") + license = "MIT" + description = "AMGCL is a header-only C++ library for solving large sparse linear systems with algebraic multigrid (AMG) method." + settings = "compiler" + no_copy_source = True + requires = [("boost/1.76.0")] + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, 11) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("LICENSE.md", src=self._source_subfolder, dst="licenses") + self.copy("*", + dst=os.path.join("include", "amgcl"), + src=(os.path.join(self._source_subfolder, "amgcl"))) + + def package_id(self): + self.info.header_only() diff --git a/recipes/amgcl/all/test_package/CMakeLists.txt b/recipes/amgcl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..70e150a06e203 --- /dev/null +++ b/recipes/amgcl/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(solver solver.cpp) +target_link_libraries(solver ${CONAN_LIBS}) +set_property(TARGET solver PROPERTY CXX_STANDARD 11) diff --git a/recipes/amgcl/all/test_package/conanfile.py b/recipes/amgcl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..cfb088ed67795 --- /dev/null +++ b/recipes/amgcl/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class AmgclTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "solver") + self.run(bin_path, run_environment=True) diff --git a/recipes/amgcl/all/test_package/solver.cpp b/recipes/amgcl/all/test_package/solver.cpp new file mode 100644 index 0000000000000..e51a692a976df --- /dev/null +++ b/recipes/amgcl/all/test_package/solver.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main() { + amgcl::profiler<> profile; + profile.tic("assemble"); + + return EXIT_SUCCESS; +} diff --git a/recipes/amgcl/config.yml b/recipes/amgcl/config.yml new file mode 100644 index 0000000000000..1d12970eb4fba --- /dev/null +++ b/recipes/amgcl/config.yml @@ -0,0 +1,7 @@ +versions: + "1.4.3": + folder: all + "1.4.2": + folder: all + "1.4.0": + folder: all diff --git a/recipes/amqp-cpp/all/conandata.yml b/recipes/amqp-cpp/all/conandata.yml index 6390b5f44429a..2543d0dc3e3ba 100644 --- a/recipes/amqp-cpp/all/conandata.yml +++ b/recipes/amqp-cpp/all/conandata.yml @@ -1,38 +1,50 @@ sources: - "4.1.5": - url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.1.5.tar.gz" - sha256: "9840c7fb17bb0c0b601d269e528b7f9cac5ec008dcf8d66bef22434423b468aa" - "4.1.6": - url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.1.6.tar.gz" - sha256: "48832068dc1e25a5313dd9e96fb33ba954c19f9dc04eeca8f7b2c6cecde3afc9" - "4.1.7": - url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.1.7.tar.gz" - sha256: "71b504f21f62b69c76b371fe7044e0dfc6d42650a15c267431c5084badb0ade7" - "4.2.1": - url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.2.1.tar.gz" - sha256: "33306d6cdb60554998afb304cdc3e3120a71ea539b4be187812065b1b9e59c2f" - "4.3.10": - url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.3.10.tar.gz" - sha256: "4fa1e9650f7a08ae7217899431a3b3f0a173ad826dd819f0b8c760e4e2a65298" + "4.3.18": + url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.3.18.tar.gz" + sha256: "cc2c1fc5da00a1778c2804306e06bdedc782a5f74762b9d9b442d3a498dd0c4f" + "4.3.16": + url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.3.16.tar.gz" + sha256: "66c96e0db1efec9e7ddcf7240ff59a073d68c09752bd3e94b8bc4c506441fbf7" "4.3.11": url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.3.11.tar.gz" sha256: "be2b11ada1020f77b859857310be54bd073c3a4f579d99a5e251a738576ca28c" -patches: + "4.3.10": + url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.3.10.tar.gz" + sha256: "4fa1e9650f7a08ae7217899431a3b3f0a173ad826dd819f0b8c760e4e2a65298" + "4.2.1": + url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.2.1.tar.gz" + sha256: "33306d6cdb60554998afb304cdc3e3120a71ea539b4be187812065b1b9e59c2f" + "4.1.7": + url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.1.7.tar.gz" + sha256: "71b504f21f62b69c76b371fe7044e0dfc6d42650a15c267431c5084badb0ade7" + "4.1.6": + url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.1.6.tar.gz" + sha256: "48832068dc1e25a5313dd9e96fb33ba954c19f9dc04eeca8f7b2c6cecde3afc9" "4.1.5": + url: "https://github.com/CopernicaMarketingSoftware/AMQP-CPP/archive/v4.1.5.tar.gz" + sha256: "9840c7fb17bb0c0b601d269e528b7f9cac5ec008dcf8d66bef22434423b468aa" +patches: + "4.3.18": - patch_file: "patches/0001-cmake-openssl-install-directories.patch" base_path: "source_subfolder" - "4.1.6": + "4.3.16": - patch_file: "patches/0001-cmake-openssl-install-directories.patch" base_path: "source_subfolder" - "4.1.7": + "4.3.11": + - patch_file: "patches/0001-cmake-openssl-install-directories.patch" + base_path: "source_subfolder" + "4.3.10": - patch_file: "patches/0001-cmake-openssl-install-directories.patch" base_path: "source_subfolder" "4.2.1": - patch_file: "patches/0001-cmake-openssl-install-directories.patch" base_path: "source_subfolder" - "4.3.10": + "4.1.7": - patch_file: "patches/0001-cmake-openssl-install-directories.patch" base_path: "source_subfolder" - "4.3.11": + "4.1.6": + - patch_file: "patches/0001-cmake-openssl-install-directories.patch" + base_path: "source_subfolder" + "4.1.5": - patch_file: "patches/0001-cmake-openssl-install-directories.patch" base_path: "source_subfolder" diff --git a/recipes/amqp-cpp/all/conanfile.py b/recipes/amqp-cpp/all/conanfile.py index 3b900ef78e001..6b5d9c2631df0 100644 --- a/recipes/amqp-cpp/all/conanfile.py +++ b/recipes/amqp-cpp/all/conanfile.py @@ -2,17 +2,18 @@ import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.43.0" class AmqpcppConan(ConanFile): name = "amqp-cpp" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/CopernicaMarketingSoftware/AMQP-CPP" - topics = ("amqp", "network", "queue", "conan") + topics = ("amqp", "network", "queue") license = "Apache-2.0" description = "C++ library for asynchronous non-blocking communication with RabbitMQ" - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -23,10 +24,8 @@ class AmqpcppConan(ConanFile): "fPIC": True, "linux_tcp_module": True, } - generators = "cmake" - - exports_sources = "CMakeLists.txt", "patches/**" + generators = "cmake" _cmake = None @property @@ -37,6 +36,11 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -48,11 +52,11 @@ def configure(self): def requirements(self): if self.options.get_safe("linux_tcp_module"): - self.requires("openssl/1.1.1j") + self.requires("openssl/1.1.1q") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("AMQP-CPP-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -76,11 +80,11 @@ def build(self): def package(self): cmake = self._configure_cmake() cmake.install() - self.copy("LICENSE", src=self._source_subfolder, dst="licenses", keep_path=False) tools.rmdir(os.path.join(self.package_folder, "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + # TODO: to remove in conan v2 once cmake_find_package* generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {"amqpcpp": "amqpcpp::amqpcpp"} @@ -98,22 +102,21 @@ def _create_cmake_module_alias_targets(module_file, targets): """.format(alias=alias, aliased=aliased)) tools.save(module_file, content) - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") - @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "amqpcpp") + self.cpp_info.set_property("cmake_target_name", "amqpcpp") + self.cpp_info.set_property("pkg_config_name", "amqpcpp") + self.cpp_info.libs = ["amqpcpp"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["dl", "pthread"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["pkg_config"] = "amqpcpp" self.cpp_info.names["cmake_find_package"] = "amqpcpp" self.cpp_info.names["cmake_find_package_multi"] = "amqpcpp" - self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - self.cpp_info.libs = ["amqpcpp"] - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["dl", "pthread"] diff --git a/recipes/amqp-cpp/all/test_package/conanfile.py b/recipes/amqp-cpp/all/test_package/conanfile.py index 6c9d5dba712c7..a500b98343c74 100644 --- a/recipes/amqp-cpp/all/test_package/conanfile.py +++ b/recipes/amqp-cpp/all/test_package/conanfile.py @@ -2,7 +2,7 @@ import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -11,6 +11,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/amqp-cpp/config.yml b/recipes/amqp-cpp/config.yml index d3e2f2ec12bb9..81db570a6cd83 100644 --- a/recipes/amqp-cpp/config.yml +++ b/recipes/amqp-cpp/config.yml @@ -1,13 +1,17 @@ versions: - "4.1.5": + "4.3.18": folder: all - "4.1.6": + "4.3.16": folder: all - "4.1.7": + "4.3.11": + folder: all + "4.3.10": folder: all "4.2.1": folder: all - "4.3.10": + "4.1.7": folder: all - "4.3.11": + "4.1.6": + folder: all + "4.1.5": folder: all diff --git a/recipes/andreasbuhr-cppcoro/all/CMakeLists.txt b/recipes/andreasbuhr-cppcoro/all/CMakeLists.txt new file mode 100644 index 0000000000000..fe06f4e0b9505 --- /dev/null +++ b/recipes/andreasbuhr-cppcoro/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.4) +project(cmake_wrapper CXX) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/andreasbuhr-cppcoro/all/conandata.yml b/recipes/andreasbuhr-cppcoro/all/conandata.yml new file mode 100644 index 0000000000000..8db5685072de7 --- /dev/null +++ b/recipes/andreasbuhr-cppcoro/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20210113": + url: "https://github.com/andreasbuhr/cppcoro/archive/7cc9433436fe8f2482138019cfaafce8e1d7a896.zip" + sha256: "5edc72bb19616ae5b794c7d83f9a5d4973f32c966f1966ab81779d3a38b36a2c" diff --git a/recipes/andreasbuhr-cppcoro/all/conanfile.py b/recipes/andreasbuhr-cppcoro/all/conanfile.py new file mode 100644 index 0000000000000..2acc06b34e08b --- /dev/null +++ b/recipes/andreasbuhr-cppcoro/all/conanfile.py @@ -0,0 +1,112 @@ +import os +from conans import ConanFile, tools, CMake +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + +class AndreasbuhrCppCoroConan(ConanFile): + name = "andreasbuhr-cppcoro" + description = "A library of C++ coroutine abstractions for the coroutines TS" + topics = ("conan", "cpp", "async", "coroutines") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/andreasbuhr/cppcoro" + license = "MIT" + settings = "os", "compiler", "build_type", "arch" + provides = "cppcoro" + + exports_sources = "CMakeLists.txt" + generators = "cmake" + + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "15", + "gcc": "10", + "clang": "8", + "apple-clang": "10", + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def validate(self): + # We can't simply check for C++20, because clang and MSVC support the coroutine TS despite not having labeled (__cplusplus macro) C++20 support + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler)) + else: + if tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} requires coroutine TS support. The current compiler {} {} does not support it.".format( + self.name, self.settings.compiler, self.settings.compiler.version)) + + # Currently clang expects coroutine to be implemented in a certain way (under std::experiemental::), while libstdc++ puts them under std:: + # There are also other inconsistencies, see https://bugs.llvm.org/show_bug.cgi?id=48172 + # This should be removed after both gcc and clang implements the final coroutine TS + if self.settings.compiler == "clang" and self.settings.compiler.get_safe("libcxx") == "libstdc++": + raise ConanInvalidConfiguration("{} does not support clang with libstdc++. Use libc++ instead.".format(self.name)) + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if not self._cmake: + self._cmake = CMake(self) + if self.settings.os == "Windows" and self.options.shared: + self._cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = "ON" + self._cmake.configure() + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.filenames["cmake_find_package"] = "cppcoro" + self.cpp_info.filenames["cmake_find_package_multi"] = "cppcoro" + self.cpp_info.names["cmake_find_package"] = "cppcoro" + self.cpp_info.names["cmake_find_package_multi"] = "cppcoro" + + comp = self.cpp_info.components["cppcoro"] + comp.names["cmake_find_package"] = "cppcoro" + comp.names["cmake_find_package_multi"] = "cppcoro" + comp.libs = ["cppcoro"] + + if self.settings.os == "Linux" and self.options.shared: + comp.system_libs = ["pthread"] + if self.settings.os == "Windows": + comp.system_libs = ["synchronization"] + + if self.settings.compiler == "Visual Studio": + comp.cxxflags.append("/await") + elif self.settings.compiler == "gcc": + comp.cxxflags.append("-fcoroutines") + comp.defines.append("CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER=1") + elif self.settings.compiler == "clang" or self.settings.compiler == "apple-clang": + comp.cxxflags.append("-fcoroutines-ts") diff --git a/recipes/andreasbuhr-cppcoro/all/test_package/CMakeLists.txt b/recipes/andreasbuhr-cppcoro/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7c6a625130a35 --- /dev/null +++ b/recipes/andreasbuhr-cppcoro/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(cppcoro CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} cppcoro::cppcoro) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20) diff --git a/recipes/andreasbuhr-cppcoro/all/test_package/conanfile.py b/recipes/andreasbuhr-cppcoro/all/test_package/conanfile.py new file mode 100644 index 0000000000000..910ae60d10438 --- /dev/null +++ b/recipes/andreasbuhr-cppcoro/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/andreasbuhr-cppcoro/all/test_package/test_package.cpp b/recipes/andreasbuhr-cppcoro/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..303b1be48d2f2 --- /dev/null +++ b/recipes/andreasbuhr-cppcoro/all/test_package/test_package.cpp @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include + +cppcoro::generator intYielder() { + co_yield 0; + co_yield 1; +} + +cppcoro::task task() { + co_return 42; +} + +int main() { + auto _ = cppcoro::sync_wait(task()); + + std::vector v; + for (int n : intYielder()) { + std::cout << "yielded " << n << '\n'; + v.push_back(n); + } + + bool success = v[0] == 0 && v[1] == 1; + if (success) { + std::cout << "success"; + return 0; + } else { + return 1; + } +} diff --git a/recipes/andreasbuhr-cppcoro/config.yml b/recipes/andreasbuhr-cppcoro/config.yml new file mode 100644 index 0000000000000..1ae5eab0b9b8f --- /dev/null +++ b/recipes/andreasbuhr-cppcoro/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210113": + folder: "all" diff --git a/recipes/android-ndk/all/conandata.yml b/recipes/android-ndk/all/conandata.yml index 22174045a7264..8bc387caae19b 100644 --- a/recipes/android-ndk/all/conandata.yml +++ b/recipes/android-ndk/all/conandata.yml @@ -1,24 +1,118 @@ sources: - "r21d": - url: - "Windows": - url: https://dl.google.com/android/repository/android-ndk-r21d-windows-x86_64.zip - sha256: 18335e57f8acab5a4acf6a2204130e64f99153015d55eb2667f8c28d4724d927 - "Linux": - url: https://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip - sha256: dd6dc090b6e2580206c64bcee499bc16509a5d017c6952dcd2bed9072af67cbd - "Macos": - url: https://dl.google.com/android/repository/android-ndk-r21d-darwin-x86_64.zip - sha256: 5851115c6fc4cce26bc320295b52da240665d7ff89bda2f5d5af1887582f5c48 + "r25": + "Windows": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r25-windows.zip" + sha256: "bdb25e75647532f979844f549a33eaf75c54a2cb4367f349be187ae9bfee9234" + "Linux": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r25-linux.zip" + sha256: "cd661aeda5d9b7cfb6e64bd80737c274d7c1c0d026df2f85be3bf3327b25e545" + "Macos": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r25-darwin.zip" + sha256: "2373424b91bba4cdd15e4c82e05f77a44ba3617aa3329843958ea3d0e25e62d0" + "r24": + "Windows": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r24-windows.zip" + sha256: "b2a9fab1481c3c21df0b78608747dde0747b50890134a62a81c983a5250066d6" + "Linux": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r24-linux.zip" + sha256: "caac638f060347c9aae994e718ba00bb18413498d8e0ad4e12e1482964032997" + "Macos": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r24-darwin.zip" + sha256: "162a7000515be07489f2ed70d6d3a117d236150f83f3fcb601c163349429ba23" + "r23c": + "Windows": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r23c-windows.zip" + sha256: "48a0a7b38fb1c69cae6d17b70e03aab8d6138e65a30f8d3faebeb0dc09bf6940" + "Linux": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r23c-linux.zip" + sha256: "6ce94604b77d28113ecd588d425363624a5228d9662450c48d2e4053f8039242" + "Macos": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r23c-darwin.zip" + sha256: "baf793127741eda36f2eabe69cdec23a70c814deb3c75df8744af35aed21e59d" + "r23b": + "Windows": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r23b-windows.zip" + sha256: "36270f8b2cfdd940f410bd8ffe6ce86ffaa8e87ff1c4fd4a8be5130268357778" + "Linux": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r23b-linux.zip" + sha256: "c6e97f9c8cfe5b7be0a9e6c15af8e7a179475b7ded23e2d1c1fa0945d6fb4382" + "Macos": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r23b-darwin.zip" + sha256: "e067b7402fdae85bfbe8af1822afd573b8e73dce443a8292fdaeb2e8dc3aeb86" + "r23": + "Windows": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r23-windows.zip" + sha256: "40325b5bfdb7f6de016ea3efee0468a7d306eda55a6f80966a501645ba01fbfa" + "Linux": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r23-linux.zip" + sha256: "e3eacf80016b91d4cd2c8ca9f34eebd32df912bb799c859cc5450b6b19277b4f" + "Macos": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r23-darwin.zip" + sha256: "163ff3bb72306ffa814de35c49819bccae9df10855a4e3fbba52ad4111fcccae" + "r22b": + "Windows": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r22b-windows-x86_64.zip" + sha256: "6d2fe8dbba8342634e88ecbaf321bcbfc07e579b6281f426639002dd35046d03" + "Linux": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip" + sha256: "ac3a0421e76f71dd330d0cd55f9d99b9ac864c4c034fc67e0d671d022d4e806b" + "Macos": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r22b-darwin-x86_64.zip" + sha256: "b05d2087a6346d66cd26a1dc89fcc877b59e49feab6269b665aa67c784a81512" "r22": - url: - "Windows": - url: https://dl.google.com/android/repository/android-ndk-r22-windows-x86_64.zip - sha256: 5a0eafa83c8bba3c76e8427aa3d83d169215f62963a277b1914a3651aa47f751 - "Linux": - url: https://dl.google.com/android/repository/android-ndk-r22-linux-x86_64.zip - sha256: d37fc69cd81e5660234a686e20adef39bc0244086e4d66525a40af771c020718 - "Macos": - url: https://dl.google.com/android/repository/android-ndk-r22-darwin-x86_64.zip - sha256: 14fce4dea7fb3facbc0e3d20270007bffec3ba383aec02e8b0e0dad8d8782892 - + "Windows": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r22-windows-x86_64.zip" + sha256: "5a0eafa83c8bba3c76e8427aa3d83d169215f62963a277b1914a3651aa47f751" + "Linux": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r22-linux-x86_64.zip" + sha256: "d37fc69cd81e5660234a686e20adef39bc0244086e4d66525a40af771c020718" + "Macos": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r22-darwin-x86_64.zip" + sha256: "14fce4dea7fb3facbc0e3d20270007bffec3ba383aec02e8b0e0dad8d8782892" + "r21e": + "Windows": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r21e-windows-x86_64.zip" + sha256: "f71307c5c572e2c163d602b3704b8bc024bec0c43ba2800de36bd10f3a21492b" + "Linux": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip" + sha256: "ad7ce5467e18d40050dc51b8e7affc3e635c85bd8c59be62de32352328ed467e" + "Macos": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r21e-darwin-x86_64.zip" + sha256: "437278103a3db12632c05b1be5c41bbb8522791a67e415cc54411a65366f499d" + "r21d": + "Windows": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r21d-windows-x86_64.zip" + sha256: "18335e57f8acab5a4acf6a2204130e64f99153015d55eb2667f8c28d4724d927" + "Linux": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip" + sha256: "dd6dc090b6e2580206c64bcee499bc16509a5d017c6952dcd2bed9072af67cbd" + "Macos": + "x86_64": + url: "https://dl.google.com/android/repository/android-ndk-r21d-darwin-x86_64.zip" + sha256: "5851115c6fc4cce26bc320295b52da240665d7ff89bda2f5d5af1887582f5c48" diff --git a/recipes/android-ndk/all/conanfile.py b/recipes/android-ndk/all/conanfile.py index d89b5c16e9b4e..cf7fce07c64ba 100644 --- a/recipes/android-ndk/all/conanfile.py +++ b/recipes/android-ndk/all/conanfile.py @@ -1,217 +1,394 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile, conan_version +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, download, unzip, load, copy +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +import re +import shutil +required_conan_version = ">=1.52.0" -class AndroidNDKInstallerConan(ConanFile): + +class AndroidNDKConan(ConanFile): name = "android-ndk" - description = "The Android NDK is a toolset that lets you implement parts of your app in " \ - "native code, using languages such as C and C++" + description = "The Android NDK is a toolset that lets you implement parts of your app in native code, using languages such as C and C++" url = "https://github.com/conan-io/conan-center-index" homepage = "https://developer.android.com/ndk/" - topics = ("NDK", "android", "toolchain", "compiler") + topics = ("android", "ndk", "toolchain", "compiler") license = "Apache-2.0" + + settings = "os", "arch", "build_type", "compiler" + short_paths = True - no_copy_source = True - exports_sources = ["cmake-wrapper.cmd", "cmake-wrapper"] + exports_sources = "cmake-wrapper.cmd", "cmake-wrapper" + + @property + def _is_universal2(self): + return self.version in ["r23b", "r23c", "r24", "r25"] and self.settings.os == "Macos" and self.settings.arch in ["x86_64", "armv8"] - settings = {"os": ["Windows", "Linux", "Macos"], - "arch": ["x86_64"]} + @property + def _arch(self): + return "x86_64" if self._is_universal2 else self.settings.arch + + @property + def _settings_os_supported(self): + return self.conan_data["sources"][self.version].get(str(self.settings.os)) is not None @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_arch_supported(self): + return self.conan_data["sources"][self.version].get(str(self.settings.os), {}).get(str(self._arch)) is not None + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + if self._is_universal2: + self.info.settings.arch = "universal:armv8/x86_64" + del self.info.settings.compiler + del self.info.settings.build_type - def configure(self): - if self.settings.arch != 'x86_64': - raise ConanInvalidConfiguration("No binaries available for other than 'x86_64' architectures") + def validate(self): + if not self._settings_os_supported: + raise ConanInvalidConfiguration(f"os={self.settings.os} is not supported by {self.name} (no binaries are available)") + if not self._settings_arch_supported: + raise ConanInvalidConfiguration(f"os,arch={self.settings.os},{self.settings.arch} is not supported by {self.name} (no binaries are available)") def source(self): - tarballs = self.conan_data["sources"][self.version]["url"] - tools.get(**tarballs[str(self.settings.os)]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + pass def build(self): - pass # no build, but please also no warnings + if self.version in ['r23', 'r23b', 'r23c', 'r24', 'r25']: + data = self.conan_data["sources"][self.version][str(self.settings.os)][str(self._arch)] + self._unzip_fix_symlinks(url=data["url"], target_folder=self.source_folder, sha256=data["sha256"]) + else: + get(self, **self.conan_data["sources"][self.version][str(self.settings.os)][str(self._arch)], + destination=self.source_folder, strip_root=True) - # from here on, everything is assumed to run in 2 profile mode, when using the ndk as a build requirement + def package(self): + copy(self, "*", src=self.source_folder, dst=os.path.join(self.package_folder, "bin")) + copy(self, "*NOTICE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*NOTICE.toolchain", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "cmake-wrapper.cmd", src=os.path.join(self.source_folder, os.pardir), dst=os.path.join(self.package_folder, "bin")) + copy(self, "cmake-wrapper", src=os.path.join(self.source_folder, os.pardir), dst=os.path.join(self.package_folder, "bin")) + self._fix_broken_links() + self._fix_permissions() + + # from here on, everything is assumed to run in 2 profile mode, using this android-ndk recipe as a build requirement @property def _platform(self): - return {"Windows": "windows", - "Macos": "darwin", - "Linux": "linux"}.get(str(self.settings_build.os)) + return { + "Linux": "linux", + "Macos": "darwin", + "Windows": "windows", + }.get(str(self.settings_build.os)) @property def _android_abi(self): - return {"x86": "x86", - "x86_64": "x86_64", - "armv7": "armeabi-v7a", - "armv8": "arm64-v8a"}.get(str(self.settings_target.arch)) + return { + "armv7": "armeabi-v7a", + "armv8": "arm64-v8a", + "x86": "x86", + "x86_64": "x86_64", + }.get(str(self.settings_target.arch)) @property def _llvm_triplet(self): - arch = {'armv7': 'arm', - 'armv8': 'aarch64', - 'x86': 'i686', - 'x86_64': 'x86_64'}.get(str(self.settings_target.arch)) - abi = 'androideabi' if self.settings_target.arch == 'armv7' else 'android' - return '%s-linux-%s' % (arch, abi) + arch = { + "armv7": "arm", + "armv8": "aarch64", + "x86": "i686", + "x86_64": "x86_64", + }.get(str(self.settings_target.arch)) + abi = "androideabi" if self.settings_target.arch == "armv7" else "android" + return f"{arch}-linux-{abi}" @property def _clang_triplet(self): - arch = {'armv7': 'armv7a', - 'armv8': 'aarch64', - 'x86': 'i686', - 'x86_64': 'x86_64'}.get(str(self.settings_target.arch)) - abi = 'androideabi' if self.settings_target.arch == 'armv7' else 'android' - return '%s-linux-%s' % (arch, abi) + arch = { + "armv7": "armv7a", + "armv8": "aarch64", + "x86": "i686", + "x86_64": "x86_64", + }.get(str(self.settings_target.arch)) + abi = "androideabi" if self.settings_target.arch == "armv7" else "android" + return f"{arch}-linux-{abi}" + + @property + def _ndk_major_minor(self): + match = re.search(r"r(\d+)(\w?)", self.version) + assert match + major, minor = match.groups() + assert major + return int(major), minor if minor else "a" + + @property + def _ndk_version_major(self): + return self._ndk_major_minor[0] + + @property + def _ndk_version_minor(self): + return self._ndk_major_minor[1] def _fix_permissions(self): - if os.name != 'posix': + if os.name != "posix": return - for root, _, files in os.walk(self.package_folder): + for root, _, files in os.walk(os.path.join(self.package_folder, "bin")): for filename in files: filename = os.path.join(root, filename) - with open(filename, 'rb') as f: + with open(filename, "rb") as f: sig = f.read(4) - if type(sig) is str: + if isinstance(sig, str): sig = [ord(s) for s in sig] else: - sig = [s for s in sig] + sig = list(sig) if len(sig) > 2 and sig[0] == 0x23 and sig[1] == 0x21: - self.output.info('chmod on script file: "%s"' % filename) + self.output.info(f"chmod on script file: '{filename}'") self._chmod_plus_x(filename) elif sig == [0x7F, 0x45, 0x4C, 0x46]: - self.output.info('chmod on ELF file: "%s"' % filename) + self.output.info(f"chmod on ELF file: '{filename}'") self._chmod_plus_x(filename) - elif sig == [0xCA, 0xFE, 0xBA, 0xBE] or \ - sig == [0xBE, 0xBA, 0xFE, 0xCA] or \ - sig == [0xFE, 0xED, 0xFA, 0xCF] or \ - sig == [0xCF, 0xFA, 0xED, 0xFE] or \ - sig == [0xFE, 0xEF, 0xFA, 0xCE] or \ - sig == [0xCE, 0xFA, 0xED, 0xFE]: - self.output.info('chmod on Mach-O file: "%s"' % filename) + elif sig in ( + [0xCA, 0xFE, 0xBA, 0xBE], + [0xBE, 0xBA, 0xFE, 0xCA], + [0xFE, 0xED, 0xFA, 0xCF], + [0xCF, 0xFA, 0xED, 0xFE], + [0xFE, 0xEF, 0xFA, 0xCE], + [0xCE, 0xFA, 0xED, 0xFE] + ): + self.output.info(f"chmod on Mach-O file: '{filename}'") self._chmod_plus_x(filename) - def package(self): - self.copy(pattern="*", dst=".", src=self._source_subfolder, keep_path=True, symlinks=True) - self.copy(pattern="*NOTICE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*NOTICE.toolchain", dst="licenses", src=self._source_subfolder) - self.copy("cmake-wrapper.cmd") - self.copy("cmake-wrapper") - self._fix_permissions() + def _fix_broken_links(self): + # https://github.com/android/ndk/issues/1671 + # https://github.com/android/ndk/issues/1569 + if self.version in ["r23b", "r23c"] and self.settings.os in ["Linux", "Macos"]: + platform = "darwin" if self.settings.os == "Macos" else "linux" + links = {f"toolchains/llvm/prebuilt/{platform}-x86_64/aarch64-linux-android/bin/as": "../../bin/aarch64-linux-android-as", + f"toolchains/llvm/prebuilt/{platform}-x86_64/arm-linux-androideabi/bin/as": "../../bin/arm-linux-androideabi-as", + f"toolchains/llvm/prebuilt/{platform}-x86_64/x86_64-linux-android/bin/as": "../../bin/x86_64-linux-android-as", + f"toolchains/llvm/prebuilt/{platform}-x86_64/i686-linux-android/bin/as": "../../bin/i686-linux-android-as"} + for path, target in links.items(): + path = os.path.join(self.package_folder, "bin", path) + os.unlink(path) + os.symlink(target, path) @property def _host(self): - return self._platform + "-x86_64" + return f"{self._platform}-{self._arch}" @property - def _ndk_root(self): - return os.path.join(self.package_folder, "toolchains", "llvm", "prebuilt", self._host) + def _ndk_root_rel_path(self): + return os.path.join("bin", "toolchains", "llvm", "prebuilt", self._host) - def _tool_name(self, tool): - if 'clang' in tool: - suffix = '.cmd' if self.settings_build.os == 'Windows' else '' - return '%s%s-%s%s' % (self._clang_triplet, self.settings_target.os.api_level, tool, suffix) + @property + def _ndk_root(self): + return os.path.join(self.package_folder, self._ndk_root_rel_path) + + def _wrap_executable(self, tool): + suffix = ".exe" if self.settings_build.os == "Windows" else "" + return f"{tool}{suffix}" + + def _tool_name(self, tool, bare=False): + prefix = "" + if "clang" in tool: + suffix = ".cmd" if self.settings_build.os == "Windows" else "" + prefix = "llvm" if bare else f"{self._clang_triplet}{self.settings_target.os.api_level}" + return f"{prefix}-{tool}{suffix}" else: - suffix = '.exe' if self.settings_build.os == 'Windows' else '' - return '%s-%s%s' % (self._llvm_triplet, tool, suffix) + prefix = "llvm" if bare else f"{self._llvm_triplet}" + executable = f"{prefix}-{tool}" + return self._wrap_executable(executable) - def _define_tool_var(self, name, value): - ndk_bin = os.path.join(self._ndk_root, 'bin') - path = os.path.join(ndk_bin, self._tool_name(value)) - self.output.info('Creating %s environment variable: %s' % (name, path)) + @property + def _cmake_system_processor(self): + cmake_system_processor = { + "x86_64": "x86_64", + "x86": "i686", + "mips": "mips", + "mips64": "mips64", + }.get(str(self.settings.arch)) + if self.settings_target.arch == "armv8": + cmake_system_processor = "aarch64" + elif "armv7" in str(self.settings.arch): + cmake_system_processor = "armv7-a" + elif "armv6" in str(self.settings.arch): + cmake_system_processor = "armv6" + elif "armv5" in str(self.settings.arch): + cmake_system_processor = "armv5te" + return cmake_system_processor + + def _define_tool_var(self, name, value, bare = False): + ndk_bin = os.path.join(self._ndk_root, "bin") + path = os.path.join(ndk_bin, self._tool_name(value, bare)) + if not os.path.isfile(path): + self.output.error(f"'Environment variable {name} could not be created: '{path}'") + return "UNKNOWN" return path - # def package_id(self): - # self.info.include_build_settings() - # del self.info.settings.arch - # del self.info.settings.os.api_level + def _define_tool_var_naked(self, name, value): + ndk_bin = os.path.join(self._ndk_root, "bin") + path = os.path.join(ndk_bin, self._wrap_executable(value)) + if not os.path.isfile(path): + self.output.error(f"'Environment variable {name} could not be created: '{path}'") + return "UNKNOWN" + return path @staticmethod def _chmod_plus_x(filename): - if os.name == 'posix': + if os.name == "posix": os.chmod(filename, os.stat(filename).st_mode | 0o111) def package_info(self): - # test shall pass, so this runs also in the build as build requirement context - # ndk-build: https://developer.android.com/ndk/guides/ndk-build - self.env_info.PATH.append(self.package_folder) + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] - # You should use the ANDROID_NDK_ROOT environment variable to indicate where the NDK is located. + # You should use the ANDROID_NDK_ROOT environment variable to indicate where the NDK is located. # That's what most NDK-related scripts use (inside the NDK, and outside of it). # https://groups.google.com/g/android-ndk/c/qZjhOaynHXc - self.output.info('Creating ANDROID_NDK_ROOT environment variable: %s' % self.package_folder) - self.env_info.ANDROID_NDK_ROOT = self.package_folder + self.buildenv_info.define_path("ANDROID_NDK_ROOT", os.path.join(self.package_folder, "bin")) - self.output.info('Creating ANDROID_NDK_HOME environment variable: %s' % self.package_folder) - self.env_info.ANDROID_NDK_HOME = self.package_folder + self.buildenv_info.define_path("ANDROID_NDK_HOME", os.path.join(self.package_folder, "bin")) # this is not enough, I can kill that ..... - if not hasattr(self, 'settings_target'): + if not hasattr(self, "settings_target"): return # interestingly I can reach that with # conan test --profile:build nsdk-default --profile:host default /Users/a4z/elux/conan/myrecipes/android-ndk/all/test_package android-ndk/r21d@ - if self.settings_target is None: + if self.settings_target is None: return # And if we are not building for Android, why bother at all if not self.settings_target.os == "Android": + self.output.warn(f"You've added {self.name}/{self.version} as a build requirement, while os={self.settings_target.os} != Android") return - self.output.info('Creating NDK_ROOT environment variable: %s' % self._ndk_root) - self.env_info.NDK_ROOT = self._ndk_root - - self.output.info('Creating CHOST environment variable: %s' % self._llvm_triplet) - self.env_info.CHOST = self._llvm_triplet - - ndk_sysroot = os.path.join(self._ndk_root, 'sysroot') - self.output.info('Creating CONAN_CMAKE_FIND_ROOT_PATH environment variable: %s' % ndk_sysroot) - self.env_info.CONAN_CMAKE_FIND_ROOT_PATH = ndk_sysroot - - self.output.info('Creating SYSROOT environment variable: %s' % ndk_sysroot) - self.env_info.SYSROOT = ndk_sysroot - - self.output.info('Creating self.cpp_info.sysroot: %s' % ndk_sysroot) - self.cpp_info.sysroot = ndk_sysroot - - self.output.info('Creating ANDROID_NATIVE_API_LEVEL environment variable: %s' % self.settings_target.os.api_level) - self.env_info.ANDROID_NATIVE_API_LEVEL = str(self.settings_target.os.api_level) - - self._chmod_plus_x(os.path.join(self.package_folder, "cmake-wrapper")) - cmake_wrapper = "cmake-wrapper.cmd" if self.settings.os == "Windows" else "cmake-wrapper" - cmake_wrapper = os.path.join(self.package_folder, cmake_wrapper) - self.output.info('Creating CONAN_CMAKE_PROGRAM environment variable: %s' % cmake_wrapper) - self.env_info.CONAN_CMAKE_PROGRAM = cmake_wrapper - - toolchain = os.path.join(self.package_folder, "build", "cmake", "android.toolchain.cmake") - self.output.info('Creating CONAN_CMAKE_TOOLCHAIN_FILE environment variable: %s' % toolchain) - self.env_info.CONAN_CMAKE_TOOLCHAIN_FILE = toolchain - - self.env_info.CC = self._define_tool_var('CC', 'clang') - self.env_info.CXX = self._define_tool_var('CXX', 'clang++') - self.env_info.LD = self._define_tool_var('LD', 'ld') - self.env_info.AR = self._define_tool_var('AR', 'ar') - self.env_info.AS = self._define_tool_var('AS', 'as') - self.env_info.RANLIB = self._define_tool_var('RANLIB', 'ranlib') - self.env_info.STRIP = self._define_tool_var('STRIP', 'strip') - self.env_info.ADDR2LINE = self._define_tool_var('ADDR2LINE', 'addr2line') - self.env_info.NM = self._define_tool_var('NM', 'nm') - self.env_info.OBJCOPY = self._define_tool_var('OBJCOPY', 'objcopy') - self.env_info.OBJDUMP = self._define_tool_var('OBJDUMP', 'objdump') - self.env_info.READELF = self._define_tool_var('READELF', 'readelf') - self.env_info.ELFEDIT = self._define_tool_var('ELFEDIT', 'elfedit') - - self.env_info.ANDROID_PLATFORM = "android-%s" % self.settings_target.os.api_level - self.env_info.ANDROID_TOOLCHAIN = "clang" - self.env_info.ANDROID_ABI = self._android_abi - libcxx_str = str(self.settings_target.compiler.libcxx) - self.env_info.ANDROID_STL = libcxx_str if libcxx_str.startswith('c++_') else 'c++_shared' + self.cpp_info.bindirs.append(os.path.join(self._ndk_root_rel_path, "bin")) + + self.buildenv_info.define_path("NDK_ROOT", self._ndk_root) - self.env_info.CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH" - self.env_info.CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = "BOTH" - self.env_info.CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = "BOTH" - self.env_info.CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = "BOTH" + self.buildenv_info.define("CHOST", self._llvm_triplet) + + ndk_sysroot = os.path.join(self._ndk_root, "sysroot") + self.conf_info.define("tools.build:sysroot", ndk_sysroot) + self.buildenv_info.define_path("SYSROOT", ndk_sysroot) + + self.buildenv_info.define("ANDROID_NATIVE_API_LEVEL", str(self.settings_target.os.api_level)) + + # CMakeToolchain automatically adds the standard Android toolchain file that ships with the NDK + # when `tools.android:ndk_path` is provided, so it MUST NOT be manually injected here to `tools.cmake.cmaketoolchain:user_toolchain` conf_info + self.conf_info.define("tools.android:ndk_path", os.path.join(self.package_folder, "bin")) + + self.buildenv_info.define_path("CC", self._define_tool_var("CC", "clang")) + self.buildenv_info.define_path("CXX", self._define_tool_var("CXX", "clang++")) + + # Versions greater than 23 had the naming convention + # changed to no longer include the triplet. + bare = self._ndk_version_major >= 23 + self.buildenv_info.define_path("AR", self._define_tool_var("AR", "ar", bare)) + self.buildenv_info.define_path("AS", self._define_tool_var("AS", "as", bare)) + self.buildenv_info.define_path("RANLIB", self._define_tool_var("RANLIB", "ranlib", bare)) + self.buildenv_info.define_path("STRIP", self._define_tool_var("STRIP", "strip", bare)) + self.buildenv_info.define_path("ADDR2LINE", self._define_tool_var("ADDR2LINE", "addr2line", bare)) + self.buildenv_info.define_path("NM", self._define_tool_var("NM", "nm", bare)) + self.buildenv_info.define_path("OBJCOPY", self._define_tool_var("OBJCOPY", "objcopy", bare)) + self.buildenv_info.define_path("OBJDUMP", self._define_tool_var("OBJDUMP", "objdump", bare)) + self.buildenv_info.define_path("READELF", self._define_tool_var("READELF", "readelf", bare)) + # there doesn't seem to be an 'elfedit' included anymore. + if self._ndk_version_major < 23: + self.buildenv_info.define_path("ELFEDIT", self._define_tool_var("ELFEDIT", "elfedit", bare)) + + # The `ld` tool changed naming conventions earlier than others + if self._ndk_version_major >= 22: + self.buildenv_info.define_path("LD", self._define_tool_var_naked("LD", "ld")) + else: + self.buildenv_info.define_path("LD", self._define_tool_var("LD", "ld")) + + self.buildenv_info.define("ANDROID_PLATFORM", f"android-{self.settings_target.os.api_level}") + self.buildenv_info.define("ANDROID_TOOLCHAIN", "clang") + self.buildenv_info.define("ANDROID_ABI", self._android_abi) + libcxx_str = str(self.settings_target.compiler.libcxx) + self.buildenv_info.define("ANDROID_STL", libcxx_str if libcxx_str.startswith("c++_") else "c++_shared") + + # TODO: conan v1 stuff to remove later + if Version(conan_version).major < 2: + self.env_info.PATH.extend([os.path.join(self.package_folder, "bin"), os.path.join(self._ndk_root, "bin")]) + self.env_info.ANDROID_NDK_ROOT = os.path.join(self.package_folder, "bin") + self.env_info.ANDROID_NDK_HOME = os.path.join(self.package_folder, "bin") + cmake_system_processor = self._cmake_system_processor + if cmake_system_processor: + self.env_info.CONAN_CMAKE_SYSTEM_PROCESSOR = cmake_system_processor + else: + self.output.warn("Could not find a valid CMAKE_SYSTEM_PROCESSOR variable, supported by CMake") + self.env_info.NDK_ROOT = self._ndk_root + self.env_info.CHOST = self._llvm_triplet + self.env_info.CONAN_CMAKE_FIND_ROOT_PATH = ndk_sysroot + self.env_info.SYSROOT = ndk_sysroot + self.env_info.ANDROID_NATIVE_API_LEVEL = str(self.settings_target.os.api_level) + self._chmod_plus_x(os.path.join(self.package_folder, "bin", "cmake-wrapper")) + cmake_wrapper = "cmake-wrapper.cmd" if self.settings.os == "Windows" else "cmake-wrapper" + cmake_wrapper = os.path.join(self.package_folder, "bin", cmake_wrapper) + self.env_info.CONAN_CMAKE_PROGRAM = cmake_wrapper + self.env_info.CONAN_CMAKE_TOOLCHAIN_FILE = os.path.join(self.package_folder, "bin", "build", "cmake", "android.toolchain.cmake") + self.env_info.CC = self._define_tool_var("CC", "clang") + self.env_info.CXX = self._define_tool_var("CXX", "clang++") + self.env_info.AR = self._define_tool_var("AR", "ar", bare) + self.env_info.AS = self._define_tool_var("AS", "as", bare) + self.env_info.RANLIB = self._define_tool_var("RANLIB", "ranlib", bare) + self.env_info.STRIP = self._define_tool_var("STRIP", "strip", bare) + self.env_info.ADDR2LINE = self._define_tool_var("ADDR2LINE", "addr2line", bare) + self.env_info.NM = self._define_tool_var("NM", "nm", bare) + self.env_info.OBJCOPY = self._define_tool_var("OBJCOPY", "objcopy", bare) + self.env_info.OBJDUMP = self._define_tool_var("OBJDUMP", "objdump", bare) + self.env_info.READELF = self._define_tool_var("READELF", "readelf", bare) + if self._ndk_version_major < 23: + self.env_info.ELFEDIT = self._define_tool_var("ELFEDIT", "elfedit") + if self._ndk_version_major >= 22: + self.env_info.LD = self._define_tool_var_naked("LD", "ld") + else: + self.env_info.LD = self._define_tool_var("LD", "ld") + self.env_info.ANDROID_PLATFORM = f"android-{self.settings_target.os.api_level}" + self.env_info.ANDROID_TOOLCHAIN = "clang" + self.env_info.ANDROID_ABI = self._android_abi + self.env_info.ANDROID_STL = libcxx_str if libcxx_str.startswith("c++_") else "c++_shared" + self.env_info.CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH" + self.env_info.CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = "BOTH" + self.env_info.CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = "BOTH" + self.env_info.CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = "BOTH" + + def _unzip_fix_symlinks(self, url, target_folder, sha256): + # Python's built-in module 'zipfile' won't handle symlinks (https://bugs.python.org/issue37921) + # Most of the logic borrowed from this PR https://github.com/conan-io/conan/pull/8100 + + filename = "android_sdk.zip" + download(self, url, filename, sha256=sha256) + unzip(self, filename, destination=target_folder, strip_root=True) + + def is_symlink_zipinfo(zi): + return (zi.external_attr >> 28) == 0xA + + full_path = os.path.normpath(target_folder) + import zipfile + with zipfile.ZipFile(filename, "r") as z: + zip_info = z.infolist() + + names = [n.replace("\\", "/") for n in z.namelist()] + common_folder = os.path.commonprefix(names).split("/", 1)[0] + + for file_ in zip_info: + if is_symlink_zipinfo(file_): + rel_path = os.path.relpath(file_.filename, common_folder) + full_name = os.path.join(full_path, rel_path) + target = load(self, full_name) + os.unlink(full_name) + + try: + os.symlink(target, full_name) + except OSError: + if not os.path.isabs(target): + target = os.path.normpath(os.path.join(os.path.dirname(full_name), target)) + shutil.copy2(target, full_name) + + os.unlink(filename) diff --git a/recipes/android-ndk/all/test_package/CMakeLists.txt b/recipes/android-ndk/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f776bcb524ea6 --- /dev/null +++ b/recipes/android-ndk/all/test_package/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +add_executable(${PROJECT_NAME} test_package.cpp) diff --git a/recipes/android-ndk/all/test_package/conanfile.py b/recipes/android-ndk/all/test_package/conanfile.py index 4a0b39392ce92..db186fc2c369f 100644 --- a/recipes/android-ndk/all/test_package/conanfile.py +++ b/recipes/android-ndk/all/test_package/conanfile.py @@ -1,14 +1,33 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +import os + class TestPackgeConan(ConanFile): - settings = "os", "arch" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): - pass #nothing to do, not warnings please + # INFO: It only makes sense to build a library, if the target OS is Android + if self.settings.os == "Android": + cmake = CMake(self) + cmake.configure() + cmake.build() def test(self): - if not tools.cross_building(self): - if self.settings.os == "Windows": - self.run("ndk-build.cmd --version", run_environment=True) - else: - self.run("ndk-build --version", run_environment=True) + if self.settings.os == "Windows": + self.run("ndk-build.cmd --version") + else: + self.run("ndk-build --version") + + # INFO: Run the project that was built using Android NDK + if self.settings.os == "Android": + test_file = os.path.join(self.cpp.build.bindirs[0], "test_package") + assert os.path.exists(test_file) diff --git a/recipes/android-ndk/all/test_package/test_package.cpp b/recipes/android-ndk/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..dc0f143f2972b --- /dev/null +++ b/recipes/android-ndk/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + std::cout << "conan-center-index\n"; + return EXIT_SUCCESS; +} diff --git a/recipes/android-ndk/all/test_v1_package/CMakeLists.txt b/recipes/android-ndk/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f7c5ddc942cf1 --- /dev/null +++ b/recipes/android-ndk/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) diff --git a/recipes/android-ndk/all/test_v1_package/conanfile.py b/recipes/android-ndk/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e7a2d6060ddc7 --- /dev/null +++ b/recipes/android-ndk/all/test_v1_package/conanfile.py @@ -0,0 +1,32 @@ +import os +from conan import ConanFile +from conans import CMake +from conan.tools.build import cross_building + + +class TestPackgeConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + generators = "cmake" + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + + def build(self): + # It only makes sense to build a library, if the target os is Android + if self.settings.os == "Android": + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + if self.settings.os == "Windows": + self.run("ndk-build.cmd --version", run_environment=True) + else: + self.run("ndk-build --version", run_environment=True) + + # Run the project that was built using Android NDK + if self.settings.os == "Android": + test_file = os.path.join("bin", "test_package") + assert os.path.exists(test_file) diff --git a/recipes/android-ndk/config.yml b/recipes/android-ndk/config.yml index 2d8f0ec278d6c..b2fc5196cfcfc 100644 --- a/recipes/android-ndk/config.yml +++ b/recipes/android-ndk/config.yml @@ -1,6 +1,19 @@ ---- - versions: - "r21d": - folder: all - "r22": - folder: all +versions: + "r25": + folder: all + "r24": + folder: all + "r23c": + folder: all + "r23b": + folder: all + "r23": + folder: all + "r22b": + folder: all + "r22": + folder: all + "r21e": + folder: all + "r21d": + folder: all diff --git a/recipes/angelscript/all/conandata.yml b/recipes/angelscript/all/conandata.yml new file mode 100644 index 0000000000000..1dec7ac1d3e71 --- /dev/null +++ b/recipes/angelscript/all/conandata.yml @@ -0,0 +1,28 @@ +sources: + "2.36.0": + url: "https://www.angelcode.com/angelscript/sdk/files/angelscript_2.36.0.zip" + sha256: "33f95f7597bc0d88b097d35e7b1320d15419ffc5779851d9d2a6cccec57811b3" + "2.35.1": + url: "https://www.angelcode.com/angelscript/sdk/files/angelscript_2.35.1.zip" + sha256: "5c1096b6d6cf50c7e77ae93c736d35b69b07b1e5047161c7816bca25b413a18b" + "2.35.0": + url: "https://www.angelcode.com/angelscript/sdk/files/angelscript_2.35.0.zip" + sha256: "010dd45e23e734d46f5891d70e268607a12cb9ab12503dda42f842d9db7e8857" +patches: + "2.36.0": + - patch_file: "patches/2.36.0-0001-missing-include-stdint.patch" + patch_description: "Add missing stdint.h include" + patch_type: "portability" + sha256: "16d08c43a871a2ab4695e63829e9c07f9fab4237515185c1921e55c0b76483d3" + "2.35.1": + - patch_file: "patches/2.35.1-0001-fix-compatibility-apple-clang.patch" + patch_description: "Fix apple-clang compatibility of ASM arm" + patch_type: "portability" + patch_source: "https://github.com/codecat/angelscript-mirror/commit/7ec10a763d9c078b57c413b552a2d05c2638878f" + sha256: "6cd39d941cc9e674f5ec2f94d2dc0d2eec04dfb348bbc8956eb2c6e6f5b2b895" + "2.35.0": + - patch_file: "patches/2.35.0-0001-fix-compatibility-apple-clang.patch" + patch_description: "Fix apple-clang compatibility of ASM arm" + patch_type: "portability" + patch_source: "https://github.com/codecat/angelscript-mirror/commit/7ec10a763d9c078b57c413b552a2d05c2638878f" + sha256: "03446786a60dbf53e0e69385ae918dbc4004bcf1a64c14960d11b856f3b0c64a" diff --git a/recipes/angelscript/all/conanfile.py b/recipes/angelscript/all/conanfile.py new file mode 100644 index 0000000000000..174e1d9732354 --- /dev/null +++ b/recipes/angelscript/all/conanfile.py @@ -0,0 +1,102 @@ +from conan import ConanFile +from conan.tools.build import valid_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, get, export_conandata_patches, load, rmdir, save +from conan.tools.microsoft import is_msvc +import os + +required_conan_version = ">=1.52.0" + + +class AngelScriptConan(ConanFile): + name = "angelscript" + license = "Zlib" + homepage = "http://www.angelcode.com/angelscript" + url = "https://github.com/conan-io/conan-center-index" + description = ( + "An extremely flexible cross-platform scripting library designed to " + "allow applications to extend their functionality through external scripts." + ) + topics = ("angelcode", "embedded", "scripting", "language", "compiler", "interpreter") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [False, True], + "fPIC": [False, True], + "no_exceptions": [False, True], + } + default_options = { + "shared": False, + "fPIC": True, + "no_exceptions": False, + } + + short_paths = True + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + # Website blocks default user agent string. + get( + self, + **self.conan_data["sources"][self.version], + destination=self.source_folder, + headers={"User-Agent": "ConanCenter"}, + strip_root=True, + ) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["AS_NO_EXCEPTIONS"] = self.options.no_exceptions + if not valid_min_cppstd(self, 11): + tc.variables["CMAKE_CXX_STANDARD"] = 11 + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "angelscript", "projects", "cmake")) + cmake.build() + + def _extract_license(self): + header = load(self, os.path.join(self.source_folder, "angelscript", "include", "angelscript.h")) + return header[header.find("/*", 1) + 3 : header.find("*/", 1)] + + def package(self): + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license()) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Angelscript") + self.cpp_info.set_property("cmake_target_name", "Angelscript::angelscript") + postfix = "d" if is_msvc(self) and self.settings.build_type == "Debug" else "" + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["_angelscript"].libs = [f"angelscript{postfix}"] + if self.settings.os in ("Linux", "FreeBSD", "SunOS"): + self.cpp_info.components["_angelscript"].system_libs.append("pthread") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "Angelscript" + self.cpp_info.names["cmake_find_package_multi"] = "Angelscript" + self.cpp_info.components["_angelscript"].names["cmake_find_package"] = "angelscript" + self.cpp_info.components["_angelscript"].names["cmake_find_package_multi"] = "angelscript" + self.cpp_info.components["_angelscript"].set_property("cmake_target_name", "Angelscript::angelscript") diff --git a/recipes/angelscript/all/patches/2.35.0-0001-fix-compatibility-apple-clang.patch b/recipes/angelscript/all/patches/2.35.0-0001-fix-compatibility-apple-clang.patch new file mode 100644 index 0000000000000..acf1d8b621bbf --- /dev/null +++ b/recipes/angelscript/all/patches/2.35.0-0001-fix-compatibility-apple-clang.patch @@ -0,0 +1,30 @@ +--- a/angelscript/projects/cmake/CMakeLists.txt ++++ b/angelscript/projects/cmake/CMakeLists.txt +@@ -110,7 +110,9 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm") + enable_language(ASM) + if(CMAKE_ASM_COMPILER_WORKS) + set(ANGELSCRIPT_SOURCE ${ANGELSCRIPT_SOURCE} ../../source/as_callfunc_arm.cpp ../../source/as_callfunc_arm_gcc.S) ++ if (NOT APPLE) + set_property(SOURCE ../../source/as_callfunc_arm_gcc.S APPEND PROPERTY COMPILE_FLAGS " -Wa,-mimplicit-it=always") ++ endif() + else() + message(FATAL ERROR "ARM target requires a working assembler") + endif() +--- a/angelscript/source/as_callfunc_arm64_gcc.S ++++ b/angelscript/source/as_callfunc_arm64_gcc.S +@@ -46,6 +46,7 @@ + .global CallARM64Float + .global CallARM64 + ++#if !defined(__MACH__) + .type GetHFAReturnDouble, %function + .type GetHFAReturnFloat, %function + .type CallARM64Ret128, %function +@@ -53,6 +54,7 @@ + .type CallARM64Double, %function + .type CallARM64Float, %function + .type CallARM64, %function ++#endif + + .align 2 + GetHFAReturnDouble: diff --git a/recipes/angelscript/all/patches/2.35.1-0001-fix-compatibility-apple-clang.patch b/recipes/angelscript/all/patches/2.35.1-0001-fix-compatibility-apple-clang.patch new file mode 100644 index 0000000000000..49ca65e890f7a --- /dev/null +++ b/recipes/angelscript/all/patches/2.35.1-0001-fix-compatibility-apple-clang.patch @@ -0,0 +1,18 @@ +--- a/angelscript/source/as_callfunc_arm64_gcc.S ++++ b/angelscript/source/as_callfunc_arm64_gcc.S +@@ -50,6 +50,7 @@ + .global CallARM64Float + .global CallARM64 + ++#if !defined(__MACH__) + .type GetHFAReturnDouble, %function + .type GetHFAReturnFloat, %function + .type CallARM64Ret128, %function +@@ -57,6 +58,7 @@ + .type CallARM64Double, %function + .type CallARM64Float, %function + .type CallARM64, %function ++#endif + + .align 2 + GetHFAReturnDouble: diff --git a/recipes/angelscript/all/patches/2.36.0-0001-missing-include-stdint.patch b/recipes/angelscript/all/patches/2.36.0-0001-missing-include-stdint.patch new file mode 100644 index 0000000000000..f2e883bacf543 --- /dev/null +++ b/recipes/angelscript/all/patches/2.36.0-0001-missing-include-stdint.patch @@ -0,0 +1,10 @@ +--- a/angelscript/source/as_context.cpp ++++ b/angelscript/source/as_context.cpp +@@ -36,6 +36,7 @@ + // + + #include // fmodf() pow() ++#include + + #include "as_config.h" + #include "as_context.h" diff --git a/recipes/angelscript/all/test_package/CMakeLists.txt b/recipes/angelscript/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ee85cb2f6cc3c --- /dev/null +++ b/recipes/angelscript/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(Angelscript REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Angelscript::angelscript) diff --git a/recipes/angelscript/all/test_package/conanfile.py b/recipes/angelscript/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/angelscript/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/angelscript/all/test_package/test_package.cpp b/recipes/angelscript/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..06aaa43e191ef --- /dev/null +++ b/recipes/angelscript/all/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include + +#include + +int main() +{ + asIScriptEngine* const engine = asCreateScriptEngine(); + if (engine) { + std::cerr << "successfully created engine" << std::endl; + engine->ShutDownAndRelease(); + return 0; + } else { + std::cerr << "failed to create engine" << std::endl; + return 1; + } +} diff --git a/recipes/angelscript/all/test_v1_package/CMakeLists.txt b/recipes/angelscript/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/angelscript/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/angelscript/all/test_v1_package/conanfile.py b/recipes/angelscript/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a3b9c17e2ea29 --- /dev/null +++ b/recipes/angelscript/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import CMake, ConanFile, tools +import os + + +class AngelScriptTestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/angelscript/config.yml b/recipes/angelscript/config.yml new file mode 100644 index 0000000000000..22190418b16a2 --- /dev/null +++ b/recipes/angelscript/config.yml @@ -0,0 +1,7 @@ +versions: + "2.36.0": + folder: all + "2.35.1": + folder: all + "2.35.0": + folder: all diff --git a/recipes/antlr4-cppruntime/all/conandata.yml b/recipes/antlr4-cppruntime/all/conandata.yml new file mode 100644 index 0000000000000..2605966cb79dc --- /dev/null +++ b/recipes/antlr4-cppruntime/all/conandata.yml @@ -0,0 +1,39 @@ +sources: + "4.9.3": + url: "https://github.com/antlr/antlr4/archive/refs/tags/4.9.3.tar.gz" + sha256: "efe4057d75ab48145d4683100fec7f77d7f87fa258707330cadd1f8e6f7eecae" + "4.10.1": + url: "https://github.com/antlr/antlr4/archive/refs/tags/4.10.1.tar.gz" + sha256: "a320568b738e42735946bebc5d9d333170e14a251c5734e8b852ad1502efa8a2" + "4.11.1": + url: "https://github.com/antlr/antlr4/archive/refs/tags/4.11.1.tar.gz" + sha256: "81f87f03bb83b48da62e4fc8bfdaf447efb9fb3b7f19eb5cbc37f64e171218cf" +patches: + "4.9.3": + - patch_file: "patches/0001-update-cmakelist.patch" + - patch_file: "patches/0004-update-DropLibuuid-4.9.3-1.patch" + patch_description: "Revise the CMakeLists.txt to remove the dependency on libuuid (#1) which is not used since 4.9." + patch_type: "backport" + patch_source: "https://github.com/antlr/antlr4/pull/3787" + - patch_file: "patches/0004-update-DropLibuuid-4.9.3-2.patch" + patch_description: "Revise the CMakeLists.txt to remove the dependency on libuuid (#2) which is not used since 4.9." + patch_type: "backport" + patch_source: "https://github.com/antlr/antlr4/pull/3787" + "4.10.1": + - patch_file: "patches/0004-update-DropLibuuid-4.10.x-1.patch" + patch_description: "Revise the CMakeLists.txt to remove the dependency on libuuid (#1) which is not used since 4.9." + patch_type: "backport" + patch_source: "https://github.com/antlr/antlr4/pull/3787" + - patch_file: "patches/0004-update-DropLibuuid-4.10.x-2.patch" + patch_description: "Revise the CMakeLists.txt to remove the dependency on libuuid (#2) which is not used since 4.9." + patch_type: "backport" + patch_source: "https://github.com/antlr/antlr4/pull/3787" + "4.11.1": + - patch_file: "patches/0002-update-FlatHashSet.patch" + patch_description: "Fix the compiler errors reported by GCC 7 due to the new type FlatHashSet introduced in 4.11." + patch_type: "portability" + patch_source: "https://github.com/antlr/antlr4/pull/3885" + - patch_file: "patches/0003-update-FlatHashMap.patch" + patch_description: "Fix the compiler errors reported by GCC 7 due to the new type FlatHashMap introduced in 4.11." + patch_type: "portability" + patch_source: "https://github.com/antlr/antlr4/pull/3885" diff --git a/recipes/antlr4-cppruntime/all/conanfile.py b/recipes/antlr4-cppruntime/all/conanfile.py new file mode 100644 index 0000000000000..e47c4f36aca6b --- /dev/null +++ b/recipes/antlr4-cppruntime/all/conanfile.py @@ -0,0 +1,167 @@ +from conan import ConanFile +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, check_min_vs +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import export_conandata_patches, apply_conandata_patches, get, copy, rm, rmdir, save +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +import os +import textwrap + +required_conan_version = ">=1.52.0" + + +class Antlr4CppRuntimeConan(ConanFile): + name = "antlr4-cppruntime" + homepage = "https://github.com/antlr/antlr4/tree/master/runtime/Cpp" + description = "C++ runtime support for ANTLR (ANother Tool for Language Recognition)" + topics = ("antlr", "parser", "runtime") + url = "https://github.com/conan-io/conan-center-index" + license = "BSD-3-Clause" + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + short_paths = True + + @property + def _minimum_cpp_standard(self): + # Antlr 4.9.3 requires C++11 while newer versions require C++17 + return 17 if Version(self.version) >= "4.10" else 11 + + @property + def _minimum_compiler_versions_cpp17(self): + return { + "gcc": "7", + "clang": "5", + "apple-clang": "9.1" + } + + def _check_minimum_compiler_version_cpp17(self): + compiler = self.info.settings.compiler + min_compiler_version = self._minimum_compiler_versions_cpp17.get(str(compiler), False) + if min_compiler_version and Version(compiler.version) < min_compiler_version: + raise ConanInvalidConfiguration(f"{self.ref} requires C++17, which your compiler does not support.") + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + # As of 4.11, antlr4-cppruntime no longer requires libuuid. + # Reference: [C++] Remove libuuid dependency (https://github.com/antlr/antlr4/pull/3787) + # Note that the above PR points that libuuid can be removed from 4.9.3, 4.10 and 4.10.1 as well. + # We have patched the CMakeLists.txt to drop the dependency on libuuid from aforementioned antlr versions. + self.requires("utfcpp/3.2.1") + + def validate(self): + # Compilation of this library on version 15 claims C2668 Error. + # This could be Bogus error or malformed Antlr4 library. + # Guard: The minimum MSVC version is 16 or 1920 (which already supports C++17) + check_min_vs(self, "192") + + # Check the minimum C++ standard + min_cppstd = self._minimum_cpp_standard + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, min_cppstd) + # Check the minimum compiler version + if min_cppstd == 17: + self._check_minimum_compiler_version_cpp17() + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ANTLR4_INSTALL"] = True + tc.variables["WITH_LIBCXX"] = self.settings.compiler.get_safe("libcxx") == "libc++" + tc.variables["ANTLR_BUILD_CPP_TESTS"] = False + if is_msvc(self): + tc.cache_variables["WITH_STATIC_CRT"] = is_msvc_static_runtime(self) + tc.variables["WITH_DEMO"] = False + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder="runtime/Cpp") + cmake.build() + + def package(self): + copy(self, "LICENSE.txt", src=os.path.join(self.source_folder), dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + if self.options.shared: + rm(self, "*antlr4-runtime-static.*", os.path.join(self.package_folder, "lib")) + rm(self, "*antlr4-runtime.a", os.path.join(self.package_folder, "lib")) + else: + rm(self, "*.dll", os.path.join(self.package_folder, "bin")) + rm(self, "antlr4-runtime.lib", os.path.join(self.package_folder, "lib")) + rm(self, "*antlr4-runtime.so*", os.path.join(self.package_folder, "lib")) + rm(self, "*antlr4-runtime.dll*", os.path.join(self.package_folder, "lib")) + rm(self, "*antlr4-runtime.*dylib", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "share")) + + # FIXME: this also removes lib/cmake/antlr4-generator + # This cmake config script is needed to provide the cmake function `antlr4_generate` + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once cmake_find_package* generatores removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"antlr4_shared" if self.options.shared else "antlr4_static": "antlr4-cppruntime::antlr4-cppruntime"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "antlr4-runtime") + self.cpp_info.set_property("cmake_target_name", "antlr4_shared" if self.options.shared else "antlr4_static") + libname = "antlr4-runtime" + if is_msvc(self) and not self.options.shared: + libname += "-static" + self.cpp_info.libs = [libname] + self.cpp_info.includedirs.append(os.path.join("include", "antlr4-runtime")) + if self.settings.os == "Windows" and not self.options.shared: + self.cpp_info.defines.append("ANTLR4CPP_STATIC") + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs = ["pthread"] + + # TODO: to remove in conan v2 once cmake_find_package* generatores removed + self.cpp_info.filenames["cmake_find_package"] = "antlr4-runtime" + self.cpp_info.filenames["cmake_find_package_multi"] = "antlr4-runtime" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/antlr4-cppruntime/all/patches/0001-update-cmakelist.patch b/recipes/antlr4-cppruntime/all/patches/0001-update-cmakelist.patch new file mode 100644 index 0000000000000..d42d778ee2d61 --- /dev/null +++ b/recipes/antlr4-cppruntime/all/patches/0001-update-cmakelist.patch @@ -0,0 +1,13 @@ +--- runtime/Cpp/runtime/CMakeLists.txt ++++ runtime/Cpp/runtime/CMakeLists.txt +@@ -141,8 +141,8 @@ + COMPILE_FLAGS "${disabled_compile_warnings} ${extra_static_compile_flags}") + + install(TARGETS antlr4_shared +- DESTINATION lib +- EXPORT antlr4-targets) ++ EXPORT antlr4-targets ++ ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) + install(TARGETS antlr4_static + DESTINATION lib + EXPORT antlr4-targets) diff --git a/recipes/antlr4-cppruntime/all/patches/0002-update-FlatHashSet.patch b/recipes/antlr4-cppruntime/all/patches/0002-update-FlatHashSet.patch new file mode 100644 index 0000000000000..336271b756971 --- /dev/null +++ b/recipes/antlr4-cppruntime/all/patches/0002-update-FlatHashSet.patch @@ -0,0 +1,15 @@ +--- runtime/Cpp/runtime/src/FlatHashSet.h ++++ runtime/Cpp/runtime/src/FlatHashSet.h +@@ -48,9 +48,9 @@ + using FlatHashSet = absl::flat_hash_set; + #else + template ::hasher, +- typename Equal = typename std::unordered_set::key_equal, +- typename Allocator = typename std::unordered_set::allocator_type> ++ typename Hash = std::hash, ++ typename Equal = std::equal_to, ++ typename Allocator = std::allocator> + using FlatHashSet = std::unordered_set; + #endif + diff --git a/recipes/antlr4-cppruntime/all/patches/0003-update-FlatHashMap.patch b/recipes/antlr4-cppruntime/all/patches/0003-update-FlatHashMap.patch new file mode 100644 index 0000000000000..e841ee8933643 --- /dev/null +++ b/recipes/antlr4-cppruntime/all/patches/0003-update-FlatHashMap.patch @@ -0,0 +1,15 @@ +--- runtime/Cpp/runtime/src/FlatHashMap.h ++++ runtime/Cpp/runtime/src/FlatHashMap.h +@@ -48,9 +48,9 @@ + using FlatHashMap = absl::flat_hash_map; + #else + template ::hasher, +- typename Equal = typename std::unordered_map::key_equal, +- typename Allocator = typename std::unordered_map::allocator_type> ++ typename Hash = std::hash, ++ typename Equal = std::equal_to, ++ typename Allocator = std::allocator>> + using FlatHashMap = std::unordered_map; + #endif + diff --git a/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.10.x-1.patch b/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.10.x-1.patch new file mode 100644 index 0000000000000..52e813be947a8 --- /dev/null +++ b/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.10.x-1.patch @@ -0,0 +1,13 @@ +--- runtime/Cpp/CMakeLists.txt ++++ runtime/Cpp/CMakeLists.txt +@@ -41,10 +41,6 @@ + CMAKE_POLICY(SET CMP0054 OLD) + endif() + +-if(CMAKE_SYSTEM_NAME MATCHES "Linux") +- find_package(PkgConfig REQUIRED) +- pkg_check_modules(UUID REQUIRED uuid) +-endif() + if(APPLE) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) + endif() diff --git a/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.10.x-2.patch b/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.10.x-2.patch new file mode 100644 index 0000000000000..f1fffa5599c8b --- /dev/null +++ b/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.10.x-2.patch @@ -0,0 +1,14 @@ +--- runtime/Cpp/runtime/CMakeLists.txt ++++ runtime/Cpp/runtime/CMakeLists.txt +@@ -69,10 +69,7 @@ + gtest_discover_tests(antlr4_tests) + endif() + +-if(CMAKE_SYSTEM_NAME MATCHES "Linux") +- target_link_libraries(antlr4_shared ${UUID_LIBRARIES}) +- target_link_libraries(antlr4_static ${UUID_LIBRARIES}) +-elseif(APPLE) ++if(APPLE) + target_link_libraries(antlr4_shared ${COREFOUNDATION_LIBRARY}) + target_link_libraries(antlr4_static ${COREFOUNDATION_LIBRARY}) + endif() diff --git a/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.9.3-1.patch b/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.9.3-1.patch new file mode 100644 index 0000000000000..6412c93b3d0b5 --- /dev/null +++ b/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.9.3-1.patch @@ -0,0 +1,13 @@ +--- runtime/Cpp/CMakeLists.txt ++++ runtime/Cpp/CMakeLists.txt +@@ -39,10 +39,6 @@ + CMAKE_POLICY(SET CMP0054 OLD) + endif() + +-if(CMAKE_SYSTEM_NAME MATCHES "Linux") +- find_package(PkgConfig REQUIRED) +- pkg_check_modules(UUID REQUIRED uuid) +-endif() + if(APPLE) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) + endif() diff --git a/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.9.3-2.patch b/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.9.3-2.patch new file mode 100644 index 0000000000000..a9b062d8bea5a --- /dev/null +++ b/recipes/antlr4-cppruntime/all/patches/0004-update-DropLibuuid-4.9.3-2.patch @@ -0,0 +1,14 @@ +--- runtime/Cpp/runtime/CMakeLists.txt ++++ runtime/Cpp/runtime/CMakeLists.txt +@@ -75,10 +75,7 @@ + endif() + endif() + +-if(CMAKE_SYSTEM_NAME MATCHES "Linux") +- target_link_libraries(antlr4_shared ${UUID_LIBRARIES}) +- target_link_libraries(antlr4_static ${UUID_LIBRARIES}) +-elseif(APPLE) ++if(APPLE) + target_link_libraries(antlr4_shared ${COREFOUNDATION_LIBRARY}) + target_link_libraries(antlr4_static ${COREFOUNDATION_LIBRARY}) + endif() diff --git a/recipes/antlr4-cppruntime/all/test_package/CMakeLists.txt b/recipes/antlr4-cppruntime/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e1a9346912d37 --- /dev/null +++ b/recipes/antlr4-cppruntime/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(antlr4-runtime REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +if(TARGET antlr4_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE antlr4_shared) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE antlr4_static) +endif() +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/antlr4-cppruntime/all/test_package/conanfile.py b/recipes/antlr4-cppruntime/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/antlr4-cppruntime/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/antlr4-cppruntime/all/test_package/test_package.cpp b/recipes/antlr4-cppruntime/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f8f8a195d6d57 --- /dev/null +++ b/recipes/antlr4-cppruntime/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include "antlr4-runtime/antlr4-runtime.h" + +int main(int argc, const char *args[]) +{ + antlr4::ANTLRInputStream input; + return 0; +} diff --git a/recipes/antlr4-cppruntime/all/test_v1_package/CMakeLists.txt b/recipes/antlr4-cppruntime/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b9ee4c6f88e3f --- /dev/null +++ b/recipes/antlr4-cppruntime/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(antlr4-runtime REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +if(TARGET antlr4_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE antlr4_shared) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE antlr4_static) +endif() +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/antlr4-cppruntime/all/test_v1_package/conanfile.py b/recipes/antlr4-cppruntime/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..90eb89e3f2f46 --- /dev/null +++ b/recipes/antlr4-cppruntime/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/antlr4-cppruntime/config.yml b/recipes/antlr4-cppruntime/config.yml new file mode 100644 index 0000000000000..fd8294e924d85 --- /dev/null +++ b/recipes/antlr4-cppruntime/config.yml @@ -0,0 +1,7 @@ +versions: + "4.9.3": + folder: all + "4.10.1": + folder: all + "4.11.1": + folder: all diff --git a/recipes/any-lite/all/conandata.yml b/recipes/any-lite/all/conandata.yml index 87edc657da904..50c84efb1a3d9 100644 --- a/recipes/any-lite/all/conandata.yml +++ b/recipes/any-lite/all/conandata.yml @@ -1,10 +1,10 @@ sources: - "0.2.0": - url: https://github.com/martinmoene/any-lite/archive/v0.2.0.tar.gz - sha256: 945ac39f14273be742c8a060af100182e38920f641e5d8fa16699e74a09e9850 - "0.3.0": - url: https://github.com/martinmoene/any-lite/archive/v0.3.0.tar.gz - sha256: fa7087ef7b4455c00b4b715649eb7176d6d0806c3a57cd4734845611ebe9888e "0.4.0": - url: https://github.com/martinmoene/any-lite/archive/v0.4.0.tar.gz - sha256: 889549098291a1313d2fc8cd12dcdab13214d05cdce7ed5fe2dc724cdd7b3125 + url: "https://github.com/martinmoene/any-lite/archive/v0.4.0.tar.gz" + sha256: "889549098291a1313d2fc8cd12dcdab13214d05cdce7ed5fe2dc724cdd7b3125" + "0.3.0": + url: "https://github.com/martinmoene/any-lite/archive/v0.3.0.tar.gz" + sha256: "fa7087ef7b4455c00b4b715649eb7176d6d0806c3a57cd4734845611ebe9888e" + "0.2.0": + url: "https://github.com/martinmoene/any-lite/archive/v0.2.0.tar.gz" + sha256: "945ac39f14273be742c8a060af100182e38920f641e5d8fa16699e74a09e9850" diff --git a/recipes/any-lite/all/conanfile.py b/recipes/any-lite/all/conanfile.py index beefaf4c5cc58..19f65824ca091 100644 --- a/recipes/any-lite/all/conanfile.py +++ b/recipes/any-lite/all/conanfile.py @@ -1,7 +1,10 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.50.0" + class AnyLiteConan(ConanFile): name = "any-lite" @@ -9,30 +12,41 @@ class AnyLiteConan(ConanFile): homepage = "https://github.com/martinmoene/any-lite" description = ("any lite - A C++17-like any, a type-safe container for single values of \ any type for C++98, C++11 and later in a single-file header-only library") - topics = ("conan", "cpp11", "cpp14", "cpp17", "any", "any-implementations") + topics = ("cpp11", "cpp14", "cpp17", "any", "any-implementations") license = "BSL-1.0" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "any-lite") + self.cpp_info.set_property("cmake_target_name", "nonstd::any-lite") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "any-lite" self.cpp_info.filenames["cmake_find_package_multi"] = "any-lite" self.cpp_info.names["cmake_find_package"] = "nonstd" self.cpp_info.names["cmake_find_package_multi"] = "nonstd" self.cpp_info.components["anylite"].names["cmake_find_package"] = "any-lite" self.cpp_info.components["anylite"].names["cmake_find_package_multi"] = "any-lite" + self.cpp_info.components["anylite"].set_property("cmake_target_name", "nonstd::any-lite") diff --git a/recipes/any-lite/all/test_package/CMakeLists.txt b/recipes/any-lite/all/test_package/CMakeLists.txt index 4c5e0086991b8..52b8d2bac37bb 100644 --- a/recipes/any-lite/all/test_package/CMakeLists.txt +++ b/recipes/any-lite/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES CXX) find_package(any-lite REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} nonstd::any-lite) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::any-lite) diff --git a/recipes/any-lite/all/test_package/conanfile.py b/recipes/any-lite/all/test_package/conanfile.py index abcaeed3f89b6..d120a992c06a6 100644 --- a/recipes/any-lite/all/test_package/conanfile.py +++ b/recipes/any-lite/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/any-lite/all/test_v1_package/CMakeLists.txt b/recipes/any-lite/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3d223cfc63eee --- /dev/null +++ b/recipes/any-lite/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(any-lite REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::any-lite) diff --git a/recipes/any-lite/all/test_v1_package/conanfile.py b/recipes/any-lite/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/any-lite/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/any-lite/config.yml b/recipes/any-lite/config.yml index ee25f0e067a38..8afd20f5689ba 100644 --- a/recipes/any-lite/config.yml +++ b/recipes/any-lite/config.yml @@ -1,7 +1,7 @@ versions: - "0.2.0": + "0.4.0": folder: all "0.3.0": folder: all - "0.4.0": + "0.2.0": folder: all diff --git a/recipes/anyrpc/all/conandata.yml b/recipes/anyrpc/all/conandata.yml new file mode 100644 index 0000000000000..26dc592b0ce1b --- /dev/null +++ b/recipes/anyrpc/all/conandata.yml @@ -0,0 +1,17 @@ +sources: + "1.0.2": + url: "https://github.com/sgieseking/anyrpc/archive/refs/tags/v1.0.2.tar.gz" + sha256: "236c9fa0ba417af945d950866c9671a1efa06506af8c86efa2e89ab67607969f" +patches: + "1.0.2": + - patch_file: "patches/0001-fix-asan-1.0.2.patch" + patch_description: "Handle ASAN flag properly in CMakeLists.txt" + patch_type: backport + patch_source: "https://github.com/sgieseking/anyrpc/pull/42" + - patch_file: "patches/0002-fix-shared-library-1.0.2.patch" + patch_description: "Fixed 'undefined reference' error when compile for windows platform" + patch_type: backport + patch_source: "https://github.com/sgieseking/anyrpc/pull/43" + - patch_file: "patches/0003-use-conan-libs-1.0.2.patch" + patch_description: "Link to conan libs" + patch_type: "conan" diff --git a/recipes/anyrpc/all/conanfile.py b/recipes/anyrpc/all/conanfile.py new file mode 100644 index 0000000000000..79bf90cb74d72 --- /dev/null +++ b/recipes/anyrpc/all/conanfile.py @@ -0,0 +1,127 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + + +required_conan_version = ">=1.52.0" + + +class AnyRPCConan(ConanFile): + name = "anyrpc" + description = "A multiprotocol remote procedure call system for C++" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/sgieseking/anyrpc" + topics = ("rpc") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_log4cplus": [True, False], + "with_threading": [True, False], + "with_regex": [True, False], + "with_wchar": [True, False], + "with_protocol_json": [True, False], + "with_protocol_xml": [True, False], + "with_protocol_messagepack": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_log4cplus": False, + "with_threading": True, + "with_wchar": True, + "with_regex": True, + "with_protocol_json": True, + "with_protocol_xml": True, + "with_protocol_messagepack": True, + } + + @property + def _minimum_cpp_standard(self): + return 11 + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_log4cplus: + self.requires("log4cplus/2.0.7") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + + if self.info.options.with_log4cplus and self.info.options.with_wchar: + raise ConanInvalidConfiguration(f"{self.ref} can not be built with both log4cplus and wchar, see https://github.com/sgieseking/anyrpc/issues/25") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ANYRPC_LIB_BUILD_SHARED"] = self.options.shared + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_TEST"] = False + tc.variables["BUILD_WITH_ADDRESS_SANITIZE"] = False + + tc.variables["BUILD_WITH_LOG4CPLUS"] = self.options.with_log4cplus + tc.variables["BUILD_WITH_THREADING"] = self.options.with_threading + tc.variables["BUILD_WITH_REGEX"] = self.options.with_regex + tc.variables["BUILD_WITH_WCHAR"] = self.options.with_wchar + + tc.variables["BUILD_PROTOCOL_JSON"] = self.options.with_protocol_json + tc.variables["BUILD_PROTOCOL_XML"] = self.options.with_protocol_xml + tc.variables["BUILD_PROTOCOL_MESSAGEPACK"] = self.options.with_protocol_messagepack + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="license", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + + def package_info(self): + self.cpp_info.libs = ["anyrpc"] + + if not self.options.shared and self.settings.os == "Windows": + self.cpp_info.system_libs.append("ws2_32") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/anyrpc/all/patches/0001-fix-asan-1.0.2.patch b/recipes/anyrpc/all/patches/0001-fix-asan-1.0.2.patch new file mode 100644 index 0000000000000..23a8dc94863a2 --- /dev/null +++ b/recipes/anyrpc/all/patches/0001-fix-asan-1.0.2.patch @@ -0,0 +1,28 @@ +From 74b4fbb92b654a9483ef3ff64b708fda46bd7b2b Mon Sep 17 00:00:00 2001 +From: Falko Axmann +Date: Sun, 12 Jan 2020 12:43:00 +0100 +Subject: [PATCH] Handle ASAN flag properly in CMakeLists.txt + +Because of a typo ("else" instead of "elseif"), the +BUILD_WITH_ADDRESS_SANITIZE option was ignored and on +Linux, anyrpc would always be built with ASAN enabled. +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cfeb604..87991bb 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -63,7 +63,7 @@ if (MSVC) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc" ) + elseif (MINGW) + SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U__STRICT_ANSI__" ) +-else (BUILD_WITH_ADDRESS_SANITIZE) ++elseif (BUILD_WITH_ADDRESS_SANITIZE) + SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer" ) + SET( ASAN_LIBRARY asan ) + endif () +-- +2.36.1.windows.1 + diff --git a/recipes/anyrpc/all/patches/0002-fix-shared-library-1.0.2.patch b/recipes/anyrpc/all/patches/0002-fix-shared-library-1.0.2.patch new file mode 100644 index 0000000000000..bb861d675230e --- /dev/null +++ b/recipes/anyrpc/all/patches/0002-fix-shared-library-1.0.2.patch @@ -0,0 +1,54 @@ +From c8ece5d572bf68a7d0f63405089a7a8d7d6206ee Mon Sep 17 00:00:00 2001 +From: "email@email.com" +Date: Fri, 31 Jul 2020 15:37:29 +0300 +Subject: [PATCH] fixed 'undefined reference' error when compile for windows + platform + +--- + include/anyrpc/json/jsonserver.h | 2 +- + include/anyrpc/messagepack/messagepackserver.h | 2 +- + include/anyrpc/xml/xmlserver.h | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/include/anyrpc/json/jsonserver.h b/include/anyrpc/json/jsonserver.h +index d883b16..000bbd4 100644 +--- a/include/anyrpc/json/jsonserver.h ++++ b/include/anyrpc/json/jsonserver.h +@@ -24,7 +24,7 @@ + namespace anyrpc + { + +-bool JsonRpcHandler(MethodManager* manager, char* request, std::size_t length, Stream &response); ++ANYRPC_API bool JsonRpcHandler(MethodManager* manager, char* request, std::size_t length, Stream &response); + + //////////////////////////////////////////////////////////////////////////////// + +diff --git a/include/anyrpc/messagepack/messagepackserver.h b/include/anyrpc/messagepack/messagepackserver.h +index cc708f8..708bd72 100644 +--- a/include/anyrpc/messagepack/messagepackserver.h ++++ b/include/anyrpc/messagepack/messagepackserver.h +@@ -24,7 +24,7 @@ + namespace anyrpc + { + +-bool MessagePackRpcHandler(MethodManager* manager, char* request, std::size_t length, Stream &response); ++ANYRPC_API bool MessagePackRpcHandler(MethodManager* manager, char* request, std::size_t length, Stream &response); + + //////////////////////////////////////////////////////////////////////////////// + +diff --git a/include/anyrpc/xml/xmlserver.h b/include/anyrpc/xml/xmlserver.h +index 5350ca5..fe0ed23 100644 +--- a/include/anyrpc/xml/xmlserver.h ++++ b/include/anyrpc/xml/xmlserver.h +@@ -24,7 +24,7 @@ + namespace anyrpc + { + +-bool XmlRpcHandler(MethodManager* manager, char* request, std::size_t length, Stream &response); ++ANYRPC_API bool XmlRpcHandler(MethodManager* manager, char* request, std::size_t length, Stream &response); + + //////////////////////////////////////////////////////////////////////////////// + +-- +2.36.1.windows.1 + diff --git a/recipes/anyrpc/all/patches/0003-use-conan-libs-1.0.2.patch b/recipes/anyrpc/all/patches/0003-use-conan-libs-1.0.2.patch new file mode 100644 index 0000000000000..b1c4f4b1d7f2e --- /dev/null +++ b/recipes/anyrpc/all/patches/0003-use-conan-libs-1.0.2.patch @@ -0,0 +1,44 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 2.8) + + Project(AnyRPC CXX) + +-# Some of the cmake find_package files are part of this distribution +-set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +- + # Read out version from "version" file + file(STRINGS "version" ANYRPC_VERSION_FILE) + +@@ -91,7 +88,7 @@ CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/version.h.in" + "${PROJECT_SOURCE_DIR}/include/anyrpc/version.h" ) + + if (BUILD_WITH_LOG4CPLUS) +- find_package( Log4cplus ) +- if (NOT LOG4CPLUS_FOUND) ++ find_package( log4cplus ) ++ if (NOT log4cplus_FOUND) + # the find_package call for Log4cplus doesn't generate an error even if marked as required + message( FATAL_ERROR "LOG4CPLUS library required if BUILD_WITH_LOG4CPLUS on" ) + +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -44,15 +44,15 @@ set(ANYRPC_HEADERS ${ANYRPC_HEADERS} ${ANYRPC_INTERNAL_HEADERS} + + # Add the necessary external library references + if (BUILD_WITH_LOG4CPLUS) +- include_directories(${LOG4CPLUS_INCLUDE_DIRS}) ++ set( LOG4CPLUS_TARGET "log4cplus::log4cplus" ) + add_definitions( -DBUILD_WITH_LOG4CPLUS ) + else () +- set( LOG4CPLUS_LIBRARIES "" ) ++ set( LOG4CPLUS_TARGET "" ) + endif () + + # Create the libraries with these header and source files + add_library( anyrpc ${ANYRPC_LIB_TYPE} ${ANYRPC_SOURCES} ${ANYRPC_HEADERS} ) +-target_link_libraries( anyrpc ${ASAN_LIBRARY} ${LOG4CPLUS_LIBRARIES}) ++target_link_libraries( anyrpc ${ASAN_LIBRARY} ${LOG4CPLUS_TARGET}) + + # Need the winsock library for Windows + if (WIN32) diff --git a/recipes/anyrpc/all/test_package/CMakeLists.txt b/recipes/anyrpc/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f9c6894d75a0f --- /dev/null +++ b/recipes/anyrpc/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_anyrpc CXX) + +find_package(anyrpc REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_anyrpc.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE anyrpc::anyrpc) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/anyrpc/all/test_package/conanfile.py b/recipes/anyrpc/all/test_package/conanfile.py new file mode 100644 index 0000000000000..7f2b358ed020e --- /dev/null +++ b/recipes/anyrpc/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestAnyRpcConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_anyrpc") + self.run(bin_path, env="conanrun") diff --git a/recipes/anyrpc/all/test_package/test_anyrpc.cpp b/recipes/anyrpc/all/test_package/test_anyrpc.cpp new file mode 100644 index 0000000000000..3a1af31f88b40 --- /dev/null +++ b/recipes/anyrpc/all/test_package/test_anyrpc.cpp @@ -0,0 +1,17 @@ +#include +#include + +#include "anyrpc/anyrpc.h" + +void testFunc(anyrpc::Value& params, anyrpc::Value& result) +{ +} + +int main(void) +{ + anyrpc::JsonHttpServer server; + anyrpc::MethodManager* methodManager = server.GetMethodManager(); + methodManager->AddFunction(&testFunc, "testFunc", "Test function"); + + return EXIT_SUCCESS; +} diff --git a/recipes/anyrpc/all/test_v1_package/CMakeLists.txt b/recipes/anyrpc/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..8272097b5b3da --- /dev/null +++ b/recipes/anyrpc/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/anyrpc/all/test_v1_package/conanfile.py b/recipes/anyrpc/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e946eccc88b51 --- /dev/null +++ b/recipes/anyrpc/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestAnyRpcV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_anyrpc") + self.run(bin_path, run_environment=True) diff --git a/recipes/anyrpc/config.yml b/recipes/anyrpc/config.yml new file mode 100644 index 0000000000000..8457ca9a4a8cd --- /dev/null +++ b/recipes/anyrpc/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.2": + folder: all diff --git a/recipes/approvaltests.cpp/all/conandata.yml b/recipes/approvaltests.cpp/all/conandata.yml index 98b291148881b..abc3968a22f1d 100644 --- a/recipes/approvaltests.cpp/all/conandata.yml +++ b/recipes/approvaltests.cpp/all/conandata.yml @@ -1,74 +1,4 @@ sources: - 8.0.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.0.0/ApprovalTests.v.8.0.0.hpp - sha256: e16a97081f8582be951d95a9d53dc611f1f5a84e117a477029890d0b34ae99d6 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.0.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.1.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.1.0/ApprovalTests.v.8.1.0.hpp - sha256: 6212684654b3deec3e54669602832b45bd9d9b6a2f45dbddce23ab5ba91e2d7e - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.1.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.1.1: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.1.1/ApprovalTests.v.8.1.1.hpp - sha256: 19b39976cbe381c64470399bcf40b61d34712fe959396e1cf4b60c9508a28d34 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.1.1/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.2.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.2.0/ApprovalTests.v.8.2.0.hpp - sha256: ef8eeafdef5b1c158e2dc73ba7e12b7697621cbf0c34b175755718f159fa4df8 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.2.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.3.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.3.0/ApprovalTests.v.8.3.0.hpp - sha256: 6e422b22a369c1a4134b68e7ef611e021ffbe43cfd411a81529b92d48fd03f59 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.3.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.4.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.4.0/ApprovalTests.v.8.4.0.hpp - sha256: 65e826aaca1cb9126c7bd41da9f1b4b131ec4cdde57450dda49233578e389bbb - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.4.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.5.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.5.0/ApprovalTests.v.8.5.0.hpp - sha256: ab2bee6487229e4f1f26d578b36ac6a73dfeb0fdab36b2ed774b4575ee544a33 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.5.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.6.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.6.0/ApprovalTests.v.8.6.0.hpp - sha256: eb62bc0aae1996fed35db0ab8571199a694954668c3ce27d5250db6a09b98f06 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.6.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.7.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.7.0/ApprovalTests.v.8.7.0.hpp - sha256: 764f0d441b10739d2cba5fb5aff43d2e4dcd1eb7972cccf884db92eae30c3460 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.7.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.7.1: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.7.1/ApprovalTests.v.8.7.1.hpp - sha256: 8b68e0278ccdc277cf39a59aacfd651c5ca59ff7b1a2604f251dc9162b64a214 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.7.1/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.8.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.8.0/ApprovalTests.v.8.8.0.hpp - sha256: fa572c13dd27c885427dc3539813518502456545993f9eb32b8eb5c5c388d857 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.8.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.8.1: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.8.1/ApprovalTests.v.8.8.1.hpp - sha256: 5fb945e50d37b1cdfdd35aacdd93dab58f0d1c6814f8792c79f7c4aa521f9f40 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.8.1/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.9.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.9.0/ApprovalTests.v.8.9.0.hpp - sha256: eaba5a46ab4406f5bd5c735ae26f453a957b664662c5febe1dad7de88718988d - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.9.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 8.9.1: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.9.1/ApprovalTests.v.8.9.1.hpp - sha256: 8c27eefe37355aaf6f8b8d1ecb23a1354c0c5af97725f105182f1eb1fd17ee3c - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.8.9.1/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 8.9.2: - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.8.9.2/ApprovalTests.v.8.9.2.hpp sha256: e743f1b83afb045cb9bdee310e438a3ed610a549240e4b4c4c995e548c773da5 @@ -79,83 +9,33 @@ sources: sha256: cae3599dc29bd50c2cf48967e209c854e7b867ecdc8a5aec143b6fb4a7dcc739 - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.9.0.0/LICENSE" sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.0.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.0.0/ApprovalTests.v.10.0.0.hpp - sha256: 3d1beff2305b067f12a56cc79f0f091fde6cb9edc02fcbfef28c26e24352976c - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.0.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.0.1: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.0.1/ApprovalTests.v.10.0.1.hpp - sha256: 62dad6a3803a49e2281497c07f64e0396503b8e99a474293383acb7be98a69ef - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.0.1/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.1.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.1.0/ApprovalTests.v.10.1.0.hpp - sha256: 031cdaeeb31d3b78aed5a6e13fc80c4d1ec607932703b38066ac2afb9b2bb2f8 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.1.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.1.1: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.1.1/ApprovalTests.v.10.1.1.hpp - sha256: 3d4109bb926f53e18c12b14de934baad8c6464c220076293b63a63155a82f754 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.1.1/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.1.2: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.1.2/ApprovalTests.v.10.1.2.hpp - sha256: 614af9434a821df39b0ffbc79ac079f2e025eb19db32e1891e9e082729b70ddc - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.1.2/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.2.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.2.0/ApprovalTests.v.10.2.0.hpp - sha256: 6d699ba637213c30ef09dfc43cb3e9ce114044f593aeea9a94e88d8baa74d33a - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.2.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.2.1: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.2.1/ApprovalTests.v.10.2.1.hpp - sha256: 9a080f5f7c502998a08e1213fd66a884ca278e764e6555bb5eb305810adc28cc - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.2.1/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.3.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.3.0/ApprovalTests.v.10.3.0.hpp - sha256: 2d86c0c2e09627620e065bbebae5676c7f69e78431bb82f1f7d74334275c9af9 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.3.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.4.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.4.0/ApprovalTests.v.10.4.0.hpp - sha256: 36d8a0eb9c1765e745e8a2da7cbdc6546206e17410a04b7572757ee2c3a67d55 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.4.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.5.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.5.0/ApprovalTests.v.10.5.0.hpp - sha256: 6f922787d3590d38d4fa2e42fe2c33cba1a04eed8e80aa420c2eb999bf21f671 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.5.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.5.1: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.5.1/ApprovalTests.v.10.5.1.hpp - sha256: 9097155f20631fd7e0cebe86a1d5744fe2b0d76a1ce7f7b4f63f0368c71a7d5e - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.5.1/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.6.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.6.0/ApprovalTests.v.10.6.0.hpp - sha256: e4ae4a5fa19cb2a2b723bdbef940fd6e0c6f0e18dc6ee0e7b10b88218a33d7dc - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.6.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.7.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.7.0/ApprovalTests.v.10.7.0.hpp - sha256: bfb1cc074cef756e0310cdf666116932a6779ba002a11ba9f4db7558ded28f04 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.7.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.7.1: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.7.1/ApprovalTests.v.10.7.1.hpp - sha256: 453eff5d04dcfdc566690df8393bf02f21aced80f5ec03068d00111632a7b549 - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.7.1/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 - 10.8.0: - - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.8.0/ApprovalTests.v.10.8.0.hpp - sha256: adcc8ac09777f62eda5dcb721d6c1ebc9f22a621997c761920c9d3858c4d3eff - - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.8.0/LICENSE" - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 10.9.1: - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.9.1/ApprovalTests.v.10.9.1.hpp sha256: 65aa9ab1afa1b9c2df5890274010eed0f8c2f57b08a81c5cb719b71a0ad9d14c - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.9.1/LICENSE" sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 + 10.10.0: + - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.10.0/ApprovalTests.v.10.10.0.hpp + sha256: e8fbe19011adad46d8a6309b1e2112fb9de729dddaa12f5fd9dfd6adb44dba2e + - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.10.0/LICENSE" + sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 + 10.11.0: + - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.11.0/ApprovalTests.v.10.11.0.hpp + sha256: 7f4efb835d59b2f31c3dc8a6f35335ad621da538ccb09abf2037d29d4f13f0b2 + - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.11.0/LICENSE" + sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 + 10.12.0: + - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.12.0/ApprovalTests.v.10.12.0.hpp + sha256: 5084ad71b8cc73ea9d753685b652d8828842335a59ab93a2199ceac879a4b292 + - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.12.0/LICENSE" + sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 + 10.12.1: + - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.12.1/ApprovalTests.v.10.12.1.hpp + sha256: 5e87f2e4b39f027676c9259c3edd4a4a8078c0814cdfb371718ef0eb685477c2 + - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.12.1/LICENSE" + sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 + 10.12.2: + - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.12.2/ApprovalTests.v.10.12.2.hpp + sha256: 4c43d0ea98669e3d6fbb5810cc47b19adaf88cabb1421b488aa306b08c434131 + - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.12.2/LICENSE" + sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 diff --git a/recipes/approvaltests.cpp/all/conanfile.py b/recipes/approvaltests.cpp/all/conanfile.py index 15193eade5562..c21feb556bea3 100644 --- a/recipes/approvaltests.cpp/all/conanfile.py +++ b/recipes/approvaltests.cpp/all/conanfile.py @@ -1,7 +1,9 @@ -import os - from conans import ConanFile, tools from conans.tools import Version, ConanInvalidConfiguration +from conan.tools.files import rename + + +required_conan_version = ">=1.43.0" class ApprovalTestsCppConan(ConanFile): @@ -12,7 +14,7 @@ class ApprovalTestsCppConan(ConanFile): description = "Approval Tests allow you to verify a chunk of output " \ "(such as a file) in one operation as opposed to writing " \ "test assertions for each element." - topics = ("conan", "testing", "unit-testing", "header-only") + topics = ("testing", "unit-testing", "header-only") options = { "with_boosttest": [True, False], "with_catch2": [True, False], @@ -28,39 +30,43 @@ class ApprovalTestsCppConan(ConanFile): "with_cpputest": False, } no_copy_source = True - settings = "compiler" + settings = "compiler", "os", "build_type", "arch" + + @property + def _header_file(self): + return "ApprovalTests.hpp" def configure(self): if not self._boost_test_supported(): del self.options.with_boosttest if not self._cpputest_supported(): del self.options.with_cpputest - self._validate_compiler_settings() - @property - def _header_file(self): - return "ApprovalTests.hpp" + def validate(self): + self._validate_compiler_settings() def requirements(self): if self.options.get_safe("with_boosttest"): self.requires("boost/1.72.0") if self.options.with_catch2: - self.requires("catch2/2.11.0") + self.requires("catch2/2.13.7") if self.options.with_gtest: self.requires("gtest/1.10.0") if self.options.with_doctest: - self.requires("doctest/2.3.6") + self.requires("doctest/2.4.6") if self.options.get_safe("with_cpputest"): self.requires("cpputest/4.0") + def package_id(self): + self.info.header_only() + def source(self): for source in self.conan_data["sources"][self.version]: url = source["url"] filename = url[url.rfind("/") + 1:] tools.download(url, filename) tools.check_sha256(filename, source["sha256"]) - os.rename("ApprovalTests.v.{}.hpp".format(self.version), - self._header_file) + rename(self, "ApprovalTests.v.{}.hpp".format(self.version), self._header_file) def package(self): self.copy(self._header_file, dst="include") @@ -70,9 +76,6 @@ def package_info(self): self.cpp_info.names["cmake_find_package"] = "ApprovalTests" self.cpp_info.names["cmake_find_package_multi"] = "ApprovalTests" - def package_id(self): - self.info.header_only() - def _boost_test_supported(self): return Version(self.version) >= "8.6.0" diff --git a/recipes/approvaltests.cpp/all/test_package/CMakeLists.txt b/recipes/approvaltests.cpp/all/test_package/CMakeLists.txt index 1f1e695622657..d603257402203 100644 --- a/recipes/approvaltests.cpp/all/test_package/CMakeLists.txt +++ b/recipes/approvaltests.cpp/all/test_package/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -CONAN_BASIC_SETUP() +CONAN_BASIC_SETUP(TARGETS) find_package(ApprovalTests REQUIRED CONFIG) @@ -30,3 +30,6 @@ if(WITH_CPPUTEST) ADD_EXECUTABLE(test_package_cpputest test_cpputest.cpp) target_link_libraries(test_package_cpputest ApprovalTests::ApprovalTests) endif() + +ADD_EXECUTABLE(test_package test_package.cpp) +target_link_libraries(test_package ApprovalTests::ApprovalTests) diff --git a/recipes/approvaltests.cpp/all/test_package/conanfile.py b/recipes/approvaltests.cpp/all/test_package/conanfile.py index 6876c46b49167..819202453d307 100644 --- a/recipes/approvaltests.cpp/all/test_package/conanfile.py +++ b/recipes/approvaltests.cpp/all/test_package/conanfile.py @@ -6,19 +6,12 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "arch", "build_type" generators = "cmake", "cmake_find_package_multi" - default_options = { - "approvaltests.cpp:with_boosttest": True, - "approvaltests.cpp:with_catch2": True, - "approvaltests.cpp:with_gtest": True, - "approvaltests.cpp:with_doctest": True, - "approvaltests.cpp:with_cpputest": True - } def build(self): cmake = CMake(self) - if self.options["approvaltests.cpp"].with_boosttest and self._boost_test_supported(): + if self._boost_test_supported() and self.options["approvaltests.cpp"].with_boosttest: cmake.definitions["WITH_BOOSTTEST"] = True if self.options["approvaltests.cpp"].with_catch2: cmake.definitions["WITH_CATCH"] = True @@ -26,19 +19,20 @@ def build(self): cmake.definitions["WITH_GTEST"] = True if self.options["approvaltests.cpp"].with_doctest: cmake.definitions["WITH_DOCTEST"] = True - if self.options["approvaltests.cpp"].with_cpputest and self._cpputest_supported(): + if self._cpputest_supported() and self.options["approvaltests.cpp"].with_cpputest: cmake.definitions["WITH_CPPUTEST"] = True cmake.configure() cmake.build() def test(self): - if tools.cross_building(self.settings): + if tools.cross_building(self): self.output.warn("Skipping run cross built package") return bin_path = os.path.join("bin", "test_package") - if self.options["approvaltests.cpp"].with_boosttest and self._boost_test_supported(): + self.run(bin_path, run_environment=True) + if self._boost_test_supported() and self.options["approvaltests.cpp"].with_boosttest: print("Running Boost") self.run(bin_path + "_boosttest", run_environment=True) if self.options["approvaltests.cpp"].with_catch2: @@ -50,7 +44,7 @@ def test(self): if self.options["approvaltests.cpp"].with_doctest: print("Running DocTest") self.run(bin_path + "_doctest", run_environment=True) - if self.options["approvaltests.cpp"].with_cpputest and self._cpputest_supported(): + if self._cpputest_supported() and self.options["approvaltests.cpp"].with_cpputest: print("Running CppUTest") self.run(bin_path + "_cpputest", run_environment=True) diff --git a/recipes/approvaltests.cpp/all/test_package/test_package.cpp b/recipes/approvaltests.cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2618ff65967f1 --- /dev/null +++ b/recipes/approvaltests.cpp/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include +#include + +#include "ApprovalTests.hpp" + + +int main(void) { + std::cout << ApprovalTests::StringMaker::toString(42) << std::endl; + return EXIT_SUCCESS; +} diff --git a/recipes/approvaltests.cpp/config.yml b/recipes/approvaltests.cpp/config.yml index 647c24a1498ee..e0b0401ce3f13 100644 --- a/recipes/approvaltests.cpp/config.yml +++ b/recipes/approvaltests.cpp/config.yml @@ -1,65 +1,17 @@ versions: - 8.0.0: - folder: all - 8.1.0: - folder: all - 8.1.1: - folder: all - 8.2.0: - folder: all - 8.3.0: - folder: all - 8.4.0: - folder: all - 8.5.0: - folder: all - 8.6.0: - folder: all - 8.7.0: - folder: all - 8.7.1: - folder: all - 8.8.0: - folder: all - 8.8.1: - folder: all - 8.9.0: - folder: all - 8.9.1: - folder: all 8.9.2: folder: all 9.0.0: folder: all - 10.0.0: - folder: all - 10.0.1: - folder: all - 10.1.0: - folder: all - 10.1.1: - folder: all - 10.1.2: - folder: all - 10.2.0: - folder: all - 10.2.1: - folder: all - 10.3.0: - folder: all - 10.4.0: - folder: all - 10.5.0: - folder: all - 10.5.1: + 10.9.1: folder: all - 10.6.0: + 10.10.0: folder: all - 10.7.0: + 10.11.0: folder: all - 10.7.1: + 10.12.0: folder: all - 10.8.0: + 10.12.1: folder: all - 10.9.1: + 10.12.2: folder: all diff --git a/recipes/apr-util/all/CMakeLists.txt b/recipes/apr-util/all/CMakeLists.txt index a69305eb3971f..2a122ebfa3606 100644 --- a/recipes/apr-util/all/CMakeLists.txt +++ b/recipes/apr-util/all/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) +project(cmake_wrapper C) include(conanbuildinfo.cmake) conan_basic_setup() diff --git a/recipes/apr-util/all/conanfile.py b/recipes/apr-util/all/conanfile.py index d676c66675672..f7c03746e3c19 100644 --- a/recipes/apr-util/all/conanfile.py +++ b/recipes/apr-util/all/conanfile.py @@ -1,17 +1,16 @@ from conans import AutoToolsBuildEnvironment, ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration -import glob import os -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.33.0" class AprUtilConan(ConanFile): name = "apr-util" description = "The Apache Portable Runtime (APR) provides a predictable and consistent interface to underlying platform-specific implementations" license = "Apache-2.0" - topics = ("conan", "apr-util", "apache", "platform", "library") + topics = ("apr-util", "apache", "platform", "library") homepage = "https://apr.apache.org/" url = "https://github.com/conan-io/conan-center-index" exports_sources = "CMakeLists.txt", "patches/**" @@ -72,8 +71,11 @@ def _build_subfolder(self): def requirements(self): self.requires("apr/1.7.0") + if self.settings.os != "Windows": + #cmake build doesn't allow injection of iconv yet + self.requires("libiconv/1.16") if self.options.with_openssl: - self.requires("openssl/1.1.1j") + self.requires("openssl/1.1.1k") if self.options.with_nss: # self.requires("nss/x.y.z") raise ConanInvalidConfiguration("CCI has no nss recipe (yet)") @@ -96,17 +98,17 @@ def requirements(self): # self.requires("ldap/x.y.z") raise ConanInvalidConfiguration("CCI has no ldap recipe (yet)") if self.options.with_mysql: - self.requires("libmysqlclient/8.0.17") + self.requires("libmysqlclient/8.0.25") if self.options.with_sqlite3: - self.requires("sqlite3/3.35.1") + self.requires("sqlite3/3.35.5") if self.options.with_expat: - self.requires("expat/2.2.10") + self.requires("expat/2.4.1") if self.options.with_postgresql: self.requires("libpq/13.2") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def validate(self): if self.options.shared != self.options["apr"].shared: @@ -139,6 +141,7 @@ def _configure_autotools(self): conf_args = [ "--with-apr={}".format(tools.unix_path(self.deps_cpp_info["apr"].rootpath)), "--with-crypto" if self._with_crypto else "--without-crypto", + "--with-iconv={}".format(tools.unix_path(self.deps_cpp_info["libiconv"].rootpath)), "--with-openssl={}".format(tools.unix_path(self.deps_cpp_info["openssl"].rootpath)) if self.options.with_openssl else "--without-openssl", "--with-expat={}".format(tools.unix_path(self.deps_cpp_info["expat"].rootpath)) if self.options.with_expat else "--without-expat", "--with-mysql={}".format(tools.unix_path(self.deps_cpp_info["libmysqlclient"].rootpath)) if self.options.with_mysql else "--without-mysql", @@ -176,8 +179,7 @@ def package(self): autotools = self._configure_autotools() autotools.install() - for file in glob.glob(os.path.join(self.package_folder, "lib", "apr-util-1", "*.la")): - os.unlink(file) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib", "apr-util-1"), "*.la") os.unlink(os.path.join(self.package_folder, "lib", "libaprutil-1.la")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) @@ -191,8 +193,6 @@ def package_info(self): self.cpp_info.system_libs = ["dl", "pthread", "rt"] elif self.settings.os == "Windows": self.cpp_info.system_libs = ["mswsock", "rpcrt4", "ws2_32"] - elif self.settings.os == "Macos": - self.cpp_info.system_libs = ["iconv"] binpath = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH env var : {}".format(binpath)) diff --git a/recipes/apr/all/conandata.yml b/recipes/apr/all/conandata.yml index 2204119221b51..761248b72bbad 100644 --- a/recipes/apr/all/conandata.yml +++ b/recipes/apr/all/conandata.yml @@ -12,3 +12,7 @@ patches: patch_file: "patches/0003-cmake-gen_test_char-use-target.patch" - base_path: "source_subfolder" patch_file: "patches/0004-autotools-mingw.patch" + - base_path: "source_subfolder" + patch_file: "patches/0005-clang12-apple.patch" + - base_path: "source_subfolder" + patch_file: "patches/0006-sys_siglist-fix.patch" diff --git a/recipes/apr/all/conanfile.py b/recipes/apr/all/conanfile.py index 2d77b6a299e90..f11328e35d47d 100644 --- a/recipes/apr/all/conanfile.py +++ b/recipes/apr/all/conanfile.py @@ -1,18 +1,19 @@ -import os -import re from conans import AutoToolsBuildEnvironment, ConanFile, CMake, tools from conans.errors import ConanException, ConanInvalidConfiguration +import os +import re + +required_conan_version = ">=1.36.0" class AprConan(ConanFile): name = "apr" description = "The Apache Portable Runtime (APR) provides a predictable and consistent interface to underlying platform-specific implementations" license = "Apache-2.0" - topics = ("conan", "apr", "apache", "platform", "library") + topics = ("apache", "platform", "library") homepage = "https://apr.apache.org/" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -25,9 +26,29 @@ class AprConan(ConanFile): "force_apr_uuid": True, } + generators = "cmake" _autotools = None _cmake = None + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _should_call_autoreconf(self): + return self.settings.compiler == "apple-clang" and \ + tools.Version(self.settings.compiler.version) >= "12" and \ + self.version == "1.7.0" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -38,22 +59,17 @@ def configure(self): del self.settings.compiler.cppstd del self.settings.compiler.libcxx - if (self.settings.compiler == "apple-clang" and - tools.Version(self.settings.compiler.version) == "12" and - self.version == "1.7.0"): - raise ConanInvalidConfiguration("apr does not (yet) support apple-clang 12") + def validate(self): + if hasattr(self, "settings_build") and tools.cross_building(self): + raise ConanInvalidConfiguration("apr cannot be cross compiled due to runtime checks") - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def build_requirements(self): + if self._should_call_autoreconf: + self.build_requires("libtool/2.4.6") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -75,14 +91,14 @@ def _configure_autotools(self): "--enable-shared={}".format(yes_no(self.options.shared)), "--enable-static={}".format(yes_no(not self.options.shared)), ] - if tools.cross_building(self.settings): + if tools.cross_building(self): # conf_args.append("apr_cv_mutex_robust_shared=yes") self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) return self._autotools def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) if self.options.force_apr_uuid: tools.replace_in_file(os.path.join(self._source_subfolder, "include", "apr.h.in"), @@ -94,6 +110,9 @@ def build(self): cmake = self._configure_cmake() cmake.build(target="libapr-1" if self.options.shared else "apr-1") else: + if self._should_call_autoreconf: + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) autotools = self._configure_autotools() autotools.make() @@ -119,22 +138,18 @@ def package(self): open(apr_rules_mk, "w").write(apr_rules_cnt) def package_info(self): - self.cpp_info.names["pkg_config"] = "apr-1" - self.cpp_info.libs = ["apr-1"] + self.cpp_info.set_property("pkg_config_name", "apr-1") + self.cpp_info.libs = ["libapr-1" if self.settings.compiler == "Visual Studio" and self.options.shared else "apr-1"] if not self.options.shared: self.cpp_info.defines = ["APR_DECLARE_STATIC"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["dl", "pthread"] if self.settings.os == "Windows": self.cpp_info.system_libs = ["rpcrt4"] - apr_root = self.package_folder - if tools.os_info.is_windows: - apr_root = tools.unix_path(apr_root) + apr_root = tools.unix_path(self.package_folder) self.output.info("Settings APR_ROOT environment var: {}".format(apr_root)) self.env_info.APR_ROOT = apr_root - apr_mk_dir = os.path.join(self.package_folder, "bin", "build-1") - if tools.os_info.is_windows: - apr_mk_dir = tools.unix_path(apr_mk_dir) + apr_mk_dir = tools.unix_path(os.path.join(self.package_folder, "bin", "build-1")) self.env_info._APR_BUILDDIR = apr_mk_dir diff --git a/recipes/apr/all/patches/0001-cmake-build-only-shared-static.patch b/recipes/apr/all/patches/0001-cmake-build-only-shared-static.patch index d14b9a0f600b3..193b94f19acb4 100644 --- a/recipes/apr/all/patches/0001-cmake-build-only-shared-static.patch +++ b/recipes/apr/all/patches/0001-cmake-build-only-shared-static.patch @@ -1,6 +1,6 @@ --- CMakeLists.txt +++ CMakeLists.txt -@@ -258,27 +258,27 @@ +@@ -258,27 +258,26 @@ SET(install_targets) SET(install_bin_pdb) @@ -11,7 +11,6 @@ SET(install_bin_pdb ${install_bin_pdb} ${PROJECT_BINARY_DIR}/libapr-1.pdb) TARGET_LINK_LIBRARIES(libapr-1 ${APR_SYSTEM_LIBS}) SET_TARGET_PROPERTIES(libapr-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_EXPORT;WINNT") -+SET_TARGET_PROPERTIES(libapr-1 PROPERTIES PREFIX "" OUTPUT_NAME "apr-1") ADD_DEPENDENCIES(libapr-1 test_char_header) - +ELSE() diff --git a/recipes/apr/all/patches/0005-clang12-apple.patch b/recipes/apr/all/patches/0005-clang12-apple.patch new file mode 100644 index 0000000000000..18a21b9587705 --- /dev/null +++ b/recipes/apr/all/patches/0005-clang12-apple.patch @@ -0,0 +1,12 @@ +diff --git a/build/apr_common.m4 b/build/apr_common.m4 +index f4e2dfd..01d9a44 100644 +--- build/apr_common.m4 ++++ build/apr_common.m4 +@@ -467,6 +467,7 @@ changequote([, ])dnl + AC_MSG_CHECKING(size of $2) + AC_CACHE_VAL(AC_CV_NAME, + [AC_TRY_RUN([#include ++#include + $1 + #ifdef WIN32 + #define binmode "b" diff --git a/recipes/apr/all/patches/0006-sys_siglist-fix.patch b/recipes/apr/all/patches/0006-sys_siglist-fix.patch new file mode 100644 index 0000000000000..eca8b4d71dfee --- /dev/null +++ b/recipes/apr/all/patches/0006-sys_siglist-fix.patch @@ -0,0 +1,13 @@ +diff --git a/threadproc/unix/signals.c b/threadproc/unix/signals.c +index c735eab..e8b44c3 100644 +--- a/threadproc/unix/signals.c ++++ b/threadproc/unix/signals.c +@@ -116,7 +116,7 @@ void apr_signal_init(apr_pool_t *pglobal) + } + const char *apr_signal_description_get(int signum) + { +- return (signum >= 0) ? sys_siglist[signum] : "unknown signal (number)"; ++ return (signum >= 0) ? strsignal(signum) : "unknown signal (number)"; + } + + #else /* !(SYS_SIGLIST_DECLARED || HAVE_DECL_SYS_SIGLIST) */ diff --git a/recipes/apr/all/test_package/conanfile.py b/recipes/apr/all/test_package/conanfile.py index 4aebe114eeb59..5c09494bc67c0 100644 --- a/recipes/apr/all/test_package/conanfile.py +++ b/recipes/apr/all/test_package/conanfile.py @@ -1,10 +1,9 @@ -import os - from conans import ConanFile, CMake, tools +import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake" def build(self): @@ -13,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/apriltag/all/conandata.yml b/recipes/apriltag/all/conandata.yml index 210b4bdacf9e5..9defb865f3be5 100644 --- a/recipes/apriltag/all/conandata.yml +++ b/recipes/apriltag/all/conandata.yml @@ -1,14 +1,20 @@ sources: - "3.1.1": - url: "https://github.com/AprilRobotics/apriltag/archive/3.1.1.tar.gz" - sha256: "7349e1fcc8b2979230b46c0d62ccf2ba2bbd611d87ef80cfd37ffe74425f5efb" + "3.1.4": + url: "https://github.com/AprilRobotics/apriltag/archive/refs/tags/v3.1.4.tar.gz" + sha256: "ad2888d432e9ddcad2f639f243479934a4cd677ed5d2f8dee3b3418617b64f5d" "3.1.2": url: "https://github.com/AprilRobotics/apriltag/archive/3.1.2.tar.gz" sha256: "2759b044ff1dc9ef725e7c456b49283399ef78deee24754bc3617cbe369584f1" -patches: "3.1.1": - - patch_file: "patches/fix-cmake-3.1.1.patch" + url: "https://github.com/AprilRobotics/apriltag/archive/3.1.1.tar.gz" + sha256: "7349e1fcc8b2979230b46c0d62ccf2ba2bbd611d87ef80cfd37ffe74425f5efb" +patches: + "3.1.4": + - patch_file: "patches/fix-cmake-3.1.4.patch" base_path: "source_subfolder" "3.1.2": - patch_file: "patches/fix-cmake-3.1.2.patch" base_path: "source_subfolder" + "3.1.1": + - patch_file: "patches/fix-cmake-3.1.1.patch" + base_path: "source_subfolder" diff --git a/recipes/apriltag/all/conanfile.py b/recipes/apriltag/all/conanfile.py index db1fa64fa8655..27b7916fdd4a2 100644 --- a/recipes/apriltag/all/conanfile.py +++ b/recipes/apriltag/all/conanfile.py @@ -1,46 +1,63 @@ +from conans import ConanFile, tools, CMake +from conans.errors import ConanInvalidConfiguration import os -import stat -from conans import ConanFile, tools, CMake, AutoToolsBuildEnvironment -from conans.errors import ConanException,ConanInvalidConfiguration -class apriltagConan(ConanFile): + +class ApriltagConan(ConanFile): name = "apriltag" - license = "BSD-2-Clause" - homepage = "https://april.eecs.umich.edu/software/apriltag" - url = "https://github.com/conan-io/conan-center-index" description = ("AprilTag is a visual fiducial system, useful for a wide variety of tasks \ including augmented reality, robotics, and camera calibration") + homepage = "https://april.eecs.umich.edu/software/apriltag" + topics = ("conan", "apriltag", "robotics") + license = "BSD-2-Clause" + url = "https://github.com/conan-io/conan-center-index" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {'shared': False, "fPIC": True} + generators = "cmake" - topics = ("conan", "apriltag", "robotics") - exports_sources = ["CMakeLists.txt", "patches/*"] + exports_sources = "CMakeLists.txt", "patches/*" + _cmake = None @property def _source_subfolder(self): return "source_subfolder" - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC def configure(self): - if self.settings.os != "Linux": - raise ConanInvalidConfiguration("Apriltag officially supported only on Linux") + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("Apriltag officially supported only on Linux") + def source(self): tools.get(**self.conan_data["sources"][self.version]) extracted_dir = self.name + "-" + self.version os.rename(extracted_dir, self._source_subfolder) + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure() + return self._cmake + def build(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) cmake = self._configure_cmake() cmake.build() @@ -54,7 +71,10 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "bin")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.names["cmake_find_package"] = "apriltag" + self.cpp_info.names["cmake_find_package_multi"] = "apriltag" + + self.cpp_info.libs = ["apriltag"] if self.settings.os == "Linux": self.cpp_info.system_libs = ["m", "pthread"] - self.cpp_info.includedirs = ["include",os.path.join("include","apriltag")] + self.cpp_info.includedirs.append(os.path.join("include","apriltag")) diff --git a/recipes/apriltag/all/patches/fix-cmake-3.1.1.patch b/recipes/apriltag/all/patches/fix-cmake-3.1.1.patch index b5fce30f4ccc2..7936b47c2a56a 100644 --- a/recipes/apriltag/all/patches/fix-cmake-3.1.1.patch +++ b/recipes/apriltag/all/patches/fix-cmake-3.1.1.patch @@ -10,7 +10,8 @@ aux_source_directory(common COMMON_SRC) aux_source_directory(. APRILTAG_SRCS) @@ -10,7 +8,8 @@ - set(CMAKE_BUILD_TYPE Release) +-set(CMAKE_BUILD_TYPE Release) ++#set(CMAKE_BUILD_TYPE Release) # Library -add_library(${PROJECT_NAME} SHARED ${APRILTAG_SRCS} ${COMMON_SRC}) diff --git a/recipes/apriltag/all/patches/fix-cmake-3.1.2.patch b/recipes/apriltag/all/patches/fix-cmake-3.1.2.patch index a02c8259458e8..15f084446a276 100644 --- a/recipes/apriltag/all/patches/fix-cmake-3.1.2.patch +++ b/recipes/apriltag/all/patches/fix-cmake-3.1.2.patch @@ -12,7 +12,8 @@ index c733c6c..540c38e 100644 aux_source_directory(common COMMON_SRC) set(APRILTAG_SRCS apriltag.c apriltag_pose.c apriltag_quad_thresh.c) @@ -10,9 +8,10 @@ set(APRILTAG_SRCS apriltag.c apriltag_pose.c apriltag_quad_thresh.c) - set(CMAKE_BUILD_TYPE Release) +-set(CMAKE_BUILD_TYPE Release) ++#set(CMAKE_BUILD_TYPE Release) # Library -file(GLOB TAG_FILES ${CMAKE_SOURCE_DIR}/tag*.c) diff --git a/recipes/apriltag/all/patches/fix-cmake-3.1.4.patch b/recipes/apriltag/all/patches/fix-cmake-3.1.4.patch new file mode 100644 index 0000000000000..9a916a9d74403 --- /dev/null +++ b/recipes/apriltag/all/patches/fix-cmake-3.1.4.patch @@ -0,0 +1,43 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -1,7 +1,7 @@ + cmake_minimum_required(VERSION 3.1) + project(apriltag) + +-find_package(OpenCV QUIET) ++#find_package(OpenCV QUIET) + + include_directories(.) + aux_source_directory(common COMMON_SRC) +@@ -10,9 +10,9 @@ +-set(CMAKE_BUILD_TYPE Release) ++#set(CMAKE_BUILD_TYPE Release) +- + # Library + file(GLOB TAG_FILES ${PROJECT_SOURCE_DIR}/tag*.c) + set_source_files_properties(SOURCE ${TAG_FILES} PROPERTIES COMPILE_FLAGS -O0) +-add_library(${PROJECT_NAME} SHARED ${APRILTAG_SRCS} ${COMMON_SRC} ${TAG_FILES}) ++add_library(${PROJECT_NAME} ${APRILTAG_SRCS} ${COMMON_SRC} ${TAG_FILES}) ++set_target_properties(${PROJECT_NAME} PROPERTIES C_STANDARD 99) + if (MSVC) + # FindThreads will not find pthread.h with MSVC + # winmm is necessary for __imp_timeGetTime +@@ -103,4 +103,4 @@ + # Examples +-# apriltag_demo + add_executable(apriltag_demo example/apriltag_demo.c) ++set_target_properties(apriltag_demo PROPERTIES C_STANDARD 99) + target_link_libraries(apriltag_demo apriltag) +@@ -108,10 +108,10 @@ +-# opencv_demo ++if(0) + if(OpenCV_FOUND) + add_executable(opencv_demo example/opencv_demo.cc) + target_link_libraries(opencv_demo apriltag ${OpenCV_LIBRARIES}) + set_target_properties(opencv_demo PROPERTIES CXX_STANDARD 11) + install(TARGETS opencv_demo RUNTIME DESTINATION bin) + endif(OpenCV_FOUND) +- ++endif() + # install example programs + install(TARGETS apriltag_demo RUNTIME DESTINATION bin) diff --git a/recipes/apriltag/all/test_package/CMakeLists.txt b/recipes/apriltag/all/test_package/CMakeLists.txt index d4fdee1a8a79c..bb399b07277ef 100644 --- a/recipes/apriltag/all/test_package/CMakeLists.txt +++ b/recipes/apriltag/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) +project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) +find_package(apriltag REQUIRED MODULE) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} apriltag::apriltag) diff --git a/recipes/apriltag/all/test_package/conanfile.py b/recipes/apriltag/all/test_package/conanfile.py index fcae7e3c40edd..abcc73138d2ae 100644 --- a/recipes/apriltag/all/test_package/conanfile.py +++ b/recipes/apriltag/all/test_package/conanfile.py @@ -1,9 +1,10 @@ import os from conans import ConanFile, CMake, tools + class apriltagTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package" def build(self): cmake = CMake(self) @@ -12,5 +13,5 @@ def build(self): def test(self): if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") + bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/apriltag/all/test_package/example.cpp b/recipes/apriltag/all/test_package/test_package.cpp similarity index 100% rename from recipes/apriltag/all/test_package/example.cpp rename to recipes/apriltag/all/test_package/test_package.cpp diff --git a/recipes/apriltag/config.yml b/recipes/apriltag/config.yml index b87404bd2ab25..6aa1925bfcd8e 100644 --- a/recipes/apriltag/config.yml +++ b/recipes/apriltag/config.yml @@ -1,5 +1,7 @@ versions: - "3.1.1": + "3.1.4": folder: all "3.1.2": folder: all + "3.1.1": + folder: all diff --git a/recipes/aravis/all/conandata.yml b/recipes/aravis/all/conandata.yml new file mode 100644 index 0000000000000..3dad42682b77d --- /dev/null +++ b/recipes/aravis/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "0.8.20": + url: "https://github.com/AravisProject/aravis/releases/download/0.8.20/aravis-0.8.20.tar.xz" + sha256: "0c0eb5a76109f29180c09c7e6a23fd403633bf22bbe8468a0ae44995c4449f46" +patches: + "0.8.20": + - patch_file: "patches/0.8.19-gst-shared-lib.patch" + base_path: "source_subfolder" diff --git a/recipes/aravis/all/conanfile.py b/recipes/aravis/all/conanfile.py new file mode 100644 index 0000000000000..3e8bc058b7f3a --- /dev/null +++ b/recipes/aravis/all/conanfile.py @@ -0,0 +1,164 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, export_conandata_patches, apply_conandata_patches, rename, chdir, rm, rmdir +from conan.tools.microsoft import is_msvc +from conans import Meson, RunEnvironment, tools +import os +import glob + +required_conan_version = ">=1.52.0" + +class AravisConan(ConanFile): + name = "aravis" + license = "LGPL-2.1-or-later" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/AravisProject/aravis" + description = "A vision library for genicam based cameras." + topics = ("usb", "camera") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "usb": [True, False], + "packet_socket": [True, False], + "gst_plugin": [True, False], + "tools": [True, False], + "introspection": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "usb": True, + "packet_socket": True, + "gst_plugin": False, + "tools": True, + "introspection": False + } + generators = "pkg_config" + + _meson = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _aravis_api_version(self): + return ".".join(self.version.split(".")[0:2]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.os != "Linux": + del self.options.packet_socket + + def configure(self): + if self.options.shared: + del self.options.fPIC + self.options["glib"].shared = True + + def validate(self): + if is_msvc(self) and self.settings.get_safe("compiler.runtime", "").startswith("MT"): + raise ConanInvalidConfiguration("Static MT/MTd runtime is not supported on Windows due to GLib issues") + if not self.options["glib"].shared and self.options.shared: + raise ConanInvalidConfiguration("Shared Aravis cannot link to static GLib") + if self.settings.os == "Macos": + raise ConanInvalidConfiguration("macOS builds are disabled until conan-io/conan#7324 gets merged to fix macOS SIP issue #8443") + + def build_requirements(self): + self.build_requires("meson/0.63.3") + self.build_requires("pkgconf/1.9.3") + if self.options.introspection: + self.build_requires("gobject-introspection/1.72.0") + + def requirements(self): + self.requires("glib/2.74.0") + self.requires("libxml2/2.9.14") + self.requires("zlib/1.2.12") + if self.options.usb: + self.requires("libusb/1.0.26") + if self.options.gst_plugin: + self.requires("gstreamer/1.19.2") + self.requires("gst-plugins-base/1.19.2") + + def export_sources(self): + export_conandata_patches(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _configure_meson(self): + if self._meson: + return self._meson + defs = dict() + defs["wrap_mode"] = "nofallback" + defs["usb"] = "enabled" if self.options.usb else "disabled" + defs["gst-plugin"] = "enabled" if self.options.gst_plugin else "disabled" + defs["packet-socket"] = "enabled" if self.options.get_safe("packet_socket") else "disabled" + defs["introspection"] = "enabled" if self.options.introspection else "disabled" + defs["viewer"] = "disabled" + defs["tests"] = "false" + defs["documentation"] = "disabled" + if self.settings.get_safe("compiler.runtime"): + defs["b_vscrt"] = str(self.settings.compiler.runtime).lower() + self._meson = Meson(self) + self._meson.configure(defs=defs, source_folder=self._source_subfolder, build_folder=self._build_subfolder) + return self._meson + + def build(self): + apply_conandata_patches(self) + with tools.environment_append(RunEnvironment(self).vars): + meson = self._configure_meson() + meson.build() + + def _fix_library_names(self, path): + # https://github.com/mesonbuild/meson/issues/1412 + if not self.options.shared and is_msvc(self): + with chdir(self, path): + for filename_old in glob.glob("*.a"): + filename_new = filename_old[3:-2] + ".lib" + self.output.info(f"rename {filename_old} into {filename_new}") + rename(self, filename_old, filename_new) + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses", keep_path=False) + with tools.environment_append(RunEnvironment(self).vars): + meson = self._configure_meson() + meson.install() + + self._fix_library_names(os.path.join(self.package_folder, "lib")) + if self.options.gst_plugin: + self._fix_library_names(os.path.join(self.package_folder, "lib", "gstreamer-1.0")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.pdb", self.package_folder, recursive=True) + if not self.options.tools: + rm(self, "arv-*", os.path.join(self.package_folder, "bin")) + + def package_id(self): + self.info.requires["glib"].full_package_mode() + if self.options.gst_plugin: + self.info.requires["gstreamer"].full_package_mode() + self.info.requires["gst-plugins-base"].full_package_mode() + + def package_info(self): + aravis_name = f"aravis-{self._aravis_api_version}" + self.cpp_info.names["pkg_config"] = aravis_name + self.cpp_info.includedirs = [os.path.join("include", aravis_name)] + self.cpp_info.libs = [aravis_name] + if self.settings.os == "Linux": + self.cpp_info.system_libs.extend(["dl", "pthread", "m", "resolv"]) + elif self.settings.os == "Windows": + self.cpp_info.system_libs.extend(["ws2_32", "iphlpapi"]) + + if self.options.tools: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH environment variable: {bin_path}") + self.env_info.PATH.append(bin_path) + if self.options.gst_plugin and self.options.shared: + gst_plugin_path = os.path.join(self.package_folder, "lib", "gstreamer-1.0") + self.output.info(f"Appending GST_PLUGIN_PATH env var: {gst_plugin_path}") + self.env_info.GST_PLUGIN_PATH.append(gst_plugin_path) diff --git a/recipes/aravis/all/patches/0.8.19-gst-shared-lib.patch b/recipes/aravis/all/patches/0.8.19-gst-shared-lib.patch new file mode 100644 index 0000000000000..fec845831e656 --- /dev/null +++ b/recipes/aravis/all/patches/0.8.19-gst-shared-lib.patch @@ -0,0 +1,11 @@ +--- a/gst/meson.build ++++ b/gst/meson.build +@@ -15,7 +15,7 @@ gst_c_args = [ + + gst_plugin_filename = 'gstaravis.@0@'.format (aravis_api_version) + +-gst_plugin = shared_library (gst_plugin_filename, ++gst_plugin = library (gst_plugin_filename, + gst_sources, gst_headers, + name_suffix: [], + link_with: aravis_library, diff --git a/recipes/aravis/all/test_package/CMakeLists.txt b/recipes/aravis/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f6a87ca17276f --- /dev/null +++ b/recipes/aravis/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aravis REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} aravis::aravis) diff --git a/recipes/aravis/all/test_package/conanfile.py b/recipes/aravis/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3f3cb5b947e78 --- /dev/null +++ b/recipes/aravis/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class AravisTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aravis/all/test_package/test_package.c b/recipes/aravis/all/test_package/test_package.c new file mode 100644 index 0000000000000..9a63b9ea3a864 --- /dev/null +++ b/recipes/aravis/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include +#include +#include + +int main(int argc, char **argv) +{ + printf("Enumerating Aravis interfaces:\n"); + unsigned int if_count = arv_get_n_interfaces(); + for (unsigned int if_index = 0; if_index < if_count; if_index++) { + const char* if_name = arv_get_interface_id(if_index); + if (if_name) + printf("* '%s'\n", if_name); + } + arv_shutdown(); + return EXIT_SUCCESS; +} diff --git a/recipes/aravis/config.yml b/recipes/aravis/config.yml new file mode 100644 index 0000000000000..a7431a882c8d4 --- /dev/null +++ b/recipes/aravis/config.yml @@ -0,0 +1,3 @@ +versions: + "0.8.20": + folder: all diff --git a/recipes/arcus/all/conandata.yml b/recipes/arcus/all/conandata.yml new file mode 100644 index 0000000000000..beb6b4ed8bb02 --- /dev/null +++ b/recipes/arcus/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "4.9.1": + url: "https://github.com/Ultimaker/libArcus/archive/refs/tags/4.9.1.tar.gz" + sha256: "18d939fd2428c72fdce35a286c196438327cfc3c8476e463e5ca46570168c9ce" +patches: + "4.9.1": + - patch_file: "patches/0001-fix-cmake.patch" diff --git a/recipes/arcus/all/conanfile.py b/recipes/arcus/all/conanfile.py new file mode 100644 index 0000000000000..10256ef37f251 --- /dev/null +++ b/recipes/arcus/all/conanfile.py @@ -0,0 +1,118 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +import os +import textwrap + +required_conan_version = ">=1.52.0" + + +class ArcusConan(ConanFile): + name = "arcus" + description = "This library contains C++ code and Python3 bindings for " \ + "creating a socket in a thread and using this socket to send " \ + "and receive messages based on the Protocol Buffers library." + license = "LGPL-3.0-or-later" + topics = ("protobuf", "socket", "cura") + homepage = "https://github.com/Ultimaker/libArcus" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("protobuf/3.17.1") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_PYTHON"] = False + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_STATIC"] = not self.options.shared + if is_msvc(self): + tc.variables["MSVC_STATIC_RUNTIME"] = is_msvc_static_runtime(self) + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"Arcus": "Arcus::Arcus"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Arcus") + self.cpp_info.set_property("cmake_target_name", "Arcus") + self.cpp_info.libs = ["Arcus"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") + elif self.settings.os == "Windows": + self.cpp_info.system_libs.append("ws2_32") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "Arcus" + self.cpp_info.names["cmake_find_package_multi"] = "Arcus" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/arcus/all/patches/0001-fix-cmake.patch b/recipes/arcus/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..581de6fa9b257 --- /dev/null +++ b/recipes/arcus/all/patches/0001-fix-cmake.patch @@ -0,0 +1,62 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,5 @@ ++cmake_minimum_required(VERSION 3.8) + project(arcus) +-cmake_minimum_required(VERSION 3.6) + + include(GNUInstallDirs) + include(CMakePackageConfigHelpers) +@@ -19,7 +19,6 @@ endif() + set(protobuf_MODULE_COMPATIBLE ON CACHE INTERNAL "" FORCE) + find_package(Protobuf 3.0.0 REQUIRED) + +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) #Required if a patch to libArcus needs to be made via templates. + + if(BUILD_PYTHON) + list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +@@ -37,11 +36,7 @@ if(BUILD_PYTHON) + include_directories(python/ src/ ${SIP_INCLUDE_DIRS} ${Python3_INCLUDE_DIRS}) + endif() + +-set(CMAKE_CXX_STANDARD 11) + +-if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") +-endif() + + set(arcus_SRCS + src/Socket.cpp +@@ -63,17 +58,16 @@ set(arcus_HDRS + set(ARCUS_VERSION 1.1.0) + set(ARCUS_SOVERSION 3) + +-set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") + + if(BUILD_STATIC) + add_library(Arcus STATIC ${arcus_SRCS}) + if(NOT WIN32 OR CMAKE_COMPILER_IS_GNUCXX) + target_link_libraries(Arcus PRIVATE pthread) +- set_target_properties(Arcus PROPERTIES COMPILE_FLAGS -fPIC) + endif() + else() + add_library(Arcus SHARED ${arcus_SRCS}) + endif() ++target_compile_features(Arcus PUBLIC cxx_std_11) + + if(MSVC_STATIC_RUNTIME) + foreach(flag_var +@@ -97,11 +91,11 @@ target_include_directories(Arcus PUBLIC + $ + ${PROTOBUF_INCLUDE_DIR} + ) +-target_link_libraries(Arcus PUBLIC ${PROTOBUF_LIBRARIES}) ++target_link_libraries(Arcus PUBLIC protobuf::libprotobuf) + + if(WIN32) + add_definitions(-D_WIN32_WINNT=0x0600) # Declare we require Vista or higher, this allows us to use IPv6 functions. +- target_link_libraries(Arcus PUBLIC Ws2_32) ++ target_link_libraries(Arcus PUBLIC ws2_32) + endif() + + if(${CMAKE_BUILD_TYPE}) diff --git a/recipes/arcus/all/test_package/CMakeLists.txt b/recipes/arcus/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..376d65791e678 --- /dev/null +++ b/recipes/arcus/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(Arcus REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Arcus) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/arcus/all/test_package/conanfile.py b/recipes/arcus/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/arcus/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/arcus/all/test_package/test_package.cpp b/recipes/arcus/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f213963f9dbec --- /dev/null +++ b/recipes/arcus/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + Arcus::Socket socket; + return 0; +} diff --git a/recipes/arcus/all/test_v1_package/CMakeLists.txt b/recipes/arcus/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..5b257f71e6bdc --- /dev/null +++ b/recipes/arcus/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Arcus REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Arcus) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/arcus/all/test_v1_package/conanfile.py b/recipes/arcus/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/arcus/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/arcus/config.yml b/recipes/arcus/config.yml new file mode 100644 index 0000000000000..4831b25407aa2 --- /dev/null +++ b/recipes/arcus/config.yml @@ -0,0 +1,3 @@ +versions: + "4.9.1": + folder: all diff --git a/recipes/arduinojson/all/conandata.yml b/recipes/arduinojson/all/conandata.yml index 1d55982f9ea1a..a9b0f2df8490a 100644 --- a/recipes/arduinojson/all/conandata.yml +++ b/recipes/arduinojson/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "6.19.4": + url: "https://github.com/bblanchon/ArduinoJson/archive/v6.19.4.tar.gz" + sha256: "d8ceaf89b290b8109aa8eb200cf7e377c076241b25c4e9d1a601ecd74a37395b" + "6.18.5": + url: "https://github.com/bblanchon/ArduinoJson/archive/v6.18.5.tar.gz" + sha256: "57125b93c03c343055dbdcff874c8bfc78beb4a124097b37b69ec49120a5f359" "6.18.0": url: "https://github.com/bblanchon/ArduinoJson/releases/download/v6.18.0/ArduinoJson-v6.18.0.zip" sha256: "2ade6a0097845d6bc0292a7f9ffa58cbd7e11a34a26616ac9e40a7754a18f1a9" diff --git a/recipes/arduinojson/all/conanfile.py b/recipes/arduinojson/all/conanfile.py index 76e292173733d..65c63794d59f1 100644 --- a/recipes/arduinojson/all/conanfile.py +++ b/recipes/arduinojson/all/conanfile.py @@ -1,8 +1,10 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import copy, get, save +from conan.tools.layout import basic_layout import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" class ArduinojsonConan(ConanFile): @@ -12,53 +14,58 @@ class ArduinojsonConan(ConanFile): topics = ("json", "arduino", "iot", "embedded", "esp8266") license = "MIT" url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + def build(self): + pass - @property - def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + def package(self): + copy(self, "*LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder, "include")) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder, "include")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"ArduinoJson": "ArduinoJson::ArduinoJson"} + ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - def package(self): - self.copy("*LICENSE*", dst="licenses", src=self._source_subfolder) - self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "src")) - self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "src")) + """) + save(self, module_file, content) - self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._module_file_rel_path), - {"ArduinoJson": "ArduinoJson::ArduinoJson"} - ) + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): + self.cpp_info.set_property("cmake_file_name", "ArduinoJson") + self.cpp_info.set_property("cmake_target_name", "ArduinoJson") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "ArduinoJson" self.cpp_info.names["cmake_find_package_multi"] = "ArduinoJson" - - self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/arduinojson/all/test_package/CMakeLists.txt b/recipes/arduinojson/all/test_package/CMakeLists.txt index 70e13ce3659e9..d206236f0971b 100644 --- a/recipes/arduinojson/all/test_package/CMakeLists.txt +++ b/recipes/arduinojson/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(ArduinoJson REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ArduinoJson) +target_link_libraries(${PROJECT_NAME} PRIVATE ArduinoJson) diff --git a/recipes/arduinojson/all/test_package/conanfile.py b/recipes/arduinojson/all/test_package/conanfile.py index 7e2dfe859bb27..d120a992c06a6 100644 --- a/recipes/arduinojson/all/test_package/conanfile.py +++ b/recipes/arduinojson/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/arduinojson/all/test_v1_package/CMakeLists.txt b/recipes/arduinojson/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7e433826ed298 --- /dev/null +++ b/recipes/arduinojson/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ArduinoJson REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ArduinoJson) diff --git a/recipes/arduinojson/all/test_v1_package/conanfile.py b/recipes/arduinojson/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/arduinojson/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/arduinojson/config.yml b/recipes/arduinojson/config.yml index 45c38eb2b1f1a..7b1d7418387a3 100644 --- a/recipes/arduinojson/config.yml +++ b/recipes/arduinojson/config.yml @@ -1,4 +1,8 @@ versions: + "6.19.4": + folder: all + "6.18.5": + folder: all "6.18.0": folder: all "6.16.1": diff --git a/recipes/argh/all/conandata.yml b/recipes/argh/all/conandata.yml index 6f0c5993d9776..2335ee8915d08 100644 --- a/recipes/argh/all/conandata.yml +++ b/recipes/argh/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.3.2": + url: "https://github.com/adishavit/argh/archive/v1.3.2.tar.gz" + sha256: "4b76d8c55e97cc0752feee4f00b99dc58464dd030dea9ba257c0a7d24a84f9dd" "1.3.1": url: "https://github.com/adishavit/argh/archive/refs/tags/v1.3.1.tar.gz" sha256: "48e09999f2768afbe90ef98864980933cf0ed5323dce3593c3f2f44b0ffda3de" diff --git a/recipes/argh/all/conanfile.py b/recipes/argh/all/conanfile.py index d303b3812ea28..f6f6a44814ca4 100644 --- a/recipes/argh/all/conanfile.py +++ b/recipes/argh/all/conanfile.py @@ -1,35 +1,73 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get, save +from conan.tools.layout import basic_layout import os +import textwrap + +required_conan_version = ">=1.50.0" class ArgparseConan(ConanFile): name = "argh" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/adishavit/argh" - topics = ("conan", "argh", "argument", "parsing") + topics = ("argh", "argument", "parsing") license = "BSD-3" description = "Frustration-free command line processing" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") + def package_id(self): + self.info.clear() def validate(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("argh-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - self.copy("argh.h", src=self._source_subfolder, dst=os.path.join("include", "argh")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "argh.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) - def package_id(self): - self.info.header_only() + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"argh": "argh::argh"}, + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.includedirs.append(os.path.join("include", "argh")) + self.cpp_info.set_property("cmake_file_name", "argh") + self.cpp_info.set_property("cmake_target_name", "argh") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/argh/all/test_package/CMakeLists.txt b/recipes/argh/all/test_package/CMakeLists.txt index 33ae887aa6aea..fcd79af5da306 100644 --- a/recipes/argh/all/test_package/CMakeLists.txt +++ b/recipes/argh/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(argh REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE argh) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/argh/all/test_package/conanfile.py b/recipes/argh/all/test_package/conanfile.py index 294cae8158173..d120a992c06a6 100644 --- a/recipes/argh/all/test_package/conanfile.py +++ b/recipes/argh/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package")) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/argh/all/test_v1_package/CMakeLists.txt b/recipes/argh/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..65e0578c4c0f6 --- /dev/null +++ b/recipes/argh/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(argh REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE argh) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/argh/all/test_v1_package/conanfile.py b/recipes/argh/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c394e09142659 --- /dev/null +++ b/recipes/argh/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package")) diff --git a/recipes/argh/config.yml b/recipes/argh/config.yml index 59334d5077368..4977bb7915a7c 100644 --- a/recipes/argh/config.yml +++ b/recipes/argh/config.yml @@ -1,3 +1,5 @@ versions: + "1.3.2": + folder: all "1.3.1": folder: all diff --git a/recipes/argon2/all/conanfile.py b/recipes/argon2/all/conanfile.py index f32d7d147483f..95aff495247cc 100644 --- a/recipes/argon2/all/conanfile.py +++ b/recipes/argon2/all/conanfile.py @@ -1,7 +1,7 @@ from conans import AutoToolsBuildEnvironment, ConanFile, MSBuild, tools import os -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.33.0" class Argon2Conan(ConanFile): @@ -20,6 +20,10 @@ class Argon2Conan(ConanFile): def _source_subfolder(self): return "source_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -31,12 +35,12 @@ def configure(self): del self.settings.compiler.cppstd def build_requirements(self): - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio" and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows" and self.settings.compiler != "Visual Studio" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("phc-winner-argon2-{0}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) @property def _kernel_name(self): @@ -66,6 +70,7 @@ def build(self): tools.replace_in_file(argon2_header, "__declspec(dllexport)", "") tools.replace_in_file(vcxproj, "DynamicLibrary", "StaticLibrary") tools.replace_in_file(vcxproj, "", "$(SolutionDir)include;%(AdditionalIncludeDirectories)") + tools.replace_in_file(vcxproj, "8.1", "") if self.settings.compiler == "Visual Studio": msbuild = MSBuild(self) msbuild.build(os.path.join(self._source_subfolder, "Argon2.sln"), targets=("Argon2OptDll",))#, platforms={"x86": "Win32"}) diff --git a/recipes/argon2/all/test_package/CMakeLists.txt b/recipes/argon2/all/test_package/CMakeLists.txt index 709e43c087dd9..b570e22ca35d5 100644 --- a/recipes/argon2/all/test_package/CMakeLists.txt +++ b/recipes/argon2/all/test_package/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1.2) project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +conan_basic_setup() add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} CONAN_PKG::argon2) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/argon2/all/test_package/conanfile.py b/recipes/argon2/all/test_package/conanfile.py index 2c955c95fd636..d4128b0450777 100644 --- a/recipes/argon2/all/test_package/conanfile.py +++ b/recipes/argon2/all/test_package/conanfile.py @@ -1,8 +1,8 @@ +from conans import ConanFile, CMake, tools import os -from conans import ConanFile, CMake, tools -class Argon2TestConan(ConanFile): +class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "cmake" diff --git a/recipes/argon2/all/test_package/test_package.cpp b/recipes/argon2/all/test_package/test_package.cpp index 2f6fd368af651..aaf97a7985fd5 100644 --- a/recipes/argon2/all/test_package/test_package.cpp +++ b/recipes/argon2/all/test_package/test_package.cpp @@ -1,15 +1,14 @@ -#include #include "argon2.h" +#include int main() { + const char *salt = "SALTSTR"; + const char *pwd = "password"; - const char * salt = "SALTSTR"; - const char * pwd = "password"; - char encoded[97] = {}; // high-level API - argon2id_hash_encoded(2,1<<16,2,pwd,sizeof(pwd),salt,sizeof(salt),32,encoded,sizeof(encoded)); + argon2id_hash_encoded(2, 1<<16, 2, pwd, sizeof(pwd), salt, sizeof(salt), 32, encoded, sizeof(encoded)); printf("Encoded password: %s", encoded); int res = argon2id_verify(encoded, pwd, sizeof(pwd)); diff --git a/recipes/argparse/all/conandata.yml b/recipes/argparse/all/conandata.yml index 9118e9c3bb73e..18f4555649896 100644 --- a/recipes/argparse/all/conandata.yml +++ b/recipes/argparse/all/conandata.yml @@ -1,4 +1,31 @@ sources: + "2.9": + url: "https://github.com/p-ranav/argparse/archive/v2.9.tar.gz" + sha256: "cd563293580b9dc592254df35b49cf8a19b4870ff5f611c7584cf967d9e6031e" + "2.6": + url: "https://github.com/p-ranav/argparse/archive/v2.6.tar.gz" + sha256: "da261c3b3010c10a163f4535bbe2b160319d2a6b1e0fd2eb5a7b9f6a85c29021" + "2.5": + url: "https://github.com/p-ranav/argparse/archive/refs/tags/v2.5.tar.gz" + sha256: "aad087125bed01ae73e650ce33f9a5edbcbceb6c30f6a43824b1afa8df5a6fac" + "2.4": + url: "https://github.com/p-ranav/argparse/archive/refs/tags/v2.4.tar.gz" + sha256: "3589559f115bfedfef2edffb3e7b61d88657ba7b70a0b1f47352ff3043abc825" + "2.3": + url: "https://github.com/p-ranav/argparse/archive/v2.3.tar.gz" + sha256: "6895d0f30d250ebb58bd93c1f07dbbcd0234216cb99ccc3ad211aa769bc5cf43" + "2.2": + url: "https://github.com/p-ranav/argparse/archive/v2.2.tar.gz" + sha256: "f0fc6ab7e70ac24856c160f44ebb0dd79dc1f7f4a614ee2810d42bb73799872b" "2.1": url: "https://github.com/p-ranav/argparse/archive/v2.1.tar.gz" sha256: "0a82f464b568b8ee6650fc837f371eb9c81417e2ef9fb3b51f65ad50fa3b8662" +patches: + "2.4": + - patch_file: "patches/0001-v2.3-add-missing-include.patch" + "2.3": + - patch_file: "patches/0001-v2.3-add-missing-include.patch" + "2.2": + - patch_file: "patches/0001-v2.2-add-missing-include.patch" + "2.1": + - patch_file: "patches/0001-v2.1-add-missing-include.patch" diff --git a/recipes/argparse/all/conanfile.py b/recipes/argparse/all/conanfile.py index 7eb011bf028f2..e7e9de237fe52 100644 --- a/recipes/argparse/all/conanfile.py +++ b/recipes/argparse/all/conanfile.py @@ -1,49 +1,84 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +required_conan_version = ">=1.50.0" + class ArgparseConan(ConanFile): name = "argparse" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/p-ranav/argparse" - topics = ("conan", "argparse", "argument", "parsing") + topics = ("argparse", "argument", "parsing") license = "MIT" description = "Argument Parser for Modern C++" - settings = "compiler" - no_copy_source = True + settings = "os", "arch", "compiler", "build_type" - _compiler_required_cpp17 = { - "gcc": "7", - "clang": "5", - "Visual Studio": "15", - "apple-clang": "10", - } + @property + def _min_cppstd(self): + return "17" @property - def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") - - def configure(self): - if self.settings.get_safe("compiler.cppstd"): - tools.check_min_cppstd(self, "17") - try: - minimum_required_compiler_version = self._compiler_required_cpp17[str(self.settings.compiler)] - if tools.Version(self.settings.compiler.version) < minimum_required_compiler_version: - raise ConanInvalidConfiguration("This package requires c++17 support. The current compiler does not support it.") - except KeyError: - self.output.warn("This recipe has no support for the current compiler. Please consider adding it.") + def _compilers_minimum_version(self): + return { + "gcc": "7" if Version(self.version) <= "2.1" else "8", + "clang": "5" if Version(self.version) <= "2.1" else "7", + # trantor/2.5 uses [[maybe_unused]] in range-based for loop + # Visual Studio 15 doesn't support it: + # https://developercommunity.visualstudio.com/t/compiler-bug-on-parsing-maybe-unused-in-range-base/209488 + "Visual Studio": "15" if Version(self.version) < "2.5" else "16", + "msvc": "191" if Version(self.version) < "2.5" else "192", + "apple-clang": "10", + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.", + ) + + if Version(self.version) > "2.1" and self.settings.compiler == "clang" and self.settings.compiler.libcxx == "libstdc++": + raise ConanInvalidConfiguration("This recipe does not permit >2.1 with clang and stdlibc++. There may be an infrastructure issue in CCI.") + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("argparse-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - self.copy("*.hpp", src=os.path.join(self._source_subfolder, "include"), dst=os.path.join("include", "argparse")) + def build(self): + apply_conandata_patches(self) - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if Version(self.version) <= "2.1": + include_dst = os.path.join(self.package_folder, "include", "argparse") + else: + include_dst = os.path.join(self.package_folder, "include") + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=include_dst) def package_info(self): - self.cpp_info.includedirs.append(os.path.join("include", "argparse")) + self.cpp_info.set_property("cmake_file_name", "argparse") + self.cpp_info.set_property("cmake_target_name", "argparse::argparse") + self.cpp_info.set_property("pkg_config_name", "argparse") + if Version(self.version) <= "2.1": + self.cpp_info.includedirs.append(os.path.join("include", "argparse")) + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/argparse/all/patches/0001-v2.1-add-missing-include.patch b/recipes/argparse/all/patches/0001-v2.1-add-missing-include.patch new file mode 100644 index 0000000000000..245ce23c3652e --- /dev/null +++ b/recipes/argparse/all/patches/0001-v2.1-add-missing-include.patch @@ -0,0 +1,12 @@ +diff --git a/include/argparse.hpp b/include/argparse.hpp +index 30c42da..7bf16a3 100644 +--- a/include/argparse.hpp ++++ b/include/argparse.hpp +@@ -44,6 +44,7 @@ SOFTWARE. + #include + #include + #include ++#include + #include + #include + diff --git a/recipes/argparse/all/patches/0001-v2.2-add-missing-include.patch b/recipes/argparse/all/patches/0001-v2.2-add-missing-include.patch new file mode 100644 index 0000000000000..8e3c371c754b3 --- /dev/null +++ b/recipes/argparse/all/patches/0001-v2.2-add-missing-include.patch @@ -0,0 +1,12 @@ +diff --git a/include/argparse/argparse.hpp b/include/argparse/argparse.hpp +index 7da3462..efd78b2 100644 +--- a/include/argparse/argparse.hpp ++++ b/include/argparse/argparse.hpp +@@ -47,6 +47,7 @@ SOFTWARE. + #include + #include + #include ++#include + #include + #include + diff --git a/recipes/argparse/all/patches/0001-v2.3-add-missing-include.patch b/recipes/argparse/all/patches/0001-v2.3-add-missing-include.patch new file mode 100644 index 0000000000000..4d0fbae4e910e --- /dev/null +++ b/recipes/argparse/all/patches/0001-v2.3-add-missing-include.patch @@ -0,0 +1,12 @@ +diff --git a/include/argparse/argparse.hpp b/include/argparse/argparse.hpp +index 55828ed..112534b 100644 +--- a/include/argparse/argparse.hpp ++++ b/include/argparse/argparse.hpp +@@ -48,6 +48,7 @@ SOFTWARE. + #include + #include + #include ++#include + #include + #include + diff --git a/recipes/argparse/all/test_package/CMakeLists.txt b/recipes/argparse/all/test_package/CMakeLists.txt index 6c1d84c7e3d82..e8794b9790e15 100644 --- a/recipes/argparse/all/test_package/CMakeLists.txt +++ b/recipes/argparse/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(argparse REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) +target_link_libraries(${PROJECT_NAME} PRIVATE argparse::argparse) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/argparse/all/test_package/conanfile.py b/recipes/argparse/all/test_package/conanfile.py index e010592ddf587..a972d9e6309b9 100644 --- a/recipes/argparse/all/test_package/conanfile.py +++ b/recipes/argparse/all/test_package/conanfile.py @@ -1,11 +1,18 @@ -from conans import ConanFile, CMake, tools -from io import StringIO +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,11 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - output = StringIO() - bin_path = os.path.join("bin", "test_package") + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") val = 42 - self.run("{} {}".format(bin_path, val), run_environment=True, output=output) - text = output.getvalue() - print(text) - assert(str(val*val) in text) + self.run(f"{bin_path} {val}", env="conanrun") diff --git a/recipes/argparse/all/test_package/test_package.cpp b/recipes/argparse/all/test_package/test_package.cpp index 1cf4f05b50595..c2df16ddec35f 100644 --- a/recipes/argparse/all/test_package/test_package.cpp +++ b/recipes/argparse/all/test_package/test_package.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -23,4 +23,3 @@ int main(int argc, char *argv[]) { return 0; } - diff --git a/recipes/argparse/all/test_v1_package/CMakeLists.txt b/recipes/argparse/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..59cfa3b376305 --- /dev/null +++ b/recipes/argparse/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(argparse REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE argparse::argparse) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/argparse/all/test_v1_package/conanfile.py b/recipes/argparse/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a3b19a8d499a6 --- /dev/null +++ b/recipes/argparse/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + val = 42 + self.run(f"{bin_path} {val}", run_environment=True) diff --git a/recipes/argparse/config.yml b/recipes/argparse/config.yml index adf6918baab9c..5a743e89da3ef 100644 --- a/recipes/argparse/config.yml +++ b/recipes/argparse/config.yml @@ -1,3 +1,15 @@ versions: + "2.9": + folder: all + "2.6": + folder: all + "2.5": + folder: all + "2.4": + folder: all + "2.3": + folder: all + "2.2": + folder: all "2.1": folder: all diff --git a/recipes/args-parser/6.0.1.0/conandata.yml b/recipes/args-parser/6.0.1.0/conandata.yml deleted file mode 100644 index 5c87f5809fa64..0000000000000 --- a/recipes/args-parser/6.0.1.0/conandata.yml +++ /dev/null @@ -1,4 +0,0 @@ -sources: - "6.0.1.0": - url: "https://github.com/igormironchik/args-parser/archive/refs/tags/6.0.1.0.tar.gz" - sha256: "d3569ee05f89d361f28fcca32e5ff782578e55aeea5559ebf1f394a689e2ae26" diff --git a/recipes/args-parser/6.0.1.0/conanfile.py b/recipes/args-parser/6.0.1.0/conanfile.py deleted file mode 100644 index b397b6a0dc597..0000000000000 --- a/recipes/args-parser/6.0.1.0/conanfile.py +++ /dev/null @@ -1,84 +0,0 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration -import os -import textwrap - - -class ArgsParserConan(ConanFile): - name = "args-parser" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/igormironchik/args-parser" - license = "MIT" - description = "Small C++ header-only library for parsing command line arguments." - topics = ("conan", "args-parser", "argument", "parsing") - settings = "compiler" - no_copy_source = True - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _compilers_minimum_version(self): - return { - "Visual Studio": "15", - "gcc": "5", - "clang": "3.5", - "apple-clang": "10" - } - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") - - @property - def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) - - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): - content = "" - for alias, aliased in targets.items(): - content += textwrap.dedent("""\ - if(TARGET {aliased} AND NOT TARGET {alias}) - add_library({alias} INTERFACE IMPORTED) - set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) - endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "14") - - compiler = str(self.settings.compiler) - if compiler not in self._compilers_minimum_version: - self.output.warn("Unknown compiler, assuming it supports at least C++14") - return - - version = tools.Version(self.settings.compiler.version) - if version < self._compilers_minimum_version[compiler]: - raise ConanInvalidConfiguration("args-parser requires a compiler that supports at least C++14") - - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) - - def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - self.copy("*.hpp", src=os.path.join(self._source_subfolder, "args-parser"), dst=os.path.join("include", "args-parser")) - self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._module_file_rel_path), - {"args-parser": "args-parser::args-parser"} - ) - - def package_id(self): - self.info.header_only() - - def package_info(self): - self.cpp_info.names["cmake_find_package"] = "args-parser" - self.cpp_info.names["cmake_find_package_multi"] = "args-parser" - self.cpp_info.builddirs.append(self._module_subfolder) - self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] - self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - self.cpp_info.includedirs.append(os.path.join("include", "args-parser")) diff --git a/recipes/args-parser/6.0.1.0/test_package/CMakeLists.txt b/recipes/args-parser/6.0.1.0/test_package/CMakeLists.txt deleted file mode 100644 index 586c390344aee..0000000000000 --- a/recipes/args-parser/6.0.1.0/test_package/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 3.1) - -project(args-parser.test) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - -conan_basic_setup(TARGETS) - -find_package(args-parser REQUIRED) - -add_executable(${PROJECT_NAME} example.cpp) - -target_link_libraries(${PROJECT_NAME} args-parser) - -set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 14 - CXX_STANDARD_REQUIRED ON -) diff --git a/recipes/args-parser/6.0.1.0/test_package/conanfile.py b/recipes/args-parser/6.0.1.0/test_package/conanfile.py deleted file mode 100644 index fe54f09e65089..0000000000000 --- a/recipes/args-parser/6.0.1.0/test_package/conanfile.py +++ /dev/null @@ -1,15 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - -class ArgsParserTestConan(ConanFile): - generators = "cmake", "cmake_find_package" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "args-parser.test") - self.run(bin_path, run_environment=True) diff --git a/recipes/args-parser/all/conandata.yml b/recipes/args-parser/all/conandata.yml new file mode 100644 index 0000000000000..787c510a62b53 --- /dev/null +++ b/recipes/args-parser/all/conandata.yml @@ -0,0 +1,25 @@ +sources: + "6.3.2": + url: "https://github.com/igormironchik/args-parser/archive/refs/tags/6.3.2.tar.gz" + sha256: "cd89549a9f5b5cfd16db2f8b9c93fd164cea334147c58890d5322365789e05e5" + "6.3.1": + url: "https://github.com/igormironchik/args-parser/archive/refs/tags/6.3.1.tar.gz" + sha256: "7509639553708baf03aca57cfb0c9e5824b705782b69ebb71de5e4f1c6ad18ab" + "6.3.0": + url: "https://github.com/igormironchik/args-parser/archive/refs/tags/6.3.0.tar.gz" + sha256: "a21d1ad1b4648f3fff0fe898514040312c7eae17b6347cb9aa1da5c74d9815f0" + "6.2.0.1": + url: "https://github.com/igormironchik/args-parser/archive/refs/tags/6.2.0.1.tar.gz" + sha256: "9fd34a717f9dbaf1ebbce35645f71ce1f5079ced8d6b77a240911bd580914ecd" + "6.2.0.0": + url: "https://github.com/igormironchik/args-parser/archive/refs/tags/6.2.0.0.tar.gz" + sha256: "77aa15ad637e48ddbf7dca1311519ad53d73fee6395989f7922754da59138915" + "6.1.1.0": + url: "https://github.com/igormironchik/args-parser/archive/refs/tags/6.1.1.0.tar.gz" + sha256: "41135cb79034f8f8940fc0bd0346059446df98a8df47ca461af8757e9cb3e33b" + "6.1.0.0": + url: "https://github.com/igormironchik/args-parser/archive/refs/tags/6.1.0.0.tar.gz" + sha256: "f6fadc1458e8821160a287a7dd096e94a36f968ba9719fa2a7ce8cec6bfb6969" + "6.0.1.0": + url: "https://github.com/igormironchik/args-parser/archive/refs/tags/6.0.1.0.tar.gz" + sha256: "d3569ee05f89d361f28fcca32e5ff782578e55aeea5559ebf1f394a689e2ae26" diff --git a/recipes/args-parser/all/conanfile.py b/recipes/args-parser/all/conanfile.py new file mode 100644 index 0000000000000..6203a42e03b3a --- /dev/null +++ b/recipes/args-parser/all/conanfile.py @@ -0,0 +1,69 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.0" + + +class ArgsParserConan(ConanFile): + name = "args-parser" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/igormironchik/args-parser" + license = "MIT" + description = "Small C++ header-only library for parsing command line arguments." + topics = ("args-parser", "argument", "parsing") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _min_cppstd(self): + return "14" + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "15", + "msvc": "191", + "gcc": "5", + "clang": "3.5", + "apple-clang": "10", + } + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.", + ) + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "args-parser"), dst=os.path.join(self.package_folder, "include", "args-parser")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "args-parser") + self.cpp_info.set_property("cmake_target_name", "args-parser::args-parser") + self.cpp_info.includedirs.append(os.path.join("include", "args-parser")) + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/args-parser/all/test_package/CMakeLists.txt b/recipes/args-parser/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..94b80c9c35998 --- /dev/null +++ b/recipes/args-parser/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(args-parser REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE args-parser::args-parser) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/args-parser/all/test_package/conanfile.py b/recipes/args-parser/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/args-parser/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/args-parser/6.0.1.0/test_package/example.cpp b/recipes/args-parser/all/test_package/test_package.cpp similarity index 100% rename from recipes/args-parser/6.0.1.0/test_package/example.cpp rename to recipes/args-parser/all/test_package/test_package.cpp diff --git a/recipes/args-parser/all/test_v1_package/CMakeLists.txt b/recipes/args-parser/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..135995b086884 --- /dev/null +++ b/recipes/args-parser/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(args-parser REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE args-parser::args-parser) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/args-parser/all/test_v1_package/conanfile.py b/recipes/args-parser/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/args-parser/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/args-parser/config.yml b/recipes/args-parser/config.yml new file mode 100644 index 0000000000000..08a70490fa0ab --- /dev/null +++ b/recipes/args-parser/config.yml @@ -0,0 +1,17 @@ +versions: + "6.3.2": + folder: all + "6.3.1": + folder: all + "6.3.0": + folder: all + "6.2.0.1": + folder: all + "6.2.0.0": + folder: all + "6.1.1.0": + folder: all + "6.1.0.0": + folder: all + "6.0.1.0": + folder: all diff --git a/recipes/argtable2/all/conandata.yml b/recipes/argtable2/all/conandata.yml index 258eee8df3aac..9f0629c6216d9 100644 --- a/recipes/argtable2/all/conandata.yml +++ b/recipes/argtable2/all/conandata.yml @@ -8,3 +8,5 @@ patches: base_path: "source_subfolder" - patch_file: "patches/2.13-0002-msvc-nmake-accept-conan-flags.patch" base_path: "source_subfolder" + - patch_file: "patches/2.13-0003-armv8-build.patch" + base_path: "source_subfolder" diff --git a/recipes/argtable2/all/conanfile.py b/recipes/argtable2/all/conanfile.py index cb8edd88462f6..4ad0658c61784 100644 --- a/recipes/argtable2/all/conanfile.py +++ b/recipes/argtable2/all/conanfile.py @@ -1,5 +1,8 @@ from conans import AutoToolsBuildEnvironment, ConanFile, tools import os +import shutil + +required_conan_version = ">=1.33.0" class Argtable2Conan(ConanFile): @@ -18,6 +21,7 @@ class Argtable2Conan(ConanFile): "shared": False, "fPIC": True, } + generators = "cmake", "pkg_config", "cmake_find_package" exports_sources = "patches/**" @@ -31,6 +35,10 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -42,12 +50,22 @@ def configure(self): del self.settings.compiler.cppstd def build_requirements(self): - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio": - self.build_requires("msys2/20200517") + if self.settings.compiler != "Visual Studio": + self.build_requires("gnu-config/cci.20201022") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("argtable{}".format(self.version.replace(".", "-")), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @property + def _user_info_build(self): + # If using the experimental feature with different context for host and + # build, the 'user_info' attributes of the 'build_requires' packages + # will be located into the 'user_info_build' object. In other cases they + # will be located into the 'deps_user_info' object. + return getattr(self, "user_info_build", None) or self.deps_user_info def _configure_autotools(self): if self._autotools: @@ -58,6 +76,14 @@ def _configure_autotools(self): "--enable-shared={}".format(yes_no(self.options.shared)), "--enable-static={}".format(yes_no(not self.options.shared)), ] + + # it contains outdated 'config.sub' and + # 'config.guess' files. It not allows to build libelf for armv8 arch. + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) + self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) return self._autotools diff --git a/recipes/argtable2/all/patches/2.13-0003-armv8-build.patch b/recipes/argtable2/all/patches/2.13-0003-armv8-build.patch new file mode 100644 index 0000000000000..84bce24b2273d --- /dev/null +++ b/recipes/argtable2/all/patches/2.13-0003-armv8-build.patch @@ -0,0 +1,12 @@ +diff --git a/src/arg_int.c b/src/arg_int.c +index 29c20e5..bc10012 100644 +--- a/src/arg_int.c ++++ b/src/arg_int.c +@@ -30,6 +30,7 @@ USA. + + #include "argtable2.h" + #include ++#include + + /* local error codes */ + enum {EMINCOUNT=1,EMAXCOUNT,EBADINT,EOVERFLOW}; diff --git a/recipes/argtable2/all/test_package/conanfile.py b/recipes/argtable2/all/test_package/conanfile.py index 7a69924b250bf..11cbe23a4ac97 100644 --- a/recipes/argtable2/all/test_package/conanfile.py +++ b/recipes/argtable2/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run("{} -n".format(bin_path), run_environment=True) diff --git a/recipes/argtable3/all/conandata.yml b/recipes/argtable3/all/conandata.yml index fee3576463e96..103508c1e8a96 100644 --- a/recipes/argtable3/all/conandata.yml +++ b/recipes/argtable3/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.2.1": + url: "https://github.com/argtable/argtable3/releases/download/v3.2.1.52f24e5/argtable-v3.2.1.52f24e5.tar.gz" + sha256: "bf02394a21378fdca95937fc4e3aeff8af63a2bfed7e3f87b1c1eda8bf9227dc" "3.2.0": url: "https://github.com/argtable/argtable3/archive/refs/tags/v3.2.0.7402e6e.tar.gz" sha256: "e692ce51fb51dc750b47ef0ef2941573c8c49195aa2ddc48cb369239c400efa7" diff --git a/recipes/argtable3/all/conanfile.py b/recipes/argtable3/all/conanfile.py index 13c8fc1b470dd..64ccba9e5506f 100644 --- a/recipes/argtable3/all/conanfile.py +++ b/recipes/argtable3/all/conanfile.py @@ -13,7 +13,6 @@ class Argtable3Conan(ConanFile): homepage = "https://www.argtable.org/" url = "https://github.com/conan-io/conan-center-index" settings = "os", "arch", "compiler", "build_type" - exports_sources = "CMakeLists.txt", "patches/**" options = { "shared": [True, False], "fPIC": [True, False], @@ -22,6 +21,8 @@ class Argtable3Conan(ConanFile): "shared": False, "fPIC": True, } + + exports_sources = "CMakeLists.txt", "patches/*" generators = "cmake" _cmake = None @@ -88,6 +89,7 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + # These targets were for versions <= 3.2.0 (newer create argtable3::argtable3) target_name = "argtable3" if self.options.shared else "argtable3_static" self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), @@ -95,15 +97,21 @@ def package(self): ) def package_info(self): - self.cpp_info.libs = ["argtable3" if self.options.shared else "argtable3_static"] + suffix = "" + if not self.options.shared: + suffix += "_static" + if tools.Version(self.version) >= "3.2.1" and self.settings.build_type == "Debug": + suffix += "d" + self.cpp_info.libs = ["argtable3{}".format(suffix)] if not self.options.shared: - if self.settings.os == "Linux": + if self.settings.os in ("FreeBSD", "Linux"): self.cpp_info.system_libs.append("m") self.cpp_info.filenames["cmake_find_package"] = "Argtable3" self.cpp_info.filenames["cmake_find_package_multi"] = "Argtable3" + self.cpp_info.names["cmake_find_package"] = "argtable3" + self.cpp_info.names["cmake_find_package_multi"] = "argtable3" self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - diff --git a/recipes/argtable3/all/test_package/conanfile.py b/recipes/argtable3/all/test_package/conanfile.py index 9ea88425d278e..fcd48798a6df1 100644 --- a/recipes/argtable3/all/test_package/conanfile.py +++ b/recipes/argtable3/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run("{} --help".format(bin_path), run_environment=True) diff --git a/recipes/argtable3/config.yml b/recipes/argtable3/config.yml index e33f13d2032a5..2f3c419dfc7ff 100644 --- a/recipes/argtable3/config.yml +++ b/recipes/argtable3/config.yml @@ -1,4 +1,6 @@ versions: + "3.2.1": + folder: "all" "3.2.0": folder: "all" "3.1.5": diff --git a/recipes/armadillo/all/CMakeLists.txt b/recipes/armadillo/all/CMakeLists.txt new file mode 100644 index 0000000000000..ec859e0f118e0 --- /dev/null +++ b/recipes/armadillo/all/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.4) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS on) + +add_subdirectory("source_subfolder") diff --git a/recipes/armadillo/all/conandata.yml b/recipes/armadillo/all/conandata.yml new file mode 100644 index 0000000000000..db673d3844290 --- /dev/null +++ b/recipes/armadillo/all/conandata.yml @@ -0,0 +1,15 @@ +sources: + "10.7.0": + url: "http://sourceforge.net/projects/arma/files/armadillo-10.7.0.tar.xz" + sha256: "9bf60db6fd237721908747a0e56797b97b7ceae3603f2cca0b012a3b88265d3f" + "10.7.3": + url: "http://sourceforge.net/projects/arma/files/armadillo-10.7.3.tar.xz" + sha256: "aac930d5fbc23dca9453ff3647d03f7d90d9584a4556719ad7bc7adab7db6ff5" + +patches: + "10.7.0": + - patch_file: "patches/0001-Guard-dependency-discovery-10.7.x.patch" + base_path: "source_subfolder" + "10.7.3": + - patch_file: "patches/0001-Guard-dependency-discovery-10.7.x.patch" + base_path: "source_subfolder" diff --git a/recipes/armadillo/all/conanfile.py b/recipes/armadillo/all/conanfile.py new file mode 100644 index 0000000000000..af32d66f1621f --- /dev/null +++ b/recipes/armadillo/all/conanfile.py @@ -0,0 +1,336 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + + +class ArmadilloConan(ConanFile): + name = "armadillo" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://arma.sourceforge.net" + description = "Armadillo is a high quality C++ library for linear algebra and scientific computing, aiming towards a good balance between speed and ease of use." + topics = ( + "linear algebra", + "scientific computing", + "matrix", + "vector", + "math", + "blas", + "lapack", + "mkl", + "hdf5", + ) + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "use_blas": [ + False, + "openblas", + "intel_mkl", + "system_blas", + "system_flexiblas", + "framework_accelerate", + ], + "use_lapack": [ + False, + "openblas", + "intel_mkl", + "system_lapack", + "system_atlas", + "framework_accelerate", + ], + "use_hdf5": [True, False], + "use_superlu": [False, "system_superlu"], + "use_extern_rng": [True, False], + "use_arpack": [False, "system_arpack"], + "use_wrapper": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "use_blas": "openblas", + "use_lapack": False, + "use_hdf5": True, + "use_superlu": False, + "use_extern_rng": False, + "use_arpack": False, + "use_wrapper": False, + } + # Values that must be set for multiple options to be valid + _co_dependencies = { + "intel_mkl": [ + "use_blas", + "use_lapack", + ], + "framework_accelerate": [ + "use_blas", + "use_lapack", + ], + } + exports_sources = ["CMakeLists.txt", "patches/*"] + generators = ( + "cmake", + "cmake_find_package", + ) + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.os == "Macos": + # Macos will default to Accelerate framework + self.options.use_blas = "framework_accelerate" + self.options.use_lapack = "framework_accelerate" + + # According with the CMakeLists file in armadillo, MinGW doesn't correctly handle thread_local. + # If any of MINGW, MSYS, CYGWIN or MSVC are True in during cmake configure, the ARMA_USE_EXTERN_RNG option will be set to false. + # Therefore, in these cases we remove the `use_extern_rng` option in conan + if self.settings.os == "Windows": + del self.options.use_extern_rng + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, "11") + + if self.settings.os != "Macos" and ( + self.options.use_blas == "framework_accelerate" + or self.options.use_lapack == "framework_accelerate" + ): + raise ConanInvalidConfiguration( + "framework_accelerate can only be used on Macos" + ) + + for value, options in self._co_dependencies.items(): + options_without_value = [ + x for x in options if getattr(self.options, x) != value + ] + if options_without_value and (len(options) != len(options_without_value)): + raise ConanInvalidConfiguration( + "Options {} must all be set to '{}' to use this feature. To fix this, set option {} to '{}'.".format( + ", ".join(options), + value, + ", ".join(options_without_value), + value, + ) + ) + + if ( + self.options.use_lapack == "openblas" + and self.options.use_blas != "openblas" + ): + raise ConanInvalidConfiguration( + "OpenBLAS can only provide LAPACK functionality when also providing BLAS functionality. Set use_blas=openblas and try again." + ) + + deprecated_opts = list( + set( + [ + opt + for opt in [ + str(self.options.use_blas), + str(self.options.use_lapack), + ] + if "system" in opt + ] + ) + ) + + for opt in deprecated_opts: + self.output.warn( + f"DEPRECATION NOTICE: Value {opt} uses armadillo's default dependency search and will be replaced when this package becomes available in ConanCenter" + ) + + # Ignore use_extern_rng when the option has been removed + if self.options.use_wrapper and not self.options.get_safe("use_extern_rng", True): + raise ConanInvalidConfiguration( + "The wrapper requires the use of an external RNG. Set use_extern_rng=True and try again." + ) + + def requirements(self): + # Optional requirements + # TODO: "atlas/3.10.3" # Pending https://github.com/conan-io/conan-center-index/issues/6757 + # TODO: "superlu/5.2.2" # Pending https://github.com/conan-io/conan-center-index/issues/6756 + # TODO: "arpack/1.0" # Pending https://github.com/conan-io/conan-center-index/issues/6755 + # TODO: "flexiblas/3.0.4" # Pending https://github.com/conan-io/conan-center-index/issues/6827 + + if self.options.use_hdf5: + # Use the conan dependency if the system lib isn't being used + self.requires("hdf5/1.12.0") + + if self.options.use_blas == "openblas": + self.requires("openblas/0.3.15") + # Note that if you're relying on this to build LAPACK, you _must_ have + # a fortran compiler installed. If you don't, OpenBLAS will build successfully but + # without LAPACK support, which isn't obvious. + # This can be achieved by setting the FC environment variable in your conan profile + self.options["openblas"].build_lapack = ( + self.options.use_lapack == "openblas" + ) + if ( + self.options.use_blas == "intel_mkl" + and self.options.use_lapack == "intel_mkl" + ): + # Consumers can override this requirement with their own by using + # self.requires("intel-mkl/version@user/channel, override=True) in their consumer + # conanfile.py + if ( + self.options.use_blas == "intel_mkl" + or self.options.use_lapack == "intel_mkl" + ): + self.output.warn( + "The intel-mkl package does not exist in CCI. To use an Intel MKL package, override this requirement with your own recipe." + ) + self.requires("intel-mkl/2021.4") + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["ARMA_USE_LAPACK"] = self.options.use_lapack + self._cmake.definitions["ARMA_USE_BLAS"] = self.options.use_blas + self._cmake.definitions["ARMA_USE_ATLAS"] = ( + self.options.use_lapack == "system_atlas" + ) + self._cmake.definitions["ARMA_USE_HDF5"] = self.options.use_hdf5 + self._cmake.definitions["ARMA_USE_ARPACK"] = self.options.use_arpack + self._cmake.definitions["ARMA_USE_EXTERN_RNG"] = self.options.get_safe("use_exern_rng", default=False) + self._cmake.definitions["ARMA_USE_SUPERLU"] = self.options.use_superlu + self._cmake.definitions["ARMA_USE_WRAPPER"] = self.options.use_wrapper + self._cmake.definitions["ARMA_USE_ACCELERATE"] = ( + self.options.use_blas == "framework_accelerate" + or self.options.use_lapack == "framework_accelerate" + ) and self.settings.os == "Macos" + self._cmake.definitions["DETECT_HDF5"] = self.options.use_hdf5 + self._cmake.definitions["USE_OPENBLAS"] = self.options.use_blas == "openblas" + self._cmake.definitions["USE_MKL"] = ( + self.options.use_blas == "intel_mkl" + and self.options.use_lapack == "intel_mkl" + ) + self._cmake.definitions["USE_SYSTEM_LAPACK"] = ( + self.options.use_lapack == "system_lapack" + ) + self._cmake.definitions["USE_SYSTEM_BLAS"] = ( + self.options.use_blas == "system_blas" + ) + self._cmake.definitions["USE_SYSTEM_ATLAS"] = ( + self.options.use_lapack == "system_atlas" + ) + self._cmake.definitions["USE_SYSTEM_HDF5"] = False + self._cmake.definitions["USE_SYSTEM_ARPACK"] = self.options.use_arpack + self._cmake.definitions["USE_SYSTEM_SUPERLU"] = self.options.use_superlu + self._cmake.definitions["USE_SYSTEM_OPENBLAS"] = False + self._cmake.definitions["USE_SYSTEM_FLEXIBLAS"] = ( + self.options.use_blas == "system_flexiblas" + ) + self._cmake.definitions["ALLOW_FLEXIBLAS_LINUX"] = ( + self.options.use_blas == "system_flexiblas" and self.settings.os == "Linux" + ) + self._cmake.definitions["ALLOW_OPENBLAS_MACOS"] = ( + self.options.use_blas == "openblas" + ) and self.settings.os == "Macos" + self._cmake.definitions["ALLOW_BLAS_LAPACK_MACOS"] = ( + self.options.use_blas != "framework_accelerate" + ) + self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + strip_root=True, + destination=self._source_subfolder, + filename="{name}-{version}.tar.xz".format( + name=self.name, version=self.version + ), + ) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + self.copy("NOTICE.txt", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["armadillo"] + self.cpp_info.names["pkg_config"] = "armadillo" + + if self.options.get_safe("use_extern_rng"): + self.cpp_info.defines.append("ARMA_USE_EXTERN_RNG") + + if self.settings.build_type == "Release": + self.cpp_info.defines.append("ARMA_NO_DEBUG") + + # The wrapper library links everything together. If disabled, system libs must be + # linked manually + if not self.options.use_wrapper: + self.cpp_info.defines.append("ARMA_DONT_USE_WRAPPER") + if self.options.use_blas == "framework_accelerate": + self.cpp_info.frameworks.append("Accelerate") + + if self.options.use_hdf5: + self.cpp_info.defines.append("ARMA_USE_HDF5") + else: + self.cpp_info.defines.append("ARMA_DONT_USE_HDF5") + + if self.options.use_blas: + self.cpp_info.defines.append("ARMA_USE_BLAS") + if self.options.use_blas == "system_blas" and not self.options.use_wrapper: + self.cpp_info.system_libs.extend(["blas"]) + else: + self.cpp_info.defines.append("ARMA_DONT_USE_BLAS") + + if self.options.use_lapack: + self.cpp_info.defines.append("ARMA_USE_LAPACK") + if ( + self.options.use_lapack == "system_lapack" + and not self.options.use_wrapper + ): + self.cpp_info.system_libs.extend(["lapack"]) + else: + self.cpp_info.defines.append("ARMA_DONT_USE_LAPACK") + + if self.options.use_arpack: + self.cpp_info.defines.append("ARMA_USE_ARPACK") + if not self.options.use_wrapper: + self.cpp_info.system_libs.extend(["arpack"]) + else: + self.cpp_info.defines.append("ARMA_DONT_USE_ARPACK") + + if self.options.use_superlu: + self.cpp_info.defines.append("ARMA_USE_SUPERLU") + if not self.options.use_wrapper: + self.cpp_info.system_libs.extend(["superlu"]) + else: + self.cpp_info.defines.append("ARMA_DONT_USE_SUPERLU") + + if self.options.use_lapack == "system_atlas": + self.cpp_info.defines.append("ARMA_USE_ATLAS") + if not self.options.use_wrapper: + self.cpp_info.system_libs.extend(["atlas"]) + else: + self.cpp_info.defines.append("ARMA_DONT_USE_ATLAS") diff --git a/recipes/armadillo/all/patches/0001-Guard-dependency-discovery-10.7.x.patch b/recipes/armadillo/all/patches/0001-Guard-dependency-discovery-10.7.x.patch new file mode 100644 index 0000000000000..89386d2e8686f --- /dev/null +++ b/recipes/armadillo/all/patches/0001-Guard-dependency-discovery-10.7.x.patch @@ -0,0 +1,148 @@ +From 48a5162899ebeb0ba3ca3141b587a53d2eda4223 Mon Sep 17 00:00:00 2001 +From: Samuel Dowling +Date: Thu, 30 Sep 2021 23:51:35 +0930 +Subject: [PATCH] Guard dependency discovery + +* Add guards to prevent usage of custom cmake find package scripts. +* Remove ability to inject hdf5 include directory into compiled binary +--- + CMakeLists.txt | 72 ++++++++++++++++++++----- + include/armadillo_bits/config.hpp.cmake | 2 +- + 2 files changed, 60 insertions(+), 14 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7857f8c..5f87f7e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -274,7 +274,11 @@ if(APPLE) + set(ARMA_USE_ACCELERATE true) + + if(ALLOW_OPENBLAS_MACOS) +- include(ARMA_FindOpenBLAS) ++ if(USE_OPENBLAS) ++ find_package(OpenBLAS) ++ else() ++ set(OpenBLAS_FOUND NO) ++ endif() + message(STATUS "OpenBLAS_FOUND = ${OpenBLAS_FOUND}") + message(STATUS "") + message(STATUS "*** If use of OpenBLAS is causing problems,") +@@ -289,8 +293,16 @@ if(APPLE) + endif() + + if(ALLOW_BLAS_LAPACK_MACOS) +- include(ARMA_FindBLAS) +- include(ARMA_FindLAPACK) ++ if(USE_SYSTEM_BLAS) ++ include(ARMA_FindBLAS) ++ else() ++ set(BLAS_FOUND NO) ++ endif() ++ if(USE_SYSTEM_LAPACK) ++ include(ARMA_FindLAPACK) ++ else() ++ set(LAPACK_FOUND NO) ++ endif() + message(STATUS " BLAS_FOUND = ${BLAS_FOUND}" ) + message(STATUS "LAPACK_FOUND = ${LAPACK_FOUND}") + message(STATUS "") +@@ -329,14 +341,42 @@ if(APPLE) + + else() + +- include(ARMA_FindMKL) +- include(ARMA_FindOpenBLAS) +- include(ARMA_FindATLAS) +- include(ARMA_FindBLAS) +- include(ARMA_FindLAPACK) ++ if(USE_MKL) ++ find_package(MKL) ++ else() ++ set(MKL_FOUND NO) ++ endif() ++ ++ if(USE_OPENBLAS) ++ find_package(OpenBLAS) ++ else() ++ set(OpenBLAS_FOUND NO) ++ endif() ++ ++ if(USE_SYSTEM_ATLAS) ++ include(ARMA_FindATLAS) ++ else() ++ set(ATLAS_FOUND NO) ++ endif() ++ ++ if(USE_SYSTEM_BLAS) ++ include(ARMA_FindBLAS) ++ else() ++ set(BLAS_FOUND NO) ++ endif() ++ ++ if(USE_SYSTEM_LAPACK) ++ include(ARMA_FindLAPACK) ++ else() ++ set(LAPACK_FOUND NO) ++ endif() + + if(ALLOW_FLEXIBLAS_LINUX AND (${CMAKE_SYSTEM_NAME} MATCHES "Linux")) +- include(ARMA_FindFlexiBLAS) ++ if(USE_SYSTEM_FLEXIBLAS) ++ include(ARMA_FindFlexiBLAS) ++ else() ++ set(FlexiBLAS_FOUND NO) ++ endif() + endif() + + message(STATUS " MKL_FOUND = ${MKL_FOUND}" ) +@@ -470,8 +510,6 @@ if(DETECT_HDF5) + # HDF5_INCLUDE_DIRS is the correct include directory. So, in either case we + # can use the first element in the list. Issue a status message, too, just + # for good measure. +- list(GET HDF5_INCLUDE_DIRS 0 ARMA_HDF5_INCLUDE_DIR) +- message(STATUS "ARMA_HDF5_INCLUDE_DIR = ${ARMA_HDF5_INCLUDE_DIR}") + message(STATUS "") + message(STATUS "*** If use of HDF5 is causing problems,") + message(STATUS "*** rerun cmake with HDF5 detection disabled:") +@@ -480,7 +518,11 @@ if(DETECT_HDF5) + endif() + endif() + +-include(ARMA_FindARPACK) ++if(USE_SYSTEM_ARPACK) ++ include(ARMA_FindARPACK) ++else() ++ set(ARPACK_FOUND NO) ++endif() + message(STATUS "ARPACK_FOUND = ${ARPACK_FOUND}") + + if(ARPACK_FOUND) +@@ -488,7 +530,11 @@ if(ARPACK_FOUND) + set(ARMA_LIBS ${ARMA_LIBS} ${ARPACK_LIBRARY}) + endif() + +-include(ARMA_FindSuperLU5) ++if(USE_SYSTEM_SUPERLU) ++ include(ARMA_FindSuperLU5) ++else() ++ set(SuperLU_FOUND NO) ++endif() + message(STATUS "SuperLU_FOUND = ${SuperLU_FOUND}") + + if(SuperLU_FOUND) +diff --git a/include/armadillo_bits/config.hpp.cmake b/include/armadillo_bits/config.hpp.cmake +index 3f7f874..998f6ec 100644 +--- a/include/armadillo_bits/config.hpp.cmake ++++ b/include/armadillo_bits/config.hpp.cmake +@@ -152,7 +152,7 @@ + #undef ARMA_USE_HDF5 + #define ARMA_USE_HDF5 + +- #define ARMA_HDF5_INCLUDE_DIR ${ARMA_HDF5_INCLUDE_DIR}/ ++ // #define ARMA_HDF5_INCLUDE_DIR ${ARMA_HDF5_INCLUDE_DIR}/ + #endif + + #if !defined(ARMA_MAT_PREALLOC) +-- +2.36.0 + diff --git a/recipes/armadillo/all/test_package/CMakeLists.txt b/recipes/armadillo/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..708a6618b6043 --- /dev/null +++ b/recipes/armadillo/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.6) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(armadillo REQUIRED) + +add_executable(example example.cpp) +target_link_libraries(example armadillo::armadillo) +set_property(TARGET example PROPERTY CXX_STANDARD 11) diff --git a/recipes/armadillo/all/test_package/conanfile.py b/recipes/armadillo/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5eba7cbe1bb9c --- /dev/null +++ b/recipes/armadillo/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class ArmadilloTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/armadillo/all/test_package/example.cpp b/recipes/armadillo/all/test_package/example.cpp new file mode 100644 index 0000000000000..e931fd518cedd --- /dev/null +++ b/recipes/armadillo/all/test_package/example.cpp @@ -0,0 +1,207 @@ +#include +#include + +using namespace std; +using namespace arma; + +// Armadillo documentation is available at: +// http://arma.sourceforge.net/docs.html + +// NOTE: the C++11 "auto" keyword is not recommended for use with Armadillo objects and functions + +int +main(int argc, char** argv) + { + cout << "Armadillo version: " << arma_version::as_string() << endl; + + // construct a matrix according to given size and form of element initialisation + mat A(2,3,fill::zeros); + + // .n_rows and .n_cols are read only + cout << "A.n_rows: " << A.n_rows << endl; + cout << "A.n_cols: " << A.n_cols << endl; + + A(1,2) = 456.0; // access an element (indexing starts at 0) + A.print("A:"); + + A = 5.0; // scalars are treated as a 1x1 matrix + A.print("A:"); + + A.set_size(4,5); // change the size (data is not preserved) + + A.fill(5.0); // set all elements to a specific value + A.print("A:"); + + A = { { 0.165300, 0.454037, 0.995795, 0.124098, 0.047084 }, + { 0.688782, 0.036549, 0.552848, 0.937664, 0.866401 }, + { 0.348740, 0.479388, 0.506228, 0.145673, 0.491547 }, + { 0.148678, 0.682258, 0.571154, 0.874724, 0.444632 }, + { 0.245726, 0.595218, 0.409327, 0.367827, 0.385736 } }; + + A.print("A:"); + +#ifdef ARMA_USE_LAPACK + // determinant + cout << "det(A): " << det(A) << endl; + + // inverse + cout << "inv(A): " << endl << inv(A) << endl; +#else + cout << "LAPACK not available. Skipping calls to functions det() and inv()" << endl; +#endif + + // save matrix as a text file + A.save("A.txt", raw_ascii); + + // load from file + mat B; + B.load("A.txt"); + + // submatrices + cout << "B( span(0,2), span(3,4) ):" << endl << B( span(0,2), span(3,4) ) << endl; + + cout << "B( 0,3, size(3,2) ):" << endl << B( 0,3, size(3,2) ) << endl; + + cout << "B.row(0): " << endl << B.row(0) << endl; + + cout << "B.col(1): " << endl << B.col(1) << endl; + + // transpose + cout << "B.t(): " << endl << B.t() << endl; + + // maximum from each column (traverse along rows) + cout << "max(B): " << endl << max(B) << endl; + + // maximum from each row (traverse along columns) + cout << "max(B,1): " << endl << max(B,1) << endl; + + // maximum value in B + cout << "max(max(B)) = " << max(max(B)) << endl; + + // sum of each column (traverse along rows) + cout << "sum(B): " << endl << sum(B) << endl; + + // sum of each row (traverse along columns) + cout << "sum(B,1) =" << endl << sum(B,1) << endl; + + // sum of all elements + cout << "accu(B): " << accu(B) << endl; + + // trace = sum along diagonal + cout << "trace(B): " << trace(B) << endl; + + // generate the identity matrix + mat C = eye(4,4); + + // random matrix with values uniformly distributed in the [0,1] interval + mat D = randu(4,4); + D.print("D:"); + + // row vectors are treated like a matrix with one row + rowvec r = { 0.59119, 0.77321, 0.60275, 0.35887, 0.51683 }; + r.print("r:"); + + // column vectors are treated like a matrix with one column + vec q = { 0.14333, 0.59478, 0.14481, 0.58558, 0.60809 }; + q.print("q:"); + + // convert matrix to vector; data in matrices is stored column-by-column + vec v = vectorise(A); + v.print("v:"); + + // dot or inner product + cout << "as_scalar(r*q): " << as_scalar(r*q) << endl; + + // outer product + cout << "q*r: " << endl << q*r << endl; + + // multiply-and-accumulate operation (no temporary matrices are created) + cout << "accu(A % B) = " << accu(A % B) << endl; + + // example of a compound operation + B += 2.0 * A.t(); + B.print("B:"); + + // imat specifies an integer matrix + imat AA = { { 1, 2, 3 }, + { 4, 5, 6 }, + { 7, 8, 9 } }; + + imat BB = { { 3, 2, 1 }, + { 6, 5, 4 }, + { 9, 8, 7 } }; + + // comparison of matrices (element-wise); output of a relational operator is a umat + umat ZZ = (AA >= BB); + ZZ.print("ZZ:"); + + // cubes ("3D matrices") + cube Q( B.n_rows, B.n_cols, 2 ); + + Q.slice(0) = B; + Q.slice(1) = 2.0 * B; + + Q.print("Q:"); + + // 2D field of matrices; 3D fields are also supported + field F(4,3); + + for(uword col=0; col < F.n_cols; ++col) + for(uword row=0; row < F.n_rows; ++row) + { + F(row,col) = randu(2,3); // each element in field is a matrix + } + + F.print("F:"); + + // Test that the result of the use_extern_rng option in the conan recipe +#ifdef ARMA_USE_EXTERN_RNG + cout << "ARMA_USE_EXTERN_RNG set." << endl; +#else + cout << "ARMA_USE_EXTERN_RNG not set." << endl; +#endif + + arma::vec v2{1,2,3,4}; + arma::arma_rng::set_seed(1237); + v2.randn(); + v2.print("v2 (randn):"); + +#ifdef ARMA_USE_HDF5 + std::cout << "ARMA_USE_HDF5 set" << std::endl; + arma::Mat a; + a.randu(20, 20); + + // Save first. + a.save("file.h5", hdf5_binary); + + // Load as different matrix. + arma::Mat b; + b.load("file.h5", hdf5_binary); + + // Check that they are the same. + bool result = true; + for (uword i = 0; i < a.n_elem; ++i) + { + result *= a[i] == b[i]; + } + std::cout << "Matrix written to and read from file.h5 are equivalent: " << result << "\n"; + + // Now autoload. + arma::Mat c; + c.load("file.h5"); + + // Check that they are the same. + result = true; + for (uword i = 0; i < a.n_elem; ++i) + { + result *= a[i] == c[i]; + } + std::cout << "Matrix written to and autoloaded from file.h5 are equivalent: " << result << "\n"; + + std::remove("file.h5"); +#else + std::cout << "ARMA_USE_HDF5 not set" << std::endl; +#endif + + return 0; + } diff --git a/recipes/armadillo/config.yml b/recipes/armadillo/config.yml new file mode 100644 index 0000000000000..9cadebcc7f6bf --- /dev/null +++ b/recipes/armadillo/config.yml @@ -0,0 +1,5 @@ +versions: + "10.7.0": + folder: all + "10.7.3": + folder: all diff --git a/recipes/arrow/all/CMakeLists.txt b/recipes/arrow/all/CMakeLists.txt deleted file mode 100644 index 5fce337b405db..0000000000000 --- a/recipes/arrow/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder/cpp) diff --git a/recipes/arrow/all/conandata.yml b/recipes/arrow/all/conandata.yml index 4a47e9e42cf2a..dd9d6a4aeec6c 100644 --- a/recipes/arrow/all/conandata.yml +++ b/recipes/arrow/all/conandata.yml @@ -1,26 +1,83 @@ sources: - "1.0.0": - url: "https://github.com/apache/arrow/archive/apache-arrow-1.0.0.tar.gz" - sha256: "08fbd4c633c08939850d619ca0224c75d7a0526467c721c0838b8aa7efccb270" + "10.0.0": + url: "https://www.apache.org/dyn/closer.lua/arrow/arrow-10.0.0/apache-arrow-10.0.0.tar.gz?action=download" + sha256: "5b46fa4c54f53e5df0019fe0f9d421e93fc906b625ebe8e89eed010d561f1f12" + "8.0.1": + url: "https://www.apache.org/dyn/closer.lua/arrow/arrow-8.0.1/apache-arrow-8.0.1.tar.gz?action=download" + sha256: "82d46929f7574715551da21700f100b39f99c3c4d6790f26cac86d869d64e94e" + "8.0.0": + url: "https://www.apache.org/dyn/closer.lua/arrow/arrow-8.0.0/apache-arrow-8.0.0.tar.gz?action=download" + sha256: "ad9a05705117c989c116bae9ac70492fe015050e1b80fb0e38fde4b5d863aaa3" + "7.0.0": + url: "https://www.apache.org/dyn/closer.lua/arrow/arrow-7.0.0/apache-arrow-7.0.0.tar.gz?action=download" + sha256: "e8f49b149a15ecef4e40fcfab1b87c113c6b1ee186005c169e5cdf95d31a99de" "2.0.0": - url: "https://github.com/apache/arrow/archive/apache-arrow-2.0.0.tar.gz" - sha256: "ea299df9cf440cfc43393ce12ee6d9a4c9d0dfa9fde33c3bc9b70ec25520a844" -patches: + url: "https://www.apache.org/dyn/closer.lua/arrow/arrow-2.0.0/apache-arrow-2.0.0.tar.gz?action=download" + sha256: "be0342cc847bb340d86aeaef43596a0b6c1dbf1ede9c789a503d939e01c71fbe" "1.0.0": - - base_path: "source_subfolder" - patch_file: "patches/1.0.0-0001-cmake.patch" - - base_path: "source_subfolder" - patch_file: "patches/1.0.0-0002-jemalloc.patch" - - base_path: "source_subfolder" - patch_file: "patches/1.0.0-0003-fix-shared-msvc.patch" - - base_path: "source_subfolder" - patch_file: "patches/1.0.0-0004-mallctl-takes-size_t.patch" + url: "https://www.apache.org/dyn/closer.lua/arrow/arrow-1.0.0/apache-arrow-1.0.0.tar.gz?action=download" + sha256: "86ddb9feb48203a5aaf9cc4f2827525e20a2ca4d7239e492af17e74532ccf243" +patches: + "10.0.0": + - patch_file: "patches/10.0.0-0001-mallctl-takes-size_t.patch" + patch_description: "use size_t instead of ssize_t" + patch_type: "backport" + - patch_file: "patches/10.0.0-0002-fix-cmake.patch" + patch_description: "use cci package" + patch_type: "conan" + "8.0.1": + - patch_file: "patches/8.0.0-0003-mallctl-takes-size_t.patch" + patch_description: "use size_t instead of ssize_t" + patch_type: "backport" + - patch_file: "patches/8.0.0-0005-install-utils.patch" + patch_description: "enable utilis installation" + patch_type: "conan" + - patch_file: "patches/8.0.0-0006-fix-cmake.patch" + patch_description: "use cci package" + patch_type: "conan" + "8.0.0": + - patch_file: "patches/8.0.0-0003-mallctl-takes-size_t.patch" + patch_description: "use size_t instead of ssize_t" + patch_type: "backport" + - patch_file: "patches/8.0.0-0005-install-utils.patch" + patch_description: "enable utilis installation" + patch_type: "conan" + - patch_file: "patches/8.0.0-0006-fix-cmake.patch" + patch_description: "use cci package" + patch_type: "conan" + "7.0.0": + - patch_file: "patches/7.0.0-0003-mallctl-takes-size_t.patch" + patch_description: "use size_t instead of ssize_t" + patch_type: "backport" + - patch_file: "patches/7.0.0-0006-install-utils.patch" + patch_description: "enable utilis installation" + patch_type: "conan" + - patch_file: "patches/7.0.0-0007-fix-cmake.patch" + patch_description: "use cci package" + patch_type: "conan" "2.0.0": - - base_path: "source_subfolder" - patch_file: "patches/2.0.0-0001-cmake.patch" - - base_path: "source_subfolder" - patch_file: "patches/2.0.0-0002-jemalloc.patch" - - base_path: "source_subfolder" - patch_file: "patches/2.0.0-0003-fix-shared-msvc.patch" - - base_path: "source_subfolder" - patch_file: "patches/1.0.0-0004-mallctl-takes-size_t.patch" + - patch_file: "patches/2.0.0-0003-fix-shared-msvc.patch" + patch_description: "make shared enabled in msvc" + patch_type: "backport" + - patch_file: "patches/1.0.0-0004-mallctl-takes-size_t.patch" + patch_description: "use size_t instead of ssize_t" + patch_type: "backport" + - patch_file: "patches/2.0.0-0005-gandiva-engine.patch" + patch_description: "fix grandiva compilation error" + patch_type: "backport" + - patch_file: "patches/2.0.0-0008-fix-cmake.patch" + patch_description: "use cci package" + patch_type: "conan" + "1.0.0": + - patch_file: "patches/1.0.0-0003-fix-shared-msvc.patch" + patch_description: "make shared enabled in msvc" + patch_type: "backport" + - patch_file: "patches/1.0.0-0004-mallctl-takes-size_t.patch" + patch_description: "use size_t instead of ssize_t" + patch_type: "backport" + - patch_file: "patches/1.0.0-0005-fix-make12-namespace.patch" + patch_description: "fix ambiguous `make12` function between std and date" + patch_type: "backport" + - patch_file: "patches/1.0.0-0006-fix-cmake.patch" + patch_description: "use cci package" + patch_type: "conan" diff --git a/recipes/arrow/all/conanfile.py b/recipes/arrow/all/conanfile.py index 8eb44e81ee06a..75de1c9463c65 100644 --- a/recipes/arrow/all/conanfile.py +++ b/recipes/arrow/all/conanfile.py @@ -1,44 +1,57 @@ -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc_static_runtime, is_msvc, check_min_vs +from conan.tools.files import export_conandata_patches, apply_conandata_patches, get, copy, rmdir +from conan.tools.build import check_min_cppstd, cross_building +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + import os +import glob +required_conan_version = ">=1.53.0" class ArrowConan(ConanFile): name = "arrow" description = "Apache Arrow is a cross-language development platform for in-memory data" - topics = ("conan", "arrow", "memory") + license = ("Apache-2.0",) url = "https://github.com/conan-io/conan-center-index" homepage = "https://arrow.apache.org/" - license = ("Apache-2.0",) - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake", "cmake_find_package" - settings = "os", "compiler", "build_type", "arch" + topics = ("memory", "gandiva", "parquet", "skyhook", "plasma", "hdfs", "csv", "cuda", "gcs", "json", "hive", "s3", "grpc") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "gandiva": [True, False], - "parquet": [True, False], + "parquet": ["auto", True, False], + "substrait": [True, False], + "skyhook": [True, False], "plasma": [True, False], "cli": [True, False], "compute": ["auto", True, False], - "dataset_modules": [True, False], + "dataset_modules": ["auto", True, False], "deprecated": [True, False], "encryption": [True, False], "filesystem_layer": [True, False], "hdfs_bridgs": [True, False], + "simd_level": [None, "default", "sse4_2", "avx2", "avx512", "neon", ], + "runtime_simd_level": [None, "sse4_2", "avx2", "avx512", "max"], "with_backtrace": [True, False], "with_boost": ["auto", True, False], "with_csv": [True, False], "with_cuda": [True, False], - "with_flight_rpc": [True, False], + "with_flight_rpc": ["auto", True, False], + "with_flight_sql": [True, False], + "with_gcs": [True, False], "with_gflags": ["auto", True, False], "with_glog": ["auto", True, False], "with_grpc": ["auto", True, False], - "with_hiveserver2": [True, False], "with_jemalloc": ["auto", True, False], + "with_mimalloc": ["auto", True, False], "with_json": [True, False], "with_llvm": ["auto", True, False], "with_openssl": ["auto", True, False], + "with_opentelemetry": [True, False], "with_orc": [True, False], "with_protobuf": ["auto", True, False], "with_re2": ["auto", True, False], @@ -55,30 +68,37 @@ class ArrowConan(ConanFile): "shared": False, "fPIC": True, "gandiva": False, - "parquet": False, + "parquet": "auto", + "skyhook": False, + "substrait": False, "plasma": False, "cli": False, "compute": "auto", - "dataset_modules": False, + "dataset_modules": "auto", "deprecated": True, "encryption": False, "filesystem_layer": False, "hdfs_bridgs": False, + "simd_level": "default", + "runtime_simd_level": "max", "with_backtrace": False, "with_boost": "auto", "with_brotli": False, "with_bz2": False, "with_csv": False, "with_cuda": False, - "with_flight_rpc": False, + "with_flight_rpc": "auto", + "with_flight_sql": False, + "with_gcs": False, "with_gflags": "auto", "with_jemalloc": "auto", + "with_mimalloc": False, "with_glog": "auto", "with_grpc": "auto", - "with_hiveserver2": False, "with_json": False, "with_llvm": "auto", "with_openssl": "auto", + "with_opentelemetry": False, "with_orc": False, "with_protobuf": "auto", "with_re2": "auto", @@ -89,25 +109,72 @@ class ArrowConan(ConanFile): "with_zlib": False, "with_zstd": False, } + short_paths = True - _cmake = None + @property + def _minimum_cpp_standard(self): + # arrow >= 10.0.0 requires C++17. + # https://github.com/apache/arrow/pull/13991 + return 11 if Version(self.version) < "10.0.0" else 17 @property - def _source_subfolder(self): - return "source_subfolder" + def _compilers_minimum_version(self): + return { + "gcc": "8", + "clang": "7", + "apple-clang": "10", + } + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if Version(self.version) < "2.0.0": + del self.options.simd_level + del self.options.runtime_simd_level + elif Version(self.version) < "6.0.0": + self.options.simd_level = "sse4_2" + if Version(self.version) < "6.0.0": + del self.options.with_gcs + if Version(self.version) < "7.0.0": + del self.options.skyhook + del self.options.with_flight_sql + del self.options.with_opentelemetry + if Version(self.version) < "8.0.0": + del self.options.substrait def configure(self): - if self.settings.compiler == "clang" and self.settings.compiler.version <= tools.Version("3.9"): - raise ConanInvalidConfiguration("This recipe does not support this compiler version") + if self.options.shared: + self.options.rm_safe("fPIC") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + + if self._minimum_cpp_standard == 11: + if self.info.settings.compiler == "clang" and self.info.settings.compiler.version <= Version("3.9"): + raise ConanInvalidConfiguration("This recipe does not support this compiler version") + else: + check_min_vs(self, 191) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support." + ) if self.options.shared: del self.options.fPIC if self.options.compute == False and not self._compute(True): raise ConanInvalidConfiguration("compute options is required (or choose auto)") + if self.options.parquet == False and self._parquet(True): + raise ConanInvalidConfiguration("parquet options is required (or choose auto)") + if self.options.dataset_modules == False and self._dataset_modules(True): + raise ConanInvalidConfiguration("dataset_modules options is required (or choose auto)") + if self.options.get_safe("skyhook", False): + raise ConanInvalidConfiguration("CCI has no librados recipe (yet)") if self.options.with_jemalloc == False and self._with_jemalloc(True): raise ConanInvalidConfiguration("with_jemalloc option is required (or choose auto)") if self.options.with_re2 == False and self._with_re2(True): @@ -116,6 +183,8 @@ def configure(self): raise ConanInvalidConfiguration("with_protobuf option is required (or choose auto)") if self.options.with_gflags == False and self._with_gflags(True): raise ConanInvalidConfiguration("with_gflags options is required (or choose auto)") + if self.options.with_flight_rpc == False and self._with_flight_rpc(True): + raise ConanInvalidConfiguration("with_flight_rpc options is required (or choose auto)") if self.options.with_grpc == False and self._with_grpc(True): raise ConanInvalidConfiguration("with_grpc options is required (or choose auto)") if self.options.with_boost == False and self._with_boost(True): @@ -123,14 +192,42 @@ def configure(self): if self.options.with_openssl == False and self._with_openssl(True): raise ConanInvalidConfiguration("with_openssl options is required (or choose auto)") if self.options.with_llvm == False and self._with_llvm(True): - raise ConanInvalidConfiguration("with_openssl options is required (or choose auto)") + raise ConanInvalidConfiguration("with_llvm options is required (or choose auto)") + if self.options.with_cuda: + raise ConanInvalidConfiguration("CCI has no cuda recipe (yet)") + if self.options.with_orc: + raise ConanInvalidConfiguration("CCI has no orc recipe (yet)") + if self.options.with_s3 and not self.options["aws-sdk-cpp"].config: + raise ConanInvalidConfiguration("arrow:with_s3 requires aws-sdk-cpp:config is True.") + + if self.options.shared and self._with_jemalloc(): + if self.options["jemalloc"].enable_cxx: + raise ConanInvalidConfiguration("jemmalloc.enable_cxx of a static jemalloc must be disabled") + + if Version(self.version) < "6.0.0" and self.options.get_safe("simd_level") == "default": + raise ConanInvalidConfiguration(f"In {self.ref}, simd_level options is not supported `default` value.") + + def layout(self): + cmake_layout(self, src_folder="src") def _compute(self, required=False): if required or self.options.compute == "auto": - return bool(self.options.dataset_modules) + return bool(self._parquet() or self._dataset_modules()) or bool(self.options.get_safe("substrait", False)) else: return bool(self.options.compute) + def _parquet(self, required=False): + if required or self.options.parquet == "auto": + return bool(self.options.get_safe("substrait", False)) + else: + return bool(self.options.parquet) + + def _dataset_modules(self, required=False): + if required or self.options.dataset_modules == "auto": + return bool(self.options.get_safe("substrait", False)) + else: + return bool(self.options.dataset_modules) + def _with_jemalloc(self, required=False): if required or self.options.with_jemalloc == "auto": return bool("BSD" in str(self.settings.os)) @@ -139,16 +236,26 @@ def _with_jemalloc(self, required=False): def _with_re2(self, required=False): if required or self.options.with_re2 == "auto": - return bool(self.options.gandiva) + if self.options.gandiva or self.options.parquet: + return True + if Version(self) >= "7.0.0" and (self._compute() or self._dataset_modules()): + return True + return False else: return bool(self.options.with_re2) def _with_protobuf(self, required=False): if required or self.options.with_protobuf == "auto": - return bool(self.options.gandiva or self.options.with_flight_rpc or self.options.with_orc) + return bool(self.options.gandiva or self._with_flight_rpc() or self.options.with_orc or self.options.get_safe("substrait", False)) else: return bool(self.options.with_protobuf) + def _with_flight_rpc(self, required=False): + if required or self.options.with_flight_rpc == "auto": + return bool(self.options.get_safe("with_flight_sql", False)) + else: + return bool(self.options.with_flight_rpc) + def _with_gflags(self, required=False): if required or self.options.with_gflags == "auto": return bool(self.options.plasma or self._with_glog() or self._with_grpc()) @@ -163,7 +270,7 @@ def _with_glog(self, required=False): def _with_grpc(self, required=False): if required or self.options.with_grpc == "auto": - return bool(self.options.with_flight_rpc) + return self._with_flight_rpc() else: return bool(self.options.with_grpc) @@ -171,12 +278,12 @@ def _with_boost(self, required=False): if required or self.options.with_boost == "auto": if self.options.gandiva: return True - version = tools.Version(self.version) + version = Version(self.version) if version.major == "1": - if self.options.parquet and self.settings.compiler == "gcc" and self.settings.compiler.version < tools.Version("4.9"): + if self._parquet() and self.settings.compiler == "gcc" and self.settings.compiler.version < Version("4.9"): return True - elif version.major == "2": - if self.settings.compiler == "Visual Studio": + elif version.major >= "2": + if is_msvc(self): return True return False else: @@ -184,7 +291,7 @@ def _with_boost(self, required=False): def _with_thrift(self, required=False): # No self.options.with_thift exists - return bool(self.options.with_hiveserver2 or self.options.parquet) + return bool(required or self._parquet()) def _with_utf8proc(self, required=False): if required or self.options.with_utf8proc == "auto": @@ -196,187 +303,243 @@ def _with_llvm(self, required=False): if required or self.options.with_llvm == "auto": return bool(self.options.gandiva) else: - return bool(self.options.with_openssl) + return bool(self.options.with_llvm) def _with_openssl(self, required=False): if required or self.options.with_openssl == "auto": - return bool(self.options.encryption or self.options.with_flight_rpc or self.options.with_s3) + return bool(self.options.encryption or self._with_flight_rpc() or self.options.with_s3) else: return bool(self.options.with_openssl) - def build_requirements(self): - if self._with_grpc(): - raise ConanInvalidConfiguration("CCI has no grpc recipe (yet)") + def _with_rapidjson(self): + if self.options.with_json: + return True + if Version(self.version) >= "7.0.0" and self.options.encryption: + return True + return False def requirements(self): if self._with_thrift(): - self.requires("thrift/0.13.0") - if self.options.with_backtrace: - raise ConanInvalidConfiguration("CCI has no backtrace recipe (yet)") + self.requires("thrift/0.17.0") if self._with_protobuf(): - self.requires("protobuf/3.12.4") + self.requires("protobuf/3.21.4") if self._with_jemalloc(): - self.requires("jemalloc/5.2.1") + self.requires("jemalloc/5.3.0") + if self.options.with_mimalloc: + self.requires("mimalloc/1.7.6") if self._with_boost(): - self.requires("boost/1.74.0") - if self.options.with_cuda: - raise ConanInvalidConfiguration("CCI has no cuda recipe (yet)") - if self.options.with_flight_rpc: - raise ConanInvalidConfiguration("CCI has no flight_rpc recipe (yet)") + self.requires("boost/1.80.0") if self._with_gflags(): self.requires("gflags/2.2.2") if self._with_glog(): - self.requires("glog/0.4.0") - if self.options.with_hiveserver2: - raise ConanInvalidConfiguration("CCI has no hiveserver2 recipe (yet)") - if self.options.with_json: + self.requires("glog/0.6.0") + if self.options.get_safe("with_gcs"): + self.requires("google-cloud-cpp/1.40.1") + if self._with_grpc(): + self.requires("grpc/1.50.0") + if self._with_rapidjson(): self.requires("rapidjson/1.1.0") if self._with_llvm(): - raise ConanInvalidConfiguration("CCI has no llvm recipe (yet)") + self.requires("llvm-core/13.0.0") if self._with_openssl(): - self.requires("openssl/1.1.1h") + # aws-sdk-cpp requires openssl/1.1.1. it uses deprecated functions in openssl/3.0.0 + if self.options.with_s3: + self.requires("openssl/1.1.1s") + else: + self.requires("openssl/1.1.1s") + if self.options.get_safe("with_opentelemetry"): + self.requires("opentelemetry-cpp/1.7.0") if self.options.with_s3: - self.requires("aws-sdk-cpp/1.7.299") + self.requires("aws-sdk-cpp/1.9.234") if self.options.with_brotli: self.requires("brotli/1.0.9") if self.options.with_bz2: self.requires("bzip2/1.0.8") - if self.options.with_orc: - raise ConanInvalidConfiguration("CCI has no orc recipe (yet)") if self.options.with_lz4: - self.requires("lz4/1.9.2") + self.requires("lz4/1.9.4") if self.options.with_snappy: - self.requires("snappy/1.1.8") + self.requires("snappy/1.1.9") + if Version(self.version) >= "6.0.0" and \ + self.options.get_safe("simd_level") != None or \ + self.options.get_safe("runtime_simd_level") != None: + self.requires("xsimd/9.0.1") if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.with_zstd: - self.requires("zstd/1.4.5") + self.requires("zstd/1.5.2") if self._with_re2(): - self.requires("re2/20201101") + self.requires("re2/20220601") + if self._with_utf8proc(): + self.requires("utf8proc/2.8.0") + if self.options.with_backtrace: + self.requires("libbacktrace/cci.20210118") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "arrow-apache-arrow-{}".format(self.version) - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["ARROW_USE_STATIC_CRT"] = "MT" in str(self.settings.compiler.runtime) - self._cmake.definitions["ARROW_DEPENDENCY_SOURCE"] = "SYSTEM" - self._cmake.definitions["ARROW_GANDIVA"] = self.options.gandiva - self._cmake.definitions["ARROW_PARQUET"] = self.options.parquet - self._cmake.definitions["ARROW_PLASMA"] = self.options.plasma - self._cmake.definitions["ARROW_DATASET"] = self.options.dataset_modules - self._cmake.definitions["ARROW_FILESYSTEM"] = self.options.filesystem_layer - self._cmake.definitions["PARQUET_REQUIRE_ENCRYPTION"] = self.options.encryption - self._cmake.definitions["ARROW_HDFS"] = self.options.hdfs_bridgs - self._cmake.definitions["ARROW_VERBOSE_THIRDPARTY_BUILD"] = True - self._cmake.definitions["ARROW_BUILD_SHARED"] = self.options.shared - self._cmake.definitions["ARROW_BUILD_STATIC"] = not self.options.shared - self._cmake.definitions["ARROW_NO_DEPRECATED_API"] = not self.options.deprecated - self._cmake.definitions["ARROW_FLIGHT"] = self.options.with_flight_rpc - self._cmake.definitions["ARROW_HIVESERVER2"] = self.options.with_hiveserver2 - self._cmake.definitions["ARROW_COMPUTE"] = self._compute() - self._cmake.definitions["ARROW_CSV"] = self.options.with_csv - self._cmake.definitions["ARROW_CUDA"] = self.options.with_cuda - self._cmake.definitions["ARROW_JEMALLOC"] = self._with_jemalloc() - self._cmake.definitions["ARROW_JSON"] = self.options.with_json - - # self._cmake.definitions["ARROW_BOOST_VENDORED"] = False - self._cmake.definitions["BOOST_SOURCE"] = "SYSTEM" - self._cmake.definitions["Protobuf_SOURCE"] = "SYSTEM" - self._cmake.definitions["gRPC_SOURCE"] = "SYSTEM" + get(self, **self.conan_data["sources"][self.version], + filename=f"apache-arrow-{self.version}.tar.gz", destination=self.source_folder, strip_root=True) + + def generate(self): + # BUILD_SHARED_LIBS and POSITION_INDEPENDENT_CODE are automatically parsed when self.options.shared or self.options.fPIC exist + tc = CMakeToolchain(self) + if cross_building(self): + cmake_system_processor = { + "armv8": "aarch64", + "armv8.3": "aarch64", + }.get(str(self.settings.arch), str(self.settings.arch)) + tc.variables["CMAKE_SYSTEM_PROCESSOR"] = cmake_system_processor + if cmake_system_processor == "aarch64": + tc.variables["ARROW_CPU_FLAG"] = "armv8" + if is_msvc(self): + tc.variables["ARROW_USE_STATIC_CRT"] = is_msvc_static_runtime(self) + tc.variables["ARROW_DEPENDENCY_SOURCE"] = "SYSTEM" + tc.variables["ARROW_GANDIVA"] = bool(self.options.gandiva) + tc.variables["ARROW_PARQUET"] = self._parquet() + tc.variables["ARROW_SUBSTRAIT"] = bool(self.options.get_safe("substrait", False)) + tc.variables["ARROW_PLASMA"] = bool(self.options.plasma) + tc.variables["ARROW_DATASET"] = self._dataset_modules() + tc.variables["ARROW_FILESYSTEM"] = bool(self.options.filesystem_layer) + tc.variables["PARQUET_REQUIRE_ENCRYPTION"] = bool(self.options.encryption) + tc.variables["ARROW_HDFS"] = bool(self.options.hdfs_bridgs) + tc.variables["ARROW_VERBOSE_THIRDPARTY_BUILD"] = True + tc.variables["ARROW_BUILD_SHARED"] = bool(self.options.shared) + tc.variables["ARROW_BUILD_STATIC"] = not bool(self.options.shared) + tc.variables["ARROW_NO_DEPRECATED_API"] = not bool(self.options.deprecated) + tc.variables["ARROW_FLIGHT"] = self._with_flight_rpc() + tc.variables["ARROW_FLIGHT_SQL"] = bool(self.options.get_safe("with_flight_sql", False)) + tc.variables["ARROW_COMPUTE"] = self._compute() + tc.variables["ARROW_CSV"] = bool(self.options.with_csv) + tc.variables["ARROW_CUDA"] = bool(self.options.with_cuda) + tc.variables["ARROW_JEMALLOC"] = self._with_jemalloc() + tc.variables["ARROW_MIMALLOC"] = bool(self.options.with_mimalloc) + tc.variables["ARROW_JSON"] = bool(self.options.with_json) + tc.variables["google_cloud_cpp_SOURCE"] = "SYSTEM" + tc.variables["ARROW_GCS"] = bool(self.options.get_safe("with_gcs", False)) + tc.variables["BOOST_SOURCE"] = "SYSTEM" + tc.variables["Protobuf_SOURCE"] = "SYSTEM" if self._with_protobuf(): - self._cmake.definitions["ARROW_PROTOBUF_USE_SHARED"] = self.options["protobuf"].shared - self._cmake.definitions["ARROW_HDFS"] = self.options.hdfs_bridgs - self._cmake.definitions["ARROW_USE_GLOG"] = self._with_glog() - self._cmake.definitions["GLOG_SOURCE"] = "SYSTEM" - self._cmake.definitions["ARROW_WITH_BACKTRACE"] = self.options.with_backtrace - self._cmake.definitions["ARROW_WITH_BROTLI"] = self.options.with_brotli - self._cmake.definitions["Brotli_SOURCE"] = "SYSTEM" - self._cmake.definitions["ARROW_BROTLI_USE_SHARED"] = "brotli" in self.options and not self.options["brotli"].shared - self._cmake.definitions["gflags_SOURCE"] = "SYSTEM" - self._cmake.definitions["ARROW_WITH_BZ2"] = self.options.with_bz2 - self._cmake.definitions["BZip2_SOURCE"] = "SYSTEM" - self._cmake.definitions["ARROW_WITH_LZ4"] = self.options.with_lz4 - self._cmake.definitions["Lz4_SOURCE"] = "SYSTEM" - self._cmake.definitions["ARROW_WITH_SNAPPY"] = self.options.with_snappy - self._cmake.definitions["Snappy_SOURCE"] = "SYSTEM" - self._cmake.definitions["ARROW_WITH_ZLIB"] = self.options.with_zlib - self._cmake.definitions["RE2_SOURCE"] = "SYSTEM" - self._cmake.definitions["ZLIB_SOURCE"] = "SYSTEM" - self._cmake.definitions["ARROW_WITH_ZSTD"] = self.options.with_zstd - if tools.Version(self.version) >= "2.0": - self._cmake.definitions["zstd_SOURCE"] = "SYSTEM" + tc.variables["ARROW_PROTOBUF_USE_SHARED"] = bool(self.options["protobuf"].shared) + tc.variables["gRPC_SOURCE"] = "SYSTEM" + if self._with_grpc(): + tc.variables["ARROW_GRPC_USE_SHARED"] = bool(self.options["grpc"].shared) + + tc.variables["ARROW_USE_GLOG"] = self._with_glog() + tc.variables["GLOG_SOURCE"] = "SYSTEM" + tc.variables["ARROW_WITH_BACKTRACE"] = bool(self.options.with_backtrace) + tc.variables["ARROW_WITH_BROTLI"] = bool(self.options.with_brotli) + tc.variables["brotli_SOURCE"] = "SYSTEM" + if self.options.with_brotli: + tc.variables["ARROW_BROTLI_USE_SHARED"] = bool(self.options["brotli"].shared) + tc.variables["gflags_SOURCE"] = "SYSTEM" + if self._with_gflags(): + tc.variables["ARROW_GFLAGS_USE_SHARED"] = bool(self.options["gflags"].shared) + tc.variables["ARROW_WITH_BZ2"] = bool(self.options.with_bz2) + tc.variables["BZip2_SOURCE"] = "SYSTEM" + if self.options.with_bz2: + tc.variables["ARROW_BZ2_USE_SHARED"] = bool(self.options["bzip2"].shared) + tc.variables["ARROW_WITH_LZ4"] = bool(self.options.with_lz4) + tc.variables["lz4_SOURCE"] = "SYSTEM" + if self.options.with_lz4: + tc.variables["ARROW_LZ4_USE_SHARED"] = bool(self.options["lz4"].shared) + tc.variables["ARROW_WITH_SNAPPY"] = bool(self.options.with_snappy) + tc.variables["RapidJSON_SOURCE"] = "SYSTEM" + tc.variables["Snappy_SOURCE"] = "SYSTEM" + if self.options.with_snappy: + tc.variables["ARROW_SNAPPY_USE_SHARED"] = bool(self.options["snappy"].shared) + tc.variables["ARROW_WITH_ZLIB"] = bool(self.options.with_zlib) + tc.variables["re2_SOURCE"] = "SYSTEM" + tc.variables["ZLIB_SOURCE"] = "SYSTEM" + tc.variables["xsimd_SOURCE"] = "SYSTEM" + tc.variables["ARROW_WITH_ZSTD"] = bool(self.options.with_zstd) + if Version(self.version) >= "2.0": + tc.variables["zstd_SOURCE"] = "SYSTEM" + tc.variables["ARROW_SIMD_LEVEL"] = str(self.options.simd_level).upper() + tc.variables["ARROW_RUNTIME_SIMD_LEVEL"] = str(self.options.runtime_simd_level).upper() else: - self._cmake.definitions["ZSTD_SOURCE"] = "SYSTEM" - self._cmake.definitions["ORC_SOURCE"] = "SYSTEM" - self._cmake.definitions["ARROW_WITH_THRIFT"] = self._with_thrift() - self._cmake.definitions["Thrift_SOURCE"] = "SYSTEM" - self._cmake.definitions["THRIFT_VERSION"] = "1.0" # a recent thrift does not require boost - self._cmake.definitions["ARROW_USE_OPENSSL"] = self._with_openssl() + tc.variables["ZSTD_SOURCE"] = "SYSTEM" + if self.options.with_zstd: + tc.variables["ARROW_ZSTD_USE_SHARED"] = bool(self.options["zstd"].shared) + tc.variables["ORC_SOURCE"] = "SYSTEM" + tc.variables["ARROW_WITH_THRIFT"] = self._with_thrift() + tc.variables["Thrift_SOURCE"] = "SYSTEM" + if self._with_thrift(): + tc.variables["THRIFT_VERSION"] = bool(self.deps_cpp_info["thrift"].version) # a recent thrift does not require boost + tc.variables["ARROW_THRIFT_USE_SHARED"] = bool(self.options["thrift"].shared) + tc.variables["ARROW_USE_OPENSSL"] = self._with_openssl() if self._with_openssl(): - self._cmake.definitions["OPENSSL_ROOT_DIR"] = self.deps_cpp_info["openssl"].rootpath.replace("\\", "/") + tc.variables["OPENSSL_ROOT_DIR"] = self.deps_cpp_info["openssl"].rootpath.replace("\\", "/") + tc.variables["ARROW_OPENSSL_USE_SHARED"] = bool(self.options["openssl"].shared) if self._with_boost(): - self._cmake.definitions["ARROW_BOOST_USE_SHARED"] = self.options["boost"].shared - self._cmake.definitions["ARROW_S3"] = self.options.with_s3 - self._cmake.definitions["AWSSDK_SOURCE"] = "SYSTEM" - - self._cmake.definitions["ARROW_BUILD_UTILITIES"] = self.options.cli - self._cmake.definitions["ARROW_BUILD_INTEGRATION"] = False - self._cmake.definitions["ARROW_INSTALL_NAME_RPATH"] = False - self._cmake.definitions["ARROW_BUILD_EXAMPLES"] = False - self._cmake.definitions["ARROW_BUILD_TESTS"] = False - self._cmake.definitions["ARROW_ENABLE_TIMING_TESTS"] = False - self._cmake.definitions["ARROW_BUILD_BENCHMARKS"] = False - self._cmake.definitions["LLVM_SOURCE"] = "SYSTEM" - self._cmake.definitions["ARROW_WITH_UTF8PROC"] = self._with_utf8proc() - self._cmake.definitions["utf8proc_SOURCE"] = "SYSTEM" - - self._cmake.definitions["BUILD_WARNING_LEVEL"] = "PRODUCTION" - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["ARROW_USE_STATIC_CRT"] = "MT" in str(self.settings.compiler.runtime) - + tc.variables["ARROW_USE_BOOST"] = True + tc.variables["ARROW_BOOST_USE_SHARED"] = bool(self.options["boost"].shared) + tc.variables["ARROW_S3"] = bool(self.options.with_s3) + tc.variables["AWSSDK_SOURCE"] = "SYSTEM" + tc.variables["ARROW_BUILD_UTILITIES"] = bool(self.options.cli) + tc.variables["ARROW_BUILD_INTEGRATION"] = False + tc.variables["ARROW_INSTALL_NAME_RPATH"] = False + tc.variables["ARROW_BUILD_EXAMPLES"] = False + tc.variables["ARROW_BUILD_TESTS"] = False + tc.variables["ARROW_ENABLE_TIMING_TESTS"] = False + tc.variables["ARROW_BUILD_BENCHMARKS"] = False + tc.variables["LLVM_SOURCE"] = "SYSTEM" + tc.variables["ARROW_WITH_UTF8PROC"] = self._with_utf8proc() + tc.variables["ARROW_BOOST_REQUIRED"] = self._with_boost() + tc.variables["utf8proc_SOURCE"] = "SYSTEM" + if self._with_utf8proc(): + tc.variables["ARROW_UTF8PROC_USE_SHARED"] = bool(self.options["utf8proc"].shared) + tc.variables["BUILD_WARNING_LEVEL"] = "PRODUCTION" + if is_msvc(self): + tc.variables["ARROW_USE_STATIC_CRT"] = "MT" in str(self.settings.compiler.runtime) if self._with_llvm(): - self._cmake.definitions["LLVM_DIR"] = self.deps_cpp_info["llvm"].rootpath.replace("\\", "/") + tc.variables["LLVM_DIR"] = self.deps_cpp_info["llvm-core"].rootpath.replace("\\", "/") + tc.generate() - self._cmake.configure() - return self._cmake + deps = CMakeDeps(self) + deps.generate() def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + apply_conandata_patches(self) + if Version(self.version) >= "7.0.0": + for filename in glob.glob(os.path.join(self.source_folder, "cpp", "cmake_modules", "Find*.cmake")): + if os.path.basename(filename) not in [ + "FindArrow.cmake", + "FindArrowCUDA.cmake", + "FindArrowDataset.cmake", + "FindArrowFlight.cmake", + "FindArrowFlightSql.cmake", + "FindArrowFlightTesting.cmake", + "FindArrowPython.cmake", + "FindArrowPythonFlight.cmake", + "FindArrowSubstrait.cmake", + "FindArrowTesting.cmake", + "FindGandiva.cmake", + "FindParquet.cmake", + "FindPlasma.cmake", + ]: + os.remove(filename) def build(self): - if self.options.shared and self._with_jemalloc(): - if self.options["jemalloc"].enable_cxx: - raise ConanInvalidConfiguration("jemmalloc.enable_cxx of a static jemalloc must be disabled") - self._patch_sources() - cmake = self._configure_cmake() + cmake =CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "cpp")) cmake.build() def package(self): - self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses") - self.copy("NOTICE.txt", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="NOTICE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake =CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def _lib_name(self, name): - if self.settings.compiler == "Visual Studio" and not self.options.shared: + if is_msvc(self) and not self.options.shared: return "{}_static".format(name) else: return "{}".format(name) def package_id(self): - self.options.with_jemalloc = self._with_jemalloc() self.info.options.with_gflags = self._with_gflags() self.info.options.with_protobuf = self._with_protobuf() self.info.options.with_re2 = self._with_re2() @@ -395,15 +558,24 @@ def package_info(self): self.cpp_info.components["libarrow"].names["pkg_config"] = "arrow" if not self.options.shared: self.cpp_info.components["libarrow"].defines = ["ARROW_STATIC"] - if self.settings.os == "Linux": - self.cpp_info.components["libarrow"].system_libs = ["pthread"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["libarrow"].system_libs = ["pthread", "m", "dl", "rt"] - if self.options.parquet: + if self._parquet(): self.cpp_info.components["libparquet"].libs = [self._lib_name("parquet")] self.cpp_info.components["libparquet"].names["cmake_find_package"] = "parquet" self.cpp_info.components["libparquet"].names["cmake_find_package_multi"] = "parquet" self.cpp_info.components["libparquet"].names["pkg_config"] = "parquet" self.cpp_info.components["libparquet"].requires = ["libarrow"] + if not self.options.shared: + self.cpp_info.components["libparquet"].defines = ["PARQUET_STATIC"] + + if self.options.get_safe("substrait", False): + self.cpp_info.components["libarrow_substrait"].libs = [self._lib_name("arrow_substrait")] + self.cpp_info.components["libarrow_substrait"].names["cmake_find_package"] = "arrow_substrait" + self.cpp_info.components["libarrow_substrait"].names["cmake_find_package_multi"] = "arrow_substrait" + self.cpp_info.components["libarrow_substrait"].names["pkg_config"] = "arrow_substrait" + self.cpp_info.components["libarrow_substrait"].requires = ["libparquet", "dataset"] if self.options.plasma: self.cpp_info.components["libplasma"].libs = [self._lib_name("plasma")] @@ -418,22 +590,38 @@ def package_info(self): self.cpp_info.components["libgandiva"].names["cmake_find_package_multi"] = "gandiva" self.cpp_info.components["libgandiva"].names["pkg_config"] = "gandiva" self.cpp_info.components["libgandiva"].requires = ["libarrow"] - - if self.options.dataset_modules: + if not self.options.shared: + self.cpp_info.components["libgandiva"].defines = ["GANDIVA_STATIC"] + + if self._with_flight_rpc(): + self.cpp_info.components["libarrow_flight"].libs = [self._lib_name("arrow_flight")] + self.cpp_info.components["libarrow_flight"].names["cmake_find_package"] = "flight_rpc" + self.cpp_info.components["libarrow_flight"].names["cmake_find_package_multi"] = "flight_rpc" + self.cpp_info.components["libarrow_flight"].names["pkg_config"] = "flight_rpc" + self.cpp_info.components["libarrow_flight"].requires = ["libarrow"] + + if self.options.get_safe("with_flight_sql"): + self.cpp_info.components["libarrow_flight_sql"].libs = [self._lib_name("arrow_flight_sql")] + self.cpp_info.components["libarrow_flight_sql"].names["cmake_find_package"] = "flight_sql" + self.cpp_info.components["libarrow_flight_sql"].names["cmake_find_package_multi"] = "flight_sql" + self.cpp_info.components["libarrow_flight_sql"].names["pkg_config"] = "flight_sql" + self.cpp_info.components["libarrow_flight_sql"].requires = ["libarrow", "libarrow_flight"] + + if self._dataset_modules(): self.cpp_info.components["dataset"].libs = ["arrow_dataset"] - if self.options.cli: + if (self.options.cli and (self.options.with_cuda or self._with_flight_rpc() or self._parquet())) or self.options.plasma: binpath = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH env var: {}".format(binpath)) + self.output.info(f"Appending PATH env var: {binpath}") self.env_info.PATH.append(binpath) if self._with_boost(): if self.options.gandiva: # FIXME: only filesystem component is used self.cpp_info.components["libgandiva"].requires.append("boost::boost") - if self.options.parquet and self.settings.compiler == "gcc" and self.settings.compiler.version < tools.Version("4.9"): + if self._parquet() and self.settings.compiler == "gcc" and self.settings.compiler.version < Version("4.9"): self.cpp_info.components["libparquet"].requires.append("boost::boost") - if tools.Version(self.version) >= "2.0": + if Version(self.version) >= "2.0": # FIXME: only headers components is used self.cpp_info.components["libarrow"].requires.append("boost::boost") if self._with_openssl(): @@ -444,40 +632,49 @@ def package_info(self): self.cpp_info.components["libarrow"].requires.append("glog::glog") if self._with_jemalloc(): self.cpp_info.components["libarrow"].requires.append("jemalloc::jemalloc") + if self.options.with_mimalloc: + self.cpp_info.components["libarrow"].requires.append("mimalloc::mimalloc") if self._with_re2(): self.cpp_info.components["libgandiva"].requires.append("re2::re2") + if self._with_llvm(): + self.cpp_info.components["libgandiva"].requires.append("llvm-core::llvm-core") if self._with_protobuf(): self.cpp_info.components["libarrow"].requires.append("protobuf::protobuf") if self._with_utf8proc(): - self.cpp_info.components["libarrow"].requires.append("uff8proc::uff8proc") - if self._with_llvm(): - self.cpp_info.components["libarrow"].requires.append("llvm::llvm") + self.cpp_info.components["libarrow"].requires.append("utf8proc::utf8proc") if self._with_thrift(): self.cpp_info.components["libarrow"].requires.append("thrift::thrift") - if self.options.with_backtrace: - self.cpp_info.components["libarrow"].requires.append("backtrace::backtrace") + self.cpp_info.components["libarrow"].requires.append("libbacktrace::libbacktrace") if self.options.with_cuda: self.cpp_info.components["libarrow"].requires.append("cuda::cuda") - if self.options.with_flight_rpc: - self.cpp_info.components["libarrow"].requires.append("flight::flight") - if self.options.with_hiveserver2: - self.cpp_info.components["libarrow"].requires.append("hiveserver2::hiveserver2") - if self.options.with_json: + if self._with_rapidjson(): self.cpp_info.components["libarrow"].requires.append("rapidjson::rapidjson") if self.options.with_s3: - self.cpp_info.components["libarrow"].requires.append("aws-sdk-cpp::filesystem") + self.cpp_info.components["libarrow"].requires.append("aws-sdk-cpp::s3") + if self.options.get_safe("with_gcs"): + self.cpp_info.components["libarrow"].requires.append("google-cloud-cpp::storage") if self.options.with_orc: self.cpp_info.components["libarrow"].requires.append("orc::orc") + if self.options.get_safe("with_opentelemetry"): + self.cpp_info.components["libarrow"].requires.append("opentelemetry-cpp::opentelemetry-cpp") if self.options.with_brotli: self.cpp_info.components["libarrow"].requires.append("brotli::brotli") if self.options.with_bz2: - self.cpp_info.components["libarrow"].requires.append("bz2::bz2") + self.cpp_info.components["libarrow"].requires.append("bzip2::bzip2") if self.options.with_lz4: self.cpp_info.components["libarrow"].requires.append("lz4::lz4") if self.options.with_snappy: self.cpp_info.components["libarrow"].requires.append("snappy::snappy") + if self.options.get_safe("simd_level") != None or self.options.get_safe("runtime_simd_level") != None: + self.cpp_info.components["libarrow"].requires.append("xsimd::xsimd") if self.options.with_zlib: self.cpp_info.components["libarrow"].requires.append("zlib::zlib") if self.options.with_zstd: self.cpp_info.components["libarrow"].requires.append("zstd::zstd") + if self._with_boost(): + self.cpp_info.components["libarrow"].requires.append("boost::boost") + if self._with_grpc(): + self.cpp_info.components["libarrow"].requires.append("grpc::grpc") + if self._with_flight_rpc(): + self.cpp_info.components["libarrow_flight"].requires.append("protobuf::protobuf") diff --git a/recipes/arrow/all/patches/1.0.0-0001-cmake.patch b/recipes/arrow/all/patches/1.0.0-0001-cmake.patch deleted file mode 100644 index c227f1860e305..0000000000000 --- a/recipes/arrow/all/patches/1.0.0-0001-cmake.patch +++ /dev/null @@ -1,92 +0,0 @@ ---- cpp/cmake_modules/DefineOptions.cmake -+++ cpp/cmake_modules/DefineOptions.cmake -@@ -76,7 +76,7 @@ macro(define_option_string name description default) - endmacro() - - # Top level cmake dir --if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") -+if(1) - #---------------------------------------------------------------------- - set_option_category("Compile and link") - ---- cpp/cmake_modules/ThirdpartyToolchain.cmake -+++ cpp/cmake_modules/ThirdpartyToolchain.cmake -@@ -854,7 +854,7 @@ if(ARROW_WITH_SNAPPY) - # location. - # https://bugzilla.redhat.com/show_bug.cgi?id=1679727 - # https://src.fedoraproject.org/rpms/snappy/pull-request/1 -- find_package(Snappy QUIET HINTS "${CMAKE_ROOT}/Modules/") -+ find_package(Snappy REQUIRED) - if(NOT Snappy_FOUND) - find_package(SnappyAlt) - endif() -@@ -866,7 +866,7 @@ - elseif(Snappy_SOURCE STREQUAL "SYSTEM") - # SnappyConfig.cmake is not installed on Ubuntu/Debian - # TODO: Make a bug report upstream -- find_package(Snappy HINTS "${CMAKE_ROOT}/Modules/") -+ find_package(Snappy REQUIRED) - if(NOT Snappy_FOUND) - find_package(SnappyAlt REQUIRED) - endif() -@@ -1139,8 +1139,8 @@ - build_gflags() - elseif(gflags_SOURCE STREQUAL "SYSTEM") -- # gflagsConfig.cmake is not installed on Ubuntu/Debian -- # TODO: Make a bug report upstream -- find_package(gflags ${ARROW_GFLAGS_REQUIRED_VERSION}) -+ find_package(gflags REQUIRED) -+ add_library(gflags-shared INTERFACE) -+ target_link_libraries(gflags-shared INTERFACE gflags::gflags) - if(NOT gflags_FOUND) - find_package(gflagsAlt ${ARROW_GFLAGS_REQUIRED_VERSION} REQUIRED) - endif() -@@ -1329,6 +1329,6 @@ macro(build_protobuf) - endmacro() -- - if(ARROW_WITH_PROTOBUF) -+ find_package(Protobuf REQUIRED) - if(ARROW_WITH_GRPC) - # gRPC 1.21.0 or later require Protobuf 3.7.0 or later. - set(ARROW_PROTOBUF_REQUIRED_VERSION "3.7.0") -@@ -1365,9 +1365,9 @@ if(ARROW_WITH_PROTOBUF) - set(ARROW_PROTOBUF_LIBPROTOC arrow::protobuf::libprotoc) - else() - if(NOT TARGET protobuf::libprotoc) -+ set(Protobuf_PROTOC_LIBRARY protoc) - if(PROTOBUF_PROTOC_LIBRARY AND NOT Protobuf_PROTOC_LIBRARY) -- # Old CMake versions have a different casing. -- set(Protobuf_PROTOC_LIBRARY ${PROTOBUF_PROTOC_LIBRARY}) -+ set(Protobuf_PROTOC_LIBRARY protoc) - endif() - if(NOT Protobuf_PROTOC_LIBRARY) - message(FATAL_ERROR "libprotoc was set to ${Protobuf_PROTOC_LIBRARY}") -@@ -1802,7 +1802,7 @@ if(ARROW_WITH_RAPIDJSON) - elseif(RapidJSON_SOURCE STREQUAL "SYSTEM") - # Fedora packages place the package information at the wrong location. - # https://bugzilla.redhat.com/show_bug.cgi?id=1680400 -- find_package(RapidJSON ${ARROW_RAPIDJSON_REQUIRED_VERSION} HINTS "${CMAKE_ROOT}") -+ find_package(RapidJSON REQUIRED) - if(RapidJSON_FOUND) - set(RAPIDJSON_INCLUDE_DIR ${RAPIDJSON_INCLUDE_DIRS}) - else() -@@ -2088,7 +2088,7 @@ if(ARROW_WITH_BZ2) - PROPERTIES IMPORTED_LOCATION "${BZIP2_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIR}") - endif() -- include_directories(SYSTEM "${BZIP2_INCLUDE_DIR}") -+ include_directories(SYSTEM "${BZip2_INCLUDE_DIR}") - endif() - - macro(build_utf8proc) ---- cpp/cmake_modules/SetupCxxFlags.cmake -+++ cpp/cmake_modules/SetupCxxFlags.cmake -@@ -188,7 +188,7 @@ - message(STATUS "Arrow build warning level: ${BUILD_WARNING_LEVEL}") - - macro(arrow_add_werror_if_debug) -- if("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG") -+ if(0) - # Treat all compiler warnings as errors - if(MSVC) - set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /WX") diff --git a/recipes/arrow/all/patches/1.0.0-0002-jemalloc.patch b/recipes/arrow/all/patches/1.0.0-0002-jemalloc.patch deleted file mode 100644 index 7e8bd1ed08039..0000000000000 --- a/recipes/arrow/all/patches/1.0.0-0002-jemalloc.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- cpp/cmake_modules/ThirdpartyToolchain.cmake -+++ cpp/cmake_modules/ThirdpartyToolchain.cmake -@@ -1407,6 +1407,6 @@ endif() - # jemalloc - Unix-only high-performance allocator -- - if(ARROW_JEMALLOC) -+if(0) - message(STATUS "Building (vendored) jemalloc from source") - # We only use a vendored jemalloc as we want to control its version. - # Also our build of jemalloc is specially prefixed so that it will not -@@ -1465,6 +1465,8 @@ if(ARROW_JEMALLOC) - add_dependencies(jemalloc::jemalloc jemalloc_ep) - - list(APPEND ARROW_BUNDLED_STATIC_LIBS jemalloc::jemalloc) -+else() -+ find_package(jemalloc REQUIRED) -+endif() - endif() -- - # ---------------------------------------------------------------------- - # mimalloc - Cross-platform high-performance allocator, from Microsoft ---- cpp/src/arrow/CMakeLists.txt -+++ cpp/src/arrow/CMakeLists.txt -@@ -292,7 +292,7 @@ - - set(_allocator_dependencies "") # Empty list - if(ARROW_JEMALLOC) -- list(APPEND _allocator_dependencies jemalloc_ep) -+ list(APPEND _allocator_dependencies jemalloc::jemalloc) - endif() - if(ARROW_MIMALLOC) - list(APPEND _allocator_dependencies mimalloc_ep) ---- cpp/src/arrow/memory_pool.cc -+++ cpp/src/arrow/memory_pool.cc -@@ -31,7 +31,7 @@ - // Needed to support jemalloc 3 and 4 - #define JEMALLOC_MANGLE - // Explicitly link to our version of jemalloc --#include "jemalloc_ep/dist/include/jemalloc/jemalloc.h" -+#include "jemalloc/jemalloc.h" - #endif - - #ifdef ARROW_MIMALLOC diff --git a/recipes/arrow/all/patches/1.0.0-0005-fix-make12-namespace.patch b/recipes/arrow/all/patches/1.0.0-0005-fix-make12-namespace.patch new file mode 100644 index 0000000000000..5f0f6f4c52d5c --- /dev/null +++ b/recipes/arrow/all/patches/1.0.0-0005-fix-make12-namespace.patch @@ -0,0 +1,22 @@ +diff --git a/cpp/src/arrow/vendored/datetime/date.h b/cpp/src/arrow/vendored/datetime/date.h +index 02a4909..2b168d2 100644 +--- a/cpp/src/arrow/vendored/datetime/date.h ++++ b/cpp/src/arrow/vendored/datetime/date.h +@@ -5152,7 +5152,7 @@ to_stream(std::basic_ostream& os, const CharT* fmt, + if (modified == CharT{}) + #endif + { +- auto h = *fmt == CharT{'I'} ? make12(hms.hours()) : hms.hours(); ++ auto h = *fmt == CharT{'I'} ? arrow_vendored::date::make12(hms.hours()) : hms.hours(); + if (h < hours{10}) + os << CharT{'0'}; + os << h.count(); +@@ -5366,7 +5366,7 @@ to_stream(std::basic_ostream& os, const CharT* fmt, + save_ostream _(os); + os.fill('0'); + os.width(2); +- os << make12(tod.hours()).count() << CharT{':'}; ++ os << arrow_vendored::date::make12(tod.hours()).count() << CharT{':'}; + os.width(2); + os << tod.minutes().count() << CharT{':'}; + os.width(2); diff --git a/recipes/arrow/all/patches/1.0.0-0006-fix-cmake.patch b/recipes/arrow/all/patches/1.0.0-0006-fix-cmake.patch new file mode 100644 index 0000000000000..eb6816262214b --- /dev/null +++ b/recipes/arrow/all/patches/1.0.0-0006-fix-cmake.patch @@ -0,0 +1,333 @@ +diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt +index 300f043..0127a7a 100644 +--- a/cpp/CMakeLists.txt ++++ b/cpp/CMakeLists.txt +@@ -654,7 +654,7 @@ endif() + + if(ARROW_WITH_BROTLI) + # Order is important for static linking +- set(ARROW_BROTLI_LIBS Brotli::brotlienc Brotli::brotlidec Brotli::brotlicommon) ++ set(ARROW_BROTLI_LIBS brotli::brotlienc brotli::brotlidec brotli::brotlicommon) + list(APPEND ARROW_LINK_LIBS ${ARROW_BROTLI_LIBS}) + list(APPEND ARROW_STATIC_LINK_LIBS ${ARROW_BROTLI_LIBS}) + endif() +@@ -664,7 +664,7 @@ if(ARROW_WITH_BZ2) + endif() + + if(ARROW_WITH_LZ4) +- list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4) ++ list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4_static) + endif() + + if(ARROW_WITH_SNAPPY) +@@ -800,8 +800,11 @@ endif() + + if(ARROW_MIMALLOC) + add_definitions(-DARROW_MIMALLOC) +- list(APPEND ARROW_LINK_LIBS mimalloc::mimalloc) +- list(APPEND ARROW_STATIC_LINK_LIBS mimalloc::mimalloc) ++ if (TARGET mimalloc-static) ++ list(APPEND ARROW_LINK_LIBS mimalloc-static) ++ else() ++ list(APPEND ARROW_STATIC_LINK_LIBS mimalloc) ++ endif() + endif() + + # ---------------------------------------------------------------------- +diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake +index eb10ebe..9c81017 100644 +--- a/cpp/cmake_modules/BuildUtils.cmake ++++ b/cpp/cmake_modules/BuildUtils.cmake +@@ -165,10 +165,10 @@ function(create_merged_static_lib output_target) + set(ar_script_path ${CMAKE_BINARY_DIR}/${ARG_NAME}.ar) + + file(WRITE ${ar_script_path}.in "CREATE ${output_lib_path}\n") +- file(APPEND ${ar_script_path}.in "ADDLIB $\n") ++ file(APPEND ${ar_script_path}.in "ADDLIB $\n") + + foreach(lib ${ARG_TO_MERGE}) +- file(APPEND ${ar_script_path}.in "ADDLIB $\n") ++ file(APPEND ${ar_script_path}.in "ADDLIB $\n") + endforeach() + + file(APPEND ${ar_script_path}.in "SAVE\nEND\n") +diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake +index 807e2b9..016c8db 100644 +--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake ++++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake +@@ -154,16 +154,7 @@ macro(build_dependency DEPENDENCY_NAME) + endmacro() + + macro(resolve_dependency DEPENDENCY_NAME) +- if(${DEPENDENCY_NAME}_SOURCE STREQUAL "AUTO") +- find_package(${DEPENDENCY_NAME} MODULE) +- if(NOT ${${DEPENDENCY_NAME}_FOUND}) +- build_dependency(${DEPENDENCY_NAME}) +- endif() +- elseif(${DEPENDENCY_NAME}_SOURCE STREQUAL "BUNDLED") +- build_dependency(${DEPENDENCY_NAME}) +- elseif(${DEPENDENCY_NAME}_SOURCE STREQUAL "SYSTEM") +- find_package(${DEPENDENCY_NAME} REQUIRED) +- endif() ++ find_package(${DEPENDENCY_NAME} REQUIRED) + endmacro() + + macro(resolve_dependency_with_version DEPENDENCY_NAME REQUIRED_VERSION) +@@ -765,6 +756,7 @@ endif() + # - Tests need Boost at runtime. + # - S3FS and Flight benchmarks need Boost at runtime. + if(ARROW_BUILD_INTEGRATION ++ OR ARROW_BOOST_REQUIRED + OR ARROW_BUILD_TESTS + OR ARROW_GANDIVA + OR (ARROW_FLIGHT AND ARROW_BUILD_BENCHMARKS) +@@ -785,7 +777,7 @@ if(ARROW_BOOST_REQUIRED) + elseif(BOOST_SOURCE STREQUAL "BUNDLED") + build_boost() + elseif(BOOST_SOURCE STREQUAL "SYSTEM") +- find_package(BoostAlt ${ARROW_BOOST_REQUIRED_VERSION} REQUIRED) ++ find_package(Boost ${ARROW_BOOST_REQUIRED_VERSION} REQUIRED) + endif() + + if(TARGET Boost::system) +@@ -936,11 +928,11 @@ macro(build_brotli) + endmacro() + + if(ARROW_WITH_BROTLI) +- resolve_dependency(Brotli) ++ resolve_dependency(brotli) + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(BROTLI_INCLUDE_DIR Brotli::brotlicommon ++ get_target_property(BROTLI_INCLUDE_DIR brotli::brotlicommon + INTERFACE_INCLUDE_DIRECTORIES) +- include_directories(SYSTEM ${BROTLI_INCLUDE_DIR}) ++ include_directories(SYSTEM ${brotli_INCLUDE_DIR}) + endif() + + if(PARQUET_REQUIRE_ENCRYPTION AND NOT ARROW_PARQUET) +@@ -1146,9 +1138,10 @@ if(ARROW_NEED_GFLAGS) + endif() + endif() + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${GFLAGS_INCLUDE_DIR}) ++ include_directories(SYSTEM ${gflags_INCLUDE_DIR}) ++ set(GFLAGS_LIBRARIES ${gflags_LIBRARIES}) + +- if(NOT TARGET ${GFLAGS_LIBRARIES}) ++ if(0) + if(TARGET gflags-shared) + set(GFLAGS_LIBRARIES gflags-shared) + elseif(TARGET gflags_shared) +@@ -1237,12 +1230,13 @@ endmacro() + if(ARROW_WITH_THRIFT) + # We already may have looked for Thrift earlier, when considering whether + # to build Boost, so don't look again if already found. +- if(NOT Thrift_FOUND AND NOT THRIFT_FOUND) ++ if(0) + # Thrift c++ code generated by 0.13 requires 0.11 or greater + resolve_dependency_with_version(Thrift 0.11.0) + endif() ++ find_package(Thrift CONFIG REQUIRED) + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${THRIFT_INCLUDE_DIR}) ++ include_directories(SYSTEM ${Thrift_INCLUDE_DIR}) + endif() + + # ---------------------------------------------------------------------- +@@ -1407,6 +1401,7 @@ endif() + # jemalloc - Unix-only high-performance allocator + + if(ARROW_JEMALLOC) ++if(0) + message(STATUS "Building (vendored) jemalloc from source") + # We only use a vendored jemalloc as we want to control its version. + # Also our build of jemalloc is specially prefixed so that it will not +@@ -1465,12 +1460,18 @@ if(ARROW_JEMALLOC) + add_dependencies(jemalloc::jemalloc jemalloc_ep) + + list(APPEND ARROW_BUNDLED_STATIC_LIBS jemalloc::jemalloc) ++else() ++ find_package(jemalloc REQUIRED CONFIG) ++ include_directories(SYSTEM "${jemalloc_INCLUDE_DIR}") ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${jemalloc_LIBRARIES_TARGETS} ) ++endif() + endif() + + # ---------------------------------------------------------------------- + # mimalloc - Cross-platform high-performance allocator, from Microsoft + + if(ARROW_MIMALLOC) ++if(0) + message(STATUS "Building (vendored) mimalloc from source") + # We only use a vendored mimalloc as we want to control its build options. + +@@ -1518,6 +1519,11 @@ if(ARROW_MIMALLOC) + add_dependencies(toolchain mimalloc_ep) + + list(APPEND ARROW_BUNDLED_STATIC_LIBS mimalloc::mimalloc) ++else() ++ find_package(mimalloc REQUIRED CONFIG) ++ include_directories(SYSTEM "${mimalloc_INCLUDE_DIR}") ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${mimalloc_LIBRARIES_TARGETS} ) ++endif() + endif() + + # ---------------------------------------------------------------------- +@@ -1918,11 +1924,16 @@ macro(build_lz4) + endmacro() + + if(ARROW_WITH_LZ4) +- resolve_dependency(Lz4) ++ resolve_dependency(lz4) + + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(LZ4_INCLUDE_DIR LZ4::lz4 INTERFACE_INCLUDE_DIRECTORIES) +- include_directories(SYSTEM ${LZ4_INCLUDE_DIR}) ++ if(TARGET LZ4::lz4_static) ++ get_target_property(LZ4_INCLUDE_DIR LZ4::lz4_static INTERFACE_INCLUDE_DIRECTORIES) ++ else() ++ get_target_property(LZ4_INCLUDE_DIR LZ4::lz4_shared INTERFACE_INCLUDE_DIRECTORIES) ++ endif() ++ include_directories(SYSTEM ${lz4_INCLUDE_DIR}) ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${lz4_LIBRARIES_TARGETS} ) + endif() + + macro(build_zstd) +@@ -2037,10 +2048,10 @@ macro(build_re2) + endmacro() + + if(ARROW_GANDIVA) +- resolve_dependency(RE2) ++ resolve_dependency(re2) + + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(RE2_INCLUDE_DIR RE2::re2 INTERFACE_INCLUDE_DIRECTORIES) ++ get_target_property(RE2_INCLUDE_DIR re2::re2 INTERFACE_INCLUDE_DIRECTORIES) + include_directories(SYSTEM ${RE2_INCLUDE_DIR}) + endif() + +@@ -2480,17 +2491,24 @@ if(ARROW_WITH_GRPC) + endif() + + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(GRPC_INCLUDE_DIR gRPC::grpc INTERFACE_INCLUDE_DIRECTORIES) ++ # get_target_property(GRPC_INCLUDE_DIR gRPC::grpc INTERFACE_INCLUDE_DIRECTORIES) ++ if(grpc_INCLUDE_DIRS_RELEASE) ++ set(GRPC_INCLUDE_DIR ${grpc_INCLUDE_DIRS_RELEASE}) ++ elseif(grpc_INCLUDE_DIRS_DEBUG) ++ set(GRPC_INCLUDE_DIR ${grpc_INCLUDE_DIRS_DEBUG}) ++ endif() + include_directories(SYSTEM ${GRPC_INCLUDE_DIR}) ++ include_directories(SYSTEM ${absl_INCLUDE_DIR}) ++ include_directories(SYSTEM ${protobuf_INCLUDE_DIR}) + + if(GRPC_VENDORED) + set(GRPCPP_PP_INCLUDE TRUE) + else() + # grpc++ headers may reside in ${GRPC_INCLUDE_DIR}/grpc++ or ${GRPC_INCLUDE_DIR}/grpcpp + # depending on the gRPC version. +- if(EXISTS "${GRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h") ++ if(EXISTS ${GRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h) + set(GRPCPP_PP_INCLUDE TRUE) +- elseif(EXISTS "${GRPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h") ++ elseif(EXISTS ${GRPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h) + set(GRPCPP_PP_INCLUDE FALSE) + else() + message(FATAL_ERROR "Cannot find grpc++ headers in ${GRPC_INCLUDE_DIR}") +diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt +index 5797a78..da6bd4d 100644 +--- a/cpp/src/arrow/CMakeLists.txt ++++ b/cpp/src/arrow/CMakeLists.txt +@@ -292,10 +292,15 @@ set(ARROW_TESTING_SRCS + + set(_allocator_dependencies "") # Empty list + if(ARROW_JEMALLOC) +- list(APPEND _allocator_dependencies jemalloc_ep) ++ list(APPEND _allocator_dependencies jemalloc::jemalloc) + endif() ++ + if(ARROW_MIMALLOC) +- list(APPEND _allocator_dependencies mimalloc_ep) ++ if (TARGET mimalloc-static) ++ list(APPEND _allocator_dependencies mimalloc-static) ++ else() ++ list(APPEND _allocator_dependencies mimalloc) ++ endif() + endif() + + if(_allocator_dependencies) +diff --git a/cpp/src/arrow/memory_pool.cc b/cpp/src/arrow/memory_pool.cc +index 784bf7b..8f005a5 100644 +--- a/cpp/src/arrow/memory_pool.cc ++++ b/cpp/src/arrow/memory_pool.cc +@@ -31,7 +31,7 @@ + // Needed to support jemalloc 3 and 4 + #define JEMALLOC_MANGLE + // Explicitly link to our version of jemalloc +-#include "jemalloc_ep/dist/include/jemalloc/jemalloc.h" ++#include "jemalloc/jemalloc.h" + #endif + + #ifdef ARROW_MIMALLOC +diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt +index 85e8db6..cd70c63 100644 +--- a/cpp/src/gandiva/CMakeLists.txt ++++ b/cpp/src/gandiva/CMakeLists.txt +@@ -25,7 +25,7 @@ add_custom_target(gandiva-benchmarks) + + add_dependencies(gandiva-all gandiva gandiva-tests gandiva-benchmarks) + +-find_package(LLVMAlt REQUIRED) ++find_package(LLVM REQUIRED) + + if(LLVM_VERSION_MAJOR LESS "10") + set(GANDIVA_CXX_STANDARD ${CMAKE_CXX_STANDARD}) +@@ -88,9 +88,16 @@ set(SRC_FILES + random_generator_holder.cc + ${GANDIVA_PRECOMPILED_CC_PATH}) + +-set(GANDIVA_SHARED_PRIVATE_LINK_LIBS arrow_shared LLVM::LLVM_INTERFACE RE2::re2) + +-set(GANDIVA_STATIC_LINK_LIBS arrow_static LLVM::LLVM_INTERFACE RE2::re2) ++ function(get_all_targets var) ++ set(targets) ++ get_all_targets_recursive(targets ${CMAKE_CURRENT_SOURCE_DIR}) ++ set(${var} ${targets} PARENT_SCOPE) ++endfunction() ++ ++set(GANDIVA_SHARED_PRIVATE_LINK_LIBS arrow_shared llvm-core::llvm-core re2::re2) ++ ++set(GANDIVA_STATIC_LINK_LIBS arrow_static llvm-core::llvm-core re2::re2) + + if(ARROW_GANDIVA_STATIC_LIBSTDCPP + AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)) +@@ -131,7 +138,7 @@ add_arrow_lib(gandiva + arrow_dependencies + precompiled + EXTRA_INCLUDES +- $ ++ $ + SHARED_LINK_FLAGS + ${GANDIVA_SHARED_LINK_FLAGS} + SHARED_LINK_LIBS +@@ -203,7 +210,7 @@ endfunction() + + set(GANDIVA_INTERNALS_TEST_ARGUMENTS) + if(WIN32) +- list(APPEND GANDIVA_INTERNALS_TEST_ARGUMENTS EXTRA_LINK_LIBS LLVM::LLVM_INTERFACE) ++ list(APPEND GANDIVA_INTERNALS_TEST_ARGUMENTS EXTRA_LINK_LIBS llvm-core::llvm-core) + endif() + add_gandiva_test(internals-test + SOURCES +@@ -225,9 +232,9 @@ add_gandiva_test(internals-test + decimal_type_util_test.cc + random_generator_holder_test.cc + EXTRA_DEPENDENCIES +- LLVM::LLVM_INTERFACE ++ llvm-core::llvm-core + EXTRA_INCLUDES +- $ ++ $ + ${GANDIVA_INTERNALS_TEST_ARGUMENTS}) + + if(ARROW_GANDIVA_JAVA) diff --git a/recipes/arrow/all/patches/10.0.0-0001-mallctl-takes-size_t.patch b/recipes/arrow/all/patches/10.0.0-0001-mallctl-takes-size_t.patch new file mode 100644 index 0000000000000..e16b57925f4b1 --- /dev/null +++ b/recipes/arrow/all/patches/10.0.0-0001-mallctl-takes-size_t.patch @@ -0,0 +1,13 @@ +diff --git a/cpp/src/arrow/memory_pool_jemalloc.cc b/cpp/src/arrow/memory_pool_jemalloc.cc +index c7d73c8..34c7c63 100644 +--- a/cpp/src/arrow/memory_pool_jemalloc.cc ++++ b/cpp/src/arrow/memory_pool_jemalloc.cc +@@ -140,7 +140,7 @@ void JemallocAllocator::ReleaseUnused() { + } while (0) + + Status jemalloc_set_decay_ms(int ms) { +- ssize_t decay_time_ms = static_cast(ms); ++ size_t decay_time_ms = static_cast(ms); + + int err = mallctl("arenas.dirty_decay_ms", nullptr, nullptr, &decay_time_ms, + sizeof(decay_time_ms)); diff --git a/recipes/arrow/all/patches/10.0.0-0002-fix-cmake.patch b/recipes/arrow/all/patches/10.0.0-0002-fix-cmake.patch new file mode 100644 index 0000000000000..62ee1a4570d30 --- /dev/null +++ b/recipes/arrow/all/patches/10.0.0-0002-fix-cmake.patch @@ -0,0 +1,311 @@ +diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt +index 029f13f..3518a23 100644 +--- a/cpp/CMakeLists.txt ++++ b/cpp/CMakeLists.txt +@@ -659,7 +659,7 @@ endif() + + if(ARROW_WITH_BROTLI) + # Order is important for static linking +- set(ARROW_BROTLI_LIBS Brotli::brotlienc Brotli::brotlidec Brotli::brotlicommon) ++ set(ARROW_BROTLI_LIBS brotli::brotlienc brotli::brotlidec brotli::brotlicommon) + list(APPEND ARROW_SHARED_LINK_LIBS ${ARROW_BROTLI_LIBS}) + list(APPEND ARROW_STATIC_LINK_LIBS ${ARROW_BROTLI_LIBS}) + if(Brotli_SOURCE STREQUAL "SYSTEM") +@@ -675,14 +675,21 @@ if(ARROW_WITH_BZ2) + endif() + + if(ARROW_WITH_LZ4) +- list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4) ++if (TARGET LZ4::lz4_static) ++ list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4_static) + if(lz4_SOURCE STREQUAL "SYSTEM") +- list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4) ++ list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4_static) + endif() ++else() ++ list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4_shared) ++ if(lz4_SOURCE STREQUAL "SYSTEM") ++ list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4_shared) ++ endif() ++endif() + endif() + + if(ARROW_WITH_SNAPPY) +- list(APPEND ARROW_STATIC_LINK_LIBS ${Snappy_TARGET}) ++ list(APPEND ARROW_STATIC_LINK_LIBS Snappy::snappy) + if(Snappy_SOURCE STREQUAL "SYSTEM") + list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ${Snappy_TARGET}) + endif() +diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake +index b7cd31f..78f3df3 100644 +--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake ++++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake +@@ -1162,10 +1162,12 @@ endmacro() + + if(ARROW_WITH_SNAPPY) + resolve_dependency(Snappy +- HAVE_ALT ++ USE_CONFIG + TRUE + PC_PACKAGE_NAMES + snappy) ++ ++ if(0) + if(${Snappy_SOURCE} STREQUAL "SYSTEM" AND NOT snappy_PC_FOUND) + get_target_property(SNAPPY_TYPE ${Snappy_TARGET} TYPE) + if(NOT SNAPPY_TYPE STREQUAL "INTERFACE_LIBRARY") +@@ -1180,6 +1182,9 @@ if(ARROW_WITH_SNAPPY) + string(APPEND ARROW_PC_LIBS_PRIVATE " ${SNAPPY_LIB}") + endif() + endif() ++ else() ++ string(APPEND ARROW_PC_LIBS_PRIVATE " ${Snappy_LIBRARIES}") ++ endif() + endif() + + # ---------------------------------------------------------------------- +@@ -1242,7 +1247,7 @@ macro(build_brotli) + endmacro() + + if(ARROW_WITH_BROTLI) +- resolve_dependency(Brotli PC_PACKAGE_NAMES libbrotlidec libbrotlienc) ++ resolve_dependency(brotli PC_PACKAGE_NAMES libbrotlidec libbrotlienc) + endif() + + if(PARQUET_REQUIRE_ENCRYPTION AND NOT ARROW_PARQUET) +@@ -1256,7 +1261,7 @@ if(PARQUET_REQUIRE_ENCRYPTION + OR ARROW_GANDIVA) + set(OpenSSL_SOURCE "SYSTEM") + resolve_dependency(OpenSSL +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_OPENSSL_REQUIRED_VERSION}) +@@ -1399,22 +1404,14 @@ endmacro() + if(ARROW_NEED_GFLAGS) + set(ARROW_GFLAGS_REQUIRED_VERSION "2.1.0") + resolve_dependency(gflags +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_GFLAGS_REQUIRED_VERSION} + IS_RUNTIME_DEPENDENCY + FALSE) + +- if(NOT TARGET ${GFLAGS_LIBRARIES}) +- if(TARGET gflags::gflags_shared) +- set(GFLAGS_LIBRARIES gflags::gflags_shared) +- elseif(TARGET gflags-shared) +- set(GFLAGS_LIBRARIES gflags-shared) +- elseif(TARGET gflags_shared) +- set(GFLAGS_LIBRARIES gflags_shared) +- endif() +- endif() ++ set(GFLAGS_LIBRARIES gflags::gflags) + endif() + + # ---------------------------------------------------------------------- +@@ -1638,7 +1635,7 @@ if(ARROW_WITH_PROTOBUF) + set(ARROW_PROTOBUF_REQUIRED_VERSION "2.6.1") + endif() + resolve_dependency(Protobuf +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_PROTOBUF_REQUIRED_VERSION} +@@ -1770,7 +1767,7 @@ macro(build_substrait) + + add_custom_target(substrait_gen ALL DEPENDS ${SUBSTRAIT_PROTO_GEN_ALL}) + +- set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR} ${PROTOBUF_INCLUDE_DIR}) ++ set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR} ${protobuf_INCLUDE_DIR}) + + add_library(substrait STATIC ${SUBSTRAIT_SOURCES}) + set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON) +@@ -1781,6 +1778,8 @@ macro(build_substrait) + list(APPEND ARROW_BUNDLED_STATIC_LIBS substrait) + endmacro() + ++set(CMAKE_VERBOSE_MAKEFILE ON) ++ + if(ARROW_SUBSTRAIT) + # Currently, we can only build Substrait from source. + set(Substrait_SOURCE "BUNDLED") +@@ -1866,7 +1865,10 @@ macro(build_jemalloc) + endmacro() + + if(ARROW_JEMALLOC) +- resolve_dependency(jemalloc) ++ #resolve_dependency(jemalloc) ++ find_package(jemalloc REQUIRED CONFIG) ++ include_directories(SYSTEM "${jemalloc_INCLUDE_DIR}") ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${jemalloc_LIBRARIES_TARGETS}) + endif() + + # ---------------------------------------------------------------------- +@@ -2186,7 +2188,7 @@ endmacro() + if(ARROW_WITH_RAPIDJSON) + set(ARROW_RAPIDJSON_REQUIRED_VERSION "1.1.0") + resolve_dependency(RapidJSON +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_RAPIDJSON_REQUIRED_VERSION} +@@ -2334,19 +2336,29 @@ macro(build_lz4) + BUILD_BYPRODUCTS ${LZ4_STATIC_LIB}) + + file(MAKE_DIRECTORY "${LZ4_PREFIX}/include") +- add_library(LZ4::lz4 STATIC IMPORTED) +- set_target_properties(LZ4::lz4 +- PROPERTIES IMPORTED_LOCATION "${LZ4_STATIC_LIB}" +- INTERFACE_INCLUDE_DIRECTORIES "${LZ4_PREFIX}/include") +- add_dependencies(toolchain lz4_ep) +- add_dependencies(LZ4::lz4 lz4_ep) +- +- list(APPEND ARROW_BUNDLED_STATIC_LIBS LZ4::lz4) ++ if (TARGET LZ4::lz4_static) ++ add_library(LZ4::lz4_static STATIC IMPORTED) ++ set_target_properties(LZ4::lz4_static ++ PROPERTIES IMPORTED_LOCATION "${LZ4_STATIC_LIB}" ++ INTERFACE_INCLUDE_DIRECTORIES "${LZ4_PREFIX}/include") ++ add_dependencies(toolchain lz4_ep) ++ add_dependencies(LZ4::lz4_static lz4_ep) ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS LZ4::lz4_static) ++ else() ++ add_library(LZ4::lz4_shared STATIC IMPORTED) ++ set_target_properties(LZ4::lz4_shared ++ PROPERTIES IMPORTED_LOCATION "${LZ4_SHARED_LIB}" ++ INTERFACE_INCLUDE_DIRECTORIES "${LZ4_PREFIX}/include") ++ add_dependencies(toolchain lz4_ep) ++ add_dependencies(LZ4::lz4_shared lz4_ep) ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS LZ4::lz4_shared) ++ endif() ++ + endmacro() + + if(ARROW_WITH_LZ4) + resolve_dependency(lz4 +- HAVE_ALT ++ USE_CONFIG + TRUE + PC_PACKAGE_NAMES + liblz4) +@@ -2415,7 +2427,7 @@ endmacro() + if(ARROW_WITH_ZSTD) + # ARROW-13384: ZSTD_minCLevel was added in v1.4.0, required by ARROW-13091 + resolve_dependency(zstd +- HAVE_ALT ++ USE_CONFIG + TRUE + PC_PACKAGE_NAMES + libzstd +@@ -2477,7 +2489,7 @@ if(ARROW_WITH_RE2) + # Don't specify "PC_PACKAGE_NAMES re2" here because re2.pc may + # include -std=c++11. It's not compatible with C source and C++ + # source not uses C++ 11. +- resolve_dependency(re2 HAVE_ALT TRUE) ++ resolve_dependency(re2 USE_CONFIG TRUE) + if(${re2_SOURCE} STREQUAL "SYSTEM") + get_target_property(RE2_TYPE re2::re2 TYPE) + if(NOT RE2_TYPE STREQUAL "INTERFACE_LIBRARY") +@@ -3922,7 +3934,7 @@ if(ARROW_WITH_GRPC) + set(gRPC_SOURCE "${Protobuf_SOURCE}") + endif() + resolve_dependency(gRPC +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_GRPC_REQUIRED_VERSION} +@@ -3939,9 +3951,9 @@ if(ARROW_WITH_GRPC) + get_target_property(GRPC_INCLUDE_DIR gRPC::grpc++ INTERFACE_INCLUDE_DIRECTORIES) + if(GRPC_INCLUDE_DIR MATCHES "^\\$<" + OR # generator expression +- EXISTS "${GRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h") ++ EXISTS ${GRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h) + set(GRPCPP_PP_INCLUDE TRUE) +- elseif(EXISTS "${GRPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h") ++ elseif(EXISTS ${GRPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h) + set(GRPCPP_PP_INCLUDE FALSE) + else() + message(FATAL_ERROR "Cannot find grpc++ headers in ${GRPC_INCLUDE_DIR}") +@@ -4282,8 +4294,11 @@ macro(build_orc) + get_target_property(ORC_SNAPPY_INCLUDE_DIR ${Snappy_TARGET} + INTERFACE_INCLUDE_DIRECTORIES) + get_filename_component(ORC_SNAPPY_ROOT "${ORC_SNAPPY_INCLUDE_DIR}" DIRECTORY) +- +- get_target_property(ORC_LZ4_ROOT LZ4::lz4 INTERFACE_INCLUDE_DIRECTORIES) ++ if (TARGET LZ4::lz4_static) ++ get_target_property(ORC_LZ4_ROOT LZ4::lz4_static INTERFACE_INCLUDE_DIRECTORIES) ++ else() ++ get_target_property(ORC_LZ4_ROOT LZ4::lz4_shared INTERFACE_INCLUDE_DIRECTORIES) ++ endif() + get_filename_component(ORC_LZ4_ROOT "${ORC_LZ4_ROOT}" DIRECTORY) + + get_target_property(ORC_ZSTD_ROOT ${ARROW_ZSTD_LIBZSTD} INTERFACE_INCLUDE_DIRECTORIES) +@@ -4321,16 +4336,29 @@ macro(build_orc) + # Work around CMake bug + file(MAKE_DIRECTORY ${ORC_INCLUDE_DIR}) + +- externalproject_add(orc_ep +- URL ${ORC_SOURCE_URL} +- URL_HASH "SHA256=${ARROW_ORC_BUILD_SHA256_CHECKSUM}" +- BUILD_BYPRODUCTS ${ORC_STATIC_LIB} +- CMAKE_ARGS ${ORC_CMAKE_ARGS} ${EP_LOG_OPTIONS} +- DEPENDS ${ARROW_PROTOBUF_LIBPROTOBUF} +- ${ARROW_ZSTD_LIBZSTD} +- ${Snappy_TARGET} +- LZ4::lz4 +- ZLIB::ZLIB) ++ if (TARGET LZ4::lz4_static) ++ externalproject_add(orc_ep ++ URL ${ORC_SOURCE_URL} ++ URL_HASH "SHA256=${ARROW_ORC_BUILD_SHA256_CHECKSUM}" ++ BUILD_BYPRODUCTS ${ORC_STATIC_LIB} ++ CMAKE_ARGS ${ORC_CMAKE_ARGS} ${EP_LOG_OPTIONS} ++ DEPENDS ${ARROW_PROTOBUF_LIBPROTOBUF} ++ ${ARROW_ZSTD_LIBZSTD} ++ ${Snappy_TARGET} ++ LZ4::lz4_static ++ ZLIB::ZLIB) ++ else() ++ externalproject_add(orc_ep ++ URL ${ORC_SOURCE_URL} ++ URL_HASH "SHA256=${ARROW_ORC_BUILD_SHA256_CHECKSUM}" ++ BUILD_BYPRODUCTS ${ORC_STATIC_LIB} ++ CMAKE_ARGS ${ORC_CMAKE_ARGS} ${EP_LOG_OPTIONS} ++ DEPENDS ${ARROW_PROTOBUF_LIBPROTOBUF} ++ ${ARROW_ZSTD_LIBZSTD} ++ ${Snappy_TARGET} ++ LZ4::lz4_shared ++ ZLIB::ZLIB) ++ endif() + + set(ORC_VENDORED 1) + +@@ -4338,7 +4366,11 @@ macro(build_orc) + set_target_properties(orc::liborc + PROPERTIES IMPORTED_LOCATION "${ORC_STATIC_LIB}" + INTERFACE_INCLUDE_DIRECTORIES "${ORC_INCLUDE_DIR}") +- set(ORC_LINK_LIBRARIES LZ4::lz4 ZLIB::ZLIB ${ARROW_ZSTD_LIBZSTD} ${Snappy_TARGET}) ++ if (TARGET LZ4::lz4_static) ++ set(ORC_LINK_LIBRARIES LZ4::lz4_static ZLIB::ZLIB ${ARROW_ZSTD_LIBZSTD} ${Snappy_TARGET}) ++ else() ++ set(ORC_LINK_LIBRARIES LZ4::lz4_shared ZLIB::ZLIB ${ARROW_ZSTD_LIBZSTD} ${Snappy_TARGET}) ++ endif() + if(NOT MSVC) + if(NOT APPLE) + list(APPEND ORC_LINK_LIBRARIES Threads::Threads) +@@ -4765,7 +4797,7 @@ macro(build_awssdk) + endmacro() + + if(ARROW_S3) +- resolve_dependency(AWSSDK HAVE_ALT TRUE) ++ resolve_dependency(AWSSDK USE_CONFIG TRUE) + + message(STATUS "Found AWS SDK headers: ${AWSSDK_INCLUDE_DIR}") + message(STATUS "Found AWS SDK libraries: ${AWSSDK_LINK_LIBRARIES}") diff --git a/recipes/arrow/all/patches/2.0.0-0001-cmake.patch b/recipes/arrow/all/patches/2.0.0-0001-cmake.patch deleted file mode 100644 index e275b8cfe872b..0000000000000 --- a/recipes/arrow/all/patches/2.0.0-0001-cmake.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- cpp/cmake_modules/DefineOptions.cmake -+++ cpp/cmake_modules/DefineOptions.cmake -@@ -76,7 +76,7 @@ macro(define_option_string name description default) - endmacro() - - # Top level cmake dir --if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") -+if(1) - #---------------------------------------------------------------------- - set_option_category("Compile and link") - ---- cpp/cmake_modules/ThirdpartyToolchain.cmake -+++ cpp/cmake_modules/ThirdpartyToolchain.cmake -@@ -1856,3 +1856,3 @@ -- find_package(RapidJSON ${ARROW_RAPIDJSON_REQUIRED_VERSION} HINTS "${CMAKE_ROOT}") -+ find_package(RapidJSON ${ARROW_RAPIDJSON_REQUIRED_VERSION} HINTS "${CMAKE_ROOT}" REQUIRED) - if(RapidJSON_FOUND) -- set(RAPIDJSON_INCLUDE_DIR ${RAPIDJSON_INCLUDE_DIRS}) -+ set(RAPIDJSON_INCLUDE_DIR ${RapidJSON_INCLUDE_DIRS}) diff --git a/recipes/arrow/all/patches/2.0.0-0002-jemalloc.patch b/recipes/arrow/all/patches/2.0.0-0002-jemalloc.patch deleted file mode 100644 index 6fd3afbe4a1db..0000000000000 --- a/recipes/arrow/all/patches/2.0.0-0002-jemalloc.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- cpp/cmake_modules/ThirdpartyToolchain.cmake -+++ cpp/cmake_modules/ThirdpartyToolchain.cmake -@@ -1461,6 +1461,6 @@ - # jemalloc - Unix-only high-performance allocator -- - if(ARROW_JEMALLOC) -+if(0) - message(STATUS "Building (vendored) jemalloc from source") - # We only use a vendored jemalloc as we want to control its version. - # Also our build of jemalloc is specially prefixed so that it will not -@@ -1519,6 +1519,8 @@ - add_dependencies(jemalloc::jemalloc jemalloc_ep) - - list(APPEND ARROW_BUNDLED_STATIC_LIBS jemalloc::jemalloc) -+else() -+ find_package(jemalloc REQUIRED) -+endif() - endif() -- - # ---------------------------------------------------------------------- - # mimalloc - Cross-platform high-performance allocator, from Microsoft ---- cpp/src/arrow/CMakeLists.txt -+++ cpp/src/arrow/CMakeLists.txt -@@ -307,7 +307,7 @@ - - set(_allocator_dependencies "") # Empty list - if(ARROW_JEMALLOC) -- list(APPEND _allocator_dependencies jemalloc_ep) -+ list(APPEND _allocator_dependencies jemalloc::jemalloc) - endif() - if(ARROW_MIMALLOC) - list(APPEND _allocator_dependencies mimalloc_ep) ---- cpp/src/arrow/memory_pool.cc -+++ cpp/src/arrow/memory_pool.cc -@@ -31,7 +31,7 @@ - // Needed to support jemalloc 3 and 4 - #define JEMALLOC_MANGLE - // Explicitly link to our version of jemalloc --#include "jemalloc_ep/dist/include/jemalloc/jemalloc.h" -+#include "jemalloc/jemalloc.h" - #endif - - #ifdef ARROW_MIMALLOC diff --git a/recipes/arrow/all/patches/2.0.0-0005-gandiva-engine.patch b/recipes/arrow/all/patches/2.0.0-0005-gandiva-engine.patch new file mode 100644 index 0000000000000..9fcc4b1a36a8a --- /dev/null +++ b/recipes/arrow/all/patches/2.0.0-0005-gandiva-engine.patch @@ -0,0 +1,13 @@ +--- cpp/src/gandiva/engine.cc ++++ cpp/src/gandiva/engine.cc +@@ -64,6 +64,10 @@ + #include + #include + ++#if GANDIVA_LLVM_VERSION >= 11 ++#include ++#endif ++ + #if defined(_MSC_VER) + #pragma warning(pop) + #endif diff --git a/recipes/arrow/all/patches/2.0.0-0008-fix-cmake.patch b/recipes/arrow/all/patches/2.0.0-0008-fix-cmake.patch new file mode 100644 index 0000000000000..7153d641e0c61 --- /dev/null +++ b/recipes/arrow/all/patches/2.0.0-0008-fix-cmake.patch @@ -0,0 +1,273 @@ +diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt +index 515e6af..7488161 100644 +--- a/cpp/CMakeLists.txt ++++ b/cpp/CMakeLists.txt +@@ -109,7 +109,7 @@ set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build-support") + set(ARROW_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") + set(ARROW_DOC_DIR "share/doc/${PROJECT_NAME}") + +-set(ARROW_LLVM_VERSIONS "10" "9" "8" "7") ++set(ARROW_LLVM_VERSIONS "13" "12" "11" "10" "9" "8" "7") + list(GET ARROW_LLVM_VERSIONS 0 ARROW_LLVM_VERSION_PRIMARY) + string(REGEX + REPLACE "^([0-9]+)(\\..+)?" "\\1" ARROW_LLVM_VERSION_PRIMARY_MAJOR +@@ -667,7 +667,7 @@ endif() + + if(ARROW_WITH_BROTLI) + # Order is important for static linking +- set(ARROW_BROTLI_LIBS Brotli::brotlienc Brotli::brotlidec Brotli::brotlicommon) ++ set(ARROW_BROTLI_LIBS brotli::brotlienc brotli::brotlidec brotli::brotlicommon) + list(APPEND ARROW_LINK_LIBS ${ARROW_BROTLI_LIBS}) + list(APPEND ARROW_STATIC_LINK_LIBS ${ARROW_BROTLI_LIBS}) + if(Brotli_SOURCE STREQUAL "SYSTEM") +@@ -683,9 +683,9 @@ if(ARROW_WITH_BZ2) + endif() + + if(ARROW_WITH_LZ4) +- list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4) ++ list(APPEND ARROW_STATIC_LINK_LIBS lz4::lz4) + if(Lz4_SOURCE STREQUAL "SYSTEM") +- list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4) ++ list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS lz4::lz4) + endif() + endif() + +@@ -842,8 +842,14 @@ endif() + + if(ARROW_MIMALLOC) + add_definitions(-DARROW_MIMALLOC) +- list(APPEND ARROW_LINK_LIBS mimalloc::mimalloc) +- list(APPEND ARROW_STATIC_LINK_LIBS mimalloc::mimalloc) ++ if (TARGET mimalloc-static) ++ list(APPEND ARROW_LINK_LIBS mimalloc-static) ++ list(APPEND ARROW_STATIC_LINK_LIBS mimalloc-static) ++ else() ++ list(APPEND ARROW_LINK_LIBS mimalloc) ++ list(APPEND ARROW_STATIC_LINK_LIBS mimalloc) ++ endif() ++ + endif() + + # ---------------------------------------------------------------------- +diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake +index cc37a3c..8fe6db9 100644 +--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake ++++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake +@@ -171,6 +171,7 @@ macro(provide_find_module DEPENDENCY_NAME) + endmacro() + + macro(resolve_dependency DEPENDENCY_NAME) ++if(0) + set(options) + set(one_value_args REQUIRED_VERSION) + cmake_parse_arguments(ARG +@@ -207,6 +208,14 @@ macro(resolve_dependency DEPENDENCY_NAME) + provide_find_module(${DEPENDENCY_NAME}) + list(APPEND ARROW_SYSTEM_DEPENDENCIES ${DEPENDENCY_NAME}) + endif() ++else() ++ if(ARG_REQUIRED_VERSION) ++ find_package(${DEPENDENCY_NAME} ${ARG_REQUIRED_VERSION} REQUIRED) ++ else() ++ find_package(${DEPENDENCY_NAME} REQUIRED) ++ endif() ++ list(APPEND ARROW_SYSTEM_DEPENDENCIES ${DEPENDENCY_NAME}) ++endif() + endmacro() + + # ---------------------------------------------------------------------- +@@ -826,6 +835,7 @@ endif() + # - Tests need Boost at runtime. + # - S3FS and Flight benchmarks need Boost at runtime. + if(ARROW_BUILD_INTEGRATION ++ OR ARROW_BOOST_REQUIRED + OR ARROW_BUILD_TESTS + OR ARROW_GANDIVA + OR (ARROW_FLIGHT AND ARROW_BUILD_BENCHMARKS) +@@ -846,7 +856,7 @@ if(ARROW_BOOST_REQUIRED) + elseif(BOOST_SOURCE STREQUAL "BUNDLED") + build_boost() + elseif(BOOST_SOURCE STREQUAL "SYSTEM") +- find_package(BoostAlt ${ARROW_BOOST_REQUIRED_VERSION} REQUIRED) ++ find_package(Boost ${ARROW_BOOST_REQUIRED_VERSION} REQUIRED) + endif() + + if(TARGET Boost::system) +@@ -973,11 +983,11 @@ macro(build_brotli) + endmacro() + + if(ARROW_WITH_BROTLI) +- resolve_dependency(Brotli) ++ resolve_dependency(brotli) + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(BROTLI_INCLUDE_DIR Brotli::brotlicommon ++ get_target_property(BROTLI_INCLUDE_DIR brotli::brotlicommon + INTERFACE_INCLUDE_DIRECTORIES) +- include_directories(SYSTEM ${BROTLI_INCLUDE_DIR}) ++ include_directories(SYSTEM ${brotli_INCLUDE_DIR}) + endif() + + if(PARQUET_REQUIRE_ENCRYPTION AND NOT ARROW_PARQUET) +@@ -1200,9 +1210,10 @@ if(ARROW_NEED_GFLAGS) + endif() + endif() + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${GFLAGS_INCLUDE_DIR}) ++ include_directories(SYSTEM ${gflags_INCLUDE_DIR}) ++ set(GFLAGS_LIBRARIES ${gflags_LIBRARIES}) + +- if(NOT TARGET ${GFLAGS_LIBRARIES}) ++ if(0) + if(TARGET gflags-shared) + set(GFLAGS_LIBRARIES gflags-shared) + elseif(TARGET gflags_shared) +@@ -1291,12 +1302,13 @@ endmacro() + if(ARROW_WITH_THRIFT) + # We already may have looked for Thrift earlier, when considering whether + # to build Boost, so don't look again if already found. +- if(NOT Thrift_FOUND AND NOT THRIFT_FOUND) ++ if(0) + # Thrift c++ code generated by 0.13 requires 0.11 or greater + resolve_dependency(Thrift REQUIRED_VERSION 0.11.0) + endif() ++ find_package(Thrift CONFIG REQUIRED) + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${THRIFT_INCLUDE_DIR}) ++ include_directories(SYSTEM ${Thrift_INCLUDE_DIR}) + endif() + + # ---------------------------------------------------------------------- +@@ -1461,6 +1473,7 @@ endif() + # jemalloc - Unix-only high-performance allocator + + if(ARROW_JEMALLOC) ++if(0) + message(STATUS "Building (vendored) jemalloc from source") + # We only use a vendored jemalloc as we want to control its version. + # Also our build of jemalloc is specially prefixed so that it will not +@@ -1519,12 +1532,18 @@ if(ARROW_JEMALLOC) + add_dependencies(jemalloc::jemalloc jemalloc_ep) + + list(APPEND ARROW_BUNDLED_STATIC_LIBS jemalloc::jemalloc) ++else() ++ find_package(jemalloc REQUIRED CONFIG) ++ include_directories(SYSTEM "${jemalloc_INCLUDE_DIR}") ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${jemalloc_LIBRARIES_TARGETS} ) ++endif() + endif() + + # ---------------------------------------------------------------------- + # mimalloc - Cross-platform high-performance allocator, from Microsoft + + if(ARROW_MIMALLOC) ++if(0) + message(STATUS "Building (vendored) mimalloc from source") + # We only use a vendored mimalloc as we want to control its build options. + +@@ -1572,6 +1591,11 @@ if(ARROW_MIMALLOC) + add_dependencies(toolchain mimalloc_ep) + + list(APPEND ARROW_BUNDLED_STATIC_LIBS mimalloc::mimalloc) ++else() ++ find_package(mimalloc REQUIRED CONFIG) ++ include_directories(SYSTEM "${mimalloc_INCLUDE_DIR}") ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${mimalloc_LIBRARIES_TARGETS} ) ++endif() + endif() + + # ---------------------------------------------------------------------- +@@ -1971,11 +1995,16 @@ macro(build_lz4) + endmacro() + + if(ARROW_WITH_LZ4) +- resolve_dependency(Lz4) ++ resolve_dependency(lz4) + + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(LZ4_INCLUDE_DIR LZ4::lz4 INTERFACE_INCLUDE_DIRECTORIES) +- include_directories(SYSTEM ${LZ4_INCLUDE_DIR}) ++ if(TARGET LZ4::lz4_static) ++ get_target_property(LZ4_INCLUDE_DIR LZ4::lz4_static INTERFACE_INCLUDE_DIRECTORIES) ++ else() ++ get_target_property(LZ4_INCLUDE_DIR LZ4::lz4_shared INTERFACE_INCLUDE_DIRECTORIES) ++ endif() ++ include_directories(SYSTEM ${lz4_INCLUDE_DIR}) ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${lz4_LIBRARIES_TARGETS} ) + endif() + + macro(build_zstd) +@@ -2090,10 +2119,10 @@ macro(build_re2) + endmacro() + + if(ARROW_GANDIVA) +- resolve_dependency(RE2) ++ resolve_dependency(re2) + + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(RE2_INCLUDE_DIR RE2::re2 INTERFACE_INCLUDE_DIRECTORIES) ++ get_target_property(RE2_INCLUDE_DIR re2::re2 INTERFACE_INCLUDE_DIRECTORIES) + include_directories(SYSTEM ${RE2_INCLUDE_DIR}) + endif() + +@@ -2541,17 +2570,24 @@ if(ARROW_WITH_GRPC) + endif() + + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(GRPC_INCLUDE_DIR gRPC::grpc INTERFACE_INCLUDE_DIRECTORIES) ++ if(grpc_INCLUDE_DIRS_RELEASE) ++ set(GRPC_INCLUDE_DIR ${grpc_INCLUDE_DIRS_RELEASE}) ++ elseif(grpc_INCLUDE_DIRS_DEBUG) ++ set(GRPC_INCLUDE_DIR ${grpc_INCLUDE_DIRS_DEBUG}) ++ endif() ++ + include_directories(SYSTEM ${GRPC_INCLUDE_DIR}) ++ include_directories(SYSTEM ${absl_INCLUDE_DIR}) ++ include_directories(SYSTEM ${protobuf_INCLUDE_DIR}) + + if(GRPC_VENDORED) + set(GRPCPP_PP_INCLUDE TRUE) + else() + # grpc++ headers may reside in ${GRPC_INCLUDE_DIR}/grpc++ or ${GRPC_INCLUDE_DIR}/grpcpp + # depending on the gRPC version. +- if(EXISTS "${GRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h") ++ if(EXISTS ${gRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h) + set(GRPCPP_PP_INCLUDE TRUE) +- elseif(EXISTS "${GRPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h") ++ elseif(EXISTS ${gRPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h) + set(GRPCPP_PP_INCLUDE FALSE) + else() + message(FATAL_ERROR "Cannot find grpc++ headers in ${GRPC_INCLUDE_DIR}") +diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt +index 2751254..842fc9e 100644 +--- a/cpp/src/arrow/CMakeLists.txt ++++ b/cpp/src/arrow/CMakeLists.txt +@@ -307,10 +307,14 @@ set(ARROW_TESTING_SRCS + + set(_allocator_dependencies "") # Empty list + if(ARROW_JEMALLOC) +- list(APPEND _allocator_dependencies jemalloc_ep) ++ list(APPEND _allocator_dependencies jemalloc::jemalloc) + endif() + if(ARROW_MIMALLOC) +- list(APPEND _allocator_dependencies mimalloc_ep) ++ if (TARGET mimalloc-static) ++ list(APPEND _allocator_dependencies mimalloc-static) ++ else() ++ list(APPEND _allocator_dependencies mimalloc) ++ endif() + endif() + + if(_allocator_dependencies) +diff --git a/cpp/src/arrow/memory_pool.cc b/cpp/src/arrow/memory_pool.cc +index 784bf7b..8f005a5 100644 +--- a/cpp/src/arrow/memory_pool.cc ++++ b/cpp/src/arrow/memory_pool.cc +@@ -31,7 +31,7 @@ + // Needed to support jemalloc 3 and 4 + #define JEMALLOC_MANGLE + // Explicitly link to our version of jemalloc +-#include "jemalloc_ep/dist/include/jemalloc/jemalloc.h" ++#include "jemalloc/jemalloc.h" + #endif + + #ifdef ARROW_MIMALLOC diff --git a/recipes/arrow/all/patches/7.0.0-0003-mallctl-takes-size_t.patch b/recipes/arrow/all/patches/7.0.0-0003-mallctl-takes-size_t.patch new file mode 100644 index 0000000000000..a7077fc324531 --- /dev/null +++ b/recipes/arrow/all/patches/7.0.0-0003-mallctl-takes-size_t.patch @@ -0,0 +1,13 @@ +diff --git a/cpp/src/arrow/memory_pool.cc b/cpp/src/arrow/memory_pool.cc +index cf8bf64..2dcfb01 100644 +--- a/cpp/src/arrow/memory_pool.cc ++++ b/cpp/src/arrow/memory_pool.cc +@@ -563,7 +563,7 @@ MemoryPool* default_memory_pool() { + + Status jemalloc_set_decay_ms(int ms) { + #ifdef ARROW_JEMALLOC +- ssize_t decay_time_ms = static_cast(ms); ++ size_t decay_time_ms = static_cast(ms); + + int err = mallctl("arenas.dirty_decay_ms", nullptr, nullptr, &decay_time_ms, + sizeof(decay_time_ms)); diff --git a/recipes/arrow/all/patches/7.0.0-0006-install-utils.patch b/recipes/arrow/all/patches/7.0.0-0006-install-utils.patch new file mode 100644 index 0000000000000..468fe3a6a6ab5 --- /dev/null +++ b/recipes/arrow/all/patches/7.0.0-0006-install-utils.patch @@ -0,0 +1,17 @@ +diff --git a/cpp/src/arrow/ipc/CMakeLists.txt b/cpp/src/arrow/ipc/CMakeLists.txt +index 495018e..f6cee6f 100644 +--- a/cpp/src/arrow/ipc/CMakeLists.txt ++++ b/cpp/src/arrow/ipc/CMakeLists.txt +@@ -61,8 +61,12 @@ endif() + if(ARROW_BUILD_UTILITIES OR ARROW_BUILD_INTEGRATION) + add_executable(arrow-file-to-stream file_to_stream.cc) + target_link_libraries(arrow-file-to-stream ${ARROW_UTIL_LIB}) ++ install(TARGETS arrow-file-to-stream ${INSTALL_IS_OPTIONAL} ++ DESTINATION ${CMAKE_INSTALL_BINDIR}) + add_executable(arrow-stream-to-file stream_to_file.cc) + target_link_libraries(arrow-stream-to-file ${ARROW_UTIL_LIB}) ++ install(TARGETS arrow-stream-to-file ${INSTALL_IS_OPTIONAL} ++ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if(ARROW_BUILD_INTEGRATION) + add_dependencies(arrow-integration arrow-file-to-stream) diff --git a/recipes/arrow/all/patches/7.0.0-0007-fix-cmake.patch b/recipes/arrow/all/patches/7.0.0-0007-fix-cmake.patch new file mode 100644 index 0000000000000..8b4d5d5518dcc --- /dev/null +++ b/recipes/arrow/all/patches/7.0.0-0007-fix-cmake.patch @@ -0,0 +1,347 @@ +diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt +index 2d7baf1..dff5b1a 100644 +--- a/cpp/CMakeLists.txt ++++ b/cpp/CMakeLists.txt +@@ -699,7 +699,7 @@ endif() + + if(ARROW_WITH_BROTLI) + # Order is important for static linking +- set(ARROW_BROTLI_LIBS Brotli::brotlienc Brotli::brotlidec Brotli::brotlicommon) ++ set(ARROW_BROTLI_LIBS brotli::brotlienc brotli::brotlidec brotli::brotlicommon) + list(APPEND ARROW_LINK_LIBS ${ARROW_BROTLI_LIBS}) + list(APPEND ARROW_STATIC_LINK_LIBS ${ARROW_BROTLI_LIBS}) + if(Brotli_SOURCE STREQUAL "SYSTEM") +@@ -715,10 +715,17 @@ if(ARROW_WITH_BZ2) + endif() + + if(ARROW_WITH_LZ4) +- list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4) +- if(Lz4_SOURCE STREQUAL "SYSTEM") +- list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4) +- endif() ++ if (TARGET LZ4::lz4_static) ++ list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4_static) ++ if(Lz4_SOURCE STREQUAL "SYSTEM") ++ list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4_static) ++ endif() ++ else() ++ list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4_shared) ++ if(Lz4_SOURCE STREQUAL "SYSTEM") ++ list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4_shared) ++ endif() ++endif() + endif() + + if(ARROW_WITH_SNAPPY) +@@ -907,8 +914,13 @@ endif() + + if(ARROW_MIMALLOC) + add_definitions(-DARROW_MIMALLOC) +- list(APPEND ARROW_LINK_LIBS mimalloc::mimalloc) +- list(APPEND ARROW_STATIC_LINK_LIBS mimalloc::mimalloc) ++ if (TARGET mimalloc-static) ++ list(APPEND ARROW_LINK_LIBS mimalloc-static) ++ list(APPEND ARROW_STATIC_LINK_LIBS mimalloc-static) ++ else() ++ list(APPEND ARROW_LINK_LIBS mimalloc) ++ list(APPEND ARROW_STATIC_LINK_LIBS mimalloc) ++ endif() + endif() + + # ---------------------------------------------------------------------- +diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake +index bc38952..62bf314 100644 +--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake ++++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake +@@ -954,7 +954,7 @@ endif() + + if(ARROW_BOOST_REQUIRED) + resolve_dependency(Boost +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_BOOST_REQUIRED_VERSION} +@@ -965,7 +965,7 @@ if(ARROW_BOOST_REQUIRED) + if(TARGET Boost::system) + set(BOOST_SYSTEM_LIBRARY Boost::system) + set(BOOST_FILESYSTEM_LIBRARY Boost::filesystem) +- elseif(BoostAlt_FOUND) ++ elseif(Boost_FOUND) + set(BOOST_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY}) + set(BOOST_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY}) + else() +@@ -1108,9 +1108,9 @@ macro(build_brotli) + endmacro() + + if(ARROW_WITH_BROTLI) +- resolve_dependency(Brotli PC_PACKAGE_NAMES libbrotlidec libbrotlienc) ++ resolve_dependency(brotli PC_PACKAGE_NAMES libbrotlidec libbrotlienc) + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(BROTLI_INCLUDE_DIR Brotli::brotlicommon ++ get_target_property(BROTLI_INCLUDE_DIR brotli::brotlicommon + INTERFACE_INCLUDE_DIRECTORIES) + include_directories(SYSTEM ${BROTLI_INCLUDE_DIR}) + endif() +@@ -1302,22 +1302,17 @@ endmacro() + if(ARROW_NEED_GFLAGS) + set(ARROW_GFLAGS_REQUIRED_VERSION "2.1.0") + resolve_dependency(gflags +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_GFLAGS_REQUIRED_VERSION} + IS_RUNTIME_DEPENDENCY + FALSE) + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${GFLAGS_INCLUDE_DIR}) ++ include_directories(SYSTEM ${gflags_INCLUDE_DIR}) + +- if(NOT TARGET ${GFLAGS_LIBRARIES}) +- if(TARGET gflags-shared) +- set(GFLAGS_LIBRARIES gflags-shared) +- elseif(TARGET gflags_shared) +- set(GFLAGS_LIBRARIES gflags_shared) +- endif() +- endif() ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${gflags_LIBRARIES_TARGETS}) ++ set(GFLAGS_LIBRARIES gflags::gflags) + endif() + + # ---------------------------------------------------------------------- +@@ -1411,9 +1406,9 @@ if(ARROW_WITH_THRIFT) + thrift) + endif() + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${THRIFT_INCLUDE_DIR}) ++ include_directories(SYSTEM ${Thrift_INCLUDE_DIR}) + +- string(REPLACE "." ";" VERSION_LIST ${THRIFT_VERSION}) ++ string(REPLACE "." ";" VERSION_LIST ${Thrift_VERSION}) + list(GET VERSION_LIST 0 THRIFT_VERSION_MAJOR) + list(GET VERSION_LIST 1 THRIFT_VERSION_MINOR) + list(GET VERSION_LIST 2 THRIFT_VERSION_PATCH) +@@ -1528,6 +1523,7 @@ if(ARROW_WITH_PROTOBUF) + set(ARROW_PROTOBUF_REQUIRED_VERSION "2.6.1") + endif() + resolve_dependency(Protobuf ++ USE_CONFIG + REQUIRED_VERSION + ${ARROW_PROTOBUF_REQUIRED_VERSION} + PC_PACKAGE_NAMES +@@ -1538,7 +1534,7 @@ if(ARROW_WITH_PROTOBUF) + endif() + + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${PROTOBUF_INCLUDE_DIR}) ++ include_directories(SYSTEM ${protobuf_INCLUDE_DIR}) + + if(TARGET arrow::protobuf::libprotobuf) + set(ARROW_PROTOBUF_LIBPROTOBUF arrow::protobuf::libprotobuf) +@@ -1547,9 +1543,9 @@ if(ARROW_WITH_PROTOBUF) + if(NOT TARGET protobuf::libprotobuf) + add_library(protobuf::libprotobuf UNKNOWN IMPORTED) + set_target_properties(protobuf::libprotobuf +- PROPERTIES IMPORTED_LOCATION "${PROTOBUF_LIBRARY}" ++ PROPERTIES IMPORTED_LOCATION "${Protobuf_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES +- "${PROTOBUF_INCLUDE_DIR}") ++ "${Protobuf_INCLUDE_DIR}") + endif() + set(ARROW_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) + endif() +@@ -1569,7 +1565,7 @@ if(ARROW_WITH_PROTOBUF) + set_target_properties(protobuf::libprotoc + PROPERTIES IMPORTED_LOCATION "${Protobuf_PROTOC_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES +- "${PROTOBUF_INCLUDE_DIR}") ++ "${Protobuf_INCLUDE_DIR}") + endif() + set(ARROW_PROTOBUF_LIBPROTOC protobuf::libprotoc) + endif() +@@ -1600,6 +1596,7 @@ endif() + # jemalloc - Unix-only high-performance allocator + + if(ARROW_JEMALLOC) ++if(0) + message(STATUS "Building (vendored) jemalloc from source") + # We only use a vendored jemalloc as we want to control its version. + # Also our build of jemalloc is specially prefixed so that it will not +@@ -1665,12 +1662,18 @@ if(ARROW_JEMALLOC) + add_dependencies(jemalloc::jemalloc jemalloc_ep) + + list(APPEND ARROW_BUNDLED_STATIC_LIBS jemalloc::jemalloc) ++else() ++ find_package(jemalloc REQUIRED CONFIG) ++ include_directories(SYSTEM "${jemalloc_INCLUDE_DIR}") ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${jemalloc_LIBRARIES_TARGETS}) ++endif() + endif() + + # ---------------------------------------------------------------------- + # mimalloc - Cross-platform high-performance allocator, from Microsoft + + if(ARROW_MIMALLOC) ++if(0) + message(STATUS "Building (vendored) mimalloc from source") + # We only use a vendored mimalloc as we want to control its build options. + +@@ -1716,6 +1719,11 @@ if(ARROW_MIMALLOC) + add_dependencies(toolchain mimalloc_ep) + + list(APPEND ARROW_BUNDLED_STATIC_LIBS mimalloc::mimalloc) ++else() ++ find_package(mimalloc REQUIRED CONFIG) ++ include_directories(SYSTEM "${mimalloc_INCLUDE_DIR}") ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${mimalloc_LIBRARIES_TARGETS} ) ++endif() + endif() + + # ---------------------------------------------------------------------- +@@ -2001,7 +2009,7 @@ endmacro() + if(ARROW_WITH_RAPIDJSON) + set(ARROW_RAPIDJSON_REQUIRED_VERSION "1.1.0") + resolve_dependency(RapidJSON +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_RAPIDJSON_REQUIRED_VERSION} +@@ -2038,10 +2046,9 @@ endmacro() + + if((NOT ARROW_SIMD_LEVEL STREQUAL "NONE") OR (NOT ARROW_RUNTIME_SIMD_LEVEL STREQUAL "NONE" + )) +- set(xsimd_SOURCE "BUNDLED") + resolve_dependency(xsimd) + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${XSIMD_INCLUDE_DIR}) ++ include_directories(SYSTEM ${xsimd_INCLUDE_DIR}) + endif() + + macro(build_zlib) +@@ -2140,10 +2147,14 @@ macro(build_lz4) + endmacro() + + if(ARROW_WITH_LZ4) +- resolve_dependency(Lz4 PC_PACKAGE_NAMES liblz4) ++ resolve_dependency(lz4) + + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(LZ4_INCLUDE_DIR LZ4::lz4 INTERFACE_INCLUDE_DIRECTORIES) ++ if (TARGET LZ4::lz4_static) ++ get_target_property(LZ4_INCLUDE_DIR LZ4::lz4_static INTERFACE_INCLUDE_DIRECTORIES) ++ else() ++ get_target_property(LZ4_INCLUDE_DIR LZ4::lz4_shared INTERFACE_INCLUDE_DIRECTORIES) ++ endif() + include_directories(SYSTEM ${LZ4_INCLUDE_DIR}) + endif() + +@@ -2274,7 +2285,7 @@ if(ARROW_WITH_RE2) + # Don't specify "PC_PACKAGE_NAMES re2" here because re2.pc may + # include -std=c++11. It's not compatible with C source and C++ + # source not uses C++ 11. +- resolve_dependency(re2 HAVE_ALT TRUE) ++ resolve_dependency(re2 USE_CONFIG TRUE) + if(${re2_SOURCE} STREQUAL "SYSTEM") + get_target_property(RE2_LIB re2::re2 IMPORTED_LOCATION) + string(APPEND ARROW_PC_LIBS_PRIVATE " ${RE2_LIB}") +@@ -2337,7 +2348,7 @@ endmacro() + if(ARROW_WITH_BZ2) + resolve_dependency(BZip2) + if(${BZip2_SOURCE} STREQUAL "SYSTEM") +- string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZIP2_LIBRARIES}") ++ string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZip2_LIBRARIES}") + endif() + + if(NOT TARGET BZip2::BZip2) +@@ -2346,7 +2357,7 @@ if(ARROW_WITH_BZ2) + PROPERTIES IMPORTED_LOCATION "${BZIP2_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIR}") + endif() +- include_directories(SYSTEM "${BZIP2_INCLUDE_DIR}") ++ include_directories(SYSTEM "${BZip2_INCLUDE_DIR}") + endif() + + macro(build_utf8proc) +@@ -3555,7 +3566,7 @@ if(ARROW_WITH_GRPC) + set(gRPC_SOURCE "${Protobuf_SOURCE}") + endif() + resolve_dependency(gRPC +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_GRPC_REQUIRED_VERSION} +@@ -3573,9 +3584,9 @@ if(ARROW_WITH_GRPC) + else() + # grpc++ headers may reside in ${GRPC_INCLUDE_DIR}/grpc++ or ${GRPC_INCLUDE_DIR}/grpcpp + # depending on the gRPC version. +- if(EXISTS "${GRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h") ++ if(EXISTS ${gRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h) + set(GRPCPP_PP_INCLUDE TRUE) +- elseif(EXISTS "${GRPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h") ++ elseif(EXISTS ${gPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h) + set(GRPCPP_PP_INCLUDE FALSE) + else() + message(FATAL_ERROR "Cannot find grpc++ headers in ${GRPC_INCLUDE_DIR}") +@@ -4097,9 +4108,9 @@ macro(build_opentelemetry) + endmacro() + + if(ARROW_WITH_OPENTELEMETRY) +- set(opentelemetry-cpp_SOURCE "AUTO") ++ set(opentelemetry-cpp_SOURCE "SYSTEM") + resolve_dependency(opentelemetry-cpp) +- get_target_property(OPENTELEMETRY_INCLUDE_DIR opentelemetry-cpp::api ++ get_target_property(OPENTELEMETRY_INCLUDE_DIR opentelemetry-cpp::opentelemetry_common + INTERFACE_INCLUDE_DIRECTORIES) + include_directories(SYSTEM ${OPENTELEMETRY_INCLUDE_DIR}) + message(STATUS "Found OpenTelemetry headers: ${OPENTELEMETRY_INCLUDE_DIR}") +diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt +index b984bc1..2c78cd9 100644 +--- a/cpp/src/arrow/CMakeLists.txt ++++ b/cpp/src/arrow/CMakeLists.txt +@@ -323,10 +323,14 @@ set(ARROW_TESTING_SRCS + + set(_allocator_dependencies "") # Empty list + if(ARROW_JEMALLOC) +- list(APPEND _allocator_dependencies jemalloc_ep) ++ list(APPEND _allocator_dependencies jemalloc::jemalloc) + endif() + if(ARROW_MIMALLOC) +- list(APPEND _allocator_dependencies mimalloc_ep) ++ if (TARGET mimalloc-static) ++ list(APPEND _allocator_dependencies mimalloc-static) ++ else() ++ list(APPEND _allocator_dependencies mimalloc) ++ endif() + endif() + + if(_allocator_dependencies) +diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt +index 2cf8c99..90ebb9a 100644 +--- a/cpp/src/arrow/flight/CMakeLists.txt ++++ b/cpp/src/arrow/flight/CMakeLists.txt +@@ -17,6 +17,9 @@ + + add_custom_target(arrow_flight) + ++# TODO: This is a temporary workaround. absl should be LINKED as TARGET. ++include_directories(SYSTEM ${absl_INCLUDE_DIR}) ++ + arrow_install_all_headers("arrow/flight") + + set(ARROW_FLIGHT_LINK_LIBS gRPC::grpc++ ${ARROW_PROTOBUF_LIBPROTOBUF}) +diff --git a/cpp/src/arrow/memory_pool.cc b/cpp/src/arrow/memory_pool.cc +index 2dcfb01..0394c01 100644 +--- a/cpp/src/arrow/memory_pool.cc ++++ b/cpp/src/arrow/memory_pool.cc +@@ -48,7 +48,7 @@ + // Needed to support jemalloc 3 and 4 + #define JEMALLOC_MANGLE + // Explicitly link to our version of jemalloc +-#include "jemalloc_ep/dist/include/jemalloc/jemalloc.h" ++#include "jemalloc/jemalloc.h" + #endif + + #ifdef ARROW_MIMALLOC diff --git a/recipes/arrow/all/patches/8.0.0-0003-mallctl-takes-size_t.patch b/recipes/arrow/all/patches/8.0.0-0003-mallctl-takes-size_t.patch new file mode 100644 index 0000000000000..87a804c6cd774 --- /dev/null +++ b/recipes/arrow/all/patches/8.0.0-0003-mallctl-takes-size_t.patch @@ -0,0 +1,13 @@ +diff --git a/cpp/src/arrow/memory_pool.cc b/cpp/src/arrow/memory_pool.cc +index 1f8f896..37a89da 100644 +--- a/cpp/src/arrow/memory_pool.cc ++++ b/cpp/src/arrow/memory_pool.cc +@@ -767,7 +767,7 @@ MemoryPool* default_memory_pool() { + + Status jemalloc_set_decay_ms(int ms) { + #ifdef ARROW_JEMALLOC +- ssize_t decay_time_ms = static_cast(ms); ++ size_t decay_time_ms = static_cast(ms); + + int err = mallctl("arenas.dirty_decay_ms", nullptr, nullptr, &decay_time_ms, + sizeof(decay_time_ms)); diff --git a/recipes/arrow/all/patches/8.0.0-0005-install-utils.patch b/recipes/arrow/all/patches/8.0.0-0005-install-utils.patch new file mode 100644 index 0000000000000..397c4b1d043c7 --- /dev/null +++ b/recipes/arrow/all/patches/8.0.0-0005-install-utils.patch @@ -0,0 +1,43 @@ +diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt +index aba18c8..bb463d0 100644 +--- a/cpp/CMakeLists.txt ++++ b/cpp/CMakeLists.txt +@@ -721,7 +721,7 @@ if(ARROW_WITH_BZ2) + endif() + + if(ARROW_WITH_LZ4) +- list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4) ++ list(APPEND ARROW_STATIC_LINK_LIBS lz4::lz4) + if(Lz4_SOURCE STREQUAL "SYSTEM") + list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4) + endif() +@@ -907,8 +907,8 @@ endif() + if(ARROW_JEMALLOC) + add_definitions(-DARROW_JEMALLOC) + add_definitions(-DARROW_JEMALLOC_INCLUDE_DIR=${JEMALLOC_INCLUDE_DIR}) +- list(APPEND ARROW_LINK_LIBS jemalloc::jemalloc) +- list(APPEND ARROW_STATIC_LINK_LIBS jemalloc::jemalloc) ++ list(APPEND ARROW_LINK_LIBS jemalloc) ++ list(APPEND ARROW_STATIC_LINK_LIBS jemalloc) + endif() + + if(ARROW_MIMALLOC) +diff --git a/cpp/src/arrow/ipc/CMakeLists.txt b/cpp/src/arrow/ipc/CMakeLists.txt +index 495018e..3dcb35d 100644 +--- a/cpp/src/arrow/ipc/CMakeLists.txt ++++ b/cpp/src/arrow/ipc/CMakeLists.txt +@@ -61,9 +61,13 @@ endif() + if(ARROW_BUILD_UTILITIES OR ARROW_BUILD_INTEGRATION) + add_executable(arrow-file-to-stream file_to_stream.cc) + target_link_libraries(arrow-file-to-stream ${ARROW_UTIL_LIB}) ++ install(TARGETS arrow-file-to-stream ${INSTALL_IS_OPTIONAL} ++ DESTINATION ${CMAKE_INSTALL_BINDIR}) + add_executable(arrow-stream-to-file stream_to_file.cc) + target_link_libraries(arrow-stream-to-file ${ARROW_UTIL_LIB}) +- ++ install(TARGETS arrow-stream-to-file ${INSTALL_IS_OPTIONAL} ++ DESTINATION ${CMAKE_INSTALL_BINDIR}) ++ + if(ARROW_BUILD_INTEGRATION) + add_dependencies(arrow-integration arrow-file-to-stream) + add_dependencies(arrow-integration arrow-stream-to-file) diff --git a/recipes/arrow/all/patches/8.0.0-0006-fix-cmake.patch b/recipes/arrow/all/patches/8.0.0-0006-fix-cmake.patch new file mode 100644 index 0000000000000..eb60d6e795ad5 --- /dev/null +++ b/recipes/arrow/all/patches/8.0.0-0006-fix-cmake.patch @@ -0,0 +1,425 @@ +diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt +index bb463d0..ce2d1df 100644 +--- a/cpp/CMakeLists.txt ++++ b/cpp/CMakeLists.txt +@@ -705,7 +705,7 @@ endif() + + if(ARROW_WITH_BROTLI) + # Order is important for static linking +- set(ARROW_BROTLI_LIBS Brotli::brotlienc Brotli::brotlidec Brotli::brotlicommon) ++ set(ARROW_BROTLI_LIBS brotli::brotlienc brotli::brotlidec brotli::brotlicommon) + list(APPEND ARROW_LINK_LIBS ${ARROW_BROTLI_LIBS}) + list(APPEND ARROW_STATIC_LINK_LIBS ${ARROW_BROTLI_LIBS}) + if(Brotli_SOURCE STREQUAL "SYSTEM") +@@ -721,11 +721,18 @@ if(ARROW_WITH_BZ2) + endif() + + if(ARROW_WITH_LZ4) +- list(APPEND ARROW_STATIC_LINK_LIBS lz4::lz4) +- if(Lz4_SOURCE STREQUAL "SYSTEM") +- list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4) ++ if (TARGET LZ4::lz4_static) ++ list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4_static) ++ if(Lz4_SOURCE STREQUAL "SYSTEM") ++ list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4_static) ++ endif() ++ else() ++ list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4_shared) ++ if(Lz4_SOURCE STREQUAL "SYSTEM") ++ list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4_shared) + endif() + endif() ++endif() + + if(ARROW_WITH_SNAPPY) + list(APPEND ARROW_STATIC_LINK_LIBS Snappy::snappy) +@@ -913,8 +920,13 @@ endif() + + if(ARROW_MIMALLOC) + add_definitions(-DARROW_MIMALLOC) +- list(APPEND ARROW_LINK_LIBS mimalloc::mimalloc) +- list(APPEND ARROW_STATIC_LINK_LIBS mimalloc::mimalloc) ++ if (TARGET mimalloc-static) ++ list(APPEND ARROW_LINK_LIBS mimalloc-static) ++ list(APPEND ARROW_STATIC_LINK_LIBS mimalloc-static) ++ else() ++ list(APPEND ARROW_LINK_LIBS mimalloc) ++ list(APPEND ARROW_STATIC_LINK_LIBS mimalloc) ++ endif() + endif() + + # ---------------------------------------------------------------------- +diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake +index f070323..16faf73 100644 +--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake ++++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake +@@ -959,6 +959,7 @@ endif() + # - Tests need Boost at runtime. + # - S3FS and Flight benchmarks need Boost at runtime. + if(ARROW_BUILD_INTEGRATION ++ OR ARROW_BOOST_REQUIRED + OR ARROW_BUILD_TESTS + OR (ARROW_FLIGHT AND ARROW_BUILD_BENCHMARKS) + OR (ARROW_S3 AND ARROW_BUILD_BENCHMARKS)) +@@ -975,7 +976,7 @@ endif() + + if(ARROW_BOOST_REQUIRED) + resolve_dependency(Boost +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_BOOST_REQUIRED_VERSION} +@@ -986,7 +987,7 @@ if(ARROW_BOOST_REQUIRED) + if(TARGET Boost::system) + set(BOOST_SYSTEM_LIBRARY Boost::system) + set(BOOST_FILESYSTEM_LIBRARY Boost::filesystem) +- elseif(BoostAlt_FOUND) ++ elseif(Boost_FOUND) + set(BOOST_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY}) + set(BOOST_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY}) + else() +@@ -1129,9 +1130,9 @@ macro(build_brotli) + endmacro() + + if(ARROW_WITH_BROTLI) +- resolve_dependency(Brotli PC_PACKAGE_NAMES libbrotlidec libbrotlienc) ++ resolve_dependency(brotli PC_PACKAGE_NAMES libbrotlidec libbrotlienc) + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(BROTLI_INCLUDE_DIR Brotli::brotlicommon ++ get_target_property(BROTLI_INCLUDE_DIR brotli::brotlicommon + INTERFACE_INCLUDE_DIRECTORIES) + include_directories(SYSTEM ${BROTLI_INCLUDE_DIR}) + endif() +@@ -1323,22 +1324,16 @@ endmacro() + if(ARROW_NEED_GFLAGS) + set(ARROW_GFLAGS_REQUIRED_VERSION "2.1.0") + resolve_dependency(gflags +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_GFLAGS_REQUIRED_VERSION} + IS_RUNTIME_DEPENDENCY + FALSE) + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${GFLAGS_INCLUDE_DIR}) +- +- if(NOT TARGET ${GFLAGS_LIBRARIES}) +- if(TARGET gflags-shared) +- set(GFLAGS_LIBRARIES gflags-shared) +- elseif(TARGET gflags_shared) +- set(GFLAGS_LIBRARIES gflags_shared) +- endif() +- endif() ++ include_directories(SYSTEM ${gflags_INCLUDE_DIR}) ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${gflags_LIBRARIES_TARGETS}) ++ set(GFLAGS_LIBRARIES gflags::gflags) + endif() + + # ---------------------------------------------------------------------- +@@ -1432,9 +1427,9 @@ if(ARROW_WITH_THRIFT) + thrift) + endif() + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${THRIFT_INCLUDE_DIR}) ++ include_directories(SYSTEM ${Thrift_INCLUDE_DIR}) + +- string(REPLACE "." ";" VERSION_LIST ${THRIFT_VERSION}) ++ string(REPLACE "." ";" VERSION_LIST ${Thrift_VERSION}) + list(GET VERSION_LIST 0 THRIFT_VERSION_MAJOR) + list(GET VERSION_LIST 1 THRIFT_VERSION_MINOR) + list(GET VERSION_LIST 2 THRIFT_VERSION_PATCH) +@@ -1557,6 +1552,7 @@ if(ARROW_WITH_PROTOBUF) + set(ARROW_PROTOBUF_REQUIRED_VERSION "2.6.1") + endif() + resolve_dependency(Protobuf ++ USE_CONFIG + REQUIRED_VERSION + ${ARROW_PROTOBUF_REQUIRED_VERSION} + PC_PACKAGE_NAMES +@@ -1567,7 +1563,7 @@ if(ARROW_WITH_PROTOBUF) + endif() + + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${PROTOBUF_INCLUDE_DIR}) ++ include_directories(SYSTEM ${protobuf_INCLUDE_DIR}) + + if(TARGET arrow::protobuf::libprotobuf) + set(ARROW_PROTOBUF_LIBPROTOBUF arrow::protobuf::libprotobuf) +@@ -1576,9 +1572,9 @@ if(ARROW_WITH_PROTOBUF) + if(NOT TARGET protobuf::libprotobuf) + add_library(protobuf::libprotobuf UNKNOWN IMPORTED) + set_target_properties(protobuf::libprotobuf +- PROPERTIES IMPORTED_LOCATION "${PROTOBUF_LIBRARY}" ++ PROPERTIES IMPORTED_LOCATION "${Protobuf_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES +- "${PROTOBUF_INCLUDE_DIR}") ++ "${Protobuf_INCLUDE_DIR}") + endif() + set(ARROW_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) + endif() +@@ -1598,7 +1594,7 @@ if(ARROW_WITH_PROTOBUF) + set_target_properties(protobuf::libprotoc + PROPERTIES IMPORTED_LOCATION "${Protobuf_PROTOC_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES +- "${PROTOBUF_INCLUDE_DIR}") ++ "${Protobuf_INCLUDE_DIR}") + endif() + set(ARROW_PROTOBUF_LIBPROTOC protobuf::libprotoc) + endif() +@@ -1690,11 +1686,12 @@ macro(build_substrait) + + add_custom_target(substrait_gen ALL DEPENDS ${SUBSTRAIT_PROTO_GEN_ALL}) + +- set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR} ${PROTOBUF_INCLUDE_DIR}) ++ set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR} ${protobuf_INCLUDE_DIR}) + + add_library(substrait STATIC ${SUBSTRAIT_SOURCES}) + set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON) + target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES}) ++ target_include_directories(substrait PUBLIC ${PROTOBUF_INCLUDE_DIR}) + target_link_libraries(substrait INTERFACE ${ARROW_PROTOBUF_LIBPROTOBUF}) + add_dependencies(substrait substrait_gen) + +@@ -1711,6 +1708,7 @@ endif() + # jemalloc - Unix-only high-performance allocator + + if(ARROW_JEMALLOC) ++if(0) + message(STATUS "Building (vendored) jemalloc from source") + # We only use a vendored jemalloc as we want to control its version. + # Also our build of jemalloc is specially prefixed so that it will not +@@ -1780,12 +1778,18 @@ if(ARROW_JEMALLOC) + add_dependencies(jemalloc::jemalloc jemalloc_ep) + + list(APPEND ARROW_BUNDLED_STATIC_LIBS jemalloc::jemalloc) ++else() ++ find_package(jemalloc REQUIRED CONFIG) ++ include_directories(SYSTEM "${jemalloc_INCLUDE_DIR}") ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${jemalloc_LIBRARIES_TARGETS}) ++endif() + endif() + + # ---------------------------------------------------------------------- + # mimalloc - Cross-platform high-performance allocator, from Microsoft + + if(ARROW_MIMALLOC) ++if(0) + message(STATUS "Building (vendored) mimalloc from source") + # We only use a vendored mimalloc as we want to control its build options. + +@@ -1836,6 +1840,11 @@ if(ARROW_MIMALLOC) + add_dependencies(toolchain mimalloc_ep) + + list(APPEND ARROW_BUNDLED_STATIC_LIBS mimalloc::mimalloc) ++else() ++ find_package(mimalloc REQUIRED CONFIG) ++ include_directories(SYSTEM "${mimalloc_INCLUDE_DIR}") ++ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${mimalloc_LIBRARIES_TARGETS} ) ++endif() + endif() + + # ---------------------------------------------------------------------- +@@ -2121,7 +2130,7 @@ endmacro() + if(ARROW_WITH_RAPIDJSON) + set(ARROW_RAPIDJSON_REQUIRED_VERSION "1.1.0") + resolve_dependency(RapidJSON +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_RAPIDJSON_REQUIRED_VERSION} +@@ -2158,10 +2167,10 @@ endmacro() + + if((NOT ARROW_SIMD_LEVEL STREQUAL "NONE") OR (NOT ARROW_RUNTIME_SIMD_LEVEL STREQUAL "NONE" + )) +- set(xsimd_SOURCE "BUNDLED") ++ set(xsimd_SOURCE "SYSTEM") + resolve_dependency(xsimd) + # TODO: Don't use global includes but rather target_include_directories +- include_directories(SYSTEM ${XSIMD_INCLUDE_DIR}) ++ include_directories(SYSTEM ${xsimd_INCLUDE_DIR}) + endif() + + macro(build_zlib) +@@ -2260,10 +2269,14 @@ macro(build_lz4) + endmacro() + + if(ARROW_WITH_LZ4) +- resolve_dependency(Lz4 PC_PACKAGE_NAMES liblz4) ++ resolve_dependency(Lz4) + + # TODO: Don't use global includes but rather target_include_directories +- get_target_property(LZ4_INCLUDE_DIR LZ4::lz4 INTERFACE_INCLUDE_DIRECTORIES) ++ if (TARGET LZ4::lz4_static) ++ get_target_property(LZ4_INCLUDE_DIR LZ4::lz4_static INTERFACE_INCLUDE_DIRECTORIES) ++ else() ++ get_target_property(LZ4_INCLUDE_DIR LZ4::lz4_shared INTERFACE_INCLUDE_DIRECTORIES) ++ endif() + include_directories(SYSTEM ${LZ4_INCLUDE_DIR}) + endif() + +@@ -2394,7 +2407,7 @@ if(ARROW_WITH_RE2) + # Don't specify "PC_PACKAGE_NAMES re2" here because re2.pc may + # include -std=c++11. It's not compatible with C source and C++ + # source not uses C++ 11. +- resolve_dependency(re2 HAVE_ALT TRUE) ++ resolve_dependency(re2 USE_CONFIG TRUE) + if(${re2_SOURCE} STREQUAL "SYSTEM") + get_target_property(RE2_LIB re2::re2 IMPORTED_LOCATION_${UPPERCASE_BUILD_TYPE}) + if(NOT RE2_LIB) +@@ -2464,7 +2477,7 @@ endmacro() + if(ARROW_WITH_BZ2) + resolve_dependency(BZip2) + if(${BZip2_SOURCE} STREQUAL "SYSTEM") +- string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZIP2_LIBRARIES}") ++ string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZip2_LIBRARIES}") + endif() + + if(NOT TARGET BZip2::BZip2) +@@ -2473,7 +2486,7 @@ if(ARROW_WITH_BZ2) + PROPERTIES IMPORTED_LOCATION "${BZIP2_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIR}") + endif() +- include_directories(SYSTEM "${BZIP2_INCLUDE_DIR}") ++ include_directories(SYSTEM "${BZip2_INCLUDE_DIR}") + endif() + + macro(build_utf8proc) +@@ -3709,7 +3722,7 @@ if(ARROW_WITH_GRPC) + set(gRPC_SOURCE "${Protobuf_SOURCE}") + endif() + resolve_dependency(gRPC +- HAVE_ALT ++ USE_CONFIG + TRUE + REQUIRED_VERSION + ${ARROW_GRPC_REQUIRED_VERSION} +@@ -3727,9 +3740,9 @@ if(ARROW_WITH_GRPC) + else() + # grpc++ headers may reside in ${GRPC_INCLUDE_DIR}/grpc++ or ${GRPC_INCLUDE_DIR}/grpcpp + # depending on the gRPC version. +- if(EXISTS "${GRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h") ++ if(EXISTS ${gRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h) + set(GRPCPP_PP_INCLUDE TRUE) +- elseif(EXISTS "${GRPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h") ++ elseif(EXISTS ${gRPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h) + set(GRPCPP_PP_INCLUDE FALSE) + else() + message(FATAL_ERROR "Cannot find grpc++ headers in ${GRPC_INCLUDE_DIR}") +@@ -3937,7 +3950,7 @@ macro(build_google_cloud_cpp_storage) + endmacro() + + if(ARROW_WITH_GOOGLE_CLOUD_CPP) +- resolve_dependency(google_cloud_cpp_storage) ++ resolve_dependency(google_cloud_cpp) + get_target_property(google_cloud_cpp_storage_INCLUDE_DIR google-cloud-cpp::storage + INTERFACE_INCLUDE_DIRECTORIES) + include_directories(SYSTEM ${google_cloud_cpp_storage_INCLUDE_DIR}) +@@ -4264,9 +4277,9 @@ if(ARROW_WITH_OPENTELEMETRY) + # cURL is required whether we build from source or use an existing installation + # (OTel's cmake files do not call find_curl for you) + find_curl() +- set(opentelemetry-cpp_SOURCE "AUTO") ++ set(opentelemetry-cpp_SOURCE "SYSTEM") + resolve_dependency(opentelemetry-cpp) +- get_target_property(OPENTELEMETRY_INCLUDE_DIR opentelemetry-cpp::api ++ get_target_property(OPENTELEMETRY_INCLUDE_DIR opentelemetry-cpp::opentelemetry_common + INTERFACE_INCLUDE_DIRECTORIES) + include_directories(SYSTEM ${OPENTELEMETRY_INCLUDE_DIR}) + message(STATUS "Found OpenTelemetry headers: ${OPENTELEMETRY_INCLUDE_DIR}") +diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt +index 690c51a..752f3b9 100644 +--- a/cpp/src/arrow/CMakeLists.txt ++++ b/cpp/src/arrow/CMakeLists.txt +@@ -326,10 +326,14 @@ set(ARROW_TESTING_SRCS + + set(_allocator_dependencies "") # Empty list + if(ARROW_JEMALLOC) +- list(APPEND _allocator_dependencies jemalloc_ep) ++ list(APPEND _allocator_dependencies jemalloc::jemalloc) + endif() + if(ARROW_MIMALLOC) +- list(APPEND _allocator_dependencies mimalloc_ep) ++ if (TARGET mimalloc-static) ++ list(APPEND _allocator_dependencies mimalloc-static) ++ else() ++ list(APPEND _allocator_dependencies mimalloc) ++ endif() + endif() + + if(_allocator_dependencies) +diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt +index f9d1356..c9bcf79 100644 +--- a/cpp/src/arrow/flight/CMakeLists.txt ++++ b/cpp/src/arrow/flight/CMakeLists.txt +@@ -17,6 +17,9 @@ + + add_custom_target(arrow_flight) + ++# TODO: This is a temporary workaround. absl should be LINKED as TARGET. ++include_directories(SYSTEM ${absl_INCLUDE_DIR}) ++ + arrow_install_all_headers("arrow/flight") + + set(ARROW_FLIGHT_LINK_LIBS gRPC::grpc++ ${ARROW_PROTOBUF_LIBPROTOBUF}) +diff --git a/cpp/src/arrow/memory_pool.cc b/cpp/src/arrow/memory_pool.cc +index ed1c2d8..37a89da 100644 +--- a/cpp/src/arrow/memory_pool.cc ++++ b/cpp/src/arrow/memory_pool.cc +@@ -52,7 +52,7 @@ + // Needed to support jemalloc 3 and 4 + #define JEMALLOC_MANGLE + // Explicitly link to our version of jemalloc +-#include "jemalloc_ep/dist/include/jemalloc/jemalloc.h" ++#include "jemalloc/jemalloc.h" + #endif + + #ifdef ARROW_MIMALLOC +diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt +index 71faf9a..3aabea1 100644 +--- a/cpp/src/gandiva/CMakeLists.txt ++++ b/cpp/src/gandiva/CMakeLists.txt +@@ -25,7 +25,7 @@ add_custom_target(gandiva-benchmarks) + + add_dependencies(gandiva-all gandiva gandiva-tests gandiva-benchmarks) + +-find_package(LLVMAlt REQUIRED) ++find_package(LLVM REQUIRED) + + if(LLVM_VERSION_MAJOR LESS "10") + set(GANDIVA_CXX_STANDARD ${CMAKE_CXX_STANDARD}) +@@ -40,7 +40,7 @@ endif() + + add_definitions(-DGANDIVA_LLVM_VERSION=${LLVM_VERSION_MAJOR}) + +-find_package(OpenSSLAlt REQUIRED) ++find_package(OpenSSL REQUIRED) + + # Set the path where the bitcode file generated, see precompiled/CMakeLists.txt + set(GANDIVA_PRECOMPILED_BC_PATH "${CMAKE_CURRENT_BINARY_DIR}/irhelpers.bc") +@@ -98,10 +98,11 @@ set(SRC_FILES + random_generator_holder.cc + ${GANDIVA_PRECOMPILED_CC_PATH}) + +-set(GANDIVA_SHARED_PRIVATE_LINK_LIBS arrow_shared LLVM::LLVM_INTERFACE +- ${GANDIVA_OPENSSL_LIBS}) ++set(GANDIVA_SHARED_PRIVATE_LINK_LIBS arrow_shared llvm-core::llvm-core NTERFACE ++ ${GANDIVA_OPENSSL_LIBS}) ++ ++set(GANDIVA_STATIC_LINK_LIBS arrow_static llvm-core::llvm-core ${GANDIVA_OPENSSL_LIBS}) + +-set(GANDIVA_STATIC_LINK_LIBS arrow_static LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS}) + + if(ARROW_GANDIVA_STATIC_LIBSTDCPP AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX + )) +@@ -139,7 +140,7 @@ add_arrow_lib(gandiva + arrow_dependencies + precompiled + EXTRA_INCLUDES +- $ ++ $ + ${GANDIVA_OPENSSL_INCLUDE_DIR} + ${UTF8PROC_INCLUDE_DIR} + SHARED_LINK_FLAGS diff --git a/recipes/arrow/all/test_package/CMakeLists.txt b/recipes/arrow/all/test_package/CMakeLists.txt index f8716e685bc76..9b721bbe6a17c 100644 --- a/recipes/arrow/all/test_package/CMakeLists.txt +++ b/recipes/arrow/all/test_package/CMakeLists.txt @@ -1,12 +1,12 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(Arrow) +find_package(Arrow REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} arrow::arrow) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) -target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_JEMALLOC) +target_link_libraries(${PROJECT_NAME} PRIVATE arrow::arrow) +if (${Arrow_VERSION} VERSION_LESS "10.0.0") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +endif() diff --git a/recipes/arrow/all/test_package/conanfile.py b/recipes/arrow/all/test_package/conanfile.py index 1d0bdd3779793..1111583fea732 100644 --- a/recipes/arrow/all/test_package/conanfile.py +++ b/recipes/arrow/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os +# It will become the standard on Conan 2.x class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +22,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/arrow/all/test_v1_package/CMakeLists.txt b/recipes/arrow/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2a9b48732268c --- /dev/null +++ b/recipes/arrow/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) + +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/arrow/all/test_v1_package/conanfile.py b/recipes/arrow/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/arrow/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/arrow/config.yml b/recipes/arrow/config.yml index b5ab92c4c4598..2b8b263889ae5 100644 --- a/recipes/arrow/config.yml +++ b/recipes/arrow/config.yml @@ -1,5 +1,13 @@ versions: - "1.0.0": + "10.0.0": + folder: all + "8.0.1": + folder: all + "8.0.0": + folder: all + "7.0.0": folder: all "2.0.0": folder: all + "1.0.0": + folder: all diff --git a/recipes/arsenalgear/all/CMakeLists.txt b/recipes/arsenalgear/all/CMakeLists.txt new file mode 100644 index 0000000000000..3656fbcc9d3a0 --- /dev/null +++ b/recipes/arsenalgear/all/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.8) +project(arsenalgear LANGUAGES CXX) + +include(GNUInstallDirs) + +add_library(arsenalgear ${arsenalgear_src}) +target_sources(arsenalgear PRIVATE + $<$: + ${ARSENALGEAR_SRC_DIR}/src/operators.cpp + > + ${ARSENALGEAR_SRC_DIR}/src/stream.cpp + ${ARSENALGEAR_SRC_DIR}/src/system.cpp + ${ARSENALGEAR_SRC_DIR}/src/utils.cpp +) +target_include_directories(arsenalgear PRIVATE "${ARSENALGEAR_SRC_DIR}/include") +set_target_properties(arsenalgear PROPERTIES + PUBLIC_HEADER "${arsenalgear_inc}" + WINDOWS_EXPORT_ALL_SYMBOLS ON +) +target_compile_features(arsenalgear PUBLIC cxx_std_17) + +if(${ARSENALGEAR_VERSION} VERSION_LESS 2.0.0) + find_package(Boost REQUIRED CONFIG) + target_link_libraries(arsenalgear PUBLIC Boost::headers) + + find_package(exprtk CONFIG) + if(${exprtk_FOUND}) + target_link_libraries(arsenalgear PUBLIC exprtk::exprtk) + endif() +endif() + +find_library(LIBM m) +target_link_libraries(arsenalgear PRIVATE $<$:${LIBM}>) + +install( + TARGETS arsenalgear + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +install( + DIRECTORY ${ARSENALGEAR_SRC_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arsenalgear +) diff --git a/recipes/arsenalgear/all/conandata.yml b/recipes/arsenalgear/all/conandata.yml new file mode 100644 index 0000000000000..b30bf921ec7e0 --- /dev/null +++ b/recipes/arsenalgear/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "2.0.1": + url: "https://github.com/JustWhit3/arsenalgear-cpp/archive/refs/tags/v2.0.1.tar.gz" + sha256: "d0fa1639abb3c41aa60e596b9d70966281a1206c5527b34a4526f6577c3bac6f" + "1.2.2": + url: "https://github.com/JustWhit3/arsenalgear-cpp/archive/refs/tags/v1.2.2.tar.gz" + sha256: "556155d0be0942bcdd5df02fcda258579915e76b5a70e7220de6ef38c8ca7779" diff --git a/recipes/arsenalgear/all/conanfile.py b/recipes/arsenalgear/all/conanfile.py new file mode 100644 index 0000000000000..5a83b05e8d8a5 --- /dev/null +++ b/recipes/arsenalgear/all/conanfile.py @@ -0,0 +1,103 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc +from conan.tools.files import get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.52.0" + +class ArsenalgearConan(ConanFile): + name = "arsenalgear" + description = "A library containing general purpose C++ utils." + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/JustWhit3/arsenalgear-cpp" + topics = ("constants", "math", "operators", "stream") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "16", + "gcc": "8", + "clang": "7", + "apple-clang": "12.0", + } + + def export_sources(self): + copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if Version(self.version) < "2.0.0": + self.requires("boost/1.80.0") + if self.settings.os in ["Linux", "Macos"]: + self.requires("exprtk/0.0.1") + + def validate(self): + # arsenalgear doesn't support Visual Studio(yet). + if is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} doesn't support Visual Studio(yet)") + + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ARSENALGEAR_VERSION"] = str(self.version) + tc.variables["ARSENALGEAR_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["arsenalgear"] + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/arsenalgear/all/test_package/CMakeLists.txt b/recipes/arsenalgear/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e3d45800d41b0 --- /dev/null +++ b/recipes/arsenalgear/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +find_package(arsenalgear REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE arsenalgear::arsenalgear) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/arsenalgear/all/test_package/conanfile.py b/recipes/arsenalgear/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fbb7f543162 --- /dev/null +++ b/recipes/arsenalgear/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/arsenalgear/all/test_package/test_package.cpp b/recipes/arsenalgear/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..895be62629f85 --- /dev/null +++ b/recipes/arsenalgear/all/test_package/test_package.cpp @@ -0,0 +1,26 @@ +#include +#include + +#include "arsenalgear/constants.hpp" +#include "arsenalgear/operators.hpp" + +void operators() { + std::cout << "\n" + << "======================================================" + << "\n" + << " OPERATORS " + << "\n" + << "======================================================" + << "\n" + << "\n"; + + std::string a = "a"; + std::cout << "Multiplying \"a\" for 5 times: " << a * 5 + << agr::empty_space * 5 << "adding spaces." + << "\n\n"; +} + +int main() { + operators(); + return 0; +} diff --git a/recipes/arsenalgear/all/test_v1_package/CMakeLists.txt b/recipes/arsenalgear/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2340ca5c12b92 --- /dev/null +++ b/recipes/arsenalgear/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(arsenalgear REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE arsenalgear::arsenalgear) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/arsenalgear/all/test_v1_package/conanfile.py b/recipes/arsenalgear/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/arsenalgear/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/arsenalgear/config.yml b/recipes/arsenalgear/config.yml new file mode 100644 index 0000000000000..6d0bf30afb485 --- /dev/null +++ b/recipes/arsenalgear/config.yml @@ -0,0 +1,5 @@ +versions: + "2.0.1": + folder: all + "1.2.2": + folder: all diff --git a/recipes/artery-font-format/all/conandata.yml b/recipes/artery-font-format/all/conandata.yml new file mode 100644 index 0000000000000..b248576ab34a5 --- /dev/null +++ b/recipes/artery-font-format/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.0.1": + url: "https://github.com/Chlumsky/artery-font-format/archive/v1.0.1.tar.gz" + sha256: "23dc9450d2364c9f1a67fcb0ae8f2bef365fabc5a3f4af55d9a646f8fbcdc537" + "1.0": + url: "https://github.com/Chlumsky/artery-font-format/archive/refs/tags/v1.0.tar.gz" + sha256: "311172C09E6B74574C93C382EBB92212FFC1710DFCF04FC25376A575DFE16DA8" diff --git a/recipes/artery-font-format/all/conanfile.py b/recipes/artery-font-format/all/conanfile.py new file mode 100644 index 0000000000000..a477d0ff0e98a --- /dev/null +++ b/recipes/artery-font-format/all/conanfile.py @@ -0,0 +1,27 @@ +from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.33.0" + + +class ArteryFontFormatConan(ConanFile): + name = "artery-font-format" + license = "MIT" + homepage = "https://github.com/Chlumsky/artery-font-format" + url = "https://github.com/conan-io/conan-center-index" + description = "Artery Atlas Font format library" + topics = ("artery", "font", "atlas") + + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses") + self.copy("*.h", src=self._source_subfolder, dst="include") + self.copy("*.hpp", src=self._source_subfolder, dst="include") diff --git a/recipes/artery-font-format/all/test_package/CMakeLists.txt b/recipes/artery-font-format/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..454c47bb2cbab --- /dev/null +++ b/recipes/artery-font-format/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/artery-font-format/all/test_package/conanfile.py b/recipes/artery-font-format/all/test_package/conanfile.py new file mode 100644 index 0000000000000..c53028872776c --- /dev/null +++ b/recipes/artery-font-format/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "arch", "build_type" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + arfont = os.path.join(self.source_folder, "example.arfont") + self.run("{} {}".format(bin_path, arfont), run_environment=True) diff --git a/recipes/artery-font-format/all/test_package/example.arfont b/recipes/artery-font-format/all/test_package/example.arfont new file mode 100644 index 0000000000000..a1530434762b6 Binary files /dev/null and b/recipes/artery-font-format/all/test_package/example.arfont differ diff --git a/recipes/artery-font-format/all/test_package/test_package.cpp b/recipes/artery-font-format/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..8e85c6f96e501 --- /dev/null +++ b/recipes/artery-font-format/all/test_package/test_package.cpp @@ -0,0 +1,32 @@ +#include +#include +#include + +#include +#include + +int main(int argc, char *argv[]) { + if (argc < 2) { + std::cerr << "usage: test_package \n"; + return EXIT_FAILURE; + } + + FILE *const font_file = fopen(argv[1], "rb"); + if (font_file == nullptr) { + std::cerr << "couldn't open font file" << std::endl; + return EXIT_FAILURE; + } + + artery_font::StdArteryFont font; + if (!artery_font::read(font, font_file)) { + std::cerr << "couldn't read artery font" << std::endl; + return EXIT_FAILURE; + } + + if (fclose(font_file) != 0) { + std::cerr << "an error occured when closing font file" << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/recipes/artery-font-format/config.yml b/recipes/artery-font-format/config.yml new file mode 100644 index 0000000000000..7b06dd8bf61ea --- /dev/null +++ b/recipes/artery-font-format/config.yml @@ -0,0 +1,5 @@ +versions: + "1.0.1": + folder: all + "1.0": + folder: all diff --git a/recipes/aruco/3.x.x/CMakeLists.txt b/recipes/aruco/3.x.x/CMakeLists.txt index c986d294c7547..61f3d3b039e2b 100644 --- a/recipes/aruco/3.x.x/CMakeLists.txt +++ b/recipes/aruco/3.x.x/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory("source_subfolder") diff --git a/recipes/aruco/3.x.x/conandata.yml b/recipes/aruco/3.x.x/conandata.yml index 66050874711be..eb3415158ea14 100644 --- a/recipes/aruco/3.x.x/conandata.yml +++ b/recipes/aruco/3.x.x/conandata.yml @@ -1,4 +1,4 @@ sources: - 3.1.12: - url: https://downloads.sourceforge.net/project/aruco/3.1.12/aruco-3.1.12.zip - sha256: 70b9ec8aa8eac6fe3f622201747a3e32c77bbb5f015e28a95c1c7c91f8ee8a09 + "3.1.12": + url: "https://downloads.sourceforge.net/project/aruco/3.1.12/aruco-3.1.12.zip" + sha256: "70b9ec8aa8eac6fe3f622201747a3e32c77bbb5f015e28a95c1c7c91f8ee8a09" diff --git a/recipes/aruco/3.x.x/conanfile.py b/recipes/aruco/3.x.x/conanfile.py index 0e3c6451cd5f1..22aa76a34e69a 100644 --- a/recipes/aruco/3.x.x/conanfile.py +++ b/recipes/aruco/3.x.x/conanfile.py @@ -1,21 +1,30 @@ from conans import ConanFile, tools, CMake +import functools import os +required_conan_version = ">=1.36.0" -class LibnameConan(ConanFile): + +class ArucoConan(ConanFile): name = "aruco" description = "Augmented reality library based on OpenCV " - topics = ("conan", "aruco", "augmented reality") + topics = ("aruco", "augmented reality") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.uco.es/investiga/grupos/ava/node/26" license = "GPL-3.0-only" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [False, True], + "fPIC": [False, True], + } + default_options = { + "shared": False, + "fPIC": True, + } + exports_sources = "CMakeLists.txt" generators = "cmake", "cmake_find_package" - _cmake = None - - settings = "os", "compiler", "arch", "build_type" - options = {"shared": [False, True], "fPIC": [False, True]} - default_options = {"shared": False, "fPIC": True} @property def _source_subfolder(self): @@ -34,47 +43,39 @@ def configure(self): del self.options.fPIC def requirements(self): - self.requires("opencv/4.5.1") - self.requires("eigen/3.3.9") - self.requires("zlib/1.2.11") + self.requires("opencv/4.5.5") + self.requires("eigen/3.4.0") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ARUCO_DEVINSTALL"] = "ON" - self._cmake.definitions["BUILD_TESTS"] = "OFF" - self._cmake.definitions["BUILD_GLSAMPLES"] = "OFF" - self._cmake.definitions["BUILD_UTILS"] = "OFF" - self._cmake.definitions["BUILD_DEBPACKAGE"] = "OFF" - self._cmake.definitions["BUILD_SVM"] = "OFF" - self._cmake.definitions["INSTALL_DOC"] = "OFF" - self._cmake.definitions["USE_OWN_EIGEN3"] = "OFF" - self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + cmake = CMake(self) + cmake.definitions["ARUCO_DEVINSTALL"] = True + cmake.definitions["BUILD_TESTS"] = False + cmake.definitions["BUILD_GLSAMPLES"] = False + cmake.definitions["BUILD_UTILS"] = False + cmake.definitions["BUILD_DEBPACKAGE"] = False + cmake.definitions["BUILD_SVM"] = False + cmake.definitions["INSTALL_DOC"] = False + cmake.definitions["USE_OWN_EIGEN3"] = False + cmake.configure(build_folder=self._build_subfolder) + return cmake def build(self): cmake = self._configure_cmake() cmake.build() def package(self): - self.copy( - pattern="LICENSE", dst="licenses", src=self._source_subfolder - ) - + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) tools.rmdir(os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.includedirs.append("include") + self.cpp_info.set_property("pkg_config_name", "aruco") self.cpp_info.includedirs.append(os.path.join("include", "aruco")) self.cpp_info.libs = tools.collect_libs(self) - self.cpp_info.names["pkg_config"] = "aruco" diff --git a/recipes/aruco/3.x.x/test_package/CMakeLists.txt b/recipes/aruco/3.x.x/test_package/CMakeLists.txt index b3b3eeacb64ce..d8da2bf5ad2d6 100644 --- a/recipes/aruco/3.x.x/test_package/CMakeLists.txt +++ b/recipes/aruco/3.x.x/test_package/CMakeLists.txt @@ -1,12 +1,11 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package) -set(CMAKE_CXX_STANDARD 11) - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -find_package(aruco REQUIRED) +find_package(aruco REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} aruco::aruco) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/aruco/3.x.x/test_package/conanfile.py b/recipes/aruco/3.x.x/test_package/conanfile.py index 4461da7f8e420..38f4483872d47 100644 --- a/recipes/aruco/3.x.x/test_package/conanfile.py +++ b/recipes/aruco/3.x.x/test_package/conanfile.py @@ -3,10 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" - - settings = "os", "compiler", "arch", "build_type" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -14,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/aruco/config.yml b/recipes/aruco/config.yml index 3f8f41444b1ab..243128b45c736 100644 --- a/recipes/aruco/config.yml +++ b/recipes/aruco/config.yml @@ -1,3 +1,3 @@ versions: - 3.1.12: + "3.1.12": folder: 3.x.x diff --git a/recipes/asio-grpc/all/conandata.yml b/recipes/asio-grpc/all/conandata.yml new file mode 100644 index 0000000000000..d44cb9f84670e --- /dev/null +++ b/recipes/asio-grpc/all/conandata.yml @@ -0,0 +1,16 @@ +sources: + "2.3.0": + url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v2.3.0.tar.gz" + sha256: "eb48e72c98d45d9251fe1cbdca3a72a4d67435a7020357cd33ff717cc5851c01" + "2.2.0": + url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v2.2.0.tar.gz" + sha256: "a820e48681bc66834f7e6dbc326e245416f4ef009769f45826b3d09079afad4c" + "2.1.0": + url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v2.1.0.tar.gz" + sha256: "51da699eb442db3ec3af1caae5a29d78733ebbd9d1b781f75abe6ce2802fc7c1" + "2.0.0": + url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v2.0.0.tar.gz" + sha256: "e36ab4f286dccfd6589b8001d6560e994c753539738680588264c1c0e0a6ce4f" + "1.7.0": + url: "https://github.com/Tradias/asio-grpc/archive/refs/tags/v1.7.0.tar.gz" + sha256: "1b2a3c832c72d1f3be90c9665731fc6076a970d6249723a49ea12dbe2b0749ea" diff --git a/recipes/asio-grpc/all/conanfile.py b/recipes/asio-grpc/all/conanfile.py new file mode 100644 index 0000000000000..d5f2c6fe82df8 --- /dev/null +++ b/recipes/asio-grpc/all/conanfile.py @@ -0,0 +1,118 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rm +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.0" + + +class AsioGrpcConan(ConanFile): + name = "asio-grpc" + description = ("Asynchronous gRPC with Asio/unified executors") + homepage = "https://github.com/Tradias/asio-grpc" + url = "https://github.com/conan-io/conan-center-index" + license = "Apache-2.0" + topics = ("cpp", "asynchronous", "grpc", "asio", "asynchronous-programming", "cpp17", "coroutine", "cpp20", "executors") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + options = { + "backend": ["boost", "asio", "unifex"], + "use_boost_container": ["auto", True, False], + } + default_options = { + "backend": "boost", + "use_boost_container": "auto", + } + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "15.7", + "clang": "6", + "apple-clang": "11", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version: + if Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.name} requires C++{self._min_cppstd}, which your compiler does not support.") + else: + self.output.warn(f"{self.name} requires C++{self._min_cppstd}. Your compiler is unknown. Assuming it supports C++{self._min_cppstd}.") + + def configure(self): + if self.options.use_boost_container == "auto": + libcxx = self.settings.compiler.get_safe("libcxx") + compiler_version = Version(self.settings.compiler.version) + self.options.use_boost_container = libcxx and str(libcxx) == "libc++" or \ + (self.settings.compiler == "gcc" and compiler_version < "9") or \ + (self.settings.compiler == "clang" and compiler_version < "12" and libcxx and str(libcxx) == "libstdc++") + + def requirements(self): + self.requires("grpc/1.50.0") + if self.options.use_boost_container or self.options.backend == "boost": + self.requires("boost/1.80.0") + if self.options.backend == "asio": + self.requires("asio/1.24.0") + if self.options.backend == "unifex": + self.requires("libunifex/cci.20220430") + + def package_id(self): + self.info.clear() + self.info.options.use_boost_container = self.options.use_boost_container + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ASIO_GRPC_USE_BOOST_CONTAINER"] = self.options.use_boost_container + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rm(self, "asio-grpc*", os.path.join(self.package_folder, "lib", "cmake", "asio-grpc")) + + def package_info(self): + build_modules = [os.path.join("lib", "cmake", "asio-grpc", "AsioGrpcProtobufGenerator.cmake")] + + self.cpp_info.requires = ["grpc::grpc++_unsecure"] + if self.options.backend == "boost": + self.cpp_info.defines = ["AGRPC_BOOST_ASIO"] + self.cpp_info.requires.append("boost::headers") + if self.options.backend == "asio": + self.cpp_info.defines = ["AGRPC_STANDALONE_ASIO"] + self.cpp_info.requires.append("asio::asio") + if self.options.backend == "unifex": + self.cpp_info.defines = ["AGRPC_UNIFEX"] + self.cpp_info.requires.append("libunifex::unifex") + + if self.options.use_boost_container: + self.cpp_info.requires.append("boost::container") + + self.cpp_info.set_property("cmake_file_name", "asio-grpc") + self.cpp_info.set_property("cmake_target_name", "asio-grpc::asio-grpc") + self.cpp_info.set_property("cmake_build_modules", build_modules) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.build_modules["cmake_find_package"] = build_modules + self.cpp_info.build_modules["cmake_find_package_multi"] = build_modules diff --git a/recipes/asio-grpc/all/test_package/CMakeLists.txt b/recipes/asio-grpc/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3566d527f1ca9 --- /dev/null +++ b/recipes/asio-grpc/all/test_package/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.14) +project(test_package LANGUAGES CXX) + +find_package(asio-grpc REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE asio-grpc::asio-grpc) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) + +# See https://github.com/chriskohlhoff/asio/issues/955 +target_compile_definitions(${PROJECT_NAME} + PRIVATE BOOST_ASIO_DISABLE_STD_ALIGNED_ALLOC) + +if(${asio-grpc_VERSION} VERSION_GREATER_EQUAL 2) + target_compile_definitions(${PROJECT_NAME} PRIVATE ASIO_GRPC_V2) +endif() + +if(CMAKE_CROSSCOMPILING) + # Assuming protoc plugins needed by `asio_grpc_protobuf_generate` are not + # available when cross compiling + target_compile_definitions(${PROJECT_NAME} PRIVATE CROSSCOMPILING) +else() + asio_grpc_protobuf_generate( + GENERATE_GRPC + TARGET + ${PROJECT_NAME} + OUT_DIR + "${CMAKE_CURRENT_BINARY_DIR}/generated" + PROTOS + "${CMAKE_CURRENT_LIST_DIR}/test.proto") +endif() diff --git a/recipes/asio-grpc/all/test_package/conanfile.py b/recipes/asio-grpc/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/asio-grpc/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/asio-grpc/all/test_package/test.proto b/recipes/asio-grpc/all/test_package/test.proto new file mode 100644 index 0000000000000..2434126edc5aa --- /dev/null +++ b/recipes/asio-grpc/all/test_package/test.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package test; + +service Test { + rpc Unary(TestRequest) returns (TestReply) {} +} + +message TestRequest { string message = 1; } + +message TestReply { string message = 1; } diff --git a/recipes/asio-grpc/all/test_package/test_package.cpp b/recipes/asio-grpc/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..b784be03686dc --- /dev/null +++ b/recipes/asio-grpc/all/test_package/test_package.cpp @@ -0,0 +1,36 @@ +#ifdef ASIO_GRPC_V2 +#include +#else +#include +#endif +#include + +#ifndef CROSSCOMPILING +#include +#include +#endif + +int main() { + agrpc::GrpcContext grpc_context{std::make_unique()}; + + boost::asio::post(grpc_context, [] {}); + +#ifndef CROSSCOMPILING + std::unique_ptr stub; + grpc::ClientContext client_context; + std::unique_ptr> reader; + test::TestRequest request; + test::TestReply response; + grpc::Status status; + + boost::asio::post(grpc_context, [&]() { + stub = test::Test::NewStub(grpc::CreateChannel( + "localhost:50051", grpc::InsecureChannelCredentials())); + request.set_message("hello"); + reader = agrpc::request(&test::Test::Stub::AsyncUnary, *stub, + client_context, request, grpc_context); + agrpc::finish(reader, response, status, + boost::asio::bind_executor(grpc_context, [](bool) {})); + }); +#endif +} diff --git a/recipes/asio-grpc/all/test_v1_package/CMakeLists.txt b/recipes/asio-grpc/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e68b2def0d618 --- /dev/null +++ b/recipes/asio-grpc/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.14) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(asio-grpc REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE asio-grpc::asio-grpc) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) + +# See https://github.com/chriskohlhoff/asio/issues/955 +target_compile_definitions(${PROJECT_NAME} + PRIVATE BOOST_ASIO_DISABLE_STD_ALIGNED_ALLOC) + +if(${asio-grpc_VERSION} VERSION_GREATER_EQUAL 2) + target_compile_definitions(${PROJECT_NAME} PRIVATE ASIO_GRPC_V2) +endif() + +if(CMAKE_CROSSCOMPILING) + # Assuming protoc plugins needed by `asio_grpc_protobuf_generate` are not + # available when cross compiling + target_compile_definitions(${PROJECT_NAME} PRIVATE CROSSCOMPILING) +else() + asio_grpc_protobuf_generate( + GENERATE_GRPC + TARGET + ${PROJECT_NAME} + OUT_DIR + "${CMAKE_CURRENT_BINARY_DIR}/generated" + PROTOS + "${CMAKE_CURRENT_LIST_DIR}/../test_package/test.proto") +endif() diff --git a/recipes/asio-grpc/all/test_v1_package/conanfile.py b/recipes/asio-grpc/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2da76eac8dd35 --- /dev/null +++ b/recipes/asio-grpc/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/asio-grpc/config.yml b/recipes/asio-grpc/config.yml new file mode 100644 index 0000000000000..9c1d421048692 --- /dev/null +++ b/recipes/asio-grpc/config.yml @@ -0,0 +1,11 @@ +versions: + "2.3.0": + folder: all + "2.2.0": + folder: all + "2.1.0": + folder: all + "2.0.0": + folder: all + "1.7.0": + folder: all diff --git a/recipes/asio/all/conandata.yml b/recipes/asio/all/conandata.yml index 8ba782c395a2d..7fac1b2c26c22 100644 --- a/recipes/asio/all/conandata.yml +++ b/recipes/asio/all/conandata.yml @@ -1,4 +1,34 @@ sources: + "1.24.0": + url: "https://github.com/chriskohlhoff/asio/archive/asio-1-24-0.tar.gz" + sha256: "cbcaaba0f66722787b1a7c33afe1befb3a012b5af3ad7da7ff0f6b8c9b7a8a5b" + "1.23.0": + url: "https://github.com/chriskohlhoff/asio/archive/asio-1-23-0.tar.gz" + sha256: "facae7627ce6c716add3f328eee3d78c2e6e133a46ac5ecb80897b37ebacf05e" + "1.22.1": + url: "https://github.com/chriskohlhoff/asio/archive/asio-1-22-1.tar.gz" + sha256: "30cb54a5de5e465d10ec0c2026d6b5917f5e89fffabdbabeb1475846fc9a2cf0" + "1.22.0": + url: "https://github.com/chriskohlhoff/asio/archive/asio-1-22-0.tar.gz" + sha256: "17bfd506f6d55c85a33603277a256b42ca5883bf290930040489ffeeed23724a" + "1.21.0": + url: "https://github.com/chriskohlhoff/asio/archive/asio-1-21-0.tar.gz" + sha256: "5d2d2dcb7bfb39bff941cabbfc8c27ee322a495470bf0f3a7c5238648cf5e6a9" + "1.20.0": + url: "https://github.com/chriskohlhoff/asio/archive/asio-1-20-0.tar.gz" + sha256: "34a8f07be6f54e3753874d46ecfa9b7ab7051c4e3f67103c52a33dfddaea48e6" + "1.19.2": + url: "https://github.com/chriskohlhoff/asio/archive/asio-1-19-2.tar.gz" + sha256: "5ee191aee825dfb1325cbacf643d599b186de057c88464ea98f1bae5ba4ff47a" + "1.19.1": + url: "https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-19-1.tar.gz" + sha256: "2555e0a29256de5c77d6a34b14faefd28c76555e094ba0371acb0b91d483520e" + "1.19.0": + url: "https://github.com/chriskohlhoff/asio/archive/asio-1-19-0.tar.gz" + sha256: "11bc0e22fcdfb3f0b77574ac33760a3592c0dac7e7eece7668b823c158243629" + "1.18.2": + url: "https://github.com/chriskohlhoff/asio/archive/asio-1-18-2.tar.gz" + sha256: "8d67133b89e0f8b212e9f82fdcf1c7b21a978d453811e2cd941c680e72c2ca32" "1.18.1": url: "https://github.com/chriskohlhoff/asio/archive/asio-1-18-1.tar.gz" sha256: "39c721b987b7a0d2fe2aee64310bd128cd8cc10f43481604d18cb2d8b342fd40" diff --git a/recipes/asio/all/conanfile.py b/recipes/asio/all/conanfile.py index 751e555beb803..b96eb6fa96e4a 100644 --- a/recipes/asio/all/conanfile.py +++ b/recipes/asio/all/conanfile.py @@ -1,5 +1,9 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools + +required_conan_version = ">=1.50.0" class Asio(ConanFile): @@ -7,32 +11,37 @@ class Asio(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "http://think-async.com/Asio" description = "Asio is a cross-platform C++ library for network and low-level I/O" - topics = ("conan", "asio", "network", "io", "low-level") - settings = "os" + topics = ("asio", "network", "io", "low-level") license = "BSL-1.0" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - archive_name = "asio-" + self.version.replace(".", "-") - extracted_name = "asio-" + archive_name - os.rename(extracted_name, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - root_dir = os.path.join(self._source_subfolder, self.name) + root_dir = os.path.join(self.source_folder, "asio") include_dir = os.path.join(root_dir, "include") - self.copy(pattern="LICENSE_1_0.txt", dst="licenses", src=root_dir) - self.copy(pattern="*.hpp", dst="include", src=include_dir) - self.copy(pattern="*.ipp", dst="include", src=include_dir) + copy(self, "LICENSE_1_0.txt", src=root_dir, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", src=include_dir, dst=os.path.join(self.package_folder, "include")) + copy(self, "*.ipp", src=include_dir, dst=os.path.join(self.package_folder, "include")) def package_info(self): - self.cpp_info.defines.append('ASIO_STANDALONE') - if str(self.settings.os) in ["Linux"]: - self.cpp_info.system_libs.append('pthread') - - def package_id(self): - self.info.header_only() + self.cpp_info.set_property("pkg_config_name", "asio") + self.cpp_info.defines.append("ASIO_STANDALONE") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/asio/all/test_package/CMakeLists.txt b/recipes/asio/all/test_package/CMakeLists.txt index 454c47bb2cbab..c41c5729ae0a5 100644 --- a/recipes/asio/all/test_package/CMakeLists.txt +++ b/recipes/asio/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(asio REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE asio::asio) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/asio/all/test_package/conanfile.py b/recipes/asio/all/test_package/conanfile.py index be0a94674e5bd..d120a992c06a6 100644 --- a/recipes/asio/all/test_package/conanfile.py +++ b/recipes/asio/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +20,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/asio/all/test_v1_package/CMakeLists.txt b/recipes/asio/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0308114c0432b --- /dev/null +++ b/recipes/asio/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(asio REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE asio::asio) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/asio/all/test_v1_package/conanfile.py b/recipes/asio/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/asio/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/asio/config.yml b/recipes/asio/config.yml index e901e81ed985d..bc4dfc6aa34d4 100644 --- a/recipes/asio/config.yml +++ b/recipes/asio/config.yml @@ -1,4 +1,24 @@ versions: + "1.24.0": + folder: all + "1.23.0": + folder: all + "1.22.1": + folder: all + "1.22.0": + folder: all + "1.21.0": + folder: all + "1.20.0": + folder: all + "1.19.2": + folder: all + "1.19.1": + folder: all + "1.19.0": + folder: all + "1.18.2": + folder: all "1.18.1": folder: all "1.18.0": diff --git a/recipes/asmjit/all/conandata.yml b/recipes/asmjit/all/conandata.yml index d98201812e740..a7cfd40faef87 100644 --- a/recipes/asmjit/all/conandata.yml +++ b/recipes/asmjit/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "cci.20221111": + url: "https://github.com/asmjit/asmjit/archive/0c03ed2f7497441ac0de232bda2e6b8cc041b2dc.zip" + sha256: "85d8f3edabd708658b63d8a9bc2e7ccb72edd1d14b668fa681b5f7fa529601a4" + "cci.20220210": + url: "https://github.com/asmjit/asmjit/archive/23ddf56b00f47d8aa0c82ad225e4b3a92661da7e.zip" + sha256: "8832003526dbb9329b308246ffe34ebda9dcbe9b5116d7c3fbbe7ab15e5fd7b3" "cci.20210306": url: "https://github.com/asmjit/asmjit/archive/8b35b4cffb62ecb58a903bf91cb7537d7a672211.zip" sha256: "3404db651051d48f31d0638c75346284929114e7038ac89353345db595f9e154" diff --git a/recipes/asmjit/all/conanfile.py b/recipes/asmjit/all/conanfile.py index bbcf66316f93d..7b366fceb161a 100644 --- a/recipes/asmjit/all/conanfile.py +++ b/recipes/asmjit/all/conanfile.py @@ -1,14 +1,18 @@ -from conans import ConanFile, CMake, tools -import glob +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir import os +required_conan_version = ">=1.53.0" + class AsmjitConan(ConanFile): name = "asmjit" description = "AsmJit is a lightweight library for machine code " \ "generation written in C++ language." license = "Zlib" - topics = ("conan", "asmjit", "compiler", "assembler", "jit") + topics = ("asmjit", "compiler", "assembler", "jit") homepage = "https://asmjit.com" url = "https://github.com/conan-io/conan-center-index" @@ -22,56 +26,55 @@ class AsmjitConan(ConanFile): "fPIC": True, } - exports_sources = "CMakeLists.txt" - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): if self.options.shared: - del self.options.fPIC - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) + self.options.rm_safe("fPIC") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("asmjit-*")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ASMJIT_EMBED"] = False - self._cmake.definitions["ASMJIT_STATIC"] = not self.options.shared - self._cmake.definitions["ASMJIT_BUILD_X86"] = False - self._cmake.definitions["ASMJIT_TEST"] = False - self._cmake.definitions["ASMJIT_NO_NATVIS"] = True - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ASMJIT_EMBED"] = False + tc.variables["ASMJIT_STATIC"] = not self.options.shared + if self.version == "cci.20210306": + tc.variables["ASMJIT_BUILD_X86"] = self.settings.arch in ["x86", "x86_64"] + tc.variables["ASMJIT_TEST"] = False + tc.variables["ASMJIT_NO_NATVIS"] = True + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "asmjit") + self.cpp_info.set_property("cmake_target_name", "asmjit::asmjit") + self.cpp_info.names["cmake_find_package"] = "asmjit" self.cpp_info.names["cmake_find_package_multi"] = "asmjit" + self.cpp_info.libs = ["asmjit"] if not self.options.shared: self.cpp_info.defines = ["ASMJIT_STATIC"] if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.system_libs = ["pthread", "rt"] + self.cpp_info.system_libs = ["pthread", "rt", "m"] diff --git a/recipes/asmjit/all/test_package/CMakeLists.txt b/recipes/asmjit/all/test_package/CMakeLists.txt index 7889b0d8e0e53..39640d23a5929 100644 --- a/recipes/asmjit/all/test_package/CMakeLists.txt +++ b/recipes/asmjit/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(asmjit REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} asmjit::asmjit) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE asmjit::asmjit) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/asmjit/all/test_package/conanfile.py b/recipes/asmjit/all/test_package/conanfile.py index a9f777f7680ff..3a8c6c5442b33 100644 --- a/recipes/asmjit/all/test_package/conanfile.py +++ b/recipes/asmjit/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/asmjit/all/test_v1_package/CMakeLists.txt b/recipes/asmjit/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9d54a092e0a67 --- /dev/null +++ b/recipes/asmjit/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/asmjit/all/test_v1_package/conanfile.py b/recipes/asmjit/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/asmjit/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/asmjit/config.yml b/recipes/asmjit/config.yml index 25e5f817ad32b..aaa7d13798678 100644 --- a/recipes/asmjit/config.yml +++ b/recipes/asmjit/config.yml @@ -1,3 +1,7 @@ versions: + "cci.20221111": + folder: all + "cci.20220210": + folder: all "cci.20210306": folder: all diff --git a/recipes/asn1c/all/conandata.yml b/recipes/asn1c/all/conandata.yml new file mode 100644 index 0000000000000..03e3e0e44b689 --- /dev/null +++ b/recipes/asn1c/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.9.28": + url: "https://github.com/vlm/asn1c/releases/download/v0.9.28/asn1c-0.9.28.tar.gz" + sha256: "8007440b647ef2dd9fb73d931c33ac11764e6afb2437dbe638bb4e5fc82386b9" diff --git a/recipes/asn1c/all/conanfile.py b/recipes/asn1c/all/conanfile.py new file mode 100644 index 0000000000000..83429575a7f31 --- /dev/null +++ b/recipes/asn1c/all/conanfile.py @@ -0,0 +1,82 @@ +from conans import AutoToolsBuildEnvironment, tools +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, rmdir, chdir +import os + +required_conan_version = ">=1.47.0" + + +class Asn1cConan(ConanFile): + name = "asn1c" + description = "The ASN.1 Compiler" + license = "BSD-2-Clause" + topics = ("asn.1", "compiler") + homepage = "https://lionet.info/asn1c" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _datarootdir(self): + return os.path.join(self.package_folder, "res") + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def build_requirements(self): + self.tool_requires("bison/3.7.6") + self.tool_requires("flex/2.6.4") + self.tool_requires("libtool/2.4.7") + + def validate(self): + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("Visual Studio is not supported") + + def package_id(self): + del self.info.settings.compiler + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + conf_args = [ + "--datarootdir={}".format(tools.unix_path(self._datarootdir)), + ] + self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + with chdir(self, self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + autotools = self._configure_autotools() + autotools.install() + rmdir(self, os.path.join(self.package_folder, "res", "doc")) + rmdir(self, os.path.join(self.package_folder, "res", "man")) + + def package_info(self): + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + + # asn1c cannot use environment variables to specify support files path + # so `SUPPORT_PATH` should be propagated to command line invocation to `-S` argument + self.env_info.SUPPORT_PATH = os.path.join(self.package_folder, "res/asn1c") + + self.cpp_info.includedirs = [] diff --git a/recipes/asn1c/all/test_package/CMakeLists.txt b/recipes/asn1c/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..72f86ddd2bed5 --- /dev/null +++ b/recipes/asn1c/all/test_package/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +set(STANDARD_ASN1_FILES + BIT_STRING.c + INTEGER.c + NativeEnumerated.c + NativeInteger.c + OBJECT_IDENTIFIER.c + OCTET_STRING.c + asn_SEQUENCE_OF.c + asn_SET_OF.c + asn_codecs_prim.c + ber_decoder.c + ber_tlv_length.c + ber_tlv_tag.c + constr_SEQUENCE.c + constr_SEQUENCE_OF.c + constr_SET_OF.c + constr_TYPE.c + constraints.c + der_encoder.c + per_decoder.c + per_encoder.c + per_opentype.c + per_support.c + xer_decoder.c + xer_encoder.c + xer_support.c +) + +set(GENERATED_FILES + MyTypes.c + MyInt.c +) + +add_custom_command( + OUTPUT ${GENERATED_FILES} ${STANDARD_ASN1_FILES} + COMMAND asn1c -S ${SUPPORT_PATH} MyModule.asn1 + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS MyModule.asn1 +) + +add_executable(${PROJECT_NAME} test_package.c ${GENERATED_FILES} ${STANDARD_ASN1_FILES}) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/recipes/asn1c/all/test_package/MyModule.asn1 b/recipes/asn1c/all/test_package/MyModule.asn1 new file mode 100644 index 0000000000000..3b9e5e66ecddb --- /dev/null +++ b/recipes/asn1c/all/test_package/MyModule.asn1 @@ -0,0 +1,15 @@ +MyModule DEFINITIONS ::= +BEGIN + +MyTypes ::= SEQUENCE { + myObjectId OBJECT IDENTIFIER, + mySeqOf SEQUENCE OF MyInt, + myBitString BIT STRING { + muxToken(0), + modemToken(1) + } +} + +MyInt ::= INTEGER (0..65535) + +END diff --git a/recipes/asn1c/all/test_package/conanfile.py b/recipes/asn1c/all/test_package/conanfile.py new file mode 100644 index 0000000000000..534923606ca41 --- /dev/null +++ b/recipes/asn1c/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conans import CMake +from conan import ConanFile +from conan.tools.files import copy +from conan.tools.build import cross_building +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + generators = "cmake" + + def build_requirements(self): + self.tool_requires(str(self.requires["asn1c"])) + + def build(self): + if not cross_building(self): + copy(self, "MyModule.asn1", src=self.source_folder, dst=self.build_folder) + cmake = CMake(self) + cmake.definitions["SUPPORT_PATH"] = self.deps_env_info["asn1c"].SUPPORT_PATH + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/asn1c/all/test_package/test_package.c b/recipes/asn1c/all/test_package/test_package.c new file mode 100644 index 0000000000000..d85fa83f55cd1 --- /dev/null +++ b/recipes/asn1c/all/test_package/test_package.c @@ -0,0 +1,73 @@ +#include /* for stdout */ +#include /* for malloc() */ +#include /* for run-time control */ +#include "MyTypes.h" /* Include MyTypes definition */ + +int main() { + /* Define an OBJECT IDENTIFIER value */ + int oid[] = { 1, 3, 6, 1, 4, 1, 9363, 1, 5, 0 }; /* or whatever */ + + /* Declare a pointer to a new instance of MyTypes type */ + MyTypes_t *myType; + /* Declare a pointer to a MyInt type */ + MyInt_t *myInt; + + /* Temporary return value */ + int ret; + + /* Allocate an instance of MyTypes */ + myType = calloc(1, sizeof *myType); + assert(myType); /* Assume infinite memory */ + + /* + * Fill in myObjectId + */ + ret = OBJECT_IDENTIFIER_set_arcs(&myType->myObjectId, + oid, sizeof(oid[0]), sizeof(oid) / sizeof(oid[0])); + assert(ret == 0); + + /* + * Fill in mySeqOf with a couple of integers. + */ + + /* Prepare a certain INTEGER */ + myInt = calloc(1, sizeof *myInt); + assert(myInt); + *myInt = 123; /* Set integer value */ + + /* Fill in mySeqOf with the prepared INTEGER */ + ret = ASN_SEQUENCE_ADD(&myType->mySeqOf, myInt); + assert(ret == 0); + + /* Prepare another integer */ + myInt = calloc(1, sizeof *myInt); + assert(myInt); + *myInt = 111222333; /* Set integer value */ + + /* Append another INTEGER into mySeqOf */ + ret = ASN_SEQUENCE_ADD(&myType->mySeqOf, myInt); + assert(ret == 0); + + /* + * Fill in myBitString + */ + + /* Allocate some space for bitmask */ + myType->myBitString.buf = calloc(1, 1); + assert(myType->myBitString.buf); + myType->myBitString.size = 1; /* 1 byte */ + + /* Set the value of muxToken */ + myType->myBitString.buf[0] |= 1 << (7 - myBitString_muxToken); + + /* Also set the value of modemToken */ + myType->myBitString.buf[0] |= 1 << (7 - myBitString_modemToken); + + /* Trim unused bits (optional) */ + myType->myBitString.bits_unused = 6; + + /* + * Print the resulting structure as XER (XML) + */ + return xer_fprint(stdout, &asn_DEF_MyTypes, myType); +} diff --git a/recipes/asn1c/config.yml b/recipes/asn1c/config.yml new file mode 100644 index 0000000000000..0008d426a65e5 --- /dev/null +++ b/recipes/asn1c/config.yml @@ -0,0 +1,3 @@ +versions: + "0.9.28": + folder: all diff --git a/recipes/assimp/5.0.x/conandata.yml b/recipes/assimp/5.0.x/conandata.yml deleted file mode 100644 index 65ce7608da613..0000000000000 --- a/recipes/assimp/5.0.x/conandata.yml +++ /dev/null @@ -1,7 +0,0 @@ -sources: - "5.0.0": - sha256: 0c81f2d6c2b18272c98727e21846a9a8a203b15e8957c2ff7a6e76a1c52af2d3 - url: https://github.com/assimp/assimp/archive/v5.0.0.zip - "5.0.1": - sha256: d10542c95e3e05dece4d97bb273eba2dfeeedb37a78fb3417fd4d5e94d879192 - url: https://github.com/assimp/assimp/archive/v5.0.1.zip diff --git a/recipes/assimp/5.0.x/conanfile.py b/recipes/assimp/5.0.x/conanfile.py deleted file mode 100644 index 2b7a011fd3ce7..0000000000000 --- a/recipes/assimp/5.0.x/conanfile.py +++ /dev/null @@ -1,162 +0,0 @@ -import os -from conans import ConanFile, CMake, tools - - -class Assimp(ConanFile): - name = "assimp" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/assimp/assimp" - description = "A library to import and export various 3d-model-formats including scene-post-processing to generate missing render data." - topics = ("conan", "assimp", "3d") - license = "BSD-3-Clause" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" - settings = "os", "compiler", "build_type", "arch" - options = { - "shared": [True, False], - "double_precision": [True, False], - "fPIC": [True, False], - } - default_options = { - "shared": False, - "double_precision": False, - "fPIC": True, - } - - _format_option_map = { - "with_3d": "ASSIMP_BUILD_3D_IMPORTER", - "with_3ds": "ASSIMP_BUILD_3DS_IMPORTER", - "with_3ds_exporter": "ASSIMP_BUILD_3DS_EXPORTER", - "with_3mf": "ASSIMP_BUILD_3MF_IMPORTER", - "with_3mf_exporter": "ASSIMP_BUILD_3MF_EXPORTER", - "with_ac": "ASSIMP_BUILD_AC_IMPORTER", - "with_amf": "ASSIMP_BUILD_AMF_IMPORTER", - "with_ase": "ASSIMP_BUILD_ASE_IMPORTER", - "with_assbin": "ASSIMP_BUILD_ASSBIN_IMPORTER", - "with_assbin_exporter": "ASSIMP_BUILD_ASSBIN_EXPORTER", - "with_assxml_exporter": "ASSIMP_BUILD_ASSXML_EXPORTER", - "with_assjson_exporter": "ASSIMP_BUILD_ASSJSON_EXPORTER", - "with_b3d": "ASSIMP_BUILD_B3D_IMPORTER", - "with_blend": "ASSIMP_BUILD_BLEND_IMPORTER", - "with_bvh": "ASSIMP_BUILD_BVH_IMPORTER", - "with_ms3d": "ASSIMP_BUILD_MS3D_IMPORTER", - "with_cob": "ASSIMP_BUILD_COB_IMPORTER", - "with_collada": "ASSIMP_BUILD_COLLADA_IMPORTER", - "with_collada_exporter": "ASSIMP_BUILD_COLLADA_EXPORTER", - "with_csm": "ASSIMP_BUILD_CSM_IMPORTER", - "with_dxf": "ASSIMP_BUILD_DXF_IMPORTER", - "with_fbx": "ASSIMP_BUILD_FBX_IMPORTER", - "with_fbx_exporter": "ASSIMP_BUILD_FBX_EXPORTER", - "with_gltf": "ASSIMP_BUILD_GLTF_IMPORTER", - "with_gltf_exporter": "ASSIMP_BUILD_GLTF_EXPORTER", - "with_hmp": "ASSIMP_BUILD_HMP_IMPORTER", - "with_ifc": "ASSIMP_BUILD_IFC_IMPORTER", - "with_irr": "ASSIMP_BUILD_IRR_IMPORTER", - "with_irrmesh": "ASSIMP_BUILD_IRRMESH_IMPORTER", - "with_lwo": "ASSIMP_BUILD_LWO_IMPORTER", - "with_lws": "ASSIMP_BUILD_LWS_IMPORTER", - "with_md2": "ASSIMP_BUILD_MD2_IMPORTER", - "with_md3": "ASSIMP_BUILD_MD3_IMPORTER", - "with_md5": "ASSIMP_BUILD_MD5_IMPORTER", - "with_mdc": "ASSIMP_BUILD_MDC_IMPORTER", - "with_mdl": "ASSIMP_BUILD_MDL_IMPORTER", - "with_mmd": "ASSIMP_BUILD_MMD_IMPORTER", - "with_ndo": "ASSIMP_BUILD_NDO_IMPORTER", - "with_nff": "ASSIMP_BUILD_NFF_IMPORTER", - "with_obj": "ASSIMP_BUILD_OBJ_IMPORTER", - "with_obj_exporter": "ASSIMP_BUILD_OBJ_EXPORTER", - "with_off": "ASSIMP_BUILD_OFF_IMPORTER", - "with_ogre": "ASSIMP_BUILD_OGRE_IMPORTER", - "with_opengex": "ASSIMP_BUILD_OPENGEX_IMPORTER", - "with_opengex_exporter": "ASSIMP_BUILD_OPENGEX_EXPORTER", - "with_ply": "ASSIMP_BUILD_PLY_IMPORTER", - "with_ply_exporter": "ASSIMP_BUILD_PLY_EXPORTER", - "with_q3bsp": "ASSIMP_BUILD_Q3BSP_IMPORTER", - "with_q3d": "ASSIMP_BUILD_Q3D_IMPORTER", - "with_raw": "ASSIMP_BUILD_RAW_IMPORTER", - "with_sib": "ASSIMP_BUILD_SIB_IMPORTER", - "with_smd": "ASSIMP_BUILD_SMD_IMPORTER", - "with_step": "ASSIMP_BUILD_STEP_IMPORTER", - "with_step_exporter": "ASSIMP_BUILD_STEP_EXPORTER", - "with_stl": "ASSIMP_BUILD_STL_IMPORTER", - "with_stl_exporter": "ASSIMP_BUILD_STL_EXPORTER", - "with_terragen": "ASSIMP_BUILD_TERRAGEN_IMPORTER", - "with_x": "ASSIMP_BUILD_X_IMPORTER", - "with_x_exporter": "ASSIMP_BUILD_X_EXPORTER", - "with_x3d": "ASSIMP_BUILD_X3D_IMPORTER", - "with_x3d_exporter": "ASSIMP_BUILD_X3D_EXPORTER", - "with_xgl": "ASSIMP_BUILD_XGL_IMPORTER", - } - options.update(dict.fromkeys(_format_option_map, [True, False])) - default_options.update(dict.fromkeys(_format_option_map, True)) - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - - def requirements(self): - self.requires("zlib/1.2.11") - self.requires("irrxml/1.2") - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - def configure(self): - if self.options.shared: - del self.options.fPIC - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("assimp-%s" % self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["SYSTEM_IRRXML"] = True - self._cmake.definitions["ASSIMP_DOUBLE_PRECISION"] = self.options.double_precision - self._cmake.definitions["ASSIMP_NO_EXPORT"] = False - self._cmake.definitions["ASSIMP_BUILD_ASSIMP_TOOLS"] = False - self._cmake.definitions["ASSIMP_BUILD_TESTS"] = False - self._cmake.definitions["ASSIMP_BUILD_SAMPLES"] = False - self._cmake.definitions["ASSIMP_INSTALL_PDB"] = False - - self._cmake.definitions["ASSIMP_ANDROID_JNIIOSYSTEM"] = False - - self._cmake.definitions["ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT"] = False - self._cmake.definitions["ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT"] = False - for option, definition in self._format_option_map.items(): - self._cmake.definitions[definition] = bool(getattr(self.options, option)) - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def build(self): - for before, after in [("-fPIC", ""), ("-g ", ""), ('SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Ob2 /DEBUG:FULL /Zi")', "")]: - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), before, after) - cmake = self._configure_cmake() - cmake.build() - - def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() - cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - - def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["rt", "m", "pthread"] - if not self.options.shared: - stdcpp_library = tools.stdcpp_library(self) - if stdcpp_library: - self.cpp_info.system_libs.append(stdcpp_library) - diff --git a/recipes/assimp/5.0.x/test_package/CMakeLists.txt b/recipes/assimp/5.0.x/test_package/CMakeLists.txt deleted file mode 100644 index 42e27ac52bcc6..0000000000000 --- a/recipes/assimp/5.0.x/test_package/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) - -add_executable(${PROJECT_NAME}_c test_package.c) -target_link_libraries(${PROJECT_NAME}_c ${CONAN_LIBS}) diff --git a/recipes/assimp/5.0.x/test_package/conanfile.py b/recipes/assimp/5.0.x/test_package/conanfile.py deleted file mode 100644 index de01e3d9fc501..0000000000000 --- a/recipes/assimp/5.0.x/test_package/conanfile.py +++ /dev/null @@ -1,22 +0,0 @@ -import os -from conans import ConanFile, CMake, tools - - -class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self.settings): - obj_path = os.path.join(self.source_folder, "box.obj") - - bin_path = os.path.join("bin", "test_package") - self.run("{0} {1}".format(bin_path, obj_path), run_environment=True) - - bin_c_path = os.path.join("bin", "test_package_c") - self.run("{0} {1}".format(bin_c_path, obj_path), run_environment=True) diff --git a/recipes/assimp/5.x/conandata.yml b/recipes/assimp/5.x/conandata.yml new file mode 100644 index 0000000000000..c99892ad1d8a8 --- /dev/null +++ b/recipes/assimp/5.x/conandata.yml @@ -0,0 +1,31 @@ +sources: + "5.2.2": + url: "https://github.com/assimp/assimp/archive/refs/tags/v5.2.2.tar.gz" + sha256: "ad76c5d86c380af65a9d9f64e8fc57af692ffd80a90f613dfc6bd945d0b80bb4" + "5.1.6": + url: "https://github.com/assimp/assimp/archive/refs/tags/v5.1.6.tar.gz" + sha256: "52ad3a3776ce320c8add531dbcb2d3b93f2e1f10fcff5ac30178b09ba934d084" + "5.1.0": + url: "https://github.com/assimp/assimp/archive/refs/tags/v5.1.0.tar.gz" + sha256: "b96f609bca45cc4747bf8ea4b696816ada484aed2812e60ea4d16aae18360b0b" + "5.0.1": + url: "https://github.com/assimp/assimp/archive/refs/tags/v5.0.1.tar.gz" + sha256: "11310ec1f2ad2cd46b95ba88faca8f7aaa1efe9aa12605c55e3de2b977b3dbfc" + "5.0.0": + url: "https://github.com/assimp/assimp/archive/refs/tags/v5.0.0.tar.gz" + sha256: "b0110a91650d6bb4000e3d5c2185bf77b0ff0a2e7a284bc2c4af81b33988b63c" +patches: + "5.2.2": + - patch_file: "patches/0005-fix-unzip.patch" + - patch_file: "patches/0006-unvendor-deps-5.2.x.patch" + "5.1.6": + - patch_file: "patches/0004-unvendor-deps-5.1.6.patch" + - patch_file: "patches/0005-fix-unzip.patch" + "5.1.0": + - patch_file: "patches/0003-unvendor-deps-5.1.x.patch" + "5.0.1": + - patch_file: "patches/0001-unvendor-deps-5.0.x.patch" + - patch_file: "patches/0002-fix-all-exporters-disabled.patch" + "5.0.0": + - patch_file: "patches/0001-unvendor-deps-5.0.x.patch" + - patch_file: "patches/0002-fix-all-exporters-disabled.patch" diff --git a/recipes/assimp/5.x/conanfile.py b/recipes/assimp/5.x/conanfile.py new file mode 100644 index 0000000000000..3a8d091687f9d --- /dev/null +++ b/recipes/assimp/5.x/conanfile.py @@ -0,0 +1,283 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, replace_in_file, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +from conans import tools as tools_legacy +import os + +required_conan_version = ">=1.53.0" + + +class AssimpConan(ConanFile): + name = "assimp" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/assimp/assimp" + description = ( + "A library to import and export various 3d-model-formats including " + "scene-post-processing to generate missing render data." + ) + topics = ("assimp", "3d", "game development", "3mf", "collada") + license = "BSD-3-Clause" + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "double_precision": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "double_precision": False, + } + + _format_option_map = { + "with_3d": ("ASSIMP_BUILD_3D_IMPORTER", "5.0.0"), + "with_3ds": ("ASSIMP_BUILD_3DS_IMPORTER", "5.0.0"), + "with_3ds_exporter": ("ASSIMP_BUILD_3DS_EXPORTER", "5.0.0"), + "with_3mf": ("ASSIMP_BUILD_3MF_IMPORTER", "5.0.0"), + "with_3mf_exporter": ("ASSIMP_BUILD_3MF_EXPORTER", "5.0.0"), + "with_ac": ("ASSIMP_BUILD_AC_IMPORTER", "5.0.0"), + "with_amf": ("ASSIMP_BUILD_AMF_IMPORTER", "5.0.0"), + "with_ase": ("ASSIMP_BUILD_ASE_IMPORTER", "5.0.0"), + "with_assbin": ("ASSIMP_BUILD_ASSBIN_IMPORTER", "5.0.0"), + "with_assbin_exporter": ("ASSIMP_BUILD_ASSBIN_EXPORTER", "5.0.0"), + "with_assxml_exporter": ("ASSIMP_BUILD_ASSXML_EXPORTER", "5.0.0"), + "with_assjson_exporter": ("ASSIMP_BUILD_ASSJSON_EXPORTER", "5.0.0"), + "with_b3d": ("ASSIMP_BUILD_B3D_IMPORTER", "5.0.0"), + "with_blend": ("ASSIMP_BUILD_BLEND_IMPORTER", "5.0.0"), + "with_bvh": ("ASSIMP_BUILD_BVH_IMPORTER", "5.0.0"), + "with_ms3d": ("ASSIMP_BUILD_MS3D_IMPORTER", "5.0.0"), + "with_cob": ("ASSIMP_BUILD_COB_IMPORTER", "5.0.0"), + "with_collada": ("ASSIMP_BUILD_COLLADA_IMPORTER", "5.0.0"), + "with_collada_exporter": ("ASSIMP_BUILD_COLLADA_EXPORTER", "5.0.0"), + "with_csm": ("ASSIMP_BUILD_CSM_IMPORTER", "5.0.0"), + "with_dxf": ("ASSIMP_BUILD_DXF_IMPORTER", "5.0.0"), + "with_fbx": ("ASSIMP_BUILD_FBX_IMPORTER", "5.0.0"), + "with_fbx_exporter": ("ASSIMP_BUILD_FBX_EXPORTER", "5.0.0"), + "with_gltf": ("ASSIMP_BUILD_GLTF_IMPORTER", "5.0.0"), + "with_gltf_exporter": ("ASSIMP_BUILD_GLTF_EXPORTER", "5.0.0"), + "with_hmp": ("ASSIMP_BUILD_HMP_IMPORTER", "5.0.0"), + "with_ifc": ("ASSIMP_BUILD_IFC_IMPORTER", "5.0.0"), + "with_irr": ("ASSIMP_BUILD_IRR_IMPORTER", "5.0.0"), + "with_irrmesh": ("ASSIMP_BUILD_IRRMESH_IMPORTER", "5.0.0"), + "with_lwo": ("ASSIMP_BUILD_LWO_IMPORTER", "5.0.0"), + "with_lws": ("ASSIMP_BUILD_LWS_IMPORTER", "5.0.0"), + "with_md2": ("ASSIMP_BUILD_MD2_IMPORTER", "5.0.0"), + "with_md3": ("ASSIMP_BUILD_MD3_IMPORTER", "5.0.0"), + "with_md5": ("ASSIMP_BUILD_MD5_IMPORTER", "5.0.0"), + "with_mdc": ("ASSIMP_BUILD_MDC_IMPORTER", "5.0.0"), + "with_mdl": ("ASSIMP_BUILD_MDL_IMPORTER", "5.0.0"), + "with_mmd": ("ASSIMP_BUILD_MMD_IMPORTER", "5.0.0"), + "with_ndo": ("ASSIMP_BUILD_NDO_IMPORTER", "5.0.0"), + "with_nff": ("ASSIMP_BUILD_NFF_IMPORTER", "5.0.0"), + "with_obj": ("ASSIMP_BUILD_OBJ_IMPORTER", "5.0.0"), + "with_obj_exporter": ("ASSIMP_BUILD_OBJ_EXPORTER", "5.0.0"), + "with_off": ("ASSIMP_BUILD_OFF_IMPORTER", "5.0.0"), + "with_ogre": ("ASSIMP_BUILD_OGRE_IMPORTER", "5.0.0"), + "with_opengex": ("ASSIMP_BUILD_OPENGEX_IMPORTER", "5.0.0"), + "with_opengex_exporter": ("ASSIMP_BUILD_OPENGEX_EXPORTER", "5.0.0"), + "with_pbrt_exporter": ("ASSIMP_BUILD_PBRT_EXPORTER", "5.1.0"), + "with_ply": ("ASSIMP_BUILD_PLY_IMPORTER", "5.0.0"), + "with_ply_exporter": ("ASSIMP_BUILD_PLY_EXPORTER", "5.0.0"), + "with_q3bsp": ("ASSIMP_BUILD_Q3BSP_IMPORTER", "5.0.0"), + "with_q3d": ("ASSIMP_BUILD_Q3D_IMPORTER", "5.0.0"), + "with_raw": ("ASSIMP_BUILD_RAW_IMPORTER", "5.0.0"), + "with_sib": ("ASSIMP_BUILD_SIB_IMPORTER", "5.0.0"), + "with_smd": ("ASSIMP_BUILD_SMD_IMPORTER", "5.0.0"), + "with_step": ("ASSIMP_BUILD_STEP_IMPORTER", "5.0.0"), + "with_step_exporter": ("ASSIMP_BUILD_STEP_EXPORTER", "5.0.0"), + "with_stl": ("ASSIMP_BUILD_STL_IMPORTER", "5.0.0"), + "with_stl_exporter": ("ASSIMP_BUILD_STL_EXPORTER", "5.0.0"), + "with_terragen": ("ASSIMP_BUILD_TERRAGEN_IMPORTER", "5.0.0"), + "with_x": ("ASSIMP_BUILD_X_IMPORTER", "5.0.0"), + "with_x_exporter": ("ASSIMP_BUILD_X_EXPORTER", "5.0.0"), + "with_x3d": ("ASSIMP_BUILD_X3D_IMPORTER", "5.0.0"), + "with_x3d_exporter": ("ASSIMP_BUILD_X3D_EXPORTER", "5.0.0"), + "with_xgl": ("ASSIMP_BUILD_XGL_IMPORTER", "5.0.0"), + "with_m3d": ("ASSIMP_BUILD_M3D_IMPORTER", "5.1.0"), + "with_m3d_exporter": ("ASSIMP_BUILD_M3D_EXPORTER", "5.1.0"), + "with_iqm": ("ASSIMP_BUILD_IQM_IMPORTER", "5.2.0"), + } + options.update(dict.fromkeys(_format_option_map, [True, False])) + default_options.update(dict.fromkeys(_format_option_map, True)) + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + for option, (_, min_version) in self._format_option_map.items(): + if Version(self.version) < Version(min_version): + delattr(self.options, option) + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + @property + def _depends_on_kuba_zip(self): + return self.options.with_3mf_exporter + + @property + def _depends_on_poly2tri(self): + return self.options.with_blend or self.options.with_ifc + + @property + def _depends_on_rapidjson(self): + return self.options.with_gltf or self.options.with_gltf_exporter + + @property + def _depends_on_draco(self): + if Version(self.version) < "5.1.0": + return False + return self.options.with_gltf or self.options.with_gltf_exporter + + @property + def _depends_on_clipper(self): + return self.options.with_ifc + + @property + def _depends_on_stb(self): + if Version(self.version) < "5.1.0": + return False + return self.options.with_m3d or self.options.with_m3d_exporter or \ + self.options.with_pbrt_exporter + + @property + def _depends_on_zlib(self): + return self.options.with_assbin or self.options.with_assbin_exporter or \ + self.options.with_assxml_exporter or self.options.with_blend or self.options.with_fbx or \ + self.options.with_q3bsp or self.options.with_x or self.options.with_xgl + + @property + def _depends_on_openddlparser(self): + if Version(self.version) < "5.1.0": + return False + return self.options.with_opengex + + def requirements(self): + # TODO: unvendor others libs: + # - Open3DGC + self.requires("minizip/1.2.13") + self.requires("utfcpp/3.2.1") + if Version(self.version) < "5.1.0": + self.requires("irrxml/1.2") + else: + self.requires("pugixml/1.12.1") + if self._depends_on_kuba_zip: + self.requires("kuba-zip/0.2.6") + if self._depends_on_poly2tri: + self.requires("poly2tri/cci.20130502") + if self._depends_on_rapidjson: + self.requires("rapidjson/cci.20220822") + if self._depends_on_zlib: + self.requires("zlib/1.2.13") + if self._depends_on_draco: + self.requires("draco/1.5.5") + if self._depends_on_clipper: + self.requires("clipper/4.10.0") # Only 4.x supported + if self._depends_on_stb: + self.requires("stb/cci.20210910") + if self._depends_on_openddlparser: + self.requires("openddl-parser/0.5.0") + + def validate(self): + if self._depends_on_clipper and Version(self.dependencies["clipper"].ref.version).major != "4": + raise ConanInvalidConfiguration("Only 'clipper/4.x' is supported") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) >= "5.1.0": + tc.variables["ASSIMP_HUNTER_ENABLED"] = False + tc.variables["ASSIMP_IGNORE_GIT_HASH"] = True + tc.variables["ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR"] = False + else: + tc.variables["HUNTER_ENABLED"] = False + tc.variables["IGNORE_GIT_HASH"] = True + tc.variables["SYSTEM_IRRXML"] = True + tc.variables["ASSIMP_ANDROID_JNIIOSYSTEM"] = False + tc.variables["ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT"] = False + tc.variables["ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT"] = False + tc.variables["ASSIMP_BUILD_ASSIMP_TOOLS"] = False + tc.variables["ASSIMP_BUILD_SAMPLES"] = False + tc.variables["ASSIMP_BUILD_TESTS"] = False + tc.variables["ASSIMP_DOUBLE_PRECISION"] = self.options.double_precision + tc.variables["ASSIMP_INSTALL_PDB"] = False + tc.variables["ASSIMP_NO_EXPORT"] = False + tc.variables["ASSIMP_BUILD_MINIZIP"] = False + for option, (definition, _) in self._format_option_map.items(): + value = self.options.get_safe(option) + if value is not None: + tc.variables[definition] = value + if self.settings.os == "Windows": + tc.preprocessor_definitions["NOMINMAX"] = 1 + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" # to avoid warnings + tc.generate() + + cd = CMakeDeps(self) + cd.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + # Don't force several compiler and linker flags + replace_mapping = [ + ("-fPIC", ""), + ("-g ", ""), + ("SET(CMAKE_POSITION_INDEPENDENT_CODE ON)", ""), + ('SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Ob2 /DEBUG:FULL /Zi")', ""), + ('SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")', ""), + ('SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")', ""), + ('SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG:FULL /PDBALTPATH:%_PDB% /OPT:REF /OPT:ICF")', ""), + ("/WX", "") + ] + + for before, after in replace_mapping: + replace_in_file(self, os.path.join( + self.source_folder, "CMakeLists.txt"), before, after, strict=False) + # Take care to not use these vendored libs + vendors = ["poly2tri", "rapidjson", "utf8cpp", "zip", "unzip", "stb", "zlib", "clipper"] + if Version(self.version) < "5.1.0": + vendors.append("irrXML") + else: + vendors.extend(["pugixml", "draco", "openddlparser"]) + for vendor in vendors: + rmdir(self, os.path.join(self.source_folder, "contrib", vendor)) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "assimp") + self.cpp_info.set_property("cmake_target_name", "assimp::assimp") + self.cpp_info.set_property("pkg_config_name", "assimp") + self.cpp_info.libs = collect_libs(self) + if is_msvc(self) and self.options.shared: + self.cpp_info.defines.append("ASSIMP_DLL") + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["rt", "m", "pthread"] + if not self.options.shared: + stdcpp_library = tools_legacy.stdcpp_library(self) + if stdcpp_library: + self.cpp_info.system_libs.append(stdcpp_library) diff --git a/recipes/assimp/5.x/patches/0001-unvendor-deps-5.0.x.patch b/recipes/assimp/5.x/patches/0001-unvendor-deps-5.0.x.patch new file mode 100644 index 0000000000000..1445d96a11b7c --- /dev/null +++ b/recipes/assimp/5.x/patches/0001-unvendor-deps-5.0.x.patch @@ -0,0 +1,278 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -437,7 +437,12 @@ IF(HUNTER_ENABLED) + set(ASSIMP_BUILD_MINIZIP TRUE) + ELSE(HUNTER_ENABLED) + IF ( NOT ASSIMP_BUILD_ZLIB ) +- FIND_PACKAGE(ZLIB) ++ if(ASSIMP_BUILD_ASSBIN_IMPORTER OR ASSIMP_BUILD_ASSBIN_EXPORTER OR ASSIMP_BUILD_ASSXML_EXPORTER OR ++ ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_FBX_IMPORTER OR ASSIMP_BUILD_Q3BSP_IMPORTER OR ++ ASSIMP_BUILD_X_IMPORTER OR ASSIMP_BUILD_XGL_IMPORTER) ++ find_package(ZLIB REQUIRED) ++ endif() ++ set(ZLIB_FOUND TRUE) + ENDIF( NOT ASSIMP_BUILD_ZLIB ) + + IF( NOT ZLIB_FOUND ) +@@ -470,14 +475,14 @@ ENDIF(HUNTER_ENABLED) + + IF( NOT IOS ) + IF( NOT ASSIMP_BUILD_MINIZIP ) +- use_pkgconfig(UNZIP minizip) ++ find_package(minizip REQUIRED CONFIG) ++ set(UNZIP_FOUND TRUE) + ENDIF( NOT ASSIMP_BUILD_MINIZIP ) + ELSE ( NOT IOS ) +- IF( NOT BUILD_SHARED_LIBS ) + IF( NOT ASSIMP_BUILD_MINIZIP ) +- use_pkgconfig(UNZIP minizip) ++ find_package(minizip REQUIRED CONFIG) ++ set(UNZIP_FOUND TRUE) + ENDIF( NOT ASSIMP_BUILD_MINIZIP ) +- ENDIF ( NOT BUILD_SHARED_LIBS ) + ENDIF ( NOT IOS ) + + IF ( ASSIMP_NO_EXPORT ) +--- a/code/3MF/D3MFExporter.cpp ++++ b/code/3MF/D3MFExporter.cpp +@@ -58,7 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include ++# include + #endif + + namespace Assimp { +--- a/code/Blender/BlenderTessellator.h ++++ b/code/Blender/BlenderTessellator.h +@@ -147,7 +147,7 @@ namespace Assimp + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" ++# include + #endif + + namespace Assimp +--- a/code/CMakeLists.txt ++++ b/code/CMakeLists.txt +@@ -866,6 +866,7 @@ IF(HUNTER_ENABLED) + hunter_add_package(irrXML) + find_package(irrXML CONFIG REQUIRED) + ELSE(HUNTER_ENABLED) ++ find_package(irrxml REQUIRED CONFIG) + # irrXML already included in contrib directory by parent CMakeLists.txt. + ENDIF(HUNTER_ENABLED) + +@@ -874,6 +875,7 @@ IF(HUNTER_ENABLED) + hunter_add_package(utf8) + find_package(utf8 CONFIG REQUIRED) + ELSE(HUNTER_ENABLED) ++ find_package(utf8cpp REQUIRED CONFIG) + # utf8 is header-only, so Assimp doesn't need to do anything. + ENDIF(HUNTER_ENABLED) + +@@ -882,6 +884,9 @@ IF(HUNTER_ENABLED) + hunter_add_package(polyclipping) + find_package(polyclipping CONFIG REQUIRED) + ELSE(HUNTER_ENABLED) ++ if(ASSIMP_BUILD_IFC_IMPORTER) ++ find_package(clipper REQUIRED CONFIG) ++ endif() + SET( Clipper_SRCS + ../contrib/clipper/clipper.hpp + ../contrib/clipper/clipper.cpp +@@ -894,6 +899,9 @@ IF(HUNTER_ENABLED) + hunter_add_package(poly2tri) + find_package(poly2tri CONFIG REQUIRED) + ELSE(HUNTER_ENABLED) ++ if(ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_IFC_IMPORTER) ++ find_package(poly2tri REQUIRED CONFIG) ++ endif() + SET( Poly2Tri_SRCS + ../contrib/poly2tri/poly2tri/common/shapes.cc + ../contrib/poly2tri/poly2tri/common/shapes.h +@@ -930,6 +938,9 @@ IF(HUNTER_ENABLED) + hunter_add_package(zip) + find_package(zip CONFIG REQUIRED) + ELSE(HUNTER_ENABLED) ++ if(ASSIMP_BUILD_3MF_EXPORTER) ++ find_package(zip REQUIRED CONFIG) ++ endif() + SET( ziplib_SRCS + ../contrib/zip/src/miniz.h + ../contrib/zip/src/zip.c +@@ -1025,8 +1036,9 @@ IF(HUNTER_ENABLED) + hunter_add_package(RapidJSON) + find_package(RapidJSON CONFIG REQUIRED) + ELSE(HUNTER_ENABLED) +- INCLUDE_DIRECTORIES( "../contrib/rapidjson/include" ) +- INCLUDE_DIRECTORIES( "../contrib" ) ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ find_package(RapidJSON REQUIRED CONFIG) ++ endif() + ENDIF(HUNTER_ENABLED) + + # VC2010 fixes +@@ -1076,13 +1088,8 @@ SET( assimp_src + ${ASSIMP_EXPORTER_SRCS} + + # Third-party libraries +- ${IrrXML_SRCS} +- ${unzip_compile_SRCS} +- ${Poly2Tri_SRCS} +- ${Clipper_SRCS} + ${openddl_parser_SRCS} + ${open3dgc_SRCS} +- ${ziplib_SRCS} + # Necessary to show the headers in the project when using the VC++ generator: + + ${PUBLIC_HEADERS} +@@ -1094,6 +1101,7 @@ IF(NOT HUNTER_ENABLED) + INCLUDE_DIRECTORIES( + ${IRRXML_INCLUDE_DIR} + ../contrib/openddlparser/include ++ ../contrib # for Open3DGC + ) + ENDIF(NOT HUNTER_ENABLED) + +@@ -1125,7 +1133,24 @@ IF(HUNTER_ENABLED) + zip::zip + ) + ELSE(HUNTER_ENABLED) +- TARGET_LINK_LIBRARIES(assimp ${ZLIB_LIBRARIES} ${OPENDDL_PARSER_LIBRARIES} ${IRRXML_LIBRARY} ) ++ target_link_libraries(assimp irrxml::irrxml utf8cpp) ++ if(ASSIMP_BUILD_ASSBIN_IMPORTER OR ASSIMP_BUILD_ASSBIN_EXPORTER OR ASSIMP_BUILD_ASSXML_EXPORTER OR ++ ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_FBX_IMPORTER OR ASSIMP_BUILD_Q3BSP_IMPORTER OR ++ ASSIMP_BUILD_X_IMPORTER OR ASSIMP_BUILD_XGL_IMPORTER) ++ target_link_libraries(assimp ZLIB::ZLIB) ++ endif() ++ if(ASSIMP_BUILD_IFC_IMPORTER) ++ target_link_libraries(assimp clipper::clipper) ++ endif() ++ if(ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_IFC_IMPORTER) ++ target_link_libraries(assimp poly2tri::poly2tri) ++ endif() ++ if(ASSIMP_BUILD_3MF_EXPORTER) ++ target_link_libraries(assimp zip::zip) ++ endif() ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ target_link_libraries(assimp rapidjson) ++ endif() + ENDIF(HUNTER_ENABLED) + + if(ASSIMP_ANDROID_JNIIOSYSTEM) +@@ -1210,8 +1235,7 @@ ENDIF(APPLE) + # assimp can #include "unzip.h" + IF(NOT HUNTER_ENABLED) + if (UNZIP_FOUND) +- INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS}) +- TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES}) ++ target_link_libraries(assimp minizip::minizip) + else (UNZIP_FOUND) + INCLUDE_DIRECTORIES("../") + endif (UNZIP_FOUND) +--- a/code/Common/BaseImporter.cpp ++++ b/code/Common/BaseImporter.cpp +@@ -344,7 +344,7 @@ std::string BaseImporter::GetExtension( const std::string& file ) { + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include "../contrib/utf8cpp/source/utf8.h" ++# include + #endif + + // ------------------------------------------------------------------------------------------------ +--- a/code/Common/ZipArchiveIOSystem.cpp ++++ b/code/Common/ZipArchiveIOSystem.cpp +@@ -55,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include ++# include + #endif + + namespace Assimp { +--- a/code/Importer/IFC/IFCGeometry.cpp ++++ b/code/Importer/IFC/IFCGeometry.cpp +@@ -53,8 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + # include + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" +-# include "../contrib/clipper/clipper.hpp" ++# include ++# include + #endif + + #include +--- a/code/Importer/IFC/IFCLoader.cpp ++++ b/code/Importer/IFC/IFCLoader.cpp +@@ -55,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + # ifdef ASSIMP_USE_HUNTER + # include + # else +-# include ++# include + # endif + #endif + +--- a/code/Importer/IFC/IFCOpenings.cpp ++++ b/code/Importer/IFC/IFCOpenings.cpp +@@ -53,8 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + # include + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" +-# include "../contrib/clipper/clipper.hpp" ++# include ++# include + #endif + + #include +--- a/code/Importer/STEPParser/STEPFileEncoding.cpp ++++ b/code/Importer/STEPParser/STEPFileEncoding.cpp +@@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include ++# include + #endif + + #include +--- a/code/MMD/MMDPmxParser.cpp ++++ b/code/MMD/MMDPmxParser.cpp +@@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include "../contrib/utf8cpp/source/utf8.h" ++# include + #endif + #include + +--- a/code/SIB/SIBImporter.cpp ++++ b/code/SIB/SIBImporter.cpp +@@ -63,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + # include + #else + //# include "../contrib/ConvertUTF/ConvertUTF.h" +-# include "../contrib/utf8cpp/source/utf8.h" ++# include + #endif + #include + #include +--- a/code/X3D/FIReader.cpp ++++ b/code/X3D/FIReader.cpp +@@ -63,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include "../contrib/utf8cpp/source/utf8.h" ++# include + #endif + #include + #include diff --git a/recipes/assimp/5.x/patches/0002-fix-all-exporters-disabled.patch b/recipes/assimp/5.x/patches/0002-fix-all-exporters-disabled.patch new file mode 100644 index 0000000000000..2e71d7e86ff86 --- /dev/null +++ b/recipes/assimp/5.x/patches/0002-fix-all-exporters-disabled.patch @@ -0,0 +1,253 @@ +patch from https://github.com/assimp/assimp/pull/2759 + +--- a/code/Common/Exporter.cpp ++++ b/code/Common/Exporter.cpp +@@ -105,90 +105,88 @@ void ExportScene3MF( const char*, IOSystem*, const aiScene*, const ExportPropert + void ExportAssimp2Json(const char* , IOSystem*, const aiScene* , const Assimp::ExportProperties*); + + // ------------------------------------------------------------------------------------------------ +-// global array of all export formats which Assimp supports in its current build +-Exporter::ExportFormatEntry gExporters[] = ++static void setupExporterArray(std::vector &exporters) + { + #ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER +- Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada ), ++ exporters.push_back(Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada )); + #endif + + #ifndef ASSIMP_BUILD_NO_X_EXPORTER +- Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile, +- aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs ), ++ exporters.push_back(Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile, ++ aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs )); + #endif + + #ifndef ASSIMP_BUILD_NO_STEP_EXPORTER +- Exporter::ExportFormatEntry( "stp", "Step Files", "stp", &ExportSceneStep, 0 ), ++ exporters.push_back(Exporter::ExportFormatEntry( "stp", "Step Files", "stp", &ExportSceneStep, 0 )); + #endif + + #ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER +- Exporter::ExportFormatEntry( "obj", "Wavefront OBJ format", "obj", &ExportSceneObj, +- aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */ ), +- Exporter::ExportFormatEntry( "objnomtl", "Wavefront OBJ format without material file", "obj", &ExportSceneObjNoMtl, +- aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */ ), ++ exporters.push_back(Exporter::ExportFormatEntry( "obj", "Wavefront OBJ format", "obj", &ExportSceneObj, ++ aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */ )); ++ exporters.push_back(Exporter::ExportFormatEntry( "objnomtl", "Wavefront OBJ format without material file", "obj", &ExportSceneObjNoMtl, ++ aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */ )); + #endif + + #ifndef ASSIMP_BUILD_NO_STL_EXPORTER +- Exporter::ExportFormatEntry( "stl", "Stereolithography", "stl" , &ExportSceneSTL, ++ exporters.push_back(Exporter::ExportFormatEntry( "stl", "Stereolithography", "stl" , &ExportSceneSTL, + aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices +- ), +- Exporter::ExportFormatEntry( "stlb", "Stereolithography (binary)", "stl" , &ExportSceneSTLBinary, ++ )); ++ exporters.push_back(Exporter::ExportFormatEntry( "stlb", "Stereolithography (binary)", "stl" , &ExportSceneSTLBinary, + aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_PreTransformVertices +- ), ++ )); + #endif + + #ifndef ASSIMP_BUILD_NO_PLY_EXPORTER +- Exporter::ExportFormatEntry( "ply", "Stanford Polygon Library", "ply" , &ExportScenePly, ++ exporters.push_back(Exporter::ExportFormatEntry( "ply", "Stanford Polygon Library", "ply" , &ExportScenePly, + aiProcess_PreTransformVertices +- ), +- Exporter::ExportFormatEntry( "plyb", "Stanford Polygon Library (binary)", "ply", &ExportScenePlyBinary, ++ )); ++ exporters.push_back(Exporter::ExportFormatEntry( "plyb", "Stanford Polygon Library (binary)", "ply", &ExportScenePlyBinary, + aiProcess_PreTransformVertices +- ), ++ )); + #endif + + #ifndef ASSIMP_BUILD_NO_3DS_EXPORTER +- Exporter::ExportFormatEntry( "3ds", "Autodesk 3DS (legacy)", "3ds" , &ExportScene3DS, +- aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices ), ++ exporters.push_back(Exporter::ExportFormatEntry( "3ds", "Autodesk 3DS (legacy)", "3ds" , &ExportScene3DS, ++ aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices )); + #endif + + #ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER +- Exporter::ExportFormatEntry( "gltf2", "GL Transmission Format v. 2", "gltf", &ExportSceneGLTF2, +- aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ), +- Exporter::ExportFormatEntry( "glb2", "GL Transmission Format v. 2 (binary)", "glb", &ExportSceneGLB2, +- aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ), +- Exporter::ExportFormatEntry( "gltf", "GL Transmission Format", "gltf", &ExportSceneGLTF, +- aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ), +- Exporter::ExportFormatEntry( "glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB, +- aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType ), ++ exporters.push_back(Exporter::ExportFormatEntry( "gltf2", "GL Transmission Format v. 2", "gltf", &ExportSceneGLTF2, ++ aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType )); ++ exporters.push_back(Exporter::ExportFormatEntry( "glb2", "GL Transmission Format v. 2 (binary)", "glb", &ExportSceneGLB2, ++ aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType )); ++ exporters.push_back(Exporter::ExportFormatEntry( "gltf", "GL Transmission Format", "gltf", &ExportSceneGLTF, ++ aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType )); ++ exporters.push_back(Exporter::ExportFormatEntry( "glb", "GL Transmission Format (binary)", "glb", &ExportSceneGLB, ++ aiProcess_JoinIdenticalVertices | aiProcess_Triangulate | aiProcess_SortByPType )); + #endif + + #ifndef ASSIMP_BUILD_NO_ASSBIN_EXPORTER +- Exporter::ExportFormatEntry( "assbin", "Assimp Binary File", "assbin" , &ExportSceneAssbin, 0 ), ++ exporters.push_back(Exporter::ExportFormatEntry( "assbin", "Assimp Binary File", "assbin" , &ExportSceneAssbin, 0 )); + #endif + + #ifndef ASSIMP_BUILD_NO_ASSXML_EXPORTER +- Exporter::ExportFormatEntry( "assxml", "Assimp XML Document", "assxml" , &ExportSceneAssxml, 0 ), ++ exporters.push_back(Exporter::ExportFormatEntry( "assxml", "Assimp XML Document", "assxml" , &ExportSceneAssxml, 0 )); + #endif + + #ifndef ASSIMP_BUILD_NO_X3D_EXPORTER +- Exporter::ExportFormatEntry( "x3d", "Extensible 3D", "x3d" , &ExportSceneX3D, 0 ), ++ exporters.push_back(Exporter::ExportFormatEntry( "x3d", "Extensible 3D", "x3d" , &ExportSceneX3D, 0 )); + #endif + + #ifndef ASSIMP_BUILD_NO_FBX_EXPORTER +- Exporter::ExportFormatEntry( "fbx", "Autodesk FBX (binary)", "fbx", &ExportSceneFBX, 0 ), +- Exporter::ExportFormatEntry( "fbxa", "Autodesk FBX (ascii)", "fbx", &ExportSceneFBXA, 0 ), ++ exporters.push_back(Exporter::ExportFormatEntry( "fbx", "Autodesk FBX (binary)", "fbx", &ExportSceneFBX, 0 )); ++ exporters.push_back(Exporter::ExportFormatEntry( "fbxa", "Autodesk FBX (ascii)", "fbx", &ExportSceneFBXA, 0 )); + #endif + + #ifndef ASSIMP_BUILD_NO_3MF_EXPORTER +- Exporter::ExportFormatEntry( "3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0 ), ++ exporters.push_back(Exporter::ExportFormatEntry( "3mf", "The 3MF-File-Format", "3mf", &ExportScene3MF, 0 )); + #endif + + #ifndef ASSIMP_BUILD_NO_ASSJSON_EXPORTER +- Exporter::ExportFormatEntry( "assjson", "Assimp JSON Document", "json", &ExportAssimp2Json, 0) ++ exporters.push_back(Exporter::ExportFormatEntry( "assjson", "Assimp JSON Document", "json", &ExportAssimp2Json, 0)); + #endif +-}; ++} + +-#define ASSIMP_NUM_EXPORTERS (sizeof(gExporters)/sizeof(gExporters[0])) + + + class ExporterPimpl { +@@ -205,10 +203,7 @@ public: + GetPostProcessingStepInstanceList(mPostProcessingSteps); + + // grab all built-in exporters +- if ( 0 != ( ASSIMP_NUM_EXPORTERS ) ) { +- mExporters.resize( ASSIMP_NUM_EXPORTERS ); +- std::copy( gExporters, gExporters + ASSIMP_NUM_EXPORTERS, mExporters.begin() ); +- } ++ setupExporterArray(mExporters); + } + + ~ExporterPimpl() { +@@ -252,23 +247,27 @@ Exporter :: Exporter() + + // ------------------------------------------------------------------------------------------------ + Exporter::~Exporter() { ++ ai_assert(nullptr != pimpl); + FreeBlob(); + delete pimpl; + } + + // ------------------------------------------------------------------------------------------------ + void Exporter::SetIOHandler( IOSystem* pIOHandler) { ++ ai_assert(nullptr != pimpl); + pimpl->mIsDefaultIOHandler = !pIOHandler; + pimpl->mIOSystem.reset(pIOHandler); + } + + // ------------------------------------------------------------------------------------------------ + IOSystem* Exporter::GetIOHandler() const { ++ ai_assert(nullptr != pimpl); + return pimpl->mIOSystem.get(); + } + + // ------------------------------------------------------------------------------------------------ + bool Exporter::IsDefaultIOHandler() const { ++ ai_assert(nullptr != pimpl); + return pimpl->mIsDefaultIOHandler; + } + +@@ -295,6 +294,7 @@ void Exporter::SetProgressHandler(ProgressHandler* pHandler) { + // ------------------------------------------------------------------------------------------------ + const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const char* pFormatId, + unsigned int pPreprocessing, const ExportProperties* pProperties) { ++ ai_assert(nullptr != pimpl); + if (pimpl->blob) { + delete pimpl->blob; + pimpl->blob = nullptr; +@@ -319,6 +319,7 @@ const aiExportDataBlob* Exporter::ExportToBlob( const aiScene* pScene, const cha + aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const char* pPath, + unsigned int pPreprocessing, const ExportProperties* pProperties) { + ASSIMP_BEGIN_EXCEPTION_REGION(); ++ ai_assert(nullptr != pimpl); + + // when they create scenes from scratch, users will likely create them not in verbose + // format. They will likely not be aware that there is a flag in the scene to indicate +@@ -466,11 +467,13 @@ aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const c + + // ------------------------------------------------------------------------------------------------ + const char* Exporter::GetErrorString() const { ++ ai_assert(nullptr != pimpl); + return pimpl->mError.c_str(); + } + + // ------------------------------------------------------------------------------------------------ + void Exporter::FreeBlob() { ++ ai_assert(nullptr != pimpl); + delete pimpl->blob; + pimpl->blob = nullptr; + +@@ -479,11 +482,13 @@ void Exporter::FreeBlob() { + + // ------------------------------------------------------------------------------------------------ + const aiExportDataBlob* Exporter::GetBlob() const { ++ ai_assert(nullptr != pimpl); + return pimpl->blob; + } + + // ------------------------------------------------------------------------------------------------ + const aiExportDataBlob* Exporter::GetOrphanedBlob() const { ++ ai_assert(nullptr != pimpl); + const aiExportDataBlob* tmp = pimpl->blob; + pimpl->blob = nullptr; + return tmp; +@@ -491,18 +496,20 @@ const aiExportDataBlob* Exporter::GetOrphanedBlob() const { + + // ------------------------------------------------------------------------------------------------ + size_t Exporter::GetExportFormatCount() const { ++ ai_assert(nullptr != pimpl); + return pimpl->mExporters.size(); + } + + // ------------------------------------------------------------------------------------------------ + const aiExportFormatDesc* Exporter::GetExportFormatDescription( size_t index ) const { ++ ai_assert(nullptr != pimpl); + if (index >= GetExportFormatCount()) { + return nullptr; + } + + // Return from static storage if the requested index is built-in. +- if (index < sizeof(gExporters) / sizeof(gExporters[0])) { +- return &gExporters[index].mDescription; ++ if (index < pimpl->mExporters.size()) { ++ return &pimpl->mExporters[index].mDescription; + } + + return &pimpl->mExporters[index].mDescription; +@@ -510,6 +517,7 @@ const aiExportFormatDesc* Exporter::GetExportFormatDescription( size_t index ) c + + // ------------------------------------------------------------------------------------------------ + aiReturn Exporter::RegisterExporter(const ExportFormatEntry& desc) { ++ ai_assert(nullptr != pimpl); + for(const ExportFormatEntry& e : pimpl->mExporters) { + if (!strcmp(e.mDescription.id,desc.mDescription.id)) { + return aiReturn_FAILURE; +@@ -522,6 +530,7 @@ aiReturn Exporter::RegisterExporter(const ExportFormatEntry& desc) { + + // ------------------------------------------------------------------------------------------------ + void Exporter::UnregisterExporter(const char* id) { ++ ai_assert(nullptr != pimpl); + for(std::vector::iterator it = pimpl->mExporters.begin(); + it != pimpl->mExporters.end(); ++it) { + if (!strcmp((*it).mDescription.id,id)) { diff --git a/recipes/assimp/5.x/patches/0003-unvendor-deps-5.1.x.patch b/recipes/assimp/5.x/patches/0003-unvendor-deps-5.1.x.patch new file mode 100644 index 0000000000000..fdd67862ddb24 --- /dev/null +++ b/recipes/assimp/5.x/patches/0003-unvendor-deps-5.1.x.patch @@ -0,0 +1,354 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -465,7 +465,12 @@ ELSE() + ENDIF() + + IF ( NOT ASSIMP_BUILD_ZLIB ) +- FIND_PACKAGE(ZLIB) ++ if(ASSIMP_BUILD_ASSBIN_IMPORTER OR ASSIMP_BUILD_ASSBIN_EXPORTER OR ASSIMP_BUILD_ASSXML_EXPORTER OR ++ ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_FBX_IMPORTER OR ASSIMP_BUILD_Q3BSP_IMPORTER OR ++ ASSIMP_BUILD_X_IMPORTER OR ASSIMP_BUILD_XGL_IMPORTER) ++ find_package(ZLIB REQUIRED) ++ endif() ++ set(ZLIB_FOUND TRUE) + ENDIF() + + IF( NOT ZLIB_FOUND ) +@@ -498,12 +503,14 @@ ENDIF() + + IF( NOT IOS ) + IF( NOT ASSIMP_BUILD_MINIZIP ) +- use_pkgconfig(UNZIP minizip) ++ find_package(minizip REQUIRED CONFIG) ++ set(UNZIP_FOUND TRUE) + ENDIF() + ELSE () + IF( NOT BUILD_SHARED_LIBS ) + IF( NOT ASSIMP_BUILD_MINIZIP ) +- use_pkgconfig(UNZIP minizip) ++ find_package(minizip REQUIRED CONFIG) ++ set(UNZIP_FOUND TRUE) + ENDIF() + ENDIF () + ENDIF () +--- a/code/AssetLib/3MF/D3MFExporter.cpp ++++ b/code/AssetLib/3MF/D3MFExporter.cpp +@@ -57,7 +57,7 @@ + #ifdef ASSIMP_USE_HUNTER + #include + #else +-#include ++#include + #endif + + namespace Assimp { +--- a/code/AssetLib/Blender/BlenderTessellator.h ++++ b/code/AssetLib/Blender/BlenderTessellator.h +@@ -147,7 +147,7 @@ + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" ++# include + #endif + + namespace Assimp +--- a/code/AssetLib/IFC/IFCGeometry.cpp ++++ b/code/AssetLib/IFC/IFCGeometry.cpp +@@ -53,8 +53,8 @@ + # include + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" +-# include "../contrib/clipper/clipper.hpp" ++# include ++# include + #endif + + #include +--- a/code/AssetLib/IFC/IFCLoader.cpp ++++ b/code/AssetLib/IFC/IFCLoader.cpp +@@ -54,7 +54,7 @@ + #ifdef ASSIMP_USE_HUNTER + #include + #else +-#include ++#include + #endif + #endif + +--- a/code/AssetLib/IFC/IFCOpenings.cpp ++++ b/code/AssetLib/IFC/IFCOpenings.cpp +@@ -53,8 +53,8 @@ + # include + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" +-# include "../contrib/clipper/clipper.hpp" ++# include ++# include + #endif + + #include +--- a/code/AssetLib/M3D/M3DWrapper.hpp ++++ b/code/AssetLib/M3D/M3DWrapper.h +@@ -59,7 +59,7 @@ + + // Share stb_image's PNG loader with other importers/exporters instead of bringing our own copy. + #define STBI_ONLY_PNG +-#include ++#include + + #include "m3d.h" + +--- a/code/AssetLib/MMD/MMDPmxParser.cpp ++++ b/code/AssetLib/MMD/MMDPmxParser.cpp +@@ -45,7 +45,7 @@ + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include "../contrib/utf8cpp/source/utf8.h" ++# include + #endif + #include + +--- a/code/AssetLib/SIB/SIBImporter.cpp ++++ b/code/AssetLib/SIB/SIBImporter.cpp +@@ -62,7 +62,7 @@ + #include + #else + //# include "../contrib/ConvertUTF/ConvertUTF.h" +-#include "../contrib/utf8cpp/source/utf8.h" ++#include + #endif + #include + #include +--- a/code/AssetLib/STEPParser/STEPFileEncoding.cpp ++++ b/code/AssetLib/STEPParser/STEPFileEncoding.cpp +@@ -48,7 +48,7 @@ + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include ++# include + #endif + + #include +--- a/code/CMakeLists.txt ++++ b/code/CMakeLists.txt +@@ -887,6 +887,7 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(pugixml) + find_package(pugixml CONFIG REQUIRED) + ELSE() ++ find_package(pugixml REQUIRED CONFIG) + SET( Pugixml_SRCS + ../contrib/pugixml/src/pugiconfig.hpp + ../contrib/pugixml/src/pugixml.hpp +@@ -900,6 +901,7 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(utf8) + find_package(utf8cpp CONFIG REQUIRED) + ELSE() ++ find_package(utf8cpp REQUIRED CONFIG) + # utf8 is header-only, so Assimp doesn't need to do anything. + ENDIF() + +@@ -908,6 +910,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(polyclipping) + find_package(polyclipping CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_IFC_IMPORTER) ++ find_package(clipper REQUIRED CONFIG) ++ endif() + SET( Clipper_SRCS + ../contrib/clipper/clipper.hpp + ../contrib/clipper/clipper.cpp +@@ -920,6 +925,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(poly2tri) + find_package(poly2tri CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_IFC_IMPORTER) ++ find_package(poly2tri REQUIRED CONFIG) ++ endif() + SET( Poly2Tri_SRCS + ../contrib/poly2tri/poly2tri/common/shapes.cc + ../contrib/poly2tri/poly2tri/common/shapes.h +@@ -957,6 +965,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(zip) + find_package(zip CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_3MF_EXPORTER) ++ find_package(zip REQUIRED CONFIG) ++ endif() + SET( ziplib_SRCS + ../contrib/zip/src/miniz.h + ../contrib/zip/src/zip.c +@@ -978,6 +989,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(openddlparser) + find_package(openddlparser CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_OPENGEX_IMPORTER) ++ find_package(openddlparser REQUIRED CONFIG) ++ endif() + SET ( openddl_parser_SRCS + ../contrib/openddlparser/code/OpenDDLParser.cpp + ../contrib/openddlparser/code/DDLNode.cpp +@@ -1052,7 +1066,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(RapidJSON) + find_package(RapidJSON CONFIG REQUIRED) + ELSE() +- INCLUDE_DIRECTORIES("../contrib/rapidjson/include") ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ find_package(RapidJSON REQUIRED CONFIG) ++ endif() + ADD_DEFINITIONS( -DRAPIDJSON_HAS_STDSTRING=1) + option( ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR "Suppress rapidjson warning on MSVC (NOTE: breaks android build)" ON ) + if(ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR) +@@ -1065,10 +1081,12 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(stb) + find_package(stb CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_M3D_IMPORTER OR ASSIMP_BUILD_M3D_EXPORTER OR ASSIMP_BUILD_PBRT_EXPORTER) ++ find_package(stb REQUIRED CONFIG) ++ endif() + SET( stb_SRCS + ../contrib/stb/stb_image.h + ) +- INCLUDE_DIRECTORIES("../contrib") + SOURCE_GROUP( Contrib\\stb FILES ${stb_SRCS}) + ENDIF() + +@@ -1123,14 +1141,7 @@ SET( assimp_src + ${ASSIMP_EXPORTER_SRCS} + + # Third-party libraries +- ${unzip_compile_SRCS} +- ${Poly2Tri_SRCS} +- ${Clipper_SRCS} +- ${openddl_parser_SRCS} + ${open3dgc_SRCS} +- ${ziplib_SRCS} +- ${Pugixml_SRCS} +- ${stb_SRCS} + # Necessary to show the headers in the project when using the VC++ generator: + + ${PUBLIC_HEADERS} +@@ -1141,7 +1152,7 @@ ADD_DEFINITIONS( -DOPENDDLPARSER_BUILD ) + IF(NOT ASSIMP_HUNTER_ENABLED) + INCLUDE_DIRECTORIES( + ${IRRXML_INCLUDE_DIR} +- ../contrib/openddlparser/include ++ ../contrib # for Open3DGC + ) + ENDIF() + +@@ -1150,8 +1161,8 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) + INCLUDE_DIRECTORIES(${C4D_INCLUDES}) + ENDIF () + +-IF (ASSIMP_BUILD_DRACO) +- INCLUDE_DIRECTORIES(${draco_INCLUDE_DIRS}) ++if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ find_package(draco REQUIRED CONFIG) + ADD_DEFINITIONS( -DASSIMP_ENABLE_DRACO ) + ENDIF() + +@@ -1162,9 +1173,7 @@ TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp) + + # enable warnings as errors ######################################## + IF (MSVC) +- TARGET_COMPILE_OPTIONS(assimp PRIVATE /WX) + ELSE() +- TARGET_COMPILE_OPTIONS(assimp PRIVATE -Werror) + ENDIF() + + # adds C_FLAGS required to compile zip.c on old GCC 4.x compiler +@@ -1195,9 +1204,32 @@ IF(ASSIMP_HUNTER_ENABLED) + target_link_libraries(assimp PUBLIC ${draco_LIBRARIES}) + endif() + ELSE() +- TARGET_LINK_LIBRARIES(assimp ${ZLIB_LIBRARIES} ${OPENDDL_PARSER_LIBRARIES}) +- if (ASSIMP_BUILD_DRACO) +- target_link_libraries(assimp ${draco_LIBRARIES}) ++ target_link_libraries(assimp pugixml::pugixml utf8cpp) ++ if(ASSIMP_BUILD_ASSBIN_IMPORTER OR ASSIMP_BUILD_ASSBIN_EXPORTER OR ASSIMP_BUILD_ASSXML_EXPORTER OR ++ ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_FBX_IMPORTER OR ASSIMP_BUILD_Q3BSP_IMPORTER OR ++ ASSIMP_BUILD_X_IMPORTER OR ASSIMP_BUILD_XGL_IMPORTER) ++ target_link_libraries(assimp ZLIB::ZLIB) ++ endif() ++ if(ASSIMP_BUILD_IFC_IMPORTER) ++ target_link_libraries(assimp clipper::clipper) ++ endif() ++ if(ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_IFC_IMPORTER) ++ target_link_libraries(assimp poly2tri::poly2tri) ++ endif() ++ if(ASSIMP_BUILD_3MF_EXPORTER) ++ target_link_libraries(assimp zip::zip) ++ endif() ++ if(ASSIMP_BUILD_OPENGEX_IMPORTER) ++ target_link_libraries(assimp openddlparser::openddlparser) ++ endif() ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ target_link_libraries(assimp rapidjson) ++ endif() ++ if(ASSIMP_BUILD_M3D_IMPORTER OR ASSIMP_BUILD_M3D_EXPORTER OR ASSIMP_BUILD_PBRT_EXPORTER) ++ target_link_libraries(assimp stb::stb) ++ endif() ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ target_link_libraries(assimp draco::draco) + endif() + ENDIF() + +@@ -1279,8 +1311,7 @@ ENDIF() + # assimp can #include "unzip.h" + IF(NOT ASSIMP_HUNTER_ENABLED) + if (UNZIP_FOUND) +- INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS}) +- TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES}) ++ target_link_libraries(assimp minizip::minizip) + else () + INCLUDE_DIRECTORIES("../") + endif () +--- a/code/Common/Assimp.cpp ++++ b/code/Common/Assimp.cpp +@@ -1290,7 +1290,7 @@ + # endif + + # define STB_IMAGE_IMPLEMENTATION +-# include "stb/stb_image.h" ++# include "stb_image.h" + + # if _MSC_VER + # pragma warning(pop) +--- a/code/Common/BaseImporter.cpp ++++ b/code/Common/BaseImporter.cpp +@@ -330,7 +330,7 @@ + #ifdef ASSIMP_USE_HUNTER + #include + #else +-#include "../contrib/utf8cpp/source/utf8.h" ++#include + #endif + + // ------------------------------------------------------------------------------------------------ +--- a/code/Common/ZipArchiveIOSystem.cpp ++++ b/code/Common/ZipArchiveIOSystem.cpp +@@ -54,7 +54,7 @@ + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include ++# include + #endif + + namespace Assimp { +--- a/code/Pbrt/PbrtExporter.cpp ++++ b/code/Pbrt/PbrtExporter.cpp +@@ -83,7 +83,7 @@ + #include + #include + +-#include "stb/stb_image.h" ++#include "stb_image.h" + + using namespace Assimp; + diff --git a/recipes/assimp/5.x/patches/0004-unvendor-deps-5.1.6.patch b/recipes/assimp/5.x/patches/0004-unvendor-deps-5.1.6.patch new file mode 100644 index 0000000000000..67d2f67fd3661 --- /dev/null +++ b/recipes/assimp/5.x/patches/0004-unvendor-deps-5.1.6.patch @@ -0,0 +1,330 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -466,7 +466,12 @@ ELSE() + ENDIF() + + IF ( NOT ASSIMP_BUILD_ZLIB ) +- FIND_PACKAGE(ZLIB) ++ if(ASSIMP_BUILD_ASSBIN_IMPORTER OR ASSIMP_BUILD_ASSBIN_EXPORTER OR ASSIMP_BUILD_ASSXML_EXPORTER OR ++ ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_FBX_IMPORTER OR ASSIMP_BUILD_Q3BSP_IMPORTER OR ++ ASSIMP_BUILD_X_IMPORTER OR ASSIMP_BUILD_XGL_IMPORTER) ++ find_package(ZLIB REQUIRED) ++ endif() ++ set(ZLIB_FOUND TRUE) + ENDIF() + + IF( NOT ZLIB_FOUND ) +@@ -499,12 +504,14 @@ ENDIF() + + IF( NOT IOS ) + IF( NOT ASSIMP_BUILD_MINIZIP ) +- use_pkgconfig(UNZIP minizip) ++ find_package(minizip REQUIRED CONFIG) ++ set(UNZIP_FOUND TRUE) + ENDIF() + ELSE () + IF( NOT BUILD_SHARED_LIBS ) + IF( NOT ASSIMP_BUILD_MINIZIP ) +- use_pkgconfig(UNZIP minizip) ++ find_package(minizip REQUIRED CONFIG) ++ set(UNZIP_FOUND TRUE) + ENDIF() + ENDIF () + ENDIF () +--- a/code/AssetLib/3MF/D3MFExporter.cpp ++++ b/code/AssetLib/3MF/D3MFExporter.cpp +@@ -57,7 +57,7 @@ + #ifdef ASSIMP_USE_HUNTER + #include + #else +-#include ++#include + #endif + + namespace Assimp { +--- a/code/AssetLib/Blender/BlenderTessellator.h ++++ b/code/AssetLib/Blender/BlenderTessellator.h +@@ -147,7 +147,7 @@ + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" ++# include + #endif + + namespace Assimp +--- a/code/AssetLib/IFC/IFCGeometry.cpp ++++ b/code/AssetLib/IFC/IFCGeometry.cpp +@@ -53,8 +53,8 @@ + # include + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" +-# include "../contrib/clipper/clipper.hpp" ++# include ++# include + #endif + + #include +--- a/code/AssetLib/IFC/IFCOpenings.cpp ++++ b/code/AssetLib/IFC/IFCOpenings.cpp +@@ -53,8 +53,8 @@ + # include + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" +-# include "../contrib/clipper/clipper.hpp" ++# include ++# include + #endif + + #include +--- a/code/AssetLib/M3D/M3DWrapper.h ++++ b/code/AssetLib/M3D/M3DWrapper.h +@@ -59,7 +59,7 @@ + + // Share stb_image's PNG loader with other importers/exporters instead of bringing our own copy. + #define STBI_ONLY_PNG +-#include ++#include + + #include "m3d.h" + +--- a/code/AssetLib/MMD/MMDPmxParser.cpp ++++ b/code/AssetLib/MMD/MMDPmxParser.cpp +@@ -45,7 +45,7 @@ + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include "../contrib/utf8cpp/source/utf8.h" ++# include + #endif + #include + +--- a/code/AssetLib/SIB/SIBImporter.cpp ++++ b/code/AssetLib/SIB/SIBImporter.cpp +@@ -62,7 +62,7 @@ + #include + #else + //# include "../contrib/ConvertUTF/ConvertUTF.h" +-#include "../contrib/utf8cpp/source/utf8.h" ++#include + #endif + #include + #include +--- a/code/AssetLib/STEPParser/STEPFileEncoding.cpp ++++ b/code/AssetLib/STEPParser/STEPFileEncoding.cpp +@@ -48,7 +48,7 @@ + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include ++# include + #endif + + #include +--- a/code/CMakeLists.txt ++++ b/code/CMakeLists.txt +@@ -888,6 +888,7 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(pugixml) + find_package(pugixml CONFIG REQUIRED) + ELSE() ++ find_package(pugixml REQUIRED CONFIG) + SET( Pugixml_SRCS + ../contrib/pugixml/src/pugiconfig.hpp + ../contrib/pugixml/src/pugixml.hpp +@@ -901,6 +902,7 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(utf8) + find_package(utf8cpp CONFIG REQUIRED) + ELSE() ++ find_package(utf8cpp REQUIRED CONFIG) + # utf8 is header-only, so Assimp doesn't need to do anything. + ENDIF() + +@@ -909,6 +911,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(polyclipping) + find_package(polyclipping CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_IFC_IMPORTER) ++ find_package(clipper REQUIRED CONFIG) ++ endif() + SET( Clipper_SRCS + ../contrib/clipper/clipper.hpp + ../contrib/clipper/clipper.cpp +@@ -921,6 +926,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(poly2tri) + find_package(poly2tri CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_IFC_IMPORTER) ++ find_package(poly2tri REQUIRED CONFIG) ++ endif() + SET( Poly2Tri_SRCS + ../contrib/poly2tri/poly2tri/common/shapes.cc + ../contrib/poly2tri/poly2tri/common/shapes.h +@@ -960,6 +968,7 @@ IF(3MF IN_LIST ASSIMP_EXPORTERS_LIST) + hunter_add_package(zip) + find_package(zip CONFIG REQUIRED) + ELSE() ++ find_package(zip REQUIRED CONFIG) + SET( ziplib_SRCS + ../contrib/zip/src/miniz.h + ../contrib/zip/src/zip.c +@@ -982,6 +991,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(openddlparser) + find_package(openddlparser CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_OPENGEX_IMPORTER) ++ find_package(openddlparser REQUIRED CONFIG) ++ endif() + SET ( openddl_parser_SRCS + ../contrib/openddlparser/code/OpenDDLParser.cpp + ../contrib/openddlparser/code/DDLNode.cpp +@@ -1056,7 +1068,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(RapidJSON) + find_package(RapidJSON CONFIG REQUIRED) + ELSE() +- INCLUDE_DIRECTORIES("../contrib/rapidjson/include") ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ find_package(RapidJSON REQUIRED CONFIG) ++ endif() + ADD_DEFINITIONS( -DRAPIDJSON_HAS_STDSTRING=1) + option( ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR "Suppress rapidjson warning on MSVC (NOTE: breaks android build)" ON ) + if(ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR) +@@ -1069,10 +1083,12 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(stb) + find_package(stb CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_M3D_IMPORTER OR ASSIMP_BUILD_M3D_EXPORTER OR ASSIMP_BUILD_PBRT_EXPORTER) ++ find_package(stb REQUIRED CONFIG) ++ endif() + SET( stb_SRCS + ../contrib/stb/stb_image.h + ) +- INCLUDE_DIRECTORIES("../contrib") + SOURCE_GROUP( Contrib\\stb FILES ${stb_SRCS}) + ENDIF() + +@@ -1127,14 +1143,7 @@ SET( assimp_src + ${ASSIMP_EXPORTER_SRCS} + + # Third-party libraries +- ${unzip_compile_SRCS} +- ${Poly2Tri_SRCS} +- ${Clipper_SRCS} +- ${openddl_parser_SRCS} + ${open3dgc_SRCS} +- ${ziplib_SRCS} +- ${Pugixml_SRCS} +- ${stb_SRCS} + # Necessary to show the headers in the project when using the VC++ generator: + + ${PUBLIC_HEADERS} +@@ -1145,7 +1154,7 @@ ADD_DEFINITIONS( -DOPENDDLPARSER_BUILD ) + IF(NOT ASSIMP_HUNTER_ENABLED) + INCLUDE_DIRECTORIES( + ${IRRXML_INCLUDE_DIR} +- ../contrib/openddlparser/include ++ ../contrib # for Open3DGC + ) + ENDIF() + +@@ -1154,8 +1163,8 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) + INCLUDE_DIRECTORIES(${C4D_INCLUDES}) + ENDIF () + +-IF (ASSIMP_BUILD_DRACO) +- INCLUDE_DIRECTORIES(${draco_INCLUDE_DIRS}) ++if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ find_package(draco REQUIRED CONFIG) + ADD_DEFINITIONS( -DASSIMP_ENABLE_DRACO ) + ENDIF() + +@@ -1166,9 +1175,7 @@ TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp) + + # enable warnings as errors ######################################## + IF (MSVC) +- TARGET_COMPILE_OPTIONS(assimp PRIVATE /WX) + ELSE() +- TARGET_COMPILE_OPTIONS(assimp PRIVATE -Werror) + ENDIF() + + # adds C_FLAGS required to compile zip.c on old GCC 4.x compiler +@@ -1201,9 +1208,32 @@ IF(ASSIMP_HUNTER_ENABLED) + target_link_libraries(assimp PUBLIC ${draco_LIBRARIES}) + endif() + ELSE() +- TARGET_LINK_LIBRARIES(assimp ${ZLIB_LIBRARIES} ${OPENDDL_PARSER_LIBRARIES}) +- if (ASSIMP_BUILD_DRACO) +- target_link_libraries(assimp ${draco_LIBRARIES}) ++ target_link_libraries(assimp pugixml::pugixml utf8cpp) ++ if(ASSIMP_BUILD_ASSBIN_IMPORTER OR ASSIMP_BUILD_ASSBIN_EXPORTER OR ASSIMP_BUILD_ASSXML_EXPORTER OR ++ ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_FBX_IMPORTER OR ASSIMP_BUILD_Q3BSP_IMPORTER OR ++ ASSIMP_BUILD_X_IMPORTER OR ASSIMP_BUILD_XGL_IMPORTER) ++ target_link_libraries(assimp ZLIB::ZLIB) ++ endif() ++ if(ASSIMP_BUILD_IFC_IMPORTER) ++ target_link_libraries(assimp clipper::clipper) ++ endif() ++ if(ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_IFC_IMPORTER) ++ target_link_libraries(assimp poly2tri::poly2tri) ++ endif() ++ if(ASSIMP_BUILD_3MF_EXPORTER) ++ target_link_libraries(assimp zip::zip) ++ endif() ++ if(ASSIMP_BUILD_OPENGEX_IMPORTER) ++ target_link_libraries(assimp openddlparser::openddlparser) ++ endif() ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ target_link_libraries(assimp rapidjson) ++ endif() ++ if(ASSIMP_BUILD_M3D_IMPORTER OR ASSIMP_BUILD_M3D_EXPORTER OR ASSIMP_BUILD_PBRT_EXPORTER) ++ target_link_libraries(assimp stb::stb) ++ endif() ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ target_link_libraries(assimp draco::draco) + endif() + ENDIF() + +@@ -1291,8 +1321,7 @@ ENDIF() + # assimp can #include "unzip.h" + IF(NOT ASSIMP_HUNTER_ENABLED) + if (UNZIP_FOUND) +- INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS}) +- TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES}) ++ target_link_libraries(assimp minizip::minizip) + else () + INCLUDE_DIRECTORIES("../") + endif () +--- a/code/Common/Assimp.cpp ++++ b/code/Common/Assimp.cpp +@@ -1290,7 +1290,7 @@ + # endif + + # define STB_IMAGE_IMPLEMENTATION +-# include "stb/stb_image.h" ++# include "stb_image.h" + + # if _MSC_VER + # pragma warning(pop) +--- a/code/Common/BaseImporter.cpp ++++ b/code/Common/BaseImporter.cpp +@@ -331,7 +331,7 @@ + #ifdef ASSIMP_USE_HUNTER + #include + #else +-#include "../contrib/utf8cpp/source/utf8.h" ++#include + #endif + + // ------------------------------------------------------------------------------------------------ +--- a/code/Pbrt/PbrtExporter.cpp ++++ b/code/Pbrt/PbrtExporter.cpp +@@ -83,7 +83,7 @@ + #include + #include + +-#include "stb/stb_image.h" ++#include "stb_image.h" + + using namespace Assimp; + diff --git a/recipes/assimp/5.x/patches/0005-fix-unzip.patch b/recipes/assimp/5.x/patches/0005-fix-unzip.patch new file mode 100644 index 0000000000000..c6980a6575974 --- /dev/null +++ b/recipes/assimp/5.x/patches/0005-fix-unzip.patch @@ -0,0 +1,13 @@ +# https://github.com/assimp/assimp/issues/4334 +--- a/code/Common/ZipArchiveIOSystem.cpp ++++ b/code/Common/ZipArchiveIOSystem.cpp +@@ -196,7 +196,9 @@ + zlib_filefunc_def mapping; + + mapping.zopen_file = (open_file_func)open; ++#ifdef ZOPENDISK64 + mapping.zopendisk_file = (opendisk_file_func)opendisk; ++#endif + mapping.zread_file = (read_file_func)read; + mapping.zwrite_file = (write_file_func)write; + mapping.ztell_file = (tell_file_func)tell; diff --git a/recipes/assimp/5.x/patches/0006-unvendor-deps-5.2.x.patch b/recipes/assimp/5.x/patches/0006-unvendor-deps-5.2.x.patch new file mode 100644 index 0000000000000..2a1e7bc39e620 --- /dev/null +++ b/recipes/assimp/5.x/patches/0006-unvendor-deps-5.2.x.patch @@ -0,0 +1,330 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -488,7 +488,12 @@ ELSE() + ENDIF() + + IF ( NOT ASSIMP_BUILD_ZLIB ) +- FIND_PACKAGE(ZLIB) ++ if(ASSIMP_BUILD_ASSBIN_IMPORTER OR ASSIMP_BUILD_ASSBIN_EXPORTER OR ASSIMP_BUILD_ASSXML_EXPORTER OR ++ ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_FBX_IMPORTER OR ASSIMP_BUILD_Q3BSP_IMPORTER OR ++ ASSIMP_BUILD_X_IMPORTER OR ASSIMP_BUILD_XGL_IMPORTER) ++ find_package(ZLIB REQUIRED) ++ endif() ++ set(ZLIB_FOUND TRUE) + ENDIF() + + IF( NOT ZLIB_FOUND ) +@@ -521,12 +526,14 @@ ENDIF() + + IF( NOT IOS ) + IF( NOT ASSIMP_BUILD_MINIZIP ) +- use_pkgconfig(UNZIP minizip) ++ find_package(minizip REQUIRED CONFIG) ++ set(UNZIP_FOUND TRUE) + ENDIF() + ELSE () + IF( NOT BUILD_SHARED_LIBS ) + IF( NOT ASSIMP_BUILD_MINIZIP ) +- use_pkgconfig(UNZIP minizip) ++ find_package(minizip REQUIRED CONFIG) ++ set(UNZIP_FOUND TRUE) + ENDIF() + ENDIF () + ENDIF () +--- a/code/AssetLib/3MF/D3MFExporter.cpp ++++ b/code/AssetLib/3MF/D3MFExporter.cpp +@@ -57,7 +57,7 @@ + #ifdef ASSIMP_USE_HUNTER + #include + #else +-#include ++#include + #endif + + namespace Assimp { +--- a/code/AssetLib/Blender/BlenderTessellator.h ++++ b/code/AssetLib/Blender/BlenderTessellator.h +@@ -147,7 +147,7 @@ + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" ++# include + #endif + + namespace Assimp +--- a/code/AssetLib/IFC/IFCGeometry.cpp ++++ b/code/AssetLib/IFC/IFCGeometry.cpp +@@ -53,8 +53,8 @@ + # include + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" +-# include "../contrib/clipper/clipper.hpp" ++# include ++# include + #endif + + #include +--- a/code/AssetLib/IFC/IFCOpenings.cpp ++++ b/code/AssetLib/IFC/IFCOpenings.cpp +@@ -53,8 +53,8 @@ + # include + # include + #else +-# include "../contrib/poly2tri/poly2tri/poly2tri.h" +-# include "../contrib/clipper/clipper.hpp" ++# include ++# include + #endif + + #include +--- a/code/AssetLib/M3D/M3DWrapper.h ++++ b/code/AssetLib/M3D/M3DWrapper.h +@@ -59,7 +59,7 @@ + + // Share stb_image's PNG loader with other importers/exporters instead of bringing our own copy. + #define STBI_ONLY_PNG +-#include ++#include + + #include "m3d.h" + +--- a/code/AssetLib/MMD/MMDPmxParser.cpp ++++ b/code/AssetLib/MMD/MMDPmxParser.cpp +@@ -45,7 +45,7 @@ + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include "../contrib/utf8cpp/source/utf8.h" ++# include + #endif + #include + +--- a/code/AssetLib/SIB/SIBImporter.cpp ++++ b/code/AssetLib/SIB/SIBImporter.cpp +@@ -59,7 +59,7 @@ + #ifdef ASSIMP_USE_HUNTER + #include + #else +-#include "../contrib/utf8cpp/source/utf8.h" ++#include + #endif + #include + #include +--- a/code/AssetLib/STEPParser/STEPFileEncoding.cpp ++++ b/code/AssetLib/STEPParser/STEPFileEncoding.cpp +@@ -48,7 +48,7 @@ + #ifdef ASSIMP_USE_HUNTER + # include + #else +-# include ++# include + #endif + + #include +--- a/code/CMakeLists.txt ++++ b/code/CMakeLists.txt +@@ -899,6 +899,7 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(pugixml) + find_package(pugixml CONFIG REQUIRED) + ELSE() ++ find_package(pugixml REQUIRED CONFIG) + SET( Pugixml_SRCS + ../contrib/pugixml/src/pugiconfig.hpp + ../contrib/pugixml/src/pugixml.hpp +@@ -912,6 +913,7 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(utf8) + find_package(utf8cpp CONFIG REQUIRED) + ELSE() ++ find_package(utf8cpp REQUIRED CONFIG) + # utf8 is header-only, so Assimp doesn't need to do anything. + ENDIF() + +@@ -920,6 +922,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(polyclipping) + find_package(polyclipping CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_IFC_IMPORTER) ++ find_package(clipper REQUIRED CONFIG) ++ endif() + SET( Clipper_SRCS + ../contrib/clipper/clipper.hpp + ../contrib/clipper/clipper.cpp +@@ -932,6 +937,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(poly2tri) + find_package(poly2tri CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_IFC_IMPORTER) ++ find_package(poly2tri REQUIRED CONFIG) ++ endif() + SET( Poly2Tri_SRCS + ../contrib/poly2tri/poly2tri/common/shapes.cc + ../contrib/poly2tri/poly2tri/common/shapes.h +@@ -971,6 +979,7 @@ IF(3MF IN_LIST ASSIMP_EXPORTERS_LIST) + hunter_add_package(zip) + find_package(zip CONFIG REQUIRED) + ELSE() ++ find_package(zip REQUIRED CONFIG) + SET( ziplib_SRCS + ../contrib/zip/src/miniz.h + ../contrib/zip/src/zip.c +@@ -993,6 +1002,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(openddlparser) + find_package(openddlparser CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_OPENGEX_IMPORTER) ++ find_package(openddlparser REQUIRED CONFIG) ++ endif() + SET ( openddl_parser_SRCS + ../contrib/openddlparser/code/OpenDDLParser.cpp + ../contrib/openddlparser/code/DDLNode.cpp +@@ -1067,7 +1079,9 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(RapidJSON) + find_package(RapidJSON CONFIG REQUIRED) + ELSE() +- INCLUDE_DIRECTORIES("../contrib/rapidjson/include") ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ find_package(RapidJSON REQUIRED CONFIG) ++ endif() + ADD_DEFINITIONS( -DRAPIDJSON_HAS_STDSTRING=1) + option( ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR "Suppress rapidjson warning on MSVC (NOTE: breaks android build)" ON ) + if(ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR) +@@ -1080,10 +1094,12 @@ IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(stb) + find_package(stb CONFIG REQUIRED) + ELSE() ++ if(ASSIMP_BUILD_M3D_IMPORTER OR ASSIMP_BUILD_M3D_EXPORTER OR ASSIMP_BUILD_PBRT_EXPORTER) ++ find_package(stb REQUIRED CONFIG) ++ endif() + SET( stb_SRCS + ../contrib/stb/stb_image.h + ) +- INCLUDE_DIRECTORIES("../contrib") + SOURCE_GROUP( Contrib\\stb FILES ${stb_SRCS}) + ENDIF() + +@@ -1138,14 +1154,7 @@ SET( assimp_src + ${ASSIMP_EXPORTER_SRCS} + + # Third-party libraries +- ${unzip_compile_SRCS} +- ${Poly2Tri_SRCS} +- ${Clipper_SRCS} +- ${openddl_parser_SRCS} + ${open3dgc_SRCS} +- ${ziplib_SRCS} +- ${Pugixml_SRCS} +- ${stb_SRCS} + # Necessary to show the headers in the project when using the VC++ generator: + + ${PUBLIC_HEADERS} +@@ -1156,7 +1165,7 @@ ADD_DEFINITIONS( -DOPENDDLPARSER_BUILD ) + IF(NOT ASSIMP_HUNTER_ENABLED) + INCLUDE_DIRECTORIES( + ${IRRXML_INCLUDE_DIR} +- ../contrib/openddlparser/include ++ ../contrib # for Open3DGC + ) + ENDIF() + +@@ -1165,8 +1174,8 @@ IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) + INCLUDE_DIRECTORIES(${C4D_INCLUDES}) + ENDIF () + +-IF (ASSIMP_BUILD_DRACO) +- INCLUDE_DIRECTORIES(${draco_INCLUDE_DIRS}) ++if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ find_package(draco REQUIRED CONFIG) + ADD_DEFINITIONS( -DASSIMP_ENABLE_DRACO ) + ENDIF() + +@@ -1177,9 +1186,7 @@ TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp) + + # enable warnings as errors ######################################## + IF (MSVC) +- TARGET_COMPILE_OPTIONS(assimp PRIVATE /WX) + ELSE() +- TARGET_COMPILE_OPTIONS(assimp PRIVATE -Werror) + ENDIF() + + # adds C_FLAGS required to compile zip.c on old GCC 4.x compiler +@@ -1212,9 +1219,32 @@ IF(ASSIMP_HUNTER_ENABLED) + target_link_libraries(assimp PUBLIC ${draco_LIBRARIES}) + endif() + ELSE() +- TARGET_LINK_LIBRARIES(assimp ${ZLIB_LIBRARIES} ${OPENDDL_PARSER_LIBRARIES}) +- if (ASSIMP_BUILD_DRACO) +- target_link_libraries(assimp ${draco_LIBRARIES}) ++ target_link_libraries(assimp pugixml::pugixml utf8cpp) ++ if(ASSIMP_BUILD_ASSBIN_IMPORTER OR ASSIMP_BUILD_ASSBIN_EXPORTER OR ASSIMP_BUILD_ASSXML_EXPORTER OR ++ ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_FBX_IMPORTER OR ASSIMP_BUILD_Q3BSP_IMPORTER OR ++ ASSIMP_BUILD_X_IMPORTER OR ASSIMP_BUILD_XGL_IMPORTER) ++ target_link_libraries(assimp ZLIB::ZLIB) ++ endif() ++ if(ASSIMP_BUILD_IFC_IMPORTER) ++ target_link_libraries(assimp clipper::clipper) ++ endif() ++ if(ASSIMP_BUILD_BLEND_IMPORTER OR ASSIMP_BUILD_IFC_IMPORTER) ++ target_link_libraries(assimp poly2tri::poly2tri) ++ endif() ++ if(ASSIMP_BUILD_3MF_EXPORTER) ++ target_link_libraries(assimp zip::zip) ++ endif() ++ if(ASSIMP_BUILD_OPENGEX_IMPORTER) ++ target_link_libraries(assimp openddlparser::openddlparser) ++ endif() ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ target_link_libraries(assimp rapidjson) ++ endif() ++ if(ASSIMP_BUILD_M3D_IMPORTER OR ASSIMP_BUILD_M3D_EXPORTER OR ASSIMP_BUILD_PBRT_EXPORTER) ++ target_link_libraries(assimp stb::stb) ++ endif() ++ if(ASSIMP_BUILD_GLTF_IMPORTER OR ASSIMP_BUILD_GLTF_EXPORTER) ++ target_link_libraries(assimp draco::draco) + endif() + ENDIF() + +@@ -1302,8 +1332,7 @@ ENDIF() + # assimp can #include "unzip.h" + IF(NOT ASSIMP_HUNTER_ENABLED) + if (UNZIP_FOUND) +- INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS}) +- TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES}) ++ target_link_libraries(assimp minizip::minizip) + else () + INCLUDE_DIRECTORIES("../") + endif () +--- a/code/Common/Assimp.cpp ++++ b/code/Common/Assimp.cpp +@@ -1290,7 +1290,7 @@ + # endif + + # define STB_IMAGE_IMPLEMENTATION +-# include "stb/stb_image.h" ++# include "stb_image.h" + + # if _MSC_VER + # pragma warning(pop) +--- a/code/Common/BaseImporter.cpp ++++ b/code/Common/BaseImporter.cpp +@@ -332,7 +332,7 @@ + #ifdef ASSIMP_USE_HUNTER + #include + #else +-#include "../contrib/utf8cpp/source/utf8.h" ++#include + #endif + + // ------------------------------------------------------------------------------------------------ +--- a/code/Pbrt/PbrtExporter.cpp ++++ b/code/Pbrt/PbrtExporter.cpp +@@ -83,7 +83,7 @@ + #include + #include + +-#include "stb/stb_image.h" ++#include "stb_image.h" + + using namespace Assimp; + diff --git a/recipes/assimp/5.x/test_package/CMakeLists.txt b/recipes/assimp/5.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6b0a89276dbf1 --- /dev/null +++ b/recipes/assimp/5.x/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C CXX) + +find_package(assimp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE assimp::assimp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +add_executable(${PROJECT_NAME}_c test_package.c) +target_link_libraries(${PROJECT_NAME}_c PRIVATE assimp::assimp) diff --git a/recipes/assimp/5.0.x/test_package/box.obj b/recipes/assimp/5.x/test_package/box.obj similarity index 100% rename from recipes/assimp/5.0.x/test_package/box.obj rename to recipes/assimp/5.x/test_package/box.obj diff --git a/recipes/assimp/5.x/test_package/conanfile.py b/recipes/assimp/5.x/test_package/conanfile.py new file mode 100644 index 0000000000000..93ba652962cbf --- /dev/null +++ b/recipes/assimp/5.x/test_package/conanfile.py @@ -0,0 +1,31 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + obj_path = os.path.join(self.source_folder, "box.obj") + + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(f"{bin_path} {obj_path}", env="conanrun") + + bin_c_path = os.path.join(self.cpp.build.bindirs[0], "test_package_c") + self.run(f"{bin_c_path} {obj_path}", env="conanrun") diff --git a/recipes/assimp/5.0.x/test_package/test_package.c b/recipes/assimp/5.x/test_package/test_package.c similarity index 100% rename from recipes/assimp/5.0.x/test_package/test_package.c rename to recipes/assimp/5.x/test_package/test_package.c diff --git a/recipes/assimp/5.0.x/test_package/test_package.cpp b/recipes/assimp/5.x/test_package/test_package.cpp similarity index 100% rename from recipes/assimp/5.0.x/test_package/test_package.cpp rename to recipes/assimp/5.x/test_package/test_package.cpp diff --git a/recipes/assimp/5.x/test_v1_package/CMakeLists.txt b/recipes/assimp/5.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/assimp/5.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/assimp/5.x/test_v1_package/conanfile.py b/recipes/assimp/5.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..32dae739b46ce --- /dev/null +++ b/recipes/assimp/5.x/test_v1_package/conanfile.py @@ -0,0 +1,22 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + obj_path = os.path.join(self.source_folder, os.pardir, "test_package", "box.obj") + + bin_path = os.path.join("bin", "test_package") + self.run(f"{bin_path} {obj_path}", run_environment=True) + + bin_c_path = os.path.join("bin", "test_package_c") + self.run(f"{bin_c_path} {obj_path}", run_environment=True) diff --git a/recipes/assimp/config.yml b/recipes/assimp/config.yml index 199724cde794c..2542b27436840 100644 --- a/recipes/assimp/config.yml +++ b/recipes/assimp/config.yml @@ -1,5 +1,11 @@ versions: - "5.0.0": - folder: "5.0.x" + "5.2.2": + folder: "5.x" + "5.1.6": + folder: "5.x" + "5.1.0": + folder: "5.x" "5.0.1": - folder: "5.0.x" + folder: "5.x" + "5.0.0": + folder: "5.x" diff --git a/recipes/astro-informatics-so3/all/conanfile.py b/recipes/astro-informatics-so3/all/conanfile.py index bb25ceafd2ae6..24be830f3db99 100644 --- a/recipes/astro-informatics-so3/all/conanfile.py +++ b/recipes/astro-informatics-so3/all/conanfile.py @@ -1,7 +1,7 @@ from conans import CMake, ConanFile, tools from conans.errors import ConanInvalidConfiguration -from glob import glob -import os + +required_conan_version = ">=1.33.0" class AstroInformaticsSO3(ConanFile): @@ -12,9 +12,10 @@ class AstroInformaticsSO3(ConanFile): description = "Fast and accurate Wigner transforms" settings = "os", "arch", "compiler", "build_type" topics = ("physics", "astrophysics", "radio interferometry") + options = {"fPIC": [True, False]} default_options = {"fPIC": True} - requires = "fftw/3.3.9", "ssht/1.3.7" + generators = "cmake", "cmake_find_package" exports_sources = ["CMakeLists.txt"] @@ -26,25 +27,33 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + def configure(self): del self.settings.compiler.cppstd del self.settings.compiler.libcxx - def config_options(self): + def requirements(self): + self.requires("fftw/3.3.9") + self.requires("ssht/1.3.7") + + def validate(self): if self.settings.compiler == "Visual Studio": raise ConanInvalidConfiguration( - "SO3 requires C99 support for complex numbers." + "Visual Studio not supported, since SO3 requires C99 support for complex numbers" ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob("so3-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) @property def cmake(self): if not hasattr(self, "_cmake"): self._cmake = CMake(self) + self._cmake.definitions["conan_deps"] = False self._cmake.definitions["BUILD_TESTING"] = False self._cmake.configure(build_folder=self._build_subfolder) return self._cmake @@ -58,5 +67,5 @@ def package(self): def package_info(self): self.cpp_info.libs = ["astro-informatics-so3"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] diff --git a/recipes/asyncplusplus/all/conanfile.py b/recipes/asyncplusplus/all/conanfile.py index c91a26eb9e341..3a587ac42b02e 100644 --- a/recipes/asyncplusplus/all/conanfile.py +++ b/recipes/asyncplusplus/all/conanfile.py @@ -1,25 +1,30 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir, save import os +import textwrap + +required_conan_version = ">=1.50.0" -from conans import ConanFile, CMake, tools class AsyncplusplusConan(ConanFile): name = "asyncplusplus" description = "Async++ concurrency framework for C++11" license = "MIT" - topics = ("conan", "asyncplusplus", "async", "parallel", "task", "scheduler") + topics = ("async", "parallel", "task", "scheduler") homepage = "https://github.com/Amanieu/asyncplusplus" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "CMakeLists.txt" - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } def config_options(self): if self.settings.os == "Windows": @@ -28,36 +33,65 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"Async++": "Async++::Async++"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): - # FIXME: official CMake target is exported without namespace - self.cpp_info.names["cmake_find_package"] = "Async++" - self.cpp_info.names["cmake_find_package_multi"] = "Async++" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "Async++") + self.cpp_info.set_property("cmake_target_name", "Async++") + self.cpp_info.libs = ["async++"] if not self.options.shared: self.cpp_info.defines = ["LIBASYNC_STATIC"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["pthread"] + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "Async++" + self.cpp_info.names["cmake_find_package_multi"] = "Async++" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/asyncplusplus/all/test_package/CMakeLists.txt b/recipes/asyncplusplus/all/test_package/CMakeLists.txt index 9f08ceabfda13..9a56b06843998 100644 --- a/recipes/asyncplusplus/all/test_package/CMakeLists.txt +++ b/recipes/asyncplusplus/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(Async++ REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} Async++::Async++) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE Async++) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/asyncplusplus/all/test_package/conanfile.py b/recipes/asyncplusplus/all/test_package/conanfile.py index c6580760bfee2..3a8c6c5442b33 100644 --- a/recipes/asyncplusplus/all/test_package/conanfile.py +++ b/recipes/asyncplusplus/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/asyncplusplus/all/test_v1_package/CMakeLists.txt b/recipes/asyncplusplus/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3fba019a21faa --- /dev/null +++ b/recipes/asyncplusplus/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Async++ REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Async++) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/asyncplusplus/all/test_v1_package/conanfile.py b/recipes/asyncplusplus/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/asyncplusplus/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/at-spi2-atk/all/conanfile.py b/recipes/at-spi2-atk/all/conanfile.py index 6f2046b991e0f..2fc37026d8c0f 100644 --- a/recipes/at-spi2-atk/all/conanfile.py +++ b/recipes/at-spi2-atk/all/conanfile.py @@ -2,6 +2,7 @@ from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.33.0" class AtSPI2AtkConan(ConanFile): name = "at-spi2-atk" @@ -30,31 +31,42 @@ def _source_subfolder(self): @property def _build_subfolder(self): return "build_subfolder" - + def validate(self): if self.settings.os not in ("Linux", "FreeBSD"): raise ConanInvalidConfiguration("at-spi2-atk is only supported on Linux and FreeBSD") + if self.options.shared and (not self.options["glib"].shared + or not self.options["at-spi2-core"].shared + or not self.options["atk"].shared): + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) + def configure(self): if self.options.shared: del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + if self.options.shared: + self.options["at-spi2-core"].shared = True + self.options["atk"].shared = True + self.options["glib"].shared = True + def build_requirements(self): - self.build_requires('meson/0.57.1') - self.build_requires('pkgconf/1.7.3') + self.build_requires("meson/0.62.2") + self.build_requires('pkgconf/1.7.4') def requirements(self): - self.requires('at-spi2-core/2.39.1') - self.requires('atk/2.36.0') - self.requires('glib/2.67.6') - self.requires('libxml2/2.9.10') + self.requires("at-spi2-core/2.44.1") + self.requires("atk/2.38.0") + self.requires("glib/2.73.0") + self.requires("libxml2/2.9.14") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) def _configure_meson(self): if self._meson: @@ -79,3 +91,8 @@ def package_info(self): self.cpp_info.libs = tools.collect_libs(self) self.cpp_info.includedirs = [os.path.join('include', 'at-spi2-atk', '2.0')] self.cpp_info.names['pkg_config'] = 'atk-bridge-2.0' + + def package_id(self): + self.info.requires["at-spi2-core"].full_package_mode() + self.info.requires["atk"].full_package_mode() + self.info.requires["glib"].full_package_mode() diff --git a/recipes/at-spi2-atk/all/test_package/conanfile.py b/recipes/at-spi2-atk/all/test_package/conanfile.py index bd7165a553cf4..d4128b0450777 100644 --- a/recipes/at-spi2-atk/all/test_package/conanfile.py +++ b/recipes/at-spi2-atk/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/at-spi2-core/all/conandata.yml b/recipes/at-spi2-core/all/conandata.yml index 6550f86472e0d..571d10adab672 100644 --- a/recipes/at-spi2-core/all/conandata.yml +++ b/recipes/at-spi2-core/all/conandata.yml @@ -5,9 +5,19 @@ sources: "2.39.1": url: "http://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.39/at-spi2-core-2.39.1.tar.xz" sha256: "44d2b042e47d25571581efff673af0a8cd79531babbad2b043784879e15e4228" - "2.40.0": - url: "https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.40/at-spi2-core-2.40.0.tar.xz" - sha256: "4196a7d30a0051e52a67b8ce4283fe79ae5e4e14a725719934565adf1d333429" - "2.40.1": - url: "https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.40/at-spi2-core-2.40.1.tar.xz" - sha256: "9f66e3a4ee42db897af478a826b1366d7011a6d55ddb7e9d4bfeb3300ab23856" + "2.40.3": + url: "https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.40/at-spi2-core-2.40.3.tar.xz" + sha256: "e49837c2ad30d71e1f29ca8e0968a54b95030272f7ff40b89b48968653f37a5c" + "2.42.0": + url: "https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.42/at-spi2-core-2.42.0.tar.xz" + sha256: "4b5da10e94fa3c6195f95222438f63a0234b99ef9df772c7640e82baeaa6e386" + "2.44.0": + url: "https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.44/at-spi2-core-2.44.0.tar.xz" + sha256: "7eee3cf285b089060fd6b6e51b3eb2cacf752cca3a082c7f4c2c5ab841e51353" + "2.44.1": + sha256: "4beb23270ba6cf7caf20b597354d75194d89afb69d2efcf15f4271688ba6f746" + url: "https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.44/at-spi2-core-2.44.1.tar.xz" +patches: + "2.44.0": + - base_path: "source_subfolder" + patch_file: "patches/08036a4c4491eea57d7b713bb4440f541584204b.patch" diff --git a/recipes/at-spi2-core/all/conanfile.py b/recipes/at-spi2-core/all/conanfile.py index 05bd05b99fb91..e6ca0e2427585 100644 --- a/recipes/at-spi2-core/all/conanfile.py +++ b/recipes/at-spi2-core/all/conanfile.py @@ -1,11 +1,12 @@ from conans import ConanFile, Meson, tools +from conans.errors import ConanInvalidConfiguration import os class AtSpi2CoreConan(ConanFile): name = "at-spi2-core" description = "It provides a Service Provider Interface for the Assistive Technologies available on the GNOME platform and a library against which applications can be linked" - topics = ("conan", "atk", "accessibility") + topics = "atk", "accessibility" url = "https://github.com/conan-io/conan-center-index" homepage = "https://gitlab.gnome.org/GNOME/at-spi2-core/" license = "LGPL-2.1-or-later" @@ -26,34 +27,51 @@ class AtSpi2CoreConan(ConanFile): @property def _source_subfolder(self): return "source_subfolder" - + @property def _build_subfolder(self): return "build_subfolder" + _meson = None + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def configure(self): if self.options.shared: del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd - + if self.options.shared: + self.options["glib"].shared = True + def build_requirements(self): - self.build_requires("meson/0.57.1") - self.build_requires("pkgconf/1.7.3") - + self.build_requires("meson/0.62.2") + self.build_requires("pkgconf/1.7.4") + def requirements(self): - self.requires("glib/2.67.6") + self.requires("glib/2.73.0") if self.options.with_x11: self.requires("xorg/system") self.requires("dbus/1.12.20") + def validate(self): + if self.options.shared and not self.options["glib"].shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("only linux is supported by this recipe") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) def _configure_meson(self): - meson = Meson(self) + if self._meson: + return self._meson + self._meson = Meson(self) defs = {} defs["introspection"] = "no" defs["docs"] = "false" @@ -62,10 +80,16 @@ def _configure_meson(self): args.append("--datadir=%s" % os.path.join(self.package_folder, "res")) args.append("--localedir=%s" % os.path.join(self.package_folder, "res")) args.append("--wrap-mode=nofallback") - meson.configure(defs=defs, build_folder=self._build_subfolder, source_folder=self._source_subfolder, pkg_config_paths=".", args=args) - return meson + self._meson.configure(defs=defs, build_folder=self._build_subfolder, source_folder=self._source_subfolder, pkg_config_paths=".", args=args) + return self._meson def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + if tools.Version(self.version) >= "2.42.0": + tools.replace_in_file(os.path.join(self._source_subfolder, "bus", "meson.build"), + "if x11_dep.found()", + "if x11_option == 'yes'") meson = self._configure_meson() meson.build() @@ -82,3 +106,5 @@ def package_info(self): self.cpp_info.includedirs = ["include/at-spi-2.0"] self.cpp_info.names["pkg_config"] = "atspi-2" + def package_id(self): + self.info.requires["glib"].full_package_mode() diff --git a/recipes/at-spi2-core/all/patches/08036a4c4491eea57d7b713bb4440f541584204b.patch b/recipes/at-spi2-core/all/patches/08036a4c4491eea57d7b713bb4440f541584204b.patch new file mode 100644 index 0000000000000..ce10b7a2bce56 --- /dev/null +++ b/recipes/at-spi2-core/all/patches/08036a4c4491eea57d7b713bb4440f541584204b.patch @@ -0,0 +1,37 @@ +From 08036a4c4491eea57d7b713bb4440f541584204b Mon Sep 17 00:00:00 2001 +From: Mike Gorse +Date: Mon, 21 Mar 2022 10:19:03 -0500 +Subject: [PATCH] Fix build with X11 disabled + +Closes #51 +--- + registryd/deviceeventcontroller.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c +index 8a321adc..3068ec4b 100644 +--- a/registryd/deviceeventcontroller.c ++++ b/registryd/deviceeventcontroller.c +@@ -1720,16 +1720,16 @@ spi_dec_synth_keysym (SpiDEController *controller, long keysym) + if (synth_mods != modifiers) { + lock_mods = synth_mods & ~modifiers; + spi_dec_plat_lock_modifiers (controller, lock_mods); +- if (modifiers & LockMask) +- spi_dec_plat_unlock_modifiers (controller, LockMask); ++ if (modifiers & SPI_KEYMASK_SHIFTLOCK) ++ spi_dec_plat_unlock_modifiers (controller, SPI_KEYMASK_SHIFTLOCK); + } + spi_dec_plat_synth_keycode_press (controller, key_synth_code); + spi_dec_plat_synth_keycode_release (controller, key_synth_code); + + if (synth_mods != modifiers) { + spi_dec_plat_unlock_modifiers (controller, lock_mods); +- if (modifiers & LockMask) +- spi_dec_plat_lock_modifiers (controller, LockMask); ++ if (modifiers & SPI_KEYMASK_SHIFTLOCK) ++ spi_dec_plat_lock_modifiers (controller, SPI_KEYMASK_SHIFTLOCK); + } + return TRUE; + } +-- +GitLab diff --git a/recipes/at-spi2-core/all/test_package/conanfile.py b/recipes/at-spi2-core/all/test_package/conanfile.py index bd7165a553cf4..d4128b0450777 100644 --- a/recipes/at-spi2-core/all/test_package/conanfile.py +++ b/recipes/at-spi2-core/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/at-spi2-core/config.yml b/recipes/at-spi2-core/config.yml index 8da9a2c347d09..75bf09030a311 100644 --- a/recipes/at-spi2-core/config.yml +++ b/recipes/at-spi2-core/config.yml @@ -3,7 +3,17 @@ versions: folder: all "2.39.1": folder: all - "2.40.0": + "2.40.3": folder: all - "2.40.1": + "2.42.0": folder: all + "2.44.0": + folder: all + "2.44.1": + folder: all + "2.45.1": + folder: new + "2.45.90": + folder: new + "2.46.0": + folder: new diff --git a/recipes/at-spi2-core/new/conandata.yml b/recipes/at-spi2-core/new/conandata.yml new file mode 100644 index 0000000000000..4ea30e6fd2d79 --- /dev/null +++ b/recipes/at-spi2-core/new/conandata.yml @@ -0,0 +1,20 @@ +sources: + "2.46.0": + url: "https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.46/at-spi2-core-2.46.0.tar.xz" + sha256: "aa0c86c79f7a8d67bae49a5b7a5ab08430c608cffe6e33bf47a72f41ab03c3d0" + "2.45.90": + url: "https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.45/at-spi2-core-2.45.90.tar.xz" + sha256: "e9050ad3c24937548396b2377f2fcdb9321ce2daffad35e7554e8f6ad850ab0d" + "2.45.1": + sha256: "ba95f346e93108fbb3462c62437081d582154db279b4052dedc52a706828b192" + url: "https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.45/at-spi2-core-2.45.1.tar.xz" +patches: + "2.46.0": + - base_path: "source_subfolder" + patch_file: "patches/93.patch" + "2.45.90": + - base_path: "source_subfolder" + patch_file: "patches/93.patch" + "2.45.1": + - base_path: "source_subfolder" + patch_file: "patches/93.patch" diff --git a/recipes/at-spi2-core/new/conanfile.py b/recipes/at-spi2-core/new/conanfile.py new file mode 100644 index 0000000000000..389943e02b001 --- /dev/null +++ b/recipes/at-spi2-core/new/conanfile.py @@ -0,0 +1,128 @@ +from conans import ConanFile, Meson, tools +from conans.errors import ConanInvalidConfiguration +import os + + +class AtSpi2CoreConan(ConanFile): + name = "at-spi2-core" + description = "It provides a Service Provider Interface for the Assistive Technologies available on the GNOME platform and a library against which applications can be linked" + topics = ("atk", "accessibility") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gitlab.gnome.org/GNOME/at-spi2-core/" + license = "LGPL-2.1-or-later" + generators = "pkg_config" + + provides = "at-spi2-atk", "atk" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_x11": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_x11": False, + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + _meson = None + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.options.shared: + self.options["glib"].shared = True + + def build_requirements(self): + self.build_requires("meson/0.62.2") + self.build_requires("pkgconf/1.7.4") + + def requirements(self): + self.requires("glib/2.73.0") + if self.options.with_x11: + self.requires("xorg/system") + self.requires("dbus/1.12.20") + + def validate(self): + if self.options.shared and not self.options["glib"].shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("only linux is supported by this recipe") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + def _configure_meson(self): + if self._meson: + return self._meson + self._meson = Meson(self) + defs = {} + defs["introspection"] = "no" + defs["docs"] = "false" + defs["x11"] = "yes" if self.options.with_x11 else "no" + args=[] + args.append("--datadir=%s" % os.path.join(self.package_folder, "res")) + args.append("--localedir=%s" % os.path.join(self.package_folder, "res")) + args.append("--wrap-mode=nofallback") + self._meson.configure(defs=defs, build_folder=self._build_subfolder, source_folder=self._source_subfolder, pkg_config_paths=".", args=args) + return self._meson + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + tools.replace_in_file(os.path.join(self._source_subfolder, "bus", "meson.build"), + "if x11_dep.found()", + "if x11_option == 'yes'") + tools.replace_in_file(os.path.join(self._source_subfolder, 'meson.build'), + "subdir('tests')", + "#subdir('tests')") + tools.replace_in_file(os.path.join(self._source_subfolder, 'meson.build'), + "libxml_dep = dependency('libxml-2.0', version: libxml_req_version)", + "#libxml_dep = dependency('libxml-2.0', version: libxml_req_version)") + meson = self._configure_meson() + meson.build() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + meson = self._configure_meson() + meson.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "etc")) + + + def package_info(self): + self.cpp_info.components["atspi"].libs = ['atspi'] + self.cpp_info.components["atspi"].includedirs = ["include/at-spi-2.0"] + self.cpp_info.components["atspi"].requires = ["dbus::dbus", "glib::glib"] + self.cpp_info.components["atspi"].names["pkg_config"] = "atspi-2" + + self.cpp_info.components["atk"].libs = ["atk-1.0"] + self.cpp_info.components["atk"].includedirs = ['include/atk-1.0'] + self.cpp_info.components["atk"].requires = ["glib::glib"] + self.cpp_info.components["atk"].names['pkg_config'] = 'atk' + + self.cpp_info.components["atk-bridge"].libs = ['atk-bridge-2.0'] + self.cpp_info.components["atk-bridge"].includedirs = [os.path.join('include', 'at-spi2-atk', '2.0')] + self.cpp_info.components["atk-bridge"].requires = ["dbus::dbus", "atk", "glib::glib", "atspi"] + self.cpp_info.components["atk-bridge"].names['pkg_config'] = 'atk-bridge-2.0' + + def package_id(self): + self.info.requires["glib"].full_package_mode() diff --git a/recipes/at-spi2-core/new/patches/93.patch b/recipes/at-spi2-core/new/patches/93.patch new file mode 100644 index 0000000000000..7ff4a19473df8 --- /dev/null +++ b/recipes/at-spi2-core/new/patches/93.patch @@ -0,0 +1,521 @@ +From 99a88f23978d668802f63470c7f75ba3886166e1 Mon Sep 17 00:00:00 2001 +From: ericLemanissier +Date: Tue, 5 Jul 2022 10:13:54 +0000 +Subject: [PATCH] add license file + +fixes GNOME/at-spi2-core#78 +--- + COPYING | 502 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 502 insertions(+) + create mode 100644 COPYING + +diff --git a/COPYING b/COPYING +new file mode 100644 +index 00000000..4362b491 +--- /dev/null ++++ b/COPYING +@@ -0,0 +1,502 @@ ++ GNU LESSER GENERAL PUBLIC LICENSE ++ Version 2.1, February 1999 ++ ++ Copyright (C) 1991, 1999 Free Software Foundation, Inc. ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ Everyone is permitted to copy and distribute verbatim copies ++ of this license document, but changing it is not allowed. ++ ++[This is the first released version of the Lesser GPL. It also counts ++ as the successor of the GNU Library Public License, version 2, hence ++ the version number 2.1.] ++ ++ Preamble ++ ++ The licenses for most software are designed to take away your ++freedom to share and change it. By contrast, the GNU General Public ++Licenses are intended to guarantee your freedom to share and change ++free software--to make sure the software is free for all its users. ++ ++ This license, the Lesser General Public License, applies to some ++specially designated software packages--typically libraries--of the ++Free Software Foundation and other authors who decide to use it. You ++can use it too, but we suggest you first think carefully about whether ++this license or the ordinary General Public License is the better ++strategy to use in any particular case, based on the explanations below. ++ ++ When we speak of free software, we are referring to freedom of use, ++not price. Our General Public Licenses are designed to make sure that ++you have the freedom to distribute copies of free software (and charge ++for this service if you wish); that you receive source code or can get ++it if you want it; that you can change the software and use pieces of ++it in new free programs; and that you are informed that you can do ++these things. ++ ++ To protect your rights, we need to make restrictions that forbid ++distributors to deny you these rights or to ask you to surrender these ++rights. These restrictions translate to certain responsibilities for ++you if you distribute copies of the library or if you modify it. ++ ++ For example, if you distribute copies of the library, whether gratis ++or for a fee, you must give the recipients all the rights that we gave ++you. You must make sure that they, too, receive or can get the source ++code. If you link other code with the library, you must provide ++complete object files to the recipients, so that they can relink them ++with the library after making changes to the library and recompiling ++it. And you must show them these terms so they know their rights. ++ ++ We protect your rights with a two-step method: (1) we copyright the ++library, and (2) we offer you this license, which gives you legal ++permission to copy, distribute and/or modify the library. ++ ++ To protect each distributor, we want to make it very clear that ++there is no warranty for the free library. Also, if the library is ++modified by someone else and passed on, the recipients should know ++that what they have is not the original version, so that the original ++author's reputation will not be affected by problems that might be ++introduced by others. ++ ++ Finally, software patents pose a constant threat to the existence of ++any free program. We wish to make sure that a company cannot ++effectively restrict the users of a free program by obtaining a ++restrictive license from a patent holder. Therefore, we insist that ++any patent license obtained for a version of the library must be ++consistent with the full freedom of use specified in this license. ++ ++ Most GNU software, including some libraries, is covered by the ++ordinary GNU General Public License. This license, the GNU Lesser ++General Public License, applies to certain designated libraries, and ++is quite different from the ordinary General Public License. We use ++this license for certain libraries in order to permit linking those ++libraries into non-free programs. ++ ++ When a program is linked with a library, whether statically or using ++a shared library, the combination of the two is legally speaking a ++combined work, a derivative of the original library. The ordinary ++General Public License therefore permits such linking only if the ++entire combination fits its criteria of freedom. The Lesser General ++Public License permits more lax criteria for linking other code with ++the library. ++ ++ We call this license the "Lesser" General Public License because it ++does Less to protect the user's freedom than the ordinary General ++Public License. It also provides other free software developers Less ++of an advantage over competing non-free programs. These disadvantages ++are the reason we use the ordinary General Public License for many ++libraries. However, the Lesser license provides advantages in certain ++special circumstances. ++ ++ For example, on rare occasions, there may be a special need to ++encourage the widest possible use of a certain library, so that it becomes ++a de-facto standard. To achieve this, non-free programs must be ++allowed to use the library. A more frequent case is that a free ++library does the same job as widely used non-free libraries. In this ++case, there is little to gain by limiting the free library to free ++software only, so we use the Lesser General Public License. ++ ++ In other cases, permission to use a particular library in non-free ++programs enables a greater number of people to use a large body of ++free software. For example, permission to use the GNU C Library in ++non-free programs enables many more people to use the whole GNU ++operating system, as well as its variant, the GNU/Linux operating ++system. ++ ++ Although the Lesser General Public License is Less protective of the ++users' freedom, it does ensure that the user of a program that is ++linked with the Library has the freedom and the wherewithal to run ++that program using a modified version of the Library. ++ ++ The precise terms and conditions for copying, distribution and ++modification follow. Pay close attention to the difference between a ++"work based on the library" and a "work that uses the library". The ++former contains code derived from the library, whereas the latter must ++be combined with the library in order to run. ++ ++ GNU LESSER GENERAL PUBLIC LICENSE ++ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION ++ ++ 0. This License Agreement applies to any software library or other ++program which contains a notice placed by the copyright holder or ++other authorized party saying it may be distributed under the terms of ++this Lesser General Public License (also called "this License"). ++Each licensee is addressed as "you". ++ ++ A "library" means a collection of software functions and/or data ++prepared so as to be conveniently linked with application programs ++(which use some of those functions and data) to form executables. ++ ++ The "Library", below, refers to any such software library or work ++which has been distributed under these terms. A "work based on the ++Library" means either the Library or any derivative work under ++copyright law: that is to say, a work containing the Library or a ++portion of it, either verbatim or with modifications and/or translated ++straightforwardly into another language. (Hereinafter, translation is ++included without limitation in the term "modification".) ++ ++ "Source code" for a work means the preferred form of the work for ++making modifications to it. For a library, complete source code means ++all the source code for all modules it contains, plus any associated ++interface definition files, plus the scripts used to control compilation ++and installation of the library. ++ ++ Activities other than copying, distribution and modification are not ++covered by this License; they are outside its scope. The act of ++running a program using the Library is not restricted, and output from ++such a program is covered only if its contents constitute a work based ++on the Library (independent of the use of the Library in a tool for ++writing it). Whether that is true depends on what the Library does ++and what the program that uses the Library does. ++ ++ 1. You may copy and distribute verbatim copies of the Library's ++complete source code as you receive it, in any medium, provided that ++you conspicuously and appropriately publish on each copy an ++appropriate copyright notice and disclaimer of warranty; keep intact ++all the notices that refer to this License and to the absence of any ++warranty; and distribute a copy of this License along with the ++Library. ++ ++ You may charge a fee for the physical act of transferring a copy, ++and you may at your option offer warranty protection in exchange for a ++fee. ++ ++ 2. You may modify your copy or copies of the Library or any portion ++of it, thus forming a work based on the Library, and copy and ++distribute such modifications or work under the terms of Section 1 ++above, provided that you also meet all of these conditions: ++ ++ a) The modified work must itself be a software library. ++ ++ b) You must cause the files modified to carry prominent notices ++ stating that you changed the files and the date of any change. ++ ++ c) You must cause the whole of the work to be licensed at no ++ charge to all third parties under the terms of this License. ++ ++ d) If a facility in the modified Library refers to a function or a ++ table of data to be supplied by an application program that uses ++ the facility, other than as an argument passed when the facility ++ is invoked, then you must make a good faith effort to ensure that, ++ in the event an application does not supply such function or ++ table, the facility still operates, and performs whatever part of ++ its purpose remains meaningful. ++ ++ (For example, a function in a library to compute square roots has ++ a purpose that is entirely well-defined independent of the ++ application. Therefore, Subsection 2d requires that any ++ application-supplied function or table used by this function must ++ be optional: if the application does not supply it, the square ++ root function must still compute square roots.) ++ ++These requirements apply to the modified work as a whole. If ++identifiable sections of that work are not derived from the Library, ++and can be reasonably considered independent and separate works in ++themselves, then this License, and its terms, do not apply to those ++sections when you distribute them as separate works. But when you ++distribute the same sections as part of a whole which is a work based ++on the Library, the distribution of the whole must be on the terms of ++this License, whose permissions for other licensees extend to the ++entire whole, and thus to each and every part regardless of who wrote ++it. ++ ++Thus, it is not the intent of this section to claim rights or contest ++your rights to work written entirely by you; rather, the intent is to ++exercise the right to control the distribution of derivative or ++collective works based on the Library. ++ ++In addition, mere aggregation of another work not based on the Library ++with the Library (or with a work based on the Library) on a volume of ++a storage or distribution medium does not bring the other work under ++the scope of this License. ++ ++ 3. You may opt to apply the terms of the ordinary GNU General Public ++License instead of this License to a given copy of the Library. To do ++this, you must alter all the notices that refer to this License, so ++that they refer to the ordinary GNU General Public License, version 2, ++instead of to this License. (If a newer version than version 2 of the ++ordinary GNU General Public License has appeared, then you can specify ++that version instead if you wish.) Do not make any other change in ++these notices. ++ ++ Once this change is made in a given copy, it is irreversible for ++that copy, so the ordinary GNU General Public License applies to all ++subsequent copies and derivative works made from that copy. ++ ++ This option is useful when you wish to copy part of the code of ++the Library into a program that is not a library. ++ ++ 4. You may copy and distribute the Library (or a portion or ++derivative of it, under Section 2) in object code or executable form ++under the terms of Sections 1 and 2 above provided that you accompany ++it with the complete corresponding machine-readable source code, which ++must be distributed under the terms of Sections 1 and 2 above on a ++medium customarily used for software interchange. ++ ++ If distribution of object code is made by offering access to copy ++from a designated place, then offering equivalent access to copy the ++source code from the same place satisfies the requirement to ++distribute the source code, even though third parties are not ++compelled to copy the source along with the object code. ++ ++ 5. A program that contains no derivative of any portion of the ++Library, but is designed to work with the Library by being compiled or ++linked with it, is called a "work that uses the Library". Such a ++work, in isolation, is not a derivative work of the Library, and ++therefore falls outside the scope of this License. ++ ++ However, linking a "work that uses the Library" with the Library ++creates an executable that is a derivative of the Library (because it ++contains portions of the Library), rather than a "work that uses the ++library". The executable is therefore covered by this License. ++Section 6 states terms for distribution of such executables. ++ ++ When a "work that uses the Library" uses material from a header file ++that is part of the Library, the object code for the work may be a ++derivative work of the Library even though the source code is not. ++Whether this is true is especially significant if the work can be ++linked without the Library, or if the work is itself a library. The ++threshold for this to be true is not precisely defined by law. ++ ++ If such an object file uses only numerical parameters, data ++structure layouts and accessors, and small macros and small inline ++functions (ten lines or less in length), then the use of the object ++file is unrestricted, regardless of whether it is legally a derivative ++work. (Executables containing this object code plus portions of the ++Library will still fall under Section 6.) ++ ++ Otherwise, if the work is a derivative of the Library, you may ++distribute the object code for the work under the terms of Section 6. ++Any executables containing that work also fall under Section 6, ++whether or not they are linked directly with the Library itself. ++ ++ 6. As an exception to the Sections above, you may also combine or ++link a "work that uses the Library" with the Library to produce a ++work containing portions of the Library, and distribute that work ++under terms of your choice, provided that the terms permit ++modification of the work for the customer's own use and reverse ++engineering for debugging such modifications. ++ ++ You must give prominent notice with each copy of the work that the ++Library is used in it and that the Library and its use are covered by ++this License. You must supply a copy of this License. If the work ++during execution displays copyright notices, you must include the ++copyright notice for the Library among them, as well as a reference ++directing the user to the copy of this License. Also, you must do one ++of these things: ++ ++ a) Accompany the work with the complete corresponding ++ machine-readable source code for the Library including whatever ++ changes were used in the work (which must be distributed under ++ Sections 1 and 2 above); and, if the work is an executable linked ++ with the Library, with the complete machine-readable "work that ++ uses the Library", as object code and/or source code, so that the ++ user can modify the Library and then relink to produce a modified ++ executable containing the modified Library. (It is understood ++ that the user who changes the contents of definitions files in the ++ Library will not necessarily be able to recompile the application ++ to use the modified definitions.) ++ ++ b) Use a suitable shared library mechanism for linking with the ++ Library. A suitable mechanism is one that (1) uses at run time a ++ copy of the library already present on the user's computer system, ++ rather than copying library functions into the executable, and (2) ++ will operate properly with a modified version of the library, if ++ the user installs one, as long as the modified version is ++ interface-compatible with the version that the work was made with. ++ ++ c) Accompany the work with a written offer, valid for at ++ least three years, to give the same user the materials ++ specified in Subsection 6a, above, for a charge no more ++ than the cost of performing this distribution. ++ ++ d) If distribution of the work is made by offering access to copy ++ from a designated place, offer equivalent access to copy the above ++ specified materials from the same place. ++ ++ e) Verify that the user has already received a copy of these ++ materials or that you have already sent this user a copy. ++ ++ For an executable, the required form of the "work that uses the ++Library" must include any data and utility programs needed for ++reproducing the executable from it. However, as a special exception, ++the materials to be distributed need not include anything that is ++normally distributed (in either source or binary form) with the major ++components (compiler, kernel, and so on) of the operating system on ++which the executable runs, unless that component itself accompanies ++the executable. ++ ++ It may happen that this requirement contradicts the license ++restrictions of other proprietary libraries that do not normally ++accompany the operating system. Such a contradiction means you cannot ++use both them and the Library together in an executable that you ++distribute. ++ ++ 7. You may place library facilities that are a work based on the ++Library side-by-side in a single library together with other library ++facilities not covered by this License, and distribute such a combined ++library, provided that the separate distribution of the work based on ++the Library and of the other library facilities is otherwise ++permitted, and provided that you do these two things: ++ ++ a) Accompany the combined library with a copy of the same work ++ based on the Library, uncombined with any other library ++ facilities. This must be distributed under the terms of the ++ Sections above. ++ ++ b) Give prominent notice with the combined library of the fact ++ that part of it is a work based on the Library, and explaining ++ where to find the accompanying uncombined form of the same work. ++ ++ 8. You may not copy, modify, sublicense, link with, or distribute ++the Library except as expressly provided under this License. Any ++attempt otherwise to copy, modify, sublicense, link with, or ++distribute the Library is void, and will automatically terminate your ++rights under this License. However, parties who have received copies, ++or rights, from you under this License will not have their licenses ++terminated so long as such parties remain in full compliance. ++ ++ 9. You are not required to accept this License, since you have not ++signed it. However, nothing else grants you permission to modify or ++distribute the Library or its derivative works. These actions are ++prohibited by law if you do not accept this License. Therefore, by ++modifying or distributing the Library (or any work based on the ++Library), you indicate your acceptance of this License to do so, and ++all its terms and conditions for copying, distributing or modifying ++the Library or works based on it. ++ ++ 10. Each time you redistribute the Library (or any work based on the ++Library), the recipient automatically receives a license from the ++original licensor to copy, distribute, link with or modify the Library ++subject to these terms and conditions. You may not impose any further ++restrictions on the recipients' exercise of the rights granted herein. ++You are not responsible for enforcing compliance by third parties with ++this License. ++ ++ 11. If, as a consequence of a court judgment or allegation of patent ++infringement or for any other reason (not limited to patent issues), ++conditions are imposed on you (whether by court order, agreement or ++otherwise) that contradict the conditions of this License, they do not ++excuse you from the conditions of this License. If you cannot ++distribute so as to satisfy simultaneously your obligations under this ++License and any other pertinent obligations, then as a consequence you ++may not distribute the Library at all. For example, if a patent ++license would not permit royalty-free redistribution of the Library by ++all those who receive copies directly or indirectly through you, then ++the only way you could satisfy both it and this License would be to ++refrain entirely from distribution of the Library. ++ ++If any portion of this section is held invalid or unenforceable under any ++particular circumstance, the balance of the section is intended to apply, ++and the section as a whole is intended to apply in other circumstances. ++ ++It is not the purpose of this section to induce you to infringe any ++patents or other property right claims or to contest validity of any ++such claims; this section has the sole purpose of protecting the ++integrity of the free software distribution system which is ++implemented by public license practices. Many people have made ++generous contributions to the wide range of software distributed ++through that system in reliance on consistent application of that ++system; it is up to the author/donor to decide if he or she is willing ++to distribute software through any other system and a licensee cannot ++impose that choice. ++ ++This section is intended to make thoroughly clear what is believed to ++be a consequence of the rest of this License. ++ ++ 12. If the distribution and/or use of the Library is restricted in ++certain countries either by patents or by copyrighted interfaces, the ++original copyright holder who places the Library under this License may add ++an explicit geographical distribution limitation excluding those countries, ++so that distribution is permitted only in or among countries not thus ++excluded. In such case, this License incorporates the limitation as if ++written in the body of this License. ++ ++ 13. The Free Software Foundation may publish revised and/or new ++versions of the Lesser General Public License from time to time. ++Such new versions will be similar in spirit to the present version, ++but may differ in detail to address new problems or concerns. ++ ++Each version is given a distinguishing version number. If the Library ++specifies a version number of this License which applies to it and ++"any later version", you have the option of following the terms and ++conditions either of that version or of any later version published by ++the Free Software Foundation. If the Library does not specify a ++license version number, you may choose any version ever published by ++the Free Software Foundation. ++ ++ 14. If you wish to incorporate parts of the Library into other free ++programs whose distribution conditions are incompatible with these, ++write to the author to ask for permission. For software which is ++copyrighted by the Free Software Foundation, write to the Free ++Software Foundation; we sometimes make exceptions for this. Our ++decision will be guided by the two goals of preserving the free status ++of all derivatives of our free software and of promoting the sharing ++and reuse of software generally. ++ ++ NO WARRANTY ++ ++ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO ++WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. ++EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR ++OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY ++KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE ++IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ++PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE ++LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME ++THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. ++ ++ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN ++WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY ++AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU ++FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR ++CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE ++LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING ++RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A ++FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF ++SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH ++DAMAGES. ++ ++ END OF TERMS AND CONDITIONS ++ ++ How to Apply These Terms to Your New Libraries ++ ++ If you develop a new library, and you want it to be of the greatest ++possible use to the public, we recommend making it free software that ++everyone can redistribute and change. You can do so by permitting ++redistribution under these terms (or, alternatively, under the terms of the ++ordinary General Public License). ++ ++ To apply these terms, attach the following notices to the library. It is ++safest to attach them to the start of each source file to most effectively ++convey the exclusion of warranty; and each file should have at least the ++"copyright" line and a pointer to where the full notice is found. ++ ++ ++ Copyright (C) ++ ++ This library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ This library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ ++Also add information on how to contact you by electronic and paper mail. ++ ++You should also get your employer (if you work as a programmer) or your ++school, if any, to sign a "copyright disclaimer" for the library, if ++necessary. Here is a sample; alter the names: ++ ++ Yoyodyne, Inc., hereby disclaims all copyright interest in the ++ library `Frob' (a library for tweaking knobs) written by James Random Hacker. ++ ++ , 1 April 1990 ++ Ty Coon, President of Vice ++ ++That's all there is to it! +-- +GitLab diff --git a/recipes/at-spi2-core/new/test_package/CMakeLists.txt b/recipes/at-spi2-core/new/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..afa2476357074 --- /dev/null +++ b/recipes/at-spi2-core/new/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/at-spi2-core/new/test_package/conanfile.py b/recipes/at-spi2-core/new/test_package/conanfile.py new file mode 100644 index 0000000000000..d4128b0450777 --- /dev/null +++ b/recipes/at-spi2-core/new/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/at-spi2-core/new/test_package/test_package.c b/recipes/at-spi2-core/new/test_package/test_package.c new file mode 100644 index 0000000000000..c155308c155ba --- /dev/null +++ b/recipes/at-spi2-core/new/test_package/test_package.c @@ -0,0 +1,9 @@ +#include "atspi/atspi.h" +#include "assert.h" + +int main() +{ + atspi_init (); + assert(atspi_get_desktop_count() > 0); + return atspi_exit(); +} diff --git a/recipes/atk/all/conandata.yml b/recipes/atk/all/conandata.yml index d31f8308dacf8..be9240fbf54e1 100644 --- a/recipes/atk/all/conandata.yml +++ b/recipes/atk/all/conandata.yml @@ -1,4 +1,12 @@ sources: + "2.38.0": + url: "https://download.gnome.org/sources/atk/2.38/atk-2.38.0.tar.xz" + sha256: "ac4de2a4ef4bd5665052952fe169657e65e895c5057dffb3c2a810f6191a0c36" "2.36.0": url: "https://download.gnome.org/sources/atk/2.36/atk-2.36.0.tar.xz" sha256: "fb76247e369402be23f1f5c65d38a9639c1164d934e40f6a9cf3c9e96b652788" + +patches: + "2.38.0": + - patch_file: "patches/define_dllmain_only_when_shared.patch" + base_path: "source_subfolder" diff --git a/recipes/atk/all/conanfile.py b/recipes/atk/all/conanfile.py index 82eac875ca94b..c160c33f34f91 100644 --- a/recipes/atk/all/conanfile.py +++ b/recipes/atk/all/conanfile.py @@ -5,7 +5,7 @@ required_conan_version = ">=1.29" -class LibnameConan(ConanFile): +class AtkConan(ConanFile): name = "atk" description = "set of accessibility interfaces that are implemented by other toolkits and applications" topics = ("conan", "atk", "accessibility") @@ -27,22 +27,32 @@ class LibnameConan(ConanFile): _source_subfolder = "source_subfolder" _build_subfolder = "build_subfolder" + exports_sources = "patches/**" + def config_options(self): if self.settings.os == 'Windows': del self.options.fPIC - + def build_requirements(self): - self.build_requires('meson/0.55.3') - self.build_requires('pkgconf/1.7.3') - + self.build_requires('meson/0.60.2') + self.build_requires('pkgconf/1.7.4') + def requirements(self): - self.requires('glib/2.66.2') + self.requires('glib/2.73.0') def configure(self): if self.options.shared: del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + if self.options.shared: + self.options["glib"].shared = True + + def validate(self): + if self.options.shared and not self.options["glib"].shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) def source(self): tools.get(**self.conan_data["sources"][self.version]) @@ -60,7 +70,12 @@ def _configure_meson(self): meson.configure(defs=defs, build_folder=self._build_subfolder, source_folder=self._source_subfolder, pkg_config_paths='.', args=args) return meson + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + def build(self): + self._patch_sources() tools.replace_in_file(os.path.join(self._source_subfolder, 'meson.build'), "subdir('tests')", "#subdir('tests')") @@ -82,3 +97,6 @@ def package(self): def package_info(self): self.cpp_info.libs = tools.collect_libs(self) self.cpp_info.includedirs = ['include/atk-1.0'] + + def package_id(self): + self.info.requires["glib"].full_package_mode() diff --git a/recipes/atk/all/patches/define_dllmain_only_when_shared.patch b/recipes/atk/all/patches/define_dllmain_only_when_shared.patch new file mode 100644 index 0000000000000..98af12c8b5189 --- /dev/null +++ b/recipes/atk/all/patches/define_dllmain_only_when_shared.patch @@ -0,0 +1,19 @@ +commit 2c8b80761a9ef6b381c909cf05dda711e7e9b85c +Author: Hesham Essam +Date: Fri Jun 3 15:58:03 2022 +0200 + + Define DllMain only when building a dll + +diff --git a/atk/atkprivate.c b/atk/atkprivate.c +index e414bf2..988acc8 100644 +--- a/atk/atkprivate.c ++++ b/atk/atkprivate.c +@@ -30,7 +30,7 @@ + + #include "atkprivate.h" + +-#ifdef G_OS_WIN32 ++#if defined(G_OS_WIN32) && defined(DLL_EXPORT) + + #define STRICT + #include diff --git a/recipes/atk/config.yml b/recipes/atk/config.yml index 32ff4be30cd17..0a1f46c973b32 100644 --- a/recipes/atk/config.yml +++ b/recipes/atk/config.yml @@ -1,3 +1,5 @@ versions: + "2.38.0": + folder: all "2.36.0": folder: all diff --git a/recipes/audiofile/all/conandata.yml b/recipes/audiofile/all/conandata.yml index ab80089154513..042cc12d06dd1 100644 --- a/recipes/audiofile/all/conandata.yml +++ b/recipes/audiofile/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.1.0": + url: "https://github.com/adamstark/AudioFile/archive/1.1.0.tar.gz" + sha256: "7546e39ca17ac09c653f46bfecce4a9936fae3784209ad53094915c78792a327" "1.0.9": url: "https://github.com/adamstark/AudioFile/archive/1.0.9.tar.gz" sha256: "1d609b80496fc5c688d8e83086cdcad5b60ddb20f02d160f80be271fab97c4c0" diff --git a/recipes/audiofile/all/conanfile.py b/recipes/audiofile/all/conanfile.py index 34f5e77630f55..0d083108cea08 100644 --- a/recipes/audiofile/all/conanfile.py +++ b/recipes/audiofile/all/conanfile.py @@ -1,32 +1,47 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +required_conan_version = ">=1.50.0" + class AudiofileConan(ConanFile): name = "audiofile" description = "A simple C++11 library for reading and writing audio files." - topics = ("conan", "audiofile", "audio", "file-format", "wav", "aif") - license = "GPL-3.0-or-later" + topics = ("audiofile", "audio", "file-format", "wav", "aif") + license = "MIT" homepage = "https://github.com/adamstark/AudioFile" url = "https://github.com/conan-io/conan-center-index" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + if Version(self.version) < "1.1.0": + self.license = "GPL-3.0-or-later" def package_id(self): - self.info.header_only() + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("AudioFile-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("AudioFile.h", dst="include", src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "AudioFile.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/audiofile/all/test_package/CMakeLists.txt b/recipes/audiofile/all/test_package/CMakeLists.txt index 33ae887aa6aea..6f7178f4a8927 100644 --- a/recipes/audiofile/all/test_package/CMakeLists.txt +++ b/recipes/audiofile/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(audiofile REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE audiofile::audiofile) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/audiofile/all/test_package/conanfile.py b/recipes/audiofile/all/test_package/conanfile.py index 4ea4ccf936bd3..fb1d035fc5b12 100644 --- a/recipes/audiofile/all/test_package/conanfile.py +++ b/recipes/audiofile/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") wav_path = os.path.join(self.source_folder, "sine.wav") - self.run("{0} {1}".format(bin_path, wav_path), run_environment=True) + self.run(f"{bin_path} {wav_path}", env="conanrun") diff --git a/recipes/audiofile/all/test_v1_package/CMakeLists.txt b/recipes/audiofile/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..60fb00c9f3f14 --- /dev/null +++ b/recipes/audiofile/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(audiofile REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE audiofile::audiofile) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/audiofile/all/test_v1_package/conanfile.py b/recipes/audiofile/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..21642db6ce1ba --- /dev/null +++ b/recipes/audiofile/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + wav_path = os.path.join(self.source_folder, os.pardir, "test_package", "sine.wav") + self.run(f"{bin_path} {wav_path}", run_environment=True) diff --git a/recipes/audiofile/config.yml b/recipes/audiofile/config.yml index 1c656ce0b375f..5fc24e2e9c188 100644 --- a/recipes/audiofile/config.yml +++ b/recipes/audiofile/config.yml @@ -1,4 +1,6 @@ versions: + "1.1.0": + folder: all "1.0.9": folder: all "1.0.8": diff --git a/recipes/autoconf-archive/all/conandata.yml b/recipes/autoconf-archive/all/conandata.yml new file mode 100644 index 0000000000000..528425d762278 --- /dev/null +++ b/recipes/autoconf-archive/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2021.02.19": + url: "https://ftpmirror.gnu.org/autoconf-archive/autoconf-archive-2021.02.19.tar.xz" + sha256: "e8a6eb9d28ddcba8ffef3fa211653239e9bf239aba6a01a6b7cfc7ceaec69cbd" diff --git a/recipes/autoconf-archive/all/conanfile.py b/recipes/autoconf-archive/all/conanfile.py new file mode 100644 index 0000000000000..b4dbfc5911f9b --- /dev/null +++ b/recipes/autoconf-archive/all/conanfile.py @@ -0,0 +1,59 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +import os + +required_conan_version = ">=1.33.0" + + +class AutoconfArchiveConan(ConanFile): + name = "autoconf-archive" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.gnu.org/software/autoconf-archive/" + license = "GPL-2.0-or-later" + description = "The GNU Autoconf Archive is a collection of more than 500 macros for GNU Autoconf" + topics = ("conan", "GNU", "autoconf", "autoconf-archive", "macro") + settings = "os" + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if not self._autotools: + self._autotools = AutoToolsBuildEnvironment(self, win_bash=self._settings_build.os == "Windows") + self._autotools.configure() + return self._autotools + + def build(self): + with tools.chdir(os.path.join(self._source_subfolder)): + self._autotools = self._configure_autotools() + self._autotools.make() + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + with tools.chdir(os.path.join(self._source_subfolder)): + self._autotools = self._configure_autotools() + self._autotools.install() + + tools.mkdir(os.path.join(self.package_folder, "res")) + tools.rename(os.path.join(self.package_folder, "share", "aclocal"), + os.path.join(self.package_folder, "res", "aclocal")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + aclocal_path = tools.unix_path(os.path.join(self.package_folder, "res", "aclocal")) + self.output.info("Appending AUTOMAKE_CONAN_INCLUDES environment var: {}".format(aclocal_path)) + self.env_info.AUTOMAKE_CONAN_INCLUDES.append(aclocal_path) diff --git a/recipes/autoconf-archive/all/test_package/Makefile.am b/recipes/autoconf-archive/all/test_package/Makefile.am new file mode 100644 index 0000000000000..b5165c3af4560 --- /dev/null +++ b/recipes/autoconf-archive/all/test_package/Makefile.am @@ -0,0 +1,2 @@ +bin_PROGRAMS = test_package +test_package_sources = test_package.c diff --git a/recipes/autoconf-archive/all/test_package/conanfile.py b/recipes/autoconf-archive/all/test_package/conanfile.py new file mode 100644 index 0000000000000..76133cc91c338 --- /dev/null +++ b/recipes/autoconf-archive/all/test_package/conanfile.py @@ -0,0 +1,49 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +import contextlib +import os +import shutil + +required_conan_version = ">=1.36.0" + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + exports_sources = "configure.ac", "Makefile.am", "test_package.c" + test_type = "explicit" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + self.build_requires("automake/1.16.3") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self): + env = { + "CC": "cl -nologo", + "CXX": "cl -nologo", + } + with tools.environment_append(env): + yield + else: + yield + + def build(self): + for src in self.exports_sources: + shutil.copy(os.path.join(self.source_folder, src), self.build_folder) + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), run_environment=True, win_bash=self._settings_build.os == "Windows") + with self._build_context(): + autotools = AutoToolsBuildEnvironment(self, win_bash=self._settings_build.os == "Windows") + autotools.libs = [] + autotools.configure() + autotools.make() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join(".", "test_package")) diff --git a/recipes/autoconf-archive/all/test_package/configure.ac b/recipes/autoconf-archive/all/test_package/configure.ac new file mode 100644 index 0000000000000..e74fbe8a4a2dd --- /dev/null +++ b/recipes/autoconf-archive/all/test_package/configure.ac @@ -0,0 +1,15 @@ +AC_INIT([test_package], [1.0]) +AC_CONFIG_SRCDIR([test_package.c]) +AC_CONFIG_AUX_DIR([autostuff]) +AM_INIT_AUTOMAKE([foreign]) +AC_PROG_CC +m4_pattern_forbid([^AX_], + [Unexpanded AX_ macro found. Please install GNU autoconf-archive.]) +AX_CXX_BOOL() +AX_CXX_HAVE_VECTOR_AT() +AX_CXX_HAVE_BIND() +AX_PRINTF_SIZE_T() +AX_CHECK_AWK_INDEX() +AX_BERKELEY_DB() +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/recipes/autoconf-archive/all/test_package/test_package.c b/recipes/autoconf-archive/all/test_package/test_package.c new file mode 100644 index 0000000000000..88b53a74dc6fb --- /dev/null +++ b/recipes/autoconf-archive/all/test_package/test_package.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello world from test_package.c\n"); + return 0; +} diff --git a/recipes/autoconf-archive/config.yml b/recipes/autoconf-archive/config.yml new file mode 100644 index 0000000000000..be18dee9e6714 --- /dev/null +++ b/recipes/autoconf-archive/config.yml @@ -0,0 +1,3 @@ +versions: + "2021.02.19": + folder: all diff --git a/recipes/autoconf/all/conandata.yml b/recipes/autoconf/all/conandata.yml index 0dfca4d3f4fe2..97adbd2afcde0 100644 --- a/recipes/autoconf/all/conandata.yml +++ b/recipes/autoconf/all/conandata.yml @@ -8,23 +8,13 @@ sources: patches: "2.71": - patch_file: "patches/2.71-0001-autom4te-relocatable.patch" - base_path: "source_subfolder" - patch_file: "patches/2.71-0002-no-perl-path-in-shebang.patch" - base_path: "source_subfolder" - patch_file: "patches/2.71-0003-uppercase-autom4te_perllibdir.patch" - base_path: "source_subfolder" - patch_file: "patches/2.71-0004-no-embedded-m4-paths.patch" - base_path: "source_subfolder" - patch_file: "patches/2.71-0005-disable-man-regeneration.patch" - base_path: "source_subfolder" - patch_file: "patches/2.71-0006-autoconf-no-embedded-trailer_m4-path.patch" - base_path: "source_subfolder" "2.69": - patch_file: "patches/2.69-0001-autom4te-relocatable.patch" - base_path: "source_subfolder" - patch_file: "patches/2.69-0002-no-perl-path-in-shebang.patch" - base_path: "source_subfolder" - patch_file: "patches/2.69-0003-uppercase-autom4te_perllibdir.patch" - base_path: "source_subfolder" - patch_file: "patches/2.69-0004-no-embedded-m4-paths.patch" - base_path: "source_subfolder" diff --git a/recipes/autoconf/all/conanfile.py b/recipes/autoconf/all/conanfile.py index ccf07d56ad31e..ceb06b4b4a4be 100644 --- a/recipes/autoconf/all/conanfile.py +++ b/recipes/autoconf/all/conanfile.py @@ -1,120 +1,138 @@ +from conan import ConanFile +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rmdir, apply_conandata_patches, replace_in_file, export_conandata_patches +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import unix_path, is_msvc +from conans import tools as tools_legacy import os -from conans import AutoToolsBuildEnvironment, ConanFile, tools + +required_conan_version = ">=1.52.0" class AutoconfConan(ConanFile): name = "autoconf" + description = ( + "Autoconf is an extensible package of M4 macros that produce shell " + "scripts to automatically configure software source code packages" + ) + license = ("GPL-2.0-or-later", "GPL-3.0-or-later") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.gnu.org/software/autoconf/" - description = "Autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages" - topics = ("conan", "autoconf", "configure", "build") - license = ("GPL-2.0-or-later", "GPL-3.0-or-later") - exports_sources = "patches/**" - settings = "os", "arch", "compiler" - _autotools = None + topics = ("autoconf", "configure", "build") + settings = "os", "arch", "compiler", "build_type" @property - def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") + def _settings_build(self): + # TODO: Remove for Conan v2 + return getattr(self, "settings_build", self.settings) - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): - self.requires("m4/1.4.18") + self.requires("m4/1.4.19") def package_id(self): - del self.info.settings.arch - del self.info.settings.compiler - # The m4 requirement does not change the contents of this package - self.info.requires.clear() + self.info.clear() def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") + self.tool_requires("m4/1.4.19") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") - @property - def _datarootdir(self): - return os.path.join(self.package_folder, "bin", "share") + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ + "--datarootdir=${prefix}/res", + ]) - @property - def _autoconf_datarootdir(self): - return os.path.join(self._datarootdir, "autoconf") - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - datarootdir = self._datarootdir - prefix = self.package_folder if self.settings.os == "Windows": - datarootdir = tools.unix_path(datarootdir) - prefix = tools.unix_path(prefix) - conf_args = [ - "--datarootdir={}".format(datarootdir), - "--prefix={}".format(prefix), - ] - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return self._autotools - - def _patch_files(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + if is_msvc(self): + build = "{}-{}-{}".format( + "x86_64" if self._settings_build.arch == "x86_64" else "i686", + "pc" if self._settings_build.arch == "x86" else "win64", + "mingw32") + host = "{}-{}-{}".format( + "x86_64" if self.settings.arch == "x86_64" else "i686", + "pc" if self.settings.arch == "x86" else "win64", + "mingw32") + tc.configure_args.append(f"--build={build}") + tc.configure_args.append(f"--host={host}") + + env = tc.environment() + env.define_path("INSTALL", unix_path(self, os.path.join(self.source_folder, "build-aux", "install-sh"))) + tc.generate(env) + + def _patch_sources(self): + apply_conandata_patches(self) + replace_in_file(self, os.path.join(self.source_folder, "Makefile.in"), + "M4 = /usr/bin/env m4", "#M4 = /usr/bin/env m4") def build(self): - self._patch_files() - autotools = self._configure_autotools() + self._patch_sources() + autotools = Autotools(self) + autotools.configure() autotools.make() def package(self): - self.copy("COPYING*", src=self._source_subfolder, dst="licenses") - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, "bin", "share", "info")) - tools.rmdir(os.path.join(self.package_folder, "bin", "share", "man")) + autotools = Autotools(self) + # TODO: can be replaced by autotools.install() if required_conan_version = ">=1.54.0" + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) - if self.settings.os == "Windows": - binpath = os.path.join(self.package_folder, "bin") - for filename in os.listdir(binpath): - fullpath = os.path.join(binpath, filename) - if not os.path.isfile(fullpath): - continue - os.rename(fullpath, fullpath + ".exe") + copy(self, "COPYING*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "res", "info")) + rmdir(self, os.path.join(self.package_folder, "res", "man")) def package_info(self): - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH env var with : {}".format(bin_path)) - self.env_info.PATH.append(bin_path) + self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] + self.cpp_info.resdirs = ["res"] - ac_macrodir = self._autoconf_datarootdir - self.output.info("Setting AC_MACRODIR to {}".format(ac_macrodir)) - self.env_info.AC_MACRODIR = ac_macrodir + # TODO: use legacy unix_path for the moment (see https://github.com/conan-io/conan/issues/12499) - autoconf = os.path.join(self.package_folder, "bin", "autoconf") - if self.settings.os == "Windows": - autoconf = tools.unix_path(autoconf) + ".exe" - self.output.info("Setting AUTOCONF to {}".format(autoconf)) - self.env_info.AUTOCONF = autoconf + dataroot_path = tools_legacy.unix_path(os.path.join(self.package_folder, "res", "autoconf")) + self.output.info(f"Defining AC_MACRODIR environment variable: {dataroot_path}") + self.buildenv_info.define_path("AC_MACRODIR", dataroot_path) - autoreconf = os.path.join(self.package_folder, "bin", "autoreconf") - if self.settings.os == "Windows": - autoreconf = tools.unix_path(autoreconf) + ".exe" - self.output.info("Setting AUTORECONF to {}".format(autoreconf)) - self.env_info.AUTORECONF = autoreconf + self.output.info(f"Defining AUTOM4TE_PERLLIBDIR environment variable: {dataroot_path}") + self.buildenv_info.define_path("AUTOM4TE_PERLLIBDIR", dataroot_path) - autoheader = os.path.join(self.package_folder, "bin", "autoheader") - if self.settings.os == "Windows": - autoheader = tools.unix_path(autoheader) + ".exe" - self.output.info("Setting AUTOHEADER to {}".format(autoheader)) - self.env_info.AUTOHEADER = autoheader + bin_path = os.path.join(self.package_folder, "bin") - autom4te = os.path.join(self.package_folder, "bin", "autom4te") - if self.settings.os == "Windows": - autom4te = tools.unix_path(autom4te) + ".exe" - self.output.info("Setting AUTOM4TE to {}".format(autom4te)) - self.env_info.AUTOM4TE = autom4te + autoconf_bin = tools_legacy.unix_path(os.path.join(bin_path, "autoconf")) + self.output.info(f"Defining AUTOCONF environment variable: {autoconf_bin}") + self.buildenv_info.define_path("AUTOCONF", autoconf_bin) + + autoreconf_bin = tools_legacy.unix_path(os.path.join(bin_path, "autoreconf")) + self.output.info(f"Defining AUTORECONF environment variable: {autoreconf_bin}") + self.buildenv_info.define_path("AUTORECONF", autoreconf_bin) + + autoheader_bin = tools_legacy.unix_path(os.path.join(bin_path, "autoheader")) + self.output.info(f"Defining AUTOHEADER environment variable: {autoheader_bin}") + self.buildenv_info.define_path("AUTOHEADER", autoheader_bin) - autom4te_perllibdir = self._autoconf_datarootdir - self.output.info("Setting AUTOM4TE_PERLLIBDIR to {}".format(autom4te_perllibdir)) - self.env_info.AUTOM4TE_PERLLIBDIR = autom4te_perllibdir + autom4te_bin = tools_legacy.unix_path(os.path.join(bin_path, "autom4te")) + self.output.info(f"Defining AUTOM4TE environment variable: {autom4te_bin}") + self.buildenv_info.define_path("AUTOM4TE", autom4te_bin) + + # TODO: to remove in conan v2 + self.env_info.PATH.append(bin_path) + self.env_info.AC_MACRODIR = dataroot_path + self.env_info.AUTOM4TE_PERLLIBDIR = dataroot_path + self.env_info.AUTOCONF = autoconf_bin + self.env_info.AUTORECONF = autoreconf_bin + self.env_info.AUTOHEADER = autoheader_bin + self.env_info.AUTOM4TE = autom4te_bin diff --git a/recipes/autoconf/all/patches/2.69-0002-no-perl-path-in-shebang.patch b/recipes/autoconf/all/patches/2.69-0002-no-perl-path-in-shebang.patch index b092867b0414a..1ff7ad736c944 100644 --- a/recipes/autoconf/all/patches/2.69-0002-no-perl-path-in-shebang.patch +++ b/recipes/autoconf/all/patches/2.69-0002-no-perl-path-in-shebang.patch @@ -2,7 +2,7 @@ +++ bin/autoheader.in @@ -1,4 +1,4 @@ -#! @PERL@ -+#! /usr/bin/perl ++#! /usr/bin/env perl # -*- Perl -*- # @configure_input@ @@ -10,39 +10,44 @@ +++ bin/autom4te.in @@ -1,4 +1,4 @@ -#! @PERL@ -w -+#! /usr/bin/perl -w - # -*- perl -*- +-# -*- perl -*- ++#! /usr/bin/env perl ++# -*- perl -*- -w # @configure_input@ --- bin/autoreconf.in +++ bin/autoreconf.in @@ -1,4 +1,4 @@ -#! @PERL@ -w -+#! /usr/bin/perl -w - # -*- perl -*- +-# -*- perl -*- ++#! /usr/bin/env perl ++# -*- perl -*- -w # @configure_input@ --- bin/autoscan.in +++ bin/autoscan.in @@ -1,4 +1,4 @@ -#! @PERL@ -w -+#! /usr/bin/perl -w - # -*- perl -*- +-# -*- perl -*- ++#! /usr/bin/env perl ++# -*- perl -*- -w # @configure_input@ --- bin/autoupdate.in +++ bin/autoupdate.in @@ -1,4 +1,4 @@ -#! @PERL@ -w -+#! /usr/bin/perl -w - # -*- perl -*- +-# -*- perl -*- ++#! /usr/bin/env perl ++# -*- perl -*- -w # @configure_input@ --- bin/ifnames.in +++ bin/ifnames.in @@ -1,4 +1,4 @@ -#! @PERL@ -w -+#! /usr/bin/perl -w - # -*- perl -*- +-# -*- perl -*- ++#! /usr/bin/env perl ++# -*- perl -*- -w # @configure_input@ diff --git a/recipes/autoconf/all/patches/2.71-0002-no-perl-path-in-shebang.patch b/recipes/autoconf/all/patches/2.71-0002-no-perl-path-in-shebang.patch index 8619e6d94023a..6fcfe26cf5cd0 100644 --- a/recipes/autoconf/all/patches/2.71-0002-no-perl-path-in-shebang.patch +++ b/recipes/autoconf/all/patches/2.71-0002-no-perl-path-in-shebang.patch @@ -2,7 +2,7 @@ +++ bin/autoheader.in @@ -1,4 +1,4 @@ -#! @PERL@ -+#! /usr/bin/perl ++#! /usr/bin/env perl # -*- Perl -*- # @configure_input@ @@ -10,7 +10,7 @@ +++ bin/autom4te.in @@ -1,4 +1,4 @@ -#! @PERL@ -+#! /usr/bin/perl ++#! /usr/bin/env perl # -*- perl -*- # @configure_input@ @@ -18,7 +18,7 @@ +++ bin/autoreconf.in @@ -1,4 +1,4 @@ -#! @PERL@ -+#! /usr/bin/perl ++#! /usr/bin/env perl # -*- perl -*- # @configure_input@ @@ -26,7 +26,7 @@ +++ bin/autoscan.in @@ -1,4 +1,4 @@ -#! @PERL@ -+#! /usr/bin/perl ++#! /usr/bin/env perl # -*- perl -*- # @configure_input@ @@ -34,7 +34,7 @@ +++ bin/autoupdate.in @@ -1,4 +1,4 @@ -#! @PERL@ -+#! /usr/bin/perl ++#! /usr/bin/env perl # -*- perl -*- # @configure_input@ @@ -42,7 +42,7 @@ +++ bin/ifnames.in @@ -1,4 +1,4 @@ -#! @PERL@ -+#! /usr/bin/perl ++#! /usr/bin/env perl # -*- perl -*- # @configure_input@ diff --git a/recipes/autoconf/all/test_package/Makefile.in b/recipes/autoconf/all/test_package/Makefile.in index 867370d7c9a89..193ade8719dfc 100644 --- a/recipes/autoconf/all/test_package/Makefile.in +++ b/recipes/autoconf/all/test_package/Makefile.in @@ -5,7 +5,7 @@ SRCS = test_package_c.c test_package_cpp.cpp OBJS := $(patsubst %.c,%.@OBJEXT@,$(patsubst %.cpp,%.@OBJEXT@,$(SRCS))) test_package@EXEEXT@: $(OBJS) - @CXX@ $^ -o $@ + @CXX@ @CXXFLAGS@ @LDFLAGS@ $^ -o $@ %.@OBJEXT@: %.cpp @CXX@ @CXXFLAGS@ @CPPFLAGS@ -c $< @CC_MINUS_O@ $@ diff --git a/recipes/autoconf/all/test_package/conanfile.py b/recipes/autoconf/all/test_package/conanfile.py index 3f6a67b49039f..bb22349ed9696 100644 --- a/recipes/autoconf/all/test_package/conanfile.py +++ b/recipes/autoconf/all/test_package/conanfile.py @@ -1,36 +1,51 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from contextlib import contextmanager +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import copy +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc import os -import shutil class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - exports_sources = "configure.ac", "config.h.in", "Makefile.in", "test_package_c.c", "test_package_cpp.cpp", + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + win_bash = True + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def layout(self): + basic_layout(self) def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") - - @contextmanager - def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - with tools.environment_append({"CC": "cl -nologo", "CXX": "cl -nologo",}): - yield - else: - yield + self.tool_requires(self.tested_reference_str) + if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.generate() + if is_msvc(self): + env = Environment() + env.define("CC", "cl -nologo") + env.define("CXX", "cl -nologo") + env.vars(self).save_script("conanbuild_msvc") def build(self): - for src in self.exports_sources: - shutil.copy(os.path.join(self.source_folder, src), self.build_folder) - self.run("{} --verbose".format(os.environ["AUTOCONF"]), win_bash=tools.os_info.is_windows) - self.run("{} --help".format(os.path.join(self.build_folder, "configure").replace("\\", "/")), win_bash=tools.os_info.is_windows) - autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - with self._build_context(): - autotools.configure() - autotools.make() + for src in ("configure.ac", "config.h.in", "Makefile.in", "test_package_c.c", "test_package_cpp.cpp"): + copy(self, src, self.source_folder, self.build_folder) + self.run("autoconf --verbose") + autotools = Autotools(self) + autotools.configure(build_script_folder=self.build_folder) + autotools.make() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join(".", "test_package"), run_environment=True) + self.win_bash = None + if can_run(self): + bin_path = os.path.join(self.build_folder, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/autoconf/all/test_v1_package/conanfile.py b/recipes/autoconf/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..422d5f44c10cf --- /dev/null +++ b/recipes/autoconf/all/test_v1_package/conanfile.py @@ -0,0 +1,43 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +from conan.tools.files import copy +from conan.tools.microsoft import is_msvc +import contextlib +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + @contextlib.contextmanager + def _build_context(self): + if is_msvc(self): + with tools.vcvars(self): + with tools.environment_append({"CC": "cl -nologo", "CXX": "cl -nologo",}): + yield + else: + yield + + def build(self): + for src in ("configure.ac", "config.h.in", "Makefile.in", "test_package_c.c", "test_package_cpp.cpp"): + copy(self, src, os.path.join(self.source_folder, os.pardir, "test_package"), self.build_folder) + self.run("autoconf --verbose", win_bash=tools.os_info.is_windows) + self.run("{} --help".format(os.path.join(self.build_folder, "configure").replace("\\", "/")), + win_bash=tools.os_info.is_windows) + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + with self._build_context(): + autotools.configure() + autotools.make() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join(".", "test_package"), run_environment=True) diff --git a/recipes/automake/all/conandata.yml b/recipes/automake/all/conandata.yml index df7d405dbc46f..24df7aa715c72 100644 --- a/recipes/automake/all/conandata.yml +++ b/recipes/automake/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.16.5": + url: "https://ftp.gnu.org/gnu/automake/automake-1.16.5.tar.gz" + sha256: "07bd24ad08a64bc17250ce09ec56e921d6343903943e99ccf63bbf0705e34605" + "1.16.4": + url: "https://ftp.gnu.org/gnu/automake/automake-1.16.4.tar.gz" + sha256: "8a0f0be7aaae2efa3a68482af28e5872d8830b9813a6a932a2571eac63ca1794" "1.16.3": url: "https://ftp.gnu.org/gnu/automake/automake-1.16.3.tar.gz" sha256: "ce010788b51f64511a1e9bb2a1ec626037c6d0e7ede32c1c103611b9d3cba65f" @@ -9,6 +15,24 @@ sources: url: "https://ftp.gnu.org/gnu/automake/automake-1.16.1.tar.gz" sha256: "608a97523f97db32f1f5d5615c98ca69326ced2054c9f82e65bade7fc4c9dea8" patches: + "1.16.5": + - base_path: "source_subfolder" + patch_file: "patches/0001-help2man-no-discard-stderr-0.16.4.patch" + - base_path: "source_subfolder" + patch_file: "patches/0002-no-perl-path-in-shebang-0.16.4.patch" + - base_path: "source_subfolder" + patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.3.patch" + - base_path: "source_subfolder" + patch_file: "patches/0004-introduce-automake_perllibdir-0.16.3.patch" + "1.16.4": + - base_path: "source_subfolder" + patch_file: "patches/0001-help2man-no-discard-stderr-0.16.4.patch" + - base_path: "source_subfolder" + patch_file: "patches/0002-no-perl-path-in-shebang-0.16.4.patch" + - base_path: "source_subfolder" + patch_file: "patches/0003-remove-embedded-datadirs-introduce-automake-conan-includes-0.16.3.patch" + - base_path: "source_subfolder" + patch_file: "patches/0004-introduce-automake_perllibdir-0.16.3.patch" "1.16.3": - base_path: "source_subfolder" patch_file: "patches/0001-help2man-no-discard-stderr-0.16.3.patch" diff --git a/recipes/automake/all/conanfile.py b/recipes/automake/all/conanfile.py index 27d52e8ccd2fc..472f84cf07d88 100644 --- a/recipes/automake/all/conanfile.py +++ b/recipes/automake/all/conanfile.py @@ -1,5 +1,7 @@ -import os from conans import AutoToolsBuildEnvironment, ConanFile, tools +import os + +required_conan_version = ">=1.33.0" class AutomakeConan(ConanFile): @@ -8,10 +10,11 @@ class AutomakeConan(ConanFile): homepage = "https://www.gnu.org/software/automake/" description = "Automake is a tool for automatically generating Makefile.in files compliant with the GNU Coding Standards." topics = ("conan", "automake", "configure", "build") - exports_sources = ["patches/**"] license = ("GPL-2.0-or-later", "GPL-3.0-or-later") + settings = "os", "arch", "compiler", "build_type" + + exports_sources = "patches/*" - settings = "os", "arch", "compiler" _autotools = None @property @@ -23,6 +26,10 @@ def _version_major_minor(self): [major, minor, _] = self.version.split(".", 2) return '{}.{}'.format(major, minor) + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def configure(self): del self.settings.compiler.cppstd del self.settings.compiler.libcxx @@ -31,21 +38,24 @@ def requirements(self): self.requires("autoconf/2.71") # automake requires perl-Thread-Queue package + def build_requirements(self): + if hasattr(self, "settings_build"): + self.build_requires("autoconf/2.71") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + def package_id(self): del self.info.settings.arch del self.info.settings.compiler - - def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + del self.info.settings.build_type def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) @property def _datarootdir(self): - return os.path.join(self.package_folder, "bin", "share") + return os.path.join(self.package_folder, "res") @property def _automake_libdir(self): @@ -70,7 +80,7 @@ def _patch_files(self): tools.replace_in_file(os.path.join(self._source_subfolder, "bin", "aclocal.in"), " $map_traced_defs{$arg1} = $file;", " $file = `cygpath -u $file`;\n" - " $file =~ s/^\s+|\s+$//g;\n" + " $file =~ s/^\\s+|\\s+$//g;\n" " $map_traced_defs{$arg1} = $file;") def build(self): @@ -82,9 +92,9 @@ def package(self): self.copy("COPYING*", src=self._source_subfolder, dst="licenses") autotools = self._configure_autotools() autotools.install() - tools.rmdir(os.path.join(self.package_folder, "bin", "share", "info")) - tools.rmdir(os.path.join(self.package_folder, "bin", "share", "man")) - tools.rmdir(os.path.join(self.package_folder, "bin", "share", "doc")) + tools.rmdir(os.path.join(self._datarootdir, "info")) + tools.rmdir(os.path.join(self._datarootdir, "man")) + tools.rmdir(os.path.join(self._datarootdir, "doc")) if self.settings.os == "Windows": binpath = os.path.join(self.package_folder, "bin") @@ -95,15 +105,18 @@ def package(self): os.rename(fullpath, fullpath + ".exe") def package_info(self): + self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] + bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH env var with : {}".format(bin_path)) + self.output.info("Appending PATH environment variable:: {}".format(bin_path)) self.env_info.PATH.append(bin_path) bin_ext = ".exe" if self.settings.os == "Windows" else "" aclocal = tools.unix_path(os.path.join(self.package_folder, "bin", "aclocal" + bin_ext)) - self.output.info("Setting ACLOCAL to {}".format(aclocal)) - self.env_info.ACLOCAL = aclocal + self.output.info("Appending ACLOCAL environment variable with: {}".format(aclocal)) + self.env_info.ACLOCAL.append(aclocal) automake_datadir = tools.unix_path(self._datarootdir) self.output.info("Setting AUTOMAKE_DATADIR to {}".format(automake_datadir)) diff --git a/recipes/automake/all/patches/0001-help2man-no-discard-stderr-0.16.4.patch b/recipes/automake/all/patches/0001-help2man-no-discard-stderr-0.16.4.patch new file mode 100644 index 0000000000000..0ae00eb737eac --- /dev/null +++ b/recipes/automake/all/patches/0001-help2man-no-discard-stderr-0.16.4.patch @@ -0,0 +1,9 @@ +--- Makefile.in ++++ Makefile.in +@@ -703,4 +703,4 @@ + update_mans = \ + $(AM_V_GEN): \ + && $(MKDIR_P) doc \ +- && ./pre-inst-env $(PERL) $(srcdir)/doc/help2man --output=$@ ++ && ./pre-inst-env $(PERL) $(srcdir)/doc/help2man --no-discard-stderr --output=$@ + diff --git a/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.1.patch b/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.1.patch index 1a4260cf8ffcb..3b71368f12261 100644 --- a/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.1.patch +++ b/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.1.patch @@ -2,12 +2,13 @@ +++ bin/aclocal.in @@ -1,8 +1,8 @@ -#!@PERL@ -w -+#!/usr/bin/perl -w - # -*- perl -*- +-# -*- perl -*- ++#!/usr/bin/env perl ++# -*- perl -*- -w # @configure_input@ -eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' -+eval 'case $# in 0) exec /usr/bin/perl -S "$0";; *) exec /usr/bin/perl -S "$0" "$@";; esac' ++eval 'case $# in 0) exec /usr/bin/env perl -S "$0";; *) exec /usr/bin/env perl -S "$0" "$@";; esac' if 0; # aclocal - create aclocal.m4 by scanning configure.ac @@ -15,12 +16,13 @@ +++ bin/automake.in @@ -1,8 +1,8 @@ -#!@PERL@ -w -+#!/usr/bin/perl -w - # -*- perl -*- +-# -*- perl -*- ++#!/usr/bin/env perl ++# -*- perl -*- -w # @configure_input@ -eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' -+eval 'case $# in 0) exec /usr/bin/perl -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' ++eval 'case $# in 0) exec /usr/bin/env perl -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' if 0; # automake - create Makefile.in from Makefile.am @@ -31,7 +33,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -+PERL = /usr/bin/perl ++PERL = /usr/bin/env perl RELEASE_YEAR = @RELEASE_YEAR@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -42,7 +44,7 @@ # that automake testsuite, if they are available. AWK=${AM_TESTSUITE_AWK-${AWK-'@AWK@'}} -PERL=${AM_TESTSUITE_PERL-${PERL-'@PERL@'}} -+PERL=${AM_TESTSUITE_PERL-${PERL-'/usr/bin/perl'}} ++PERL=${AM_TESTSUITE_PERL-${PERL-'/usr/bin/env perl'}} MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}} YACC=${AM_TESTSUITE_YACC-${YACC-'@YACC@'}} LEX=${AM_TESTSUITE_LEX-${LEX-'@LEX@'}} diff --git a/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.2.patch b/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.2.patch index 20a36ce449ee0..5e91a18bb5be9 100644 --- a/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.2.patch +++ b/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.2.patch @@ -2,12 +2,14 @@ +++ bin/aclocal.in @@ -1,1 +1,1 @@ -#!@PERL@ -w -+#!/usr/bin/perl -w ++#!/usr/bin/env perl ++# -*- perl -*- -w --- bin/automake.in +++ bin/automake.in @@ -1,1 +1,1 @@ -#!@PERL@ -w -+#!/usr/bin/perl -w ++#!/usr/bin/env perl ++# -*- perl -*- -w --- Makefile.in +++ Makefile.in @@ -524,7 +524,7 @@ @@ -15,7 +17,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -+PERL = /usr/bin/perl ++PERL = /usr/bin/env perl RELEASE_YEAR = @RELEASE_YEAR@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -26,7 +28,7 @@ # that automake testsuite, if they are available. AWK=${AM_TESTSUITE_AWK-${AWK-'@AWK@'}} -PERL=${AM_TESTSUITE_PERL-${PERL-'@PERL@'}} -+PERL=${AM_TESTSUITE_PERL-${PERL-'/usr/bin/perl'}} ++PERL=${AM_TESTSUITE_PERL-${PERL-'/usr/bin/env perl'}} MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}} YACC=${AM_TESTSUITE_YACC-${YACC-'@YACC@'}} LEX=${AM_TESTSUITE_LEX-${LEX-'@LEX@'}} diff --git a/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.3.patch b/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.3.patch index cdb880db2bb89..d13c305ceee18 100644 --- a/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.3.patch +++ b/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.3.patch @@ -2,12 +2,12 @@ +++ bin/aclocal.in @@ -1,1 +1,1 @@ -#!@PERL@ -+#!/usr/bin/perl ++#!/usr/bin/env perl --- bin/automake.in +++ bin/automake.in @@ -1,1 +1,1 @@ -#!@PERL@ -+#!/usr/bin/perl ++#!/usr/bin/env perl --- Makefile.in +++ Makefile.in @@ -535,7 +535,7 @@ @@ -15,7 +15,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -+PERL = /usr/bin/perl ++PERL = /usr/bin/env perl RELEASE_YEAR = @RELEASE_YEAR@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ @@ -26,7 +26,7 @@ # that automake testsuite, if they are available. AWK=${AM_TESTSUITE_AWK-${AWK-'@AWK@'}} -PERL=${AM_TESTSUITE_PERL-${PERL-'@PERL@'}} -+PERL=${AM_TESTSUITE_PERL-${PERL-'/usr/bin/perl'}} ++PERL=${AM_TESTSUITE_PERL-${PERL-'/usr/bin/env perl'}} MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}} YACC=${AM_TESTSUITE_YACC-${YACC-'@YACC@'}} LEX=${AM_TESTSUITE_LEX-${LEX-'@LEX@'}} diff --git a/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.4.patch b/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.4.patch new file mode 100644 index 0000000000000..986bcfba26760 --- /dev/null +++ b/recipes/automake/all/patches/0002-no-perl-path-in-shebang-0.16.4.patch @@ -0,0 +1,32 @@ +--- bin/aclocal.in ++++ bin/aclocal.in +@@ -1,1 +1,1 @@ +-#!@PERL@ ++#!/usr/bin/env perl +--- bin/automake.in ++++ bin/automake.in +@@ -1,1 +1,1 @@ +-#!@PERL@ ++#!/usr/bin/env perl +--- Makefile.in ++++ Makefile.in +@@ -527,7 +527,7 @@ + PACKAGE_URL = @PACKAGE_URL@ + PACKAGE_VERSION = @PACKAGE_VERSION@ + PATH_SEPARATOR = @PATH_SEPARATOR@ +-PERL = @PERL@ ++PERL = /usr/bin/env perl + RELEASE_YEAR = @RELEASE_YEAR@ + SET_MAKE = @SET_MAKE@ + SHELL = @SHELL@ +--- t/ax/test-defs.in ++++ t/ax/test-defs.in +@@ -97,7 +97,7 @@ + # User can override various tools used. Prefer overriding specific for + # that automake testsuite, if they are available. + AWK=${AM_TESTSUITE_AWK-${AWK-'@AWK@'}} +-PERL=${AM_TESTSUITE_PERL-${PERL-'@PERL@'}} ++PERL=${AM_TESTSUITE_PERL-${PERL-'/usr/bin/env perl'}} + MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}} + YACC=${AM_TESTSUITE_YACC-${YACC-'@YACC@'}} + LEX=${AM_TESTSUITE_LEX-${LEX-'@LEX@'}} diff --git a/recipes/automake/all/test_package/conanfile.py b/recipes/automake/all/test_package/conanfile.py index fdafd418b4358..8362800620a5a 100644 --- a/recipes/automake/all/test_package/conanfile.py +++ b/recipes/automake/all/test_package/conanfile.py @@ -1,22 +1,34 @@ from conans import AutoToolsBuildEnvironment, ConanFile, tools +from conan.tools.microsoft import is_msvc from contextlib import contextmanager import os import shutil +required_conan_version = ">=1.45.0" + class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" exports_sources = "configure.ac", "Makefile.am", "test_package_1.c", "test_package.cpp" # DON'T COPY extra.m4 TO BUILD FOLDER!!! + test_type = "explicit" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def requirements(self): + self.requires(self.tested_reference_str) def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + self.build_requires(self.tested_reference_str) + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") @contextmanager def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): + if is_msvc(self): + with tools.vcvars(self): with tools.environment_append({"CC": "cl -nologo", "CXX": "cl -nologo",}): yield else: @@ -35,16 +47,20 @@ def _system_cc(self): if not system_cc: system_cc = self._default_cc.get(str(self.settings.compiler)) return system_cc + + @property + def _user_info(self): + return getattr(self, "user_info_build", self.deps_user_info) def _build_scripts(self): """Test compile script of automake""" - compile_script = self.deps_user_info["automake"].compile - ar_script = self.deps_user_info["automake"].ar_lib + compile_script = self._user_info["automake"].compile + ar_script = self._user_info["automake"].ar_lib assert os.path.isfile(ar_script) assert os.path.isfile(compile_script) if self._system_cc: - with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op(): + with tools.vcvars(self) if is_msvc(self) else tools.no_op(): self.run("{} {} test_package_1.c -o script_test".format(tools.unix_path(compile_script), self._system_cc), win_bash=tools.os_info.is_windows) def _build_autotools(self): @@ -66,8 +82,8 @@ def build(self): def test(self): if self._system_cc: - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run(os.path.join(".", "script_test"), run_environment=True) - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run(os.path.join(".", "test_package"), run_environment=True) diff --git a/recipes/automake/config.yml b/recipes/automake/config.yml index 698ee3d3950b2..fd370ec1de9eb 100644 --- a/recipes/automake/config.yml +++ b/recipes/automake/config.yml @@ -1,7 +1,11 @@ versions: - "1.16.1": + "1.16.5": folder: all - "1.16.2": + "1.16.4": folder: all "1.16.3": folder: all + "1.16.2": + folder: all + "1.16.1": + folder: all diff --git a/recipes/avahi/all/conandata.yml b/recipes/avahi/all/conandata.yml new file mode 100644 index 0000000000000..49b6c0881959d --- /dev/null +++ b/recipes/avahi/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.8": + url: "https://github.com/lathiat/avahi/releases/download/v0.8/avahi-0.8.tar.gz" + sha256: "060309d7a333d38d951bc27598c677af1796934dbd98e1024e7ad8de798fedda" diff --git a/recipes/avahi/all/conanfile.py b/recipes/avahi/all/conanfile.py new file mode 100644 index 0000000000000..1bb65f4a2da31 --- /dev/null +++ b/recipes/avahi/all/conanfile.py @@ -0,0 +1,127 @@ +import os + +from conan import ConanFile +from conan.tools.files import copy, get, rmdir, rm +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain, PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.51.0" + + +class AvahiConan(ConanFile): + name = "avahi" + # --enable-compat-libdns_sd means that this recipe provides the mdnsresponder compile interface + provides = "mdnsresponder" + description = "Avahi - Service Discovery for Linux using mDNS/DNS-SD -- compatible with Bonjour" + topics = ("bonjour", "dns", "dns-sd", "mdns") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/lathiat/avahi" + license = "LGPL-2.1-only" + settings = "os", "arch", "compiler", "build_type" + + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("glib/2.74.0") + self.requires("expat/2.4.9") + self.requires("libdaemon/0.14") + self.requires("dbus/1.15.0") + self.requires("gdbm/1.19") + self.requires("libevent/2.1.12") + + def validate(self): + if self.info.settings.os != "Linux": + raise ConanInvalidConfiguration("Only Linux is supported for this package.") + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = AutotoolsToolchain(self) + tc.configure_args.append("--enable-compat-libdns_sd") + tc.configure_args.append("--disable-gtk3") + tc.configure_args.append("--disable-mono") + tc.configure_args.append("--disable-monodoc") + tc.configure_args.append("--disable-python") + tc.configure_args.append("--disable-qt5") + tc.configure_args.append("--with-systemdsystemunitdir=/lib/systemd/system") + tc.generate() + AutotoolsDeps(self).generate() + PkgConfigDeps(self).generate() + + def build(self): + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + autotools = Autotools(self) + autotools.install() + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "etc")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "run")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + + def package_info(self): + for lib in ("client", "common", "core", "glib", "gobject", "libevent", "compat-libdns_sd"): + avahi_lib = f"avahi-{lib}" + self.cpp_info.components[lib].names["cmake_find_package"] = lib + self.cpp_info.components[lib].names["cmake_find_package_multi"] = lib + self.cpp_info.components[lib].names["pkg_config"] = avahi_lib + self.cpp_info.components[lib].libs = [avahi_lib] + self.cpp_info.components[lib].includedirs = [os.path.join("include", avahi_lib)] + self.cpp_info.components["compat-libdns_sd"].libs = ["dns_sd"] + + self.cpp_info.components["client"].requires = ["common", "dbus::dbus"] + self.cpp_info.components["common"].system_libs = ["pthread"] + self.cpp_info.components["core"].requires = ["common"] + self.cpp_info.components["glib"].requires = ["common", "glib::glib"] + self.cpp_info.components["gobject"].requires = ["client", "glib"] + self.cpp_info.components["libevent"].requires = ["common", "libevent::libevent"] + self.cpp_info.components["compat-libdns_sd"].requires = ["client"] + + for app in ("autoipd", "browse", "daemon", "dnsconfd", "publish", "resolve", "set-host-name"): + avahi_app = f"avahi-{app}" + self.cpp_info.components[app].names["cmake_find_package"] = app + self.cpp_info.components[app].names["cmake_find_package_multi"] = app + self.cpp_info.components[app].names["pkg_config"] = avahi_app + + self.cpp_info.components["autoipd"].requires = ["libdaemon::libdaemon"] + self.cpp_info.components["browse"].requires = ["client", "gdbm::gdbm"] + self.cpp_info.components["daemon"].requires = ["core", "expat::expat", "libdaemon::libdaemon"] + self.cpp_info.components["dnsconfd"].requires = ["common", "libdaemon::libdaemon"] + self.cpp_info.components["publish"].requires = ["client"] + self.cpp_info.components["resolve"].requires = ["client"] + self.cpp_info.components["set-host-name"].requires = ["client"] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH environment variable: {bin_path}") + self.env_info.PATH.append(bin_path) diff --git a/recipes/avahi/all/test_package/CMakeLists.txt b/recipes/avahi/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fce015c3405a9 --- /dev/null +++ b/recipes/avahi/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(Avahi CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE avahi::compat-libdns_sd) diff --git a/recipes/avahi/all/test_package/conanfile.py b/recipes/avahi/all/test_package/conanfile.py new file mode 100644 index 0000000000000..704f712573f0d --- /dev/null +++ b/recipes/avahi/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake +from conan.tools.layout import cmake_layout + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/avahi/all/test_package/test_package.c b/recipes/avahi/all/test_package/test_package.c new file mode 100644 index 0000000000000..bae1467c7d687 --- /dev/null +++ b/recipes/avahi/all/test_package/test_package.c @@ -0,0 +1,18 @@ +#include +#include + +int main() +{ + DNSServiceRef sdRef; + DNSServiceErrorType err = DNSServiceBrowse(&sdRef, 0, 0, "_example._tcp", NULL, NULL, NULL); + if (err == kDNSServiceErr_NoError) + { + printf("DNSServiceBrowse succeeded\n"); + DNSServiceRefDeallocate(sdRef); + } + else + { + printf("DNSServiceBrowse failed: %d\n", err); + } + return 0; +} diff --git a/recipes/avahi/all/test_v1_package/CMakeLists.txt b/recipes/avahi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..abd3bb0df681c --- /dev/null +++ b/recipes/avahi/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Avahi CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE avahi::compat-libdns_sd) diff --git a/recipes/avahi/all/test_v1_package/conanfile.py b/recipes/avahi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..b6a26067f365d --- /dev/null +++ b/recipes/avahi/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os + +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/avahi/config.yml b/recipes/avahi/config.yml new file mode 100644 index 0000000000000..37290caa0a7c9 --- /dev/null +++ b/recipes/avahi/config.yml @@ -0,0 +1,3 @@ +versions: + "0.8": + folder: all diff --git a/recipes/avcpp/all/conandata.yml b/recipes/avcpp/all/conandata.yml new file mode 100644 index 0000000000000..1ba5e69f511c2 --- /dev/null +++ b/recipes/avcpp/all/conandata.yml @@ -0,0 +1,17 @@ +sources: + "2.1.0": + url: "https://github.com/h4tr3d/avcpp/archive/refs/tags/v2.1.0.tar.gz" + sha256: "8398217dccb9f5b4cbb41e5bf4f73f47b461ed3ba8c3aefdda9f9dd714649855" + "cci.20220301": + url: "https://github.com/h4tr3d/avcpp/archive/fd4bc4662eb39853de8fcac4a663bebd0eea30b8.tar.gz" + sha256: "e48eae2ec154bc69aed16159c8b18c9ffb4925ba672b022e94a3c9b96782a4bf" + +patches: + "2.1.0": + - patch_file: "patches/2.1.0-fix-ffmpeg.patch" + patch_description: "fix ffmpeg package name and remove ffmpeg from install targets" + patch_type: "conan" + "cci.20220301": + - patch_file: "patches/cci.20220301-fix-ffmpeg.patch" + patch_description: "fix ffmpeg package name and remove ffmpeg from install targets" + patch_type: "conan" diff --git a/recipes/avcpp/all/conanfile.py b/recipes/avcpp/all/conanfile.py new file mode 100644 index 0000000000000..7585987f38a75 --- /dev/null +++ b/recipes/avcpp/all/conanfile.py @@ -0,0 +1,115 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.52.0" + +class AvcppConan(ConanFile): + name = "avcpp" + description = "C++ wrapper for FFmpeg" + license = "LGPL-2.1", "BSD-3-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/h4tr3d/avcpp/" + topics = ("ffmpeg", "cpp") + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + "shared": [True, False], + } + default_options = { + "fPIC": True, + "shared": False, + } + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8", + "clang": "7", + "apple-clang": "12.0", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + check_min_vs(self, 191) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support." + ) + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("ffmpeg/5.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.variables["AV_ENABLE_SHARED"] = self.options.shared + tc.variables["AV_ENABLE_STATIC"] = not self.options.shared + tc.variables["AV_BUILD_EXAMPLES"] = False + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE*", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + target_name = "avcpp" if self.options.shared else "avcpp-static" + + self.cpp_info.set_property("cmake_file_name", "avcpp") + self.cpp_info.set_property("cmake_target_name", f"avcpp::{target_name}") + + self.cpp_info.components["AvCpp"].names["cmake_find_package"] = target_name + self.cpp_info.components["AvCpp"].names["cmake_find_package_multi"] = target_name + self.cpp_info.components["AvCpp"].set_property("cmake_target_name", f"avcpp::{target_name}") + self.cpp_info.components["AvCpp"].libs = ["avcpp", ] + self.cpp_info.components["AvCpp"].requires = ["ffmpeg::ffmpeg", ] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["AvCpp"].system_libs = ["mvec"] + if self.settings.os == "Windows": + self.cpp_info.components["AvCpp"].system_libs = ["mfplat"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "avcpp" + self.cpp_info.filenames["cmake_find_package_multi"] = "avcpp" + self.cpp_info.names["cmake_find_package"] = "avcpp" + self.cpp_info.names["cmake_find_package_multi"] = "avcpp" diff --git a/recipes/avcpp/all/patches/2.1.0-fix-ffmpeg.patch b/recipes/avcpp/all/patches/2.1.0-fix-ffmpeg.patch new file mode 100644 index 0000000000000..38c60a601238c --- /dev/null +++ b/recipes/avcpp/all/patches/2.1.0-fix-ffmpeg.patch @@ -0,0 +1,46 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 95b1a02..0f31197 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,8 +6,6 @@ endif() + + project(AvCpp LANGUAGES CXX VERSION 2.1.0) + +-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) +- + set(FFMPEG_PKG_CONFIG_SUFFIX "" CACHE STRING "This suffix uses for FFmpeg component names searches by pkg-config") + set(AV_ENABLE_STATIC On CACHE BOOL "Enable static library build (On)") + set(AV_ENABLE_SHARED On CACHE BOOL "Enable shared library build (On)") +@@ -28,8 +26,8 @@ set (AVCPP_WARNING_OPTIONS + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads) + +-find_package(FFmpeg +- COMPONENTS AVCODEC AVFORMAT AVUTIL AVDEVICE AVFILTER SWSCALE SWRESAMPLE REQUIRED) ++find_package(ffmpeg ++ COMPONENTS avcodec avformat avutil avdevice avfilter swscale swresample REQUIRED) + + add_subdirectory(src) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 4c58281..bee779f 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -24,7 +24,7 @@ foreach(TARGET ${AV_TARGETS}) + add_library(${TARGET} ${TYPE} ${AV_SOURCES} ${AV_HEADERS}) + + target_compile_options(${TARGET} PRIVATE ${AVCPP_WARNING_OPTIONS}) +- target_link_libraries(${TARGET} PRIVATE Threads::Threads PUBLIC FFmpeg::FFmpeg) ++ target_link_libraries(${TARGET} PRIVATE Threads::Threads PUBLIC ffmpeg::ffmpeg) + target_include_directories(${TARGET} + PUBLIC + $ +@@ -53,7 +53,7 @@ if (AVCPP_NOT_SUBPROJECT) + # APPEND + # FILE ${CMAKE_CURRENT_BINARY_DIR}/avcpp-targets.cmake) + +- install(TARGETS ${AV_TARGETS} FFmpeg ++ install(TARGETS ${AV_TARGETS} + EXPORT avcpp-targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/recipes/avcpp/all/patches/cci.20220301-fix-ffmpeg.patch b/recipes/avcpp/all/patches/cci.20220301-fix-ffmpeg.patch new file mode 100644 index 0000000000000..3207ead4b4610 --- /dev/null +++ b/recipes/avcpp/all/patches/cci.20220301-fix-ffmpeg.patch @@ -0,0 +1,46 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a5fed05..d077b96 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,7 +6,7 @@ endif() + + project(AvCpp LANGUAGES CXX VERSION 2.0.99) + +-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) ++# set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) + + set(FFMPEG_PKG_CONFIG_SUFFIX "" CACHE STRING "This suffix uses for FFmpeg component names searches by pkg-config") + set(AV_ENABLE_STATIC On CACHE BOOL "Enable static library build (On)") +@@ -28,8 +28,8 @@ set (AVCPP_WARNING_OPTIONS + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads) + +-find_package(FFmpeg +- COMPONENTS AVCODEC AVFORMAT AVUTIL AVDEVICE AVFILTER SWSCALE SWRESAMPLE REQUIRED) ++find_package(ffmpeg ++ COMPONENTS avcodec avformat avutil avdevice avfilter swscale swresample REQUIRED) + + add_subdirectory(src) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 80c6faa..262c16c 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -24,7 +24,7 @@ foreach(TARGET ${AV_TARGETS}) + add_library(${TARGET} ${TYPE} ${AV_SOURCES} ${AV_HEADERS}) + + target_compile_options(${TARGET} PRIVATE ${AVCPP_WARNING_OPTIONS}) +- target_link_libraries(${TARGET} PRIVATE Threads::Threads PUBLIC FFmpeg::FFmpeg) ++ target_link_libraries(${TARGET} PRIVATE Threads::Threads PUBLIC ffmpeg::ffmpeg) + target_include_directories(${TARGET} + PUBLIC + $ +@@ -53,7 +53,7 @@ if (AVCPP_NOT_SUBPROJECT) + # APPEND + # FILE ${CMAKE_CURRENT_BINARY_DIR}/avcpp-targets.cmake) + +- install(TARGETS ${AV_TARGETS} FFmpeg ++ install(TARGETS ${AV_TARGETS} + EXPORT avcpp-targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/recipes/avcpp/all/test_package/CMakeLists.txt b/recipes/avcpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b07f0b83ed62 --- /dev/null +++ b/recipes/avcpp/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(avcpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +if (TARGET avcpp::avcpp) + target_link_libraries(${PROJECT_NAME} PRIVATE avcpp::avcpp) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE avcpp::avcpp-static) +endif() +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) diff --git a/recipes/avcpp/all/test_package/conanfile.py b/recipes/avcpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/avcpp/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/avcpp/all/test_package/test_package.cpp b/recipes/avcpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4a0006ac9890a --- /dev/null +++ b/recipes/avcpp/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include "avcpp/av.h" +#include "avcpp/avutils.h" + +int main() { + av::init(); + av::setFFmpegLoggingLevel(AV_LOG_DEBUG); + + return 0; +} diff --git a/recipes/avcpp/all/test_v1_package/CMakeLists.txt b/recipes/avcpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..053bba6e952b4 --- /dev/null +++ b/recipes/avcpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(avcpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +if (TARGET avcpp::avcpp) + target_link_libraries(${PROJECT_NAME} PRIVATE avcpp::avcpp) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE avcpp::avcpp-static) +endif() +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) diff --git a/recipes/avcpp/all/test_v1_package/conanfile.py b/recipes/avcpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..6b551939fbde3 --- /dev/null +++ b/recipes/avcpp/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, CMake, tools + +class TestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/avcpp/config.yml b/recipes/avcpp/config.yml new file mode 100644 index 0000000000000..deb0eb011c7ea --- /dev/null +++ b/recipes/avcpp/config.yml @@ -0,0 +1,5 @@ +versions: + "2.1.0": + folder: all + "cci.20220301": + folder: all diff --git a/recipes/avir/all/conandata.yml b/recipes/avir/all/conandata.yml new file mode 100644 index 0000000000000..34c53c22f1e4f --- /dev/null +++ b/recipes/avir/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.0": + url: "https://github.com/avaneev/avir/archive/refs/tags/3.0.tar.gz" + sha256: "011909d31cf782152a69f570563eb70700504f168174a6049b6acbb9b9f511ea" diff --git a/recipes/avir/all/conanfile.py b/recipes/avir/all/conanfile.py new file mode 100644 index 0000000000000..61093399842d4 --- /dev/null +++ b/recipes/avir/all/conanfile.py @@ -0,0 +1,40 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class AVIRConan(ConanFile): + name = "avir" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + description = "High-quality pro image resizing / scaling C++ library, image resize" + topics = ("image-processing", "image-resizer", "lanczos", ) + homepage = "https://github.com/avaneev/avir" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/avir/all/test_package/CMakeLists.txt b/recipes/avir/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..51fd0e87ec014 --- /dev/null +++ b/recipes/avir/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(avir CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE avir::avir) diff --git a/recipes/avir/all/test_package/conanfile.py b/recipes/avir/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/avir/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/avir/all/test_package/test_package.cpp b/recipes/avir/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..6726fc2fb72b5 --- /dev/null +++ b/recipes/avir/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include "avir.h" + +int main() { + avir::CImageResizer<> ImageResizer(8); + + return 0; +} + diff --git a/recipes/avir/all/test_v1_package/CMakeLists.txt b/recipes/avir/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b53aff65d290e --- /dev/null +++ b/recipes/avir/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(avir CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE avir::avir) diff --git a/recipes/avir/all/test_v1_package/conanfile.py b/recipes/avir/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/avir/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/avir/config.yml b/recipes/avir/config.yml new file mode 100644 index 0000000000000..fdd08f532337f --- /dev/null +++ b/recipes/avir/config.yml @@ -0,0 +1,3 @@ +versions: + "3.0": + folder: all diff --git a/recipes/aws-c-auth/all/conandata.yml b/recipes/aws-c-auth/all/conandata.yml new file mode 100644 index 0000000000000..3f6bee7b4b086 --- /dev/null +++ b/recipes/aws-c-auth/all/conandata.yml @@ -0,0 +1,16 @@ +sources: + "0.6.17": + url: "https://github.com/awslabs/aws-c-auth/archive/v0.6.17.tar.gz" + sha256: "b43678ad3a779c9c7fccf8f931c162eaaf4d5d64d2955ac1fcfd32e538545c0f" + "0.6.11": + url: "https://github.com/awslabs/aws-c-auth/archive/v0.6.11.tar.gz" + sha256: "d8a0d373cf8b0ff148a014ae2ba24c51f2e7a598b5b0cf3a6e64482c1cd37f90" + "0.6.8": + url: "https://github.com/awslabs/aws-c-auth/archive/v0.6.8.tar.gz" + sha256: "48b1c0008265ea8e7d7b653b34640ce8111e00d6e0e3f4855f3fba71e1ac5704" + "0.6.4": + url: "https://github.com/awslabs/aws-c-auth/archive/v0.6.4.tar.gz" + sha256: "119cec67e85b01af8c01b11d962c610d8e9b183cde96fee77db669cccaa19ac9" + "0.6.0": + url: "https://github.com/awslabs/aws-c-auth/archive/v0.6.0.tar.gz" + sha256: "5f5fff63110c3e8f619385ca563f77886bc101d3e054987eecbb87586e27b651" diff --git a/recipes/aws-c-auth/all/conanfile.py b/recipes/aws-c-auth/all/conanfile.py new file mode 100644 index 0000000000000..98d3c8c463737 --- /dev/null +++ b/recipes/aws-c-auth/all/conanfile.py @@ -0,0 +1,105 @@ +from conan import ConanFile +from conan.tools.files import get, copy, rmdir +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.47.0" + +class AwsCAuth(ConanFile): + name = "aws-c-auth" + description = "C99 library implementation of AWS client-side authentication: standard credentials providers and signing." + license = "Apache-2.0", + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/awslabs/aws-c-auth" + topics = ("aws", "amazon", "cloud", "authentication", "credentials", "providers", "signing") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("aws-c-common/0.8.2") + self.requires("aws-c-cal/0.5.13") + if Version(self.version) < "0.6.17": + self.requires("aws-c-io/0.10.20") + self.requires("aws-c-http/0.6.13") + else: + self.requires("aws-c-io/0.13.4") + self.requires("aws-c-http/0.6.22") + if Version(self.version) >= "0.6.5": + self.requires("aws-c-sdkutils/0.1.3") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-auth")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-c-auth") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-c-auth") + + self.cpp_info.components["aws-c-auth-lib"].names["cmake_find_package"] = "aws-c-auth" + self.cpp_info.components["aws-c-auth-lib"].names["cmake_find_package_multi"] = "aws-c-auth" + self.cpp_info.components["aws-c-auth-lib"].set_property("cmake_target_name", "AWS::aws-c-auth") + + self.cpp_info.components["aws-c-auth-lib"].libs = ["aws-c-auth"] + self.cpp_info.components["aws-c-auth-lib"].requires = [ + "aws-c-common::aws-c-common-lib", + "aws-c-cal::aws-c-cal-lib", + "aws-c-io::aws-c-io-lib", + "aws-c-http::aws-c-http-lib", + ] + if Version(self.version) >= "0.6.5": + self.cpp_info.components["aws-c-auth-lib"].requires.append("aws-c-sdkutils::aws-c-sdkutils-lib") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "aws-c-auth" + self.cpp_info.filenames["cmake_find_package_multi"] = "aws-c-auth" + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" diff --git a/recipes/aws-c-auth/all/test_package/CMakeLists.txt b/recipes/aws-c-auth/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d0c587e8dd59d --- /dev/null +++ b/recipes/aws-c-auth/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(aws-c-auth REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-auth) diff --git a/recipes/aws-c-auth/all/test_package/conanfile.py b/recipes/aws-c-auth/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/aws-c-auth/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-c-auth/all/test_package/test_package.c b/recipes/aws-c-auth/all/test_package/test_package.c new file mode 100644 index 0000000000000..3a09afc9945dc --- /dev/null +++ b/recipes/aws-c-auth/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include + +int main() { + struct aws_allocator *allocator = aws_default_allocator(); + aws_auth_library_init(allocator); + aws_auth_library_clean_up(); + + return EXIT_SUCCESS; +} diff --git a/recipes/aws-c-auth/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-auth/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..606180fec87bd --- /dev/null +++ b/recipes/aws-c-auth/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-auth REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-auth) diff --git a/recipes/aws-c-auth/all/test_v1_package/conanfile.py b/recipes/aws-c-auth/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/aws-c-auth/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-c-auth/config.yml b/recipes/aws-c-auth/config.yml new file mode 100644 index 0000000000000..503ab418198f1 --- /dev/null +++ b/recipes/aws-c-auth/config.yml @@ -0,0 +1,11 @@ +versions: + "0.6.17": + folder: all + "0.6.11": + folder: all + "0.6.8": + folder: all + "0.6.4": + folder: all + "0.6.0": + folder: all diff --git a/recipes/aws-c-cal/all/conandata.yml b/recipes/aws-c-cal/all/conandata.yml new file mode 100644 index 0000000000000..e1b848e4dfa2d --- /dev/null +++ b/recipes/aws-c-cal/all/conandata.yml @@ -0,0 +1,52 @@ +sources: + "0.5.20": + url: "https://github.com/awslabs/aws-c-cal/archive/v0.5.20.tar.gz" + sha256: "acc352359bd06f8597415c366cf4ec4f00d0b0da92d637039a73323dd55b6cd0" + "0.5.19": + url: "https://github.com/awslabs/aws-c-cal/archive/refs/tags/v0.5.19.tar.gz" + sha256: "23452ab7960c480f1ec0a96ac55bde32d7d27c4a664baeadc248923b19c12086" + "0.5.17": + url: "https://github.com/awslabs/aws-c-cal/archive/v0.5.17.tar.gz" + sha256: "40297da04443d4ee2988d1c5fb0dc4a156d0e4cfaf80e6a1df1867452566d540" + "0.5.13": + url: "https://github.com/awslabs/aws-c-cal/archive/v0.5.13.tar.gz" + sha256: "3aba3954877ea5271ce68361f3bd9c155b422b1149eed403874f6493285ca04d" + "0.5.12": + url: "https://github.com/awslabs/aws-c-cal/archive/v0.5.12.tar.gz" + sha256: "350c29a288d5d498bd6574fca659cffc9453bf62691fbde5788399716c2bd132" + "0.5.11": + url: "https://github.com/awslabs/aws-c-cal/archive/v0.5.11.tar.gz" + sha256: "ef46e121b2231a0b19afce8af4b32d77501df4d470e926990918456636cd83c0" +patches: + "0.5.20": + - patch_file: "patches/0002-apple-corefoundation-0.5.13.patch" + patch_description: "Link to CoreFoundation on Apple" + patch_type: "backport" + patch_source: "https://github.com/awslabs/aws-c-cal/pull/126" + "0.5.19": + - patch_file: "patches/0002-apple-corefoundation-0.5.13.patch" + patch_description: "Link to CoreFoundation on Apple" + patch_type: "backport" + patch_source: "https://github.com/awslabs/aws-c-cal/pull/126" + "0.5.17": + - patch_file: "patches/0002-apple-corefoundation-0.5.13.patch" + patch_description: "Link to CoreFoundation on Apple" + patch_type: "backport" + patch_source: "https://github.com/awslabs/aws-c-cal/pull/126" + "0.5.13": + - patch_file: "patches/0002-apple-corefoundation-0.5.13.patch" + patch_description: "Link to CoreFoundation on Apple" + patch_type: "backport" + patch_source: "https://github.com/awslabs/aws-c-cal/pull/126" + "0.5.12": + - patch_file: "patches/0001-use-openssl-cmake-imported-target.patch" + - patch_file: "patches/0002-apple-corefoundation-0.5.11.patch" + patch_description: "Link to CoreFoundation on Apple" + patch_type: "backport" + patch_source: "https://github.com/awslabs/aws-c-cal/pull/126" + "0.5.11": + - patch_file: "patches/0001-use-openssl-cmake-imported-target.patch" + - patch_file: "patches/0002-apple-corefoundation-0.5.11.patch" + patch_description: "Link to CoreFoundation on Apple" + patch_type: "backport" + patch_source: "https://github.com/awslabs/aws-c-cal/pull/126" diff --git a/recipes/aws-c-cal/all/conanfile.py b/recipes/aws-c-cal/all/conanfile.py new file mode 100644 index 0000000000000..3ed5c70f492e6 --- /dev/null +++ b/recipes/aws-c-cal/all/conanfile.py @@ -0,0 +1,128 @@ +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.51.3" + + +class AwsCCal(ConanFile): + name = "aws-c-cal" + description = "Aws Crypto Abstraction Layer: Cross-Platform, C99 wrapper for cryptography primitives." + topics = ("aws", "amazon", "cloud", "cal", "crypt", ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/awslabs/aws-c-cal" + license = "Apache-2.0", + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _needs_openssl(self): + return self.settings.os != "Windows" and not is_apple_os(self) + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if Version(self.version) <= "0.5.11": + self.requires("aws-c-common/0.6.11") + else: + self.requires("aws-c-common/0.8.2") + if self._needs_openssl: + self.requires("openssl/1.1.1s") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.variables["USE_OPENSSL"] = self._needs_openssl + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-cal")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-c-cal") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-c-cal") + + self.cpp_info.filenames["cmake_find_package"] = "aws-c-cal" + self.cpp_info.filenames["cmake_find_package_multi"] = "aws-c-cal" + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" + self.cpp_info.components["aws-c-cal-lib"].names["cmake_find_package"] = "aws-c-cal" + self.cpp_info.components["aws-c-cal-lib"].names["cmake_find_package_multi"] = "aws-c-cal" + self.cpp_info.components["aws-c-cal-lib"].set_property("cmake_target_name", "AWS::aws-c-cal") + + self.cpp_info.components["aws-c-cal-lib"].libs = ["aws-c-cal"] + self.cpp_info.components["aws-c-cal-lib"].requires = ["aws-c-common::aws-c-common-lib"] + if self.settings.os == "Windows": + self.cpp_info.components["aws-c-cal-lib"].system_libs.append("ncrypt") + elif is_apple_os(self): + self.cpp_info.components["aws-c-cal-lib"].frameworks.extend(["CoreFoundation", "Security"]) + elif self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.components["aws-c-cal-lib"].system_libs.append("dl") + + self.user_info.with_openssl = self._needs_openssl + if self._needs_openssl: + self.cpp_info.components["aws-c-cal-lib"].requires.append("openssl::crypto") + if not self.dependencies["openssl"].options.shared: + # aws-c-cal does not statically link to openssl and searches dynamically for openssl symbols . + # Mark these as undefined so the linker will include them. + # This avoids dynamical look-up for a system crypto library. + crypto_symbols = [ + "HMAC_Update", "HMAC_Final", "HMAC_Init_ex", + ] + if Version(self.dependencies["openssl"].ref.version) >= "1.1": + crypto_symbols.extend([ + "HMAC_CTX_new", "HMAC_CTX_free", "HMAC_CTX_reset", + ]) + else: + crypto_symbols.extend([ + "HMAC_CTX_init", "HMAC_CTX_cleanup", "HMAC_CTX_reset", + ]) + crypto_link_flags = "-Wl," + ",".join(f"-u{symbol}" for symbol in crypto_symbols) + self.cpp_info.components["aws-c-cal-lib"].exelinkflags.append(crypto_link_flags) + self.cpp_info.components["aws-c-cal-lib"].sharedlinkflags.append(crypto_link_flags) diff --git a/recipes/aws-c-cal/all/patches/0001-use-openssl-cmake-imported-target.patch b/recipes/aws-c-cal/all/patches/0001-use-openssl-cmake-imported-target.patch new file mode 100644 index 0000000000000..2ebcf79f59924 --- /dev/null +++ b/recipes/aws-c-cal/all/patches/0001-use-openssl-cmake-imported-target.patch @@ -0,0 +1,19 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -86,12 +86,12 @@ + if (USE_OPENSSL AND NOT ANDROID) + find_package(OpenSSL REQUIRED) + find_package(Threads REQUIRED) +- add_library(crypto UNKNOWN IMPORTED) ++ add_library(crypto INTERFACE IMPORTED) + set_target_properties(crypto PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") + set_target_properties(crypto PROPERTIES +- IMPORTED_LINK_INTERFACE_LANGUAGES "C" +- IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}") ++ #IMPORTED_LINK_INTERFACE_LANGUAGES "C" ++ INTERFACE_LINK_LIBRARIES "OpenSSL::Crypto") + add_dependencies(crypto Threads::Threads) + message(STATUS "Using libcrypto from system: ${OPENSSL_CRYPTO_LIBRARY}") + elseif(NOT USE_OPENSSL AND IN_SOURCE_BUILD) + diff --git a/recipes/aws-c-cal/all/patches/0002-apple-corefoundation-0.5.11.patch b/recipes/aws-c-cal/all/patches/0002-apple-corefoundation-0.5.11.patch new file mode 100644 index 0000000000000..3de09bddfa119 --- /dev/null +++ b/recipes/aws-c-cal/all/patches/0002-apple-corefoundation-0.5.11.patch @@ -0,0 +1,26 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -76,7 +76,12 @@ elseif (APPLE) + message(FATAL_ERROR "Security Framework not found") + endif () + +- list(APPEND PLATFORM_LIBS "-framework Security") ++ find_library(COREFOUNDATION_LIB CoreFoundation) ++ if(NOT COREFOUNDATION_LIB) ++ message(FATAL_ERROR "CoreFoundation Framework not found") ++ endif() ++ ++ list(APPEND PLATFORM_LIBS "-framework Security -framework CoreFoundation") + endif() + else () + if (NOT BYO_CRYPTO) +--- a/source/darwin/securityframework_ecc.c ++++ b/source/darwin/securityframework_ecc.c +@@ -7,6 +7,7 @@ + #include + #include + ++#include + #include + #include + diff --git a/recipes/aws-c-cal/all/patches/0002-apple-corefoundation-0.5.13.patch b/recipes/aws-c-cal/all/patches/0002-apple-corefoundation-0.5.13.patch new file mode 100644 index 0000000000000..422624b80de7e --- /dev/null +++ b/recipes/aws-c-cal/all/patches/0002-apple-corefoundation-0.5.13.patch @@ -0,0 +1,26 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -78,7 +78,12 @@ elseif (APPLE) + message(FATAL_ERROR "Security Framework not found") + endif () + +- list(APPEND PLATFORM_LIBS "-framework Security") ++ find_library(COREFOUNDATION_LIB CoreFoundation) ++ if(NOT COREFOUNDATION_LIB) ++ message(FATAL_ERROR "CoreFoundation Framework not found") ++ endif() ++ ++ list(APPEND PLATFORM_LIBS "-framework Security -framework CoreFoundation") + endif() + else () + if (NOT BYO_CRYPTO) +--- a/source/darwin/securityframework_ecc.c ++++ b/source/darwin/securityframework_ecc.c +@@ -7,6 +7,7 @@ + #include + #include + ++#include + #include + #include + diff --git a/recipes/aws-c-cal/all/test_package/CMakeLists.txt b/recipes/aws-c-cal/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7ed07f4d9b8e6 --- /dev/null +++ b/recipes/aws-c-cal/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(aws-c-cal REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-cal) diff --git a/recipes/aws-c-cal/all/test_package/conanfile.py b/recipes/aws-c-cal/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1b3c18ef08ac1 --- /dev/null +++ b/recipes/aws-c-cal/all/test_package/conanfile.py @@ -0,0 +1,31 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os +import io + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + stream = io.StringIO() + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun", output=stream) + self.output.info(stream.getvalue()) + if self.deps_user_info["aws-c-cal"].with_openssl == "True": + assert "found static libcrypto" in stream.getvalue() diff --git a/recipes/aws-c-cal/all/test_package/test_package.c b/recipes/aws-c-cal/all/test_package/test_package.c new file mode 100644 index 0000000000000..a82e5eb0a2146 --- /dev/null +++ b/recipes/aws-c-cal/all/test_package/test_package.c @@ -0,0 +1,19 @@ +#include + +int main() { + struct aws_allocator* allocator = aws_default_allocator(); + + struct aws_logger_standard_options options; + options.level = AWS_LL_TRACE; + options.filename = NULL; + options.file = stdout; + struct aws_logger logger; + aws_logger_init_standard(&logger, allocator, &options); + aws_logger_set(&logger); + + aws_cal_library_init(allocator); + aws_cal_library_clean_up(); + aws_logger_clean_up(&logger); + + return EXIT_SUCCESS; +} diff --git a/recipes/aws-c-cal/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-cal/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..8a88842ed46e6 --- /dev/null +++ b/recipes/aws-c-cal/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-cal REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-cal) diff --git a/recipes/aws-c-cal/all/test_v1_package/conanfile.py b/recipes/aws-c-cal/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..ff0f4e1acbd6f --- /dev/null +++ b/recipes/aws-c-cal/all/test_v1_package/conanfile.py @@ -0,0 +1,22 @@ +from conans import ConanFile, CMake, tools +import os +import io + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + stream = io.StringIO() + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True, output=stream) + self.output.info(stream.getvalue()) + if self.deps_user_info["aws-c-cal"].with_openssl == "True": + assert "found static libcrypto" in stream.getvalue() diff --git a/recipes/aws-c-cal/config.yml b/recipes/aws-c-cal/config.yml new file mode 100644 index 0000000000000..f969df4acc583 --- /dev/null +++ b/recipes/aws-c-cal/config.yml @@ -0,0 +1,13 @@ +versions: + "0.5.20": + folder: all + "0.5.19": + folder: all + "0.5.17": + folder: all + "0.5.13": + folder: all + "0.5.12": + folder: all + "0.5.11": + folder: all diff --git a/recipes/aws-c-common/all/CMakeLists.txt b/recipes/aws-c-common/all/CMakeLists.txt deleted file mode 100644 index fe3c5e109c923..0000000000000 --- a/recipes/aws-c-common/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper LANGUAGES C) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/aws-c-common/all/conandata.yml b/recipes/aws-c-common/all/conandata.yml index 05764c23ef2c4..773702bbe2c98 100644 --- a/recipes/aws-c-common/all/conandata.yml +++ b/recipes/aws-c-common/all/conandata.yml @@ -1,8 +1,56 @@ sources: + "0.8.2": + url: "https://github.com/awslabs/aws-c-common/archive/v0.8.2.tar.gz" + sha256: "36edc6e486c43bbb34059dde227e872c0d41ab54f0b3609d38f188cfbbc6d1f8" + "0.7.5": + url: "https://github.com/awslabs/aws-c-common/archive/v0.7.5.tar.gz" + sha256: "e34fd3d3d32e3597f572205aaabbe995e162f4015e14c7328987b596bd25812c" + "0.7.4": + url: "https://github.com/awslabs/aws-c-common/archive/v0.7.4.tar.gz" + sha256: "e9462a141b5db30006704f537d19b92357a59be38d590272e6118976b0356ccd" + "0.7.3": + url: "https://github.com/awslabs/aws-c-common/archive/v0.7.3.tar.gz" + sha256: "e4b80d368668814d9b76989fd2e3cd0fcf0be160bbb8bfeedf1f652e27f9c08c" + "0.7.2": + url: "https://github.com/awslabs/aws-c-common/archive/v0.7.2.tar.gz" + sha256: "455aed7447ed58eb7d5d3e8c952ed59f77c71dfed4115883e900f36d95f06dab" + "0.7.1": + url: "https://github.com/awslabs/aws-c-common/archive/v0.7.1.tar.gz" + sha256: "75c444a337e446e82d4f71c127118981656234b25cbdfd5913b8de713354fb43" + "0.7.0": + url: "https://github.com/awslabs/aws-c-common/archive/v0.7.0.tar.gz" + sha256: "a4e94d2c1d045a27467c9dfae51382f851a5223c3a0ecc15a96d1dba94f85ad6" + "0.6.20": + url: "https://github.com/awslabs/aws-c-common/archive/v0.6.20.tar.gz" + sha256: "6eb0b806c78b36a32eec9bcba8d2833e3973491a29d46fe3d11edc3f8d3e7f73" + "0.6.19": + url: "https://github.com/awslabs/aws-c-common/archive/v0.6.19.tar.gz" + sha256: "91cb2b809687be19fce8d6ca03ddc00c78723854ead30dcb58bdc4172cb1796c" + "0.6.17": + url: "https://github.com/awslabs/aws-c-common/archive/v0.6.17.tar.gz" + sha256: "441156ecfabb84e41601d7173a7f88267f099899f0ae6091c3b745d9e02211f6" + "0.6.15": + url: "https://github.com/awslabs/aws-c-common/archive/v0.6.15.tar.gz" + sha256: "eb3ead3fb7a1f09c046393f776a96a0f50ae5f38c70d462273084280383669f1" + "0.6.14": + url: "https://github.com/awslabs/aws-c-common/archive/v0.6.14.tar.gz" + sha256: "1691c9dad5a0d236c2a0e351cc972231b176947e454c61d1c4b3ea4ab42f32e7" + "0.6.11": + url: "https://github.com/awslabs/aws-c-common/archive/v0.6.11.tar.gz" + sha256: "86159bd1128eee2813f705c275d319e14d1b77017fab46f6ca5dafcc66edaea9" + "0.6.9": + url: "https://github.com/awslabs/aws-c-common/archive/v0.6.9.tar.gz" + sha256: "928a3e36f24d1ee46f9eec360ec5cebfe8b9b8994fe39d4fa74ff51aebb12717" + "0.6.8": + url: "https://github.com/awslabs/aws-c-common/archive/v0.6.8.tar.gz" + sha256: "2997e851ed690a614507a43f4c393f45a198614d94da1660ecdf9b5a729535fc" + "0.6.7": + url: "https://github.com/awslabs/aws-c-common/archive/v0.6.7.tar.gz" + sha256: "643b35c62f948367f484f3a436bc37b5799538f47b08aa72deb3818b8bcdc631" "0.4.25": - sha256: "f85a8f74e42bd983a4615654457f8037876bc6b8dbf890e368bb516cbc2e9844" url: "https://github.com/awslabs/aws-c-common/archive/v0.4.25.tar.gz" + sha256: "f85a8f74e42bd983a4615654457f8037876bc6b8dbf890e368bb516cbc2e9844" patches: "0.4.25": - patch_file: "patches/0001-disable-fPIC.patch" - base_path: "source_subfolder" + - patch_file: "patches/0002-no-warnings-as-errors.patch" diff --git a/recipes/aws-c-common/all/conanfile.py b/recipes/aws-c-common/all/conanfile.py index 827f3b10b602f..53aa924766140 100644 --- a/recipes/aws-c-common/all/conanfile.py +++ b/recipes/aws-c-common/all/conanfile.py @@ -1,85 +1,114 @@ -from conans import CMake, ConanFile, tools +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version import os -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.51.3" + class AwsCCommon(ConanFile): name = "aws-c-common" - description = "Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling." - topics = ("conan", "aws", "amazon", "cloud", ) + description = ( + "Core c99 package for AWS SDK for C. Includes cross-platform " + "primitives, configuration, data structures, and error handling." + ) + topics = ("aws", "amazon", "cloud", ) url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/awslabs/aws-sdk-cpp" + homepage = "https://github.com/awslabs/aws-c-common" license = "Apache-2.0", - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], + "cpu_extensions": [True, False], } default_options = { "shared": False, "fPIC": True, + "cpu_extensions": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if Version(self.version) < "0.6.11": + del self.options.cpu_extensions def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def validate(self): + if self.info.options.shared and is_msvc(self) and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration("Static runtime + shared is not working for more recent releases") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "aws-c-common-{}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure() - return self._cmake - - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.variables["AWS_ENABLE_LTO"] = False + if Version(self.version) >= "0.6.0": + tc.variables["AWS_WARNINGS_ARE_ERRORS"] = False + if is_msvc(self): + tc.variables["STATIC_CRT"] = is_msvc_static_runtime(self) + tc.variables["USE_CPU_EXTENSIONS"] = self.options.get_safe("cpu_extensions", False) + tc.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - - tools.rmdir(os.path.join(self.package_folder, "lib", "aws-c-common")) + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-common")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-c-common") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-c-common") + self.cpp_info.filenames["cmake_find_package"] = "aws-c-common" self.cpp_info.filenames["cmake_find_package_multi"] = "aws-c-common" self.cpp_info.names["cmake_find_package"] = "AWS" self.cpp_info.names["cmake_find_package_multi"] = "AWS" + self.cpp_info.components["aws-c-common-lib"].set_property("cmake_target_name", "AWS::aws-c-common") self.cpp_info.components["aws-c-common-lib"].names["cmake_find_package"] = "aws-c-common" self.cpp_info.components["aws-c-common-lib"].names["cmake_find_package_multi"] = "aws-c-common" + self.cpp_info.components["aws-c-common-lib"].libs = ["aws-c-common"] - if self.settings.os == "Linux": - self.cpp_info.components["aws-c-common-lib"].system_libs = ["m", "pthread", "rt"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["aws-c-common-lib"].system_libs = ["dl", "m", "pthread", "rt"] elif self.settings.os == "Windows": self.cpp_info.components["aws-c-common-lib"].system_libs = ["bcrypt", "ws2_32"] + if Version(self.version) >= "0.6.13": + self.cpp_info.components["aws-c-common-lib"].system_libs.append("shlwapi") if not self.options.shared: - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): self.cpp_info.components["aws-c-common-lib"].frameworks = ["CoreFoundation"] - self.cpp_info.components["aws-c-common-lib"].builddirs = [os.path.join("lib", "cmake")] + self.cpp_info.components["aws-c-common-lib"].builddirs.append(os.path.join("lib", "cmake")) diff --git a/recipes/aws-c-common/all/patches/0002-no-warnings-as-errors.patch b/recipes/aws-c-common/all/patches/0002-no-warnings-as-errors.patch new file mode 100644 index 0000000000000..8abe45bd0a3d6 --- /dev/null +++ b/recipes/aws-c-common/all/patches/0002-no-warnings-as-errors.patch @@ -0,0 +1,20 @@ +--- a/cmake/AwsCFlags.cmake ++++ b/cmake/AwsCFlags.cmake +@@ -34,7 +34,7 @@ function(aws_set_common_properties target) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" PARENT_SCOPE) + endif() + +- list(APPEND AWS_C_FLAGS /W4 /WX /MP) ++ list(APPEND AWS_C_FLAGS /W4 /MP) + # /volatile:iso relaxes some implicit memory barriers that MSVC normally applies for volatile accesses + # Since we want to be compatible with user builds using /volatile:iso, use it for the tests. + list(APPEND AWS_C_FLAGS /volatile:iso) +@@ -49,7 +49,7 @@ function(aws_set_common_properties target) + list(APPEND AWS_C_FLAGS "${_FLAGS}") + + else() +- list(APPEND AWS_C_FLAGS -Wall -Werror -Wstrict-prototypes) ++ list(APPEND AWS_C_FLAGS -Wall -Wstrict-prototypes) + + if(NOT SET_PROPERTIES_NO_WEXTRA) + list(APPEND AWS_C_FLAGS -Wextra) diff --git a/recipes/aws-c-common/all/test_package/CMakeLists.txt b/recipes/aws-c-common/all/test_package/CMakeLists.txt index 71cecbe9bdcb2..c60f5562de5c5 100644 --- a/recipes/aws-c-common/all/test_package/CMakeLists.txt +++ b/recipes/aws-c-common/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - find_package(aws-c-common REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} AWS::aws-c-common) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-common) diff --git a/recipes/aws-c-common/all/test_package/conanfile.py b/recipes/aws-c-common/all/test_package/conanfile.py index 7e2dfe859bb27..d120a992c06a6 100644 --- a/recipes/aws-c-common/all/test_package/conanfile.py +++ b/recipes/aws-c-common/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-c-common/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-common/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..089f7544e3394 --- /dev/null +++ b/recipes/aws-c-common/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-common REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-common) diff --git a/recipes/aws-c-common/all/test_v1_package/conanfile.py b/recipes/aws-c-common/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/aws-c-common/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-c-common/config.yml b/recipes/aws-c-common/config.yml index ce5ce8265fc78..5a8e794412c2f 100644 --- a/recipes/aws-c-common/config.yml +++ b/recipes/aws-c-common/config.yml @@ -1,3 +1,35 @@ versions: + "0.8.2": + folder: all + "0.7.5": + folder: all + "0.7.4": + folder: all + "0.7.3": + folder: all + "0.7.2": + folder: all + "0.7.1": + folder: all + "0.7.0": + folder: all + "0.6.20": + folder: all + "0.6.19": + folder: all + "0.6.17": + folder: all + "0.6.15": + folder: all + "0.6.14": + folder: all + "0.6.11": + folder: all + "0.6.9": + folder: all + "0.6.8": + folder: all + "0.6.7": + folder: all "0.4.25": folder: all diff --git a/recipes/aws-c-compression/all/conandata.yml b/recipes/aws-c-compression/all/conandata.yml new file mode 100644 index 0000000000000..1baf0be5b106a --- /dev/null +++ b/recipes/aws-c-compression/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "0.2.15": + url: "https://github.com/awslabs/aws-c-compression/archive/v0.2.15.tar.gz" + sha256: "11d58a229e2961b2b36493155a981dea2c8a0bc0d113b0073deb8c3189cfa04e" + "0.2.14": + url: "https://github.com/awslabs/aws-c-compression/archive/v0.2.14.tar.gz" + sha256: "8737863ced57d92f5a0bdde554bf0fe70eaa76aae118fec09a6c361dfc55d0d5" + "0.2.13": + url: "https://github.com/awslabs/aws-c-compression/archive/v0.2.13.tar.gz" + sha256: "6b6ebb223408b48a8b2c74ba7042ff61e5333dc900acd67c40ca1cd4b382c137" diff --git a/recipes/aws-c-compression/all/conanfile.py b/recipes/aws-c-compression/all/conanfile.py new file mode 100644 index 0000000000000..635a3e71fc9b4 --- /dev/null +++ b/recipes/aws-c-compression/all/conanfile.py @@ -0,0 +1,88 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +import os + +required_conan_version = ">=1.47.0" + + +class AwsCCompression(ConanFile): + name = "aws-c-compression" + description = "C99 implementation of huffman encoding/decoding" + topics = ("aws", "amazon", "cloud", "compression", "huffman", ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/awslabs/aws-c-compression" + license = "Apache-2.0", + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("aws-c-common/0.8.2") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-compression")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-c-compression") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-c-compression") + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["aws-c-compression-lib"].libs = ["aws-c-compression"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.filenames["cmake_find_package"] = "aws-c-compression" + self.cpp_info.filenames["cmake_find_package_multi"] = "aws-c-compression" + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" + self.cpp_info.components["aws-c-compression-lib"].names["cmake_find_package"] = "aws-c-compression" + self.cpp_info.components["aws-c-compression-lib"].names["cmake_find_package_multi"] = "aws-c-compression" + self.cpp_info.components["aws-c-compression-lib"].set_property("cmake_target_name", "AWS::aws-c-compression") + self.cpp_info.components["aws-c-compression-lib"].requires = ["aws-c-common::aws-c-common-lib"] diff --git a/recipes/aws-c-compression/all/test_package/CMakeLists.txt b/recipes/aws-c-compression/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8efb2e9b0efa5 --- /dev/null +++ b/recipes/aws-c-compression/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(aws-c-compression REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-compression) diff --git a/recipes/aws-c-compression/all/test_package/conanfile.py b/recipes/aws-c-compression/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/aws-c-compression/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-c-compression/all/test_package/test_package.c b/recipes/aws-c-compression/all/test_package/test_package.c new file mode 100644 index 0000000000000..3c3523903fd35 --- /dev/null +++ b/recipes/aws-c-compression/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include + +int main() { + struct aws_allocator *allocator = aws_default_allocator(); + aws_compression_library_init(allocator); + aws_compression_library_clean_up(); + + return EXIT_SUCCESS; +} diff --git a/recipes/aws-c-compression/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-compression/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e3ad5964d2a88 --- /dev/null +++ b/recipes/aws-c-compression/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-compression REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-compression) diff --git a/recipes/aws-c-compression/all/test_v1_package/conanfile.py b/recipes/aws-c-compression/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/aws-c-compression/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-c-compression/config.yml b/recipes/aws-c-compression/config.yml new file mode 100644 index 0000000000000..5a381bb0e6674 --- /dev/null +++ b/recipes/aws-c-compression/config.yml @@ -0,0 +1,7 @@ +versions: + "0.2.15": + folder: all + "0.2.14": + folder: all + "0.2.13": + folder: all diff --git a/recipes/aws-c-event-stream/all/CMakeLists.txt b/recipes/aws-c-event-stream/all/CMakeLists.txt deleted file mode 100644 index 969e73de12b57..0000000000000 --- a/recipes/aws-c-event-stream/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.0) -project(cmake_wrapper LANGUAGES C) - -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(source_subfolder) diff --git a/recipes/aws-c-event-stream/all/conandata.yml b/recipes/aws-c-event-stream/all/conandata.yml index d445092b9b0ee..61428e916296b 100644 --- a/recipes/aws-c-event-stream/all/conandata.yml +++ b/recipes/aws-c-event-stream/all/conandata.yml @@ -1,10 +1,20 @@ sources: + "0.2.15": + url: "https://github.com/awslabs/aws-c-event-stream/archive/v0.2.15.tar.gz" + sha256: "4ff2ada07ede3c6afa4b8e6e20de541e717038307f29b38c27efa7c4d875ee26" + "0.2.12": + url: "https://github.com/awslabs/aws-c-event-stream/archive/v0.2.12.tar.gz" + sha256: "cc4ebfe715d8df5b9e3f4a3ce9b67d5f480017a7ebbbfa1d5e64ea53ec672580" + "0.2.11": + url: "https://github.com/awslabs/aws-c-event-stream/archive/v0.2.11.tar.gz" + sha256: "4818b8d3fe02016fcfdd033c1e9d8f6be07ccaeb38664fe8c31c0fd153ea56e6" + "0.2.7": + url: "https://github.com/awslabs/aws-c-event-stream/archive/v0.2.7.tar.gz" + sha256: "bb5c94cdff70c1985fb0b5f30d81756cedb5a3c3075d37f7e1e2b34e2a33c8c0" "0.1.5": - sha256: "f1b423a487b5d6dca118bfc0d0c6cc596dc476b282258a3228e73a8f730422d4" url: "https://github.com/awslabs/aws-c-event-stream/archive/v0.1.5.tar.gz" + sha256: "f1b423a487b5d6dca118bfc0d0c6cc596dc476b282258a3228e73a8f730422d4" patches: "0.1.5": - - base_path: "source_subfolder" - patch_file: "patches/0001-disable-tests-bin.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-use-PROJECT_SOURCE_DIR.patch" + - patch_file: "patches/0001-disable-tests-bin.patch" + - patch_file: "patches/0002-use-PROJECT_SOURCE_DIR.patch" diff --git a/recipes/aws-c-event-stream/all/conanfile.py b/recipes/aws-c-event-stream/all/conanfile.py index d25909c26428e..25bb2fd989f0a 100644 --- a/recipes/aws-c-event-stream/all/conanfile.py +++ b/recipes/aws-c-event-stream/all/conanfile.py @@ -1,17 +1,18 @@ -from conans import CMake, ConanFile, tools +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout import os -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.52.0" class AwsCEventStream(ConanFile): name = "aws-c-event-stream" description = "C99 implementation of the vnd.amazon.eventstream content-type" - topics = ("conan", "aws", "eventstream", "content", ) + license = "Apache-2.0", url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/awslabs/aws-c-event-stream" - license = "Apache-2.0", - exports_sources = "CMakeLists.txt", "aws_eventstream_target.cmake", "patches/*" - generators = "cmake", "cmake_find_package" + topics = ("aws", "eventstream", "content", ) settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -22,11 +23,8 @@ class AwsCEventStream(ConanFile): "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -34,50 +32,69 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("aws-c-common/0.4.25") - self.requires("aws-checksums/0.1.5") + self.requires("aws-checksums/0.1.13") + self.requires("aws-c-common/0.8.2") + if Version(self.version) >= "0.2": + if Version(self.version) < "0.2.11": + self.requires("aws-c-io/0.10.20") + else: + self.requires("aws-c-io/0.13.4") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "aws-c-event-stream-{}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_BINARIES"] = False - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_BINARIES"] = False + tc.variables["BUILD_TESTING"] = False + tc.generate() - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + deps = CMakeDeps(self) + deps.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "aws-c-event-stream")) + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-event-stream")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-c-event-stream") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-c-event-stream") + self.cpp_info.components["aws-c-event-stream-lib"].names["cmake_find_package"] = "aws-c-event-stream" + self.cpp_info.components["aws-c-event-stream-lib"].names["cmake_find_package_multi"] = "aws-c-event-stream" + self.cpp_info.components["aws-c-event-stream-lib"].libs = ["aws-c-event-stream"] + self.cpp_info.components["aws-c-event-stream-lib"].requires = ["aws-c-common::aws-c-common-lib", "aws-checksums::aws-checksums"] + if Version(self.version) >= "0.2": + self.cpp_info.components["aws-c-event-stream-lib"].requires.append("aws-c-io::aws-c-io-lib") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.filenames["cmake_find_package"] = "aws-c-event-stream" self.cpp_info.filenames["cmake_find_package_multi"] = "aws-c-event-stream" self.cpp_info.names["cmake_find_package"] = "AWS" self.cpp_info.names["cmake_find_package_multi"] = "AWS" - self.cpp_info.components["aws-c-event-stream-lib"].names["cmake_find_package"] = "aws-c-event-stream" - self.cpp_info.components["aws-c-event-stream-lib"].names["cmake_find_package_multi"] = "aws-c-event-stream" - self.cpp_info.components["aws-c-event-stream-lib"].libs = ["aws-c-event-stream"] - self.cpp_info.components["aws-c-event-stream-lib"].requires = ["aws-c-common::aws-c-common", "aws-checksums::aws-checksums"] diff --git a/recipes/aws-c-event-stream/all/test_package/CMakeLists.txt b/recipes/aws-c-event-stream/all/test_package/CMakeLists.txt index 9623c5ba8bc47..05cae5027e20e 100644 --- a/recipes/aws-c-event-stream/all/test_package/CMakeLists.txt +++ b/recipes/aws-c-event-stream/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - find_package(aws-c-event-stream REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} AWS::aws-c-event-stream) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-event-stream) diff --git a/recipes/aws-c-event-stream/all/test_package/conanfile.py b/recipes/aws-c-event-stream/all/test_package/conanfile.py index 7e2dfe859bb27..a9fb96656f203 100644 --- a/recipes/aws-c-event-stream/all/test_package/conanfile.py +++ b/recipes/aws-c-event-stream/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-c-event-stream/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-event-stream/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..674dc4a319004 --- /dev/null +++ b/recipes/aws-c-event-stream/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-event-stream REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-event-stream) diff --git a/recipes/aws-c-event-stream/all/test_v1_package/conanfile.py b/recipes/aws-c-event-stream/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/aws-c-event-stream/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-c-event-stream/config.yml b/recipes/aws-c-event-stream/config.yml index 7944b76e5ee5d..96ac653286f12 100644 --- a/recipes/aws-c-event-stream/config.yml +++ b/recipes/aws-c-event-stream/config.yml @@ -1,3 +1,11 @@ versions: - 0.1.5: + "0.2.15": + folder: all + "0.2.12": + folder: all + "0.2.11": + folder: all + "0.2.7": + folder: all + "0.1.5": folder: all diff --git a/recipes/aws-c-http/all/conandata.yml b/recipes/aws-c-http/all/conandata.yml new file mode 100644 index 0000000000000..09a36b1a86c13 --- /dev/null +++ b/recipes/aws-c-http/all/conandata.yml @@ -0,0 +1,16 @@ +sources: + "0.6.22": + url: "https://github.com/awslabs/aws-c-http/archive/v0.6.22.tar.gz" + sha256: "a178fd04bd1618469cd21afc5b84cbe436d1f9d9e036fefbd3a8f00356da4d4c" + "0.6.13": + url: "https://github.com/awslabs/aws-c-http/archive/v0.6.13.tar.gz" + sha256: "8c69f8fc58b7073039e598383da3e1fd9b23f392cb992dbe769a7b80f342dbaf" + "0.6.10": + url: "https://github.com/awslabs/aws-c-http/archive/v0.6.10.tar.gz" + sha256: "4413faf2b8f6a83c898bb535cf83542fa548d7ecc1acf681dc79b7959a07231a" + "0.6.7": + url: "https://github.com/awslabs/aws-c-http/archive/v0.6.7.tar.gz" + sha256: "2244d1e26ce5b5f40f96e570b1c4332a07c645ef744644d5b90b089d3695ec3b" + "0.6.5": + url: "https://github.com/awslabs/aws-c-http/archive/v0.6.5.tar.gz" + sha256: "9cb82f1cfe1342f4bbd58f51b74beaeb6a544fb6792c48f9b0d3967619b33221" diff --git a/recipes/aws-c-http/all/conanfile.py b/recipes/aws-c-http/all/conanfile.py new file mode 100644 index 0000000000000..5f4b5242c4dbe --- /dev/null +++ b/recipes/aws-c-http/all/conanfile.py @@ -0,0 +1,96 @@ +from conan import ConanFile +from conan.tools.scm import Version +from conan.tools.files import get, copy, rmdir +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.47.0" + +class AwsCHttp(ConanFile): + name = "aws-c-http" + description = "C99 implementation of the HTTP/1.1 and HTTP/2 specifications" + license = "Apache-2.0", + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/awslabs/aws-c-http" + topics = ("aws", "amazon", "cloud", "http", "http2", ) + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("aws-c-common/0.8.2") + self.requires("aws-c-compression/0.2.15") + if Version(self.version) < "0.6.22": + self.requires("aws-c-io/0.10.20") + else: + self.requires("aws-c-io/0.13.4") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-http")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-c-http") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-c-http") + + self.cpp_info.filenames["cmake_find_package"] = "aws-c-http" + self.cpp_info.filenames["cmake_find_package_multi"] = "aws-c-http" + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" + + self.cpp_info.components["aws-c-http-lib"].set_property("cmake_target_name", "AWS::aws-c-http") + self.cpp_info.components["aws-c-http-lib"].names["cmake_find_package"] = "aws-c-http" + self.cpp_info.components["aws-c-http-lib"].names["cmake_find_package_multi"] = "aws-c-http" + self.cpp_info.components["aws-c-http-lib"].libs = ["aws-c-http"] + self.cpp_info.components["aws-c-http-lib"].requires = [ + "aws-c-common::aws-c-common-lib", + "aws-c-compression::aws-c-compression-lib", + "aws-c-io::aws-c-io-lib" + ] diff --git a/recipes/aws-c-http/all/test_package/CMakeLists.txt b/recipes/aws-c-http/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..94387e3cbcded --- /dev/null +++ b/recipes/aws-c-http/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(aws-c-http REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-http) diff --git a/recipes/aws-c-http/all/test_package/conanfile.py b/recipes/aws-c-http/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/aws-c-http/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-c-http/all/test_package/test_package.c b/recipes/aws-c-http/all/test_package/test_package.c new file mode 100644 index 0000000000000..0891853e8abbf --- /dev/null +++ b/recipes/aws-c-http/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include + +int main() { + struct aws_allocator *allocator = aws_default_allocator(); + aws_http_library_init(allocator); + aws_http_library_clean_up(); + + return EXIT_SUCCESS; +} diff --git a/recipes/aws-c-http/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-http/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b3195e120b0b2 --- /dev/null +++ b/recipes/aws-c-http/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) + +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-http REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-http) diff --git a/recipes/aws-c-http/all/test_v1_package/conanfile.py b/recipes/aws-c-http/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/aws-c-http/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-c-http/config.yml b/recipes/aws-c-http/config.yml new file mode 100644 index 0000000000000..ab4b9f0488086 --- /dev/null +++ b/recipes/aws-c-http/config.yml @@ -0,0 +1,11 @@ +versions: + "0.6.22": + folder: all + "0.6.13": + folder: all + "0.6.10": + folder: all + "0.6.7": + folder: all + "0.6.5": + folder: all diff --git a/recipes/aws-c-io/all/conandata.yml b/recipes/aws-c-io/all/conandata.yml new file mode 100644 index 0000000000000..4a9102a6ede26 --- /dev/null +++ b/recipes/aws-c-io/all/conandata.yml @@ -0,0 +1,19 @@ +sources: + "0.13.4": + url: "https://github.com/awslabs/aws-c-io/archive/v0.13.4.tar.gz" + sha256: "133bd0aa46caa2041962cd4f6d076209686ce2934af82f86d1a258df4cbdce8b" + "0.11.2": + url: "https://github.com/awslabs/aws-c-io/archive/v0.11.2.tar.gz" + sha256: "b60270d23b6e2f4a5d80e64ca6538ba114cd6044b53752964c940f87e59bf0d9" + "0.10.20": + url: "https://github.com/awslabs/aws-c-io/archive/v0.10.20.tar.gz" + sha256: "293248ef96166826370223865bff2537bea5e08f6913919884c53add8238ba97" + "0.10.13": + url: "https://github.com/awslabs/aws-c-io/archive/v0.10.13.tar.gz" + sha256: "ee34a93190e35a5c372ba73661dd69c48986e051a4b26dedb62bc5aa78f1660f" + "0.10.9": + url: "https://github.com/awslabs/aws-c-io/archive/v0.10.9.tar.gz" + sha256: "c64464152abe8b7e23f10bc026ed54a15eaf0ec0aae625d28e2caf4489090327" + "0.10.5": + url: "https://github.com/awslabs/aws-c-io/archive/v0.10.5.tar.gz" + sha256: "59abd4606661790cc0b777807938f3134cce77c03383015781498cfbfd191811" diff --git a/recipes/aws-c-io/all/conanfile.py b/recipes/aws-c-io/all/conanfile.py new file mode 100644 index 0000000000000..84b513c37e69f --- /dev/null +++ b/recipes/aws-c-io/all/conanfile.py @@ -0,0 +1,104 @@ +from conan import ConanFile +from conan.tools.files import get, copy, rmdir +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.52.0" + +class AwsCIO(ConanFile): + name = "aws-c-io" + description = "IO and TLS for application protocols" + license = "Apache-2.0", + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/awslabs/aws-c-io" + topics = ("aws", "amazon", "cloud", "io", "tls",) + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + # the versions of aws-c-common and aws-c-io are tied since aws-c-common/0.6.12 and aws-c-io/0.10.10 + # Please refer https://github.com/conan-io/conan-center-index/issues/7763 + if Version(self.version) <= "0.10.9": + self.requires("aws-c-common/0.6.11") + self.requires("aws-c-cal/0.5.11") + else: + self.requires("aws-c-common/0.8.2") + self.requires("aws-c-cal/0.5.13") + + if self.settings.os in ["Linux", "FreeBSD", "Android"]: + self.requires("s2n/1.3.15") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-io")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-c-io") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-c-io") + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["aws-c-io-lib"].libs = ["aws-c-io"] + if self.settings.os == "Macos": + self.cpp_info.components["aws-c-io-lib"].frameworks.append("Security") + if self.settings.os == "Windows": + self.cpp_info.components["aws-c-io-lib"].system_libs = ["crypt32", "secur32", "shlwapi"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.filenames["cmake_find_package"] = "aws-c-io" + self.cpp_info.filenames["cmake_find_package_multi"] = "aws-c-io" + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" + self.cpp_info.components["aws-c-io-lib"].names["cmake_find_package"] = "aws-c-io" + self.cpp_info.components["aws-c-io-lib"].names["cmake_find_package_multi"] = "aws-c-io" + self.cpp_info.components["aws-c-io-lib"].set_property("cmake_target_name", "AWS::aws-c-io") + self.cpp_info.components["aws-c-io-lib"].requires = ["aws-c-cal::aws-c-cal-lib", "aws-c-common::aws-c-common-lib"] + if self.settings.os in ["Linux", "FreeBSD", "Android"]: + self.cpp_info.components["aws-c-io-lib"].requires.append("s2n::s2n-lib") diff --git a/recipes/aws-c-io/all/test_package/CMakeLists.txt b/recipes/aws-c-io/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..de3176cc25055 --- /dev/null +++ b/recipes/aws-c-io/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(aws-c-io REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} AWS::aws-c-io) diff --git a/recipes/aws-c-io/all/test_package/conanfile.py b/recipes/aws-c-io/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fbb7f543162 --- /dev/null +++ b/recipes/aws-c-io/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-c-io/all/test_package/test_package.c b/recipes/aws-c-io/all/test_package/test_package.c new file mode 100644 index 0000000000000..2cab00be1ddca --- /dev/null +++ b/recipes/aws-c-io/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include + +int main() { + struct aws_allocator *allocator = aws_default_allocator(); + aws_io_library_init(allocator); + aws_io_library_clean_up(); + + return EXIT_SUCCESS; +} diff --git a/recipes/aws-c-io/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-io/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e45dc2bc298c6 --- /dev/null +++ b/recipes/aws-c-io/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-io REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} AWS::aws-c-io) diff --git a/recipes/aws-c-io/all/test_v1_package/conanfile.py b/recipes/aws-c-io/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/aws-c-io/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-c-io/config.yml b/recipes/aws-c-io/config.yml new file mode 100644 index 0000000000000..6dca88e3f0554 --- /dev/null +++ b/recipes/aws-c-io/config.yml @@ -0,0 +1,13 @@ +versions: + "0.13.4": + folder: all + "0.11.2": + folder: all + "0.10.20": + folder: all + "0.10.13": + folder: all + "0.10.9": + folder: all + "0.10.5": + folder: all diff --git a/recipes/aws-c-mqtt/all/conandata.yml b/recipes/aws-c-mqtt/all/conandata.yml new file mode 100644 index 0000000000000..6240cf10ee0f5 --- /dev/null +++ b/recipes/aws-c-mqtt/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "0.7.12": + url: "https://github.com/awslabs/aws-c-mqtt/archive/v0.7.12.tar.gz" + sha256: "cf80f1b4f37aa8a6b8698315fae32cbf2bd944b67784f07b5762f392f18e64df" + "0.7.10": + url: "https://github.com/awslabs/aws-c-mqtt/archive/v0.7.10.tar.gz" + sha256: "95667477e17bc99d49a1d6674d7fb98f9a0379b6966cb2ed4863152e959d9e8f" + "0.7.9": + url: "https://github.com/awslabs/aws-c-mqtt/archive/v0.7.9.tar.gz" + sha256: "8556ae7c2b30ebb4ccb61becb120a848ea33315f7cf85436ebe5f21b75ab09c4" + "0.7.6": + url: "https://github.com/awslabs/aws-c-mqtt/archive/v0.7.6.tar.gz" + sha256: "a02c0525f7ddcdc058cd9f507b2f3a8be0383fc946920ed32c9d780cc29703ac" diff --git a/recipes/aws-c-mqtt/all/conanfile.py b/recipes/aws-c-mqtt/all/conanfile.py new file mode 100644 index 0000000000000..4edb02ac94d9f --- /dev/null +++ b/recipes/aws-c-mqtt/all/conanfile.py @@ -0,0 +1,100 @@ +from conan import ConanFile +from conan.tools.files import get, copy, rmdir +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.47.0" + + +class AwsCMQTT(ConanFile): + name = "aws-c-mqtt" + description = "C99 implementation of the MQTT 3.1.1 specification." + license = "Apache-2.0", + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/awslabs/aws-c-mqtt" + topics = ("aws", "amazon", "cloud", "mqtt") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def requirements(self): + self.requires("aws-c-common/0.8.2") + self.requires("aws-c-cal/0.5.13") + if Version(self.version) < "0.7.12": + self.requires("aws-c-io/0.10.20") + self.requires("aws-c-http/0.6.13") + else: + self.requires("aws-c-io/0.13.4") + self.requires("aws-c-http/0.6.22") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-mqtt")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-c-mqtt") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-c-mqtt") + + self.cpp_info.filenames["cmake_find_package"] = "aws-c-mqtt" + self.cpp_info.filenames["cmake_find_package_multi"] = "aws-c-mqtt" + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" + self.cpp_info.components["aws-c-mqtt-lib"].names["cmake_find_package"] = "aws-c-mqtt" + self.cpp_info.components["aws-c-mqtt-lib"].names["cmake_find_package_multi"] = "aws-c-mqtt" + self.cpp_info.components["aws-c-mqtt-lib"].set_property("cmake_target_name", "AWS::aws-c-mqtt") + + self.cpp_info.components["aws-c-mqtt-lib"].libs = ["aws-c-mqtt"] + self.cpp_info.components["aws-c-mqtt-lib"].requires = [ + "aws-c-common::aws-c-common-lib", + "aws-c-cal::aws-c-cal-lib", + "aws-c-io::aws-c-io-lib", + "aws-c-http::aws-c-http-lib" + ] diff --git a/recipes/aws-c-mqtt/all/test_package/CMakeLists.txt b/recipes/aws-c-mqtt/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..04c8de77ba626 --- /dev/null +++ b/recipes/aws-c-mqtt/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(aws-c-mqtt REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-mqtt) diff --git a/recipes/aws-c-mqtt/all/test_package/conanfile.py b/recipes/aws-c-mqtt/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/aws-c-mqtt/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-c-mqtt/all/test_package/test_package.c b/recipes/aws-c-mqtt/all/test_package/test_package.c new file mode 100644 index 0000000000000..95b2eb760ba12 --- /dev/null +++ b/recipes/aws-c-mqtt/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include + +int main() { + struct aws_allocator *allocator = aws_default_allocator(); + aws_mqtt_library_init(allocator); + aws_mqtt_library_clean_up(); + + return EXIT_SUCCESS; +} diff --git a/recipes/aws-c-mqtt/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-mqtt/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..610e2350e6503 --- /dev/null +++ b/recipes/aws-c-mqtt/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-mqtt REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-mqtt) diff --git a/recipes/aws-c-mqtt/all/test_v1_package/conanfile.py b/recipes/aws-c-mqtt/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/aws-c-mqtt/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-c-mqtt/config.yml b/recipes/aws-c-mqtt/config.yml new file mode 100644 index 0000000000000..edbab7e67d700 --- /dev/null +++ b/recipes/aws-c-mqtt/config.yml @@ -0,0 +1,9 @@ +versions: + "0.7.12": + folder: all + "0.7.10": + folder: all + "0.7.9": + folder: all + "0.7.6": + folder: all diff --git a/recipes/aws-c-s3/all/conandata.yml b/recipes/aws-c-s3/all/conandata.yml new file mode 100644 index 0000000000000..af6e82a742aa6 --- /dev/null +++ b/recipes/aws-c-s3/all/conandata.yml @@ -0,0 +1,16 @@ +sources: + "0.1.49": + url: "https://github.com/awslabs/aws-c-s3/archive/v0.1.49.tar.gz" + sha256: "71acbba41a02477a6c352172da561bc2138bf239b936490c773d7aaa83afc9ab" + "0.1.37": + url: "https://github.com/awslabs/aws-c-s3/archive/v0.1.37.tar.gz" + sha256: "2c35100c1739300e438d47f49aaa2c374001416a79fe3c6f27d79371fb2ac90b" + "0.1.29": + url: "https://github.com/awslabs/aws-c-s3/archive/v0.1.29.tar.gz" + sha256: "bcbc38d091ad994fec2789bffd1d99e157c5e29a60685e836f028006e531bc60" + "0.1.27": + url: "https://github.com/awslabs/aws-c-s3/archive/v0.1.27.tar.gz" + sha256: "8fccbf967c3b29f0feaa1ba3de158b7ead805c3b4302c45b7cad3429f045920c" + "0.1.19": + url: "https://github.com/awslabs/aws-c-s3/archive/v0.1.19.tar.gz" + sha256: "30e17e31eed18e8d621cd3d3978b2e6eeeee5557bfc3a9d701d0d3e1c4a8a74d" diff --git a/recipes/aws-c-s3/all/conanfile.py b/recipes/aws-c-s3/all/conanfile.py new file mode 100644 index 0000000000000..131627214ba79 --- /dev/null +++ b/recipes/aws-c-s3/all/conanfile.py @@ -0,0 +1,103 @@ +from conan import ConanFile +from conan.tools.files import get, copy, rmdir +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.47.0" + +class AwsCS3(ConanFile): + name = "aws-c-s3" + description = "C99 implementation of the S3 client" + license = "Apache-2.0", + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/awslabs/aws-c-s3" + topics = ("aws", "amazon", "cloud", "s3") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("aws-c-common/0.8.2") + if Version(self.version) < "0.1.49": + self.requires("aws-c-io/0.10.20") + self.requires("aws-c-http/0.6.13") + self.requires("aws-c-auth/0.6.11") + else: + self.requires("aws-c-io/0.13.4") + self.requires("aws-c-http/0.6.22") + self.requires("aws-c-auth/0.6.17") + if Version(self.version) >= "0.1.36": + self.requires("aws-checksums/0.1.13") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-s3")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-c-s3") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-c-s3") + + self.cpp_info.filenames["cmake_find_package"] = "aws-c-s3" + self.cpp_info.filenames["cmake_find_package_multi"] = "aws-c-s3" + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" + self.cpp_info.components["aws-c-s3-lib"].names["cmake_find_package"] = "aws-c-s3" + self.cpp_info.components["aws-c-s3-lib"].names["cmake_find_package_multi"] = "aws-c-s3" + self.cpp_info.components["aws-c-s3-lib"].set_property("cmake_target_name", "AWS::aws-c-s3") + + self.cpp_info.components["aws-c-s3-lib"].libs = ["aws-c-s3"] + self.cpp_info.components["aws-c-s3-lib"].requires = [ + "aws-c-common::aws-c-common-lib", + "aws-c-io::aws-c-io-lib", + "aws-c-http::aws-c-http-lib", + "aws-c-auth::aws-c-auth-lib" + ] + if Version(self.version) >= "0.1.36": + self.cpp_info.components["aws-c-s3-lib"].requires.append("aws-checksums::aws-checksums-lib") diff --git a/recipes/aws-c-s3/all/test_package/CMakeLists.txt b/recipes/aws-c-s3/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8e0fdd1abc04c --- /dev/null +++ b/recipes/aws-c-s3/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(aws-c-s3 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-s3) diff --git a/recipes/aws-c-s3/all/test_package/conanfile.py b/recipes/aws-c-s3/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/aws-c-s3/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-c-s3/all/test_package/test_package.c b/recipes/aws-c-s3/all/test_package/test_package.c new file mode 100644 index 0000000000000..6a88150ba4a43 --- /dev/null +++ b/recipes/aws-c-s3/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include +#include + +int main() { + struct aws_allocator *allocator = aws_default_allocator(); + aws_s3_library_init(allocator); + aws_s3_library_clean_up(); + + return EXIT_SUCCESS; +} diff --git a/recipes/aws-c-s3/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-s3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0778b2e2c7246 --- /dev/null +++ b/recipes/aws-c-s3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-s3 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-c-s3) diff --git a/recipes/aws-c-s3/all/test_v1_package/conanfile.py b/recipes/aws-c-s3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/aws-c-s3/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-c-s3/config.yml b/recipes/aws-c-s3/config.yml new file mode 100644 index 0000000000000..182095498622b --- /dev/null +++ b/recipes/aws-c-s3/config.yml @@ -0,0 +1,11 @@ +versions: + "0.1.49": + folder: all + "0.1.37": + folder: all + "0.1.29": + folder: all + "0.1.27": + folder: all + "0.1.19": + folder: all diff --git a/recipes/aws-c-sdkutils/all/conandata.yml b/recipes/aws-c-sdkutils/all/conandata.yml new file mode 100644 index 0000000000000..7ec4906cf9a7f --- /dev/null +++ b/recipes/aws-c-sdkutils/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "0.1.3": + url: "https://github.com/awslabs/aws-c-sdkutils/archive/v0.1.3.tar.gz" + sha256: "13d99c0877424a8fad40f312762968012dd54ec60a4438fb601ee65ff8b2484b" + "0.1.2": + url: "https://github.com/awslabs/aws-c-sdkutils/archive/refs/tags/v0.1.2.tar.gz" + sha256: "d654670c145212ed3ce0699a988b9f83ebf3e7c44ed74d4d0772dc95ad46b38e" + "0.1.1": + url: "https://github.com/awslabs/aws-c-sdkutils/archive/refs/tags/v0.1.1.tar.gz" + sha256: "201a5f694c912c952f50abab54fa0e576db75ddf6e8710c589896038ff9673f7" diff --git a/recipes/aws-c-sdkutils/all/conanfile.py b/recipes/aws-c-sdkutils/all/conanfile.py new file mode 100644 index 0000000000000..43b3b4f755411 --- /dev/null +++ b/recipes/aws-c-sdkutils/all/conanfile.py @@ -0,0 +1,85 @@ +from conan import ConanFile +from conan.tools.files import get, copy, rmdir +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.52.0" + +class AwsCSDKUtils(ConanFile): + name = "aws-c-sdkutils" + description = "C99 library implementing AWS SDK specific utilities. Includes utilities for ARN parsing, reading AWS profiles, etc..." + license = "Apache-2.0", + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/awslabs/aws-c-sdkutils" + topics = ("aws", "amazon", "cloud", "utility", "ARN") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("aws-c-common/0.8.2") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "aws-c-sdkutils")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-c-sdkutils") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-c-sdkutils") + + self.cpp_info.filenames["cmake_find_package"] = "aws-c-sdkutils" + self.cpp_info.filenames["cmake_find_package_multi"] = "aws-c-sdkutils" + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" + self.cpp_info.components["aws-c-sdkutils-lib"].names["cmake_find_package"] = "aws-c-sdkutils" + self.cpp_info.components["aws-c-sdkutils-lib"].names["cmake_find_package_multi"] = "aws-c-sdkutils" + self.cpp_info.components["aws-c-sdkutils-lib"].set_property("cmake_target_name", "AWS::aws-c-sdkutils") + + self.cpp_info.components["aws-c-sdkutils-lib"].libs = ["aws-c-sdkutils"] + self.cpp_info.components["aws-c-sdkutils-lib"].requires = ["aws-c-common::aws-c-common-lib"] diff --git a/recipes/aws-c-sdkutils/all/test_package/CMakeLists.txt b/recipes/aws-c-sdkutils/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..4b5efc665c153 --- /dev/null +++ b/recipes/aws-c-sdkutils/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(aws-c-sdkutils REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} AWS::aws-c-sdkutils) diff --git a/recipes/aws-c-sdkutils/all/test_package/conanfile.py b/recipes/aws-c-sdkutils/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/aws-c-sdkutils/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-c-sdkutils/all/test_package/test_package.c b/recipes/aws-c-sdkutils/all/test_package/test_package.c new file mode 100644 index 0000000000000..3b89ef23f44f3 --- /dev/null +++ b/recipes/aws-c-sdkutils/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include +#include + +int main() { + struct aws_allocator *allocator = aws_default_allocator(); + aws_sdkutils_library_init(allocator); + aws_sdkutils_library_clean_up(); + + return EXIT_SUCCESS; +} diff --git a/recipes/aws-c-sdkutils/all/test_v1_package/CMakeLists.txt b/recipes/aws-c-sdkutils/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6e620de3b4bc3 --- /dev/null +++ b/recipes/aws-c-sdkutils/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) + +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-c-sdkutils REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} AWS::aws-c-sdkutils) diff --git a/recipes/aws-c-sdkutils/all/test_v1_package/conanfile.py b/recipes/aws-c-sdkutils/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/aws-c-sdkutils/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-c-sdkutils/config.yml b/recipes/aws-c-sdkutils/config.yml new file mode 100644 index 0000000000000..b2ced6f0d7ab7 --- /dev/null +++ b/recipes/aws-c-sdkutils/config.yml @@ -0,0 +1,7 @@ +versions: + "0.1.3": + folder: all + "0.1.2": + folder: all + "0.1.1": + folder: all diff --git a/recipes/aws-cdi-sdk/all/CMakeLists.txt b/recipes/aws-cdi-sdk/all/CMakeLists.txt new file mode 100644 index 0000000000000..19f6430ae56b6 --- /dev/null +++ b/recipes/aws-cdi-sdk/all/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.5) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(AWSSDK REQUIRED) +add_library(aws-cpp-sdk-core ALIAS AWS::aws-sdk-cpp-core) + +add_subdirectory(source_subfolder/aws-cpp-sdk-cdi) diff --git a/recipes/aws-cdi-sdk/all/conandata.yml b/recipes/aws-cdi-sdk/all/conandata.yml new file mode 100644 index 0000000000000..c926a59a5cbb7 --- /dev/null +++ b/recipes/aws-cdi-sdk/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "2.2.0": + url: https://github.com/aws/aws-cdi-sdk/archive/refs/tags/v2.2.0.tar.gz + sha256: 4ee109b7fa2f683b4b0cd03028d0946857f09f34da4e89fe69a5c297cdaeb689 +patches: + "2.2.0": + - base_path: source_subfolder + patch_file: patches/001-Makefile.patch diff --git a/recipes/aws-cdi-sdk/all/conanfile.py b/recipes/aws-cdi-sdk/all/conanfile.py new file mode 100644 index 0000000000000..5fba77e00e10a --- /dev/null +++ b/recipes/aws-cdi-sdk/all/conanfile.py @@ -0,0 +1,144 @@ +import os +import re + +from conans import AutoToolsBuildEnvironment, CMake, ConanFile, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.35.0" + +class AwsCdiSdkConan(ConanFile): + name = "aws-cdi-sdk" + description = "AWS Cloud Digital Interface (CDI) SDK" + topics = ("aws", "communication", "framework", "service") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/aws/aws-cdi-sdk" + license = "BSD-2-Clause" + settings = "os", "arch", "compiler", "build_type" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake", "cmake_find_package" + + @property + def _source_subfolder(self): + return "source_subfolder" + + _autotools = None + _cmake = None + + def requirements(self): + self.requires("aws-libfabric/1.9.1amzncdi1.0") + self.requires("aws-sdk-cpp/1.8.130") + + def configure(self): + self.options["aws-libfabric"].shared = True + self.options["aws-sdk-cpp"].shared = True + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("This recipe currently only supports Linux. Feel free to contribute other platforms!") + if not self.options["aws-libfabric"].shared or not self.options["aws-sdk-cpp"].shared: + raise ConanInvalidConfiguration("Cannot build with static dependencies") + if not getattr(self.options["aws-sdk-cpp"], "monitoring"): + raise ConanInvalidConfiguration("This package requires the monitoring AWS SDK") + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self) + return self._autotools + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure() + return self._cmake + + def _detect_compilers(self): + cmake_cache = tools.load(os.path.join(self.build_folder, "CMakeCache.txt")) + cc = re.search("CMAKE_C_COMPILER:FILEPATH=(.*)", cmake_cache)[1] + cxx = re.search("CMAKE_CXX_COMPILER:FILEPATH=(.*)", cmake_cache)[1] + return cc, cxx + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + # build aws-cpp-sdk-cdi + cmake = self._configure_cmake() + cmake.build() + + autotools = self._configure_autotools() + with tools.chdir(self._source_subfolder): + # configure autotools to find aws-cpp-sdk-cdi + autotools.include_paths.append(os.path.join(self.build_folder, self._source_subfolder, "aws-cpp-sdk-cdi", "include")) + autotools.library_paths.append(os.path.join(self.build_folder, "lib")) + autotools.libs.append("aws-cpp-sdk-cdi") + + vars = autotools.vars + cc, cxx = self._detect_compilers() + vars["CC"] = cc + vars["CXX"] = cxx + if self.settings.build_type == "Debug": + vars["DEBUG"] = "y" + + args = ["require_aws_sdk=no"] + + autotools.make(target="libsdk", vars=vars, args=args) + + def package(self): + cmake = self._configure_cmake() + cmake.install() + + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + config = "debug" if self.settings.build_type == "Debug" else "release" + self.copy(pattern="*", dst="lib", src=os.path.join(self._source_subfolder, "build", config, "lib")) + + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-cdi-sdk") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + # TODO: Remove the namespace on CMake targets + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" + self.cpp_info.filenames["cmake_find_package"] = "aws-cdi-sdk" + self.cpp_info.filenames["cmake_find_package_multi"] = "aws-cdi-sdk" + + cppSdk = self.cpp_info.components["aws-cpp-sdk-cdi"] + cppSdk.libs = ["aws-cpp-sdk-cdi"] + + cppSdk.requires = ["aws-sdk-cpp::monitoring", "aws-libfabric::aws-libfabric"] + + cppSdk.set_property("cmake_target_name", "AWS::aws-cpp-sdk-cdi") + cppSdk.set_property("pkg_config_name", "aws-cpp-sdk-cdi") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + # TODO: Remove the namespace on CMake targets + cppSdk.names["cmake_find_package"] = "aws-cpp-sdk-cdi" + cppSdk.names["cmake_find_package_multi"] = "aws-cpp-sdk-cdi" + cppSdk.names["pkg_config"] = "aws-cpp-sdk-cdi" + + cSdk = self.cpp_info.components["cdisdk"] + cSdk.libs = ["cdisdk"] + cSdk.requires = ["aws-cpp-sdk-cdi"] + if self.settings.os == "Linux": + cSdk.defines = ["_LINUX"] + + cSdk.set_property("cmake_target_name", "AWS::aws-cdi-sdk") + cSdk.set_property("pkg_config_name", "aws-cdi-sdk") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + # TODO: Remove the namespace on CMake targets + cSdk.names["cmake_find_package"] = "aws-cdi-sdk" + cSdk.names["cmake_find_package_multi"] = "aws-cdi-sdk" + cSdk.names["pkg_config"] = "aws-cdi-sdk" + diff --git a/recipes/aws-cdi-sdk/all/patches/001-Makefile.patch b/recipes/aws-cdi-sdk/all/patches/001-Makefile.patch new file mode 100644 index 0000000000000..7462ee93a50e9 --- /dev/null +++ b/recipes/aws-cdi-sdk/all/patches/001-Makefile.patch @@ -0,0 +1,100 @@ +commit dfff3ca2bd52df35be52ec104d1f31f1e4aeef0e +Author: dvirtz +Date: Tue Aug 3 16:48:41 2021 +0300 + + build with external sdk + +diff --git a/Makefile b/Makefile +index 6929dee..74194b5 100644 +--- a/Makefile ++++ b/Makefile +@@ -98,9 +98,6 @@ endif + # makefile.[name].vars.mk. + -include makefile.*.vars.mk + +-ifeq ($(top.libfabric),) +- $(error libfabric source tree not found) +-endif + # Build artifacts for libfabric go into a debug or release directory under top.libfabric + build_dir.libfabric := $(top.libfabric)/build/$(config_libfabric) + +@@ -127,7 +124,7 @@ srcs.cdi := $(foreach ext,c cpp,$(wildcard $(src_dir.cdi)/*.$(ext))) + srcs.cdi += queue.c fifo.c list.c logger.c os_linux.c pool.c + objs.cdi := $(addprefix $(build_dir.obj)/,$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(notdir $(srcs.cdi))))) + headers.cdi := $(foreach dir,$(include_dirs.cdi),$(wildcard $(dir)/*.h)) +-include_opts.cdi := $(foreach proj,cdi libfabric,$(addprefix -I,$(include_dirs.$(proj)))) ++include_opts.cdi := $(foreach proj,cdi,$(addprefix -I,$(include_dirs.$(proj)))) + depends.cdi := $(patsubst %.o,%.d,$(objs.cdi)) + + # the end goal of building the SDK library +@@ -186,24 +183,24 @@ headers.all := $(foreach dir,cdi test test_common test_min_tx test_min_rx test_u + # augment compiler flags + COMMON_COMPILER_FLAG_ADDITIONS := \ + $(include_opts.cdi) $(include_opts.test) \ +- $(EXTRA_COMPILER_FLAG_ADDITIONS) \ +- -Wall -Wextra -Werror -pthread -fPIC \ ++ -Wall -Wextra -pthread -fPIC \ + -D_LINUX -D_POSIX_C_SOURCE=200112L \ +- $(sanitize_opts) ++ $(sanitize_opts) \ ++ $(EXTRA_COMPILER_FLAG_ADDITIONS) + ifeq ($(config), debug) + COMMON_COMPILER_FLAG_ADDITIONS += -O0 -g -DDEBUG + else + COMMON_COMPILER_FLAG_ADDITIONS += -O3 -DNDEBUG + endif + +-CFLAGS += $(COMMON_COMPILER_FLAG_ADDITIONS) --std=c99 +-CXXFLAGS += $(COMMON_COMPILER_FLAG_ADDITIONS) --std=c++11 ++CFLAGS += $(CPPFLAGS) $(COMMON_COMPILER_FLAG_ADDITIONS) --std=c99 ++CXXFLAGS += $(CPPFLAGS) $(COMMON_COMPILER_FLAG_ADDITIONS) --std=c++11 + + # additional flags to pass to the linker to create cdi_test* programs + # The only libraries needed here are those that present new dependencies beyond what libcdisdk.so already requires. + # An rpath is specified so cdi_test can find libcdisdk.so.2 in the same directory as cdi_test or in a sibling directory + # named lib. +-CDI_LDFLAGS = $(LDFLAGS) -L$(build_dir.lib) -lcdisdk -lfabric $(EXTRA_LD_LIBS) -lncurses -lm $(aws_sdk_library_flags) \ ++CDI_LDFLAGS = $(LDFLAGS) -L$(build_dir.lib) -lcdisdk -lfabric $(EXTRA_LD_LIBS) -lncurses -lm \ + -Wl,-rpath,\$$ORIGIN:\$$ORIGIN/../lib64:\$$ORIGIN/../lib + + # docs go into the build directory but are not specific to release/debug +@@ -284,7 +281,7 @@ vpath %.c $(foreach proj,cdi common test test_common test_minimal test_unit,$(sr + vpath %.cpp $(src_dir.cdi) + + # rule to create the various build output directories +-$(foreach d,obj lib bin doc packages libfabric results image libaws,$(build_dir.$(d))) : ++$(foreach d,obj lib bin doc packages results image libaws,$(build_dir.$(d))) : + $(Q)mkdir -p $@ + + # Setup flags for libfabric depending on debug/release build target. +@@ -321,12 +318,10 @@ $(libfabric) : $(libfabric_config_h) | $(build_dir.lib) + # rule to create the SDK library file + .PHONY : libsdk + libsdk : $(libsdk) +-$(libsdk) : $(libfabric_config_h) $(objs.cdi) $(libfabric) $(libaws) | $(build_dir.lib) ++$(libsdk) : $(objs.cdi) | $(build_dir.lib) + @echo "GCC version is" $(GCCVERSION) + $(Q)$(CC) -shared -o $@ -Wl,-z,defs,-soname=$(basename $(notdir $@)),--version-script,libcdisdk.vers \ +- $(objs.cdi) -L$(build_dir.lib) $(aws_sdk_library_flags) \ +- -lfabric -ldl -lrt $(EXTRA_CC_LIBS) -lnl-3 -lm $(EXTRA_LD_LIBS) -lpthread -lc \ +- $(ASAN_LIBS) -Wl,-rpath,\$$ORIGIN:\$$ORIGIN/../lib ++ $(objs.cdi) $(LDFLAGS) $(LIBS) + $(Q)ln -fs $@ $(basename $@) + $(Q)ln -fs $@ $(basename $(basename $@)) + +@@ -432,13 +427,12 @@ clean :: + $(Q)$(RM) -r $(top.build) + + cleanall :: clean +- $(Q)$(RM) -r $(top.libfabric)/build $(libfabric_config_h) + +-$(depends.cdi) : $(libfabric_config_h) $(aws_h) ++$(depends.cdi) : $(aws_h) + + # include dependency rules from generated files; this is conditional so .d files are only created if needed. + ifneq ($(real_build_goals),) +--include $(foreach proj,cdi test test_min_tx test_min_rx test_unit,$(depends.$(proj))) ++-include $(foreach proj,$(real_build_goals),$(depends.$(proj))) + endif + + # Users can add their own rules to this makefile by creating a makefile in this directory called diff --git a/recipes/aws-cdi-sdk/all/test_package/CMakeLists.txt b/recipes/aws-cdi-sdk/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d207864c9df26 --- /dev/null +++ b/recipes/aws-cdi-sdk/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(aws-cdi-sdk REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} AWS::aws-cdi-sdk) diff --git a/recipes/aws-cdi-sdk/all/test_package/conanfile.py b/recipes/aws-cdi-sdk/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/aws-cdi-sdk/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-cdi-sdk/all/test_package/test_package.c b/recipes/aws-cdi-sdk/all/test_package/test_package.c new file mode 100644 index 0000000000000..e6b8b0eada16b --- /dev/null +++ b/recipes/aws-cdi-sdk/all/test_package/test_package.c @@ -0,0 +1,16 @@ +/* example was taken from https://www.gnu.org/ghm/2011/paris/slides/andreas-enge-mpc.pdf */ + +#include +#include +#include + +int main () { + CdiLoggerInitialize(); // Intialize logger so we can use the CDI_LOG_THREAD() macro to generate console messages. + + CDI_LOG_THREAD(kLogInfo, "CDI SDK Version: %d.%d.%d\n", CDI_SDK_VERSION, CDI_SDK_MAJOR_VERSION, + CDI_SDK_MINOR_VERSION); + + CdiLoggerShutdown(false); + + return EXIT_SUCCESS; +} diff --git a/recipes/aws-cdi-sdk/config.yml b/recipes/aws-cdi-sdk/config.yml new file mode 100644 index 0000000000000..1979b3114ab95 --- /dev/null +++ b/recipes/aws-cdi-sdk/config.yml @@ -0,0 +1,3 @@ +versions: + "2.2.0": + folder: all diff --git a/recipes/aws-checksums/all/CMakeLists.txt b/recipes/aws-checksums/all/CMakeLists.txt deleted file mode 100644 index fe3c5e109c923..0000000000000 --- a/recipes/aws-checksums/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper LANGUAGES C) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/aws-checksums/all/conandata.yml b/recipes/aws-checksums/all/conandata.yml index a55c422b35d81..ddf66e3fcf5ae 100644 --- a/recipes/aws-checksums/all/conandata.yml +++ b/recipes/aws-checksums/all/conandata.yml @@ -1,12 +1,18 @@ sources: + "0.1.13": + url: "https://github.com/awslabs/aws-checksums/archive/v0.1.13.tar.gz" + sha256: "0f897686f1963253c5069a0e495b85c31635ba146cd3ac38cc2ea31eaf54694d" + "0.1.12": + url: "https://github.com/awslabs/aws-checksums/archive/v0.1.12.tar.gz" + sha256: "394723034b81cc7cd528401775bc7aca2b12c7471c92350c80a0e2fb9d2909fe" + "0.1.11": + url: "https://github.com/awslabs/aws-checksums/archive/v0.1.11.tar.gz" + sha256: "9312e305428655bcea1f81524c3a8f617ce5299b903187047078929e850fb6d4" "0.1.5": - sha256: "6e6bed6f75cf54006b6bafb01b3b96df19605572131a2260fddaf0e87949ced0" url: "https://github.com/awslabs/aws-checksums/archive/v0.1.5.tar.gz" + sha256: "6e6bed6f75cf54006b6bafb01b3b96df19605572131a2260fddaf0e87949ced0" patches: "0.1.5": - - base_path: "source_subfolder" - patch_file: "patches/0001-use-PROJECT_SOURCE_DIR.cmake" - - base_path: "source_subfolder" - patch_file: "patches/0002-disable-overriding-fPIC.patch" - - base_path: "source_subfolder" - patch_file: "patches/0003-disable-building-tests.patch" + - patch_file: "patches/0001-use-PROJECT_SOURCE_DIR.patch" + - patch_file: "patches/0002-disable-overriding-fPIC.patch" + - patch_file: "patches/0003-disable-building-tests.patch" diff --git a/recipes/aws-checksums/all/conanfile.py b/recipes/aws-checksums/all/conanfile.py index 0cbf5647c9e9a..d3412c3a07b16 100644 --- a/recipes/aws-checksums/all/conanfile.py +++ b/recipes/aws-checksums/all/conanfile.py @@ -1,17 +1,20 @@ -from conans import CMake, ConanFile, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, rmdir import os -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.52.0" class AwsChecksums(ConanFile): name = "aws-checksums" - description = "Cross-Platform HW accelerated CRC32c and CRC32 with fallback to efficient SW implementations. C interface with language bindings for each of our SDKs " - topics = ("conan", "aws", "checksum", ) + description = ( + "Cross-Platform HW accelerated CRC32c and CRC32 with fallback to efficient " + "SW implementations. C interface with language bindings for each of our SDKs." + ) + license = "Apache-2.0", url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/awslabs/aws-checksums" - license = "Apache-2.0", - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake" + topics = ("aws", "checksum", ) settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -22,11 +25,8 @@ class AwsChecksums(ConanFile): "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -34,44 +34,60 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "aws-checksums-{}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure() - return self._cmake + def requirements(self): + self.requires("aws-c-common/0.8.2") - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - - tools.rmdir(os.path.join(self.package_folder, "lib", "aws-checksums")) + rmdir(self, os.path.join(self.package_folder, "lib", "aws-checksums")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-checksums") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-checksums") + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["aws-checksums-lib"].libs = ["aws-checksums"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "aws-checksums" self.cpp_info.filenames["cmake_find_package_multi"] = "aws-checksums" self.cpp_info.names["cmake_find_package"] = "AWS" self.cpp_info.names["cmake_find_package_multi"] = "AWS" self.cpp_info.components["aws-checksums-lib"].names["cmake_find_package"] = "aws-checksums" self.cpp_info.components["aws-checksums-lib"].names["cmake_find_package_multi"] = "aws-checksums" - self.cpp_info.components["aws-checksums-lib"].libs = ["aws-checksums"] + self.cpp_info.components["aws-checksums-lib"].set_property("cmake_target_name", "AWS::aws-checksums") + self.cpp_info.components["aws-checksums-lib"].requires = ["aws-c-common::aws-c-common-lib"] diff --git a/recipes/aws-checksums/all/patches/0001-use-PROJECT_SOURCE_DIR.cmake b/recipes/aws-checksums/all/patches/0001-use-PROJECT_SOURCE_DIR.patch similarity index 100% rename from recipes/aws-checksums/all/patches/0001-use-PROJECT_SOURCE_DIR.cmake rename to recipes/aws-checksums/all/patches/0001-use-PROJECT_SOURCE_DIR.patch diff --git a/recipes/aws-checksums/all/test_package/CMakeLists.txt b/recipes/aws-checksums/all/test_package/CMakeLists.txt index fbc568f4d3307..9922744f24e3f 100644 --- a/recipes/aws-checksums/all/test_package/CMakeLists.txt +++ b/recipes/aws-checksums/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - find_package(aws-checksums REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} AWS::aws-checksums) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-checksums) diff --git a/recipes/aws-checksums/all/test_package/conanfile.py b/recipes/aws-checksums/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/aws-checksums/all/test_package/conanfile.py +++ b/recipes/aws-checksums/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-checksums/all/test_v1_package/CMakeLists.txt b/recipes/aws-checksums/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..915af9f83a60f --- /dev/null +++ b/recipes/aws-checksums/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-checksums REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-checksums) diff --git a/recipes/aws-checksums/all/test_v1_package/conanfile.py b/recipes/aws-checksums/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/aws-checksums/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-checksums/config.yml b/recipes/aws-checksums/config.yml index d9312355bf833..55fedf4c307f5 100644 --- a/recipes/aws-checksums/config.yml +++ b/recipes/aws-checksums/config.yml @@ -1,3 +1,9 @@ versions: + "0.1.13": + folder: all + "0.1.12": + folder: all + "0.1.11": + folder: all "0.1.5": folder: all diff --git a/recipes/aws-crt-cpp/all/conandata.yml b/recipes/aws-crt-cpp/all/conandata.yml new file mode 100644 index 0000000000000..5615e65f10a0b --- /dev/null +++ b/recipes/aws-crt-cpp/all/conandata.yml @@ -0,0 +1,26 @@ +sources: + "0.18.8": + url: "https://github.com/awslabs/aws-crt-cpp/archive/v0.18.8.tar.gz" + sha256: "70ea622cf8c1a7028b24078e909ee5898990444436584178f58d61b50b5b197d" + "0.17.23": + url: "https://github.com/awslabs/aws-crt-cpp/archive/v0.17.23.tar.gz" + sha256: "28061c3efa493519cfae46e4ea96389f03a81eeec7613d7da861dd8c5f4f6598" + "0.17.12": + url: "https://github.com/awslabs/aws-crt-cpp/archive/v0.17.12.tar.gz" + sha256: "acdd8b83198c5a471f92702bc4101828fe55361005764143704c39acd6f80ffc" + "0.14.3": + url: "https://github.com/awslabs/aws-crt-cpp/archive/v0.14.3.tar.gz" + sha256: "3ea16c43e691bab0c373ba1ad072f6535390c516ebda658dfaf4d074d920e0fb" +patches: + "0.18.8": + - patch_file: "patches/0.17.23-fix-cast-error.patch" + patch_description: "fix const cast error" + patch_type: "portability" + "0.17.23": + - patch_file: "patches/0.17.23-fix-cast-error.patch" + patch_description: "fix const cast error" + patch_type: "portability" + "0.17.12": + - patch_file: "patches/0.17.12-fix-cast-error.patch" + patch_description: "fix const cast error" + patch_type: "portability" diff --git a/recipes/aws-crt-cpp/all/conanfile.py b/recipes/aws-crt-cpp/all/conanfile.py new file mode 100644 index 0000000000000..c70a676efc102 --- /dev/null +++ b/recipes/aws-crt-cpp/all/conanfile.py @@ -0,0 +1,117 @@ +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.52.0" + +class AwsCrtCpp(ConanFile): + name = "aws-crt-cpp" + description = "C++ wrapper around the aws-c-* libraries. Provides Cross-Platform Transport Protocols and SSL/TLS implementations for C++." + license = "Apache-2.0", + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/awslabs/aws-crt-cpp" + topics = ("aws", "amazon", "cloud", "wrapper") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _minimum_cpp_standard(self): + return 11 + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("aws-c-common/0.8.2") + self.requires("aws-checksums/0.1.13") + if Version(self.version) < "0.17.29": + self.requires("aws-c-io/0.10.20") + self.requires("aws-c-http/0.6.13") + self.requires("aws-c-auth/0.6.11") + self.requires("aws-c-s3/0.1.37") + self.requires("aws-c-mqtt/0.7.10") + self.requires("aws-c-event-stream/0.2.7") + else: + self.requires("aws-c-io/0.13.4") + self.requires("aws-c-http/0.6.22") + self.requires("aws-c-auth/0.6.17") + self.requires("aws-c-s3/0.1.49") + self.requires("aws-c-mqtt/0.7.12") + self.requires("aws-c-event-stream/0.2.15") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.variables["BUILD_DEPS"] = False + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "aws-crt-cpp")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "aws-crt-cpp") + self.cpp_info.set_property("cmake_target_name", "AWS::aws-crt-cpp") + + self.cpp_info.components["aws-crt-cpp-lib"].names["cmake_find_package"] = "aws-crt-cpp" + self.cpp_info.components["aws-crt-cpp-lib"].names["cmake_find_package_multi"] = "aws-crt-cpp" + self.cpp_info.components["aws-crt-cpp-lib"].libs = ["aws-crt-cpp"] + self.cpp_info.components["aws-crt-cpp-lib"].requires = [ + "aws-c-event-stream::aws-c-event-stream-lib", + "aws-c-common::aws-c-common-lib", + "aws-c-io::aws-c-io-lib", + "aws-c-http::aws-c-http-lib", + "aws-c-auth::aws-c-auth-lib", + "aws-c-mqtt::aws-c-mqtt-lib", + "aws-c-s3::aws-c-s3-lib", + "aws-checksums::aws-checksums-lib" + ] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "aws-crt-cpp" + self.cpp_info.filenames["cmake_find_package_multi"] = "aws-crt-cpp" + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" diff --git a/recipes/aws-crt-cpp/all/patches/0.17.12-fix-cast-error.patch b/recipes/aws-crt-cpp/all/patches/0.17.12-fix-cast-error.patch new file mode 100644 index 0000000000000..be886c030a52c --- /dev/null +++ b/recipes/aws-crt-cpp/all/patches/0.17.12-fix-cast-error.patch @@ -0,0 +1,13 @@ +diff --git a/source/io/TlsOptions.cpp b/source/io/TlsOptions.cpp +index 9f9f8cf..e9913ef 100644 +--- a/source/io/TlsOptions.cpp ++++ b/source/io/TlsOptions.cpp +@@ -216,7 +216,7 @@ namespace Aws + + if (m_slotId) + { +- options.slot_id = &(*m_slotId); ++ options.slot_id = const_cast(&(*m_slotId)); + } + + if (m_userPin) diff --git a/recipes/aws-crt-cpp/all/patches/0.17.23-fix-cast-error.patch b/recipes/aws-crt-cpp/all/patches/0.17.23-fix-cast-error.patch new file mode 100644 index 0000000000000..676d3a87fbac2 --- /dev/null +++ b/recipes/aws-crt-cpp/all/patches/0.17.23-fix-cast-error.patch @@ -0,0 +1,13 @@ +diff --git a/source/io/TlsOptions.cpp b/source/io/TlsOptions.cpp +index 3018e4c..eb5e129 100644 +--- a/source/io/TlsOptions.cpp ++++ b/source/io/TlsOptions.cpp +@@ -213,7 +213,7 @@ namespace Aws + + if (m_slotId) + { +- options.slot_id = &(*m_slotId); ++ options.slot_id = const_cast(&(*m_slotId)); + } + + if (m_userPin) diff --git a/recipes/aws-crt-cpp/all/test_package/CMakeLists.txt b/recipes/aws-crt-cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..50b34b056a787 --- /dev/null +++ b/recipes/aws-crt-cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(aws-crt-cpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/aws-crt-cpp/all/test_package/conanfile.py b/recipes/aws-crt-cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/aws-crt-cpp/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/aws-crt-cpp/all/test_package/test_package.cpp b/recipes/aws-crt-cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..16c00751ddda3 --- /dev/null +++ b/recipes/aws-crt-cpp/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + Aws::Crt::HashString("test"); + + return 0; +} diff --git a/recipes/aws-crt-cpp/all/test_v1_package/CMakeLists.txt b/recipes/aws-crt-cpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..31592420f8acc --- /dev/null +++ b/recipes/aws-crt-cpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(aws-crt-cpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/aws-crt-cpp/all/test_v1_package/conanfile.py b/recipes/aws-crt-cpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/aws-crt-cpp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-crt-cpp/config.yml b/recipes/aws-crt-cpp/config.yml new file mode 100644 index 0000000000000..a2a8f6922a602 --- /dev/null +++ b/recipes/aws-crt-cpp/config.yml @@ -0,0 +1,9 @@ +versions: + "0.18.8": + folder: all + "0.17.23": + folder: all + "0.17.12": + folder: all + "0.14.3": + folder: all diff --git a/recipes/aws-kvs-pic/all/CMakeLists.txt b/recipes/aws-kvs-pic/all/CMakeLists.txt new file mode 100644 index 0000000000000..6abb33ac667b0 --- /dev/null +++ b/recipes/aws-kvs-pic/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/aws-kvs-pic/all/conandata.yml b/recipes/aws-kvs-pic/all/conandata.yml new file mode 100644 index 0000000000000..3e715c5477031 --- /dev/null +++ b/recipes/aws-kvs-pic/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "cci.20210812": + url: "https://github.com/awslabs/amazon-kinesis-video-streams-pic/archive/bbf0e4ba749a6c045fc3958951c1c3a61a808dd0.tar.gz" + sha256: "5a6d8da62af766ec86423ead2a45d9ff00cd80ddea679ce228ff9696a490fae5" +patches: + "cci.20210812": + - base_path: "source_subfolder" + patch_file: "patches/0001-do-not-enforce-fpic.patch" diff --git a/recipes/aws-kvs-pic/all/conanfile.py b/recipes/aws-kvs-pic/all/conanfile.py new file mode 100644 index 0000000000000..3cdebbedda863 --- /dev/null +++ b/recipes/aws-kvs-pic/all/conanfile.py @@ -0,0 +1,76 @@ +import os +from conans import ConanFile, tools, CMake +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + +class awskvspicConan(ConanFile): + name = "aws-kvs-pic" + license = "Apache-2.0" + homepage = "https://github.com/awslabs/amazon-kinesis-video-streams-pic" + url = "https://github.com/conan-io/conan-center-index" + description = ("Platform Independent Code for Amazon Kinesis Video Streams") + settings = "os", "arch", "compiler", "build_type" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {'shared': False, "fPIC": True} + generators = "cmake" + topics = ("aws", "kvs", "kinesis", "video", "stream") + exports_sources = ["CMakeLists.txt", "patches/*"] + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def _configure_cmake(self): + if not self._cmake: + self._cmake = CMake(self) + self._cmake.definitions["BUILD_DEPENDENCIES"] = False + self._cmake.configure() + return self._cmake + + def validate(self): + if (self.settings.os != "Linux" and self.options.shared): + raise ConanInvalidConfiguration("This library can only be built shared on Linux") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.components["kvspic"].libs = ["kvspic"] + self.cpp_info.components["kvspic"].names["pkg_config"] = "libkvspic" + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["kvspic"].system_libs = ["dl", "rt", "pthread"] + + self.cpp_info.components["kvspicClient"].libs = ["kvspicClient"] + self.cpp_info.components["kvspicClient"].names["pkg_config"] = "libkvspicClient" + + self.cpp_info.components["kvspicState"].libs = ["kvspicState"] + self.cpp_info.components["kvspicState"].names["pkg_config"] = "libkvspicState" + + self.cpp_info.components["kvspicUtils"].libs = ["kvspicUtils"] + self.cpp_info.components["kvspicUtils"].names["pkg_config"] = "libkvspicUtils" + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["kvspicUtils"].system_libs = ["dl", "rt", "pthread"] diff --git a/recipes/aws-kvs-pic/all/patches/0001-do-not-enforce-fpic.patch b/recipes/aws-kvs-pic/all/patches/0001-do-not-enforce-fpic.patch new file mode 100644 index 0000000000000..0286a964caa2c --- /dev/null +++ b/recipes/aws-kvs-pic/all/patches/0001-do-not-enforce-fpic.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt 2021-08-06 17:10:31.808434572 -0300 ++++ b/CMakeLists.txt 2021-08-06 17:10:31.888434646 -0300 +@@ -79,7 +79,7 @@ + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads) + +-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") ++ + + if(MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) diff --git a/recipes/aws-kvs-pic/all/test_package/CMakeLists.txt b/recipes/aws-kvs-pic/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..dbfb3fd9c7861 --- /dev/null +++ b/recipes/aws-kvs-pic/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(LIBKVSPIC REQUIRED IMPORTED_TARGET libkvspic) + +add_executable(test_package test_package.c) +target_link_libraries(test_package PkgConfig::LIBKVSPIC) diff --git a/recipes/aws-kvs-pic/all/test_package/conanfile.py b/recipes/aws-kvs-pic/all/test_package/conanfile.py new file mode 100644 index 0000000000000..6fdab74d20c22 --- /dev/null +++ b/recipes/aws-kvs-pic/all/test_package/conanfile.py @@ -0,0 +1,19 @@ +import os +from conans import ConanFile, CMake, tools + +class TestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "pkg_config" + + def build_requirements(self): + self.build_requires("pkgconf/1.7.4") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-kvs-pic/all/test_package/test_package.c b/recipes/aws-kvs-pic/all/test_package/test_package.c new file mode 100644 index 0000000000000..fe89810597779 --- /dev/null +++ b/recipes/aws-kvs-pic/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include +#include "com/amazonaws/kinesis/video/client/Include.h" + +int main(int argc, char *argv[]) +{ + + CLIENT_HANDLE clientHandle = INVALID_CLIENT_HANDLE_VALUE; + PDeviceInfo pDeviceInfo = NULL; + PClientCallbacks pClientCallbacks = NULL; + + createKinesisVideoClient(pDeviceInfo, pClientCallbacks, &clientHandle); + + printf("aws-kps-pic test_package ran successfully \n"); + + return 0; +} diff --git a/recipes/aws-kvs-pic/config.yml b/recipes/aws-kvs-pic/config.yml new file mode 100644 index 0000000000000..e6b575a028845 --- /dev/null +++ b/recipes/aws-kvs-pic/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210812": + folder: all diff --git a/recipes/aws-libfabric/all/conandata.yml b/recipes/aws-libfabric/all/conandata.yml new file mode 100644 index 0000000000000..7836777b3aad7 --- /dev/null +++ b/recipes/aws-libfabric/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.9.1amzncdi1.0": + url: https://github.com/aws/libfabric/archive/refs/tags/1.9.1amzncdi1.0.tar.gz + sha256: 714935292fb85a6edad4f3824cc23e46d18ba0a65ba5e292b6378440e8293ce7 diff --git a/recipes/aws-libfabric/all/conanfile.py b/recipes/aws-libfabric/all/conanfile.py new file mode 100644 index 0000000000000..134b19e72fb91 --- /dev/null +++ b/recipes/aws-libfabric/all/conanfile.py @@ -0,0 +1,116 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.35.0" + +class LibfabricConan(ConanFile): + name = "aws-libfabric" + description = "AWS Libfabric" + topics = ("fabric", "communication", "framework", "service") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/aws/libfabric" + license = "BSD-2-Clause", "GPL-2.0-or-later" + settings = "os", "arch", "compiler", "build_type" + _providers = ["gni", "psm", "psm2", "sockets", "rxm", "tcp", "udp", "usnic", "verbs", "bgq", "shm", "efa", "rxd", "mrail", "rstream", "perf", "hook_debug"] + options = { + **{ p: [True, False, "shared"] for p in _providers }, + **{ + "shared": [True, False], + "fPIC": [True, False], + "with_libnl": [True, False], + "bgq_progress": ["auto", "manual"], + "bgq_mr": ["basic", "scalable"] + } + } + default_options = { + **{ p: False for p in _providers }, + **{ + "shared": False, + "fPIC": True, + "tcp": True, + "with_libnl": False, + "bgq_progress": "manual", + "bgq_mr": "basic" + } + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + _autotools = None + + def build_requirements(self): + self.build_requires("libtool/2.4.6") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + elif self.settings.os == "Linux": + self.options.efa = True + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + if self.options.with_libnl: + self.requires("libnl/3.2.25") + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("The libfabric package cannot be built on Windows.") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + + yes_no_dl = lambda v: {"True": "yes", "False": "no", "shared": "dl"}[str(v)] + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--with-bgq-progress={}".format(self.options.bgq_progress), + "--with-bgq-mr={}".format(self.options.bgq_mr), + ] + for p in self._providers: + args.append("--enable-{}={}".format(p, yes_no_dl(getattr(self.options, p)))) + if self.options.with_libnl: + args.append("--with-libnl={}".format(tools.unix_path(self.deps_cpp_info["libnl"].rootpath))), + else: + args.append("--with-libnl=no") + if self.settings.build_type == "Debug": + args.append("--enable-debug") + self._autotools.configure(args=args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + autotools = self._configure_autotools() + autotools.install() + + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + + def package_info(self): + self.cpp_info.names["pkg_config"] = "libfabric" + self.cpp_info.libs = self.collect_libs() + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs = ["pthread", "m"] + if not self.options.shared: + self.cpp_info.system_libs.extend(["dl", "rt"]) diff --git a/recipes/libsndfile/1.0.28/test_package/CMakeLists.txt b/recipes/aws-libfabric/all/test_package/CMakeLists.txt similarity index 100% rename from recipes/libsndfile/1.0.28/test_package/CMakeLists.txt rename to recipes/aws-libfabric/all/test_package/CMakeLists.txt diff --git a/recipes/aws-libfabric/all/test_package/conanfile.py b/recipes/aws-libfabric/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d4128b0450777 --- /dev/null +++ b/recipes/aws-libfabric/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/aws-libfabric/all/test_package/test_package.c b/recipes/aws-libfabric/all/test_package/test_package.c new file mode 100644 index 0000000000000..36566af74b311 --- /dev/null +++ b/recipes/aws-libfabric/all/test_package/test_package.c @@ -0,0 +1,11 @@ +/* example was taken from https://www.gnu.org/ghm/2011/paris/slides/andreas-enge-mpc.pdf */ + +#include +#include +#include + +int main () { + const uint32_t version = fi_version(); + printf("hello libfabric version %d.%d\n", FI_MAJOR(version), FI_MINOR(version)); + return EXIT_SUCCESS; +} diff --git a/recipes/aws-libfabric/config.yml b/recipes/aws-libfabric/config.yml new file mode 100644 index 0000000000000..f256ec26c29cc --- /dev/null +++ b/recipes/aws-libfabric/config.yml @@ -0,0 +1,3 @@ +versions: + "1.9.1amzncdi1.0": + folder: all diff --git a/recipes/aws-sdk-cpp/all/CMakeLists.txt b/recipes/aws-sdk-cpp/all/CMakeLists.txt index 30c065f03128e..d19ff91050d95 100644 --- a/recipes/aws-sdk-cpp/all/CMakeLists.txt +++ b/recipes/aws-sdk-cpp/all/CMakeLists.txt @@ -4,4 +4,8 @@ project(cmake_wrapper) include(conanbuildinfo.cmake) conan_basic_setup(TARGETS) +if(MSVC) + add_definitions(-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING) +endif() + add_subdirectory(source_subfolder) diff --git a/recipes/aws-sdk-cpp/all/conandata.yml b/recipes/aws-sdk-cpp/all/conandata.yml index 0ee18b6e99000..8abd96ad2e0be 100644 --- a/recipes/aws-sdk-cpp/all/conandata.yml +++ b/recipes/aws-sdk-cpp/all/conandata.yml @@ -1,14 +1,38 @@ sources: + "1.9.234": + url: "https://github.com/aws/aws-sdk-cpp/archive/1.9.234.tar.gz" + sha256: "52e36cf568fe0b2a0fc82a9333c0b31ba843db16670f4ccbb7b9fd142f1b00a5" + "1.9.100": + url: "https://github.com/aws/aws-sdk-cpp/archive/1.9.100.tar.gz" + sha256: "f0930d14ec92b9ddf1e3c966d9a3fe70d2a01b80e79e3e76da78d108bb81e5c4" "1.8.130": url: "https://github.com/aws/aws-sdk-cpp/archive/1.8.130.tar.gz" sha256: "5dd09baa28d3f6f4fb03fbba1a4269724d79bcca3d47752cd3e15caf97276bda" patches: + "1.9.234": + - base_path: source_subfolder + patch_file: patches/1.9.234-0001-issue-1816.patch + - base_path: source_subfolder + patch_file: patches/1.9.234-0002-disable-sort-links.patch + - base_path: source_subfolder + patch_file: patches/1.9.100-0002-aws-plugin-conf.patch + "1.9.100": + - base_path: source_subfolder + patch_file: patches/1.9.100-0001-disable-sort-links.patch + - base_path: source_subfolder + patch_file: patches/1.9.100-0002-aws-plugin-conf.patch + - base_path: source_subfolder + patch_file: patches/1.9.100-0003-issue-1816.patch "1.8.130": - base_path: source_subfolder - patch_file: patches/0001-disable-sort-links.patch + patch_file: patches/1.8.130-0001-disable-sort-links.patch + - base_path: source_subfolder + patch_file: patches/1.8.130-0002-force-archive-directory-to-library-directory.patch + - base_path: source_subfolder + patch_file: patches/1.8.130-0003-disable-cmake-install-rpath-use-link-path.patch - base_path: source_subfolder - patch_file: patches/0002-force-archive-directory-to-library-directory.patch + patch_file: patches/1.8.130-0004-improve-pulseaudio-detection.patch - base_path: source_subfolder - patch_file: patches/0003-disable-cmake-install-rpath-use-link-path.patch + patch_file: patches/1.8.130-0005-aws-plugin-conf.patch - base_path: source_subfolder - patch_file: patches/0004-improve-pulseaudio-detection.patch + patch_file: patches/1.8.130-0006-issue-1816.patch diff --git a/recipes/aws-sdk-cpp/all/conanfile.py b/recipes/aws-sdk-cpp/all/conanfile.py index 8b6ed41aa3922..91c2066868882 100644 --- a/recipes/aws-sdk-cpp/all/conanfile.py +++ b/recipes/aws-sdk-cpp/all/conanfile.py @@ -1,7 +1,13 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration import os +from conan.tools.files import rename +from conan.tools.microsoft import msvc_runtime_flag +from conans import CMake, ConanFile, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.43.0" + + class AwsSdkCppConan(ConanFile): name = "aws-sdk-cpp" license = "Apache-2.0" @@ -9,301 +15,296 @@ class AwsSdkCppConan(ConanFile): homepage = "https://github.com/aws/aws-sdk-cpp" description = "AWS SDK for C++" topics = ("aws", "cpp", "cross-platform", "amazon", "cloud") - settings = "os", "compiler", "build_type", "arch" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" - _sdks = ("access-management", - "accessanalyzer", - "acm", - "acm-pca", - "alexaforbusiness", - "amp", - "amplify", - "amplifybackend", - "apigateway", - "apigatewaymanagementapi", - "apigatewayv2", - "appconfig", - "appflow", - "appintegrations", - "application-autoscaling", - "application-insights", - "appmesh", - "appstream", - "appsync", - "athena", - "auditmanager", - "autoscaling", - "autoscaling-plans", - "awstransfer", - "backup", - "batch", - "braket", - "budgets", - "ce", - "chime", - "cloud9", - "clouddirectory", - "cloudformation", - "cloudfront", - "cloudhsm", - "cloudhsmv2", - "cloudsearch", - "cloudsearchdomain", - "cloudtrail", - "codeartifact", - "codebuild", - "codecommit", - "codedeploy", - "codeguru-reviewer", - "codeguruprofiler", - "codepipeline", - "codestar", - "codestar-connections", - "codestar-notifications", - "cognito-identity", - "cognito-idp", - "cognito-sync", - "comprehend", - "comprehendmedical", - "compute-optimizer", - "config", - "connect", - "connect-contact-lens", - "connectparticipant", - "cur", - "customer-profiles", - "databrew", - "dataexchange", - "datapipeline", - "datasync", - "dax", - "detective", - "devicefarm", - "devops-guru", - "directconnect", - "discovery", - "dlm", - "dms", - "docdb", - "ds", - "dynamodb", - "dynamodbstreams", - "ebs", - "ec2", - "ec2-instance-connect", - "ecr", - "ecr-public", - "ecs", - "eks", - "elastic-inference", - "elasticache", - "elasticbeanstalk", - "elasticfilesystem", - "elasticloadbalancing", - "elasticloadbalancingv2", - "elasticmapreduce", - "elastictranscoder", - "email", - "emr-containers", - "es", - "eventbridge", - "events", - "firehose", - "fms", - "forecast", - "forecastquery", - "frauddetector", - "fsx", - "gamelift", - "glacier", - "globalaccelerator", - "glue", - "greengrass", - "greengrassv2", - "groundstation", - "guardduty", - "health", - "healthlake", - "honeycode", - "iam", - "identity-management", - "identitystore", - "imagebuilder", - "importexport", - "inspector", - "iot", - "iot-data", - "iot-jobs-data", - "iot1click-devices", - "iot1click-projects", - "iotanalytics", - "iotdeviceadvisor", - "iotevents", - "iotevents-data", - "iotfleethub", - "iotsecuretunneling", - "iotsitewise", - "iotthingsgraph", - "iotwireless", - "ivs", - "kafka", - "kendra", - "kinesis", - "kinesis-video-archived-media", - "kinesis-video-media", - "kinesis-video-signaling", - "kinesisanalytics", - "kinesisanalyticsv2", - "kinesisvideo", - "kms", - "lakeformation", - "lambda", - "lex", - "lex-models", - "lexv2-models", - "lexv2-runtime", - "license-manager", - "lightsail", - "location", - "logs", - "lookoutvision", - "machinelearning", - "macie", - "macie2", - "managedblockchain", - "marketplace-catalog", - "marketplace-entitlement", - "marketplacecommerceanalytics", - "mediaconnect", - "mediaconvert", - "medialive", - "mediapackage", - "mediapackage-vod", - "mediastore", - "mediastore-data", - "mediatailor", - "meteringmarketplace", - "migrationhub-config", - "mobile", - "mobileanalytics", - "monitoring", - "mq", - "mturk-requester", - "mwaa", - "neptune", - "network-firewall", - "networkmanager", - "opsworks", - "opsworkscm", - "organizations", - "outposts", - "personalize", - "personalize-events", - "personalize-runtime", - "pi", - "pinpoint", - "pinpoint-email", - "polly", - "polly-sample", - "pricing", - "qldb", - "qldb-session", - "queues", - "quicksight", - "ram", - "rds", - "rds-data", - "redshift", - "redshift-data", - "rekognition", - "resource-groups", - "resourcegroupstaggingapi", - "robomaker", - "route53", - "route53domains", - "route53resolver", - "s3", - "s3-encryption", - "s3control", - "s3outposts", - "sagemaker", - "sagemaker-a2i-runtime", - "sagemaker-edge", - "sagemaker-featurestore-runtime", - "sagemaker-runtime", - "savingsplans", - "schemas", - "sdb", - "secretsmanager", - "securityhub", - "serverlessrepo", - "service-quotas", - "servicecatalog", - "servicecatalog-appregistry", - "servicediscovery", - "sesv2", - "shield", - "signer", - "sms", - "sms-voice", - "snowball", - "sns", - "sqs", - "ssm", - "sso", - "sso-admin", - "sso-oidc", - "states", - "storagegateway", - "sts", - "support", - "swf", - "synthetics", - "text-to-speech", - "textract", - "timestream-query", - "timestream-write", - "transcribe", - "transcribestreaming", - "transfer", - "translate", - "waf", - "waf-regional", - "wafv2", - "wellarchitected", - "workdocs", - "worklink", - "workmail", - "workmailmessageflow", - "workspaces", - "xray" - ) + + settings = "os", "arch", "compiler", "build_type" + _sdks = ( + "access-management", + "accessanalyzer", + "acm", + "acm-pca", + "alexaforbusiness", + "amp", + "amplify", + "amplifybackend", + "apigateway", + "apigatewaymanagementapi", + "apigatewayv2", + "appconfig", + "appflow", + "appintegrations", + "application-autoscaling", + "application-insights", + "appmesh", + "appstream", + "appsync", + "athena", + "auditmanager", + "autoscaling", + "autoscaling-plans", + "awstransfer", + "backup", + "batch", + "braket", + "budgets", + "ce", + "chime", + "cloud9", + "clouddirectory", + "cloudformation", + "cloudfront", + "cloudhsm", + "cloudhsmv2", + "cloudsearch", + "cloudsearchdomain", + "cloudtrail", + "codeartifact", + "codebuild", + "codecommit", + "codedeploy", + "codeguru-reviewer", + "codeguruprofiler", + "codepipeline", + "codestar", + "codestar-connections", + "codestar-notifications", + "cognito-identity", + "cognito-idp", + "cognito-sync", + "comprehend", + "comprehendmedical", + "compute-optimizer", + "config", + "connect", + "connect-contact-lens", + "connectparticipant", + "cur", + "customer-profiles", + "databrew", + "dataexchange", + "datapipeline", + "datasync", + "dax", + "detective", + "devicefarm", + "devops-guru", + "directconnect", + "discovery", + "dlm", + "dms", + "docdb", + "ds", + "dynamodb", + "dynamodbstreams", + "ebs", + "ec2", + "ec2-instance-connect", + "ecr", + "ecr-public", + "ecs", + "eks", + "elastic-inference", + "elasticache", + "elasticbeanstalk", + "elasticfilesystem", + "elasticloadbalancing", + "elasticloadbalancingv2", + "elasticmapreduce", + "elastictranscoder", + "email", + "emr-containers", + "es", + "eventbridge", + "events", + "firehose", + "fms", + "forecast", + "forecastquery", + "frauddetector", + "fsx", + "gamelift", + "glacier", + "globalaccelerator", + "glue", + "greengrass", + "greengrassv2", + "groundstation", + "guardduty", + "health", + "healthlake", + "honeycode", + "iam", + "identity-management", + "identitystore", + "imagebuilder", + "importexport", + "inspector", + "iot", + "iot-data", + "iot-jobs-data", + "iot1click-devices", + "iot1click-projects", + "iotanalytics", + "iotdeviceadvisor", + "iotevents", + "iotevents-data", + "iotfleethub", + "iotsecuretunneling", + "iotsitewise", + "iotthingsgraph", + "iotwireless", + "ivs", + "kafka", + "kendra", + "kinesis", + "kinesis-video-archived-media", + "kinesis-video-media", + "kinesis-video-signaling", + "kinesisanalytics", + "kinesisanalyticsv2", + "kinesisvideo", + "kms", + "lakeformation", + "lambda", + "lex", + "lex-models", + "lexv2-models", + "lexv2-runtime", + "license-manager", + "lightsail", + "location", + "logs", + "lookoutvision", + "machinelearning", + "macie", + "macie2", + "managedblockchain", + "marketplace-catalog", + "marketplace-entitlement", + "marketplacecommerceanalytics", + "mediaconnect", + "mediaconvert", + "medialive", + "mediapackage", + "mediapackage-vod", + "mediastore", + "mediastore-data", + "mediatailor", + "meteringmarketplace", + "migrationhub-config", + "mobile", + "mobileanalytics", + "monitoring", + "mq", + "mturk-requester", + "mwaa", + "neptune", + "network-firewall", + "networkmanager", + "opsworks", + "opsworkscm", + "organizations", + "outposts", + "personalize", + "personalize-events", + "personalize-runtime", + "pi", + "pinpoint", + "pinpoint-email", + "polly", + "polly-sample", + "pricing", + "qldb", + "qldb-session", + "queues", + "quicksight", + "ram", + "rds", + "rds-data", + "redshift", + "redshift-data", + "rekognition", + "resource-groups", + "resourcegroupstaggingapi", + "robomaker", + "route53", + "route53domains", + "route53resolver", + "s3", + "s3-crt", + "s3-encryption", + "s3control", + "s3outposts", + "sagemaker", + "sagemaker-a2i-runtime", + "sagemaker-edge", + "sagemaker-featurestore-runtime", + "sagemaker-runtime", + "savingsplans", + "schemas", + "sdb", + "secretsmanager", + "securityhub", + "serverlessrepo", + "service-quotas", + "servicecatalog", + "servicecatalog-appregistry", + "servicediscovery", + "sesv2", + "shield", + "signer", + "sms", + "sms-voice", + "snowball", + "sns", + "sqs", + "ssm", + "sso", + "sso-admin", + "sso-oidc", + "states", + "storagegateway", + "sts", + "support", + "swf", + "synthetics", + "text-to-speech", + "textract", + "timestream-query", + "timestream-write", + "transcribe", + "transcribestreaming", + "transfer", + "translate", + "waf", + "waf-regional", + "wafv2", + "wellarchitected", + "workdocs", + "worklink", + "workmail", + "workmailmessageflow", + "workspaces", + "xray", + ) options = { - **{ x: [True, False] for x in _sdks}, - **{ - "shared": [True, False], - "fPIC": [True, False], - "min_size": [True, False], - } - } + **{ + "shared": [True, False], + "fPIC": [True, False], + "min_size": [True, False], + }, + **{ x: [True, False] for x in _sdks}, + } default_options = {key: False for key in options.keys()} default_options["fPIC"] = True default_options["access-management"] = True default_options["identity-management"] = True + default_options["monitoring"] = True default_options["queues"] = True - default_options["transfer"] = True default_options["s3-encryption"] = True + default_options["transfer"] = True default_options["text-to-speech"] = True - _internal_requirements = { - "access-management": ["iam", "cognito-identity"], - "identity-management": ["cognito-identity", "sts"], - "queues": ["sqs"], - "s3-encryption": ["s3", "kms"], - "text-to-speech": ["polly"], - "transfer": ["s3"] - } + generators = "cmake", "cmake_find_package" short_paths = True _cmake = None @@ -311,26 +312,82 @@ class AwsSdkCppConan(ConanFile): def _source_subfolder(self): return "source_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _internal_requirements(self): + return { + "access-management": ["iam", "cognito-identity"], + "identity-management": ["cognito-identity", "sts"], + "queues": ["sqs"], + "s3-encryption": ["s3", "kms"], + "text-to-speech": ["polly"], + "transfer": ["s3"], + } + + @property + def _use_aws_crt_cpp(self): + return tools.Version(self.version) >= "1.9" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if tools.Version(self.version) < "1.9": + delattr(self.options, "s3-crt") def configure(self): if self.options.shared: del self.options.fPIC - if (self.settings.compiler == "gcc" - and tools.Version(self.settings.compiler.version) < "6.0"): - raise ConanInvalidConfiguration("""Doesn't support gcc5 / shared. - See https://github.com/conan-io/conan-center-index/pull/4401#issuecomment-802631744""") def requirements(self): - self.requires("aws-c-event-stream/0.1.5") + self.requires("aws-c-common/0.6.19") + if self._use_aws_crt_cpp: + self.requires("aws-c-cal/0.5.13") + self.requires("aws-c-http/0.6.13") + self.requires("aws-c-io/0.10.20") + self.requires("aws-crt-cpp/0.17.23") + else: + self.requires("aws-c-event-stream/0.2.7") if self.settings.os != "Windows": - self.requires("libcurl/7.74.0") - if self.settings.os == "Linux": + self.requires("openssl/1.1.1n") + self.requires("libcurl/7.80.0") + if self.settings.os in ["Linux", "FreeBSD"]: if self.options.get_safe("text-to-speech"): self.requires("pulseaudio/14.2") + def validate(self): + if (self.options.shared + and self.settings.compiler == "gcc" + and tools.Version(self.settings.compiler.version) < "6.0"): + raise ConanInvalidConfiguration( + "Doesn't support gcc5 / shared. " + "See https://github.com/conan-io/conan-center-index/pull/4401#issuecomment-802631744" + ) + if (tools.Version(self.version) < "1.9.234" + and self.settings.compiler == "gcc" + and tools.Version(self.settings.compiler.version) >= "11.0" + and self.settings.build_type == "Release"): + raise ConanInvalidConfiguration( + "Versions prior to 1.9.234 don't support release builds on >= gcc 11 " + "See https://github.com/aws/aws-sdk-cpp/issues/1505" + ) + if self._use_aws_crt_cpp: + if self._is_msvc and "MT" in msvc_runtime_flag(self): + raise ConanInvalidConfiguration("Static runtime is not working for more recent releases") + else: + if self.settings.os == "Macos" and self.settings.arch == "armv8": + raise ConanInvalidConfiguration( + "This version doesn't support arm8. " + "See https://github.com/aws/aws-sdk-cpp/issues/1542" + ) + def package_id(self): for hl_comp in self._internal_requirements.keys(): if getattr(self.options, hl_comp): @@ -338,11 +395,8 @@ def package_id(self): setattr(self.info.options, internal_requirement, True) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) - # Keeping these unused folders make the source copy fail on Windows - tools.rmdir(os.path.join(self._source_subfolder, "code-generation", "generator")) - tools.rmdir(os.path.join(self._source_subfolder, "aws-cpp-sdk-core-tests")) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -351,19 +405,26 @@ def _configure_cmake(self): build_only = ["core"] for sdk in self._sdks: - if getattr(self.options, sdk): + if self.options.get_safe(sdk): build_only.append(sdk) self._cmake.definitions["BUILD_ONLY"] = ";".join(build_only) - self._cmake.definitions["BUILD_DEPS"] = False self._cmake.definitions["ENABLE_UNITY_BUILD"] = True self._cmake.definitions["ENABLE_TESTING"] = False self._cmake.definitions["AUTORUN_UNIT_TESTS"] = False + self._cmake.definitions["BUILD_DEPS"] = False + if self.settings.os != "Windows": + self._cmake.definitions["ENABLE_OPENSSL_ENCRYPTION"] = True self._cmake.definitions["MINIMIZE_SIZE"] = self.options.min_size - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["FORCE_SHARED_CRT"] = "MD" in self.settings.compiler.runtime + if self._is_msvc and not self._use_aws_crt_cpp: + self._cmake.definitions["FORCE_SHARED_CRT"] = "MD" in msvc_runtime_flag(self) + if tools.cross_building(self): + self._cmake.definitions["CURL_HAS_H2_EXITCODE"] = "0" + self._cmake.definitions["CURL_HAS_H2_EXITCODE__TRYRUN_OUTPUT"] = "" + self._cmake.definitions["CURL_HAS_TLS_PROXY_EXITCODE"] = "0" + self._cmake.definitions["CURL_HAS_TLS_PROXY_EXITCODE__TRYRUN_OUTPUT"] = "" self._cmake.configure() return self._cmake @@ -373,26 +434,62 @@ def build(self): cmake = self._configure_cmake() cmake.build() + @property + def _res_folder(self): + return "res" + + def _create_project_cmake_module(self): + # package files needed to build other components (e.g. aws-cdi-sdk) with this SDK + for file in [ + "cmake/compiler_settings.cmake", + "cmake/initialize_project_version.cmake", + "cmake/utilities.cmake", + "cmake/sdk_plugin_conf.cmake", + "toolchains/cmakeProjectConfig.cmake", + "toolchains/pkg-config.pc.in", + "aws-cpp-sdk-core/include/aws/core/VersionConfig.h" + ]: + self.copy(file, src=self._source_subfolder, dst=self._res_folder) + tools.replace_in_file(os.path.join(self.package_folder, self._res_folder, file), "CMAKE_CURRENT_SOURCE_DIR", "AWS_NATIVE_SDK_ROOT", strict=False) + + # avoid getting error from hook + with tools.chdir(os.path.join(self.package_folder, self._res_folder)): + rename(self, os.path.join("toolchains", "cmakeProjectConfig.cmake"), os.path.join("toolchains", "cmakeProjectConf.cmake")) + tools.replace_in_file(os.path.join("cmake", "utilities.cmake"), "cmakeProjectConfig.cmake", "cmakeProjectConf.cmake") + def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() + if self._is_msvc: + self.copy(pattern="*.lib", dst="lib", keep_path=False) + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.lib") tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + self._create_project_cmake_module() + def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "AWSSDK" - self.cpp_info.filenames["cmake_find_package_multi"] = "AWSSDK" - self.cpp_info.names["cmake_find_package"] = "AWS" - self.cpp_info.names["cmake_find_package_multi"] = "AWS" - self.cpp_info.components["core"].names["cmake_find_package"] = "aws-sdk-cpp-core" - self.cpp_info.components["core"].names["cmake_find_package_multi"] = "aws-sdk-cpp-core" - self.cpp_info.components["core"].names["pkg_config"] = "aws-sdk-cpp-core" + self.cpp_info.set_property("cmake_file_name", "AWSSDK") + + # core component + self.cpp_info.components["core"].set_property("cmake_target_name", "AWS::aws-sdk-cpp-core") + self.cpp_info.components["core"].set_property("pkg_config_name", "aws-sdk-cpp-core") self.cpp_info.components["core"].libs = ["aws-cpp-sdk-core"] - self.cpp_info.components["core"].requires = ["aws-c-event-stream::aws-c-event-stream-lib"] + self.cpp_info.components["core"].requires = ["aws-c-common::aws-c-common-lib"] + if self._use_aws_crt_cpp: + self.cpp_info.components["core"].requires.extend([ + "aws-c-cal::aws-c-cal-lib", + "aws-c-http::aws-c-http-lib", + "aws-c-io::aws-c-io-lib", + "aws-crt-cpp::aws-crt-cpp-lib", + ]) + else: + self.cpp_info.components["core"].requires.append("aws-c-event-stream::aws-c-event-stream-lib") - enabled_sdks = [sdk for sdk in self._sdks if getattr(self.options, sdk)] + # other components + enabled_sdks = [sdk for sdk in self._sdks if self.options.get_safe(sdk)] for hl_comp in self._internal_requirements.keys(): if getattr(self.options, hl_comp): for internal_requirement in self._internal_requirements[hl_comp]: @@ -400,28 +497,35 @@ def package_info(self): enabled_sdks.append(internal_requirement) for sdk in enabled_sdks: + # TODO: there is no way to properly emulate COMPONENTS names for + # find_package(AWSSDK COMPONENTS ) in set_property() + # right now: see https://github.com/conan-io/conan/issues/10258 + self.cpp_info.components[sdk].set_property("cmake_target_name", "AWS::aws-sdk-cpp-{}".format(sdk)) + self.cpp_info.components[sdk].set_property("pkg_config_name", "aws-sdk-cpp-{}".format(sdk)) self.cpp_info.components[sdk].requires = ["core"] if sdk in self._internal_requirements: self.cpp_info.components[sdk].requires.extend(self._internal_requirements[sdk]) self.cpp_info.components[sdk].libs = ["aws-cpp-sdk-" + sdk] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.components[sdk].names["cmake_find_package"] = "aws-sdk-cpp-" + sdk self.cpp_info.components[sdk].names["cmake_find_package_multi"] = "aws-sdk-cpp-" + sdk - self.cpp_info.components[sdk].names["pkg_config"] = "aws-sdk-cpp-" + sdk - - # alias name to support find_package(AWSSDK COMPONENTS s3 kms ...) - component_alias = "aws-sdk-cpp-{}_alias".format(sdk) + component_alias = "aws-sdk-cpp-{}_alias".format(sdk) # to emulate COMPONENTS names for find_package() self.cpp_info.components[component_alias].names["cmake_find_package"] = sdk self.cpp_info.components[component_alias].names["cmake_find_package_multi"] = sdk self.cpp_info.components[component_alias].requires = [sdk] + # specific system_libs, frameworks and requires of components if self.settings.os == "Windows": - self.cpp_info.components["core"].system_libs.extend(["winhttp", "wininet", "bcrypt", "userenv", "version", "ws2_32"]) + self.cpp_info.components["core"].system_libs.extend([ + "winhttp", "wininet", "bcrypt", "userenv", "version", "ws2_32" + ]) if self.options.get_safe("text-to-speech"): self.cpp_info.components["text-to-speech"].system_libs.append("winmm") else: - self.cpp_info.components["core"].requires.append("libcurl::curl") + self.cpp_info.components["core"].requires.extend(["libcurl::curl", "openssl::openssl"]) - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["core"].system_libs.append("atomic") if self.options.get_safe("text-to-speech"): self.cpp_info.components["text-to-speech"].requires.append("pulseaudio::pulseaudio") @@ -433,3 +537,17 @@ def package_info(self): lib_stdcpp = tools.stdcpp_library(self) if lib_stdcpp: self.cpp_info.components["core"].system_libs.append(lib_stdcpp) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "AWSSDK" + self.cpp_info.filenames["cmake_find_package_multi"] = "AWSSDK" + self.cpp_info.names["cmake_find_package"] = "AWS" + self.cpp_info.names["cmake_find_package_multi"] = "AWS" + self.cpp_info.components["core"].names["cmake_find_package"] = "aws-sdk-cpp-core" + self.cpp_info.components["core"].names["cmake_find_package_multi"] = "aws-sdk-cpp-core" + + self.cpp_info.components["plugin_scripts"].requires = ["core"] + self.cpp_info.components["plugin_scripts"].builddirs.extend([ + os.path.join(self._res_folder, "cmake"), + os.path.join(self._res_folder, "toolchains")]) + self.cpp_info.components["plugin_scripts"].build_modules.append(os.path.join(self._res_folder, "cmake", "sdk_plugin_conf.cmake")) diff --git a/recipes/aws-sdk-cpp/all/patches/0001-disable-sort-links.patch b/recipes/aws-sdk-cpp/all/patches/1.8.130-0001-disable-sort-links.patch similarity index 100% rename from recipes/aws-sdk-cpp/all/patches/0001-disable-sort-links.patch rename to recipes/aws-sdk-cpp/all/patches/1.8.130-0001-disable-sort-links.patch diff --git a/recipes/aws-sdk-cpp/all/patches/0002-force-archive-directory-to-library-directory.patch b/recipes/aws-sdk-cpp/all/patches/1.8.130-0002-force-archive-directory-to-library-directory.patch similarity index 100% rename from recipes/aws-sdk-cpp/all/patches/0002-force-archive-directory-to-library-directory.patch rename to recipes/aws-sdk-cpp/all/patches/1.8.130-0002-force-archive-directory-to-library-directory.patch diff --git a/recipes/aws-sdk-cpp/all/patches/0003-disable-cmake-install-rpath-use-link-path.patch b/recipes/aws-sdk-cpp/all/patches/1.8.130-0003-disable-cmake-install-rpath-use-link-path.patch similarity index 100% rename from recipes/aws-sdk-cpp/all/patches/0003-disable-cmake-install-rpath-use-link-path.patch rename to recipes/aws-sdk-cpp/all/patches/1.8.130-0003-disable-cmake-install-rpath-use-link-path.patch diff --git a/recipes/aws-sdk-cpp/all/patches/0004-improve-pulseaudio-detection.patch b/recipes/aws-sdk-cpp/all/patches/1.8.130-0004-improve-pulseaudio-detection.patch similarity index 100% rename from recipes/aws-sdk-cpp/all/patches/0004-improve-pulseaudio-detection.patch rename to recipes/aws-sdk-cpp/all/patches/1.8.130-0004-improve-pulseaudio-detection.patch diff --git a/recipes/aws-sdk-cpp/all/patches/1.8.130-0005-aws-plugin-conf.patch b/recipes/aws-sdk-cpp/all/patches/1.8.130-0005-aws-plugin-conf.patch new file mode 100644 index 0000000000000..b3eccfe69cc45 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/patches/1.8.130-0005-aws-plugin-conf.patch @@ -0,0 +1,44 @@ +commit 1179cb040d6b9292d30eb7d444298cd286f9f574 +Author: dvirtz +Date: Tue Nov 16 21:38:45 2021 +0200 + + add a file to configure SDK plugins + +diff --git a/cmake/sdk_plugin_conf.cmake b/cmake/sdk_plugin_conf.cmake +new file mode 100644 +index 0000000000..474ead75bd +--- /dev/null ++++ b/cmake/sdk_plugin_conf.cmake +@@ -0,0 +1,32 @@ ++get_filename_component(AWS_NATIVE_SDK_ROOT ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) ++set(SIMPLE_INSTALL TRUE) ++ ++if (CMAKE_INSTALL_BINDIR) ++ set(BINARY_DIRECTORY "${CMAKE_INSTALL_BINDIR}") ++endif() ++ ++if (CMAKE_INSTALL_LIBDIR) ++ set(LIBRARY_DIRECTORY "${CMAKE_INSTALL_LIBDIR}") ++endif() ++ ++if (CMAKE_INSTALL_INCLUDEDIR) ++ set(INCLUDE_DIRECTORY "${CMAKE_INSTALL_INCLUDEDIR}") ++endif() ++ ++if(BUILD_SHARED_LIBS) ++ set(ARCHIVE_DIRECTORY "${BINARY_DIRECTORY}") ++else() ++ set(ARCHIVE_DIRECTORY "${LIBRARY_DIRECTORY}") ++endif() ++ ++if(DEFINED CMAKE_CXX_STANDARD) ++ set(STANDARD_DEFAULT ${CMAKE_CXX_STANDARD}) ++else() ++ set(STANDARD_DEFAULT "11") ++endif() ++set(CPP_STANDARD ${STANDARD_DEFAULT} CACHE STRING "Flag to upgrade the C++ standard used. The default is 11. The minimum is 11.") ++ ++include(CMakePackageConfigHelpers) ++include(initialize_project_version) ++include(utilities) ++include(compiler_settings) diff --git a/recipes/aws-sdk-cpp/all/patches/1.8.130-0006-issue-1816.patch b/recipes/aws-sdk-cpp/all/patches/1.8.130-0006-issue-1816.patch new file mode 100644 index 0000000000000..6abce1b705a47 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/patches/1.8.130-0006-issue-1816.patch @@ -0,0 +1,20 @@ +diff --git aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp +index c633f3fabe..abb1ab7332 100644 +--- aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp ++++ aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp +@@ -146,7 +146,6 @@ namespace Aws + AWS_LOGSTREAM_TRACE(CLASS_TAG, "Audio retrieved from Polly. " << result.GetContentType() << " with " + << result.GetRequestCharacters() << " characters syntesized"); + +- std::streamsize amountRead(0); + unsigned char buffer[BUFF_SIZE]; + + std::lock_guard m(m_driverLock); +@@ -159,7 +158,6 @@ namespace Aws + AWS_LOGSTREAM_TRACE(CLASS_TAG, "Writing " << read << " bytes to device."); + + successfullyPlayed = m_activeDriver->WriteBufferToDevice(buffer, (std::size_t)read); +- amountRead += read; + played = successfullyPlayed; + } + diff --git a/recipes/aws-sdk-cpp/all/patches/1.9.100-0001-disable-sort-links.patch b/recipes/aws-sdk-cpp/all/patches/1.9.100-0001-disable-sort-links.patch new file mode 100644 index 0000000000000..6e93f7675b327 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/patches/1.9.100-0001-disable-sort-links.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/sdks.cmake b/cmake/sdks.cmake +index 0ec9981ddf..d86a9f4874 100644 +--- a/cmake/sdks.cmake ++++ b/cmake/sdks.cmake +@@ -250,7 +250,7 @@ function(add_sdks) + + # the catch-all config needs to list all the targets in a dependency-sorted order + include(dependencies) +- sort_links(EXPORTS) ++ #sort_links(EXPORTS) + + # make an everything config by just including all the individual configs + file(WRITE ${CMAKE_BINARY_DIR}/aws-sdk-cpp-config.cmake "") diff --git a/recipes/aws-sdk-cpp/all/patches/1.9.100-0002-aws-plugin-conf.patch b/recipes/aws-sdk-cpp/all/patches/1.9.100-0002-aws-plugin-conf.patch new file mode 100644 index 0000000000000..b3eccfe69cc45 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/patches/1.9.100-0002-aws-plugin-conf.patch @@ -0,0 +1,44 @@ +commit 1179cb040d6b9292d30eb7d444298cd286f9f574 +Author: dvirtz +Date: Tue Nov 16 21:38:45 2021 +0200 + + add a file to configure SDK plugins + +diff --git a/cmake/sdk_plugin_conf.cmake b/cmake/sdk_plugin_conf.cmake +new file mode 100644 +index 0000000000..474ead75bd +--- /dev/null ++++ b/cmake/sdk_plugin_conf.cmake +@@ -0,0 +1,32 @@ ++get_filename_component(AWS_NATIVE_SDK_ROOT ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) ++set(SIMPLE_INSTALL TRUE) ++ ++if (CMAKE_INSTALL_BINDIR) ++ set(BINARY_DIRECTORY "${CMAKE_INSTALL_BINDIR}") ++endif() ++ ++if (CMAKE_INSTALL_LIBDIR) ++ set(LIBRARY_DIRECTORY "${CMAKE_INSTALL_LIBDIR}") ++endif() ++ ++if (CMAKE_INSTALL_INCLUDEDIR) ++ set(INCLUDE_DIRECTORY "${CMAKE_INSTALL_INCLUDEDIR}") ++endif() ++ ++if(BUILD_SHARED_LIBS) ++ set(ARCHIVE_DIRECTORY "${BINARY_DIRECTORY}") ++else() ++ set(ARCHIVE_DIRECTORY "${LIBRARY_DIRECTORY}") ++endif() ++ ++if(DEFINED CMAKE_CXX_STANDARD) ++ set(STANDARD_DEFAULT ${CMAKE_CXX_STANDARD}) ++else() ++ set(STANDARD_DEFAULT "11") ++endif() ++set(CPP_STANDARD ${STANDARD_DEFAULT} CACHE STRING "Flag to upgrade the C++ standard used. The default is 11. The minimum is 11.") ++ ++include(CMakePackageConfigHelpers) ++include(initialize_project_version) ++include(utilities) ++include(compiler_settings) diff --git a/recipes/aws-sdk-cpp/all/patches/1.9.100-0003-issue-1816.patch b/recipes/aws-sdk-cpp/all/patches/1.9.100-0003-issue-1816.patch new file mode 100644 index 0000000000000..6abce1b705a47 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/patches/1.9.100-0003-issue-1816.patch @@ -0,0 +1,20 @@ +diff --git aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp +index c633f3fabe..abb1ab7332 100644 +--- aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp ++++ aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp +@@ -146,7 +146,6 @@ namespace Aws + AWS_LOGSTREAM_TRACE(CLASS_TAG, "Audio retrieved from Polly. " << result.GetContentType() << " with " + << result.GetRequestCharacters() << " characters syntesized"); + +- std::streamsize amountRead(0); + unsigned char buffer[BUFF_SIZE]; + + std::lock_guard m(m_driverLock); +@@ -159,7 +158,6 @@ namespace Aws + AWS_LOGSTREAM_TRACE(CLASS_TAG, "Writing " << read << " bytes to device."); + + successfullyPlayed = m_activeDriver->WriteBufferToDevice(buffer, (std::size_t)read); +- amountRead += read; + played = successfullyPlayed; + } + diff --git a/recipes/aws-sdk-cpp/all/patches/1.9.234-0001-issue-1816.patch b/recipes/aws-sdk-cpp/all/patches/1.9.234-0001-issue-1816.patch new file mode 100644 index 0000000000000..9d0a2e810a0ee --- /dev/null +++ b/recipes/aws-sdk-cpp/all/patches/1.9.234-0001-issue-1816.patch @@ -0,0 +1,21 @@ +# https://github.com/aws/aws-sdk-cpp/issues/1816 +diff --git aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp +index 82a298f5a4..f995fcfd4a 100644 +--- aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp ++++ aws-cpp-sdk-text-to-speech/source/text-to-speech/TextToSpeechManager.cpp +@@ -152,7 +152,6 @@ namespace Aws + AWS_LOGSTREAM_TRACE(CLASS_TAG, "Audio retrieved from Polly. " << result.GetContentType() << " with " + << result.GetRequestCharacters() << " characters syntesized"); + +- std::streamsize amountRead(0); + unsigned char buffer[BUFF_SIZE]; + + std::lock_guard m(m_driverLock); +@@ -165,7 +164,6 @@ namespace Aws + AWS_LOGSTREAM_TRACE(CLASS_TAG, "Writing " << read << " bytes to device."); + + successfullyPlayed = m_activeDriver->WriteBufferToDevice(buffer, (std::size_t)read); +- amountRead += read; + played = successfullyPlayed; + } + diff --git a/recipes/aws-sdk-cpp/all/patches/1.9.234-0002-disable-sort-links.patch b/recipes/aws-sdk-cpp/all/patches/1.9.234-0002-disable-sort-links.patch new file mode 100644 index 0000000000000..635bfcae92b8f --- /dev/null +++ b/recipes/aws-sdk-cpp/all/patches/1.9.234-0002-disable-sort-links.patch @@ -0,0 +1,18 @@ +# Fix errors like below in older cmake versions: +# CMake Error at source_subfolder/cmake/dependencies.cmake:34 (get_target_property): +# INTERFACE_LIBRARY targets may only have whitelisted properties. The +# property "LINK_LIBRARIES_ALL" is not allowed. + +diff --git cmake/sdks.cmake cmake/sdks.cmake +index 68ccc88ec8..91e3295e1d 100644 +--- cmake/sdks.cmake ++++ cmake/sdks.cmake +@@ -269,7 +269,7 @@ function(add_sdks) + + # the catch-all config needs to list all the targets in a dependency-sorted order + include(dependencies) +- sort_links(EXPORTS) ++ #sort_links(EXPORTS) + + # make an everything config by just including all the individual configs + file(WRITE ${CMAKE_BINARY_DIR}/aws-sdk-cpp-config.cmake "") diff --git a/recipes/aws-sdk-cpp/all/test_package/CMakeLists.txt b/recipes/aws-sdk-cpp/all/test_package/CMakeLists.txt index 7ad61e0c05823..efb9a3d957583 100644 --- a/recipes/aws-sdk-cpp/all/test_package/CMakeLists.txt +++ b/recipes/aws-sdk-cpp/all/test_package/CMakeLists.txt @@ -1,11 +1,13 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(AWSSDK REQUIRED CONFIG) + +add_subdirectory(aws-sdk-cpp-plugin) -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} aws-sdk-cpp-plugin) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) diff --git a/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.cpp b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.cpp new file mode 100644 index 0000000000000..6171e1633708e --- /dev/null +++ b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.cpp @@ -0,0 +1,16 @@ +#include "AwsSdkCppPlugin.h" +#include +#include +#include +#include + +AwsSdkCppPlugin::AwsSdkCppPlugin() { + using namespace Aws; + using namespace Auth; + using namespace Client; + using namespace S3; + ClientConfiguration config; + auto client = MakeShared("S3Client", + MakeShared("S3Client"), config, + AWSAuthV4Signer::PayloadSigningPolicy::Never /*signPayloads*/, true /*useVirtualAddressing*/, US_EAST_1_REGIONAL_ENDPOINT_OPTION::LEGACY); +} diff --git a/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.h b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.h new file mode 100644 index 0000000000000..e05192e725523 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.h @@ -0,0 +1,7 @@ +#include + +class AWS_SDK_CPP_PLUGIN_EXPORT AwsSdkCppPlugin +{ +public: + AwsSdkCppPlugin(); +}; diff --git a/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/CMakeLists.txt b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/CMakeLists.txt new file mode 100644 index 0000000000000..dddf745d2e408 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.1) + +add_project(aws-sdk-cpp-plugin "C++ AWS SDK plugin" AWS::aws-sdk-cpp-s3) + +add_library(${PROJECT_NAME} AwsSdkCppPlugin.cpp) + +include(GenerateExportHeader) +generate_export_header(${PROJECT_NAME} BASE_NAME aws_sdk_cpp_plugin) +target_include_directories(${PROJECT_NAME} PUBLIC $ $) +target_link_libraries(${PROJECT_NAME} PUBLIC ${PROJECT_LIBS}) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) + +setup_install() + +do_packaging() diff --git a/recipes/aws-sdk-cpp/all/test_package/conanfile.py b/recipes/aws-sdk-cpp/all/test_package/conanfile.py index 4a88c26c08008..38f4483872d47 100644 --- a/recipes/aws-sdk-cpp/all/test_package/conanfile.py +++ b/recipes/aws-sdk-cpp/all/test_package/conanfile.py @@ -1,11 +1,10 @@ -import os - from conans import ConanFile, CMake, tools +import os -class AwsSdkCppTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -14,5 +13,5 @@ def build(self): def test(self): if not tools.cross_building(self): - bin_path = os.path.join("bin", "example") + bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/aws-sdk-cpp/all/test_package/example.cpp b/recipes/aws-sdk-cpp/all/test_package/example.cpp deleted file mode 100644 index a0ccde14df8ea..0000000000000 --- a/recipes/aws-sdk-cpp/all/test_package/example.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - - -int main() { - using namespace Aws; - using namespace Auth; - using namespace Client; - using namespace S3; - SDKOptions options; - InitAPI(options); - ClientConfiguration config; - auto client = MakeShared("pouet", - MakeShared("pouet"), config, - AWSAuthV4Signer::PayloadSigningPolicy::Never /*signPayloads*/, true /*useVirtualAddressing*/, US_EAST_1_REGIONAL_ENDPOINT_OPTION::LEGACY); - ShutdownAPI(options); - return 0; -} - diff --git a/recipes/aws-sdk-cpp/all/test_package/test_package.cpp b/recipes/aws-sdk-cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f66fb046b91dc --- /dev/null +++ b/recipes/aws-sdk-cpp/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include +#include +#include + + +int main() { + using namespace Aws; + SDKOptions options; + InitAPI(options); + AwsSdkCppPlugin Plugin; + ShutdownAPI(options); + return 0; +} + diff --git a/recipes/aws-sdk-cpp/config.yml b/recipes/aws-sdk-cpp/config.yml index 1d2940997fa48..3af57130465e4 100644 --- a/recipes/aws-sdk-cpp/config.yml +++ b/recipes/aws-sdk-cpp/config.yml @@ -1,3 +1,7 @@ versions: + "1.9.234": + folder: "all" + "1.9.100": + folder: "all" "1.8.130": folder: "all" diff --git a/recipes/azure-storage-cpp/all/CMakeLists.txt b/recipes/azure-storage-cpp/all/CMakeLists.txt new file mode 100644 index 0000000000000..82ba25e8c2576 --- /dev/null +++ b/recipes/azure-storage-cpp/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder/Microsoft.WindowsAzure.Storage") diff --git a/recipes/azure-storage-cpp/all/conandata.yml b/recipes/azure-storage-cpp/all/conandata.yml new file mode 100644 index 0000000000000..ccef8ba8c5bd6 --- /dev/null +++ b/recipes/azure-storage-cpp/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "7.5.0": + url: "https://github.com/Azure/azure-storage-cpp/archive/refs/tags/v7.5.0.tar.gz" + sha256: "446a821d115949f6511b7eb01e6a0e4f014b17bfeba0f3dc33a51750a9d5eca5" +patches: + "7.5.0": + - base_path: source_subfolder + patch_file: patches/0001-cmake-fixes.patch diff --git a/recipes/azure-storage-cpp/all/conanfile.py b/recipes/azure-storage-cpp/all/conanfile.py new file mode 100644 index 0000000000000..692bc2ab703fe --- /dev/null +++ b/recipes/azure-storage-cpp/all/conanfile.py @@ -0,0 +1,123 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + +class AzureStorageCppConan(ConanFile): + name = "azure-storage-cpp" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/Azure/azure-storage-cpp" + description = "Microsoft Azure Storage Client Library for C++" + topics = ("azure", "cpp", "cross-platform", "microsoft", "cloud") + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + exports_sources = ["CMakeLists.txt", "patches/**"] + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + short_paths = True + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _minimum_cpp_standard(self): + return 11 + + @property + def _minimum_compiler_version(self): + return { + "gcc": "5", + "Visual Studio": "14", + "clang": "3.4", + "apple-clang": "5.1", + } + + def requirements(self): + self.requires("cpprestsdk/2.10.18") + if self.settings.os != "Windows": + self.requires("boost/1.76.0") + self.requires("libxml2/2.9.10") + self.requires("libuuid/1.0.3") + if self.settings.os == "Macos": + self.requires("libgettext/0.20.1") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + + self._cmake.definitions["CMAKE_FIND_FRAMEWORK"] = "LAST" + self._cmake.definitions["BUILD_TESTS"] = False + self._cmake.definitions["BUILD_SAMPLES"] = False + if not self.settings.compiler.cppstd: + self._cmake.definitions["CMAKE_CXX_STANDARD"] = self._minimum_cpp_standard + + if self.settings.os == "Macos": + self._cmake.definitions["GETTEXT_LIB_DIR"] = self.deps_cpp_info["libgettext"].lib_paths[0] + + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compiler_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler)) + else: + if tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) + + # FIXME: Visual Studio 2015 & 2017 are supported but CI of CCI lacks several Win SDK components + # https://github.com/conan-io/conan-center-index/issues/4195 + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < "16": + raise ConanInvalidConfiguration("Visual Studio < 2019 not yet supported in this recipe") + if self.settings.compiler == "Visual Studio" and self.options.shared and "MT" in self.settings.compiler.runtime: + raise ConanInvalidConfiguration("Visual Studio build for shared library with MT runtime is not supported") + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + + self.cpp_info.libs = tools.collect_libs(self) + if self.settings.os == "Windows": + self.cpp_info.system_libs = ["ws2_32", "rpcrt4", "xmllite", "bcrypt"] + if not self.options.shared: + self.cpp_info.defines = ["_NO_WASTORAGE_API"] diff --git a/recipes/azure-storage-cpp/all/patches/0001-cmake-fixes.patch b/recipes/azure-storage-cpp/all/patches/0001-cmake-fixes.patch new file mode 100644 index 0000000000000..c775329eb84fe --- /dev/null +++ b/recipes/azure-storage-cpp/all/patches/0001-cmake-fixes.patch @@ -0,0 +1,72 @@ +diff --git a/Microsoft.WindowsAzure.Storage/CMakeLists.txt b/Microsoft.WindowsAzure.Storage/CMakeLists.txt +index ac9e65d..f5988f6 100644 +--- a/Microsoft.WindowsAzure.Storage/CMakeLists.txt ++++ b/Microsoft.WindowsAzure.Storage/CMakeLists.txt +@@ -46,9 +46,9 @@ if(UNIX) + find_package(OpenSSL 1.0.0 REQUIRED) + + +- find_package(UUID REQUIRED) +- find_package(Casablanca REQUIRED) +- find_package(LibXML2 REQUIRED) ++ find_package(libuuid REQUIRED) ++ find_package(cpprestsdk REQUIRED) ++ find_package(LibXml2 REQUIRED) + + if(BUILD_TESTS) + find_package(UnitTest++ REQUIRED) +@@ -57,7 +57,7 @@ if(UNIX) + + elseif(WIN32) + message("-- Setting WIN32 options") +- find_package(Casablanca REQUIRED) ++ find_package(cpprestsdk REQUIRED) + add_definitions(-DUNICODE -D_UNICODE -D_WIN32) + else() + message("-- Unsupported Build Platform.") +@@ -85,13 +85,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + + set(LD_FLAGS "${LD_FLAGS} -Wl,-z,defs") + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-strict-aliasing") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") + + set(STRICT_CXX_FLAGS ${WARNINGS} "-Werror -pedantic") + +- if (BUILD_SHARED_LIBS) +- add_definitions(-DBOOST_LOG_DYN_LINK) +- endif() + add_definitions(-D_TURN_OFF_PLATFORM_STRING) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + message("-- Setting clang options") +@@ -100,14 +97,11 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(OSX_SUPPRESSIONS "-Wno-overloaded-virtual -Wno-sign-conversion -Wno-deprecated -Wno-unknown-pragmas -Wno-reorder -Wno-char-subscripts -Wno-switch -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated -Wno-unused-value -Wno-unknown-warning-option -Wno-return-type-c-linkage -Wno-unused-function -Wno-sign-compare -Wno-shorten-64-to-32 -Wno-reorder -Wno-unused-local-typedefs") + set(WARNINGS "${WARNINGS} ${OSX_SUPPRESSIONS}") + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -Wno-return-type-c-linkage -Wno-unneeded-internal-declaration") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage -Wno-unneeded-internal-declaration") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-strict-aliasing") +- if (BUILD_SHARED_LIBS) +- add_definitions(-DBOOST_LOG_DYN_LINK) +- endif() ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") + add_definitions(-D_TURN_OFF_PLATFORM_STRING) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + message("-- Setting MSVC options") +@@ -142,11 +136,11 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) + + set(AZURESTORAGE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/includes) +-set(AZURESTORAGE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/includes ${CASABLANCA_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIRS} ${UUID_INCLUDE_DIRS} ${LibXML2_INCLUDE_DIR}) ++set(AZURESTORAGE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/includes ${cpprestsdk_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${OpenSSL_INCLUDE_DIRS} ${libuuid_INCLUDE_DIRS} ${LibXml2_INCLUDE_DIR}) + + + set(AZURESTORAGE_LIBRARY azurestorage) +-set(AZURESTORAGE_LIBRARIES ${AZURESTORAGE_LIBRARY} ${CASABLANCA_LIBRARY} ${Boost_LIBRARIES} ${Boost_FRAMEWORK} ${OPENSSL_LIBRARIES} ${UUID_LIBRARIES} ${LibXML2_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) ++set(AZURESTORAGE_LIBRARIES ${AZURESTORAGE_LIBRARY} ${cpprestsdk_LIBRARIES} ${Boost_LIBRARIES} ${OpenSSL_LIBRARIES} ${libuuid_LIBRARIES} ${LibXml2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + + # Set version numbers centralized + set (AZURESTORAGE_VERSION_MAJOR 7) diff --git a/recipes/azure-storage-cpp/all/test_package/CMakeLists.txt b/recipes/azure-storage-cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..1c789ba4ceba1 --- /dev/null +++ b/recipes/azure-storage-cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +set(CMAKE_CXX_STANDARD 11) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(azure-storage-cpp REQUIRED CONFIG) + +add_executable(example example.cpp) +target_link_libraries(example azure-storage-cpp::azure-storage-cpp) diff --git a/recipes/azure-storage-cpp/all/test_package/conanfile.py b/recipes/azure-storage-cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..33fb4c0ecc216 --- /dev/null +++ b/recipes/azure-storage-cpp/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class AwsSdkCppTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/azure-storage-cpp/all/test_package/example.cpp b/recipes/azure-storage-cpp/all/test_package/example.cpp new file mode 100644 index 0000000000000..632507089345a --- /dev/null +++ b/recipes/azure-storage-cpp/all/test_package/example.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +int main() +{ + // Define the connection-string with your values.// Define the connection-string with Azurite. + const utility::string_t storage_connection_string(U("UseDevelopmentStorage=true;")); + // Retrieve storage account from connection string. + azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string); +} diff --git a/recipes/azure-storage-cpp/config.yml b/recipes/azure-storage-cpp/config.yml new file mode 100644 index 0000000000000..c51af1b34b117 --- /dev/null +++ b/recipes/azure-storage-cpp/config.yml @@ -0,0 +1,3 @@ +versions: + "7.5.0": + folder: "all" diff --git a/recipes/b2/config.yml b/recipes/b2/config.yml index 963e0d0fe1b2f..72ab4de1e5c67 100644 --- a/recipes/b2/config.yml +++ b/recipes/b2/config.yml @@ -17,3 +17,27 @@ versions: folder: portable "4.5.0": folder: portable + "4.6.0": + folder: portable + "4.6.1": + folder: portable + "4.7.0": + folder: portable + "4.7.1": + folder: portable + "4.7.2": + folder: portable + "4.8.0": + folder: portable + "4.8.1": + folder: portable + "4.8.2": + folder: portable + "4.9.0": + folder: portable + "4.9.1": + folder: portable + "4.9.2": + folder: portable + "4.9.3": + folder: portable diff --git a/recipes/b2/portable/conandata.yml b/recipes/b2/portable/conandata.yml index c46bfcd9f1d6f..0ce27c0e93f9c 100644 --- a/recipes/b2/portable/conandata.yml +++ b/recipes/b2/portable/conandata.yml @@ -14,3 +14,39 @@ sources: "4.5.0": url: "https://github.com/bfgroup/b2/archive/4.5.0.tar.gz" sha256: "39c3b51bf9c5f32b1c249d2d405274976b166e1bdca1fc5205b595f1cb5dbac3" + "4.6.0": + url: "https://github.com/bfgroup/b2/archive/4.6.0.tar.gz" + sha256: "3a308e0f79a039d8a9495b375f3292f5163000c19caa79c5687e4cb5b1938b49" + "4.6.1": + url: "https://github.com/bfgroup/b2/archive/4.6.1.tar.gz" + sha256: "a3f3323eaeb2c27d7a3ca86842665c6c3bc3d93cc626ba362ae6d0c5a7bfbe2c" + "4.7.0": + url: "https://github.com/bfgroup/b2/archive/4.7.0.tar.gz" + sha256: "82c2eb92d6ab2bd447646568ac8430c316cbd2a1819c108136224498c0abed84" + "4.7.1": + url: "https://github.com/bfgroup/b2/archive/4.7.1.tar.gz" + sha256: "30844184ded3217c090b76e6e051c3ac663ea63bd19e1b727b05c54411cac867" + "4.7.2": + url: "https://github.com/bfgroup/b2/archive/4.7.2.tar.gz" + sha256: "70883f8ed82efc49f425f1961a82e961cefdbca3a28581cb57b405bd7516677f" + "4.8.0": + url: "https://github.com/bfgroup/b2/archive/4.8.0.tar.gz" + sha256: "2f18951d4cc267a810e44fc483b747d489e30ed42ee6d9e7c5e19de750ee5cd2" + "4.8.1": + url: "https://github.com/bfgroup/b2/archive/4.8.1.tar.gz" + sha256: "8ecff1025df9473d91a0d116af3e32be6fba6e57d4ea962e033ff1678609d668" + "4.8.2": + url: "https://github.com/bfgroup/b2/archive/4.8.2.tar.gz" + sha256: "220edfbd5022394c5dc264dfdd8bf6d3ec53b784db87461026bb23ea9d9ec4bd" + "4.9.0": + url: "https://github.com/bfgroup/b2/archive/4.9.0.tar.gz" + sha256: "7c614e41f10e004c7539c75c60f7b2df26a61fe35058e9021f8fd5049c97a255" + "4.9.1": + url: "https://github.com/bfgroup/b2/archive/4.9.1.tar.gz" + sha256: "81e49dc85e956c3e708bdd02fcfe0b9f406fca8edca54c75c94ebd6c322ed587" + "4.9.2": + url: "https://github.com/bfgroup/b2/archive/4.9.2.tar.gz" + sha256: "7e1a135b308999d2a65fce3eba8f4ffb41ca82ae133f8494cc42cbca63c890de" + "4.9.3": + url: "https://github.com/bfgroup/b2/archive/4.9.3.tar.gz" + sha256: "4524b8ecf138a9087aa24b8889c44ea7ae9f2d373acc9535d72fb048c213e1b9" diff --git a/recipes/b2/portable/conanfile.py b/recipes/b2/portable/conanfile.py index a1bdcc520c005..5cc7b0cdfb0dc 100644 --- a/recipes/b2/portable/conanfile.py +++ b/recipes/b2/portable/conanfile.py @@ -1,13 +1,19 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration import os +from contextlib import contextmanager +import conan.tools.files +import conan.tools.layout +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from six import StringIO + +required_conan_version = ">=1.47.0" class B2Conan(ConanFile): name = "b2" homepage = "https://www.bfgroup.xyz/b2/" description = "B2 makes it easy to build C++ projects, everywhere." - topics = ("conan", "installer", "builder") + topics = ("b2", "installer", "builder", "build", "build-system") license = "BSL-1.0" settings = "os", "arch" url = "https://github.com/conan-io/conan-center-index" @@ -23,7 +29,7 @@ class B2Conan(ConanFile): 'acc', 'borland', 'clang', 'como', 'gcc-nocygwin', 'gcc', 'intel-darwin', 'intel-linux', 'intel-win32', 'kcc', 'kylix', 'mingw', 'mipspro', 'pathscale', 'pgi', 'qcc', 'sun', 'sunpro', - 'tru64cxx', 'vacpp', 'vc12', 'vc14', 'vc141', 'vc142' + 'tru64cxx', 'vacpp', 'vc12', 'vc14', 'vc141', 'vc142', 'vc143' Specifies the toolset to use for building. The default of 'auto' detects a usable compiler for building and should be preferred. The 'cxx' toolset @@ -39,59 +45,127 @@ class B2Conan(ConanFile): 'acc', 'borland', 'clang', 'como', 'gcc-nocygwin', 'gcc', 'intel-darwin', 'intel-linux', 'intel-win32', 'kcc', 'kylix', 'mingw', 'mipspro', 'pathscale', 'pgi', 'qcc', 'sun', 'sunpro', - 'tru64cxx', 'vacpp', 'vc12', 'vc14', 'vc141', 'vc142'] + 'tru64cxx', 'vacpp', 'vc12', 'vc14', 'vc141', 'vc142', 'vc143'] } default_options = { 'use_cxx_env': False, 'toolset': 'auto' } - def configure(self): + def validate(self): if (self.options.toolset == 'cxx' or self.options.toolset == 'cross-cxx') and not self.options.use_cxx_env: raise ConanInvalidConfiguration( "Option toolset 'cxx' and 'cross-cxx' requires 'use_cxx_env=True'") + def layout(self): + conan.tools.layout.basic_layout(self, src_folder="root") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "b2-" + \ - os.path.basename(self.conan_data["sources"][self.version]['url']).replace( - ".tar.gz", "") - os.rename(extracted_dir, "source") + conan.tools.files.get( + self, **self.conan_data["sources"][self.version], strip_root=True) + + @property + def _b2_dir(self): + return self.source_folder + + @property + def _b2_engine_dir(self): + return os.path.join(self._b2_dir, "src", "engine") + + @property + def _b2_output_dir(self): + return os.path.join(self.build_folder, "output") + + @property + def _pkg_licenses_dir(self): + return os.path.join(self.package_folder, "licenses") + + @property + def _pkg_bin_dir(self): + return os.path.join(self.package_folder, "bin") + + @contextmanager + def _bootstrap_env(self): + saved_env = dict(os.environ) + # Vcvars will change the directory after it runs in the situation when + # the user has previously run the VS command console inits. In that + # context it remembers the dir and resets it at each vcvars invocation. + os.environ.update({"VSCMD_START_DIR": os.getcwd()}) + if not self.options.use_cxx_env: + # To avoid using the CXX env vars we clear them out for the build. + os.environ.update({ + "CXX": "", + "CXXFLAGS": ""}) + try: + yield + finally: + os.environ.clear() + os.environ.update(saved_env) def build(self): + # The order of the with:with: below is important. The first one changes + # the current dir. While the second does env changes that guarantees + # that dir doesn't change if/when vsvars runs to set the msvc compile + # env. + self.output.info("Build engine..") + command = "" + b2_toolset = self.options.toolset use_windows_commands = os.name == 'nt' - command = "build" if use_windows_commands else "./build.sh" - if self.options.toolset != 'auto': - command += " "+str(self.options.toolset) - build_dir = os.path.join(self.source_folder, "source") - engine_dir = os.path.join(build_dir, "src", "engine") - os.chdir(engine_dir) - with tools.environment_append({"VSCMD_START_DIR": os.curdir}): - if self.options.use_cxx_env: - # Allow use of CXX env vars. + if b2_toolset == 'auto': + if use_windows_commands: + # For windows auto detection it can evaluate to a msvc version + # that it's not aware of. Most likely because it's a future one + # that didn't exist when the build was written. This turns that + # into a generic msvc toolset build assuming it could work, + # since it's a better version. + with conan.tools.files.chdir(self, self._b2_engine_dir): + with self._bootstrap_env(): + buf = StringIO() + self.run('guess_toolset && set', output=buf) + guess_vars = map( + lambda x: x.strip(), buf.getvalue().split("\n")) + if "B2_TOOLSET=vcunk" in guess_vars: + b2_toolset = 'msvc' + for kv in guess_vars: + if kv.startswith("B2_TOOLSET_ROOT="): + b2_vcvars = os.path.join( + kv.split('=')[1].strip(), 'Auxiliary', 'Build', 'vcvars32.bat') + command += '"'+b2_vcvars+'" && ' + command += "build" if use_windows_commands else "./build.sh" + if b2_toolset != 'auto': + command += " "+str(b2_toolset) + with conan.tools.files.chdir(self, self._b2_engine_dir): + with self._bootstrap_env(): self.run(command) - else: - # To avoid using the CXX env vars we clear them out for the build. - with tools.environment_append({"CXX": "", "CXXFLAGS": ""}): - self.run(command) - os.chdir(build_dir) + + self.output.info("Install..") command = os.path.join( - engine_dir, "b2.exe" if use_windows_commands else "b2") + self._b2_engine_dir, "b2.exe" if use_windows_commands else "b2") full_command = \ - "{0} --ignore-site-config --prefix=../output --abbreviate-paths install b2-install-layout=portable".format( - command) - self.run(full_command) + ("{0} --ignore-site-config " + + "--prefix={1} " + + "--abbreviate-paths " + + "install " + + "b2-install-layout=portable").format(command, self._b2_output_dir) + with conan.tools.files.chdir(self, self._b2_dir): + self.run(full_command) def package(self): - self.copy("LICENSE.txt", dst="licenses", src="source") - self.copy(pattern="*b2", dst="bin", src="output") - self.copy(pattern="*b2.exe", dst="bin", src="output") - self.copy(pattern="*.jam", dst="bin", src="output") + conan.tools.files.copy( + self, "LICENSE.txt", dst=self._pkg_licenses_dir, src=self.source_folder) + conan.tools.files.copy( + self, "*b2", dst=self._pkg_bin_dir, src=self._b2_output_dir) + conan.tools.files.copy( + self, "*b2.exe", dst=self._pkg_bin_dir, src=self._b2_output_dir) + conan.tools.files.copy( + self, "*.jam", dst=self._pkg_bin_dir, src=self._b2_output_dir) def package_info(self): + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] self.cpp_info.bindirs = ["bin"] - self.env_info.path = [os.path.join( - self.package_folder, "bin")] + self.buildenv_info.prepend_path("PATH", self._pkg_bin_dir) + self.env_info.path = [self._pkg_bin_dir] def package_id(self): del self.info.options.use_cxx_env diff --git a/recipes/b2/portable/test_package/conanfile.py b/recipes/b2/portable/test_package/conanfile.py index 5f6d593461098..270c3bedc31a3 100644 --- a/recipes/b2/portable/test_package/conanfile.py +++ b/recipes/b2/portable/test_package/conanfile.py @@ -1,12 +1,13 @@ -from conans import ConanFile, tools -import os +from conan import ConanFile -class TestPackgeConan(ConanFile): - settings = "os", "arch" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) def test(self): - tools.save( - "jamroot.jam", - 'ECHO "info:" Success loading project jamroot.jam file. ;') - self.run("b2 --debug-configuration", run_environment=True) + self.run("b2 -v") diff --git a/recipes/b2/portable/test_v1_package/conanfile.py b/recipes/b2/portable/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..53ed1a9a77b8b --- /dev/null +++ b/recipes/b2/portable/test_v1_package/conanfile.py @@ -0,0 +1,8 @@ +from conan import ConanFile + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def test(self): + self.run("b2 -v", run_environment=True) diff --git a/recipes/b2/standard/conanfile.py b/recipes/b2/standard/conanfile.py index 605daa796c58a..6eac8be0f9018 100644 --- a/recipes/b2/standard/conanfile.py +++ b/recipes/b2/standard/conanfile.py @@ -23,7 +23,7 @@ class B2Conan(ConanFile): 'acc', 'borland', 'clang', 'como', 'gcc-nocygwin', 'gcc', 'intel-darwin', 'intel-linux', 'intel-win32', 'kcc', 'kylix', 'mingw', 'mipspro', 'pathscale', 'pgi', 'qcc', 'sun', 'sunpro', - 'tru64cxx', 'vacpp', 'vc12', 'vc14', 'vc141', 'vc142' + 'tru64cxx', 'vacpp', 'vc12', 'vc14', 'vc141', 'vc142', 'vc143' Specifies the toolset to use for building. The default of 'auto' detects a usable compiler for building and should be preferred. The 'cxx' toolset @@ -39,7 +39,7 @@ class B2Conan(ConanFile): 'acc', 'borland', 'clang', 'como', 'gcc-nocygwin', 'gcc', 'intel-darwin', 'intel-linux', 'intel-win32', 'kcc', 'kylix', 'mingw', 'mipspro', 'pathscale', 'pgi', 'qcc', 'sun', 'sunpro', - 'tru64cxx', 'vacpp', 'vc12', 'vc14', 'vc141', 'vc142'] + 'tru64cxx', 'vacpp', 'vc12', 'vc14', 'vc141', 'vc142', 'vc143'] } default_options = { 'use_cxx_env': False, @@ -52,11 +52,8 @@ def configure(self): "Option toolset 'cxx' and 'cross-cxx' requires 'use_cxx_env=True'") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "b2-" + \ - os.path.basename(self.conan_data["sources"][self.version]['url']).replace( - ".tar.gz", "") - os.rename(extracted_dir, "source") + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination="source") def build(self): use_windows_commands = os.name == 'nt' @@ -77,9 +74,12 @@ def build(self): os.chdir(build_dir) command = os.path.join( engine_dir, "b2.exe" if use_windows_commands else "b2") - full_command = \ - "{0} --ignore-site-config --prefix=../output --abbreviate-paths install".format( - command) + if self.options.toolset != 'auto': + full_command = "{0} --ignore-site-config --prefix=../output --abbreviate-paths" \ + " toolset={1} install".format(command, self.options.toolset) + else: + full_command = "{0} --ignore-site-config --prefix=../output --abbreviate-paths" \ + " install".format(command) self.run(full_command) def package(self): diff --git a/recipes/b2/standard/test_package/conanfile.py b/recipes/b2/standard/test_package/conanfile.py index 64fc310c96082..24d8a018c8f84 100644 --- a/recipes/b2/standard/test_package/conanfile.py +++ b/recipes/b2/standard/test_package/conanfile.py @@ -6,12 +6,4 @@ class TestPackgeConan(ConanFile): settings = "os", "arch" def test(self): - tools.save( - "jamroot.jam", - 'ECHO "info:" Success loading project jamroot.jam file. ;') - tools.save( - "boost-build.jam", - "boost-build \"" + - os.environ['BOOST_BUILD_PATH'].replace("\\", "/")+"\" ;" - ) - self.run("b2 --debug-configuration", run_environment=True) + self.run("b2 -v", run_environment=True) diff --git a/recipes/backport-cpp/all/conanfile.py b/recipes/backport-cpp/all/conanfile.py index beecb81b9c849..a114a54bf9ff4 100644 --- a/recipes/backport-cpp/all/conanfile.py +++ b/recipes/backport-cpp/all/conanfile.py @@ -1,33 +1,46 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools +required_conan_version = ">=1.50.0" class BackportCppRecipe(ConanFile): name = "backport-cpp" description = "An ongoing effort to bring modern C++ utilities to be compatible with C++11" - topics = ("conan", "backport-cpp", "header-only", "backport") + topics = ("backport-cpp", "header-only", "backport") homepage = "https://github.com/bitwizeshift/BackportCpp" url = "https://github.com/conan-io/conan-center-index" license = "MIT" + settings = "os", "arch", "compiler", "build_type" no_copy_source=True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "BackportCpp-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(os.path.join("include", "**", "*.hpp"), src=self._source_subfolder) + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, os.path.join("include", "**", "*.hpp"), src=self.source_folder, dst=self.package_folder) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Backport") + self.cpp_info.set_property("cmake_target_name", "Backport::Backport") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "Backport" self.cpp_info.names["cmake_find_package_multi"] = "Backport" diff --git a/recipes/backport-cpp/all/test_package/CMakeLists.txt b/recipes/backport-cpp/all/test_package/CMakeLists.txt index c02d367dce1ee..2b33b3fe58289 100644 --- a/recipes/backport-cpp/all/test_package/CMakeLists.txt +++ b/recipes/backport-cpp/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(Backport REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} Backport::Backport) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE Backport::Backport) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/backport-cpp/all/test_package/conanfile.py b/recipes/backport-cpp/all/test_package/conanfile.py index 3f4a9f50f389e..d120a992c06a6 100644 --- a/recipes/backport-cpp/all/test_package/conanfile.py +++ b/recipes/backport-cpp/all/test_package/conanfile.py @@ -1,11 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools - class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/backport-cpp/all/test_v1_package/CMakeLists.txt b/recipes/backport-cpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7c4264b0a6d02 --- /dev/null +++ b/recipes/backport-cpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Backport REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Backport::Backport) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/backport-cpp/all/test_v1_package/conanfile.py b/recipes/backport-cpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/backport-cpp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/backward-cpp/all/CMakeLists.txt b/recipes/backward-cpp/all/CMakeLists.txt deleted file mode 100644 index cdeeef45d13c1..0000000000000 --- a/recipes/backward-cpp/all/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") - include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -else() - include(conanbuildinfo.cmake) -endif() -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/backward-cpp/all/conandata.yml b/recipes/backward-cpp/all/conandata.yml index 1935a0c9e7bf2..56d588551a507 100644 --- a/recipes/backward-cpp/all/conandata.yml +++ b/recipes/backward-cpp/all/conandata.yml @@ -1,25 +1,25 @@ sources: - "1.4": - url: "https://github.com/bombela/backward-cpp/archive/v1.4.tar.gz" - sha256: "ad73be31c5cfcbffbde7d34dba18158a42043a109e7f41946f0b0abd589ed55e" + "1.6": + url: "https://github.com/bombela/backward-cpp/archive/v1.6.tar.gz" + sha256: "c654d0923d43f1cea23d086729673498e4741fb2457e806cfaeaea7b20c97c10" "1.5": url: "https://github.com/bombela/backward-cpp/archive/v1.5.tar.gz" sha256: "faf7d4fe7ca65117ed4fe7be9bff9628927bd95b49f71df63d5f99af233d1915" -patches: "1.4": - - patch_file: "patches/backward-cpp-1.4.patch" - base_path: "source_subfolder" - # https://github.com/bombela/backward-cpp/commit/7539d53b54f08f056dc9366c8d5c24c5d749cfce.patch - - patch_file: "patches/backward-cpp-1.4-7539d53b54f08f056dc9366c8d5c24c5d749cfce.patch" - base_path: "source_subfolder" - # https://github.com/bombela/backward-cpp/commit/b7ffd640ec48ada93045f8c46fc65f823490819b.patch - - patch_file: "patches/backward-cpp-1.4-b7ffd640ec48ada93045f8c46fc65f823490819b.patch" - base_path: "source_subfolder" + url: "https://github.com/bombela/backward-cpp/archive/v1.4.tar.gz" + sha256: "ad73be31c5cfcbffbde7d34dba18158a42043a109e7f41946f0b0abd589ed55e" +patches: + "1.6": + - patch_file: "patches/backward-cpp-1.5.patch" "1.5": - patch_file: "patches/backward-cpp-1.5.patch" - base_path: "source_subfolder" - # https://github.com/bombela/backward-cpp/commit/74dd7d6733d1ab6b79994f4acbc1ad86ba950d23.patch - patch_file: "patches/backward-cpp-1.5-74dd7d6733d1ab6b79994f4acbc1ad86ba950d23.patch" - base_path: "source_subfolder" + patch_source: "https://github.com/bombela/backward-cpp/commit/74dd7d6733d1ab6b79994f4acbc1ad86ba950d23.patch" - patch_file: "patches/backward-cpp-1.5-add-iterator-include.patch" - base_path: "source_subfolder" + - patch_file: "patches/backward-cpp-1.5-mingw.patch" + "1.4": + - patch_file: "patches/backward-cpp-1.4.patch" + - patch_file: "patches/backward-cpp-1.4-7539d53b54f08f056dc9366c8d5c24c5d749cfce.patch" + patch_source: "https://github.com/bombela/backward-cpp/commit/7539d53b54f08f056dc9366c8d5c24c5d749cfce.patch" + - patch_file: "patches/backward-cpp-1.4-b7ffd640ec48ada93045f8c46fc65f823490819b.patch" + patch_source: "https://github.com/bombela/backward-cpp/commit/b7ffd640ec48ada93045f8c46fc65f823490819b.patch" diff --git a/recipes/backward-cpp/all/conanfile.py b/recipes/backward-cpp/all/conanfile.py index 2e59de82600f1..5ca9c317f3d8d 100644 --- a/recipes/backward-cpp/all/conanfile.py +++ b/recipes/backward-cpp/all/conanfile.py @@ -1,34 +1,42 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.scm import Version import os +required_conan_version = ">=1.52.0" + class BackwardCppConan(ConanFile): name = "backward-cpp" description = "A beautiful stack trace pretty printer for C++" homepage = "https://github.com/bombela/backward-cpp" url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "backward-cpp", "stack-trace") + topics = ("backward-cpp", "stack-trace") license = "MIT" - exports_sources = [ "CMakeLists.txt", "patches/backward-cpp-*.patch" ] - generators = "cmake" settings = "os", "arch", "compiler", "build_type" options = { - "stack_walking" : ["unwind", "backtrace"], - "stack_details" : ["dw", "bfd", "dwarf", "backtrace_symbol"], - "shared": [True, False], - "fPIC": [True, False] + "shared": [True, False], + "fPIC": [True, False], + "stack_walking" : ["unwind", "backtrace"], + "stack_details" : ["dw", "bfd", "dwarf", "backtrace_symbol"], } default_options = { - "stack_walking": "unwind", - "stack_details": "dwarf", - "shared": False, - "fPIC": True + "shared": False, + "fPIC": True, + "stack_walking": "unwind", + "stack_details": "dwarf", } - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + @property + def _supported_os(self): + supported_os = ["Linux", "Macos", "Android"] + if Version(self.version) >= "1.5": + supported_os.append("Windows") + return supported_os def _has_stack_walking(self, type): return self.options.stack_walking == type @@ -36,113 +44,99 @@ def _has_stack_walking(self, type): def _has_stack_details(self, type): return False if self.settings.os == "Windows" else self.options.stack_details == type - def _supported_os(self): - return ["Linux", "Macos", "Android", "Windows"] if tools.Version(self.version) >= "1.5" \ - else ["Linux", "Macos", "Android"] + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC del self.options.stack_details + # default option + if self.settings.os == "Macos": + self.options.stack_details = "backtrace_symbol" def configure(self): - if self.settings.os not in self._supported_os(): - raise ConanInvalidConfiguration("upstream backward-cpp v{0} is not \ - supported in {1}.".format(self.version, self.settings.os)) + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass - if self.settings.os == "Macos" and \ - not self._has_stack_details("backtrace_symbol"): - raise ConanInvalidConfiguration("only stack_details=backtrace_symbol" - " is supported on Macos") + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - if self.settings.os in ["Linux", "Android"] and \ - self._has_stack_details("dwarf"): - self.requires("libdwarf/20191104") - - def system_requirements(self): - required_package = None - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "Android"]: + if self._has_stack_details("dwarf"): + self.requires("libdwarf/20191104") if self._has_stack_details("dw"): - if tools.os_info.linux_distro in ["ubuntu", "debian"]: - required_package = "libdw-dev" - elif tools.os_info.linux_distro in ["fedora", "centos"]: - required_package = "elfutils-libs" - elif tools.os_info.linux_distro == "opensuse": - required_package = "libdw-devel" - elif tools.os_info.linux_distro == "arch": - required_package = "libelf" - + self.requires("elfutils/0.186") if self._has_stack_details("bfd"): - if tools.os_info.linux_distro in ["ubuntu", "debian"]: - required_package = "binutils-dev" - elif tools.os_info.linux_distro in ["fedora", "centos", "opensuse"]: - required_package = "binutils-devel" - elif tools.os_info.linux_distro == "arch": - required_package = "binutils" - elif tools.os_info.is_freebsd: - required_package = "libbfd" - - if required_package != None: - installer = tools.SystemPackageTool() - if not installer.installed(required_package): - raise ConanInvalidConfiguration("backward-cpp requires {}.".format(required_package)) + self.requires("binutils/2.38") + + def validate(self): + if self.info.settings.os not in self._supported_os: + raise ConanInvalidConfiguration(f"{self.ref} is not supported on {self.info.settings.os}.") + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.info.settings.os == "Macos": + if self.info.settings.arch == "armv8": + raise ConanInvalidConfiguration("Macos M1 not supported yet") + if not self._has_stack_details("backtrace_symbol"): + raise ConanInvalidConfiguration("only stack_details=backtrace_symbol" + " is supported on Macos") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions['STACK_WALKING_UNWIND'] = self._has_stack_walking("unwind") - cmake.definitions['STACK_WALKING_BACKTRACE'] = self._has_stack_walking("backtrace") - cmake.definitions['STACK_DETAILS_AUTO_DETECT'] = False - cmake.definitions['STACK_DETAILS_BACKTRACE_SYMBOL'] = self._has_stack_details("backtrace_symbol") - cmake.definitions['STACK_DETAILS_DW'] = self._has_stack_details("dw") - cmake.definitions['STACK_DETAILS_BFD'] = self._has_stack_details("bfd") - cmake.definitions['STACK_DETAILS_DWARF'] = self._has_stack_details("dwarf") - cmake.definitions['BACKWARD_SHARED'] = self.options.shared - cmake.definitions['BACKWARD_TESTS'] = False - cmake.configure(build_folder=self._build_subfolder) - return cmake - - def _patch_sources(self): - if "patches" in self.conan_data: - if self.version in self.conan_data["patches"]: - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["STACK_WALKING_UNWIND"] = self._has_stack_walking("unwind") + tc.variables["STACK_WALKING_BACKTRACE"] = self._has_stack_walking("backtrace") + tc.variables["STACK_DETAILS_AUTO_DETECT"] = False + tc.variables["STACK_DETAILS_BACKTRACE_SYMBOL"] = self._has_stack_details("backtrace_symbol") + tc.variables["STACK_DETAILS_DW"] = self._has_stack_details("dw") + tc.variables["STACK_DETAILS_BFD"] = self._has_stack_details("bfd") + tc.variables["STACK_DETAILS_DWARF"] = self._has_stack_details("dwarf") + tc.variables["BACKWARD_SHARED"] = self.options.shared + tc.variables["BACKWARD_TESTS"] = False + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy(pattern="LICENSE*", dst="licenses", src=self._source_subfolder) - os.remove(os.path.join(self.package_folder, "lib", "backward", "BackwardConfig.cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "backward")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "Backward" - self.cpp_info.names["cmake_find_package_multi"] = "Backward" + self.cpp_info.set_property("cmake_file_name", "Backward") + self.cpp_info.set_property("cmake_target_name", "Backward::Backward") - self.cpp_info.defines.append('BACKWARD_HAS_UNWIND={}'.format(int(self._has_stack_walking("unwind")))) - self.cpp_info.defines.append('BACKWARD_HAS_BACKTRACE={}'.format(int(self._has_stack_walking("backtrace")))) + self.cpp_info.defines.append("BACKWARD_HAS_UNWIND={}".format(int(self._has_stack_walking("unwind")))) + self.cpp_info.defines.append("BACKWARD_HAS_BACKTRACE={}".format(int(self._has_stack_walking("backtrace")))) - self.cpp_info.defines.append('BACKWARD_HAS_BACKTRACE_SYMBOL={}'.format(int(self._has_stack_details("backtrace_symbol")))) - self.cpp_info.defines.append('BACKWARD_HAS_DW={}'.format(int(self._has_stack_details("dw")))) - self.cpp_info.defines.append('BACKWARD_HAS_BFD={}'.format(int(self._has_stack_details("bfd")))) - self.cpp_info.defines.append('BACKWARD_HAS_DWARF={}'.format(int(self._has_stack_details("dwarf")))) - self.cpp_info.defines.append('BACKWARD_HAS_PDB_SYMBOL={}'.format(int(self.settings.os == "Windows"))) + self.cpp_info.defines.append("BACKWARD_HAS_BACKTRACE_SYMBOL={}".format(int(self._has_stack_details("backtrace_symbol")))) + self.cpp_info.defines.append("BACKWARD_HAS_DW={}".format(int(self._has_stack_details("dw")))) + self.cpp_info.defines.append("BACKWARD_HAS_BFD={}".format(int(self._has_stack_details("bfd")))) + self.cpp_info.defines.append("BACKWARD_HAS_DWARF={}".format(int(self._has_stack_details("dwarf")))) + self.cpp_info.defines.append("BACKWARD_HAS_PDB_SYMBOL={}".format(int(self.settings.os == "Windows"))) - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["backward"] if self.settings.os == "Linux": self.cpp_info.system_libs.extend(["dl"]) - if self._has_stack_details("dw"): - self.cpp_info.system_libs.extend(["dw"]) - if self._has_stack_details("bfd"): - self.cpp_info.system_libs.extend(["bfd"]) if self.settings.os == "Windows": self.cpp_info.system_libs.extend(["psapi", "dbghelp"]) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "Backward" + self.cpp_info.names["cmake_find_package_multi"] = "Backward" diff --git a/recipes/backward-cpp/all/patches/backward-cpp-1.4.patch b/recipes/backward-cpp/all/patches/backward-cpp-1.4.patch index 1ee41e9e22298..f0e6e425a176f 100644 --- a/recipes/backward-cpp/all/patches/backward-cpp-1.4.patch +++ b/recipes/backward-cpp/all/patches/backward-cpp-1.4.patch @@ -1,14 +1,24 @@ ---- CMakeLists.txt.old 2019-12-27 12:02:21.820493913 +0100 -+++ CMakeLists.txt 2019-12-27 12:06:07.968261384 +0100 -@@ -34,7 +34,6 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -20,7 +20,7 @@ + # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + # SOFTWARE. + +-cmake_minimum_required(VERSION 2.8.12) ++cmake_minimum_required(VERSION 3.8) + project(backward CXX) + + include(BackwardConfig.cmake) +@@ -33,8 +33,6 @@ if (COMPILER_NAME MATCHES "^nvcc") + endif() # set CXX standard - set(CMAKE_CXX_STANDARD_REQUIRED True) +-set(CMAKE_CXX_STANDARD_REQUIRED True) -set(CMAKE_CXX_STANDARD 11) if (${COMPILER_IS_NVCC}) # GNU CXX extensions are not supported by nvcc set(CMAKE_CXX_EXTENSIONS OFF) -@@ -47,7 +46,7 @@ +@@ -47,7 +45,7 @@ endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") if (NOT ${COMPILER_IS_NVCC}) @@ -17,24 +27,45 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") endif() -@@ -74,6 +73,7 @@ +@@ -56,11 +54,13 @@ endif() + # BACKWARD OBJECT + ############################################################################### + ++if(0) + add_library(backward_object OBJECT backward.cpp) + target_compile_definitions(backward_object PRIVATE ${BACKWARD_DEFINITIONS}) + target_include_directories(backward_object PRIVATE ${BACKWARD_INCLUDE_DIRS}) + set(BACKWARD_ENABLE $ CACHE STRING + "Link with this object to setup backward automatically") ++endif() + + + ############################################################################### +@@ -74,6 +74,19 @@ endif() add_library(backward ${libtype} backward.cpp) target_compile_definitions(backward PUBLIC ${BACKWARD_DEFINITIONS}) target_include_directories(backward PUBLIC ${BACKWARD_INCLUDE_DIRS}) -+conan_target_link_libraries(backward) ++target_compile_features(backward PUBLIC cxx_std_11) ++if(STACK_DETAILS_DW) ++ find_package(elfutils REQUIRED CONFIG) ++ target_link_libraries(backward PUBLIC elfutils::libdw) ++endif() ++if(STACK_DETAILS_BFD) ++ find_package(binutils REQUIRED CONFIG) ++ target_link_libraries(backward PUBLIC binutils::binutils) ++endif() ++if(STACK_DETAILS_DWARF) ++ find_package(libdwarf REQUIRED CONFIG) ++ target_link_libraries(backward PUBLIC libdwarf::libdwarf) ++endif() ############################################################################### # TESTS -@@ -117,11 +117,23 @@ +@@ -117,11 +130,18 @@ if(BACKWARD_TESTS) endforeach() endif() -+# Introduce variables: -+# * CMAKE_INSTALL_LIBDIR -+# * CMAKE_INSTALL_BINDIR -+# * CMAKE_INSTALL_INCLUDEDIR +include(GNUInstallDirs) -+ install( FILES "backward.hpp" - DESTINATION ${CMAKE_INSTALL_PREFIX}/include @@ -51,10 +82,9 @@ + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) - ---- backward.hpp.old 2019-12-27 13:11:07.097037784 +0100 -+++ backward.hpp 2019-12-27 13:11:23.336703016 +0100 -@@ -1922,7 +1922,7 @@ +--- a/backward.hpp ++++ b/backward.hpp +@@ -1922,7 +1922,7 @@ private: dwarf_file_t file_handle; file_handle.reset(open(filename_object.c_str(), O_RDONLY)); diff --git a/recipes/backward-cpp/all/patches/backward-cpp-1.5-add-iterator-include.patch b/recipes/backward-cpp/all/patches/backward-cpp-1.5-add-iterator-include.patch index a9175d0114a07..b8743d5496f52 100644 --- a/recipes/backward-cpp/all/patches/backward-cpp-1.5-add-iterator-include.patch +++ b/recipes/backward-cpp/all/patches/backward-cpp-1.5-add-iterator-include.patch @@ -1,10 +1,10 @@ --- backward.hpp.old 2020-05-05 20:37:23.473359490 +0200 +++ backward.hpp 2020-05-05 20:38:57.019308525 +0200 -@@ -309,6 +309,7 @@ +@@ -309,6 +309,6 @@ #include #include #include +#include - +- #include typedef SSIZE_T ssize_t; diff --git a/recipes/backward-cpp/all/patches/backward-cpp-1.5-mingw.patch b/recipes/backward-cpp/all/patches/backward-cpp-1.5-mingw.patch new file mode 100644 index 0000000000000..e274749027f9c --- /dev/null +++ b/recipes/backward-cpp/all/patches/backward-cpp-1.5-mingw.patch @@ -0,0 +1,16 @@ +--- backward.hpp ++++ backward.hpp +@@ -313,1 +313,1 @@ +-#include ++#include +@@ -317,1 +317,1 @@ +-#include ++#include +@@ -320,1 +320,1 @@ +-#include ++#include +@@ -4017,2 +4017,2 @@ +- set_terminate(&terminator); +- set_unexpected(&terminator); ++ std::set_terminate(&terminator); ++ std::set_unexpected(&terminator); diff --git a/recipes/backward-cpp/all/patches/backward-cpp-1.5.patch b/recipes/backward-cpp/all/patches/backward-cpp-1.5.patch index 4fe311e6ee5b6..2fa198687d928 100644 --- a/recipes/backward-cpp/all/patches/backward-cpp-1.5.patch +++ b/recipes/backward-cpp/all/patches/backward-cpp-1.5.patch @@ -1,31 +1,67 @@ ---- CMakeLists.txt.old 2020-04-16 23:52:50.168833268 +0200 -+++ CMakeLists.txt 2020-04-16 23:52:58.480651391 +0200 -@@ -46,7 +46,6 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -20,7 +20,7 @@ + # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + # SOFTWARE. + +-cmake_minimum_required(VERSION 3.0) ++cmake_minimum_required(VERSION 3.8) + project(backward CXX) + + # Introduce variables: +@@ -45,8 +45,6 @@ if (DEFINED ENV{OMPI_CXX} OR DEFINED ENV{MPICH_CXX}) + endif() # set CXX standard - set(CMAKE_CXX_STANDARD_REQUIRED True) +-set(CMAKE_CXX_STANDARD_REQUIRED True) -set(CMAKE_CXX_STANDARD 11) if (${COMPILER_IS_NVCC}) # GNU CXX extensions are not supported by nvcc set(CMAKE_CXX_EXTENSIONS OFF) -@@ -59,7 +58,7 @@ +@@ -59,7 +57,7 @@ endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") if (NOT ${COMPILER_IS_NVCC}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") -+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") endif() -@@ -86,6 +85,7 @@ +@@ -68,11 +66,13 @@ endif() + # BACKWARD OBJECT + ############################################################################### + ++if(0) + add_library(backward_object OBJECT backward.cpp) + target_compile_definitions(backward_object PRIVATE ${BACKWARD_DEFINITIONS}) + target_include_directories(backward_object PRIVATE ${BACKWARD_INCLUDE_DIRS}) + set(BACKWARD_ENABLE $ CACHE STRING + "Link with this object to setup backward automatically") ++endif() + + + ############################################################################### +@@ -86,6 +86,19 @@ endif() add_library(backward ${libtype} backward.cpp) target_compile_definitions(backward PUBLIC ${BACKWARD_DEFINITIONS}) target_include_directories(backward PUBLIC ${BACKWARD_INCLUDE_DIRS}) -+conan_target_link_libraries(backward) ++target_compile_features(backward PUBLIC cxx_std_11) ++if(STACK_DETAILS_DW) ++ find_package(elfutils REQUIRED CONFIG) ++ target_link_libraries(backward PUBLIC elfutils::libdw) ++endif() ++if(STACK_DETAILS_BFD) ++ find_package(binutils REQUIRED CONFIG) ++ target_link_libraries(backward PUBLIC binutils::binutils) ++endif() ++if(STACK_DETAILS_DWARF) ++ find_package(libdwarf REQUIRED CONFIG) ++ target_link_libraries(backward PUBLIC libdwarf::libdwarf) ++endif() ############################################################################### # TESTS -@@ -137,3 +137,9 @@ +@@ -137,3 +150,9 @@ install( FILES "BackwardConfig.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/backward ) diff --git a/recipes/backward-cpp/all/test_package/CMakeLists.txt b/recipes/backward-cpp/all/test_package/CMakeLists.txt index cb436339de00b..9950bd34800a4 100644 --- a/recipes/backward-cpp/all/test_package/CMakeLists.txt +++ b/recipes/backward-cpp/all/test_package/CMakeLists.txt @@ -1,34 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) - -# Force test_package to be generated in build_folder (CMAKE_BINARY_DIR) -# so we get same behaviour between Unix Makefiles & Visual studio generator - -# First for the generic no-config case (e.g. with mingw) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) -# Second, for multi-config builds (e.g. msvc) -foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}) -endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES) - -if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - if (CMAKE_BUILD_TYPE MATCHES "Debug" AND MSVC_RUNTIME_TYPE) - set (MSVC_RUNTIME_TYPE "${MSVC_RUNTIME_TYPE}d") - endif () - - set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MSVC_RUNTIME_TYPE}") - set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MSVC_RUNTIME_TYPE}") - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${MSVC_RUNTIME_TYPE}") - set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/PROFILE") - - message (STATUS "Build type: ${CMAKE_BUILD_TYPE}") - message (STATUS "USE MSVC RUNTIME: ${MSVC_RUNTIME_TYPE}") -endif() - -find_package(Backward REQUIRED) +find_package(Backward REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} PRIVATE Backward::Backward) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/backward-cpp/all/test_package/conanfile.py b/recipes/backward-cpp/all/test_package/conanfile.py index ed9f488d8a63e..0a6bc68712d90 100644 --- a/recipes/backward-cpp/all/test_package/conanfile.py +++ b/recipes/backward-cpp/all/test_package/conanfile.py @@ -1,21 +1,26 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) - compiler = self.settings.compiler - if compiler == 'Visual Studio': - runtime = str(self.settings.compiler.runtime) - cmake.definitions["MSVC_RUNTIME_TYPE"] = '/' + runtime cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join(self.build_folder, "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/backward-cpp/all/test_v1_package/CMakeLists.txt b/recipes/backward-cpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/backward-cpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/backward-cpp/all/test_v1_package/conanfile.py b/recipes/backward-cpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/backward-cpp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/backward-cpp/config.yml b/recipes/backward-cpp/config.yml index 21e5a85a81100..2379ce6b78062 100644 --- a/recipes/backward-cpp/config.yml +++ b/recipes/backward-cpp/config.yml @@ -1,5 +1,7 @@ versions: - "1.4": + "1.6": folder: all "1.5": folder: all + "1.4": + folder: all diff --git a/recipes/bacnet-stack/all/conandata.yml b/recipes/bacnet-stack/all/conandata.yml index 834cc1c526e20..d44111989de5e 100644 --- a/recipes/bacnet-stack/all/conandata.yml +++ b/recipes/bacnet-stack/all/conandata.yml @@ -1,13 +1,10 @@ sources: - "20200306": - sha256: bf61bc7ffe556b30464ac0734e18d975fe6a8676d9c2fcb7c215981a46381847 - url: https://github.com/bacnet-stack/bacnet-stack/archive/4a916468c63de478b84ef4d0c67d541cd84da27e.zip - "20200515": - sha256: dda1b8c180c3eeb85eb950de5a5907fa22543d7c6b930f11f3fe735eb6ea662b - url: https://github.com/bacnet-stack/bacnet-stack/archive/3553ae56c2b0240949ddf54dbea4213b0c69433c.zip - "20200601": - sha256: 0575a7b1f9d05778ed6211a6a095d344b8684aebf3b51889423b51a4f3575889 - url: https://github.com/bacnet-stack/bacnet-stack/archive/ff9697bab4d520588dae350de9b8a700c8af18a0.zip "1.0.0": - sha256: 6a57448fa8099bcb51713a6799f9f08f4f14f70dc9c69c6927129b0a21868b92 - url: https://github.com/bacnet-stack/bacnet-stack/archive/bacnet-stack-1.0.0.zip + url: "https://github.com/bacnet-stack/bacnet-stack/archive/refs/tags/bacnet-stack-1.0.0.tar.gz" + sha256: "8dad24decb3870bc8147a1ea5eecd5c6f8c1205ec48d5ae4d454085427122658" +patches: + "1.0.0": + - patch_file: "patches/0001-fix-dll-install.patch" + patch_description: "Fix installation of dll" + patch_type: "portability" + patch_source: "https://github.com/bacnet-stack/bacnet-stack/pull/351" diff --git a/recipes/bacnet-stack/all/conanfile.py b/recipes/bacnet-stack/all/conanfile.py index 1d0069018b56d..69ae62a1c72de 100644 --- a/recipes/bacnet-stack/all/conanfile.py +++ b/recipes/bacnet-stack/all/conanfile.py @@ -1,6 +1,9 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir import os -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.53.0" class BacnetStackConan(ConanFile): @@ -12,8 +15,7 @@ class BacnetStackConan(ConanFile): BACnet Protocol Stack library provides a BACnet application layer, network layer and media access (MAC) layer communications services.""" topics = ("bacnet") - exports_sources = ['CMakeLists.txt'] - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -22,63 +24,51 @@ class BacnetStackConan(ConanFile): "shared": False, "fPIC": True } - generators = "cmake", "cmake_find_package" - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("Windows shared builds are not supported right now, see issue https://github.com/bacnet-stack/bacnet-stack/issues/49") + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - if self.version.startswith("2020"): - extracted_dir = self.name + "-" + os.path.basename(self.conan_data["sources"][self.version]["url"]).split(".")[0] - else: - extracted_dir = self.name + "-" + self.name + "-" + self.version - - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BACNET_STACK_BUILD_APPS"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BACNET_STACK_BUILD_APPS"] = False + tc.generate() def build(self): - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("gpl-2.txt", dst='licenses', src=os.path.join(self._source_subfolder, "license")) - cmake = self._configure_cmake() + copy(self, pattern="gpl-2.txt", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "license")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, - "lib", "bacnet-stack", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "bacnet-stack", "cmake")) def package_info(self): self.cpp_info.libs = ["bacnet-stack"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["pthread"] elif self.settings.os == "Windows": self.cpp_info.system_libs = ["ws2_32"] if not self.options.shared: self.cpp_info.defines = ["BACNET_STACK_STATIC_DEFINE"] + self.cpp_info.set_property("cmake_file_name", "bacnet-stack") + self.cpp_info.set_property("cmake_target_name", "bacnet-stack::bacnet-stack") diff --git a/recipes/bacnet-stack/all/patches/0001-fix-dll-install.patch b/recipes/bacnet-stack/all/patches/0001-fix-dll-install.patch new file mode 100644 index 0000000000000..b15286bcdd1e5 --- /dev/null +++ b/recipes/bacnet-stack/all/patches/0001-fix-dll-install.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -659,6 +659,7 @@ set(BACNET_STACK_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME + install( + TARGETS ${PROJECT_NAME} + EXPORT ${PROJECT_NAME}Targets ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib) + diff --git a/recipes/bacnet-stack/all/test_package/CMakeLists.txt b/recipes/bacnet-stack/all/test_package/CMakeLists.txt index 33ae887aa6aea..ad98c1486c8f3 100644 --- a/recipes/bacnet-stack/all/test_package/CMakeLists.txt +++ b/recipes/bacnet-stack/all/test_package/CMakeLists.txt @@ -1,9 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(bacnet-stack REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE bacnet-stack::bacnet-stack) diff --git a/recipes/bacnet-stack/all/test_package/conanfile.py b/recipes/bacnet-stack/all/test_package/conanfile.py index 933dbf96533ae..a60b6fe8a1512 100644 --- a/recipes/bacnet-stack/all/test_package/conanfile.py +++ b/recipes/bacnet-stack/all/test_package/conanfile.py @@ -1,11 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os -from conans import ConanFile, CMake, tools +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" -class TestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -13,6 +21,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - bin_path = self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + diff --git a/recipes/bacnet-stack/all/test_package/test_package.c b/recipes/bacnet-stack/all/test_package/test_package.c new file mode 100644 index 0000000000000..317c15cde5c25 --- /dev/null +++ b/recipes/bacnet-stack/all/test_package/test_package.c @@ -0,0 +1,24 @@ +#include "bacnet/basic/object/device.h" +#include "bacnet/basic/service/h_apdu.h" +#include "bacnet/basic/binding/address.h" +#include "bacnet/bacdef.h" +#include "bacnet/basic/services.h" + +static void Init_Service_Handlers(void) +{ + Device_Init(NULL); + apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); + apdu_set_unrecognized_service_handler_handler(handler_unrecognized_service); + apdu_set_confirmed_handler( + SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property); + apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, handler_i_am_add); +} + +int main(int argc, char *argv[]) +{ + address_init(); + Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE); + Init_Service_Handlers(); + + return 0; +} diff --git a/recipes/bacnet-stack/all/test_package/test_package.cpp b/recipes/bacnet-stack/all/test_package/test_package.cpp deleted file mode 100644 index 28a71f016d118..0000000000000 --- a/recipes/bacnet-stack/all/test_package/test_package.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "bacnet/basic/object/device.h" -#include "bacnet/basic/service/h_apdu.h" -#include "bacnet/basic/binding/address.h" -#include "bacnet/bacdef.h" -#include "bacnet/basic/services.h" - -static void Init_Service_Handlers(void) -{ - Device_Init(nullptr); - apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); - apdu_set_unrecognized_service_handler_handler(handler_unrecognized_service); - apdu_set_confirmed_handler( - SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property); - apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, handler_i_am_add); -} - -int main(int argc, char *argv[]) -{ - address_init(); - Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE); - Init_Service_Handlers(); - - return 0; -} diff --git a/recipes/bacnet-stack/all/test_v1_package/CMakeLists.txt b/recipes/bacnet-stack/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/bacnet-stack/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/bacnet-stack/all/test_v1_package/conanfile.py b/recipes/bacnet-stack/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..6005bae433a02 --- /dev/null +++ b/recipes/bacnet-stack/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class TestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + bin_path = self.run(bin_path, run_environment=True) diff --git a/recipes/bacnet-stack/config.yml b/recipes/bacnet-stack/config.yml index 056dc291cd850..c7f13630776fb 100644 --- a/recipes/bacnet-stack/config.yml +++ b/recipes/bacnet-stack/config.yml @@ -1,10 +1,3 @@ ---- versions: - "20200306": - folder: "all" - "20200515": - folder: "all" - "20200601": - folder: "all" "1.0.0": folder: "all" diff --git a/recipes/bandit/all/conandata.yml b/recipes/bandit/all/conandata.yml new file mode 100644 index 0000000000000..f6a1c1fc0eaad --- /dev/null +++ b/recipes/bandit/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "cci.20210618": + url: "https://github.com/banditcpp/bandit/archive/77f50861c09d794af9ae5f65111b330d9b721054.tar.gz" + sha256: "4fe2eeb623e16a09b56f7a4e3d8fde864a5a4a67226cb514945fa7e9a1ae216a" +patches: + "cci.20210618": + - patch_file: "patches/0001-change-snowhouse-path.patch" + patch_description: "Fix snowhouse.h include path" + patch_type: "conan" diff --git a/recipes/bandit/all/conanfile.py b/recipes/bandit/all/conanfile.py new file mode 100644 index 0000000000000..31fd2c6978fa4 --- /dev/null +++ b/recipes/bandit/all/conanfile.py @@ -0,0 +1,46 @@ +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.51.3" + + +class BanditConan(ConanFile): + name = "bandit" + description = "Human-friendly unit testing for C++11" + topics = ("testing", "header-only") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/banditcpp/bandit" + license = "MIT" + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def requirements(self): + self.requires("snowhouse/5.0.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def layout(self): + basic_layout(self) + + def build(self): + apply_conandata_patches(self) + + def package(self): + copy(self, "LICENSE.txt", src=os.path.join(self.source_folder, "docs"), dst=os.path.join(self.package_folder, "licenses")) + copy(self, pattern="*", dst=os.path.join(self.package_folder, "include", "bandit"), src=os.path.join(self.source_folder, "bandit")) + + def package_id(self): + self.info.clear() + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + diff --git a/recipes/bandit/all/patches/0001-change-snowhouse-path.patch b/recipes/bandit/all/patches/0001-change-snowhouse-path.patch new file mode 100644 index 0000000000000..1df54a4f04d5b --- /dev/null +++ b/recipes/bandit/all/patches/0001-change-snowhouse-path.patch @@ -0,0 +1,13 @@ +diff --git a/bandit/adapters/snowhouse.h b/bandit/adapters/snowhouse.h +index f3d9fde..ee3844c 100644 +--- a/bandit/adapters/snowhouse.h ++++ b/bandit/adapters/snowhouse.h +@@ -3,7 +3,7 @@ + + #include + #include +-#include ++#include + + namespace bandit { + namespace adapter { diff --git a/recipes/bandit/all/test_package/CMakeLists.txt b/recipes/bandit/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..58ffec4a070b7 --- /dev/null +++ b/recipes/bandit/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +find_package(bandit REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} bandit::bandit) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/bandit/all/test_package/conanfile.py b/recipes/bandit/all/test_package/conanfile.py new file mode 100644 index 0000000000000..40f70f535b209 --- /dev/null +++ b/recipes/bandit/all/test_package/conanfile.py @@ -0,0 +1,30 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bandit/all/test_package/test_package.cpp b/recipes/bandit/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..764be0a694402 --- /dev/null +++ b/recipes/bandit/all/test_package/test_package.cpp @@ -0,0 +1,24 @@ +#include +#include + +using namespace snowhouse; +using namespace bandit; + +go_bandit([]() { + describe("context", []() { + bool b; + + before_each([&]() { + b = true; + }); + + it("is true", [&]() { + AssertThat(b, IsTrue()); + }); + }); +}); + +int main(int argc, char** argv) { + return bandit::run(argc, argv); +} + diff --git a/recipes/bandit/all/test_v1_package/CMakeLists.txt b/recipes/bandit/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..08111eba078e8 --- /dev/null +++ b/recipes/bandit/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bandit REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE bandit::bandit) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/bandit/all/test_v1_package/conanfile.py b/recipes/bandit/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/recipes/bandit/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bandit/config.yml b/recipes/bandit/config.yml new file mode 100644 index 0000000000000..5cbf4c1d7cb53 --- /dev/null +++ b/recipes/bandit/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210618": + folder: "all" diff --git a/recipes/base64/all/conandata.yml b/recipes/base64/all/conandata.yml index 4a9e80d3b3b00..6ebaff03fb45d 100644 --- a/recipes/base64/all/conandata.yml +++ b/recipes/base64/all/conandata.yml @@ -1,10 +1,19 @@ sources: + "0.5.0": + url: "https://github.com/aklomp/base64/archive/v0.5.0.tar.gz" + sha256: "b21be58a90d31302ba86056db7ef77a481393b9359c505be5337d7d54e8a0559" "0.4.0": - sha256: 1fce54059c504b2604c22c20cd930444a71b3340fc81334c037da63976d92002 - url: https://github.com/aklomp/base64/archive/v0.4.0.tar.gz + url: "https://github.com/aklomp/base64/archive/v0.4.0.tar.gz" + sha256: "1fce54059c504b2604c22c20cd930444a71b3340fc81334c037da63976d92002" patches: + "0.5.0": + - patch_file: "patches/0.5.0-0001-make.patch" + patch_description: "add library taget" + patch_type: "conan" "0.4.0": - - base_path: "source_subfolder" - patch_file: "patches/make.patch" - - base_path: "source_subfolder" - patch_file: "patches/cmake.patch" + - patch_file: "patches/0.4.0-0001-make.patch" + patch_description: "add library taget" + patch_type: "conan" + - patch_file: "patches/0.4.0-0002-cmake.patch" + patch_description: "provide CMakeLists.txt for MSVC" + patch_type: "conan" diff --git a/recipes/base64/all/conanfile.py b/recipes/base64/all/conanfile.py index 6db47a061d928..d56ae8c5bcf10 100644 --- a/recipes/base64/all/conanfile.py +++ b/recipes/base64/all/conanfile.py @@ -1,85 +1,125 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import Environment +from conan.tools.files import copy, get, apply_conandata_patches, chdir, export_conandata_patches, rmdir +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version + import os -from conans import ConanFile, AutoToolsBuildEnvironment, CMake, tools +required_conan_version = ">=1.52.0" class Base64Conan(ConanFile): name = "base64" + description = "Fast Base64 stream encoder/decoder" license = "BSD-2-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/aklomp/base64" - description = "Fast Base64 stream encoder/decoder" - topics = ("base64", "codec") - exports_sources = "patches/**", "CMakeLists.txt" - generators = "cmake" + topics = ("base64", "codec", "encoder", "decoder") settings = "os", "arch", "compiler", "build_type" options = { - "fPIC": [True, False] + "shared": [True, False], + "fPIC": [True, False], } default_options = { - "fPIC": True + "shared": False, + "fPIC": True, } - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == 'Windows': del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def layout(self): + if self._use_cmake: + cmake_layout(self, src_folder="src") + else: + basic_layout(self, src_folder="src") - def _configure_cmake(self): - cmake = CMake(self) - cmake.configure(build_folder=self._build_subfolder) - return cmake + def validate(self): + if Version(self.version) < "0.5.0" and self.info.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} doesn't support build shared.") - def _build_cmake(self): - cmake = self._configure_cmake() - cmake.build(target="base64") + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + @property + def _use_cmake(self): + return is_msvc(self) or Version(self.version) >= "0.5.0" - def _build_autotools(self): - autotools = AutoToolsBuildEnvironment(self) - if self.settings.arch == "x86" or self.settings.arch == "x86_64": - extra_env = { - "AVX2_CFLAGS": "-mavx2", - "SSSE3_CFLAGS": "-mssse3", - "SSE41_CFLAGS": "-msse4.1", - "SSE42_CFLAGS": "-msse4.2", - "AVX_CFLAGS": "-mavx" - } + def generate(self): + if self._use_cmake: + tc = CMakeToolchain(self) + tc.generate() else: - # ARM-specific instructions can be enabled here - extra_env = {} - with tools.environment_append(extra_env): - with tools.chdir(self._source_subfolder): - autotools.make(target="lib/libbase64.a") + tc = AutotoolsToolchain(self) + tc.generate() def build(self): - self._patch_sources() - if self.settings.compiler == "Visual Studio": - self._build_cmake() + apply_conandata_patches(self) + if self._use_cmake: + cmake = CMake(self) + cmake.configure() + if Version(self.version) >= "0.5.0": + cmake.build() + else: + cmake.build(target="base64") else: - self._build_autotools() + env = Environment() + if self.settings.arch == "x86" or self.settings.arch == "x86_64": + env.append("AVX2_CFLAGS", "-mavx2") + env.append("SSSE3_CFLAGS", "-mssse3") + env.append("SSE41_CFLAGS", "-msse4.1") + env.append("SSE42_CFLAGS", "-msse4.2") + env.append("AVX_CFLAGS", "-mavx") + else: + # ARM-specific instructions can be enabled here + pass + with env.vars(self).apply(), \ + chdir(self, self.source_folder): + autotools = Autotools(self) + autotools.make(target="lib/libbase64.a") def package(self): - self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) - self.copy(pattern="*.a", dst="lib", keep_path=False) - self.copy(pattern="*.lib", dst="lib", keep_path=False) - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + if self._use_cmake: + cmake = CMake(self) + cmake.install() + if Version(self.version) >= "0.5.0": + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + else: + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib")) + copy(self, pattern="*.lib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) + else: + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + copy(self, pattern="*.a", dst=os.path.join(self.package_folder, "lib"), src=self.source_folder, keep_path=False) + copy(self, pattern="*.lib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) def package_info(self): self.cpp_info.libs = ["base64"] + + if Version(self.version) >= "0.5.0" and not self.options.shared: + self.cpp_info.defines.append("BASE64_STATIC_DEFINE") diff --git a/recipes/base64/all/patches/make.patch b/recipes/base64/all/patches/0.4.0-0001-make.patch similarity index 100% rename from recipes/base64/all/patches/make.patch rename to recipes/base64/all/patches/0.4.0-0001-make.patch diff --git a/recipes/base64/all/patches/cmake.patch b/recipes/base64/all/patches/0.4.0-0002-cmake.patch similarity index 100% rename from recipes/base64/all/patches/cmake.patch rename to recipes/base64/all/patches/0.4.0-0002-cmake.patch diff --git a/recipes/base64/all/patches/0.5.0-0001-make.patch b/recipes/base64/all/patches/0.5.0-0001-make.patch new file mode 100644 index 0000000000000..f20d7ff2ec119 --- /dev/null +++ b/recipes/base64/all/patches/0.5.0-0001-make.patch @@ -0,0 +1,14 @@ +diff --git a/Makefile b/Makefile +index 2bb01e2..200ca73 100644 +--- a/Makefile ++++ b/Makefile +@@ -63,6 +63,9 @@ lib/libbase64.o: $(OBJS) + $(LD) -r -o $@ $^ + $(OBJCOPY) --keep-global-symbols=lib/exports.txt $@ + ++lib/libbase64.a: $(OBJS) ++ $(AR) rc $@ $^ ++ + lib/config.h: + @echo "#define HAVE_AVX2 $(HAVE_AVX2)" > $@ + @echo "#define HAVE_NEON32 $(HAVE_NEON32)" >> $@ diff --git a/recipes/base64/all/test_package/CMakeLists.txt b/recipes/base64/all/test_package/CMakeLists.txt index 48b855b8a30aa..195fdf269b250 100644 --- a/recipes/base64/all/test_package/CMakeLists.txt +++ b/recipes/base64/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package C) -add_executable(example example.c) -target_link_libraries(example ${CONAN_LIBS}) +find_package(base64 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE base64::base64) diff --git a/recipes/base64/all/test_package/conanfile.py b/recipes/base64/all/test_package/conanfile.py index 9a662bfeb73fe..a9fb96656f203 100644 --- a/recipes/base64/all/test_package/conanfile.py +++ b/recipes/base64/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os -from conans import ConanFile, CMake, tools -class CppcodecTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/base64/all/test_package/example.c b/recipes/base64/all/test_package/test_package.c similarity index 100% rename from recipes/base64/all/test_package/example.c rename to recipes/base64/all/test_package/test_package.c diff --git a/recipes/base64/all/test_v1_package/CMakeLists.txt b/recipes/base64/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6c32de99d28f7 --- /dev/null +++ b/recipes/base64/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) + +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(base64 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE base64::base64) diff --git a/recipes/base64/all/test_v1_package/conanfile.py b/recipes/base64/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/base64/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/base64/config.yml b/recipes/base64/config.yml index 80f918766690c..d13fcfd021b7b 100644 --- a/recipes/base64/config.yml +++ b/recipes/base64/config.yml @@ -1,4 +1,5 @@ ---- versions: + "0.5.0": + folder: all "0.4.0": folder: all diff --git a/recipes/bdwgc/all/CMakeLists.txt b/recipes/bdwgc/all/CMakeLists.txt deleted file mode 100644 index a69305eb3971f..0000000000000 --- a/recipes/bdwgc/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/bdwgc/all/conandata.yml b/recipes/bdwgc/all/conandata.yml index bf7d831af6c66..97d6a0b86b6e9 100644 --- a/recipes/bdwgc/all/conandata.yml +++ b/recipes/bdwgc/all/conandata.yml @@ -2,7 +2,16 @@ sources: "8.0.4": url: "https://github.com/ivmai/bdwgc/releases/download/v8.0.4/gc-8.0.4.tar.gz" sha256: "436a0ddc67b1ac0b0405b61a9675bca9e075c8156f4debd1d06f3a56c7cd289d" + "8.0.6": + url: "https://github.com/ivmai/bdwgc/releases/download/v8.0.6/gc-8.0.6.tar.gz" + sha256: "3b4914abc9fa76593596773e4da671d7ed4d5390e3d46fbf2e5f155e121bea11" + "8.2.2": + url: "https://github.com/ivmai/bdwgc/releases/download/v8.2.2/gc-8.2.2.tar.gz" + sha256: "f30107bcb062e0920a790ffffa56d9512348546859364c23a14be264b38836a0" patches: "8.0.4": - - patch_file: "patches/update-cmake.patch" - base_path: "source_subfolder" + - patch_file: "patches/update-cmake-8_0_4.patch" + "8.0.6": + - patch_file: "patches/update-cmake-8_0_6.patch" + "8.2.2": + - patch_file: "patches/update-cmake-8_2_2.patch" diff --git a/recipes/bdwgc/all/conanfile.py b/recipes/bdwgc/all/conanfile.py index e65b97e9e08dc..925a47c27595c 100644 --- a/recipes/bdwgc/all/conanfile.py +++ b/recipes/bdwgc/all/conanfile.py @@ -1,18 +1,21 @@ -from conans import CMake, ConanFile, tools -from conans.errors import ConanException +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.scm import Version +from conan.tools.files import apply_conandata_patches, get, save, rmdir, copy, load +from conan.errors import ConanException import os +required_conan_version = ">=1.50.0" + class BdwGcConan(ConanFile): name = "bdwgc" homepage = "https://www.hboehm.info/gc/" description = "The Boehm-Demers-Weiser conservative C/C++ Garbage Collector (libgc, bdwgc, boehm-gc)" - topics = ("conan", "gc", "garbage", "collector") + topics = ("gc", "garbage", "collector") url = "https://github.com/conan-io/conan-center-index" license = "MIT" settings = "os", "compiler", "build_type", "arch" - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake" _autotools_options_defaults = ( ("cplusplus", False,), @@ -23,7 +26,6 @@ class BdwGcConan(ConanFile): ("handle_fork", True,), ("thread_local_alloc", True,), ("threads_discovery", True,), - ("parallel_mark", True,), ("gcj_support", True,), ("java_finalization", True,), ("sigrt_signals", False,), @@ -37,7 +39,6 @@ class BdwGcConan(ConanFile): ("munmap", True,), ("dynamic_loading", True,), ("register_main_static_data", True,), - ("gc_assertions", False,), ("checksums", False,), ("single_obj_compilation", False,), ) @@ -46,6 +47,7 @@ class BdwGcConan(ConanFile): "shared": [True, False], "fPIC": [True, False], } + default_options = { "shared": False, "fPIC": True, @@ -54,11 +56,9 @@ class BdwGcConan(ConanFile): options[option] = [True, False] default_options[option] = default - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -66,52 +66,60 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - if tools.Version(self.version) <= "8.0.4": + try: + del self.options.fPIC + except Exception: + pass + if Version(self.version) < "8.2.0": del self.options.throw_bad_alloc_library if not self.options.cplusplus: - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): if self.settings.os == "Windows": - self.requires("libatomic_ops/7.6.10") + self.requires("libatomic_ops/7.6.14") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("gc-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) + def generate(self): + tc = CMakeToolchain(self) for option, _ in self._autotools_options_defaults: - self._cmake.definitions["enable_{}".format(option)] = self.options.get_safe(option) - self._cmake.definitions["disable_gc_debug"] = not self.options.gc_debug - self._cmake.definitions["disable_handle_fork"] = not self.options.handle_fork - self._cmake.definitions["install_headers"] = True - self._cmake.definitions["build_tests"] = False - if tools.is_apple_os(self.settings.os): - cmake_osx_arch = { - "x86": "i386", - }.get(str(self.settings.arch), str(self.settings.arch)) - self._cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = cmake_osx_arch - self._cmake.verbose = True - self._cmake.parallel = False - self._cmake.configure() - return self._cmake - - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + if option == "cord": + tc.variables["build_cord"] = self.options.get_safe(option) + elif option == "cplusplus": + tc.cache_variables["enable_cplusplus"] = str(self.options.get_safe(option)) + else: + tc.variables["enable_{}".format(option)] = self.options.get_safe(option) + tc.variables["disable_gc_debug"] = not self.options.gc_debug + tc.variables["disable_handle_fork"] = not self.options.handle_fork + tc.variables["install_headers"] = True + tc.variables["enable_docs"] = False + tc.variables["build_tests"] = False + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + tc = CMakeDeps(self) + tc.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def _extract_copyright(self): - readme_md = open(os.path.join(self._source_subfolder, "README.md")).read() + readme_md = load(self, os.path.join(self.source_folder, "README.md")) copyright_header = "## Copyright & Warranty\n" index = readme_md.find(copyright_header) if index == -1: @@ -119,28 +127,43 @@ def _extract_copyright(self): return readme_md[index+len(copyright_header):] def package(self): - tools.save(os.path.join(self.package_folder, "licenses", "COPYRIGHT"), self._extract_copyright()) - cmake = self._configure_cmake() + save(self, os.path.join(self.package_folder, "licenses", "COPYRIGHT"), self._extract_copyright()) + cmake = CMake(self) cmake.install() - - @property - def _libs(self): - libs = [] - if self.options.get_safe("throw_bad_alloc_library"): - libs.append("gctba") - if self.options.cplusplus: - libs.append("gccpp") - if self.options.cord: - libs.append("cord") - libs.append("gc") - return libs + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.names["pkg_config"] = "bdw-gc" - self.cpp_info.libs = self._libs - self.cpp_info.defines = ["GC_DLL" if self.options.shared else "GC_NOT_DLL"] - if not self.options.shared: - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["pthread", "dl"] + self.cpp_info.set_property("cmake_file_name", "BDWgc") + self.cpp_info.set_property("cmake_target_name", "BDWgc::BDWgc") + + # TODO: Remove on Conan 2.0 + self.cpp_info.names["cmake_find_package"] = "BDWgc" + self.cpp_info.names["cmake_find_package_multi"] = "BDWgc" + + self.cpp_info.components["gc"].set_property("cmake_target_name", "BDWgc::gc") + self.cpp_info.components["gc"].set_property("pkg_config_name", "bdw-gc") + self.cpp_info.components["gc"].libs = ["gc"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["gc"].system_libs = ["pthread", "dl"] + self.cpp_info.components["gc"].defines = ["GC_DLL" if self.options.shared else "GC_NOT_DLL"] if self.options.gc_debug: - self.cpp_info.defines.append("GC_DEBUG") + self.cpp_info.components["gc"].defines.append("GC_DEBUG") + if self.settings.os == "Windows": + self.cpp_info.components["gc"].requires = ["libatomic_ops::atomic_ops"] + + if self.options.cplusplus and self.options.get_safe("throw_bad_alloc_library"): + self.cpp_info.components["gctba"].set_property("cmake_target_name", "BDWgc::gctba") + self.cpp_info.components["gctba"].libs = ["gctba"] + self.cpp_info.components["gctba"].requires = ["gc"] + + if self.options.cplusplus: + self.cpp_info.components["gccpp"].set_property("cmake_target_name", "BDWgc::gccpp") + self.cpp_info.components["gccpp"].libs = ["gccpp"] + self.cpp_info.components["gccpp"].requires = ["gc"] + + if self.options.cord: + self.cpp_info.components["cord"].set_property("cmake_target_name", "BDWgc::cord") + self.cpp_info.components["cord"].libs = ["cord"] + self.cpp_info.components["cord"].requires = ["gc"] diff --git a/recipes/bdwgc/all/patches/update-cmake-8_0_4.patch b/recipes/bdwgc/all/patches/update-cmake-8_0_4.patch new file mode 100644 index 0000000000000..1af6e770494fc --- /dev/null +++ b/recipes/bdwgc/all/patches/update-cmake-8_0_4.patch @@ -0,0 +1,841 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -21,241 +21,603 @@ + # this will generate gc.sln + # + +-SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required +- +-PROJECT(gc) +- +-INCLUDE(CTest) +- +-CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +- +-ADD_DEFINITIONS("-D_CRT_SECURE_NO_DEPRECATE +- -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION") +- +-IF(APPLE) +- IF("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") +- SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;x86_64" CACHE STRING "Build architectures for Mac OS X" FORCE) +- ENDIF() +-ENDIF(APPLE) +- +-#LIBATOMIC #TODO +-#ADD_LIBRARY(atomic_ops STATIC ) +-#SET_TARGET_PROPERTIES(atomic_ops PROPERTIES COMPILE_FLAGS -DNO_DEBUGGING) +- +- +-#LIBGC +- +-INCLUDE_DIRECTORIES(include) +-INCLUDE_DIRECTORIES(libatomic_ops/src) +- +-SET(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c ++cmake_minimum_required(VERSION 3.1) ++ ++option(enable_cplusplus "C++ support" OFF) ++if (enable_cplusplus) ++ project(gc) ++else() ++ project(gc C) ++endif() ++ ++include(CheckCCompilerFlag) ++include(CheckCSourceCompiles) ++include(CheckFunctionExists) ++include(CheckIncludeFile) ++include(CheckSymbolExists) ++include(CTest) ++ ++# Customize the build by passing "-D=ON|OFF" in the command line. ++option(BUILD_SHARED_LIBS "Build shared libraries" ON) ++option(build_cord "Build cord library" ON) ++option(build_tests "Build tests" OFF) ++option(enable_threads "Support threads" ON) ++option(enable_parallel_mark "Parallelize marking and free list construction" ON) ++option(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON) ++option(enable_threads_discovery "Enable threads discovery in GC" ON) ++option(enable_gcj_support "Support for gcj" ON) ++option(enable_sigrt_signals "Use SIGRTMIN-based signals for thread suspend/resume" OFF) ++option(enable_gc_debug "Support for pointer back-tracing" OFF) ++option(disable_gc_debug "Disable debugging like GC_dump and its callees" OFF) ++option(enable_java_finalization "Support for java finalization" ON) ++option(enable_atomic_uncollectable "Support for atomic uncollectible allocation" ON) ++option(enable_redirect_malloc "Redirect malloc and friends to GC routines" OFF) ++option(enable_disclaim "Support alternative finalization interface" ON) ++option(enable_large_config "Optimize for large heap or root set" OFF) ++option(enable_gc_assertions "Enable collector-internal assertion checking" OFF) ++option(enable_mmap "Use mmap instead of sbrk to expand the heap" OFF) ++option(enable_munmap "Return page to the OS if empty for N collections" ON) ++option(enable_dynamic_loading "Enable tracing of dynamic library data roots" ON) ++option(enable_register_main_static_data "Perform the initial guess of data root sets" ON) ++option(enable_checksums "Report erroneously cleared dirty bits" OFF) ++option(enable_werror "Pass -Werror to the C compiler (treat warnings as errors)" OFF) ++option(enable_single_obj_compilation "Compile all libgc source files into single .o" OFF) ++option(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON) ++option(disable_handle_fork "Prohibit installation of pthread_atfork() handlers" OFF) ++option(install_headers "Install header files" ON) ++ ++add_definitions("-DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION") ++ ++if (APPLE AND ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")) ++ set(CMAKE_OSX_ARCHITECTURES "x86_64;i386" ++ CACHE STRING "Build architectures for Mac OS X" FORCE) ++endif() ++ ++# Set struct packing alignment to word (instead of 1-byte). ++if (BORLAND) ++ add_compile_options(/a4) ++elseif (WATCOM) ++ add_compile_options(/zp4) ++endif() ++ ++# Output all warnings. ++if (BORLAND) ++ # All warnings except for particular ones. ++ add_compile_options(/w /w-pro /w-aus /w-par /w-ccc /w-inl /w-rch) ++elseif (MSVC) ++ # All warnings but ignoring "unreferenced formal parameter" and ++ # "conditional expression is constant" ones. ++ add_compile_options(/W4 /wd4100 /wd4127) ++ # Disable crt security warnings, since unfortunately they warn about all ++ # sorts of safe uses of strncpy. ++ add_definitions("-D_CRT_SECURE_NO_DEPRECATE") ++elseif (WATCOM) ++ add_compile_options(/wx) ++else() ++ # TODO add -[W]pedantic -Wno-long-long ++ add_compile_options(-Wall -Wextra) ++endif() ++ ++include_directories(include) ++ ++set(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c + mark_rts.c headers.c mark.c obj_map.c blacklst.c finalize.c + new_hblk.c dbg_mlc.c malloc.c dyn_load.c typd_mlc.c ptr_chck.c + mallocx.c) +-SET(LIBS) +-OPTION(enable_threads "TODO" NO) +-IF(enable_threads) +- FIND_PACKAGE(Threads REQUIRED) +- MESSAGE("Thread Model: ${CMAKE_THREAD_LIBS_INIT}" ) +- INCLUDE_DIRECTORIES(${Threads_INCLUDE_DIR}) +- SET(LIBS ${LIBS} ${Threads_LIBRARIES}) +-ENDIF(enable_threads) +- +-OPTION(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON) +- +-OPTION(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON) +- +-OPTION(enable_parallel_mark "Parallelize marking and free list construction" ON) +- +-#IF(Threads_FOUND) +-# ADD_DEFINITIONS("") +-#ELSE +-# MESSAGE("Parallel mark requires enable_threads ON" ) +-#ENDIF(Threads_FOUND) +- +-#OPTION(enable_cplusplus "install C++ support" ON) +-SET(SRC ${SRC} gc_cpp.cc) +- +-SET(_HOST ${CMAKE_HOST_SYSTEM_PROCESSOR}--${CMAKE_SYSTEM}) #FIXME missing the vendor field. +-STRING(TOLOWER ${_HOST} HOST) +-MESSAGE("HOST = ${HOST}") +- +-# Thread Detection. Relying on cmake for lib and includes. +-#TODO check cmake detection +-IF(CMAKE_USE_PTHREADS_INIT) +- SET(SRC ${SRC} pthread_start.c pthread_support.c pthread_stop_world.c) +- # Common defines for most POSIX platforms. +- IF( HOST MATCHES .*-.*-aix.*|.*-.*-android.*|.*-.*-cygwin.*|.*-.*-darwin.*|.*-.*-.*freebsd.*|.*-.*-haiku.*|.*-.*-gnu.*|.*-.*-hpux11.*|.*-.*-irix.*|.*-.*-.*linux.*|.*-.*-nacl.*|.*-.*-netbsd.*|.*-.*-openbsd.*|.*-.*-osf.*|.*-.*-solaris.*) +- ADD_DEFINITIONS("-DGC_THREADS -D_REENTRANT") +- IF(enable_parallel_mark) +- ADD_DEFINITIONS("-DPARALLEL_MARK") +- ENDIF(enable_parallel_mark) +- IF(enable_thread_local_alloc) +- ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC") +- SET(SRC ${SRC} thread_local_alloc.c) +- ENDIF(enable_thread_local_alloc) +- MESSAGE("Explicit GC_INIT() calls may be required.") +- ENDIF() +- IF ( HOST MATCHES .*-.*-hpux11.*) +- MESSAGE("Only HP/UX 11 POSIX threads are supported.") +- ADD_DEFINITIONS("-D_POSIX_C_SOURCE=199506L") #TODO test -DVAR=value. Alternative is COMPILE_DEFINITIONS property +- ENDIF() +- IF ( HOST MATCHES .*-.*-hpux10.*) +- MESSAGE("HP/UX 10 POSIX threads are not supported.") +- ENDIF() +- IF ( HOST MATCHES .*-.*-netbsd.*) +- MESSAGE("Only on NetBSD 2.0 or later.") +- ADD_DEFINITIONS("-D_PTHREADS") +- ENDIF() +- IF( HOST MATCHES .*-.*-android.*) +- # Android NDK does not provide pthread_atfork. +- ELSEIF( HOST MATCHES .*-.*-aix.*|.*-.*-cygwin.*|.*-.*-freebsd.*|.*-.*-haiku.*|.*-.*-hpux11.*|.*-.*-irix.*|.*-.*-kfreebsd.*-gnu|.*-.*-.*linux.*|.*-.*-netbsd.*|.*-.*-openbsd.*|.*-.*-osf.*|.*-.*-solaris.*) +- IF(enable_handle_fork) +- ADD_DEFINITIONS("-DHANDLE_FORK") +- ENDIF(enable_handle_fork) +- ENDIF() +- IF ( HOST MATCHES .*-.*-cygwin.*) +- SET(SRC ${SRC} win32_threads.c) +- ENDIF() +- IF ( HOST MATCHES .*-.*-darwin.*) +- IF(enable_handle_fork) +- # The incremental mode conflicts with fork handling. +- IF(enable_parallel_mark) +- ADD_DEFINITIONS("-DHANDLE_FORK") +- ENDIF(enable_parallel_mark) +- ENDIF(enable_handle_fork) +- SET(SRC ${SRC} darwin_stop_world.c) +- #TODO +- #darwin_threads=true +- ENDIF() +-ENDIF(CMAKE_USE_PTHREADS_INIT) +- +-IF(CMAKE_USE_WIN32_THREADS_INIT) +- ADD_DEFINITIONS("-DGC_THREADS") +- IF(enable_parallel_mark) +- ADD_DEFINITIONS("-DPARALLEL_MARK") +- IF(enable_thread_local_alloc) +- ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC") +- SET(SRC ${SRC} thread_local_alloc.c) +- ENDIF(enable_thread_local_alloc) +- ENDIF() +- ADD_DEFINITIONS("-DEMPTY_GETENV_RESULTS") #TODO test +- SET(SRC ${SRC} win32_threads.c) +-ENDIF(CMAKE_USE_WIN32_THREADS_INIT) +- +-OPTION(enable_gcj_support "Support for gcj" ON) +-IF(enable_gcj_support) +- ADD_DEFINITIONS("-DGC_GCJ_SUPPORT") +- IF(enable_threads) +- ADD_DEFINITIONS("-DGC_ENABLE_SUSPEND_THREAD") +- ENDIF(enable_threads) +- SET(SRC ${SRC} gcj_mlc.c) +-ENDIF(enable_gcj_support) +- +-OPTION(enable_disclaim "Support alternative finalization interface" ON) +-IF(enable_disclaim) +- ADD_DEFINITIONS("-DENABLE_DISCLAIM") +- SET(SRC ${SRC} fnlz_mlc.c) +-ENDIF(enable_disclaim) +- +-OPTION(enable_java_finalization "Support for java finalization" ON) +-IF(enable_java_finalization) +- ADD_DEFINITIONS("-DJAVA_FINALIZATION") +-ENDIF(enable_java_finalization) +- +-OPTION(enable_atomic_uncollectable "Support for atomic uncollectible allocation" ON) +-IF(enable_atomic_uncollectable) +- ADD_DEFINITIONS("-DGC_ATOMIC_UNCOLLECTABLE") +-ENDIF(enable_atomic_uncollectable) +- +-OPTION(enable_gc_debug "Support for pointer back-tracing" NO) +-IF(enable_gc_debug) +- ADD_DEFINITIONS("-DDBG_HDRS_ALL -DKEEP_BACK_PTRS") +- IF (HOST MATCHES ia64-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86-.*-linux.*|x86_64-.*-linux.*) +- ADD_DEFINITIONS("-DMAKE_BACK_GRAPH") +- ADD_DEFINITIONS("-DSAVE_CALL_COUNT=8") +- SET(SRC ${SRC} backgraph.c) +- ENDIF() +- IF (HOST MATCHES i.86-.*-dgux.*) +- ADD_DEFINITIONS("-DMAKE_BACK_GRAPH") +- SET(SRC ${SRC} backgraph.c) +- ENDIF() +-ENDIF(enable_gc_debug) +- +-OPTION(enable_redirect_malloc "Redirect malloc and friends to GC routines" NO) +-IF(enable_redirect_malloc) +- IF(enable_gc_debug) +- ADD_DEFINITIONS("-DREDIRECT_MALLOC=GC_debug_malloc_replacement") +- ADD_DEFINITIONS("-DREDIRECT_REALLOC=GC_debug_realloc_replacement") +- ADD_DEFINITIONS("-DREDIRECT_FREE=GC_debug_free") +- ELSE(enable_gc_debug) +- ADD_DEFINITIONS("-DREDIRECT_MALLOC=GC_malloc") +- ENDIF(enable_gc_debug) +- ADD_DEFINITIONS("-DGC_USE_DLOPEN_WRAP") +-ENDIF(enable_redirect_malloc) +- +-OPTION(enable_mmap "Use mmap instead of sbrk to expand the heap" NO) +- +-OPTION(enable_munmap "Return page to the OS if empty for N collections" ON) +-IF(enable_munmap) +- ADD_DEFINITIONS("-DUSE_MMAP -DUSE_MUNMAP") +-ELSEIF(enable_mmap) +- ADD_DEFINITIONS("-DUSE_MMAP") +-ENDIF() +- +-OPTION(enable_dynamic_loading "Enable tracing of dynamic library data roots" ON) +-IF(NOT enable_dynamic_loading) +- ADD_DEFINITIONS("-DIGNORE_DYNAMIC_LOADING") +-ENDIF() +- +-OPTION(enable_register_main_static_data "Perform the initial guess of data root sets" ON) +-IF(NOT enable_register_main_static_data) +- ADD_DEFINITIONS("-DGC_DONT_REGISTER_MAIN_STATIC_DATA") +-ENDIF() +- +-OPTION(enable_large_config "Optimize for large heap or root set" NO) +-IF(enable_large_config) +- ADD_DEFINITIONS("-DLARGE_CONFIG") +-ENDIF(enable_large_config) +- +-OPTION(enable_gc_assertions "Enable collector-internal assertion checking" NO) +-IF(enable_gc_assertions) +- ADD_DEFINITIONS("-DGC_ASSERTIONS") +-ENDIF(enable_gc_assertions) +- +-OPTION(enable_threads_discovery "Enable threads discovery in GC" ON) +-IF(NOT enable_threads_discovery) +- ADD_DEFINITIONS("-DGC_NO_THREADS_DISCOVERY") +-ENDIF() +- +-OPTION(enable_checksums "Report erroneously cleared dirty bits" NO) +-IF(enable_checksums) +- IF(enable_munmap OR enable_threads) +- MESSAGE("CHECKSUMS not compatible with USE_MUNMAP or threads") +- ENDIF() +- ADD_DEFINITIONS("-DCHECKSUMS") +- SET(SRC ${SRC} checksums.c) +-ENDIF(enable_checksums) +- +-ADD_LIBRARY( gc-lib STATIC ${SRC}) +-SET_TARGET_PROPERTIES(gc-lib PROPERTIES +- COMPILE_DEFINITIONS GC_NOT_DLL) +-#TODO TARGET_LINK_LIBRARIES(... ... ${LIBS}) +- +-ADD_LIBRARY( gcmt-lib STATIC ${SRC}) +-SET_TARGET_PROPERTIES(gcmt-lib PROPERTIES +- COMPILE_DEFINITIONS GC_NOT_DLL) +- +-ADD_LIBRARY( gcmt-dll SHARED ${SRC}) +- +-IF(WIN32) +- ADD_EXECUTABLE(cord cord/cordbscs.c cord/cordxtra.c +- cord/tests/de.c cord/tests/de_win.c) +- SET_TARGET_PROPERTIES(cord PROPERTIES WIN32_EXECUTABLE TRUE) +- SET_TARGET_PROPERTIES(cord PROPERTIES +- COMPILE_DEFINITIONS GC_NOT_DLL) +- TARGET_LINK_LIBRARIES(cord gc-lib) +- TARGET_LINK_LIBRARIES(cord gdi32) +-ENDIF(WIN32) +- +-ADD_SUBDIRECTORY(tests) ++set(THREADDLLIBS) ++ ++set(_HOST ${CMAKE_SYSTEM_PROCESSOR}-unknown-${CMAKE_SYSTEM}) ++string(TOLOWER ${_HOST} HOST) ++message(STATUS "TARGET = ${HOST}") ++ ++if (enable_threads) ++ if(NOT APPLE) ++ find_package(Threads REQUIRED) ++ message(STATUS "Thread library: ${CMAKE_THREAD_LIBS_INIT}") ++ include_directories(${Threads_INCLUDE_DIR}) ++ set(THREADDLLIBS ${CMAKE_THREAD_LIBS_INIT}) ++ endif() ++ if (MSVC) ++ find_package(Atomic_ops CONFIG) ++ if (Atomic_ops_FOUND) ++ get_target_property(AO_INCLUDE_DIRS Atomic_ops::atomic_ops ++ INTERFACE_INCLUDE_DIRECTORIES) ++ include_directories(${AO_INCLUDE_DIRS}) ++ endif() ++ endif() ++ if (NOT (APPLE OR CYGWIN OR MSYS OR WIN32 OR HOST MATCHES mips-.*-irix6.*)) ++ set(THREADDLLIBS ${THREADDLLIBS} -ldl) ++ # The predefined CMAKE_DL_LIBS may be broken. ++ endif() ++endif(enable_threads) ++ ++# Thread support detection. ++if (CMAKE_USE_PTHREADS_INIT) ++ set(SRC ${SRC} pthread_start.c pthread_support.c pthread_stop_world.c) ++ if (HOST MATCHES .*-.*-hpux10.*) ++ message(FATAL_ERROR "HP/UX 10 POSIX threads are not supported.") ++ endif() ++ # Assume the compiler supports C11 (GCC) atomic intrinsics. ++ add_definitions("-DGC_BUILTIN_ATOMIC") ++ # Common defines for POSIX platforms. ++ add_definitions("-DGC_THREADS -D_REENTRANT") ++ if (enable_parallel_mark) ++ add_definitions("-DPARALLEL_MARK") ++ endif() ++ if (enable_thread_local_alloc) ++ add_definitions("-DTHREAD_LOCAL_ALLOC") ++ set(SRC ${SRC} thread_local_alloc.c) ++ endif() ++ message("Explicit GC_INIT() calls may be required.") ++ if (HOST MATCHES .*-.*-hpux11.*) ++ message("Only HP/UX 11 POSIX threads are supported.") ++ add_definitions("-D_POSIX_C_SOURCE=199506L") ++ elseif (HOST MATCHES .*-.*-netbsd.*) ++ message("Only on NetBSD 2.0 or later.") ++ add_definitions("-D_PTHREADS") ++ endif() ++ if (ANDROID OR MSYS) # ANDROID variable is defined by CMake v3.7.0+. ++ # Android NDK does not provide pthread_atfork. ++ elseif (APPLE) ++ if (enable_handle_fork AND NOT disable_handle_fork) ++ # The incremental mode conflicts with fork handling. ++ if (enable_parallel_mark) ++ add_definitions("-DHANDLE_FORK") ++ endif(enable_parallel_mark) ++ endif() ++ set(SRC ${SRC} darwin_stop_world.c) ++ elseif (enable_handle_fork AND NOT disable_handle_fork) ++ add_definitions("-DHANDLE_FORK") ++ endif() ++ if (enable_sigrt_signals) ++ add_definitions("-DGC_USESIGRT_SIGNALS") ++ endif() ++ if (CYGWIN OR MSYS) ++ set(SRC ${SRC} win32_threads.c) ++ endif() ++elseif (CMAKE_USE_WIN32_THREADS_INIT) ++ add_definitions("-DGC_THREADS") ++ if (enable_parallel_mark) ++ add_definitions("-DPARALLEL_MARK") ++ endif() ++ if (enable_thread_local_alloc AND (enable_parallel_mark OR NOT BUILD_SHARED_LIBS)) ++ # Imply THREAD_LOCAL_ALLOC unless GC_DLL. ++ add_definitions("-DTHREAD_LOCAL_ALLOC") ++ set(SRC ${SRC} thread_local_alloc.c) ++ endif() ++ add_definitions("-DEMPTY_GETENV_RESULTS") ++ set(SRC ${SRC} win32_threads.c) ++elseif (CMAKE_HP_PTHREADS_INIT OR CMAKE_USE_SPROC_INIT) ++ message(FATAL_ERROR "Unsupported thread package") ++endif() ++ ++if (disable_handle_fork) ++ add_definitions("-DNO_HANDLE_FORK") ++endif() ++ ++if (enable_gcj_support) ++ add_definitions("-DGC_GCJ_SUPPORT") ++ if (enable_threads AND NOT (enable_thread_local_alloc AND HOST MATCHES .*-.*-kfreebsd.*-gnu)) ++ # FIXME: For a reason, gctest hangs up on kFreeBSD if both of ++ # THREAD_LOCAL_ALLOC and GC_ENABLE_SUSPEND_THREAD are defined. ++ add_definitions("-DGC_ENABLE_SUSPEND_THREAD") ++ endif() ++ set(SRC ${SRC} gcj_mlc.c) ++endif(enable_gcj_support) ++ ++if (enable_disclaim) ++ add_definitions("-DENABLE_DISCLAIM") ++ set(SRC ${SRC} fnlz_mlc.c) ++endif() ++ ++if (enable_java_finalization) ++ add_definitions("-DJAVA_FINALIZATION") ++endif() ++ ++if (enable_atomic_uncollectable) ++ add_definitions("-DGC_ATOMIC_UNCOLLECTABLE") ++endif() ++ ++if (enable_gc_debug) ++ add_definitions("-DDBG_HDRS_ALL -DKEEP_BACK_PTRS") ++ if (HOST MATCHES i.86-.*-dgux.*|ia64-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86-.*-linux.*|x86_64-.*-linux.*) ++ add_definitions("-DMAKE_BACK_GRAPH") ++ if (HOST MATCHES .*-.*-.*linux.*) ++ add_definitions("-DSAVE_CALL_COUNT=8") ++ endif() ++ set(SRC ${SRC} backgraph.c) ++ endif() ++endif(enable_gc_debug) ++ ++if (disable_gc_debug) ++ add_definitions("-DNO_DEBUGGING") ++elseif (WINCE) ++ # Read environment variables from ".gc.env" file. ++ add_definitions("-DGC_READ_ENV_FILE") ++endif() ++ ++if (enable_redirect_malloc) ++ if (enable_gc_debug) ++ add_definitions("-DREDIRECT_MALLOC=GC_debug_malloc_replacement") ++ add_definitions("-DREDIRECT_REALLOC=GC_debug_realloc_replacement") ++ add_definitions("-DREDIRECT_FREE=GC_debug_free") ++ else() ++ add_definitions("-DREDIRECT_MALLOC=GC_malloc") ++ endif() ++ add_definitions("-DGC_USE_DLOPEN_WRAP") ++endif(enable_redirect_malloc) ++ ++if (enable_munmap) ++ add_definitions("-DUSE_MMAP -DUSE_MUNMAP") ++elseif (enable_mmap) ++ add_definitions("-DUSE_MMAP") ++endif() ++ ++if (NOT enable_dynamic_loading) ++ add_definitions("-DIGNORE_DYNAMIC_LOADING") ++endif() ++ ++if (NOT enable_register_main_static_data) ++ add_definitions("-DGC_DONT_REGISTER_MAIN_STATIC_DATA") ++endif() ++ ++if (enable_large_config) ++ add_definitions("-DLARGE_CONFIG") ++endif() ++ ++if (enable_gc_assertions) ++ add_definitions("-DGC_ASSERTIONS") ++endif() ++ ++if (NOT enable_threads_discovery) ++ add_definitions("-DGC_NO_THREADS_DISCOVERY") ++endif() ++ ++if (enable_checksums) ++ if (enable_munmap OR enable_threads) ++ message(FATAL_ERROR "CHECKSUMS not compatible with USE_MUNMAP or threads") ++ endif() ++ add_definitions("-DCHECKSUMS") ++ set(SRC ${SRC} checksums.c) ++endif(enable_checksums) ++ ++if (enable_werror) ++ if (BORLAND) ++ add_compile_options(/w!) ++ elseif (MSVC) ++ add_compile_options(/WX) ++ # Workaround "typedef ignored on left of ..." warning reported in ++ # imagehlp.h of e.g. Windows Kit 8.1. ++ add_compile_options(/wd4091) ++ elseif (WATCOM) ++ add_compile_options(/we) ++ else() ++ add_compile_options(-Werror) ++ if (APPLE) ++ # _dyld_bind_fully_image_containing_address is deprecated in OS X 10.5+ ++ add_compile_options(-Wno-deprecated-declarations) ++ endif() ++ endif() ++endif(enable_werror) ++ ++if (enable_single_obj_compilation OR BUILD_SHARED_LIBS) ++ set(SRC extra/gc.c) # override SRC ++ if (CMAKE_USE_PTHREADS_INIT) ++ add_definitions("-DGC_PTHREAD_START_STANDALONE") ++ set(SRC ${SRC} pthread_start.c) ++ endif(CMAKE_USE_PTHREADS_INIT) ++elseif (BORLAND) ++ # Suppress "GC_push_contents_hdr() is declared but never used" warning. ++ add_compile_options(/w-use) ++endif() ++ ++# Add implementation of backtrace() and backtrace_symbols(). ++if (MSVC) ++ set(SRC ${SRC} extra/msvc_dbg.c) ++endif() ++ ++# Instruct check_c_source_compiles and similar CMake checks not to ignore ++# compiler warnings (like "implicit declaration of function"). ++if (NOT BORLAND AND NOT MSVC AND NOT WATCOM) ++ check_c_compiler_flag(-Werror HAVE_FLAG_WERROR) ++ if (HAVE_FLAG_WERROR) ++ SET(CMAKE_REQUIRED_FLAGS "-Werror") ++ endif(HAVE_FLAG_WERROR) ++endif() ++ ++if (BUILD_SHARED_LIBS) ++ add_definitions("-DGC_DLL") ++ # Pass -fvisibility=hidden option if supported. ++ check_c_compiler_flag(-fvisibility=hidden HAVE_FLAG_F_VISIBILITY_HIDDEN) ++ if (HAVE_FLAG_F_VISIBILITY_HIDDEN) ++ add_definitions("-DGC_VISIBILITY_HIDDEN_SET") ++ add_compile_options(-fvisibility=hidden) ++ else() ++ add_definitions("-DGC_NO_VISIBILITY") ++ endif() ++ check_c_compiler_flag(-Wl,--no-undefined HAVE_FLAG_WL_NO_UNDEFINED) ++else() ++ add_definitions("-DGC_NOT_DLL") ++ if (WIN32) ++ # Do not require the clients to link with "user32" system library. ++ add_definitions("-DDONT_USE_USER32_DLL") ++ endif(WIN32) ++endif() ++ ++# Disable strict aliasing optimizations. ++# It could re-enabled back by a flag passed in CFLAGS_EXTRA. ++check_c_compiler_flag(-fno-strict-aliasing HAVE_FLAG_F_NO_STRICT_ALIASING) ++if (HAVE_FLAG_F_NO_STRICT_ALIASING) ++ add_compile_options(-fno-strict-aliasing) ++endif() ++ ++# Extra user-defined flags to pass both to C and C++ compilers. ++if (DEFINED CFLAGS_EXTRA) ++ add_compile_options(${CFLAGS_EXTRA}) ++endif() ++ ++# Check whether execinfo.h header file is present. ++check_include_file(execinfo.h HAVE_EXECINFO_H) ++if (NOT HAVE_EXECINFO_H) ++ add_definitions("-DGC_MISSING_EXECINFO_H") ++endif() ++ ++# Check for getcontext (uClibc can be configured without it, for example). ++check_function_exists(getcontext HAVE_GETCONTEXT) ++if (NOT HAVE_GETCONTEXT) ++ add_definitions("-DNO_GETCONTEXT") ++endif() ++ ++# Check whether dl_iterate_phdr exists (as a strong symbol). ++check_function_exists(dl_iterate_phdr HAVE_DL_ITERATE_PHDR) ++if (HAVE_DL_ITERATE_PHDR) ++ add_definitions("-DHAVE_DL_ITERATE_PHDR") ++endif() ++ ++check_symbol_exists(sigsetjmp setjmp.h HAVE_SIGSETJMP) ++if (NOT HAVE_SIGSETJMP) ++ add_definitions("-DGC_NO_SIGSETJMP") ++endif() ++ ++# pthread_setname_np, if available, may have 1, 2 or 3 arguments. ++if (CMAKE_USE_PTHREADS_INIT) ++ check_c_source_compiles(" ++#include \n ++int main(void) { (void)pthread_setname_np(\"thread-name\"); return 0; }" ++ HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) ++ if (HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) ++ # Define to use 'pthread_setname_np(const char*)' function. ++ add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITHOUT_TID") ++ else() ++ check_c_source_compiles(" ++#include \n ++int main(void) {\n ++ (void)pthread_setname_np(pthread_self(), \"thread-name-%u\", 0); return 0; }" ++ HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG) ++ if (HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG) ++ # Define to use 'pthread_setname_np(pthread_t, const char*, void *)'. ++ add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG") ++ else() ++ check_c_source_compiles(" ++#if defined(__linux__) || defined(__GLIBC__) || defined(__GNU__) || defined(__CYGWIN__)\n ++#define _GNU_SOURCE 1\n ++#endif\n ++#include \n ++int main(void) {\n ++ (void)pthread_setname_np(pthread_self(), \"thread-name\"); return 0; }" ++ HAVE_PTHREAD_SETNAME_NP_WITH_TID) ++ if (HAVE_PTHREAD_SETNAME_NP_WITH_TID) ++ # Define to use 'pthread_setname_np(pthread_t, const char*)' function. ++ add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITH_TID") ++ endif() ++ endif(HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG) ++ endif (HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) ++endif() ++ ++# Check for dladdr (used for debugging). ++check_c_source_compiles(" ++#define _GNU_SOURCE 1\n ++#include \n ++int main(void) { Dl_info info; (void)dladdr(\"\", &info); return 0; }" ++ HAVE_DLADDR) ++if (HAVE_DLADDR) ++ # Define to use 'dladdr' function. ++ add_definitions("-DHAVE_DLADDR") ++endif() ++ ++add_library(gc ${SRC}) ++if (enable_threads) ++ target_link_libraries(gc PRIVATE ${THREADDLLIBS}) ++endif() ++ ++if (enable_cplusplus) ++ add_library(gccpp gc_cpp.cc) ++ target_link_libraries(gccpp PRIVATE gc) ++endif() ++ ++if (build_cord) ++ set(CORD_SRC cord/cordbscs.c cord/cordprnt.c cord/cordxtra.c) ++ add_library(cord ${CORD_SRC}) ++ target_link_libraries(cord PRIVATE gc) ++ install(TARGETS cord EXPORT cordExports ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++ RUNTIME DESTINATION bin ++ INCLUDES DESTINATION include) ++endif() ++ ++if (BUILD_SHARED_LIBS AND HAVE_FLAG_WL_NO_UNDEFINED) ++ # Declare that the libraries do not refer to external symbols. ++ # TODO: use add_link_options() when cmake_minimum_required > 3.13 ++ target_link_libraries(gc PRIVATE -Wl,--no-undefined) ++ if (enable_cplusplus) ++ target_link_libraries(gccpp PRIVATE -Wl,--no-undefined) ++ endif(enable_cplusplus) ++ if (build_cord) ++ target_link_libraries(cord PRIVATE -Wl,--no-undefined) ++ endif(build_cord) ++endif() ++ ++install(TARGETS gc EXPORT gcExports ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++ RUNTIME DESTINATION bin ++ INCLUDES DESTINATION include) ++ ++if (enable_cplusplus) ++ install(TARGETS gccpp EXPORT gccppExports ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++ RUNTIME DESTINATION bin ++ INCLUDES DESTINATION include) ++endif() ++ ++if (install_headers) ++ install(FILES include/gc.h ++ include/gc_backptr.h ++ include/gc_config_macros.h ++ include/gc_gcj.h ++ include/gc_inline.h ++ include/gc_mark.h ++ include/gc_pthread_redirects.h ++ include/gc_tiny_fl.h ++ include/gc_typed.h ++ include/gc_version.h ++ include/javaxfc.h ++ include/leak_detector.h ++ DESTINATION include/gc) ++ install(FILES include/extra/gc.h DESTINATION include) ++ if (enable_cplusplus) ++ install(FILES include/gc_allocator.h ++ include/gc_cpp.h ++ DESTINATION include/gc) ++ install(FILES include/extra/gc_cpp.h DESTINATION include) ++ endif() ++ if (enable_disclaim) ++ install(FILES include/gc_disclaim.h DESTINATION include/gc) ++ endif() ++ if (build_cord) ++ install(FILES include/cord.h ++ include/cord_pos.h ++ include/ec.h ++ DESTINATION include/gc) ++ endif() ++endif(install_headers) ++ ++if (build_tests) ++ if (build_cord) ++ add_executable(cordtest cord/tests/cordtest.c) ++ target_link_libraries(cordtest PRIVATE cord gc) ++ add_test(NAME cordtest COMMAND cordtest) ++ ++ if (WIN32 AND NOT CYGWIN) ++ add_executable(de cord/tests/de.c cord/tests/de_win.c ++ cord/tests/de_win.rc) ++ set_target_properties(de PROPERTIES WIN32_EXECUTABLE TRUE) ++ target_link_libraries(de PRIVATE cord gc gdi32) ++ endif() ++ endif(build_cord) ++ ++ # Compile some tests as C++ to test extern "C" in header files. ++ if (enable_cplusplus) ++ set_source_files_properties(tests/leak_test.c tests/test.c ++ PROPERTIES LANGUAGE CXX) ++ # To avoid "treating 'c' input as 'c++' when in C++ mode" Clang warning. ++ if (NOT (BORLAND OR MSVC OR WATCOM)) ++ add_compile_options(-x c++) ++ endif() ++ endif(enable_cplusplus) ++ ++ add_executable(gctest WIN32 tests/test.c) ++ target_link_libraries(gctest PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME gctest COMMAND gctest) ++ if (WATCOM) ++ # Suppress "conditional expression in if statement is always true/false" ++ # and "unreachable code" warnings in GC_MALLOC_[ATOMIC_]WORDS. ++ target_compile_options(gctest PRIVATE ++ /wcd=13 /wcd=201 /wcd=367 /wcd=368 /wcd=726) ++ endif() ++ ++ add_executable(hugetest tests/huge_test.c) ++ target_link_libraries(hugetest PRIVATE gc) ++ add_test(NAME hugetest COMMAND hugetest) ++ ++ add_executable(leaktest tests/leak_test.c) ++ target_link_libraries(leaktest PRIVATE gc) ++ add_test(NAME leaktest COMMAND leaktest) ++ ++ add_executable(middletest tests/middle.c) ++ target_link_libraries(middletest PRIVATE gc) ++ add_test(NAME middletest COMMAND middletest) ++ ++ add_executable(realloc_test tests/realloc_test.c) ++ target_link_libraries(realloc_test PRIVATE gc) ++ add_test(NAME realloc_test COMMAND realloc_test) ++ ++ add_executable(smashtest tests/smash_test.c) ++ target_link_libraries(smashtest PRIVATE gc) ++ add_test(NAME smashtest COMMAND smashtest) ++ ++ if (NOT (BUILD_SHARED_LIBS AND WIN32)) ++ add_library(staticrootslib_test tests/staticrootslib.c) ++ target_link_libraries(staticrootslib_test PRIVATE gc) ++ add_library(staticrootslib2_test tests/staticrootslib.c) ++ target_compile_options(staticrootslib2_test PRIVATE "-DSTATICROOTSLIB2") ++ target_link_libraries(staticrootslib2_test PRIVATE gc) ++ add_executable(staticrootstest tests/staticrootstest.c) ++ target_compile_options(staticrootstest PRIVATE "-DSTATICROOTSLIB2") ++ target_link_libraries(staticrootstest PRIVATE ++ gc staticrootslib_test staticrootslib2_test) ++ add_test(NAME staticrootstest COMMAND staticrootstest) ++ endif() ++ ++ if (enable_gc_debug) ++ add_executable(tracetest tests/trace_test.c) ++ target_link_libraries(tracetest PRIVATE gc) ++ add_test(NAME tracetest COMMAND tracetest) ++ endif() ++ ++ if (enable_threads) ++ add_executable(test_atomic_ops tests/test_atomic_ops.c) ++ target_link_libraries(test_atomic_ops PRIVATE gc) ++ add_test(NAME test_atomic_ops COMMAND test_atomic_ops) ++ ++ add_executable(threadleaktest tests/thread_leak_test.c) ++ target_link_libraries(threadleaktest PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME threadleaktest COMMAND threadleaktest) ++ ++ if (NOT WIN32) ++ add_executable(threadkey_test tests/threadkey_test.c) ++ target_link_libraries(threadkey_test PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME threadkey_test COMMAND threadkey_test) ++ endif() ++ ++ add_executable(subthreadcreate_test tests/subthread_create.c) ++ target_link_libraries(subthreadcreate_test PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME subthreadcreate_test COMMAND subthreadcreate_test) ++ ++ add_executable(initsecondarythread_test tests/initsecondarythread.c) ++ target_link_libraries(initsecondarythread_test PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME initsecondarythread_test COMMAND initsecondarythread_test) ++ endif(enable_threads) ++ ++ if (enable_cplusplus) ++ add_executable(test_cpp WIN32 tests/test_cpp.cc) ++ target_link_libraries(test_cpp PRIVATE gc gccpp) ++ add_test(NAME test_cpp COMMAND test_cpp) ++ endif() ++ ++ if (enable_disclaim) ++ add_executable(disclaim_bench tests/disclaim_bench.c) ++ target_link_libraries(disclaim_bench PRIVATE gc) ++ add_test(NAME disclaim_bench COMMAND disclaim_bench) ++ ++ add_executable(disclaim_test tests/disclaim_test.c) ++ target_link_libraries(disclaim_test PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME disclaim_test COMMAND disclaim_test) ++ ++ add_executable(disclaim_weakmap_test tests/disclaim_weakmap_test.c) ++ target_link_libraries(disclaim_weakmap_test PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME disclaim_weakmap_test COMMAND disclaim_weakmap_test) ++ endif() ++endif(build_tests) diff --git a/recipes/bdwgc/all/patches/update-cmake-8_0_6.patch b/recipes/bdwgc/all/patches/update-cmake-8_0_6.patch new file mode 100644 index 0000000000000..10451ed429544 --- /dev/null +++ b/recipes/bdwgc/all/patches/update-cmake-8_0_6.patch @@ -0,0 +1,828 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -21,232 +21,599 @@ + # this will generate gc.sln + # + +-SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required +- +-PROJECT(gc) +- +-INCLUDE(CTest) +- +-CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +- +-ADD_DEFINITIONS("-D_CRT_SECURE_NO_DEPRECATE +- -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION") +- +-#LIBATOMIC #TODO +-#ADD_LIBRARY(atomic_ops STATIC ) +-#SET_TARGET_PROPERTIES(atomic_ops PROPERTIES COMPILE_FLAGS -DNO_DEBUGGING) +- +- +-#LIBGC +- +-INCLUDE_DIRECTORIES(include) +-INCLUDE_DIRECTORIES(libatomic_ops/src) +- +-SET(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c ++cmake_minimum_required(VERSION 3.1) ++ ++option(enable_cplusplus "C++ support" OFF) ++if (enable_cplusplus) ++ project(gc) ++else() ++ project(gc C) ++endif() ++ ++include(CheckCCompilerFlag) ++include(CheckCSourceCompiles) ++include(CheckFunctionExists) ++include(CheckIncludeFile) ++include(CheckSymbolExists) ++include(CTest) ++ ++# Customize the build by passing "-D=ON|OFF" in the command line. ++option(BUILD_SHARED_LIBS "Build shared libraries" ON) ++option(build_cord "Build cord library" ON) ++option(build_tests "Build tests" OFF) ++option(enable_threads "Support threads" ON) ++option(enable_parallel_mark "Parallelize marking and free list construction" ON) ++option(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON) ++option(enable_threads_discovery "Enable threads discovery in GC" ON) ++option(enable_gcj_support "Support for gcj" ON) ++option(enable_sigrt_signals "Use SIGRTMIN-based signals for thread suspend/resume" OFF) ++option(enable_gc_debug "Support for pointer back-tracing" OFF) ++option(disable_gc_debug "Disable debugging like GC_dump and its callees" OFF) ++option(enable_java_finalization "Support for java finalization" ON) ++option(enable_atomic_uncollectable "Support for atomic uncollectible allocation" ON) ++option(enable_redirect_malloc "Redirect malloc and friends to GC routines" OFF) ++option(enable_disclaim "Support alternative finalization interface" ON) ++option(enable_large_config "Optimize for large heap or root set" OFF) ++option(enable_gc_assertions "Enable collector-internal assertion checking" OFF) ++option(enable_mmap "Use mmap instead of sbrk to expand the heap" OFF) ++option(enable_munmap "Return page to the OS if empty for N collections" ON) ++option(enable_dynamic_loading "Enable tracing of dynamic library data roots" ON) ++option(enable_register_main_static_data "Perform the initial guess of data root sets" ON) ++option(enable_checksums "Report erroneously cleared dirty bits" OFF) ++option(enable_werror "Pass -Werror to the C compiler (treat warnings as errors)" OFF) ++option(enable_single_obj_compilation "Compile all libgc source files into single .o" OFF) ++option(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON) ++option(disable_handle_fork "Prohibit installation of pthread_atfork() handlers" OFF) ++option(install_headers "Install header files" ON) ++ ++add_definitions("-DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION") ++ ++# Set struct packing alignment to word (instead of 1-byte). ++if (BORLAND) ++ add_compile_options(/a4) ++elseif (WATCOM) ++ add_compile_options(/zp4) ++endif() ++ ++# Output all warnings. ++if (BORLAND) ++ # All warnings except for particular ones. ++ add_compile_options(/w /w-pro /w-aus /w-par /w-ccc /w-inl /w-rch) ++elseif (MSVC) ++ # All warnings but ignoring "unreferenced formal parameter" and ++ # "conditional expression is constant" ones. ++ add_compile_options(/W4 /wd4100 /wd4127) ++ # Disable crt security warnings, since unfortunately they warn about all ++ # sorts of safe uses of strncpy. ++ add_definitions("-D_CRT_SECURE_NO_DEPRECATE") ++elseif (WATCOM) ++ add_compile_options(/wx) ++else() ++ # TODO add -[W]pedantic -Wno-long-long ++ add_compile_options(-Wall -Wextra) ++endif() ++ ++include_directories(include) ++ ++set(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c + mark_rts.c headers.c mark.c obj_map.c blacklst.c finalize.c + new_hblk.c dbg_mlc.c malloc.c dyn_load.c typd_mlc.c ptr_chck.c + mallocx.c) +-SET(LIBS) +-OPTION(enable_threads "TODO" NO) +-IF(enable_threads) +- FIND_PACKAGE(Threads REQUIRED) +- MESSAGE("Thread Model: ${CMAKE_THREAD_LIBS_INIT}" ) +- INCLUDE_DIRECTORIES(${Threads_INCLUDE_DIR}) +- SET(LIBS ${LIBS} ${Threads_LIBRARIES}) +-ENDIF(enable_threads) +- +-OPTION(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON) +- +-OPTION(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON) +- +-OPTION(enable_parallel_mark "Parallelize marking and free list construction" ON) +- +-#IF(Threads_FOUND) +-# ADD_DEFINITIONS("") +-#ELSE +-# MESSAGE("Parallel mark requires enable_threads ON" ) +-#ENDIF(Threads_FOUND) +- +-#OPTION(enable_cplusplus "install C++ support" ON) +-SET(SRC ${SRC} gc_cpp.cc) +- +-SET(_HOST ${CMAKE_HOST_SYSTEM_PROCESSOR}--${CMAKE_SYSTEM}) #FIXME missing the vendor field. +-STRING(TOLOWER ${_HOST} HOST) +-MESSAGE("HOST = ${HOST}") +- +-# Thread Detection. Relying on cmake for lib and includes. +-#TODO check cmake detection +-IF(CMAKE_USE_PTHREADS_INIT) +- SET(SRC ${SRC} gc_dlopen.c pthread_start.c pthread_stop_world.c +- pthread_support.c) +- # Common defines for most POSIX platforms. +- IF( HOST MATCHES .*-.*-aix.*|.*-.*-android.*|.*-.*-cygwin.*|.*-.*-darwin.*|.*-.*-.*freebsd.*|.*-.*-haiku.*|.*-.*-gnu.*|.*-.*-hpux11.*|.*-.*-irix.*|.*-.*-.*linux.*|.*-.*-msys.*|.*-.*-nacl.*|.*-.*-netbsd.*|.*-.*-openbsd.*|.*-.*-osf.*|.*-.*-solaris.*) +- ADD_DEFINITIONS("-DGC_THREADS -D_REENTRANT") +- IF(enable_parallel_mark) +- ADD_DEFINITIONS("-DPARALLEL_MARK") +- ENDIF(enable_parallel_mark) +- IF(enable_thread_local_alloc) +- ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC") +- SET(SRC ${SRC} specific.c thread_local_alloc.c) +- ENDIF(enable_thread_local_alloc) +- MESSAGE("Explicit GC_INIT() calls may be required.") +- ENDIF() +- IF ( HOST MATCHES .*-.*-hpux11.*) +- MESSAGE("Only HP/UX 11 POSIX threads are supported.") +- ADD_DEFINITIONS("-D_POSIX_C_SOURCE=199506L") #TODO test -DVAR=value. Alternative is COMPILE_DEFINITIONS property +- ENDIF() +- IF ( HOST MATCHES .*-.*-hpux10.*) +- MESSAGE("HP/UX 10 POSIX threads are not supported.") +- ENDIF() +- IF ( HOST MATCHES .*-.*-netbsd.*) +- MESSAGE("Only on NetBSD 2.0 or later.") +- ADD_DEFINITIONS("-D_PTHREADS") +- ENDIF() +- IF( HOST MATCHES .*-.*-android.*) +- # Android NDK does not provide pthread_atfork. +- ELSEIF( HOST MATCHES .*-.*-aix.*|.*-.*-cygwin.*|.*-.*-freebsd.*|.*-.*-haiku.*|.*-.*-hpux11.*|.*-.*-irix.*|.*-.*-kfreebsd.*-gnu|.*-.*-.*linux.*|.*-.*-netbsd.*|.*-.*-openbsd.*|.*-.*-osf.*|.*-.*-solaris.*) +- IF(enable_handle_fork) +- ADD_DEFINITIONS("-DHANDLE_FORK") +- ENDIF(enable_handle_fork) +- ENDIF() +- IF ( HOST MATCHES .*-.*-cygwin.*|.*-.*-msys.*) +- SET(SRC ${SRC} win32_threads.c) +- ENDIF() +- IF ( HOST MATCHES .*-.*-darwin.*) +- IF(enable_handle_fork) +- # The incremental mode conflicts with fork handling. +- IF(enable_parallel_mark) +- ADD_DEFINITIONS("-DHANDLE_FORK") +- ENDIF(enable_parallel_mark) +- ENDIF(enable_handle_fork) +- SET(SRC ${SRC} darwin_stop_world.c) +- #TODO +- #darwin_threads=true +- ENDIF() +-ENDIF(CMAKE_USE_PTHREADS_INIT) +- +-IF(CMAKE_USE_WIN32_THREADS_INIT) +- ADD_DEFINITIONS("-DGC_THREADS") +- IF(enable_parallel_mark) +- ADD_DEFINITIONS("-DPARALLEL_MARK") +- IF(enable_thread_local_alloc) +- ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC") +- SET(SRC ${SRC} thread_local_alloc.c) +- ENDIF(enable_thread_local_alloc) +- ENDIF() +- ADD_DEFINITIONS("-DEMPTY_GETENV_RESULTS") #TODO test +- SET(SRC ${SRC} win32_threads.c) +-ENDIF(CMAKE_USE_WIN32_THREADS_INIT) +- +-OPTION(enable_gcj_support "Support for gcj" ON) +-IF(enable_gcj_support) +- ADD_DEFINITIONS("-DGC_GCJ_SUPPORT") +- IF(enable_threads) +- ADD_DEFINITIONS("-DGC_ENABLE_SUSPEND_THREAD") +- ENDIF(enable_threads) +- SET(SRC ${SRC} gcj_mlc.c) +-ENDIF(enable_gcj_support) +- +-OPTION(enable_disclaim "Support alternative finalization interface" ON) +-IF(enable_disclaim) +- ADD_DEFINITIONS("-DENABLE_DISCLAIM") +- SET(SRC ${SRC} fnlz_mlc.c) +-ENDIF(enable_disclaim) +- +-OPTION(enable_java_finalization "Support for java finalization" ON) +-IF(enable_java_finalization) +- ADD_DEFINITIONS("-DJAVA_FINALIZATION") +-ENDIF(enable_java_finalization) +- +-OPTION(enable_atomic_uncollectable "Support for atomic uncollectible allocation" ON) +-IF(enable_atomic_uncollectable) +- ADD_DEFINITIONS("-DGC_ATOMIC_UNCOLLECTABLE") +-ENDIF(enable_atomic_uncollectable) +- +-OPTION(enable_gc_debug "Support for pointer back-tracing" NO) +-IF(enable_gc_debug) +- ADD_DEFINITIONS("-DDBG_HDRS_ALL -DKEEP_BACK_PTRS") +- IF (HOST MATCHES ia64-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86-.*-linux.*|x86_64-.*-linux.*) +- ADD_DEFINITIONS("-DMAKE_BACK_GRAPH") +- ADD_DEFINITIONS("-DSAVE_CALL_COUNT=8") +- SET(SRC ${SRC} backgraph.c) +- ENDIF() +- IF (HOST MATCHES i.86-.*-dgux.*) +- ADD_DEFINITIONS("-DMAKE_BACK_GRAPH") +- SET(SRC ${SRC} backgraph.c) +- ENDIF() +-ENDIF(enable_gc_debug) +- +-OPTION(enable_redirect_malloc "Redirect malloc and friends to GC routines" NO) +-IF(enable_redirect_malloc) +- IF(enable_gc_debug) +- ADD_DEFINITIONS("-DREDIRECT_MALLOC=GC_debug_malloc_replacement") +- ADD_DEFINITIONS("-DREDIRECT_REALLOC=GC_debug_realloc_replacement") +- ADD_DEFINITIONS("-DREDIRECT_FREE=GC_debug_free") +- ELSE(enable_gc_debug) +- ADD_DEFINITIONS("-DREDIRECT_MALLOC=GC_malloc") +- ENDIF(enable_gc_debug) +- ADD_DEFINITIONS("-DGC_USE_DLOPEN_WRAP") +-ENDIF(enable_redirect_malloc) +- +-OPTION(enable_mmap "Use mmap instead of sbrk to expand the heap" NO) +- +-OPTION(enable_munmap "Return page to the OS if empty for N collections" ON) +-IF(enable_munmap) +- ADD_DEFINITIONS("-DUSE_MMAP -DUSE_MUNMAP") +-ELSEIF(enable_mmap) +- ADD_DEFINITIONS("-DUSE_MMAP") +-ENDIF() +- +-OPTION(enable_dynamic_loading "Enable tracing of dynamic library data roots" ON) +-IF(NOT enable_dynamic_loading) +- ADD_DEFINITIONS("-DIGNORE_DYNAMIC_LOADING") +-ENDIF() +- +-OPTION(enable_register_main_static_data "Perform the initial guess of data root sets" ON) +-IF(NOT enable_register_main_static_data) +- ADD_DEFINITIONS("-DGC_DONT_REGISTER_MAIN_STATIC_DATA") +-ENDIF() +- +-OPTION(enable_large_config "Optimize for large heap or root set" NO) +-IF(enable_large_config) +- ADD_DEFINITIONS("-DLARGE_CONFIG") +-ENDIF(enable_large_config) +- +-OPTION(enable_gc_assertions "Enable collector-internal assertion checking" NO) +-IF(enable_gc_assertions) +- ADD_DEFINITIONS("-DGC_ASSERTIONS") +-ENDIF(enable_gc_assertions) +- +-OPTION(enable_threads_discovery "Enable threads discovery in GC" ON) +-IF(NOT enable_threads_discovery) +- ADD_DEFINITIONS("-DGC_NO_THREADS_DISCOVERY") +-ENDIF() +- +-OPTION(enable_checksums "Report erroneously cleared dirty bits" NO) +-IF(enable_checksums) +- IF(enable_munmap OR enable_threads) +- MESSAGE("CHECKSUMS not compatible with USE_MUNMAP or threads") +- ENDIF() +- ADD_DEFINITIONS("-DCHECKSUMS") +- SET(SRC ${SRC} checksums.c) +-ENDIF(enable_checksums) +- +-ADD_LIBRARY( gc-lib STATIC ${SRC}) +-SET_TARGET_PROPERTIES(gc-lib PROPERTIES +- COMPILE_DEFINITIONS GC_NOT_DLL) +-#TODO TARGET_LINK_LIBRARIES(... ... ${LIBS}) +- +-ADD_LIBRARY( gcmt-dll SHARED ${SRC}) +- +-IF(WIN32) +- ADD_EXECUTABLE(cord cord/cordbscs.c cord/cordxtra.c +- cord/tests/de.c cord/tests/de_win.c) +- SET_TARGET_PROPERTIES(cord PROPERTIES WIN32_EXECUTABLE TRUE) +- SET_TARGET_PROPERTIES(cord PROPERTIES +- COMPILE_DEFINITIONS GC_NOT_DLL) +- TARGET_LINK_LIBRARIES(cord gc-lib) +- TARGET_LINK_LIBRARIES(cord gdi32) +-ENDIF(WIN32) +- +-ADD_SUBDIRECTORY(tests) ++set(THREADDLLIBS) ++ ++set(_HOST ${CMAKE_SYSTEM_PROCESSOR}-unknown-${CMAKE_SYSTEM}) ++string(TOLOWER ${_HOST} HOST) ++message(STATUS "TARGET = ${HOST}") ++ ++if (enable_threads) ++ if(NOT APPLE) ++ find_package(Threads REQUIRED) ++ message(STATUS "Thread library: ${CMAKE_THREAD_LIBS_INIT}") ++ include_directories(${Threads_INCLUDE_DIR}) ++ set(THREADDLLIBS ${CMAKE_THREAD_LIBS_INIT}) ++ endif() ++ if (MSVC) ++ find_package(Atomic_ops CONFIG) ++ if (Atomic_ops_FOUND) ++ get_target_property(AO_INCLUDE_DIRS Atomic_ops::atomic_ops ++ INTERFACE_INCLUDE_DIRECTORIES) ++ include_directories(${AO_INCLUDE_DIRS}) ++ endif() ++ endif() ++ if (NOT (APPLE OR CYGWIN OR MSYS OR WIN32 OR HOST MATCHES mips-.*-irix6.*)) ++ set(THREADDLLIBS ${THREADDLLIBS} -ldl) ++ # The predefined CMAKE_DL_LIBS may be broken. ++ endif() ++endif(enable_threads) ++ ++# Thread support detection. ++if (CMAKE_USE_PTHREADS_INIT) ++ set(SRC ${SRC} gc_dlopen.c pthread_start.c pthread_stop_world.c ++ pthread_support.c) ++ if (HOST MATCHES .*-.*-hpux10.*) ++ message(FATAL_ERROR "HP/UX 10 POSIX threads are not supported.") ++ endif() ++ # Assume the compiler supports GCC atomic intrinsics. ++ add_definitions("-DGC_BUILTIN_ATOMIC") ++ # Common defines for POSIX platforms. ++ add_definitions("-DGC_THREADS -D_REENTRANT") ++ if (enable_parallel_mark) ++ add_definitions("-DPARALLEL_MARK") ++ endif() ++ if (enable_thread_local_alloc) ++ add_definitions("-DTHREAD_LOCAL_ALLOC") ++ set(SRC ${SRC} specific.c thread_local_alloc.c) ++ endif() ++ message("Explicit GC_INIT() calls may be required.") ++ if (HOST MATCHES .*-.*-hpux11.*) ++ message("Only HP/UX 11 POSIX threads are supported.") ++ add_definitions("-D_POSIX_C_SOURCE=199506L") ++ elseif (HOST MATCHES .*-.*-netbsd.*) ++ message("Only on NetBSD 2.0 or later.") ++ add_definitions("-D_PTHREADS") ++ endif() ++ if (ANDROID OR MSYS) # ANDROID variable is defined by CMake v3.7.0+. ++ # Android NDK does not provide pthread_atfork. ++ elseif (APPLE) ++ if (enable_handle_fork AND NOT disable_handle_fork) ++ # The incremental mode conflicts with fork handling. ++ if (enable_parallel_mark) ++ add_definitions("-DHANDLE_FORK") ++ endif(enable_parallel_mark) ++ endif() ++ set(SRC ${SRC} darwin_stop_world.c) ++ elseif (enable_handle_fork AND NOT disable_handle_fork) ++ add_definitions("-DHANDLE_FORK") ++ endif() ++ if (enable_sigrt_signals) ++ add_definitions("-DGC_USESIGRT_SIGNALS") ++ endif() ++ if (CYGWIN OR MSYS) ++ set(SRC ${SRC} win32_threads.c) ++ endif() ++elseif (CMAKE_USE_WIN32_THREADS_INIT) ++ add_definitions("-DGC_THREADS") ++ if (enable_parallel_mark) ++ add_definitions("-DPARALLEL_MARK") ++ endif() ++ if (enable_thread_local_alloc AND (enable_parallel_mark OR NOT BUILD_SHARED_LIBS)) ++ # Imply THREAD_LOCAL_ALLOC unless GC_DLL. ++ add_definitions("-DTHREAD_LOCAL_ALLOC") ++ set(SRC ${SRC} thread_local_alloc.c) ++ endif() ++ add_definitions("-DEMPTY_GETENV_RESULTS") ++ set(SRC ${SRC} win32_threads.c) ++elseif (CMAKE_HP_PTHREADS_INIT OR CMAKE_USE_SPROC_INIT) ++ message(FATAL_ERROR "Unsupported thread package") ++endif() ++ ++if (disable_handle_fork) ++ add_definitions("-DNO_HANDLE_FORK") ++endif() ++ ++if (enable_gcj_support) ++ add_definitions("-DGC_GCJ_SUPPORT") ++ if (enable_threads AND NOT (enable_thread_local_alloc AND HOST MATCHES .*-.*-kfreebsd.*-gnu)) ++ # FIXME: For a reason, gctest hangs up on kFreeBSD if both of ++ # THREAD_LOCAL_ALLOC and GC_ENABLE_SUSPEND_THREAD are defined. ++ add_definitions("-DGC_ENABLE_SUSPEND_THREAD") ++ endif() ++ set(SRC ${SRC} gcj_mlc.c) ++endif(enable_gcj_support) ++ ++if (enable_disclaim) ++ add_definitions("-DENABLE_DISCLAIM") ++ set(SRC ${SRC} fnlz_mlc.c) ++endif() ++ ++if (enable_java_finalization) ++ add_definitions("-DJAVA_FINALIZATION") ++endif() ++ ++if (enable_atomic_uncollectable) ++ add_definitions("-DGC_ATOMIC_UNCOLLECTABLE") ++endif() ++ ++if (enable_gc_debug) ++ add_definitions("-DDBG_HDRS_ALL -DKEEP_BACK_PTRS") ++ if (HOST MATCHES i.86-.*-dgux.*|ia64-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86-.*-linux.*|x86_64-.*-linux.*) ++ add_definitions("-DMAKE_BACK_GRAPH") ++ if (HOST MATCHES .*-.*-.*linux.*) ++ add_definitions("-DSAVE_CALL_COUNT=8") ++ endif() ++ set(SRC ${SRC} backgraph.c) ++ endif() ++endif(enable_gc_debug) ++ ++if (disable_gc_debug) ++ add_definitions("-DNO_DEBUGGING") ++elseif (WINCE) ++ # Read environment variables from ".gc.env" file. ++ add_definitions("-DGC_READ_ENV_FILE") ++endif() ++ ++if (enable_redirect_malloc) ++ if (enable_gc_debug) ++ add_definitions("-DREDIRECT_MALLOC=GC_debug_malloc_replacement") ++ add_definitions("-DREDIRECT_REALLOC=GC_debug_realloc_replacement") ++ add_definitions("-DREDIRECT_FREE=GC_debug_free") ++ else() ++ add_definitions("-DREDIRECT_MALLOC=GC_malloc") ++ endif() ++ add_definitions("-DGC_USE_DLOPEN_WRAP") ++endif(enable_redirect_malloc) ++ ++if (enable_munmap) ++ add_definitions("-DUSE_MMAP -DUSE_MUNMAP") ++elseif (enable_mmap) ++ add_definitions("-DUSE_MMAP") ++endif() ++ ++if (NOT enable_dynamic_loading) ++ add_definitions("-DIGNORE_DYNAMIC_LOADING") ++endif() ++ ++if (NOT enable_register_main_static_data) ++ add_definitions("-DGC_DONT_REGISTER_MAIN_STATIC_DATA") ++endif() ++ ++if (enable_large_config) ++ add_definitions("-DLARGE_CONFIG") ++endif() ++ ++if (enable_gc_assertions) ++ add_definitions("-DGC_ASSERTIONS") ++endif() ++ ++if (NOT enable_threads_discovery) ++ add_definitions("-DGC_NO_THREADS_DISCOVERY") ++endif() ++ ++if (enable_checksums) ++ if (enable_munmap OR enable_threads) ++ message(FATAL_ERROR "CHECKSUMS not compatible with USE_MUNMAP or threads") ++ endif() ++ add_definitions("-DCHECKSUMS") ++ set(SRC ${SRC} checksums.c) ++endif(enable_checksums) ++ ++if (enable_werror) ++ if (BORLAND) ++ add_compile_options(/w!) ++ elseif (MSVC) ++ add_compile_options(/WX) ++ # Workaround "typedef ignored on left of ..." warning reported in ++ # imagehlp.h of e.g. Windows Kit 8.1. ++ add_compile_options(/wd4091) ++ elseif (WATCOM) ++ add_compile_options(/we) ++ else() ++ add_compile_options(-Werror) ++ if (APPLE) ++ # _dyld_bind_fully_image_containing_address is deprecated in OS X 10.5+ ++ add_compile_options(-Wno-deprecated-declarations) ++ endif() ++ endif() ++endif(enable_werror) ++ ++if (enable_single_obj_compilation OR BUILD_SHARED_LIBS) ++ set(SRC extra/gc.c) # override SRC ++ if (CMAKE_USE_PTHREADS_INIT) ++ add_definitions("-DGC_PTHREAD_START_STANDALONE") ++ set(SRC ${SRC} pthread_start.c) ++ endif(CMAKE_USE_PTHREADS_INIT) ++elseif (BORLAND) ++ # Suppress "GC_push_contents_hdr() is declared but never used" warning. ++ add_compile_options(/w-use) ++endif() ++ ++# Add implementation of backtrace() and backtrace_symbols(). ++if (MSVC) ++ set(SRC ${SRC} extra/msvc_dbg.c) ++endif() ++ ++# Instruct check_c_source_compiles and similar CMake checks not to ignore ++# compiler warnings (like "implicit declaration of function"). ++if (NOT BORLAND AND NOT MSVC AND NOT WATCOM) ++ check_c_compiler_flag(-Werror HAVE_FLAG_WERROR) ++ if (HAVE_FLAG_WERROR) ++ SET(CMAKE_REQUIRED_FLAGS "-Werror") ++ endif(HAVE_FLAG_WERROR) ++endif() ++ ++if (BUILD_SHARED_LIBS) ++ add_definitions("-DGC_DLL") ++ # Pass -fvisibility=hidden option if supported. ++ check_c_compiler_flag(-fvisibility=hidden HAVE_FLAG_F_VISIBILITY_HIDDEN) ++ if (HAVE_FLAG_F_VISIBILITY_HIDDEN) ++ add_definitions("-DGC_VISIBILITY_HIDDEN_SET") ++ add_compile_options(-fvisibility=hidden) ++ else() ++ add_definitions("-DGC_NO_VISIBILITY") ++ endif() ++ check_c_compiler_flag(-Wl,--no-undefined HAVE_FLAG_WL_NO_UNDEFINED) ++else() ++ add_definitions("-DGC_NOT_DLL") ++ if (WIN32) ++ # Do not require the clients to link with "user32" system library. ++ add_definitions("-DDONT_USE_USER32_DLL") ++ endif(WIN32) ++endif() ++ ++# Disable strict aliasing optimizations. ++# It could re-enabled back by a flag passed in CFLAGS_EXTRA. ++check_c_compiler_flag(-fno-strict-aliasing HAVE_FLAG_F_NO_STRICT_ALIASING) ++if (HAVE_FLAG_F_NO_STRICT_ALIASING) ++ add_compile_options(-fno-strict-aliasing) ++endif() ++ ++# Extra user-defined flags to pass both to C and C++ compilers. ++if (DEFINED CFLAGS_EXTRA) ++ add_compile_options(${CFLAGS_EXTRA}) ++endif() ++ ++# Check whether execinfo.h header file is present. ++check_include_file(execinfo.h HAVE_EXECINFO_H) ++if (NOT HAVE_EXECINFO_H) ++ add_definitions("-DGC_MISSING_EXECINFO_H") ++endif() ++ ++# Check for getcontext (uClibc can be configured without it, for example). ++check_function_exists(getcontext HAVE_GETCONTEXT) ++if (NOT HAVE_GETCONTEXT) ++ add_definitions("-DNO_GETCONTEXT") ++endif() ++ ++# Check whether dl_iterate_phdr exists (as a strong symbol). ++check_function_exists(dl_iterate_phdr HAVE_DL_ITERATE_PHDR) ++if (HAVE_DL_ITERATE_PHDR) ++ add_definitions("-DHAVE_DL_ITERATE_PHDR") ++endif() ++ ++check_symbol_exists(sigsetjmp setjmp.h HAVE_SIGSETJMP) ++if (NOT HAVE_SIGSETJMP) ++ add_definitions("-DGC_NO_SIGSETJMP") ++endif() ++ ++# pthread_setname_np, if available, may have 1, 2 or 3 arguments. ++if (CMAKE_USE_PTHREADS_INIT) ++ check_c_source_compiles(" ++#include \n ++int main(void) { (void)pthread_setname_np(\"thread-name\"); return 0; }" ++ HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) ++ if (HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) ++ # Define to use 'pthread_setname_np(const char*)' function. ++ add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITHOUT_TID") ++ else() ++ check_c_source_compiles(" ++#include \n ++int main(void) {\n ++ (void)pthread_setname_np(pthread_self(), \"thread-name-%u\", 0); return 0; }" ++ HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG) ++ if (HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG) ++ # Define to use 'pthread_setname_np(pthread_t, const char*, void *)'. ++ add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG") ++ else() ++ check_c_source_compiles(" ++#if defined(__linux__) || defined(__GLIBC__) || defined(__GNU__) || defined(__CYGWIN__)\n ++#define _GNU_SOURCE 1\n ++#endif\n ++#include \n ++int main(void) {\n ++ (void)pthread_setname_np(pthread_self(), \"thread-name\"); return 0; }" ++ HAVE_PTHREAD_SETNAME_NP_WITH_TID) ++ if (HAVE_PTHREAD_SETNAME_NP_WITH_TID) ++ # Define to use 'pthread_setname_np(pthread_t, const char*)' function. ++ add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITH_TID") ++ endif() ++ endif(HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG) ++ endif (HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) ++endif() ++ ++# Check for dladdr (used for debugging). ++check_c_source_compiles(" ++#define _GNU_SOURCE 1\n ++#include \n ++int main(void) { Dl_info info; (void)dladdr(\"\", &info); return 0; }" ++ HAVE_DLADDR) ++if (HAVE_DLADDR) ++ # Define to use 'dladdr' function. ++ add_definitions("-DHAVE_DLADDR") ++endif() ++ ++add_library(gc ${SRC}) ++if (enable_threads) ++ target_link_libraries(gc PRIVATE ${THREADDLLIBS}) ++endif() ++ ++if (enable_cplusplus) ++ add_library(gccpp gc_cpp.cc) ++ target_link_libraries(gccpp PRIVATE gc) ++endif() ++ ++if (build_cord) ++ set(CORD_SRC cord/cordbscs.c cord/cordprnt.c cord/cordxtra.c) ++ add_library(cord ${CORD_SRC}) ++ target_link_libraries(cord PRIVATE gc) ++ install(TARGETS cord EXPORT cordExports ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++ RUNTIME DESTINATION bin ++ INCLUDES DESTINATION include) ++endif() ++ ++if (BUILD_SHARED_LIBS AND HAVE_FLAG_WL_NO_UNDEFINED) ++ # Declare that the libraries do not refer to external symbols. ++ # TODO: use add_link_options() when cmake_minimum_required > 3.13 ++ target_link_libraries(gc PRIVATE -Wl,--no-undefined) ++ if (enable_cplusplus) ++ target_link_libraries(gccpp PRIVATE -Wl,--no-undefined) ++ endif(enable_cplusplus) ++ if (build_cord) ++ target_link_libraries(cord PRIVATE -Wl,--no-undefined) ++ endif(build_cord) ++endif() ++ ++install(TARGETS gc EXPORT gcExports ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++ RUNTIME DESTINATION bin ++ INCLUDES DESTINATION include) ++ ++if (enable_cplusplus) ++ install(TARGETS gccpp EXPORT gccppExports ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++ RUNTIME DESTINATION bin ++ INCLUDES DESTINATION include) ++endif() ++ ++if (install_headers) ++ install(FILES include/gc.h ++ include/gc_backptr.h ++ include/gc_config_macros.h ++ include/gc_gcj.h ++ include/gc_inline.h ++ include/gc_mark.h ++ include/gc_pthread_redirects.h ++ include/gc_tiny_fl.h ++ include/gc_typed.h ++ include/gc_version.h ++ include/javaxfc.h ++ include/leak_detector.h ++ DESTINATION include/gc) ++ install(FILES include/extra/gc.h DESTINATION include) ++ if (enable_cplusplus) ++ install(FILES include/gc_allocator.h ++ include/gc_cpp.h ++ DESTINATION include/gc) ++ install(FILES include/extra/gc_cpp.h DESTINATION include) ++ endif() ++ if (enable_disclaim) ++ install(FILES include/gc_disclaim.h DESTINATION include/gc) ++ endif() ++ if (build_cord) ++ install(FILES include/cord.h ++ include/cord_pos.h ++ include/ec.h ++ DESTINATION include/gc) ++ endif() ++endif(install_headers) ++ ++if (build_tests) ++ if (build_cord) ++ add_executable(cordtest cord/tests/cordtest.c) ++ target_link_libraries(cordtest PRIVATE cord gc) ++ add_test(NAME cordtest COMMAND cordtest) ++ ++ if (WIN32 AND NOT CYGWIN) ++ add_executable(de cord/tests/de.c cord/tests/de_win.c ++ cord/tests/de_win.rc) ++ set_target_properties(de PROPERTIES WIN32_EXECUTABLE TRUE) ++ target_link_libraries(de PRIVATE cord gc gdi32) ++ endif() ++ endif(build_cord) ++ ++ # Compile some tests as C++ to test extern "C" in header files. ++ if (enable_cplusplus) ++ set_source_files_properties(tests/leak_test.c tests/test.c ++ PROPERTIES LANGUAGE CXX) ++ # To avoid "treating 'c' input as 'c++' when in C++ mode" Clang warning. ++ if (NOT (BORLAND OR MSVC OR WATCOM)) ++ add_compile_options(-x c++) ++ endif() ++ endif(enable_cplusplus) ++ ++ add_executable(gctest WIN32 tests/test.c) ++ target_link_libraries(gctest PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME gctest COMMAND gctest) ++ if (WATCOM) ++ # Suppress "conditional expression in if statement is always true/false" ++ # and "unreachable code" warnings in GC_MALLOC_[ATOMIC_]WORDS. ++ target_compile_options(gctest PRIVATE ++ /wcd=13 /wcd=201 /wcd=367 /wcd=368 /wcd=726) ++ endif() ++ ++ add_executable(hugetest tests/huge_test.c) ++ target_link_libraries(hugetest PRIVATE gc) ++ add_test(NAME hugetest COMMAND hugetest) ++ ++ add_executable(leaktest tests/leak_test.c) ++ target_link_libraries(leaktest PRIVATE gc) ++ add_test(NAME leaktest COMMAND leaktest) ++ ++ add_executable(middletest tests/middle.c) ++ target_link_libraries(middletest PRIVATE gc) ++ add_test(NAME middletest COMMAND middletest) ++ ++ add_executable(realloc_test tests/realloc_test.c) ++ target_link_libraries(realloc_test PRIVATE gc) ++ add_test(NAME realloc_test COMMAND realloc_test) ++ ++ add_executable(smashtest tests/smash_test.c) ++ target_link_libraries(smashtest PRIVATE gc) ++ add_test(NAME smashtest COMMAND smashtest) ++ ++ if (NOT (BUILD_SHARED_LIBS AND WIN32)) ++ add_library(staticrootslib_test tests/staticrootslib.c) ++ target_link_libraries(staticrootslib_test PRIVATE gc) ++ add_library(staticrootslib2_test tests/staticrootslib.c) ++ target_compile_options(staticrootslib2_test PRIVATE "-DSTATICROOTSLIB2") ++ target_link_libraries(staticrootslib2_test PRIVATE gc) ++ add_executable(staticrootstest tests/staticrootstest.c) ++ target_compile_options(staticrootstest PRIVATE "-DSTATICROOTSLIB2") ++ target_link_libraries(staticrootstest PRIVATE ++ gc staticrootslib_test staticrootslib2_test) ++ add_test(NAME staticrootstest COMMAND staticrootstest) ++ endif() ++ ++ if (enable_gc_debug) ++ add_executable(tracetest tests/trace_test.c) ++ target_link_libraries(tracetest PRIVATE gc) ++ add_test(NAME tracetest COMMAND tracetest) ++ endif() ++ ++ if (enable_threads) ++ add_executable(test_atomic_ops tests/test_atomic_ops.c) ++ target_link_libraries(test_atomic_ops PRIVATE gc) ++ add_test(NAME test_atomic_ops COMMAND test_atomic_ops) ++ ++ add_executable(threadleaktest tests/thread_leak_test.c) ++ target_link_libraries(threadleaktest PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME threadleaktest COMMAND threadleaktest) ++ ++ if (NOT WIN32) ++ add_executable(threadkey_test tests/threadkey_test.c) ++ target_link_libraries(threadkey_test PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME threadkey_test COMMAND threadkey_test) ++ endif() ++ ++ add_executable(subthreadcreate_test tests/subthread_create.c) ++ target_link_libraries(subthreadcreate_test PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME subthreadcreate_test COMMAND subthreadcreate_test) ++ ++ add_executable(initsecondarythread_test tests/initsecondarythread.c) ++ target_link_libraries(initsecondarythread_test PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME initsecondarythread_test COMMAND initsecondarythread_test) ++ endif(enable_threads) ++ ++ if (enable_cplusplus) ++ add_executable(test_cpp WIN32 tests/test_cpp.cc) ++ target_link_libraries(test_cpp PRIVATE gc gccpp) ++ add_test(NAME test_cpp COMMAND test_cpp) ++ endif() ++ ++ if (enable_disclaim) ++ add_executable(disclaim_bench tests/disclaim_bench.c) ++ target_link_libraries(disclaim_bench PRIVATE gc) ++ add_test(NAME disclaim_bench COMMAND disclaim_bench) ++ ++ add_executable(disclaim_test tests/disclaim_test.c) ++ target_link_libraries(disclaim_test PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME disclaim_test COMMAND disclaim_test) ++ ++ add_executable(disclaim_weakmap_test tests/disclaim_weakmap_test.c) ++ target_link_libraries(disclaim_weakmap_test PRIVATE gc ${THREADDLLIBS}) ++ add_test(NAME disclaim_weakmap_test COMMAND disclaim_weakmap_test) ++ endif() ++endif(build_tests) diff --git a/recipes/bdwgc/all/patches/update-cmake-8_2_2.patch b/recipes/bdwgc/all/patches/update-cmake-8_2_2.patch new file mode 100644 index 0000000000000..3d721c976bf45 --- /dev/null +++ b/recipes/bdwgc/all/patches/update-cmake-8_2_2.patch @@ -0,0 +1,15 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -161,6 +161,12 @@ if (enable_threads) + message(STATUS "Thread library: ${CMAKE_THREAD_LIBS_INIT}") + if (without_libatomic_ops OR BORLAND OR MSVC OR WATCOM) + include_directories(libatomic_ops/src) ++ find_package(Atomic_ops CONFIG) ++ if (Atomic_ops_FOUND) ++ get_target_property(AO_INCLUDE_DIRS Atomic_ops::atomic_ops ++ INTERFACE_INCLUDE_DIRECTORIES) ++ include_directories(${AO_INCLUDE_DIRS}) ++ endif() + # Note: alternatively, use CFLAGS_EXTRA to pass -I<...>/libatomic_ops/src. + else() + # Assume the compiler supports GCC atomic intrinsics. diff --git a/recipes/bdwgc/all/patches/update-cmake.patch b/recipes/bdwgc/all/patches/update-cmake.patch deleted file mode 100644 index 35f75a11f629a..0000000000000 --- a/recipes/bdwgc/all/patches/update-cmake.patch +++ /dev/null @@ -1,834 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -21,241 +21,596 @@ - # this will generate gc.sln - # - --SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required -- --PROJECT(gc) -- --INCLUDE(CTest) -- --CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -- --ADD_DEFINITIONS("-D_CRT_SECURE_NO_DEPRECATE -- -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION") -- --IF(APPLE) -- IF("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") -- SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;x86_64" CACHE STRING "Build architectures for Mac OS X" FORCE) -- ENDIF() --ENDIF(APPLE) -- --#LIBATOMIC #TODO --#ADD_LIBRARY(atomic_ops STATIC ) --#SET_TARGET_PROPERTIES(atomic_ops PROPERTIES COMPILE_FLAGS -DNO_DEBUGGING) -- -- --#LIBGC -- --INCLUDE_DIRECTORIES(include) --INCLUDE_DIRECTORIES(libatomic_ops/src) -- --SET(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c -+cmake_minimum_required(VERSION 3.1) -+ -+option(enable_cplusplus "C++ support" OFF) -+if (enable_cplusplus) -+ project(gc) -+else() -+ project(gc C) -+endif() -+ -+include(CheckCCompilerFlag) -+include(CheckCSourceCompiles) -+include(CheckFunctionExists) -+include(CheckIncludeFile) -+include(CheckSymbolExists) -+include(CTest) -+ -+# Customize the build by passing "-D=ON|OFF" in the command line. -+option(BUILD_SHARED_LIBS "Build shared libraries" ON) -+option(build_cord "Build cord library" ON) -+option(build_tests "Build tests" OFF) -+option(enable_threads "Support threads" ON) -+option(enable_parallel_mark "Parallelize marking and free list construction" ON) -+option(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON) -+option(enable_threads_discovery "Enable threads discovery in GC" ON) -+option(enable_gcj_support "Support for gcj" ON) -+option(enable_sigrt_signals "Use SIGRTMIN-based signals for thread suspend/resume" OFF) -+option(enable_gc_debug "Support for pointer back-tracing" OFF) -+option(disable_gc_debug "Disable debugging like GC_dump and its callees" OFF) -+option(enable_java_finalization "Support for java finalization" ON) -+option(enable_atomic_uncollectable "Support for atomic uncollectible allocation" ON) -+option(enable_redirect_malloc "Redirect malloc and friends to GC routines" OFF) -+option(enable_disclaim "Support alternative finalization interface" ON) -+option(enable_large_config "Optimize for large heap or root set" OFF) -+option(enable_gc_assertions "Enable collector-internal assertion checking" OFF) -+option(enable_mmap "Use mmap instead of sbrk to expand the heap" OFF) -+option(enable_munmap "Return page to the OS if empty for N collections" ON) -+option(enable_dynamic_loading "Enable tracing of dynamic library data roots" ON) -+option(enable_register_main_static_data "Perform the initial guess of data root sets" ON) -+option(enable_checksums "Report erroneously cleared dirty bits" OFF) -+option(enable_werror "Pass -Werror to the C compiler (treat warnings as errors)" OFF) -+option(enable_single_obj_compilation "Compile all libgc source files into single .o" OFF) -+option(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON) -+option(disable_handle_fork "Prohibit installation of pthread_atfork() handlers" OFF) -+option(install_headers "Install header files" ON) -+ -+add_definitions("-DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION") -+ -+if (APPLE AND ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")) -+ set(CMAKE_OSX_ARCHITECTURES "x86_64;i386" -+ CACHE STRING "Build architectures for Mac OS X" FORCE) -+endif() -+ -+# Set struct packing alignment to word (instead of 1-byte). -+if (BORLAND) -+ add_compile_options(/a4) -+elseif (WATCOM) -+ add_compile_options(/zp4) -+endif() -+ -+# Output all warnings. -+if (BORLAND) -+ # All warnings except for particular ones. -+ add_compile_options(/w /w-pro /w-aus /w-par /w-ccc /w-inl /w-rch) -+elseif (MSVC) -+ # All warnings but ignoring "unreferenced formal parameter" and -+ # "conditional expression is constant" ones. -+ add_compile_options(/W4 /wd4100 /wd4127) -+ # Disable crt security warnings, since unfortunately they warn about all -+ # sorts of safe uses of strncpy. -+ add_definitions("-D_CRT_SECURE_NO_DEPRECATE") -+elseif (WATCOM) -+ add_compile_options(/wx) -+else() -+ # TODO add -[W]pedantic -Wno-long-long -+ add_compile_options(-Wall -Wextra) -+endif() -+ -+include_directories(include) -+ -+set(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c - mark_rts.c headers.c mark.c obj_map.c blacklst.c finalize.c - new_hblk.c dbg_mlc.c malloc.c dyn_load.c typd_mlc.c ptr_chck.c - mallocx.c) --SET(LIBS) --OPTION(enable_threads "TODO" NO) --IF(enable_threads) -- FIND_PACKAGE(Threads REQUIRED) -- MESSAGE("Thread Model: ${CMAKE_THREAD_LIBS_INIT}" ) -- INCLUDE_DIRECTORIES(${Threads_INCLUDE_DIR}) -- SET(LIBS ${LIBS} ${Threads_LIBRARIES}) --ENDIF(enable_threads) -- --OPTION(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON) -- --OPTION(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON) -- --OPTION(enable_parallel_mark "Parallelize marking and free list construction" ON) -- --#IF(Threads_FOUND) --# ADD_DEFINITIONS("") --#ELSE --# MESSAGE("Parallel mark requires enable_threads ON" ) --#ENDIF(Threads_FOUND) -- --#OPTION(enable_cplusplus "install C++ support" ON) --SET(SRC ${SRC} gc_cpp.cc) -- --SET(_HOST ${CMAKE_HOST_SYSTEM_PROCESSOR}--${CMAKE_SYSTEM}) #FIXME missing the vendor field. --STRING(TOLOWER ${_HOST} HOST) --MESSAGE("HOST = ${HOST}") -- --# Thread Detection. Relying on cmake for lib and includes. --#TODO check cmake detection --IF(CMAKE_USE_PTHREADS_INIT) -- SET(SRC ${SRC} pthread_start.c pthread_support.c pthread_stop_world.c) -- # Common defines for most POSIX platforms. -- IF( HOST MATCHES .*-.*-aix.*|.*-.*-android.*|.*-.*-cygwin.*|.*-.*-darwin.*|.*-.*-.*freebsd.*|.*-.*-haiku.*|.*-.*-gnu.*|.*-.*-hpux11.*|.*-.*-irix.*|.*-.*-.*linux.*|.*-.*-nacl.*|.*-.*-netbsd.*|.*-.*-openbsd.*|.*-.*-osf.*|.*-.*-solaris.*) -- ADD_DEFINITIONS("-DGC_THREADS -D_REENTRANT") -- IF(enable_parallel_mark) -- ADD_DEFINITIONS("-DPARALLEL_MARK") -- ENDIF(enable_parallel_mark) -- IF(enable_thread_local_alloc) -- ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC") -- SET(SRC ${SRC} thread_local_alloc.c) -- ENDIF(enable_thread_local_alloc) -- MESSAGE("Explicit GC_INIT() calls may be required.") -- ENDIF() -- IF ( HOST MATCHES .*-.*-hpux11.*) -- MESSAGE("Only HP/UX 11 POSIX threads are supported.") -- ADD_DEFINITIONS("-D_POSIX_C_SOURCE=199506L") #TODO test -DVAR=value. Alternative is COMPILE_DEFINITIONS property -- ENDIF() -- IF ( HOST MATCHES .*-.*-hpux10.*) -- MESSAGE("HP/UX 10 POSIX threads are not supported.") -- ENDIF() -- IF ( HOST MATCHES .*-.*-netbsd.*) -- MESSAGE("Only on NetBSD 2.0 or later.") -- ADD_DEFINITIONS("-D_PTHREADS") -- ENDIF() -- IF( HOST MATCHES .*-.*-android.*) -- # Android NDK does not provide pthread_atfork. -- ELSEIF( HOST MATCHES .*-.*-aix.*|.*-.*-cygwin.*|.*-.*-freebsd.*|.*-.*-haiku.*|.*-.*-hpux11.*|.*-.*-irix.*|.*-.*-kfreebsd.*-gnu|.*-.*-.*linux.*|.*-.*-netbsd.*|.*-.*-openbsd.*|.*-.*-osf.*|.*-.*-solaris.*) -- IF(enable_handle_fork) -- ADD_DEFINITIONS("-DHANDLE_FORK") -- ENDIF(enable_handle_fork) -- ENDIF() -- IF ( HOST MATCHES .*-.*-cygwin.*) -- SET(SRC ${SRC} win32_threads.c) -- ENDIF() -- IF ( HOST MATCHES .*-.*-darwin.*) -- IF(enable_handle_fork) -- # The incremental mode conflicts with fork handling. -- IF(enable_parallel_mark) -- ADD_DEFINITIONS("-DHANDLE_FORK") -- ENDIF(enable_parallel_mark) -- ENDIF(enable_handle_fork) -- SET(SRC ${SRC} darwin_stop_world.c) -- #TODO -- #darwin_threads=true -- ENDIF() --ENDIF(CMAKE_USE_PTHREADS_INIT) -- --IF(CMAKE_USE_WIN32_THREADS_INIT) -- ADD_DEFINITIONS("-DGC_THREADS") -- IF(enable_parallel_mark) -- ADD_DEFINITIONS("-DPARALLEL_MARK") -- IF(enable_thread_local_alloc) -- ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC") -- SET(SRC ${SRC} thread_local_alloc.c) -- ENDIF(enable_thread_local_alloc) -- ENDIF() -- ADD_DEFINITIONS("-DEMPTY_GETENV_RESULTS") #TODO test -- SET(SRC ${SRC} win32_threads.c) --ENDIF(CMAKE_USE_WIN32_THREADS_INIT) -- --OPTION(enable_gcj_support "Support for gcj" ON) --IF(enable_gcj_support) -- ADD_DEFINITIONS("-DGC_GCJ_SUPPORT") -- IF(enable_threads) -- ADD_DEFINITIONS("-DGC_ENABLE_SUSPEND_THREAD") -- ENDIF(enable_threads) -- SET(SRC ${SRC} gcj_mlc.c) --ENDIF(enable_gcj_support) -- --OPTION(enable_disclaim "Support alternative finalization interface" ON) --IF(enable_disclaim) -- ADD_DEFINITIONS("-DENABLE_DISCLAIM") -- SET(SRC ${SRC} fnlz_mlc.c) --ENDIF(enable_disclaim) -- --OPTION(enable_java_finalization "Support for java finalization" ON) --IF(enable_java_finalization) -- ADD_DEFINITIONS("-DJAVA_FINALIZATION") --ENDIF(enable_java_finalization) -- --OPTION(enable_atomic_uncollectable "Support for atomic uncollectible allocation" ON) --IF(enable_atomic_uncollectable) -- ADD_DEFINITIONS("-DGC_ATOMIC_UNCOLLECTABLE") --ENDIF(enable_atomic_uncollectable) -- --OPTION(enable_gc_debug "Support for pointer back-tracing" NO) --IF(enable_gc_debug) -- ADD_DEFINITIONS("-DDBG_HDRS_ALL -DKEEP_BACK_PTRS") -- IF (HOST MATCHES ia64-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86-.*-linux.*|x86_64-.*-linux.*) -- ADD_DEFINITIONS("-DMAKE_BACK_GRAPH") -- ADD_DEFINITIONS("-DSAVE_CALL_COUNT=8") -- SET(SRC ${SRC} backgraph.c) -- ENDIF() -- IF (HOST MATCHES i.86-.*-dgux.*) -- ADD_DEFINITIONS("-DMAKE_BACK_GRAPH") -- SET(SRC ${SRC} backgraph.c) -- ENDIF() --ENDIF(enable_gc_debug) -- --OPTION(enable_redirect_malloc "Redirect malloc and friends to GC routines" NO) --IF(enable_redirect_malloc) -- IF(enable_gc_debug) -- ADD_DEFINITIONS("-DREDIRECT_MALLOC=GC_debug_malloc_replacement") -- ADD_DEFINITIONS("-DREDIRECT_REALLOC=GC_debug_realloc_replacement") -- ADD_DEFINITIONS("-DREDIRECT_FREE=GC_debug_free") -- ELSE(enable_gc_debug) -- ADD_DEFINITIONS("-DREDIRECT_MALLOC=GC_malloc") -- ENDIF(enable_gc_debug) -- ADD_DEFINITIONS("-DGC_USE_DLOPEN_WRAP") --ENDIF(enable_redirect_malloc) -- --OPTION(enable_mmap "Use mmap instead of sbrk to expand the heap" NO) -- --OPTION(enable_munmap "Return page to the OS if empty for N collections" ON) --IF(enable_munmap) -- ADD_DEFINITIONS("-DUSE_MMAP -DUSE_MUNMAP") --ELSEIF(enable_mmap) -- ADD_DEFINITIONS("-DUSE_MMAP") --ENDIF() -- --OPTION(enable_dynamic_loading "Enable tracing of dynamic library data roots" ON) --IF(NOT enable_dynamic_loading) -- ADD_DEFINITIONS("-DIGNORE_DYNAMIC_LOADING") --ENDIF() -- --OPTION(enable_register_main_static_data "Perform the initial guess of data root sets" ON) --IF(NOT enable_register_main_static_data) -- ADD_DEFINITIONS("-DGC_DONT_REGISTER_MAIN_STATIC_DATA") --ENDIF() -- --OPTION(enable_large_config "Optimize for large heap or root set" NO) --IF(enable_large_config) -- ADD_DEFINITIONS("-DLARGE_CONFIG") --ENDIF(enable_large_config) -- --OPTION(enable_gc_assertions "Enable collector-internal assertion checking" NO) --IF(enable_gc_assertions) -- ADD_DEFINITIONS("-DGC_ASSERTIONS") --ENDIF(enable_gc_assertions) -- --OPTION(enable_threads_discovery "Enable threads discovery in GC" ON) --IF(NOT enable_threads_discovery) -- ADD_DEFINITIONS("-DGC_NO_THREADS_DISCOVERY") --ENDIF() -- --OPTION(enable_checksums "Report erroneously cleared dirty bits" NO) --IF(enable_checksums) -- IF(enable_munmap OR enable_threads) -- MESSAGE("CHECKSUMS not compatible with USE_MUNMAP or threads") -- ENDIF() -- ADD_DEFINITIONS("-DCHECKSUMS") -- SET(SRC ${SRC} checksums.c) --ENDIF(enable_checksums) -- --ADD_LIBRARY( gc-lib STATIC ${SRC}) --SET_TARGET_PROPERTIES(gc-lib PROPERTIES -- COMPILE_DEFINITIONS GC_NOT_DLL) --#TODO TARGET_LINK_LIBRARIES(... ... ${LIBS}) -- --ADD_LIBRARY( gcmt-lib STATIC ${SRC}) --SET_TARGET_PROPERTIES(gcmt-lib PROPERTIES -- COMPILE_DEFINITIONS GC_NOT_DLL) -- --ADD_LIBRARY( gcmt-dll SHARED ${SRC}) -- --IF(WIN32) -- ADD_EXECUTABLE(cord cord/cordbscs.c cord/cordxtra.c -- cord/tests/de.c cord/tests/de_win.c) -- SET_TARGET_PROPERTIES(cord PROPERTIES WIN32_EXECUTABLE TRUE) -- SET_TARGET_PROPERTIES(cord PROPERTIES -- COMPILE_DEFINITIONS GC_NOT_DLL) -- TARGET_LINK_LIBRARIES(cord gc-lib) -- TARGET_LINK_LIBRARIES(cord gdi32) --ENDIF(WIN32) -- --ADD_SUBDIRECTORY(tests) -+set(THREADDLLIBS) -+ -+set(_HOST ${CMAKE_SYSTEM_PROCESSOR}-unknown-${CMAKE_SYSTEM}) -+string(TOLOWER ${_HOST} HOST) -+message(STATUS "TARGET = ${HOST}") -+ -+if (enable_threads) -+ if(NOT APPLE) -+ find_package(Threads REQUIRED) -+ message(STATUS "Thread library: ${CMAKE_THREAD_LIBS_INIT}") -+ include_directories(${Threads_INCLUDE_DIR}) -+ set(THREADDLLIBS ${CMAKE_THREAD_LIBS_INIT}) -+ endif() -+ include_directories(libatomic_ops/src) -+ if (NOT (APPLE OR CYGWIN OR MSYS OR WIN32 OR HOST MATCHES mips-.*-irix6.*)) -+ set(THREADDLLIBS ${THREADDLLIBS} -ldl) -+ # The predefined CMAKE_DL_LIBS may be broken. -+ endif() -+endif(enable_threads) -+ -+# Thread support detection. -+if (CMAKE_USE_PTHREADS_INIT) -+ set(SRC ${SRC} pthread_start.c pthread_support.c pthread_stop_world.c) -+ if (HOST MATCHES .*-.*-hpux10.*) -+ message(FATAL_ERROR "HP/UX 10 POSIX threads are not supported.") -+ endif() -+ # Assume the compiler supports C11 (GCC) atomic intrinsics. -+ add_definitions("-DGC_BUILTIN_ATOMIC") -+ # Common defines for POSIX platforms. -+ add_definitions("-DGC_THREADS -D_REENTRANT") -+ if (enable_parallel_mark) -+ add_definitions("-DPARALLEL_MARK") -+ endif() -+ if (enable_thread_local_alloc) -+ add_definitions("-DTHREAD_LOCAL_ALLOC") -+ set(SRC ${SRC} thread_local_alloc.c) -+ endif() -+ message("Explicit GC_INIT() calls may be required.") -+ if (HOST MATCHES .*-.*-hpux11.*) -+ message("Only HP/UX 11 POSIX threads are supported.") -+ add_definitions("-D_POSIX_C_SOURCE=199506L") -+ elseif (HOST MATCHES .*-.*-netbsd.*) -+ message("Only on NetBSD 2.0 or later.") -+ add_definitions("-D_PTHREADS") -+ endif() -+ if (ANDROID OR MSYS) # ANDROID variable is defined by CMake v3.7.0+. -+ # Android NDK does not provide pthread_atfork. -+ elseif (APPLE) -+ if (enable_handle_fork AND NOT disable_handle_fork) -+ # The incremental mode conflicts with fork handling. -+ if (enable_parallel_mark) -+ add_definitions("-DHANDLE_FORK") -+ endif(enable_parallel_mark) -+ endif() -+ set(SRC ${SRC} darwin_stop_world.c) -+ elseif (enable_handle_fork AND NOT disable_handle_fork) -+ add_definitions("-DHANDLE_FORK") -+ endif() -+ if (enable_sigrt_signals) -+ add_definitions("-DGC_USESIGRT_SIGNALS") -+ endif() -+ if (CYGWIN OR MSYS) -+ set(SRC ${SRC} win32_threads.c) -+ endif() -+elseif (CMAKE_USE_WIN32_THREADS_INIT) -+ add_definitions("-DGC_THREADS") -+ if (enable_parallel_mark) -+ add_definitions("-DPARALLEL_MARK") -+ endif() -+ if (enable_thread_local_alloc AND (enable_parallel_mark OR NOT BUILD_SHARED_LIBS)) -+ # Imply THREAD_LOCAL_ALLOC unless GC_DLL. -+ add_definitions("-DTHREAD_LOCAL_ALLOC") -+ set(SRC ${SRC} thread_local_alloc.c) -+ endif() -+ add_definitions("-DEMPTY_GETENV_RESULTS") -+ set(SRC ${SRC} win32_threads.c) -+elseif (CMAKE_HP_PTHREADS_INIT OR CMAKE_USE_SPROC_INIT) -+ message(FATAL_ERROR "Unsupported thread package") -+endif() -+ -+if (disable_handle_fork) -+ add_definitions("-DNO_HANDLE_FORK") -+endif() -+ -+if (enable_gcj_support) -+ add_definitions("-DGC_GCJ_SUPPORT") -+ if (enable_threads AND NOT (enable_thread_local_alloc AND HOST MATCHES .*-.*-kfreebsd.*-gnu)) -+ # FIXME: For a reason, gctest hangs up on kFreeBSD if both of -+ # THREAD_LOCAL_ALLOC and GC_ENABLE_SUSPEND_THREAD are defined. -+ add_definitions("-DGC_ENABLE_SUSPEND_THREAD") -+ endif() -+ set(SRC ${SRC} gcj_mlc.c) -+endif(enable_gcj_support) -+ -+if (enable_disclaim) -+ add_definitions("-DENABLE_DISCLAIM") -+ set(SRC ${SRC} fnlz_mlc.c) -+endif() -+ -+if (enable_java_finalization) -+ add_definitions("-DJAVA_FINALIZATION") -+endif() -+ -+if (enable_atomic_uncollectable) -+ add_definitions("-DGC_ATOMIC_UNCOLLECTABLE") -+endif() -+ -+if (enable_gc_debug) -+ add_definitions("-DDBG_HDRS_ALL -DKEEP_BACK_PTRS") -+ if (HOST MATCHES i.86-.*-dgux.*|ia64-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86-.*-linux.*|x86_64-.*-linux.*) -+ add_definitions("-DMAKE_BACK_GRAPH") -+ if (HOST MATCHES .*-.*-.*linux.*) -+ add_definitions("-DSAVE_CALL_COUNT=8") -+ endif() -+ set(SRC ${SRC} backgraph.c) -+ endif() -+endif(enable_gc_debug) -+ -+if (disable_gc_debug) -+ add_definitions("-DNO_DEBUGGING") -+elseif (WINCE) -+ # Read environment variables from ".gc.env" file. -+ add_definitions("-DGC_READ_ENV_FILE") -+endif() -+ -+if (enable_redirect_malloc) -+ if (enable_gc_debug) -+ add_definitions("-DREDIRECT_MALLOC=GC_debug_malloc_replacement") -+ add_definitions("-DREDIRECT_REALLOC=GC_debug_realloc_replacement") -+ add_definitions("-DREDIRECT_FREE=GC_debug_free") -+ else() -+ add_definitions("-DREDIRECT_MALLOC=GC_malloc") -+ endif() -+ add_definitions("-DGC_USE_DLOPEN_WRAP") -+endif(enable_redirect_malloc) -+ -+if (enable_munmap) -+ add_definitions("-DUSE_MMAP -DUSE_MUNMAP") -+elseif (enable_mmap) -+ add_definitions("-DUSE_MMAP") -+endif() -+ -+if (NOT enable_dynamic_loading) -+ add_definitions("-DIGNORE_DYNAMIC_LOADING") -+endif() -+ -+if (NOT enable_register_main_static_data) -+ add_definitions("-DGC_DONT_REGISTER_MAIN_STATIC_DATA") -+endif() -+ -+if (enable_large_config) -+ add_definitions("-DLARGE_CONFIG") -+endif() -+ -+if (enable_gc_assertions) -+ add_definitions("-DGC_ASSERTIONS") -+endif() -+ -+if (NOT enable_threads_discovery) -+ add_definitions("-DGC_NO_THREADS_DISCOVERY") -+endif() -+ -+if (enable_checksums) -+ if (enable_munmap OR enable_threads) -+ message(FATAL_ERROR "CHECKSUMS not compatible with USE_MUNMAP or threads") -+ endif() -+ add_definitions("-DCHECKSUMS") -+ set(SRC ${SRC} checksums.c) -+endif(enable_checksums) -+ -+if (enable_werror) -+ if (BORLAND) -+ add_compile_options(/w!) -+ elseif (MSVC) -+ add_compile_options(/WX) -+ # Workaround "typedef ignored on left of ..." warning reported in -+ # imagehlp.h of e.g. Windows Kit 8.1. -+ add_compile_options(/wd4091) -+ elseif (WATCOM) -+ add_compile_options(/we) -+ else() -+ add_compile_options(-Werror) -+ if (APPLE) -+ # _dyld_bind_fully_image_containing_address is deprecated in OS X 10.5+ -+ add_compile_options(-Wno-deprecated-declarations) -+ endif() -+ endif() -+endif(enable_werror) -+ -+if (enable_single_obj_compilation OR BUILD_SHARED_LIBS) -+ set(SRC extra/gc.c) # override SRC -+ if (CMAKE_USE_PTHREADS_INIT) -+ add_definitions("-DGC_PTHREAD_START_STANDALONE") -+ set(SRC ${SRC} pthread_start.c) -+ endif(CMAKE_USE_PTHREADS_INIT) -+elseif (BORLAND) -+ # Suppress "GC_push_contents_hdr() is declared but never used" warning. -+ add_compile_options(/w-use) -+endif() -+ -+# Add implementation of backtrace() and backtrace_symbols(). -+if (MSVC) -+ set(SRC ${SRC} extra/msvc_dbg.c) -+endif() -+ -+# Instruct check_c_source_compiles and similar CMake checks not to ignore -+# compiler warnings (like "implicit declaration of function"). -+if (NOT BORLAND AND NOT MSVC AND NOT WATCOM) -+ check_c_compiler_flag(-Werror HAVE_FLAG_WERROR) -+ if (HAVE_FLAG_WERROR) -+ SET(CMAKE_REQUIRED_FLAGS "-Werror") -+ endif(HAVE_FLAG_WERROR) -+endif() -+ -+if (BUILD_SHARED_LIBS) -+ add_definitions("-DGC_DLL") -+ # Pass -fvisibility=hidden option if supported. -+ check_c_compiler_flag(-fvisibility=hidden HAVE_FLAG_F_VISIBILITY_HIDDEN) -+ if (HAVE_FLAG_F_VISIBILITY_HIDDEN) -+ add_definitions("-DGC_VISIBILITY_HIDDEN_SET") -+ add_compile_options(-fvisibility=hidden) -+ else() -+ add_definitions("-DGC_NO_VISIBILITY") -+ endif() -+ check_c_compiler_flag(-Wl,--no-undefined HAVE_FLAG_WL_NO_UNDEFINED) -+else() -+ add_definitions("-DGC_NOT_DLL") -+ if (WIN32) -+ # Do not require the clients to link with "user32" system library. -+ add_definitions("-DDONT_USE_USER32_DLL") -+ endif(WIN32) -+endif() -+ -+# Disable strict aliasing optimizations. -+# It could re-enabled back by a flag passed in CFLAGS_EXTRA. -+check_c_compiler_flag(-fno-strict-aliasing HAVE_FLAG_F_NO_STRICT_ALIASING) -+if (HAVE_FLAG_F_NO_STRICT_ALIASING) -+ add_compile_options(-fno-strict-aliasing) -+endif() -+ -+# Extra user-defined flags to pass both to C and C++ compilers. -+if (DEFINED CFLAGS_EXTRA) -+ add_compile_options(${CFLAGS_EXTRA}) -+endif() -+ -+# Check whether execinfo.h header file is present. -+check_include_file(execinfo.h HAVE_EXECINFO_H) -+if (NOT HAVE_EXECINFO_H) -+ add_definitions("-DGC_MISSING_EXECINFO_H") -+endif() -+ -+# Check for getcontext (uClibc can be configured without it, for example). -+check_function_exists(getcontext HAVE_GETCONTEXT) -+if (NOT HAVE_GETCONTEXT) -+ add_definitions("-DNO_GETCONTEXT") -+endif() -+ -+# Check whether dl_iterate_phdr exists (as a strong symbol). -+check_function_exists(dl_iterate_phdr HAVE_DL_ITERATE_PHDR) -+if (HAVE_DL_ITERATE_PHDR) -+ add_definitions("-DHAVE_DL_ITERATE_PHDR") -+endif() -+ -+check_symbol_exists(sigsetjmp setjmp.h HAVE_SIGSETJMP) -+if (NOT HAVE_SIGSETJMP) -+ add_definitions("-DGC_NO_SIGSETJMP") -+endif() -+ -+# pthread_setname_np, if available, may have 1, 2 or 3 arguments. -+if (CMAKE_USE_PTHREADS_INIT) -+ check_c_source_compiles(" -+#include \n -+int main(void) { (void)pthread_setname_np(\"thread-name\"); return 0; }" -+ HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) -+ if (HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) -+ # Define to use 'pthread_setname_np(const char*)' function. -+ add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITHOUT_TID") -+ else() -+ check_c_source_compiles(" -+#include \n -+int main(void) {\n -+ (void)pthread_setname_np(pthread_self(), \"thread-name-%u\", 0); return 0; }" -+ HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG) -+ if (HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG) -+ # Define to use 'pthread_setname_np(pthread_t, const char*, void *)'. -+ add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG") -+ else() -+ check_c_source_compiles(" -+#if defined(__linux__) || defined(__GLIBC__) || defined(__GNU__) || defined(__CYGWIN__)\n -+#define _GNU_SOURCE 1\n -+#endif\n -+#include \n -+int main(void) {\n -+ (void)pthread_setname_np(pthread_self(), \"thread-name\"); return 0; }" -+ HAVE_PTHREAD_SETNAME_NP_WITH_TID) -+ if (HAVE_PTHREAD_SETNAME_NP_WITH_TID) -+ # Define to use 'pthread_setname_np(pthread_t, const char*)' function. -+ add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITH_TID") -+ endif() -+ endif(HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG) -+ endif (HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) -+endif() -+ -+# Check for dladdr (used for debugging). -+check_c_source_compiles(" -+#define _GNU_SOURCE 1\n -+#include \n -+int main(void) { Dl_info info; (void)dladdr(\"\", &info); return 0; }" -+ HAVE_DLADDR) -+if (HAVE_DLADDR) -+ # Define to use 'dladdr' function. -+ add_definitions("-DHAVE_DLADDR") -+endif() -+ -+add_library(gc ${SRC}) -+if (enable_threads) -+ target_link_libraries(gc PRIVATE ${THREADDLLIBS}) -+endif() -+ -+if (enable_cplusplus) -+ add_library(gccpp gc_cpp.cc) -+ target_link_libraries(gccpp PRIVATE gc) -+endif() -+ -+if (build_cord) -+ set(CORD_SRC cord/cordbscs.c cord/cordprnt.c cord/cordxtra.c) -+ add_library(cord ${CORD_SRC}) -+ target_link_libraries(cord PRIVATE gc) -+ install(TARGETS cord EXPORT cordExports -+ LIBRARY DESTINATION lib -+ ARCHIVE DESTINATION lib -+ RUNTIME DESTINATION bin -+ INCLUDES DESTINATION include) -+endif() -+ -+if (BUILD_SHARED_LIBS AND HAVE_FLAG_WL_NO_UNDEFINED) -+ # Declare that the libraries do not refer to external symbols. -+ # TODO: use add_link_options() when cmake_minimum_required > 3.13 -+ target_link_libraries(gc PRIVATE -Wl,--no-undefined) -+ if (enable_cplusplus) -+ target_link_libraries(gccpp PRIVATE -Wl,--no-undefined) -+ endif(enable_cplusplus) -+ if (build_cord) -+ target_link_libraries(cord PRIVATE -Wl,--no-undefined) -+ endif(build_cord) -+endif() -+ -+install(TARGETS gc EXPORT gcExports -+ LIBRARY DESTINATION lib -+ ARCHIVE DESTINATION lib -+ RUNTIME DESTINATION bin -+ INCLUDES DESTINATION include) -+ -+if (enable_cplusplus) -+ install(TARGETS gccpp EXPORT gccppExports -+ LIBRARY DESTINATION lib -+ ARCHIVE DESTINATION lib -+ RUNTIME DESTINATION bin -+ INCLUDES DESTINATION include) -+endif() -+ -+if (install_headers) -+ install(FILES include/gc.h -+ include/gc_backptr.h -+ include/gc_config_macros.h -+ include/gc_gcj.h -+ include/gc_inline.h -+ include/gc_mark.h -+ include/gc_pthread_redirects.h -+ include/gc_tiny_fl.h -+ include/gc_typed.h -+ include/gc_version.h -+ include/javaxfc.h -+ include/leak_detector.h -+ DESTINATION include/gc) -+ install(FILES include/extra/gc.h DESTINATION include) -+ if (enable_cplusplus) -+ install(FILES include/gc_allocator.h -+ include/gc_cpp.h -+ DESTINATION include/gc) -+ install(FILES include/extra/gc_cpp.h DESTINATION include) -+ endif() -+ if (enable_disclaim) -+ install(FILES include/gc_disclaim.h DESTINATION include/gc) -+ endif() -+ if (build_cord) -+ install(FILES include/cord.h -+ include/cord_pos.h -+ include/ec.h -+ DESTINATION include/gc) -+ endif() -+endif(install_headers) -+ -+if (build_tests) -+ if (build_cord) -+ add_executable(cordtest cord/tests/cordtest.c) -+ target_link_libraries(cordtest PRIVATE cord gc) -+ add_test(NAME cordtest COMMAND cordtest) -+ -+ if (WIN32 AND NOT CYGWIN) -+ add_executable(de cord/tests/de.c cord/tests/de_win.c -+ cord/tests/de_win.rc) -+ set_target_properties(de PROPERTIES WIN32_EXECUTABLE TRUE) -+ target_link_libraries(de PRIVATE cord gc gdi32) -+ endif() -+ endif(build_cord) -+ -+ # Compile some tests as C++ to test extern "C" in header files. -+ if (enable_cplusplus) -+ set_source_files_properties(tests/leak_test.c tests/test.c -+ PROPERTIES LANGUAGE CXX) -+ # To avoid "treating 'c' input as 'c++' when in C++ mode" Clang warning. -+ if (NOT (BORLAND OR MSVC OR WATCOM)) -+ add_compile_options(-x c++) -+ endif() -+ endif(enable_cplusplus) -+ -+ add_executable(gctest WIN32 tests/test.c) -+ target_link_libraries(gctest PRIVATE gc ${THREADDLLIBS}) -+ add_test(NAME gctest COMMAND gctest) -+ if (WATCOM) -+ # Suppress "conditional expression in if statement is always true/false" -+ # and "unreachable code" warnings in GC_MALLOC_[ATOMIC_]WORDS. -+ target_compile_options(gctest PRIVATE -+ /wcd=13 /wcd=201 /wcd=367 /wcd=368 /wcd=726) -+ endif() -+ -+ add_executable(hugetest tests/huge_test.c) -+ target_link_libraries(hugetest PRIVATE gc) -+ add_test(NAME hugetest COMMAND hugetest) -+ -+ add_executable(leaktest tests/leak_test.c) -+ target_link_libraries(leaktest PRIVATE gc) -+ add_test(NAME leaktest COMMAND leaktest) -+ -+ add_executable(middletest tests/middle.c) -+ target_link_libraries(middletest PRIVATE gc) -+ add_test(NAME middletest COMMAND middletest) -+ -+ add_executable(realloc_test tests/realloc_test.c) -+ target_link_libraries(realloc_test PRIVATE gc) -+ add_test(NAME realloc_test COMMAND realloc_test) -+ -+ add_executable(smashtest tests/smash_test.c) -+ target_link_libraries(smashtest PRIVATE gc) -+ add_test(NAME smashtest COMMAND smashtest) -+ -+ if (NOT (BUILD_SHARED_LIBS AND WIN32)) -+ add_library(staticrootslib_test tests/staticrootslib.c) -+ target_link_libraries(staticrootslib_test PRIVATE gc) -+ add_library(staticrootslib2_test tests/staticrootslib.c) -+ target_compile_options(staticrootslib2_test PRIVATE "-DSTATICROOTSLIB2") -+ target_link_libraries(staticrootslib2_test PRIVATE gc) -+ add_executable(staticrootstest tests/staticrootstest.c) -+ target_compile_options(staticrootstest PRIVATE "-DSTATICROOTSLIB2") -+ target_link_libraries(staticrootstest PRIVATE -+ gc staticrootslib_test staticrootslib2_test) -+ add_test(NAME staticrootstest COMMAND staticrootstest) -+ endif() -+ -+ if (enable_gc_debug) -+ add_executable(tracetest tests/trace_test.c) -+ target_link_libraries(tracetest PRIVATE gc) -+ add_test(NAME tracetest COMMAND tracetest) -+ endif() -+ -+ if (enable_threads) -+ add_executable(test_atomic_ops tests/test_atomic_ops.c) -+ target_link_libraries(test_atomic_ops PRIVATE gc) -+ add_test(NAME test_atomic_ops COMMAND test_atomic_ops) -+ -+ add_executable(threadleaktest tests/thread_leak_test.c) -+ target_link_libraries(threadleaktest PRIVATE gc ${THREADDLLIBS}) -+ add_test(NAME threadleaktest COMMAND threadleaktest) -+ -+ if (NOT WIN32) -+ add_executable(threadkey_test tests/threadkey_test.c) -+ target_link_libraries(threadkey_test PRIVATE gc ${THREADDLLIBS}) -+ add_test(NAME threadkey_test COMMAND threadkey_test) -+ endif() -+ -+ add_executable(subthreadcreate_test tests/subthread_create.c) -+ target_link_libraries(subthreadcreate_test PRIVATE gc ${THREADDLLIBS}) -+ add_test(NAME subthreadcreate_test COMMAND subthreadcreate_test) -+ -+ add_executable(initsecondarythread_test tests/initsecondarythread.c) -+ target_link_libraries(initsecondarythread_test PRIVATE gc ${THREADDLLIBS}) -+ add_test(NAME initsecondarythread_test COMMAND initsecondarythread_test) -+ endif(enable_threads) -+ -+ if (enable_cplusplus) -+ add_executable(test_cpp WIN32 tests/test_cpp.cc) -+ target_link_libraries(test_cpp PRIVATE gc gccpp) -+ add_test(NAME test_cpp COMMAND test_cpp) -+ endif() -+ -+ if (enable_disclaim) -+ add_executable(disclaim_bench tests/disclaim_bench.c) -+ target_link_libraries(disclaim_bench PRIVATE gc) -+ add_test(NAME disclaim_bench COMMAND disclaim_bench) -+ -+ add_executable(disclaim_test tests/disclaim_test.c) -+ target_link_libraries(disclaim_test PRIVATE gc ${THREADDLLIBS}) -+ add_test(NAME disclaim_test COMMAND disclaim_test) -+ -+ add_executable(disclaim_weakmap_test tests/disclaim_weakmap_test.c) -+ target_link_libraries(disclaim_weakmap_test PRIVATE gc ${THREADDLLIBS}) -+ add_test(NAME disclaim_weakmap_test COMMAND disclaim_weakmap_test) -+ endif() -+endif(build_tests) diff --git a/recipes/bdwgc/all/test_package/CMakeLists.txt b/recipes/bdwgc/all/test_package/CMakeLists.txt index 7b9b613cbb24a..6b8623ba2be96 100644 --- a/recipes/bdwgc/all/test_package/CMakeLists.txt +++ b/recipes/bdwgc/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(BDWgc CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE BDWgc::gc) diff --git a/recipes/bdwgc/all/test_package/conanfile.py b/recipes/bdwgc/all/test_package/conanfile.py index b5ecfa88d3a13..fde7967ed16f1 100644 --- a/recipes/bdwgc/all/test_package/conanfile.py +++ b/recipes/bdwgc/all/test_package/conanfile.py @@ -1,10 +1,19 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import cmake_layout, CMake +from conan.tools.build import can_run class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package_multi", "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +21,5 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin","test_package"), run_environment=True) + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/recipes/bdwgc/all/test_v1_package/CMakeLists.txt b/recipes/bdwgc/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..8ab3169f9e927 --- /dev/null +++ b/recipes/bdwgc/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(BDWgc REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE BDWgc::gc) diff --git a/recipes/bdwgc/all/test_v1_package/conanfile.py b/recipes/bdwgc/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..dfe389167a895 --- /dev/null +++ b/recipes/bdwgc/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake +from conan.tools.build import cross_building + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake_find_package_multi", "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + self.run(os.path.join("bin","test_package"), run_environment=True) diff --git a/recipes/bdwgc/config.yml b/recipes/bdwgc/config.yml index 739451866530b..a32355f74df3f 100644 --- a/recipes/bdwgc/config.yml +++ b/recipes/bdwgc/config.yml @@ -1,3 +1,7 @@ versions: "8.0.4": folder: all + "8.0.6": + folder: all + "8.2.2": + folder: all diff --git a/recipes/beauty/all/conandata.yml b/recipes/beauty/all/conandata.yml new file mode 100644 index 0000000000000..67db3d5af7757 --- /dev/null +++ b/recipes/beauty/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.0.0-rc1": + url: "https://github.com/dfleury2/beauty/archive/refs/tags/1.0.0-rc1.tar.gz" + sha256: "e5c0cdffd9324ed0cbe771a4aaff3a572ec553dc0275bbaf4db754ce043ecf49" +patches: + "1.0.0-rc1": + - patch_file: "patches/0001-fix-cmake.patch" diff --git a/recipes/beauty/all/conanfile.py b/recipes/beauty/all/conanfile.py new file mode 100644 index 0000000000000..fe51140196608 --- /dev/null +++ b/recipes/beauty/all/conanfile.py @@ -0,0 +1,105 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.0" + + +class BeautyConan(ConanFile): + name = "beauty" + homepage = "https://github.com/dfleury2/beauty" + description = "HTTP Server above Boost.Beast" + topics = ("http", "server", "boost.beast") + url = "https://github.com/conan-io/conan-center-index" + license = "MIT" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "CMakeDeps" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8", + "clang": "11", + "Visual Studio": "16", + "msvc": "192", + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("boost/1.79.0"), + self.requires("openssl/1.1.1q") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, "20") + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"Compiler {self.name} must be at least {minimum_version}") + + if self.settings.compiler == "clang" and self.settings.compiler.libcxx != "libc++": + raise ConanInvalidConfiguration("Only libc++ is supported for clang") + + if self.settings.compiler == "apple-clang" and self.options.shared: + raise ConanInvalidConfiguration("shared is not supported on apple-clang") + + if is_msvc(self) and self.options.shared: + raise ConanInvalidConfiguration("shared is not supported on Visual Studio") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build(target="beauty") + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "beauty") + self.cpp_info.set_property("cmake_target_name", "beauty::beauty") + self.cpp_info.libs = ["beauty"] + self.cpp_info.requires = ["boost::headers", "openssl::openssl"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["m"] diff --git a/recipes/beauty/all/patches/0001-fix-cmake.patch b/recipes/beauty/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..6bdf75a96f54e --- /dev/null +++ b/recipes/beauty/all/patches/0001-fix-cmake.patch @@ -0,0 +1,18 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.15) + project(Beauty) + set(VERSION 0.1-rc) + ++if(0) + if (CONAN_EXPORTED) + else() + if (NOT EXISTS ${CMAKE_BINARY_DIR}/conan_toolchain.cmake) +@@ -20,6 +21,7 @@ else() + endif() + + include(${CMAKE_BINARY_DIR}/conan_toolchain.cmake) ++endif() + + # C++ + set(CMAKE_CXX_STANDARD 20) diff --git a/recipes/beauty/all/test_package/CMakeLists.txt b/recipes/beauty/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8673671fd5aab --- /dev/null +++ b/recipes/beauty/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) + +find_package(beauty REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE beauty::beauty) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) diff --git a/recipes/beauty/all/test_package/conanfile.py b/recipes/beauty/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/beauty/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/beauty/all/test_package/test_package.cpp b/recipes/beauty/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..60288e6673e4c --- /dev/null +++ b/recipes/beauty/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + // Create a server + beauty::server server; +} diff --git a/recipes/beauty/all/test_v1_package/CMakeLists.txt b/recipes/beauty/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..45a312a95a7c8 --- /dev/null +++ b/recipes/beauty/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(beauty REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE beauty::beauty) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) diff --git a/recipes/beauty/all/test_v1_package/conanfile.py b/recipes/beauty/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/beauty/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/beauty/config.yml b/recipes/beauty/config.yml new file mode 100644 index 0000000000000..ca2cfd0e152c6 --- /dev/null +++ b/recipes/beauty/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.0-rc1": + folder: all diff --git a/recipes/behaviortree.cpp/all/conandata.yml b/recipes/behaviortree.cpp/all/conandata.yml new file mode 100644 index 0000000000000..8e188b3097d43 --- /dev/null +++ b/recipes/behaviortree.cpp/all/conandata.yml @@ -0,0 +1,28 @@ +sources: + "4.0.1": + url: "https://github.com/BehaviorTree/BehaviorTree.CPP/archive/refs/tags/4.0.1.tar.gz" + sha256: "71544f72abea8e8c246b016b7e8d87d96f731c8aa96698058d8e69d40e56f9b9" + "3.7.0": + url: "https://github.com/BehaviorTree/BehaviorTree.CPP/archive/refs/tags/3.7.0.tar.gz" + sha256: "ab0d8ac1a0df4dd43cf45da8a784bab7fdedf711bd0e227f7ed071f79b0c7b5c" + "3.5.6": + url: "https://github.com/BehaviorTree/BehaviorTree.CPP/archive/refs/tags/3.5.6.tar.gz" + sha256: "543c428602b5acb7c5666aee34feb532e18ce7200870a79b23ff9aed17ee84c4" +patches: + "4.0.1": + - patch_file: "patches/4.0.1-0001-remove-fpic.patch" + - patch_file: "patches/4.0.1-0002-find-zmq.patch" + - patch_file: "patches/4.0.1-0003-no-werror.patch" + - patch_file: "patches/3.5.6-0005-stdc-format.patch" + - patch_file: "patches/3.5.6-0005-stdc-format.patch" + "3.7.0": + - patch_file: "patches/3.7.0-0001-remove-fpic.patch" + - patch_file: "patches/3.7.0-0002-find-zmq.patch" + - patch_file: "patches/3.7.0-0003-no-werror.patch" + - patch_file: "patches/3.5.6-0005-stdc-format.patch" + "3.5.6": + - patch_file: "patches/3.5.6-0001-remove-fpic.patch" + - patch_file: "patches/3.5.6-0002-find-zmq.patch" + - patch_file: "patches/3.5.6-0003-no-werror.patch" + - patch_file: "patches/3.5.6-0004-win-sigaction.patch" + - patch_file: "patches/3.5.6-0005-stdc-format.patch" diff --git a/recipes/behaviortree.cpp/all/conanfile.py b/recipes/behaviortree.cpp/all/conanfile.py new file mode 100644 index 0000000000000..54f5ae5ad8322 --- /dev/null +++ b/recipes/behaviortree.cpp/all/conanfile.py @@ -0,0 +1,165 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.53.0" + +class BehaviorTreeCPPConan(ConanFile): + name = "behaviortree.cpp" + description = "This C++ library provides a framework to create BehaviorTrees" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/BehaviorTree/BehaviorTree.CPP" + topics = ("ai", "robotics", "games", "coordination") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_tools": [True, False], + "with_coroutines": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_tools": False, + "with_coroutines": False, + } + + @property + def _minimum_cppstd_required(self): + return 14 if Version(self.version) < "4.0" else 17 + + @property + def _minimum_compilers_version(self): + if Version(self.version) < "4.0": + return { + "gcc": "5", + "clang": "5", + "apple-clang": "12", + } + else: + return { + "gcc": "8", + "clang": "7", + "apple-clang": "12", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_coroutines: + self.requires("boost/1.80.0") + self.requires("ncurses/6.3") + self.requires("zeromq/4.3.4") + self.requires("cppzmq/4.9.0") + + def validate(self): + if self.info.settings.os == "Windows" and self.info.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} can not be built as shared on Windows.") + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._minimum_cppstd_required) + check_min_vs(self, 191 if Version(self.version) < "4.0" else 192) + if not is_msvc(self): + minimum_version = self._minimum_compilers_version.get(str(self.info.settings.compiler), False) + if not minimum_version: + self.output.warn(f"{self.ref} requires C++{self._minimum_cppstd_required}. Your compiler is unknown. Assuming it supports C++{self._minimum_cppstd_required}.") + elif Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration("BehaviorTree.CPP requires C++{}, which your compiler does not support." + .format(self._minimum_cppstd_required)) + + if self.settings.compiler == "clang" and str(self.settings .compiler.libcxx) == "libstdc++": + raise ConanInvalidConfiguration(f"{self.ref} needs recent libstdc++ with charconv. please switch to gcc, or to libc++") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) < "4.0": + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_UNIT_TESTS"] = False + tc.variables["BUILD_TOOLS"] = self.options.with_tools + tc.variables["ENABLE_COROUTINES"] = self.options.with_coroutines + else: + tc.variables["BTCPP_SHARED_LIBS"] = self.options.shared + tc.variables["BTCPP_EXAMPLES"] = False + tc.variables["BTCPP_UNIT_TESTS"] = False + tc.variables["BTCPP_BUILD_TOOLS"] = self.options.with_tools + tc.variables["BTCPP_ENABLE_COROUTINES"] = self.options.with_coroutines + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + rmdir(self, os.path.join(self.package_folder, "lib", "BehaviorTreeV3")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + if Version(self.version) < "4.0": + self.cpp_info.set_property("cmake_file_name", "BehaviorTreeV3") + else: + self.cpp_info.set_property("cmake_file_name", "BehaviorTree") + + libname = "behaviortree_cpp_v3" if Version(self.version) < "4.0" else "behaviortree_cpp" + self.cpp_info.set_property("cmake_target_name", f"BT::{libname}") + + postfix = "d" if self.settings.os == "Windows" and self.settings.build_type == "Debug" else "" + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + self.cpp_info.components[libname].libs = [f"{libname}{postfix}"] + self.cpp_info.components[libname].requires = ["zeromq::zeromq", "cppzmq::cppzmq", "ncurses::ncurses"] + if self.options.with_coroutines: + self.cpp_info.components[libname].requires.append("boost::coroutine") + if self.settings.os in ("Linux", "FreeBSD"): + self.cpp_info.components[libname].system_libs.append("pthread") + if Version(self.version) >= "4.0" and \ + self.settings.compiler == "gcc" and Version(self.settings.compiler.version).major == "8": + self.cpp_info.components[libname].system_libs.append("stdc++fs") + + if self.options.with_tools: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH env var with : {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + if Version(self.version) < "4.0": + self.cpp_info.filenames["cmake_find_package"] = "BehaviorTreeV3" + self.cpp_info.filenames["cmake_find_package_multi"] = "BehaviorTreeV3" + else: + self.cpp_info.filenames["cmake_find_package"] = "BehaviorTree" + self.cpp_info.filenames["cmake_find_package_multi"] = "BehaviorTree" + + self.cpp_info.names["cmake_find_package"] = "BT" + self.cpp_info.names["cmake_find_package_multi"] = "BT" + self.cpp_info.components[libname].names["cmake_find_package"] = libname + self.cpp_info.components[libname].names["cmake_find_package_multi"] = libname + self.cpp_info.components[libname].set_property("cmake_target_name", f"BT::{libname}") diff --git a/recipes/behaviortree.cpp/all/patches/3.5.6-0001-remove-fpic.patch b/recipes/behaviortree.cpp/all/patches/3.5.6-0001-remove-fpic.patch new file mode 100644 index 0000000000000..7cb2daad955aa --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/3.5.6-0001-remove-fpic.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a390aed..aff91ec 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -36,7 +36,6 @@ if(NOT DEFINED BT_COROUTINES) + add_definitions(-DBT_NO_COROUTINES) + endif() + +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + #---- project configuration ---- + option(BUILD_EXAMPLES "Build tutorials and examples" ON) diff --git a/recipes/behaviortree.cpp/all/patches/3.5.6-0002-find-zmq.patch b/recipes/behaviortree.cpp/all/patches/3.5.6-0002-find-zmq.patch new file mode 100644 index 0000000000000..c717020c8e00a --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/3.5.6-0002-find-zmq.patch @@ -0,0 +1,68 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index aff91ec..242c214 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -45,14 +45,14 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON) + + #---- Find other packages ---- + find_package(Threads) +-find_package(ZMQ) ++find_package(ZeroMQ) + + list(APPEND BEHAVIOR_TREE_PUBLIC_LIBRARIES + ${CMAKE_THREAD_LIBS_INIT} + ${CMAKE_DL_LIBS} + ) + +-if( ZMQ_FOUND ) ++if( ZeroMQ_FOUND ) + message(STATUS "ZeroMQ found.") + add_definitions( -DZMQ_FOUND ) + list(APPEND BT_SOURCE src/loggers/bt_zmq_publisher.cpp) +@@ -202,8 +202,8 @@ if (WIN32) + add_library(${BEHAVIOR_TREE_LIBRARY} STATIC ${BT_SOURCE} ) + endif() + +-if( ZMQ_FOUND ) +- list(APPEND BUILD_TOOL_INCLUDE_DIRS ${ZMQ_INCLUDE_DIRS}) ++if( ZeroMQ_FOUND ) ++ list(APPEND BUILD_TOOL_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIRS}) + endif() + + target_link_libraries(${BEHAVIOR_TREE_LIBRARY} PUBLIC +@@ -211,7 +211,7 @@ target_link_libraries(${BEHAVIOR_TREE_LIBRARY} PUBLIC + + target_link_libraries(${BEHAVIOR_TREE_LIBRARY} PRIVATE + ${Boost_LIBRARIES} +- ${ZMQ_LIBRARIES}) ++ ${ZeroMQ_LIBRARIES}) + + #get_target_property(my_libs ${BEHAVIOR_TREE_LIBRARY} INTERFACE_LINK_LIBRARIES) + #list(REMOVE_ITEM _libs X) +@@ -227,8 +227,8 @@ target_include_directories(${BEHAVIOR_TREE_LIBRARY} PUBLIC + $ + ${BUILD_TOOL_INCLUDE_DIRS}) + +-if( ZMQ_FOUND ) +- target_compile_definitions(${BEHAVIOR_TREE_LIBRARY} PUBLIC ZMQ_FOUND) ++if( ZeroMQ_FOUND ) ++ target_compile_definitions(${BEHAVIOR_TREE_LIBRARY} PUBLIC ZeroMQ_FOUND) + endif() + + if(MSVC) +diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt +index 0801850..153b447 100644 +--- a/tools/CMakeLists.txt ++++ b/tools/CMakeLists.txt +@@ -6,9 +6,9 @@ target_link_libraries(bt3_log_cat ${BEHAVIOR_TREE_LIBRARY} ) + install(TARGETS bt3_log_cat + DESTINATION ${BEHAVIOR_TREE_BIN_DESTINATION} ) + +-if( ZMQ_FOUND ) ++if( ZeroMQ_FOUND ) + add_executable(bt3_recorder bt_recorder.cpp ) +- target_link_libraries(bt3_recorder ${BEHAVIOR_TREE_LIBRARY} ${ZMQ_LIBRARIES}) ++ target_link_libraries(bt3_recorder ${BEHAVIOR_TREE_LIBRARY} ${ZeroMQ_LIBRARIES}) + install(TARGETS bt3_recorder + DESTINATION ${BEHAVIOR_TREE_BIN_DESTINATION} ) + endif() diff --git a/recipes/behaviortree.cpp/all/patches/3.5.6-0003-no-werror.patch b/recipes/behaviortree.cpp/all/patches/3.5.6-0003-no-werror.patch new file mode 100644 index 0000000000000..4996714060f93 --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/3.5.6-0003-no-werror.patch @@ -0,0 +1,17 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 242c214..cb8d77a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -232,10 +232,10 @@ if( ZeroMQ_FOUND ) + endif() + + if(MSVC) +- target_compile_options(${BEHAVIOR_TREE_LIBRARY} PRIVATE /W3 /WX) ++ target_compile_options(${BEHAVIOR_TREE_LIBRARY} PRIVATE /W3) + else() + target_compile_options(${BEHAVIOR_TREE_LIBRARY} PRIVATE +- -Wall -Wextra -Werror=return-type) ++ -Wall -Wextra) + endif() + + ###################################################### diff --git a/recipes/behaviortree.cpp/all/patches/3.5.6-0004-win-sigaction.patch b/recipes/behaviortree.cpp/all/patches/3.5.6-0004-win-sigaction.patch new file mode 100644 index 0000000000000..75f9c74e55e10 --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/3.5.6-0004-win-sigaction.patch @@ -0,0 +1,22 @@ +diff --git a/tools/bt_recorder.cpp b/tools/bt_recorder.cpp +index 3aa6740..4b36414 100644 +--- a/tools/bt_recorder.cpp ++++ b/tools/bt_recorder.cpp +@@ -16,12 +16,17 @@ static void s_signal_handler(int) + + static void CatchSignals(void) + { ++#ifdef _WIN32 ++ signal(SIGINT, s_signal_handler); ++ signal(SIGTERM, s_signal_handler); ++#else + struct sigaction action; + action.sa_handler = s_signal_handler; + action.sa_flags = 0; + sigemptyset(&action.sa_mask); + sigaction(SIGINT, &action, NULL); + sigaction(SIGTERM, &action, NULL); ++#endif + } + + int main(int argc, char* argv[]) diff --git a/recipes/behaviortree.cpp/all/patches/3.5.6-0005-stdc-format.patch b/recipes/behaviortree.cpp/all/patches/3.5.6-0005-stdc-format.patch new file mode 100644 index 0000000000000..d1b1b47051f32 --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/3.5.6-0005-stdc-format.patch @@ -0,0 +1,12 @@ +diff --git a/3rdparty/minitrace/minitrace.h b/3rdparty/minitrace/minitrace.h +index c7d5b31..d68dc52 100644 +--- a/3rdparty/minitrace/minitrace.h ++++ b/3rdparty/minitrace/minitrace.h +@@ -21,6 +21,7 @@ + // More: + // http://www.altdevblogaday.com/2012/08/21/using-chrometracing-to-view-your-inline-profiling-data/ + ++#define __STDC_FORMAT_MACROS + #include + + #define MTR_ENABLED diff --git a/recipes/behaviortree.cpp/all/patches/3.7.0-0001-remove-fpic.patch b/recipes/behaviortree.cpp/all/patches/3.7.0-0001-remove-fpic.patch new file mode 100644 index 0000000000000..b1bd9fd89538c --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/3.7.0-0001-remove-fpic.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cd490a5..843045e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -15,8 +15,6 @@ else() + add_definitions(-Wpedantic) + endif() + +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) +- + #---- project configuration ---- + option(BUILD_EXAMPLES "Build tutorials and examples" ON) + option(BUILD_SAMPLES "Build sample nodes" ON) diff --git a/recipes/behaviortree.cpp/all/patches/3.7.0-0002-find-zmq.patch b/recipes/behaviortree.cpp/all/patches/3.7.0-0002-find-zmq.patch new file mode 100644 index 0000000000000..7290476cc8726 --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/3.7.0-0002-find-zmq.patch @@ -0,0 +1,68 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 843045e..471c00e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -54,14 +54,14 @@ endif() + + #---- Find other packages ---- + find_package(Threads) +-find_package(ZMQ) ++find_package(ZeroMQ) + + list(APPEND BEHAVIOR_TREE_PUBLIC_LIBRARIES + ${CMAKE_THREAD_LIBS_INIT} + ${CMAKE_DL_LIBS} + ) + +-if( ZMQ_FOUND ) ++if( ZeroMQ_FOUND ) + message(STATUS "ZeroMQ found.") + add_definitions( -DZMQ_FOUND ) + list(APPEND BT_SOURCE src/loggers/bt_zmq_publisher.cpp) +@@ -193,8 +193,8 @@ else() + add_library(${BEHAVIOR_TREE_LIBRARY} STATIC ${BT_SOURCE}) + endif() + +-if( ZMQ_FOUND ) +- list(APPEND BUILD_TOOL_INCLUDE_DIRS ${ZMQ_INCLUDE_DIRS}) ++if( ZeroMQ_FOUND ) ++ list(APPEND BUILD_TOOL_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIRS}) + endif() + + target_link_libraries(${BEHAVIOR_TREE_LIBRARY} PUBLIC +@@ -202,7 +202,7 @@ target_link_libraries(${BEHAVIOR_TREE_LIBRARY} PUBLIC + + target_link_libraries(${BEHAVIOR_TREE_LIBRARY} PRIVATE + ${Boost_LIBRARIES} +- ${ZMQ_LIBRARIES}) ++ ${ZeroMQ_LIBRARIES}) + + #get_target_property(my_libs ${BEHAVIOR_TREE_LIBRARY} INTERFACE_LINK_LIBRARIES) + #list(REMOVE_ITEM _libs X) +@@ -218,8 +218,8 @@ target_include_directories(${BEHAVIOR_TREE_LIBRARY} PUBLIC + $ + ${BUILD_TOOL_INCLUDE_DIRS}) + +-if( ZMQ_FOUND ) +- target_compile_definitions(${BEHAVIOR_TREE_LIBRARY} PUBLIC ZMQ_FOUND) ++if( ZeroMQ_FOUND ) ++ target_compile_definitions(${BEHAVIOR_TREE_LIBRARY} PUBLIC ZeroMQ_FOUND) + endif() + + if(MSVC) +diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt +index 2ad33b3..2dc969d 100644 +--- a/tools/CMakeLists.txt ++++ b/tools/CMakeLists.txt +@@ -6,9 +6,9 @@ target_link_libraries(bt3_log_cat ${BEHAVIOR_TREE_LIBRARY} ) + install(TARGETS bt3_log_cat + DESTINATION ${BEHAVIOR_TREE_BIN_DESTINATION} ) + +-if( ZMQ_FOUND ) ++if( ZeroMQ_FOUND ) + add_executable(bt3_recorder bt_recorder.cpp ) +- target_link_libraries(bt3_recorder ${BEHAVIOR_TREE_LIBRARY} ${ZMQ_LIBRARIES}) ++ target_link_libraries(bt3_recorder ${BEHAVIOR_TREE_LIBRARY} ${ZeroMQ_LIBRARIES}) + install(TARGETS bt3_recorder + DESTINATION ${BEHAVIOR_TREE_BIN_DESTINATION} ) + endif() diff --git a/recipes/behaviortree.cpp/all/patches/3.7.0-0003-no-werror.patch b/recipes/behaviortree.cpp/all/patches/3.7.0-0003-no-werror.patch new file mode 100644 index 0000000000000..5bf8893db1770 --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/3.7.0-0003-no-werror.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 471c00e..7245461 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -225,7 +225,7 @@ endif() + if(MSVC) + else() + target_compile_options(${BEHAVIOR_TREE_LIBRARY} PRIVATE +- -Wall -Wextra -Werror=return-type) ++ -Wall -Wextra) + endif() + + ############################################################# diff --git a/recipes/behaviortree.cpp/all/patches/4.0.1-0001-remove-fpic.patch b/recipes/behaviortree.cpp/all/patches/4.0.1-0001-remove-fpic.patch new file mode 100644 index 0000000000000..23931bd446392 --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/4.0.1-0001-remove-fpic.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d03b8a7..a2f23cf 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -15,8 +15,6 @@ else() + add_definitions(-Wpedantic) + endif() + +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) +- + #---- project configuration ---- + option(BTCPP_SHARED_LIBS "Build shared libraries" ON) + option(BTCPP_ENABLE_COROUTINES "Enable boost coroutines" ON) diff --git a/recipes/behaviortree.cpp/all/patches/4.0.1-0002-find-zmq.patch b/recipes/behaviortree.cpp/all/patches/4.0.1-0002-find-zmq.patch new file mode 100644 index 0000000000000..6753b06f564d0 --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/4.0.1-0002-find-zmq.patch @@ -0,0 +1,57 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a2f23cf..d427d37 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -67,14 +67,14 @@ endif() + + #---- Find other packages ---- + find_package(Threads) +-find_package(ZMQ) ++find_package(ZeroMQ) + + list(APPEND BEHAVIOR_TREE_PUBLIC_LIBRARIES + ${CMAKE_THREAD_LIBS_INIT} + ${CMAKE_DL_LIBS} + ) + +-if( ZMQ_FOUND ) ++if( ZeroMQ_FOUND ) + message(STATUS "ZeroMQ found.") + add_definitions( -DZMQ_FOUND ) + list(APPEND BT_SOURCE src/loggers/bt_zmq_publisher.cpp) +@@ -221,7 +221,7 @@ target_link_libraries(${BEHAVIOR_TREE_LIBRARY} + ${BEHAVIOR_TREE_PUBLIC_LIBRARIES} + PRIVATE + ${Boost_LIBRARIES} +- ${ZMQ_LIBRARIES} ++ ${ZeroMQ_LIBRARIES} + $ + ) + +@@ -243,8 +243,8 @@ target_include_directories(${BEHAVIOR_TREE_LIBRARY} PRIVATE + $ + ) + +-if( ZMQ_FOUND ) +- target_compile_definitions(${BEHAVIOR_TREE_LIBRARY} PUBLIC ZMQ_FOUND) ++if( ZeroMQ_FOUND ) ++ target_compile_definitions(${BEHAVIOR_TREE_LIBRARY} PUBLIC ZeroMQ_FOUND) + endif() + + if(MSVC) +diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt +index 163e703..b98f525 100644 +--- a/tools/CMakeLists.txt ++++ b/tools/CMakeLists.txt +@@ -7,9 +7,9 @@ target_link_libraries(bt3_log_cat ${BEHAVIOR_TREE_LIBRARY} ) + install(TARGETS bt3_log_cat + DESTINATION ${BEHAVIOR_TREE_BIN_DESTINATION} ) + +-if( ZMQ_FOUND ) ++if( ZeroMQ_FOUND ) + add_executable(bt3_recorder bt_recorder.cpp ) +- target_link_libraries(bt3_recorder ${BEHAVIOR_TREE_LIBRARY} ${ZMQ_LIBRARIES}) ++ target_link_libraries(bt3_recorder ${BEHAVIOR_TREE_LIBRARY} ${ZeroMQ_LIBRARIES}) + install(TARGETS bt3_recorder + DESTINATION ${BEHAVIOR_TREE_BIN_DESTINATION} ) + endif() diff --git a/recipes/behaviortree.cpp/all/patches/4.0.1-0003-no-werror.patch b/recipes/behaviortree.cpp/all/patches/4.0.1-0003-no-werror.patch new file mode 100644 index 0000000000000..b69541449eb87 --- /dev/null +++ b/recipes/behaviortree.cpp/all/patches/4.0.1-0003-no-werror.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d427d37..0c10f52 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -250,7 +250,7 @@ endif() + if(MSVC) + else() + target_compile_options(${BEHAVIOR_TREE_LIBRARY} PRIVATE +- -Wall -Wextra -Werror=return-type) ++ -Wall -Wextra) + endif() + + ############################################################# diff --git a/recipes/behaviortree.cpp/all/test_package/CMakeLists.txt b/recipes/behaviortree.cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d710fc297db68 --- /dev/null +++ b/recipes/behaviortree.cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +add_executable(${PROJECT_NAME} test_package.cpp) + +find_package(BehaviorTreeV3 CONFIG) +if(TARGET BT::behaviortree_cpp_v3) + target_link_libraries(${PROJECT_NAME} PRIVATE BT::behaviortree_cpp_v3) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DBEHAVIORTREE_CPP_VERSION=3) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +else() + find_package(BehaviorTree REQUIRED CONFIG) + target_link_libraries(${PROJECT_NAME} PRIVATE BT::behaviortree_cpp) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DBEHAVIORTREE_CPP_VERSION=4) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +endif() diff --git a/recipes/behaviortree.cpp/all/test_package/conanfile.py b/recipes/behaviortree.cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/behaviortree.cpp/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/behaviortree.cpp/all/test_package/test_package.cpp b/recipes/behaviortree.cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..d5a7ae6ffc770 --- /dev/null +++ b/recipes/behaviortree.cpp/all/test_package/test_package.cpp @@ -0,0 +1,106 @@ +#if BEHAVIORTREE_CPP_VERSION < 4 +#include "behaviortree_cpp_v3/bt_factory.h" +#else +#include "behaviortree_cpp/bt_factory.h" +#endif + +using namespace BT; + +struct Position2D { double x,y; }; + +namespace BT{ + template <> inline Position2D convertFromString(StringView str) { + printf("Converting string: \"%s\"\n", str.data() ); + + // real numbers separated by semicolons + auto parts = splitString(str, ';'); + if (parts.size() != 2) + { + throw RuntimeError("invalid input)"); + } + else{ + Position2D output; + output.x = convertFromString(parts[0]); + output.y = convertFromString(parts[1]); + return output; + } + } +} + +class CalculateGoal: public SyncActionNode{ +public: +#if BEHAVIORTREE_CPP_VERSION < 4 + CalculateGoal(const std::string& name, const NodeConfiguration& config): + SyncActionNode(name,config) {} +#else + CalculateGoal(const std::string& name, const NodeConfig& config): + SyncActionNode(name,config) {} +#endif + + NodeStatus tick() override{ + Position2D mygoal = {1.1, 2.3}; + setOutput("goal", mygoal); + return NodeStatus::SUCCESS; + } + static PortsList providedPorts(){ + return { OutputPort("goal") }; + } +}; + + +class PrintTarget: public SyncActionNode { +public: +#if BEHAVIORTREE_CPP_VERSION < 4 + PrintTarget(const std::string& name, const NodeConfiguration& config): + SyncActionNode(name,config) {} +#else + PrintTarget(const std::string& name, const NodeConfig& config): + SyncActionNode(name,config) {} +#endif + + NodeStatus tick() override { + auto res = getInput("target"); + if( !res ){ + throw RuntimeError("error reading port [target]:", res.error() ); + } + Position2D goal = res.value(); + printf("Target positions: [ %.1f, %.1f ]\n", goal.x, goal.y ); + return NodeStatus::SUCCESS; + } + + static PortsList providedPorts() { + // Optionally, a port can have a human readable description + const char* description = "Simply print the target on console..."; + return { InputPort("target", description) }; + } +}; + +static const char* xml_text = R"( + + + + + + + + + + + )"; + + +int main() { + using namespace BT; + + BehaviorTreeFactory factory; + factory.registerNodeType("CalculateGoal"); + factory.registerNodeType("PrintTarget"); + + auto tree = factory.createTreeFromText(xml_text); +#if BEHAVIORTREE_CPP_VERSION < 4 + tree.tickRoot(); +#else + tree.tickWhileRunning(); +#endif + return 0; +} diff --git a/recipes/behaviortree.cpp/all/test_v1_package/CMakeLists.txt b/recipes/behaviortree.cpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/behaviortree.cpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/behaviortree.cpp/all/test_v1_package/conanfile.py b/recipes/behaviortree.cpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/behaviortree.cpp/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/behaviortree.cpp/config.yml b/recipes/behaviortree.cpp/config.yml new file mode 100644 index 0000000000000..e1234d5535a8c --- /dev/null +++ b/recipes/behaviortree.cpp/config.yml @@ -0,0 +1,7 @@ +versions: + "4.0.1": + folder: all + "3.7.0": + folder: all + "3.5.6": + folder: all diff --git a/recipes/benchmark/all/CMakeLists.txt b/recipes/benchmark/all/CMakeLists.txt deleted file mode 100644 index 08bd91ff0594a..0000000000000 --- a/recipes/benchmark/all/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") - include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -else() - include(conanbuildinfo.cmake) -endif() -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/benchmark/all/conandata.yml b/recipes/benchmark/all/conandata.yml index e9b328af1e596..926ace1d06183 100644 --- a/recipes/benchmark/all/conandata.yml +++ b/recipes/benchmark/all/conandata.yml @@ -1,13 +1,19 @@ sources: - "1.5.0": - sha256: 3c6a165b6ecc948967a1ead710d4a181d7b0fbcaa183ef7ea84604994966221a - url: https://github.com/google/benchmark/archive/v1.5.0.tar.gz - "1.5.1": - sha256: 23082937d1663a53b90cb5b61df4bcc312f6dee7018da78ba00dd6bd669dfef2 - url: https://github.com/google/benchmark/archive/v1.5.1.tar.gz - "1.5.2": - sha256: dccbdab796baa1043f04982147e67bb6e118fe610da2c65f88912d73987e700c - url: https://github.com/google/benchmark/archive/v1.5.2.tar.gz - "1.5.3": - sha256: e4fbb85eec69e6668ad397ec71a3a3ab165903abe98a8327db920b94508f720e - url: https://github.com/google/benchmark/archive/v1.5.3.tar.gz + "1.7.1": + url: "https://github.com/google/benchmark/archive/refs/tags/v1.7.1.tar.gz" + sha256: "6430e4092653380d9dc4ccb45a1e2dc9259d581f4866dc0759713126056bc1d7" + "1.7.0": + url: "https://github.com/google/benchmark/archive/refs/tags/v1.7.0.tar.gz" + sha256: "3aff99169fa8bdee356eaa1f691e835a6e57b1efeadb8a0f9f228531158246ac" + "1.6.2": + url: "https://github.com/google/benchmark/archive/v1.6.2.tar.gz" + sha256: "a9f77e6188c1cd4ebedfa7538bf5176d6acc72ead6f456919e5f464ef2f06158" + "1.6.1": + url: "https://github.com/google/benchmark/archive/v1.6.1.tar.gz" + sha256: "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4" + "1.6.0": + url: "https://github.com/google/benchmark/archive/v1.6.0.tar.gz" + sha256: "1f71c72ce08d2c1310011ea6436b31e39ccab8c2db94186d26657d41747c85d6" + "1.5.6": + url: "https://github.com/google/benchmark/archive/v1.5.6.tar.gz" + sha256: "789f85b4810d13ff803834ea75999e41b326405d83d6a538baf01499eda96102" diff --git a/recipes/benchmark/all/conanfile.py b/recipes/benchmark/all/conanfile.py index 67f03de25da70..04fc858f5c5ba 100644 --- a/recipes/benchmark/all/conanfile.py +++ b/recipes/benchmark/all/conanfile.py @@ -1,21 +1,24 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.53.0" class BenchmarkConan(ConanFile): name = "benchmark" description = "A microbenchmark support library." - topics = ("conan", "benchmark", "google", "microbenchmark") + license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index/" homepage = "https://github.com/google/benchmark" - license = "Apache-2.0" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" + topics = ("google", "microbenchmark") - settings = "arch", "build_type", "compiler", "os" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -29,70 +32,92 @@ class BenchmarkConan(ConanFile): "enable_exceptions": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - - def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version.value) <= 12: - raise ConanInvalidConfiguration("{} {} does not support Visual Studio <= 12".format(self.name, self.version)) def configure(self): if self.options.shared: - del self.options.fPIC - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("Windows shared builds are not supported right now, see issue #639") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - - self._cmake.definitions["BENCHMARK_ENABLE_TESTING"] = "OFF" - self._cmake.definitions["BENCHMARK_ENABLE_GTEST_TESTS"] = "OFF" - self._cmake.definitions["BENCHMARK_ENABLE_LTO"] = "ON" if self.options.enable_lto else "OFF" - self._cmake.definitions["BENCHMARK_ENABLE_EXCEPTIONS"] = "ON" if self.options.enable_exceptions else "OFF" + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler == "Visual Studio" and Version(self.info.settings.compiler.version) <= "12": + raise ConanInvalidConfiguration(f"{self.ref} doesn't support Visual Studio <= 12") + if Version(self.version) < "1.7.0" and is_msvc(self) and self.info.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} doesn't support msvc shared builds") + + def _cmake_new_enough(self, required_version): + try: + import re + from io import StringIO + output = StringIO() + self.run("cmake --version", output=output) + m = re.search(r'cmake version (\d+\.\d+\.\d+)', output.getvalue()) + return Version(m.group(1)) >= required_version + except: + return False + + def build_requirements(self): + if Version(self.version) >= "1.7.1" and not self._cmake_new_enough("3.16.3"): + self.tool_requires("cmake/3.25.0") + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BENCHMARK_ENABLE_TESTING"] = "OFF" + tc.variables["BENCHMARK_ENABLE_GTEST_TESTS"] = "OFF" + tc.variables["BENCHMARK_ENABLE_LTO"] = self.options.enable_lto + tc.variables["BENCHMARK_ENABLE_EXCEPTIONS"] = self.options.enable_exceptions + if Version(self.version) >= "1.6.1": + tc.variables["BENCHMARK_ENABLE_WERROR"] = False + tc.variables["BENCHMARK_FORCE_WERROR"] = False if self.settings.os != "Windows": - if tools.cross_building(self.settings): - self._cmake.definitions["HAVE_STD_REGEX"] = False - self._cmake.definitions["HAVE_POSIX_REGEX"] = False - self._cmake.definitions["HAVE_STEADY_CLOCK"] = False - self._cmake.definitions["BENCHMARK_USE_LIBCXX"] = "ON" if self.settings.compiler.get_safe("libcxx") == "libc++" else "OFF" + if cross_building(self): + tc.variables["HAVE_STD_REGEX"] = False + tc.variables["HAVE_POSIX_REGEX"] = False + tc.variables["HAVE_STEADY_CLOCK"] = False + tc.variables["BENCHMARK_USE_LIBCXX"] = self.settings.compiler.get_safe("libcxx") == "libc++" else: - self._cmake.definitions["BENCHMARK_USE_LIBCXX"] = "OFF" - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + tc.variables["BENCHMARK_USE_LIBCXX"] = False + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) - tools.rmdir(os.path.join(self.package_folder, 'lib', 'cmake')) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.libs = ["benchmark", "benchmark_main"] + self.cpp_info.set_property("cmake_file_name", "benchmark") + self.cpp_info.set_property("pkg_config_name", "benchmark") + + self.cpp_info.components["_benchmark"].set_property("cmake_target_name", "benchmark::benchmark") + self.cpp_info.components["_benchmark"].libs = ["benchmark"] + if Version(self.version) >= "1.7.0" and not self.options.shared: + self.cpp_info.components["_benchmark"].defines.append("BENCHMARK_STATIC_DEFINE") if self.settings.os in ("FreeBSD", "Linux"): - self.cpp_info.system_libs.extend(["pthread", "rt"]) + self.cpp_info.components["_benchmark"].system_libs.extend(["pthread", "rt", "m"]) elif self.settings.os == "Windows": - self.cpp_info.system_libs.append("shlwapi") + self.cpp_info.components["_benchmark"].system_libs.append("shlwapi") elif self.settings.os == "SunOS": - self.cpp_info.system_libs.append("kstat") + self.cpp_info.components["_benchmark"].system_libs.append("kstat") + + self.cpp_info.components["benchmark_main"].set_property("cmake_target_name", "benchmark::benchmark_main") + self.cpp_info.components["benchmark_main"].libs = ["benchmark_main"] + self.cpp_info.components["benchmark_main"].requires = ["_benchmark"] + + # workaround to have all components in CMakeDeps of downstream recipes + self.cpp_info.set_property("cmake_target_name", "benchmark::benchmark_main") diff --git a/recipes/benchmark/all/test_package/CMakeLists.txt b/recipes/benchmark/all/test_package/CMakeLists.txt index 196188113685c..58358ea09a5db 100644 --- a/recipes/benchmark/all/test_package/CMakeLists.txt +++ b/recipes/benchmark/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(benchmark REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark benchmark::benchmark_main) diff --git a/recipes/benchmark/all/test_package/conanfile.py b/recipes/benchmark/all/test_package/conanfile.py index bd7165a553cf4..0a6bc68712d90 100644 --- a/recipes/benchmark/all/test_package/conanfile.py +++ b/recipes/benchmark/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/benchmark/all/test_v1_package/CMakeLists.txt b/recipes/benchmark/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/benchmark/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/benchmark/all/test_v1_package/conanfile.py b/recipes/benchmark/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2490acfa82ff8 --- /dev/null +++ b/recipes/benchmark/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/benchmark/config.yml b/recipes/benchmark/config.yml index c3cad7197c441..c3f78fe6dce87 100644 --- a/recipes/benchmark/config.yml +++ b/recipes/benchmark/config.yml @@ -1,9 +1,13 @@ versions: - "1.5.0": + "1.7.1": folder: all - "1.5.1": + "1.7.0": folder: all - "1.5.2": + "1.6.2": folder: all - "1.5.3": + "1.6.1": + folder: all + "1.6.0": + folder: all + "1.5.6": folder: all diff --git a/recipes/bertrand/all/CMakeLists.txt b/recipes/bertrand/all/CMakeLists.txt deleted file mode 100644 index 6c3ae2de9686d..0000000000000 --- a/recipes/bertrand/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/bertrand/all/conandata.yml b/recipes/bertrand/all/conandata.yml index a115611dd5732..78b4e7eb868bb 100644 --- a/recipes/bertrand/all/conandata.yml +++ b/recipes/bertrand/all/conandata.yml @@ -1,10 +1,16 @@ sources: - 0.0.12: - url: https://github.com/bernedom/bertrand/archive/0.0.12.tar.gz - sha256: 0648edbb9ea39a918f718a672e14b26c614d8409f146c1550becd45d881cfcf4 - 0.0.14: - url: https://github.com/bernedom/bertrand/archive/0.0.14.tar.gz - sha256: f6ba82e715f9371f06a0d0bd6b7f017c3ff0709e8e5142d8fd4ba00aec1228ba - 0.0.15: + "0.013": + url: "https://github.com/bernedom/bertrand/archive/0.013.tar.gz" + sha256: "f2f071006d3a9b31382957b84e81405adba44cbf1a9bb8242ad4d0f44d7af7fb" + "0.0.17": + url: https://github.com/bernedom/bertrand/archive/0.0.17.tar.gz + sha256: 72e59971bd8ae48d95da9337ad78004b99ba4e8d0eeb3b613ce17b577ca41012 + "0.0.15": url: https://github.com/bernedom/bertrand/archive/0.0.15.tar.gz sha256: 5ad481c2fc3d3166d8660ab3013b4513c5b425c9f13c8925b3cfb40f988d8e9b + "0.0.14": + url: https://github.com/bernedom/bertrand/archive/0.0.14.tar.gz + sha256: f6ba82e715f9371f06a0d0bd6b7f017c3ff0709e8e5142d8fd4ba00aec1228ba + "0.0.12": + url: https://github.com/bernedom/bertrand/archive/0.0.12.tar.gz + sha256: 0648edbb9ea39a918f718a672e14b26c614d8409f146c1550becd45d881cfcf4 diff --git a/recipes/bertrand/all/conanfile.py b/recipes/bertrand/all/conanfile.py index ec6d4bb18eef9..3e410daba2d59 100644 --- a/recipes/bertrand/all/conanfile.py +++ b/recipes/bertrand/all/conanfile.py @@ -1,9 +1,12 @@ -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration - - +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir import os +required_conan_version = ">=1.50.0" + class BertrandConan(ConanFile): name = "bertrand" @@ -11,55 +14,70 @@ class BertrandConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/bernedom/bertrand" description = "A C++ header only library providing a trivial implementation for design by contract." - topics = ("design by contract", "dbc", - "cplusplus-library", "cplusplus-17") - exports_sources = "CMakeLists.txt" + topics = ("design by contract", "dbc", "cplusplus-library", "cplusplus-17") settings = "os", "arch", "compiler", "build_type" - no_copy_source = True - generators = "cmake" @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def _min_cppstd(self): + return "17" @property def _compilers_minimum_version(self): return { "gcc": "7", "Visual Studio": "15.7", + "msvc": "191", "clang": "5", "apple-clang": "10", } - def configure(self): + def package_id(self): + self.info.clear() + + def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "17") - minimum_version = self._compilers_minimum_version.get( - str(self.settings.compiler), False) - if minimum_version: - if tools.Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration("bertrand requires C++17, which your compiler ({} {}) does not support.".format( - self.settings.compiler, self.settings.compiler.version)) - else: - self.output.warn( - "bertrand requires C++17. Your compiler is unknown. Assuming it supports C++17.") + check_min_cppstd(self, self._min_cppstd) - def package_id(self): - self.info.header_only() + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.", + ) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "bertrand-{}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BERTRAND_BUILD_TESTING"] = False + tc.variables["BERTRAND_INSTALL_LIBRARY"] = True + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) cmake = CMake(self) - cmake.definitions["BERTRAND_BUILD_TESTING"] = False - cmake.configure(build_folder=self._build_subfolder) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "bertrand") + self.cpp_info.set_property("cmake_target_name", "bertrand::bertrand") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/bertrand/all/test_package/CMakeLists.txt b/recipes/bertrand/all/test_package/CMakeLists.txt index 6d951a20d7497..8d8eab3e4ede9 100644 --- a/recipes/bertrand/all/test_package/CMakeLists.txt +++ b/recipes/bertrand/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ cmake_minimum_required(VERSION 3.8) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(bertrand REQUIRED CONFIG) -add_executable(${PROJECT_NAME} bertrand_package_test.cpp) +add_executable(${PROJECT_NAME} test_package.cpp) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) -target_link_libraries(${PROJECT_NAME} bertrand::bertrand) +target_link_libraries(${PROJECT_NAME} PRIVATE bertrand::bertrand) diff --git a/recipes/bertrand/all/test_package/conanfile.py b/recipes/bertrand/all/test_package/conanfile.py index 7e2dfe859bb27..d120a992c06a6 100644 --- a/recipes/bertrand/all/test_package/conanfile.py +++ b/recipes/bertrand/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bertrand/all/test_package/bertrand_package_test.cpp b/recipes/bertrand/all/test_package/test_package.cpp similarity index 100% rename from recipes/bertrand/all/test_package/bertrand_package_test.cpp rename to recipes/bertrand/all/test_package/test_package.cpp diff --git a/recipes/bertrand/all/test_v1_package/CMakeLists.txt b/recipes/bertrand/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4b58a4f48ada0 --- /dev/null +++ b/recipes/bertrand/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bertrand REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +target_link_libraries(${PROJECT_NAME} PRIVATE bertrand::bertrand) diff --git a/recipes/bertrand/all/test_v1_package/conanfile.py b/recipes/bertrand/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/bertrand/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bertrand/config.yml b/recipes/bertrand/config.yml index 1b3262caf8a68..f342735d8a8f8 100644 --- a/recipes/bertrand/config.yml +++ b/recipes/bertrand/config.yml @@ -1,7 +1,11 @@ versions: - 0.0.12: + "0.013": folder: all - 0.0.14: + "0.0.17": folder: all - 0.0.15: + "0.0.15": + folder: all + "0.0.14": + folder: all + "0.0.12": folder: all diff --git a/recipes/bigint/all/CMakeLists.txt b/recipes/bigint/all/CMakeLists.txt new file mode 100644 index 0000000000000..acc15b2e4f05f --- /dev/null +++ b/recipes/bigint/all/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.4) +project(bigint LANGUAGES CXX) + +include(GNUInstallDirs) + +add_library(bigint + ${BIGINT_SRC_DIR}/BigUnsigned.cc + ${BIGINT_SRC_DIR}/BigInteger.cc + ${BIGINT_SRC_DIR}/BigIntegerAlgorithms.cc + ${BIGINT_SRC_DIR}/BigUnsignedInABase.cc + ${BIGINT_SRC_DIR}/BigIntegerUtils.cc +) + +set(BIGINT_PUBLIC_HEADERS + ${BIGINT_SRC_DIR}/BigIntegerLibrary.hh + ${BIGINT_SRC_DIR}/NumberlikeArray.hh + ${BIGINT_SRC_DIR}/BigUnsigned.hh + ${BIGINT_SRC_DIR}/BigInteger.hh + ${BIGINT_SRC_DIR}/BigIntegerAlgorithms.hh + ${BIGINT_SRC_DIR}/BigUnsignedInABase.hh + ${BIGINT_SRC_DIR}/BigIntegerUtils.hh +) + +set_target_properties(bigint PROPERTIES + WINDOWS_EXPORT_ALL_SYMBOLS ON + PUBLIC_HEADER "${BIGINT_PUBLIC_HEADERS}" +) + +install( + TARGETS bigint + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/bigint/all/conandata.yml b/recipes/bigint/all/conandata.yml new file mode 100644 index 0000000000000..d95cb78607454 --- /dev/null +++ b/recipes/bigint/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "2010.04.30": + url: "https://mattmccutchen.net/bigint/bigint-2010.04.30.tar.bz2" + sha256: "05fb838472b8f06c30cd11d58e6d911dd54d8413338c4d3d77dd4e52fed6dacc" +patches: + "2010.04.30": + - patch_file: "patches/0001-deprecation-wanings.patch" diff --git a/recipes/bigint/all/conanfile.py b/recipes/bigint/all/conanfile.py new file mode 100644 index 0000000000000..c4c070e4b830d --- /dev/null +++ b/recipes/bigint/all/conanfile.py @@ -0,0 +1,70 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +import os + +required_conan_version = ">=1.47.0" + + +class BigintConan(ConanFile): + name = "bigint" + description = "C++ Big Integer Library" + license = "Unlicense" + topics = ("bigint", "integer") + homepage = "https://mattmccutchen.net/bigint" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.info.options.shared and is_msvc(self) and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration("shared with static runtime not supported") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BIGINT_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "README", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["bigint"] diff --git a/recipes/bigint/all/patches/0001-deprecation-wanings.patch b/recipes/bigint/all/patches/0001-deprecation-wanings.patch new file mode 100644 index 0000000000000..2902ef801709e --- /dev/null +++ b/recipes/bigint/all/patches/0001-deprecation-wanings.patch @@ -0,0 +1,35 @@ +--- a/BigUnsigned.hh ++++ b/BigUnsigned.hh +@@ -20,7 +20,7 @@ public: + typedef unsigned long Blk; + + typedef NumberlikeArray::Index Index; +- NumberlikeArray::N; ++ using NumberlikeArray::N; + + protected: + // Creates a BigUnsigned with a capacity; for internal use. +@@ -84,8 +84,8 @@ public: + // BIT/BLOCK ACCESSORS + + // Expose these from NumberlikeArray directly. +- NumberlikeArray::getCapacity; +- NumberlikeArray::getLength; ++ using NumberlikeArray::getCapacity; ++ using NumberlikeArray::getLength; + + /* Returns the requested block, or 0 if it is beyond the length (as if + * the number had 0s infinitely to the left). */ +--- a/BigUnsignedInABase.hh ++++ b/BigUnsignedInABase.hh +@@ -100,8 +100,8 @@ public: + Base getBase() const { return base; } + + // Expose these from NumberlikeArray directly. +- NumberlikeArray::getCapacity; +- NumberlikeArray::getLength; ++ using NumberlikeArray::getCapacity; ++ using NumberlikeArray::getLength; + + /* Returns the requested digit, or 0 if it is beyond the length (as if + * the number had 0s infinitely to the left). */ diff --git a/recipes/bigint/all/test_package/CMakeLists.txt b/recipes/bigint/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..301bd00b111ce --- /dev/null +++ b/recipes/bigint/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(bigint REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE bigint::bigint) diff --git a/recipes/bigint/all/test_package/conanfile.py b/recipes/bigint/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/bigint/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bigint/all/test_package/test_package.cpp b/recipes/bigint/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..b5ce60fe98277 --- /dev/null +++ b/recipes/bigint/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include + +#include + +int main() { + BigInteger a = 65536; + std::cout << a << "^8 = " << a * a * a * a * a * a * a * a << std::endl; + return 0; +} diff --git a/recipes/bigint/all/test_v1_package/CMakeLists.txt b/recipes/bigint/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d1ec33823d2ba --- /dev/null +++ b/recipes/bigint/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bigint REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE bigint::bigint) diff --git a/recipes/bigint/all/test_v1_package/conanfile.py b/recipes/bigint/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/bigint/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bigint/config.yml b/recipes/bigint/config.yml new file mode 100644 index 0000000000000..03ea2082495cf --- /dev/null +++ b/recipes/bigint/config.yml @@ -0,0 +1,3 @@ +versions: + "2010.04.30": + folder: all diff --git a/recipes/binutils/all/conandata.yml b/recipes/binutils/all/conandata.yml new file mode 100644 index 0000000000000..b7a4dea94feef --- /dev/null +++ b/recipes/binutils/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "2.38": # 2022-02-09 + url: "https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.gz" + sha256: "b3f1dc5b17e75328f19bd88250bee2ef9f91fc8cbb7bd48bdb31390338636052" + "2.37": + url: "https://ftp.gnu.org/gnu/binutils/binutils-2.37.tar.gz" + sha256: "c44968b97cd86499efbc4b4ab7d98471f673e5414c554ef54afa930062dbbfcb" +patches: + "2.38": + - patch_file: "patches/2.38-0001-no-texinfo.patch" diff --git a/recipes/binutils/all/conanfile.py b/recipes/binutils/all/conanfile.py new file mode 100644 index 0000000000000..524749a89efb5 --- /dev/null +++ b/recipes/binutils/all/conanfile.py @@ -0,0 +1,516 @@ +from conan import ConanFile +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.files import get, rmdir, rm, copy, apply_conandata_patches, export_conandata_patches +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc +from conan.tools.layout import basic_layout + +import os +import re +import typing +import unittest + + +required_conan_version = ">=1.52.0" + + +# This recipe includes a selftest to test conversion of os/arch to triplets (and vice verse) +# Run it using `python -m unittest conanfile.py` + + +class BinutilsConan(ConanFile): + name = "binutils" + description = "The GNU Binutils are a collection of binary tools." + license = "GPL-2.0-or-later" + url = "https://github.com/conan-io/conan-center-index/" + homepage = "https://www.gnu.org/software/binutils" + topics = ("binutils", "ld", "linker", "as", "assembler", "objcopy", "objdump") + settings = "os", "arch", "compiler", "build_type" + + _PLACEHOLDER_TEXT = "__PLACEHOLDER__" + + options = { + "multilib": [True, False], + "with_libquadmath": [True, False], + "target_arch": "ANY", + "target_os": "ANY", + "target_triplet": "ANY", + "prefix": "ANY", + } + + default_options = { + "multilib": True, + "with_libquadmath": True, + "target_arch": _PLACEHOLDER_TEXT, # Initialized in configure, checked in validate + "target_os": _PLACEHOLDER_TEXT, # Initialized in configure, checked in validate + "target_triplet": _PLACEHOLDER_TEXT, # Initialized in configure, checked in validate + "prefix": _PLACEHOLDER_TEXT, # Initialized in configure (NOT config_options, because it depends on target_{arch,os}) + } + + def layout(self): + basic_layout(self, src_folder="src") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _settings_target(self): + return getattr(self, "settings_target", None) or self.settings + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def configure(self): + if self.options.target_triplet == self._PLACEHOLDER_TEXT: + if self.options.target_arch == self._PLACEHOLDER_TEXT: + # If target triplet and target arch are not set, initialize it from the target settings + self.options.target_arch = str(self._settings_target.arch) + if self.options.target_os == self._PLACEHOLDER_TEXT: + # If target triplet and target os are not set, initialize it from the target settings + self.options.target_os = str(self._settings_target.os) + # Initialize the target_triplet from the target arch and target os + self.options.target_triplet = _GNUTriplet.from_archos(_ArchOs(arch=str(self.options.target_arch), os=str(self.options.target_os), extra=dict(self._settings_target.values_list))).triplet + else: + gnu_triplet_obj = _GNUTriplet.from_text(str(self.options.target_triplet)) + archos = _ArchOs.from_triplet(gnu_triplet_obj) + if self.options.target_arch == self._PLACEHOLDER_TEXT: + # If target arch is not set, deduce it from the target triplet + self.options.target_arch = archos.arch + if self.options.target_os == self._PLACEHOLDER_TEXT: + # If target arch is not set, deduce it from the target triplet + self.options.target_os = archos.os + + if self.options.prefix == self._PLACEHOLDER_TEXT: + self.options.prefix = f"{self.options.target_triplet}-" + + self.output.info(f"binutils:target_arch={self.options.target_arch}") + self.output.info(f"binutils:target_os={self.options.target_os}") + self.output.info(f"binutils:target_triplet={self.options.target_triplet}") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration("This recipe does not support building binutils by this compiler") + + if self.options.target_os == "Macos": + raise ConanInvalidConfiguration("cci does not support building binutils for Macos since binutils is degraded there (no as/ld + armv8 does not build)") + + # Check whether the actual target_arch and target_os option are valid (they should be in settings.yml) + # FIXME: does there exist a stable Conan API to accomplish this? + if self.options.target_arch not in self.settings.arch.values_range: + raise ConanInvalidConfiguration(f"target_arch={self.options.target_arch} is invalid (possibilities={self.settings.arch.values_range})") + if self.options.target_os not in self.settings.os.values_range: + raise ConanInvalidConfiguration(f"target_os={self.options.target_os} is invalid (possibilities={self.settings.os.values_range})") + + target_archos = _ArchOs(str(self.options.target_arch), str(self.options.target_os)) + target_gnu_triplet = _GNUTriplet.from_text(str(self.options.target_triplet)) + if not target_archos.is_compatible(target_gnu_triplet): + suggested_gnu_triplet = _GNUTriplet.from_archos(target_archos) + suggested_archos = _ArchOs.from_triplet(target_gnu_triplet) + raise ConanInvalidConfiguration(f"target_arch={target_archos.arch}/target_os={target_archos.os} is not compatible with {target_gnu_triplet.triplet}. Change target triplet to {suggested_gnu_triplet.triplet}, or change target_arch/target_os to {suggested_archos.arch}/{suggested_archos.os}.") + + # Check, when used as build requirement in a cross build, whether the target arch/os agree + settings_target = getattr(self, "settings_target", None) + if settings_target is not None: + if self.options.target_arch != settings_target.arch: + raise ConanInvalidConfiguration(f"binutils:target_arch={self.options.target_arch} does not match target architecture={settings_target.arch}") + if self.options.target_os != settings_target.os: + raise ConanInvalidConfiguration(f"binutils:target_os={self.options.target_os} does not match target os={settings_target.os}") + + def package_id(self): + del self.info.settings.compiler + + def _raise_unsupported_configuration(self, key, value): + raise ConanInvalidConfiguration(f"This configuration is unsupported by this conan recip. Please consider adding support. ({key}={value})") + + def build_requirements(self): + if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path"): + self.build_requires("msys2/cci.latest") + + def requirements(self): + self.requires("zlib/1.2.13") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination=self.source_folder) + + @property + def _exec_prefix(self): + return os.path.join("bin", "exec_prefix") + + def generate(self): + yes_no = lambda tf : "yes" if tf else "no" + tc = AutotoolsToolchain(self) + tc.configure_args.append("--disable-nls") + tc.configure_args.append(f"--target={self.options.target_triplet}") + tc.configure_args.append(f"--enable-multilib={yes_no(self.options.multilib)}") + tc.configure_args.append(f"--with-zlib={self.deps_cpp_info['zlib'].rootpath}") + tc.configure_args.append(f"--program-prefix={self.options.prefix}") + tc.configure_args.append("--exec_prefix=/bin/exec_prefix") + tc.generate() + + def build(self): + apply_conandata_patches(self) + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + autotools = Autotools(self) + autotools.install() + + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) + copy( + self, + pattern="COPYING*", + dst=os.path.join(self.package_folder, "licenses"), + src=self.source_folder, + keep_path=False, + ) + + def package_info(self): + target_bindir = os.path.join(self._exec_prefix, str(self.options.target_triplet), "bin") + self.cpp_info.bindirs = ["bin", target_bindir] + + absolute_target_bindir = os.path.join(self.package_folder, target_bindir) + + # v1 exports + bindir = os.path.join(self.package_folder, "bin") + self.env_info.PATH.append(bindir) + self.env_info.PATH.append(absolute_target_bindir) + self.output.info(f"GNU triplet={self.options.target_triplet}") + self.user_info.gnu_triplet = self.options.target_triplet + self.user_info.prefix = self.options.prefix + self.output.info(f"executable prefix={self.options.prefix}") + + # Add recipe path to enable running the self test in the test package. + # Don't use this property in production code. It's unsupported. + self.user_info.recipe_path = os.path.realpath(__file__) + + +class _ArchOs: + def __init__(self, arch: str, os: str, extra: typing.Optional[typing.Dict[str, str]]=None): + self.arch = arch + self.os = os + self.extra = extra if extra is not None else {} + + def is_compatible(self, triplet: "_GNUTriplet") -> bool: + return self.arch in self.calculate_archs(triplet) and self.os == self.calculate_os(triplet) + + _MACHINE_TO_ARCH_LUT = { + "arm": "armv7", + "aarch64": ("armv8", "armv9"), + "i386": "x86", + "i486": "x86", + "i586": "x86", + "i686": "x86", + "x86_64": "x86_64", + "riscv32": "riscv32", + "riscv64": "riscv64", + } + + @classmethod + def calculate_archs(cls, triplet: "_GNUTriplet") -> typing.Tuple[str]: + if triplet.machine == "arm": + archs = "armv7" + ("hf" if "hf" in triplet.abi else "") + else: + archs = cls._MACHINE_TO_ARCH_LUT[triplet.machine] + if isinstance(archs, str): + archs = (archs, ) + return archs + + _GNU_OS_TO_OS_LUT = { + None: "baremetal", + "android": "Android", + "mingw32": "Windows", + "linux": "Linux", + "freebsd": "FreeBSD", + "darwin": "Macos", + "none": "baremetal", + "unknown": "baremetal", + } + + @classmethod + def calculate_os(cls, triplet: "_GNUTriplet") -> str: + if triplet.abi and "android" in triplet.abi: + return "Android" + return cls._GNU_OS_TO_OS_LUT[triplet.os] + + @classmethod + def from_triplet(cls, triplet: "_GNUTriplet") -> "_ArchOs": + archs = cls.calculate_archs(triplet) + _os = cls.calculate_os(triplet) + extra = {} + + if _os == "Android" and triplet.abi: + m = re.match(".*([0-9]+)", triplet.abi) + if m: + extra["os.api_level"] = m.group(1) + + # Assume first architecture + return cls(arch=archs[0], os=_os, extra=extra) + + def __eq__(self, other) -> bool: + if type(self) != type(other): + return False + if not (self.arch == other.arch and self.os == other.os): + return False + self_extra_keys = set(self.extra.keys()) + other_extra_keys = set(other.extra.keys()) + if (self_extra_keys - other_extra_keys) or (other_extra_keys - self_extra_keys): + return False + return True + + def __repr__(self) -> str: + return f"<{type(self).__name__}:arch='{self.arch}',os='{self.os}',extra={self.extra}>" + + +class _GNUTriplet: + def __init__(self, machine: str, vendor: typing.Optional[str], os: typing.Optional[str], abi: typing.Optional[str]): + self.machine = machine + self.vendor = vendor + self.os = os + self.abi = abi + + @property + def triplet(self) -> str: + return "-".join(p for p in (self.machine, self.vendor, self.os, self.abi) if p) + + @classmethod + def from_archos(cls, archos: _ArchOs) -> "_GNUTriplet": + gnu_machine = cls.calculate_gnu_machine(archos) + gnu_vendor = cls.calculate_gnu_vendor(archos) + gnu_os = cls.calculate_gnu_os(archos) + gnu_abi = cls.calculate_gnu_abi(archos) + + return cls(gnu_machine, gnu_vendor, gnu_os, gnu_abi) + + @classmethod + def from_text(cls, text: str) -> "_GNUTriplet": + gnu_machine: str + gnu_vendor: typing.Optional[str] + gnu_os: typing.Optional[str] + gnu_abi: typing.Optional[str] + + parts = text.split("-") + if not 2 <= len(parts) <= 4: + raise ValueError("Wrong number of GNU triplet components. Count must lie in range [2, 4]. format=$machine(-$vendor)?(-$os)?(-$abi)?") + + gnu_machine = parts[0] + parts = parts[1:] + if any(v in parts[-1] for v in cls.KNOWN_GNU_ABIS): + gnu_abi = parts[-1] + parts = parts[:-1] + else: + gnu_abi = None + + if len(parts) == 2: + gnu_vendor = parts[0] + gnu_os = parts[1] + elif len(parts) == 1: + if parts[0] in _GNUTriplet.UNKNOWN_OS_ALIASES: + gnu_vendor = None + gnu_os = parts[0] + elif parts[0] in cls.OS_TO_GNU_OS_LUT.values(): + gnu_vendor = None + gnu_os = parts[0] + else: + gnu_vendor = parts[0] + gnu_os = None + else: + gnu_vendor = None + gnu_os = None + + return cls(gnu_machine, gnu_vendor, gnu_os, gnu_abi) + + + ARCH_TO_GNU_MACHINE_LUT = { + "x86": "i686", + "x86_64": "x86_64", + "armv7": "arm", + "armv7hf": "arm", + "armv8": "aarch64", + "riscv32": "riscv32", + "riscv64": "riscv64", + } + + @classmethod + def calculate_gnu_machine(cls, archos: _ArchOs) -> str: + return cls.ARCH_TO_GNU_MACHINE_LUT[archos.arch] + + UNKNOWN_OS_ALIASES = ( + "unknown", + "none", + ) + + OS_TO_GNU_OS_LUT = { + "baremetal": "none", + "Android": "linux", + "FreeBSD": "freebsd", + "Linux": "linux", + "Macos": "darwin", + "Windows": "mingw32", + } + + @classmethod + def calculate_gnu_os(cls, archos: _ArchOs) -> typing.Optional[str]: + if archos.os in ("baremetal", ): + if archos.arch in ("x86", "x86_64", ): + return None + elif archos.arch in ("riscv32", "riscv64"): + return "unknown" + return cls.OS_TO_GNU_OS_LUT[archos.os] + + OS_TO_GNU_VENDOR_LUT = { + "Windows": "w64", + "baremetal": None, + } + + @classmethod + def calculate_gnu_vendor(cls, archos: _ArchOs) -> typing.Optional[str]: + if archos.os in ("baremetal", "Android"): + return None + if archos.os in ("Macos", "iOS", "tvOS", "watchOS"): + return "apple" + return cls.OS_TO_GNU_VENDOR_LUT.get(archos.os, "pc") + + @classmethod + def calculate_gnu_abi(self, archos: _ArchOs) -> typing.Optional[str]: + if archos.os in ("baremetal", ): + if archos.arch in ("armv7",): + return "eabi" + else: + return "elf" + abi_start = None + if archos.os in ("Linux", ): + abi_start = "gnu" + elif archos.os in ("Android", ): + abi_start = "android" + else: + return None + if archos.arch in ("armv7",): + abi_suffix = "eabi" + elif archos.arch in ("armv7hf",): + abi_suffix = "eabihf" + else: + abi_suffix = "" + if archos.os in ("Android", ): + abi_suffix += str(archos.extra.get("os.api_level", "")) + + return abi_start + abi_suffix + + KNOWN_GNU_ABIS = ( + "android", + "gnu", + "eabi", + "elf", + ) + + def __eq__(self, other: object) -> bool: + if type(self) != type(other): + return False + other: "_GNUTriplet" + return self.machine == other.machine and self.vendor == other.vendor and self.os == other.os and self.abi == other.abi + + def __repr__(self) -> str: + def x(v): + if v is None: + return None + return f"'{v}'" + return f"<{type(self).__name__}:machine={x(self.machine)},vendor={x(self.vendor)},os={x(self.os)},abi={x(self.abi)}>" + + +class _TestOsArch2GNUTriplet(unittest.TestCase): + def test_linux_x86(self): + archos = _ArchOs(arch="x86", os="Linux") + self._test_osarch_to_gnutriplet(archos, _GNUTriplet(machine="i686", vendor="pc", os="linux", abi="gnu"), "i686-pc-linux-gnu") + self.assertEqual(_ArchOs("x86", "Linux"), _ArchOs.from_triplet(_GNUTriplet.from_text("i386-linux"))) + self.assertEqual(_ArchOs("x86", "Linux"), _ArchOs.from_triplet(_GNUTriplet.from_text("i686-linux"))) + self.assertEqual(_GNUTriplet("i486", None, "linux", None), _GNUTriplet.from_text("i486-linux")) + self.assertTrue(archos.is_compatible(_GNUTriplet.from_text("i486-linux"))) + self.assertTrue(archos.is_compatible(_GNUTriplet.from_text("i486-linux-gnu"))) + + def test_linux_x86_64(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="x86_64", os="Linux"), _GNUTriplet(machine="x86_64", vendor="pc", os="linux", abi="gnu"), "x86_64-pc-linux-gnu") + + def test_linux_armv7(self): + archos = _ArchOs(arch="armv7", os="Linux") + self._test_osarch_to_gnutriplet(archos, _GNUTriplet(machine="arm", vendor="pc", os="linux", abi="gnueabi"), "arm-pc-linux-gnueabi") + self.assertEqual(_GNUTriplet("arm", "pc", None, "gnueabi"), _GNUTriplet.from_text("arm-pc-gnueabi")) + self.assertEqual(_GNUTriplet("arm", "pc", None, "eabi"), _GNUTriplet.from_text("arm-pc-eabi")) + self.assertEqual(_ArchOs("armv7hf", "baremetal"), _ArchOs.from_triplet(_GNUTriplet.from_text("arm-pc-gnueabihf"))) + self.assertTrue(archos.is_compatible(_GNUTriplet.from_text("arm-linux-gnueabi"))) + self.assertTrue(archos.is_compatible(_GNUTriplet.from_text("arm-linux-eabi"))) + self.assertFalse(archos.is_compatible(_GNUTriplet.from_text("arm-pc-linux-gnueabihf"))) + self.assertFalse(archos.is_compatible(_GNUTriplet.from_text("arm-pc-gnueabihf"))) + + def test_linux_armv7hf(self): + archos = _ArchOs(arch="armv7hf", os="Linux") + self._test_osarch_to_gnutriplet(archos, _GNUTriplet(machine="arm", vendor="pc", os="linux", abi="gnueabihf"), "arm-pc-linux-gnueabihf") + self.assertEqual(_GNUTriplet("arm", "pc", None, "gnueabihf"), _GNUTriplet.from_text("arm-pc-gnueabihf")) + self.assertEqual(_ArchOs("armv7", "baremetal"), _ArchOs.from_triplet(_GNUTriplet.from_text("arm-pc-gnueabi"))) + self.assertFalse(archos.is_compatible(_GNUTriplet.from_text("arm-linux-gnueabi"))) + self.assertFalse(archos.is_compatible(_GNUTriplet.from_text("arm-linux-eabi"))) + self.assertTrue(archos.is_compatible(_GNUTriplet.from_text("arm-pc-linux-gnueabihf"))) + self.assertFalse(archos.is_compatible(_GNUTriplet.from_text("arm-pc-gnueabihf"))) + + def test_windows_x86(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="x86", os="Windows"), _GNUTriplet(machine="i686", vendor="w64", os="mingw32", abi=None), "i686-w64-mingw32") + + def test_windows_x86_64(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="x86_64", os="Windows"), _GNUTriplet(machine="x86_64", vendor="w64", os="mingw32", abi=None), "x86_64-w64-mingw32") + + def test_macos_x86_64(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="x86_64", os="Macos"), _GNUTriplet(machine="x86_64", vendor="apple", os="darwin", abi=None), "x86_64-apple-darwin") + + def test_freebsd_x86_64(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="x86_64", os="FreeBSD"), _GNUTriplet(machine="x86_64", vendor="pc", os="freebsd", abi=None), "x86_64-pc-freebsd") + + def test_baremetal_x86(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="x86", os="baremetal"), _GNUTriplet(machine="i686", vendor=None, os=None, abi="elf"), "i686-elf") + + def test_baremetal_x86_64(self): + archos = _ArchOs(arch="x86_64", os="baremetal") + self._test_osarch_to_gnutriplet(archos, _GNUTriplet(machine="x86_64", vendor=None, os=None, abi="elf"), "x86_64-elf") + self.assertTrue(archos.is_compatible(_GNUTriplet.from_text("x86_64-elf"))) + self.assertTrue(archos.is_compatible(_GNUTriplet.from_text("x86_64-none-elf"))) + self.assertTrue(archos.is_compatible(_GNUTriplet.from_text("x86_64-unknown-elf"))) + + def test_baremetal_armv7(self): + archos = _ArchOs(arch="armv7", os="baremetal") + self._test_osarch_to_gnutriplet(archos, _GNUTriplet(machine="arm", vendor=None, os="none", abi="eabi"), "arm-none-eabi") + self.assertTrue(archos.is_compatible(_GNUTriplet.from_text("arm-none-eabi"))) + + def test_baremetal_armv8(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="armv8", os="baremetal"), _GNUTriplet(machine="aarch64", vendor=None, os="none", abi="elf"), "aarch64-none-elf") + + def test_baremetal_riscv32(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="riscv32", os="baremetal"), _GNUTriplet(machine="riscv32", vendor=None, os="unknown", abi="elf"), "riscv32-unknown-elf") + + def test_baremetal_riscv64(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="riscv64", os="baremetal"), _GNUTriplet(machine="riscv64", vendor=None, os="unknown", abi="elf"), "riscv64-unknown-elf") + + def test_android_armv7(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="armv7", os="Android", extra={"os.api_level": "31"}), _GNUTriplet(machine="arm", vendor=None, os="linux", abi="androideabi31"), "arm-linux-androideabi31") + + def test_android_armv8(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="armv8", os="Android", extra={"os.api_level": "24"}), _GNUTriplet(machine="aarch64", vendor=None, os="linux", abi="android24"), "aarch64-linux-android24") + + def test_android_x86(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="x86", os="Android", extra={"os.api_level": "16"}), _GNUTriplet(machine="i686", vendor=None, os="linux", abi="android16"), "i686-linux-android16") + + def test_android_x86_64(self): + self._test_osarch_to_gnutriplet(_ArchOs(arch="x86_64", os="Android", extra={"os.api_level": "29"}), _GNUTriplet(machine="x86_64", vendor=None, os="linux", abi="android29"), "x86_64-linux-android29") + self.assertEqual(_ArchOs(arch="x86_64", os="Android", extra={"os.api_level": "25"}), _ArchOs.from_triplet(_GNUTriplet.from_text("x86_64-linux-android29"))) + + def _test_osarch_to_gnutriplet(self, archos: _ArchOs, gnuobj_ref: _GNUTriplet, triplet_ref: str): + gnuobj = _GNUTriplet.from_archos(archos) + self.assertEqual(gnuobj_ref, gnuobj) + self.assertEqual(triplet_ref, gnuobj.triplet) + self.assertEqual(gnuobj_ref, _GNUTriplet.from_text(triplet_ref)) + # self.assertEqual(triplet_ref, tools.get_gnu_triplet(archos.os, archos.arch, compiler="gcc")) diff --git a/recipes/binutils/all/patches/2.38-0001-no-texinfo.patch b/recipes/binutils/all/patches/2.38-0001-no-texinfo.patch new file mode 100644 index 0000000000000..1e0698965c0de --- /dev/null +++ b/recipes/binutils/all/patches/2.38-0001-no-texinfo.patch @@ -0,0 +1,20 @@ +--- gas/Makefile.in ++++ gas/Makefile.in +@@ -1778,7 +1778,7 @@ + check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU + check: check-recursive +-all-am: Makefile $(INFO_DEPS) $(PROGRAMS) $(SCRIPTS) $(MANS) config.h ++all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(MANS) config.h + installdirs: installdirs-recursive + installdirs-am: + for dir in "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)"; do \ +@@ -1854,7 +1854,7 @@ info: info-recursive + + info-am: $(INFO_DEPS) info-local + +-install-data-am: install-data-local install-info-am install-man ++install-data-am: install-man + + install-dvi: install-dvi-recursive + diff --git a/recipes/binutils/all/test_package/Linux-armv7.s b/recipes/binutils/all/test_package/Linux-armv7.s new file mode 100644 index 0000000000000..88c05d0d0aac9 --- /dev/null +++ b/recipes/binutils/all/test_package/Linux-armv7.s @@ -0,0 +1,23 @@ + .arm + .arch armv7-a + + .global _start + + .text +_start: + # write(1, message, 14) + mov r7, #4 // system call 4 is write + mov r0, #1 // file handle 1 is stdout + adr r1, message // address of string to output + mov r2, #14 // number of bytes + swi #0 // do syscall into os (supervisor call) + + # exit(0) + mov r7, #1 // system call 1 is exit + mov r0, #0 // we want return code 0 + swi #0 // do syscall into os (supervisor call) + + .align 2 + +message: + .ascii "Hello, world!\n" diff --git a/recipes/binutils/all/test_package/Linux-armv8.s b/recipes/binutils/all/test_package/Linux-armv8.s new file mode 100644 index 0000000000000..c744b1ba7ea47 --- /dev/null +++ b/recipes/binutils/all/test_package/Linux-armv8.s @@ -0,0 +1,19 @@ + .global _start + + .text +_start: + # write(1, message, 14) + mov x8, 64 // system call 64 is write + mov x0, 1 // file handle 1 is stdout + mov x1, message // address of string to output + mov x2, 14 // number of bytes + svc 0 // do syscall into os (supervisor call) + + # exit(0) + mov x8, 93 // system call 93 is exit + mov x0, 0 // we want return code 0 + svc 0 // do syscall into os (supervisor call) + + .section .rodata +message: + .ascii "Hello, world!\n" diff --git a/recipes/binutils/all/test_package/Linux-riscv.s b/recipes/binutils/all/test_package/Linux-riscv.s new file mode 100644 index 0000000000000..21d80984c1b16 --- /dev/null +++ b/recipes/binutils/all/test_package/Linux-riscv.s @@ -0,0 +1,19 @@ + .global _start + + .text +_start: + # write(1, message, 14) + addi a7, x0, 64 # system call 64 is write + addi a0, x0, 1 # file handle 1 is stdout + la a1, message # address of string to output + addi a2, x0, 14 # number of bytes + ecall # do syscall into os (environment call) + + # exit(0) + addi a7, x0, 93 # system call 93 is exit + addi a0, x0, 0 # we want return code 0 + ecall # do syscall into os (environment call) + + .data +message: + .ascii "Hello, world!\n" diff --git a/recipes/binutils/all/test_package/Linux-x86.s b/recipes/binutils/all/test_package/Linux-x86.s new file mode 100644 index 0000000000000..b932e52148e99 --- /dev/null +++ b/recipes/binutils/all/test_package/Linux-x86.s @@ -0,0 +1,20 @@ + .global _start + + .text +_start: + # write(1, message, 14) + mov $4, %eax # system call 4 is write + mov $1, %ebx # file handle 1 is stdout + mov $message, %ecx # address of string to output + mov $14, %edx # number of bytes + int $0x80 # do syscall into os + + # exit(0) + mov $1, %eax # system call 1 is exit + xor %ebx, %ebx # we want return code 0 + int $0x80 # do syscall into os + + .data + +message: + .ascii "Hello, world!\n" diff --git a/recipes/binutils/all/test_package/Linux-x86_64.s b/recipes/binutils/all/test_package/Linux-x86_64.s new file mode 100644 index 0000000000000..b2bcbb46dbc56 --- /dev/null +++ b/recipes/binutils/all/test_package/Linux-x86_64.s @@ -0,0 +1,20 @@ + .global _start + + .text +_start: + # write(1, message, 14) + mov $1, %rax # system call 1 is write + mov $1, %rdi # file handle 1 is stdout + mov $message, %rsi # address of string to output + mov $14, %rdx # number of bytes + syscall # do syscall into os + + # exit(0) + mov $60, %eax # system call 60 is exit + xor %rdi, %rdi # we want return code 0 + syscall # do syscall into os + + .section .data + +message: + .ascii "Hello, world!\n" diff --git a/recipes/binutils/all/test_package/Windows-kernel32.def b/recipes/binutils/all/test_package/Windows-kernel32.def new file mode 100644 index 0000000000000..88e93c499b32b --- /dev/null +++ b/recipes/binutils/all/test_package/Windows-kernel32.def @@ -0,0 +1,7 @@ +; The Windows test_package needs the following symbols from kernel32.dll + +LIBRARY kernel32 +EXPORTS + GetStdHandle + WriteConsoleA + ExitProcess diff --git a/recipes/binutils/all/test_package/Windows-x86.s b/recipes/binutils/all/test_package/Windows-x86.s new file mode 100644 index 0000000000000..8b6b27e91288f --- /dev/null +++ b/recipes/binutils/all/test_package/Windows-x86.s @@ -0,0 +1,23 @@ + .section .rdata,"dr" + +output: .ascii "Hello, world!\n" + + .text + .globl _start + +_start: + # GetStdHandle(STD_OUTPUT_HANDLE) + pushl $-11 # STD_OUTPUT_HANDLE (=COUNOUT$) + call _GetStdHandle # Retrieve console handle + + # WriteConsoleA($handle, output, 14, NULL, 0) + pushl $0 # lpReserved + pushl $0 # lpNumberOfCharsWritten (optional) + pushl $14 # nNumberOfCharsToWrite + pushl $output # lpBuffer + pushl %eax # hConsoleOutput + call _WriteConsoleA # Write to console + + # ExitProcess(0) + pushl $0 # Return 0 errorcode + call _ExitProcess # Exit process diff --git a/recipes/binutils/all/test_package/Windows-x86_64.s b/recipes/binutils/all/test_package/Windows-x86_64.s new file mode 100644 index 0000000000000..9d17a6a37a336 --- /dev/null +++ b/recipes/binutils/all/test_package/Windows-x86_64.s @@ -0,0 +1,26 @@ + .section .rdata,"dr" + +output: .ascii "Hello, world!\n" + + .text + .globl _start + +_start: + # GetStdHandle(STD_OUTPUT_HANDLE) + mov $-11, %rcx # STD_OUTPUT_HANDLE (=COUNOUT$) + movq __imp_GetStdHandle(%rip), %rax # Get relocatable address of __imp_GetStdHandle + call *%rax # Retrieve console handle + + # WriteConsoleA($handle, "Hello world!\n", 14, NULL, 0) + pushq $0 # lpReserved + movq $0, %r9 # lpNumberOfCharsWritten (optional) + movq $14, %r8 # nNumberOfCharsToWrite + leaq output(%rip), %rdx # lpBuffer + movq %rax, %rcx # hConsoleOutput + movq __imp_WriteConsoleA(%rip), %rax # Get relocatable address of __imp_WriteConsoleA + call *%rax # Write to console + + # ExitProcess(0) + xorq %rcx, %rcx # Return 0 errorcode + movq __imp_ExitProcess(%rip), %rax # Get relocatable address of __imp__ExitProcess + call *%rax # Exit process diff --git a/recipes/binutils/all/test_package/conanfile.py b/recipes/binutils/all/test_package/conanfile.py new file mode 100644 index 0000000000000..6b7ddeed01c09 --- /dev/null +++ b/recipes/binutils/all/test_package/conanfile.py @@ -0,0 +1,113 @@ +from conans import ConanFile, tools +from io import StringIO +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _target_arch(self): + return str(self.options["binutils"].target_arch) + + @property + def _target_os(self): + return str(self.options["binutils"].target_os) + + @property + def _test_linker_args(self): + args = [] + if self._target_os == "Windows": + args.extend(["--subsystem", "console", f"{self.build_folder}/lib/libkernel32.a"]) + return args + + @property + def _test_package_assembly_source(self): + part_arch = self._target_arch + if "armv7" in part_arch: + part_arch = "armv7" + elif part_arch in ("riscv32", "riscv64"): + part_arch = "riscv" + return os.path.join(self.source_folder, f"{self._target_os}-{part_arch}.s") + + def _append_gnu_triplet(self, exe): + return f"{self.deps_user_info['binutils'].prefix}{exe}" + + def build(self): + if not tools.cross_building(self): + + if not os.path.isfile(self._test_package_assembly_source): + self.output.warn(f"Missing {self._test_package_assembly_source}.\ntest_package does not support this target os/arch. Please consider adding it. (It's a great learning experience)") + else: + tools.mkdir(os.path.join(self.build_folder, "bin")) + tools.mkdir(os.path.join(self.build_folder, "lib")) + + gas = self._append_gnu_triplet("as") + ld = self._append_gnu_triplet("ld") + extension = "" + if self._target_os == "Windows": + extension = ".exe" + + # Create minimum import library for kernel32.dll + dlltool = f"{self.deps_user_info['binutils'].gnu_triplet}-dlltool" + + dlltool_args = [dlltool, "--input-def", f"{self.source_folder}/Windows-kernel32.def", "--output-lib", f"{self.build_folder}/lib/libkernel32.a"] + self.run(" ".join(dlltool_args)) + + + assembler_args = [gas, self._test_package_assembly_source, "-o", f"{self.build_folder}/object.o"] + linker_args = [ld, f"{self.build_folder}/object.o", "-o", f"{self.build_folder}/bin/test_package{extension}"] + self._test_linker_args + + self.run(" ".join(assembler_args)) + self.run(" ".join(linker_args)) + + def _can_run_target(self): + if self._settings_build.os != self._target_os: + return False + if self._settings_build.arch == "x86_64": + return self._target_arch in ("x86", "x86_64") + return self._settings_build.arch == self._target_arch + + def _has_as(self): + if self._target_os in ("Macos"): + return False + return True + + def _has_ld(self): + if self._target_os in ("Macos"): + return False + return True + + def test(self): + # Run selftest (conversion between conan os/arch <=> gnu triplet) + with tools.chdir(os.path.dirname(self.deps_user_info["binutils"].recipe_path)): + self.run(f"python -m unittest {os.path.basename(self.deps_user_info['binutils'].recipe_path)} --verbose") + + if not tools.cross_building(self): + if self._can_run_target() and os.path.isfile(self._test_package_assembly_source): + output = StringIO() + self.run(os.path.join("bin", "test_package"), output=output) + text = output.getvalue() + print(text) + assert "Hello, world!" in text + + bins = ["ar", "nm", "objcopy", "objdump", "ranlib", "readelf", "strip"] + if self._has_as(): + bins.append("as") + if self._has_ld(): + bins.append("ld") + + for bin in bins: + bin_path = os.path.realpath(tools.which(bin)) + self.output.info(f"Found {bin} at {bin_path}") + assert bin_path.startswith(self.deps_cpp_info["binutils"].rootpath) + + output = StringIO() + self.run("{} --version".format(bin_path), run_environment=True, output=output) + text = output.getvalue() + print(text) + assert str(self.requires["binutils"].ref.version) in text diff --git a/recipes/binutils/config.yml b/recipes/binutils/config.yml new file mode 100644 index 0000000000000..f7cce7c207880 --- /dev/null +++ b/recipes/binutils/config.yml @@ -0,0 +1,5 @@ +versions: + "2.38": + folder: all + "2.37": + folder: all diff --git a/recipes/bison/all/conandata.yml b/recipes/bison/all/conandata.yml index b39f9af2ec494..67b0780a7f658 100644 --- a/recipes/bison/all/conandata.yml +++ b/recipes/bison/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "3.8.2": + url: "https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.gz" + sha256: "06c9e13bdf7eb24d4ceb6b59205a4f67c2c7e7213119644430fe82fbd14a0abb" + "3.7.6": + url: "https://ftp.gnu.org/gnu/bison/bison-3.7.6.tar.gz" + sha256: "69dc0bb46ea8fc307d4ca1e0b61c8c355eb207d0b0c69f4f8462328e74d7b9ea" "3.7.1": url: "https://ftp.gnu.org/gnu/bison/bison-3.7.1.tar.gz" sha256: "1dd952839cf0d5a8178c691eeae40dc48fa50d18dcce648b1ad9ae0195367d13" @@ -6,6 +12,20 @@ sources: url: "https://ftp.gnu.org/gnu/bison/bison-3.5.3.tar.gz" sha256: "34e201d963156618a0ea5bc87220f660a1e08403dd3c7c7903d4f38db3f40039" patches: + "3.8.2": + - patch_file: "patches/0001-3.8-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-3.7.6-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch" + base_path: "source_subfolder" + - patch_file: "patches/0005-gnulib-limit-search-range-of-_setmaxstdio.patch" + base_path: "source_subfolder" + "3.7.6": + - patch_file: "patches/0001-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-3.7.6-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch" + base_path: "source_subfolder" + - patch_file: "patches/0005-gnulib-limit-search-range-of-_setmaxstdio.patch" + base_path: "source_subfolder" "3.7.1": - patch_file: "patches/0001-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch" base_path: "source_subfolder" @@ -13,6 +33,8 @@ patches: base_path: "source_subfolder" - patch_file: "patches/0005-gnulib-limit-search-range-of-_setmaxstdio.patch" base_path: "source_subfolder" + - patch_file: "patches/0006-dont-link-bison-against-libreadline.patch" + base_path: "source_subfolder" "3.5.3": - patch_file: "patches/0001-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch" base_path: "source_subfolder" diff --git a/recipes/bison/all/conanfile.py b/recipes/bison/all/conanfile.py index beb51709765ac..86d0e584d5c46 100644 --- a/recipes/bison/all/conanfile.py +++ b/recipes/bison/all/conanfile.py @@ -1,17 +1,20 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from contextlib import contextmanager +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, apply_conandata_patches, replace_in_file +from conans import AutoToolsBuildEnvironment, tools +import contextlib import os +required_conan_version = ">=1.47.0" + class BisonConan(ConanFile): name = "bison" url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.gnu.org/software/bison/" description = "Bison is a general-purpose parser generator" - topics = ("conan", "bison", "parser") + topics = ("bison", "parser") license = "GPL-3.0-or-later" - exports_sources = "patches/**" - settings = "os", "arch", "compiler", "build_type" options = { "fPIC": [True, False], @@ -20,26 +23,17 @@ class BisonConan(ConanFile): "fPIC": True, } + exports_sources = "patches/*" + _autotools = None @property def _source_subfolder(self): return "source_subfolder" - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "bison-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def requirements(self): - self.requires("m4/1.4.18") - - def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH") and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") - if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.2") + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): if self.settings.os == "Windows": @@ -49,11 +43,30 @@ def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd - @contextmanager + def requirements(self): + self.requires("m4/1.4.19") + + def validate(self): + if self.settings.compiler == "Visual Studio" and self.version == "3.8.2": + raise ConanInvalidConfiguration("bison/3.8.2 is not yet ready for Visual Studio, use previous version or open a pull request on https://github.com/conan-io/conan-center-index/pulls") + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + if self.settings.compiler == "Visual Studio": + self.build_requires("automake/1.16.5") + if self.settings.os != "Windows": + self.build_requires("flex/2.6.4") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @contextlib.contextmanager def _build_context(self): if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - build_env = { + with tools.vcvars(self): + env = { "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), "CFLAGS": "-{}".format(self.settings.compiler.runtime), @@ -63,11 +76,15 @@ def _build_context(self): "AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), "RANLIB": ":", } - with tools.environment_append(build_env): + with tools.environment_append(env): yield else: yield + @property + def _datarootdir(self): + return os.path.join(self.package_folder, "res") + def _configure_autotools(self): if self._autotools: return self._autotools @@ -75,11 +92,13 @@ def _configure_autotools(self): args = [ "--enable-relocatable", "--disable-nls", - "--datarootdir={}".format(os.path.join(self.package_folder, "bin", "share").replace("\\", "/")), + "--datarootdir={}".format(os.path.join(self._datarootdir).replace("\\", "/")), ] host, build = None, None if self.settings.os == "Windows": self._autotools.defines.append("_WINDOWS") + if self.settings.compiler == "apple-clang": + args.append("gl_cv_compiler_check_decl_option=") if self.settings.compiler == "Visual Studio": # Avoid a `Assertion Failed Dialog Box` during configure with build_type=Debug # Visual Studio does not support the %n format flag: @@ -93,31 +112,30 @@ def _configure_autotools(self): return self._autotools def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + apply_conandata_patches(self) if self.settings.os == "Windows": # replace embedded unix paths by windows paths - tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), + replace_in_file(self, os.path.join(self._source_subfolder, "Makefile.in"), "echo '#define BINDIR \"$(bindir)\"';", "echo '#define BINDIR \"$(shell cygpath -m \"$(bindir)\")\"';") - tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), + replace_in_file(self, os.path.join(self._source_subfolder, "Makefile.in"), "echo '#define PKGDATADIR \"$(pkgdatadir)\"';", "echo '#define PKGDATADIR \"$(shell cygpath -m \"$(pkgdatadir)\")\"';") - tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), + replace_in_file(self, os.path.join(self._source_subfolder, "Makefile.in"), "echo '#define DATADIR \"$(datadir)\"';", "echo '#define DATADIR \"$(shell cygpath -m \"$(datadir)\")\"';") - tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), + replace_in_file(self, os.path.join(self._source_subfolder, "Makefile.in"), "echo '#define DATAROOTDIR \"$(datarootdir)\"';", "echo '#define DATAROOTDIR \"$(shell cygpath -m \"$(datarootdir)\")\"';") - tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), + replace_in_file(self, os.path.join(self._source_subfolder, "Makefile.in"), "dist_man_MANS = $(top_srcdir)/doc/bison.1", "dist_man_MANS =") - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "yacc.in"), + replace_in_file(self, os.path.join(self._source_subfolder, "src", "yacc.in"), "@prefix@", "${}_ROOT".format(self.name.upper())) - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "yacc.in"), + replace_in_file(self, os.path.join(self._source_subfolder, "src", "yacc.in"), "@bindir@", "${}_ROOT/bin".format(self.name.upper())) @@ -138,16 +156,17 @@ def package(self): os.path.join(self.package_folder, "lib", "y.lib")) def package_info(self): + self.cpp_info.includedirs = [] self.cpp_info.libs = ["y"] - self.output.info('Setting BISON_ROOT environment variable: {}'.format(self.package_folder)) + self.output.info("Setting BISON_ROOT environment variable: {}".format(self.package_folder)) self.env_info.BISON_ROOT = self.package_folder.replace("\\", "/") bindir = os.path.join(self.package_folder, "bin") - self.output.info('Appending PATH environment variable: {}'.format(bindir)) + self.output.info("Appending PATH environment variable: {}".format(bindir)) self.env_info.PATH.append(bindir) - pkgdir = os.path.join(bindir, 'share', 'bison') - self.output.info('Setting the BISON_PKGDATADIR environment variable: {}'.format(pkgdir)) + pkgdir = os.path.join(self._datarootdir, "bison") + self.output.info("Setting the BISON_PKGDATADIR environment variable: {}".format(pkgdir)) self.env_info.BISON_PKGDATADIR = pkgdir # yacc is a shell script, so requires a shell (such as bash) diff --git a/recipes/bison/all/patches/0001-3.8-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch b/recipes/bison/all/patches/0001-3.8-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch new file mode 100644 index 0000000000000..b40517e5083c9 --- /dev/null +++ b/recipes/bison/all/patches/0001-3.8-create_pipe-uses-O_TEXT-not-O_BINARY-mode.patch @@ -0,0 +1,29 @@ +From dffa2a21edeba243ef76b75e0c2081ec15fe95bd Mon Sep 17 00:00:00 2001 +From: SSE4 +Date: Wed, 3 Apr 2019 19:48:12 +0700 +Subject: [PATCH 3/4] 0003 + +--- + lib/spawn-pipe.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lib/spawn-pipe.c b/lib/spawn-pipe.c +index 3af5167..09e9cad 100644 +--- a/lib/spawn-pipe.c ++++ b/lib/spawn-pipe.c +@@ -213,10 +213,10 @@ create_pipe (const char *progname, + xalloc_die (); + + if (pipe_stdout) +- if (pipe2_safer (ifd, O_BINARY | O_CLOEXEC) < 0) ++ if (pipe2_safer (ifd, O_TEXT | O_CLOEXEC) < 0) + error (EXIT_FAILURE, errno, _("cannot create pipe")); + if (pipe_stdin) +- if (pipe2_safer (ofd, O_BINARY | O_CLOEXEC) < 0) ++ if (pipe2_safer (ofd, O_TEXT | O_CLOEXEC) < 0) + error (EXIT_FAILURE, errno, _("cannot create pipe")); + /* Data flow diagram: + * +-- +2.7.4.windows.1 + diff --git a/recipes/bison/all/patches/0002-3.7.6-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch b/recipes/bison/all/patches/0002-3.7.6-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch new file mode 100644 index 0000000000000..2310d29a3ca9e --- /dev/null +++ b/recipes/bison/all/patches/0002-3.7.6-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch @@ -0,0 +1,26 @@ +--- src/location.c ++++ src/location.c +@@ -258,6 +258,14 @@ + static bool + caret_set_file (const char *file) + { ++#if defined(_WIN32) ++ /* ftell() is unusable on Windows in the face of text files ++ that use just LF and not Windows-style CR-LF as newlines ++ http://support.microsoft.com/kb/68337 */ ++ char fopen_mode[3] = "rb"; ++#else ++ char fopen_mode[2] = "r"; ++#endif + /* If a different file than before, close and let the rest open + the new one. */ + if (caret_info.pos.file && caret_info.pos.file != file) +@@ -268,7 +268,7 @@ + if (!caret_info.pos.file) + { + caret_info.pos.file = file; +- if ((caret_info.file = fopen (caret_info.pos.file, "r"))) ++ if ((caret_info.file = fopen (caret_info.pos.file, fopen_mode))) + { + /* If the file is not regular (imagine #line 1 "/dev/stdin" + in the input file for instance), don't try to quote the diff --git a/recipes/bison/all/patches/0006-dont-link-bison-against-libreadline.patch b/recipes/bison/all/patches/0006-dont-link-bison-against-libreadline.patch new file mode 100644 index 0000000000000..377c9d47a6ad1 --- /dev/null +++ b/recipes/bison/all/patches/0006-dont-link-bison-against-libreadline.patch @@ -0,0 +1,14 @@ +build: don't link bison against libreadline +Reported by Paul Smith . +https://lists.gnu.org/r/bug-bison/2020-10/msg00001.html + +--- a/Makefile.in ++++ b/Makefile.in +@@ -3456,7 +3456,6 @@ + $(LIB_SETLOCALE_NULL) \ + $(LIBICONV) \ + $(LIBINTL) \ +- $(LIBREADLINE) \ + $(LIBTEXTSTYLE) + + @ENABLE_YACC_TRUE@nodist_bin_SCRIPTS = src/yacc diff --git a/recipes/bison/all/test_package/conanfile.py b/recipes/bison/all/test_package/conanfile.py index 1f515de3bc32c..82220fffff866 100644 --- a/recipes/bison/all/test_package/conanfile.py +++ b/recipes/bison/all/test_package/conanfile.py @@ -3,20 +3,23 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH") and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") - @ property + @property def _mc_parser_source(self): return os.path.join(self.source_folder, "mc_parser.yy") def build(self): - if not tools.cross_building(self.settings, skip_x64_x86=True): + if not tools.cross_building(self, skip_x64_x86=True): # verify bison may run self.run("bison --version", run_environment=True) # verify yacc may run @@ -30,14 +33,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings, skip_x64_x86=True): + if not tools.cross_building(self, skip_x64_x86=True): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) - - # verify bison works without M4 environment variables - with tools.environment_append({"M4": None}): - self.run("bison -d {}".format(self._mc_parser_source), run_environment=True) - - # verify bison works without BISON_PKGDATADIR and M4 environment variables - with tools.environment_append({"BISON_PKGDATADIR": None, "M4": None}): - self.run("bison -d {}".format(self._mc_parser_source), run_environment=True) diff --git a/recipes/bison/all/test_package/mc_parser.yy b/recipes/bison/all/test_package/mc_parser.yy index 9d219d506394d..f09b5cc80778a 100644 --- a/recipes/bison/all/test_package/mc_parser.yy +++ b/recipes/bison/all/test_package/mc_parser.yy @@ -37,6 +37,6 @@ factor: NUM { $$ = $1; } %% int main() { - yyparse(); - return 0; + yyparse(); + return 0; } diff --git a/recipes/bison/all/test_package/test_package.cpp b/recipes/bison/all/test_package/test_package.cpp index bd8eb53edd5e0..b00966a007909 100644 --- a/recipes/bison/all/test_package/test_package.cpp +++ b/recipes/bison/all/test_package/test_package.cpp @@ -2,12 +2,12 @@ extern "C" { - int yyerror(char *); + int yyerror(const char *); } int main() { - char error[] = "Bincrafters"; + char error[] = "conan-center-index"; std::cout << yyerror(error) << std::endl; return 0; } diff --git a/recipes/bison/config.yml b/recipes/bison/config.yml index 47d307b4a5e3a..7e22e455ae51e 100644 --- a/recipes/bison/config.yml +++ b/recipes/bison/config.yml @@ -1,4 +1,8 @@ versions: + "3.8.2": + folder: all + "3.7.6": + folder: all "3.7.1": folder: all "3.5.3": diff --git a/recipes/bit-lite/all/conanfile.py b/recipes/bit-lite/all/conanfile.py index 2fb2da26e80f0..b0529cb7abe9a 100644 --- a/recipes/bit-lite/all/conanfile.py +++ b/recipes/bit-lite/all/conanfile.py @@ -1,7 +1,10 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.50.0" + class BitLiteConan(ConanFile): name = "bit-lite" @@ -9,30 +12,41 @@ class BitLiteConan(ConanFile): homepage = "https://github.com/martinmoene/bit-lite" description = ("bit is a C++20 bit operations for C++98 and later \ in a single-file header-only library.") - topics = ("conan", "bit-lite", "bit", "manipulation", ) + topics = ("bit-lite", "bit", "manipulation", ) license = "BSL-1.0" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "bit-lite") + self.cpp_info.set_property("cmake_target_name", "nonstd::bit-lite") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "bit-lite" self.cpp_info.filenames["cmake_find_package_multi"] = "bit-lite" self.cpp_info.names["cmake_find_package"] = "nonstd" self.cpp_info.names["cmake_find_package_multi"] = "nonstd" self.cpp_info.components["bitlite"].names["cmake_find_package"] = "bit-lite" self.cpp_info.components["bitlite"].names["cmake_find_package_multi"] = "bit-lite" + self.cpp_info.components["bitlite"].set_property("cmake_target_name", "nonstd::bit-lite") diff --git a/recipes/bit-lite/all/test_package/CMakeLists.txt b/recipes/bit-lite/all/test_package/CMakeLists.txt index dd523cd2fc988..ed13431c56a28 100644 --- a/recipes/bit-lite/all/test_package/CMakeLists.txt +++ b/recipes/bit-lite/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES CXX) find_package(bit-lite REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} nonstd::bit-lite) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::bit-lite) diff --git a/recipes/bit-lite/all/test_package/conanfile.py b/recipes/bit-lite/all/test_package/conanfile.py index abcaeed3f89b6..d120a992c06a6 100644 --- a/recipes/bit-lite/all/test_package/conanfile.py +++ b/recipes/bit-lite/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bit-lite/all/test_v1_package/CMakeLists.txt b/recipes/bit-lite/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a2c6ae82d037d --- /dev/null +++ b/recipes/bit-lite/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bit-lite REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::bit-lite) diff --git a/recipes/bit-lite/all/test_v1_package/conanfile.py b/recipes/bit-lite/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/bit-lite/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bitflags/all/conandata.yml b/recipes/bitflags/all/conandata.yml new file mode 100644 index 0000000000000..2abe2034e3c41 --- /dev/null +++ b/recipes/bitflags/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.5.0": + url: "https://github.com/m-peko/bitflags/archive/refs/tags/v1.5.0.tar.gz" + sha256: 1ea19e03e05e8e78faf0126a1a100e591467828bc816224e9cda330b104e69b5 diff --git a/recipes/bitflags/all/conanfile.py b/recipes/bitflags/all/conanfile.py new file mode 100644 index 0000000000000..c9f1d462a3694 --- /dev/null +++ b/recipes/bitflags/all/conanfile.py @@ -0,0 +1,59 @@ +import os + +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import get, copy +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.50.0" + + +class BitFlags(ConanFile): + name = "bitflags" + description = "Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags" + topics = ("bits", "bitflags", "header-only") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/m-peko/bitflags" + license = "MIT" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _minimum_compilers_version(self): + return {"apple-clang": "5", "clang": "5", "gcc": "7", "Visual Studio": "14"} + + @property + def _minimum_cpp_standard(self): + return 11 + + def layout(self): + basic_layout(self) + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + try: + if Version(self.settings.compiler.version) < self._minimum_compilers_version[str(self.settings.compiler)]: + raise ConanInvalidConfiguration(f"{self.ref} requires a compiler that supports C++{self._minimum_cpp_standard}.") + except KeyError: + self.output.warn("Unknown compiler encountered. Assuming it supports C++11.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, + destination=self.source_folder) + + def package(self): + copy(self, pattern="LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, pattern="*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "bitflags") + self.cpp_info.set_property("cmake_target_name", "bitflags::bitflags") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/bitflags/all/test_package/CMakeLists.txt b/recipes/bitflags/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..51b69634fef26 --- /dev/null +++ b/recipes/bitflags/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +find_package(bitflags REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE bitflags::bitflags) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/bitflags/all/test_package/conanfile.py b/recipes/bitflags/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e506c322ce801 --- /dev/null +++ b/recipes/bitflags/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + +required_conan_version = ">=1.50.0" + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/recipes/bitflags/all/test_package/test_package.cpp b/recipes/bitflags/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..91a9730c23c5a --- /dev/null +++ b/recipes/bitflags/all/test_package/test_package.cpp @@ -0,0 +1,27 @@ +#include "bitflags/bitflags.hpp" +#include +#include + +BEGIN_BITFLAGS(Flags) +FLAG(none) +FLAG(flag_a) +FLAG(flag_b) +FLAG(flag_c) +END_BITFLAGS(Flags) + +DEFINE_FLAG(Flags, none) +DEFINE_FLAG(Flags, flag_a) +DEFINE_FLAG(Flags, flag_b) +DEFINE_FLAG(Flags, flag_c) + +int main() { + std::cout << +Flags::none.bits << " - " << Flags::none.name << '\n'; + std::cout << +Flags::flag_a.bits << " - " << Flags::flag_a.name << '\n'; + std::cout << +Flags::flag_b.bits << " - " << Flags::flag_b.name << '\n'; + std::cout << +Flags::flag_c.bits << " - " << Flags::flag_c.name << '\n'; + + const auto flags = Flags::flag_a | Flags::flag_b; + + assert(flags & Flags::flag_a); + assert(!(flags & Flags::flag_c)); +} diff --git a/recipes/bitflags/all/test_v1_package/CMakeLists.txt b/recipes/bitflags/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..789568c184c15 --- /dev/null +++ b/recipes/bitflags/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(bitflags REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE bitflags::bitflags) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/bitflags/all/test_v1_package/conanfile.py b/recipes/bitflags/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/bitflags/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bitflags/config.yml b/recipes/bitflags/config.yml new file mode 100644 index 0000000000000..16b5c7979d806 --- /dev/null +++ b/recipes/bitflags/config.yml @@ -0,0 +1,3 @@ +versions: + "1.5.0": + folder: "all" diff --git a/recipes/bitmagic/all/conandata.yml b/recipes/bitmagic/all/conandata.yml new file mode 100644 index 0000000000000..be5ff4fa07b8e --- /dev/null +++ b/recipes/bitmagic/all/conandata.yml @@ -0,0 +1,25 @@ +sources: + "7.12.3": + url: "https://github.com/tlk00/BitMagic/archive/refs/tags/v7.12.3.tar.gz" + sha256: "5e59507a01a8295bb57aebcf557a4a25b992244736f7924300cdb9635f1b2780" + "7.11.2": + url: "https://github.com/tlk00/BitMagic/archive/refs/tags/v7.11.2.tar.gz" + sha256: "09faf5b9da4e0cee4947e05b7af0bd834e63e90c8877c115b719b4f390709a6f" + "7.10.3": + url: "https://github.com/tlk00/BitMagic/archive/v7.10.3.tar.gz" + sha256: "164aae4f52f35f3a0e4a596611efcd1494a9be5489be494c6a440e5a83f17460" + "7.9.3": + url: "https://github.com/tlk00/BitMagic/archive/v7.9.3.tar.gz" + sha256: "fa1799f702dac47148dc8e2672957b1fc5be440d043ef2c4d275c04b434182e1" + "7.8.0": + url: "https://github.com/tlk00/BitMagic/archive/v7.8.0.tar.gz" + sha256: "78e1d2ba81ad14595c976ecb0e8d18a9b652dfe8e394964f94bd98cc8164391b" + "7.7.7": + url: "https://github.com/tlk00/BitMagic/archive/v7.7.7.tar.gz" + sha256: "9f645a2aa18566462733d592f8f44c9bb283a2df52701474f620d20cee4c9e92" + "7.6.0": + url: "https://github.com/tlk00/BitMagic/archive/v7.6.0.tar.gz" + sha256: "eebe39e15fc7c14d2c5aad5f07bf2c8ddf79bffafef2e748470f35d3555cf6a9" + "7.5.0": + url: "https://github.com/tlk00/BitMagic/archive/refs/tags/v7.5.0.tar.gz" + sha256: "dec7d316baf3be9cb058d9da302a7e4cb694ac429d4bd29138c24b1b0157a9e8" diff --git a/recipes/bitmagic/all/conanfile.py b/recipes/bitmagic/all/conanfile.py new file mode 100644 index 0000000000000..8a5d321f046d1 --- /dev/null +++ b/recipes/bitmagic/all/conanfile.py @@ -0,0 +1,64 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.0" + + +class BitmagicConan(ConanFile): + name = "bitmagic" + description = "BitMagic Library helps to develop high-throughput intelligent search systems, " \ + "promote combination of hardware optimizations and on the fly compression to fit " \ + "inverted indexes and binary fingerprints into memory, minimize disk and network footprint." + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://bitmagic.io" + topics = ("information-retrieval", "algorithm", "bit-manipulation", + "integer-compression", "sparse-vector", "sparse-matrix", "bit-array", + "bit-vector", "indexing-engine", "adjacency-matrix", "associative-array") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "msvc": "192", + "gcc": "7", + "clang": "6", + "apple-clang": "10", + } + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 17) + minimum_version = self._minimum_compilers_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.name} requires C++17, which your compiler does not support.") + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/bitmagic/all/test_package/CMakeLists.txt b/recipes/bitmagic/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a756218c12bb7 --- /dev/null +++ b/recipes/bitmagic/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(bitmagic REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE bitmagic::bitmagic) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/bitmagic/all/test_package/conanfile.py b/recipes/bitmagic/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/bitmagic/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bitmagic/all/test_package/test_package.cpp b/recipes/bitmagic/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..b633db7b8c598 --- /dev/null +++ b/recipes/bitmagic/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include + +int main() { + bm::bvector<> bv_A{1, 2, 3}; + bm::bvector<> bv_B{1, 2, 4}; + bv_A.combine_operation(bv_B, bm::BM_OR); + return 0; +} diff --git a/recipes/bitmagic/all/test_v1_package/CMakeLists.txt b/recipes/bitmagic/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a1f535ce8930b --- /dev/null +++ b/recipes/bitmagic/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bitmagic REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE bitmagic::bitmagic) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/bitmagic/all/test_v1_package/conanfile.py b/recipes/bitmagic/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/bitmagic/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bitmagic/config.yml b/recipes/bitmagic/config.yml new file mode 100644 index 0000000000000..34c9a540c22c6 --- /dev/null +++ b/recipes/bitmagic/config.yml @@ -0,0 +1,17 @@ +versions: + "7.12.3": + folder: all + "7.11.2": + folder: all + "7.10.3": + folder: all + "7.9.3": + folder: all + "7.8.0": + folder: all + "7.7.7": + folder: all + "7.6.0": + folder: all + "7.5.0": + folder: all diff --git a/recipes/bitserializer/0.10/conandata.yml b/recipes/bitserializer/0.10/conandata.yml deleted file mode 100644 index ba4b025057059..0000000000000 --- a/recipes/bitserializer/0.10/conandata.yml +++ /dev/null @@ -1,4 +0,0 @@ -sources: - "0.10": - sha256: d5ae211aead17acb91d9fb7df7e72a30202f39412159dd0b46fe0e5046b29f94 - url: https://bitbucket.com/Pavel_Kisliak/BitSerializer/get/0.10.tar.gz diff --git a/recipes/bitserializer/0.10/conanfile.py b/recipes/bitserializer/0.10/conanfile.py deleted file mode 100644 index f3d4e78833b79..0000000000000 --- a/recipes/bitserializer/0.10/conanfile.py +++ /dev/null @@ -1,90 +0,0 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration -import glob -import os - -required_conan_version = ">=1.28.0" - -class BitserializerConan(ConanFile): - name = "bitserializer" - description = "C++ 17 library for serialization to multiple output formats (JSON, XML, YAML)" - topics = ("serialization", "json", "xml") - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://bitbucket.org/Pavel_Kisliak/bitserializer" - license = "MIT" - settings = "os", "compiler" - no_copy_source = True - options = { - "with_cpprestsdk": [True, False], - "with_rapidjson": [True, False], - "with_pugixml": [True, False] - } - default_options = { - "with_cpprestsdk": True, - "with_rapidjson": True, - "with_pugixml": True - } - - @property - def _supported_compilers(self): - return { - "gcc": "8", - "clang": "7", - "Visual Studio": "15", - "apple-clang": "10", - } - - @property - def _source_subfolder(self): - return "source_subfolder" - - def configure(self): - if self.settings.get_safe("compiler.cppstd"): - tools.check_min_cppstd(self, "17") - try: - minimum_required_compiler_version = self._supported_compilers[str(self.settings.compiler)] - if tools.Version(self.settings.compiler.version) < minimum_required_compiler_version: - raise ConanInvalidConfiguration("This package requires c++17 support. The current compiler does not support it.") - except KeyError: - self.output.warn("This recipe has no support for the current compiler. Please consider adding it.") - - def requirements(self): - if self.options.with_cpprestsdk: - self.requires("cpprestsdk/2.10.16") - if self.options.with_rapidjson: - self.requires("rapidjson/1.1.0") - if self.options.with_pugixml: - self.requires("pugixml/1.10") - - def package_id(self): - self.info.header_only() - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("*-bitserializer-*")[0] - os.rename(extracted_dir, self._source_subfolder) - - def package(self): - self.copy(pattern="license.txt", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) - - def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "bitserializer" - self.cpp_info.filenames["cmake_find_package_multi"] = "bitserializer" - self.cpp_info.names["cmake_find_package"] = "BitSerializer" - self.cpp_info.names["cmake_find_package_multi"] = "BitSerializer" - # core - self.cpp_info.components["core"].names["cmake_find_package"] = "core" - self.cpp_info.components["core"].names["cmake_find_package_multi"] = "core" - if self.settings.compiler == "gcc" or (self.settings.os == "Linux" and self.settings.compiler == "clang"): - if tools.Version(self.settings.compiler.version) < 9: - self.cpp_info.components["core"].system_libs = ["stdc++fs"] - # cpprestjson-archive - if self.options.with_cpprestsdk: - self.cpp_info.components["cpprestjson-archive"].requires = ["core", "cpprestsdk::cpprestsdk"] - # rapidjson-archive - if self.options.with_rapidjson: - self.cpp_info.components["rapidjson-archive"].requires = ["core", "rapidjson::rapidjson"] - # pugixml-archive - if self.options.with_pugixml: - self.cpp_info.components["pugixml-archive"].requires = ["core", "pugixml::pugixml"] diff --git a/recipes/bitserializer/0.10/test_package/CMakeLists.txt b/recipes/bitserializer/0.10/test_package/CMakeLists.txt deleted file mode 100644 index b88d99d47163c..0000000000000 --- a/recipes/bitserializer/0.10/test_package/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(bitserializer REQUIRED CONFIG) - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} - BitSerializer::core - $<$:BitSerializer::cpprestjson-archive> - $<$:BitSerializer::rapidjson-archive> - $<$:BitSerializer::pugixml-archive>) -target_compile_definitions(${PROJECT_NAME} PRIVATE - $<$:"WITH_CPPRESTSDK"> - $<$:"WITH_RAPIDJSON"> - $<$:"WITH_PUGIXML">) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/bitserializer/0.10/test_package/conanfile.py b/recipes/bitserializer/0.10/test_package/conanfile.py deleted file mode 100644 index c565523fc32c8..0000000000000 --- a/recipes/bitserializer/0.10/test_package/conanfile.py +++ /dev/null @@ -1,20 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.definitions["WITH_CPPRESTSDK"] = self.options["bitserializer"].with_cpprestsdk - cmake.definitions["WITH_RAPIDJSON"] = self.options["bitserializer"].with_rapidjson - cmake.definitions["WITH_PUGIXML"] = self.options["bitserializer"].with_pugixml - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) diff --git a/recipes/bitserializer/all/conandata.yml b/recipes/bitserializer/all/conandata.yml new file mode 100644 index 0000000000000..10234ee527ae7 --- /dev/null +++ b/recipes/bitserializer/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "0.44": + url: "https://bitbucket.com/Pavel_Kisliak/BitSerializer/get/0.44.tar.gz" + sha256: "39ee0b038c9f38a012f96913c9738a68514d2e923431fbd83ddf3f454e02bc6c" + "0.10": + url: "https://bitbucket.com/Pavel_Kisliak/BitSerializer/get/0.10.tar.gz" + sha256: "d5ae211aead17acb91d9fb7df7e72a30202f39412159dd0b46fe0e5046b29f94" diff --git a/recipes/bitserializer/all/conanfile.py b/recipes/bitserializer/all/conanfile.py new file mode 100644 index 0000000000000..aae97523850f3 --- /dev/null +++ b/recipes/bitserializer/all/conanfile.py @@ -0,0 +1,128 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.43.0" + + +class BitserializerConan(ConanFile): + name = "bitserializer" + description = "C++ 17 library for serialization to multiple output formats (JSON, XML, YAML)" + topics = ("serialization", "json", "xml") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://bitbucket.org/Pavel_Kisliak/bitserializer" + license = "MIT" + + settings = "os", "arch", "compiler", "build_type" + options = { + "with_cpprestsdk": [True, False], + "with_rapidjson": [True, False], + "with_pugixml": [True, False], + } + default_options = { + "with_cpprestsdk": False, + "with_rapidjson": False, + "with_pugixml": False, + } + + no_copy_source = True + + @property + def _supported_compilers(self): + if tools.Version(self.version) >= "0.44": + return { + "gcc": "8", + "clang": "8", + "Visual Studio": "15", + "apple-clang": "12", + } + + return { + "gcc": "8", + "clang": "7", + "Visual Studio": "15", + "apple-clang": "12", + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def requirements(self): + if self.options.with_cpprestsdk: + self.requires("cpprestsdk/2.10.18") + if self.options.with_rapidjson: + self.requires("rapidjson/cci.20211112") + if self.options.with_pugixml: + self.requires("pugixml/1.11") + + def validate(self): + # Check compiler for supporting C++ 17 + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "17") + try: + minimum_required_compiler_version = self._supported_compilers[str(self.settings.compiler)] + if tools.Version(self.settings.compiler.version) < minimum_required_compiler_version: + raise ConanInvalidConfiguration("This package requires c++17 support. The current compiler does not support it.") + except KeyError: + self.output.warn("This recipe has no support for the current compiler. Please consider adding it.") + + # Check stdlib ABI compatibility + compiler_name = str(self.settings.compiler) + if compiler_name == "gcc" and self.settings.compiler.libcxx != "libstdc++11": + raise ConanInvalidConfiguration('Using %s with GCC requires "compiler.libcxx=libstdc++11"' % self.name) + elif compiler_name == "clang" and self.settings.compiler.libcxx not in ["libstdc++11", "libc++"]: + raise ConanInvalidConfiguration('Using %s with Clang requires either "compiler.libcxx=libstdc++11"' + ' or "compiler.libcxx=libc++"' % self.name) + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy(pattern="license.txt", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "bitserializer") + + # cpprestjson-core + self.cpp_info.components["bitserializer-core"].set_property("cmake_target_name", "BitSerializer::core") + if self.settings.compiler == "gcc" or (self.settings.os == "Linux" and self.settings.compiler == "clang"): + if tools.Version(self.settings.compiler.version) < 9: + self.cpp_info.components["bitserializer-core"].system_libs = ["stdc++fs"] + + # cpprestjson-archive + if self.options.with_cpprestsdk: + self.cpp_info.components["bitserializer-cpprestjson"].set_property("cmake_target_name", "BitSerializer::cpprestjson-archive") + self.cpp_info.components["bitserializer-cpprestjson"].requires = ["bitserializer-core", "cpprestsdk::cpprestsdk"] + + # rapidjson-archive + if self.options.with_rapidjson: + self.cpp_info.components["bitserializer-rapidjson"].set_property("cmake_target_name", "BitSerializer::rapidjson-archive") + self.cpp_info.components["bitserializer-rapidjson"].requires = ["bitserializer-core", "rapidjson::rapidjson"] + + # pugixml-archive + if self.options.with_pugixml: + self.cpp_info.components["bitserializer-pugixml"].set_property("cmake_target_name", "BitSerializer::pugixml-archive") + self.cpp_info.components["bitserializer-pugixml"].requires = ["bitserializer-core", "pugixml::pugixml"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.filenames["cmake_find_package"] = "bitserializer" + self.cpp_info.filenames["cmake_find_package_multi"] = "bitserializer" + self.cpp_info.names["cmake_find_package"] = "BitSerializer" + self.cpp_info.names["cmake_find_package_multi"] = "BitSerializer" + self.cpp_info.components["bitserializer-core"].names["cmake_find_package"] = "core" + self.cpp_info.components["bitserializer-core"].names["cmake_find_package_multi"] = "core" + if self.options.with_cpprestsdk: + self.cpp_info.components["bitserializer-cpprestjson"].names["cmake_find_package"] = "cpprestjson-archive" + self.cpp_info.components["bitserializer-cpprestjson"].names["cmake_find_package_multi"] = "cpprestjson-archive" + if self.options.with_rapidjson: + self.cpp_info.components["bitserializer-rapidjson"].names["cmake_find_package"] = "rapidjson-archive" + self.cpp_info.components["bitserializer-rapidjson"].names["cmake_find_package_multi"] = "rapidjson-archive" + if self.options.with_pugixml: + self.cpp_info.components["bitserializer-pugixml"].names["cmake_find_package"] = "pugixml-archive" + self.cpp_info.components["bitserializer-pugixml"].names["cmake_find_package_multi"] = "pugixml-archive" diff --git a/recipes/bitserializer/all/test_package/CMakeLists.txt b/recipes/bitserializer/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..920aede3112b7 --- /dev/null +++ b/recipes/bitserializer/all/test_package/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bitserializer REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +target_link_libraries(${PROJECT_NAME} + BitSerializer::core + $<$:BitSerializer::cpprestjson-archive> + $<$:BitSerializer::rapidjson-archive> + $<$:BitSerializer::pugixml-archive>) +target_compile_definitions(${PROJECT_NAME} PRIVATE + $<$:"WITH_CPPRESTSDK"> + $<$:"WITH_RAPIDJSON"> + $<$:"WITH_PUGIXML">) diff --git a/recipes/bitserializer/all/test_package/conanfile.py b/recipes/bitserializer/all/test_package/conanfile.py new file mode 100644 index 0000000000000..2aef261cc5712 --- /dev/null +++ b/recipes/bitserializer/all/test_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["WITH_CPPRESTSDK"] = self.options["bitserializer"].with_cpprestsdk + cmake.definitions["WITH_RAPIDJSON"] = self.options["bitserializer"].with_rapidjson + cmake.definitions["WITH_PUGIXML"] = self.options["bitserializer"].with_pugixml + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bitserializer/0.10/test_package/test_package.cpp b/recipes/bitserializer/all/test_package/test_package.cpp similarity index 100% rename from recipes/bitserializer/0.10/test_package/test_package.cpp rename to recipes/bitserializer/all/test_package/test_package.cpp diff --git a/recipes/bitserializer/config.yml b/recipes/bitserializer/config.yml index 514b66a4b3392..3b57b2ed72ef1 100644 --- a/recipes/bitserializer/config.yml +++ b/recipes/bitserializer/config.yml @@ -1,3 +1,5 @@ versions: + "0.44": + folder: "all" "0.10": - folder: "0.10" + folder: "all" diff --git a/recipes/bitsery/all/conandata.yml b/recipes/bitsery/all/conandata.yml index 0a2a671959f50..81be1b1c7d44e 100644 --- a/recipes/bitsery/all/conandata.yml +++ b/recipes/bitsery/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "5.2.2": + url: "https://github.com/fraillt/bitsery/archive/v5.2.2.tar.gz" + sha256: "5e932c463f16db15228b2546632a5851a502c68e605a1e313b0f1a35c061e4ae" "5.2.1": url: "https://github.com/fraillt/bitsery/archive/v5.2.1.tar.gz" sha256: "1e2ee66827c55ef82eaf6ef4c87a2c5b3a010dfe6c770eb0feeb3f0c35254d00" diff --git a/recipes/bitsery/all/conanfile.py b/recipes/bitsery/all/conanfile.py index 42184eb52412b..dd2f676b3757f 100644 --- a/recipes/bitsery/all/conanfile.py +++ b/recipes/bitsery/all/conanfile.py @@ -1,40 +1,58 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools +required_conan_version = ">=1.50.0" class BitseryConan(ConanFile): name = "bitsery" - description = "Header only C++ binary serialization library. It is designed around the networking requirements for real-time data delivery, especially for games." - topics = "serialization", "binary", "header-only" + description = ( + "Header only C++ binary serialization library. It is designed around " + "the networking requirements for real-time data delivery, especially for games." + ) + topics = ("serialization", "binary", "header-only") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/fraillt/bitsery" license = "MIT" - settings = "compiler", "os" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, "11") + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) - def package_id(self): - self.info.header_only() + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "bitsery-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Bitsery") + self.cpp_info.set_property("cmake_target_name", "Bitsery::bitsery") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["bitserylib"].bindirs = [] + self.cpp_info.components["bitserylib"].frameworkdirs = [] + self.cpp_info.components["bitserylib"].libdirs = [] + self.cpp_info.components["bitserylib"].resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "Bitsery" self.cpp_info.names["cmake_find_package_multi"] = "Bitsery" self.cpp_info.components["bitserylib"].names["cmake_find_package"] = "bitsery" self.cpp_info.components["bitserylib"].names["cmake_find_package_multi"] = "bitsery" + self.cpp_info.components["bitserylib"].set_property("cmake_target_name", "Bitsery::bitsery") diff --git a/recipes/bitsery/all/test_package/CMakeLists.txt b/recipes/bitsery/all/test_package/CMakeLists.txt index f8434814c34c6..ae7a2f24744c3 100644 --- a/recipes/bitsery/all/test_package/CMakeLists.txt +++ b/recipes/bitsery/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(Bitsery REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} Bitsery::bitsery) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON) +target_link_libraries(${PROJECT_NAME} PRIVATE Bitsery::bitsery) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/bitsery/all/test_package/conanfile.py b/recipes/bitsery/all/test_package/conanfile.py index 7e2dfe859bb27..d120a992c06a6 100644 --- a/recipes/bitsery/all/test_package/conanfile.py +++ b/recipes/bitsery/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bitsery/all/test_v1_package/CMakeLists.txt b/recipes/bitsery/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..be90dcf1b4730 --- /dev/null +++ b/recipes/bitsery/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Bitsery REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Bitsery::bitsery) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/bitsery/all/test_v1_package/conanfile.py b/recipes/bitsery/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/bitsery/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bitsery/config.yml b/recipes/bitsery/config.yml index 62f98ac14882d..50e396f35efb2 100644 --- a/recipes/bitsery/config.yml +++ b/recipes/bitsery/config.yml @@ -1,4 +1,6 @@ versions: + "5.2.2": + folder: all "5.2.1": folder: all "5.2.0": diff --git a/recipes/blaze/all/conandata.yml b/recipes/blaze/all/conandata.yml index d481439d0eb6a..a6e5a6aa09753 100644 --- a/recipes/blaze/all/conandata.yml +++ b/recipes/blaze/all/conandata.yml @@ -1,7 +1,7 @@ sources: - "3.7": - sha256: 4dfd6bf518c983e8785e217262813d44cdd2842955792417eb0b3736586168fa - url: https://bitbucket.org/blaze-lib/blaze/downloads/blaze-3.7.tar.gz "3.8": - sha256: dfaae1a3a9fea0b3cc92e78c9858dcc6c93301d59f67de5d388a3a41c8a629ae - url: https://bitbucket.org/blaze-lib/blaze/downloads/blaze-3.8.tar.gz + url: "https://bitbucket.org/blaze-lib/blaze/downloads/blaze-3.8.tar.gz" + sha256: "dfaae1a3a9fea0b3cc92e78c9858dcc6c93301d59f67de5d388a3a41c8a629ae" + "3.7": + url: "https://bitbucket.org/blaze-lib/blaze/downloads/blaze-3.7.tar.gz" + sha256: "ef3cbc5db7d62dcdde0af88d3c951051254afd750d26773406fddb6afc5ad890" diff --git a/recipes/blaze/all/conanfile.py b/recipes/blaze/all/conanfile.py index 8d62468e456df..a5d62edf842a5 100644 --- a/recipes/blaze/all/conanfile.py +++ b/recipes/blaze/all/conanfile.py @@ -1,5 +1,10 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import chdir, copy, get, rename, rmdir +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools + +required_conan_version = ">=1.50.0" class BlazeConan(ConanFile): @@ -7,22 +12,40 @@ class BlazeConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://bitbucket.org/blaze-lib/blaze" description = "open-source, high-performance C++ math library for dense and sparse arithmetic" - topics = ("conan", "blaze", "math", "algebra", "linear algebra", "high-performance") + topics = ("blaze", "math", "algebra", "linear algebra", "high-performance") license = "BSD-3-Clause" - + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 14) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("blaze-{}".format(self.version), self._source_subfolder) + base_source_dir = os.path.join(self.source_folder, os.pardir) + get(self, **self.conan_data["sources"][self.version], + destination=base_source_dir, strip_root=True) + with chdir(self, base_source_dir): + rmdir(self, self.source_folder) + rename(self, src=f"blaze-{self.version}", dst=self.source_folder) - def package_id(self): - self.info.header_only() + def build(self): + pass def package(self): - self.copy("LICENSE", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") - self.copy(pattern="blaze/*.h", src=os.path.join(self.source_folder, self._source_subfolder), dst="include") + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "blaze/*.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "blaze") + self.cpp_info.set_property("cmake_target_name", "blaze::blaze") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/blaze/all/test_package/CMakeLists.txt b/recipes/blaze/all/test_package/CMakeLists.txt index c92478a554d8b..1b0a92218a093 100755 --- a/recipes/blaze/all/test_package/CMakeLists.txt +++ b/recipes/blaze/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.5) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(blaze REQUIRED CONFIG) -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) -set_target_properties(example PROPERTIES - CXX_STANDARD 14 - CXX_STANDARD_REQUIRED ON) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE blaze::blaze) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/blaze/all/test_package/conanfile.py b/recipes/blaze/all/test_package/conanfile.py index 7b99c9826a2c7..d120a992c06a6 100755 --- a/recipes/blaze/all/test_package/conanfile.py +++ b/recipes/blaze/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -class BlazeTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/blaze/all/test_package/example.cpp b/recipes/blaze/all/test_package/test_package.cpp similarity index 100% rename from recipes/blaze/all/test_package/example.cpp rename to recipes/blaze/all/test_package/test_package.cpp diff --git a/recipes/blaze/all/test_v1_package/CMakeLists.txt b/recipes/blaze/all/test_v1_package/CMakeLists.txt new file mode 100755 index 0000000000000..ec8caed27fa90 --- /dev/null +++ b/recipes/blaze/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(blaze REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE blaze::blaze) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/blaze/all/test_v1_package/conanfile.py b/recipes/blaze/all/test_v1_package/conanfile.py new file mode 100755 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/blaze/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/blaze/config.yml b/recipes/blaze/config.yml index 8bc78d87a1dd0..df754600895a3 100644 --- a/recipes/blaze/config.yml +++ b/recipes/blaze/config.yml @@ -1,5 +1,5 @@ versions: - "3.7": - folder: all "3.8": folder: all + "3.7": + folder: all diff --git a/recipes/blend2d/all/conandata.yml b/recipes/blend2d/all/conandata.yml new file mode 100644 index 0000000000000..6da900cdfb3fd --- /dev/null +++ b/recipes/blend2d/all/conandata.yml @@ -0,0 +1,15 @@ +sources: + "0.0.18": + url: "https://blend2d.com/download/blend2d-beta18.zip" + sha256: "02d23b185183705215241d7b161937bbda5b427c54cc5aa4c03238ef8dd1e60b" + "0.0.17": + url: "https://blend2d.com/download/blend2d-beta17.zip" + sha256: "06ee8fb0bea281d09291e498900093139426501a1a7f09dba0ec801dd340635e" + +patches: + "0.0.18": + - patch_file: "patches/0.0.17-0001-disable-embed-asmjit.patch" + # fix gcc12 compilation error, backport from upstream + - patch_file: "patches/0.0.18-0002-fix-gcc12-compilationerror.patch" + "0.0.17": + - patch_file: "patches/0.0.17-0001-disable-embed-asmjit.patch" diff --git a/recipes/blend2d/all/conanfile.py b/recipes/blend2d/all/conanfile.py new file mode 100644 index 0000000000000..e786098393dd3 --- /dev/null +++ b/recipes/blend2d/all/conanfile.py @@ -0,0 +1,95 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd, valid_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.microsoft import check_min_vs +import os + +required_conan_version = ">=1.52.0" + + +class Blend2dConan(ConanFile): + name = "blend2d" + description = "2D Vector Graphics Engine Powered by a JIT Compiler" + license = "Zlib" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://blend2d.com/" + topics = ("2d-graphics", "rasterization", "asmjit", "jit") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("asmjit/cci.20221111") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + # In Visual Studio < 16, there are compilation error. patch is already provided. + # https://github.com/blend2d/blend2d/commit/63db360c7eb2c1c3ca9cd92a867dbb23dc95ca7d + check_min_vs(self, 192) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.variables["BLEND2D_TEST"] = False + tc.variables["BLEND2D_EMBED"] = False + tc.variables["BLEND2D_STATIC"] = not self.options.shared + tc.variables["BLEND2D_NO_STDCXX"] = False + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + if not valid_min_cppstd(self, 11): + tc.variables["CMAKE_CXX_STANDARD"] = 11 + if not self.options.shared: + tc.preprocessor_definitions["BL_STATIC"] = "1" + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "blend2d") + self.cpp_info.set_property("cmake_target_name", "blend2d::blend2d") + self.cpp_info.libs = ["blend2d"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["pthread", "rt",]) + if not self.options.shared: + self.cpp_info.defines.append("BL_STATIC") diff --git a/recipes/blend2d/all/patches/0.0.17-0001-disable-embed-asmjit.patch b/recipes/blend2d/all/patches/0.0.17-0001-disable-embed-asmjit.patch new file mode 100644 index 0000000000000..6a3ccd1e255b1 --- /dev/null +++ b/recipes/blend2d/all/patches/0.0.17-0001-disable-embed-asmjit.patch @@ -0,0 +1,19 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 52d295a..b1a78a5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -398,10 +398,10 @@ if (NOT BLEND2D_NO_JIT) + set(ASMJIT_EMBED TRUE CACHE BOOL "") + endif() + +- include("${ASMJIT_DIR}/CMakeLists.txt") +- list(APPEND BLEND2D_DEPS ${ASMJIT_LIBS}) +- list(APPEND BLEND2D_PRIVATE_CFLAGS ${ASMJIT_CFLAGS}) +- list(APPEND BLEND2D_PRIVATE_CFLAGS -DASMJIT_NO_STDCXX) ++ find_package(asmjit CONFIG REQUIRED) ++ list(APPEND BLEND2D_DEPS asmjit::asmjit) ++ list(APPEND BLEND2D_PRIVATE_CFLAGS ${asmjit_DEFINITIONS_DEBUG}${asmjit_DEFINITIONS_RELEASE}) ++ + + # A possibility to reduce the resulting binary size by disabling asmjit logging. + if (BLEND2D_NO_JIT_LOGGING) diff --git a/recipes/blend2d/all/patches/0.0.18-0002-fix-gcc12-compilationerror.patch b/recipes/blend2d/all/patches/0.0.18-0002-fix-gcc12-compilationerror.patch new file mode 100644 index 0000000000000..b089c5a2e867f --- /dev/null +++ b/recipes/blend2d/all/patches/0.0.18-0002-fix-gcc12-compilationerror.patch @@ -0,0 +1,39 @@ +diff --git a/src/blend2d/support/arenaallocator_p.h b/src/blend2d/support/arenaallocator_p.h +index d09b6da..eebd854 100644 +--- a/src/blend2d/support/arenaallocator_p.h ++++ b/src/blend2d/support/arenaallocator_p.h +@@ -445,7 +445,7 @@ public: + template + class BLArenaAllocatorTmp : public BLArenaAllocator { + public: +- BL_NONCOPYABLE(BLArenaAllocatorTmp) ++ BL_NONCOPYABLE(BLArenaAllocatorTmp) + + BL_INLINE explicit BLArenaAllocatorTmp(size_t blockSize, size_t blockAlignment = 1) noexcept + : BLArenaAllocator(blockSize, blockAlignment, _storage.data, N) {} +diff --git a/src/blend2d/support/arenahashmap_p.h b/src/blend2d/support/arenahashmap_p.h +index 29882e1..911d985 100644 +--- a/src/blend2d/support/arenahashmap_p.h ++++ b/src/blend2d/support/arenahashmap_p.h +@@ -185,7 +185,7 @@ public: + template + class BLArenaHashMap : public BLArenaHashMapBase { + public: +- BL_NONCOPYABLE(BLArenaHashMap) ++ BL_NONCOPYABLE(BLArenaHashMap) + + typedef NodeT Node; + +diff --git a/src/blend2d/support/scopedbuffer_p.h b/src/blend2d/support/scopedbuffer_p.h +index e14df50..379f519 100644 +--- a/src/blend2d/support/scopedbuffer_p.h ++++ b/src/blend2d/support/scopedbuffer_p.h +@@ -82,7 +82,7 @@ public: + template + class BLScopedBufferTmp : public BLScopedBuffer { + public: +- BL_NONCOPYABLE(BLScopedBufferTmp) ++ BL_NONCOPYABLE(BLScopedBufferTmp) + + uint8_t _storage[N]; + diff --git a/recipes/blend2d/all/test_package/CMakeLists.txt b/recipes/blend2d/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7ac05ac9286e7 --- /dev/null +++ b/recipes/blend2d/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(blend2d CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE blend2d::blend2d) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/blend2d/all/test_package/conanfile.py b/recipes/blend2d/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/blend2d/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/blend2d/all/test_package/test_package.cpp b/recipes/blend2d/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7bc7acd9b0bd1 --- /dev/null +++ b/recipes/blend2d/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include + +#include "blend2d.h" + +int main() { + auto img = BLImage(480, 480, BL_FORMAT_PRGB32); + return 0; +} diff --git a/recipes/blend2d/all/test_v1_package/CMakeLists.txt b/recipes/blend2d/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/blend2d/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/blend2d/all/test_v1_package/conanfile.py b/recipes/blend2d/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/blend2d/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/blend2d/config.yml b/recipes/blend2d/config.yml new file mode 100644 index 0000000000000..dfbc91823fb6c --- /dev/null +++ b/recipes/blend2d/config.yml @@ -0,0 +1,5 @@ +versions: + "0.0.18": + folder: all + "0.0.17": + folder: all diff --git a/recipes/bliss/all/CMakeLists.txt b/recipes/bliss/all/CMakeLists.txt index 2249bc862f359..8bdaa1e47bfa0 100644 --- a/recipes/bliss/all/CMakeLists.txt +++ b/recipes/bliss/all/CMakeLists.txt @@ -1,55 +1,7 @@ -cmake_minimum_required(VERSION 3.4) +cmake_minimum_required(VERSION 3.5) project(cmake_wrapper) include(conanbuildinfo.cmake) conan_basic_setup() -option(WITH_GMP "With GMP" OFF) - -add_library(libbliss - source_subfolder/bliss_C.cc - source_subfolder/defs.cc - source_subfolder/Doxyfile - source_subfolder/graph.cc - source_subfolder/heap.cc - source_subfolder/orbit.cc - source_subfolder/partition.cc - source_subfolder/timer.cc - source_subfolder/uintseqhash.cc - source_subfolder/utils.cc -) -set_property(TARGET libbliss PROPERTY OUTPUT_NAME bliss) -target_link_libraries(libbliss PUBLIC ${CONAN_LIBS}) -if(WITH_GMP) - target_compile_definitions(libbliss PUBLIC BLISS_USE_GMP) -endif() -if(WIN32 AND BUILD_SHARED_LIBS) - set_property(TARGET libbliss PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - - -add_executable(bliss - source_subfolder/bliss.cc -) -target_link_libraries(bliss PRIVATE libbliss) - -install(TARGETS libbliss bliss - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin -) -install(FILES - source_subfolder/bliss_C.h - source_subfolder/heap.hh - source_subfolder/kqueue.hh - source_subfolder/kstack.hh - source_subfolder/utils.hh - source_subfolder/bignum.hh - source_subfolder/graph.hh - source_subfolder/defs.hh - source_subfolder/timer.hh - source_subfolder/uintseqhash.hh - source_subfolder/partition.hh - source_subfolder/orbit.hh - DESTINATION include/bliss -) +add_subdirectory(source_subfolder) diff --git a/recipes/bliss/all/conandata.yml b/recipes/bliss/all/conandata.yml index 054c174924916..9472225934cbd 100644 --- a/recipes/bliss/all/conandata.yml +++ b/recipes/bliss/all/conandata.yml @@ -1,8 +1,10 @@ sources: - "0.73": - url: "http://www.tcs.hut.fi/Software/bliss/bliss-0.73.zip" - sha256: "f57bf32804140cad58b1240b804e0dbd68f7e6bf67eba8e0c0fa3a62fd7f0f84" + "0.77": + url: "https://users.aalto.fi/~tjunttil/bliss/downloads/bliss-0.77.zip" + sha256: "acc8b98034f30fad24c897f365abd866c13d9f1bb207e398d0caf136875972a4" patches: - "0.73": - - patch_file: "patches/0001-patch-sources.patch" + "0.77": + - patch_file: "patches/0001-fix-cmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-no-assert-non-existent-member-variable.patch" base_path: "source_subfolder" diff --git a/recipes/bliss/all/conanfile.py b/recipes/bliss/all/conanfile.py index 73c48f1c7dc1f..5a7032f515942 100644 --- a/recipes/bliss/all/conanfile.py +++ b/recipes/bliss/all/conanfile.py @@ -1,5 +1,8 @@ -import os from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" class BlissConan(ConanFile): @@ -7,7 +10,7 @@ class BlissConan(ConanFile): description = "bliss is an open source tool for computing automorphism groups and canonical forms of graphs. " topics = "conan", "bliss", "automorphism", "group", "graph" url = "https://github.com/conan-io/conan-center-index" - homepage = "http://www.tcs.hut.fi/Software/bliss/" + homepage = "https://users.aalto.fi/~tjunttil/bliss" license = "GPL-3-or-later", "LGPL-3-or-later" settings = "arch", "os", "compiler", "build_type" options = { @@ -33,10 +36,6 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("bliss-{}".format(self.version), self._source_subfolder) - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -51,12 +50,22 @@ def requirements(self): elif self.options.with_exact_int == "mpir": self.requires("mpir/3.0.0") + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < "15": + raise ConanInvalidConfiguration("bliss doesn't support Visual Studio < 2017") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - self._cmake.definitions["WITH_GMP"] = self.options.with_exact_int != False + self._cmake.definitions["USE_GMP"] = self.options.with_exact_int != False self._cmake.configure(build_folder=self._build_subfolder) return self._cmake @@ -74,10 +83,12 @@ def package(self): cmake.install() def package_info(self): - self.cpp_info.libs = ["bliss"] + self.cpp_info.libs = ["bliss" if self.options.shared else "bliss_static"] self.cpp_info.includedirs.append(os.path.join("include", "bliss")) if self.options.with_exact_int != False: self.cpp_info.defines = ["BLISS_USE_GMP"] + if self.settings.compiler == "Visual Studio": + self.cpp_info.cxxflags.append("/permissive-") bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) diff --git a/recipes/bliss/all/patches/0001-fix-cmake.patch b/recipes/bliss/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..2831deda49096 --- /dev/null +++ b/recipes/bliss/all/patches/0001-fix-cmake.patch @@ -0,0 +1,51 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -14,17 +14,11 @@ if (MSVC) + add_compile_options(/permissive-) + else() + # Warnings, optimization, no assertions +- add_compile_options(-Wall -pedantic -O3 -DNDEBUG) #-Wextra -Werror + endif() + + if(USE_GMP) +- find_path(GMP_INCLUDE_DIR NAMES gmp.h) +- find_library(GMP_LIBRARIES NAMES gmp libgmp mpir REQUIRED) +- if (MSVC) +- add_compile_options(/DBLISS_USE_GMP /I${GMP_INCLUDE_DIR}) +- else() +- add_compile_options(-DBLISS_USE_GMP -I${GMP_INCLUDE_DIR}) +- endif() ++ link_libraries(${CONAN_LIBS}) ++ add_definitions(-DBLISS_USE_GMP) + endif(USE_GMP) + + set( +@@ -50,7 +44,7 @@ endif(MSVC) + + # Add the shared library + add_library(bliss SHARED ${BLISS_SOURCE_FILES}) +-set_property(TARGET bliss PROPERTY POSITION_INDEPENDENT_CODE 1) ++set_property(TARGET bliss PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) + + # Add the static library + add_library(bliss_static STATIC ${BLISS_SOURCE_FILES}) +@@ -59,6 +53,18 @@ add_library(bliss_static STATIC ${BLISS_SOURCE_FILES}) + add_executable(bliss-executable src/bliss.cc) + target_link_libraries(bliss-executable bliss_static) + if(USE_GMP) +- target_link_libraries(bliss-executable ${GMP_LIBRARIES}) + endif(USE_GMP) + set_target_properties(bliss-executable PROPERTIES OUTPUT_NAME bliss) ++ ++install(TARGETS bliss-executable DESTINATION ${CMAKE_INSTALL_BINDIR}) ++ ++file(GLOB BLISS_HEADERS src/*.h src/*.hh) ++install(FILES ${BLISS_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bliss) ++if(BUILD_SHARED_LIBS) ++ install(TARGETS bliss ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++else() ++ install(TARGETS bliss_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++endif() diff --git a/recipes/bliss/all/patches/0001-patch-sources.patch b/recipes/bliss/all/patches/0001-patch-sources.patch deleted file mode 100644 index 3dd2edf39bb5a..0000000000000 --- a/recipes/bliss/all/patches/0001-patch-sources.patch +++ /dev/null @@ -1,177 +0,0 @@ ---- bliss.cc -+++ bliss.cc -@@ -1,3 +1,8 @@ -+#ifdef _MSC_VER -+#define and && -+#define not ! -+#define or || -+#endif - #include - #include - #include -@@ -53,13 +58,13 @@ - { - const char* program_name; - -- program_name = rindex(argv0, '/'); -+ program_name = strrchr(argv0, '/'); - - if(program_name) program_name++; - else program_name = argv0; - if(!program_name or *program_name == 0) program_name = "bliss"; - -- fprintf(fp, "bliss version %s (compiled "__DATE__")\n", bliss::version); -+ fprintf(fp, "bliss version %s (compiled " __DATE__ ")\n", bliss::version); - fprintf(fp, "Copyright 2003-2015 Tommi Junttila\n"); - fprintf(fp, - "\n" ---- bliss_C.cc -+++ bliss_C.cc -@@ -1,3 +1,8 @@ -+#ifdef _MSC_VER -+#define and && -+#define not ! -+#define or || -+#endif - #include - #include - #include ---- defs.cc -+++ defs.cc -@@ -1,3 +1,8 @@ -+#ifdef _MSC_VER -+#define and && -+#define not ! -+#define or || -+#endif - #include - #include - #include "defs.hh" ---- graph.cc -+++ graph.cc -@@ -1,3 +1,8 @@ -+#ifdef _MSC_VER -+#define and && -+#define not ! -+#define or || -+#endif - #include - #include - #include ---- heap.cc -+++ heap.cc -@@ -1,3 +1,8 @@ -+#ifdef _MSC_VER -+#define and && -+#define not ! -+#define or || -+#endif - #include - #include - #include ---- orbit.cc -+++ orbit.cc -@@ -1,3 +1,8 @@ -+#ifdef _MSC_VER -+#define and && -+#define not ! -+#define or || -+#endif - #include - #include - #include "defs.hh" ---- partition.cc -+++ partition.cc -@@ -1,3 +1,8 @@ -+#ifdef _MSC_VER -+#define and && -+#define not ! -+#define or || -+#endif - #include - #include - #include ---- timer.cc -+++ timer.cc -@@ -1,5 +1,14 @@ -+#ifdef _MSC_VER -+#define and && -+#define not ! -+#define or || -+#endif -+#ifdef WIN32 -+#include -+#else - #include - #include -+#endif - #include "timer.hh" - - /* -@@ -22,9 +29,9 @@ - */ - - namespace bliss { -- -+#ifndef WIN32 - static const double numTicksPerSec = (double)(sysconf(_SC_CLK_TCK)); -- -+#endif - Timer::Timer() - { - reset(); -@@ -32,24 +39,30 @@ - - void Timer::reset() - { -+#ifdef WIN32 -+ start_time = GetTickCount() / 1000.; -+#else - struct tms clkticks; -- - times(&clkticks); - start_time = - ((double) clkticks.tms_utime + (double) clkticks.tms_stime) / - numTicksPerSec; -+#endif - } - - - double Timer::get_duration() - { -+#ifdef WIN32 -+ return GetTickCount() / 1000. - start_time; -+#else - struct tms clkticks; -- - times(&clkticks); - double intermediate = - ((double) clkticks.tms_utime + (double) clkticks.tms_stime) / - numTicksPerSec; - return intermediate - start_time; -+#endif - } - - } // namespace bliss ---- uintseqhash.cc -+++ uintseqhash.cc -@@ -1,3 +1,8 @@ -+#ifdef _MSC_VER -+#define and && -+#define not ! -+#define or || -+#endif - #include "uintseqhash.hh" - - /* ---- utils.cc -+++ utils.cc -@@ -1,3 +1,8 @@ -+#ifdef _MSC_VER -+#define and && -+#define not ! -+#define or || -+#endif - #include - #include - #include "utils.hh" diff --git a/recipes/bliss/all/patches/0002-no-assert-non-existent-member-variable.patch b/recipes/bliss/all/patches/0002-no-assert-non-existent-member-variable.patch new file mode 100644 index 0000000000000..ac4d2de7b66ff --- /dev/null +++ b/recipes/bliss/all/patches/0002-no-assert-non-existent-member-variable.patch @@ -0,0 +1,10 @@ +--- a/src/graph.cc ++++ b/src/graph.cc +@@ -748,7 +748,6 @@ Graph::split_neighbourhood_of_cell(Partition::Cell* const cell) + + + Partition::Cell* const last_new_cell = p.zplit_cell(neighbour_cell, true); +- assert(neighbour_cell->nof_nonzeros == 0); + + /* Update certificate and hash if needed */ + const Partition::Cell* c = neighbour_cell; diff --git a/recipes/bliss/all/test_package/CMakeLists.txt b/recipes/bliss/all/test_package/CMakeLists.txt index 196188113685c..33ae887aa6aea 100644 --- a/recipes/bliss/all/test_package/CMakeLists.txt +++ b/recipes/bliss/all/test_package/CMakeLists.txt @@ -6,3 +6,4 @@ conan_basic_setup() add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/bliss/all/test_package/test_package.cpp b/recipes/bliss/all/test_package/test_package.cpp index 83680f5c1389c..b06e698ccf141 100644 --- a/recipes/bliss/all/test_package/test_package.cpp +++ b/recipes/bliss/all/test_package/test_package.cpp @@ -1,6 +1,7 @@ -#include "graph.hh" +#include -#include +#include +#include int main() { bliss::Graph graph(4); @@ -13,9 +14,9 @@ int main() { graph.add_edge(1, 3); graph.add_edge(2, 3); - graph.write_dot(stdout); - fprintf(stdout, "===\n"); - graph.write_dimacs(stdout); + graph.write_dot("dot_output.txt"); + std::ifstream ifs("dot_output.txt", std::ios::binary); + std::cout << ifs.rdbuf() << std::endl; return 0; } diff --git a/recipes/bliss/config.yml b/recipes/bliss/config.yml index 443d1fc7030b4..ef686fd171068 100644 --- a/recipes/bliss/config.yml +++ b/recipes/bliss/config.yml @@ -1,3 +1,3 @@ versions: - "0.73": + "0.77": folder: all diff --git a/recipes/boolean-lite/all/conandata.yml b/recipes/boolean-lite/all/conandata.yml index e15d45bc36d1f..0fb54f08285a9 100644 --- a/recipes/boolean-lite/all/conandata.yml +++ b/recipes/boolean-lite/all/conandata.yml @@ -1,4 +1,4 @@ sources: "0.1.0": - url: https://github.com/martinmoene/boolean-lite/archive/v0.1.0.tar.gz - sha256: 4ee534b73f8cc007f0df2cae642ac4aa9c2f42f310c3dfb6844cc0dabd208a75 + url: "https://github.com/martinmoene/boolean-lite/archive/v0.1.0.tar.gz" + sha256: "30687455c55877464b61b87b66798af8bce45b6f90f1709c030f263fdcb5d97d" diff --git a/recipes/boolean-lite/all/conanfile.py b/recipes/boolean-lite/all/conanfile.py index 64684547f94b4..312d87af87164 100644 --- a/recipes/boolean-lite/all/conanfile.py +++ b/recipes/boolean-lite/all/conanfile.py @@ -1,37 +1,51 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.50.0" + class BooleanLiteConan(ConanFile): name = "boolean-lite" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/martinmoene/boolean-lite" description = "boolean lite - A strong boolean type for C++98 and later in a single-file header-only library" - topics = ("conan", "boolean-lite", "strong bool", "cpp98/11/17") + topics = ("boolean-lite", "strong bool", "cpp98/11/17") license = "BSL-1.0" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "boolean-lite") + self.cpp_info.set_property("cmake_target_name", "nonstd::boolean-lite") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "boolean-lite" self.cpp_info.filenames["cmake_find_package_multi"] = "boolean-lite" self.cpp_info.names["cmake_find_package"] = "nonstd" self.cpp_info.names["cmake_find_package_multi"] = "nonstd" self.cpp_info.components["booleanlite"].names["cmake_find_package"] = "boolean-lite" self.cpp_info.components["booleanlite"].names["cmake_find_package_multi"] = "boolean-lite" + self.cpp_info.components["booleanlite"].set_property("cmake_target_name", "nonstd::boolean-lite") diff --git a/recipes/boolean-lite/all/test_package/CMakeLists.txt b/recipes/boolean-lite/all/test_package/CMakeLists.txt index d7a99515e8641..3c97278b05cc2 100644 --- a/recipes/boolean-lite/all/test_package/CMakeLists.txt +++ b/recipes/boolean-lite/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES CXX) find_package(boolean-lite REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} nonstd::boolean-lite) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::boolean-lite) diff --git a/recipes/boolean-lite/all/test_package/conanfile.py b/recipes/boolean-lite/all/test_package/conanfile.py index abcaeed3f89b6..d120a992c06a6 100644 --- a/recipes/boolean-lite/all/test_package/conanfile.py +++ b/recipes/boolean-lite/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/boolean-lite/all/test_v1_package/CMakeLists.txt b/recipes/boolean-lite/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b87d5ceee70b7 --- /dev/null +++ b/recipes/boolean-lite/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(boolean-lite REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::boolean-lite) diff --git a/recipes/boolean-lite/all/test_v1_package/conanfile.py b/recipes/boolean-lite/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/boolean-lite/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/boolinq/all/conandata.yml b/recipes/boolinq/all/conandata.yml index 822e6e71317fb..750c8265f0482 100644 --- a/recipes/boolinq/all/conandata.yml +++ b/recipes/boolinq/all/conandata.yml @@ -1,4 +1,13 @@ sources: + "3.0.4": + url: "https://github.com/k06a/boolinq/archive/3.0.4.tar.gz" + sha256: "3cbee2b5f70ad98a8dfd1332dad0554a60628b69acb2477b5f035155fb9aed45" + "3.0.3": + url: "https://github.com/k06a/boolinq/archive/refs/tags/3.0.3.tar.gz" + sha256: "29e9233c07d234f442d58fa5c78a8187b5c28bbb938e38dd805a87ba0e762ed3" + "3.0.2": + url: "https://github.com/k06a/boolinq/archive/3.0.2.tar.gz" + sha256: "ad4c1bac9f4897262564e183d60adb784b86c8d407d7444ce8ac07b5db898356" "3.0.1": url: "https://github.com/k06a/boolinq/archive/3.0.1.tar.gz" sha256: "c72314aed7e43d1c35bf469057d264321599e358f5171d922924873c67b7f1ab" diff --git a/recipes/boolinq/all/conanfile.py b/recipes/boolinq/all/conanfile.py index ff716a57b4d5c..b9eaad3c63e47 100644 --- a/recipes/boolinq/all/conanfile.py +++ b/recipes/boolinq/all/conanfile.py @@ -1,32 +1,45 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.50.0" + class BoolinqConan(ConanFile): name = "boolinq" description = "Super tiny C++11 single-file header-only LINQ template library" - topics = ("conan", "boolinq", "linq", "header-only") + topics = ("boolinq", "linq", "header-only") license = "MIT" homepage = "https://github.com/k06a/boolinq" url = "https://github.com/conan-io/conan-center-index" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) - def package_id(self): - self.info.header_only() + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/boolinq/all/test_package/CMakeLists.txt b/recipes/boolinq/all/test_package/CMakeLists.txt index 33ae887aa6aea..bb2f73e7d69ee 100644 --- a/recipes/boolinq/all/test_package/CMakeLists.txt +++ b/recipes/boolinq/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(boolinq REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE boolinq::boolinq) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/boolinq/all/test_package/conanfile.py b/recipes/boolinq/all/test_package/conanfile.py index bd7165a553cf4..d120a992c06a6 100644 --- a/recipes/boolinq/all/test_package/conanfile.py +++ b/recipes/boolinq/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/boolinq/all/test_v1_package/CMakeLists.txt b/recipes/boolinq/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..cdc0bcf4354a1 --- /dev/null +++ b/recipes/boolinq/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(boolinq REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE boolinq::boolinq) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/boolinq/all/test_v1_package/conanfile.py b/recipes/boolinq/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/boolinq/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/boolinq/config.yml b/recipes/boolinq/config.yml index f1eca9cdf76de..ddaa431bd89d8 100644 --- a/recipes/boolinq/config.yml +++ b/recipes/boolinq/config.yml @@ -1,3 +1,9 @@ versions: + "3.0.4": + folder: all + "3.0.3": + folder: all + "3.0.2": + folder: all "3.0.1": folder: all diff --git a/recipes/boost-ext-ut/all/conandata.yml b/recipes/boost-ext-ut/all/conandata.yml index 188cb04ebb675..81ce02efd2b42 100644 --- a/recipes/boost-ext-ut/all/conandata.yml +++ b/recipes/boost-ext-ut/all/conandata.yml @@ -2,3 +2,11 @@ sources: "1.1.8": url: "https://github.com/boost-ext/ut/archive/v1.1.8.tar.gz" sha256: "3cc426dcf38397637e889efd9567b06d55dd23fb4e65cc0381eb8103a411d104" + "1.1.9": + url: "https://github.com/boost-ext/ut/archive/v1.1.9.tar.gz" + sha256: "1a666513157905aa0e53a13fac602b5673dcafb04a869100a85cd3f000c2ed0d" +patches: + "1.1.8": + - patch_file: "patches/license.patch" + "1.1.9": + - patch_file: "patches/1.1.9_cmake_project_version.patch" diff --git a/recipes/boost-ext-ut/all/conanfile.py b/recipes/boost-ext-ut/all/conanfile.py index 24f28b949daab..bce6579a06de7 100644 --- a/recipes/boost-ext-ut/all/conanfile.py +++ b/recipes/boost-ext-ut/all/conanfile.py @@ -1,73 +1,120 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration import os +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.52.0" + class UTConan(ConanFile): name = "boost-ext-ut" - description = ("C++17/20 single header/single module, " + description = ("C++20 single header/single module, " "macro-free micro Unit Testing Framework") - topics = ("conan", "UT", "header-only", "unit-test", "tdd", "bdd") + topics = ("ut", "header-only", "unit-test", "test", "tdd", "bdd") url = "https://github.com/conan-io/conan-center-index" homepage = "https://boost-ext.github.io/ut/" license = "BSL-1.0" settings = "os", "compiler", "arch", "build_type" no_copy_source = True + options = { "disable_module": [True, False], } + default_options = { "disable_module": False, } @property def _minimum_cpp_standard(self): - return 17 + return 17 if self.settings.compiler in ["clang", "gcc"] and Version(self.version) <= "1.1.8" else 20 @property def _minimum_compilers_version(self): return { - "Visual Studio": "16", - "gcc": "9", + "apple-clang": "11" if Version(self.version) < "1.1.8" else "12", "clang": "9", - "apple-clang": "11", + "gcc": "9", } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if Version(self.version) <= "1.1.8": + del self.options.disable_module + elif is_msvc(self): + self.options.disable_module = True - def configure(self): + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._minimum_cpp_standard) - min_version = self._minimum_compilers_version.get( - str(self.settings.compiler)) - if not min_version: - self.output.warn("{} recipe lacks information about the {} " - "compiler support.".format( - self.name, self.settings.compiler)) - else: - if tools.Version(self.settings.compiler.version) < min_version: - raise ConanInvalidConfiguration( - "{} requires C++{} support. " - "The current compiler {} {} does not support it.".format( - self.name, self._minimum_cpp_standard, - self.settings.compiler, - self.settings.compiler.version)) + check_min_cppstd(self, self._minimum_cpp_standard) + if Version(self.version) <= "1.1.8" and is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} may not be built with MSVC. " + "Please use at least version 1.1.9 with MSVC.") + + if is_msvc(self): + check_min_vs(self, "192") + if not self.options.get_safe("disable_module", True): + self.output.warn("The 'disable_module' option must be enabled when using MSVC.") + if not is_msvc(self): + min_version = self._minimum_compilers_version.get( + str(self.settings.compiler)) + if not min_version: + self.output.warn(f"{self.ref} recipe lacks information about the {self.settings.compiler} " + "compiler support.") + else: + if Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._minimum_cpp_standard} support. " + f"The current compiler {self.settings.compiler} {self.settings.compiler.version} does not support it.") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("ut-" + self.version, self._source_subfolder) - tools.download("https://www.boost.org/LICENSE_1_0.txt", "LICENSE", - sha256="c9bff75738922193e67fa726fa225535870d2aa1059f914" - "52c411736284ad566") + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["BOOST_UT_BUILD_BENCHMARKS"] = False + tc.cache_variables["BOOST_UT_BUILD_EXAMPLES"] = False + tc.cache_variables["BOOST_UT_BUILD_TESTS"] = not self.conf.get("tools.build:skip_test", default=True, check_type=bool) + tc.cache_variables["PROJECT_DISABLE_VERSION_SUFFIX"] = True + disable_module = self.options.get_safe("disable_module") + if disable_module: + tc.cache_variables["BOOST_UT_DISABLE_MODULE"] = disable_module + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - self.copy("LICENSE", dst="licenses") - self.copy(os.path.join("include", "boost", "ut.hpp"), - src=self._source_subfolder) + copy(self, "LICENSE*", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_id(self): - self.info.header_only() + self.info.clear() def package_info(self): - self.cpp_info.names["cmake_find_package"] = "boost" - self.cpp_info.names["cmake_find_package_multi"] = "boost" + newer_than_1_1_8 = Version(self.version) > "1.1.8" + namespace = "Boost" if newer_than_1_1_8 else "boost" + self.cpp_info.set_property("cmake_file_name", "ut") + self.cpp_info.set_property("cmake_target_name", f"{namespace}::ut") + + self.cpp_info.names["cmake_find_package"] = namespace + self.cpp_info.names["cmake_find_package_multi"] = namespace self.cpp_info.filenames["cmake_find_package"] = "ut" self.cpp_info.filenames["cmake_find_package_multi"] = "ut" self.cpp_info.components["ut"].names["cmake_find_package"] = "ut" self.cpp_info.components["ut"].names["cmake_find_package_multi"] = "ut" + + if newer_than_1_1_8: + self.cpp_info.components["ut"].includedirs = [os.path.join("include", "ut-" + self.version, "include")] + + if self.options.get_safe("disable_module"): + self.cpp_info.components["ut"].defines = ["BOOST_UT_DISABLE_MODULE=1"] diff --git a/recipes/boost-ext-ut/all/patches/1.1.9_cmake_project_version.patch b/recipes/boost-ext-ut/all/patches/1.1.9_cmake_project_version.patch new file mode 100644 index 0000000000000..8d99306e9fb42 --- /dev/null +++ b/recipes/boost-ext-ut/all/patches/1.1.9_cmake_project_version.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b9e94ab..ea96425 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -7,7 +7,7 @@ + cmake_minimum_required(VERSION 3.12...3.20) + project( + ut +- VERSION 1.1.8 ++ VERSION 1.1.9 + LANGUAGES CXX + ) + diff --git a/recipes/boost-ext-ut/all/patches/license.patch b/recipes/boost-ext-ut/all/patches/license.patch new file mode 100644 index 0000000000000..6a8a3069a851f --- /dev/null +++ b/recipes/boost-ext-ut/all/patches/license.patch @@ -0,0 +1,29 @@ +diff --git a/LICENSE_1_0.txt b/LICENSE_1_0.txt +new file mode 100644 +index 0000000..36b7cd9 +--- /dev/null ++++ b/LICENSE_1_0.txt +@@ -0,0 +1,23 @@ ++Boost Software License - Version 1.0 - August 17th, 2003 ++ ++Permission is hereby granted, free of charge, to any person or organization ++obtaining a copy of the software and accompanying documentation covered by ++this license (the "Software") to use, reproduce, display, distribute, ++execute, and transmit the Software, and to prepare derivative works of the ++Software, and to permit third-parties to whom the Software is furnished to ++do so, all subject to the following: ++ ++The copyright notices in the Software and this entire statement, including ++the above license grant, this restriction and the following disclaimer, ++must be included in all copies of the Software, in whole or in part, and ++all derivative works of the Software, unless such copies or derivative ++works are solely in the form of machine-executable object code generated by ++a source language processor. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT ++SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE ++FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ++ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ++DEALINGS IN THE SOFTWARE. diff --git a/recipes/boost-ext-ut/all/test_package/CMakeLists.txt b/recipes/boost-ext-ut/all/test_package/CMakeLists.txt index 831dc1f5b4b95..1f234990a3bc2 100644 --- a/recipes/boost-ext-ut/all/test_package/CMakeLists.txt +++ b/recipes/boost-ext-ut/all/test_package/CMakeLists.txt @@ -1,14 +1,13 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED yes) -set(CMAKE_CXX_EXTENSIONS no) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) find_package(ut REQUIRED CONFIG) +set(namespace Boost) +if(ut_VERSION VERSION_LESS "1.1.9") + set(namespace boost) +endif() + add_executable(test_package test_package.cpp) -target_link_libraries(test_package boost::ut) +target_link_libraries(test_package PRIVATE "${namespace}::ut") +target_compile_features(test_package PRIVATE cxx_std_20) diff --git a/recipes/boost-ext-ut/all/test_package/conanfile.py b/recipes/boost-ext-ut/all/test_package/conanfile.py index 7e2dfe859bb27..cb68885270b30 100644 --- a/recipes/boost-ext-ut/all/test_package/conanfile.py +++ b/recipes/boost-ext-ut/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -from conans import ConanFile, CMake, tools import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +22,5 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/recipes/boost-ext-ut/all/test_v1_package/CMakeLists.txt b/recipes/boost-ext-ut/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b3e2caed93a69 --- /dev/null +++ b/recipes/boost-ext-ut/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ut REQUIRED CONFIG) + +set(namespace Boost) +if(ut_VERSION VERSION_LESS "1.1.9") + set(namespace boost) +endif() + +add_executable(test_package ../test_package/test_package.cpp) +target_link_libraries(test_package PRIVATE "${namespace}::ut") +target_compile_features(test_package PRIVATE cxx_std_20) diff --git a/recipes/boost-ext-ut/all/test_v1_package/conanfile.py b/recipes/boost-ext-ut/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..37ada808989d9 --- /dev/null +++ b/recipes/boost-ext-ut/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +import os + +from conan.tools.build import cross_building +from conans import ConanFile, CMake + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/boost-ext-ut/config.yml b/recipes/boost-ext-ut/config.yml index c40ea90efe3de..968159344a038 100644 --- a/recipes/boost-ext-ut/config.yml +++ b/recipes/boost-ext-ut/config.yml @@ -1,3 +1,5 @@ versions: "1.1.8": folder: "all" + "1.1.9": + folder: "all" diff --git a/recipes/boost-leaf/all/conandata.yml b/recipes/boost-leaf/all/conandata.yml new file mode 100644 index 0000000000000..42c2ccab24961 --- /dev/null +++ b/recipes/boost-leaf/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.81.0": + url: "https://github.com/boostorg/leaf/archive/refs/tags/1.81.0.tar.gz" + sha256: "6a2bfa8727891e844f1f95c9c68af192f4c5f53b1707acce54290932118b48c0" diff --git a/recipes/boost-leaf/all/conanfile.py b/recipes/boost-leaf/all/conanfile.py new file mode 100644 index 0000000000000..dd5fcba91fc10 --- /dev/null +++ b/recipes/boost-leaf/all/conanfile.py @@ -0,0 +1,90 @@ +from conan import ConanFile +from conan.tools.files import get, copy +from conan.tools.layout import basic_layout +from conan.tools.build import check_min_cppstd +from conan.errors import ConanInvalidConfiguration +import os + + +required_conan_version = ">=1.50.0" + + +class BoostLEAFConan(ConanFile): + name = "boost-leaf" + license = "BSL-1.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/boostorg/leaf" + description = ("Lightweight Error Augmentation Framework") + topics = ("multi-platform", "multi-threading", "cpp11", "error-handling", + "header-only", "low-latency", "no-dependencies", "single-header") + settings = "os", "compiler", "arch", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + @property + def _min_cppstd(self): + return "11" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "4.8", + "Visual Studio": "17", + "msvc": "141", + "clang": "3.9", + "apple-clang": "10.0.0" + } + + def requirements(self): + pass + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._min_cppstd) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + compiler = str(self.settings.compiler) + version = str(self.settings.compiler.version) + minimum_version = self._compilers_minimum_version.get(compiler, False) + + if minimum_version and lazy_lt_semver(version, minimum_version): + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler ({compiler}-{version}) does not support") + + def layout(self): + basic_layout(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def package(self): + copy(self, "LICENSE_1_0.txt", dst=os.path.join( + self.package_folder, "licenses"), src=self.source_folder) + copy(self, "*.h", dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include")) + copy(self, "*.hpp", dst=os.path.join(self.package_folder, + "include"), src=os.path.join(self.source_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "boost-leaf") + self.cpp_info.set_property("cmake_target_name", "boost::leaf") + + self.cpp_info.names["cmake_find_package"] = "boost" + self.cpp_info.names["cmake_find_package_multi"] = "boost" + self.cpp_info.filenames["cmake_find_package"] = "boost-leaf" + self.cpp_info.filenames["cmake_find_package_multi"] = "boost-leaf" + self.cpp_info.components["leaf"].names["cmake_find_package"] = "leaf" + self.cpp_info.components["leaf"].names["cmake_find_package_multi"] = "leaf" + + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/boost-leaf/all/test_package/CMakeLists.txt b/recipes/boost-leaf/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ca3f81cb32f1b --- /dev/null +++ b/recipes/boost-leaf/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) + +find_package(boost-leaf REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} main.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF) +target_link_libraries(${PROJECT_NAME} PRIVATE boost::leaf) diff --git a/recipes/boost-leaf/all/test_package/conanfile.py b/recipes/boost-leaf/all/test_package/conanfile.py new file mode 100644 index 0000000000000..8a5bb47f50c4c --- /dev/null +++ b/recipes/boost-leaf/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/boost-leaf/all/test_package/main.cpp b/recipes/boost-leaf/all/test_package/main.cpp new file mode 100644 index 0000000000000..b6cf03bce1653 --- /dev/null +++ b/recipes/boost-leaf/all/test_package/main.cpp @@ -0,0 +1,64 @@ +#include +#include + +using namespace boost; + +enum custom_error_t +{ + err1, + err2, + err3, +}; + +leaf::result f1() +{ + return 5; +} + +leaf::result f2() +{ + return 15; +} + +leaf::result g(int a, int b) +{ + int sum = a + b; + if (sum == 20) + { + return leaf::new_error(custom_error_t::err2); + } + return sum; +} + +int main() +{ + leaf::result r = leaf::try_handle_some( + []() -> leaf::result + { + BOOST_LEAF_AUTO(v1, f1()); + BOOST_LEAF_AUTO(v2, f2()); + + return g(v1, v2); + }, + [](leaf::match) -> leaf::result + { + exit(1); + return -1; + }, + [](custom_error_t e) -> leaf::result + { + printf("Error value [%d] handled\n", static_cast(e)); + return 17; + }); + + if (r) + { + printf("value of r = %d\n", r.value()); + } + else + { + printf("r contains an error!\n"); + } + + return 0; +} diff --git a/recipes/boost-leaf/all/test_v1_package/CMakeLists.txt b/recipes/boost-leaf/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3b99781525c3c --- /dev/null +++ b/recipes/boost-leaf/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(boost-leaf REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/main.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF) +target_link_libraries(${PROJECT_NAME} PRIVATE boost::leaf) diff --git a/recipes/boost-leaf/all/test_v1_package/conanfile.py b/recipes/boost-leaf/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..25bed518a9fa8 --- /dev/null +++ b/recipes/boost-leaf/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class LibhalTestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = ("cmake", "cmake_find_package_multi") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.build_folder, "bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/boost-leaf/config.yml b/recipes/boost-leaf/config.yml new file mode 100644 index 0000000000000..80eea4560f825 --- /dev/null +++ b/recipes/boost-leaf/config.yml @@ -0,0 +1,3 @@ +versions: + "1.81.0": + folder: "all" diff --git a/recipes/boost/all/conandata.yml b/recipes/boost/all/conandata.yml index 1a803d063f8a9..ca9313ee3988b 100644 --- a/recipes/boost/all/conandata.yml +++ b/recipes/boost/all/conandata.yml @@ -1,10 +1,4 @@ sources: - 1.69.0: - url: [ - "https://boostorg.jfrog.io/artifactory/main/release/1.69.0/source/boost_1_69_0.tar.bz2", - "https://sourceforge.net/projects/boost/files/boost/1.69.0/boost_1_69_0.tar.bz2", - ] - sha256: "8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406" 1.70.0: url: [ "https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/boost_1_70_0.tar.bz2", @@ -46,16 +40,31 @@ sources: "https://sourceforge.net/projects/boost/files/boost/1.76.0/boost_1_76_0.tar.bz2" ] sha256: "f0397ba6e982c4450f27bf32a2a83292aba035b827a5623a14636ea583318c41" + 1.77.0: + url: [ + "https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2", + "https://sourceforge.net/projects/boost/files/boost/1.77.0/boost_1_77_0.tar.bz2" + ] + sha256: "fc9f85fc030e233142908241af7a846e60630aa7388de9a5fafb1f3a26840854" + 1.78.0: + url: [ + "https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.tar.bz2", + "https://sourceforge.net/projects/boost/files/boost/1.78.0/boost_1_78_0.tar.bz2" + ] + sha256: "8681f175d4bdb26c52222665793eef08490d7758529330f98d3b29dd0735bccc" + 1.79.0: + url: [ + "https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.bz2", + "https://sourceforge.net/projects/boost/files/boost/1.79.0/boost_1_79_0.tar.bz2" + ] + sha256: "475d589d51a7f8b3ba2ba4eda022b170e562ca3b760ee922c146b6c65856ef39" + 1.80.0: + url: [ + "https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2", + "https://sourceforge.net/projects/boost/files/boost/1.80.0/boost_1_80_0.tar.bz2" + ] + sha256: "1e19565d82e43bc59209a168f5ac899d3ba471d55c7610c677d4ccf2c9c500c0" patches: - 1.69.0: - - patch_file: "patches/boost_build_asmflags.patch" - base_path: "source_subfolder" - - patch_file: "patches/python_base_prefix.patch" - base_path: "source_subfolder" - - patch_file: "patches/static_object_init.patch" - base_path: "source_subfolder" - - patch_file: "patches/support_msvc_2019.patch" - base_path: "source_subfolder" 1.70.0: - patch_file: "patches/0001-beast-fix-moved-from-executor.patch" base_path: "source_subfolder" @@ -69,6 +78,20 @@ patches: base_path: "source_subfolder" - patch_file: "patches/solaris_pthread_data.patch" base_path: "source_subfolder" + - patch_file: "patches/boost_locale_fail_on_missing_backend.patch" + base_path: "source_subfolder" + - patch_file: "patches/boost_mpi_check.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-contract-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-locale-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-random-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-type_erasure-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.70.0-boost_build-with-newer-b2.patch" + base_path: "source_subfolder" 1.71.0: - patch_file: "patches/bcp_namespace_issues_1_71.patch" base_path: "source_subfolder" @@ -80,6 +103,20 @@ patches: base_path: "source_subfolder" - patch_file: "patches/solaris_pthread_data.patch" base_path: "source_subfolder" + - patch_file: "patches/boost_locale_fail_on_missing_backend.patch" + base_path: "source_subfolder" + - patch_file: "patches/boost_mpi_check.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-contract-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-locale-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-random-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-type_erasure-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.75.0-boost_build-with-newer-b2.patch" + base_path: "source_subfolder" 1.72.0: - patch_file: "patches/bcp_namespace_issues_1_72.patch" base_path: "source_subfolder" @@ -95,18 +132,147 @@ patches: base_path: "source_subfolder" - patch_file: "patches/boost_log_filesystem_no_deprecated_1_72.patch" base_path: "source_subfolder" + - patch_file: "patches/boost_locale_fail_on_missing_backend.patch" + base_path: "source_subfolder" + - patch_file: "patches/boost_mpi_check.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-locale-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-random-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-type_erasure-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.75.0-boost_build-with-newer-b2.patch" + base_path: "source_subfolder" 1.73.0: - patch_file: "patches/boost_build_qcc_fix_debug_build_parameter.patch" base_path: "source_subfolder" - patch_file: "patches/python_base_prefix.patch" base_path: "source_subfolder" + - patch_file: "patches/boost_locale_fail_on_missing_backend.patch" + base_path: "source_subfolder" + - patch_file: "patches/boost_mpi_check.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-locale-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-random-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-type_erasure-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.75.0-boost_build-with-newer-b2.patch" + base_path: "source_subfolder" 1.74.0: - patch_file: "patches/boost_build_qcc_fix_debug_build_parameter_since_1_74.patch" base_path: "source_subfolder" - patch_file: "patches/python_base_prefix_since_1_74.patch" base_path: "source_subfolder" + - patch_file: "patches/boost_locale_fail_on_missing_backend.patch" + base_path: "source_subfolder" + - patch_file: "patches/boost_mpi_check.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-locale-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-random-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-type_erasure-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.75.0-boost_build-with-newer-b2.patch" + base_path: "source_subfolder" 1.75.0: - patch_file: "patches/boost_build_qcc_fix_debug_build_parameter_since_1_74.patch" base_path: "source_subfolder" - patch_file: "patches/python_base_prefix_since_1_74.patch" base_path: "source_subfolder" + - patch_file: "patches/boost_locale_fail_on_missing_backend.patch" + base_path: "source_subfolder" + - patch_file: "patches/boost_mpi_check.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-locale-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.77.0-type_erasure-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.75.0-boost_build-with-newer-b2.patch" + base_path: "source_subfolder" + 1.76.0: + - patch_file: "patches/boost_locale_fail_on_missing_backend.patch" + base_path: "source_subfolder" + - patch_file: "patches/boost_mpi_check.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-locale-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.77.0-type_erasure-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.77.0-boost_build-with-newer-b2.patch" + base_path: "source_subfolder" + 1.77.0: + - patch_file: "patches/boost_locale_fail_on_missing_backend.patch" + base_path: "source_subfolder" + - patch_file: "patches/boost_1_77_mpi_check.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-locale-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.77.0-type_erasure-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.77.0-fiber-mingw.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.77.0-boost_build-with-newer-b2.patch" + base_path: "source_subfolder" + 1.78.0: + - patch_file: "patches/boost_locale_fail_on_missing_backend.patch" + base_path: "source_subfolder" + - patch_file: "patches/boost_1_77_mpi_check.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-locale-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.77.0-type_erasure-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.77.0-fiber-mingw.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.78.0-b2-fix-install.patch" + base_path: "source_subfolder" + 1.79.0: + - patch_file: "patches/boost_locale_fail_on_missing_backend.patch" + base_path: "source_subfolder" + - patch_file: "patches/boost_1_77_mpi_check.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.69.0-locale-no-system.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.77.0-fiber-mingw.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.79.0-0001-json-array-erase-relocate.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.79.0-smart_ptr_cw_ppc_msync.patch" + base_path: "source_subfolder" + - patch_file: "patches/1.79.0-geometry_no_rtti.patch" + base_path: "source_subfolder" + patch_type: "portability" + patch_source: "https://github.com/boostorg/geometry/discussions/1041" + 1.80.0: + - patch_file: "patches/1.80.0-locale-fail-on-missing-backend.patch" + patch_description: "Fails the build when there is no iconv backend" + patch_type: "conan" + base_path: "source_subfolder" + - patch_file: "patches/boost_1_77_mpi_check.patch" + patch_description: "Fails the build when mpi is not configured" + patch_type: "conan" + base_path: "source_subfolder" + - patch_file: "patches/1.80.0-0001-filesystem-win-fix-dir-it-net-share.patch" + patch_description: "Directory iterators may fail to construct for a network share on Windows prior to 10" + patch_type: "official" + patch_source: "https://github.com/boostorg/filesystem/issues/245" + base_path: "source_subfolder" + - patch_file: "patches/1.80.0-0002-filesystem-fix-weakly-canonical-long-path.patch" + patch_description: 'On Windows, weakly_canonical fails to process paths that start with the "\\?\" prefix' + patch_type: "official" + patch_source: "https://github.com/boostorg/filesystem/issues/247" + base_path: "source_subfolder" + - patch_file: "patches/1.80.0-0003-unordered-valid-after-move.patch" + patch_description: "Containers are not in a valid state after moving" + patch_type: "official" + patch_source: "https://github.com/boostorg/unordered/issues/139" + base_path: "source_subfolder" + - patch_file: "patches/1.80.0-0004-filesystem-posix-fix-no-at-apis-missing-include.patch" + patch_description: "On POSIX systems that don't support *at APIs, compilation fails due to a missing include" + patch_type: "official" + patch_source: "https://github.com/boostorg/filesystem/issues/250" + base_path: "source_subfolder" diff --git a/recipes/boost/all/conanfile.py b/recipes/boost/all/conanfile.py index 359e4a39d7c2d..ff43defcf2c0c 100644 --- a/recipes/boost/all/conanfile.py +++ b/recipes/boost/all/conanfile.py @@ -1,11 +1,15 @@ -from conans import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.build import build_jobs, check_min_cppstd, cross_building +from conan.tools.files import apply_conandata_patches, chdir, get, mkdir, rename, replace_in_file, rm, rmdir, save +from conan.tools.microsoft import msvc_runtime_flag +from conan import ConanFile +from conan.errors import ConanException, ConanInvalidConfiguration from conans import tools -from conans.tools import Version, cppstd_flag -from conans.errors import ConanException +from conan.tools.scm import Version -from conans.errors import ConanInvalidConfiguration import glob import os +import re import sys import shlex import shutil @@ -16,7 +20,7 @@ except ImportError: from io import StringIO -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.51.3" # When adding (or removing) an option, also add this option to the list in @@ -63,7 +67,7 @@ class BoostConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.boost.org" license = "BSL-1.0" - topics = ("conan", "boost", "libraries", "cpp") + topics = ("libraries", "cpp") _options = None @@ -74,6 +78,8 @@ class BoostConan(ConanFile): "system_no_deprecated": [True, False], "asio_no_deprecated": [True, False], "filesystem_no_deprecated": [True, False], + "filesystem_use_std_fs": [True, False], + "filesystem_version": [None, "3", "4"], "fPIC": [True, False], "layout": ["system", "versioned", "tagged", "b2-default"], "magic_autolink": [True, False], # enables BOOST_ALL_NO_LIB @@ -89,15 +95,20 @@ class BoostConan(ConanFile): "lzma": [True, False], "zstd": [True, False], "segmented_stacks": [True, False], - "debug_level": [i for i in range(0, 14)], + "debug_level": list(range(0, 14)), "pch": [True, False], "extra_b2_flags": "ANY", # custom b2 flags - "i18n_backend": ["iconv", "icu", None], + "i18n_backend": ["iconv", "icu", None, "deprecated"], + "i18n_backend_iconv": ["libc", "libiconv", "off"], + "i18n_backend_icu": [True, False], "visibility": ["global", "protected", "hidden"], "addr2line_location": "ANY", "with_stacktrace_backtrace": [True, False], + "buildid": "ANY", + "python_buildid": "ANY", + "system_use_utf8": [True, False], } - options.update({"without_{}".format(_name): [True, False] for _name in CONFIGURE_OPTIONS}) + options.update({f"without_{_name}": [True, False] for _name in CONFIGURE_OPTIONS}) default_options = { "shared": False, @@ -106,6 +117,8 @@ class BoostConan(ConanFile): "system_no_deprecated": False, "asio_no_deprecated": False, "filesystem_no_deprecated": False, + "filesystem_use_std_fs": False, + "filesystem_version": None, "fPIC": True, "layout": "system", "magic_autolink": False, @@ -124,19 +137,27 @@ class BoostConan(ConanFile): "debug_level": 0, "pch": True, "extra_b2_flags": "None", - "i18n_backend": "iconv", + "i18n_backend": "deprecated", + "i18n_backend_iconv": "libc", + "i18n_backend_icu": False, "visibility": "hidden", "addr2line_location": "/usr/bin/addr2line", "with_stacktrace_backtrace": True, + "buildid": None, + "python_buildid": None, + "system_use_utf8": False, } - default_options.update({"without_{}".format(_name): False for _name in CONFIGURE_OPTIONS}) - default_options.update({"without_{}".format(_name): True for _name in ("graph_parallel", "mpi", "python")}) + default_options.update({f"without_{_name}": False for _name in CONFIGURE_OPTIONS}) + default_options.update({f"without_{_name}": True for _name in ("graph_parallel", "mpi", "python")}) short_paths = True no_copy_source = True - exports_sources = ['patches/*'] _cached_dependencies = None + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def export(self): self.copy(self._dependency_filename, src="dependencies", dst="dependencies") @@ -163,15 +184,16 @@ def _min_compiler_version_nowide(self): @property def _dependency_filename(self): - return "dependencies-{}.yml".format(self.version) + return f"dependencies-{self.version}.yml" @property def _dependencies(self): if self._cached_dependencies is None: dependencies_filepath = os.path.join(self.recipe_folder, "dependencies", self._dependency_filename) if not os.path.isfile(dependencies_filepath): - raise ConanException("Cannot find {}".format(dependencies_filepath)) - self._cached_dependencies = yaml.safe_load(open(dependencies_filepath)) + raise ConanException(f"Cannot find {dependencies_filepath}") + with open(dependencies_filepath, encoding='utf-8') as f: + self._cached_dependencies = yaml.safe_load(f) return self._cached_dependencies def _all_dependent_modules(self, name): @@ -210,7 +232,7 @@ def _bcp_dir(self): @property def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + return str(self.settings.compiler) in ["Visual Studio", "msvc"] @property def _is_clang_cl(self): @@ -227,7 +249,15 @@ def _python_executable(self): :return: path to the python interpreter executable, either set by option, or system default """ exe = self.options.python_executable if self.options.python_executable else sys.executable - return str(exe).replace('\\', '/') + return str(exe).replace("\\", "/") + + @property + def _is_windows_platform(self): + return self.settings.os in ["Windows", "WindowsStore", "WindowsCE"] + + @property + def _is_apple_embedded_platform(self): + return self.settings.os in ["iOS", "watchOS", "tvOS"] def config_options(self): if self.settings.os == "Windows": @@ -235,8 +265,8 @@ def config_options(self): # Test whether all config_options from the yml are available in CONFIGURE_OPTIONS for opt_name in self._configure_options: - if "without_{}".format(opt_name) not in self.options: - raise ConanException("{} has the configure options {} which is not available in conanfile.py".format(self._dependency_filename, opt_name)) + if f"without_{opt_name}" not in self.options: + raise ConanException(f"{self._dependency_filename} has the configure options {opt_name} which is not available in conanfile.py") # stacktrace_backtrace not supported on Windows if self.settings.os == "Windows": @@ -252,7 +282,7 @@ def config_options(self): else: version_cxx11_standard_json = self._min_compiler_version_default_cxx11 if version_cxx11_standard_json: - if tools.Version(self.settings.compiler.version) < version_cxx11_standard_json: + if Version(self.settings.compiler.version) < version_cxx11_standard_json: self.options.without_fiber = True self.options.without_json = True self.options.without_nowide = True @@ -261,17 +291,23 @@ def config_options(self): self.options.without_json = True self.options.without_nowide = True + # iconv is off by default on Windows and Solaris + if self._is_windows_platform or self.settings.os == "SunOS": + self.options.i18n_backend_iconv = "off" + elif is_apple_os(self): + self.options.i18n_backend_iconv = "libiconv" + elif self.settings.os == "Android": + # bionic provides iconv since API level 28 + api_level = self.settings.get_safe("os.api_level") + if api_level and Version(api_level) < "28": + self.options.i18n_backend_iconv = "libiconv" # Remove options not supported by this version of boost for dep_name in CONFIGURE_OPTIONS: if dep_name not in self._configure_options: - delattr(self.options, "without_{}".format(dep_name)) + delattr(self.options, f"without_{dep_name}") - if self.settings.compiler == "Visual Studio": - # Shared builds of numa do not link on Visual Studio due to missing symbols - self.options.numa = False - - if tools.Version(self.version) >= "1.76.0": + if Version(self.version) >= "1.76.0": # Starting from 1.76.0, Boost.Math requires a c++11 capable compiler # ==> disable it by default for older compilers or c++ standards @@ -279,7 +315,7 @@ def disable_math(): super_modules = self._all_super_modules("math") for smod in super_modules: try: - setattr(self.options, "without_{}".format(smod), True) + setattr(self.options, f"without_{smod}", True) except ConanException: pass @@ -290,9 +326,31 @@ def disable_math(): min_compiler_version = self._min_compiler_version_default_cxx11 if min_compiler_version is None: self.output.warn("Assuming the compiler supports c++11 by default") - elif tools.Version(self.settings.compiler.version) < min_compiler_version: + elif Version(self.settings.compiler.version) < min_compiler_version: disable_math() + if Version(self.version) >= "1.79.0": + # Starting from 1.79.0, Boost.Wave requires a c++11 capable compiler + # ==> disable it by default for older compilers or c++ standards + + def disable_wave(): + super_modules = self._all_super_modules("wave") + for smod in super_modules: + try: + setattr(self.options, f"without_{smod}", True) + except ConanException: + pass + + if self.settings.compiler.cppstd: + if not tools.valid_min_cppstd(self, 11): + disable_wave() + else: + min_compiler_version = self._min_compiler_version_default_cxx11 + if min_compiler_version is None: + self.output.warn("Assuming the compiler supports c++11 by default") + elif Version(self.settings.compiler.version) < min_compiler_version: + disable_wave() + @property def _configure_options(self): return self._dependencies["configure_options"] @@ -307,6 +365,9 @@ def _shared(self): @property def _stacktrace_addr2line_available(self): + if (self._is_apple_embedded_platform or self.settings.get_safe("os.subsystem") == "catalyst"): + # sandboxed environment - cannot launch external processes (like addr2line), system() function is forbidden + return False return not self.options.header_only and not self.options.without_stacktrace and self.settings.os != "Windows" def configure(self): @@ -316,21 +377,29 @@ def configure(self): elif self.options.shared: del self.options.fPIC + if self.options.i18n_backend != "deprecated": + self.output.warn("i18n_backend option is deprecated, do not use anymore.") + if self.options.i18n_backend == "iconv": + self.options.i18n_backend_iconv = "libiconv" + self.options.i18n_backend_icu = False + if self.options.i18n_backend == "icu": + self.options.i18n_backend_iconv = "off" + self.options.i18n_backend_icu = True + if self.options.i18n_backend == "None": + self.options.i18n_backend_iconv = "off" + self.options.i18n_backend_icu = False if self.options.without_locale: - self.options.i18n_backend = None - else: - if not self.options.i18n_backend: - raise ConanInvalidConfiguration("Boost.locale library requires a i18n_backend (either 'icu' or 'iconv')") + del self.options.i18n_backend_iconv + del self.options.i18n_backend_icu if not self.options.without_python: if not self.options.python_version: self.options.python_version = self._detect_python_version() self.options.python_executable = self._python_executable - - if self._stacktrace_addr2line_available: - if os.path.abspath(str(self.options.addr2line_location)) != str(self.options.addr2line_location): - raise ConanInvalidConfiguration("addr2line_location must be an absolute path to addr2line") else: + del self.options.python_buildid + + if not self._stacktrace_addr2line_available: del self.options.addr2line_location if self.options.get_safe("without_stacktrace", True): @@ -348,36 +417,43 @@ def validate(self): # Look also on the comments of the answer for more details # * Although the 'context' and 'atomic' library does not mention anything about threading, # when being build the compiler uses the -pthread flag, which makes it quite dangerous - for lib in ['locale', 'coroutine', 'wave', 'type_erasure', 'fiber', 'thread', 'context', 'atomic']: - if not self.options.get_safe('without_%s' % lib): - raise ConanInvalidConfiguration("Boost '%s' library requires multi threading" % lib) + for lib in ["locale", "coroutine", "wave", "type_erasure", "fiber", "thread", "context", "atomic"]: + if not self.options.get_safe(f"without_{lib}"): + raise ConanInvalidConfiguration(f"Boost '{lib}' library requires multi threading") + + if self._is_msvc and self._shared and "MT" in msvc_runtime_flag(self): + raise ConanInvalidConfiguration("Boost can not be built as shared library with MT runtime.") - if self.settings.compiler == "Visual Studio" and self._shared: - if "MT" in str(self.settings.compiler.runtime): - raise ConanInvalidConfiguration("Boost can not be built as shared library with MT runtime.") - if self.options.get_safe("numa"): - raise ConanInvalidConfiguration("Cannot build a shared boost with numa support on Visual Studio") + if not self.options.without_locale and self.options.i18n_backend_iconv == "off" and \ + not self.options.i18n_backend_icu and not self._is_windows_platform: + raise ConanInvalidConfiguration( + "Boost.Locale library needs either iconv or ICU library to be built on non windows platforms" + ) + + if self._stacktrace_addr2line_available: + if not os.path.isabs(str(self.options.addr2line_location)): + raise ConanInvalidConfiguration("addr2line_location must be an absolute path to addr2line") # Check, when a boost module is enabled, whether the boost modules it depends on are enabled as well. for mod_name, mod_deps in self._dependencies["dependencies"].items(): - if not self.options.get_safe("without_{}".format(mod_name), True): + if not self.options.get_safe(f"without_{mod_name}", True): for mod_dep in mod_deps: - if self.options.get_safe("without_{}".format(mod_dep), False): - raise ConanInvalidConfiguration("{} requires {}: {} is disabled".format(mod_name, mod_deps, mod_dep)) + if self.options.get_safe(f"without_{mod_dep}", False): + raise ConanInvalidConfiguration(f"{mod_name} requires {mod_deps}: {mod_dep} is disabled") if not self.options.get_safe("without_nowide", True): # nowide require a c++11-able compiler with movable std::fstream mincompiler_version = self._min_compiler_version_nowide if mincompiler_version: - if tools.Version(self.settings.compiler.version) < mincompiler_version: + if Version(self.settings.compiler.version) < mincompiler_version: raise ConanInvalidConfiguration("This compiler is too old to build Boost.nowide.") if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + check_min_cppstd(self, 11) else: version_cxx11_standard = self._min_compiler_version_default_cxx11 if version_cxx11_standard: - if tools.Version(self.settings.compiler.version) < version_cxx11_standard: + if Version(self.settings.compiler.version) < version_cxx11_standard: raise ConanInvalidConfiguration("Boost.{fiber,json} require a c++11 compiler (please set compiler.cppstd or use a newer compiler)") else: self.output.warn("I don't know what the default c++ standard of this compiler is. I suppose it supports c++11 by default.\n" @@ -386,30 +462,37 @@ def validate(self): if not all((self.options.without_fiber, self.options.get_safe("without_json", True))): # fiber/json require a c++11-able compiler. if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + check_min_cppstd(self, 11) else: version_cxx11_standard = self._min_compiler_version_default_cxx11 if version_cxx11_standard: - if tools.Version(self.settings.compiler.version) < version_cxx11_standard: + if Version(self.settings.compiler.version) < version_cxx11_standard: raise ConanInvalidConfiguration("Boost.{fiber,json} requires a c++11 compiler (please set compiler.cppstd or use a newer compiler)") else: self.output.warn("I don't know what the default c++ standard of this compiler is. I suppose it supports c++11 by default.\n" "This might cause some boost libraries not being built and conan components to fail.") - if tools.Version(self.version) >= "1.76.0": - # Starting from 1.76.0, Boost.Math requires a c++11 capable compiler + if Version(self.version) >= "1.76.0": + # Starting from 1.76.0, Boost.Math requires a compiler with c++ standard 11 or higher if not self.options.without_math: if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + check_min_cppstd(self, 11) else: min_compiler_version = self._min_compiler_version_default_cxx11 if min_compiler_version is not None: - if tools.Version(self.settings.compiler.version) < min_compiler_version: - raise ConanInvalidConfiguration("Boost.Math requires a C++11 capable compiler") + if Version(self.settings.compiler.version) < min_compiler_version: + raise ConanInvalidConfiguration("Boost.Math requires (boost:)cppstd>=11 (current one is lower)") - def build_requirements(self): - if not self.options.header_only: - self.build_requires("b2/4.5.0") + if Version(self.version) >= "1.79.0": + # Starting from 1.79.0, Boost.Wave requires a compiler with c++ standard 11 or higher + if not self.options.without_wave: + if self.settings.compiler.cppstd: + check_min_cppstd(self, 11) + else: + min_compiler_version = self._min_compiler_version_default_cxx11 + if min_compiler_version is not None: + if Version(self.settings.compiler.version) < min_compiler_version: + raise ConanInvalidConfiguration("Boost.Wave requires (boost:)cppstd>=11 (current one is lower)") def _with_dependency(self, dependency): """ @@ -417,7 +500,7 @@ def _with_dependency(self, dependency): """ for name, reqs in self._dependencies["requirements"].items(): if dependency in reqs: - if not self.options.get_safe("without_{}".format(name), True): + if not self.options.get_safe(f"without_{name}", True): return True return False @@ -439,11 +522,11 @@ def _with_zstd(self): @property def _with_icu(self): - return not self.options.header_only and self._with_dependency("icu") and self.options.i18n_backend == "icu" + return not self.options.header_only and self._with_dependency("icu") and self.options.get_safe("i18n_backend_icu") @property def _with_iconv(self): - return not self.options.header_only and self._with_dependency("iconv") and self.options.i18n_backend == "iconv" + return not self.options.header_only and self._with_dependency("iconv") and self.options.get_safe("i18n_backend_iconv") == "libiconv" @property def _with_stacktrace_backtrace(self): @@ -451,27 +534,30 @@ def _with_stacktrace_backtrace(self): def requirements(self): if self._with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self._with_bzip2: self.requires("bzip2/1.0.8") if self._with_lzma: self.requires("xz_utils/5.2.5") if self._with_zstd: - self.requires("zstd/1.5.0") + self.requires("zstd/1.5.2") if self._with_stacktrace_backtrace: self.requires("libbacktrace/cci.20210118") if self._with_icu: - self.requires("icu/68.2") - elif self._with_iconv: - self.requires("libiconv/1.16") + self.requires("icu/72.1") + if self._with_iconv: + self.requires("libiconv/1.17") def package_id(self): + del self.info.options.i18n_backend + if self.options.header_only: self.info.header_only() self.info.options.header_only = True else: del self.info.options.debug_level + del self.info.options.filesystem_version del self.info.options.pch del self.info.options.python_executable # PATH to the interpreter is not important, only version matters if self.options.without_python: @@ -479,11 +565,14 @@ def package_id(self): else: self.info.options.python_version = self._python_version + def build_requirements(self): + if not self.options.header_only: + self.build_requires("b2/4.9.2") + def source(self): - tools.get(**self.conan_data["sources"][self.version], + get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) ##################### BUILDING METHODS ########################### @@ -494,17 +583,18 @@ def _run_python_script(self, script): :return: output of the python script execution, or None, if script has failed """ output = StringIO() - command = '"%s" -c "%s"' % (self._python_executable, script) - self.output.info('running %s' % command) + command = f'"{self._python_executable}" -c "{script}"' + self.output.info(f"running {command}") try: self.run(command=command, output=output) except ConanException: self.output.info("(failed)") return None - output = output.getvalue().strip() + output = output.getvalue() # Conan is broken when run_to_output = True if "\n-----------------\n" in output: output = output.split("\n-----------------\n", 1)[1] + output = output.strip() return output if output != "None" else None def _get_python_path(self, name): @@ -517,7 +607,7 @@ def _get_python_path(self, name): # https://docs.python.org/2.7/library/sysconfig.html return self._run_python_script("from __future__ import print_function; " "import sysconfig; " - "print(sysconfig.get_path('%s'))" % name) + f"print(sysconfig.get_path('{name}'))") def _get_python_sc_var(self, name): """ @@ -527,7 +617,7 @@ def _get_python_sc_var(self, name): """ return self._run_python_script("from __future__ import print_function; " "import sysconfig; " - "print(sysconfig.get_config_var('%s'))" % name) + f"print(sysconfig.get_config_var('{name}'))") def _get_python_du_var(self, name): """ @@ -538,14 +628,22 @@ def _get_python_du_var(self, name): """ return self._run_python_script("from __future__ import print_function; " "import distutils.sysconfig as du_sysconfig; " - "print(du_sysconfig.get_config_var('%s'))" % name) + f"print(du_sysconfig.get_config_var('{name}'))") def _get_python_var(self, name): """ obtain value of python variable, either by sysconfig, or by distutils.sysconfig :param name: name of variable to be queried (such as LIBRARY or LDLIBRARY) :return: value of python sysconfig variable + + NOTE: distutils is deprecated and breaks the recipe since Python 3.10 """ + python_version_parts = self.info.options.python_version.split('.') + python_major = int(python_version_parts[0]) + python_minor = int(python_version_parts[1]) + if(python_major >= 3 and python_minor >= 10): + return self._get_python_sc_var(name) + return self._get_python_sc_var(name) or self._get_python_du_var(name) def _detect_python_version(self): @@ -555,15 +653,14 @@ def _detect_python_version(self): """ return self._run_python_script("from __future__ import print_function; " "import sys; " - "print('%s.%s' % (sys.version_info[0], sys.version_info[1]))") + "print('{}.{}'.format(sys.version_info[0], sys.version_info[1]))") @property def _python_version(self): version = self._detect_python_version() if self.options.python_version and version != self.options.python_version: - raise ConanInvalidConfiguration("detected python version %s doesn't match conan option %s" % (version, - self.options.python_version)) + raise ConanInvalidConfiguration(f"detected python version {version} doesn't match conan option {self.options.python_version}") return version @property @@ -592,10 +689,10 @@ def _python_includes(self): attempt to find directory containing Python.h header file :return: the directory with python includes """ - include = self._get_python_path('include') - plat_include = self._get_python_path('platinclude') - include_py = self._get_python_var('INCLUDEPY') - include_dir = self._get_python_var('INCLUDEDIR') + include = self._get_python_path("include") + plat_include = self._get_python_path("platinclude") + include_py = self._get_python_var("INCLUDEPY") + include_dir = self._get_python_var("INCLUDEDIR") python_inc = self._python_inc candidates = [include, @@ -606,14 +703,14 @@ def _python_includes(self): for candidate in candidates: if candidate: python_h = os.path.join(candidate, 'Python.h') - self.output.info('checking %s' % python_h) + self.output.info(f"checking {python_h}") if os.path.isfile(python_h): - self.output.info('found Python.h: %s' % python_h) - return candidate.replace('\\', '/') + self.output.info(f"found Python.h: {python_h}") + return candidate.replace("\\", "/") raise Exception("couldn't locate Python.h - make sure you have installed python development files") @property - def _python_libraries(self): + def _python_library_dir(self): """ attempt to find python development library :return: the full path to the python library to be linked with @@ -647,30 +744,32 @@ def _python_libraries(self): for prefix in library_prefixes: for suffix in library_suffixes: for version in versions: - candidates.append("%spython%s%s%s" % (prefix, version, abiflags, suffix)) + candidates.append(f"{prefix}python{version}{abiflags}{suffix}") for candidate in candidates: if candidate: python_lib = os.path.join(libdir, candidate) - self.output.info('checking %s' % python_lib) + self.output.info(f"checking {python_lib}") if os.path.isfile(python_lib): - self.output.info('found python library: %s' % python_lib) - return python_lib.replace('\\', '/') + self.output.info(f"found python library: {python_lib}") + return libdir.replace("\\", "/") raise ConanInvalidConfiguration("couldn't locate python libraries - make sure you have installed python development files") def _clean(self): src = os.path.join(self.source_folder, self._source_subfolder) - clean_dirs = [os.path.join(self.build_folder, "bin.v2"), - os.path.join(self.build_folder, "architecture"), - os.path.join(self.source_folder, self._bcp_dir), - os.path.join(src, "dist", "bin"), - os.path.join(src, "stage"), - os.path.join(src, "tools", "build", "src", "engine", "bootstrap"), - os.path.join(src, "tools", "build", "src", "engine", "bin.ntx86"), - os.path.join(src, "tools", "build", "src", "engine", "bin.ntx86_64")] + clean_dirs = [ + os.path.join(self.build_folder, "bin.v2"), + os.path.join(self.build_folder, "architecture"), + os.path.join(self.source_folder, self._bcp_dir), + os.path.join(src, "dist", "bin"), + os.path.join(src, "stage"), + os.path.join(src, "tools", "build", "src", "engine", "bootstrap"), + os.path.join(src, "tools", "build", "src", "engine", "bin.ntx86"), + os.path.join(src, "tools", "build", "src", "engine", "bin.ntx86_64"), + ] for d in clean_dirs: if os.path.isdir(d): - self.output.warn('removing "%s"' % d) + self.output.warn(f"removing '{d}'") shutil.rmtree(d) @property @@ -695,21 +794,21 @@ def _boost_build_dir(self): return os.path.join(self.source_folder, self._source_subfolder, "tools", "build") def _build_bcp(self): - folder = os.path.join(self.source_folder, self._source_subfolder, 'tools', 'bcp') + folder = os.path.join(self.source_folder, self._source_subfolder, "tools", "bcp") with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): - with tools.chdir(folder): - command = "%s -j%s --abbreviate-paths toolset=%s" % (self._b2_exe, tools.cpu_count(), self._toolset) + with chdir(self, folder): + command = f"{self._b2_exe} -j{build_jobs(self)} --abbreviate-paths toolset={self._toolset}" command += " -d%d" % self.options.debug_level self.output.warn(command) self.run(command, run_environment=True) def _run_bcp(self): with tools.vcvars(self.settings) if self._is_msvc or self._is_clang_cl else tools.no_op(): - with tools.chdir(self.source_folder): - os.mkdir(self._bcp_dir) - namespace = "--namespace=%s" % self.options.namespace + with chdir(self, self.source_folder): + mkdir(self, self._bcp_dir) + namespace = f"--namespace={self.options.namespace}" alias = "--namespace-alias" if self.options.namespace_alias else "" - boostdir = "--boost=%s" % self._source_subfolder + boostdir = f"--boost={self._source_subfolder}" libraries = {"build", "boost-build.jam", "boostcpp.jam", "boost_install", "headers"} for d in os.listdir(os.path.join(self._source_subfolder, "boost")): if os.path.isdir(os.path.join(self._source_subfolder, "boost", d)): @@ -717,33 +816,39 @@ def _run_bcp(self): for d in os.listdir(os.path.join(self._source_subfolder, "libs")): if os.path.isdir(os.path.join(self._source_subfolder, "libs", d)): libraries.add(d) - libraries = ' '.join(libraries) - command = "{bcp} {namespace} {alias} " \ - "{boostdir} {libraries} {outdir}".format(bcp=self._bcp_exe, - namespace=namespace, - alias=alias, - libraries=libraries, - boostdir=boostdir, - outdir=self._bcp_dir) + libraries = " ".join(libraries) + command = f"{self._bcp_exe} {namespace} {alias} {boostdir} {libraries} {self._bcp_dir}" self.output.warn(command) self.run(command) def build(self): - if tools.cross_building(self.settings, skip_x64_x86=True): + if cross_building(self, skip_x64_x86=True): # When cross building, do not attempt to run the test-executable (assume they work) - tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "libs", "stacktrace", "build", "Jamfile.v2"), + replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "libs", "stacktrace", "build", "Jamfile.v2"), "$(>) > $(<)", "echo \"\" > $(<)", strict=False) # Older clang releases require a thread_local variable to be initialized by a constant value - tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"), + replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"), "/* thread_local */", "thread_local", strict=False) - tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"), + replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"), "/* static __thread */", "static __thread", strict=False) - if self.settings.compiler == "apple-clang" or (self.settings.compiler == "clang" and tools.Version(self.settings.compiler.version) < 6): - tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"), + if self.settings.compiler == "apple-clang" or (self.settings.compiler == "clang" and Version(self.settings.compiler.version) < 6): + replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"), "thread_local", "/* thread_local */") - tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"), + replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"), "static __thread", "/* static __thread */") + replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "tools", "build", "src", "tools", "gcc.jam"), + "local generic-os = [ set.difference $(all-os) : aix darwin vxworks solaris osf hpux ] ;", + "local generic-os = [ set.difference $(all-os) : aix darwin vxworks solaris osf hpux iphone appletv ] ;", + strict=False) + replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "tools", "build", "src", "tools", "gcc.jam"), + "local no-threading = android beos haiku sgi darwin vxworks ;", + "local no-threading = android beos haiku sgi darwin vxworks iphone appletv ;", + strict=False) + replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "libs", "fiber", "build", "Jamfile.v2"), + " @numa", + " shared:.//boost_fiber : @numa", + strict=False) if self.options.header_only: self.output.warn("Header only package, skipping build") @@ -760,80 +865,89 @@ def build(self): # JOIN ALL FLAGS b2_flags = " ".join(self._build_flags) - full_command = "%s %s" % (self._b2_exe, b2_flags) + full_command = f"{self._b2_exe} {b2_flags}" # -d2 is to print more debug info and avoid travis timing out without output sources = os.path.join(self.source_folder, self._boost_dir) - full_command += ' --debug-configuration --build-dir="%s"' % self.build_folder + full_command += f' --debug-configuration --build-dir="{self.build_folder}"' self.output.warn(full_command) - with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): - with tools.chdir(sources): + # If sending a user-specified toolset to B2, setting the vcvars + # interferes with the compiler selection. + use_vcvars = self._is_msvc and not self.settings.compiler.get_safe("toolset", default="") + with tools.vcvars(self.settings) if use_vcvars else tools.no_op(): + with chdir(self, sources): # To show the libraries *1 # self.run("%s --show-libraries" % b2_exe) self.run(full_command, run_environment=True) @property def _b2_os(self): - return {"Windows": "windows", - "WindowsStore": "windows", - "Linux": "linux", - "Android": "android", - "Macos": "darwin", - "iOS": "iphone", - "watchOS": "iphone", - "tvOS": "appletv", - "FreeBSD": "freebsd", - "SunOS": "solaris"}.get(str(self.settings.os)) + return { + "Windows": "windows", + "WindowsStore": "windows", + "Linux": "linux", + "Android": "android", + "Macos": "darwin", + "iOS": "iphone", + "watchOS": "iphone", + "tvOS": "appletv", + "FreeBSD": "freebsd", + "SunOS": "solaris", + }.get(str(self.settings.os)) @property def _b2_address_model(self): if self.settings.arch in ("x86_64", "ppc64", "ppc64le", "mips64", "armv8", "armv8.3", "sparcv9"): return "64" - else: - return "32" + + return "32" @property def _b2_binary_format(self): - return {"Windows": "pe", - "WindowsStore": "pe", - "Linux": "elf", - "Android": "elf", - "Macos": "mach-o", - "iOS": "mach-o", - "watchOS": "mach-o", - "tvOS": "mach-o", - "FreeBSD": "elf", - "SunOS": "elf"}.get(str(self.settings.os)) + return { + "Windows": "pe", + "WindowsStore": "pe", + "Linux": "elf", + "Android": "elf", + "Macos": "mach-o", + "iOS": "mach-o", + "watchOS": "mach-o", + "tvOS": "mach-o", + "FreeBSD": "elf", + "SunOS": "elf", + }.get(str(self.settings.os)) @property def _b2_architecture(self): - if str(self.settings.arch).startswith('x86'): - return 'x86' - elif str(self.settings.arch).startswith('ppc'): - return 'power' - elif str(self.settings.arch).startswith('arm'): - return 'arm' - elif str(self.settings.arch).startswith('sparc'): - return 'sparc' - elif str(self.settings.arch).startswith('mips64'): - return 'mips64' - elif str(self.settings.arch).startswith('mips'): - return 'mips1' - else: - return None + if str(self.settings.arch).startswith("x86"): + return "x86" + if str(self.settings.arch).startswith("ppc"): + return "power" + if str(self.settings.arch).startswith("arm"): + return "arm" + if str(self.settings.arch).startswith("sparc"): + return "sparc" + if str(self.settings.arch).startswith("mips64"): + return "mips64" + if str(self.settings.arch).startswith("mips"): + return "mips1" + if str(self.settings.arch).startswith("s390"): + return "s390x" + + return None @property def _b2_abi(self): - if str(self.settings.arch).startswith('x86'): + if str(self.settings.arch).startswith("x86"): return "ms" if str(self.settings.os) in ["Windows", "WindowsStore"] else "sysv" - elif str(self.settings.arch).startswith('ppc'): + if str(self.settings.arch).startswith("ppc"): return "sysv" - elif str(self.settings.arch).startswith('arm'): + if str(self.settings.arch).startswith("arm"): return "aapcs" - elif str(self.settings.arch).startswith('mips'): + if str(self.settings.arch).startswith("mips"): return "o32" - else: - return None + + return None @property def _gnu_cxx11_abi(self): @@ -844,9 +958,9 @@ def _gnu_cxx11_abi(self): try: if str(self.settings.compiler.libcxx) == "libstdc++": return "0" - elif str(self.settings.compiler.libcxx) == "libstdc++11": + if str(self.settings.compiler.libcxx) == "libstdc++11": return "1" - except: + except ConanException: pass return None @@ -861,37 +975,42 @@ def _build_flags(self): flags.append("numa=on") # https://www.boost.org/doc/libs/1_70_0/libs/context/doc/html/context/architectures.html - if self._b2_os: - flags.append("target-os=%s" % self._b2_os) + if not self._is_apple_embedded_platform and self._b2_os: + flags.append(f"target-os={self._b2_os}") if self._b2_architecture: - flags.append("architecture=%s" % self._b2_architecture) + flags.append(f"architecture={self._b2_architecture}") if self._b2_address_model: - flags.append("address-model=%s" % self._b2_address_model) + flags.append(f"address-model={self._b2_address_model}") if self._b2_binary_format: - flags.append("binary-format=%s" % self._b2_binary_format) + flags.append(f"binary-format={self._b2_binary_format}") if self._b2_abi: - flags.append("abi=%s" % self._b2_abi) - - flags.append("--layout=%s" % self.options.layout) - flags.append("--user-config=%s" % os.path.join(self._boost_build_dir, 'user-config.jam')) - flags.append("-sNO_ZLIB=%s" % ("0" if self._with_zlib else "1")) - flags.append("-sNO_BZIP2=%s" % ("0" if self._with_bzip2 else "1")) - flags.append("-sNO_LZMA=%s" % ("0" if self._with_lzma else "1")) - flags.append("-sNO_ZSTD=%s" % ("0" if self._with_zstd else "1")) - - if self.options.i18n_backend == 'icu': - flags.append("-sICU_PATH={}".format(self.deps_cpp_info["icu"].rootpath)) - flags.append("boost.locale.iconv=off boost.locale.icu=on") - elif self.options.i18n_backend == 'iconv': - flags.append("boost.locale.iconv=on boost.locale.icu=off") + flags.append(f"abi={self._b2_abi}") + + flags.append(f"--layout={self.options.layout}") + flags.append(f"--user-config={os.path.join(self._boost_build_dir, 'user-config.jam')}") + flags.append(f"-sNO_ZLIB={'0' if self._with_zlib else '1'}") + flags.append(f"-sNO_BZIP2={'0' if self._with_bzip2 else '1'}") + flags.append(f"-sNO_LZMA={'0' if self._with_lzma else '1'}") + flags.append(f"-sNO_ZSTD={'0' if self._with_zstd else '1'}") + + if self.options.get_safe("i18n_backend_icu"): + flags.append("boost.locale.icu=on") + else: + flags.append("boost.locale.icu=off") flags.append("--disable-icu") + if self.options.get_safe("i18n_backend_iconv") in ["libc", "libiconv"]: + flags.append("boost.locale.iconv=on") + if self.options.get_safe("i18n_backend_iconv") == "libc": + flags.append("boost.locale.iconv.lib=libc") + else: + flags.append("boost.locale.iconv.lib=libiconv") else: - flags.append("boost.locale.iconv=off boost.locale.icu=off") - flags.append("--disable-icu --disable-iconv") + flags.append("boost.locale.iconv=off") + flags.append("--disable-iconv") def add_defines(library): for define in self.deps_cpp_info[library].defines: - flags.append("define=%s" % define) + flags.append(f"define={define}") if self._with_zlib: add_defines("zlib") @@ -903,27 +1022,27 @@ def add_defines(library): add_defines("zstd") if self._is_msvc: - flags.append("runtime-link=%s" % ("static" if "MT" in str(self.settings.compiler.runtime) else "shared")) - flags.append("runtime-debugging=%s" % ("on" if "d" in str(self.settings.compiler.runtime) else "off")) + flags.append(f"runtime-link={'static' if 'MT' in msvc_runtime_flag(self) else 'shared'}" % ()) + flags.append(f"runtime-debugging={'on' if 'd' in msvc_runtime_flag(self) else 'off'}") # For details https://boostorg.github.io/build/manual/master/index.html - flags.append("threading=%s" % ("single" if not self.options.multithreading else "multi" )) - flags.append("visibility=%s" % self.options.visibility) + flags.append(f"threading={'single' if not self.options.multithreading else 'multi'}") + flags.append(f"visibility={self.options.visibility}") - flags.append("link=%s" % ("shared" if self._shared else "static")) + flags.append(f"link={'shared' if self._shared else 'static'}") if self.settings.build_type == "Debug": flags.append("variant=debug") else: flags.append("variant=release") for libname in self._configure_options: - if not getattr(self.options, "without_%s" % libname): - flags.append("--with-%s" % libname) + if not getattr(self.options, f"without_{libname}"): + flags.append(f"--with-{libname}") - flags.append("toolset=%s" % self._toolset) + flags.append(f"toolset={self._toolset}") if self.settings.get_safe("compiler.cppstd"): - flags.append("cxxflags=%s" % cppstd_flag(self.settings)) + flags.append(f"cxxflags={tools.cppstd_flag(self.settings)}") # LDFLAGS link_flags = [] @@ -936,7 +1055,7 @@ def add_defines(library): if self.settings.build_type == "RelWithDebInfo": if self.settings.compiler == "gcc" or "clang" in str(self.settings.compiler): cxx_flags.append("-g") - elif self.settings.compiler == "Visual Studio": + elif self._is_msvc: cxx_flags.append("/Z7") @@ -944,15 +1063,15 @@ def add_defines(library): if self.settings.os not in ("Android", "Emscripten"): try: if self._gnu_cxx11_abi: - flags.append("define=_GLIBCXX_USE_CXX11_ABI=%s" % self._gnu_cxx11_abi) + flags.append(f"define=_GLIBCXX_USE_CXX11_ABI={self._gnu_cxx11_abi}") if self.settings.compiler in ("clang", "apple-clang"): libcxx = { "libstdc++11": "libstdc++", }.get(str(self.settings.compiler.libcxx), str(self.settings.compiler.libcxx)) - cxx_flags.append("-stdlib={}".format(libcxx)) - link_flags.append("-stdlib={}".format(libcxx)) - except: + cxx_flags.append(f"-stdlib={libcxx}") + link_flags.append(f"-stdlib={libcxx}") + except ConanException: pass if self.options.error_code_header_only: @@ -963,55 +1082,73 @@ def add_defines(library): flags.append("define=BOOST_ASIO_NO_DEPRECATED=1") if self.options.filesystem_no_deprecated: flags.append("define=BOOST_FILESYSTEM_NO_DEPRECATED=1") + if self.options.filesystem_use_std_fs: + flags.append("define=BOOST_DLL_USE_STD_FS=1") + if self.options.system_use_utf8: + flags.append("define=BOOST_SYSTEM_USE_UTF8=1") if self.options.segmented_stacks: flags.extend(["segmented-stacks=on", "define=BOOST_USE_SEGMENTED_STACKS=1", "define=BOOST_USE_UCONTEXT=1"]) flags.append("pch=on" if self.options.pch else "pch=off") - if tools.is_apple_os(self.settings.os): - if self.settings.get_safe("os.version"): - cxx_flags.append(tools.apple_deployment_target_flag(self.settings.os, - self.settings.get_safe("os.version"), - self.settings.get_safe("os.sdk"), - self.settings.get_safe("os.subsystem"), - self.settings.get_safe("arch"))) + if is_apple_os(self): + os_version = self.settings.get_safe("os.version") + if os_version: + os_subsystem = self.settings.get_safe("os.subsystem") + deployment_target_flag = tools.apple_deployment_target_flag( + self.settings.os, + os_version, + self.settings.get_safe("os.sdk"), + os_subsystem, + self.settings.get_safe("arch") + ) + cxx_flags.append(deployment_target_flag) + link_flags.append(deployment_target_flag) + if os_subsystem == "catalyst": + cxx_flags.append("--target=arm64-apple-ios-macabi") + link_flags.append("--target=arm64-apple-ios-macabi") if self.settings.os == "iOS": if self.options.multithreading: - cxx_flags.append("-DBOOST_AC_USE_PTHREADS") - cxx_flags.append("-DBOOST_SP_USE_PTHREADS") + cxx_flags.append("-DBOOST_SP_USE_SPINLOCK") - cxx_flags.append("-fembed-bitcode") + if self.conf.get("tools.apple:enable_bitcode", check_type=bool): + cxx_flags.append("-fembed-bitcode") if self._with_iconv: - flags.append("-sICONV_PATH={}".format(self.deps_cpp_info["libiconv"].rootpath)) + flags.append(f"-sICONV_PATH={self.deps_cpp_info['libiconv'].rootpath}") if self._with_icu: - flags.append("-sICU_PATH={}".format(self.deps_cpp_info["icu"].rootpath)) + flags.append(f"-sICU_PATH={self.deps_cpp_info['icu'].rootpath}") if not self.options["icu"].shared: # Using ICU_OPTS to pass ICU system libraries is not possible due to Boost.Regex disallowing it. - if self.settings.compiler == "Visual Studio": - icu_ldflags = " ".join("{}.lib".format(l) for l in self.deps_cpp_info["icu"].system_libs) + if self._is_msvc: + icu_ldflags = " ".join(f"{l}.lib" for l in self.deps_cpp_info["icu"].system_libs) else: - icu_ldflags = " ".join("-l{}".format(l) for l in self.deps_cpp_info["icu"].system_libs) + icu_ldflags = " ".join(f"-l{l}" for l in self.deps_cpp_info["icu"].system_libs) link_flags.append(icu_ldflags) - link_flags = 'linkflags="%s"' % " ".join(link_flags) if link_flags else "" + link_flags = f'linkflags="{" ".join(link_flags)}"' flags.append(link_flags) if self.options.get_safe("addr2line_location"): - cxx_flags.append("-DBOOST_STACKTRACE_ADDR2LINE_LOCATION={}".format(self.options.addr2line_location)) + cxx_flags.append(f"-DBOOST_STACKTRACE_ADDR2LINE_LOCATION={self.options.addr2line_location}") - cxx_flags = 'cxxflags="%s"' % " ".join(cxx_flags) if cxx_flags else "" + cxx_flags = f'cxxflags="{" ".join(cxx_flags)}"' flags.append(cxx_flags) + if self.options.buildid: + flags.append(f"--buildid={self.options.buildid}") + if not self.options.without_python and self.options.python_buildid: + flags.append(f"--python-buildid={self.options.python_buildid}") + if self.options.extra_b2_flags: flags.extend(shlex.split(str(self.options.extra_b2_flags))) flags.extend([ "install", - "--prefix=%s" % self.package_folder, - "-j%s" % tools.cpu_count(), + f"--prefix={self.package_folder}", + f"-j{build_jobs(self)}", "--abbreviate-paths", "-d%d" % self.options.debug_level, ]) @@ -1020,14 +1157,14 @@ def add_defines(library): @property def _build_cross_flags(self): flags = [] - if not tools.cross_building(self.settings): + if not cross_building(self): return flags - arch = self.settings.get_safe('arch') + arch = self.settings.get_safe("arch") self.output.info("Cross building, detecting compiler...") - if arch.startswith('arm'): - if 'hf' in arch: - flags.append('-mfloat-abi=hard') + if arch.startswith("arm"): + if "hf" in arch: + flags.append("-mfloat-abi=hard") elif self.settings.os == "Emscripten": pass elif arch in ["x86", "x86_64"]: @@ -1037,39 +1174,39 @@ def _build_cross_flags(self): elif arch.startswith("mips"): pass else: - self.output.warn("Unable to detect the appropriate ABI for %s architecture." % arch) - self.output.info("Cross building flags: %s" % flags) + self.output.warn(f"Unable to detect the appropriate ABI for {arch} architecture.") + self.output.info(f"Cross building flags: {flags}") return flags @property def _ar(self): - if "AR" in os.environ: + if os.environ.get("AR"): return os.environ["AR"] - if tools.is_apple_os(self.settings.os) and self.settings.compiler == "apple-clang": + if is_apple_os(self) and self.settings.compiler == "apple-clang": return tools.XCRun(self.settings).ar return None @property def _ranlib(self): - if "RANLIB" in os.environ: + if os.environ.get("RANLIB"): return os.environ["RANLIB"] - if tools.is_apple_os(self.settings.os) and self.settings.compiler == "apple-clang": + if is_apple_os(self) and self.settings.compiler == "apple-clang": return tools.XCRun(self.settings).ranlib return None @property def _cxx(self): - if "CXX" in os.environ: + if os.environ.get("CXX"): return os.environ["CXX"] - if tools.is_apple_os(self.settings.os) and self.settings.compiler == "apple-clang": + if is_apple_os(self) and self.settings.compiler == "apple-clang": return tools.XCRun(self.settings).cxx compiler_version = str(self.settings.compiler.version) - major = compiler_version.split(".")[0] + major = compiler_version.split(".", maxsplit=1)[0] if self.settings.compiler == "gcc": - return tools.which("g++-%s" % compiler_version) or tools.which("g++-%s" % major) or tools.which("g++") or "" + return tools.which(f"g++-{compiler_version}") or tools.which(f"g++-{major}") or tools.which("g++") or "" if self.settings.compiler == "clang": - return tools.which("clang++-%s" % compiler_version) or tools.which("clang++-%s" % major) or tools.which("clang++") or "" + return tools.which(f"clang++-{compiler_version}") or tools.which(f"clang++-{major}") or tools.which("clang++") or "" return "" def _create_user_config_jam(self, folder): @@ -1079,18 +1216,14 @@ def _create_user_config_jam(self, folder): contents = "" if self._zip_bzip2_requires_needed: def create_library_config(deps_name, name): - includedir = '"%s"' % self.deps_cpp_info[deps_name].include_paths[0].replace('\\', '/') - libdir = '"%s"' % self.deps_cpp_info[deps_name].lib_paths[0].replace('\\', '/') + includedir = '"%s"' % self.deps_cpp_info[deps_name].include_paths[0].replace("\\", "/") + libdir = '"%s"' % self.deps_cpp_info[deps_name].lib_paths[0].replace("\\", "/") lib = self.deps_cpp_info[deps_name].libs[0] version = self.deps_cpp_info[deps_name].version - return "\nusing {name} : {version} : " \ - "{includedir} " \ - "{libdir} " \ - "{lib} ;".format(name=name, - version=version, - includedir=includedir, - libdir=libdir, - lib=lib) + return f"\nusing {name} : {version} : " \ + f"{includedir} " \ + f"{libdir} " \ + f"{lib} ;" contents = "" if self._with_zlib: @@ -1104,31 +1237,34 @@ def create_library_config(deps_name, name): if not self.options.without_python: # https://www.boost.org/doc/libs/1_70_0/libs/python/doc/html/building/configuring_boost_build.html - contents += '\nusing python : {version} : "{executable}" : "{includes}" : "{libraries}" ;'\ - .format(version=self._python_version, - executable=self._python_executable, - includes=self._python_includes, - libraries=self._python_libraries) + contents += f'\nusing python : {self._python_version} : "{self._python_executable}" : "{self._python_includes}" : "{self._python_library_dir}" ;' + + if not self.options.without_mpi: + # https://www.boost.org/doc/libs/1_72_0/doc/html/mpi/getting_started.html + contents += "\nusing mpi ;" # Specify here the toolset with the binary if present if don't empty parameter : - contents += '\nusing "%s" : %s : ' % (self._toolset, self._toolset_version) + contents += f'\nusing "{self._toolset}" : {self._toolset_version} : ' + cxx_fwd_slahes = self._cxx.replace("\\", "/") if self._is_msvc: - contents += ' "%s"' % self._cxx.replace("\\", "/") + contents += f' "{cxx_fwd_slahes}"' else: - contents += ' %s' % self._cxx.replace("\\", "/") + contents += f' {cxx_fwd_slahes}' - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): if self.settings.compiler == "apple-clang": - contents += " -isysroot %s" % tools.XCRun(self.settings).sdk_path + contents += f" -isysroot {tools.XCRun(self.settings).sdk_path}" if self.settings.get_safe("arch"): - contents += " -arch %s" % tools.to_apple_arch(self.settings.arch) + contents += f" -arch {tools.to_apple_arch(self.settings.arch)}" contents += " : \n" if self._ar: - contents += '"%s" ' % tools.which(self._ar).replace("\\", "/") + ar_path = tools.which(self._ar).replace("\\", "/") + contents += f'"{ar_path}" ' if self._ranlib: - contents += '"%s" ' % tools.which(self._ranlib).replace("\\", "/") + ranlib_path = tools.which(self._ranlib).replace("\\", "/") + contents += f'"{ranlib_path}" ' cxxflags = tools.get_env("CXXFLAGS", "") + " " cflags = tools.get_env("CFLAGS", "") + " " cppflags = tools.get_env("CPPFLAGS", "") + " " @@ -1136,75 +1272,100 @@ def create_library_config(deps_name, name): asflags = tools.get_env("ASFLAGS", "") + " " if self._with_stacktrace_backtrace: - cppflags += " ".join("-I{}".format(p) for p in self.deps_cpp_info["libbacktrace"].include_paths) + " " - ldflags += " ".join("-L{}".format(p) for p in self.deps_cpp_info["libbacktrace"].lib_paths) + " " + cppflags += " ".join(f"-I{p}" for p in self.deps_cpp_info["libbacktrace"].include_paths) + " " + ldflags += " ".join(f"-L{p}" for p in self.deps_cpp_info["libbacktrace"].lib_paths) + " " if cxxflags.strip(): - contents += '"%s" ' % cxxflags.strip() + contents += f'"{cxxflags.strip()}" ' if cflags.strip(): - contents += '"%s" ' % cflags.strip() + contents += f'"{cflags.strip()}" ' if cppflags.strip(): - contents += '"%s" ' % cppflags.strip() + contents += f'"{cppflags.strip()}" ' if ldflags.strip(): - contents += '"%s" ' % ldflags.strip() + contents += f'"{ldflags.strip()}" ' if asflags.strip(): - contents += '"%s" ' % asflags.strip() + contents += f'"{asflags.strip()}" ' + + if self._is_apple_embedded_platform: + contents += f'"{self._b2_os}" ' contents += " ;" self.output.warn(contents) - filename = "%s/user-config.jam" % folder - tools.save(filename, contents) + filename = f"{folder}/user-config.jam" + save(self, filename, contents) @property def _toolset_version(self): - if self._is_msvc: - compiler_version = str(self.settings.compiler.version) - if Version(compiler_version) >= "16": - return "14.2" - elif Version(compiler_version) >= "15": - return "14.1" - else: - return "%s.0" % compiler_version + if self.settings.get_safe("compiler") == "Visual Studio": + toolset = tools.msvs_toolset(self) + match = re.match(r"v(\d+)(\d)$", toolset) + if match: + return f"{match.group(1)}.{match.group(2)}" + elif self.settings.get_safe("compiler") == "msvc": + toolsets = {'170': '11.0', + '180': '12.0', + '190': '14.0', + '191': '14.1', + '192': '14.2', + "193": '14.3'} + return toolsets[self.settings.get_safe("compiler.version")] return "" @property def _toolset(self): if self._is_msvc: - return "msvc" - elif self.settings.os == "Windows" and self.settings.compiler == "clang": + return "clang-win" if self.settings.compiler.get_safe("toolset") == "ClangCL" else "msvc" + if self.settings.os == "Windows" and self.settings.compiler == "clang": return "clang-win" - elif self.settings.os == "Emscripten" and self.settings.compiler == "clang": + if self.settings.os == "Emscripten" and self.settings.compiler == "clang": return "emscripten" - elif self.settings.compiler == "gcc" and tools.is_apple_os(self.settings.os): + if self.settings.compiler == "gcc" and is_apple_os(self): return "darwin" - elif self.settings.compiler == "apple-clang": + if self.settings.compiler == "apple-clang": return "clang-darwin" - elif self.settings.os == "Android" and self.settings.compiler == "clang": + if self.settings.os == "Android" and self.settings.compiler == "clang": return "clang-linux" - elif self.settings.compiler in ["clang", "gcc"]: + if self.settings.compiler in ["clang", "gcc"]: return str(self.settings.compiler) - elif self.settings.compiler == "sun-cc": + if self.settings.compiler == "sun-cc": return "sunpro" - elif self.settings.compiler == "intel": + if self.settings.compiler == "intel": return { "Macos": "intel-darwin", "Windows": "intel-win", "Linux": "intel-linux", }[str(self.settings.os)] - else: - return str(self.settings.compiler) + + return str(self.settings.compiler) @property def _toolset_tag(self): + # compiler | compiler.version | os | toolset_tag | remark + # ---------------+------------------+-------------+----------------+----------------------------- + # apple-clang | 12 | Macos | darwin12 | + # clang | 12 | Macos | clang-darwin12 | + # gcc | 11 | Linux | gcc8 | + # gcc | 8 | Windows | mgw8 | + # Visual Studio | 17 | Windows | vc142 | depends on compiler.toolset + compiler = { + "apple-clang": "", + "Visual Studio": "vc", + "msvc": "vc", + }.get(str(self.settings.compiler), str(self.settings.compiler)) + if (self.settings.compiler, self.settings.os) == ("gcc", "Windows"): + compiler = "mgw" + os_ = "" + if self.settings.os == "Macos": + os_ = "darwin" if self._is_msvc: - return "vc{}".format(self._toolset_version.replace(".","")) + toolset_version = self._toolset_version.replace(".", "") else: - # FIXME: missing toolset tags for compilers (see self._toolset) - compiler = str(self.settings.compiler) - if self.settings.compiler == "apple-clang": - compiler = "darwin" - return "{}{}".format(compiler, self.settings.compiler.version) + toolset_version = str(Version(self.settings.compiler.version).major) + + toolset_parts = [compiler, os_] + toolset_tag = "-".join(part for part in toolset_parts if part) + toolset_version + return toolset_tag #################################################################### @@ -1213,11 +1374,11 @@ def package(self): # copy to source with the good lib name self.copy("LICENSE_1_0.txt", dst="licenses", src=os.path.join(self.source_folder, self._source_subfolder)) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) if self.options.header_only: - self.copy(pattern="*", dst="include/boost", src="%s/boost" % self._boost_dir) + self.copy(pattern="*", dst="include/boost", src=f"{self._boost_dir}/boost") - if self.settings.os == "Emscripten": + if self.settings.os == "Emscripten" and not self.options.header_only: self._create_emscripten_libs() if self._is_msvc and self._shared: @@ -1228,17 +1389,18 @@ def package(self): static_libs = set(l[3:] for l in static_libs) common_libs = static_libs.intersection(shared_libs) for common_lib in common_libs: - self.output.info("Unlinking static duplicate library: {}".format(os.path.join(self.package_folder, "lib", "lib{}.lib".format(common_lib)))) - os.unlink(os.path.join(self.package_folder, "lib", "lib{}.lib".format(common_lib))) + common_lib_fullname = f"lib{common_lib}.lib" + self.output.info(f'Unlinking static duplicate library: {os.path.join(self.package_folder, "lib", common_lib_fullname)}') + os.unlink(os.path.join(self.package_folder, "lib", common_lib_fullname)) dll_pdbs = glob.glob(os.path.join(self.package_folder, "lib", "*.dll")) + \ glob.glob(os.path.join(self.package_folder, "lib", "*.pdb")) if dll_pdbs: - tools.mkdir(os.path.join(self.package_folder, "bin")) + mkdir(self, os.path.join(self.package_folder, "bin")) for bin_file in dll_pdbs: - tools.rename(bin_file, os.path.join(self.package_folder, "bin", os.path.basename(bin_file))) + rename(self, bin_file, os.path.join(self.package_folder, "bin", os.path.basename(bin_file))) - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) def _create_emscripten_libs(self): # Boost Build doesn't create the libraries, but it gets close, @@ -1246,13 +1408,13 @@ def _create_emscripten_libs(self): staged_libs = os.path.join( self.package_folder, "lib" ) + if not os.path.exists(staged_libs): + self.output.warn(f"Lib folder doesn't exist, can't collect libraries: {staged_libs}") + return for bc_file in os.listdir(staged_libs): if bc_file.startswith("lib") and bc_file.endswith(".bc"): a_file = bc_file[:-3] + ".a" - cmd = "emar q {dst} {src}".format( - dst=os.path.join(staged_libs, a_file), - src=os.path.join(staged_libs, bc_file), - ) + cmd = f"emar q {os.path.join(staged_libs, a_file)} {os.path.join(staged_libs, bc_file)}" self.output.info(cmd) self.run(cmd) @@ -1267,6 +1429,7 @@ def _option_to_conan_requirement(name): def package_info(self): self.env_info.BOOST_ROOT = self.package_folder + self.cpp_info.set_property("cmake_file_name", "Boost") self.cpp_info.filenames["cmake_find_package"] = "Boost" self.cpp_info.filenames["cmake_find_package_multi"] = "Boost" self.cpp_info.names["cmake_find_package"] = "Boost" @@ -1276,6 +1439,7 @@ def package_info(self): # - Use '_libboost' component to attach extra system_libs, ... self.cpp_info.components["headers"].libs = [] + self.cpp_info.components["headers"].set_property("cmake_target_name", "Boost::headers") self.cpp_info.components["headers"].names["cmake_find_package"] = "headers" self.cpp_info.components["headers"].names["cmake_find_package_multi"] = "headers" self.cpp_info.components["headers"].names["pkg_config"] = "boost" @@ -1289,19 +1453,36 @@ def package_info(self): if self.options.filesystem_no_deprecated: self.cpp_info.components["headers"].defines.append("BOOST_FILESYSTEM_NO_DEPRECATED") + if self.options.filesystem_use_std_fs: + self.cpp_info.components["headers"].defines.append("BOOST_DLL_USE_STD_FS") + + if self.options.filesystem_version: + self.cpp_info.components["headers"].defines.append(f"BOOST_FILESYSTEM_VERSION={self.options.filesystem_version}") + if self.options.segmented_stacks: self.cpp_info.components["headers"].defines.extend(["BOOST_USE_SEGMENTED_STACKS", "BOOST_USE_UCONTEXT"]) + if self.options.system_use_utf8: + self.cpp_info.components["headers"].defines.append("BOOST_SYSTEM_USE_UTF8") + + if self.options.buildid: + # If you built Boost using the --buildid option then set this macro to the same value + # as you passed to bjam. + # For example if you built using bjam address-model=64 --buildid=amd64 then compile your code with + # -DBOOST_LIB_BUILDID=amd64 to ensure the correct libraries are selected at link time. + self.cpp_info.components["headers"].defines.append(f"BOOST_LIB_BUILDID={self.options.buildid}") + if not self.options.header_only: if self.options.error_code_header_only: self.cpp_info.components["headers"].defines.append("BOOST_ERROR_CODE_HEADER_ONLY") if self.options.layout == "versioned": - version = tools.Version(self.version) - self.cpp_info.components["headers"].includedirs.append(os.path.join("include", "boost-{}_{}".format(version.major, version.minor))) + version = Version(self.version) + self.cpp_info.components["headers"].includedirs.append(os.path.join("include", f"boost-{version.major}_{version.minor}")) # Boost::boost is an alias of Boost::headers self.cpp_info.components["_boost_cmake"].requires = ["headers"] + self.cpp_info.components["_boost_cmake"].set_property("cmake_target_name", "Boost::boost") self.cpp_info.components["_boost_cmake"].names["cmake_find_package"] = "boost" self.cpp_info.components["_boost_cmake"].names["cmake_find_package_multi"] = "boost" @@ -1309,24 +1490,48 @@ def package_info(self): self.cpp_info.components["_libboost"].requires = ["headers"] self.cpp_info.components["diagnostic_definitions"].libs = [] + self.cpp_info.components["diagnostic_definitions"].set_property("cmake_target_name", "Boost::diagnostic_definitions") self.cpp_info.components["diagnostic_definitions"].names["cmake_find_package"] = "diagnostic_definitions" self.cpp_info.components["diagnostic_definitions"].names["cmake_find_package_multi"] = "diagnostic_definitions" self.cpp_info.components["diagnostic_definitions"].names["pkg_config"] = "boost_diagnostic_definitions" # FIXME: disable on pkg_config - self.cpp_info.components["_libboost"].requires.append("diagnostic_definitions") + # I would assume headers also need the define BOOST_LIB_DIAGNOSTIC, as a header can trigger an autolink, + # and this definition triggers a print out of the library selected. See notes below on autolink and headers. + self.cpp_info.components["headers"].requires.append("diagnostic_definitions") if self.options.diagnostic_definitions: self.cpp_info.components["diagnostic_definitions"].defines = ["BOOST_LIB_DIAGNOSTIC"] self.cpp_info.components["disable_autolinking"].libs = [] + self.cpp_info.components["disable_autolinking"].set_property("cmake_target_name", "Boost::disable_autolinking") self.cpp_info.components["disable_autolinking"].names["cmake_find_package"] = "disable_autolinking" self.cpp_info.components["disable_autolinking"].names["cmake_find_package_multi"] = "disable_autolinking" self.cpp_info.components["disable_autolinking"].names["pkg_config"] = "boost_disable_autolinking" # FIXME: disable on pkg_config - self.cpp_info.components["_libboost"].requires.append("disable_autolinking") + + # Even headers needs to know the flags for disabling autolinking ... + # magic_autolink is an option in the recipe, so if a consumer wants this version of boost, + # then they should not get autolinking. + # Note that autolinking can sneak in just by some file #including a header with (eg) boost/atomic.hpp, + # even if it doesn't use any part that requires linking with libboost_atomic in order to compile. + # So a boost-header-only library that links to Boost::headers needs to see BOOST_ALL_NO_LIB + # in order to avoid autolinking to libboost_atomic + + # This define is already imported into all of the _libboost libraries from this recipe anyway, + # so it would be better to be consistent and ensure ANYTHING using boost (headers or libs) has consistent #defines. + + # Same applies for for BOOST_AUTO_LINK_{layout}: + # consumer libs that use headers also need to know what is the layout/filename of the libraries. + # + # eg, if using the "tagged" naming scheme, and a header triggers an autolink, + # then that header's autolink request had better be configured to request the "tagged" library name. + # Otherwise, the linker will be looking for a (eg) "versioned" library name, and there will be a link error. + + # Note that "_libboost" requires "headers" so these defines will be applied to all the libraries too. + self.cpp_info.components["headers"].requires.append("disable_autolinking") if self._is_msvc or self._is_clang_cl: if self.options.magic_autolink: if self.options.layout == "system": - self.cpp_info.components["_libboost"].defines.append("BOOST_AUTO_LINK_SYSTEM") + self.cpp_info.components["headers"].defines.append("BOOST_AUTO_LINK_SYSTEM") elif self.options.layout == "tagged": - self.cpp_info.components["_libboost"].defines.append("BOOST_AUTO_LINK_TAGGED") + self.cpp_info.components["headers"].defines.append("BOOST_AUTO_LINK_TAGGED") self.output.info("Enabled magic autolinking (smart and magic decisions)") else: # DISABLES AUTO LINKING! NO SMART AND MAGIC DECISIONS THANKS! @@ -1334,10 +1539,15 @@ def package_info(self): self.output.info("Disabled magic autolinking (smart and magic decisions)") self.cpp_info.components["dynamic_linking"].libs = [] + self.cpp_info.components["dynamic_linking"].set_property("cmake_target_name", "Boost::dynamic_linking") self.cpp_info.components["dynamic_linking"].names["cmake_find_package"] = "dynamic_linking" self.cpp_info.components["dynamic_linking"].names["cmake_find_package_multi"] = "dynamic_linking" self.cpp_info.components["dynamic_linking"].names["pkg_config"] = "boost_dynamic_linking" # FIXME: disable on pkg_config - self.cpp_info.components["_libboost"].requires.append("dynamic_linking") + # A library that only links to Boost::headers can be linked into another library that links a Boost::library, + # so for this reasons, the header-only library should know the BOOST_ALL_DYN_LINK definition as it will likely + # change some important part of the boost code and cause linking errors downstream. + # This is in the same theme as the notes above, re autolinking. + self.cpp_info.components["headers"].requires.append("dynamic_linking") if self._shared: # A Boost::dynamic_linking cmake target does only make sense for a shared boost package self.cpp_info.components["dynamic_linking"].defines = ["BOOST_ALL_DYN_LINK"] @@ -1353,7 +1563,7 @@ def package_info(self): "tagged": "{threading}{abi}{arch}", } libsuffix_data = { - "toolset": "-{}".format(self._toolset_tag), + "toolset": f"-{self._toolset_tag}", "threading": "-mt" if self.options.multithreading else "", "abi": "", "ach": "", @@ -1361,44 +1571,44 @@ def package_info(self): } if self._is_msvc: # FIXME: mingw? # FIXME: add 'y' when using cpython cci package and when python is built in debug mode - static_runtime_key = "s" if "MT" in str(self.settings.compiler.runtime) else "" - debug_runtime_key = "g" if "d" in str(self.settings.compiler.runtime) else "" + static_runtime_key = "s" if "MT" in msvc_runtime_flag(self) else "" + debug_runtime_key = "g" if "d" in msvc_runtime_flag(self) else "" debug_key = "d" if self.settings.build_type == "Debug" else "" abi = static_runtime_key + debug_runtime_key + debug_key if abi: - libsuffix_data["abi"] = "-{}".format(abi) + libsuffix_data["abi"] = f"-{abi}" else: debug_tag = "d" if self.settings.build_type == "Debug" else "" abi = debug_tag if abi: - libsuffix_data["abi"] = "-{}".format(abi) + libsuffix_data["abi"] = f"-{abi}" - libsuffix_data["arch"] = "-{}{}".format(self._b2_architecture[0], self._b2_address_model) - version = tools.Version(self.version) + libsuffix_data["arch"] = f"-{self._b2_architecture[0]}{self._b2_address_model}" + version = Version(self.version) if not version.patch or version.patch == "0": - libsuffix_data["version"] = "-{}_{}".format(version.major, version.minor) + libsuffix_data["version"] = f"-{version.major}_{version.minor}" else: - libsuffix_data["version"] = "-{}_{}_{}".format(version.major, version.minor, version.patch) + libsuffix_data["version"] = f"-{version.major}_{version.minor}_{version.patch}" libsuffix = libsuffix_lut[str(self.options.layout)].format(**libsuffix_data) if libsuffix: - self.output.info("Library layout suffix: {}".format(repr(libsuffix))) + self.output.info(f"Library layout suffix: {repr(libsuffix)}") libformatdata = {} if not self.options.without_python: - pyversion = tools.Version(self._python_version) + pyversion = Version(self._python_version) libformatdata["py_major"] = pyversion.major libformatdata["py_minor"] = pyversion.minor def add_libprefix(n): """ On MSVC, static libraries are built with a 'lib' prefix. Some libraries do not support shared, so are always built as a static library. """ libprefix = "" - if self.settings.compiler == "Visual Studio" and (not self._shared or n in self._dependencies["static_only"]): + if self._is_msvc and (not self._shared or n in self._dependencies["static_only"]): libprefix = "lib" return libprefix + n - all_detected_libraries = set(tools.collect_libs(self)) + all_detected_libraries = set(l[:-4] if l.endswith(".dll") else l for l in tools.collect_libs(self)) all_expected_libraries = set() - incomplete_components = list() + incomplete_components = [] def filter_transform_module_libraries(names): libs = [] @@ -1407,13 +1617,25 @@ def filter_transform_module_libraries(names): continue if name in ("boost_stacktrace_addr2line", "boost_stacktrace_backtrace", "boost_stacktrace_basic",) and self.settings.os == "Windows": continue + if name == "boost_stacktrace_addr2line" and not self._stacktrace_addr2line_available: + continue + if name == "boost_stacktrace_backtrace" and self.options.get_safe("with_stacktrace_backtrace") == False: + continue if not self.options.get_safe("numa") and "_numa" in name: continue - libs.append(add_libprefix(name.format(**libformatdata)) + libsuffix) + new_name = add_libprefix(name.format(**libformatdata)) + libsuffix + if self.options.namespace != 'boost': + new_name = new_name.replace("boost_", str(self.options.namespace) + "_") + if name.startswith("boost_python") or name.startswith("boost_numpy"): + if self.options.python_buildid: + new_name += f"-{self.options.python_buildid}" + if self.options.buildid: + new_name += f"-{self.options.buildid}" + libs.append(new_name) return libs for module in self._dependencies["dependencies"].keys(): - missing_depmodules = list(depmodule for depmodule in self._all_dependent_modules(module) if self.options.get_safe("without_{}".format(depmodule), False)) + missing_depmodules = list(depmodule for depmodule in self._all_dependent_modules(module) if self.options.get_safe(f"without_{depmodule}", False)) if missing_depmodules: continue @@ -1427,12 +1649,20 @@ def filter_transform_module_libraries(names): if set(module_libraries).difference(all_detected_libraries): incomplete_components.append(module) + # Starting v1.69.0 Boost.System is header-only. A stub library is + # still built for compatibility, but linking to it is no longer + # necessary. + # https://www.boost.org/doc/libs/1_75_0/libs/system/doc/html/system.html#changes_in_boost_1_69 + if module == "system": + module_libraries = [] + self.cpp_info.components[module].libs = module_libraries self.cpp_info.components[module].requires = self._dependencies["dependencies"][module] + ["_libboost"] + self.cpp_info.components[module].set_property("cmake_target_name", "Boost::" + module) self.cpp_info.components[module].names["cmake_find_package"] = module self.cpp_info.components[module].names["cmake_find_package_multi"] = module - self.cpp_info.components[module].names["pkg_config"] = "boost_{}".format(module) + self.cpp_info.components[module].names["pkg_config"] = f"boost_{module}" for requirement in self._dependencies.get("requirements", {}).get(module, []): if self.options.get_safe(requirement, None) == False: @@ -1441,31 +1671,34 @@ def filter_transform_module_libraries(names): if conan_requirement not in self.requires: continue if module == "locale" and requirement in ("icu", "iconv"): - if requirement != self.options.i18n_backend: + if requirement == "icu" and not self._with_icu: + continue + if requirement == "iconv" and not self._with_iconv: continue - self.cpp_info.components[module].requires.append("{0}::{0}".format(conan_requirement)) + self.cpp_info.components[module].requires.append(f"{conan_requirement}::{conan_requirement}") for incomplete_component in incomplete_components: - self.output.warn("Boost component '{0}' is missing libraries. Try building boost with '-o boost:without_{0}'. (Option is not guaranteed to exist)".format(incomplete_component)) + self.output.warn(f"Boost component '{incomplete_component}' is missing libraries. Try building boost with '-o boost:without_{incomplete_component}'. (Option is not guaranteed to exist)") non_used = all_detected_libraries.difference(all_expected_libraries) if non_used: - raise ConanException("These libraries were built, but were not used in any boost module: {}".format(non_used)) + raise ConanException(f"These libraries were built, but were not used in any boost module: {non_used}") non_built = all_expected_libraries.difference(all_detected_libraries) if non_built: - raise ConanException("These libraries were expected to be built, but were not built: {}".format(non_built)) + raise ConanException(f"These libraries were expected to be built, but were not built: {non_built}") if not self.options.without_stacktrace: if self.settings.os in ("Linux", "FreeBSD"): self.cpp_info.components["stacktrace_basic"].system_libs.append("dl") - self.cpp_info.components["stacktrace_addr2line"].system_libs.append("dl") + if self._stacktrace_addr2line_available: + self.cpp_info.components["stacktrace_addr2line"].system_libs.append("dl") if self._with_stacktrace_backtrace: self.cpp_info.components["stacktrace_backtrace"].system_libs.append("dl") if self._stacktrace_addr2line_available: self.cpp_info.components["stacktrace_addr2line"].defines.extend([ - "BOOST_STACKTRACE_ADDR2LINE_LOCATION=\"{}\"".format(self.options.addr2line_location), + f"BOOST_STACKTRACE_ADDR2LINE_LOCATION=\"{self.options.addr2line_location}\"", "BOOST_STACKTRACE_USE_ADDR2LINE", ]) @@ -1476,20 +1709,20 @@ def filter_transform_module_libraries(names): self.cpp_info.components["stacktrace_noop"].defines.append("BOOST_STACKTRACE_USE_NOOP") if self.settings.os == "Windows": - self.cpp_info.components["stacktrace_windb"].defines.append("BOOST_STACKTRACE_USE_WINDBG") - self.cpp_info.components["stacktrace_windb"].system_libs.extend(["ole32", "dbgeng"]) - self.cpp_info.components["stacktrace_windb_cached"].defines.append("BOOST_STACKTRACE_USE_WINDBG_CACHED") - self.cpp_info.components["stacktrace_windb_cached"].system_libs.extend(["ole32", "dbgeng"]) - elif tools.is_apple_os(self.settings.os): + self.cpp_info.components["stacktrace_windbg"].defines.append("BOOST_STACKTRACE_USE_WINDBG") + self.cpp_info.components["stacktrace_windbg"].system_libs.extend(["ole32", "dbgeng"]) + self.cpp_info.components["stacktrace_windbg_cached"].defines.append("BOOST_STACKTRACE_USE_WINDBG_CACHED") + self.cpp_info.components["stacktrace_windbg_cached"].system_libs.extend(["ole32", "dbgeng"]) + elif is_apple_os(self) or self.settings.os == "FreeBSD": self.cpp_info.components["stacktrace"].defines.append("BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED") if not self.options.without_python: - pyversion = tools.Version(self._python_version) - self.cpp_info.components["python{}{}".format(pyversion.major, pyversion.minor)].requires = ["python"] + pyversion = Version(self._python_version) + self.cpp_info.components[f"python{pyversion.major}{pyversion.minor}"].requires = ["python"] if not self._shared: self.cpp_info.components["python"].defines.append("BOOST_PYTHON_STATIC_LIB") - self.cpp_info.components["numpy{}{}".format(pyversion.major, pyversion.minor)].requires = ["numpy"] + self.cpp_info.components[f"numpy{pyversion.major}{pyversion.minor}"].requires = ["numpy"] if self._is_msvc or self._is_clang_cl: # https://github.com/conan-community/conan-boost/issues/127#issuecomment-404750974 @@ -1515,7 +1748,9 @@ def filter_transform_module_libraries(names): if self.options.multithreading: # https://github.com/conan-io/conan-center-index/issues/3867 # runtime crashes occur when using the default platform-specific reference counter/atomic - self.cpp_info.components["headers"].defines.extend(["BOOST_AC_USE_PTHREADS", "BOOST_SP_USE_PTHREADS"]) + # https://github.com/boostorg/filesystem/issues/147 + # iOS should use spinlocks to avoid filesystem crashes + self.cpp_info.components["headers"].defines.append("BOOST_SP_USE_SPINLOCK") else: self.cpp_info.components["headers"].defines.extend(["BOOST_AC_DISABLE_THREADS", "BOOST_SP_DISABLE_THREADS"]) self.user_info.stacktrace_addr2line_available = self._stacktrace_addr2line_available diff --git a/recipes/boost/all/dependencies/dependencies-1.69.0.yml b/recipes/boost/all/dependencies/dependencies-1.69.0.yml deleted file mode 100644 index d87addbc7942a..0000000000000 --- a/recipes/boost/all/dependencies/dependencies-1.69.0.yml +++ /dev/null @@ -1,271 +0,0 @@ -configure_options: -- atomic -- chrono -- container -- context -- contract -- coroutine -- date_time -- exception -- fiber -- filesystem -- graph -- graph_parallel -- iostreams -- locale -- log -- math -- mpi -- program_options -- python -- random -- regex -- serialization -- stacktrace -- system -- test -- thread -- timer -- type_erasure -- wave -dependencies: - atomic: [] - chrono: - - system - container: [] - context: - - thread - contract: - - exception - - thread - coroutine: - - context - - exception - - system - - thread - date_time: - - serialization - exception: [] - fiber: - - context - - filesystem - fiber_numa: - - fiber - filesystem: - - system - graph: - - math - - random - - regex - - serialization - - test - graph_parallel: - - filesystem - - graph - - mpi - - random - - serialization - iostreams: - - random - - regex - locale: - - thread - log: - - atomic - - container - - date_time - - exception - - filesystem - - locale - - random - - regex - - system - - thread - log_setup: - - log - math: - - atomic - math_c99: - - math - math_c99f: - - math - math_c99l: - - math - math_tr1: - - math - math_tr1f: - - math - math_tr1l: - - math - mpi: - - graph - - serialization - mpi_python: - - mpi - - python - numpy: - - python - prg_exec_monitor: - - test - program_options: [] - python: [] - random: - - math - - system - regex: [] - serialization: [] - stacktrace: [] - stacktrace_addr2line: - - stacktrace - stacktrace_backtrace: - - stacktrace - stacktrace_basic: - - stacktrace - stacktrace_noop: - - stacktrace - stacktrace_windbg: - - stacktrace - stacktrace_windbg_cached: - - stacktrace - system: [] - test: - - exception - - timer - test_exec_monitor: - - test - thread: - - atomic - - chrono - - container - - date_time - - exception - - system - timer: - - chrono - - system - type_erasure: - - thread - unit_test_framework: - - prg_exec_monitor - - test - - test_exec_monitor - wave: - - filesystem - - serialization - wserialization: - - serialization -libs: - atomic: - - boost_atomic - chrono: - - boost_chrono - container: - - boost_container - context: - - boost_context - contract: - - boost_contract - coroutine: - - boost_coroutine - date_time: - - boost_date_time - exception: - - boost_exception - fiber: - - boost_fiber - fiber_numa: - - boost_fiber_numa - filesystem: - - boost_filesystem - graph: - - boost_graph - graph_parallel: - - boost_graph_parallel - iostreams: - - boost_iostreams - locale: - - boost_locale - log: - - boost_log - log_setup: - - boost_log_setup - math: [] - math_c99: - - boost_math_c99 - math_c99f: - - boost_math_c99f - math_c99l: - - boost_math_c99l - math_tr1: - - boost_math_tr1 - math_tr1f: - - boost_math_tr1f - math_tr1l: - - boost_math_tr1l - mpi: - - boost_mpi - mpi_python: - - boost_mpi_python - numpy: - - boost_numpy{py_major}{py_minor} - prg_exec_monitor: - - boost_prg_exec_monitor - program_options: - - boost_program_options - python: - - boost_python{py_major}{py_minor} - random: - - boost_random - regex: - - boost_regex - serialization: - - boost_serialization - stacktrace: [] - stacktrace_addr2line: - - boost_stacktrace_addr2line - stacktrace_backtrace: - - boost_stacktrace_backtrace - stacktrace_basic: - - boost_stacktrace_basic - stacktrace_noop: - - boost_stacktrace_noop - stacktrace_windbg: - - boost_stacktrace_windbg - stacktrace_windbg_cached: - - boost_stacktrace_windbg_cached - system: - - boost_system - test: [] - test_exec_monitor: - - boost_test_exec_monitor - thread: - - boost_thread - timer: - - boost_timer - type_erasure: - - boost_type_erasure - unit_test_framework: - - boost_unit_test_framework - wave: - - boost_wave - wserialization: - - boost_wserialization -requirements: - iostreams: - - bzip2 - - lzma - - zlib - - zstd - locale: - - iconv - - icu - python: - - python - regex: - - icu - stacktrace: - - backtrace -static_only: -- boost_exception -- boost_test_exec_monitor -version: 1.69.0 diff --git a/recipes/boost/all/dependencies/dependencies-1.77.0.yml b/recipes/boost/all/dependencies/dependencies-1.77.0.yml new file mode 100644 index 0000000000000..921d8f4f45b12 --- /dev/null +++ b/recipes/boost/all/dependencies/dependencies-1.77.0.yml @@ -0,0 +1,277 @@ +configure_options: +- atomic +- chrono +- container +- context +- contract +- coroutine +- date_time +- exception +- fiber +- filesystem +- graph +- graph_parallel +- iostreams +- json +- locale +- log +- math +- mpi +- nowide +- program_options +- python +- random +- regex +- serialization +- stacktrace +- system +- test +- thread +- timer +- type_erasure +- wave +dependencies: + atomic: [] + chrono: + - system + container: [] + context: [] + contract: + - exception + - thread + coroutine: + - context + - exception + - system + - thread + date_time: [] + exception: [] + fiber: + - context + - filesystem + fiber_numa: + - fiber + filesystem: + - atomic + - system + graph: + - math + - random + - regex + - serialization + graph_parallel: + - filesystem + - graph + - mpi + - random + - serialization + iostreams: + - random + - regex + json: + - container + - exception + - system + locale: + - thread + log: + - atomic + - container + - date_time + - exception + - filesystem + - random + - regex + - system + - thread + log_setup: + - log + math: [] + math_c99: + - math + math_c99f: + - math + math_c99l: + - math + math_tr1: + - math + math_tr1f: + - math + math_tr1l: + - math + mpi: + - graph + - serialization + mpi_python: + - mpi + - python + nowide: + - filesystem + numpy: + - python + prg_exec_monitor: + - test + program_options: [] + python: [] + random: + - system + regex: [] + serialization: [] + stacktrace: [] + stacktrace_addr2line: + - stacktrace + stacktrace_backtrace: + - stacktrace + stacktrace_basic: + - stacktrace + stacktrace_noop: + - stacktrace + stacktrace_windbg: + - stacktrace + stacktrace_windbg_cached: + - stacktrace + system: [] + test: + - exception + test_exec_monitor: + - test + thread: + - atomic + - chrono + - container + - date_time + - exception + - system + timer: + - chrono + - system + type_erasure: + - thread + unit_test_framework: + - prg_exec_monitor + - test + - test_exec_monitor + wave: + - filesystem + - serialization + wserialization: + - serialization +libs: + atomic: + - boost_atomic + chrono: + - boost_chrono + container: + - boost_container + context: + - boost_context + contract: + - boost_contract + coroutine: + - boost_coroutine + date_time: + - boost_date_time + exception: + - boost_exception + fiber: + - boost_fiber + fiber_numa: + - boost_fiber_numa + filesystem: + - boost_filesystem + graph: + - boost_graph + graph_parallel: + - boost_graph_parallel + iostreams: + - boost_iostreams + json: + - boost_json + locale: + - boost_locale + log: + - boost_log + log_setup: + - boost_log_setup + math: [] + math_c99: + - boost_math_c99 + math_c99f: + - boost_math_c99f + math_c99l: + - boost_math_c99l + math_tr1: + - boost_math_tr1 + math_tr1f: + - boost_math_tr1f + math_tr1l: + - boost_math_tr1l + mpi: + - boost_mpi + mpi_python: + - boost_mpi_python + nowide: + - boost_nowide + numpy: + - boost_numpy{py_major}{py_minor} + prg_exec_monitor: + - boost_prg_exec_monitor + program_options: + - boost_program_options + python: + - boost_python{py_major}{py_minor} + random: + - boost_random + regex: + - boost_regex + serialization: + - boost_serialization + stacktrace: [] + stacktrace_addr2line: + - boost_stacktrace_addr2line + stacktrace_backtrace: + - boost_stacktrace_backtrace + stacktrace_basic: + - boost_stacktrace_basic + stacktrace_noop: + - boost_stacktrace_noop + stacktrace_windbg: + - boost_stacktrace_windbg + stacktrace_windbg_cached: + - boost_stacktrace_windbg_cached + system: + - boost_system + test: [] + test_exec_monitor: + - boost_test_exec_monitor + thread: + - boost_thread + timer: + - boost_timer + type_erasure: + - boost_type_erasure + unit_test_framework: + - boost_unit_test_framework + wave: + - boost_wave + wserialization: + - boost_wserialization +requirements: + iostreams: + - bzip2 + - lzma + - zlib + - zstd + locale: + - iconv + - icu + python: + - python + regex: + - icu + stacktrace: + - backtrace +static_only: +- boost_exception +- boost_test_exec_monitor +version: 1.77.0 diff --git a/recipes/boost/all/dependencies/dependencies-1.78.0.yml b/recipes/boost/all/dependencies/dependencies-1.78.0.yml new file mode 100644 index 0000000000000..dd3207297bf16 --- /dev/null +++ b/recipes/boost/all/dependencies/dependencies-1.78.0.yml @@ -0,0 +1,276 @@ +configure_options: +- atomic +- chrono +- container +- context +- contract +- coroutine +- date_time +- exception +- fiber +- filesystem +- graph +- graph_parallel +- iostreams +- json +- locale +- log +- math +- mpi +- nowide +- program_options +- python +- random +- regex +- serialization +- stacktrace +- system +- test +- thread +- timer +- type_erasure +- wave +dependencies: + atomic: [] + chrono: + - system + container: [] + context: [] + contract: + - exception + - thread + coroutine: + - context + - exception + - system + date_time: [] + exception: [] + fiber: + - context + - filesystem + fiber_numa: + - fiber + filesystem: + - atomic + - system + graph: + - math + - random + - regex + - serialization + graph_parallel: + - filesystem + - graph + - mpi + - random + - serialization + iostreams: + - random + - regex + json: + - container + - exception + - system + locale: + - thread + log: + - atomic + - container + - date_time + - exception + - filesystem + - random + - regex + - system + - thread + log_setup: + - log + math: [] + math_c99: + - math + math_c99f: + - math + math_c99l: + - math + math_tr1: + - math + math_tr1f: + - math + math_tr1l: + - math + mpi: + - graph + - serialization + mpi_python: + - mpi + - python + nowide: + - filesystem + numpy: + - python + prg_exec_monitor: + - test + program_options: [] + python: [] + random: + - system + regex: [] + serialization: [] + stacktrace: [] + stacktrace_addr2line: + - stacktrace + stacktrace_backtrace: + - stacktrace + stacktrace_basic: + - stacktrace + stacktrace_noop: + - stacktrace + stacktrace_windbg: + - stacktrace + stacktrace_windbg_cached: + - stacktrace + system: [] + test: + - exception + test_exec_monitor: + - test + thread: + - atomic + - chrono + - container + - date_time + - exception + - system + timer: + - chrono + - system + type_erasure: + - thread + unit_test_framework: + - prg_exec_monitor + - test + - test_exec_monitor + wave: + - filesystem + - serialization + wserialization: + - serialization +libs: + atomic: + - boost_atomic + chrono: + - boost_chrono + container: + - boost_container + context: + - boost_context + contract: + - boost_contract + coroutine: + - boost_coroutine + date_time: + - boost_date_time + exception: + - boost_exception + fiber: + - boost_fiber + fiber_numa: + - boost_fiber_numa + filesystem: + - boost_filesystem + graph: + - boost_graph + graph_parallel: + - boost_graph_parallel + iostreams: + - boost_iostreams + json: + - boost_json + locale: + - boost_locale + log: + - boost_log + log_setup: + - boost_log_setup + math: [] + math_c99: + - boost_math_c99 + math_c99f: + - boost_math_c99f + math_c99l: + - boost_math_c99l + math_tr1: + - boost_math_tr1 + math_tr1f: + - boost_math_tr1f + math_tr1l: + - boost_math_tr1l + mpi: + - boost_mpi + mpi_python: + - boost_mpi_python + nowide: + - boost_nowide + numpy: + - boost_numpy{py_major}{py_minor} + prg_exec_monitor: + - boost_prg_exec_monitor + program_options: + - boost_program_options + python: + - boost_python{py_major}{py_minor} + random: + - boost_random + regex: + - boost_regex + serialization: + - boost_serialization + stacktrace: [] + stacktrace_addr2line: + - boost_stacktrace_addr2line + stacktrace_backtrace: + - boost_stacktrace_backtrace + stacktrace_basic: + - boost_stacktrace_basic + stacktrace_noop: + - boost_stacktrace_noop + stacktrace_windbg: + - boost_stacktrace_windbg + stacktrace_windbg_cached: + - boost_stacktrace_windbg_cached + system: + - boost_system + test: [] + test_exec_monitor: + - boost_test_exec_monitor + thread: + - boost_thread + timer: + - boost_timer + type_erasure: + - boost_type_erasure + unit_test_framework: + - boost_unit_test_framework + wave: + - boost_wave + wserialization: + - boost_wserialization +requirements: + iostreams: + - bzip2 + - lzma + - zlib + - zstd + locale: + - iconv + - icu + python: + - python + regex: + - icu + stacktrace: + - backtrace +static_only: +- boost_exception +- boost_test_exec_monitor +version: 1.78.0 diff --git a/recipes/boost/all/dependencies/dependencies-1.79.0.yml b/recipes/boost/all/dependencies/dependencies-1.79.0.yml new file mode 100644 index 0000000000000..ddef536e6ff01 --- /dev/null +++ b/recipes/boost/all/dependencies/dependencies-1.79.0.yml @@ -0,0 +1,276 @@ +configure_options: +- atomic +- chrono +- container +- context +- contract +- coroutine +- date_time +- exception +- fiber +- filesystem +- graph +- graph_parallel +- iostreams +- json +- locale +- log +- math +- mpi +- nowide +- program_options +- python +- random +- regex +- serialization +- stacktrace +- system +- test +- thread +- timer +- type_erasure +- wave +dependencies: + atomic: [] + chrono: + - system + container: [] + context: [] + contract: + - exception + - thread + coroutine: + - context + - exception + - system + date_time: [] + exception: [] + fiber: + - context + - filesystem + fiber_numa: + - fiber + filesystem: + - atomic + - system + graph: + - math + - random + - regex + - serialization + graph_parallel: + - filesystem + - graph + - mpi + - random + - serialization + iostreams: + - random + - regex + json: + - container + - exception + - system + locale: + - thread + log: + - atomic + - container + - date_time + - exception + - filesystem + - random + - regex + - system + - thread + log_setup: + - log + math: [] + math_c99: + - math + math_c99f: + - math + math_c99l: + - math + math_tr1: + - math + math_tr1f: + - math + math_tr1l: + - math + mpi: + - graph + - serialization + mpi_python: + - mpi + - python + nowide: + - filesystem + numpy: + - python + prg_exec_monitor: + - test + program_options: [] + python: [] + random: + - system + regex: [] + serialization: [] + stacktrace: [] + stacktrace_addr2line: + - stacktrace + stacktrace_backtrace: + - stacktrace + stacktrace_basic: + - stacktrace + stacktrace_noop: + - stacktrace + stacktrace_windbg: + - stacktrace + stacktrace_windbg_cached: + - stacktrace + system: [] + test: + - exception + test_exec_monitor: + - test + thread: + - atomic + - chrono + - container + - date_time + - exception + - system + timer: + - chrono + - system + type_erasure: + - thread + unit_test_framework: + - prg_exec_monitor + - test + - test_exec_monitor + wave: + - filesystem + - serialization + wserialization: + - serialization +libs: + atomic: + - boost_atomic + chrono: + - boost_chrono + container: + - boost_container + context: + - boost_context + contract: + - boost_contract + coroutine: + - boost_coroutine + date_time: + - boost_date_time + exception: + - boost_exception + fiber: + - boost_fiber + fiber_numa: + - boost_fiber_numa + filesystem: + - boost_filesystem + graph: + - boost_graph + graph_parallel: + - boost_graph_parallel + iostreams: + - boost_iostreams + json: + - boost_json + locale: + - boost_locale + log: + - boost_log + log_setup: + - boost_log_setup + math: [] + math_c99: + - boost_math_c99 + math_c99f: + - boost_math_c99f + math_c99l: + - boost_math_c99l + math_tr1: + - boost_math_tr1 + math_tr1f: + - boost_math_tr1f + math_tr1l: + - boost_math_tr1l + mpi: + - boost_mpi + mpi_python: + - boost_mpi_python + nowide: + - boost_nowide + numpy: + - boost_numpy{py_major}{py_minor} + prg_exec_monitor: + - boost_prg_exec_monitor + program_options: + - boost_program_options + python: + - boost_python{py_major}{py_minor} + random: + - boost_random + regex: + - boost_regex + serialization: + - boost_serialization + stacktrace: [] + stacktrace_addr2line: + - boost_stacktrace_addr2line + stacktrace_backtrace: + - boost_stacktrace_backtrace + stacktrace_basic: + - boost_stacktrace_basic + stacktrace_noop: + - boost_stacktrace_noop + stacktrace_windbg: + - boost_stacktrace_windbg + stacktrace_windbg_cached: + - boost_stacktrace_windbg_cached + system: + - boost_system + test: [] + test_exec_monitor: + - boost_test_exec_monitor + thread: + - boost_thread + timer: + - boost_timer + type_erasure: + - boost_type_erasure + unit_test_framework: + - boost_unit_test_framework + wave: + - boost_wave + wserialization: + - boost_wserialization +requirements: + iostreams: + - bzip2 + - lzma + - zlib + - zstd + locale: + - iconv + - icu + python: + - python + regex: + - icu + stacktrace: + - backtrace +static_only: +- boost_exception +- boost_test_exec_monitor +version: 1.79.0 diff --git a/recipes/boost/all/dependencies/dependencies-1.80.0.yml b/recipes/boost/all/dependencies/dependencies-1.80.0.yml new file mode 100644 index 0000000000000..4cabd8ca5c44d --- /dev/null +++ b/recipes/boost/all/dependencies/dependencies-1.80.0.yml @@ -0,0 +1,275 @@ +configure_options: +- atomic +- chrono +- container +- context +- contract +- coroutine +- date_time +- exception +- fiber +- filesystem +- graph +- graph_parallel +- iostreams +- json +- locale +- log +- math +- mpi +- nowide +- program_options +- python +- random +- regex +- serialization +- stacktrace +- system +- test +- thread +- timer +- type_erasure +- wave +dependencies: + atomic: [] + chrono: + - system + container: [] + context: [] + contract: + - exception + - thread + coroutine: + - context + - exception + - system + date_time: [] + exception: [] + fiber: + - context + - filesystem + fiber_numa: + - fiber + filesystem: + - atomic + - system + graph: + - math + - random + - regex + - serialization + graph_parallel: + - filesystem + - graph + - mpi + - random + - serialization + iostreams: + - random + - regex + json: + - container + - system + locale: + - thread + log: + - atomic + - container + - date_time + - exception + - filesystem + - random + - regex + - system + - thread + log_setup: + - log + math: [] + math_c99: + - math + math_c99f: + - math + math_c99l: + - math + math_tr1: + - math + math_tr1f: + - math + math_tr1l: + - math + mpi: + - graph + - serialization + mpi_python: + - mpi + - python + nowide: + - filesystem + numpy: + - python + prg_exec_monitor: + - test + program_options: [] + python: [] + random: + - system + regex: [] + serialization: [] + stacktrace: [] + stacktrace_addr2line: + - stacktrace + stacktrace_backtrace: + - stacktrace + stacktrace_basic: + - stacktrace + stacktrace_noop: + - stacktrace + stacktrace_windbg: + - stacktrace + stacktrace_windbg_cached: + - stacktrace + system: [] + test: + - exception + test_exec_monitor: + - test + thread: + - atomic + - chrono + - container + - date_time + - exception + - system + timer: + - chrono + - system + type_erasure: + - thread + unit_test_framework: + - prg_exec_monitor + - test + - test_exec_monitor + wave: + - filesystem + - serialization + wserialization: + - serialization +libs: + atomic: + - boost_atomic + chrono: + - boost_chrono + container: + - boost_container + context: + - boost_context + contract: + - boost_contract + coroutine: + - boost_coroutine + date_time: + - boost_date_time + exception: + - boost_exception + fiber: + - boost_fiber + fiber_numa: + - boost_fiber_numa + filesystem: + - boost_filesystem + graph: + - boost_graph + graph_parallel: + - boost_graph_parallel + iostreams: + - boost_iostreams + json: + - boost_json + locale: + - boost_locale + log: + - boost_log + log_setup: + - boost_log_setup + math: [] + math_c99: + - boost_math_c99 + math_c99f: + - boost_math_c99f + math_c99l: + - boost_math_c99l + math_tr1: + - boost_math_tr1 + math_tr1f: + - boost_math_tr1f + math_tr1l: + - boost_math_tr1l + mpi: + - boost_mpi + mpi_python: + - boost_mpi_python + nowide: + - boost_nowide + numpy: + - boost_numpy{py_major}{py_minor} + prg_exec_monitor: + - boost_prg_exec_monitor + program_options: + - boost_program_options + python: + - boost_python{py_major}{py_minor} + random: + - boost_random + regex: + - boost_regex + serialization: + - boost_serialization + stacktrace: [] + stacktrace_addr2line: + - boost_stacktrace_addr2line + stacktrace_backtrace: + - boost_stacktrace_backtrace + stacktrace_basic: + - boost_stacktrace_basic + stacktrace_noop: + - boost_stacktrace_noop + stacktrace_windbg: + - boost_stacktrace_windbg + stacktrace_windbg_cached: + - boost_stacktrace_windbg_cached + system: + - boost_system + test: [] + test_exec_monitor: + - boost_test_exec_monitor + thread: + - boost_thread + timer: + - boost_timer + type_erasure: + - boost_type_erasure + unit_test_framework: + - boost_unit_test_framework + wave: + - boost_wave + wserialization: + - boost_wserialization +requirements: + iostreams: + - bzip2 + - lzma + - zlib + - zstd + locale: + - iconv + - icu + python: + - python + regex: + - icu + stacktrace: + - backtrace +static_only: +- boost_exception +- boost_test_exec_monitor +version: 1.80.0 diff --git a/recipes/boost/all/patches/1.69.0-contract-no-system.patch b/recipes/boost/all/patches/1.69.0-contract-no-system.patch new file mode 100644 index 0000000000000..d98fe7b2f7e3e --- /dev/null +++ b/recipes/boost/all/patches/1.69.0-contract-no-system.patch @@ -0,0 +1,11 @@ +This library links to boost_system, even though that library is header-only. +--- libs/contract/build/Jamfile.v2 ++++ libs/contract/build/Jamfile.v2 +@@ -18,5 +18,5 @@ + ; + + # If lib as header-only, none of following will be used. +-lib boost_contract : contract.cpp : shared /boost//system ; +-lib boost_contract : contract.cpp : static /boost//system ; ++lib boost_contract : contract.cpp : shared ; ++lib boost_contract : contract.cpp : static ; diff --git a/recipes/boost/all/patches/1.69.0-locale-no-system.patch b/recipes/boost/all/patches/1.69.0-locale-no-system.patch new file mode 100644 index 0000000000000..a2ca64eb92300 --- /dev/null +++ b/recipes/boost/all/patches/1.69.0-locale-no-system.patch @@ -0,0 +1,12 @@ +This library links to boost_system, even though that library is header-only. +--- libs/locale/build/Jamfile.v2 ++++ libs/locale/build/Jamfile.v2 +@@ -410,7 +410,7 @@ + result += util/gregorian.cpp ; + } + +- result += ../../system/build//boost_system ; ++ + + + if "$(flags-only)" = "flags" diff --git a/recipes/boost/all/patches/1.69.0-random-no-system.patch b/recipes/boost/all/patches/1.69.0-random-no-system.patch new file mode 100644 index 0000000000000..ad03e39931654 --- /dev/null +++ b/recipes/boost/all/patches/1.69.0-random-no-system.patch @@ -0,0 +1,11 @@ +This library links to boost_system, even though that library is header-only. +--- libs/random/build/Jamfile.v2 ++++ libs/random/build/Jamfile.v2 +@@ -13,6 +13,6 @@ + : usage-requirements shared:BOOST_RANDOM_DYN_LINK + ; + +-lib boost_random : [ glob *.cpp ] /boost//system ; ++lib boost_random : [ glob *.cpp ] ; + + boost-install boost_random ; diff --git a/recipes/boost/all/patches/1.69.0-type_erasure-no-system.patch b/recipes/boost/all/patches/1.69.0-type_erasure-no-system.patch new file mode 100644 index 0000000000000..c3b7cde662175 --- /dev/null +++ b/recipes/boost/all/patches/1.69.0-type_erasure-no-system.patch @@ -0,0 +1,9 @@ +This library links to boost_system, even though that library is header-only. +--- libs/type_erasure/build/Jamfile.v2 ++++ libs/type_erasure/build/Jamfile.v2 +@@ -12,4 +12,4 @@ + : usage-requirements shared:BOOST_TYPE_ERASURE_DYN_LINK + ; + +-lib boost_type_erasure : dynamic_binding.cpp /boost//thread /boost//system ; ++lib boost_type_erasure : dynamic_binding.cpp /boost//thread ; diff --git a/recipes/boost/all/patches/1.70.0-boost_build-with-newer-b2.patch b/recipes/boost/all/patches/1.70.0-boost_build-with-newer-b2.patch new file mode 100644 index 0000000000000..11edf1b516dfb --- /dev/null +++ b/recipes/boost/all/patches/1.70.0-boost_build-with-newer-b2.patch @@ -0,0 +1,51 @@ +--- tools/build/src/build/configure.jam.orig 2019-04-09 15:36:57.000000000 -0400 ++++ tools/build/src/build/configure.jam 2022-01-28 20:51:10.924240100 -0500 +@@ -452,7 +452,7 @@ + return [ find-builds-raw $(p) : $(ps) : $(what) : + $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) : + $(10) : $(11) : $(12) : $(13) : $(14) : $(15) : +- $(16) : $(17) : $(18) : $(19) ] ; ++ $(16) : $(17) : $(18) ] ; + } + + +@@ -510,7 +510,7 @@ + rule __init__ ( message : * ) + { + self.message = $(message) ; +- for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ++ for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 + { + local name = [ CALC $(i) - 1 ] ; + self.targets.$(name) = $($(i)[1]) ; +@@ -527,7 +527,7 @@ + } + rule all-properties ( ) + { +- local i = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; ++ local i = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; + return $(self.props.$(i)) ; + } + rule check ( properties * ) +@@ -549,9 +549,7 @@ + : $(self.targets.14) $(self.what.14) + : $(self.targets.15) $(self.what.15) + : $(self.targets.16) $(self.what.16) +- : $(self.targets.17) $(self.what.17) +- : $(self.targets.18) $(self.what.18) +- : $(self.targets.19) $(self.what.19) ] ; ++ : $(self.targets.17) $(self.what.17) ] ; + if $(self.props.$(i)) + { + return [ property.evaluate-conditionals-in-context $(self.props.$(i)) : $(properties) ] ; +--- tools/build/src/util/indirect.jam.orig 2020-12-03 00:02:49.000000000 -0500 ++++ tools/build/src/util/indirect.jam 2022-01-28 20:32:41.249509200 -0500 +@@ -102,7 +102,7 @@ + { + return [ modules.call-in [ get-module $(r) ] : [ get-rule $(r) ] $(args) : + $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) : $(10) : $(11) : +- $(12) : $(13) : $(14) : $(15) : $(16) : $(17) : $(18) : $(19) ] ; ++ $(12) : $(13) : $(14) : $(15) : $(16) : $(17) : $(18) ] ; + } + + diff --git a/recipes/boost/all/patches/1.75.0-boost_build-with-newer-b2.patch b/recipes/boost/all/patches/1.75.0-boost_build-with-newer-b2.patch new file mode 100644 index 0000000000000..4c22c748fe894 --- /dev/null +++ b/recipes/boost/all/patches/1.75.0-boost_build-with-newer-b2.patch @@ -0,0 +1,51 @@ +--- tools/build/src/build/configure.jam.orig 2020-12-03 00:02:49.000000000 -0500 ++++ tools/build/src/build/configure.jam 2022-01-28 20:32:41.260634800 -0500 +@@ -454,7 +454,7 @@ + return [ find-builds-raw $(p) : $(ps) : $(what) : + $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) : + $(10) : $(11) : $(12) : $(13) : $(14) : $(15) : +- $(16) : $(17) : $(18) : $(19) ] ; ++ $(16) : $(17) : $(18) ] ; + } + + +@@ -518,7 +518,7 @@ + { + local project = [ project.current ] ; + self.message = $(message) ; +- for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ++ for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 + { + local name = [ CALC $(i) - 1 ] ; + self.targets.$(name) = $($(i)[1]) ; +@@ -537,7 +537,7 @@ + } + rule all-properties ( ) + { +- local i = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; ++ local i = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; + return $(self.props.$(i)) ; + } + rule check ( properties * ) +@@ -559,9 +559,7 @@ + : $(self.targets.14) $(self.what.14) + : $(self.targets.15) $(self.what.15) + : $(self.targets.16) $(self.what.16) +- : $(self.targets.17) $(self.what.17) +- : $(self.targets.18) $(self.what.18) +- : $(self.targets.19) $(self.what.19) ] ; ++ : $(self.targets.17) $(self.what.17) ] ; + if $(self.props.$(i)) + { + return [ property.evaluate-conditionals-in-context $(self.props.$(i)) : $(properties) ] ; +--- tools/build/src/util/indirect.jam.orig 2020-12-03 00:02:49.000000000 -0500 ++++ tools/build/src/util/indirect.jam 2022-01-28 20:32:41.249509200 -0500 +@@ -102,7 +102,7 @@ + { + return [ modules.call-in [ get-module $(r) ] : [ get-rule $(r) ] $(args) : + $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) : $(10) : $(11) : +- $(12) : $(13) : $(14) : $(15) : $(16) : $(17) : $(18) : $(19) ] ; ++ $(12) : $(13) : $(14) : $(15) : $(16) : $(17) : $(18) ] ; + } + + diff --git a/recipes/boost/all/patches/1.77.0-boost_build-with-newer-b2.patch b/recipes/boost/all/patches/1.77.0-boost_build-with-newer-b2.patch new file mode 100644 index 0000000000000..bdc7476f27137 --- /dev/null +++ b/recipes/boost/all/patches/1.77.0-boost_build-with-newer-b2.patch @@ -0,0 +1,51 @@ +--- tools/build/src/build/configure.jam.orig 2021-08-05 05:42:46.000000000 -0400 ++++ tools/build/src/build/configure.jam 2022-01-28 19:55:37.960877600 -0500 +@@ -467,7 +467,7 @@ + return [ find-builds-raw $(p) : $(ps) : $(what) : + $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) : + $(10) : $(11) : $(12) : $(13) : $(14) : $(15) : +- $(16) : $(17) : $(18) : $(19) ] ; ++ $(16) : $(17) : $(18) ] ; + } + + +@@ -531,7 +531,7 @@ + { + local project = [ project.current ] ; + self.message = $(message) ; +- for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ++ for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 + { + local name = [ CALC $(i) - 1 ] ; + self.targets.$(name) = $($(i)[1]) ; +@@ -550,7 +550,7 @@ + } + rule all-properties ( ) + { +- local i = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; ++ local i = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; + return $(self.props.$(i)) ; + } + rule check ( properties * ) +@@ -572,9 +572,7 @@ + : $(self.targets.14) $(self.what.14) + : $(self.targets.15) $(self.what.15) + : $(self.targets.16) $(self.what.16) +- : $(self.targets.17) $(self.what.17) +- : $(self.targets.18) $(self.what.18) +- : $(self.targets.19) $(self.what.19) ] ; ++ : $(self.targets.17) $(self.what.17) ] ; + if $(self.props.$(i)) + { + return [ property.evaluate-conditionals-in-context $(self.props.$(i)) : $(properties) ] ; +--- tools/build/src/util/indirect.jam.orig 2021-08-05 05:42:46.000000000 -0400 ++++ tools/build/src/util/indirect.jam 2021-12-02 01:48:03.000000000 -0500 +@@ -102,7 +102,7 @@ + { + return [ modules.call-in [ get-module $(r) ] : [ get-rule $(r) ] $(args) : + $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) : $(10) : $(11) : +- $(12) : $(13) : $(14) : $(15) : $(16) : $(17) : $(18) : $(19) ] ; ++ $(12) : $(13) : $(14) : $(15) : $(16) : $(17) : $(18) ] ; + } + + .parts_regex = "^([^@]*)@" "([^%]*)%" "([^%]+)$" ; diff --git a/recipes/boost/all/patches/1.77.0-fiber-mingw.patch b/recipes/boost/all/patches/1.77.0-fiber-mingw.patch new file mode 100644 index 0000000000000..5bf38006a4213 --- /dev/null +++ b/recipes/boost/all/patches/1.77.0-fiber-mingw.patch @@ -0,0 +1,20 @@ +--- libs/fiber/src/numa/windows/pin_thread.cpp ++++ libs/fiber/src/numa/windows/pin_thread.cpp +@@ -23,7 +23,7 @@ + + BOOST_FIBERS_DECL + void pin_thread( std::uint32_t cpuid) { +- pin_thread( cpuid, ::GetCurrentThread() ); ++ pin_thread( cpuid, reinterpret_cast< std::thread::native_handle_type >(::GetCurrentThread())); + } + + BOOST_FIBERS_DECL +@@ -37,7 +37,7 @@ + uint32_t id = cpuid % 64; + // set the bit mask of the logical CPU + affinity.Mask = static_cast< KAFFINITY >( 1) << id; +- if ( BOOST_UNLIKELY( 0 == ::SetThreadGroupAffinity( h, & affinity, nullptr) ) ) { ++ if ( BOOST_UNLIKELY( 0 == ::SetThreadGroupAffinity( reinterpret_cast< HANDLE >(h), & affinity, nullptr) ) ) { + throw std::system_error( + std::error_code( ::GetLastError(), std::system_category() ), + "::SetThreadiGroupAffinity() failed"); diff --git a/recipes/boost/all/patches/1.77.0-type_erasure-no-system.patch b/recipes/boost/all/patches/1.77.0-type_erasure-no-system.patch new file mode 100644 index 0000000000000..71aac779a339f --- /dev/null +++ b/recipes/boost/all/patches/1.77.0-type_erasure-no-system.patch @@ -0,0 +1,11 @@ +This library links to boost_system, even though that library is header-only. +--- libs/type_erasure/build/Jamfile.v2 ++++ libs/type_erasure/build/Jamfile.v2 +@@ -12,6 +12,6 @@ + : usage-requirements shared:BOOST_TYPE_ERASURE_DYN_LINK + ; + +-lib boost_type_erasure : dynamic_binding.cpp /boost//thread /boost//system ; ++lib boost_type_erasure : dynamic_binding.cpp /boost//thread ; + + boost-install boost_type_erasure ; diff --git a/recipes/boost/all/patches/1.78.0-b2-fix-install.patch b/recipes/boost/all/patches/1.78.0-b2-fix-install.patch new file mode 100644 index 0000000000000..ac0ed81a3e85c --- /dev/null +++ b/recipes/boost/all/patches/1.78.0-b2-fix-install.patch @@ -0,0 +1,62 @@ +--- tools/build/src/tools/stage.jam 2021-12-09 16:30:45.956457531 +0300 ++++ tools/build/src/tools/stage.jam 2021-12-09 16:30:45.952457519 +0300 +@@ -476,10 +476,14 @@ class install-target-class : basic-targe + } + DELETE_MODULE $(result) ; + return [ sequence.unique $(result2) ] ; + } + ++ rule skip-from-usage-requirements ( ) ++ { ++ } ++ + # Returns true iff 'type' is subtype of some element of 'types-to-include'. + # + local rule include-type ( type : types-to-include * ) + { + local found ; + +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ tools/build/test/install_build_no.py 2021-12-09 16:30:45.953457522 +0300 +@@ -0,0 +1,26 @@ ++#!/usr/bin/python ++ ++# Copyright 2021 Dmitry Arkhipov (grisumbras@gmail.com) ++# Distributed under the Boost Software License, Version 1.0. ++# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) ++ ++# Check that no in usage-requirements of dependencies does not affect ++# install rule, i.e. a skipped installed target does not affect insallation of ++# other targets. ++ ++import BoostBuild ++ ++t = BoostBuild.Tester() ++ ++t.write("a.cpp", "int main() {}\n") ++ ++t.write("jamroot.jam", """ ++make x : : maker : no ; ++exe a : a.cpp ; ++install install : x a ; ++""") ++ ++t.run_build_system() ++t.expect_addition("install/a.exe") ++ ++t.cleanup() + +--- tools/build/test/test_all.py 2021-12-09 16:30:45.956457531 +0300 ++++ tools/build/test/test_all.py 2021-12-09 16:30:45.953457522 +0300 +@@ -248,10 +248,11 @@ tests = ["abs_workdir", + "implicit_dependency", + "indirect_conditional", + "inherit_toolset", + "inherited_dependency", + "inline", ++ "install_build_no", + "libjpeg", + "liblzma", + "libpng", + "libtiff", + "libzstd", diff --git a/recipes/boost/all/patches/1.79.0-0001-json-array-erase-relocate.patch b/recipes/boost/all/patches/1.79.0-0001-json-array-erase-relocate.patch new file mode 100644 index 0000000000000..d322b64f4477d --- /dev/null +++ b/recipes/boost/all/patches/1.79.0-0001-json-array-erase-relocate.patch @@ -0,0 +1,49 @@ +diff -ur boost/json/impl/array.ipp boost/json/impl/array.ipp +--- boost/json/impl/array.ipp 2022-04-06 17:02:43.000000000 -0400 ++++ boost/json/impl/array.ipp 2022-04-13 20:55:20.464359478 -0400 +@@ -491,8 +491,11 @@ + auto const p = &(*t_)[0] + + (pos - &(*t_)[0]); + destroy(p, p + 1); +- relocate(p, p + 1, 1); + --t_->size; ++ if(t_->size > 0) ++ relocate(p, p + 1, ++ t_->size - (p - ++ &(*t_)[0])); + return p; + } + +diff -ur libs/json/test/array.cpp libs/json/test/array.cpp +--- libs/json/test/array.cpp 2022-04-06 17:02:43.000000000 -0400 ++++ libs/json/test/array.cpp 2022-04-13 20:53:32.671782680 -0400 +@@ -1270,6 +1270,21 @@ + } + + void ++ testIssue692() ++ { ++ array a; ++ object obj; ++ obj["test1"] = "hello"; ++ a.push_back(obj); ++ a.push_back(obj); ++ a.push_back(obj); ++ a.push_back(obj); ++ a.push_back(obj); ++ while(a.size()) ++ a.erase(a.begin()); ++ } ++ ++ void + run() + { + testDestroy(); +@@ -1283,6 +1298,7 @@ + testExceptions(); + testEquality(); + testHash(); ++ testIssue692(); + } + }; + diff --git a/recipes/boost/all/patches/1.79.0-geometry_no_rtti.patch b/recipes/boost/all/patches/1.79.0-geometry_no_rtti.patch new file mode 100644 index 0000000000000..15e7b06f56835 --- /dev/null +++ b/recipes/boost/all/patches/1.79.0-geometry_no_rtti.patch @@ -0,0 +1,169 @@ +From 379f0c364a5ef3e6d57021ab815ea603ab3f1178 Mon Sep 17 00:00:00 2001 +From: Adam Wulkiewicz +Date: Tue, 19 Jul 2022 22:52:09 +0200 +Subject: [PATCH] [index] Fix and improve rtree experimental features + +Fix access specifier preventing use of experimental iterators. +Allow more granular control over enabled experimental features. +--- + .../geometry/index/distance_predicates.hpp | 12 +++++++++--- + include/boost/geometry/index/predicates.hpp | 16 +++++++++++----- + include/boost/geometry/index/rtree.hpp | 18 ++++++++++++++---- + 3 files changed, 34 insertions(+), 12 deletions(-) + +diff --git a/boost/geometry/index/distance_predicates.hpp b/boost/geometry/index/distance_predicates.hpp +index 59b32af4753..00fc663cb38 100644 +--- a/boost/geometry/index/distance_predicates.hpp ++++ b/boost/geometry/index/distance_predicates.hpp +@@ -2,7 +2,7 @@ + // + // Spatial index distance predicates, calculators and checkers used in nearest neighbor query + // +-// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. ++// Copyright (c) 2011-2022 Adam Wulkiewicz, Lodz, Poland. + // + // Use, modification and distribution is subject to the Boost Software License, + // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +@@ -11,6 +11,12 @@ + #ifndef BOOST_GEOMETRY_INDEX_DISTANCE_PREDICATES_HPP + #define BOOST_GEOMETRY_INDEX_DISTANCE_PREDICATES_HPP + ++#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL ++#ifndef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES ++#define BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES ++#endif ++#endif ++ + #include + + /*! +@@ -21,7 +27,7 @@ namespace boost { namespace geometry { namespace index { + + // relations generators + +-#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL ++#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES + + /*! + \brief Generate to_nearest() relationship. +@@ -91,7 +97,7 @@ detail::to_furthest to_furthest(T const& v) + return detail::to_furthest(v); + } + +-#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL ++#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES + + // distance predicates generators + +diff --git a/boost/geometry/index/predicates.hpp b/boost/geometry/index/predicates.hpp +index 6da0d0ec5d0..3678188dcd1 100644 +--- a/boost/geometry/index/predicates.hpp ++++ b/boost/geometry/index/predicates.hpp +@@ -2,7 +2,7 @@ + // + // Spatial query predicates + // +-// Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland. ++// Copyright (c) 2011-2022 Adam Wulkiewicz, Lodz, Poland. + // + // This file was modified by Oracle on 2019-2021. + // Modifications copyright (c) 2019-2021 Oracle and/or its affiliates. +@@ -15,6 +15,12 @@ + #ifndef BOOST_GEOMETRY_INDEX_PREDICATES_HPP + #define BOOST_GEOMETRY_INDEX_PREDICATES_HPP + ++#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL ++#ifndef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES ++#define BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES ++#endif ++#endif ++ + #include + #include + +@@ -212,7 +218,7 @@ overlaps(Geometry const& g) + >(g); + } + +-#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL ++#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES + + /*! + \brief Generate \c touches() predicate. +@@ -240,7 +246,7 @@ touches(Geometry const& g) + >(g); + } + +-#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL ++#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES + + /*! + \brief Generate \c within() predicate. +@@ -343,7 +349,7 @@ nearest(Geometry const& geometry, std::size_t k) + return detail::predicates::nearest(geometry, k); + } + +-#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL ++#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES + + /*! + \brief Generate path() predicate. +@@ -373,7 +379,7 @@ path(SegmentOrLinestring const& linestring, std::size_t k) + return detail::predicates::path(linestring, k); + } + +-#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL ++#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_PREDICATES + + namespace detail { namespace predicates { + +diff --git a/boost/geometry/index/rtree.hpp b/boost/geometry/index/rtree.hpp +index af3b6f4ee07..6bb34faf6e9 100644 +--- a/boost/geometry/index/rtree.hpp ++++ b/boost/geometry/index/rtree.hpp +@@ -3,7 +3,7 @@ + // R-tree implementation + // + // Copyright (c) 2008 Federico J. Fernandez. +-// Copyright (c) 2011-2019 Adam Wulkiewicz, Lodz, Poland. ++// Copyright (c) 2011-2022 Adam Wulkiewicz, Lodz, Poland. + // Copyright (c) 2020 Caian Benedicto, Campinas, Brazil. + // + // This file was modified by Oracle on 2019-2021. +@@ -90,7 +90,15 @@ + #include + + #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL +-// serialization ++#ifndef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_SERIALIZATION ++#define BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_SERIALIZATION ++#endif ++#ifndef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_ITERATORS ++#define BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_ITERATORS ++#endif ++#endif ++ ++#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_SERIALIZATION + #include + #endif + +@@ -312,7 +320,7 @@ class rtree + typedef typename members_holder::allocator_traits_type allocator_traits_type; + + friend class detail::rtree::utilities::view; +-#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL ++#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_SERIALIZATION + friend class detail::rtree::private_view; + friend class detail::rtree::const_private_view; + #endif +@@ -1184,7 +1192,9 @@ class rtree + detail::rtree::iterators::distance_query_iterator + >; + +-#ifndef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL ++#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL_ITERATORS ++public: ++#else + private: + #endif + /*! diff --git a/recipes/boost/all/patches/1.79.0-smart_ptr_cw_ppc_msync.patch b/recipes/boost/all/patches/1.79.0-smart_ptr_cw_ppc_msync.patch new file mode 100644 index 0000000000000..61770f8c8863f --- /dev/null +++ b/recipes/boost/all/patches/1.79.0-smart_ptr_cw_ppc_msync.patch @@ -0,0 +1,25 @@ +diff --git a/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp b/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +index 81387ce..58a69e6 100644 +--- a/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp ++++ b/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +@@ -35,8 +35,6 @@ BOOST_PRAGMA_MESSAGE("Using CodeWarrior/PowerPC sp_counted_base") + + #endif + +-BOOST_SP_OBSOLETE() +- + namespace boost + { + +@@ -64,7 +62,11 @@ inline long atomic_decrement( register long * pw ) + + asm + { ++#if defined(__PPCZen__) || defined(__PPCe500__) || defined(__PPCe500v2__) ++ msync ++#else + sync ++#endif + + loop: + diff --git a/recipes/boost/all/patches/1.80.0-0001-filesystem-win-fix-dir-it-net-share.patch b/recipes/boost/all/patches/1.80.0-0001-filesystem-win-fix-dir-it-net-share.patch new file mode 100644 index 0000000000000..0d28b86bb670c --- /dev/null +++ b/recipes/boost/all/patches/1.80.0-0001-filesystem-win-fix-dir-it-net-share.patch @@ -0,0 +1,31 @@ +commit 9c9d127bddc2b72187c57f4933c49666255d7a4f +Author: Olavo Belloc +Date: Mon Aug 8 10:54:02 2022 +0200 + + Limit the buffer size for compatibility with previous versions of Windows + + The reported error was reproduced on Windows 7 and 8.1, but not on an early + version of Windows 10 (2004). + + Closes https://github.com/boostorg/filesystem/pull/246. + Likely fixes https://github.com/boostorg/filesystem/issues/245. + +diff --git a/libs/filesystem/src/directory.cpp b/libs/filesystem/src/directory.cpp +index 6a3e1dc..9334893 100644 +--- a/libs/filesystem/src/directory.cpp ++++ b/libs/filesystem/src/directory.cpp +@@ -599,9 +599,12 @@ extra_data_format g_extra_data_format = file_directory_information_format; + * \brief Extra buffer size for GetFileInformationByHandleEx-based or NtQueryDirectoryFile-based directory iterator. + * + * Must be large enough to accommodate at least one FILE_DIRECTORY_INFORMATION or *_DIR_INFO struct and one filename. +- * NTFS, VFAT, exFAT support filenames up to 255 UTF-16/UCS-2 characters. ReFS supports filenames up to 32768 UTF-16 characters. ++ * NTFS, VFAT, exFAT and ReFS support filenames up to 255 UTF-16/UCS-2 characters. (For ReFS, there is no information ++ * on the on-disk format, and it is possible that it supports longer filenames, up to 32768 UTF-16/UCS-2 characters.) ++ * The buffer cannot be larger than 64k, because up to Windows 8.1, NtQueryDirectoryFile and GetFileInformationByHandleEx ++ * fail with ERROR_INVALID_PARAMETER when trying to retrieve the filenames from a network share. + */ +-BOOST_CONSTEXPR_OR_CONST std::size_t dir_itr_extra_size = sizeof(file_id_extd_dir_info) + 65536u; ++BOOST_CONSTEXPR_OR_CONST std::size_t dir_itr_extra_size = 65536u; + + inline system::error_code dir_itr_close(dir_itr_imp& imp) BOOST_NOEXCEPT + { diff --git a/recipes/boost/all/patches/1.80.0-0002-filesystem-fix-weakly-canonical-long-path.patch b/recipes/boost/all/patches/1.80.0-0002-filesystem-fix-weakly-canonical-long-path.patch new file mode 100644 index 0000000000000..9312059a60000 --- /dev/null +++ b/recipes/boost/all/patches/1.80.0-0002-filesystem-fix-weakly-canonical-long-path.patch @@ -0,0 +1,171 @@ +commit 476ca7b6c1d37a5d796f8525813a9a64c9e54ffc +Author: Andrey Semashev +Date: Wed Aug 10 04:57:21 2022 +0300 + + Fix weakly_canonical on Windows with long paths prefix. + + During its operation, weakly_canonical would call status() on the path + consisting only from the root name of the input path. This would fail + with ERROR_INVALID_FUNCTION if the root name starts with the "\\?\" prefix, + as the root name path is not absolute. + + To fix this, we don't check the status of the root name path (which is + not the correct check anyways as it tests the current directory on the + corresponding drive for existence, which is not what we want). Additionally, + avoid calling status() on the paths containing dot and dot-dot elements + during the weakly_canonical execution for the same reason - the "\\?\" + prefix disables most of the path processing in Windows APIs, including + dot and dot-dot elements resolution. + + Fixes https://github.com/boostorg/filesystem/issues/247. + +diff --git a/libs/filesystem/src/operations.cpp b/libs/filesystem/src/operations.cpp +index dd636e9..ca2fff3 100644 +--- a/libs/filesystem/src/operations.cpp ++++ b/libs/filesystem/src/operations.cpp +@@ -4434,7 +4434,7 @@ path weakly_canonical(path const& p, path const& base, system::error_code* ec) + path head(p); + for (; !head.empty(); --itr) + { +- file_status head_status = detail::status_impl(head, &local_ec); ++ file_status head_status(detail::status_impl(head, &local_ec)); + if (BOOST_UNLIKELY(head_status.type() == fs::status_error)) + { + if (!ec) +@@ -4450,32 +4450,83 @@ path weakly_canonical(path const& p, path const& base, system::error_code* ec) + head.remove_filename(); + } + ++ if (head.empty()) ++ return p.lexically_normal(); ++ ++ path const& dot_p = dot_path(); ++ path const& dot_dot_p = dot_dot_path(); ++ + #else + +- // On Windows, filesystem APIs such as GetFileAttributesW perform lexical path normalization internally. +- // As a result, a path like "c:\a\.." can be reported as present even if "c:\a" is not. This would break +- // canonical, as symlink_status that it calls internally would report an error that the file at the intermediate +- // path does not exist. To avoid this, scan the initial path in the forward direction. +- // Also, operate on paths with preferred separators. This can be important on Windows since GetFileAttributesW, +- // which is called in status() may return "file not found" for paths to network shares and mounted cloud +- // storages that have forward slashes as separators. ++ // On Windows, filesystem APIs such as GetFileAttributesW and CreateFileW perform lexical path normalization ++ // internally. As a result, a path like "c:\a\.." can be reported as present even if "c:\a" is not. This would ++ // break canonical, as symlink_status that it calls internally would report an error that the file at the ++ // intermediate path does not exist. To avoid this, scan the initial path in the forward direction. ++ // Also, operate on paths with preferred separators. This can be important on Windows since GetFileAttributesW ++ // or CreateFileW, which is called in status() may return "file not found" for paths to network shares and ++ // mounted cloud storages that have forward slashes as separators. ++ // Also, avoid querying status of the root name such as \\?\c: as CreateFileW returns ERROR_INVALID_FUNCTION for ++ // such path. Querying the status of a root name such as c: is also not right as this path refers to the current ++ // directory on drive C:, which is not what we want to test for existence anyway. + path::iterator itr(p.begin()); + path head; +- for (; itr != p_end; ++itr) ++ if (p.has_root_name()) + { +- path const& p_elem = *itr; +- if (p_elem.size() == 1u && detail::is_directory_separator(p_elem.native()[0])) ++ BOOST_ASSERT(itr != p_end); ++ head = *itr; ++ ++itr; ++ } ++ ++ if (p.has_root_directory()) ++ { ++ BOOST_ASSERT(itr != p_end); ++ // Convert generic separator returned by the iterator for the root directory to ++ // the preferred separator. ++ head += path::preferred_separator; ++ ++itr; ++ } ++ ++ if (!head.empty()) ++ { ++ file_status head_status(detail::status_impl(head, &local_ec)); ++ if (BOOST_UNLIKELY(head_status.type() == fs::status_error)) + { +- // Convert generic separator returned by the iterator for the root directory to +- // the preferred separator. +- head += path::preferred_separator; ++ if (!ec) ++ BOOST_FILESYSTEM_THROW(filesystem_error("boost::filesystem::weakly_canonical", head, local_ec)); ++ ++ *ec = local_ec; ++ return path(); + } +- else ++ ++ if (head_status.type() == fs::file_not_found) ++ { ++ // If the root path does not exist then no path element exists ++ return p.lexically_normal(); ++ } ++ } ++ ++ path const& dot_p = dot_path(); ++ path const& dot_dot_p = dot_dot_path(); ++ for (; itr != p_end; ++itr) ++ { ++ path const& p_elem = *itr; ++ ++ // Avoid querying status of paths containing dot and dot-dot elements, as this will break ++ // if the root name starts with "\\?\". ++ if (p_elem == dot_p) ++ continue; ++ ++ if (p_elem == dot_dot_p) + { +- head /= p_elem; ++ if (head.has_relative_path()) ++ head.remove_filename(); ++ ++ continue; + } + +- file_status head_status = detail::status_impl(head, &local_ec); ++ head /= p_elem; ++ ++ file_status head_status(detail::status_impl(head, &local_ec)); + if (BOOST_UNLIKELY(head_status.type() == fs::status_error)) + { + if (!ec) +@@ -4492,33 +4543,22 @@ path weakly_canonical(path const& p, path const& base, system::error_code* ec) + } + } + ++ if (head.empty()) ++ return p.lexically_normal(); ++ + #endif + +- path const& dot_p = dot_path(); +- path const& dot_dot_p = dot_dot_path(); + path tail; + bool tail_has_dots = false; + for (; itr != p_end; ++itr) + { + path const& tail_elem = *itr; +-#if defined(BOOST_WINDOWS_API) +- if (tail_elem.size() == 1u && detail::is_directory_separator(tail_elem.native()[0])) +- { +- // Convert generic separator returned by the iterator for the root directory to +- // the preferred separator. +- tail += path::preferred_separator; +- continue; +- } +-#endif + tail /= tail_elem; + // for a later optimization, track if any dot or dot-dot elements are present + if (!tail_has_dots && (tail_elem == dot_p || tail_elem == dot_dot_p)) + tail_has_dots = true; + } + +- if (head.empty()) +- return p.lexically_normal(); +- + head = detail::canonical(head, base, &local_ec); + if (BOOST_UNLIKELY(!!local_ec)) + { diff --git a/recipes/boost/all/patches/1.80.0-0003-unordered-valid-after-move.patch b/recipes/boost/all/patches/1.80.0-0003-unordered-valid-after-move.patch new file mode 100644 index 0000000000000..4245f23e76299 --- /dev/null +++ b/recipes/boost/all/patches/1.80.0-0003-unordered-valid-after-move.patch @@ -0,0 +1,175 @@ +diff -urN a/boost/unordered/detail/fca.hpp b/boost/unordered/detail/fca.hpp +--- a/boost/unordered/detail/fca.hpp 2022-08-03 22:47:16.000000000 -0400 ++++ b/boost/unordered/detail/fca.hpp 2022-08-24 19:44:43.139787681 -0400 +@@ -646,7 +646,7 @@ + + size_type bucket_count() const { return size_; } + +- iterator begin() const { return ++at(size_); } ++ iterator begin() const { return size_ == 0 ? end() : ++at(size_); } + + iterator end() const + { +@@ -660,6 +660,10 @@ + + local_iterator begin(size_type n) const + { ++ if (size_ == 0) { ++ return this->end(n); ++ } ++ + return local_iterator( + (buckets + static_cast(n))->next); + } +@@ -670,12 +674,16 @@ + + iterator at(size_type n) const + { +- std::size_t const N = group::N; ++ if (size_ > 0) { ++ std::size_t const N = group::N; + +- iterator pbg(buckets + static_cast(n), +- groups + static_cast(n / N)); ++ iterator pbg(buckets + static_cast(n), ++ groups + static_cast(n / N)); + +- return pbg; ++ return pbg; ++ } else { ++ return this->end(); ++ } + } + + span raw() +diff -urN a/boost/unordered/detail/implementation.hpp b/boost/unordered/detail/implementation.hpp +--- a/boost/unordered/detail/implementation.hpp 2022-08-03 22:47:16.000000000 -0400 ++++ b/boost/unordered/detail/implementation.hpp 2022-08-24 19:44:43.139787681 -0400 +@@ -2054,12 +2054,14 @@ + + std::size_t bucket_size(std::size_t index) const + { +- bucket_iterator itb = buckets_.at(index); +- node_pointer n = itb->next; + std::size_t count = 0; +- while (n) { +- ++count; +- n = n->next; ++ if (size_ > 0) { ++ bucket_iterator itb = buckets_.at(index); ++ node_pointer n = itb->next; ++ while (n) { ++ ++count; ++ n = n->next; ++ } + } + return count; + } +@@ -2420,11 +2422,14 @@ + node_pointer find_node_impl( + Key const& x, bucket_iterator itb) const + { +- key_equal const& pred = this->key_eq(); +- node_pointer p = itb->next; +- for (; p; p = p->next) { +- if (pred(x, extractor::extract(p->value()))) { +- break; ++ node_pointer p = node_pointer(); ++ if (itb != buckets_.end()) { ++ key_equal const& pred = this->key_eq(); ++ p = itb->next; ++ for (; p; p = p->next) { ++ if (pred(x, extractor::extract(p->value()))) { ++ break; ++ } + } + } + return p; +@@ -2453,11 +2458,13 @@ + inline iterator transparent_find( + Key const& k, Hash const& h, Pred const& pred) const + { +- std::size_t const key_hash = h(k); +- bucket_iterator itb = buckets_.at(buckets_.position(key_hash)); +- for (node_pointer p = itb->next; p; p = p->next) { +- if (BOOST_LIKELY(pred(k, extractor::extract(p->value())))) { +- return iterator(p, itb); ++ if (size_ > 0) { ++ std::size_t const key_hash = h(k); ++ bucket_iterator itb = buckets_.at(buckets_.position(key_hash)); ++ for (node_pointer p = itb->next; p; p = p->next) { ++ if (BOOST_LIKELY(pred(k, extractor::extract(p->value())))) { ++ return iterator(p, itb); ++ } + } + } + +@@ -2467,11 +2474,13 @@ + template + node_pointer* find_prev(Key const& key, bucket_iterator itb) + { +- key_equal pred = this->key_eq(); +- for (node_pointer* pp = boost::addressof(itb->next); *pp; +- pp = boost::addressof((*pp)->next)) { +- if (pred(key, extractor::extract((*pp)->value()))) { +- return pp; ++ if (size_ > 0) { ++ key_equal pred = this->key_eq(); ++ for (node_pointer* pp = boost::addressof(itb->next); *pp; ++ pp = boost::addressof((*pp)->next)) { ++ if (pred(key, extractor::extract((*pp)->value()))) { ++ return pp; ++ } + } + } + typedef node_pointer* node_pointer_pointer; +diff -urN a/boost/unordered/unordered_map.hpp b/boost/unordered/unordered_map.hpp +--- a/boost/unordered/unordered_map.hpp 2022-08-03 22:47:16.000000000 -0400 ++++ b/boost/unordered/unordered_map.hpp 2022-08-24 19:44:43.139787681 -0400 +@@ -2069,6 +2069,10 @@ + template + float unordered_map::load_factor() const BOOST_NOEXCEPT + { ++ if (table_.size_ == 0) { ++ return 0.0f; ++ } ++ + BOOST_ASSERT(table_.bucket_count() != 0); + return static_cast(table_.size_) / + static_cast(table_.bucket_count()); +@@ -2506,6 +2510,10 @@ + template + float unordered_multimap::load_factor() const BOOST_NOEXCEPT + { ++ if (table_.size_ == 0) { ++ return 0.0f; ++ } ++ + BOOST_ASSERT(table_.bucket_count() != 0); + return static_cast(table_.size_) / + static_cast(table_.bucket_count()); +diff -urN a/boost/unordered/unordered_set.hpp b/boost/unordered/unordered_set.hpp +--- a/boost/unordered/unordered_set.hpp 2022-08-03 22:47:16.000000000 -0400 ++++ b/boost/unordered/unordered_set.hpp 2022-08-24 19:44:43.139787681 -0400 +@@ -1586,6 +1586,10 @@ + template + float unordered_set::load_factor() const BOOST_NOEXCEPT + { ++ if (table_.size_ == 0) { ++ return 0.0f; ++ } ++ + BOOST_ASSERT(table_.bucket_count() != 0); + return static_cast(table_.size_) / + static_cast(table_.bucket_count()); +@@ -1986,6 +1990,10 @@ + template + float unordered_multiset::load_factor() const BOOST_NOEXCEPT + { ++ if (table_.size_ == 0) { ++ return 0.0f; ++ } ++ + BOOST_ASSERT(table_.bucket_count() != 0); + return static_cast(table_.size_) / + static_cast(table_.bucket_count()); diff --git a/recipes/boost/all/patches/1.80.0-0004-filesystem-posix-fix-no-at-apis-missing-include.patch b/recipes/boost/all/patches/1.80.0-0004-filesystem-posix-fix-no-at-apis-missing-include.patch new file mode 100644 index 0000000000000..dfa4438d93acd --- /dev/null +++ b/recipes/boost/all/patches/1.80.0-0004-filesystem-posix-fix-no-at-apis-missing-include.patch @@ -0,0 +1,21 @@ +commit 5864f397ccad30f6e73221b90bdac57a303b9752 +Author: Andrey Semashev +Date: Fri Aug 12 12:59:56 2022 +0300 + + Fixed a missing include on POSIX systems that don't support *at APIs. + + Fixes https://github.com/boostorg/filesystem/issues/250. + +diff --git a/libs/filesystem/src/operations.cpp b/libs/filesystem/src/operations.cpp +index ca2fff3..e22967e 100644 +--- a/libs/filesystem/src/operations.cpp ++++ b/libs/filesystem/src/operations.cpp +@@ -70,7 +70,7 @@ + + #include + #include +-#if _POSIX_C_SOURCE < 200809L ++#if !defined(BOOST_FILESYSTEM_HAS_POSIX_AT_APIS) + #include + #endif + #include diff --git a/recipes/boost/all/patches/1.80.0-locale-fail-on-missing-backend.patch b/recipes/boost/all/patches/1.80.0-locale-fail-on-missing-backend.patch new file mode 100644 index 0000000000000..e352396226710 --- /dev/null +++ b/recipes/boost/all/patches/1.80.0-locale-fail-on-missing-backend.patch @@ -0,0 +1,84 @@ +diff --git a/libs/locale/build/Jamfile.v2 b/libs/locale/build/Jamfile.v2 +index 3c517c884..0f521dbcf 100644 +--- a/libs/locale/build/Jamfile.v2 ++++ b/libs/locale/build/Jamfile.v2 +@@ -20,6 +20,7 @@ project /boost/locale + # Features + + feature.feature boost.locale.iconv : on off : optional propagated ; ++feature.feature boost.locale.iconv.lib : libc libiconv : optional propagated ; + feature.feature boost.locale.icu : on off : optional propagated ; + feature.feature boost.locale.posix : on off : optional propagated ; + feature.feature boost.locale.std : on off : optional propagated ; +@@ -29,7 +30,8 @@ feature.feature boost.locale.winapi : on off : optional propagated ; + + ## iconv + +-exe has_iconv : $(TOP)/build/has_iconv.cpp ; ++obj has_iconv_libc_obj : $(TOP)/build/has_iconv.cpp ; ++exe has_iconv : has_iconv_libc_obj ; + explicit has_iconv ; + + ICONV_PATH = [ modules.peek : ICONV_PATH ] ; +@@ -43,7 +45,8 @@ lib iconv + + explicit iconv ; + +-exe has_external_iconv : $(TOP)/build/has_iconv.cpp iconv ; ++obj has_iconv_libc_ext : $(TOP)/build/has_iconv.cpp iconv ; ++exe has_external_iconv : has_iconv_libc_ext iconv ; + explicit has_external_iconv ; + + exe accepts_shared_option : $(TOP)/build/option.cpp +@@ -230,10 +233,37 @@ rule configure-full ( properties * : flags-only ) + if [ configure.builds has_iconv : $(properties) : "iconv (libc)" ] + { + found-iconv = true ; +- } else if [ configure.builds has_external_iconv : $(properties) : "iconv (separate)" ] ++ if libiconv in $(properties) ++ { ++ if [ configure.builds has_external_iconv : $(properties) : "iconv (separate)" ] ++ { ++ result += iconv ; ++ } ++ else ++ { ++ EXIT "- Boost.Locale found iconv (libc) instead of iconv (separate) library to be built." ; ++ } ++ } ++ } ++ else if libc in $(properties) + { +- found-iconv = true ; +- result += iconv ; ++ EXIT "- Boost.Locale failed to find iconv (libc) library to be built." ; ++ } ++ else ++ { ++ if [ configure.builds has_external_iconv : $(properties) : "iconv (separate)" ] ++ { ++ found-iconv = true ; ++ result += iconv ; ++ } ++ else if libiconv in $(properties) ++ { ++ EXIT "- Boost.Locale failed to find iconv (separate) library to be built." ; ++ } ++ } ++ if ! $(found-iconv) ++ { ++ EXIT "- Boost.Locale failed to find iconv library to be built." ; + } + } + if $(found-iconv) +@@ -273,6 +303,10 @@ rule configure-full ( properties * : flags-only ) + /boost/thread//boost_thread + ; + } ++ else ++ { ++ EXIT "- Boost.Locale failed to find ICU library to be built." ; ++ } + } + + if ! $(found-iconv) && ! $(found-icu) && ! windows in $(properties) && ! cygwin in $(properties) diff --git a/recipes/boost/all/patches/boost_1_77_mpi_check.patch b/recipes/boost/all/patches/boost_1_77_mpi_check.patch new file mode 100644 index 0000000000000..59e5030464cca --- /dev/null +++ b/recipes/boost/all/patches/boost_1_77_mpi_check.patch @@ -0,0 +1,24 @@ +diff -ru a/tools/build/src/tools/mpi.jam b/tools/build/src/tools/mpi.jam +--- a/tools/build/src/tools/mpi.jam 2019-12-10 01:20:16.000000000 +0100 ++++ b/tools/build/src/tools/mpi.jam 2020-09-02 13:17:22.942349254 +0200 +@@ -66,6 +66,8 @@ + import type ; + import path ; + ++import errors ; ++ + # Make this module a project + project.initialize $(__name__) ; + project mpi ; +@@ -538,6 +540,11 @@ + # Set up the "mpi" alias + alias mpi : : : : $(options) ; + } ++ ++ if ! $(.configured) ++ { ++ errors.user-error "MPI not configured" ; ++ } + } + + # States whether MPI has bee configured diff --git a/recipes/boost/all/patches/boost_build_asmflags.patch b/recipes/boost/all/patches/boost_build_asmflags.patch deleted file mode 100644 index 075f0b1d89d65..0000000000000 --- a/recipes/boost/all/patches/boost_build_asmflags.patch +++ /dev/null @@ -1,42 +0,0 @@ -diff --git a/tools/build/src/tools/common.jam b/tools/build/src/tools/common.jam -index 19eaca51c9..5b9b350854 100644 ---- a/tools/build/src/tools/common.jam -+++ b/tools/build/src/tools/common.jam -@@ -429,6 +429,7 @@ local rule check-tool ( xcommand + ) - # - OPTIONS for compile to the value of in $(options) - # - OPTIONS for compile.c to the value of in $(options) - # - OPTIONS for compile.c++ to the value of in $(options) -+# - OPTIONS for compile.asm to the value of in $(options) - # - OPTIONS for compile.fortran to the value of in $(options) - # - OPTIONS for link to the value of in $(options) - # -@@ -454,6 +455,9 @@ rule handle-options ( toolset : condition * : command * : options * ) - toolset.flags $(toolset).compile.c++ OPTIONS $(condition) : - [ feature.get-values : $(options) ] : unchecked ; - -+ toolset.flags $(toolset).compile.asm OPTIONS $(condition) : -+ [ feature.get-values : $(options) ] : unchecked ; -+ - toolset.flags $(toolset).compile.fortran OPTIONS $(condition) : - [ feature.get-values : $(options) ] : unchecked ; - -diff --git a/tools/build/src/tools/common.py b/tools/build/src/tools/common.py -index d0e2a387e0..8f6cbfff1a 100644 ---- a/tools/build/src/tools/common.py -+++ b/tools/build/src/tools/common.py -@@ -441,6 +441,7 @@ def handle_options(tool, condition, command, options): - - OPTIOns for compile to the value of in options - - OPTIONS for compile.c to the value of in options - - OPTIONS for compile.c++ to the value of in options -+ - OPTIONS for compile.asm to the value of in options - - OPTIONS for compile.fortran to the value of in options - - OPTIONs for link to the value of in options - """ -@@ -454,6 +455,7 @@ def handle_options(tool, condition, command, options): - toolset.flags(tool + '.compile', 'OPTIONS', condition, feature.get_values('', options)) - toolset.flags(tool + '.compile.c', 'OPTIONS', condition, feature.get_values('', options)) - toolset.flags(tool + '.compile.c++', 'OPTIONS', condition, feature.get_values('', options)) -+ toolset.flags(tool + '.compile.asm', 'OPTIONS', condition, feature.get_values('', options)) - toolset.flags(tool + '.compile.fortran', 'OPTIONS', condition, feature.get_values('', options)) - toolset.flags(tool + '.link', 'OPTIONS', condition, feature.get_values('', options)) - diff --git a/recipes/boost/all/patches/boost_locale_fail_on_missing_backend.patch b/recipes/boost/all/patches/boost_locale_fail_on_missing_backend.patch new file mode 100644 index 0000000000000..f1a0b7958449e --- /dev/null +++ b/recipes/boost/all/patches/boost_locale_fail_on_missing_backend.patch @@ -0,0 +1,60 @@ +diff --git a/libs/locale/build/Jamfile.v2 b/libs/locale/build/Jamfile.v2 +index 578e722..b715f59 100644 +--- a/libs/locale/build/Jamfile.v2 ++++ b/libs/locale/build/Jamfile.v2 +@@ -17,6 +17,7 @@ import feature ; + # Features + + feature.feature boost.locale.iconv : on off : optional propagated ; ++feature.feature boost.locale.iconv.lib : libc libiconv : optional propagated ; + feature.feature boost.locale.icu : on off : optional propagated ; + feature.feature boost.locale.posix : on off : optional propagated ; + feature.feature boost.locale.std : on off : optional propagated ; +@@ -217,6 +217,21 @@ rule configure-full ( properties * : flags-only ) + if [ configure.builds has_iconv : $(properties) : "iconv (libc)" ] + { + found-iconv = true ; ++ if libiconv in $(properties) ++ { ++ if [ configure.builds has_external_iconv : $(properties) : "iconv (separate)" ] ++ { ++ result += iconv ; ++ } ++ else ++ { ++ EXIT "- Boost.Locale found iconv (libc) instead of iconv (separate) library to be built." ; ++ } ++ } ++ } ++ else if libc in $(properties) ++ { ++ EXIT "- Boost.Locale failed to find iconv (libc) library to be built." ; + } + else + { +@@ -225,6 +234,14 @@ rule configure-full ( properties * : flags-only ) + found-iconv = true ; + result += iconv ; + } ++ else if libiconv in $(properties) ++ { ++ EXIT "- Boost.Locale failed to find iconv (separate) library to be built." ; ++ } ++ } ++ if ! $(found-iconv) ++ { ++ EXIT "- Boost.Locale failed to find iconv library to be built." ; + } + } + if $(found-iconv) +@@ -265,6 +282,10 @@ rule configure-full ( properties * : flags-only ) + ../../thread/build//boost_thread + ; + } ++ else ++ { ++ EXIT "- Boost.Locale failed to find ICU library to be built." ; ++ } + + } + diff --git a/recipes/boost/all/patches/boost_mpi_check.patch b/recipes/boost/all/patches/boost_mpi_check.patch new file mode 100644 index 0000000000000..af7e45f610510 --- /dev/null +++ b/recipes/boost/all/patches/boost_mpi_check.patch @@ -0,0 +1,24 @@ +diff -ru a/tools/build/src/tools/mpi.jam b/tools/build/src/tools/mpi.jam +--- a/tools/build/src/tools/mpi.jam 2019-12-10 01:20:16.000000000 +0100 ++++ b/tools/build/src/tools/mpi.jam 2020-09-02 13:17:22.942349254 +0200 +@@ -66,6 +66,8 @@ + import type ; + import path ; + ++import errors ; ++ + # Make this module a project + project.initialize $(__name__) ; + project mpi ; +@@ -539,6 +541,11 @@ + # Set up the "mpi" alias + alias mpi : : : : $(options) ; + } ++ ++ if ! $(.configured) ++ { ++ errors.user-error "MPI not configured" ; ++ } + } + + # States whether MPI has bee configured diff --git a/recipes/boost/all/patches/static_object_init.patch b/recipes/boost/all/patches/static_object_init.patch deleted file mode 100644 index 2336c4de5565c..0000000000000 --- a/recipes/boost/all/patches/static_object_init.patch +++ /dev/null @@ -1,44 +0,0 @@ -diff --ru a/boost/python/detail/caller.hpp b/boost/python/detail/caller.hpp ---- a/boost/python/detail/caller.hpp -+++ b/boost/python/detail/caller.hpp -@@ -109,6 +109,21 @@ struct converter_target_type - return 0; - } - }; -+ -+template const signature_element* get_ret() -+{ -+ typedef BOOST_DEDUCED_TYPENAME Policies::template extract_return_type::type rtype; -+ typedef typename select_result_converter::type result_converter; -+ -+ static const signature_element ret = { -+ (is_void::value ? "void" : type_id().name()) -+ , &detail::converter_target_type::get_pytype -+ , boost::detail::indirect_traits::is_reference_to_non_const::value -+ }; -+ -+ return &ret; -+}; -+ - #endif - - -@@ -229,16 +244,9 @@ struct caller_arity - { - const signature_element * sig = detail::signature::elements(); - #ifndef BOOST_PYTHON_NO_PY_SIGNATURES -+ const signature_element * ret = detail::get_ret(); - -- typedef BOOST_DEDUCED_TYPENAME Policies::template extract_return_type::type rtype; -- typedef typename select_result_converter::type result_converter; -- -- static const signature_element ret = { -- (is_void::value ? "void" : type_id().name()) -- , &detail::converter_target_type::get_pytype -- , boost::detail::indirect_traits::is_reference_to_non_const::value -- }; -- py_func_sig_info res = {sig, &ret }; -+ py_func_sig_info res = {sig, ret }; - #else - py_func_sig_info res = {sig, sig }; - #endif diff --git a/recipes/boost/all/patches/support_msvc_2019.patch b/recipes/boost/all/patches/support_msvc_2019.patch deleted file mode 100644 index 867e65c44a2ec..0000000000000 --- a/recipes/boost/all/patches/support_msvc_2019.patch +++ /dev/null @@ -1,715 +0,0 @@ -diff --git a/tools/build/src/engine/config_toolset.bat b/tools/build/src/engine/config_toolset.bat -index b0bdfbb6f5..b0e3baa9e5 100644 ---- a/tools/build/src/engine/config_toolset.bat -+++ b/tools/build/src/engine/config_toolset.bat -@@ -184,7 +184,7 @@ set "_known_=1" - :Skip_VC141 - if NOT "_%BOOST_JAM_TOOLSET%_" == "_borland_" goto Skip_BORLAND - if "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" ( -- call :Test_Path bcc32.exe ) -+ call guess_toolset.bat test_path bcc32.exe ) - if "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" ( - if not errorlevel 1 ( - set "BOOST_JAM_TOOLSET_ROOT=%FOUND_PATH%..\" -@@ -192,7 +192,7 @@ if "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" ( - if not "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" ( - set "PATH=%BOOST_JAM_TOOLSET_ROOT%Bin;%PATH%" - ) --set "BOOST_JAM_CC=bcc32 -WC -w- -q -I%BOOST_JAM_TOOLSET_ROOT%Include -L%BOOST_JAM_TOOLSET_ROOT%Lib /DNT -nbootstrap" -+set "BOOST_JAM_CC=bcc32 -WC -w- -q -I"%BOOST_JAM_TOOLSET_ROOT%Include" -L"%BOOST_JAM_TOOLSET_ROOT%Lib" -Nd /DNT -nbootstrap" - set "BOOST_JAM_OPT_JAM=-ejam0" - set "BOOST_JAM_OPT_MKJAMBASE=-emkjambasejam0" - set "BOOST_JAM_OPT_YYACC=-eyyacc0" - -diff --git a/tools/build/src/engine/vswhere_usability_wrapper.cmd b/tools/build/src/engine/vswhere_usability_wrapper.cmd -index eb7c537bc3..5f68b60730 100644 ---- a/tools/build/src/engine/vswhere_usability_wrapper.cmd -+++ b/tools/build/src/engine/vswhere_usability_wrapper.cmd -@@ -1,7 +1,8 @@ - :: Copyright 2017 - Refael Ackermann -+:: Copyright 2019 - Thomas Kent - :: Distributed under MIT style license - :: See accompanying file LICENSE at https://github.com/node4good/windows-autoconf --:: version: 1.15.4 -+:: Forked from version: 1.15.4 - - @if not defined DEBUG_HELPER @ECHO OFF - setlocal -@@ -14,19 +15,44 @@ where vswhere 2> nul > nul - if errorlevel 1 goto :no-vswhere - set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 - set VSWHERE_PRP=-property installationPath -+ -+REM Visual Studio 2017 (15.X, toolset 14.1) - set VSWHERE_LMT=-version "[15.0,16.0)" --vswhere -prerelease > nul --if "%~1"=="prerelase" set VSWHERE_WITH_PRERELASE=1 --if not errorlevel 1 if "%VSWHERE_WITH_PRERELASE%"=="1" set "VSWHERE_LMT=%VSWHERE_LMT% -prerelease" - SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT% - for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( - endlocal -+ echo Found with vswhere %%i - @rem comment out setting VCINSTALLDIR for Boost.build - @rem set "VCINSTALLDIR=%%i\VC\" - set "VS150COMNTOOLS=%%i\Common7\Tools\" - exit /B 0 - ) - -+REM Visual Studio 2019 (16.X, toolset 14.2) -+set VSWHERE_LMT=-version "[16.0,17.0)" -+SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT% -+for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( -+ endlocal -+ echo Found with vswhere %%i -+ @rem comment out setting VCINSTALLDIR for Boost.build -+ @rem set "VCINSTALLDIR=%%i\VC\" -+ set "VS160COMNTOOLS=%%i\Common7\Tools\" -+ exit /B 0 -+) -+ -+REM Visual Studio Next (17.X, toolset 14.3???) -+set VSWHERE_LMT=-version "[17.0,18.0)" -+set VSWHERE_PRERELEASE=-prerelease -+SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT% %VSWHERE_PRERELEASE% -+for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( -+ endlocal -+ echo Found with vswhere %%i -+ @rem comment out setting VCINSTALLDIR for Boost.build -+ @rem set "VCINSTALLDIR=%%i\VC\" -+ set "VS170COMNTOOLS=%%i\Common7\Tools\" -+ exit /B 0 -+) -+ - :no-vswhere - endlocal - echo could not find "vswhere" - -diff --git a/tools/build/src/engine/vswhere_usability_wrapper.cmd b/tools/build/src/engine/vswhere_usability_wrapper.cmd -index 5f68b60730..d642a578ef 100644 ---- a/tools/build/src/engine/vswhere_usability_wrapper.cmd -+++ b/tools/build/src/engine/vswhere_usability_wrapper.cmd -@@ -40,8 +40,8 @@ for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( - exit /B 0 - ) - --REM Visual Studio Next (17.X, toolset 14.3???) --set VSWHERE_LMT=-version "[17.0,18.0)" -+REM Visual Studio Unknown Version, Beyond 2019 -+set VSWHERE_LMT=-version "[17.0)" - set VSWHERE_PRERELEASE=-prerelease - SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT% %VSWHERE_PRERELEASE% - for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( -@@ -49,7 +49,7 @@ for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( - echo Found with vswhere %%i - @rem comment out setting VCINSTALLDIR for Boost.build - @rem set "VCINSTALLDIR=%%i\VC\" -- set "VS170COMNTOOLS=%%i\Common7\Tools\" -+ set "VSUNKCOMNTOOLS=%%i\Common7\Tools\" - exit /B 0 - ) - -diff --git a/tools/build/src/engine/build.jam b/tools/build/src/engine/build.jam -index 0a67d14bb9..de567ddb5a 100644 ---- a/tools/build/src/engine/build.jam -+++ b/tools/build/src/engine/build.jam -@@ -408,6 +408,13 @@ toolset vc141 cl : /Fe /Fe /Fd /Fo : -D - [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ] - -I$(--python-include) -I$(--extra-include) - : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; -+## Microsoft Visual C++ 2019 -+toolset vc142 cl : /Fe /Fe /Fd /Fo : -D -+ : /nologo -+ [ opt --release : /GL /MT /O2 /Ob2 /Gy /GF /GA /wd4996 ] -+ [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ] -+ -I$(--python-include) -I$(--extra-include) -+ : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; - ## VMS/OpenVMS DEC C - toolset vmsdecc cc : /OBJECT= : "/DEFINES=(" "," ")" - : /STANDARD=VAXC /PREFIX_LIBRARY_ENTRIES=(ALL_ENTRIES) - -diff --git a/tools/build/src/engine/config_toolset.bat b/tools/build/src/engine/config_toolset.bat -index b0e3baa9e5..9da024e41a 100644 ---- a/tools/build/src/engine/config_toolset.bat -+++ b/tools/build/src/engine/config_toolset.bat -@@ -182,6 +182,50 @@ set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0" - set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0" - set "_known_=1" - :Skip_VC141 -+if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc142_" goto Skip_VC142 -+call vswhere_usability_wrapper.cmd -+REM Reset ERRORLEVEL since from now on it's all based on ENV vars -+ver > nul 2> nul -+if "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" ( -+ if NOT "_%VS160COMNTOOLS%_" == "__" ( -+ set "BOOST_JAM_TOOLSET_ROOT=%VS160COMNTOOLS%..\..\VC\" -+ )) -+ -+if "_%BOOST_JAM_ARCH%_" == "__" set BOOST_JAM_ARCH=x86 -+set BOOST_JAM_ARGS=%BOOST_JAM_ARGS% %BOOST_JAM_ARCH% -+ -+REM return to current directory as vsdevcmd_end.bat switches to %USERPROFILE%\Source if it exists. -+pushd %CD% -+if "_%VSINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%Auxiliary\Build\vcvarsall.bat" %BOOST_JAM_ARGS% -+popd -+set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib" -+set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0" -+set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0" -+set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0" -+set "_known_=1" -+:Skip_VC142 -+if NOT "_%BOOST_JAM_TOOLSET%_" == "_vcunk_" goto Skip_VCUNK -+call vswhere_usability_wrapper.cmd -+REM Reset ERRORLEVEL since from now on it's all based on ENV vars -+ver > nul 2> nul -+if "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" ( -+ if NOT "_%VSUNKCOMNTOOLS%_" == "__" ( -+ set "BOOST_JAM_TOOLSET_ROOT=%VSUNKCOMNTOOLS%..\..\VC\" -+ )) -+ -+if "_%BOOST_JAM_ARCH%_" == "__" set BOOST_JAM_ARCH=x86 -+set BOOST_JAM_ARGS=%BOOST_JAM_ARGS% %BOOST_JAM_ARCH% -+ -+REM return to current directory as vsdevcmd_end.bat switches to %USERPROFILE%\Source if it exists. -+pushd %CD% -+if "_%VSINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%Auxiliary\Build\vcvarsall.bat" %BOOST_JAM_ARGS% -+popd -+set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib" -+set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0" -+set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0" -+set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0" -+set "_known_=1" -+:Skip_VCUNK - if NOT "_%BOOST_JAM_TOOLSET%_" == "_borland_" goto Skip_BORLAND - if "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" ( - call guess_toolset.bat test_path bcc32.exe ) - -diff --git a/tools/build/src/tools/msvc.jam b/tools/build/src/tools/msvc.jam -index e6c0b60358..cbde9eb136 100644 ---- a/tools/build/src/tools/msvc.jam -+++ b/tools/build/src/tools/msvc.jam -@@ -21,6 +21,7 @@ http://msdn.microsoft.com/visualc/[Microsoft Visual C++] command-line - tools on Microsoft Windows. The supported products and versions of - command line tools are listed below: - -+* Visual Studio 2019-14.2 - * Visual Studio 2017—14.1 - * Visual Studio 2015—14.0 - * Visual Studio 2013—12.0 -@@ -37,7 +38,7 @@ equal to `msvc-[version number]` for example to build with Visual Studio - 2017 one could run: - - ---- --.\b2 toolset=msvc-14.1 target -+.\b2 toolset=msvc-14.2 target - ---- - - The `msvc` module is initialized using the following syntax: -@@ -1015,7 +1016,15 @@ local rule generate-setup-cmd ( version : command : parent : options * : cpu : g - } - else - { -- if [ MATCH "(14.1)" : $(version) ] -+ if [ MATCH "(14.2)" : $(version) ] -+ { -+ if $(.debug-configuration) -+ { -+ ECHO 'notice\: "[generate-setup-cmd]" $(version) is 14.2' ; -+ } -+ parent = [ path.native [ path.join $(parent) "..\\..\\..\\..\\..\\Auxiliary\\Build" ] ] ; -+ } -+ else if [ MATCH "(14.1)" : $(version) ] - { - if $(.debug-configuration) - { -@@ -1173,9 +1182,9 @@ local rule configure-really ( version ? : options * ) - - local command = [ feature.get-values : $(options) ] ; - -- # For 14.1 we need the exact version as MS is planning rolling updates -+ # For 14.1+ we need the exact version as MS is planning rolling updates - # that will cause our `setup-cmd` to become invalid -- exact-version = [ MATCH "(14\.10\.[0-9\.]+)" : $(command) ] ; -+ exact-version = [ MATCH "(14\.[1-9][0-9]\.[0-9\.]+)" : $(command) ] ; - - # If version is specified, we try to search first in default paths, and - # only then in PATH. -@@ -1204,7 +1213,11 @@ local rule configure-really ( version ? : options * ) - # version from the path. - # FIXME: We currently detect both Microsoft Visual Studio 9.0 and - # 9.0express as 9.0 here. -- if [ MATCH "(MSVC\\14.1)" : $(command) ] -+ if [ MATCH "(MSVC\\14.2)" : $(command) ] -+ { -+ version = 14.2 ; -+ } -+ else if [ MATCH "(MSVC\\14.1)" : $(command) ] - { - version = 14.1 ; - } -@@ -1533,8 +1546,26 @@ local rule default-path ( version ) - else - { - # try to use vswhere -- local pseudo_env_VS150 ; -- if $(version) = 14.1 || $(version) = "default" -+ local pseudo_env_VSCOMNTOOLS ; -+ if $(version) = 14.2 || $(version) = "default" -+ { -+ local req = "-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ; -+ local prop = "-property installationPath" ; -+ local limit = "-version \"[16.0,17.0)\"" ; -+ local root = [ os.environ "ProgramFiles(x86)" ] ; -+ if ( ! $(root) ) -+ { -+ root = [ os.environ "ProgramFiles" ] ; -+ } -+ local vswhere = "$(root)\\Microsoft Visual Studio\\Installer\\vswhere.exe" ; -+ if ( [ path.exists $(vswhere) ] ) -+ { -+ local vmwhere_cmd = "\"$(vswhere)\" -latest -products * $(req) $(prop) $(limit)" ; -+ local shell_ret = [ SPLIT_BY_CHARACTERS [ SHELL $(vmwhere_cmd) ] : "\n" ] ; -+ pseudo_env_VSCOMNTOOLS = [ path.native [ path.join $(shell_ret) "\\Common7\\Tools" ] ] ; -+ } -+ } -+ else if $(version) = 14.1 - { - local req = "-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ; - local prop = "-property installationPath" ; -@@ -1549,7 +1580,7 @@ local rule default-path ( version ) - { - local vmwhere_cmd = "\"$(vswhere)\" -latest -products * $(req) $(prop) $(limit)" ; - local shell_ret = [ SPLIT_BY_CHARACTERS [ SHELL $(vmwhere_cmd) ] : "\n" ] ; -- pseudo_env_VS150 = [ path.native [ path.join $(shell_ret) "\\Common7\\Tools" ] ] ; -+ pseudo_env_VSCOMNTOOLS = [ path.native [ path.join $(shell_ret) "\\Common7\\Tools" ] ] ; - } - } - -@@ -1557,9 +1588,9 @@ local rule default-path ( version ) - for local env in $(.version-$(version)-env) - { - local env-path ; -- if ( $(pseudo_env_VS150) && [ path.exists $(pseudo_env_VS150) ] ) -+ if ( $(pseudo_env_VSCOMNTOOLS) && [ path.exists $(pseudo_env_VSCOMNTOOLS) ] ) - { -- env-path = $(pseudo_env_VS150) ; -+ env-path = $(pseudo_env_VSCOMNTOOLS) ; - } - else - { -@@ -1956,7 +1987,7 @@ if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] - armv7 armv7s ; - - # Known toolset versions, in order of preference. --.known-versions = 14.1 14.0 12.0 11.0 10.0 10.0express 9.0 9.0express 8.0 8.0express 7.1 -+.known-versions = 14.2 14.1 14.0 12.0 11.0 10.0 10.0express 9.0 9.0express 8.0 8.0express 7.1 - 7.1toolkit 7.0 6.0 ; - - # Version aliases. -@@ -1970,6 +2001,7 @@ if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] - .version-alias-12 = 12.0 ; - .version-alias-14 = 14.0 ; - .version-alias-14.1 = 14.1 ; -+.version-alias-14.2 = 14.2 ; - - # Names of registry keys containing the Visual C++ installation path (relative - # to "HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft"). -@@ -1999,6 +2031,11 @@ if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] - "Microsoft Visual Studio/2017/*/VC/Tools/MSVC/*/bin/Host*/*" - ; - .version-14.1-env = VS150COMNTOOLS ProgramFiles ProgramFiles(x86) ; -+.version-14.2-path = -+ "../../VC/Tools/MSVC/*/bin/Host*/*" -+ "Microsoft Visual Studio/2017/*/VC/Tools/MSVC/*/bin/Host*/*" -+ ; -+.version-14.2-env = VS150COMNTOOLS ProgramFiles ProgramFiles(x86) ; - - # Auto-detect all the available msvc installations on the system. - auto-detect-toolset-versions ; - -diff --git a/tools/build/src/tools/msvc.jam b/tools/build/src/tools/msvc.jam -index cbde9eb136..185f5f2a1b 100644 ---- a/tools/build/src/tools/msvc.jam -+++ b/tools/build/src/tools/msvc.jam -@@ -223,6 +223,7 @@ import project ; - import property ; - import property-set ; - import rc ; -+import sequence ; - import set ; - import toolset ; - import type ; -@@ -1547,55 +1548,46 @@ local rule default-path ( version ) - { - # try to use vswhere - local pseudo_env_VSCOMNTOOLS ; -- if $(version) = 14.2 || $(version) = "default" -+ local all-env-paths ; -+ local root = [ os.environ "ProgramFiles(x86)" ] ; -+ if ( ! $(root) ) - { -- local req = "-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ; -- local prop = "-property installationPath" ; -- local limit = "-version \"[16.0,17.0)\"" ; -- local root = [ os.environ "ProgramFiles(x86)" ] ; -- if ( ! $(root) ) -- { -- root = [ os.environ "ProgramFiles" ] ; -- } -- local vswhere = "$(root)\\Microsoft Visual Studio\\Installer\\vswhere.exe" ; -- if ( [ path.exists $(vswhere) ] ) -- { -- local vmwhere_cmd = "\"$(vswhere)\" -latest -products * $(req) $(prop) $(limit)" ; -- local shell_ret = [ SPLIT_BY_CHARACTERS [ SHELL $(vmwhere_cmd) ] : "\n" ] ; -- pseudo_env_VSCOMNTOOLS = [ path.native [ path.join $(shell_ret) "\\Common7\\Tools" ] ] ; -- } -+ root = [ os.environ "ProgramFiles" ] ; - } -- else if $(version) = 14.1 -+ local vswhere = "$(root)\\Microsoft Visual Studio\\Installer\\vswhere.exe" ; -+ if $(version) in 14.1 14.2 default && [ path.exists $(vswhere) ] - { - local req = "-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ; - local prop = "-property installationPath" ; -- local limit = "-version \"[15.0,16.0)\"" ; -- local root = [ os.environ "ProgramFiles(x86)" ] ; -- if ( ! $(root) ) -+ local limit ; -+ -+ if $(version) = 14.2 || $(version) = "default" - { -- root = [ os.environ "ProgramFiles" ] ; -+ limit = "-version \"[16.0,17.0)\"" ; - } -- local vswhere = "$(root)\\Microsoft Visual Studio\\Installer\\vswhere.exe" ; -- if ( [ path.exists $(vswhere) ] ) -+ else if $(version) = 14.1 -+ { -+ limit = "-version \"[15.0,16.0)\"" ; -+ } -+ -+ local vswhere_cmd = "\"$(vswhere)\" -latest -products * $(req) $(prop) $(limit)" ; -+ local shell_ret = [ SPLIT_BY_CHARACTERS [ SHELL $(vswhere_cmd) ] : "\n" ] ; -+ pseudo_env_VSCOMNTOOLS = [ path.native [ path.join $(shell_ret) "\\Common7\\Tools" ] ] ; -+ if ! [ path.exists $(pseudo_env_VSCOMNTOOLS) ] - { -- local vmwhere_cmd = "\"$(vswhere)\" -latest -products * $(req) $(prop) $(limit)" ; -- local shell_ret = [ SPLIT_BY_CHARACTERS [ SHELL $(vmwhere_cmd) ] : "\n" ] ; -- pseudo_env_VSCOMNTOOLS = [ path.native [ path.join $(shell_ret) "\\Common7\\Tools" ] ] ; -+ return ; # Not found. If we have vswhere, assume that it works. - } -+ all-env-paths = $(pseudo_env_VSCOMNTOOLS) ; -+ } -+ else -+ { -+ all-env-paths = [ sequence.transform os.environ -+ : $(.version-$(version)-env) ] ; - } - - # Check environment or previous path_VS150 -- for local env in $(.version-$(version)-env) -+ for local env-path in $(all-env-paths) - { -- local env-path ; -- if ( $(pseudo_env_VSCOMNTOOLS) && [ path.exists $(pseudo_env_VSCOMNTOOLS) ] ) -- { -- env-path = $(pseudo_env_VSCOMNTOOLS) ; -- } -- else -- { -- env-path = [ os.environ $(env) ] ; -- } - if $(env-path) && $(.version-$(version)-path) - { - for local bin-path in $(.version-$(version)-path) -@@ -2033,9 +2025,9 @@ if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] - .version-14.1-env = VS150COMNTOOLS ProgramFiles ProgramFiles(x86) ; - .version-14.2-path = - "../../VC/Tools/MSVC/*/bin/Host*/*" -- "Microsoft Visual Studio/2017/*/VC/Tools/MSVC/*/bin/Host*/*" -+ "Microsoft Visual Studio/2019/*/VC/Tools/MSVC/*/bin/Host*/*" - ; --.version-14.2-env = VS150COMNTOOLS ProgramFiles ProgramFiles(x86) ; -+.version-14.2-env = VS160COMNTOOLS ProgramFiles ProgramFiles(x86) ; - - # Auto-detect all the available msvc installations on the system. - auto-detect-toolset-versions ; - -From 1691e6194c470e237ddf595bdbd9fb4e0a3320c3 Mon Sep 17 00:00:00 2001 -From: Tom Kent -Date: Tue, 5 Mar 2019 06:53:19 -0600 -Subject: [PATCH 31/37] If the vswhere lookup fails, keep searching for others - ---- - src/engine/vswhere_usability_wrapper.cmd | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tools/build/src/engine/vswhere_usability_wrapper.cmd b/tools/build/src/engine/vswhere_usability_wrapper.cmd -index d642a578ef..6b43e1eab7 100644 ---- a/tools/build/src/engine/vswhere_usability_wrapper.cmd -+++ b/tools/build/src/engine/vswhere_usability_wrapper.cmd -@@ -56,4 +56,4 @@ for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( - :no-vswhere - endlocal - echo could not find "vswhere" --exit /B 1 -\ No newline at end of file -+exit /B 0 -\ No newline at end of file - -diff --git a/tools/build/src/engine/vswhere_usability_wrapper.cmd b/tools/build/src/engine/vswhere_usability_wrapper.cmd -index 6b43e1eab7..d642a578ef 100644 ---- a/tools/build/src/engine/vswhere_usability_wrapper.cmd -+++ b/tools/build/src/engine/vswhere_usability_wrapper.cmd -@@ -56,4 +56,4 @@ for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( - :no-vswhere - endlocal - echo could not find "vswhere" --exit /B 0 -\ No newline at end of file -+exit /B 1 -\ No newline at end of file - -diff --git a/tools/build/src/tools/msvc.jam b/tools/build/src/tools/msvc.jam -index 185f5f2a1b..dda22b4c5f 100644 ---- a/tools/build/src/tools/msvc.jam -+++ b/tools/build/src/tools/msvc.jam -@@ -1126,12 +1126,15 @@ local rule set-setup-command ( targets * : properties * ) - # - local rule configure-really ( version ? : options * ) - { -- local v = $(version) ; -+ local command = [ feature.get-values : $(options) ] ; - -- # Decide what the 'default' version is. -- if ! $(v) -+ if ! $(version) && ! $(command) - { -+ # We were given neither a command, nor a version. - # Take the best registered (i.e. auto-detected) version. -+ # FIXME: consider whether an explicitly specified setup script -+ # should disable this logic. We already won't get here if -+ # there is a user specified command. - version = [ $(.versions).all ] ; - for local known in $(.known-versions) - { -@@ -1141,59 +1144,31 @@ local rule configure-really ( version ? : options * ) - break ; - } - } -+ # version might still have multiple elements if no versions -+ # were auto-detected, but an unknown version was configured -+ # manually. - version = $(version[1]) ; -- v = $(version) ; -- -- # Note: 'version' can still be empty at this point if no versions have -- # been auto-detected. -- version ?= "default" ; - } - -- # Version alias -> real version number. -- version = [ resolve-possible-msvc-version-alias $(version) ] ; -- -- # Check whether the selected configuration is already in use. -- if $(version) in [ $(.versions).used ] -+ # Handle a user-provided command, and deduce the version if necessary. -+ # If the user-requested version was not autodetected and no command -+ # was given, attempt to find it in PATH -+ if $(command) || ! ( $(version:E=default) in [ $(.versions).all ] ) - { -- # Allow multiple 'toolset.using' calls for the same configuration if the -- # identical sets of options are used. -- if $(options) && ( $(options) != [ $(.versions).get $(version) : options ] ) -+ local found-command = [ common.get-invocation-command-nodefault msvc : cl.exe : $(command) ] ; -+ -+ if $(found-command) - { -- import errors ; -- errors.error "MSVC toolset configuration: Toolset version" -- "'$(version)' already configured." ; -+ command = $(found-command) ; -+ if ! $(command:D) -+ { -+ local path = [ common.get-absolute-tool-path $(command) ] ; -+ command = $(command:R=$(path)) ; -+ } - } -- } -- else -- { -- # Register a new configuration. -- $(.versions).register $(version) ; -- -- # Add user-supplied to auto-detected options. -- options = [ $(.versions).get $(version) : options ] $(options) ; -- -- # Mark the configuration as 'used'. -- $(.versions).use $(version) ; -- -- # Generate conditions and save them. -- local conditions = [ common.check-init-parameters msvc : version $(v) ] -- ; -- -- $(.versions).set $(version) : conditions : $(conditions) ; -- -- local command = [ feature.get-values : $(options) ] ; -- -- # For 14.1+ we need the exact version as MS is planning rolling updates -- # that will cause our `setup-cmd` to become invalid -- exact-version = [ MATCH "(14\.[1-9][0-9]\.[0-9\.]+)" : $(command) ] ; -- -- # If version is specified, we try to search first in default paths, and -- # only then in PATH. -- command = [ common.get-invocation-command msvc : cl.exe : $(command) : -- [ default-paths $(version) ] : $(version) ] ; -- -- if ( ! $(version) || $(version) = "default" ) && ! $(command:D) -+ else - { -+ # If we still failed to find cl.exe, bail out. - ECHO ; - ECHO warning\: - "Did not find command for MSVC toolset." -@@ -1204,21 +1179,20 @@ local rule configure-really ( version ? : options * ) - "build from the 'Visual Studio Command Prompt for VS 2017'." - ; - ECHO ; -+ command ?= cl.exe ; - } - -- common.handle-options msvc : $(conditions) : $(command) : $(options) ; -- - if ! $(version) - { - # Even if version is not explicitly specified, try to detect the - # version from the path. - # FIXME: We currently detect both Microsoft Visual Studio 9.0 and - # 9.0express as 9.0 here. -- if [ MATCH "(MSVC\\14.2)" : $(command) ] -+ if [ MATCH "(MSVC\\\\14.2)" : $(command) ] - { - version = 14.2 ; - } -- else if [ MATCH "(MSVC\\14.1)" : $(command) ] -+ else if [ MATCH "(MSVC\\\\14.1)" : $(command) ] - { - version = 14.1 ; - } -@@ -1264,6 +1238,44 @@ local rule configure-really ( version ? : options * ) - version = 6.0 ; - } - } -+ } -+ -+ # Version alias -> real version number. -+ version = [ resolve-possible-msvc-version-alias $(version) ] ; -+ -+ # Check whether the selected configuration is already in use. -+ if $(version) in [ $(.versions).used ] -+ { -+ # Allow multiple 'toolset.using' calls for the same configuration if the -+ # identical sets of options are used. -+ if $(options) && ( $(options) != [ $(.versions).get $(version) : options ] ) -+ { -+ import errors ; -+ errors.user-error "MSVC toolset configuration: Toolset version" -+ "'$(version)' already configured." ; -+ } -+ } -+ else -+ { -+ # Register a new configuration. -+ $(.versions).register $(version) ; -+ $(.versions).set $(version) : options : $(options) ; -+ -+ # Mark the configuration as 'used'. -+ $(.versions).use $(version) ; -+ -+ # Generate conditions and save them. -+ local conditions = [ common.check-init-parameters msvc : version $(version) ] ; -+ -+ $(.versions).set $(version) : conditions : $(conditions) ; -+ -+ command ?= [ $(.versions).get $(version) : default-command ] ; -+ -+ # For 14.1+ we need the exact version as MS is planning rolling updates -+ # that will cause our `setup-cmd` to become invalid -+ exact-version = [ MATCH "(14\.[1-9][0-9]\.[0-9\.]+)" : $(command) ] ; -+ -+ common.handle-options msvc : $(conditions) : $(command) : $(options) ; - - # Generate and register setup command. - -@@ -1458,7 +1470,7 @@ local rule configure-really ( version ? : options * ) - { - for local cpu-condition in $(cpu-conditions) - { -- ECHO "notice: [msvc-cfg] condition: '$(cpu-condition)', setup: '$(setup-$(c))'" ; -+ ECHO "notice: [msvc-cfg] condition: '$(cpu-condition)', setup: '$(setup-$(c):J= )'" ; - } - } - -@@ -1536,15 +1548,7 @@ local rule configure-really ( version ? : options * ) - # - local rule default-path ( version ) - { -- # Use auto-detected path if possible. -- local result = [ feature.get-values : [ $(.versions).get $(version) -- : options ] ] ; -- -- if $(result) -- { -- result = $(result:D) ; -- } -- else -+ local result ; - { - # try to use vswhere - local pseudo_env_VSCOMNTOOLS ; -@@ -1611,28 +1615,6 @@ local rule default-path ( version ) - } - - --# Returns either the default installation path (if 'version' is not empty) or --# list of all known default paths (if no version is given) --# --local rule default-paths ( version ? ) --{ -- local possible-paths ; -- -- if $(version) -- { -- possible-paths += [ default-path $(version) ] ; -- } -- else -- { -- for local i in $(.known-versions) -- { -- possible-paths += [ default-path $(i) ] ; -- } -- } -- -- return $(possible-paths) ; --} -- - - rule get-rspline ( target : lang-opt ) - { -@@ -1908,7 +1890,7 @@ local rule register-configuration ( version : path ? ) - } - - $(.versions).register $(version) ; -- $(.versions).set $(version) : options : $(command) ; -+ $(.versions).set $(version) : default-command : $(command) ; - } - } - } -@@ -1992,8 +1974,6 @@ if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] - .version-alias-11 = 11.0 ; - .version-alias-12 = 12.0 ; - .version-alias-14 = 14.0 ; --.version-alias-14.1 = 14.1 ; --.version-alias-14.2 = 14.2 ; - - # Names of registry keys containing the Visual C++ installation path (relative - # to "HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft"). diff --git a/recipes/boost/all/test_package/CMakeLists.txt b/recipes/boost/all/test_package/CMakeLists.txt index d9fcc60a94ace..0a03121f75920 100644 --- a/recipes/boost/all/test_package/CMakeLists.txt +++ b/recipes/boost/all/test_package/CMakeLists.txt @@ -4,6 +4,10 @@ project(test_package) include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup(TARGETS) +if(BOOST_NAMESPACE) + add_definitions("-DBOOST_NAMESPACE=${BOOST_NAMESPACE}") +endif() + if(NOT HEADER_ONLY) if(WITH_RANDOM) find_package(Boost COMPONENTS random REQUIRED) diff --git a/recipes/boost/all/test_package/chrono.cpp b/recipes/boost/all/test_package/chrono.cpp index 9e82bc80d32a4..0127868cfeca9 100644 --- a/recipes/boost/all/test_package/chrono.cpp +++ b/recipes/boost/all/test_package/chrono.cpp @@ -4,6 +4,10 @@ #include #include +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + int main() { boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now(); diff --git a/recipes/boost/all/test_package/conanfile.py b/recipes/boost/all/test_package/conanfile.py index 9dfea8ad218ac..54e431f7b3b68 100644 --- a/recipes/boost/all/test_package/conanfile.py +++ b/recipes/boost/all/test_package/conanfile.py @@ -1,12 +1,21 @@ +import os + +from conan.tools.build import cross_building from conans import ConanFile, CMake, tools from conans.errors import ConanException -import os class TestPackageConan(ConanFile): settings = "os", "compiler", "arch", "build_type" generators = "cmake", "cmake_find_package" + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + self.build_requires("cmake/3.20.1") + def _boost_option(self, name, default): try: return getattr(self.options["boost"], name, default) @@ -37,13 +46,15 @@ def build(self): cmake.definitions["WITH_STACKTRACE"] = not self.options["boost"].without_stacktrace cmake.definitions["WITH_STACKTRACE_ADDR2LINE"] = self.deps_user_info["boost"].stacktrace_addr2line_available cmake.definitions["WITH_STACKTRACE_BACKTRACE"] = self._boost_option("with_stacktrace_backtrace", False) + if self.options["boost"].namespace != 'boost' and not self.options["boost"].namespace_alias: + cmake.definitions['BOOST_NAMESPACE'] = self.options["boost"].namespace cmake.configure() # Disable parallel builds because c3i (=conan-center's test/build infrastructure) seems to choke here cmake.parallel = False cmake.build() def test(self): - if tools.cross_building(self.settings): + if cross_building(self): return self.run(os.path.join("bin", "lambda_exe"), run_environment=True) if self.options["boost"].header_only: diff --git a/recipes/boost/all/test_package/coroutine.cpp b/recipes/boost/all/test_package/coroutine.cpp index 85f05a83d646a..06e901c78b82b 100644 --- a/recipes/boost/all/test_package/coroutine.cpp +++ b/recipes/boost/all/test_package/coroutine.cpp @@ -1,6 +1,10 @@ #include #include +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + using namespace boost::coroutines; void cooperative(coroutine::push_type &sink) diff --git a/recipes/boost/all/test_package/fiber.cpp b/recipes/boost/all/test_package/fiber.cpp index 5d9c5e402e4a2..6a0165c129269 100644 --- a/recipes/boost/all/test_package/fiber.cpp +++ b/recipes/boost/all/test_package/fiber.cpp @@ -20,6 +20,10 @@ #include +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + static std::size_t fiber_count{ 0 }; static std::mutex mtx_count{}; static boost::fibers::condition_variable_any cnd_count{}; diff --git a/recipes/boost/all/test_package/json.cpp b/recipes/boost/all/test_package/json.cpp index f74f69c4168e7..3670a3ddb4ff2 100644 --- a/recipes/boost/all/test_package/json.cpp +++ b/recipes/boost/all/test_package/json.cpp @@ -1,4 +1,9 @@ #include + +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + using namespace boost::json; #include diff --git a/recipes/boost/all/test_package/lambda.cpp b/recipes/boost/all/test_package/lambda.cpp index 471be39714198..0b35eec20eaeb 100644 --- a/recipes/boost/all/test_package/lambda.cpp +++ b/recipes/boost/all/test_package/lambda.cpp @@ -3,6 +3,10 @@ #include #include +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + int main(int argc, const char * const argv[]) { using namespace boost::lambda; diff --git a/recipes/boost/all/test_package/locale.cpp b/recipes/boost/all/test_package/locale.cpp index 4722b7025b8e0..b21f16247bcfc 100644 --- a/recipes/boost/all/test_package/locale.cpp +++ b/recipes/boost/all/test_package/locale.cpp @@ -9,6 +9,11 @@ #include #include #include + +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + int main() { using namespace boost::locale; diff --git a/recipes/boost/all/test_package/nowide.cpp b/recipes/boost/all/test_package/nowide.cpp index 516a345abad42..10a3495f22c61 100644 --- a/recipes/boost/all/test_package/nowide.cpp +++ b/recipes/boost/all/test_package/nowide.cpp @@ -5,6 +5,11 @@ #include #include #include + +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + int main(int argc,char **argv) { boost::nowide::args a(argc,argv); // Fix arguments - make them UTF-8 diff --git a/recipes/boost/all/test_package/numpy.cpp b/recipes/boost/all/test_package/numpy.cpp index 361342c75b256..184d107a28096 100644 --- a/recipes/boost/all/test_package/numpy.cpp +++ b/recipes/boost/all/test_package/numpy.cpp @@ -1,6 +1,10 @@ #include #include +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + namespace p = boost::python; namespace np = boost::python::numpy; diff --git a/recipes/boost/all/test_package/python.cpp b/recipes/boost/all/test_package/python.cpp index 753aa189e779d..f10411c1a309b 100644 --- a/recipes/boost/all/test_package/python.cpp +++ b/recipes/boost/all/test_package/python.cpp @@ -1,5 +1,9 @@ #include +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + char const* greet() { return "hello, world!!!!!"; diff --git a/recipes/boost/all/test_package/random.cpp b/recipes/boost/all/test_package/random.cpp index c00a15c076c36..c78d082b8d033 100644 --- a/recipes/boost/all/test_package/random.cpp +++ b/recipes/boost/all/test_package/random.cpp @@ -4,6 +4,10 @@ #include #include +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + int main() { std::string chars( "abcdefghijklmnopqrstuvwxyz" diff --git a/recipes/boost/all/test_package/regex.cpp b/recipes/boost/all/test_package/regex.cpp index 93a5d66b4729a..416c10ba741c5 100644 --- a/recipes/boost/all/test_package/regex.cpp +++ b/recipes/boost/all/test_package/regex.cpp @@ -1,6 +1,10 @@ #include #include +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + int main(int argc, const char * const argv[]) { std::string line; diff --git a/recipes/boost/all/test_package/stacktrace.cpp b/recipes/boost/all/test_package/stacktrace.cpp index d58676489cb60..4ff17e101e644 100644 --- a/recipes/boost/all/test_package/stacktrace.cpp +++ b/recipes/boost/all/test_package/stacktrace.cpp @@ -2,6 +2,10 @@ #include +#if defined(BOOST_NAMESPACE) +namespace boost = BOOST_NAMESPACE; +#endif + void f3() { std::cout << "==start stacktrace==\n" << boost::stacktrace::stacktrace() << "==end stacktrace==\n"; } @@ -30,48 +34,96 @@ static const char *stacktrace_impls[] = { "windbg_cached", }; -int main() { - int res = 0; +bool check_used_defined() +{ + bool success = true; +#if TEST_STACKTRACE_IMPL == TEST_STACKTRACE_ADDR2LINE +# if !defined(BOOST_STACKTRACE_USE_ADDR2LINE) + std::cerr << "testing stacktrace_addr2line but BOOST_STACKTRACE_USE_ADDR2LINE not defined\n"; + success = false; +# endif +#endif +#if TEST_STACKTRACE_IMPL == TEST_STACKTRACE_BACKTRACE +# if !defined(BOOST_STACKTRACE_USE_BACKTRACE) + std::cerr << "testing stacktrace_backtrace but BOOST_STACKTRACE_USE_BACKTRACE not defined\n"; + success = false; +# endif +#endif +#if TEST_STACKTRACE_IMPL == TEST_STACKTRACE_NOOP +# if !defined(BOOST_STACKTRACE_USE_NOOP) + std::cerr << "testing stacktrace_noop but BOOST_STACKTRACE_USE_NOOP not defined\n"; + success = false; +# endif +#endif +#if TEST_STACKTRACE_IMPL == TEST_STACKTRACE_WINDBG +# if !defined(BOOST_STACKTRACE_USE_WINDBG) + std::cerr << "testing stacktrace_windbg but BOOST_STACKTRACE_USE_WINDBG not defined\n"; + success = false; +# endif +#endif +#if TEST_STACKTRACE_IMPL == TEST_STACKTRACE_WINDBG_CACHED +# if !defined(BOOST_STACKTRACE_USE_WINDBG_CACHED) + std::cerr << "testing stacktrace_windbg_cached but BOOST_STACKTRACE_USE_WINDBG_CACHED not defined\n"; + success = false; +# endif +#endif + return success; +} -#if !defined TEST_STACKTRACE_IMPL - std::cerr << "TEST_STACKTRACE_IMPL not defined!\n"; - res = 1; -#else - std::cerr << "Testing stacktrace_" << stacktrace_impls[TEST_STACKTRACE_IMPL-1] << "...\n"; +bool check_unused_undefined() +{ + bool success = true; # if defined(BOOST_STACKTRACE_USE_ADDR2LINE) # if TEST_STACKTRACE_IMPL != TEST_STACKTRACE_ADDR2LINE std::cerr << "BOOST_STACKTRACE_USE_ADDR2LINE defined but not testing stacktrace_addr2line\n"; - res = 1; + success = false; # endif # if !defined(BOOST_STACKTRACE_ADDR2LINE_LOCATION) std::cerr << "error: BOOST_STACKTRACE_ADDR2LINE_LOCATION not defined\n"; - res = 1; + success = false; # endif # endif # if defined(BOOST_STACKTRACE_USE_BACKTRACE) # if TEST_STACKTRACE_IMPL != TEST_STACKTRACE_BACKTRACE std::cerr << "BOOST_STACKTRACE_USE_BACKTRACE defined but not testing stacktrace_backtrace\n"; - res = 1; + success = false; # endif # endif # if defined(BOOST_STACKTRACE_USE_NOOP) # if TEST_STACKTRACE_IMPL != TEST_STACKTRACE_NOOP std::cerr << "BOOST_STACKTRACE_USE_NOOP defined but not testing stacktrace_noop\n"; - res = 1; + success = false; # endif # endif # if defined(BOOST_STACKTRACE_USE_WINDBG) # if TEST_STACKTRACE_IMPL != TEST_STACKTRACE_WINDBG std::cerr << "BOOST_STACKTRACE_USE_WINDBG defined but not testing stacktrace_windbg\n"; - res = 1; + success = false; # endif # endif # if defined(BOOST_STACKTRACE_USE_WINDBG_CACHED) # if TEST_STACKTRACE_IMPL != TEST_STACKTRACE_WINDBG_CACHED std::cerr << "BOOST_STACKTRACE_USE_WINDBG_CACHED defined but not testing stacktrace_windbg_cached\n"; - res = 1; + success = false; # endif # endif + return success; +} + +int main() { + int res = 0; + +#if !defined TEST_STACKTRACE_IMPL + std::cerr << "TEST_STACKTRACE_IMPL not defined!\n"; + res = 1; +#else + std::cerr << "Testing stacktrace_" << stacktrace_impls[TEST_STACKTRACE_IMPL-1] << "...\n"; + if (!check_unused_undefined()) { + res = 1; + } + if (!check_used_defined()) { + res = 1; + } #endif f1(); return res; diff --git a/recipes/boost/config.yml b/recipes/boost/config.yml index 50573110c2370..c2b37ebeaa9db 100644 --- a/recipes/boost/config.yml +++ b/recipes/boost/config.yml @@ -1,17 +1,23 @@ versions: - 1.69.0: - folder: all 1.70.0: - folder: all + folder: all 1.71.0: - folder: all + folder: all 1.72.0: - folder: all + folder: all 1.73.0: - folder: all + folder: all 1.74.0: - folder: all + folder: all 1.75.0: - folder: all + folder: all 1.76.0: - folder: all + folder: all + 1.77.0: + folder: all + 1.78.0: + folder: all + 1.79.0: + folder: all + 1.80.0: + folder: all diff --git a/recipes/botan/all/conandata.yml b/recipes/botan/all/conandata.yml index f8fc7cf1b8d4e..b4fd5502f1bd3 100644 --- a/recipes/botan/all/conandata.yml +++ b/recipes/botan/all/conandata.yml @@ -29,6 +29,21 @@ sources: "2.18.0": url: "https://github.com/randombit/botan/archive/2.18.0.tar.gz" sha256: "8556991402f9ecf5f84f1f2c4de20ca3fd14a5ebd775f065ea6676b36646a77d" + "2.18.1": + url: "https://github.com/randombit/botan/archive/2.18.1.tar.gz" + sha256: "4afebf2dbfa2f047d161437dcc544003d5822f47ceac97ada6a24948297bd3ed" + "2.18.2": + url: "https://github.com/randombit/botan/archive/2.18.2.tar.gz" + sha256: "10ded69c4fd4ade9d87527b394787beefa190b4ecb65ed04535bdd00e088cd96" + "2.19.1": + url: "https://github.com/randombit/botan/archive/2.19.1.tar.gz" + sha256: "eb5eaac0d8bf1dcf64b7ae39736d928fca8be1b24c27787873106e41a6c36725" + "2.19.2": + url: "https://github.com/randombit/botan/archive/2.19.2.tar.gz" + sha256: "47bb0330255cf1a439db3f2bc91894b2f41788e58eb71d27e0abf36038d93f1e" + "2.19.3": + url: "https://github.com/randombit/botan/archive/2.19.3.tar.gz" + sha256: "8f568bf74c2e476d92ac8a1cfc2ba8407ec038fe9458bd0a11e7da827a9b8199" patches: "2.12.1": - patch_file: "patches/dll-dir.patch" @@ -38,3 +53,6 @@ patches: "2.17.2": - patch_file: "patches/vs2015-install-fix.patch" base_path: "sources" + "2.18.2": + - patch_file: "patches/fix-amalgamation-build.patch" + base_path: "sources" diff --git a/recipes/botan/all/conanfile.py b/recipes/botan/all/conanfile.py index ff3a9602fb5d4..e8599f32dde75 100644 --- a/recipes/botan/all/conanfile.py +++ b/recipes/botan/all/conanfile.py @@ -1,71 +1,76 @@ -import os +from conan.tools.microsoft import is_msvc, msvc_runtime_flag from conans import ConanFile, tools from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.45.0" class BotanConan(ConanFile): - name = 'botan' + name = "botan" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/randombit/botan" license = "BSD-2-Clause" - exports = ["patches/*"] description = "Botan is a cryptography library written in C++11." topics = ("cryptography", "crypto", "C++11", "tls") - settings = 'os', 'arch', 'compiler', 'build_type' + + settings = "os", "arch", "compiler", "build_type" options = { - 'amalgamation': [True, False], - 'with_bzip2': [True, False], - 'with_openssl': [True, False], - 'shared': [True, False], - 'fPIC': [True, False], - 'single_amalgamation': [True, False], - 'with_sqlite3': [True, False], - 'with_zlib': [True, False], - 'with_boost': [True, False], - 'with_sse2': [True, False], - 'with_ssse3': [True, False], - 'with_sse4_1': [True, False], - 'with_sse4_2': [True, False], - 'with_avx2': [True, False], - 'with_bmi2': [True, False], - 'with_rdrand': [True, False], - 'with_rdseed': [True, False], - 'with_aes_ni': [True, False], - 'with_sha_ni': [True, False], - 'with_altivec': [True, False], - 'with_neon': [True, False], - 'with_armv8crypto': [True, False], - 'with_powercrypto': [True, False], - 'enable_modules': 'ANY', - 'system_cert_bundle': 'ANY', - 'module_policy': [None, 'bsi', 'modern', 'nist'] + "shared": [True, False], + "fPIC": [True, False], + "amalgamation": [True, False], + "with_bzip2": [True, False], + "with_openssl": [True, False], + "single_amalgamation": [True, False], + "with_sqlite3": [True, False], + "with_zlib": [True, False], + "with_boost": [True, False], + "with_sse2": [True, False], + "with_ssse3": [True, False], + "with_sse4_1": [True, False], + "with_sse4_2": [True, False], + "with_avx2": [True, False], + "with_bmi2": [True, False], + "with_rdrand": [True, False], + "with_rdseed": [True, False], + "with_aes_ni": [True, False], + "with_sha_ni": [True, False], + "with_altivec": [True, False], + "with_neon": [True, False], + "with_armv8crypto": [True, False], + "with_powercrypto": [True, False], + "enable_modules": "ANY", + "system_cert_bundle": "ANY", + "module_policy": [None, "bsi", "modern", "nist"], + } + default_options = { + "shared": False, + "fPIC": True, + "amalgamation": True, + "with_bzip2": False, + "with_openssl": False, + "single_amalgamation": False, + "with_sqlite3": False, + "with_zlib": False, + "with_boost": False, + "with_sse2": True, + "with_ssse3": True, + "with_sse4_1": True, + "with_sse4_2": True, + "with_avx2": True, + "with_bmi2": True, + "with_rdrand": True, + "with_rdseed": True, + "with_aes_ni": True, + "with_sha_ni": True, + "with_altivec": True, + "with_neon": True, + "with_armv8crypto": True, + "with_powercrypto": True, + "enable_modules": None, + "system_cert_bundle": None, + "module_policy": None, } - default_options = {'amalgamation': True, - 'with_bzip2': False, - 'with_openssl': False, - 'shared': False, - 'fPIC': True, - 'single_amalgamation': False, - 'with_sqlite3': False, - 'with_zlib': False, - 'with_boost': False, - 'with_sse2': True, - 'with_ssse3': True, - 'with_sse4_1': True, - 'with_sse4_2': True, - 'with_avx2': True, - 'with_bmi2': True, - 'with_rdrand': True, - 'with_rdseed': True, - 'with_aes_ni': True, - 'with_sha_ni': True, - 'with_altivec': True, - 'with_neon': True, - 'with_armv8crypto': True, - 'with_powercrypto': True, - 'enable_modules': None, - 'system_cert_bundle': None, - 'module_policy': None} @property def _is_x86(self): @@ -79,7 +84,14 @@ def _is_ppc(self): def _is_arm(self): return 'arm' in str(self.settings.arch) - _source_subfolder = 'sources' # Required to build at least 2.12.1 + @property + def _source_subfolder(self): + # Required to build at least 2.12.1 + return "sources" + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == 'Windows': @@ -112,8 +124,17 @@ def configure(self): if self.options.shared: del self.options.fPIC - if self.options.get_safe('single_amalgamation'): - self.options.amalgamation = True + def requirements(self): + if self.options.with_bzip2: + self.requires("bzip2/1.0.8") + if self.options.with_openssl: + self.requires("openssl/1.1.1o") + if self.options.with_zlib: + self.requires("zlib/1.2.12") + if self.options.with_sqlite3: + self.requires("sqlite3/3.38.5") + if self.options.with_boost: + self.requires("boost/1.79.0") @property def _required_boost_components(self): @@ -149,17 +170,8 @@ def validate(self): raise ConanInvalidConfiguration( 'botan amalgamation is not supported for {}/{}'.format(compiler, version)) - def requirements(self): - if self.options.with_bzip2: - self.requires('bzip2/1.0.8') - if self.options.with_openssl: - self.requires('openssl/1.1.1k') - if self.options.with_zlib: - self.requires('zlib/1.2.11') - if self.options.with_sqlite3: - self.requires('sqlite3/3.35.5') - if self.options.with_boost: - self.requires('boost/1.76.0') + if self.options.get_safe("single_amalgamation", False) and not self.options.amalgamation: + raise ConanInvalidConfiguration("botan:single_amalgamation=True requires botan:amalgamation=True") def source(self): tools.get(**self.conan_data['sources'][self.version], strip_root=True, destination=self._source_subfolder) @@ -177,7 +189,10 @@ def package(self): self.run(self._make_install_cmd) def package_info(self): - self.cpp_info.libs = ['botan' if self.settings.compiler == 'Visual Studio' else 'botan-2'] + major_version = tools.Version(self.version).major + self.cpp_info.set_property("pkg_config_name", f"botan-{major_version}") + self.cpp_info.names["pkg_config"] = f"botan-{major_version}" + self.cpp_info.libs = ["botan" if is_msvc(self) else f"botan-{major_version}"] if self.settings.os == 'Linux': self.cpp_info.system_libs.extend(['dl', 'rt', 'pthread']) if self.settings.os == 'Macos': @@ -185,7 +200,7 @@ def package_info(self): if self.settings.os == 'Windows': self.cpp_info.system_libs.extend(['ws2_32', 'crypt32']) - self.cpp_info.includedirs = [os.path.join('include', 'botan-2')] + self.cpp_info.includedirs = [os.path.join("include", f"botan-{major_version}")] @property def _is_mingw_windows(self): @@ -199,6 +214,7 @@ def _botan_os(self): 'Linux': 'linux', 'Macos': 'darwin', 'Android': 'linux', + 'baremetal': 'none', 'iOS': 'ios'}.get(str(self.settings.os)) def _dependency_build_flags(self, dependency): @@ -226,12 +242,20 @@ def _configure_cmd(self): if self._is_linux_clang_libcxx: botan_abi_flags.extend(['-stdlib=libc++', '-lc++abi']) - if botan_compiler in ['clang', 'apple-clang', 'gcc']: + if self.settings.compiler in ['clang', 'apple-clang', 'gcc']: if self.settings.arch == 'x86': botan_abi_flags.append('-m32') elif self.settings.arch == 'x86_64': botan_abi_flags.append('-m64') + if self.settings.compiler in ['apple-clang']: + if self.settings.arch in ['armv7']: + botan_abi_flags.append('-arch armv7') + elif self.settings.arch in ['armv8']: + botan_abi_flags.append('-arch arm64') + elif self.settings.arch in ['x86_64']: + botan_abi_flags.append('-arch x86_64') + if self.options.get_safe('fPIC', True): botan_extra_cxx_flags.append('-fPIC') @@ -348,8 +372,8 @@ def _configure_cmd(self): if self._is_mingw_windows: build_flags.append('--without-stack-protector') - if self.settings.compiler == 'Visual Studio': - build_flags.append('--msvc-runtime=%s' % str(self.settings.compiler.runtime)) + if is_msvc(self): + build_flags.append(f"--msvc-runtime={msvc_runtime_flag(self)}") build_flags.append('--without-pkg-config') @@ -385,7 +409,7 @@ def _configure_cmd(self): @property def _make_cmd(self): - return self._nmake_cmd if self.settings.compiler == 'Visual Studio' else self._gnumake_cmd + return self._nmake_cmd if is_msvc(self) else self._gnumake_cmd @property def _make_program(self): @@ -407,7 +431,7 @@ def _nmake_cmd(self): @property def _make_install_cmd(self): - if self.settings.compiler == 'Visual Studio': + if is_msvc(self): vcvars = tools.vcvars_command(self.settings) make_install_cmd = vcvars + ' && nmake install' else: diff --git a/recipes/botan/all/patches/fix-amalgamation-build.patch b/recipes/botan/all/patches/fix-amalgamation-build.patch new file mode 100644 index 0000000000000..4654ba32c6140 --- /dev/null +++ b/recipes/botan/all/patches/fix-amalgamation-build.patch @@ -0,0 +1,22 @@ +diff --git a/src/lib/hash/sha3/sha3_bmi2/sha3_bmi2.cpp b/src/lib/hash/sha3/sha3_bmi2/sha3_bmi2.cpp +index c7f1914a3..620b83eaa 100644 +--- a/src/lib/hash/sha3/sha3_bmi2/sha3_bmi2.cpp ++++ b/src/lib/hash/sha3/sha3_bmi2/sha3_bmi2.cpp +@@ -28,7 +28,7 @@ namespace { + #endif + + BOTAN_WORKAROUND_MAYBE_INLINE std::tuple +- xor_CNs(const uint64_t A[25]) ++ xor_CNs_BMI2(const uint64_t A[25]) + { + return { + A[0] ^ A[5] ^ A[10] ^ A[15] ^ A[20], +@@ -42,7 +42,7 @@ BOTAN_WORKAROUND_MAYBE_INLINE std::tuple(std::get<0>(Cs)) ^ std::get<3>(Cs); + const uint64_t D1 = rotl<1>(std::get<1>(Cs)) ^ std::get<4>(Cs); diff --git a/recipes/botan/all/test_package/CMakeLists.txt b/recipes/botan/all/test_package/CMakeLists.txt index 5865328af0543..5021b4e27691a 100644 --- a/recipes/botan/all/test_package/CMakeLists.txt +++ b/recipes/botan/all/test_package/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -file(GLOB SOURCE_FILES *.cpp) +find_package(botan REQUIRED CONFIG) -add_executable(${PROJECT_NAME} ${SOURCE_FILES}) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} botan::botan) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/botan/all/test_package/conanfile.py b/recipes/botan/all/test_package/conanfile.py index be0a94674e5bd..f4b0754b85efb 100644 --- a/recipes/botan/all/test_package/conanfile.py +++ b/recipes/botan/all/test_package/conanfile.py @@ -1,10 +1,10 @@ +from conans import ConanFile, CMake, tools import os -from conans import ConanFile, CMake class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,5 +12,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not tools.cross_building(self, skip_x64_x86=True): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/botan/all/test_package/test_package.cpp b/recipes/botan/all/test_package/test_package.cpp index c7d7c4d0d671b..d8ace17201cc0 100644 --- a/recipes/botan/all/test_package/test_package.cpp +++ b/recipes/botan/all/test_package/test_package.cpp @@ -2,5 +2,6 @@ int main() { - std::vector key = Botan::hex_decode("000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); + std::vector key = Botan::hex_decode("000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); + return 0; } diff --git a/recipes/botan/config.yml b/recipes/botan/config.yml index 5935f66a652c0..7fdc77ee53c3b 100644 --- a/recipes/botan/config.yml +++ b/recipes/botan/config.yml @@ -19,3 +19,13 @@ versions: folder: all "2.18.0": folder: all + "2.18.1": + folder: all + "2.18.2": + folder: all + "2.19.1": + folder: all + "2.19.2": + folder: all + "2.19.3": + folder: all diff --git a/recipes/box2d/2.4.x/conandata.yml b/recipes/box2d/2.4.x/conandata.yml index 3e9aef1571a09..c7372e2a8f037 100644 --- a/recipes/box2d/2.4.x/conandata.yml +++ b/recipes/box2d/2.4.x/conandata.yml @@ -7,5 +7,4 @@ sources: sha256: "d6b4650ff897ee1ead27cf77a5933ea197cbeef6705638dd181adc2e816b23c2" patches: "2.4.0": - - patch_file: "patches/install-and-allow-shared.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-install-and-allow-shared.patch" diff --git a/recipes/box2d/2.4.x/conanfile.py b/recipes/box2d/2.4.x/conanfile.py index 0a37f41d13d33..ae09ce435deda 100644 --- a/recipes/box2d/2.4.x/conanfile.py +++ b/recipes/box2d/2.4.x/conanfile.py @@ -1,7 +1,10 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, rm, rmdir, copy +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.scm import Version -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.52.0" class Box2dConan(ConanFile): @@ -16,55 +19,53 @@ class Box2dConan(ConanFile): "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True,} - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass def configure(self): if self.options.shared: - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("box2d-%s" % self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BOX2D_BUILD_TESTBED"] = False - self._cmake.definitions["BOX2D_BUILD_UNIT_TESTS"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.variables["BOX2D_BUILD_TESTBED"] = False + tc.variables["BOX2D_BUILD_UNIT_TESTS"] = False + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.configure() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.pdb") + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rm(self, "*.pdb", self.package_folder, recursive=True) def package_info(self): self.cpp_info.names["cmake_find_package"] = "box2d" self.cpp_info.names["cmake_find_package_multi"] = "box2d" self.cpp_info.libs = ["box2d"] - if tools.Version(self.version) >= "2.4.1" and self.options.shared: + if Version(self.version) >= "2.4.1" and self.options.shared: self.cpp_info.defines.append("B2_SHARED") diff --git a/recipes/box2d/2.4.x/patches/install-and-allow-shared.patch b/recipes/box2d/2.4.x/patches/0001-install-and-allow-shared.patch similarity index 100% rename from recipes/box2d/2.4.x/patches/install-and-allow-shared.patch rename to recipes/box2d/2.4.x/patches/0001-install-and-allow-shared.patch diff --git a/recipes/box2d/2.4.x/test_package/CMakeLists.txt b/recipes/box2d/2.4.x/test_package/CMakeLists.txt index 373fb5bb61846..fb4d8d7f5888a 100644 --- a/recipes/box2d/2.4.x/test_package/CMakeLists.txt +++ b/recipes/box2d/2.4.x/test_package/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.1) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - find_package(box2d REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) diff --git a/recipes/box2d/2.4.x/test_package/conanfile.py b/recipes/box2d/2.4.x/test_package/conanfile.py index 7513484720425..d1ce1a2cbc477 100644 --- a/recipes/box2d/2.4.x/test_package/conanfile.py +++ b/recipes/box2d/2.4.x/test_package/conanfile.py @@ -1,10 +1,19 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout class Box2DTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/box2d/2.4.x/test_v1_package/CMakeLists.txt b/recipes/box2d/2.4.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..373fb5bb61846 --- /dev/null +++ b/recipes/box2d/2.4.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(box2d REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} box2d::box2d) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/box2d/2.4.x/test_v1_package/conanfile.py b/recipes/box2d/2.4.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..7513484720425 --- /dev/null +++ b/recipes/box2d/2.4.x/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class Box2DTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/box2d/2.4.x/test_v1_package/test_package.cpp b/recipes/box2d/2.4.x/test_v1_package/test_package.cpp new file mode 100644 index 0000000000000..7dfa813bc1d2e --- /dev/null +++ b/recipes/box2d/2.4.x/test_v1_package/test_package.cpp @@ -0,0 +1,16 @@ +#include +#include "box2d/box2d.h" + +int main(void) { + b2Vec2 gravity(0.0f, -10.0f); + b2World world(gravity); + + b2BodyDef groundBodyDef; + groundBodyDef.position.Set(0.0f, -10.0f); + + b2Body* groundBody = world.CreateBody(&groundBodyDef); + b2PolygonShape groundBox; + groundBox.SetAsBox(50.0f, 10.0f); + + return 0; +} diff --git a/recipes/box2d/all/CMakeLists.txt b/recipes/box2d/all/CMakeLists.txt deleted file mode 100644 index c4d4346e42ef9..0000000000000 --- a/recipes/box2d/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("sources/Box2D") diff --git a/recipes/box2d/all/conanfile.py b/recipes/box2d/all/conanfile.py index f3b5e66b01950..e5adde1f2b06a 100644 --- a/recipes/box2d/all/conanfile.py +++ b/recipes/box2d/all/conanfile.py @@ -1,5 +1,8 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile, tools +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout + +required_conan_version = ">=1.46.0" class Box2dConan(ConanFile): @@ -13,43 +16,53 @@ class Box2dConan(ConanFile): options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True,} - generators = "cmake" - exports_sources = "CMakeLists.txt" - - @property - def _source_subfolder(self): - return "sources" def config_options(self): if self.settings.os == "Windows": - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass def configure(self): if self.options.shared: - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="Box2D") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("box2d-%s" % self.version, self._source_subfolder) + tools.files.get(self, + **self.conan_data["sources"][self.version], + strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BOX2D_BUILD_SHARED"] = self.options.shared + tc.variables["BOX2D_BUILD_STATIC"] = not self.options.shared + if self.settings.os == "Windows" and self.options.shared: + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.variables["BOX2D_BUILD_EXAMPLES"] = False + tc.generate() def build(self): cmake = CMake(self) - cmake.definitions["BOX2D_BUILD_SHARED"] = self.options.shared - cmake.definitions["BOX2D_BUILD_STATIC"] = not self.options.shared - if self.settings.os == "Windows" and self.options.shared: - cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True - cmake.definitions["BOX2D_BUILD_EXAMPLES"] = False - cmake.configure() + cmake.configure(build_script_folder="Box2D") cmake.build() def package(self): - self.copy("License.txt", dst="licenses", src=os.path.join(self._source_subfolder, "Box2D")) - self.copy("*.h", dst=os.path.join("include", "Box2D"), src=os.path.join(self._source_subfolder, "Box2D", "Box2D")) - self.copy("*.lib", dst="lib", keep_path=False) - self.copy("*.dll", dst="bin", keep_path=False) - self.copy("*.so*", dst="lib", keep_path=False, symlinks=True) - self.copy("*.dylib", dst="lib", keep_path=False) - self.copy("*.a", dst="lib", keep_path=False) + tools.files.copy(self, "License.txt", src=os.path.join(self.source_folder, "Box2D"), dst=os.path.join(self.package_folder,"licenses")) + tools.files.copy(self, os.path.join("Box2D", "*.h"), src=os.path.join(self.source_folder, "Box2D"), dst=os.path.join(self.package_folder, "include")) + tools.files.copy(self, "*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + tools.files.copy(self, "*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False) + tools.files.copy(self, "*.so*", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + tools.files.copy(self, "*.dylib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + tools.files.copy(self, "*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) def package_info(self): self.cpp_info.libs = ["Box2D"] + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs = ["m"] diff --git a/recipes/box2d/all/test_package/CMakeLists.txt b/recipes/box2d/all/test_package/CMakeLists.txt index 42c40193bf4a9..22c1118333f4f 100644 --- a/recipes/box2d/all/test_package/CMakeLists.txt +++ b/recipes/box2d/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.4) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(box2d) add_executable(test_package test_package.cpp) -target_link_libraries(test_package ${CONAN_LIBS}) +target_link_libraries(test_package box2d::box2d) diff --git a/recipes/box2d/all/test_package/conanfile.py b/recipes/box2d/all/test_package/conanfile.py index 133228fb54665..a3a0294a68898 100644 --- a/recipes/box2d/all/test_package/conanfile.py +++ b/recipes/box2d/all/test_package/conanfile.py @@ -1,10 +1,17 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile, tools +from conan.tools.cmake import CMake, cmake_layout class Box2DTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +19,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not tools.build.cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/box2d/all/test_v1_package/CMakeLists.txt b/recipes/box2d/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..458981ad5eb24 --- /dev/null +++ b/recipes/box2d/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.4) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(test_package ../test_package/test_package.cpp) +target_link_libraries(test_package ${CONAN_LIBS}) diff --git a/recipes/box2d/all/test_v1_package/conanfile.py b/recipes/box2d/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..133228fb54665 --- /dev/null +++ b/recipes/box2d/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class Box2DTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/box2d/config.yml b/recipes/box2d/config.yml index bdf14f8d236d5..1922ed59d887d 100644 --- a/recipes/box2d/config.yml +++ b/recipes/box2d/config.yml @@ -5,4 +5,3 @@ versions: folder: "2.4.x" "2.4.1": folder: "2.4.x" - diff --git a/recipes/breakpad/all/conandata.yml b/recipes/breakpad/all/conandata.yml new file mode 100644 index 0000000000000..ca1b1d96e427d --- /dev/null +++ b/recipes/breakpad/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "cci.20210521": + url: "https://github.com/google/breakpad/archive/f7428bc.tar.gz" + sha256: "55a688a49ffc476d94d92c3fd73f9264c974c25af8d6371c3901bd3451081e47" +patches: + "cci.20210521": + - patch_file: "patches/0001-Use_conans_lss.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-Remove-hardcoded-fpic.patch" + base_path: "source_subfolder" diff --git a/recipes/breakpad/all/conanfile.py b/recipes/breakpad/all/conanfile.py new file mode 100644 index 0000000000000..369681d6570ec --- /dev/null +++ b/recipes/breakpad/all/conanfile.py @@ -0,0 +1,77 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration +import os +import textwrap + +required_conan_version = ">=1.33.0" + +class BreakpadConan(ConanFile): + name = "breakpad" + description = "A set of client and server components which implement a crash-reporting system" + topics = ["crash", "report", "breakpad"] + license = "BSD-3-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://chromium.googlesource.com/breakpad/breakpad/" + settings = "os", "compiler", "build_type", "arch" + provides = "breakpad" + exports_sources = "patches/**" + options = { + "fPIC": [True, False] + } + default_options = { + "fPIC": True + } + _env_build = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("Breakpad can only be built on Linux. For other OSs check sentry-breakpad") + + def requirements(self): + self.requires("linux-syscall-support/cci.20200813") + + def _configure_autotools(self): + if not self._env_build: + self._env_build = AutoToolsBuildEnvironment(self) + self._env_build.configure(configure_dir=self._source_subfolder) + return self._env_build + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + env_build = self._configure_autotools() + env_build.make() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + env_build = self._configure_autotools() + env_build.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info( self ): + self.cpp_info.components["libbreakpad"].libs = ["breakpad"] + self.cpp_info.components["libbreakpad"].includedirs.append(os.path.join("include", "breakpad")) + self.cpp_info.components["libbreakpad"].names["pkg_config"] = "breakpad" + + self.cpp_info.components["client"].libs = ["breakpad_client"] + self.cpp_info.components["client"].includedirs.append(os.path.join("include", "breakpad")) + self.cpp_info.components["client"].names["pkg_config"] = "breakpad-client" + + + self.cpp_info.components["libbreakpad"].system_libs.append("pthread") + self.cpp_info.components["libbreakpad"].requires.append("linux-syscall-support::linux-syscall-support") + + self.cpp_info.components["client"].system_libs.append("pthread") + self.cpp_info.components["client"].requires.append("linux-syscall-support::linux-syscall-support") + + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) diff --git a/recipes/breakpad/all/patches/0001-Use_conans_lss.patch b/recipes/breakpad/all/patches/0001-Use_conans_lss.patch new file mode 100644 index 0000000000000..abe15dd4f2ace --- /dev/null +++ b/recipes/breakpad/all/patches/0001-Use_conans_lss.patch @@ -0,0 +1,258 @@ +diff --color -ur Makefile.in Makefile.in +--- Makefile.in 2021-05-21 15:56:41.000000000 -0300 ++++ Makefile.in 2021-05-27 18:57:23.986912433 -0300 +@@ -2082,7 +2082,7 @@ + HEADERS = $(includec_HEADERS) $(includecl_HEADERS) \ + $(includeclc_HEADERS) $(includecldwc_HEADERS) \ + $(includeclh_HEADERS) $(includeclm_HEADERS) \ +- $(includegbc_HEADERS) $(includelss_HEADERS) \ ++ $(includegbc_HEADERS) \ + $(includep_HEADERS) + am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) + # Read a list of newline-separated strings from the standard input, +@@ -9718,7 +9718,7 @@ + install-includeclHEADERS install-includeclcHEADERS \ + install-includecldwcHEADERS install-includeclhHEADERS \ + install-includeclmHEADERS install-includegbcHEADERS \ +- install-includelssHEADERS install-includepHEADERS \ ++ iinstall-includepHEADERS \ + install-pkgconfigDATA + + install-dvi: install-dvi-am +@@ -10084,7 +10084,7 @@ + install-includeclHEADERS install-includeclcHEADERS \ + install-includecldwcHEADERS install-includeclhHEADERS \ + install-includeclmHEADERS install-includegbcHEADERS \ +- install-includelssHEADERS install-includepHEADERS install-info \ ++ iinstall-includepHEADERS install-info \ + install-info-am install-libLIBRARIES install-libexecPROGRAMS \ + install-man install-pdf install-pdf-am install-pkgconfigDATA \ + install-ps install-ps-am install-strip installcheck \ +diff --color -ur src/client/linux/crash_generation/crash_generation_client.cc src/client/linux/crash_generation/crash_generation_client.cc +--- src/client/linux/crash_generation/crash_generation_client.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/crash_generation/crash_generation_client.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -37,7 +37,7 @@ + + #include "common/linux/eintr_wrapper.h" + #include "common/linux/ignore_ret.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + namespace google_breakpad { + +diff --color -ur src/client/linux/handler/exception_handler.cc src/client/linux/handler/exception_handler.cc +--- src/client/linux/handler/exception_handler.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/handler/exception_handler.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -95,7 +95,7 @@ + #include "client/linux/minidump_writer/linux_dumper.h" + #include "client/linux/minidump_writer/minidump_writer.h" + #include "common/linux/eintr_wrapper.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + #if defined(__ANDROID__) + #include "linux/sched.h" +diff --color -ur src/client/linux/handler/exception_handler_unittest.cc src/client/linux/handler/exception_handler_unittest.cc +--- src/client/linux/handler/exception_handler_unittest.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/handler/exception_handler_unittest.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -50,7 +50,7 @@ + #include "common/linux/linux_libc_support.h" + #include "common/tests/auto_tempdir.h" + #include "common/using_std_string.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + #include "google_breakpad/processor/minidump.h" + + using namespace google_breakpad; +diff --color -ur src/client/linux/log/log.cc src/client/linux/log/log.cc +--- src/client/linux/log/log.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/log/log.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -33,7 +33,7 @@ + #include + #include + #else +-#include "third_party/lss/linux_syscall_support.h" ++#include + #endif + + namespace logger { +diff --color -ur src/client/linux/minidump_writer/cpu_set.h src/client/linux/minidump_writer/cpu_set.h +--- src/client/linux/minidump_writer/cpu_set.h 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/minidump_writer/cpu_set.h 2021-05-27 18:57:23.990912414 -0300 +@@ -35,7 +35,7 @@ + #include + + #include "common/linux/linux_libc_support.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + namespace google_breakpad { + +diff --color -ur src/client/linux/minidump_writer/directory_reader.h src/client/linux/minidump_writer/directory_reader.h +--- src/client/linux/minidump_writer/directory_reader.h 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/minidump_writer/directory_reader.h 2021-05-27 18:57:23.990912414 -0300 +@@ -38,7 +38,7 @@ + #include + + #include "common/linux/linux_libc_support.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + namespace google_breakpad { + +diff --color -ur src/client/linux/minidump_writer/line_reader.h src/client/linux/minidump_writer/line_reader.h +--- src/client/linux/minidump_writer/line_reader.h 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/minidump_writer/line_reader.h 2021-05-27 18:57:23.990912414 -0300 +@@ -35,7 +35,7 @@ + #include + + #include "common/linux/linux_libc_support.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + namespace google_breakpad { + +diff --color -ur src/client/linux/minidump_writer/linux_dumper.cc src/client/linux/minidump_writer/linux_dumper.cc +--- src/client/linux/minidump_writer/linux_dumper.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/minidump_writer/linux_dumper.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -51,7 +51,7 @@ + #include "common/linux/memory_mapped_file.h" + #include "common/linux/safe_readlink.h" + #include "google_breakpad/common/minidump_exception_linux.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + #if defined(__ANDROID__) + +diff --color -ur src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc +--- src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -39,7 +39,7 @@ + #include + + #include "common/scoped_ptr.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + #if defined(__ARM_EABI__) + #define TID_PTR_REGISTER "r3" +diff --color -ur src/client/linux/minidump_writer/linux_ptrace_dumper.cc src/client/linux/minidump_writer/linux_ptrace_dumper.cc +--- src/client/linux/minidump_writer/linux_ptrace_dumper.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/minidump_writer/linux_ptrace_dumper.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -57,7 +57,7 @@ + #include "client/linux/minidump_writer/directory_reader.h" + #include "client/linux/minidump_writer/line_reader.h" + #include "common/linux/linux_libc_support.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + // Suspends a thread by attaching to it. + static bool SuspendThread(pid_t pid) { +diff --color -ur src/client/linux/minidump_writer/minidump_writer.cc src/client/linux/minidump_writer/minidump_writer.cc +--- src/client/linux/minidump_writer/minidump_writer.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/minidump_writer/minidump_writer.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -77,7 +77,7 @@ + #include "common/linux/linux_libc_support.h" + #include "common/minidump_type_helper.h" + #include "google_breakpad/common/minidump_format.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + namespace { + +diff --color -ur src/client/linux/minidump_writer/proc_cpuinfo_reader.h src/client/linux/minidump_writer/proc_cpuinfo_reader.h +--- src/client/linux/minidump_writer/proc_cpuinfo_reader.h 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/linux/minidump_writer/proc_cpuinfo_reader.h 2021-05-27 18:57:23.990912414 -0300 +@@ -36,7 +36,7 @@ + + #include "client/linux/minidump_writer/line_reader.h" + #include "common/linux/linux_libc_support.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + namespace google_breakpad { + +diff --color -ur src/client/minidump_file_writer.cc src/client/minidump_file_writer.cc +--- src/client/minidump_file_writer.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/client/minidump_file_writer.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -41,7 +41,7 @@ + #include "common/linux/linux_libc_support.h" + #include "common/string_conversion.h" + #if defined(__linux__) && __linux__ +-#include "third_party/lss/linux_syscall_support.h" ++#include + #endif + + #if defined(__ANDROID__) +diff --color -ur src/common/linux/file_id.cc src/common/linux/file_id.cc +--- src/common/linux/file_id.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/common/linux/file_id.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -46,7 +46,7 @@ + #include "common/linux/linux_libc_support.h" + #include "common/linux/memory_mapped_file.h" + #include "common/using_std_string.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + namespace google_breakpad { + +diff --color -ur src/common/linux/memory_mapped_file.cc src/common/linux/memory_mapped_file.cc +--- src/common/linux/memory_mapped_file.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/common/linux/memory_mapped_file.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -40,7 +40,7 @@ + #include + + #include "common/memory_range.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + namespace google_breakpad { + +diff --color -ur src/common/linux/safe_readlink.cc src/common/linux/safe_readlink.cc +--- src/common/linux/safe_readlink.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/common/linux/safe_readlink.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -32,7 +32,7 @@ + + #include + +-#include "third_party/lss/linux_syscall_support.h" ++#include + + namespace google_breakpad { + +diff --color -ur src/common/memory_allocator.h src/common/memory_allocator.h +--- src/common/memory_allocator.h 2021-05-21 15:56:41.000000000 -0300 ++++ src/common/memory_allocator.h 2021-05-27 18:57:23.990912414 -0300 +@@ -47,7 +47,7 @@ + #define sys_munmap munmap + #define MAP_ANONYMOUS MAP_ANON + #else +-#include "third_party/lss/linux_syscall_support.h" ++#include + #endif + + namespace google_breakpad { +diff --color -ur src/processor/testdata/linux_test_app.cc src/processor/testdata/linux_test_app.cc +--- src/processor/testdata/linux_test_app.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/processor/testdata/linux_test_app.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -46,7 +46,7 @@ + #include + + #include "client/linux/handler/exception_handler.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + + namespace { + +diff --color -ur src/tools/linux/md2core/minidump-2-core.cc src/tools/linux/md2core/minidump-2-core.cc +--- src/tools/linux/md2core/minidump-2-core.cc 2021-05-21 15:56:41.000000000 -0300 ++++ src/tools/linux/md2core/minidump-2-core.cc 2021-05-27 18:57:23.990912414 -0300 +@@ -52,7 +52,7 @@ + #include "common/using_std_string.h" + #include "google_breakpad/common/breakpad_types.h" + #include "google_breakpad/common/minidump_format.h" +-#include "third_party/lss/linux_syscall_support.h" ++#include + #include "tools/linux/md2core/minidump_memory_range.h" + + #if ULONG_MAX == 0xffffffffffffffff diff --git a/recipes/breakpad/all/patches/0002-Remove-hardcoded-fpic.patch b/recipes/breakpad/all/patches/0002-Remove-hardcoded-fpic.patch new file mode 100644 index 0000000000000..e0ca688e693a5 --- /dev/null +++ b/recipes/breakpad/all/patches/0002-Remove-hardcoded-fpic.patch @@ -0,0 +1,13 @@ +diff --color -ur a/Makefile.in b/Makefile.in +--- Makefile.in 2021-05-21 15:56:41.000000000 -0300 ++++ Makefile.in 2021-05-27 19:01:06.857704652 -0300 +@@ -130,8 +130,7 @@ + @ANDROID_HOST_TRUE@ -I$(top_srcdir)/src/common/android/testing/include + + # Build as PIC on Linux, for linux_client_unittest_shlib +-@LINUX_HOST_TRUE@am__append_2 = -fPIC +-@LINUX_HOST_TRUE@am__append_3 = -fPIC ++ + libexec_PROGRAMS = $(am__EXEEXT_10) + bin_PROGRAMS = $(am__EXEEXT_2) $(am__EXEEXT_3) $(am__EXEEXT_4) + check_PROGRAMS = $(am__EXEEXT_5) $(am__EXEEXT_6) $(am__EXEEXT_7) \ diff --git a/recipes/breakpad/all/test_package/CMakeLists.txt b/recipes/breakpad/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..97c267052c49a --- /dev/null +++ b/recipes/breakpad/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/breakpad/all/test_package/conanfile.py b/recipes/breakpad/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a04d0f33ab7ca --- /dev/null +++ b/recipes/breakpad/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class BreakpadTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/breakpad/all/test_package/test_package.cpp b/recipes/breakpad/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..83fc0946bdb6c --- /dev/null +++ b/recipes/breakpad/all/test_package/test_package.cpp @@ -0,0 +1,35 @@ +#include "client/linux/handler/exception_handler.h" + +#include + +using namespace google_breakpad; + +namespace { + +bool callback(const MinidumpDescriptor &descriptor, + void *context, + bool succeeded) { + // if succeeded is true, descriptor.path() contains a path + // to the minidump file. Context is the context passed to + // the exception handler's constructor. + return succeeded; +} + +} + +int main(int argc, char *argv[]) { + std::cout << "Breakpad test_package\n"; + + MinidumpDescriptor descriptor("path/to/cache"); + ExceptionHandler eh( + descriptor, + /* filter */ nullptr, + callback, + /* context */ nullptr, + /* install handler */ true, + /* server FD */ -1 + ); + + // run your program here + return 0; +} diff --git a/recipes/breakpad/config.yml b/recipes/breakpad/config.yml new file mode 100644 index 0000000000000..f9fbb96c7dd28 --- /dev/null +++ b/recipes/breakpad/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210521": + folder: all diff --git a/recipes/brigand/all/conandata.yml b/recipes/brigand/all/conandata.yml index a0d9557501e79..9a62d14168e32 100644 --- a/recipes/brigand/all/conandata.yml +++ b/recipes/brigand/all/conandata.yml @@ -1,4 +1,4 @@ sources: "cpp11-1.3.0": - url: https://github.com/edouarda/brigand/archive/refs/tags/cpp11-1.3.0.tar.gz - sha256: 33c8fc780d2f2c9c0d21cbea909429ae9a64765496f66f6ab2f1e978502aa295 + url: "https://github.com/edouarda/brigand/archive/refs/tags/cpp11-1.3.0.tar.gz" + sha256: "33c8fc780d2f2c9c0d21cbea909429ae9a64765496f66f6ab2f1e978502aa295" diff --git a/recipes/brigand/all/conanfile.py b/recipes/brigand/all/conanfile.py index 7975d98b3dc53..d205988b4830f 100644 --- a/recipes/brigand/all/conanfile.py +++ b/recipes/brigand/all/conanfile.py @@ -1,9 +1,10 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools - - -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.50.0" class BrigandConan(ConanFile): @@ -13,29 +14,51 @@ class BrigandConan(ConanFile): topics = ("meta-programming", "boost", "runtime", "header-only") homepage = "https://github.com/edouarda/brigand" license = "BSL-1.0" - settings = "compiler" - requires = "boost/1.75.0" - no_copy_sources = True - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "with_boost": [True, False], + } + default_options = { + "with_boost": True, + } + + no_copy_source = True + + def requirements(self): + if self.options.with_boost: + # TODO: add transitive_headers=True & bump required_conan_version to >=1.52.0 + self.requires("boost/1.79.0") + + def package_id(self): + self.info.clear() def validate(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) include_path = os.path.join("include", "brigand") - self.copy("*.hpp", dst=include_path, src=os.path.join(self._source_subfolder, include_path)) - - def package_id(self): - self.info.header_only() + copy(self, "*.hpp", src=os.path.join(self.source_folder, include_path), dst=os.path.join(self.package_folder, include_path)) def package_info(self): - self.cpp_info.names["pkg_config"] = "libbrigand" + self.cpp_info.set_property("pkg_config_name", "libbrigand") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + if self.options.with_boost: + self.cpp_info.requires = ["boost::headers"] + else: + self.cpp_info.defines.append("BRIGAND_NO_BOOST_SUPPORT") diff --git a/recipes/brigand/all/test_package/CMakeLists.txt b/recipes/brigand/all/test_package/CMakeLists.txt index 8e185891d822d..edca2f720d504 100644 --- a/recipes/brigand/all/test_package/CMakeLists.txt +++ b/recipes/brigand/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(brigand REQUIRED) +find_package(brigand REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} brigand::brigand) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE brigand::brigand) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/brigand/all/test_package/conanfile.py b/recipes/brigand/all/test_package/conanfile.py index 55bf6d0ec4634..d120a992c06a6 100644 --- a/recipes/brigand/all/test_package/conanfile.py +++ b/recipes/brigand/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi", "pkg_config" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/brigand/all/test_v1_package/CMakeLists.txt b/recipes/brigand/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..c08f269548f6a --- /dev/null +++ b/recipes/brigand/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(brigand REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE brigand::brigand) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/brigand/all/test_v1_package/conanfile.py b/recipes/brigand/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/brigand/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/brotli/all/conandata.yml b/recipes/brotli/all/conandata.yml index 0d65de76c2337..c664dae35678e 100644 --- a/recipes/brotli/all/conandata.yml +++ b/recipes/brotli/all/conandata.yml @@ -7,8 +7,6 @@ sources: sha256: 4c61bfb0faca87219ea587326c467b95acb25555b53d1a421ffa3c8a9296ee2c patches: "1.0.9": - - base_path: "source_subfolder" - patch_file: "patches/0002-target-props.patch" + - patch_file: "patches/0002-target-props.patch" "1.0.7": - - base_path: "source_subfolder" - patch_file: "patches/0001-target-props.patch" + - patch_file: "patches/0001-target-props.patch" diff --git a/recipes/brotli/all/conanfile.py b/recipes/brotli/all/conanfile.py index dc9619836520c..1f7e57755d1f4 100644 --- a/recipes/brotli/all/conanfile.py +++ b/recipes/brotli/all/conanfile.py @@ -1,35 +1,44 @@ -from conans import CMake, ConanFile, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir import os +required_conan_version = ">=1.50.0" + class BrotliConan(ConanFile): name = "brotli" description = "Brotli compression format" - topics = ("conan", "brotli", "compression") + topics = ("brotli", "compression") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/google/brotli" license = "MIT", - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake", + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], + "target_bits": [64, 32, None], + "endianness": ["big", "little", "neutral", None], + "enable_portable": [True, False], + "enable_rbit": [True, False], + "enable_debug": [True, False], + "enable_log": [True, False], } default_options = { "shared": False, "fPIC": True, + "target_bits": None, + "endianness": None, + "enable_portable": False, + "enable_rbit": True, + "enable_debug": False, + "enable_log": False, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -38,58 +47,89 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "brotli-{}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BROTLI_BUNDLED_MODE"] = False - self._cmake.definitions["BROTLI_DISABLE_TESTS"] = True - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BROTLI_BUNDLED_MODE"] = False + tc.variables["BROTLI_DISABLE_TESTS"] = True + if self.options.get_safe("target_bits") == 32: + tc.preprocessor_definitions["BROTLI_BUILD_32_BIT"] = 1 + elif self.options.get_safe("target_bits") == 64: + tc.preprocessor_definitions["BROTLI_BUILD_64_BIT"] = 1 + if self.options.get_safe("endianness") == "big": + tc.preprocessor_definitions["BROTLI_BUILD_BIG_ENDIAN"] = 1 + elif self.options.get_safe("endianness") == "neutral": + tc.preprocessor_definitions["BROTLI_BUILD_ENDIAN_NEUTRAL"] = 1 + elif self.options.get_safe("endianness") == "little": + tc.preprocessor_definitions["BROTLI_BUILD_LITTLE_ENDIAN"] = 1 + if self.options.enable_portable: + tc.preprocessor_definitions["BROTLI_BUILD_PORTABLE"] = 1 + if not self.options.enable_rbit: + tc.preprocessor_definitions["BROTLI_BUILD_NO_RBIT"] = 1 + if self.options.enable_debug: + tc.preprocessor_definitions["BROTLI_DEBUG"] = 1 + if self.options.enable_log: + tc.preprocessor_definitions["BROTLI_ENABLE_LOG"] = 1 + # To install relocatable shared libs on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "Brotli" - self.cpp_info.names["cmake_find_package_multi"] = "Brotli" includedir = os.path.join("include", "brotli") # brotlicommon - self.cpp_info.components["brotlicommon"].names["pkg_config"] = "libbrotlicommon" + self.cpp_info.components["brotlicommon"].set_property("pkg_config_name", "libbrotlicommon") self.cpp_info.components["brotlicommon"].includedirs.append(includedir) self.cpp_info.components["brotlicommon"].libs = [self._get_decorated_lib("brotlicommon")] if self.settings.os == "Windows" and self.options.shared: self.cpp_info.components["brotlicommon"].defines.append("BROTLI_SHARED_COMPILATION") # brotlidec - self.cpp_info.components["brotlidec"].names["pkg_config"] = "libbrotlidec" + self.cpp_info.components["brotlidec"].set_property("pkg_config_name", "libbrotlidec") self.cpp_info.components["brotlidec"].includedirs.append(includedir) self.cpp_info.components["brotlidec"].libs = [self._get_decorated_lib("brotlidec")] self.cpp_info.components["brotlidec"].requires = ["brotlicommon"] # brotlienc - self.cpp_info.components["brotlienc"].names["pkg_config"] = "libbrotlienc" + self.cpp_info.components["brotlienc"].set_property("pkg_config_name", "libbrotlienc") self.cpp_info.components["brotlienc"].includedirs.append(includedir) self.cpp_info.components["brotlienc"].libs = [self._get_decorated_lib("brotlienc")] self.cpp_info.components["brotlienc"].requires = ["brotlicommon"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["brotlienc"].system_libs = ["m"] + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed. + # do not set this target in CMakeDeps, it was a mistake, there is no official brotil config file, nor Find module file + self.cpp_info.names["cmake_find_package"] = "Brotli" + self.cpp_info.names["cmake_find_package_multi"] = "Brotli" + self.cpp_info.components["brotlicommon"].names["pkg_config"] = "libbrotlicommon" + self.cpp_info.components["brotlidec"].names["pkg_config"] = "libbrotlidec" + self.cpp_info.components["brotlienc"].names["pkg_config"] = "libbrotlienc" + def _get_decorated_lib(self, name): libname = name if not self.options.shared: diff --git a/recipes/brotli/all/patches/0002-target-props.patch b/recipes/brotli/all/patches/0002-target-props.patch index 1edbdd0a83968..3647649bb1e14 100644 --- a/recipes/brotli/all/patches/0002-target-props.patch +++ b/recipes/brotli/all/patches/0002-target-props.patch @@ -1,6 +1,6 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -183,6 +183,16 @@ foreach(lib IN LISTS BROTLI_SHARED_LIBS) +@@ -183,6 +183,16 @@ set_target_properties (${lib} PROPERTIES DEFINE_SYMBOL "${LIB}_SHARED_COMPILATION") endforeach() @@ -17,7 +17,7 @@ foreach(lib IN LISTS BROTLI_SHARED_LIBS BROTLI_STATIC_LIBS) target_link_libraries(${lib} ${LIBM_LIBRARY}) set_property(TARGET ${lib} APPEND PROPERTY INCLUDE_DIRECTORIES ${BROTLI_INCLUDE_DIRS}) -@@ -190,7 +200,6 @@ foreach(lib IN LISTS BROTLI_SHARED_LIBS BROTLI_STATIC_LIBS) +@@ -190,7 +200,6 @@ VERSION "${BROTLI_ABI_COMPATIBILITY}.${BROTLI_ABI_AGE}.${BROTLI_ABI_REVISION}" SOVERSION "${BROTLI_ABI_COMPATIBILITY}") if(NOT BROTLI_EMSCRIPTEN) @@ -25,14 +25,14 @@ endif() set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIRS}") endforeach() -@@ -217,15 +226,13 @@ endif() +@@ -217,15 +226,12 @@ # Build the brotli executable add_executable(brotli ${BROTLI_CLI_C}) target_link_libraries(brotli ${BROTLI_LIBRARIES_STATIC}) +set_target_properties(brotli PROPERTIES EXCLUDE_FROM_ALL ON EXCLUDE_FROM_DEFAULT ON) # Installation - if(NOT BROTLI_EMSCRIPTEN) +-if(NOT BROTLI_EMSCRIPTEN) if(NOT BROTLI_BUNDLED_MODE) - install( - TARGETS brotli @@ -43,7 +43,7 @@ install( TARGETS ${BROTLI_LIBRARIES_CORE} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" -@@ -233,12 +240,14 @@ if(NOT BROTLI_BUNDLED_MODE) +@@ -233,19 +239,20 @@ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) @@ -58,3 +58,10 @@ install( DIRECTORY ${BROTLI_INCLUDE_DIRS}/brotli + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + ) + endif() # BROTLI_BUNDLED_MODE +-endif() # BROTLI_EMSCRIPTEN + + # Tests + diff --git a/recipes/brotli/all/test_package/CMakeLists.txt b/recipes/brotli/all/test_package/CMakeLists.txt index 196188113685c..8339b11b6d1f4 100644 --- a/recipes/brotli/all/test_package/CMakeLists.txt +++ b/recipes/brotli/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(brotli REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE brotli::brotli) diff --git a/recipes/brotli/all/test_package/conanfile.py b/recipes/brotli/all/test_package/conanfile.py index bd7165a553cf4..3a8c6c5442b33 100644 --- a/recipes/brotli/all/test_package/conanfile.py +++ b/recipes/brotli/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/brotli/all/test_v1_package/CMakeLists.txt b/recipes/brotli/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..c67747eec972a --- /dev/null +++ b/recipes/brotli/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Brotli REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Brotli::Brotli) diff --git a/recipes/brotli/all/test_v1_package/conanfile.py b/recipes/brotli/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/brotli/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/brynet/all/conandata.yml b/recipes/brynet/all/conandata.yml new file mode 100644 index 0000000000000..9c73dc59d6547 --- /dev/null +++ b/recipes/brynet/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.11.1": + url: "https://github.com/IronsDu/brynet/archive/v1.11.1.tar.gz" + sha256: "780f7e1be5e16a202b75661178209a9dd572d07d548a7f30e9bcc7f4a768c61d" + "1.11.0": + url: "https://github.com/IronsDu/brynet/archive/refs/tags/v1.11.0.tar.gz" + sha256: "e446c5616a5353f6d29510d30eaa852c69bda9aecd1f74b8cc9c6ae8f1fd6485" diff --git a/recipes/brynet/all/conanfile.py b/recipes/brynet/all/conanfile.py new file mode 100644 index 0000000000000..f19ddf2cfae85 --- /dev/null +++ b/recipes/brynet/all/conanfile.py @@ -0,0 +1,61 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.52.0" + + +class BrynetConan(ConanFile): + name = "brynet" + description = "Header Only Cross platform high performance TCP network library using C++ 11." + license = "MIT" + topics = ("networking", "tcp", "websocket") + homepage = "https://github.com/IronsDu/brynet" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "with_openssl": [True, False], + } + default_options = { + "with_openssl": True, + } + + no_copy_source = True + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_openssl: + self.requires("openssl/1.1.1q", transitive_headers=True, transitive_libs=True) + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + if self.options.with_openssl: + self.cpp_info.defines.append("BRYNET_USE_OPENSSL") + if self.settings.os == "Windows": + self.cpp_info.system_libs.append("ws2_32") + elif self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/brynet/all/test_package/CMakeLists.txt b/recipes/brynet/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d7b3556ccaf55 --- /dev/null +++ b/recipes/brynet/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(brynet REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE brynet::brynet) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/brynet/all/test_package/conanfile.py b/recipes/brynet/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/brynet/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/brynet/all/test_package/test_package.cpp b/recipes/brynet/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..54ae2df3641ce --- /dev/null +++ b/recipes/brynet/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + auto service = brynet::net::TcpService::Create(); + return 0; +} diff --git a/recipes/brynet/all/test_v1_package/CMakeLists.txt b/recipes/brynet/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d6bc29a53890 --- /dev/null +++ b/recipes/brynet/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(brynet REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE brynet::brynet) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/brynet/all/test_v1_package/conanfile.py b/recipes/brynet/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/brynet/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/brynet/config.yml b/recipes/brynet/config.yml new file mode 100644 index 0000000000000..95c35b8102625 --- /dev/null +++ b/recipes/brynet/config.yml @@ -0,0 +1,5 @@ +versions: + "1.11.1": + folder: all + "1.11.0": + folder: all diff --git a/recipes/bshoshany-thread-pool/all/conandata.yml b/recipes/bshoshany-thread-pool/all/conandata.yml new file mode 100644 index 0000000000000..7dac950c38bc0 --- /dev/null +++ b/recipes/bshoshany-thread-pool/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "3.3.0": + sha256: "b76c0103c7ed07c137bd5b1988b9c09da280bbbad37588a096d2954c8d996e0f" + url: "https://github.com/bshoshany/thread-pool/archive/refs/tags/v3.3.0.tar.gz" + "3.2.0": + sha256: "0604e5978fb65d5b27868892c931902cdd320ca6d623b555141060a715394453" + url: "https://github.com/bshoshany/thread-pool/archive/refs/tags/v3.2.0.tar.gz" + "3.1.0": + sha256: "c8b70ee63822ee21f25c201806e464100686b1faca5aeabeee96378d2a2c3be8" + url: "https://github.com/bshoshany/thread-pool/archive/refs/tags/v3.1.0.tar.gz" + "3.0.0": + sha256: "c36052b28b4f28698a6d6f3ad988d7979f6bf6823ebf2af2074714fde15dc19c" + url: "https://github.com/bshoshany/thread-pool/archive/refs/tags/v3.0.0.tar.gz" diff --git a/recipes/bshoshany-thread-pool/all/conanfile.py b/recipes/bshoshany-thread-pool/all/conanfile.py new file mode 100644 index 0000000000000..ee5a622fcbc1c --- /dev/null +++ b/recipes/bshoshany-thread-pool/all/conanfile.py @@ -0,0 +1,56 @@ +import os +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.43.0" + + +class BShoshanyThreadPoolConan(ConanFile): + description = "BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library" + homepage = "https://github.com/bshoshany/thread-pool" + license = "MIT" + name = "bshoshany-thread-pool" + no_copy_source = True + settings = "arch", "build_type", "compiler", "os" + topics = ("concurrency", "cpp17", "header-only", "library", "multi-threading", "parallel-computing", "thread-pool", "threads") + url = "https://github.com/conan-io/conan-center-index" + + @property + def _minimum_compilers_version(self): + return {"apple-clang": "10", "clang": "5", "gcc": "8", "Visual Studio": "16"} + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _source_subfolder(self): + return "source_subfolder" + + def package(self): + copy(self, "*.hpp", self.source_folder, os.path.join(self.package_folder, "include")) + copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) + + def package_id(self): + self.info.clear() + + def package_info(self): + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["pthread"] + self.cpp_info.names["cmake_find_package"] = "bshoshany-thread-pool" + self.cpp_info.names["cmake_find_package_multi"] = "bshoshany-thread-pool" + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + try: + if Version(self.settings.compiler.version) < self._minimum_compilers_version[str(self.settings.compiler)]: + raise ConanInvalidConfiguration(f"{self.name} requires a compiler that supports C++{self._minimum_cpp_standard}. {self.settings.compiler}, {self.settings.compiler.version}") + except KeyError: + self.output.warn("Unknown compiler encountered. Assuming it supports C++17.") diff --git a/recipes/bshoshany-thread-pool/all/test_package/CMakeLists.txt b/recipes/bshoshany-thread-pool/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e58c83ea5f16f --- /dev/null +++ b/recipes/bshoshany-thread-pool/all/test_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bshoshany-thread-pool REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} bshoshany-thread-pool::bshoshany-thread-pool) diff --git a/recipes/bshoshany-thread-pool/all/test_package/conanfile.py b/recipes/bshoshany-thread-pool/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d52de022aa2ac --- /dev/null +++ b/recipes/bshoshany-thread-pool/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "arch", "build_type", "compiler", "os" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bshoshany-thread-pool/all/test_package/test_package.cpp b/recipes/bshoshany-thread-pool/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..bbde93d5eba55 --- /dev/null +++ b/recipes/bshoshany-thread-pool/all/test_package/test_package.cpp @@ -0,0 +1,59 @@ +#include "BS_thread_pool.hpp" + +BS::synced_stream sync_out; +BS::thread_pool pool; + +std::condition_variable ID_cv, total_cv; +std::mutex ID_mutex, total_mutex; +BS::concurrency_t count_unique_threads() +{ + const BS::concurrency_t num_tasks = pool.get_thread_count() * 2; + std::vector thread_IDs(num_tasks); + std::unique_lock total_lock(total_mutex); + BS::concurrency_t total_count = 0; + bool ID_release = false; + pool.wait_for_tasks(); + for (std::thread::id& id : thread_IDs) + pool.push_task( + [&total_count, &id, &ID_release] + { + id = std::this_thread::get_id(); + { + const std::scoped_lock total_lock_local(total_mutex); + ++total_count; + } + total_cv.notify_one(); + std::unique_lock ID_lock_local(ID_mutex); + ID_cv.wait(ID_lock_local, [&ID_release] { return ID_release; }); + }); + total_cv.wait(total_lock, [&total_count] { return total_count == pool.get_thread_count(); }); + { + const std::scoped_lock ID_lock(ID_mutex); + ID_release = true; + } + ID_cv.notify_all(); + total_cv.wait(total_lock, [&total_count, &num_tasks] { return total_count == num_tasks; }); + pool.wait_for_tasks(); + std::sort(thread_IDs.begin(), thread_IDs.end()); + return static_cast(std::unique(thread_IDs.begin(), thread_IDs.end()) - thread_IDs.begin()); +} + +int main() +{ + const char* line = "------------------------------------------"; + sync_out.println(line); + sync_out.println("Testing thread pool..."); + BS::concurrency_t unique_threads = count_unique_threads(); + if (pool.get_thread_count() == unique_threads) + { + sync_out.println("SUCCESS: Created ", unique_threads, " unique threads!"); + sync_out.println(line); + return EXIT_SUCCESS; + } + else + { + sync_out.println("ERROR: Failed to create ", unique_threads, " unique threads!"); + sync_out.println(line); + return EXIT_FAILURE; + } +} diff --git a/recipes/bshoshany-thread-pool/config.yml b/recipes/bshoshany-thread-pool/config.yml new file mode 100644 index 0000000000000..319c05acee4d0 --- /dev/null +++ b/recipes/bshoshany-thread-pool/config.yml @@ -0,0 +1,9 @@ +versions: + "3.3.0": + folder: all + "3.2.0": + folder: all + "3.1.0": + folder: all + "3.0.0": + folder: all diff --git a/recipes/btyacc/all/CMakeLists.txt b/recipes/btyacc/all/CMakeLists.txt new file mode 100644 index 0000000000000..b598faf845d1a --- /dev/null +++ b/recipes/btyacc/all/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.2) + +project(btyacc_wrapper C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/btyacc/all/conandata.yml b/recipes/btyacc/all/conandata.yml new file mode 100644 index 0000000000000..f0142fff4add4 --- /dev/null +++ b/recipes/btyacc/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.0": + sha256: "ce89b9121895aa29e9fd609f23eb8e0727912745a4d41aa7ad42984ef83f05c7" + url: https://github.com/ChrisDodd/btyacc/archive/0256b69f36f01877f1f4e76f80a5f561beabcfef.zip diff --git a/recipes/btyacc/all/conanfile.py b/recipes/btyacc/all/conanfile.py new file mode 100644 index 0000000000000..392605b08cf53 --- /dev/null +++ b/recipes/btyacc/all/conanfile.py @@ -0,0 +1,80 @@ +import functools +import os +import textwrap + +from conans import CMake, ConanFile, tools + +required_conan_version = ">=1.43.0" + + +class BtyaccConan(ConanFile): + name = "btyacc" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/ChrisDodd/btyacc" + description = "Backtracking yacc" + topics = "yacc", "parser" + license = "Unlicense" + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + } + default_options = { + "fPIC": True, + } + generators = "cmake" + exports_sources = "CMakeLists.txt" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + root = self._source_subfolder + get_args = self.conan_data["sources"][self.version] + tools.get(**get_args, destination=root, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure() + return cmake + + def build(self): + self._configure_cmake().build() + + @property + def _variables(self): + return os.path.join("bin", "conan-official-btyacc-variables.cmake") + + def package(self): + self.copy("README", "licenses", self._source_subfolder) + self.copy("README.BYACC", "licenses", self._source_subfolder) + self._configure_cmake().install() + tools.rmdir(os.path.join(self.package_folder, "share")) + variables = os.path.join(self.package_folder, self._variables) + content = textwrap.dedent("""\ + set(BTYACC_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/btyacc") + if(NOT EXISTS "${BTYACC_EXECUTABLE}") + set(BTYACC_EXECUTABLE "${BTYACC_EXECUTABLE}.exe") + endif() + """) + tools.save(variables, content) + + def package_info(self): + bindir = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH environment variable: {bindir}") + self.env_info.PATH.append(bindir) + self.cpp_info.build_modules["cmake"] = [self._variables] + self.cpp_info.build_modules["cmake_find_package"] = [self._variables] + self.cpp_info.build_modules["cmake_find_package_multi"] = \ + [self._variables] + self.cpp_info.builddirs = ["bin"] diff --git a/recipes/btyacc/all/test_package/CMakeLists.txt b/recipes/btyacc/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..80f7ff14861ac --- /dev/null +++ b/recipes/btyacc/all/test_package/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.1) + +project(test_package C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS KEEP_RPATHS) + +find_package(btyacc REQUIRED CONFIG) +if(NOT DEFINED BTYACC_EXECUTABLE) + message(FATAL_ERROR "BTYACC_EXECUTABLE is not defined") +endif() + +set(bin "${PROJECT_BINARY_DIR}") +add_custom_command( + OUTPUT main.c + COMMAND "${BTYACC_EXECUTABLE}" -b y "${PROJECT_SOURCE_DIR}/test.y" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${bin}/y.tab.c" "${bin}/main.c" + COMMAND "${CMAKE_COMMAND}" -E remove "${bin}/y.tab.c" + MAIN_DEPENDENCY test.y + WORKING_DIRECTORY "${bin}" + COMMENT "Generating main.c" + VERBATIM +) + +add_executable(test_package "${bin}/main.c") + +enable_testing() +add_test( + NAME main + COMMAND "${CMAKE_COMMAND}" -E echo "(())()(())" | test_package +) diff --git a/recipes/btyacc/all/test_package/conanfile.py b/recipes/btyacc/all/test_package/conanfile.py new file mode 100644 index 0000000000000..84bba6ad911d3 --- /dev/null +++ b/recipes/btyacc/all/test_package/conanfile.py @@ -0,0 +1,23 @@ +import functools +import os + +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure() + return cmake + + def build(self): + if not tools.cross_building(self): + self._configure_cmake().build() + + def test(self): + if not tools.cross_building(self): + self._configure_cmake().test() diff --git a/recipes/btyacc/all/test_package/test.y b/recipes/btyacc/all/test_package/test.y new file mode 100644 index 0000000000000..57215a5ad5dde --- /dev/null +++ b/recipes/btyacc/all/test_package/test.y @@ -0,0 +1,43 @@ +%{ +/* first section */ +%} +/* + * [test] btyacc + * [test] cc + * [test] input (())()(()) + * [test] input-fail (())(*)(()) + * [test] btyacc -DABC + * [test] cc + * [test] input (())(*)(()) + */ +%% +%{ +/* second section */ +%} +S : /* empty */ { printf("S -> epsilon\n"); } + | '(' S ')' S { printf("S -> ( S ) S\n"); } +%ifdef ABC + /* see how preprocessor can be used */ + | '*' { printf("S -> *\n"); } +%endif + ; +%% +#include + +int main() { + int rv; + printf("yyparse() = %d\n", (rv=yyparse())); + return rv; +} + +yylex() { + int ch; + + do { ch = getchar(); } while (ch == ' ' || ch == '\n' || ch == '\t'); + if (ch == EOF) return 0; + return ch; +} + +void yyerror(const char *s, ...) { + printf("%s\n",s); +} diff --git a/recipes/btyacc/config.yml b/recipes/btyacc/config.yml new file mode 100644 index 0000000000000..fdd08f532337f --- /dev/null +++ b/recipes/btyacc/config.yml @@ -0,0 +1,3 @@ +versions: + "3.0": + folder: all diff --git a/recipes/bullet3/all/CMakeLists.txt b/recipes/bullet3/all/CMakeLists.txt deleted file mode 100644 index 474ce09871371..0000000000000 --- a/recipes/bullet3/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/bullet3/all/conandata.yml b/recipes/bullet3/all/conandata.yml index 12b598dc02ebf..ec81e3ffa2344 100644 --- a/recipes/bullet3/all/conandata.yml +++ b/recipes/bullet3/all/conandata.yml @@ -1,19 +1,28 @@ sources: - "2.89": - url: "https://github.com/bulletphysics/bullet3/archive/2.89.tar.gz" - sha256: "621b36e91c0371933f3c2156db22c083383164881d2a6b84636759dc4cbb0bb8" - "3.06": - url: "https://github.com/bulletphysics/bullet3/archive/3.06.tar.gz" - sha256: "217c1d198ee00be7e40d4cb4d79882e37ef4a06cbfbe11f5fbc207c347a57020" - "3.07": - url: "https://github.com/bulletphysics/bullet3/archive/3.07.tar.gz" - sha256: "068ecf8acbf256d3976eebee75d7d6f5af16c049f10f6b2d8ba28bb638bef3b0" - "3.08": - url: "https://github.com/bulletphysics/bullet3/archive/3.08.tar.gz" - sha256: "05826c104b842bcdd1339b86894cb44c84ac2525ac296689d34b38a14bbba0dd" - "3.09": - url: "https://github.com/bulletphysics/bullet3/archive/3.09.tar.gz" - sha256: "f2feef9322329c0571d9066fede2db0ede92b19f7f7fdf54def3b4651f02af03" + "3.24": + url: "https://github.com/bulletphysics/bullet3/archive/refs/tags/3.24.tar.gz" + sha256: "6b1e987d6f8156fa8a6468652f4eaad17b3e11252c9870359e5bca693e35780b" + "3.22a": + url: "https://github.com/bulletphysics/bullet3/archive/refs/tags/3.22a.tar.gz" + sha256: "c40a0e832751c1590474cf21679972d2938e0705a45c29fed846ddb523d82b03" + "3.21": + url: "https://github.com/bulletphysics/bullet3/archive/3.21.tar.gz" + sha256: "49d1ee47aa8cbb0bc6bb459f0a4cfb9579b40e28f5c7d9a36c313e3031fb3965" "3.17": url: "https://github.com/bulletphysics/bullet3/archive/3.17.tar.gz" sha256: "baa642c906576d4d98d041d0acb80d85dd6eff6e3c16a009b1abf1ccd2bc0a61" + "3.09": + url: "https://github.com/bulletphysics/bullet3/archive/3.09.tar.gz" + sha256: "f2feef9322329c0571d9066fede2db0ede92b19f7f7fdf54def3b4651f02af03" + "3.08": + url: "https://github.com/bulletphysics/bullet3/archive/3.08.tar.gz" + sha256: "05826c104b842bcdd1339b86894cb44c84ac2525ac296689d34b38a14bbba0dd" + "3.07": + url: "https://github.com/bulletphysics/bullet3/archive/3.07.tar.gz" + sha256: "068ecf8acbf256d3976eebee75d7d6f5af16c049f10f6b2d8ba28bb638bef3b0" + "3.06": + url: "https://github.com/bulletphysics/bullet3/archive/3.06.tar.gz" + sha256: "217c1d198ee00be7e40d4cb4d79882e37ef4a06cbfbe11f5fbc207c347a57020" + "2.89": + url: "https://github.com/bulletphysics/bullet3/archive/2.89.tar.gz" + sha256: "621b36e91c0371933f3c2156db22c083383164881d2a6b84636759dc4cbb0bb8" diff --git a/recipes/bullet3/all/conanfile.py b/recipes/bullet3/all/conanfile.py index 6fcbb5346bebe..56400df5625cf 100644 --- a/recipes/bullet3/all/conanfile.py +++ b/recipes/bullet3/all/conanfile.py @@ -1,17 +1,27 @@ -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir, save +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version +import glob import os +import textwrap + +required_conan_version = ">=1.50.0" class Bullet3Conan(ConanFile): name = "bullet3" - description = "Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc." + description = ( + "Bullet Physics SDK: real-time collision detection and multi-physics " + "simulation for VR, games, visual effects, robotics, machine learning etc." + ) homepage = "https://github.com/bulletphysics/bullet3" - topics = "conan", "bullet", "physics", "simulation", "robotics", "kinematics", "engine", + topics = ("bullet", "physics", "simulation", "robotics", "kinematics", "engine") license = "ZLIB" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "CMakeLists.txt" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -22,22 +32,21 @@ class Bullet3Conan(ConanFile): "bt2_thread_locks": [True, False], "soft_body_multi_body_dynamics_world": [True, False], "network_support": [True, False], - "extras": [True, False] + "extras": [True, False], } default_options = { "shared": False, "fPIC": True, - "bullet3": False, + "bullet3": True, "graphical_benchmark": False, "double_precision": False, "bt2_thread_locks": False, "soft_body_multi_body_dynamics_world": False, "network_support": False, - "extras": False + "extras": False, } - _source_subfolder = "source_subfolder" - _cmake = None + short_paths = True def config_options(self): if self.settings.os == "Windows": @@ -46,83 +55,146 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler == "Visual Studio" and self.options.shared: + + def validate(self): + if is_msvc(self) and self.info.options.shared: raise ConanInvalidConfiguration("Shared libraries on Visual Studio not supported") + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("bullet3-{}".format(self.version), self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_BULLET3"] = self.options.bullet3 - self._cmake.definitions["INSTALL_LIBS"] = True - self._cmake.definitions["USE_GRAPHICAL_BENCHMARK"] = self.options.graphical_benchmark - self._cmake.definitions["USE_DOUBLE_PRECISION"] = self.options.double_precision - self._cmake.definitions["BULLET2_USE_THREAD_LOCKS"] = self.options.bt2_thread_locks - self._cmake.definitions["USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD"] = self.options.soft_body_multi_body_dynamics_world - self._cmake.definitions["BUILD_ENET"] = self.options.network_support - self._cmake.definitions["BUILD_CLSOCKET"] = self.options.network_support - self._cmake.definitions["BUILD_CPU_DEMOS"] = False - self._cmake.definitions["BUILD_OPENGL3_DEMOS"] = False - self._cmake.definitions["BUILD_BULLET2_DEMOS"] = False - self._cmake.definitions["BUILD_EXTRAS"] = self.options.extras - self._cmake.definitions["BUILD_UNIT_TESTS"] = False - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["USE_MSVC_RUNTIME_LIBRARY_DLL"] = "MD" in self.settings.compiler.runtime - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_BULLET3"] = self.options.bullet3 + tc.variables["INSTALL_LIBS"] = True + tc.variables["USE_GRAPHICAL_BENCHMARK"] = self.options.graphical_benchmark + tc.variables["USE_DOUBLE_PRECISION"] = self.options.double_precision + tc.variables["BULLET2_MULTITHREADING"] = self.options.bt2_thread_locks + tc.variables["USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD"] = self.options.soft_body_multi_body_dynamics_world + tc.variables["BUILD_ENET"] = self.options.network_support + tc.variables["BUILD_CLSOCKET"] = self.options.network_support + tc.variables["BUILD_CPU_DEMOS"] = False + tc.variables["BUILD_OPENGL3_DEMOS"] = False + tc.variables["BUILD_BULLET2_DEMOS"] = False + tc.variables["BUILD_EXTRAS"] = self.options.extras + tc.variables["BUILD_UNIT_TESTS"] = False + if is_msvc(self): + tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + if Version(self.version) < "3.21": + # silence warning + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0115"] = "OLD" + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy("LICENSE.txt", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + for cmake_file in glob.glob(os.path.join(self.package_folder, self._module_subfolder, "*.cmake")): + if os.path.basename(cmake_file) != "UseBullet.cmake": + os.remove(cmake_file) + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path) + ) + + def _create_cmake_module_variables(self, module_file): + content = textwrap.dedent(f"""\ + set(BULLET_FOUND 1) + set(BULLET_USE_FILE "lib/cmake/bullet/UseBullet.cmake") + set(BULLET_DEFINITIONS {" ".join(self._bullet_definitions)}) + set(BULLET_INCLUDE_DIR ${{Bullet_INCLUDE_DIR}} + ${{Bullet_INCLUDE_DIR_RELEASE}} + ${{Bullet_INCLUDE_DIR_RELWITHDEBINFO}} + ${{Bullet_INCLUDE_DIR_MINSIZEREL}} + ${{Bullet_INCLUDE_DIR_DEBUG}}) + set(BULLET_INCLUDE_DIRS ${{BULLET_INCLUDE_DIR}}) + set(BULLET_LIBRARIES Bullet::Bullet) + set(BULLET_LIBRARY_DIRS ${{Bullet_LIB_DIRS}} + ${{Bullet_LIB_DIRS_RELEASE}} + ${{Bullet_LIB_DIRS_RELWITHDEBINFO}} + ${{Bullet_LIB_DIRS_MINSIZEREL}} + ${{Bullet_LIB_DIRS_DEBUG}}) + set(BULLET_ROOT_DIR "${{CMAKE_CURRENT_LIST_DIR}}/../../..") + set(BULLET_VERSION_STRING {self.version}) + """) + save(self, module_file, content) + + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake", "bullet") + + @property + def _module_file_rel_path(self): + return os.path.join(self._module_subfolder, + f"conan-official-{self.name}-variables.cmake") + + @property + def _bullet_definitions(self): + defines = [] + if self.options.double_precision: + defines.append("BT_USE_DOUBLE_PRECISION") + return defines def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "Bullet") + self.cpp_info.set_property("cmake_target_name", "Bullet::Bullet") # not official + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) + self.cpp_info.set_property("pkg_config_name", "bullet") libs = [] if self.options.bullet3: - libs += [ - "Bullet2FileLoader", - "Bullet3Collision", - "Bullet3Dynamics", + libs.extend([ + "Bullet3OpenCL_clew", # depends on LinearMath Bullet3Dynamics (and libdl on Linux) + "Bullet3Dynamics", # depends on Bullet3Collision + "Bullet3Collision", # depends on Bullet3Geometry "Bullet3Geometry", - "Bullet3OpenCL_clew", - ] - libs += [ - "BulletDynamics", - "BulletCollision", + "Bullet2FileLoader", # depends on Bullet3Common + ]) + if self.options.extras: + libs.extend([ + "BulletRobotics", # depends on BulletInverseDynamicsUtils BulletWorldImporter BulletFileLoader BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamics LinearMath Bullet3Common + "BulletInverseDynamicsUtils", # depends on BulletInverseDynamics BulletDynamics BulletCollision Bullet3Common LinearMath + "BulletXmlWorldImporter", # depends on BulletWorldImporter BulletDynamics BulletCollision BulletFileLoader LinearMath + "BulletWorldImporter", # depends on BulletDynamics BulletCollision BulletFileLoader LinearMath + "BulletFileLoader", # depends on LinearMath + "GIMPACTUtils", # depends on ConvexDecomposition BulletCollision + "ConvexDecomposition", # depends on BulletCollision LinearMath + "HACD", + ]) + libs.extend([ + "BulletSoftBody", # depends on BulletDynamics + "BulletDynamics", # depends on BulletCollision & LinearMath + "BulletCollision", # depends on LinearMath + "BulletInverseDynamics", # depends on Bullet3Common & LinearMath "LinearMath", - "BulletSoftBody", "Bullet3Common", - "BulletInverseDynamics", - ] - if self.options.extras: - libs += [ "BulletInverseDynamicsUtils", - "BulletRobotics", - "BulletFileLoader", - "BulletXmlWorldImporter", - "BulletWorldImporter", - "ConvexDecomposition", - "HACD", - "GIMPACTUtils" - ] + ]) if self.settings.os == "Windows" and self.settings.build_type in ("Debug", "MinSizeRel", "RelWithDebInfo"): - libs = [lib + "_{}".format(self.settings.build_type) for lib in libs] + lib_suffix = "RelWithDebugInfo" if self.settings.build_type == "RelWithDebInfo" else self.settings.build_type + libs = [lib + "_{}".format(lib_suffix) for lib in libs] - self.cpp_info.names["cmake_find_package"] = "Bullet" - self.cpp_info.names["cmake_find_package_multi"] = "Bullet" - self.cpp_info.names["pkg_config"] = "bullet" self.cpp_info.libs = libs self.cpp_info.includedirs = ["include", os.path.join("include", "bullet")] if self.options.extras: self.cpp_info.includedirs.append(os.path.join("include", "bullet_robotics")) - if self.options.double_precision: - self.cpp_info.defines.append("BT_USE_DOUBLE_PRECISION") + self.cpp_info.defines = self._bullet_definitions + if self.options.bt2_thread_locks and self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "Bullet" + self.cpp_info.names["cmake_find_package_multi"] = "Bullet" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.names["pkg_config"] = "bullet" diff --git a/recipes/bullet3/all/test_package/CMakeLists.txt b/recipes/bullet3/all/test_package/CMakeLists.txt index 196188113685c..35fb321995112 100644 --- a/recipes/bullet3/all/test_package/CMakeLists.txt +++ b/recipes/bullet3/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(Bullet REQUIRED CONFIG) +include(${BULLET_ROOT_DIR}/${BULLET_USE_FILE}) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} ${BULLET_LIBRARIES}) diff --git a/recipes/bullet3/all/test_package/conanfile.py b/recipes/bullet3/all/test_package/conanfile.py index bd7165a553cf4..3a8c6c5442b33 100644 --- a/recipes/bullet3/all/test_package/conanfile.py +++ b/recipes/bullet3/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bullet3/all/test_v1_package/CMakeLists.txt b/recipes/bullet3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2be76b63171a5 --- /dev/null +++ b/recipes/bullet3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Bullet REQUIRED CONFIG) +include(${BULLET_ROOT_DIR}/${BULLET_USE_FILE}) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${BULLET_LIBRARIES}) diff --git a/recipes/bullet3/all/test_v1_package/conanfile.py b/recipes/bullet3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/bullet3/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bullet3/config.yml b/recipes/bullet3/config.yml index f75edd1cbe3a1..0250c44853be5 100644 --- a/recipes/bullet3/config.yml +++ b/recipes/bullet3/config.yml @@ -1,13 +1,19 @@ versions: - "2.89": + "3.24": folder: all - "3.06": + "3.22a": folder: all - "3.07": + "3.21": folder: all - "3.08": + "3.17": folder: all "3.09": folder: all - "3.17": + "3.08": + folder: all + "3.07": + folder: all + "3.06": + folder: all + "2.89": folder: all diff --git a/recipes/butteraugli/all/CMakeLists.txt b/recipes/butteraugli/all/CMakeLists.txt index f8e874acb1d64..d92428ae1ee9a 100644 --- a/recipes/butteraugli/all/CMakeLists.txt +++ b/recipes/butteraugli/all/CMakeLists.txt @@ -1,31 +1,31 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) +cmake_minimum_required(VERSION 3.8) +project(butteraugli LANGUAGES CXX) -include(conanbuildinfo.cmake) -conan_basic_setup() +option(BUTTERAUGLI_TOOL "Build comparison tool" ON) -if(WIN32 AND BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif(WIN32 AND BUILD_SHARED_LIBS) +add_library(butteraugli_lib ${BUTTERAUGLI_SRC_DIR}/butteraugli/butteraugli.cc) +target_include_directories(butteraugli_lib PUBLIC ${BUTTERAUGLI_SRC_DIR}) +set_target_properties(butteraugli_lib PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) +target_compile_features(butteraugli_lib PUBLIC cxx_std_11) -set(butteraugli_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) - -set(SRCS_FILES ${butteraugli_DIR}/butteraugli/butteraugli.cc) -set(HDRS_FILES ${butteraugli_DIR}/butteraugli/butteraugli.h) -add_library(butteraugli_lib ${SRCS_FILES} ${HDRS_FILES}) -target_include_directories(butteraugli_lib PUBLIC ${butteraugli_DIR}) -set_property(TARGET butteraugli_lib PROPERTY CXX_STANDARD 11) - -find_package(JPEG REQUIRED) -find_package(PNG REQUIRED) - -add_library(butteraugli ${butteraugli_DIR}/butteraugli/butteraugli_main.cc) -target_link_libraries(butteraugli butteraugli_lib ${JPEG_LIBRARIES} ${PNG_LIBRARIES}) -set_property(TARGET butteraugli PROPERTY CXX_STANDARD 11) - -install(TARGETS butteraugli butteraugli_lib +install( + TARGETS butteraugli_lib RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -install(FILES ${HDRS_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/butteraugli) +install( + FILES ${BUTTERAUGLI_SRC_DIR}/butteraugli/butteraugli.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/butteraugli +) + +if(BUTTERAUGLI_TOOL) + find_package(JPEG REQUIRED) + find_package(PNG REQUIRED) + + add_executable(butteraugli ${BUTTERAUGLI_SRC_DIR}/butteraugli/butteraugli_main.cc) + target_link_libraries(butteraugli PRIVATE butteraugli_lib JPEG::JPEG PNG::PNG) + target_compile_features(butteraugli PRIVATE cxx_std_11) + + install(TARGETS butteraugli DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/recipes/butteraugli/all/conandata.yml b/recipes/butteraugli/all/conandata.yml index e055fe4ea0162..bcd4f7dd9d272 100644 --- a/recipes/butteraugli/all/conandata.yml +++ b/recipes/butteraugli/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "cci.20190319": - patch_file: "patches/0001-compilation-fixes-for-vs2015.patch" - base_path: "source_subfolder" diff --git a/recipes/butteraugli/all/conanfile.py b/recipes/butteraugli/all/conanfile.py index 08ed283655462..129e25bd723ec 100644 --- a/recipes/butteraugli/all/conanfile.py +++ b/recipes/butteraugli/all/conanfile.py @@ -1,35 +1,35 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get import os -import glob -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.53.0" + class ButteraugliConan(ConanFile): name = "butteraugli" description = "A tool for measuring perceived differences between images" license = "Apache-2.0" - topics = ("conan", "image", "butteraugli", "diff") + topics = ("image", "diff") homepage = "https://github.com/google/butteraugli" url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" options = { "shared": [True, False], "fPIC": [True, False], + "tool": [True, False], } default_options = { "shared": False, "fPIC": True, + "tool": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -37,39 +37,48 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("libpng/1.6.37") - self.requires("libjpeg/9d") + if self.options.tool: + self.requires("libpng/1.6.38") + self.requires("libjpeg/9e") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob('butteraugli-*/')[0] - os.rename(extracted_dir, self._source_subfolder) + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUTTERAUGLI_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["BUTTERAUGLI_TOOL"] = self.options.tool + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.libs = ["butteraugli_lib"] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] + + if self.options.tool: + # TODO: to remove in conan v2 + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/butteraugli/all/test_package/CMakeLists.txt b/recipes/butteraugli/all/test_package/CMakeLists.txt index 33ae887aa6aea..7f874ff8ee8e1 100644 --- a/recipes/butteraugli/all/test_package/CMakeLists.txt +++ b/recipes/butteraugli/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(butteraugli REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE butteraugli::butteraugli) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/butteraugli/all/test_package/conanfile.py b/recipes/butteraugli/all/test_package/conanfile.py index ea57a464900be..0a6bc68712d90 100644 --- a/recipes/butteraugli/all/test_package/conanfile.py +++ b/recipes/butteraugli/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/butteraugli/all/test_v1_package/CMakeLists.txt b/recipes/butteraugli/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/butteraugli/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/butteraugli/all/test_v1_package/conanfile.py b/recipes/butteraugli/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/butteraugli/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bvdberg-ctest/all/conanfile.py b/recipes/bvdberg-ctest/all/conanfile.py index 96b95b7505043..ac8c63a98f38c 100644 --- a/recipes/bvdberg-ctest/all/conanfile.py +++ b/recipes/bvdberg-ctest/all/conanfile.py @@ -1,5 +1,10 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools + +required_conan_version = ">=1.50.0" class BvdbergCtestConan(ConanFile): @@ -8,21 +13,33 @@ class BvdbergCtestConan(ConanFile): homepage = "https://github.com/bvdberg/ctest" url = "https://github.com/conan-io/conan-center-index" description = "ctest is a unit test framework for software written in C." - topics = ("conan", "testing", "testing-framework", "unit-testing") + topics = ("testing", "testing-framework", "unit-testing") + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("Windows not supported") + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "ctest" + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*.h", dst="include", src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/bvdberg-ctest/all/test_package/CMakeLists.txt b/recipes/bvdberg-ctest/all/test_package/CMakeLists.txt index 7b9b613cbb24a..85fca601d8ec2 100644 --- a/recipes/bvdberg-ctest/all/test_package/CMakeLists.txt +++ b/recipes/bvdberg-ctest/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(bvdberg-ctest REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE bvdberg-ctest::bvdberg-ctest) diff --git a/recipes/bvdberg-ctest/all/test_package/conanfile.py b/recipes/bvdberg-ctest/all/test_package/conanfile.py index 6c0a50e0f7678..d120a992c06a6 100644 --- a/recipes/bvdberg-ctest/all/test_package/conanfile.py +++ b/recipes/bvdberg-ctest/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools -class TestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - bin_path = self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bvdberg-ctest/all/test_v1_package/CMakeLists.txt b/recipes/bvdberg-ctest/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..fd0d83ce8ad41 --- /dev/null +++ b/recipes/bvdberg-ctest/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bvdberg-ctest REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE bvdberg-ctest::bvdberg-ctest) diff --git a/recipes/bvdberg-ctest/all/test_v1_package/conanfile.py b/recipes/bvdberg-ctest/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..f2243371b7f1d --- /dev/null +++ b/recipes/bvdberg-ctest/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + bin_path = self.run(bin_path, run_environment=True) diff --git a/recipes/bvdberg-ctest/config.yml b/recipes/bvdberg-ctest/config.yml index 8f50af2b049ed..c7f13630776fb 100644 --- a/recipes/bvdberg-ctest/config.yml +++ b/recipes/bvdberg-ctest/config.yml @@ -1,4 +1,3 @@ ---- versions: "1.0.0": folder: "all" diff --git a/recipes/byte-lite/all/conanfile.py b/recipes/byte-lite/all/conanfile.py index 1bcc895e9335a..67d695dbd0333 100644 --- a/recipes/byte-lite/all/conanfile.py +++ b/recipes/byte-lite/all/conanfile.py @@ -1,7 +1,10 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.50.0" + class ByteLiteConan(ConanFile): name = "byte-lite" @@ -9,30 +12,45 @@ class ByteLiteConan(ConanFile): homepage = "https://github.com/martinmoene/byte-lite" description = ("byte lite - A single-file header-only C++17-like byte type for \ C++98, C++11 and later") - topics = ("conan", "cpp11", "cpp14", "cpp17", "byte", "byte-implementations") + topics = ("cpp11", "cpp14", "cpp17", "byte", "byte-implementations") license = "BSL-1.0" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "byte-lite") + self.cpp_info.set_property("cmake_target_name", "nonstd::byte-lite") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "byte-lite" self.cpp_info.filenames["cmake_find_package_multi"] = "byte-lite" self.cpp_info.names["cmake_find_package"] = "nonstd" self.cpp_info.names["cmake_find_package_multi"] = "nonstd" self.cpp_info.components["bytelite"].names["cmake_find_package"] = "byte-lite" self.cpp_info.components["bytelite"].names["cmake_find_package_multi"] = "byte-lite" + self.cpp_info.components["bytelite"].set_property("cmake_target_name", "nonstd::byte-lite") + self.cpp_info.components["bytelite"].bindirs = [] + self.cpp_info.components["bytelite"].frameworkdirs = [] + self.cpp_info.components["bytelite"].libdirs = [] + self.cpp_info.components["bytelite"].resdirs = [] diff --git a/recipes/byte-lite/all/test_package/CMakeLists.txt b/recipes/byte-lite/all/test_package/CMakeLists.txt index 836700c287faa..2c4833803c8c9 100644 --- a/recipes/byte-lite/all/test_package/CMakeLists.txt +++ b/recipes/byte-lite/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES CXX) find_package(byte-lite REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} nonstd::byte-lite) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::byte-lite) diff --git a/recipes/byte-lite/all/test_package/conanfile.py b/recipes/byte-lite/all/test_package/conanfile.py index abcaeed3f89b6..d120a992c06a6 100644 --- a/recipes/byte-lite/all/test_package/conanfile.py +++ b/recipes/byte-lite/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/byte-lite/all/test_v1_package/CMakeLists.txt b/recipes/byte-lite/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..65ad56138429f --- /dev/null +++ b/recipes/byte-lite/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(byte-lite REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::byte-lite) diff --git a/recipes/byte-lite/all/test_v1_package/conanfile.py b/recipes/byte-lite/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/byte-lite/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bzip2/all/CMakeLists.txt b/recipes/bzip2/all/CMakeLists.txt index f030f7a2fa9cd..cce959a4a45c5 100644 --- a/recipes/bzip2/all/CMakeLists.txt +++ b/recipes/bzip2/all/CMakeLists.txt @@ -1,47 +1,41 @@ cmake_minimum_required(VERSION 3.4) -project(bzip2 C) +project(bzip2 LANGUAGES C) include(GNUInstallDirs) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -if(MSVC OR MSVC90 OR MSVC10) - set(MSVC ON) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - -set(SOURCE_SUBFOLDER ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) -set(BZ2_LIBRARY bz2) - -option(BZ2_BUILD_EXE ON) - -set(BZ2_TARGETS ${BZ2_LIBRARY}) - -add_library(${BZ2_LIBRARY} ${SOURCE_SUBFOLDER}/blocksort.c - ${SOURCE_SUBFOLDER}/bzlib.c - ${SOURCE_SUBFOLDER}/compress.c - ${SOURCE_SUBFOLDER}/crctable.c - ${SOURCE_SUBFOLDER}/decompress.c - ${SOURCE_SUBFOLDER}/huffman.c - ${SOURCE_SUBFOLDER}/randtable.c - ${SOURCE_SUBFOLDER}/bzlib.h - ${SOURCE_SUBFOLDER}/bzlib_private.h) -target_include_directories(${BZ2_LIBRARY} PRIVATE ${SOURCE_SUBFOLDER}) +option(BZ2_BUILD_EXE "Build bzip2 command-line utility" ON) + +add_library( + bz2 + ${BZ2_SRC_DIR}/blocksort.c + ${BZ2_SRC_DIR}/bzlib.c + ${BZ2_SRC_DIR}/compress.c + ${BZ2_SRC_DIR}/crctable.c + ${BZ2_SRC_DIR}/decompress.c + ${BZ2_SRC_DIR}/huffman.c + ${BZ2_SRC_DIR}/randtable.c +) + +target_include_directories(bz2 PUBLIC ${BZ2_SRC_DIR}) +set_target_properties( + bz2 + PROPERTIES + PUBLIC_HEADER "${BZ2_SRC_DIR}/bzlib.h" + SOVERSION ${BZ2_VERSION_MAJOR} + VERSION ${BZ2_VERSION_STRING} + WINDOWS_EXPORT_ALL_SYMBOLS ON +) + +install( + TARGETS bz2 + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) if(BZ2_BUILD_EXE) - add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_SUBFOLDER}/bzip2.c) - target_link_libraries(${CMAKE_PROJECT_NAME} ${BZ2_LIBRARY}) - target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${SOURCE_SUBFOLDER}) - list(APPEND BZ2_TARGETS ${CMAKE_PROJECT_NAME}) + add_executable(bzip2 ${BZ2_SRC_DIR}/bzip2.c) + target_link_libraries(bzip2 PRIVATE bz2) + install(TARGETS bzip2 DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() - -set_target_properties(${BZ2_LIBRARY} PROPERTIES VERSION ${BZ2_VERSION_STRING} SOVERSION ${BZ2_VERSION_MAJOR}) - -install(TARGETS ${BZ2_TARGETS} - BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -install(FILES ${SOURCE_SUBFOLDER}/bzlib.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/bzip2/all/conandata.yml b/recipes/bzip2/all/conandata.yml index f433f5953ee1d..01ba013179e10 100644 --- a/recipes/bzip2/all/conandata.yml +++ b/recipes/bzip2/all/conandata.yml @@ -8,4 +8,3 @@ sources: patches: "1.0.6": - patch_file: "patches/0001-fix-sys-stat-include.patch" - base_path: "source_subfolder" diff --git a/recipes/bzip2/all/conanfile.py b/recipes/bzip2/all/conanfile.py index f95d8070f7d75..49ea55c016349 100644 --- a/recipes/bzip2/all/conanfile.py +++ b/recipes/bzip2/all/conanfile.py @@ -1,8 +1,11 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, save +from conan.tools.scm import Version import os import textwrap -from conans import ConanFile, CMake, tools -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.52.0" class Bzip2Conan(ConanFile): @@ -11,102 +14,104 @@ class Bzip2Conan(ConanFile): homepage = "http://www.bzip.org" license = "bzip2-1.0.8" description = "bzip2 is a free and open-source file compression program that uses the Burrows Wheeler algorithm." - topics = ("conan", "bzip2", "data-compressor", "file-compression") - - settings = "os", "compiler", "arch", "build_type" + topics = ("data-compressor", "file-compression") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "build_executable": [True, False] + "build_executable": [True, False], } default_options = { "shared": False, "fPIC": True, - "build_executable": True + "build_executable": True, } - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - self.license = "bzip2-{}".format(self.version) + self.license = f"bzip2-{self.version}" def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BZ2_VERSION_STRING"] = self.version - self._cmake.definitions["BZ2_VERSION_MAJOR"] = tools.Version(self.version).major - self._cmake.definitions["BZ2_BUILD_EXE"] = self.options.build_executable - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BZ2_BUILD_EXE"] = self.options.build_executable + tc.variables["BZ2_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["BZ2_VERSION_MAJOR"] = Version(self.version).major + tc.variables["BZ2_VERSION_STRING"] = self.version + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() self._create_cmake_module_variables( - os.path.join(self.package_folder, self._module_subfolder, self._module_file) + os.path.join(self.package_folder, self._module_file_rel_path) ) - @staticmethod - def _create_cmake_module_variables(module_file): + def _create_cmake_module_variables(self, module_file): content = textwrap.dedent("""\ - if(DEFINED BZip2_FOUND) - set(BZIP2_FOUND ${BZip2_FOUND}) - set(BZIP2_NEED_PREFIX TRUE) + set(BZIP2_NEED_PREFIX TRUE) + set(BZIP2_FOUND TRUE) + if(NOT DEFINED BZIP2_INCLUDE_DIRS AND DEFINED BZip2_INCLUDE_DIRS) + set(BZIP2_INCLUDE_DIRS ${BZip2_INCLUDE_DIRS}) endif() - if(DEFINED BZip2_INCLUDE_DIR) - set(BZIP2_INCLUDE_DIRS ${BZip2_INCLUDE_DIR}) + if(NOT DEFINED BZIP2_INCLUDE_DIR AND DEFINED BZip2_INCLUDE_DIR) set(BZIP2_INCLUDE_DIR ${BZip2_INCLUDE_DIR}) endif() - if(DEFINED BZip2_LIBRARIES) + if(NOT DEFINED BZIP2_LIBRARIES AND DEFINED BZip2_LIBRARIES) set(BZIP2_LIBRARIES ${BZip2_LIBRARIES}) endif() - if(DEFINED BZip2_VERSION) + if(NOT DEFINED BZIP2_VERSION_STRING AND DEFINED BZip2_VERSION) set(BZIP2_VERSION_STRING ${BZip2_VERSION}) endif() """) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + save(self, module_file, content) @property - def _module_file(self): - return "conan-official-{}-variables.cmake".format(self.name) + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") def package_info(self): - self.cpp_info.names["cmake_find_package"] = "BZip2" - self.cpp_info.names["cmake_find_package_multi"] = "BZip2" - self.cpp_info.builddirs.append(self._module_subfolder) - self.cpp_info.build_modules["cmake_find_package"] = [os.path.join(self._module_subfolder, self._module_file)] + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "BZip2") + self.cpp_info.set_property("cmake_target_name", "BZip2::BZip2") + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) self.cpp_info.libs = ["bz2"] + self.cpp_info.names["cmake_find_package"] = "BZip2" + self.cpp_info.names["cmake_find_package_multi"] = "BZip2" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] if self.options.build_executable: - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/bzip2/all/test_package/CMakeLists.txt b/recipes/bzip2/all/test_package/CMakeLists.txt index 8bc0f00ec83b0..540d39e432a7e 100644 --- a/recipes/bzip2/all/test_package/CMakeLists.txt +++ b/recipes/bzip2/all/test_package/CMakeLists.txt @@ -1,16 +1,24 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(BZip2 REQUIRED) -message("BZIP2_FOUND: ${BZIP2_FOUND}") -message("BZIP2_NEED_PREFIX: ${BZIP2_NEED_PREFIX}") -message("BZIP2_INCLUDE_DIRS: ${BZIP2_INCLUDE_DIRS}") -message("BZIP2_INCLUDE_DIR: ${BZIP2_INCLUDE_DIR}") -message("BZIP2_LIBRARIES: ${BZIP2_LIBRARIES}") -message("BZIP2_VERSION_STRING: ${BZIP2_VERSION_STRING}") add_executable(test_package test_package.c) -target_link_libraries(test_package BZip2::BZip2) +target_link_libraries(test_package PRIVATE BZip2::BZip2) + +# Test whether variables from https://cmake.org/cmake/help/latest/module/FindBZip2.html are properly defined +set(_custom_vars + BZIP2_FOUND + BZIP2_NEED_PREFIX + BZIP2_INCLUDE_DIRS + BZIP2_INCLUDE_DIR + BZIP2_LIBRARIES + BZIP2_VERSION_STRING +) +foreach(_custom_var ${_custom_vars}) + if(DEFINED _custom_var) + message(STATUS "${_custom_var}: ${${_custom_var}}") + else() + message(FATAL_ERROR "${_custom_var} not defined") + endif() +endforeach() diff --git a/recipes/bzip2/all/test_package/conanfile.py b/recipes/bzip2/all/test_package/conanfile.py index 4df84b70849e5..8a5bb47f50c4c 100644 --- a/recipes/bzip2/all/test_package/conanfile.py +++ b/recipes/bzip2/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "arch", "build_type" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run("%s --help" % bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bzip2/all/test_package/test_package.c b/recipes/bzip2/all/test_package/test_package.c index dc626a42312d5..fb91334dfae69 100644 --- a/recipes/bzip2/all/test_package/test_package.c +++ b/recipes/bzip2/all/test_package/test_package.c @@ -1,2034 +1,14 @@ - -/*-----------------------------------------------------------*/ -/*--- A block-sorting, lossless compressor bzip2.c ---*/ -/*-----------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.6 of 6 September 2010 - Copyright (C) 1996-2010 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -/* Place a 1 beside your platform, and 0 elsewhere. - Generic 32-bit Unix. - Also works on 64-bit Unix boxes. - This is the default. -*/ -#define BZ_UNIX 1 - -/*-- - Win32, as seen by Jacob Navia's excellent - port of (Chris Fraser & David Hanson)'s excellent - lcc compiler. Or with MS Visual C. - This is selected automatically if compiled by a compiler which - defines _WIN32, not including the Cygwin GCC. ---*/ -#define BZ_LCCWIN32 0 - -#if defined(_WIN32) && !defined(__CYGWIN__) -#undef BZ_LCCWIN32 -#define BZ_LCCWIN32 1 -#undef BZ_UNIX -#define BZ_UNIX 0 -#endif - - -/*---------------------------------------------*/ -/*-- - Some stuff for all platforms. ---*/ - #include #include -#include -#include -#include -#include -#include #include "bzlib.h" -#define ERROR_IF_EOF(i) { if ((i) == EOF) ioError(); } -#define ERROR_IF_NOT_ZERO(i) { if ((i) != 0) ioError(); } -#define ERROR_IF_MINUS_ONE(i) { if ((i) == (-1)) ioError(); } - - -/*---------------------------------------------*/ -/*-- - Platform-specific stuff. ---*/ - -#if BZ_UNIX -# include -# include -# include -# include -# include -# include - -# define PATH_SEP '/' -# define MY_LSTAT lstat -# define MY_STAT stat -# define MY_S_ISREG S_ISREG -# define MY_S_ISDIR S_ISDIR - -# define APPEND_FILESPEC(root, name) \ - root=snocString((root), (name)) - -# define APPEND_FLAG(root, name) \ - root=snocString((root), (name)) - -# define SET_BINARY_MODE(fd) /**/ - -# ifdef __GNUC__ -# define NORETURN __attribute__ ((noreturn)) -# else -# define NORETURN /**/ -# endif - -# ifdef __DJGPP__ -# include -# include -# undef MY_LSTAT -# undef MY_STAT -# define MY_LSTAT stat -# define MY_STAT stat -# undef SET_BINARY_MODE -# define SET_BINARY_MODE(fd) \ - do { \ - int retVal = setmode ( fileno ( fd ), \ - O_BINARY ); \ - ERROR_IF_MINUS_ONE ( retVal ); \ - } while ( 0 ) -# endif - -# ifdef __CYGWIN__ -# include -# include -# undef SET_BINARY_MODE -# define SET_BINARY_MODE(fd) \ - do { \ - int retVal = setmode ( fileno ( fd ), \ - O_BINARY ); \ - ERROR_IF_MINUS_ONE ( retVal ); \ - } while ( 0 ) -# endif -#endif /* BZ_UNIX */ - - - -#if BZ_LCCWIN32 -# include -# include -# include - -# define NORETURN /**/ -# define PATH_SEP '\\' -# define MY_LSTAT _stat -# define MY_STAT _stat -# define MY_S_ISREG(x) ((x) & _S_IFREG) -# define MY_S_ISDIR(x) ((x) & _S_IFDIR) - -# define APPEND_FLAG(root, name) \ - root=snocString((root), (name)) - -# define APPEND_FILESPEC(root, name) \ - root = snocString ((root), (name)) - -# define SET_BINARY_MODE(fd) \ - do { \ - int retVal = setmode ( fileno ( fd ), \ - O_BINARY ); \ - ERROR_IF_MINUS_ONE ( retVal ); \ - } while ( 0 ) - -#endif /* BZ_LCCWIN32 */ - - -/*---------------------------------------------*/ -/*-- - Some more stuff for all platforms :-) ---*/ - -typedef char Char; -typedef unsigned char Bool; -typedef unsigned char UChar; -typedef int Int32; -typedef unsigned int UInt32; -typedef short Int16; -typedef unsigned short UInt16; - -#define True ((Bool)1) -#define False ((Bool)0) - -/*-- - IntNative is your platform's `native' int size. - Only here to avoid probs with 64-bit platforms. ---*/ -typedef int IntNative; - - -/*---------------------------------------------------*/ -/*--- Misc (file handling) data decls ---*/ -/*---------------------------------------------------*/ - -Int32 verbosity; -Bool keepInputFiles, smallMode, deleteOutputOnInterrupt; -Bool forceOverwrite, testFailsExist, unzFailsExist, noisy; -Int32 numFileNames, numFilesProcessed, blockSize100k; -Int32 exitValue; - -/*-- source modes; F==file, I==stdin, O==stdout --*/ -#define SM_I2O 1 -#define SM_F2O 2 -#define SM_F2F 3 - -/*-- operation modes --*/ -#define OM_Z 1 -#define OM_UNZ 2 -#define OM_TEST 3 - -Int32 opMode; -Int32 srcMode; - -#define FILE_NAME_LEN 1034 - -Int32 longestFileName; -Char inName [FILE_NAME_LEN]; -Char outName[FILE_NAME_LEN]; -Char tmpName[FILE_NAME_LEN]; -Char *progName; -Char progNameReally[FILE_NAME_LEN]; -FILE *outputHandleJustInCase; -Int32 workFactor; - -static void panic ( const Char* ) NORETURN; -static void ioError ( void ) NORETURN; -static void outOfMemory ( void ) NORETURN; -static void configError ( void ) NORETURN; -static void crcError ( void ) NORETURN; -static void cleanUpAndFail ( Int32 ) NORETURN; -static void compressedStreamEOF ( void ) NORETURN; - -static void copyFileName ( Char*, Char* ); -static void* myMalloc ( Int32 ); -static void applySavedFileAttrToOutputFile ( IntNative fd ); - - - -/*---------------------------------------------------*/ -/*--- An implementation of 64-bit ints. Sigh. ---*/ -/*--- Roll on widespread deployment of ANSI C9X ! ---*/ -/*---------------------------------------------------*/ - -typedef - struct { UChar b[8]; } - UInt64; - - -static -void uInt64_from_UInt32s ( UInt64* n, UInt32 lo32, UInt32 hi32 ) -{ - n->b[7] = (UChar)((hi32 >> 24) & 0xFF); - n->b[6] = (UChar)((hi32 >> 16) & 0xFF); - n->b[5] = (UChar)((hi32 >> 8) & 0xFF); - n->b[4] = (UChar) (hi32 & 0xFF); - n->b[3] = (UChar)((lo32 >> 24) & 0xFF); - n->b[2] = (UChar)((lo32 >> 16) & 0xFF); - n->b[1] = (UChar)((lo32 >> 8) & 0xFF); - n->b[0] = (UChar) (lo32 & 0xFF); -} - - -static -double uInt64_to_double ( UInt64* n ) -{ - Int32 i; - double base = 1.0; - double sum = 0.0; - for (i = 0; i < 8; i++) { - sum += base * (double)(n->b[i]); - base *= 256.0; - } - return sum; -} - - -static -Bool uInt64_isZero ( UInt64* n ) -{ - Int32 i; - for (i = 0; i < 8; i++) - if (n->b[i] != 0) return 0; - return 1; -} - - -/* Divide *n by 10, and return the remainder. */ -static -Int32 uInt64_qrm10 ( UInt64* n ) -{ - UInt32 rem, tmp; - Int32 i; - rem = 0; - for (i = 7; i >= 0; i--) { - tmp = rem * 256 + n->b[i]; - n->b[i] = tmp / 10; - rem = tmp % 10; - } - return rem; -} - - -/* ... and the Whole Entire Point of all this UInt64 stuff is - so that we can supply the following function. -*/ -static -void uInt64_toAscii ( char* outbuf, UInt64* n ) -{ - Int32 i, q; - UChar buf[32]; - Int32 nBuf = 0; - UInt64 n_copy = *n; - do { - q = uInt64_qrm10 ( &n_copy ); - buf[nBuf] = q + '0'; - nBuf++; - } while (!uInt64_isZero(&n_copy)); - outbuf[nBuf] = 0; - for (i = 0; i < nBuf; i++) - outbuf[i] = buf[nBuf-i-1]; -} - - -/*---------------------------------------------------*/ -/*--- Processing of complete files and streams ---*/ -/*---------------------------------------------------*/ - -/*---------------------------------------------*/ -static -Bool myfeof ( FILE* f ) -{ - Int32 c = fgetc ( f ); - if (c == EOF) return True; - ungetc ( c, f ); - return False; -} - - -/*---------------------------------------------*/ -static -void compressStream ( FILE *stream, FILE *zStream ) -{ - BZFILE* bzf = NULL; - UChar ibuf[5000]; - Int32 nIbuf; - UInt32 nbytes_in_lo32, nbytes_in_hi32; - UInt32 nbytes_out_lo32, nbytes_out_hi32; - Int32 bzerr, bzerr_dummy, ret; - - SET_BINARY_MODE(stream); - SET_BINARY_MODE(zStream); - - if (ferror(stream)) goto errhandler_io; - if (ferror(zStream)) goto errhandler_io; - - bzf = BZ2_bzWriteOpen ( &bzerr, zStream, - blockSize100k, verbosity, workFactor ); - if (bzerr != BZ_OK) goto errhandler; - - if (verbosity >= 2) fprintf ( stderr, "\n" ); - - while (True) { - - if (myfeof(stream)) break; - nIbuf = fread ( ibuf, sizeof(UChar), 5000, stream ); - if (ferror(stream)) goto errhandler_io; - if (nIbuf > 0) BZ2_bzWrite ( &bzerr, bzf, (void*)ibuf, nIbuf ); - if (bzerr != BZ_OK) goto errhandler; - - } - - BZ2_bzWriteClose64 ( &bzerr, bzf, 0, - &nbytes_in_lo32, &nbytes_in_hi32, - &nbytes_out_lo32, &nbytes_out_hi32 ); - if (bzerr != BZ_OK) goto errhandler; - - if (ferror(zStream)) goto errhandler_io; - ret = fflush ( zStream ); - if (ret == EOF) goto errhandler_io; - if (zStream != stdout) { - Int32 fd = fileno ( zStream ); - if (fd < 0) goto errhandler_io; - applySavedFileAttrToOutputFile ( fd ); - ret = fclose ( zStream ); - outputHandleJustInCase = NULL; - if (ret == EOF) goto errhandler_io; - } - outputHandleJustInCase = NULL; - if (ferror(stream)) goto errhandler_io; - ret = fclose ( stream ); - if (ret == EOF) goto errhandler_io; - - if (verbosity >= 1) { - if (nbytes_in_lo32 == 0 && nbytes_in_hi32 == 0) { - fprintf ( stderr, " no data compressed.\n"); - } else { - Char buf_nin[32], buf_nout[32]; - UInt64 nbytes_in, nbytes_out; - double nbytes_in_d, nbytes_out_d; - uInt64_from_UInt32s ( &nbytes_in, - nbytes_in_lo32, nbytes_in_hi32 ); - uInt64_from_UInt32s ( &nbytes_out, - nbytes_out_lo32, nbytes_out_hi32 ); - nbytes_in_d = uInt64_to_double ( &nbytes_in ); - nbytes_out_d = uInt64_to_double ( &nbytes_out ); - uInt64_toAscii ( buf_nin, &nbytes_in ); - uInt64_toAscii ( buf_nout, &nbytes_out ); - fprintf ( stderr, "%6.3f:1, %6.3f bits/byte, " - "%5.2f%% saved, %s in, %s out.\n", - nbytes_in_d / nbytes_out_d, - (8.0 * nbytes_out_d) / nbytes_in_d, - 100.0 * (1.0 - nbytes_out_d / nbytes_in_d), - buf_nin, - buf_nout - ); - } - } - - return; - errhandler: - BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1, - &nbytes_in_lo32, &nbytes_in_hi32, - &nbytes_out_lo32, &nbytes_out_hi32 ); - switch (bzerr) { - case BZ_CONFIG_ERROR: - configError(); break; - case BZ_MEM_ERROR: - outOfMemory (); break; - case BZ_IO_ERROR: - errhandler_io: - ioError(); break; - default: - panic ( "compress:unexpected error" ); - } - - panic ( "compress:end" ); - /*notreached*/ -} - - - -/*---------------------------------------------*/ -static -Bool uncompressStream ( FILE *zStream, FILE *stream ) -{ - BZFILE* bzf = NULL; - Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i; - UChar obuf[5000]; - UChar unused[BZ_MAX_UNUSED]; - Int32 nUnused; - void* unusedTmpV; - UChar* unusedTmp; - - nUnused = 0; - streamNo = 0; - - SET_BINARY_MODE(stream); - SET_BINARY_MODE(zStream); - - if (ferror(stream)) goto errhandler_io; - if (ferror(zStream)) goto errhandler_io; - - while (True) { - - bzf = BZ2_bzReadOpen ( - &bzerr, zStream, verbosity, - (int)smallMode, unused, nUnused - ); - if (bzf == NULL || bzerr != BZ_OK) goto errhandler; - streamNo++; - - while (bzerr == BZ_OK) { - nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 ); - if (bzerr == BZ_DATA_ERROR_MAGIC) goto trycat; - if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0) - fwrite ( obuf, sizeof(UChar), nread, stream ); - if (ferror(stream)) goto errhandler_io; - } - if (bzerr != BZ_STREAM_END) goto errhandler; - - BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused ); - if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" ); - - unusedTmp = (UChar*)unusedTmpV; - for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i]; - - BZ2_bzReadClose ( &bzerr, bzf ); - if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" ); - - if (nUnused == 0 && myfeof(zStream)) break; - } - - closeok: - if (ferror(zStream)) goto errhandler_io; - if (stream != stdout) { - Int32 fd = fileno ( stream ); - if (fd < 0) goto errhandler_io; - applySavedFileAttrToOutputFile ( fd ); - } - ret = fclose ( zStream ); - if (ret == EOF) goto errhandler_io; - - if (ferror(stream)) goto errhandler_io; - ret = fflush ( stream ); - if (ret != 0) goto errhandler_io; - if (stream != stdout) { - ret = fclose ( stream ); - outputHandleJustInCase = NULL; - if (ret == EOF) goto errhandler_io; - } - outputHandleJustInCase = NULL; - if (verbosity >= 2) fprintf ( stderr, "\n " ); - return True; - - trycat: - if (forceOverwrite) { - rewind(zStream); - while (True) { - if (myfeof(zStream)) break; - nread = fread ( obuf, sizeof(UChar), 5000, zStream ); - if (ferror(zStream)) goto errhandler_io; - if (nread > 0) fwrite ( obuf, sizeof(UChar), nread, stream ); - if (ferror(stream)) goto errhandler_io; - } - goto closeok; - } - - errhandler: - BZ2_bzReadClose ( &bzerr_dummy, bzf ); - switch (bzerr) { - case BZ_CONFIG_ERROR: - configError(); break; - case BZ_IO_ERROR: - errhandler_io: - ioError(); break; - case BZ_DATA_ERROR: - crcError(); - case BZ_MEM_ERROR: - outOfMemory(); - case BZ_UNEXPECTED_EOF: - compressedStreamEOF(); - case BZ_DATA_ERROR_MAGIC: - if (zStream != stdin) fclose(zStream); - if (stream != stdout) fclose(stream); - if (streamNo == 1) { - return False; - } else { - if (noisy) - fprintf ( stderr, - "\n%s: %s: trailing garbage after EOF ignored\n", - progName, inName ); - return True; - } - default: - panic ( "decompress:unexpected error" ); - } - - panic ( "decompress:end" ); - return True; /*notreached*/ -} - - -/*---------------------------------------------*/ -static -Bool testStream ( FILE *zStream ) -{ - BZFILE* bzf = NULL; - Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i; - UChar obuf[5000]; - UChar unused[BZ_MAX_UNUSED]; - Int32 nUnused; - void* unusedTmpV; - UChar* unusedTmp; - - nUnused = 0; - streamNo = 0; - - SET_BINARY_MODE(zStream); - if (ferror(zStream)) goto errhandler_io; - - while (True) { - - bzf = BZ2_bzReadOpen ( - &bzerr, zStream, verbosity, - (int)smallMode, unused, nUnused - ); - if (bzf == NULL || bzerr != BZ_OK) goto errhandler; - streamNo++; - - while (bzerr == BZ_OK) { - nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 ); - if (bzerr == BZ_DATA_ERROR_MAGIC) goto errhandler; - } - if (bzerr != BZ_STREAM_END) goto errhandler; - - BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused ); - if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" ); - - unusedTmp = (UChar*)unusedTmpV; - for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i]; - - BZ2_bzReadClose ( &bzerr, bzf ); - if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" ); - if (nUnused == 0 && myfeof(zStream)) break; - - } - - if (ferror(zStream)) goto errhandler_io; - ret = fclose ( zStream ); - if (ret == EOF) goto errhandler_io; - - if (verbosity >= 2) fprintf ( stderr, "\n " ); - return True; - - errhandler: - BZ2_bzReadClose ( &bzerr_dummy, bzf ); - if (verbosity == 0) - fprintf ( stderr, "%s: %s: ", progName, inName ); - switch (bzerr) { - case BZ_CONFIG_ERROR: - configError(); break; - case BZ_IO_ERROR: - errhandler_io: - ioError(); break; - case BZ_DATA_ERROR: - fprintf ( stderr, - "data integrity (CRC) error in data\n" ); - return False; - case BZ_MEM_ERROR: - outOfMemory(); - case BZ_UNEXPECTED_EOF: - fprintf ( stderr, - "file ends unexpectedly\n" ); - return False; - case BZ_DATA_ERROR_MAGIC: - if (zStream != stdin) fclose(zStream); - if (streamNo == 1) { - fprintf ( stderr, - "bad magic number (file not created by bzip2)\n" ); - return False; - } else { - if (noisy) - fprintf ( stderr, - "trailing garbage after EOF ignored\n" ); - return True; - } - default: - panic ( "test:unexpected error" ); - } - - panic ( "test:end" ); - return True; /*notreached*/ -} - - -/*---------------------------------------------------*/ -/*--- Error [non-] handling grunge ---*/ -/*---------------------------------------------------*/ - -/*---------------------------------------------*/ -static -void setExit ( Int32 v ) -{ - if (v > exitValue) exitValue = v; -} - - -/*---------------------------------------------*/ -static -void cadvise ( void ) -{ - if (noisy) - fprintf ( - stderr, - "\nIt is possible that the compressed file(s) have become corrupted.\n" - "You can use the -tvv option to test integrity of such files.\n\n" - "You can use the `bzip2recover' program to attempt to recover\n" - "data from undamaged sections of corrupted files.\n\n" - ); -} - - -/*---------------------------------------------*/ -static -void showFileNames ( void ) -{ - if (noisy) - fprintf ( - stderr, - "\tInput file = %s, output file = %s\n", - inName, outName - ); -} - - -/*---------------------------------------------*/ -static -void cleanUpAndFail ( Int32 ec ) -{ - IntNative retVal; - struct MY_STAT statBuf; - - if ( srcMode == SM_F2F - && opMode != OM_TEST - && deleteOutputOnInterrupt ) { - - /* Check whether input file still exists. Delete output file - only if input exists to avoid loss of data. Joerg Prante, 5 - January 2002. (JRS 06-Jan-2002: other changes in 1.0.2 mean - this is less likely to happen. But to be ultra-paranoid, we - do the check anyway.) */ - retVal = MY_STAT ( inName, &statBuf ); - if (retVal == 0) { - if (noisy) - fprintf ( stderr, - "%s: Deleting output file %s, if it exists.\n", - progName, outName ); - if (outputHandleJustInCase != NULL) - fclose ( outputHandleJustInCase ); - retVal = remove ( outName ); - if (retVal != 0) - fprintf ( stderr, - "%s: WARNING: deletion of output file " - "(apparently) failed.\n", - progName ); - } else { - fprintf ( stderr, - "%s: WARNING: deletion of output file suppressed\n", - progName ); - fprintf ( stderr, - "%s: since input file no longer exists. Output file\n", - progName ); - fprintf ( stderr, - "%s: `%s' may be incomplete.\n", - progName, outName ); - fprintf ( stderr, - "%s: I suggest doing an integrity test (bzip2 -tv)" - " of it.\n", - progName ); - } - } - - if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) { - fprintf ( stderr, - "%s: WARNING: some files have not been processed:\n" - "%s: %d specified on command line, %d not processed yet.\n\n", - progName, progName, - numFileNames, numFileNames - numFilesProcessed ); - } - setExit(ec); - exit(exitValue); -} - - -/*---------------------------------------------*/ -static -void panic ( const Char* s ) -{ - fprintf ( stderr, - "\n%s: PANIC -- internal consistency error:\n" - "\t%s\n" - "\tThis is a BUG. Please report it to me at:\n" - "\tjseward@bzip.org\n", - progName, s ); - showFileNames(); - cleanUpAndFail( 3 ); -} - - -/*---------------------------------------------*/ -static -void crcError ( void ) -{ - fprintf ( stderr, - "\n%s: Data integrity error when decompressing.\n", - progName ); - showFileNames(); - cadvise(); - cleanUpAndFail( 2 ); -} - - -/*---------------------------------------------*/ -static -void compressedStreamEOF ( void ) -{ - if (noisy) { - fprintf ( stderr, - "\n%s: Compressed file ends unexpectedly;\n\t" - "perhaps it is corrupted? *Possible* reason follows.\n", - progName ); - perror ( progName ); - showFileNames(); - cadvise(); - } - cleanUpAndFail( 2 ); +int main(void) { + char buffer [256] = {0}; + unsigned int size = 256; + const char* version = BZ2_bzlibVersion(); + printf("Bzip2 version: %s\n", version); + BZ2_bzBuffToBuffCompress(buffer, &size, "conan-package-manager", 21, 1, 0, 1); + printf("Bzip2 compressed: %s\n", buffer); + return EXIT_SUCCESS; } - - -/*---------------------------------------------*/ -static -void ioError ( void ) -{ - fprintf ( stderr, - "\n%s: I/O or other error, bailing out. " - "Possible reason follows.\n", - progName ); - perror ( progName ); - showFileNames(); - cleanUpAndFail( 1 ); -} - - -/*---------------------------------------------*/ -static -void mySignalCatcher ( IntNative n ) -{ - fprintf ( stderr, - "\n%s: Control-C or similar caught, quitting.\n", - progName ); - cleanUpAndFail(1); -} - - -/*---------------------------------------------*/ -static -void mySIGSEGVorSIGBUScatcher ( IntNative n ) -{ - if (opMode == OM_Z) - fprintf ( - stderr, - "\n%s: Caught a SIGSEGV or SIGBUS whilst compressing.\n" - "\n" - " Possible causes are (most likely first):\n" - " (1) This computer has unreliable memory or cache hardware\n" - " (a surprisingly common problem; try a different machine.)\n" - " (2) A bug in the compiler used to create this executable\n" - " (unlikely, if you didn't compile bzip2 yourself.)\n" - " (3) A real bug in bzip2 -- I hope this should never be the case.\n" - " The user's manual, Section 4.3, has more info on (1) and (2).\n" - " \n" - " If you suspect this is a bug in bzip2, or are unsure about (1)\n" - " or (2), feel free to report it to me at: jseward@bzip.org.\n" - " Section 4.3 of the user's manual describes the info a useful\n" - " bug report should have. If the manual is available on your\n" - " system, please try and read it before mailing me. If you don't\n" - " have the manual or can't be bothered to read it, mail me anyway.\n" - "\n", - progName ); - else - fprintf ( - stderr, - "\n%s: Caught a SIGSEGV or SIGBUS whilst decompressing.\n" - "\n" - " Possible causes are (most likely first):\n" - " (1) The compressed data is corrupted, and bzip2's usual checks\n" - " failed to detect this. Try bzip2 -tvv my_file.bz2.\n" - " (2) This computer has unreliable memory or cache hardware\n" - " (a surprisingly common problem; try a different machine.)\n" - " (3) A bug in the compiler used to create this executable\n" - " (unlikely, if you didn't compile bzip2 yourself.)\n" - " (4) A real bug in bzip2 -- I hope this should never be the case.\n" - " The user's manual, Section 4.3, has more info on (2) and (3).\n" - " \n" - " If you suspect this is a bug in bzip2, or are unsure about (2)\n" - " or (3), feel free to report it to me at: jseward@bzip.org.\n" - " Section 4.3 of the user's manual describes the info a useful\n" - " bug report should have. If the manual is available on your\n" - " system, please try and read it before mailing me. If you don't\n" - " have the manual or can't be bothered to read it, mail me anyway.\n" - "\n", - progName ); - - showFileNames(); - if (opMode == OM_Z) - cleanUpAndFail( 3 ); else - { cadvise(); cleanUpAndFail( 2 ); } -} - - -/*---------------------------------------------*/ -static -void outOfMemory ( void ) -{ - fprintf ( stderr, - "\n%s: couldn't allocate enough memory\n", - progName ); - showFileNames(); - cleanUpAndFail(1); -} - - -/*---------------------------------------------*/ -static -void configError ( void ) -{ - fprintf ( stderr, - "bzip2: I'm not configured correctly for this platform!\n" - "\tI require Int32, Int16 and Char to have sizes\n" - "\tof 4, 2 and 1 bytes to run properly, and they don't.\n" - "\tProbably you can fix this by defining them correctly,\n" - "\tand recompiling. Bye!\n" ); - setExit(3); - exit(exitValue); -} - - -/*---------------------------------------------------*/ -/*--- The main driver machinery ---*/ -/*---------------------------------------------------*/ - -/* All rather crufty. The main problem is that input files - are stat()d multiple times before use. This should be - cleaned up. -*/ - -/*---------------------------------------------*/ -static -void pad ( Char *s ) -{ - Int32 i; - if ( (Int32)strlen(s) >= longestFileName ) return; - for (i = 1; i <= longestFileName - (Int32)strlen(s); i++) - fprintf ( stderr, " " ); -} - - -/*---------------------------------------------*/ -static -void copyFileName ( Char* to, Char* from ) -{ - if ( strlen(from) > FILE_NAME_LEN-10 ) { - fprintf ( - stderr, - "bzip2: file name\n`%s'\n" - "is suspiciously (more than %d chars) long.\n" - "Try using a reasonable file name instead. Sorry! :-)\n", - from, FILE_NAME_LEN-10 - ); - setExit(1); - exit(exitValue); - } - - strncpy(to,from,FILE_NAME_LEN-10); - to[FILE_NAME_LEN-10]='\0'; -} - - -/*---------------------------------------------*/ -static -Bool fileExists ( Char* name ) -{ - FILE *tmp = fopen ( name, "rb" ); - Bool exists = (tmp != NULL); - if (tmp != NULL) fclose ( tmp ); - return exists; -} - - -/*---------------------------------------------*/ -/* Open an output file safely with O_EXCL and good permissions. - This avoids a race condition in versions < 1.0.2, in which - the file was first opened and then had its interim permissions - set safely. We instead use open() to create the file with - the interim permissions required. (--- --- rw-). - - For non-Unix platforms, if we are not worrying about - security issues, simple this simply behaves like fopen. -*/ -static -FILE* fopen_output_safely ( Char* name, const char* mode ) -{ -# if BZ_UNIX - FILE* fp; - IntNative fh; - fh = open(name, O_WRONLY|O_CREAT|O_EXCL, S_IWUSR|S_IRUSR); - if (fh == -1) return NULL; - fp = fdopen(fh, mode); - if (fp == NULL) close(fh); - return fp; -# else - return fopen(name, mode); -# endif -} - - -/*---------------------------------------------*/ -/*-- - if in doubt, return True ---*/ -static -Bool notAStandardFile ( Char* name ) -{ - IntNative i; - struct MY_STAT statBuf; - - i = MY_LSTAT ( name, &statBuf ); - if (i != 0) return True; - if (MY_S_ISREG(statBuf.st_mode)) return False; - return True; -} - - -/*---------------------------------------------*/ -/*-- - rac 11/21/98 see if file has hard links to it ---*/ -static -Int32 countHardLinks ( Char* name ) -{ - IntNative i; - struct MY_STAT statBuf; - - i = MY_LSTAT ( name, &statBuf ); - if (i != 0) return 0; - return (statBuf.st_nlink - 1); -} - - -/*---------------------------------------------*/ -/* Copy modification date, access date, permissions and owner from the - source to destination file. We have to copy this meta-info off - into fileMetaInfo before starting to compress / decompress it, - because doing it afterwards means we get the wrong access time. - - To complicate matters, in compress() and decompress() below, the - sequence of tests preceding the call to saveInputFileMetaInfo() - involves calling fileExists(), which in turn establishes its result - by attempting to fopen() the file, and if successful, immediately - fclose()ing it again. So we have to assume that the fopen() call - does not cause the access time field to be updated. - - Reading of the man page for stat() (man 2 stat) on RedHat 7.2 seems - to imply that merely doing open() will not affect the access time. - Therefore we merely need to hope that the C library only does - open() as a result of fopen(), and not any kind of read()-ahead - cleverness. - - It sounds pretty fragile to me. Whether this carries across - robustly to arbitrary Unix-like platforms (or even works robustly - on this one, RedHat 7.2) is unknown to me. Nevertheless ... -*/ -#if BZ_UNIX -static -struct MY_STAT fileMetaInfo; -#endif - -static -void saveInputFileMetaInfo ( Char *srcName ) -{ -# if BZ_UNIX - IntNative retVal; - /* Note use of stat here, not lstat. */ - retVal = MY_STAT( srcName, &fileMetaInfo ); - ERROR_IF_NOT_ZERO ( retVal ); -# endif -} - - -static -void applySavedTimeInfoToOutputFile ( Char *dstName ) -{ -# if BZ_UNIX - IntNative retVal; - struct utimbuf uTimBuf; - - uTimBuf.actime = fileMetaInfo.st_atime; - uTimBuf.modtime = fileMetaInfo.st_mtime; - - retVal = utime ( dstName, &uTimBuf ); - ERROR_IF_NOT_ZERO ( retVal ); -# endif -} - -static -void applySavedFileAttrToOutputFile ( IntNative fd ) -{ -# if BZ_UNIX - IntNative retVal; - - retVal = fchmod ( fd, fileMetaInfo.st_mode ); - ERROR_IF_NOT_ZERO ( retVal ); - - (void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid ); - /* chown() will in many cases return with EPERM, which can - be safely ignored. - */ -# endif -} - - -/*---------------------------------------------*/ -static -Bool containsDubiousChars ( Char* name ) -{ -# if BZ_UNIX - /* On unix, files can contain any characters and the file expansion - * is performed by the shell. - */ - return False; -# else /* ! BZ_UNIX */ - /* On non-unix (Win* platforms), wildcard characters are not allowed in - * filenames. - */ - for (; *name != '\0'; name++) - if (*name == '?' || *name == '*') return True; - return False; -# endif /* BZ_UNIX */ -} - - -/*---------------------------------------------*/ -#define BZ_N_SUFFIX_PAIRS 4 - -const Char* zSuffix[BZ_N_SUFFIX_PAIRS] - = { ".bz2", ".bz", ".tbz2", ".tbz" }; -const Char* unzSuffix[BZ_N_SUFFIX_PAIRS] - = { "", "", ".tar", ".tar" }; - -static -Bool hasSuffix ( Char* s, const Char* suffix ) -{ - Int32 ns = strlen(s); - Int32 nx = strlen(suffix); - if (ns < nx) return False; - if (strcmp(s + ns - nx, suffix) == 0) return True; - return False; -} - -static -Bool mapSuffix ( Char* name, - const Char* oldSuffix, - const Char* newSuffix ) -{ - if (!hasSuffix(name,oldSuffix)) return False; - name[strlen(name)-strlen(oldSuffix)] = 0; - strcat ( name, newSuffix ); - return True; -} - - -/*---------------------------------------------*/ -static -void compress ( Char *name ) -{ - FILE *inStr; - FILE *outStr; - Int32 n, i; - struct MY_STAT statBuf; - - deleteOutputOnInterrupt = False; - - if (name == NULL && srcMode != SM_I2O) - panic ( "compress: bad modes\n" ); - - switch (srcMode) { - case SM_I2O: - copyFileName ( inName, (Char*)"(stdin)" ); - copyFileName ( outName, (Char*)"(stdout)" ); - break; - case SM_F2F: - copyFileName ( inName, name ); - copyFileName ( outName, name ); - strcat ( outName, ".bz2" ); - break; - case SM_F2O: - copyFileName ( inName, name ); - copyFileName ( outName, (Char*)"(stdout)" ); - break; - } - - if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) { - if (noisy) - fprintf ( stderr, "%s: There are no files matching `%s'.\n", - progName, inName ); - setExit(1); - return; - } - if ( srcMode != SM_I2O && !fileExists ( inName ) ) { - fprintf ( stderr, "%s: Can't open input file %s: %s.\n", - progName, inName, strerror(errno) ); - setExit(1); - return; - } - for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) { - if (hasSuffix(inName, zSuffix[i])) { - if (noisy) - fprintf ( stderr, - "%s: Input file %s already has %s suffix.\n", - progName, inName, zSuffix[i] ); - setExit(1); - return; - } - } - if ( srcMode == SM_F2F || srcMode == SM_F2O ) { - MY_STAT(inName, &statBuf); - if ( MY_S_ISDIR(statBuf.st_mode) ) { - fprintf( stderr, - "%s: Input file %s is a directory.\n", - progName,inName); - setExit(1); - return; - } - } - if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) { - if (noisy) - fprintf ( stderr, "%s: Input file %s is not a normal file.\n", - progName, inName ); - setExit(1); - return; - } - if ( srcMode == SM_F2F && fileExists ( outName ) ) { - if (forceOverwrite) { - remove(outName); - } else { - fprintf ( stderr, "%s: Output file %s already exists.\n", - progName, outName ); - setExit(1); - return; - } - } - if ( srcMode == SM_F2F && !forceOverwrite && - (n=countHardLinks ( inName )) > 0) { - fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", - progName, inName, n, n > 1 ? "s" : "" ); - setExit(1); - return; - } - - if ( srcMode == SM_F2F ) { - /* Save the file's meta-info before we open it. Doing it later - means we mess up the access times. */ - saveInputFileMetaInfo ( inName ); - } - - switch ( srcMode ) { - - case SM_I2O: - inStr = stdin; - outStr = stdout; - if ( isatty ( fileno ( stdout ) ) ) { - fprintf ( stderr, - "%s: I won't write compressed data to a terminal.\n", - progName ); - fprintf ( stderr, "%s: For help, type: `%s --help'.\n", - progName, progName ); - setExit(1); - return; - }; - break; - - case SM_F2O: - inStr = fopen ( inName, "rb" ); - outStr = stdout; - if ( isatty ( fileno ( stdout ) ) ) { - fprintf ( stderr, - "%s: I won't write compressed data to a terminal.\n", - progName ); - fprintf ( stderr, "%s: For help, type: `%s --help'.\n", - progName, progName ); - if ( inStr != NULL ) fclose ( inStr ); - setExit(1); - return; - }; - if ( inStr == NULL ) { - fprintf ( stderr, "%s: Can't open input file %s: %s.\n", - progName, inName, strerror(errno) ); - setExit(1); - return; - }; - break; - - case SM_F2F: - inStr = fopen ( inName, "rb" ); - outStr = fopen_output_safely ( outName, "wb" ); - if ( outStr == NULL) { - fprintf ( stderr, "%s: Can't create output file %s: %s.\n", - progName, outName, strerror(errno) ); - if ( inStr != NULL ) fclose ( inStr ); - setExit(1); - return; - } - if ( inStr == NULL ) { - fprintf ( stderr, "%s: Can't open input file %s: %s.\n", - progName, inName, strerror(errno) ); - if ( outStr != NULL ) fclose ( outStr ); - setExit(1); - return; - }; - break; - - default: - panic ( "compress: bad srcMode" ); - break; - } - - if (verbosity >= 1) { - fprintf ( stderr, " %s: ", inName ); - pad ( inName ); - fflush ( stderr ); - } - - /*--- Now the input and output handles are sane. Do the Biz. ---*/ - outputHandleJustInCase = outStr; - deleteOutputOnInterrupt = True; - compressStream ( inStr, outStr ); - outputHandleJustInCase = NULL; - - /*--- If there was an I/O error, we won't get here. ---*/ - if ( srcMode == SM_F2F ) { - applySavedTimeInfoToOutputFile ( outName ); - deleteOutputOnInterrupt = False; - if ( !keepInputFiles ) { - IntNative retVal = remove ( inName ); - ERROR_IF_NOT_ZERO ( retVal ); - } - } - - deleteOutputOnInterrupt = False; -} - - -/*---------------------------------------------*/ -static -void uncompress ( Char *name ) -{ - FILE *inStr; - FILE *outStr; - Int32 n, i; - Bool magicNumberOK; - Bool cantGuess; - struct MY_STAT statBuf; - - deleteOutputOnInterrupt = False; - - if (name == NULL && srcMode != SM_I2O) - panic ( "uncompress: bad modes\n" ); - - cantGuess = False; - switch (srcMode) { - case SM_I2O: - copyFileName ( inName, (Char*)"(stdin)" ); - copyFileName ( outName, (Char*)"(stdout)" ); - break; - case SM_F2F: - copyFileName ( inName, name ); - copyFileName ( outName, name ); - for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) - if (mapSuffix(outName,zSuffix[i],unzSuffix[i])) - goto zzz; - cantGuess = True; - strcat ( outName, ".out" ); - break; - case SM_F2O: - copyFileName ( inName, name ); - copyFileName ( outName, (Char*)"(stdout)" ); - break; - } - - zzz: - if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) { - if (noisy) - fprintf ( stderr, "%s: There are no files matching `%s'.\n", - progName, inName ); - setExit(1); - return; - } - if ( srcMode != SM_I2O && !fileExists ( inName ) ) { - fprintf ( stderr, "%s: Can't open input file %s: %s.\n", - progName, inName, strerror(errno) ); - setExit(1); - return; - } - if ( srcMode == SM_F2F || srcMode == SM_F2O ) { - MY_STAT(inName, &statBuf); - if ( MY_S_ISDIR(statBuf.st_mode) ) { - fprintf( stderr, - "%s: Input file %s is a directory.\n", - progName,inName); - setExit(1); - return; - } - } - if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) { - if (noisy) - fprintf ( stderr, "%s: Input file %s is not a normal file.\n", - progName, inName ); - setExit(1); - return; - } - if ( /* srcMode == SM_F2F implied && */ cantGuess ) { - if (noisy) - fprintf ( stderr, - "%s: Can't guess original name for %s -- using %s\n", - progName, inName, outName ); - /* just a warning, no return */ - } - if ( srcMode == SM_F2F && fileExists ( outName ) ) { - if (forceOverwrite) { - remove(outName); - } else { - fprintf ( stderr, "%s: Output file %s already exists.\n", - progName, outName ); - setExit(1); - return; - } - } - if ( srcMode == SM_F2F && !forceOverwrite && - (n=countHardLinks ( inName ) ) > 0) { - fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", - progName, inName, n, n > 1 ? "s" : "" ); - setExit(1); - return; - } - - if ( srcMode == SM_F2F ) { - /* Save the file's meta-info before we open it. Doing it later - means we mess up the access times. */ - saveInputFileMetaInfo ( inName ); - } - - switch ( srcMode ) { - - case SM_I2O: - inStr = stdin; - outStr = stdout; - if ( isatty ( fileno ( stdin ) ) ) { - fprintf ( stderr, - "%s: I won't read compressed data from a terminal.\n", - progName ); - fprintf ( stderr, "%s: For help, type: `%s --help'.\n", - progName, progName ); - setExit(1); - return; - }; - break; - - case SM_F2O: - inStr = fopen ( inName, "rb" ); - outStr = stdout; - if ( inStr == NULL ) { - fprintf ( stderr, "%s: Can't open input file %s:%s.\n", - progName, inName, strerror(errno) ); - if ( inStr != NULL ) fclose ( inStr ); - setExit(1); - return; - }; - break; - - case SM_F2F: - inStr = fopen ( inName, "rb" ); - outStr = fopen_output_safely ( outName, "wb" ); - if ( outStr == NULL) { - fprintf ( stderr, "%s: Can't create output file %s: %s.\n", - progName, outName, strerror(errno) ); - if ( inStr != NULL ) fclose ( inStr ); - setExit(1); - return; - } - if ( inStr == NULL ) { - fprintf ( stderr, "%s: Can't open input file %s: %s.\n", - progName, inName, strerror(errno) ); - if ( outStr != NULL ) fclose ( outStr ); - setExit(1); - return; - }; - break; - - default: - panic ( "uncompress: bad srcMode" ); - break; - } - - if (verbosity >= 1) { - fprintf ( stderr, " %s: ", inName ); - pad ( inName ); - fflush ( stderr ); - } - - /*--- Now the input and output handles are sane. Do the Biz. ---*/ - outputHandleJustInCase = outStr; - deleteOutputOnInterrupt = True; - magicNumberOK = uncompressStream ( inStr, outStr ); - outputHandleJustInCase = NULL; - - /*--- If there was an I/O error, we won't get here. ---*/ - if ( magicNumberOK ) { - if ( srcMode == SM_F2F ) { - applySavedTimeInfoToOutputFile ( outName ); - deleteOutputOnInterrupt = False; - if ( !keepInputFiles ) { - IntNative retVal = remove ( inName ); - ERROR_IF_NOT_ZERO ( retVal ); - } - } - } else { - unzFailsExist = True; - deleteOutputOnInterrupt = False; - if ( srcMode == SM_F2F ) { - IntNative retVal = remove ( outName ); - ERROR_IF_NOT_ZERO ( retVal ); - } - } - deleteOutputOnInterrupt = False; - - if ( magicNumberOK ) { - if (verbosity >= 1) - fprintf ( stderr, "done\n" ); - } else { - setExit(2); - if (verbosity >= 1) - fprintf ( stderr, "not a bzip2 file.\n" ); else - fprintf ( stderr, - "%s: %s is not a bzip2 file.\n", - progName, inName ); - } - -} - - -/*---------------------------------------------*/ -static -void testf ( Char *name ) -{ - FILE *inStr; - Bool allOK; - struct MY_STAT statBuf; - - deleteOutputOnInterrupt = False; - - if (name == NULL && srcMode != SM_I2O) - panic ( "testf: bad modes\n" ); - - copyFileName ( outName, (Char*)"(none)" ); - switch (srcMode) { - case SM_I2O: copyFileName ( inName, (Char*)"(stdin)" ); break; - case SM_F2F: copyFileName ( inName, name ); break; - case SM_F2O: copyFileName ( inName, name ); break; - } - - if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) { - if (noisy) - fprintf ( stderr, "%s: There are no files matching `%s'.\n", - progName, inName ); - setExit(1); - return; - } - if ( srcMode != SM_I2O && !fileExists ( inName ) ) { - fprintf ( stderr, "%s: Can't open input %s: %s.\n", - progName, inName, strerror(errno) ); - setExit(1); - return; - } - if ( srcMode != SM_I2O ) { - MY_STAT(inName, &statBuf); - if ( MY_S_ISDIR(statBuf.st_mode) ) { - fprintf( stderr, - "%s: Input file %s is a directory.\n", - progName,inName); - setExit(1); - return; - } - } - - switch ( srcMode ) { - - case SM_I2O: - if ( isatty ( fileno ( stdin ) ) ) { - fprintf ( stderr, - "%s: I won't read compressed data from a terminal.\n", - progName ); - fprintf ( stderr, "%s: For help, type: `%s --help'.\n", - progName, progName ); - setExit(1); - return; - }; - inStr = stdin; - break; - - case SM_F2O: case SM_F2F: - inStr = fopen ( inName, "rb" ); - if ( inStr == NULL ) { - fprintf ( stderr, "%s: Can't open input file %s:%s.\n", - progName, inName, strerror(errno) ); - setExit(1); - return; - }; - break; - - default: - panic ( "testf: bad srcMode" ); - break; - } - - if (verbosity >= 1) { - fprintf ( stderr, " %s: ", inName ); - pad ( inName ); - fflush ( stderr ); - } - - /*--- Now the input handle is sane. Do the Biz. ---*/ - outputHandleJustInCase = NULL; - allOK = testStream ( inStr ); - - if (allOK && verbosity >= 1) fprintf ( stderr, "ok\n" ); - if (!allOK) testFailsExist = True; -} - - -/*---------------------------------------------*/ -static -void license ( void ) -{ - fprintf ( stderr, - - "bzip2, a block-sorting file compressor. " - "Version %s.\n" - " \n" - " Copyright (C) 1996-2010 by Julian Seward.\n" - " \n" - " This program is free software; you can redistribute it and/or modify\n" - " it under the terms set out in the LICENSE file, which is included\n" - " in the bzip2-1.0.6 source distribution.\n" - " \n" - " This program is distributed in the hope that it will be useful,\n" - " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - " LICENSE file for more details.\n" - " \n", - BZ2_bzlibVersion() - ); -} - - -/*---------------------------------------------*/ -static -void usage ( Char *fullProgName ) -{ - fprintf ( - stderr, - "bzip2, a block-sorting file compressor. " - "Version %s.\n" - "\n usage: %s [flags and input files in any order]\n" - "\n" - " -h --help print this message\n" - " -d --decompress force decompression\n" - " -z --compress force compression\n" - " -k --keep keep (don't delete) input files\n" - " -f --force overwrite existing output files\n" - " -t --test test compressed file integrity\n" - " -c --stdout output to standard out\n" - " -q --quiet suppress noncritical error messages\n" - " -v --verbose be verbose (a 2nd -v gives more)\n" - " -L --license display software version & license\n" - " -V --version display software version & license\n" - " -s --small use less memory (at most 2500k)\n" - " -1 .. -9 set block size to 100k .. 900k\n" - " --fast alias for -1\n" - " --best alias for -9\n" - "\n" - " If invoked as `bzip2', default action is to compress.\n" - " as `bunzip2', default action is to decompress.\n" - " as `bzcat', default action is to decompress to stdout.\n" - "\n" - " If no file names are given, bzip2 compresses or decompresses\n" - " from standard input to standard output. You can combine\n" - " short flags, so `-v -4' means the same as -v4 or -4v, &c.\n" -# if BZ_UNIX - "\n" -# endif - , - - BZ2_bzlibVersion(), - fullProgName - ); -} - - -/*---------------------------------------------*/ -static -void redundant ( Char* flag ) -{ - fprintf ( - stderr, - "%s: %s is redundant in versions 0.9.5 and above\n", - progName, flag ); -} - - -/*---------------------------------------------*/ -/*-- - All the garbage from here to main() is purely to - implement a linked list of command-line arguments, - into which main() copies argv[1 .. argc-1]. - - The purpose of this exercise is to facilitate - the expansion of wildcard characters * and ? in - filenames for OSs which don't know how to do it - themselves, like MSDOS, Windows 95 and NT. - - The actual Dirty Work is done by the platform- - specific macro APPEND_FILESPEC. ---*/ - -typedef - struct zzzz { - Char *name; - struct zzzz *link; - } - Cell; - - -/*---------------------------------------------*/ -static -void *myMalloc ( Int32 n ) -{ - void* p; - - p = malloc ( (size_t)n ); - if (p == NULL) outOfMemory (); - return p; -} - - -/*---------------------------------------------*/ -static -Cell *mkCell ( void ) -{ - Cell *c; - - c = (Cell*) myMalloc ( sizeof ( Cell ) ); - c->name = NULL; - c->link = NULL; - return c; -} - - -/*---------------------------------------------*/ -static -Cell *snocString ( Cell *root, Char *name ) -{ - if (root == NULL) { - Cell *tmp = mkCell(); - tmp->name = (Char*) myMalloc ( 5 + strlen(name) ); - strcpy ( tmp->name, name ); - return tmp; - } else { - Cell *tmp = root; - while (tmp->link != NULL) tmp = tmp->link; - tmp->link = snocString ( tmp->link, name ); - return root; - } -} - - -/*---------------------------------------------*/ -static -void addFlagsFromEnvVar ( Cell** argList, Char* varName ) -{ - Int32 i, j, k; - Char *envbase, *p; - - envbase = getenv(varName); - if (envbase != NULL) { - p = envbase; - i = 0; - while (True) { - if (p[i] == 0) break; - p += i; - i = 0; - while (isspace((Int32)(p[0]))) p++; - while (p[i] != 0 && !isspace((Int32)(p[i]))) i++; - if (i > 0) { - k = i; if (k > FILE_NAME_LEN-10) k = FILE_NAME_LEN-10; - for (j = 0; j < k; j++) tmpName[j] = p[j]; - tmpName[k] = 0; - APPEND_FLAG(*argList, tmpName); - } - } - } -} - - -/*---------------------------------------------*/ -#define ISFLAG(s) (strcmp(aa->name, (s))==0) - -IntNative main ( IntNative argc, Char *argv[] ) -{ - Int32 i, j; - Char *tmp; - Cell *argList; - Cell *aa; - Bool decode; - - /*-- Be really really really paranoid :-) --*/ - if (sizeof(Int32) != 4 || sizeof(UInt32) != 4 || - sizeof(Int16) != 2 || sizeof(UInt16) != 2 || - sizeof(Char) != 1 || sizeof(UChar) != 1) - configError(); - - /*-- Initialise --*/ - outputHandleJustInCase = NULL; - smallMode = False; - keepInputFiles = False; - forceOverwrite = False; - noisy = True; - verbosity = 0; - blockSize100k = 9; - testFailsExist = False; - unzFailsExist = False; - numFileNames = 0; - numFilesProcessed = 0; - workFactor = 30; - deleteOutputOnInterrupt = False; - exitValue = 0; - i = j = 0; /* avoid bogus warning from egcs-1.1.X */ - - /*-- Set up signal handlers for mem access errors --*/ - signal (SIGSEGV, mySIGSEGVorSIGBUScatcher); -# if BZ_UNIX -# ifndef __DJGPP__ - signal (SIGBUS, mySIGSEGVorSIGBUScatcher); -# endif -# endif - - copyFileName ( inName, (Char*)"(none)" ); - copyFileName ( outName, (Char*)"(none)" ); - - copyFileName ( progNameReally, argv[0] ); - progName = &progNameReally[0]; - for (tmp = &progNameReally[0]; *tmp != '\0'; tmp++) - if (*tmp == PATH_SEP) progName = tmp + 1; - - - /*-- Copy flags from env var BZIP2, and - expand filename wildcards in arg list. - --*/ - argList = NULL; - addFlagsFromEnvVar ( &argList, (Char*)"BZIP2" ); - addFlagsFromEnvVar ( &argList, (Char*)"BZIP" ); - for (i = 1; i <= argc-1; i++) - APPEND_FILESPEC(argList, argv[i]); - - - /*-- Find the length of the longest filename --*/ - longestFileName = 7; - numFileNames = 0; - decode = True; - for (aa = argList; aa != NULL; aa = aa->link) { - if (ISFLAG("--")) { decode = False; continue; } - if (aa->name[0] == '-' && decode) continue; - numFileNames++; - if (longestFileName < (Int32)strlen(aa->name) ) - longestFileName = (Int32)strlen(aa->name); - } - - - /*-- Determine source modes; flag handling may change this too. --*/ - if (numFileNames == 0) - srcMode = SM_I2O; else srcMode = SM_F2F; - - - /*-- Determine what to do (compress/uncompress/test/cat). --*/ - /*-- Note that subsequent flag handling may change this. --*/ - opMode = OM_Z; - - if ( (strstr ( progName, "unzip" ) != 0) || - (strstr ( progName, "UNZIP" ) != 0) ) - opMode = OM_UNZ; - - if ( (strstr ( progName, "z2cat" ) != 0) || - (strstr ( progName, "Z2CAT" ) != 0) || - (strstr ( progName, "zcat" ) != 0) || - (strstr ( progName, "ZCAT" ) != 0) ) { - opMode = OM_UNZ; - srcMode = (numFileNames == 0) ? SM_I2O : SM_F2O; - } - - - /*-- Look at the flags. --*/ - for (aa = argList; aa != NULL; aa = aa->link) { - if (ISFLAG("--")) break; - if (aa->name[0] == '-' && aa->name[1] != '-') { - for (j = 1; aa->name[j] != '\0'; j++) { - switch (aa->name[j]) { - case 'c': srcMode = SM_F2O; break; - case 'd': opMode = OM_UNZ; break; - case 'z': opMode = OM_Z; break; - case 'f': forceOverwrite = True; break; - case 't': opMode = OM_TEST; break; - case 'k': keepInputFiles = True; break; - case 's': smallMode = True; break; - case 'q': noisy = False; break; - case '1': blockSize100k = 1; break; - case '2': blockSize100k = 2; break; - case '3': blockSize100k = 3; break; - case '4': blockSize100k = 4; break; - case '5': blockSize100k = 5; break; - case '6': blockSize100k = 6; break; - case '7': blockSize100k = 7; break; - case '8': blockSize100k = 8; break; - case '9': blockSize100k = 9; break; - case 'V': - case 'L': license(); break; - case 'v': verbosity++; break; - case 'h': usage ( progName ); - exit ( 0 ); - break; - default: fprintf ( stderr, "%s: Bad flag `%s'\n", - progName, aa->name ); - usage ( progName ); - exit ( 1 ); - break; - } - } - } - } - - /*-- And again ... --*/ - for (aa = argList; aa != NULL; aa = aa->link) { - if (ISFLAG("--")) break; - if (ISFLAG("--stdout")) srcMode = SM_F2O; else - if (ISFLAG("--decompress")) opMode = OM_UNZ; else - if (ISFLAG("--compress")) opMode = OM_Z; else - if (ISFLAG("--force")) forceOverwrite = True; else - if (ISFLAG("--test")) opMode = OM_TEST; else - if (ISFLAG("--keep")) keepInputFiles = True; else - if (ISFLAG("--small")) smallMode = True; else - if (ISFLAG("--quiet")) noisy = False; else - if (ISFLAG("--version")) license(); else - if (ISFLAG("--license")) license(); else - if (ISFLAG("--exponential")) workFactor = 1; else - if (ISFLAG("--repetitive-best")) redundant(aa->name); else - if (ISFLAG("--repetitive-fast")) redundant(aa->name); else - if (ISFLAG("--fast")) blockSize100k = 1; else - if (ISFLAG("--best")) blockSize100k = 9; else - if (ISFLAG("--verbose")) verbosity++; else - if (ISFLAG("--help")) { usage ( progName ); exit ( 0 ); } - else - if (strncmp ( aa->name, "--", 2) == 0) { - fprintf ( stderr, "%s: Bad flag `%s'\n", progName, aa->name ); - usage ( progName ); - exit ( 1 ); - } - } - - if (verbosity > 4) verbosity = 4; - if (opMode == OM_Z && smallMode && blockSize100k > 2) - blockSize100k = 2; - - if (opMode == OM_TEST && srcMode == SM_F2O) { - fprintf ( stderr, "%s: -c and -t cannot be used together.\n", - progName ); - exit ( 1 ); - } - - if (srcMode == SM_F2O && numFileNames == 0) - srcMode = SM_I2O; - - if (opMode != OM_Z) blockSize100k = 0; - - if (srcMode == SM_F2F) { - signal (SIGINT, mySignalCatcher); - signal (SIGTERM, mySignalCatcher); -# if BZ_UNIX - signal (SIGHUP, mySignalCatcher); -# endif - } - - if (opMode == OM_Z) { - if (srcMode == SM_I2O) { - compress ( NULL ); - } else { - decode = True; - for (aa = argList; aa != NULL; aa = aa->link) { - if (ISFLAG("--")) { decode = False; continue; } - if (aa->name[0] == '-' && decode) continue; - numFilesProcessed++; - compress ( aa->name ); - } - } - } - else - - if (opMode == OM_UNZ) { - unzFailsExist = False; - if (srcMode == SM_I2O) { - uncompress ( NULL ); - } else { - decode = True; - for (aa = argList; aa != NULL; aa = aa->link) { - if (ISFLAG("--")) { decode = False; continue; } - if (aa->name[0] == '-' && decode) continue; - numFilesProcessed++; - uncompress ( aa->name ); - } - } - if (unzFailsExist) { - setExit(2); - exit(exitValue); - } - } - - else { - testFailsExist = False; - if (srcMode == SM_I2O) { - testf ( NULL ); - } else { - decode = True; - for (aa = argList; aa != NULL; aa = aa->link) { - if (ISFLAG("--")) { decode = False; continue; } - if (aa->name[0] == '-' && decode) continue; - numFilesProcessed++; - testf ( aa->name ); - } - } - if (testFailsExist && noisy) { - fprintf ( stderr, - "\n" - "You can use the `bzip2recover' program to attempt to recover\n" - "data from undamaged sections of corrupted files.\n\n" - ); - setExit(2); - exit(exitValue); - } - } - - /* Free the argument list memory to mollify leak detectors - (eg) Purify, Checker. Serves no other useful purpose. - */ - aa = argList; - while (aa != NULL) { - Cell* aa2 = aa->link; - if (aa->name != NULL) free(aa->name); - free(aa); - aa = aa2; - } - - return exitValue; -} - - -/*-----------------------------------------------------------*/ -/*--- end bzip2.c ---*/ -/*-----------------------------------------------------------*/ diff --git a/recipes/bzip2/all/test_v1_package/CMakeLists.txt b/recipes/bzip2/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/bzip2/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/bzip2/all/test_v1_package/conanfile.py b/recipes/bzip2/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/bzip2/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bzip3/all/CMakeLists.txt b/recipes/bzip3/all/CMakeLists.txt new file mode 100644 index 0000000000000..f58db5b429ac9 --- /dev/null +++ b/recipes/bzip3/all/CMakeLists.txt @@ -0,0 +1,68 @@ +cmake_minimum_required(VERSION 3.4) +project(bzip3 LANGUAGES C) + +option(BZIP3_WITH_THREAD "enable thread" OFF) +option(BZIP3_WITH_UTIL "build and install utility" OFF) + +set(BZIP3_INC + ${BZIP3_SRC_DIR}/include/libbz3.h +) + +add_library(bzip3) + +if (BZIP3_VERSION VERSION_GREATER_EQUAL "1.1.5") +target_sources(bzip3 PRIVATE + ${BZIP3_SRC_DIR}/src/libbz3.c +) +else() +target_sources(bzip3 PRIVATE + ${BZIP3_SRC_DIR}/src/cm.c + ${BZIP3_SRC_DIR}/src/crc32.c + ${BZIP3_SRC_DIR}/src/libbz3.c + ${BZIP3_SRC_DIR}/src/libsais.c + ${BZIP3_SRC_DIR}/src/lzp.c + ${BZIP3_SRC_DIR}/src/rle.c +) +endif() +target_include_directories(bzip3 PUBLIC ${BZIP3_SRC_DIR}/include) +set_target_properties(bzip3 PROPERTIES + PUBLIC_HEADER "${BZIP3_INC}" + C_VISIBILITY_PRESET hidden + C_EXTENSIONS OFF +) +if (BZIP3_VERSION VERSION_GREATER_EQUAL "1.1.6" AND (MSVC OR MSVC90 OR MSVC10) AND BUILD_SHARED_LIBS) + target_compile_definitions(bzip3 PRIVATE "BZIP3_DLL_EXPORT=1") +endif() + +if (BZIP3_VERSION VERSION_GREATER_EQUAL "1.1.7") + target_compile_definitions(bzip3 PRIVATE "VERSION=\"${BZIP3_VERSION}\"") +endif() + +if (BZIP3_WITH_THREAD) + find_package(Threads REQUIRED) + target_link_libraries(bzip3 PRIVATE Threads::Threads) + target_compile_definitions(bzip3 PRIVATE "PTHREAD") +endif() + +if (BZIP3_WITH_UTIL) + add_executable(bzip3_cmd ${BZIP3_SRC_DIR}/src/main.c) + target_link_libraries(bzip3_cmd bzip3) + target_compile_definitions(bzip3_cmd PRIVATE "VERSION=\"${BZIP3_VERSION}\"") + set_target_properties(bzip3_cmd PROPERTIES OUTPUT_NAME "bzip3") +endif() + +find_library(LIBM m) +target_link_libraries(bzip3 PRIVATE $<$:${LIBM}>) + +include(GNUInstallDirs) +install( + TARGETS bzip3 + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +if (BZIP3_WITH_UTIL) + install(TARGETS bzip3_cmd DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/recipes/bzip3/all/conandata.yml b/recipes/bzip3/all/conandata.yml new file mode 100644 index 0000000000000..793290248520a --- /dev/null +++ b/recipes/bzip3/all/conandata.yml @@ -0,0 +1,28 @@ +sources: + "1.2.1": + url: "https://github.com/kspalaiologos/bzip3/archive/1.2.1.tar.gz" + sha256: "f2fc4c9c7679d3b120e8f44d8c4ecd00f03af9981f53e13dc0f956b5996913c9" + "1.2.0": + url: "https://github.com/kspalaiologos/bzip3/archive/1.2.0.tar.gz" + sha256: "6f9bd935ac1e845cb49e64ad23969db914e4760dad7feec0995f5cdbd336c10d" + "1.1.8": + url: "https://github.com/kspalaiologos/bzip3/releases/download/1.1.8/bzip3-1.1.8.tar.bz2" + sha256: "bc15d0e4599aad18d9ed71ee0f7e859af89051bf5105b0751e8ca3a26117567d" + "1.1.7": + url: "https://github.com/kspalaiologos/bzip3/releases/download/1.1.7/bzip3-1.1.7.tar.bz2" + sha256: "1f74768dd1a76c45417f84779cc04d8d8b1f595ac564a2ea2aeb0248defca803" + "1.1.6": + url: "https://github.com/kspalaiologos/bzip3/releases/download/1.1.6/bzip3-1.1.6.tar.bz2" + sha256: "2bfd35dd57ab80b35b25e3ad628e0ff8f1f5e6dea02a8d472914823ea2e07e96" + "1.1.5": + url: "https://github.com/kspalaiologos/bzip3/releases/download/1.1.5/bzip3-1.1.5.tar.bz2" + sha256: "2f5012b0004b6c23d5f606deed9191fdce44849234edbcf26e0316bf7856d114" + "1.1.4": + url: "https://github.com/kspalaiologos/bzip3/releases/download/1.1.4/bzip3-1.1.4.tar.bz2" + sha256: "e23a06ae17fc36192e79d0151950b3bbd4e26381af50ba4b4fd7a2d9797e498f" +patches: + "1.1.5": + - patch_file: "patches/1.1.5-0002-export-symbols.patch" + "1.1.4": + - patch_file: "patches/1.1.4-0001-make-restrict-alias.patch" + - patch_file: "patches/1.1.4-0002-export-symbols.patch" diff --git a/recipes/bzip3/all/conanfile.py b/recipes/bzip3/all/conanfile.py new file mode 100644 index 0000000000000..118e5fbf34f0c --- /dev/null +++ b/recipes/bzip3/all/conanfile.py @@ -0,0 +1,90 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import export_conandata_patches, apply_conandata_patches, copy, get +import os + +required_conan_version = ">=1.52.0" + + +class BZip3Conan(ConanFile): + name = "bzip3" + description = "A better and stronger spiritual successor to BZip2." + license = "LGPL-3.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/kspalaiologos/bzip3" + topics = ("bzip2", "lzma", "compression") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_thread": [True, False], + "with_util": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_thread": True, + "with_util": False, + } + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + # FIXME: could be supported on Windows: + # - MinGW with posix thread supports it out of the box + # - otherwise, add pthreads4w to requirements and link it in CMakeLists + if self.settings.os == "Windows": + del self.options.with_thread + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BZIP3_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["BZIP3_WITH_PTHREAD"] = self.options.get_safe("with_thread", False) + tc.variables["BZIP3_WITH_UTIL"] = self.options.with_util + tc.variables["BZIP3_VERSION"] = self.version + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "*LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "bzip3") + self.cpp_info.libs = ["bzip3"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + if self.options.get_safe("with_thread", False): + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/bzip3/all/patches/1.1.4-0001-make-restrict-alias.patch b/recipes/bzip3/all/patches/1.1.4-0001-make-restrict-alias.patch new file mode 100644 index 0000000000000..20195b834da7b --- /dev/null +++ b/recipes/bzip3/all/patches/1.1.4-0001-make-restrict-alias.patch @@ -0,0 +1,114 @@ +diff --git a/src/crc32.c b/src/crc32.c +index 856fcd4..d9fb87a 100644 +--- a/src/crc32.c ++++ b/src/crc32.c +@@ -19,6 +19,14 @@ + + #include "crc32.h" + ++#if defined(__GNUC__) || defined(__clang__) ++ #define RESTRICT __restrict__ ++#elif defined(_MSC_VER) || defined(__INTEL_COMPILER) ++ #define RESTRICT __restrict ++#else ++ #error Your compiler, configuration or platform is not supported. ++#endif ++ + static const u32 crc32Table[256] = { + 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, 0x8AD958CFL, + 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL, 0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L, 0x105EC76FL, 0xE235446CL, +@@ -51,7 +59,7 @@ static const u32 crc32Table[256] = { + 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L + }; + +-u32 crc32sum(u32 crc, u8 * restrict buf, size_t size) { ++u32 crc32sum(u32 crc, u8 * RESTRICT buf, size_t size) { + while (size--) crc = crc32Table[(crc ^ *(buf++)) & 0xff] ^ (crc >> 8); + return crc; + } +diff --git a/src/lzp.c b/src/lzp.c +index c19580d..2206673 100644 +--- a/src/lzp.c ++++ b/src/lzp.c +@@ -11,8 +11,16 @@ + + #define MATCH 0xf2 + +-static s32 lzp_encode_block(const u8 * restrict in, const u8 * in_end, u8 * restrict out, u8 * out_end, +- s32 * restrict lut, s32 mask, s32 m_len) { ++#if defined(__GNUC__) || defined(__clang__) ++ #define RESTRICT __restrict__ ++#elif defined(_MSC_VER) || defined(__INTEL_COMPILER) ++ #define RESTRICT __restrict ++#else ++ #error Your compiler, configuration or platform is not supported. ++#endif ++ ++static s32 lzp_encode_block(const u8 * RESTRICT in, const u8 * in_end, u8 * RESTRICT out, u8 * out_end, ++ s32 * RESTRICT lut, s32 mask, s32 m_len) { + const u8 *ins = in, *outs = out; + const u8 * out_eob = out_end - 8; + const u8 * heur = in; +@@ -28,7 +36,7 @@ static s32 lzp_encode_block(const u8 * restrict in, const u8 * in_end, u8 * rest + s32 val = lut[idx]; + lut[idx] = in - ins; + if (val > 0) { +- const u8 * restrict ref = ins + val; ++ const u8 * RESTRICT ref = ins + val; + if (memcmp(in + m_len - 4, ref + m_len - 4, sizeof(u32)) == 0 && memcmp(in, ref, sizeof(u32)) == 0) { + if (heur > in && *(u32 *)heur != *(u32 *)(ref + (heur - in))) goto not_found; + +@@ -85,7 +93,7 @@ static s32 lzp_encode_block(const u8 * restrict in, const u8 * in_end, u8 * rest + return out >= out_eob ? -1 : (s32)(out - outs); + } + +-static s32 lzp_decode_block(const u8 * restrict in, const u8 * in_end, s32 * restrict lut, u8 * restrict out, s32 hash, ++static s32 lzp_decode_block(const u8 * RESTRICT in, const u8 * in_end, s32 * RESTRICT lut, u8 * RESTRICT out, s32 hash, + s32 m_len) { + if (in_end - in < 4) return -1; + +@@ -129,7 +137,7 @@ static s32 lzp_decode_block(const u8 * restrict in, const u8 * in_end, s32 * res + return out - outs; + } + +-s32 lzp_compress(const u8 * restrict in, u8 * restrict out, s32 n, s32 hash, s32 m_len, s32 * restrict lut) { ++s32 lzp_compress(const u8 * RESTRICT in, u8 * RESTRICT out, s32 n, s32 hash, s32 m_len, s32 * RESTRICT lut) { + if (n - m_len < 32) return -1; + + memset(lut, 0, sizeof(s32) * (1 << hash)); +@@ -137,6 +145,6 @@ s32 lzp_compress(const u8 * restrict in, u8 * restrict out, s32 n, s32 hash, s32 + return lzp_encode_block(in, in + n, out, out + n, lut, (s32)(1 << hash) - 1, m_len); + } + +-s32 lzp_decompress(const u8 * restrict in, u8 * restrict out, s32 n, s32 hash, s32 m_len, s32 * restrict lut) { ++s32 lzp_decompress(const u8 * RESTRICT in, u8 * RESTRICT out, s32 n, s32 hash, s32 m_len, s32 * RESTRICT lut) { + return lzp_decode_block(in, in + n, lut, out, hash, m_len); + } +diff --git a/src/rle.c b/src/rle.c +index b1f0340..2cb2e53 100644 +--- a/src/rle.c ++++ b/src/rle.c +@@ -19,6 +19,14 @@ + + #include "rle.h" + ++#if defined(__GNUC__) || defined(__clang__) ++ #define RESTRICT __restrict__ ++#elif defined(_MSC_VER) || defined(__INTEL_COMPILER) ++ #define RESTRICT __restrict ++#else ++ #error Your compiler, configuration or platform is not supported. ++#endif ++ + s32 mrlec(u8 * in, s32 inlen, u8 * out) { + u8 *ip = in, *in_end = in + inlen; + s32 op = 0; +@@ -57,7 +65,7 @@ s32 mrlec(u8 * in, s32 inlen, u8 * out) { + return op; + } + +-void mrled(u8 * restrict in, u8 * restrict out, s32 outlen) { ++void mrled(u8 * RESTRICT in, u8 * RESTRICT out, s32 outlen) { + s32 op = 0, ip = 0; + + s32 c, pc = -1; diff --git a/recipes/bzip3/all/patches/1.1.4-0002-export-symbols.patch b/recipes/bzip3/all/patches/1.1.4-0002-export-symbols.patch new file mode 100644 index 0000000000000..3bdf13582cc59 --- /dev/null +++ b/recipes/bzip3/all/patches/1.1.4-0002-export-symbols.patch @@ -0,0 +1,95 @@ +--- a/include/common.h ++++ b/include/common.h +@@ -46,10 +46,6 @@ static void write_neutral_s32(u8 * data, s32 value) { + data[3] = (value >> 24) & 0xFF; + } + +-#ifdef __MINGW32__ +- #define PUBLIC_API __declspec(dllexport) +-#else +- #define PUBLIC_API +-#endif ++#define PUBLIC_API + + #endif +--- a/include/libbz3.h ++++ b/include/libbz3.h +@@ -22,6 +22,16 @@ + + #include + ++#ifdef bzip3_EXPORTS ++#ifdef _WIN32 ++ #define BZIP3_API __declspec(dllexport) ++#else ++ #define BZIP3_API __attribute__((visibility("default"))) ++#endif ++#else ++ #define BZIP3_API ++#endif ++ + #define BZ3_OK 0 + #define BZ3_ERR_OUT_OF_BOUNDS -1 + #define BZ3_ERR_BWT -2 +@@ -35,31 +45,31 @@ struct bz3_state; + /** + * @brief Get the last error number associated with a given state. + */ +-int8_t bz3_last_error(struct bz3_state * state); ++BZIP3_API int8_t bz3_last_error(struct bz3_state * state); + + /** + * @brief Return a user-readable message explaining the cause of the last error. + */ +-const char * bz3_strerror(struct bz3_state * state); ++BZIP3_API const char * bz3_strerror(struct bz3_state * state); + + /** + * @brief Construct a new block encoder state, which will encode blocks as big as the given block size. + * The decoder will be able to decode blocks at most as big as the given block size. + * Returns NULL in case allocation fails or the block size is not between 65K and 511M + */ +-struct bz3_state * bz3_new(int32_t block_size); ++BZIP3_API struct bz3_state * bz3_new(int32_t block_size); + + /** + * @brief Free the memory occupied by a block encoder state. + */ +-void bz3_free(struct bz3_state * state); ++BZIP3_API void bz3_free(struct bz3_state * state); + + /** + * @brief Encode a single block. Returns the amount of bytes written to `buffer'. + * `buffer' must be able to hold at least `size + size / 50 + 32' bytes. The size must not + * exceed the block size associated with the state. + */ +-int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t size); ++BZIP3_API int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t size); + + /** + * @brief Decode a single block. +@@ -68,7 +78,7 @@ int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t siz + * @param size The size of the compressed data in `buffer' + * @param orig_size The original size of the data before compression. + */ +-int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t size, int32_t orig_size); ++BZIP3_API int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t size, int32_t orig_size); + + /** + * @brief Encode `n' blocks, all in parallel. +@@ -80,13 +90,13 @@ int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t siz + * + * Present in the shared library only if -lpthread was present during building. + */ +-void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n); ++BZIP3_API void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n); + + /** + * @brief Decode `n' blocks, all in parallel. + * Same specifics as `bz3_encode_blocks', but doesn't overwrite `sizes'. + */ +-void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t orig_sizes[], ++BZIP3_API void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t orig_sizes[], + int32_t n); + + #endif diff --git a/recipes/bzip3/all/patches/1.1.5-0002-export-symbols.patch b/recipes/bzip3/all/patches/1.1.5-0002-export-symbols.patch new file mode 100644 index 0000000000000..e76dc6e0d184e --- /dev/null +++ b/recipes/bzip3/all/patches/1.1.5-0002-export-symbols.patch @@ -0,0 +1,83 @@ +diff --git a/include/libbz3.h b/include/libbz3.h +index a5ac58a..a9b13fd 100644 +--- a/include/libbz3.h ++++ b/include/libbz3.h +@@ -22,6 +22,16 @@ + + #include + ++#ifdef bzip3_EXPORTS ++#ifdef _WIN32 ++ #define BZIP3_API __declspec(dllexport) ++#else ++ #define BZIP3_API __attribute__((visibility("default"))) ++#endif ++#else ++ #define BZIP3_API ++#endif ++ + #define BZ3_OK 0 + #define BZ3_ERR_OUT_OF_BOUNDS -1 + #define BZ3_ERR_BWT -2 +@@ -35,31 +45,31 @@ struct bz3_state; + /** + * @brief Get the last error number associated with a given state. + */ +-int8_t bz3_last_error(struct bz3_state * state); ++BZIP3_API int8_t bz3_last_error(struct bz3_state * state); + + /** + * @brief Return a user-readable message explaining the cause of the last error. + */ +-const char * bz3_strerror(struct bz3_state * state); ++BZIP3_API const char * bz3_strerror(struct bz3_state * state); + + /** + * @brief Construct a new block encoder state, which will encode blocks as big as the given block size. + * The decoder will be able to decode blocks at most as big as the given block size. + * Returns NULL in case allocation fails or the block size is not between 65K and 511M + */ +-struct bz3_state * bz3_new(int32_t block_size); ++BZIP3_API struct bz3_state * bz3_new(int32_t block_size); + + /** + * @brief Free the memory occupied by a block encoder state. + */ +-void bz3_free(struct bz3_state * state); ++BZIP3_API void bz3_free(struct bz3_state * state); + + /** + * @brief Encode a single block. Returns the amount of bytes written to `buffer'. + * `buffer' must be able to hold at least `size + size / 50 + 32' bytes. The size must not + * exceed the block size associated with the state. + */ +-int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t size); ++BZIP3_API int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t size); + + /** + * @brief Decode a single block. +@@ -68,7 +78,7 @@ int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t siz + * @param size The size of the compressed data in `buffer' + * @param orig_size The original size of the data before compression. + */ +-int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t size, int32_t orig_size); ++BZIP3_API int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t size, int32_t orig_size); + + /** + * @brief Encode `n' blocks, all in parallel. +@@ -80,13 +90,13 @@ int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t siz + * + * Present in the shared library only if -lpthread was present during building. + */ +-void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n); ++BZIP3_API void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n); + + /** + * @brief Decode `n' blocks, all in parallel. + * Same specifics as `bz3_encode_blocks', but doesn't overwrite `sizes'. + */ +-void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t orig_sizes[], ++BZIP3_API void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t orig_sizes[], + int32_t n); + + #endif diff --git a/recipes/bzip3/all/test_package/CMakeLists.txt b/recipes/bzip3/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e47e03f4174fe --- /dev/null +++ b/recipes/bzip3/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(bzip3 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE bzip3::bzip3) diff --git a/recipes/bzip3/all/test_package/conanfile.py b/recipes/bzip3/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/bzip3/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bzip3/all/test_package/test_package.c b/recipes/bzip3/all/test_package/test_package.c new file mode 100644 index 0000000000000..a93ba92b22e72 --- /dev/null +++ b/recipes/bzip3/all/test_package/test_package.c @@ -0,0 +1,13 @@ +#include +#include + +#include "libbz3.h" + +int main() { + const unsigned int block_size = 8 * 1024 * 1024; + struct bz3_state * state = bz3_new(block_size); + + bz3_free(state); + + return 0; +} diff --git a/recipes/bzip3/all/test_v1_package/CMakeLists.txt b/recipes/bzip3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..8c1771e7b1081 --- /dev/null +++ b/recipes/bzip3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bzip3 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE bzip3::bzip3) diff --git a/recipes/bzip3/all/test_v1_package/conanfile.py b/recipes/bzip3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/bzip3/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bzip3/config.yml b/recipes/bzip3/config.yml new file mode 100644 index 0000000000000..a95d0b82239d8 --- /dev/null +++ b/recipes/bzip3/config.yml @@ -0,0 +1,15 @@ +versions: + "1.2.1": + folder: all + "1.2.0": + folder: all + "1.1.8": + folder: all + "1.1.7": + folder: all + "1.1.6": + folder: all + "1.1.5": + folder: all + "1.1.4": + folder: all diff --git a/recipes/c-ares/all/conandata.yml b/recipes/c-ares/all/conandata.yml index 6374181280d1b..245e6d426beea 100644 --- a/recipes/c-ares/all/conandata.yml +++ b/recipes/c-ares/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.18.1": + url: "https://github.com/c-ares/c-ares/releases/download/cares-1_18_1/c-ares-1.18.1.tar.gz" + sha256: "1a7d52a8a84a9fbffb1be9133c0f6e17217d91ea5a6fa61f6b4729cda78ebbcf" + "1.17.2": + sha256: 444b7dbf33cb6e8a764d069e3485cbaaa28386d60eace6988275c3cb9534d300 + url: https://github.com/c-ares/c-ares/archive/refs/tags/cares-1_17_2.tar.gz "1.17.1": sha256: 61f7cf09605f5e38d4828f82d0e2ddb9de8e355ecfd6819b740691c644583b8f url: https://github.com/c-ares/c-ares/archive/cares-1_17_1.tar.gz @@ -14,15 +20,10 @@ sources: patches: "1.17.1": - patch_file: "patches/upstream-pr-395-bundle-destination-v16-17.patch" - base_path: "source_subfolder" "1.16.1": - patch_file: "patches/upstream-pr-395-bundle-destination-v16-17.patch" - base_path: "source_subfolder" "1.15.0": - patch_file: "patches/upstream-pr-395-bundle-destination-v15.patch" - base_path: "source_subfolder" "1.14.0": - patch_file: "patches/option-tools.patch" - base_path: "source_subfolder" - patch_file: "patches/upstream-pr-395-bundle-destination-v14.patch" - base_path: "source_subfolder" diff --git a/recipes/c-ares/all/conanfile.py b/recipes/c-ares/all/conanfile.py index 193224cb99d86..d8b3c1bbab956 100644 --- a/recipes/c-ares/all/conanfile.py +++ b/recipes/c-ares/all/conanfile.py @@ -1,7 +1,11 @@ +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get, rm, rmdir +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.51.3" class CAresConan(ConanFile): @@ -9,31 +13,24 @@ class CAresConan(ConanFile): license = "MIT" url = "https://github.com/conan-io/conan-center-index" description = "A C library for asynchronous DNS requests" - topics = ("conan", "c-ares", "dns") + topics = ("c-ares", "dns") homepage = "https://c-ares.haxx.se/" - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "tools": [True, False] + "tools": [True, False], } default_options = { "shared": False, "fPIC": True, - "tools": True + "tools": True, } - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -42,56 +39,73 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("c-ares-cares-{}".format(self.version.replace(".", "_")), self._source_subfolder) - - def _cmake_configure(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CARES_STATIC"] = not self.options.shared - self._cmake.definitions["CARES_SHARED"] = self.options.shared - self._cmake.definitions["CARES_BUILD_TESTS"] = False - self._cmake.definitions["CARES_MSVC_STATIC_RUNTIME"] = False - self._cmake.definitions["CARES_BUILD_TOOLS"] = self.options.tools - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CARES_STATIC"] = not self.options.shared + tc.variables["CARES_SHARED"] = self.options.shared + tc.variables["CARES_BUILD_TESTS"] = False + tc.variables["CARES_MSVC_STATIC_RUNTIME"] = False + tc.variables["CARES_BUILD_TOOLS"] = self.options.tools + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._cmake_configure() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._cmake_configure() + copy(self, "*LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy("*LICENSE.md", src=self._source_subfolder, dst="licenses", keep_path=False) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) def package_info(self): - self.cpp_info.names["pkg_config"] = "libcares" - self.cpp_info.components["cares"].names["cmake_find_package"] = "cares" - self.cpp_info.components["cares"].names["cmake_find_package_multi"] = "cares" - self.cpp_info.components["cares"].names["pkg_config"] = "libcares" - self.cpp_info.components["cares"].libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "c-ares") + self.cpp_info.set_property("cmake_target_name", "c-ares::cares") + self.cpp_info.set_property("pkg_config_name", "libcares") + + # TODO: back to global scope once cmake_find_package* generators removed + self.cpp_info.components["cares"].libs = collect_libs(self) if not self.options.shared: self.cpp_info.components["cares"].defines.append("CARES_STATICLIB") if self.settings.os == "Linux": self.cpp_info.components["cares"].system_libs.append("rt") elif self.settings.os == "Windows": - self.cpp_info.components["cares"].system_libs.extend(["ws2_32", "Advapi32"]) - elif tools.is_apple_os(self.settings.os): + self.cpp_info.components["cares"].system_libs.extend(["ws2_32", "advapi32"]) + if Version(self.version) >= "1.18.0": + self.cpp_info.components["cares"].system_libs.append("iphlpapi") + elif is_apple_os(self): self.cpp_info.components["cares"].system_libs.append("resolv") if self.options.tools: bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["pkg_config"] = "libcares" + self.cpp_info.components["cares"].names["cmake_find_package"] = "cares" + self.cpp_info.components["cares"].names["cmake_find_package_multi"] = "cares" + self.cpp_info.components["cares"].names["pkg_config"] = "libcares" + self.cpp_info.components["cares"].set_property("cmake_target_name", "c-ares::cares") + self.cpp_info.components["cares"].set_property("pkg_config_name", "libcares") diff --git a/recipes/c-ares/all/test_package/CMakeLists.txt b/recipes/c-ares/all/test_package/CMakeLists.txt index 29dc66ee16d9c..18c37b0445afc 100644 --- a/recipes/c-ares/all/test_package/CMakeLists.txt +++ b/recipes/c-ares/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(c-ares REQUIRED CONFIG) -find_package(c-ares REQUIRED) - -add_executable(example example.c) -target_link_libraries(example c-ares::cares) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE c-ares::cares) diff --git a/recipes/c-ares/all/test_package/conanfile.py b/recipes/c-ares/all/test_package/conanfile.py index 3bfb6f61a71fa..3a8c6c5442b33 100644 --- a/recipes/c-ares/all/test_package/conanfile.py +++ b/recipes/c-ares/all/test_package/conanfile.py @@ -1,9 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -class CAresTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/c-ares/all/test_package/example.c b/recipes/c-ares/all/test_package/test_package.c similarity index 100% rename from recipes/c-ares/all/test_package/example.c rename to recipes/c-ares/all/test_package/test_package.c diff --git a/recipes/c-ares/all/test_v1_package/CMakeLists.txt b/recipes/c-ares/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7a0669d9d064c --- /dev/null +++ b/recipes/c-ares/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(c-ares REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE c-ares::cares) diff --git a/recipes/c-ares/all/test_v1_package/conanfile.py b/recipes/c-ares/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/c-ares/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/c-ares/config.yml b/recipes/c-ares/config.yml index 76442ff52022e..8355a60395bae 100644 --- a/recipes/c-ares/config.yml +++ b/recipes/c-ares/config.yml @@ -1,4 +1,8 @@ versions: + "1.18.1": + folder: all + "1.17.2": + folder: all "1.17.1": folder: all "1.16.1": diff --git a/recipes/c-blosc/all/CMakeLists.txt b/recipes/c-blosc/all/CMakeLists.txt deleted file mode 100644 index 4d393c7a86c09..0000000000000 --- a/recipes/c-blosc/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory("source_subfolder") diff --git a/recipes/c-blosc/all/conandata.yml b/recipes/c-blosc/all/conandata.yml index 57779722fb1aa..dfd824d8023f0 100644 --- a/recipes/c-blosc/all/conandata.yml +++ b/recipes/c-blosc/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.21.1": + url: "https://github.com/Blosc/c-blosc/archive/v1.21.1.tar.gz" + sha256: "f387149eab24efa01c308e4cba0f59f64ccae57292ec9c794002232f7903b55b" + "1.21.0": + url: "https://github.com/Blosc/c-blosc/archive/v1.21.0.tar.gz" + sha256: "b0ef4fda82a1d9cbd11e0f4b9685abf14372db51703c595ecd4d76001a8b342d" "1.20.1": url: "https://github.com/Blosc/c-blosc/archive/v1.20.1.tar.gz" sha256: "42c4d3fcce52af9f8e2078f8f57681bfc711706a3330cb72b9b39e05ae18a413" @@ -15,18 +21,17 @@ sources: url: "https://github.com/Blosc/c-blosc/archive/v1.17.1.tar.gz" sha256: "19a6948b579c27e8ac440b4f077f99fc90e7292b1d9cb896bec0fd781d68fba2" patches: + "1.21.1": + - patch_file: "patches/cmake-dependencies-1.21.1+.patch" + "1.21.0": + - patch_file: "patches/cmake-dependencies-1.20.0+.patch" "1.20.1": - patch_file: "patches/cmake-dependencies-1.20.0+.patch" - base_path: "source_subfolder" "1.20.0": - patch_file: "patches/cmake-dependencies-1.20.0+.patch" - base_path: "source_subfolder" "1.19.0": - patch_file: "patches/cmake-dependencies-1.19.0.patch" - base_path: "source_subfolder" "1.18.1": - patch_file: "patches/cmake-dependencies-1.18.1-.patch" - base_path: "source_subfolder" "1.17.1": - patch_file: "patches/cmake-dependencies-1.18.1-.patch" - base_path: "source_subfolder" diff --git a/recipes/c-blosc/all/conanfile.py b/recipes/c-blosc/all/conanfile.py index 53740da2ef20f..1a0282104d95b 100644 --- a/recipes/c-blosc/all/conanfile.py +++ b/recipes/c-blosc/all/conanfile.py @@ -1,16 +1,21 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.52.0" + class CbloscConan(ConanFile): name = "c-blosc" description = "An extremely fast, multi-threaded, meta-compressor library." license = "BSD-3-Clause" - topics = ("conan", "c-blosc", "blosc", "compression") + topics = ("c-blosc", "blosc", "compression") homepage = "https://github.com/Blosc/c-blosc" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -19,7 +24,7 @@ class CbloscConan(ConanFile): "with_lz4": [True, False], "with_snappy": [True, False], "with_zlib": [True, False], - "with_zstd": [True, False] + "with_zstd": [True, False], } default_options = { "shared": False, @@ -28,93 +33,101 @@ class CbloscConan(ConanFile): "with_lz4": True, "with_snappy": True, "with_zlib": True, - "with_zstd": True + "with_zstd": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.settings.arch not in ["x86", "x86_64"]: + del self.options.simd_intrinsics def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx - if self.settings.arch not in ["x86", "x86_64"]: - del self.options.simd_intrinsics + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): if self.options.with_lz4: - self.requires("lz4/1.9.2") + self.requires("lz4/1.9.4") if self.options.with_snappy: - self.requires("snappy/1.1.8") + self.requires("snappy/1.1.9") if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.with_zstd: - self.requires("zstd/1.4.5") + self.requires("zstd/1.5.2") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BLOSC_INSTALL"] = True + tc.variables["BUILD_STATIC"] = not self.options.shared + tc.variables["BUILD_SHARED"] = self.options.shared + tc.variables["BUILD_TESTS"] = False + if Version(self.version) >= "1.20.0": + tc.variables["BUILD_FUZZERS"] = False + tc.variables["BUILD_BENCHMARKS"] = False + simd_intrinsics = self.options.get_safe("simd_intrinsics", False) + tc.variables["DEACTIVATE_SSE2"] = simd_intrinsics not in ["sse2", "avx2"] + tc.variables["DEACTIVATE_AVX2"] = simd_intrinsics != "avx2" + tc.variables["DEACTIVATE_LZ4"] = not self.options.with_lz4 + tc.variables["DEACTIVATE_SNAPPY"] = not self.options.with_snappy + tc.variables["DEACTIVATE_ZLIB"] = not self.options.with_zlib + tc.variables["DEACTIVATE_ZSTD"] = not self.options.with_zstd + tc.variables["DEACTIVATE_SYMBOLS_CHECK"] = True + tc.variables["PREFER_EXTERNAL_LZ4"] = True + if Version(self.version) < "1.19.0": + tc.variables["PREFER_EXTERNAL_SNAPPY"] = True + tc.variables["PREFER_EXTERNAL_ZLIB"] = True + tc.variables["PREFER_EXTERNAL_ZSTD"] = True + tc.variables["CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP"] = True + # Generate a relocatable shared lib on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + rmdir(self, os.path.join(self.source_folder, "cmake")) def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - # Remove folder containing custom FindLib.cmake files - tools.rmdir(os.path.join(self._source_subfolder, "cmake")) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BLOSC_INSTALL"] = True - self._cmake.definitions["BUILD_STATIC"] = not self.options.shared - self._cmake.definitions["BUILD_SHARED"] = self.options.shared - self._cmake.definitions["BUILD_TESTS"] = False - if tools.Version(self.version) >= "1.20.0": - self._cmake.definitions["BUILD_FUZZERS"] = False - self._cmake.definitions["BUILD_BENCHMARKS"] = False - simd_intrinsics = self.options.get_safe("simd_intrinsics", False) - self._cmake.definitions["DEACTIVATE_SSE2"] = simd_intrinsics not in ["sse2", "avx2"] - self._cmake.definitions["DEACTIVATE_AVX2"] = simd_intrinsics != "avx2" - self._cmake.definitions["DEACTIVATE_LZ4"] = not self.options.with_lz4 - self._cmake.definitions["DEACTIVATE_SNAPPY"] = not self.options.with_snappy - self._cmake.definitions["DEACTIVATE_ZLIB"] = not self.options.with_zlib - self._cmake.definitions["DEACTIVATE_ZSTD"] = not self.options.with_zstd - self._cmake.definitions["DEACTIVATE_SYMBOLS_CHECK"] = True - self._cmake.definitions["PREFER_EXTERNAL_LZ4"] = True - if tools.Version(self.version) < "1.19.0": - self._cmake.definitions["PREFER_EXTERNAL_SNAPPY"] = True - self._cmake.definitions["PREFER_EXTERNAL_ZLIB"] = True - self._cmake.definitions["PREFER_EXTERNAL_ZSTD"] = True - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): licenses = ["BLOSC.txt", "BITSHUFFLE.txt", "FASTLZ.txt"] for license_file in licenses: - self.copy(license_file, dst="licenses", src=os.path.join(self._source_subfolder, "LICENSES")) - cmake = self._configure_cmake() + copy(self, license_file, src=os.path.join(self.source_folder, "LICENSES"), dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["pkg_config"] = "blosc" - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.set_property("pkg_config_name", "blosc") + prefix = "lib" if is_msvc(self) and not self.options.shared else "" + self.cpp_info.libs = [f"{prefix}blosc"] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("pthread") diff --git a/recipes/c-blosc/all/patches/cmake-dependencies-1.18.1-.patch b/recipes/c-blosc/all/patches/cmake-dependencies-1.18.1-.patch index 04f2ab0166de3..d4a2354fd9ed0 100644 --- a/recipes/c-blosc/all/patches/cmake-dependencies-1.18.1-.patch +++ b/recipes/c-blosc/all/patches/cmake-dependencies-1.18.1-.patch @@ -1,6 +1,6 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -122,12 +122,11 @@ option(PREFER_EXTERNAL_ZLIB +@@ -122,12 +122,12 @@ option(PREFER_EXTERNAL_ZLIB option(PREFER_EXTERNAL_ZSTD "Find and use external Zstd library instead of included sources." OFF) @@ -10,6 +10,7 @@ if(NOT DEACTIVATE_LZ4) if(PREFER_EXTERNAL_LZ4) - find_package(LZ4) ++ find_package(lz4 REQUIRED CONFIG) + set(LZ4_FOUND TRUE) else() message(STATUS "Using LZ4 internal sources.") @@ -27,7 +28,7 @@ if (NOT DEACTIVATE_ZSTD) if (PREFER_EXTERNAL_ZSTD) - find_package(Zstd) -+ find_package(zstd) ++ find_package(zstd REQUIRED CONFIG) else () message(STATUS "Using ZSTD internal sources.") endif (PREFER_EXTERNAL_ZSTD) @@ -38,7 +39,7 @@ if(NOT DEACTIVATE_LZ4) if(LZ4_FOUND) - set(LIBS ${LIBS} ${LZ4_LIBRARY}) -+ set(LIBS ${LIBS} "CONAN_PKG::lz4") ++ set(LIBS ${LIBS} $,LZ4::lz4_shared,LZ4::lz4_static>) else(LZ4_FOUND) file(GLOB LZ4_FILES ${LZ4_LOCAL_DIR}/*.c) set(SOURCES ${SOURCES} ${LZ4_FILES}) @@ -65,7 +66,7 @@ if (NOT DEACTIVATE_ZSTD) if (ZSTD_FOUND) - set(LIBS ${LIBS} ${ZSTD_LIBRARY}) -+ set(LIBS ${LIBS} "zstd::zstd") ++ set(LIBS ${LIBS} $,zstd::libzstd_shared,zstd::libzstd_static>) else (ZSTD_FOUND) file(GLOB ZSTD_FILES ${ZSTD_LOCAL_DIR}/common/*.c diff --git a/recipes/c-blosc/all/patches/cmake-dependencies-1.19.0.patch b/recipes/c-blosc/all/patches/cmake-dependencies-1.19.0.patch index 5ef7800ef0bef..3f5a9b46096f3 100644 --- a/recipes/c-blosc/all/patches/cmake-dependencies-1.19.0.patch +++ b/recipes/c-blosc/all/patches/cmake-dependencies-1.19.0.patch @@ -1,6 +1,6 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -117,12 +117,11 @@ option(PREFER_EXTERNAL_ZLIB +@@ -117,12 +117,12 @@ option(PREFER_EXTERNAL_ZLIB option(PREFER_EXTERNAL_ZSTD "Find and use external Zstd library instead of included sources." OFF) @@ -10,6 +10,7 @@ if(NOT DEACTIVATE_LZ4) if(PREFER_EXTERNAL_LZ4) - find_package(LZ4) ++ find_package(lz4 REQUIRED CONFIG) + set(LZ4_FOUND TRUE) else() message(STATUS "Using LZ4 internal sources.") @@ -27,7 +28,7 @@ if (NOT DEACTIVATE_ZSTD) if (PREFER_EXTERNAL_ZSTD) - find_package(Zstd) -+ find_package(zstd) ++ find_package(zstd REQUIRED CONFIG) else () message(STATUS "Using ZSTD internal sources.") endif (PREFER_EXTERNAL_ZSTD) @@ -38,7 +39,7 @@ if(NOT DEACTIVATE_LZ4) if(LZ4_FOUND) - set(LIBS ${LIBS} ${LZ4_LIBRARY}) -+ set(LIBS ${LIBS} "CONAN_PKG::lz4") ++ set(LIBS ${LIBS} $,LZ4::lz4_shared,LZ4::lz4_static>) else(LZ4_FOUND) file(GLOB LZ4_FILES ${LZ4_LOCAL_DIR}/*.c) set(SOURCES ${SOURCES} ${LZ4_FILES}) @@ -65,7 +66,7 @@ if (NOT DEACTIVATE_ZSTD) if (ZSTD_FOUND) - set(LIBS ${LIBS} ${ZSTD_LIBRARY}) -+ set(LIBS ${LIBS} "zstd::zstd") ++ set(LIBS ${LIBS} $,zstd::libzstd_shared,zstd::libzstd_static>) else (ZSTD_FOUND) file(GLOB ZSTD_FILES ${ZSTD_LOCAL_DIR}/common/*.c diff --git a/recipes/c-blosc/all/patches/cmake-dependencies-1.20.0+.patch b/recipes/c-blosc/all/patches/cmake-dependencies-1.20.0+.patch index c943456b7a005..428ddd7762cfb 100644 --- a/recipes/c-blosc/all/patches/cmake-dependencies-1.20.0+.patch +++ b/recipes/c-blosc/all/patches/cmake-dependencies-1.20.0+.patch @@ -1,6 +1,6 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -121,12 +121,11 @@ option(PREFER_EXTERNAL_ZLIB +@@ -121,12 +121,12 @@ option(PREFER_EXTERNAL_ZLIB option(PREFER_EXTERNAL_ZSTD "Find and use external Zstd library instead of included sources." OFF) @@ -10,6 +10,7 @@ if(NOT DEACTIVATE_LZ4) if(PREFER_EXTERNAL_LZ4) - find_package(LZ4) ++ find_package(lz4 REQUIRED CONFIG) + set(LZ4_FOUND TRUE) else() message(STATUS "Using LZ4 internal sources.") @@ -27,7 +28,7 @@ if (NOT DEACTIVATE_ZSTD) if (PREFER_EXTERNAL_ZSTD) - find_package(Zstd) -+ find_package(zstd) ++ find_package(zstd REQUIRED CONFIG) else () message(STATUS "Using ZSTD internal sources.") endif (PREFER_EXTERNAL_ZSTD) @@ -38,7 +39,7 @@ if(NOT DEACTIVATE_LZ4) if(LZ4_FOUND) - set(LIBS ${LIBS} ${LZ4_LIBRARY}) -+ set(LIBS ${LIBS} "CONAN_PKG::lz4") ++ set(LIBS ${LIBS} $,LZ4::lz4_shared,LZ4::lz4_static>) else(LZ4_FOUND) file(GLOB LZ4_FILES ${LZ4_LOCAL_DIR}/*.c) set(SOURCES ${SOURCES} ${LZ4_FILES}) @@ -65,7 +66,7 @@ if (NOT DEACTIVATE_ZSTD) if (ZSTD_FOUND) - set(LIBS ${LIBS} ${ZSTD_LIBRARY}) -+ set(LIBS ${LIBS} "zstd::zstd") ++ set(LIBS ${LIBS} $,zstd::libzstd_shared,zstd::libzstd_static>) else (ZSTD_FOUND) file(GLOB ZSTD_FILES ${ZSTD_LOCAL_DIR}/common/*.c diff --git a/recipes/c-blosc/all/patches/cmake-dependencies-1.21.1+.patch b/recipes/c-blosc/all/patches/cmake-dependencies-1.21.1+.patch new file mode 100644 index 0000000000000..fb62441ddd89b --- /dev/null +++ b/recipes/c-blosc/all/patches/cmake-dependencies-1.21.1+.patch @@ -0,0 +1,72 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -121,12 +121,12 @@ option(PREFER_EXTERNAL_ZLIB + option(PREFER_EXTERNAL_ZSTD + "Find and use external Zstd library instead of included sources." OFF) + +-set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") + + + if(NOT DEACTIVATE_LZ4) + if(PREFER_EXTERNAL_LZ4) +- find_package(LZ4) ++ find_package(lz4 REQUIRED CONFIG) ++ set(LZ4_FOUND TRUE) + else() + message(STATUS "Using LZ4 internal sources.") + endif(PREFER_EXTERNAL_LZ4) +@@ -148,7 +148,6 @@ endif(NOT DEACTIVATE_SNAPPY) + if(NOT DEACTIVATE_ZLIB) + # import the ZLIB_ROOT environment variable to help finding the zlib library + if(PREFER_EXTERNAL_ZLIB) +- set(ZLIB_ROOT $ENV{ZLIB_ROOT}) + find_package(ZLIB) + if (NOT ZLIB_FOUND ) + message(STATUS "No zlib found. Using internal sources.") +@@ -163,7 +162,7 @@ endif(NOT DEACTIVATE_ZLIB) + + if (NOT DEACTIVATE_ZSTD) + if (PREFER_EXTERNAL_ZSTD) +- find_package(Zstd) ++ find_package(zstd REQUIRED CONFIG) + else () + message(STATUS "Using ZSTD internal sources.") + endif (PREFER_EXTERNAL_ZSTD) +--- a/blosc/CMakeLists.txt ++++ b/blosc/CMakeLists.txt +@@ -91,7 +91,7 @@ endif(WIN32) + + if(NOT DEACTIVATE_LZ4) + if(LZ4_FOUND) +- set(LIBS ${LIBS} ${LZ4_LIBRARY}) ++ set(LIBS ${LIBS} $,LZ4::lz4_shared,LZ4::lz4_static>) + else(LZ4_FOUND) + file(GLOB LZ4_FILES ${LZ4_LOCAL_DIR}/*.c) + set(SOURCES ${SOURCES} ${LZ4_FILES}) +@@ -101,7 +101,7 @@ endif(NOT DEACTIVATE_LZ4) + + if(NOT DEACTIVATE_SNAPPY) + if(SNAPPY_FOUND) +- set(LIBS ${LIBS} ${SNAPPY_LIBRARY}) ++ set(LIBS ${LIBS} "Snappy::snappy") + else(SNAPPY_FOUND) + file(GLOB SNAPPY_FILES ${SNAPPY_LOCAL_DIR}/*.cc) + set(SOURCES ${SOURCES} ${SNAPPY_FILES}) +@@ -111,7 +111,7 @@ endif(NOT DEACTIVATE_SNAPPY) + + if(NOT DEACTIVATE_ZLIB) + if(ZLIB_FOUND) +- set(LIBS ${LIBS} ${ZLIB_LIBRARY}) ++ set(LIBS ${LIBS} "ZLIB::ZLIB") + else(ZLIB_FOUND) + file(GLOB ZLIB_FILES ${ZLIB_LOCAL_DIR}/*.c) + set(SOURCES ${SOURCES} ${ZLIB_FILES}) +@@ -121,7 +121,7 @@ endif(NOT DEACTIVATE_ZLIB) + + if (NOT DEACTIVATE_ZSTD) + if (ZSTD_FOUND) +- set(LIBS ${LIBS} ${ZSTD_LIBRARY}) ++ set(LIBS ${LIBS} $,zstd::libzstd_shared,zstd::libzstd_static>) + else (ZSTD_FOUND) + file(GLOB ZSTD_FILES + ${ZSTD_LOCAL_DIR}/common/*.c diff --git a/recipes/c-blosc/all/test_package/CMakeLists.txt b/recipes/c-blosc/all/test_package/CMakeLists.txt index 7b9b613cbb24a..e73da46b32d37 100644 --- a/recipes/c-blosc/all/test_package/CMakeLists.txt +++ b/recipes/c-blosc/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(c-blosc REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE c-blosc::c-blosc) diff --git a/recipes/c-blosc/all/test_package/conanfile.py b/recipes/c-blosc/all/test_package/conanfile.py index ea57a464900be..0a6bc68712d90 100644 --- a/recipes/c-blosc/all/test_package/conanfile.py +++ b/recipes/c-blosc/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/c-blosc/all/test_v1_package/CMakeLists.txt b/recipes/c-blosc/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..178f209fe3a3a --- /dev/null +++ b/recipes/c-blosc/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(c-blosc REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE c-blosc::c-blosc) diff --git a/recipes/c-blosc/all/test_v1_package/conanfile.py b/recipes/c-blosc/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..72910d4a2a0b5 --- /dev/null +++ b/recipes/c-blosc/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conan import ConanFile, tools +from conans import CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.build.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/c-blosc/config.yml b/recipes/c-blosc/config.yml index fe69e4655cbdf..600b8bb73358e 100644 --- a/recipes/c-blosc/config.yml +++ b/recipes/c-blosc/config.yml @@ -1,4 +1,8 @@ versions: + "1.21.1": + folder: all + "1.21.0": + folder: all "1.20.1": folder: all "1.20.0": diff --git a/recipes/c-blosc2/all/conandata.yml b/recipes/c-blosc2/all/conandata.yml new file mode 100644 index 0000000000000..d80738613d1bd --- /dev/null +++ b/recipes/c-blosc2/all/conandata.yml @@ -0,0 +1,23 @@ +sources: + "2.4.3": + url: "https://github.com/Blosc/c-blosc2/archive/v2.4.3.tar.gz" + sha256: "d4aa5e0794598794f20ab950e973d44f0d0d9c133ea1a5a07cb200fa54d2e036" + "2.4.2": + url: "https://github.com/Blosc/c-blosc2/archive/v2.4.2.tar.gz" + sha256: "763ded7a6286abd248a79b1560ce8bfda11018b699a450b3e43c529f284a5232" + "2.4.1": + url: "https://github.com/Blosc/c-blosc2/archive/refs/tags/v2.4.1.tar.gz" + sha256: "f09a43bfac563ceda611a213c799ca5359c3b629281e0a4f3a543e692a64a931" + "2.2.0": + url: "https://github.com/Blosc/c-blosc2/archive/refs/tags/v2.2.0.tar.gz" + sha256: "66f9977de26d6bc9ea1c0e623d873c3225e4fff709aa09b3335fd09d41d57c0e" + +patches: + "2.4.3": + - patch_file: "patches/2.4.1-0001-fix-cmake.patch" + "2.4.2": + - patch_file: "patches/2.4.1-0001-fix-cmake.patch" + "2.4.1": + - patch_file: "patches/2.4.1-0001-fix-cmake.patch" + "2.2.0": + - patch_file: "patches/2.2.0-0001-fix-cmake.patch" diff --git a/recipes/c-blosc2/all/conanfile.py b/recipes/c-blosc2/all/conanfile.py new file mode 100644 index 0000000000000..e8b9099a17a49 --- /dev/null +++ b/recipes/c-blosc2/all/conanfile.py @@ -0,0 +1,148 @@ +from conan import ConanFile +from conan.tools.microsoft import is_msvc +from conan.tools.files import export_conandata_patches, apply_conandata_patches, get, copy, rm, rmdir +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os +import glob + +required_conan_version = ">=1.52.0" + +class CBlosc2Conan(ConanFile): + name = "c-blosc2" + description = "A fast, compressed, persistent binary data store library for C." + license = "BSD-3-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/Blosc/c-blosc2" + topics = ("c-blosc", "blosc", "compression") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "simd_intrinsics": [None, "sse2", "avx2"], + "with_lz4": [True, False], + "with_zlib": [None, "zlib", "zlib-ng", "zlib-ng-compat"], + "with_zstd": [True, False], + "with_plugins": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "simd_intrinsics": "avx2", + "with_lz4": True, + "with_zlib": "zlib", + "with_zstd": True, + "with_plugins": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.arch not in ["x86", "x86_64"]: + del self.options.simd_intrinsics + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + # c-blosc2 uses zlib-ng with zlib compat options. + if self.options.with_zlib == "zlib-ng-compat": + self.options["zlib-ng"].zlib_compat = True + elif self.options.with_zlib == "zlib-ng": + self.options["zlib-ng"].zlib_compat = False + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_lz4: + self.requires("lz4/1.9.4") + if self.options.with_zlib in ["zlib-ng", "zlib-ng-compat"]: + self.requires("zlib-ng/2.0.6") + elif self.options.with_zlib == "zlib": + self.requires("zlib/1.2.13") + if self.options.with_zstd: + self.requires("zstd/1.5.2") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["BLOSC_IS_SUBPROJECT"] = False + tc.cache_variables["BLOSC_INSTALL"] = True + tc.cache_variables["BUILD_STATIC"] = not bool(self.options.shared) + tc.cache_variables["BUILD_SHARED"] = bool(self.options.shared) + tc.cache_variables["BUILD_TESTS"] = False + tc.cache_variables["BUILD_FUZZERS"] = False + tc.cache_variables["BUILD_BENCHMARKS"] = False + tc.cache_variables["BUILD_EXAMPLES"] = False + simd_intrinsics = self.options.get_safe("simd_intrinsics", False) + tc.cache_variables["DEACTIVATE_AVX2"] = simd_intrinsics != "avx2" + tc.cache_variables["DEACTIVATE_LZ4"] = not bool(self.options.with_lz4) + tc.cache_variables["PREFER_EXTERNAL_LZ4"] = True + tc.cache_variables["DEACTIVATE_ZLIB"] = self.options.with_zlib is None + tc.cache_variables["PREFER_EXTERNAL_ZLIB"] = True + tc.cache_variables["DEACTIVATE_ZSTD"] = not bool(self.options.with_zstd) + tc.cache_variables["PREFER_EXTERNAL_ZSTD"] = True + tc.cache_variables["BUILD_PLUGINS"] = bool(self.options.with_plugins) + if self.options.with_zlib == "zlib-ng-compat": + tc.preprocessor_definitions["ZLIB_COMPAT"] = "1" + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + for filename in glob.glob(os.path.join(self.source_folder, "cmake", "Find*.cmake")): + if os.path.basename(filename) not in [ + "FindSIMD.cmake", + ]: + rm(self, os.path.basename(filename), os.path.join(self.source_folder, "cmake")) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + licenses = ["BLOSC.txt", "BITSHUFFLE.txt", "FASTLZ.txt", "LZ4.txt", "ZLIB.txt", "STDINT.txt"] + for license_file in licenses: + copy(self, pattern=license_file, dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "LICENSES")) + + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + # Remove MS runtime files + for dll_pattern_to_remove in ["concrt*.dll", "msvcp*.dll", "vcruntime*.dll"]: + rm(self, pattern=dll_pattern_to_remove, folder=os.path.join(self.package_folder, "bin"), recursive=True) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "blosc2") + + prefix = "lib" if is_msvc(self) and not self.options.shared else "" + self.cpp_info.libs = ["{}blosc2".format(prefix)] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["rt", "m", "pthread"] + + # TODO: to remove in conan v2 once pkg_config generator removed + self.cpp_info.names["pkg_config"] = "blosc2" diff --git a/recipes/c-blosc2/all/patches/2.2.0-0001-fix-cmake.patch b/recipes/c-blosc2/all/patches/2.2.0-0001-fix-cmake.patch new file mode 100644 index 0000000000000..cef3c154b1ab2 --- /dev/null +++ b/recipes/c-blosc2/all/patches/2.2.0-0001-fix-cmake.patch @@ -0,0 +1,127 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bd8cb34..9c4cfe0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -68,7 +68,8 @@ if(NOT WIN32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") + endif() + +-cmake_minimum_required(VERSION 3.16.3) ++## TODO: dirty fix. ++cmake_minimum_required(VERSION 3.15) + if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 3.4) + cmake_policy(SET CMP0063 NEW) + endif() +@@ -144,26 +145,26 @@ if(BUILD_LITE) + endif() + + if(PREFER_EXTERNAL_LZ4) +- find_package(LZ4) ++ find_package(lz4) + else() + message(STATUS "Using LZ4 internal sources.") + endif() + + if(NOT DEACTIVATE_ZLIB) + if(PREFER_EXTERNAL_ZLIB) +- find_package(ZLIB_NG) +- if (ZLIB_NG_FOUND) ++ find_package(zlib-ng) ++ if (zlib-ng_FOUND) + set(HAVE_ZLIB_NG TRUE) + else() + find_package(ZLIB) + endif() + +- if(NOT (ZLIB_NG_FOUND OR ZLIB_FOUND)) ++ if(NOT (zlib-ng_FOUND OR ZLIB_FOUND)) + message(STATUS "No ZLIB found. Using ZLIB-NG internal sources.") + endif() + endif() + +- if (NOT (ZLIB_NG_FOUND OR ZLIB_FOUND)) ++ if (0) + message(STATUS "Using ZLIB-NG internal sources for ZLIB support.") + set(HAVE_ZLIB_NG TRUE) + add_definitions(-DZLIB_COMPAT) +@@ -184,7 +185,7 @@ endif() + + if(NOT DEACTIVATE_ZSTD) + if(PREFER_EXTERNAL_ZSTD) +- find_package(ZSTD) ++ find_package(zstd) + if(NOT ZSTD_FOUND) + message(STATUS "No ZSTD library found. Using internal sources.") + endif() +diff --git a/blosc/CMakeLists.txt b/blosc/CMakeLists.txt +index 7f3eac6..c7afecd 100644 +--- a/blosc/CMakeLists.txt ++++ b/blosc/CMakeLists.txt +@@ -10,16 +10,16 @@ set(CMAKE_C_VISIBILITY_PRESET hidden) + + # includes + set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) +-if(LZ4_FOUND) +- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${LZ4_INCLUDE_DIR}) ++if(lz4_FOUND) ++ set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${lz4_INCLUDE_DIR}) + else() + set(LZ4_LOCAL_DIR ${INTERNAL_LIBS}/lz4-1.9.3) + set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${LZ4_LOCAL_DIR}) + endif() + + if(NOT DEACTIVATE_ZLIB) +- if(ZLIB_NG_FOUND) +- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZLIB_NG_INCLUDE_DIR}) ++ if(zlib-ng_FOUND) ++ set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${zlib-ng_INCLUDE_DIR}) + elseif(ZLIB_FOUND) + set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) + else() +@@ -29,8 +29,8 @@ if(NOT DEACTIVATE_ZLIB) + endif() + + if(NOT DEACTIVATE_ZSTD) +- if(ZSTD_FOUND) +- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZSTD_INCLUDE_DIR}) ++ if(zstd_FOUND) ++ set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${zstd_INCLUDE_DIR}) + else() + set(ZSTD_LOCAL_DIR ${INTERNAL_LIBS}/zstd-1.5.2) + set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZSTD_LOCAL_DIR} +@@ -90,8 +90,8 @@ else() + endif() + endif() + +-if(LZ4_FOUND) +- set(LIBS ${LIBS} ${LZ4_LIBRARY}) ++if(lz4_FOUND) ++ set(LIBS ${LIBS} ${lz4_LIBRARIES}) + else() + file(GLOB LZ4_FILES ${LZ4_LOCAL_DIR}/*.c) + set(SOURCES ${SOURCES} ${LZ4_FILES}) +@@ -99,10 +99,10 @@ else() + endif() + + if(NOT DEACTIVATE_ZLIB) +- if(ZLIB_NG_FOUND) +- set(LIBS ${LIBS} ${ZLIB_NG_LIBRARY}) ++ if(zlib-ng_FOUND) ++ set(LIBS ${LIBS} ${zlib-ng_LIBRARIES}) + elseif(ZLIB_FOUND) +- set(LIBS ${LIBS} ${ZLIB_LIBRARY}) ++ set(LIBS ${LIBS} ${ZLIB_LIBRARIES}) + else() + set(ZLIB_LOCAL_DIR ${INTERNAL_LIBS}/${ZLIB_NG_DIR}) + file(GLOB ZLIB_FILES ${ZLIB_LOCAL_DIR}/*.c) +@@ -112,8 +112,8 @@ if(NOT DEACTIVATE_ZLIB) + endif() + + if(NOT DEACTIVATE_ZSTD) +- if(ZSTD_FOUND) +- set(LIBS ${LIBS} ${ZSTD_LIBRARY}) ++ if(zstd_FOUND) ++ set(LIBS ${LIBS} ${zstd_LIBRARIES}) + else() + # Enable assembly code only when not using MSVC *and* x86 is there + if((NOT MSVC) AND COMPILER_SUPPORT_SSE2) # if SSE2 is here, this is an x86 platform diff --git a/recipes/c-blosc2/all/patches/2.4.1-0001-fix-cmake.patch b/recipes/c-blosc2/all/patches/2.4.1-0001-fix-cmake.patch new file mode 100644 index 0000000000000..c7220f5674f37 --- /dev/null +++ b/recipes/c-blosc2/all/patches/2.4.1-0001-fix-cmake.patch @@ -0,0 +1,129 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 866c7f6..d68513a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -68,7 +68,8 @@ if(NOT WIN32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") + endif() + +-cmake_minimum_required(VERSION 3.16.3) ++## TODO: dirty fix. ++cmake_minimum_required(VERSION 3.15) + if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 3.4) + cmake_policy(SET CMP0063 NEW) + endif() +@@ -144,26 +145,26 @@ if(BUILD_LITE) + endif() + + if(PREFER_EXTERNAL_LZ4) +- find_package(LZ4) ++ find_package(lz4) + else() + message(STATUS "Using LZ4 internal sources.") + endif() + + if(NOT DEACTIVATE_ZLIB) + if(PREFER_EXTERNAL_ZLIB) +- find_package(ZLIB_NG) +- if (ZLIB_NG_FOUND) ++ find_package(zlib-ng) ++ if (zlib-ng_FOUND) + set(HAVE_ZLIB_NG TRUE) + else() + find_package(ZLIB) + endif() + +- if(NOT (ZLIB_NG_FOUND OR ZLIB_FOUND)) ++ if(NOT (zlib-ng_FOUND OR ZLIB_FOUND)) + message(STATUS "No ZLIB found. Using ZLIB-NG internal sources.") + endif() + endif() + +- if (NOT (ZLIB_NG_FOUND OR ZLIB_FOUND)) ++ if (0) + message(STATUS "Using ZLIB-NG internal sources for ZLIB support.") + set(HAVE_ZLIB_NG TRUE) + add_definitions(-DZLIB_COMPAT) +@@ -184,8 +185,8 @@ endif() + + if(NOT DEACTIVATE_ZSTD) + if(PREFER_EXTERNAL_ZSTD) +- find_package(ZSTD) +- if(NOT ZSTD_FOUND) ++ find_package(zstd) ++ if(NOT zstd_FOUND) + message(STATUS "No ZSTD library found. Using internal sources.") + endif() + else() +diff --git a/blosc/CMakeLists.txt b/blosc/CMakeLists.txt +index 441bab6..f17e467 100644 +--- a/blosc/CMakeLists.txt ++++ b/blosc/CMakeLists.txt +@@ -10,16 +10,16 @@ set(CMAKE_C_VISIBILITY_PRESET hidden) + + # includes + set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) +-if(LZ4_FOUND) +- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${LZ4_INCLUDE_DIR}) ++if(lz4_FOUND) ++ set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${lz4_INCLUDE_DIR}) + else() + set(LZ4_LOCAL_DIR ${INTERNAL_LIBS}/lz4-1.9.4) + set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${LZ4_LOCAL_DIR}) + endif() + + if(NOT DEACTIVATE_ZLIB) +- if(ZLIB_NG_FOUND) +- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZLIB_NG_INCLUDE_DIR}) ++ if(zlib-ng_FOUND) ++ set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${zlib-ng_INCLUDE_DIR}) + elseif(ZLIB_FOUND) + set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) + else() +@@ -29,8 +29,8 @@ if(NOT DEACTIVATE_ZLIB) + endif() + + if(NOT DEACTIVATE_ZSTD) +- if(ZSTD_FOUND) +- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZSTD_INCLUDE_DIR}) ++ if(zstd_FOUND) ++ set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${zstd_INCLUDE_DIR}) + else() + set(ZSTD_LOCAL_DIR ${INTERNAL_LIBS}/zstd-1.5.2) + set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZSTD_LOCAL_DIR} +@@ -90,8 +90,8 @@ else() + endif() + endif() + +-if(LZ4_FOUND) +- set(LIBS ${LIBS} ${LZ4_LIBRARY}) ++if(lz4_FOUND) ++ set(LIBS ${LIBS} ${lz4_LIBRARIES}) + else() + file(GLOB LZ4_FILES ${LZ4_LOCAL_DIR}/*.c) + set(SOURCES ${SOURCES} ${LZ4_FILES}) +@@ -99,10 +99,10 @@ else() + endif() + + if(NOT DEACTIVATE_ZLIB) +- if(ZLIB_NG_FOUND) +- set(LIBS ${LIBS} ${ZLIB_NG_LIBRARY}) ++ if(zlib-ng_FOUND) ++ set(LIBS ${LIBS} ${zlib-ng_LIBRARIES}) + elseif(ZLIB_FOUND) +- set(LIBS ${LIBS} ${ZLIB_LIBRARY}) ++ set(LIBS ${LIBS} ${ZLIB_LIBRARIES}) + else() + set(ZLIB_LOCAL_DIR ${INTERNAL_LIBS}/${ZLIB_NG_DIR}) + file(GLOB ZLIB_FILES ${ZLIB_LOCAL_DIR}/*.c) +@@ -112,8 +112,8 @@ if(NOT DEACTIVATE_ZLIB) + endif() + + if(NOT DEACTIVATE_ZSTD) +- if(ZSTD_FOUND) +- set(LIBS ${LIBS} ${ZSTD_LIBRARY}) ++ if(zstd_FOUND) ++ set(LIBS ${LIBS} ${zstd_LIBRARIES}) + else() + # Enable assembly code only when not using MSVC *and* x86 is there + if((NOT MSVC) AND COMPILER_SUPPORT_SSE2) # if SSE2 is here, this is an x86 platform diff --git a/recipes/c-blosc2/all/test_package/CMakeLists.txt b/recipes/c-blosc2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..50ba489df290c --- /dev/null +++ b/recipes/c-blosc2/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) + +find_package(c-blosc2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE c-blosc2::c-blosc2) diff --git a/recipes/c-blosc2/all/test_package/conanfile.py b/recipes/c-blosc2/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/c-blosc2/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/c-blosc2/all/test_package/test_package.c b/recipes/c-blosc2/all/test_package/test_package.c new file mode 100644 index 0000000000000..754d85bde8768 --- /dev/null +++ b/recipes/c-blosc2/all/test_package/test_package.c @@ -0,0 +1,114 @@ +/* + Copyright (C) 2014 Francesc Alted + http://blosc.org + License: MIT (see LICENSE.txt) + Example program demonstrating use of the Blosc filter from C code. + To compile this program: + $ gcc simple.c -o simple -lblosc + or, if you don't have the blosc library installed: + $ gcc -O3 -msse2 simple.c -I../blosc -o simple -L../build/blosc + Using MSVC on Windows: + $ cl /arch:SSE2 /Ox /Fesimple.exe /Iblosc examples\simple.c blosc\blosc.c blosc\blosclz.c blosc\shuffle.c blosc\shuffle-sse2.c blosc\shuffle-generic.c blosc\bitshuffle-generic.c blosc\bitshuffle-sse2.c + To run: + $ ./simple + Blosc version info: 1.4.2.dev ($Date:: 2014-07-08 #$) + Compression: 4000000 -> 158494 (25.2x) + Decompression succesful! + Succesful roundtrip! +*/ + +#include "blosc2.h" + +#include + +#define SIZE 100*100*100 + +int main(){ + static float data[SIZE]; + static float data_out[SIZE]; + static float data_dest[SIZE]; + int isize = SIZE*sizeof(float), osize = SIZE*sizeof(float); + int dsize = SIZE*sizeof(float), csize; + int i; + + for(i=0; i %d (%.1fx)\n", isize, csize, (1.*isize) / csize); + + /* Decompress */ + dsize = blosc_decompress(data_out, data_dest, dsize); + if (dsize < 0) { + printf("Decompression error. Error code: %d\n", dsize); + return dsize; + } + + printf("Decompression succesful!\n"); + + /* After using it, destroy the Blosc environment */ + blosc_destroy(); +#else + /* Register the filter with the library */ + printf("Blosc version info: %s (%s)\n", + BLOSC2_VERSION_STRING, BLOSC2_VERSION_DATE); + + /* Initialize the Blosc compressor */ + blosc2_init(); + + /* Compress with clevel=5 and shuffle active */ + csize = blosc2_compress(5, 1, sizeof(float), data, isize, data_out, osize); + if (csize == 0) { + printf("Buffer is uncompressible. Giving up.\n"); + return 1; + } + else if (csize < 0) { + printf("Compression error. Error code: %d\n", csize); + return csize; + } + + printf("Compression: %d -> %d (%.1fx)\n", isize, csize, (1.*isize) / csize); + + /* Decompress */ + dsize = blosc2_decompress(data_out, osize, data_dest, dsize); + if (dsize < 0) { + printf("Decompression error. Error code: %d\n", dsize); + return dsize; + } + + printf("Decompression succesful!\n"); + + /* After using it, destroy the Blosc environment */ + blosc2_destroy(); +#endif + + + for(i=0;i\n#include ", + "#include \n#include " + ) + target = "osx" if self.settings.os == "Macos" else "slx" + # NOTE: only one job is used, because there are issues with dependency + # tracking in parallel builds + args = ["IP=6", "-j1"] + AutoToolsBuildEnvironment(self).make(target=target, args=args) + + def build(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + if self._is_msvc: + self._patch_msvc() + self._build_msvc() + else: + self._build_unix() + + def package(self): + self.copy("LICENSE.txt", "licenses") + self.copy("c-client/*.h", "include") + if self._is_msvc: + self.copy("*.lib", "lib", "c-client") + else: + self.copy("*.a", "lib", "c-client") + + def package_info(self): + if self._is_msvc: + self.cpp_info.system_libs = \ + ["Winmm", "Ws2_32", "Secur32", "Crypt32"] + else: + self.cpp_info.defines = ["_DEFAULT_SOURCE"] + self.cpp_info.system_libs = ["crypt"] + self.cpp_info.requires = ["openssl::crypto", "openssl::ssl"] + self.cpp_info.libs = ["cclient" if self._is_msvc else "c-client"] diff --git a/recipes/c-client/all/patches/0001-fix-yunchan-tempfile.patch b/recipes/c-client/all/patches/0001-fix-yunchan-tempfile.patch new file mode 100644 index 0000000000000..043b44a640ead --- /dev/null +++ b/recipes/c-client/all/patches/0001-fix-yunchan-tempfile.patch @@ -0,0 +1,68 @@ +--- src/osdep/nt/yunchan.c ++++ src/osdep/nt/yunchan.c +@@ -219,6 +219,34 @@ + * I would be delighted to have a better alternative. + */ + ++/* Fixes the above regret :-) */ ++static FILE *win_create_tempfile (char *name) ++{ ++ HANDLE handle = INVALID_HANDLE_VALUE; ++ int descriptor = -1; ++ FILE *result = NIL; ++ ++ handle = CreateFileA (name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE, ++ NIL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NIL); ++ if (handle == INVALID_HANDLE_VALUE) return NIL; ++ ++ descriptor = _open_osfhandle ((intptr_t) handle, 0); ++ if (descriptor == -1) goto cleanup_handle; ++ ++ result = _fdopen (descriptor, "w+b"); ++ if (result == NIL) goto cleanup_descriptor; ++ ++ return result; ++ ++cleanup_descriptor: ++ _close (descriptor); ++ return NIL; ++ ++cleanup_handle: ++ CloseHandle (handle); ++ return NIL; ++} ++ + #undef fclose /* use the real fclose() in close_file() */ + + /* Substitute for Microsoft's tmpfile() that uses the real temporary directory +@@ -229,11 +257,8 @@ + { + FILE *ret = NIL; + char *s = _tempnam (getenv ("TEMP"),"msg"); +- if (s) { /* if got temporary name... */ +- /* open file, and stash name on _tmpfname */ +- if (ret = fopen (s,"w+b")) ret->_tmpfname = s; +- else fs_give ((void **) &s);/* flush temporary string */ +- } ++ if (s) ret = win_create_tempfile (s); ++ fs_give ((void **) &s); + return ret; + } + +@@ -244,15 +269,7 @@ + + int close_file (FILE *stream) + { +- int ret; +- char *s = stream->_tmpfname; +- stream->_tmpfname = NIL; /* just in case fclose() tries to delete it */ +- ret = fclose (stream); /* close the file */ +- if (s) { /* was there a _tmpfname? */ +- unlink (s); /* yup, delete it */ +- fs_give ((void **) &s); /* and flush the name */ +- } +- return ret; ++ return fclose (stream); + } + + /* Get password from console diff --git a/recipes/c-client/all/patches/0002-fix-makefile-w2k.patch b/recipes/c-client/all/patches/0002-fix-makefile-w2k.patch new file mode 100644 index 0000000000000..54dbc5e5b71af --- /dev/null +++ b/recipes/c-client/all/patches/0002-fix-makefile-w2k.patch @@ -0,0 +1,13 @@ +--- src/osdep/nt/makefile.w2k ++++ src/osdep/nt/makefile.w2k +@@ -33,8 +33,8 @@ + CREATEDRIVER = mbx + APPENDDRIVER = unix + OSCOMPAT = /DWIN32 +-VSCOMPAT = /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE +-CFLAGS = /MT /W3 /Ox /DCHUNKSIZE=65536 $(OSCOMPAT) $(VSCOMPAT) -nologo /I.. $(EXTRACFLAGS) ++VSCOMPAT = /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /D_WINSOCK_DEPRECATED_NO_WARNINGS ++CFLAGS = /DCHUNKSIZE=65536 $(OSCOMPAT) $(VSCOMPAT) /nologo /I.. $(EXTRACFLAGS) + CC = cl + CCLIENTLIB = cclient.lib + diff --git a/recipes/c-client/all/patches/0003-fix-env-nt.patch b/recipes/c-client/all/patches/0003-fix-env-nt.patch new file mode 100644 index 0000000000000..e7df6e1290fb8 --- /dev/null +++ b/recipes/c-client/all/patches/0003-fix-env-nt.patch @@ -0,0 +1,11 @@ +--- src/osdep/nt/env_nt.c ++++ src/osdep/nt/env_nt.c +@@ -167,7 +167,7 @@ + if (suffix) { /* append timezone suffix if desired */ + char *tz; + tzset (); /* get timezone from TZ environment stuff */ +- tz = tzname[daylight ? (((struct tm *) t)->tm_isdst > 0) : 0]; ++ tz = _tzname[_daylight ? (((struct tm *) t)->tm_isdst > 0) : 0]; + if (tz && tz[0]) { + char *s; + for (s = tz; *s; s++) if (*s & 0x80) return; diff --git a/recipes/c-client/all/patches/0004-fix-makefile.patch b/recipes/c-client/all/patches/0004-fix-makefile.patch new file mode 100644 index 0000000000000..85d9ff7b5f18e --- /dev/null +++ b/recipes/c-client/all/patches/0004-fix-makefile.patch @@ -0,0 +1,55 @@ +--- Makefile ++++ Makefile +@@ -422,10 +422,8 @@ + EXTRACFLAGS="$(EXTRACFLAGS) -DMAC_OSX_KLUDGE=1" \ + SPECIALS="SSLINCLUDE=/usr/include/openssl SSLLIB=/usr/lib SSLCERTS=/System/Library/OpenSSL/certs SSLKEYS=/System/Library/OpenSSL/private GSSINCLUDE=/usr/include GSSLIB=/usr/lib PAMDLFLAGS=-lpam" + +-osx: osxok an +- $(TOUCH) ip6 +- $(BUILD) BUILDTYPE=$@ IP=$(IP6) EXTRAAUTHENTICATORS="$(EXTRAAUTHENTICATORS) gss" \ +- SPECIALS="SSLINCLUDE=/usr/include/openssl SSLLIB=/usr/lib SSLCERTS=/System/Library/OpenSSL/certs SSLKEYS=/System/Library/OpenSSL/private GSSINCLUDE=/usr/include GSSLIB=/usr/lib" ++osx: an ++ $(BUILD) BUILDTYPE=$@ IP=$(IP6) + + osxok: + @$(SH) -c '(test ! -f /usr/include/pam/pam_appl.h ) || make osxwarn' +@@ -678,7 +676,7 @@ + $(TOOLS)/$@ "$(LN)" src/tmail tmail + $(LN) $(TOOLS)/$@ . + +-build: OSTYPE rebuild rebuildclean bundled ++build: OSTYPE rebuild rebuildclean + + OSTYPE: + @$(MAKE) ip$(IP) +@@ -695,8 +693,8 @@ + $(TOUCH) rebuild + + rebuild: +- @$(SH) -c '(test $(BUILDTYPE) = rebuild -o $(BUILDTYPE) = `$(CAT) OSTYPE`) || (echo Already built for `$(CAT) OSTYPE` -- you must do \"make clean\" first && exit 1)' +- @echo Rebuilding c-client for `$(CAT) OSTYPE`... ++ @$(SH) -c '(test $(BUILDTYPE) = rebuild) || (echo Already built for $(BUILDTYPE) -- you must do \"make clean\" first && exit 1)' ++ @echo Rebuilding c-client for $(BUILDTYPE)... + @$(TOUCH) SPECIALS + $(CD) c-client;$(MAKE) all CC=`$(CAT) CCTYPE` \ + CFLAGS="`$(CAT) CFLAGS`" `$(CAT) SPECIALS` +--- src/osdep/unix/Makefile ++++ src/osdep/unix/Makefile +@@ -149,7 +149,7 @@ + + # Normally no need to change any of these + +-ARCHIVE=c-client.a ++ARCHIVE=libc-client.a + BINARIES=osdep.o mail.o misc.o newsrc.o smanager.o utf8.o utf8aux.o siglocal.o \ + dummy.o pseudo.o netmsg.o flstring.o fdstring.o \ + rfc822.o nntp.o smtp.o imap4r1.o pop3.o \ +@@ -935,7 +935,7 @@ + @echo If you get No such file error messages for files x509.h, ssl.h, + @echo pem.h, buffer.h, bio.h, and crypto.h, that means that OpenSSL + @echo is not installed on your system. Either install OpenSSL first +- @echo or build with command: make `$(CAT) OSTYPE` SSLTYPE=none ++ @echo or build with command: make $(OS) SSLTYPE=none + @echo ======================================================================== + + osdep.so: $(OSDEPS) diff --git a/recipes/c-client/all/patches/2014_openssl1.1.1_sni.patch b/recipes/c-client/all/patches/2014_openssl1.1.1_sni.patch new file mode 100644 index 0000000000000..2f58b0af15099 --- /dev/null +++ b/recipes/c-client/all/patches/2014_openssl1.1.1_sni.patch @@ -0,0 +1,42 @@ +Bug-Debian: https://bugs.debian.org/916041 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1834340 +Description: + Google IMAP servers require SNI if TLSv1.3 is used, + otherwise it sends a self-signed certificate which + fails validation. + + OpenSSL support/versions: + - TLSv1.3 on 1.1.1, + - a2i_IPADDRESS() on 0.9.8'ish, + - SSL_set_tlsext_host_name() on 0.9.8'ish/1.0.0; + per 'git blame/describe' and the CHANGES file. + + So check for TLSv1.3 support / OpenSSL 1.1.1 + not to incur behavior changes on pre-TLSv1.3, + and set host_name to 'host' (ssl_open_verify() + validates this, via 'ssl_last_host' variable) + + This patch just combines these two patches: + - BTS#916041 (message #5) by Ed Spiridonov, + - LP#1834340 (comment #6) by David Zuelke. +Author: Mauricio Faria de Oliveira + +Index: uw-imap-2007f~dfsg/src/osdep/unix/ssl_unix.c +=================================================================== +--- src/osdep/unix/ssl_unix.c ++++ src/osdep/unix/ssl_unix.c +@@ -266,6 +266,14 @@ static char *ssl_start_work (SSLSTREAM * + /* create connection */ + if (!(stream->con = (SSL *) SSL_new (stream->context))) + return "SSL connection failed"; ++#if OPENSSL_VERSION_NUMBER >= 0x10101000 ++ /* Use SNI in case server requires it with TLSv1.3. ++ * Literal IP addresses not permitted per RFC 6066. */ ++ if (!a2i_IPADDRESS(host)) { ++ ERR_clear_error(); ++ SSL_set_tlsext_host_name(stream->con,host); ++ } ++#endif + bio = BIO_new_socket (stream->tcpstream->tcpsi,BIO_NOCLOSE); + SSL_set_bio (stream->con,bio,bio); + SSL_set_connect_state (stream->con); diff --git a/recipes/c-client/all/test_package/CMakeLists.txt b/recipes/c-client/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6e4e3c79ee835 --- /dev/null +++ b/recipes/c-client/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS KEEP_RPATHS) + +find_package(c-client REQUIRED CONFIG) + +add_executable(test_package test_package.c) +target_link_libraries(test_package PRIVATE c-client::c-client) diff --git a/recipes/c-client/all/test_package/conanfile.py b/recipes/c-client/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a8c92dea63335 --- /dev/null +++ b/recipes/c-client/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/c-client/all/test_package/test_package.c b/recipes/c-client/all/test_package/test_package.c new file mode 100644 index 0000000000000..0edeebbf26ec6 --- /dev/null +++ b/recipes/c-client/all/test_package/test_package.c @@ -0,0 +1,34 @@ +#include +#include + +/* These symbols are left undefined in the library and are expected to be + * defined by a consumer */ +void mm_searched(MAILSTREAM* stream, unsigned long number) {} +void mm_exists(MAILSTREAM* stream, unsigned long number) {} +void mm_expunged(MAILSTREAM* stream, unsigned long number) {} +void mm_flags(MAILSTREAM* stream, unsigned long number) {} +void mm_notify(MAILSTREAM* stream, char* string, long errflg) {} +void mm_list(MAILSTREAM* stream, int delimiter, char* name, long attributes) {} +void mm_lsub(MAILSTREAM* stream, int delimiter, char* name, long attributes) {} +void mm_status(MAILSTREAM* stream, char* mailbox, MAILSTATUS* status) {} +void mm_log(char* string, long errflg) {} +void mm_dlog(char* string) {} +void mm_login(NETMBX* mb, char* user, char* pwd, long trial) {} +void mm_critical(MAILSTREAM* stream) {} +void mm_nocritical(MAILSTREAM* stream) {} +long mm_diskerror(MAILSTREAM* stream, long errcode, long serious) +{ + return 0; +} +void mm_fatal(char* string) {} + +int main(int argc, char const* argv[]) +{ + (void)argc; + (void)argv; + + MAILHANDLE* dummy = NULL; + mail_free_handle(&dummy); + + return 0; +} diff --git a/recipes/c-client/config.yml b/recipes/c-client/config.yml new file mode 100644 index 0000000000000..d5b2e9f3dbe4f --- /dev/null +++ b/recipes/c-client/config.yml @@ -0,0 +1,3 @@ +versions: + "2007f": + folder: all diff --git a/recipes/c-dbg-macro/all/conandata.yml b/recipes/c-dbg-macro/all/conandata.yml new file mode 100644 index 0000000000000..996d14e84ce29 --- /dev/null +++ b/recipes/c-dbg-macro/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.12.1": + url: https://github.com/eerimoq/dbg-macro/archive/0.12.1.tar.gz + sha256: 8567730747c8f18cf01748819ebd178bcd9f9ca54431e124b9fda9f0616db751 diff --git a/recipes/c-dbg-macro/all/conanfile.py b/recipes/c-dbg-macro/all/conanfile.py new file mode 100644 index 0000000000000..8c02b5c63b5a6 --- /dev/null +++ b/recipes/c-dbg-macro/all/conanfile.py @@ -0,0 +1,33 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration + + +required_conan_version = ">=1.33.0" + +class DbgMacroConan(ConanFile): + name = "c-dbg-macro" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/eerimoq/dbg-macro" + license = "MIT" + description = "A dbg(...) macro for C" + topics = ("conan", "debugging", "macro", "pretty-printing", "header-only") + settings = ("compiler", "build_type", "os", "arch") + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("This library is not compatible with Windows") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("include/dbg.h", dst=".", src=self._source_subfolder) + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + + def package_id(self): + self.info.header_only() diff --git a/recipes/c-dbg-macro/all/test_package/CMakeLists.txt b/recipes/c-dbg-macro/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..85e615074f940 --- /dev/null +++ b/recipes/c-dbg-macro/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(test_package test_package.c) diff --git a/recipes/c-dbg-macro/all/test_package/conanfile.py b/recipes/c-dbg-macro/all/test_package/conanfile.py new file mode 100644 index 0000000000000..c795b378cca50 --- /dev/null +++ b/recipes/c-dbg-macro/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/c-dbg-macro/all/test_package/test_package.c b/recipes/c-dbg-macro/all/test_package/test_package.c new file mode 100644 index 0000000000000..8319756f0fcce --- /dev/null +++ b/recipes/c-dbg-macro/all/test_package/test_package.c @@ -0,0 +1,30 @@ +#include +#include + +static int factorial(int n) +{ + if (dbgb(n <= 1)) { + return dbg(1); + } else { + return dbg(n * factorial(n - 1)); + } +} + +int main() +{ + char message[] = "hello"; + dbg(message); // main.c:15: message = "hello" + dbgh(message, sizeof(message)); + + const int a = 2; + const int b = dbg(3 * a) + 1; // main.c:19: 3 * a = 6 (0x6) + + int numbers[2] = { b, 13 }; + dbga(numbers, 2); // main.c:22: numbers = [7, 13] (length: 2) + + dbg(factorial(4)); + dbge(-EINVAL); + dbgbt(); + + return 0; +} diff --git a/recipes/c-dbg-macro/config.yml b/recipes/c-dbg-macro/config.yml new file mode 100644 index 0000000000000..f7f11eb2dea71 --- /dev/null +++ b/recipes/c-dbg-macro/config.yml @@ -0,0 +1,3 @@ +versions: + "0.12.1": + folder: "all" diff --git a/recipes/c4core/all/conandata.yml b/recipes/c4core/all/conandata.yml new file mode 100644 index 0000000000000..622bb4f50ac3a --- /dev/null +++ b/recipes/c4core/all/conandata.yml @@ -0,0 +1,24 @@ +sources: + "0.1.10": + url: "https://github.com/biojppm/c4core/releases/download/v0.1.10/c4core-0.1.10-src.tgz" + sha256: "e8ab4dedd0e20f86af7c69527cfbe8bc1cf72c84b7fbc0cfd420656f28ae20b2" + "0.1.9": + url: "https://github.com/biojppm/c4core/releases/download/v0.1.9/c4core-0.1.9-src.tgz" + sha256: "818d82456b640d88527fe517e1fef88fe45d8fffb414492eddf54480ee222449" + "0.1.8": + url: "https://github.com/biojppm/c4core/releases/download/v0.1.8/c4core-0.1.8-src.tgz" + sha256: "95c0663192c6bff7a098b50afcb05d22a34dd0fd8e6be2e1b61edad2b9675fde" + +patches: + "0.1.10": + - patch_file: "patches/0.1.10-0001-make-fast_float-external.patch" + patch_description: "use cci's fast_float recipe" + patch_type: "conan" + "0.1.9": + - patch_file: "patches/0.1.9-0001-make-fast_float-external.patch" + patch_description: "use cci's fast_float recipe" + patch_type: "conan" + "0.1.8": + - patch_file: "patches/0.1.8-0001-make-fast_float-external.patch" + patch_description: "use cci's fast_float recipe" + patch_type: "conan" diff --git a/recipes/c4core/all/conanfile.py b/recipes/c4core/all/conanfile.py new file mode 100644 index 0000000000000..885a6cf2b70cc --- /dev/null +++ b/recipes/c4core/all/conanfile.py @@ -0,0 +1,99 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import copy, get, rm, rmdir, apply_conandata_patches, export_conandata_patches +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.52.0" + +class C4CoreConan(ConanFile): + name = "c4core" + description = ( + "c4core is a library of low-level C++ utilities, written with " + "low-latency projects in mind." + ) + license = "MIT", + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/biojppm/c4core" + topics = ("utilities", "low-latency", ) + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_fast_float": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_fast_float": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_fast_float: + self.requires("fast_float/3.8.1") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, "11") + + ## clang with libc++ is not supported. It is already fixed since 0.1.9. + if Version(self.version) <= "0.1.8": + if self.info.settings.compiler in ["clang", "apple-clang"] and \ + self.info.settings.compiler.get_safe("libcxx") == "libc++": + raise ConanInvalidConfiguration(f"{self.ref} doesn't support clang with libc++") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["C4CORE_WITH_FASTFLOAT"] = bool(self.options.with_fast_float) + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE*", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rm(self, "*.natvis", os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.libs = ["c4core"] + if not self.options.with_fast_float: + self.cpp_info.defines.append("C4CORE_NO_FAST_FLOAT") + + self.cpp_info.set_property("cmake_file_name", "c4core") + self.cpp_info.set_property("cmake_target_name", "c4core::c4core") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/c4core/all/patches/0.1.10-0001-make-fast_float-external.patch b/recipes/c4core/all/patches/0.1.10-0001-make-fast_float-external.patch new file mode 100644 index 0000000000000..a530b3907baca --- /dev/null +++ b/recipes/c4core/all/patches/0.1.10-0001-make-fast_float-external.patch @@ -0,0 +1,37 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b2450e1..3f52516 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -72,7 +72,6 @@ set(C4CORE_SRC_FILES + if(C4CORE_WITH_FASTFLOAT) + list(APPEND C4CORE_SRC_FILES + c4/ext/fast_float.hpp +- c4/ext/fast_float_all.h + ) + endif() + set(C4CORE_AMALGAMATED ${C4CORE_SRC_DIR}/../src_singleheader/c4/c4core_all.hpp) +@@ -92,7 +91,10 @@ c4_add_library(c4core + SOURCES ${C4CORE_SRC_FILES} + ) + +-if(NOT C4CORE_WITH_FASTFLOAT) ++if(C4CORE_WITH_FASTFLOAT) ++ find_package(FastFloat REQUIRED CONFIG) ++ target_link_libraries(c4core PUBLIC "FastFloat::fast_float") ++else() + target_compile_definitions(c4core PUBLIC -DC4CORE_NO_FAST_FLOAT) + endif() + +diff --git a/src/c4/ext/fast_float.hpp b/src/c4/ext/fast_float.hpp +index 9e75b5e..64aa2a4 100644 +--- a/src/c4/ext/fast_float.hpp ++++ b/src/c4/ext/fast_float.hpp +@@ -15,7 +15,7 @@ + # pragma GCC diagnostic ignored "-Wuseless-cast" + #endif + +-#include "c4/ext/fast_float_all.h" ++#include "fast_float/fast_float.h" + + #ifdef _MSC_VER + # pragma warning(pop) diff --git a/recipes/c4core/all/patches/0.1.8-0001-make-fast_float-external.patch b/recipes/c4core/all/patches/0.1.8-0001-make-fast_float-external.patch new file mode 100644 index 0000000000000..1e139fba70445 --- /dev/null +++ b/recipes/c4core/all/patches/0.1.8-0001-make-fast_float-external.patch @@ -0,0 +1,37 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5bc4b09..ee7a0d8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -69,7 +69,6 @@ set(C4CORE_SRC_FILES + if(C4CORE_WITH_FASTFLOAT) + list(APPEND C4CORE_SRC_FILES + c4/ext/fast_float.hpp +- c4/ext/fast_float_all.h + ) + endif() + set(C4CORE_AMALGAMATED ${C4CORE_SRC_DIR}/../src_singleheader/c4/c4core_all.hpp) +@@ -89,7 +88,10 @@ c4_add_library(c4core + SOURCES ${C4CORE_SRC_FILES} + ) + +-if(NOT C4CORE_WITH_FASTFLOAT) ++if(C4CORE_WITH_FASTFLOAT) ++ find_package(FastFloat REQUIRED CONFIG) ++ target_link_libraries(c4core PUBLIC "FastFloat::fast_float") ++else() + target_compile_definitions(c4core PUBLIC -DC4CORE_NO_FAST_FLOAT) + endif() + +diff --git a/src/c4/ext/fast_float.hpp b/src/c4/ext/fast_float.hpp +index 9e75b5e..64aa2a4 100644 +--- a/src/c4/ext/fast_float.hpp ++++ b/src/c4/ext/fast_float.hpp +@@ -15,7 +15,7 @@ + # pragma GCC diagnostic ignored "-Wuseless-cast" + #endif + +-#include "c4/ext/fast_float_all.h" ++#include "fast_float/fast_float.h" + + #ifdef _MSC_VER + # pragma warning(pop) diff --git a/recipes/c4core/all/patches/0.1.9-0001-make-fast_float-external.patch b/recipes/c4core/all/patches/0.1.9-0001-make-fast_float-external.patch new file mode 100644 index 0000000000000..ae4e2acd03d15 --- /dev/null +++ b/recipes/c4core/all/patches/0.1.9-0001-make-fast_float-external.patch @@ -0,0 +1,37 @@ +diff --git a/a/CMakeLists.txt b/b/CMakeLists.txt +index e9412de..7d11193 100644 +--- a/a/CMakeLists.txt ++++ b/b/CMakeLists.txt +@@ -72,7 +72,6 @@ set(C4CORE_SRC_FILES + if(C4CORE_WITH_FASTFLOAT) + list(APPEND C4CORE_SRC_FILES + c4/ext/fast_float.hpp +- c4/ext/fast_float_all.h + ) + endif() + set(C4CORE_AMALGAMATED ${C4CORE_SRC_DIR}/../src_singleheader/c4/c4core_all.hpp) +@@ -92,7 +91,10 @@ c4_add_library(c4core + SOURCES ${C4CORE_SRC_FILES} + ) + +-if(NOT C4CORE_WITH_FASTFLOAT) ++if(C4CORE_WITH_FASTFLOAT) ++ find_package(FastFloat REQUIRED CONFIG) ++ target_link_libraries(c4core PUBLIC "FastFloat::fast_float") ++else() + target_compile_definitions(c4core PUBLIC -DC4CORE_NO_FAST_FLOAT) + endif() + +diff --git a/a/src/c4/ext/fast_float.hpp b/b/src/c4/ext/fast_float.hpp +index 9e75b5e..64aa2a4 100644 +--- a/a/src/c4/ext/fast_float.hpp ++++ b/b/src/c4/ext/fast_float.hpp +@@ -15,7 +15,7 @@ + # pragma GCC diagnostic ignored "-Wuseless-cast" + #endif + +-#include "c4/ext/fast_float_all.h" ++#include "fast_float/fast_float.h" + + #ifdef _MSC_VER + # pragma warning(pop) diff --git a/recipes/c4core/all/test_package/CMakeLists.txt b/recipes/c4core/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..62cfc706469cd --- /dev/null +++ b/recipes/c4core/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +find_package(c4core REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE c4core::c4core) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/c4core/all/test_package/conanfile.py b/recipes/c4core/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/c4core/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/c4core/all/test_package/test_package.cpp b/recipes/c4core/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..0859f030295f4 --- /dev/null +++ b/recipes/c4core/all/test_package/test_package.cpp @@ -0,0 +1,13 @@ +#include "c4/std/std.hpp" +#include "c4/charconv.hpp" + +#include + +auto main( int argc, char* argv[]) -> int { + double value; + c4::from_chars("52.4354", &value); + + std::cout << value << std::endl; + + return 0; +} diff --git a/recipes/c4core/all/test_v1_package/CMakeLists.txt b/recipes/c4core/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..bfd5ba0ad4164 --- /dev/null +++ b/recipes/c4core/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(c4core REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE c4core::c4core) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/c4core/all/test_v1_package/conanfile.py b/recipes/c4core/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/c4core/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/c4core/config.yml b/recipes/c4core/config.yml new file mode 100644 index 0000000000000..364da530085a9 --- /dev/null +++ b/recipes/c4core/config.yml @@ -0,0 +1,7 @@ +versions: + "0.1.10": + folder: all + "0.1.9": + folder: all + "0.1.8": + folder: all diff --git a/recipes/caf/all/conandata.yml b/recipes/caf/all/conandata.yml index 192b1a2ff030b..8560c79dbf871 100644 --- a/recipes/caf/all/conandata.yml +++ b/recipes/caf/all/conandata.yml @@ -1,13 +1,19 @@ sources: - "0.17.6": - url: "https://github.com/actor-framework/actor-framework/archive/0.17.6.tar.gz" - sha256: "e2bf5bd243f08bb7d8adde197cfe3e6d71314ed3378fe0692f8932f4c3b3928c" - "0.18.0": - url: "https://github.com/actor-framework/actor-framework/archive/0.18.0.tar.gz" - sha256: "df765fa78861e67d44e2587c0ac0c1c662d8c93fe5ffc8757f552fc7ac15941f" + "0.18.6": + url: "https://github.com/actor-framework/actor-framework/archive/0.18.6.tar.gz" + sha256: "c2ead63a0322d992fea8813a7f7d15b4d16cbb8bbe026722f2616a79109b91cc" + "0.18.5": + url: "https://github.com/actor-framework/actor-framework/archive/0.18.5.tar.gz" + sha256: "4c96f896f000218bb65890b4d7175451834add73750d5f33b0c7fe82b7d5a679" "0.18.2": url: "https://github.com/actor-framework/actor-framework/archive/0.18.2.tar.gz" sha256: "03837dbef73a13c3e4cac76c009d018f48d1d97b182277230f204984c9542ccc" + "0.18.0": + url: "https://github.com/actor-framework/actor-framework/archive/0.18.0.tar.gz" + sha256: "df765fa78861e67d44e2587c0ac0c1c662d8c93fe5ffc8757f552fc7ac15941f" + "0.17.6": + url: "https://github.com/actor-framework/actor-framework/archive/0.17.6.tar.gz" + sha256: "e2bf5bd243f08bb7d8adde197cfe3e6d71314ed3378fe0692f8932f4c3b3928c" patches: "0.17.6": - patch_file: "patches/win_install.patch" diff --git a/recipes/caf/all/conanfile.py b/recipes/caf/all/conanfile.py index a20d0dea5c93c..adbfa98e4822c 100644 --- a/recipes/caf/all/conanfile.py +++ b/recipes/caf/all/conanfile.py @@ -1,7 +1,8 @@ -import os from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration -from conans.tools import Version +import os + +required_conan_version = ">=1.43.0" class CAFConan(ConanFile): @@ -11,20 +12,37 @@ class CAFConan(ConanFile): homepage = "https://github.com/actor-framework/actor-framework" topics = "conan", "caf", "actor-framework", "actor-model", "pattern-matching", "actors" license = "BSD-3-Clause", "BSL-1.0" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "log_level": ["error", "warning", "info", "debug", "trace", "quiet"], - "with_openssl": [True, False] + "with_openssl": [True, False], } - default_options = {"shared": False, "fPIC": True, "log_level": "quiet", "with_openssl": True} - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + default_options = { + "shared": False, + "fPIC": True, + "log_level": "quiet", + "with_openssl": True, + } + + generators = "cmake", "cmake_find_package" _cmake = None + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -33,13 +51,9 @@ def configure(self): if self.options.shared: del self.options.fPIC - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("actor-framework-" + self.version, self._source_subfolder) - def requirements(self): if self.options.with_openssl: - self.requires("openssl/1.1.1j") + self.requires("openssl/1.1.1m") def _minimum_compilers_version(self, cppstd): standards = { @@ -61,7 +75,7 @@ def _minimum_compilers_version(self, cppstd): @property def _cppstd(self): - return "11" if Version(self.version) <= "0.17.6" else "17" + return "11" if tools.Version(self.version) <= "0.17.6" else "17" def validate(self): min_version = self._minimum_compilers_version(self._cppstd).get(str(self.settings.compiler)) @@ -73,7 +87,7 @@ def validate(self): raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( self.name, self._cppstd, self.settings.compiler, self.settings.compiler.version)) - if self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) > "10.0" and \ + if self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) > "10.0" and \ self.settings.arch == 'x86': raise ConanInvalidConfiguration("clang >= 11.0 does not support x86") if self.options.shared and self.settings.os == "Windows": @@ -81,11 +95,15 @@ def validate(self): if self.options.with_openssl and self.settings.os == "Windows" and self.settings.arch == "x86": raise ConanInvalidConfiguration("OpenSSL is not supported for Windows x86") + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + def _cmake_configure(self): if not self._cmake: self._cmake = CMake(self) self._cmake.definitions["CMAKE_CXX_STANDARD"] = self._cppstd - if Version(self.version) <= "0.17.6": + if tools.Version(self.version) <= "0.17.6": self._cmake.definitions["CAF_NO_AUTO_LIBCPP"] = True self._cmake.definitions["CAF_NO_OPENSSL"] = not self.options.with_openssl for define in ["CAF_NO_EXAMPLES", "CAF_NO_TOOLS", "CAF_NO_UNIT_TESTS", "CAF_NO_PYTHON"]: @@ -103,6 +121,9 @@ def _cmake_configure(self): def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "set(CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/cmake\")", + "list(APPEND CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/cmake\")") cmake = self._cmake_configure() cmake.build() @@ -113,28 +134,35 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - suffix = "_static" if not self.options.shared and Version(self.version) <= "0.17.6" else "" + self.cpp_info.set_property("cmake_file_name", "CAF") - self.cpp_info.names["cmake_find_package"] = "CAF" - self.cpp_info.names["cmake_find_package_multi"] = "CAF" + suffix = "_static" if not self.options.shared and tools.Version(self.version) <= "0.17.6" else "" - self.cpp_info.components["caf_core"].names["cmake_find_package"] = "core" - self.cpp_info.components["caf_core"].names["cmake_find_package_multi"] = "core" + self.cpp_info.components["caf_core"].set_property("cmake_target_name", "CAF::core") self.cpp_info.components["caf_core"].libs = ["caf_core{}".format(suffix)] if self.settings.os == "Windows": self.cpp_info.components["caf_core"].system_libs = ["iphlpapi"] - elif self.settings.os == "Linux": + elif self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["caf_core"].system_libs = ["pthread", "m"] - self.cpp_info.components["caf_io"].names["cmake_find_package"] = "io" - self.cpp_info.components["caf_io"].names["cmake_find_package_multi"] = "io" + self.cpp_info.components["caf_io"].set_property("cmake_target_name", "CAF::io") self.cpp_info.components["caf_io"].libs = ["caf_io{}".format(suffix)] self.cpp_info.components["caf_io"].requires = ["caf_core"] if self.settings.os == "Windows": self.cpp_info.components["caf_io"].system_libs = ["ws2_32"] if self.options.with_openssl: - self.cpp_info.components["caf_openssl"].names["cmake_find_package"] = "openssl" - self.cpp_info.components["caf_openssl"].names["cmake_find_package_multi"] = "openssl" + self.cpp_info.components["caf_openssl"].set_property("cmake_target_name", "CAF::openssl") self.cpp_info.components["caf_openssl"].libs = ["caf_openssl{}".format(suffix)] self.cpp_info.components["caf_openssl"].requires = ["caf_io", "openssl::openssl"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "CAF" + self.cpp_info.names["cmake_find_package_multi"] = "CAF" + self.cpp_info.components["caf_core"].names["cmake_find_package"] = "core" + self.cpp_info.components["caf_core"].names["cmake_find_package_multi"] = "core" + self.cpp_info.components["caf_io"].names["cmake_find_package"] = "io" + self.cpp_info.components["caf_io"].names["cmake_find_package_multi"] = "io" + if self.options.with_openssl: + self.cpp_info.components["caf_openssl"].names["cmake_find_package"] = "openssl" + self.cpp_info.components["caf_openssl"].names["cmake_find_package_multi"] = "openssl" diff --git a/recipes/caf/all/test_package/CMakeLists.txt b/recipes/caf/all/test_package/CMakeLists.txt index d8b8da7bcca08..327d84bc52fea 100644 --- a/recipes/caf/all/test_package/CMakeLists.txt +++ b/recipes/caf/all/test_package/CMakeLists.txt @@ -1,10 +1,15 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -find_package(CAF REQUIRED) +find_package(CAF REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} CAF::core CAF::io CAF::openssl) +if(CAF_VERSION VERSION_LESS "0.18.0") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +endif() diff --git a/recipes/caf/all/test_package/conanfile.py b/recipes/caf/all/test_package/conanfile.py index 41f845ea7f7d9..1b0c13a342cd9 100644 --- a/recipes/caf/all/test_package/conanfile.py +++ b/recipes/caf/all/test_package/conanfile.py @@ -4,16 +4,15 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) - cmake.definitions["CMAKE_CXX_STANDARD"] = "11" if Version(self.deps_cpp_info["caf"].version) < "0.18.0" else "17" cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/caf/config.yml b/recipes/caf/config.yml index 9ed1c8431e348..f96fed142bde9 100644 --- a/recipes/caf/config.yml +++ b/recipes/caf/config.yml @@ -1,7 +1,11 @@ versions: - "0.17.6": + "0.18.6": folder: all - "0.18.0": + "0.18.5": folder: all "0.18.2": folder: all + "0.18.0": + folder: all + "0.17.6": + folder: all diff --git a/recipes/cairo/all/conandata.yml b/recipes/cairo/all/conandata.yml index 8d3e651d08d5f..e6ad418ca420e 100644 --- a/recipes/cairo/all/conandata.yml +++ b/recipes/cairo/all/conandata.yml @@ -12,9 +12,15 @@ patches: "1.17.4": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" base_path: "source_subfolder" + - patch_file: "patches/binutils-2.34-libbfd-fix.patch" + base_path: "source_subfolder/util/cairo-trace" "1.17.2": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" base_path: "source_subfolder" + - patch_file: "patches/binutils-2.34-libbfd-fix.patch" + base_path: "source_subfolder/util/cairo-trace" "1.16.0": - patch_file: "patches/0001-msvc-update-build-scripts-to-compile-with-more-featu.patch" base_path: "source_subfolder" + - patch_file: "patches/binutils-2.34-libbfd-fix.patch" + base_path: "source_subfolder/util/cairo-trace" diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index ae17c6951b3d9..363cd49cb6c52 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -1,51 +1,71 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools, VisualStudioBuildEnvironment -from conans.errors import ConanInvalidConfiguration import os import shutil +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import files, microsoft, scm +from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment +from conans import tools + +required_conan_version = ">=1.50.0" + class CairoConan(ConanFile): name = "cairo" description = "Cairo is a 2D graphics library with support for multiple output devices" - topics = ("conan", "cairo", "graphics") + topics = ("cairo", "graphics") url = "https://github.com/conan-io/conan-center-index" homepage = "https://cairographics.org/" license = ("LGPL-2.1-only", "MPL-1.1") - exports_sources = ["patches/*"] settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], + options = { + "shared": [True, False], "fPIC": [True, False], "with_freetype": [True, False], "with_fontconfig": [True, False], "with_xlib": [True, False], "with_xlib_xrender": [True, False], "with_xcb": [True, False], - "with_glib": [True, False]} - default_options = {'shared': False, - 'fPIC': True, + "with_glib": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, "with_freetype": True, "with_fontconfig": True, "with_xlib": True, "with_xlib_xrender": False, "with_xcb": True, - "with_glib": True} + "with_glib": True, + } + + exports_sources = "patches/*" generators = "pkg_config" - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" - _env_build = None + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC del self.options.with_fontconfig - if self._is_msvc: + if microsoft.is_msvc(self): del self.options.with_freetype del self.options.with_glib - if self.settings.os != 'Linux': + if self.settings.os != "Linux": del self.options.with_xlib del self.options.with_xlib_xrender del self.options.with_xcb @@ -55,43 +75,46 @@ def configure(self): del self.options.fPIC del self.settings.compiler.cppstd del self.settings.compiler.libcxx - if self._is_msvc: - if self.settings.build_type not in ['Debug', 'Release']: + + def validate(self): + if microsoft.is_msvc(self): + if self.settings.build_type not in ["Debug", "Release"]: raise ConanInvalidConfiguration("MSVC build supports only Debug or Release build type") + if self.options.get_safe("with_glib") and self.options["glib"].shared \ + and microsoft.is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) def requirements(self): if self.options.get_safe("with_freetype", True): - self.requires("freetype/2.10.4") + self.requires("freetype/2.11.0") if self.options.get_safe("with_fontconfig", False): self.requires("fontconfig/2.13.93") - if self.settings.os == 'Linux': + if self.settings.os == "Linux": if self.options.with_xlib or self.options.with_xlib_xrender or self.options.with_xcb: self.requires("xorg/system") if self.options.get_safe("with_glib", True): - self.requires("glib/2.68.1") + self.requires("glib/2.70.0") self.requires("zlib/1.2.11") self.requires("pixman/0.40.0") self.requires("libpng/1.6.37") def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires('msys2/cci.latest') - if not self._is_msvc: - self.build_requires("libtool/2.4.6") - self.build_requires("pkgconf/1.7.4") - - @property - def _is_msvc(self): - return self.settings.compiler == 'Visual Studio' + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.tool_requires("msys2/cci.latest") + if not microsoft.is_msvc(self): + self.tool_requires("libtool/2.4.6") + self.tool_requires("pkgconf/1.7.4") + self.tool_requires("gtk-doc-stub/cci.20181216") def source(self): - tools.get(**self.conan_data["sources"][self.version], + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - if self._is_msvc: + files.apply_conandata_patches(self) + if microsoft.is_msvc(self): self._build_msvc() else: self._build_configure() @@ -99,79 +122,90 @@ def build(self): def _build_msvc(self): with tools.chdir(self._source_subfolder): # https://cairographics.org/end_to_end_build_for_win32/ - win32_common = os.path.join('build', 'Makefile.win32.common') - tools.replace_in_file(win32_common, '-MD ', '-%s ' % self.settings.compiler.runtime) - tools.replace_in_file(win32_common, '-MDd ', '-%s ' % self.settings.compiler.runtime) - tools.replace_in_file(win32_common, '$(ZLIB_PATH)/lib/zlib1.lib', - self.deps_cpp_info['zlib'].libs[0] + '.lib') - tools.replace_in_file(win32_common, '$(LIBPNG_PATH)/lib/libpng16.lib', - self.deps_cpp_info['libpng'].libs[0] + '.lib') - tools.replace_in_file(win32_common, '$(FREETYPE_PATH)/lib/freetype.lib', - self.deps_cpp_info['freetype'].libs[0] + '.lib') + win32_common = os.path.join("build", "Makefile.win32.common") + files.replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") + files.replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") + files.replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", + self.deps_cpp_info["zlib"].libs[0] + ".lib") + files.replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", + self.deps_cpp_info["libpng"].libs[0] + ".lib") + files.replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", + self.deps_cpp_info["freetype"].libs[0] + ".lib") with tools.vcvars(self.settings): env_msvc = VisualStudioBuildEnvironment(self) - env_msvc.flags.append('/FS') # C1041 if multiple CL.EXE write to the same .PDB file, please use /FS + env_msvc.flags.append("/FS") # C1041 if multiple CL.EXE write to the same .PDB file, please use /FS with tools.environment_append(env_msvc.vars): env_build = AutoToolsBuildEnvironment(self) args=[ "-f", "Makefile.win32", - "CFG={}".format(str(self.settings.build_type).lower()), + f"CFG={str(self.settings.build_type).lower()}", "CAIRO_HAS_FC_FONT=0", - "ZLIB_PATH={}".format(self.deps_cpp_info["zlib"].rootpath), - "LIBPNG_PATH={}".format(self.deps_cpp_info["libpng"].rootpath), - "PIXMAN_PATH={}".format(self.deps_cpp_info['pixman'].rootpath), - "FREETYPE_PATH={}".format(self.deps_cpp_info['freetype'].rootpath), - "GOBJECT_PATH={}".format(self.deps_cpp_info['glib'].rootpath) + f"ZLIB_PATH={self.deps_cpp_info['zlib'].rootpath}", + f"LIBPNG_PATH={self.deps_cpp_info['libpng'].rootpath}", + f"PIXMAN_PATH={self.deps_cpp_info['pixman'].rootpath}", + f"FREETYPE_PATH={self.deps_cpp_info['freetype'].rootpath}", + f"GOBJECT_PATH={self.deps_cpp_info['glib'].rootpath}" ] env_build.make(args=args) - env_build.make(args=['-C', os.path.join('util', 'cairo-gobject')] + args) + env_build.make(args=["-C", os.path.join("util", "cairo-gobject")] + args) + + def _configure_autotools(self): + if self._autotools: + return self._autotools - def _get_env_build(self): - if self._env_build: - return self._env_build + def boolean(value): + return "yes" if value else "no" - self._env_build = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - yes_no = lambda v: "yes" if v else "no" + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) configure_args = [ - "--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), - "--enable-ft={}".format(yes_no(self.options.with_freetype)), - "--enable-gobject={}".format(yes_no(self.options.with_glib)), - "--enable-fc={}".format(yes_no(self.options.get_safe("with_fontconfig"))), - "--enable-xlib={}".format(yes_no(self.options.get_safe("with_xlib"))), - "--enable-xlib_xrender={}".format(yes_no(self.options.get_safe("with_xlib_xrender"))), - "--enable-xcb={}".format(yes_no(self.options.get_safe("xcb"))), - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), + f"--datarootdir={tools.unix_path(os.path.join(self.package_folder, 'res'))}", + f"--enable-ft={boolean(self.options.with_freetype)}", + f"--enable-gobject={boolean(self.options.with_glib)}", + f"--enable-fc={boolean(self.options.get_safe('with_fontconfig'))}", + f"--enable-xlib={boolean(self.options.get_safe('with_xlib'))}", + f"--enable-xlib_xrender={boolean(self.options.get_safe('with_xlib_xrender'))}", + f"--enable-xcb={boolean(self.options.get_safe('xcb'))}", + f"--enable-shared={boolean(self.options.shared)}", + f"--enable-static={boolean(not self.options.shared)}", + "--disable-gtk-doc", ] if self.settings.compiler in ["gcc", "clang", "apple-clang"]: - self._env_build.flags.append("-Wno-enum-conversion") + self._autotools.flags.append("-Wno-enum-conversion") with tools.run_environment(self): - self._env_build.configure(args=configure_args) - return self._env_build + self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) + return self._autotools def _build_configure(self): with tools.chdir(self._source_subfolder): # disable build of test suite - tools.replace_in_file(os.path.join('test', 'Makefile.am'), 'noinst_PROGRAMS = cairo-test-suite$(EXEEXT)', - '') + files.replace_in_file(self, os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", + "") if self.options.with_freetype: - tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "src", "cairo-ft-font.c"), - '#if HAVE_UNISTD_H', '#ifdef HAVE_UNISTD_H') + files.replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "src", "cairo-ft-font.c"), + "#if HAVE_UNISTD_H", "#ifdef HAVE_UNISTD_H") + + tools.touch(os.path.join("boilerplate", "Makefile.am.features")) + tools.touch(os.path.join("src", "Makefile.am.features")) + tools.touch("ChangeLog") - with tools.environment_append({"NOCONFIGURE": "1"}): - self.run("./autogen.sh", win_bash=tools.os_info.is_windows, run_environment=True) - env_build = self._get_env_build() - env_build.make() + with tools.environment_append({"GTKDOCIZE": "echo"}): + self.run( + f"{tools.get_env('AUTORECONF')} -fiv", + run_environment=True, + win_bash=tools.os_info.is_windows, + ) + autotools = self._configure_autotools() + autotools.make() def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - if self._is_msvc: - src = os.path.join(self._source_subfolder, 'src') - cairo_gobject = os.path.join(self._source_subfolder, 'util', 'cairo-gobject') - inc = os.path.join('include', 'cairo') - self.copy(pattern="cairo-version.h", dst=inc, src=(src if tools.Version(self.version) >= "1.17.4" else self._source_subfolder)) + if microsoft.is_msvc(self): + src = os.path.join(self._source_subfolder, "src") + cairo_gobject = os.path.join(self._source_subfolder, "util", "cairo-gobject") + inc = os.path.join("include", "cairo") + self.copy(pattern="cairo-version.h", dst=inc, src=(src if scm.Version(self.version) >= "1.17.4" else self._source_subfolder)) self.copy(pattern="cairo-features.h", dst=inc, src=src) self.copy(pattern="cairo.h", dst=inc, src=src) self.copy(pattern="cairo-deprecated.h", dst=inc, src=src) @@ -190,37 +224,41 @@ def package(self): else: self.copy(pattern="*cairo-static.lib", dst="lib", src=src, keep_path=False) self.copy(pattern="*cairo-gobject.lib", dst="lib", src=cairo_gobject, keep_path=False) - shutil.move(os.path.join(self.package_folder, 'lib', "cairo-static.lib"), - os.path.join(self.package_folder, 'lib', "cairo.lib")) + shutil.move(os.path.join(self.package_folder, "lib", "cairo-static.lib"), + os.path.join(self.package_folder, "lib", "cairo.lib")) else: - with tools.chdir(self._source_subfolder): - env_build = self._get_env_build() - env_build.install() + autotools = self._configure_autotools() + autotools.install() tools.remove_files_by_mask(self.package_folder, "*.la") self.copy("COPYING*", src=self._source_subfolder, dst="licenses", keep_path=False) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") + self.cpp_info.names["pkg_config"] = "cairo-all-do-not-use" + + self.cpp_info.components["cairo_"].set_property("pkg_config_name", "cairo") self.cpp_info.components["cairo_"].names["pkg_config"] = "cairo" self.cpp_info.components["cairo_"].libs = ["cairo"] - self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join('include', 'cairo')) + self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) self.cpp_info.components["cairo_"].requires = ["pixman::pixman", "libpng::libpng", "zlib::zlib"] + if self.options.get_safe("with_freetype", True): self.cpp_info.components["cairo_"].requires.append("freetype::freetype") if self.settings.os == "Windows": - self.cpp_info.components["cairo_"].system_libs.extend(['gdi32','msimg32','user32']) + self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) if not self.options.shared: - self.cpp_info.components["cairo_"].defines.append('CAIRO_WIN32_STATIC_BUILD=1') + self.cpp_info.components["cairo_"].defines.append("CAIRO_WIN32_STATIC_BUILD=1") else: if self.options.with_glib: self.cpp_info.components["cairo_"].requires.extend(["glib::gobject-2.0", "glib::glib-2.0"]) if self.options.with_fontconfig: self.cpp_info.components["cairo_"].requires.append("fontconfig::fontconfig") + if self.settings.os == "Linux": - self.cpp_info.components["cairo_"].system_libs = ["pthread"] + self.cpp_info.components["cairo_"].system_libs = ["pthread", "rt"] self.cpp_info.components["cairo_"].cflags = ["-pthread"] self.cpp_info.components["cairo_"].cxxflags = ["-pthread"] if self.options.with_xcb: @@ -229,36 +267,50 @@ def package_info(self): self.cpp_info.components["cairo_"].requires.extend(["xorg::xcb-render"]) if self.options.with_xlib: self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) + if tools.is_apple_os(self.settings.os): self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") - if self.settings.os == "Windows": + self.cpp_info.components["cairo-win32"].set_property("pkg_config_name", "cairo-win32") self.cpp_info.components["cairo-win32"].names["pkg_config"] = "cairo-win32" self.cpp_info.components["cairo-win32"].requires = ["cairo_", "pixman::pixman", "libpng::libpng"] if self.options.get_safe("with_glib", True): + self.cpp_info.components["cairo-gobject"].set_property("pkg_config_name", "cairo-gobject") self.cpp_info.components["cairo-gobject"].names["pkg_config"] = "cairo-gobject" self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] if self.settings.os != "Windows": if self.options.with_fontconfig: + self.cpp_info.components["cairo-fc"].set_property("pkg_config_name", "cairo-fc") self.cpp_info.components["cairo-fc"].names["pkg_config"] = "cairo-fc" self.cpp_info.components["cairo-fc"].requires = ["cairo_", "fontconfig::fontconfig"] if self.options.get_safe("with_freetype", True): + self.cpp_info.components["cairo-ft"].set_property("pkg_config_name", "cairo-ft") self.cpp_info.components["cairo-ft"].names["pkg_config"] = "cairo-ft" self.cpp_info.components["cairo-ft"].requires = ["cairo_", "freetype::freetype"] + + self.cpp_info.components["cairo-pdf"].set_property("pkg_config_name", "cairo-pdf") self.cpp_info.components["cairo-pdf"].names["pkg_config"] = "cairo-pdf" self.cpp_info.components["cairo-pdf"].requires = ["cairo_", "zlib::zlib"] if self.settings.os == "Linux": if self.options.with_xlib: + self.cpp_info.components["cairo-xlib"].set_property("pkg_config_name", "cairo-xlib") self.cpp_info.components["cairo-xlib"].names["pkg_config"] = "cairo-xlib" self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] if tools.is_apple_os(self.settings.os): + self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") self.cpp_info.components["cairo-quartz"].names["pkg_config"] = "cairo-quartz" self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] - self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics"]) + self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics", "ApplicationServices"]) + + self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") self.cpp_info.components["cairo-quartz-font"].names["pkg_config"] = "cairo-quartz-font" self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] + + def package_id(self): + if self.options.get_safe("with_glib") and not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() diff --git a/recipes/cairo/all/patches/binutils-2.34-libbfd-fix.patch b/recipes/cairo/all/patches/binutils-2.34-libbfd-fix.patch new file mode 100644 index 0000000000000..197f3fbc3cad0 --- /dev/null +++ b/recipes/cairo/all/patches/binutils-2.34-libbfd-fix.patch @@ -0,0 +1,43 @@ +The libbfd issues were fixed in upstream with following commit: + + From e30259f6237571c61992433c110bc6e1ef900244 Mon Sep 17 00:00:00 2001 + From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= + Date: Tue, 23 Feb 2021 11:36:24 +0000 + Subject: cairo-trace: fix build with newer versions of bfd + + https://cgit.freedesktop.org/cairo/commit/?id=e30259f6237571c61992433c110bc6e1ef900244 + +Note that the upstream commit was more comprehensive, but cannot be directly +applied to 1.17.4 version. Any new cairo version beyond 1.17.4 will likely +not need this fix. + +--- lookup-symbol.c.original 2021-08-05 22:21:15.819998378 +0300 ++++ lookup-symbol.c 2021-08-05 22:26:05.212448342 +0300 +@@ -145,14 +145,26 @@ + if (symbol->found) + return; + ++#ifdef bfd_get_section_flags + if ((bfd_get_section_flags (symtab->bfd, section) & SEC_ALLOC) == 0) ++#else ++ if ((bfd_section_flags (section) & SEC_ALLOC) == 0) ++#endif + return; + ++#ifdef bfd_get_section_vma + vma = bfd_get_section_vma (symtab->bfd, section); ++#else ++ vma = bfd_section_vma (section); ++#endif + if (symbol->pc < vma) + return; + +- size = bfd_section_size (symtab->bfd, section); ++#ifdef bfd_get_section_size ++ size = bfd_get_section_size (section); ++#else ++ size = bfd_section_size (section); ++#endif + if (symbol->pc >= vma + size) + return; + diff --git a/recipes/cairo/all/test_package/CMakeLists.txt b/recipes/cairo/all/test_package/CMakeLists.txt index 2b4f3670163bb..bed5cd67420b6 100644 --- a/recipes/cairo/all/test_package/CMakeLists.txt +++ b/recipes/cairo/all/test_package/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1.2) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() diff --git a/recipes/cairo/all/test_package/test_package.c b/recipes/cairo/all/test_package/test_package.c index 94aaa86a176e3..e7474b6da5809 100644 --- a/recipes/cairo/all/test_package/test_package.c +++ b/recipes/cairo/all/test_package/test_package.c @@ -1,6 +1,6 @@ -#include #include #include +#include int main() { diff --git a/recipes/cairo/config.yml b/recipes/cairo/config.yml index 454fbd8471026..fcad6cea70952 100644 --- a/recipes/cairo/config.yml +++ b/recipes/cairo/config.yml @@ -4,4 +4,4 @@ versions: "1.17.2": folder: all "1.17.4": - folder: all + folder: meson diff --git a/recipes/cairo/meson/conandata.yml b/recipes/cairo/meson/conandata.yml new file mode 100644 index 0000000000000..b5df6a0c87d1c --- /dev/null +++ b/recipes/cairo/meson/conandata.yml @@ -0,0 +1,33 @@ +sources: + "1.17.4": + sha256: "74b24c1ed436bbe87499179a3b27c43f4143b8676d8ad237a6fa787401959705" + url: "https://www.cairographics.org/snapshots/cairo-1.17.4.tar.xz" +patches: + "1.17.4": + - patch_file: "patches/binutils-2.34-libbfd-fix.patch" + patch_type: "backport" + patch_description: "fix build with newer versions of bfd" + patch_source: "https://gitlab.freedesktop.org/cairo/cairo/-/commit/e30259f6237571c61992433c110bc6e1ef900244" + base_path: "util/cairo-trace" + + - patch_file: "patches/cairo-1.17.4-trace-cflags-fix.patch" + patch_type: "conan" + patch_description: | + Add missing 'PACKAGE' and 'PACKAGE_VERSION' defines for libbfd headers included by 'lookup-symbol.c'. + base_path: "util/cairo-trace" + + - patch_file: "patches/cairo-1.17.4-xlib-xrender-option.patch" + patch_type: "conan" + patch_description: >- + This patch adds option to enable or disable xlib-xrender component. + Without it 'xrender' is always required when 'xlib' option is enabled. @sh0 + + - patch_file: "patches/cairo-1.17.4-symbol-lookup-backport.patch" + patch_type: "backport" + patch_description: "add symbol-lookup option to allow disabling bfd/libiberty usage" + patch_source: "https://gitlab.freedesktop.org/cairo/cairo/-/commit/e0cf7b869fb1c6b73cf4a9aad2fc8aea4ff1f6ee" + + - patch_file: "patches/cairo-1.17.4-encoding-backport.patch" + patch_type: "backport" + patch_description: "use encoding=utf-8 when reading/writing files in helper script" + patch_source: "https://gitlab.freedesktop.org/cairo/cairo/-/commit/9732f4e80f906fab85b97ae55ee44bfd3ee4945e" diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py new file mode 100644 index 0000000000000..3871b067363f2 --- /dev/null +++ b/recipes/cairo/meson/conanfile.py @@ -0,0 +1,366 @@ +import glob +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import ( + apply_conandata_patches, + copy, + export_conandata_patches, + get, + rename, + replace_in_file, + rm, + rmdir) +from conan.tools.gnu import PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.meson import MesonToolchain, Meson +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version + +required_conan_version = ">=1.52.0" + + +class CairoConan(ConanFile): + name = "cairo" + description = "Cairo is a 2D graphics library with support for multiple output devices" + topics = ("cairo", "graphics") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://cairographics.org/" + license = ("LGPL-2.1-only", "MPL-1.1") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_freetype": [True, False], + "with_fontconfig": [True, False], + "with_xlib": [True, False], + "with_xlib_xrender": [True, False], + "with_xcb": [True, False], + "with_glib": [True, False], + "with_lzo": [True, False], + "with_zlib": [True, False], + "with_png": [True, False], + "with_opengl": [False, "desktop", "gles2", "gles3"], + "with_symbol_lookup": [True, False], + "tee": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_freetype": True, + "with_fontconfig": True, + "with_xlib": True, + "with_xlib_xrender": True, + "with_xcb": True, + "with_glib": True, + "with_lzo": True, + "with_zlib": True, + "with_png": True, + "with_opengl": "desktop", + "with_symbol_lookup": False, + "tee": True, + } + short_paths = True + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def layout(self): + basic_layout(self, src_folder="src") + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.os != "Linux": + del self.options.with_xlib + del self.options.with_xlib_xrender + del self.options.with_xcb + del self.options.with_symbol_lookup + if self.settings.os in ["Macos", "Windows"]: + del self.options.with_opengl + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + if self.options.with_glib and self.options.shared: + self.options["glib"].shared = True + + def requirements(self): + self.requires("pixman/0.40.0") + if self.options.with_zlib and self.options.with_png: + self.requires("expat/2.4.9") + if self.options.with_lzo: + self.requires("lzo/2.10") + if self.options.with_zlib: + self.requires("zlib/1.2.13") + if self.options.with_freetype: + self.requires("freetype/2.12.1") + if self.options.with_fontconfig: + self.requires("fontconfig/2.13.93") + if self.options.with_png: + self.requires("libpng/1.6.38") + if self.options.with_glib: + self.requires("glib/2.74.0") + if self.settings.os == "Linux": + if self.options.with_xlib or self.options.with_xlib_xrender or self.options.with_xcb: + self.requires("xorg/system") + if self.options.get_safe("with_opengl") == "desktop": + self.requires("opengl/system") + if self.settings.os == "Windows": + self.requires("glext/cci.20210420") + self.requires("wglext/cci.20200813") + self.requires("khrplatform/cci.20200529") + if self.options.get_safe("with_opengl") and self.settings.os in ["Linux", "FreeBSD"]: + self.requires("egl/system") + + def build_requirements(self): + self.tool_requires("meson/0.63.3") + self.tool_requires("pkgconf/1.9.3") + + def validate(self): + if self.options.get_safe("with_xlib_xrender") and not self.options.get_safe("with_xlib"): + raise ConanInvalidConfiguration("'with_xlib_xrender' option requires 'with_xlib' option to be enabled as well!") + if self.options.with_glib: + if self.options["glib"].shared: + if is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) + elif self.options.shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) + + def generate(self): + def is_enabled(value): + return "enabled" if value else "disabled" + + pkg_deps = PkgConfigDeps(self) + pkg_deps.generate() + + options = dict() + options["tests"] = "disabled" + options["zlib"] = is_enabled(self.options.with_zlib) + options["png"] = is_enabled(self.options.with_png) + options["freetype"] = is_enabled(self.options.with_freetype) + options["fontconfig"] = is_enabled(self.options.with_fontconfig) + if self.settings.os == "Linux": + options["xcb"] = is_enabled(self.options.with_xcb) + options["xlib"] = is_enabled(self.options.with_xlib) + options["xlib-xrender"] = is_enabled(self.options.with_xlib_xrender) + else: + options["xcb"] = "disabled" + options["xlib"] = "disabled" + if self.options.get_safe("with_opengl") == "desktop": + options["gl-backend"] = "gl" + elif self.options.get_safe("with_opengl") == "gles2": + options["gl-backend"] = "glesv2" + elif self.options.get_safe("with_opengl") == "gles3": + options["gl-backend"] = "glesv3" + else: + options["gl-backend"] = "disabled" + options["glesv2"] = is_enabled(self.options.get_safe("with_opengl") == "gles2") + options["glesv3"] = is_enabled(self.options.get_safe("with_opengl") == "gles3") + options["tee"] = is_enabled(self.options.tee) + options["symbol-lookup"] = is_enabled(self.options.get_safe("with_symbol_lookup")) + + # future options to add, see meson_options.txt. + # for now, disabling explicitly, to avoid non-reproducible auto-detection of system libs + options["cogl"] = "disabled" # https://gitlab.gnome.org/GNOME/cogl + options["directfb"] = "disabled" + options["drm"] = "disabled" # not yet compilable in cairo 1.17.4 + options["openvg"] = "disabled" # https://www.khronos.org/openvg/ + options["qt"] = "disabled" # not yet compilable in cairo 1.17.4 + options["gtk2-utils"] = "disabled" + options["spectre"] = "disabled" # https://www.freedesktop.org/wiki/Software/libspectre/ + + meson = MesonToolchain(self) + meson.project_options.update(options) + + if is_apple_os(self) and Version(self.version) < "1.17.6": + # This was fixed in the meson build from 1.17.6 + meson.c_link_args += ["-framework", "ApplicationServices", "-framework", "CoreFoundation"] + + if not self.options.shared: + meson.c_args.append("-DCAIRO_WIN32_STATIC_BUILD") + + meson.generate() + + env = VirtualBuildEnv(self) + env.generate() + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def build(self): + apply_conandata_patches(self) + + # Dependency freetype2 found: NO found 2.11.0 but need: '>= 9.7.3' + if self.options.with_freetype: + replace_in_file(self, os.path.join(self.source_folder, "meson.build"), + "freetype_required_version = '>= 9.7.3'", + f"freetype_required_version = '>= {self.deps_cpp_info['freetype'].version}'") + meson = Meson(self) + meson.configure() + meson.build() + + def _fix_library_names(self, path): + if is_msvc(self): + for filename_old in glob.glob(os.path.join(path, "*.a")): + root, _ = os.path.splitext(filename_old) + folder, basename = os.path.split(root) + rename(self, filename_old, os.path.join(folder, basename.replace("lib", "") + ".lib")) + + def package(self): + meson = Meson(self) + meson.install() + self._fix_library_names(os.path.join(self.package_folder, "lib")) + copy(self, "COPYING*", self.source_folder, os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + + def package_info(self): + base_requirements = {"pixman::pixman"} + base_system_libs = {} + + def add_component_and_base_requirements(component, requirements, system_libs=None): + self.cpp_info.components[component].set_property("pkg_config_name", component) + self.cpp_info.components[component].names["pkg_config"] = component + self.cpp_info.components[component].requires += ["cairo_"] + requirements + base_requirements.update(set(requirements)) + if system_libs is not None: + self.cpp_info.components[component].system_libs += system_libs + base_system_libs.update(set(system_libs)) + + self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") + self.cpp_info.names["pkg_config"] = "cairo-all-do-no-use" + + self.cpp_info.components["cairo_"].set_property("pkg_config_name", "cairo") + self.cpp_info.components["cairo_"].names["pkg_config"] = "cairo" + self.cpp_info.components["cairo_"].libs = ["cairo"] + self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) + + if self.settings.os == "Linux": + self.cpp_info.components["cairo_"].system_libs.extend(["m", "dl", "pthread"]) + if self.options.get_safe("with_symbol_lookup"): + self.cpp_info.components["cairo_"].system_libs.append("bfd") + self.cpp_info.components["cairo_"].cflags = ["-pthread"] + self.cpp_info.components["cairo_"].cxxflags = ["-pthread"] + + if self.options.with_lzo: + self.cpp_info.components["cairo_"].requires.append("lzo::lzo") + + if self.options.with_zlib: + self.cpp_info.components["cairo_"].requires.append("zlib::zlib") + + if self.options.with_png: + add_component_and_base_requirements("cairo-png", ["libpng::libpng"]) + add_component_and_base_requirements("cairo-svg", ["libpng::libpng"]) + + if self.options.with_fontconfig: + add_component_and_base_requirements("cairo-fc", ["fontconfig::fontconfig"]) + + if self.options.with_freetype: + add_component_and_base_requirements("cairo-ft", ["freetype::freetype"]) + + if self.options.get_safe("with_xlib"): + add_component_and_base_requirements("cairo-xlib", ["xorg::x11", "xorg::xext"]) + + if self.options.get_safe("with_xlib_xrender"): + add_component_and_base_requirements("cairo-xlib-xrender", ["xorg::xrender"]) + + if self.options.get_safe("with_xcb"): + add_component_and_base_requirements("cairo-xcb", ["xorg::xcb", "xorg::xcb-render"]) + add_component_and_base_requirements("cairo-xcb-shm", ["xorg::xcb", "xorg::xcb-shm"]) + + if self.options.get_safe("with_xlib"): + add_component_and_base_requirements("cairo-xlib-xcb", ["xorg::x11-xcb"]) + + if is_apple_os(self): + self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") + self.cpp_info.components["cairo-quartz"].names["pkg_config"] = "cairo-quartz" + self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] + + self.cpp_info.components["cairo-quartz-image"].set_property("pkg_config_name", "cairo-quartz-image") + self.cpp_info.components["cairo-quartz-image"].names["pkg_config"] = "cairo-quartz-image" + self.cpp_info.components["cairo-quartz-image"].requires = ["cairo_"] + + self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") + self.cpp_info.components["cairo-quartz-font"].names["pkg_config"] = "cairo-quartz-font" + self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] + + self.cpp_info.components["cairo_"].frameworks += ["ApplicationServices", "CoreFoundation", "CoreGraphics"] + + if self.settings.os == "Windows": + self.cpp_info.components["cairo-win32"].set_property("pkg_config_name", "cairo-win32") + self.cpp_info.components["cairo-win32"].names["pkg_config"] = "cairo-win32" + self.cpp_info.components["cairo-win32"].requires = ["cairo_"] + + self.cpp_info.components["cairo-win32-font"].set_property("pkg_config_name", "cairo-win32-font") + self.cpp_info.components["cairo-win32-font"].names["pkg_config"] = "cairo-win32-font" + self.cpp_info.components["cairo-win32-font"].requires = ["cairo_"] + + self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) + + if not self.options.shared: + self.cpp_info.components["cairo_"].defines.append("CAIRO_WIN32_STATIC_BUILD=1") + + if self.options.get_safe("with_opengl"): + if self.options.with_opengl == "desktop": + add_component_and_base_requirements("cairo-gl", ["opengl::opengl"]) + + if self.settings.os == "Linux": + add_component_and_base_requirements("cairo-glx", ["opengl::opengl"]) + + if self.settings.os == "Windows": + add_component_and_base_requirements("cairo-wgl", ["glext::glext", "wglext::wglext", "khrplatform::khrplatform"]) + + elif self.options.with_opengl == "gles3": + add_component_and_base_requirements("cairo-glesv3", [], ["GLESv2"]) + elif self.options.with_opengl == "gles2": + add_component_and_base_requirements("cairo-glesv2", [], ["GLESv2"]) + if self.settings.os in ["Linux", "FreeBSD"]: + add_component_and_base_requirements("cairo-egl", ["egl::egl"]) + + if self.options.with_zlib: + add_component_and_base_requirements("cairo-script", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-ps", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-pdf", ["zlib::zlib"]) + self.cpp_info.components["cairo-script-interpreter"].set_property("pkg_config_name", "cairo-script-interpreter") + self.cpp_info.components["cairo-script-interpreter"].names["pkg_config"] = "cairo-script-interpreter" + self.cpp_info.components["cairo-script-interpreter"].libs = ["cairo-script-interpreter"] + self.cpp_info.components["cairo-script-interpreter"].requires = ["cairo_"] + + if self.options.with_png: + add_component_and_base_requirements("cairo-xml", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-util_", ["expat::expat"]) + + if self.options.tee: + self.cpp_info.components["cairo-tee"].set_property("pkg_config_name", "cairo-tee") + self.cpp_info.components["cairo-tee"].names["pkg_config"] = "cairo-tee" + self.cpp_info.components["cairo-tee"].requires = ["cairo_"] + + # util directory + if self.options.with_glib: + self.cpp_info.components["cairo-gobject"].set_property("pkg_config_name", "cairo-gobject") + self.cpp_info.components["cairo-gobject"].names["pkg_config"] = "cairo-gobject" + self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] + self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] + + self.cpp_info.components["cairo_"].requires += list(base_requirements) + self.cpp_info.components["cairo_"].system_libs += list(base_system_libs) + + def package_id(self): + if self.options.get_safe("with_glib") and not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() diff --git a/recipes/cairo/meson/patches/binutils-2.34-libbfd-fix.patch b/recipes/cairo/meson/patches/binutils-2.34-libbfd-fix.patch new file mode 100644 index 0000000000000..197f3fbc3cad0 --- /dev/null +++ b/recipes/cairo/meson/patches/binutils-2.34-libbfd-fix.patch @@ -0,0 +1,43 @@ +The libbfd issues were fixed in upstream with following commit: + + From e30259f6237571c61992433c110bc6e1ef900244 Mon Sep 17 00:00:00 2001 + From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= + Date: Tue, 23 Feb 2021 11:36:24 +0000 + Subject: cairo-trace: fix build with newer versions of bfd + + https://cgit.freedesktop.org/cairo/commit/?id=e30259f6237571c61992433c110bc6e1ef900244 + +Note that the upstream commit was more comprehensive, but cannot be directly +applied to 1.17.4 version. Any new cairo version beyond 1.17.4 will likely +not need this fix. + +--- lookup-symbol.c.original 2021-08-05 22:21:15.819998378 +0300 ++++ lookup-symbol.c 2021-08-05 22:26:05.212448342 +0300 +@@ -145,14 +145,26 @@ + if (symbol->found) + return; + ++#ifdef bfd_get_section_flags + if ((bfd_get_section_flags (symtab->bfd, section) & SEC_ALLOC) == 0) ++#else ++ if ((bfd_section_flags (section) & SEC_ALLOC) == 0) ++#endif + return; + ++#ifdef bfd_get_section_vma + vma = bfd_get_section_vma (symtab->bfd, section); ++#else ++ vma = bfd_section_vma (section); ++#endif + if (symbol->pc < vma) + return; + +- size = bfd_section_size (symtab->bfd, section); ++#ifdef bfd_get_section_size ++ size = bfd_get_section_size (section); ++#else ++ size = bfd_section_size (section); ++#endif + if (symbol->pc >= vma + size) + return; + diff --git a/recipes/cairo/meson/patches/cairo-1.17.4-encoding-backport.patch b/recipes/cairo/meson/patches/cairo-1.17.4-encoding-backport.patch new file mode 100644 index 0000000000000..cd4f55bc86ffa --- /dev/null +++ b/recipes/cairo/meson/patches/cairo-1.17.4-encoding-backport.patch @@ -0,0 +1,40 @@ +From 9732f4e80f906fab85b97ae55ee44bfd3ee4945e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= +Date: Tue, 23 Feb 2021 23:42:11 +0000 +Subject: meson: use encoding=utf-8 when reading/writing files in helper script + +Fixes errors such as + +Traceback (most recent call last): + File "C:\Users\...\cairo\test\make-cairo-test-constructors.py", line 19, in + for l in f.readlines(): + File "c:\python39\lib\encodings\cp1253.py", line 23, in decode + return codecs.charmap_decode(input,self.errors,decoding_table)[0] +UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 6694: character maps to + +on non-English-language Windows locales/installations. +--- + boilerplate/make-cairo-boilerplate-constructors.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +(limited to 'boilerplate/make-cairo-boilerplate-constructors.py') + +diff --git a/boilerplate/make-cairo-boilerplate-constructors.py b/boilerplate/make-cairo-boilerplate-constructors.py +index 8e02fa500..40198ed1a 100644 +--- a/boilerplate/make-cairo-boilerplate-constructors.py ++++ b/boilerplate/make-cairo-boilerplate-constructors.py +@@ -16,12 +16,12 @@ if __name__=='__main__': + match_boilerplate_name = re.compile(r'^CAIRO_BOILERPLATE.*\((.*),.*') + + for fname in args.input: +- with open(fname, 'r') as f: ++ with open(fname, 'r', encoding='utf-8') as f: + for l in f.readlines(): + if match_boilerplate_line.match(l): + boilerplate_names.append(match_boilerplate_name.match(l).group(1)) + +- with open(args.output, 'w') as f: ++ with open(args.output, 'w', encoding='utf-8') as f: + f.write('/* WARNING: Autogenerated file - see %s! */\n\n' % sys.argv[0]) + f.write('#include "cairo-boilerplate-private.h"\n\n') + f.write('void _cairo_boilerplate_register_all (void);\n\n') diff --git a/recipes/cairo/meson/patches/cairo-1.17.4-symbol-lookup-backport.patch b/recipes/cairo/meson/patches/cairo-1.17.4-symbol-lookup-backport.patch new file mode 100644 index 0000000000000..a63f6e5638529 --- /dev/null +++ b/recipes/cairo/meson/patches/cairo-1.17.4-symbol-lookup-backport.patch @@ -0,0 +1,25 @@ +Backport new 'symbol-lookup' meson option from git master to cairo 1.17.4. +This option is needed to turn linking with libbfd deterministically on or off. @sh0 + +--- meson.build 2021-12-01 03:56:33.290547341 +0200 ++++ meson.build 2021-12-01 03:58:17.955355490 +0200 +@@ -659,7 +659,7 @@ + + # Untested, libiberty.h is in a libiberty subfolder for me + # FIXME: automagic +-bfd_dep = cc.find_library('bfd', required: false) ++bfd_dep = cc.find_library('bfd', has_headers: ['bfd.h'], required: get_option('symbol-lookup')) + if bfd_dep.found() and cc.has_function('bfd_openr', dependencies: [bfd_dep]) + if cc.has_header('libiberty.h') + conf.set('HAVE_BFD', 1) +--- meson_options.txt 2021-12-01 03:56:33.290547341 +0200 ++++ meson_options.txt 2021-12-01 03:57:29.498907256 +0200 +@@ -30,6 +30,8 @@ + # Misc deps + option('glib', type : 'feature', value : 'auto') + option('spectre', type : 'feature', value : 'auto') ++option('symbol-lookup', type: 'feature', value : 'auto', ++ description: 'Symbol lookup in debug utils via binutils/bfd') + + # FIXME: implement these to avoid automagic + #option('egl', type : 'feature', value : 'auto') diff --git a/recipes/cairo/meson/patches/cairo-1.17.4-trace-cflags-fix.patch b/recipes/cairo/meson/patches/cairo-1.17.4-trace-cflags-fix.patch new file mode 100644 index 0000000000000..83876c84ca34f --- /dev/null +++ b/recipes/cairo/meson/patches/cairo-1.17.4-trace-cflags-fix.patch @@ -0,0 +1,20 @@ +Add missing 'PACKAGE' and 'PACKAGE_VERSION' defines for libbfd headers included by 'lookup-symbol.c'. +Offending lines in 'bfd.h': + + #if !defined PACKAGE && !defined PACKAGE_VERSION + #error config.h must be included before this header + #endif + +Previously autotools provided those defines for Cairo, but they are no longer generated with meson. @sh0 + +--- meson.build 2020-11-27 01:20:59.000000000 +0200 ++++ meson.build 2021-12-01 00:42:26.798320019 +0200 +@@ -12,7 +12,7 @@ + include_directories: [incbase, incsrc], + dependencies: deps, + link_args: extra_link_args, +- c_args: ['-DSHARED_LIB_EXT="@0@"'.format(shared_lib_ext), '-DHAVE_CONFIG_H'] + pthread_c_args, ++ c_args: ['-DPACKAGE', '-DPACKAGE_VERSION', '-DSHARED_LIB_EXT="@0@"'.format(shared_lib_ext), '-DHAVE_CONFIG_H'] + pthread_c_args, + install: true, + install_dir: join_paths(get_option('prefix'), get_option('libdir'), 'cairo'), + ) diff --git a/recipes/cairo/meson/patches/cairo-1.17.4-xlib-xrender-option.patch b/recipes/cairo/meson/patches/cairo-1.17.4-xlib-xrender-option.patch new file mode 100644 index 0000000000000..55d7c984f8406 --- /dev/null +++ b/recipes/cairo/meson/patches/cairo-1.17.4-xlib-xrender-option.patch @@ -0,0 +1,26 @@ +This patch adds option to enable or disable xlib-xrender component. +Without it 'xrender' is always required when 'xlib' option is enabled. @sh0 + +--- meson.build 2020-11-27 01:20:59.000000000 +0200 ++++ meson.build 2021-12-01 00:34:50.366334030 +0200 +@@ -273,8 +273,8 @@ + endif + endif + +-if feature_conf.get('CAIRO_HAS_XLIB_SURFACE', 0) == 1 +- xrender_dep = dependency('xrender', required: get_option('xlib'), ++if feature_conf.get('CAIRO_HAS_XLIB_SURFACE', 0) == 1 and get_option('xlib-xrender').enabled() ++ xrender_dep = dependency('xrender', required: true, + version: xrender_required_version) + + if xrender_dep.found() +--- meson_options.txt 2020-11-27 01:20:59.000000000 +0200 ++++ meson_options.txt 2021-12-01 00:32:43.480337924 +0200 +@@ -17,6 +17,7 @@ + option('tee', type : 'feature', value : 'disabled') + option('xcb', type : 'feature', value : 'auto') + option('xlib', type : 'feature', value : 'auto') ++option('xlib-xrender', type : 'feature', value : 'disabled') + #option('xml', type : 'feature', value : 'disabled') + option('zlib', type : 'feature', value : 'auto') # script, ps, pdf, xml surfaces + diff --git a/recipes/cairo/meson/test_package/CMakeLists.txt b/recipes/cairo/meson/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..4f33d55898eb2 --- /dev/null +++ b/recipes/cairo/meson/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1.2) +project(test_package C) + +find_package(cairo CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE cairo::cairo) diff --git a/recipes/cairo/meson/test_package/conanfile.py b/recipes/cairo/meson/test_package/conanfile.py new file mode 100644 index 0000000000000..e904c93b97465 --- /dev/null +++ b/recipes/cairo/meson/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cairo/meson/test_package/test_package.c b/recipes/cairo/meson/test_package/test_package.c new file mode 100644 index 0000000000000..5854291cea177 --- /dev/null +++ b/recipes/cairo/meson/test_package/test_package.c @@ -0,0 +1,36 @@ +#include +#include +#include + +#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT + +#include +#include + +#endif + +int main() +{ +#if defined(WIN32) && CAIRO_HAS_WIN32_SURFACE && CAIRO_HAS_WIN32_FONT + + HDC hDC = GetDC(0); + if (hDC) + { + cairo_surface_t * surface = cairo_win32_surface_create(hDC); + if (surface) + { + HFONT hFont = (HFONT)GetStockObject(SYSTEM_FONT); + cairo_font_face_t* font = cairo_win32_font_face_create_for_hfont(hFont); + if (font) + cairo_font_face_destroy(font); + + cairo_surface_destroy(surface); + } + ReleaseDC(0, hDC); + } +#endif + + printf("cairo version is %s\n", cairo_version_string()); + + return 0; +} diff --git a/recipes/cairo/meson/test_v1_package/CMakeLists.txt b/recipes/cairo/meson/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..692a4909c85a7 --- /dev/null +++ b/recipes/cairo/meson/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1.2) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cairo/meson/test_v1_package/conanfile.py b/recipes/cairo/meson/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..24f9e474d6cd2 --- /dev/null +++ b/recipes/cairo/meson/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self, skip_x64_x86=True): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + diff --git a/recipes/cairomm/all/conandata.yml b/recipes/cairomm/all/conandata.yml new file mode 100644 index 0000000000000..e9529d1b4235f --- /dev/null +++ b/recipes/cairomm/all/conandata.yml @@ -0,0 +1,15 @@ +sources: + "1.16.1": + url: "https://cairographics.org/releases/cairomm-1.16.1.tar.xz" + sha256: "6f6060d8e98dd4b8acfee2295fddbdd38cf487c07c26aad8d1a83bb9bff4a2c6" + "1.14.3": + url: "https://cairographics.org/releases/cairomm-1.14.3.tar.xz" + sha256: "0d37e067c5c4ca7808b7ceddabfe1932c5bd2a750ad64fb321e1213536297e78" + +patches: + "1.16.1": + - patch_file: "patches/enable_static_lib_1_16_1.patch" + base_path: "source_subfolder" + "1.14.3": + - patch_file: "patches/enable_static_lib_1_14_3.patch" + base_path: "source_subfolder" diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py new file mode 100644 index 0000000000000..8a403a49b992b --- /dev/null +++ b/recipes/cairomm/all/conanfile.py @@ -0,0 +1,194 @@ +from conans import ConanFile, Meson, tools +from conan.tools.files import rename +from conan.tools.microsoft import is_msvc +from conans.errors import ConanInvalidConfiguration +import glob +import os +import shutil + + +class CairommConan(ConanFile): + name = "cairomm" + homepage = "https://github.com/freedesktop/cairomm" + url = "https://github.com/conan-io/conan-center-index" + license = "LGPL-2.0" + description = "cairomm is a C++ wrapper for the cairo graphics library." + topics = ["cairo", "wrapper", "graphics"] + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "pkg_config" + exports_sources = "patches/**" + short_paths = True + + def _abi_version(self): + return "1.16" if tools.Version(self.version) >= "1.16.0" else "1.0" + + def validate(self): + if hasattr(self, "settings_build") and tools.cross_building(self): + raise ConanInvalidConfiguration("Cross-building not implemented") + if self.settings.compiler.get_safe("cppstd"): + if self._abi_version() == "1.16": + tools.check_min_cppstd(self, 17) + else: + tools.check_min_cppstd(self, 11) + if self.options.shared and not self.options["cairo"].shared: + raise ConanInvalidConfiguration( + "Linking against static cairo would cause shared cairomm to link " + "against static glib which can cause problems." + ) + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def _patch_sources(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + if is_msvc(self): + # when using cpp_std=c++11 the /permissive- flag is added which + # attempts enforcing standard conformant c++ code + # the problem is that older versions of Windows SDK is not standard + # conformant! see: + # https://developercommunity.visualstudio.com/t/error-c2760-in-combaseapih-with-windows-sdk-81-and/185399 + tools.replace_in_file( + os.path.join(self._source_subfolder, "meson.build"), + "cpp_std=c++", "cpp_std=vc++") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + if self.options.shared: + self.options["cairo"].shared = True + + def build_requirements(self): + self.build_requires("meson/0.59.1") + self.build_requires("pkgconf/1.7.4") + + def requirements(self): + self.requires("cairo/1.17.4") + + if self._abi_version() == "1.16": + self.requires("libsigcpp/3.0.7") + else: + self.requires("libsigcpp/2.10.8") + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + strip_root=True, + destination=self._source_subfolder, + ) + + def build(self): + self._patch_sources() + with tools.environment_append(tools.RunEnvironment(self).vars): + meson = self._configure_meson() + meson.build() + + def _configure_meson(self): + meson = Meson(self) + defs = { + "build-examples": "false", + "build-documentation": "false", + "build-tests": "false", + "msvc14x-parallel-installable": "false", + "default_library": "shared" if self.options.shared else "static", + } + meson.configure( + defs=defs, + build_folder=self._build_subfolder, + source_folder=self._source_subfolder, + pkg_config_paths=[self.install_folder], + ) + return meson + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + meson = self._configure_meson() + meson.install() + if is_msvc(self): + tools.remove_files_by_mask( + os.path.join(self.package_folder, "bin"), "*.pdb") + if not self.options.shared: + rename( + self, + os.path.join( + self.package_folder, + "lib", + f"libcairomm-{self._abi_version()}.a", + ), + os.path.join(self.package_folder, "lib", + f"cairomm-{self._abi_version()}.lib"), + ) + + for header_file in glob.glob( + os.path.join( + self.package_folder, + "lib", + f"cairomm-{self._abi_version()}", + "include", + "*.h", + )): + shutil.move( + header_file, + os.path.join( + self.package_folder, + "include", + f"cairomm-{self._abi_version()}", + os.path.basename(header_file), + ), + ) + + for dir_to_remove in ["pkgconfig", f"cairomm-{self._abi_version()}"]: + tools.rmdir(os.path.join(self.package_folder, "lib", + dir_to_remove)) + + def package_info(self): + if self._abi_version() == "1.16": + self.cpp_info.components["cairomm-1.16"].names[ + "pkg_config"] = "cairomm-1.16" + self.cpp_info.components["cairomm-1.16"].includedirs = [ + os.path.join("include", "cairomm-1.16") + ] + self.cpp_info.components["cairomm-1.16"].libs = ["cairomm-1.16"] + self.cpp_info.components["cairomm-1.16"].requires = [ + "libsigcpp::sigc++", "cairo::cairo_" + ] + if tools.is_apple_os(self.settings.os): + self.cpp_info.components["cairomm-1.16"].frameworks = [ + "CoreFoundation" + ] + else: + self.cpp_info.components["cairomm-1.0"].names[ + "pkg_config"] = "cairomm-1.0" + self.cpp_info.components["cairomm-1.0"].includedirs = [ + os.path.join("include", "cairomm-1.0") + ] + self.cpp_info.components["cairomm-1.0"].libs = ["cairomm-1.0"] + self.cpp_info.components["cairomm-1.0"].requires = [ + "libsigcpp::sigc++-2.0", "cairo::cairo_" + ] + if tools.is_apple_os(self.settings.os): + self.cpp_info.components["cairomm-1.0"].frameworks = [ + "CoreFoundation" + ] + + def package_id(self): + self.info.requires["cairo"].full_package_mode() diff --git a/recipes/cairomm/all/patches/enable_static_lib_1_14_3.patch b/recipes/cairomm/all/patches/enable_static_lib_1_14_3.patch new file mode 100644 index 0000000000000..f5fcae443d2f0 --- /dev/null +++ b/recipes/cairomm/all/patches/enable_static_lib_1_14_3.patch @@ -0,0 +1,37 @@ +commit 04b20b02cc0ff18f71da693cf2d89709adabd297 +Author: Hesham Essam +Date: Fri May 6 21:26:01 2022 +0200 + + Enable static builds with msvc + + Cairomm exports dll symbols if the macro CAIROMM_STATIC_LIB is not + defined. This patch defines this macro in case of static builds. + +diff --git a/cairommconfig.h.meson b/cairommconfig.h.meson +index 2988edc..b9e5c21 100644 +--- a/cairommconfig.h.meson ++++ b/cairommconfig.h.meson +@@ -18,6 +18,9 @@ + /* Micro version number of cairomm. */ + #mesondefine CAIROMM_MICRO_VERSION + ++/* Define if cairomm is built as a static library */ ++#mesondefine CAIROMM_STATIC_LIB ++ + /* Enable DLL-specific stuff only when not building a static library */ + #if !defined(__CYGWIN__) && \ + (defined(__MINGW32__) || defined (_MSC_VER)) && \ +diff --git a/meson.build b/meson.build +index e130814..54c8d4f 100644 +--- a/meson.build ++++ b/meson.build +@@ -244,6 +244,9 @@ endif + if build_exceptions_api + mm_conf_data.set('CAIROMM_EXCEPTIONS_ENABLED', 1) + endif ++if get_option('default_library') == 'static' ++ mm_conf_data.set('CAIROMM_STATIC_LIB', 1) ++endif + mm_conf_data.set('CAIROMM_MAJOR_VERSION', cairomm_major_version) + mm_conf_data.set('CAIROMM_MINOR_VERSION', cairomm_minor_version) + mm_conf_data.set('CAIROMM_MICRO_VERSION', cairomm_micro_version) diff --git a/recipes/cairomm/all/patches/enable_static_lib_1_16_1.patch b/recipes/cairomm/all/patches/enable_static_lib_1_16_1.patch new file mode 100644 index 0000000000000..5d6cd671de960 --- /dev/null +++ b/recipes/cairomm/all/patches/enable_static_lib_1_16_1.patch @@ -0,0 +1,38 @@ +commit cd43f2e55de6db57e561989e7f6ad3765e1d4971 +Author: Hesham Essam +Date: Fri May 6 21:35:47 2022 +0200 + + Enable static builds with msvc + + Cairomm exports dll symbols if the macro CAIROMM_STATIC_LIB is not + defined. This patch defines this macro in case of static builds. + +diff --git a/cairommconfig.h.meson b/cairommconfig.h.meson +index 2988edc..b9e5c21 100644 +--- a/cairommconfig.h.meson ++++ b/cairommconfig.h.meson +@@ -18,6 +18,9 @@ + /* Micro version number of cairomm. */ + #mesondefine CAIROMM_MICRO_VERSION + ++/* Define if cairomm is built as a static library */ ++#mesondefine CAIROMM_STATIC_LIB ++ + /* Enable DLL-specific stuff only when not building a static library */ + #if !defined(__CYGWIN__) && \ + (defined(__MINGW32__) || defined (_MSC_VER)) && \ +diff --git a/meson.build b/meson.build +index 2c0c8bb..5259409 100644 +--- a/meson.build ++++ b/meson.build +@@ -247,6 +247,10 @@ endif + if build_exceptions_api + mm_conf_data.set('CAIROMM_EXCEPTIONS_ENABLED', 1) + endif ++if get_option('default_library') == 'static' ++ mm_conf_data.set('CAIROMM_STATIC_LIB', 1) ++endif ++ + mm_conf_data.set('CAIROMM_MAJOR_VERSION', cairomm_major_version) + mm_conf_data.set('CAIROMM_MINOR_VERSION', cairomm_minor_version) + mm_conf_data.set('CAIROMM_MICRO_VERSION', cairomm_micro_version) diff --git a/recipes/cairomm/all/test_package/CMakeLists.txt b/recipes/cairomm/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..366e829c2704c --- /dev/null +++ b/recipes/cairomm/all/test_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.6) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGET) + +add_executable(${PROJECT_NAME} test_package.cpp) + +find_package(cairomm REQUIRED CONFIG) +if (TARGET cairomm::cairomm-1.16) + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) + target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.16) +else() + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) + target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.0) +endif() diff --git a/recipes/cairomm/all/test_package/conanfile.py b/recipes/cairomm/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a691174f8ed16 --- /dev/null +++ b/recipes/cairomm/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + diff --git a/recipes/cairomm/all/test_package/test_package.cpp b/recipes/cairomm/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..d802e56f01bd2 --- /dev/null +++ b/recipes/cairomm/all/test_package/test_package.cpp @@ -0,0 +1,36 @@ +#define _USE_MATH_DEFINES + +#include +#include +#include + +int main() { +#if CAIROMM_MINOR_VERSION == 16 + auto surface = + Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32, 600, 400); +#else + auto surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 600, 400); +#endif + + auto cr = Cairo::Context::create(surface); + cr->save(); // save the state of the context + cr->set_source_rgb(0.86, 0.85, 0.47); + cr->paint(); // fill image with the color + cr->restore(); // color is back to black now + cr->save(); + // draw a border around the image + cr->set_line_width(20.0); // make the line wider + cr->rectangle(0.0, 0.0, surface->get_width(), surface->get_height()); + cr->stroke(); + cr->set_source_rgba(0.0, 0.0, 0.0, 0.7); + // draw a circle in the center of the image + cr->arc(surface->get_width() / 2.0, surface->get_height() / 2.0, + surface->get_height() / 4.0, 0.0, 2.0 * M_PI); + cr->stroke(); + // draw a diagonal line + cr->move_to(surface->get_width() / 4.0, surface->get_height() / 4.0); + cr->line_to(surface->get_width() * 3.0 / 4.0, + surface->get_height() * 3.0 / 4.0); + cr->stroke(); + cr->restore(); +} diff --git a/recipes/cairomm/config.yml b/recipes/cairomm/config.yml new file mode 100644 index 0000000000000..cc2573070ee79 --- /dev/null +++ b/recipes/cairomm/config.yml @@ -0,0 +1,5 @@ +versions: + "1.16.1": + folder: "all" + "1.14.3": + folder: "all" diff --git a/recipes/cajun-jsonapi/all/conandata.yml b/recipes/cajun-jsonapi/all/conandata.yml index 3b2de80377cbc..2dc8730667a35 100644 --- a/recipes/cajun-jsonapi/all/conandata.yml +++ b/recipes/cajun-jsonapi/all/conandata.yml @@ -2,3 +2,6 @@ sources: "2.0.3": url: https://github.com/cajun-jsonapi/cajun-jsonapi/archive/2.0.3.tar.gz sha256: b47f9338f1fbaee5ffc7247a94219e767d22d02fb6cdd37a51a9367700b72f34 + "2.1.1": + url: https://github.com/cajun-jsonapi/cajun-jsonapi/archive/refs/tags/2.1.1.tar.gz + sha256: 88f1eecf105e7ea337cd4142d1ea1bd165e84b0fa91cdaa098437b2e153a234c diff --git a/recipes/cajun-jsonapi/all/conanfile.py b/recipes/cajun-jsonapi/all/conanfile.py index 35592e6c5119e..55cd07447203f 100644 --- a/recipes/cajun-jsonapi/all/conanfile.py +++ b/recipes/cajun-jsonapi/all/conanfile.py @@ -1,39 +1,89 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import get, copy, load, save +from conan.tools.scm import Version import os +required_conan_version = ">=1.53.0" + + class CajunJsonApiConan(ConanFile): - name = 'cajun-jsonapi' - description = 'CAJUN* is a C++ API for the JSON object interchange format.' + name = "cajun-jsonapi" + description = "CAJUN* is a C++ API for the JSON object interchange format." topics = ("conan", "cajun", "json") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/cajun-jsonapi/cajun-jsonapi" license = "BSD-3-Clause" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + get( + self, + **self.conan_data["sources"][self.version], + destination=self.source_folder, + strip_root=True + ) def validate(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, 11) def _extract_license(self): - file_content = tools.load(os.path.join(self.source_folder, self._source_subfolder, "test.cpp")) - return file_content[:file_content.find("*/")] + file_content = load(self, os.path.join(self.source_folder, "test.cpp")) + return ( + file_content[: file_content.find("*/")] + .split("\n", 2)[-1] + .rsplit("\n", 1)[0] + ) def package(self): - tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license()) - self.copy('LICENSE', dst='licenses', src=self._source_subfolder) - self.copy('*.h', dst=os.path.join('include', 'json'), src=os.path.join(self._source_subfolder, 'json')) - self.copy('*.inl', dst=os.path.join('include', 'json'), src=os.path.join(self._source_subfolder, 'json')) + package_version = Version(self.version) + if package_version < "2.1.0": + # No dedicated LICENSE file in older versions, extracting license text from comments + save( + self, + os.path.join(self.package_folder, "licenses", "LICENSE"), + self._extract_license(), + ) + # Prior to v2.1.0 there was no "cajun" subfolder in sources but it was present in RPM packages + # (e.g. https://centos.pkgs.org/7/epel-x86_64/cajun-jsonapi-devel-2.0.3-2.el7.noarch.rpm.html) + # For ease of migration from RPM dependencies to Conan creating intermediate "cajun" folder + # so that '#include "cajun/json/..."' statements worked correctly + copy( + self, + "*.h", + dst=os.path.join(self.package_folder, "include", "cajun", "json"), + src=os.path.join(self.source_folder, "json"), + ) + copy( + self, + "*.inl", + dst=os.path.join(self.package_folder, "include", "cajun", "json"), + src=os.path.join(self.source_folder, "json"), + ) + else: + copy( + self, + "*.h", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include"), + ) + copy( + self, + "*.inl", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include"), + ) + copy( + self, + "LICENSE", + dst=os.path.join(self.package_folder, "licenses"), + src=self.source_folder, + ) def package_id(self): - self.info.header_only() + self.info.clear() def package_info(self): self.cpp_info.includedirs.append(os.path.join("include", "cajun")) diff --git a/recipes/cajun-jsonapi/all/test_package/CMakeLists.txt b/recipes/cajun-jsonapi/all/test_package/CMakeLists.txt index 55ba603774dce..6361de2a69cab 100644 --- a/recipes/cajun-jsonapi/all/test_package/CMakeLists.txt +++ b/recipes/cajun-jsonapi/all/test_package/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.1) project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - find_package(cajun-jsonapi REQUIRED) add_executable(${PROJECT_NAME} main.cpp) diff --git a/recipes/cajun-jsonapi/all/test_package/conanfile.py b/recipes/cajun-jsonapi/all/test_package/conanfile.py index e065617c053bc..48499fa0989d9 100644 --- a/recipes/cajun-jsonapi/all/test_package/conanfile.py +++ b/recipes/cajun-jsonapi/all/test_package/conanfile.py @@ -1,16 +1,27 @@ -from conans import ConanFile, CMake, tools, RunEnvironment +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os + +# It will become the standard on Conan 2.x class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) cmake.configure() - cmake.build() + cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cajun-jsonapi/all/test_package/main.cpp b/recipes/cajun-jsonapi/all/test_package/main.cpp index 30cdecbb6d34d..a061fd3b751d9 100644 --- a/recipes/cajun-jsonapi/all/test_package/main.cpp +++ b/recipes/cajun-jsonapi/all/test_package/main.cpp @@ -1,43 +1,43 @@ -#include -#include -#include +#include // Recommended include path as of v2.1.0 +#include +#include // Shortened include path used prior to v2.1.0 #include #include int main() { - using namespace json; + using namespace json; - Object objAPA; - objAPA["Name"] = String("Schlafly American Pale Ale"); - objAPA["Origin"] = String("St. Louis, MO, USA"); - objAPA["ABV"] = Number(3.8); - objAPA["BottleConditioned"] = Boolean(true); + Object objAPA; + objAPA["Name"] = String("Schlafly American Pale Ale"); + objAPA["Origin"] = String("St. Louis, MO, USA"); + objAPA["ABV"] = Number(3.8); + objAPA["BottleConditioned"] = Boolean(true); - Array arrayBeer; - arrayBeer.Insert(objAPA); + Array arrayBeer; + arrayBeer.Insert(objAPA); - Object objDocument; - objDocument["Delicious Beers"] = arrayBeer; + Object objDocument; + objDocument["Delicious Beers"] = arrayBeer; - Number numDeleteThis = objDocument["AnotherMember"]; + Number numDeleteThis = objDocument["AnotherMember"]; - objDocument["Delicious Beers"][1]["Name"] = String("John Smith's Extra Smooth"); - objDocument["Delicious Beers"][1]["Origin"] = String("Tadcaster, Yorkshire, UK"); - objDocument["Delicious Beers"][1]["ABV"] = Number(3.8); - objDocument["Delicious Beers"][1]["BottleConditioned"] = Boolean(false); + objDocument["Delicious Beers"][1]["Name"] = String("John Smith's Extra Smooth"); + objDocument["Delicious Beers"][1]["Origin"] = String("Tadcaster, Yorkshire, UK"); + objDocument["Delicious Beers"][1]["ABV"] = Number(3.8); + objDocument["Delicious Beers"][1]["BottleConditioned"] = Boolean(false); - const Object& objRoot = objDocument; + const Object &objRoot = objDocument; - const Array& arrayBeers = objRoot["Delicious Beers"]; - const Object& objBeer0 = arrayBeers[0]; - const String& strName0 = objBeer0["Name"]; + const Array &arrayBeers = objRoot["Delicious Beers"]; + const Object &objBeer0 = arrayBeers[0]; + const String &strName0 = objBeer0["Name"]; - const Number numAbv1 = objRoot["Delicious Beers"][1]["ABV"]; + const Number numAbv1 = objRoot["Delicious Beers"][1]["ABV"]; - std::cout << "First beer name: " << strName0.Value() << std::endl; - std::cout << "First beer ABV: " << numAbv1.Value() << std::endl; + std::cout << "First beer name: " << strName0.Value() << std::endl; + std::cout << "First beer ABV: " << numAbv1.Value() << std::endl; - return 0; + return 0; } diff --git a/recipes/cajun-jsonapi/all/test_v1_package/CMakeLists.txt b/recipes/cajun-jsonapi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7ea0378c83fe1 --- /dev/null +++ b/recipes/cajun-jsonapi/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cajun-jsonapi/all/test_v1_package/conanfile.py b/recipes/cajun-jsonapi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e065617c053bc --- /dev/null +++ b/recipes/cajun-jsonapi/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools, RunEnvironment +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cajun-jsonapi/config.yml b/recipes/cajun-jsonapi/config.yml index fe9068c6bbcb1..84cd2c74fdbc1 100644 --- a/recipes/cajun-jsonapi/config.yml +++ b/recipes/cajun-jsonapi/config.yml @@ -1,3 +1,5 @@ versions: "2.0.3": folder: "all" + "2.1.1": + folder: "all" diff --git a/recipes/calceph/all/conandata.yml b/recipes/calceph/all/conandata.yml index 567accb492faa..f4d850c349cf0 100644 --- a/recipes/calceph/all/conandata.yml +++ b/recipes/calceph/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "3.5.1": + url: "https://www.imcce.fr/content/medias/recherche/equipes/asd/calceph/calceph-3.5.1.tar.gz" + sha256: "33cc0be1b8ffb647aff9d3ac1cf025e460451e00144050d3bbc4f13bceb11c1d" + "3.5.0": + url: "https://www.imcce.fr/content/medias/recherche/equipes/asd/calceph/calceph-3.5.0.tar.gz" + sha256: "2aa9ba47af6a73ab74ae10d1c8efbcfab9068d9d05f016a8a5fe695df7b52e00" "3.4.7": url: "https://www.imcce.fr/content/medias/recherche/equipes/asd/calceph/calceph-3.4.7.tar.gz" sha256: "99ff6c153c888cc514d9c4e8acfb99448ab0bdaff8ef5aaa398a1d4f00c8579f" diff --git a/recipes/calceph/all/conanfile.py b/recipes/calceph/all/conanfile.py index 31e1ce2bf4624..2c626e956a387 100644 --- a/recipes/calceph/all/conanfile.py +++ b/recipes/calceph/all/conanfile.py @@ -1,121 +1,141 @@ -import glob -import os - from conans import ConanFile, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment, tools from conans.errors import ConanInvalidConfiguration +from contextlib import contextmanager +import functools +import os + +required_conan_version = ">=1.33.0" + class CalcephConan(ConanFile): name = "calceph" description = "C Library designed to access the binary planetary ephemeris " \ "files, such INPOPxx, JPL DExxx and SPICE ephemeris files." license = ["CECILL-C", "CECILL-B", "CECILL-2.1"] - topics = ("conan", "calceph", "ephemeris", "astronomy", "space", "planet") + topics = ("calceph", "ephemeris", "astronomy", "space", "planet") homepage = "https://www.imcce.fr/inpop/calceph" url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "threadsafe": [True, False] + "threadsafe": [True, False], } default_options = { "shared": False, "fPIC": True, - "threadsafe": False + "threadsafe": False, } - _autotools= None - _nmake_args = None - @property def _source_subfolder(self): return "source_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self._is_msvc: + del self.options.threadsafe def configure(self): if self.options.shared: del self.options.fPIC del self.settings.compiler.cppstd del self.settings.compiler.libcxx - if self.settings.compiler == "Visual Studio": - del self.options.threadsafe - if self.options.shared: - raise ConanInvalidConfiguration("calceph doesn't support shared builds with Visual Studio yet") + + def validate(self): + if self._is_msvc and self.options.shared: + raise ConanInvalidConfiguration("calceph doesn't support shared builds with Visual Studio yet") def build_requirements(self): - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio" and \ - "CONAN_BASH_PATH" not in os.environ: - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows" and not self._is_msvc and \ + not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): - if self.settings.compiler == "Visual Studio": + if self._is_msvc: tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.vc"), "CFLAGS = /O2 /GR- /MD /nologo /EHs", "CFLAGS = /nologo /EHs") with tools.chdir(self._source_subfolder): - with tools.vcvars(self.settings): - with tools.environment_append(VisualStudioBuildEnvironment(self).vars): - self.run("nmake -f Makefile.vc {}".format(" ".join(self._get_nmake_args()))) + with self._msvc_build_environment(): + self.run("nmake -f Makefile.vc {}".format(self._nmake_args)) else: + # relocatable shared lib on macOS + tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), + "-install_name \\$rpath/", + "-install_name @rpath/") autotools = self._configure_autotools() autotools.make() - def _get_nmake_args(self): - if self._nmake_args: - return self._nmake_args - self._nmake_args = [] - self._nmake_args.append("DESTDIR=\"{}\"".format(self.package_folder)) - self._nmake_args.extend(["ENABLEF2003=0", "ENABLEF77=0"]) - return self._nmake_args + @contextmanager + def _msvc_build_environment(self): + with tools.vcvars(self): + with tools.environment_append(VisualStudioBuildEnvironment(self).vars): + yield + + @property + def _nmake_args(self): + return " ".join([ + "DESTDIR=\"{}\"".format(self.package_folder), + "ENABLEF2003=0", + "ENABLEF77=0", + ]) + @functools.lru_cache(1) def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" args = [ - "--disable-static" if self.options.shared else "--enable-static", - "--enable-shared" if self.options.shared else "--disable-shared", - "--enable-thread" if self.options.threadsafe else "--disable-thread", + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-thread={}".format(yes_no(self.options.threadsafe)), "--disable-fortran", "--disable-python", "--disable-python-package-system", "--disable-python-package-user", - "--disable-mex-octave" + "--disable-mex-octave", ] - self._autotools.configure(args=args, configure_dir=self._source_subfolder) - return self._autotools + autotools.configure(args=args, configure_dir=self._source_subfolder) + return autotools def package(self): self.copy(pattern="COPYING*", dst="licenses", src=self._source_subfolder) - if self.settings.compiler == "Visual Studio": + if self._is_msvc: with tools.chdir(self._source_subfolder): - with tools.vcvars(self.settings): - with tools.environment_append(VisualStudioBuildEnvironment(self).vars): - self.run("nmake -f Makefile.vc install {}".format(" ".join(self._get_nmake_args()))) + with self._msvc_build_environment(): + self.run("nmake -f Makefile.vc install {}".format(self._nmake_args)) tools.rmdir(os.path.join(self.package_folder, "doc")) else: autotools = self._configure_autotools() autotools.install() tools.rmdir(os.path.join(self.package_folder, "share")) - for la_file in glob.glob(os.path.join(self.package_folder, "lib", "*.la")): - os.remove(la_file) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") tools.rmdir(os.path.join(self.package_folder, "libexec")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + prefix = "lib" if self._is_msvc else "" + self.cpp_info.libs = ["{}calceph".format(prefix)] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") if self.options.threadsafe: self.cpp_info.system_libs.append("pthread") - if self.settings.compiler != "Visual Studio": + if not self._is_msvc: bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) diff --git a/recipes/calceph/all/test_package/CMakeLists.txt b/recipes/calceph/all/test_package/CMakeLists.txt index 7b9b613cbb24a..ac91ef75e60e6 100644 --- a/recipes/calceph/all/test_package/CMakeLists.txt +++ b/recipes/calceph/all/test_package/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(calceph REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} calceph::calceph) diff --git a/recipes/calceph/all/test_package/conanfile.py b/recipes/calceph/all/test_package/conanfile.py index ea57a464900be..38f4483872d47 100644 --- a/recipes/calceph/all/test_package/conanfile.py +++ b/recipes/calceph/all/test_package/conanfile.py @@ -1,10 +1,10 @@ +from conans import ConanFile, CMake, tools import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/calceph/config.yml b/recipes/calceph/config.yml index 2976b34a9dff1..8843656f63225 100644 --- a/recipes/calceph/config.yml +++ b/recipes/calceph/config.yml @@ -1,4 +1,8 @@ versions: + "3.5.1": + folder: all + "3.5.0": + folder: all "3.4.7": folder: all "3.4.6": diff --git a/recipes/canary/all/conandata.yml b/recipes/canary/all/conandata.yml new file mode 100644 index 0000000000000..a5b79d2d07ace --- /dev/null +++ b/recipes/canary/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "v1": + url: "https://github.com/djarek/canary/archive/refs/tags/v1.tar.gz" + sha256: "f3e2e80f5c01b4d60aed4b5ec73663158b495caa4f9324a10d05e55ea8f3938c" diff --git a/recipes/canary/all/conanfile.py b/recipes/canary/all/conanfile.py new file mode 100644 index 0000000000000..1a102a8feb035 --- /dev/null +++ b/recipes/canary/all/conanfile.py @@ -0,0 +1,61 @@ +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain +from conan.tools.files import copy, get, rmdir + +required_conan_version = ">=1.53.0" + + +class SocketcanCanaryConan(ConanFile): + name = "canary" + description = "A lightweight implementation of Linux SocketCAN bindings for ASIO/Boost.ASIO" + url = "https://github.com/conan-io/conan-center-index" + license = "BSL-1.0" + homepage = "https://github.com/djarek/canary" + topics = ("socketcan", "can-bus", "can") + + settings = "os", "compiler", "build_type", "arch" + no_copy_source = True + + @property + def _min_cppstd(self): + return 11 + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration(f"{self.ref} only supports Linux.") + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + def requirements(self): + self.requires("boost/1.74.0", transitive_headers=True) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def build(self): + pass + + def package(self): + copy(self, "LICENSE_1_0.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.configure() + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib")) + + def package_id(self): + self.info.clear() + + def package_info(self): + self.cpp_info.requires = ["boost::headers", "boost::system"] + self.cpp_info.set_property("cmake_file_name", "canary") + self.cpp_info.set_property("cmake_target_name", "canary::canary") diff --git a/recipes/canary/all/test_package/CMakeLists.txt b/recipes/canary/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..81f2b230ac92c --- /dev/null +++ b/recipes/canary/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(canary REQUIRED) + +add_executable(test_package test_package.cpp) +target_link_libraries(test_package PUBLIC canary::canary) +target_compile_features(test_package PRIVATE cxx_std_11) diff --git a/recipes/canary/all/test_package/conanfile.py b/recipes/canary/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d94ba2fb11ca8 --- /dev/null +++ b/recipes/canary/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + + +class TestPackage(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/canary/all/test_package/test_package.cpp b/recipes/canary/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..ccec8d0783be7 --- /dev/null +++ b/recipes/canary/all/test_package/test_package.cpp @@ -0,0 +1,15 @@ +#include +#include + +int main() +{ + try { + auto index = canary::get_interface_index("vcan0"); + std::cout << "vcan0 interface index: " << index << "\n"; + } + catch (std::exception& exc) { + std::cout << "unable to find vcan0: " << exc.what() << "\n"; + } + + return 0; +} diff --git a/recipes/canary/all/test_v1_package/CMakeLists.txt b/recipes/canary/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..81f2b230ac92c --- /dev/null +++ b/recipes/canary/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(canary REQUIRED) + +add_executable(test_package test_package.cpp) +target_link_libraries(test_package PUBLIC canary::canary) +target_compile_features(test_package PRIVATE cxx_std_11) diff --git a/recipes/canary/all/test_v1_package/conanfile.py b/recipes/canary/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..f8bae5c00ce0a --- /dev/null +++ b/recipes/canary/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import CMake, ConanFile, tools + + +class TestPackage(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join(".", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/canary/all/test_v1_package/test_package.cpp b/recipes/canary/all/test_v1_package/test_package.cpp new file mode 100644 index 0000000000000..ccec8d0783be7 --- /dev/null +++ b/recipes/canary/all/test_v1_package/test_package.cpp @@ -0,0 +1,15 @@ +#include +#include + +int main() +{ + try { + auto index = canary::get_interface_index("vcan0"); + std::cout << "vcan0 interface index: " << index << "\n"; + } + catch (std::exception& exc) { + std::cout << "unable to find vcan0: " << exc.what() << "\n"; + } + + return 0; +} diff --git a/recipes/canary/config.yml b/recipes/canary/config.yml new file mode 100644 index 0000000000000..96340c06c871e --- /dev/null +++ b/recipes/canary/config.yml @@ -0,0 +1,3 @@ +versions: + "v1": + folder: all diff --git a/recipes/canvas_ity/all/conandata.yml b/recipes/canvas_ity/all/conandata.yml new file mode 100644 index 0000000000000..4bd2a5a6b3481 --- /dev/null +++ b/recipes/canvas_ity/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.00": + url: "https://github.com/a-e-k/canvas_ity/archive/f32fbb37e2fe7c0fcaee6ebdc02d3e5385603fd5.tar.gz" + sha256: "be0d9ef9a023ba732e403fe8c1ec9e1cd8f02c75777c09562067c9270612a3ed" diff --git a/recipes/canvas_ity/all/conanfile.py b/recipes/canvas_ity/all/conanfile.py new file mode 100644 index 0000000000000..b4527ac4677c7 --- /dev/null +++ b/recipes/canvas_ity/all/conanfile.py @@ -0,0 +1,48 @@ +from conan import ConanFile +from conan.tools.files import get, copy, load, save +from conan.tools.layout import basic_layout +import os + + +required_conan_version = ">=1.50.0" + + +class CanvasItyConan(ConanFile): + name = "canvas_ity" + description = "A tiny, single-header -like 2D rasterizer for C++" + license = "ISC" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/a-e-k/canvas_ity" + topics = ("rasterizer", "canvas", "2d", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + filename = os.path.join(self.source_folder, "src", "canvas_ity.hpp") + file_content = load(self, filename) + license_end = "// ======== ABOUT ========" + license_contents = file_content[:file_content.find(license_end)].replace("//", "") + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), license_contents) + + copy( + self, + pattern="*.hpp", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "src"), + ) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/canvas_ity/all/test_package/CMakeLists.txt b/recipes/canvas_ity/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d050dc832dd0b --- /dev/null +++ b/recipes/canvas_ity/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(canvas_ity REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE canvas_ity::canvas_ity) diff --git a/recipes/canvas_ity/all/test_package/conanfile.py b/recipes/canvas_ity/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e845ae751a301 --- /dev/null +++ b/recipes/canvas_ity/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/canvas_ity/all/test_package/test_package.cpp b/recipes/canvas_ity/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..84a5a4297d714 --- /dev/null +++ b/recipes/canvas_ity/all/test_package/test_package.cpp @@ -0,0 +1,71 @@ +#include +#include + +#define CANVAS_ITY_IMPLEMENTATION +#include "canvas_ity.hpp" + +int main() { + // Construct the canvas. + static int const width = 256, height = 256; + canvas_ity::canvas context( width, height ); + + // Build a star path. + context.move_to( 128.0f, 28.0f ); context.line_to( 157.0f, 87.0f ); + context.line_to( 223.0f, 97.0f ); context.line_to( 175.0f, 143.0f ); + context.line_to( 186.0f, 208.0f ); context.line_to( 128.0f, 178.0f ); + context.line_to( 69.0f, 208.0f ); context.line_to( 80.0f, 143.0f ); + context.line_to( 32.0f, 97.0f ); context.line_to( 98.0f, 87.0f ); + context.close_path(); + + // Set up the drop shadow. + context.set_shadow_blur( 8.0f ); + context.shadow_offset_y = 4.0f; + context.set_shadow_color( 0.0f, 0.0f, 0.0f, 0.5f ); + + // Fill the star with yellow. + context.set_color( canvas_ity::fill_style, 1.0f, 0.9f, 0.2f, 1.0f ); + context.fill(); + + // Draw the star with a thick red stroke and rounded points. + context.line_join = canvas_ity::rounded; + context.set_line_width( 12.0f ); + context.set_color( canvas_ity::stroke_style, 0.9f, 0.0f, 0.5f, 1.0f ); + context.stroke(); + + // Draw the star again with a dashed thinner orange stroke. + float segments[] = { 21.0f, 9.0f, 1.0f, 9.0f, 7.0f, 9.0f, 1.0f, 9.0f }; + context.set_line_dash( segments, 8 ); + context.line_dash_offset = 10.0f; + context.line_cap = canvas_ity::circle; + context.set_line_width( 6.0f ); + context.set_color( canvas_ity::stroke_style, 0.95f, 0.65f, 0.15f, 1.0f ); + context.stroke(); + + // Turn off the drop shadow. + context.set_shadow_color( 0.0f, 0.0f, 0.0f, 0.0f ); + + // Add a shine layer over the star. + context.set_linear_gradient( canvas_ity::fill_style, 64.0f, 0.0f, 192.0f, 256.0f ); + context.add_color_stop( canvas_ity::fill_style, 0.30f, 1.0f, 1.0f, 1.0f, 0.0f ); + context.add_color_stop( canvas_ity::fill_style, 0.35f, 1.0f, 1.0f, 1.0f, 0.8f ); + context.add_color_stop( canvas_ity::fill_style, 0.45f, 1.0f, 1.0f, 1.0f, 0.8f ); + context.add_color_stop( canvas_ity::fill_style, 0.50f, 1.0f, 1.0f, 1.0f, 0.0f ); + + context.global_composite_operation = canvas_ity::source_atop; + context.fill_rectangle( 0.0f, 0.0f, 256.0f, 256.0f ); + + // Fetch the rendered RGBA pixels from the entire canvas. + unsigned char *image = new unsigned char[ height * width * 4 ]; + context.get_image_data( image, width, height, width * 4, 0, 0 ); + // Write them out to a TGA image file (TGA uses BGRA order). + unsigned char header[] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + width & 255, width >> 8, height & 255, height >> 8, 32, 40 }; + for ( int pixel = 0; pixel < height * width; ++pixel ) + std::swap( image[ pixel * 4 + 0 ], image[ pixel * 4 + 2 ] ); + std::ofstream stream( "example.tga", std::ios::binary ); + stream.write( reinterpret_cast< char * >( header ), sizeof( header ) ); + stream.write( reinterpret_cast< char * >( image ), height * width * 4 ); + delete[] image; + + return 0; +} diff --git a/recipes/canvas_ity/all/test_v1_package/CMakeLists.txt b/recipes/canvas_ity/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/canvas_ity/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/canvas_ity/all/test_v1_package/conanfile.py b/recipes/canvas_ity/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/canvas_ity/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/canvas_ity/config.yml b/recipes/canvas_ity/config.yml new file mode 100644 index 0000000000000..5ec3e5033421a --- /dev/null +++ b/recipes/canvas_ity/config.yml @@ -0,0 +1,3 @@ +versions: + "1.00": + folder: all diff --git a/recipes/capnproto/all/conandata.yml b/recipes/capnproto/all/conandata.yml index 79fd67a5869f8..90455ae513317 100644 --- a/recipes/capnproto/all/conandata.yml +++ b/recipes/capnproto/all/conandata.yml @@ -1,8 +1,33 @@ sources: + "0.10.1": + url: "https://github.com/capnproto/capnproto/archive/v0.10.1.tar.gz" + sha256: "2e9c918f02c198557c75ca7c635fe281337c9755b752a6ab3a841bcc1cf5176b" + "0.10.0": + url: "https://github.com/capnproto/capnproto/archive/v0.10.0.tar.gz" + sha256: "0e46a72d086830762c001116c0a146098fbdce3cd40665a0ffd4742962d42bfd" + "0.9.1": + url: "https://github.com/capnproto/capnproto/archive/v0.9.1.tar.gz" + sha256: "daf49f794560f715e2f4651c842aaece2d065d4216834c5c3d3254962e35b535" "0.8.0": url: "https://github.com/capnproto/capnproto/archive/v0.8.0.tar.gz" sha256: "6d8b43a7ec2a764b4dfe4139a7cdd070ad9057f106898050d9f4db3754b98820" + "0.7.0": + url: "https://github.com/capnproto/capnproto/archive/v0.7.0.tar.gz" + sha256: 76c7114a3d142ad08b7208b3964a26e72a6320ee81331d3f0b87569fc9c47a28 patches: + "0.10.1": + - patch_file: patches/0014-disable-tests-for-0.10.1.patch + base_path: source_subfolder + "0.10.0": + - patch_file: patches/0013-disable-tests-for-0.10.0.patch + base_path: source_subfolder + "0.9.1": + - patch_file: patches/0010-disable-tests-for-0.9.1.patch + base_path: source_subfolder + - patch_file: patches/0011-msvc-cpp17-hassubstring-fix-0.9.1.patch + base_path: source_subfolder + - patch_file: patches/0012-msvc-nogdi-fix-0.9.1.patch + base_path: source_subfolder "0.8.0": - patch_file: patches/0001-disable-tests.patch base_path: source_subfolder @@ -14,3 +39,12 @@ patches: base_path: source_subfolder - patch_file: patches/0005-msvc-16.7-ice-workaround.patch base_path: source_subfolder + - patch_file: patches/0009-windows-symlink-fix-0.8.0.patch + base_path: source_subfolder + "0.7.0": + - patch_file: patches/0006-symlink.patch + base_path: source_subfolder + - patch_file: patches/0007-cmake-module-path.patch + base_path: source_subfolder + - patch_file: patches/0008-disable-tests.patch + base_path: source_subfolder diff --git a/recipes/capnproto/all/conanfile.py b/recipes/capnproto/all/conanfile.py index bac50c25bdc85..4d5fd86b03ef9 100644 --- a/recipes/capnproto/all/conanfile.py +++ b/recipes/capnproto/all/conanfile.py @@ -1,36 +1,37 @@ from conans import ConanFile, CMake, tools, AutoToolsBuildEnvironment from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc import glob import os +import textwrap +import functools -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.43.0" class CapnprotoConan(ConanFile): name = "capnproto" description = "Cap'n Proto serialization/RPC system." license = "MIT" - topics = ("conan", "capnproto", "serialization", "rpc") + topics = ("capnproto", "serialization", "rpc") homepage = "https://capnproto.org" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ("CMakeLists.txt", "patches/**") - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "with_openssl": [True, False], - "with_zlib": [True, False] + "with_zlib": [True, False], } default_options = { "shared": False, "fPIC": True, "with_openssl": True, - "with_zlib": True + "with_zlib": True, } - _cmake = None - _autotools = None + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): @@ -49,28 +50,39 @@ def _minimum_compilers_version(self): "apple-clang": "5.1", } + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if tools.Version(self.version) < "0.8.0": + del self.options.with_zlib def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: + + def requirements(self): + if self.options.with_openssl: + self.requires("openssl/1.1.1o") + if self.options.get_safe("with_zlib"): + self.requires("zlib/1.2.12") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, 14) minimum_version = self._minimum_compilers_version.get(str(self.settings.compiler), False) if not minimum_version: self.output.warn("Cap'n Proto requires C++14. Your compiler is unknown. Assuming it supports C++14.") elif tools.Version(self.settings.compiler.version) < minimum_version: raise ConanInvalidConfiguration("Cap'n Proto requires C++14, which your compiler does not support.") - if self.settings.compiler == "Visual Studio" and self.options.shared: + if is_msvc(self) and self.options.shared: raise ConanInvalidConfiguration("Cap'n Proto doesn't support shared libraries for Visual Studio") - - def requirements(self): - if self.options.with_openssl: - self.requires("openssl/1.1.1k") - if self.options.with_zlib: - self.requires("zlib/1.2.11") + if self.settings.os == "Windows" and tools.Version(self.version) < "0.8.0" and self.options.with_openssl: + raise ConanInvalidConfiguration("Cap'n Proto doesn't support OpenSSL on Windows pre 0.8.0") def build_requirements(self): if self.settings.os != "Windows": @@ -80,30 +92,32 @@ def source(self): tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.definitions["EXTERNAL_CAPNP"] = False - self._cmake.definitions["CAPNP_LITE"] = False - self._cmake.definitions["WITH_OPENSSL"] = self.options.with_openssl - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - + cmake = CMake(self) + cmake.definitions["BUILD_TESTING"] = False + cmake.definitions["EXTERNAL_CAPNP"] = False + cmake.definitions["CAPNP_LITE"] = False + cmake.definitions["WITH_OPENSSL"] = self.options.with_openssl + cmake.configure(build_folder=self._build_subfolder) + return cmake + + @functools.lru_cache(1) def _configure_autotools(self): - if self._autotools: - return self._autotools args = [ "--enable-shared" if self.options.shared else "--disable-shared", "--disable-static" if self.options.shared else "--enable-static", "--with-openssl" if self.options.with_openssl else "--without-openssl", - "--with-zlib" if self.options.with_zlib else "--without-zlib", - "--enable-reflection" + "--enable-reflection", ] - self._autotools = AutoToolsBuildEnvironment(self) - self._autotools.configure(args=args, configure_dir=os.path.join(self._source_subfolder, "c++")) - return self._autotools + if tools.Version(self.version) >= "0.8.0": + args.append("--with-zlib" if self.options.with_zlib else "--without-zlib") + autotools = AutoToolsBuildEnvironment(self) + # Fix rpath on macOS + if self.settings.os == "Macos": + autotools.link_flags.append("-Wl,-rpath,@loader_path/../lib") + autotools.configure(args=args) + return autotools def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): @@ -113,9 +127,19 @@ def build(self): cmake.build() else: with tools.chdir(os.path.join(self._source_subfolder, "c++")): - self.run("{} --install --verbose -Wall".format(tools.get_env("AUTORECONF"))) - autotools = self._configure_autotools() - autotools.make() + self.run("{} -fiv".format(tools.get_env("AUTORECONF"))) + # relocatable shared libs on macOS + tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name @rpath/") + # avoid SIP issues on macOS when dependencies are shared + if tools.is_apple_os(self.settings.os): + libpaths = ":".join(self.deps_cpp_info.lib_paths) + tools.replace_in_file( + "configure", + "#! /bin/sh\n", + "#! /bin/sh\nexport DYLD_LIBRARY_PATH={}:$DYLD_LIBRARY_PATH\n".format(libpaths), + ) + autotools = self._configure_autotools() + autotools.make() @property def _cmake_folder(self): @@ -127,8 +151,9 @@ def package(self): cmake = self._configure_cmake() cmake.install() else: - autotools = self._configure_autotools() - autotools.install() + with tools.chdir(os.path.join(self._source_subfolder, "c++")): + autotools = self._configure_autotools() + autotools.install() tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) for cmake_file in glob.glob(os.path.join(self.package_folder, self._cmake_folder, "*")): @@ -136,16 +161,28 @@ def package(self): os.remove(cmake_file) # inject mandatory variables so that CAPNP_GENERATE_CPP function can # work in a robust way (build from source or from pre build package) + find_execs = textwrap.dedent("""\ + if(CMAKE_CROSSCOMPILING) + find_program(CAPNP_EXECUTABLE capnp PATHS ENV PATH NO_DEFAULT_PATH) + find_program(CAPNPC_CXX_EXECUTABLE capnpc-c++ PATHS ENV PATH NO_DEFAULT_PATH) + endif() + if(NOT CAPNP_EXECUTABLE) + set(CAPNP_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/../../../bin/capnp${CMAKE_EXECUTABLE_SUFFIX}") + endif() + if(NOT CAPNPC_CXX_EXECUTABLE) + set(CAPNPC_CXX_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/../../../bin/capnpc-c++${CMAKE_EXECUTABLE_SUFFIX}") + endif() + set(CAPNP_INCLUDE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../../../include") + function(CAPNP_GENERATE_CPP SOURCES HEADERS) + """) tools.replace_in_file(os.path.join(self.package_folder, self._cmake_folder, "CapnProtoMacros.cmake"), "function(CAPNP_GENERATE_CPP SOURCES HEADERS)", - """set(CAPNP_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/../../../bin/capnp${CMAKE_EXECUTABLE_SUFFIX}") -set(CAPNPC_CXX_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/../../../bin/capnpc-c++${CMAKE_EXECUTABLE_SUFFIX}") -set(CAPNP_INCLUDE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../../../include") -function(CAPNP_GENERATE_CPP SOURCES HEADERS)""") + find_execs) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "CapnProto" - self.cpp_info.names["cmake_find_package_multi"] = "CapnProto" + self.cpp_info.set_property("cmake_file_name", "CapnProto") + capnprotomacros = os.path.join(self._cmake_folder, "CapnProtoMacros.cmake") + self.cpp_info.set_property("cmake_build_modules", [capnprotomacros]) components = [ {"name": "capnp", "requires": ["kj"]}, @@ -157,31 +194,39 @@ def package_info(self): {"name": "kj-http", "requires": ["kj", "kj-async"]}, {"name": "kj-test", "requires": ["kj"]}, ] - if self.options.with_zlib: + if self.options.get_safe("with_zlib"): components.append({"name": "kj-gzip", "requires": ["kj", "kj-async", "zlib::zlib"]}) if self.options.with_openssl: components.append({"name": "kj-tls", "requires": ["kj", "kj-async", "openssl::openssl"]}) + if tools.Version(self.version) >= "0.9.0": + components.append({ + "name": "capnp-websocket", + "requires": ["capnp", "capnp-rpc", "kj-http", "kj-async", "kj"], + }) for component in components: self._register_component(component) - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["capnpc"].system_libs = ["pthread"] self.cpp_info.components["kj"].system_libs = ["pthread"] self.cpp_info.components["kj-async"].system_libs = ["pthread"] elif self.settings.os == "Windows": self.cpp_info.components["kj-async"].system_libs = ["ws2_32"] - self.cpp_info.components["kj"].builddirs.append(self._cmake_folder) - self.cpp_info.components["kj"].build_modules = [os.path.join(self._cmake_folder, "CapnProtoMacros.cmake")] bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH env var with: {}".format(bin_path)) self.env_info.PATH.append(bin_path) + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "CapnProto" + self.cpp_info.names["cmake_find_package_multi"] = "CapnProto" + self.cpp_info.components["kj"].build_modules = [capnprotomacros] + def _register_component(self, component): name = component["name"] - self.cpp_info.components[name].names["cmake_find_package"] = name - self.cpp_info.components[name].names["cmake_find_package_multi"] = name - self.cpp_info.components[name].names["pkg_config"] = name + self.cpp_info.components[name].set_property("cmake_target_name", "CapnProto::{}".format(name)) + self.cpp_info.components[name].builddirs.append(self._cmake_folder) + self.cpp_info.components[name].set_property("pkg_config_name", name) self.cpp_info.components[name].libs = [name] self.cpp_info.components[name].requires = component["requires"] diff --git a/recipes/capnproto/all/patches/0006-symlink.patch b/recipes/capnproto/all/patches/0006-symlink.patch new file mode 100644 index 0000000000000..ddf7b7ec382ec --- /dev/null +++ b/recipes/capnproto/all/patches/0006-symlink.patch @@ -0,0 +1,38 @@ +From fdbf035619ab2f9e25173bb7361e7e19a52e0fa1 Mon Sep 17 00:00:00 2001 +From: Thomas Arcila +Date: Sat, 9 Mar 2019 19:00:24 -0500 +Subject: [PATCH] Fix capnpc extension handling on Windows + +On Windows executables needs to end with .exe. +Fix this in CMakeLists.txt and update capnp detection code accordingly. +--- + c++/src/capnp/CMakeLists.txt | 2 +- + c++/src/capnp/compiler/capnp.c++ | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/c++/src/capnp/CMakeLists.txt b/c++/src/capnp/CMakeLists.txt +index 11cbf5afa..041697466 100644 +--- a/c++/src/capnp/CMakeLists.txt ++++ b/c++/src/capnp/CMakeLists.txt +@@ -182,7 +182,7 @@ if(NOT CAPNP_LITE) + install(TARGETS capnp_tool capnpc_cpp capnpc_capnp ${INSTALL_TARGETS_DEFAULT_ARGS}) + + # Symlink capnpc -> capnp +- install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink capnp \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/capnpc\")") ++ install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink capnp${CMAKE_EXECUTABLE_SUFFIX} \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/capnpc${CMAKE_EXECUTABLE_SUFFIX}\")") + endif() # NOT CAPNP_LITE + + # Tests ======================================================================== +diff --git a/c++/src/capnp/compiler/capnp.c++ b/c++/src/capnp/compiler/capnp.c++ +index 8e8c459b2..d252fb12b 100644 +--- a/c++/src/capnp/compiler/capnp.c++ ++++ b/c++/src/capnp/compiler/capnp.c++ +@@ -78,7 +78,7 @@ public: + : context(context), disk(kj::newDiskFilesystem()), loader(*this) {} + + kj::MainFunc getMain() { +- if (context.getProgramName().endsWith("capnpc")) { ++ if (context.getProgramName().endsWith("capnpc") || context.getProgramName().endsWith("capnpc.exe")) { + kj::MainBuilder builder(context, VERSION_STRING, + "Compiles Cap'n Proto schema files and generates corresponding source code in one or " + "more languages."); diff --git a/recipes/capnproto/all/patches/0007-cmake-module-path.patch b/recipes/capnproto/all/patches/0007-cmake-module-path.patch new file mode 100644 index 0000000000000..7ee7d0eb8de70 --- /dev/null +++ b/recipes/capnproto/all/patches/0007-cmake-module-path.patch @@ -0,0 +1,11 @@ +--- a/c++/CMakeLists.txt ++++ b/c++/CMakeLists.txt +@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1) + project("Cap'n Proto" CXX) + set(VERSION 0.7.0) + +-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + + include(CheckIncludeFileCXX) + include(GNUInstallDirs) diff --git a/recipes/capnproto/all/patches/0008-disable-tests.patch b/recipes/capnproto/all/patches/0008-disable-tests.patch new file mode 100644 index 0000000000000..dee1e36a10227 --- /dev/null +++ b/recipes/capnproto/all/patches/0008-disable-tests.patch @@ -0,0 +1,157 @@ +--- a/c++/Makefile.am ++++ b/c++/Makefile.am +@@ -403,154 +407,3 @@ endif LITE_MODE + # src/capnp/serialize-snappy* + # src/capnp/benchmark/... + # src/capnp/compiler/... +- +-# Tests ============================================================== +- +-test_capnpc_inputs = \ +- src/capnp/test.capnp \ +- src/capnp/test-import.capnp \ +- src/capnp/test-import2.capnp \ +- src/capnp/compat/json-test.capnp +- +-test_capnpc_outputs = \ +- src/capnp/test.capnp.c++ \ +- src/capnp/test.capnp.h \ +- src/capnp/test-import.capnp.c++ \ +- src/capnp/test-import.capnp.h \ +- src/capnp/test-import2.capnp.c++ \ +- src/capnp/test-import2.capnp.h \ +- src/capnp/compat/json-test.capnp.c++ \ +- src/capnp/compat/json-test.capnp.h +- +-if USE_EXTERNAL_CAPNP +- +-test_capnpc_middleman: $(test_capnpc_inputs) +- @$(MKDIR_P) src +- $(CAPNP) compile --src-prefix=$(srcdir)/src -o$(CAPNPC_CXX):src -I$(srcdir)/src $^ +- touch test_capnpc_middleman +- +-else +- +-test_capnpc_middleman: capnp$(EXEEXT) capnpc-c++$(EXEEXT) $(test_capnpc_inputs) +- @$(MKDIR_P) src +- echo $^ | (read CAPNP CAPNPC_CXX SOURCES && ./$$CAPNP compile --src-prefix=$(srcdir)/src -o./$$CAPNPC_CXX:src -I$(srcdir)/src $$SOURCES) +- touch test_capnpc_middleman +- +-endif +- +-$(test_capnpc_outputs): test_capnpc_middleman +- +-BUILT_SOURCES = $(test_capnpc_outputs) +- +-check_LIBRARIES = libcapnp-test.a +-libcapnp_test_a_SOURCES = \ +- src/capnp/test-util.c++ \ +- src/capnp/test-util.h +-nodist_libcapnp_test_a_SOURCES = $(test_capnpc_outputs) +- +-if LITE_MODE +- +-check_PROGRAMS = capnp-test +-compiler_tests = +-capnp_test_LDADD = libcapnp-test.a libcapnp.la libkj-test.la libkj.la +- +-else !LITE_MODE +- +-check_PROGRAMS = capnp-test capnp-evolution-test capnp-afl-testcase +-heavy_tests = \ +- src/kj/async-test.c++ \ +- src/kj/async-unix-test.c++ \ +- src/kj/async-win32-test.c++ \ +- src/kj/async-io-test.c++ \ +- src/kj/parse/common-test.c++ \ +- src/kj/parse/char-test.c++ \ +- src/kj/std/iostream-test.c++ \ +- src/kj/compat/url-test.c++ \ +- src/kj/compat/http-test.c++ \ +- src/kj/compat/gzip-test.c++ \ +- $(MAYBE_KJ_TLS_TESTS) \ +- src/capnp/canonicalize-test.c++ \ +- src/capnp/capability-test.c++ \ +- src/capnp/membrane-test.c++ \ +- src/capnp/schema-test.c++ \ +- src/capnp/schema-loader-test.c++ \ +- src/capnp/schema-parser-test.c++ \ +- src/capnp/dynamic-test.c++ \ +- src/capnp/stringify-test.c++ \ +- src/capnp/serialize-async-test.c++ \ +- src/capnp/serialize-text-test.c++ \ +- src/capnp/rpc-test.c++ \ +- src/capnp/rpc-twoparty-test.c++ \ +- src/capnp/ez-rpc-test.c++ \ +- src/capnp/compat/json-test.c++ \ +- src/capnp/compiler/lexer-test.c++ \ +- src/capnp/compiler/type-id-test.c++ +-capnp_test_LDADD = \ +- libcapnp-test.a \ +- libcapnpc.la \ +- libcapnp-rpc.la \ +- libcapnp-json.la \ +- libcapnp.la \ +- libkj-http.la \ +- $(MAYBE_KJ_TLS_LA) \ +- libkj-async.la \ +- libkj-test.la \ +- libkj.la \ +- $(ASYNC_LIBS) \ +- $(PTHREAD_LIBS) +- +-endif !LITE_MODE +- +-capnp_test_CPPFLAGS = -Wno-deprecated-declarations +-capnp_test_SOURCES = \ +- src/kj/common-test.c++ \ +- src/kj/memory-test.c++ \ +- src/kj/refcount-test.c++ \ +- src/kj/array-test.c++ \ +- src/kj/string-test.c++ \ +- src/kj/string-tree-test.c++ \ +- src/kj/table-test.c++ \ +- src/kj/map-test.c++ \ +- src/kj/encoding-test.c++ \ +- src/kj/exception-test.c++ \ +- src/kj/debug-test.c++ \ +- src/kj/arena-test.c++ \ +- src/kj/units-test.c++ \ +- src/kj/tuple-test.c++ \ +- src/kj/one-of-test.c++ \ +- src/kj/function-test.c++ \ +- src/kj/io-test.c++ \ +- src/kj/mutex-test.c++ \ +- src/kj/threadlocal-test.c++ \ +- src/kj/threadlocal-pthread-test.c++ \ +- src/kj/filesystem-test.c++ \ +- src/kj/filesystem-disk-test.c++ \ +- src/kj/test-test.c++ \ +- src/capnp/common-test.c++ \ +- src/capnp/blob-test.c++ \ +- src/capnp/endian-test.c++ \ +- src/capnp/endian-fallback-test.c++ \ +- src/capnp/endian-reverse-test.c++ \ +- src/capnp/layout-test.c++ \ +- src/capnp/any-test.c++ \ +- src/capnp/message-test.c++ \ +- src/capnp/encoding-test.c++ \ +- src/capnp/orphan-test.c++ \ +- src/capnp/serialize-test.c++ \ +- src/capnp/serialize-packed-test.c++ \ +- src/capnp/fuzz-test.c++ \ +- $(heavy_tests) +- +-if !LITE_MODE +-capnp_evolution_test_LDADD = libcapnpc.la libcapnp.la libkj.la +-capnp_evolution_test_SOURCES = src/capnp/compiler/evolution-test.c++ +- +-capnp_afl_testcase_LDADD = libcapnp-test.a libcapnp-rpc.la libcapnp.la libkj.la libkj-async.la +-capnp_afl_testcase_SOURCES = src/capnp/afl-testcase.c++ +-endif !LITE_MODE +- +-if LITE_MODE +-TESTS = capnp-test +-else !LITE_MODE +-TESTS = capnp-test capnp-evolution-test src/capnp/compiler/capnp-test.sh +-endif !LITE_MODE diff --git a/recipes/capnproto/all/patches/0009-windows-symlink-fix-0.8.0.patch b/recipes/capnproto/all/patches/0009-windows-symlink-fix-0.8.0.patch new file mode 100644 index 0000000000000..47da876301b50 --- /dev/null +++ b/recipes/capnproto/all/patches/0009-windows-symlink-fix-0.8.0.patch @@ -0,0 +1,20 @@ +Workaround for install step on Windows where symlinks might be not supported. +This leads to the following error: +CMake error : failed to create symbolic link ... : operation not permitted +--- a/c++/src/capnp/CMakeLists.txt ++++ b/c++/src/capnp/CMakeLists.txt +@@ -188,8 +188,12 @@ if(NOT CAPNP_LITE) + + install(TARGETS capnp_tool capnpc_cpp capnpc_capnp ${INSTALL_TARGETS_DEFAULT_ARGS}) + +- # Symlink capnpc -> capnp +- install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink capnp${CMAKE_EXECUTABLE_SUFFIX} \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/capnpc${CMAKE_EXECUTABLE_SUFFIX}\")") ++ if(WIN32) ++ install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E copy \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/capnp${CMAKE_EXECUTABLE_SUFFIX}\" \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/capnpc${CMAKE_EXECUTABLE_SUFFIX}\")") ++ else() ++ # Symlink capnpc -> capnp ++ install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink capnp${CMAKE_EXECUTABLE_SUFFIX} \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/capnpc${CMAKE_EXECUTABLE_SUFFIX}\")") ++ endif() + endif() # NOT CAPNP_LITE + + # Tests ======================================================================== diff --git a/recipes/capnproto/all/patches/0010-disable-tests-for-0.9.1.patch b/recipes/capnproto/all/patches/0010-disable-tests-for-0.9.1.patch new file mode 100644 index 0000000000000..d421b4b60ddcc --- /dev/null +++ b/recipes/capnproto/all/patches/0010-disable-tests-for-0.9.1.patch @@ -0,0 +1,185 @@ +Disable tests for 0.9.1 + +--- + c++/Makefile.am | 168 ------------------------------------------------ + 1 file changed, 168 deletions(-) + +diff --git a/c++/Makefile.am b/c++/Makefile.am +index 1e3fd8e9..488e54d5 100644 +--- a/c++/Makefile.am ++++ b/c++/Makefile.am +@@ -444,171 +444,3 @@ endif LITE_MODE + # src/capnp/serialize-snappy* + # src/capnp/benchmark/... + # src/capnp/compiler/... +- +-# Tests ============================================================== +- +-test_capnpc_inputs = \ +- src/capnp/test.capnp \ +- src/capnp/test-import.capnp \ +- src/capnp/test-import2.capnp \ +- src/capnp/compat/json-test.capnp +- +-test_capnpc_outputs = \ +- src/capnp/test.capnp.c++ \ +- src/capnp/test.capnp.h \ +- src/capnp/test-import.capnp.c++ \ +- src/capnp/test-import.capnp.h \ +- src/capnp/test-import2.capnp.c++ \ +- src/capnp/test-import2.capnp.h \ +- src/capnp/compat/json-test.capnp.c++ \ +- src/capnp/compat/json-test.capnp.h +- +-if USE_EXTERNAL_CAPNP +- +-test_capnpc_middleman: $(test_capnpc_inputs) +- @$(MKDIR_P) src +- $(CAPNP) compile --src-prefix=$(srcdir)/src -o$(CAPNPC_CXX):src -I$(srcdir)/src $$(for FILE in $(test_capnpc_inputs); do echo $(srcdir)/$$FILE; done) +- touch test_capnpc_middleman +- +-else +- +-test_capnpc_middleman: capnp$(EXEEXT) capnpc-c++$(EXEEXT) $(test_capnpc_inputs) +- @$(MKDIR_P) src +- ./capnp$(EXEEXT) compile --src-prefix=$(srcdir)/src -o./capnpc-c++$(EXEEXT):src -I$(srcdir)/src $$(for FILE in $(test_capnpc_inputs); do echo $(srcdir)/$$FILE; done) +- touch test_capnpc_middleman +- +-endif +- +-$(test_capnpc_outputs): test_capnpc_middleman +- +-BUILT_SOURCES = $(test_capnpc_outputs) +- +-check_LIBRARIES = libcapnp-test.a +-libcapnp_test_a_SOURCES = \ +- src/capnp/test-util.c++ \ +- src/capnp/test-util.h +-nodist_libcapnp_test_a_SOURCES = $(test_capnpc_outputs) +- +-if LITE_MODE +- +-check_PROGRAMS = capnp-test +-compiler_tests = +-capnp_test_LDADD = libcapnp-test.a libcapnp.la libkj-test.la libkj.la +- +-else !LITE_MODE +- +-check_PROGRAMS = capnp-test capnp-evolution-test capnp-afl-testcase +-if HAS_FUZZING_ENGINE +- check_PROGRAMS += capnp-llvm-fuzzer-testcase +-endif +-heavy_tests = \ +- src/kj/async-test.c++ \ +- src/kj/async-xthread-test.c++ \ +- src/kj/async-unix-test.c++ \ +- src/kj/async-unix-xthread-test.c++ \ +- src/kj/async-win32-test.c++ \ +- src/kj/async-win32-xthread-test.c++ \ +- src/kj/async-io-test.c++ \ +- src/kj/async-queue-test.c++ \ +- src/kj/parse/common-test.c++ \ +- src/kj/parse/char-test.c++ \ +- src/kj/std/iostream-test.c++ \ +- src/kj/compat/url-test.c++ \ +- src/kj/compat/http-test.c++ \ +- $(MAYBE_KJ_GZIP_TESTS) \ +- $(MAYBE_KJ_TLS_TESTS) \ +- src/capnp/canonicalize-test.c++ \ +- src/capnp/capability-test.c++ \ +- src/capnp/membrane-test.c++ \ +- src/capnp/schema-test.c++ \ +- src/capnp/schema-loader-test.c++ \ +- src/capnp/schema-parser-test.c++ \ +- src/capnp/dynamic-test.c++ \ +- src/capnp/stringify-test.c++ \ +- src/capnp/serialize-async-test.c++ \ +- src/capnp/serialize-text-test.c++ \ +- src/capnp/rpc-test.c++ \ +- src/capnp/rpc-twoparty-test.c++ \ +- src/capnp/ez-rpc-test.c++ \ +- src/capnp/compat/json-test.c++ \ +- src/capnp/compat/websocket-rpc-test.c++ \ +- src/capnp/compiler/lexer-test.c++ \ +- src/capnp/compiler/type-id-test.c++ +-capnp_test_LDADD = \ +- libcapnp-test.a \ +- libcapnpc.la \ +- libcapnp-rpc.la \ +- libcapnp-websocket.la \ +- libcapnp-json.la \ +- libcapnp.la \ +- libkj-http.la \ +- $(MAYBE_KJ_GZIP_LA) \ +- $(MAYBE_KJ_TLS_LA) \ +- libkj-async.la \ +- libkj-test.la \ +- libkj.la \ +- $(ASYNC_LIBS) \ +- $(PTHREAD_LIBS) +- +-endif !LITE_MODE +- +-capnp_test_CPPFLAGS = -Wno-deprecated-declarations +-capnp_test_SOURCES = \ +- src/kj/common-test.c++ \ +- src/kj/memory-test.c++ \ +- src/kj/refcount-test.c++ \ +- src/kj/array-test.c++ \ +- src/kj/list-test.c++ \ +- src/kj/string-test.c++ \ +- src/kj/string-tree-test.c++ \ +- src/kj/table-test.c++ \ +- src/kj/map-test.c++ \ +- src/kj/encoding-test.c++ \ +- src/kj/exception-test.c++ \ +- src/kj/debug-test.c++ \ +- src/kj/arena-test.c++ \ +- src/kj/units-test.c++ \ +- src/kj/tuple-test.c++ \ +- src/kj/one-of-test.c++ \ +- src/kj/function-test.c++ \ +- src/kj/io-test.c++ \ +- src/kj/mutex-test.c++ \ +- src/kj/time-test.c++ \ +- src/kj/threadlocal-test.c++ \ +- src/kj/filesystem-test.c++ \ +- src/kj/filesystem-disk-test.c++ \ +- src/kj/test-test.c++ \ +- src/capnp/common-test.c++ \ +- src/capnp/blob-test.c++ \ +- src/capnp/endian-test.c++ \ +- src/capnp/endian-fallback-test.c++ \ +- src/capnp/endian-reverse-test.c++ \ +- src/capnp/layout-test.c++ \ +- src/capnp/any-test.c++ \ +- src/capnp/message-test.c++ \ +- src/capnp/encoding-test.c++ \ +- src/capnp/orphan-test.c++ \ +- src/capnp/serialize-test.c++ \ +- src/capnp/serialize-packed-test.c++ \ +- src/capnp/fuzz-test.c++ \ +- $(heavy_tests) +- +-if !LITE_MODE +-capnp_evolution_test_LDADD = libcapnpc.la libcapnp.la libkj.la +-capnp_evolution_test_SOURCES = src/capnp/compiler/evolution-test.c++ +- +-capnp_afl_testcase_LDADD = libcapnp-test.a libcapnp-rpc.la libcapnp.la libkj.la libkj-async.la +-capnp_afl_testcase_SOURCES = src/capnp/afl-testcase.c++ +- +-if HAS_FUZZING_ENGINE +- capnp_llvm_fuzzer_testcase_LDADD = libcapnp-test.a libcapnp-rpc.la libcapnp.la libkj.la libkj-async.la +- capnp_llvm_fuzzer_testcase_SOURCES = src/capnp/llvm-fuzzer-testcase.c++ +- capnp_llvm_fuzzer_testcase_LDFLAGS = $(LIB_FUZZING_ENGINE) +-endif +-endif !LITE_MODE +- +-if LITE_MODE +-TESTS = capnp-test +-else !LITE_MODE +-TESTS = capnp-test capnp-evolution-test src/capnp/compiler/capnp-test.sh +-endif !LITE_MODE +-- +2.31.1 + diff --git a/recipes/capnproto/all/patches/0011-msvc-cpp17-hassubstring-fix-0.9.1.patch b/recipes/capnproto/all/patches/0011-msvc-cpp17-hassubstring-fix-0.9.1.patch new file mode 100644 index 0000000000000..53ed03419e21d --- /dev/null +++ b/recipes/capnproto/all/patches/0011-msvc-cpp17-hassubstring-fix-0.9.1.patch @@ -0,0 +1,39 @@ +From 509d27117c4e794f566ad37b1fdabb4b78be51ce Mon Sep 17 00:00:00 2001 +From: nyanpasu64 +Date: Sun, 19 Sep 2021 10:24:56 -0700 +Subject: [PATCH] Fix building test-helpers.c++ hasSubstring() on Windows C++17 + +The std::boyer_moore_horspool_searcher() codepath is complex and +untested, and was broken without being caught on CI, so remove it since +hasSubstring() isn't performance-critical. + +Partly reverts bd88a9157e81000168e03e281172da4fb04e5e45. +#include was added in that commit, so I assume it's unused +in the rest of this file and can safely be removed. +--- + c++/src/kj/test-helpers.c++ | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/c++/src/kj/test-helpers.c++ b/c++/src/kj/test-helpers.c++ +index c4fcbc19f..cd480a450 100644 +--- a/c++/src/kj/test-helpers.c++ ++++ b/c++/src/kj/test-helpers.c++ +@@ -34,8 +34,6 @@ + #include + #endif + +-#include +- + namespace kj { + namespace _ { // private + +@@ -49,9 +47,6 @@ bool hasSubstring(StringPtr haystack, StringPtr needle) { + + #if !defined(_WIN32) + return memmem(haystack.begin(), haystack.size(), needle.begin(), needle.size()) != nullptr; +-#elif defined(__cpp_lib_boyer_moore_searcher) +- std::boyer_moore_horspool_searcher searcher{needle.begin(), needle.size()}; +- return std::search(haystack.begin(), haystack.end(), searcher) != haystack.end(); + #else + // TODO(perf): This is not the best algorithm for substring matching. strstr can't be used + // because this is supposed to be safe to call on strings with embedded nulls. diff --git a/recipes/capnproto/all/patches/0012-msvc-nogdi-fix-0.9.1.patch b/recipes/capnproto/all/patches/0012-msvc-nogdi-fix-0.9.1.patch new file mode 100644 index 0000000000000..9c32cf5857633 --- /dev/null +++ b/recipes/capnproto/all/patches/0012-msvc-nogdi-fix-0.9.1.patch @@ -0,0 +1,29 @@ +--- c++/src/kj/windows-sanity.h ++++ c++/src/kj/windows-sanity.h +@@ -48,10 +48,13 @@ + // now, we use `#pragma once` to tell the compiler never to include this file again. + #pragma once + +-namespace win32 { +- const auto ERROR_ = ERROR; ++namespace kj_win32_workarounds { ++ // Namespace containing constant definitions intended to replace constants that are defined as ++ // macros in the Windows headers. Do not refer to this namespace directly, we'll import it into ++ // the global scope below. + + #ifdef ERROR // This could be absent if e.g. NOGDI was used. ++ const auto ERROR_ = ERROR; + #undef ERROR + const auto ERROR = ERROR_; + #endif +@@ -61,7 +64,8 @@ + typedef VOID_ VOID; + } + +-using win32::ERROR; +-using win32::VOID; ++// Pull our constant definitions into the global namespace -- but only if they don't already exist ++// in the global namespace. ++using namespace kj_win32_workarounds; + + #endif diff --git a/recipes/capnproto/all/patches/0013-disable-tests-for-0.10.0.patch b/recipes/capnproto/all/patches/0013-disable-tests-for-0.10.0.patch new file mode 100644 index 0000000000000..75da52bf1bbac --- /dev/null +++ b/recipes/capnproto/all/patches/0013-disable-tests-for-0.10.0.patch @@ -0,0 +1,177 @@ +diff --git a/c++/Makefile.am b/c++/Makefile.am +index b67b6b1..488e54d 100644 +--- a/c++/Makefile.am ++++ b/c++/Makefile.am +@@ -444,172 +444,3 @@ endif LITE_MODE + # src/capnp/serialize-snappy* + # src/capnp/benchmark/... + # src/capnp/compiler/... +- +-# Tests ============================================================== +- +-test_capnpc_inputs = \ +- src/capnp/test.capnp \ +- src/capnp/test-import.capnp \ +- src/capnp/test-import2.capnp \ +- src/capnp/compat/json-test.capnp +- +-test_capnpc_outputs = \ +- src/capnp/test.capnp.c++ \ +- src/capnp/test.capnp.h \ +- src/capnp/test-import.capnp.c++ \ +- src/capnp/test-import.capnp.h \ +- src/capnp/test-import2.capnp.c++ \ +- src/capnp/test-import2.capnp.h \ +- src/capnp/compat/json-test.capnp.c++ \ +- src/capnp/compat/json-test.capnp.h +- +-if USE_EXTERNAL_CAPNP +- +-test_capnpc_middleman: $(test_capnpc_inputs) +- @$(MKDIR_P) src +- $(CAPNP) compile --src-prefix=$(srcdir)/src -o$(CAPNPC_CXX):src -I$(srcdir)/src $$(for FILE in $(test_capnpc_inputs); do echo $(srcdir)/$$FILE; done) +- touch test_capnpc_middleman +- +-else +- +-test_capnpc_middleman: capnp$(EXEEXT) capnpc-c++$(EXEEXT) $(test_capnpc_inputs) +- @$(MKDIR_P) src +- ./capnp$(EXEEXT) compile --src-prefix=$(srcdir)/src -o./capnpc-c++$(EXEEXT):src -I$(srcdir)/src $$(for FILE in $(test_capnpc_inputs); do echo $(srcdir)/$$FILE; done) +- touch test_capnpc_middleman +- +-endif +- +-$(test_capnpc_outputs): test_capnpc_middleman +- +-BUILT_SOURCES = $(test_capnpc_outputs) +- +-check_LIBRARIES = libcapnp-test.a +-libcapnp_test_a_SOURCES = \ +- src/capnp/test-util.c++ \ +- src/capnp/test-util.h +-nodist_libcapnp_test_a_SOURCES = $(test_capnpc_outputs) +- +-if LITE_MODE +- +-check_PROGRAMS = capnp-test +-compiler_tests = +-capnp_test_LDADD = libcapnp-test.a libcapnp.la libkj-test.la libkj.la +- +-else !LITE_MODE +- +-check_PROGRAMS = capnp-test capnp-evolution-test capnp-afl-testcase +-if HAS_FUZZING_ENGINE +- check_PROGRAMS += capnp-llvm-fuzzer-testcase +-endif +-heavy_tests = \ +- src/kj/async-test.c++ \ +- src/kj/async-xthread-test.c++ \ +- src/kj/async-coroutine-test.c++ \ +- src/kj/async-unix-test.c++ \ +- src/kj/async-unix-xthread-test.c++ \ +- src/kj/async-win32-test.c++ \ +- src/kj/async-win32-xthread-test.c++ \ +- src/kj/async-io-test.c++ \ +- src/kj/async-queue-test.c++ \ +- src/kj/parse/common-test.c++ \ +- src/kj/parse/char-test.c++ \ +- src/kj/std/iostream-test.c++ \ +- src/kj/compat/url-test.c++ \ +- src/kj/compat/http-test.c++ \ +- $(MAYBE_KJ_GZIP_TESTS) \ +- $(MAYBE_KJ_TLS_TESTS) \ +- src/capnp/canonicalize-test.c++ \ +- src/capnp/capability-test.c++ \ +- src/capnp/membrane-test.c++ \ +- src/capnp/schema-test.c++ \ +- src/capnp/schema-loader-test.c++ \ +- src/capnp/schema-parser-test.c++ \ +- src/capnp/dynamic-test.c++ \ +- src/capnp/stringify-test.c++ \ +- src/capnp/serialize-async-test.c++ \ +- src/capnp/serialize-text-test.c++ \ +- src/capnp/rpc-test.c++ \ +- src/capnp/rpc-twoparty-test.c++ \ +- src/capnp/ez-rpc-test.c++ \ +- src/capnp/compat/json-test.c++ \ +- src/capnp/compat/websocket-rpc-test.c++ \ +- src/capnp/compiler/lexer-test.c++ \ +- src/capnp/compiler/type-id-test.c++ +-capnp_test_LDADD = \ +- libcapnp-test.a \ +- libcapnpc.la \ +- libcapnp-rpc.la \ +- libcapnp-websocket.la \ +- libcapnp-json.la \ +- libcapnp.la \ +- libkj-http.la \ +- $(MAYBE_KJ_GZIP_LA) \ +- $(MAYBE_KJ_TLS_LA) \ +- libkj-async.la \ +- libkj-test.la \ +- libkj.la \ +- $(ASYNC_LIBS) \ +- $(PTHREAD_LIBS) +- +-endif !LITE_MODE +- +-capnp_test_CPPFLAGS = -Wno-deprecated-declarations +-capnp_test_SOURCES = \ +- src/kj/common-test.c++ \ +- src/kj/memory-test.c++ \ +- src/kj/refcount-test.c++ \ +- src/kj/array-test.c++ \ +- src/kj/list-test.c++ \ +- src/kj/string-test.c++ \ +- src/kj/string-tree-test.c++ \ +- src/kj/table-test.c++ \ +- src/kj/map-test.c++ \ +- src/kj/encoding-test.c++ \ +- src/kj/exception-test.c++ \ +- src/kj/debug-test.c++ \ +- src/kj/arena-test.c++ \ +- src/kj/units-test.c++ \ +- src/kj/tuple-test.c++ \ +- src/kj/one-of-test.c++ \ +- src/kj/function-test.c++ \ +- src/kj/io-test.c++ \ +- src/kj/mutex-test.c++ \ +- src/kj/time-test.c++ \ +- src/kj/threadlocal-test.c++ \ +- src/kj/filesystem-test.c++ \ +- src/kj/filesystem-disk-test.c++ \ +- src/kj/test-test.c++ \ +- src/capnp/common-test.c++ \ +- src/capnp/blob-test.c++ \ +- src/capnp/endian-test.c++ \ +- src/capnp/endian-fallback-test.c++ \ +- src/capnp/endian-reverse-test.c++ \ +- src/capnp/layout-test.c++ \ +- src/capnp/any-test.c++ \ +- src/capnp/message-test.c++ \ +- src/capnp/encoding-test.c++ \ +- src/capnp/orphan-test.c++ \ +- src/capnp/serialize-test.c++ \ +- src/capnp/serialize-packed-test.c++ \ +- src/capnp/fuzz-test.c++ \ +- $(heavy_tests) +- +-if !LITE_MODE +-capnp_evolution_test_LDADD = libcapnpc.la libcapnp.la libkj.la +-capnp_evolution_test_SOURCES = src/capnp/compiler/evolution-test.c++ +- +-capnp_afl_testcase_LDADD = libcapnp-test.a libcapnp-rpc.la libcapnp.la libkj.la libkj-async.la +-capnp_afl_testcase_SOURCES = src/capnp/afl-testcase.c++ +- +-if HAS_FUZZING_ENGINE +- capnp_llvm_fuzzer_testcase_LDADD = libcapnp-test.a libcapnp-rpc.la libcapnp.la libkj.la libkj-async.la +- capnp_llvm_fuzzer_testcase_SOURCES = src/capnp/llvm-fuzzer-testcase.c++ +- capnp_llvm_fuzzer_testcase_LDFLAGS = $(LIB_FUZZING_ENGINE) +-endif +-endif !LITE_MODE +- +-if LITE_MODE +-TESTS = capnp-test +-else !LITE_MODE +-TESTS = capnp-test capnp-evolution-test src/capnp/compiler/capnp-test.sh +-endif !LITE_MODE diff --git a/recipes/capnproto/all/patches/0014-disable-tests-for-0.10.1.patch b/recipes/capnproto/all/patches/0014-disable-tests-for-0.10.1.patch new file mode 100644 index 0000000000000..218e656c58716 --- /dev/null +++ b/recipes/capnproto/all/patches/0014-disable-tests-for-0.10.1.patch @@ -0,0 +1,176 @@ +diff --git a/c++/Makefile.am b/c++/Makefile.am +index 40a1d95..08f6eda 100644 +--- a/c++/Makefile.am ++++ b/c++/Makefile.am +@@ -446,171 +446,3 @@ endif LITE_MODE + # src/capnp/benchmark/... + # src/capnp/compiler/... + +-# Tests ============================================================== +- +-test_capnpc_inputs = \ +- src/capnp/test.capnp \ +- src/capnp/test-import.capnp \ +- src/capnp/test-import2.capnp \ +- src/capnp/compat/json-test.capnp +- +-test_capnpc_outputs = \ +- src/capnp/test.capnp.c++ \ +- src/capnp/test.capnp.h \ +- src/capnp/test-import.capnp.c++ \ +- src/capnp/test-import.capnp.h \ +- src/capnp/test-import2.capnp.c++ \ +- src/capnp/test-import2.capnp.h \ +- src/capnp/compat/json-test.capnp.c++ \ +- src/capnp/compat/json-test.capnp.h +- +-if USE_EXTERNAL_CAPNP +- +-test_capnpc_middleman: $(test_capnpc_inputs) +- @$(MKDIR_P) src +- $(CAPNP) compile --src-prefix=$(srcdir)/src -o$(CAPNPC_CXX):src -I$(srcdir)/src $$(for FILE in $(test_capnpc_inputs); do echo $(srcdir)/$$FILE; done) +- touch test_capnpc_middleman +- +-else +- +-test_capnpc_middleman: capnp$(EXEEXT) capnpc-c++$(EXEEXT) $(test_capnpc_inputs) +- @$(MKDIR_P) src +- ./capnp$(EXEEXT) compile --src-prefix=$(srcdir)/src -o./capnpc-c++$(EXEEXT):src -I$(srcdir)/src $$(for FILE in $(test_capnpc_inputs); do echo $(srcdir)/$$FILE; done) +- touch test_capnpc_middleman +- +-endif +- +-$(test_capnpc_outputs): test_capnpc_middleman +- +-BUILT_SOURCES = $(test_capnpc_outputs) +- +-check_LIBRARIES = libcapnp-test.a +-libcapnp_test_a_SOURCES = \ +- src/capnp/test-util.c++ \ +- src/capnp/test-util.h +-nodist_libcapnp_test_a_SOURCES = $(test_capnpc_outputs) +- +-if LITE_MODE +- +-check_PROGRAMS = capnp-test +-compiler_tests = +-capnp_test_LDADD = libcapnp-test.a libcapnp.la libkj-test.la libkj.la +- +-else !LITE_MODE +- +-check_PROGRAMS = capnp-test capnp-evolution-test capnp-afl-testcase +-if HAS_FUZZING_ENGINE +- check_PROGRAMS += capnp-llvm-fuzzer-testcase +-endif +-heavy_tests = \ +- src/kj/async-test.c++ \ +- src/kj/async-xthread-test.c++ \ +- src/kj/async-coroutine-test.c++ \ +- src/kj/async-unix-test.c++ \ +- src/kj/async-unix-xthread-test.c++ \ +- src/kj/async-win32-test.c++ \ +- src/kj/async-win32-xthread-test.c++ \ +- src/kj/async-io-test.c++ \ +- src/kj/async-queue-test.c++ \ +- src/kj/parse/common-test.c++ \ +- src/kj/parse/char-test.c++ \ +- src/kj/std/iostream-test.c++ \ +- src/kj/compat/url-test.c++ \ +- src/kj/compat/http-test.c++ \ +- $(MAYBE_KJ_GZIP_TESTS) \ +- $(MAYBE_KJ_TLS_TESTS) \ +- src/capnp/canonicalize-test.c++ \ +- src/capnp/capability-test.c++ \ +- src/capnp/membrane-test.c++ \ +- src/capnp/schema-test.c++ \ +- src/capnp/schema-loader-test.c++ \ +- src/capnp/schema-parser-test.c++ \ +- src/capnp/dynamic-test.c++ \ +- src/capnp/stringify-test.c++ \ +- src/capnp/serialize-async-test.c++ \ +- src/capnp/serialize-text-test.c++ \ +- src/capnp/rpc-test.c++ \ +- src/capnp/rpc-twoparty-test.c++ \ +- src/capnp/ez-rpc-test.c++ \ +- src/capnp/compat/json-test.c++ \ +- src/capnp/compat/websocket-rpc-test.c++ \ +- src/capnp/compiler/lexer-test.c++ \ +- src/capnp/compiler/type-id-test.c++ +-capnp_test_LDADD = \ +- libcapnp-test.a \ +- libcapnpc.la \ +- libcapnp-rpc.la \ +- libcapnp-websocket.la \ +- libcapnp-json.la \ +- libcapnp.la \ +- libkj-http.la \ +- $(MAYBE_KJ_GZIP_LA) \ +- $(MAYBE_KJ_TLS_LA) \ +- libkj-async.la \ +- libkj-test.la \ +- libkj.la \ +- $(ASYNC_LIBS) \ +- $(PTHREAD_LIBS) +- +-endif !LITE_MODE +- +-capnp_test_CPPFLAGS = -Wno-deprecated-declarations +-capnp_test_SOURCES = \ +- src/kj/common-test.c++ \ +- src/kj/memory-test.c++ \ +- src/kj/refcount-test.c++ \ +- src/kj/array-test.c++ \ +- src/kj/list-test.c++ \ +- src/kj/string-test.c++ \ +- src/kj/string-tree-test.c++ \ +- src/kj/table-test.c++ \ +- src/kj/map-test.c++ \ +- src/kj/encoding-test.c++ \ +- src/kj/exception-test.c++ \ +- src/kj/debug-test.c++ \ +- src/kj/arena-test.c++ \ +- src/kj/units-test.c++ \ +- src/kj/tuple-test.c++ \ +- src/kj/one-of-test.c++ \ +- src/kj/function-test.c++ \ +- src/kj/io-test.c++ \ +- src/kj/mutex-test.c++ \ +- src/kj/time-test.c++ \ +- src/kj/threadlocal-test.c++ \ +- src/kj/filesystem-test.c++ \ +- src/kj/filesystem-disk-test.c++ \ +- src/kj/test-test.c++ \ +- src/capnp/common-test.c++ \ +- src/capnp/blob-test.c++ \ +- src/capnp/endian-test.c++ \ +- src/capnp/endian-fallback-test.c++ \ +- src/capnp/endian-reverse-test.c++ \ +- src/capnp/layout-test.c++ \ +- src/capnp/any-test.c++ \ +- src/capnp/message-test.c++ \ +- src/capnp/encoding-test.c++ \ +- src/capnp/orphan-test.c++ \ +- src/capnp/serialize-test.c++ \ +- src/capnp/serialize-packed-test.c++ \ +- src/capnp/fuzz-test.c++ \ +- $(heavy_tests) +- +-if !LITE_MODE +-capnp_evolution_test_LDADD = libcapnpc.la libcapnp.la libkj.la +-capnp_evolution_test_SOURCES = src/capnp/compiler/evolution-test.c++ +- +-capnp_afl_testcase_LDADD = libcapnp-test.a libcapnp-rpc.la libcapnp.la libkj.la libkj-async.la +-capnp_afl_testcase_SOURCES = src/capnp/afl-testcase.c++ +- +-if HAS_FUZZING_ENGINE +- capnp_llvm_fuzzer_testcase_LDADD = libcapnp-test.a libcapnp-rpc.la libcapnp.la libkj.la libkj-async.la +- capnp_llvm_fuzzer_testcase_SOURCES = src/capnp/llvm-fuzzer-testcase.c++ +- capnp_llvm_fuzzer_testcase_LDFLAGS = $(LIB_FUZZING_ENGINE) +-endif +-endif !LITE_MODE +- +-if LITE_MODE +-TESTS = capnp-test +-else !LITE_MODE +-TESTS = capnp-test capnp-evolution-test src/capnp/compiler/capnp-test.sh +-endif !LITE_MODE diff --git a/recipes/capnproto/all/test_package/CMakeLists.txt b/recipes/capnproto/all/test_package/CMakeLists.txt index ef8c017cfe390..44e90440833f5 100644 --- a/recipes/capnproto/all/test_package/CMakeLists.txt +++ b/recipes/capnproto/all/test_package/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(CapnProto REQUIRED capnp capnp-rpc CONFIG) @@ -13,11 +13,13 @@ target_include_directories(addressbook PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) set_property(TARGET addressbook PROPERTY CXX_STANDARD 14) capnp_generate_cpp(calculatorSources calculatorHeaders calculator.capnp) -add_executable(calculator-client calculator-client.c++ ${calculatorSources}) -add_executable(calculator-server calculator-server.c++ ${calculatorSources}) -target_link_libraries(calculator-client CapnProto::capnp-rpc) -target_link_libraries(calculator-server CapnProto::capnp-rpc) -target_include_directories(calculator-client PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_include_directories(calculator-server PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -set_property(TARGET calculator-client PROPERTY CXX_STANDARD 14) -set_property(TARGET calculator-server PROPERTY CXX_STANDARD 14) +add_library(calculator_protocol STATIC) +target_sources(calculator_protocol PRIVATE ${calculatorSources}) +target_include_directories(calculator_protocol PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(calculator_protocol PUBLIC CapnProto::capnp-rpc) +target_compile_features(calculator_protocol PUBLIC cxx_std_14) + +add_executable(calculator-client calculator-client.c++) +target_link_libraries(calculator-client PRIVATE calculator_protocol) +add_executable(calculator-server calculator-server.c++) +target_link_libraries(calculator-server PRIVATE calculator_protocol) diff --git a/recipes/capnproto/all/test_package/conanfile.py b/recipes/capnproto/all/test_package/conanfile.py index 5d2773a858676..10650773f736a 100644 --- a/recipes/capnproto/all/test_package/conanfile.py +++ b/recipes/capnproto/all/test_package/conanfile.py @@ -6,13 +6,16 @@ class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" + def build_requirements(self): + if hasattr(self, "settings_build"): + self.build_requires(str(self.requires["capnproto"])) + def build(self): - with tools.run_environment(self): - cmake = CMake(self) - cmake.configure() - cmake.build() + cmake = CMake(self) + cmake.configure() + cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "addressbook") self.run("{} write".format(bin_path), run_environment=True) diff --git a/recipes/capnproto/config.yml b/recipes/capnproto/config.yml index 675f954f2770e..b46b8cb89082c 100644 --- a/recipes/capnproto/config.yml +++ b/recipes/capnproto/config.yml @@ -1,3 +1,11 @@ versions: + "0.10.1": + folder: all + "0.10.0": + folder: all + "0.9.1": + folder: all "0.8.0": folder: all + "0.7.0": + folder: all diff --git a/recipes/capstone/all/CMakeLists.txt b/recipes/capstone/all/CMakeLists.txt deleted file mode 100644 index 274835e74cb84..0000000000000 --- a/recipes/capstone/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/capstone/all/conandata.yml b/recipes/capstone/all/conandata.yml index e3487780998d8..7e93927333e67 100644 --- a/recipes/capstone/all/conandata.yml +++ b/recipes/capstone/all/conandata.yml @@ -1,4 +1,4 @@ sources: "4.0.2": - url: "https://github.com/aquynh/capstone/archive/refs/tags/4.0.2.tar.gz" + url: "https://github.com/capstone-engine/capstone/archive/refs/tags/4.0.2.tar.gz" sha256: "7c81d798022f81e7507f1a60d6817f63aa76e489aa4e7055255f21a22f5e526a" diff --git a/recipes/capstone/all/conanfile.py b/recipes/capstone/all/conanfile.py index 3d8d2f761f397..148a51bb1323b 100644 --- a/recipes/capstone/all/conanfile.py +++ b/recipes/capstone/all/conanfile.py @@ -1,5 +1,10 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.53.0" class CapstoneConan(ConanFile): @@ -7,75 +12,75 @@ class CapstoneConan(ConanFile): license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.capstone-engine.org" - description = "Capstone disassembly/disassembler framework: Core (Arm, Arm64, BPF, EVM, M68K, M680X, MOS65xx, Mips, PPC, RISCV, Sparc, SystemZ, TMS320C64x, Web Assembly, X86, X86_64, XCore) + bindings." - topics = ("conan", 'reverse-engineering', 'disassembler', 'security', 'framework', 'arm', 'arm64', 'x86', 'sparc', 'powerpc', 'mips', 'x86-64', 'ethereum', 'systemz', 'webassembly', 'm68k', 'm0s65xx', 'm680x', 'tms320c64x', 'bpf', 'riscv') + description = ( + "Capstone disassembly/disassembler framework: Core (Arm, Arm64, BPF, " + "EVM, M68K, M680X, MOS65xx, Mips, PPC, RISCV, Sparc, SystemZ, " + "TMS320C64x, Web Assembly, X86, X86_64, XCore) + bindings." + ) + topics = ( + "reverse-engineering", "disassembler", "security", "framework", "arm", "arm64", + "x86", "sparc", "powerpc", "mips", "x86-64", "ethereum", "systemz", + "webassembly", "m68k", "m0s65xx", "m680x", "tms320c64x", "bpf", "riscv", + ) + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False], - "use_default_alloc": [True, False]} - default_options = {"shared": False, - "fPIC": True, - "use_default_alloc": True} - exports_sources = ["CMakeLists.txt"] - generators = "cmake", - _cmake = None - _archs = ['arm', 'm68k', 'mips', 'ppc', 'sparc', 'sysz', 'xcore', 'x86', 'tms320c64x', 'm680x', 'evm'] + options = { + "shared": [True, False], + "fPIC": [True, False], + "use_default_alloc": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "use_default_alloc": True, + } + + _archs = ["arm", "m68k", "mips", "ppc", "sparc", "sysz", "xcore", "x86", "tms320c64x", "m680x", "evm"] options.update({a: [True, False] for a in _archs}) default_options.update({a: True for a in _archs}) - @property - def _source_subfolder(self): - return "source_subfolder" - - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - if self._cmake: - return self._cmake - cmake = CMake(self) - cmake.definitions['CAPSTONE_BUILD_STATIC'] = not self.options.shared - cmake.definitions['CAPSTONE_BUILD_SHARED'] = self.options.shared - cmake.definitions['CAPSTONE_BUILD_TESTS'] = False - cmake.definitions['CAPSTONE_BUILD_CSTOOL'] = False - cmake.definitions['CAPSTONE_ARCHITECUTRE_DEFAULT'] = False - cmake.definitions['CAPSTONE_USE_SYS_DYN_MEM'] = self.options.use_default_alloc + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CAPSTONE_BUILD_STATIC"] = not self.options.shared + tc.variables["CAPSTONE_BUILD_SHARED"] = self.options.shared + tc.variables["CAPSTONE_BUILD_TESTS"] = False + tc.variables["CAPSTONE_BUILD_CSTOOL"] = False + tc.variables["CAPSTONE_ARCHITECUTRE_DEFAULT"] = False + tc.variables["CAPSTONE_USE_SYS_DYN_MEM"] = self.options.use_default_alloc for a in self._archs: - cmake.definitions['CAPSTONE_%s_SUPPORT' % a.upper()] = self.options.get_safe(a) - runtime = self.settings.get_safe("compiler.runtime") - if runtime: - cmake.definitions['CAPSTONE_BUILD_STATIC_RUNTIME'] = 'MT' in runtime - cmake.configure() - self._cmake = cmake - return self._cmake + tc.variables[f"CAPSTONE_{a.upper()}_SUPPORT"] = self.options.get_safe(a) + tc.variables["CAPSTONE_BUILD_STATIC_RUNTIME"] = is_msvc_static_runtime(self) + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE_LLVM.txt", dst="licenses", src=self._source_subfolder) - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE*.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - # FIXME : add components, if needed def package_info(self): + suffix = "_dll" if is_msvc(self) and self.options.shared else "" + self.cpp_info.libs = [f"capstone{suffix}"] if self.options.shared: - self.cpp_info.defines.append('CAPSTONE_SHARED') - if self.settings.compiler == "Visual Studio" and self.options.shared: - self.cpp_info.libs = ["capstone_dll"] - else: - self.cpp_info.libs = ["capstone"] + self.cpp_info.defines.append("CAPSTONE_SHARED") diff --git a/recipes/capstone/all/test_package/CMakeLists.txt b/recipes/capstone/all/test_package/CMakeLists.txt index 34af13462f44f..7c02e4fe66493 100644 --- a/recipes/capstone/all/test_package/CMakeLists.txt +++ b/recipes/capstone/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(capstone REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE capstone::capstone) diff --git a/recipes/capstone/all/test_package/conanfile.py b/recipes/capstone/all/test_package/conanfile.py index 1d0bdd3779793..0a6bc68712d90 100644 --- a/recipes/capstone/all/test_package/conanfile.py +++ b/recipes/capstone/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/capstone/all/test_v1_package/CMakeLists.txt b/recipes/capstone/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/capstone/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/capstone/all/test_v1_package/conanfile.py b/recipes/capstone/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/capstone/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cargs/all/conandata.yml b/recipes/cargs/all/conandata.yml index 741afff64213f..21e38ee9fe720 100644 --- a/recipes/cargs/all/conandata.yml +++ b/recipes/cargs/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.0.3": + url: "https://github.com/likle/cargs/archive/v1.0.3.tar.gz" + sha256: "ddba25bd35e9c6c75bc706c126001b8ce8e084d40ef37050e6aa6963e836eb8b" + "1.0.1": + url: "https://github.com/likle/cargs/archive/v1.0.1.tar.gz" + sha256: "1ff43742857e1ae8f6d76a98c92631ca2095f121a0d7b566f8c4d1f811c3387b" "1.0.0": url: "https://github.com/likle/cargs/archive/v1.0.0.zip" sha256: "c9fc3fa6086ea1086ef89ac688508579a4f7e59730bd2a1fd1646d97a05078ba" diff --git a/recipes/cargs/all/conanfile.py b/recipes/cargs/all/conanfile.py index 500415c73cb99..6aeeae1d3b488 100644 --- a/recipes/cargs/all/conanfile.py +++ b/recipes/cargs/all/conanfile.py @@ -1,8 +1,10 @@ import os from conans import ConanFile, CMake, tools +required_conan_version = ">=1.33.0" -class CwalkConan(ConanFile): + +class CargsConan(ConanFile): name = "cargs" description = "A lightweight getopt replacement that works on Linux, " \ "Windows and macOS. Command line argument parser library" \ @@ -33,12 +35,14 @@ def config_options(self): del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): cmake = CMake(self) diff --git a/recipes/cargs/config.yml b/recipes/cargs/config.yml index 40341aa3db6cd..63312af6d65c1 100644 --- a/recipes/cargs/config.yml +++ b/recipes/cargs/config.yml @@ -1,3 +1,7 @@ versions: + "1.0.3": + folder: all + "1.0.1": + folder: all "1.0.0": folder: all diff --git a/recipes/cassandra-cpp-driver/all/conanfile.py b/recipes/cassandra-cpp-driver/all/conanfile.py index 11cdd57087d7e..76b1d99adf12b 100644 --- a/recipes/cassandra-cpp-driver/all/conanfile.py +++ b/recipes/cassandra-cpp-driver/all/conanfile.py @@ -1,6 +1,8 @@ -import os.path from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" class CassandraCppDriverConan(ConanFile): @@ -20,7 +22,7 @@ class CassandraCppDriverConan(ConanFile): "with_openssl": [True, False], "with_zlib": [True, False], "with_kerberos": [True, False], - "use_timerfd": [True, False] + "use_timerfd": [True, False], } default_options = { "shared": False, @@ -30,9 +32,10 @@ class CassandraCppDriverConan(ConanFile): "with_openssl": True, "with_zlib": True, "with_kerberos": False, - "use_timerfd": True + "use_timerfd": True, } + short_paths = True generators = "cmake" exports_sources = [ "CMakeLists.txt", @@ -41,10 +44,60 @@ class CassandraCppDriverConan(ConanFile): _cmake = None + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + del self.options.use_timerfd + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("libuv/1.44.1") + self.requires("http_parser/2.9.4") + self.requires("rapidjson/cci.20211112") + + if self.options.with_openssl: + self.requires("openssl/1.1.1q") + + if self.options.with_zlib: + self.requires("minizip/1.2.12") + self.requires("zlib/1.2.12") + + if self.options.use_atomic == "boost": + self.requires("boost/1.79.0") + + def validate(self): + if self.options.use_atomic == "boost": + # Compilation error on Linux + if self.settings.os == "Linux": + raise ConanInvalidConfiguration( + "Boost.Atomic is not supported on Linux at the moment") + + if self.options.with_kerberos: + raise ConanInvalidConfiguration( + "Kerberos is not supported at the moment") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\"", + "\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\" OR \"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"AppleClang\"") + def _configure_cmake(self): if self._cmake: return self._cmake - + self._cmake = CMake(self) self._cmake.definitions["VERSION"] = self.version self._cmake.definitions["CASS_BUILD_EXAMPLES"] = False @@ -75,58 +128,15 @@ def _configure_cmake(self): # FIXME: To use kerberos, its conan package is needed. Uncomment this when kerberos conan package is ready. # self._cmake.definitions["CASS_USE_KERBEROS"] = self.options.with_kerberos - + if self.settings.os == "Linux": self._cmake.definitions["CASS_USE_TIMERFD"] = self.options.use_timerfd self._cmake.configure() return self._cmake - @property - def _source_subfolder(self): - return "source_subfolder" - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - del self.options.use_timerfd - - def configure(self): - if self.settings.os == "Macos": - raise ConanInvalidConfiguration("Macos is unsupported") - - if self.options.use_atomic == "boost": - # Compilation error on Linux - if self.settings.os == "Linux": - raise ConanInvalidConfiguration( - "Boost.Atomic is not supported on Linux at the moment") - - if self.options.with_kerberos: - raise ConanInvalidConfiguration( - "Kerberos is not supported at the moment") - - def requirements(self): - self.requires("libuv/1.40.0") - self.requires("http_parser/2.9.4") - self.requires("rapidjson/cci.20200410") - - if self.options.with_openssl: - self.requires("openssl/1.1.1i") - - if self.options.with_zlib: - self.requires("minizip/1.2.11") - self.requires("zlib/1.2.11") - - if self.options.use_atomic == "boost": - self.requires("boost/1.75.0") - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("cpp-driver-{}".format(self.version), self._source_subfolder) - def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + self._patch_sources() cmake = self._configure_cmake() cmake.build() diff --git a/recipes/catch2/2.x.x/CMakeLists.txt b/recipes/catch2/2.x.x/CMakeLists.txt deleted file mode 100644 index 8f9f6470cf8b0..0000000000000 --- a/recipes/catch2/2.x.x/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(cmake_wrapper) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/catch2/2.x.x/conandata.yml b/recipes/catch2/2.x.x/conandata.yml index 1d8fb2e61667e..a0d3adb7f0e99 100644 --- a/recipes/catch2/2.x.x/conandata.yml +++ b/recipes/catch2/2.x.x/conandata.yml @@ -1,50 +1,16 @@ sources: - 2.9.2: - url: https://github.com/catchorg/Catch2/archive/v2.9.2.tar.gz - sha256: 54BEA6D80A388A80F895CD0E2343FCA72B0D9093A776AF40904AEFCE49C13BDA - 2.11.0: - url: https://github.com/catchorg/Catch2/archive/v2.11.0.tar.gz - sha256: b9957af46a04327d80833960ae51cf5e67765fd264389bd1e275294907f1a3e0 - 2.11.1: - url: https://github.com/catchorg/Catch2/archive/v2.11.1.tar.gz - sha256: 9af06ca5b10362620c6c9c729821367e1aeb0f76adfc7bc3a468da83db3c50c6 - 2.11.3: - url: https://github.com/catchorg/Catch2/archive/v2.11.3.tar.gz - sha256: 9a6967138062688f04374698fce4ce65908f907d8c0fe5dfe8dc33126bd46543 - 2.12.0: - url: https://github.com/catchorg/Catch2/archive/v2.12.0.tar.gz - sha256: 6606b754363d3a4521bfecf717dc1972c50dca282bd428dfb1370ec8b9c26918 - 2.12.1: - url: https://github.com/catchorg/Catch2/archive/v2.12.1.tar.gz - sha256: e5635c082282ea518a8dd7ee89796c8026af8ea9068cd7402fb1615deacd91c3 - 2.12.2: - url: https://github.com/catchorg/Catch2/archive/v2.12.2.tar.gz - sha256: 4075d12aa4dc9a5bab00e82e0140b2969b88b8524b224e06ee129fabb9e2944b - 2.12.3: - url: https://github.com/catchorg/Catch2/archive/v2.12.3.tar.gz - sha256: 78425e7055cea5bad1ff8db7ea0d6dfc0722ece156be1ccf3597c15e674e6943 - 2.12.4: - url: https://github.com/catchorg/Catch2/archive/v2.12.4.tar.gz - sha256: 5436725bbc6ee131a0bc9545bef31f0adabbb21fbc39fb6f1b2a42c12e4f8107 - 2.13.0: - url: https://github.com/catchorg/Catch2/archive/v2.13.0.tar.gz - sha256: 4e6608d3fb0247e2aa988735bae2064381b0ec712f47beb766dd761838a546b6 - 2.13.1: - url: https://github.com/catchorg/Catch2/archive/v2.13.1.tar.gz - sha256: 36bcc9e6190923961be11e589d747e606515de95f10779e29853cfeae560bd6c - 2.13.2: - url: https://github.com/catchorg/Catch2/archive/v2.13.2.tar.gz - sha256: 5e39d9199f4f174dc3c8896fb4cf0a2ce9b9c358ae759b87fade6d615ca2d27e - 2.13.3: - url: https://github.com/catchorg/Catch2/archive/v2.13.3.tar.gz - sha256: fedc5b008f7eb574f45098e7c7138211c543f0f8ad04792090e790511697a877 - 2.13.4: - url: https://github.com/catchorg/Catch2/archive/v2.13.4.tar.gz - sha256: e7eb70b3d0ac2ed7dcf14563ad808740c29e628edde99e973adad373a2b5e4df - 2.13.6: - url: https://github.com/catchorg/Catch2/archive/v2.13.6.tar.gz - sha256: 48dfbb77b9193653e4e72df9633d2e0383b9b625a47060759668480fdf24fbd4 -patches: - 2.13.4: - - patch_file: patches/abs-static-cast.patch - base_path: source_subfolder + "2.11.3": + url: "https://github.com/catchorg/Catch2/archive/v2.11.3.tar.gz" + sha256: "9a6967138062688f04374698fce4ce65908f907d8c0fe5dfe8dc33126bd46543" + "2.12.4": + url: "https://github.com/catchorg/Catch2/archive/v2.12.4.tar.gz" + sha256: "5436725bbc6ee131a0bc9545bef31f0adabbb21fbc39fb6f1b2a42c12e4f8107" + "2.13.7": + url: "https://github.com/catchorg/Catch2/archive/v2.13.7.tar.gz" + sha256: "3cdb4138a072e4c0290034fe22d9f0a80d3bcfb8d7a8a5c49ad75d3a5da24fae" + "2.13.8": + url: "https://github.com/catchorg/Catch2/archive/v2.13.8.tar.gz" + sha256: "b9b592bd743c09f13ee4bf35fc30eeee2748963184f6bea836b146e6cc2a585a" + "2.13.9": + url: "https://github.com/catchorg/Catch2/archive/v2.13.9.tar.gz" + sha256: "06dbc7620e3b96c2b69d57bf337028bf245a211b3cddb843835bfe258f427a52" diff --git a/recipes/catch2/2.x.x/conanfile.py b/recipes/catch2/2.x.x/conanfile.py index e18d967152cca..44ba8e97757aa 100644 --- a/recipes/catch2/2.x.x/conanfile.py +++ b/recipes/catch2/2.x.x/conanfile.py @@ -1,100 +1,133 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.53.0" -class ConanRecipe(ConanFile): +class Catch2Conan(ConanFile): name = "catch2" description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD" - topics = ("conan", "catch2", "header-only", "unit-test", "tdd", "bdd") + topics = ("catch2", "header-only", "unit-test", "tdd", "bdd") homepage = "https://github.com/catchorg/Catch2" url = "https://github.com/conan-io/conan-center-index" license = "BSL-1.0" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "compiler", "build_type", "arch" - options = {"fPIC": [True, False], "with_main": [True, False]} - default_options = {"fPIC": True, "with_main": False} - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + "with_main": [True, False], + "with_benchmark": [True, False], + "with_prefix": [True, False], + "default_reporter": [None, "ANY"], + } + default_options = { + "fPIC": True, + "with_main": False, + "with_benchmark": False, + "with_prefix": False, + "default_reporter": None, + } @property - def _build_subfolder(self): - return "build_subfolder" + def _default_reporter_str(self): + return str(self.options.default_reporter).strip('"') def config_options(self): - if self.settings.os == "Windows" or not self.options.with_main: + if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.options.with_main and tools.Version(self.version) < "2.13.4": - raise ConanInvalidConfiguration("Option with_main not supported with versions < 2.13.4") + if not self.options.with_main: + self.options.rm_safe("fPIC") + self.options.rm_safe("with_benchmark") + + def package_id(self): + if not self.options.with_main: + self.info.clear() + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if Version(self.version) < "2.13.1" and self.settings.arch == "armv8": + raise ConanInvalidConfiguration("ARMv8 is not supported by versions < 2.13.1+") + if self.info.options.get_safe("with_main") and Version(self.version) < "2.13.4": + raise ConanInvalidConfiguration("Option with_main not supported by versions < 2.13.4") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "Catch2-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = "OFF" - self._cmake.definitions["CATCH_INSTALL_DOCS"] = "OFF" - self._cmake.definitions["CATCH_INSTALL_HELPERS"] = "ON" - self._cmake.definitions["CATCH_BUILD_STATIC_LIBRARY"] = self.options.with_main - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.cache_variables["CATCH_INSTALL_DOCS"] = False # these are cmake options, so use cache_variables + tc.cache_variables["CATCH_INSTALL_HELPERS"] = "ON" # these are cmake options, so use cache_variables + tc.cache_variables["CATCH_BUILD_STATIC_LIBRARY"] = str(self.options.with_main) # these are cmake options, so use cache_variables (str() is required for conan 1.52) + if self.options.with_prefix: + tc.preprocessor_definitions["CATCH_CONFIG_PREFIX_ALL"] = 1 + if self.options.get_safe("with_benchmark", False): + tc.preprocessor_definitions["CATCH_CONFIG_ENABLE_BENCHMARKING"] = 1 + if self.options.default_reporter: + tc.variables["CATCH_CONFIG_DEFAULT_REPORTER"] = self._default_reporter_str + tc.generate() def build(self): - self._patch_sources() - # Catch2 does skip install if included as subproject: - # https://github.com/catchorg/Catch2/blob/79a5cd795c387e2da58c13e9dcbfd9ea7a2cfb30/CMakeLists.txt#L100-L102 - main_cml = os.path.join(self._source_subfolder, "CMakeLists.txt") - tools.replace_in_file(main_cml, "if (NOT_SUBPROJECT)", "if (TRUE)") + cmake = CMake(self) + cmake.configure() if self.options.with_main: - cmake = self._configure_cmake() cmake.build() def package(self): - self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) for cmake_file in ["ParseAndAddCatchTests.cmake", "Catch.cmake", "CatchAddTests.cmake"]: - self.copy( + copy(self, cmake_file, - src=os.path.join(self._source_subfolder, "contrib"), - dst=os.path.join("lib", "cmake", "Catch2"), + src=os.path.join(self.source_folder, "contrib"), + dst=os.path.join(self.package_folder, "lib", "cmake", "Catch2"), ) - def package_id(self): - if not self.options.with_main: - self.info.header_only() - def package_info(self): - self.cpp_info.names["cmake_find_package"] = "Catch2" - self.cpp_info.names["cmake_find_package_multi"] = "Catch2" + self.cpp_info.set_property("cmake_file_name", "Catch2") + self.cpp_info.set_property("cmake_target_name", "Catch2::Catch2{}".format("WithMain" if self.options.with_main else "")) + self.cpp_info.set_property("pkg_config_name", "catch2{}".format("-with-main" if self.options.with_main else "")) + + defines = [] + if self.options.get_safe("with_benchmark", False): + defines.append("CATCH_CONFIG_ENABLE_BENCHMARKING") + if self.options.with_prefix: + defines.append("CATCH_CONFIG_PREFIX_ALL") + if self.options.default_reporter: + defines.append(f"CATCH_CONFIG_DEFAULT_REPORTER={self._default_reporter_str}") if self.options.with_main: - self.cpp_info.components["Catch2"].names["cmake_find_package"] = "Catch2" - self.cpp_info.components["Catch2"].names["cmake_find_package_multi"] = "Catch2" - - self.cpp_info.components["Catch2WithMain"].builddirs = [os.path.join("lib", "cmake", "Catch2")] - self.cpp_info.components["Catch2WithMain"].libs = ["Catch2WithMain"] - self.cpp_info.components["Catch2WithMain"].system_libs = ["log"] if self.settings.os == "Android" else [] - self.cpp_info.components["Catch2WithMain"].names["cmake_find_package"] = "Catch2WithMain" - self.cpp_info.components["Catch2WithMain"].names["cmake_find_package_multi"] = "Catch2WithMain" + self.cpp_info.components["_catch2"].set_property("cmake_target_name", "Catch2::Catch2") + self.cpp_info.components["_catch2"].set_property("pkg_config_name", "catch2") + self.cpp_info.components["_catch2"].defines = defines + + self.cpp_info.components["catch2_with_main"].builddirs.append(os.path.join("lib", "cmake", "Catch2")) + self.cpp_info.components["catch2_with_main"].libs = ["Catch2WithMain"] + self.cpp_info.components["catch2_with_main"].system_libs = ["log"] if self.settings.os == "Android" else [] + self.cpp_info.components["catch2_with_main"].set_property("cmake_target_name", "Catch2::Catch2WithMain") + self.cpp_info.components["catch2_with_main"].set_property("pkg_config_name", "catch2-with-main") + self.cpp_info.components["catch2_with_main"].defines = defines else: self.cpp_info.builddirs = [os.path.join("lib", "cmake", "Catch2")] self.cpp_info.system_libs = ["log"] if self.settings.os == "Android" else [] + self.cpp_info.defines = defines + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.names["cmake_find_package"] = "Catch2" + self.cpp_info.names["cmake_find_package_multi"] = "Catch2" + if self.options.with_main: + self.cpp_info.components["_catch2"].names["cmake_find_package"] = "Catch2" + self.cpp_info.components["_catch2"].names["cmake_find_package_multi"] = "Catch2" + self.cpp_info.components["catch2_with_main"].names["cmake_find_package"] = "Catch2WithMain" + self.cpp_info.components["catch2_with_main"].names["cmake_find_package_multi"] = "Catch2WithMain" diff --git a/recipes/catch2/2.x.x/patches/abs-static-cast.patch b/recipes/catch2/2.x.x/patches/abs-static-cast.patch deleted file mode 100644 index 8b5b064ca7d2b..0000000000000 --- a/recipes/catch2/2.x.x/patches/abs-static-cast.patch +++ /dev/null @@ -1,38 +0,0 @@ -diff --git a/include/internal/catch_matchers_floating.cpp b/include/internal/catch_matchers_floating.cpp -index bcca0725..40cea7c7 100644 ---- a/include/internal/catch_matchers_floating.cpp -+++ b/include/internal/catch_matchers_floating.cpp -@@ -55,7 +55,7 @@ namespace { - return lhs == rhs; - } - -- auto ulpDiff = std::abs(lc - rc); -+ auto ulpDiff = std::abs(static_cast(lc - rc)); - return static_cast(ulpDiff) <= maxUlpDiff; - } - -diff --git a/single_include/catch2/catch.hpp b/single_include/catch2/catch.hpp -index 0384171a..15743e12 100644 ---- a/single_include/catch2/catch.hpp -+++ b/single_include/catch2/catch.hpp -@@ -1,9 +1,9 @@ - /* - * Catch v2.13.4 -- * Generated: 2020-12-29 14:48:00.116107 -+ * Generated: 2021-01-19 09:44:08.909331 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly -- * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. -+ * Copyright (c) 2021 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -@@ -11447,7 +11447,7 @@ namespace { - return lhs == rhs; - } - -- auto ulpDiff = std::abs(lc - rc); -+ auto ulpDiff = std::abs(static_cast(lc - rc)); - return static_cast(ulpDiff) <= maxUlpDiff; - } - diff --git a/recipes/catch2/2.x.x/test_package/300-benchmark.cpp b/recipes/catch2/2.x.x/test_package/300-benchmark.cpp new file mode 100644 index 0000000000000..147c743b7e14d --- /dev/null +++ b/recipes/catch2/2.x.x/test_package/300-benchmark.cpp @@ -0,0 +1,11 @@ +#include + +unsigned int Factorial( unsigned int number ) { + return number > 1 ? Factorial(number-1)*number : 1; +} + +TEST_CASE( "compiles and runs" ) { + BENCHMARK("factorial 25"){ + return Factorial(25); + }; +} diff --git a/recipes/catch2/2.x.x/test_package/400-with-prefix.cpp b/recipes/catch2/2.x.x/test_package/400-with-prefix.cpp new file mode 100644 index 0000000000000..6340e09f840a9 --- /dev/null +++ b/recipes/catch2/2.x.x/test_package/400-with-prefix.cpp @@ -0,0 +1,5 @@ +#include + +CATCH_TEST_CASE( "compiles and runs" ) { + CATCH_REQUIRE( true == !false ); +} diff --git a/recipes/catch2/2.x.x/test_package/CMakeLists.txt b/recipes/catch2/2.x.x/test_package/CMakeLists.txt index 62d59604e86a5..56f2fde0dcab5 100644 --- a/recipes/catch2/2.x.x/test_package/CMakeLists.txt +++ b/recipes/catch2/2.x.x/test_package/CMakeLists.txt @@ -1,18 +1,31 @@ -cmake_minimum_required(VERSION 3.5) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +find_package(Catch2 REQUIRED CONFIG) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +if(NOT WITH_PREFIX) + add_executable(test_package 000-CatchMain.cpp 100-Fix-Section.cpp) + target_link_libraries(test_package PRIVATE Catch2::Catch2) + target_compile_features(test_package PRIVATE cxx_std_11) -find_package(Catch2 REQUIRED) + if(WITH_MAIN) + add_executable(standalone 200-standalone.cpp) + target_link_libraries(standalone PRIVATE Catch2::Catch2WithMain) + target_compile_features(standalone PRIVATE cxx_std_11) + if(WITH_BENCHMARK) + add_executable(benchmark 300-benchmark.cpp) + target_link_libraries(benchmark PRIVATE Catch2::Catch2WithMain) + target_compile_features(benchmark PRIVATE cxx_std_11) + endif() + endif() +else() + add_executable(test_package 000-CatchMain.cpp 400-with-prefix.cpp) + target_link_libraries(test_package PRIVATE Catch2::Catch2) + target_compile_features(test_package PRIVATE cxx_std_11) -add_executable(test_package 000-CatchMain.cpp 100-Fix-Section.cpp) -target_link_libraries(test_package PRIVATE Catch2::Catch2) - -if(WITH_MAIN) - add_executable(standalone 200-standalone.cpp) - target_link_libraries(standalone PRIVATE Catch2::Catch2WithMain) + if(WITH_MAIN) + add_executable(standalone 400-with-prefix.cpp) + target_link_libraries(standalone PRIVATE Catch2::Catch2WithMain) + target_compile_features(standalone PRIVATE cxx_std_11) + endif() endif() diff --git a/recipes/catch2/2.x.x/test_package/conanfile.py b/recipes/catch2/2.x.x/test_package/conanfile.py index f9515ad894660..e5d217bf13ce5 100644 --- a/recipes/catch2/2.x.x/test_package/conanfile.py +++ b/recipes/catch2/2.x.x/test_package/conanfile.py @@ -1,21 +1,53 @@ -from conans import ConanFile, CMake, tools -from conans.tools import Version +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout import os - +import yaml class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + _tests_todo = [] + + @property + def _todos_filename(self): + return os.path.join(self.recipe_folder, self.folders.generators, "catch2_test_to_do.yml") + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + catch_opts = self.dependencies[self.tested_reference_str].options + tc.variables["WITH_PREFIX"] = catch_opts.with_prefix + tc.variables["WITH_MAIN"] = catch_opts.with_main + tc.variables["WITH_BENCHMARK"] = not catch_opts.with_prefix and catch_opts.with_main and catch_opts.with_benchmark + tc.generate() + + # note: this is required as self.dependencies is not available in test() + self._tests_todo.append("test_package") + if catch_opts.with_main: + self._tests_todo.append("standalone") + if not catch_opts.with_prefix and catch_opts.with_main and catch_opts.with_benchmark: + self._tests_todo.append("benchmark") + + with open(self._todos_filename, "w", encoding="utf-8") as file: + yaml.dump(self._tests_todo, file) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) - cmake.definitions["WITH_MAIN"] = self.options["catch2"].with_main cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) - - if self.options["catch2"].with_main: - self.run(os.path.join("bin", "standalone"), run_environment=True) + with open(self._todos_filename, "r", encoding="utf-8") as file: + self._tests_todo = yaml.safe_load(file) + if can_run(self): + for test_name in self._tests_todo: + self.run(os.path.join(self.cpp.build.bindirs[0], test_name), env="conanrun") diff --git a/recipes/catch2/2.x.x/test_package/test_all.sh b/recipes/catch2/2.x.x/test_package/test_all.sh new file mode 100755 index 0000000000000..6d50ad26b2429 --- /dev/null +++ b/recipes/catch2/2.x.x/test_package/test_all.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Run with the package reference as an argument +set -ex +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +conan test $DIR $1 --build=catch2 +conan test $DIR $1 --build=catch2 -o catch2:with_main=True -o catch2:with_benchmark=True +conan test $DIR $1 --build=catch2 -o catch2:with_prefix=True +conan test $DIR $1 --build=catch2 -o catch2:with_main=True -o catch2:with_prefix=True +conan test $DIR $1 --build=catch2 -o catch2:default_reporter=xml +conan test $DIR $1 --build=catch2 -o catch2:with_main=True -o catch2:default_reporter=xml diff --git a/recipes/catch2/2.x.x/test_v1_package/CMakeLists.txt b/recipes/catch2/2.x.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..ba50d23310806 --- /dev/null +++ b/recipes/catch2/2.x.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.5) +project(test_package) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Catch2 REQUIRED) + +if(NOT WITH_PREFIX) + add_executable(test_package ../test_package/000-CatchMain.cpp ../test_package/100-Fix-Section.cpp) + target_link_libraries(test_package PRIVATE Catch2::Catch2) + + if(WITH_MAIN) + add_executable(standalone ../test_package/200-standalone.cpp) + target_link_libraries(standalone PRIVATE Catch2::Catch2WithMain) + if(WITH_BENCHMARK) + add_executable(benchmark ../test_package/300-benchmark.cpp) + target_link_libraries(benchmark PRIVATE Catch2::Catch2WithMain) + endif() + endif() +else() + add_executable(test_package ../test_package/000-CatchMain.cpp ../test_package/400-with-prefix.cpp) + target_link_libraries(test_package PRIVATE Catch2::Catch2) + + if(WITH_MAIN) + add_executable(standalone ../test_package/400-with-prefix.cpp) + target_link_libraries(standalone PRIVATE Catch2::Catch2WithMain) + endif() +endif() diff --git a/recipes/catch2/2.x.x/test_v1_package/conanfile.py b/recipes/catch2/2.x.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..26e54f7cba1f5 --- /dev/null +++ b/recipes/catch2/2.x.x/test_v1_package/conanfile.py @@ -0,0 +1,24 @@ +from conans import ConanFile, CMake, tools +from conans.tools import Version +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.definitions["WITH_MAIN"] = self.options["catch2"].with_main + cmake.definitions["WITH_BENCHMARK"] = self.options["catch2"].with_main and self.options["catch2"].with_benchmark + cmake.definitions["WITH_PREFIX"] = self.options["catch2"].with_prefix + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) + if self.options["catch2"].with_main: + self.run(os.path.join("bin", "standalone"), run_environment=True) + if self.options["catch2"].with_benchmark: + self.run(os.path.join("bin", "benchmark"), run_environment=True) diff --git a/recipes/catch2/3.x.x/conandata.yml b/recipes/catch2/3.x.x/conandata.yml new file mode 100644 index 0000000000000..80296e292f33a --- /dev/null +++ b/recipes/catch2/3.x.x/conandata.yml @@ -0,0 +1,29 @@ +sources: + "3.2.0": + url: "https://github.com/catchorg/Catch2/archive/v3.2.0.tar.gz" + sha256: "feee04647e28ac3cbeff46cb42abc8ee2d8d5f646d36e3fb3ba274b8c69a58ea" + "3.1.0": + url: "https://github.com/catchorg/Catch2/archive/v3.1.0.tar.gz" + sha256: "c252b2d9537e18046d8b82535069d2567f77043f8e644acf9a9fffc22ea6e6f7" + "3.0.1": + url: "https://github.com/catchorg/Catch2/archive/v3.0.1.tar.gz" + sha256: "8c4173c68ae7da1b5b505194a0c2d6f1b2aef4ec1e3e7463bde451f26bbaf4e7" +patches: + "3.1.0": + - patch_file: "patches/3.1.0-0001-fix-dll-install.patch" + patch_description: "Install dll in bin folder" + patch_type: "portability" + patch_source: "https://github.com/catchorg/Catch2/pull/2485" + - patch_file: "patches/3.1.0-0002-dllimport-global-symbols-msvc.patch" + patch_description: "Fix import of global symbols for msvc shared" + patch_type: "portability" + patch_source: "https://github.com/catchorg/Catch2/pull/2527" + "3.0.1": + - patch_file: "patches/3.0.1-0001-allow-shared.patch" + patch_description: "Allow to build catch2 as a shared library" + patch_type: "portability" + patch_source: "https://github.com/catchorg/Catch2/commit/bea58bf8bbfca887f871c3aa2d720ba62c01f855" + - patch_file: "patches/3.0.1-0002-dllimport-global-symbols-msvc.patch" + patch_description: "Fix import of global symbols for msvc shared" + patch_type: "portability" + patch_source: "https://github.com/catchorg/Catch2/pull/2527" diff --git a/recipes/catch2/3.x.x/conanfile.py b/recipes/catch2/3.x.x/conanfile.py new file mode 100644 index 0000000000000..ec3465c8a1719 --- /dev/null +++ b/recipes/catch2/3.x.x/conanfile.py @@ -0,0 +1,166 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save +from conan.tools.scm import Version +import os +import textwrap + +required_conan_version = ">=1.53.0" + + +class Catch2Conan(ConanFile): + name = "catch2" + description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD" + topics = ("catch2", "unit-test", "tdd", "bdd") + license = "BSL-1.0" + homepage = "https://github.com/catchorg/Catch2" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_prefix": [True, False], + "default_reporter": [None, "ANY"], + } + default_options = { + "shared": False, + "fPIC": True, + "with_prefix": False, + "default_reporter": None, + } + + @property + def _min_cppstd(self): + return "14" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "15", + "msvc": "191", + "clang": "5", + "apple-clang": "10", + } + + @property + def _default_reporter_str(self): + return str(self.options.default_reporter).strip('"') + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler doesn't support", + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.cache_variables["CATCH_INSTALL_DOCS"] = False + tc.cache_variables["CATCH_INSTALL_EXTRAS"] = True + tc.cache_variables["CATCH_DEVELOPMENT_BUILD"] = False + tc.variables["CATCH_CONFIG_PREFIX_ALL"] = self.options.with_prefix + if self.options.default_reporter: + tc.variables["CATCH_CONFIG_DEFAULT_REPORTER"] = self._default_reporter_str + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + for cmake_file in ["ParseAndAddCatchTests.cmake", "Catch.cmake", "CatchAddTests.cmake"]: + copy( + self, + cmake_file, + src=os.path.join(self.source_folder, "extras"), + dst=os.path.join(self.package_folder, "lib", "cmake", "Catch2"), + ) + + # TODO: to remove in conan v2 once legacy generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + { + "Catch2::Catch2": "catch2::_catch2", + "Catch2::Catch2WithMain": "catch2::catch2_with_main", + } + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Catch2") + self.cpp_info.set_property("cmake_target_name", "Catch2::Catch2WithMain") + self.cpp_info.set_property("pkg_config_name", "catch2-with-main") + + lib_suffix = "d" if self.settings.build_type == "Debug" else "" + self.cpp_info.components["_catch2"].set_property("cmake_target_name", "Catch2::Catch2") + self.cpp_info.components["_catch2"].set_property("pkg_config_name", "catch2") + self.cpp_info.components["_catch2"].libs = ["Catch2" + lib_suffix] + + self.cpp_info.components["catch2_with_main"].builddirs.append(os.path.join("lib", "cmake", "Catch2")) + self.cpp_info.components["catch2_with_main"].libs = ["Catch2Main" + lib_suffix] + self.cpp_info.components["catch2_with_main"].requires = ["_catch2"] + self.cpp_info.components["catch2_with_main"].system_libs = ["log"] if self.settings.os == "Android" else [] + self.cpp_info.components["catch2_with_main"].set_property("cmake_target_name", "Catch2::Catch2WithMain") + self.cpp_info.components["catch2_with_main"].set_property("pkg_config_name", "catch2-with-main") + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["catch2_with_main"].system_libs.append("m") + defines = [] + if self.options.with_prefix: + defines.append("CATCH_CONFIG_PREFIX_ALL") + if self.options.default_reporter: + defines.append(f"CATCH_CONFIG_DEFAULT_REPORTER={self._default_reporter_str}") + self.cpp_info.components["catch2_with_main"].defines = defines + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.filenames["cmake_find_package"] = "Catch2" + self.cpp_info.filenames["cmake_find_package_multi"] = "Catch2" + self.cpp_info.names["cmake_find_package"] = "catch2" + self.cpp_info.names["cmake_find_package_multi"] = "catch2" + self.cpp_info.components["_catch2"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["_catch2"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["catch2_with_main"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["catch2_with_main"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/catch2/3.x.x/patches/3.0.1-0001-allow-shared.patch b/recipes/catch2/3.x.x/patches/3.0.1-0001-allow-shared.patch new file mode 100644 index 0000000000000..38c31d266b121 --- /dev/null +++ b/recipes/catch2/3.x.x/patches/3.0.1-0001-allow-shared.patch @@ -0,0 +1,64 @@ +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -263,9 +263,7 @@ set(REPORTER_SOURCES + ) + set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES}) + +-# Fixme: STATIC because for dynamic, we would need to handle visibility +-# and I don't want to do the annotations right now +-add_library(Catch2 STATIC ++add_library(Catch2 + ${REPORTER_FILES} + ${INTERNAL_FILES} + ${BENCHMARK_HEADERS} +@@ -318,7 +316,7 @@ target_include_directories(Catch2 + ) + + +-add_library(Catch2WithMain STATIC ++add_library(Catch2WithMain + ${SOURCES_DIR}/internal/catch_main.cpp + ) + add_build_reproducibility_settings(Catch2WithMain) +@@ -338,8 +336,12 @@ if (NOT_SUBPROJECT) + Catch2WithMain + EXPORT + Catch2Targets +- DESTINATION ++ LIBRARY DESTINATION ++ ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION + ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ++ ${CMAKE_INSTALL_BINDIR} + ) + + +@@ -409,3 +411,27 @@ endif() + + list(APPEND CATCH_WARNING_TARGETS Catch2 Catch2WithMain) + set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE) ++ ++ ++# We still do not support building dynamic library with hidden visibility ++# so we want to check & warn users if they do this. However, we won't abort ++# the configuration step so that we don't have to also provide an override. ++if (BUILD_SHARED_LIBS) ++ if (MSVC) ++ set_target_properties(Catch2 Catch2WithMain ++ PROPERTIES ++ WINDOWS_EXPORT_ALL_SYMBOLS ON ++ ) ++ endif() ++ ++ get_target_property(_VisPreset Catch2 CXX_VISIBILITY_PRESET) ++ if (NOT MSVC AND _VisPreset STREQUAL "hidden") ++ set_target_properties(Catch2 Catch2WithMain ++ PROPERTIES ++ CXX_VISIBILITY_PRESET "default" ++ VISIBILITY_INLINES_HIDDEN OFF ++ ) ++ message(WARNING "Setting Catch2's visibility to default." ++ " Hidden visibility is not supported.") ++ endif() ++endif() diff --git a/recipes/catch2/3.x.x/patches/3.0.1-0002-dllimport-global-symbols-msvc.patch b/recipes/catch2/3.x.x/patches/3.0.1-0002-dllimport-global-symbols-msvc.patch new file mode 100644 index 0000000000000..c797f9d544f0c --- /dev/null +++ b/recipes/catch2/3.x.x/patches/3.0.1-0002-dllimport-global-symbols-msvc.patch @@ -0,0 +1,77 @@ +--- a/CMake/CatchConfigOptions.cmake ++++ b/CMake/CatchConfigOptions.cmake +@@ -45,6 +45,7 @@ set(_OverridableOptions + foreach(OptionName ${_OverridableOptions}) + AddOverridableConfigOption(${OptionName}) + endforeach() ++set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS}) + + set(_OtherConfigOptions + "DISABLE_EXCEPTIONS" +--- a/src/catch2/catch_tostring.hpp ++++ b/src/catch2/catch_tostring.hpp +@@ -296,13 +296,13 @@ namespace Catch { + template<> + struct StringMaker { + static std::string convert(float value); +- static int precision; ++ CATCH_EXPORT static int precision; + }; + + template<> + struct StringMaker { + static std::string convert(double value); +- static int precision; ++ CATCH_EXPORT static int precision; + }; + + template +--- a/src/catch2/catch_user_config.hpp.in ++++ b/src/catch2/catch_user_config.hpp.in +@@ -181,6 +181,8 @@ + #cmakedefine CATCH_CONFIG_PREFIX_ALL + #cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG + ++#cmakedefine CATCH_CONFIG_SHARED_LIBRARY ++ + + // ------ + // "Variable" defines, these have actual values +--- a/src/catch2/internal/catch_compiler_capabilities.hpp ++++ b/src/catch2/internal/catch_compiler_capabilities.hpp +@@ -364,5 +364,15 @@ + # define CATCH_CONFIG_COLOUR_WIN32 + #endif + ++#if defined( CATCH_CONFIG_SHARED_LIBRARY ) && defined( _MSC_VER ) && \ ++ !defined( CATCH_CONFIG_STATIC ) ++# ifdef Catch2_EXPORTS ++# define CATCH_EXPORT //__declspec( dllexport ) // not needed ++# else ++# define CATCH_EXPORT __declspec( dllimport ) ++# endif ++#else ++# define CATCH_EXPORT ++#endif + + #endif // CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED +--- a/src/catch2/internal/catch_context.hpp ++++ b/src/catch2/internal/catch_context.hpp +@@ -8,6 +8,8 @@ + #ifndef CATCH_CONTEXT_HPP_INCLUDED + #define CATCH_CONTEXT_HPP_INCLUDED + ++#include ++ + namespace Catch { + + class IResultCapture; +@@ -28,7 +30,7 @@ namespace Catch { + virtual void setConfig( IConfig const* config ) = 0; + + private: +- static IMutableContext *currentContext; ++ CATCH_EXPORT static IMutableContext *currentContext; + friend IMutableContext& getCurrentMutableContext(); + friend void cleanUpContext(); + static void createContext(); diff --git a/recipes/catch2/3.x.x/patches/3.1.0-0001-fix-dll-install.patch b/recipes/catch2/3.x.x/patches/3.1.0-0001-fix-dll-install.patch new file mode 100644 index 0000000000000..c7027940432a6 --- /dev/null +++ b/recipes/catch2/3.x.x/patches/3.1.0-0001-fix-dll-install.patch @@ -0,0 +1,16 @@ +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -359,8 +359,12 @@ if (NOT_SUBPROJECT) + Catch2WithMain + EXPORT + Catch2Targets +- DESTINATION ++ LIBRARY DESTINATION ++ ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION + ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ++ ${CMAKE_INSTALL_BINDIR} + ) + + diff --git a/recipes/catch2/3.x.x/patches/3.1.0-0002-dllimport-global-symbols-msvc.patch b/recipes/catch2/3.x.x/patches/3.1.0-0002-dllimport-global-symbols-msvc.patch new file mode 100644 index 0000000000000..63e221c1fb44c --- /dev/null +++ b/recipes/catch2/3.x.x/patches/3.1.0-0002-dllimport-global-symbols-msvc.patch @@ -0,0 +1,77 @@ +--- a/CMake/CatchConfigOptions.cmake ++++ b/CMake/CatchConfigOptions.cmake +@@ -45,6 +45,7 @@ set(_OverridableOptions + foreach(OptionName ${_OverridableOptions}) + AddOverridableConfigOption(${OptionName}) + endforeach() ++set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS}) + + set(_OtherConfigOptions + "DISABLE_EXCEPTIONS" +--- a/src/catch2/catch_tostring.hpp ++++ b/src/catch2/catch_tostring.hpp +@@ -296,13 +296,13 @@ namespace Catch { + template<> + struct StringMaker { + static std::string convert(float value); +- static int precision; ++ CATCH_EXPORT static int precision; + }; + + template<> + struct StringMaker { + static std::string convert(double value); +- static int precision; ++ CATCH_EXPORT static int precision; + }; + + template +--- a/src/catch2/catch_user_config.hpp.in ++++ b/src/catch2/catch_user_config.hpp.in +@@ -181,6 +181,8 @@ + #cmakedefine CATCH_CONFIG_PREFIX_ALL + #cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG + ++#cmakedefine CATCH_CONFIG_SHARED_LIBRARY ++ + + // ------ + // "Variable" defines, these have actual values +--- a/src/catch2/internal/catch_compiler_capabilities.hpp ++++ b/src/catch2/internal/catch_compiler_capabilities.hpp +@@ -376,5 +376,15 @@ + # define CATCH_CONFIG_COLOUR_WIN32 + #endif + ++#if defined( CATCH_CONFIG_SHARED_LIBRARY ) && defined( _MSC_VER ) && \ ++ !defined( CATCH_CONFIG_STATIC ) ++# ifdef Catch2_EXPORTS ++# define CATCH_EXPORT //__declspec( dllexport ) // not needed ++# else ++# define CATCH_EXPORT __declspec( dllimport ) ++# endif ++#else ++# define CATCH_EXPORT ++#endif + + #endif // CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED +--- a/src/catch2/internal/catch_context.hpp ++++ b/src/catch2/internal/catch_context.hpp +@@ -8,6 +8,8 @@ + #ifndef CATCH_CONTEXT_HPP_INCLUDED + #define CATCH_CONTEXT_HPP_INCLUDED + ++#include ++ + namespace Catch { + + class IResultCapture; +@@ -28,7 +30,7 @@ namespace Catch { + virtual void setConfig( IConfig const* config ) = 0; + + private: +- static IMutableContext *currentContext; ++ CATCH_EXPORT static IMutableContext *currentContext; + friend IMutableContext& getCurrentMutableContext(); + friend void cleanUpContext(); + static void createContext(); diff --git a/recipes/catch2/3.x.x/test_package/100-standalone.cpp b/recipes/catch2/3.x.x/test_package/100-standalone.cpp new file mode 100644 index 0000000000000..4930209c907a2 --- /dev/null +++ b/recipes/catch2/3.x.x/test_package/100-standalone.cpp @@ -0,0 +1,5 @@ +#include + +TEST_CASE( "compiles and runs" ) { + REQUIRE( true == !false ); +} diff --git a/recipes/catch2/3.x.x/test_package/200-benchmark.cpp b/recipes/catch2/3.x.x/test_package/200-benchmark.cpp new file mode 100644 index 0000000000000..a109712183d7c --- /dev/null +++ b/recipes/catch2/3.x.x/test_package/200-benchmark.cpp @@ -0,0 +1,12 @@ +#include +#include + +unsigned int Factorial( unsigned int number ) { + return number > 1 ? Factorial(number-1)*number : 1; +} + +TEST_CASE( "compiles and runs" ) { + BENCHMARK("factorial 25"){ + return Factorial(25); + }; +} diff --git a/recipes/catch2/3.x.x/test_package/300-standalone-with-prefix.cpp b/recipes/catch2/3.x.x/test_package/300-standalone-with-prefix.cpp new file mode 100644 index 0000000000000..1f26b184ca151 --- /dev/null +++ b/recipes/catch2/3.x.x/test_package/300-standalone-with-prefix.cpp @@ -0,0 +1,5 @@ +#include + +CATCH_TEST_CASE( "compiles and runs" ) { + CATCH_REQUIRE( true == !false ); +} diff --git a/recipes/catch2/3.x.x/test_package/400-benchmark-with-prefix.cpp b/recipes/catch2/3.x.x/test_package/400-benchmark-with-prefix.cpp new file mode 100644 index 0000000000000..a496560fe3440 --- /dev/null +++ b/recipes/catch2/3.x.x/test_package/400-benchmark-with-prefix.cpp @@ -0,0 +1,12 @@ +#include +#include + +unsigned int Factorial( unsigned int number ) { + return number > 1 ? Factorial(number-1)*number : 1; +} + +CATCH_TEST_CASE( "compiles and runs" ) { + CATCH_BENCHMARK("factorial 25"){ + return Factorial(25); + }; +} diff --git a/recipes/catch2/3.x.x/test_package/CMakeLists.txt b/recipes/catch2/3.x.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..1e2b06644735c --- /dev/null +++ b/recipes/catch2/3.x.x/test_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(Catch2 REQUIRED CONFIG) + +if(WITH_PREFIX) + add_executable(standalone 300-standalone-with-prefix.cpp) + add_executable(benchmark 400-benchmark-with-prefix.cpp) +else() + add_executable(standalone 100-standalone.cpp) + add_executable(benchmark 200-benchmark.cpp) +endif() +target_link_libraries(standalone PRIVATE Catch2::Catch2WithMain) +target_compile_features(standalone PRIVATE cxx_std_14) +target_link_libraries(benchmark PRIVATE Catch2::Catch2WithMain) +target_compile_features(benchmark PRIVATE cxx_std_14) diff --git a/recipes/catch2/3.x.x/test_package/conanfile.py b/recipes/catch2/3.x.x/test_package/conanfile.py new file mode 100644 index 0000000000000..259cc3545b24c --- /dev/null +++ b/recipes/catch2/3.x.x/test_package/conanfile.py @@ -0,0 +1,31 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_PREFIX"] = self.dependencies[self.tested_reference_str].options.with_prefix + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "standalone"), env="conanrun") + self.run(os.path.join(self.cpp.build.bindirs[0], "benchmark"), env="conanrun") diff --git a/recipes/catch2/3.x.x/test_v1_package/CMakeLists.txt b/recipes/catch2/3.x.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/catch2/3.x.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/catch2/3.x.x/test_v1_package/conanfile.py b/recipes/catch2/3.x.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..b62a348e1044b --- /dev/null +++ b/recipes/catch2/3.x.x/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["WITH_PREFIX"] = self.options["catch2"].with_prefix + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "standalone"), run_environment=True) + self.run(os.path.join("bin", "benchmark"), run_environment=True) diff --git a/recipes/catch2/config.yml b/recipes/catch2/config.yml index ced518e6ea432..70386952911a8 100644 --- a/recipes/catch2/config.yml +++ b/recipes/catch2/config.yml @@ -1,31 +1,17 @@ versions: - 2.9.2: + "3.2.0": + folder: 3.x.x + "3.1.0": + folder: 3.x.x + "3.0.1": + folder: 3.x.x + "2.13.9": folder: 2.x.x - 2.11.0: + "2.13.8": folder: 2.x.x - 2.11.1: + "2.13.7": folder: 2.x.x - 2.11.3: + "2.12.4": folder: 2.x.x - 2.12.0: - folder: 2.x.x - 2.12.1: - folder: 2.x.x - 2.12.2: - folder: 2.x.x - 2.12.3: - folder: 2.x.x - 2.12.4: - folder: 2.x.x - 2.13.0: - folder: 2.x.x - 2.13.1: - folder: 2.x.x - 2.13.2: - folder: 2.x.x - 2.13.3: - folder: 2.x.x - 2.13.4: - folder: 2.x.x - 2.13.6: + "2.11.3": folder: 2.x.x diff --git a/recipes/ccache/all/CMakeLists.txt b/recipes/ccache/all/CMakeLists.txt new file mode 100644 index 0000000000000..b71c882d9d33f --- /dev/null +++ b/recipes/ccache/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/ccache/all/conandata.yml b/recipes/ccache/all/conandata.yml new file mode 100644 index 0000000000000..ed2c1276132d0 --- /dev/null +++ b/recipes/ccache/all/conandata.yml @@ -0,0 +1,14 @@ +sources: + "4.6": + url: "https://github.com/ccache/ccache/releases/download/v4.6/ccache-4.6.tar.xz" + sha256: "3d2bb860f4359169e640f60cf7cc11da5fab5fb9aed55230d78141e49c3945e9" + "4.5.1": + url: "https://github.com/ccache/ccache/releases/download/v4.5.1/ccache-4.5.1.tar.xz" + sha256: "51186ebe0326365f4e6131e1caa8911de7da4aa6718efc00680322d63a759517" +patches: + "4.6": + - patch_file: "patches/0001-fix-cmake-4.6.patch" + base_path: "source_subfolder" + "4.5.1": + - patch_file: "patches/0001-fix-cmake-4.5.1.patch" + base_path: "source_subfolder" diff --git a/recipes/ccache/all/conanfile.py b/recipes/ccache/all/conanfile.py new file mode 100644 index 0000000000000..8da0d74ff87ef --- /dev/null +++ b/recipes/ccache/all/conanfile.py @@ -0,0 +1,113 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.33.0" + + +class CcacheConan(ConanFile): + name = "ccache" + description = ( + "Ccache (or “ccache”) is a compiler cache. It speeds up recompilation " + "by caching previous compilations and detecting when the same " + "compilation is being done again." + ) + license = "GPL-3.0-or-later" + topics = ("ccache", "compiler-cache", "recompilation") + homepage = "https://ccache.dev" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "redis_storage_backend": [True, False], + } + default_options = { + "redis_storage_backend": True, + } + + generators = "cmake", "cmake_find_package_multi" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _min_cppstd(self): + return "17" if self._is_msvc else "14" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "6", + "clang": "6", + "apple-clang": "10", + "Visual Studio": "15.7" if tools.Version(self.version) < "4.6" else "16.2", + } + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def requirements(self): + self.requires("zstd/1.5.2") + if self.options.redis_storage_backend: + self.requires("hiredis/1.0.2") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._min_cppstd) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + "{} requires C++{}, which your compiler does not support.".format(self.name, self._min_cppstd) + ) + + def package_id(self): + del self.info.settings.compiler + + def build_requirements(self): + if hasattr(self, "settings_build") and tools.cross_building(self) and \ + self.settings.os == "Macos" and self.settings.arch == "armv8": + self.build_requires("cmake/3.22.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["REDIS_STORAGE_BACKEND"] = self.options.redis_storage_backend + cmake.definitions["ENABLE_DOCUMENTATION"] = False + cmake.definitions["ENABLE_TESTING"] = False + cmake.configure() + return cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("GPL-*.txt", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/ccache/all/patches/0001-fix-cmake-4.5.1.patch b/recipes/ccache/all/patches/0001-fix-cmake-4.5.1.patch new file mode 100644 index 0000000000000..ba4c4b6a18286 --- /dev/null +++ b/recipes/ccache/all/patches/0001-fix-cmake-4.5.1.patch @@ -0,0 +1,63 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -97,12 +97,12 @@ if(MSVC AND NOT CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg|conan") + endif() + + option(ZSTD_FROM_INTERNET "Download and use libzstd from the Internet" ${ZSTD_FROM_INTERNET_DEFAULT}) +-find_package(zstd 1.1.2 REQUIRED) ++find_package(zstd REQUIRED CONFIG) + + option(REDIS_STORAGE_BACKEND "Enable Redis secondary storage" ON) + if(REDIS_STORAGE_BACKEND) + option(HIREDIS_FROM_INTERNET "Download and use libhiredis from the Internet" ${HIREDIS_FROM_INTERNET_DEFAULT}) +- find_package(hiredis 0.13.3 REQUIRED) ++ find_package(hiredis REQUIRED CONFIG) + endif() + + # +--- a/cmake/GenerateConfigurationFile.cmake ++++ b/cmake/GenerateConfigurationFile.cmake +@@ -104,5 +104,5 @@ if(HAVE_SYS_MMAN_H AND HAVE_PTHREAD_MUTEXATTR_SETPSHARED) + set(INODE_CACHE_SUPPORTED 1) + endif() + +-configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.in ++configure_file(${PROJECT_SOURCE_DIR}/cmake/config.h.in + ${CMAKE_BINARY_DIR}/config.h @ONLY) +--- a/cmake/GenerateVersionFile.cmake ++++ b/cmake/GenerateVersionFile.cmake +@@ -1,4 +1,4 @@ + configure_file( +- ${CMAKE_SOURCE_DIR}/cmake/version.cpp.in ++ ${PROJECT_SOURCE_DIR}/cmake/version.cpp.in + ${CMAKE_BINARY_DIR}/src/version.cpp + @ONLY) +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -27,7 +27,7 @@ set( + execute.cpp + hashutil.cpp + language.cpp +- version.cpp ++ ${CMAKE_BINARY_DIR}/src/version.cpp + ) + + if(INODE_CACHE_SUPPORTED) +@@ -65,7 +65,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + target_link_libraries( + ccache_framework +- PRIVATE standard_settings standard_warnings ZSTD::ZSTD Threads::Threads third_party ++ PRIVATE standard_settings standard_warnings $,zstd::libzstd_shared,zstd::libzstd_static> Threads::Threads third_party + ) + + target_include_directories(ccache_framework PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +@@ -74,7 +74,7 @@ if(REDIS_STORAGE_BACKEND) + target_compile_definitions(ccache_framework PRIVATE -DHAVE_REDIS_STORAGE_BACKEND) + target_link_libraries( + ccache_framework +- PUBLIC standard_settings standard_warnings HIREDIS::HIREDIS third_party ++ PUBLIC standard_settings standard_warnings hiredis::hiredis third_party + ) + endif() + diff --git a/recipes/ccache/all/patches/0001-fix-cmake-4.6.patch b/recipes/ccache/all/patches/0001-fix-cmake-4.6.patch new file mode 100644 index 0000000000000..3b482d24c1c3b --- /dev/null +++ b/recipes/ccache/all/patches/0001-fix-cmake-4.6.patch @@ -0,0 +1,63 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -96,12 +96,12 @@ if(MSVC AND NOT CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg|conan") + endif() + + option(ZSTD_FROM_INTERNET "Download and use libzstd from the Internet" ${ZSTD_FROM_INTERNET_DEFAULT}) +-find_package(zstd 1.1.2 REQUIRED) ++find_package(zstd REQUIRED CONFIG) + + option(REDIS_STORAGE_BACKEND "Enable Redis secondary storage" ON) + if(REDIS_STORAGE_BACKEND) + option(HIREDIS_FROM_INTERNET "Download and use libhiredis from the Internet" ${HIREDIS_FROM_INTERNET_DEFAULT}) +- find_package(hiredis 0.13.3 REQUIRED) ++ find_package(hiredis REQUIRED CONFIG) + endif() + + # +--- a/cmake/GenerateConfigurationFile.cmake ++++ b/cmake/GenerateConfigurationFile.cmake +@@ -106,5 +106,5 @@ if(HAVE_SYS_MMAN_H AND HAVE_PTHREAD_MUTEXATTR_SETPSHARED) + set(INODE_CACHE_SUPPORTED 1) + endif() + +-configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.in ++configure_file(${PROJECT_SOURCE_DIR}/cmake/config.h.in + ${CMAKE_BINARY_DIR}/config.h @ONLY) +--- a/cmake/GenerateVersionFile.cmake ++++ b/cmake/GenerateVersionFile.cmake +@@ -1,4 +1,4 @@ + configure_file( +- ${CMAKE_SOURCE_DIR}/cmake/version.cpp.in ++ ${PROJECT_SOURCE_DIR}/cmake/version.cpp.in + ${CMAKE_BINARY_DIR}/src/version.cpp + @ONLY) +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -26,7 +26,7 @@ set( + execute.cpp + hashutil.cpp + language.cpp +- version.cpp ++ ${CMAKE_BINARY_DIR}/src/version.cpp + ) + + if(INODE_CACHE_SUPPORTED) +@@ -64,7 +64,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + target_link_libraries( + ccache_framework +- PRIVATE standard_settings standard_warnings ZSTD::ZSTD Threads::Threads third_party ++ PRIVATE standard_settings standard_warnings $,zstd::libzstd_shared,zstd::libzstd_static> Threads::Threads third_party + ) + + target_include_directories(ccache_framework PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +@@ -73,7 +73,7 @@ if(REDIS_STORAGE_BACKEND) + target_compile_definitions(ccache_framework PRIVATE -DHAVE_REDIS_STORAGE_BACKEND) + target_link_libraries( + ccache_framework +- PUBLIC standard_settings standard_warnings HIREDIS::HIREDIS third_party ++ PUBLIC standard_settings standard_warnings hiredis::hiredis third_party + ) + endif() + diff --git a/recipes/ccache/all/test_package/conanfile.py b/recipes/ccache/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e357214905abd --- /dev/null +++ b/recipes/ccache/all/test_package/conanfile.py @@ -0,0 +1,9 @@ +from conans import ConanFile, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def test(self): + if not tools.cross_building(self): + self.run("ccache --version", run_environment=True) diff --git a/recipes/ccache/config.yml b/recipes/ccache/config.yml new file mode 100644 index 0000000000000..dd431bc687e88 --- /dev/null +++ b/recipes/ccache/config.yml @@ -0,0 +1,5 @@ +versions: + "4.6": + folder: all + "4.5.1": + folder: all diff --git a/recipes/cccl/all/conandata.yml b/recipes/cccl/all/conandata.yml index 698ce1430d5b6..20725ee2a4b27 100644 --- a/recipes/cccl/all/conandata.yml +++ b/recipes/cccl/all/conandata.yml @@ -2,3 +2,6 @@ sources: "1.1": url: https://github.com/swig/cccl/archive/cccl-1.1.tar.gz sha256: 03ed67d04e8b1e165b8f8d42546ab62ff6c42b3623a2358a7c8255ced144ce28 + "1.3": + url: https://github.com/swig/cccl/archive/cccl-1.3.tar.gz + sha256: 1E34E315CE3AB890D39A75FFABAACCE2E55FE5ED21591F036A45AFDA43A3E989 diff --git a/recipes/cccl/all/conanfile.py b/recipes/cccl/all/conanfile.py index 96543dc449519..3d0509b8a7502 100644 --- a/recipes/cccl/all/conanfile.py +++ b/recipes/cccl/all/conanfile.py @@ -1,15 +1,19 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.files import get, replace_in_file, copy +from conan.tools.layout import basic_layout +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc import os class CcclConan(ConanFile): name = "cccl" description = "Unix cc compiler to Microsoft's cl compiler wrapper" - topics = ("conan", "msvc", "Visual Studio", "wrapper", "gcc") + topics = ("msvc", "visual studio", "wrapper", "gcc") homepage = "https://github.com/swig/cccl/" url = "https://github.com/conan-io/conan-center-index" license = "GPL-3.0-or-later" + settings = "os", "arch", "compiler", "build_type" options = { "muffle": [True, False], "verbose": [True, False], @@ -18,34 +22,37 @@ class CcclConan(ConanFile): "muffle": True, "verbose": False, } - settings = "compiler", - _source_subfolder = "source_subfolder" + @property + def _cccl_dir(self): + return os.path.join(self.package_folder, "bin") - def configure(self): - if self.settings.compiler != "Visual Studio": - raise ConanInvalidConfiguration("This recipe support only Visual Studio") - del self.settings.compiler + def layout(self): + basic_layout(self, src_folder="src") def package_id(self): - del self.info.options.muffle - del self.info.options.verbose + self.info.clear() + + def validate(self): + if not is_msvc(self): + raise ConanInvalidConfiguration("This recipe only supports msvc/Visual Studio.") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("cccl-cccl-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination=self.source_folder) - cccl_path = os.path.join(self.source_folder, self._source_subfolder, "cccl") - tools.replace_in_file(cccl_path, + def build(self): + cccl_path = os.path.join(self.source_folder, self.source_folder, "cccl") + replace_in_file(self, cccl_path, " --help)", " *.lib)\n" " linkopt+=(\"$lib\")" " ;;\n\n" " --help)") - tools.replace_in_file(cccl_path, + replace_in_file(self, cccl_path, "clopt+=(\"$lib\")", "linkopt+=(\"$lib\")") - tools.replace_in_file(cccl_path, + replace_in_file(self, cccl_path, " -L*)", " -LIBPATH:*)\n" " linkopt+=(\"$1\")\n" @@ -53,15 +60,12 @@ def source(self): " -L*)") def package(self): - self.copy("cccl", src=os.path.join(self.source_folder, self._source_subfolder), dst="bin") - self.copy("COPYING", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") + copy(self, pattern="cccl", src=os.path.join(self.source_folder, self.source_folder), dst=self._cccl_dir) + copy(self, pattern="COPYING", src=os.path.join(self.source_folder, self.source_folder), dst=os.path.join(self.package_folder, "licenses")) def package_info(self): - self.cpp_info.bindirs = ["bin", ] - - bindir = os.path.join(self.package_folder, "bin") - self.output.info('Appending PATH environment variable: {}'.format(bindir)) - self.env_info.PATH.append(bindir) + self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] cccl_args = [ "sh", @@ -73,9 +77,16 @@ def package_info(self): cccl_args.append("--cccl-verbose") cccl = " ".join(cccl_args) - self.output.info("Setting CC to '{}'".format(cccl)) + self.buildenv_info.define("CC", cccl) + self.buildenv_info.define("CXX", cccl) + self.buildenv_info.define("LD", cccl) + + # TODO: Legacy, to be removed on Conan 2.0 + self.env_info.PATH.append(self._cccl_dir) + + self.output.info(f"Setting CC to '{cccl}'") self.env_info.CC = cccl - self.output.info("Setting CXX to '{}'".format(cccl)) + self.output.info(f"Setting CXX to '{cccl}'") self.env_info.CXX = cccl - self.output.info("Setting LD to '{}'".format(cccl)) + self.output.info(f"Setting LD to '{cccl}'") self.env_info.LD = cccl diff --git a/recipes/cccl/all/test_package/conanfile.py b/recipes/cccl/all/test_package/conanfile.py index ef3e8cec26c70..b0e11ede43362 100644 --- a/recipes/cccl/all/test_package/conanfile.py +++ b/recipes/cccl/all/test_package/conanfile.py @@ -1,25 +1,33 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import can_run import os class CcclTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "VCVars", "VirtualBuildEnv" + test_type = "explicit" + win_bash = True + + @property + def _settings_build(self): + # TODO: Remove for Conan v2 + return getattr(self, "settings_build", self.settings) def build_requirements(self): - if tools.os_info.is_windows and "CONAN_BASH_PATH" not in os.environ and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") + self.tool_requires(self.tested_reference_str) + if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + self.tool_requires("msys2/cci.latest") def build(self): - environment = {} - if self.settings.compiler == "Visual Studio": - environment.update(tools.vcvars_dict(self.settings)) - with tools.environment_append(environment): - cxx = tools.get_env("CXX") - self.run("{cxx} {src} -o example".format( - cxx=cxx, src=os.path.join(self.source_folder, "example.cpp")), win_bash=self.settings.os is "Windows") + if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + return # cccl needs a bash if there isn't a bash we can't build + cxx = "cccl " + src = os.path.join(self.source_folder, "example.cpp").replace("\\", "/") + self.run(f"{cxx} {src} -o example", cwd=self.build_folder) def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join(self.build_folder, "example")) + if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + return # cccl needs a bash if there isn't a bash we can't build + if can_run(self): + self.run("./example") #test self.run still runs in bash, so it needs "./"; seems weird but okay... diff --git a/recipes/cccl/all/test_v1_package/conanfile.py b/recipes/cccl/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38669b537fb21 --- /dev/null +++ b/recipes/cccl/all/test_v1_package/conanfile.py @@ -0,0 +1,35 @@ +from conans import ConanFile, tools +from conan.tools.microsoft import is_msvc +import os + + +class CcclTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def build(self): + environment = {} + if is_msvc(self): + environment.update(tools.vcvars_dict(self.settings)) + #for k in environment.keys(): + #self.output.highlight(k) + #self.output.highlight(environment[k]) + with tools.environment_append(environment): + cxxTest = tools.get_env("CXX") + #cxxB = self.buildenv_info.vars["CXX"] + self.output.highlight(f"tools.get_env(\"CXX\") = {cxxTest}") + #self.output.highlight(f"self.buildenv_info.vars[\"CXX\"] = {cxxB}") + cxx = "sh cccl " + self.run("{cxx} {src} -o example".format( + cxx=cxx, src=os.path.join(self.source_folder, "example.cpp")), win_bash=self.settings.os is "Windows", run_environment=True) + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join(self.build_folder, "example")) diff --git a/recipes/cccl/all/test_v1_package/example.cpp b/recipes/cccl/all/test_v1_package/example.cpp new file mode 100644 index 0000000000000..ef5068e37c8cc --- /dev/null +++ b/recipes/cccl/all/test_v1_package/example.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello world\n"; + return 0; +} diff --git a/recipes/cccl/config.yml b/recipes/cccl/config.yml index 3f8a45fae5832..8bade519ff028 100644 --- a/recipes/cccl/config.yml +++ b/recipes/cccl/config.yml @@ -1,3 +1,5 @@ versions: "1.1": folder: all + "1.3": + folder: all diff --git a/recipes/ccfits/all/conandata.yml b/recipes/ccfits/all/conandata.yml new file mode 100644 index 0000000000000..010d52b6753b2 --- /dev/null +++ b/recipes/ccfits/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "2.6": + url: "https://heasarc.gsfc.nasa.gov/fitsio/CCfits-2.6/CCfits-2.6.tar.gz" + sha256: "c8395e80379df4e2a63b0890166fb47be4b96dff977214e7ed10ea9d3e9e9a9e" + "2.5": + url: "https://heasarc.gsfc.nasa.gov/fitsio/CCfits-2.5/CCfits-2.5.tar.gz" + sha256: "e542f39fa496417c401be7fbca715d566462cf4c56c83e3d43b6df3cb8d92105" +patches: + "2.6": + - patch_file: "patches/0001-adapt-cmakelists-for-conan-2.6.patch" + "2.5": + - patch_file: "patches/0001-adapt-cmakelists-for-conan-2.5.patch" diff --git a/recipes/ccfits/all/conanfile.py b/recipes/ccfits/all/conanfile.py new file mode 100644 index 0000000000000..c9d53caa2f748 --- /dev/null +++ b/recipes/ccfits/all/conanfile.py @@ -0,0 +1,81 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.52.0" + + +class CcfitsConan(ConanFile): + name = "ccfits" + description = "CCfits is an object oriented interface to the cfitsio library." + license = "ISC" + topics = ("ccfits", "fits", "image", "nasa", "astronomy", "astrophysics", "space") + homepage = "https://heasarc.gsfc.nasa.gov/fitsio/ccfits" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("cfitsio/4.1.0") + + def validate_build(self): + if Version(self.version) >= "2.6": + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + # Export symbols for msvc shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "License.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "CCfits") + self.cpp_info.libs = ["CCfits"] diff --git a/recipes/ccfits/all/patches/0001-adapt-cmakelists-for-conan-2.5.patch b/recipes/ccfits/all/patches/0001-adapt-cmakelists-for-conan-2.5.patch new file mode 100644 index 0000000000000..76929726440b1 --- /dev/null +++ b/recipes/ccfits/all/patches/0001-adapt-cmakelists-for-conan-2.5.patch @@ -0,0 +1,44 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,5 @@ ++CMAKE_MINIMUM_REQUIRED(VERSION 3.1) + PROJECT(CCfits) +-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) + + # Allow the developer to select if Dynamic or Static libraries are built + OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" OFF) +@@ -22,8 +22,7 @@ ENDIF() + + #add_subdirectory (src) + +-find_package(CFITSIO REQUIRED) +-INCLUDE_DIRECTORIES(${CFITSIO_INCLUDE_DIR}) ++find_package(cfitsio REQUIRED CONFIG) + + SET (LIB_TYPE STATIC) + IF (BUILD_SHARED_LIBS) +@@ -55,15 +53,16 @@ SET(SRC_FILES + ) + + ADD_LIBRARY(${LIB_NAME} ${LIB_TYPE} ${H_FILES} ${SRC_FILES}) +-TARGET_LINK_LIBRARIES(${LIB_NAME} ${CFITSIO_LIBRARY} ++TARGET_LINK_LIBRARIES(${LIB_NAME} cfitsio::cfitsio + ) + + SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES + VERSION ${${PROJECT_NAME}_VERSION} + ) +-install(TARGETS ${LIB_NAME} DESTINATION ${LIB_DESTINATION}) ++install(TARGETS ${LIB_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(FILES ${H_FILES} DESTINATION ${INCLUDE_INSTALL_DIR}) + ++if(0) + ENABLE_TESTING() + + SET(TEST_FILES file1.pha) +@@ -72,4 +71,5 @@ ADD_EXECUTABLE(cookbook cookbook.cxx) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/../") + TARGET_LINK_LIBRARIES(cookbook ${LIB_NAME} ${CFITSIO_LIBRARY}) + ADD_TEST(cookbook cookbook) ++endif() + diff --git a/recipes/ccfits/all/patches/0001-adapt-cmakelists-for-conan-2.6.patch b/recipes/ccfits/all/patches/0001-adapt-cmakelists-for-conan-2.6.patch new file mode 100644 index 0000000000000..7d13bff3f3252 --- /dev/null +++ b/recipes/ccfits/all/patches/0001-adapt-cmakelists-for-conan-2.6.patch @@ -0,0 +1,47 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,8 +1,6 @@ ++CMAKE_MINIMUM_REQUIRED(VERSION 3.8) + PROJECT(CCfits) +-CMAKE_MINIMUM_REQUIRED(VERSION 3.1) + +-set (CMAKE_CXX_STANDARD_REQUIRED on) +-set (CMAKE_CXX_STANDARD 11) + + # Allow the developer to select whether to build Dynamic or Static libraries + OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" OFF) +@@ -25,8 +23,7 @@ ENDIF() + + #add_subdirectory (src) + +-find_package(CFITSIO REQUIRED) +-INCLUDE_DIRECTORIES(${CFITSIO_INCLUDE_DIR}) ++find_package(cfitsio REQUIRED CONFIG) + + SET (LIB_TYPE STATIC) + IF (BUILD_SHARED_LIBS) +@@ -58,15 +55,17 @@ SET(SRC_FILES + ) + + ADD_LIBRARY(${LIB_NAME} ${LIB_TYPE} ${H_FILES} ${SRC_FILES}) +-TARGET_LINK_LIBRARIES(${LIB_NAME} ${CFITSIO_LIBRARY} ++TARGET_LINK_LIBRARIES(${LIB_NAME} cfitsio::cfitsio + ) ++TARGET_COMPILE_FEATURES(${LIB_NAME} PRIVATE cxx_std_11) + + SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES + VERSION ${${PROJECT_NAME}_VERSION} + ) +-install(TARGETS ${LIB_NAME} DESTINATION ${LIB_DESTINATION}) ++install(TARGETS ${LIB_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(FILES ${H_FILES} DESTINATION ${INCLUDE_INSTALL_DIR}) + ++if(0) + ENABLE_TESTING() + + SET(TEST_FILES file1.pha) +@@ -75,3 +74,4 @@ ADD_EXECUTABLE(cookbook cookbook.cxx) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} "${CMAKE_SOURCE_DIR}/../") + TARGET_LINK_LIBRARIES(cookbook ${LIB_NAME} ${CFITSIO_LIBRARY}) + ADD_TEST(cookbook cookbook) ++endif() diff --git a/recipes/ccfits/all/test_package/CMakeLists.txt b/recipes/ccfits/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2112b47f62dd2 --- /dev/null +++ b/recipes/ccfits/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(ccfits REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ccfits::ccfits) diff --git a/recipes/ccfits/all/test_package/conanfile.py b/recipes/ccfits/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/ccfits/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/ccfits/all/test_package/test_package.cpp b/recipes/ccfits/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..d90b0da45c1bf --- /dev/null +++ b/recipes/ccfits/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include + +int main() { + long naxis = 2; + long naxes[2] = {10, 20}; + CCfits::FITS fits("test.fit", USHORT_IMG, naxis, naxes); + return 0; +} diff --git a/recipes/ccfits/all/test_v1_package/CMakeLists.txt b/recipes/ccfits/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..20c81e8e8eb12 --- /dev/null +++ b/recipes/ccfits/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ccfits REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ccfits::ccfits) diff --git a/recipes/ccfits/all/test_v1_package/conanfile.py b/recipes/ccfits/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/ccfits/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ccfits/config.yml b/recipes/ccfits/config.yml new file mode 100644 index 0000000000000..190484bc6f800 --- /dev/null +++ b/recipes/ccfits/config.yml @@ -0,0 +1,5 @@ +versions: + "2.6": + folder: all + "2.5": + folder: all diff --git a/recipes/cctag/all/CMakeLists.txt b/recipes/cctag/all/CMakeLists.txt new file mode 100644 index 0000000000000..63ebbfa0b0e57 --- /dev/null +++ b/recipes/cctag/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.13) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/cctag/all/conandata.yml b/recipes/cctag/all/conandata.yml new file mode 100644 index 0000000000000..21b5b45039b4d --- /dev/null +++ b/recipes/cctag/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.0.1": + url: "https://github.com/alicevision/CCTag/archive/refs/tags/v1.0.1.tar.gz" + sha256: "ae8a819bc978eb13bb1061a204c214da835e56c9b7dc775237ed6b2191011dec" +patches: + "1.0.1": + - patch_file: "patches/0001-honor-vc-runtime.patch" + base_path: "source_subfolder" diff --git a/recipes/cctag/all/conanfile.py b/recipes/cctag/all/conanfile.py new file mode 100644 index 0000000000000..f770ba481240f --- /dev/null +++ b/recipes/cctag/all/conanfile.py @@ -0,0 +1,154 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.43.0" + + +class CCTagConan(ConanFile): + name = "cctag" + description = "Detection of CCTag markers made up of concentric circles." + license = "MPL-2.0" + topics = ("cctag", "computer-vision", "detection", "image-processing", + "markers", "fiducial-markers", "concentric-circles") + homepage = "https://github.com/alicevision/CCTag" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "serialize": [True, False], + "visual_debug": [True, False], + "no_cout": [True, False], + "with_cuda": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "serialize": False, + "visual_debug": False, + "no_cout": True, + "with_cuda": False, + } + + generators = "cmake", "cmake_find_package" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("boost/1.78.0") + self.requires("eigen/3.4.0") + self.requires("onetbb/2020.3") + self.requires("opencv/4.5.5") + + @property + def _required_boost_components(self): + return [ + "atomic", "chrono", "date_time", "exception", "filesystem", + "math", "serialization", "stacktrace", "system", "thread", "timer", + ] + + def validate(self): + miss_boost_required_comp = \ + any(getattr(self.options["boost"], + "without_{}".format(boost_comp), + True) for boost_comp in self._required_boost_components) + if self.options["boost"].header_only or miss_boost_required_comp: + raise ConanInvalidConfiguration( + "{0} requires non header-only boost with these components: {1}".format( + self.name, ", ".join(self._required_boost_components), + ) + ) + + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 14) + + # FIXME: add cuda support + if self.options.with_cuda: + raise ConanInvalidConfiguration("CUDA not supported yet") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + # Cleanup RPATH if Apple in shared lib of install tree + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)", + "") + # Link to OpenCV targets + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + "${OpenCV_LIBS}", + "opencv_core opencv_videoio opencv_imgproc opencv_imgcodecs") + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["CCTAG_SERIALIZE"] = self.options.serialize + cmake.definitions["CCTAG_VISUAL_DEBUG"] = self.options.visual_debug + cmake.definitions["CCTAG_NO_COUT"] = self.options.no_cout + cmake.definitions["CCTAG_WITH_CUDA"] = self.options.with_cuda + cmake.definitions["CCTAG_BUILD_APPS"] = False + cmake.definitions["CCTAG_CUDA_CC_CURRENT_ONLY"] = False + cmake.definitions["CCTAG_NVCC_WARNINGS"] = False + cmake.definitions["CCTAG_EIGEN_NO_ALIGN"] = True + cmake.definitions["CCTAG_USE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) + cmake.definitions["CCTAG_ENABLE_SIMD_AVX2"] = False + cmake.definitions["CCTAG_BUILD_TESTS"] = False + cmake.definitions["CCTAG_BUILD_DOC"] = False + cmake.definitions["CCTAG_NO_THRUST_COPY_IF"] = False + cmake.configure() + return cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("COPYING.md", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "CCTag") + self.cpp_info.set_property("cmake_target_name", "CCTag::CCTag") + suffix = "d" if self.settings.build_type == "Debug" else "" + self.cpp_info.libs = ["CCTag{}".format(suffix)] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["dl", "pthread"]) + self.cpp_info.requires = [ + "boost::atomic", "boost::chrono", "boost::date_time", "boost::exception", + "boost::filesystem", "boost::serialization", "boost::system", + "boost::thread", "boost::timer", "boost::math_c99", "eigen::eigen", + "onetbb::onetbb", "opencv::opencv_core", "opencv::opencv_videoio", + "opencv::opencv_imgproc", "opencv::opencv_imgcodecs", + ] + if self.settings.os == "Windows": + self.cpp_info.requires.append("boost::stacktrace_windbg") + else: + self.cpp_info.requires.append("boost::stacktrace_basic") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "CCTag" + self.cpp_info.names["cmake_find_package_multi"] = "CCTag" diff --git a/recipes/cctag/all/patches/0001-honor-vc-runtime.patch b/recipes/cctag/all/patches/0001-honor-vc-runtime.patch new file mode 100644 index 0000000000000..ee5d7ef70c107 --- /dev/null +++ b/recipes/cctag/all/patches/0001-honor-vc-runtime.patch @@ -0,0 +1,18 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -41,6 +41,7 @@ else() + message(STATUS "Building in ${CMAKE_BUILD_TYPE} configuration") + endif() + ++if(0) + # ensure the proper linker flags when building the static version on MSVC + if(MSVC AND NOT BUILD_SHARED_LIBS) + foreach(config "DEBUG" "RELEASE" "MINSIZEREL" "RELWITHDEBINFO") +@@ -64,6 +65,7 @@ if(MSVC AND CMAKE_GENERATOR MATCHES "Ninja") + endif() + list(APPEND CUDA_NVCC_FLAGS -Xcompiler ${CCTAG_MVSC_LINKER}) + endif() ++endif() + + set(CCTAG_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD ${CCTAG_CXX_STANDARD}) diff --git a/recipes/cctag/all/test_package/CMakeLists.txt b/recipes/cctag/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..9ba93733e0fd1 --- /dev/null +++ b/recipes/cctag/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CCTag REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} CCTag::CCTag) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/cctag/all/test_package/conanfile.py b/recipes/cctag/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cctag/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cctag/all/test_package/test_package.cpp b/recipes/cctag/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f4cc8324c2330 --- /dev/null +++ b/recipes/cctag/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + cctag::EdgePointCollection(1024, 1024); + return 0; +} diff --git a/recipes/cctag/config.yml b/recipes/cctag/config.yml new file mode 100644 index 0000000000000..715e55357a17b --- /dev/null +++ b/recipes/cctag/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.1": + folder: all diff --git a/recipes/cctz/all/CMakeLists.txt b/recipes/cctz/all/CMakeLists.txt deleted file mode 100644 index 49f4fbe2d606b..0000000000000 --- a/recipes/cctz/all/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - - -if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") - include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -else() - include(conanbuildinfo.cmake) -endif() -conan_basic_setup() - -if (WIN32 AND BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif(WIN32 AND BUILD_SHARED_LIBS) - -add_subdirectory("source_subfolder") diff --git a/recipes/cctz/all/conandata.yml b/recipes/cctz/all/conandata.yml index f42080f1e4e5d..112fd00e61958 100644 --- a/recipes/cctz/all/conandata.yml +++ b/recipes/cctz/all/conandata.yml @@ -2,3 +2,7 @@ sources: "2.3": url: "https://github.com/google/cctz/archive/v2.3.tar.gz" sha256: "8615b20d4e33e02a271c3b93a3b208e3d7d5d66880f5f6208b03426e448f32db" +patches: + "2.3": + - patch_file: "patches/0001-fix-installation.patch" + - patch_file: "patches/0002-fix-frameworks-apple.patch" diff --git a/recipes/cctz/all/conanfile.py b/recipes/cctz/all/conanfile.py index 4ffc61e1d3aca..ccf49ac66ee4e 100644 --- a/recipes/cctz/all/conanfile.py +++ b/recipes/cctz/all/conanfile.py @@ -1,6 +1,12 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.51.3" class CCTZConan(ConanFile): @@ -8,66 +14,73 @@ class CCTZConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/google/cctz" description = "C++ library for translating between absolute and civil times" - topics = ("conan", "cctz", "time", "timezones") + topics = ("cctz", "time", "timezones") license = "Apache-2.0" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "fPIC": [True, False], "shared": [True, False], - "build_tools" : [True, False] + "build_tools" : [True, False], } default_options = { "fPIC": True, - "shared": False, - "build_tools": False + "shared": False, + "build_tools": True, } - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.os == "Windows" and \ - self.settings.compiler == "Visual Studio" and \ - tools.Version(self.settings.compiler.version) < 14: - raise ConanInvalidConfiguration("CCTZ requires MSVC >= 14") + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.compiler == "Visual Studio" and \ + Version(self.settings.compiler.version) < 14: + raise ConanInvalidConfiguration("CCTZ requires MSVC >= 14") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["BUILD_TOOLS"] = self.options.build_tools - cmake.definitions["BUILD_EXAMPLES"] = False - cmake.definitions["BUILD_TESTING"] = False - cmake.configure(build_folder=self._build_subfolder) - return cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TOOLS"] = self.options.build_tools + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_TESTING"] = False + # For shared msvc + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + # Relocatable shared lib on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() def build(self): - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - - # CMake install doesn't package the .dll - self.copy(pattern="*.dll", dst="bin", keep_path=False) - - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if tools.is_apple_os(self.settings.os): + self.cpp_info.set_property("cmake_file_name", "cctz") + self.cpp_info.set_property("cmake_target_name", "cctz::cctz") + self.cpp_info.libs = ["cctz"] + if is_apple_os(self): self.cpp_info.frameworks.append("CoreFoundation") if self.options.build_tools: diff --git a/recipes/cctz/all/patches/0001-fix-installation.patch b/recipes/cctz/all/patches/0001-fix-installation.patch new file mode 100644 index 0000000000000..f4f161a168e17 --- /dev/null +++ b/recipes/cctz/all/patches/0001-fix-installation.patch @@ -0,0 +1,18 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -159,13 +159,14 @@ include(GNUInstallDirs) + install(TARGETS cctz + EXPORT ${PROJECT_NAME}-targets + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cctz ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + if (BUILD_TOOLS) + install(TARGETS time_tool + EXPORT ${PROJECT_NAME}-targets +- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + endif() + set(CMAKE_INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) diff --git a/recipes/cctz/all/patches/0002-fix-frameworks-apple.patch b/recipes/cctz/all/patches/0002-fix-frameworks-apple.patch new file mode 100644 index 0000000000000..d7c764fd33efe --- /dev/null +++ b/recipes/cctz/all/patches/0002-fix-frameworks-apple.patch @@ -0,0 +1,13 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -96,7 +96,9 @@ target_include_directories(cctz PUBLIC + set_target_properties(cctz PROPERTIES + PUBLIC_HEADER "${CCTZ_HDRS}" + ) +-target_link_libraries(cctz PUBLIC $<$:${CoreFoundation}>) ++if(APPLE) ++ target_link_libraries(cctz PUBLIC ${CoreFoundation}) ++endif() + add_library(cctz::cctz ALIAS cctz) + + if (BUILD_TOOLS) diff --git a/recipes/cctz/all/test_package/CMakeLists.txt b/recipes/cctz/all/test_package/CMakeLists.txt index 9c43a46da45b0..ed91192a576a9 100644 --- a/recipes/cctz/all/test_package/CMakeLists.txt +++ b/recipes/cctz/all/test_package/CMakeLists.txt @@ -1,10 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cctz REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) - -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE cctz::cctz) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cctz/all/test_package/conanfile.py b/recipes/cctz/all/test_package/conanfile.py index e59b03d39f6cf..3a8c6c5442b33 100644 --- a/recipes/cctz/all/test_package/conanfile.py +++ b/recipes/cctz/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,9 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - - if self.options["cctz"].build_tools: - self.run("time_tool --tz=Europe/Berlin") + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cctz/all/test_v1_package/CMakeLists.txt b/recipes/cctz/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..46aaf8b80ff51 --- /dev/null +++ b/recipes/cctz/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cctz REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cctz::cctz) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cctz/all/test_v1_package/conanfile.py b/recipes/cctz/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cctz/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/celero/all/conandata.yml b/recipes/celero/all/conandata.yml index e8a65e8d6d374..5c189657151ee 100644 --- a/recipes/celero/all/conandata.yml +++ b/recipes/celero/all/conandata.yml @@ -1,12 +1,16 @@ sources: + "2.8.2": + url: "https://github.com/DigitalInBlue/Celero/archive/v2.8.2.tar.gz" + sha256: "7d2131ba27ca5343b31f1e04777ed3e666e2ad7f785e79c960c872fc48cd5f88" "2.6.0": url: "https://github.com/DigitalInBlue/Celero/archive/v2.6.0.tar.gz" sha256: "a5b72da254f81d42369382ba3157229b6b32ebbb670a22b185f80db95535e66e" patches: + "2.8.2": + - patch_file: "patches/0004-2.8.2-missing-include.patch" + - patch_file: "patches/0005-drop-runtime.patch" "2.6.0": - - patch_file: "patches/cmake-install-pic-cxx-standard-sytem-libs.patch" - base_path: "source_subfolder" - - patch_file: "patches/lowercase-include-system-libs-windows.patch" - base_path: "source_subfolder" - - patch_file: "patches/typo-declspec.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-cmake-install-pic-cxx-standard-sytem-libs.patch" + - patch_file: "patches/0002-lowercase-include-system-libs-windows.patch" + - patch_file: "patches/0003-typo-declspec.patch" + - patch_file: "patches/0004-2.6.0-missing-include.patch" diff --git a/recipes/celero/all/conanfile.py b/recipes/celero/all/conanfile.py index 55d8e88426e9a..69aa65940de12 100644 --- a/recipes/celero/all/conanfile.py +++ b/recipes/celero/all/conanfile.py @@ -1,32 +1,32 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get, rmdir, save +from conan.tools.scm import Version import os +import textwrap -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.50.0" -required_conan_version = ">=1.28.0" class CeleroConan(ConanFile): name = "celero" description = "C++ Benchmarking Library" license = "Apache-2.0" - topics = ("conan", "celero", "benchmark", "benchmark-tests", "measurements", "microbenchmarks") + topics = ("celero", "benchmark", "benchmark-tests", "measurements", "microbenchmarks") homepage = "https://github.com/DigitalInBlue/Celero" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } @property def _compilers_minimum_version(self): @@ -37,56 +37,90 @@ def _compilers_minimum_version(self): "apple-clang": "5.1", } + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 14) - minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if not minimum_version: - self.output.warn("celero requires C++14. Your compiler is unknown. Assuming it supports C++14.") - elif tools.Version(self.settings.compiler.version) < minimum_version: + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 14) + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: raise ConanInvalidConfiguration("celero requires C++14, which your compiler does not support.") + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("Celero-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CELERO_COMPILE_DYNAMIC_LIBRARIES"] = self.options.shared - self._cmake.definitions["CELERO_COMPILE_PIC"] = self.options.get_safe("fPIC", True) - self._cmake.definitions["CELERO_ENABLE_EXPERIMENTS"] = False - self._cmake.definitions["CELERO_ENABLE_FOLDERS"] = False - self._cmake.definitions["CELERO_ENABLE_TESTS"] = False - self._cmake.definitions["CELERO_TREAT_WARNINGS_AS_ERRORS"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CELERO_COMPILE_DYNAMIC_LIBRARIES"] = self.options.shared + tc.variables["CELERO_COMPILE_PIC"] = self.options.get_safe("fPIC", True) + tc.variables["CELERO_ENABLE_EXPERIMENTS"] = False + tc.variables["CELERO_ENABLE_FOLDERS"] = False + tc.variables["CELERO_ENABLE_TESTS"] = False + tc.variables["CELERO_TREAT_WARNINGS_AS_ERRORS"] = False + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("license.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "license.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "share")) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"celero": "celero::celero"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - # FIXME: official CMake target is exported without namespace - self.cpp_info.filenames["cmake_find_package"] = "Celero" - self.cpp_info.filenames["cmake_find_package_multi"] = "Celero" - self.cpp_info.names["cmake_find_package"] = "celero" - self.cpp_info.names["cmake_find_package_multi"] = "celero" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "Celero") + self.cpp_info.set_property("cmake_target_name", "celero") + self.cpp_info.libs = collect_libs(self) if not self.options.shared: self.cpp_info.defines = ["CELERO_STATIC"] - if self.settings.os == "Linux": + if self.settings.os in ("FreeBSD", "Linux"): self.cpp_info.system_libs = ["pthread"] elif self.settings.os == "Windows": self.cpp_info.system_libs = ["powrprof", "psapi"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "Celero" + self.cpp_info.filenames["cmake_find_package_multi"] = "Celero" + self.cpp_info.names["cmake_find_package"] = "celero" + self.cpp_info.names["cmake_find_package_multi"] = "celero" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/celero/all/patches/cmake-install-pic-cxx-standard-sytem-libs.patch b/recipes/celero/all/patches/0001-cmake-install-pic-cxx-standard-sytem-libs.patch similarity index 100% rename from recipes/celero/all/patches/cmake-install-pic-cxx-standard-sytem-libs.patch rename to recipes/celero/all/patches/0001-cmake-install-pic-cxx-standard-sytem-libs.patch diff --git a/recipes/celero/all/patches/lowercase-include-system-libs-windows.patch b/recipes/celero/all/patches/0002-lowercase-include-system-libs-windows.patch similarity index 100% rename from recipes/celero/all/patches/lowercase-include-system-libs-windows.patch rename to recipes/celero/all/patches/0002-lowercase-include-system-libs-windows.patch diff --git a/recipes/celero/all/patches/typo-declspec.patch b/recipes/celero/all/patches/0003-typo-declspec.patch similarity index 100% rename from recipes/celero/all/patches/typo-declspec.patch rename to recipes/celero/all/patches/0003-typo-declspec.patch diff --git a/recipes/celero/all/patches/0004-2.6.0-missing-include.patch b/recipes/celero/all/patches/0004-2.6.0-missing-include.patch new file mode 100644 index 0000000000000..60589414f6eb6 --- /dev/null +++ b/recipes/celero/all/patches/0004-2.6.0-missing-include.patch @@ -0,0 +1,10 @@ +--- a/include/celero/TestFixture.h ++++ b/include/celero/TestFixture.h +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + #include + #include + diff --git a/recipes/celero/all/patches/0004-2.8.2-missing-include.patch b/recipes/celero/all/patches/0004-2.8.2-missing-include.patch new file mode 100644 index 0000000000000..00155b6e65a62 --- /dev/null +++ b/recipes/celero/all/patches/0004-2.8.2-missing-include.patch @@ -0,0 +1,10 @@ +--- a/include/celero/TestFixture.h ++++ b/include/celero/TestFixture.h +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + #include + #include + diff --git a/recipes/celero/all/patches/0005-drop-runtime.patch b/recipes/celero/all/patches/0005-drop-runtime.patch new file mode 100644 index 0000000000000..0559d5d36c265 --- /dev/null +++ b/recipes/celero/all/patches/0005-drop-runtime.patch @@ -0,0 +1,23 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a8e771a..ff89a66 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -35,18 +35,6 @@ macro(CeleroSetDefaultCompilerOptions) + target_compile_options(${PROJECT_NAME} PRIVATE /D_SCL_SECURE_NO_WARNINGS) + target_compile_options(${PROJECT_NAME} PRIVATE /permissive-) + +- if (NOT CELERO_COMPILE_DYNAMIC_LIBRARIES) +- if(VCPKG_CRT_LINKAGE) +- if(VCPKG_CRT_LINKAGE STREQUAL "static") +- target_compile_options(${PROJECT_NAME} PRIVATE /MT$<$:d>) +- else() +- target_compile_options(${PROJECT_NAME} PRIVATE /MD$<$:d>) +- endif() +- else() +- target_compile_options(${PROJECT_NAME} PRIVATE /MD$<$:d>) +- endif() +- endif() +- + if(CELERO_TREAT_WARNINGS_AS_ERRORS) + target_compile_options(${PROJECT_NAME} PRIVATE /WX) + endif() diff --git a/recipes/celero/all/test_package/CMakeLists.txt b/recipes/celero/all/test_package/CMakeLists.txt index ef9165a2bb9f6..0a511951ebd5f 100644 --- a/recipes/celero/all/test_package/CMakeLists.txt +++ b/recipes/celero/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(Celero REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} celero::celero) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +target_link_libraries(${PROJECT_NAME} PRIVATE celero) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/celero/all/test_package/conanfile.py b/recipes/celero/all/test_package/conanfile.py index c6580760bfee2..d120a992c06a6 100644 --- a/recipes/celero/all/test_package/conanfile.py +++ b/recipes/celero/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/celero/all/test_package/test_package.cpp b/recipes/celero/all/test_package/test_package.cpp index d621620bb7ba7..ac63ab21c696d 100644 --- a/recipes/celero/all/test_package/test_package.cpp +++ b/recipes/celero/all/test_package/test_package.cpp @@ -19,7 +19,7 @@ std::uniform_int_distribution UniformDistribution(0, 1024); /// Interestingly, taking the sin of a constant number here resulted in a /// great deal of optimization in clang and gcc. /// -BASELINE(DemoSimple, Baseline, 10, 1000000) +BASELINE(DemoSimple, Baseline, 10, 100000) { celero::DoNotOptimizeAway(static_cast(std::sin(UniformDistribution(RandomDevice)))); } diff --git a/recipes/celero/all/test_v1_package/CMakeLists.txt b/recipes/celero/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..5f83c8c27b4cd --- /dev/null +++ b/recipes/celero/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Celero REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE celero) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/celero/all/test_v1_package/conanfile.py b/recipes/celero/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/celero/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/celero/config.yml b/recipes/celero/config.yml index fd1c6521f3d05..3f32427faf7d1 100644 --- a/recipes/celero/config.yml +++ b/recipes/celero/config.yml @@ -1,3 +1,5 @@ versions: + "2.8.2": + folder: all "2.6.0": folder: all diff --git a/recipes/cereal/all/CMakeLists.txt b/recipes/cereal/all/CMakeLists.txt deleted file mode 100644 index d17aaff199b4a..0000000000000 --- a/recipes/cereal/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/cereal/all/conandata.yml b/recipes/cereal/all/conandata.yml index b49969281eb0b..885e23f3a294b 100644 --- a/recipes/cereal/all/conandata.yml +++ b/recipes/cereal/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.3.2": + url: "https://github.com/USCiLab/cereal/archive/v1.3.2.tar.gz" + sha256: "16a7ad9b31ba5880dac55d62b5d6f243c3ebc8d46a3514149e56b5e7ea81f85f" + "1.3.1": + url: "https://github.com/USCiLab/cereal/archive/v1.3.1.tar.gz" + sha256: "65ea6ddda98f4274f5c10fb3e07b2269ccdd1e5cbb227be6a2fd78b8f382c976" "1.3.0": url: "https://github.com/USCiLab/cereal/archive/v1.3.0.tar.gz" sha256: "329ea3e3130b026c03a4acc50e168e7daff4e6e661bc6a7dfec0d77b570851d5" diff --git a/recipes/cereal/all/conanfile.py b/recipes/cereal/all/conanfile.py index e382ee5823f5f..7523bebc550cf 100644 --- a/recipes/cereal/all/conanfile.py +++ b/recipes/cereal/all/conanfile.py @@ -1,73 +1,94 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir, save import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" class CerealConan(ConanFile): name = "cereal" description = "Serialization header-only library for C++11." license = "BSD-3-Clause" - topics = ("conan", "cereal", "header-only", "serialization", "cpp11") + topics = ("cereal", "header-only", "serialization", "cpp11") homepage = "https://github.com/USCiLab/cereal" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "CMakeLists.txt" - generators = "cmake" - settings = "os", "compiler", "build_type", "arch" - options = {"thread_safe": [True, False]} - default_options = {"thread_safe": False} - no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "thread_safe": [True, False], + } + default_options = { + "thread_safe": False, + } def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + def generate(self): + tc = CMakeToolchain(self) + tc.variables["JUST_INSTALL_CEREAL"] = True + tc.variables["CEREAL_INSTALL"] = True + tc.generate() + + def build(self): cmake = CMake(self) - cmake.definitions["JUST_INSTALL_CEREAL"] = True cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) + + # The "share" folder was being removed up to and including version 1.3.0. + # The module files were moved to lib/cmake from 1.3.1 on, so now removing both + # as to avoid breaking versions < 1.3.1 + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib")) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._module_subfolder, self._module_file), + os.path.join(self.package_folder, self._module_file_rel_path), {"cereal": "cereal::cereal"} ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) + """) + save(self, module_file, content) @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") - - @property - def _module_file(self): - return "conan-official-{}-targets.cmake".format(self.name) + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.builddirs.append(self._module_subfolder) - module_target_rel_path = os.path.join(self._module_subfolder, self._module_file) - self.cpp_info.build_modules["cmake_find_package"] = [module_target_rel_path] - self.cpp_info.build_modules["cmake_find_package_multi"] = [module_target_rel_path] + self.cpp_info.set_property("cmake_file_name", "cereal") + self.cpp_info.set_property("cmake_target_name", "cereal::cereal") + self.cpp_info.set_property("cmake_target_aliases", ["cereal"]) # target before 1.3.1 + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] if self.options.thread_safe: self.cpp_info.defines = ["CEREAL_THREAD_SAFE=1"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("pthread") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/cereal/all/test_package/CMakeLists.txt b/recipes/cereal/all/test_package/CMakeLists.txt index 00968c253c9b2..70514b278957b 100644 --- a/recipes/cereal/all/test_package/CMakeLists.txt +++ b/recipes/cereal/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(cereal CONFIG REQUIRED) +find_package(cereal REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} cereal) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE cereal::cereal) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cereal/all/test_package/conanfile.py b/recipes/cereal/all/test_package/conanfile.py index 84ee68733e516..d120a992c06a6 100644 --- a/recipes/cereal/all/test_package/conanfile.py +++ b/recipes/cereal/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cereal/all/test_v1_package/CMakeLists.txt b/recipes/cereal/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3bc0d9666049d --- /dev/null +++ b/recipes/cereal/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cereal REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cereal::cereal) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cereal/all/test_v1_package/conanfile.py b/recipes/cereal/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cereal/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cereal/config.yml b/recipes/cereal/config.yml index 426a0e4c79e9b..b558b881f2cfe 100644 --- a/recipes/cereal/config.yml +++ b/recipes/cereal/config.yml @@ -1,3 +1,7 @@ versions: + "1.3.2": + folder: all + "1.3.1": + folder: all "1.3.0": folder: all diff --git a/recipes/ceres-solver/all/CMakeLists.txt b/recipes/ceres-solver/all/CMakeLists.txt index bd945206ea460..61f3d3b039e2b 100644 --- a/recipes/ceres-solver/all/CMakeLists.txt +++ b/recipes/ceres-solver/all/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 2.8) -project(conanWrapper) +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory("source_subfolder") diff --git a/recipes/ceres-solver/all/conandata.yml b/recipes/ceres-solver/all/conandata.yml index 00f1275d526e9..6ee161fbdfbf0 100644 --- a/recipes/ceres-solver/all/conandata.yml +++ b/recipes/ceres-solver/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "2.1.0": + url: https://github.com/ceres-solver/ceres-solver/archive/2.1.0.tar.gz + sha256: ccbd716a93f65d4cb017e3090ae78809e02f5426dce16d0ee2b4f8a4ba2411a8 "2.0.0": url: https://github.com/ceres-solver/ceres-solver/archive/2.0.0.tar.gz sha256: 2ab0348e0f65fdf43bebcd325a1c73f7e8999691ee75e2a2981281931c42e9fa @@ -9,11 +12,20 @@ sources: url: https://github.com/ceres-solver/ceres-solver/archive/1.13.0.tar.gz sha256: 51ccb201b61ac71501fb6ccef158f078a750bc796ee6a271cd535cfe338202e5 patches: + "2.1.0": + - patch_file: "patches/2.0.1-0001-find-glog-conan.patch" + base_path: "source_subfolder" + - patch_file: "patches/2.0.1-0002-find-glags-conan.patch" + base_path: "source_subfolder" + - patch_file: "patches/2.0.1-0003-fix-mingw-build.patch" + base_path: "source_subfolder" "2.0.0": - patch_file: "patches/2.0.0-0001-find-libraries-conan.patch" base_path: "source_subfolder" - patch_file: "patches/2.0.0-0002-fix-eigen-version.patch" base_path: "source_subfolder" + - patch_file: "patches/2.0.0-0003-fix-mingw-build.patch" + base_path: "source_subfolder" "1.14.0": - patch_file: "patches/1.14.0-0001-find-libraries-conan.patch" base_path: "source_subfolder" diff --git a/recipes/ceres-solver/all/conanfile.py b/recipes/ceres-solver/all/conanfile.py index ebde9d4ffb753..ab45710022fbe 100644 --- a/recipes/ceres-solver/all/conanfile.py +++ b/recipes/ceres-solver/all/conanfile.py @@ -1,44 +1,63 @@ -import os +from conan.tools.microsoft import msvc_runtime_flag from conans import ConanFile, tools, CMake from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.43.0" + class ceressolverConan(ConanFile): name = "ceres-solver" license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "http://ceres-solver.org/" - description = ("Ceres Solver is an open source C++ library for modeling\ - and solving large, complicated optimization problems") - topics = ("optimization","Non-linear Least Squares") + description = ( + "Ceres Solver is an open source C++ library for modeling " + "and solving large, complicated optimization problems" + ) + topics = ("optimization","non-linear least squares") + settings = "os", "arch", "compiler", "build_type" - generators = ["cmake"] - options = {"shared": [True, False], - "fPIC": [True, False], - "use_glog": [True, False], #TODO Set to true once gflags with nothreads=False binaries are available. Using MINILOG has a big performance drawback. - "use_gflags": [True, False], - "use_custom_blas": [True, False], - "use_eigen_sparse": [True, False], - "use_TBB": [True, False], - "use_CXX11_threads": [True, False], - "use_CXX11": [True, False], - "use_schur_specializations": [True, False]} - default_options = {"shared": False, - "fPIC": True, - "use_glog": False, - "use_gflags": False, - "use_custom_blas": True, - "use_eigen_sparse": True, - "use_TBB": False, - "use_CXX11_threads": False, - "use_CXX11": False, - "use_schur_specializations": True} - exports_sources = ["CMakeLists.txt","patches/*"] + options = { + "shared": [True, False], + "fPIC": [True, False], + "use_glog": [True, False], #TODO Set to true once gflags with nothreads=False binaries are available. Using MINILOG has a big performance drawback. + "use_gflags": [True, False], + "use_custom_blas": [True, False], + "use_eigen_sparse": [True, False], + "use_TBB": [True, False], + "use_CXX11_threads": [True, False], + "use_CXX11": [True, False], + "use_schur_specializations": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "use_glog": False, + "use_gflags": False, + "use_custom_blas": True, + "use_eigen_sparse": True, + "use_TBB": False, + "use_CXX11_threads": False, + "use_CXX11": False, + "use_schur_specializations": True, + } + + generators = "cmake" @property def _source_subfolder(self): return "source_subfolder" - _cmake = None + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == "Windows": @@ -47,6 +66,21 @@ def config_options(self): del self.options.use_CXX11_threads del self.options.use_CXX11 + def configure(self): + if self.options.shared: + del self.options.fPIC + if self.options.use_gflags: + self.options["gflags"].nothreads = False + + def requirements(self): + self.requires("eigen/3.4.0") + if self.options.use_glog: + self.requires("glog/0.5.0") + if self.options.use_gflags: + self.requires("gflags/2.2.2") + if self.options.use_TBB: + self.requires("onetbb/2020.3") + def _check_cxx14_supported(self): min_compiler_version = { "gcc": "5", @@ -59,65 +93,53 @@ def _check_cxx14_supported(self): elif tools.Version(self.settings.compiler.version) < min_compiler_version: raise ConanInvalidConfiguration("Current compiler version does not support c++14") - def configure(self): - if self.options.shared: - del self.options.fPIC + def validate(self): if self.settings.build_type == "Debug" and self.options.use_glog: raise ConanInvalidConfiguration("Ceres-solver only links against the release version of glog") if self.options.use_glog and not self.options.use_gflags: #At this stage we can't check the value of self.options["glog"].with_gflags so we asume it is true because is the default value raise ConanInvalidConfiguration("To depend on glog built with gflags (Default behavior) set use_gflags=True, otherwise Ceres may fail to link due to missing gflags symbols.") + if self.options.use_gflags and self.options["gflags"].nothreads: + raise ConanInvalidConfiguration("Ceres-solver requires options gflags:nothreads=False") # This could use a source as to why if tools.Version(self.version) >= "2.0": # 1.x uses ceres-solver specific FindXXX.cmake modules self.generators.append("cmake_find_package") - if self.settings.compiler.cppstd: + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, 14) self._check_cxx14_supported() - def requirements(self): - self.requires("eigen/3.3.8") - if self.options.use_glog: - self.requires("glog/0.4.0") - if self.options.use_gflags: - self.requires("gflags/2.2.2") - self.options["gflags"].nothreads = False - if self.options.use_TBB: - self.requires("tbb/2020.2") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination = self._source_subfolder, strip_root=True) + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) #You can check what these flags do in http://ceres-solver.org/installation.html - self._cmake.definitions["LIB_SUFFIX"] = "" - self._cmake.definitions["GFLAGS"] = self.options.use_gflags - self._cmake.definitions["BUILD_EXAMPLES"] = False #Requires gflags - self._cmake.definitions["BUILD_TESTING"] = False #Requires gflags - self._cmake.definitions["BUILD_DOCUMENTATION"] = False #Requires python modules Sphinx and sphinx-rtd-theme - self._cmake.definitions["CUSTOM_BLAS"] = self.options.use_custom_blas - self._cmake.definitions["GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION"] = False #Set to false to Force CMake to use the conan-generated dependencies - self._cmake.definitions["EIGENSPARSE"] = self.options.use_eigen_sparse - self._cmake.definitions["SUITESPARSE"] = False #Optional. Not supported right now because SuiteSparse is not part of conan-index - self._cmake.definitions["LAPACK"] = False #Optional. Not supported right now because LAPACK is not part of conan-index - self._cmake.definitions["CXSPARSE"] = False #Optional. Not supported right now because CXSSPARSE is not part of conan-index - self._cmake.definitions["MINIGLOG"] = not self.options.use_glog + cmake = CMake(self) #You can check what these flags do in http://ceres-solver.org/installation.html + cmake.definitions["LIB_SUFFIX"] = "" + cmake.definitions["GFLAGS"] = self.options.use_gflags + cmake.definitions["BUILD_EXAMPLES"] = False #Requires gflags + cmake.definitions["BUILD_TESTING"] = False #Requires gflags + cmake.definitions["BUILD_DOCUMENTATION"] = False #Requires python modules Sphinx and sphinx-rtd-theme + cmake.definitions["CUSTOM_BLAS"] = self.options.use_custom_blas + cmake.definitions["GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION"] = False #Set to false to Force CMake to use the conan-generated dependencies + cmake.definitions["EIGENSPARSE"] = self.options.use_eigen_sparse + cmake.definitions["SUITESPARSE"] = False #Optional. Not supported right now because SuiteSparse is not part of conan-index + cmake.definitions["LAPACK"] = False #Optional. Not supported right now because LAPACK is not part of conan-index + cmake.definitions["CXSPARSE"] = False #Optional. Not supported right now because CXSSPARSE is not part of conan-index + cmake.definitions["MINIGLOG"] = not self.options.use_glog if not self.options.use_TBB: - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_TBB"] = True + cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_TBB"] = True if tools.Version(self.version) < "2.0": - self._cmake.definitions["TBB"] = self.options.use_TBB - self._cmake.definitions["OPENMP"] = False - self._cmake.definitions["EIGEN_PREFER_EXPORTED_EIGEN_CMAKE_CONFIGURATION"] = False #Set to false to Force CMake to use the conan-generated dependencies - self._cmake.definitions["GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION"] = False #Set to false to Force CMake to use the conan-generated dependencies - self._cmake.definitions["CXX11_THREADS"] = self.options.use_CXX11_threads - self._cmake.definitions["CXX11"] = self.options.use_CXX11 - self._cmake.definitions["SCHUR_SPECIALIZATIONS"] = self.options.use_schur_specializations - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["MSVC_USE_STATIC_CRT"] = str(self.settings.compiler.runtime) == "MT" or str(self.settings.compiler.runtime) == "MTd" - self._cmake.configure() - return self._cmake + cmake.definitions["TBB"] = self.options.use_TBB + cmake.definitions["OPENMP"] = False + cmake.definitions["EIGEN_PREFER_EXPORTED_EIGEN_CMAKE_CONFIGURATION"] = False #Set to false to Force CMake to use the conan-generated dependencies + cmake.definitions["GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION"] = False #Set to false to Force CMake to use the conan-generated dependencies + cmake.definitions["CXX11_THREADS"] = self.options.use_CXX11_threads + cmake.definitions["CXX11"] = self.options.use_CXX11 + cmake.definitions["SCHUR_SPECIALIZATIONS"] = self.options.use_schur_specializations + if self._is_msvc: + cmake.definitions["MSVC_USE_STATIC_CRT"] = "MT" in msvc_runtime_flag(self) + cmake.configure() + return cmake def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): @@ -133,16 +155,18 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "CMake")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Ceres") + self.cpp_info.set_property("cmake_target_name", "Ceres::ceres") + libsuffix = "" if self.settings.build_type == "Debug": libsuffix = "-debug" - self.cpp_info.names["cmake_find_package"] = "Ceres" - self.cpp_info.names["cmake_find_package_multi"] = "Ceres" + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed self.cpp_info.components["ceres"].libs = ["ceres{}".format(libsuffix)] self.cpp_info.components["ceres"].includedirs = ["include", os.path.join("include","ceres")] if not self.options.use_glog: self.cpp_info.components["ceres"].includedirs.append(os.path.join("include","ceres", "internal", "miniglog")) - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: if self.options.get_safe("use_CXX11_threads", True): self.cpp_info.components["ceres"].system_libs.append("pthread") elif tools.is_apple_os(self.settings.os): @@ -154,7 +178,11 @@ def package_info(self): if self.options.use_gflags: self.cpp_info.components["ceres"].requires.append("gflags::gflags") if self.options.use_TBB: - self.cpp_info.components["ceres"].requires.append("tbb::tbb") + self.cpp_info.components["ceres"].requires.append("onetbb::onetbb") libcxx = tools.stdcpp_library(self) if libcxx: self.cpp_info.components["ceres"].system_libs.append(libcxx) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "Ceres" + self.cpp_info.names["cmake_find_package_multi"] = "Ceres" diff --git a/recipes/ceres-solver/all/patches/2.0.0-0003-fix-mingw-build.patch b/recipes/ceres-solver/all/patches/2.0.0-0003-fix-mingw-build.patch new file mode 100644 index 0000000000000..fc971893376fa --- /dev/null +++ b/recipes/ceres-solver/all/patches/2.0.0-0003-fix-mingw-build.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3828e33..30ef8cb 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -512,6 +512,9 @@ if (MINGW) + "to a MinGW bug: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556") + string(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + update_cache_variable(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") ++ # Add the equivalent of /bigobj for MSVC for MinGW to fix 'too many sections' ++ # compile errors due to extensive use of templates. ++ add_compile_options(-Wa,-mbig-obj) + endif (MINGW) + + # After the tweaks for the compile settings, disable some warnings on MSVC. + diff --git a/recipes/ceres-solver/all/patches/2.0.1-0001-find-glog-conan.patch b/recipes/ceres-solver/all/patches/2.0.1-0001-find-glog-conan.patch new file mode 100644 index 0000000000000..e8474163f4157 --- /dev/null +++ b/recipes/ceres-solver/all/patches/2.0.1-0001-find-glog-conan.patch @@ -0,0 +1,40 @@ +diff --git a/cmake/FindGlog.cmake b/cmake/FindGlog.cmake +index 1a7b6c09..d4bd7f08 100644 +--- a/cmake/FindGlog.cmake ++++ b/cmake/FindGlog.cmake +@@ -261,12 +261,12 @@ if (NOT GLOG_FOUND) + + # Search user-installed locations first, so that we prefer user installs + # to system installs where both exist. +- list(APPEND GLOG_CHECK_INCLUDE_DIRS +- /usr/local/include +- /usr/local/homebrew/include # Mac OS X +- /opt/local/var/macports/software # Mac OS X. +- /opt/local/include +- /usr/include) ++ list(APPEND GLOG_CHECK_INCLUDE_DIRS ${CMAKE_INCLUDE_PATH}) ++ #/usr/local/include ++ #/usr/local/homebrew/include # Mac OS X ++ #/opt/local/var/macports/software # Mac OS X. ++ #/opt/local/include ++ #/usr/include) + # Windows (for C:/Program Files prefix). + list(APPEND GLOG_CHECK_PATH_SUFFIXES + glog/include +@@ -276,11 +276,11 @@ if (NOT GLOG_FOUND) + google-glog/include # CMake installs with project name prefix. + google-glog/Include) + +- list(APPEND GLOG_CHECK_LIBRARY_DIRS +- /usr/local/lib +- /usr/local/homebrew/lib # Mac OS X. +- /opt/local/lib +- /usr/lib) ++ list(APPEND GLOG_CHECK_LIBRARY_DIRS ${CMAKE_LIB_PATH}) ++ #/usr/local/lib ++ #/usr/local/homebrew/lib # Mac OS X. ++ #/opt/local/lib ++ #/usr/lib) + # Windows (for C:/Program Files prefix). + list(APPEND GLOG_CHECK_LIBRARY_SUFFIXES + glog/lib diff --git a/recipes/ceres-solver/all/patches/2.0.1-0002-find-glags-conan.patch b/recipes/ceres-solver/all/patches/2.0.1-0002-find-glags-conan.patch new file mode 100644 index 0000000000000..ed1fe61607668 --- /dev/null +++ b/recipes/ceres-solver/all/patches/2.0.1-0002-find-glags-conan.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7f88fb48..058f4cd9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -367,7 +367,7 @@ endif() + # GFlags. + if (GFLAGS) + # Don't search with REQUIRED as we can continue without gflags. +- find_package(gflags 2.2.0) ++ find_package(gflags 2.2.0 REQUIRED) + if (gflags_FOUND) + if (TARGET gflags) + message("-- Found Google Flags (gflags) version ${gflags_VERSION}: ${gflags_DIR}") diff --git a/recipes/ceres-solver/all/patches/2.0.1-0003-fix-mingw-build.patch b/recipes/ceres-solver/all/patches/2.0.1-0003-fix-mingw-build.patch new file mode 100644 index 0000000000000..77df4bf8d3750 --- /dev/null +++ b/recipes/ceres-solver/all/patches/2.0.1-0003-fix-mingw-build.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 058f4cd9..58b5ed01 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -486,6 +486,9 @@ if (MINGW) + "to a MinGW bug: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556") + string(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + update_cache_variable(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") ++ # Add the equivalent of /bigobj for MSVC for MinGW to fix 'too many sections' ++ # compile errors due to extensive use of templates. ++ add_compile_options(-Wa,-mbig-obj) + endif (MINGW) + + # After the tweaks for the compile settings, disable some warnings on MSVC. diff --git a/recipes/ceres-solver/all/test_package/CMakeLists.txt b/recipes/ceres-solver/all/test_package/CMakeLists.txt index 8e78ee369c8b9..de5b6209a38b8 100644 --- a/recipes/ceres-solver/all/test_package/CMakeLists.txt +++ b/recipes/ceres-solver/all/test_package/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) diff --git a/recipes/ceres-solver/all/test_package/conanfile.py b/recipes/ceres-solver/all/test_package/conanfile.py index 910ae60d10438..38f4483872d47 100644 --- a/recipes/ceres-solver/all/test_package/conanfile.py +++ b/recipes/ceres-solver/all/test_package/conanfile.py @@ -1,8 +1,9 @@ -import os from conans import ConanFile, CMake, tools +import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -11,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/ceres-solver/config.yml b/recipes/ceres-solver/config.yml index 4b6b45bc2cf8f..a3c4c3f90c1ea 100644 --- a/recipes/ceres-solver/config.yml +++ b/recipes/ceres-solver/config.yml @@ -1,4 +1,6 @@ versions: + "2.1.0": + folder: all "2.0.0": folder: all "1.14.0": diff --git a/recipes/cern-root/all/conandata.yml b/recipes/cern-root/all/conandata.yml index 15690be6b429a..ea1780c15b67b 100644 --- a/recipes/cern-root/all/conandata.yml +++ b/recipes/cern-root/all/conandata.yml @@ -2,3 +2,9 @@ sources: "v6-22-06": url: "https://github.com/root-project/root/archive/v6-22-06.zip" sha256: "125e056f315fb280b13e154d4b73d3b302ac1f5775062e89681edb86c1447a62" +patches: + "v6-22-06": + - patch_file: "patches/0001-add-missing-includes.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-cmake-missing-link-libraries.patch" + base_path: "source_subfolder" diff --git a/recipes/cern-root/all/conanfile.py b/recipes/cern-root/all/conanfile.py index 1ff02d22b1713..be3871ebefe4c 100644 --- a/recipes/cern-root/all/conanfile.py +++ b/recipes/cern-root/all/conanfile.py @@ -1,10 +1,10 @@ +from conans import CMake, ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import glob import os import shutil import stat -from glob import glob - -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +import textwrap class PythonOption: @@ -16,7 +16,7 @@ class PythonOption: ALL = [OFF, SYSTEM] -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.33.0" class CernRootConan(ConanFile): @@ -45,27 +45,9 @@ class CernRootConan(ConanFile): # default python=off as there is currently no libpython in Conan center "python": PythonOption.OFF, } - generators = ("cmake", "cmake_find_package") - requires = ( - "opengl/system", - "libxml2/2.9.10", - "glu/system", - "xorg/system", - "sqlite3/3.34.0", - "libjpeg/9d", - "libpng/1.6.37", - "libcurl/7.74.0", - "pcre/8.44", - "xz_utils/5.2.5", - "zstd/1.4.8", - "lz4/1.9.3", - "glew/2.1.0", - "openssl/1.1.1i", - "fftw/3.3.8", - "cfitsio/3.490", - "tbb/2020.3", - "libpng/1.6.37", - ) + + exports_sources = "patches/*" + generators = "cmake", "cmake_find_package" _cmake = None @@ -90,7 +72,32 @@ def _minimum_compilers_version(self): "apple-clang": "5.1", } - def configure(self): + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def requirements(self): + self.requires("cfitsio/4.0.0") + self.requires("fftw/3.3.9") + self.requires("giflib/5.2.1") + self.requires("glew/2.2.0") + self.requires("glu/system") + self.requires("libcurl/7.78.0") + self.requires("libjpeg/9d") + self.requires("libpng/1.6.37") + self.requires("libxml2/2.9.12") + self.requires("lz4/1.9.3") + self.requires("opengl/system") + self.requires("openssl/1.1.1l") + self.requires("pcre/8.44") + self.requires("sqlite3/3.36.0") + self.requires("tbb/2020.3") + self.requires("xorg/system") + self.requires("xxhash/0.8.0") + self.requires("xz_utils/5.2.5") + self.requires("zstd/1.5.0") + + def validate(self): self._enforce_minimum_compiler_version() self._enforce_libcxx_requirements() @@ -119,32 +126,19 @@ def _enforce_libcxx_requirements(self): compiler = self.settings.compiler libcxx = compiler.get_safe("libcxx") # ROOT doesn't currently build with libc++. - # This restriction may be lifted in future if the problems are fixed upstream + # This restriction may be lifted in future if the problems are fixed upstream if libcxx and libcxx == "libc++": raise ConanInvalidConfiguration( '{} is incompatible with libc++".'.format(self.name) ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename( - "root-{}".format(self.version.replace("v", "")), - self._source_subfolder, - ) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _patch_source_cmake(self): try: - os.remove( - os.sep.join( - ( - self.source_folder, - self._source_subfolder, - "cmake", - "modules", - "FindTBB.cmake", - ) - ) - ) + os.remove(os.path.join(self._source_subfolder, "cmake", "modules", "FindTBB.cmake")) except OSError: pass # Conan generated cmake_find_packages names differ from @@ -155,115 +149,115 @@ def _patch_source_cmake(self): tools.replace_in_file( os.path.join(self.source_folder, self._source_subfolder, "CMakeLists.txt"), "project(ROOT)", - "\n".join( - ( - "project(ROOT)", - "# sets the current C runtime on MSVC (MT vs MD vd MTd vs MDd)", - "include({}/conanbuildinfo.cmake)".format( - self.install_folder.replace("\\", "/") - ), - "conan_basic_setup(NO_OUTPUT_DIRS)", - "find_package(OpenSSL REQUIRED)", - "set(OPENSSL_VERSION ${OpenSSL_VERSION})", - "find_package(LibXml2 REQUIRED)", - "set(LIBXML2_INCLUDE_DIR ${LibXml2_INCLUDE_DIR})", - "set(LIBXML2_LIBRARIES ${LibXml2_LIBRARIES})", - "find_package(SQLite3 REQUIRED)", - "set(SQLITE_INCLUDE_DIR ${SQLITE3_INCLUDE_DIRS})", - "set(SQLITE_LIBRARIES SQLite::SQLite3)", - ) - ), + textwrap.dedent("""\ + project(ROOT) + # sets the current C runtime on MSVC (MT vs MD vd MTd vs MDd) + include("{install_folder}/conanbuildinfo.cmake") + conan_basic_setup(NO_OUTPUT_DIRS) + find_package(OpenSSL REQUIRED) + set(OPENSSL_VERSION ${{OpenSSL_VERSION}}) + find_package(LibXml2 REQUIRED) + set(LIBXML2_INCLUDE_DIR ${{LibXml2_INCLUDE_DIR}}) + set(LIBXML2_LIBRARIES ${{LibXml2_LIBRARIES}}) + find_package(SQLite3 REQUIRED) + set(SQLITE_INCLUDE_DIR ${{SQLITE3_INCLUDE_DIRS}}) + set(SQLITE_LIBRARIES SQLite::SQLite3) + """).format(install_folder=self.install_folder.replace("\\", "/")) ) + tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "CMakeLists.txt"), + "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)", + "list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)") def _fix_source_permissions(self): # Fix execute permissions on scripts scripts = [ filename for pattern in ( - "**" + os.sep + "configure", - "**" + os.sep + "*.sh", - "**" + os.sep + "*.csh", - "**" + os.sep + "*.bat", + os.path.join("**", "configure"), + os.path.join("**", "*.sh"), + os.path.join("**", "*.csh"), + os.path.join("**", "*.bat"), ) - for filename in glob(self.source_folder + os.sep + pattern, recursive=True) + for filename in glob.glob(os.path.join(self.source_folder, pattern), recursive=True) ] for s in scripts: self._make_file_executable(s) - def _make_file_executable(self, filename): + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + self._patch_source_cmake() + self._fix_source_permissions() + + @staticmethod + def _make_file_executable(filename): st = os.stat(filename) os.chmod(filename, st.st_mode | stat.S_IEXEC) - @property - def _configured_cmake(self): - if self._cmake is None: - self._move_findcmake_conan_to_root_dir() - self._cmake = CMake(self) - cmakelibpath = ";".join(self.deps_cpp_info.lib_paths) - cmakeincludepath = ";".join(self.deps_cpp_info.include_paths) - self._cmake.configure( - source_folder=self._source_subfolder, - build_folder=self._build_subfolder, - defs={ - # TODO: Remove BUILD_SHARED_LIBS option when hooks issue is resolved - # (see: https://github.com/conan-io/hooks/issues/252) - "BUILD_SHARED_LIBS": "ON", - "fail-on-missing": "ON", - "CMAKE_CXX_STANDARD": self._cmake_cxx_standard, - "gnuinstall": "OFF", - "soversion": "ON", - # Disable builtins and use Conan deps where available - "builtin_pcre": "OFF", - "builtin_lzma": "OFF", - "builtin_zstd": "OFF", - "builtin_lz4": "OFF", - "builtin_glew": "OFF", - "builtin_openssl": "OFF", - "builtin_fftw3": "OFF", - "builtin_cfitsio": "OFF", - "builtin_davix": "OFF", - "builtin_tbb": "OFF", - # Enable builtins where there is no Conan package - "builtin_xxhash": "ON", # FIXME : replace with xxhash CCI package when available - "builtin_afterimage": "ON", # FIXME : replace with afterimage CCI package when available - "builtin_gsl": "ON", # FIXME : replace with gsl CCI package when available - "builtin_gl2ps": "ON", # FIXME : replace with gl2ps CCI package when available - "builtin_ftgl": "ON", # FIXME : replace with ftgl CCI package when available - "builtin_vdt": "ON", # FIXME : replace with vdt CCI package when available - # No Conan packages available for these dependencies yet - "davix": "OFF", # FIXME : switch on if davix CCI package available - "pythia6": "OFF", # FIXME : switch on if pythia6 CCI package available - "pythia8": "OFF", # FIXME : switch on if pythia8 CCI package available - "mysql": "OFF", # FIXME : switch on if mysql CCI package available - "oracle": "OFF", - "pgsql": "OFF", # FIXME: switch on if PostgreSQL CCI package available - "gfal": "OFF", # FIXME: switch on if gfal CCI package available - "tmva-pymva": "OFF", # FIXME: switch on if Python CCI package available - "xrootd": "OFF", # FIXME: switch on if xrootd CCI package available - "pyroot": self._pyrootopt, - # clad is built with ExternalProject_Add and its - # COMPILE_DEFINITIONS property is not propagated causing the build to - # fail on some systems if libcxx != libstdc++11 - "clad": "OFF", - # Tell CMake where to look for Conan provided depedencies - "CMAKE_LIBRARY_PATH": cmakelibpath.replace("\\", "/"), - "CMAKE_INCLUDE_PATH": cmakeincludepath.replace("\\", "/"), - # Configure install directories - # Conan CCI hooks restrict the allowed install directory - # names but ROOT is very picky about where build/runtime - # resources get installed. - # Set install prefix to work around these limitations - # Following: https://github.com/conan-io/conan/issues/3695 - "CMAKE_INSTALL_PREFIX": os.sep.join((self.package_folder, "res")), - # Fix some Conan-ROOT CMake variable naming differences - "PNG_PNG_INCLUDE_DIR": ";".join( - self.deps_cpp_info["libpng"].include_paths - ).replace("\\", "/"), - "LIBLZMA_INCLUDE_DIR": ";".join( - self.deps_cpp_info["xz_utils"].include_paths - ).replace("\\", "/"), - }, - ) + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + cmakelibpath = ";".join(self.deps_cpp_info.lib_paths) + cmakeincludepath = ";".join(self.deps_cpp_info.include_paths) + self._cmake.definitions.update({ + "BUILD_SHARED_LIBS": True, + "fail-on-missing": True, + "CMAKE_CXX_STANDARD": self._cmake_cxx_standard, + "gnuinstall": True, + "soversion": True, + # Disable builtins and use Conan deps where available + "builtin_cfitsio": False, + "builtin_davix": False, + "builtin_fftw3": False, + "builtin_freetype": False, + "builtin_glew": False, + "builtin_lz4": False, + "builtin_lzma": False, + "builtin_openssl": False, + "builtin_pcre": False, + "builtin_tbb": False, + "builtin_xxhash": False, + "builtin_zlib": False, + "builtin_zstd": False, + # Enable builtins where there is no Conan package + "builtin_afterimage": True, # FIXME : replace with afterimage CCI package when available + "builtin_gsl": True, # FIXME : replace with gsl CCI package when available + "builtin_gl2ps": True, # FIXME : replace with gl2ps CCI package when available + "builtin_ftgl": True, # FIXME : replace with ftgl CCI package when available + "builtin_vdt": True, # FIXME : replace with vdt CCI package when available + # No Conan packages available for these dependencies yet + "davix": False, # FIXME : switch on if davix CCI package available + "pythia6": False, # FIXME : switch on if pythia6 CCI package available + "pythia8": False, # FIXME : switch on if pythia8 CCI package available + "mysql": False, # FIXME : switch on if mysql CCI package available + "oracle": False, + "pgsql": False, # FIXME: switch on if PostgreSQL CCI package available + "gfal": False, # FIXME: switch on if gfal CCI package available + "tmva-pymva": False, # FIXME: switch on if Python CCI package available + "xrootd": False, # FIXME: switch on if xrootd CCI package available + "pyroot": self._cmake_pyrootopt, + # clad is built with ExternalProject_Add and its + # COMPILE_DEFINITIONS property is not propagated causing the build to + # fail on some systems if libcxx != libstdc++11 + "clad": False, + # Tell CMake where to look for Conan provided depedencies + "CMAKE_LIBRARY_PATH": cmakelibpath.replace("\\", "/"), + "CMAKE_INCLUDE_PATH": cmakeincludepath.replace("\\", "/"), + # Configure install directories + # Conan CCI hooks restrict the allowed install directory + # names but ROOT is very picky about where build/runtime + # resources get installed. + # Set install prefix to work around these limitations + # Following: https://github.com/conan-io/conan/issues/3695 + "CMAKE_INSTALL_CMAKEDIR": "lib/cmake", + "CMAKE_INSTALL_DATAROOTDIR": "res/share", + "CMAKE_INSTALL_SYSCONFDIR": "res/etc", + # Fix some Conan-ROOT CMake variable naming differences + "PNG_PNG_INCLUDE_DIR": ";".join(self.deps_cpp_info["libpng"].include_paths).replace("\\", "/"), + "LIBLZMA_INCLUDE_DIR": ";".join(self.deps_cpp_info["xz_utils"].include_paths).replace("\\", "/"), + }) + self._cmake.configure(source_folder=self._source_subfolder, build_folder=self._build_subfolder) return self._cmake def _move_findcmake_conan_to_root_dir(self): @@ -280,38 +274,32 @@ def _cmake_cxx_standard(self): return str(self.settings.compiler.get_safe("cppstd", "11")) @property - def _pyrootopt(self): + def _cmake_pyrootopt(self): if self.options.python == PythonOption.OFF: - return "OFF" + return False else: - return "ON" + return True def build(self): - self._fix_source_permissions() - self._patch_source_cmake() - self._configured_cmake.build() + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() def package(self): - self._configured_cmake.install() - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - for dir in ["include", "lib", "bin"]: - os.symlink( - os.sep.join((self.package_folder, "res", dir)), - os.sep.join((self.package_folder, dir)), - ) + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + cmake = self._configure_cmake() + cmake.install() # Fix for CMAKE-MODULES-CONFIG-FILES (KB-H016) - tools.remove_files_by_mask(self.package_folder, "*Config*.cmake") - # Fix for CMAKE FILE NOT IN BUILD FOLDERS (KB-H019) - os.remove( - os.sep.join((self.package_folder, "res", "tutorials", "CTestCustom.cmake")) - ) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib", "cmake"), "*Config*.cmake") + tools.rmdir(os.path.join(self.package_folder, "res", "README")) + tools.rmdir(os.path.join(self.package_folder, "res", "share", "man")) + tools.rmdir(os.path.join(self.package_folder, "res", "share", "doc")) + tools.rmdir(os.path.join(self.package_folder, "res", "tutorials")) def package_info(self): # FIXME: ROOT generates multiple CMake files self.cpp_info.names["cmake_find_package"] = "ROOT" self.cpp_info.names["cmake_find_package_multi"] = "ROOT" - self.cpp_info.names["cmake_find_package"] = "ROOT" - self.cpp_info.names["cmake_find_package_multi"] = "ROOT" # See root-config --libs for a list of ordered libs self.cpp_info.libs = [ "Core", @@ -323,7 +311,7 @@ def package_info(self): "Graf3d", "Gpad", "ROOTVecOps", - "Tree ", + "Tree", "TreePlayer", "Rint", "Postscript", @@ -334,11 +322,11 @@ def package_info(self): "MultiProc", "ROOTDataFrame", ] - self.cpp_info.builddirs = [os.path.join("res", "cmake")] + self.cpp_info.builddirs = [os.path.join("lib", "cmake")] self.cpp_info.build_modules.extend( [ - os.path.join("res", "cmake", "RootMacros.cmake"), - # os.path.join("res", "cmake", "ROOTUseFile.cmake"), + os.path.join("lib", "cmake", "RootMacros.cmake"), + # os.path.join("lib", "cmake", "ROOTUseFile.cmake"), ] ) self.cpp_info.resdirs = ["res"] diff --git a/recipes/cern-root/all/patches/0001-add-missing-includes.patch b/recipes/cern-root/all/patches/0001-add-missing-includes.patch new file mode 100644 index 0000000000000..ce959e107ffeb --- /dev/null +++ b/recipes/cern-root/all/patches/0001-add-missing-includes.patch @@ -0,0 +1,11 @@ +--- core/foundation/inc/ROOT/libcpp_string_view.h ++++ core/foundation/inc/ROOT/libcpp_string_view.h +@@ -10,7 +10,7 @@ + + #ifndef _LIBCPP_LFTS_STRING_VIEW + #define _LIBCPP_LFTS_STRING_VIEW +- ++#include + #ifndef RWrap_libcpp_string_view_h + #error "Do not use libcpp_string_view.h directly. #include \"RWrap_libcpp_string_view.h\" instead." + #endif // RWrap_libcpp_string_view_h diff --git a/recipes/cern-root/all/patches/0002-cmake-missing-link-libraries.patch b/recipes/cern-root/all/patches/0002-cmake-missing-link-libraries.patch new file mode 100644 index 0000000000000..a979ced9370fa --- /dev/null +++ b/recipes/cern-root/all/patches/0002-cmake-missing-link-libraries.patch @@ -0,0 +1,9 @@ +--- interpreter/llvm/src/lib/Support/CMakeLists.txt ++++ interpreter/llvm/src/lib/Support/CMakeLists.txt +@@ -148,5 +148,5 @@ + ${Backtrace_INCLUDE_DIRS} + LINK_LIBS ${system_libs} + ) +- ++target_link_libraries(LLVMSupport PRIVATE ZLIB::ZLIB) + set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${system_libs}") diff --git a/recipes/cern-root/all/test_package/CMakeLists.txt b/recipes/cern-root/all/test_package/CMakeLists.txt index bdd0937578a5e..d6093677e3757 100644 --- a/recipes/cern-root/all/test_package/CMakeLists.txt +++ b/recipes/cern-root/all/test_package/CMakeLists.txt @@ -1,16 +1,19 @@ cmake_minimum_required(VERSION 3.13) -project(PackageTest CXX) +project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(NO_OUTPUT_DIRS) +conan_basic_setup(TARGETS NO_OUTPUT_DIRS) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY bin) find_package(ROOT REQUIRED) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -ROOT_GENERATE_DICTIONARY(G__Event Event.hpp OPTIONS -inlineInputHeader LINKDEF EventLinkDef.h ) +root_generate_dictionary(G__Event Event.hpp OPTIONS -inlineInputHeader LINKDEF EventLinkDef.h ) add_library(Event SHARED Event.cpp G__Event.cxx) -target_link_libraries(Event ROOT::ROOT) +target_link_libraries(Event PRIVATE ROOT::ROOT) add_executable(testrootdictionaries testrootdictionaries.cpp) -target_link_libraries(testrootdictionaries Event ROOT::ROOT) +target_link_libraries(testrootdictionaries PRIVATE Event ROOT::ROOT) diff --git a/recipes/cern-root/all/test_package/conanfile.py b/recipes/cern-root/all/test_package/conanfile.py index d601a87511d2c..9fcab707edbee 100644 --- a/recipes/cern-root/all/test_package/conanfile.py +++ b/recipes/cern-root/all/test_package/conanfile.py @@ -1,11 +1,10 @@ -import os - from conans import CMake, ConanFile, RunEnvironment, tools +import os -class CernRootTestConan(ConanFile): +class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = ("cmake", "cmake_find_package") + generators = "cmake", "cmake_find_package" def configure(self): if self.settings.compiler.get_safe("cppstd"): @@ -43,4 +42,5 @@ def _check_binaries_are_found(self): self.run("root -q", run_environment=True) def _check_root_dictionaries(self): - self.run(".{}testrootdictionaries".format(os.sep), run_environment=True) + bin_path = os.path.join("bin", "testrootdictionaries") + self.run(bin_path, run_environment=True) diff --git a/recipes/certify/all/conandata.yml b/recipes/certify/all/conandata.yml new file mode 100644 index 0000000000000..6772243589218 --- /dev/null +++ b/recipes/certify/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20201114": + url: "https://github.com/djarek/certify/archive/a1bd27f2e86ba73d6a64f289f030ec65250edceb.zip" + sha256: f9606583c29bea5537427e5c37a8c67874e64bea7e49b30c03b80b0ac60f66e4 diff --git a/recipes/certify/all/conanfile.py b/recipes/certify/all/conanfile.py new file mode 100644 index 0000000000000..86be0e74f0cf1 --- /dev/null +++ b/recipes/certify/all/conanfile.py @@ -0,0 +1,76 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.43.0" + + +class CertifyConan(ConanFile): + name = "certify" + description = "Platform-specific TLS keystore abstraction for use with Boost.ASIO and OpenSSL" + topics = ("boost", "asio", "tls", "ssl", "https") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/djarek/certify" + license = "BSL-1.0" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "9", + "Visual Studio": "15.7", + "clang": "7", + "apple-clang": "11", + } + + @property + def _min_cppstd(self): + return "17" + + def requirements(self): + self.requires("boost/1.79.0") + self.requires("openssl/1.1.1q") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._min_cppstd) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if not minimum_version: + self.output.warn("{} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name)) + elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration("{} requires C++17, which your compiler does not support.".format(self.name)) + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + def package(self): + self.copy(pattern="LICENSE_1_0.txt", dst="licenses", + src=self._source_subfolder) + self.copy(pattern="*", dst="include", + src=os.path.join(self._source_subfolder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "certify") + self.cpp_info.set_property("cmake_target_name", "certify::core") + self.cpp_info.components["_certify"].requires = ["boost::boost", "openssl::openssl"] + + self.cpp_info.components["_certify"].names["cmake_find_package"] = "core" + self.cpp_info.components["_certify"].names["cmake_find_package_multi"] = "core" + self.cpp_info.names["cmake_find_package"] = "certify" + self.cpp_info.names["cmake_find_package_multi"] = "certify" diff --git a/recipes/certify/all/test_package/CMakeLists.txt b/recipes/certify/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..37373018e655a --- /dev/null +++ b/recipes/certify/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(certify REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE certify::core) +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) diff --git a/recipes/certify/all/test_package/conanfile.py b/recipes/certify/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/certify/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/certify/all/test_package/test_package.cpp b/recipes/certify/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..28f4c97339bb8 --- /dev/null +++ b/recipes/certify/all/test_package/test_package.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +#include + +#include + +int main() { + boost::asio::io_context ioc{1}; + boost::asio::ssl::context context{boost::asio::ssl::context_base::method::tls_client}; + boost::asio::ssl::stream stream(ioc, context); + constexpr auto hostname = "example.com"; + + BOOST_TEST(boost::certify::sni_hostname(stream).empty()); + boost::certify::sni_hostname(stream, hostname); + BOOST_TEST(boost::certify::sni_hostname(stream) == hostname); + std::cout << boost::report_errors(); + + return 0; +} diff --git a/recipes/certify/config.yml b/recipes/certify/config.yml new file mode 100644 index 0000000000000..220885d7229f9 --- /dev/null +++ b/recipes/certify/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20201114": + folder: "all" diff --git a/recipes/cfgfile/0.2.8.2.1/conandata.yml b/recipes/cfgfile/0.2.8.2.1/conandata.yml deleted file mode 100644 index 8600f8c1d981b..0000000000000 --- a/recipes/cfgfile/0.2.8.2.1/conandata.yml +++ /dev/null @@ -1,4 +0,0 @@ -sources: - "0.2.8.2.1": - url: "https://github.com/igormironchik/cfgfile/releases/download/0.2.8.2.1/cfgfile-0.2.8.2.1-full.tar.gz" - sha256: "6b0fe28323904ceb4567c5f3d450ab6eec6cca5eebad7ad0b77b1967f9e2772d" diff --git a/recipes/cfgfile/0.2.8.2.1/conanfile.py b/recipes/cfgfile/0.2.8.2.1/conanfile.py deleted file mode 100644 index 9f814c8e7f167..0000000000000 --- a/recipes/cfgfile/0.2.8.2.1/conanfile.py +++ /dev/null @@ -1,77 +0,0 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -import os - - -class CfgfileConan(ConanFile): - name = "cfgfile" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/igormironchik/cfgfile.git" - license = "MIT" - description = "Header-only library for reading/saving configuration files with schema defined in sources." - exports_sources = "CMakeLists.txt" - generators = "cmake" - topics = ("conan", "cfgfile", "configuration") - settings = "os", "arch", "compiler", "build_type" - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - - @property - def _compilers_minimum_version(self): - return { - "Visual Studio": "15", - "gcc": "5", - "clang": "3.5", - "apple-clang": "10" - } - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "14") - - compiler = str(self.settings.compiler) - if compiler not in self._compilers_minimum_version: - self.output.warn("Unknown compiler, assuming it supports at least C++14") - return - - version = tools.Version(self.settings.compiler.version) - if version < self._compilers_minimum_version[compiler]: - raise ConanInvalidConfiguration("cfgfile requires a compiler that supports at least C++14") - - def build(self): - cmake = self._configure_cmake() - cmake.build() - - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) - - def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - self.copy("*.hpp", src=os.path.join(self._source_subfolder, "cfgfile"), dst=os.path.join("include", "cfgfile")) - cmake = self._configure_cmake() - cmake.install() - - def package_info(self): - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH env var with : {}".format(bin_path)) - self.env_info.PATH.append(bin_path) - - def package_id(self): - del self.info.settings.compiler diff --git a/recipes/cfgfile/0.2.8.2.1/test_package/CMakeLists.txt b/recipes/cfgfile/0.2.8.2.1/test_package/CMakeLists.txt deleted file mode 100644 index bffd2deb35594..0000000000000 --- a/recipes/cfgfile/0.2.8.2.1/test_package/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -cmake_minimum_required(VERSION 3.1) - -set( CMAKE_CXX_STANDARD 14 ) - -set( CMAKE_CXX_STANDARD_REQUIRED ON ) - -project(cfgfile.test) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -include_directories(${CMAKE_CURRENT_BINARY_DIR} - ${CONAN_INCLUDE_DIRS_CFGFILE}/include) - -add_custom_target(gencfg - COMMAND ${CONAN_BIN_DIRS_CFGFILE}/cfgfile.generator${CMAKE_EXECUTABLE_SUFFIX} -i ${CMAKE_CURRENT_SOURCE_DIR}/session_cfg.conf -o ${CMAKE_CURRENT_BINARY_DIR}/cfg.hpp - ) - -add_executable(${PROJECT_NAME} example.cpp) - -add_dependencies(${PROJECT_NAME} gencfg) - -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/cfgfile/0.2.8.2.1/test_package/conanfile.py b/recipes/cfgfile/0.2.8.2.1/test_package/conanfile.py deleted file mode 100644 index 4059c036e83f0..0000000000000 --- a/recipes/cfgfile/0.2.8.2.1/test_package/conanfile.py +++ /dev/null @@ -1,15 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - -class CfgfileTestConan(ConanFile): - generators = "cmake" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "cfgfile.test") - self.run(bin_path, run_environment=True) diff --git a/recipes/cfgfile/0.2.8.2.1/test_package/example.cpp b/recipes/cfgfile/0.2.8.2.1/test_package/example.cpp deleted file mode 100644 index 75b436063c48e..0000000000000 --- a/recipes/cfgfile/0.2.8.2.1/test_package/example.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - -#include - -int main() -{ - Cfg::Session cfg; - - std::ifstream stream( "../../test.cfg" ); - - try { - Cfg::tag_Session< cfgfile::string_trait_t > s; - - cfgfile::read_cfgfile( s, stream, "test.cfg" ); - - stream.close(); - - cfg = s.get_cfg(); - } - catch( const cfgfile::exception_t<> & x ) - { - stream.close(); - - std::cout << x.desc() << std::endl; - - return 1; - } - - if( cfg.project() == "123" ) - return 0; - else - return 1; -} diff --git a/recipes/cfgfile/0.2.9.0/CMakeLists.txt b/recipes/cfgfile/0.2.9.0/CMakeLists.txt deleted file mode 100644 index 64b7fce508eb0..0000000000000 --- a/recipes/cfgfile/0.2.9.0/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -project(cmake_wrapper) - -set(CMAKE_CXX_STANDARD 14) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/cfgfile/0.2.9.0/conandata.yml b/recipes/cfgfile/0.2.9.0/conandata.yml deleted file mode 100644 index e8386eb178e1f..0000000000000 --- a/recipes/cfgfile/0.2.9.0/conandata.yml +++ /dev/null @@ -1,4 +0,0 @@ -sources: - "0.2.9.0": - url: "https://github.com/igormironchik/cfgfile/archive/refs/tags/0.2.9.0.tar.gz" - sha256: "4f42899849e87779089aab1db519ad7977c65cc40315c15515d7e29b0a3088c8" diff --git a/recipes/cfgfile/0.2.9.0/conanfile.py b/recipes/cfgfile/0.2.9.0/conanfile.py deleted file mode 100644 index eb20e0f629748..0000000000000 --- a/recipes/cfgfile/0.2.9.0/conanfile.py +++ /dev/null @@ -1,113 +0,0 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -import os -import textwrap - - -class CfgfileConan(ConanFile): - name = "cfgfile" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/igormironchik/cfgfile.git" - license = "MIT" - description = "Header-only library for reading/saving configuration files with schema defined in sources." - exports_sources = "CMakeLists.txt" - generators = "cmake", "cmake_find_package" - topics = ("conan", "cfgfile", "configuration") - settings = "os", "arch", "compiler", "build_type" - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - - @property - def _compilers_minimum_version(self): - return { - "Visual Studio": "15", - "gcc": "5", - "clang": "3.5", - "apple-clang": "10" - } - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") - - @property - def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) - - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): - content = "" - for alias, aliased in targets.items(): - content += textwrap.dedent("""\ - if(TARGET {aliased} AND NOT TARGET {alias}) - add_library({alias} INTERFACE IMPORTED) - set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) - endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["USE_INTERNAL_ARGS_PARSER"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "14") - - compiler = str(self.settings.compiler) - if compiler not in self._compilers_minimum_version: - self.output.warn("Unknown compiler, assuming it supports at least C++14") - return - - version = tools.Version(self.settings.compiler.version) - if version < self._compilers_minimum_version[compiler]: - raise ConanInvalidConfiguration("cfgfile requires a compiler that supports at least C++14") - - def requirements(self): - self.requires("args-parser/6.0.1.0") - - def build(self): - cmake = self._configure_cmake() - cmake.build() - - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) - - def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - self.copy("*.hpp", src=os.path.join(self._source_subfolder, "cfgfile"), dst=os.path.join("include", "cfgfile")) - cmake = self._configure_cmake() - cmake.install() - self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._module_file_rel_path), - {"cfgfile": "cfgfile::cfgfile"} - ) - - def package_info(self): - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH env var with : {}".format(bin_path)) - self.env_info.PATH.append(bin_path) - self.cpp_info.names["cmake_find_package"] = "cfgfile" - self.cpp_info.names["cmake_find_package_multi"] = "cfgfile" - self.cpp_info.builddirs.append(self._module_subfolder) - self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] - self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - self.cpp_info.includedirs.append(os.path.join("include", "cfgfile")) - - def package_id(self): - del self.info.settings.compiler diff --git a/recipes/cfgfile/0.2.9.0/test_package/CMakeLists.txt b/recipes/cfgfile/0.2.9.0/test_package/CMakeLists.txt deleted file mode 100644 index 844f2d4b27d2e..0000000000000 --- a/recipes/cfgfile/0.2.9.0/test_package/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.1) - -project(cfgfile.test) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - -conan_basic_setup(TARGETS) - -find_package(cfgfile REQUIRED) - -add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cfg.hpp" - COMMAND cfgfile.generator -i "${CMAKE_CURRENT_SOURCE_DIR}/session_cfg.conf" -o "${CMAKE_CURRENT_BINARY_DIR}/cfg.hpp" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/session_cfg.conf" -) - -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -add_executable(${PROJECT_NAME} - example.cpp - "${CMAKE_CURRENT_BINARY_DIR}/cfg.hpp" -) - -target_link_libraries(${PROJECT_NAME} cfgfile) - -set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 14 - CXX_STANDARD_REQUIRED ON -) diff --git a/recipes/cfgfile/0.2.9.0/test_package/conanfile.py b/recipes/cfgfile/0.2.9.0/test_package/conanfile.py deleted file mode 100644 index 6d799530904b8..0000000000000 --- a/recipes/cfgfile/0.2.9.0/test_package/conanfile.py +++ /dev/null @@ -1,17 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - -class CfgfileTestConan(ConanFile): - generators = "cmake", "cmake_find_package" - - def build(self): - if not tools.cross_building(self.settings, skip_x64_x86=True): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "cfgfile.test") - cfg_path = os.path.join(self.source_folder, "test.cfg"); - self.run("{} \"{}\"".format(bin_path, cfg_path), run_environment=True) diff --git a/recipes/cfgfile/0.2.9.0/test_package/session_cfg.conf b/recipes/cfgfile/0.2.9.0/test_package/session_cfg.conf deleted file mode 100644 index bb573d645884f..0000000000000 --- a/recipes/cfgfile/0.2.9.0/test_package/session_cfg.conf +++ /dev/null @@ -1,19 +0,0 @@ - -{forGeneration SESSION_CFG_HPP - - {namespace Cfg - - |# - Session. - #| - {class Session - {tagScalar - {valueType std::string} - {name project} - {required} - } - } - - } || namespace Cfg - -} diff --git a/recipes/cfgfile/0.2.9.0/test_package/test.cfg b/recipes/cfgfile/0.2.9.0/test_package/test.cfg deleted file mode 100644 index 695b398b2d314..0000000000000 --- a/recipes/cfgfile/0.2.9.0/test_package/test.cfg +++ /dev/null @@ -1,3 +0,0 @@ -{Session - {project 123} -} diff --git a/recipes/cfgfile/0.2.8.2.1/CMakeLists.txt b/recipes/cfgfile/all/CMakeLists.txt similarity index 100% rename from recipes/cfgfile/0.2.8.2.1/CMakeLists.txt rename to recipes/cfgfile/all/CMakeLists.txt diff --git a/recipes/cfgfile/all/conandata.yml b/recipes/cfgfile/all/conandata.yml new file mode 100644 index 0000000000000..2e90d0b7dcbd7 --- /dev/null +++ b/recipes/cfgfile/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "0.2.10": + url: "https://github.com/igormironchik/cfgfile/archive/refs/tags/0.2.10.tar.gz" + sha256: "bfab4deb8c9d71872a62a4f2a06056b56c93faf70b36ebb3bab5f207c8fe2c3f" + "0.2.9.1": + url: "https://github.com/igormironchik/cfgfile/archive/refs/tags/0.2.9.1.tar.gz" + sha256: "b5c8aa2ab148404325e817dc059dd6af81e96d7d831f137c93fe9dd79bbe3c7b" + "0.2.9.0": + url: "https://github.com/igormironchik/cfgfile/archive/refs/tags/0.2.9.0.tar.gz" + sha256: "4f42899849e87779089aab1db519ad7977c65cc40315c15515d7e29b0a3088c8" + "0.2.8.2.1": + url: "https://github.com/igormironchik/cfgfile/releases/download/0.2.8.2.1/cfgfile-0.2.8.2.1-full.tar.gz" + sha256: "6b0fe28323904ceb4567c5f3d450ab6eec6cca5eebad7ad0b77b1967f9e2772d" diff --git a/recipes/cfgfile/all/conanfile.py b/recipes/cfgfile/all/conanfile.py new file mode 100644 index 0000000000000..1e8c15c48583c --- /dev/null +++ b/recipes/cfgfile/all/conanfile.py @@ -0,0 +1,91 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os +import textwrap + + +class CfgfileConan(ConanFile): + name = "cfgfile" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/igormironchik/cfgfile.git" + license = "MIT" + description = "Header-only library for reading/saving configuration files with schema defined in sources." + exports_sources = "CMakeLists.txt" + generators = "cmake", "cmake_find_package" + topics = ("cfgfile", "configuration", "file") + settings = "os", "arch", "compiler", "build_type" + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "15", + "gcc": "5", + "clang": "3.5", + "apple-clang": "10" + } + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_EXAMPLES"] = False + self._cmake.definitions["BUILD_TESTS"] = False + if tools.Version(self.version) >= "0.2.9": + self._cmake.definitions["USE_INTERNAL_ARGS_PARSER"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "14") + + compiler = str(self.settings.compiler) + if compiler not in self._compilers_minimum_version: + self.output.warn("Unknown compiler, assuming it supports at least C++14") + return + + version = tools.Version(self.settings.compiler.version) + if version < self._compilers_minimum_version[compiler]: + raise ConanInvalidConfiguration("cfgfile requires a compiler that supports at least C++14") + + def requirements(self): + if tools.Version(self.version) >= "0.2.10": + self.requires("args-parser/6.2.0.1") + elif self.version == "0.2.9.1": + self.requires("args-parser/6.2.0.1") + elif self.version == "0.2.9.0": + self.requires("args-parser/6.0.1.0") + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + self.copy("*.hpp", src=os.path.join(self._source_subfolder, "cfgfile"), dst=os.path.join("include", "cfgfile")) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH env var with : {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + self.cpp_info.names["cmake_find_package"] = "cfgfile" + self.cpp_info.names["cmake_find_package_multi"] = "cfgfile" + self.cpp_info.includedirs.append(os.path.join("include", "cfgfile")) + + def package_id(self): + del self.info.settings.compiler diff --git a/recipes/cfgfile/all/test_package/CMakeLists.txt b/recipes/cfgfile/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fa54312562336 --- /dev/null +++ b/recipes/cfgfile/all/test_package/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.1) + +project(cfgfile.test) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + +conan_basic_setup(TARGETS) + +find_package(cfgfile REQUIRED) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cfg.hpp" + COMMAND cfgfile.generator -i "${CMAKE_CURRENT_SOURCE_DIR}/session_cfg.conf" -o "${CMAKE_CURRENT_BINARY_DIR}/cfg.hpp" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/session_cfg.conf" +) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +add_executable(${PROJECT_NAME} + example.cpp + "${CMAKE_CURRENT_BINARY_DIR}/cfg.hpp" +) + +target_link_libraries(${PROJECT_NAME} cfgfile::cfgfile) + +set_target_properties(${PROJECT_NAME} PROPERTIES + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON +) diff --git a/recipes/cfgfile/all/test_package/conanfile.py b/recipes/cfgfile/all/test_package/conanfile.py new file mode 100644 index 0000000000000..95fef1a204a6c --- /dev/null +++ b/recipes/cfgfile/all/test_package/conanfile.py @@ -0,0 +1,21 @@ +from conans import ConanFile, CMake, tools +import os + +class CfgfileTestConan(ConanFile): + generators = "cmake", "cmake_find_package" + + def build(self): + if not tools.cross_building(self, skip_x64_x86=True): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def build_requirements(self): + if hasattr(self, "settings_build"): + self.build_requires(str(self.requires["cfgfile"])) + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "cfgfile.test") + cfg_path = os.path.join(self.source_folder, "test.cfg"); + self.run("{} \"{}\"".format(bin_path, cfg_path), run_environment=True) diff --git a/recipes/cfgfile/0.2.9.0/test_package/example.cpp b/recipes/cfgfile/all/test_package/example.cpp similarity index 100% rename from recipes/cfgfile/0.2.9.0/test_package/example.cpp rename to recipes/cfgfile/all/test_package/example.cpp diff --git a/recipes/cfgfile/0.2.8.2.1/test_package/session_cfg.conf b/recipes/cfgfile/all/test_package/session_cfg.conf similarity index 100% rename from recipes/cfgfile/0.2.8.2.1/test_package/session_cfg.conf rename to recipes/cfgfile/all/test_package/session_cfg.conf diff --git a/recipes/cfgfile/0.2.8.2.1/test_package/test.cfg b/recipes/cfgfile/all/test_package/test.cfg similarity index 100% rename from recipes/cfgfile/0.2.8.2.1/test_package/test.cfg rename to recipes/cfgfile/all/test_package/test.cfg diff --git a/recipes/cfgfile/config.yml b/recipes/cfgfile/config.yml new file mode 100644 index 0000000000000..26f651ad576a2 --- /dev/null +++ b/recipes/cfgfile/config.yml @@ -0,0 +1,9 @@ +versions: + "0.2.10": + folder: all + "0.2.9.1": + folder: all + "0.2.9.0": + folder: all + "0.2.8.2.1": + folder: all diff --git a/recipes/cfitsio/all/CMakeLists.txt b/recipes/cfitsio/all/CMakeLists.txt index 4d393c7a86c09..31bd8dc482596 100644 --- a/recipes/cfitsio/all/CMakeLists.txt +++ b/recipes/cfitsio/all/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.1.2) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +conan_basic_setup(TARGETS KEEP_RPATHS) +# we also need to inject definitions of dependencies, +# since cfitsio doesn't link to CMake imported targets +conan_global_flags() add_subdirectory("source_subfolder") diff --git a/recipes/cfitsio/all/conandata.yml b/recipes/cfitsio/all/conandata.yml index cc42b39769d6b..2439d42db1dbd 100644 --- a/recipes/cfitsio/all/conandata.yml +++ b/recipes/cfitsio/all/conandata.yml @@ -1,26 +1,42 @@ sources: - "3.470": - url: "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.47.tar.gz" - sha256: "985606e058403c073a68d95be74e9696f0ded9414520784457a1d4cba8cca7e2" - "3.480": - url: "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.48.tar.gz" - sha256: "fc369363616753fa4dbe9bf28fa7e49cc1b057081229d89b52087d85ef303314" + "4.1.0": + url: "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.1.0.tar.gz" + sha256: "748994dd1c819b88567e3539ea1f0ec2dd39fc0ed2884c033afa3da66efb5f4e" + "4.0.0": + url: "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.0.0.tar.gz" + sha256: "88735b69bb017ee92823b9e7ee14efeae2e57fb6c00503ed3aa2820e850a7b5e" "3.490": url: "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.49.tar.gz" sha256: "8cc4beddd0ff389fb81bde9c181e0e3c419c15ec8a66df201ff4619a93715558" -patches: + "3.480": + url: "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.48.tar.gz" + sha256: "fc369363616753fa4dbe9bf28fa7e49cc1b057081229d89b52087d85ef303314" "3.470": + url: "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.47.tar.gz" + sha256: "985606e058403c073a68d95be74e9696f0ded9414520784457a1d4cba8cca7e2" +patches: + "4.1.0": - patch_file: "patches/windows-use-strtok_s.patch" base_path: "source_subfolder" - - patch_file: "patches/fix-cmake-3.470.patch" + - patch_file: "patches/fix-cmake-4.1.0.patch" base_path: "source_subfolder" - "3.480": + "4.0.0": - patch_file: "patches/windows-use-strtok_s.patch" base_path: "source_subfolder" - - patch_file: "patches/fix-cmake-3.470.patch" + - patch_file: "patches/fix-cmake-4.0.0.patch" base_path: "source_subfolder" "3.490": - patch_file: "patches/windows-use-strtok_s.patch" base_path: "source_subfolder" - patch_file: "patches/fix-cmake-3.490.patch" base_path: "source_subfolder" + "3.480": + - patch_file: "patches/windows-use-strtok_s.patch" + base_path: "source_subfolder" + - patch_file: "patches/fix-cmake-3.470.patch" + base_path: "source_subfolder" + "3.470": + - patch_file: "patches/windows-use-strtok_s.patch" + base_path: "source_subfolder" + - patch_file: "patches/fix-cmake-3.470.patch" + base_path: "source_subfolder" diff --git a/recipes/cfitsio/all/conanfile.py b/recipes/cfitsio/all/conanfile.py index 13731b53d0bd6..806cbca0ccd55 100644 --- a/recipes/cfitsio/all/conanfile.py +++ b/recipes/cfitsio/all/conanfile.py @@ -1,18 +1,20 @@ +from conans import ConanFile, CMake, tools +import functools import glob import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.36.0" + class CfitsioConan(ConanFile): name = "cfitsio" description = "C library for reading and writing data files in FITS " \ "(Flexible Image Transport System) data format" license = "ISC" - topics = ("conan", "cfitsio", "fits", "image", "nasa", "astronomy", "astrophysics", "space") + topics = ("cfitsio", "fits", "image", "nasa", "astronomy", "astrophysics", "space") homepage = "https://heasarc.gsfc.nasa.gov/fitsio/" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -20,7 +22,7 @@ class CfitsioConan(ConanFile): "threadsafe": [True, False], "simd_intrinsics": [None, "sse2", "ssse3"], "with_bzip2": [True, False], - "with_curl": [True, False] + "with_curl": [True, False], } default_options = { "shared": False, @@ -28,10 +30,10 @@ class CfitsioConan(ConanFile): "threadsafe": False, "simd_intrinsics": None, "with_bzip2": False, - "with_curl": False + "with_curl": False, } - _cmake = None + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): @@ -41,35 +43,38 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + del self.options.with_bzip2 + del self.options.with_curl + if self.settings.arch not in ["x86", "x86_64"]: + del self.options.simd_intrinsics def configure(self): if self.options.shared: del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd - if self.settings.arch not in ["x86", "x86_64"]: - del self.options.simd_intrinsics - if self.settings.os == "Windows": - del self.options.with_bzip2 - del self.options.with_curl def requirements(self): - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.12") if self.options.threadsafe and self.settings.os == "Windows" and \ (not self.settings.compiler == "gcc" or self.settings.compiler.threads == "win32"): self.requires("pthreads4w/3.0.0") if self.options.get_safe("with_bzip2"): self.requires("bzip2/1.0.8") if self.options.get_safe("with_curl"): - self.requires("libcurl/7.73.0") + self.requires("libcurl/7.80.0") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("cfitsio-*")[0] - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): self._patch_sources() @@ -79,23 +84,36 @@ def build(self): def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - # Remove embedded zlib files - for zlib_file in glob.glob(os.path.join(self._source_subfolder, "zlib", "*")): - if not zlib_file.endswith(("zcompress.c", "zuncompress.c")): - os.remove(zlib_file) + if tools.Version(self.version) < "4.0.0": + # Remove embedded zlib files + for zlib_file in glob.glob(os.path.join(self._source_subfolder, "zlib", "*")): + if not zlib_file.endswith(("zcompress.c", "zuncompress.c")): + os.remove(zlib_file) + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["USE_PTHREADS"] = self.options.threadsafe - self._cmake.definitions["CFITSIO_USE_SSE2"] = self.options.get_safe("simd_intrinsics") == "sse2" - self._cmake.definitions["CFITSIO_USE_SSSE3"] = self.options.get_safe("simd_intrinsics") == "ssse3" + cmake = CMake(self) + cmake.definitions["USE_PTHREADS"] = self.options.threadsafe + if tools.Version(self.version) >= "4.1.0": + cmake.definitions["USE_SSE2"] = self.options.get_safe("simd_intrinsics") == "sse2" + cmake.definitions["USE_SSSE3"] = self.options.get_safe("simd_intrinsics") == "ssse3" + else: + cmake.definitions["CFITSIO_USE_SSE2"] = self.options.get_safe("simd_intrinsics") == "sse2" + cmake.definitions["CFITSIO_USE_SSSE3"] = self.options.get_safe("simd_intrinsics") == "ssse3" if self.settings.os != "Windows": - self._cmake.definitions["CFITSIO_USE_BZIP2"] = self.options.with_bzip2 - self._cmake.definitions["UseCurl"] = self.options.with_curl - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + if tools.Version(self.version) >= "4.1.0": + cmake.definitions["USE_BZIP2"] = self.options.with_bzip2 + else: + cmake.definitions["CFITSIO_USE_BZIP2"] = self.options.with_bzip2 + if tools.Version(self.version) >= "4.0.0": + cmake.definitions["USE_CURL"] = self.options.with_curl + else: + cmake.definitions["UseCurl"] = self.options.with_curl + if tools.Version(self.version) >= "4.0.0": + cmake.definitions["TESTS"] = False + cmake.definitions["UTILS"] = False + cmake.configure(build_folder=self._build_subfolder) + return cmake def package(self): self.copy("License.txt", dst="licenses", src=self._source_subfolder) @@ -104,8 +122,9 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "cfitsio") self.cpp_info.libs = ["cfitsio"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") if self.options.threadsafe: self.cpp_info.system_libs.append("pthread") diff --git a/recipes/cfitsio/all/patches/fix-cmake-3.470.patch b/recipes/cfitsio/all/patches/fix-cmake-3.470.patch index 3ef2412e259d2..a0359c65d47c9 100644 --- a/recipes/cfitsio/all/patches/fix-cmake-3.470.patch +++ b/recipes/cfitsio/all/patches/fix-cmake-3.470.patch @@ -31,7 +31,7 @@ -FILE(GLOB H_FILES "*.h") -+SET(H_FILES fitsio.h longnam.h) ++SET(H_FILES fitsio.h fitsio2.h longnam.h) +SET(LINK_LIBS "") IF (USE_PTHREADS) diff --git a/recipes/cfitsio/all/patches/fix-cmake-3.490.patch b/recipes/cfitsio/all/patches/fix-cmake-3.490.patch index 97e72a4feccc9..690a5f19cfee6 100644 --- a/recipes/cfitsio/all/patches/fix-cmake-3.490.patch +++ b/recipes/cfitsio/all/patches/fix-cmake-3.490.patch @@ -31,7 +31,7 @@ -FILE(GLOB H_FILES "*.h") -+SET(H_FILES fitsio.h longnam.h) ++SET(H_FILES fitsio.h fitsio2.h longnam.h) +SET(LINK_LIBS "") IF (USE_PTHREADS) diff --git a/recipes/cfitsio/all/patches/fix-cmake-4.0.0.patch b/recipes/cfitsio/all/patches/fix-cmake-4.0.0.patch new file mode 100644 index 0000000000000..aa6952cfb90bd --- /dev/null +++ b/recipes/cfitsio/all/patches/fix-cmake-4.0.0.patch @@ -0,0 +1,59 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -71,7 +71,7 @@ ELSE() + SET (LIB_TYPE STATIC) + ENDIF(BUILD_SHARED_LIBS) + +-IF(NOT MSVC) ++IF(NOT WIN32) + # Find curl library, for HTTPS support: + IF(USE_CURL) + FIND_PACKAGE(CURL) +@@ -82,8 +82,14 @@ IF(NOT MSVC) + ENDIF(NOT MSVC) + + IF(USE_PTHREADS) +- FIND_PACKAGE(Threads REQUIRED) +- ADD_DEFINITIONS(-D_REENTRANT) ++ SET(CMAKE_THREAD_PREFER_PTHREAD TRUE) ++ SET(THREADS_PREFER_PTHREAD_FLAG TRUE) ++ FIND_PACKAGE(Threads REQUIRED) ++ IF(CMAKE_USE_PTHREADS_INIT) ++ LIST(APPEND LINK_LIBS "Threads::Threads") ++ ELSE() ++ LIST(APPEND LINK_LIBS "CONAN_PKG::pthreads4w") ++ ENDIF() + ENDIF(USE_PTHREADS) + + IF(CFITSIO_USE_BZIP2) +@@ -99,19 +105,13 @@ ELSE() + ENDIF() + + # Support for remote file drivers is not implemented for native Windows: +-IF (NOT MSVC) ++IF (NOT WIN32) + + # Find library needed for gethostbyname: +- CHECK_FUNCTION_EXISTS("gethostbyname" CMAKE_HAVE_GETHOSTBYNAME) +- IF (NOT CMAKE_HAVE_GETHOSTBYNAME) +- CHECK_LIBRARY_EXISTS("nsl" "gethostbyname" "" CMAKE_HAVE_GETHOSTBYNAME) +- ENDIF () ++ CHECK_SYMBOL_EXISTS(gethostbyname "netdb.h" CMAKE_HAVE_GETHOSTBYNAME) + + # Find library needed for connect: +- CHECK_FUNCTION_EXISTS("connect" CMAKE_HAVE_CONNECT) +- IF (NOT CMAKE_HAVE_CONNECT) +- CHECK_LIBRARY_EXISTS("socket" "connect" "" CMAKE_HAVE_CONNECT) +- ENDIF () ++ CHECK_SYMBOL_EXISTS(connect "sys/types.h;sys/socket.h" CMAKE_HAVE_CONNECT) + + # Define HAVE_NET_SERVICES if gethostbyname & connect were found: + IF (CMAKE_HAVE_GETHOSTBYNAME AND CMAKE_HAVE_CONNECT) +@@ -275,7 +275,6 @@ IF (BZIP2_FOUND) + ENDIF(BZIP2_FOUND) + + SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${${PROJECT_NAME}_VERSION} SOVERSION ${${PROJECT_NAME}_MAJOR_VERSION}) +-install(TARGETS ${LIB_NAME} DESTINATION ${LIB_DESTINATION}) + install(TARGETS ${LIB_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib diff --git a/recipes/cfitsio/all/patches/fix-cmake-4.1.0.patch b/recipes/cfitsio/all/patches/fix-cmake-4.1.0.patch new file mode 100644 index 0000000000000..c067c25a4a81b --- /dev/null +++ b/recipes/cfitsio/all/patches/fix-cmake-4.1.0.patch @@ -0,0 +1,41 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -82,8 +82,14 @@ IF(NOT WIN32) + ENDIF(NOT WIN32) + + IF(USE_PTHREADS) ++ SET(CMAKE_THREAD_PREFER_PTHREAD TRUE) ++ SET(THREADS_PREFER_PTHREAD_FLAG TRUE) + FIND_PACKAGE(Threads REQUIRED) +- ADD_DEFINITIONS(-D_REENTRANT) ++ IF(CMAKE_USE_PTHREADS_INIT) ++ LIST(APPEND LINK_LIBS "Threads::Threads") ++ ELSE() ++ LIST(APPEND LINK_LIBS "CONAN_PKG::pthreads4w") ++ ENDIF() + ENDIF(USE_PTHREADS) + + IF(USE_BZIP2) +@@ -99,19 +105,13 @@ ELSE() + ENDIF() + + # Support for remote file drivers is not implemented for native Windows: +-IF (NOT MSVC) ++IF (NOT WIN32) + + # Find library needed for gethostbyname: +- CHECK_FUNCTION_EXISTS("gethostbyname" CMAKE_HAVE_GETHOSTBYNAME) +- IF (NOT CMAKE_HAVE_GETHOSTBYNAME) +- CHECK_LIBRARY_EXISTS("nsl" "gethostbyname" "" CMAKE_HAVE_GETHOSTBYNAME) +- ENDIF () ++ CHECK_SYMBOL_EXISTS(gethostbyname "netdb.h" CMAKE_HAVE_GETHOSTBYNAME) + + # Find library needed for connect: +- CHECK_FUNCTION_EXISTS("connect" CMAKE_HAVE_CONNECT) +- IF (NOT CMAKE_HAVE_CONNECT) +- CHECK_LIBRARY_EXISTS("socket" "connect" "" CMAKE_HAVE_CONNECT) +- ENDIF () ++ CHECK_SYMBOL_EXISTS(connect "sys/types.h;sys/socket.h" CMAKE_HAVE_CONNECT) + + # Define HAVE_NET_SERVICES if gethostbyname & connect were found: + IF (CMAKE_HAVE_GETHOSTBYNAME AND CMAKE_HAVE_CONNECT) diff --git a/recipes/cfitsio/all/test_package/CMakeLists.txt b/recipes/cfitsio/all/test_package/CMakeLists.txt index 7b9b613cbb24a..d376289c5a2fe 100644 --- a/recipes/cfitsio/all/test_package/CMakeLists.txt +++ b/recipes/cfitsio/all/test_package/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(cfitsio REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} cfitsio::cfitsio) diff --git a/recipes/cfitsio/all/test_package/conanfile.py b/recipes/cfitsio/all/test_package/conanfile.py index 2451c9e17b95c..5d7487325efa0 100644 --- a/recipes/cfitsio/all/test_package/conanfile.py +++ b/recipes/cfitsio/all/test_package/conanfile.py @@ -1,10 +1,10 @@ +from conans import ConanFile, CMake, tools import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,7 +12,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): fits_name = os.path.join(self.source_folder, "file011.fits") bin_path = os.path.join("bin", "test_package") self.run("\"{0}\" \"{1}\"".format(bin_path, fits_name), run_environment=True) diff --git a/recipes/cfitsio/config.yml b/recipes/cfitsio/config.yml index e448429fe7e41..cc5b885b36e75 100644 --- a/recipes/cfitsio/config.yml +++ b/recipes/cfitsio/config.yml @@ -1,7 +1,11 @@ versions: - "3.470": + "4.1.0": folder: all - "3.480": + "4.0.0": folder: all "3.490": folder: all + "3.480": + folder: all + "3.470": + folder: all diff --git a/recipes/cgal/all/conandata.yml b/recipes/cgal/all/conandata.yml index 8f19f736c79c1..a9e86a3361343 100644 --- a/recipes/cgal/all/conandata.yml +++ b/recipes/cgal/all/conandata.yml @@ -1,28 +1,19 @@ sources: - "5.0": - sha256: bd9327be903ab7ee379a8a7a0609eba0962f5078d2497cf8e13e8e1598584154 - url: https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-5.0/CGAL-5.0.zip - "5.0.1": - sha256: 15e7a8c5ce04762ec2e4e1ee494a9a6840db0cc066a3b1c8da89db43d8357ce5 - url: https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-5.0.1/CGAL-5.0.1.zip - "5.0.2": - sha256: 4d281e482449de3a7415cfc117ace2341427ffc4a03cb0806794531cacdde38f - url: https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-5.0.2/CGAL-5.0.2.zip - "5.0.3": - sha256: d47912d6a9e79492aa41d91c8001fdbf504b9c971d11c293328e189e6779c862 - url: https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-5.0.3/CGAL-5.0.3.zip - "5.1": - sha256: 85217a74df0e7b8c5e1c29b45d9d3846c22346211c9b2232201919e42f33d3d2 - url: https://github.com/CGAL/cgal/releases/download/v5.1/CGAL-5.1.zip - "5.1.1": - sha256: eb052f9b47e4f5891f217b667f34e0e3aee9ff36b7cf858cd771d555ae9c5c30 - url: https://github.com/CGAL/cgal/releases/download/v5.1.1/CGAL-5.1.1.zip - "5.1.3": - sha256: 6986e6b67ec3fe4191f35e326bb2838995b84090448a15a8050347c4dcab7829 - url: https://github.com/CGAL/cgal/releases/download/v5.1.3/CGAL-5.1.3.tar.xz - "5.2": - sha256: 744c86edb6e020ab0238f95ffeb9cf8363d98cde17ebb897d3ea93dac4145923 - url: https://github.com/CGAL/cgal/releases/download/v5.2/CGAL-5.2.tar.xz - "5.2.1": - sha256: 7e80b710a2b05cf7c22ce6fd8000905957c2263ab0048185b5010172b5bc19e6 - url: https://github.com/CGAL/cgal/releases/download/v5.2.1/CGAL-5.2.1.tar.xz + "5.0.4": + sha256: e82096c03ccb31200f02a5b9bd0a5e9ea07840351987dca55aae99a8d5823f59 + url: https://github.com/CGAL/cgal/releases/download/v5.0.4/CGAL-5.0.4.tar.xz + "5.1.5": + sha256: b1bb8a6053aa12baa5981aef20a542cd3e617a86826963fb8fb6852b1a0da97c + url: https://github.com/CGAL/cgal/releases/download/v5.1.5/CGAL-5.1.5.tar.xz + "5.2.4": + sha256: 7f792c59d067e41a073bcee5d615f4276f9ccd2b5e7d359093cc36149fda14c3 + url: https://github.com/CGAL/cgal/releases/download/v5.2.4/CGAL-5.2.4.tar.xz + "5.3.2": + sha256: af917dbc550388ebcb206f774e610fbdb914d95a4b2932fa952279129103852b + url: https://github.com/CGAL/cgal/releases/download/v5.3.2/CGAL-5.3.2.tar.xz + "5.5": + sha256: 98ac395ca08aacf38b7a8170a822b650aedf10355df41dd0e4bfb238408e08a6 + url: https://github.com/CGAL/cgal/releases/download/v5.5/CGAL-5.5.tar.xz + "5.5.1": + sha256: 091630def028facdcaf00eb5b68ad79eddac1b855cca6e87eef18a031566edfc + url: https://github.com/CGAL/cgal/releases/download/v5.5.1/CGAL-5.5.1.tar.xz diff --git a/recipes/cgal/all/conanfile.py b/recipes/cgal/all/conanfile.py index b6e92e08f2d78..47cc7c6fa95ce 100644 --- a/recipes/cgal/all/conanfile.py +++ b/recipes/cgal/all/conanfile.py @@ -1,33 +1,23 @@ import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools import files +from conan.tools import scm +from conans import CMake +required_conan_version = ">=1.50.0" class CgalConan(ConanFile): name = "cgal" license = "GPL-3.0-or-later", "LGPL-3.0-or-later" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/CGAL/cgal" - description = "C++ library that aims to provide easy access to efficient and reliable algorithms"\ - "in computational geometry." - topics = ("conan", "cgal", "geometry", "algorithms") + description = "C++ library that provides easy access to efficient and reliable algorithms"\ + " in computational geometry." + topics = ("cgal", "geometry", "algorithms") settings = "os", "compiler", "build_type", "arch" generators = "cmake" exports_sources = "CMakeLists.txt" - options = { - "with_cgal_core": [True, False], - "with_cgal_qt5": [True, False], - "with_cgal_imageio": [True, False], - "shared": [True, False], - "header_only": [True, False] - } - default_options = { - "with_cgal_core": True, - "with_cgal_qt5": False, - "with_cgal_imageio": True, - "shared": False, - "header_only": True - } + short_paths = True _cmake = None @@ -42,22 +32,17 @@ def _build_subfolder(self): def _configure_cmake(self): if not self._cmake: self._cmake = CMake(self) - self._cmake.definitions["WITH_CGAL_Core"] = self.options.with_cgal_core - self._cmake.definitions["WITH_CGAL_Qt5"] = self.options.with_cgal_qt5 - self._cmake.definitions["WITH_CGAL_ImageIO"] = self.options.with_cgal_imageio - self._cmake.definitions["CGAL_HEADER_ONLY"] = self.options.header_only + self._cmake.definitions["CGAL_HEADER_ONLY"] = "TRUE" self._cmake.configure(build_folder=self._build_subfolder) return self._cmake def _patch_sources(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "CMAKE_SOURCE_DIR", "CMAKE_CURRENT_SOURCE_DIR") - - def configure(self): - if self.options.with_cgal_qt5: - raise ConanInvalidConfiguration("Qt Conan package is not available yet.") - if self.options.header_only: - del self.options.shared + if scm.Version(self.version) < "5.3": + files.replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), + "CMAKE_SOURCE_DIR", "CMAKE_CURRENT_SOURCE_DIR") + else: + files.replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), + "if(NOT PROJECT_NAME)", "if(TRUE)") def requirements(self): self.requires("boost/1.75.0") @@ -65,13 +50,10 @@ def requirements(self): self.requires("mpfr/4.1.0") def package_id(self): - if self.options.header_only: - self.info.header_only() + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "CGAL-{}".format(self.version) - os.rename(extracted_dir, self._source_subfolder) + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def build(self): self._patch_sources() @@ -82,23 +64,13 @@ def package(self): self.copy("LICENSE*", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - if self.options.get_safe("shared"): - for root, _, filenames in os.walk(os.path.join(self.package_folder, "bin")): - for filename in filenames: - if not filename.endswith(".dll"): - os.unlink(os.path.join(root, filename)) - else: - tools.rmdir(os.path.join(self.package_folder, "bin")) + files.rmdir(self, os.path.join(self.package_folder, "share")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + files.rmdir(self, os.path.join(self.package_folder, "bin")) def package_info(self): - # TODO: add components self.cpp_info.names["cmake_find_package"] = "CGAL" self.cpp_info.names["cmake_find_package_multi"] = "CGAL" - if not self.options.header_only: - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux" and (self.options.with_cgal_core or self.options.with_cgal_imageio): + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") - if not self.options.header_only: - self.cpp_info.defines.append("CGAL_NOT_HEADER_ONLY=1") + self.cpp_info.defines.append("CGAL_HEADER_ONLY=1") diff --git a/recipes/cgal/all/test_package/conanfile.py b/recipes/cgal/all/test_package/conanfile.py index 4aebe114eeb59..2b959f9f04238 100644 --- a/recipes/cgal/all/test_package/conanfile.py +++ b/recipes/cgal/all/test_package/conanfile.py @@ -1,6 +1,8 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools import build +from conans import CMake class TestPackageConan(ConanFile): @@ -13,6 +15,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not build.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/cgal/config.yml b/recipes/cgal/config.yml index ceea989c5ea61..72209e170658c 100644 --- a/recipes/cgal/config.yml +++ b/recipes/cgal/config.yml @@ -1,19 +1,13 @@ versions: - "5.0": + "5.0.4": folder: all - "5.0.1": + "5.1.5": folder: all - "5.0.2": + "5.2.4": folder: all - "5.0.3": + "5.3.2": folder: all - "5.1": + "5.5": folder: all - "5.1.1": - folder: all - "5.1.3": - folder: all - "5.2": - folder: all - "5.2.1": + "5.5.1": folder: all diff --git a/recipes/cglm/all/CMakeLists.txt b/recipes/cglm/all/CMakeLists.txt new file mode 100644 index 0000000000000..3a14ce35d533b --- /dev/null +++ b/recipes/cglm/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory("source_subfolder") diff --git a/recipes/cglm/all/conandata.yml b/recipes/cglm/all/conandata.yml new file mode 100644 index 0000000000000..d63882c55fca8 --- /dev/null +++ b/recipes/cglm/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.8.5": + url: "https://github.com/recp/cglm/archive/refs/tags/v0.8.5.tar.gz" + sha256: "baefa21342d228a83c90708459a745d5aa9b0ebb381555eea42db1f37fdf7a5a" diff --git a/recipes/cglm/all/conanfile.py b/recipes/cglm/all/conanfile.py new file mode 100644 index 0000000000000..023c54a31f51b --- /dev/null +++ b/recipes/cglm/all/conanfile.py @@ -0,0 +1,101 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.29.1" + + +class CglmConan(ConanFile): + name = "cglm" + description = "Highly Optimized Graphics Math (glm) for C " + topics = ("cglm", "graphics", "opengl", "simd", "vector", "glm") + homepage = "https://github.com/recp/cglm" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + exports_sources = ("CMakeLists.txt", ) + generators = "cmake" + options = { + "shared": [True, False], + "fPIC": [True, False], + "header_only": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "header_only": False, + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.options.header_only: + del self.settings.arch + del self.settings.build_type + del self.settings.compiler + del self.settings.os + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + + self._cmake = CMake(self) + self._cmake.definitions["CGLM_STATIC"] = not self.options.shared + self._cmake.definitions["CGLM_SHARED"] = self.options.shared + self._cmake.definitions["CGLM_USE_TEST"] = False + self._cmake.configure() + return self._cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + if not self.options.header_only: + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + + if self.options.header_only: + self.copy("*", src=os.path.join(self._source_subfolder, "include"), dst="include") + else: + cmake = self._configure_cmake() + cmake.install() + + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "cglm") + self.cpp_info.set_property("cmake_target_name", "cglm::cglm") + self.cpp_info.set_property("pkg_config_name", "cglm") + + if not self.options.header_only: + self.cpp_info.libs = ["cglm"] + if self.settings.os in ("Linux", "FreeBSD"): + self.cpp_info.system_libs.append("m") + + # backward support of cmake_find_package, cmake_find_package_multi & pkg_config generators + self.cpp_info.names["pkg_config"] = "cglm" + self.cpp_info.names["cmake_find_package"] = "cglm" + self.cpp_info.names["cmake_find_package_multi"] = "cglm" diff --git a/recipes/cglm/all/test_package/CMakeLists.txt b/recipes/cglm/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..511cf63c2b9e2 --- /dev/null +++ b/recipes/cglm/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cglm REQUIRED) + +add_executable(test_package test_package.c) +target_link_libraries(test_package PRIVATE cglm::cglm) diff --git a/recipes/cglm/all/test_package/conanfile.py b/recipes/cglm/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cglm/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cglm/all/test_package/test_package.c b/recipes/cglm/all/test_package/test_package.c new file mode 100644 index 0000000000000..9e263a8afc8ed --- /dev/null +++ b/recipes/cglm/all/test_package/test_package.c @@ -0,0 +1,21 @@ +#include +#include + +int main() { + mat4 matrix = { + { 0.20138f, 0.82993f, 0.28319, 0.29518f }, + { 0.99043f, 0.88820f, 0.62279, 0.33396f }, + { 0.48144f, 0.36351f, 0.70723, 0.65915f }, + { 0.64711f, 0.69593f, 0.80561, 0.62619f }, + }; + vec4 vector = { 0.023048f, 0.243715f, 0.125258f, 0.699470 }; + vec4 result; + + float det = glm_mat4_det(matrix); + glm_mat4_mulv(matrix, vector, result); + + printf("determinant is %f\n", det); + printf("result of multiplication is: { %f, %f, %f, %f }\n", result[0], result[1], result[2], result[3]); + + return 0; +} diff --git a/recipes/cglm/config.yml b/recipes/cglm/config.yml new file mode 100644 index 0000000000000..dacc103c54543 --- /dev/null +++ b/recipes/cglm/config.yml @@ -0,0 +1,3 @@ +versions: + "0.8.5": + folder: all diff --git a/recipes/cgltf/all/conandata.yml b/recipes/cgltf/all/conandata.yml index 8319a74b4b70e..e54cb4331e847 100644 --- a/recipes/cgltf/all/conandata.yml +++ b/recipes/cgltf/all/conandata.yml @@ -1,4 +1,13 @@ sources: + "1.13": + url: "https://github.com/jkuhlmann/cgltf/archive/v1.13.tar.gz" + sha256: "053d5320097334767486c6e33d01dd1b1c6224eac82aac2d720f4ec456d8c50b" + "1.12": + url: "https://github.com/jkuhlmann/cgltf/archive/v1.12.tar.gz" + sha256: "2c429bb26256b49bfed2510aef1e5fa9321b27fe4cf226c9ece9a5867150974f" + "1.11": + url: "https://github.com/jkuhlmann/cgltf/archive/v1.11.tar.gz" + sha256: "e086c9e886cf786a091f5aac05250f9ea836488bd799f327f87e95c8f4247cc6" "1.10": url: "https://github.com/jkuhlmann/cgltf/archive/v1.10.tar.gz" sha256: "13047916886298c11fb97a4145e24753847f4dd674423cd5e3c572ccc34fad22" diff --git a/recipes/cgltf/config.yml b/recipes/cgltf/config.yml index ca46794f15bb5..9f334f27c89c6 100644 --- a/recipes/cgltf/config.yml +++ b/recipes/cgltf/config.yml @@ -1,4 +1,10 @@ versions: + "1.13": + folder: all + "1.12": + folder: all + "1.11": + folder: all "1.10": folder: all "1.9": diff --git a/recipes/cgns/all/CMakeLists.txt b/recipes/cgns/all/CMakeLists.txt deleted file mode 100644 index a1b3f866c27c3..0000000000000 --- a/recipes/cgns/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory("source_subfolder") diff --git a/recipes/cgns/all/conandata.yml b/recipes/cgns/all/conandata.yml index f087eac889b03..bbbd27b41a558 100644 --- a/recipes/cgns/all/conandata.yml +++ b/recipes/cgns/all/conandata.yml @@ -1,10 +1,8 @@ sources: - "3.4.1": - url: "https://github.com/CGNS/CGNS/archive/v3.4.1.tar.gz" - sha256: "d32595e7737b9332243bd3de1eb8c018a272f620f09b289dea8292eba1365994" + "4.3.0": + url: "https://github.com/CGNS/CGNS/archive/v4.3.0.tar.gz" + sha256: "7709eb7d99731dea0dd1eff183f109eaef8d9556624e3fbc34dc5177afc0a032" patches: - "3.4.1": - - patch_file: "patches/fix_find_hdf5.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix_static_or_shared.patch" - base_path: "source_subfolder" + "4.3.0": + - patch_file: "patches/4.3.0-fix_find_hdf5.patch" + - patch_file: "patches/4.3.0-fix_static_or_shared.patch" diff --git a/recipes/cgns/all/conanfile.py b/recipes/cgns/all/conanfile.py index 72ba39fc8a3bd..137666452ceb7 100644 --- a/recipes/cgns/all/conanfile.py +++ b/recipes/cgns/all/conanfile.py @@ -1,41 +1,36 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir import os -from conans import ConanFile, CMake, tools -required_conan_version = ">=1.29.1" - +required_conan_version = ">=1.52.0" class CgnsConan(ConanFile): name = "cgns" description = "Standard for data associated with the numerical solution " \ "of fluid dynamics equations." - topics = ("conan", "cgns", "data", "cfd", "fluids") + topics = "data", "cfd", "fluids" homepage = "http://cgns.org/" license = "Zlib" url = "https://github.com/conan-io/conan-center-index" settings = "os", "compiler", "build_type", "arch" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" options = { "shared": [True, False], "fPIC": [True, False], - "with_hdf5": [True, False] + "with_hdf5": [True, False], + "parallel": [True, False], } default_options = { "shared": False, "fPIC": True, - "with_hdf5": True + "with_hdf5": True, + "parallel": False, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -43,50 +38,91 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): if self.options.with_hdf5: - self.requires("hdf5/1.12.0") - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("CGNS-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake + self.requires("hdf5/1.13.1") - self._cmake = CMake(self) - self._cmake.definitions["CGNS_ENABLE_TESTS"] = False - self._cmake.definitions["CGNS_BUILD_TESTING"] = False - self._cmake.definitions["CGNS_ENABLE_FORTRAN"] = False - self._cmake.definitions["CGNS_ENABLE_HDF5"] = self.options.with_hdf5 - self._cmake.definitions["CGNS_BUILD_SHARED"] = self.options.shared - self._cmake.definitions["CGNS_USE_SHARED"] = self.options.shared - self._cmake.definitions["CGNS_BUILD_CGNSTOOLS"] = False - self._cmake.configure() + def validate(self): + if self.info.options.parallel and not (self.info.options.with_hdf5 and self.dependencies["hdf5"].options.parallel): + raise ConanInvalidConfiguration("The option 'parallel' requires HDF5 with parallel=True") + if self.info.options.parallel and self.info.options.with_hdf5 and self.dependencies["hdf5"].options.enable_cxx: + raise ConanInvalidConfiguration("The option 'parallel' requires HDF5 with enable_cxx=False") - return self._cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + cmake = CMakeDeps(self) + cmake.generate() + + tc = CMakeToolchain(self) + tc.variables["CGNS_ENABLE_TESTS"] = False + tc.variables["CGNS_BUILD_TESTING"] = False + tc.variables["CGNS_ENABLE_FORTRAN"] = False + tc.variables["CGNS_ENABLE_HDF5"] = self.options.with_hdf5 + tc.variables["CGNS_BUILD_SHARED"] = self.options.shared + tc.variables["CGNS_USE_SHARED"] = self.options.shared + tc.variables["CGNS_ENABLE_PARALLEL"] = self.options.parallel + tc.variables["CGNS_BUILD_CGNSTOOLS"] = False + tc.generate() + + # Other flags, seen in appveyor.yml in source code, not currently managed. + # CGNS_ENABLE_LFS:BOOL=OFF --- note in code: needed on 32 bit systems + # CGNS_ENABLE_SCOPING:BOOL=OFF --- disabled in VTK's bundle + # HDF5_NEED_ZLIB:BOOL=ON -- should be dealt with by cmake auto dependency management or something? def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build(target="cgns_shared" if self.options.shared else "cgns_static") def package(self): - self.copy("license.txt", dst="licenses", src=self._source_subfolder) + copy(self, "license.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - os.remove(os.path.join(self.package_folder, "include", "cgnsBuild.defs")) + rm(self, "cgnsBuild.defs", os.path.join(self.package_folder, "include")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.libs = ["cgnsdll" if self.settings.os == "Windows" and self.options.shared else "cgns"] - if self.settings.os == "Windows" and self.options.shared: - self.cpp_info.defines = ["CGNSDLL=__declspec(dllimport)"] # we could instead define USE_DLL but it's too generic + self.cpp_info.set_property("cmake_file_name", "CGNS") + self.cpp_info.set_property("cmake_target_name", "CGNS::CGNS") + + if self.options.shared: + self.cpp_info.components["cgns_shared"].set_property("cmake_target_name", "CGNS::cgns_shared") + self.cpp_info.components["cgns_shared"].libs = ["cgnsdll" if self.settings.os == "Windows" else "cgns"] + self.cpp_info.components["cgns_shared"].libdirs = ["lib"] + if self.options.with_hdf5: + self.cpp_info.components["cgns_shared"].requires = ["hdf5::hdf5"] + if self.settings.os == "Windows": + # we could instead define USE_DLL but it's too generic + self.cpp_info.components["cgns_shared"].defines = ["CGNSDLL=__declspec(dllimport)"] + else: + self.cpp_info.components["cgns_static"].set_property("cmake_target_name", "CGNS::cgns_static") + self.cpp_info.components["cgns_static"].libs = ["cgns"] + self.cpp_info.components["cgns_static"].libdirs = ["lib"] + if self.options.with_hdf5: + self.cpp_info.components["cgns_static"].requires = ["hdf5::hdf5"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "CGNS" + self.cpp_info.names["cmake_find_package_multi"] = "CGNS" diff --git a/recipes/cgns/all/patches/4.3.0-fix_find_hdf5.patch b/recipes/cgns/all/patches/4.3.0-fix_find_hdf5.patch new file mode 100644 index 0000000000000..2863a2571c6d2 --- /dev/null +++ b/recipes/cgns/all/patches/4.3.0-fix_find_hdf5.patch @@ -0,0 +1,23 @@ +diff -r -u a/src/CMakeLists.txt b/src/CMakeLists.txt +--- a/src/CMakeLists.txt 2022-05-31 16:13:29.855723400 +0800 ++++ b/src/CMakeLists.txt 2022-05-31 16:40:39.332447379 +0800 +@@ -576,7 +576,7 @@ + add_library(CGNS::cgns-static ALIAS cgns_static) + # Needed to work around a CMake > 3.8 bug on Windows with MSVS and Intel Fortran + set_property(TARGET cgns_static PROPERTY LINKER_LANGUAGE C) +-target_link_libraries(cgns_static PRIVATE $<$:hdf5::hdf5-${CG_HDF5_LINK_TYPE}>) ++target_link_libraries(cgns_static PRIVATE $<$:HDF5::HDF5>) + + # Build a shared version of the library + if(CGNS_BUILD_SHARED) +@@ -592,8 +592,8 @@ + target_compile_definitions(cgns_shared PRIVATE -DBUILD_DLL) + target_compile_definitions(cgns_shared INTERFACE -DUSE_DLL) + endif () +- if (CGNS_ENABLE_HDF5 AND HDF5_LIBRARY) +- target_link_libraries(cgns_shared PUBLIC hdf5::hdf5-${CG_HDF5_LINK_TYPE} $<$>:${CMAKE_DL_LIBS}>) ++ if (CGNS_ENABLE_HDF5) ++ target_link_libraries(cgns_shared PUBLIC HDF5::HDF5 $<$>:${CMAKE_DL_LIBS}>) + if(HDF5_NEED_ZLIB AND ZLIB_LIBRARY) + target_link_libraries(cgns_shared PUBLIC ${ZLIB_LIBRARY}) + endif() diff --git a/recipes/cgns/all/patches/4.3.0-fix_static_or_shared.patch b/recipes/cgns/all/patches/4.3.0-fix_static_or_shared.patch new file mode 100644 index 0000000000000..8d07a513f10d2 --- /dev/null +++ b/recipes/cgns/all/patches/4.3.0-fix_static_or_shared.patch @@ -0,0 +1,24 @@ +Enforces that either static or dynamic libs are built + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 103cb1f..aae21a7 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -674,7 +674,9 @@ if(CGNS_BUILD_SHARED) + endif() + + ++if(NOT CGNS_BUILD_SHARED) + set (install_targets cgns_static) ++endif() + if(CGNS_BUILD_SHARED) + set(install_targets ${install_targets} cgns_shared) + endif () +@@ -738,7 +740,6 @@ install(EXPORT cgns-targets + # Tools # + ######### + +-add_subdirectory(tools) + + ######### + # Tests # diff --git a/recipes/cgns/all/patches/fix_find_hdf5.patch b/recipes/cgns/all/patches/fix_find_hdf5.patch deleted file mode 100644 index 1ca9fbb2be23d..0000000000000 --- a/recipes/cgns/all/patches/fix_find_hdf5.patch +++ /dev/null @@ -1,19 +0,0 @@ -The CGNS build uses the FindHDF5 module that locates the HDF5 libs by invoking the HDF5 compiler. -In order to link to the correct libraries provided by conan, the whole logic is removed from the cmake script. - ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -192,8 +192,11 @@ endif (CGNS_ENABLE_FORTRAN AND HAS_FORTRAN) - ######## - - option(CGNS_ENABLE_HDF5 "Enable or disable HDF5 interface" "OFF") --if (CGNS_ENABLE_HDF5) -- -+include_directories(${CONAN_INCLUDE_DIRS}) -+set(HDF5_LIBRARY CONAN_PKG::hdf5) -+# All this logic is useless for conan -+# (but don't forget to handle HDF5_NEED_MPI cache variable when we could use openmpi in hdf5) -+if(0) - if (CGNS_BUILD_SHARED) - set (FIND_HDF_COMPONENTS C shared) - else (CGNS_BUILD_SHARED) diff --git a/recipes/cgns/all/patches/fix_static_or_shared.patch b/recipes/cgns/all/patches/fix_static_or_shared.patch deleted file mode 100644 index df7af85cd4aa1..0000000000000 --- a/recipes/cgns/all/patches/fix_static_or_shared.patch +++ /dev/null @@ -1,31 +0,0 @@ -Enforces that either static or dynamic libs are built - ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -542,7 +542,7 @@ option(CGNS_USE_SHARED "Link programs to the CGNS shared library" "ON") - if (CGNS_ENABLE_FORTRAN) - add_library(cgns_static STATIC ${cgns_FILES} $) - else (CGNS_ENABLE_FORTRAN) -- add_library(cgns_static STATIC ${cgns_FILES}) -+ add_library(cgns_static STATIC EXCLUDE_FROM_ALL ${cgns_FILES}) - endif (CGNS_ENABLE_FORTRAN) - # Needed to work around a CMake > 3.8 bug on Windows with MSVS and Intel Fortran - set_property(TARGET cgns_static PROPERTY LINKER_LANGUAGE C) -@@ -598,7 +598,9 @@ if(CGNS_BUILD_SHARED) - endif(CGNS_BUILD_SHARED) - - # Set the install path of the static library -+if(NOT CGNS_BUILD_SHARED) - install(TARGETS cgns_static ARCHIVE DESTINATION lib) -+endif() - # Set the install path of the shared library - if(CGNS_BUILD_SHARED) - # for windows, need to install both cgnsdll.dll and cgnsdll.lib -@@ -650,7 +652,6 @@ install(FILES ${headers} - # Tools # - ######### - --add_subdirectory(tools) - - ######### - # Tests # diff --git a/recipes/cgns/all/test_package/CMakeLists.txt b/recipes/cgns/all/test_package/CMakeLists.txt index 9d13f5fdc4323..bb8b97918cf4b 100644 --- a/recipes/cgns/all/test_package/CMakeLists.txt +++ b/recipes/cgns/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(CGNS CONFIG REQUIRED) add_executable(test_package test_package.cpp) -target_link_libraries(test_package ${CONAN_LIBS}) +target_link_libraries(test_package CGNS::CGNS) diff --git a/recipes/cgns/all/test_package/conanfile.py b/recipes/cgns/all/test_package/conanfile.py index b4c9865828e62..7fa7076884d60 100644 --- a/recipes/cgns/all/test_package/conanfile.py +++ b/recipes/cgns/all/test_package/conanfile.py @@ -1,11 +1,20 @@ import os +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run -from conans import ConanFile, CMake, tools - +required_conan_version = ">=1.52.0" class CgnsTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,6 +22,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cgns/all/test_v1_package/CMakeLists.txt b/recipes/cgns/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a7c9449fc2eb1 --- /dev/null +++ b/recipes/cgns/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(test_package ../test_package/test_package.cpp) +target_link_libraries(test_package ${CONAN_LIBS}) diff --git a/recipes/cgns/all/test_v1_package/conanfile.py b/recipes/cgns/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..b4c9865828e62 --- /dev/null +++ b/recipes/cgns/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class CgnsTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cgns/config.yml b/recipes/cgns/config.yml index d212293f8478b..fefa3b794940e 100644 --- a/recipes/cgns/config.yml +++ b/recipes/cgns/config.yml @@ -1,3 +1,3 @@ versions: - "3.4.1": + "4.3.0": folder: all diff --git a/recipes/charls/all/conandata.yml b/recipes/charls/all/conandata.yml index ac4df6e69d8c3..0c25d16afadd4 100644 --- a/recipes/charls/all/conandata.yml +++ b/recipes/charls/all/conandata.yml @@ -1,14 +1,16 @@ sources: + "2.3.4": + url: "https://github.com/team-charls/charls/archive/2.3.4.tar.gz" + sha256: "28e895a6e22daee76c24cf4d36c62bb20fd60fad0c9cfefc2eb8fa9b6045ae84" + "2.2.0": + url: "https://github.com/team-charls/charls/archive/2.2.0.tar.gz" + sha256: "e1d7dd70cd9d6d46de5abbf22278dc8169707995a21e8bf705f5746c04c76891" "2.1.0": url: "https://github.com/team-charls/charls/archive/2.1.0.tar.gz" sha256: "0d6af23928ba4f1205b1b74754111e5f5f6b47d192199ffa7a70d14b824ad97d" patches: "2.1.0": - patch_file: "patches/def-and-rc-for-msvc-only.patch" - base_path: "source_subfolder" - patch_file: "patches/fix-missing-includes-for-clang5-stdc++.patch" - base_path: "source_subfolder" - patch_file: "patches/enum-name-lookup-for-gcc5.patch" - base_path: "source_subfolder" - patch_file: "patches/constexpr-msvc2015.patch" - base_path: "source_subfolder" diff --git a/recipes/charls/all/conanfile.py b/recipes/charls/all/conanfile.py index 0bd5bc398f827..97c3e37e316b8 100644 --- a/recipes/charls/all/conanfile.py +++ b/recipes/charls/all/conanfile.py @@ -1,70 +1,114 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get, rmdir, save +from conan.tools.scm import Version import os +import textwrap + +required_conan_version = ">=1.50.0" -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration class CharlsConan(ConanFile): name = "charls" description = "C++ implementation of the JPEG-LS standard for lossless " \ "and near-lossless image compression and decompression." license = "BSD-3-Clause" - topics = ("conan", "charls", "jpeg", "compression", "decompression") + topics = ("charls", "jpeg", "JPEG-LS", "compression", "decompression", ) homepage = "https://github.com/team-charls/charls" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - minimal_cpp_standard = "14" - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, minimal_cpp_standard) + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 14) # brace initialization issue for gcc < 5 - if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5": - raise ConanInvalidConfiguration("CharLS can't be compiled by {0} {1}".format(self.settings.compiler, - self.settings.compiler.version)) + if self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) < "5": + raise ConanInvalidConfiguration("CharLS can't be compiled by {0} {1}".format(self.info.settings.compiler, + self.info.settings.compiler.version)) + + # name lookup issue for gcc == 5 in charls/2.2.0 + if self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) == "5" and Version(self.version) >= "2.2.0": + raise ConanInvalidConfiguration("CharLS can't be compiled by {0} {1}".format(self.info.settings.compiler, + self.info.settings.compiler.version)) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CHARLS_INSTALL"] = True + tc.generate() def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CHARLS_INSTALL"] = True - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package(self): - self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + # TODO: to remove in conan v2 once legacy generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"charls": "charls::charls"} + ) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "charls") + self.cpp_info.set_property("cmake_target_name", "charls") + self.cpp_info.set_property("pkg_config_name", "charls") + self.cpp_info.libs = collect_libs(self) if not self.options.shared: self.cpp_info.defines.append("CHARLS_STATIC") + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/charls/all/test_package/CMakeLists.txt b/recipes/charls/all/test_package/CMakeLists.txt index 238a57912da9d..4f9a1f4112d6f 100644 --- a/recipes/charls/all/test_package/CMakeLists.txt +++ b/recipes/charls/all/test_package/CMakeLists.txt @@ -1,13 +1,12 @@ -cmake_minimum_required(VERSION 3.1.3) +cmake_minimum_required(VERSION 3.8) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(charls CONFIG REQUIRED) add_executable(test_package_c test_package.c) -target_link_libraries(test_package_c ${CONAN_LIBS}) +target_link_libraries(test_package_c PRIVATE charls) set_target_properties(test_package_c PROPERTIES LINKER_LANGUAGE CXX) add_executable(test_package_cpp test_package.cpp) -target_link_libraries(test_package_cpp ${CONAN_LIBS}) -set_target_properties(test_package_cpp PROPERTIES CXX_STANDARD 14) +target_link_libraries(test_package_cpp PRIVATE charls) +target_compile_features(test_package_cpp PRIVATE cxx_std_14) diff --git a/recipes/charls/all/test_package/conanfile.py b/recipes/charls/all/test_package/conanfile.py index ea63baef42d54..4048086764007 100644 --- a/recipes/charls/all/test_package/conanfile.py +++ b/recipes/charls/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,8 +20,8 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_c_path = os.path.join("bin", "test_package_c") - self.run(bin_c_path, run_environment=True) - bin_cpp_path = os.path.join("bin", "test_package_cpp") - self.run(bin_cpp_path, run_environment=True) + if not cross_building(self): + bin_c_path = os.path.join(self.cpp.build.bindirs[0], "test_package_c") + self.run(bin_c_path, env="conanrun") + bin_cpp_path = os.path.join(self.cpp.build.bindirs[0], "test_package_cpp") + self.run(bin_cpp_path, env="conanrun") diff --git a/recipes/charls/all/test_v1_package/CMakeLists.txt b/recipes/charls/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..47ece1bc01777 --- /dev/null +++ b/recipes/charls/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(charls CONFIG REQUIRED) + +add_executable(test_package_c ../test_package/test_package.c) +target_link_libraries(test_package_c PRIVATE charls) +set_target_properties(test_package_c PROPERTIES LINKER_LANGUAGE CXX) + +add_executable(test_package_cpp ../test_package/test_package.cpp) +target_link_libraries(test_package_cpp PRIVATE charls) +target_compile_features(test_package_cpp PRIVATE cxx_std_14) diff --git a/recipes/charls/all/test_v1_package/conanfile.py b/recipes/charls/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..4e87a21d76c99 --- /dev/null +++ b/recipes/charls/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_c_path = os.path.join("bin", "test_package_c") + self.run(bin_c_path, run_environment=True) + bin_cpp_path = os.path.join("bin", "test_package_cpp") + self.run(bin_cpp_path, run_environment=True) diff --git a/recipes/charls/config.yml b/recipes/charls/config.yml index dfff490f9a9b6..a9e865d288a54 100644 --- a/recipes/charls/config.yml +++ b/recipes/charls/config.yml @@ -1,3 +1,7 @@ versions: + "2.3.4": + folder: all + "2.2.0": + folder: all "2.1.0": folder: all diff --git a/recipes/chipmunk2d/all/CMakeLists.txt b/recipes/chipmunk2d/all/CMakeLists.txt deleted file mode 100644 index 2fcc36dafa513..0000000000000 --- a/recipes/chipmunk2d/all/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -if(WIN32 AND BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/chipmunk2d/all/conanfile.py b/recipes/chipmunk2d/all/conanfile.py index 75542113f6cdb..4608d275e2aff 100644 --- a/recipes/chipmunk2d/all/conanfile.py +++ b/recipes/chipmunk2d/all/conanfile.py @@ -1,5 +1,9 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.46.0" class Chipmunk2DConan(ConanFile): @@ -10,23 +14,16 @@ class Chipmunk2DConan(ConanFile): topics = ("physics", "engine", "game development") description = "Chipmunk2D is a simple, lightweight, fast and portable 2D "\ "rigid body physics library written in C." - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], - "fPIC": [True, False] + "fPIC": [True, False], } default_options = { - "shared": False, - "fPIC": True + "shared": False, + "fPIC": True, } - exports_sources = ["CMakeLists.txt"] - generators = "cmake" - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" def config_options(self): if self.settings.os == "Windows": @@ -35,40 +32,43 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "Chipmunk2D-Chipmunk-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - if self._cmake: - return self._cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - self._cmake = CMake(self) - self._cmake.definitions["BUILD_DEMOS"] = False - self._cmake.definitions["INSTALL_DEMOS"] = False - self._cmake.definitions["INSTALL_STATIC"] = not self.options.shared - self._cmake.definitions["BUILD_SHARED"] = self.options.shared - self._cmake.definitions["BUILD_STATIC"] = not self.options.shared - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_DEMOS"] = False + tc.variables["INSTALL_DEMOS"] = False + tc.variables["INSTALL_STATIC"] = not self.options.shared + tc.variables["BUILD_SHARED"] = self.options.shared + tc.variables["BUILD_STATIC"] = not self.options.shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses") def package_info(self): - chipmunk_name = "chipmunk" if self.options.shared else "chipmunk_static" - self.cpp_info.components["chipmunk"].names["cmake_find_package"] = chipmunk_name - self.cpp_info.components["chipmunk"].names["cmake_find_package_multi"] = chipmunk_name - self.cpp_info.components["chipmunk"].libs = ["chipmunk"] - if self.settings.os == "Linux": - self.cpp_info.components["chipmunk"].system_libs = ["m", "pthread"] + self.cpp_info.libs = ["chipmunk"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["m", "pthread"] diff --git a/recipes/chipmunk2d/all/test_package/CMakeLists.txt b/recipes/chipmunk2d/all/test_package/CMakeLists.txt index f83a5aee0c39a..b51652c38fd2b 100644 --- a/recipes/chipmunk2d/all/test_package/CMakeLists.txt +++ b/recipes/chipmunk2d/all/test_package/CMakeLists.txt @@ -1,15 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(chipmunk2d REQUIRED CONFIG) -add_executable(example example.c) - -if(CHIPMUNK_SHARED) - target_link_libraries(example chipmunk2d::chipmunk) -else() - target_link_libraries(example chipmunk2d::chipmunk_static) -endif() +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE chipmunk2d::chipmunk2d) diff --git a/recipes/chipmunk2d/all/test_package/conanfile.py b/recipes/chipmunk2d/all/test_package/conanfile.py index 1629bd12c57ec..3a8c6c5442b33 100644 --- a/recipes/chipmunk2d/all/test_package/conanfile.py +++ b/recipes/chipmunk2d/all/test_package/conanfile.py @@ -1,17 +1,25 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -class Chipmunk2DTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) - cmake.definitions["CHIPMUNK_SHARED"] = self.options["chipmunk2d"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/chipmunk2d/all/test_package/example.c b/recipes/chipmunk2d/all/test_package/test_package.c similarity index 100% rename from recipes/chipmunk2d/all/test_package/example.c rename to recipes/chipmunk2d/all/test_package/test_package.c diff --git a/recipes/chipmunk2d/all/test_v1_package/CMakeLists.txt b/recipes/chipmunk2d/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..ca2c1e3f5df78 --- /dev/null +++ b/recipes/chipmunk2d/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(chipmunk2d REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE chipmunk2d::chipmunk2d) diff --git a/recipes/chipmunk2d/all/test_v1_package/conanfile.py b/recipes/chipmunk2d/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/chipmunk2d/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cimg/all/conandata.yml b/recipes/cimg/all/conandata.yml index 649c594e463f2..939c703cb331f 100644 --- a/recipes/cimg/all/conandata.yml +++ b/recipes/cimg/all/conandata.yml @@ -1,4 +1,13 @@ sources: + "3.0.2": + url: "https://cimg.eu/files/CImg_3.0.2.zip" + sha256: "ee55a37c33d503a64ff264b53952e502ba7c2887b59ded47c47c86ea52ac5c31" + "3.0.0": + url: "https://cimg.eu/files/CImg_3.0.0.zip" + sha256: "8ec6e9d87459a3cb85bddcd5ae8a4891bc734957ea4aa3089dcf1d234e8d0525" + "2.9.9": + url: "https://cimg.eu/files/CImg_2.9.9.zip" + sha256: "c94412f26800ea318fa79410c58da1cf3df71771d07e515c39b16ee743f68e92" "2.9.4": url: "https://cimg.eu/files/CImg_2.9.4.zip" sha256: "455945dc035d50bbc042450e2dc81b2ca19ea74cd3bc38b46ac623df6997dfff" diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index 937623544a3d4..4c4d65c0ab3d8 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -1,64 +1,119 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -import shutil + +required_conan_version = ">=1.51.1" class CImgConan(ConanFile): name = "cimg" description = "The CImg Library is a small and open-source C++ toolkit for image processing" homepage = "http://cimg.eu" - topics = "conan", "cimg", "physics", "simulation", "robotics", "kinematics", "engine", + topics = ("physics", "simulation", "robotics", "kinematics", "engine") license = "CeCILL V2" url = "https://github.com/conan-io/conan-center-index" - no_copy_source = True - settings = "compiler" - - _cimg_options = ( - ("enable_fftw", "cimg_use_fftw", "fftw/3.3.8"), - ("enable_jpeg", "cimg_use_jpeg", "libjpeg/9d"), - ("enable_openexr", "cimg_use_openexr", "openexr/2.5.4"), - ("enable_png", "cimg_use_png", "libpng/1.6.37"), - ("enable_tiff", "cimg_use_tiff", "libtiff/4.2.0"), - # ("enable_ffmpeg", "cimg_use_ffmpeg", "ffmpeg/???"), - ("enable_opencv", "cimg_use_opencv", "opencv/4.5.1"), - # ("enable_magick", "cimg_use_magick", "magick/???"), - # ("enable_xrandr", "cimg_use_xrandr", "xrandr/???"), - # ("enable_xshm", "cimg_use_xshm", "xshm/???"), - ) - # TODO: Update requirements when available in CCI - options = dict((option, [True, False]) for option, _, _ in _cimg_options) - default_options = dict((option, True) for option, _, _ in _cimg_options) + settings = "os", "arch", "compiler", "build_type" + options = { + "enable_fftw": [True, False], + "enable_jpeg": [True, False], + "enable_openexr": [True, False], + "enable_png": [True, False], + "enable_tiff": [True, False], + "enable_ffmpeg": [True, False], + "enable_opencv": [True, False], + "enable_magick": [True, False], + "enable_xrandr": [True, False], + "enable_xshm": [True, False], + } + default_options = { + "enable_fftw": False, + "enable_jpeg": False, + "enable_openexr": False, + "enable_png": False, + "enable_tiff": False, + "enable_ffmpeg": False, + "enable_opencv": False, + "enable_magick": False, + "enable_xrandr": False, + "enable_xshm": False, + } - def configure(self): - tools.check_min_cppstd(self, "11") + no_copy_source = True @property - def _source_subfolder(self): - return "source_subfolder" + def _cimg_defines(self): + return [ + ("enable_fftw", "cimg_use_fftw"), + ("enable_jpeg", "cimg_use_jpeg"), + ("enable_openexr", "cimg_use_openexr"), + ("enable_png", "cimg_use_png"), + ("enable_tiff", "cimg_use_tiff"), + ("enable_ffmpeg", "cimg_use_ffmpeg"), + ("enable_opencv", "cimg_use_opencv"), + ("enable_magick", "cimg_use_magick"), + ("enable_xrandr", "cimg_use_xrandr"), + ("enable_xshm", "cimg_use_xshm"), + ] + + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): - for option, _, req in self._cimg_options: - if getattr(self.options, option): - self.requires(req) + if self.options.enable_fftw: + self.requires("fftw/3.3.9") + if self.options.enable_jpeg: + self.requires("libjpeg/9e") + if self.options.enable_openexr: + self.requires("openexr/2.5.7") + if self.options.enable_png: + self.requires("libpng/1.6.39") + if self.options.enable_tiff: + self.requires("libtiff/4.4.0") + if self.options.enable_ffmpeg: + self.requires("ffmpeg/5.0") + if self.options.enable_opencv: + self.requires("opencv/4.5.5") + if self.options.enable_magick: + self.requires("imagemagick/7.0.11-14") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, "11") + # TODO: Update requirements when available in CCI + if self.options.enable_xrandr: + raise ConanInvalidConfiguration("xrandr not available in CCI yet") + if self.options.enable_xshm: + raise ConanInvalidConfiguration("xshm not available in CCI yet") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("CImg-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("Licence*", src=self._source_subfolder, dst="licenses") - self.copy("CImg.h", src=self._source_subfolder, dst="include") - shutil.copytree(os.path.join(self.source_folder, self._source_subfolder, "plugins"), + copy(self, "Licence*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "CImg.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) + copy(self, "*", os.path.join(self.source_folder, "plugins"), os.path.join(self.package_folder, "include", "plugins")) - def package_id(self): - self.info.header_only() - def package_info(self): - self.cpp_info.names["cmake_find_package"] = "CImg" - self.cpp_info.names["cmake_find_package_multi"] = "CImg" - - for option, define, _ in self._cimg_options: + self.cpp_info.set_property("pkg_config_name", "CImg") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + for option, define in self._cimg_defines: if getattr(self.options, option): self.cpp_info.defines.append(define) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + # do not use this name in CMakeDeps, it was a mistake, there is no offical CMake config file + self.cpp_info.names["cmake_find_package"] = "CImg" + self.cpp_info.names["cmake_find_package_multi"] = "CImg" diff --git a/recipes/cimg/all/test_package/CMakeLists.txt b/recipes/cimg/all/test_package/CMakeLists.txt index 54f60fa9925c0..449f2a9e10e69 100644 --- a/recipes/cimg/all/test_package/CMakeLists.txt +++ b/recipes/cimg/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 11) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cimg REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) - +target_link_libraries(${PROJECT_NAME} PRIVATE cimg::cimg) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cimg/all/test_package/conanfile.py b/recipes/cimg/all/test_package/conanfile.py index b63178709d69f..0a6bc68712d90 100644 --- a/recipes/cimg/all/test_package/conanfile.py +++ b/recipes/cimg/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,5 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cimg/all/test_v1_package/CMakeLists.txt b/recipes/cimg/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9cb59c3d4ef6a --- /dev/null +++ b/recipes/cimg/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CImg REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE CImg::CImg) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cimg/all/test_v1_package/conanfile.py b/recipes/cimg/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cimg/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cimg/config.yml b/recipes/cimg/config.yml index b5b90251908ae..57d368a954f0b 100644 --- a/recipes/cimg/config.yml +++ b/recipes/cimg/config.yml @@ -1,4 +1,10 @@ versions: + "3.0.2": + folder: all + "3.0.0": + folder: all + "2.9.9": + folder: all "2.9.4": folder: all "2.9.2": diff --git a/recipes/circularbuffer/all/conandata.yml b/recipes/circularbuffer/all/conandata.yml new file mode 100644 index 0000000000000..ba45559184f9d --- /dev/null +++ b/recipes/circularbuffer/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.3.3": + url: "https://github.com/rlogiacco/CircularBuffer/archive/refs/tags/1.3.3.tar.gz" + sha256: "d558029c9ab5012a8bbf9a89bd130eb320bdeb69e3f8bd96851ddc1e5dc24eba" diff --git a/recipes/circularbuffer/all/conanfile.py b/recipes/circularbuffer/all/conanfile.py new file mode 100644 index 0000000000000..c3948bef41ba8 --- /dev/null +++ b/recipes/circularbuffer/all/conanfile.py @@ -0,0 +1,51 @@ +from conan import ConanFile +from conan.tools.files import get, copy +from conan.tools.layout import basic_layout +from conan.tools.cmake import CMakeToolchain + +import os + +required_conan_version = ">=1.47.0" + + +class CircularBufferConan(ConanFile): + name = "circularbuffer" + description = "Arduino circular buffer library" + topics = ("circular buffer", "arduino", "data-structures") + license = "LGPL-3.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/rlogiacco/CircularBuffer" + no_copy_source = True + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def layout(self): + basic_layout(self, src_folder="src") + + def package(self): + copy(self, "LICENSE", dst=os.path.join(self.package_folder, + "licenses"), src=self.source_folder) + copy(self, "CircularBuffer.h", + dst=os.path.join(self.package_folder, "include"), src=self.source_folder) + copy(self, "CircularBuffer.tpp", + dst=os.path.join(self.package_folder, "include"), src=self.source_folder) + + def package_id(self): + self.info.clear() + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "CircularBuffer") + self.cpp_info.set_property( + "cmake_target_name", "CircularBuffer::CircularBuffer") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "CircularBuffer" + self.cpp_info.filenames["cmake_find_package_multi"] = "CircularBuffer" + self.cpp_info.names["cmake_find_package"] = "CircularBuffer" + self.cpp_info.names["cmake_find_package_multi"] = "CircularBuffer" diff --git a/recipes/circularbuffer/all/test_package/CMakeLists.txt b/recipes/circularbuffer/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d331e75f3a1ad --- /dev/null +++ b/recipes/circularbuffer/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + + +find_package(CircularBuffer CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE CircularBuffer::CircularBuffer) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/circularbuffer/all/test_package/conanfile.py b/recipes/circularbuffer/all/test_package/conanfile.py new file mode 100644 index 0000000000000..28cb4e311392b --- /dev/null +++ b/recipes/circularbuffer/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/circularbuffer/all/test_package/test_package.cpp b/recipes/circularbuffer/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..c9d59e4b258c6 --- /dev/null +++ b/recipes/circularbuffer/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include + +int main() { + CircularBuffer buffer; + + buffer.push(5); + buffer.unshift(1); + + return 0; +} diff --git a/recipes/circularbuffer/all/test_v1_package/CMakeLists.txt b/recipes/circularbuffer/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3ddfb18ba1fed --- /dev/null +++ b/recipes/circularbuffer/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ + +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CircularBuffer CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} CircularBuffer::CircularBuffer) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/circularbuffer/all/test_v1_package/conanfile.py b/recipes/circularbuffer/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..0a93a273ba575 --- /dev/null +++ b/recipes/circularbuffer/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/circularbuffer/all/test_v1_package/test_package.cpp b/recipes/circularbuffer/all/test_v1_package/test_package.cpp new file mode 100644 index 0000000000000..c9d59e4b258c6 --- /dev/null +++ b/recipes/circularbuffer/all/test_v1_package/test_package.cpp @@ -0,0 +1,10 @@ +#include + +int main() { + CircularBuffer buffer; + + buffer.push(5); + buffer.unshift(1); + + return 0; +} diff --git a/recipes/circularbuffer/config.yml b/recipes/circularbuffer/config.yml new file mode 100644 index 0000000000000..3abfca40293f6 --- /dev/null +++ b/recipes/circularbuffer/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3.3": + folder: all diff --git a/recipes/cista/all/conandata.yml b/recipes/cista/all/conandata.yml new file mode 100644 index 0000000000000..dd598e2bd2c5c --- /dev/null +++ b/recipes/cista/all/conandata.yml @@ -0,0 +1,21 @@ +sources: + "0.10": + - url: "https://github.com/felixguendling/cista/releases/download/v0.10/cista.h" + sha256: "c06162c73c0fb034170198d79940d2eeecc233140797ab7e3b66053d61a0169b" + - url: "https://raw.githubusercontent.com/felixguendling/cista/v0.10/LICENSE" + sha256: "fcd47e35fd6dc22feec454c5c1e572ccb7587dedd91d824528ebbb00a7f37c56" + "0.9": + - url: "https://github.com/felixguendling/cista/releases/download/v0.9/cista.h" + sha256: "e5401638eeb6d4bdaba6448de90663d9cc2c8d41d4e30c48c1fac4663e01f96d" + - url: "https://raw.githubusercontent.com/felixguendling/cista/v0.9/LICENSE" + sha256: "fcd47e35fd6dc22feec454c5c1e572ccb7587dedd91d824528ebbb00a7f37c56" + "0.8": + - url: "https://github.com/felixguendling/cista/releases/download/0.8/cista.h" + sha256: "1fc202033f3e33dc25bed3b75e8f6dc346f7c3b0a182ea675fc519d057d48777" + - url: "https://raw.githubusercontent.com/felixguendling/cista/0.8/LICENSE" + sha256: "fcd47e35fd6dc22feec454c5c1e572ccb7587dedd91d824528ebbb00a7f37c56" + "0.7": + - url: "https://github.com/felixguendling/cista/releases/download/v0.7/cista.h" + sha256: "10da0a23c4dd18fab87fa7c49cf6aa86cd8f17918930cad0331996f406719fae" + - url: "https://raw.githubusercontent.com/felixguendling/cista/v0.7/LICENSE" + sha256: "5db66757f5d9e791a8dcdca16dd59ad499dcfd9c245083bb7df93b20caa2bd55" diff --git a/recipes/cista/all/conanfile.py b/recipes/cista/all/conanfile.py new file mode 100644 index 0000000000000..6021efe7f6600 --- /dev/null +++ b/recipes/cista/all/conanfile.py @@ -0,0 +1,70 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, download +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class CistaConan(ConanFile): + name = "cista" + description = ( + "Cista++ is a simple, open source (MIT license) C++17 " + "compatible way of (de-)serializing C++ data structures." + ) + license = "MIT" + topics = ("cista", "serialization", "deserialization", "reflection") + homepage = "https://github.com/felixguendling/cista" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "15.7", + "gcc": "8", + "clang": "6", + "apple-clang": "9.1" + } + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 17) + + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), None) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++17, which your compiler does not support.", + ) + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + for file in self.conan_data["sources"][self.version]: + filename = os.path.basename(file["url"]) + download(self, filename=filename, **file) + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "cista.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "cista") + self.cpp_info.set_property("cmake_target_name", "cista::cista") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/cista/all/test_package/CMakeLists.txt b/recipes/cista/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d342da86f8d00 --- /dev/null +++ b/recipes/cista/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +find_package(cista REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cista::cista) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/cista/all/test_package/conanfile.py b/recipes/cista/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/cista/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cista/all/test_package/test_package.cpp b/recipes/cista/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..87833458476bb --- /dev/null +++ b/recipes/cista/all/test_package/test_package.cpp @@ -0,0 +1,28 @@ +#include + +struct pos { + int x; + int y; +}; + +namespace data = cista::offset; +using pos_map = data::hash_map, data::hash_set>; + +int main() { + constexpr auto const MODE = cista::mode::WITH_VERSION | cista::mode::WITH_INTEGRITY; + + { // Serialize + auto positions = pos_map{ + {{{1, 2}, {3, 4}}, {"hello", "cista"}}, + {{{5, 6}, {7, 8}}, {"hello", "world"}}, + }; + cista::buf mmap{cista::mmap{"data"}}; + cista::serialize(mmap, positions); + } + + // Deserialize. + auto b = cista::mmap("data", cista::mmap::protection::READ); + auto positions = cista::deserialize(b); + + return 0; +} diff --git a/recipes/cista/all/test_v1_package/CMakeLists.txt b/recipes/cista/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d27dfd94cab14 --- /dev/null +++ b/recipes/cista/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cista REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cista::cista) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/cista/all/test_v1_package/conanfile.py b/recipes/cista/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cista/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cista/config.yml b/recipes/cista/config.yml new file mode 100644 index 0000000000000..5808152f9189f --- /dev/null +++ b/recipes/cista/config.yml @@ -0,0 +1,9 @@ +versions: + "0.10": + folder: all + "0.9": + folder: all + "0.8": + folder: all + "0.7": + folder: all diff --git a/recipes/cityhash/all/conandata.yml b/recipes/cityhash/all/conandata.yml new file mode 100644 index 0000000000000..77c6f2317b0e8 --- /dev/null +++ b/recipes/cityhash/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20130801": + url: "https://github.com/google/cityhash/archive/8af9b8c2b889d80c22d6bc26ba0df1afb79a30db.zip" + sha256: "3524f5ed43143974a29fddeeece29c8b6348f05db08dd180452da01a2837ddce" diff --git a/recipes/cityhash/all/conanfile.py b/recipes/cityhash/all/conanfile.py new file mode 100644 index 0000000000000..35e373369c7eb --- /dev/null +++ b/recipes/cityhash/all/conanfile.py @@ -0,0 +1,115 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration +from contextlib import contextmanager +import functools +import os + +required_conan_version = ">=1.33.0" + + +class CityhashConan(ConanFile): + name = "cityhash" + description = "CityHash, a family of hash functions for strings." + license = "MIT" + topics = ("cityhash", "hash") + homepage = "https://github.com/google/cityhash" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self._is_msvc and self.options.shared: + raise ConanInvalidConfiguration("cityhash does not support shared builds with Visual Studio") + + def build_requirements(self): + self.build_requires("libtool/2.4.6") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @contextmanager + def _build_context(self): + if self._is_msvc: + with tools.vcvars(self): + env = { + "CC": "cl -nologo", + "CXX": "cl -nologo", + "LD": "link -nologo", + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), + } + with tools.environment_append(env): + yield + else: + yield + + @functools.lru_cache(1) + def _configure_autotools(self): + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-shared={}".format(yes_no(self.options.shared)), + ] + if self._is_msvc: + autotools.cxx_flags.append("-EHsc") + if not (self.settings.compiler == "Visual Studio" and \ + tools.Version(self.settings.compiler.version) < "12"): + autotools.flags.append("-FS") + autotools.configure(configure_dir=self._source_subfolder, args=args) + return autotools + + def build(self): + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + # relocatable shared lib on macOS + tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name @rpath/") + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["cityhash"] diff --git a/recipes/cityhash/all/test_package/CMakeLists.txt b/recipes/cityhash/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..895a4298a7cae --- /dev/null +++ b/recipes/cityhash/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cityhash REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} cityhash::cityhash) diff --git a/recipes/cityhash/all/test_package/conanfile.py b/recipes/cityhash/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cityhash/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cityhash/all/test_package/test_package.cpp b/recipes/cityhash/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..158134bbe3214 --- /dev/null +++ b/recipes/cityhash/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include + +#include + +int main() { + std::cout << CityHash64("conan-center-index", 18) << std::endl; + return 0; +} diff --git a/recipes/cityhash/config.yml b/recipes/cityhash/config.yml new file mode 100644 index 0000000000000..489bded5765de --- /dev/null +++ b/recipes/cityhash/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20130801": + folder: all diff --git a/recipes/civetweb/all/conandata.yml b/recipes/civetweb/all/conandata.yml index e37373a7ae1f3..695402c1a57a4 100644 --- a/recipes/civetweb/all/conandata.yml +++ b/recipes/civetweb/all/conandata.yml @@ -1,4 +1,15 @@ sources: + "1.15": + url: "https://github.com/civetweb/civetweb/archive/v1.15.tar.gz" + sha256: "90a533422944ab327a4fbb9969f0845d0dba05354f9cacce3a5005fa59f593b9" + "1.14": + url: "https://github.com/civetweb/civetweb/archive/v1.14.tar.gz" + sha256: "d02d7ab091c8b4edf21fc13a03c6db08a8a8b8605e35e0073251b9d88443c653" "1.13": url: "https://github.com/civetweb/civetweb/archive/v1.13.tar.gz" sha256: "a7ccc76c2f1b5f4e8d855eb328ed542f8fe3b882a6da868781799a98f4acdedc" +patches: + "1.14": + - patch_file: "patches/0001-fix-install-bundle.patch" + "1.13": + - patch_file: "patches/0001-fix-install-bundle.patch" diff --git a/recipes/civetweb/all/conanfile.py b/recipes/civetweb/all/conanfile.py index be0f0b9c13ee7..fd01f187e2af3 100644 --- a/recipes/civetweb/all/conanfile.py +++ b/recipes/civetweb/all/conanfile.py @@ -1,8 +1,11 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import export_conandata_patches, apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout import os -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.52.0" class CivetwebConan(ConanFile): @@ -11,92 +14,138 @@ class CivetwebConan(ConanFile): homepage = "https://github.com/civetweb/civetweb" url = "https://github.com/conan-io/conan-center-index" description = "Embedded C/C++ web server" - topics = ("conan", "civetweb", "web-server", "embedded") - exports_sources = ["CMakeLists.txt"] - generators = "cmake", "cmake_find_package" - settings = "os", "compiler", "build_type", "arch" + topics = ("web-server", "embedded") + + settings = "os", "arch", "compiler", "build_type" options = { - "shared" : [True, False], - "fPIC" : [True, False], - "with_ssl" : [True, False], + "fPIC": [True, False], + "shared": [True, False], "ssl_dynamic_loading": [True, False], - "with_websockets" : [True, False], - "with_ipv6" : [True, False], - "with_cxx" : [True, False] + "with_caching": [True, False], + "with_cgi": [True, False], + "with_cxx": [True, False], + "with_duktape": [True, False], + "with_ipv6": [True, False], + "with_lua": [True, False], + "with_server_stats": [True, False], + "with_ssl": [True, False], + "with_static_files": [True, False], + "with_third_party_output": [True, False], + "with_websockets": [True, False], + "with_zlib": [True, False], } default_options = { - "shared" : False, - "fPIC" : True, - "with_ssl" : True, + "fPIC": True, + "shared": False, "ssl_dynamic_loading": False, - "with_websockets" : True, - "with_ipv6" : True, - "with_cxx" : True + "with_caching": True, + "with_cgi": True, + "with_cxx": True, + "with_duktape": False, + "with_ipv6": True, + "with_lua": False, + "with_server_stats": False, + "with_ssl": True, + "with_static_files": True, + "with_third_party_output": False, + "with_websockets": True, + "with_zlib": False, } - _cmake = None + no_copy_source = True @property - def _source_subfolder(self): - return "source_subfolder" + def _has_zlib_option(self): + return Version(self.version) >= "1.15" - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if not self._has_zlib_option: + del self.options.with_zlib def configure(self): if self.options.shared: - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass if not self.options.with_cxx: - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass if not self.options.with_ssl: del self.options.ssl_dynamic_loading def requirements(self): if self.options.with_ssl: - self.requires("openssl/1.1.1j") + self.requires("openssl/1.1.1s") + if self.options.get_safe("with_zlib"): + self.requires("zlib/1.2.13") def validate(self): if self.options.get_safe("ssl_dynamic_loading") and not self.options["openssl"].shared: raise ConanInvalidConfiguration("ssl_dynamic_loading requires shared openssl") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("civetweb-%s" % self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CIVETWEB_ENABLE_SSL"] = self.options.with_ssl + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + if self.options.with_ssl: - openssl_version = tools.Version(self.deps_cpp_info["openssl"].version[:-1]) - self._cmake.definitions["CIVETWEB_SSL_OPENSSL_API_1_0"] = openssl_version.minor == "0" - self._cmake.definitions["CIVETWEB_SSL_OPENSSL_API_1_1"] = openssl_version.minor == "1" - self._cmake.definitions["CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING"] = self.options.ssl_dynamic_loading - self._cmake.definitions["CIVETWEB_ENABLE_WEBSOCKETS"] = self.options.with_websockets - self._cmake.definitions["CIVETWEB_ENABLE_IPV6"] = self.options.with_ipv6 - self._cmake.definitions["CIVETWEB_ENABLE_CXX"] = self.options.with_cxx - self._cmake.definitions["CIVETWEB_BUILD_TESTING"] = False - self._cmake.definitions["CIVETWEB_ENABLE_ASAN"] = False - self._cmake.definitions["CIVETWEB_CXX_ENABLE_LTO"] = False - self._cmake.configure(build_dir=self._build_subfolder) - return self._cmake + openssl_version = Version(self.dependencies["openssl"].ref.version[:-1]) + tc.variables["CIVETWEB_ENABLE_SSL"] = self.options.with_ssl + tc.variables["CIVETWEB_ENABLE_SSL_DYNAMIC_LOADING"] = self.options.ssl_dynamic_loading + tc.variables["CIVETWEB_SSL_OPENSSL_API_1_0"] = openssl_version.minor == "0" + tc.variables["CIVETWEB_SSL_OPENSSL_API_1_1"] = openssl_version.minor == "1" + + tc.variables["CIVETWEB_BUILD_TESTING"] = False + tc.variables["CIVETWEB_CXX_ENABLE_LTO"] = False + tc.variables["CIVETWEB_ENABLE_ASAN"] = False + + tc.variables["CIVETWEB_DISABLE_CACHING"] = not self.options.with_caching + tc.variables["CIVETWEB_DISABLE_CGI"] = not self.options.with_cgi + tc.variables["CIVETWEB_ENABLE_CXX"] = self.options.with_cxx + tc.variables["CIVETWEB_ENABLE_DUKTAPE"] = self.options.with_duktape + tc.variables["CIVETWEB_ENABLE_IPV6"] = self.options.with_ipv6 + tc.variables["CIVETWEB_ENABLE_LUA"] = self.options.with_lua + tc.variables["CIVETWEB_ENABLE_SERVER_STATS"] = self.options.with_server_stats + tc.variables["CIVETWEB_ENABLE_THIRD_PARTY_OUTPUT"] = self.options.with_third_party_output + tc.variables["CIVETWEB_ENABLE_WEBSOCKETS"] = self.options.with_websockets + tc.variables["CIVETWEB_SERVE_NO_FILES"] = not self.options.with_static_files + + if self._has_zlib_option: + tc.variables["CIVETWEB_ENABLE_ZLIB"] = self.options.with_zlib + + tc.generate() + + cd = CMakeDeps(self) + cd.generate() def build(self): - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(os.path.join(self._source_subfolder, "LICENSE.md"), dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.configure() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) bin_folder = os.path.join(self.package_folder, "bin") for bin_file in os.listdir(bin_folder): if not bin_file.startswith("civetweb"): @@ -105,8 +154,11 @@ def package(self): def package_info(self): self.cpp_info.names["cmake_find_package"] = "civetweb" self.cpp_info.names["cmake_find_package_multi"] = "civetweb" + self.cpp_info.set_property("cmake_file_name", "civetweb") + self.cpp_info.set_property("cmake_target_name", "civetweb::civetweb") self.cpp_info.components["_civetweb"].names["cmake_find_package"] = "civetweb" self.cpp_info.components["_civetweb"].names["cmake_find_package_multi"] = "civetweb" + self.cpp_info.components["_civetweb"].set_property("cmake_target_name", "civetweb::civetweb") self.cpp_info.components["_civetweb"].libs = ["civetweb"] if self.settings.os == "Linux": self.cpp_info.components["_civetweb"].system_libs.extend(["rt", "pthread"]) @@ -118,12 +170,16 @@ def package_info(self): self.cpp_info.components["_civetweb"].system_libs.append("ws2_32") if self.options.shared: self.cpp_info.components["_civetweb"].defines.append("CIVETWEB_DLL_IMPORTS") + if self.options.with_ssl: - self.cpp_info.components["_civetweb"].requires = ["openssl::openssl"] + self.cpp_info.components["_civetweb"].requires.append("openssl::openssl") + if self.options.get_safe("with_zlib"): + self.cpp_info.components["_civetweb"].requires.append("zlib::zlib") if self.options.with_cxx: self.cpp_info.components["civetweb-cpp"].names["cmake_find_package"] = "civetweb-cpp" self.cpp_info.components["civetweb-cpp"].names["cmake_find_package_multi"] = "civetweb-cpp" + self.cpp_info.components["civetweb-cpp"].set_property("cmake_target_name", "civetweb::civetweb-cpp") self.cpp_info.components["civetweb-cpp"].libs = ["civetweb-cpp"] self.cpp_info.components["civetweb-cpp"].requires = ["_civetweb"] if self.settings.os == "Linux": diff --git a/recipes/civetweb/all/patches/0001-fix-install-bundle.patch b/recipes/civetweb/all/patches/0001-fix-install-bundle.patch new file mode 100644 index 0000000000000..0dcd4902b8e19 --- /dev/null +++ b/recipes/civetweb/all/patches/0001-fix-install-bundle.patch @@ -0,0 +1,13 @@ +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -257,9 +257,7 @@ if (CIVETWEB_ENABLE_SERVER_EXECUTABLE) + install( + TARGETS civetweb-c-executable + EXPORT ${PROJECT_NAME}-targets +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT server) + endif() + target_include_directories( diff --git a/recipes/civetweb/all/test_package/CMakeLists.txt b/recipes/civetweb/all/test_package/CMakeLists.txt index 7557711b6dc83..8ec3a0b53c970 100644 --- a/recipes/civetweb/all/test_package/CMakeLists.txt +++ b/recipes/civetweb/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(civetweb REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} civetweb::civetweb) diff --git a/recipes/civetweb/all/test_package/conanfile.py b/recipes/civetweb/all/test_package/conanfile.py index 6e3e368f36fa1..1a993f797dc27 100644 --- a/recipes/civetweb/all/test_package/conanfile.py +++ b/recipes/civetweb/all/test_package/conanfile.py @@ -1,10 +1,17 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, tools, CMake - class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +19,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/civetweb/all/test_v1_package/CMakeLists.txt b/recipes/civetweb/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b6a8217aa2b62 --- /dev/null +++ b/recipes/civetweb/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(civetweb CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} civetweb::civetweb) diff --git a/recipes/civetweb/all/test_v1_package/conanfile.py b/recipes/civetweb/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..6f09f10193d23 --- /dev/null +++ b/recipes/civetweb/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, tools, CMake + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/civetweb/all/test_v1_package/test_package.cpp b/recipes/civetweb/all/test_v1_package/test_package.cpp new file mode 100644 index 0000000000000..a8f94d139a8db --- /dev/null +++ b/recipes/civetweb/all/test_v1_package/test_package.cpp @@ -0,0 +1,7 @@ +#include "civetweb.h" + +int main(int argc, char *argv[]) +{ + mg_init_library(0); + return 0; +} diff --git a/recipes/civetweb/config.yml b/recipes/civetweb/config.yml index 48dc233badeb6..1d382163182dc 100644 --- a/recipes/civetweb/config.yml +++ b/recipes/civetweb/config.yml @@ -1,3 +1,7 @@ versions: + "1.15": + folder: all + "1.14": + folder: all "1.13": folder: all diff --git a/recipes/cjson/all/CMakeLists.txt b/recipes/cjson/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/cjson/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/cjson/all/conandata.yml b/recipes/cjson/all/conandata.yml index c24244e3027ab..397bb216165bb 100644 --- a/recipes/cjson/all/conandata.yml +++ b/recipes/cjson/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.7.15": + url: "https://github.com/DaveGamble/cJSON/archive/v1.7.15.tar.gz" + sha256: "5308fd4bd90cef7aa060558514de6a1a4a0819974a26e6ed13973c5f624c24b2" "1.7.14": url: "https://github.com/DaveGamble/cJSON/archive/v1.7.14.tar.gz" sha256: "fb50a663eefdc76bafa80c82bc045af13b1363e8f45cec8b442007aef6a41343" @@ -11,4 +14,3 @@ sources: patches: "1.7.12": - patch_file: "patches/fix-cmake-install.patch" - base_path: "source_subfolder" diff --git a/recipes/cjson/all/conanfile.py b/recipes/cjson/all/conanfile.py index e1cee6c7ed1bf..8b410ba909952 100644 --- a/recipes/cjson/all/conanfile.py +++ b/recipes/cjson/all/conanfile.py @@ -1,43 +1,38 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.53.0" class CjsonConan(ConanFile): name = "cjson" description = "Ultralightweight JSON parser in ANSI C." license = "MIT" - topics = ("conan", "cjson", "json", "parser") + topics = ("json", "parser") homepage = "https://github.com/DaveGamble/cJSON" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "utils": [True, False], - "use_locales": [True, False] + "use_locales": [True, False], } default_options = { "shared": False, "fPIC": True, "utils": False, - "use_locales": True + "use_locales": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -45,99 +40,104 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.settings.compiler == "Visual Studio" and self.options.shared and self.settings.compiler.runtime == "MTd": - raise ConanInvalidConfiguration("shared cjson is not supported with MTd runtime") + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.options.shared and is_msvc(self) and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration("shared cjson is not supported with MT runtime") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("cJSON-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_SANITIZERS"] = False + tc.variables["ENABLE_SAFE_STACK"] = False + tc.variables["ENABLE_PUBLIC_SYMBOLS"] = True + tc.variables["ENABLE_HIDDEN_SYMBOLS"] = False + tc.variables["ENABLE_TARGET_EXPORT"] = False + tc.variables["BUILD_SHARED_AND_STATIC_LIBS"] = False + tc.variables["CJSON_OVERRIDE_BUILD_SHARED_LIBS"] = False + tc.variables["ENABLE_CJSON_UTILS"] = self.options.utils + tc.variables["ENABLE_CJSON_TEST"] = False + tc.variables["ENABLE_LOCALES"] = self.options.use_locales + tc.variables["ENABLE_FUZZING"] = False + tc.variables["ENABLE_CUSTOM_COMPILER_FLAGS"] = False + # Relocatable shared libs on macOS + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_SANITIZERS"] = False - self._cmake.definitions["ENABLE_SAFE_STACK"] = False - self._cmake.definitions["ENABLE_PUBLIC_SYMBOLS"] = True - self._cmake.definitions["ENABLE_HIDDEN_SYMBOLS"] = False - self._cmake.definitions["ENABLE_TARGET_EXPORT"] = False - self._cmake.definitions["BUILD_SHARED_AND_STATIC_LIBS"] = False - self._cmake.definitions["CJSON_OVERRIDE_BUILD_SHARED_LIBS"] = False - self._cmake.definitions["ENABLE_CJSON_UTILS"] = self.options.utils - self._cmake.definitions["ENABLE_CJSON_TEST"] = False - self._cmake.definitions["ENABLE_LOCALES"] = self.options.use_locales - self._cmake.definitions["ENABLE_FUZZING"] = False - self._cmake.definitions["ENABLE_CUSTOM_COMPILER_FLAGS"] = False - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed targets = {"cjson": "cJSON::cjson"} if self.options.utils: targets.update({"cjson_utils": "cJSON::cjson_utils"}) self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._module_subfolder, self._module_file), + os.path.join(self.package_folder, self._module_file_rel_path), targets ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + """) + save(self, module_file, content) @property - def _module_file(self): - return "conan-official-{}-targets.cmake".format(self.name) + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.names["cmake_find_package"] = "cJSON" - self.cpp_info.names["cmake_find_package_multi"] = "cJSON" + self.cpp_info.set_property("cmake_file_name", "cJSON") - module_target_rel_path = os.path.join(self._module_subfolder, self._module_file) + self.cpp_info.components["_cjson"].set_property("cmake_target_name", "cjson") + self.cpp_info.components["_cjson"].set_property("pkg_config_name", "libcjson") + self.cpp_info.components["_cjson"].libs = ["cjson"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["_cjson"].system_libs = ["m"] + if self.options.utils: + self.cpp_info.components["cjson_utils"].set_property("cmake_target_name", "cjson_utils") + self.cpp_info.components["cjson_utils"].set_property("pkg_config_name", "libcjson_utils") + self.cpp_info.components["cjson_utils"].libs = ["cjson_utils"] + self.cpp_info.components["cjson_utils"].requires = ["_cjson"] + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "cJSON" + self.cpp_info.names["cmake_find_package_multi"] = "cJSON" self.cpp_info.components["_cjson"].names["cmake_find_package"] = "cjson" self.cpp_info.components["_cjson"].names["cmake_find_package_multi"] = "cjson" + self.cpp_info.components["_cjson"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["_cjson"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] self.cpp_info.components["_cjson"].names["pkg_config"] = "libcjson" - self.cpp_info.components["_cjson"].libs = ["cjson"] - self.cpp_info.components["_cjson"].builddirs.append(self._module_subfolder) - self.cpp_info.components["_cjson"].build_modules["cmake_find_package"] = [module_target_rel_path] - self.cpp_info.components["_cjson"].build_modules["cmake_find_package_multi"] = [module_target_rel_path] - if self.settings.os == "Linux": - self.cpp_info.components["_cjson"].system_libs = ["m"] - if self.options.utils: self.cpp_info.components["cjson_utils"].names["cmake_find_package"] = "cjson_utils" self.cpp_info.components["cjson_utils"].names["cmake_find_package_multi"] = "cjson_utils" + self.cpp_info.components["cjson_utils"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["cjson_utils"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] self.cpp_info.components["cjson_utils"].names["pkg_config"] = "libcjson_utils" - self.cpp_info.components["cjson_utils"].libs = ["cjson_utils"] - self.cpp_info.components["cjson_utils"].requires = ["_cjson"] - self.cpp_info.components["cjson_utils"].builddirs.append(self._module_subfolder) - self.cpp_info.components["cjson_utils"].build_modules["cmake_find_package"] = [module_target_rel_path] - self.cpp_info.components["cjson_utils"].build_modules["cmake_find_package_multi"] = [module_target_rel_path] diff --git a/recipes/cjson/all/test_package/CMakeLists.txt b/recipes/cjson/all/test_package/CMakeLists.txt index b6229ac11cea5..84258514da5b3 100644 --- a/recipes/cjson/all/test_package/CMakeLists.txt +++ b/recipes/cjson/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(cJSON REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} cjson) +target_link_libraries(${PROJECT_NAME} PRIVATE cjson) diff --git a/recipes/cjson/all/test_package/conanfile.py b/recipes/cjson/all/test_package/conanfile.py index 84ee68733e516..0a6bc68712d90 100644 --- a/recipes/cjson/all/test_package/conanfile.py +++ b/recipes/cjson/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cjson/all/test_v1_package/CMakeLists.txt b/recipes/cjson/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/cjson/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/cjson/all/test_v1_package/conanfile.py b/recipes/cjson/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cjson/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cjson/config.yml b/recipes/cjson/config.yml index 9fece68d6d082..894ac0453b1d4 100644 --- a/recipes/cjson/config.yml +++ b/recipes/cjson/config.yml @@ -1,4 +1,6 @@ versions: + "1.7.15": + folder: all "1.7.14": folder: all "1.7.13": diff --git a/recipes/clara/all/conanfile.py b/recipes/clara/all/conanfile.py index beed2eaac8fda..8e0af90e17b97 100644 --- a/recipes/clara/all/conanfile.py +++ b/recipes/clara/all/conanfile.py @@ -1,29 +1,33 @@ import os -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import get, copy +from conan.tools.layout import basic_layout -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.46.0" class ClaraConan(ConanFile): name = "clara" description = "A simple to use, composable, command line parser for C++ 11 and beyond" homepage = "https://github.com/catchorg/Clara" - topics = ("conan", "clara", "cli", "cpp11", "command-parser") + topics = ("clara", "cli", "cpp11", "command-parser") + settings = "os", "arch", "compiler", "build_type" url = "https://github.com/conan-io/conan-center-index" license = "BSL-1.0" no_copy_source = True deprecated = "lyra" - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + basic_layout(self) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("Clara-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) def package(self): - self.copy(pattern="LICENSE.txt", src=self._source_subfolder, dst="licenses") - self.copy(pattern="*", src=os.path.join(self._source_subfolder, "include"), dst="include", keep_path=True) + copy(self, "LICENSE.txt", src=self.source_folder, + dst=os.path.join(self.package_folder, "licenses")) + copy(self, pattern="*", + src=os.path.join(self.source_folder, "include"), + dst=os.path.join(self.package_folder, "include"), keep_path=True) def package_id(self): - self.info.header_only() + self.info.clear() diff --git a/recipes/clara/all/test_package/CMakeLists.txt b/recipes/clara/all/test_package/CMakeLists.txt index 33ae887aa6aea..1f340c9983632 100644 --- a/recipes/clara/all/test_package/CMakeLists.txt +++ b/recipes/clara/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) # if the project uses c++ -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(clara REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE clara::clara) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/clara/all/test_package/conanfile.py b/recipes/clara/all/test_package/conanfile.py index 3f668ebf0acf9..9ff0633c99a01 100644 --- a/recipes/clara/all/test_package/conanfile.py +++ b/recipes/clara/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,7 +21,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run("{} --width 640".format(bin_path), run_environment=True) - self.run("{} --help".format(bin_path), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run("{} --width 640".format(bin_path), env="conanrun") + self.run("{} --help".format(bin_path), env="conanrun") diff --git a/recipes/clara/all/test_v1_package/CMakeLists.txt b/recipes/clara/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/clara/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/clara/all/test_v1_package/conanfile.py b/recipes/clara/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2489ddc6e36c1 --- /dev/null +++ b/recipes/clara/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run("{} --width 640".format(bin_path), run_environment=True) + self.run("{} --help".format(bin_path), run_environment=True) diff --git a/recipes/clhep/all/CMakeLists.txt b/recipes/clhep/all/CMakeLists.txt deleted file mode 100644 index cb292635a3e38..0000000000000 --- a/recipes/clhep/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder/CLHEP") diff --git a/recipes/clhep/all/conandata.yml b/recipes/clhep/all/conandata.yml index fe4b0c678d141..2745e50b6c689 100644 --- a/recipes/clhep/all/conandata.yml +++ b/recipes/clhep/all/conandata.yml @@ -5,8 +5,5 @@ sources: patches: "2.4.1.3": - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" - patch_file: "patches/mingw-support.patch" - base_path: "source_subfolder" - patch_file: "patches/msvc-2015-no-SFINAE.patch" - base_path: "source_subfolder" diff --git a/recipes/clhep/all/conanfile.py b/recipes/clhep/all/conanfile.py index a724be1c9d1d3..71922771f6947 100644 --- a/recipes/clhep/all/conanfile.py +++ b/recipes/clhep/all/conanfile.py @@ -1,31 +1,37 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.microsoft import is_msvc import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.50.0" + class ClhepConan(ConanFile): name = "clhep" description = "Class Library for High Energy Physics." license = "LGPL-3.0-only" - topics = ("conan", "clhep", "cern", "hep", "high energy", "physics", "geometry", "algebra") + topics = ("clhep", "cern", "hep", "high energy", "physics", "geometry", "algebra") homepage = "http://proj-clhep.web.cern.ch/proj-clhep" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" - short_paths = True - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - _cmake = None + short_paths = True - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -34,126 +40,92 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) - if self.settings.compiler == "Visual Studio" and self.options.shared: + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + if is_msvc(self) and self.info.options.shared: raise ConanInvalidConfiguration("CLHEP doesn't properly build its shared libs with Visual Studio") + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CLHEP_SINGLE_THREAD"] = False + tc.variables["CLHEP_BUILD_DOCS"] = False + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "CLHEP")) cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CLHEP_SINGLE_THREAD"] = False - self._cmake.definitions["CLHEP_BUILD_DOCS"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy(pattern="COPYING*", dst="licenses", src=os.path.join(self._source_subfolder, "CLHEP")) - cmake = self._configure_cmake() + copy(self, "COPYING*", src=os.path.join(self.source_folder, "CLHEP"), dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() + @property + def _clhep_components(self): + def libm(): + return ["m"] if self.settings.os in ["Linux", "FreeBSD"] else [] + + def pthread(): + return ["pthread"] if self.settings.os in ["Linux", "FreeBSD"] else [] + + return [ + {"name": "Vector", "system_libs": libm() + pthread()}, + {"name": "Evaluator", "system_libs": libm() + pthread()}, + {"name": "GenericFunctions", "system_libs": libm() + pthread()}, + {"name": "Geometry", "system_libs": libm() + pthread(), "requires": ["vector"]}, + {"name": "Random", "system_libs": libm() + pthread()}, + {"name": "Matrix", "system_libs": libm() + pthread(), "requires": ["random", "vector"]}, + {"name": "RandomObjects", "system_libs": libm(), "requires": ["random", "matrix", "vector"]}, + {"name": "Cast", "system_libs": pthread()}, + {"name": "RefCount", "system_libs": pthread()}, + {"name": "Exceptions", "requires": ["cast", "refcount"]}, + ] + def package_info(self): + suffix = "" if self.options.shared else "S" + + self.cpp_info.set_property("cmake_file_name", "CLHEP") + self.cpp_info.set_property("cmake_target_name", f"CLHEP::CLHEP{suffix}") + self.cpp_info.set_property("pkg_config_name", "clhep") + + for component in self._clhep_components: + name = component["name"] + conan_comp = name.lower() + cmake_target = f"{name}{suffix}" + pkg_config_name = f"clhep-{name.lower()}" + lib_name = f"CLHEP-{name}-{self.version}" + system_libs = component.get("system_libs", []) + requires = component.get("requires", []) + + self.cpp_info.components[conan_comp].set_property("cmake_target_name", f"CLHEP::{cmake_target}") + self.cpp_info.components[conan_comp].set_property("pkg_config_name", pkg_config_name) + self.cpp_info.components[conan_comp].libs = [lib_name] + self.cpp_info.components[conan_comp].system_libs = system_libs + self.cpp_info.components[conan_comp].requires = requires + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.components[conan_comp].names["cmake_find_package"] = cmake_target + self.cpp_info.components[conan_comp].names["cmake_find_package_multi"] = cmake_target + self.cpp_info.components[conan_comp].names["pkg_config"] = pkg_config_name + self.cpp_info.components["clheplib"].requires.append(conan_comp) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "CLHEP" self.cpp_info.names["cmake_find_package_multi"] = "CLHEP" self.cpp_info.names["pkg_config"] = "clhep" - # Vector - vector_cmake = "Vector" if self.options.shared else "VectorS" - self.cpp_info.components["vector"].names["cmake_find_package"] = vector_cmake - self.cpp_info.components["vector"].names["cmake_find_package_multi"] = vector_cmake - self.cpp_info.components["vector"].names["pkg_config"] = "clhep-vector" - self.cpp_info.components["vector"].libs = ["CLHEP-Vector-" + self.version] - if self.settings.os == "Linux": - self.cpp_info.components["vector"].system_libs = ["m", "pthread"] - # Evaluator - evaluator_cmake = "Evaluator" if self.options.shared else "EvaluatorS" - self.cpp_info.components["evaluator"].names["cmake_find_package"] = evaluator_cmake - self.cpp_info.components["evaluator"].names["cmake_find_package_multi"] = evaluator_cmake - self.cpp_info.components["evaluator"].names["pkg_config"] = "clhep-evaluator" - self.cpp_info.components["evaluator"].libs = ["CLHEP-Evaluator-" + self.version] - if self.settings.os == "Linux": - self.cpp_info.components["evaluator"].system_libs = ["m", "pthread"] - # GenericFunctions - genericfunctions_cmake = "GenericFunctions" if self.options.shared else "GenericFunctionsS" - self.cpp_info.components["genericfunctions"].names["cmake_find_package"] = genericfunctions_cmake - self.cpp_info.components["genericfunctions"].names["cmake_find_package_multi"] = genericfunctions_cmake - self.cpp_info.components["genericfunctions"].names["pkg_config"] = "clhep-genericfunctions" - self.cpp_info.components["genericfunctions"].libs = ["CLHEP-GenericFunctions-" + self.version] - if self.settings.os == "Linux": - self.cpp_info.components["genericfunctions"].system_libs = ["m", "pthread"] - # Geometry - geometry_cmake = "Geometry" if self.options.shared else "GeometryS" - self.cpp_info.components["geometry"].names["cmake_find_package"] = geometry_cmake - self.cpp_info.components["geometry"].names["cmake_find_package_multi"] = geometry_cmake - self.cpp_info.components["geometry"].names["pkg_config"] = "clhep-geometry" - self.cpp_info.components["geometry"].libs = ["CLHEP-Geometry-" + self.version] - if self.settings.os == "Linux": - self.cpp_info.components["geometry"].system_libs = ["m", "pthread"] - self.cpp_info.components["geometry"].requires = ["vector"] - # Random - random_cmake = "Random" if self.options.shared else "RandomS" - self.cpp_info.components["random"].names["cmake_find_package"] = random_cmake - self.cpp_info.components["random"].names["cmake_find_package_multi"] = random_cmake - self.cpp_info.components["random"].names["pkg_config"] = "clhep-random" - self.cpp_info.components["random"].libs = ["CLHEP-Random-" + self.version] - if self.settings.os == "Linux": - self.cpp_info.components["random"].system_libs = ["m", "pthread"] - # Matrix - matrix_cmake = "Matrix" if self.options.shared else "MatrixS" - self.cpp_info.components["matrix"].names["cmake_find_package"] = matrix_cmake - self.cpp_info.components["matrix"].names["cmake_find_package_multi"] = matrix_cmake - self.cpp_info.components["matrix"].names["pkg_config"] = "clhep-matrix" - self.cpp_info.components["matrix"].libs = ["CLHEP-Matrix-" + self.version] - if self.settings.os == "Linux": - self.cpp_info.components["matrix"].system_libs = ["m", "pthread"] - self.cpp_info.components["matrix"].requires = ["random", "vector"] - # RandomObjects - randomobjects_cmake = "RandomObjects" if self.options.shared else "RandomObjectsS" - self.cpp_info.components["randomobjects"].names["cmake_find_package"] = randomobjects_cmake - self.cpp_info.components["randomobjects"].names["cmake_find_package_multi"] = randomobjects_cmake - self.cpp_info.components["randomobjects"].names["pkg_config"] = "clhep-randomobjects" - self.cpp_info.components["randomobjects"].libs = ["CLHEP-RandomObjects-" + self.version] - if self.settings.os == "Linux": - self.cpp_info.components["randomobjects"].system_libs = ["m"] - self.cpp_info.components["randomobjects"].requires = ["random", "matrix", "vector"] - # Cast - cast_cmake = "Cast" if self.options.shared else "CastS" - self.cpp_info.components["cast"].names["cmake_find_package"] = cast_cmake - self.cpp_info.components["cast"].names["cmake_find_package_multi"] = cast_cmake - self.cpp_info.components["cast"].names["pkg_config"] = "clhep-cast" - self.cpp_info.components["cast"].libs = ["CLHEP-Cast-" + self.version] - if self.settings.os == "Linux": - self.cpp_info.components["cast"].system_libs = ["pthread"] - # RefCount - refcount_cmake = "RefCount" if self.options.shared else "RefCountS" - self.cpp_info.components["refcount"].names["cmake_find_package"] = refcount_cmake - self.cpp_info.components["refcount"].names["cmake_find_package_multi"] = refcount_cmake - self.cpp_info.components["refcount"].names["pkg_config"] = "clhep-refcount" - self.cpp_info.components["refcount"].libs = ["CLHEP-RefCount-" + self.version] - if self.settings.os == "Linux": - self.cpp_info.components["refcount"].system_libs = ["pthread"] - # Exceptions - exceptions_cmake = "Exceptions" if self.options.shared else "ExceptionsS" - self.cpp_info.components["exceptions"].names["cmake_find_package"] = exceptions_cmake - self.cpp_info.components["exceptions"].names["cmake_find_package_multi"] = exceptions_cmake - self.cpp_info.components["exceptions"].names["pkg_config"] = "clhep-exceptions" - self.cpp_info.components["exceptions"].libs = ["CLHEP-Exceptions-" + self.version] - self.cpp_info.components["exceptions"].requires = ["cast", "refcount"] - # CLHEP (global imported target including all CLHEP components) - global_cmake = "CLHEP" if self.options.shared else "CLHEPS" - self.cpp_info.components["clheplib"].names["cmake_find_package"] = global_cmake - self.cpp_info.components["clheplib"].names["cmake_find_package_multi"] = global_cmake - self.cpp_info.components["clheplib"].requires = [ - "vector", "evaluator", "genericfunctions", "geometry", "random", - "matrix", "randomobjects", "cast", "refcount", "exceptions" - ] + self.cpp_info.components["clheplib"].names["cmake_find_package"] = f"CLHEP{suffix}" + self.cpp_info.components["clheplib"].names["cmake_find_package_multi"] = f"CLHEP{suffix}" + self.cpp_info.components["clheplib"].set_property("cmake_target_name", f"CLHEP::CLHEP{suffix}") + self.cpp_info.components["clheplib"].names["pkg_config"] = "clhep" + self.cpp_info.components["clheplib"].set_property("pkg_config_name", "clhep") diff --git a/recipes/clhep/all/test_package/CMakeLists.txt b/recipes/clhep/all/test_package/CMakeLists.txt index 0cf68593b72d5..a757fede3cd0c 100644 --- a/recipes/clhep/all/test_package/CMakeLists.txt +++ b/recipes/clhep/all/test_package/CMakeLists.txt @@ -1,15 +1,12 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(CLHEP REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) -if(CLHEP_SHARED) - target_link_libraries(${PROJECT_NAME} CLHEP::CLHEP) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +if(TARGET CLHEP::CLHEPS) + target_link_libraries(${PROJECT_NAME} PRIVATE CLHEP::CLHEPS) else() - target_link_libraries(${PROJECT_NAME} CLHEP::CLHEPS) + target_link_libraries(${PROJECT_NAME} PRIVATE CLHEP::CLHEP) endif() diff --git a/recipes/clhep/all/test_package/conanfile.py b/recipes/clhep/all/test_package/conanfile.py index 5bbdd633539eb..3a8c6c5442b33 100644 --- a/recipes/clhep/all/test_package/conanfile.py +++ b/recipes/clhep/all/test_package/conanfile.py @@ -1,18 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) - cmake.definitions["CLHEP_SHARED"] = self.options["clhep"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/clhep/all/test_v1_package/CMakeLists.txt b/recipes/clhep/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d579da155e563 --- /dev/null +++ b/recipes/clhep/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CLHEP REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +if(TARGET CLHEP::CLHEPS) + target_link_libraries(${PROJECT_NAME} PRIVATE CLHEP::CLHEPS) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE CLHEP::CLHEP) +endif() diff --git a/recipes/clhep/all/test_v1_package/conanfile.py b/recipes/clhep/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/clhep/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cli11/all/conandata.yml b/recipes/cli11/all/conandata.yml index ceab99ad3069f..36add26ccbad7 100644 --- a/recipes/cli11/all/conandata.yml +++ b/recipes/cli11/all/conandata.yml @@ -1,4 +1,22 @@ sources: + "2.3.1": + url: "https://github.com/CLIUtils/CLI11/archive/v2.3.1.tar.gz" + sha256: "378da73d2d1d9a7b82ad6ed2b5bda3e7bc7093c4034a1d680a2e009eb067e7b2" + "2.3.0": + url: "https://github.com/CLIUtils/CLI11/archive/v2.3.0.tar.gz" + sha256: "b6e116ca1555e2b7f2743fd41e3bd18149baae791acd98eb653e5b07e0f20561" + "2.2.0": + url: "https://github.com/CLIUtils/CLI11/archive/v2.2.0.tar.gz" + sha256: "d60440dc4d43255f872d174e416705f56ba40589f6eb07727f76376fb8378fd6" + "2.1.2": + url: "https://github.com/CLIUtils/CLI11/archive/v2.1.2.tar.gz" + sha256: "26291377e892ba0e5b4972cdfd4a2ab3bf53af8dac1f4ea8fe0d1376b625c8cb" + "2.1.1": + url: "https://github.com/CLIUtils/CLI11/archive/v2.1.1.tar.gz" + sha256: "d69023d1d0ab6a22be86b4f59d449422bc5efd9121868f4e284d6042e52f682e" + "2.0.0": + url: "https://github.com/CLIUtils/CLI11/archive/v2.0.0.tar.gz" + sha256: "2c672f17bf56e8e6223a3bfb74055a946fa7b1ff376510371902adb9cb0ab6a3" "1.9.1": - sha256: c780cf8cf3ba5ec2648a7eeb20a47e274493258f38a9b417628e0576f473a50b - url: https://github.com/CLIUtils/CLI11/archive/v1.9.1.tar.gz + url: "https://github.com/CLIUtils/CLI11/archive/v1.9.1.tar.gz" + sha256: "c780cf8cf3ba5ec2648a7eeb20a47e274493258f38a9b417628e0576f473a50b" diff --git a/recipes/cli11/all/conanfile.py b/recipes/cli11/all/conanfile.py index 76b2c380d32a4..6ccc240eeda4f 100644 --- a/recipes/cli11/all/conanfile.py +++ b/recipes/cli11/all/conanfile.py @@ -1,38 +1,64 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.files import get, copy, rmdir +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.build import check_min_cppstd import os +required_conan_version = ">=1.52.0" class CLI11Conan(ConanFile): name = "cli11" homepage = "https://github.com/CLIUtils/CLI11" description = "A command line parser for C++11 and beyond." - topics = ("cli-parser", "cpp11", "no-dependencies", "cli", "header-only") + topics = "cli-parser", "cpp11", "no-dependencies", "cli", "header-only" url = "https://github.com/conan-io/conan-center-index" license = "BSD-3-Clause" settings = "os", "compiler", "build_type", "arch" @property - def _source_subfolder(self): - return "source_subfolder" + def _min_cppstd(self): + return "11" + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name.upper() + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CLI11_BUILD_EXAMPLES"] = False + tc.variables["CLI11_BUILD_TESTS"] = False + tc.variables["CLI11_BUILD_DOCS"] = False + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) cmake = CMake(self) - cmake.definitions["CLI11_BUILD_EXAMPLES"] = False - cmake.definitions["CLI11_BUILD_TESTS"] = False - cmake.definitions["CLI11_BUILD_DOCS"] = False - cmake.configure(source_folder=self._source_subfolder) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + # since 2.1.1 + rmdir(self, os.path.join(self.package_folder, "share")) def package_id(self): - self.info.header_only() + self.info.clear() def package_info(self): + self.cpp_info.set_property("cmake_file_name", "CLI11") + self.cpp_info.set_property("cmake_target_name", "CLI11::CLI11") + self.cpp_info.set_property("pkg_config_name", "CLI11") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.names["cmake_find_package"] = "CLI11" self.cpp_info.names["cmake_find_package_multi"] = "CLI11" + self.cpp_info.names["pkg_config"] = "CLI11" diff --git a/recipes/cli11/all/test_package/CMakeLists.txt b/recipes/cli11/all/test_package/CMakeLists.txt index 91d2e99ba70db..0b06b681b8997 100644 --- a/recipes/cli11/all/test_package/CMakeLists.txt +++ b/recipes/cli11/all/test_package/CMakeLists.txt @@ -1,11 +1,9 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(CLI11 REQUIRED) +find_package(CLI11 REQUIRED CONFIG) add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) -set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 11) -target_link_libraries(${CMAKE_PROJECT_NAME} CLI11::CLI11) +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE CLI11::CLI11) + +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cli11/all/test_package/conanfile.py b/recipes/cli11/all/test_package/conanfile.py index 5c92748cdd246..a9fb96656f203 100644 --- a/recipes/cli11/all/test_package/conanfile.py +++ b/recipes/cli11/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package", "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin","test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cli11/all/test_v1_package/CMakeLists.txt b/recipes/cli11/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..145dcc03e0f3d --- /dev/null +++ b/recipes/cli11/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/cli11/all/test_v1_package/conanfile.py b/recipes/cli11/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..b30e638816fc5 --- /dev/null +++ b/recipes/cli11/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake_find_package_multi", "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin","test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cli11/config.yml b/recipes/cli11/config.yml index d107b03e40374..404e9fa4a9f55 100644 --- a/recipes/cli11/config.yml +++ b/recipes/cli11/config.yml @@ -1,3 +1,15 @@ versions: + "2.3.1": + folder: all + "2.3.0": + folder: all + "2.2.0": + folder: all + "2.1.2": + folder: all + "2.1.1": + folder: all + "2.0.0": + folder: all "1.9.1": folder: all diff --git a/recipes/clipp/all/conanfile.py b/recipes/clipp/all/conanfile.py index 0124538bd614f..2a4b7c31a6543 100644 --- a/recipes/clipp/all/conanfile.py +++ b/recipes/clipp/all/conanfile.py @@ -1,30 +1,25 @@ import os -import glob -from conans import ConanFile, tools +from conan import ConanFile, tools +required_conan_version = ">=1.50.0" + class ClippConan(ConanFile): name = "clipp" description = """Easy to use, powerful & expressive command line argument parsing for modern C++ / single header / usage & doc generation.""" - topics = ("conan", "clipp", "argparse") + topics = ("clipp", "argparse", "cli", "usage", "options", "subcommands") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/muellan/clipp" license = "MIT" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob(self.name + "-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + tools.files.get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) def package(self): - include_folder = os.path.join(self._source_subfolder, "include") - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*", dst="include", src=include_folder) + tools.files.copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + tools.files.copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_id(self): - self.info.header_only() + self.info.clear() diff --git a/recipes/clipp/all/test_package/conanfile.py b/recipes/clipp/all/test_package/conanfile.py index a59a26a52c8dc..70924c438164e 100644 --- a/recipes/clipp/all/test_package/conanfile.py +++ b/recipes/clipp/all/test_package/conanfile.py @@ -1,17 +1,21 @@ import os -from conans import ConanFile, CMake, tools +from conans import CMake +from conan import ConanFile, tools class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "cmake" + def requirements(self): + self.requires(self.tested_reference_str) + def build(self): cmake = CMake(self) cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.build.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/clipp/config.yml b/recipes/clipp/config.yml index c8148b0faf8c5..81ff4bc37c872 100644 --- a/recipes/clipp/config.yml +++ b/recipes/clipp/config.yml @@ -1,4 +1,3 @@ versions: "1.2.3": folder: "all" - diff --git a/recipes/clipper/all/CMakeLists.txt b/recipes/clipper/all/CMakeLists.txt deleted file mode 100644 index 218d94f2c71dd..0000000000000 --- a/recipes/clipper/all/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -if(WIN32 AND BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder/cpp") diff --git a/recipes/clipper/all/conandata.yml b/recipes/clipper/all/conandata.yml index 09ca138c7838c..00528d6271889 100644 --- a/recipes/clipper/all/conandata.yml +++ b/recipes/clipper/all/conandata.yml @@ -1,8 +1,12 @@ sources: "6.4.2": - url: "https://github.com/skyrpex/clipper/archive/6.4.2.tar.gz" - sha256: 8F55019C0CB73E22F4FD15AF721B6B8D3BD20B0EB5621271834C796671E0B634 + url: "https://sourceforge.net/projects/polyclipping/files/clipper_ver6.4.2.zip" + sha256: "a14320d82194807c4480ce59c98aa71cd4175a5156645c4e2b3edd330b930627" + "4.10.0": + url: "https://sourceforge.net/projects/polyclipping/files/Older%20versions/clipper_ver4.10.0.zip" + sha256: "4530e01006d02507a41f7eeaefa758c8067a94a7a0d6e0381fadfa40bc0cf248" patches: "6.4.2": - - patch_file: "patches/0001-include-install-directory.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-include-install-directory-6.x.patch" + "4.10.0": + - patch_file: "patches/0001-include-install-directory-4.x.patch" diff --git a/recipes/clipper/all/conanfile.py b/recipes/clipper/all/conanfile.py index ff0e463a3ea26..0213fccdf0a34 100644 --- a/recipes/clipper/all/conanfile.py +++ b/recipes/clipper/all/conanfile.py @@ -1,61 +1,74 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.53.0" class ClipperConan(ConanFile): name = "clipper" - description = """Clipper is an open source freeware polygon clipping library""" - topics = ("conan", "clipper") + description = "Clipper is an open source freeware polygon clipping library" + topics = ("clipper", "clipping", "polygon") url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/skyrpex/clipper" + homepage = "http://www.angusj.com/delphi/clipper.php" license = "BSL-1.0" - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" - settings = "arch", "build_type", "compiler", "os" - _cmake = None - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], - "fPIC": [True, False] + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, } - default_options = {"shared": False, "fPIC": True} - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - def _configure_cmake(self): - if self._cmake: - return self._cmake + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def layout(self): + cmake_layout(self, src_folder="src") - def build(self): - if "patches" in self.conan_data and self.version in self.conan_data["patches"]: - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder) - cmake = self._configure_cmake() + def generate(self): + tc = CMakeToolchain(self) + # Export symbols for msvc shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + # To install relocatable shared libs on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # TODO: can be removed if required_conan_version bumped to at least 1.54.0 + tc.variables["BUILD_SHARED_LIBS"] = self.options.shared + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "cpp")) cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "License.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - - self.copy("License.txt", dst="licenses", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "polyclipping") + self.cpp_info.libs = ["polyclipping"] + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed. + # Do not use these CMake names in CMakeDeps, it was a mistake, + # clipper doesn't provide CMake config file self.cpp_info.names["cmake_find_package"] = "polyclipping" self.cpp_info.names["cmake_find_package_multi"] = "polyclipping" - self.cpp_info.names["pkg_config"] = "polyclipping" - self.cpp_info.libs = ["polyclipping"] diff --git a/recipes/clipper/all/patches/0001-include-install-directory-4.x.patch b/recipes/clipper/all/patches/0001-include-install-directory-4.x.patch new file mode 100644 index 0000000000000..6a1c973c90a92 --- /dev/null +++ b/recipes/clipper/all/patches/0001-include-install-directory-4.x.patch @@ -0,0 +1,9 @@ +--- a/cpp/CMakeLists.txt ++++ b/cpp/CMakeLists.txt +@@ -10,4 +10,4 @@ + + # The header name clipper.hpp is too generic, so install in a subdirectory + INSTALL (FILES clipper.hpp DESTINATION include/polyclipping) +-INSTALL (TARGETS polyclipping LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++INSTALL (TARGETS polyclipping LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + diff --git a/recipes/clipper/all/patches/0001-include-install-directory.patch b/recipes/clipper/all/patches/0001-include-install-directory-6.x.patch similarity index 100% rename from recipes/clipper/all/patches/0001-include-install-directory.patch rename to recipes/clipper/all/patches/0001-include-install-directory-6.x.patch diff --git a/recipes/clipper/all/test_package/CMakeLists.txt b/recipes/clipper/all/test_package/CMakeLists.txt index 196188113685c..cb269d6010aa1 100644 --- a/recipes/clipper/all/test_package/CMakeLists.txt +++ b/recipes/clipper/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(clipper REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE clipper::clipper) +target_compile_definitions(${PROJECT_NAME} PRIVATE CLIPPER_MAJOR_VERSION=${CLIPPER_MAJOR_VERSION}) diff --git a/recipes/clipper/all/test_package/conanfile.py b/recipes/clipper/all/test_package/conanfile.py index bd7165a553cf4..3238612bed7d0 100644 --- a/recipes/clipper/all/test_package/conanfile.py +++ b/recipes/clipper/all/test_package/conanfile.py @@ -1,10 +1,25 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.scm import Version import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CLIPPER_MAJOR_VERSION"] = Version(self.dependencies["clipper"].ref.version).major + tc.generate() def build(self): cmake = CMake(self) @@ -12,6 +27,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/clipper/all/test_package/test_package.cpp b/recipes/clipper/all/test_package/test_package.cpp index 4f96a23d599ec..df4f8a3365269 100644 --- a/recipes/clipper/all/test_package/test_package.cpp +++ b/recipes/clipper/all/test_package/test_package.cpp @@ -5,35 +5,63 @@ using namespace ClipperLib; int main() { - std::cout << CLIPPER_VERSION << std::endl; +#if CLIPPER_MAJOR_VERSION == 6 + + //from clipper.hpp ... + //typedef signed long long cInt; + //struct IntPoint {cInt X; cInt Y;}; + //typedef std::vector Path; + //typedef std::vector Paths; + + Paths subj(2), clip(1), solution; + + //define outer blue 'subject' polygon + subj[0] << + IntPoint(180,200) << IntPoint(260,200) << + IntPoint(260,150) << IntPoint(180,150); + + //define subject's inner triangular 'hole' (with reverse orientation) + subj[1] << + IntPoint(215,160) << IntPoint(230,190) << IntPoint(200,190); + + //define orange 'clipping' polygon + clip[0] << + IntPoint(190,210) << IntPoint(240,210) << + IntPoint(240,130) << IntPoint(190,130); + + //perform intersection ... + Clipper c; + c.AddPaths(subj, ptSubject, true); + c.AddPaths(clip, ptClip, true); + c.Execute(ctIntersection, solution, pftNonZero, pftNonZero); + +#else + + Polygons subj(2), clip(1), solution; return 0; - - //from clipper.hpp ... - //typedef signed long long cInt; - //struct IntPoint {cInt X; cInt Y;}; - //typedef std::vector Path; - //typedef std::vector Paths; - - Paths subj(2), clip(1), solution; - - //define outer blue 'subject' polygon - subj[0] << - IntPoint(180,200) << IntPoint(260,200) << - IntPoint(260,150) << IntPoint(180,150); - - //define subject's inner triangular 'hole' (with reverse orientation) - subj[1] << - IntPoint(215,160) << IntPoint(230,190) << IntPoint(200,190); - - //define orange 'clipping' polygon - clip[0] << - IntPoint(190,210) << IntPoint(240,210) << - IntPoint(240,130) << IntPoint(190,130); - - //perform intersection ... - Clipper c; - c.AddPaths(subj, ptSubject, true); - c.AddPaths(clip, ptClip, true); - c.Execute(ctIntersection, solution, pftNonZero, pftNonZero); + + //define outer blue 'subject' polygon + subj[0].push_back(IntPoint(180,200)); + subj[0].push_back(IntPoint(260,200)); + subj[0].push_back(IntPoint(260,150)); + subj[0].push_back(IntPoint(180,150)); + + //define subject's inner triangular 'hole' (with reverse orientation) + subj[1].push_back(IntPoint(215,160)); + subj[1].push_back(IntPoint(230,190)); + subj[1].push_back(IntPoint(200,190)); + + //define orange 'clipping' polygon + clip[0].push_back(IntPoint(190,210)); + clip[0].push_back(IntPoint(240,210)); + clip[0].push_back(IntPoint(240,130)); + clip[0].push_back(IntPoint(190,130)); + + Clipper c; + c.AddPolygons(subj, ptSubject); + c.AddPolygons(clip, ptClip); + c.Execute(ctIntersection, solution, pftNonZero, pftNonZero); + +#endif } diff --git a/recipes/clipper/all/test_v1_package/CMakeLists.txt b/recipes/clipper/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..5a89ce2e8d32a --- /dev/null +++ b/recipes/clipper/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(polyclipping REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE polyclipping::polyclipping) +target_compile_definitions(${PROJECT_NAME} PRIVATE CLIPPER_MAJOR_VERSION=${CLIPPER_MAJOR_VERSION}) diff --git a/recipes/clipper/all/test_v1_package/conanfile.py b/recipes/clipper/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..d963e4448d15a --- /dev/null +++ b/recipes/clipper/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["CLIPPER_MAJOR_VERSION"] = tools.Version(self.deps_cpp_info["clipper"].version).major + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/clipper/config.yml b/recipes/clipper/config.yml index d70ae325d3209..b53e32183cb28 100644 --- a/recipes/clipper/config.yml +++ b/recipes/clipper/config.yml @@ -1,3 +1,5 @@ versions: "6.4.2": folder: all + "4.10.0": + folder: all diff --git a/recipes/clove-unit/all/conandata.yml b/recipes/clove-unit/all/conandata.yml new file mode 100644 index 0000000000000..2c3695d23b94a --- /dev/null +++ b/recipes/clove-unit/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "2.3.0": + url: "https://github.com/fdefelici/clove-unit/archive/v2.3.0.tar.gz" + sha256: ca94d33643bbe1ff2205f7e6405f3e9c5a95d2f3a076a126814e64b46e3cce8e + "2.2.4": + url: "https://github.com/fdefelici/clove-unit/archive/v2.2.4.tar.gz" + sha256: 0341f13b3e897952f1643eea2ca70cf014c4a086cf83375270980ac05f9d51aa + "2.2.3": + url: "https://github.com/fdefelici/clove-unit/archive/v2.2.3.tar.gz" + sha256: 65f80d600ddec35f7ba70370f10e2df268d68c589e5cddbdcad815b6dbb61dfd diff --git a/recipes/clove-unit/all/conanfile.py b/recipes/clove-unit/all/conanfile.py new file mode 100644 index 0000000000000..c29b4d879af19 --- /dev/null +++ b/recipes/clove-unit/all/conanfile.py @@ -0,0 +1,30 @@ +from conans import ConanFile, tools + +required_conan_version = ">=1.43.0" + +class CloveUnitConan(ConanFile): + name = "clove-unit" + description = "Single-header Unit Testing framework for C (interoperable with C++) with test autodiscovery feature" + topics = ("clove-unit", "unit-testing", "testing", "unit testing", "test") + homepage = "https://github.com/fdefelici/clove-unit" + url = "https://github.com/conan-io/conan-center-index" + license = "MIT" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="clove-unit.h", dst="include", src=self._source_subfolder) + + def package_id(self): + self.info.header_only() + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "CloveUnit" + self.cpp_info.names["cmake_find_package_multi"] = "CloveUnit" diff --git a/recipes/clove-unit/all/test_package/CMakeLists.txt b/recipes/clove-unit/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fde8b9c97172b --- /dev/null +++ b/recipes/clove-unit/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CloveUnit CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} CloveUnit::CloveUnit) diff --git a/recipes/clove-unit/all/test_package/conanfile.py b/recipes/clove-unit/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1bf1c7e26255d --- /dev/null +++ b/recipes/clove-unit/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/clove-unit/all/test_package/test_package.cpp b/recipes/clove-unit/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4d57d1c55fccb --- /dev/null +++ b/recipes/clove-unit/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include + +int main() { + const char* version = __CLOVE_VERSION; + if (version) return 0; + return 1; +} + + diff --git a/recipes/clove-unit/config.yml b/recipes/clove-unit/config.yml new file mode 100644 index 0000000000000..3c940ec906d09 --- /dev/null +++ b/recipes/clove-unit/config.yml @@ -0,0 +1,7 @@ +versions: + "2.3.0": + folder: "all" + "2.2.4": + folder: "all" + "2.2.3": + folder: "all" diff --git a/recipes/cmake/3.x.x/conandata.yml b/recipes/cmake/3.x.x/conandata.yml index f73912fd2dd96..6d9ebddf32aad 100644 --- a/recipes/cmake/3.x.x/conandata.yml +++ b/recipes/cmake/3.x.x/conandata.yml @@ -1,103 +1,22 @@ sources: - "3.15.7": - sha256: 71999d8a14c9b51708847371250a61533439a7331eb7702ac105cfb3cb1be54b - url: https://cmake.org/files/v3.15/cmake-3.15.7.tar.gz - "3.16.2": - sha256: 8c09786ec60ca2be354c29829072c38113de9184f29928eb9da8446a5f2ce6a9 - url: https://cmake.org/files/v3.16/cmake-3.16.2.tar.gz - "3.16.3": - sha256: e54f16df9b53dac30fd626415833a6e75b0e47915393843da1825b096ee60668 - url: https://cmake.org/files/v3.16/cmake-3.16.3.tar.gz - "3.16.4": - sha256: 9bcc8c114d9da603af9512083ed7d4a39911d16105466beba165ba8fe939ac2c - url: https://cmake.org/files/v3.16/cmake-3.16.4.tar.gz - "3.16.5": - sha256: 5f760b50b8ecc9c0c37135fae5fbf00a2fef617059aa9d61c1bb91653e5a8bfc - url: https://cmake.org/files/v3.16/cmake-3.16.5.tar.gz - "3.16.6": - sha256: 6f6ff1a197851b0fa8412ff5de602e6717a4eb9509b2c385b08589c4e7a16b62 - url: https://cmake.org/files/v3.16/cmake-3.16.6.tar.gz - "3.16.7": - sha256: 5f49c95a2933b1800f14840f3a389f4cef0b19093985a35053b43f38ec21358f - url: https://cmake.org/files/v3.16/cmake-3.16.7.tar.gz - "3.16.8": - sha256: 177434021132686cb901fea7db9fa2345efe48d566b998961594d5cc346ac588 - url: https://cmake.org/files/v3.16/cmake-3.16.8.tar.gz - "3.16.9": - sha256: 1708361827a5a0de37d55f5c9698004c035abb1de6120a376d5d59a81630191f - url: https://cmake.org/files/v3.16/cmake-3.16.9.tar.gz - "3.17.0": - sha256: b74c05b55115eacc4fa2b77a814981dbda05cdc95a53e279fe16b7b272f00847 - url: https://cmake.org/files/v3.17/cmake-3.17.0.tar.gz - "3.17.1": - sha256: 3aa9114485da39cbd9665a0bfe986894a282d5f0882b1dea960a739496620727 - url: https://cmake.org/files/v3.17/cmake-3.17.1.tar.gz - "3.17.2": - sha256: fc77324c4f820a09052a7785549b8035ff8d3461ded5bbd80d252ae7d1cd3aa5 - url: https://cmake.org/files/v3.17/cmake-3.17.2.tar.gz - "3.17.3": - sha256: 0bd60d512275dc9f6ef2a2865426a184642ceb3761794e6b65bff233b91d8c40 - url: https://cmake.org/files/v3.17/cmake-3.17.3.tar.gz - "3.17.4": - sha256: 86985d73d0a63ec99c236aab5287316e252164f33d7c4cb160954a980c71f36f - url: https://cmake.org/files/v3.17/cmake-3.17.4.tar.gz - "3.17.5": - sha256: 8c3083d98fd93c1228d5e4e40dbff2dd88f4f7b73b9fa24a2938627b8bc28f1a - url: https://cmake.org/files/v3.17/cmake-3.17.5.tar.gz - "3.18.0": - sha256: 83b4ffcb9482a73961521d2bafe4a16df0168f03f56e6624c419c461e5317e29 - url: https://github.com/Kitware/CMake/releases/download/v3.18.0/cmake-3.18.0.tar.gz - "3.18.1": - sha256: c0e3338bd37e67155b9d1e9526fec326b5c541f74857771b7ffed0c46ad62508 - url: https://github.com/Kitware/CMake/releases/download/v3.18.1/cmake-3.18.1.tar.gz - "3.18.2": - sha256: 5d4e40fc775d3d828c72e5c45906b4d9b59003c9433ff1b36a1cb552bbd51d7e - url: https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2.tar.gz - "3.18.3": - sha256: 2c89f4e30af4914fd6fb5d00f863629812ada848eee4e2d29ec7e456d7fa32e5 - url: https://github.com/Kitware/CMake/releases/download/v3.18.3/cmake-3.18.3.tar.gz - "3.18.4": - sha256: 597c61358e6a92ecbfad42a9b5321ddd801fc7e7eca08441307c9138382d4f77 - url: https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4.tar.gz - "3.18.5": - sha256: 080bf24b0f73f4bf3ec368d2be1aa59369b9bb1cd693deeb6f18fe553ca74ab4 - url: https://github.com/Kitware/CMake/releases/download/v3.18.5/cmake-3.18.5.tar.gz - "3.18.6": - sha256: 124f571ab70332da97a173cb794dfa09a5b20ccbb80a08e56570a500f47b6600 - url: https://github.com/Kitware/CMake/releases/download/v3.18.6/cmake-3.18.6.tar.gz - "3.19.0": - sha256: fdda688155aa7e72b7c63ef6f559fca4b6c07382ea6dca0beb5f45aececaf493 - url: https://github.com/Kitware/CMake/releases/download/v3.19.0/cmake-3.19.0.tar.gz - "3.19.1": - sha256: 1d266ea3a76ef650cdcf16c782a317cb4a7aa461617ee941e389cb48738a3aba - url: https://github.com/Kitware/CMake/releases/download/v3.19.1/cmake-3.19.1.tar.gz - "3.19.2": - sha256: e3e0fd3b23b7fb13e1a856581078e0776ffa2df4e9d3164039c36d3315e0c7f0 - url: https://github.com/Kitware/CMake/releases/download/v3.19.2/cmake-3.19.2.tar.gz - "3.19.3": - sha256: 3faca7c131494a1e34d66e9f8972ff5369e48d419ea8ceaa3dc15b4c11367732 - url: https://github.com/Kitware/CMake/releases/download/v3.19.3/cmake-3.19.3.tar.gz - "3.19.4": - sha256: 7d0232b9f1c57e8de81f38071ef8203e6820fe7eec8ae46a1df125d88dbcc2e1 - url: https://github.com/Kitware/CMake/releases/download/v3.19.4/cmake-3.19.4.tar.gz - "3.19.5": - sha256: c432296eb5dec6d71eae15d140f6297d63df44e9ffe3e453628d1dc8fc4201ce - url: https://github.com/Kitware/CMake/releases/download/v3.19.5/cmake-3.19.5.tar.gz - "3.19.6": - sha256: ec87ab67c45f47c4285f204280c5cde48e1c920cfcfed1555b27fb3b1a1d20ba - url: https://github.com/Kitware/CMake/releases/download/v3.19.6/cmake-3.19.6.tar.gz - "3.19.7": - sha256: 58a15f0d56a0afccc3cc5371234fce73fcc6c8f9dbd775d898e510b83175588e - url: https://github.com/Kitware/CMake/releases/download/v3.19.7/cmake-3.19.7.tar.gz "3.19.8": - sha256: 09b4fa4837aae55c75fb170f6a6e2b44818deba48335d1969deddfbb34e30369 url: https://github.com/Kitware/CMake/releases/download/v3.19.8/cmake-3.19.8.tar.gz - "3.20.0": - sha256: 9c06b2ddf7c337e31d8201f6ebcd3bba86a9a033976a9aee207fe0c6971f4755 - url: https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0.tar.gz - "3.20.1": - sha256: 3f1808b9b00281df06c91dd7a021d7f52f724101000da7985a401678dfe035b0 - url: https://github.com/Kitware/CMake/releases/download/v3.20.1/cmake-3.20.1.tar.gz - "3.20.2": - sha256: aecf6ecb975179eb3bb6a4a50cae192d41e92b9372b02300f9e8f1d5f559544e - url: https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz + sha256: 09b4fa4837aae55c75fb170f6a6e2b44818deba48335d1969deddfbb34e30369 + "3.20.6": + url: https://github.com/Kitware/CMake/releases/download/v3.20.6/cmake-3.20.6.tar.gz + sha256: a0bd485e1a38dd13c0baec89d5f4adbf61c7fd32fddb38eabc69a75bc0b65d72 + "3.21.7": + url: https://github.com/Kitware/CMake/releases/download/v3.21.7/cmake-3.21.7.tar.gz + sha256: 3523c4a5afc61ac3d7c92835301cdf092129c9b672a6ee17e68c92e928c1375a + "3.22.6": + url: https://github.com/Kitware/CMake/releases/download/v3.22.6/cmake-3.22.6.tar.gz + sha256: 73933163670ea4ea95c231549007b0c7243282293506a2cf4443714826ad5ec3 + "3.23.5": + url: "https://github.com/Kitware/CMake/releases/download/v3.23.5/cmake-3.23.5.tar.gz" + sha256: "f2944cde7a140b992ba5ccea2009a987a92413762250de22ebbace2319a0f47d" + "3.24.3": + url: "https://github.com/Kitware/CMake/releases/download/v3.24.3/cmake-3.24.3.tar.gz" + sha256: "b53aa10fa82bff84ccdb59065927b72d3bee49f4d86261249fc0984b3b367291" + "3.25.0": + url: "https://github.com/Kitware/CMake/releases/download/v3.25.0/cmake-3.25.0.tar.gz" + sha256: "306463f541555da0942e6f5a0736560f70c487178b9d94a5ae7f34d0538cdd48" diff --git a/recipes/cmake/3.x.x/conanfile.py b/recipes/cmake/3.x.x/conanfile.py index 09123dc7e71b8..e0d41c4a94794 100644 --- a/recipes/cmake/3.x.x/conanfile.py +++ b/recipes/cmake/3.x.x/conanfile.py @@ -1,12 +1,16 @@ import os -from conans import tools, ConanFile, CMake -from conans.errors import ConanInvalidConfiguration, ConanException +from conan import ConanFile +from conan.tools.scm import Version +from conan.tools.files import rmdir, get +from conans import tools, AutoToolsBuildEnvironment, CMake +from conan.errors import ConanInvalidConfiguration, ConanException +required_conan_version = ">=1.49.0" class CMakeConan(ConanFile): name = "cmake" description = "Conan installer for CMake" - topics = ("conan", "cmake", "build", "installer") + topics = ("cmake", "build", "installer") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/Kitware/CMake" license = "BSD-3-Clause" @@ -15,25 +19,31 @@ class CMakeConan(ConanFile): options = { "with_openssl": [True, False], + "bootstrap": [True, False], } default_options = { "with_openssl": True, + "bootstrap": False, } _source_subfolder = "source_subfolder" _cmake = None - def _minor_version(self): - return ".".join(str(self.version).split(".")[:2]) - def config_options(self): if self.settings.os == "Windows": self.options.with_openssl = False - def configure(self): + def requirements(self): + if self.options.with_openssl: + self.requires("openssl/1.1.1s") + + def validate(self): if self.settings.os == "Macos" and self.settings.arch == "x86": raise ConanInvalidConfiguration("CMake does not support x86 for macOS") + if self.settings.os == "Windows" and self.options.bootstrap: + raise ConanInvalidConfiguration("CMake does not support bootstrapping on Windows") + minimal_cpp_standard = "11" if self.settings.compiler.cppstd: tools.check_min_cppstd(self, minimal_cpp_standard) @@ -53,19 +63,14 @@ def configure(self): "{} requires a compiler that supports at least C++{}".format(self.name, minimal_cpp_standard)) return - version = tools.Version(self.settings.compiler.version) + version = Version(self.settings.compiler.version) if version < minimal_version[compiler]: raise ConanInvalidConfiguration( "{} requires a compiler that supports at least C++{}".format(self.name, minimal_cpp_standard)) - def requirements(self): - if self.options.with_openssl: - self.requires("openssl/1.1.1k") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + rmdir(self, os.path.join(self._source_subfolder, "Tests", "RunCMake", "find_package")) def _configure_cmake(self): if not self._cmake: @@ -77,39 +82,59 @@ def _configure_cmake(self): self._cmake.definitions["CMAKE_USE_OPENSSL"] = self.options.with_openssl if self.options.with_openssl: self._cmake.definitions["OPENSSL_USE_STATIC_LIBS"] = not self.options["openssl"].shared + if tools.cross_building(self): + self._cmake.definitions["HAVE_POLL_FINE_EXITCODE"] = '' + self._cmake.definitions["HAVE_POLL_FINE_EXITCODE__TRYRUN_OUTPUT"] = '' self._cmake.configure(source_folder=self._source_subfolder) + return self._cmake def build(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "project(CMake)", - "project(CMake)\ninclude(\"{}/conanbuildinfo.cmake\")\nconan_basic_setup(NO_OUTPUT_DIRS)".format( - self.install_folder.replace("\\", "/"))) - if self.settings.os == "Linux": - tools.replace_in_file(os.path.join(self._source_subfolder, "Utilities", "cmcurl", "CMakeLists.txt"), - "list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})", - "list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} pthread)") - cmake = self._configure_cmake() - cmake.build() + if self.options.bootstrap: + with tools.chdir(self._source_subfolder): + self.run(['./bootstrap', '--prefix={}'.format(self.package_folder), '--parallel={}'.format(tools.cpu_count())]) + autotools = AutoToolsBuildEnvironment(self) + autotools.make() + else: + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "project(CMake)", + "project(CMake)\ninclude(\"{}/conanbuildinfo.cmake\")\nconan_basic_setup(NO_OUTPUT_DIRS)".format( + self.install_folder.replace("\\", "/"))) + if self.settings.os == "Linux": + tools.replace_in_file(os.path.join(self._source_subfolder, "Utilities", "cmcurl", "CMakeLists.txt"), + "list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})", + "list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} pthread)") + + cmake = self._configure_cmake() + cmake.build() def package(self): self.copy("Copyright.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() - cmake.install() - tools.rmdir(os.path.join(self.package_folder, "doc")) + if self.options.bootstrap: + with tools.chdir(self._source_subfolder): + autotools = AutoToolsBuildEnvironment(self) + autotools.install() + else: + cmake = self._configure_cmake() + cmake.install() + rmdir(self, os.path.join(self.package_folder, "doc")) def package_id(self): del self.info.settings.compiler def package_info(self): - minor = self._minor_version() + module_version = "{}.{}".format(Version(self.version).major, Version(self.version).minor) bindir = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bindir)) self.env_info.PATH.append(bindir) + self.buildenv_info.prepend_path("CMAKE_ROOT", self.package_folder) self.env_info.CMAKE_ROOT = self.package_folder - mod_path = os.path.join(self.package_folder, "share", "cmake-%s" % minor, "Modules") + mod_path = os.path.join(self.package_folder, "share", f"cmake-{module_version}", "Modules") + self.buildenv_info.prepend_path("CMAKE_MODULE_PATH", mod_path) self.env_info.CMAKE_MODULE_PATH = mod_path if not os.path.exists(mod_path): raise ConanException("Module path not found: %s" % mod_path) + + self.cpp_info.includedirs = [] diff --git a/recipes/cmake/3.x.x/test_package/conanfile.py b/recipes/cmake/3.x.x/test_package/conanfile.py index 41479cc9b4d0c..0b0c4858e1c60 100644 --- a/recipes/cmake/3.x.x/test_package/conanfile.py +++ b/recipes/cmake/3.x.x/test_package/conanfile.py @@ -1,15 +1,20 @@ import os from six import StringIO -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import can_run class TestPackageConan(ConanFile): - settings = "os", "os_build" + settings = "os", "arch" + generators = "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) def test(self): - if not tools.cross_building(self.settings): + if can_run(self): output = StringIO() - self.run("cmake --version", output=output, run_environment=True) + self.run("cmake --version", env="conanrun", output=output) output_str = str(output.getvalue()) self.output.info("Installed version: {}".format(output_str)) require_version = str(self.deps_cpp_info["cmake"].version) diff --git a/recipes/cmake/3.x.x/test_v1_package/conanfile.py b/recipes/cmake/3.x.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..efb629f7d5725 --- /dev/null +++ b/recipes/cmake/3.x.x/test_v1_package/conanfile.py @@ -0,0 +1,23 @@ +import os +from six import StringIO +from conan import ConanFile +from conan.tools.build import can_run + + +class TestPackageConan(ConanFile): + settings = "os", "arch" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def test(self): + if can_run(self): + output = StringIO() + self.run("cmake --version", output=output, run_environment=True) + output_str = str(output.getvalue()) + self.output.info("Installed version: {}".format(output_str)) + require_version = str(self.deps_cpp_info["cmake"].version) + self.output.info("Expected version: {}".format(require_version)) + assert_cmake_version = "cmake version %s" % require_version + assert(assert_cmake_version in output_str) diff --git a/recipes/cmake/config.yml b/recipes/cmake/config.yml index 1fbf801f011c8..6075464de552d 100644 --- a/recipes/cmake/config.yml +++ b/recipes/cmake/config.yml @@ -1,69 +1,15 @@ versions: - "3.15.7": - folder: "3.x.x" - "3.16.2": - folder: "3.x.x" - "3.16.3": - folder: "3.x.x" - "3.16.4": - folder: "3.x.x" - "3.16.5": - folder: "3.x.x" - "3.16.6": - folder: "3.x.x" - "3.16.7": - folder: "3.x.x" - "3.16.8": - folder: "3.x.x" - "3.16.9": - folder: "3.x.x" - "3.17.0": - folder: "3.x.x" - "3.17.1": - folder: "3.x.x" - "3.17.2": - folder: "3.x.x" - "3.17.3": - folder: "3.x.x" - "3.17.4": - folder: "3.x.x" - "3.17.5": - folder: "3.x.x" - "3.18.0": - folder: "3.x.x" - "3.18.1": - folder: "3.x.x" - "3.18.2": - folder: "3.x.x" - "3.18.3": - folder: "3.x.x" - "3.18.4": - folder: "3.x.x" - "3.18.5": - folder: "3.x.x" - "3.18.6": - folder: "3.x.x" - "3.19.0": - folder: "3.x.x" - "3.19.1": - folder: "3.x.x" - "3.19.2": - folder: "3.x.x" - "3.19.3": - folder: "3.x.x" - "3.19.4": - folder: "3.x.x" - "3.19.5": + "3.19.8": folder: "3.x.x" - "3.19.6": + "3.20.6": folder: "3.x.x" - "3.19.7": + "3.21.7": folder: "3.x.x" - "3.19.8": + "3.22.6": folder: "3.x.x" - "3.20.0": + "3.23.5": folder: "3.x.x" - "3.20.1": + "3.24.3": folder: "3.x.x" - "3.20.2": + "3.25.0": folder: "3.x.x" diff --git a/recipes/cminpack/all/conandata.yml b/recipes/cminpack/all/conandata.yml new file mode 100644 index 0000000000000..114fe2eaf9bb8 --- /dev/null +++ b/recipes/cminpack/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.3.8": + sha256: "3ea7257914ad55eabc43a997b323ba0dfee0a9b010d648b6d5b0c96425102d0e" + url: "https://github.com/devernay/cminpack/archive/refs/tags/v1.3.8.tar.gz" diff --git a/recipes/cminpack/all/conanfile.py b/recipes/cminpack/all/conanfile.py new file mode 100644 index 0000000000000..a1da35f69dd6a --- /dev/null +++ b/recipes/cminpack/all/conanfile.py @@ -0,0 +1,116 @@ +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools import files +from conan import ConanFile +import os + +required_conan_version = ">=1.45.0" + + +class CMinpackConan(ConanFile): + name = "cminpack" + url = "https://github.com/conan-io/conan-center-index" + description = "About A C/C++ rewrite of the MINPACK software (originally in FORTRAN)" \ + "for solving nonlinear equations and nonlinear least squares problems" + topics = ("nonlinear", "solver") + homepage = "http://devernay.free.fr/hacks/cminpack/" + license = "LicenseRef-CopyrightMINPACK.txt" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_EXAMPLES"] = "OFF" + tc.variables["CMINPACK_LIB_INSTALL_DIR"] = "lib" + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + def layout(self): + cmake_layout(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + # cminpack is a c library + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination=self.source_folder) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + files.copy(self, "CopyrightMINPACK.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + files.rmdir(self, os.path.join(self.package_folder, "share")) # contains cmake config files + + def _library_postfix(self): + postfix = "" + if not self.options.shared: + postfix += "_s" # for static + if self.settings.build_type == "Debug": + postfix += "_d" + + return postfix + + def package_info(self): + minpack_include_dir = os.path.join("include", "cminpack-1") + self.cpp_info.set_property("cmake_target_name", "cminpack") + # the double precision version + self.cpp_info.components['cminpack-double'].libs = ['cminpack' + self._library_postfix()] + self.cpp_info.components['cminpack-double'].includedirs.append(minpack_include_dir) + self.cpp_info.components["cminpack-double"].set_property("cmake_target_name", "cminpack::cminpack") + self.cpp_info.components["cminpack-double"].names["cmake_find_package"] = "cminpack" + self.cpp_info.components["cminpack-double"].names["cmake_find_package_multi"] = "cminpack" + self.cpp_info.components["cminpack-double"].names["pkg_config"] = "cminpack" + + # the single precision version + self.cpp_info.components['cminpack-single'].libs = ['cminpacks' + self._library_postfix()] + self.cpp_info.components['cminpack-single'].includedirs.append(minpack_include_dir) + self.cpp_info.components['cminpack-single'].defines.append("__cminpack_float__") + self.cpp_info.components["cminpack-single"].set_property("cmake_target_name", "cminpack::cminpacks") + self.cpp_info.components["cminpack-single"].names["cmake_find_package"] = "cminpacks" + self.cpp_info.components["cminpack-single"].names["cmake_find_package_multi"] = "cminpacks" + self.cpp_info.components["cminpack-single"].names["pkg_config"] = "cminpacks" + + + if self.settings.os != "Windows": + self.cpp_info.components['cminpack-double'].system_libs.append("m") + self.cpp_info.components['cminpack-single'].system_libs.append("m") + + # required apple frameworks + self.cpp_info.components['cminpack-double'].frameworks.append("Accelerate") + self.cpp_info.components['cminpack-single'].frameworks.append("Accelerate") + + if not self.options.shared and self.settings.os == "Windows": + self.cpp_info.components['cminpack-double'].defines.append("CMINPACK_NO_DLL") + self.cpp_info.components['cminpack-single'].defines.append("CMINPACK_NO_DLL") diff --git a/recipes/cminpack/all/test_package/CMakeLists.txt b/recipes/cminpack/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fa33c20512fe4 --- /dev/null +++ b/recipes/cminpack/all/test_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.12) +project(CMinPack-Conan-TestPackage C) + +find_package(CMinpack REQUIRED) + +# This builds one of the original cminpack examples against +# both types of the library + +add_executable(cminpack_test_double tchkderc.c) +target_link_libraries(cminpack_test_double PRIVATE cminpack::cminpack) + +add_executable(cminpack_test_float tchkderc.c) +target_link_libraries(cminpack_test_float PRIVATE cminpack::cminpacks) diff --git a/recipes/cminpack/all/test_package/conanfile.py b/recipes/cminpack/all/test_package/conanfile.py new file mode 100644 index 0000000000000..db7d5f7ac5bc3 --- /dev/null +++ b/recipes/cminpack/all/test_package/conanfile.py @@ -0,0 +1,25 @@ + +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "cminpack_test_double") + self.run(bin_path, env="conanrun") + bin_path = os.path.join(self.cpp.build.bindirs[0], "cminpack_test_float") + self.run(bin_path, env="conanrun") diff --git a/recipes/cminpack/all/test_package/tchkderc.c b/recipes/cminpack/all/test_package/tchkderc.c new file mode 100644 index 0000000000000..8f6a3f0f741b8 --- /dev/null +++ b/recipes/cminpack/all/test_package/tchkderc.c @@ -0,0 +1,159 @@ +/* driver for chkder example. */ + +#include +#include +#include +#include +#define real __cminpack_real__ + +/* the following struct defines the data points */ +typedef struct { + int m; + real *y; +#ifdef BOX_CONSTRAINTS + real *xmin; + real *xmax; +#endif +} fcndata_t; + +int fcn(void *p, int m, int n, const real *x, real *fvec, + real *fjac, int ldfjac, int iflag); + +int main() +{ +#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER < 1900)) + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif + int i, ldfjac; + real x[3], fvec[15], fjac[15*3], xp[3], fvecp[15], + err[15]; + const int m = 15; + const int n = 3; + /* auxiliary data (e.g. measurements) */ + real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1, + 3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39}; +#ifdef BOX_CONSTRAINTS + real xmin[3] = {0., 0.1, 0.5}; + real xmax[3] = {2., 1.5, 2.3}; +#endif + fcndata_t data; + data.m = m; + data.y = y; +#ifdef BOX_CONSTRAINTS + data.xmin = xmin; + data.xmax = xmax; +#endif + + /* the following values should be suitable for */ + /* checking the jacobian matrix. */ + + x[0] = 9.2e-1; + x[1] = 1.3e-1; + x[2] = 5.4e-1; + + ldfjac = 15; + + /* compute xp from x */ + __cminpack_func__(chkder)(m, n, x, NULL, NULL, ldfjac, xp, NULL, 1, NULL); + /* compute fvec at x (all components of fvec should be != 0).*/ + fcn(&data, m, n, x, fvec, NULL, ldfjac, 1); + /* compute fjac at x */ + fcn(&data, m, n, x, NULL, fjac, ldfjac, 2); + /* compute fvecp at xp (all components of fvecp should be != 0)*/ + fcn(&data, m, n, xp, fvecp, NULL, ldfjac, 1); + /* check Jacobian, put the result in err */ + __cminpack_func__(chkder)(m, n, x, fvec, fjac, ldfjac, NULL, fvecp, 2, err); + /* Output values: + err[i] = 1.: i-th gradient is correct + err[i] = 0.: i-th gradient is incorrect + err[I] > 0.5: i-th gradient is probably correct + */ + + for (i=0; iy; +#ifdef BOX_CONSTRAINTS + const real *xmin = ((fcndata_t*)p)->xmin; + const real *xmax = ((fcndata_t*)p)->xmax; + int j; + real xb[3]; + real jacfac[3]; + + for (j = 0; j < 3; ++j) { + real xmiddle = (xmin[j]+xmax[j])/2.; + real xwidth = (xmax[j]-xmin[j])/2.; + real th = tanh((x[j]-xmiddle)/xwidth); + xb[j] = xmiddle + th * xwidth; + jacfac[j] = 1. - th * th; + } + x = xb; +#endif + + if (iflag == 0) { + /* insert print statements here when nprint is positive. */ + /* if the nprint parameter to lmder is positive, the function is + called every nprint iterations with iflag=0, so that the + function may perform special operations, such as printing + residuals. */ + return 0; + } + + if (iflag != 2) { + /* compute residuals */ + for (i=0; i < 15; ++i) { + tmp1 = i + 1; + tmp2 = 15 - i; + tmp3 = (i > 7) ? tmp2 : tmp1; + fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); + } + } else { + /* compute Jacobian */ + for (i=0; i < 15; ++i) { + tmp1 = i + 1; + tmp2 = 15 - i; +# ifdef TCHKDER_FIXED + tmp3 = (i > 7) ? tmp2 : tmp1; +# else + /* error introduced into next statement for illustration. */ + /* corrected statement should read tmp3 = (i > 7) ? tmp2 : tmp1 . */ + tmp3 = (i > 7) ? tmp2 : tmp2; +# endif + tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4; + fjac[i + ldfjac*0] = -1.; + fjac[i + ldfjac*1] = tmp1*tmp2/tmp4; + fjac[i + ldfjac*2] = tmp1*tmp3/tmp4; + } +# ifdef BOX_CONSTRAINTS + for (j = 0; j < 3; ++j) { + for (i=0; i < 15; ++i) { + fjac[i + ldfjac*j] *= jacfac[j]; + } + } +# endif + } + return 0; +} diff --git a/recipes/cminpack/all/test_v1_package/CMakeLists.txt b/recipes/cminpack/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..124290cb0ab4b --- /dev/null +++ b/recipes/cminpack/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.1.2) +project(CMinPack-ConanV1-TestPackage C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CMinpack REQUIRED CONFIG) + +# This builds one of the original cminpack examples against +# both types of the library + +add_executable(cminpack_test_double ../test_package/tchkderc.c) +target_link_libraries(cminpack_test_double PRIVATE cminpack::cminpack) + +add_executable(cminpack_test_float ../test_package/tchkderc.c) +target_link_libraries(cminpack_test_float PRIVATE cminpack::cminpacks) diff --git a/recipes/cminpack/all/test_v1_package/conanfile.py b/recipes/cminpack/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..0cdc195d14862 --- /dev/null +++ b/recipes/cminpack/all/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +import os + +from conan.tools.build import cross_building +from conans import ConanFile, CMake + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "cminpack_test_double") + self.run(bin_path, run_environment=True) + bin_path = os.path.join("bin", "cminpack_test_float") + self.run(bin_path, run_environment=True) diff --git a/recipes/cminpack/config.yml b/recipes/cminpack/config.yml new file mode 100644 index 0000000000000..859ab74128907 --- /dev/null +++ b/recipes/cminpack/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3.8": + folder: all diff --git a/recipes/cmocka/all/conandata.yml b/recipes/cmocka/all/conandata.yml new file mode 100644 index 0000000000000..d9ca5bcc54526 --- /dev/null +++ b/recipes/cmocka/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.1.5": + url: "https://cmocka.org/files/1.1/cmocka-1.1.5.tar.xz" + sha256: "f0ccd8242d55e2fd74b16ba518359151f6f8383ff8aef4976e48393f77bba8b6" +patches: + "1.1.5": + - patch_file: "patches/build_either_static_or_shared.patch" diff --git a/recipes/cmocka/all/conanfile.py b/recipes/cmocka/all/conanfile.py new file mode 100644 index 0000000000000..a0184c6e3cfae --- /dev/null +++ b/recipes/cmocka/all/conanfile.py @@ -0,0 +1,109 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir, save +import os +import textwrap + +required_conan_version = ">=1.47.0" + + +class CmockaConan(ConanFile): + name = "cmocka" + license = "Apache-2.0" + homepage = "https://cmocka.org" + url = "https://github.com/conan-io/conan-center-index" + description = "A unit testing framework for C" + topics = ("unit_test", "unittest", "test", "testing", "mock", "mocking") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_STATIC_LIB"] = not self.options.shared + tc.variables["WITH_EXAMPLES"] = False + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path) + ) + + def _create_cmake_module_variables(self, module_file): + content = textwrap.dedent("""\ + if(NOT DEFINED CMOCKA_INCLUDE_DIR) + set(CMOCKA_INCLUDE_DIR ${cmocka_INCLUDE_DIRS} + ${cmocka_INCLUDE_DIRS_RELEASE} + ${cmocka_INCLUDE_DIRS_RELWITHDEBINFO} + ${cmocka_INCLUDE_DIRS_MINSIZEREL} + ${cmocka_INCLUDE_DIRS_DEBUG}) + endif() + if(TARGET cmocka::cmocka) + if(NOT DEFINED CMOCKA_LIBRARY) + set(CMOCKA_LIBRARY cmocka::cmocka) + endif() + if(NOT DEFINED CMOCKA_LIBRARIES) + set(CMOCKA_LIBRARIES cmocka::cmocka) + endif() + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "cmocka") + self.cpp_info.set_property("pkg_config_name", "cmocka") + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) + self.cpp_info.libs = ["cmocka{}".format("" if self.options.shared else "-static")] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/cmocka/all/patches/build_either_static_or_shared.patch b/recipes/cmocka/all/patches/build_either_static_or_shared.patch new file mode 100644 index 0000000000000..20ce61e8e4a7c --- /dev/null +++ b/recipes/cmocka/all/patches/build_either_static_or_shared.patch @@ -0,0 +1,20 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 5684685..5f0fc81 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -31,6 +31,7 @@ if (WIN32) + ) + endif (WIN32) + ++if (NOT BUILD_STATIC_LIB) + add_library(${CMOCKA_SHARED_LIBRARY} SHARED ${cmocka_SRCS}) + + target_include_directories(${CMOCKA_SHARED_LIBRARY} +@@ -82,6 +83,7 @@ install(TARGETS + ${CMAKE_INSTALL_BINDIR} + COMPONENT + ${PROJECT_NAME}) ++endif (NOT BUILD_STATIC_LIB) + + if (BUILD_STATIC_LIB) + add_library(${CMOCKA_STATIC_LIBRARY} STATIC ${cmocka_SRCS}) diff --git a/recipes/cmocka/all/test_package/CMakeLists.txt b/recipes/cmocka/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..23601e264af84 --- /dev/null +++ b/recipes/cmocka/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(cmocka REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMOCKA_INCLUDE_DIR}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${CMOCKA_LIBRARY}) diff --git a/recipes/cmocka/all/test_package/conanfile.py b/recipes/cmocka/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/cmocka/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cmocka/all/test_package/test_package.c b/recipes/cmocka/all/test_package/test_package.c new file mode 100644 index 0000000000000..4b9fbf9e29998 --- /dev/null +++ b/recipes/cmocka/all/test_package/test_package.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include "cmocka.h" + +/* A test case that does nothing and succeeds. */ +static void null_test_success(void **state) { + (void) state; /* unused */ +} + +int main(void) { + const struct CMUnitTest tests[] = { + cmocka_unit_test(null_test_success), + }; + + return cmocka_run_group_tests(tests, NULL, NULL); +} diff --git a/recipes/cmocka/all/test_v1_package/CMakeLists.txt b/recipes/cmocka/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6059ab4d19a64 --- /dev/null +++ b/recipes/cmocka/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cmocka REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMOCKA_INCLUDE_DIR}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${CMOCKA_LIBRARY}) diff --git a/recipes/cmocka/all/test_v1_package/conanfile.py b/recipes/cmocka/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cmocka/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cmocka/config.yml b/recipes/cmocka/config.yml new file mode 100644 index 0000000000000..e48685771bd64 --- /dev/null +++ b/recipes/cmocka/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.5": + folder: all diff --git a/recipes/cmp/all/CMakeLists.txt b/recipes/cmp/all/CMakeLists.txt new file mode 100644 index 0000000000000..cc7e397ad25e6 --- /dev/null +++ b/recipes/cmp/all/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.4) +project(cmp LANGUAGES C) + +include(GNUInstallDirs) + +add_library(cmp ${CMP_SRC_DIR}/cmp.c) +set_target_properties(cmp PROPERTIES + WINDOWS_EXPORT_ALL_SYMBOLS ON + PUBLIC_HEADER ${CMP_SRC_DIR}/cmp.h +) + +install(TARGETS cmp + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/cmp/all/conandata.yml b/recipes/cmp/all/conandata.yml new file mode 100644 index 0000000000000..c3d249aab079b --- /dev/null +++ b/recipes/cmp/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "20": + url: "https://github.com/camgunz/cmp/archive/v20.tar.gz" + sha256: "cde6db84cb04913d4ce4880c4db665555f92c163f362de151e350d8f30113362" + "19": + url: "https://github.com/camgunz/cmp/archive/refs/tags/v19.tar.gz" + sha256: "afa23e1961027c0146bda73f892726f3cdf0a85579a9813077890a51aec99916" diff --git a/recipes/cmp/all/conanfile.py b/recipes/cmp/all/conanfile.py new file mode 100644 index 0000000000000..5987f311045bf --- /dev/null +++ b/recipes/cmp/all/conanfile.py @@ -0,0 +1,68 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.46.0" + + +class CmpConan(ConanFile): + name = "cmp" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://msgpack.org" + description = "An implementation of the MessagePack serialization format in C / msgpack.org[C]" + topics = ("cmp", "msgpack", "serialization") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMP_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["cmp"] diff --git a/recipes/cmp/all/test_package/CMakeLists.txt b/recipes/cmp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..059b67a026f33 --- /dev/null +++ b/recipes/cmp/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(cmp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE cmp::cmp) diff --git a/recipes/cmp/all/test_package/conanfile.py b/recipes/cmp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/cmp/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cmp/all/test_package/test_package.c b/recipes/cmp/all/test_package/test_package.c new file mode 100644 index 0000000000000..b3d7579a14f99 --- /dev/null +++ b/recipes/cmp/all/test_package/test_package.c @@ -0,0 +1,11 @@ +#include +#include +#include +#include +#include + +int main() +{ + printf("cmp version: %u\n", cmp_version()); + return EXIT_SUCCESS; +} diff --git a/recipes/cmp/all/test_v1_package/CMakeLists.txt b/recipes/cmp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..bde0b0bffb0fa --- /dev/null +++ b/recipes/cmp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cmp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE cmp::cmp) diff --git a/recipes/cmp/all/test_v1_package/conanfile.py b/recipes/cmp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cmp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cmp/config.yml b/recipes/cmp/config.yml new file mode 100644 index 0000000000000..87cab3dd1a538 --- /dev/null +++ b/recipes/cmp/config.yml @@ -0,0 +1,5 @@ +versions: + "20": + folder: "all" + "19": + folder: "all" diff --git a/recipes/cn-cbor/all/conandata.yml b/recipes/cn-cbor/all/conandata.yml index 36c49a5492539..4de861bba88a9 100644 --- a/recipes/cn-cbor/all/conandata.yml +++ b/recipes/cn-cbor/all/conandata.yml @@ -2,4 +2,3 @@ sources: "1.0.0": sha256: eca2bcc15b8400037fd95748724287afbb966e34d4d0275a496b4872bcea9d77 url: https://github.com/jimsch/cn-cbor/archive/1.0.0.zip - diff --git a/recipes/cn-cbor/all/conanfile.py b/recipes/cn-cbor/all/conanfile.py index ffb0e3a88f745..74e90a06cc919 100644 --- a/recipes/cn-cbor/all/conanfile.py +++ b/recipes/cn-cbor/all/conanfile.py @@ -8,8 +8,8 @@ class CnCborStackConan(ConanFile): license = "MIT" homepage = "https://github.com/jimsch/cn-cbor/" url = "https://github.com/conan-io/conan-center-index" - description = """A constrained node implementation of CBOR in C""" - topics = ("cbor", "nodes", "messaging") + description = "A constrained node implementation of CBOR in C" + topics = "cbor", "nodes", "messaging" exports_sources = ['CMakeLists.txt'] settings = "os", "compiler", "build_type", "arch" options = { @@ -39,6 +39,8 @@ def config_options(self): def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC if self.settings.os == "Windows" and self.options.shared: raise ConanInvalidConfiguration("Windows shared builds are not supported right now") @@ -64,8 +66,6 @@ def build(self): cmake = self._configure_cmake() cmake.build() - - def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() @@ -74,8 +74,7 @@ def package(self): os.remove(os.path.join(self.package_folder, "LICENSE")) tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, - "lib", "cn-cbor", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cn-cbor", "cmake")) def package_info(self): self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/cnpy/all/CMakeLists.txt b/recipes/cnpy/all/CMakeLists.txt deleted file mode 100644 index faa97ba1ac412..0000000000000 --- a/recipes/cnpy/all/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - -add_subdirectory("source_subfolder") diff --git a/recipes/cnpy/all/conandata.yml b/recipes/cnpy/all/conandata.yml index 953d832ba545b..a4b4bcd8ca10b 100644 --- a/recipes/cnpy/all/conandata.yml +++ b/recipes/cnpy/all/conandata.yml @@ -4,5 +4,4 @@ sources: sha256: "5120abc54a564efa92c642cc0199cc4fd3f345901157de9fbbdcedbb34d28d8a" patches: "cci.20180601": - - patch_file: "patches/0001-exclude-example.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-fix-cmake.patch" diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index 794d778b22da5..1ee4b6417368a 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -1,36 +1,32 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get import os -import glob -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.53.0" + class CnpyConan(ConanFile): name = "cnpy" description = "library to read/write .npy and .npz files in C/C++" license = "MIT" - topics = ("conan", "cnpy") - homepage = "https://github.com/hongyx11/cnpy" + topics = ("numpy", "npy", "npz") + homepage = "https://github.com/rogersce/cnpy" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake", "cmake_find_package" - settings = "os", "arch", "compiler", "build_type" - _cmake = None + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], - "fPIC": [True, False] + "fPIC": [True, False], } default_options = { "shared": False, - "fPIC": True + "fPIC": True, } - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -38,36 +34,38 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13", transitive_headers=True, transitive_libs=True) + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob(self.name + "-*")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_STATIC"] = not self.options.shared - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.names["cmake_find_package"] = "cnpy" - self.cpp_info.names["cmake_find_package_multi"] = "cnpy" self.cpp_info.libs = ["cnpy"] diff --git a/recipes/cnpy/all/patches/0001-exclude-example.patch b/recipes/cnpy/all/patches/0001-exclude-example.patch deleted file mode 100644 index f39f242261c6a..0000000000000 --- a/recipes/cnpy/all/patches/0001-exclude-example.patch +++ /dev/null @@ -1,37 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 9eb550f..d57c6dd 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -5,26 +5,17 @@ endif(COMMAND cmake_policy) - - project(CNPY) - --set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -- --option(ENABLE_STATIC "Build static (.a) library" ON) -- - find_package(ZLIB REQUIRED) - - include_directories(${ZLIB_INCLUDE_DIRS}) - --add_library(cnpy SHARED "cnpy.cpp") -+add_library(cnpy "cnpy.cpp") - target_link_libraries(cnpy ${ZLIB_LIBRARIES}) --install(TARGETS "cnpy" LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) -- --if(ENABLE_STATIC) -- add_library(cnpy-static STATIC "cnpy.cpp") -- set_target_properties(cnpy-static PROPERTIES OUTPUT_NAME "cnpy") -- install(TARGETS "cnpy-static" ARCHIVE DESTINATION lib) --endif(ENABLE_STATIC) -+set_property(TARGET cnpy PROPERTY CXX_STANDARD 11) -+install(TARGETS "cnpy" -+ LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE -+ ARCHIVE DESTINATION lib -+ RUNTIME DESTINATION bin) - - install(FILES "cnpy.h" DESTINATION include) --install(FILES "mat2npz" "npy2mat" "npz2mat" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - --add_executable(example1 example1.cpp) --target_link_libraries(example1 cnpy) diff --git a/recipes/cnpy/all/patches/0001-fix-cmake.patch b/recipes/cnpy/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..b3ee3550b104d --- /dev/null +++ b/recipes/cnpy/all/patches/0001-fix-cmake.patch @@ -0,0 +1,40 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,30 +1,18 @@ +-CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR) +-if(COMMAND cmake_policy) +- cmake_policy(SET CMP0003 NEW) +-endif(COMMAND cmake_policy) ++CMAKE_MINIMUM_REQUIRED(VERSION 3.8) + +-project(CNPY) ++project(CNPY LANGUAGES CXX) + +-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +-option(ENABLE_STATIC "Build static (.a) library" ON) + + find_package(ZLIB REQUIRED) + +-include_directories(${ZLIB_INCLUDE_DIRS}) + +-add_library(cnpy SHARED "cnpy.cpp") +-target_link_libraries(cnpy ${ZLIB_LIBRARIES}) +-install(TARGETS "cnpy" LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) ++add_library(cnpy "cnpy.cpp") ++target_compile_features(cnpy PUBLIC cxx_std_11) ++set_target_properties(cnpy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) ++target_link_libraries(cnpy PUBLIC ZLIB::ZLIB) ++install(TARGETS "cnpy" LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) + +-if(ENABLE_STATIC) +- add_library(cnpy-static STATIC "cnpy.cpp") +- set_target_properties(cnpy-static PROPERTIES OUTPUT_NAME "cnpy") +- install(TARGETS "cnpy-static" ARCHIVE DESTINATION lib) +-endif(ENABLE_STATIC) + + install(FILES "cnpy.h" DESTINATION include) +-install(FILES "mat2npz" "npy2mat" "npz2mat" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + +-add_executable(example1 example1.cpp) +-target_link_libraries(example1 cnpy) diff --git a/recipes/cnpy/all/test_package/CMakeLists.txt b/recipes/cnpy/all/test_package/CMakeLists.txt index 9145952903057..18d71adb9d0d4 100644 --- a/recipes/cnpy/all/test_package/CMakeLists.txt +++ b/recipes/cnpy/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.1.0) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() -add_executable(${PROJECT_NAME} example1.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +find_package(cnpy REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cnpy::cnpy) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cnpy/all/test_package/conanfile.py b/recipes/cnpy/all/test_package/conanfile.py index ea57a464900be..0a6bc68712d90 100644 --- a/recipes/cnpy/all/test_package/conanfile.py +++ b/recipes/cnpy/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cnpy/all/test_package/example1.cpp b/recipes/cnpy/all/test_package/test_package.cpp similarity index 100% rename from recipes/cnpy/all/test_package/example1.cpp rename to recipes/cnpy/all/test_package/test_package.cpp diff --git a/recipes/cnpy/all/test_v1_package/CMakeLists.txt b/recipes/cnpy/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/cnpy/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/cnpy/all/test_v1_package/conanfile.py b/recipes/cnpy/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cnpy/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/civetweb/all/CMakeLists.txt b/recipes/co/all/CMakeLists.txt similarity index 100% rename from recipes/civetweb/all/CMakeLists.txt rename to recipes/co/all/CMakeLists.txt diff --git a/recipes/co/all/conandata.yml b/recipes/co/all/conandata.yml new file mode 100644 index 0000000000000..e71aeda87ca26 --- /dev/null +++ b/recipes/co/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "2.0.2": + url: "https://github.com/idealvin/co/archive/refs/tags/v2.0.2.tar.gz" + sha256: "5dbb90e18627ebe563a6a437e8e28329a6bfc07f266718318bd3adf26027d156" +patches: + "2.0.2": + - patch_file: "patches/001-install-dll.patch" + base_path: "source_subfolder" diff --git a/recipes/co/all/conanfile.py b/recipes/co/all/conanfile.py new file mode 100644 index 0000000000000..5be88f24e0ce3 --- /dev/null +++ b/recipes/co/all/conanfile.py @@ -0,0 +1,104 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + + +class CoConan(ConanFile): + name = "co" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/idealvin/co" + license = "MIT" + description = "A go-style coroutine library in C++11 and more." + topics = ("co", "coroutine", "c++11") + + deprecated = "cocoyaxi" + + exports_sources = "CMakeLists.txt", "patches/*" + generators = "cmake", "cmake_find_package" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_libcurl": [True, False], + "with_openssl": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_libcurl": False, + "with_openssl": False, + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.options.with_libcurl: + self.requires("libcurl/7.79.1") + if self.options.with_openssl: + self.requires("openssl/1.1.1l") + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # The OSX_ARCHITECTURES target property is now respected for the ASM language + self.build_requires("cmake/3.20.1") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + if not self.options.shared: + self._cmake.definitions["FPIC"] = self.options.get_safe("fPIC", False) + runtime = self.settings.get_safe("compiler.runtime") + if runtime: + self._cmake.definitions["STATIC_VS_CRT"] = "MT" in runtime + self._cmake.definitions["WITH_LIBCURL"] = self.options.with_libcurl + self._cmake.definitions["WITH_OPENSSL"] = self.options.with_openssl + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["co"] + self.cpp_info.names["cmake_find_package"] = "co" + self.cpp_info.names["cmake_find_package_multi"] = "co" + + def validate(self): + if self.options.with_libcurl: + if not self.options.with_openssl: + raise ConanInvalidConfiguration(f"{self.name} requires with_openssl=True when using with_libcurl=True") + if self.options["libcurl"].with_ssl != "openssl": + raise ConanInvalidConfiguration(f"{self.name} requires libcurl:with_ssl='openssl' to be enabled") + if not self.options["libcurl"].with_zlib: + raise ConanInvalidConfiguration(f"{self.name} requires libcurl:with_zlib=True to be enabled") diff --git a/recipes/co/all/patches/001-install-dll.patch b/recipes/co/all/patches/001-install-dll.patch new file mode 100644 index 0000000000000..9332f3296762e --- /dev/null +++ b/recipes/co/all/patches/001-install-dll.patch @@ -0,0 +1,10 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 9e03c9a..499b550 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -112,4 +112,5 @@ install( + TARGETS co + LIBRARY DESTINATION lib # shared lib installed to ${CMAKE_INSTALL_PREFIX}/lib + ARCHIVE DESTINATION lib # static lib installed to ${CMAKE_INSTALL_PREFIX}/lib ++ RUNTIME DESTINATION bin + ) diff --git a/recipes/co/all/patches/002-fix-event-destruct.patch b/recipes/co/all/patches/002-fix-event-destruct.patch new file mode 100644 index 0000000000000..7949dbdca3146 --- /dev/null +++ b/recipes/co/all/patches/002-fix-event-destruct.patch @@ -0,0 +1,13 @@ +diff --git a/src/co/co.cc b/src/co/co.cc +index 8921296..838ac16 100644 +--- a/src/co/co.cc ++++ b/src/co/co.cc +@@ -8,7 +8,7 @@ namespace co { + class EventImpl { + public: + EventImpl() : _counter(0), _signaled(false), _has_cond(false) {} +- ~EventImpl() { co::xx::cond_destroy(&_cond); } ++ ~EventImpl() { if (_has_cond) co::xx::cond_destroy(&_cond); } + + bool wait(uint32 ms); + diff --git a/recipes/co/all/test_package/CMakeLists.txt b/recipes/co/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d9ea9b93dcee7 --- /dev/null +++ b/recipes/co/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +set(CMAKE_CXX_STANDARD 11) +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(co REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cc) +target_link_libraries(${PROJECT_NAME} co::co) diff --git a/recipes/co/all/test_package/conanfile.py b/recipes/co/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5493d58611803 --- /dev/null +++ b/recipes/co/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/co/all/test_package/test_package.cc b/recipes/co/all/test_package/test_package.cc new file mode 100644 index 0000000000000..46b92d23f6830 --- /dev/null +++ b/recipes/co/all/test_package/test_package.cc @@ -0,0 +1,7 @@ +#include "co/str.h" +#include + +int main() { + std::cout << str::from(123) << std::endl; + return 0; +} diff --git a/recipes/co/config.yml b/recipes/co/config.yml new file mode 100644 index 0000000000000..5df97e2cc232e --- /dev/null +++ b/recipes/co/config.yml @@ -0,0 +1,3 @@ +versions: + "2.0.2": + folder: all diff --git a/recipes/cocoyaxi/all/conandata.yml b/recipes/cocoyaxi/all/conandata.yml new file mode 100644 index 0000000000000..535de47c89a52 --- /dev/null +++ b/recipes/cocoyaxi/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.0.3": + url: "https://github.com/idealvin/coost/archive/refs/tags/v2.0.3.tar.gz" + sha256: "afb5219e56cbcfae1211590e01ad9d9d7f61287e76d9dea5c5f68c432f85bf30" diff --git a/recipes/cocoyaxi/all/conanfile.py b/recipes/cocoyaxi/all/conanfile.py new file mode 100644 index 0000000000000..217d2d1b7c4e1 --- /dev/null +++ b/recipes/cocoyaxi/all/conanfile.py @@ -0,0 +1,97 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +import os + +required_conan_version = ">=1.50.0" + + +class CocoyaxiConan(ConanFile): + name = "cocoyaxi" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/idealvin/cocoyaxi" + license = "MIT" + description = "A go-style coroutine library in C++11 and more." + topics = ("cocoyaxi", "coroutine", "c++11") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_libcurl": [True, False], + "with_openssl": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_libcurl": False, + "with_openssl": False, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.options.with_libcurl: + self.requires("libcurl/7.80.0") + if self.options.with_libcurl or self.options.with_openssl: + self.requires("openssl/1.1.1q") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + if self.info.options.with_libcurl: + if not self.info.options.with_openssl: + raise ConanInvalidConfiguration(f"{self.name} requires with_openssl=True when using with_libcurl=True") + if self.dependencies["libcurl"].options.with_ssl != "openssl": + raise ConanInvalidConfiguration(f"{self.name} requires libcurl:with_ssl='openssl' to be enabled") + if not self.dependencies["libcurl"].options.with_zlib: + raise ConanInvalidConfiguration(f"{self.name} requires libcurl:with_zlib=True to be enabled") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if is_msvc(self): + tc.variables["STATIC_VS_CRT"] = is_msvc_static_runtime(self) + tc.variables["WITH_LIBCURL"] = self.options.with_libcurl + tc.variables["WITH_OPENSSL"] = self.options.with_openssl + tc.generate() + cd = CMakeDeps(self) + cd.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "cocoyaxi") + self.cpp_info.set_property("cmake_target_name", "cocoyaxi::co") + # TODO: back to global scope in conan v2 once legacy generators removed + self.cpp_info.components["co"].libs = ["co"] + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.components["co"].set_property("cmake_target_name", "cocoyaxi::co") + if self.options.with_libcurl: + self.cpp_info.components["co"].requires.append("libcurl::libcurl") + if self.options.with_libcurl or self.options.with_openssl: + self.cpp_info.components["co"].requires.append("openssl::openssl") diff --git a/recipes/cocoyaxi/all/test_package/CMakeLists.txt b/recipes/cocoyaxi/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2d0878488574e --- /dev/null +++ b/recipes/cocoyaxi/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(cocoyaxi REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cocoyaxi::co) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cocoyaxi/all/test_package/conanfile.py b/recipes/cocoyaxi/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/cocoyaxi/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cocoyaxi/all/test_package/test_package.cpp b/recipes/cocoyaxi/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..46b92d23f6830 --- /dev/null +++ b/recipes/cocoyaxi/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include "co/str.h" +#include + +int main() { + std::cout << str::from(123) << std::endl; + return 0; +} diff --git a/recipes/cocoyaxi/all/test_v1_package/CMakeLists.txt b/recipes/cocoyaxi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..882cedffb12e9 --- /dev/null +++ b/recipes/cocoyaxi/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cocoyaxi REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cocoyaxi::co) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cocoyaxi/all/test_v1_package/conanfile.py b/recipes/cocoyaxi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cocoyaxi/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cocoyaxi/config.yml b/recipes/cocoyaxi/config.yml new file mode 100644 index 0000000000000..7f57148a20478 --- /dev/null +++ b/recipes/cocoyaxi/config.yml @@ -0,0 +1,3 @@ +versions: + "2.0.3": + folder: all diff --git a/recipes/coin-cbc/all/conandata.yml b/recipes/coin-cbc/all/conandata.yml index af2b1518d973d..99a9ed92100b1 100644 --- a/recipes/coin-cbc/all/conandata.yml +++ b/recipes/coin-cbc/all/conandata.yml @@ -6,3 +6,5 @@ patches: "2.10.5": - patch_file: "patches/0001-no-pkg-config-check.patch" base_path: "source_subfolder" + - patch_file: "patches/0002-pthreads4w.patch" + base_path: "source_subfolder" diff --git a/recipes/coin-cbc/all/conanfile.py b/recipes/coin-cbc/all/conanfile.py index 8f69fa985cac5..ffea985fa3a7d 100644 --- a/recipes/coin-cbc/all/conanfile.py +++ b/recipes/coin-cbc/all/conanfile.py @@ -1,14 +1,19 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import rename, get, apply_conandata_patches, rmdir, mkdir +from conan.tools.build import cross_building +from conan.tools.scm import Version +from conans import AutoToolsBuildEnvironment, tools from contextlib import contextmanager import os import shutil +required_conan_version = ">=1.47.0" class CoinCbcConan(ConanFile): name = "coin-cbc" description = "COIN-OR Branch-and-Cut solver" - topics = ("conan", "clp", "simplex", "solver", "linear", "programming") + topics = ("clp", "simplex", "solver", "linear", "programming") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/coin-or/Clp" license = ("EPL-2.0",) @@ -16,12 +21,13 @@ class CoinCbcConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "parallel": [True, False], } default_options = { "shared": False, "fPIC": True, + "parallel": False, } - exports_sources = "patches/**.patch" generators = "pkg_config" _autotools = None @@ -34,13 +40,15 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("coin-cbc does not support shared builds on Windows") if self.options.shared: del self.options.fPIC @@ -49,27 +57,45 @@ def requirements(self): self.requires("coin-osi/0.108.6") self.requires("coin-clp/1.17.6") self.requires("coin-cgl/0.60.3") + if self.settings.compiler == "Visual Studio" and self.options.parallel: + self.requires("pthreads4w/3.0.0") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) def build_requirements(self): - self.build_requires("pkgconf/1.7.3") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + self.tool_requires("gnu-config/cci.20201022") + self.tool_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.tool_requires("msys2/cci.latest") if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.2") + self.tool_requires("automake/1.16.5") + + def validate(self): + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("coin-cbc does not support shared builds on Windows") + # FIXME: This issue likely comes from very old autotools versions used to produce configure. + if hasattr(self, "settings_build") and cross_building(self) and self.options.shared: + raise ConanInvalidConfiguration("coin-cbc shared not supported yet when cross-building") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("Cbc-releases-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) @contextmanager def _build_context(self): if self.settings.compiler == "Visual Studio": with tools.vcvars(self.settings): env = { - "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "LD": "{} link -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "LD": "{} link -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), } with tools.environment_append(env): yield @@ -84,18 +110,27 @@ def _configure_autotools(self): yes_no = lambda v: "yes" if v else "no" configure_args = [ "--enable-shared={}".format(yes_no(self.options.shared)), - "--without-blas" - "--without-lapack" + "--enable-cbc-parallel={}".format(yes_no(self.options.parallel)), + "--without-blas", + "--without-lapack", ] if self.settings.compiler == "Visual Studio": self._autotools.cxx_flags.append("-EHsc") - configure_args.append("--enable-msvc={}".format(self.settings.compiler.runtime)) + configure_args.append(f"--enable-msvc={self.settings.compiler.runtime}") + if Version(self.settings.compiler.version) >= 12: + self._autotools.flags.append("-FS") + if self.options.parallel: + configure_args.append("--with-pthreadsw32-lib={}".format(tools.unix_path(os.path.join(self.deps_cpp_info["pthreads4w"].lib_paths[0], self.deps_cpp_info["pthreads4w"].libs[0] + ".lib")))) + configure_args.append("--with-pthreadsw32-incdir={}".format(tools.unix_path(self.deps_cpp_info["pthreads4w"].include_paths[0]))) self._autotools.configure(configure_dir=os.path.join(self.source_folder, self._source_subfolder), args=configure_args) return self._autotools def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) with self._build_context(): autotools = self._configure_autotools() autotools.make() @@ -103,25 +138,30 @@ def build(self): def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") # Installation script expects include/coin to already exist - tools.mkdir(os.path.join(self.package_folder, "include", "coin")) + mkdir(self, os.path.join(self.package_folder, "include", "coin")) with self._build_context(): autotools = self._configure_autotools() autotools.install() for l in ("CbcSolver", "Cbc", "OsiCbc"): - os.unlink(os.path.join(self.package_folder, "lib", "lib{}.la").format(l)) + os.unlink(f"{self.package_folder}/lib/lib{l}.la") if self.settings.compiler == "Visual Studio": - os.rename(os.path.join(self.package_folder, "lib", "lib{}.a").format(l), - os.path.join(self.package_folder, "lib", "{}.lib").format(l)) + rename(self, + f"{self.package_folder}/lib/lib{l}.a", + f"{self.package_folder}/lib/{l}.lib") - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): self.cpp_info.components["libcbc"].libs = ["CbcSolver", "Cbc"] self.cpp_info.components["libcbc"].includedirs.append(os.path.join("include", "coin")) self.cpp_info.components["libcbc"].requires = ["coin-clp::osi-clp", "coin-utils::coin-utils", "coin-osi::coin-osi", "coin-cgl::coin-cgl"] self.cpp_info.components["libcbc"].names["pkg_config"] = "cbc" + if self.settings.os in ["Linux", "FreeBSD"] and self.options.parallel: + self.cpp_info.components["libcbc"].system_libs.append("pthread") + if self.settings.os in ["Windows"] and self.options.parallel: + self.cpp_info.components["libcbc"].requires.append("pthreads4w::pthreads4w") self.cpp_info.components["osi-cbc"].libs = ["OsiCbc"] self.cpp_info.components["osi-cbc"].requires = ["libcbc"] diff --git a/recipes/coin-cbc/all/patches/0002-pthreads4w.patch b/recipes/coin-cbc/all/patches/0002-pthreads4w.patch new file mode 100644 index 0000000000000..e5211957dfea0 --- /dev/null +++ b/recipes/coin-cbc/all/patches/0002-pthreads4w.patch @@ -0,0 +1,11 @@ +--- a/Cbc/configure ++++ b/Cbc/configure +@@ -30970,7 +30970,7 @@ cat >>confdefs.h <<\_ACEOF + #define CBC_THREAD 1 + _ACEOF + +- if test $coin_cxx_is_cl = true ; ++ if test "${with_pthreadsw32_lib+set}" = set ; + then + # TODO we should check whether the library works and pthread.h is indeed there + diff --git a/recipes/coin-cbc/all/test_package/conanfile.py b/recipes/coin-cbc/all/test_package/conanfile.py index 6605d353d5c93..9ade272b0a40d 100644 --- a/recipes/coin-cbc/all/test_package/conanfile.py +++ b/recipes/coin-cbc/all/test_package/conanfile.py @@ -7,7 +7,7 @@ class TestPackageConan(ConanFile): generators = "cmake", "pkg_config" def build_requirements(self): - self.build_requires("pkgconf/1.7.3") + self.build_requires("pkgconf/1.7.4") def build(self): cmake = CMake(self) diff --git a/recipes/coin-cgl/all/conanfile.py b/recipes/coin-cgl/all/conanfile.py index 4d1dd46599a97..152335302dd9a 100644 --- a/recipes/coin-cgl/all/conanfile.py +++ b/recipes/coin-cgl/all/conanfile.py @@ -1,13 +1,19 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import rename, get, apply_conandata_patches, rmdir +from conan.tools.build import cross_building +from conan.tools.scm import Version +from conans import AutoToolsBuildEnvironment, tools from contextlib import contextmanager import os +import shutil +required_conan_version = ">=1.47.0" class CoinCglConan(ConanFile): name = "coin-cgl" description = "COIN-OR Cut Generator Library" - topics = ("conan", "clp", "simplex", "solver", "linear", "programming") + topics = ("cgl", "simplex", "solver", "linear", "programming") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/coin-or/Cgl" license = ("EPL-2.0",) @@ -20,7 +26,6 @@ class CoinCglConan(ConanFile): "shared": False, "fPIC": True, } - exports_sources = "patches/**.patch" generators = "pkg_config" _autotools = None @@ -33,13 +38,15 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("coin-cgl does not support shared builds on Windows") if self.options.shared: del self.options.fPIC @@ -48,24 +55,42 @@ def requirements(self): self.requires("coin-osi/0.108.6") self.requires("coin-clp/1.17.6") + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def build_requirements(self): - self.build_requires("pkgconf/1.7.3") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + self.tool_requires("gnu-config/cci.20201022") + self.tool_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.tool_requires("msys2/cci.latest") + if self.settings.compiler == "Visual Studio": + self.tool_requires("automake/1.16.5") + + def validate(self): + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("coin-cgl does not support shared builds on Windows") + # FIXME: This issue likely comes from very old autotools versions used to produce configure. + if hasattr(self, "settings_build") and cross_building(self) and self.options.shared: + raise ConanInvalidConfiguration("coin-cgl shared not supported yet when cross-building") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("Cgl-releases-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) @contextmanager def _build_context(self): if self.settings.compiler == "Visual Studio": with tools.vcvars(self.settings): env = { - "CC": "cl -nologo", - "CXX": "cl -nologo", - "LD": "link -nologo", - "AR": "lib", + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "LD": "{} link -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), } with tools.environment_append(env): yield @@ -80,18 +105,23 @@ def _configure_autotools(self): yes_no = lambda v: "yes" if v else "no" configure_args = [ "--enable-shared={}".format(yes_no(self.options.shared)), - "--without-blas" - "--without-lapack" + "--without-blas", + "--without-lapack", ] if self.settings.compiler == "Visual Studio": self._autotools.cxx_flags.append("-EHsc") - configure_args.append("--enable-msvc={}".format(self.settings.compiler.runtime)) + configure_args.append(f"--enable-msvc={self.settings.compiler.runtime}") + if Version(self.settings.compiler.version) >= 12: + self._autotools.flags.append("-FS") self._autotools.configure(configure_dir=os.path.join(self.source_folder, self._source_subfolder), args=configure_args) return self._autotools def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) with self._build_context(): autotools = self._configure_autotools() autotools.make() @@ -105,13 +135,14 @@ def package(self): os.unlink(os.path.join(self.package_folder, "lib", "libCgl.la")) if self.settings.compiler == "Visual Studio": - os.rename(os.path.join(self.package_folder, "lib", "libCgl.lib"), - os.path.join(self.package_folder, "lib", "Cgl.lib")) + rename(self, + os.path.join(self.package_folder, "lib", "libCgl.a"), + os.path.join(self.package_folder, "lib", "Cgl.lib")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): self.cpp_info.libs = ["Cgl"] - self.cpp_info.includedirs = [os.path.join("include", "coin")] + self.cpp_info.includedirs.append(os.path.join("include", "coin")) self.cpp_info.names["pkg_config"] = "cgl" diff --git a/recipes/coin-cgl/all/test_package/conanfile.py b/recipes/coin-cgl/all/test_package/conanfile.py index 6605d353d5c93..9e09e219fdcb3 100644 --- a/recipes/coin-cgl/all/test_package/conanfile.py +++ b/recipes/coin-cgl/all/test_package/conanfile.py @@ -7,7 +7,7 @@ class TestPackageConan(ConanFile): generators = "cmake", "pkg_config" def build_requirements(self): - self.build_requires("pkgconf/1.7.3") + self.build_requires("pkgconf/1.7.4") def build(self): cmake = CMake(self) @@ -15,6 +15,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/coin-clp/all/conanfile.py b/recipes/coin-clp/all/conanfile.py index 0158bfe6e7c64..39939b551d54c 100644 --- a/recipes/coin-clp/all/conanfile.py +++ b/recipes/coin-clp/all/conanfile.py @@ -1,13 +1,20 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, apply_conandata_patches, mkdir, rm, rmdir, rename +from conan.tools.build import cross_building +from conan.tools.scm import Version +from conans import AutoToolsBuildEnvironment, tools from contextlib import contextmanager import os +import shutil + +required_conan_version = ">=1.50.0" class CoinClpConan(ConanFile): name = "coin-clp" description = "COIN-OR Linear Programming Solver" - topics = ("conan", "clp", "simplex", "solver", "linear", "programming") + topics = ("clp", "simplex", "solver", "linear", "programming") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/coin-or/Clp" license = ("EPL-2.0",) @@ -33,13 +40,19 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("coin-clp does not support shared builds on Windows") if self.options.shared: del self.options.fPIC @@ -47,30 +60,40 @@ def requirements(self): self.requires("coin-utils/2.11.4") self.requires("coin-osi/0.108.6") + def validate(self): + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("coin-clp does not support shared builds on Windows") + # FIXME: This issue likely comes from very old autotools versions used to produce configure. + if hasattr(self, "settings_build") and cross_building(self) and self.options.shared: + raise ConanInvalidConfiguration("coin-clp shared not supported yet when cross-building") + def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + self.build_requires("gnu-config/cci.20201022") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.2") + self.build_requires("automake/1.16.4") + self.build_requires("pkgconf/1.7.4") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("Clp-releases-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) @contextmanager def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - env = { - "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "LD": "{} link -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), - } - with tools.environment_append(env): - yield - else: - yield + with tools.environment_append({"PKG_CONFIG_PATH": self.install_folder}): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self.settings): + env = { + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "LD": "{} link -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), + } + with tools.environment_append(env): + yield + else: + yield def _configure_autotools(self): if self._autotools: @@ -81,12 +104,17 @@ def _configure_autotools(self): configure_args = [ "--enable-shared={}".format(yes_no(self.options.shared)), ] - self._autotools.configure(configure_dir=os.path.join(self.source_folder, self._source_subfolder), args=configure_args) + if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= 12: + self._autotools.flags.append("-FS") + self._autotools.configure(self._source_subfolder, args=configure_args) return self._autotools def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) with self._build_context(): autotools = self._configure_autotools() autotools.make() @@ -94,19 +122,18 @@ def build(self): def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") # Installation script expects include/coin to already exist - tools.mkdir(os.path.join(self.package_folder, "include", "coin")) + mkdir(self, os.path.join(self.package_folder, "include", "coin")) with self._build_context(): autotools = self._configure_autotools() - autotools.install() + autotools.install(args=["-j1"]) # due to configure generated with old autotools version - for l in ("Clp", "ClpSolver", "OsiClp"): - os.unlink(os.path.join(self.package_folder, "lib", "lib{}.la").format(l)) - if self.settings.compiler == "Visual Studio": - os.rename(os.path.join(self.package_folder, "lib", "lib{}.a").format(l), - os.path.join(self.package_folder, "lib", "{}.lib").format(l)) - - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + if self.settings.compiler == "Visual Studio": + for l in ("Clp", "ClpSolver", "OsiClp"): + rename(self, os.path.join(self.package_folder, "lib", f"lib{l}.a"), + os.path.join(self.package_folder, "lib", f"{l}.lib")) def package_info(self): self.cpp_info.components["clp"].libs = ["ClpSolver", "Clp"] diff --git a/recipes/coin-clp/all/test_package/conanfile.py b/recipes/coin-clp/all/test_package/conanfile.py index 2aa5dfbd935f5..d24de2f0b2690 100644 --- a/recipes/coin-clp/all/test_package/conanfile.py +++ b/recipes/coin-clp/all/test_package/conanfile.py @@ -3,11 +3,11 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "pkg_config" def build_requirements(self): - self.build_requires("pkgconf/1.7.3") + self.build_requires("pkgconf/1.7.4") def build(self): cmake = CMake(self) @@ -15,7 +15,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") mps = os.path.join(self.source_folder, "sample.mps") self.run("{} {}".format(bin_path, mps), run_environment=True) diff --git a/recipes/coin-lemon/all/conandata.yml b/recipes/coin-lemon/all/conandata.yml new file mode 100644 index 0000000000000..f00f950c896c3 --- /dev/null +++ b/recipes/coin-lemon/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.3.1": + url: "http://lemon.cs.elte.hu/pub/sources/lemon-1.3.1.tar.gz" + sha256: "71b7c725f4c0b4a8ccb92eb87b208701586cf7a96156ebd821ca3ed855bad3c8" +patches: + "1.3.1": + - patch_file: "patches/cmake-add-runtime-destination_1.3.1.patch" + - patch_file: "patches/0001-remove-register-keyword.patch" diff --git a/recipes/coin-lemon/all/conanfile.py b/recipes/coin-lemon/all/conanfile.py new file mode 100644 index 0000000000000..d76140ba95344 --- /dev/null +++ b/recipes/coin-lemon/all/conanfile.py @@ -0,0 +1,94 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file, rmdir +import os + +required_conan_version = ">=1.50.0" + + +class CoinLemonConan(ConanFile): + name = "coin-lemon" + license = "Boost 1.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://lemon.cs.elte.hu" + description = "LEMON stands for Library for Efficient Modeling and Optimization in Networks." + topics = ("data structures", "algorithms", "graphs", "network") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LEMON_ENABLE_GLPK"] = False + tc.variables["LEMON_ENABLE_ILOG"] = False + tc.variables["LEMON_ENABLE_COIN"] = False + tc.variables["LEMON_ENABLE_SOPLEX"] = False + # For msvc shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + # Relocatable shared libs on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # For Ninja generator + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0058"] = "NEW" + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # Disable demo, tools, doc & test + replace_in_file( + self, + os.path.join(self.source_folder, "CMakeLists.txt"), + "IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})", + "if(0)", + ) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "LEMON") + self.cpp_info.set_property("cmake_target_name", "LEMON::LEMON") # no official target name actually + self.cpp_info.set_property("pkg_config_name", "lemon") + self.cpp_info.libs = ["lemon" if self.settings.os == "Windows" else "emon"] + self.cpp_info.defines.append("LEMON_ONLY_TEMPLATES") + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "LEMON" + self.cpp_info.names["cmake_find_package_multi"] = "LEMON" + self.cpp_info.names["pkg_config"] = "lemon" diff --git a/recipes/coin-lemon/all/patches/0001-remove-register-keyword.patch b/recipes/coin-lemon/all/patches/0001-remove-register-keyword.patch new file mode 100644 index 0000000000000..dc78f03fdb7cc --- /dev/null +++ b/recipes/coin-lemon/all/patches/0001-remove-register-keyword.patch @@ -0,0 +1,15 @@ +diff --git a/lemon/random.h b/lemon/random.h +index 8de74ed..f9861f3 100644 +--- a/lemon/random.h ++++ b/lemon/random.h +@@ -249,8 +249,8 @@ namespace lemon { + + current = state + length; + +- register Word *curr = state + length - 1; +- register long num; ++ Word *curr = state + length - 1; ++ long num; + + num = length - shift; + while (num--) { diff --git a/recipes/coin-lemon/all/patches/cmake-add-runtime-destination_1.3.1.patch b/recipes/coin-lemon/all/patches/cmake-add-runtime-destination_1.3.1.patch new file mode 100644 index 0000000000000..310c19587e5ba --- /dev/null +++ b/recipes/coin-lemon/all/patches/cmake-add-runtime-destination_1.3.1.patch @@ -0,0 +1,12 @@ +diff --git a/lemon/CMakeLists.txt b/lemon/CMakeLists.txt +index 4e6567e..dec0513 100644 +--- a/lemon/CMakeLists.txt ++++ b/lemon/CMakeLists.txt +@@ -68,6 +68,7 @@ INSTALL( + TARGETS lemon + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib ++ RUNTIME DESTINATION bin + COMPONENT library + ) + diff --git a/recipes/coin-lemon/all/test_package/CMakeLists.txt b/recipes/coin-lemon/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5343530b3b283 --- /dev/null +++ b/recipes/coin-lemon/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(LEMON CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE LEMON::LEMON) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/coin-lemon/all/test_package/conanfile.py b/recipes/coin-lemon/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/coin-lemon/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/coin-lemon/all/test_package/test_package.cpp b/recipes/coin-lemon/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7c329ab87f4a2 --- /dev/null +++ b/recipes/coin-lemon/all/test_package/test_package.cpp @@ -0,0 +1,17 @@ +#include +#include "lemon/list_graph.h" + +using namespace lemon; +using namespace std; + +int main() +{ + ListDigraph g; + ListDigraph::Node u = g.addNode(); + ListDigraph::Node v = g.addNode(); + ListDigraph::Arc a = g.addArc(u, v); + cout << "Hello World! This is LEMON library here." << endl; + cout << "We have a directed graph with " << countNodes(g) << " nodes " + << "and " << countArcs(g) << " arc." << endl; + return 0; +} diff --git a/recipes/coin-lemon/all/test_v1_package/CMakeLists.txt b/recipes/coin-lemon/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d665d92471e4e --- /dev/null +++ b/recipes/coin-lemon/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(LEMON REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE LEMON::LEMON) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/coin-lemon/all/test_v1_package/conanfile.py b/recipes/coin-lemon/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/coin-lemon/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/coin-lemon/config.yml b/recipes/coin-lemon/config.yml new file mode 100644 index 0000000000000..71bf3f0e1bada --- /dev/null +++ b/recipes/coin-lemon/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3.1": + folder: "all" diff --git a/recipes/coin-osi/all/conanfile.py b/recipes/coin-osi/all/conanfile.py index 529fd8e34c0ea..798aa130f6fe1 100644 --- a/recipes/coin-osi/all/conanfile.py +++ b/recipes/coin-osi/all/conanfile.py @@ -1,13 +1,20 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration -from contextlib import contextmanager +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.files import get, apply_conandata_patches, rmdir, rm, rename +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +from conans import AutoToolsBuildEnvironment, tools +import contextlib import os +import shutil + +required_conan_version = ">=1.50.0" class CoinOsiConan(ConanFile): name = "coin-osi" description = "COIN-OR Linear Programming Solver" - topics = ("conan", "clp", "simplex", "solver", "linear", "programming") + topics = ("clp", "simplex", "solver", "linear", "programming") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/coin-or/Osi" license = ("EPL-2.0",) @@ -33,13 +40,19 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("coin-osi does not support shared builds on Windows") if self.options.shared: del self.options.fPIC @@ -47,18 +60,26 @@ def requirements(self): self.requires("coin-utils/2.11.4") def build_requirements(self): - self.build_requires("pkgconf/1.7.3") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + self.build_requires("gnu-config/cci.20201022") + self.build_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def validate(self): + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("coin-osi does not support shared builds on Windows") + # FIXME: This issue likely comes from very old autotools versions used to produce configure. + if hasattr(self, "settings_build") and cross_building(self) and self.options.shared: + raise ConanInvalidConfiguration("coin-osi shared not supported yet when cross-building") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("Osi-releases-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) - @contextmanager + @contextlib.contextmanager def _build_context(self): if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): + with tools.vcvars(self): env = { "CC": "cl -nologo", "CXX": "cl -nologo", @@ -83,13 +104,18 @@ def _configure_autotools(self): ] if self.settings.compiler == "Visual Studio": self._autotools.cxx_flags.append("-EHsc") - configure_args.append("--enable-msvc={}".format(self.settings.compiler.runtime)) - self._autotools.configure(configure_dir=os.path.join(self.source_folder, self._source_subfolder), args=configure_args) + configure_args.append(f"--enable-msvc={self.settings.compiler.runtime}") + if Version(self.settings.compiler.version) >= 12: + self._autotools.flags.append("-FS") + self._autotools.configure(configure_dir=self._source_subfolder, args=configure_args) return self._autotools def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) with self._build_context(): autotools = self._configure_autotools() autotools.make() @@ -98,18 +124,17 @@ def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") with self._build_context(): autotools = self._configure_autotools() - autotools.install() + autotools.install(args=["-j1"]) # due to configure generated with old autotools version - os.unlink(os.path.join(self.package_folder, "lib", "libOsi.la")) - os.unlink(os.path.join(self.package_folder, "lib", "libOsiCommonTests.la")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) if self.settings.compiler == "Visual Studio": for l in ("Osi", "OsiCommonTests"): - os.rename(os.path.join(self.package_folder, "lib", "lib{}.lib").format(l), - os.path.join(self.package_folder, "lib", "{}.lib").format(l)) + rename(self, os.path.join(self.package_folder, "lib", f"lib{l}.lib"), + os.path.join(self.package_folder, "lib", f"{l}.lib")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): self.cpp_info.components["libosi"].libs = ["Osi"] diff --git a/recipes/coin-osi/all/test_package/conanfile.py b/recipes/coin-osi/all/test_package/conanfile.py index 6605d353d5c93..9e09e219fdcb3 100644 --- a/recipes/coin-osi/all/test_package/conanfile.py +++ b/recipes/coin-osi/all/test_package/conanfile.py @@ -7,7 +7,7 @@ class TestPackageConan(ConanFile): generators = "cmake", "pkg_config" def build_requirements(self): - self.build_requires("pkgconf/1.7.3") + self.build_requires("pkgconf/1.7.4") def build(self): cmake = CMake(self) @@ -15,6 +15,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/coin-utils/all/conanfile.py b/recipes/coin-utils/all/conanfile.py index d104bc148db3b..43fc93be8d655 100644 --- a/recipes/coin-utils/all/conanfile.py +++ b/recipes/coin-utils/all/conanfile.py @@ -1,13 +1,20 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration -from contextlib import contextmanager -import os +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.files import get, apply_conandata_patches, rm, rmdir, rename +from conan.tools.scm import Version +from conan.tools.microsoft import is_msvc +from conans import AutoToolsBuildEnvironment, tools +import contextlib +import shutil + +required_conan_version = ">=1.50.0" class CoinUtilsConan(ConanFile): name = "coin-utils" description = "CoinUtils is an open-source collection of classes and helper functions that are generally useful to multiple COIN-OR projects." - topics = ("conan", "coin-utils", "sparse", "matrix", "helper", "parsing", "representation") + topics = ("coin-utils", "sparse", "matrix", "helper", "parsing", "representation") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/coin-or/CoinUtils" license = ("EPL-2.0",) @@ -20,6 +27,7 @@ class CoinUtilsConan(ConanFile): "shared": False, "fPIC": True, } + exports_sources = "patches/**" _autotools = None @@ -32,6 +40,14 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -39,32 +55,42 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.os == "Windows": - raise ConanInvalidConfiguration("coin-utils does not provide a shared library on Windows") def requirements(self): self.requires("zlib/1.2.11") self.requires("bzip2/1.0.8") + def validate(self): + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("coin-utils does not provide a shared library on Windows") + # FIXME: This issue likely comes from very old autotools versions used to produce configure. + # It might be fixed by calling autoreconf, but https://github.com/coin-or-tools/BuildTools + # should be packaged and added to build requirements. + if hasattr(self, "settings_build") and cross_building(self) and self.options.shared: + raise ConanInvalidConfiguration("coin-utils shared not supported yet when cross-building") + def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") - if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.2") + if not is_msvc(self): + self.build_requires("gnu-config/cci.20201022") + + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + if is_msvc(self): + self.build_requires("automake/1.16.4") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("CoinUtils-releases-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - @contextmanager + @contextlib.contextmanager def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): + if is_msvc(self): + with tools.vcvars(self): env = { - "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), "LD": "link -nologo", - "AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), } with tools.environment_append(env): yield @@ -76,22 +102,27 @@ def _configure_autotools(self): return self._autotools self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) self._autotools.libs = [] - if self.settings.compiler == "Visual Studio": + if is_msvc(self): self._autotools.cxx_flags.append("-EHsc") - self._autotools.flags.append("-FS") + if Version(self.settings.compiler.version) >= "12": + self._autotools.flags.append("-FS") yes_no = lambda v: "yes" if v else "no" configure_args = [ "--enable-shared={}".format(yes_no(self.options.shared)), "--enable-static={}".format(yes_no(not self.options.shared)), ] - if self.settings.compiler == "Visual Studio": - configure_args.append("--enable-msvc={}".format(self.settings.compiler.runtime)) - self._autotools.configure(configure_dir=os.path.join(self.source_folder, self._source_subfolder), args=configure_args) + if is_msvc(self): + configure_args.append(f"--enable-msvc={self.settings.compiler.runtime}") + self._autotools.configure(configure_dir=self._source_subfolder, args=configure_args) return self._autotools def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) + if not is_msvc(self): + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + f"{self._source_subfolder}/config.sub") + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + f"{self._source_subfolder}/config.guess") with self._build_context(): autotools = self._configure_autotools() autotools.make() @@ -100,20 +131,19 @@ def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") with self._build_context(): autotools = self._configure_autotools() - autotools.install() - - os.unlink(os.path.join(self.package_folder, "lib", "libCoinUtils.la")) + autotools.install(args=["-j1"]) - if self.settings.compiler == "Visual Studio": - os.rename(os.path.join(self.package_folder, "lib", "libCoinUtils.a"), - os.path.join(self.package_folder, "lib", "CoinUtils.lib")) + rm(self, "*.la", f"{self.package_folder}/lib") + rmdir(self, f"{self.package_folder}/lib/pkgconfig") + rmdir(self, f"{self.package_folder}/share") - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + if is_msvc(self): + rename(self, f"{self.package_folder}/lib/libCoinUtils.a", + f"{self.package_folder}/lib/CoinUtils.lib") def package_info(self): self.cpp_info.libs = ["CoinUtils"] - if self.settings.os == "Linux": + if self.settings.os in ("FreeBSD", "Linux"): self.cpp_info.system_libs = ["m"] - self.cpp_info.includedirs.append(os.path.join("include", "coin")) + self.cpp_info.includedirs.append("include/coin") self.cpp_info.names["pkg_config"] = "coinutils" diff --git a/recipes/coin-utils/all/test_package/conanfile.py b/recipes/coin-utils/all/test_package/conanfile.py index 0d546c0580b7c..a76b4ec929926 100644 --- a/recipes/coin-utils/all/test_package/conanfile.py +++ b/recipes/coin-utils/all/test_package/conanfile.py @@ -12,9 +12,9 @@ def build(self): cmake.build() def build_requirements(self): - self.build_requires("pkgconf/1.7.3") + self.build_requires("pkgconf/1.7.4") def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/concurrencpp/all/conandata.yml b/recipes/concurrencpp/all/conandata.yml new file mode 100644 index 0000000000000..1ea38721cc28a --- /dev/null +++ b/recipes/concurrencpp/all/conandata.yml @@ -0,0 +1,14 @@ +sources: + "0.1.5": + url: "https://github.com/David-Haim/concurrencpp/archive/refs/tags/v.0.1.5.tar.gz" + sha256: "330150ebe11b3d30ffcb3efdecc184a34cf50a6bd43b68e294a496225d286651" + "0.1.4": + url: "https://github.com/David-Haim/concurrencpp/archive/refs/tags/v.0.1.4.tar.gz" + sha256: "3ad9424f975b766accc6eaedf4acfe1a20b5fdbb57fa3ae71f400e13d471e86f" +patches: + "0.1.5": + - patch_file: "patches/cmake-min-version.patch" + - patch_file: "patches/directory-name-0.1.5.patch" + "0.1.4": + - patch_file: "patches/cmake-min-version.patch" + - patch_file: "patches/directory-name.patch" diff --git a/recipes/concurrencpp/all/conanfile.py b/recipes/concurrencpp/all/conanfile.py new file mode 100644 index 0000000000000..b561687e537bb --- /dev/null +++ b/recipes/concurrencpp/all/conanfile.py @@ -0,0 +1,104 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.0" + + +class ConcurrencppConan(ConanFile): + name = "concurrencpp" + description = "Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all." + homepage = "https://github.com/David-Haim/concurrencpp" + topics = ("scheduler", "coroutines", "concurrency", "tasks", "executors", "timers", "await", "multithreading") + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "msvc": "192", + "clang": "11", + } + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, "20") + if self.info.options.shared and is_msvc(self): + # see https://github.com/David-Haim/concurrencpp/issues/75 + raise ConanInvalidConfiguration("concurrencpp does not support shared builds with Visual Studio") + if self.info.settings.compiler == "gcc": + raise ConanInvalidConfiguration("gcc is not supported by concurrencpp") + if Version(self.version) >= "0.1.5" and self.info.settings.compiler == "apple-clang": + # apple-clang does not seem to support the C++20 synchronization library which concurrencpp 0.1.5 depends on + raise ConanInvalidConfiguration("apple-clang is not supported by concurrencpp 0.1.5 and higher") + + minimum_version = self._minimum_compilers_version.get( + str(self.info.settings.compiler), False + ) + if not minimum_version: + self.output.warn( + "concurrencpp requires C++20. Your compiler is unknown. Assuming it supports C++20." + ) + elif Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + "concurrencpp requires clang >= 11 or Visual Studio >= 16.8.2 as a compiler!" + ) + if self.info.settings.compiler == "clang" and self.info.settings.compiler.libcxx != "libc++": + raise ConanInvalidConfiguration("libc++ required") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "concurrencpp") + self.cpp_info.set_property("cmake_target_name", "concurrencpp::concurrencpp") + self.cpp_info.libs = ["concurrencpp"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["m", "pthread", "rt"] diff --git a/recipes/concurrencpp/all/patches/cmake-min-version.patch b/recipes/concurrencpp/all/patches/cmake-min-version.patch new file mode 100644 index 0000000000000..382d5c856d005 --- /dev/null +++ b/recipes/concurrencpp/all/patches/cmake-min-version.patch @@ -0,0 +1,8 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,3 +1,3 @@ +-cmake_minimum_required(VERSION 3.16) ++cmake_minimum_required(VERSION 3.15) + + project(concurrencpp diff --git a/recipes/concurrencpp/all/patches/directory-name-0.1.5.patch b/recipes/concurrencpp/all/patches/directory-name-0.1.5.patch new file mode 100644 index 0000000000000..73d77806a9b8a --- /dev/null +++ b/recipes/concurrencpp/all/patches/directory-name-0.1.5.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -104,8 +104,8 @@ include(CMakePackageConfigHelpers) + include(CMakePackageConfigHelpers) + include(GNUInstallDirs) + +-set(concurrencpp_directory "concurrencpp-${PROJECT_VERSION}") +-set(concurrencpp_include_directory "${CMAKE_INSTALL_INCLUDEDIR}/${concurrencpp_directory}") ++set(concurrencpp_directory "concurrencpp") ++set(concurrencpp_include_directory "${CMAKE_INSTALL_INCLUDEDIR}") + + install(TARGETS concurrencpp + EXPORT concurrencppTargets diff --git a/recipes/concurrencpp/all/patches/directory-name.patch b/recipes/concurrencpp/all/patches/directory-name.patch new file mode 100644 index 0000000000000..b79525132cfac --- /dev/null +++ b/recipes/concurrencpp/all/patches/directory-name.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -99,8 +99,8 @@ include(CMakePackageConfigHelpers) + include(CMakePackageConfigHelpers) + include(GNUInstallDirs) + +-set(concurrencpp_directory "concurrencpp-${PROJECT_VERSION}") +-set(concurrencpp_include_directory "${CMAKE_INSTALL_INCLUDEDIR}/${concurrencpp_directory}") ++set(concurrencpp_directory "concurrencpp") ++set(concurrencpp_include_directory "${CMAKE_INSTALL_INCLUDEDIR}") + + install(TARGETS concurrencpp + EXPORT concurrencppTargets diff --git a/recipes/concurrencpp/all/test_package/CMakeLists.txt b/recipes/concurrencpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8a9efdb5e56ab --- /dev/null +++ b/recipes/concurrencpp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) + +find_package(concurrencpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE concurrencpp::concurrencpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) diff --git a/recipes/concurrencpp/all/test_package/conanfile.py b/recipes/concurrencpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/concurrencpp/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/concurrencpp/all/test_package/test_package.cpp b/recipes/concurrencpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..c34af08342f09 --- /dev/null +++ b/recipes/concurrencpp/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include "concurrencpp/concurrencpp.h" +#include + +int main() { + concurrencpp::runtime runtime; + auto result = runtime.thread_executor()->submit([] { + std::cout << "hello world" << std::endl; + }); + + result.get(); + return 0; +} diff --git a/recipes/concurrencpp/all/test_v1_package/CMakeLists.txt b/recipes/concurrencpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..82e72fcb03579 --- /dev/null +++ b/recipes/concurrencpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(concurrencpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE concurrencpp::concurrencpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) diff --git a/recipes/concurrencpp/all/test_v1_package/conanfile.py b/recipes/concurrencpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/concurrencpp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/concurrencpp/config.yml b/recipes/concurrencpp/config.yml new file mode 100644 index 0000000000000..5fafcacd7c8fb --- /dev/null +++ b/recipes/concurrencpp/config.yml @@ -0,0 +1,5 @@ +versions: + "0.1.5": + folder: all + "0.1.4": + folder: all diff --git a/recipes/concurrentqueue/all/conandata.yml b/recipes/concurrentqueue/all/conandata.yml index 0803ae1cd25f1..4a3b84f1e1032 100644 --- a/recipes/concurrentqueue/all/conandata.yml +++ b/recipes/concurrentqueue/all/conandata.yml @@ -1,7 +1,10 @@ sources: - "1.0.1": - url: https://github.com/cameron314/concurrentqueue/archive/v1.0.1.zip - sha256: b31dca11745ef331756109af838e3689462fbbc2c52dda9f7e1c416778f1f35b + "1.0.3": + url: https://github.com/cameron314/concurrentqueue/archive/v1.0.3.zip + sha256: 5e9e229a1791e8299dcd4bd73ac1be1953424a903818feb7afd929eb16094ef5 "1.0.2": url: https://github.com/cameron314/concurrentqueue/archive/v1.0.2.zip sha256: 6dc85de0e38a014471fe3c653e3e21dc38a5f069cfc031a90fa59f0a45f7584f + "1.0.1": + url: https://github.com/cameron314/concurrentqueue/archive/v1.0.1.zip + sha256: b31dca11745ef331756109af838e3689462fbbc2c52dda9f7e1c416778f1f35b diff --git a/recipes/concurrentqueue/all/conanfile.py b/recipes/concurrentqueue/all/conanfile.py index 259fedade2c4f..866dbaf480b38 100644 --- a/recipes/concurrentqueue/all/conanfile.py +++ b/recipes/concurrentqueue/all/conanfile.py @@ -1,7 +1,11 @@ -from conans import ConanFile, CMake, tools -from fnmatch import fnmatch +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.50.0" + class ConcurrentqueueConan(ConanFile): name = "concurrentqueue" @@ -10,24 +14,38 @@ class ConcurrentqueueConan(ConanFile): description = "A fast multi-producer, multi-consumer lock-free concurrent queue for C++11" topics = ("cpp11", "cpp14", "cpp17", "queue", "lock-free") license = ["BSD-2-Clause", "BSL-1.0"] + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - settings = "os" - _source_subfolder = "concurrentqueue" + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("concurrentqueue-{}".format(self.version), - self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("*.h", - src=os.path.join(self._source_subfolder), - dst=os.path.join("include", "moodycamel")) - self.copy("LICENSE.md", src=self._source_subfolder, dst="licenses") + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + for file in ["blockingconcurrentqueue.h", "concurrentqueue.h", "lightweightsemaphore.h"]: + copy(self, file, src=self.source_folder, dst=os.path.join(self.package_folder, "include", "moodycamel")) def package_info(self): - if self.settings.os == "Linux": + self.cpp_info.set_property("cmake_file_name", "concurrentqueue") + self.cpp_info.set_property("cmake_target_name", "concurrentqueue::concurrentqueue") + self.cpp_info.includedirs.append(os.path.join("include", "moodycamel")) + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["pthread"] diff --git a/recipes/concurrentqueue/all/test_package/CMakeLists.txt b/recipes/concurrentqueue/all/test_package/CMakeLists.txt index 6aab347eddf53..a0355afc44419 100644 --- a/recipes/concurrentqueue/all/test_package/CMakeLists.txt +++ b/recipes/concurrentqueue/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(concurrentqueue REQUIRED CONFIG) -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) -set_property(TARGET example PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE concurrentqueue::concurrentqueue) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/concurrentqueue/all/test_package/conanfile.py b/recipes/concurrentqueue/all/test_package/conanfile.py index 2641cef2da0db..d120a992c06a6 100644 --- a/recipes/concurrentqueue/all/test_package/conanfile.py +++ b/recipes/concurrentqueue/all/test_package/conanfile.py @@ -1,9 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -class ConcurrentqueueTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,5 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "example"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/concurrentqueue/all/test_package/example.cpp b/recipes/concurrentqueue/all/test_package/example.cpp deleted file mode 100644 index a3b882c384897..0000000000000 --- a/recipes/concurrentqueue/all/test_package/example.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include -#include - -int main(int argc, char **argv) { - moodycamel::ConcurrentQueue q; - return 0; -} diff --git a/recipes/concurrentqueue/all/test_package/test_package.cpp b/recipes/concurrentqueue/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..e841e6bc3bd22 --- /dev/null +++ b/recipes/concurrentqueue/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main(int argc, char **argv) { + moodycamel::ConcurrentQueue q; + return 0; +} diff --git a/recipes/concurrentqueue/all/test_v1_package/CMakeLists.txt b/recipes/concurrentqueue/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2f4b988bcfd06 --- /dev/null +++ b/recipes/concurrentqueue/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(concurrentqueue REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE concurrentqueue::concurrentqueue) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/concurrentqueue/all/test_v1_package/conanfile.py b/recipes/concurrentqueue/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/concurrentqueue/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/concurrentqueue/config.yml b/recipes/concurrentqueue/config.yml index 76b559a7fe1c3..df27cd90727cc 100644 --- a/recipes/concurrentqueue/config.yml +++ b/recipes/concurrentqueue/config.yml @@ -1,6 +1,7 @@ ---- versions: - "1.0.1": + "1.0.3": folder: all "1.0.2": folder: all + "1.0.1": + folder: all diff --git a/recipes/confu_json/all/conandata.yml b/recipes/confu_json/all/conandata.yml new file mode 100644 index 0000000000000..a3a9fc5d26fcf --- /dev/null +++ b/recipes/confu_json/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + 0.0.5: + url: https://github.com/werto87/confu_json/archive/refs/tags/v0.0.5.tar.gz + sha256: bc506d4b7836a7689b1c6a2d89bb0c3441f774c8f845fef79d85c71099df5bf9 + 0.0.9: + url: https://github.com/werto87/confu_json/archive/refs/tags/v0.0.9.tar.gz + sha256: 29b2940b939cb04f11fdab4964c86bcb23ac75c588550bf54048e024444d2718 + "0.0.10": + url: "https://github.com/werto87/confu_json/archive/v0.0.10.tar.gz" + sha256: "b31aab1bce952c0dc0bfc1f955a7b88be5103350b5a5eee1a4586ccec0e51fc1" diff --git a/recipes/confu_json/all/conanfile.py b/recipes/confu_json/all/conanfile.py new file mode 100644 index 0000000000000..e2414377fc1df --- /dev/null +++ b/recipes/confu_json/all/conanfile.py @@ -0,0 +1,75 @@ +from conan import ConanFile, tools +from conan.errors import ConanInvalidConfiguration +from conan.tools.scm import Version +from conan.tools.microsoft import is_msvc + +required_conan_version = ">=1.50.0" + +class ConfuJson(ConanFile): + name = "confu_json" + homepage = "https://github.com/werto87/confu_json" + description = "uses boost::fusion to help with serialization; json <-> user defined type" + topics = ("json parse", "serialization", "user defined type") + license = "BSL-1.0" + url = "https://github.com/conan-io/conan-center-index" + settings = "compiler" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _minimum_cpp_standard(self): + return 20 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "17", + "gcc": "10", + "clang": "10", + } + + + + def configure(self): + if is_msvc(self) and Version(self.version) < "0.0.9": + raise ConanInvalidConfiguration( + "Visual Studio is not supported in versions before confu_json/0.0.9") + if self.settings.compiler == "apple-clang": + raise ConanInvalidConfiguration( + "apple-clang is not supported. Pull request welcome") + if self.settings.compiler.get_safe("cppstd"): + tools.build.check_min_cppstd(self, self._minimum_cpp_standard) + + min_version = self._minimum_compilers_version.get( + str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} " + "compiler support.".format( + self.name, self.settings.compiler)) + else: + if Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration( + "{} requires C++{} support. " + "The current compiler {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, + self.settings.compiler, + self.settings.compiler.version)) + + def requirements(self): + self.requires("boost/1.79.0") + self.requires("magic_enum/0.8.0") + + def source(self): + tools.files.get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("*.h*", dst="include/confu_json", + src="source_subfolder/confu_json") + self.copy("*LICENSE.md", dst="licenses", keep_path=False) + + def package_id(self): + self.info.header_only() diff --git a/recipes/confu_json/all/test_package/CMakeLists.txt b/recipes/confu_json/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..1090ad8b4fc01 --- /dev/null +++ b/recipes/confu_json/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.5) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_executable(${PROJECT_NAME} example.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::confu_json) +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) diff --git a/recipes/confu_json/all/test_package/conanfile.py b/recipes/confu_json/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b63178709d69f --- /dev/null +++ b/recipes/confu_json/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/confu_json/all/test_package/example.cpp b/recipes/confu_json/all/test_package/example.cpp new file mode 100644 index 0000000000000..e1edc3931571a --- /dev/null +++ b/recipes/confu_json/all/test_package/example.cpp @@ -0,0 +1,16 @@ +#include "confu_json/confu_json.hxx" +#include // this file should be included only in one translation unit + +BOOST_FUSION_DEFINE_STRUCT((shared_class), Nested, + (long, answer)) // used to define a struct + +int main() { + using namespace confu_json; + auto nested = shared_class::Nested{}; + nested.answer = 42; + std::cout << to_json(nested) + << std::endl; // converts the struct into json and prints it + auto nestedTest = to_object( + to_json(nested)); // converts the struct into json and back into an object + assert(nested.answer == nestedTest.answer); +} diff --git a/recipes/confu_json/config.yml b/recipes/confu_json/config.yml new file mode 100644 index 0000000000000..b07b03aef2ff9 --- /dev/null +++ b/recipes/confu_json/config.yml @@ -0,0 +1,7 @@ +versions: + 0.0.5: + folder: all + 0.0.9: + folder: all + "0.0.10": + folder: all diff --git a/recipes/continuable/all/conandata.yml b/recipes/continuable/all/conandata.yml index 57c40a874d2ed..b1c9fe04e8ebc 100644 --- a/recipes/continuable/all/conandata.yml +++ b/recipes/continuable/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "4.2.0": + url: "https://github.com/Naios/continuable/archive/4.2.0.tar.gz" + sha256: "d85bed930ac19d4b36b23778ad9ae943c2981f7492982bd51dadb89e8908d53f" "4.1.0": sha256: "CBCF50B1B73D8B4EB54734C827D6736CD038960E13F80699958DBB87F1827650" url: "https://github.com/Naios/continuable/archive/4.1.0.tar.gz" diff --git a/recipes/continuable/config.yml b/recipes/continuable/config.yml index 702888c159594..71d2cb6211de6 100644 --- a/recipes/continuable/config.yml +++ b/recipes/continuable/config.yml @@ -1,3 +1,5 @@ versions: + "4.2.0": + folder: all "4.1.0": folder: all diff --git a/recipes/corrade/all/CMakeLists.txt b/recipes/corrade/all/CMakeLists.txt index 0077f8f5ff162..61f3d3b039e2b 100644 --- a/recipes/corrade/all/CMakeLists.txt +++ b/recipes/corrade/all/CMakeLists.txt @@ -1,11 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) -if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") - include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -else() - include("conanbuildinfo.cmake") -endif() -conan_basic_setup() +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) add_subdirectory("source_subfolder") diff --git a/recipes/corrade/all/cmake/conan-corrade-vars.cmake b/recipes/corrade/all/cmake/conan-corrade-vars.cmake new file mode 100644 index 0000000000000..c098a20adb237 --- /dev/null +++ b/recipes/corrade/all/cmake/conan-corrade-vars.cmake @@ -0,0 +1,61 @@ + +# Here we are reproducing the variables and call performed by the FindCorrade.cmake provided by the library + +# Read flags from configuration +file(READ "${CMAKE_CURRENT_LIST_DIR}/../../include/Corrade/configure.h" _corradeConfigure) +string(REGEX REPLACE ";" "\\\\;" _corradeConfigure "${_corradeConfigure}") +string(REGEX REPLACE "\n" ";" _corradeConfigure "${_corradeConfigure}") +set(_corradeFlags + MSVC2015_COMPATIBILITY + MSVC2017_COMPATIBILITY + MSVC2019_COMPATIBILITY + BUILD_DEPRECATED + BUILD_STATIC + BUILD_STATIC_UNIQUE_GLOBALS + BUILD_MULTITHREADED + TARGET_UNIX + TARGET_APPLE + TARGET_IOS + TARGET_IOS_SIMULATOR + TARGET_WINDOWS + TARGET_WINDOWS_RT + TARGET_EMSCRIPTEN + TARGET_ANDROID + # TARGET_X86 etc and TARGET_LIBCXX are not exposed to CMake as the meaning + # is unclear on platforms with multi-arch binaries or when mixing different + # STL implementations. TARGET_GCC etc are figured out via UseCorrade.cmake, + # as the compiler can be different when compiling the lib & when using it. + PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT + TESTSUITE_TARGET_XCTEST + UTILITY_USE_ANSI_COLORS) +foreach(_corradeFlag ${_corradeFlags}) + list(FIND _corradeConfigure "#define CORRADE_${_corradeFlag}" _corrade_${_corradeFlag}) + if(NOT _corrade_${_corradeFlag} EQUAL -1) + set(CORRADE_${_corradeFlag} 1) + endif() +endforeach() + + +# Corrade::rc, a target with just an executable +if(NOT TARGET Corrade::rc) + if(CMAKE_CROSSCOMPILING) + find_program(CORRADE_RC_PROGRAM + NAMES corrade-rc + PATHS ENV + PATH NO_DEFAULT_PATH) + else() + find_program(CORRADE_RC_PROGRAM + NAMES corrade-rc + PATHS "${CMAKE_CURRENT_LIST_DIR}/../../bin/" + NO_DEFAULT_PATH) + endif() + + get_filename_component(CORRADE_RC_PROGRAM "${CORRADE_RC_PROGRAM}" ABSOLUTE) + + add_executable(Corrade::rc IMPORTED) + set_property(TARGET Corrade::rc PROPERTY IMPORTED_LOCATION ${CORRADE_RC_PROGRAM}) +endif() + +# Include and declare other build modules +include("${CMAKE_CURRENT_LIST_DIR}/UseCorrade.cmake") +set(CORRADE_LIB_SUFFIX_MODULE "${CMAKE_CURRENT_LIST_DIR}/CorradeLibSuffix.cmake") diff --git a/recipes/corrade/all/conandata.yml b/recipes/corrade/all/conandata.yml index fd7aa14d18734..4b0cd1b7fd3fb 100644 --- a/recipes/corrade/all/conandata.yml +++ b/recipes/corrade/all/conandata.yml @@ -5,3 +5,10 @@ sources: "2019.10": sha256: 19dbf3c0b28a06a7017d627ee7b84c23b994c469198c1134a8aeba9cfbff7ec3 url: https://github.com/mosra/corrade/archive/v2019.10.tar.gz +patches: + "2020.06": + - base_path: "source_subfolder" + patch_file: "patches/2020.06/0001-emscripten-toolchain.patch" + # patch_type: "portability" + # description: "Remove unnecessary dependency on UseEmscripten" + # source: "https://github.com/mosra/corrade/issues/104" diff --git a/recipes/corrade/all/conanfile.py b/recipes/corrade/all/conanfile.py index 2154bad0b27f9..dcff18b711642 100644 --- a/recipes/corrade/all/conanfile.py +++ b/recipes/corrade/all/conanfile.py @@ -1,19 +1,20 @@ +from conan.tools.microsoft import is_msvc +from conan.tools.microsoft.visual import vs_ide_version from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration +import functools import os +required_conan_version = ">=1.45.0" + class CorradeConan(ConanFile): name = "corrade" description = "Corrade is a multiplatform utility library written in C++11/C++14." - topics = ("conan", "corrade", "magnum", "filesystem", "console", "environment", "os") + topics = ("corrade", "magnum", "filesystem", "console", "environment", "os") url = "https://github.com/conan-io/conan-center-index" homepage = "https://magnum.graphics/corrade" license = "MIT" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" - short_paths = True - _cmake = None settings = "os", "arch", "compiler", "build_type" options = { @@ -37,50 +38,77 @@ class CorradeConan(ConanFile): "with_utility": True, } - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + generators = "cmake" + short_paths = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + self.copy("cmake/*") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < 14: + if self.options.shared: + del self.options.fPIC + + def validate(self): + if is_msvc(self) and tools.Version(vs_ide_version(self)) < 14: raise ConanInvalidConfiguration("Corrade requires Visual Studio version 14 or greater") - if tools.cross_building(self): - self.output.warn("This Corrade recipe could not be prepared for cross building") + + if not self.options.with_utility and (self.options.with_testsuite or self.options.with_interconnect or self.options.with_pluginmanager): + raise ConanInvalidConfiguration("Component 'utility' is required for 'test_suite', 'interconnect' and 'plugin_manager'") + + def build_requirements(self): + if hasattr(self, "settings_build") and tools.cross_building(self, skip_x64_x86=True): + self.build_requires("corrade/{}".format(self.version)) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + @functools.lru_cache(1) def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["BUILD_STATIC"] = not self.options.shared - self._cmake.definitions["BUILD_DEPRECARED"] = self.options["build_deprecated"] - self._cmake.definitions["WITH_INTERCONNECT"] = self.options["with_interconnect"] - self._cmake.definitions["WITH_MAIN"] = self.options["with_main"] - self._cmake.definitions["WITH_PLUGINMANAGER"] = self.options["with_pluginmanager"] - self._cmake.definitions["WITH_TESTSUITE"] = self.options["with_testsuite"] - self._cmake.definitions["WITH_UTILITY"] = self.options["with_utility"] - self._cmake.definitions["WITH_RC"] = "ON" - - # Corrade uses suffix on the resulting "lib"-folder when running cmake.install() - # Set it explicitly to empty, else Corrade might set it implicitly (eg. to "64") - self._cmake.definitions["LIB_SUFFIX"] = "" - - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["CORRADE_MSVC2015_COMPATIBILITY"] = "ON" if self.settings.compiler.version == "14" else "OFF" - self._cmake.definitions["CORRADE_MSVC2017_COMPATIBILITY"] = "ON" if self.settings.compiler.version == "15" else "OFF" - self._cmake.definitions["CORRADE_MSVC2019_COMPATIBILITY"] = "ON" if self.settings.compiler.version == "16" else "OFF" - - self._cmake.configure(build_folder=self._build_subfolder) - - return self._cmake + cmake = CMake(self) + cmake.definitions["BUILD_STATIC"] = not self.options.shared + cmake.definitions["BUILD_STATIC_PIC"] = self.options.get_safe("fPIC", False) + + cmake.definitions["BUILD_DEPRECATED"] = self.options.build_deprecated + cmake.definitions["WITH_INTERCONNECT"] = self.options.with_interconnect + cmake.definitions["WITH_MAIN"] = self.options.with_main + cmake.definitions["WITH_PLUGINMANAGER"] = self.options.with_pluginmanager + cmake.definitions["WITH_TESTSUITE"] = self.options.with_testsuite + cmake.definitions["WITH_UTILITY"] = self.options.with_utility + cmake.definitions["WITH_RC"] = self.options.with_utility + + # Corrade uses suffix on the resulting "lib"-folder when running cmake.install() + # Set it explicitly to empty, else Corrade might set it implicitly (eg. to "64") + cmake.definitions["LIB_SUFFIX"] = "" + + if is_msvc(self): + cmake.definitions["MSVC2015_COMPATIBILITY"] = vs_ide_version(self) == "14" + cmake.definitions["MSVC2017_COMPATIBILITY"] = vs_ide_version(self) == "15" + cmake.definitions["MSVC2019_COMPATIBILITY"] = vs_ide_version(self) == "16" + + cmake.configure(build_folder=self._build_subfolder) + + return cmake def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() cmake.build() @@ -90,54 +118,72 @@ def package(self): cmake.install() share_cmake = os.path.join(self.package_folder, "share", "cmake", "Corrade") - self.copy("UseCorrade.cmake", src=share_cmake, dst=os.path.join(self.package_folder, "lib", "cmake", "Corrade")) - self.copy("CorradeLibSuffix.cmake", src=share_cmake, dst=os.path.join(self.package_folder, "lib", "cmake", "Corrade")) + self.copy("UseCorrade.cmake", src=share_cmake, dst=os.path.join(self.package_folder, "lib", "cmake")) + self.copy("CorradeLibSuffix.cmake", src=share_cmake, dst=os.path.join(self.package_folder, "lib", "cmake")) + self.copy("*.cmake", src=os.path.join(self.source_folder, "cmake"), dst=os.path.join("lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "share")) - def _sort_libs(self, correct_order, libs, lib_suffix="", reverse_result=False): - # Add suffix for correct string matching - correct_order[:] = [s.__add__(lib_suffix) for s in correct_order] - - result = [] - for expectedLib in correct_order: - for lib in libs: - if expectedLib == lib: - result.append(lib) - - if reverse_result: - # Linking happens in reversed order - result.reverse() - return result - def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "Corrade") self.cpp_info.names["cmake_find_package"] = "Corrade" self.cpp_info.names["cmake_find_package_multi"] = "Corrade" - self.cpp_info.builddirs.append(os.path.join("lib", "cmake")) - self.cpp_info.build_modules.append(os.path.join("lib", "cmake", "Corrade", "UseCorrade.cmake")) - self.cpp_info.build_modules.append(os.path.join("lib", "cmake", "Corrade", "CorradeLibSuffix.cmake")) - - # See dependency order here: https://doc.magnum.graphics/magnum/custom-buildsystems.html - allLibs = [ - #1 - "CorradeMain", - "CorradeUtility", - "CorradeContainers", - #2 - "CorradeInterconnect", - "CorradePluginManager", - "CorradeTestSuite", - ] - - # Sort all built libs according to above, and reverse result for correct link order suffix = "-d" if self.settings.build_type == "Debug" else "" - builtLibs = tools.collect_libs(self) - self.cpp_info.libs = self._sort_libs(allLibs, builtLibs, suffix, True) - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["m", "dl"] - - self.cpp_info.builddirs = [os.path.join(self.package_folder, "lib", "cmake", "Corrade")] - bindir = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bindir)) - self.env_info.PATH.append(bindir) + # The FindCorrade.cmake file provided by the library populates some extra stuff + self.cpp_info.set_property("cmake_build_modules", [os.path.join("lib", "cmake", "conan-corrade-vars.cmake")]) + self.cpp_info.components["_corrade"].build_modules.append(os.path.join("lib", "cmake", "conan-corrade-vars.cmake")) + + if self.options.with_main: + self.cpp_info.components["main"].set_property("cmake_target_name", "Corrade::Main") + self.cpp_info.components["main"].names["cmake_find_package"] = "Main" + self.cpp_info.components["main"].names["cmake_find_package_multi"] = "Main" + if self.settings.os == "Windows": + self.cpp_info.components["main"].libs = ["CorradeMain" + suffix] + self.cpp_info.components["main"].requires = ["_corrade"] + + if self.options.with_utility: + self.cpp_info.components["utility"].set_property("cmake_target_name", "Corrade::Utility") + self.cpp_info.components["utility"].names["cmake_find_package"] = "Utility" + self.cpp_info.components["utility"].names["cmake_find_package_multi"] = "Utility" + self.cpp_info.components["utility"].libs = ["CorradeUtility" + suffix] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["utility"].system_libs = ["m", "dl"] + self.cpp_info.components["utility"].requires = ["_corrade"] + + # This one is statically linked into utility + #self.cpp_info.components["containers"].set_property("cmake_target_name", "Corrade::Containers") + #self.cpp_info.components["containers"].names["cmake_find_package"] = "Containers" + #self.cpp_info.components["containers"].names["cmake_find_package_multi"] = "Containers" + #self.cpp_info.components["containers"].libs = ["CorradeContainers" + suffix] + + if self.options.with_interconnect: + self.cpp_info.components["interconnect"].set_property("cmake_target_name", "Corrade::Interconnect") + self.cpp_info.components["interconnect"].names["cmake_find_package"] = "Interconnect" + self.cpp_info.components["interconnect"].names["cmake_find_package_multi"] = "Interconnect" + self.cpp_info.components["interconnect"].libs = ["CorradeInterconnect" + suffix] + self.cpp_info.components["interconnect"].requires = ["utility"] + + if self.options.with_pluginmanager: + self.cpp_info.components["plugin_manager"].set_property("cmake_target_name", "Corrade::PluginManager") + self.cpp_info.components["plugin_manager"].names["cmake_find_package"] = "PluginManager" + self.cpp_info.components["plugin_manager"].names["cmake_find_package_multi"] = "PluginManager" + self.cpp_info.components["plugin_manager"].libs = ["CorradePluginManager" + suffix] + self.cpp_info.components["plugin_manager"].requires = ["utility"] + + if self.options.with_testsuite: + self.cpp_info.components["test_suite"].set_property("cmake_target_name", "Corrade::TestSuite") + self.cpp_info.components["test_suite"].names["cmake_find_package"] = "TestSuite" + self.cpp_info.components["test_suite"].names["cmake_find_package_multi"] = "TestSuite" + self.cpp_info.components["test_suite"].libs = ["CorradeTestSuite" + suffix] + self.cpp_info.components["test_suite"].requires = ["utility"] + + if self.options.with_utility: + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) + + # pkg_config: Add more explicit naming to generated files (avoid filesystem collision). + for key, cmp in self.cpp_info.components.items(): + self.cpp_info.components[key].names["pkg_config"] = "{}_{}".format(self.name, key) diff --git a/recipes/corrade/all/patches/2020.06/0001-emscripten-toolchain.patch b/recipes/corrade/all/patches/2020.06/0001-emscripten-toolchain.patch new file mode 100644 index 0000000000000..0ed74b13960f9 --- /dev/null +++ b/recipes/corrade/all/patches/2020.06/0001-emscripten-toolchain.patch @@ -0,0 +1,49 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e0cc288..81e919e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -223,9 +223,6 @@ if(TESTSUITE_TARGET_XCTEST) + endif() + + include(UseCorrade) +-if(CORRADE_TARGET_EMSCRIPTEN) +- include(UseEmscripten) +-endif() + + # Installation paths + include(CorradeLibSuffix) +diff --git a/modules/UseCorrade.cmake b/modules/UseCorrade.cmake +index 8276c71..d0800a0 100644 +--- a/modules/UseCorrade.cmake ++++ b/modules/UseCorrade.cmake +@@ -319,11 +319,6 @@ if(CORRADE_TESTSUITE_TARGET_XCTEST) + endif() + endif() + +-if(CORRADE_TARGET_EMSCRIPTEN) +- # For bundling files to the tests +- include(UseEmscripten) +-endif() +- + if(CORRADE_TARGET_IOS AND NOT CORRADE_TESTSUITE_TARGET_XCTEST) + set(CORRADE_TESTSUITE_BUNDLE_IDENTIFIER_PREFIX ${PROJECT_NAME} CACHE STRING + "Bundle identifier prefix for tests ran on iOS device") +@@ -434,7 +429,17 @@ function(corrade_add_test test_name) + string(REGEX REPLACE ${_corrade_file_pair_match} "${_corrade_file_pair_replace}" file_pair ${file}) + list(GET file_pair 0 input_filename) + list(GET file_pair 1 output_filename) +- emscripten_embed_file(${test_name} ${input_filename} "/${output_filename}") ++ ++ # This is a verbatim copy of emscripten_embed_file() from ++ # UseEmscripten inside the toolchains submodule. It's not ++ # included in order to avoid a dependency on the toolchains and ++ # thus allow 3rd party toolchains to be used instead. ++ get_filename_component(absolute_file ${input_filename} ABSOLUTE) ++ get_target_property(${test_name}_LINK_FLAGS ${test_name} LINK_FLAGS) ++ if(NOT ${test_name}_LINK_FLAGS) ++ set(${test_name}_LINK_FLAGS ) ++ endif() ++ set_target_properties(${test_name} PROPERTIES LINK_FLAGS "${${test_name}_LINK_FLAGS} --embed-file ${absolute_file}@/${output_filename}") + endforeach() + + # Generate the runner file, first replacing ${test_name} with diff --git a/recipes/corrade/all/test_package/CMakeLists.txt b/recipes/corrade/all/test_package/CMakeLists.txt index e6e36e8f483fb..e4c1f34b721de 100644 --- a/recipes/corrade/all/test_package/CMakeLists.txt +++ b/recipes/corrade/all/test_package/CMakeLists.txt @@ -2,10 +2,19 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(Corrade REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} Corrade::Main) +if(VERSION_2019_10) + target_compile_definitions(${PROJECT_NAME} PRIVATE VERSION_2019_10) +endif() +if(WITH_UTILITY) + target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_UTILITY) + target_link_libraries(${PROJECT_NAME} Corrade::Utility) +endif() set_target_properties(${PROJECT_NAME} PROPERTIES diff --git a/recipes/corrade/all/test_package/conanfile.py b/recipes/corrade/all/test_package/conanfile.py index 6efa898293411..be914f107e121 100644 --- a/recipes/corrade/all/test_package/conanfile.py +++ b/recipes/corrade/all/test_package/conanfile.py @@ -4,18 +4,25 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package" def build(self): cmake = CMake(self) - if self.settings.compiler == "Visual Studio": - cmake.definitions["CORRADE_MSVC2015_COMPATIBILITY"] = "ON" if self.settings.compiler.version == "14" else "OFF" - cmake.definitions["CORRADE_MSVC2017_COMPATIBILITY"] = "ON" if self.settings.compiler.version == "15" else "OFF" - cmake.definitions["CORRADE_MSVC2019_COMPATIBILITY"] = "ON" if self.settings.compiler.version == "16" else "OFF" + cmake.definitions["WITH_UTILITY"] = self.options["corrade"].with_utility + if self.deps_cpp_info["corrade"].version == "2019.10": + cmake.definitions["VERSION_2019_10"] = True cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) + + if self.options["corrade"].with_utility: + # Run corrade-rc + self.run("corrade-rc --help", run_environment=True) + + if self.settings.os == "Emscripten": + bin_path = os.path.join("bin", "test_package.js") + self.run("node {}".format(bin_path), run_environment=True) diff --git a/recipes/corrade/all/test_package/test_package.cpp b/recipes/corrade/all/test_package/test_package.cpp index edcd95df9f563..8f5dc321a44de 100644 --- a/recipes/corrade/all/test_package/test_package.cpp +++ b/recipes/corrade/all/test_package/test_package.cpp @@ -1,5 +1,23 @@ -#include +#include +#include // Here it is 'nothing' + +#ifndef VERSION_2019_10 + #include +#endif + +#ifdef WITH_UTILITY + #include +#endif + int main() { - Corrade::Utility::Debug{} << "Success"; + std::cout << "Test package for Corrade\n"; + + #ifndef VERSION_2019_10 + std::cout << "Corrade " << CORRADE_VERSION_YEAR << "." << CORRADE_VERSION_MONTH << std::endl; + #endif + + #ifdef WITH_UTILITY + Corrade::Utility::Debug{} << "Success"; + #endif } diff --git a/recipes/cotila/all/conandata.yml b/recipes/cotila/all/conandata.yml new file mode 100644 index 0000000000000..d33f2b8f9826d --- /dev/null +++ b/recipes/cotila/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.2.1": + url: "https://github.com/calebzulawski/cotila/archive/refs/tags/1.2.1.tar.gz" + sha256: "898ebfdf562cd1a3622870e17a703b38559cf2c607b2d5f79e6b3a55563af619" diff --git a/recipes/cotila/all/conanfile.py b/recipes/cotila/all/conanfile.py new file mode 100644 index 0000000000000..eb47a8c74e0c9 --- /dev/null +++ b/recipes/cotila/all/conanfile.py @@ -0,0 +1,66 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + + +class CotilaConan(ConanFile): + name = "cotila" + description = "A compile time linear algebra system" + homepage = "https://github.com/calebzulawski/cotila" + topics = ("c++", "math", "linear algebra", "compile-time") + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _min_cppstd(self): + return "17" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "15.7", + "clang": "6.0", + "apple-clang": "10", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "17") + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if not minimum_version: + self.output.warn("{} {} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name, self.version)) + elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration("{} {} requires C++17, which your compiler does not support.".format(self.name, self.version)) + + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, + destination=self._source_subfolder) + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="include/*", src=self._source_subfolder) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "cotila" + self.cpp_info.names["cmake_find_package_multi"] = "cotila" + diff --git a/recipes/cotila/all/test_package/CMakeLists.txt b/recipes/cotila/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fb76dc36e1dc6 --- /dev/null +++ b/recipes/cotila/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(cotila CONFIG REQUIRED) + +add_executable(test_package test_package.cpp) +target_compile_features(test_package PRIVATE cxx_std_17) +target_link_libraries(test_package cotila::cotila) diff --git a/recipes/cotila/all/test_package/conanfile.py b/recipes/cotila/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e1ab7e3d234d6 --- /dev/null +++ b/recipes/cotila/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class CotilaTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cotila/all/test_package/test_package.cpp b/recipes/cotila/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..66e4c15a0d8ca --- /dev/null +++ b/recipes/cotila/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + constexpr cotila::matrix m1 {{{1., 2., 3.}, {4., 5., 6.}}}; // very explicit declaration + constexpr cotila::matrix m2 {{{1., 4.}, {2., 5.}, {3., 6.}}}; // deduces the type, but the extra braces are required + static_assert(m2 == cotila::transpose(m1)); +} diff --git a/recipes/cotila/config.yml b/recipes/cotila/config.yml new file mode 100644 index 0000000000000..cf2793f85804d --- /dev/null +++ b/recipes/cotila/config.yml @@ -0,0 +1,3 @@ +versions: + 1.2.1: + folder: all diff --git a/recipes/asmjit/all/CMakeLists.txt b/recipes/coz/all/CMakeLists.txt similarity index 100% rename from recipes/asmjit/all/CMakeLists.txt rename to recipes/coz/all/CMakeLists.txt diff --git a/recipes/coz/all/conandata.yml b/recipes/coz/all/conandata.yml new file mode 100644 index 0000000000000..9ded250516619 --- /dev/null +++ b/recipes/coz/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20210322": + url: "https://github.com/plasma-umass/coz/archive/6dd3c3f9cdce5094024aab49aeb1b6b44c73b220.zip" + sha256: "f6b8332df45190d300a9d7a9049e9817729080dbd099af3b02ea4ea6977f24dd" diff --git a/recipes/coz/all/conanfile.py b/recipes/coz/all/conanfile.py new file mode 100644 index 0000000000000..525f92fcfbd9c --- /dev/null +++ b/recipes/coz/all/conanfile.py @@ -0,0 +1,62 @@ +import os +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + + +class CozConan(ConanFile): + name = "coz" + description = """Causal profiler, uses performance experiments + to predict the effect of optimizations""" + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://coz-profiler.org" + license = "BSD-2-Clause" + topics = ("conan", "coz", "profiler", "causal") + + settings = "os", "arch", "compiler", "build_type" + + requires = "libelfin/0.3" + exports_sources = "CMakeLists.txt" + generators = "cmake", "cmake_find_package" + + _source_subfolder = "source_subfolder" + + def validate(self): + compiler = self.settings.compiler + compiler_version = tools.Version(self.settings.compiler.version) + if self.settings.os == "Macos" or compiler == "Visual Studio" or ( + compiler == "gcc" and compiler_version < "5.0"): + raise ConanInvalidConfiguration( + "coz doesn't support compiler: {} on OS: {}.".format( + self.settings.compiler, self.settings.os)) + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, "11") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + _cmake = None + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure() + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.filenames["cmake_find_package"] = "coz-profiler" + self.cpp_info.filenames["cmake_find_package_multi"] = "coz-profiler" + self.cpp_info.names["cmake_find_package"] = "coz" + self.cpp_info.names["cmake_find_package_multi"] = "coz" diff --git a/recipes/coz/all/test_package/CMakeLists.txt b/recipes/coz/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b9b613cbb24a --- /dev/null +++ b/recipes/coz/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/coz/all/test_package/conanfile.py b/recipes/coz/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ad479949b486f --- /dev/null +++ b/recipes/coz/all/test_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self, build_type="RelWithDebInfo") # To work properly Coz tool requires debug information https://github.com/plasma-umass/coz + cmake.configure() + cmake.build() + + def test(self): + if tools.cross_building(self.settings): + return + bin_path = os.path.join("bin", "test_package") + self.run("coz run --- " + bin_path, run_environment=True) + print(open("profile.coz").read()) diff --git a/recipes/coz/all/test_package/test_package.c b/recipes/coz/all/test_package/test_package.c new file mode 100644 index 0000000000000..7e5f6d8d14a0e --- /dev/null +++ b/recipes/coz/all/test_package/test_package.c @@ -0,0 +1,11 @@ +#include +#include + +int +main(int argc, char **argv) +{ + COZ_PROGRESS_NAMED("something"); + printf("Hello, Coz!\n"); + + return 0; +} diff --git a/recipes/coz/config.yml b/recipes/coz/config.yml new file mode 100644 index 0000000000000..b90744deceea1 --- /dev/null +++ b/recipes/coz/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210322": + folder: "all" diff --git a/recipes/cpp-httplib/all/conandata.yml b/recipes/cpp-httplib/all/conandata.yml index 2b0581f53e299..dbdbe18e1b5ac 100644 --- a/recipes/cpp-httplib/all/conandata.yml +++ b/recipes/cpp-httplib/all/conandata.yml @@ -1,61 +1,49 @@ sources: - "0.8.8": - url: "https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.8.8.tar.gz" - sha256: "4b3d2e8d1a441bd986a0916085043ab9851437e52df9358e409a888fcc00c63e" - "0.8.6": - url: "https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.8.6.tar.gz" - sha256: "0222aa4b3b72ee5c38d6eabe0ba6e6fa4984406573980d028409ce8c04288773" - "0.8.5": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.8.5.tar.gz" - sha256: "b353f3e7c124a08940d9425aeb7206183fa29857a8f720c162f8fd820cc18f0e" - "0.8.4": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.8.4.tar.gz" - sha256: "6716c83d50b7df15129fc4df98cfcb1e16ad5d6855c0ee058bc76687e880bfb7" - "0.8.0": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.8.0.tar.gz" - sha256: "c553ad74043ad2fb47bf329edd9aa451bd0a74b69f4e7a165042a67a9daaf469" + "0.11.3": + url: "https://github.com/yhirose/cpp-httplib/archive/v0.11.3.tar.gz" + sha256: "799b2daa0441d207f6cd1179ae3a34869722084a434da6614978be1682c1e12d" + "0.11.2": + url: "https://github.com/yhirose/cpp-httplib/archive/v0.11.2.tar.gz" + sha256: "e620d030215733c4831fdc7813d5eb37a6fd599f8192a730662662e1748a741b" + "0.11.1": + url: "https://github.com/yhirose/cpp-httplib/archive/v0.11.1.tar.gz" + sha256: "1ce2f0393ba779ec34885c5cd937141b4b5b730e2bc2efc34eb8554289c24d61" + "0.11.0": + url: "https://github.com/yhirose/cpp-httplib/archive/v0.11.0.tar.gz" + sha256: "9f533b0aa67066bd8f049e080eef75ad710a2f3ba3d80edbb13957389a5eeca7" + "0.10.9": + url: "https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.10.9.tar.gz" + sha256: "95ac0740ef760829a079c01a44164fd74af3fdc0748a40fc6beefd0276fd2345" + "0.10.8": + url: "https://github.com/yhirose/cpp-httplib/archive/v0.10.8.tar.gz" + sha256: "2959ae3669e34ca8934dfe066cd72fc2bfff44ba53bfc26f3b2cb81ed664ca0d" + "0.10.7": + url: "https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.10.7.tar.gz" + sha256: "f89e2e74f64821f3cd925750dcee5dde7160600b1122e692253a4ebed8e1b1b1" + "0.10.6": + url: "https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.10.6.tar.gz" + sha256: "c9024e1f41881f28ca276f0f35c1916eb34dab8c52b6aa32a3c360d4e40eb440" + "0.10.4": + url: "https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.10.4.tar.gz" + sha256: "7719ff9f309c807dd8a574048764836b6a12bcb7d6ae9e129e7e4289cfdb4bd4" + "0.10.3": + url: "https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.10.3.tar.gz" + sha256: "2c02fe6bca8407fb260944ecca68de367475e7221912b104f882c278b46d4776" + "0.10.1": + url: "https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.10.1.tar.gz" + sha256: "c3fb2019ed77482681b80b9a5d74ddf49df61a024703be1a5379b28fa13dfa2f" + "0.9.10": + url: "https://github.com/yhirose/cpp-httplib/archive/v0.9.10.tar.gz" + sha256: "49dfa101ced75f8536ec7c865f872ab8fca157c8b49e29be5ef2d2aa11f716e8" + "0.8.9": + url: "https://github.com/yhirose/cpp-httplib/archive/v0.8.9.tar.gz" + sha256: "3c5e0d6784d04b0b3d10f60fa2a26ef2a968fb80f434c4d117c2811f9e3a5ed7" "0.7.18": url: "https://github.com/yhirose/cpp-httplib/archive/v0.7.18.tar.gz" sha256: "ed90e670a39fcacfb670f51b619e670dafe419bca74f8a50fb3c31bb46be8b23" - "0.7.15": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.7.15.tar.gz" - sha256: "0e424f92b607fc9245c144dada85c2e97bc6cc5938c0c69a598a5b2a5c1ab98a" - "0.7.12": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.7.12.tar.gz" - sha256: "110a10d47882c20e292d1c2f79663ac355aaa10fe122d1d385cc07c0de4cf94a" - "0.7.10": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.7.10.tar.gz" - sha256: "4371938551db14bce7fd3dfc665b362608dd5c953d7ff3ace871306a8495699d" - "0.7.9": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.7.9.tar.gz" - sha256: "9c8ec09215e8583694f2469246d139fa0b8f33a144f1097e53739c6d6ec2f6eb" - "0.7.8": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.7.8.tar.gz" - sha256: "31461e082282846d1f8b2de9856e720a9730dcfacf9056d1ab584ad07f59107d" - "0.7.7": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.7.7.tar.gz" - sha256: "270ca46419d49c98e848363b5d5d7ddf84317157076a5e9f1ffdc4932a98737b" - "0.7.6": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.7.6.tar.gz" - sha256: "307810678ad6e9dd34868e34939ecf95222b7ef549e3083eb06782e42e917946" - "0.7.5": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.7.5.tar.gz" - sha256: "9740a9b043852330fa00d86e15796c1dfdc9c113ef5e78dee100a6bcc6b28224" - "0.7.0": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.7.0.tar.gz" - sha256: "f7ba53c50d7faa23c31f099423b92a95b511a13a752bfe1e8cad46ca79de5e1b" "0.6.6": url: "https://github.com/yhirose/cpp-httplib/archive/v0.6.6.tar.gz" sha256: "35bcc6a3f9612feb92b2153c5e56389ccc1ab46c7ba8781b873a5c2e249eb610" "0.5.13": url: "https://github.com/yhirose/cpp-httplib/archive/v0.5.13.tar.gz" sha256: "a19af3488089a6ed9f5bf4868893d2e2262f5ebab831dd5f8cf2843e8b48b231" - "0.5.8": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.5.8.tar.gz" - sha256: "184d4fe79fc836ee26aa8635b3240879af4c6f17257fc7063d0b77a0cf856dfc" - "0.5.7": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.5.7.tar.gz" - sha256: "27b7f6346bdeb1ead9d17bd7cea89d9ad491f50f0479081053cc6e5742a89e64" - "0.5.4": - url: "https://github.com/yhirose/cpp-httplib/archive/v0.5.4.tar.gz" - sha256: "40dcce66ec002e2631ef918e1b3bfc9ec1662d02007291ea4743e17ac9c7d43f" diff --git a/recipes/cpp-httplib/all/conanfile.py b/recipes/cpp-httplib/all/conanfile.py index e5a2b77521790..7129662e2807e 100644 --- a/recipes/cpp-httplib/all/conanfile.py +++ b/recipes/cpp-httplib/all/conanfile.py @@ -1,71 +1,87 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" class CpphttplibConan(ConanFile): name = "cpp-httplib" description = "A C++11 single-file header-only cross platform HTTP/HTTPS library." license = "MIT" - topics = ("conan", "cpp-httplib", "http", "https", "header-only") + topics = ("cpp-httplib", "http", "https", "header-only") homepage = "https://github.com/yhirose/cpp-httplib" url = "https://github.com/conan-io/conan-center-index" - no_copy_source = True - settings = "os", "compiler" + + settings = "os", "arch", "compiler", "build_type" options = { "with_openssl": [True, False], "with_zlib": [True, False], - "with_brotli": [True, False] + "with_brotli": [True, False], } default_options = { "with_openssl": False, "with_zlib": False, - "with_brotli": False + "with_brotli": False, } - @property - def _source_subfolder(self): - return "source_subfolder" + no_copy_source = True def config_options(self): - if tools.Version(self.version) < "0.7.2": + if Version(self.version) < "0.7.2": del self.options.with_brotli - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) - def requirements(self): if self.options.with_openssl: - self.requires("openssl/1.1.1k") + self.requires("openssl/1.1.1s") if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.get_safe("with_brotli"): self.requires("brotli/1.0.9") def package_id(self): - self.info.header_only() + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("httplib.h", dst=os.path.join("include", "httplib"), src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "httplib.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include", "httplib")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "httplib" - self.cpp_info.names["cmake_find_package_multi"] = "httplib" + self.cpp_info.set_property("cmake_file_name", "httplib") + self.cpp_info.set_property("cmake_target_name", "httplib::httplib") + self.cpp_info.includedirs.append(os.path.join("include", "httplib")) + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] if self.options.with_openssl: self.cpp_info.defines.append("CPPHTTPLIB_OPENSSL_SUPPORT") if self.options.with_zlib: self.cpp_info.defines.append("CPPHTTPLIB_ZLIB_SUPPORT") if self.options.get_safe("with_brotli"): self.cpp_info.defines.append("CPPHTTPLIB_BROTLI_SUPPORT") - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["pthread"] elif self.settings.os == "Windows": self.cpp_info.system_libs = ["crypt32", "cryptui", "ws2_32"] - self.cpp_info.includedirs = ["include", os.path.join("include", "httplib")] + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.names["cmake_find_package"] = "httplib" + self.cpp_info.names["cmake_find_package_multi"] = "httplib" diff --git a/recipes/cpp-httplib/all/test_package/CMakeLists.txt b/recipes/cpp-httplib/all/test_package/CMakeLists.txt index 2656e5577e693..71e165a411166 100644 --- a/recipes/cpp-httplib/all/test_package/CMakeLists.txt +++ b/recipes/cpp-httplib/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(httplib REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} httplib::httplib) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE httplib::httplib) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cpp-httplib/all/test_package/conanfile.py b/recipes/cpp-httplib/all/test_package/conanfile.py index 84ee68733e516..d120a992c06a6 100644 --- a/recipes/cpp-httplib/all/test_package/conanfile.py +++ b/recipes/cpp-httplib/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cpp-httplib/all/test_v1_package/CMakeLists.txt b/recipes/cpp-httplib/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..72809bb080c2c --- /dev/null +++ b/recipes/cpp-httplib/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(httplib REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE httplib::httplib) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cpp-httplib/all/test_v1_package/conanfile.py b/recipes/cpp-httplib/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cpp-httplib/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpp-httplib/config.yml b/recipes/cpp-httplib/config.yml index a0d8ca5ceea01..7b7f02579048e 100644 --- a/recipes/cpp-httplib/config.yml +++ b/recipes/cpp-httplib/config.yml @@ -1,41 +1,33 @@ versions: - "0.8.8": + "0.11.3": folder: all - "0.8.6": + "0.11.2": folder: all - "0.8.5": + "0.11.1": folder: all - "0.8.4": + "0.11.0": folder: all - "0.8.0": + "0.10.9": folder: all - "0.7.18": - folder: all - "0.7.15": + "0.10.8": folder: all - "0.7.12": + "0.10.7": folder: all - "0.7.10": + "0.10.6": folder: all - "0.7.9": + "0.10.4": folder: all - "0.7.8": + "0.10.3": folder: all - "0.7.7": + "0.10.1": folder: all - "0.7.6": + "0.9.10": folder: all - "0.7.5": + "0.8.9": folder: all - "0.7.0": + "0.7.18": folder: all "0.6.6": folder: all "0.5.13": folder: all - "0.5.8": - folder: all - "0.5.7": - folder: all - "0.5.4": - folder: all diff --git a/recipes/cpp-ipc/all/CMakeLists.txt b/recipes/cpp-ipc/all/CMakeLists.txt new file mode 100644 index 0000000000000..e17d82eddcc5d --- /dev/null +++ b/recipes/cpp-ipc/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) +project(cmake_wrapper LANGUAGES CXX) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/cpp-ipc/all/conandata.yml b/recipes/cpp-ipc/all/conandata.yml new file mode 100644 index 0000000000000..c463e509b6004 --- /dev/null +++ b/recipes/cpp-ipc/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.2.0": + url: "https://github.com/mutouyun/cpp-ipc/archive/refs/tags/v1.2.0.tar.gz" + sha256: "c8df492e08b55e0722eb3e5684163709c1758f3282f05358ff78c694eadb6e60" + "1.1.1": + url: "https://github.com/mutouyun/cpp-ipc/archive/refs/tags/v1.1.1.tar.gz" + sha256: "5c7539de763e5cf3bb3469df17837793cebe2cd9fe44ab2f6ef1ba45f06206a5" diff --git a/recipes/cpp-ipc/all/conanfile.py b/recipes/cpp-ipc/all/conanfile.py new file mode 100644 index 0000000000000..b11041af3f594 --- /dev/null +++ b/recipes/cpp-ipc/all/conanfile.py @@ -0,0 +1,87 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + +class CppIPCConan(ConanFile): + name = "cpp-ipc" + description = "C++ IPC Library: A high-performance inter-process communication using shared memory on Linux/Windows." + topics = ("ipc", "shared memory", ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/mutouyun/cpp-ipc" + license = "MIT", + settings = "os", "arch", "compiler", "build_type" + exports_sources = ["CMakeLists.txt"] + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "cmake" + + _compiler_required_cpp17 = { + "Visual Studio": "17", + "gcc": "8", + "clang": "4", + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if tools.is_apple_os(self.settings.os): + raise ConanInvalidConfiguration("{} does not support Apple platform".format(self.name)) + + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 17) + + minimum_version = self._compiler_required_cpp17.get(str(self.settings.compiler), False) + if minimum_version: + if tools.Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration("{} requires C++17, which your compiler does not support.".format(self.name)) + else: + self.output.warn("{0} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name)) + + if self.settings.compiler == "clang" and self.settings.compiler.get_safe("libcxx") == "libc++": + raise ConanInvalidConfiguration("{} doesn't support clang with libc++".format(self.name)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["LIBIPC_BUILD_SHARED_LIBS"] = self.options.shared + self._cmake.configure() + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["ipc"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["rt", "pthread"] diff --git a/recipes/cpp-ipc/all/test_package/CMakeLists.txt b/recipes/cpp-ipc/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c258338b9324e --- /dev/null +++ b/recipes/cpp-ipc/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cpp-ipc REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} cpp-ipc::cpp-ipc) +set(CMAKE_CXX_STANDARD 17) diff --git a/recipes/cpp-ipc/all/test_package/conanfile.py b/recipes/cpp-ipc/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/cpp-ipc/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpp-ipc/all/test_package/test_package.cpp b/recipes/cpp-ipc/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2b7e80a88c400 --- /dev/null +++ b/recipes/cpp-ipc/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include "libipc/ipc.h" + +int main() { + ipc::channel cc { "my-ipc-channel", ipc::sender | ipc::receiver }; + + return EXIT_SUCCESS; +} diff --git a/recipes/cpp-ipc/config.yml b/recipes/cpp-ipc/config.yml new file mode 100644 index 0000000000000..797b8dd014054 --- /dev/null +++ b/recipes/cpp-ipc/config.yml @@ -0,0 +1,5 @@ +versions: + "1.2.0": + folder: all + "1.1.1": + folder: all diff --git a/recipes/cpp-jwt/all/conandata.yml b/recipes/cpp-jwt/all/conandata.yml index 5109949ff5bdb..e953202e01124 100644 --- a/recipes/cpp-jwt/all/conandata.yml +++ b/recipes/cpp-jwt/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.4": + url: "https://github.com/arun11299/cpp-jwt/archive/v1.4.tar.gz" + sha256: "1cb8039ee15bf9bf735c26082d7ff50c23d2886d65015dd6b0668c65e17dd20f" "1.3": url: "https://github.com/arun11299/cpp-jwt/archive/v1.3.tar.gz" sha256: "792889f08dd1acbc14129d11e013f9ef46e663c545ea366dd922402d8becbe05" @@ -6,6 +9,9 @@ sources: sha256: 5d0102d182c48ef520f3fb15412fbaa67e002e1bf90b3ba45d5a2c7f850371f7 url: https://github.com/arun11299/cpp-jwt/archive/v1.2.tar.gz patches: + "1.4": + patch_file: "patches/001-fix-msvc-14-compilation.patch" + base_path: "source_subfolder" "1.3": patch_file: "patches/001-fix-msvc-14-compilation.patch" base_path: "source_subfolder" diff --git a/recipes/cpp-jwt/config.yml b/recipes/cpp-jwt/config.yml index 81d0457bb64a7..f55a2df2807c5 100644 --- a/recipes/cpp-jwt/config.yml +++ b/recipes/cpp-jwt/config.yml @@ -1,4 +1,6 @@ versions: + "1.4": + folder: all "1.3": folder: all "1.2": diff --git a/recipes/cpp-lazy/all/conandata.yml b/recipes/cpp-lazy/all/conandata.yml new file mode 100644 index 0000000000000..0292874c3773e --- /dev/null +++ b/recipes/cpp-lazy/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "6.0.0": + url: "https://github.com/MarcDirven/cpp-lazy/releases/download/v6.0.0/cpp-lazy-src.zip" + sha256: "424973eabaab8c756dae5e1795febeface65bb1dc42f474e5e2e1e4ab3effc5e" +patches: + "6.0.0": + - patch_file: "patches/0001-support-gcc5.patch" + patch_description: "fix compilation errors on gcc5" + patch_type: "portability" + patch_source: "https://github.com/MarcDirven/cpp-lazy/issues/133" diff --git a/recipes/cpp-lazy/all/conanfile.py b/recipes/cpp-lazy/all/conanfile.py new file mode 100644 index 0000000000000..e137cb684e6b8 --- /dev/null +++ b/recipes/cpp-lazy/all/conanfile.py @@ -0,0 +1,59 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy +from conan.tools.layout import basic_layout +from conan.tools.scm import Version + +import os + +required_conan_version = ">=1.52.0" + +class CpplazyConan(ConanFile): + name = "cpp-lazy" + description = "C++11/14/17/20 library for lazy evaluation " + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/MarcDirven/cpp-lazy" + topics = ("lazy evaluation", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _min_cppstd(self): + return 11 + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + if self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) < "14.0": + raise ConanInvalidConfiguration(f"{self.ref} doesn't support apple-clang < 14.0.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder) + + def build(self): + apply_conandata_patches(self) + + def package(self): + copy(self, pattern="LICENSE.md", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy( + self, + pattern="*.hpp", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include"), + ) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/cpp-lazy/all/patches/0001-support-gcc5.patch b/recipes/cpp-lazy/all/patches/0001-support-gcc5.patch new file mode 100644 index 0000000000000..578428158ca2b --- /dev/null +++ b/recipes/cpp-lazy/all/patches/0001-support-gcc5.patch @@ -0,0 +1,297 @@ +diff --git a/include/Lz/FunctionTools.hpp b/include/Lz/FunctionTools.hpp +index 5beebed..9b1e3c7 100644 +--- a/include/Lz/FunctionTools.hpp ++++ b/include/Lz/FunctionTools.hpp +@@ -91,7 +91,7 @@ LZ_NODISCARD StringSplitter lines(const String& string) + * @return The result of the sum from [from, upToAndIncluding] + */ + template +-LZ_NODISCARD constexpr T sumTo(const T from, const T upToAndIncluding) { ++LZ_NODISCARD LZ_CONSTEXPR_CXX_14 T sumTo(const T from, const T upToAndIncluding) { + static_assert(std::is_integral::value, "T must be integral type"); + const T fromAbs = from < 0 ? -from : from; + const T toAbs = upToAndIncluding < 0 ? -upToAndIncluding : upToAndIncluding; +@@ -114,7 +114,7 @@ LZ_NODISCARD constexpr T sumTo(const T from, const T upToAndIncluding) { + * @return The result of the sum from [0, upToAndIncluding] + */ + template +-LZ_NODISCARD constexpr T sumTo(const T upToAndIncluding) { ++LZ_NODISCARD LZ_CONSTEXPR_CXX_14 T sumTo(const T upToAndIncluding) { + return lz::sumTo(0, upToAndIncluding); + } + +@@ -1241,7 +1241,7 @@ bool startsWith(IteratorA beginA, IteratorA endA, IteratorB beginB, IteratorB en + return std::search(std::move(beginA), std::move(endA), std::move(beginB), std::move(endB), std::move(compare)) != endA; + } + +-template)> ++template)> + bool startsWith(const IterableA& a, const IterableB& b, BinaryPredicate compare = {}) { + return lz::startsWith(std::begin(a), std::end(a), std::begin(b), std::end(b), std::move(compare)); + } +@@ -1255,7 +1255,7 @@ bool endsWith(IteratorA beginA, IteratorA endA, IteratorB beginB, IteratorB endB + return lz::startsWith(std::move(revBegA), std::move(revEndA), std::move(revBegB), std::move(revEndB), std::move(compare)); + } + +-template)> ++template)> + bool endsWith(const IterableA& a, const IterableB& b, BinaryPredicate compare = {}) { + return lz::endsWith(std::begin(a), std::end(a), std::begin(b), std::end(b), std::move(compare)); + } +diff --git a/include/Lz/Zip.hpp b/include/Lz/Zip.hpp +index a3e1560..95c6cf5 100644 +--- a/include/Lz/Zip.hpp ++++ b/include/Lz/Zip.hpp +@@ -15,7 +15,7 @@ Tuple createFakeEnd(const Tuple& begin, Tuple end, IndexSequence) { + // If we use begin + smallestLength, we get compile errors for non random access iterators. However, we know that we are + // dealing with a random access iterator, so std::next does a + internally. It is implemented this way to prevent more + // enable_if's from appearing +- return { std::next(std::get(begin), smallestLength)... }; ++ return Tuple{ std::next(std::get(begin), smallestLength)... }; + } + } // namespace internal + +diff --git a/include/Lz/detail/BasicIteratorView.hpp b/include/Lz/detail/BasicIteratorView.hpp +index 176f878..b5cbff1 100644 +--- a/include/Lz/detail/BasicIteratorView.hpp ++++ b/include/Lz/detail/BasicIteratorView.hpp +@@ -641,7 +641,7 @@ view(Iterable&& iterable) { + template)> + bool equal(const IterableA& a, const IterableB& b, BinaryPredicate predicate = {}) { +- return std::equal(std::begin(a), std::end(a), std::begin(b), std::end(b), std::move(predicate)); ++ return std::equal(std::begin(a), std::end(a), std::begin(b), std::move(predicate)); + } + # else // ^^^ !LZ_HAS_EXECUTION vvv LZ_HAS_EXECUTION + /** +diff --git a/include/Lz/detail/CartesianProductIterator.hpp b/include/Lz/detail/CartesianProductIterator.hpp +index 554e75c..3c63d90 100644 +--- a/include/Lz/detail/CartesianProductIterator.hpp ++++ b/include/Lz/detail/CartesianProductIterator.hpp +@@ -209,7 +209,7 @@ private: + + template + LZ_CONSTEXPR_CXX_20 reference dereference(IndexSequence) const { +- return { *std::get(_iterator)... }; ++ return reference{ *std::get(_iterator)... }; + } + + template +diff --git a/include/Lz/detail/FunctionContainer.hpp b/include/Lz/detail/FunctionContainer.hpp +index c08d9ff..7b721a2 100644 +--- a/include/Lz/detail/FunctionContainer.hpp ++++ b/include/Lz/detail/FunctionContainer.hpp +@@ -28,7 +28,7 @@ class FunctionContainer { + _isConstructed = true; + } + +- constexpr void reset() noexcept { ++ LZ_CONSTEXPR_CXX_14 void reset() noexcept { + if (_isConstructed) { + _func.~Func(); + _isConstructed = false; +diff --git a/include/Lz/detail/LzTools.hpp b/include/Lz/detail/LzTools.hpp +index 919688a..8f57dce 100644 +--- a/include/Lz/detail/LzTools.hpp ++++ b/include/Lz/detail/LzTools.hpp +@@ -223,6 +223,8 @@ using Decay = typename std::decay::type; + + template + using TupleElement = typename std::tuple_element::type; ++ ++# define MAKE_BIN_OP(OP, VALUE_TYPE) OP + # else // ^^^ has cxx 11 vvv cxx > 11 + template + using IndexSequence = std::index_sequence; +@@ -364,7 +366,7 @@ template + struct IsRandomAccess : IsRandomAccessTag> {}; + + template +-inline constexpr bool isEven(const Arithmetic value) noexcept { ++LZ_CONSTEXPR_CXX_14 bool isEven(const Arithmetic value) noexcept { + return (value % 2) == 0; + } + +@@ -373,7 +375,7 @@ inline constexpr void decompose(const Ts&...) noexcept { + } + + template +-inline constexpr Arithmetic roundEven(const Arithmetic a, const Arithmetic b) noexcept { ++LZ_CONSTEXPR_CXX_14 Arithmetic roundEven(const Arithmetic a, const Arithmetic b) noexcept { + LZ_ASSERT(a != 0 && b != 0, "division by zero error"); + if (b == 1) { + return a; +diff --git a/include/Lz/detail/Optional.hpp b/include/Lz/detail/Optional.hpp +index 12bbf3f..885a50a 100644 +--- a/include/Lz/detail/Optional.hpp ++++ b/include/Lz/detail/Optional.hpp +@@ -39,7 +39,7 @@ public: + constexpr Optional(U&& value) : _value(std::forward(value)), _hasValue(true) { + } + +- constexpr Optional(Optional&& right) noexcept(noexcept(construct(std::move(right.value())))) { ++ LZ_CONSTEXPR_CXX_14 Optional(Optional&& right) noexcept { + if (right) { + construct(std::move(right.value())); + } +@@ -55,7 +55,7 @@ public: + } + + template +- constexpr Optional& ++ LZ_CONSTEXPR_CXX_14 Optional& + operator=(U&& value) noexcept { + if (_hasValue) { + _value = std::forward(value); +@@ -70,35 +70,35 @@ public: + return _hasValue; + } + +- constexpr const T& value() const { ++ LZ_CONSTEXPR_CXX_14 const T& value() const { + if (_hasValue) { + return _value; + } + throw std::runtime_error("Cannot get uninitialized optional"); + } + +- constexpr T& value() { ++ LZ_CONSTEXPR_CXX_14 T& value() { + if (_hasValue) { + return _value; + } + throw std::runtime_error("Cannot get uninitialized optional"); + } + +- constexpr T& operator*() noexcept { ++ LZ_CONSTEXPR_CXX_14 T& operator*() noexcept { + return _value; + } + +- constexpr const T& operator*() const noexcept { ++ LZ_CONSTEXPR_CXX_14 const T& operator*() const noexcept { + return _value; + } + + template +- constexpr T value_or(U&& v) const& { ++ LZ_CONSTEXPR_CXX_14 T value_or(U&& v) const& { + return bool(*this) ? this->value() : static_cast(std::forward(v)); + } + + template +- constexpr T value_or(U&& v) && { ++ LZ_CONSTEXPR_CXX_14 T value_or(U&& v) && { + return bool(*this) ? std::move(this->value()) : static_cast(std::forward(v)); + } + }; +diff --git a/include/Lz/detail/RangeIterator.hpp b/include/Lz/detail/RangeIterator.hpp +index 34ca280..7be29b2 100644 +--- a/include/Lz/detail/RangeIterator.hpp ++++ b/include/Lz/detail/RangeIterator.hpp +@@ -25,7 +25,7 @@ EnableIf::value, std::ptrdiff_t> plusImpl(cons + } + + template +-constexpr EnableIf::value, std::ptrdiff_t> ++LZ_CONSTEXPR_CXX_14 EnableIf::value, std::ptrdiff_t> + plusImpl(const ValueType difference, const ValueType step) noexcept { + return static_cast(roundEven(difference, step)); + } +@@ -95,23 +95,23 @@ public: + return *(*this + offset); + } + +- constexpr RangeIterator& operator+=(const difference_type value) noexcept { ++ LZ_CONSTEXPR_CXX_14 RangeIterator& operator+=(const difference_type value) noexcept { + _iterator += static_cast(value) * _step; + return *this; + } + +- LZ_NODISCARD constexpr RangeIterator operator+(const difference_type value) const noexcept { ++ LZ_NODISCARD LZ_CONSTEXPR_CXX_14 RangeIterator operator+(const difference_type value) const noexcept { + RangeIterator tmp(*this); + tmp += value; + return tmp; + } + +- constexpr RangeIterator operator-=(const difference_type value) noexcept { ++ LZ_CONSTEXPR_CXX_14 RangeIterator operator-=(const difference_type value) noexcept { + _iterator -= static_cast(value) * _step; + return *this; + } + +- LZ_NODISCARD constexpr RangeIterator operator-(const difference_type value) const noexcept { ++ LZ_NODISCARD LZ_CONSTEXPR_CXX_14 RangeIterator operator-(const difference_type value) const noexcept { + RangeIterator tmp(*this); + tmp -= value; + return tmp; +diff --git a/include/Lz/detail/SplitIterator.hpp b/include/Lz/detail/SplitIterator.hpp +index e4e58a3..564632e 100644 +--- a/include/Lz/detail/SplitIterator.hpp ++++ b/include/Lz/detail/SplitIterator.hpp +@@ -26,12 +26,12 @@ class SplitIterator { + } + # else + template +- EnableIf::value, std::size_t> getDelimiterLength() const { ++ constexpr EnableIf::value, std::size_t> getDelimiterLength() const { + return 1; + } + + template +- EnableIf::value, std::size_t> getDelimiterLength() const { ++ LZ_CONSTEXPR_CXX_20 EnableIf::value, std::size_t> getDelimiterLength() const { + return _delimiter.length(); + } + # endif +@@ -70,12 +70,12 @@ public: + return FakePointerProxy(**this); + } + +- constexpr friend bool operator!=(const SplitIterator& a, const SplitIterator& b) noexcept { ++ LZ_CONSTEXPR_CXX_14 friend bool operator!=(const SplitIterator& a, const SplitIterator& b) noexcept { + LZ_ASSERT(a._delimiter == b._delimiter, "incompatible iterator types, found different delimiters"); + return a._currentPos != b._currentPos; + } + +- constexpr friend bool operator==(const SplitIterator& a, const SplitIterator& b) noexcept { ++ LZ_CONSTEXPR_CXX_14 friend bool operator==(const SplitIterator& a, const SplitIterator& b) noexcept { + return !(a != b); // NOLINT + } + +diff --git a/include/Lz/detail/ZipIterator.hpp b/include/Lz/detail/ZipIterator.hpp +index 085c816..50e1668 100644 +--- a/include/Lz/detail/ZipIterator.hpp ++++ b/include/Lz/detail/ZipIterator.hpp +@@ -26,7 +26,7 @@ private: + + template + LZ_CONSTEXPR_CXX_20 reference dereference(IndexSequence) const { +- return { *std::get(_iterators)... }; ++ return reference{ *std::get(_iterators)... }; + } + + template +diff --git a/include/Lz/detail/ZipLongestIterator.hpp b/include/Lz/detail/ZipLongestIterator.hpp +index 2263cd9..4959996 100644 +--- a/include/Lz/detail/ZipLongestIterator.hpp ++++ b/include/Lz/detail/ZipLongestIterator.hpp +@@ -48,7 +48,7 @@ private: + + template + LZ_CONSTEXPR_CXX_20 value_type dereference(IndexSequence) const { +- return { dereferenceOne(std::get(_iterators), std::get(_end))... }; ++ return value_type{ dereferenceOne(std::get(_iterators), std::get(_end))... }; + } + + template +@@ -137,7 +137,7 @@ private: + + template + LZ_CONSTEXPR_CXX_20 value_type dereference(IndexSequence) const { +- return { dereferenceOne(std::get(_iterators), std::get(_end))... }; ++ return value_type{ dereferenceOne(std::get(_iterators), std::get(_end))... }; + } + + template diff --git a/recipes/cpp-lazy/all/test_package/CMakeLists.txt b/recipes/cpp-lazy/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..77fddb4fc3c4b --- /dev/null +++ b/recipes/cpp-lazy/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(cpp-lazy REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cpp-lazy::cpp-lazy) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cpp-lazy/all/test_package/conanfile.py b/recipes/cpp-lazy/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e845ae751a301 --- /dev/null +++ b/recipes/cpp-lazy/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cpp-lazy/all/test_package/test_package.cpp b/recipes/cpp-lazy/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2fb082350a8e9 --- /dev/null +++ b/recipes/cpp-lazy/all/test_package/test_package.cpp @@ -0,0 +1,13 @@ +#include + +#define LZ_STANDALONE +#include + +int main() { + std::array arr = {1, 2, 3, 4}; + std::string result = lz::map(arr, [](int i) { return i + 1; }).toString(" "); // == "2 3 4 5" + + std::cout << result << "\n"; + + return 0; +} diff --git a/recipes/cpp-lazy/all/test_v1_package/CMakeLists.txt b/recipes/cpp-lazy/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..be00a8c7f57c7 --- /dev/null +++ b/recipes/cpp-lazy/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cpp-lazy/all/test_v1_package/conanfile.py b/recipes/cpp-lazy/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/cpp-lazy/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpp-lazy/config.yml b/recipes/cpp-lazy/config.yml new file mode 100644 index 0000000000000..77c16e87f7d92 --- /dev/null +++ b/recipes/cpp-lazy/config.yml @@ -0,0 +1,3 @@ +versions: + "6.0.0": + folder: all diff --git a/recipes/cpp-optparse/all/CMakeLists.txt b/recipes/cpp-optparse/all/CMakeLists.txt index 1b1cd4a6f56b1..85cb504fb1461 100644 --- a/recipes/cpp-optparse/all/CMakeLists.txt +++ b/recipes/cpp-optparse/all/CMakeLists.txt @@ -1,18 +1,14 @@ cmake_minimum_required(VERSION 3.4) -project(cpp-optparser) +project(cpp-optparse LANGUAGES CXX) -include(conanbuildinfo.cmake) -conan_basic_setup() +include(GNUInstallDirs) -add_library(OptionParser source_subfolder/OptionParser.cpp) - -if(MSVC AND BUILD_SHARED_LIBS) - set_target_properties(OptionParser PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) -endif() +add_library(OptionParser ${CPP_OPTPARSE_SRC_DIR}/OptionParser.cpp) +set_target_properties(OptionParser PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) install(TARGETS OptionParser - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(FILES source_subfolder/OptionParser.h DESTINATION include) +install(FILES ${CPP_OPTPARSE_SRC_DIR}/OptionParser.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/cpp-optparse/all/conanfile.py b/recipes/cpp-optparse/all/conanfile.py index 219e464035256..4eddbf4e8f909 100644 --- a/recipes/cpp-optparse/all/conanfile.py +++ b/recipes/cpp-optparse/all/conanfile.py @@ -1,31 +1,30 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get import os -import glob +required_conan_version = ">=1.46.0" -class CppOptparse(ConanFile): + +class CppOptparseConan(ConanFile): name = "cpp-optparse" license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/weisslj/cpp-optparse" description = "Python's excellent OptionParser in C++" - topics = ("conan", "cpp-optparse", "argument", "parsing") - settings = "os", "compiler", "build_type", "arch" - options = {"fPIC": [True, False], - "shared": [True, False]} - default_options = {"fPIC": True, - "shared": False} - generators = "cmake" - exports_sources = ["CMakeLists.txt"] - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + topics = ("cpp-optparse", "argument", "parsing") + + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + "shared": [True, False], + } + default_options = { + "fPIC": True, + "shared": False, + } + + exports_sources = "CMakeLists.txt" def config_options(self): if self.settings.os == "Windows": @@ -35,25 +34,27 @@ def configure(self): if self.options.shared: del self.options.fPIC + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("cpp-optparse-*")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CPP_OPTPARSE_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["OptionParser"] diff --git a/recipes/cpp-optparse/all/test_package/CMakeLists.txt b/recipes/cpp-optparse/all/test_package/CMakeLists.txt index be424f797e329..39cb8da083e2d 100644 --- a/recipes/cpp-optparse/all/test_package/CMakeLists.txt +++ b/recipes/cpp-optparse/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cpp-optparse REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -conan_target_link_libraries(${PROJECT_NAME}) +target_link_libraries(${PROJECT_NAME} PRIVATE cpp-optparse::cpp-optparse) diff --git a/recipes/cpp-optparse/all/test_package/conanfile.py b/recipes/cpp-optparse/all/test_package/conanfile.py index 4d7a75245472b..d1d4c5276c22f 100644 --- a/recipes/cpp-optparse/all/test_package/conanfile.py +++ b/recipes/cpp-optparse/all/test_package/conanfile.py @@ -1,9 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path + " --help", run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(f"{bin_path} --help", env="conanrun") diff --git a/recipes/cpp-optparse/all/test_v1_package/CMakeLists.txt b/recipes/cpp-optparse/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3b1318982f30f --- /dev/null +++ b/recipes/cpp-optparse/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cpp-optparse REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cpp-optparse::cpp-optparse) diff --git a/recipes/cpp-optparse/all/test_v1_package/conanfile.py b/recipes/cpp-optparse/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..9f45afc4e29a1 --- /dev/null +++ b/recipes/cpp-optparse/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(f"{bin_path} --help", run_environment=True) diff --git a/recipes/cpp-peglib/0.x.x/conandata.yml b/recipes/cpp-peglib/0.x.x/conandata.yml new file mode 100644 index 0000000000000..a29b4845fd315 --- /dev/null +++ b/recipes/cpp-peglib/0.x.x/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.1.13": + url: "https://github.com/yhirose/cpp-peglib/archive/v0.1.13.tar.gz" + sha256: "84af1255c0c53be57abbc41bf216d6ab7e0dbd0ff8886841b29e0e089dd985ca" diff --git a/recipes/cpp-peglib/0.x.x/conanfile.py b/recipes/cpp-peglib/0.x.x/conanfile.py new file mode 100644 index 0000000000000..1121c3515336e --- /dev/null +++ b/recipes/cpp-peglib/0.x.x/conanfile.py @@ -0,0 +1,47 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class CpppeglibConan(ConanFile): + name = "cpp-peglib" + description = "A single file C++11 header-only PEG (Parsing Expression Grammars) library." + license = "MIT" + topics = ("peg", "parser", "header-only") + homepage = "https://github.com/yhirose/cpp-peglib" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "peglib.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/cpp-peglib/0.x.x/test_package/CMakeLists.txt b/recipes/cpp-peglib/0.x.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..9f2b801df306b --- /dev/null +++ b/recipes/cpp-peglib/0.x.x/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(cpp-peglib CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cpp-peglib::cpp-peglib) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cpp-peglib/0.x.x/test_package/conanfile.py b/recipes/cpp-peglib/0.x.x/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/cpp-peglib/0.x.x/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cpp-peglib/all/test_package/test_package.cpp b/recipes/cpp-peglib/0.x.x/test_package/test_package.cpp similarity index 100% rename from recipes/cpp-peglib/all/test_package/test_package.cpp rename to recipes/cpp-peglib/0.x.x/test_package/test_package.cpp diff --git a/recipes/cpp-peglib/0.x.x/test_v1_package/CMakeLists.txt b/recipes/cpp-peglib/0.x.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..fad4cae2ba206 --- /dev/null +++ b/recipes/cpp-peglib/0.x.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cpp-peglib CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cpp-peglib::cpp-peglib) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cpp-peglib/0.x.x/test_v1_package/conanfile.py b/recipes/cpp-peglib/0.x.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cpp-peglib/0.x.x/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpp-peglib/1.x.x/conandata.yml b/recipes/cpp-peglib/1.x.x/conandata.yml index df8f7261f2634..08e29671dff3e 100644 --- a/recipes/cpp-peglib/1.x.x/conandata.yml +++ b/recipes/cpp-peglib/1.x.x/conandata.yml @@ -1,17 +1,34 @@ sources: - "1.3.7": - url: "https://github.com/yhirose/cpp-peglib/archive/v1.3.7.tar.gz" - sha256: "3f68843d442e5013ff927cadc6ae2e2364305fbf30dee287c798b094642124f8" - "1.3.5": - url: "https://github.com/yhirose/cpp-peglib/archive/v1.3.5.tar.gz" - sha256: "10e4bd70dff77bc3038382d1fce41f9f48629e8cd81e432dd27e232ba852b2e1" - "1.3.3": - url: "https://github.com/yhirose/cpp-peglib/archive/v1.3.3.tar.gz" - sha256: "939968fafe593ee64d46b803c5fb49b87835102db085a066311f3d47c09a67b9" - "1.3.1": - url: "https://github.com/yhirose/cpp-peglib/archive/v1.3.1.tar.gz" - sha256: "9ab528afd95ad2dcecfa86b0e46952b142be09958fc8a6a605fcd3ea4f812c5f" -patches: - "1.3.7": - - patch_file: patches/fix-token_to_number_.patch - base_path: source_subfolder + "1.8.2": + url: "https://github.com/yhirose/cpp-peglib/archive/v1.8.2.tar.gz" + sha256: "eca5d06dafb940ffee8a99060a57272ada7f2486fc21ed1663e4e49851a70e0c" + "1.8.1": + url: "https://github.com/yhirose/cpp-peglib/archive/v1.8.1.tar.gz" + sha256: "15d7c39d01780bb6f27db511722936d82d04cb1f5a6c63025021ff5dfe5fe1b2" + "1.8.0": + url: "https://github.com/yhirose/cpp-peglib/archive/refs/tags/v1.8.0.tar.gz" + sha256: "63dc755afb5072ba58468fa39d1037ebadc1206c489b0493d635147524cf5379" + "1.6.1": + url: "https://github.com/yhirose/cpp-peglib/archive/v1.6.1.tar.gz" + sha256: "e1777ea79323c4cfe98587edc50e33df0c42bdb8648b7c5cc679dbf85f4f4768" + "1.6.0": + url: "https://github.com/yhirose/cpp-peglib/archive/v1.6.0.tar.gz" + sha256: "2b09d711fd02bad24089bc5a6f51ef4c307d86e0adb6f9938e0549a12c102ac4" + "1.5.0": + url: "https://github.com/yhirose/cpp-peglib/archive/refs/tags/v1.5.0.tar.gz" + sha256: "45a02b749556af6ab0abf78c4c1d1afe02f17705b1c51f5820e957616f453b33" + "1.4.2": + url: "https://github.com/yhirose/cpp-peglib/archive/refs/tags/v1.4.2.tar.gz" + sha256: "28a09c1bee50608733a989cd5b62368a767a66f9e1a39654c0342e9698c479ca" + "1.4.1": + url: "https://github.com/yhirose/cpp-peglib/archive/refs/tags/v1.4.1.tar.gz" + sha256: "3784039727f8317cd5e202c5a2d142584bf48a311910643298dc4ba9083424e7" + "1.3.10": + url: "https://github.com/yhirose/cpp-peglib/archive/refs/tags/v1.3.10.tar.gz" + sha256: "9c79abd8a304d163d176918b74d7ab272e6ab1405af2dd699b6b7ae1b5605b09" + "1.3.9": + url: "https://github.com/yhirose/cpp-peglib/archive/refs/tags/v1.3.9.tar.gz" + sha256: "0d14fcbf7ed4409699fff70867c5776a2219e38547de5bf0bf689ba0d58c0d7f" + "1.3.8": + url: "https://github.com/yhirose/cpp-peglib/archive/refs/tags/v1.3.8.tar.gz" + sha256: "6d266806825ec491f1e3d1eb8a2163114f328a691f7c9fbce7bb3edf2f42074c" diff --git a/recipes/cpp-peglib/1.x.x/conanfile.py b/recipes/cpp-peglib/1.x.x/conanfile.py index 6d198030c439c..6e5ba98921cbb 100644 --- a/recipes/cpp-peglib/1.x.x/conanfile.py +++ b/recipes/cpp-peglib/1.x.x/conanfile.py @@ -1,21 +1,29 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +from conans import tools as tools_legacy import os +required_conan_version = ">=1.50.0" + class CpppeglibConan(ConanFile): name = "cpp-peglib" description = "A single file C++11 header-only PEG (Parsing Expression Grammars) library." license = "MIT" - topics = ("conan", "cpp-peglib", "peg", "parser", "header-only") - homepage = "https://github.com/yhirose/cpp-peglib" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler" - exports_sources = "patches/**" + homepage = "https://github.com/yhirose/cpp-peglib" + topics = ("peg", "parser", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True @property - def _source_subfolder(self): - return "source_subfolder" + def _min_cppstd(self): + return "17" @property def _compilers_minimum_version(self): @@ -26,46 +34,52 @@ def _compilers_minimum_version(self): "apple-clang": "10" } - def configure(self): + def package_id(self): + self.info.clear() + + def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 17) + check_min_cppstd(self, self._min_cppstd) - def lazy_lt_semver(v1, v2): + def loose_lt_semver(v1, v2): lv1 = [int(v) for v in v1.split(".")] lv2 = [int(v) for v in v2.split(".")] min_length = min(len(lv1), len(lv2)) return lv1[:min_length] < lv2[:min_length] minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if not minimum_version: - self.output.warn("{} {} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name, self.version)) - elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): - raise ConanInvalidConfiguration("{} {} requires C++17, which your compiler does not support.".format(self.name, self.version)) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.", + ) - if self.settings.compiler == "clang" and tools.Version(self.settings.compiler.version) == "7" and \ - tools.stdcpp_library(self) == "stdc++": - raise ConanInvalidConfiguration("{} {} does not support clang 7 with libstdc++.".format(self.name, self.version)) + if self.settings.compiler == "clang" and Version(self.settings.compiler.version) == "7" and \ + tools_legacy.stdcpp_library(self) == "stdc++": + raise ConanInvalidConfiguration(f"{self.name} {self.version} does not support clang 7 with libstdc++.") - def package_id(self): - self.info.header_only() + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("peglib.h", dst="include", src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "peglib.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) def package_info(self): - if self.settings.os == "Linux": + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["pthread"] self.cpp_info.cxxflags.append("-pthread") self.cpp_info.exelinkflags.append("-pthread") self.cpp_info.sharedlinkflags.append("-pthread") - if self.settings.compiler == "Visual Studio": + if is_msvc(self): self.cpp_info.cxxflags.append("/Zc:__cplusplus") diff --git a/recipes/cpp-peglib/1.x.x/patches/fix-token_to_number_.patch b/recipes/cpp-peglib/1.x.x/patches/fix-token_to_number_.patch deleted file mode 100644 index 2398f013cf624..0000000000000 --- a/recipes/cpp-peglib/1.x.x/patches/fix-token_to_number_.patch +++ /dev/null @@ -1,29 +0,0 @@ -Fix compilation errors with clang 6, 7, 10, 11 and gcc 7 -see https://github.com/yhirose/cpp-peglib/pull/168 - ---- a/peglib.h -+++ b/peglib.h -@@ -13,9 +13,6 @@ - #include - #if __has_include() - #include --#define CPPPEGLIB_HAS_CHARCONV true --#else --#define CPPPEGLIB_HAS_CHARCONV false - #endif - #include - #include -@@ -343,8 +340,12 @@ inline std::string resolve_escape_sequence(const char *s, size_t n) { - - template T token_to_number_(std::string_view sv) { - T n = 0; -- if constexpr (CPPPEGLIB_HAS_CHARCONV && !std::is_floating_point::value) { -+#if __has_include() -+ if constexpr (!std::is_floating_point::value) { - std::from_chars(sv.data(), sv.data() + sv.size(), n); -+#else -+ if constexpr (false) { -+#endif - } else { - auto s = std::string(sv); - std::istringstream ss(s); diff --git a/recipes/cpp-peglib/1.x.x/test_package/CMakeLists.txt b/recipes/cpp-peglib/1.x.x/test_package/CMakeLists.txt index b3261081f0004..de79c59d80c35 100644 --- a/recipes/cpp-peglib/1.x.x/test_package/CMakeLists.txt +++ b/recipes/cpp-peglib/1.x.x/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cpp-peglib CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17) +target_link_libraries(${PROJECT_NAME} PRIVATE cpp-peglib::cpp-peglib) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/cpp-peglib/1.x.x/test_package/conanfile.py b/recipes/cpp-peglib/1.x.x/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/cpp-peglib/1.x.x/test_package/conanfile.py +++ b/recipes/cpp-peglib/1.x.x/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cpp-peglib/1.x.x/test_v1_package/CMakeLists.txt b/recipes/cpp-peglib/1.x.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..71e37a553ede3 --- /dev/null +++ b/recipes/cpp-peglib/1.x.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cpp-peglib CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cpp-peglib::cpp-peglib) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/cpp-peglib/1.x.x/test_v1_package/conanfile.py b/recipes/cpp-peglib/1.x.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cpp-peglib/1.x.x/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpp-peglib/all/conandata.yml b/recipes/cpp-peglib/all/conandata.yml deleted file mode 100644 index ad5521652bf55..0000000000000 --- a/recipes/cpp-peglib/all/conandata.yml +++ /dev/null @@ -1,16 +0,0 @@ -sources: - "0.1.13": - url: "https://github.com/yhirose/cpp-peglib/archive/v0.1.13.tar.gz" - sha256: "84af1255c0c53be57abbc41bf216d6ab7e0dbd0ff8886841b29e0e089dd985ca" - "0.1.12": - url: "https://github.com/yhirose/cpp-peglib/archive/v0.1.12.tar.gz" - sha256: "162bd0bf3492722dd251ec0968f7d643146872adedeb3779bb9faffcb56ebd24" - "0.1.7": - url: "https://github.com/yhirose/cpp-peglib/archive/v0.1.7.tar.gz" - sha256: "b3f74347bcd0c09e50e76d94091907426b935bb44a0a291de6d16317e7753d53" - "0.1.6": - url: "https://github.com/yhirose/cpp-peglib/archive/v0.1.6.tar.gz" - sha256: "a051a0131bac474d24b07220e9fa1b485e50179b6e0f84253475035bc3859bc3" - "0.1.5": - url: "https://github.com/yhirose/cpp-peglib/archive/v0.1.5.tar.gz" - sha256: "3879548ed220beb6d9c36f73dc7f6173c45f3cb33c797f0701f2cd5bc07d9696" diff --git a/recipes/cpp-peglib/all/conanfile.py b/recipes/cpp-peglib/all/conanfile.py deleted file mode 100644 index 2ac7a870ae96b..0000000000000 --- a/recipes/cpp-peglib/all/conanfile.py +++ /dev/null @@ -1,32 +0,0 @@ -import os - -from conans import ConanFile, tools - -class CpppeglibConan(ConanFile): - name = "cpp-peglib" - description = "A single file C++11 header-only PEG (Parsing Expression Grammars) library." - license = "MIT" - topics = ("conan", "cpp-peglib", "peg", "parser", "header-only") - homepage = "https://github.com/yhirose/cpp-peglib" - url = "https://github.com/conan-io/conan-center-index" - settings = "os" - no_copy_source = True - - @property - def _source_subfolder(self): - return "source_subfolder" - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("peglib.h", dst="include", src=self._source_subfolder) - - def package_id(self): - self.info.header_only() - - def package_info(self): - if self.settings.os == "Linux": - self.cpp_info.system_libs.append("pthread") diff --git a/recipes/cpp-peglib/all/test_package/CMakeLists.txt b/recipes/cpp-peglib/all/test_package/CMakeLists.txt deleted file mode 100644 index 829b5ca81b9ce..0000000000000 --- a/recipes/cpp-peglib/all/test_package/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) diff --git a/recipes/cpp-peglib/config.yml b/recipes/cpp-peglib/config.yml index 02bc95f44ebaa..0c3a84819eed8 100644 --- a/recipes/cpp-peglib/config.yml +++ b/recipes/cpp-peglib/config.yml @@ -1,19 +1,25 @@ versions: - "1.3.7": + "1.8.2": folder: "1.x.x" - "1.3.5": + "1.8.1": folder: "1.x.x" - "1.3.3": + "1.8.0": folder: "1.x.x" - "1.3.1": + "1.6.1": + folder: "1.x.x" + "1.6.0": + folder: "1.x.x" + "1.5.0": + folder: "1.x.x" + "1.4.2": + folder: "1.x.x" + "1.4.1": + folder: "1.x.x" + "1.3.10": + folder: "1.x.x" + "1.3.9": + folder: "1.x.x" + "1.3.8": folder: "1.x.x" "0.1.13": - folder: all - "0.1.12": - folder: all - "0.1.7": - folder: all - "0.1.6": - folder: all - "0.1.5": - folder: all + folder: "0.x.x" diff --git a/recipes/cpp-sort/all/conandata.yml b/recipes/cpp-sort/all/conandata.yml index 9aa6f7aa25201..75a1298f3e54e 100644 --- a/recipes/cpp-sort/all/conandata.yml +++ b/recipes/cpp-sort/all/conandata.yml @@ -1,22 +1,40 @@ sources: - "1.5.1": - sha256: 39925958dbd773f15d36d74d4ded48f075c05feef7fe604c7c5c4bfae2a4ec55 - url: https://github.com/Morwenn/cpp-sort/archive/1.5.1.tar.gz - "1.6.0": - sha256: df048d15ff555030eb90d3c96f560a75bbec8baee256f2ced647f359c892c9c8 - url: https://github.com/Morwenn/cpp-sort/archive/1.6.0.tar.gz - "1.7.0": - sha256: 4a8230be2c63a92395e140cb7e6593171638a41c46f4cd14d6ffc354ba830e2b - url: https://github.com/Morwenn/cpp-sort/archive/1.7.0.tar.gz - "1.8.0": - sha256: a3de426a66cffbe9f8865feb7518ff4f4d1b3aadf3725161b8e118dcbf6fe9b9 - url: https://github.com/Morwenn/cpp-sort/archive/1.8.0.tar.gz - "1.8.1": - sha256: 04d518dabb422614fcb4a2b4e258c515f31dd01d51c26e9eaaec76e77c4d3d40 - url: https://github.com/Morwenn/cpp-sort/archive/1.8.1.tar.gz - "1.9.0": - sha256: e83f3daad30bd91fed668bdb56ad379c4aeea39d7dc640484fdcc55149b6d0e4 - url: https://github.com/Morwenn/cpp-sort/archive/1.9.0.tar.gz + "1.13.2": + sha256: f5384ed9c8abef2f26cb010df2687ac8bba52f0e1726935826a80e83c1347b23 + url: https://github.com/Morwenn/cpp-sort/archive/1.13.2.tar.gz + "1.13.1": + sha256: 139912c6004df8748bb1cfd3b94f2c6bfc2713885ed4b8e927a783d6b66963a8 + url: https://github.com/Morwenn/cpp-sort/archive/1.13.1.tar.gz + "1.13.0": + sha256: 646eca5c592d20cbde0fbff41c65527940bb6430be68e0224fb5fcbf38b0df92 + url: https://github.com/Morwenn/cpp-sort/archive/1.13.0.tar.gz + "1.12.1": + sha256: 5b0b6f3b4d9ecc339d6c2204a18479edca49fbc4d487413e0ec747e143569e2a + url: https://github.com/Morwenn/cpp-sort/archive/1.12.1.tar.gz + "1.12.0": + sha256: 70877c1993fa1e5eb53974ac30aeb713448c206344379f193dec8ee887c23998 + url: https://github.com/Morwenn/cpp-sort/archive/1.12.0.tar.gz + "1.11.0": + sha256: a53b3ea240d6f8d8ea9da0a7e0c8e313cf5e714daedf1617473ab34f111ffeec + url: https://github.com/Morwenn/cpp-sort/archive/1.11.0.tar.gz "1.10.0": sha256: 48951cac0051d48fee286c3bc02804975f9d83269d80c10dfc5589e76a542765 url: https://github.com/Morwenn/cpp-sort/archive/1.10.0.tar.gz + "1.9.0": + sha256: e83f3daad30bd91fed668bdb56ad379c4aeea39d7dc640484fdcc55149b6d0e4 + url: https://github.com/Morwenn/cpp-sort/archive/1.9.0.tar.gz + "1.8.1": + sha256: 04d518dabb422614fcb4a2b4e258c515f31dd01d51c26e9eaaec76e77c4d3d40 + url: https://github.com/Morwenn/cpp-sort/archive/1.8.1.tar.gz + "1.8.0": + sha256: a3de426a66cffbe9f8865feb7518ff4f4d1b3aadf3725161b8e118dcbf6fe9b9 + url: https://github.com/Morwenn/cpp-sort/archive/1.8.0.tar.gz + "1.7.0": + sha256: 4a8230be2c63a92395e140cb7e6593171638a41c46f4cd14d6ffc354ba830e2b + url: https://github.com/Morwenn/cpp-sort/archive/1.7.0.tar.gz + "1.6.0": + sha256: df048d15ff555030eb90d3c96f560a75bbec8baee256f2ced647f359c892c9c8 + url: https://github.com/Morwenn/cpp-sort/archive/1.6.0.tar.gz + "1.5.1": + sha256: 39925958dbd773f15d36d74d4ded48f075c05feef7fe604c7c5c4bfae2a4ec55 + url: https://github.com/Morwenn/cpp-sort/archive/1.5.1.tar.gz diff --git a/recipes/cpp-sort/all/conanfile.py b/recipes/cpp-sort/all/conanfile.py index 8e583eea10ea5..881a2c63d61be 100644 --- a/recipes/cpp-sort/all/conanfile.py +++ b/recipes/cpp-sort/all/conanfile.py @@ -1,44 +1,55 @@ -import os +import os.path -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.scm import Version + +required_conan_version = ">=1.50.0" class CppSortConan(ConanFile): name = "cpp-sort" description = "Additional sorting algorithms & related tools" - topics = "conan", "cpp-sort", "sorting", "algorithms" + topics = "cpp-sort", "sorting", "algorithms" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/Morwenn/cpp-sort" license = "MIT" no_copy_source = True settings = "os", "compiler", "build_type", "arch" - @property - def _source_subfolder(self): - return "source_subfolder" - @property def _minimum_cpp_standard(self): return 14 @property - def _minimum_compilers_version(self): + def _compilers_minimum_version(self): return { "apple-clang": "9.4", "clang": "3.8", - "gcc": "5.5", - "Visual Studio": "16" + "gcc": "5.5" } + def layout(self): + cmake_layout(self, src_folder="src") + def validate(self): if self.settings.get_safe("compiler.cppstd"): - tools.check_min_cppstd(self, self._minimum_cpp_standard) + check_min_cppstd(self, self._minimum_cpp_standard) + + if is_msvc(self): + if Version(self.version) < "1.10.0": + raise ConanInvalidConfiguration("cpp-sort versions older than 1.10.0 do not support MSVC") + check_min_vs(self, 192) + return compiler = self.settings.compiler try: - min_version = self._minimum_compilers_version[str(compiler)] - if tools.Version(compiler.version) < min_version: + min_version = self._compilers_minimum_version[str(compiler)] + if Version(compiler.version) < min_version: msg = ( "{} requires C++{} features which are not supported by compiler {} {}." ).format(self.name, self._minimum_cpp_standard, compiler, compiler.version) @@ -51,31 +62,35 @@ def validate(self): self.output.warn(msg) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = "OFF" + tc.generate() def package(self): # Install with CMake cmake = CMake(self) - cmake.definitions["BUILD_TESTING"] = "OFF" - cmake.configure(source_folder=self._source_subfolder) + cmake.configure() cmake.install() # Copy license files - if tools.Version(self.version) < "1.8.0": + if Version(self.version) < "1.8.0": license_files = ["license.txt"] else: license_files = ["LICENSE.txt", "NOTICE.txt"] for license_file in license_files: - self.copy(license_file, dst="licenses", src=self._source_subfolder) + copy(self, license_file, src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) # Remove CMake config files (only files in lib) - tools.rmdir(os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib")) def package_info(self): + self.cpp_info.names["cmake_find_package"] = "cpp-sort" + self.cpp_info.names["cmake_find_package_multi"] = "cpp-sort" if self.settings.compiler == "Visual Studio": self.cpp_info.cxxflags = ["/permissive-"] def package_id(self): - self.info.header_only() + self.info.clear() diff --git a/recipes/cpp-sort/all/test_package/CMakeLists.txt b/recipes/cpp-sort/all/test_package/CMakeLists.txt index 1188af055db95..fe9c658362ade 100644 --- a/recipes/cpp-sort/all/test_package/CMakeLists.txt +++ b/recipes/cpp-sort/all/test_package/CMakeLists.txt @@ -1,10 +1,9 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cpp-sort REQUIRED CONFIG) add_executable(${CMAKE_PROJECT_NAME} cpp-sort-integrity.cpp) -target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${CMAKE_PROJECT_NAME} cpp-sort::cpp-sort) set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 14) diff --git a/recipes/cpp-sort/all/test_package/conanfile.py b/recipes/cpp-sort/all/test_package/conanfile.py index 3b1fda73382d9..3c57d0fcd9af8 100644 --- a/recipes/cpp-sort/all/test_package/conanfile.py +++ b/recipes/cpp-sort/all/test_package/conanfile.py @@ -1,11 +1,19 @@ -import os.path - -from conans import ConanFile, CMake +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os class CppsortTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,5 +21,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cpp-sort/all/test_v1_package/CMakeLists.txt b/recipes/cpp-sort/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4ebb96b60a293 --- /dev/null +++ b/recipes/cpp-sort/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) + +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cpp-sort REQUIRED CONFIG) + +add_executable(${CMAKE_PROJECT_NAME} cpp-sort-integrity.cpp) +target_link_libraries(${CMAKE_PROJECT_NAME} cpp-sort::cpp-sort) +set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 14) diff --git a/recipes/cpp-sort/all/test_v1_package/conanfile.py b/recipes/cpp-sort/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..b6f0560ab0e48 --- /dev/null +++ b/recipes/cpp-sort/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class CppsortTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpp-sort/all/test_v1_package/cpp-sort-integrity.cpp b/recipes/cpp-sort/all/test_v1_package/cpp-sort-integrity.cpp new file mode 100644 index 0000000000000..05f269569147f --- /dev/null +++ b/recipes/cpp-sort/all/test_v1_package/cpp-sort-integrity.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018-2020 Morwenn. + * + * SPDX-License-Identifier: MIT + */ +#include +#include +#include +#include +#include + +int main() +{ + int arr[] = { 5, 8, 3, 2, 9 }; + cppsort::smooth_sort(arr); + assert(std::is_sorted(std::begin(arr), std::end(arr))); + + // should print 2 3 5 8 9 + for (int val: arr) { + std::cout << val << ' '; + } +} diff --git a/recipes/cpp-sort/config.yml b/recipes/cpp-sort/config.yml index 8206b27d71479..55b2c50d93416 100644 --- a/recipes/cpp-sort/config.yml +++ b/recipes/cpp-sort/config.yml @@ -1,15 +1,27 @@ versions: - "1.5.1": + "1.13.2": folder: all - "1.6.0": + "1.13.1": folder: all - "1.7.0": + "1.13.0": folder: all - "1.8.0": + "1.12.1": folder: all - "1.8.1": + "1.12.0": folder: all - "1.9.0": + "1.11.0": folder: all "1.10.0": folder: all + "1.9.0": + folder: all + "1.8.1": + folder: all + "1.8.0": + folder: all + "1.7.0": + folder: all + "1.6.0": + folder: all + "1.5.1": + folder: all diff --git a/recipes/cpp_project_framework/all/conandata.yml b/recipes/cpp_project_framework/all/conandata.yml new file mode 100644 index 0000000000000..43a795642b381 --- /dev/null +++ b/recipes/cpp_project_framework/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.0": + url: "https://github.com/sheepgrass/cpp_project_framework/archive/1.0.0.tar.gz" + sha256: "1df9f3ad46e369372e1a3b108437b929e13320f8d649d2f360b8a3d033c8c60d" diff --git a/recipes/cpp_project_framework/all/conanfile.py b/recipes/cpp_project_framework/all/conanfile.py new file mode 100644 index 0000000000000..5a2a5fe5679e4 --- /dev/null +++ b/recipes/cpp_project_framework/all/conanfile.py @@ -0,0 +1,65 @@ +from conan import ConanFile +from conan.tools.files import get +from conan.tools.scm import Version +from conans.errors import ConanInvalidConfiguration +from conans.tools import check_min_cppstd +import os + +required_conan_version = ">=1.33.0" + + +class CppProjectFrameworkConan(ConanFile): + name = "cpp_project_framework" + license = "AGPL-3.0" + homepage = "https://github.com/sheepgrass/cpp_project_framework" + url = "https://github.com/conan-io/conan-center-index" # Package recipe repository url here, for issues about the package + description = "C++ Project Framework is a framework for creating C++ project." + topics = ("cpp", "project", "framework") + settings = "os", "compiler", "build_type", "arch" + + def package_id(self): + self.info.header_only() + + @property + def _minimum_cpp_standard(self): + return 14 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "gcc": "7", + "clang": "6", + "apple-clang": "10", + } + + def validate(self): + if self.settings.os not in ('Linux', 'Windows'): + raise ConanInvalidConfiguration(f"{self.name} is just supported for Linux and Windows") + + compiler = self.settings.compiler + + if compiler.get_safe("cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + + if compiler in ('gcc', 'clang'): + if compiler.get_safe("libcxx") != "libstdc++": + raise ConanInvalidConfiguration(f"only supported {compiler} with libstdc++") + + min_version = self._minimum_compilers_version.get(str(compiler)) + if not min_version: + self.output.warn(f"{self.name} recipe lacks information about the {compiler} compiler support.") + else: + if Version(compiler.version) < min_version: + raise ConanInvalidConfiguration(f"{self.name} requires C++{self._minimum_cpp_standard} support. The current compiler {compiler} {compiler.version} does not support it.") + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + self.copy("*.h", dst=os.path.join("include", self.name), src=os.path.join(self._source_subfolder, self.name)) diff --git a/recipes/cpp_project_framework/all/test_package/CMakeLists.txt b/recipes/cpp_project_framework/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d3c22a987a39d --- /dev/null +++ b/recipes/cpp_project_framework/all/test_package/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cpp_project_framework REQUIRED) +find_package(GTest REQUIRED) + +add_executable(test_package test_package.cpp) +if(UNIX) + target_link_libraries(test_package cpp_project_framework::cpp_project_framework GTest::gtest GTest::gtest_main stdc++fs) +else() + target_link_libraries(test_package cpp_project_framework::cpp_project_framework GTest::gtest GTest::gtest_main) +endif() diff --git a/recipes/cpp_project_framework/all/test_package/conanfile.py b/recipes/cpp_project_framework/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ed8a4e73713c6 --- /dev/null +++ b/recipes/cpp_project_framework/all/test_package/conanfile.py @@ -0,0 +1,20 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conans import CMake +import os + + +class CppProjectFrameworkTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + requires = "gtest/1.10.0" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpp_project_framework/all/test_package/test_package.cpp b/recipes/cpp_project_framework/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..056f85631bb0f --- /dev/null +++ b/recipes/cpp_project_framework/all/test_package/test_package.cpp @@ -0,0 +1,30 @@ +#include "cpp_project_framework/cpp_project_framework.h" + +#include "cpp_project_framework/filesystem.h" +#include "cpp_project_framework/gtest.h" + + +/// Dummy test +TEST(CppProjectFrameworkTest, DummyTest) +{ + EXPECT_TRUE(true); +} + + /// Test for GET_TEST_CASE_NAME() macro +TEST(CppProjectFrameworkGoogleTestTest, GetTestCaseName) +{ + EXPECT_STREQ(GET_TEST_CASE_NAME(), "CppProjectFrameworkGoogleTestTest.GetTestCaseName"); +} + +/// Test for SCOPED_TRACE_CODE_BLOCK() macro +TEST(CppProjectFrameworkGoogleTestTest, ScopedTraceCodeBlock) +{ + SCOPED_TRACE_CODE_BLOCK(EXPECT_STREQ(GET_TEST_CASE_NAME(), "CppProjectFrameworkGoogleTestTest.ScopedTraceCodeBlock")); +} + +/// Test for filesystem header +TEST(CppProjectFrameworkFileSystemTest, FileSystem) +{ + namespace fs = sheepgrass::filesystem; + EXPECT_TRUE(fs::is_directory(fs::current_path())); +} diff --git a/recipes/cpp_project_framework/config.yml b/recipes/cpp_project_framework/config.yml new file mode 100644 index 0000000000000..40341aa3db6cd --- /dev/null +++ b/recipes/cpp_project_framework/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.0": + folder: all diff --git a/recipes/cppcheck/all/CMakeLists.txt b/recipes/cppcheck/all/CMakeLists.txt deleted file mode 100644 index b0b16ec6b271c..0000000000000 --- a/recipes/cppcheck/all/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include("conanbuildinfo.cmake") -conan_basic_setup(TARGETS) - -# Set include paths -conan_global_flags() - -# Setup libraries to link -set(Z3_LIBRARIES CONAN_PKG::z3) -set(PCRE_LIBRARY CONAN_PKG::pcre) - -add_subdirectory(source_subfolder) diff --git a/recipes/cppcheck/all/conandata.yml b/recipes/cppcheck/all/conandata.yml index a5b57299e5623..d97f5c1a31a95 100644 --- a/recipes/cppcheck/all/conandata.yml +++ b/recipes/cppcheck/all/conandata.yml @@ -1,26 +1,38 @@ sources: - "2.4.1": - url: "https://github.com/danmar/cppcheck/archive/2.4.1.tar.gz" - sha256: "11a9d9fe5305a105561655c45d2cd83cb30fbc87b41d0569de1b00a1a314867f" - "2.4": - url: "https://github.com/danmar/cppcheck/archive/2.4.tar.gz" - sha256: "d1ac6a1eaf24f2f54df5a164c7e37d1e0624cc094a4622e226a73b53ede1eeb8" - "2.3": - url: "https://github.com/danmar/cppcheck/archive/2.3.tar.gz" - sha256: "3c622628ebf46f68909c7a96743b07b6207894a0772fbe802603732152ab1035" - "2.2": - url: "https://github.com/danmar/cppcheck/archive/2.2.tar.gz" - sha256: "ad96290a1842c5934bf9c4268cb270953f3078d4ce33a9a53922d6cb6daf61aa" + "2.9.2": + url: "https://github.com/danmar/cppcheck/archive/2.9.2.tar.gz" + sha256: "93920d24d4442856bf7916ee0e3fc31308bc23948e7029b4fd332e01cac63c3e" + "2.8.2": + url: "https://github.com/danmar/cppcheck/archive/2.8.2.tar.gz" + sha256: "30ba99ab54089c44b83f02e2453da046a7edff5237950d4A0eb1eba4afcb4f45" + "2.7.5": + url: "https://github.com/danmar/cppcheck/archive/2.7.5.tar.gz" + sha256: "6c7ac29e57fa8b3ac7be224510200e579d5a90217e2152591ef46ffc947d8f78" patches: - "2.4.1": - - patch_file: "patches/0001-cmake-source-dir.patch" - base_path: "source_subfolder" - "2.4": - - patch_file: "patches/0001-cmake-source-dir.patch" - base_path: "source_subfolder" - "2.3": - - patch_file: "patches/0001-cmake-source-dir.patch" - base_path: "source_subfolder" - "2.2": - - patch_file: "patches/0001-cmake-source-dir.patch" - base_path: "source_subfolder" + "2.9.2": + - patch_file: "patches/0001-cli-remove-dmake-cmake.patch" + patch_description: "Remove dmake tool from target ALL" + patch_type: "portability" + - patch_file: "patches/0002-htmlreport-python3.patch" + patch_description: "Use Python 3 in Shebang Header" + patch_type: "portability" + - patch_file: "patches/0003-pcre-debuglib-name.patch" + patch_description: "Consider the Debug suffix for Windows" + patch_type: "portability" + "2.8.2": + - patch_file: "patches/0001-cli-remove-dmake-cmake-2.8.patch" + patch_description: "Remove dmake tool from target ALL" + patch_type: "portability" + - patch_file: "patches/0002-htmlreport-python3.patch" + patch_description: "Use Python 3 in Shebang Header" + patch_type: "portability" + - patch_file: "patches/0003-pcre-debuglib-name.patch" + patch_description: "Consider the Debug suffix for Windows" + patch_type: "portability" + "2.7.5": + - patch_file: "patches/0002-htmlreport-python3.patch" + patch_description: "Use Python 3 in Shebang Header" + patch_type: "portability" + - patch_file: "patches/0003-pcre-debuglib-name-2.7.patch" + patch_description: "Consider the Debug suffix for Windows" + patch_type: "portability" diff --git a/recipes/cppcheck/all/conanfile.py b/recipes/cppcheck/all/conanfile.py index 12b76d01a0c15..4427cdebe7d18 100644 --- a/recipes/cppcheck/all/conanfile.py +++ b/recipes/cppcheck/all/conanfile.py @@ -1,71 +1,78 @@ -"""Conan recipe package for cppcheck -""" +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.52.0" class CppcheckConan(ConanFile): name = "cppcheck" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/danmar/cppcheck" - topics = ("Cpp Check", "static analyzer") + topics = ("code quality", "static analyzer", "linter") description = "Cppcheck is an analysis tool for C/C++ code." license = "GPL-3.0-or-later" - generators = "cmake" settings = "os", "arch", "compiler", "build_type" options = {"with_z3": [True, False], "have_rules": [True, False]} default_options = {"with_z3": True, "have_rules": True} - exports_sources = ["CMakeLists.txt", "patches/**"] - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + cmake_layout(self) + + def export_sources(self): + export_conandata_patches(self) - @property - def _build_subfolder(self): - return "build_subfolder" - - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def config_options(self): + if Version(self.version) >= Version("2.8.0"): + del self.options.with_z3 def requirements(self): - if self.options.with_z3: + if self.options.get_safe("with_z3", default=False): self.requires("z3/4.8.8") if self.options.have_rules: - self.requires("pcre/8.44") + self.requires("pcre/8.45") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "cppcheck-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) < "2.8.0": + tc.variables["USE_Z3"] = self.options.with_z3 + tc.variables["HAVE_RULES"] = self.options.have_rules + tc.variables["USE_MATCHCOMPILER"] = "Auto" + tc.variables["ENABLE_OSS_FUZZ"] = False + if is_apple_os(self): + tc.variables["FILESDIR"] = os.path.join(self.package_folder, "bin", "cfg") + tc.generate() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["USE_Z3"] = self.options.with_z3 - self._cmake.definitions["HAVE_RULES"] = self.options.have_rules - self._cmake.definitions["USE_MATCHCOMPILER"] = "Auto" - self._cmake.definitions["ENABLE_OSS_FUZZ"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + deps = CMakeDeps(self) + deps.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - self.copy("*", dst=os.path.join("bin","cfg"), src=os.path.join(self._source_subfolder,"cfg")) - cmake = self._configure_cmake() + copy(self, "COPYING", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder)) + copy(self, "*", dst=os.path.join(self.package_folder, "bin", "cfg"), src=os.path.join(self.source_folder, "cfg")) + copy(self, "cppcheck-htmlreport", dst=os.path.join(self.package_folder, "bin"), src=os.path.join(self.source_folder, "htmlreport")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - + rmdir(self, os.path.join(self.package_folder, "share")) + def package_info(self): + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + bin_folder = os.path.join(self.package_folder, "bin") self.output.info("Append %s to environment variable PATH" % bin_folder) self.env_info.PATH.append(bin_folder) + cppcheck_htmlreport = os.path.join(bin_folder, "cppcheck-htmlreport") + self.env_info.CPPCHECK_HTMLREPORT = cppcheck_htmlreport + self.runenv_info.define_path("CPPCHECK_HTMLREPORT", cppcheck_htmlreport) diff --git a/recipes/cppcheck/all/patches/0001-cli-remove-dmake-cmake-2.8.patch b/recipes/cppcheck/all/patches/0001-cli-remove-dmake-cmake-2.8.patch new file mode 100644 index 0000000000000..157034975424b --- /dev/null +++ b/recipes/cppcheck/all/patches/0001-cli-remove-dmake-cmake-2.8.patch @@ -0,0 +1,14 @@ +--- a/cli/CMakeLists.txt 2022-07-12 23:11:29.000000000 +0200 ++++ b/cli/CMakeLists.txt 2022-11-23 22:01:29.111581500 +0100 +@@ -45,10 +45,9 @@ + + add_dependencies(cppcheck copy_cfg) + add_dependencies(cppcheck copy_addons) +-add_dependencies(cppcheck run-dmake) + + install(TARGETS cppcheck +- RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} ++ DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} + COMPONENT applications) + + install(FILES ${addons} diff --git a/recipes/cppcheck/all/patches/0001-cli-remove-dmake-cmake.patch b/recipes/cppcheck/all/patches/0001-cli-remove-dmake-cmake.patch new file mode 100644 index 0000000000000..18fff8473a497 --- /dev/null +++ b/recipes/cppcheck/all/patches/0001-cli-remove-dmake-cmake.patch @@ -0,0 +1,14 @@ +--- a/cli/CMakeLists.txt 2022-11-08 20:22:59.000000000 +0100 ++++ b/cli/CMakeLists.txt 2022-11-23 21:33:49.347849300 +0100 +@@ -43,10 +43,9 @@ + + add_dependencies(cppcheck copy_cfg) + add_dependencies(cppcheck copy_addons) +-add_dependencies(cppcheck run-dmake) + + install(TARGETS cppcheck +- RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} ++ DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} + COMPONENT applications) + + install(FILES ${addons} diff --git a/recipes/cppcheck/all/patches/0001-cmake-source-dir.patch b/recipes/cppcheck/all/patches/0001-cmake-source-dir.patch deleted file mode 100644 index 95e8658caedb3..0000000000000 --- a/recipes/cppcheck/all/patches/0001-cmake-source-dir.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt -index 303b8d55f77cd36bc597ddfc406bc5fe7c2992e5..e25948fa14664d9a8b758586a75369ecde111ddb 100644 ---- a/tools/CMakeLists.txt -+++ b/tools/CMakeLists.txt -@@ -4,23 +4,23 @@ foreach(file ${srcs_lib}) - set(src "${CMAKE_BINARY_DIR}/lib/build/mc_${file}") - set_source_files_properties(${src} PROPERTIES GENERATED TRUE) - else() -- set(src "${CMAKE_SOURCE_DIR}/lib/${file}") -+ set(src "${PROJECT_SOURCE_DIR}/lib/${file}") - endif() - set(srcs_tools ${srcs_tools} ${src}) - endforeach() - - add_executable(dmake EXCLUDE_FROM_ALL - dmake.cpp -- ${CMAKE_SOURCE_DIR}/cli/filelister.cpp -+ ${PROJECT_SOURCE_DIR}/cli/filelister.cpp - ${srcs_tools} -- ${CMAKE_SOURCE_DIR}/lib/utils.cpp -- ${CMAKE_SOURCE_DIR}/externals/simplecpp/simplecpp -+ ${PROJECT_SOURCE_DIR}/lib/utils.cpp -+ ${PROJECT_SOURCE_DIR}/externals/simplecpp/simplecpp - ) --target_include_directories(dmake PRIVATE ${CMAKE_SOURCE_DIR}/cli ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR}/externals/simplecpp) -+target_include_directories(dmake PRIVATE ${PROJECT_SOURCE_DIR}/cli ${PROJECT_SOURCE_DIR}/lib ${PROJECT_SOURCE_DIR}/externals/simplecpp) - if (WIN32 AND NOT BORLAND) - target_link_libraries(dmake Shlwapi.lib) - endif() - - add_custom_target(run-dmake $ -- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} -+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - DEPENDS dmake) -\ No newline at end of file diff --git a/recipes/cppcheck/all/patches/0002-htmlreport-python3.patch b/recipes/cppcheck/all/patches/0002-htmlreport-python3.patch new file mode 100644 index 0000000000000..2012ae5551b1b --- /dev/null +++ b/recipes/cppcheck/all/patches/0002-htmlreport-python3.patch @@ -0,0 +1,10 @@ +diff --git a/htmlreport/cppcheck-htmlreport b/htmlreport/cppcheck-htmlreport +index 97a3af50d..b45cebf31 100755 +--- a/htmlreport/cppcheck-htmlreport ++++ b/htmlreport/cppcheck-htmlreport +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + + from __future__ import unicode_literals + diff --git a/recipes/cppcheck/all/patches/0003-pcre-debuglib-name-2.7.patch b/recipes/cppcheck/all/patches/0003-pcre-debuglib-name-2.7.patch new file mode 100644 index 0000000000000..fa8b46fd1608e --- /dev/null +++ b/recipes/cppcheck/all/patches/0003-pcre-debuglib-name-2.7.patch @@ -0,0 +1,28 @@ +--- a/cmake/findDependencies.cmake 2022-04-15 20:23:30.000000000 +0200 ++++ b/cmake/findDependencies.cmake 2022-11-24 13:57:22.099453500 +0100 +@@ -16,7 +16,7 @@ + + if (HAVE_RULES) + find_path(PCRE_INCLUDE pcre.h) +- find_library(PCRE_LIBRARY pcre) ++ find_library(PCRE_LIBRARY NAMES pcre pcred) + if (NOT PCRE_LIBRARY OR NOT PCRE_INCLUDE) + message(FATAL_ERROR "pcre dependency for RULES has not been found") + endif() +@@ -24,16 +24,8 @@ + + if (USE_Z3) + find_package(Z3 QUIET) +- if (NOT Z3_FOUND) + find_library(Z3_LIBRARIES z3) +- if (NOT Z3_LIBRARIES) +- message(FATAL_ERROR "z3 dependency has not been found") +- endif() + find_path(Z3_CXX_INCLUDE_DIRS z3++.h PATH_SUFFIXES "z3") +- if (NOT Z3_CXX_INCLUDE_DIRS) +- message(FATAL_ERROR "z3++.h has not been found") +- endif() +- endif() + endif() + + set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/recipes/cppcheck/all/patches/0003-pcre-debuglib-name.patch b/recipes/cppcheck/all/patches/0003-pcre-debuglib-name.patch new file mode 100644 index 0000000000000..9431d05ce2a2d --- /dev/null +++ b/recipes/cppcheck/all/patches/0003-pcre-debuglib-name.patch @@ -0,0 +1,11 @@ +--- a/cmake/findDependencies.cmake 2022-11-08 20:22:59.000000000 +0100 ++++ b/cmake/findDependencies.cmake 2022-11-23 21:29:50.222152900 +0100 +@@ -36,7 +36,7 @@ + + if (HAVE_RULES) + find_path(PCRE_INCLUDE pcre.h) +- find_library(PCRE_LIBRARY pcre) ++ find_library(PCRE_LIBRARY NAMES pcre pcred) + if (NOT PCRE_LIBRARY OR NOT PCRE_INCLUDE) + message(FATAL_ERROR "pcre dependency for RULES has not been found") + endif() diff --git a/recipes/cppcheck/all/test_package/conanfile.py b/recipes/cppcheck/all/test_package/conanfile.py index ae269574fb905..f29289a5751d7 100644 --- a/recipes/cppcheck/all/test_package/conanfile.py +++ b/recipes/cppcheck/all/test_package/conanfile.py @@ -1,7 +1,21 @@ -from conans import ConanFile +from conan import ConanFile +from conan.tools.build import can_run +import sys class TestPackageConan(ConanFile): + settings = "os", "arch" + generators = "VirtualRunEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) def test(self): - self.run("cppcheck --version", run_environment=True) + if can_run(self): + self.run("cppcheck --enable=warning,style,performance --std=c++11 .", + cwd=self.source_folder, run_environment=True) + if self.settings.os == "Windows": + self.run(f"{sys.executable} %CPPCHECK_HTMLREPORT% -h", run_environment=True) + else: + self.run("cppcheck-htmlreport -h", run_environment=True) diff --git a/recipes/cppcheck/all/test_package/file_to_check.cpp b/recipes/cppcheck/all/test_package/file_to_check.cpp new file mode 100644 index 0000000000000..33c14ce1d76c0 --- /dev/null +++ b/recipes/cppcheck/all/test_package/file_to_check.cpp @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/recipes/cppcheck/all/test_v1_package/conanfile.py b/recipes/cppcheck/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..14b7ebe1713c7 --- /dev/null +++ b/recipes/cppcheck/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +import sys + + +class TestPackageConan(ConanFile): + settings = "os", "arch" + generators = "VirtualRunEnv" + + def test(self): + if can_run(self): + self.run("cppcheck --enable=warning,style,performance --std=c++11 .", + cwd=self.source_folder, run_environment=True) + if self.settings.os == "Windows": + # Unable to work with Environment variable CPPCHECK_HTML_REPORT + self.run(f"{sys.executable} %CPPCHECK_HTMLREPORT% -h", run_environment=True) + else: + self.run("cppcheck-htmlreport -h", run_environment=True) diff --git a/recipes/cppcheck/all/test_v1_package/file_to_check.cpp b/recipes/cppcheck/all/test_v1_package/file_to_check.cpp new file mode 100644 index 0000000000000..33c14ce1d76c0 --- /dev/null +++ b/recipes/cppcheck/all/test_v1_package/file_to_check.cpp @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/recipes/cppcheck/config.yml b/recipes/cppcheck/config.yml index 578073d1e0964..bc6d13a4fc4ca 100644 --- a/recipes/cppcheck/config.yml +++ b/recipes/cppcheck/config.yml @@ -1,10 +1,7 @@ versions: - "2.4.1": + "2.9.2": folder: all - "2.4": + "2.8.2": folder: all - "2.3": + "2.7.5": folder: all - "2.2": - folder: all - diff --git a/recipes/cppcodec/all/conanfile.py b/recipes/cppcodec/all/conanfile.py index c843146d3df75..59f96dbe4a59f 100644 --- a/recipes/cppcodec/all/conanfile.py +++ b/recipes/cppcodec/all/conanfile.py @@ -1,5 +1,10 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools + +required_conan_version = ">=1.50.0" class CppcodecConan(ConanFile): @@ -7,21 +12,37 @@ class CppcodecConan(ConanFile): license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/tplgy/cppcodec" - description = "Header-only C++11 library to encode/decode base64, base64url, base32, base32hex and hex (a.k.a. base16) as specified in RFC 4648, plus Crockford's base32" + description = ( + "Header-only C++11 library to encode/decode base64, base64url, base32, " + "base32hex and hex (a.k.a. base16) as specified in RFC 4648, plus Crockford's base32" + ) topics = ("base64", "cpp11", "codec", "base32") + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - _source_subfolder = "source_subfolder" + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("*hpp", dst=os.path.join("include", "cppcodec"), src=os.path.join(self._source_subfolder, "cppcodec")) - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "*hpp", src=os.path.join(self.source_folder, "cppcodec"), dst=os.path.join(self.package_folder, "include", "cppcodec")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "cppcodec-1") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/cppcodec/all/test_package/CMakeLists.txt b/recipes/cppcodec/all/test_package/CMakeLists.txt index 6aab347eddf53..d359976811ee3 100644 --- a/recipes/cppcodec/all/test_package/CMakeLists.txt +++ b/recipes/cppcodec/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cppcodec REQUIRED CONFIG) -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) -set_property(TARGET example PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cppcodec::cppcodec) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cppcodec/all/test_package/conanfile.py b/recipes/cppcodec/all/test_package/conanfile.py index 9a662bfeb73fe..0a6bc68712d90 100644 --- a/recipes/cppcodec/all/test_package/conanfile.py +++ b/recipes/cppcodec/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools -class CppcodecTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cppcodec/all/test_package/example.cpp b/recipes/cppcodec/all/test_package/test_package.cpp similarity index 100% rename from recipes/cppcodec/all/test_package/example.cpp rename to recipes/cppcodec/all/test_package/test_package.cpp diff --git a/recipes/cppcodec/all/test_v1_package/CMakeLists.txt b/recipes/cppcodec/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4e3738c68e0b9 --- /dev/null +++ b/recipes/cppcodec/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cppcodec REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cppcodec::cppcodec) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cppcodec/all/test_v1_package/conanfile.py b/recipes/cppcodec/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cppcodec/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cppcodec/config.yml b/recipes/cppcodec/config.yml index 4862588660bd8..7e65100e62b2c 100644 --- a/recipes/cppcodec/config.yml +++ b/recipes/cppcodec/config.yml @@ -1,4 +1,3 @@ ---- versions: "0.2": folder: all diff --git a/recipes/cppcommon/all/conandata.yml b/recipes/cppcommon/all/conandata.yml index bdaca8ee76ea4..c69e434893cba 100644 --- a/recipes/cppcommon/all/conandata.yml +++ b/recipes/cppcommon/all/conandata.yml @@ -5,15 +5,39 @@ sources: "cci.20201104": url: "https://github.com/chronoxor/CppCommon/archive/cacfa9554d367467808663d9d5a695933ae566bb.tar.gz" sha256: "d2e717798e1668c831ee977763eaff7413ef48e6e0914a6322c9918016092048" + "1.0.1.0": + url: "https://github.com/chronoxor/CppCommon/archive/1.0.1.0.tar.gz" + sha256: "974ac65c72bb57bc6cbe825990e595fd40ead8c1e66e00c1206b19f749697878" + "1.0.2.0": + url: "https://github.com/chronoxor/CppCommon/archive/1.0.2.0.tar.gz" + sha256: "1a748159ab5d0eb74a6c7b110606718caa779cdf17b3e91bf0dbd0e297823dec" + "1.0.3.0": + url: "https://github.com/chronoxor/CppCommon/archive/1.0.3.0.tar.gz" + sha256: "af530d3550a050d4ed73a680b016e043ea6f4f56e11163226f2a6e24d9eae4ca" patches: "1.0.0.0": - - patch_file: "patches/00001-update-cmakelists.patch" + - patch_file: "patches/0001-update-cmakelists-1-0-0-0.patch" base_path: "source_subfolder" - - patch_file: "patches/00002-fix-cross-platform-issues.patch" + - patch_file: "patches/0002-fix-cross-platform-issues.patch" base_path: "source_subfolder" "cci.20201104": - - patch_file: "patches/00001-update-cmakelists.patch" + - patch_file: "patches/0001-update-cmakelists-1-0-0-0.patch" base_path: "source_subfolder" - - patch_file: "patches/00003-define-win32-winnt.patch" + - patch_file: "patches/0003-define-win32-winnt-cci-20201104.patch" + base_path: "source_subfolder" + "1.0.1.0": + - patch_file: "patches/0001-update-cmakelists-1-0-1-0.patch" + base_path: "source_subfolder" + - patch_file: "patches/0003-define-win32-winnt-1-0-1-0.patch" + base_path: "source_subfolder" + "1.0.2.0": + - patch_file: "patches/0001-update-cmakelists-1-0-1-0.patch" + base_path: "source_subfolder" + - patch_file: "patches/0003-define-win32-winnt-1-0-1-0.patch" + base_path: "source_subfolder" + "1.0.3.0": + - patch_file: "patches/0001-update-cmakelists-1-0-3-0.patch" + base_path: "source_subfolder" + - patch_file: "patches/0003-define-win32-winnt-1-0-1-0.patch" base_path: "source_subfolder" diff --git a/recipes/cppcommon/all/conanfile.py b/recipes/cppcommon/all/conanfile.py index 9a7dfdb64411a..aa3040d536ba0 100644 --- a/recipes/cppcommon/all/conanfile.py +++ b/recipes/cppcommon/all/conanfile.py @@ -60,7 +60,7 @@ def configure(self): self.output.warn("cppcommon requires C++17. Your compiler is unknown. Assuming it supports C++17.") def requirements(self): - self.requires("fmt/7.1.2") + self.requires("fmt/8.0.0") if self.settings.os == "Linux": self.requires("libuuid/1.0.3") diff --git a/recipes/cppcommon/all/patches/00001-update-cmakelists.patch b/recipes/cppcommon/all/patches/0001-update-cmakelists-1-0-0-0.patch similarity index 100% rename from recipes/cppcommon/all/patches/00001-update-cmakelists.patch rename to recipes/cppcommon/all/patches/0001-update-cmakelists-1-0-0-0.patch diff --git a/recipes/cppcommon/all/patches/0001-update-cmakelists-1-0-1-0.patch b/recipes/cppcommon/all/patches/0001-update-cmakelists-1-0-1-0.patch new file mode 100644 index 0000000000000..c7b2d0bf5679b --- /dev/null +++ b/recipes/cppcommon/all/patches/0001-update-cmakelists-1-0-1-0.patch @@ -0,0 +1,139 @@ +From 85122652b618951f1b8fe91d8804d92a74d971be Mon Sep 17 00:00:00 2001 +From: Alejandro Colomar +Date: Mon, 7 Jun 2021 10:27:46 +0200 +Subject: [PATCH] update cmakelists + +--- + CMakeLists.txt | 42 +++++++++++++++++++----------------------- + 1 file changed, 19 insertions(+), 23 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index aa5447a8..10a0065b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -17,49 +17,36 @@ if(DOXYGEN_FOUND) + endif() + endif() + +-# CMake module path +-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +- +-# Compiler features +-include(SetCompilerFeatures) +-include(SetCompilerWarnings) +-include(SetPlatformFeatures) +-include(SystemInformation) +- + # External packages + find_package(Threads REQUIRED) + if(UNIX AND NOT APPLE AND NOT MSYS) + find_package(LibBFD) + find_package(LibDL) + find_package(LibRT) +- find_package(LibUUID) ++ find_package(libuuid) + endif() + if(WIN32 OR MSYS) + find_package(DbgHelp) + find_package(RPC) +- find_package(Userenv) + endif() + +-# Modules +-add_subdirectory("modules") +- + # Link libraries + list(APPEND LINKLIBS Threads::Threads) + if(UNIX AND NOT APPLE AND NOT MSYS) + list(APPEND LINKLIBS ${LIBBFD_LIBRARIES}) + list(APPEND LINKLIBS ${LIBDL_LIBRARIES}) + list(APPEND LINKLIBS ${LIBRT_LIBRARIES}) +- list(APPEND LINKLIBS ${LIBUUID_LIBRARIES}) ++ list(APPEND LINKLIBS CONAN_PKG::libuuid) + endif() + if(WIN32 OR MSYS) + list(APPEND LINKLIBS ${DBGHELP_LIBRARIES}) + list(APPEND LINKLIBS ${RPC_LIBRARIES}) +- list(APPEND LINKLIBS ${USERENV_LIBRARIES}) ++ list(APPEND LINKLIBS userenv) ++ list(APPEND LINKLIBS rpcrt4) + list(APPEND LINKLIBS ${LIBVLD_LIBRARIES}) + endif() + + # System directories +-include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/modules") + include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/plugins") + + # Library +@@ -68,8 +55,9 @@ file(GLOB_RECURSE LIB_INLINE_FILES "include/*.inl" "source/*.inl") + file(GLOB_RECURSE LIB_SOURCE_FILES "include/*.cpp" "source/*.cpp") + add_library(cppcommon ${LIB_HEADER_FILES} ${LIB_INLINE_FILES} ${LIB_SOURCE_FILES}) + set_target_properties(cppcommon PROPERTIES COMPILE_FLAGS "${PEDANTIC_COMPILE_FLAGS}" FOLDER "libraries") +-target_include_directories(cppcommon PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" PUBLIC ${vld}) +-target_link_libraries(cppcommon ${LINKLIBS} fmt) ++target_include_directories(cppcommon PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") ++target_compile_features(cppcommon PUBLIC cxx_std_17) ++target_link_libraries(cppcommon PUBLIC ${LINKLIBS} CONAN_PKG::fmt) + list(APPEND INSTALL_TARGETS cppcommon) + list(APPEND LINKLIBS cppcommon) + +@@ -92,6 +80,7 @@ if(NOT CPPCOMMON_MODULE) + endforeach() + + # Examples ++ if(FALSE) + file(GLOB EXAMPLE_HEADER_FILES "examples/*.h") + file(GLOB EXAMPLE_INLINE_FILES "examples/*.inl") + file(GLOB EXAMPLE_SOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/examples" "examples/*.cpp") +@@ -105,8 +94,10 @@ if(NOT CPPCOMMON_MODULE) + list(APPEND INSTALL_TARGETS ${EXAMPLE_TARGET}) + list(APPEND INSTALL_TARGETS_PDB ${EXAMPLE_TARGET}) + endforeach() ++ endif() + + # Benchmarks ++ if(FALSE) + file(GLOB BENCHMARK_HEADER_FILES "performance/*.h") + file(GLOB BENCHMARK_INLINE_FILES "performance/*.inl") + file(GLOB BENCHMARK_SOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/performance" "performance/*.cpp") +@@ -120,8 +111,10 @@ if(NOT CPPCOMMON_MODULE) + list(APPEND INSTALL_TARGETS ${BENCHMARK_TARGET}) + list(APPEND INSTALL_TARGETS_PDB ${BENCHMARK_TARGET}) + endforeach() ++ endif() + + # Tests ++ if(FALSE) + file(GLOB TESTS_HEADER_FILES "tests/*.h") + file(GLOB TESTS_INLINE_FILES "tests/*.inl") + file(GLOB TESTS_SOURCE_FILES "tests/*.cpp") +@@ -132,19 +125,22 @@ if(NOT CPPCOMMON_MODULE) + target_link_libraries(cppcommon-tests ${LINKLIBS}) + list(APPEND INSTALL_TARGETS cppcommon-tests) + list(APPEND INSTALL_TARGETS_PDB cppcommon-tests) ++ endif() + + # CTest ++ if(FALSE) + enable_testing() + add_test(cppcommon-tests cppcommon-tests --durations yes --order lex) ++ endif() + + # Install + install(TARGETS ${INSTALL_TARGETS} +- RUNTIME DESTINATION "${PROJECT_SOURCE_DIR}/bin" +- LIBRARY DESTINATION "${PROJECT_SOURCE_DIR}/bin" +- ARCHIVE DESTINATION "${PROJECT_SOURCE_DIR}/bin") ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib) + + # Install *.pdb files +- if(MSVC) ++ if(FALSE) + foreach(INSTALL_TARGET_PDB ${INSTALL_TARGETS_PDB}) + install(FILES $ DESTINATION "${PROJECT_SOURCE_DIR}/bin") + endforeach() +-- +2.31.1.498.g6c1eba8ee3d + diff --git a/recipes/cppcommon/all/patches/0001-update-cmakelists-1-0-3-0.patch b/recipes/cppcommon/all/patches/0001-update-cmakelists-1-0-3-0.patch new file mode 100644 index 0000000000000..83cb81ebe9a49 --- /dev/null +++ b/recipes/cppcommon/all/patches/0001-update-cmakelists-1-0-3-0.patch @@ -0,0 +1,133 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index aa5447a8..10a0065b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.20) ++cmake_minimum_required(VERSION 3.18.2) + + # Global properties + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +@@ -17,49 +17,36 @@ if(DOXYGEN_FOUND) + endif() + endif() + +-# CMake module path +-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +- +-# Compiler features +-include(SetCompilerFeatures) +-include(SetCompilerWarnings) +-include(SetPlatformFeatures) +-include(SystemInformation) +- + # External packages + find_package(Threads REQUIRED) + if(UNIX AND NOT APPLE AND NOT MSYS) + find_package(LibBFD) + find_package(LibDL) + find_package(LibRT) +- find_package(LibUUID) ++ find_package(libuuid) + endif() + if(WIN32 OR MSYS) + find_package(DbgHelp) + find_package(RPC) +- find_package(Userenv) + endif() + +-# Modules +-add_subdirectory("modules") +- + # Link libraries + list(APPEND LINKLIBS Threads::Threads) + if(UNIX AND NOT APPLE AND NOT MSYS) + list(APPEND LINKLIBS ${LIBBFD_LIBRARIES}) + list(APPEND LINKLIBS ${LIBDL_LIBRARIES}) + list(APPEND LINKLIBS ${LIBRT_LIBRARIES}) +- list(APPEND LINKLIBS ${LIBUUID_LIBRARIES}) ++ list(APPEND LINKLIBS CONAN_PKG::libuuid) + endif() + if(WIN32 OR MSYS) + list(APPEND LINKLIBS ${DBGHELP_LIBRARIES}) + list(APPEND LINKLIBS ${RPC_LIBRARIES}) +- list(APPEND LINKLIBS ${USERENV_LIBRARIES}) ++ list(APPEND LINKLIBS userenv) ++ list(APPEND LINKLIBS rpcrt4) + list(APPEND LINKLIBS ${VLD_LIBRARIES}) + endif() + + # System directories +-include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/modules") + include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/plugins") + + # Library +@@ -68,8 +55,9 @@ file(GLOB_RECURSE LIB_INLINE_FILES "include/*.inl" "source/*.inl") + file(GLOB_RECURSE LIB_SOURCE_FILES "include/*.cpp" "source/*.cpp") + add_library(cppcommon ${LIB_HEADER_FILES} ${LIB_INLINE_FILES} ${LIB_SOURCE_FILES}) + set_target_properties(cppcommon PROPERTIES COMPILE_FLAGS "${PEDANTIC_COMPILE_FLAGS}" FOLDER "libraries") +-target_include_directories(cppcommon PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" PUBLIC ${vld}) +-target_link_libraries(cppcommon ${LINKLIBS} fmt) ++target_include_directories(cppcommon PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") ++target_compile_features(cppcommon PUBLIC cxx_std_17) ++target_link_libraries(cppcommon PUBLIC ${LINKLIBS} CONAN_PKG::fmt) + list(APPEND INSTALL_TARGETS cppcommon) + list(APPEND LINKLIBS cppcommon) + +@@ -92,6 +80,7 @@ if(NOT CPPCOMMON_MODULE) + endforeach() + + # Examples ++ if(FALSE) + file(GLOB EXAMPLE_HEADER_FILES "examples/*.h") + file(GLOB EXAMPLE_INLINE_FILES "examples/*.inl") + file(GLOB EXAMPLE_SOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/examples" "examples/*.cpp") +@@ -105,8 +94,10 @@ if(NOT CPPCOMMON_MODULE) + list(APPEND INSTALL_TARGETS ${EXAMPLE_TARGET}) + list(APPEND INSTALL_TARGETS_PDB ${EXAMPLE_TARGET}) + endforeach() ++ endif() + + # Benchmarks ++ if(FALSE) + file(GLOB BENCHMARK_HEADER_FILES "performance/*.h") + file(GLOB BENCHMARK_INLINE_FILES "performance/*.inl") + file(GLOB BENCHMARK_SOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/performance" "performance/*.cpp") +@@ -120,8 +111,10 @@ if(NOT CPPCOMMON_MODULE) + list(APPEND INSTALL_TARGETS ${BENCHMARK_TARGET}) + list(APPEND INSTALL_TARGETS_PDB ${BENCHMARK_TARGET}) + endforeach() ++ endif() + + # Tests ++ if(FALSE) + file(GLOB TESTS_HEADER_FILES "tests/*.h") + file(GLOB TESTS_INLINE_FILES "tests/*.inl") + file(GLOB TESTS_SOURCE_FILES "tests/*.cpp") +@@ -132,19 +125,22 @@ if(NOT CPPCOMMON_MODULE) + target_link_libraries(cppcommon-tests ${LINKLIBS}) + list(APPEND INSTALL_TARGETS cppcommon-tests) + list(APPEND INSTALL_TARGETS_PDB cppcommon-tests) ++ endif() + + # CTest ++ if(FALSE) + enable_testing() + add_test(cppcommon-tests cppcommon-tests --durations yes --order lex) ++ endif() + + # Install + install(TARGETS ${INSTALL_TARGETS} +- RUNTIME DESTINATION "${PROJECT_SOURCE_DIR}/bin" +- LIBRARY DESTINATION "${PROJECT_SOURCE_DIR}/bin" +- ARCHIVE DESTINATION "${PROJECT_SOURCE_DIR}/bin") ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib) + + # Install *.pdb files +- if(MSVC) ++ if(FALSE) + foreach(INSTALL_TARGET_PDB ${INSTALL_TARGETS_PDB}) + install(FILES $ DESTINATION "${PROJECT_SOURCE_DIR}/bin") + endforeach() diff --git a/recipes/cppcommon/all/patches/00002-fix-cross-platform-issues.patch b/recipes/cppcommon/all/patches/0002-fix-cross-platform-issues.patch similarity index 100% rename from recipes/cppcommon/all/patches/00002-fix-cross-platform-issues.patch rename to recipes/cppcommon/all/patches/0002-fix-cross-platform-issues.patch diff --git a/recipes/cppcommon/all/patches/0003-define-win32-winnt-1-0-1-0.patch b/recipes/cppcommon/all/patches/0003-define-win32-winnt-1-0-1-0.patch new file mode 100644 index 0000000000000..3b9099c8f0c45 --- /dev/null +++ b/recipes/cppcommon/all/patches/0003-define-win32-winnt-1-0-1-0.patch @@ -0,0 +1,33 @@ +From 80370771e98dc4558811a3846cb567d13ad7d636 Mon Sep 17 00:00:00 2001 +From: Alejandro Colomar +Date: Mon, 7 Jun 2021 10:40:58 +0200 +Subject: [PATCH] define win32 winnt + +The change present here is handled upstream by this CMake module: + +https://github.com/chronoxor/CppCMakeScripts/blob/1.0.0.0/SetPlatformFeatures.cmake + +Even if it sets _WIN32_WINNT to _WIN32_WINNT_WIN10, here a less strict +definiton is chosen (_WIN32_WINNT_VISTA). +--- + CMakeLists.txt | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 10a0065b..2ed1668c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -61,6 +61,10 @@ target_link_libraries(cppcommon PUBLIC ${LINKLIBS} CONAN_PKG::fmt) + list(APPEND INSTALL_TARGETS cppcommon) + list(APPEND LINKLIBS cppcommon) + ++if(WIN32 AND NOT MSVC) ++ target_compile_definitions(cppcommon PUBLIC -D_WIN32_WINNT=_WIN32_WINNT_VISTA) ++endif() ++ + # Additional module components: benchmarks, examples, plugins, tests, tools and install + if(NOT CPPCOMMON_MODULE) + +-- +2.31.1.498.g6c1eba8ee3d + diff --git a/recipes/cppcommon/all/patches/00003-define-win32-winnt.patch b/recipes/cppcommon/all/patches/0003-define-win32-winnt-cci-20201104.patch similarity index 100% rename from recipes/cppcommon/all/patches/00003-define-win32-winnt.patch rename to recipes/cppcommon/all/patches/0003-define-win32-winnt-cci-20201104.patch diff --git a/recipes/cppcommon/config.yml b/recipes/cppcommon/config.yml index 082768aa4dd38..17d2cd502269e 100644 --- a/recipes/cppcommon/config.yml +++ b/recipes/cppcommon/config.yml @@ -3,3 +3,9 @@ versions: folder: all "cci.20201104": folder: all + "1.0.1.0": + folder: all + "1.0.2.0": + folder: all + "1.0.3.0": + folder: all diff --git a/recipes/cppfront/all/CMakeLists.txt b/recipes/cppfront/all/CMakeLists.txt new file mode 100644 index 0000000000000..3a5c515464abd --- /dev/null +++ b/recipes/cppfront/all/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(cppfront CXX) + +add_executable(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/source/cppfront.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) + +install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) + diff --git a/recipes/cppfront/all/conandata.yml b/recipes/cppfront/all/conandata.yml new file mode 100644 index 0000000000000..9256a02f34f3a --- /dev/null +++ b/recipes/cppfront/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "cci.20221024": + url: "https://github.com/hsutter/cppfront/archive/b1754dbd53a496a9104b43ecde6064c9980246bd.zip" + sha256: "8668bddbd7fc06d4975c867521c005f898eca8f83f018e7c28b54dbcf9aa3ab9" + "cci.20220924": + url: "https://github.com/hsutter/cppfront/archive/98f6dd46957e100f813245241f183c8aedbcb36f.zip" + sha256: "db51c1ac634d45c6047c7eec5c29993ff215443edadf334370f53d09a11cc5b1" diff --git a/recipes/cppfront/all/conanfile.py b/recipes/cppfront/all/conanfile.py new file mode 100644 index 0000000000000..92fa383ff535f --- /dev/null +++ b/recipes/cppfront/all/conanfile.py @@ -0,0 +1,100 @@ +from conan import ConanFile + +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.microsoft import check_min_vs, is_msvc + +import os + +required_conan_version = ">=1.47.0" + +class CppfrontConan(ConanFile): + name = "cppfront" + description = "Cppfront is a experimental compiler from a potential C++ 'syntax 2' (Cpp2) to today's 'syntax 1' (Cpp1)" + topics = ("cpp2") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/hsutter/cppfront" + license = "CC-BY-NC-ND-4.0" + settings = "os", "arch", "compiler", "build_type" + + @property + def _minimum_cpp_standard(self): + return 20 + + @property + def _compilers_minimum_version(self): + return {"gcc": "11", + "Visual Studio": "16.9", + "clang": "12", + "apple-clang": "13", + } + + def layout(self): + cmake_layout(self, src_folder="src") + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, os.path.join(self.export_sources_folder, "src")) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + + def _lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + check_min_vs(self, "192.9") + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if not minimum_version: + self.output.warn(f"{self.name} {self.version} requires C++20. Your compiler is unknown. Assuming it supports C++20.") + elif _lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration(f"{self.name} {self.version} requires C++20, which your compiler does not support.") + if self.info.settings.compiler == "clang" and str(self.info.settings.compiler.version) in ("13", "14"): + raise ConanInvalidConfiguration(f"{self.ref} currently does not work with Clang {self.info.settings.compiler.version} on CCI, it enters in an infinite build loop (smells like a compiler bug). Contributions are welcomed!") + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "cppfront*", src=self.source_folder, dst=os.path.join(self.package_folder, "bin")) + copy(self, pattern="*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + cmake = CMake(self) + cmake.install() + + @staticmethod + def _chmod_plus_x(filename): + if os.name == "posix": + os.chmod(filename, os.stat(filename).st_mode | 0o111) + + def package_info(self): + bin_path = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH environment variable: {bin_path}") + self.env_info.PATH.append(bin_path) + + bin_ext = ".exe" if self.settings.os == "Windows" else "" + cppfront_bin = os.path.join(self.package_folder, "bin", "cppfront{}".format(bin_ext)).replace("\\", "/") + + self.output.info("Setting CppFront environment variable: {}".format(cppfront_bin)) + self.env_info.cppfront = cppfront_bin + + self.cpp_info.frameworkdirs = [] + self.cpp_info.includedirs = [os.path.join(self.package_folder, "include")] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + diff --git a/recipes/cppfront/all/test_package/conanfile.py b/recipes/cppfront/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1999bacfd39a7 --- /dev/null +++ b/recipes/cppfront/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.files import copy +from conan.tools.build import can_run +from conan.tools.layout import basic_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def layout(self): + basic_layout(self) + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def build(self): + if can_run(self): + copy(self, "pure2-hello.cpp2", src=self.recipe_folder, dst=self.build_folder) + self.run("cppfront {}".format(os.path.join(self.build_folder, "pure2-hello.cpp2")), env="conanbuild") + + def test(self): + if can_run(self): + self.run("cppfront -h", env="conanbuild") + assert os.path.isfile(os.path.join(self.build_folder, "pure2-hello.cpp")) diff --git a/recipes/cppfront/all/test_package/pure2-hello.cpp2 b/recipes/cppfront/all/test_package/pure2-hello.cpp2 new file mode 100644 index 0000000000000..338735841ca79 --- /dev/null +++ b/recipes/cppfront/all/test_package/pure2-hello.cpp2 @@ -0,0 +1,13 @@ +main: () -> int = { + std::cout << "Hello " << name() << "\n"; +} + +name: () -> std::string = { + s: std::string = "world"; + decorate(s); + return s; +} + +decorate: (inout s: std::string) = { + s = "[" + s + "]"; +} \ No newline at end of file diff --git a/recipes/cppfront/all/test_v1_package/conanfile.py b/recipes/cppfront/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..962a3b9a9704c --- /dev/null +++ b/recipes/cppfront/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, tools +import os +import shutil + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + @property + def _cppfront_input_path(self): + return os.path.join(self.build_folder, "pure2-hello.cpp2") + + def build(self): + if not tools.cross_building(self): + shutil.copy2(src=os.path.join(self.source_folder, "..", "test_package", "pure2-hello.cpp2"), dst=os.path.join(self.build_folder, "pure2-hello.cpp2")) + self.run("cppfront {}".format(os.path.join(self.build_folder, "pure2-hello.cpp2")), run_environment=True) + + def test(self): + if not tools.cross_building(self): + self.run("cppfront -h", run_environment=True) + assert os.path.isfile(os.path.join(self.build_folder, "pure2-hello.cpp")) diff --git a/recipes/cppfront/config.yml b/recipes/cppfront/config.yml new file mode 100644 index 0000000000000..58e5c15a9b457 --- /dev/null +++ b/recipes/cppfront/config.yml @@ -0,0 +1,5 @@ +versions: + "cci.20221024": + folder: all + "cci.20220924": + folder: all diff --git a/recipes/cppitertools/all/conanfile.py b/recipes/cppitertools/all/conanfile.py index 39e86eda7c6f1..585bcc850ce23 100644 --- a/recipes/cppitertools/all/conanfile.py +++ b/recipes/cppitertools/all/conanfile.py @@ -41,7 +41,7 @@ def validate(self): compiler_version = tools.Version(self.settings.compiler.version) if compiler not in minimal_version: - self.output.info("{} requires a compiler that supports at least C++17".format(self.name, min)) + self.output.info("{} requires a compiler that supports at least C++17".format(self.name)) return # Exclude compilers not supported by cppitertools diff --git a/recipes/cppitertools/all/test_package/test_package.cpp b/recipes/cppitertools/all/test_package/test_package.cpp index 52c5e8148e898..b18a4af82cb6b 100644 --- a/recipes/cppitertools/all/test_package/test_package.cpp +++ b/recipes/cppitertools/all/test_package/test_package.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace { @@ -12,7 +13,7 @@ int main() { const std::vector vec = {"hi", "ab", "ho", "abc", "def", "abcde", "efghi"}; std::vector keys; std::vector> groups; - + for (auto&& gb : iter::groupby(vec, length)) { keys.push_back(gb.first); groups.emplace_back(std::begin(gb.second), std::end(gb.second)); diff --git a/recipes/cppkafka/all/conandata.yml b/recipes/cppkafka/all/conandata.yml new file mode 100644 index 0000000000000..741ef5502bb96 --- /dev/null +++ b/recipes/cppkafka/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "0.4.0": + url: "https://github.com/mfontanini/cppkafka/archive/refs/tags/0.4.0.tar.gz" + sha256: "f4f05eb7a180a856663b02ec0b777283275ef88e5523f3013fd51c6c4ab63b5a" +patches: + "0.4.0": + - patch_file: "patches/0001-no-template-export.patch" + - patch_file: "patches/0002-cppstd.patch" + - patch_file: "patches/0003-clean-rpath.patch" diff --git a/recipes/cppkafka/all/conanfile.py b/recipes/cppkafka/all/conanfile.py new file mode 100644 index 0000000000000..bc32e36950898 --- /dev/null +++ b/recipes/cppkafka/all/conanfile.py @@ -0,0 +1,102 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +import os + +required_conan_version = ">=1.50.0" + + +class CppKafkaConan(ConanFile): + name = "cppkafka" + description = "Modern C++ Apache Kafka client library (wrapper for librdkafka)" + topics = ("librdkafka", "kafka") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/mfontanini/cppkafka" + license = "MIT" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("boost/1.79.0") + self.requires("librdkafka/1.9.2") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CPPKAFKA_BUILD_SHARED"] = self.options.shared + tc.variables["CPPKAFKA_DISABLE_TESTS"] = True + tc.variables["CPPKAFKA_DISABLE_EXAMPLES"] = True + tc.variables["CPPKAFKA_RDKAFKA_STATIC_LIB"] = False # underlying logic is useless + if self.settings.os == "Windows": + tc.preprocessor_definitions["NOMINMAX"] = 1 + tc.generate() + cd = CMakeDeps(self) + cd.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "CppKafka") + self.cpp_info.set_property("cmake_target_name", "CppKafka::cppkafka") + self.cpp_info.set_property("pkg_config_name", "cppkafka") + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["_cppkafka"].libs = ["cppkafka"] + self.cpp_info.components["_cppkafka"].requires = ["boost::headers", "librdkafka::librdkafka"] + if self.settings.os == "Windows": + if not self.options.shared: + self.cpp_info.components["_cppkafka"].system_libs = ["mswsock", "ws2_32"] + elif self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["_cppkafka"].system_libs = ["pthread"] + if not self.options.shared: + self.cpp_info.components["_cppkafka"].defines.append("CPPKAFKA_STATIC") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "CppKafka" + self.cpp_info.names["cmake_find_package_multi"] = "CppKafka" + self.cpp_info.components["_cppkafka"].names["cmake_find_package"] = "cppkafka" + self.cpp_info.components["_cppkafka"].names["cmake_find_package_multi"] = "cppkafka" + self.cpp_info.components["_cppkafka"].set_property("cmake_target_name", "CppKafka::cppkafka") + self.cpp_info.components["_cppkafka"].set_property("pkg_config_name", "cppkafka") diff --git a/recipes/cppkafka/all/patches/0001-no-template-export.patch b/recipes/cppkafka/all/patches/0001-no-template-export.patch new file mode 100644 index 0000000000000..8c84c53443710 --- /dev/null +++ b/recipes/cppkafka/all/patches/0001-no-template-export.patch @@ -0,0 +1,45 @@ +Exporting a template is non-sense (it only makes sense for an explicit instantiation), and msvc will complain. +see https://github.com/mfontanini/cppkafka/issues/206 + +--- a/include/cppkafka/utils/buffered_producer.h ++++ b/include/cppkafka/utils/buffered_producer.h +@@ -84,7 +84,7 @@ namespace cppkafka { + */ + template >> +-class CPPKAFKA_API BufferedProducer { ++class BufferedProducer { + public: + enum class FlushMethod { + Sync, ///< Empty the buffer and wait for acks from the broker. +--- a/include/cppkafka/utils/compacted_topic_processor.h ++++ b/include/cppkafka/utils/compacted_topic_processor.h +@@ -44,7 +44,7 @@ namespace cppkafka { + * \brief Events generated by a CompactedTopicProcessor + */ + template +-class CPPKAFKA_API CompactedTopicEvent { ++class CompactedTopicEvent { + public: + /** + * \brief Event type enum +@@ -111,7 +111,7 @@ private: + }; + + template +-class CPPKAFKA_API CompactedTopicProcessor { ++class CompactedTopicProcessor { + public: + /** + * The type of events generated by this processor +--- a/include/cppkafka/utils/consumer_dispatcher.h ++++ b/include/cppkafka/utils/consumer_dispatcher.h +@@ -70,7 +70,7 @@ namespace cppkafka { + * * EOF: void(BasicConsumerDispatcher::EndOfFile, TopicPartition) + */ + template +-class CPPKAFKA_API BasicConsumerDispatcher { ++class BasicConsumerDispatcher { + public: + /** + * Tag to indicate a timeout occurred diff --git a/recipes/cppkafka/all/patches/0002-cppstd.patch b/recipes/cppkafka/all/patches/0002-cppstd.patch new file mode 100644 index 0000000000000..778cdc867d5ec --- /dev/null +++ b/recipes/cppkafka/all/patches/0002-cppstd.patch @@ -0,0 +1,20 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -28,7 +28,6 @@ if (NOT CMAKE_CXX_FLAGS) + add_definitions("-DNOGDI=1") + add_definitions("-DNOMINMAX=1") + else() +- set(CMAKE_CXX_FLAGS "-std=c++11 -Wall") + endif() + endif() + +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -36,6 +36,7 @@ set(NAMESPACE "${PROJECT_NAME}::") + set(TARGET_EXPORT_NAME ${PROJECT_NAME}Targets) + + add_library(${TARGET_NAME} ${CPPKAFKA_LIBRARY_TYPE} ${SOURCES}) ++target_compile_features(${TARGET_NAME} PUBLIC cxx_std_11) + target_include_directories(${TARGET_NAME} PUBLIC $) + set_target_properties(${TARGET_NAME} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}" diff --git a/recipes/cppkafka/all/patches/0003-clean-rpath.patch b/recipes/cppkafka/all/patches/0003-clean-rpath.patch new file mode 100644 index 0000000000000..917faa692f549 --- /dev/null +++ b/recipes/cppkafka/all/patches/0003-clean-rpath.patch @@ -0,0 +1,11 @@ +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -43,8 +43,6 @@ set_target_properties(${TARGET_NAME} PROPERTIES + ARCHIVE_OUTPUT_NAME "${TARGET_NAME}" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}" + LIBRARY_OUTPUT_NAME "${TARGET_NAME}" +- INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}" +- INSTALL_RPATH_USE_LINK_PATH TRUE + VERSION ${CPPKAFKA_VERSION} + SOVERSION ${CPPKAFKA_VERSION}) + # In CMake >= 3.15 Boost::boost == Boost::headers diff --git a/recipes/cppkafka/all/test_package/CMakeLists.txt b/recipes/cppkafka/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..cceda19c2c398 --- /dev/null +++ b/recipes/cppkafka/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(CppKafka REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE CppKafka::cppkafka) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cppkafka/all/test_package/conanfile.py b/recipes/cppkafka/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/cppkafka/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cppkafka/all/test_package/test_package.cpp b/recipes/cppkafka/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..37e5ad0e461f6 --- /dev/null +++ b/recipes/cppkafka/all/test_package/test_package.cpp @@ -0,0 +1,29 @@ +#include "cppkafka/cppkafka.h" +#include +#include + +using namespace cppkafka; + +int main() { + try { + // Create the config + Configuration kafkaConfig = { + {"metadata.broker.list", "127.0.0.1:9092"}, + {"group.id", "xxx"}, + {"auto.offset.reset", "earliest"}, + {"enable.auto.commit", false} + }; + + // Create the producer + Producer producer(kafkaConfig); + + // Produce a message! + std::string message = "hey there!"; + producer.produce(MessageBuilder("my_topic").partition(0).payload(message)); + producer.flush(); + } catch (std::exception& e) { + std::cout << e.what() << std::endl; + } + + return 0; +} diff --git a/recipes/cppkafka/all/test_v1_package/CMakeLists.txt b/recipes/cppkafka/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a83b16bfd9b93 --- /dev/null +++ b/recipes/cppkafka/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CppKafka REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE CppKafka::cppkafka) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cppkafka/all/test_v1_package/conanfile.py b/recipes/cppkafka/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a500b98343c74 --- /dev/null +++ b/recipes/cppkafka/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cppkafka/config.yml b/recipes/cppkafka/config.yml new file mode 100644 index 0000000000000..da269653d6e6b --- /dev/null +++ b/recipes/cppkafka/config.yml @@ -0,0 +1,3 @@ +versions: + "0.4.0": + folder: "all" diff --git a/recipes/cpprestsdk/all/conandata.yml b/recipes/cpprestsdk/all/conandata.yml index aac669c6455d4..5216074c76f9d 100644 --- a/recipes/cpprestsdk/all/conandata.yml +++ b/recipes/cpprestsdk/all/conandata.yml @@ -1,34 +1,42 @@ sources: - "2.10.15": - url: https://github.com/Microsoft/cpprestsdk/archive/v2.10.15.tar.gz - sha256: 1c027a53457e87b0b3a475e5c8045b94400c475898c8bd51b0fbd218b99a7f7b - "2.10.16": - url: https://github.com/Microsoft/cpprestsdk/archive/v2.10.16.tar.gz - sha256: 3d75e17c7d79131320438f2a15331f7ca6281c38c0e2daa27f051e290eeb8681 - "2.10.17": - url: https://github.com/Microsoft/cpprestsdk/archive/2.10.17.tar.gz - sha256: a2d9dae3ae10cdf7e41caf3dd0fa52f0b9c5012a24ba123901f686cfc484c043 "2.10.18": - url: https://github.com/Microsoft/cpprestsdk/archive/2.10.18.tar.gz - sha256: 6bd74a637ff182144b6a4271227ea8b6b3ea92389f88b25b215e6f94fd4d41cb -patches: - "2.10.15": - - patch_file: "patches/0001-find-cmake-targets.patch" - base_path: "source_subfolder" - - patch_file: "patches/0002-remove-wconversion.patch" - base_path: "source_subfolder" + url: "https://github.com/Microsoft/cpprestsdk/archive/2.10.18.tar.gz" + sha256: "6bd74a637ff182144b6a4271227ea8b6b3ea92389f88b25b215e6f94fd4d41cb" + "2.10.17": + url: "https://github.com/Microsoft/cpprestsdk/archive/2.10.17.tar.gz" + sha256: "a2d9dae3ae10cdf7e41caf3dd0fa52f0b9c5012a24ba123901f686cfc484c043" "2.10.16": + url: "https://github.com/Microsoft/cpprestsdk/archive/v2.10.16.tar.gz" + sha256: "3d75e17c7d79131320438f2a15331f7ca6281c38c0e2daa27f051e290eeb8681" + "2.10.15": + url: "https://github.com/Microsoft/cpprestsdk/archive/v2.10.15.tar.gz" + sha256: "1c027a53457e87b0b3a475e5c8045b94400c475898c8bd51b0fbd218b99a7f7b" +patches: + "2.10.18": - patch_file: "patches/0003-find-cmake-targets.patch" - base_path: "source_subfolder" + patch_type: "conan" + patch_description: "CMake: internal targets" - patch_file: "patches/0002-remove-wconversion.patch" - base_path: "source_subfolder" + patch_type: "conan" + patch_description: "fix warnings" "2.10.17": - patch_file: "patches/0003-find-cmake-targets.patch" - base_path: "source_subfolder" + patch_type: "conan" + patch_description: "CMake: internal targets" - patch_file: "patches/0002-remove-wconversion.patch" - base_path: "source_subfolder" - "2.10.18": + patch_type: "conan" + patch_description: "fix warnings" + "2.10.16": - patch_file: "patches/0003-find-cmake-targets.patch" - base_path: "source_subfolder" + patch_type: "conan" + patch_description: "CMake: internal targets" + - patch_file: "patches/0002-remove-wconversion.patch" + patch_type: "conan" + patch_description: "fix warnings" + "2.10.15": + - patch_file: "patches/0001-find-cmake-targets.patch" + patch_type: "conan" + patch_description: "CMake: internal targets" - patch_file: "patches/0002-remove-wconversion.patch" - base_path: "source_subfolder" + patch_type: "conan" + patch_description: "fix warnings" diff --git a/recipes/cpprestsdk/all/conanfile.py b/recipes/cpprestsdk/all/conanfile.py index e372ecd9e8438..467c812235f66 100644 --- a/recipes/cpprestsdk/all/conanfile.py +++ b/recipes/cpprestsdk/all/conanfile.py @@ -1,6 +1,10 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools import files +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout import os +required_conan_version = ">=1.53.0" + class CppRestSDKConan(ConanFile): name = "cpprestsdk" @@ -8,10 +12,9 @@ class CppRestSDKConan(ConanFile): "C++ API design" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/Microsoft/cpprestsdk" - topics = ("conan", "cpprestsdk", "rest", "client", "http", "https") + topics = ("cpprestsdk", "rest", "client", "http", "https") license = "MIT" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -20,7 +23,7 @@ class CppRestSDKConan(ConanFile): "with_compression": [True, False], "pplx_impl": ["win", "winpplx"], "http_client_impl": ["winhttp", "asio"], - "http_listener_impl": ["httpsys", "asio"] + "http_listener_impl": ["httpsys", "asio"], } default_options = { "shared": False, @@ -29,18 +32,11 @@ class CppRestSDKConan(ConanFile): "with_compression": True, "pplx_impl": "win", "http_client_impl": "winhttp", - "http_listener_impl": "httpsys" + "http_listener_impl": "httpsys", } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + files.export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -52,69 +48,79 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") def requirements(self): - self.requires("boost/1.75.0") - self.requires("openssl/1.1.1i") + self.requires("boost/1.80.0") + self.requires("openssl/1.1.1s") if self.options.with_compression: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.with_websockets: self.requires("websocketpp/0.8.2") + def package_id(self): + self.info.requires["boost"].minor_mode() + + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - - self._cmake = CMake(self, set_cmake_flags=True) - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["BUILD_SAMPLES"] = False - self._cmake.definitions["WERROR"] = False - self._cmake.definitions["CPPREST_EXCLUDE_WEBSOCKETS"] = not self.options.with_websockets - self._cmake.definitions["CPPREST_EXCLUDE_COMPRESSION"] = not self.options.with_compression + files.get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + # upstream CMakeLists.txt sets BUILD_SHARED_LIBS as a CACHE variable + # TODO: remove if required_conan_version = ">=1.54.0" + tc.variables["BUILD_SHARED_LIBS"] = self.options.shared + tc.variables["BUILD_TESTS"] = False + tc.variables["BUILD_SAMPLES"] = False + tc.variables["WERROR"] = False + tc.variables["CPPREST_EXCLUDE_WEBSOCKETS"] = not self.options.with_websockets + tc.variables["CPPREST_EXCLUDE_COMPRESSION"] = not self.options.with_compression if self.options.get_safe("pplx_impl"): - self._cmake.definitions["CPPREST_PPLX_IMPL"] = self.options.pplx_impl + tc.variables["CPPREST_PPLX_IMPL"] = self.options.pplx_impl if self.options.get_safe("http_client_impl"): - self._cmake.definitions["CPPREST_HTTP_CLIENT_IMPL"] = self.options.http_client_impl + tc.variables["CPPREST_HTTP_CLIENT_IMPL"] = self.options.http_client_impl if self.options.get_safe("http_listener_impl"): - self._cmake.definitions["CPPREST_HTTP_LISTENER_IMPL"] = self.options.http_listener_impl - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + tc.variables["CPPREST_HTTP_LISTENER_IMPL"] = self.options.http_listener_impl + tc.generate() + deps = CMakeDeps(self) + deps.generate() def _patch_clang_libcxx(self): if self.settings.compiler == 'clang' and str(self.settings.compiler.libcxx) in ['libstdc++', 'libstdc++11']: - tools.replace_in_file(os.path.join(self._source_subfolder, 'Release', 'CMakeLists.txt'), + files.replace_in_file(self, os.path.join(self.source_folder, 'Release', 'CMakeLists.txt'), 'libc++', 'libstdc++') def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, {}): - tools.patch(**patch) + files.apply_conandata_patches(self) self._patch_clang_libcxx() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("license.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + files.copy(self, "license.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cpprestsdk")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "cpprestsdk")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "cpprestsdk") + # cpprestsdk_boost_internal + self.cpp_info.components["cpprestsdk_boost_internal"].set_property("cmake_target_name", "cpprestsdk::cpprestsdk_boost_internal") self.cpp_info.components["cpprestsdk_boost_internal"].includedirs = [] self.cpp_info.components["cpprestsdk_boost_internal"].requires = ["boost::boost"] # cpprestsdk_openssl_internal + self.cpp_info.components["cpprestsdk_openssl_internal"].set_property("cmake_target_name", "cpprestsdk::cpprestsdk_openssl_internal") self.cpp_info.components["cpprestsdk_openssl_internal"].includedirs = [] self.cpp_info.components["cpprestsdk_openssl_internal"].requires = ["openssl::openssl"] # cpprest - self.cpp_info.components["cpprest"].libs = tools.collect_libs(self) + self.cpp_info.components["cpprest"].set_property("cmake_target_name", "cpprestsdk::cpprest") + self.cpp_info.components["cpprest"].libs = files.collect_libs(self) self.cpp_info.components["cpprest"].requires = ["cpprestsdk_boost_internal", "cpprestsdk_openssl_internal"] if self.settings.os == "Linux": self.cpp_info.components["cpprest"].system_libs.append("pthread") @@ -133,14 +139,16 @@ def package_info(self): elif self.settings.os == "Macos": self.cpp_info.components["cpprest"].frameworks.extend(["CoreFoundation", "Security"]) if not self.options.shared: - self.cpp_info.components["cpprest"].defines.append("_NO_ASYNCRTIMP") + self.cpp_info.components["cpprest"].defines.extend(["_NO_ASYNCRTIMP", "_NO_PPLXIMP"]) # cpprestsdk_zlib_internal if self.options.with_compression: + self.cpp_info.components["cpprestsdk_zlib_internal"].set_property("cmake_target_name", "cpprestsdk::cpprestsdk_zlib_internal") self.cpp_info.components["cpprestsdk_zlib_internal"].includedirs = [] self.cpp_info.components["cpprestsdk_zlib_internal"].requires = ["zlib::zlib"] self.cpp_info.components["cpprest"].requires.append("cpprestsdk_zlib_internal") # cpprestsdk_websocketpp_internal if self.options.with_websockets: + self.cpp_info.components["cpprestsdk_websocketpp_internal"].set_property("cmake_target_name", "cpprestsdk::cpprestsdk_websocketpp_internal") self.cpp_info.components["cpprestsdk_websocketpp_internal"].includedirs = [] self.cpp_info.components["cpprestsdk_websocketpp_internal"].requires = ["websocketpp::websocketpp"] self.cpp_info.components["cpprest"].requires.append("cpprestsdk_websocketpp_internal") diff --git a/recipes/cpprestsdk/all/patches/0001-find-cmake-targets.patch b/recipes/cpprestsdk/all/patches/0001-find-cmake-targets.patch index c1b4a4342b8bb..6fdbcbfe30dcb 100644 --- a/recipes/cpprestsdk/all/patches/0001-find-cmake-targets.patch +++ b/recipes/cpprestsdk/all/patches/0001-find-cmake-targets.patch @@ -33,11 +33,7 @@ index 0b49a7e..ed5c24b 100644 - "${CMAKE_BINARY_DIR}/../openssl/x86/lib/libcrypto.a" - CACHE INTERNAL "" - ) -+ if(NOT TARGET cpprestsdk_openssl_internal) -+ add_library(cpprestsdk_openssl_internal INTERFACE) -+ target_include_directories(cpprestsdk_openssl_internal INTERFACE "${CONAN_INCLUDE_DIRS_OPENSSL}") -+ target_link_libraries(cpprestsdk_openssl_internal INTERFACE "${CONAN_LIBS_OPENSSL}") - endif() +- endif() - set(_SSL_LEAK_SUPPRESS_AVAILABLE ON CACHE INTERNAL "") - else() - if(APPLE) @@ -76,13 +72,17 @@ index 0b49a7e..ed5c24b 100644 - # libressl doesn't ship with the cleanup method being used in ws_client_wspp - target_compile_definitions(cpprestsdk_openssl_internal INTERFACE -DCPPREST_NO_SSL_LEAK_SUPPRESS) - endif() ++ if(NOT TARGET cpprestsdk_openssl_internal) ++ add_library(cpprestsdk_openssl_internal INTERFACE) ++ find_package(OpenSSL REQUIRED) ++ target_link_libraries(cpprestsdk_openssl_internal INTERFACE "OpenSSL::SSL") ++ endif() endfunction() -\ No newline at end of file diff --git a/Release/cmake/cpprest_find_websocketpp.cmake b/Release/cmake/cpprest_find_websocketpp.cmake index 94ea81a..f83a777 100644 --- a/Release/cmake/cpprest_find_websocketpp.cmake +++ b/Release/cmake/cpprest_find_websocketpp.cmake -@@ -1,27 +1,7 @@ +@@ -1,26 +1,6 @@ function(cpprest_find_websocketpp) - if(TARGET cpprestsdk_websocketpp_internal) - return() @@ -109,11 +109,9 @@ index 94ea81a..f83a777 100644 - cpprestsdk_boost_internal - cpprestsdk_openssl_internal - ) --endfunction() + if(NOT TARGET cpprestsdk_websocketpp_internal) + add_library(cpprestsdk_websocketpp_internal INTERFACE) -+ target_include_directories(cpprestsdk_websocketpp_internal INTERFACE "${CONAN_INCLUDE_DIRS_WEBSOCKETPP}") -+ target_link_libraries(cpprestsdk_websocketpp_internal INTERFACE "${CONAN_LIBS_WEBSOCKETPP}") ++ find_package(websocketpp REQUIRED) ++ target_link_libraries(cpprestsdk_websocketpp_internal INTERFACE "websocketpp::websocketpp") + endif() -+endfunction() -\ No newline at end of file + endfunction() diff --git a/recipes/cpprestsdk/all/patches/0003-find-cmake-targets.patch b/recipes/cpprestsdk/all/patches/0003-find-cmake-targets.patch index 5ce9d5a891943..b3963409c208d 100644 --- a/recipes/cpprestsdk/all/patches/0003-find-cmake-targets.patch +++ b/recipes/cpprestsdk/all/patches/0003-find-cmake-targets.patch @@ -84,15 +84,15 @@ index 0b49a7e..ed5c24b 100644 - endif() + if(NOT TARGET cpprestsdk_openssl_internal) + add_library(cpprestsdk_openssl_internal INTERFACE) -+ target_include_directories(cpprestsdk_openssl_internal INTERFACE "${CONAN_INCLUDE_DIRS_OPENSSL}") -+ target_link_libraries(cpprestsdk_openssl_internal INTERFACE "${CONAN_LIBS_OPENSSL}") -+ endif() ++ find_package(OpenSSL REQUIRED) ++ target_link_libraries(cpprestsdk_openssl_internal INTERFACE "OpenSSL::SSL") ++ endif() endfunction() diff --git a/Release/cmake/cpprest_find_websocketpp.cmake b/Release/cmake/cpprest_find_websocketpp.cmake index 94ea81a..f83a777 100644 --- a/Release/cmake/cpprest_find_websocketpp.cmake +++ b/Release/cmake/cpprest_find_websocketpp.cmake -@@ -1,27 +1,7 @@ +@@ -1,26 +1,6 @@ function(cpprest_find_websocketpp) - if(TARGET cpprestsdk_websocketpp_internal) - return() @@ -119,11 +119,9 @@ index 94ea81a..f83a777 100644 - cpprestsdk_boost_internal - cpprestsdk_openssl_internal - ) --endfunction() + if(NOT TARGET cpprestsdk_websocketpp_internal) + add_library(cpprestsdk_websocketpp_internal INTERFACE) -+ target_include_directories(cpprestsdk_websocketpp_internal INTERFACE "${CONAN_INCLUDE_DIRS_WEBSOCKETPP}") -+ target_link_libraries(cpprestsdk_websocketpp_internal INTERFACE "${CONAN_LIBS_WEBSOCKETPP}") ++ find_package(websocketpp REQUIRED) ++ target_link_libraries(cpprestsdk_websocketpp_internal INTERFACE "websocketpp::websocketpp") + endif() -+endfunction() -\ No newline at end of file + endfunction() diff --git a/recipes/cpprestsdk/all/test_package/CMakeLists.txt b/recipes/cpprestsdk/all/test_package/CMakeLists.txt index c11ad1fb0e2dd..b305f36beee8f 100644 --- a/recipes/cpprestsdk/all/test_package/CMakeLists.txt +++ b/recipes/cpprestsdk/all/test_package/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.1) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - find_package(cpprestsdk REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) diff --git a/recipes/cpprestsdk/all/test_package/conanfile.py b/recipes/cpprestsdk/all/test_package/conanfile.py index abcaeed3f89b6..e845ae751a301 100644 --- a/recipes/cpprestsdk/all/test_package/conanfile.py +++ b/recipes/cpprestsdk/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cpprestsdk/all/test_package/test_package.cpp b/recipes/cpprestsdk/all/test_package/test_package.cpp index e3f62537b9963..2e37ce5334db9 100644 --- a/recipes/cpprestsdk/all/test_package/test_package.cpp +++ b/recipes/cpprestsdk/all/test_package/test_package.cpp @@ -1,6 +1,7 @@ -#include +#include int main() { const auto parsed_value = web::json::value::parse(U("-22")); + const auto get_method = web::http::methods::GET; } diff --git a/recipes/cpprestsdk/all/test_v1_package/CMakeLists.txt b/recipes/cpprestsdk/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/cpprestsdk/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/cpprestsdk/all/test_v1_package/conanfile.py b/recipes/cpprestsdk/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cpprestsdk/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpprestsdk/config.yml b/recipes/cpprestsdk/config.yml index b6b95a950186e..d4be51c9a70c3 100644 --- a/recipes/cpprestsdk/config.yml +++ b/recipes/cpprestsdk/config.yml @@ -1,9 +1,9 @@ versions: - "2.10.15": - folder: "all" - "2.10.16": + "2.10.18": folder: "all" "2.10.17": folder: "all" - "2.10.18": + "2.10.16": + folder: "all" + "2.10.15": folder: "all" diff --git a/recipes/cppserver/all/conandata.yml b/recipes/cppserver/all/conandata.yml index f5c85dd1e67c0..2fb55836179d9 100644 --- a/recipes/cppserver/all/conandata.yml +++ b/recipes/cppserver/all/conandata.yml @@ -2,11 +2,21 @@ sources: "1.0.0.0": url: "https://github.com/chronoxor/CppServer/archive/1.0.0.0.tar.gz" sha256: "dc70fb24231ac4c06e813a0489ff911dd5c48f844b75856b1e753ac8dbd64772" + "1.0.1.0": + url: "https://github.com/chronoxor/CppServer/archive/1.0.1.0.tar.gz" + sha256: "eff49607a18821de6b992e6b0d9c3d48fa6726242546a1da08cbc2832f901ffc" patches: "1.0.0.0": - - patch_file: "patches/00001-cmake-clean-up.patch" + - patch_file: "patches/0001-cmake-clean-up-1-0-0-0.patch" base_path: "source_subfolder" - - patch_file: "patches/00002-define-win32-winnt.patch" + - patch_file: "patches/0002-define-win32-winnt-1-0-0-0.patch" base_path: "source_subfolder" - - patch_file: "patches/00003-remove-asio-defines.patch" + - patch_file: "patches/0003-remove-asio-defines-1-0-0-0.patch" + base_path: "source_subfolder" + "1.0.1.0": + - patch_file: "patches/0001-cmake-clean-up-1-0-1-0.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-define-win32-winnt-1-0-1-0.patch" + base_path: "source_subfolder" + - patch_file: "patches/0003-remove-asio-defines-1-0-1-0.patch" base_path: "source_subfolder" diff --git a/recipes/cppserver/all/conanfile.py b/recipes/cppserver/all/conanfile.py index a087dc5442744..8d6f05452ed13 100644 --- a/recipes/cppserver/all/conanfile.py +++ b/recipes/cppserver/all/conanfile.py @@ -18,7 +18,7 @@ class CppServer(ConanFile): "shared": [True, False]} default_options = {"fPIC": True, "shared": False} - requires = ["asio/1.17.0", "openssl/1.1.1i", "cppcommon/cci.20201104"] + requires = ["asio/1.19.1", "openssl/1.1.1k", "cppcommon/1.0.2.0"] generators = "cmake", "cmake_find_package" exports_sources = ["patches/**", "CMakeLists.txt"] _cmake = None diff --git a/recipes/cppserver/all/patches/00001-cmake-clean-up.patch b/recipes/cppserver/all/patches/0001-cmake-clean-up-1-0-0-0.patch similarity index 100% rename from recipes/cppserver/all/patches/00001-cmake-clean-up.patch rename to recipes/cppserver/all/patches/0001-cmake-clean-up-1-0-0-0.patch diff --git a/recipes/cppserver/all/patches/0001-cmake-clean-up-1-0-1-0.patch b/recipes/cppserver/all/patches/0001-cmake-clean-up-1-0-1-0.patch new file mode 100644 index 0000000000000..336f885c2dec9 --- /dev/null +++ b/recipes/cppserver/all/patches/0001-cmake-clean-up-1-0-1-0.patch @@ -0,0 +1,140 @@ +From 3fa937989fcb8c96a1a73eb016706e5cfb18a799 Mon Sep 17 00:00:00 2001 +From: Alejandro Colomar +Date: Mon, 7 Jun 2021 11:42:21 +0200 +Subject: [PATCH] cmake clean up + +--- + CMakeLists.txt | 59 +++++++++++++++----------------------------------- + 1 file changed, 18 insertions(+), 41 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 95e9c9e1..2183c531 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -17,52 +17,20 @@ if(DOXYGEN_FOUND) + endif() + endif() + +-# CMake module path +-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +- +-# Compiler features +-include(SetCompilerFeatures) +-include(SetCompilerWarnings) +-include(SetPlatformFeatures) +-include(SystemInformation) +- + # External packages +-if(CYGWIN) +- set(OPENSSL_ROOT_DIR "/usr/lib") +- set(OPENSSL_INCLUDE_DIR "/usr/include") +- set(OPENSSL_CRYPTO_LIBRARY "/usr/lib/libcrypto.dll.a") +- set(OPENSSL_SSL_LIBRARY "/usr/lib/libssl.dll.a") +-elseif(MINGW) +- set(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/modules/OpenSSL/MinGW") +- set(OPENSSL_USE_STATIC_LIBS TRUE) +-elseif(MSVC) +- set(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/modules/OpenSSL/VS") +- set(OPENSSL_USE_STATIC_LIBS TRUE) +- set(OPENSSL_MSVC_STATIC_RT TRUE) +-endif() + find_package(OpenSSL REQUIRED) +-if(WIN32) +- find_package(Crypt) +- find_package(WinSock) +-endif() +- +-# Modules +-add_subdirectory("modules") + + # Link libraries +-list(APPEND LINKLIBS ${OPENSSL_LIBRARIES}) ++list(APPEND LINKLIBS CONAN_PKG::openssl) + if(WIN32) +- list(APPEND LINKLIBS ${CRYPT_LIBRARIES}) +- list(APPEND LINKLIBS ${WINSOCK_LIBRARIES}) ++ list(APPEND LINKLIBS crypt32) ++ list(APPEND LINKLIBS mswsock ws2_32) + endif() +-list(APPEND LINKLIBS cppcommon) ++list(APPEND LINKLIBS CONAN_PKG::cppcommon) + + # OpenSSL libraries + message(STATUS "OpenSSL version: ${OPENSSL_VERSION} ${OPENSSL_INCLUDE_DIR} ${OPENSSL_LIBRARIES}") + +-# System directories +-include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/modules") +- + # Library + file(GLOB_RECURSE LIB_HEADER_FILES "include/*.h" "source/*.h") + file(GLOB_RECURSE LIB_INLINE_FILES "include/*.inl" "source/*.inl") +@@ -70,7 +38,8 @@ file(GLOB_RECURSE LIB_SOURCE_FILES "include/*.cpp" "source/*.cpp") + add_library(cppserver ${LIB_HEADER_FILES} ${LIB_INLINE_FILES} ${LIB_SOURCE_FILES}) + set_target_properties(cppserver PROPERTIES COMPILE_FLAGS "${PEDANTIC_COMPILE_FLAGS}" FOLDER "libraries") + target_include_directories(cppserver PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") +-target_link_libraries(cppserver ${LINKLIBS} asio) ++target_link_libraries(cppserver ${LINKLIBS} CONAN_PKG::asio) ++target_compile_features(cppserver PUBLIC cxx_std_17) + list(APPEND INSTALL_TARGETS cppserver) + list(APPEND LINKLIBS cppserver) + +@@ -78,6 +47,7 @@ list(APPEND LINKLIBS cppserver) + if(NOT CPPSERVER_MODULE) + + # Examples ++ if(FALSE) + file(GLOB EXAMPLE_HEADER_FILES "examples/*.h") + file(GLOB EXAMPLE_INLINE_FILES "examples/*.inl") + file(GLOB EXAMPLE_SOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/examples" "examples/*.cpp") +@@ -90,8 +60,10 @@ if(NOT CPPSERVER_MODULE) + list(APPEND INSTALL_TARGETS ${EXAMPLE_TARGET}) + list(APPEND INSTALL_TARGETS_PDB ${EXAMPLE_TARGET}) + endforeach() ++ endif() + + # Benchmarks ++ if(FALSE) + file(GLOB BENCHMARK_HEADER_FILES "performance/*.h") + file(GLOB BENCHMARK_INLINE_FILES "performance/*.inl") + file(GLOB BENCHMARK_SOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/performance" "performance/*.cpp") +@@ -104,8 +76,10 @@ if(NOT CPPSERVER_MODULE) + list(APPEND INSTALL_TARGETS ${BENCHMARK_TARGET}) + list(APPEND INSTALL_TARGETS_PDB ${BENCHMARK_TARGET}) + endforeach() ++ endif() + + # Tests ++ if(FALSE) + file(GLOB TESTS_HEADER_FILES "tests/*.h") + file(GLOB TESTS_INLINE_FILES "tests/*.inl") + file(GLOB TESTS_SOURCE_FILES "tests/*.cpp") +@@ -115,19 +89,22 @@ if(NOT CPPSERVER_MODULE) + target_link_libraries(cppserver-tests ${LINKLIBS}) + list(APPEND INSTALL_TARGETS cppserver-tests) + list(APPEND INSTALL_TARGETS_PDB cppserver-tests) ++ endif() + + # CTest ++ if(FALSE) + enable_testing() + add_test(cppserver-tests cppserver-tests --durations yes --order lex) ++ endif() + + # Install + install(TARGETS ${INSTALL_TARGETS} +- RUNTIME DESTINATION "${PROJECT_SOURCE_DIR}/bin" +- LIBRARY DESTINATION "${PROJECT_SOURCE_DIR}/bin" +- ARCHIVE DESTINATION "${PROJECT_SOURCE_DIR}/bin") ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib) + + # Install *.pdb files +- if(MSVC) ++ if(FALSE) + foreach(INSTALL_TARGET_PDB ${INSTALL_TARGETS_PDB}) + install(FILES $ DESTINATION "${PROJECT_SOURCE_DIR}/bin") + endforeach() +-- +2.31.1.498.g6c1eba8ee3d + diff --git a/recipes/cppserver/all/patches/00002-define-win32-winnt.patch b/recipes/cppserver/all/patches/0002-define-win32-winnt-1-0-0-0.patch similarity index 100% rename from recipes/cppserver/all/patches/00002-define-win32-winnt.patch rename to recipes/cppserver/all/patches/0002-define-win32-winnt-1-0-0-0.patch diff --git a/recipes/cppserver/all/patches/0002-define-win32-winnt-1-0-1-0.patch b/recipes/cppserver/all/patches/0002-define-win32-winnt-1-0-1-0.patch new file mode 100644 index 0000000000000..4ba54a1111696 --- /dev/null +++ b/recipes/cppserver/all/patches/0002-define-win32-winnt-1-0-1-0.patch @@ -0,0 +1,33 @@ +From 7e22e6744924bf00bcb01bc1efe552446a389915 Mon Sep 17 00:00:00 2001 +From: Alejandro Colomar +Date: Mon, 7 Jun 2021 11:45:37 +0200 +Subject: [PATCH] define win32 winnt + +The change present here is handled upstream by this CMake module: + +https://github.com/chronoxor/CppCMakeScripts/blob/1.0.0.0/SetPlatformFeatures.cmake + +Even if it sets _WIN32_WINNT to _WIN32_WINNT_WIN10, here a less strict +definiton is chosen (_WIN32_WINNT_VISTA). +--- + CMakeLists.txt | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2183c531..29fe1a3c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -43,6 +43,10 @@ target_compile_features(cppserver PUBLIC cxx_std_17) + list(APPEND INSTALL_TARGETS cppserver) + list(APPEND LINKLIBS cppserver) + ++if(WIN32 AND NOT MSVC) ++ target_compile_definitions(cppserver PUBLIC -D_WIN32_WINNT=_WIN32_WINNT_VISTA) ++endif() ++ + # Additional module components: benchmarks, examples, plugins, tests, tools and install + if(NOT CPPSERVER_MODULE) + +-- +2.31.1.498.g6c1eba8ee3d + diff --git a/recipes/cppserver/all/patches/00003-remove-asio-defines.patch b/recipes/cppserver/all/patches/0003-remove-asio-defines-1-0-0-0.patch similarity index 100% rename from recipes/cppserver/all/patches/00003-remove-asio-defines.patch rename to recipes/cppserver/all/patches/0003-remove-asio-defines-1-0-0-0.patch diff --git a/recipes/cppserver/all/patches/0003-remove-asio-defines-1-0-1-0.patch b/recipes/cppserver/all/patches/0003-remove-asio-defines-1-0-1-0.patch new file mode 100644 index 0000000000000..796ba572a73d1 --- /dev/null +++ b/recipes/cppserver/all/patches/0003-remove-asio-defines-1-0-1-0.patch @@ -0,0 +1,25 @@ +From 3eba074264a5b3a36fedff3e5b13b3743bba2932 Mon Sep 17 00:00:00 2001 +From: Alejandro Colomar +Date: Mon, 7 Jun 2021 11:46:46 +0200 +Subject: [PATCH] remove asio defines + +--- + include/server/asio/asio.h | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/include/server/asio/asio.h b/include/server/asio/asio.h +index 8ad4d6bc..b8cb7030 100644 +--- a/include/server/asio/asio.h ++++ b/include/server/asio/asio.h +@@ -26,8 +26,6 @@ + + #else + +-#define ASIO_STANDALONE +-#define ASIO_SEPARATE_COMPILATION + #define ASIO_NO_WIN32_LEAN_AND_MEAN + + #if defined(_MSC_VER) +-- +2.31.1.498.g6c1eba8ee3d + diff --git a/recipes/cppserver/config.yml b/recipes/cppserver/config.yml index 401095558bd5b..75c89baf4fb06 100644 --- a/recipes/cppserver/config.yml +++ b/recipes/cppserver/config.yml @@ -1,3 +1,5 @@ versions: "1.0.0.0": folder: all + "1.0.1.0": + folder: all diff --git a/recipes/cppunit/all/conanfile.py b/recipes/cppunit/all/conanfile.py index 90c809224c6e1..b78b323595ebf 100644 --- a/recipes/cppunit/all/conanfile.py +++ b/recipes/cppunit/all/conanfile.py @@ -1,12 +1,24 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from contextlib import contextmanager +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import copy, get, rename, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version +from conans import tools as tools_legacy import os +required_conan_version = ">=1.53.0" + class CppunitConan(ConanFile): name = "cppunit" - description = "CppUnit is the C++ port of the famous JUnit framework for unit testing. Test output is in XML for automatic testing and GUI based for supervised tests." - topics = ("conan", "cppunit", "unit-test", "tdd") + description = ( + "CppUnit is the C++ port of the famous JUnit framework for unit testing. " + "Test output is in XML for automatic testing and GUI based for supervised tests." + ) + topics = ("unit-test", "tdd") license = " LGPL-2.1-or-later" homepage = "https://freedesktop.org/wiki/Software/cppunit/" url = "https://github.com/conan-io/conan-center-index" @@ -19,13 +31,14 @@ class CppunitConan(ConanFile): "shared": False, "fPIC": True, } - generators = "pkg_config" - _autotools = None + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) @property - def _source_subfolder(self): - return "source_subfolder" + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) def config_options(self): if self.settings.os == "Windows": @@ -33,85 +46,86 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + + def layout(self): + basic_layout(self, src_folder="src") def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") - if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.2") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + if is_msvc(self): + self.tool_requires("automake/1.16.5") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) - - @contextmanager - def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - env = { - "AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), - "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "NM": "dumpbin -symbols", - "OBJDUMP": ":", - "RANLIB": ":", - "STRIP": ":", - } - with tools.environment_append(env): - yield - else: - yield - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) if self.settings.os == "Windows" and self.options.shared: - self._autotools.defines.append("CPPUNIT_BUILD_DLL") - if self.settings.compiler == "Visual Studio": - self._autotools.flags.append("-FS") - self._autotools.cxx_flags.append("-EHsc") + tc.extra_defines.append("CPPUNIT_BUILD_DLL") + if is_msvc(self): + tc.extra_cxxflags.append("-EHsc") + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + tc.extra_cxxflags.append("-FS") yes_no = lambda v: "yes" if v else "no" - conf_args = [ - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), + tc.configure_args.extend([ "--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")), "--enable-doxygen=no", "--enable-dot=no", "--enable-werror=no", "--enable-html-docs=no", - ] - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return self._autotools + ]) + tc.generate() + + if is_msvc(self): + env = Environment() + compile_wrapper = unix_path(self, self._user_info_build["automake"].compile) + ar_wrapper = unix_path(self, self._user_info_build["automake"].ar_lib) + env.define("CC", f"{compile_wrapper} cl -nologo") + env.define("CXX", f"{compile_wrapper} cl -nologo") + env.define("LD", "link -nologo") + env.define("AR", f"{ar_wrapper} \"lib -nologo\"") + env.define("NM", "dumpbin -symbols") + env.define("OBJDUMP", ":") + env.define("RANLIB", ":") + env.define("STRIP", ":") + env.vars(self).save_script("conanbuild_cppunit_msvc") def build(self): - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() - - if self.settings.compiler == "Visual Studio" and self.options.shared: - os.rename(os.path.join(self.package_folder, "lib", "cppunit.dll.lib"), - os.path.join(self.package_folder, "lib", "cppunit.lib")) - - os.unlink(os.path.join(self.package_folder, "lib", "libcppunit.la")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + if is_msvc(self) and self.options.shared: + rename(self, os.path.join(self.package_folder, "lib", "cppunit.dll.lib"), + os.path.join(self.package_folder, "lib", "cppunit.lib")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + fix_apple_shared_install_name(self) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "cppunit") self.cpp_info.libs = ["cppunit"] if not self.options.shared: - stdlib = tools.stdcpp_library(self) - if stdlib: - self.cpp_info.system_libs.append(stdlib) - if self.settings.os == "Linux": + libcxx = tools_legacy.stdcpp_library(self) + if libcxx: + self.cpp_info.system_libs.append(libcxx) + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("dl") if self.options.shared and self.settings.os == "Windows": self.cpp_info.defines.append("CPPUNIT_DLL") - self.cpp_info.filenames["pkg_config"] = "cppunit" diff --git a/recipes/cppunit/all/test_package/CMakeLists.txt b/recipes/cppunit/all/test_package/CMakeLists.txt index a5527484bd16a..e62b0d941a7cc 100644 --- a/recipes/cppunit/all/test_package/CMakeLists.txt +++ b/recipes/cppunit/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +find_package(cppunit REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE cppunit::cppunit) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cppunit/all/test_package/conanfile.py b/recipes/cppunit/all/test_package/conanfile.py index bd7165a553cf4..0a6bc68712d90 100644 --- a/recipes/cppunit/all/test_package/conanfile.py +++ b/recipes/cppunit/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cppunit/all/test_v1_package/CMakeLists.txt b/recipes/cppunit/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/cppunit/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/cppunit/all/test_v1_package/conanfile.py b/recipes/cppunit/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cppunit/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpputest/all/CMakeLists.txt b/recipes/cpputest/all/CMakeLists.txt deleted file mode 100644 index 361b35d4c17d9..0000000000000 --- a/recipes/cpputest/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/cpputest/all/conandata.yml b/recipes/cpputest/all/conandata.yml index d06d6d3fe54b1..6511c1a3d0188 100644 --- a/recipes/cpputest/all/conandata.yml +++ b/recipes/cpputest/all/conandata.yml @@ -2,4 +2,7 @@ sources: "4.0": url: "https://github.com/cpputest/cpputest/releases/download/v4.0/cpputest-4.0.tar.gz" sha256: 21c692105db15299b5529af81a11a7ad80397f92c122bd7bf1e4a4b0e85654f7 - +patches: + "4.0": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "CMake: move cmake_minimum_required() before project()" diff --git a/recipes/cpputest/all/conanfile.py b/recipes/cpputest/all/conanfile.py index aeb890323643c..ee586cab99d82 100644 --- a/recipes/cpputest/all/conanfile.py +++ b/recipes/cpputest/all/conanfile.py @@ -1,89 +1,126 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save import os +import textwrap + +required_conan_version = ">=1.52.0" -from conans import ConanFile, CMake, tools class CppUTestConan(ConanFile): name = "cpputest" - description = \ -"CppUTest is a C /C++ based unit xUnit test framework for unit testing and for test-driving your code." \ -"It is written in C++ but is used in C and C++ projects and frequently" \ -"used in embedded systems but it works for any C/C++ project." + description = ( + "CppUTest is a C /C++ based unit xUnit test framework for unit testing " + "and for test-driving your code. It is written in C++ but is used in C " + "and C++ projects and frequently used in embedded systems but it works " + "for any C/C++ project." + ) license = "BSD-3-Clause" - topics = ("conan", "testing", "unit-testing") + topics = ("testing", "unit-testing") homepage = "https://cpputest.github.io" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "fPIC": [True, False], "with_extensions": [True, False], + "with_leak_detection": [True, False], } default_options = { "fPIC": True, "with_extensions": True, + "with_leak_detection": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["STD_C"] = True + tc.variables["STD_CPP"] = True + tc.variables["C++11"] = True + tc.variables["MEMORY_LEAK_DETECTION"] = self.options.with_leak_detection + tc.variables["EXTENSIONS"] = self.options.with_extensions + tc.variables["LONGLONG"] = True + tc.variables["COVERAGE"] = False + tc.variables["TESTS"] = False + tc.generate() def build(self): - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["STD_C"] = "ON" - self._cmake.definitions["STD_CPP"] = "ON" - self._cmake.definitions["C++11"] = "ON" - self._cmake.definitions["MEMORY_LEAK_DETECTION"] = "ON" - self._cmake.definitions["EXTENSIONS"] = self.options.with_extensions - self._cmake.definitions["LONGLONG"] = "ON" - self._cmake.definitions["COVERAGE"] = "OFF" - self._cmake.definitions["TESTS"] = "OFF" - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "CppUTest", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "CppUTest")) + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + { + "CppUTest": "CppUTest::CppUTest", + "CppUTestExt": "CppUTest::CppUTestExt", + } + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): + self.cpp_info.set_property("cmake_file_name", "CppUTest") + self.cpp_info.set_property("pkg_config_name", "cpputest") + + self.cpp_info.components["CppUTest"].set_property("cmake_target_name", "CppUTest") + self.cpp_info.components["CppUTest"].libs = ["CppUTest"] + if self.settings.os == "Windows": + self.cpp_info.components["CppUTest"].system_libs.append("winmm") + elif self.settings.os in ("Linux", "FreeBSD"): + self.cpp_info.components["CppUTest"].system_libs.append("pthread") + + if self.options.with_extensions: + self.cpp_info.components["CppUTestExt"].set_property("cmake_target_name", "CppUTestExt") + self.cpp_info.components["CppUTestExt"].libs = ["CppUTestExt"] + self.cpp_info.components["CppUTestExt"].requires = ["CppUTest"] + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self.cpp_info.names["cmake_find_package"] = "CppUTest" self.cpp_info.names["cmake_find_package_multi"] = "CppUTest" self.cpp_info.names["pkg_config"] = "cpputest" - self.cpp_info.components["CppUTest"].names["cmake_find_package"] = "CppUTest" self.cpp_info.components["CppUTest"].names["cmake_find_package_multi"] = "CppUTest" - self.cpp_info.components["CppUTest"].libs = ["CppUTest"] - + self.cpp_info.components["CppUTest"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["CppUTest"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] if self.options.with_extensions: self.cpp_info.components["CppUTestExt"].names["cmake_find_package"] = "CppUTestExt" self.cpp_info.components["CppUTestExt"].names["cmake_find_package_multi"] = "CppUTestExt" - self.cpp_info.components["CppUTestExt"].libs = ["CppUTestExt"] - self.cpp_info.components["CppUTestExt"].requires = ["CppUTest"] - - if self.settings.os == "Windows": - self.cpp_info.components["CppUTest"].system_libs.extend(["winmm"]) - elif self.settings.os in ("Linux", "FreeBSD"): - self.cpp_info.components["CppUTest"].system_libs = ["pthread"] + self.cpp_info.components["CppUTestExt"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["CppUTestExt"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/cpputest/all/patches/0001-fix-cmake.patch b/recipes/cpputest/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..a40096caf1d6d --- /dev/null +++ b/recipes/cpputest/all/patches/0001-fix-cmake.patch @@ -0,0 +1,15 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,3 +1,4 @@ ++cmake_minimum_required(VERSION 3.1) + project(CppUTest) + + set(CppUTest_version_major 4) +@@ -5,7 +6,6 @@ set(CppUTest_version_minor 0) + + # 2.6.3 is needed for ctest support + # 3.1 is needed for target_sources +-cmake_minimum_required(VERSION 3.1) + + ############### + # Conan support diff --git a/recipes/cpputest/all/test_package/CMakeLists.txt b/recipes/cpputest/all/test_package/CMakeLists.txt index fca24bcb4b699..be713b804677f 100644 --- a/recipes/cpputest/all/test_package/CMakeLists.txt +++ b/recipes/cpputest/all/test_package/CMakeLists.txt @@ -1,16 +1,12 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES CXX) find_package(CppUTest REQUIRED CONFIG) add_executable(test_package test_package.cpp) -target_link_libraries(test_package CppUTest::CppUTest) +target_link_libraries(test_package PRIVATE CppUTest) if(WITH_EXTENSIONS) add_executable(test_package_with_extensions test_package_with_extensions.cpp) - # Note: CppUTest::CppUTestExt adds dependency on CppUTest::CppUTest - target_link_libraries(test_package_with_extensions CppUTest::CppUTestExt) + target_link_libraries(test_package_with_extensions PRIVATE CppUTestExt) endif() diff --git a/recipes/cpputest/all/test_package/conanfile.py b/recipes/cpputest/all/test_package/conanfile.py index 90fb643538593..f422d1c08f29f 100644 --- a/recipes/cpputest/all/test_package/conanfile.py +++ b/recipes/cpputest/all/test_package/conanfile.py @@ -1,22 +1,34 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_EXTENSIONS"] = self.dependencies["cpputest"].options.with_extensions + tc.generate() def build(self): cmake = CMake(self) - cmake.definitions["WITH_EXTENSIONS"] = self.options["cpputest"].with_extensions cmake.configure() cmake.build() def test(self): - if tools.cross_building(self.settings): - return - - self.run(os.path.join("bin", "test_package"), run_environment=True) - - if self.options["cpputest"].with_extensions: - self.run(os.path.join("bin", "test_package_with_extensions"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + if self.options["cpputest"].with_extensions: + bin_extensions_path = os.path.join(self.cpp.build.bindirs[0], "test_package_with_extensions") + self.run(bin_extensions_path, env="conanrun") diff --git a/recipes/cpputest/all/test_v1_package/CMakeLists.txt b/recipes/cpputest/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/cpputest/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/cpputest/all/test_v1_package/conanfile.py b/recipes/cpputest/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..cce86300f1595 --- /dev/null +++ b/recipes/cpputest/all/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["WITH_EXTENSIONS"] = self.options["cpputest"].with_extensions + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + if self.options["cpputest"].with_extensions: + bin_extensions_path = os.path.join("bin", "test_package_with_extensions") + self.run(bin_extensions_path, run_environment=True) diff --git a/recipes/cppzmq/all/conandata.yml b/recipes/cppzmq/all/conandata.yml index a138aaf2dc58f..263917af47c65 100644 --- a/recipes/cppzmq/all/conandata.yml +++ b/recipes/cppzmq/all/conandata.yml @@ -1,10 +1,16 @@ sources: - "4.5.0": - url: "https://github.com/zeromq/cppzmq/archive/v4.5.0.tar.gz" - sha256: "64eb4e58eaf0c77505391c6c9a606cffcb57c6086f3431567a1ef4a25b01fa36" - "4.6.0": - url: "https://github.com/zeromq/cppzmq/archive/v4.6.0.tar.gz" - sha256: "e9203391a0b913576153a2ad22a2dc1479b1ec325beb6c46a3237c669aef5a52" + "4.9.0": + url: "https://github.com/zeromq/cppzmq/archive/v4.9.0.tar.gz" + sha256: "3fdf5b100206953f674c94d40599bdb3ea255244dcc42fab0d75855ee3645581" + "4.8.1": + url: "https://github.com/zeromq/cppzmq/archive/v4.8.1.tar.gz" + sha256: "7a23639a45f3a0049e11a188e29aaedd10b2f4845f0000cf3e22d6774ebde0af" "4.7.1": url: "https://github.com/zeromq/cppzmq/archive/v4.7.1.tar.gz" sha256: "9853e0437d834cbed5d3c223bf1d755cadee70e7c964c6e42c4c6783dee5d02c" + "4.6.0": + url: "https://github.com/zeromq/cppzmq/archive/v4.6.0.tar.gz" + sha256: "e9203391a0b913576153a2ad22a2dc1479b1ec325beb6c46a3237c669aef5a52" + "4.5.0": + url: "https://github.com/zeromq/cppzmq/archive/v4.5.0.tar.gz" + sha256: "64eb4e58eaf0c77505391c6c9a606cffcb57c6086f3431567a1ef4a25b01fa36" diff --git a/recipes/cppzmq/all/conanfile.py b/recipes/cppzmq/all/conanfile.py index 580ebf3d514cb..44e3718dd5de3 100644 --- a/recipes/cppzmq/all/conanfile.py +++ b/recipes/cppzmq/all/conanfile.py @@ -1,8 +1,10 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import copy, get, save +from conan.tools.layout import basic_layout import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.52.0" class CppZmqConan(ConanFile): @@ -10,63 +12,69 @@ class CppZmqConan(ConanFile): description = "C++ binding for 0MQ" homepage = "https://github.com/zeromq/cppzmq" license = "MIT" - topics = ("conan", "cppzmq", "zmq-cpp", "zmq", "cpp-bind") + topics = ("cppzmq", "zmq-cpp", "zmq", "cpp-bind") url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): - self.requires("zeromq/4.3.4") + self.requires("zeromq/4.3.4", transitive_headers=True, transitive_libs=True) def package_id(self): - self.info.header_only() + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("cppzmq-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("zmq*.hpp", dst="include", src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "zmq*.hpp", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), { - # cppzmq has 2 weird official CMake imported targets: - # - cppzmq if cppzmq depends on shared zeromq - # - cppzmq-static if cppzmq depends on static zeromq "cppzmq": "cppzmq::cppzmq", "cppzmq-static": "cppzmq::cppzmq", } ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + """) + save(self, module_file, content) @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): + self.cpp_info.set_property("cmake_file_name", "cppzmq") + # cppzmq has 2 weird official CMake imported targets: + # - cppzmq if cppzmq depends on shared zeromq + # - cppzmq-static if cppzmq depends on static zeromq + self.cpp_info.set_property("cmake_target_name", "cppzmq") + self.cpp_info.set_property("cmake_target_aliases", ["cppzmq-static"]) + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "cppzmq" self.cpp_info.names["cmake_find_package_multi"] = "cppzmq" - self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/cppzmq/all/test_package/CMakeLists.txt b/recipes/cppzmq/all/test_package/CMakeLists.txt index 6f9d165d70f7b..207bcc2f27a5a 100644 --- a/recipes/cppzmq/all/test_package/CMakeLists.txt +++ b/recipes/cppzmq/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(cppzmq REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} cppzmq) +target_link_libraries(${PROJECT_NAME} PRIVATE cppzmq) diff --git a/recipes/cppzmq/all/test_package/conanfile.py b/recipes/cppzmq/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/cppzmq/all/test_package/conanfile.py +++ b/recipes/cppzmq/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cppzmq/all/test_v1_package/CMakeLists.txt b/recipes/cppzmq/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/cppzmq/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cppzmq/all/test_v1_package/conanfile.py b/recipes/cppzmq/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cppzmq/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cppzmq/config.yml b/recipes/cppzmq/config.yml index 1b79875812de1..a52b8593d6634 100644 --- a/recipes/cppzmq/config.yml +++ b/recipes/cppzmq/config.yml @@ -1,7 +1,11 @@ versions: - "4.5.0": + "4.9.0": folder: all - "4.6.0": + "4.8.1": folder: all "4.7.1": folder: all + "4.6.0": + folder: all + "4.5.0": + folder: all diff --git a/recipes/cpr/all/conandata.yml b/recipes/cpr/all/conandata.yml index 4a1d4f821a3eb..d7338e66daa30 100644 --- a/recipes/cpr/all/conandata.yml +++ b/recipes/cpr/all/conandata.yml @@ -1,48 +1,46 @@ sources: - "1.3.0": - sha256: "82597627e8b2aef1f0482631c9b11595c63a7565bb462a5995d126da4419ac99" - url: https://github.com/whoshuu/cpr/archive/1.3.0.tar.gz - "1.4.0": - sha256: "13baffba95445e02291684e31906b04df41d8c6a3020a1a55253047c6756a004" - url: https://github.com/whoshuu/cpr/archive/1.4.0.tar.gz - "1.5.0": - sha256: "a1727794541bac6d1bb73c9c27ac3ef5b0d64edcc4f81dc8d79b3cf31b6144e9" - url: https://github.com/whoshuu/cpr/archive/1.5.0.tar.gz - "1.5.2": - sha256: "6fc9102dd63b549912d7af1ec95ee41ece1a2fe27f759864306b07f6fcf24fe1" - url: https://github.com/whoshuu/cpr/archive/1.5.2.tar.gz - "1.6.0": - sha256: "5a20a9f014b47988f5230d008174e5db2b33f8c547df825e6beae0c78fc05a9e" - url: https://github.com/whoshuu/cpr/archive/1.6.0.tar.gz + "1.9.0": + url: "https://github.com/libcpr/cpr/archive/refs/tags/1.9.0.tar.gz" + sha256: "67023cde8979e8371f5ee7d6e586d6d0761af4a3a3a3be6270256353c9bf411f" + "1.8.1": + url: "https://github.com/libcpr/cpr/archive/refs/tags/1.8.1.tar.gz" + sha256: "9155ec36fcafe8cf8d61c98cde8dc6bd27c146740002069bf990855eecb2b95f" + "1.7.2": + url: "https://github.com/libcpr/cpr/archive/refs/tags/1.7.2.tar.gz" + sha256: "aa38a414fe2ffc49af13a08b6ab34df825fdd2e7a1213d032d835a779e14176f" "1.6.2": + url: "https://github.com/libcpr/cpr/archive/1.6.2.tar.gz" sha256: "c45f9c55797380c6ba44060f0c73713fbd7989eeb1147aedb8723aa14f3afaa3" - url: https://github.com/whoshuu/cpr/archive/1.6.2.tar.gz - + "1.5.2": + url: "https://github.com/libcpr/cpr/archive/1.5.2.tar.gz" + sha256: "6fc9102dd63b549912d7af1ec95ee41ece1a2fe27f759864306b07f6fcf24fe1" + "1.4.0": + url: "https://github.com/libcpr/cpr/archive/1.4.0.tar.gz" + sha256: "13baffba95445e02291684e31906b04df41d8c6a3020a1a55253047c6756a004" patches: - "1.3.0": - - patch_file: "patches/001-fix-curl-define.patch" - base_path: "source_subfolder" - - patch_file: "patches/002-create-install.patch" + "1.9.0": + - patch_file: "patches/005-1.9.0-fix-curl-components.patch" base_path: "source_subfolder" - - patch_file: "patches/003-zlib-use-target.patch" + "1.8.1": + - patch_file: "patches/005-1.8.1-fix-curl-components.patch" base_path: "source_subfolder" - - patch_file: "patches/004-curl-global-scope.patch" + - patch_file: "patches/007-fix-dll-install.patch" base_path: "source_subfolder" - "1.4.0": - - patch_file: "patches/001-1.4.0-create-install.patch" + "1.7.2": + - patch_file: "patches/005-1.7.2-fix-curl-components.patch" base_path: "source_subfolder" - - patch_file: "patches/002-1.4.0-zlib-use-target.patch" + - patch_file: "patches/007-fix-dll-install.patch" base_path: "source_subfolder" - - patch_file: "patches/003-1.4.0-curl-global-scope.patch" + "1.6.2": + - patch_file: "patches/005-1.6.2-fix-curl-components.patch" base_path: "source_subfolder" "1.5.2": - - patch_file: "patches/005-fix-curl-components.patch" + - patch_file: "patches/005-1.5.2-fix-curl-components.patch" base_path: "source_subfolder" - "1.6.0": - - patch_file: "patches/006-fix-curl-components.patch" + "1.4.0": + - patch_file: "patches/002-1.4.0-create-install.patch" base_path: "source_subfolder" - - patch_file: "patches/007-patch-sanitizer.patch" + - patch_file: "patches/003-1.4.0-curl-use-target.patch" base_path: "source_subfolder" - "1.6.2": - - patch_file: "patches/008-fix-curl-components.patch" + - patch_file: "patches/004-1.4.0-curl-global-scope.patch" base_path: "source_subfolder" diff --git a/recipes/cpr/all/conanfile.py b/recipes/cpr/all/conanfile.py index 419aafd2738e0..90958d55211c7 100644 --- a/recipes/cpr/all/conanfile.py +++ b/recipes/cpr/all/conanfile.py @@ -1,6 +1,11 @@ from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc +from conan.tools.build import cross_building import os +import functools + +required_conan_version = ">=1.43.0" class CprConan(ConanFile): @@ -9,28 +14,26 @@ class CprConan(ConanFile): name = "cpr" description = "C++ Requests: Curl for People, a spiritual port of Python Requests" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://whoshuu.github.io/cpr/" license = "MIT" - topics = ("conan", "cpr", "requests", "web", "curl") - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake", "cmake_find_package" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://docs.libcpr.org/" + topics = ("requests", "web", "curl") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "with_openssl": [True, False, "deprecated"], - "with_winssl": [True, False, "deprecated"], - "with_ssl": ["openssl", "darwinssl", "winssl", _AUTO_SSL, _NO_SSL] + "with_ssl": ["openssl", "darwinssl", "winssl", _AUTO_SSL, _NO_SSL], + "signal": [True, False], } default_options = { "shared": False, "fPIC": True, - "with_openssl": "deprecated", - "with_winssl": "deprecated", - "with_ssl": _AUTO_SSL + "with_ssl": _AUTO_SSL, + "signal": True, } + generators = "cmake", "cmake_find_package" _cmake = None @property @@ -43,34 +46,33 @@ def _build_subfolder(self): @property def _supports_openssl(self): - # https://github.com/whoshuu/cpr/commit/b036a3279ba62720d1e43362d32202bf412ea152 - # https://github.com/whoshuu/cpr/releases/tag/1.5.0 + # https://github.com/libcpr/cpr/commit/b036a3279ba62720d1e43362d32202bf412ea152 + # https://github.com/libcpr/cpr/releases/tag/1.5.0 return tools.Version(self.version) >= "1.5.0" and not tools.is_apple_os(self.settings.os) @property def _supports_winssl(self): - # https://github.com/whoshuu/cpr/commit/18e1fc5c3fc0ffc07695f1d78897fb69e7474ea9 - # https://github.com/whoshuu/cpr/releases/tag/1.5.1 + # https://github.com/libcpr/cpr/commit/18e1fc5c3fc0ffc07695f1d78897fb69e7474ea9 + # https://github.com/libcpr/cpr/releases/tag/1.5.1 return tools.Version(self.version) >= "1.5.1" and self.settings.os == "Windows" @property def _supports_darwinssl(self): - # https://github.com/whoshuu/cpr/releases/tag/1.6.1 + # https://github.com/libcpr/cpr/releases/tag/1.6.1 return tools.Version(self.version) >= "1.6.1" and tools.is_apple_os(self.settings.os) @property def _can_auto_ssl(self): - # https://github.com/whoshuu/cpr/releases/tag/1.6.0 + # https://github.com/libcpr/cpr/releases/tag/1.6.0 return not self._uses_old_cmake_options and not ( - # https://github.com/whoshuu/cpr/issues/546 + # https://github.com/libcpr/cpr/issues/546 tools.Version(self.version) in ["1.6.0", "1.6.1"] and tools.is_apple_os(self.settings.os) ) - @property def _uses_old_cmake_options(self): - # https://github.com/whoshuu/cpr/releases/tag/1.6.0 + # https://github.com/libcpr/cpr/releases/tag/1.6.0 return tools.Version(self.version) < "1.6.0" @property @@ -83,11 +85,16 @@ def _uses_valid_abi_and_compiler(self): and tools.Version(self.settings.compiler.version) < "9" ) + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - ssl_library = self._get_ssl_library() + ssl_library = str(self.options.get_safe("with_ssl")) if not self._can_auto_ssl and ssl_library == CprConan._AUTO_SSL: if self._supports_openssl: self.output.info("Auto SSL is not available below version 1.6.0. Falling back to openssl") @@ -99,18 +106,43 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if not self._supports_openssl: - del self.options.with_openssl - if not self._supports_winssl: - del self.options.with_winssl + def requirements(self): + self.requires("libcurl/7.80.0") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("cpr-{}".format(self.version), self._source_subfolder) + def validate(self): + SSL_FAILURE_MESSAGES = { + "openssl": "OpenSSL is not supported on macOS or on CPR versions < 1.5.0", + "darwinssl": "DarwinSSL is only supported on macOS and on CPR versions >= 1.6.1", + "winssl": "WinSSL is only on Windows and on CPR versions >= 1.5.1", + CprConan._AUTO_SSL: "Automatic SSL selection is only available on CPR versions >= 1.6.0 (and only >= 1.6.2 on macOS)" + } - def requirements(self): - self.requires("libcurl/{}".format("7.67.0" if not self._supports_openssl else "7.69.1")) + if not self._uses_valid_abi_and_compiler: + raise ConanInvalidConfiguration("Cannot compile cpr/1.6.0 with libstdc++ on clang < 9") + + ssl_library = str(self.options.get_safe("with_ssl")) + if not self._supports_ssl_library(ssl_library): + raise ConanInvalidConfiguration( + "Invalid SSL selection for the given configuration: {}".format(SSL_FAILURE_MESSAGES[ssl_library]) + if ssl_library in SSL_FAILURE_MESSAGES + else "Invalid value of ssl option, {}".format(ssl_library) + ) + + if ssl_library not in (CprConan._AUTO_SSL, CprConan._NO_SSL, "winssl") and ssl_library != self.options["libcurl"].with_ssl: + raise ConanInvalidConfiguration("cpr requires libcurl to be built with the option with_ssl='{}'.".format(self.options.get_safe('with_ssl'))) + + if ssl_library == "winssl" and self.options["libcurl"].with_ssl != "schannel": + raise ConanInvalidConfiguration("cpr requires libcurl to be built with the option with_ssl='schannel'") + + if is_msvc(self) and self.options.shared and "MT" in self.settings.compiler.runtime: + raise ConanInvalidConfiguration("Visual Studio build for shared library with MT runtime is not supported") + + if tools.Version(self.version) == "1.9.0" and self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "6": + raise ConanInvalidConfiguration("{}/{} doesn't support gcc < 6".format(self.name, self.version)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): @@ -125,7 +157,6 @@ def _get_cmake_option(self, option): "CPR_USE_SYSTEM_GTEST": "USE_SYSTEM_GTEST", "CPR_FORCE_OPENSSL_BACKEND": "USE_OPENSSL", "CPR_FORCE_WINSSL_BACKEND": "USE_WINSSL", - "CPR_GENERATE_COVERAGE": "GENERATE_COVERAGE", } if self._uses_old_cmake_options: @@ -134,31 +165,40 @@ def _get_cmake_option(self, option): else: return option + @functools.lru_cache(1) def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions[self._get_cmake_option("CPR_FORCE_USE_SYSTEM_CURL")] = True - self._cmake.definitions[self._get_cmake_option("CPR_BUILD_TESTS")] = False - self._cmake.definitions[self._get_cmake_option("CPR_GENERATE_COVERAGE")] = False - self._cmake.definitions[self._get_cmake_option("CPR_USE_SYSTEM_GTEST")] = False - - ssl_value = self._get_ssl_library() - SSL_OPTIONS = { - "CPR_FORCE_DARWINSSL_BACKEND": ssl_value == "darwinssl", - "CPR_FORCE_OPENSSL_BACKEND": ssl_value == "openssl", - "CPR_FORCE_WINSSL_BACKEND": ssl_value == "winssl", - "CMAKE_USE_OPENSSL": ssl_value == "openssl" - } - - for cmake_option, value in SSL_OPTIONS.items(): - self._cmake.definitions[self._get_cmake_option(cmake_option)] = value - - # If we are on a version where disabling SSL requires a cmake option, disable it - if not self._uses_old_cmake_options and self._get_ssl_library() == CprConan._NO_SSL: - self._cmake.definitions["CPR_ENABLE_SSL"] = False - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + cmake = CMake(self) + cmake.definitions[self._get_cmake_option("CPR_FORCE_USE_SYSTEM_CURL")] = True + cmake.definitions[self._get_cmake_option("CPR_BUILD_TESTS")] = False + cmake.definitions[self._get_cmake_option("CPR_GENERATE_COVERAGE")] = False + cmake.definitions[self._get_cmake_option("CPR_USE_SYSTEM_GTEST")] = False + cmake.definitions["CPR_CURL_NOSIGNAL"] = not self.options.signal + + ssl_value = str(self.options.get_safe("with_ssl")) + SSL_OPTIONS = { + "CPR_FORCE_DARWINSSL_BACKEND": ssl_value == "darwinssl", + "CPR_FORCE_OPENSSL_BACKEND": ssl_value == "openssl", + "CPR_FORCE_WINSSL_BACKEND": ssl_value == "winssl", + "CMAKE_USE_OPENSSL": ssl_value == "openssl" + } + + for cmake_option, value in SSL_OPTIONS.items(): + cmake.definitions[self._get_cmake_option(cmake_option)] = value + + # If we are on a version where disabling SSL requires a cmake option, disable it + if not self._uses_old_cmake_options and str(self.options.get_safe("with_ssl")) == CprConan._NO_SSL: + cmake.definitions["CPR_ENABLE_SSL"] = False + + if hasattr(self, "settings_build") and cross_building(self, skip_x64_x86=True): + cmake.definitions["THREAD_SANITIZER_AVAILABLE_EXITCODE"] = 1 + cmake.definitions["THREAD_SANITIZER_AVAILABLE_EXITCODE__TRYRUN_OUTPUT"] = 1 + cmake.definitions["ADDRESS_SANITIZER_AVAILABLE_EXITCODE"] = 1 + cmake.definitions["ADDRESS_SANITIZER_AVAILABLE_EXITCODE__TRYRUN_OUTPUT"] = 1 + cmake.definitions["ALL_SANITIZERS_AVAILABLE_EXITCODE"] = 1 + cmake.definitions["ALL_SANITIZERS_AVAILABLE_EXITCODE__TRYRUN_OUTPUT"] = 1 + + cmake.configure(build_folder=self._build_subfolder) + return cmake # Check if the system supports the given ssl library def _supports_ssl_library(self, library): @@ -177,50 +217,6 @@ def _supports_ssl_library(self, library): # A KeyError should never happen, as the options are validated by conan. return validators[library] - def _print_deprecation_messages(self): - if self.options.get_safe("with_openssl") != "deprecated": - self.output.warn("with_openssl is deprecated. Please use the with_ssl option.") - elif self.options.get_safe("with_winssl") != "deprecated": - self.output.warn("with_winssl is deprecated. Please use the with_ssl option.") - - # Get the configured ssl library - def _get_ssl_library(self): - ssl_library = str(self.options.get_safe("with_ssl")) - # These must check for True so that we don't take "deprecated" to be truthy - if self.options.get_safe("with_openssl") == True: - return "openssl" - elif self.options.get_safe("with_winssl") == True: - return "winssl" - - return ssl_library - - def validate(self): - SSL_FAILURE_MESSAGES = { - "openssl": "OpenSSL is not supported on macOS or on CPR versions < 1.5.0", - "darwinssl": "DarwinSSL is only supported on macOS and on CPR versions >= 1.6.1", - "winssl": "WinSSL is only on Windows and on CPR versions >= 1.5.1", - CprConan._AUTO_SSL: "Automatic SSL selection is only available on CPR versions >= 1.6.0 (and only >= 1.6.2 on macOS)" - } - - self._print_deprecation_messages() - if not self._uses_valid_abi_and_compiler: - raise ConanInvalidConfiguration("Cannot compile cpr/1.6.0 with libstdc++ on clang < 9") - - ssl_library = self._get_ssl_library() - if not self._supports_ssl_library(ssl_library): - raise ConanInvalidConfiguration( - "Invalid SSL selection for the given configuration: {}".format(SSL_FAILURE_MESSAGES[ssl_library]) - if ssl_library in SSL_FAILURE_MESSAGES - else "Invalid value of ssl option, {}".format(ssl_library) - ) - - if ssl_library not in (CprConan._AUTO_SSL, CprConan._NO_SSL) and ssl_library != self.options["libcurl"].with_ssl: - raise ConanInvalidConfiguration("cpr requires libcurl to be built with the option with_ssl='{}'.".format(self.options.get_safe('ssl'))) - - if self.settings.compiler == "Visual Studio" and self.options.shared and "MT" in self.settings.compiler.runtime: - raise ConanInvalidConfiguration("Visual Studio build for shared library with MT runtime is not supported") - - def build(self): self._patch_sources() cmake = self._configure_cmake() @@ -230,6 +226,15 @@ def package(self): self.copy(pattern="LICENSE", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): self.cpp_info.libs = ["cpr"] + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + + self.cpp_info.set_property("cmake_target_name", "cpr::cpr") + + self.cpp_info.names["cmake_find_package"] = "cpr" + self.cpp_info.names["cmake_find_package_multi"] = "cpr" diff --git a/recipes/cpr/all/patches/001-fix-curl-define.patch b/recipes/cpr/all/patches/001-fix-curl-define.patch deleted file mode 100644 index d302777daf454..0000000000000 --- a/recipes/cpr/all/patches/001-fix-curl-define.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/cpr/error.cpp b/cpr/error.cpp -index 713cb10..ca8d09b 100644 ---- a/cpr/error.cpp -+++ b/cpr/error.cpp -@@ -38,8 +38,8 @@ ErrorCode Error::getErrorCodeForCurlError(std::int32_t curl_code) { - return ErrorCode::SSL_LOCAL_CERTIFICATE_ERROR; - case CURLE_SSL_CIPHER: - return ErrorCode::GENERIC_SSL_ERROR; -- case CURLE_SSL_CACERT: -- return ErrorCode::SSL_CACERT_ERROR; -+ //case CURLE_SSL_CACERT: // It's same value as CURLE_PEER_FAILED_VERIFICATION -+ // return ErrorCode::SSL_CACERT_ERROR; - case CURLE_USE_SSL_FAILED: - return ErrorCode::GENERIC_SSL_ERROR; - case CURLE_SSL_ENGINE_INITFAILED: diff --git a/recipes/cpr/all/patches/001-1.4.0-create-install.patch b/recipes/cpr/all/patches/002-1.4.0-create-install.patch similarity index 100% rename from recipes/cpr/all/patches/001-1.4.0-create-install.patch rename to recipes/cpr/all/patches/002-1.4.0-create-install.patch diff --git a/recipes/cpr/all/patches/002-create-install.patch b/recipes/cpr/all/patches/002-create-install.patch deleted file mode 100644 index 4bb70f090d351..0000000000000 --- a/recipes/cpr/all/patches/002-create-install.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- cpr/CMakeLists.txt -+++ cpr/CMakeLists.txt -@@ -45,3 +45,11 @@ - message(STATUS "Using CURL_LIBRARIES: ${CURL_LIBRARIES}.") - target_link_libraries(${CPR_LIBRARIES} - ${CURL_LIBRARIES}) -+ -+include(GNUInstallDirs) -+install(TARGETS cpr -+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" -+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" -+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" -+) -+install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/cpr" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") diff --git a/recipes/cpr/all/patches/002-1.4.0-zlib-use-target.patch b/recipes/cpr/all/patches/003-1.4.0-curl-use-target.patch similarity index 100% rename from recipes/cpr/all/patches/002-1.4.0-zlib-use-target.patch rename to recipes/cpr/all/patches/003-1.4.0-curl-use-target.patch diff --git a/recipes/cpr/all/patches/003-zlib-use-target.patch b/recipes/cpr/all/patches/003-zlib-use-target.patch deleted file mode 100644 index d8d5ca9d6fe8d..0000000000000 --- a/recipes/cpr/all/patches/003-zlib-use-target.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/cpr/CMakeLists.txt b/cpr/CMakeLists.txt -index 48f4ee1..8793573 100644 ---- a/cpr/CMakeLists.txt -+++ b/cpr/CMakeLists.txt -@@ -43,8 +43,8 @@ add_library(${CPR_LIBRARIES} - "${CPR_INCLUDE_DIRS}/cpr/ssl_options.h") - - message(STATUS "Using CURL_LIBRARIES: ${CURL_LIBRARIES}.") --target_link_libraries(${CPR_LIBRARIES} -- ${CURL_LIBRARIES}) -+target_link_libraries(cpr -+ PUBLIC CURL::CURL) - - include(GNUInstallDirs) - install(TARGETS cpr diff --git a/recipes/cpr/all/patches/003-1.4.0-curl-global-scope.patch b/recipes/cpr/all/patches/004-1.4.0-curl-global-scope.patch similarity index 100% rename from recipes/cpr/all/patches/003-1.4.0-curl-global-scope.patch rename to recipes/cpr/all/patches/004-1.4.0-curl-global-scope.patch diff --git a/recipes/cpr/all/patches/004-curl-global-scope.patch b/recipes/cpr/all/patches/004-curl-global-scope.patch deleted file mode 100644 index a35fd846182c5..0000000000000 --- a/recipes/cpr/all/patches/004-curl-global-scope.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index ea4f46a..6d9516a 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -69,7 +69,8 @@ if(BUILD_CPR_TESTS) - enable_testing() - endif() - --add_subdirectory(opt) -+# add_subdirectory(opt) # With Conan, none of this is used -+find_package(CURL) - add_subdirectory(cpr) - if(BUILD_CPR_TESTS) - add_subdirectory(test) diff --git a/recipes/cpr/all/patches/005-fix-curl-components.patch b/recipes/cpr/all/patches/005-1.5.2-fix-curl-components.patch similarity index 100% rename from recipes/cpr/all/patches/005-fix-curl-components.patch rename to recipes/cpr/all/patches/005-1.5.2-fix-curl-components.patch diff --git a/recipes/cpr/all/patches/008-fix-curl-components.patch b/recipes/cpr/all/patches/005-1.6.2-fix-curl-components.patch similarity index 100% rename from recipes/cpr/all/patches/008-fix-curl-components.patch rename to recipes/cpr/all/patches/005-1.6.2-fix-curl-components.patch diff --git a/recipes/cpr/all/patches/005-1.7.2-fix-curl-components.patch b/recipes/cpr/all/patches/005-1.7.2-fix-curl-components.patch new file mode 100644 index 0000000000000..c1964e9affa40 --- /dev/null +++ b/recipes/cpr/all/patches/005-1.7.2-fix-curl-components.patch @@ -0,0 +1,19 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -143,6 +143,8 @@ endif() + + # Curl configuration + if(CPR_FORCE_USE_SYSTEM_CURL) ++ find_package(CURL REQUIRED) ++ if(0) + if(CPR_ENABLE_SSL) + find_package(CURL COMPONENTS HTTP HTTPS SSL) + if(CURL_FOUND) +@@ -167,6 +169,7 @@ if(CPR_FORCE_USE_SYSTEM_CURL) + message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") + endif() + endif() ++ endif() + else() + message(STATUS "Configuring build in curl...") + diff --git a/recipes/cpr/all/patches/005-1.8.1-fix-curl-components.patch b/recipes/cpr/all/patches/005-1.8.1-fix-curl-components.patch new file mode 100644 index 0000000000000..4cab4c9e85382 --- /dev/null +++ b/recipes/cpr/all/patches/005-1.8.1-fix-curl-components.patch @@ -0,0 +1,55 @@ +diff --git a/a/CMakeLists.txt b/b/CMakeLists.txt +index 6df3663..9317f97 100644 +--- a/a/CMakeLists.txt ++++ b/b/CMakeLists.txt +@@ -156,6 +156,8 @@ endif() + + # Curl configuration + if(CPR_FORCE_USE_SYSTEM_CURL) ++ find_package(CURL REQUIRED) ++ if(0) + if(CPR_ENABLE_SSL) + find_package(CURL COMPONENTS HTTP HTTPS) + if(CURL_FOUND) +@@ -180,6 +182,7 @@ if(CPR_FORCE_USE_SYSTEM_CURL) + message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") + endif() + endif() ++ endif() + else() + message(STATUS "Configuring build in curl...") + +@@ -251,7 +254,7 @@ else() + if(BUILD_CURL_EXE) + set_property(TARGET curl PROPERTY FOLDER "external") + endif() +- ++ + set_property(TARGET libcurl PROPERTY FOLDER "external") + endif() + +@@ -279,13 +282,13 @@ if(CPR_BUILD_TESTS) + FetchContent_MakeAvailable(googletest) + + restore_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP) +- ++ + add_library(gtest_int INTERFACE) + target_link_libraries(gtest_int INTERFACE gtest) + target_include_directories(gtest_int INTERFACE ${googletest_SOURCE_DIR}/include) + + add_library(GTest::GTest ALIAS gtest_int) +- ++ + # Group under the "tests/gtest" project folder in IDEs such as Visual Studio. + set_property(TARGET gtest PROPERTY FOLDER "tests/gtest") + set_property(TARGET gtest_main PROPERTY FOLDER "tests/gtest") +@@ -314,7 +317,7 @@ if(CPR_BUILD_TESTS) + # Disable linting for mongoose + clear_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP) + +- FetchContent_Declare(mongoose ++ FetchContent_Declare(mongoose + URL https://github.com/cesanta/mongoose/archive/6.18.tar.gz + URL_HASH SHA256=f5c10346abc9c72f7cac7885d853ca064fb09aad57580433941a8fd7a3543769 # the hash for 6.18.tar.gz + USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress diff --git a/recipes/cpr/all/patches/005-1.9.0-fix-curl-components.patch b/recipes/cpr/all/patches/005-1.9.0-fix-curl-components.patch new file mode 100644 index 0000000000000..f20781e9ef90e --- /dev/null +++ b/recipes/cpr/all/patches/005-1.9.0-fix-curl-components.patch @@ -0,0 +1,21 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cb7c5f0..c6c19e4 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -162,6 +162,8 @@ endif() + + # Curl configuration + if(CPR_FORCE_USE_SYSTEM_CURL) ++ find_package(CURL REQUIRED) ++ if(0) + if(CPR_ENABLE_SSL) + find_package(CURL COMPONENTS HTTP HTTPS) + if(CURL_FOUND) +@@ -186,6 +188,7 @@ if(CPR_FORCE_USE_SYSTEM_CURL) + message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") + endif() + endif() ++ endif() + else() + message(STATUS "Configuring build in curl...") + diff --git a/recipes/cpr/all/patches/006-fix-curl-components.patch b/recipes/cpr/all/patches/006-fix-curl-components.patch deleted file mode 100644 index 9f469f556bddc..0000000000000 --- a/recipes/cpr/all/patches/006-fix-curl-components.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -112,29 +112,11 @@ - - # Curl configuration - if(CPR_FORCE_USE_SYSTEM_CURL) -- if(CPR_ENABLE_SSL) -- find_package(CURL COMPONENTS HTTP HTTPS SSL) -- if(CURL_FOUND) -- message(STATUS "Curl ${CURL_VERSION_STRING} found on this system.") -- # To be able to load certificates under Windows when using OpenSSL: -- if(CMAKE_USE_OPENSSL AND WIN32 AND (NOT (CURL_VERSION_STRING VERSION_GREATER_EQUAL "7.71.0"))) -- message(FATAL_ERROR "Your system curl version (${CURL_VERSION_STRING}) is too old to support OpenSSL on Windows which requires curl >= 7.71.0. Update your curl version, use WinSSL, disable SSL or use the build in version of curl.") -- endif() -- else() -- find_package(CURL COMPONENTS HTTP) -- if(CURL_FOUND) -- message(FATAL_ERROR "Curl found on this system but WITHOUT HTTPS/SSL support. Either disable SSL by setting CPR_ENABLE_SSL to OFF or use the build in version of curl by setting CPR_FORCE_USE_SYSTEM_CURL to OFF.") -- else() -- message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") -- endif() -- endif() -+ find_package(CURL REQUIRED) -+ if(CURL_FOUND) -+ message(STATUS "Curl found on this system.") - else() -- find_package(CURL COMPONENTS HTTP) -- if(CURL_FOUND) -- message(STATUS "Curl found on this system.") -- else() -- message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") -- endif() -+ message(FATAL_ERROR "Curl not found on this system. To use the build in version set CPR_FORCE_USE_SYSTEM_CURL to OFF.") - endif() - else() - message(STATUS "Configuring build in curl...") diff --git a/recipes/cpr/all/patches/007-fix-dll-install.patch b/recipes/cpr/all/patches/007-fix-dll-install.patch new file mode 100644 index 0000000000000..74a7b3690c9c7 --- /dev/null +++ b/recipes/cpr/all/patches/007-fix-dll-install.patch @@ -0,0 +1,18 @@ +--- a/cpr/CMakeLists.txt ++++ b/cpr/CMakeLists.txt +@@ -36,6 +36,7 @@ include(GNUInstallDirs) + if(CPR_FORCE_USE_SYSTEM_CURL) + install(TARGETS cpr + EXPORT cprTargets ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +@@ -62,6 +63,7 @@ if(CPR_FORCE_USE_SYSTEM_CURL) + + else() + install(TARGETS cpr ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() diff --git a/recipes/cpr/all/patches/007-patch-sanitizer.patch b/recipes/cpr/all/patches/007-patch-sanitizer.patch deleted file mode 100644 index ecb7d53ae55e8..0000000000000 --- a/recipes/cpr/all/patches/007-patch-sanitizer.patch +++ /dev/null @@ -1,39 +0,0 @@ ---- a/cmake/sanitizer.cmake -+++ b/cmake/sanitizer.cmake -@@ -16,6 +16,7 @@ if(THREAD_SANITIZER_AVAILABLE) - endif() - set(CMAKE_C_FLAGS_THREADSAN "${CMAKE_C_FLAGS_DEBUG} ${THREAD_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C compiler during thread sanitizer builds." FORCE) - set(CMAKE_CXX_FLAGS_THREADSAN "${CMAKE_CXX_FLAGS_DEBUG} ${THREAD_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C++ compiler during thread sanitizer builds." FORCE) -+set(CMAKE_SHARED_LINKER_FLAGS_THREADSAN "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" "Flags used for the linker during thread sanitizer builds" FORCE) - - # Address sanitizer - set(ADDR_SAN_FLAGS "-fsanitize=address") -@@ -29,6 +30,7 @@ if(ADDRESS_SANITIZER_AVAILABLE) - endif() - set(CMAKE_C_FLAGS_ADDRSAN "${CMAKE_C_FLAGS_DEBUG} ${ADDR_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C compiler during address sanitizer builds." FORCE) - set(CMAKE_CXX_FLAGS_ADDRSAN "${CMAKE_CXX_FLAGS_DEBUG} ${ADDR_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C++ compiler during address sanitizer builds." FORCE) -+set(CMAKE_SHARED_LINKER_FLAGS_ADDRSAN "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" "Flags used for the linker during address sanitizer builds" FORCE) - - # Leak sanitizer - set(LEAK_SAN_FLAGS "-fsanitize=leak") -@@ -39,6 +41,7 @@ if(LEAK_SANITIZER_AVAILABLE) - endif() - set(CMAKE_C_FLAGS_LEAKSAN "${CMAKE_C_FLAGS_DEBUG} ${LEAK_SAN_FLAGS} -fno-omit-frame-pointer" CACHE INTERNAL "Flags used by the C compiler during leak sanitizer builds." FORCE) - set(CMAKE_CXX_FLAGS_LEAKSAN "${CMAKE_CXX_FLAGS_DEBUG} ${LEAK_SAN_FLAGS} -fno-omit-frame-pointer" CACHE INTERNAL "Flags used by the C++ compiler during leak sanitizer builds." FORCE) -+set(CMAKE_SHARED_LINKER_FLAGS_LEAKSAN "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" "Flags used for the linker during leak sanitizer builds" FORCE) - - # Undefined behavior sanitizer - set(UDEF_SAN_FLAGS "-fsanitize=undefined") -@@ -49,6 +52,7 @@ if(UNDEFINED_BEHAVIOUR_SANITIZER_AVAILABLE) - endif() - set(CMAKE_C_FLAGS_UDEFSAN "${CMAKE_C_FLAGS_DEBUG} ${UDEF_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C compiler during undefined behaviour sanitizer builds." FORCE) - set(CMAKE_CXX_FLAGS_UDEFSAN "${CMAKE_CXX_FLAGS_DEBUG} ${UDEF_SAN_FLAGS}" CACHE INTERNAL "Flags used by the C++ compiler during undefined behaviour sanitizer builds." FORCE) -+set(CMAKE_SHARED_LINKER_FLAGS_UDEFSAN "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" "Flags used for the linker during undefined behaviour sanitizer builds" FORCE) - - # All sanitizer (without thread sanitizer) - if(NOT ALL_SAN_FLAGS STREQUAL "") -@@ -63,3 +67,4 @@ endif() - - set(CMAKE_C_FLAGS_ALLSAN "${CMAKE_C_FLAGS_DEBUG} ${ALL_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C compiler during most possible sanitizer builds." FORCE) - set(CMAKE_CXX_FLAGS_ALLSAN "${CMAKE_CXX_FLAGS_DEBUG} ${ALL_SAN_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE INTERNAL "Flags used by the C++ compiler during most possible sanitizer builds." FORCE) -+set(CMAKE_SHARED_LINKER_FLAGS_ALLSAN "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" "Flags used for the linker during most possible sanitizer builds" FORCE) diff --git a/recipes/cpr/all/test_package/CMakeLists.txt b/recipes/cpr/all/test_package/CMakeLists.txt index e719a6c96c448..c003582670c36 100644 --- a/recipes/cpr/all/test_package/CMakeLists.txt +++ b/recipes/cpr/all/test_package/CMakeLists.txt @@ -2,11 +2,10 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -find_package(cpr) - -set(CMAKE_CXX_STANDARD 11) +find_package(cpr REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} cpr::cpr) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) diff --git a/recipes/cpr/all/test_package/conanfile.py b/recipes/cpr/all/test_package/conanfile.py index 3d3f26e961ad6..2490acfa82ff8 100644 --- a/recipes/cpr/all/test_package/conanfile.py +++ b/recipes/cpr/all/test_package/conanfile.py @@ -1,10 +1,11 @@ from conans import ConanFile, CMake +from conan.tools.build import cross_building import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,5 +13,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpr/config.yml b/recipes/cpr/config.yml index 4b27e15b26e7f..3ceff74829cd9 100644 --- a/recipes/cpr/config.yml +++ b/recipes/cpr/config.yml @@ -1,13 +1,13 @@ versions: - "1.3.0": + "1.9.0": folder: all - "1.4.0": + "1.8.1": folder: all - "1.5.0": + "1.7.2": folder: all - "1.5.2": + "1.6.2": folder: all - "1.6.0": + "1.5.2": folder: all - "1.6.2": + "1.4.0": folder: all diff --git a/recipes/cprocessing/all/conandata.yml b/recipes/cprocessing/all/conandata.yml new file mode 100644 index 0000000000000..2dad81caaa9dc --- /dev/null +++ b/recipes/cprocessing/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.4.5": + url: "https://github.com/maksmakuta/CProcessing/archive/25d8888b4adde7b6b1f1e1f67226e5d9778db13f.tar.gz" + sha256: "a003f5cc368a995c095c66a12ebf7fc81d3f09eef9a27e485e32520c581fbf21" diff --git a/recipes/cprocessing/all/conanfile.py b/recipes/cprocessing/all/conanfile.py new file mode 100644 index 0000000000000..f1d8d20922d76 --- /dev/null +++ b/recipes/cprocessing/all/conanfile.py @@ -0,0 +1,84 @@ +from conans import ConanFile, tools +from conans.tools import ConanInvalidConfiguration +import os +import re + +required_conan_version = ">=1.43.0" + +class CProcessingConan(ConanFile): + name = "cprocessing" + description = "Processsing programming for C++ " + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/maksmakuta/CProcessing" + topics = ("processing", "opengl", "sketch") + settings = "os", "arch", "compiler", "build_type" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "9", + "Visual Studio": "16.2", + "msvc": "19.22", + "clang": "10", + "apple-clang": "11" + } + + def requirements(self): + self.requires("glfw/3.3.7") + self.requires("glm/0.9.9.8") + self.requires("glew/2.2.0") + self.requires("stb/cci.20210910") + self.requires("opengl/system") + + def package_id(self): + self.info.header_only() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 20) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + compiler_version = str(self.settings.compiler.version) + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if not minimum_version: + self.output.warn("{} requires C++20. Your compiler is unknown. Assuming it supports C++20.".format(self.name)) + elif lazy_lt_semver(compiler_version, minimum_version): + raise ConanInvalidConfiguration("{} requires some C++20 features,".format(self.name)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, + destination=self._source_subfolder) + + def build(self): + tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "PImage.h"), + "stb/stb_image.h", + "stb_image.h") + + def package(self): + self.copy("*.h", "include", os.path.join(self._source_subfolder, "lib")) + + # Extract the License/s from README.md to a file + tmp = tools.load(os.path.join(self._source_subfolder, "README.md")) + license_contents = re.search("(## Author.*)", tmp, re.DOTALL)[1] + tools.save(os.path.join(self.package_folder, "licenses", "LICENSE.md"), license_contents) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "CProcessing") + self.cpp_info.set_property("cmake_target_name", "CProcessing::CProcessing") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "CProcessing" + self.cpp_info.filenames["cmake_find_package_multi"] = "CProcessing" + self.cpp_info.names["cmake_find_package"] = "CProcessing" + self.cpp_info.names["cmake_find_package_multi"] = "CProcessing" diff --git a/recipes/cprocessing/all/test_package/CMakeLists.txt b/recipes/cprocessing/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..05121b9bfe414 --- /dev/null +++ b/recipes/cprocessing/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CProcessing REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} CProcessing::CProcessing) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) diff --git a/recipes/cprocessing/all/test_package/conanfile.py b/recipes/cprocessing/all/test_package/conanfile.py new file mode 100644 index 0000000000000..51cf79f1d6887 --- /dev/null +++ b/recipes/cprocessing/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + test_file = os.path.join("bin", "test_package") + if self.settings.os == "Windows": + test_file += ".exe" + assert os.path.exists(test_file) diff --git a/recipes/cprocessing/all/test_package/test_package.cpp b/recipes/cprocessing/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..479e221b8ea06 --- /dev/null +++ b/recipes/cprocessing/all/test_package/test_package.cpp @@ -0,0 +1,72 @@ +/** + * Starfield Simulation + * Author: Maks Makuta + * URLs: + * Part 1: https://youtube.com/shorts/Bk5O7-3xIfw + * Part 2: https://youtube.com/shorts/IS6_apBewlI + */ + +#include + +float speed; + +class Star{ + private: + float x,y,z,pz; + public: + Star(){ + this->x = random(-width,width); + this->y = random(-height,height); + this->z = random(width); + this->pz = z; + } + + void update(){ + this->z -= speed; + if(this->z < 1.f){ + this->z = width; + this->x = random(-width,width); + this->y = random(-height,height); + this->pz = z; + } + } + + void show(){ + fill(255); + + float sx = map(this->x / this->z,0,1,0, width); + float sy = map(this->y / this->z,0,1,0,height); + + float r = map(this->z,0,width,16,0); + circle(sx,sy,r); + + float zx = map(this->x / this->pz,0,1,0, width); + float zy = map(this->y / this->pz,0,1,0,height); + + this->pz = z; + + stroke(255); + line(zx,zy,sx,sy); + } + +}; + +std::vector stars; + +void setup(){ + size(640,480); + for(int a = 0;a < 100;a++) + stars.push_back(Star()); +} + +void draw(){ + speed = map(mouseX,0,width,0.f,50.f); + background(0); + translate(width/2,height/2); + + for(int a = 0;a < stars.size();a++){ + stars[a].update(); + stars[a].show(); + } + +} diff --git a/recipes/cprocessing/config.yml b/recipes/cprocessing/config.yml new file mode 100644 index 0000000000000..9e9d42f66ffae --- /dev/null +++ b/recipes/cprocessing/config.yml @@ -0,0 +1,3 @@ +versions: + "1.4.5": + folder: all diff --git a/recipes/cpu_features/all/CMakeLists.txt b/recipes/cpu_features/all/CMakeLists.txt deleted file mode 100644 index 6c05c4e9c38e4..0000000000000 --- a/recipes/cpu_features/all/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/cpu_features/all/conandata.yml b/recipes/cpu_features/all/conandata.yml index 0016eef085e8f..a6a49730a3d42 100644 --- a/recipes/cpu_features/all/conandata.yml +++ b/recipes/cpu_features/all/conandata.yml @@ -1,4 +1,12 @@ sources: + "0.7.0": + url: "https://github.com/google/cpu_features/archive/refs/tags/v0.7.0.tar.gz" + sha256: "df80d9439abf741c7d2fdcdfd2d26528b136e6c52976be8bd0cd5e45a27262c0" "0.6.0": url: "https://github.com/google/cpu_features/archive/refs/tags/v0.6.0.tar.gz" sha256: "95a1cf6f24948031df114798a97eea2a71143bd38a4d07d9a758dda3924c1932" +patches: + "0.7.0": + - patch_file: "patches/0.7.0-0001-support-aarch64-macos.patch" + "0.6.0": + - patch_file: "patches/0.6.0-0001-fix-bundle-install.patch" diff --git a/recipes/cpu_features/all/conanfile.py b/recipes/cpu_features/all/conanfile.py index 6abca552051fe..67333f1731762 100644 --- a/recipes/cpu_features/all/conanfile.py +++ b/recipes/cpu_features/all/conanfile.py @@ -1,5 +1,11 @@ +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.53.0" class CpuFeaturesConan(ConanFile): @@ -8,65 +14,78 @@ class CpuFeaturesConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/google/cpu_features" description = "A cross platform C99 library to get cpu features at runtime." - topics = ("conan", "cpu", "features", "cpuid") - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False]} - default_options = {"shared": False, - "fPIC": True} - exports_sources = ["CMakeLists.txt"] - generators = "cmake", - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + topics = ("cpu", "features", "cpuid") - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - def configure(self): - if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - def _configure_cmake(self): - if self._cmake: - return self._cmake - cmake = CMake(self) - cmake.definitions["BUILD_PIC"] = self.options.get_safe("fPIC", True) - cmake.configure() - self._cmake = cmake - return self._cmake + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.compiler.rm_safe("cppstd") + self.settings.compiler.rm_safe("libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) < "0.7.0": + tc.variables["BUILD_PIC"] = self.options.get_safe("fPIC", True) + if Version(self.version) >= "0.7.0": + tc.variables["BUILD_TESTING"] = False + # TODO: should be handled by CMake helper + if is_apple_os(self) and self.settings.arch in ["armv8", "armv8_32", "armv8.3"]: + tc.variables["CMAKE_SYSTEM_PROCESSOR"] = "aarch64" + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.generate() def build(self): - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "CpuFeatures") + self.cpp_info.set_property("cmake_target_name", "CpuFeatures::cpu_features") + + # TODO: back to global scope once cmake_find_package* generators removed + self.cpp_info.components["libcpu_features"].libs = ["cpu_features"] + self.cpp_info.components["libcpu_features"].includedirs = [os.path.join("include", "cpu_features")] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["libcpu_features"].system_libs = ["dl"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "CpuFeatures" self.cpp_info.names["cmake_find_package_multi"] = "CpuFeatures" self.cpp_info.components["libcpu_features"].names["cmake_find_package"] = "cpu_features" self.cpp_info.components["libcpu_features"].names["cmake_find_package_multi"] = "cpu_features" - self.cpp_info.components["libcpu_features"].libs = ["cpu_features"] - self.cpp_info.components["libcpu_features"].includedirs = [os.path.join("include", "cpu_features")] - if self.settings.os == "Linux": - self.cpp_info.components["libcpu_features"].system_libs = ["dl"] + self.cpp_info.components["libcpu_features"].set_property("cmake_target_name", "CpuFeatures::cpu_features") bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) diff --git a/recipes/cpu_features/all/patches/0.6.0-0001-fix-bundle-install.patch b/recipes/cpu_features/all/patches/0.6.0-0001-fix-bundle-install.patch new file mode 100644 index 0000000000000..59baf15e395dd --- /dev/null +++ b/recipes/cpu_features/all/patches/0.6.0-0001-fix-bundle-install.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -233,6 +233,7 @@ install(TARGETS cpu_features list_cpu_features + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + install(EXPORT CpuFeaturesTargets + NAMESPACE CpuFeatures:: diff --git a/recipes/cpu_features/all/patches/0.7.0-0001-support-aarch64-macos.patch b/recipes/cpu_features/all/patches/0.7.0-0001-support-aarch64-macos.patch new file mode 100644 index 0000000000000..a498640a584fc --- /dev/null +++ b/recipes/cpu_features/all/patches/0.7.0-0001-support-aarch64-macos.patch @@ -0,0 +1,288 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 81451d4..99f2512 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -135,7 +135,7 @@ target_link_libraries(cpu_features PUBLIC ${CMAKE_DL_LIBS}) + target_include_directories(cpu_features + PUBLIC $ + ) +-if(PROCESSOR_IS_X86) ++if(PROCESSOR_IS_X86 OR PROCESSOR_IS_AARCH64) + if(APPLE) + target_compile_definitions(cpu_features PRIVATE HAVE_SYSCTLBYNAME) + endif() +diff --git a/include/cpu_features_macros.h b/include/cpu_features_macros.h +index 6a2f76a..5faae4d 100644 +--- a/include/cpu_features_macros.h ++++ b/include/cpu_features_macros.h +@@ -39,7 +39,7 @@ + #define CPU_FEATURES_ARCH_ARM + #endif + +-#if defined(__aarch64__) ++#if defined(__aarch64__) || defined(__arm64__) + #define CPU_FEATURES_ARCH_AARCH64 + #endif + +diff --git b/include/impl_aarch64__base_implementation.inl b/include/impl_aarch64__base_implementation.inl +new file mode 100644 +index 0000000..a8918e6 +--- /dev/null ++++ b/include/impl_aarch64__base_implementation.inl +@@ -0,0 +1,84 @@ ++// Copyright 2021 Google LLC ++// ++// Licensed under the Apache License, Version 2.0 (the "License"); ++// you may not use this file except in compliance with the License. ++// You may obtain a copy of the License at ++// ++// http://www.apache.org/licenses/LICENSE-2.0 ++// ++// Unless required by applicable law or agreed to in writing, software ++// distributed under the License is distributed on an "AS IS" BASIS, ++// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++// See the License for the specific language governing permissions and ++// limitations under the License. ++ ++#include ++ ++#include "cpuinfo_aarch64.h" ++#include "internal/bit_utils.h" ++#include "internal/filesystem.h" ++#include "internal/stack_line_reader.h" ++#include "internal/string_view.h" ++ ++#if !defined(CPU_FEATURES_ARCH_AARCH64) ++#error "Cannot compile aarch64_base on a non aarch64 platform." ++#endif ++ ++//////////////////////////////////////////////////////////////////////////////// ++// Definitions for introspection. ++//////////////////////////////////////////////////////////////////////////////// ++#define INTROSPECTION_TABLE \ ++ LINE(AARCH64_FP, fp, "fp", AARCH64_HWCAP_FP, 0) \ ++ LINE(AARCH64_ASIMD, asimd, "asimd", AARCH64_HWCAP_ASIMD, 0) \ ++ LINE(AARCH64_EVTSTRM, evtstrm, "evtstrm", AARCH64_HWCAP_EVTSTRM, 0) \ ++ LINE(AARCH64_AES, aes, "aes", AARCH64_HWCAP_AES, 0) \ ++ LINE(AARCH64_PMULL, pmull, "pmull", AARCH64_HWCAP_PMULL, 0) \ ++ LINE(AARCH64_SHA1, sha1, "sha1", AARCH64_HWCAP_SHA1, 0) \ ++ LINE(AARCH64_SHA2, sha2, "sha2", AARCH64_HWCAP_SHA2, 0) \ ++ LINE(AARCH64_CRC32, crc32, "crc32", AARCH64_HWCAP_CRC32, 0) \ ++ LINE(AARCH64_ATOMICS, atomics, "atomics", AARCH64_HWCAP_ATOMICS, 0) \ ++ LINE(AARCH64_FPHP, fphp, "fphp", AARCH64_HWCAP_FPHP, 0) \ ++ LINE(AARCH64_ASIMDHP, asimdhp, "asimdhp", AARCH64_HWCAP_ASIMDHP, 0) \ ++ LINE(AARCH64_CPUID, cpuid, "cpuid", AARCH64_HWCAP_CPUID, 0) \ ++ LINE(AARCH64_ASIMDRDM, asimdrdm, "asimdrdm", AARCH64_HWCAP_ASIMDRDM, 0) \ ++ LINE(AARCH64_JSCVT, jscvt, "jscvt", AARCH64_HWCAP_JSCVT, 0) \ ++ LINE(AARCH64_FCMA, fcma, "fcma", AARCH64_HWCAP_FCMA, 0) \ ++ LINE(AARCH64_LRCPC, lrcpc, "lrcpc", AARCH64_HWCAP_LRCPC, 0) \ ++ LINE(AARCH64_DCPOP, dcpop, "dcpop", AARCH64_HWCAP_DCPOP, 0) \ ++ LINE(AARCH64_SHA3, sha3, "sha3", AARCH64_HWCAP_SHA3, 0) \ ++ LINE(AARCH64_SM3, sm3, "sm3", AARCH64_HWCAP_SM3, 0) \ ++ LINE(AARCH64_SM4, sm4, "sm4", AARCH64_HWCAP_SM4, 0) \ ++ LINE(AARCH64_ASIMDDP, asimddp, "asimddp", AARCH64_HWCAP_ASIMDDP, 0) \ ++ LINE(AARCH64_SHA512, sha512, "sha512", AARCH64_HWCAP_SHA512, 0) \ ++ LINE(AARCH64_SVE, sve, "sve", AARCH64_HWCAP_SVE, 0) \ ++ LINE(AARCH64_ASIMDFHM, asimdfhm, "asimdfhm", AARCH64_HWCAP_ASIMDFHM, 0) \ ++ LINE(AARCH64_DIT, dit, "dit", AARCH64_HWCAP_DIT, 0) \ ++ LINE(AARCH64_USCAT, uscat, "uscat", AARCH64_HWCAP_USCAT, 0) \ ++ LINE(AARCH64_ILRCPC, ilrcpc, "ilrcpc", AARCH64_HWCAP_ILRCPC, 0) \ ++ LINE(AARCH64_FLAGM, flagm, "flagm", AARCH64_HWCAP_FLAGM, 0) \ ++ LINE(AARCH64_SSBS, ssbs, "ssbs", AARCH64_HWCAP_SSBS, 0) \ ++ LINE(AARCH64_SB, sb, "sb", AARCH64_HWCAP_SB, 0) \ ++ LINE(AARCH64_PACA, paca, "paca", AARCH64_HWCAP_PACA, 0) \ ++ LINE(AARCH64_PACG, pacg, "pacg", AARCH64_HWCAP_PACG, 0) \ ++ LINE(AARCH64_DCPODP, dcpodp, "dcpodp", 0, AARCH64_HWCAP2_DCPODP) \ ++ LINE(AARCH64_SVE2, sve2, "sve2", 0, AARCH64_HWCAP2_SVE2) \ ++ LINE(AARCH64_SVEAES, sveaes, "sveaes", 0, AARCH64_HWCAP2_SVEAES) \ ++ LINE(AARCH64_SVEPMULL, svepmull, "svepmull", 0, AARCH64_HWCAP2_SVEPMULL) \ ++ LINE(AARCH64_SVEBITPERM, svebitperm, "svebitperm", 0, \ ++ AARCH64_HWCAP2_SVEBITPERM) \ ++ LINE(AARCH64_SVESHA3, svesha3, "svesha3", 0, AARCH64_HWCAP2_SVESHA3) \ ++ LINE(AARCH64_SVESM4, svesm4, "svesm4", 0, AARCH64_HWCAP2_SVESM4) \ ++ LINE(AARCH64_FLAGM2, flagm2, "flagm2", 0, AARCH64_HWCAP2_FLAGM2) \ ++ LINE(AARCH64_FRINT, frint, "frint", 0, AARCH64_HWCAP2_FRINT) \ ++ LINE(AARCH64_SVEI8MM, svei8mm, "svei8mm", 0, AARCH64_HWCAP2_SVEI8MM) \ ++ LINE(AARCH64_SVEF32MM, svef32mm, "svef32mm", 0, AARCH64_HWCAP2_SVEF32MM) \ ++ LINE(AARCH64_SVEF64MM, svef64mm, "svef64mm", 0, AARCH64_HWCAP2_SVEF64MM) \ ++ LINE(AARCH64_SVEBF16, svebf16, "svebf16", 0, AARCH64_HWCAP2_SVEBF16) \ ++ LINE(AARCH64_I8MM, i8mm, "i8mm", 0, AARCH64_HWCAP2_I8MM) \ ++ LINE(AARCH64_BF16, bf16, "bf16", 0, AARCH64_HWCAP2_BF16) \ ++ LINE(AARCH64_DGH, dgh, "dgh", 0, AARCH64_HWCAP2_DGH) \ ++ LINE(AARCH64_RNG, rng, "rng", 0, AARCH64_HWCAP2_RNG) \ ++ LINE(AARCH64_BTI, bti, "bti", 0, AARCH64_HWCAP2_BTI) \ ++ LINE(AARCH64_MTE, mte, "mte", 0, AARCH64_HWCAP2_MTE) ++#define INTROSPECTION_PREFIX Aarch64 ++#define INTROSPECTION_ENUM_PREFIX AARCH64 +diff --git a/src/impl_aarch64_linux_or_android.c b/src/impl_aarch64_linux_or_android.c +index 745beb9..c0a764c 100644 +--- a/src/impl_aarch64_linux_or_android.c ++++ b/src/impl_aarch64_linux_or_android.c +@@ -17,78 +17,7 @@ + #ifdef CPU_FEATURES_ARCH_AARCH64 + #if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID) + +-#include "cpuinfo_aarch64.h" +- +-//////////////////////////////////////////////////////////////////////////////// +-// Definitions for introspection. +-//////////////////////////////////////////////////////////////////////////////// +-#define INTROSPECTION_TABLE \ +- LINE(AARCH64_FP, fp, "fp", AARCH64_HWCAP_FP, 0) \ +- LINE(AARCH64_ASIMD, asimd, "asimd", AARCH64_HWCAP_ASIMD, 0) \ +- LINE(AARCH64_EVTSTRM, evtstrm, "evtstrm", AARCH64_HWCAP_EVTSTRM, 0) \ +- LINE(AARCH64_AES, aes, "aes", AARCH64_HWCAP_AES, 0) \ +- LINE(AARCH64_PMULL, pmull, "pmull", AARCH64_HWCAP_PMULL, 0) \ +- LINE(AARCH64_SHA1, sha1, "sha1", AARCH64_HWCAP_SHA1, 0) \ +- LINE(AARCH64_SHA2, sha2, "sha2", AARCH64_HWCAP_SHA2, 0) \ +- LINE(AARCH64_CRC32, crc32, "crc32", AARCH64_HWCAP_CRC32, 0) \ +- LINE(AARCH64_ATOMICS, atomics, "atomics", AARCH64_HWCAP_ATOMICS, 0) \ +- LINE(AARCH64_FPHP, fphp, "fphp", AARCH64_HWCAP_FPHP, 0) \ +- LINE(AARCH64_ASIMDHP, asimdhp, "asimdhp", AARCH64_HWCAP_ASIMDHP, 0) \ +- LINE(AARCH64_CPUID, cpuid, "cpuid", AARCH64_HWCAP_CPUID, 0) \ +- LINE(AARCH64_ASIMDRDM, asimdrdm, "asimdrdm", AARCH64_HWCAP_ASIMDRDM, 0) \ +- LINE(AARCH64_JSCVT, jscvt, "jscvt", AARCH64_HWCAP_JSCVT, 0) \ +- LINE(AARCH64_FCMA, fcma, "fcma", AARCH64_HWCAP_FCMA, 0) \ +- LINE(AARCH64_LRCPC, lrcpc, "lrcpc", AARCH64_HWCAP_LRCPC, 0) \ +- LINE(AARCH64_DCPOP, dcpop, "dcpop", AARCH64_HWCAP_DCPOP, 0) \ +- LINE(AARCH64_SHA3, sha3, "sha3", AARCH64_HWCAP_SHA3, 0) \ +- LINE(AARCH64_SM3, sm3, "sm3", AARCH64_HWCAP_SM3, 0) \ +- LINE(AARCH64_SM4, sm4, "sm4", AARCH64_HWCAP_SM4, 0) \ +- LINE(AARCH64_ASIMDDP, asimddp, "asimddp", AARCH64_HWCAP_ASIMDDP, 0) \ +- LINE(AARCH64_SHA512, sha512, "sha512", AARCH64_HWCAP_SHA512, 0) \ +- LINE(AARCH64_SVE, sve, "sve", AARCH64_HWCAP_SVE, 0) \ +- LINE(AARCH64_ASIMDFHM, asimdfhm, "asimdfhm", AARCH64_HWCAP_ASIMDFHM, 0) \ +- LINE(AARCH64_DIT, dit, "dit", AARCH64_HWCAP_DIT, 0) \ +- LINE(AARCH64_USCAT, uscat, "uscat", AARCH64_HWCAP_USCAT, 0) \ +- LINE(AARCH64_ILRCPC, ilrcpc, "ilrcpc", AARCH64_HWCAP_ILRCPC, 0) \ +- LINE(AARCH64_FLAGM, flagm, "flagm", AARCH64_HWCAP_FLAGM, 0) \ +- LINE(AARCH64_SSBS, ssbs, "ssbs", AARCH64_HWCAP_SSBS, 0) \ +- LINE(AARCH64_SB, sb, "sb", AARCH64_HWCAP_SB, 0) \ +- LINE(AARCH64_PACA, paca, "paca", AARCH64_HWCAP_PACA, 0) \ +- LINE(AARCH64_PACG, pacg, "pacg", AARCH64_HWCAP_PACG, 0) \ +- LINE(AARCH64_DCPODP, dcpodp, "dcpodp", 0, AARCH64_HWCAP2_DCPODP) \ +- LINE(AARCH64_SVE2, sve2, "sve2", 0, AARCH64_HWCAP2_SVE2) \ +- LINE(AARCH64_SVEAES, sveaes, "sveaes", 0, AARCH64_HWCAP2_SVEAES) \ +- LINE(AARCH64_SVEPMULL, svepmull, "svepmull", 0, AARCH64_HWCAP2_SVEPMULL) \ +- LINE(AARCH64_SVEBITPERM, svebitperm, "svebitperm", 0, \ +- AARCH64_HWCAP2_SVEBITPERM) \ +- LINE(AARCH64_SVESHA3, svesha3, "svesha3", 0, AARCH64_HWCAP2_SVESHA3) \ +- LINE(AARCH64_SVESM4, svesm4, "svesm4", 0, AARCH64_HWCAP2_SVESM4) \ +- LINE(AARCH64_FLAGM2, flagm2, "flagm2", 0, AARCH64_HWCAP2_FLAGM2) \ +- LINE(AARCH64_FRINT, frint, "frint", 0, AARCH64_HWCAP2_FRINT) \ +- LINE(AARCH64_SVEI8MM, svei8mm, "svei8mm", 0, AARCH64_HWCAP2_SVEI8MM) \ +- LINE(AARCH64_SVEF32MM, svef32mm, "svef32mm", 0, AARCH64_HWCAP2_SVEF32MM) \ +- LINE(AARCH64_SVEF64MM, svef64mm, "svef64mm", 0, AARCH64_HWCAP2_SVEF64MM) \ +- LINE(AARCH64_SVEBF16, svebf16, "svebf16", 0, AARCH64_HWCAP2_SVEBF16) \ +- LINE(AARCH64_I8MM, i8mm, "i8mm", 0, AARCH64_HWCAP2_I8MM) \ +- LINE(AARCH64_BF16, bf16, "bf16", 0, AARCH64_HWCAP2_BF16) \ +- LINE(AARCH64_DGH, dgh, "dgh", 0, AARCH64_HWCAP2_DGH) \ +- LINE(AARCH64_RNG, rng, "rng", 0, AARCH64_HWCAP2_RNG) \ +- LINE(AARCH64_BTI, bti, "bti", 0, AARCH64_HWCAP2_BTI) \ +- LINE(AARCH64_MTE, mte, "mte", 0, AARCH64_HWCAP2_MTE) +-#define INTROSPECTION_PREFIX Aarch64 +-#define INTROSPECTION_ENUM_PREFIX AARCH64 +-#include "define_introspection_and_hwcaps.inl" +- +-//////////////////////////////////////////////////////////////////////////////// +-// Implementation. +-//////////////////////////////////////////////////////////////////////////////// +- +-#include +- +-#include "internal/bit_utils.h" +-#include "internal/filesystem.h" +-#include "internal/stack_line_reader.h" +-#include "internal/string_view.h" ++#include "impl_aarch64__base_implementation.inl" + + static bool HandleAarch64Line(const LineResult result, + Aarch64Info* const info) { +diff --git b/src/impl_aarch64_macos_or_iphone.c b/src/impl_aarch64_macos_or_iphone.c +new file mode 100644 +index 0000000..4dd1db7 +--- /dev/null ++++ b/src/impl_aarch64_macos_or_iphone.c +@@ -0,0 +1,82 @@ ++// Copyright 2021 Google LLC ++// ++// Licensed under the Apache License, Version 2.0 (the "License"); ++// you may not use this file except in compliance with the License. ++// You may obtain a copy of the License at ++// ++// http://www.apache.org/licenses/LICENSE-2.0 ++// ++// Unless required by applicable law or agreed to in writing, software ++// distributed under the License is distributed on an "AS IS" BASIS, ++// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++// See the License for the specific language governing permissions and ++// limitations under the License. ++ ++#include "cpu_features_macros.h" ++ ++#ifdef CPU_FEATURES_ARCH_AARCH64 ++#if defined(CPU_FEATURES_OS_MACOS) || defined(CPU_FEATURES_OS_IPHONE) ++ ++#include "impl_aarch64__base_implementation.inl" ++#include "define_introspection_and_hwcaps.inl" ++ ++#if !defined(HAVE_SYSCTLBYNAME) ++#error "Darwin needs support for sysctlbyname" ++#endif ++#include ++ ++#if defined(CPU_FEATURES_MOCK_SYSCTL_AARCH64) ++extern bool GetDarwinSysCtlByName(const char*); ++extern int GetDarwinSysCtlByNameValue(const char* name); ++#else ++static int GetDarwinSysCtlByNameValue(const char* name) { ++ int enabled; ++ size_t enabled_len = sizeof(enabled); ++ const int failure = sysctlbyname(name, &enabled, &enabled_len, NULL, 0); ++ return failure ? 0 : enabled; ++} ++ ++static bool GetDarwinSysCtlByName(const char* name) { ++ return GetDarwinSysCtlByNameValue(name) != 0; ++} ++#endif ++ ++static const Aarch64Info kEmptyAarch64Info; ++ ++Aarch64Info GetAarch64Info(void) { ++ Aarch64Info info = kEmptyAarch64Info; ++ ++ // Handling Darwin platform through sysctlbyname. ++ info.implementer = GetDarwinSysCtlByNameValue("hw.cputype"); ++ info.variant = GetDarwinSysCtlByNameValue("hw.cpusubtype"); ++ info.part = GetDarwinSysCtlByNameValue("hw.cpufamily"); ++ info.revision = GetDarwinSysCtlByNameValue("hw.cpusubfamily"); ++ ++ info.features.fp = GetDarwinSysCtlByName("hw.optional.floatingpoint"); ++ info.features.asimd = GetDarwinSysCtlByName("hw.optional.AdvSIMD"); ++ info.features.aes = GetDarwinSysCtlByName("hw.optional.arm.FEAT_AES"); ++ info.features.pmull = GetDarwinSysCtlByName("hw.optional.arm.FEAT_PMULL"); ++ info.features.sha1 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA1"); ++ info.features.sha2 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA2"); ++ info.features.crc32 = GetDarwinSysCtlByName("hw.optional.armv8_crc32"); ++ info.features.atomics = GetDarwinSysCtlByName("hw.optional.armv8_1_atomics"); ++ info.features.fphp = GetDarwinSysCtlByName("hw.optional.neon_hpfp"); ++ info.features.jscvt = GetDarwinSysCtlByName("hw.optional.arm.FEAT_JSCVT"); ++ info.features.fcma = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FCMA"); ++ info.features.lrcpc = GetDarwinSysCtlByName("hw.optional.arm.FEAT_LRCPC"); ++ info.features.sha3 = GetDarwinSysCtlByName("hw.optional.armv8_2_sha3"); ++ info.features.sha512 = GetDarwinSysCtlByName("hw.optional.armv8_2_sha512"); ++ info.features.asimdfhm = GetDarwinSysCtlByName("hw.optional.armv8_2_fhm"); ++ info.features.flagm = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FLAGM"); ++ info.features.flagm2 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FLAGM2"); ++ info.features.ssbs = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SSBS"); ++ info.features.sb = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SB"); ++ info.features.i8mm = GetDarwinSysCtlByName("hw.optional.arm.FEAT_I8MM"); ++ info.features.bf16 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_BF16"); ++ info.features.bti = GetDarwinSysCtlByName("hw.optional.arm.FEAT_BTI"); ++ ++ return info; ++} ++ ++#endif // defined(CPU_FEATURES_OS_MACOS) || defined(CPU_FEATURES_OS_IPHONE) ++#endif // CPU_FEATURES_ARCH_AARCH64 diff --git a/recipes/cpu_features/all/test_package/CMakeLists.txt b/recipes/cpu_features/all/test_package/CMakeLists.txt index 868e6e8286cb8..34c33e1cc8a13 100644 --- a/recipes/cpu_features/all/test_package/CMakeLists.txt +++ b/recipes/cpu_features/all/test_package/CMakeLists.txt @@ -1,9 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() -find_package(CpuFeatures CONFIG REQUIRED) +find_package(CpuFeatures REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} CpuFeatures::cpu_features) +target_link_libraries(${PROJECT_NAME} PRIVATE CpuFeatures::cpu_features) diff --git a/recipes/cpu_features/all/test_package/conanfile.py b/recipes/cpu_features/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/cpu_features/all/test_package/conanfile.py +++ b/recipes/cpu_features/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cpu_features/all/test_package/test_package.c b/recipes/cpu_features/all/test_package/test_package.c index ac0aae36dbd1c..5871a5e9abd8c 100644 --- a/recipes/cpu_features/all/test_package/test_package.c +++ b/recipes/cpu_features/all/test_package/test_package.c @@ -1,14 +1,40 @@ +#include +#if defined(CPU_FEATURES_ARCH_X86) +#include +#elif defined(CPU_FEATURES_ARCH_ARM) +#include +#elif defined(CPU_FEATURES_ARCH_AARCH64) +#include +#elif defined(CPU_FEATURES_ARCH_MIPS) +#include +#elif defined(CPU_FEATURES_ARCH_PPC) +#include +#endif + #include #include -#include int main() { - X86Features features = GetX86Info().features; - if (features.aes) { - printf("AES is available\n"); - } else { - printf("AES isn't available\n"); - } - return EXIT_SUCCESS; +#if defined(CPU_FEATURES_ARCH_X86) + X86Features features = GetX86Info().features; +#elif defined(CPU_FEATURES_ARCH_ARM) + ArmFeatures features = GetArmInfo().features; +#elif defined(CPU_FEATURES_ARCH_AARCH64) + Aarch64Features features = GetAarch64Info().features; +#elif defined(CPU_FEATURES_ARCH_MIPS) + MipsFeatures features = GetMipsInfo().features; +#elif defined(CPU_FEATURES_ARCH_PPC) + PPCFeatures features = GetPPCInfo().features; +#endif + +#if defined(CPU_FEATURES_ARCH_X86) || defined(CPU_FEATURES_ARCH_ARM) || defined(CPU_FEATURES_ARCH_AARCH64) + printf("AES is%s available\n", features.aes ? "" : "n't"); +#elif defined(CPU_FEATURES_ARCH_MIPS) + printf("EVA is%s available\n", features.eva ? "" : "n't"); +#elif defined(CPU_FEATURES_ARCH_PPC) + printf("SPE is%s available\n", features.spe ? "" : "n't"); +#endif + + return EXIT_SUCCESS; } diff --git a/recipes/cpu_features/all/test_v1_package/CMakeLists.txt b/recipes/cpu_features/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/cpu_features/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/cpu_features/all/test_v1_package/conanfile.py b/recipes/cpu_features/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cpu_features/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpu_features/config.yml b/recipes/cpu_features/config.yml index f3d4fd1074551..5af5c000c90f1 100644 --- a/recipes/cpu_features/config.yml +++ b/recipes/cpu_features/config.yml @@ -1,3 +1,5 @@ versions: + "0.7.0": + folder: "all" "0.6.0": folder: "all" diff --git a/recipes/cpuinfo/all/CMakeLists.txt b/recipes/cpuinfo/all/CMakeLists.txt index bd3083b512cb9..e40870cb28701 100644 --- a/recipes/cpuinfo/all/CMakeLists.txt +++ b/recipes/cpuinfo/all/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) -include(conanbuildinfo.cmake) -conan_basic_setup() +if(NOT CMAKE_SYSTEM_PROCESSOR AND CONAN_CPUINFO_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR ${CONAN_CPUINFO_SYSTEM_PROCESSOR}) +endif() -add_subdirectory(source_subfolder) +add_subdirectory(src) diff --git a/recipes/cpuinfo/all/conandata.yml b/recipes/cpuinfo/all/conandata.yml index f559c5cf7eeec..6231a9e8c3b97 100644 --- a/recipes/cpuinfo/all/conandata.yml +++ b/recipes/cpuinfo/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "cci.20220228": + url: "https://github.com/pytorch/cpuinfo/archive/6288930068efc8dff4f3c0b95f062fc5ddceba04.tar.gz" + sha256: "9e9e937b3569320d23d8b1c8c26ed3603affe55c3e4a3e49622e8a2c6d6e1696" "cci.20201217": - url: "https://github.com/pytorch/cpuinfo/archive/5916273f79a21551890fd3d56fc5375a78d1598d.zip" - sha256: "2a160c527d3c58085ce260f34f9e2b161adc009b34186a2baf24e74376e89e6d" + url: "https://github.com/pytorch/cpuinfo/archive/5916273f79a21551890fd3d56fc5375a78d1598d.tar.gz" + sha256: "f3c16d5d393d6d1fa6b6ed8621dd0a535552df9bc88cbba739375dde38a93142" diff --git a/recipes/cpuinfo/all/conanfile.py b/recipes/cpuinfo/all/conanfile.py index 2f4a8b94af6cb..8c665b04ef10e 100644 --- a/recipes/cpuinfo/all/conanfile.py +++ b/recipes/cpuinfo/all/conanfile.py @@ -1,16 +1,19 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -import glob +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file, rmdir import os +required_conan_version = ">=1.51.1" + class CpuinfoConan(ConanFile): name = "cpuinfo" description = "cpuinfo is a library to detect essential for performance " \ "optimization information about host CPU." license = "BSD-2-Clause" - topics = ("conan", "cpuinfo", "cpu", "cpuid", "cpu-cache", "cpu-model", - "instruction-set", "cpu-topology") + topics = ("cpu", "cpuid", "cpu-cache", "cpu-model", "instruction-set", "cpu-topology") homepage = "https://github.com/pytorch/cpuinfo" url = "https://github.com/conan-io/conan-center-index" @@ -27,12 +30,6 @@ class CpuinfoConan(ConanFile): } exports_sources = "CMakeLists.txt" - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" def config_options(self): if self.settings.os == "Windows": @@ -40,53 +37,73 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx - if self.settings.os == "Windows" and self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.os == "Windows" and self.info.options.shared: raise ConanInvalidConfiguration("shared cpuinfo not supported on Windows") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("cpuinfo-*")[0] - os.rename(extracted_dir, self._source_subfolder) - - def _patch_sources(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "SET_PROPERTY(TARGET clog PROPERTY POSITION_INDEPENDENT_CODE ON)", - "") + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) + def generate(self): + tc = CMakeToolchain(self) # cpuinfo - self._cmake.definitions["CPUINFO_LIBRARY_TYPE"] = "default" - self._cmake.definitions["CPUINFO_RUNTIME_TYPE"] = "default" - self._cmake.definitions["CPUINFO_LOG_LEVEL"] = self.options.log_level - self._cmake.definitions["CPUINFO_BUILD_TOOLS"] = False - self._cmake.definitions["CPUINFO_BUILD_UNIT_TESTS"] = False - self._cmake.definitions["CPUINFO_BUILD_MOCK_TESTS"] = False - self._cmake.definitions["CPUINFO_BUILD_BENCHMARKS"] = False + tc.cache_variables["CPUINFO_LIBRARY_TYPE"] = "default" + tc.cache_variables["CPUINFO_RUNTIME_TYPE"] = "default" + # TODO: remove str cast in conan 1.53.0 (see https://github.com/conan-io/conan/pull/12086) + tc.cache_variables["CPUINFO_LOG_LEVEL"] = str(self.options.log_level) + tc.variables["CPUINFO_BUILD_TOOLS"] = False + tc.variables["CPUINFO_BUILD_UNIT_TESTS"] = False + tc.variables["CPUINFO_BUILD_MOCK_TESTS"] = False + tc.variables["CPUINFO_BUILD_BENCHMARKS"] = False # clog (always static) - self._cmake.definitions["CLOG_RUNTIME_TYPE"] = "default" - self._cmake.definitions["CLOG_BUILD_TESTS"] = False - self._cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) + tc.cache_variables["CLOG_RUNTIME_TYPE"] = "default" + tc.variables["CLOG_BUILD_TESTS"] = False + tc.variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) + # CMAKE_SYSTEM_PROCESSOR must be manually set if cross-building + if cross_building(self): + cmake_system_processor = { + "armv8": "arm64", + "armv8.3": "arm64", + }.get(str(self.settings.arch), str(self.settings.arch)) + tc.variables["CONAN_CPUINFO_SYSTEM_PROCESSOR"] = cmake_system_processor + tc.generate() - self._cmake.configure() - return self._cmake + def _patch_sources(self): + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "SET_PROPERTY(TARGET clog PROPERTY POSITION_INDEPENDENT_CODE ON)", + "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libcpuinfo") self.cpp_info.libs = ["cpuinfo", "clog"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["pthread"] diff --git a/recipes/cpuinfo/all/test_package/CMakeLists.txt b/recipes/cpuinfo/all/test_package/CMakeLists.txt index fd126a732c403..f7fd88969d977 100644 --- a/recipes/cpuinfo/all/test_package/CMakeLists.txt +++ b/recipes/cpuinfo/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cpuinfo REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) +target_link_libraries(${PROJECT_NAME} PRIVATE cpuinfo::cpuinfo) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/cpuinfo/all/test_package/conanfile.py b/recipes/cpuinfo/all/test_package/conanfile.py index 5216332f39f5c..0a6bc68712d90 100644 --- a/recipes/cpuinfo/all/test_package/conanfile.py +++ b/recipes/cpuinfo/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cpuinfo/all/test_v1_package/CMakeLists.txt b/recipes/cpuinfo/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b06d2e30ef81 --- /dev/null +++ b/recipes/cpuinfo/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cpuinfo REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE cpuinfo::cpuinfo) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/cpuinfo/all/test_v1_package/conanfile.py b/recipes/cpuinfo/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cpuinfo/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cpuinfo/config.yml b/recipes/cpuinfo/config.yml index 2f90866366efe..a6383a8ac8924 100644 --- a/recipes/cpuinfo/config.yml +++ b/recipes/cpuinfo/config.yml @@ -1,3 +1,5 @@ versions: + "cci.20220228": + folder: all "cci.20201217": folder: all diff --git a/recipes/cpython/all/conandata.yml b/recipes/cpython/all/conandata.yml new file mode 100644 index 0000000000000..f9fd51067c8b3 --- /dev/null +++ b/recipes/cpython/all/conandata.yml @@ -0,0 +1,72 @@ +sources: + "3.10.0": + url: "https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz" + sha256: "c4e0cbad57c90690cb813fb4663ef670b4d0f587d8171e2c42bd4c9245bd2758" + "3.9.7": + url: "https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz" + sha256: "a838d3f9360d157040142b715db34f0218e535333696a5569dc6f854604eb9d1" + "3.8.12": + url: "https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz" + sha256: "316aa33f3b7707d041e73f246efedb297a70898c4b91f127f66dc8d80c596f1a" + "3.7.12": + url: "https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz" + sha256: "33b4daaf831be19219659466d12645f87ecec6eb21d4d9f9711018a7b66cce46" + "2.7.18": + url: "https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz" + sha256: "da3080e3b488f648a3d7a4560ddee895284c3380b11d6de75edb986526b9a814" +patches: + "3.10.0": + - patch_file: "patches/3.10.0-0001-msvc.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.9.7-0002-_msi-vcxproj.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.10.0-0003-_ctypes-ffi.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.10.0-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.10.0-0005-disable-macos-tcltk.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.x-0001-relocatable-python-config.patch" + base_path: "source_subfolder" + "3.9.7": + - patch_file: "patches/3.9.7-0001-msvc.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.9.7-0002-_msi-vcxproj.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.9.7-0003-_ctypes-ffi.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.9.7-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.9.7-0005-disable-macos-tcltk.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.x-0001-relocatable-python-config.patch" + base_path: "source_subfolder" + "3.8.12": + - patch_file: "patches/3.8.12-0001-msvc.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.8.12-0002-_ctypes-ffi.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.8.12-0003-setup.py-pass-CFLAGS-CPPFLAGS.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.8.12-0004-disable-macos-tcltk.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.x-0001-relocatable-python-config.patch" + base_path: "source_subfolder" + "3.7.12": + - patch_file: "patches/3.7.9-0001-msvc.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.7.9-0002-setup.py-pass-CFLAGS-CPPFLAGS.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.7.9-0003-disable-macos-tcltk.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.x-0001-relocatable-python-config.patch" + base_path: "source_subfolder" + "2.7.18": + - patch_file: "patches/2.7.18-0001-msvc.patch" + base_path: "source_subfolder" + - patch_file: "patches/2.7.18-0002-add-support-msvc-14.patch" + base_path: "source_subfolder" + - patch_file: "patches/2.7.18-0003-msvc-fix-static.patch" + base_path: "source_subfolder" + - patch_file: "patches/2.7.18-0004-disable-macos-tcltk.patch" + base_path: "source_subfolder" diff --git a/recipes/cpython/all/conanfile.py b/recipes/cpython/all/conanfile.py new file mode 100644 index 0000000000000..4fa1d1da6334e --- /dev/null +++ b/recipes/cpython/all/conanfile.py @@ -0,0 +1,738 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, MSBuild, tools +from conans.errors import ConanInvalidConfiguration +from io import StringIO +import os +import re +import textwrap + +required_conan_version = ">=1.33.0" + + +class CPythonConan(ConanFile): + name = "cpython" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.python.org" + description = "Python is a programming language that lets you work quickly and integrate systems more effectively." + topics = ("python", "cpython", "language", "script") + license = ("Python-2.0",) + exports_sources = "patches/**" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "optimizations": [True, False], + "lto": [True, False], + "docstrings": [True, False], + "pymalloc": [True, False], + "with_bz2": [True, False], + "with_gdbm": [True, False], + "with_nis": [True, False], + "with_sqlite3": [True, False], + "with_tkinter": [True, False], + "with_curses": [True, False], + + # Python 2 options + "unicode": ["ucs2", "ucs4"], + "with_bsddb": [True, False], + # Python 3 options + "with_lzma": [True, False], + + # options that don't change package id + "env_vars": [True, False], # set environment variables + } + default_options = { + "shared": False, + "fPIC": True, + "optimizations": False, + "lto": False, + "docstrings": True, + "pymalloc": True, + "with_bz2": True, + "with_gdbm": True, + "with_nis": False, + "with_sqlite3": True, + "with_tkinter": True, + "with_curses": True, + + # Python 2 options + "unicode": "ucs2", + "with_bsddb": False, # True, # FIXME: libdb package missing (#5309/#5392) + # Python 3 options + "with_lzma": True, + + # options that don't change package id + "env_vars": True, + } + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _version_number_only(self): + return re.match(r"^([0-9.]+)", self.version).group(1) + + @property + def _version_tuple(self): + return tuple(self._version_number_only.split(".")) + + @property + def _supports_modules(self): + return self.settings.compiler != "Visual Studio" or self.options.shared + + @property + def _version_suffix(self): + if self.settings.compiler == "Visual Studio": + joiner = "" + else: + joiner = "." + return joiner.join(self._version_tuple[:2]) + + @property + def _is_py3(self): + return tools.Version(self._version_number_only).major == "3" + + @property + def _is_py2(self): + return tools.Version(self._version_number_only).major == "2" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.compiler == "Visual Studio": + del self.options.lto + del self.options.docstrings + del self.options.pymalloc + del self.options.with_curses + del self.options.with_gdbm + del self.options.with_nis + if self._is_py2: + # Python 2.xx does not support following options + del self.options.with_lzma + elif self._is_py3: + # Python 3.xx does not support following options + del self.options.with_bsddb + del self.options.unicode + + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def configure(self): + if self.options.shared: + del self.options.fPIC + if not self._supports_modules: + del self.options.with_bz2 + del self.options.with_sqlite3 + del self.options.with_tkinter + + del self.options.with_bsddb + del self.options.with_lzma + if self.settings.compiler == "Visual Studio": + # The msbuild generator only works with Visual Studio + self.generators.append("MSBuildDeps") + + def validate(self): + if self.options.shared: + if self.settings.compiler == "Visual Studio" and "MT" in self.settings.compiler.runtime: + raise ConanInvalidConfiguration("cpython does not support MT(d) runtime when building a shared cpython library") + if self.settings.compiler == "Visual Studio": + if self.options.optimizations: + raise ConanInvalidConfiguration("This recipe does not support optimized MSVC cpython builds (yet)") + # FIXME: should probably throw when cross building + # FIXME: optimizations for Visual Studio, before building the final `build_type`: + # 1. build the MSVC PGInstrument build_type, + # 2. run the instrumented binaries, (PGInstrument should have created a `python.bat` file in the PCbuild folder) + # 3. build the MSVC PGUpdate build_type + if self.settings.build_type == "Debug" and "d" not in self.settings.compiler.runtime: + raise ConanInvalidConfiguration("Building debug cpython requires a debug runtime (Debug cpython requires _CrtReportMode symbol, which only debug runtimes define)") + if self._is_py2: + if self.settings.compiler.version >= tools.Version("14"): + self.output.warn("Visual Studio versions 14 and higher were never officially supported by the CPython developers") + if str(self.settings.arch) not in self._msvc_archs: + raise ConanInvalidConfiguration("Visual Studio does not support this architecture") + + if not self.options.shared and tools.Version(self._version_number_only) >= "3.10": + raise ConanInvalidConfiguration("Static msvc build disabled (>=3.10) due to \"AttributeError: module 'sys' has no attribute 'winver'\"") + + if self.options.get_safe("with_curses", False) and not self.options["ncurses"].with_widec: + raise ConanInvalidConfiguration("cpython requires ncurses with wide character support") + + def package_id(self): + del self.info.options.env_vars + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @property + def _with_libffi(self): + # cpython 3.7.x on MSVC uses an ancient libffi 2.00-beta (which is not available at cci, and is API/ABI incompatible with current 3.2+) + return self._supports_modules \ + and (self.settings.compiler != "Visual Studio" or tools.Version(self._version_number_only) >= "3.8") + + def requirements(self): + self.requires("zlib/1.2.11") + if self._supports_modules: + self.requires("openssl/1.1.1l") + self.requires("expat/2.4.1") + if self._with_libffi: + self.requires("libffi/3.2.1") + if tools.Version(self._version_number_only) < "3.8": + self.requires("mpdecimal/2.4.2") + elif tools.Version(self._version_number_only) < "3.10": + self.requires("mpdecimal/2.5.0") + else: + self.requires("mpdecimal/2.5.0") # FIXME: no 2.5.1 to troubleshoot apple + if self.settings.os != "Windows": + if not tools.is_apple_os(self.settings.os): + self.requires("libuuid/1.0.3") + self.requires("libxcrypt/4.4.25") + if self.options.get_safe("with_bz2"): + self.requires("bzip2/1.0.8") + if self.options.get_safe("with_gdbm", False): + self.requires("gdbm/1.19") + if self.options.get_safe("with_nis", False): + # TODO: Add nis when available. + raise ConanInvalidConfiguration("nis is not available on CCI (yet)") + if self.options.get_safe("with_sqlite3"): + self.requires("sqlite3/3.36.0") + if self.options.get_safe("with_tkinter"): + self.requires("tk/8.6.10") + if self.options.get_safe("with_curses", False): + self.requires("ncurses/6.2") + if self.options.get_safe("with_bsddb", False): + self.requires("libdb/5.3.28") + if self.options.get_safe("with_lzma", False): + self.requires("xz_utils/5.2.5") + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + self._autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" + conf_args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--with-doc-strings={}".format(yes_no(self.options.docstrings)), + "--with-pymalloc={}".format(yes_no(self.options.pymalloc)), + "--with-system-expat", + "--with-system-ffi", + "--enable-optimizations={}".format(yes_no(self.options.optimizations)), + "--with-lto={}".format(yes_no(self.options.lto)), + "--with-pydebug={}".format(yes_no(self.settings.build_type == "Debug")), + ] + if self._is_py2: + conf_args.extend([ + "--enable-unicode={}".format(yes_no(self.options.unicode)), + ]) + if self._is_py3: + conf_args.extend([ + "--with-system-libmpdec", + "--with-openssl={}".format(self.deps_cpp_info["openssl"].rootpath), + "--enable-loadable-sqlite-extensions={}".format(yes_no(not self.options["sqlite3"].omit_load_extension)), + ]) + if self.settings.compiler == "intel": + conf_args.extend(["--with-icc"]) + if tools.get_env("CC") or self.settings.compiler != "gcc": + conf_args.append("--without-gcc") + if self.options.with_tkinter: + tcltk_includes = [] + tcltk_libs = [] + # FIXME: collect using some conan util (https://github.com/conan-io/conan/issues/7656) + for dep in ("tcl", "tk", "zlib"): + tcltk_includes += ["-I{}".format(d) for d in self.deps_cpp_info[dep].include_paths] + tcltk_libs += ["-l{}".format(lib) for lib in self.deps_cpp_info[dep].libs] + if self.settings.os == "Linux" and not self.options["tk"].shared: + # FIXME: use info from xorg.components (x11, xscrnsaver) + tcltk_libs.extend(["-l{}".format(lib) for lib in ("X11", "Xss")]) + conf_args.extend([ + "--with-tcltk-includes={}".format(" ".join(tcltk_includes)), + "--with-tcltk-libs={}".format(" ".join(tcltk_libs)), + ]) + if self.settings.os in ("Linux", "FreeBSD"): + # Building _testembed fails due to missing pthread/rt symbols + self._autotools.link_flags.append("-lpthread") + + build = None + if tools.cross_building(self) and not tools.cross_building(self, skip_x64_x86=True): + # Building from x86_64 to x86 is not a "real" cross build, so set build == host + build = tools.get_gnu_triplet(str(self.settings.os), str(self.settings.arch), str(self.settings.compiler)) + self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder, build=build) + return self._autotools + + def _patch_sources(self): + for patch in self.conan_data.get("patches",{}).get(self.version, []): + tools.patch(**patch) + if self._is_py3 and tools.Version(self._version_number_only) < "3.10": + tools.replace_in_file(os.path.join(self._source_subfolder, "setup.py"), + ":libmpdec.so.2", "mpdec") + if self.settings.compiler == "Visual Studio": + runtime_library = { + "MT": "MultiThreaded", + "MTd": "MultiThreadedDebug", + "MD": "MultiThreadedDLL", + "MDd": "MultiThreadedDebugDLL", + }[str(self.settings.compiler.runtime)] + self.output.info("Patching runtime") + tools.replace_in_file(os.path.join(self._source_subfolder, "PCbuild", "pyproject.props"), + "MultiThreadedDLL", runtime_library) + tools.replace_in_file(os.path.join(self._source_subfolder, "PCbuild", "pyproject.props"), + "MultiThreadedDebugDLL", runtime_library) + + # Remove vendored packages + tools.rmdir(os.path.join(self._source_subfolder, "Modules", "_decimal", "libmpdec")) + tools.rmdir(os.path.join(self._source_subfolder, "Modules", "expat")) + + if self.options.get_safe("with_curses", False): + # FIXME: this will link to ALL libraries of ncurses. Only need to link to ncurses(w) (+ eventually tinfo) + tools.replace_in_file(os.path.join(self._source_subfolder, "setup.py"), + "curses_libs = ", + "curses_libs = {} #".format(repr(self.deps_cpp_info["ncurses"].libs + self.deps_cpp_info["ncurses"].system_libs))) + + # Enable static MSVC cpython + if not self.options.shared: + tools.replace_in_file(os.path.join(self._source_subfolder, "PCbuild", "pythoncore.vcxproj"), + "","Py_NO_BUILD_SHARED;") + tools.replace_in_file(os.path.join(self._source_subfolder, "PCbuild", "pythoncore.vcxproj"), + "Py_ENABLE_SHARED", "Py_NO_ENABLE_SHARED") + tools.replace_in_file(os.path.join(self._source_subfolder, "PCbuild", "pythoncore.vcxproj"), + "DynamicLibrary", "StaticLibrary") + + tools.replace_in_file(os.path.join(self._source_subfolder, "PCbuild", "python.vcxproj"), + "", "shlwapi.lib;ws2_32.lib;pathcch.lib;version.lib;%(AdditionalDependencies)") + tools.replace_in_file(os.path.join(self._source_subfolder, "PCbuild", "python.vcxproj"), + "", "Py_NO_ENABLE_SHARED;") + + tools.replace_in_file(os.path.join(self._source_subfolder, "PCbuild", "pythonw.vcxproj"), + "", "shlwapi.lib;ws2_32.lib;pathcch.lib;version.lib;%(AdditionalDependencies)") + tools.replace_in_file(os.path.join(self._source_subfolder, "PCbuild", "pythonw.vcxproj"), + "", "Py_NO_ENABLE_SHARED;%(PreprocessorDefinitions)") + + def _upgrade_single_project_file(self, project_file): + """ + `devenv /upgrade ` will upgrade *ALL* projects referenced by the project. + By temporarily moving the solution project, only one project is upgraded + This is needed for static cpython or for disabled optional dependencies (e.g. tkinter=False) + Restore it afterwards because it is needed to build some targets. + """ + tools.rename(os.path.join(self._source_subfolder, "PCbuild", "pcbuild.sln"), + os.path.join(self._source_subfolder, "PCbuild", "pcbuild.sln.bak")) + tools.rename(os.path.join(self._source_subfolder, "PCbuild", "pcbuild.proj"), + os.path.join(self._source_subfolder, "PCbuild", "pcbuild.proj.bak")) + with tools.vcvars(self.settings): + self.run("devenv \"{}\" /upgrade".format(project_file), run_environment=True) + tools.rename(os.path.join(self._source_subfolder, "PCbuild", "pcbuild.sln.bak"), + os.path.join(self._source_subfolder, "PCbuild", "pcbuild.sln")) + tools.rename(os.path.join(self._source_subfolder, "PCbuild", "pcbuild.proj.bak"), + os.path.join(self._source_subfolder, "PCbuild", "pcbuild.proj")) + + @property + def _solution_projects(self): + if self.options.shared: + solution_path = os.path.join(self._source_subfolder, "PCbuild", "pcbuild.sln") + projects = set(m.group(1) for m in re.finditer("\"([^\"]+)\\.vcxproj\"", open(solution_path).read())) + + def project_build(name): + if os.path.basename(name) in self._msvc_discarded_projects: + return False + if "test" in name: + return False + return True + + def sort_importance(key): + importance = ( + "pythoncore", # The python library MUST be built first. All modules and executables depend on it + "python", # Build the python executable next (for convenience, when debugging) + ) + try: + return importance.index(key) + except ValueError: + return len(importance) + + projects = sorted((p for p in projects if project_build(p)), key=sort_importance) + return projects + else: + return "pythoncore", "python", "pythonw" + + @property + def _msvc_discarded_projects(self): + discarded = {"python_uwp", "pythonw_uwp"} + if not self.options.with_bz2: + discarded.add("bz2") + if not self.options.with_sqlite3: + discarded.add("_sqlite3") + if not self.options.with_tkinter: + discarded.add("_tkinter") + if self._is_py2: + # Python 2 Visual Studio projects NOT to build + discarded = discarded.union({"bdist_wininst", "libeay", "ssleay", "sqlite3", "tcl", "tk", "tix"}) + if not self.options.with_bsddb: + discarded.add("_bsddb") + elif self._is_py3: + discarded = discarded.union({"bdist_wininst", "liblzma", "openssl", "sqlite3", "xxlimited"}) + if not self.options.with_lzma: + discarded.add("_lzma") + return discarded + + @property + def _msvc_archs(self): + archs = { + "x86": "Win32", + "x86_64": "x64", + } + if tools.Version(self._version_number_only) >= "3.8": + archs.update({ + "armv7": "ARM", + "armv8_32": "ARM", + "armv8": "ARM64", + }) + return archs + + def _msvc_build(self): + msbuild = MSBuild(self) + msbuild_properties = { + "IncludeExternals": "true", + } + projects = self._solution_projects + self.output.info("Building {} Visual Studio projects: {}".format(len(projects), projects)) + + with tools.no_op(): + for project_i, project in enumerate(projects, 1): + self.output.info("[{}/{}] Building project '{}'...".format(project_i, len(projects), project)) + project_file = os.path.join(self._source_subfolder, "PCbuild", project + ".vcxproj") + self._upgrade_single_project_file(project_file) + msbuild.build(project_file, upgrade_project=False, build_type="Debug" if self.settings.build_type == "Debug" else "Release", + platforms=self._msvc_archs, properties=msbuild_properties) + + def build(self): + # FIXME: these checks belong in validate, but the versions of dependencies are not available there yet + if self._supports_modules: + if tools.Version(self._version_number_only) < "3.8.0": + if tools.Version(self.deps_cpp_info["mpdecimal"].version) >= "2.5.0": + raise ConanInvalidConfiguration("cpython versions lesser then 3.8.0 require a mpdecimal lesser then 2.5.0") + elif tools.Version(self._version_number_only) >= "3.9.0": + if tools.Version(self.deps_cpp_info["mpdecimal"].version) < "2.5.0": + raise ConanInvalidConfiguration("cpython 3.9.0 (and newer) requires (at least) mpdecimal 2.5.0") + + if self._with_libffi: + if tools.Version(self.deps_cpp_info["libffi"].version) >= "3.3" and self.settings.compiler == "Visual Studio" and "d" in str(self.settings.compiler.runtime): + raise ConanInvalidConfiguration("libffi versions >= 3.3 cause 'read access violations' when using a debug runtime (MTd/MDd)") + + self._patch_sources() + if self.settings.compiler == "Visual Studio": + self._msvc_build() + else: + autotools = self._configure_autotools() + autotools.make() + + @property + def _msvc_artifacts_path(self): + build_subdir_lut = { + "x86_64": "amd64", + "x86": "win32", + } + if tools.Version(self._version_number_only) >= "3.8": + build_subdir_lut.update({ + "armv7": "arm32", + "armv8_32": "arm32", + "armv8": "arm64", + }) + return os.path.join(self._source_subfolder, "PCbuild", build_subdir_lut[str(self.settings.arch)]) + + @property + def _msvc_install_subprefix(self): + return "bin" + + def _copy_essential_dlls(self): + if self.settings.compiler == "Visual Studio": + # Until MSVC builds support cross building, copy dll's of essential (shared) dependencies to python binary location. + # These dll's are required when running the layout tool using the newly built python executable. + dest_path = os.path.join(self.build_folder, self._msvc_artifacts_path) + if self._with_libffi: + for bin_path in self.deps_cpp_info["libffi"].bin_paths: + self.copy("*.dll", src=bin_path, dst=dest_path) + for bin_path in self.deps_cpp_info["expat"].bin_paths: + self.copy("*.dll", src=bin_path, dst=dest_path) + for bin_path in self.deps_cpp_info["zlib"].bin_paths: + self.copy("*.dll", src=bin_path, dst=dest_path) + + def _msvc_package_layout(self): + self._copy_essential_dlls() + install_prefix = os.path.join(self.package_folder, self._msvc_install_subprefix) + tools.mkdir(install_prefix) + build_path = self._msvc_artifacts_path + infix = "_d" if self.settings.build_type == "Debug" else "" + # FIXME: if cross building, use a build python executable here + python_built = os.path.join(build_path, "python{}.exe".format(infix)) + layout_args = [ + os.path.join(self._source_subfolder, "PC", "layout", "main.py"), + "-v", + "-s", self._source_subfolder, + "-b", build_path, + "--copy", install_prefix, + "-p", + "--include-pip", + "--include-venv", + "--include-dev", + ] + if self.options.with_tkinter: + layout_args.append("--include-tcltk") + if self.settings.build_type == "Debug": + layout_args.append("-d") + python_args = " ".join("\"{}\"".format(a) for a in layout_args) + self.run("{} {}".format(python_built, python_args), run_environment=True) + + tools.rmdir(os.path.join(self.package_folder, "bin", "tcl")) + + for file in os.listdir(install_prefix): + if re.match("vcruntime.*", file): + os.unlink(os.path.join(install_prefix, file)) + continue + os.unlink(os.path.join(install_prefix, "LICENSE.txt")) + for file in os.listdir(os.path.join(install_prefix, "libs")): + if not re.match("python.*", file): + os.unlink(os.path.join(install_prefix, "libs", file)) + + def _msvc_package_copy(self): + build_path = self._msvc_artifacts_path + infix = "_d" if self.settings.build_type == "Debug" else "" + self.copy("*.exe", src=build_path, dst=os.path.join(self.package_folder, self._msvc_install_subprefix)) + self.copy("*.dll", src=build_path, dst=os.path.join(self.package_folder, self._msvc_install_subprefix)) + self.copy("*.pyd", src=build_path, dst=os.path.join(self.package_folder, self._msvc_install_subprefix, "DLLs")) + self.copy("python{}{}.lib".format(self._version_suffix, infix), src=build_path, dst=os.path.join(self.package_folder, self._msvc_install_subprefix, "libs")) + self.copy("*", src=os.path.join(self._source_subfolder, "Include"), dst=os.path.join(self.package_folder, self._msvc_install_subprefix, "include")) + self.copy("pyconfig.h", src=os.path.join(self._source_subfolder, "PC"), dst=os.path.join(self.package_folder, self._msvc_install_subprefix, "include")) + self.copy("*.py", src=os.path.join(self._source_subfolder, "lib"), dst=os.path.join(self.package_folder, self._msvc_install_subprefix, "Lib")) + tools.rmdir(os.path.join(self.package_folder, self._msvc_install_subprefix, "Lib", "test")) + + packages = {} + get_name_version = lambda fn: fn.split(".", 2)[:2] + whldir = os.path.join(self._source_subfolder, "Lib", "ensurepip", "_bundled") + for fn in filter(lambda n: n.endswith(".whl"), os.listdir(whldir)): + name, version = get_name_version(fn) + add = True + if name in packages: + pname, pversion = get_name_version(packages[name]) + add = tools.Version(version) > tools.Version(pversion) + if add: + packages[name] = fn + for fname in packages.values(): + tools.unzip(filename=os.path.join(whldir, fname), destination=os.path.join(self.package_folder, "bin", "Lib", "site-packages")) + + self.run("{} -c \"import compileall; compileall.compile_dir('{}')\"".format(os.path.join(build_path, self._cpython_interpreter_name), os.path.join(self.package_folder, self._msvc_install_subprefix, "Lib").replace("\\", "/")), + run_environment=True) + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + if self.settings.compiler == "Visual Studio": + if self._is_py2 or not self.options.shared: + self._msvc_package_copy() + else: + self._msvc_package_layout() + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "vcruntime*") + else: + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + # Rewrite shebangs of python scripts + for filename in os.listdir(os.path.join(self.package_folder, "bin")): + filepath = os.path.join(self.package_folder, "bin", filename) + if not os.path.isfile(filepath): + continue + if os.path.islink(filepath): + continue + with open(filepath, "rb") as fn: + firstline = fn.readline(1024) + if not(firstline.startswith(b"#!") and b"/python" in firstline and b"/bin/sh" not in firstline): + continue + text = fn.read() + self.output.info("Rewriting shebang of {}".format(filename)) + with open(filepath, "wb") as fn: + fn.write(textwrap.dedent("""\ + #!/bin/sh + ''':' + __file__="$0" + while [ -L "$__file__" ]; do + __file__="$(dirname "$__file__")/$(readlink "$__file__")" + done + exec "$(dirname "$__file__")/python{}" "$0" "$@" + ''' + """.format(self._version_suffix)).encode()) + fn.write(text) + + if not os.path.exists(self._cpython_symlink): + os.symlink("python{}".format(self._version_suffix), self._cpython_symlink) + self._fix_install_name() + + @property + def _cpython_symlink(self): + symlink = os.path.join(self.package_folder, "bin", "python") + if self.settings.os == "Windows": + symlink += ".exe" + return symlink + + @property + def _cpython_interpreter_name(self): + if self.settings.compiler == "Visual Studio": + suffix = "" + else: + suffix = self._version_suffix + python = "python{}".format(suffix) + if self.settings.compiler == "Visual Studio": + if self.settings.build_type == "Debug": + python += "_d" + if self.settings.os == "Windows": + python += ".exe" + return python + + @property + def _cpython_interpreter_path(self): + return os.path.join(self.package_folder, "bin", self._cpython_interpreter_name) + + @property + def _abi_suffix(self): + res = "" + if self._is_py3: + if self.settings.build_type == "Debug": + res += "d" + if tools.Version(self._version_number_only) < "3.8": + if self.options.get_safe("pymalloc", False): + res += "m" + return res + + @property + def _lib_name(self): + if self.settings.compiler == "Visual Studio": + if self.settings.build_type == "Debug": + lib_ext = "_d" + else: + lib_ext = "" + else: + lib_ext = self._abi_suffix + (".dll.a" if self.options.shared and self.settings.os == "Windows" else "") + return "python{}{}".format(self._version_suffix, lib_ext) + + def _fix_install_name(self): + if tools.is_apple_os(self.settings.os) and self.options.shared: + buffer = StringIO() + python = os.path.join(self.package_folder, "bin", "python") + self.run('otool -L "%s"' % python, output=buffer) + lines = buffer.getvalue().strip().split('\n')[1:] + for line in lines: + library = line.split()[0] + if library.startswith(self.package_folder): + new = library.replace(self.package_folder, "@executable_path/..") + self.output.info("patching {}, replace {} with {}".format(python, library, new)) + self.run("install_name_tool -change {} {} {}".format(library, new, python)) + + def package_info(self): + # FIXME: conan components Python::Interpreter component, need a target type + # self.cpp_info.names["cmake_find_package"] = "Python" + # self.cpp_info.names["cmake_find_package_multi"] = "Python" + # FIXME: conan components need to generate multiple .pc files (python2, python-27) + + py_version = tools.Version(self._version_number_only) + # python component: "Build a C extension for Python" + if self.settings.compiler == "Visual Studio": + self.cpp_info.components["python"].includedirs = [os.path.join(self._msvc_install_subprefix, "include")] + libdir = os.path.join(self._msvc_install_subprefix, "libs") + else: + self.cpp_info.components["python"].includedirs.append(os.path.join("include", "python{}{}".format(self._version_suffix, self._abi_suffix))) + libdir = "lib" + if self.options.shared: + self.cpp_info.components["python"].defines.append("Py_ENABLE_SHARED") + else: + self.cpp_info.components["python"].defines.append("Py_NO_ENABLE_SHARED") + if self.settings.os == "Linux": + self.cpp_info.components["python"].system_libs.extend(["dl", "m", "pthread", "util"]) + elif self.settings.os == "Windows": + self.cpp_info.components["python"].system_libs.extend(["pathcch", "shlwapi", "version", "ws2_32"]) + self.cpp_info.components["python"].requires = ["zlib::zlib"] + if self.settings.os != "Windows": + self.cpp_info.components["python"].requires.append("libxcrypt::libxcrypt") + self.cpp_info.components["python"].names["pkg_config"] = "python-{}.{}".format(py_version.major, py_version.minor) + self.cpp_info.components["python"].libdirs = [] + + self.cpp_info.components["_python_copy"].names["pkg_config"] = "python{}".format(py_version.major) + self.cpp_info.components["_python_copy"].requires = ["python"] + self.cpp_info.components["_python_copy"].libdirs = [] + + # embed component: "Embed Python into an application" + self.cpp_info.components["embed"].libs = [self._lib_name] + self.cpp_info.components["embed"].libdirs = [libdir] + self.cpp_info.components["embed"].names["pkg_config"] = "python-{}.{}-embed".format(py_version.major, py_version.minor) + self.cpp_info.components["embed"].requires = ["python"] + + self.cpp_info.components["_embed_copy"].requires = ["embed"] + self.cpp_info.components["_embed_copy"].names["pkg_config"] = ["python{}-embed".format(py_version.major)] + self.cpp_info.components["_embed_copy"].libdirs = [] + + if self._supports_modules: + # hidden components: the C extensions of python are built as dynamically loaded shared libraries. + # C extensions or applications with an embedded Python should not need to link to them.. + self.cpp_info.components["_hidden"].requires = [ + "openssl::openssl", + "expat::expat", + "mpdecimal::mpdecimal", + ] + if self._with_libffi: + self.cpp_info.components["_hidden"].requires.append("libffi::libffi") + if self.settings.os != "Windows": + if not tools.is_apple_os(self.settings.os): + self.cpp_info.components["_hidden"].requires.append("libuuid::libuuid") + self.cpp_info.components["_hidden"].requires.append("libxcrypt::libxcrypt") + if self.options.with_bz2: + self.cpp_info.components["_hidden"].requires.append("bzip2::bzip2") + if self.options.get_safe("with_gdbm", False): + self.cpp_info.components["_hidden"].requires.append("gdbm::gdbm") + if self.options.with_sqlite3: + self.cpp_info.components["_hidden"].requires.append("sqlite3::sqlite3") + if self.options.get_safe("with_curses", False): + self.cpp_info.components["_hidden"].requires.append("ncurses::ncurses") + if self.options.get_safe("with_bsddb"): + self.cpp_info.components["_hidden"].requires.append("libdb::libdb") + if self.options.get_safe("with_lzma"): + self.cpp_info.components["_hidden"].requires.append("xz_utils::xz_utils") + if self.options.get_safe("with_tkinter"): + self.cpp_info.components["_hidden"].requires.append("tk::tk") + self.cpp_info.components["_hidden"].libdirs = [] + + if self.options.env_vars: + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) + + python = self._cpython_interpreter_path + self.user_info.python = python + if self.options.env_vars: + self.output.info("Setting PYTHON environment variable: {}".format(python)) + self.env_info.PYTHON = python + + if self.settings.compiler == "Visual Studio": + pythonhome = os.path.join(self.package_folder, "bin") + elif tools.is_apple_os(self.settings.os): + pythonhome = self.package_folder + else: + version = tools.Version(self._version_number_only) + pythonhome = os.path.join(self.package_folder, "lib", "python{}.{}".format(version.major, version.minor)) + self.user_info.pythonhome = pythonhome + + pythonhome_required = self.settings.compiler == "Visual Studio" or tools.is_apple_os(self.settings.os) + self.user_info.module_requires_pythonhome = pythonhome_required + + if self.settings.compiler == "Visual Studio": + if self.options.env_vars: + self.output.info("Setting PYTHONHOME environment variable: {}".format(pythonhome)) + self.env_info.PYTHONHOME = pythonhome + + if self._is_py2: + python_root = "" + else: + python_root = self.package_folder + if self.options.env_vars: + self.output.info("Setting PYTHON_ROOT environment variable: {}".format(python_root)) + self.env_info.PYTHON_ROOT = python_root + self.user_info.python_root = python_root diff --git a/recipes/cpython/all/patches/2.7.18-0001-msvc.patch b/recipes/cpython/all/patches/2.7.18-0001-msvc.patch new file mode 100644 index 0000000000000..2c101049df531 --- /dev/null +++ b/recipes/cpython/all/patches/2.7.18-0001-msvc.patch @@ -0,0 +1,278 @@ +--- PCbuild/_bsddb.vcxproj ++++ PCbuild/_bsddb.vcxproj +@@ -46,7 +46,7 @@ + NotSet + + +- ++ + + .pyd + +@@ -75,7 +75,7 @@ + + + +- ++ + + + +--- PCbuild/_hashlib.vcxproj ++++ PCbuild/_hashlib.vcxproj +@@ -45,7 +45,7 @@ + DynamicLibrary + NotSet + +- ++ + + .pyd + +@@ -64,7 +64,7 @@ + $(opensslIncludeDir);%(AdditionalIncludeDirectories) + + +- ws2_32.lib;$(OutDir)libeay$(PyDebugExt).lib;$(OutDir)ssleay$(PyDebugExt).lib;%(AdditionalDependencies) ++ ws2_32.lib;%(AdditionalDependencies) + + + +@@ -75,14 +75,14 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + + +--- PCbuild/_sqlite3.vcxproj ++++ PCbuild/_sqlite3.vcxproj +@@ -45,7 +45,7 @@ + DynamicLibrary + NotSet + +- ++ + + .pyd + +@@ -96,10 +96,10 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + + +--- PCbuild/_ssl.vcxproj ++++ PCbuild/_ssl.vcxproj +@@ -45,7 +45,7 @@ + DynamicLibrary + NotSet + +- ++ + + .pyd + +@@ -64,7 +64,7 @@ + $(opensslIncludeDir);%(AdditionalIncludeDirectories) + + +- ws2_32.lib;crypt32.lib;$(OutDir)libeay$(PyDebugExt).lib;$(OutDir)ssleay$(PyDebugExt).lib;%(AdditionalDependencies) ++ ws2_32.lib;crypt32.lib;%(AdditionalDependencies) + + + +@@ -75,14 +75,14 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + {86937f53-c189-40ef-8ce8-8759d8e7d480} + false +--- PCbuild/bz2.vcxproj ++++ PCbuild/bz2.vcxproj +@@ -47,7 +47,7 @@ + NotSet + + +- ++ + + .pyd + +@@ -72,13 +72,13 @@ + + + +- ++ + + + +--- PCbuild/_elementtree.vcxproj ++++ PCbuild/_elementtree.vcxproj +@@ -45,7 +45,7 @@ + DynamicLibrary + NotSet + +- ++ + + .pyd + +@@ -61,15 +61,15 @@ + + + +- ..\Modules\expat;%(AdditionalIncludeDirectories) +- _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) ++ %(AdditionalIncludeDirectories) ++ _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;%(PreprocessorDefinitions) + + + 0x1D100000 + + + +- ++ + + + +- ++ + + + +--- PCbuild/pyexpat.vcxproj ++++ PCbuild/pyexpat.vcxproj +@@ -45,7 +45,7 @@ + DynamicLibrary + NotSet + +- ++ + + .pyd + +@@ -58,19 +58,19 @@ + + + +- $(PySourcePath)Modules\expat;%(AdditionalIncludeDirectories) +- _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) ++ %(AdditionalIncludeDirectories) ++ _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;%(PreprocessorDefinitions) + + + +- +- ++ + + + +- ++ + + + +--- PCbuild/_tkinter.vcxproj ++++ PCbuild/_tkinter.vcxproj +@@ -45,7 +45,7 @@ + DynamicLibrary + NotSet + +- ++ + + .pyd + +@@ -61,11 +61,11 @@ + + + +- $(tcltkDir)include;%(AdditionalIncludeDirectories) ++ %(AdditionalIncludeDirectories) + WITH_APPINIT;%(PreprocessorDefinitions) + + +- $(tcltkLib);%(AdditionalDependencies) ++ %(AdditionalDependencies) + + + +@@ -77,12 +77,12 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + + diff --git a/recipes/cpython/all/patches/2.7.18-0002-add-support-msvc-14.patch b/recipes/cpython/all/patches/2.7.18-0002-add-support-msvc-14.patch new file mode 100644 index 0000000000000..6034410d3d265 --- /dev/null +++ b/recipes/cpython/all/patches/2.7.18-0002-add-support-msvc-14.patch @@ -0,0 +1,59 @@ +Patches from https://bugs.python.org/issue30742 + +--- Modules/posixmodule.c ++++ Modules/posixmodule.c +@@ -563,7 +563,10 @@ typedef struct { + char osfile; + } my_ioinfo; + ++#if _MSC_VER < 1900 // MSVS2013 and lower (https://bugs.python.org/issue30742) + extern __declspec(dllimport) char * __pioinfo[]; ++#endif ++ + #define IOINFO_L2E 5 + #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) + #define IOINFO_ARRAYS 64 +@@ -575,6 +578,7 @@ extern __declspec(dllimport) char * __pioinfo[]; + int + _PyVerify_fd(int fd) + { ++#if _MSC_VER < 1900 // MSVS2013 and lower (https://bugs.python.org/issue30742) + const int i1 = fd >> IOINFO_L2E; + const int i2 = fd & ((1 << IOINFO_L2E) - 1); + +@@ -607,6 +611,13 @@ _PyVerify_fd(int fd) + fail: + errno = EBADF; + return 0; ++#else ++ //a call to _get_osfhandle with invalid fd sets errno to EBADF ++ if (_get_osfhandle(fd) == INVALID_HANDLE_VALUE) ++ return 0; ++ else ++ return 1; ++#endif + } + + /* the special case of checking dup2. The target fd must be in a sensible range */ +--- Modules/timemodule.c ++++ Modules/timemodule.c +@@ -803,7 +803,18 @@ inittimezone(PyObject *m) { + + And I'm lazy and hate C so nyer. + */ +-#if defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__) ++#if defined(HAVE_TZNAME) && (_MSC_VER >= 1900) //MSVS2015+ (https://bugs.python.org/issue30742) ++ tzset(); ++ PyModule_AddIntConstant(m, "timezone", _timezone); ++#ifdef HAVE_ALTZONE ++ PyModule_AddIntConstant(m, "altzone", altzone); ++#else ++ PyModule_AddIntConstant(m, "altzone", _timezone - 3600); ++#endif ++ PyModule_AddIntConstant(m, "daylight", _daylight); ++ PyModule_AddObject(m, "tzname", ++ Py_BuildValue("(zz)", _tzname[0], _tzname[1])); ++#elif defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__) + tzset(); + #ifdef PYOS_OS2 + PyModule_AddIntConstant(m, "timezone", _timezone); diff --git a/recipes/cpython/all/patches/2.7.18-0003-msvc-fix-static.patch b/recipes/cpython/all/patches/2.7.18-0003-msvc-fix-static.patch new file mode 100644 index 0000000000000..9eb079402733d --- /dev/null +++ b/recipes/cpython/all/patches/2.7.18-0003-msvc-fix-static.patch @@ -0,0 +1,11 @@ +--- PC/dl_nt.c ++++ PC/dl_nt.c +@@ -107,5 +107,7 @@ + } + return TRUE; + } +- ++#else ++ULONG_PTR _Py_ActivateActCtx() { return 0; } ++void _Py_DeactivateActCtx(ULONG_PTR cookie) {} + #endif /* Py_ENABLE_SHARED */ diff --git a/recipes/cpython/all/patches/2.7.18-0004-disable-macos-tcltk.patch b/recipes/cpython/all/patches/2.7.18-0004-disable-macos-tcltk.patch new file mode 100644 index 0000000000000..5c61acd74bd5c --- /dev/null +++ b/recipes/cpython/all/patches/2.7.18-0004-disable-macos-tcltk.patch @@ -0,0 +1,15 @@ +--- setup.py ++++ setup.py +@@ -1928,9 +1928,9 @@ + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. +- if (host_platform == 'darwin' and +- self.detect_tkinter_darwin(inc_dirs, lib_dirs)): +- return ++ #if (host_platform == 'darwin' and ++ # self.detect_tkinter_darwin(inc_dirs, lib_dirs)): ++ # return + + # Assume we haven't found any of the libraries or include files + # The versions with dots are used on Unix, and the versions without diff --git a/recipes/cpython/all/patches/3.10.0-0001-msvc.patch b/recipes/cpython/all/patches/3.10.0-0001-msvc.patch new file mode 100644 index 0000000000000..e9b1faf061f3b --- /dev/null +++ b/recipes/cpython/all/patches/3.10.0-0001-msvc.patch @@ -0,0 +1,416 @@ +--- PCbuild/pcbuild.sln ++++ PCbuild/pcbuild.sln +@@ -58,2 +58,0 @@ +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcxproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}" +-EndProject +--- PCbuild/python.vcxproj ++++ PCbuild/python.vcxproj +@@ -120,1 +120,1 @@ +- ++ +--- PCbuild/_freeze_importlib.vcxproj ++++ PCbuild/_freeze_importlib.vcxproj +@@ -151,1 +151,1 @@ +- ++ --> +--- PCbuild/_bz2.vcxproj ++++ PCbuild/_bz2.vcxproj +@@ -71,7 +71,7 @@ + bz2 + Win32Proj + +- ++ + + + DynamicLibrary +@@ -101,17 +101,17 @@ + + + +- ++ + + +- +- ++ + + + +--- PCbuild/_ctypes.vcxproj ++++ PCbuild/_ctypes.vcxproj +@@ -71,7 +71,7 @@ + _ctypes + Win32Proj + +- ++ + + + DynamicLibrary +@@ -86,7 +86,7 @@ + + + +- ++ + + + +@@ -94,7 +94,7 @@ + + + +- FFI_BUILDING;%(PreprocessorDefinitions) ++ %(PreprocessorDefinitions) + + + /EXPORT:DllGetClassObject,PRIVATE /EXPORT:DllCanUnloadNow,PRIVATE %(AdditionalOptions) +--- PCbuild/_decimal.vcxproj ++++ PCbuild/_decimal.vcxproj +@@ -71,7 +71,7 @@ + _decimal + Win32Proj + +- ++ + + + DynamicLibrary +@@ -98,11 +98,11 @@ + CONFIG_32;ANSI;%(PreprocessorDefinitions) + CONFIG_64;ANSI;%(PreprocessorDefinitions) + CONFIG_64;MASM;%(PreprocessorDefinitions) +- ..\Modules\_decimal;..\Modules\_decimal\libmpdec;%(AdditionalIncludeDirectories) ++ ..\Modules\_decimal;%(AdditionalIncludeDirectories) + + + +- ++ + + + +- ++ + + +- ++ + + + +--- PCbuild/_lzma.vcxproj ++++ PCbuild/_lzma.vcxproj +@@ -71,7 +71,7 @@ + lzma + Win32Proj + +- ++ + + + DynamicLibrary +@@ -94,10 +94,10 @@ + + + $(lzmaDir)src/liblzma/api;%(AdditionalIncludeDirectories) +- WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LZMA_API_STATIC;%(PreprocessorDefinitions) ++ $(ConanPreprocessorDefinitions);WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LZMA_API_STATIC;%(PreprocessorDefinitions) + + +- $(OutDir)liblzma$(PyDebugExt).lib;%(AdditionalDependencies) ++ %(AdditionalDependencies) + + + +@@ -111,10 +111,10 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + + +--- PCbuild/_sqlite3.vcxproj ++++ PCbuild/_sqlite3.vcxproj +@@ -74,1 +74,1 @@ +- ++ +@@ -129,4 +129,4 @@ +- ++ +--- PCbuild/pythoncore.vcxproj ++++ PCbuild/pythoncore.vcxproj +@@ -73,1 +73,1 @@ +- ++ +@@ -302,7 +302,7 @@ + + + +- ++ + + + +@@ -496,7 +496,7 @@ + + + +- ++ + + + +--- PCbuild/_hashlib.vcxproj ++++ PCbuild/_hashlib.vcxproj +@@ -71,7 +71,7 @@ + _hashlib + Win32Proj + +- ++ + + + DynamicLibrary +@@ -86,7 +86,7 @@ + + + +- ++ + + + +--- PCbuild/_ssl.vcxproj ++++ PCbuild/_ssl.vcxproj +@@ -71,7 +71,7 @@ + _ssl + Win32Proj + +- ++ + + + DynamicLibrary +@@ -86,7 +86,7 @@ + + + +- ++ + + + +@@ -99,9 +99,9 @@ + + + +- ++ + + + +--- PCbuild/_elementtree.vcxproj ++++ PCbuild/_elementtree.vcxproj +@@ -71,7 +71,7 @@ + _elementtree + Win32Proj + +- ++ + + + DynamicLibrary +@@ -93,12 +93,12 @@ + + + +- ..\Modules\expat;%(AdditionalIncludeDirectories) +- _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) ++ %(AdditionalIncludeDirectories) ++ _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;%(PreprocessorDefinitions) + + + +- ++ + + + +- ++ + + + +--- PCbuild/pyexpat.vcxproj ++++ PCbuild/pyexpat.vcxproj +@@ -71,7 +71,7 @@ + {D06B6426-4762-44CC-8BAD-D79052507F2F} + pyexpat + +- ++ + + + DynamicLibrary +@@ -90,19 +90,19 @@ + + + +- $(PySourcePath)Modules\expat;%(AdditionalIncludeDirectories) +- _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_STATIC;%(PreprocessorDefinitions) ++ %(AdditionalIncludeDirectories) ++ _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;%(PreprocessorDefinitions) + + + +- +- ++ + + + +- ++ + + + +--- PCbuild/_tkinter.vcxproj ++++ PCbuild/_tkinter.vcxproj +@@ -77,7 +77,7 @@ + DynamicLibrary + NotSet + +- ++ + + .pyd + +@@ -93,12 +93,12 @@ + + + +- $(tcltkDir)include;%(AdditionalIncludeDirectories) ++ %(AdditionalIncludeDirectories) + WITH_APPINIT;%(PreprocessorDefinitions) +- Py_TCLTK_DIR="$(tcltkDir.TrimEnd('\').Replace('\', '\\'))";%(PreprocessorDefinitions) ++ + + +- $(tcltkLib);%(AdditionalDependencies) ++ %(AdditionalDependencies) + + + +@@ -108,10 +108,10 @@ + + + +- ++ + + + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} +--- PCbuild/pcbuild.sln ++++ PCbuild/pcbuild.sln +@@ -9,9 +9,6 @@ + EndProjectSection + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcxproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" +- ProjectSection(ProjectDependencies) = postProject +- {0E9791DB-593A-465F-98BC-681011311618} = {0E9791DB-593A-465F-98BC-681011311618} +- EndProjectSection + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcxproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" + EndProject diff --git a/recipes/cpython/all/patches/3.10.0-0003-_ctypes-ffi.patch b/recipes/cpython/all/patches/3.10.0-0003-_ctypes-ffi.patch new file mode 100644 index 0000000000000..4bc35cf905b12 --- /dev/null +++ b/recipes/cpython/all/patches/3.10.0-0003-_ctypes-ffi.patch @@ -0,0 +1,50 @@ +--- Modules/_ctypes/cfield.c ++++ Modules/_ctypes/cfield.c +@@ -1472,7 +1472,11 @@ + return PyLong_FromVoidPtr(*(void **)ptr); + } + +-static struct fielddesc formattable[] = { ++#define FORMATTABLE_SIZE 30 ++static struct fielddesc formattable[FORMATTABLE_SIZE]; ++ ++static void formattable_init(void) { ++struct fielddesc my_formattable[] = { + { 's', s_set, s_get, &ffi_type_pointer}, + { 'b', b_set, b_get, &ffi_type_schar}, + { 'B', B_set, B_get, &ffi_type_uchar}, +@@ -1524,6 +1528,11 @@ + { 'O', O_set, O_get, &ffi_type_pointer}, + { 0, NULL, NULL, NULL}, + }; ++ size_t nb = 1; ++ for (struct fielddesc *pos = my_formattable; pos->code; ++pos, ++nb); ++ if (FORMATTABLE_SIZE < nb) abort(); ++ memcpy(formattable, my_formattable, nb * sizeof(struct fielddesc)); ++} + + /* + Ideas: Implement VARIANT in this table, using 'V' code. +@@ -1538,5 +1547,6 @@ + + if (!initialized) { + initialized = 1; ++ formattable_init(); + if (sizeof(wchar_t) == sizeof(short)) + _ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sshort; +@@ -1598,7 +1608,7 @@ typedef struct _ffi_type + struct _ffi_type **elements; + } ffi_type; + */ +- ++#if 0 + /* align and size are bogus for void, but they must not be zero */ + ffi_type ffi_type_void = { 1, 1, FFI_TYPE_VOID }; + +@@ -1625,5 +1635,5 @@ + FFI_TYPE_LONGDOUBLE }; + + ffi_type ffi_type_pointer = { sizeof(void *), VOID_P_ALIGN, FFI_TYPE_POINTER }; +- ++#endif + /*---------------- EOF ----------------*/ diff --git a/recipes/cpython/all/patches/3.10.0-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch b/recipes/cpython/all/patches/3.10.0-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch new file mode 100644 index 0000000000000..0288bdae92ee9 --- /dev/null +++ b/recipes/cpython/all/patches/3.10.0-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch @@ -0,0 +1,15 @@ +--- Makefile.pre.in ++++ Makefile.pre.in +@@ -627,10 +627,10 @@ + *\ -s*|s*) quiet="-q";; \ + *) quiet="";; \ + esac; \ +- echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ echo "$(RUNSHARED) CC='$(CC) $(CONFIGURE_CFLAGS) $(CONFIGURE_CPPFLAGS)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build"; \ +- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ $(RUNSHARED) CC='$(CC) $(CONFIGURE_CFLAGS) $(CONFIGURE_CPPFLAGS)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build + diff --git a/recipes/cpython/all/patches/3.10.0-0005-disable-macos-tcltk.patch b/recipes/cpython/all/patches/3.10.0-0005-disable-macos-tcltk.patch new file mode 100644 index 0000000000000..ec23890e0a717 --- /dev/null +++ b/recipes/cpython/all/patches/3.10.0-0005-disable-macos-tcltk.patch @@ -0,0 +1,13 @@ +--- setup.py ++++ setup.py +@@ -2094,8 +2094,8 @@ + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. +- if (MACOS and self.detect_tkinter_darwin()): +- return True ++ #if (MACOS and self.detect_tkinter_darwin()): ++ # return True + + # Assume we haven't found any of the libraries or include files + # The versions with dots are used on Unix, and the versions without diff --git a/recipes/cpython/all/patches/3.7.9-0001-msvc.patch b/recipes/cpython/all/patches/3.7.9-0001-msvc.patch new file mode 100644 index 0000000000000..29be01b13f5b5 --- /dev/null +++ b/recipes/cpython/all/patches/3.7.9-0001-msvc.patch @@ -0,0 +1,416 @@ +--- PCbuild/pcbuild.sln ++++ PCbuild/pcbuild.sln +@@ -58,2 +58,0 @@ +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcxproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}" +-EndProject +--- PCbuild/python.vcxproj ++++ PCbuild/python.vcxproj +@@ -85,1 +85,1 @@ +- ++ +--- PCbuild/_freeze_importlib.vcxproj ++++ PCbuild/_freeze_importlib.vcxproj +@@ -110,1 +110,1 @@ +- ++ --> +--- PCbuild/_bz2.vcxproj ++++ PCbuild/_bz2.vcxproj +@@ -39,7 +39,7 @@ + bz2 + Win32Proj + +- ++ + + + DynamicLibrary +@@ -69,17 +69,17 @@ + + + +- ++ + + +- +- ++ + + + +--- PCbuild/_decimal.vcxproj ++++ PCbuild/_decimal.vcxproj +@@ -39,7 +39,7 @@ + _decimal + Win32Proj + +- ++ + + + DynamicLibrary +@@ -64,11 +64,11 @@ + _CRT_SECURE_NO_WARNINGS;MASM;%(PreprocessorDefinitions) + CONFIG_32;PPRO;%(PreprocessorDefinitions) + CONFIG_64;%(PreprocessorDefinitions) +- ..\Modules\_decimal;..\Modules\_decimal\libmpdec;%(AdditionalIncludeDirectories) ++ ..\Modules\_decimal;%(AdditionalIncludeDirectories) + + + +- ++ + + + +- ++ + + +- ++ + + + +--- PCbuild/_elementtree.vcxproj ++++ PCbuild/_elementtree.vcxproj +@@ -39,7 +39,7 @@ + _elementtree + Win32Proj + +- ++ + + + DynamicLibrary +@@ -65,8 +65,8 @@ +- _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) ++ _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;%(PreprocessorDefinitions) + + + +- ++ + + + +- ++ + + + +--- PCbuild/_lzma.vcxproj ++++ PCbuild/_lzma.vcxproj +@@ -39,7 +39,7 @@ + lzma + Win32Proj + +- ++ + + + DynamicLibrary +@@ -62,10 +62,10 @@ + + + $(lzmaDir)src/liblzma/api;%(AdditionalIncludeDirectories) +- WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LZMA_API_STATIC;%(PreprocessorDefinitions) ++ $(ConanPreprocessorDefinitions);WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LZMA_API_STATIC;%(PreprocessorDefinitions) + + +- $(OutDir)liblzma$(PyDebugExt).lib;%(AdditionalDependencies) ++ %(AdditionalDependencies) + + + +@@ -79,10 +79,10 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + + +--- PCbuild/_sqlite3.vcxproj ++++ PCbuild/_sqlite3.vcxproj +@@ -39,7 +39,7 @@ + _sqlite3 + Win32Proj + +- ++ + + + DynamicLibrary +@@ -95,10 +95,10 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + + +--- PCbuild/openssl.vcxproj ++++ PCbuild/openssl.vcxproj +@@ -74,6 +74,6 @@ nmake + + + +- ++ + + + +--- PCbuild/pyexpat.vcxproj ++++ PCbuild/pyexpat.vcxproj +@@ -39,7 +39,7 @@ + {D06B6426-4762-44CC-8BAD-D79052507F2F} + pyexpat + +- ++ + + + DynamicLibrary +@@ -58,19 +58,19 @@ + + + +- $(PySourcePath)Modules\expat;%(AdditionalIncludeDirectories) +- _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_STATIC;%(PreprocessorDefinitions) ++ %(AdditionalIncludeDirectories) ++ _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + +- +- ++ + + + +- ++ + + + +--- PCbuild/pythoncore.vcxproj ++++ PCbuild/pythoncore.vcxproj +@@ -38,7 +38,7 @@ + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + pythoncore + +- ++ + + + DynamicLibrary +@@ -215,7 +215,7 @@ + + + +- ++ + + + +@@ -409,7 +409,7 @@ + + + +- ++ + + + +--- PCbuild/_hashlib.vcxproj ++++ PCbuild/_hashlib.vcxproj +@@ -39,7 +39,7 @@ + _hashlib + Win32Proj + +- ++ + + + DynamicLibrary +@@ -54,7 +54,7 @@ + + + +- ++ + + + +--- PCbuild/_ssl.vcxproj ++++ PCbuild/_ssl.vcxproj +@@ -39,7 +39,7 @@ + _ssl + Win32Proj + +- ++ + + + DynamicLibrary +@@ -54,7 +54,7 @@ + + + +- ++ + + + +@@ -67,9 +67,9 @@ + + + +- ++ + + + +--- PCbuild/_tkinter.vcxproj ++++ PCbuild/_tkinter.vcxproj +@@ -45,7 +45,7 @@ + DynamicLibrary + NotSet + +- ++ + + .pyd + +@@ -61,12 +61,12 @@ + + + +- $(tcltkDir)include;%(AdditionalIncludeDirectories) ++ %(AdditionalIncludeDirectories) + WITH_APPINIT;%(PreprocessorDefinitions) +- Py_TCLTK_DIR="$(tcltkDir.TrimEnd('\').Replace('\', '\\'))";%(PreprocessorDefinitions) ++ + + +- $(tcltkLib);%(AdditionalDependencies) ++ %(AdditionalDependencies) + + + +@@ -76,10 +76,10 @@ + + + +- ++ + + + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} +--- PCbuild/pcbuild.sln ++++ PCbuild/pcbuild.sln +@@ -9,9 +9,6 @@ + EndProjectSection + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcxproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" +- ProjectSection(ProjectDependencies) = postProject +- {0E9791DB-593A-465F-98BC-681011311618} = {0E9791DB-593A-465F-98BC-681011311618} +- EndProjectSection + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcxproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" + EndProject diff --git a/recipes/cpython/all/patches/3.7.9-0002-setup.py-pass-CFLAGS-CPPFLAGS.patch b/recipes/cpython/all/patches/3.7.9-0002-setup.py-pass-CFLAGS-CPPFLAGS.patch new file mode 100644 index 0000000000000..92e44c8ea6ee5 --- /dev/null +++ b/recipes/cpython/all/patches/3.7.9-0002-setup.py-pass-CFLAGS-CPPFLAGS.patch @@ -0,0 +1,15 @@ +--- Makefile.pre.in ++++ Makefile.pre.in +@@ -618,10 +618,10 @@ + *\ -s*|s*) quiet="-q";; \ + *) quiet="";; \ + esac; \ +- echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ echo "$(RUNSHARED) CC='$(CC) $(CONFIGURE_CFLAGS) $(CONFIGURE_CPPFLAGS)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build"; \ +- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ $(RUNSHARED) CC='$(CC) $(CONFIGURE_CFLAGS) $(CONFIGURE_CPPFLAGS)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build + diff --git a/recipes/cpython/all/patches/3.7.9-0003-disable-macos-tcltk.patch b/recipes/cpython/all/patches/3.7.9-0003-disable-macos-tcltk.patch new file mode 100644 index 0000000000000..f5ffba2f61232 --- /dev/null +++ b/recipes/cpython/all/patches/3.7.9-0003-disable-macos-tcltk.patch @@ -0,0 +1,15 @@ +--- setup.py ++++ setup.py +@@ -1829,9 +1829,9 @@ + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. +- if (host_platform == 'darwin' and +- self.detect_tkinter_darwin(inc_dirs, lib_dirs)): +- return ++ #if (host_platform == 'darwin' and ++ # self.detect_tkinter_darwin(inc_dirs, lib_dirs)): ++ # return + + # Assume we haven't found any of the libraries or include files + # The versions with dots are used on Unix, and the versions without diff --git a/recipes/cpython/all/patches/3.8.12-0001-msvc.patch b/recipes/cpython/all/patches/3.8.12-0001-msvc.patch new file mode 100644 index 0000000000000..4e390810d2dde --- /dev/null +++ b/recipes/cpython/all/patches/3.8.12-0001-msvc.patch @@ -0,0 +1,431 @@ +--- PCbuild/pcbuild.sln ++++ PCbuild/pcbuild.sln +@@ -60,2 +60,0 @@ +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcxproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}" +-EndProject +--- PCbuild/python.vcxproj ++++ PCbuild/python.vcxproj +@@ -118,1 +118,1 @@ +- ++ +--- PCbuild/_freeze_importlib.vcxproj ++++ PCbuild/_freeze_importlib.vcxproj +@@ -149,1 +149,1 @@ +- ++ --> +--- PCbuild/_bz2.vcxproj ++++ PCbuild/_bz2.vcxproj +@@ -71,7 +71,7 @@ + bz2 + Win32Proj + +- ++ + + + DynamicLibrary +@@ -101,17 +101,17 @@ + + + +- ++ + + +- +- ++ + + + +--- PCbuild/_ctypes.vcxproj ++++ PCbuild/_ctypes.vcxproj +@@ -71,7 +71,7 @@ + _ctypes + Win32Proj + +- ++ + + + DynamicLibrary +@@ -86,7 +86,7 @@ + + + +- ++ + + + +@@ -94,7 +94,7 @@ + + + +- FFI_BUILDING;%(PreprocessorDefinitions) ++ %(PreprocessorDefinitions) + + + /EXPORT:DllGetClassObject,PRIVATE /EXPORT:DllCanUnloadNow,PRIVATE %(AdditionalOptions) +--- PCbuild/_decimal.vcxproj ++++ PCbuild/_decimal.vcxproj +@@ -71,7 +71,7 @@ + _decimal + Win32Proj + +- ++ + + + DynamicLibrary +@@ -98,11 +98,11 @@ + CONFIG_32;ANSI;%(PreprocessorDefinitions) + CONFIG_64;ANSI;%(PreprocessorDefinitions) + CONFIG_64;%(PreprocessorDefinitions) +- ..\Modules\_decimal;..\Modules\_decimal\libmpdec;%(AdditionalIncludeDirectories) ++ ..\Modules\_decimal;%(AdditionalIncludeDirectories) + + + +- ++ + + + +- ++ + + +- ++ + + + +--- PCbuild/_lzma.vcxproj ++++ PCbuild/_lzma.vcxproj +@@ -71,7 +71,7 @@ + lzma + Win32Proj + +- ++ + + + DynamicLibrary +@@ -94,10 +94,10 @@ + + + $(lzmaDir)src/liblzma/api;%(AdditionalIncludeDirectories) +- WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LZMA_API_STATIC;%(PreprocessorDefinitions) ++ $(ConanPreprocessorDefinitions);WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LZMA_API_STATIC;%(PreprocessorDefinitions) + + +- $(OutDir)liblzma$(PyDebugExt).lib;%(AdditionalDependencies) ++ %(AdditionalDependencies) + + + +@@ -111,10 +111,10 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + + +--- PCbuild/_sqlite3.vcxproj ++++ PCbuild/_sqlite3.vcxproj +@@ -71,7 +71,7 @@ + _sqlite3 + Win32Proj + +- ++ + + + DynamicLibrary +@@ -127,10 +127,10 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + + +--- PCbuild/pythoncore.vcxproj ++++ PCbuild/pythoncore.vcxproj +@@ -70,7 +70,7 @@ + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + pythoncore + +- ++ + + + DynamicLibrary +@@ -272,7 +272,7 @@ + + + +- ++ + + + +@@ -468,7 +468,7 @@ + + + +- ++ + + + +--- PCbuild/_hashlib.vcxproj ++++ PCbuild/_hashlib.vcxproj +@@ -71,7 +71,7 @@ + _hashlib + Win32Proj + +- ++ + + + DynamicLibrary +@@ -86,7 +86,7 @@ + + + +- ++ + + + +--- PCbuild/_ssl.vcxproj ++++ PCbuild/_ssl.vcxproj +@@ -71,7 +71,7 @@ + _ssl + Win32Proj + +- ++ + + + DynamicLibrary +@@ -86,7 +86,7 @@ + + + +- ++ + + + +@@ -99,9 +99,9 @@ + + + +- ++ + + + +--- PCbuild/_elementtree.vcxproj ++++ PCbuild/_elementtree.vcxproj +@@ -71,7 +71,7 @@ + _elementtree + Win32Proj + +- ++ + + + DynamicLibrary +@@ -93,12 +93,12 @@ + + + +- ..\Modules\expat;%(AdditionalIncludeDirectories) +- _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) ++ %(AdditionalIncludeDirectories) ++ _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;%(PreprocessorDefinitions) + + + +- ++ + + + +- ++ + + + +--- PCbuild/pyexpat.vcxproj ++++ PCbuild/pyexpat.vcxproj +@@ -71,7 +71,7 @@ + {D06B6426-4762-44CC-8BAD-D79052507F2F} + pyexpat + +- ++ + + + DynamicLibrary +@@ -91,18 +91,18 @@ + + + $(PySourcePath)Modules\expat;%(AdditionalIncludeDirectories) +- _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_STATIC;%(PreprocessorDefinitions) ++ _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;HAVE_EXPAT_H;%(PreprocessorDefinitions) + + + +- +- ++ + + + +- ++ + + + +--- PCbuild/_tkinter.vcxproj ++++ PCbuild/_tkinter.vcxproj +@@ -77,7 +77,7 @@ + DynamicLibrary + NotSet + +- ++ + + .pyd + +@@ -93,12 +93,12 @@ + + + +- $(tcltkDir)include;%(AdditionalIncludeDirectories) ++ %(AdditionalIncludeDirectories) + WITH_APPINIT;%(PreprocessorDefinitions) +- Py_TCLTK_DIR="$(tcltkDir.TrimEnd('\').Replace('\', '\\'))";%(PreprocessorDefinitions) ++ + + +- $(tcltkLib);%(AdditionalDependencies) ++ %(AdditionalDependencies) + + + +@@ -108,10 +108,10 @@ + + + +- ++ + + + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} +--- PCbuild/pcbuild.sln ++++ PCbuild/pcbuild.sln +@@ -9,9 +9,6 @@ + EndProjectSection + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcxproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" +- ProjectSection(ProjectDependencies) = postProject +- {0E9791DB-593A-465F-98BC-681011311618} = {0E9791DB-593A-465F-98BC-681011311618} +- EndProjectSection + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcxproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" + EndProject diff --git a/recipes/cpython/all/patches/3.8.12-0002-_ctypes-ffi.patch b/recipes/cpython/all/patches/3.8.12-0002-_ctypes-ffi.patch new file mode 100644 index 0000000000000..04b87052a81e0 --- /dev/null +++ b/recipes/cpython/all/patches/3.8.12-0002-_ctypes-ffi.patch @@ -0,0 +1,67 @@ +comments --- Modules/_ctypes/malloc_closure.c +comments +++ Modules/_ctypes/malloc_closure.c +comments @@ -87,7 +87,7 @@ +comments } +comments +comments /******************************************************************/ +comments - +comments +#if 0 +comments /* put the item back into the free list */ +comments void ffi_closure_free(void *p) +comments { +comments @@ -114,3 +114,4 @@ +comments #endif +comments return (void *)item; +comments } +comments +#endif +--- Modules/_ctypes/cfield.c ++++ Modules/_ctypes/cfield.c +@@ -1510,7 +1510,11 @@ + return PyLong_FromVoidPtr(*(void **)ptr); + } + +-static struct fielddesc formattable[] = { ++#define FORMATTABLE_SIZE 30 ++static struct fielddesc formattable[FORMATTABLE_SIZE]; ++ ++static void formattable_init(void) { ++struct fielddesc my_formattable[] = { + { 's', s_set, s_get, &ffi_type_pointer}, + { 'b', b_set, b_get, &ffi_type_schar}, + { 'B', B_set, B_get, &ffi_type_uchar}, +@@ -1564,6 +1568,11 @@ + { 'O', O_set, O_get, &ffi_type_pointer}, + { 0, NULL, NULL, NULL}, + }; ++ size_t nb = 1; ++ for (struct fielddesc *pos = my_formattable; pos->code; ++pos, ++nb); ++ if (FORMATTABLE_SIZE < nb) abort(); ++ memcpy(formattable, my_formattable, nb * sizeof(struct fielddesc)); ++} + + /* + Ideas: Implement VARIANT in this table, using 'V' code. +@@ -1578,6 +1587,7 @@ + + if (!initialized) { + initialized = 1; ++ formattable_init(); + #ifdef CTYPES_UNICODE + if (sizeof(wchar_t) == sizeof(short)) + _ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sshort; +@@ -1640,7 +1650,7 @@ + struct _ffi_type **elements; + } ffi_type; + */ +- ++#if 0 + /* align and size are bogus for void, but they must not be zero */ + ffi_type ffi_type_void = { 1, 1, FFI_TYPE_VOID }; + +@@ -1667,5 +1677,5 @@ + FFI_TYPE_LONGDOUBLE }; + + ffi_type ffi_type_pointer = { sizeof(void *), VOID_P_ALIGN, FFI_TYPE_POINTER }; +- ++#endif + /*---------------- EOF ----------------*/ diff --git a/recipes/cpython/all/patches/3.8.12-0003-setup.py-pass-CFLAGS-CPPFLAGS.patch b/recipes/cpython/all/patches/3.8.12-0003-setup.py-pass-CFLAGS-CPPFLAGS.patch new file mode 100644 index 0000000000000..21527d0ed307f --- /dev/null +++ b/recipes/cpython/all/patches/3.8.12-0003-setup.py-pass-CFLAGS-CPPFLAGS.patch @@ -0,0 +1,15 @@ +--- Makefile.pre.in ++++ Makefile.pre.in +@@ -606,10 +606,10 @@ + *\ -s*|s*) quiet="-q";; \ + *) quiet="";; \ + esac; \ +- echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ echo "$(RUNSHARED) CC='$(CC) $(CONFIGURE_CFLAGS) $(CONFIGURE_CPPFLAGS)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build"; \ +- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ $(RUNSHARED) CC='$(CC) $(CONFIGURE_CFLAGS) $(CONFIGURE_CPPFLAGS)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build + diff --git a/recipes/cpython/all/patches/3.8.12-0004-disable-macos-tcltk.patch b/recipes/cpython/all/patches/3.8.12-0004-disable-macos-tcltk.patch new file mode 100644 index 0000000000000..90af822b58070 --- /dev/null +++ b/recipes/cpython/all/patches/3.8.12-0004-disable-macos-tcltk.patch @@ -0,0 +1,13 @@ +--- setup.py ++++ setup.py +@@ -1838,8 +1838,8 @@ + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. +- if (MACOS and self.detect_tkinter_darwin()): +- return True ++ #if (MACOS and self.detect_tkinter_darwin()): ++ # return True + + # Assume we haven't found any of the libraries or include files + # The versions with dots are used on Unix, and the versions without diff --git a/recipes/cpython/all/patches/3.9.7-0001-msvc.patch b/recipes/cpython/all/patches/3.9.7-0001-msvc.patch new file mode 100644 index 0000000000000..fac9247123880 --- /dev/null +++ b/recipes/cpython/all/patches/3.9.7-0001-msvc.patch @@ -0,0 +1,434 @@ +--- PCbuild/pcbuild.sln ++++ PCbuild/pcbuild.sln +@@ -60,2 +60,0 @@ +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcxproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}" +-EndProject +--- PCbuild/python.vcxproj ++++ PCbuild/python.vcxproj +@@ -118,1 +118,1 @@ +- ++ +--- PCbuild/_freeze_importlib.vcxproj ++++ PCbuild/_freeze_importlib.vcxproj +@@ -149,1 +149,1 @@ +- ++ --> +--- PCbuild/_bz2.vcxproj ++++ PCbuild/_bz2.vcxproj +@@ -71,7 +71,7 @@ + bz2 + Win32Proj + +- ++ + + + DynamicLibrary +@@ -101,17 +101,17 @@ + + + +- ++ + + +- +- ++ + + + +--- PCbuild/_ctypes.vcxproj ++++ PCbuild/_ctypes.vcxproj +@@ -71,7 +71,7 @@ + _ctypes + Win32Proj + +- ++ + + + DynamicLibrary +@@ -86,7 +86,7 @@ + + + +- ++ + + + +@@ -94,7 +94,7 @@ + + + +- FFI_BUILDING;%(PreprocessorDefinitions) ++ %(PreprocessorDefinitions) + + + /EXPORT:DllGetClassObject,PRIVATE /EXPORT:DllCanUnloadNow,PRIVATE %(AdditionalOptions) +--- PCbuild/_decimal.vcxproj ++++ PCbuild/_decimal.vcxproj +@@ -71,7 +71,7 @@ + _decimal + Win32Proj + +- ++ + + + DynamicLibrary +@@ -98,11 +98,11 @@ + CONFIG_32;ANSI;%(PreprocessorDefinitions) + CONFIG_64;ANSI;%(PreprocessorDefinitions) + CONFIG_64;%(PreprocessorDefinitions) +- ..\Modules\_decimal;..\Modules\_decimal\libmpdec;%(AdditionalIncludeDirectories) ++ ..\Modules\_decimal;%(AdditionalIncludeDirectories) + + + +- ++ + + + +- ++ + + +- ++ + + + +--- PCbuild/_lzma.vcxproj ++++ PCbuild/_lzma.vcxproj +@@ -71,7 +71,7 @@ + lzma + Win32Proj + +- ++ + + + DynamicLibrary +@@ -94,10 +94,10 @@ + + + $(lzmaDir)src/liblzma/api;%(AdditionalIncludeDirectories) +- WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LZMA_API_STATIC;%(PreprocessorDefinitions) ++ $(ConanPreprocessorDefinitions);WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LZMA_API_STATIC;%(PreprocessorDefinitions) + + +- $(OutDir)liblzma$(PyDebugExt).lib;%(AdditionalDependencies) ++ %(AdditionalDependencies) + + + +@@ -111,10 +111,10 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + + +--- PCbuild/_sqlite3.vcxproj ++++ PCbuild/_sqlite3.vcxproj +@@ -71,7 +71,7 @@ + _sqlite3 + Win32Proj + +- ++ + + + DynamicLibrary +@@ -127,10 +127,10 @@ + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} + false + +- ++ + + + +--- PCbuild/pythoncore.vcxproj ++++ PCbuild/pythoncore.vcxproj +@@ -70,7 +70,7 @@ + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} + pythoncore + +- ++ + + + DynamicLibrary +@@ -295,7 +295,7 @@ + + + +- ++ + + + +@@ -497,7 +497,7 @@ + + + +- ++ + + + +--- PCbuild/_hashlib.vcxproj ++++ PCbuild/_hashlib.vcxproj +@@ -71,7 +71,7 @@ + _hashlib + Win32Proj + +- ++ + + + DynamicLibrary +@@ -86,7 +86,7 @@ + + + +- ++ + + + +--- PCbuild/_ssl.vcxproj ++++ PCbuild/_ssl.vcxproj +@@ -71,7 +71,7 @@ + _ssl + Win32Proj + +- ++ + + + DynamicLibrary +@@ -86,7 +86,7 @@ + + + +- ++ + + + +@@ -99,9 +99,9 @@ + + + +- ++ + + + +--- PCbuild/_elementtree.vcxproj ++++ PCbuild/_elementtree.vcxproj +@@ -71,7 +71,7 @@ + _elementtree + Win32Proj + +- ++ + + + DynamicLibrary +@@ -93,12 +93,12 @@ + + + +- ..\Modules\expat;%(AdditionalIncludeDirectories) +- _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) ++ %(AdditionalIncludeDirectories) ++ _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;%(PreprocessorDefinitions) + + + +- ++ + + + +- ++ + + + +--- PCbuild/pyexpat.vcxproj ++++ PCbuild/pyexpat.vcxproj +@@ -71,7 +71,7 @@ + {D06B6426-4762-44CC-8BAD-D79052507F2F} + pyexpat + +- ++ + + + DynamicLibrary +@@ -90,19 +90,19 @@ + + + +- $(PySourcePath)Modules\expat;%(AdditionalIncludeDirectories) +- _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_STATIC;%(PreprocessorDefinitions) ++ %(AdditionalIncludeDirectories) ++ _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;%(PreprocessorDefinitions) + + + +- +- ++ + + + +- ++ + + + +--- PCbuild/_tkinter.vcxproj ++++ PCbuild/_tkinter.vcxproj +@@ -77,7 +77,7 @@ + DynamicLibrary + NotSet + +- ++ + + .pyd + +@@ -93,12 +93,12 @@ + + + +- $(tcltkDir)include;%(AdditionalIncludeDirectories) ++ %(AdditionalIncludeDirectories) + WITH_APPINIT;%(PreprocessorDefinitions) +- Py_TCLTK_DIR="$(tcltkDir.TrimEnd('\').Replace('\', '\\'))";%(PreprocessorDefinitions) ++ + + +- $(tcltkLib);%(AdditionalDependencies) ++ %(AdditionalDependencies) + + + +@@ -108,10 +108,10 @@ + + + +- ++ + + + {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} +--- PCbuild/pcbuild.sln ++++ PCbuild/pcbuild.sln +@@ -9,9 +9,6 @@ + EndProjectSection + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcxproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" +- ProjectSection(ProjectDependencies) = postProject +- {0E9791DB-593A-465F-98BC-681011311618} = {0E9791DB-593A-465F-98BC-681011311618} +- EndProjectSection + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcxproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" + EndProject diff --git a/recipes/cpython/all/patches/3.9.7-0002-_msi-vcxproj.patch b/recipes/cpython/all/patches/3.9.7-0002-_msi-vcxproj.patch new file mode 100644 index 0000000000000..0dd36511dc9e0 --- /dev/null +++ b/recipes/cpython/all/patches/3.9.7-0002-_msi-vcxproj.patch @@ -0,0 +1,11 @@ +--- PCbuild/_msi.vcxproj ++++ PCbuild/_msi.vcxproj +@@ -23,7 +23,7 @@ + + + PGInstrument +- ARM4 ++ ARM64 + + + PGInstrument diff --git a/recipes/cpython/all/patches/3.9.7-0003-_ctypes-ffi.patch b/recipes/cpython/all/patches/3.9.7-0003-_ctypes-ffi.patch new file mode 100644 index 0000000000000..aecf32f4f6594 --- /dev/null +++ b/recipes/cpython/all/patches/3.9.7-0003-_ctypes-ffi.patch @@ -0,0 +1,51 @@ +--- Modules/_ctypes/cfield.c ++++ Modules/_ctypes/cfield.c +@@ -1504,7 +1504,11 @@ + return PyLong_FromVoidPtr(*(void **)ptr); + } + +-static struct fielddesc formattable[] = { ++#define FORMATTABLE_SIZE 30 ++static struct fielddesc formattable[FORMATTABLE_SIZE]; ++ ++static void formattable_init(void) { ++struct fielddesc my_formattable[] = { + { 's', s_set, s_get, &ffi_type_pointer}, + { 'b', b_set, b_get, &ffi_type_schar}, + { 'B', B_set, B_get, &ffi_type_uchar}, +@@ -1558,6 +1562,11 @@ + { 'O', O_set, O_get, &ffi_type_pointer}, + { 0, NULL, NULL, NULL}, + }; ++ size_t nb = 1; ++ for (struct fielddesc *pos = my_formattable; pos->code; ++pos, ++nb); ++ if (FORMATTABLE_SIZE < nb) abort(); ++ memcpy(formattable, my_formattable, nb * sizeof(struct fielddesc)); ++} + + /* + Ideas: Implement VARIANT in this table, using 'V' code. +@@ -1572,6 +1581,7 @@ + + if (!initialized) { + initialized = 1; ++ formattable_init(); + #ifdef CTYPES_UNICODE + if (sizeof(wchar_t) == sizeof(short)) + _ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sshort; +@@ -1634,7 +1644,7 @@ + struct _ffi_type **elements; + } ffi_type; + */ +- ++#if 0 + /* align and size are bogus for void, but they must not be zero */ + ffi_type ffi_type_void = { 1, 1, FFI_TYPE_VOID }; + +@@ -1661,5 +1671,5 @@ + FFI_TYPE_LONGDOUBLE }; + + ffi_type ffi_type_pointer = { sizeof(void *), VOID_P_ALIGN, FFI_TYPE_POINTER }; +- ++#endif + /*---------------- EOF ----------------*/ diff --git a/recipes/cpython/all/patches/3.9.7-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch b/recipes/cpython/all/patches/3.9.7-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch new file mode 100644 index 0000000000000..0bec735b3653d --- /dev/null +++ b/recipes/cpython/all/patches/3.9.7-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch @@ -0,0 +1,15 @@ +--- Makefile.pre.in ++++ Makefile.pre.in +@@ -630,10 +630,10 @@ + *\ -s*|s*) quiet="-q";; \ + *) quiet="";; \ + esac; \ +- echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ echo "$(RUNSHARED) CC='$(CC) $(CONFIGURE_CFLAGS) $(CONFIGURE_CPPFLAGS)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build"; \ +- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ $(RUNSHARED) CC='$(CC) $(CONFIGURE_CFLAGS) $(CONFIGURE_CPPFLAGS)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build + diff --git a/recipes/cpython/all/patches/3.9.7-0005-disable-macos-tcltk.patch b/recipes/cpython/all/patches/3.9.7-0005-disable-macos-tcltk.patch new file mode 100644 index 0000000000000..68a48853b3089 --- /dev/null +++ b/recipes/cpython/all/patches/3.9.7-0005-disable-macos-tcltk.patch @@ -0,0 +1,13 @@ +--- setup.py ++++ setup.py +@@ -1986,8 +1986,8 @@ + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. +- if (MACOS and self.detect_tkinter_darwin()): +- return True ++ #if (MACOS and self.detect_tkinter_darwin()): ++ # return True + + # Assume we haven't found any of the libraries or include files + # The versions with dots are used on Unix, and the versions without diff --git a/recipes/cpython/all/patches/3.x-0001-relocatable-python-config.patch b/recipes/cpython/all/patches/3.x-0001-relocatable-python-config.patch new file mode 100644 index 0000000000000..113aa2108bbe6 --- /dev/null +++ b/recipes/cpython/all/patches/3.x-0001-relocatable-python-config.patch @@ -0,0 +1,11 @@ +--- Misc/python-config.sh.in ++++ Misc/python-config.sh.in +@@ -30,7 +30,7 @@ + # locations. Keep prefix & exec_prefix using their original values in case + # they are referenced in other configure variables, to prevent double + # substitution, issue #22140. +-prefix="@prefix@" ++prefix="$PYTHON_ROOT" + exec_prefix="@exec_prefix@" + exec_prefix_real=${prefix_real} + includedir=$(echo "@includedir@" | sed "s#$prefix#$prefix_real#") diff --git a/recipes/cpython/all/test_package/CMakeLists.txt b/recipes/cpython/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..525329324757f --- /dev/null +++ b/recipes/cpython/all/test_package/CMakeLists.txt @@ -0,0 +1,100 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup() + +set(CACHE PY_VERSION_MAJOR "" CACHE STRING "MAJOR version of python") +set(CACHE PY_VERSION_MAJOR_MINOR "" CACHE STRING "MAJOR.MINOR version of python") +set(CACHE PY_VERSION "" CACHE STRING "Required version of python") +set(CACHE PY_VERSION_SUFFIX "" CACHE STRING "Suffix of python") + +set(Python_ADDITIONAL_VERSIONS ${PY_VERSION}${PY_VERSION_SUFFIX} ${PY_VERSION_MAJOR_MINOR}${PY_VERSION_SUFFIX} ${PY_VERSION_MAJOR}${PY_VERSION_SUFFIX} ${PY_VERSION} ${PY_VERSION_MAJOR_MINOR} ${PY_VERSION_MAJOR}) +message("Using Python_ADDITIONAL_VERSIONS: ${Python_ADDITIONAL_VERSIONS}") + +find_package(PythonInterp REQUIRED) +find_package(PythonLibs REQUIRED) + +string(FIND "${PYTHON_EXECUTABLE}" "${CONAN_CPYTHON_ROOT}" ROOT_SUBPOS) +if(ROOT_SUBPOS EQUAL -1) + message(FATAL_ERROR "found wrong python interpreter: ${PYTHON_EXECUTABLE}") +endif() + +message(STATUS "FindPythonInterp:") +message(STATUS "PYTHON_VERSION_STRING: ${PYTHON_VERSION_STRING}") +message(STATUS "PYTHON_VERSION_MAJOR: ${PYTHON_VERSION_MAJOR}") +message(STATUS "PYTHON_VERSION_MINOR: ${PYTHON_VERSION_MINOR}") +message(STATUS "PYTHON_VERSION_PATCH: ${PYTHON_VERSION_PATCH}") +message(STATUS "=============================================") +message(STATUS "FindPythonLibs:") +message(STATUS "PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}") +message(STATUS "PYTHON_INCLUDE_PATH: ${PYTHON_INCLUDE_PATH} (deprecated)") +message(STATUS "PYTHON_INCLUDE_DIRS: ${PYTHON_INCLUDE_DIRS}") +message(STATUS "PYTHON_DEBUG_LIBRARIES: ${PYTHON_DEBUG_LIBRARIES} (deprecated)") +message(STATUS "PYTHONLIBS_VERSION_STRING: ${PYTHONLIBS_VERSION_STRING}") + +if(NOT PYTHON_VERSION_STRING AND NOT PYTHONLIBS_VERSION_STRING) + message(FATAL_ERROR "Version of python interpreter and libraries not found") +endif() + +if(PYTHON_VERSION_STRING) + if(NOT PYTHON_VERSION_STRING VERSION_EQUAL "${PY_VERSION}") + message("PYTHON_VERSION_STRING does not match PY_VERSION") + message(FATAL_ERROR "CMake detected wrong cpython version") + endif() +endif() + +if(PYTHONLIBS_VERSION_STRING) + if(NOT PYTHONLIBS_VERSION_STRING STREQUAL "${PY_FULL_VERSION}") + message("PYTHONLIBS_VERSION_STRING does not match PY_FULL_VERSION") + message(FATAL_ERROR "CMake detected wrong cpython version") + endif() +endif() + +option(BUILD_MODULE "Build python module") + +if(BUILD_MODULE) + add_library(spam MODULE "py${PY_VERSION_MAJOR}/test_module.c") + target_include_directories(spam + PRIVATE + ${PYTHON_INCLUDE_DIRS} + ) + target_link_libraries(spam PRIVATE + ${PYTHON_LIBRARIES} + ) + set_property(TARGET spam PROPERTY PREFIX "") + if(MSVC) + if(CONAN_SETTINGS_BUILD_TYPE STREQUAL "Debug") + set(SUFFIX "_d.pyd") + else() + set(SUFFIX ".pyd") + endif() + set_property(TARGET spam PROPERTY SUFFIX "${SUFFIX}") + endif() + + option(USE_FINDPYTHON_X "Use new-style FindPythonX module") + if(USE_FINDPYTHON_X AND NOT (CMAKE_VERSION VERSION_LESS "3.16")) + # Require CMake 3.16 because this version introduces Python${PY_VERSION_MAJOR}_FIND_ABI + find_package(Python${PY_VERSION_MAJOR} REQUIRED COMPONENTS Interpreter Development) + message("Python${PY_VERSION_MAJOR}_EXECUTABLE: ${Python${PY_VERSION_MAJOR}_EXECUTABLE}") + message("Python${PY_VERSION_MAJOR}_INTERPRETER_ID: ${Python${PY_VERSION_MAJOR}_INTERPRETER_ID}") + message("Python${PY_VERSION_MAJOR}_VERSION: ${Python${PY_VERSION_MAJOR}_VERSION}") + message("Python${PY_VERSION_MAJOR}_INCLUDE_DIRS: ${Python${PY_VERSION_MAJOR}_INCLUDE_DIRS}") + message("Python${PY_VERSION_MAJOR}_LIBRARIES: ${Python${PY_VERSION_MAJOR}_LIBRARIES}") + if(NOT Python${PY_VERSION_MAJOR}_VERSION STREQUAL "${PY_VERSION}") + message("Python_ADDITIONAL_VERSIONS does not match PY_VERSION") + message(FATAL_ERROR "CMake detected wrong cpython version") + endif() + + if(PY_VERSION_MAJOR STREQUAL "2") + python2_add_library(spam2 "py${PY_VERSION_MAJOR}/test_module.c") + elseif(PY_VERSION_MAJOR STREQUAL "3") + python3_add_library(spam2 "py${PY_VERSION_MAJOR}/test_module.c") + else() + message(FATAL_ERROR "Unknown PY_VERSION_MAJOR") + endif() + endif() +endif() + +add_executable(${PROJECT_NAME} "py${PY_VERSION_MAJOR}/test_package.c") +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/cpython/all/test_package/conanfile.py b/recipes/cpython/all/test_package/conanfile.py new file mode 100644 index 0000000000000..8abc18e4492c5 --- /dev/null +++ b/recipes/cpython/all/test_package/conanfile.py @@ -0,0 +1,192 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, CMake, tools, RunEnvironment +from conans.errors import ConanException +from io import StringIO +import os +import re +import shutil + + +class CmakePython3Abi(object): + def __init__(self, debug, pymalloc, unicode): + self.debug, self.pymalloc, self.unicode = debug, pymalloc, unicode + + _cmake_lut = { + None: "ANY", + True: "ON", + False: "OFF", + } + + @property + def suffix(self): + return "{}{}{}".format( + "d" if self.debug else "", + "m" if self.pymalloc else "", + "u" if self.unicode else "", + ) + + @property + def cmake_arg(self): + return ";".join(self._cmake_lut[a] for a in (self.debug, self.pymalloc, self.unicode)) + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + @property + def _py_version(self): + return re.match(r"^([0-9.]+)", self.deps_cpp_info["cpython"].version).group(1) + + @property + def _pymalloc(self): + return bool("pymalloc" in self.options["cpython"] and self.options["cpython"].pymalloc) + + @property + def _cmake_abi(self): + if self._py_version < tools.Version("3.8"): + return CmakePython3Abi( + debug=self.settings.build_type == "Debug", + pymalloc=self._pymalloc, + unicode=False, + ) + else: + return CmakePython3Abi( + debug=self.settings.build_type == "Debug", + pymalloc=False, + unicode=False, + ) + + @property + def _cmake_try_FindPythonX(self): + if self.settings.compiler == "Visual Studio" and self.settings.build_type == "Debug": + return False + return True + + @property + def _supports_modules(self): + return self.settings.compiler != "Visual Studio" or self.options["cpython"].shared + + def build(self): + if not tools.cross_building(self, skip_x64_x86=True): + command = "{} --version".format(self.deps_user_info["cpython"].python) + buffer = StringIO() + self.run(command, output=buffer, ignore_errors=True, run_environment=True) + self.output.info("output: %s" % buffer.getvalue()) + self.run(command, run_environment=True) + + cmake = CMake(self) + py_major = self.deps_cpp_info["cpython"].version.split(".")[0] + cmake.definitions["BUILD_MODULE"] = self._supports_modules + cmake.definitions["PY_VERSION_MAJOR"] = py_major + cmake.definitions["PY_VERSION_MAJOR_MINOR"] = ".".join(self._py_version.split(".")[:2]) + cmake.definitions["PY_FULL_VERSION"] = self.deps_cpp_info["cpython"].version + cmake.definitions["PY_VERSION"] = self._py_version + cmake.definitions["PY_VERSION_SUFFIX"] = self._cmake_abi.suffix + cmake.definitions["PYTHON_EXECUTABLE"] = self.deps_user_info["cpython"].python + cmake.definitions["USE_FINDPYTHON_X".format(py_major)] = self._cmake_try_FindPythonX + cmake.definitions["Python{}_EXECUTABLE".format(py_major)] = self.deps_user_info["cpython"].python + cmake.definitions["Python{}_ROOT_DIR".format(py_major)] = self.deps_cpp_info["cpython"].rootpath + cmake.definitions["Python{}_USE_STATIC_LIBS".format(py_major)] = not self.options["cpython"].shared + cmake.definitions["Python{}_FIND_FRAMEWORK".format(py_major)] = "NEVER" + cmake.definitions["Python{}_FIND_REGISTRY".format(py_major)] = "NEVER" + cmake.definitions["Python{}_FIND_IMPLEMENTATIONS".format(py_major)] = "CPython" + cmake.definitions["Python{}_FIND_STRATEGY".format(py_major)] = "LOCATION" + + if self.settings.compiler != "Visual Studio": + if tools.Version(self._py_version) < tools.Version("3.8"): + cmake.definitions["Python{}_FIND_ABI".format(py_major)] = self._cmake_abi.cmake_arg + + with tools.environment_append(RunEnvironment(self).vars): + cmake.configure() + cmake.build() + + if not tools.cross_building(self, skip_x64_x86=True): + if self._supports_modules: + with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op(): + modsrcfolder = "py2" if tools.Version(self.deps_cpp_info["cpython"].version).major < "3" else "py3" + tools.mkdir(os.path.join(self.build_folder, modsrcfolder)) + for fn in os.listdir(os.path.join(self.source_folder, modsrcfolder)): + shutil.copy(os.path.join(self.source_folder, modsrcfolder, fn), os.path.join(self.build_folder, modsrcfolder, fn)) + shutil.copy(os.path.join(self.source_folder, "setup.py"), os.path.join(self.build_folder, "setup.py")) + env = { + "DISTUTILS_USE_SDK": "1", + "MSSdk": "1" + } + env.update(**AutoToolsBuildEnvironment(self).vars) + with tools.environment_append(env): + setup_args = [ + "{}/setup.py".format(self.source_folder), + # "conan", + # "--install-folder", self.build_folder, + "build", + "--build-base", self.build_folder, + "--build-platlib", os.path.join(self.build_folder, "lib_setuptools"), + ] + if self.settings.build_type == "Debug": + setup_args.append("--debug") + self.run("{} {}".format(self.deps_user_info["cpython"].python, " ".join("\"{}\"".format(a) for a in setup_args)), run_environment=True) + + def _test_module(self, module, should_work): + try: + self.run("{} {}/test_package.py -b {} -t {} ".format( + self.deps_user_info["cpython"].python, self.source_folder, self.build_folder, module), run_environment=True) + works = True + except ConanException as e: + works = False + exception = e + if should_work == works: + self.output.info("Result of test was expected.") + else: + if works: + raise ConanException("Module '{}' works, but should not have worked".format(module)) + else: + self.output.warn("Module '{}' does not work, but should have worked".format(module)) + raise exception + + def _cpython_option(self, name): + try: + return getattr(self.options["cpython"], name, False) + except ConanException: + return False + + def test(self): + if not tools.cross_building(self, skip_x64_x86=True): + self.run("{} -c \"print('hello world')\"".format(self.deps_user_info["cpython"].python), run_environment=True) + + buffer = StringIO() + self.run("{} -c \"import sys; print('.'.join(str(s) for s in sys.version_info[:3]))\"".format(self.deps_user_info["cpython"].python), run_environment=True, output=buffer) + self.output.info(buffer.getvalue()) + version_detected = buffer.getvalue().splitlines()[-1].strip() + if self._py_version != version_detected: + raise ConanException("python reported wrong version. Expected {exp}. Got {res}.".format(exp=self._py_version, res=version_detected)) + + if self._supports_modules: + self._test_module("gdbm", self._cpython_option("with_gdbm")) + self._test_module("bz2", self._cpython_option("with_bz2")) + self._test_module("bsddb", self._cpython_option("with_bsddb")) + self._test_module("lzma", self._cpython_option("with_lzma")) + self._test_module("tkinter", self._cpython_option("with_tkinter")) + with tools.environment_append({"TERM": "ansi"}): + self._test_module("curses", self._cpython_option("with_curses")) + + self._test_module("expat", True) + self._test_module("sqlite3", True) + self._test_module("decimal", True) + self._test_module("ctypes", True) + + if tools.is_apple_os(self.settings.os) and not self.options["cpython"].shared: + self.output.info("Not testing the module, because these seem not to work on apple when cpython is built as a static library") + # FIXME: find out why cpython on apple does not allow to use modules linked against a static python + else: + if self._supports_modules: + with tools.environment_append({"PYTHONPATH": [os.path.join(self.build_folder, "lib")]}): + self.output.info("Testing module (spam) using cmake built module") + self._test_module("spam", True) + + with tools.environment_append({"PYTHONPATH": [os.path.join(self.build_folder, "lib_setuptools")]}): + self.output.info("Testing module (spam) using setup.py built module") + self._test_module("spam", True) + + # MSVC builds need PYTHONHOME set. + with tools.environment_append({"PYTHONHOME": self.deps_user_info["cpython"].pythonhome}) if self.deps_user_info["cpython"].module_requires_pythonhome == "True" else tools.no_op(): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/cpython/all/test_package/py2/test_module.c b/recipes/cpython/all/test_package/py2/test_module.c new file mode 100644 index 0000000000000..9c5af39ab391b --- /dev/null +++ b/recipes/cpython/all/test_package/py2/test_module.c @@ -0,0 +1,42 @@ +#include + +#include + +static PyObject *SpamError; + +static PyObject * +spam_system(PyObject *self, PyObject *args) +{ + const char *command; + int sts; + + if (!PyArg_ParseTuple(args, "s", &command)) + return NULL; + sts = system(command); + if (sts < 0) { + PyErr_SetString(SpamError, "System command failed"); + return NULL; + } + return PyLong_FromLong(sts); +} + +const char spam_doc[] = "This is an example spam doc."; + +static PyMethodDef SpamMethods[] = { + {"system", spam_system, METH_VARARGS, "Execute a shell command."}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +PyMODINIT_FUNC +initspam(void) +{ + PyObject *m; + + m = Py_InitModule("spam", SpamMethods); + if (m == NULL) + return; + PyModule_AddStringConstant(m, "__doc__", spam_doc); + SpamError = PyErr_NewException("spam.error", NULL, NULL); + Py_INCREF(SpamError); + PyModule_AddObject(m, "error", SpamError); +} diff --git a/recipes/cpython/all/test_package/py2/test_package.c b/recipes/cpython/all/test_package/py2/test_package.c new file mode 100644 index 0000000000000..5e5d839b5a6a1 --- /dev/null +++ b/recipes/cpython/all/test_package/py2/test_package.c @@ -0,0 +1,12 @@ +#include + +int +main(int argc, char *argv[]) +{ + Py_SetProgramName(argv[0]); /* optional but recommended */ + Py_Initialize(); + PyRun_SimpleString("from time import time,ctime\n" + "print 'Today is',ctime(time())\n"); + Py_Finalize(); + return 0; +} diff --git a/recipes/cpython/all/test_package/py3/test_module.c b/recipes/cpython/all/test_package/py3/test_module.c new file mode 100644 index 0000000000000..7372ac3b1a944 --- /dev/null +++ b/recipes/cpython/all/test_package/py3/test_module.c @@ -0,0 +1,52 @@ +#include + +#include + +static PyObject *SpamError; + +static PyObject * +spam_system(PyObject *self, PyObject *args) +{ + const char *command; + int sts; + + if (!PyArg_ParseTuple(args, "s", &command)) + return NULL; + sts = system(command); + if (sts < 0) { + PyErr_SetString(SpamError, "System command failed"); + return NULL; + } + return PyLong_FromLong(sts); +} + +const char spam_doc[] = "This is an example spam doc."; + +static PyMethodDef SpamMethods[] = { + {"system", spam_system, METH_VARARGS, "Execute a shell command."}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +static struct PyModuleDef spammodule = { + PyModuleDef_HEAD_INIT, + "spam", /* name of module */ + spam_doc, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + SpamMethods +}; + +PyMODINIT_FUNC +PyInit_spam(void) +{ + PyObject *m; + + m = PyModule_Create(&spammodule); + if (m == NULL) + return NULL; + + SpamError = PyErr_NewException("spam.error", NULL, NULL); + Py_INCREF(SpamError); + PyModule_AddObject(m, "error", SpamError); + return m; +} diff --git a/recipes/cpython/all/test_package/py3/test_package.c b/recipes/cpython/all/test_package/py3/test_package.c new file mode 100644 index 0000000000000..f5dfe41cd757c --- /dev/null +++ b/recipes/cpython/all/test_package/py3/test_package.c @@ -0,0 +1,21 @@ +#define PY_SSIZE_T_CLEAN +#include + +int +main(int argc, char *argv[]) +{ + wchar_t *program = Py_DecodeLocale(argv[0], NULL); + if (program == NULL) { + fprintf(stderr, "Fatal error: cannot decode argv[0]\n"); + exit(1); + } + Py_SetProgramName(program); /* optional but recommended */ + Py_Initialize(); + PyRun_SimpleString("from time import time, ctime\n" + "print('Today is', ctime(time()))\n"); + if (Py_FinalizeEx() < 0) { + exit(120); + } + PyMem_RawFree(program); + return 0; +} diff --git a/recipes/cpython/all/test_package/setup.py b/recipes/cpython/all/test_package/setup.py new file mode 100644 index 0000000000000..cd1754cef8131 --- /dev/null +++ b/recipes/cpython/all/test_package/setup.py @@ -0,0 +1,31 @@ +import os +import sys + +# Hack to work around Python 3.8+ secure dll loading: +# see https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew +if hasattr(os, "add_dll_directory"): + for directory in os.environ.get("PATH", "").split(os.pathsep): + if os.path.isdir(directory): + os.add_dll_directory(directory) + +PY2 = (2, 0) <= sys.version_info < (3, 0) +PY3 = (3, 0) <= sys.version_info < (4, 0) + +if PY2: + subdir = "py2" + from distutils.core import setup, Extension +elif PY3: + subdir = "py3" + from setuptools import setup, Extension +else: + raise Exception + + +setup( + name="test_package", + version="1.0", + use_2to3=True, + ext_modules=[ + Extension("spam", [os.path.join(subdir, "test_module.c")]), + ], +) diff --git a/recipes/cpython/all/test_package/test_package.py b/recipes/cpython/all/test_package/test_package.py new file mode 100644 index 0000000000000..f77d2837c6376 --- /dev/null +++ b/recipes/cpython/all/test_package/test_package.py @@ -0,0 +1,213 @@ +import argparse +import os +import sys + +# Hack to work around Python 3.8+ secure dll loading +# See https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew +if hasattr(os, "add_dll_directory"): + for directory in os.environ.get("PATH", "").split(os.pathsep): + if os.path.isdir(directory): + os.add_dll_directory(directory) + +ALL_TESTS = dict() + + +def add_test(fn): + global ALL_TESTS + name = fn.__name__[fn.__name__.find("_")+1:] + + def inner_fn(): + print("testing {}".format(name)) + sys.stdout.flush() + fn() + ALL_TESTS[name] = inner_fn + return fn + + +@add_test +def test_expat(): + import xml.parsers.expat + + # 3 handler functions + def start_element(name, attrs): + print('Start element:', name, attrs) + + def end_element(name): + print('End element:', name) + + def char_data(data): + print('Character data:', repr(data)) + + p = xml.parsers.expat.ParserCreate() + + p.StartElementHandler = start_element + p.EndElementHandler = end_element + p.CharacterDataHandler = char_data + + p.Parse(""" + Text goes here + More text + """, 1) + + +@add_test +def test_gdbm(): + if sys.version_info < (3, 0): + import gdbm + else: + import dbm.gnu as gdbm + + dbfile = "gdbm.db" + + db = gdbm.open(dbfile, "c") + db["key1"] = "data1" + db["key2"] = "data2" + db.close() + + db = gdbm.open(dbfile, "r") + print("keys read from", dbfile, "are", db.keys()) + if len(db.keys()) != 2: + raise Exception("Wrong length") + if b"key1" not in db.keys(): + raise Exception("key1 not present") + if b"key2" not in db.keys(): + raise Exception("key2 not present") + + +@add_test +def test_spam(): + import platform + + print("About to import spam") + sys.stdout.flush() + import spam + + if "This is an example spam doc." not in spam.__doc__: + raise Exception("spam.__doc__ does not contain the expected text") + + cmd = { + "Windows": "dir", + }.get(platform.system(), "ls") + print("About to run spam.system(\"{}\")".format(cmd)) + sys.stdout.flush() + + spam.system(cmd) + + +@add_test +def test_bz2(): + import bz2 + + compressed = bz2.compress(b"hellow world") + if compressed is None: + raise Exception("bz2.compress returned no data") + + +@add_test +def test_bsddb(): + import bsddb + + db = bsddb.btopen("bsddb.db", "c") + db["key1"] = "value1" + db["key2"] = "value2" + db.close() + + db = bsddb.btopen("bsddb.db", "r") + if len(db) != 2: + raise Exception("Wrong length") + if db["key1"] != "value1": + raise Exception("value1 incorrect {}".format(db["key1"])) + if db["key2"] != "value2": + raise Exception("value2 incorrect {}".format(db["key2"])) + + +@add_test +def test_lzma(): + import lzma + + data = lzma.compress(b"hello world") + if data is None: + raise Exception("lzma.compress returned no data") + + +@add_test +def test_sqlite3(): + import sqlite3 + conn = sqlite3.connect("sqlite3.db") + + c = conn.cursor() + c.execute("""CREATE TABLE stocks + (date text, trans text, symbol text, qty real, price real)""") + c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)") + conn.commit() + + t = ('RHAT',) + c.execute('SELECT * FROM stocks WHERE symbol=?', t) + + # Larger example that inserts many records at a time + purchases = [ + ('2006-03-28', 'BUY', 'IBM', 1000, 45.00), + ('2006-04-05', 'BUY', 'MSFT', 1000, 72.00), + ('2006-04-06', 'SELL', 'IBM', 500, 53.00), + ] + c.executemany('INSERT INTO stocks VALUES (?,?,?,?,?)', purchases) + conn.commit() + conn.close() + conn = sqlite3.connect("sqlite3.db") + c = conn.cursor() + c.execute("SELECT * from stocks") + data = c.fetchall() + if len(data) != 4: + raise Exception("Need 4 stocks") + print(data) + conn.close() + + +@add_test +def test_decimal(): + if sys.version_info >= (3, ): + # Check whether the _decimal package was built successfully + import _decimal as decimal + else: + import decimal + decimal.getcontext().prec = 6 + print("1/7 =", decimal.Decimal(1) / decimal.Decimal(7)) + decimal.getcontext().prec = 40 + print("1/7 =", decimal.Decimal(1) / decimal.Decimal(7)) + + +@add_test +def test_curses(): + import _curses + + print("Using _curses version {}".format(_curses.version)) + + +@add_test +def test_ctypes(): + import _ctypes + + errno = _ctypes.get_errno() + print("errno={}".format(errno)) + + +@add_test +def test_tkinter(): + import _tkinter + + print("tcl version: {}".format(_tkinter.TCL_VERSION)) + print("tk version: {}".format(_tkinter.TK_VERSION)) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-b", dest="build_folder", help="build_folder", required=True) + parser.add_argument("-t", dest="test_module", help="test python module") + ns = parser.parse_args() + + os.chdir(ns.build_folder) + ALL_TESTS[ns.test_module]() + + +if __name__ == "__main__": + main() diff --git a/recipes/cpython/config.yml b/recipes/cpython/config.yml new file mode 100644 index 0000000000000..e3abf3ec8acb2 --- /dev/null +++ b/recipes/cpython/config.yml @@ -0,0 +1,11 @@ +versions: + "3.10.0": + folder: "all" + "3.9.7": + folder: "all" + "3.8.12": + folder: "all" + "3.7.12": + folder: "all" + "2.7.18": + folder: "all" diff --git a/recipes/cqrlib/all/CMakeLists.txt b/recipes/cqrlib/all/CMakeLists.txt new file mode 100644 index 0000000000000..1c86519b249a8 --- /dev/null +++ b/recipes/cqrlib/all/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.4) +project(CQRlib LANGUAGES C) + +add_library(CQRlib ${CQRLIB_SRC_DIR}/cqrlib.c) +target_include_directories(CQRlib PRIVATE ${CQRLIB_SRC_DIR}) +set_target_properties(CQRlib PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + +find_library(M_LIB m) +if(M_LIB) + target_link_libraries(CQRlib PRIVATE ${M_LIB}) +endif() + +include(GNUInstallDirs) +install(TARGETS CQRlib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install(FILES ${CQRLIB_SRC_DIR}/cqrlib.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/cqrlib/all/conandata.yml b/recipes/cqrlib/all/conandata.yml new file mode 100644 index 0000000000000..9ec75e284f70b --- /dev/null +++ b/recipes/cqrlib/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.1.4": + url: "https://github.com/yayahjb/cqrlib/archive/refs/tags/CQRlib-1.1.4.tar.gz" + sha256: "98d70b5a347638754ef3a3874d4ec1ecdd9d1d12c123c44b367ff18419f92c6d" diff --git a/recipes/cqrlib/all/conanfile.py b/recipes/cqrlib/all/conanfile.py new file mode 100644 index 0000000000000..ae3ab6223dcac --- /dev/null +++ b/recipes/cqrlib/all/conanfile.py @@ -0,0 +1,71 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.46.0" + + +class CqrlibConan(ConanFile): + name = "cqrlib" + description = "CQRlib is an ANSI C implementation of a utility library " \ + "for quaternion arithmetic and quaternion rotation math." + license = "LGPL-2.1-only" + topics = ("cqrlib", "quaternion") + homepage = "https://github.com/yayahjb/cqrlib" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CQRLIB_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "lgpl.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["CQRlib"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/cqrlib/all/test_package/CMakeLists.txt b/recipes/cqrlib/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5e9a386c11d30 --- /dev/null +++ b/recipes/cqrlib/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +find_package(cqrlib REQUIRED CONFIG) + +add_executable(${PROJECT_NAME}_c test_package.c) +target_link_libraries(${PROJECT_NAME}_c PRIVATE cqrlib::cqrlib) + +add_executable(${PROJECT_NAME}_cpp test_package.cpp) +target_link_libraries(${PROJECT_NAME}_cpp PRIVATE cqrlib::cqrlib) diff --git a/recipes/cqrlib/all/test_package/conanfile.py b/recipes/cqrlib/all/test_package/conanfile.py new file mode 100644 index 0000000000000..94db9a10dc181 --- /dev/null +++ b/recipes/cqrlib/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path_c = os.path.join(self.cpp.build.bindirs[0], "test_package_c") + self.run(bin_path_c, env="conanrun") + bin_path_cpp = os.path.join(self.cpp.build.bindirs[0], "test_package_cpp") + self.run(bin_path_cpp, env="conanrun") diff --git a/recipes/cqrlib/all/test_package/test_package.c b/recipes/cqrlib/all/test_package/test_package.c new file mode 100644 index 0000000000000..ec994ea428cfa --- /dev/null +++ b/recipes/cqrlib/all/test_package/test_package.c @@ -0,0 +1,7 @@ +#include + +int main(void) { + CQRQuaternionHandle q; + CQRCreateEmptyQuaternion(&q); + return 0; +} diff --git a/recipes/cqrlib/all/test_package/test_package.cpp b/recipes/cqrlib/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..20ad8de2bc5cf --- /dev/null +++ b/recipes/cqrlib/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + CPPQR q; + return 0; +} diff --git a/recipes/cqrlib/all/test_v1_package/CMakeLists.txt b/recipes/cqrlib/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b455e3e89e446 --- /dev/null +++ b/recipes/cqrlib/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cqrlib REQUIRED CONFIG) + +add_executable(${PROJECT_NAME}_c ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME}_c PRIVATE cqrlib::cqrlib) + +add_executable(${PROJECT_NAME}_cpp ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME}_cpp PRIVATE cqrlib::cqrlib) diff --git a/recipes/cqrlib/all/test_v1_package/conanfile.py b/recipes/cqrlib/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..302285c48aded --- /dev/null +++ b/recipes/cqrlib/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path_c = os.path.join("bin", "test_package_c") + self.run(bin_path_c, run_environment=True) + bin_path_cpp = os.path.join("bin", "test_package_cpp") + self.run(bin_path_cpp, run_environment=True) diff --git a/recipes/cqrlib/config.yml b/recipes/cqrlib/config.yml new file mode 100644 index 0000000000000..f7bc2bb892fbd --- /dev/null +++ b/recipes/cqrlib/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.4": + folder: all diff --git a/recipes/crashpad/all/conandata.yml b/recipes/crashpad/all/conandata.yml index 4a7b208c5f5d9..78196c9e613a3 100644 --- a/recipes/crashpad/all/conandata.yml +++ b/recipes/crashpad/all/conandata.yml @@ -1,12 +1,18 @@ sources: "cci.20210507": - url: - crashpad: - url: "https://github.com/chromium/crashpad/archive/d9bc7cf06aef74e928f9afc3dee33b60121b9c73.zip" - sha256: "34c2d4bf7be49c2db1d2f50e3410b506aab15a06d245f8c02ea0046e9295eaa6" - mini_chromium: - url: "https://github.com/chromium/mini_chromium/archive/ccb198907cecf072d8f5b2543d4d348e834a298a.zip" - sha256: "d526f659b0d44932bb4b5ff1277d855569572eb3fcad6ec1c69a71aac6a3d6ee" + crashpad: + url: "https://github.com/chromium/crashpad/archive/d9bc7cf06aef74e928f9afc3dee33b60121b9c73.tar.gz" + sha256: "49f4b10f1de9b6d33743eccecace6b0fc9d7fe92e5e550ba5e099e6db9a11f0f" + mini_chromium: + url: "https://github.com/chromium/mini_chromium/archive/ccb198907cecf072d8f5b2543d4d348e834a298a.tar.gz" + sha256: "f40a77a4580cd1cb9af71602917a0e85b62bf0f74641b6ed81dd9fb2f2012ea9" + "cci.20220219": + crashpad: + url: "https://github.com/chromium/crashpad/archive/e9937cb36cd12f24d73a07c4b91168cf1885b5db.tar.gz" + sha256: "3876ada53bfb35ca58ac4c27fba79ec56d9436046ab28477fb06c9e8d1a97c7e" + mini_chromium: + url: "https://github.com/chromium/mini_chromium/archive/822fada4a9972e3e2f36a981da770539025beb0a.tar.gz" + sha256: "2c3bf30d324fcb60eeef84dd6aaf7fb75b70e37bdb3716ab3ea10cda51c4b05c" patches: "cci.20210507": - patch_file: "patches/cci.20210507-0001-fix-openssl-link-order.patch" @@ -23,3 +29,21 @@ patches: base_path: "source_subfolder" - patch_file: "patches/cci.20210507-0007-use-system-zlib.patch" base_path: "source_subfolder" + "cci.20220219": + - patch_file: "patches/cci.20220219-0001-fix-openssl-link-order.patch" + base_path: "source_subfolder" + - patch_file: "patches/cci.20220219-0002-remove-fPIC-Werror-LTO.patch" + base_path: "source_subfolder" + - patch_file: "patches/cci.20220219-0003-compilers-from-env.patch" + base_path: "source_subfolder" + - patch_file: "patches/cci.20220219-0004-use-conan-linux-syscall-support-package.patch" + base_path: "source_subfolder" + - patch_file: "patches/cci.20220219-0005-allow-all-archs.patch" + base_path: "source_subfolder" + - patch_file: "patches/cci.20220219-0006-mini_chromium-win_helper-py3.patch" + base_path: "source_subfolder" + # reused patch from cci.20210507 + - patch_file: "patches/cci.20210507-0007-use-system-zlib.patch" + base_path: "source_subfolder" + - patch_file: "patches/cci.20220219-0007-static-lib-tool_support.patch" + base_path: "source_subfolder" diff --git a/recipes/crashpad/all/conanfile.py b/recipes/crashpad/all/conanfile.py index bef72c1f45474..42d603abefb4c 100644 --- a/recipes/crashpad/all/conanfile.py +++ b/recipes/crashpad/all/conanfile.py @@ -54,15 +54,15 @@ def build_requirements(self): def requirements(self): # FIXME: use mini_chromium conan package instead of embedded package (if possible) - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.12") if self.settings.os in ("Linux", "FreeBSD"): self.requires("linux-syscall-support/cci.20200813") if self.options.http_transport != "socket": del self.options.with_tls if self.options.http_transport == "libcurl": - self.requires("libcurl/7.75.0") + self.requires("libcurl/7.82.0") if self.options.get_safe("with_tls") == "openssl": - self.requires("openssl/1.1.1k") + self.requires("openssl/1.1.1o") def validate(self): if self.settings.compiler == "Visual Studio": @@ -82,8 +82,8 @@ def validate(self): tools.check_min_cppstd(self, 14) def source(self): - tools.get(**self.conan_data["sources"][self.version]["url"]["crashpad"], destination=self._source_subfolder, strip_root=True) - tools.get(**self.conan_data["sources"][self.version]["url"]["mini_chromium"], + tools.get(**self.conan_data["sources"][self.version]["crashpad"], destination=self._source_subfolder, strip_root=True) + tools.get(**self.conan_data["sources"][self.version]["mini_chromium"], destination=os.path.join(self._source_subfolder, "third_party", "mini_chromium", "mini_chromium"), strip_root=True) @property @@ -101,7 +101,7 @@ def _gn_os(self): def _gn_arch(self): return { "x86_64": "x64", - "armv8": "aarch64", + "armv8": "arm64", "x86": "x86", }.get(str(self.settings.arch), str(self.settings.arch)) @@ -138,6 +138,15 @@ def _http_transport_impl(self): else: return str(self.options.http_transport) + def _version_greater_equal_to_cci_20220219(self): + return self.version >= "cci.20220219" + + def _has_separate_util_net_lib(self): + return self._version_greater_equal_to_cci_20220219() + + def _needs_to_link_tool_support(self): + return self._version_greater_equal_to_cci_20220219() + def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) @@ -191,6 +200,14 @@ def build(self): targets=" ".join(targets), parallel=tools.cpu_count()), run_environment=True) + def lib_filename(name): + prefix, suffix = ("", ".lib") if self.settings.compiler == "Visual Studio" else ("lib", ".a") + return "{}{}{}".format(prefix, name, suffix) + tools.rename(os.path.join(self._source_subfolder, "out", "Default", "obj", "client", lib_filename("common")), + os.path.join(self._source_subfolder, "out", "Default", "obj", "client", lib_filename("client_common"))) + tools.rename(os.path.join(self._source_subfolder, "out", "Default", "obj", "handler", lib_filename("common")), + os.path.join(self._source_subfolder, "out", "Default", "obj", "handler", lib_filename("handler_common"))) + def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") @@ -201,10 +218,14 @@ def package(self): self.copy("*.h", src=os.path.join(self._source_subfolder, "out", "Default", "gen", "build"), dst=os.path.join("include", "build")) self.copy("*.a", src=os.path.join(self._source_subfolder, "out", "Default"), dst="lib", keep_path=False) + self.copy("*.lib", src=os.path.join(self._source_subfolder, "out", "Default"), dst="lib", keep_path=False) self.copy("crashpad_handler", src=os.path.join(self._source_subfolder, "out", "Default"), dst="bin", keep_path=False) self.copy("crashpad_handler.exe", src=os.path.join(self._source_subfolder, "out", "Default"), dst="bin", keep_path=False) self.copy("crashpad_handler_com.com", src=os.path.join(self._source_subfolder, "out", "Default"), dst="bin", keep_path=False) + if self.settings.os == "Windows": + tools.rename(os.path.join(self.package_folder, "bin", "crashpad_handler_com.com"), + os.path.join(self.package_folder, "bin", "crashpad_handler.com")) # Remove accidentally copied libraries. These are used by the executables, not by the libraries. tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*getopt*") @@ -243,11 +264,11 @@ def package_info(self): self.cpp_info.components["util"].frameworks.extend(["CoreFoundation", "Foundation", "IOKit"]) self.cpp_info.components["util"].system_libs.append("bsm") - self.cpp_info.components["common"].libs = ["common"] - self.cpp_info.components["common"].requires = ["util"] + self.cpp_info.components["client_common"].libs = ["client_common"] + self.cpp_info.components["client_common"].requires = ["util", "mini_chromium_base"] self.cpp_info.components["client"].libs = ["client"] - self.cpp_info.components["client"].requires = ["common"] + self.cpp_info.components["client"].requires = ["util", "mini_chromium_base", "client_common"] if self.settings.os == "Windows": self.cpp_info.components["client"].system_libs.append("rpcrt4") @@ -255,7 +276,7 @@ def package_info(self): self.cpp_info.components["context"].requires = ["util"] self.cpp_info.components["snapshot"].libs = ["snapshot"] - self.cpp_info.components["snapshot"].requires = ["common", "mini_chromium_base", "util"] + self.cpp_info.components["snapshot"].requires = ["context", "client_common", "mini_chromium_base", "util"] if tools.is_apple_os(self.settings.os): self.cpp_info.components["snapshot"].frameworks.extend(["OpenCL"]) @@ -265,8 +286,21 @@ def package_info(self): self.cpp_info.components["minidump"].libs = ["minidump"] self.cpp_info.components["minidump"].requires = ["snapshot", "mini_chromium_base", "util"] + extra_handler_common_req = [] + if self._has_separate_util_net_lib(): + self.cpp_info.components["net"].libs = ["net"] + extra_handler_common_req = ["net"] + + extra_handler_req = [] + if self._needs_to_link_tool_support(): + self.cpp_info.components["tool_support"].libs = ["tool_support"] + extra_handler_req = ["tool_support"] + + self.cpp_info.components["handler_common"].libs = ["handler_common"] + self.cpp_info.components["handler_common"].requires = ["client_common", "snapshot", "util"] + extra_handler_common_req + self.cpp_info.components["handler"].libs = ["handler"] - self.cpp_info.components["handler"].requires = ["common", "minidump", "snapshot"] + self.cpp_info.components["handler"].requires = ["client", "util", "handler_common", "minidump", "snapshot"] + extra_handler_req bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) diff --git a/recipes/crashpad/all/patches/cci.20210507-0005-allow-all-archs.patch b/recipes/crashpad/all/patches/cci.20210507-0005-allow-all-archs.patch index a26dcaaf0d927..ae7425fb742f1 100644 --- a/recipes/crashpad/all/patches/cci.20210507-0005-allow-all-archs.patch +++ b/recipes/crashpad/all/patches/cci.20210507-0005-allow-all-archs.patch @@ -27,3 +27,14 @@ } # fdio is listed in ldflags instead of libs because it’s important for it to +--- util/BUILD.gn ++++ util/BUILD.gn +@@ -145,7 +145,7 @@ if (crashpad_is_mac || crashpad_is_ios) { + "arm64", + ] + } else { +- assert(false, "Unsupported architecture") ++ print("Unknown architecture -> assume conan knows how to handle it") + } + } + diff --git a/recipes/crashpad/all/patches/cci.20220219-0001-fix-openssl-link-order.patch b/recipes/crashpad/all/patches/cci.20220219-0001-fix-openssl-link-order.patch new file mode 100644 index 0000000000000..06ec740db0f7c --- /dev/null +++ b/recipes/crashpad/all/patches/cci.20220219-0001-fix-openssl-link-order.patch @@ -0,0 +1,22 @@ +--- util/BUILD.gn ++++ util/BUILD.gn +@@ -662,8 +662,8 @@ crashpad_static_library("net") { + deps += [ "//third_party/boringssl" ] + } else { + libs = [ +- "crypto", + "ssl", ++ "crypto", + ] + } + } +@@ -708,8 +708,8 @@ if (!crashpad_is_android && !crashpad_is_ios) { + deps += [ "//third_party/boringssl" ] + } else { + libs = [ +- "crypto", + "ssl", ++ "crypto", + ] + } + } diff --git a/recipes/crashpad/all/patches/cci.20220219-0002-remove-fPIC-Werror-LTO.patch b/recipes/crashpad/all/patches/cci.20220219-0002-remove-fPIC-Werror-LTO.patch new file mode 100644 index 0000000000000..574534a76af5c --- /dev/null +++ b/recipes/crashpad/all/patches/cci.20220219-0002-remove-fPIC-Werror-LTO.patch @@ -0,0 +1,50 @@ +--- third_party/mini_chromium/mini_chromium/build/config/BUILD.gn ++++ third_party/mini_chromium/mini_chromium/build/config/BUILD.gn +@@ -108,7 +108,7 @@ config("release") { + } + } else if (mini_chromium_is_win) { + cflags = [ +- "/GL", # LTCG. ++ # LTCG. + "/O2", + "/Ob2", # Both explicit and auto inlining. + "/Oy-", # Disable omitting frame pointers, must be after /O2. +@@ -118,9 +118,9 @@ config("release") { + ldflags = [ + "/OPT:ICF", + "/OPT:REF", +- "/LTCG", ++ + ] +- arflags = [ "/LTCG" ] ++ arflags = [ ] + } + } + +@@ -133,7 +133,7 @@ config("default") { + cflags = [ + "-Wall", + "-Wendif-labels", +- "-Werror", ++ + "-Wextra", + "-Wextra-semi", + "-Wheader-hygiene", +@@ -244,7 +244,7 @@ config("default") { + "/D_UNICODE", + "/FS", + "/W4", +- "/WX", ++ + "/Zi", + "/bigobj", # Support larger number of sections in obj file. + "/wd4100", # Unreferenced formal parameter. +@@ -329,7 +329,7 @@ config("default") { + + if ((mini_chromium_is_posix && !mini_chromium_is_mac && + !mini_chromium_is_ios) || mini_chromium_is_fuchsia) { +- cflags += [ "-fPIC" ] ++ + ldflags += [ + # This must follow Fuchsia’s fdio library above. + "-Wl,--as-needed", diff --git a/recipes/crashpad/all/patches/cci.20220219-0003-compilers-from-env.patch b/recipes/crashpad/all/patches/cci.20220219-0003-compilers-from-env.patch new file mode 100644 index 0000000000000..64627104d299c --- /dev/null +++ b/recipes/crashpad/all/patches/cci.20220219-0003-compilers-from-env.patch @@ -0,0 +1,13 @@ +--- third_party/mini_chromium/mini_chromium/build/config/BUILD.gn ++++ third_party/mini_chromium/mini_chromium/build/config/BUILD.gn +@@ -437,8 +437,8 @@ toolchain("gcc_like_toolchain") { + ld = cxx + ar = ndk_bin_dir + tool_prefix + "-ar" + } else { +- cc = "clang" +- cxx = "clang++" ++ cc = getenv("CC") ++ cxx = getenv("CXX") + asm = cxx + ld = cxx + diff --git a/recipes/crashpad/all/patches/cci.20220219-0004-use-conan-linux-syscall-support-package.patch b/recipes/crashpad/all/patches/cci.20220219-0004-use-conan-linux-syscall-support-package.patch new file mode 100644 index 0000000000000..00b30221ee0a7 --- /dev/null +++ b/recipes/crashpad/all/patches/cci.20220219-0004-use-conan-linux-syscall-support-package.patch @@ -0,0 +1,14 @@ +--- third_party/lss/lss.h ++++ third_party/lss/lss.h +@@ -16,9 +16,9 @@ + #define CRASHPAD_THIRD_PARTY_LSS_LSS_H_ + + #if defined(CRASHPAD_LSS_SOURCE_EXTERNAL) +-#include "third_party/lss/linux_syscall_support.h" ++#include + #elif defined(CRASHPAD_LSS_SOURCE_EMBEDDED) +-#include "third_party/lss/lss/linux_syscall_support.h" ++#include + #elif defined(CRASHPAD_LSS_SOURCE_FUCHSIA) + #include "../../../../third_party/linux-syscall-support/linux_syscall_support.h" + #else diff --git a/recipes/crashpad/all/patches/cci.20220219-0005-allow-all-archs.patch b/recipes/crashpad/all/patches/cci.20220219-0005-allow-all-archs.patch new file mode 100644 index 0000000000000..436e4b67ae520 --- /dev/null +++ b/recipes/crashpad/all/patches/cci.20220219-0005-allow-all-archs.patch @@ -0,0 +1,40 @@ +--- third_party/mini_chromium/mini_chromium/build/config/BUILD.gn ++++ third_party/mini_chromium/mini_chromium/build/config/BUILD.gn +@@ -198,7 +198,7 @@ config("default") { + "arm64", + ] + } else { +- assert(false, "Unsupported architecture") ++ print("Unknown architecture -> assume conan knows how to handle it") + } + } + +@@ -278,7 +278,7 @@ config("default") { + "-m64", + ] + } else { +- assert(false, "Unsupported architecture") ++ print("Unknown architecture -> assume conan knows how to handle it") + } + + # This is currently required by the clang toolchain build that DEPS uses +@@ -312,7 +312,7 @@ config("default") { + } else if (target_cpu == "x64") { + common_flags += [ "--target=x86_64-fuchsia" ] + } else { +- assert(false, "Unsupported architecture") ++ print("Unknown architecture -> assume conan knows how to handle it") + } + + # fdio is listed in ldflags instead of libs because it’s important for it to +--- util/BUILD.gn ++++ util/BUILD.gn +@@ -143,7 +143,7 @@ if (crashpad_is_mac || crashpad_is_ios) { + "arm64", + ] + } else { +- assert(false, "Unsupported architecture") ++ print("Unknown architecture -> assume conan knows how to handle it") + } + } + diff --git a/recipes/crashpad/all/patches/cci.20220219-0006-mini_chromium-win_helper-py3.patch b/recipes/crashpad/all/patches/cci.20220219-0006-mini_chromium-win_helper-py3.patch new file mode 100644 index 0000000000000..311514add9153 --- /dev/null +++ b/recipes/crashpad/all/patches/cci.20220219-0006-mini_chromium-win_helper-py3.patch @@ -0,0 +1,96 @@ +--- third_party/mini_chromium/mini_chromium/build/win_helper.py ++++ third_party/mini_chromium/mini_chromium/build/win_helper.py +@@ -4,7 +4,10 @@ + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. + +-import _winreg ++try: ++ import _winreg ++except ImportError: ++ import winreg as _winreg + import os + import re + import subprocess +@@ -62,7 +65,7 @@ def _FormatAsEnvironmentBlock(envvar_dict): + CreateProcess() documentation for more details.""" + block = '' + nul = '\0' +- for key, value in envvar_dict.iteritems(): ++ for key, value in envvar_dict.items(): + block += key + '=' + value + nul + block += nul + return block +@@ -81,7 +84,7 @@ def _GenerateEnvironmentFiles(install_dir, out_dir, script_path): + archs = ('x86', 'amd64', 'arm64') + result = [] + for arch in archs: +- # Extract environment variables for subprocesses. ++ sys.stderr.write("install_dir {} script_path {}".format(install_dir, script_path)) + args = [os.path.join(install_dir, script_path)] + script_arch_name = arch + if script_path.endswith('SetEnv.cmd') and arch == 'amd64': +@@ -94,12 +97,12 @@ def _GenerateEnvironmentFiles(install_dir, out_dir, script_path): + variables, _ = popen.communicate() + if popen.returncode != 0: + raise Exception('"%s" failed with error %d' % (args, popen.returncode)) +- env = _ExtractImportantEnvironment(variables) ++ env = _ExtractImportantEnvironment(variables.decode()) + + env_block = _FormatAsEnvironmentBlock(env) + basename = 'environment.' + arch + with open(os.path.join(out_dir, basename), 'wb') as f: +- f.write(env_block) ++ f.write(env_block.encode()) + result.append(basename) + return result + +@@ -139,10 +142,10 @@ class WinTool(object): + link = subprocess.Popen(args, env=env, shell=True, stdout=subprocess.PIPE) + out, _ = link.communicate() + for line in out.splitlines(): +- if (not line.startswith(' Creating library ') and +- not line.startswith('Generating code') and +- not line.startswith('Finished generating code')): +- print line ++ if (not line.startswith(b' Creating library ') and ++ not line.startswith(b'Generating code') and ++ not line.startswith(b'Finished generating code')): ++ print(line) + return link.returncode + + def ExecAsmWrapper(self, arch, *args): +@@ -152,11 +155,11 @@ class WinTool(object): + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + out, _ = popen.communicate() + for line in out.splitlines(): +- if (not line.startswith('Copyright (C) Microsoft Corporation') and +- not line.startswith('Microsoft (R) Macro Assembler') and +- not line.startswith(' Assembling: ') and ++ if (not line.startswith(b'Copyright (C) Microsoft Corporation') and ++ not line.startswith(b'Microsoft (R) Macro Assembler') and ++ not line.startswith(b' Assembling: ') and + line): +- print line ++ print(line) + return popen.returncode + + def ExecGetVisualStudioData(self, outdir, toolchain_path): +@@ -185,7 +188,7 @@ class WinTool(object): + 'Microsoft Visual Studio', 'Installer', 'vswhere.exe') + if os.path.exists(vswhere_path): + installation_path = subprocess.check_output( +- [vswhere_path, '-latest', '-property', 'installationPath']).strip() ++ [vswhere_path, '-latest', '-property', 'installationPath']).strip().decode() + if installation_path: + return (installation_path, + os.path.join('VC', 'Auxiliary', 'Build', 'vcvarsall.bat')) +@@ -216,7 +219,7 @@ class WinTool(object): + x86_environment_file = "%s" + x64_environment_file = "%s" + arm64_environment_file = "%s"''' % (install_dir, x86_file, x64_file, arm64_file) +- print result ++ print(result) + return 0 + + def ExecStamp(self, path): diff --git a/recipes/crashpad/all/patches/cci.20220219-0007-static-lib-tool_support.patch b/recipes/crashpad/all/patches/cci.20220219-0007-static-lib-tool_support.patch new file mode 100644 index 0000000000000..c2f0a14e65754 --- /dev/null +++ b/recipes/crashpad/all/patches/cci.20220219-0007-static-lib-tool_support.patch @@ -0,0 +1,13 @@ +diff --git a/tools/BUILD.gn b/tools/BUILD.gn +index 4069e070..316d7ee7 100644 +--- a/tools/BUILD.gn ++++ b/tools/BUILD.gn +@@ -14,7 +14,7 @@ + + import("../build/crashpad_buildconfig.gni") + +-source_set("tool_support") { ++static_library("tool_support") { + sources = [ + "tool_support.cc", + "tool_support.h", diff --git a/recipes/crashpad/all/test_package/CMakeLists.txt b/recipes/crashpad/all/test_package/CMakeLists.txt index 33ae887aa6aea..6c1d84c7e3d82 100644 --- a/recipes/crashpad/all/test_package/CMakeLists.txt +++ b/recipes/crashpad/all/test_package/CMakeLists.txt @@ -6,4 +6,4 @@ conan_basic_setup() add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/crashpad/all/test_package/conanfile.py b/recipes/crashpad/all/test_package/conanfile.py index e0b20d0f49610..a0d87c14b0333 100644 --- a/recipes/crashpad/all/test_package/conanfile.py +++ b/recipes/crashpad/all/test_package/conanfile.py @@ -12,7 +12,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): test_env_dir = "test_env" tools.mkdir(test_env_dir) bin_path = os.path.join("bin", "test_package") @@ -20,6 +20,6 @@ def test(self): handler_bin_path = os.path.join(self.deps_cpp_info["crashpad"].rootpath, "bin", handler_exe) self.run("%s %s/db %s" % (bin_path, test_env_dir, handler_bin_path), run_environment=True) if self.settings.os == "Windows": - handler_exe = "crashpad_handler_com.com" + handler_exe = "crashpad_handler.com" handler_bin_path = os.path.join(self.deps_cpp_info["crashpad"].rootpath, "bin", handler_exe) self.run("%s %s/db %s" % (bin_path, test_env_dir, handler_bin_path), run_environment=True) diff --git a/recipes/crashpad/all/test_package/test_package.cpp b/recipes/crashpad/all/test_package/test_package.cpp index 8f5ca824f1a03..923a0cf8888d3 100644 --- a/recipes/crashpad/all/test_package/test_package.cpp +++ b/recipes/crashpad/all/test_package/test_package.cpp @@ -9,6 +9,8 @@ #include "client/crashpad_client.h" #include "client/settings.h" +#include "client/crash_report_database.h" + bool startCrashpad(const base::FilePath &db, const base::FilePath &handler) { std::string url("http://localhost"); @@ -44,5 +46,9 @@ int main(int argc, char* argv[]) { base::FilePath handler(argv[2]); #endif + // Test availability of this function. + auto database = crashpad::CrashReportDatabase::Initialize(db); + (void) database; /* Avoid warning about unused variable */ + return startCrashpad(db, handler) ? 0 : 1; } diff --git a/recipes/crashpad/config.yml b/recipes/crashpad/config.yml index 47ddf4761a729..104465b6c7315 100644 --- a/recipes/crashpad/config.yml +++ b/recipes/crashpad/config.yml @@ -1,3 +1,5 @@ versions: "cci.20210507": folder: all + "cci.20220219": + folder: all diff --git a/recipes/crc32c/all/CMakeLists.txt b/recipes/crc32c/all/CMakeLists.txt deleted file mode 100644 index 16d33ed296f4b..0000000000000 --- a/recipes/crc32c/all/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - -add_subdirectory("source_subfolder") diff --git a/recipes/crc32c/all/conandata.yml b/recipes/crc32c/all/conandata.yml index 3c3f1ce53505c..58186e6d3f210 100644 --- a/recipes/crc32c/all/conandata.yml +++ b/recipes/crc32c/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.1.2": + url: "https://github.com/google/crc32c/archive/1.1.2.tar.gz" + sha256: "ac07840513072b7fcebda6e821068aa04889018f24e10e46181068fb214d7e56" "1.1.1": url: https://github.com/google/crc32c/archive/refs/tags/1.1.1.tar.gz sha256: "a6533f45b1670b5d59b38a514d82b09c6fb70cc1050467220216335e873074e8" diff --git a/recipes/crc32c/all/conanfile.py b/recipes/crc32c/all/conanfile.py index 810624dd06f81..2ffae46055537 100644 --- a/recipes/crc32c/all/conanfile.py +++ b/recipes/crc32c/all/conanfile.py @@ -1,21 +1,21 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -from conans.tools import Version +from conan import ConanFile +from conan.tools.build import check_min_cppstd, valid_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir import os +required_conan_version = ">=1.50.0" + class crc32cConan(ConanFile): name = "crc32c" description = "CRC32C implementation with support for CPU-specific acceleration instructions" - topics = ("conan", "crc32c", "crc") + topics = ("crc32c", "crc") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/google/crc32c" license = "BSD-3-Clause" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" settings = "os", "arch", "compiler", "build_type" - options = { "shared": [True, False], "fPIC": [True, False], @@ -25,16 +25,6 @@ class crc32cConan(ConanFile): "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -44,41 +34,48 @@ def configure(self): del self.options.fPIC def validate(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) - - def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - - def _configure_cmake(self): - if self._cmake is not None: - return self._cmake + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) - self._cmake = CMake(self) - if not self.settings.compiler.cppstd: - self._cmake.definitions["CMAKE_CXX_STANDARD"] = 11 - self._cmake.definitions["CRC32C_BUILD_TESTS"] = False - self._cmake.definitions["CRC32C_BUILD_BENCHMARKS"] = False - self._cmake.definitions["CRC32C_INSTALL"] = True - self._cmake.definitions["CRC32C_USE_GLOG"] = False + def layout(self): + cmake_layout(self, src_folder="src") - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if not valid_min_cppstd(self, 11): + tc.variables["CMAKE_CXX_STANDARD"] = 11 + tc.variables["CRC32C_BUILD_TESTS"] = False + tc.variables["CRC32C_BUILD_BENCHMARKS"] = False + tc.variables["CRC32C_INSTALL"] = True + tc.variables["CRC32C_USE_GLOG"] = False + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Crc32c") + self.cpp_info.set_property("cmake_target_name", "Crc32c::crc32c") + + # TODO: back to global scope once cmake_find_package* generators removed + self.cpp_info.components["_crc32c"].libs = ["crc32c"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "Crc32c" self.cpp_info.names["cmake_find_package_multi"] = "Crc32c" - self.cpp_info.components["_crc32c"].names["cmake_find_package"] = "crc32c" self.cpp_info.components["_crc32c"].names["cmake_find_package_multi"] = "crc32c" - self.cpp_info.components["_crc32c"].libs = ["crc32c"] + self.cpp_info.components["_crc32c"].set_property("cmake_target_name", "Crc32c::crc32c") diff --git a/recipes/crc32c/all/test_package/CMakeLists.txt b/recipes/crc32c/all/test_package/CMakeLists.txt index d77dec3da8636..4bb96eb2a3d2f 100644 --- a/recipes/crc32c/all/test_package/CMakeLists.txt +++ b/recipes/crc32c/all/test_package/CMakeLists.txt @@ -1,12 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -set(CMAKE_CXX_STANDARD 11) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(Crc32c CONFIG REQUIRED) -add_executable(${PROJECT_NAME} main.cpp) -target_link_libraries(${PROJECT_NAME} Crc32c::crc32c) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Crc32c::crc32c) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/crc32c/all/test_package/conanfile.py b/recipes/crc32c/all/test_package/conanfile.py index 03594e163dafc..3a8c6c5442b33 100644 --- a/recipes/crc32c/all/test_package/conanfile.py +++ b/recipes/crc32c/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join(".", "bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/crc32c/all/test_package/main.cpp b/recipes/crc32c/all/test_package/test_package.cpp similarity index 100% rename from recipes/crc32c/all/test_package/main.cpp rename to recipes/crc32c/all/test_package/test_package.cpp diff --git a/recipes/crc32c/all/test_v1_package/CMakeLists.txt b/recipes/crc32c/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4a774c8062feb --- /dev/null +++ b/recipes/crc32c/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Crc32c CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Crc32c::crc32c) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/crc32c/all/test_v1_package/conanfile.py b/recipes/crc32c/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..968e0fcd39136 --- /dev/null +++ b/recipes/crc32c/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join(".", "bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/crc32c/config.yml b/recipes/crc32c/config.yml index e80b5baf3ff6d..be8fcc08d267b 100644 --- a/recipes/crc32c/config.yml +++ b/recipes/crc32c/config.yml @@ -1,3 +1,5 @@ versions: + "1.1.2": + folder: "all" "1.1.1": folder: "all" diff --git a/recipes/crc_cpp/all/conandata.yml b/recipes/crc_cpp/all/conandata.yml new file mode 100644 index 0000000000000..5080c58c69521 --- /dev/null +++ b/recipes/crc_cpp/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "1.0.0": + url: "https://github.com/AshleyRoll/crc_cpp/archive/refs/tags/v1.0.0.tar.gz" + sha256: "035ed616e0662eddbe7db7c920faaef99bbeb8953ebf98c3bb76cb81a2c4de2b" + "1.0.1": + url: "https://github.com/AshleyRoll/crc_cpp/archive/refs/tags/v1.0.1.tar.gz" + sha256: "865a0e110bf7e94061ceef1683947a7788b54f932c7ce3848edc89d36e1aea26" + "1.1.0": + url: "https://github.com/AshleyRoll/crc_cpp/archive/refs/tags/v1.1.0.tar.gz" + sha256: "50e46e3c44eb39809f6697b253f7b36c089642d7b7f2ebe2f75adf23c50676be" diff --git a/recipes/crc_cpp/all/conanfile.py b/recipes/crc_cpp/all/conanfile.py new file mode 100644 index 0000000000000..4ccb993ef97a2 --- /dev/null +++ b/recipes/crc_cpp/all/conanfile.py @@ -0,0 +1,53 @@ +from conan import ConanFile, tools +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.50.0" + + +class Crc_CppConan(ConanFile): + name = "crc_cpp" + description = "A header only constexpr / compile time small-table based CRC library for C++17 and newer" + topics = "crc_cpp", "crc", "constexpr", "cpp17", "cpp20", "header-only" + settings = "compiler", "os" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/AshleyRoll/crc_cpp" + license = "MIT" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _supported_compiler(self): + compiler = str(self.settings.compiler) + version = Version(self.settings.compiler.version) + if compiler == "Visual Studio" and version >= "15": + return True + elif compiler == "gcc" and version >= "9": + return True + elif compiler == "clang" and version >= "5": + return True + elif compiler == "apple-clang" and version >= "10": + return True + else: + self.output.warn("{} recipe lacks information about the {} compiler standard version support".format(self.name, compiler)) + return False + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.build.check_min_cppstd(self, "17") + if not self._supported_compiler: + raise ConanInvalidConfiguration("crc_cpp: Unsupported compiler: {}-{} " + "Minimum C++17 constexpr features required.".format(self.settings.compiler, self.settings.compiler.version)) + def source(self): + tools.files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + + def package_id(self): + self.info.header_only() diff --git a/recipes/crc_cpp/all/test_package/CMakeLists.txt b/recipes/crc_cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d41bc6dd30265 --- /dev/null +++ b/recipes/crc_cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/crc_cpp/all/test_package/conanfile.py b/recipes/crc_cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..34a0bcae95438 --- /dev/null +++ b/recipes/crc_cpp/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conan import ConanFile, tools +from conans import CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.build.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/crc_cpp/all/test_package/test_package.cpp b/recipes/crc_cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..8ff6f35a02302 --- /dev/null +++ b/recipes/crc_cpp/all/test_package/test_package.cpp @@ -0,0 +1,35 @@ +#include +#include +#include + +#include "crc_cpp.h" + +using namespace crc_cpp; + +[[nodiscard]] auto compute_crc32(std::vector const &message) +{ + crc_cpp::crc32 crc; + + for(auto c : message) { + crc.update(c); + } + + return crc.final(); +} + + +int main() +{ + std::cout << "Smoke Testing crc_cpp with CRC32\n"; + + std::vector const message{'1', '2', '3', '4', '5', '6', '7', '8', '9'}; + + auto const result = compute_crc32(message); + if(result == 0xCBF43926) { + std::cout << "Success!\n"; + return 0; + } else { + std::cout << "Failed!??\n"; + return -1; + } +} diff --git a/recipes/crc_cpp/config.yml b/recipes/crc_cpp/config.yml new file mode 100644 index 0000000000000..f0842436f445a --- /dev/null +++ b/recipes/crc_cpp/config.yml @@ -0,0 +1,7 @@ +versions: + "1.0.0": + folder: "all" + "1.0.1": + folder: "all" + "1.1.0": + folder: "all" diff --git a/recipes/create-dmg/all/conandata.yml b/recipes/create-dmg/all/conandata.yml new file mode 100644 index 0000000000000..3bee38ab2012d --- /dev/null +++ b/recipes/create-dmg/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "1.1.0": + url: "https://github.com/create-dmg/create-dmg/archive/refs/tags/v1.1.0.tar.gz" + sha256: "d50e14a00b73a3f040732b4cfa11361f5786521719059ce2dfcccd9088d3bf32" + "1.0.10": + url: "https://github.com/create-dmg/create-dmg/archive/refs/tags/v1.0.10.tar.gz" + sha256: "8fd43498988f6d334d483faf4e4a330a25228784995d72c57e4565967d09e6ab" +patches: + "1.1.0": + - patch_file: "patches/0001-change-share-to-res.patch" + patch_type: "conan" + patch_description: "Change share folder to res" diff --git a/recipes/create-dmg/all/conanfile.py b/recipes/create-dmg/all/conanfile.py new file mode 100644 index 0000000000000..52e6fe840c8e2 --- /dev/null +++ b/recipes/create-dmg/all/conanfile.py @@ -0,0 +1,52 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.53.0" + + +class CreateDmgConan(ConanFile): + name = "create-dmg" + description = "A shell script to build fancy DMGs" + license = "MIT" + topics = "command-line", "dmg" + homepage = "https://github.com/create-dmg/create-dmg" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.os != "Macos": + raise ConanInvalidConfiguration(f"{self.name} works only on MacOS") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + apply_conandata_patches(self) + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="create-dmg", dst=os.path.join(self.package_folder, "bin"), src=self.source_folder) + copy(self, pattern="*", dst=os.path.join(self.package_folder, "res", "create-dmg", "support"), src=os.path.join(self.source_folder, "support")) + + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = ["res"] + + # TODO: to remove in conan v2 + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/create-dmg/all/patches/0001-change-share-to-res.patch b/recipes/create-dmg/all/patches/0001-change-share-to-res.patch new file mode 100644 index 0000000000000..c85d9062516ed --- /dev/null +++ b/recipes/create-dmg/all/patches/0001-change-share-to-res.patch @@ -0,0 +1,13 @@ +diff --git a/create-dmg b/create-dmg +index 4a9715e..4181ce4 100755 +--- a/create-dmg ++++ b/create-dmg +@@ -248,7 +248,7 @@ else + # We're running inside an installed location + bin_dir="$SCRIPT_DIR" + prefix_dir=$(dirname "$bin_dir") +- CDMG_SUPPORT_DIR="$prefix_dir/share/create-dmg/support" ++ CDMG_SUPPORT_DIR="$prefix_dir/res" + fi + + if [[ -z "$VOLUME_NAME" ]]; then diff --git a/recipes/create-dmg/all/test_package/conanfile.py b/recipes/create-dmg/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5618bda930886 --- /dev/null +++ b/recipes/create-dmg/all/test_package/conanfile.py @@ -0,0 +1,13 @@ +from conan import ConanFile + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def test(self): + self.run("create-dmg --version") diff --git a/recipes/create-dmg/all/test_v1_package/conanfile.py b/recipes/create-dmg/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..3d9d911ea4f98 --- /dev/null +++ b/recipes/create-dmg/all/test_v1_package/conanfile.py @@ -0,0 +1,10 @@ +from conans import ConanFile +from conan.tools.build import can_run + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def test(self): + if can_run(self): + self.run("create-dmg --version", run_environment=True) diff --git a/recipes/create-dmg/config.yml b/recipes/create-dmg/config.yml new file mode 100644 index 0000000000000..d8aafe5a32208 --- /dev/null +++ b/recipes/create-dmg/config.yml @@ -0,0 +1,5 @@ +versions: + "1.1.0": + folder: all + "1.0.10": + folder: all diff --git a/recipes/croncpp/all/CMakeLists.txt b/recipes/croncpp/all/CMakeLists.txt new file mode 100644 index 0000000000000..46247ce0c956e --- /dev/null +++ b/recipes/croncpp/all/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(conan_wrapper CXX) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +set(CMAKE_CXX_STANDARD 11) + +add_subdirectory(source_subfolder) diff --git a/recipes/croncpp/all/conandata.yml b/recipes/croncpp/all/conandata.yml new file mode 100644 index 0000000000000..7f25de8a50772 --- /dev/null +++ b/recipes/croncpp/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20220503": + url: "https://github.com/mariusbancila/croncpp/archive/5c28f410db1af9507ef8469c9796a7070e5e8e2e.tar.gz" + sha256: "cabc480c78ebf12b11bd9fcd705a7ecb1c85ac88a8c9debe8de67f30abd808a8" diff --git a/recipes/croncpp/all/conanfile.py b/recipes/croncpp/all/conanfile.py new file mode 100644 index 0000000000000..cecf595a5a249 --- /dev/null +++ b/recipes/croncpp/all/conanfile.py @@ -0,0 +1,45 @@ +import os +import functools +from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.33.0" + +class CroncppConan(ConanFile): + name = "croncpp" + description = "A C++11/14/17 header-only cross-platform library for handling CRON expressions" + topics = ("cron", "header-only") + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/mariusbancila/croncpp/" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + + def package_id(self): + self.info.header_only() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "11") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure() + return cmake + + def package(self): + self.copy("LICENSE*", "licenses", self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) diff --git a/recipes/croncpp/all/test_package/CMakeLists.txt b/recipes/croncpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..1bb4c146bf257 --- /dev/null +++ b/recipes/croncpp/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(croncpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} croncpp::croncpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/croncpp/all/test_package/conanfile.py b/recipes/croncpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..6cae150e6701a --- /dev/null +++ b/recipes/croncpp/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class CroncppConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/croncpp/all/test_package/test_package.cpp b/recipes/croncpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f8b277d966c59 --- /dev/null +++ b/recipes/croncpp/all/test_package/test_package.cpp @@ -0,0 +1,18 @@ +#include +#include + +#include "croncpp.h" + +int main(int argc, const char** argv) { + try { + auto cron = cron::make_cron("* 0/5 * * * ?"); + + auto now = std::time(0); + auto next = cron::cron_next(cron, now); + std::cout << (next - now) << "[sec]" << std::endl; + return 0; + } catch (cron::bad_cronexpr const& ex) { + std::cerr << ex.what() << std::endl; + } + return -1; +} diff --git a/recipes/croncpp/config.yml b/recipes/croncpp/config.yml new file mode 100644 index 0000000000000..162ec03638ac6 --- /dev/null +++ b/recipes/croncpp/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220503": + folder: "all" diff --git a/recipes/crowcpp-crow/all/conandata.yml b/recipes/crowcpp-crow/all/conandata.yml index d8eced9828909..3aed5442c57ab 100644 --- a/recipes/crowcpp-crow/all/conandata.yml +++ b/recipes/crowcpp-crow/all/conandata.yml @@ -1,8 +1,33 @@ sources: + "1.0+3": + url: "https://github.com/CrowCpp/crow/archive/refs/tags/v1.0+3.tar.gz" + sha256: "509248e7bd30dad725cfb66c383405a8bdc59d1fe7f8f2b464d459444047855e" + "1.0+1": + url: "https://github.com/CrowCpp/crow/archive/refs/tags/v1.0+1.tar.gz" + sha256: "0763342f1d6bfc8a58c99647bd2a5ac9fcb278523a662a20b560e42e5c6c8474" + "0.3+4": + url: "https://github.com/CrowCpp/crow/archive/refs/tags/v0.3+4.tar.gz" + sha256: "539622451c1c9be4329d1c260d4014db14ef399b6bc170c7dd0d72b33cba88b0" + "0.3+3": + url: "https://github.com/CrowCpp/crow/archive/refs/tags/v0.3+3.tar.gz" + sha256: "d6d8019ec647dc199e026e847f6cdf714afea29d1c202e3b2a9cde929bfd54b2" + "0.3+2": + url: "https://github.com/CrowCpp/crow/archive/refs/tags/v0.3+2.tar.gz" + sha256: "982fe978c113506aefe77c413befb3ab21fffb09d9bdf287ec8e8ba59bd786e7" + "0.3": + url: "https://github.com/CrowCpp/crow/archive/v0.3.tar.gz" + sha256: "95538db88fba73c0bc87bbc40b62dcf488012c133a895634ade015009ebb4f25" "0.2": - sha256: f52445e0b236ecf0fda50ac5a1b7a2da511401c885071fb97a74b6b9844a9e64 - url: https://github.com/CrowCpp/crow/archive/0.2.tar.gz + url: "https://github.com/CrowCpp/crow/archive/0.2.tar.gz" + sha256: "c419767f0a336f2add71fc8b311ad95434d59601fb8b0e5ba3048407d85d0a71" patches: "0.2": - - patch_file: "patches/001-disable-examples.patch" + - patch_file: "patches/0.2/0001-normalize-buildsystem.patch" base_path: "source_subfolder" + # patch_type: "conan" + # description: "Skip tests and examples from build" + - patch_file: "patches/0.2/0002-replace-uint.patch" + base_path: "source_subfolder" + # patch_type: "portability" + # source: "https://github.com/CrowCpp/Crow/commit/5fe3a45793604a50f5c9086909dfa1b50dfa3e88" + # description: "Replace uint (not default type) with unsigned" diff --git a/recipes/crowcpp-crow/all/conanfile.py b/recipes/crowcpp-crow/all/conanfile.py index 8232f86b54008..ac9c4ed132538 100644 --- a/recipes/crowcpp-crow/all/conanfile.py +++ b/recipes/crowcpp-crow/all/conanfile.py @@ -1,42 +1,82 @@ from conans import ConanFile, tools, CMake import os +required_conan_version = ">=1.33.0" + + class CrowConan(ConanFile): name = "crowcpp-crow" - homepage = "https://github.com/CrowCpp/crow" + homepage = "http://crowcpp.org/" description = "Crow is a C++ microframework for running web services." - topics = ("conan", "web", "microframework", "header-only") + topics = ("web", "microframework", "header-only") url = "https://github.com/conan-io/conan-center-index" settings = "os", "compiler", "arch", "build_type" license = "BSD-3-Clause" + provides = "crow" + + options = { + "amalgamation": [True, False], + } + default_options = { + "amalgamation": False, + } + @property def _source_subfolder(self): return "source_subfolder" + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def requirements(self): - self.requires("boost/1.75.0") - '''To be removed in next released versions''' - self.requires("openssl/1.1.1i") + self.requires("boost/1.77.0") + if self.version == "0.2": + self.requires("openssl/1.1.1l") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "crow-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get( + **self.conan_data["sources"][self.version], + strip_root=True, + destination=self._source_subfolder + ) def build(self): - cmake = CMake(self) - cmake.configure(source_folder=self._source_subfolder) - cmake.build(target="amalgamation") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + if self.options.amalgamation: + cmake = CMake(self) + cmake.definitions["BUILD_EXAMPLES"] = False + cmake.definitions["BUILD_TESTING"] = False + cmake.configure(source_folder=self._source_subfolder) + cmake.build(target="amalgamation") def package(self): self.copy(pattern="LICENSE*", dst="licenses", src=self._source_subfolder) - self.copy("*.h", dst=os.path.join("include", "crow"), src=os.path.join(self._source_subfolder, "include")) - self.copy("crow_all.h", dst=os.path.join("include", "crow")) + + if self.options.amalgamation: + self.copy("crow_all.h", dst="include") + else: + self.copy( + "*.h", + dst=os.path.join("include"), + src=os.path.join(self._source_subfolder, "include"), + ) + self.copy( + "*.hpp", + dst=os.path.join("include"), + src=os.path.join(self._source_subfolder, "include"), + ) def package_id(self): - self.info.header_only() + self.info.settings.clear() def package_info(self): + # These are not official targets, this is just the name (without fork prefix) + self.cpp_info.names["cmake_find_package"] = "crow" + self.cpp_info.names["cmake_find_package_multi"] = "crow" + if self.settings.os in ("FreeBSD", "Linux"): self.cpp_info.system_libs = ["pthread"] diff --git a/recipes/crowcpp-crow/all/patches/0.2/0001-normalize-buildsystem.patch b/recipes/crowcpp-crow/all/patches/0.2/0001-normalize-buildsystem.patch new file mode 100644 index 0000000000000..67c9be1d0235b --- /dev/null +++ b/recipes/crowcpp-crow/all/patches/0.2/0001-normalize-buildsystem.patch @@ -0,0 +1,31 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f00e9a9..61961da 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,6 +1,7 @@ + cmake_minimum_required(VERSION 3.15) + project (crow_all) + ++if(BUILD_TESTING) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") + + find_package(Tcmalloc) +@@ -43,15 +44,17 @@ include_directories("${PROJECT_INCLUDE_DIR}") + include_directories("${PROJECT_SOURCE_DIR}") + + add_subdirectory(examples) ++endif() + + if (MSVC) + else() ++ if (BUILD_TESTING) + add_subdirectory(tests) + + enable_testing() + add_test(NAME crow_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/unittest) + add_test(NAME template_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/template/test.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests/template) +- ++ endif() + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h + COMMAND python ${PROJECT_SOURCE_DIR}/scripts/merge_all.py diff --git a/recipes/crowcpp-crow/all/patches/0.2/0002-replace-uint.patch b/recipes/crowcpp-crow/all/patches/0.2/0002-replace-uint.patch new file mode 100644 index 0000000000000..c6f95ea173f09 --- /dev/null +++ b/recipes/crowcpp-crow/all/patches/0.2/0002-replace-uint.patch @@ -0,0 +1,26 @@ +diff --git a/include/crow/http_connection.h b/include/crow/http_connection.h +index 2216687..04a992d 100644 +--- a/include/crow/http_connection.h ++++ b/include/crow/http_connection.h +@@ -627,7 +627,7 @@ namespace crow + + boost::array buffer_; + +- const uint res_stream_threshold_ = 1048576; ++ const unsigned res_stream_threshold_ = 1048576; + + HTTPParser parser_; + request req_; +diff --git a/include/crow/multipart.h b/include/crow/multipart.h +index 7deb8d4..7b63c20 100644 +--- a/include/crow/multipart.h ++++ b/include/crow/multipart.h +@@ -48,7 +48,7 @@ namespace crow + std::stringstream str; + std::string delimiter = dd + boundary; + +- for (uint i=0 ; i $) ++ target_include_directories(cryptopp-pem-static PUBLIC $ $) + else () +- set_target_properties(cryptopp-static PROPERTIES INCLUDE_DIRECTORIES "$ $") ++ set_target_properties(cryptopp-pem-static PROPERTIES INCLUDE_DIRECTORIES "$ $") + endif () + endif () + + if (BUILD_SHARED) +- add_library(cryptopp-shared SHARED ${cryptopp_LIBRARY_SOURCES}) +- cryptopp_target_compile_properties(cryptopp-shared) ++ add_library(cryptopp-pem-shared SHARED ${cryptopp_LIBRARY_SOURCES}) ++ cryptopp_target_compile_properties(cryptopp-pem-shared) + if (NOT ${CMAKE_VERSION} VERSION_LESS "2.8.11") +- target_include_directories(cryptopp-shared PUBLIC $ $) ++ target_include_directories(cryptopp-pem-shared PUBLIC $ $) + else () +- set_target_properties(cryptopp-shared PROPERTIES INCLUDE_DIRECTORIES "$ $") ++ set_target_properties(cryptopp-pem-shared PROPERTIES INCLUDE_DIRECTORIES "$ $") + endif () + endif () + +@@ -1046,15 +1046,15 @@ + set(COMPAT_VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR}) + + if (BUILD_STATIC) +- set_target_properties(cryptopp-static ++ set_target_properties(cryptopp-pem-static + PROPERTIES +- OUTPUT_NAME cryptopp) ++ OUTPUT_NAME cryptopp-pem) + endif () + if (BUILD_SHARED) +- set_target_properties(cryptopp-shared ++ set_target_properties(cryptopp-pem-shared + PROPERTIES + SOVERSION ${COMPAT_VERSION} +- OUTPUT_NAME cryptopp) ++ OUTPUT_NAME cryptopp-pem) + endif () + endif () + +@@ -1062,11 +1062,11 @@ + # similar to how the crypto++ 'make' tool works. + # see https://github.com/noloader/cryptopp-cmake/issues/32 + if (BUILD_STATIC) +- add_custom_target(static DEPENDS cryptopp-static) ++ add_custom_target(static DEPENDS cryptopp-pem-static) + endif () + if (BUILD_SHARED) +- add_custom_target(shared DEPENDS cryptopp-shared) +- add_custom_target(dynamic DEPENDS cryptopp-shared) ++ add_custom_target(shared DEPENDS cryptopp-pem-shared) ++ add_custom_target(dynamic DEPENDS cryptopp-pem-shared) + endif () + + #============================================================================ +@@ -1075,29 +1075,29 @@ + + if (WIN32) + if (BUILD_STATIC) +- target_link_libraries(cryptopp-static ws2_32) ++ target_link_libraries(cryptopp-pem-static ws2_32) + endif () + if (BUILD_SHARED) +- target_link_libraries(cryptopp-shared ws2_32) ++ target_link_libraries(cryptopp-pem-shared ws2_32) + endif () + endif () + + # This may need to be expanded to "Solaris" + if (CRYPTOPP_SOLARIS) + if (BUILD_STATIC) +- target_link_libraries(cryptopp-static nsl socket) ++ target_link_libraries(cryptopp-pem-static nsl socket) + endif () + if (BUILD_SHARED) +- target_link_libraries(cryptopp-shared nsl socket) ++ target_link_libraries(cryptopp-pem-shared nsl socket) + endif () + endif () + + find_package(Threads) + if (BUILD_STATIC) +- target_link_libraries(cryptopp-static ${CMAKE_THREAD_LIBS_INIT}) ++ target_link_libraries(cryptopp-pem-static ${CMAKE_THREAD_LIBS_INIT}) + endif () + if (BUILD_SHARED) +- target_link_libraries(cryptopp-shared ${CMAKE_THREAD_LIBS_INIT}) ++ target_link_libraries(cryptopp-pem-shared ${CMAKE_THREAD_LIBS_INIT}) + endif () + + #============================================================================ +@@ -1107,7 +1107,7 @@ + enable_testing() + if (BUILD_TESTING) + add_executable(cryptest ${cryptopp_SOURCES_TEST}) +- target_link_libraries(cryptest cryptopp-static) ++ target_link_libraries(cryptest cryptopp-pem-static) + + # Setting "cryptest" binary name to "cryptest.exe" + if (NOT (WIN32 OR CYGWIN)) +@@ -1159,9 +1159,9 @@ + + # Runtime package + if (BUILD_SHARED) +- export(TARGETS cryptopp-shared FILE ${export_name}.cmake ) ++ export(TARGETS cryptopp-pem-shared FILE ${export_name}.cmake ) + install( +- TARGETS cryptopp-shared ++ TARGETS cryptopp-pem-shared + EXPORT ${export_name} + DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +@@ -1172,8 +1172,8 @@ + + # Development package + if (BUILD_STATIC) +- export(TARGETS cryptopp-static FILE ${export_name}.cmake ) +- install(TARGETS cryptopp-static EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++ export(TARGETS cryptopp-pem-static FILE ${export_name}.cmake ) ++ install(TARGETS cryptopp-pem-static EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif () + install(FILES ${cryptopp_HEADERS} DESTINATION include/cryptopp) + diff --git a/recipes/cryptopp-pem/all/patches/use-cryptopp-include-from-conan.patch b/recipes/cryptopp-pem/all/patches/use-cryptopp-include-from-conan.patch new file mode 100644 index 0000000000000..e7c0d678e7363 --- /dev/null +++ b/recipes/cryptopp-pem/all/patches/use-cryptopp-include-from-conan.patch @@ -0,0 +1,172 @@ +--- a/pem.h ++++ b/pem.h +@@ -15,13 +15,13 @@ + #ifndef CRYPTOPP_PEM_H + #define CRYPTOPP_PEM_H + +-#include "pubkey.h" +-#include "eccrypto.h" +-#include "gfpcrypt.h" +-#include "integer.h" +-#include "rsa.h" +-#include "dsa.h" +-#include "elgamal.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include + + NAMESPACE_BEGIN(CryptoPP) + +--- a/pem_common.cpp ++++ b/pem_common.cpp +@@ -6,10 +6,10 @@ + // http://www.cryptopp.com/wiki/PEM_Pack + /////////////////////////////////////////////////////////////////////////// + +-#include "cryptlib.h" +-#include "secblock.h" +-#include "base64.h" +-#include "osrng.h" ++#include ++#include ++#include ++#include + + #include + #include +--- a/pem_common.h ++++ b/pem_common.h +@@ -10,9 +10,10 @@ + #ifndef CRYPTOPP_PEM_COMMON_H + #define CRYPTOPP_PEM_COMMON_H + +-#include "cryptlib.h" +-#include "secblock.h" +-#include "osrng.h" ++#include ++#include ++#include ++ + #include "pem.h" + + #include +--- a/pem_read.cpp ++++ b/pem_read.cpp +@@ -10,27 +10,27 @@ + #include + #include + +-#include "cryptlib.h" +-#include "secblock.h" +-#include "nbtheory.h" +-#include "gfpcrypt.h" +-#include "camellia.h" +-#include "smartptr.h" +-#include "filters.h" +-#include "base64.h" +-#include "queue.h" +-#include "modes.h" +-#include "asn.h" +-#include "aes.h" +-#include "idea.h" +-#include "hex.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + + #include "pem.h" + #include "pem_common.h" + + #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 +-#include "des.h" +-#include "md5.h" ++#include ++#include + + ////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// +--- a/pem_test.cxx ++++ b/pem_test.cxx +@@ -4,13 +4,14 @@ + #include + #include + +-#include "cryptlib.h" +-#include "integer.h" +-#include "eccrypto.h" +-#include "osrng.h" +-#include "files.h" +-#include "rsa.h" +-#include "dsa.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ + #include "pem.h" + + int main(int argc, char* argv[]) +--- a/pem_write.cpp ++++ b/pem_write.cpp +@@ -10,27 +10,27 @@ + #include + #include + +-#include "cryptlib.h" +-#include "secblock.h" +-#include "camellia.h" +-#include "smartptr.h" +-#include "filters.h" +-#include "base64.h" +-#include "files.h" +-#include "queue.h" +-#include "modes.h" +-#include "osrng.h" +-#include "asn.h" +-#include "aes.h" +-#include "idea.h" +-#include "hex.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + + #include "pem.h" + #include "pem_common.h" + + #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 +-#include "des.h" +-#include "md5.h" ++#include ++#include + + ////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////// diff --git a/recipes/cryptopp-pem/all/test_package/CMakeLists.txt b/recipes/cryptopp-pem/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f9ceeed7804cb --- /dev/null +++ b/recipes/cryptopp-pem/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cryptopp-pem) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} cryptopp-pem::cryptopp-pem) diff --git a/recipes/cryptopp-pem/all/test_package/conanfile.py b/recipes/cryptopp-pem/all/test_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/cryptopp-pem/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cryptopp-pem/all/test_package/test_package.cpp b/recipes/cryptopp-pem/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f3e9ea6413d94 --- /dev/null +++ b/recipes/cryptopp-pem/all/test_package/test_package.cpp @@ -0,0 +1,27 @@ +#include + +#include +#include + +int main() +{ + try + { + CryptoPP::RSA::PublicKey publicKey; + std::string key = "-----BEGIN PUBLIC KEY-----\n" + "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDWEDeqk749sYZAt2adT2m1Vo8N\n" + "h86GzAs/ZWvlQDUyiedDuAvOhrVwllp4GuAXP7tZwGoeJ+Un6Nkl45IIQ2U9NMWQ\n" + "aru76CD9kVUdThnKVOaeeqZysM1Bz6iJF5piSUzVKZdEk6rIUZjrwpNaYdBBq4a/\n" + "cNETdvolooljIRB8ywIDAQAB\n" + "-----END PUBLIC KEY-----"; + CryptoPP::StringSource source_str(key, true); + CryptoPP::PEM_Load(source_str, publicKey); + + return 0; + } + catch(const std::exception& e) + { + std::cout << e.what() << std::endl; + return 1; + } +} diff --git a/recipes/cryptopp-pem/config.yml b/recipes/cryptopp-pem/config.yml new file mode 100644 index 0000000000000..1496698a0560a --- /dev/null +++ b/recipes/cryptopp-pem/config.yml @@ -0,0 +1,3 @@ +versions: + "8.2.0": + folder: "all" diff --git a/recipes/cryptopp/all/conandata.yml b/recipes/cryptopp/all/conandata.yml index 73d7636692771..b34682e4296a3 100644 --- a/recipes/cryptopp/all/conandata.yml +++ b/recipes/cryptopp/all/conandata.yml @@ -1,26 +1,43 @@ sources: + "8.7.0": + source: + url: "https://github.com/weidai11/cryptopp/archive/CRYPTOPP_8_7_0.tar.gz" + sha256: "8d6a4064b8e9f34cd3e838f5a12c40067ee7b95ee37d9173ec273cb0913e7ca2" + cmake: + url: "https://github.com/abdes/cryptopp-cmake/archive/CRYPTOPP_8_7_0.tar.gz" + sha256: "c113aba8069842edb201b4aaa2925e2c9d6ca081c4fd6b049ff74fedf6e8bae3" + "8.6.0": + source: + url: "https://github.com/weidai11/cryptopp/archive/CRYPTOPP_8_6_0.tar.gz" + sha256: "9304625f4767a13e0a5f26d0f019d78cf9375604a33e5391c3bf2e81399dfeb8" + cmake: + url: "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_6_0.tar.gz" + sha256: "970b20d55dbf9d6335485e72c9f8967d878bf64bbd3de6aa28436beb6799c493" "8.5.0": - url: - "source": "https://github.com/weidai11/cryptopp/archive/CRYPTOPP_8_5_0.tar.gz" - "cmake": "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_5_0.tar.gz" - sha256: - "source": "8f64cf09cf4f61d5d74bca53574b8cc9959186cc0f072a2e6597e4999d6ad5db" - "cmake": "10685209405e676993873fcf638ade5f8f99d7949afa6b2045289ce9cc6d90ac" + source: + url: "https://github.com/weidai11/cryptopp/archive/CRYPTOPP_8_5_0.tar.gz" + sha256: "8f64cf09cf4f61d5d74bca53574b8cc9959186cc0f072a2e6597e4999d6ad5db" + cmake: + url: "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_5_0.tar.gz" + sha256: "10685209405e676993873fcf638ade5f8f99d7949afa6b2045289ce9cc6d90ac" "8.4.0": - url: - "source": "https://github.com/weidai11/cryptopp/archive/CRYPTOPP_8_4_0.tar.gz" - "cmake": "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_4_0.tar.gz" - sha256: - "source": "6687dfc1e33b084aeab48c35a8550b239ee5f73a099a3b6a0918d70b8a89e654" - "cmake": "b850070141f6724fce640e4e2cfde433ec5b2d99d4386d29ba9255167bc4b4f0" + source: + url: "https://github.com/weidai11/cryptopp/archive/CRYPTOPP_8_4_0.tar.gz" + sha256: "6687dfc1e33b084aeab48c35a8550b239ee5f73a099a3b6a0918d70b8a89e654" + cmake: + url: "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_4_0.tar.gz" + sha256: "b850070141f6724fce640e4e2cfde433ec5b2d99d4386d29ba9255167bc4b4f0" "8.2.0": - url: - "source": "https://github.com/weidai11/cryptopp/archive/CRYPTOPP_8_2_0.tar.gz" - "cmake": "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_2_0.tar.gz" - sha256: - "source": "e3bcd48a62739ad179ad8064b523346abb53767bcbefc01fe37303412292343e" - "cmake": "f41f6a32b1177c094c3ef97423916713c902d0ac26cbee30ec70b1e8ab0e6fba" + source: + url: "https://github.com/weidai11/cryptopp/archive/CRYPTOPP_8_2_0.tar.gz" + sha256: "e3bcd48a62739ad179ad8064b523346abb53767bcbefc01fe37303412292343e" + cmake: + url: "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_2_0.tar.gz" + sha256: "f41f6a32b1177c094c3ef97423916713c902d0ac26cbee30ec70b1e8ab0e6fba" patches: + "8.7.0": + - patch_file: "patches/0001-fix-msvc-arm64-8.7.0.patch" + "8.6.0": + - patch_file: "patches/0001-fix-cmake-8.6.0.patch" "8.2.0": - - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-fix-cmake-8.2.0.patch" diff --git a/recipes/cryptopp/all/conanfile.py b/recipes/cryptopp/all/conanfile.py index 6b4d904deac1b..f4a34568ef0e2 100644 --- a/recipes/cryptopp/all/conanfile.py +++ b/recipes/cryptopp/all/conanfile.py @@ -1,9 +1,13 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get, rename, replace_in_file, rmdir, save +from conan.tools.scm import Version +from conans import tools as tools_legacy import os -import shutil import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.47.0" class CryptoPPConan(ConanFile): @@ -12,89 +16,125 @@ class CryptoPPConan(ConanFile): homepage = "https://cryptopp.com" license = "BSL-1.0" description = "Crypto++ Library is a free C++ class library of cryptographic schemes." - topics = ("conan", "cryptopp", "crypto", "cryptographic", "security") - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - generators = "cmake" - exports_sources = ["CMakeLists.txt", "patches/**"] - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + topics = ("cryptopp", "crypto", "cryptographic", "security") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def build_requirements(self): + if Version(self.version) >= "8.7.0": + self.tool_requires("cmake/3.24.0") + + def validate(self): + if self.options.shared and Version(self.version) >= "8.7.0": + raise ConanInvalidConfiguration("cryptopp 8.7.0 and higher do not support shared builds") + def configure(self): if self.options.shared: del self.options.fPIC + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - suffix = "CRYPTOPP_{}".format(self.version.replace(".", "_")) - data = self.conan_data["sources"][self.version] - - # Get sources - source_cryptopp = { - "url": data["url"]["source"], - "sha256": data["sha256"]["source"] - } - tools.get(**source_cryptopp) - os.rename("cryptopp-" + suffix, self._source_subfolder) - - # Get CMakeLists - cmake_cryptopp = { - "url": data["url"]["cmake"], - "sha256": data["sha256"]["cmake"] - } - tools.get(**cmake_cryptopp) - src_folder = os.path.join(self.source_folder, "cryptopp-cmake-" + suffix) - dst_folder = os.path.join(self.source_folder, self._source_subfolder) - shutil.move(os.path.join(src_folder, "CMakeLists.txt"), os.path.join(dst_folder, "CMakeLists.txt")) - shutil.move(os.path.join(src_folder, "cryptopp-config.cmake"), os.path.join(dst_folder, "cryptopp-config.cmake")) - tools.rmdir(src_folder) + # Get cryptopp sources + get(self, **self.conan_data["sources"][self.version]["source"], + destination=self.source_folder, strip_root=True) + + if Version(self.version) < "8.7.0": + # Get CMakeLists + base_source_dir = os.path.join(self.source_folder, os.pardir) + get(self, **self.conan_data["sources"][self.version]["cmake"], destination=base_source_dir) + src_folder = os.path.join( + base_source_dir, + f"cryptopp-cmake-CRYPTOPP_{self.version.replace('.', '_')}", + ) + for file in ("CMakeLists.txt", "cryptopp-config.cmake"): + rename(self, src=os.path.join(src_folder, file), dst=os.path.join(self.source_folder, file)) + rmdir(self, src_folder) + else: + # Get cryptopp-cmake sources + get(self, **self.conan_data["sources"][self.version]["cmake"], + destination=os.path.join(self.source_folder, "cryptopp-cmake"), strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) < "8.7.0": + tc.variables["BUILD_STATIC"] = not self.options.shared + tc.variables["BUILD_SHARED"] = self.options.shared + tc.variables["BUILD_TESTING"] = False + tc.variables["BUILD_DOCUMENTATION"] = False + tc.variables["USE_INTERMEDIATE_OBJECTS_TARGET"] = False + if self.settings.os == "Android": + tc.variables["CRYPTOPP_NATIVE_ARCH"] = True + if self.settings.os == "Macos" and self.settings.arch == "armv8" and Version(self.version) <= "8.4.0": + tc.variables["CMAKE_CXX_FLAGS"] = "-march=armv8-a" + # For msvc shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + # Relocatable shared libs on macOS + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + else: + tc.cache_variables["CRYPTOPP_SOURCES"] = self.source_folder + tc.cache_variables["CRYPTOPP_BUILD_TESTING"] = False + tc.cache_variables["CRYPTOPP_BUILD_DOCUMENTATION"] = False + tc.cache_variables["CRYPTOPP_USE_INTERMEDIATE_OBJECTS_TARGET"] = False + if self.settings.os == "Android": + tc.cache_variables["CRYPTOPP_NATIVE_ARCH"] = True + tc.generate() def _patch_sources(self): - if self.settings.os == "Android" and "ANDROID_NDK_HOME" in os.environ: - shutil.copyfile(os.path.join(tools.get_env("ANDROID_NDK_HOME"), "sources", "android", "cpufeatures", "cpu-features.h"), - os.path.join(self._source_subfolder, "cpu-features.h")) - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - # Honor fPIC option - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "SET(CMAKE_POSITION_INDEPENDENT_CODE 1)", "") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_STATIC"] = not self.options.shared - self._cmake.definitions["BUILD_SHARED"] = self.options.shared - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.definitions["BUILD_DOCUMENTATION"] = False - self._cmake.definitions["USE_INTERMEDIATE_OBJECTS_TARGET"] = False + apply_conandata_patches(self) + # Use cpu-features.h from Android NDK if self.settings.os == "Android": - self._cmake.definitions["CRYPTOPP_NATIVE_ARCH"] = True - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + android_ndk_home = tools_legacy.get_env("ANDROID_NDK_HOME") + if android_ndk_home: + copy( + self, + "cpu-features.h", + src=os.path.join(android_ndk_home, "sources", "android", "cpufeatures"), + dst=self.source_folder, + ) + # Honor fPIC option + if Version(self.version) < "8.7.0": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "SET(CMAKE_POSITION_INDEPENDENT_CODE 1)", "") + else: + replace_in_file(self, os.path.join(self.source_folder, "cryptopp-cmake", "cryptopp", "CMakeLists.txt"), + "set(CMAKE_POSITION_INDEPENDENT_CODE 1)", "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + if Version(self.version) < "8.7.0": + cmake.configure() + else: + cmake.configure(build_script_folder="cryptopp-cmake") cmake.build() def package(self): - self.copy(pattern="License.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "License.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + if Version(self.version) < "8.7.0": + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + else: + rmdir(self, os.path.join(self.package_folder, "share")) + # TODO: to remove in conan v2 once cmake_find_package* generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), { @@ -103,42 +143,41 @@ def package(self): } ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + """) + save(self, module_file, content) @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.names["cmake_find_package"] = "cryptopp" - self.cpp_info.names["cmake_find_package_multi"] = "cryptopp" - self.cpp_info.names["pkg_config"] = "libcryptopp" cmake_target = "cryptopp-shared" if self.options.shared else "cryptopp-static" - self.cpp_info.components["libcryptopp"].names["cmake_find_package"] = cmake_target - self.cpp_info.components["libcryptopp"].names["cmake_find_package_multi"] = cmake_target - self.cpp_info.components["libcryptopp"].builddirs.append(self._module_subfolder) - self.cpp_info.components["libcryptopp"].build_modules["cmake_find_package"] = [self._module_file_rel_path] - self.cpp_info.components["libcryptopp"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - self.cpp_info.components["libcryptopp"].names["pkg_config"] = "libcryptopp" - self.cpp_info.components["libcryptopp"].libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.set_property("cmake_file_name", "cryptopp") + self.cpp_info.set_property("cmake_target_name", cmake_target) + self.cpp_info.set_property("pkg_config_name", "libcryptopp") + + # TODO: back to global scope once cmake_find_package* generators removed + self.cpp_info.components["libcryptopp"].libs = collect_libs(self) + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libcryptopp"].system_libs = ["pthread", "m"] elif self.settings.os == "SunOS": self.cpp_info.components["libcryptopp"].system_libs = ["nsl", "socket"] elif self.settings.os == "Windows": self.cpp_info.components["libcryptopp"].system_libs = ["ws2_32"] + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["pkg_config"] = "libcryptopp" + self.cpp_info.components["libcryptopp"].names["cmake_find_package"] = cmake_target + self.cpp_info.components["libcryptopp"].names["cmake_find_package_multi"] = cmake_target + self.cpp_info.components["libcryptopp"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["libcryptopp"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["libcryptopp"].set_property("cmake_target_name", cmake_target) + self.cpp_info.components["libcryptopp"].set_property("pkg_config_name", "libcryptopp") diff --git a/recipes/cryptopp/all/patches/0001-fix-cmake-8.2.0.patch b/recipes/cryptopp/all/patches/0001-fix-cmake-8.2.0.patch new file mode 100644 index 0000000000000..139deaef4e3b5 --- /dev/null +++ b/recipes/cryptopp/all/patches/0001-fix-cmake-8.2.0.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -447,7 +447,7 @@ if (MSVC) + if (CMAKE_SYSTEM_VERSION MATCHES "10\\.0.*") + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS "_WIN32_WINNT=0x0A00") + endif () +- list(APPEND CRYPTOPP_COMPILE_OPTIONS "/FI\"winapifamily.h\"") ++ list(APPEND CRYPTOPP_COMPILE_OPTIONS /FIwinapifamily.h) + endif () + + # Enable PIC for all target machines except 32-bit i386 due to register pressures. diff --git a/recipes/cryptopp/all/patches/0001-fix-cmake-8.6.0.patch b/recipes/cryptopp/all/patches/0001-fix-cmake-8.6.0.patch new file mode 100644 index 0000000000000..6491b83de8d9e --- /dev/null +++ b/recipes/cryptopp/all/patches/0001-fix-cmake-8.6.0.patch @@ -0,0 +1,13 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1024,8 +1024,8 @@ + # https://stackoverflow.com/q/61250087 + add_definitions("${CMAKE_CPP_FLAGS}" "${CMAKE_CXX_FLAGS}" "${CRYPTOPP_COMPILE_DEFINITIONS}" "${CRYPTOPP_COMPILE_OPTIONS}") + else() +- add_compile_definitions("${CMAKE_CPP_FLAGS}" "${CRYPTOPP_COMPILE_DEFINITIONS}") +- add_compile_options("${CMAKE_CXX_FLAGS}" "${CRYPTOPP_COMPILE_OPTIONS}") ++ add_compile_definitions(${CRYPTOPP_COMPILE_DEFINITIONS}) ++ add_compile_options(${CRYPTOPP_COMPILE_OPTIONS}) + endif() + + #============================================================================ diff --git a/recipes/cryptopp/all/patches/0001-fix-msvc-arm64-8.7.0.patch b/recipes/cryptopp/all/patches/0001-fix-msvc-arm64-8.7.0.patch new file mode 100755 index 0000000000000..1e813c076823d --- /dev/null +++ b/recipes/cryptopp/all/patches/0001-fix-msvc-arm64-8.7.0.patch @@ -0,0 +1,35 @@ +--- a/arm_simd.h ++++ b/arm_simd.h +@@ -307,28 +307,32 @@ inline uint64x2_t PMULL_HIGH(const uint64x2_t a, const uint64x2_t b) + #endif + } + ++// This function will be removed in the next version of Crypto++: ++// https://github.com/weidai11/cryptopp/commit/31fa3384160071793bc428a32383938551b3652c ++#if !defined(_MSC_VER) || defined(_M_ARM) + /// \brief Vector extraction + /// \param a the first value + /// \param b the second value + /// \param c the byte count + /// \return vector + /// \details VEXT_U8() extracts the first c bytes of vector + /// a and the remaining bytes in b. VEXT_U8 is provided + /// as GCC inline assembly due to Clang and lack of support for the intrinsic. + /// \since Crypto++ 8.0 + inline uint64x2_t VEXT_U8(uint64x2_t a, uint64x2_t b, unsigned int c) + { + #if defined(_MSC_VER) + return vreinterpretq_u64_u8(vextq_u8( + vreinterpretq_u8_u64(a), vreinterpretq_u8_u64(b), c)); + #else + uint64x2_t r; + __asm__ ("ext %0.16b, %1.16b, %2.16b, %3 \n\t" + :"=w" (r) : "w" (a), "w" (b), "I" (c) ); + return r; + #endif + } ++#endif + + /// \brief Vector extraction + /// \tparam C the byte count + /// \param a the first value diff --git a/recipes/cryptopp/all/test_package/CMakeLists.txt b/recipes/cryptopp/all/test_package/CMakeLists.txt index 3d99fde2c4dea..a2bf3d6bb06b3 100644 --- a/recipes/cryptopp/all/test_package/CMakeLists.txt +++ b/recipes/cryptopp/all/test_package/CMakeLists.txt @@ -1,14 +1,11 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES CXX) find_package(cryptopp REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -if(CRYPTOPP_SHARED) - target_link_libraries(${PROJECT_NAME} cryptopp-shared) +if(TARGET cryptopp-shared) + target_link_libraries(${PROJECT_NAME} PRIVATE cryptopp-shared) else() - target_link_libraries(${PROJECT_NAME} cryptopp-static) + target_link_libraries(${PROJECT_NAME} PRIVATE cryptopp-static) endif() diff --git a/recipes/cryptopp/all/test_package/conanfile.py b/recipes/cryptopp/all/test_package/conanfile.py index d5a812c1f4061..3a8c6c5442b33 100644 --- a/recipes/cryptopp/all/test_package/conanfile.py +++ b/recipes/cryptopp/all/test_package/conanfile.py @@ -1,18 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) - cmake.definitions["CRYPTOPP_SHARED"] = self.options["cryptopp"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cryptopp/all/test_v1_package/CMakeLists.txt b/recipes/cryptopp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..344dcc7df8b41 --- /dev/null +++ b/recipes/cryptopp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cryptopp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +if(TARGET cryptopp-shared) + target_link_libraries(${PROJECT_NAME} PRIVATE cryptopp-shared) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE cryptopp-static) +endif() diff --git a/recipes/cryptopp/all/test_v1_package/conanfile.py b/recipes/cryptopp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cryptopp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cryptopp/config.yml b/recipes/cryptopp/config.yml index c90ff76f4a6b6..0cf6dab66b6c7 100644 --- a/recipes/cryptopp/config.yml +++ b/recipes/cryptopp/config.yml @@ -1,4 +1,8 @@ versions: + "8.7.0": + folder: "all" + "8.6.0": + folder: "all" "8.5.0": folder: "all" "8.4.0": diff --git a/recipes/cspice/all/CMakeLists.txt b/recipes/cspice/all/CMakeLists.txt index 4f280145ac55c..8630af1db4d4a 100644 --- a/recipes/cspice/all/CMakeLists.txt +++ b/recipes/cspice/all/CMakeLists.txt @@ -1,18 +1,39 @@ -cmake_minimum_required(VERSION 3.4) -project(cspice C) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -option(BUILD_UTILITIES "Build cspice utilities" ON) +cmake_minimum_required(VERSION 3.7) +project(cspice LANGUAGES C) + +include(GNUInstallDirs) + +option(CSPICE_BUILD_UTILITIES "Build cspice utilities" ON) + +add_compile_options( + $<$,$>:-Wno-implicit-int> + $<$,$>:-Wno-format> + $<$,$>:-Wno-pointer-to-int-cast> + $<$:-Wno-logical-op-parentheses> + $<$:-Wno-shift-op-parentheses> + $<$:-Wno-parentheses> + $<$:-Wno-dangling-else> + $<$:-Wno-unsequenced> + $<$:/wd4101> + $<$:/wd4244> + $<$:/wd4267> + $<$:/wd4311> + $<$:/wd4477> + $<$:/wd4554> + $<$:/wd4723> + $<$:/wd4996> + # Behavior of implicitly defined functions changed in AppleClang 12 + # https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes + $<$,$>:-Wno-error=implicit-function-declaration> +) -set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/src) +set(SRC_DIR ${CSPICE_SRC_DIR}/src) file(GLOB CSPICE_SRC_FILES ${SRC_DIR}/cspice/*.c) add_library(cspice ${CSPICE_SRC_FILES}) if(WIN32) - target_compile_definitions(cspice PRIVATE "_COMPLEX_DEFINED;MSDOS;OMIT_BLANK_CC;NON_ANSI_STDIO") + target_compile_definitions(cspice PRIVATE "_COMPLEX_DEFINED;MSDOS;OMIT_BLANK_CC;NON_ANSI_STDIO;_CRT_SECURE_NO_WARNINGS") set_target_properties(cspice PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) elseif(UNIX) target_compile_definitions(cspice PRIVATE "NON_UNIX_STDIO") @@ -23,13 +44,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") target_link_libraries(cspice PRIVATE m) endif() -# Behavior of implicitly defined functions changed in AppleClang 12 -# https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes -if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND - CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "12") - target_compile_options(cspice PRIVATE -Wno-error=implicit-function-declaration) -endif() - install( TARGETS cspice RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} @@ -37,13 +51,13 @@ install( ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -file(GLOB INCLUDE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/include/*.h) -install(FILES ${INCLUDE_FILES} DESTINATION include) +file(GLOB INCLUDE_FILES ${CSPICE_SRC_DIR}/include/*.h) +install(FILES ${INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -if(BUILD_UTILITIES) +if(CSPICE_BUILD_UTILITIES) # csupport is common to all utilities file(GLOB CSUPPORT_SRC_FILES "${SRC_DIR}/csupport/*.c") - add_library(csupport OBJECT ${CSUPPORT_SRC_FILES}) + add_library(csupport STATIC ${CSUPPORT_SRC_FILES}) # Walk into all utilities subfolders and build them (except cook_c which only contains examples) file(GLOB CSPICE_UTILITIES_SUBDIRS RELATIVE ${SRC_DIR} "${SRC_DIR}/*_c") diff --git a/recipes/cspice/all/conandata.yml b/recipes/cspice/all/conandata.yml index 21297690b87bd..ed4687777f4ca 100644 --- a/recipes/cspice/all/conandata.yml +++ b/recipes/cspice/all/conandata.yml @@ -1,60 +1,122 @@ sources: + "0067": + "Macos": + "apple-clang": + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/MacIntel_OSX_AppleC_64bit/packages/cspice.tar.Z" + sha256: "6f4980445fee4d363dbce6f571819f4a248358d2c1bebca47e0743eedfe9935e" + "armv8": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/MacM1_OSX_clang_64bit/packages/cspice.tar.Z" + sha256: "0deae048443e11ca4d093cac651d9785d4f2594631a183d85a3d58949f4d0aa9" + "Linux": + "gcc": + "x86": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/PC_Linux_GCC_32bit/packages/cspice.tar.Z" + sha256: "33d75cd94acf6546e53d7ebc4e7d3d6d42ac27c83cb0d8f04c91a8b50c1149e3" + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/PC_Linux_GCC_64bit/packages/cspice.tar.Z" + sha256: "60a95b51a6472f1afe7e40d77ebdee43c12bb5b8823676ccc74692ddfede06ce" + "Windows": + "Visual Studio": + "x86": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/PC_Windows_VisualC_32bit/packages/cspice.zip" + sha256: "bc566e6a975c888fc5fd89d76554329501446bda88c8bab937c0725faead170f" + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/PC_Windows_VisualC_64bit/packages/cspice.zip" + sha256: "98d60b814b412fa55294aeaaeb7dab46d849cc87a8b709ffe835d08de17625dc" + "msvc": + "x86": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/PC_Windows_VisualC_32bit/packages/cspice.zip" + sha256: "bc566e6a975c888fc5fd89d76554329501446bda88c8bab937c0725faead170f" + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/PC_Windows_VisualC_64bit/packages/cspice.zip" + sha256: "98d60b814b412fa55294aeaaeb7dab46d849cc87a8b709ffe835d08de17625dc" + "cygwin": + "gcc": + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/PC_Cygwin_GCC_64bit/packages/cspice.tar.gz" + sha256: "78ca611638653e1b86347d2b58d8bc761c256e5d0037314fcb7c3eedb3e981bd" + "SunOs": + "sun-cc": + "sparc": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/SunSPARC_Solaris_SunC_32bit/packages/cspice.tar.Z" + sha256: "382d6bc51312c0af8b52d6995c255a5af468551bb04c79fb2e6171dc10de95f3" + "sparcv9": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/SunSPARC_Solaris_SunC_64bit/packages/cspice.tar.Z" + sha256: "f2510faccdcfeb4ed75ed3fc377059629ae090c29e7d22189e0933e9a905143b" + "gcc": + "sparc": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/SunSPARC_Solaris_GCC_32bit/packages/cspice.tar.Z" + sha256: "b26c645d11b12f906c4283202d630c114710288531f2dfc118721b81de25722f" + "sparcv9": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0067/C/SunSPARC_Solaris_GCC_64bit/packages/cspice.tar.Z" + sha256: "b0936d1ef0973fcdbd2b204faacd128059d8a656d73e4f276dfc6709d8080eee" "0066": - url: - "Macos": - "apple-clang": - "x86": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/MacIntel_OSX_AppleC_32bit/packages/cspice.tar.Z" - "x86_64": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/MacIntel_OSX_AppleC_64bit/packages/cspice.tar.Z" - "Linux": - "gcc": - "x86": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Linux_GCC_32bit/packages/cspice.tar.Z" - "x86_64": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Linux_GCC_64bit/packages/cspice.tar.Z" - "Windows": - "Visual Studio": - "x86": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Windows_VisualC_32bit/packages/cspice.zip" - "x86_64": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Windows_VisualC_64bit/packages/cspice.zip" - "cygwin": - "gcc": - "x86": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Cygwin_GCC_32bit/packages/cspice.tar.gz" - "x86_64": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Cygwin_GCC_64bit/packages/cspice.tar.gz" - "SunOs": - "sun-cc": - "x86": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunIntel_Solaris_SunC_32bit/packages/cspice.tar.Z" - "x86_64": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunIntel_Solaris_SunC_64bit/packages/cspice.tar.Z" - "sparc": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_SunC_32bit/packages/cspice.tar.Z" - "sparcv9": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_SunC_64bit/packages/cspice.tar.Z" - "gcc": - "sparc": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_GCC_32bit/packages/cspice.tar.Z" - "sparcv9": "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_GCC_64bit/packages/cspice.tar.Z" - sha256: - "Macos": - "apple-clang": - "x86": "9a4b5f674ea76821c43aa9140829da4091de646ef3ce40fd5be1d09d7c37b6b3" - "x86_64": "f5d48c4b0d558c5d71e8bf6fcdf135b0943210c1ff91f8191dfc447419a6b12e" - "Linux": - "gcc": - "x86": "59f5a2e865ff8dee3e415477fe55cf366bad5498948bf7b034ee00b46ec80720" - "x86_64": "93cd4fbce5818f8b7fecf3914c5756b8d41fd5bdaaeac1f4037b5a5410bc4768" - "Windows": - "Visual Studio": - "x86": "db48e5beddc0e50f7a0224bb2c6f2b39fc38f84628ad5cd455e847fc70aa5e75" - "x86_64": "b29dfb0b41ae8322c60ee9d162beb97433d21e12843ecbe03d819e5edef45920" - "cygwin": - "gcc": - "x86": "fae1e81f2b120801078415ddc78069543792b2ecf6f01e2ddd4f9d1fdff6d705" - "x86_64": "bc41bd496c98b5b26c03e2eb1235a2ab3ee3d6b54452155722c0163ebec52c09" - "SunOs": - "sun-cc": - "x86": "2779be0a8cce3a342fd77d118c53689344979de01a4185f8ff727f85502f116e" - "x86_64": "b221eb598e4397acf957b0464694a62c92871671be9fe9c32ac64d621b1eb29d" - "sparc": "1432f49f628930b48197bcf4e9234ed7a340732302c82fd6d0650d15fe8503f8" - "sparcv9": "be27fa91fefa9f54e90578a7c84e9e16d19b0ce6420eb346340ecf8d26db1b5f" - "gcc": - "sparc": "463c93a54f432fa41e1733bc4ec0e584f1017f48f84e0e9fafe4adc4163064c9" - "sparcv9": "4e86fad7e8fa947abddd3d78174efc65476a3f54627747ffc2027ee572af48b3" + "Macos": + "apple-clang": + "x86": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/MacIntel_OSX_AppleC_32bit/packages/cspice.tar.Z" + sha256: "9a4b5f674ea76821c43aa9140829da4091de646ef3ce40fd5be1d09d7c37b6b3" + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/MacIntel_OSX_AppleC_64bit/packages/cspice.tar.Z" + sha256: "f5d48c4b0d558c5d71e8bf6fcdf135b0943210c1ff91f8191dfc447419a6b12e" + "Linux": + "gcc": + "x86": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Linux_GCC_32bit/packages/cspice.tar.Z" + sha256: "59f5a2e865ff8dee3e415477fe55cf366bad5498948bf7b034ee00b46ec80720" + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Linux_GCC_64bit/packages/cspice.tar.Z" + sha256: "93cd4fbce5818f8b7fecf3914c5756b8d41fd5bdaaeac1f4037b5a5410bc4768" + "Windows": + "Visual Studio": + "x86": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Windows_VisualC_32bit/packages/cspice.zip" + sha256: "db48e5beddc0e50f7a0224bb2c6f2b39fc38f84628ad5cd455e847fc70aa5e75" + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Windows_VisualC_64bit/packages/cspice.zip" + sha256: "b29dfb0b41ae8322c60ee9d162beb97433d21e12843ecbe03d819e5edef45920" + "msvc": + "x86": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Windows_VisualC_32bit/packages/cspice.zip" + sha256: "db48e5beddc0e50f7a0224bb2c6f2b39fc38f84628ad5cd455e847fc70aa5e75" + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Windows_VisualC_64bit/packages/cspice.zip" + sha256: "b29dfb0b41ae8322c60ee9d162beb97433d21e12843ecbe03d819e5edef45920" + "cygwin": + "gcc": + "x86": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Cygwin_GCC_32bit/packages/cspice.tar.gz" + sha256: "fae1e81f2b120801078415ddc78069543792b2ecf6f01e2ddd4f9d1fdff6d705" + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Cygwin_GCC_64bit/packages/cspice.tar.gz" + sha256: "bc41bd496c98b5b26c03e2eb1235a2ab3ee3d6b54452155722c0163ebec52c09" + "SunOs": + "sun-cc": + "x86": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunIntel_Solaris_SunC_32bit/packages/cspice.tar.Z" + sha256: "2779be0a8cce3a342fd77d118c53689344979de01a4185f8ff727f85502f116e" + "x86_64": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunIntel_Solaris_SunC_64bit/packages/cspice.tar.Z" + sha256: "b221eb598e4397acf957b0464694a62c92871671be9fe9c32ac64d621b1eb29d" + "sparc": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_SunC_32bit/packages/cspice.tar.Z" + sha256: "1432f49f628930b48197bcf4e9234ed7a340732302c82fd6d0650d15fe8503f8" + "sparcv9": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_SunC_64bit/packages/cspice.tar.Z" + sha256: "be27fa91fefa9f54e90578a7c84e9e16d19b0ce6420eb346340ecf8d26db1b5f" + "gcc": + "sparc": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_GCC_32bit/packages/cspice.tar.Z" + sha256: "463c93a54f432fa41e1733bc4ec0e584f1017f48f84e0e9fafe4adc4163064c9" + "sparcv9": + url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_GCC_64bit/packages/cspice.tar.Z" + sha256: "4e86fad7e8fa947abddd3d78174efc65476a3f54627747ffc2027ee572af48b3" patches: + "0067": + - patch_file: "patches/isatty.patch" "0066": - patch_file: "patches/isatty.patch" - base_path: "source_subfolder" - - patch_file: "patches/patches20171106.patch" # from https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066_patches - base_path: "source_subfolder" + - patch_file: "patches/patches20171106.patch" + patch_type: "backport" + patch_source: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066_patches" diff --git a/recipes/cspice/all/conanfile.py b/recipes/cspice/all/conanfile.py index 29b8dbb11406f..4d9de47239cb0 100644 --- a/recipes/cspice/all/conanfile.py +++ b/recipes/cspice/all/conanfile.py @@ -1,34 +1,36 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, chdir, copy, download, get, load, rename, rmdir, save import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.47.0" + class CspiceConan(ConanFile): name = "cspice" description = "NASA C SPICE library" license = "TSPA" - topics = ("conan", "spice", "naif", "kernels", "space", "nasa", "jpl", "spacecraft", "planet", "robotics") + topics = ("spice", "naif", "kernels", "space", "nasa", "jpl", "spacecraft", "planet", "robotics") homepage = "https://naif.jpl.nasa.gov/naif/toolkit.html" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "utilities": [True, False] + "utilities": [True, False], } default_options = { "shared": False, "fPIC": True, - "utilities": True + "utilities": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -37,21 +39,32 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - self._raise_if_not_supported_triplet() - - def _raise_if_not_supported_triplet(self): - sources_url_per_triplet = self.conan_data["sources"][self.version]["url"] - the_os = self._get_os_or_subsystem() - if the_os not in sources_url_per_triplet: - raise ConanInvalidConfiguration("cspice does not support {0}".format(the_os)) - compiler = str(self.settings.compiler) - if compiler not in sources_url_per_triplet[the_os]: - raise ConanInvalidConfiguration("cspice does not support {0} on {1}".format(compiler, the_os)) - arch = str(self.settings.arch) - if arch not in sources_url_per_triplet[the_os][compiler]: - raise ConanInvalidConfiguration("cspice does not support {0} on {1} {2}".format(compiler, the_os, arch)) + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def validate(self): + sources_url_per_triplet = self.conan_data["sources"][self.version] + host_os = self._get_os_or_subsystem() + if host_os not in sources_url_per_triplet: + raise ConanInvalidConfiguration( + f"cspice N{self.version} does not support {host_os}", + ) + compiler = str(self.info.settings.compiler) + if compiler not in sources_url_per_triplet[host_os]: + raise ConanInvalidConfiguration( + f"cspice N{self.version} does not support {compiler} on {host_os}", + ) + arch = str(self.info.settings.arch) + if arch not in sources_url_per_triplet[host_os][compiler]: + raise ConanInvalidConfiguration( + f"cspice N{self.version} does not support {compiler} on {host_os} {arch}", + ) def _get_os_or_subsystem(self): if self.settings.os == "Windows" and self.settings.os.subsystem != "None": @@ -60,47 +73,53 @@ def _get_os_or_subsystem(self): os_or_subsystem = str(self.settings.os) return os_or_subsystem + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): pass - def build(self): - self._get_sources() - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() - cmake.build() + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CSPICE_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["CSPICE_BUILD_UTILITIES"] = self.options.utilities + tc.generate() + + @property + def _parent_source_folder(self): + return os.path.join(self.source_folder, os.pardir) def _get_sources(self): - the_os = self._get_os_or_subsystem() - compiler = str(self.settings.compiler) - arch = str(self.settings.arch) - url = self.conan_data["sources"][self.version]["url"][the_os][compiler][arch] - sha256 = self.conan_data["sources"][self.version]["sha256"][the_os][compiler][arch] - if url.endswith(".tar.Z"): # Python doesn't have any module to uncompress .Z files - filename = os.path.basename(url) - tools.download(url, filename, sha256=sha256) - command = "zcat {} | tar -xf -".format(filename) - self.run(command=command) - os.remove(filename) - else: - tools.get(url, sha256=sha256) - os.rename(self.name, self._source_subfolder) + with chdir(self, self._parent_source_folder): + host_os = self._get_os_or_subsystem() + compiler = str(self.settings.compiler) + arch = str(self.settings.arch) + data = self.conan_data["sources"][self.version][host_os][compiler][arch] + url = data["url"] + if url.endswith(".tar.Z"): # Python doesn't have any module to uncompress .Z files + tarball = os.path.basename(url) + download(self, url, tarball, sha256=data["sha256"]) + self.run(f"zcat {tarball} | tar -xf -") + os.remove(tarball) + else: + get(self, **data) + rmdir(self, self.source_folder) + rename(self, "cspice", os.path.basename(self.source_folder)) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_UTILITIES"] = self.options.utilities - self._cmake.configure() - return self._cmake + def build(self): + self._get_sources() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=self._parent_source_folder) + cmake.build() def package(self): - tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license()) - cmake = self._configure_cmake() + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license()) + cmake = CMake(self) cmake.install() def _extract_license(self): - spiceusr_header = tools.load(os.path.join(self._source_subfolder, "include", "SpiceUsr.h")) + spiceusr_header = load(self, os.path.join(self.source_folder, "include", "SpiceUsr.h")) begin = spiceusr_header.find("-Disclaimer") end = spiceusr_header.find("-Required_Reading", begin) return spiceusr_header[begin:end] @@ -112,5 +131,5 @@ def package_info(self): if self.options.utilities: bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.output.info(f"Appending PATH environment variable: {bin_path}") self.env_info.PATH.append(bin_path) diff --git a/recipes/cspice/all/test_package/CMakeLists.txt b/recipes/cspice/all/test_package/CMakeLists.txt index 7b9b613cbb24a..19e72e03db2a8 100644 --- a/recipes/cspice/all/test_package/CMakeLists.txt +++ b/recipes/cspice/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cspice REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE cspice::cspice) diff --git a/recipes/cspice/all/test_package/conanfile.py b/recipes/cspice/all/test_package/conanfile.py index ea57a464900be..d120a992c06a6 100644 --- a/recipes/cspice/all/test_package/conanfile.py +++ b/recipes/cspice/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cspice/all/test_v1_package/CMakeLists.txt b/recipes/cspice/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a8e7e9f7503eb --- /dev/null +++ b/recipes/cspice/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cspice REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE cspice::cspice) diff --git a/recipes/cspice/all/test_v1_package/conanfile.py b/recipes/cspice/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cspice/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cspice/config.yml b/recipes/cspice/config.yml index 4d3b13e170a14..2624f80e58dbf 100644 --- a/recipes/cspice/config.yml +++ b/recipes/cspice/config.yml @@ -1,3 +1,5 @@ versions: + "0067": + folder: all "0066": folder: all diff --git a/recipes/csvmonkey/all/conandata.yml b/recipes/csvmonkey/all/conandata.yml new file mode 100644 index 0000000000000..299ceba354465 --- /dev/null +++ b/recipes/csvmonkey/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.0.5": + url: "https://github.com/dw/csvmonkey/archive/594ad9854b7a77ccb8e26260b1e1a4300ba18465.tar.gz" + sha256: "89db5c3cdee4e6d59945edbca054695d9ee2d1150c92a26282c0e35f041729ac" diff --git a/recipes/csvmonkey/all/conanfile.py b/recipes/csvmonkey/all/conanfile.py new file mode 100644 index 0000000000000..70c4748ec7036 --- /dev/null +++ b/recipes/csvmonkey/all/conanfile.py @@ -0,0 +1,56 @@ +import os + +from conan.errors import ConanInvalidConfiguration +from conan import ConanFile, tools + +required_conan_version = ">=1.43.0" + +class CSVMONEKYConan(ConanFile): + name = "csvmonkey" + license = "BSD-3-Clause" + url = "https://github.com/conan-io/conan-center-index" + description = "Header-only vectorized, lazy-decoding, zero-copy CSV file parser " + topics = ("csv-parser", "header-only", "vectorized") + homepage = "https://github.com/dw/csvmonkey/" + settings = "arch", "compiler" + no_copy_source = True + options = {"with_spirit": [True, False]} + default_options = {"with_spirit": False} + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.arch not in ("x86", "x86_64",): + raise ConanInvalidConfiguration("{} requires x86 architecture.".format(self.name)) + + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("{} doesn't support Visual Studio C++.".format(self.name)) + + def requirements(self): + if self.options.with_spirit: + self.requires("boost/1.77.0") + + def source(self): + tools.files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("LICENSE*", "licenses", self._source_subfolder) + self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) + + def package_id(self): + self.info.header_only() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "csvmonkey") + self.cpp_info.set_property("cmake_target_name", "csvmonkey::csvmonkey") + self.cpp_info.set_property("pkg_config_name", "csvmonkey") + + self.cpp_info.filenames["cmake_find_package"] = "csvmonkey" + self.cpp_info.filenames["cmake_find_package_multi"] = "csvmonkey" + self.cpp_info.names["cmake_find_package"] = "csvmonkey" + self.cpp_info.names["cmake_find_package_multi"] = "csvmonkey" + + if self.options.with_spirit: + self.cpp_info.defines.append("USE_SPIRIT") diff --git a/recipes/csvmonkey/all/test_package/CMakeLists.txt b/recipes/csvmonkey/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6f39b9addc9e6 --- /dev/null +++ b/recipes/csvmonkey/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(csvmonkey CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} csvmonkey::csvmonkey) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/csvmonkey/all/test_package/conanfile.py b/recipes/csvmonkey/all/test_package/conanfile.py new file mode 100644 index 0000000000000..69bc51936474f --- /dev/null +++ b/recipes/csvmonkey/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conan import ConanFile, tools +from conans import CMake + +class CSVMonkeyTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.build.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/csvmonkey/all/test_package/test_package.cpp b/recipes/csvmonkey/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..e1669a1c2b39e --- /dev/null +++ b/recipes/csvmonkey/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include "csvmonkey.hpp" + +int main() { + csvmonkey::MappedFileCursor stream{}; + + return 0; +} diff --git a/recipes/csvmonkey/config.yml b/recipes/csvmonkey/config.yml new file mode 100644 index 0000000000000..6506e357707be --- /dev/null +++ b/recipes/csvmonkey/config.yml @@ -0,0 +1,3 @@ +versions: + "0.0.5": + folder: all diff --git a/recipes/ctml/all/conandata.yml b/recipes/ctml/all/conandata.yml new file mode 100644 index 0000000000000..ba4b9057c6b96 --- /dev/null +++ b/recipes/ctml/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.0.0": + url: "https://github.com/tinfoilboy/CTML/archive/refs/tags/2.0.0.tar.gz" + sha256: "e13b3bb04903f47b90b286f8a4695232179e28474a0a33f1a3f333552338d132" diff --git a/recipes/ctml/all/conanfile.py b/recipes/ctml/all/conanfile.py new file mode 100644 index 0000000000000..b5c3dd7c38f7d --- /dev/null +++ b/recipes/ctml/all/conanfile.py @@ -0,0 +1,42 @@ +import os +from conans import ConanFile, tools + +required_conan_version = ">=1.43.0" + +class CtmlLibrariesConan(ConanFile): + name = "ctml" + description = "A C++ HTML document constructor only depending on the standard library." + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/tinfoilboy/CTML" + topics = ("generator", "html", ) + settings = "os", "arch", "compiler", "build_type", + generators = "cmake", + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def package_id(self): + self.info.header_only() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "11") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("LICENSE*", "licenses", self._source_subfolder) + self.copy("ctml.hpp", "include", os.path.join(self._source_subfolder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "CTML") + self.cpp_info.set_property("cmake_target_name", "CTML::CTML") + + self.cpp_info.filenames["cmake_find_package"] = "CTML" + self.cpp_info.filenames["cmake_find_package_multi"] = "CTML" + self.cpp_info.names["cmake_find_package"] = "CTML" + self.cpp_info.names["cmake_find_package_multi"] = "CTML" diff --git a/recipes/ctml/all/test_package/CMakeLists.txt b/recipes/ctml/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..1df60de830867 --- /dev/null +++ b/recipes/ctml/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CTML CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} CTML::CTML) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/ctml/all/test_package/conanfile.py b/recipes/ctml/all/test_package/conanfile.py new file mode 100644 index 0000000000000..270a1ae971491 --- /dev/null +++ b/recipes/ctml/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, CMake, tools + +class TestWrapperConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ctml/all/test_package/test_package.cpp b/recipes/ctml/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..c7627f90fb776 --- /dev/null +++ b/recipes/ctml/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include + +#include "ctml.hpp" + +int main() { + CTML::Node node("div#first section#second article#third"); + + std::cout << node.ToString() << std::endl; + + return 0; +} diff --git a/recipes/ctml/config.yml b/recipes/ctml/config.yml new file mode 100644 index 0000000000000..d77ad03cbf510 --- /dev/null +++ b/recipes/ctml/config.yml @@ -0,0 +1,3 @@ +versions: + "2.0.0": + folder: all diff --git a/recipes/ctpg/all/conandata.yml b/recipes/ctpg/all/conandata.yml new file mode 100644 index 0000000000000..e352628a7b1dd --- /dev/null +++ b/recipes/ctpg/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "1.3.7": + url: "https://github.com/peter-winter/ctpg/archive/refs/tags/v1.3.7.tar.gz" + sha256: "6cc7c34de4983e21070599fd5693b65ef08cd5c8f42612e43b47eda723623429" + "1.3.6": + url: "https://github.com/peter-winter/ctpg/archive/refs/tags/v1.3.6.tar.gz" + sha256: "8ad5e06ab551fe30ff10faf6b53b85c862a873e3827505d5f5b63aae2b836ba2" + "1.3.5": + url: "https://github.com/peter-winter/ctpg/archive/refs/tags/v1.3.5.tar.gz" + sha256: "6874e71aecace33a07dd202c5c6c53277653d54daa13b460f4e1eb5b0c902d42" diff --git a/recipes/ctpg/all/conanfile.py b/recipes/ctpg/all/conanfile.py new file mode 100644 index 0000000000000..bd69eefe8c5a2 --- /dev/null +++ b/recipes/ctpg/all/conanfile.py @@ -0,0 +1,59 @@ +from conans.errors import ConanInvalidConfiguration +from conans import ConanFile, tools +import os + +required_conan_version = ">=1.33.0" + +class CTPGConan(ConanFile): + name = "ctpg" + license = "MIT" + description = ( + "Compile Time Parser Generator is a C++ single header library which takes a language description as a C++ code " + "and turns it into a LR1 table parser with a deterministic finite automaton lexical analyzer, all in compile time." + ) + topics = ("regex", "parser", "grammar", "compile-time") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/peter-winter/ctpg" + settings = "compiler", + no_copy_source = True + + _compiler_required_cpp17 = { + "Visual Studio": "16", + "gcc": "8", + "clang": "12", + "apple-clang": "12.0", + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + ## TODO: In ctpg<=1.3.5, Visual Studio C++ failed to compile ctpg with "error MSB6006: "CL.exe" exited with code -1073741571." + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("{} does not support Visual Studio currently.".format(self.name)) + + if self.settings.get_safe("compiler.cppstd"): + tools.check_min_cppstd(self, "17") + + minimum_version = self._compiler_required_cpp17.get(str(self.settings.compiler), False) + if minimum_version: + if tools.Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration("{} requires C++17, which your compiler does not support.".format(self.name)) + else: + self.output.warn("{} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name)) + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("LICENSE*", "licenses", self._source_subfolder) + if tools.Version(self.version) >= "1.3.7": + self.copy("ctpg.hpp", + os.path.join("include", "ctpg"), + os.path.join(self._source_subfolder, "include", "ctpg")) + else: + self.copy("ctpg.hpp", "include", os.path.join(self._source_subfolder, "include")) diff --git a/recipes/ctpg/all/test_package/CMakeLists.txt b/recipes/ctpg/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b09bb90b2f88d --- /dev/null +++ b/recipes/ctpg/all/test_package/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ctpg CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ctpg::ctpg) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) +if(CTPG_PLACED_CPTG_FOLDER) + target_compile_definitions(${PROJECT_NAME} PUBLIC CTPG_PLACED_CPTG_FOLDER) +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + target_compile_options(${PROJECT_NAME} PUBLIC -constexpr:depth3000000) + target_compile_options(${PROJECT_NAME} PUBLIC -constexpr:steps3000000) +endif() diff --git a/recipes/ctpg/all/test_package/conanfile.py b/recipes/ctpg/all/test_package/conanfile.py new file mode 100644 index 0000000000000..34c01340114ef --- /dev/null +++ b/recipes/ctpg/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["CTPG_PLACED_CPTG_FOLDER"] = tools.Version(self.deps_cpp_info["ctpg"].version) >= "1.3.7" + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ctpg/all/test_package/test_package.cpp b/recipes/ctpg/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..bcd377f23cbd8 --- /dev/null +++ b/recipes/ctpg/all/test_package/test_package.cpp @@ -0,0 +1,37 @@ +#ifdef CTPG_PLACED_CPTG_FOLDER +# include "ctpg/ctpg.hpp" +#else +# include "ctpg.hpp" +#endif + +#include + +constexpr ctpg::nterm list("list"); +constexpr char number_pattern[] = "[1-9][0-9]*"; +constexpr ctpg::regex_term number("number"); + +int to_int(std::string_view sv) { + int i = 0; + for (auto c : sv) { + i = i * 10 + (c - '0'); + } + return i; +} + +constexpr ctpg::parser p( + list, + terms(',', number), + nterms(list), + rules( + list(number) >= to_int, + list(list, ',', number) >= [](int sum, char, const auto& n){ return sum + to_int(n); } + ) +); + +int main(int argc, char* argv[]) { + auto res = p.parse(ctpg::buffers::string_buffer("10, 20, 30"), std::cerr); + bool success = res.has_value(); + if (success) + std::cout << res.value() << std::endl; + return success ? 0 : -1; +} diff --git a/recipes/ctpg/config.yml b/recipes/ctpg/config.yml new file mode 100644 index 0000000000000..3da45bc778250 --- /dev/null +++ b/recipes/ctpg/config.yml @@ -0,0 +1,7 @@ +versions: + "1.3.7": + folder: all + "1.3.6": + folder: all + "1.3.5": + folder: all diff --git a/recipes/ctre/all/conandata.yml b/recipes/ctre/all/conandata.yml index 05c0521cc6e7c..b82c82a8db15a 100644 --- a/recipes/ctre/all/conandata.yml +++ b/recipes/ctre/all/conandata.yml @@ -1,7 +1,4 @@ sources: - "2.8.2": - url: https://github.com/hanickadot/compile-time-regular-expressions/archive/v2.8.2.tar.gz - sha256: f89494f52ec31e5854fff3d2c5825474201476636c5d82a9365dad5188396314 "2.8.4": url: https://github.com/hanickadot/compile-time-regular-expressions/archive/v2.8.4.tar.gz sha256: 99b981857f1b66cab5e71161ae74deca268ed39a96ec6507def92d4f445cadd6 @@ -20,12 +17,21 @@ sources: "3.2": url: https://github.com/hanickadot/compile-time-regular-expressions/archive/v3.2.tar.gz sha256: d4e734e3dd501f741424aceb5198f5ebbc35c624335c99f7e202a9ecb31cd3e6 - "3.3.2": - url: https://github.com/hanickadot/compile-time-regular-expressions/archive/v3.3.2.tar.gz - sha256: adb1b52ed58ffd5631f37564bb0baf5fd8716dad640970d31c8093943a0e7486 "3.3.4": url: "https://github.com/hanickadot/compile-time-regular-expressions/archive/v3.3.4.tar.gz" sha256: "8161f0d3100fc690590f475aa9acb70163ed7f2922e35e13136dececc52c49a9" "3.4.1": url: "https://github.com/hanickadot/compile-time-regular-expressions/archive/v3.4.1.tar.gz" sha256: "c4a1a88b8c4a8c267507a3da3707f29a2b7c1f722e27d695296f152501a414ab" + "3.5": + url: "https://github.com/hanickadot/compile-time-regular-expressions/archive/v3.5.tar.gz" + sha256: "94b5cbf90057b252119e9a0ce459e3b488decb98e57163b00a6c7c494cd0761e" + "3.6": + url: "https://github.com/hanickadot/compile-time-regular-expressions/archive/v3.6.tar.gz" + sha256: "82633af08edff556f1401e1cf247e44eeef50f0588202731fddab183e9fda6d0" + "3.7": + url: "https://github.com/hanickadot/compile-time-regular-expressions/archive/v3.7.tar.gz" + sha256: "12be2a37f7fe39c489f646d3faee534f965871fd998258162962f36a19a455ef" + "3.7.1": + url: "https://github.com/hanickadot/compile-time-regular-expressions/archive/v3.7.1.tar.gz" + sha256: "d00d7eaa0e22f2fdaa947a532b81b6fc35880acf4887b50a5ac9bfb7411ced03" diff --git a/recipes/ctre/all/conanfile.py b/recipes/ctre/all/conanfile.py index fce0e7216a8b2..f98178ac4b67c 100644 --- a/recipes/ctre/all/conanfile.py +++ b/recipes/ctre/all/conanfile.py @@ -1,6 +1,9 @@ import os from conans import ConanFile, tools from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc + +required_conan_version = ">=1.33.0" class CtreConan(ConanFile): name = "ctre" @@ -12,38 +15,43 @@ class CtreConan(ConanFile): no_copy_source = True settings = "compiler" - _source_name = "compile-time-regular-expressions" - _source_subfolder = "source_subfolder" + @property + def _source_subfolder(self): + return "source_subfolder" - def _validate_compiler_settings(self): - # See: https://github.com/hanickadot/compile-time-regular-expressions#supported-compilers + def validate(self): compiler = self.settings.compiler - version = tools.Version(self.settings.compiler.version) + compiler_version = tools.Version(self.settings.compiler.version) + ctre_version = tools.Version(self.version) - min_gcc = "7.4" if self.version < "3" else "8" + min_gcc = "7.4" if ctre_version < "3" else "8" if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, "17") - if compiler == "Visual Studio" and version < "15": - raise ConanInvalidConfiguration("ctre doesn't support MSVC < 15") - elif compiler == "gcc" and version < min_gcc: - raise ConanInvalidConfiguration("ctre doesn't support gcc < {}".format(min_gcc)) - elif compiler == "clang" and version < "6.0": - raise ConanInvalidConfiguration("ctre doesn't support clang < 6.0") - elif compiler == "apple-clang" and version < "10.0": - raise ConanInvalidConfiguration("ctre doesn't support Apple clang < 10.0") - - def configure(self): - self._validate_compiler_settings() + if is_msvc(self): + if compiler_version < "15": + raise ConanInvalidConfiguration("{}/{} doesn't support MSVC < 15".format(self.name, self.version)) + if ctre_version >= "3.7" and compiler_version < 16: + raise ConanInvalidConfiguration("{}/{} doesn't support MSVC < 16".format(self.name, self.version)) + elif compiler == "gcc" and compiler_version < min_gcc: + raise ConanInvalidConfiguration("{}/{} doesn't support gcc < {}".format(self.name, self.version, min_gcc)) + elif compiler == "clang" and compiler_version < "6.0": + raise ConanInvalidConfiguration("{}/{} doesn't support clang < 6.0".format(self.name, self.version)) + elif compiler == "apple-clang": + if compiler_version < "10.0": + raise ConanInvalidConfiguration("{}/{} doesn't support Apple clang < 10.0".format(self.name, self.version)) + # "library does not compile with (at least) Xcode 12.0-12.4" + # https://github.com/hanickadot/compile-time-regular-expressions/issues/188 + # it's also occurred in Xcode 13. + if ctre_version.major == "3" and ctre_version.minor == "4" and compiler_version >= "12": + raise ConanInvalidConfiguration("{}/{} doesn't support Apple clang".format(self.name, self.version)) + + def package_id(self): + self.info.header_only() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self._source_name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def package(self): self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - def package_id(self): - self.info.header_only() - diff --git a/recipes/ctre/all/test_package/CMakeLists.txt b/recipes/ctre/all/test_package/CMakeLists.txt index bb747275da78e..b2fb1f2436ed0 100644 --- a/recipes/ctre/all/test_package/CMakeLists.txt +++ b/recipes/ctre/all/test_package/CMakeLists.txt @@ -1,11 +1,12 @@ -cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) -set_property(TARGET example PROPERTY CXX_STANDARD 17) -set_property(TARGET example PROPERTY CXX_STANDARD_REQUIRED ON) +find_package(ctre CONFIG REQUIRED) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ctre::ctre) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) diff --git a/recipes/ctre/all/test_package/conanfile.py b/recipes/ctre/all/test_package/conanfile.py index 7f1c3ec509593..38f44a943c8f6 100644 --- a/recipes/ctre/all/test_package/conanfile.py +++ b/recipes/ctre/all/test_package/conanfile.py @@ -2,8 +2,8 @@ from conans import ConanFile, CMake, tools class CtreTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -11,6 +11,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/ctre/all/test_package/example.cpp b/recipes/ctre/all/test_package/test_package.cpp similarity index 100% rename from recipes/ctre/all/test_package/example.cpp rename to recipes/ctre/all/test_package/test_package.cpp diff --git a/recipes/ctre/config.yml b/recipes/ctre/config.yml index ee88139a875a3..6b59866d3b987 100644 --- a/recipes/ctre/config.yml +++ b/recipes/ctre/config.yml @@ -1,6 +1,4 @@ versions: - "2.8.2": - folder: all "2.8.4": folder: all "2.9.2": @@ -13,9 +11,15 @@ versions: folder: all "3.2": folder: all - "3.3.2": - folder: all "3.3.4": folder: all "3.4.1": folder: all + "3.5": + folder: all + "3.6": + folder: all + "3.7": + folder: all + "3.7.1": + folder: all diff --git a/recipes/cubicinterpolation/all/CMakeLists.txt b/recipes/cubicinterpolation/all/CMakeLists.txt new file mode 100644 index 0000000000000..0ed622c3eb5d7 --- /dev/null +++ b/recipes/cubicinterpolation/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATH) + +add_subdirectory("source_subfolder") diff --git a/recipes/cubicinterpolation/all/conandata.yml b/recipes/cubicinterpolation/all/conandata.yml index 2d29d875af145..21963599ee1f4 100644 --- a/recipes/cubicinterpolation/all/conandata.yml +++ b/recipes/cubicinterpolation/all/conandata.yml @@ -1,7 +1,17 @@ sources: + "0.1.5": + url: "https://github.com/MaxSac/cubic_interpolation/archive/v0.1.5.tar.gz" + sha256: "fc34de15c9dd9e651728c9e0eee5528ee9636e41a3d8aa6f41735018810afd59" + "0.1.4": + url: "https://github.com/MaxSac/cubic_interpolation/archive/v0.1.4.tar.gz" + sha256: "38bb8fe46b19b135bfcba79e098c5d90284f0bc02f42f86118aefcb63aed7668" "0.1.3": url: "https://github.com/MaxSac/cubic_interpolation/archive/v0.1.3.tar.gz" sha256: "3151d99ecbbddd4e57605ff1919bdf234d08336b47d369b9dc562acff780aaf7" +patches: "0.1.4": - url: "https://github.com/MaxSac/cubic_interpolation/archive/v0.1.4.tar.gz" - sha256: "38bb8fe46b19b135bfcba79e098c5d90284f0bc02f42f86118aefcb63aed7668" + - patch_file: "patches/patch_conanbuildinfo.txt" + base_path: "source_subfolder" + "0.1.3": + - patch_file: "patches/patch_conanbuildinfo.txt" + base_path: "source_subfolder" diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index 2d3560c8fde51..5ab5b03d47a69 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -2,7 +2,7 @@ from conans.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.43.0" class CubicInterpolationConan(ConanFile): @@ -12,24 +12,28 @@ class CubicInterpolationConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" description = "Leightweight interpolation library based on boost and eigen." topics = ("interpolation", "splines", "cubic", "bicubic", "boost", "eigen3") - - settings = "os", "compiler", "build_type", "arch" + exports_sources = ["CMakeLists.txt", "patches/**"] + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], } default_options = { "shared": False, - "fPIC": True + "fPIC": True, } - generators = "cmake" + generators = "cmake", "cmake_find_package" _cmake = None @property def _source_subfolder(self): return "source_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -39,6 +43,7 @@ def configure(self): del self.options.fPIC def requirements(self): + # TODO: update boost dependency as soon as issue #11207 is fixed self.requires("boost/1.75.0") self.requires("eigen/3.3.9") @@ -60,7 +65,7 @@ def validate(self): if self.options["boost"].header_only or miss_boost_required_comp: raise ConanInvalidConfiguration("{0} requires non header-only boost with these components: {1}".format(self.name, ", ".join(self._required_boost_components))) - if self.settings.compiler.cppstd: + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, "14") minimum_version = self._minimum_compilers_version.get( @@ -75,13 +80,12 @@ def validate(self): "CubicInterpolation requires C++14, which your compiler does not support." ) - if self.settings.compiler == "Visual Studio" and self.options.shared: + if self._is_msvc and self.options.shared: raise ConanInvalidConfiguration("cubicinterpolation shared is not supported with Visual Studio") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "cubic_interpolation-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -89,10 +93,13 @@ def _configure_cmake(self): self._cmake = CMake(self) self._cmake.definitions["BUILD_EXAMPLE"] = False self._cmake.definitions["BUILD_DOCUMENTATION"] = False - self._cmake.configure(source_folder=self._source_subfolder) + self._cmake.configure() return self._cmake def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() cmake.build() @@ -103,7 +110,11 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "CubicInterpolation" - self.cpp_info.names["cmake_find_package_multi"] = "CubicInterpolation" + self.cpp_info.set_property("cmake_file_name", "CubicInterpolation") + self.cpp_info.set_property("cmake_target_name", "CubicInterpolation::CubicInterpolation") self.cpp_info.libs = ["CubicInterpolation"] self.cpp_info.requires = ["boost::headers", "boost::filesystem", "boost::math", "boost::serialization", "eigen::eigen"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "CubicInterpolation" + self.cpp_info.names["cmake_find_package_multi"] = "CubicInterpolation" diff --git a/recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.txt b/recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.txt new file mode 100644 index 0000000000000..614a14be9b7ed --- /dev/null +++ b/recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.txt @@ -0,0 +1,11 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 0199a76..1b0a2b4 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -46,6 +46,3 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CubicInterpolationConfig.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CubicInterpolation + ) +- +-install(FILES "${PROJECT_BINARY_DIR}/conanbuildinfo.cmake" +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CubicInterpolation) diff --git a/recipes/cubicinterpolation/all/test_package/conanfile.py b/recipes/cubicinterpolation/all/test_package/conanfile.py index 46bc45f7741b8..38f4483872d47 100644 --- a/recipes/cubicinterpolation/all/test_package/conanfile.py +++ b/recipes/cubicinterpolation/all/test_package/conanfile.py @@ -2,8 +2,8 @@ import os -class CubicInterpolationTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/cubicinterpolation/config.yml b/recipes/cubicinterpolation/config.yml index 7766a332b561a..5185d65a2df90 100644 --- a/recipes/cubicinterpolation/config.yml +++ b/recipes/cubicinterpolation/config.yml @@ -1,5 +1,7 @@ versions: - "0.1.3": - folder: all + "0.1.5": + folder: all "0.1.4": folder: all + "0.1.3": + folder: all diff --git a/recipes/cuda-kat/all/conandata.yml b/recipes/cuda-kat/all/conandata.yml new file mode 100644 index 0000000000000..1e1d88dea820e --- /dev/null +++ b/recipes/cuda-kat/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.2": + url: "https://github.com/eyalroz/cuda-kat/archive/refs/tags/v0.2.tar.gz" + sha256: "1d5fc1172663f1db0e98d000ea0b1ab4c033a974090024559199954fd1c6b63f" diff --git a/recipes/cuda-kat/all/conanfile.py b/recipes/cuda-kat/all/conanfile.py new file mode 100644 index 0000000000000..dfc221ba485b8 --- /dev/null +++ b/recipes/cuda-kat/all/conanfile.py @@ -0,0 +1,54 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + +class CudaKatConan(ConanFile): + name = "cuda-kat" + homepage = "https://github.com/eyalroz/cuda-kat" + description = "CUDA kernel author's tools" + topics = ("gpgpu", "cuda", "cuda-kat", "header-only") + url = "https://github.com/conan-io/conan-center-index" + no_copy_source = True + license = "BSD-3-Clause" + + settings = "os", "arch", "compiler", "build_type" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def package_id(self): + self.info.header_only() + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "15", + "clang": "5", + "apple-clang": "10", + } + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("CUDA-kat library are not compatible on Windows") + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 17) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if not minimum_version: + self.output.warn(f"{self.name} requires C++17. Your compiler is unknown. Assuming it supports C++17.") + elif tools.Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.name} requires a compiler that supports at least C++17") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy(pattern="LICENSE*", src=self._source_subfolder, dst="licenses") + self.copy("*", src=os.path.join(self._source_subfolder, "src"), dst="include") + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "cuda-kat" + self.cpp_info.names["cmake_find_package_multi"] = "cuda-kat" diff --git a/recipes/cuda-kat/all/test_package/CMakeLists.txt b/recipes/cuda-kat/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a6fd14216f176 --- /dev/null +++ b/recipes/cuda-kat/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cuda-kat REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} cuda-kat::cuda-kat) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17) diff --git a/recipes/cuda-kat/all/test_package/conanfile.py b/recipes/cuda-kat/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/cuda-kat/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cuda-kat/all/test_package/test_package.cpp b/recipes/cuda-kat/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..b8d25e32f26c1 --- /dev/null +++ b/recipes/cuda-kat/all/test_package/test_package.cpp @@ -0,0 +1,13 @@ +#include +#include + + +int main() { + auto t = kat::tuple{1}; + static_assert(kat::tuple_size>::value == 1, "tuple_size> test failed."); + if ( kat::get<0>(t) != 1 ) + { throw std::logic_error{""}; } + + return 0; +} + diff --git a/recipes/cuda-kat/config.yml b/recipes/cuda-kat/config.yml new file mode 100644 index 0000000000000..7e65100e62b2c --- /dev/null +++ b/recipes/cuda-kat/config.yml @@ -0,0 +1,3 @@ +versions: + "0.2": + folder: all diff --git a/recipes/cunit/all/conanfile.py b/recipes/cunit/all/conanfile.py index aed9df32771d7..a7c3f16aa1cdc 100644 --- a/recipes/cunit/all/conanfile.py +++ b/recipes/cunit/all/conanfile.py @@ -3,6 +3,8 @@ import glob import os +required_conan_version = ">=1.33.0" + class CunitConan(ConanFile): name = "cunit" @@ -50,27 +52,34 @@ def requirements(self): if self.options.with_curses == "ncurses": self.requires("ncurses/6.2") + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") self.build_requires("libtool/2.4.6") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("CUnit-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) with tools.chdir(self._source_subfolder): for f in glob.glob("*.c"): os.chmod(f, 0o644) + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + @contextmanager def _build_context(self): env = {} if self.settings.compiler == "Visual Studio": with tools.vcvars(self.settings): env.update({ - "AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), - "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), "NM": "dumpbin -symbols", "OBJDUMP": ":", "RANLIB": ":", @@ -82,13 +91,16 @@ def _build_context(self): with tools.environment_append(env): yield - def _configure_autools(self): + def _configure_autotools(self): if self._autotools: return self._autotools self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) self._autotools.libs = [] + host, build = None, None if self.settings.compiler == "Visual Studio": self._autotools.flags.append("-FS") + # MSVC canonical names aren't understood + host, build = False, False conf_args = [ "--datarootdir={}".format(os.path.join(self.package_folder, "bin", "share").replace("\\", "/")), "--enable-debug" if self.settings.build_type == "Debug" else "--disable-debug", @@ -101,7 +113,7 @@ def _configure_autools(self): conf_args.extend(["--enable-shared", "--disable-static"]) else: conf_args.extend(["--disable-shared", "--enable-static"]) - self._autotools.configure(args=conf_args) + self._autotools.configure(args=conf_args, host=host, build=build) return self._autotools def build(self): @@ -109,18 +121,22 @@ def build(self): tools.patch(**patch) with self._build_context(): with tools.chdir(self._source_subfolder): - self.run("autoreconf -fiv".format(os.environ["AUTORECONF"]), win_bash=tools.os_info.is_windows) - autotools = self._configure_autools() + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + autotools = self._configure_autotools() autotools.make() def package(self): self.copy("COPYING", src=self._source_subfolder, dst="licenses") with self._build_context(): with tools.chdir(self._source_subfolder): - autotools = self._configure_autools() + autotools = self._configure_autotools() autotools.install() - os.unlink(os.path.join(self.package_folder, "lib", "libcunit.la")) + if self.settings.compiler == "Visual Studio" and self.options.shared: + tools.rename(os.path.join(self.package_folder, "lib", "cunit.dll.lib"), + os.path.join(self.package_folder, "lib", "cunit.lib")) + + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") tools.rmdir(os.path.join(self.package_folder, "bin", "share", "man")) tools.rmdir(os.path.join(self.package_folder, "doc")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) @@ -128,9 +144,6 @@ def package(self): def package_info(self): self.cpp_info.names["cmake_find_package"] = "CUnit" self.cpp_info.names["cmake_find_package_multi"] = "CUnit" - libname = "cunit" - if self.settings.os == "Windows" and self.options.shared: - libname += ".dll" + (".lib" if self.settings.compiler == "Visual Studio" else ".a") - self.cpp_info.libs = [libname] + self.cpp_info.libs = ["cunit"] if self.settings.os == "Windows" and self.options.shared: self.cpp_info.defines.append("CU_DLL") diff --git a/recipes/cunit/all/test_package/conanfile.py b/recipes/cunit/all/test_package/conanfile.py index bd7165a553cf4..d4128b0450777 100644 --- a/recipes/cunit/all/test_package/conanfile.py +++ b/recipes/cunit/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/cvplot/all/conandata.yml b/recipes/cvplot/all/conandata.yml new file mode 100644 index 0000000000000..9079421334b14 --- /dev/null +++ b/recipes/cvplot/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.2.2": + url: "https://github.com/Profactor/cv-plot/archive/refs/tags/v1.2.2.tar.gz" + sha256: "a7dbc80a8ec13fa2cfdc4f1389a1eb0cb83b56f021c64214d733812d3e301bc5" diff --git a/recipes/cvplot/all/conanfile.py b/recipes/cvplot/all/conanfile.py new file mode 100644 index 0000000000000..49ceaeafa285e --- /dev/null +++ b/recipes/cvplot/all/conanfile.py @@ -0,0 +1,35 @@ +from conans import ConanFile, tools +import os + +required_conan_version = ">=1.43.0" + + +class CvPlotConan(ConanFile): + name = "cvplot" + description = "fast modular opencv plotting library" + license = "MIT" + topics = ("plot", "opencv", "diagram", "plotting") + homepage = "https://github.com/Profactor/cv-plot" + url = "https://github.com/conan-io/conan-center-index" + requires = "opencv/4.5.3" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "CvPlot", "inc")) + + def package_id(self): + self.info.header_only() + + def package_info(self): + self.cpp_info.defines.append("CVPLOT_HEADER_ONLY") + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.names["cmake_find_package"] = "CvPlot" + self.cpp_info.names["cmake_find_package_multi"] = "CvPlot" diff --git a/recipes/cvplot/all/test_package/CMakeLists.txt b/recipes/cvplot/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b75c35da97dea --- /dev/null +++ b/recipes/cvplot/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CvPlot CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} CvPlot::CvPlot) + +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) diff --git a/recipes/cvplot/all/test_package/conanfile.py b/recipes/cvplot/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/cvplot/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cvplot/all/test_package/test_package.cpp b/recipes/cvplot/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..0592129b4a676 --- /dev/null +++ b/recipes/cvplot/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include + +using namespace CvPlot; + +int main() { + Axes axes = plot(std::vector{ 3, 3, 4, 6, 4, 3 }, "-o"); + cv::Mat mat = axes.render(400, 600); + return 0; +} diff --git a/recipes/cvplot/config.yml b/recipes/cvplot/config.yml new file mode 100644 index 0000000000000..af40d9653a378 --- /dev/null +++ b/recipes/cvplot/config.yml @@ -0,0 +1,3 @@ +versions: + "1.2.2": + folder: all diff --git a/recipes/cwalk/all/CMakeLists.txt b/recipes/cwalk/all/CMakeLists.txt deleted file mode 100644 index 42d6e7408fb33..0000000000000 --- a/recipes/cwalk/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.9.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/cwalk/all/conandata.yml b/recipes/cwalk/all/conandata.yml index 0903b164f538c..89588e33be62f 100644 --- a/recipes/cwalk/all/conandata.yml +++ b/recipes/cwalk/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.2.7": + url: "https://github.com/likle/cwalk/archive/v1.2.7.tar.gz" + sha256: "ae424ec30830c970412e34d9092eaa6131d91af289cdad0ad66a7b1c58e768e7" + "1.2.6": + url: "https://github.com/likle/cwalk/archive/v1.2.6.tar.gz" + sha256: "4e7c0e9e30e93343ebc9d5dc3ffc1703b3abb05baf8d8a3ab05a75b69a65a3ef" "1.2.5": url: "https://github.com/likle/cwalk/archive/v1.2.5.tar.gz" sha256: "55a24deb602a7bee822e48bda50e454d102649a8cb064300a6dabc8f0405646f" @@ -11,3 +17,16 @@ sources: "1.0.0": url: "https://github.com/likle/cwalk/archive/v1.0.0.zip" sha256: "9ff6d85f88e7fe4877698afb40745d301491c1d3fca96f08d1622f5fe3494182" +patches: + "1.2.7": + - patch_file: "patches/0001-fix-cmake-1.2.5.patch" + "1.2.6": + - patch_file: "patches/0001-fix-cmake-1.2.5.patch" + "1.2.5": + - patch_file: "patches/0001-fix-cmake-1.2.5.patch" + "1.2.2": + - patch_file: "patches/0001-fix-cmake-1.2.2.patch" + "1.1.0": + - patch_file: "patches/0001-fix-cmake-1.1.0.patch" + "1.0.0": + - patch_file: "patches/0001-fix-cmake-1.0.0.patch" diff --git a/recipes/cwalk/all/conanfile.py b/recipes/cwalk/all/conanfile.py index 920aceb638b7e..fa74a668f51fa 100644 --- a/recipes/cwalk/all/conanfile.py +++ b/recipes/cwalk/all/conanfile.py @@ -1,5 +1,11 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir, save +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools +import textwrap + +required_conan_version = ">=1.47.0" class CwalkConan(ConanFile): @@ -13,52 +19,92 @@ class CwalkConan(ConanFile): topics = ("cwalk", "cross-platform", "windows", "macos", "osx", "linux", "path-manipulation", "path", "directory", "file", "file-system", "unc", "path-parsing", "file-path") - exports_sources = ["CMakeLists.txt"] - generators = "cmake" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {'shared': False, 'fPIC': True} - - @property - def _source_subfolder(self): - return "source_subfolder" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() def build(self): + apply_conandata_patches(self) cmake = CMake(self) - cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = self.options.shared and self.settings.os == "Windows" - cmake.configure(build_folder=self._build_subfolder) - cmake.build(target="cwalk") + cmake.configure() + cmake.build() def package(self): - include_dir = os.path.join(self._source_subfolder, 'include') - lib_dir = os.path.join(self._build_subfolder, "lib") - bin_dir = os.path.join(self._build_subfolder, "bin") - - self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) - self.copy("cwalk.h", dst="include", src=include_dir) - self.copy(pattern="*.a", dst="lib", src=lib_dir, keep_path=False) - self.copy(pattern="*.lib", dst="lib", src=lib_dir, keep_path=False) - self.copy(pattern="*.dylib", dst="lib", src=lib_dir, keep_path=False) - self.copy(pattern="*.so*", dst="lib", src=lib_dir, keep_path=False, - symlinks=True) - self.copy(pattern="*.dll", dst="bin", src=bin_dir, keep_path=False) + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"cwalk": "cwalk::cwalk"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "Cwalk") + self.cpp_info.set_property("cmake_target_name", "cwalk") + self.cpp_info.libs = ["cwalk"] + if self.options.shared and Version(self.version) >= "1.2.5": + self.cpp_info.defines.append("CWK_SHARED") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "Cwalk" + self.cpp_info.filenames["cmake_find_package_multi"] = "Cwalk" + self.cpp_info.names["cmake_find_package"] = "cwalk" + self.cpp_info.names["cmake_find_package_multi"] = "cwalk" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/cwalk/all/patches/0001-fix-cmake-1.0.0.patch b/recipes/cwalk/all/patches/0001-fix-cmake-1.0.0.patch new file mode 100644 index 0000000000000..c50f13017cfde --- /dev/null +++ b/recipes/cwalk/all/patches/0001-fix-cmake-1.0.0.patch @@ -0,0 +1,29 @@ +Fixes: +* export symbols if shared msvc +* add install target +* disable tests and warnings as errors + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -41,7 +41,16 @@ add_library(${LIBRARY_TARGET} + "${INCLUDE_DIRECTORY}/cwalk.h" + "${SOURCE_DIRECTORY}/cwalk.c") + target_include_directories(${LIBRARY_TARGET} PUBLIC "${INCLUDE_DIRECTORY}") ++set_target_properties(${LIBRARY_TARGET} PROPERTIES ++ PUBLIC_HEADER "${INCLUDE_DIRECTORY}/cwalk.h" ++ WINDOWS_EXPORT_ALL_SYMBOLS TRUE) ++install(TARGETS ${LIBRARY_TARGET} ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++ PUBLIC_HEADER DESTINATION include) + ++if(0) # disable tests and warnings as errors + # add tests + enable_testing() + create_test(DEFAULT absolute simple) +@@ -152,3 +161,4 @@ target_include_directories(${TEST_TARGET} PUBLIC "${INCLUDE_DIRECTORY}") + + # enable warnings + enable_warnings(${LIBRARY_TARGET}) ++endif() diff --git a/recipes/cwalk/all/patches/0001-fix-cmake-1.1.0.patch b/recipes/cwalk/all/patches/0001-fix-cmake-1.1.0.patch new file mode 100644 index 0000000000000..13a9c7f66569c --- /dev/null +++ b/recipes/cwalk/all/patches/0001-fix-cmake-1.1.0.patch @@ -0,0 +1,29 @@ +Fixes: +* export symbols if shared msvc +* add install target +* disable tests and warnings as errors + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -41,7 +41,16 @@ add_library(${LIBRARY_TARGET} + "${INCLUDE_DIRECTORY}/cwalk.h" + "${SOURCE_DIRECTORY}/cwalk.c") + target_include_directories(${LIBRARY_TARGET} PUBLIC "${INCLUDE_DIRECTORY}") ++set_target_properties(${LIBRARY_TARGET} PROPERTIES ++ PUBLIC_HEADER "${INCLUDE_DIRECTORY}/cwalk.h" ++ WINDOWS_EXPORT_ALL_SYMBOLS TRUE) ++install(TARGETS ${LIBRARY_TARGET} ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++ PUBLIC_HEADER DESTINATION include) + ++if(0) # disable tests and warnings as errors + # add tests + enable_testing() + create_test(DEFAULT absolute simple) +@@ -198,3 +207,4 @@ target_include_directories(${TEST_TARGET} PUBLIC "${INCLUDE_DIRECTORY}") + + # enable warnings + enable_warnings(${LIBRARY_TARGET}) ++endif() diff --git a/recipes/cwalk/all/patches/0001-fix-cmake-1.2.2.patch b/recipes/cwalk/all/patches/0001-fix-cmake-1.2.2.patch new file mode 100644 index 0000000000000..ca014de0fa389 --- /dev/null +++ b/recipes/cwalk/all/patches/0001-fix-cmake-1.2.2.patch @@ -0,0 +1,29 @@ +Fixes: +* export symbols if shared msvc +* add install target +* disable tests and warnings as errors + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -40,7 +40,16 @@ add_library(${LIBRARY_TARGET} + "${INCLUDE_DIRECTORY}/cwalk.h" + "${SOURCE_DIRECTORY}/cwalk.c") + target_include_directories(${LIBRARY_TARGET} PUBLIC "${INCLUDE_DIRECTORY}") ++set_target_properties(${LIBRARY_TARGET} PROPERTIES ++ PUBLIC_HEADER "${INCLUDE_DIRECTORY}/cwalk.h" ++ WINDOWS_EXPORT_ALL_SYMBOLS TRUE) ++install(TARGETS ${LIBRARY_TARGET} ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++ PUBLIC_HEADER DESTINATION include) + ++if(0) # disable tests and warnings as errors + # add tests + enable_testing() + create_test(DEFAULT absolute simple) +@@ -234,3 +243,4 @@ target_include_directories(${TEST_TARGET} PUBLIC "${INCLUDE_DIRECTORY}") + + # enable warnings + enable_warnings(${LIBRARY_TARGET}) ++endif() diff --git a/recipes/cwalk/all/patches/0001-fix-cmake-1.2.5.patch b/recipes/cwalk/all/patches/0001-fix-cmake-1.2.5.patch new file mode 100644 index 0000000000000..a59d803cf814d --- /dev/null +++ b/recipes/cwalk/all/patches/0001-fix-cmake-1.2.5.patch @@ -0,0 +1,12 @@ +Do not enable warnings as errors + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -39,7 +39,6 @@ endif() + add_library(cwalk + "${INCLUDE_DIRECTORY}/cwalk.h" + "${SOURCE_DIRECTORY}/cwalk.c") +-enable_warnings(cwalk) + target_include_directories(cwalk PUBLIC + $ + $ diff --git a/recipes/cwalk/all/test_package/CMakeLists.txt b/recipes/cwalk/all/test_package/CMakeLists.txt index f6bb6f79f518f..873589b946c24 100644 --- a/recipes/cwalk/all/test_package/CMakeLists.txt +++ b/recipes/cwalk/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(Cwalk REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE cwalk) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_11) diff --git a/recipes/cwalk/all/test_package/conanfile.py b/recipes/cwalk/all/test_package/conanfile.py index 55762d557051d..3a8c6c5442b33 100644 --- a/recipes/cwalk/all/test_package/conanfile.py +++ b/recipes/cwalk/all/test_package/conanfile.py @@ -1,9 +1,18 @@ -from conans import ConanFile, CMake +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,5 +20,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cwalk/all/test_v1_package/CMakeLists.txt b/recipes/cwalk/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9e3af2e4fad4c --- /dev/null +++ b/recipes/cwalk/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Cwalk REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE cwalk) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_11) diff --git a/recipes/cwalk/all/test_v1_package/conanfile.py b/recipes/cwalk/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cwalk/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cwalk/config.yml b/recipes/cwalk/config.yml index bed65a4262a72..3a4a484ff7332 100644 --- a/recipes/cwalk/config.yml +++ b/recipes/cwalk/config.yml @@ -1,4 +1,8 @@ versions: + "1.2.7": + folder: all + "1.2.6": + folder: all "1.2.5": folder: all "1.2.2": diff --git a/recipes/cxxopts/all/conandata.yml b/recipes/cxxopts/all/conandata.yml index 1146f615b6d98..80d718f14d1a0 100644 --- a/recipes/cxxopts/all/conandata.yml +++ b/recipes/cxxopts/all/conandata.yml @@ -1,10 +1,13 @@ sources: - "1.4.4": - url: https://github.com/jarro2783/cxxopts/archive/v1.4.4.zip - sha256: 7c8ec885fcc58e10a8268b57ae04d5cbeac895d150d3a09c15605ff7ef05cf87 - "2.2.0": - url: https://github.com/jarro2783/cxxopts/archive/v2.2.0.zip - sha256: f9640c00d9938bedb291a21f9287902a3a8cee38db6910b905f8eba4a6416204 + "3.0.0": + url: "https://github.com/jarro2783/cxxopts/archive/refs/tags/v3.0.0.tar.gz" + sha256: "36f41fa2a46b3c1466613b63f3fa73dc24d912bc90d667147f1e43215a8c6d00" "2.2.1": - url: https://github.com/jarro2783/cxxopts/archive/v2.2.1.zip - sha256: 7021ce97f51a40f7fd3558da416ab6914b1d3f758ccf68a1e8734ad10b49b676 + url: "https://github.com/jarro2783/cxxopts/archive/refs/tags/v2.2.1.tar.gz" + sha256: "984aa3c8917d649b14d7f6277104ce38dd142ce378a9198ec926f03302399681" + "2.2.0": + url: "https://github.com/jarro2783/cxxopts/archive/refs/tags/v2.2.0.tar.gz" + sha256: "447dbfc2361fce9742c5d1c9cfb25731c977b405f9085a738fbd608626da8a4d" + "1.4.4": + url: "https://github.com/jarro2783/cxxopts/archive/refs/tags/v1.4.4.tar.gz" + sha256: "1d0eedb39ecbc64a0f82d8b6fe40d5c8e611501702969cfbd14a07ce6ddb8501" diff --git a/recipes/cxxopts/all/conanfile.py b/recipes/cxxopts/all/conanfile.py index 13008c4023106..c9aafdc057393 100644 --- a/recipes/cxxopts/all/conanfile.py +++ b/recipes/cxxopts/all/conanfile.py @@ -1,6 +1,12 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.51.1" class CxxOptsConan(ConanFile): @@ -9,18 +15,19 @@ class CxxOptsConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" description = "Lightweight C++ option parser library, supporting the standard GNU style syntax for options." license = "MIT" - topics = ("conan", "option-parser", "positional-arguments ", "header-only") - settings = "compiler" - options = { "unicode": [True, False] } - default_options = { "unicode": False } + topics = ("option-parser", "positional-arguments ", "header-only") + + settings = "os", "arch", "compiler", "build_type" + options = { + "unicode": [True, False], + } + default_options = { + "unicode": False, + } no_copy_source = True - - @property - def _source_subfolder(self): - return "source_subfolder" @property - def _minimum_cpp_standard(self): + def _min_cppstd(self): return 11 @property @@ -32,33 +39,41 @@ def _minimum_compilers_version(self): "apple-clang": "8", } - def configure(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._minimum_cpp_standard) - min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) - if not min_version: - self.output.warn("{} recipe lacks information about the {} compiler support.".format( - self.name, self.settings.compiler)) - else: - if tools.Version(self.settings.compiler.version) < min_version: - raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( - self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): if self.options.unicode: - self.requires("icu/64.2") + self.requires("icu/71.1") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if min_version and Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support", + ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("{}.hpp".format(self.name), dst="include", src=os.path.join(self._source_subfolder, "include")) + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "cxxopts.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "cxxopts") + self.cpp_info.set_property("cmake_target_name", "cxxopts::cxxopts") + self.cpp_info.set_property("pkg_config_name", "cxxopts") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] if self.options.unicode: self.cpp_info.defines = ["CXXOPTS_USE_UNICODE"] diff --git a/recipes/cxxopts/all/test_package/CMakeLists.txt b/recipes/cxxopts/all/test_package/CMakeLists.txt index 7f2172dfd2a9c..6f5decb20d62e 100644 --- a/recipes/cxxopts/all/test_package/CMakeLists.txt +++ b/recipes/cxxopts/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1.3) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +find_package(cxxopts REQUIRED CONFIG) -add_executable(${PROJECT_NAME} main.cpp) -target_link_libraries(${PROJECT_NAME} CONAN_PKG::cxxopts) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE cxxopts::cxxopts) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/cxxopts/all/test_package/conanfile.py b/recipes/cxxopts/all/test_package/conanfile.py index ba68078180bb3..284c7dbfedbea 100644 --- a/recipes/cxxopts/all/test_package/conanfile.py +++ b/recipes/cxxopts/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout from io import StringIO -from conans import ConanFile, CMake, tools +import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,13 +22,13 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if can_run(self): output = StringIO() - bin_path = os.path.join("bin", "test_package") - option_string = "-f 41 --bar baria --baz"; + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + option_string = "-f 41 --bar baria --baz" if self.options["cxxopts"].unicode: - option_string += " -q quxis"; - self.run("{} {}".format(bin_path, option_string), run_environment=True, output=output) + option_string += " -q quxis" + self.run(f"{bin_path} {option_string}", env="conanrun", output=output) output_lines = set(output.getvalue().splitlines()) expected_lines = {"foo:41", "bar:baria", "baz:1"} if self.options["cxxopts"].unicode: diff --git a/recipes/cxxopts/all/test_package/main.cpp b/recipes/cxxopts/all/test_package/test_package.cpp similarity index 100% rename from recipes/cxxopts/all/test_package/main.cpp rename to recipes/cxxopts/all/test_package/test_package.cpp diff --git a/recipes/cxxopts/all/test_v1_package/CMakeLists.txt b/recipes/cxxopts/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/cxxopts/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/cxxopts/all/test_v1_package/conanfile.py b/recipes/cxxopts/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c68398ab15a88 --- /dev/null +++ b/recipes/cxxopts/all/test_v1_package/conanfile.py @@ -0,0 +1,27 @@ +from conans import ConanFile, CMake, tools +from io import StringIO +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + output = StringIO() + bin_path = os.path.join("bin", "test_package") + option_string = "-f 41 --bar baria --baz" + if self.options["cxxopts"].unicode: + option_string += " -q quxis" + self.run(f"{bin_path} {option_string}", run_environment=True, output=output) + output_lines = set(output.getvalue().splitlines()) + expected_lines = {"foo:41", "bar:baria", "baz:1"} + if self.options["cxxopts"].unicode: + expected_lines.add("qux:quxis") + assert(expected_lines.issubset(output_lines)) diff --git a/recipes/cxxopts/config.yml b/recipes/cxxopts/config.yml index feaa84a163e3a..69689683a4346 100644 --- a/recipes/cxxopts/config.yml +++ b/recipes/cxxopts/config.yml @@ -1,7 +1,9 @@ versions: - "1.4.4": + "3.0.0": + folder: all + "2.2.1": folder: all "2.2.0": folder: all - "2.2.1": + "1.4.4": folder: all diff --git a/recipes/cyclonedds/all/conandata.yml b/recipes/cyclonedds/all/conandata.yml new file mode 100644 index 0000000000000..3842a2285af2b --- /dev/null +++ b/recipes/cyclonedds/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "0.10.2": + url: "https://github.com/eclipse-cyclonedds/cyclonedds/archive/refs/tags/0.10.2.tar.gz" + sha256: "BC84E137E0C8A055B8CD97FBEAFEC94E36DE1B0C2E88800896A82384FD867AE5" +patches: + "0.10.2": + - patch_file: "patches/0.10.2-0001-fix-find-iceoryx.patch" + patch_description: "Fix cmake find for iceoryx package" + patch_type: "conan" diff --git a/recipes/cyclonedds/all/conanfile.py b/recipes/cyclonedds/all/conanfile.py new file mode 100644 index 0000000000000..039c8d5f7e45d --- /dev/null +++ b/recipes/cyclonedds/all/conanfile.py @@ -0,0 +1,179 @@ +import os +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import files, build, scm +from conan.tools.microsoft import is_msvc +from conan.tools.cmake import CMakeToolchain, CMake, CMakeDeps, cmake_layout + +required_conan_version = ">=1.51.3" + +class CycloneDDSConan(ConanFile): + name = "cyclonedds" + license = "EPL-2.0" + homepage = "https://cyclonedds.io/" + url = "https://github.com/conan-io/conan-center-index" + description = "Eclipse Cyclone DDS - An implementation"\ + " of the OMG Data Distribution Service (DDS) specification" + topics = ("dds", "ipc", "ros", "middleware") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_ssl": [True, False], + "with_shm" : [True, False], + "enable_security" : [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "with_ssl": False, + "with_shm": False, + "enable_security": False + } + + short_paths = True + + @property + def _bin_package_folder(self): + return os.path.join(self.package_folder,"bin") + + @property + def _tmp_folder(self): + return os.path.join(self.package_folder,"tmp") + + @property + def _license_folder(self): + return os.path.join(self.package_folder,"licenses") + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "16.0", + "clang": "7", + "apple-clang": "10", + } + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + files.copy(self,patch["patch_file"],self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def requirements(self): + if self.options.with_shm: + self.requires("iceoryx/2.0.0") + if self.options.with_ssl: + self.requires("openssl/1.1.1q") + + def build_requirements(self): + self.tool_requires("cmake/3.21.7") + + def validate(self): + if self.options.enable_security and not self.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} currently do not support"\ + "static build and security on") + if self.info.settings.compiler.cppstd: + build.check_min_cppstd(self, 14) + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and scm.Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} is just tested with minimal version "\ + f"{minimum_version} of compiler {self.info.settings.compiler}.") + + def source(self): + files.get(self,**self.conan_data["sources"][self.version], strip_root=True, + destination=self.source_folder) + + def layout(self): + cmake_layout(self,src_folder="src") + + def generate(self): + + tc = CMakeToolchain(self) + # TODO : determine how to do in conan : + # - idlc is a code generator that is used as tool (and so not cross compiled) + # - other tools like ddsperf is cross compiled for target + # - maybe separate package like cyclonedds_idlc + tc.variables["BUILD_IDLC"] = False + tc.variables["BUILD_IDLC_TESTING"] = False + tc.variables["BUILD_DDSPERF"] = False + tc.variables["BUILD_IDLC_TESTING"] = False + # variables which effects build + tc.variables["ENABLE_SSL"] = self.options.with_ssl + tc.variables["ENABLE_SHM"] = self.options.with_shm + tc.variables["ENABLE_SECURITY"] = self.options.enable_security + tc.generate() + + cd = CMakeDeps(self) + cd.generate() + + def build(self): + files.apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + files.copy(self, "LICENSE", self.source_folder, self._license_folder) + files.rmdir(self, os.path.join(self.package_folder, "share")) + files.rmdir(self, os.path.join(self.package_folder, "lib","pkgconfig")) + files.rmdir(self, os.path.join(self.package_folder, "lib","cmake")) + + # cyclonedds copies multiple windows dlls to bin folder + # these must be removed and just keep ddsc.dll + if self.settings.os == "Windows": + if self.options.shared: + files.mkdir(self, self._tmp_folder) + files.copy(self, "ddsc.dll", self._bin_package_folder, self._tmp_folder) + files.rmdir(self, self._bin_package_folder) + if self.options.shared: + files.mkdir(self,self._bin_package_folder) + files.copy(self,"ddsc.dll",self._tmp_folder,self._bin_package_folder) + files.rmdir(self, self._tmp_folder) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "cyclonedds") + self.cpp_info.filenames["cmake_find_package"] = "cyclonedds" + self.cpp_info.filenames["cmake_find_package_multi"] = "cyclonedds" + self.cpp_info.names["cmake_find_package"] = "CycloneDDS" + self.cpp_info.names["cmake_find_package_multi"] = "CycloneDDS" + self.cpp_info.components["CycloneDDS"].names["cmake_find_package"] = "ddsc" + self.cpp_info.components["CycloneDDS"].names["cmake_find_package_multi"] = "ddsc" + self.cpp_info.components["CycloneDDS"].libs = ["ddsc"] + self.cpp_info.components["CycloneDDS"].set_property("cmake_target_name", + "CycloneDDS::ddsc") + requires = [] + if self.options.with_shm: + requires.append("iceoryx::iceoryx_binding_c") + if self.options.with_ssl: + requires.append("openssl::openssl") + self.cpp_info.components["CycloneDDS"].requires = requires + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["CycloneDDS"].system_libs = ["pthread"] + elif self.settings.os == "Windows": + self.cpp_info.components["CycloneDDS"].system_libs = [ + "Ws2_32", + "Dbghelp", + "Bcrypt", + "Iphlpapi" + ] diff --git a/recipes/cyclonedds/all/patches/0.10.2-0001-fix-find-iceoryx.patch b/recipes/cyclonedds/all/patches/0.10.2-0001-fix-find-iceoryx.patch new file mode 100644 index 0000000000000..228ee7dba0b01 --- /dev/null +++ b/recipes/cyclonedds/all/patches/0.10.2-0001-fix-find-iceoryx.patch @@ -0,0 +1,15 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index fa08094a..516806dd 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -55,8 +55,8 @@ if(ENABLE_SHM) + else() + set(iceoryx_required QUIET) + endif() +- find_package(iceoryx_binding_c ${iceoryx_required}) +- set(ENABLE_SHM ${iceoryx_binding_c_FOUND} CACHE STRING "" FORCE) ++ find_package(iceoryx ${iceoryx_required}) ++ set(ENABLE_SHM ${iceoryx_FOUND} CACHE STRING "" FORCE) + if(ENABLE_SHM AND APPLE) + get_filename_component(iceoryx_libdir "${ICEORYX_LIB}" DIRECTORY) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${iceoryx_libdir}") diff --git a/recipes/cyclonedds/all/test_package/CMakeLists.txt b/recipes/cyclonedds/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..9653148f924fa --- /dev/null +++ b/recipes/cyclonedds/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(cyclonedds REQUIRED CONFIG) + +add_executable(test_package test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE CycloneDDS::ddsc) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/cyclonedds/all/test_package/conanfile.py b/recipes/cyclonedds/all/test_package/conanfile.py new file mode 100644 index 0000000000000..422a7d5c03da2 --- /dev/null +++ b/recipes/cyclonedds/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +import os +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run + +class CycloneDDSTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cyclonedds/all/test_package/test_package.cpp b/recipes/cyclonedds/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..9966d58481774 --- /dev/null +++ b/recipes/cyclonedds/all/test_package/test_package.cpp @@ -0,0 +1,21 @@ + +#include +#include +#include +#include +#include +#include + +#include "dds/dds.h" + +int main() { + dds_entity_t participant; + dds_entity_t topic; + + /* Create a Participant. */ + participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL); + if (participant < 0) + DDS_FATAL("dds_create_participant: %s\n", dds_strretcode(-participant)); + + return EXIT_SUCCESS; +} diff --git a/recipes/cyclonedds/all/test_v1_package/CMakeLists.txt b/recipes/cyclonedds/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..aa258f41398f0 --- /dev/null +++ b/recipes/cyclonedds/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(cyclonedds CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE CycloneDDS::ddsc) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/cyclonedds/all/test_v1_package/conanfile.py b/recipes/cyclonedds/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..f7bf754d5a675 --- /dev/null +++ b/recipes/cyclonedds/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake +from conan.tools import build + +class CycloneDDSTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = ["cmake", "cmake_find_package_multi"] + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not build.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cyclonedds/config.yml b/recipes/cyclonedds/config.yml new file mode 100644 index 0000000000000..6c8041d964ef5 --- /dev/null +++ b/recipes/cyclonedds/config.yml @@ -0,0 +1,3 @@ +versions: + "0.10.2": + folder: all diff --git a/recipes/cyrus-sasl/all/conandata.yml b/recipes/cyrus-sasl/all/conandata.yml index b23ec93d1a513..0fe894820dcdf 100644 --- a/recipes/cyrus-sasl/all/conandata.yml +++ b/recipes/cyrus-sasl/all/conandata.yml @@ -1,4 +1,4 @@ sources: "2.1.27": url: "https://github.com/cyrusimap/cyrus-sasl/releases/download/cyrus-sasl-2.1.27/cyrus-sasl-2.1.27.tar.gz" - sha256: 26866b1549b00ffd020f188a43c258017fa1c382b3ddadd8201536f72efb05d5 + sha256: "26866b1549b00ffd020f188a43c258017fa1c382b3ddadd8201536f72efb05d5" diff --git a/recipes/cyrus-sasl/all/conanfile.py b/recipes/cyrus-sasl/all/conanfile.py index a1a65dd7691ee..03e66247f9633 100644 --- a/recipes/cyrus-sasl/all/conanfile.py +++ b/recipes/cyrus-sasl/all/conanfile.py @@ -1,8 +1,14 @@ -import glob +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import copy, get, replace_in_file, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import unix_path import os -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.53.0" class CyrusSaslConan(ConanFile): @@ -15,9 +21,9 @@ class CyrusSaslConan(ConanFile): "It can be used on the client or server side " "to provide authentication and authorization services." ) + topics = ("sasl", "authentication", "authorization") - topics = ("SASL", "authentication", "authorization") - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -50,150 +56,124 @@ class CyrusSaslConan(ConanFile): "with_mysql": False, "with_sqlite3": False, } - exports_sources = ("patches/**",) - _autotools = None @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd if self.options.shared: - del self.options.fPIC - if self.settings.os == "Windows": - raise ConanInvalidConfiguration( - "Cyrus SASL package is not compatible with Windows yet." - ) + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): if self.options.with_openssl: - self.requires("openssl/1.1.1i") + self.requires("openssl/1.1.1s") if self.options.with_postgresql: - self.requires("libpq/13.1") + self.requires("libpq/14.5") if self.options.with_mysql: - self.requires("libmysqlclient/8.0.17") + self.requires("libmysqlclient/8.0.30") if self.options.with_sqlite3: - self.requires("sqlite3/3.34.0") + self.requires("sqlite3/3.39.4") + + def validate(self): + if self.info.settings.os == "Windows": + raise ConanInvalidConfiguration( + "Cyrus SASL package is not compatible with Windows yet." + ) if self.options.with_gssapi: - raise ConanInvalidConfiguration("with_gssapi requires krb5 recipe, not yet available in CCI") - self.requires("krb5/1.18.3") + raise ConanInvalidConfiguration( + f"{self.name}:with_gssapi=True requires krb5 recipe, not yet available in conan-center", + ) + + def build_requirements(self): + self.tool_requires("gnu-config/cci.20210814") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - downloaded_folder_name = "{}-{}".format(self.name, self.version) - os.rename(downloaded_folder_name, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + yes_no = lambda v: "yes" if v else "no" + rootpath_no = lambda v, req: unix_path(self, self.dependencies[req].package_folder) if v else "no" + tc.configure_args.extend([ + "--disable-sample", + "--disable-macos-framework", + "--with-dblib=none", + "--with-openssl={}".format(yes_no(self.options.with_openssl)), + "--enable-digest={}".format(yes_no(self.options.with_digest)), + "--enable-scram={}".format(yes_no(self.options.with_scram)), + "--enable-otp={}".format(yes_no(self.options.with_otp)), + "--enable-krb4={}".format(yes_no(self.options.with_krb4)), + "--enable-gssapi={}".format(yes_no(self.options.with_gssapi)), + "--enable-plain={}".format(yes_no(self.options.with_plain)), + "--enable-anon={}".format(yes_no(self.options.with_anon)), + "--enable-sql={}".format( + yes_no(self.options.with_postgresql or self.options.with_mysql or self.options.with_sqlite3), + ), + "--with-pgsql={}".format(rootpath_no(self.options.with_postgresql, "libpq")), + "--with-mysql={}".format(rootpath_no(self.options.with_mysql, "libmysqlclient")), + "--without-sqlite", + "--with-sqlite3={}".format(rootpath_no(self.options.with_sqlite3, "sqlite3")), + ]) + if self.options.with_gssapi: + tc.configure_args.append("--with-gss_impl=mit") + tc.generate() - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + deps = AutotoolsDeps(self) + deps.generate() + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") - def _configure_autotools(self): - if self._autotools is None: - self._autotools = AutoToolsBuildEnvironment( - self, win_bash=tools.os_info.is_windows - ) - configure_args = [ - "--disable-sample", - "--disable-macos-framework", - "--with-dblib=none", - ] - if self.options.shared: - configure_args.extend(["--enable-shared", "--disable-static"]) - else: - configure_args.extend(["--disable-shared", "--enable-static"]) - - if not self.options.with_openssl: - configure_args.append("--without-openssl") - - if not self.options.with_digest: - configure_args.append("--disable-digest") - - if not self.options.with_scram: - configure_args.append("--disable-scram") - - if not self.options.with_otp: - configure_args.append("--disable-otp") - - if not self.options.with_krb4: - configure_args.append("--disable-krb4") - - if self.options.with_gssapi: - configure_args.append("--with-gss_impl=mit") - else: - configure_args.append("--disable-gssapi") - - if not self.options.with_plain: - configure_args.append("--disable-plain") - - if not self.options.with_anon: - configure_args.append("--disable-anon") - - if ( - self.options.with_postgresql - or self.options.with_mysql - or self.options.with_sqlite3 - ): - configure_args.append("--enable-sql") - if self.options.with_postgresql: - configure_args.append( - "--with-pgsql={}".format(self.deps_cpp_info["libpq"].rootpath) - ) - else: - configure_args.append("--with-pgsql=no") - if self.options.with_mysql: - configure_args.append( - "--with-mysql={}".format( - self.deps_cpp_info["libmysqlclient"].rootpath - ) - ) - else: - configure_args.append("--with-mysql=no") - configure_args.append("--with-sqlite=no") - if self.options.with_mysql: - configure_args.append( - "--with-sqlite3={}".format( - self.deps_cpp_info["libmysqlclient"].rootpath - ) - ) - else: - configure_args.append("--with-sqlite3=no") - else: - configure_args.append("--disable-sql") - - configure_file_path = os.path.join(self._source_subfolder) - self._autotools.configure( - configure_dir=configure_file_path, args=configure_args - ) - return self._autotools + def _patch_sources(self): + for gnu_config in [ + self.conf.get("user.gnu-config:config_guess", check_type=str), + self.conf.get("user.gnu-config:config_sub", check_type=str), + ]: + if gnu_config: + copy(self, os.path.basename(gnu_config), + src=os.path.dirname(gnu_config), + dst=os.path.join(self.source_folder, "config")) + # relocatable executable & shared libs on macOS + replace_in_file(self, os.path.join(self.source_folder, "configure"), "-install_name \\$rpath/", "-install_name @rpath/") def build(self): self._patch_sources() - autotools = self._configure_autotools() + autotools = Autotools(self) + autotools.configure() autotools.make() def package(self): - self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses") - autotools = self._configure_autotools() - autotools.install() - - self._remove_la() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - - def _remove_la(self): - la_exp = os.path.join(self.package_folder, "lib", "**", "*.la") - for la_file in glob.glob(la_exp, recursive=True): - os.remove(la_file) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) def package_info(self): - self.cpp_info.names["pkg_config"] = "libsasl2" + self.cpp_info.set_property("pkg_config_name", "libsasl2") self.cpp_info.libs = ["sasl2"] + + # TODO: to remove in conan v2 bindir = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.output.info(f"Appending PATH environment variable: {bindir}") self.env_info.PATH.append(bindir) diff --git a/recipes/cyrus-sasl/all/test_package/CMakeLists.txt b/recipes/cyrus-sasl/all/test_package/CMakeLists.txt index e794a99c2ca03..b50bb405e7050 100644 --- a/recipes/cyrus-sasl/all/test_package/CMakeLists.txt +++ b/recipes/cyrus-sasl/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(cyrus-sasl REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE cyrus-sasl::cyrus-sasl) diff --git a/recipes/cyrus-sasl/all/test_package/conanfile.py b/recipes/cyrus-sasl/all/test_package/conanfile.py index 9bcd2b3211d95..0a6bc68712d90 100644 --- a/recipes/cyrus-sasl/all/test_package/conanfile.py +++ b/recipes/cyrus-sasl/all/test_package/conanfile.py @@ -1,11 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import CMake, ConanFile, tools +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" -class CyrusSaslTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -13,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "PackageTest") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cyrus-sasl/all/test_package/test.cpp b/recipes/cyrus-sasl/all/test_package/test.cpp deleted file mode 100644 index 43978bd41267e..0000000000000 --- a/recipes/cyrus-sasl/all/test_package/test.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -int main(int argc, char *argv[]) -{ - const char *implementation, *version; - sasl_version_info(&implementation, &version, NULL, NULL, NULL, NULL); - std::cout << std::endl - << "--------------------------->Tests are done.<--------------------------" << std::endl - << "SASL Using implementation: " << implementation << ", version: " << version << std::endl - << "//////////////////////////////////////////////////////////////////////" << std::endl; - return 0; -} diff --git a/recipes/cyrus-sasl/all/test_package/test_package.c b/recipes/cyrus-sasl/all/test_package/test_package.c new file mode 100644 index 0000000000000..8851f184023fd --- /dev/null +++ b/recipes/cyrus-sasl/all/test_package/test_package.c @@ -0,0 +1,13 @@ +#include + +#include + +int main(int argc, char *argv[]) +{ + const char *implementation, *version; + sasl_version_info(&implementation, &version, NULL, NULL, NULL, NULL); + printf("--------------------------->Tests are done.<--------------------------\n"); + printf("SASL Using implementation: %s, version: %s\n", implementation, version); + printf("//////////////////////////////////////////////////////////////////////\n"); + return 0; +} diff --git a/recipes/cyrus-sasl/all/test_v1_package/CMakeLists.txt b/recipes/cyrus-sasl/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/cyrus-sasl/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/cyrus-sasl/all/test_v1_package/conanfile.py b/recipes/cyrus-sasl/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e0a85886fc12c --- /dev/null +++ b/recipes/cyrus-sasl/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import CMake, ConanFile, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/czmq/all/conanfile.py b/recipes/czmq/all/conanfile.py index 7830453bf157f..916303c3f9b24 100644 --- a/recipes/czmq/all/conanfile.py +++ b/recipes/czmq/all/conanfile.py @@ -1,15 +1,18 @@ -import os from conans import ConanFile, tools, CMake +import os +import textwrap + +required_conan_version = ">=1.43.0" class CzmqConan(ConanFile): name = "czmq" homepage = "https://github.com/zeromq/czmq" - description = "ZeroMQ is a community of projects focused on decentralized messaging and computing" - topics = ("conan", "zmq", "libzmq", "message-queue", "asynchronous") + description = "High-level C binding for ZeroMQ" + topics = ("zmq", "libzmq", "message-queue", "asynchronous") url = "https://github.com/conan-io/conan-center-index" license = "MPL-2.0" - exports_sources = "CMakeLists.txt", "patches/**" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -25,35 +28,50 @@ class CzmqConan(ConanFile): "with_lz4": True, "with_libuuid": True, } - generators = "cmake" + generators = "cmake" _cmake = None - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC # libuuid is not available on Windows - del self.options.with_uuid + del self.options.with_libuuid def configure(self): if self.options.shared: del self.options.fPIC def requirements(self): - self.requires("openssl/1.1.1g") # zdigest depends on openssl - self.requires("zeromq/4.3.2") + self.requires("openssl/1.1.1m") # zdigest depends on openssl + self.requires("zeromq/4.3.4") if self.options.with_libcurl: - self.requires("libcurl/7.71.1") + self.requires("libcurl/7.80.0") if self.options.with_lz4: - self.requires("lz4/1.9.2") + self.requires("lz4/1.9.3") if self.options.get_safe("with_libuuid"): - self.requires("libuuid/1.0.3") + self.requires("libuuid/1.0.3") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("czmq-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -65,7 +83,7 @@ def _configure_cmake(self): return self._cmake def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) def build(self): @@ -77,32 +95,54 @@ def package(self): self.copy(pattern="LICENSE", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "CMake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) tools.rmdir(os.path.join(self.package_folder, "share")) + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {self._czmq_target: "czmq::czmq"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + + @property + def _czmq_target(self): + return "czmq" if self.options.shared else "czmq-static" + def package_info(self): - # TODO: CMake imported target shouldn't be namespaced - self.cpp_info.names["pkg_config"] = "libczmq" - czmq_target = "czmq" if self.options.shared else "czmq-static" - self.cpp_info.components["libczmq"].names["cmake_find_package"] = czmq_target - self.cpp_info.components["libczmq"].names["cmake_find_package_multi"] = czmq_target - if self.settings.compiler == "Visual Studio": - self.cpp_info.components["libczmq"].libs = ["czmq" if self.options.shared else "libczmq"] - self.cpp_info.components["libczmq"].system_libs.append("rpcrt4") - else: - self.cpp_info.components["libczmq"].libs = ["czmq"] - if self.settings.os == "Linux": - self.cpp_info.components["libczmq"].system_libs.extend(["pthread", "m"]) - if self.settings.os == "Windows": - self.cpp_info.components["libczmq"].system_libs.append("rpcrt4") + self.cpp_info.set_property("cmake_file_name", "czmq") + self.cpp_info.set_property("cmake_target_name", self._czmq_target) + self.cpp_info.set_property("pkg_config_name", "libczmq") + prefix = "lib" if self._is_msvc and not self.options.shared else "" + self.cpp_info.libs = ["{}czmq".format(prefix)] if not self.options.shared: - self.cpp_info.components["libczmq"].defines.append("CZMQ_STATIC") - self.cpp_info.components["libczmq"].requires = ["openssl::openssl", "zeromq::zeromq"] - if self.options.with_libcurl: - self.cpp_info.components["libczmq"].requires.append("libcurl::libcurl") - if self.options.with_lz4: - self.cpp_info.components["libczmq"].requires.append("lz4::lz4") - if self.options.get_safe("with_libuuid"): - self.cpp_info.components["libczmq"].requires.append("libuuid::libuuid") + self.cpp_info.defines.append("CZMQ_STATIC") + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["pthread", "m"]) + elif self.settings.os == "Windows": + self.cpp_info.system_libs.append("rpcrt4") + if not self.options.shared: + stdcpp_library = tools.stdcpp_library(self) + if stdcpp_library: + self.cpp_info.system_libs.append(stdcpp_library) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.names["pkg_config"] = "libczmq" diff --git a/recipes/czmq/all/test_package/CMakeLists.txt b/recipes/czmq/all/test_package/CMakeLists.txt index a570c463076c2..48b3bf1fe3b3f 100644 --- a/recipes/czmq/all/test_package/CMakeLists.txt +++ b/recipes/czmq/all/test_package/CMakeLists.txt @@ -2,18 +2,14 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(czmq REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -# TODO: remove czmq:: namespace when fixed in conanfile.py -if(CZMQ_SHARED) - target_link_libraries(${PROJECT_NAME} czmq::czmq) +target_compile_definitions(${PROJECT_NAME} PRIVATE $<$:"WITH_LIBSODIUM">) +if(TARGET czmq-static) + target_link_libraries(${PROJECT_NAME} czmq-static) else() - target_link_libraries(${PROJECT_NAME} czmq::czmq-static) -endif() - -if(WITH_LIBSODIUM) - target_compile_definitions(${PROJECT_NAME} PRIVATE "WITH_LIBSODIUM") + target_link_libraries(${PROJECT_NAME} czmq) endif() diff --git a/recipes/czmq/all/test_package/conanfile.py b/recipes/czmq/all/test_package/conanfile.py index c6f924f24929b..5eac88580e108 100644 --- a/recipes/czmq/all/test_package/conanfile.py +++ b/recipes/czmq/all/test_package/conanfile.py @@ -3,17 +3,16 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) cmake.definitions["WITH_LIBSODIUM"] = self.options["zeromq"].encryption == "libsodium" - cmake.definitions["CZMQ_SHARED"] = self.options["czmq"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/dacap-clip/all/conandata.yml b/recipes/dacap-clip/all/conandata.yml new file mode 100644 index 0000000000000..daa1ee060995e --- /dev/null +++ b/recipes/dacap-clip/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.5": + url: "https://github.com/dacap/clip/archive/refs/tags/v1.5.tar.gz" + sha256: "8f6f8a427075a09011fafbb75bfdbf1213e4492a13cff4a70975aab361c99382" diff --git a/recipes/dacap-clip/all/conanfile.py b/recipes/dacap-clip/all/conanfile.py new file mode 100644 index 0000000000000..e2bd672a9b3d1 --- /dev/null +++ b/recipes/dacap-clip/all/conanfile.py @@ -0,0 +1,114 @@ +import os + +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc +from conan.tools.apple import is_apple_os +from conan.tools.build import check_min_cppstd + +required_conan_version = ">=1.51.3" + +class DacapClipConan(ConanFile): + name = "dacap-clip" + description = "Cross-platform C++ library to copy/paste clipboard content" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/dacap/clip/" + topics = ("clipboard", "copy", "paste") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_png": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_png": True, + } + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + if self.settings.os not in ["Linux", "FreeBSD"]: + del self.options.with_png + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.get_safe("with_png", False): + self.requires("libpng/1.6.37") + if self.settings.os == "Linux": + self.requires("xorg/system") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + if is_msvc(self) and self.info.settings.build_type == "Debug" and self.info.options.shared == True: + raise ConanInvalidConfiguration(f"{self.ref} doesn't support MSVC debug shared build (now).") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self.source_folder) + + def generate(self): + toolchain = CMakeToolchain(self) + toolchain.variables["CLIP_EXAMPLES"] = False + toolchain.variables["CLIP_TESTS"] = False + toolchain.variables["CLIP_X11_WITH_PNG"] = self.options.get_safe("with_png", False) + if is_msvc(self): + toolchain.cache_variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = bool(self.options.shared) + toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "clip.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) + copy(self, "*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.so", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.dylib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["clip"] + + if self.options.get_safe("with_png", False): + self.cpp_info.requires.append("libpng::libpng") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.requires.append("xorg::xcb") + self.cpp_info.system_libs.append("pthread") + elif is_apple_os(self): + self.cpp_info.frameworks = ['Cocoa', 'Carbon', 'CoreFoundation', 'Foundation', 'AppKit'] + elif self.settings.os == "Windows": + self.cpp_info.system_libs.extend([ + "shlwapi", + "windowscodecs", + ]) + + self.cpp_info.set_property("cmake_file_name", "clip") + self.cpp_info.set_property("cmake_target_name", "clip::clip") + + # TODO: Remove on Conan 2.0 + self.cpp_info.names["cmake_find_package"] = "clip" + self.cpp_info.names["cmake_find_package_multi"] = "clip" diff --git a/recipes/dacap-clip/all/test_package/CMakeLists.txt b/recipes/dacap-clip/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..63e11b22a301b --- /dev/null +++ b/recipes/dacap-clip/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(clip REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} clip::clip) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/dacap-clip/all/test_package/conanfile.py b/recipes/dacap-clip/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5a673574d7a5b --- /dev/null +++ b/recipes/dacap-clip/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/dacap-clip/all/test_package/test_package.cpp b/recipes/dacap-clip/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..78ce3cdf1d299 --- /dev/null +++ b/recipes/dacap-clip/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include +#include "clip.h" + +int main() { + clip::set_text("Hello World"); + + std::string value; + clip::get_text(value); + std::cout << value << std::endl; + + return 0; +} diff --git a/recipes/dacap-clip/all/test_v1_package/CMakeLists.txt b/recipes/dacap-clip/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..784c43a27c83a --- /dev/null +++ b/recipes/dacap-clip/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include("${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(clip REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} clip::clip) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/dacap-clip/all/test_v1_package/conanfile.py b/recipes/dacap-clip/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e9bf8aa5f82dd --- /dev/null +++ b/recipes/dacap-clip/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +import os + +from conans import ConanFile, CMake +from conan.tools.build import cross_building + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/dacap-clip/config.yml b/recipes/dacap-clip/config.yml new file mode 100644 index 0000000000000..84f49b2850870 --- /dev/null +++ b/recipes/dacap-clip/config.yml @@ -0,0 +1,3 @@ +versions: + "1.5": + folder: "all" diff --git a/recipes/daggy/2.1/CMakeLists.txt b/recipes/daggy/2.1/CMakeLists.txt new file mode 100644 index 0000000000000..9cc5cb456e2f0 --- /dev/null +++ b/recipes/daggy/2.1/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.21.0) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +if (NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_subdirectory("source_subfolder/src") diff --git a/recipes/daggy/2.1/conandata.yml b/recipes/daggy/2.1/conandata.yml new file mode 100644 index 0000000000000..7f518b6c061d3 --- /dev/null +++ b/recipes/daggy/2.1/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.1.2": + sha256: d3b244fcb06cf5b749d19ca9d678aebbaa43a7e8c8208d99c15a58e140e49493 + url: https://github.com/synacker/daggy/archive/refs/tags/2.1.2.tar.gz diff --git a/recipes/daggy/2.1/conanfile.py b/recipes/daggy/2.1/conanfile.py new file mode 100644 index 0000000000000..6856d194c3bb9 --- /dev/null +++ b/recipes/daggy/2.1/conanfile.py @@ -0,0 +1,138 @@ +from conans import ConanFile, CMake, tools, errors +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.43.0" + + +class DaggyConan(ConanFile): + name = "daggy" + license = "MIT" + homepage = "https://daggy.dev" + url = "https://github.com/conan-io/conan-center-index" + description = "Data Aggregation Utility and C/C++ developer library for data streams catching" + topics = ("streaming", "qt", "monitoring", "process", "stream-processing", "extensible", "serverless-framework", "aggregation", "ssh2", "crossplatform", "ssh-client") + + settings = "os", "compiler", "build_type", "arch" + options = { + "with_ssh2": [True, False], + "with_yaml": [True, False], + "with_console": [True, False], + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "with_ssh2": True, + "with_yaml": True, + "with_console": False, + "shared": False, + "fPIC": True + } + generators = "cmake", "cmake_find_package" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _minimum_cpp_standard(self): + return 17 + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def build_requirements(self): + self.build_requires("cmake/3.21.3") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + self.options["qt"].shared = True + + def configure(self): + if self.options.shared: + del self.options.fPIC + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "gcc": "8", + "clang": "8", + "apple-clang": "10", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler)) + else: + if tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( + self.name, + self._minimum_cpp_standard, + self.settings.compiler, + self.settings.compiler.version)) + + if not self.options["qt"].shared: + raise ConanInvalidConfiguration("Shared Qt lib is required.") + + def requirements(self): + self.requires("qt/6.2.2") + self.requires("kainjow-mustache/4.1") + + if self.options.with_yaml: + self.requires("yaml-cpp/0.7.0") + + if self.options.with_ssh2: + self.requires("libssh2/1.10.0") + + def _configure(self): + if self._cmake: + return self._cmake + + self._cmake = CMake(self) + self._cmake.definitions["SSH2_SUPPORT"] = self.options.with_ssh2 + self._cmake.definitions["YAML_SUPPORT"] = self.options.with_yaml + self._cmake.definitions["CONSOLE"] = self.options.with_console + self._cmake.definitions["PACKAGE_DEPS"] = False + self._cmake.definitions["VERSION"] = self.version + self._cmake.definitions["CONAN_BUILD"] = True + self._cmake.definitions["BUILD_TESTING"] = False + + if self.options.shared: + self._cmake.definitions["CMAKE_C_VISIBILITY_PRESET"] = "hidden" + self._cmake.definitions["CMAKE_CXX_VISIBILITY_PRESET"] = "hidden" + self._cmake.definitions["CMAKE_VISIBILITY_INLINES_HIDDEN"] = 1 + self._cmake.configure() + return self._cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + cmake = self._configure() + cmake.build() + + def package(self): + cmake = self._configure() + cmake.install() + + self.copy("LICENSE", src=self._source_subfolder, dst="licenses", keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["DaggyCore"] + + + diff --git a/recipes/daggy/2.1/test_package/CMakeLists.txt b/recipes/daggy/2.1/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2be549c8044e6 --- /dev/null +++ b/recipes/daggy/2.1/test_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.21.0) +project(DaggyPackageTest) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(daggy REQUIRED) + +if (NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(testcpp test.cpp) +target_link_libraries(testcpp daggy::daggy) diff --git a/recipes/daggy/2.1/test_package/conanfile.py b/recipes/daggy/2.1/test_package/conanfile.py new file mode 100644 index 0000000000000..26810dfa0f7a5 --- /dev/null +++ b/recipes/daggy/2.1/test_package/conanfile.py @@ -0,0 +1,21 @@ +import os + +from conans import ConanFile, CMake, tools, RunEnvironment + + +class DaggyTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_paths", "cmake_find_package" + + def build_requirements(self): + self.build_requires("cmake/3.21.3") + + def build(self): + cmake = CMake(self) + + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "testcpp"), run_environment=True) diff --git a/recipes/daggy/2.1/test_package/test.cpp b/recipes/daggy/2.1/test_package/test.cpp new file mode 100644 index 0000000000000..aaac466a71277 --- /dev/null +++ b/recipes/daggy/2.1/test_package/test.cpp @@ -0,0 +1,86 @@ +/* +MIT License + +Copyright (c) 2021 synacker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include +#include +#include +#include + +#include +#include + +namespace { +constexpr const char* json_data = R"JSON( +{ + "sources": { + "localhost" : { + "type": "local", + "commands": { + "ping1": { + "exec": "ping 127.0.0.1", + "extension": "log" + }, + "ping2": { + "exec": "ping 127.0.0.1", + "extension": "log" + } + } + } + } +} +)JSON"; +} + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + daggy::Core core(*daggy::sources::convertors::json(json_data)); + + daggy::aggregators::CFile file_aggregator("test"); + daggy::aggregators::CConsole console_aggregator("test"); + + core.connectAggregator(&file_aggregator); + core.connectAggregator(&console_aggregator); + + QObject::connect(&core, &daggy::Core::stateChanged, &core, + [&](DaggyStates state){ + if(state == DaggyFinished) + app.quit(); + }); + + QTimer::singleShot(2000, &core, [&]() + { + core.stop(); + }); + + QTimer::singleShot(5000, &core, [&]() + { + app.exit(-1); + }); + + core.prepare(); + core.start(); + + return app.exec(); +} diff --git a/recipes/daggy/config.yml b/recipes/daggy/config.yml new file mode 100644 index 0000000000000..009e3d455971a --- /dev/null +++ b/recipes/daggy/config.yml @@ -0,0 +1,3 @@ +versions: + "2.1.2": + folder: "2.1" diff --git a/recipes/darknet/all/conandata.yml b/recipes/darknet/all/conandata.yml index d2371cfad3e30..f7382d7a3ec4c 100644 --- a/recipes/darknet/all/conandata.yml +++ b/recipes/darknet/all/conandata.yml @@ -1,7 +1,7 @@ sources: cci.20180914: - url: "https://github.com/pjreddie/darknet/archive/61c9d02ec461e30d55762ec7669d6a1d3c356fb2.zip" - sha256: "ab4f1eb87aa12025a37fb0992ede1d951b1846157373ad8592dba6e1552c265b" + url: "https://github.com/pjreddie/darknet/archive/61c9d02ec461e30d55762ec7669d6a1d3c356fb2.tar.gz" + sha256: "a1993ba2628b1be81ab14f8ef81de6c00a298b316c64ca96bebef2b0f40c3967" patches: cci.20180914: - patch_file: "patches/include_conan_flags.patch" diff --git a/recipes/darknet/all/conanfile.py b/recipes/darknet/all/conanfile.py index 58be102c412ad..5e49bf67b81ff 100644 --- a/recipes/darknet/all/conanfile.py +++ b/recipes/darknet/all/conanfile.py @@ -10,7 +10,7 @@ class DarknetConan(ConanFile): homepage = "http://pjreddie.com/darknet/" description = "Darknet is a neural network frameworks written in C" topics = ("darknet", "neural network", "deep learning") - settings = "os", "compiler", "build_type", "arch", "arch_build" + settings = "os", "compiler", "build_type", "arch" options = { "shared": [True, False], "fPIC": [True, False], @@ -22,16 +22,12 @@ class DarknetConan(ConanFile): "with_opencv": False, } exports_sources = ['patches/*'] + generators = "pkg_config" @property def _source_subfolder(self): return "source_subfolder" - @property - def _commit(self): - url = self.conan_data["sources"][self.version]["url"] - return url[url.rfind("/")+1:url.rfind(".")] - @property def _lib_to_compile(self): if not self.options.shared: @@ -49,7 +45,6 @@ def _shared_lib_extension(self): def _patch_sources(self): for patch in self.conan_data["patches"].get(self.version, []): tools.patch(**patch) - tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile"), "OPENCV=0", "OPENCV={}".format("1" if self.options.with_opencv else "0")) tools.replace_in_file( os.path.join(self._source_subfolder, "Makefile"), "SLIB=libdarknet.so", @@ -62,26 +57,31 @@ def _patch_sources(self): ) def configure(self): - if self.settings.os == "Windows": - raise ConanInvalidConfiguration("This library is not compatible with Windows") + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("This library is not compatible with Windows") + def requirements(self): if self.options.with_opencv: - # FIXME: opencv recipe is missing on CCI - raise ConanInvalidConfiguration("opencv recipe is not (yet) available on CCI") + self.requires("opencv/2.4.13.7") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = self.name + "-" + self._commit - os.rename(extracted_folder, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, + strip_root=True) def build(self): self._patch_sources() with tools.chdir(self._source_subfolder): - env_build = AutoToolsBuildEnvironment(self) - env_build.make() + with tools.environment_append({"PKG_CONFIG_PATH": self.build_folder}): + args = ["OPENCV={}".format("1" if self.options.with_opencv else "0")] + env_build = AutoToolsBuildEnvironment(self) + env_build.fpic = self.options.get_safe("fPIC", True) + env_build.make(args=args) def package(self): self.copy("LICENSE*", dst="licenses", src=self._source_subfolder) diff --git a/recipes/darknet/all/test_package/CMakeLists.txt b/recipes/darknet/all/test_package/CMakeLists.txt index d4fdee1a8a79c..e651ebaf233a3 100644 --- a/recipes/darknet/all/test_package/CMakeLists.txt +++ b/recipes/darknet/all/test_package/CMakeLists.txt @@ -1,8 +1,11 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) +project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) +find_package(darknet CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} example.cpp) +target_link_libraries(${PROJECT_NAME} darknet::darknet) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/darknet/all/test_package/conanfile.py b/recipes/darknet/all/test_package/conanfile.py index 562fbed537435..ffafc9bf4fa15 100644 --- a/recipes/darknet/all/test_package/conanfile.py +++ b/recipes/darknet/all/test_package/conanfile.py @@ -4,7 +4,8 @@ class DarknetTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" + def build(self): cmake = CMake(self) @@ -12,6 +13,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/darknet/all/test_package/example.cpp b/recipes/darknet/all/test_package/example.cpp index 377edda6d4ad5..f552a5b8da9b9 100644 --- a/recipes/darknet/all/test_package/example.cpp +++ b/recipes/darknet/all/test_package/example.cpp @@ -5,4 +5,5 @@ int main() { image image = make_image(2, 3, 1); free_image(image); + return 0; } diff --git a/recipes/dataframe/all/CMakeLists.txt b/recipes/dataframe/all/CMakeLists.txt deleted file mode 100644 index 50689e4881cea..0000000000000 --- a/recipes/dataframe/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/dataframe/all/conandata.yml b/recipes/dataframe/all/conandata.yml index 61ebceedc0382..91566611b6db3 100644 --- a/recipes/dataframe/all/conandata.yml +++ b/recipes/dataframe/all/conandata.yml @@ -1,4 +1,16 @@ sources: + "1.21.0": + url: "https://github.com/hosseinmoein/DataFrame/archive/refs/tags/1.21.0.tar.gz" + sha256: "a6b07eaaf628225a34e4402c1a6e311430e8431455669ac03691d92f44081172" + "1.20.0": + url: "https://github.com/hosseinmoein/DataFrame/archive/refs/tags/1.20.0.tar.gz" + sha256: "5c241c71823c6975251f49316e03724f06cd3a288892f5a76dd504fe08700b6d" + "1.19.0": + url: "https://github.com/hosseinmoein/DataFrame/archive/1.19.0.tar.gz" + sha256: "81382e9c68df7c52f69f645b1830fcd3634eedc07fa3d2024ee6c57cf2cdb7ff" + "1.18.0": + sha256: 8cdb8b246263fbd8fcef07b6300f6aefb58b3a54cd67e5cbe5383bc948305844 + url: https://github.com/hosseinmoein/DataFrame/archive/1.18.0.tar.gz "1.17.0": sha256: 669e9663de358330b15eacaa783ccf42fe16db27b9556fdcd18f1114c0335557 url: https://github.com/hosseinmoein/DataFrame/archive/1.17.0.tar.gz @@ -22,8 +34,6 @@ sources: url: https://github.com/hosseinmoein/DataFrame/archive/1.7.0.tar.gz patches: "1.8.0": - - base_path: source_subfolder - patch_file: "patches/0001-remove-tests-bin-for-conan-package.patch" + - patch_file: "patches/0001-remove-tests-bin-for-conan-package.patch" "1.7.0": - - base_path: source_subfolder - patch_file: "patches/0001-remove-tests-bin-for-conan-package.patch" + - patch_file: "patches/0001-remove-tests-bin-for-conan-package.patch" diff --git a/recipes/dataframe/all/conanfile.py b/recipes/dataframe/all/conanfile.py index c1c78711b049c..33492673970a7 100644 --- a/recipes/dataframe/all/conanfile.py +++ b/recipes/dataframe/all/conanfile.py @@ -1,6 +1,14 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +import textwrap + +required_conan_version = ">=1.50.0" class DataFrameConan(ConanFile): @@ -8,23 +16,29 @@ class DataFrameConan(ConanFile): license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/hosseinmoein/DataFrame" - description = "C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types, continuous memory storage, and no pointers are involved" + description = ( + "C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ " + "using native types, continuous memory storage, and no pointers are involved" + ) topics = ( - "conan", "dataframe", + "data-science", "numerical-analysis", "multidimensional-data", "heterogeneous", "cpp", "statistical-analysis", "financial-data-analysis", + "financial-engineering", + "data-analysis", "trading-strategies", "machine-learning", "trading-algorithms", "financial-engineering", "large-data", ) - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -34,14 +48,18 @@ class DataFrameConan(ConanFile): "fPIC": True, } - generators = "cmake" - exports_sources = ["CMakeLists.txt", "patches/*"] - - _cmake = None - @property - def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") + def _minimum_compilers_version(self): + return { + "Visual Studio": "15", + "gcc": "7", + "clang": "6", + "apple-clang": "10.0" if Version(self.version) >= "1.12.0" else "9.0", + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -51,67 +69,64 @@ def configure(self): if self.options.shared: del self.options.fPIC - compiler = str(self.settings.compiler) - compiler_version = tools.Version(self.settings.compiler.version) - - if compiler == "Visual Studio" and self.options.shared: + def validate(self): + if is_msvc(self) and self.info.options.shared and Version(self.version) < "1.20.0": raise ConanInvalidConfiguration( - "Could not support this specific configuration. Try static." + "dataframe {} doesn't support shared lib with Visual Studio".format(self.version) ) - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, "17") - else: - self.output.warn( - "{} recipe lacks information about the {} compiler standard version support".format( - self.name, compiler - ) - ) + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, "17") - minimal_version = { - "Visual Studio": "15", - "gcc": "7", - "clang": "6", - "apple-clang": "10.0" if tools.Version(self.version) >= "1.12.0" else "9.0", - } - - if compiler not in minimal_version: - self.output.info( - "{} requires a compiler that supports at least C++17".format(self.name) - ) - return - - # Exclude compilers not supported - if compiler_version < minimal_version[compiler]: + minimum_version = self._minimum_compilers_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: raise ConanInvalidConfiguration( - "{} requires a compiler that supports at least C++17. {} {} is not supported.".format( - self.name, compiler, tools.Version(self.settings.compiler.version) - ) + "{} requires C++17, which your compiler does not support.".format(self.name) ) + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "DataFrame-{}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - if tools.Version(self.version) >= "1.14.0": - self._cmake.definitions["ENABLE_TESTING"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) >= "1.20.0": + tc.variables["HMDF_TESTING"] = False + tc.variables["HMDF_EXAMPLES"] = False + tc.variables["HMDF_BENCHMARKS"] = False + elif Version(self.version) >= "1.14.0": + tc.variables["ENABLE_TESTING"] = False + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # Don't pollute RPATH + if Version(self.version) < "1.20.0": + replace_in_file( + self, + os.path.join(self.source_folder, "CMakeLists.txt"), + textwrap.dedent("""\ + include(AddInstallRPATHSupport) + add_install_rpath_support(BIN_DIRS "${CMAKE_INSTALL_FULL_LIBDIR}" + LIB_DIRS "${CMAKE_INSTALL_FULL_BINDIR}" + INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}" + USE_LINK_PATH) + """), + "", + ) def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("License", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "License", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() # Remove packaging files & MS runtime files @@ -121,12 +136,24 @@ def package(self): os.path.join("lib", "pkgconfig"), "CMake", ]: - tools.rmdir(os.path.join(self.package_folder, dir_to_remove)) + rmdir(self, os.path.join(self.package_folder, dir_to_remove)) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "DataFrame") + self.cpp_info.set_property("cmake_target_name", "DataFrame::DataFrame") + self.cpp_info.set_property("pkg_config_name", "DataFrame") + self.cpp_info.libs = ["DataFrame"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["pthread", "rt"]) + if is_msvc(self): + self.cpp_info.defines.append("_USE_MATH_DEFINES") + if Version(self.version) < "1.20.0" and not self.options.shared: + # weird but required in those versions of dataframe + self.cpp_info.defines.append("LIBRARY_EXPORTS") + if Version(self.version) >= "1.20.0" and self.options.shared: + self.cpp_info.defines.append("HMDF_SHARED") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.names["cmake_find_package"] = "DataFrame" self.cpp_info.names["cmake_find_package_multi"] = "DataFrame" self.cpp_info.names["pkg_config"] = "DataFrame" - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": - self.cpp_info.system_libs.extend(["pthread", "dl", "rt"]) diff --git a/recipes/dataframe/all/test_package/CMakeLists.txt b/recipes/dataframe/all/test_package/CMakeLists.txt index 052b845ceabe0..4c82a6b1a8874 100644 --- a/recipes/dataframe/all/test_package/CMakeLists.txt +++ b/recipes/dataframe/all/test_package/CMakeLists.txt @@ -1,15 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(DataFrame REQUIRED CONFIG) -if(MSVC) - add_definitions(-DLIBRARY_EXPORTS) -endif() - add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} DataFrame::DataFrame) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) +target_link_libraries(${PROJECT_NAME} PRIVATE DataFrame::DataFrame) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/dataframe/all/test_package/conanfile.py b/recipes/dataframe/all/test_package/conanfile.py index 3f4a9f50f389e..3a8c6c5442b33 100644 --- a/recipes/dataframe/all/test_package/conanfile.py +++ b/recipes/dataframe/all/test_package/conanfile.py @@ -1,11 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools - class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/dataframe/all/test_package/test_package.cpp b/recipes/dataframe/all/test_package/test_package.cpp index a3ab1b958f8ef..c5f07eb299a96 100644 --- a/recipes/dataframe/all/test_package/test_package.cpp +++ b/recipes/dataframe/all/test_package/test_package.cpp @@ -4,6 +4,7 @@ #include #include #include +#include using namespace hmdf; diff --git a/recipes/dataframe/all/test_v1_package/CMakeLists.txt b/recipes/dataframe/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..ff71d0aea5f2c --- /dev/null +++ b/recipes/dataframe/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(DataFrame REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE DataFrame::DataFrame) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/dataframe/all/test_v1_package/conanfile.py b/recipes/dataframe/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/dataframe/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/dataframe/config.yml b/recipes/dataframe/config.yml index 32f6fda574d1e..ee0214f11ffb3 100644 --- a/recipes/dataframe/config.yml +++ b/recipes/dataframe/config.yml @@ -1,4 +1,12 @@ versions: + "1.21.0": + folder: all + "1.20.0": + folder: all + "1.19.0": + folder: all + "1.18.0": + folder: all "1.17.0": folder: all "1.16.0": diff --git a/recipes/date/all/CMakeLists.txt b/recipes/date/all/CMakeLists.txt index 49191bdd3b16d..1848ca5a77c35 100644 --- a/recipes/date/all/CMakeLists.txt +++ b/recipes/date/all/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 2.8.12) project(cmake_wrapper) -message(STATUS "Conan CMake Wrapper") include(conanbuildinfo.cmake) conan_basic_setup() diff --git a/recipes/date/all/conandata.yml b/recipes/date/all/conandata.yml index d1bcf54a4c8d7..3a000e554ebbb 100644 --- a/recipes/date/all/conandata.yml +++ b/recipes/date/all/conandata.yml @@ -5,6 +5,9 @@ sources: "3.0.0": sha256: 87bba2eaf0ebc7ec539e5e62fc317cb80671a337c1fb1b84cb9e4d42c6dbebe3 url: https://github.com/HowardHinnant/date/archive/v3.0.0.tar.gz + "3.0.1": + sha256: 7a390f200f0ccd207e8cff6757e04817c1a0aec3e327b006b7eb451c57ee3538 + url: https://github.com/HowardHinnant/date/archive/v3.0.1.tar.gz patches: "2.4.1": - base_path: source_subfolder @@ -16,3 +19,6 @@ patches: "3.0.0": - base_path: source_subfolder patch_file: patches/cmake-3.0.0.patch + "3.0.1": + - base_path: source_subfolder + patch_file: patches/cmake-3.0.1.patch diff --git a/recipes/date/all/conanfile.py b/recipes/date/all/conanfile.py index 6302ceae3afc4..c6c05647b84c5 100644 --- a/recipes/date/all/conanfile.py +++ b/recipes/date/all/conanfile.py @@ -1,5 +1,7 @@ -import os from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.33.0" class DateConan(ConanFile): @@ -10,29 +12,56 @@ class DateConan(ConanFile): topics = ("date", "datetime", "timezone", "calendar", "time", "iana-database") license = "MIT" - exports_sources = ["patches/*", "CMakeLists.txt"] + settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package" - options = {"shared": [True, False], - "fPIC": [True, False], - "header_only": [True, False], - "use_system_tz_db": [True, False], - "use_tz_db_in_dot": [True, False]} - default_options = {"shared": False, - "fPIC": True, - "header_only": False, - "use_system_tz_db": False, - "use_tz_db_in_dot": False} + options = { + "shared": [True, False], + "fPIC": [True, False], + "header_only": [True, False], + "use_system_tz_db": [True, False], + "use_tz_db_in_dot": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "header_only": False, + "use_system_tz_db": False, + "use_tz_db_in_dot": False, + } + exports_sources = ["patches/*", "CMakeLists.txt"] + generators = "cmake", "cmake_find_package" _cmake = None @property def _source_subfolder(self): return "source_subfolder" - @property - def _build_subfolder(self): - return "build_subfolder" + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.os in ["iOS", "tvOS", "watchOS"]: + self.options.use_system_tz_db = True + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if not self.options.header_only and not self.options.use_system_tz_db: + self.requires("libcurl/7.78.0") + + def validate(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, "11") + + def package_id(self): + if self.options.header_only: + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -51,33 +80,12 @@ def _configure_cmake(self): self._cmake = cmake return self._cmake - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, "11") - - def requirements(self): - if self.options.header_only: - return - if not self.options.use_system_tz_db: - self.requires("libcurl/7.69.1") - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - def build(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - if self.options.header_only: - self.output.info("Header only package, skipping build") - return - cmake = self._configure_cmake() - cmake.build() + if not self.options.header_only: + cmake = self._configure_cmake() + cmake.build() def package(self): self.copy(pattern="LICENSE.txt", dst="licenses", @@ -87,35 +95,39 @@ def package(self): dst = os.path.join("include", "date") self.copy(pattern="date.h", dst=dst, src=src) self.copy(pattern="tz.h", dst=dst, src=src) + self.copy(pattern="ptz.h", dst=dst, src=src) self.copy(pattern="iso_week.h", dst=dst, src=src) self.copy(pattern="julian.h", dst=dst, src=src) self.copy(pattern="islamic.h", dst=dst, src=src) - return - - cmake = self._configure_cmake() - cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "CMake")) - - def package_info(self): - if self.options.header_only: - return - - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": - self.cpp_info.system_libs.append("pthread") - - if self.options.use_system_tz_db and not self.settings.os == "Windows": - use_os_tzdb = 1 else: - use_os_tzdb = 0 + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "CMake")) - defines = ["USE_OS_TZDB={}".format(use_os_tzdb)] - if self.settings.os == "Windows" and self.options.shared: - defines.append("DATE_USE_DLL=1") - - self.cpp_info.defines.extend(defines) - - def package_id(self): - if self.options.header_only: - self.info.header_only() + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "date" + self.cpp_info.names["cmake_find_package_multi"] = "date" + + # date-tz + if not self.options.header_only: + self.cpp_info.components["date-tz"].names["cmake_find_package"] = "date-tz" + self.cpp_info.components["date-tz"].names["cmake_find_package_multi"] = "date-tz" + lib_name = "{}tz".format("date-" if tools.Version(self.version) >= "3.0.0" else "") + self.cpp_info.components["date-tz"].libs = [lib_name] + if self.settings.os == "Linux": + self.cpp_info.components["date-tz"].system_libs.append("pthread") + + if not self.options.use_system_tz_db: + self.cpp_info.components["date-tz"].requires.append("libcurl::libcurl") + + if self.options.use_system_tz_db and not self.settings.os == "Windows": + use_os_tzdb = 1 + else: + use_os_tzdb = 0 + + defines = ["USE_OS_TZDB={}".format(use_os_tzdb)] + if self.settings.os == "Windows" and self.options.shared: + defines.append("DATE_USE_DLL=1") + + self.cpp_info.components["date-tz"].defines.extend(defines) diff --git a/recipes/date/all/patches/cmake-3.0.1.patch b/recipes/date/all/patches/cmake-3.0.1.patch new file mode 100644 index 0000000000000..8edcb30921f23 --- /dev/null +++ b/recipes/date/all/patches/cmake-3.0.1.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ad74900..ac390a9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -156,6 +156,9 @@ if( BUILD_TZ_LIB ) + target_include_directories( date-tz SYSTEM PRIVATE ${CURL_INCLUDE_DIRS} ) + target_link_libraries( date-tz PRIVATE ${CURL_LIBRARIES} ) + endif( ) ++ if( DISABLE_STRING_VIEW ) ++ target_compile_definitions( date-tz PRIVATE -DHAS_STRING_VIEW=0 -DHAS_DEDUCTION_GUIDES=0 ) ++ endif( ) + endif( ) + + #[===================================================================[ diff --git a/recipes/date/config.yml b/recipes/date/config.yml index 960726f7be698..8da6f34991031 100644 --- a/recipes/date/config.yml +++ b/recipes/date/config.yml @@ -4,3 +4,5 @@ versions: folder: all "3.0.0": folder: all + "3.0.1": + folder: all diff --git a/recipes/dav1d/all/conandata.yml b/recipes/dav1d/all/conandata.yml index 392eef9b00098..91f4fe2083735 100644 --- a/recipes/dav1d/all/conandata.yml +++ b/recipes/dav1d/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.0.0": + url: "https://code.videolan.org/videolan/dav1d/-/archive/1.0.0/dav1d-1.0.0.tar.gz" + sha256: "047b8229511a82b5718a1d34c86c067b078efd02f602986d2ed09b23182ec136" + "0.9.1": + url: "https://code.videolan.org/videolan/dav1d/-/archive/0.9.1/dav1d-0.9.1.tar.gz" + sha256: "097db6f370b88bf09fec62919c0d3af64e07d58210c665ec461d63f4ec79f6a2" "0.8.1": url: "https://code.videolan.org/videolan/dav1d/-/archive/0.8.1/dav1d-0.8.1.tar.gz" sha256: "39f52cccc31180c7180ebe8f223de6d12351c0407de0dfac087e8a9cc3feb8da" diff --git a/recipes/dav1d/all/conanfile.py b/recipes/dav1d/all/conanfile.py index fef43cf2e8da7..58cc7327c8da1 100644 --- a/recipes/dav1d/all/conanfile.py +++ b/recipes/dav1d/all/conanfile.py @@ -1,15 +1,25 @@ +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, replace_in_file, rm, rmdir +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os -from conans import ConanFile, Meson, tools -required_conan_version = ">= 1.29.1" +required_conan_version = ">=1.50.0" + class Dav1dConan(ConanFile): name = "dav1d" description = "dav1d is a new AV1 cross-platform decoder, open-source, and focused on speed, size and correctness." homepage = "https://www.videolan.org/projects/dav1d.html" - topics = ("conan", "av1", "codec", "video", "decoding") + topics = ("av1", "codec", "video", "decoding") license = "BSD-2-Clause" url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -24,94 +34,106 @@ class Dav1dConan(ConanFile): "bit_depth": "all", "with_tools": True, "assembly": True, - "with_avx512": False + "with_avx512": False, } - settings = "os", "arch", "compiler", "build_type" - generators = "cmake" - - _meson = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if self.settings.compiler == "Visual Studio" and self.settings.build_type == "Debug": + if is_msvc(self) and self.settings.build_type == "Debug": # debug builds with assembly often causes linker hangs or LNK1000 self.options.assembly = False + if Version(self.version) < "1.0.0": + del self.options.with_avx512 def configure(self): if self.options.shared: del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass if not self.options.assembly: del self.options.with_avx512 - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd def build_requirements(self): - # Meson versions since 0.51.0 do not work with autodetect symbol prefix - # so the nasm build is broken - # See upstream bug https://github.com/mesonbuild/meson/issues/5482 - self.build_requires("meson/0.51.0") + self.tool_requires("meson/0.63.1") if self.options.assembly: - self.build_requires("nasm/2.15.05") + self.tool_requires("nasm/2.15.05") + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("dav1d-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = MesonToolchain(self) + tc.project_options["enable_tests"] = False + tc.project_options["enable_asm"] = self.options.assembly + if Version(self.version) < "1.0.0": + tc.project_options["enable_avx512"] = self.options.get_safe("with_avx512", False) + tc.project_options["enable_tools"] = self.options.with_tools + if self.options.bit_depth == "all": + tc.project_options["bitdepths"] = "8,16" + else: + tc.project_options["bitdepths"] = str(self.options.bit_depth) + # TODO: fixed in conan 1.51.0? + tc.project_options["bindir"] = "bin" + tc.project_options["libdir"] = "lib" + tc.generate() + + env = VirtualBuildEnv(self) + env.generate(scope="build") def _patch_sources(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "meson.build"), + replace_in_file(self, os.path.join(self.source_folder, "meson.build"), "subdir('doc')", "") - def _configure_meson(self): - if self._meson: - return self._meson - self._meson = Meson(self) - self._meson.options["enable_tests"] = False - self._meson.options["enable_asm"] = self.options.assembly - self._meson.options["enable_avx512"] = self.options.get_safe("with_avx512", False) - self._meson.options["enable_tools"] = self.options.with_tools - if self.options.bit_depth == "all": - self._meson.options["bitdepths"] = "8,16" - else: - self._meson.options["bitdepths"] = str(self.options.bit_depth) - self._meson.configure(source_folder=self._source_subfolder, build_folder=self._build_subfolder, pkg_config_paths=[self.install_folder]) - return self._meson - def build(self): self._patch_sources() - meson = self._configure_meson() + meson = Meson(self) + meson.configure() meson.build() def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - meson = self._configure_meson() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + meson = Meson(self) meson.install() - - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.pdb") - - if self.settings.compiler == "Visual Studio" and not self.options.shared: - # https://github.com/mesonbuild/meson/issues/7378 - os.rename(os.path.join(self.package_folder, "lib", "libdav1d.a"), - os.path.join(self.package_folder, "lib", "dav1d.lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) + fix_msvc_libname(self) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "dav1d") self.cpp_info.libs = ["dav1d"] - self.cpp_info.names["pkg_config"] = "dav1d" - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["dl", "pthread"]) if self.options.with_tools: bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) + +def fix_msvc_libname(conanfile, remove_lib_prefix=True): + """remove lib prefix & change extension to .lib""" + from conan.tools.files import rename + import glob + if not is_msvc(conanfile): + return + libdirs = getattr(conanfile.cpp.package, "libdirs") + for libdir in libdirs: + for ext in [".dll.a", ".dll.lib", ".a"]: + full_folder = os.path.join(conanfile.package_folder, libdir) + for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")): + libname = os.path.basename(filepath)[0:-len(ext)] + if remove_lib_prefix and libname[0:3] == "lib": + libname = libname[3:] + rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib")) diff --git a/recipes/dav1d/all/test_package/CMakeLists.txt b/recipes/dav1d/all/test_package/CMakeLists.txt index 7b9b613cbb24a..7ef99743f0b06 100644 --- a/recipes/dav1d/all/test_package/CMakeLists.txt +++ b/recipes/dav1d/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(dav1d REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE dav1d::dav1d) diff --git a/recipes/dav1d/all/test_package/conanfile.py b/recipes/dav1d/all/test_package/conanfile.py index bd7165a553cf4..3a8c6c5442b33 100644 --- a/recipes/dav1d/all/test_package/conanfile.py +++ b/recipes/dav1d/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/dav1d/all/test_v1_package/CMakeLists.txt b/recipes/dav1d/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d3dffeef53fe1 --- /dev/null +++ b/recipes/dav1d/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(dav1d REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE dav1d::dav1d) diff --git a/recipes/dav1d/all/test_v1_package/conanfile.py b/recipes/dav1d/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/dav1d/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/dav1d/config.yml b/recipes/dav1d/config.yml index 0524adbec5458..d99137151015c 100644 --- a/recipes/dav1d/config.yml +++ b/recipes/dav1d/config.yml @@ -1,3 +1,7 @@ versions: + "1.0.0": + folder: "all" + "0.9.1": + folder: "all" "0.8.1": folder: "all" diff --git a/recipes/daw_header_libraries/all/conandata.yml b/recipes/daw_header_libraries/all/conandata.yml new file mode 100644 index 0000000000000..6545605dcb07a --- /dev/null +++ b/recipes/daw_header_libraries/all/conandata.yml @@ -0,0 +1,28 @@ +sources: + "2.76.3": + url: "https://github.com/beached/header_libraries/archive/v2.76.3.tar.gz" + sha256: "2d66f9aec38fb9a42779e0283fa2fc5842e04d34f2bf655c72a9beb4bf5cc8c8" + "2.76.2": + url: "https://github.com/beached/header_libraries/archive/v2.76.2.tar.gz" + sha256: "bfa2da192360a66e400d03a52f8a7bf0fccd23de1f446a812a8890b11df2c592" + "2.74.2": + url: "https://github.com/beached/header_libraries/archive/v2.74.2.tar.gz" + sha256: "32871df3d314cc9b4e293a9a8c79968d1c963dfd3dd60965dbf704eb18acb218" + "2.73.1": + url: "https://github.com/beached/header_libraries/archive/v2.73.1.tar.gz" + sha256: "62bd26398afa7eba1aae7bbbf107865044b8be0539d266085c36aed82557ae07" + "2.72.0": + url: "https://github.com/beached/header_libraries/archive/v2.72.0.tar.gz" + sha256: "f681755183af4af35f4741f3bcb7d99c6707911806e39e3acc982f9532aacc08" + "2.71.0": + url: "https://github.com/beached/header_libraries/archive/v2.71.0.tar.gz" + sha256: "50b9ddebdbc808a5714408a45f686fafe9d1d3b78c988df3973c12c9928828b9" + "2.68.3": + url: "https://github.com/beached/header_libraries/archive/v2.68.3.tar.gz" + sha256: "9bb7d25d161b89ad4a0ac857c28734c061cf53f6e80212c7fe70b8e0fd14789f" + "2.68.1": + url: "https://github.com/beached/header_libraries/archive/v2.68.1.tar.gz" + sha256: "51bdb042959373729009f91449c492f58bb63262146463a767f17d3de6fb2687" + "1.29.7": + url: "https://github.com/beached/header_libraries/archive/refs/tags/v1.29.7.tar.gz" + sha256: "524c34f3f5d2af498e7bcaff7802b914ba42acde29f7e3ecce41a035db0bf5bd" diff --git a/recipes/daw_header_libraries/all/conanfile.py b/recipes/daw_header_libraries/all/conanfile.py new file mode 100644 index 0000000000000..50f3611d7a2d8 --- /dev/null +++ b/recipes/daw_header_libraries/all/conanfile.py @@ -0,0 +1,70 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.layout import basic_layout + +import os + +required_conan_version = ">=1.50.0" + +class DawHeaderLibrariesConan(ConanFile): + name = "daw_header_libraries" + description = "Various header libraries mostly future std lib, replacements for(e.g. visit), or some misc" + license = "BSL-1.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/beached/header_libraries" + topics = ("algorithms", "helpers", "data-structures") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _compiler_required_cpp17(self): + return { + "Visual Studio": "16", + "msvc": "192", + "gcc": "8", + "clang": "7", + "apple-clang": "12.0", + } + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, "17") + + minimum_version = self._compiler_required_cpp17.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.get_safe("compiler.version")) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} requires C++17, which your compiler does not support.") + else: + self.output.warn(f"{self.ref} requires C++17. Your compiler is unknown. Assuming it supports C++17.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, pattern="LICENSE*", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "daw-header-libraries") + self.cpp_info.set_property("cmake_target_name", "daw::daw-header-libraries") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "daw-header-libraries" + self.cpp_info.filenames["cmake_find_package_multi"] = "daw-header-libraries" + self.cpp_info.names["cmake_find_package"] = "daw" + self.cpp_info.names["cmake_find_package_multi"] = "daw" + self.cpp_info.components["daw"].names["cmake_find_package"] = "daw-header-libraries" + self.cpp_info.components["daw"].names["cmake_find_package_multi"] = "daw-header-libraries" + self.cpp_info.components["daw"].set_property("cmake_target_name", "daw::daw-header-libraries") diff --git a/recipes/daw_header_libraries/all/test_package/CMakeLists.txt b/recipes/daw_header_libraries/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..817fb2a992dc4 --- /dev/null +++ b/recipes/daw_header_libraries/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package LANGUAGES CXX) + +find_package(daw-header-libraries REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE daw::daw-header-libraries) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/daw_header_libraries/all/test_package/conanfile.py b/recipes/daw_header_libraries/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fbb7f543162 --- /dev/null +++ b/recipes/daw_header_libraries/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/daw_header_libraries/all/test_package/test_package.cpp b/recipes/daw_header_libraries/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7b47a51d28ef5 --- /dev/null +++ b/recipes/daw_header_libraries/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include "daw/daw_carray.h" + +int main() { + daw::carray t = { 1, 2, 3, 4, 5, 6 }; + + auto val = t[3]; + + return 0; +} diff --git a/recipes/daw_header_libraries/all/test_v1_package/CMakeLists.txt b/recipes/daw_header_libraries/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..bc541ea90b512 --- /dev/null +++ b/recipes/daw_header_libraries/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/daw_header_libraries/all/test_v1_package/conanfile.py b/recipes/daw_header_libraries/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/daw_header_libraries/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/daw_header_libraries/config.yml b/recipes/daw_header_libraries/config.yml new file mode 100644 index 0000000000000..3e49278dd8894 --- /dev/null +++ b/recipes/daw_header_libraries/config.yml @@ -0,0 +1,19 @@ +versions: + "2.76.3": + folder: all + "2.76.2": + folder: all + "2.74.2": + folder: all + "2.73.1": + folder: all + "2.72.0": + folder: all + "2.71.0": + folder: all + "2.68.3": + folder: all + "2.68.1": + folder: all + "1.29.7": + folder: all diff --git a/recipes/daw_json_link/all/conandata.yml b/recipes/daw_json_link/all/conandata.yml new file mode 100644 index 0000000000000..0116aa5dce76f --- /dev/null +++ b/recipes/daw_json_link/all/conandata.yml @@ -0,0 +1,34 @@ +sources: + "3.11.1": + url: "https://github.com/beached/daw_json_link/archive/v3.11.1.tar.gz" + sha256: "d2b5cb221892c6b1ecd30fd2e45d168d6b378e97d134e75349703104c5882309" + "3.10.0": + url: "https://github.com/beached/daw_json_link/archive/v3.10.0.tar.gz" + sha256: "8a2e635e695d57eb147815f516c56d48360b103fbefc06f720607e8cf93c2937" + "3.8.1": + url: "https://github.com/beached/daw_json_link/archive/v3.8.1.tar.gz" + sha256: "b0f20310d1e295babaca62b83488b22f438cc4aacf8a7a47dcc92ad7386baaec" + "3.5.0": + url: "https://github.com/beached/daw_json_link/archive/v3.5.0.tar.gz" + sha256: "d1643725711b4564fb166f1f4bac0acb386fbbdb761f822c99a4ef585d8bdd71" + "3.4.1": + url: "https://github.com/beached/daw_json_link/archive/v3.4.1.tar.gz" + sha256: "3f57ccc936a9999b5c8c5684b2b3b8b989f50ef6e1ea8dce7bc311d1c77195ac" + "3.3.0": + url: "https://github.com/beached/daw_json_link/archive/v3.3.0.tar.gz" + sha256: "fd806245fc8b944e613b29da5ef0570c0e6881b6049a7bf65eb0285c58848f40" + "3.1.1": + url: "https://github.com/beached/daw_json_link/archive/v3.1.1.tar.gz" + sha256: "7d340886898b2ea3c595f0f871c81e4c7382fe53d22d80edc5629768e49fa634" + "3.1.0": + url: "https://github.com/beached/daw_json_link/archive/v3.1.0.tar.gz" + sha256: "c1134fed24794cda598306d23d23c393a0df8ee13d0019cae6ed46b939dad190" + "3.0.5": + url: "https://github.com/beached/daw_json_link/archive/v3.0.5.tar.gz" + sha256: "77abe2ca525083d59a1e4e8e9aa1d2633e5382d98a0d5d838cd2379eaf8d7edf" + "2.15.3": + url: "https://github.com/beached/daw_json_link/archive/v2.15.3.tar.gz" + sha256: "ec0457a5682a76c5aec709f2d6959ef7bafa0b54c5e7740f911d97991188ee84" + "2.14.0": + url: "https://github.com/beached/daw_json_link/archive/v2.14.0.tar.gz" + sha256: "811d0c5ab9ed9c79c84fc5837c8e7ef48f1f45177b7931bc849363c48a62261b" diff --git a/recipes/daw_json_link/all/conanfile.py b/recipes/daw_json_link/all/conanfile.py new file mode 100644 index 0000000000000..c31ac48f8445e --- /dev/null +++ b/recipes/daw_json_link/all/conanfile.py @@ -0,0 +1,94 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import get, copy, rmdir +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.scm import Version +from conan.tools.microsoft import is_msvc, check_min_vs + +import os + +required_conan_version = ">=1.52.0" + +class DawJsonLinkConan(ConanFile): + name = "daw_json_link" + description = "Static JSON parsing in C++" + license = "BSL-1.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/beached/daw_json_link" + topics = ("json", "parse", "json-parser", "serialization", "constexpr", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + short_paths = True + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8", + "clang": "7", + "apple-clang": "12", + } + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("daw_header_libraries/2.76.3") + self.requires("daw_utf_range/2.2.3") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + check_min_vs(self, 192) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support." + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["DAW_USE_PACKAGE_MANAGEMENT"] = True + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + self.cpp_info.set_property("cmake_file_name", "daw-json-link") + self.cpp_info.set_property("cmake_target_name", "daw::daw-json-link") + self.cpp_info.components["daw"].set_property("cmake_target_name", "daw::daw-json-link") + self.cpp_info.components["daw"].requires = ["daw_header_libraries::daw", "daw_utf_range::daw"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "daw-json-link" + self.cpp_info.filenames["cmake_find_package_multi"] = "daw-json-link" + self.cpp_info.names["cmake_find_package"] = "daw" + self.cpp_info.names["cmake_find_package_multi"] = "daw" + self.cpp_info.components["daw"].names["cmake_find_package"] = "daw-json-link" + self.cpp_info.components["daw"].names["cmake_find_package_multi"] = "daw-json-link" diff --git a/recipes/daw_json_link/all/test_package/CMakeLists.txt b/recipes/daw_json_link/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5162d77931f1e --- /dev/null +++ b/recipes/daw_json_link/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(daw-json-link REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE daw::daw-json-link) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/daw_json_link/all/test_package/conanfile.py b/recipes/daw_json_link/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e845ae751a301 --- /dev/null +++ b/recipes/daw_json_link/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/daw_json_link/all/test_package/test_package.cpp b/recipes/daw_json_link/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f1f131b75e79a --- /dev/null +++ b/recipes/daw_json_link/all/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include +#include + +#include "daw/json/daw_json_link.h" + +int main() { + std::string json_data = "[1, 2, 3, 4, 5]"; + + auto const obj = daw::json::from_json_array(json_data); + + for (auto val : obj) { + std::cout << val << std::endl; + } + + return 0; +} diff --git a/recipes/daw_json_link/all/test_v1_package/CMakeLists.txt b/recipes/daw_json_link/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b4b25bff2f0cd --- /dev/null +++ b/recipes/daw_json_link/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/daw_json_link/all/test_v1_package/conanfile.py b/recipes/daw_json_link/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..103e285f2d1a0 --- /dev/null +++ b/recipes/daw_json_link/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class DawJsonLinkTestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/daw_json_link/config.yml b/recipes/daw_json_link/config.yml new file mode 100644 index 0000000000000..534a6fe8ae542 --- /dev/null +++ b/recipes/daw_json_link/config.yml @@ -0,0 +1,23 @@ +versions: + "3.11.1": + folder: "all" + "3.10.0": + folder: "all" + "3.8.1": + folder: "all" + "3.5.0": + folder: "all" + "3.4.1": + folder: "all" + "3.3.0": + folder: "all" + "3.1.1": + folder: "all" + "3.1.0": + folder: "all" + "3.0.5": + folder: "all" + "2.15.3": + folder: "all" + "2.14.0": + folder: "all" diff --git a/recipes/daw_utf_range/all/conandata.yml b/recipes/daw_utf_range/all/conandata.yml new file mode 100644 index 0000000000000..179be6adbbd6e --- /dev/null +++ b/recipes/daw_utf_range/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "2.2.3": + url: "https://github.com/beached/utf_range/archive/v2.2.3.tar.gz" + sha256: "cfa36285ffbdf8d4d08fbbe95d054e67ad845c064a92419ea68a770415ad7a98" + "2.2.2": + url: "https://github.com/beached/utf_range/archive/refs/tags/v2.2.2.tar.gz" + sha256: "5380ade7c7eb5c82a748211896fc7385eaec00d3215af1374aec8f0e326f91fd" + "2.2.0": + url: "https://github.com/beached/utf_range/archive/refs/tags/v2.2.0.tar.gz" + sha256: "00f60360736062403c8a7a94dd07c750366958f20d1864578faecf2e09d84265" diff --git a/recipes/daw_utf_range/all/conanfile.py b/recipes/daw_utf_range/all/conanfile.py new file mode 100644 index 0000000000000..b3e630fee1e5a --- /dev/null +++ b/recipes/daw_utf_range/all/conanfile.py @@ -0,0 +1,91 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.files import get, copy, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.47.0" + +class DawUtfRangeConan(ConanFile): + name = "daw_utf_range" + description = "Range operations on character arrays" + license = "BSL-1.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/beached/utf_range/" + topics = ("utf", "validator", "iterator") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8", + "clang": "7", + "apple-clang": "12.0", + } + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("daw_header_libraries/2.76.3") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + check_min_vs(self, 192) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support." + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["DAW_USE_PACKAGE_MANAGEMENT"] = True + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + + def package(self): + copy(self, pattern="LICENSE*", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + self.cpp_info.set_property("cmake_file_name", "daw-utf-range") + self.cpp_info.set_property("cmake_target_name", "daw::daw-utf-range") + self.cpp_info.components["daw"].set_property("cmake_target_name", "daw::daw-utf-range") + self.cpp_info.components["daw"].requires = ["daw_header_libraries::daw"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "daw-utf-range" + self.cpp_info.filenames["cmake_find_package_multi"] = "daw-utf-range" + self.cpp_info.names["cmake_find_package"] = "daw" + self.cpp_info.names["cmake_find_package_multi"] = "daw" + self.cpp_info.components["daw"].names["cmake_find_package"] = "daw-utf-range" + self.cpp_info.components["daw"].names["cmake_find_package_multi"] = "daw-utf-range" diff --git a/recipes/daw_utf_range/all/test_package/CMakeLists.txt b/recipes/daw_utf_range/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..423476843bbe4 --- /dev/null +++ b/recipes/daw_utf_range/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(daw-utf-range REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE daw::daw-utf-range) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/daw_utf_range/all/test_package/conanfile.py b/recipes/daw_utf_range/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/daw_utf_range/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/daw_utf_range/all/test_package/test_package.cpp b/recipes/daw_utf_range/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..3591cd38b07aa --- /dev/null +++ b/recipes/daw_utf_range/all/test_package/test_package.cpp @@ -0,0 +1,19 @@ +#include "daw/utf8/unchecked.h" +#include +#include + +int main() { + std::string sample{"あいうえお abcde"}; + + auto first = daw::utf8::unchecked::iterator{sample.begin()}; + auto last = daw::utf8::unchecked::iterator{sample.end()}; + + int count = 0; + for (; first != last; ++first) { + ++count; + } + + std::cout << count << std::endl; + + return 0; +} diff --git a/recipes/daw_utf_range/all/test_v1_package/CMakeLists.txt b/recipes/daw_utf_range/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..ab1c8bbe0a5e1 --- /dev/null +++ b/recipes/daw_utf_range/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(daw-utf-range REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE daw::daw-utf-range) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/daw_utf_range/all/test_v1_package/conanfile.py b/recipes/daw_utf_range/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e4d8733790192 --- /dev/null +++ b/recipes/daw_utf_range/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, CMake, tools + +class DawUtfRangeTestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/daw_utf_range/config.yml b/recipes/daw_utf_range/config.yml new file mode 100644 index 0000000000000..20edb7543cf05 --- /dev/null +++ b/recipes/daw_utf_range/config.yml @@ -0,0 +1,7 @@ +versions: + "2.2.3": + folder: "all" + "2.2.2": + folder: "all" + "2.2.0": + folder: "all" diff --git a/recipes/dbcppp/all/conandata.yml b/recipes/dbcppp/all/conandata.yml new file mode 100644 index 0000000000000..ee0c7b702a4f7 --- /dev/null +++ b/recipes/dbcppp/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "3.2.6": + url: https://github.com/xR3b0rn/dbcppp/archive/refs/tags/v3.2.6.tar.gz + sha256: "e54829abf503abbc95513629e9318450224c1b22c0fcee4febc16cbfd73afafb" +patches: + "3.2.6": + - patch_file: "patches/0001-dep-cmake-rem-kcd.patch" + patch_type: "conan" + patch_description: "Disable use of KCD to ensure compatibility with conan" diff --git a/recipes/dbcppp/all/conanfile.py b/recipes/dbcppp/all/conanfile.py new file mode 100644 index 0000000000000..3a0d9d2ce43eb --- /dev/null +++ b/recipes/dbcppp/all/conanfile.py @@ -0,0 +1,111 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc_static_runtime, is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.53.0" + +class DBCpppConan(ConanFile): + name = "dbcppp" + description = ".dbc library for C/C++" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/xR3b0rn/dbcppp" + topics = ("can", "dbc", "network") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_tools": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_tools": False, + } + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "9", + "clang": "12", + "apple-clang": "12", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.options["boost"].header_only = True + + def layout(self): + cmake_layout(self) + + def requirements(self): + if self.options.with_tools: + self.requires("cxxopts/3.0.0") + self.requires("boost/1.80.0") + + def validate(self): + if self.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} does not currently support {self.ref}:shared=True") + + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + check_min_vs(self, 191) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support." + ) + + def source(self): + get(self, **self.conan_data["sources"][str(self.version)],destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if is_msvc(self): + tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) + tc.variables["build_tests"] = False + tc.variables["build_examples"] = False + tc.variables["build_tools"] = self.options.with_tools + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + rm(self, "KCD2Network.cpp", self.source_folder, recursive=True) # Cannot support KCD because of weird dll issues + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + + def package_info(self): + self.cpp_info.libs = ["libdbcppp"] + self.env_info.path.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/dbcppp/all/patches/0001-dep-cmake-rem-kcd.patch b/recipes/dbcppp/all/patches/0001-dep-cmake-rem-kcd.patch new file mode 100644 index 0000000000000..094014da38730 --- /dev/null +++ b/recipes/dbcppp/all/patches/0001-dep-cmake-rem-kcd.patch @@ -0,0 +1,317 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d905b29..d35d486 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,53 +5,16 @@ project("libdbcppp" VERSION 0.1.0) + + option(build_tests "Build tests" ON) + option(build_examples "Build examples" ON) ++option(build_tools "Build tools" ON) + +-set(CMAKE_CXX_STANDARD 17) +-set(CMAKE_STATIC_LIBRARY_PREFIX "") +-set(CMAKE_SHARED_LIBRARY_PREFIX "") +-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) ++set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + + if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + add_definitions("/bigobj") + endif() + + include_directories("include") +-include_directories("third-party/libxml2/include") +-include_directories("third-party/libxmlmm/libxmlmm") +-include_directories("third-party/boost") +-include_directories("third-party/cxxopts/include") + +-set(LIBXML2_WITH_ICONV OFF) +-set(LIBXML2_WITH_LZMA OFF) +-set(LIBXML2_WITH_PYTHON OFF) +-set(LIBXML2_WITH_ZLIB OFF) +-set(LIBXML2_WITH_TESTS OFF) +- +-add_subdirectory(third-party/libxml2) +- +-file(GLOB libxmlmm_header +- "third-party/libxmlmm/libxmlmm/*.h" +-) +-file(GLOB libxmlmm_src +- "third-party/libxmlmm/libxmlmm/*.cpp" +-) +- +-add_library(libxmlmm SHARED "") +-target_link_libraries(libxmlmm LibXml2) +- +-target_sources("libxmlmm" +- PRIVATE ${libxmlmm_header} +- PRIVATE ${libxmlmm_src} +-) +- +-install( +- TARGETS "libxmlmm" "LibXml2" EXPORT ${PROJECT_NAME}Targets +- DESTINATION ${CMAKE_INSTALL_LIBDIR}) +-install( +- DIRECTORY "libxmlmm" +- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libxmlmm +- FILES_MATCHING PATTERN "*.h") +- + add_subdirectory(src) + if (build_tests) + add_subdirectory(tests) +@@ -59,7 +22,3 @@ endif() + if (build_examples) + add_subdirectory(examples) + endif() +- +-set(CMAKE_STATIC_LIBRARY_PREFIX "") +-set(CMAKE_SHARED_LIBRARY_PREFIX "") +-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +diff --git a/include/dbcppp/Export.h b/include/dbcppp/Export.h +index 00dac6a..2ebe898 100644 +--- a/include/dbcppp/Export.h ++++ b/include/dbcppp/Export.h +@@ -1,12 +1,4 @@ + + #pragma once + +-#ifdef _WIN32 +-# ifdef DBCPPP_EXPORT +-# define DBCPPP_API __declspec(dllexport) +-# else +-# define DBCPPP_API __declspec(dllimport) +-# endif +-#else +-# define DBCPPP_API +-#endif ++#define DBCPPP_API +diff --git a/include/dbcppp/Network.h b/include/dbcppp/Network.h +index 34459e9..f36084b 100644 +--- a/include/dbcppp/Network.h ++++ b/include/dbcppp/Network.h +@@ -39,7 +39,6 @@ namespace dbcppp + , std::string&& comment); + static std::map> LoadNetworkFromFile(const std::filesystem::path& filename); + static std::unique_ptr LoadDBCFromIs(std::istream& is); +- static std::map> LoadKCDFromIs(std::istream& is); + + virtual std::unique_ptr Clone() const = 0; + +diff --git a/src/dbcppp/CMakeLists.txt b/src/dbcppp/CMakeLists.txt +index 371cbbf..6d56ae9 100644 +--- a/src/dbcppp/CMakeLists.txt ++++ b/src/dbcppp/CMakeLists.txt +@@ -1,8 +1,6 @@ +- +-include_directories( +- ${CMAKE_SOURCE_DIR}/src +- ${CMAKE_BINARY_DIR}/src +-) ++if(NOT build_tools) ++ return() ++endif() + + file(GLOB header + "*.h" +@@ -11,10 +9,12 @@ file(GLOB src + "*.cpp" + ) + ++find_package(cxxopts CONFIG REQUIRED) ++ + add_executable(dbcppp ${header} ${src}) + set_property(TARGET dbcppp PROPERTY CXX_STANDARD 17) + add_dependencies(dbcppp ${PROJECT_NAME}) +-target_link_libraries(dbcppp ${PROJECT_NAME} ${Boost_LIBRARIES}) ++target_link_libraries(dbcppp ${PROJECT_NAME} cxxopts::cxxopts) + + install( + TARGETS dbcppp +diff --git a/src/dbcppp/main.cpp b/src/dbcppp/main.cpp +index 462af2e..9ce93a6 100644 +--- a/src/dbcppp/main.cpp ++++ b/src/dbcppp/main.cpp +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include + #include + + #include +@@ -35,11 +36,7 @@ int main(int argc, char** argv) + ("f,format", "Output format (C, DBC, human)", cxxopts::value()) + ("dbc", "List of DBC files", cxxopts::value>()); + +- for (std::size_t i = 1; i < argc - 1; i++) +- { +- argv[i] = argv[i + 1]; +- } +- auto vm = options.parse(argc - 1, argv); ++ auto vm = options.parse(argc, argv); + + if (vm.count("help")) + { +@@ -89,10 +86,6 @@ int main(int argc, char** argv) + options.add_options() + ("h,help", "Produce help message") + ("bus", "List of buses in format <:>", cxxopts::value>()); +- for (std::size_t i = 1; i < argc - 1; i++) +- { +- argv[i] = argv[i + 1]; +- } + auto vm = options.parse(argc, argv); + if (vm.count("help")) + { +diff --git a/src/libdbcppp/CMakeLists.txt b/src/libdbcppp/CMakeLists.txt +index 9a69748..0ced933 100644 +--- a/src/libdbcppp/CMakeLists.txt ++++ b/src/libdbcppp/CMakeLists.txt +@@ -2,12 +2,11 @@ + include(GNUInstallDirs) + include(TestBigEndian) + +-add_library(${PROJECT_NAME} SHARED "") ++add_library(${PROJECT_NAME} "") + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) + +-target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} ${LIBXML2_LIBRARIES} "libxmlmm") +- +-add_compile_definitions(DBCPPP_EXPORT) ++find_package(Boost CONFIG REQUIRED) ++target_link_libraries(${PROJECT_NAME} boost::boost) + + include_directories( + ${CMAKE_SOURCE_DIR}/src +@@ -45,9 +44,6 @@ target_sources(${PROJECT_NAME} + ) + set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${header_interface}") + +-include(GenerateExportHeader) +-generate_export_header(${PROJECT_NAME}) +- + # install + install( + TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets +@@ -57,35 +53,3 @@ install( + FILES + $ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dbcppp) +- +-include(CMakePackageConfigHelpers) +-write_basic_package_version_file( +- "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" +- VERSION ${Upstream_VERSION} +- COMPATIBILITY AnyNewerVersion +-) +- +-export(EXPORT ${PROJECT_NAME}Targets +- FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake" +-) +-configure_file(cmake/${PROJECT_NAME}Config.cmake +- "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" +- @ONLY +-) +- +-set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) +-install(EXPORT ${PROJECT_NAME}Targets +- FILE +- ${PROJECT_NAME}Targets.cmake +- DESTINATION +- ${ConfigPackageLocation} +-) +-install( +- FILES +- cmake/${PROJECT_NAME}Config.cmake +- "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" +- DESTINATION +- ${ConfigPackageLocation} +- COMPONENT +- Devel +-) +\ No newline at end of file +diff --git a/src/libdbcppp/DBCAST2Network.cpp b/src/libdbcppp/DBCAST2Network.cpp +index fbbf155..d2fb973 100644 +--- a/src/libdbcppp/DBCAST2Network.cpp ++++ b/src/libdbcppp/DBCAST2Network.cpp +@@ -3,6 +3,7 @@ + #include + #include + #include ++#include + + #include + +diff --git a/src/libdbcppp/Export.h b/src/libdbcppp/Export.h +index 00dac6a..2ebe898 100644 +--- a/src/libdbcppp/Export.h ++++ b/src/libdbcppp/Export.h +@@ -1,12 +1,4 @@ + + #pragma once + +-#ifdef _WIN32 +-# ifdef DBCPPP_EXPORT +-# define DBCPPP_API __declspec(dllexport) +-# else +-# define DBCPPP_API __declspec(dllimport) +-# endif +-#else +-# define DBCPPP_API +-#endif ++#define DBCPPP_API +diff --git a/src/libdbcppp/Network2DBC.cpp b/src/libdbcppp/Network2DBC.cpp +index 3de0623..2fc7caa 100644 +--- a/src/libdbcppp/Network2DBC.cpp ++++ b/src/libdbcppp/Network2DBC.cpp +@@ -1,5 +1,6 @@ + #include "../../include/dbcppp/Network2Functions.h" + #include "NetworkImpl.h" ++#include + + using namespace dbcppp; + using namespace dbcppp::Network2DBC; +diff --git a/src/libdbcppp/Network2Human.cpp b/src/libdbcppp/Network2Human.cpp +index d61ee14..3110f2f 100644 +--- a/src/libdbcppp/Network2Human.cpp ++++ b/src/libdbcppp/Network2Human.cpp +@@ -1,6 +1,7 @@ + + #include + #include "../../include/dbcppp/Network2Functions.h" ++#include + + using namespace dbcppp; + +diff --git a/src/libdbcppp/NetworkImpl.cpp b/src/libdbcppp/NetworkImpl.cpp +index 04ce841..eab54e5 100644 +--- a/src/libdbcppp/NetworkImpl.cpp ++++ b/src/libdbcppp/NetworkImpl.cpp +@@ -1,5 +1,6 @@ + #include + #include ++#include + #include "../../include/dbcppp/Network.h" + #include "NetworkImpl.h" + +@@ -339,9 +340,5 @@ std::map> INetwork::LoadNetworkFromFile(c + result.insert(std::make_pair("", std::move(net))); + } + } +- else if (filename.extension() == ".kcd") +- { +- result = LoadKCDFromIs(is); +- } + return std::move(result); + } +\ No newline at end of file +diff --git a/src/libdbcppp/SignalMultiplexerValueImpl.cpp b/src/libdbcppp/SignalMultiplexerValueImpl.cpp +index 9c9a601..fea0544 100644 +--- a/src/libdbcppp/SignalMultiplexerValueImpl.cpp ++++ b/src/libdbcppp/SignalMultiplexerValueImpl.cpp +@@ -1,5 +1,6 @@ + + #include "SignalMultiplexerValueImpl.h" ++#include + + using namespace dbcppp; + diff --git a/recipes/dbcppp/all/test_package/CMakeLists.txt b/recipes/dbcppp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c5a24dec129dd --- /dev/null +++ b/recipes/dbcppp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(dbcppp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE dbcppp::dbcppp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/dbcppp/all/test_package/conanfile.py b/recipes/dbcppp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fbb7f543162 --- /dev/null +++ b/recipes/dbcppp/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/dbcppp/all/test_package/test_package.cpp b/recipes/dbcppp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..9adb143af2782 --- /dev/null +++ b/recipes/dbcppp/all/test_package/test_package.cpp @@ -0,0 +1,27 @@ + +#include +#include +#include + +#include + +int main() { + constexpr char* test_dbc = + "VERSION \"\"\n" + "NS_ :\n" + "BS_: 1 : 2, 3\n" + "BU_:\n" + "BO_ 1 Msg0: 8 Sender0\n" + " SG_ Sig0: 0|1@1+ (1,0) [1|12] \"Unit0\" Vector__XXX\n" + " SG_ Sig1 m0 : 1|1@0- (1,0) [1|12] \"Unit1\" Recv0, Recv1\n" + " SG_ Sig2 M : 2|1@0- (1,0) [1|12] \"Unit2\" Recv0, Recv1\n"; + + std::istringstream iss(test_dbc); + auto net = dbcppp::INetwork::LoadDBCFromIs(iss); + for (const auto& msg : net->Messages()) { + std::cout << "Message ID: " << msg.Id() << " Name: " << msg.Name() << std::endl; + for (const auto& sig : msg.Signals()) { + std::cout << '\t' << "Signal ID: " << sig.Name() << " Unit: " << sig.Unit() << std::endl; + } + } +} diff --git a/recipes/dbcppp/all/test_v1_package/CMakeLists.txt b/recipes/dbcppp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/dbcppp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/dbcppp/all/test_v1_package/conanfile.py b/recipes/dbcppp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e4d8733790192 --- /dev/null +++ b/recipes/dbcppp/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, CMake, tools + +class DawUtfRangeTestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/dbcppp/config.yml b/recipes/dbcppp/config.yml new file mode 100644 index 0000000000000..501f2f8a2e3d1 --- /dev/null +++ b/recipes/dbcppp/config.yml @@ -0,0 +1,3 @@ +versions: + "3.2.6": + folder: all diff --git a/recipes/dbus/1.x.x/conandata.yml b/recipes/dbus/1.x.x/conandata.yml index 3fb532e1380c8..20ee5e48052c8 100644 --- a/recipes/dbus/1.x.x/conandata.yml +++ b/recipes/dbus/1.x.x/conandata.yml @@ -1,4 +1,30 @@ sources: - "1.12.20": - url: "https://dbus.freedesktop.org/releases/dbus/dbus-1.12.20.tar.gz" - sha256: "f77620140ecb4cdc67f37fb444f8a6bea70b5b6461f12f1cbe2cec60fa7de5fe" + "1.15.2": + url: "https://dbus.freedesktop.org/releases/dbus/dbus-1.15.2.tar.xz" + sha256: "7e640803084af59f5e477b7ded11fd888b5380910a895c51ca3aedd63c0626ca" + "1.15.0": + url: "https://dbus.freedesktop.org/releases/dbus/dbus-1.15.0.tar.xz" + sha256: "5073c8cb9ad20226647bb38f4965182b762a6e1f595ccdc8e59411014bfd640a" + "1.14.0": + url: "https://dbus.freedesktop.org/releases/dbus/dbus-1.14.0.tar.xz" + sha256: "ccd7cce37596e0a19558fd6648d1272ab43f011d80c8635aea8fd0bad58aebd4" + "1.12.20": + url: "https://dbus.freedesktop.org/releases/dbus/dbus-1.12.20.tar.gz" + sha256: "f77620140ecb4cdc67f37fb444f8a6bea70b5b6461f12f1cbe2cec60fa7de5fe" +patches: + "1.15.2": + - patch_file: "patches/0003-meson-monotonic-clock-check.patch" + patch_type: "portability" + patch_description: "Fix detection of necessary monotonic clock functions in pthread" + patch_source: "https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/352" + "1.15.0": + - patch_file: "patches/0003-meson-monotonic-clock-check.patch" + patch_type: "portability" + patch_description: "Fix detection of necessary monotonic clock functions in pthread" + patch_source: "https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/352" + "1.12.20": + - patch_file: "patches/0001-cmake-project.patch" + - patch_file: "patches/0002-cmake_configure_checks_list_separator.patch" + patch_type: "portability" + url: "https://gitlab.freedesktop.org/dbus/dbus/-/commit/8cd1c2155252938ed38d2612e4d054c7fc0244c3.patch" + patch_source: "https://gitlab.freedesktop.org/dbus/dbus/-/issues/324" diff --git a/recipes/dbus/1.x.x/conanfile.py b/recipes/dbus/1.x.x/conanfile.py index 0224d00fc937c..8e5ffa679d9f5 100644 --- a/recipes/dbus/1.x.x/conanfile.py +++ b/recipes/dbus/1.x.x/conanfile.py @@ -1,7 +1,17 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, rename, replace_in_file, rm, rmdir, save +from conan.tools.gnu import PkgConfigDeps +from conan.tools.layout import basic_layout, cmake_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.scm import Version import os -import shutil -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +import textwrap + +required_conan_version = ">=1.52.0" class DbusConan(ConanFile): @@ -10,86 +20,205 @@ class DbusConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.freedesktop.org/wiki/Software/dbus" description = "D-Bus is a simple system for interprocess communication and coordination." - topics = ("conan", "dbus") - settings = "os", "compiler", "build_type", "arch" - + topics = ("bus", "interprocess", "message") + settings = "os", "arch", "compiler", "build_type" + short_paths = True options = { + "system_socket": ["ANY"], + "system_pid_file": ["ANY"], "with_x11": [True, False], - "with_glib": [True, False]} - + "with_glib": [True, False], + "with_systemd": [True, False], + "with_selinux": [True, False], + "session_socket_dir": ["ANY"], + } default_options = { + "system_socket": "", + "system_pid_file": "", "with_x11": False, - "with_glib": False} - - generators = "pkg_config" + "with_glib": False, + "with_systemd": False, + "with_selinux": False, + "session_socket_dir": "/tmp", + } @property - def _source_subfolder(self): - return "source_subfolder" + def _meson_available(self): + return Version(self.version) >= "1.15.0" - _autotools = None + def export_sources(self): + export_conandata_patches(self) - def configure(self): + def config_options(self): + if self.settings.os not in ("Linux", "FreeBSD") or Version(self.version) < "1.14.0": + del self.options.with_systemd if self.settings.os not in ("Linux", "FreeBSD"): - raise ConanInvalidConfiguration("dbus is only supported on Linux and FreeBSD") + del self.options.with_x11 - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - tools.rename(extracted_dir, self._source_subfolder) + def configure(self): + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + if self._meson_available: + basic_layout(self, src_folder="src") + else: + cmake_layout(self, src_folder="src") + + def build_requirements(self): + if self._meson_available: + self.tool_requires("meson/0.63.3") + self.tool_requires("pkgconf/1.9.3") def requirements(self): - self.requires("expat/2.2.10") + self.requires("expat/2.4.9") if self.options.with_glib: - self.requires("glib/2.67.0") - - if self.options.with_x11: + self.requires("glib/2.74.0") + if self.options.get_safe("with_systemd"): + self.requires("libsystemd/251.4") + if self.options.with_selinux: + self.requires("libselinux/3.3") + if self.options.get_safe("with_x11"): self.requires("xorg/system") - def _configure_autotools(self): - if not self._autotools: - self._autotools = AutoToolsBuildEnvironment(self) - - args = [] - args.append("--disable-tests") - args.append("--disable-doxygen-docs") - args.append("--disable-xml-docs") + def validate(self): + if Version(self.version) >= "1.14.0": + if self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) < 7: + raise ConanInvalidConfiguration(f"{self.ref} requires at least gcc 7.") + + if not self._meson_available and self.info.settings.os == "Windows": + raise ConanInvalidConfiguration(f"{self.ref} does not support Windows. Contributions welcome.") - args.append("--%s-x11-autolaunch" % ("enable" if self.options.with_x11 else "disable")) - args.append("--disable-asserts") - args.append("--disable-checks") - - self._autotools.configure(args=args, configure_dir=self._source_subfolder) - return self._autotools + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + if self._meson_available: + tc = MesonToolchain(self) + tc.project_options["asserts"] = not is_apple_os(self) + tc.project_options["checks"] = False + tc.project_options["doxygen_docs"] = "disabled" + tc.project_options["modular_tests"] = "disabled" + tc.project_options["session_socket_dir"] = str(self.options.session_socket_dir) + tc.project_options["selinux"] = "enabled" if self.options.get_safe("with_selinux", False) else "disabled" + tc.project_options["systemd"] = "enabled" if self.options.get_safe("with_systemd", False) else "disabled" + if self.options.get_safe("with_systemd", False): + tc.project_options["systemd_system_unitdir"] = os.path.join(self.package_folder, "lib", "systemd", "system") + tc.project_options["systemd_user_unitdir"] = os.path.join(self.package_folder, "lib", "systemd", "user") + if is_apple_os(self): + tc.project_options["launchd_agent_dir"] = os.path.join(self.package_folder, "res", "LaunchAgents") + tc.project_options["x11_autolaunch"] = "enabled" if self.options.get_safe("with_x11", False) else "disabled" + tc.project_options["xml_docs"] = "disabled" + tc.generate() + env = VirtualBuildEnv(self) + env.generate(scope="build") + else: + tc = CMakeToolchain(self) + tc.variables["DBUS_BUILD_TESTS"] = False + tc.variables["DBUS_ENABLE_DOXYGEN_DOCS"] = False + tc.variables["DBUS_ENABLE_XML_DOCS"] = False + tc.variables["DBUS_BUILD_X11"] = bool(self.options.get_safe("with_x11", False)) + tc.variables["ENABLE_SYSTEMD"] = "ON" if self.options.get_safe("with_systemd", False) else "OFF" + tc.variables["DBUS_WITH_GLIB"] = bool(self.options.get_safe("with_glib", False)) + tc.variables["DBUS_DISABLE_ASSERT"] = is_apple_os(self) + tc.variables["DBUS_DISABLE_CHECKS"] = False + + # Conan does not provide an EXPAT_LIBRARIES CMake variable for the Expat library. + # Define EXPAT_LIBRARIES to be the expat::expat target provided by Conan to fix linking. + tc.variables["EXPAT_LIBRARIES"] = "expat::expat" + + # https://github.com/freedesktop/dbus/commit/e827309976cab94c806fda20013915f1db2d4f5a + tc.variables["DBUS_SESSION_SOCKET_DIR"] = str(self.options.session_socket_dir) + + tc.cache_variables["CMAKE_FIND_PACKAGE_PREFER_CONFIG"] = False + tc.generate() + cmake_deps = CMakeDeps(self) + cmake_deps.generate() + pkg_config_deps = PkgConfigDeps(self) + pkg_config_deps.generate() def build(self): - autotools = self._configure_autotools() - autotools.make() + apply_conandata_patches(self) + if self._meson_available: + meson = Meson(self) + meson.configure() + meson.build() + else: + cmake = CMake(self) + build_script_folder = None + if Version(self.version) < "1.14.0": + build_script_folder = "cmake" + cmake.configure(build_script_folder=build_script_folder) + cmake.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", - src=self._source_subfolder) - autotools = self._configure_autotools() - autotools.install() - + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if self._meson_available: + meson = Meson(self) + meson.install() + else: + cmake = CMake(self) + cmake.install() + + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "share", "doc")) + mkdir(self, os.path.join(self.package_folder, "res")) for i in ["var", "share", "etc"]: - shutil.move(os.path.join(self.package_folder, i), os.path.join(self.package_folder, "res", i)) + rename(self, os.path.join(self.package_folder, i), os.path.join(self.package_folder, "res", i)) + + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "systemd")) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"dbus-1": "dbus-1::dbus-1"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(self.package_folder, "*.la") + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - # FIXME: There should not be a namespace + self.cpp_info.set_property("cmake_file_name", "DBus1") + self.cpp_info.set_property("cmake_target_name", "dbus-1") + self.cpp_info.set_property("pkg_config_name", "dbus-1") + self.cpp_info.includedirs.extend([ + os.path.join("include", "dbus-1.0"), + os.path.join("lib", "dbus-1.0", "include"), + ]) + self.cpp_info.resdirs = ["res"] + self.cpp_info.libs = ["dbus-1"] + if self.settings.os == "Linux": + self.cpp_info.system_libs.append("rt") + if self.settings.os == "Windows": + self.cpp_info.system_libs.extend(["iphlpapi", "ws2_32"]) + else: + self.cpp_info.system_libs.append("pthread") + + # TODO: to remove in conan v2 once cmake_find_package_* & pkg_config generators removed self.cpp_info.filenames["cmake_find_package"] = "DBus1" self.cpp_info.filenames["cmake_find_package_multi"] = "DBus1" self.cpp_info.names["cmake_find_package"] = "dbus-1" self.cpp_info.names["cmake_find_package_multi"] = "dbus-1" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] self.cpp_info.names["pkg_config"] = "dbus-1" - - self.cpp_info.includedirs.extend([ - "include/dbus-1.0", "lib/dbus-1.0/include"]) - self.cpp_info.libs = ["dbus-1"] diff --git a/recipes/dbus/1.x.x/patches/0001-cmake-project.patch b/recipes/dbus/1.x.x/patches/0001-cmake-project.patch new file mode 100644 index 0000000000000..2d00f57d33527 --- /dev/null +++ b/recipes/dbus/1.x.x/patches/0001-cmake-project.patch @@ -0,0 +1,23 @@ +--- a/cmake/CMakeLists.txt ++++ b/cmake/CMakeLists.txt +@@ -1,10 +1,3 @@ +-# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked +-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules") +- +-# we do not need to have WIN32 defined +-set(CMAKE_LEGACY_CYGWIN_WIN32 0) +- +-project(dbus) + + # we need to be up to date + CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2 FATAL_ERROR) +@@ -19,6 +12,9 @@ if(CMAKE_MAJOR_VERSION GREATER 2) + cmake_policy(SET CMP0054 NEW) + endif() + endif() ++set(CMAKE_LEGACY_CYGWIN_WIN32 0) ++project(dbus) ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules") + + # detect version + include(MacrosAutotools) diff --git a/recipes/dbus/1.x.x/patches/0002-cmake_configure_checks_list_separator.patch b/recipes/dbus/1.x.x/patches/0002-cmake_configure_checks_list_separator.patch new file mode 100644 index 0000000000000..7c60bf52d5ec2 --- /dev/null +++ b/recipes/dbus/1.x.x/patches/0002-cmake_configure_checks_list_separator.patch @@ -0,0 +1,22 @@ +diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake +index a9a5fc90..1a59461a 100644 +--- a/cmake/ConfigureChecks.cmake ++++ b/cmake/ConfigureChecks.cmake +@@ -43,7 +43,7 @@ check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) # + check_symbol_exists(getgrouplist "grp.h" HAVE_GETGROUPLIST) # dbus-sysdeps.c + check_symbol_exists(getpeerucred "ucred.h" HAVE_GETPEERUCRED) # dbus-sysdeps.c, dbus-sysdeps-win.c + check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP) # dbus-sysdeps.c +-check_symbol_exists(getpwnam_r "errno.h pwd.h" HAVE_POSIX_GETPWNAM_R) # dbus-sysdeps-util-unix.c ++check_symbol_exists(getpwnam_r "errno.h;pwd.h" HAVE_POSIX_GETPWNAM_R) # dbus-sysdeps-util-unix.c + check_symbol_exists(setenv "stdlib.h" HAVE_SETENV) # dbus-sysdeps.c + check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV) # dbus-sysdeps.c + check_symbol_exists(clearenv "stdlib.h" HAVE_CLEARENV) # dbus-sysdeps.c +@@ -66,7 +66,7 @@ check_symbol_exists(getrlimit "sys/resource.h;sys/time.h" HAVE_GETRLIMIT) + check_symbol_exists(prlimit "sys/resource.h;sys/time.h" HAVE_PRLIMIT) + check_symbol_exists(setrlimit "sys/resource.h;sys/time.h" HAVE_SETRLIMIT) + +-check_struct_member(cmsgcred cmcred_pid "sys/types.h sys/socket.h" HAVE_CMSGCRED) # dbus-sysdeps.c ++check_struct_member(cmsgcred cmcred_pid "sys/types.h;sys/socket.h" HAVE_CMSGCRED) # dbus-sysdeps.c + + # missing: + # DBUS_HAVE_GCC33_GCOV diff --git a/recipes/dbus/1.x.x/patches/0003-meson-monotonic-clock-check.patch b/recipes/dbus/1.x.x/patches/0003-meson-monotonic-clock-check.patch new file mode 100644 index 0000000000000..7e9e94edfd469 --- /dev/null +++ b/recipes/dbus/1.x.x/patches/0003-meson-monotonic-clock-check.patch @@ -0,0 +1,15 @@ +diff --git a/meson.build b/meson.build +index 3b5b182c..4e400a52 100644 +--- a/meson.build ++++ b/meson.build +@@ -328,7 +328,9 @@ data_config.set('top_builddir', meson.project_build_root()) + threads = dependency('threads') + config.set( + 'HAVE_MONOTONIC_CLOCK', +- cc.has_header_symbol('pthread.h', 'CLOCK_MONOTONIC', args: compile_args_c), ++ cc.has_header_symbol('pthread.h', 'CLOCK_MONOTONIC', args: compile_args_c) ++ and cc.has_header_symbol('pthread.h', 'pthread_condattr_setclock', args: compile_args_c) ++ and cc.has_header_symbol('time.h', 'clock_getres', args: compile_args_c), + ) + + glib = dependency( diff --git a/recipes/dbus/1.x.x/test_package/CMakeLists.txt b/recipes/dbus/1.x.x/test_package/CMakeLists.txt index fb51c0dc265db..497b3ee2b047c 100644 --- a/recipes/dbus/1.x.x/test_package/CMakeLists.txt +++ b/recipes/dbus/1.x.x/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(DBus1 REQUIRED CONFIG) -find_package(DBus1 REQUIRED) - -add_executable(example example.c) -target_link_libraries(example dbus-1::dbus-1) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE dbus-1) diff --git a/recipes/dbus/1.x.x/test_package/conanfile.py b/recipes/dbus/1.x.x/test_package/conanfile.py index fbdb7876c19ea..3cb242daa016f 100644 --- a/recipes/dbus/1.x.x/test_package/conanfile.py +++ b/recipes/dbus/1.x.x/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools -class DbusTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package", "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run("dbus-monitor --help", run_environment=True) - self.run(os.path.join("bin", "example"), run_environment=True) + if can_run(self): + self.run("dbus-monitor --help", env="conanrun") + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/dbus/1.x.x/test_package/example.c b/recipes/dbus/1.x.x/test_package/test_package.c similarity index 100% rename from recipes/dbus/1.x.x/test_package/example.c rename to recipes/dbus/1.x.x/test_package/test_package.c diff --git a/recipes/dbus/1.x.x/test_v1_package/CMakeLists.txt b/recipes/dbus/1.x.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b2f91e4b0e322 --- /dev/null +++ b/recipes/dbus/1.x.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(DBus1 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE dbus-1) diff --git a/recipes/dbus/1.x.x/test_v1_package/conanfile.py b/recipes/dbus/1.x.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..3a412edafcc0d --- /dev/null +++ b/recipes/dbus/1.x.x/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run("dbus-monitor --help", run_environment=True) + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/dbus/config.yml b/recipes/dbus/config.yml index 25658d2dae43d..cc866e2f4cf3b 100644 --- a/recipes/dbus/config.yml +++ b/recipes/dbus/config.yml @@ -1,3 +1,9 @@ versions: + "1.15.2": + folder: 1.x.x + "1.15.0": + folder: 1.x.x + "1.14.0": + folder: 1.x.x "1.12.20": folder: 1.x.x diff --git a/recipes/dcmtk/all/CMakeLists.txt b/recipes/dcmtk/all/CMakeLists.txt index 32d0b43daf801..56b7606e716f9 100644 --- a/recipes/dcmtk/all/CMakeLists.txt +++ b/recipes/dcmtk/all/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.0) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +conan_basic_setup(TARGETS KEEP_RPATHS) add_subdirectory(source_subfolder) diff --git a/recipes/dcmtk/all/conandata.yml b/recipes/dcmtk/all/conandata.yml index 0f7e63c70e121..3d3f43928861f 100644 --- a/recipes/dcmtk/all/conandata.yml +++ b/recipes/dcmtk/all/conandata.yml @@ -1,14 +1,14 @@ sources: - "3.6.5": - url: "https://dicom.offis.de/download/dcmtk/dcmtk365/dcmtk-3.6.5.tar.gz" - sha256: "a05178665f21896dbb0974106dba1ad144975414abd760b4cf8f5cc979f9beb9" "3.6.6": url: "https://dicom.offis.de/download/dcmtk/dcmtk366/dcmtk-3.6.6.tar.gz" sha256: "6859c62b290ee55677093cccfd6029c04186d91cf99c7642ae43627387f3458e" -patches: "3.6.5": - - patch_file: "patches/0001-cmake-use-conan-packages.patch" - base_path: "source_subfolder" + url: "https://dicom.offis.de/download/dcmtk/dcmtk365/dcmtk-3.6.5.tar.gz" + sha256: "a05178665f21896dbb0974106dba1ad144975414abd760b4cf8f5cc979f9beb9" +patches: "3.6.6": - patch_file: "patches/0002-cmake-use-conan-packages.patch" base_path: "source_subfolder" + "3.6.5": + - patch_file: "patches/0001-cmake-use-conan-packages.patch" + base_path: "source_subfolder" diff --git a/recipes/dcmtk/all/conanfile.py b/recipes/dcmtk/all/conanfile.py index 04bee844e1097..a22b5ac9d4a21 100644 --- a/recipes/dcmtk/all/conanfile.py +++ b/recipes/dcmtk/all/conanfile.py @@ -1,8 +1,11 @@ +from conan.tools.microsoft import msvc_runtime_flag from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import functools import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.43.0" class DCMTKConan(ConanFile): @@ -11,7 +14,8 @@ class DCMTKConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://dicom.offis.de/dcmtk" license = "BSD-3-Clause" - topics = "conan", "dcmtk", "dicom", "image" + topics = ("dcmtk", "dicom", "image") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -21,10 +25,8 @@ class DCMTKConan(ConanFile): "charset_conversion": [None, "libiconv", "icu"], "with_libxml2": [True, False], "with_zlib": [True, False], - "with_openjpeg": [True, False, "deprecated"], "with_openssl": [True, False], "with_libpng": [True, False], - "with_libsndfile": [True, False, "deprecated"], "with_libtiff": [True, False], "with_tcpwrappers": [True, False], "builtin_dictionary": [None, True, False], @@ -40,10 +42,8 @@ class DCMTKConan(ConanFile): "charset_conversion": "libiconv", "with_libxml2": True, "with_zlib": True, - "with_openjpeg": "deprecated", "with_openssl": True, "with_libpng": True, - "with_libsndfile": "deprecated", "with_libtiff": True, "with_tcpwrappers": False, "builtin_dictionary": None, @@ -51,10 +51,8 @@ class DCMTKConan(ConanFile): "external_dictionary": None, "wide_io": False, } - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake", "cmake_find_package" - _cmake = None + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): @@ -64,113 +62,116 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + del self.options.with_tcpwrappers def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.os == "Windows": - del self.options.with_tcpwrappers - - # Looking into source code, it appears that OpenJPEG and libsndfile are not used - if self.options.with_openjpeg != "deprecated": - self.output.warn("with_openjpeg option is deprecated, do not use anymore") - if self.options.with_libsndfile != "deprecated": - self.output.warn("with_libsndfile option is deprecated, do not use anymore") - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) def requirements(self): if self.options.charset_conversion == "libiconv": self.requires("libiconv/1.16") elif self.options.charset_conversion == "icu": - self.requires("icu/68.2") + self.requires("icu/71.1") if self.options.with_libxml2: - self.requires("libxml2/2.9.10") + self.requires("libxml2/2.9.13") if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.12") if self.options.with_openssl: - # FIXME: Bump openssl. dcmtk build files have a logic to detect - # various openssl API but for some reason it fails with 1.1 API - self.requires("openssl/1.0.2u") + if self.settings.os == "Windows": + # FIXME: CMake configuration fails to detect Openssl 1.1 on Windows. + self.requires("openssl/1.0.2u") + else: + self.requires("openssl/1.1.1n") if self.options.with_libpng: self.requires("libpng/1.6.37") if self.options.with_libtiff: - self.requires("libtiff/4.2.0") + self.requires("libtiff/4.3.0") if self.options.get_safe("with_tcpwrappers"): self.requires("tcp-wrappers/7.6") - def package_id(self): - del self.info.options.with_openjpeg - del self.info.options.with_libsndfile + def validate(self): + if hasattr(self, "settings_build") and tools.cross_building(self) and \ + self.settings.os == "Macos" and self.settings.arch == "armv8": + # FIXME: Probable issue with flags, build includes header 'mmintrin.h' + raise ConanInvalidConfiguration("Cross building to Macos M1 is not supported (yet)") + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) + cmake = CMake(self) # DICOM Data Dictionaries are required - self._cmake.definitions["CMAKE_INSTALL_DATADIR"] = self._dcm_datadictionary_path + cmake.definitions["CMAKE_INSTALL_DATADIR"] = self._dcm_datadictionary_path - self._cmake.definitions["BUILD_APPS"] = self.options.with_applications - self._cmake.definitions["DCMTK_WITH_ICONV"] = self.options.charset_conversion == "libiconv" + cmake.definitions["BUILD_APPS"] = self.options.with_applications + cmake.definitions["DCMTK_WITH_ICONV"] = self.options.charset_conversion == "libiconv" if self.options.charset_conversion == "libiconv": - self._cmake.definitions["WITH_LIBICONVINC"] = self.deps_cpp_info["libiconv"].rootpath - self._cmake.definitions["DCMTK_WITH_ICU"] = self.options.charset_conversion == "icu" - self._cmake.definitions["DCMTK_WITH_OPENJPEG"] = False - self._cmake.definitions["DCMTK_WITH_OPENSSL"] = self.options.with_openssl + cmake.definitions["WITH_LIBICONVINC"] = self.deps_cpp_info["libiconv"].rootpath + cmake.definitions["DCMTK_WITH_ICU"] = self.options.charset_conversion == "icu" + cmake.definitions["DCMTK_WITH_OPENJPEG"] = False + cmake.definitions["DCMTK_WITH_OPENSSL"] = self.options.with_openssl if self.options.with_openssl: - self._cmake.definitions["WITH_OPENSSLINC"] = self.deps_cpp_info["openssl"].rootpath - self._cmake.definitions["DCMTK_WITH_PNG"] = self.options.with_libpng + cmake.definitions["WITH_OPENSSLINC"] = self.deps_cpp_info["openssl"].rootpath + cmake.definitions["DCMTK_WITH_PNG"] = self.options.with_libpng if self.options.with_libpng: - self._cmake.definitions["WITH_LIBPNGINC"] = self.deps_cpp_info["libpng"].rootpath - self._cmake.definitions["DCMTK_WITH_SNDFILE"] = False - self._cmake.definitions["DCMTK_WITH_THREADS"] = self.options.with_multithreading - self._cmake.definitions["DCMTK_WITH_TIFF"] = self.options.with_libtiff + cmake.definitions["WITH_LIBPNGINC"] = self.deps_cpp_info["libpng"].rootpath + cmake.definitions["DCMTK_WITH_SNDFILE"] = False + cmake.definitions["DCMTK_WITH_THREADS"] = self.options.with_multithreading + cmake.definitions["DCMTK_WITH_TIFF"] = self.options.with_libtiff if self.options.with_libtiff: - self._cmake.definitions["WITH_LIBTIFFINC"] = self.deps_cpp_info["libtiff"].rootpath + cmake.definitions["WITH_LIBTIFFINC"] = self.deps_cpp_info["libtiff"].rootpath if self.settings.os != "Windows": - self._cmake.definitions["DCMTK_WITH_WRAP"] = self.options.with_tcpwrappers - self._cmake.definitions["DCMTK_WITH_XML"] = self.options.with_libxml2 + cmake.definitions["DCMTK_WITH_WRAP"] = self.options.with_tcpwrappers + cmake.definitions["DCMTK_WITH_XML"] = self.options.with_libxml2 if self.options.with_libxml2: - self._cmake.definitions["WITH_LIBXMLINC"] = self.deps_cpp_info["libxml2"].rootpath - self._cmake.definitions["WITH_LIBXML_SHARED"] = self.options["libxml2"].shared - self._cmake.definitions["DCMTK_WITH_ZLIB"] = self.options.with_zlib + cmake.definitions["WITH_LIBXMLINC"] = self.deps_cpp_info["libxml2"].rootpath + cmake.definitions["WITH_LIBXML_SHARED"] = self.options["libxml2"].shared + cmake.definitions["DCMTK_WITH_ZLIB"] = self.options.with_zlib if self.options.with_zlib: - self._cmake.definitions["WITH_ZLIBINC"] = self.deps_cpp_info["zlib"].rootpath + cmake.definitions["WITH_ZLIBINC"] = self.deps_cpp_info["zlib"].rootpath - self._cmake.definitions["DCMTK_ENABLE_STL"] = True - self._cmake.definitions["DCMTK_ENABLE_CXX11"] = True + cmake.definitions["DCMTK_ENABLE_STL"] = "ON" + cmake.definitions["DCMTK_ENABLE_CXX11"] = True - self._cmake.definitions["DCMTK_ENABLE_MANPAGE"] = False - self._cmake.definitions["DCMTK_WITH_DOXYGEN"] = False + cmake.definitions["DCMTK_ENABLE_MANPAGE"] = False + cmake.definitions["DCMTK_WITH_DOXYGEN"] = False - self._cmake.definitions["DCMTK_ENABLE_PRIVATE_TAGS"] = self.options.builtin_private_tags + cmake.definitions["DCMTK_ENABLE_PRIVATE_TAGS"] = self.options.builtin_private_tags if self.options.external_dictionary is not None: - self._cmake.definitions["DCMTK_ENABLE_EXTERNAL_DICTIONARY"] = self.options.external_dictionary + cmake.definitions["DCMTK_ENABLE_EXTERNAL_DICTIONARY"] = self.options.external_dictionary if self.options.builtin_dictionary is not None: - self._cmake.definitions["DCMTK_ENABLE_BUILTIN_DICTIONARY"] = self.options.builtin_dictionary - self._cmake.definitions["DCMTK_WIDE_CHAR_FILE_IO_FUNCTIONS"] = self.options.wide_io - self._cmake.definitions["DCMTK_WIDE_CHAR_MAIN_FUNCTION"] = self.options.wide_io - + cmake.definitions["DCMTK_ENABLE_BUILTIN_DICTIONARY"] = self.options.builtin_dictionary + cmake.definitions["DCMTK_WIDE_CHAR_FILE_IO_FUNCTIONS"] = self.options.wide_io + cmake.definitions["DCMTK_WIDE_CHAR_MAIN_FUNCTION"] = self.options.wide_io if self.settings.os == "Windows": - self._cmake.definitions["DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS"] = False + cmake.definitions["DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS"] = False - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["DCMTK_ICONV_FLAGS_ANALYZED"] = True - self._cmake.definitions["DCMTK_COMPILE_WIN32_MULTITHREADED_DLL"] = "MD" in str(self.settings.compiler.runtime) + if self._is_msvc: + cmake.definitions["DCMTK_ICONV_FLAGS_ANALYZED"] = True + cmake.definitions["DCMTK_COMPILE_WIN32_MULTITHREADED_DLL"] = "MD" in msvc_runtime_flag(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + cmake.configure(build_folder=self._build_subfolder) + return cmake def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) def build(self): @@ -276,25 +277,31 @@ def _dcm_datadictionary_path(self): return os.path.join(self.package_folder, "bin", "share") def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "DCMTK") + self.cpp_info.names["cmake_find_package"] = "DCMTK" self.cpp_info.names["cmake_find_package_multi"] = "DCMTK" def register_components(components): for target_lib, requires in components.items(): + self.cpp_info.components[target_lib].set_property("cmake_target_name", target_lib) + self.cpp_info.components[target_lib].libs = [target_lib] + self.cpp_info.components[target_lib].includedirs.append(os.path.join("include", "dcmtk")) + self.cpp_info.components[target_lib].requires = requires + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.components[target_lib].names["cmake_find_package"] = target_lib self.cpp_info.components[target_lib].names["cmake_find_package_multi"] = target_lib self.cpp_info.components[target_lib].builddirs.append(self._module_subfolder) self.cpp_info.components[target_lib].build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.components[target_lib].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - self.cpp_info.components[target_lib].libs = [target_lib] - self.cpp_info.components[target_lib].includedirs.append(os.path.join("include", "dcmtk")) - self.cpp_info.components[target_lib].requires = requires if self.settings.os == "Windows": self.cpp_info.components["ofstd"].system_libs.extend([ "iphlpapi", "ws2_32", "netapi32", "wsock32" ]) - elif self.settings.os == "Linux": + elif self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["ofstd"].system_libs.append("m") if self.options.with_multithreading: self.cpp_info.components["ofstd"].system_libs.append("pthread") @@ -303,9 +310,11 @@ def register_components(components): dcmdictpath = os.path.join(self._dcm_datadictionary_path, "dcmtk", "dicom.dic") self.output.info("Settings DCMDICTPATH environment variable: {}".format(dcmdictpath)) - self.env_info.DCMDICTPATH = dcmdictpath + self.runenv_info.define_path("DCMDICTPATH", dcmdictpath) + self.env_info.DCMDICTPATH = dcmdictpath # remove in conan v2? if self.options.with_applications: + self.buildenv_info.define_path("DCMDICTPATH", dcmdictpath) bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) diff --git a/recipes/dcmtk/all/test_package/CMakeLists.txt b/recipes/dcmtk/all/test_package/CMakeLists.txt index 33ae887aa6aea..b3dafcdddcb7d 100644 --- a/recipes/dcmtk/all/test_package/CMakeLists.txt +++ b/recipes/dcmtk/all/test_package/CMakeLists.txt @@ -2,8 +2,10 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(DCMTK REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} dcmdata) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/dcmtk/all/test_package/conanfile.py b/recipes/dcmtk/all/test_package/conanfile.py index bd7165a553cf4..38f4483872d47 100644 --- a/recipes/dcmtk/all/test_package/conanfile.py +++ b/recipes/dcmtk/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/dcmtk/config.yml b/recipes/dcmtk/config.yml index df4877414768a..ebad15c840829 100644 --- a/recipes/dcmtk/config.yml +++ b/recipes/dcmtk/config.yml @@ -1,5 +1,5 @@ versions: - "3.6.5": - folder: "all" "3.6.6": folder: "all" + "3.6.5": + folder: "all" diff --git a/recipes/dd-opentracing-cpp/all/CMakeLists.txt b/recipes/dd-opentracing-cpp/all/CMakeLists.txt new file mode 100644 index 0000000000000..4adab61a177bf --- /dev/null +++ b/recipes/dd-opentracing-cpp/all/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +if(CONAN_COMPILER MATCHES "clang" AND CONAN_COMPILER_VERSION VERSION_LESS "4.0") + add_compile_options(-ftemplate-depth=1024) +endif() + +add_subdirectory(source_subfolder) diff --git a/recipes/dd-opentracing-cpp/all/conandata.yml b/recipes/dd-opentracing-cpp/all/conandata.yml new file mode 100644 index 0000000000000..5c4a8f88936e6 --- /dev/null +++ b/recipes/dd-opentracing-cpp/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.3.0": + url: https://github.com/DataDog/dd-opentracing-cpp/archive/refs/tags/v1.3.0.tar.gz + sha256: 16aad0c0daed054d4bcdf68cf069956e8d3b0c60a33c2162ad655a17b33b65e4 +patches: + "1.3.0": + - base_path: "source_subfolder" + patch_file: "patches/0001-Find-packages-setup.patch" diff --git a/recipes/dd-opentracing-cpp/all/conanfile.py b/recipes/dd-opentracing-cpp/all/conanfile.py new file mode 100644 index 0000000000000..39cb79ab41f5f --- /dev/null +++ b/recipes/dd-opentracing-cpp/all/conanfile.py @@ -0,0 +1,120 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + + +class DatadogOpenTracingConan(ConanFile): + name = "dd-opentracing-cpp" + description = "Monitoring service for cloud-scale applications based on OpenTracing " + license = "Apache-2.0" + topics = ("instrumentration", "monitoring", "security", "tracing") + homepage = "https://github.com/DataDog/dd-opentracing-cpp" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "cmake", "cmake_find_package" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "5", + "Visual Studio": "15", + "clang": "3.4", + "apple-clang": "7", + } + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("opentracing-cpp/1.6.0") + self.requires("zlib/1.2.11") + self.requires("libcurl/7.80.0") + self.requires("msgpack/3.3.0") + self.requires("nlohmann_json/3.10.5") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 14) + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version: + if tools.Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration("Datadog-opentracing requires C++14, which your compiler does not support.") + else: + self.output.warn("Datadog-opentracing requires C++14. Your compiler is unknown. Assuming it supports C++14.") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_PLUGIN"] = False + self._cmake.definitions["BUILD_SHARED"] = self.options.shared + self._cmake.definitions["BUILD_STATIC"] = not self.options.shared + self._cmake.definitions["BUILD_TESTING"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["dd_opentracing"].libs = ["dd_opentracing"] + self.cpp_info.components["dd_opentracing"].defines.append( + "DD_OPENTRACING_SHARED" if self.options.shared else "DD_OPENTRACING_STATIC" + ) + if self.settings.os in ("Linux", "FreeBSD"): + self.cpp_info.components["dd_opentracing"].system_libs.append("pthread") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed. + # Do not support these names in CMakeDeps, it was a mistake, upstream doesn't export targets + self.cpp_info.names["cmake_find_package"] = "DataDogOpenTracing" + self.cpp_info.names["cmake_find_package_multi"] = "DataDogOpenTracing" + target_suffix = "" if self.options.shared else "-static" + self.cpp_info.components["dd_opentracing"].names["cmake_find_package"] = "dd_opentracing" + target_suffix + self.cpp_info.components["dd_opentracing"].names["cmake_find_package_multi"] = "dd_opentracing" + target_suffix + self.cpp_info.components["dd_opentracing"].requires = [ + "opentracing-cpp::opentracing-cpp", "zlib::zlib", "libcurl::libcurl", + "msgpack::msgpack", "nlohmann_json::nlohmann_json", + ] diff --git a/recipes/dd-opentracing-cpp/all/patches/0001-Find-packages-setup.patch b/recipes/dd-opentracing-cpp/all/patches/0001-Find-packages-setup.patch new file mode 100644 index 0000000000000..3308c5a043699 --- /dev/null +++ b/recipes/dd-opentracing-cpp/all/patches/0001-Find-packages-setup.patch @@ -0,0 +1,65 @@ +--- + CMakeLists.txt | 30 ++++++++++-------------------- + 1 file changed, 10 insertions(+), 20 deletions(-) + +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -34,17 +34,12 @@ include_directories(include) + set(CMAKE_LIBRARY_PATH deps/lib) + + # Dependencies +-find_path(OPENTRACING_INCLUDE_DIR NAMES opentracing/tracer.h) +-find_library(OPENTRACING_LIB opentracing) ++find_package(OpenTracing REQUIRED) + find_package(ZLIB REQUIRED) +-find_library(MSGPACK_LIB msgpack) +-find_package(CURL) ++find_package(msgpack REQUIRED) ++find_package(CURL REQUIRED) + find_package(Threads REQUIRED) + +-# Code Sanitizers +-set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/3rd_party/sanitizers-cmake" ${CMAKE_MODULE_PATH}) +-find_package(Sanitizers) +- + # Code + install(DIRECTORY include/datadog DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + file(GLOB DD_OPENTRACING_SOURCES "src/*.cpp") +@@ -58,29 +53,24 @@ else() + endif() + + # Outputs +-set(DATADOG_LINK_LIBRARIES ${OPENTRACING_LIB} ${CURL_LIBRARIES} ${ZLIB_LIBRARIES} Threads::Threads) ++set(DATADOG_LINK_LIBRARIES OpenTracing::OpenTracing CURL::CURL msgpack::msgpack ZLIB::ZLIB Threads::Threads) + + ## Shared lib + if(BUILD_SHARED) + add_library(dd_opentracing SHARED ${DD_OPENTRACING_SOURCES}) +- add_sanitizers(dd_opentracing) + target_link_libraries(dd_opentracing ${DATADOG_LINK_LIBRARIES}) + set_target_properties(dd_opentracing PROPERTIES SOVERSION ${SOVERSION}) +- target_compile_definitions(dd_opentracing PRIVATE DD_OPENTRACING_SHARED) +- install(TARGETS dd_opentracing +- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++ target_compile_definitions(dd_opentracing PUBLIC DD_OPENTRACING_SHARED) ++ install(TARGETS dd_opentracing) + endif() + + ## Static lib + if(BUILD_STATIC) + add_library(dd_opentracing-static STATIC ${DD_OPENTRACING_SOURCES}) +- add_sanitizers(dd_opentracing-static) +- set_target_properties(dd_opentracing-static PROPERTIES OUTPUT_NAME dd_opentracing POSITION_INDEPENDENT_CODE ON) +- target_compile_definitions(dd_opentracing PRIVATE DD_OPENTRACING_STATIC) +- install(TARGETS dd_opentracing-static +- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++ target_link_libraries(dd_opentracing-static ${DATADOG_LINK_LIBRARIES}) ++ set_target_properties(dd_opentracing-static PROPERTIES OUTPUT_NAME dd_opentracing) ++ target_compile_definitions(dd_opentracing-static PUBLIC DD_OPENTRACING_STATIC) ++ install(TARGETS dd_opentracing-static) + endif() + + ## Plugin + diff --git a/recipes/dd-opentracing-cpp/all/test_package/CMakeLists.txt b/recipes/dd-opentracing-cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..61e5eac8d9ed0 --- /dev/null +++ b/recipes/dd-opentracing-cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) diff --git a/recipes/dd-opentracing-cpp/all/test_package/conanfile.py b/recipes/dd-opentracing-cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5c09494bc67c0 --- /dev/null +++ b/recipes/dd-opentracing-cpp/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/dd-opentracing-cpp/all/test_package/test_package.cpp b/recipes/dd-opentracing-cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..45a3699729757 --- /dev/null +++ b/recipes/dd-opentracing-cpp/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + datadog::opentracing::TracerOptions tracer_options{"localhost", 8126, "compiled-in example"}; + auto tracer = datadog::opentracing::makeTracer(tracer_options); + + tracer->Close(); + return 0; +} diff --git a/recipes/dd-opentracing-cpp/config.yml b/recipes/dd-opentracing-cpp/config.yml new file mode 100644 index 0000000000000..426a0e4c79e9b --- /dev/null +++ b/recipes/dd-opentracing-cpp/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3.0": + folder: all diff --git a/recipes/decimal_for_cpp/all/conandata.yml b/recipes/decimal_for_cpp/all/conandata.yml new file mode 100644 index 0000000000000..1725a9d7288d2 --- /dev/null +++ b/recipes/decimal_for_cpp/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.18": + url: "https://github.com/vpiotr/decimal_for_cpp/archive/c949929d796ea389f2203a198a23fe59c0ab47d9.tar.gz" + sha256: "575d06e0a75e9db981a2cdb6949c2fe0709214aaf3fb293c94df7657cd394192" diff --git a/recipes/decimal_for_cpp/all/conanfile.py b/recipes/decimal_for_cpp/all/conanfile.py new file mode 100644 index 0000000000000..3e6a2b2a8d7a3 --- /dev/null +++ b/recipes/decimal_for_cpp/all/conanfile.py @@ -0,0 +1,40 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class DecimalforcppConan(ConanFile): + name = "decimal_for_cpp" + description = "Decimal data type support, for COBOL-like fixed-point operations on currency values." + license = "BSD-3-Clause" + topics = ("decimal_for_cpp", "currency", "money-library", "decimal-numbers") + homepage = "https://github.com/vpiotr/decimal_for_cpp" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "license.txt", src=os.path.join(self.source_folder, "doc"), dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/decimal_for_cpp/all/test_package/CMakeLists.txt b/recipes/decimal_for_cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ee7bfe5c692c5 --- /dev/null +++ b/recipes/decimal_for_cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(decimal_for_cpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} decimal_for_cpp::decimal_for_cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/decimal_for_cpp/all/test_package/conanfile.py b/recipes/decimal_for_cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/decimal_for_cpp/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/decimal_for_cpp/all/test_package/test_package.cpp b/recipes/decimal_for_cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..aca2d825d7873 --- /dev/null +++ b/recipes/decimal_for_cpp/all/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include + +#include + +int main() { + dec::decimal<2> value(143125); + std::cout << "Value #1 is: " << value << std::endl; + + dec::decimal<2> b("0.11"); + value += b; + std::cout << "Value #2 is: " << value << std::endl; + + value /= 1000; + std::cout << "Value #3 is: " << value << std::endl; + return 0; +} diff --git a/recipes/decimal_for_cpp/all/test_v1_package/CMakeLists.txt b/recipes/decimal_for_cpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..99324bd86f533 --- /dev/null +++ b/recipes/decimal_for_cpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(decimal_for_cpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} decimal_for_cpp::decimal_for_cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/decimal_for_cpp/all/test_v1_package/conanfile.py b/recipes/decimal_for_cpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/decimal_for_cpp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/decimal_for_cpp/config.yml b/recipes/decimal_for_cpp/config.yml new file mode 100644 index 0000000000000..7066915bb47f2 --- /dev/null +++ b/recipes/decimal_for_cpp/config.yml @@ -0,0 +1,3 @@ +versions: + "1.18": + folder: all diff --git a/recipes/deco/all/conandata.yml b/recipes/deco/all/conandata.yml new file mode 100644 index 0000000000000..907b9dffee329 --- /dev/null +++ b/recipes/deco/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.0.1": + url: "https://github.com/Enhex/Deco/archive/refs/tags/v1.0.1.zip" + sha256: 819e0a7fe2053944e2ec7fe0dee5e028d51e998b6b46b82f9553f26da50e7c9a + "1.0.0": + url: "https://github.com/Enhex/Deco/archive/refs/tags/v1.0.0.zip" + sha256: f167228306ccfaa24cffd08f5bc95e909b811920e7ed7b584ca83173534ff1eb diff --git a/recipes/deco/all/conanfile.py b/recipes/deco/all/conanfile.py new file mode 100644 index 0000000000000..3760e5bb68e07 --- /dev/null +++ b/recipes/deco/all/conanfile.py @@ -0,0 +1,56 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +class DecoConan(ConanFile): + name = "deco" + license = "Apache-2.0-WITH-LLVM-exception" + description = "Delimiter Collision Free Format" + topics = ("serialization") + homepage = "https://github.com/Enhex/Deco" + url = "https://github.com/conan-io/conan-center-index" + no_copy_source = True + settings = ("compiler", "build_type", "os", "arch") + requires = ( + "enhex-generic_serialization/1.0.0", + "enhex-strong_type/1.0.0", + "boost/1.79.0", + "rang/3.2", + ) + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 17) + + minimal_version = { + "Visual Studio": "15", + "gcc": "7", + "clang": "5.0", + "apple-clang": "9.1" + } + compiler = str(self.settings.compiler) + compiler_version = tools.Version(self.settings.compiler.version) + + if compiler not in minimal_version: + self.output.info("{} requires a compiler that supports at least C++17".format(self.name)) + return + + # Exclude compilers not supported + if compiler_version < minimal_version[compiler]: + raise ConanInvalidConfiguration("{} requires a compiler that supports at least C++17. {} {} is not".format( + self.name, compiler, tools.Version(self.settings.compiler.version.value))) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + + def package_id(self): + self.info.header_only() diff --git a/recipes/deco/all/test_package/CMakeLists.txt b/recipes/deco/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..00c3587be1a63 --- /dev/null +++ b/recipes/deco/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(deco CONFIG REQUIRED) + +add_executable(example example.cpp) +target_link_libraries(example deco::deco) +set_target_properties(example PROPERTIES CXX_STANDARD 17) diff --git a/recipes/deco/all/test_package/conanfile.py b/recipes/deco/all/test_package/conanfile.py new file mode 100644 index 0000000000000..f735734fbcfa9 --- /dev/null +++ b/recipes/deco/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class DecoTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/deco/all/test_package/example.cpp b/recipes/deco/all/test_package/example.cpp new file mode 100644 index 0000000000000..336ea678b84e6 --- /dev/null +++ b/recipes/deco/all/test_package/example.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +int main() +{ + using namespace std; + + const string sample { + "hello:\n" + " world!\n" + ":\n" + }; + + deco::parse(sample.begin(), sample.end()); + + cout << sample << endl; +} diff --git a/recipes/deco/config.yml b/recipes/deco/config.yml new file mode 100644 index 0000000000000..ac95cfe2bb3a3 --- /dev/null +++ b/recipes/deco/config.yml @@ -0,0 +1,5 @@ +versions: + "1.0.1": + folder: "all" + "1.0.0": + folder: "all" diff --git a/recipes/depot_tools/all/conanfile.py b/recipes/depot_tools/all/conanfile.py index d2721c1534515..45bfe37d78533 100644 --- a/recipes/depot_tools/all/conanfile.py +++ b/recipes/depot_tools/all/conanfile.py @@ -8,11 +8,11 @@ class DepotToolsConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://chromium.googlesource.com/chromium/tools/depot_tools" description = "Tools for working with Chromium development." - topics = ("conan", "depot_tools", "chromium") + topics = ("depot_tools", "chromium") license = "BSD-3-Clause" - no_copy_source = True short_paths = True - settings = "os_build" + no_copy_source = True + settings = "os", "arch", "build_type", "compiler" exports_sources = ["patches/**"] @@ -27,7 +27,7 @@ def _dereference_symlinks(self): `OSError: Invalid argument` rather than actually following the symlinks. Therefore, this workaround simply copies the destination file over the symlink """ - if self.settings.os_build != "Windows": + if self.settings.os != "Windows": return for root, dirs, files in os.walk(self._source_subfolder): @@ -55,7 +55,7 @@ def _fix_permissions(self): def chmod_plus_x(name): os.chmod(name, os.stat(name).st_mode | 0o111) - if self.settings.os_build != "Windows": + if self.settings.os != "Windows": for root, _, files in os.walk(self.package_folder): for file_it in files: filename = os.path.join(root, file_it) @@ -79,6 +79,11 @@ def chmod_plus_x(name): self.output.info('chmod on Mach-O file %s' % file_it) chmod_plus_x(filename) + def package_id(self): + del self.info.settings.arch + del self.info.settings.build_type + del self.info.settings.compiler + def package_info(self): bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH env var with : {}".format(bin_path)) diff --git a/recipes/depot_tools/all/test_package/conanfile.py b/recipes/depot_tools/all/test_package/conanfile.py index ac2f6fe27b9d9..38bf21d14dbee 100644 --- a/recipes/depot_tools/all/test_package/conanfile.py +++ b/recipes/depot_tools/all/test_package/conanfile.py @@ -3,4 +3,5 @@ class TestPackageConan(ConanFile): def test(self): - self.run("gclient --version", run_environment=True) + # cit: Chrome Infrastructure CLI + self.run("cit --help", run_environment=True) diff --git a/recipes/detools/all/CMakeLists.txt b/recipes/detools/all/CMakeLists.txt new file mode 100644 index 0000000000000..d0a389940b0bf --- /dev/null +++ b/recipes/detools/all/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(detools C) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_library(detools source_subfolder/c/detools.c) +install(TARGETS detools DESTINATION lib) +install(FILES source_subfolder/c/detools.h DESTINATION include) diff --git a/recipes/detools/all/conandata.yml b/recipes/detools/all/conandata.yml new file mode 100644 index 0000000000000..0c05a6fd77b19 --- /dev/null +++ b/recipes/detools/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.51.0": + url: "https://github.com/eerimoq/detools/archive/refs/tags/0.51.0.zip" + sha256: 604175d493a9df5d19e78a55cd183e9c44789ee552f24d1a2b7466d58628c1ac diff --git a/recipes/detools/all/conanfile.py b/recipes/detools/all/conanfile.py new file mode 100644 index 0000000000000..2b8703a181ae6 --- /dev/null +++ b/recipes/detools/all/conanfile.py @@ -0,0 +1,65 @@ +import functools + +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + + +class DetoolsConan(ConanFile): + name = "detools" + description = "Binary delta encoding" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/eerimoq/detools" + license = "MIT" + topics = ("delta-compression", "delta-update", "delta-encoding", + "ota", "bsdiff", "hdiffpatch") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + exports_sources = "CMakeLists.txt" + generators = "cmake" + requires = ['heatshrink/0.4.1', 'lz4/1.9.3', 'xz_utils/5.2.5'] + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def validate(self): + if self.settings.os not in ["Linux", "FreeBSD"]: + raise ConanInvalidConfiguration("This library is only compatible with Linux and FreeBSD") + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure(build_folder=self._build_subfolder) + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["detools"] diff --git a/recipes/detools/all/test_package/CMakeLists.txt b/recipes/detools/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..4e6b7c3b6cba8 --- /dev/null +++ b/recipes/detools/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(detools REQUIRED CONFIG) + +add_executable(test_package test_package.c) +target_link_libraries(test_package detools::detools) diff --git a/recipes/detools/all/test_package/conanfile.py b/recipes/detools/all/test_package/conanfile.py new file mode 100644 index 0000000000000..add2424f12959 --- /dev/null +++ b/recipes/detools/all/test_package/conanfile.py @@ -0,0 +1,32 @@ +import os + +from conans import ConanFile, CMake, tools + + +class DetoolsTestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + self.build_requires("cmake/3.20.1") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if tools.cross_building(self): + return + + bin_path = os.path.join("bin", "test_package") + old_path = os.path.join(self.source_folder, "old") + patch_path = os.path.join(self.source_folder, "patch") + patched_path = os.path.join(self.build_folder, "patched") + + self.run(f"{bin_path} {old_path} {patch_path} {patched_path}", + run_environment=True) diff --git a/recipes/detools/all/test_package/old b/recipes/detools/all/test_package/old new file mode 100644 index 0000000000000..0368e11feda26 Binary files /dev/null and b/recipes/detools/all/test_package/old differ diff --git a/recipes/detools/all/test_package/patch b/recipes/detools/all/test_package/patch new file mode 100644 index 0000000000000..99321d7000aa0 Binary files /dev/null and b/recipes/detools/all/test_package/patch differ diff --git a/recipes/detools/all/test_package/test_package.c b/recipes/detools/all/test_package/test_package.c new file mode 100644 index 0000000000000..e96fd3f5f3d9a --- /dev/null +++ b/recipes/detools/all/test_package/test_package.c @@ -0,0 +1,23 @@ +#include +#include "detools.h" + +#define EXPECTED_PATCHED_FILE_SIZE 2780 + +int main(int argc, const char *argv[]) +{ + int res; + + if (argc != 4) { + printf("Wrong number of arguments.\n"); + + return EXIT_FAILURE; + } + + res = detools_apply_patch_filenames(argv[1], argv[2], argv[3]); + + if (res == EXPECTED_PATCHED_FILE_SIZE) { + return EXIT_SUCCESS; + } else { + return EXIT_FAILURE; + } +} diff --git a/recipes/detools/config.yml b/recipes/detools/config.yml new file mode 100644 index 0000000000000..0cb36a4c86d32 --- /dev/null +++ b/recipes/detools/config.yml @@ -0,0 +1,3 @@ +versions: + "0.51.0": + folder: "all" diff --git a/recipes/detours/all/CMakeLists.txt b/recipes/detours/all/CMakeLists.txt new file mode 100644 index 0000000000000..08643cd4c3e75 --- /dev/null +++ b/recipes/detours/all/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.0) +project(conan_detours CXX) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +file(GLOB DETOURS_SOURCES source_subfolder/src/*.cpp) +list(REMOVE_ITEM DETOURS_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/src/uimports.cpp" +) +file(GLOB DETOURS_HEADERS source_subfolder/src/*.h) +add_library(detours STATIC ${DETOURS_SOURCES} ${DETOURS_HEADERS}) + +include(GNUInstallDirs) +install(TARGETS detours + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) +install(FILES ${DETOURS_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") diff --git a/recipes/detours/all/conandata.yml b/recipes/detours/all/conandata.yml new file mode 100644 index 0000000000000..3dfe062c93117 --- /dev/null +++ b/recipes/detours/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20220630": + url: "https://github.com/microsoft/Detours/archive/a1dd93fddfbba5ad07992edbaf4a296dcfca8d6f.tar.gz" + sha256: "6e1c9c8f7264749e58931660721b3aaa520ce1b489559bc9ad7003eb705427df" diff --git a/recipes/detours/all/conanfile.py b/recipes/detours/all/conanfile.py new file mode 100644 index 0000000000000..6d72096230585 --- /dev/null +++ b/recipes/detours/all/conanfile.py @@ -0,0 +1,98 @@ +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.45.0" + + +class DetoursConan(ConanFile): + name = "detours" + homepage = "https://github.com/antlr/antlr4/tree/master/runtime/Cpp" + description = "Detours is a software package for monitoring and instrumenting API calls on Windows" + topics = ("monitoror", "instrumenting", "hook", "injection") + url = "https://github.com/conan-io/conan-center-index" + license = "MIT" + generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def validate(self): + if self.settings.os != "Windows": + raise ConanInvalidConfiguration("Only os=Windows is supported") + # if not is_msvc(self): + # raise ConanInvalidConfiguration("Only the MSVC compiler is supported") + if is_msvc(self) and not is_msvc_static_runtime(self): + # Debug and/or dynamic runtime is undesired for a hooking library + raise ConanInvalidConfiguration("Only static runtime is supported (MT)") + if self.settings.build_type != "Release": + raise ConanInvalidConfiguration("Detours only supports the Release build type") + try: + self.output.info(f"target process is {self._target_processor}") + except KeyError: + raise ConanInvalidConfiguration("Unsupported architecture") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def export_sources(self): + self.copy("CMakeLists.txt") + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + @property + def _target_processor(self): + return { + "x86": "X86", + "x86_64": "X64", + "armv7": "ARM", + "armv8": "ARM64", + }[str(self.settings.arch)] + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure() + return cmake + + def _patch_sources(self): + if is_msvc(self): + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Makefile"), + "/MT ", f"/{self.settings.compiler.runtime} ") + + def build(self): + self._patch_sources() + if is_msvc(self): + with tools.vcvars(self): + with tools.chdir(os.path.join(self._source_subfolder, "src")): + self.run(f"nmake DETOURS_TARGET_PROCESSOR={self._target_processor}") + else: + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE.md", src=self._source_subfolder, dst="licenses") + if is_msvc(self): + self.copy("detours.lib", src=os.path.join(self._source_subfolder, f"lib.{self._target_processor}"), dst="lib") + self.copy("*.h", src=os.path.join(self._source_subfolder, "include"), dst="include") + else: + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libs = ["detours"] + if self.settings.compiler == "gcc": + self.cpp_info.system_libs = [tools.stdcpp_library(self)] + self.cpp_info.link_flags = ["-static-libgcc", "-static-libstdc++"] diff --git a/recipes/detours/all/test_package/CMakeLists.txt b/recipes/detours/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6b89b27839454 --- /dev/null +++ b/recipes/detours/all/test_package/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(detours REQUIRED CONFIG) + +add_executable(victim victim.c) + +set(HOOK_SOURCES hook.c) +if(MSVC) + list(APPEND HOOK_SOURCES hook_msvc.def) +else() + list(APPEND HOOK_SOURCES hook_mingw.def) +endif() +add_library(hook SHARED ${HOOK_SOURCES}) +target_link_libraries(hook PRIVATE detours::detours) +if(NOT MSVC) + target_link_options(hook PRIVATE -static-libgcc -static-libstdc++) +endif() +set_target_properties(hook PROPERTIES PREFIX "") + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE detours::detours) diff --git a/recipes/detours/all/test_package/conanfile.py b/recipes/detours/all/test_package/conanfile.py new file mode 100644 index 0000000000000..43240d491944c --- /dev/null +++ b/recipes/detours/all/test_package/conanfile.py @@ -0,0 +1,22 @@ +from conans import ConanFile, CMake, tools +import io +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.verbose = 1 + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self, skip_x64_x86=True): + bin_path = os.path.join("bin", "test_package") + buffer = io.StringIO() + self.run(f"{bin_path} \"{os.path.join(self.build_folder, 'bin')}\"", run_environment=True, output=buffer) + print(buffer.getvalue()) + assert "I found your message! It was 'A secret text'! I am 1337! :^)" in buffer.getvalue() diff --git a/recipes/detours/all/test_package/hook.c b/recipes/detours/all/test_package/hook.c new file mode 100644 index 0000000000000..55bcff4678b8c --- /dev/null +++ b/recipes/detours/all/test_package/hook.c @@ -0,0 +1,40 @@ +#include +#include + +#include +#include + +typedef BOOL (WINAPI * tWriteFile)(HANDLE, LPCVOID, DWORD, LPDWORD, LPOVERLAPPED); +static tWriteFile OriginalWriteFile = WriteFile; +static BOOL WINAPI HookWriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped) { + char buffer[512]; + sprintf_s(buffer, sizeof(buffer), "I found your message! It was '%s'! I am 1337! :^)", (char*)lpBuffer); + return OriginalWriteFile(hFile, buffer, (DWORD)strlen(buffer), lpNumberOfBytesWritten, lpOverlapped); +} + +BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserve0d) +{ + if (DetourIsHelperProcess()) { + return TRUE; + } + + if (dwReason == DLL_PROCESS_ATTACH) { + AllocConsole(); + DetourRestoreAfterWith(); + + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + + DetourAttach((PVOID*)&OriginalWriteFile, HookWriteFile); + + DetourTransactionCommit(); + } else if (dwReason == DLL_PROCESS_DETACH) { + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + + DetourDetach((PVOID*)&OriginalWriteFile, HookWriteFile); + + DetourTransactionCommit(); + } + return TRUE; +} diff --git a/recipes/detours/all/test_package/hook_mingw.def b/recipes/detours/all/test_package/hook_mingw.def new file mode 100644 index 0000000000000..1f2b4e23a5ee9 --- /dev/null +++ b/recipes/detours/all/test_package/hook_mingw.def @@ -0,0 +1,3 @@ +LIBRARY hook.dll +EXPORTS + DetourFinishHelperProcess@16 @1 NONAME diff --git a/recipes/detours/all/test_package/hook_msvc.def b/recipes/detours/all/test_package/hook_msvc.def new file mode 100644 index 0000000000000..c84b3610d727f --- /dev/null +++ b/recipes/detours/all/test_package/hook_msvc.def @@ -0,0 +1,3 @@ +LIBRARY hook.dll +EXPORTS + DetourFinishHelperProcess @1 NONAME diff --git a/recipes/detours/all/test_package/test_package.c b/recipes/detours/all/test_package/test_package.c new file mode 100644 index 0000000000000..908c3cb28e6e0 --- /dev/null +++ b/recipes/detours/all/test_package/test_package.c @@ -0,0 +1,134 @@ +#include +#include + +#include +#include +#include + +#define ARRAY_SIZE(ARR) ((sizeof(ARR))/sizeof(*(ARR))) + +int CDECL main(int argc, char **argv) { + if (argc < 2) { + fprintf(stderr, "Need at least one argument\n"); + return 1; + } + + SECURITY_ATTRIBUTES saAttr; + saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); + saAttr.bInheritHandle = TRUE; + saAttr.lpSecurityDescriptor = NULL; + + HANDLE hChildStd_IN_Rd = NULL; + HANDLE hChildStd_IN_Wr = NULL; + HANDLE hChildStd_OUT_Rd = NULL; + HANDLE hChildStd_OUT_Wr = NULL; + + if (!CreatePipe(&hChildStd_OUT_Rd, &hChildStd_OUT_Wr, &saAttr, 0)) { + fprintf(stderr, "StdoutRd CreatePipe\n"); + return 1; + } + if (!SetHandleInformation(hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0)) { + fprintf(stderr, "Stdout SetHandleInformation"); + } + if (!CreatePipe(&hChildStd_IN_Rd, &hChildStd_IN_Wr, &saAttr, 0)) { + fprintf(stderr, "Stdin CreatePipe"); + } + if (!SetHandleInformation(hChildStd_IN_Wr, HANDLE_FLAG_INHERIT, 0)) { + fprintf(stderr, "Stdin SetHandleInformation"); + } + + STARTUPINFOA si; + PROCESS_INFORMATION pi; + + ZeroMemory(&si, sizeof(si)); + ZeroMemory(&pi, sizeof(pi)); + si.cb = sizeof(si); + si.hStdError = hChildStd_OUT_Wr; + si.hStdOutput = hChildStd_OUT_Wr; + si.hStdInput = hChildStd_IN_Rd; + si.dwFlags |= STARTF_USESTDHANDLES; + + char exe[1024]; + strcpy_s(exe, sizeof(exe), argv[1]); + strcat_s(exe, sizeof(exe), "\\"); + strcat_s(exe, sizeof(exe), "victim.exe"); + + char command[1024]; + strcpy_s(command, sizeof(command), exe); + + char hook_dll[1024];; + strcpy_s(hook_dll, sizeof(hook_dll), argv[1]); + strcat_s(hook_dll, sizeof(hook_dll), "\\"); + strcat_s(hook_dll, sizeof(hook_dll), "hook.dll"); + const char* hooks[] = { + hook_dll, + }; + + printf("Starting \"%s`\n", exe); + printf(" with command: \"%s`\n", command); + printf(" with dlls:\n"); + for (size_t i = 0; i < ARRAY_SIZE(hooks); ++i) { + printf(" - %s\n", hooks[i]); + } + fflush(stdout); + + DWORD dwFlags = CREATE_DEFAULT_ERROR_MODE | CREATE_SUSPENDED | CREATE_NO_WINDOW; + + SetLastError(0); + if (!DetourCreateProcessWithDllsA( + exe, + command, + NULL, + NULL, + TRUE, + dwFlags, + NULL, + NULL, + &si, + &pi, + ARRAY_SIZE(hooks), + hooks, + NULL)) { + DWORD dwError = GetLastError(); + printf("%s: DetourCreateProcessWithDllEx failed: %ld\n", argv[0], dwError); + if (dwError == ERROR_INVALID_HANDLE) { +#if DETOURS_64BIT + printf("%s: Can't detour a 32-bit target process from a 64-bit parent process.\n", argv[0]); +#else + printf("%s: Can't detour a 64-bit target process from a 32-bit parent process.\n", argv[0]); +#endif + } + printf("ERROR"); + return 1; + } + + ResumeThread(pi.hThread); + CloseHandle(hChildStd_OUT_Wr); + CloseHandle(hChildStd_IN_Rd); + + for (;;) + { + DWORD dwRead, dwWritten; + char chBuf[256]; + BOOL bSuccess = ReadFile( hChildStd_OUT_Rd, chBuf, sizeof(chBuf), &dwRead, NULL); + if( ! bSuccess || dwRead == 0 ) { + break; + } + + bSuccess = WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), chBuf, + dwRead, &dwWritten, NULL); + if (!bSuccess) { + break; + } + } + + WaitForSingleObject(pi.hProcess, INFINITE); + + DWORD dwResult = 0; + if (!GetExitCodeProcess(pi.hProcess, &dwResult)) { + printf("%s: GetExitCodeProcess failed: %ld\n", argv[0], GetLastError()); + return 9010; + } + + return dwResult; +} diff --git a/recipes/detours/all/test_package/victim.c b/recipes/detours/all/test_package/victim.c new file mode 100644 index 0000000000000..ea4d0ad64375e --- /dev/null +++ b/recipes/detours/all/test_package/victim.c @@ -0,0 +1,11 @@ +#include + +#include + +int main(int argc, const char *args[]) +{ + HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE); + const char* text = "A secret text"; + WriteFile(stdout, text, (DWORD)strlen(text), NULL, NULL); + return 0; +} diff --git a/recipes/detours/config.yml b/recipes/detours/config.yml new file mode 100644 index 0000000000000..add5cbbf72010 --- /dev/null +++ b/recipes/detours/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220630": + folder: all diff --git a/recipes/dice-template-library/all/CMakeLists.txt b/recipes/dice-template-library/all/CMakeLists.txt new file mode 100644 index 0000000000000..b71c882d9d33f --- /dev/null +++ b/recipes/dice-template-library/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/dice-template-library/all/conandata.yml b/recipes/dice-template-library/all/conandata.yml new file mode 100644 index 0000000000000..a56456e70c621 --- /dev/null +++ b/recipes/dice-template-library/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "0.1.0": + url: "https://github.com/dice-group/dice-template-library/archive/refs/tags/v0.1.0.tar.gz" + sha256: "1d682283c4a54c4495fc65caa6f9a7674739156ce851227980430052120b2c29" + "0.2.0": + url: "https://github.com/dice-group/dice-template-library/archive/refs/tags/v0.2.0.tar.gz" + sha256: "0f981aeb5604eb305a190d3aef6625032bbb2a34a0bcd17f17ae0cef19fac384" + "0.3.0": + url: "https://github.com/dice-group/dice-template-library/archive/refs/tags/v0.3.0.tar.gz" + sha256: "2c02278f86c7b5fe1c684f5126f30529952a03784fa7c883cc4fd44965b3c33e" diff --git a/recipes/dice-template-library/all/conanfile.py b/recipes/dice-template-library/all/conanfile.py new file mode 100644 index 0000000000000..d7cce02ca9aa4 --- /dev/null +++ b/recipes/dice-template-library/all/conanfile.py @@ -0,0 +1,69 @@ +import os +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + + +class DiceTemplateLibrary(ConanFile): + name = "dice-template-library" + description = "This template library is a collection of handy template-oriented code that we, the Data Science Group at UPB, found pretty handy." + homepage = "https://dice-research.org/" + url = "https://github.com/conan-io/conan-center-index" + license = "MIT" + topics = ("template", "template-library", "compile-time", "switch", "integral-tuple") + settings = "build_type", "compiler", "os", "arch" + no_copy_source = True + + @property + def _min_cppstd(self): + return "20" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "10.2", + "clang": "12", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._min_cppstd) + if self.settings.compiler == "apple-clang": + raise ConanInvalidConfiguration("apple-clang is not supported because a full concept implementation is needed") + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("MSVC is not supported because a full concept implementation is needed") + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get( + str(self.settings.compiler), False) + if not minimum_version: + self.output.warn("{} {} requires C++20. Your compiler is unknown. Assuming it supports C++20.".format(self.name, self.version)) + elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration("{} {} requires C++20, which your compiler does not support.".format(self.name, self.version)) + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + + def package_id(self): + self.info.header_only() + + def package_info(self): + self.cpp_info.set_property("cmake_target_name", self.name) + self.cpp_info.set_property("cmake_target_aliases", ["{0}::{0}".format(self.name)]) + self.cpp_info.names["cmake_find_package"] = self.name + self.cpp_info.names["cmake_find_package_multi"] = self.name diff --git a/recipes/dice-template-library/all/test_package/CMakeLists.txt b/recipes/dice-template-library/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6fcf6dde0f94e --- /dev/null +++ b/recipes/dice-template-library/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(dice-template-library REQUIRED) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE dice-template-library::dice-template-library) diff --git a/recipes/dice-template-library/all/test_package/conanfile.py b/recipes/dice-template-library/all/test_package/conanfile.py new file mode 100644 index 0000000000000..9d8f35201d56c --- /dev/null +++ b/recipes/dice-template-library/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package", "cmake_find_package_multi", + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/dice-template-library/all/test_package/test_package.cpp b/recipes/dice-template-library/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..49e49454d63d0 --- /dev/null +++ b/recipes/dice-template-library/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include + +#include +#include + +template struct Wrapper { static constexpr int i = N; }; + +int main() { + dice::template_library::integral_template_tuple tup; + std::cout << std::boolalpha << "tup.get<3>().i == 3: " << (tup.get<3>().i == 3) << std::endl; +} diff --git a/recipes/dice-template-library/config.yml b/recipes/dice-template-library/config.yml new file mode 100644 index 0000000000000..b657866f6cca6 --- /dev/null +++ b/recipes/dice-template-library/config.yml @@ -0,0 +1,7 @@ +versions: + "0.1.0": + folder: all + "0.2.0": + folder: all + "0.3.0": + folder: all diff --git a/recipes/diligent-core/all/CMakeLists.txt b/recipes/diligent-core/all/CMakeLists.txt new file mode 100644 index 0000000000000..a00123a14d403 --- /dev/null +++ b/recipes/diligent-core/all/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.2) +project(cmake_wrapper) + +find_package(SPIRV-Tools REQUIRED CONFIG) +find_package(spirv-cross REQUIRED CONFIG) +find_package(glslang REQUIRED CONFIG) +find_package(volk REQUIRED CONFIG) +find_package(xxHash REQUIRED CONFIG) + +add_library(glslang INTERFACE) +target_link_libraries(glslang INTERFACE glslang::glslang) +target_include_directories(glslang INTERFACE ${glslang_INCLUDE_DIR}/glslang) + +add_library(SPIRV ALIAS glslang::SPIRV) +add_library(SPIRV-Headers ALIAS SPIRV-Headers::SPIRV-Headers) + +add_library(SPIRV-Tools-opt ALIAS spirv-tools::spirv-tools) +add_library(spirv-tools-core ALIAS spirv-tools::spirv-tools) +add_library(SPIRV-Tools-static ALIAS spirv-tools::spirv-tools) + +add_subdirectory(source_subfolder) + diff --git a/recipes/diligent-core/all/conandata.yml b/recipes/diligent-core/all/conandata.yml new file mode 100644 index 0000000000000..a48d5fbd77dc8 --- /dev/null +++ b/recipes/diligent-core/all/conandata.yml @@ -0,0 +1,59 @@ +sources: + "api.252009": + url: "https://github.com/DiligentGraphics/DiligentCore/archive/refs/tags/API252009.tar.gz" + sha256: "48d62ba72551166ea47eec4d2ad0589811e51c76c40d1998ad5049096efe8c19" + "api.252005": + url: "https://github.com/DiligentGraphics/DiligentCore/archive/refs/tags/API252005.tar.gz" + sha256: "20d164b36ec6ff6f1ef69aa44210bb46f3244af1c0d9538ac3758ca2437fb2e1" + "api.252004": + url: "https://github.com/DiligentGraphics/DiligentCore/archive/refs/tags/API252004.tar.gz" + sha256: "06e4ee5f95163ae74bbe62f59dcdf1da5e181ff2d6a8e3982319bb5c8f97c53b" + "api.252003": + url: "https://github.com/DiligentGraphics/DiligentCore/archive/refs/tags/API252003.tar.gz" + sha256: "18f17eaa0b6425022be4019c61fede441b9feec4b94c2b7e8ab73d86a7f6a913" + "2.5.2": + url: "https://github.com/DiligentGraphics/DiligentCore/archive/refs/tags/v2.5.2.tar.gz" + sha256: "6767a6b4f5750c3801ccdba8f7793ac79fa429c8d4518d79717f68ef9dd0ed2a" + "2.5.1": + url: "https://github.com/DiligentGraphics/DiligentCore/archive/refs/tags/v2.5.1.tar.gz" + sha256: "56a577d5273539f88cc27fb74ab61e42f407da77ef4d0876f83a9f8e763c0f64" + "api.250014": + url: "https://github.com/DiligentGraphics/DiligentCore/archive/refs/tags/API250014.tar.gz" + sha256: "8f85fc55c6241f9215875df58a077f797e9134c9b51f330f1489df91d8553b7d" +patches: + "api.252003": + - patch_file: "patches/0023-252003-fix-warning-as-error.patch" + base_path: "source_subfolder" + "2.5.2": + - patch_file: "patches/0014-252-exclude-tests.patch" + base_path: "source_subfolder" + - patch_file: "patches/0015-252-dont-install-3d-party-license.patch" + base_path: "source_subfolder" + - patch_file: "patches/0016-252-fix-glslang-usage.patch" + base_path: "source_subfolder" + - patch_file: "patches/0017-252-fix-glslang-include.patch" + base_path: "source_subfolder" + - patch_file: "patches/0018-252-fix-warning-as-error.patch" + base_path: "source_subfolder" + "2.5.1": + - patch_file: "patches/0001-remove_warning_as_error.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-use_conan_dependencies.patch" + base_path: "source_subfolder" + - patch_file: "patches/0003-use_volk_from_conan.patch" + base_path: "source_subfolder" + - patch_file: "patches/0005-spirv-cross-namespace-override.patch" + base_path: "source_subfolder" + - patch_file: "patches/0006-install-linux-platform-header.diff" + base_path: "source_subfolder" + "api.250014": + - patch_file: "patches/0007-API250014-remove_warning_as_error.patch" + base_path: "source_subfolder" + - patch_file: "patches/0009-API250014-use_conan_dependencies_in_third_party.patch" + base_path: "source_subfolder" + - patch_file: "patches/0010-API250014-use_volk_from_conan.patch" + base_path: "source_subfolder" + - patch_file: "patches/0013-API250014-use-vulkan-headers-in-archiver.patch" + base_path: "source_subfolder" + - patch_file: "patches/0005-spirv-cross-namespace-override.patch" + base_path: "source_subfolder" diff --git a/recipes/diligent-core/all/conanfile.py b/recipes/diligent-core/all/conanfile.py new file mode 100644 index 0000000000000..a02de86844027 --- /dev/null +++ b/recipes/diligent-core/all/conanfile.py @@ -0,0 +1,225 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building, check_min_cppstd +from conan.tools.scm import Version +from conan.tools.files import rm, get, rmdir, rename, collect_libs, patches, export_conandata_patches, copy, apply_conandata_patches +from conan.tools.apple import is_apple_os +import os + +required_conan_version = ">=1.52.0" + + +class DiligentCoreConan(ConanFile): + name = "diligent-core" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/DiligentGraphics/DiligentCore" + description = "Diligent Core is a modern cross-platfrom low-level graphics API." + license = "Apache-2.0" + topics = ("graphics") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_glslang": [True, False], + } + default_options = { + "shared": False , + "fPIC": True, + "with_glslang": True + } + short_paths = True + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "gcc": "6", + "clang": "3.4", + "apple-clang": "5.1", + } + + @property + def _minimum_cpp_standard(self): + return 14 + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler)) + else: + if Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) + if self.settings.compiler == "Visual Studio" and "MT" in self.settings.compiler.runtime: + raise ConanInvalidConfiguration("Visual Studio build with MT runtime is not supported") + + def export_sources(self): + copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder, keep_path=False) + export_conandata_patches(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=os.path.join(self.source_folder, "source_subfolder"), strip_root=True) + + def package_id(self): + if self.settings.compiler == "Visual Studio": + if "MD" in self.settings.compiler.runtime: + self.info.settings.compiler.runtime = "MD/MDd" + else: + self.info.settings.compiler.runtime = "MT/MTd" + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["DILIGENT_BUILD_SAMPLES"] = False + tc.variables["DILIGENT_NO_FORMAT_VALIDATION"] = True + tc.variables["DILIGENT_BUILD_TESTS"] = False + tc.variables["DILIGENT_NO_DXC"] = True + tc.variables["DILIGENT_NO_GLSLANG"] = not self.options.with_glslang + tc.variables["SPIRV_CROSS_NAMESPACE_OVERRIDE"] = self.options["spirv-cross"].namespace + tc.variables["BUILD_SHARED_LIBS"] = False + tc.variables["DILIGENT_CLANG_COMPILE_OPTIONS"] = "" + tc.variables["DILIGENT_MSVC_COMPILE_OPTIONS"] = "" + tc.variables["ENABLE_RTTI"] = True + tc.variables["ENABLE_EXCEPTIONS"] = True + tc.variables[self._diligent_platform()] = True + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def layout(self): + cmake_layout(self) + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def _patch_sources(self): + patches.apply_conandata_patches(self) + + def build_requirements(self): + self.tool_requires("cmake/3.24.2") + + def requirements(self): + self.requires("opengl/system") + if self.settings.os == "Linux": + self.requires("wayland/1.21.0") + + self.requires("spirv-cross/1.3.224.0") + self.requires("spirv-tools/1.3.224.0") + if self.options.with_glslang: + self.requires("glslang/1.3.224.0") + self.requires("vulkan-headers/1.3.224.1") + self.requires("vulkan-validationlayers/1.3.224.1") + self.requires("volk/1.3.224.1") + self.requires("xxhash/0.8.1") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.requires("xorg/system") + if not cross_building(self, skip_x64_x86=True): + self.requires("xkbcommon/1.4.1") + + def _diligent_platform(self): + if self.settings.os == "Windows": + return "PLATFORM_WIN32" + elif self.settings.os == "Macos": + return "PLATFORM_MACOS" + elif self.settings.os == "Linux": + return "PLATFORM_LINUX" + elif self.settings.os == "Android": + return "PLATFORM_ANDROID" + elif self.settings.os == "iOS": + return "PLATFORM_IOS" + elif self.settings.os == "Emscripten": + return "PLATFORM_EMSCRIPTEN" + elif self.settings.os == "watchOS": + return "PLATFORM_TVOS" + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + rename(self, src=os.path.join(self.package_folder, "include", "source_subfolder"), + dst=os.path.join(self.package_folder, "include", "DiligentCore")) + + rmdir(self, os.path.join(self.package_folder, "Licenses")) + rmdir(self, os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "bin")) + copy(self, "License.txt", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.package_folder, self.source_folder, "source_subfolder")) + + if self.options.shared: + copy(self, pattern="*.dylib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) + copy(self, pattern="*.so", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) + copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=self.build_folder, keep_path=False) + rm(self, os.path.join(self.package_folder, "lib"), "*.a", recursive=True) + if self.settings.os != "Windows": + rm(self, os.path.join(self.package_folder, "lib"), "*.lib", recursive=True) + else: + copy(self, pattern="*.a", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) + copy(self, pattern="*.lib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) + rm(self, os.path.join(self.package_folder, "lib"), "*.dylib", recursive=True) + rm(self, os.path.join(self.package_folder, "lib"), "*.so", recursive=True) + rm(self, os.path.join(self.package_folder, "lib"), "*.dll", recursive=True) + + copy(self, pattern="*.fxh", dst=os.path.join(self.package_folder, "res"), src=self.source_folder, keep_path=False) + copy(self, "File2String*", dst=os.path.join(self.package_folder, "bin"), src=self.source_folder, keep_path=False) + rm(self, "*.pdb", self.package_folder, recursive=True) + # MinGw creates many invalid files, called objects.a, remove them here: + rm(self, "objects.a", self.package_folder, recursive=True) + + def package_info(self): + self.cpp_info.libs = collect_libs(self) + # included as discussed here https://github.com/conan-io/conan-center-index/pull/10732#issuecomment-1123596308 + self.cpp_info.includedirs.append(os.path.join(self.package_folder, "include")) + self.cpp_info.includedirs.append(os.path.join(self.package_folder, "include", "DiligentCore", "Common")) + + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Common", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsEngine", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsEngineVulkan", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsEngineOpenGL", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsAccessories", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsTools", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "HLSL2GLSLConverterLib", "interface")) + archiver_path = os.path.join("include", "DiligentCore", "Graphics", "Archiver", "interface") + if os.path.isdir(archiver_path): + self.cpp_info.includedirs.append(archiver_path) + + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Primitives", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Basic", "interface")) + if self.settings.os == "Android": + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Android", "interface")) + elif is_apple_os(self): + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Apple", "interface")) + elif self.settings.os == "Emscripten": + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Emscripten", "interface")) + elif self.settings.os == "Linux": + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Linux", "interface")) + elif self.settings.os == "Windows": + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Platforms", "Win32", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsEngineD3D11", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentCore", "Graphics", "GraphicsEngineD3D12", "interface")) + + self.cpp_info.defines.append("SPIRV_CROSS_NAMESPACE_OVERRIDE={}".format(self.options["spirv-cross"].namespace)) + self.cpp_info.defines.append("{}=1".format(self._diligent_platform())) + + if self.settings.os in ["Macos", "Linux"]: + self.cpp_info.system_libs = ["dl", "pthread"] + if self.settings.os == 'Macos': + self.cpp_info.frameworks = ["CoreFoundation", 'Cocoa', 'AppKit'] + if self.settings.os == 'Windows': + self.cpp_info.system_libs = ["dxgi", "shlwapi"] diff --git a/recipes/diligent-core/all/patches/0001-remove_warning_as_error.patch b/recipes/diligent-core/all/patches/0001-remove_warning_as_error.patch new file mode 100644 index 0000000000000..0bb985efa0bb4 --- /dev/null +++ b/recipes/diligent-core/all/patches/0001-remove_warning_as_error.patch @@ -0,0 +1,30 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c8fa3c2a2..15dd0f60e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -296,7 +296,7 @@ if(MSVC) + # - w4100 - unreferenced formal parameter + # - w4201 - nonstandard extension used: nameless struct/union + # - w4505 - unreferenced local function has been removed +- target_compile_options(Diligent-BuildSettings INTERFACE /W4 /WX /wd4100 /wd4201 /wd4505 /MP) ++ target_compile_options(Diligent-BuildSettings INTERFACE /W1 /wd4100 /wd4201 /wd4505 /MP) + # In all release modes also: + # - disable w4189 - local variable is initialized but not referenced + # - Disable RTTI (/GR-) +@@ -343,7 +343,7 @@ endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(Diligent-BuildSettings INTERFACE + # All warnings are errors +- -Werror ++ + # Some extra warnings + -Wall -Wextra -Wuninitialized -Wconditional-uninitialized -Wextra-tokens -Wpointer-arith -Wloop-analysis -Wunused + # Disable few warnings +@@ -427,7 +427,6 @@ add_subdirectory(Primitives) + add_subdirectory(Platforms) + add_subdirectory(Common) + add_subdirectory(Graphics) +-add_subdirectory(Tests) + + + # Installation instructions diff --git a/recipes/diligent-core/all/patches/0002-use_conan_dependencies.patch b/recipes/diligent-core/all/patches/0002-use_conan_dependencies.patch new file mode 100644 index 0000000000000..b6e7c03e3b6d6 --- /dev/null +++ b/recipes/diligent-core/all/patches/0002-use_conan_dependencies.patch @@ -0,0 +1,93 @@ +diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt +index e329495f..d61520cd 100644 +--- a/ThirdParty/CMakeLists.txt ++++ b/ThirdParty/CMakeLists.txt +@@ -23,9 +23,6 @@ if(VULKAN_SUPPORTED OR METAL_SUPPORTED) + # do not really need any target from the project. + #add_subdirectory(SPIRV-Headers) + #set_directory_root_folder("SPIRV-Headers" "ThirdParty/DiligentCore/SPIRV-Headers") +- install(FILES SPIRV-Headers/LICENSE DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME SPIRV-Headers-License.txt) +- +- install(FILES Vulkan-Headers/LICENSE.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME Vulkan-Headers-License.txt) + + option(DILIGENT_NO_GLSLANG "Do NOT build glslang compiler" OFF) + option(DILIGENT_IMPROVE_SPIRV_TOOLS_DEBUG_PERF "Enable some optimizations for SPIRV-Tools, glslang, SPIRV-Cross and related projects in debug build to improve performance" ON) +@@ -41,15 +38,9 @@ if(VULKAN_SUPPORTED OR METAL_SUPPORTED) + set(SPIRV_CHECK_CONTEXT OFF CACHE BOOL "Do not check if the IR context is in a valid state") + endif() + set(CMAKE_MACOSX_RPATH TRUE) +- add_subdirectory(SPIRV-Tools) +- set_directory_root_folder("SPIRV-Tools" "DiligentCore/ThirdParty/SPIRV-Tools") + # We only need SPIRV-Tools-opt for glslang that also depends on SPIRV-Tools-static. + # Exclude all other targets from the build to save build time +- set(SPIRV_TOOLS_EXCLUDE_TARGETS SPIRV-Tools-link SPIRV-Tools-reduce SPIRV-Tools-shared) +- set_target_properties(${SPIRV_TOOLS_EXCLUDE_TARGETS} PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) + +- set(THIRD_PARTY_LIBS SPIRV-Tools-static SPIRV-Tools-opt) +- install(FILES SPIRV-Tools/LICENSE DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME SPIRV-Tools-License.txt) + endif() + + if(NOT ${DILIGENT_NO_GLSLANG}) +@@ -57,14 +48,9 @@ if(VULKAN_SUPPORTED OR METAL_SUPPORTED) + set(ENABLE_SPVREMAPPER OFF CACHE BOOL "Do not build SPIRV remapper") + set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "Skip glslang installation") + set(ENABLE_CTEST OFF CACHE BOOL "Disable testing") +- add_subdirectory(glslang) +- set_directory_root_folder("glslang" "DiligentCore/ThirdParty/glslang") + + # glslang "kindly" sets global CMAKE_DEBUG_POSTFIX to "d", which we have to unset now + unset(CMAKE_DEBUG_POSTFIX CACHE) +- +- list(APPEND THIRD_PARTY_LIBS GenericCodeGen glslang OGLCompiler OSDependent SPIRV HLSL MachineIndependent) +- install(FILES glslang/LICENSE.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME GLSLang-License.txt) + endif() + + set(SPIRV_CROSS_CLI OFF CACHE BOOL "Build the CLI binary. Requires SPIRV_CROSS_STATIC.") +@@ -80,37 +66,11 @@ if(VULKAN_SUPPORTED OR METAL_SUPPORTED) + set(SPIRV_CROSS_FORCE_PIC ON CACHE BOOL "Force position-independent code.") + set(SPIRV_CROSS_SKIP_INSTALL ON CACHE BOOL "Skip SPIRV-Cross installation.") + set(SPIRV_CROSS_NAMESPACE_OVERRIDE diligent_spirv_cross CACHE STRING "Override the namespace used in the C++ API.") +- add_subdirectory(SPIRV-Cross) +- set_directory_root_folder("SPIRV-Cross" "DiligentCore/ThirdParty/SPIRV-Cross") +- +- list(APPEND THIRD_PARTY_LIBS spirv-cross-core) +- if(METAL_SUPPORTED) +- list(APPEND THIRD_PARTY_LIBS spirv-cross-msl spirv-cross-glsl) +- endif() +- install(FILES SPIRV-Cross/LICENSE DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME SPIRV-Cross-License.txt) +- +- if(DILIGENT_INSTALL_CORE) +- install(TARGETS ${THIRD_PARTY_LIBS} +- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_CORE_DIR}/$" +- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_CORE_DIR}/$" +- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${DILIGENT_CORE_DIR}/$" +- ) +- endif() + +- if(${DILIGENT_IMPROVE_SPIRV_TOOLS_DEBUG_PERF} AND MSVC) +- # Enable function inlining (/Ob1) in Debug build to improve shader compilation performance +- foreach(TARGET ${THIRD_PARTY_LIBS}) +- target_compile_options(${TARGET} PRIVATE "$<$:/Ob1>") +- endforeach() +- endif() ++ list(APPEND THIRD_PARTY_LIBS SPIRV-Tools-opt spirv-cross-msl spirv-cross-glsl glslang::SPIRV glslang::glslang glslang::MachineIndependent glslang::GenericCodeGen glslang::OSDependent glslang::OGLCompiler glslang::HLSL) + + # Make sure that symbols do not leak out when third-party + # libs are linked into shared libraries +- set_target_properties(${THIRD_PARTY_LIBS} PROPERTIES +- CXX_VISIBILITY_PRESET hidden # -fvisibility=hidden +- C_VISIBILITY_PRESET hidden # -fvisibility=hidden +- VISIBILITY_INLINES_HIDDEN TRUE +- ) + endif() + + if(${DILIGENT_BUILD_GOOGLE_TEST}) +@@ -126,8 +86,3 @@ if(${DILIGENT_BUILD_GOOGLE_TEST}) + ) + endif() + +-install(FILES googletest/LICENSE DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME googletest-License.txt) +-install(FILES stb/stb_image_write_license.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}") +-install(FILES volk/LICENSE.md DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME Volk-License.md) +-install(FILES DirectXShaderCompiler/LICENSE.TXT DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME DXC-License.txt) +-install(FILES DirectXShaderCompiler/ThirdPartyNotices.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME DXC-ThirdPartyNotices.txt) diff --git a/recipes/diligent-core/all/patches/0003-use_volk_from_conan.patch b/recipes/diligent-core/all/patches/0003-use_volk_from_conan.patch new file mode 100644 index 0000000000000..3a247cb516390 --- /dev/null +++ b/recipes/diligent-core/all/patches/0003-use_volk_from_conan.patch @@ -0,0 +1,40 @@ +diff --git a/Graphics/GraphicsEngineVulkan/CMakeLists.txt b/Graphics/GraphicsEngineVulkan/CMakeLists.txt +index e760513d..a0d2de9c 100644 +--- a/Graphics/GraphicsEngineVulkan/CMakeLists.txt ++++ b/Graphics/GraphicsEngineVulkan/CMakeLists.txt +@@ -156,7 +156,8 @@ target_include_directories(Diligent-GraphicsEngineVk-static + PRIVATE + include + ../../ThirdParty +- ../../ThirdParty/Vulkan-Headers/include ++${VulkanHeaders_INCLUDE_DIR} ++${volk_INCLUDE_DIR}/ + ) + + set(PRIVATE_DEPENDENCIES +diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h +index ad00815a..65b3753c 100644 +--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h ++++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h +@@ -37,7 +37,7 @@ + #define VK_FORMAT_RANGE_SIZE (VK_FORMAT_ASTC_12x12_SRGB_BLOCK - VK_FORMAT_UNDEFINED + 1) + + #if DILIGENT_USE_VOLK +-# include "volk/volk.h" ++# include "volk.h" + #endif + + #ifdef _WINBASE_ +diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp +index 6e0a8e42..5fbf4b20 100644 +--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp ++++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp +@@ -34,7 +34,7 @@ + + #if DILIGENT_USE_VOLK + # define VOLK_IMPLEMENTATION +-# include "volk/volk.h" ++# include "volk.h" + #endif + + #include "VulkanErrors.hpp" diff --git a/recipes/diligent-core/all/patches/0005-spirv-cross-namespace-override.patch b/recipes/diligent-core/all/patches/0005-spirv-cross-namespace-override.patch new file mode 100644 index 0000000000000..d966a41920467 --- /dev/null +++ b/recipes/diligent-core/all/patches/0005-spirv-cross-namespace-override.patch @@ -0,0 +1,142 @@ +diff --git a/Graphics/ShaderTools/include/SPIRVShaderResources.hpp b/Graphics/ShaderTools/include/SPIRVShaderResources.hpp +index 6f3bec87b..842b485b3 100644 +--- a/Graphics/ShaderTools/include/SPIRVShaderResources.hpp ++++ b/Graphics/ShaderTools/include/SPIRVShaderResources.hpp +@@ -47,11 +47,17 @@ + #include "RefCntAutoPtr.hpp" + #include "StringPool.hpp" + +-namespace diligent_spirv_cross ++#ifdef SPIRV_CROSS_NAMESPACE_OVERRIDE ++#define SPIRV_CROSS_NAMESPACE SPIRV_CROSS_NAMESPACE_OVERRIDE ++#else ++#define SPIRV_CROSS_NAMESPACE spirv_cross ++#endif ++ ++namespace SPIRV_CROSS_NAMESPACE + { + class Compiler; + struct Resource; +-} // namespace diligent_spirv_cross ++} // namespace SPIRV_CROSS_NAMESPACE + + namespace Diligent + { +@@ -98,8 +104,8 @@ struct SPIRVShaderResourceAttribs + + // clang-format on + +- SPIRVShaderResourceAttribs(const diligent_spirv_cross::Compiler& Compiler, +- const diligent_spirv_cross::Resource& Res, ++ SPIRVShaderResourceAttribs(const SPIRV_CROSS_NAMESPACE::Compiler& Compiler, ++ const SPIRV_CROSS_NAMESPACE::Resource& Res, + const char* _Name, + ResourceType _Type, + Uint32 _BufferStaticSize = 0, +diff --git a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp +index c8badc818..c9f8f2171 100644 +--- a/Graphics/ShaderTools/src/SPIRVShaderResources.cpp ++++ b/Graphics/ShaderTools/src/SPIRVShaderResources.cpp +@@ -38,8 +38,8 @@ namespace Diligent + { + + template +-Type GetResourceArraySize(const diligent_spirv_cross::Compiler& Compiler, +- const diligent_spirv_cross::Resource& Res) ++Type GetResourceArraySize(const SPIRV_CROSS_NAMESPACE::Compiler& Compiler, ++ const SPIRV_CROSS_NAMESPACE::Resource& Res) + { + const auto& type = Compiler.get_type(Res.type_id); + uint32_t arrSize = 1; +@@ -53,12 +53,12 @@ Type GetResourceArraySize(const diligent_spirv_cross::Compiler& Compiler, + return static_cast(arrSize); + } + +-static RESOURCE_DIMENSION GetResourceDimension(const diligent_spirv_cross::Compiler& Compiler, +- const diligent_spirv_cross::Resource& Res) ++static RESOURCE_DIMENSION GetResourceDimension(const SPIRV_CROSS_NAMESPACE::Compiler& Compiler, ++ const SPIRV_CROSS_NAMESPACE::Resource& Res) + { + const auto& type = Compiler.get_type(Res.type_id); +- if (type.basetype == diligent_spirv_cross::SPIRType::BaseType::Image || +- type.basetype == diligent_spirv_cross::SPIRType::BaseType::SampledImage) ++ if (type.basetype == SPIRV_CROSS_NAMESPACE::SPIRType::BaseType::Image || ++ type.basetype == SPIRV_CROSS_NAMESPACE::SPIRType::BaseType::SampledImage) + { + switch (type.image.dim) + { +@@ -78,12 +78,12 @@ static RESOURCE_DIMENSION GetResourceDimension(const diligent_spirv_cross::Compi + } + } + +-static bool IsMultisample(const diligent_spirv_cross::Compiler& Compiler, +- const diligent_spirv_cross::Resource& Res) ++static bool IsMultisample(const SPIRV_CROSS_NAMESPACE::Compiler& Compiler, ++ const SPIRV_CROSS_NAMESPACE::Resource& Res) + { + const auto& type = Compiler.get_type(Res.type_id); +- if (type.basetype == diligent_spirv_cross::SPIRType::BaseType::Image || +- type.basetype == diligent_spirv_cross::SPIRType::BaseType::SampledImage) ++ if (type.basetype == SPIRV_CROSS_NAMESPACE::SPIRType::BaseType::Image || ++ type.basetype == SPIRV_CROSS_NAMESPACE::SPIRType::BaseType::SampledImage) + { + return type.image.ms; + } +@@ -93,8 +93,8 @@ static bool IsMultisample(const diligent_spirv_cross::Compiler& Compiler, + } + } + +-static uint32_t GetDecorationOffset(const diligent_spirv_cross::Compiler& Compiler, +- const diligent_spirv_cross::Resource& Res, ++static uint32_t GetDecorationOffset(const SPIRV_CROSS_NAMESPACE::Compiler& Compiler, ++ const SPIRV_CROSS_NAMESPACE::Resource& Res, + spv::Decoration Decoration) + { + VERIFY(Compiler.has_decoration(Res.id, Decoration), "Resource \'", Res.name, "\' has no requested decoration"); +@@ -105,8 +105,8 @@ static uint32_t GetDecorationOffset(const diligent_spirv_cross::Compiler& Compil + return offset; + } + +-SPIRVShaderResourceAttribs::SPIRVShaderResourceAttribs(const diligent_spirv_cross::Compiler& Compiler, +- const diligent_spirv_cross::Resource& Res, ++SPIRVShaderResourceAttribs::SPIRVShaderResourceAttribs(const SPIRV_CROSS_NAMESPACE::Compiler& Compiler, ++ const SPIRV_CROSS_NAMESPACE::Resource& Res, + const char* _Name, + ResourceType _Type, + Uint32 _BufferStaticSize, +@@ -222,9 +222,9 @@ spv::ExecutionModel ShaderTypeToSpvExecutionModel(SHADER_TYPE ShaderType) + } + } + +-const std::string& GetUBName(diligent_spirv_cross::Compiler& Compiler, +- const diligent_spirv_cross::Resource& UB, +- const diligent_spirv_cross::ParsedIR::Source& IRSource) ++const std::string& GetUBName(SPIRV_CROSS_NAMESPACE::Compiler& Compiler, ++ const SPIRV_CROSS_NAMESPACE::Resource& UB, ++ const SPIRV_CROSS_NAMESPACE::ParsedIR::Source& IRSource) + { + // Consider the following HLSL constant buffer: + // +@@ -269,11 +269,11 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, + m_ShaderType{shaderDesc.ShaderType} + { + // https://github.com/KhronosGroup/SPIRV-Cross/wiki/Reflection-API-user-guide +- diligent_spirv_cross::Parser parser(move(spirv_binary)); ++ SPIRV_CROSS_NAMESPACE::Parser parser(move(spirv_binary)); + parser.parse(); + const auto ParsedIRSource = parser.get_parsed_ir().source; + m_IsHLSLSource = ParsedIRSource.hlsl; +- diligent_spirv_cross::Compiler Compiler(std::move(parser.get_parsed_ir())); ++ SPIRV_CROSS_NAMESPACE::Compiler Compiler(std::move(parser.get_parsed_ir())); + + spv::ExecutionModel ExecutionModel = ShaderTypeToSpvExecutionModel(shaderDesc.ShaderType); + auto EntryPoints = Compiler.get_entry_points_and_stages(); +@@ -298,7 +298,7 @@ SPIRVShaderResources::SPIRVShaderResources(IMemoryAllocator& Allocator, + Compiler.set_entry_point(EntryPoint, ExecutionModel); + + // The SPIR-V is now parsed, and we can perform reflection on it. +- diligent_spirv_cross::ShaderResources resources = Compiler.get_shader_resources(); ++ SPIRV_CROSS_NAMESPACE::ShaderResources resources = Compiler.get_shader_resources(); + + size_t ResourceNamesPoolSize = 0; + for (const auto& ub : resources.uniform_buffers) diff --git a/recipes/diligent-core/all/patches/0006-install-linux-platform-header.diff b/recipes/diligent-core/all/patches/0006-install-linux-platform-header.diff new file mode 100644 index 0000000000000..a1af22db1a7f4 --- /dev/null +++ b/recipes/diligent-core/all/patches/0006-install-linux-platform-header.diff @@ -0,0 +1,120 @@ +commit 7b5536cfee83af507b9182ca7f8035b69d6af6bd +Author: assiduous +Date: Thu Feb 17 07:57:41 2022 -0800 + + CMake: added install instructions for required Linux platform headers for Apple, Emscriptent and Android (fixed DiligentGraphics/DiligentTools#161) + +diff --git a/Platforms/Android/CMakeLists.txt b/Platforms/Android/CMakeLists.txt +index 8d9ef237f..724e41faa 100644 +--- a/Platforms/Android/CMakeLists.txt ++++ b/Platforms/Android/CMakeLists.txt +@@ -8,6 +8,7 @@ set(INTERFACE + interface/AndroidPlatformDefinitions.h + interface/AndroidPlatformMisc.hpp + interface/AndroidNativeWindow.h ++ ../Linux/interface/LinuxPlatformMisc.hpp + ) + + set(SOURCE +@@ -34,8 +35,8 @@ PUBLIC + ) + + source_group("src" FILES ${SOURCE}) +-source_group("include" FILES ${INCLUDE}) +-source_group("interface" FILES ${PLATFORM_INTERFACE_HEADERS}) ++source_group("interface\\android" FILES ${INTERFACE}) ++source_group("interface\\common" FILES ${PLATFORM_INTERFACE_HEADERS}) + + set_target_properties(Diligent-AndroidPlatform PROPERTIES + FOLDER DiligentCore/Platforms +@@ -43,4 +44,9 @@ set_target_properties(Diligent-AndroidPlatform PROPERTIES + + if(DILIGENT_INSTALL_CORE) + install_core_lib(Diligent-AndroidPlatform) ++ ++ get_target_relative_dir(Diligent-AndroidPlatform RELATIVE_PATH) ++ install(DIRECTORY ../Linux/interface ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${RELATIVE_PATH}/../Linux" ++ ) + endif() +diff --git a/Platforms/Apple/CMakeLists.txt b/Platforms/Apple/CMakeLists.txt +index 643c06aac..2d0f19c6d 100644 +--- a/Platforms/Apple/CMakeLists.txt ++++ b/Platforms/Apple/CMakeLists.txt +@@ -16,6 +16,7 @@ set(INTERFACE + interface/AppleFileSystem.hpp + interface/ApplePlatformDefinitions.h + interface/ApplePlatformMisc.hpp ++ ../Linux/interface/LinuxPlatformMisc.hpp + ${APPLE_NATIVE_WINDOW_H} + ) + +@@ -61,8 +62,8 @@ elseif(PLATFORM_TVOS) + endif() + + source_group("src" FILES ${SOURCE}) +-source_group("include" FILES ${INCLUDE}) +-source_group("interface" FILES ${PLATFORM_INTERFACE_HEADERS}) ++source_group("interface\\apple" FILES ${INTERFACE}) ++source_group("interface\\common" FILES ${PLATFORM_INTERFACE_HEADERS}) + + set_target_properties(Diligent-ApplePlatform PROPERTIES + FOLDER DiligentCore/Platforms +@@ -70,4 +71,9 @@ set_target_properties(Diligent-ApplePlatform PROPERTIES + + if(DILIGENT_INSTALL_CORE) + install_core_lib(Diligent-ApplePlatform) ++ ++ get_target_relative_dir(Diligent-ApplePlatform RELATIVE_PATH) ++ install(DIRECTORY ../Linux/interface ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${RELATIVE_PATH}/../Linux" ++ ) + endif() +diff --git a/Platforms/Emscripten/CMakeLists.txt b/Platforms/Emscripten/CMakeLists.txt +index 9d19518d9..4012f6bc3 100644 +--- a/Platforms/Emscripten/CMakeLists.txt ++++ b/Platforms/Emscripten/CMakeLists.txt +@@ -8,6 +8,7 @@ set(INTERFACE + interface/EmscriptenPlatformDefinitions.h + interface/EmscriptenPlatformMisc.hpp + interface/EmscriptenNativeWindow.h ++ ../Linux/interface/LinuxPlatformMisc.hpp + ) + + set(SOURCE +@@ -32,8 +33,8 @@ PUBLIC + ) + + source_group("src" FILES ${SOURCE}) +-source_group("include" FILES ${INCLUDE}) +-source_group("interface" FILES ${PLATFORM_INTERFACE_HEADERS}) ++source_group("interface\\emscripten" FILES ${INTERFACE}) ++source_group("interface\\common" FILES ${PLATFORM_INTERFACE_HEADERS}) + + set_target_properties(Diligent-EmscriptenPlatform PROPERTIES + FOLDER DiligentCore/Platforms +@@ -41,4 +42,9 @@ set_target_properties(Diligent-EmscriptenPlatform PROPERTIES + + if(DILIGENT_INSTALL_CORE) + install_core_lib(Diligent-EmscriptenPlatform) ++ ++ get_target_relative_dir(Diligent-EmscriptenPlatform RELATIVE_PATH) ++ install(DIRECTORY ../Linux/interface ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${RELATIVE_PATH}/../Linux" ++ ) + endif() +diff --git a/Platforms/Linux/CMakeLists.txt b/Platforms/Linux/CMakeLists.txt +index 558673dd8..db113331c 100644 +--- a/Platforms/Linux/CMakeLists.txt ++++ b/Platforms/Linux/CMakeLists.txt +@@ -32,8 +32,8 @@ PUBLIC + ) + + source_group("src" FILES ${SOURCE}) +-source_group("include" FILES ${INCLUDE}) +-source_group("interface" FILES ${PLATFORM_INTERFACE_HEADERS}) ++source_group("interface\\linux" FILES ${INTERFACE}) ++source_group("interface\\common" FILES ${PLATFORM_INTERFACE_HEADERS}) + + set_target_properties(Diligent-LinuxPlatform PROPERTIES + FOLDER DiligentCore/Platforms diff --git a/recipes/diligent-core/all/patches/0007-API250014-remove_warning_as_error.patch b/recipes/diligent-core/all/patches/0007-API250014-remove_warning_as_error.patch new file mode 100644 index 0000000000000..caf983be16889 --- /dev/null +++ b/recipes/diligent-core/all/patches/0007-API250014-remove_warning_as_error.patch @@ -0,0 +1,30 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c527cc4cd..bc7de0420 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -304,7 +304,7 @@ if(MSVC) + # - w4100 - unreferenced formal parameter + # - w4201 - nonstandard extension used: nameless struct/union + # - w4505 - unreferenced local function has been removed +- target_compile_options(Diligent-BuildSettings INTERFACE /W4 /WX /wd4100 /wd4201 /wd4505 /MP) ++ target_compile_options(Diligent-BuildSettings INTERFACE /W1 /wd4100 /wd4201 /wd4505 /MP) + # In all release modes also: + # - disable w4189 - local variable is initialized but not referenced + # - Disable RTTI (/GR-) +@@ -351,7 +351,7 @@ endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(Diligent-BuildSettings INTERFACE + # All warnings are errors +- -Werror ++ + # Some extra warnings + -Wall -Wextra -Wuninitialized -Wconditional-uninitialized -Wextra-tokens -Wpointer-arith -Wloop-analysis -Wunused + # Disable few warnings +@@ -441,7 +441,6 @@ add_subdirectory(Primitives) + add_subdirectory(Platforms) + add_subdirectory(Common) + add_subdirectory(Graphics) +-add_subdirectory(Tests) + + + # Installation instructions diff --git a/recipes/diligent-core/all/patches/0009-API250014-use_conan_dependencies_in_third_party.patch b/recipes/diligent-core/all/patches/0009-API250014-use_conan_dependencies_in_third_party.patch new file mode 100644 index 0000000000000..28b9e92435870 --- /dev/null +++ b/recipes/diligent-core/all/patches/0009-API250014-use_conan_dependencies_in_third_party.patch @@ -0,0 +1,100 @@ +diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt +index d7eea08a..e457b9b6 100644 +--- a/ThirdParty/CMakeLists.txt ++++ b/ThirdParty/CMakeLists.txt +@@ -23,9 +23,6 @@ if(VULKAN_SUPPORTED OR METAL_SUPPORTED) + # do not really need any target from the project. + #add_subdirectory(SPIRV-Headers) + #set_directory_root_folder("SPIRV-Headers" "ThirdParty/DiligentCore/SPIRV-Headers") +- install(FILES SPIRV-Headers/LICENSE DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME SPIRV-Headers-License.txt) +- +- install(FILES Vulkan-Headers/LICENSE.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME Vulkan-Headers-License.txt) + + option(DILIGENT_NO_GLSLANG "Do NOT build glslang compiler" OFF) + option(DILIGENT_IMPROVE_SPIRV_TOOLS_DEBUG_PERF "Enable some optimizations for SPIRV-Tools, glslang, SPIRV-Cross and related projects in debug build to improve performance" ON) +@@ -41,15 +38,8 @@ if(VULKAN_SUPPORTED OR METAL_SUPPORTED) + set(SPIRV_CHECK_CONTEXT OFF CACHE BOOL "Do not check if the IR context is in a valid state") + endif() + set(CMAKE_MACOSX_RPATH TRUE) +- add_subdirectory(SPIRV-Tools) +- set_directory_root_folder("SPIRV-Tools" "DiligentCore/ThirdParty/SPIRV-Tools") + # We only need SPIRV-Tools-opt for glslang that also depends on SPIRV-Tools-static. + # Exclude all other targets from the build to save build time +- set(SPIRV_TOOLS_EXCLUDE_TARGETS SPIRV-Tools-link SPIRV-Tools-lint SPIRV-Tools-reduce SPIRV-Tools-shared) +- set_target_properties(${SPIRV_TOOLS_EXCLUDE_TARGETS} PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) +- +- set(THIRD_PARTY_LIBS SPIRV-Tools-static SPIRV-Tools-opt) +- install(FILES SPIRV-Tools/LICENSE DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME SPIRV-Tools-License.txt) + endif() + + if(NOT ${DILIGENT_NO_GLSLANG}) +@@ -57,14 +47,8 @@ if(VULKAN_SUPPORTED OR METAL_SUPPORTED) + set(ENABLE_SPVREMAPPER OFF CACHE BOOL "Do not build SPIRV remapper") + set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "Skip glslang installation") + set(ENABLE_CTEST OFF CACHE BOOL "Disable testing") +- add_subdirectory(glslang) +- set_directory_root_folder("glslang" "DiligentCore/ThirdParty/glslang") + + # glslang "kindly" sets global CMAKE_DEBUG_POSTFIX to "d", which we have to unset now +- unset(CMAKE_DEBUG_POSTFIX CACHE) +- +- list(APPEND THIRD_PARTY_LIBS GenericCodeGen glslang OGLCompiler OSDependent SPIRV HLSL MachineIndependent) +- install(FILES glslang/LICENSE.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME GLSLang-License.txt) + endif() + + set(SPIRV_CROSS_CLI OFF CACHE BOOL "Build the CLI binary. Requires SPIRV_CROSS_STATIC.") +@@ -80,37 +64,9 @@ if(VULKAN_SUPPORTED OR METAL_SUPPORTED) + set(SPIRV_CROSS_FORCE_PIC ON CACHE BOOL "Force position-independent code.") + set(SPIRV_CROSS_SKIP_INSTALL ON CACHE BOOL "Skip SPIRV-Cross installation.") + set(SPIRV_CROSS_NAMESPACE_OVERRIDE diligent_spirv_cross CACHE STRING "Override the namespace used in the C++ API.") +- add_subdirectory(SPIRV-Cross) +- set_directory_root_folder("SPIRV-Cross" "DiligentCore/ThirdParty/SPIRV-Cross") +- +- list(APPEND THIRD_PARTY_LIBS spirv-cross-core) +- if(METAL_SUPPORTED) +- list(APPEND THIRD_PARTY_LIBS spirv-cross-msl spirv-cross-glsl) +- endif() +- install(FILES SPIRV-Cross/LICENSE DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME SPIRV-Cross-License.txt) +- +- if(DILIGENT_INSTALL_CORE) +- install(TARGETS ${THIRD_PARTY_LIBS} +- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_CORE_DIR}/$" +- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_CORE_DIR}/$" +- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${DILIGENT_CORE_DIR}/$" +- ) +- endif() +- +- if(${DILIGENT_IMPROVE_SPIRV_TOOLS_DEBUG_PERF} AND MSVC) +- # Enable function inlining (/Ob1) in Debug build to improve shader compilation performance +- foreach(TARGET ${THIRD_PARTY_LIBS}) +- target_compile_options(${TARGET} PRIVATE "$<$:/Ob1>") +- endforeach() +- endif() +- ++ list(APPEND THIRD_PARTY_LIBS SPIRV-Tools-opt spirv-cross-msl spirv-cross-glsl glslang::SPIRV glslang::glslang glslang::MachineIndependent glslang::GenericCodeGen glslang::OSDependent glslang::OGLCompiler glslang::HLSL xxHash::xxhash) + # Make sure that symbols do not leak out when third-party + # libs are linked into shared libraries +- set_target_properties(${THIRD_PARTY_LIBS} PROPERTIES +- CXX_VISIBILITY_PRESET hidden # -fvisibility=hidden +- C_VISIBILITY_PRESET hidden # -fvisibility=hidden +- VISIBILITY_INLINES_HIDDEN TRUE +- ) + endif() + + if(${DILIGENT_BUILD_GOOGLE_TEST}) +@@ -127,15 +83,4 @@ if(${DILIGENT_BUILD_GOOGLE_TEST}) + endif() + + option(BUILD_SHARED_LIBS "Build shared library" OFF) +-set(XXHASH_BUILD_XXHSUM OFF) +-set(XXHASH_BUILD_ENABLE_INLINE_API OFF) +-add_subdirectory(xxHash/cmake_unofficial) +-set_directory_root_folder("xxHash/cmake_unofficial" "DiligentCore/ThirdParty/xxHash") + +-install(FILES xxHash/LICENSE DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME XXH3-License.txt) +-install(FILES googletest/LICENSE DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME googletest-License.txt) +-install(FILES stb/stb_image_write_license.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}") +-install(FILES volk/LICENSE.md DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME Volk-License.md) +-install(FILES DirectXShaderCompiler/LICENSE.TXT DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME DXC-License.txt) +-install(FILES DirectXShaderCompiler/ThirdPartyNotices.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME DXC-ThirdPartyNotices.txt) +-install(FILES xxHash/LICENSE DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME xxHash-License.txt) diff --git a/recipes/diligent-core/all/patches/0010-API250014-use_volk_from_conan.patch b/recipes/diligent-core/all/patches/0010-API250014-use_volk_from_conan.patch new file mode 100644 index 0000000000000..fd00b73de0f8b --- /dev/null +++ b/recipes/diligent-core/all/patches/0010-API250014-use_volk_from_conan.patch @@ -0,0 +1,40 @@ +diff --git a/Graphics/GraphicsEngineVulkan/CMakeLists.txt b/Graphics/GraphicsEngineVulkan/CMakeLists.txt +index 34451f2dd..d61797325 100644 +--- a/Graphics/GraphicsEngineVulkan/CMakeLists.txt ++++ b/Graphics/GraphicsEngineVulkan/CMakeLists.txt +@@ -165,7 +165,8 @@ target_include_directories(Diligent-GraphicsEngineVk-static + PRIVATE + include + ../../ThirdParty +- ../../ThirdParty/Vulkan-Headers/include ++${VulkanHeaders_INCLUDE_DIR} ++${volk_INCLUDE_DIR}/ + ) + + set(PRIVATE_DEPENDENCIES +diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h +index 50f25dcdd..cf1c301aa 100644 +--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h ++++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanHeaders.h +@@ -41,7 +41,7 @@ + #define VK_FORMAT_RANGE_SIZE (VK_FORMAT_ASTC_12x12_SRGB_BLOCK - VK_FORMAT_UNDEFINED + 1) + + #if DILIGENT_USE_VOLK +-# include "volk/volk.h" ++# include "volk.h" + #endif + + #if PLATFORM_WIN32 +diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp +index bd293feb2..6b42a243e 100644 +--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp ++++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp +@@ -34,7 +34,7 @@ + + #if DILIGENT_USE_VOLK + # define VOLK_IMPLEMENTATION +-# include "volk/volk.h" ++# include "volk.h" + #endif + + #include "VulkanErrors.hpp" diff --git a/recipes/diligent-core/all/patches/0013-API250014-use-vulkan-headers-in-archiver.patch b/recipes/diligent-core/all/patches/0013-API250014-use-vulkan-headers-in-archiver.patch new file mode 100644 index 0000000000000..c6f5c58e9c39c --- /dev/null +++ b/recipes/diligent-core/all/patches/0013-API250014-use-vulkan-headers-in-archiver.patch @@ -0,0 +1,14 @@ +diff --git a/Graphics/Archiver/CMakeLists.txt b/Graphics/Archiver/CMakeLists.txt +index 1552937ce..73c77158e 100644 +--- a/Graphics/Archiver/CMakeLists.txt ++++ b/Graphics/Archiver/CMakeLists.txt +@@ -116,7 +116,8 @@ if(VULKAN_SUPPORTED) + target_include_directories(Diligent-Archiver-static + PRIVATE + ../GraphicsEngineVulkan/include +- ../../ThirdParty/Vulkan-Headers/include ++ ${VulkanHeaders_INCLUDE_DIR} ++ ${volk_INCLUDE_DIR}/ + ) + endif() + diff --git a/recipes/diligent-core/all/patches/0014-252-exclude-tests.patch b/recipes/diligent-core/all/patches/0014-252-exclude-tests.patch new file mode 100644 index 0000000000000..e9b971b287199 --- /dev/null +++ b/recipes/diligent-core/all/patches/0014-252-exclude-tests.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 88c4ba53..0b094735 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -446,7 +446,7 @@ add_subdirectory(Primitives) + add_subdirectory(Platforms) + add_subdirectory(Common) + add_subdirectory(Graphics) +-add_subdirectory(Tests) ++#add_subdirectory(Tests) + + + # Installation instructions diff --git a/recipes/diligent-core/all/patches/0015-252-dont-install-3d-party-license.patch b/recipes/diligent-core/all/patches/0015-252-dont-install-3d-party-license.patch new file mode 100644 index 0000000000000..2b626adc16205 --- /dev/null +++ b/recipes/diligent-core/all/patches/0015-252-dont-install-3d-party-license.patch @@ -0,0 +1,78 @@ +diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt +index a77ab3d7..86606aeb 100644 +--- a/ThirdParty/CMakeLists.txt ++++ b/ThirdParty/CMakeLists.txt +@@ -15,7 +15,6 @@ if (GL_SUPPORTED AND (PLATFORM_WIN32 OR PLATFORM_LINUX OR PLATFORM_MACOS) AND (N + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${DILIGENT_CORE_DIR}/$" + ) + endif() +- install(FILES glew/LICENSE.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME GLEW-License.txt) + endif() + + if (VULKAN_SUPPORTED OR METAL_SUPPORTED) +@@ -26,7 +25,6 @@ if (VULKAN_SUPPORTED OR METAL_SUPPORTED) + # Note that SPIRV-Headers_SOURCE_DIR variable is normally created by project(SPIRV-Headers) + set(SPIRV-Headers_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/SPIRV-Headers") + target_include_directories(SPIRV-Headers INTERFACE "${SPIRV-Headers_SOURCE_DIR}/include") +- install(FILES "${SPIRV-Headers_SOURCE_DIR}/LICENSE" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME SPIRV-Headers-License.txt) + endif() + + if (NOT TARGET Vulkan::Headers) +@@ -37,7 +35,6 @@ if (VULKAN_SUPPORTED OR METAL_SUPPORTED) + set(Vulkan-Headers_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers") + add_library(Vulkan::Headers ALIAS Vulkan-Headers) + target_include_directories(Vulkan-Headers INTERFACE "${Vulkan-Headers_SOURCE_DIR}/include") +- install(FILES "${Vulkan-Headers_SOURCE_DIR}/LICENSE.txt" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME Vulkan-Headers-License.txt) + endif() + + option(DILIGENT_NO_GLSLANG "Do NOT build glslang compiler" OFF) +@@ -61,7 +58,6 @@ if (VULKAN_SUPPORTED OR METAL_SUPPORTED) + set_target_properties(${SPIRV_TOOLS_EXCLUDE_TARGETS} PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) + + set(THIRD_PARTY_LIBS SPIRV-Tools-static SPIRV-Tools-opt) +- install(FILES "${spirv-tools_SOURCE_DIR}/LICENSE" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME SPIRV-Tools-License.txt) + endif() + + if (NOT ${DILIGENT_NO_GLSLANG} AND (NOT TARGET glslang)) +@@ -76,7 +72,6 @@ if (VULKAN_SUPPORTED OR METAL_SUPPORTED) + unset(CMAKE_DEBUG_POSTFIX CACHE) + + list(APPEND THIRD_PARTY_LIBS GenericCodeGen glslang OGLCompiler OSDependent SPIRV HLSL MachineIndependent) +- install(FILES "${glslang_SOURCE_DIR}/LICENSE.txt" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME GLSLang-License.txt) + endif() + + if (NOT TARGET spirv-cross-core) +@@ -101,7 +96,6 @@ if (VULKAN_SUPPORTED OR METAL_SUPPORTED) + list(APPEND THIRD_PARTY_LIBS spirv-cross-msl spirv-cross-glsl) + endif() + +- install(FILES "${SPIRV-Cross_SOURCE_DIR}/LICENSE" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME SPIRV-Cross-License.txt) + endif() + + if (DILIGENT_INSTALL_CORE) +@@ -138,7 +132,6 @@ if (VULKAN_SUPPORTED AND (PLATFORM_WIN32 OR PLATFORM_LINUX OR PLATFORM_MACOS OR + EXCLUDE_FROM_DEFAULT_BUILD 1 + FOLDER "DiligentCore/ThirdParty/volk" + ) +- install(FILES "${volk_SOURCE_DIR}/LICENSE.md" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME Volk-License.md) + endif() + + if ((${DILIGENT_BUILD_GOOGLE_TEST}) AND (NOT TARGET gtest)) +@@ -154,7 +147,6 @@ if ((${DILIGENT_BUILD_GOOGLE_TEST}) AND (NOT TARGET gtest)) + ) + + get_target_property(GTEST_SOURCE_DIR gtest SOURCE_DIR) +- install(FILES "googletest/LICENSE" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME googletest-License.txt) + endif() + + if (NOT TARGET xxHash::xxhash) +@@ -163,9 +155,6 @@ if (NOT TARGET xxHash::xxhash) + set(XXHASH_BUILD_ENABLE_INLINE_API OFF) + add_subdirectory(xxHash/cmake_unofficial) + set_directory_root_folder("xxHash/cmake_unofficial" "DiligentCore/ThirdParty/xxHash") +- install(FILES "${xxHash_SOURCE_DIR}/../LICENSE" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME xxHash-License.txt) + endif() + +-install(FILES stb/stb_image_write_license.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}") +-install(FILES DirectXShaderCompiler/LICENSE.TXT DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME DXC-License.txt) + install(FILES DirectXShaderCompiler/ThirdPartyNotices.txt DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME DXC-ThirdPartyNotices.txt) diff --git a/recipes/diligent-core/all/patches/0016-252-fix-glslang-usage.patch b/recipes/diligent-core/all/patches/0016-252-fix-glslang-usage.patch new file mode 100644 index 0000000000000..72d343355ab43 --- /dev/null +++ b/recipes/diligent-core/all/patches/0016-252-fix-glslang-usage.patch @@ -0,0 +1,28 @@ +diff --git a/Graphics/ShaderTools/CMakeLists.txt b/Graphics/ShaderTools/CMakeLists.txt +index c2dd85f3..cc83e707 100644 +--- a/Graphics/ShaderTools/CMakeLists.txt ++++ b/Graphics/ShaderTools/CMakeLists.txt +@@ -150,8 +150,8 @@ if(ENABLE_SPIRV) + if (${USE_GLSLANG}) + target_link_libraries(Diligent-ShaderTools + PRIVATE +- SPIRV +- glslang ++ SPIRV-Tools-opt ++ glslang::SPIRV glslang::glslang glslang::MachineIndependent glslang::GenericCodeGen glslang::OSDependent glslang::OGLCompiler glslang::HLSL + ) + endif() + endif() +diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt +index 86606aeb..f2d84497 100644 +--- a/ThirdParty/CMakeLists.txt ++++ b/ThirdParty/CMakeLists.txt +@@ -60,7 +60,7 @@ if (VULKAN_SUPPORTED OR METAL_SUPPORTED) + set(THIRD_PARTY_LIBS SPIRV-Tools-static SPIRV-Tools-opt) + endif() + +- if (NOT ${DILIGENT_NO_GLSLANG} AND (NOT TARGET glslang)) ++ if (NOT ${DILIGENT_NO_GLSLANG} AND (NOT TARGET glslang::glslang)) + set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "Do not build glslang binaries") + set(ENABLE_SPVREMAPPER OFF CACHE BOOL "Do not build SPIRV remapper") + set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "Skip glslang installation") diff --git a/recipes/diligent-core/all/patches/0017-252-fix-glslang-include.patch b/recipes/diligent-core/all/patches/0017-252-fix-glslang-include.patch new file mode 100644 index 0000000000000..592bf3d4e8cf9 --- /dev/null +++ b/recipes/diligent-core/all/patches/0017-252-fix-glslang-include.patch @@ -0,0 +1,13 @@ +diff --git a/Graphics/ShaderTools/src/GLSLangUtils.cpp b/Graphics/ShaderTools/src/GLSLangUtils.cpp +index eb2f4a9a..085bc61b 100644 +--- a/Graphics/ShaderTools/src/GLSLangUtils.cpp ++++ b/Graphics/ShaderTools/src/GLSLangUtils.cpp +@@ -34,7 +34,7 @@ + # include + #else + # define ENABLE_HLSL +-# include "SPIRV/GlslangToSpv.h" ++# include + #endif + + #include "GLSLangUtils.hpp" diff --git a/recipes/diligent-core/all/patches/0018-252-fix-warning-as-error.patch b/recipes/diligent-core/all/patches/0018-252-fix-warning-as-error.patch new file mode 100644 index 0000000000000..8c5572bcaa2b4 --- /dev/null +++ b/recipes/diligent-core/all/patches/0018-252-fix-warning-as-error.patch @@ -0,0 +1,21 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0b094735..de80eb1e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -304,7 +304,7 @@ if(MSVC) + # - w4100 - unreferenced formal parameter + # - w4201 - nonstandard extension used: nameless struct/union + # - w4505 - unreferenced local function has been removed +- target_compile_options(Diligent-BuildSettings INTERFACE /W4 /WX /wd4100 /wd4201 /wd4505 /MP) ++ target_compile_options(Diligent-BuildSettings INTERFACE /W1 /wd4100 /wd4201 /wd4505 /MP) + # In all release modes also: + # - disable w4189 - local variable is initialized but not referenced + # - Disable RTTI (/GR-) +@@ -353,7 +353,6 @@ endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(Diligent-BuildSettings INTERFACE + # All warnings are errors +- -Werror + # Some extra warnings + -Wall -Wextra -Wuninitialized -Wconditional-uninitialized -Wextra-tokens -Wpointer-arith -Wloop-analysis -Wunused + # Disable few warnings diff --git a/recipes/diligent-core/all/patches/0023-252003-fix-warning-as-error.patch b/recipes/diligent-core/all/patches/0023-252003-fix-warning-as-error.patch new file mode 100644 index 0000000000000..9f05a87c6d918 --- /dev/null +++ b/recipes/diligent-core/all/patches/0023-252003-fix-warning-as-error.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -362,7 +362,7 @@ endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(Diligent-BuildSettings INTERFACE + # All warnings are errors +- -Werror ++ + # Some extra warnings + -Wall -Wextra -Wuninitialized -Wconditional-uninitialized -Wextra-tokens -Wpointer-arith -Wloop-analysis -Wunused + # Disable few warnings diff --git a/recipes/diligent-core/all/test_package/CMakeLists.txt b/recipes/diligent-core/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..927e85d16c3ed --- /dev/null +++ b/recipes/diligent-core/all/test_package/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +if(WIN32) + set(FILE2STRING_PATH "${CONAN_BIN_DIRS_DILIGENT-CORE}/File2String.exe") +else() + set(FILE2STRING_PATH "${CONAN_BIN_DIRS_DILIGENT-CORE}/File2String") +endif() + +set(FILE "${CONAN_RES_DIRS_DILIGENT}/HLSLDefinitions.fxh") +set(CONVERTED_FILE "${PROJECT_BINARY_DIR}/HLSLDefinitions.h") + +add_custom_command(OUTPUT ${CONVERTED_FILE} + COMMAND ${FILE2STRING_PATH} ${FILE} ${CONVERTED_FILE} + MAIN_DEPENDENCY ${FILE} # the primary input source file to the command + COMMENT "Processing shader ${FILE}" + VERBATIM) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/diligent-core/all/test_package/conanfile.py b/recipes/diligent-core/all/test_package/conanfile.py new file mode 100644 index 0000000000000..f2355b8294daf --- /dev/null +++ b/recipes/diligent-core/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os +from conan.tools.build import cross_building + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/diligent-core/all/test_package/test_package.cpp b/recipes/diligent-core/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..797079ee15abf --- /dev/null +++ b/recipes/diligent-core/all/test_package/test_package.cpp @@ -0,0 +1,43 @@ +#include + +#include "Common/interface/RefCntAutoPtr.hpp" +#include "Graphics/GraphicsEngine/interface/PipelineState.h" +#include "Graphics/GraphicsEngine/interface/SwapChain.h" +#include "Graphics/GraphicsEngine/interface/DeviceContext.h" +#include "Graphics/GraphicsEngine/interface/RenderDevice.h" + +int main() +{ +#ifdef PLATFORM_WIN32 + std::cout << "PLATFORM_WIN32: " << PLATFORM_WIN32; +#endif + +#ifdef PLATFORM_MACOS + std::cout << "PLATFORM_MACOS: " << PLATFORM_MACOS; +#endif + +#ifdef PLATFORM_LINUX + std::cout << "PLATFORM_LINUX: " << PLATFORM_LINUX; +#endif + +#ifdef PLATFORM_ANDROID + std::cout << "PLATFORM_ANDROID: " << PLATFORM_ANDROID; +#endif + +#ifdef PLATFORM_IOS + std::cout << "PLATFORM_IOS: " << PLATFORM_IOS; +#endif + +#ifdef PLATFORM_EMSCRIPTEN + std::cout << "PLATFORM_EMSCRIPTEN: " << PLATFORM_EMSCRIPTEN; +#endif + +#ifdef PLATFORM_TVOS + std::cout << "PLATFORM_TVOS: " << PLATFORM_TVOS; +#endif + + Diligent::RefCntAutoPtr _pDevice; + Diligent::RefCntAutoPtr _pImmediateContext; + Diligent::RefCntAutoPtr _pSwapChain; + return 0; +} diff --git a/recipes/diligent-core/config.yml b/recipes/diligent-core/config.yml new file mode 100644 index 0000000000000..fbdb8d06e169e --- /dev/null +++ b/recipes/diligent-core/config.yml @@ -0,0 +1,15 @@ +versions: + "api.252009": + folder: "all" + "api.252005": + folder: "all" + "api.252004": + folder: "all" + "api.252003": + folder: "all" + "2.5.2": + folder: "all" + "2.5.1": + folder: "all" + "api.250014": + folder: "all" diff --git a/recipes/diligent-fx/all/BuildUtils.cmake b/recipes/diligent-fx/all/BuildUtils.cmake new file mode 100644 index 0000000000000..baedd17d66435 --- /dev/null +++ b/recipes/diligent-fx/all/BuildUtils.cmake @@ -0,0 +1,399 @@ +if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS) + + function(copy_required_dlls TARGET_NAME) + if(D3D11_SUPPORTED) + list(APPEND ENGINE_DLLS Diligent-GraphicsEngineD3D11-shared) + endif() + if(D3D12_SUPPORTED) + list(APPEND ENGINE_DLLS Diligent-GraphicsEngineD3D12-shared) + endif() + if(GL_SUPPORTED) + list(APPEND ENGINE_DLLS Diligent-GraphicsEngineOpenGL-shared) + endif() + if(VULKAN_SUPPORTED) + list(APPEND ENGINE_DLLS Diligent-GraphicsEngineVk-shared) + endif() + if(METAL_SUPPORTED) + list(APPEND ENGINE_DLLS Diligent-GraphicsEngineMetal-shared) + endif() + + foreach(DLL ${ENGINE_DLLS}) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "\"$\"" + "\"$\"") + endforeach(DLL) + + # Copy D3Dcompiler_47.dll, dxcompiler.dll, and dxil.dll + if(MSVC) + if ((D3D11_SUPPORTED OR D3D12_SUPPORTED) AND VS_D3D_COMPILER_PATH) + # Note that VS_D3D_COMPILER_PATH can only be used in a Visual Studio command + # and is not a valid path during CMake configuration + list(APPEND SHADER_COMPILER_DLLS ${VS_D3D_COMPILER_PATH}) + endif() + + if(D3D12_SUPPORTED AND VS_DXC_COMPILER_PATH AND VS_DXIL_SIGNER_PATH) + # For the compiler to sign the bytecode, you have to have a copy of dxil.dll in + # the same folder as the dxcompiler.dll at runtime. + + # Note that VS_DXC_COMPILER_PATH and VS_DXIL_SIGNER_PATH can only be used in a Visual Studio command + # and are not valid paths during CMake configuration + list(APPEND SHADER_COMPILER_DLLS ${VS_DXC_COMPILER_PATH}) + list(APPEND SHADER_COMPILER_DLLS ${VS_DXIL_SIGNER_PATH}) + endif() + + foreach(DLL ${SHADER_COMPILER_DLLS}) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DLL} + "\"$\"") + endforeach(DLL) + + if(D3D12_SUPPORTED AND EXISTS ${DILIGENT_PIX_EVENT_RUNTIME_DLL_PATH}) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DILIGENT_PIX_EVENT_RUNTIME_DLL_PATH} + "\"$\"") + endif() + + if(VULKAN_SUPPORTED) + if(NOT DEFINED DILIGENT_DXCOMPILER_FOR_SPIRV_PATH) + message(FATAL_ERROR "DILIGENT_DXCOMPILER_FOR_SPIRV_PATH is undefined, check order of cmake includes") + endif() + if(EXISTS ${DILIGENT_DXCOMPILER_FOR_SPIRV_PATH}) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DILIGENT_DXCOMPILER_FOR_SPIRV_PATH} + "\"$/spv_dxcompiler.dll\"") + endif() + endif() + endif() + endfunction() + + function(package_required_dlls TARGET_NAME) + if(D3D12_SUPPORTED AND VS_DXC_COMPILER_PATH AND VS_DXIL_SIGNER_PATH) + # Copy the dlls to the project's CMake binary dir + + # Note that VS_DXC_COMPILER_PATH and VS_DXIL_SIGNER_PATH can only be used in a Visual Studio command + # and are not valid paths during CMake configuration + add_custom_command(TARGET ${TARGET_NAME} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${VS_DXC_COMPILER_PATH} + "\"${CMAKE_CURRENT_BINARY_DIR}/dxcompiler.dll\"" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${VS_DXIL_SIGNER_PATH} + "\"${CMAKE_CURRENT_BINARY_DIR}/dxil.dll\"") + set(DLLS "${CMAKE_CURRENT_BINARY_DIR}/dxcompiler.dll" "${CMAKE_CURRENT_BINARY_DIR}/dxil.dll") + + # Add the dlls to the target project as source files + target_sources(${TARGET_NAME} PRIVATE ${DLLS}) + + # Label them as content + set_source_files_properties(${DLLS} PROPERTIES + GENERATED TRUE + VS_DEPLOYMENT_CONTENT 1 + VS_DEPLOYMENT_LOCATION ".") + endif() + endfunction() + + # Set dll output name by adding _{32|64}{r|d} suffix + function(set_dll_output_name TARGET_NAME OUTPUT_NAME_WITHOUT_SUFFIX) + foreach(DBG_CONFIG ${DEBUG_CONFIGURATIONS}) + set_target_properties(${TARGET_NAME} PROPERTIES + OUTPUT_NAME_${DBG_CONFIG} ${OUTPUT_NAME_WITHOUT_SUFFIX}${DLL_DBG_SUFFIX} + ) + endforeach() + + foreach(REL_CONFIG ${RELEASE_CONFIGURATIONS}) + set_target_properties(${TARGET_NAME} PROPERTIES + OUTPUT_NAME_${REL_CONFIG} ${OUTPUT_NAME_WITHOUT_SUFFIX}${DLL_REL_SUFFIX} + ) + endforeach() + endfunction() + +endif(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS) + + +function(set_common_target_properties TARGET) + + if(COMMAND custom_pre_configure_target) + custom_pre_configure_target(${TARGET}) + if(TARGET_CONFIGURATION_COMPLETE) + return() + endif() + endif() + + get_target_property(TARGET_TYPE ${TARGET} TYPE) + + if(MSVC) + # For msvc, enable link-time code generation for release builds (I was not able to + # find any way to set these settings through interface library BuildSettings) + if(TARGET_TYPE STREQUAL STATIC_LIBRARY) + + foreach(REL_CONFIG ${RELEASE_CONFIGURATIONS}) + set_target_properties(${TARGET} PROPERTIES + STATIC_LIBRARY_FLAGS_${REL_CONFIG} /LTCG + ) + endforeach() + + else() + + foreach(REL_CONFIG ${RELEASE_CONFIGURATIONS}) + set_target_properties(${TARGET} PROPERTIES + LINK_FLAGS_${REL_CONFIG} "/LTCG /OPT:REF /INCREMENTAL:NO" + ) + endforeach() + + if(PLATFORM_UNIVERSAL_WINDOWS) + # On UWP, disable incremental link to avoid linker warnings + foreach(DBG_CONFIG ${DEBUG_CONFIGURATIONS}) + set_target_properties(${TARGET} PROPERTIES + LINK_FLAGS_${DBG_CONFIG} "/INCREMENTAL:NO" + ) + endforeach() + endif() + endif() + else() + set_target_properties(${TARGET} PROPERTIES + CXX_VISIBILITY_PRESET hidden # -fvisibility=hidden + C_VISIBILITY_PRESET hidden # -fvisibility=hidden + VISIBILITY_INLINES_HIDDEN TRUE + + # Without -fPIC option GCC fails to link static libraries into dynamic library: + # -fPIC + # If supported for the target machine, emit position-independent code, suitable for + # dynamic linking and avoiding any limit on the size of the global offset table. + POSITION_INDEPENDENT_CODE ON + + # It is crucial to set CXX_STANDARD flag to only affect c++ files and avoid failures compiling c-files: + # error: invalid argument '-std=c++14' not allowed with 'C/ObjC' + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON + + C_STANDARD 11 + ) + + if(NOT MINGW_BUILD) + # Do not disable extensions when building with MinGW! + set_target_properties(${TARGET} PROPERTIES + CXX_EXTENSIONS OFF + ) + endif() + endif() + + if(COMMAND custom_post_configure_target) + custom_post_configure_target(${TARGET}) + endif() + +endfunction() + +function(find_targets_in_directory _RESULT _DIR) + get_property(_subdirs DIRECTORY "${_DIR}" PROPERTY SUBDIRECTORIES) + foreach(_subdir IN LISTS _subdirs) + find_targets_in_directory(${_RESULT} "${_subdir}") + endforeach() + get_property(_SUB_TARGETS DIRECTORY "${_DIR}" PROPERTY BUILDSYSTEM_TARGETS) + set(${_RESULT} ${${_RESULT}} ${_SUB_TARGETS} PARENT_SCOPE) +endfunction() + +function(set_directory_root_folder _DIRECTORY _ROOT_FOLDER) + find_targets_in_directory(_TARGETS ${_DIRECTORY}) + foreach(_TARGET IN LISTS _TARGETS) + get_target_property(_FOLDER ${_TARGET} FOLDER) + if(_FOLDER) + set_target_properties(${_TARGET} PROPERTIES FOLDER "${_ROOT_FOLDER}/${_FOLDER}") + else() + set_target_properties(${_TARGET} PROPERTIES FOLDER "${_ROOT_FOLDER}") + endif() + endforeach() +endfunction() + + +# Returns default backend library type (static/dynamic) for the current platform +function(get_backend_libraries_type _LIB_TYPE) + if(PLATFORM_WIN32 OR PLATFORM_LINUX OR PLATFORM_ANDROID OR PLATFORM_UNIVERSAL_WINDOWS OR PLATFORM_MACOS) + set(LIB_TYPE "shared") + elseif(PLATFORM_IOS OR PLATFORM_TVOS OR PLATFORM_EMSCRIPTEN) + # Statically link with the engine on iOS, tvOS and Emscripten. + # It is also possible to link dynamically by + # putting the library into the framework. + set(LIB_TYPE "static") + else() + message(FATAL_ERROR "Undefined platform") + endif() + set(${_LIB_TYPE} ${LIB_TYPE} PARENT_SCOPE) +endfunction() + + +# Adds the list of supported backend targets to variable ${_TARGETS} in parent scope. +# Second argument to the function may override the target type (static/dynamic). If It +# is not given, default target type for the platform is used. +function(get_supported_backends _TARGETS) + if(${ARGC} GREATER 1) + set(LIB_TYPE ${ARGV1}) + else() + get_backend_libraries_type(LIB_TYPE) + endif() + + if(D3D11_SUPPORTED) + list(APPEND BACKENDS Diligent-GraphicsEngineD3D11-${LIB_TYPE}) + endif() + if(D3D12_SUPPORTED) + list(APPEND BACKENDS Diligent-GraphicsEngineD3D12-${LIB_TYPE}) + endif() + if(GL_SUPPORTED OR GLES_SUPPORTED) + list(APPEND BACKENDS Diligent-GraphicsEngineOpenGL-${LIB_TYPE}) + endif() + if(VULKAN_SUPPORTED) + list(APPEND BACKENDS Diligent-GraphicsEngineVk-${LIB_TYPE}) + endif() + if(METAL_SUPPORTED) + list(APPEND BACKENDS Diligent-GraphicsEngineMetal-${LIB_TYPE}) + endif() + # ${_TARGETS} == ENGINE_LIBRARIES + # ${${_TARGETS}} == ${ENGINE_LIBRARIES} + set(${_TARGETS} ${${_TARGETS}} ${BACKENDS} PARENT_SCOPE) +endfunction() + + +# Returns path to the target relative to CMake root +function(get_target_relative_dir _TARGET _DIR) + get_target_property(TARGET_SOURCE_DIR ${_TARGET} SOURCE_DIR) + file(RELATIVE_PATH TARGET_RELATIVE_PATH "${CMAKE_SOURCE_DIR}" "${TARGET_SOURCE_DIR}") + set(${_DIR} ${TARGET_RELATIVE_PATH} PARENT_SCOPE) +endfunction() + +# Performs installation steps for the core library +function(install_core_lib _TARGET) + get_target_relative_dir(${_TARGET} TARGET_RELATIVE_PATH) + + get_target_property(TARGET_TYPE ${_TARGET} TYPE) + if(TARGET_TYPE STREQUAL STATIC_LIBRARY) + list(APPEND DILIGENT_CORE_INSTALL_LIBS_LIST ${_TARGET}) + set(DILIGENT_CORE_INSTALL_LIBS_LIST ${DILIGENT_CORE_INSTALL_LIBS_LIST} CACHE INTERNAL "Core libraries installation list") + elseif(TARGET_TYPE STREQUAL SHARED_LIBRARY) + install(TARGETS ${_TARGET} + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_CORE_DIR}/$" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_CORE_DIR}/$" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${DILIGENT_CORE_DIR}/$" + ) + if (DILIGENT_INSTALL_PDB) + install(FILES $ DESTINATION "${CMAKE_INSTALL_BINDIR}/${DILIGENT_CORE_DIR}/$" OPTIONAL) + endif() + endif() + + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/interface") + install(DIRECTORY interface + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${TARGET_RELATIVE_PATH}/" + ) + endif() +endfunction() + + +function(install_combined_static_lib COMBINED_LIB_NAME LIBS_LIST CUSTOM_TARGET_NAME CUSTOM_TARGET_FOLDER INSTALL_DESTINATION) + + foreach(LIB ${LIBS_LIST}) + list(APPEND COMBINED_LIB_TARGET_FILES $) + endforeach(LIB) + + if(MSVC) + add_custom_command( + OUTPUT ${COMBINED_LIB_NAME} + COMMAND lib.exe /OUT:${COMBINED_LIB_NAME} ${COMBINED_LIB_TARGET_FILES} + DEPENDS ${LIBS_LIST} + COMMENT "Combining libraries..." + ) + add_custom_target(${CUSTOM_TARGET_NAME} ALL DEPENDS ${COMBINED_LIB_NAME}) + else() + + if(PLATFORM_WIN32) + # do NOT use stock ar on MinGW + find_program(AR NAMES x86_64-w64-mingw32-gcc-ar) + else() + set(AR ${CMAKE_AR}) + endif() + + if(AR) + add_custom_command( + OUTPUT ${COMBINED_LIB_NAME} + # Delete all object files from current directory + COMMAND ${CMAKE_COMMAND} -E remove "*${CMAKE_C_OUTPUT_EXTENSION}" + DEPENDS ${LIBS_LIST} + COMMENT "Combining libraries..." + ) + + # Unpack all object files from all targets to current directory + foreach(LIB_TARGET ${COMBINED_LIB_TARGET_FILES}) + add_custom_command( + OUTPUT ${COMBINED_LIB_NAME} + COMMAND ${AR} -x ${LIB_TARGET} + APPEND + ) + endforeach() + + # Pack object files to a combined library and delete them + add_custom_command( + OUTPUT ${COMBINED_LIB_NAME} + COMMAND ${AR} -crs ${COMBINED_LIB_NAME} "*${CMAKE_C_OUTPUT_EXTENSION}" + COMMAND ${CMAKE_COMMAND} -E remove "*${CMAKE_C_OUTPUT_EXTENSION}" + APPEND + ) + + add_custom_target(${CUSTOM_TARGET_NAME} ALL DEPENDS ${COMBINED_LIB_NAME}) + else() + message("ar command is not found") + endif() + endif() + + if(TARGET ${CUSTOM_TARGET_NAME}) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${COMBINED_LIB_NAME}" + DESTINATION ${INSTALL_DESTINATION} + ) + set_target_properties(${CUSTOM_TARGET_NAME} PROPERTIES + FOLDER ${CUSTOM_TARGET_FOLDER} + ) + else() + message("Unable to find librarian tool. Combined ${COMBINED_LIB_NAME} static library will not be produced.") + endif() + +endfunction() + + + + +function(add_format_validation_target MODULE_NAME MODULE_ROOT_PATH IDE_FOLDER) + + if(${DILIGENT_NO_FORMAT_VALIDATION}) + return() + endif() + + # Start by copying .clang-format file to the module's root folder + add_custom_target(${MODULE_NAME}-ValidateFormatting ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${DILIGENT_CORE_SOURCE_DIR}/.clang-format" "${MODULE_ROOT_PATH}/.clang-format" + ) + + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(RUN_VALIDATION_SCRIPT validate_format_win.bat) + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") + set(RUN_VALIDATION_SCRIPT ./validate_format_linux.sh) + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + set(RUN_VALIDATION_SCRIPT ./validate_format_mac.sh) + else() + message(FATAL_ERROR "Unexpected host system") + endif() + + # Run the format validation script + add_custom_command(TARGET ${MODULE_NAME}-ValidateFormatting + COMMAND ${RUN_VALIDATION_SCRIPT} + WORKING_DIRECTORY "${MODULE_ROOT_PATH}/BuildTools/FormatValidation" + COMMENT "Validating ${MODULE_NAME} module's source code formatting..." + VERBATIM + ) + + if(TARGET ${MODULE_NAME}-ValidateFormatting) + set_target_properties(${MODULE_NAME}-ValidateFormatting PROPERTIES FOLDER ${IDE_FOLDER}) + endif() + +endfunction() + + diff --git a/recipes/diligent-fx/all/CMakeLists.txt b/recipes/diligent-fx/all/CMakeLists.txt new file mode 100644 index 0000000000000..f624602d00651 --- /dev/null +++ b/recipes/diligent-fx/all/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.2) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(diligent-core) +find_package(diligent-tools) + +find_package(PythonInterp 3 REQUIRED) +set(FILE2STRING_PATH "${CMAKE_CURRENT_SOURCE_DIR}/script.py" CACHE INTERNAL "File2String utility") + +include(BuildUtils.cmake) +add_subdirectory(source_subfolder) diff --git a/recipes/diligent-fx/all/conandata.yml b/recipes/diligent-fx/all/conandata.yml new file mode 100644 index 0000000000000..c9711b69e2711 --- /dev/null +++ b/recipes/diligent-fx/all/conandata.yml @@ -0,0 +1,32 @@ +sources: + "api.252009": + url: "https://github.com/DiligentGraphics/DiligentFX/archive/refs/tags/API252009.tar.gz" + sha256: "4a7822e21d07d018fb5436fb286c552e160847ba5104561c17af6e86fa837c7d" + "api.252005": + url: "https://github.com/DiligentGraphics/DiligentFX/archive/refs/tags/API252005.tar.gz" + sha256: "1f6b4e0e81a8300ebd89bbf1a94d73b508e7c0b2e1170c3f9faa9d22645d19dd" + "2.5.2": + url: "https://github.com/DiligentGraphics/DiligentFX/archive/refs/tags/v2.5.2.tar.gz" + sha256: "2875e7d1e449c32c3c10a7f563cc5b3ad56b3465374dec2a9ed598411ab3b65f" + "cci.20211112": + url: "https://github.com/DiligentGraphics/DiligentFX/archive/d2f70a5107f51800e84b08072ec72dfbc0144529.tar.gz" + sha256: "0ce506bc1d509551468cc7e109f76fb7beeecf90238e93cc30c129b5ebc9f28d" + "cci.20220219": + url: "https://github.com/DiligentGraphics/DiligentFX/archive/3757c8c99141400e0d215e0bb8865eef404a5488.tar.gz" + sha256: "09f347dc00b968f3ccc383bb3e9af0e9197641f1ba7a5d22652a1cee5552786a" +patches: + "api.252009": + - patch_file: "patches/0001-use-conan-dependencies.diff" + base_path: "source_subfolder" + "api.252005": + - patch_file: "patches/0001-use-conan-dependencies.diff" + base_path: "source_subfolder" + "2.5.2": + - patch_file: "patches/0001-use-conan-dependencies.diff" + base_path: "source_subfolder" + "cci.20211112": + - patch_file: "patches/0001-use-conan-dependencies.diff" + base_path: "source_subfolder" + "cci.20220219": + - patch_file: "patches/0001-use-conan-dependencies.diff" + base_path: "source_subfolder" diff --git a/recipes/diligent-fx/all/conanfile.py b/recipes/diligent-fx/all/conanfile.py new file mode 100644 index 0000000000000..e5b2755279d0d --- /dev/null +++ b/recipes/diligent-fx/all/conanfile.py @@ -0,0 +1,121 @@ +import os +from conan import ConanFile +from conans import CMake +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, collect_libs, export_conandata_patches, apply_conandata_patches, rename +import shutil + +required_conan_version = ">=1.52.0" + +class DiligentFxConan(ConanFile): + name = "diligent-fx" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/DiligentGraphics/DiligentFx/" + description = "DiligentFX is the Diligent Engine's high-level rendering framework." + license = ("Apache-2.0") + topics = ("graphics", "game-engine", "renderer", "graphics-library") + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], + "fPIC": [True, False], + } + default_options = {"shared": False, + "fPIC": True, + } + generators = "cmake_find_package", "cmake" + _cmake = None + short_paths = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def export_sources(self): + export_conandata_patches(self) + self.copy("CMakeLists.txt") + self.copy("BuildUtils.cmake") + self.copy("script.py") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def validate(self): + if self.options.shared: + raise ConanInvalidConfiguration("Can't build as a shared lib") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def _patch_sources(self): + apply_conandata_patches(self) + + def requirements(self): + if self.version == "cci.20220219" or self.version == "cci.20211112": + self.requires("diligent-tools/2.5.2") + else: + self.requires("diligent-tools/{}".format(self.version)) + + @property + def _diligent_platform(self): + if self.settings.os == "Windows": + return "PLATFORM_WIN32" + elif self.settings.os == "Macos": + return "PLATFORM_MACOS" + elif self.settings.os == "Linux": + return "PLATFORM_LINUX" + elif self.settings.os == "Android": + return "PLATFORM_ANDROID" + elif self.settings.os == "iOS": + return "PLATFORM_IOS" + elif self.settings.os == "Emscripten": + return "PLATFORM_EMSCRIPTEN" + elif self.settings.os == "watchOS": + return "PLATFORM_TVOS" + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["DILIGENT_NO_FORMAT_VALIDATION"] = True + self._cmake.definitions["DILIGENT_BUILD_TESTS"] = False + + self._cmake.definitions[self._diligent_platform] = True + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + self.copy("License.txt", dst="licenses", src=self._source_subfolder) + rename(self, src=os.path.join(self.package_folder, "include", "source_subfolder"), + dst=os.path.join(self.package_folder, "include", "DiligentFx")) + shutil.move(os.path.join(self.package_folder, "Shaders"), + os.path.join(self.package_folder, "res", "Shaders")) + + self.copy(pattern="*.dll", src=self._build_subfolder, dst="bin", keep_path=False) + self.copy(pattern="*.dylib", src=self._build_subfolder, dst="lib", keep_path=False) + self.copy(pattern="*.lib", src=self._build_subfolder, dst="lib", keep_path=False) + self.copy(pattern="*.a", src=self._build_subfolder, dst="lib", keep_path=False) + + def package_info(self): + self.cpp_info.libs = collect_libs(self) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentFx")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentFx", "Components", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentFx", "GLTF_PBR_Renderer", "interface")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentFx", "PostProcess", "EpipolarLightScattering", "interface")) + self.cpp_info.includedirs.append(os.path.join("res")) + + diff --git a/recipes/diligent-fx/all/patches/0001-use-conan-dependencies.diff b/recipes/diligent-fx/all/patches/0001-use-conan-dependencies.diff new file mode 100644 index 0000000000000..ed42ff2d58f84 --- /dev/null +++ b/recipes/diligent-fx/all/patches/0001-use-conan-dependencies.diff @@ -0,0 +1,18 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7d56e79..46b1113 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -18,11 +18,8 @@ endif() + + target_link_libraries(DiligentFX + PRIVATE +- Diligent-BuildSettings +-PUBLIC +- Diligent-GraphicsEngine +- Diligent-GraphicsTools +- Diligent-AssetLoader ++ diligent-core::diligent-core ++ diligent-tools::diligent-tools + ) + set_common_target_properties(DiligentFX) + diff --git a/recipes/diligent-fx/all/script.py b/recipes/diligent-fx/all/script.py new file mode 100644 index 0000000000000..38007ee747ebd --- /dev/null +++ b/recipes/diligent-fx/all/script.py @@ -0,0 +1,58 @@ +# ---------------------------------------------------------------------------- +# Copyright 2019-2022 Diligent Graphics LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# In no event and under no legal theory, whether in tort (including negligence), +# contract, or otherwise, unless required by applicable law (such as deliberate +# and grossly negligent acts) or agreed to in writing, shall any Contributor be +# liable for any damages, including any direct, indirect, special, incidental, +# or consequential damages of any character arising as a result of this License or +# out of the use or inability to use the software (including but not limited to damages +# for loss of goodwill, work stoppage, computer failure or malfunction, or any and +# all other commercial damages or losses), even if such Contributor has been advised +# of the possibility of such damages. +# ---------------------------------------------------------------------------- + +import sys + + +def main(): + try: + if len(sys.argv) < 3: + raise ValueError("Incorrect number of command line arguments. Expected arguments: src file, dst file") + + if sys.argv[1] == sys.argv[2]: + raise ValueError("Source and destination files must be different") + + with open(sys.argv[1], "r") as src_file, open(sys.argv[2], "w") as dst_file: + special_chars = "\'\"\\" + + for line in src_file: + dst_file.write('\"') + + for i, c in enumerate(line.rstrip()): + if special_chars.find(c) != -1: + dst_file.write('\\') + dst_file.write(c) + + dst_file.write('\\n\"\n') + + print("File2String: successfully converted {} to {}".format(sys.argv[1], sys.argv[2])) + except (ValueError, IOError) as error: + print(error) + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/recipes/diligent-fx/all/test_package/CMakeLists.txt b/recipes/diligent-fx/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d1ec0133b8f6 --- /dev/null +++ b/recipes/diligent-fx/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(diligent-fx REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} diligent-fx::diligent-fx) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/diligent-fx/all/test_package/conanfile.py b/recipes/diligent-fx/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/diligent-fx/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/diligent-fx/all/test_package/test_package.cpp b/recipes/diligent-fx/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..b6931c38fa517 --- /dev/null +++ b/recipes/diligent-fx/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + Diligent::ShadowMapManager manager; + return 0; +} diff --git a/recipes/diligent-fx/config.yml b/recipes/diligent-fx/config.yml new file mode 100644 index 0000000000000..0ef99607c429d --- /dev/null +++ b/recipes/diligent-fx/config.yml @@ -0,0 +1,11 @@ +versions: + "api.252009": + folder: "all" + "api.252005": + folder: "all" + "cci.20211112": + folder: "all" + "cci.20220219": + folder: "all" + "2.5.2": + folder: "all" diff --git a/recipes/diligent-tools/all/BuildUtils.cmake b/recipes/diligent-tools/all/BuildUtils.cmake new file mode 100644 index 0000000000000..baedd17d66435 --- /dev/null +++ b/recipes/diligent-tools/all/BuildUtils.cmake @@ -0,0 +1,399 @@ +if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS) + + function(copy_required_dlls TARGET_NAME) + if(D3D11_SUPPORTED) + list(APPEND ENGINE_DLLS Diligent-GraphicsEngineD3D11-shared) + endif() + if(D3D12_SUPPORTED) + list(APPEND ENGINE_DLLS Diligent-GraphicsEngineD3D12-shared) + endif() + if(GL_SUPPORTED) + list(APPEND ENGINE_DLLS Diligent-GraphicsEngineOpenGL-shared) + endif() + if(VULKAN_SUPPORTED) + list(APPEND ENGINE_DLLS Diligent-GraphicsEngineVk-shared) + endif() + if(METAL_SUPPORTED) + list(APPEND ENGINE_DLLS Diligent-GraphicsEngineMetal-shared) + endif() + + foreach(DLL ${ENGINE_DLLS}) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "\"$\"" + "\"$\"") + endforeach(DLL) + + # Copy D3Dcompiler_47.dll, dxcompiler.dll, and dxil.dll + if(MSVC) + if ((D3D11_SUPPORTED OR D3D12_SUPPORTED) AND VS_D3D_COMPILER_PATH) + # Note that VS_D3D_COMPILER_PATH can only be used in a Visual Studio command + # and is not a valid path during CMake configuration + list(APPEND SHADER_COMPILER_DLLS ${VS_D3D_COMPILER_PATH}) + endif() + + if(D3D12_SUPPORTED AND VS_DXC_COMPILER_PATH AND VS_DXIL_SIGNER_PATH) + # For the compiler to sign the bytecode, you have to have a copy of dxil.dll in + # the same folder as the dxcompiler.dll at runtime. + + # Note that VS_DXC_COMPILER_PATH and VS_DXIL_SIGNER_PATH can only be used in a Visual Studio command + # and are not valid paths during CMake configuration + list(APPEND SHADER_COMPILER_DLLS ${VS_DXC_COMPILER_PATH}) + list(APPEND SHADER_COMPILER_DLLS ${VS_DXIL_SIGNER_PATH}) + endif() + + foreach(DLL ${SHADER_COMPILER_DLLS}) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DLL} + "\"$\"") + endforeach(DLL) + + if(D3D12_SUPPORTED AND EXISTS ${DILIGENT_PIX_EVENT_RUNTIME_DLL_PATH}) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DILIGENT_PIX_EVENT_RUNTIME_DLL_PATH} + "\"$\"") + endif() + + if(VULKAN_SUPPORTED) + if(NOT DEFINED DILIGENT_DXCOMPILER_FOR_SPIRV_PATH) + message(FATAL_ERROR "DILIGENT_DXCOMPILER_FOR_SPIRV_PATH is undefined, check order of cmake includes") + endif() + if(EXISTS ${DILIGENT_DXCOMPILER_FOR_SPIRV_PATH}) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DILIGENT_DXCOMPILER_FOR_SPIRV_PATH} + "\"$/spv_dxcompiler.dll\"") + endif() + endif() + endif() + endfunction() + + function(package_required_dlls TARGET_NAME) + if(D3D12_SUPPORTED AND VS_DXC_COMPILER_PATH AND VS_DXIL_SIGNER_PATH) + # Copy the dlls to the project's CMake binary dir + + # Note that VS_DXC_COMPILER_PATH and VS_DXIL_SIGNER_PATH can only be used in a Visual Studio command + # and are not valid paths during CMake configuration + add_custom_command(TARGET ${TARGET_NAME} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${VS_DXC_COMPILER_PATH} + "\"${CMAKE_CURRENT_BINARY_DIR}/dxcompiler.dll\"" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${VS_DXIL_SIGNER_PATH} + "\"${CMAKE_CURRENT_BINARY_DIR}/dxil.dll\"") + set(DLLS "${CMAKE_CURRENT_BINARY_DIR}/dxcompiler.dll" "${CMAKE_CURRENT_BINARY_DIR}/dxil.dll") + + # Add the dlls to the target project as source files + target_sources(${TARGET_NAME} PRIVATE ${DLLS}) + + # Label them as content + set_source_files_properties(${DLLS} PROPERTIES + GENERATED TRUE + VS_DEPLOYMENT_CONTENT 1 + VS_DEPLOYMENT_LOCATION ".") + endif() + endfunction() + + # Set dll output name by adding _{32|64}{r|d} suffix + function(set_dll_output_name TARGET_NAME OUTPUT_NAME_WITHOUT_SUFFIX) + foreach(DBG_CONFIG ${DEBUG_CONFIGURATIONS}) + set_target_properties(${TARGET_NAME} PROPERTIES + OUTPUT_NAME_${DBG_CONFIG} ${OUTPUT_NAME_WITHOUT_SUFFIX}${DLL_DBG_SUFFIX} + ) + endforeach() + + foreach(REL_CONFIG ${RELEASE_CONFIGURATIONS}) + set_target_properties(${TARGET_NAME} PROPERTIES + OUTPUT_NAME_${REL_CONFIG} ${OUTPUT_NAME_WITHOUT_SUFFIX}${DLL_REL_SUFFIX} + ) + endforeach() + endfunction() + +endif(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS) + + +function(set_common_target_properties TARGET) + + if(COMMAND custom_pre_configure_target) + custom_pre_configure_target(${TARGET}) + if(TARGET_CONFIGURATION_COMPLETE) + return() + endif() + endif() + + get_target_property(TARGET_TYPE ${TARGET} TYPE) + + if(MSVC) + # For msvc, enable link-time code generation for release builds (I was not able to + # find any way to set these settings through interface library BuildSettings) + if(TARGET_TYPE STREQUAL STATIC_LIBRARY) + + foreach(REL_CONFIG ${RELEASE_CONFIGURATIONS}) + set_target_properties(${TARGET} PROPERTIES + STATIC_LIBRARY_FLAGS_${REL_CONFIG} /LTCG + ) + endforeach() + + else() + + foreach(REL_CONFIG ${RELEASE_CONFIGURATIONS}) + set_target_properties(${TARGET} PROPERTIES + LINK_FLAGS_${REL_CONFIG} "/LTCG /OPT:REF /INCREMENTAL:NO" + ) + endforeach() + + if(PLATFORM_UNIVERSAL_WINDOWS) + # On UWP, disable incremental link to avoid linker warnings + foreach(DBG_CONFIG ${DEBUG_CONFIGURATIONS}) + set_target_properties(${TARGET} PROPERTIES + LINK_FLAGS_${DBG_CONFIG} "/INCREMENTAL:NO" + ) + endforeach() + endif() + endif() + else() + set_target_properties(${TARGET} PROPERTIES + CXX_VISIBILITY_PRESET hidden # -fvisibility=hidden + C_VISIBILITY_PRESET hidden # -fvisibility=hidden + VISIBILITY_INLINES_HIDDEN TRUE + + # Without -fPIC option GCC fails to link static libraries into dynamic library: + # -fPIC + # If supported for the target machine, emit position-independent code, suitable for + # dynamic linking and avoiding any limit on the size of the global offset table. + POSITION_INDEPENDENT_CODE ON + + # It is crucial to set CXX_STANDARD flag to only affect c++ files and avoid failures compiling c-files: + # error: invalid argument '-std=c++14' not allowed with 'C/ObjC' + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON + + C_STANDARD 11 + ) + + if(NOT MINGW_BUILD) + # Do not disable extensions when building with MinGW! + set_target_properties(${TARGET} PROPERTIES + CXX_EXTENSIONS OFF + ) + endif() + endif() + + if(COMMAND custom_post_configure_target) + custom_post_configure_target(${TARGET}) + endif() + +endfunction() + +function(find_targets_in_directory _RESULT _DIR) + get_property(_subdirs DIRECTORY "${_DIR}" PROPERTY SUBDIRECTORIES) + foreach(_subdir IN LISTS _subdirs) + find_targets_in_directory(${_RESULT} "${_subdir}") + endforeach() + get_property(_SUB_TARGETS DIRECTORY "${_DIR}" PROPERTY BUILDSYSTEM_TARGETS) + set(${_RESULT} ${${_RESULT}} ${_SUB_TARGETS} PARENT_SCOPE) +endfunction() + +function(set_directory_root_folder _DIRECTORY _ROOT_FOLDER) + find_targets_in_directory(_TARGETS ${_DIRECTORY}) + foreach(_TARGET IN LISTS _TARGETS) + get_target_property(_FOLDER ${_TARGET} FOLDER) + if(_FOLDER) + set_target_properties(${_TARGET} PROPERTIES FOLDER "${_ROOT_FOLDER}/${_FOLDER}") + else() + set_target_properties(${_TARGET} PROPERTIES FOLDER "${_ROOT_FOLDER}") + endif() + endforeach() +endfunction() + + +# Returns default backend library type (static/dynamic) for the current platform +function(get_backend_libraries_type _LIB_TYPE) + if(PLATFORM_WIN32 OR PLATFORM_LINUX OR PLATFORM_ANDROID OR PLATFORM_UNIVERSAL_WINDOWS OR PLATFORM_MACOS) + set(LIB_TYPE "shared") + elseif(PLATFORM_IOS OR PLATFORM_TVOS OR PLATFORM_EMSCRIPTEN) + # Statically link with the engine on iOS, tvOS and Emscripten. + # It is also possible to link dynamically by + # putting the library into the framework. + set(LIB_TYPE "static") + else() + message(FATAL_ERROR "Undefined platform") + endif() + set(${_LIB_TYPE} ${LIB_TYPE} PARENT_SCOPE) +endfunction() + + +# Adds the list of supported backend targets to variable ${_TARGETS} in parent scope. +# Second argument to the function may override the target type (static/dynamic). If It +# is not given, default target type for the platform is used. +function(get_supported_backends _TARGETS) + if(${ARGC} GREATER 1) + set(LIB_TYPE ${ARGV1}) + else() + get_backend_libraries_type(LIB_TYPE) + endif() + + if(D3D11_SUPPORTED) + list(APPEND BACKENDS Diligent-GraphicsEngineD3D11-${LIB_TYPE}) + endif() + if(D3D12_SUPPORTED) + list(APPEND BACKENDS Diligent-GraphicsEngineD3D12-${LIB_TYPE}) + endif() + if(GL_SUPPORTED OR GLES_SUPPORTED) + list(APPEND BACKENDS Diligent-GraphicsEngineOpenGL-${LIB_TYPE}) + endif() + if(VULKAN_SUPPORTED) + list(APPEND BACKENDS Diligent-GraphicsEngineVk-${LIB_TYPE}) + endif() + if(METAL_SUPPORTED) + list(APPEND BACKENDS Diligent-GraphicsEngineMetal-${LIB_TYPE}) + endif() + # ${_TARGETS} == ENGINE_LIBRARIES + # ${${_TARGETS}} == ${ENGINE_LIBRARIES} + set(${_TARGETS} ${${_TARGETS}} ${BACKENDS} PARENT_SCOPE) +endfunction() + + +# Returns path to the target relative to CMake root +function(get_target_relative_dir _TARGET _DIR) + get_target_property(TARGET_SOURCE_DIR ${_TARGET} SOURCE_DIR) + file(RELATIVE_PATH TARGET_RELATIVE_PATH "${CMAKE_SOURCE_DIR}" "${TARGET_SOURCE_DIR}") + set(${_DIR} ${TARGET_RELATIVE_PATH} PARENT_SCOPE) +endfunction() + +# Performs installation steps for the core library +function(install_core_lib _TARGET) + get_target_relative_dir(${_TARGET} TARGET_RELATIVE_PATH) + + get_target_property(TARGET_TYPE ${_TARGET} TYPE) + if(TARGET_TYPE STREQUAL STATIC_LIBRARY) + list(APPEND DILIGENT_CORE_INSTALL_LIBS_LIST ${_TARGET}) + set(DILIGENT_CORE_INSTALL_LIBS_LIST ${DILIGENT_CORE_INSTALL_LIBS_LIST} CACHE INTERNAL "Core libraries installation list") + elseif(TARGET_TYPE STREQUAL SHARED_LIBRARY) + install(TARGETS ${_TARGET} + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_CORE_DIR}/$" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_CORE_DIR}/$" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${DILIGENT_CORE_DIR}/$" + ) + if (DILIGENT_INSTALL_PDB) + install(FILES $ DESTINATION "${CMAKE_INSTALL_BINDIR}/${DILIGENT_CORE_DIR}/$" OPTIONAL) + endif() + endif() + + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/interface") + install(DIRECTORY interface + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${TARGET_RELATIVE_PATH}/" + ) + endif() +endfunction() + + +function(install_combined_static_lib COMBINED_LIB_NAME LIBS_LIST CUSTOM_TARGET_NAME CUSTOM_TARGET_FOLDER INSTALL_DESTINATION) + + foreach(LIB ${LIBS_LIST}) + list(APPEND COMBINED_LIB_TARGET_FILES $) + endforeach(LIB) + + if(MSVC) + add_custom_command( + OUTPUT ${COMBINED_LIB_NAME} + COMMAND lib.exe /OUT:${COMBINED_LIB_NAME} ${COMBINED_LIB_TARGET_FILES} + DEPENDS ${LIBS_LIST} + COMMENT "Combining libraries..." + ) + add_custom_target(${CUSTOM_TARGET_NAME} ALL DEPENDS ${COMBINED_LIB_NAME}) + else() + + if(PLATFORM_WIN32) + # do NOT use stock ar on MinGW + find_program(AR NAMES x86_64-w64-mingw32-gcc-ar) + else() + set(AR ${CMAKE_AR}) + endif() + + if(AR) + add_custom_command( + OUTPUT ${COMBINED_LIB_NAME} + # Delete all object files from current directory + COMMAND ${CMAKE_COMMAND} -E remove "*${CMAKE_C_OUTPUT_EXTENSION}" + DEPENDS ${LIBS_LIST} + COMMENT "Combining libraries..." + ) + + # Unpack all object files from all targets to current directory + foreach(LIB_TARGET ${COMBINED_LIB_TARGET_FILES}) + add_custom_command( + OUTPUT ${COMBINED_LIB_NAME} + COMMAND ${AR} -x ${LIB_TARGET} + APPEND + ) + endforeach() + + # Pack object files to a combined library and delete them + add_custom_command( + OUTPUT ${COMBINED_LIB_NAME} + COMMAND ${AR} -crs ${COMBINED_LIB_NAME} "*${CMAKE_C_OUTPUT_EXTENSION}" + COMMAND ${CMAKE_COMMAND} -E remove "*${CMAKE_C_OUTPUT_EXTENSION}" + APPEND + ) + + add_custom_target(${CUSTOM_TARGET_NAME} ALL DEPENDS ${COMBINED_LIB_NAME}) + else() + message("ar command is not found") + endif() + endif() + + if(TARGET ${CUSTOM_TARGET_NAME}) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${COMBINED_LIB_NAME}" + DESTINATION ${INSTALL_DESTINATION} + ) + set_target_properties(${CUSTOM_TARGET_NAME} PROPERTIES + FOLDER ${CUSTOM_TARGET_FOLDER} + ) + else() + message("Unable to find librarian tool. Combined ${COMBINED_LIB_NAME} static library will not be produced.") + endif() + +endfunction() + + + + +function(add_format_validation_target MODULE_NAME MODULE_ROOT_PATH IDE_FOLDER) + + if(${DILIGENT_NO_FORMAT_VALIDATION}) + return() + endif() + + # Start by copying .clang-format file to the module's root folder + add_custom_target(${MODULE_NAME}-ValidateFormatting ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${DILIGENT_CORE_SOURCE_DIR}/.clang-format" "${MODULE_ROOT_PATH}/.clang-format" + ) + + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(RUN_VALIDATION_SCRIPT validate_format_win.bat) + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") + set(RUN_VALIDATION_SCRIPT ./validate_format_linux.sh) + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + set(RUN_VALIDATION_SCRIPT ./validate_format_mac.sh) + else() + message(FATAL_ERROR "Unexpected host system") + endif() + + # Run the format validation script + add_custom_command(TARGET ${MODULE_NAME}-ValidateFormatting + COMMAND ${RUN_VALIDATION_SCRIPT} + WORKING_DIRECTORY "${MODULE_ROOT_PATH}/BuildTools/FormatValidation" + COMMENT "Validating ${MODULE_NAME} module's source code formatting..." + VERBATIM + ) + + if(TARGET ${MODULE_NAME}-ValidateFormatting) + set_target_properties(${MODULE_NAME}-ValidateFormatting PROPERTIES FOLDER ${IDE_FOLDER}) + endif() + +endfunction() + + diff --git a/recipes/diligent-tools/all/CMakeLists.txt b/recipes/diligent-tools/all/CMakeLists.txt new file mode 100644 index 0000000000000..67d43c91fddd2 --- /dev/null +++ b/recipes/diligent-tools/all/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.2) +project(cmake_wrapper) + +include(BuildUtils.cmake) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(imgui REQUIRED) +find_package(PNG REQUIRED) +find_package(TIFF REQUIRED) +find_package(JPEG REQUIRED) +find_package(ZLIB REQUIRED) +find_package(args CONFIG) +find_package(diligent-core REQUIRED) + +set(Diligent-GraphicsEngine_SOURCE_DIR ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/) +set(DILIGENT_ARGS_DIR ${CONAN_INCLUDE_DIRS_TAYWEE-ARGS}) +set(DILIGENT_DEAR_IMGUI_PATH ${CONAN_INCLUDE_DIRS_IMGUI}) + +add_library(Diligent-BuildSettings ALIAS diligent-core::diligent-core) +add_library(Diligent-Common ALIAS diligent-core::diligent-core) +add_library(Diligent-PlatformInterface ALIAS diligent-core::diligent-core) +add_library(Diligent-GraphicsEngineInterface ALIAS diligent-core::diligent-core) +add_library(Diligent-GraphicsAccessories ALIAS diligent-core::diligent-core) +add_library(Diligent-GraphicsTools ALIAS diligent-core::diligent-core) +add_library(Diligent-Archiver-static ALIAS diligent-core::diligent-core) +add_library(Diligent-HLSL2GLSLConverterLib ALIAS diligent-core::diligent-core) +add_library(Diligent-TargetPlatform ALIAS diligent-core::diligent-core) +add_library(Diligent-GraphicsEngineOpenGL-static ALIAS diligent-core::diligent-core) +add_library(imgui ALIAS imgui::imgui) + +add_subdirectory(source_subfolder) diff --git a/recipes/diligent-tools/all/conandata.yml b/recipes/diligent-tools/all/conandata.yml new file mode 100644 index 0000000000000..27798ef8a71ae --- /dev/null +++ b/recipes/diligent-tools/all/conandata.yml @@ -0,0 +1,44 @@ +sources: + "api.252009": + url: "https://github.com/DiligentGraphics/DiligentTools/archive/refs/tags/API252009.tar.gz" + sha256: "f0ffd7e7145df2b66694d88a9d7854325032171ee6a9650f348da69f735d57a3" + "api.252005": + url: "https://github.com/DiligentGraphics/DiligentTools/archive/refs/tags/API252004.tar.gz" + sha256: "28caa91bc1a7d8b1e7bf0198da23c74a8ea0cfda447c72eeb39b5766d01a754a" + "2.5.2": + url: "https://github.com/DiligentGraphics/DiligentTools/archive/refs/tags/v2.5.2.tar.gz" + sha256: "6519f3d5871a1119876928531d249c45ef46392237ab7bacc6531b4d538551ca" + "cci.20211009": + url: "https://github.com/DiligentGraphics/DiligentTools/archive/846ffbe83ac5ae0c96135f5a772d0077d0d086a8.tar.gz" + sha256: "12ec01e730aefd64ca0d335b5ac6af47279f5e58617f37bc062cd83422f81703" +patches: + "api.252009": + - patch_file: "patches/0012-2.5.2-fix-imgui-include-path.diff" + base_path: "source_subfolder" + "api.252005": + - patch_file: "patches/0006-2.5.2-use-imgui-from-conan.diff" + base_path: "source_subfolder" + - patch_file: "patches/0012-2.5.2-fix-imgui-include-path.diff" + base_path: "source_subfolder" + "2.5.2": + - patch_file: "patches/0006-2.5.2-use-imgui-from-conan.diff" + base_path: "source_subfolder" + - patch_file: "patches/0007-2.5.2-use-diligent-core-dependencies.diff" + base_path: "source_subfolder" + - patch_file: "patches/0008-2.5.2-use-conan-dependencies.diff" + base_path: "source_subfolder" + - patch_file: "patches/0009-2.5.2-fix-include-path.diff" + base_path: "source_subfolder" + - patch_file: "patches/0010-2.5.2-fix-render-state-notation-paths.diff" + base_path: "source_subfolder" + - patch_file: "patches/0011-2.5.2-use-conan-dependencies-part2.diff" + base_path: "source_subfolder" + - patch_file: "patches/0012-2.5.2-fix-imgui-include-path.diff" + base_path: "source_subfolder" + "cci.20211009": + - patch_file: "patches/0001-use-imgui-from-conan.diff" + base_path: "source_subfolder" + - patch_file: "patches/0002-use-conan-dependencies.diff" + base_path: "source_subfolder" + - patch_file: "patches/0005-fix-include-path.diff" + base_path: "source_subfolder" diff --git a/recipes/diligent-tools/all/conanfile.py b/recipes/diligent-tools/all/conanfile.py new file mode 100644 index 0000000000000..958f6428f4048 --- /dev/null +++ b/recipes/diligent-tools/all/conanfile.py @@ -0,0 +1,165 @@ +import os +from conan import ConanFile +from conans import CMake +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import get, rmdir, rm, collect_libs, patches, export_conandata_patches +from conan.tools.scm import Version + +required_conan_version = ">=1.52.0" + +class DiligentToolsConan(ConanFile): + name = "diligent-tools" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/DiligentGraphics/DiligentTools/" + description = "Diligent Core is a modern cross-platfrom low-level graphics API." + license = ("Apache-2.0") + topics = ("graphics", "texture", "gltf", "draco", "imgui") + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], + "fPIC": [True, False], + "jpeg": [False, "libjpeg-turbo", "libjpeg"], + "with_render_state_packager": [True, False], + "with_archiver": [True, False], + } + default_options = {"shared": False, + "fPIC": True, + "jpeg": "libjpeg", + "with_render_state_packager": False, + "with_archiver": True, + } + + generators = "cmake_find_package", "cmake_find_package_multi", "cmake" + _cmake = None + short_paths = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def export_sources(self): + export_conandata_patches(self) + self.copy("CMakeLists.txt") + self.copy("BuildUtils.cmake") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def package_id(self): + if self.settings.compiler == "Visual Studio": + if "MD" in self.settings.compiler.runtime: + self.info.settings.compiler.runtime = "MD/MDd" + else: + self.info.settings.compiler.runtime = "MT/MTd" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def _patch_sources(self): + patches.apply_conandata_patches(self) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.options.shared: + raise ConanInvalidConfiguration("Can't build diligent tools as shared lib") + + def build_requirements(self): + self.tool_requires("cmake/3.24.2") + + def requirements(self): + if self.version == "cci.20211009": + self.requires("diligent-core/2.5.1") + self.requires("imgui/1.87") + else: + self.requires("diligent-core/{}".format(self.version)) + self.requires('taywee-args/6.3.0') + self.requires("imgui/1.85") + + if self.options.jpeg == "libjpeg": + self.requires("libjpeg/9e") + if self.options.jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/2.1.4") + self.requires("libpng/1.6.37") + self.requires("libtiff/4.3.0") + self.requires("zlib/1.2.12") + + @property + def _diligent_platform(self): + if self.settings.os == "Windows": + return "PLATFORM_WIN32" + elif self.settings.os == "Macos": + return "PLATFORM_MACOS" + elif self.settings.os == "Linux": + return "PLATFORM_LINUX" + elif self.settings.os == "Android": + return "PLATFORM_ANDROID" + elif self.settings.os == "iOS": + return "PLATFORM_IOS" + elif self.settings.os == "Emscripten": + return "PLATFORM_EMSCRIPTEN" + elif self.settings.os == "watchOS": + return "PLATFORM_TVOS" + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + + self._cmake.definitions["DILIGENT_INSTALL_TOOLS"] = False + self._cmake.definitions["DILIGENT_BUILD_SAMPLES"] = False + self._cmake.definitions["DILIGENT_NO_FORMAT_VALIDATION"] = True + self._cmake.definitions["DILIGENT_BUILD_TESTS"] = False + self._cmake.definitions["DILIGENT_BUILD_TOOLS_TESTS"] = False + self._cmake.definitions["DILIGENT_BUILD_TOOLS_INCLUDE_TEST"] = False + self._cmake.definitions["DILIGENT_NO_RENDER_STATE_PACKAGER"] = not self.options.with_render_state_packager + self._cmake.definitions["ARCHIVER_SUPPORTED"] = not self.options.with_archiver + + if self.version != "cci.20211009" and \ + (self.version.startswith("api") and self.version >= "api.252005") or \ + (self.version > "2.5.2"): + self._cmake.definitions["GL_SUPPORTED"] = True + self._cmake.definitions["GLES_SUPPORTED"] = True + self._cmake.definitions["VULKAN_SUPPORTED"] = True + self._cmake.definitions["METAL_SUPPORTED"] = True + + self._cmake.definitions[self._diligent_platform] = True + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("*.hpp", src=self._source_subfolder, dst="include/DiligentTools", keep_path=True) + self.copy(pattern="*.dll", src=self._build_subfolder, dst="bin", keep_path=False) + self.copy(pattern="*.dylib", src=self._build_subfolder, dst="lib", keep_path=False) + self.copy(pattern="*.lib", src=self._build_subfolder, dst="lib", keep_path=False) + self.copy(pattern="*.a", src=self._build_subfolder, dst="lib", keep_path=False) + self.copy("*", src=os.path.join(self._build_subfolder, "bin"), dst="bin", keep_path=False) + rmdir(self, os.path.join(self.package_folder, "Licenses")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + self.copy("License.txt", dst="licenses", src=self._source_subfolder) + + def package_info(self): + self.cpp_info.libs = collect_libs(self) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentTools")) + self.cpp_info.includedirs.append(os.path.join("include", "DiligentTools", "AssetLoader", "interface")) + + self.cpp_info.defines.append(f"{self._diligent_platform}=1") + + if self.settings.os in ["Macos", "Linux"]: + self.cpp_info.system_libs = ["dl", "pthread"] + if self.settings.os == 'Macos': + self.cpp_info.frameworks = ["CoreFoundation", 'Cocoa'] diff --git a/recipes/diligent-tools/all/patches/0001-use-imgui-from-conan.diff b/recipes/diligent-tools/all/patches/0001-use-imgui-from-conan.diff new file mode 100644 index 0000000000000..364629b2f1833 --- /dev/null +++ b/recipes/diligent-tools/all/patches/0001-use-imgui-from-conan.diff @@ -0,0 +1,56 @@ +diff --git a/Imgui/CMakeLists.txt b/Imgui/CMakeLists.txt +index 7a8e62f..041f324 100644 +--- a/Imgui/CMakeLists.txt ++++ b/Imgui/CMakeLists.txt +@@ -11,24 +11,12 @@ endif() + set(IMGUIZMO_QUAT_PATH ../ThirdParty/imGuIZMO.quat) + + set(DEAR_IMGUI_INCLUDE +- ${DEAR_IMGUI_PATH}/imconfig.h +- ${DEAR_IMGUI_PATH}/imgui_internal.h +- ${DEAR_IMGUI_PATH}/imstb_rectpack.h +- ${DEAR_IMGUI_PATH}/imstb_textedit.h +- ${DEAR_IMGUI_PATH}/imstb_truetype.h +- ${DEAR_IMGUI_PATH}/misc/cpp/imgui_stdlib.h + ) + + set(DEAR_IMGUI_INTERFACE +- ${DEAR_IMGUI_PATH}/imgui.h + ) + + set(DEAR_IMGUI_SOURCE +- ${DEAR_IMGUI_PATH}/imgui.cpp +- ${DEAR_IMGUI_PATH}/imgui_draw.cpp +- ${DEAR_IMGUI_PATH}/imgui_tables.cpp +- ${DEAR_IMGUI_PATH}/imgui_widgets.cpp +- ${DEAR_IMGUI_PATH}/misc/cpp/imgui_stdlib.cpp + ) + + set(SOURCE +@@ -48,8 +36,6 @@ set(INTERFACE + ) + + if(PLATFORM_WIN32) +- list(APPEND DEAR_IMGUI_SOURCE ${DEAR_IMGUI_PATH}/backends/imgui_impl_win32.cpp) +- list(APPEND DEAR_IMGUI_INCLUDE ${DEAR_IMGUI_PATH}/backends/imgui_impl_win32.h) + + list(APPEND SOURCE src/ImGuiImplWin32.cpp) + list(APPEND INTERFACE interface/ImGuiImplWin32.hpp) +@@ -62,9 +48,6 @@ elseif(PLATFORM_LINUX) + elseif(PLATFORM_ANDROID) + list(APPEND SOURCE src/ImGuiImplAndroid.cpp) + list(APPEND INTERFACE interface/ImGuiImplAndroid.hpp) +-elseif(PLATFORM_MACOS) +- list(APPEND DEAR_IMGUI_SOURCE ${DEAR_IMGUI_PATH}/backends/imgui_impl_osx.mm) +- list(APPEND DEAR_IMGUI_INCLUDE ${DEAR_IMGUI_PATH}/backends/imgui_impl_osx.h) + + list(APPEND SOURCE src/ImGuiImplMacOS.mm) + list(APPEND INTERFACE interface/ImGuiImplMacOS.hpp) +@@ -129,6 +112,7 @@ PRIVATE + Diligent-GraphicsEngineInterface + Diligent-GraphicsAccessories + Diligent-GraphicsTools ++ imgui::imgui + ) + + set_target_properties(Diligent-Imgui PROPERTIES diff --git a/recipes/diligent-tools/all/patches/0002-use-conan-dependencies.diff b/recipes/diligent-tools/all/patches/0002-use-conan-dependencies.diff new file mode 100644 index 0000000000000..9c378eb64f83a --- /dev/null +++ b/recipes/diligent-tools/all/patches/0002-use-conan-dependencies.diff @@ -0,0 +1,131 @@ +diff --git a/AssetLoader/CMakeLists.txt b/AssetLoader/CMakeLists.txt +--- a/AssetLoader/CMakeLists.txt ++++ b/AssetLoader/CMakeLists.txt +@@ -34,13 +34,8 @@ source_group("interface" FILES ${INTERFACE}) + + target_link_libraries(Diligent-AssetLoader + PRIVATE +- Diligent-BuildSettings +- Diligent-Common +- Diligent-PlatformInterface +- Diligent-GraphicsEngineInterface +- Diligent-GraphicsAccessories +- Diligent-GraphicsTools + Diligent-TextureLoader ++ diligent-core::diligent-core + ) + + if (TARGET draco) +diff --git a/HLSL2GLSLConverter/CMakeLists.txt b/HLSL2GLSLConverter/CMakeLists.txt +--- a/HLSL2GLSLConverter/CMakeLists.txt ++++ b/HLSL2GLSLConverter/CMakeLists.txt +@@ -33,12 +33,7 @@ target_compile_definitions(HLSL2GLSLConverter PRIVATE UNICODE) + + target_link_libraries(HLSL2GLSLConverter + PRIVATE +- Diligent-BuildSettings +- Diligent-TargetPlatform +- Diligent-Common +- Diligent-GraphicsTools +- Diligent-HLSL2GLSLConverterLib +- Diligent-GraphicsEngineOpenGL-static ++ diligent-core::diligent-core + ) + + source_group("source" FILES ${SOURCE}) +diff --git a/Imgui/CMakeLists.txt b/Imgui/CMakeLists.txt +--- a/Imgui/CMakeLists.txt ++++ b/Imgui/CMakeLists.txt +@@ -106,13 +106,8 @@ source_group("imGuIZMO.quat" FILES ${IMGUIZMO_QUAT_SOURCE}) + + target_link_libraries(Diligent-Imgui + PRIVATE +- Diligent-BuildSettings +- Diligent-Common +- Diligent-PlatformInterface +- Diligent-GraphicsEngineInterface +- Diligent-GraphicsAccessories +- Diligent-GraphicsTools +- imgui::imgui ++ diligent-core::diligent-core ++ imgui::imgui + ) + + set_target_properties(Diligent-Imgui PROPERTIES +diff --git a/NativeApp/Android/ndk_helper/CMakeLists.txt b/NativeApp/Android/ndk_helper/CMakeLists.txt +--- a/NativeApp/Android/ndk_helper/CMakeLists.txt ++++ b/NativeApp/Android/ndk_helper/CMakeLists.txt +@@ -29,7 +29,7 @@ PUBLIC + + target_link_libraries(NDKHelper + PRIVATE +- Diligent-BuildSettings ++ diligent-core::diligent-core + PUBLIC + native_app_glue + ) +diff --git a/NativeApp/CMakeLists.txt b/NativeApp/CMakeLists.txt +--- a/NativeApp/CMakeLists.txt ++++ b/NativeApp/CMakeLists.txt +@@ -432,8 +432,7 @@ PUBLIC + + target_link_libraries(Diligent-NativeAppBase + PRIVATE +- Diligent-BuildSettings +- Diligent-Common ++ diligent-core::diligent-core + ) + + if(PLATFORM_WIN32) +diff --git a/NativeApp/Linux/CMakeLists.txt b/NativeApp/Linux/CMakeLists.txt +--- a/NativeApp/Linux/CMakeLists.txt ++++ b/NativeApp/Linux/CMakeLists.txt +@@ -20,7 +20,7 @@ source_group("interface" FILES ${INTERFACE}) + + target_link_libraries(XCBKeySyms + PRIVATE +- Diligent-BuildSettings ++ diligent-core::diligent-core + xcb + ) + +diff --git a/TextureLoader/CMakeLists.txt b/TextureLoader/CMakeLists.txt +--- a/TextureLoader/CMakeLists.txt ++++ b/TextureLoader/CMakeLists.txt +@@ -44,16 +44,12 @@ source_group("include" FILES ${INCLUDE}) + source_group("interface" FILES ${INTERFACE}) + + target_link_libraries(Diligent-TextureLoader +-PRIVATE +- Diligent-BuildSettings +- Diligent-Common +- Diligent-PlatformInterface +- Diligent-GraphicsEngineInterface +- Diligent-GraphicsAccessories +- Diligent-GraphicsTools +- LibPng +- LibTiff +- ZLib ++PRIVATE ++ diligent-core::diligent-core ++ JPEG::JPEG ++ PNG::PNG ++ TIFF::TIFF ++ ZLIB::ZLIB + ) + + if (NOT DILIGENT_EXTERNAL_LIBJPEG) +diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt +--- a/ThirdParty/CMakeLists.txt ++++ b/ThirdParty/CMakeLists.txt +@@ -1,10 +1,5 @@ + cmake_minimum_required (VERSION 3.6) + +-add_subdirectory(libjpeg-9a) +-add_subdirectory(libtiff) +-add_subdirectory(zlib-1.2.8) +-add_subdirectory(lpng-1.6.17) +- + set(LICENSE_INSTALL_PATH "Licenses/ThirdParty/${DILIGENT_TOOLS_DIR}") + + install(FILES libjpeg-9a/README DESTINATION ${LICENSE_INSTALL_PATH} RENAME libjpeg-readme.txt) diff --git a/recipes/diligent-tools/all/patches/0003-fix-diligent-core-include-paths.diff b/recipes/diligent-tools/all/patches/0003-fix-diligent-core-include-paths.diff new file mode 100644 index 0000000000000..2c3025797fc4b --- /dev/null +++ b/recipes/diligent-tools/all/patches/0003-fix-diligent-core-include-paths.diff @@ -0,0 +1,122 @@ +diff --git a/TextureLoader/interface/BCTools.h b/TextureLoader/interface/BCTools.h +index cb46211..95bee9f 100644 +--- a/TextureLoader/interface/BCTools.h ++++ b/TextureLoader/interface/BCTools.h +@@ -26,7 +26,7 @@ + + #pragma once + +-#include "../../../DiligentCore/Primitives/interface/BasicTypes.h" ++#include "DiligentCore/Primitives/interface/BasicTypes.h" + + DILIGENT_BEGIN_NAMESPACE(Diligent) + +diff --git a/TextureLoader/interface/Image.h b/TextureLoader/interface/Image.h +index 78629a0..4d5f5f7 100644 +--- a/TextureLoader/interface/Image.h ++++ b/TextureLoader/interface/Image.h +@@ -27,15 +27,15 @@ + + #pragma once + +-#include "../../../DiligentCore/Graphics/GraphicsEngine/interface/GraphicsTypes.h" +-#include "../../../DiligentCore/Primitives/interface/FileStream.h" +-#include "../../../DiligentCore/Primitives/interface/DataBlob.h" ++#include "DiligentCore/Graphics/GraphicsEngine/interface/GraphicsTypes.h" ++#include "DiligentCore/Primitives/interface/FileStream.h" ++#include "DiligentCore/Primitives/interface/DataBlob.h" + + #if DILIGENT_CPP_INTERFACE + # include + +-# include "../../../DiligentCore/Common/interface/RefCntAutoPtr.hpp" +-# include "../../../DiligentCore/Common/interface/ObjectBase.hpp" ++# include "DiligentCore/Common/interface/RefCntAutoPtr.hpp" ++# include "DiligentCore/Common/interface/ObjectBase.hpp" + #endif + + DILIGENT_BEGIN_NAMESPACE(Diligent) +diff --git a/TextureLoader/interface/TextureLoader.h b/TextureLoader/interface/TextureLoader.h +index 15710a6..9ccf234 100644 +--- a/TextureLoader/interface/TextureLoader.h ++++ b/TextureLoader/interface/TextureLoader.h +@@ -27,9 +27,9 @@ + + #pragma once + +-#include "../../../DiligentCore/Primitives/interface/FileStream.h" +-#include "../../../DiligentCore/Graphics/GraphicsEngine/interface/RenderDevice.h" +-#include "../../../DiligentCore/Graphics/GraphicsEngine/interface/Texture.h" ++#include "DiligentCore/Primitives/interface/FileStream.h" ++#include "DiligentCore/Graphics/GraphicsEngine/interface/RenderDevice.h" ++#include "DiligentCore/Graphics/GraphicsEngine/interface/Texture.h" + #include "Image.h" + + DILIGENT_BEGIN_NAMESPACE(Diligent) +@@ -96,7 +96,7 @@ static const struct INTERFACE_ID IID_TextureLoader = + {0xe04fe6d5, 0x8665, 0x4183, {0xa8, 0x72, 0x85, 0x2e, 0xf, 0x7c, 0xe2, 0x42}}; + + #define DILIGENT_INTERFACE_NAME ITextureLoader +-#include "../../../DiligentCore/Primitives/interface/DefineInterfaceHelperMacros.h" ++#include "DiligentCore/Primitives/interface/DefineInterfaceHelperMacros.h" + + #define ITextureLoaderInclusiveMethods \ + IObjectInclusiveMethods; \ +@@ -123,7 +123,7 @@ DILIGENT_BEGIN_INTERFACE(ITextureLoader, IObject) + DILIGENT_END_INTERFACE + // clang-format on + +-#include "../../../DiligentCore/Primitives/interface/UndefInterfaceHelperMacros.h" ++#include "DiligentCore/Primitives/interface/UndefInterfaceHelperMacros.h" + + #if DILIGENT_C_INTERFACE + +@@ -135,7 +135,7 @@ DILIGENT_END_INTERFACE + + #endif + +-#include "../../../DiligentCore/Primitives/interface/DefineGlobalFuncHelperMacros.h" ++#include "DiligentCore/Primitives/interface/DefineGlobalFuncHelperMacros.h" + + /// Creates a texture loader from image. + +@@ -177,6 +177,6 @@ void DILIGENT_GLOBAL_FUNCTION(CreateTextureLoaderFromMemory)(const void* + const TextureLoadInfo REF TexLoadInfo, + ITextureLoader** ppLoader); + +-#include "../../../DiligentCore/Primitives/interface/UndefGlobalFuncHelperMacros.h" ++#include "DiligentCore/Primitives/interface/UndefGlobalFuncHelperMacros.h" + + DILIGENT_END_NAMESPACE // namespace Diligent +diff --git a/TextureLoader/interface/TextureUtilities.h b/TextureLoader/interface/TextureUtilities.h +index 93d563a..2b53b02 100644 +--- a/TextureLoader/interface/TextureUtilities.h ++++ b/TextureLoader/interface/TextureUtilities.h +@@ -30,15 +30,15 @@ + /// \file + /// Defines texture utilities + +-#include "../../../DiligentCore/Graphics/GraphicsEngine/interface/GraphicsTypes.h" +-#include "../../../DiligentCore/Graphics/GraphicsEngine/interface/Texture.h" +-#include "../../../DiligentCore/Graphics/GraphicsEngine/interface/RenderDevice.h" ++#include "DiligentCore/Graphics/GraphicsEngine/interface/GraphicsTypes.h" ++#include "DiligentCore/Graphics/GraphicsEngine/interface/Texture.h" ++#include "DiligentCore/Graphics/GraphicsEngine/interface/RenderDevice.h" + #include "TextureLoader.h" + + DILIGENT_BEGIN_NAMESPACE(Diligent) + + +-#include "../../../DiligentCore/Primitives/interface/DefineGlobalFuncHelperMacros.h" ++#include "DiligentCore/Primitives/interface/DefineGlobalFuncHelperMacros.h" + + /// Creates a texture from file. + +@@ -51,6 +51,6 @@ void DILIGENT_GLOBAL_FUNCTION(CreateTextureFromFile)(const Char* F + IRenderDevice* pDevice, + ITexture** ppTexture); + +-#include "../../../DiligentCore/Primitives/interface/UndefGlobalFuncHelperMacros.h" ++#include "DiligentCore/Primitives/interface/UndefGlobalFuncHelperMacros.h" + + DILIGENT_END_NAMESPACE // namespace Diligent diff --git a/recipes/diligent-tools/all/patches/0005-fix-include-path.diff b/recipes/diligent-tools/all/patches/0005-fix-include-path.diff new file mode 100644 index 0000000000000..9f64d594c669c --- /dev/null +++ b/recipes/diligent-tools/all/patches/0005-fix-include-path.diff @@ -0,0 +1,13 @@ +diff --git a/Imgui/src/ImGuiImplWin32.cpp b/Imgui/src/ImGuiImplWin32.cpp +index 2c01cc6..403375c 100644 +--- a/Imgui/src/ImGuiImplWin32.cpp ++++ b/Imgui/src/ImGuiImplWin32.cpp +@@ -33,7 +33,7 @@ + #include "GraphicsTypes.h" + #include "imgui.h" + #include "ImGuiImplWin32.hpp" +-#include "backends/imgui_impl_win32.h" ++#include "../res/bindings/imgui_impl_win32.h" + #include "DebugUtilities.hpp" + + IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); diff --git a/recipes/diligent-tools/all/patches/0006-2.5.2-use-imgui-from-conan.diff b/recipes/diligent-tools/all/patches/0006-2.5.2-use-imgui-from-conan.diff new file mode 100644 index 0000000000000..9c9e5cb1cfd03 --- /dev/null +++ b/recipes/diligent-tools/all/patches/0006-2.5.2-use-imgui-from-conan.diff @@ -0,0 +1,21 @@ +diff --git a/Imgui/CMakeLists.txt b/Imgui/CMakeLists.txt +index 89e8a33..64a2a77 100644 +--- a/Imgui/CMakeLists.txt ++++ b/Imgui/CMakeLists.txt +@@ -78,8 +78,6 @@ add_library(Diligent-Imgui STATIC + ${SOURCE} + ${INCLUDE} + ${INTERFACE} +- ${DEAR_IMGUI_SOURCE} +- ${DEAR_IMGUI_INCLUDE} + ${DEAR_IMGUI_INTERFACE} + ${IMGUIZMO_QUAT_SOURCE} + ) +@@ -124,6 +122,7 @@ PRIVATE + Diligent-GraphicsEngineInterface + Diligent-GraphicsAccessories + Diligent-GraphicsTools ++ imgui::imgui + ) + + set_target_properties(Diligent-Imgui PROPERTIES diff --git a/recipes/diligent-tools/all/patches/0007-2.5.2-use-diligent-core-dependencies.diff b/recipes/diligent-tools/all/patches/0007-2.5.2-use-diligent-core-dependencies.diff new file mode 100644 index 0000000000000..fa18122657068 --- /dev/null +++ b/recipes/diligent-tools/all/patches/0007-2.5.2-use-diligent-core-dependencies.diff @@ -0,0 +1,97 @@ +diff --git a/AssetLoader/CMakeLists.txt b/AssetLoader/CMakeLists.txt +index 9c9a16d..7479b6c 100644 +--- a/AssetLoader/CMakeLists.txt ++++ b/AssetLoader/CMakeLists.txt +@@ -35,13 +35,8 @@ source_group("interface" FILES ${INTERFACE}) + + target_link_libraries(Diligent-AssetLoader + PRIVATE +- Diligent-BuildSettings +- Diligent-Common +- Diligent-PlatformInterface +- Diligent-GraphicsEngineInterface +- Diligent-GraphicsAccessories +- Diligent-GraphicsTools + Diligent-TextureLoader ++ diligent-core::diligent-core + ) + + if (TARGET draco) +diff --git a/HLSL2GLSLConverter/CMakeLists.txt b/HLSL2GLSLConverter/CMakeLists.txt +index 0b1de80..5f800f3 100644 +--- a/HLSL2GLSLConverter/CMakeLists.txt ++++ b/HLSL2GLSLConverter/CMakeLists.txt +@@ -33,12 +33,7 @@ target_compile_definitions(HLSL2GLSLConverter PRIVATE UNICODE) + + target_link_libraries(HLSL2GLSLConverter + PRIVATE +- Diligent-BuildSettings +- Diligent-TargetPlatform +- Diligent-Common +- Diligent-GraphicsTools +- Diligent-HLSL2GLSLConverterLib +- Diligent-GraphicsEngineOpenGL-static ++ diligent-core::diligent-core + ) + + source_group("source" FILES ${SOURCE}) +diff --git a/Imgui/CMakeLists.txt b/Imgui/CMakeLists.txt +index 64a2a77..bc0fb39 100644 +--- a/Imgui/CMakeLists.txt ++++ b/Imgui/CMakeLists.txt +@@ -116,13 +116,8 @@ source_group("imGuIZMO.quat" FILES ${IMGUIZMO_QUAT_SOURCE}) + + target_link_libraries(Diligent-Imgui + PRIVATE +- Diligent-BuildSettings +- Diligent-Common +- Diligent-PlatformInterface +- Diligent-GraphicsEngineInterface +- Diligent-GraphicsAccessories +- Diligent-GraphicsTools +- imgui::imgui ++ diligent-core::diligent-core ++ imgui::imgui + ) + + set_target_properties(Diligent-Imgui PROPERTIES +diff --git a/NativeApp/Android/ndk_helper/CMakeLists.txt b/NativeApp/Android/ndk_helper/CMakeLists.txt +index 6f23857..35d2f02 100644 +--- a/NativeApp/Android/ndk_helper/CMakeLists.txt ++++ b/NativeApp/Android/ndk_helper/CMakeLists.txt +@@ -29,7 +29,7 @@ PUBLIC + + target_link_libraries(NDKHelper + PRIVATE +- Diligent-BuildSettings ++ diligent-core::diligent-core + PUBLIC + native_app_glue + ) +diff --git a/NativeApp/CMakeLists.txt b/NativeApp/CMakeLists.txt +index 7ea2063..951206b 100644 +--- a/NativeApp/CMakeLists.txt ++++ b/NativeApp/CMakeLists.txt +@@ -435,8 +435,7 @@ PUBLIC + + target_link_libraries(Diligent-NativeAppBase + PRIVATE +- Diligent-BuildSettings +- Diligent-Common ++ diligent-core::diligent-core + ) + + if(PLATFORM_WIN32) +diff --git a/NativeApp/Linux/CMakeLists.txt b/NativeApp/Linux/CMakeLists.txt +index a550fe0..e17d01c 100644 +--- a/NativeApp/Linux/CMakeLists.txt ++++ b/NativeApp/Linux/CMakeLists.txt +@@ -20,7 +20,7 @@ source_group("interface" FILES ${INTERFACE}) + + target_link_libraries(XCBKeySyms + PRIVATE +- Diligent-BuildSettings ++ diligent-core::diligent-core + xcb + ) + diff --git a/recipes/diligent-tools/all/patches/0008-2.5.2-use-conan-dependencies.diff b/recipes/diligent-tools/all/patches/0008-2.5.2-use-conan-dependencies.diff new file mode 100644 index 0000000000000..25a58db257d65 --- /dev/null +++ b/recipes/diligent-tools/all/patches/0008-2.5.2-use-conan-dependencies.diff @@ -0,0 +1,18 @@ +diff --git a/TextureLoader/CMakeLists.txt b/TextureLoader/CMakeLists.txt +index 362e209..256b352 100644 +--- a/TextureLoader/CMakeLists.txt ++++ b/TextureLoader/CMakeLists.txt +@@ -47,12 +47,7 @@ source_group("interface" FILES ${INTERFACE}) + + target_link_libraries(Diligent-TextureLoader + PRIVATE +- Diligent-BuildSettings +- Diligent-Common +- Diligent-PlatformInterface +- Diligent-GraphicsEngineInterface +- Diligent-GraphicsAccessories +- Diligent-GraphicsTools ++ diligent-core::diligent-core + PNG::PNG + TIFF::TIFF + ZLIB::ZLIB diff --git a/recipes/diligent-tools/all/patches/0009-2.5.2-fix-include-path.diff b/recipes/diligent-tools/all/patches/0009-2.5.2-fix-include-path.diff new file mode 100644 index 0000000000000..3d6f8246a5f82 --- /dev/null +++ b/recipes/diligent-tools/all/patches/0009-2.5.2-fix-include-path.diff @@ -0,0 +1,13 @@ +diff --git a/Imgui/src/ImGuiImplWin32.cpp b/Imgui/src/ImGuiImplWin32.cpp +--- a/Imgui/src/ImGuiImplWin32.cpp ++++ b/Imgui/src/ImGuiImplWin32.cpp +@@ -32,7 +32,7 @@ + #include "GraphicsTypes.h" + #include "imgui.h" + #include "ImGuiImplWin32.hpp" +-#include "backends/imgui_impl_win32.h" ++#include "../res/bindings/imgui_impl_win32.h" + #include "DebugUtilities.hpp" + + IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + diff --git a/recipes/diligent-tools/all/patches/0010-2.5.2-fix-render-state-notation-paths.diff b/recipes/diligent-tools/all/patches/0010-2.5.2-fix-render-state-notation-paths.diff new file mode 100644 index 0000000000000..9099a853a4abb --- /dev/null +++ b/recipes/diligent-tools/all/patches/0010-2.5.2-fix-render-state-notation-paths.diff @@ -0,0 +1,43 @@ +diff --git a/RenderStateNotation/CMakeLists.txt b/RenderStateNotation/CMakeLists.txt +index fca3d7b..30ded42 100644 +--- a/RenderStateNotation/CMakeLists.txt ++++ b/RenderStateNotation/CMakeLists.txt +@@ -3,18 +3,18 @@ cmake_minimum_required (VERSION 3.6) + project(Diligent-RenderStateNotation CXX) + + set(REFLECTED +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/BlendState.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/DepthStencilState.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/GraphicsTypes.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/InputLayout.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/PipelineState.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/RasterizerState.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/RenderPass.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/Shader.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/GraphicsEngine/interface/Sampler.h +- ${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/Graphics/Archiver/interface/ArchiverFactory.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/BlendState.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/DepthStencilState.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/GraphicsTypes.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/InputLayout.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/PipelineResourceSignature.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/PipelineState.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/RasterizerState.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/RenderPass.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/Shader.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/GraphicsEngine/interface/Sampler.h ++ ${CONAN_DILIGENT-CORE_ROOT}/include/DiligentCore/Graphics/Archiver/interface/ArchiverFactory.h + ) + + set(RSN_PARSER_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/parser_headers CACHE INTERNAL "Render State Notation Parser generated headers directory") +@@ -64,7 +64,6 @@ endif() + + add_custom_command(OUTPUT ${GENERATED} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/scripts/cxx_generator.py" --dir "." --files ${REFLECTED} +- COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/../../DiligentCore/BuildTools/FormatValidation/${CLANG_FORMAT_VERSION}" -i *.hpp --verbose + WORKING_DIRECTORY "${RSN_PARSER_GENERATED_HEADERS_DIR}" + DEPENDS ${REFLECTED} + COMMENT "RSN Parser Header Generation") diff --git a/recipes/diligent-tools/all/patches/0011-2.5.2-use-conan-dependencies-part2.diff b/recipes/diligent-tools/all/patches/0011-2.5.2-use-conan-dependencies-part2.diff new file mode 100644 index 0000000000000..75579bd94bb7b --- /dev/null +++ b/recipes/diligent-tools/all/patches/0011-2.5.2-use-conan-dependencies-part2.diff @@ -0,0 +1,35 @@ +diff --git a/RenderStateNotation/CMakeLists.txt b/RenderStateNotation/CMakeLists.txt +index 30ded42..34cc344 100644 +--- a/RenderStateNotation/CMakeLists.txt ++++ b/RenderStateNotation/CMakeLists.txt +@@ -88,12 +88,7 @@ PRIVATE + + target_link_libraries(Diligent-RenderStateNotation + PRIVATE +- Diligent-BuildSettings +- Diligent-Common +- Diligent-PlatformInterface +- Diligent-GraphicsEngineInterface +- Diligent-GraphicsAccessories +- Diligent-GraphicsTools ++diligent-core::diligent-core + ) + + target_compile_definitions(Diligent-RenderStateNotation PUBLIC JSON_DIAGNOSTICS=1) +diff --git a/RenderStatePackager/CMakeLists.txt b/RenderStatePackager/CMakeLists.txt +index 003a298..f047083 100644 +--- a/RenderStatePackager/CMakeLists.txt ++++ b/RenderStatePackager/CMakeLists.txt +@@ -25,11 +25,7 @@ target_include_directories(Diligent-RenderStatePackager + + target_link_libraries(Diligent-RenderStatePackager + PUBLIC +- Diligent-BuildSettings +- Diligent-GraphicsAccessories +- Diligent-Common +- Diligent-Archiver-static +- Diligent-RenderStateNotation ++diligent-core::diligent-core + ) + + set_target_properties(Diligent-RenderStatePackager PROPERTIES diff --git a/recipes/diligent-tools/all/patches/0012-2.5.2-fix-imgui-include-path.diff b/recipes/diligent-tools/all/patches/0012-2.5.2-fix-imgui-include-path.diff new file mode 100644 index 0000000000000..c8b1088f0d524 --- /dev/null +++ b/recipes/diligent-tools/all/patches/0012-2.5.2-fix-imgui-include-path.diff @@ -0,0 +1,26 @@ +diff --git a/Imgui/src/ImGuiImplMacOS.mm b/Imgui/src/ImGuiImplMacOS.mm +index 3b5c217..6cdabdb 100644 +--- a/Imgui/src/ImGuiImplMacOS.mm ++++ b/Imgui/src/ImGuiImplMacOS.mm +@@ -23,7 +23,7 @@ + + #include "imgui.h" + #include "ImGuiImplMacOS.hpp" +-#include "backends/imgui_impl_osx.h" ++#include "../res/bindings/imgui_impl_osx.h" + #import + + namespace Diligent +diff --git a/Imgui/src/ImGuiImplWin32.cpp b/Imgui/src/ImGuiImplWin32.cpp +index d5f4767..b7cefb2 100644 +--- a/Imgui/src/ImGuiImplWin32.cpp ++++ b/Imgui/src/ImGuiImplWin32.cpp +@@ -32,7 +32,7 @@ + #include "GraphicsTypes.h" + #include "imgui.h" + #include "ImGuiImplWin32.hpp" +-#include "backends/imgui_impl_win32.h" ++#include "../res/bindings/imgui_impl_win32.h" + #include "DebugUtilities.hpp" + + IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); \ No newline at end of file diff --git a/recipes/diligent-tools/all/test_package/CMakeLists.txt b/recipes/diligent-tools/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..86493ca2e0e0f --- /dev/null +++ b/recipes/diligent-tools/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(diligent-tools CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} diligent-tools::diligent-tools) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/diligent-tools/all/test_package/conanfile.py b/recipes/diligent-tools/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/diligent-tools/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/diligent-tools/all/test_package/test_package.cpp b/recipes/diligent-tools/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..5d09457bb585e --- /dev/null +++ b/recipes/diligent-tools/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + Diligent::GLTF::Material material; + return 0; +} diff --git a/recipes/diligent-tools/config.yml b/recipes/diligent-tools/config.yml new file mode 100644 index 0000000000000..961e780a18a9f --- /dev/null +++ b/recipes/diligent-tools/config.yml @@ -0,0 +1,9 @@ +versions: + "api.252009": + folder: "all" + "api.252005": + folder: "all" + "cci.20211009": + folder: "all" + "2.5.2": + folder: "all" diff --git a/recipes/brotli/all/CMakeLists.txt b/recipes/diligentgraphics-spirv-headers/all/CMakeLists.txt similarity index 100% rename from recipes/brotli/all/CMakeLists.txt rename to recipes/diligentgraphics-spirv-headers/all/CMakeLists.txt diff --git a/recipes/diligentgraphics-spirv-headers/all/conandata.yml b/recipes/diligentgraphics-spirv-headers/all/conandata.yml new file mode 100644 index 0000000000000..484bd4f756594 --- /dev/null +++ b/recipes/diligentgraphics-spirv-headers/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20211006": + url: https://github.com/DiligentGraphics/SPIRV-Headers/archive/5ea2d62e8c0ddd9e2a7d0ca5e3f2335e09e5f408.zip + sha256: 8b9a9b49600a01d7d768c7e95ae09a4e81e7b2b3ed0a7a24d2375474c00d06ff diff --git a/recipes/diligentgraphics-spirv-headers/all/conanfile.py b/recipes/diligentgraphics-spirv-headers/all/conanfile.py new file mode 100644 index 0000000000000..2ea40ddfdfe54 --- /dev/null +++ b/recipes/diligentgraphics-spirv-headers/all/conanfile.py @@ -0,0 +1,59 @@ +from conans import ConanFile, tools, CMake +import os + +required_conan_version = ">=1.33.0" + + +class SpirvheadersConan(ConanFile): + name = "diligentgraphics-spirv-headers" + homepage = "https://github.com/DiligentGraphics/SPIRV-Headers" + description = "Diligent fork of header files for the SPIRV instruction set." + license = "MIT-KhronosGroup" + topics = ("spirv", "spirv-v", "vulkan", "opengl", "opencl", "khronos") + url = "https://github.com/conan-io/conan-center-index" + provides = "spirv-headers" + deprecated = "spirv-headers" + + settings = "os", "compiler", "arch", "build_type" + + exports_sources = "CMakeLists.txt" + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["SPIRV_HEADERS_SKIP_EXAMPLES"] = True + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE*", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "SPIRV-Headers" + self.cpp_info.names["cmake_find_package_multi"] = "SPIRV-Headers" diff --git a/recipes/diligentgraphics-spirv-headers/all/test_package/CMakeLists.txt b/recipes/diligentgraphics-spirv-headers/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..1a13bcce874fc --- /dev/null +++ b/recipes/diligentgraphics-spirv-headers/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(SPIRV-Headers REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} SPIRV-Headers::SPIRV-Headers) diff --git a/recipes/diligentgraphics-spirv-headers/all/test_package/conanfile.py b/recipes/diligentgraphics-spirv-headers/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/diligentgraphics-spirv-headers/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/diligentgraphics-spirv-headers/all/test_package/test_package.cpp b/recipes/diligentgraphics-spirv-headers/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..db6d549853bea --- /dev/null +++ b/recipes/diligentgraphics-spirv-headers/all/test_package/test_package.cpp @@ -0,0 +1,43 @@ +// Copyright (c) 2016 The Khronos Group Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and/or associated documentation files (the +// "Materials"), to deal in the Materials without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Materials, and to +// permit persons to whom the Materials are furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Materials. +// +// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS +// KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS +// SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT +// https://www.khronos.org/registry/ +// +// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +#include +#include +#include + +namespace { + +const GLSLstd450 kSin = GLSLstd450Sin; +const OpenCLLIB::Entrypoints kNative_cos = OpenCLLIB::Native_cos; +const spv::Op kNop = spv::OpNop; + +} + +int main(int argc, char ** argv) +{ + + return 0; +} diff --git a/recipes/diligentgraphics-spirv-headers/config.yml b/recipes/diligentgraphics-spirv-headers/config.yml new file mode 100644 index 0000000000000..ae88f0a176dec --- /dev/null +++ b/recipes/diligentgraphics-spirv-headers/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20211006": + folder: all diff --git a/recipes/c-ares/all/CMakeLists.txt b/recipes/diligentgraphics-spirv-tools/all/CMakeLists.txt similarity index 100% rename from recipes/c-ares/all/CMakeLists.txt rename to recipes/diligentgraphics-spirv-tools/all/CMakeLists.txt diff --git a/recipes/diligentgraphics-spirv-tools/all/conandata.yml b/recipes/diligentgraphics-spirv-tools/all/conandata.yml new file mode 100644 index 0000000000000..707d246773a1c --- /dev/null +++ b/recipes/diligentgraphics-spirv-tools/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20211008": + url: https://github.com/DiligentGraphics/SPIRV-Tools/archive/7308083707a4bffb62bcfbc721851033e5534bb7.zip + sha256: bfe9d6f1c2cfc354c0eda3c2139485cae4483d8b12fa994d1f0f1f3624645fcd diff --git a/recipes/diligentgraphics-spirv-tools/all/conanfile.py b/recipes/diligentgraphics-spirv-tools/all/conanfile.py new file mode 100644 index 0000000000000..04f39fb2c75a4 --- /dev/null +++ b/recipes/diligentgraphics-spirv-tools/all/conanfile.py @@ -0,0 +1,223 @@ +from conans import ConanFile, tools, CMake +from conans.errors import ConanInvalidConfiguration +import os +import textwrap + +required_conan_version = ">=1.33.0" + + +class SpirvtoolsConan(ConanFile): + name = "diligentgraphics-spirv-tools" + homepage = "https://github.com/DiligentGraphics/SPIRV-Tools/" + description = "Diligent fork. Create and optimize SPIRV shaders" + topics = ("spirv", "spirv-v", "vulkan", "opengl", "opencl", "hlsl", "khronos", "diligent") + url = "https://github.com/conan-io/conan-center-index" + provides = "spirv-tools" + deprecated = "spirv-tools" + license = "Apache-2.0" + + settings = "os", "compiler", "arch", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "build_executables": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "build_executables": True, + } + + short_paths = True + + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if not self._get_compatible_spirv_headers_version: + raise ConanInvalidConfiguration("unknown diligentgraphics-spirv-headers version") + self.requires("diligentgraphics-spirv-headers/{}".format(self._get_compatible_spirv_headers_version)) + + @property + def _get_compatible_spirv_headers_version(self): + return { + "cci.20211008": "cci.20211006", + }.get(str(self.version), False) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + def _validate_dependency_graph(self): + if self.deps_cpp_info["diligentgraphics-spirv-headers"].version != self._get_compatible_spirv_headers_version: + raise ConanInvalidConfiguration("diligentgraphics-spirv-tools {0} requires diligentgraphics-spirv-headers {1}" + .format(self.version, self._get_compatible_spirv_headers_version)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + + cmake = CMake(self) + + # Required by the project's CMakeLists.txt + cmake.definitions["SPIRV-Headers_SOURCE_DIR"] = self.deps_cpp_info["diligentgraphics-spirv-headers"].rootpath.replace("\\", "/") + + # There are some switch( ) statements that are causing errors + # need to turn this off + cmake.definitions["SPIRV_WERROR"] = False + + cmake.definitions["SKIP_SPIRV_TOOLS_INSTALL"] = False + cmake.definitions["SPIRV_LOG_DEBUG"] = False + cmake.definitions["SPIRV_SKIP_TESTS"] = True + cmake.definitions["SPIRV_CHECK_CONTEXT"] = False + cmake.definitions["SPIRV_BUILD_FUZZER"] = False + cmake.definitions["SPIRV_SKIP_EXECUTABLES"] = not self.options.build_executables + + cmake.configure(build_folder=self._build_subfolder) + self._cmake = cmake + return self._cmake + + def build(self): + self._validate_dependency_graph() + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + # CMAKE_POSITION_INDEPENDENT_CODE was set ON for the entire + # project in the lists file. + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "") + + def package(self): + self.copy(pattern="LICENSE*", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools")) + tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools-link")) + tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools-opt")) + tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools-reduce")) + tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools-lint")) + + if self.options.shared: + for file_name in ["*SPIRV-Tools", "*SPIRV-Tools-opt", "*SPIRV-Tools-link", "*SPIRV-Tools-reduce"]: + for ext in [".a", ".lib"]: + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), file_name + ext) + else: + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*SPIRV-Tools-shared.dll") + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*SPIRV-Tools-shared*") + + if self.options.shared: + targets = {"SPIRV-Tools-shared": "diligentgraphics-spirv-tools::SPIRV-Tools"} + else: + targets = { + "SPIRV-Tools": "diligentgraphics-spirv-tools::SPIRV-Tools", # before 2020.5, kept for conveniency + "SPIRV-Tools-static": "diligentgraphics-spirv-tools::SPIRV-Tools", + "SPIRV-Tools-opt": "diligentgraphics-spirv-tools::SPIRV-Tools-opt", + "SPIRV-Tools-link": "diligentgraphics-spirv-tools::SPIRV-Tools-link", + "SPIRV-Tools-reduce": "diligentgraphics-spirv-tools::SPIRV-Tools-reduce", + } + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + targets, + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake") + + @property + def _module_file_rel_path(self): + return os.path.join(self._module_subfolder, + "conan-official-{}-targets.cmake".format(self.name)) + + def package_info(self): + self.cpp_info.filenames["cmake_find_package"] = "SPIRV-Tools" + self.cpp_info.filenames["cmake_find_package_multi"] = "SPIRV-Tools" + self.cpp_info.names["pkg_config"] = "SPIRV-Tools-shared" if self.options.shared else "SPIRV-Tools" + + # SPIRV-Tools + self.cpp_info.components["spirv-tools-core"].names["cmake_find_package"] = "SPIRV-Tools" + self.cpp_info.components["spirv-tools-core"].names["cmake_find_package_multi"] = "SPIRV-Tools" + self.cpp_info.components["spirv-tools-core"].builddirs.append(self._module_subfolder) + self.cpp_info.components["spirv-tools-core"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["spirv-tools-core"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["spirv-tools-core"].libs = ["SPIRV-Tools-shared" if self.options.shared else "SPIRV-Tools"] + self.cpp_info.components["spirv-tools-core"].requires = ["diligentgraphics-spirv-headers::diligentgraphics-spirv-headers"] + if self.options.shared: + self.cpp_info.components["spirv-tools-core"].defines = ["SPIRV_TOOLS_SHAREDLIB"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["spirv-tools-core"].system_libs.extend(["m", "rt"]) + if not self.options.shared and tools.stdcpp_library(self): + self.cpp_info.components["spirv-tools-core"].system_libs.append(tools.stdcpp_library(self)) + + # FIXME: others components should have their own CMake config file + if not self.options.shared: + # SPIRV-Tools-opt + self.cpp_info.components["spirv-tools-opt"].names["cmake_find_package"] = "SPIRV-Tools-opt" + self.cpp_info.components["spirv-tools-opt"].names["cmake_find_package_multi"] = "SPIRV-Tools-opt" + self.cpp_info.components["spirv-tools-opt"].builddirs.append(self._module_subfolder) + self.cpp_info.components["spirv-tools-opt"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["spirv-tools-opt"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["spirv-tools-opt"].libs = ["SPIRV-Tools-opt"] + self.cpp_info.components["spirv-tools-opt"].requires = ["spirv-tools-core", "diligentgraphics-spirv-headers::diligentgraphics-spirv-headers"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["spirv-tools-opt"].system_libs.append("m") + # SPIRV-Tools-link + self.cpp_info.components["spirv-tools-link"].names["cmake_find_package"] = "SPIRV-Tools-link" + self.cpp_info.components["spirv-tools-link"].names["cmake_find_package_multi"] = "SPIRV-Tools-link" + self.cpp_info.components["spirv-tools-link"].builddirs.append(self._module_subfolder) + self.cpp_info.components["spirv-tools-link"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["spirv-tools-link"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["spirv-tools-link"].libs = ["SPIRV-Tools-link"] + self.cpp_info.components["spirv-tools-link"].requires = ["spirv-tools-core", "spirv-tools-opt"] + # SPIRV-Tools-reduce + self.cpp_info.components["spirv-tools-reduce"].names["cmake_find_package"] = "SPIRV-Tools-reduce" + self.cpp_info.components["spirv-tools-reduce"].names["cmake_find_package_multi"] = "SPIRV-Tools-reduce" + self.cpp_info.components["spirv-tools-reduce"].builddirs.append(self._module_subfolder) + self.cpp_info.components["spirv-tools-reduce"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["spirv-tools-reduce"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["spirv-tools-reduce"].libs = ["SPIRV-Tools-reduce"] + self.cpp_info.components["spirv-tools-reduce"].requires = ["spirv-tools-core", "spirv-tools-opt"] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: %s" % bin_path) + self.env_info.path.append(bin_path) diff --git a/recipes/spirv-tools/all/patches/support-SPV_KHR_fragment_shading_rate.patch b/recipes/diligentgraphics-spirv-tools/all/patches/support-SPV_KHR_fragment_shading_rate.patch similarity index 100% rename from recipes/spirv-tools/all/patches/support-SPV_KHR_fragment_shading_rate.patch rename to recipes/diligentgraphics-spirv-tools/all/patches/support-SPV_KHR_fragment_shading_rate.patch diff --git a/recipes/diligentgraphics-spirv-tools/all/test_package/CMakeLists.txt b/recipes/diligentgraphics-spirv-tools/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..17a8d915b246e --- /dev/null +++ b/recipes/diligentgraphics-spirv-tools/all/test_package/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(SPIRV-Tools REQUIRED CONFIG) + +add_executable(${PROJECT_NAME}_c test_package.c) +if(TARGET SPIRV-Tools-shared) + target_link_libraries(${PROJECT_NAME}_c SPIRV-Tools-shared) +elseif(TARGET SPIRV-Tools-static) + target_link_libraries(${PROJECT_NAME}_c SPIRV-Tools-static) +else() + message(FATAL_ERROR "Neither target SPIRV-Tools-shared or target SPIRV-Tools-shared exist") +endif() + +# TODO: we should call find_package(SPIRV-Tools-opt REQUIRED CONFIG), but not modeled right now +if(TARGET SPIRV-Tools-opt) + add_executable(${PROJECT_NAME}_cpp test_package.cpp) + target_link_libraries(${PROJECT_NAME}_cpp SPIRV-Tools-opt) + set_property(TARGET ${PROJECT_NAME}_cpp PROPERTY CXX_STANDARD 11) +endif() diff --git a/recipes/diligentgraphics-spirv-tools/all/test_package/conanfile.py b/recipes/diligentgraphics-spirv-tools/all/test_package/conanfile.py new file mode 100644 index 0000000000000..095f9b5e4320c --- /dev/null +++ b/recipes/diligentgraphics-spirv-tools/all/test_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path_c = os.path.join("bin", "test_package_c") + self.run(bin_path_c, run_environment=True) + if not self.options["diligentgraphics-spirv-tools"].shared: + bin_path_cpp = os.path.join("bin", "test_package_cpp") + self.run(bin_path_cpp, run_environment=True) diff --git a/recipes/diligentgraphics-spirv-tools/all/test_package/test_package.c b/recipes/diligentgraphics-spirv-tools/all/test_package/test_package.c new file mode 100644 index 0000000000000..932428db546e7 --- /dev/null +++ b/recipes/diligentgraphics-spirv-tools/all/test_package/test_package.c @@ -0,0 +1,31 @@ +#include "spirv-tools/libspirv.h" + +int main(int argc, char ** argv) +{ +const char input_text[] = + "OpCapability Shader\n" + "OpCapability Linkage\n" + "OpMemoryModel Logical GLSL450"; + spv_text text; + spv_binary binary; + spv_context context; + + context = spvContextCreate(SPV_ENV_UNIVERSAL_1_1); + + binary = 0; + if( SPV_SUCCESS != spvTextToBinary(context, input_text, sizeof(input_text), &binary, 0) ) + { + return 1; + } + + text = 0; + if( SPV_SUCCESS != spvBinaryToText(context, binary->code, binary->wordCount, 0, &text, 0) ) + { + return 1; + } + + spvTextDestroy(text); + spvBinaryDestroy(binary); + spvContextDestroy(context); + return 0; +} diff --git a/recipes/diligentgraphics-spirv-tools/all/test_package/test_package.cpp b/recipes/diligentgraphics-spirv-tools/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..a1e22c7365ae8 --- /dev/null +++ b/recipes/diligentgraphics-spirv-tools/all/test_package/test_package.cpp @@ -0,0 +1,65 @@ +// Copyright (c) 2016 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This program demonstrates basic SPIR-V module processing using +// SPIRV-Tools C++ API: +// * Assembling +// * Validating +// * Optimizing +// * Disassembling + +#include +#include +#include + +#include "spirv-tools/libspirv.hpp" +#include "spirv-tools/optimizer.hpp" + +int main() { + const std::string source = + " OpCapability Linkage " + " OpCapability Shader " + " OpMemoryModel Logical GLSL450 " + " OpSource GLSL 450 " + " OpDecorate %spec SpecId 1 " + " %int = OpTypeInt 32 1 " + " %spec = OpSpecConstant %int 0 " + "%const = OpConstant %int 42"; + + spvtools::SpirvTools core(SPV_ENV_UNIVERSAL_1_3); + spvtools::Optimizer opt(SPV_ENV_UNIVERSAL_1_3); + + auto print_msg_to_stderr = [](spv_message_level_t, const char*, + const spv_position_t&, const char* m) { + std::cerr << "error: " << m << std::endl; + }; + core.SetMessageConsumer(print_msg_to_stderr); + opt.SetMessageConsumer(print_msg_to_stderr); + + std::vector spirv; + if (!core.Assemble(source, &spirv)) return 1; + if (!core.Validate(spirv)) return 1; + + opt.RegisterPass(spvtools::CreateSetSpecConstantDefaultValuePass({{1, "42"}})) + .RegisterPass(spvtools::CreateFreezeSpecConstantValuePass()) + .RegisterPass(spvtools::CreateUnifyConstantPass()) + .RegisterPass(spvtools::CreateStripDebugInfoPass()); + if (!opt.Run(spirv.data(), spirv.size(), &spirv)) return 1; + + std::string disassembly; + if (!core.Disassemble(spirv, &disassembly)) return 1; + std::cout << disassembly << "\n"; + + return 0; +} diff --git a/recipes/diligentgraphics-spirv-tools/config.yml b/recipes/diligentgraphics-spirv-tools/config.yml new file mode 100644 index 0000000000000..b60234b0142df --- /dev/null +++ b/recipes/diligentgraphics-spirv-tools/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20211008": + folder: all diff --git a/recipes/diligentgraphics-vulkan-headers/all/conandata.yml b/recipes/diligentgraphics-vulkan-headers/all/conandata.yml new file mode 100644 index 0000000000000..055ccbddfe499 --- /dev/null +++ b/recipes/diligentgraphics-vulkan-headers/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20211005": + url: "https://github.com/DiligentGraphics/Vulkan-Headers/archive/fa27a13cf74080df2ad421a788299db1276f17a7.zip" + sha256: "c4af8476d8ac788c5d7fea9fc74c982a64e280c592c5c68fe65e3119f40ed58e" diff --git a/recipes/diligentgraphics-vulkan-headers/all/conanfile.py b/recipes/diligentgraphics-vulkan-headers/all/conanfile.py new file mode 100644 index 0000000000000..7f3356c28a8d9 --- /dev/null +++ b/recipes/diligentgraphics-vulkan-headers/all/conanfile.py @@ -0,0 +1,49 @@ +from conans import ConanFile, tools +import glob +import os + +required_conan_version = ">=1.33" + + +class VulkanHeadersConan(ConanFile): + name = "diligentgraphics-vulkan-headers" + description = "Diligent fork of Vulkan Header files." + license = "Apache-2.0" + topics = ("vulkan-headers", "vulkan") + homepage = "https://github.com/DiligentGraphics/Vulkan-Headers" + url = "https://github.com/conan-io/conan-center-index" + provides = "vulkan-headers" + deprecated = "vulkan-headers" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + self.copy("*", dst="include", src=os.path.join(self.source_folder, self._source_subfolder, "include")) + self.copy("*", dst=os.path.join("res", "vulkan", "registry"), + src=os.path.join(self.source_folder, self._source_subfolder, "registry")) + + def package_info(self): + self.cpp_info.filenames["cmake_find_package"] = "VulkanHeaders" + self.cpp_info.filenames["cmake_find_package_multi"] = "VulkanHeaders" + self.cpp_info.names["cmake_find_package"] = "Vulkan" + self.cpp_info.names["cmake_find_package_multi"] = "Vulkan" + self.cpp_info.components["vulkanheaders"].names["cmake_find_package"] = "Headers" + self.cpp_info.components["vulkanheaders"].names["cmake_find_package_multi"] = "Headers" + self.cpp_info.components["vulkanheaders"].bindirs = [] + self.cpp_info.components["vulkanheaders"].libdirs = [] + self.cpp_info.components["vulkanregistry"].names["cmake_find_package"] = "Registry" + self.cpp_info.components["vulkanregistry"].names["cmake_find_package_multi"] = "Registry" + self.cpp_info.components["vulkanregistry"].includedirs = [os.path.join("res", "vulkan", "registry")] + self.cpp_info.components["vulkanregistry"].bindirs = [] + self.cpp_info.components["vulkanregistry"].libdirs = [] diff --git a/recipes/diligentgraphics-vulkan-headers/all/test_package/CMakeLists.txt b/recipes/diligentgraphics-vulkan-headers/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5e69638f3fc18 --- /dev/null +++ b/recipes/diligentgraphics-vulkan-headers/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(VulkanHeaders REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} Vulkan::Headers) diff --git a/recipes/diligentgraphics-vulkan-headers/all/test_package/conanfile.py b/recipes/diligentgraphics-vulkan-headers/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b6a26067f365d --- /dev/null +++ b/recipes/diligentgraphics-vulkan-headers/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os + +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/diligentgraphics-vulkan-headers/all/test_package/test_package.c b/recipes/diligentgraphics-vulkan-headers/all/test_package/test_package.c new file mode 100644 index 0000000000000..defd9fd301685 --- /dev/null +++ b/recipes/diligentgraphics-vulkan-headers/all/test_package/test_package.c @@ -0,0 +1,21 @@ +#include + +int main() { + VkApplicationInfo appInfo; + appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; + appInfo.pApplicationName = "Hello Conan"; + appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0); + appInfo.pEngineName = "Dummy Engine"; + appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0); + appInfo.apiVersion = VK_API_VERSION_1_0; + + VkInstanceCreateInfo createInfo; + createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + createInfo.pApplicationInfo = &appInfo; + createInfo.enabledLayerCount = 0; + createInfo.ppEnabledLayerNames = NULL; + createInfo.enabledExtensionCount = 0; + createInfo.ppEnabledExtensionNames = NULL; + + return 0; +} diff --git a/recipes/diligentgraphics-vulkan-headers/config.yml b/recipes/diligentgraphics-vulkan-headers/config.yml new file mode 100644 index 0000000000000..3d7bd37111af4 --- /dev/null +++ b/recipes/diligentgraphics-vulkan-headers/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20211005": + folder: all diff --git a/recipes/dime/all/CMakeLists.txt b/recipes/dime/all/CMakeLists.txt new file mode 100644 index 0000000000000..8977c3f43d6f8 --- /dev/null +++ b/recipes/dime/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.11) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/dime/all/conandata.yml b/recipes/dime/all/conandata.yml new file mode 100644 index 0000000000000..3672fc5963336 --- /dev/null +++ b/recipes/dime/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.9.1": + url: "https://github.com/coin3d/dime/releases/download/dime-0.9.1/dime-0.9.1-src.tar.gz" + sha256: "ded4c45b4a13a876d87bb36a0fba40d3456ccda3add739791da117e9603f0325" diff --git a/recipes/dime/all/conanfile.py b/recipes/dime/all/conanfile.py new file mode 100644 index 0000000000000..4c72fb275c245 --- /dev/null +++ b/recipes/dime/all/conanfile.py @@ -0,0 +1,96 @@ +from conans import ConanFile, CMake, tools +from conan.tools.microsoft import is_msvc +import os +import functools + +required_conan_version = ">=1.33.0" + +class DimeConan(ConanFile): + name = "dime" + description = "DXF (Data eXchange Format) file format support library." + topics = ("dxf", "coin3d", "opengl", "graphics") + homepage = "https://github.com/coin3d/dime" + url = "https://github.com/conan-io/conan-center-index" + license = "BSD-3-Clause" + exports_sources = ["CMakeLists.txt"] + generators = "cmake", + settings = "os", "arch", "compiler", "build_type", + options = { + "fPIC": [True, False], + "shared": [True, False], + "fixbig": [True, False], + } + default_options = { + "fPIC": True, + "shared": False, + "fixbig": False, + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "11") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["DIME_BUILD_SHARED_LIBS"] = self.options.shared + if self.options.fixbig: + cmake.definitions["CMAKE_CXX_FLAGS"] = "-DDIME_FIXBIG" + cmake.configure(build_folder=self._build_subfolder) + return cmake + + def build(self): + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "configure_file(${CMAKE_SOURCE_DIR}/${PROJECT_NAME_LOWER}.pc.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME_LOWER}.pc @ONLY)", + "configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME_LOWER}.pc.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME_LOWER}.pc @ONLY)") + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + if self.settings.os == "Windows" and is_msvc(self): + tools.remove_files_by_mask(self.package_folder, "*.pdb") + + def package_info(self): + libname = "dime" + if self.settings.os == "Windows" and is_msvc(self): + libname = "{}{}{}{}".format( + libname, + tools.Version(self.version).major, + "" if self.options.shared else "s", + "d" if self.settings.build_type == "Debug" else "", + ) + self.cpp_info.libs = [libname] + + if self.settings.os == "Windows": + self.cpp_info.cxxflags.append("-DDIME_DLL" if self.options.shared else "-DDIME_NOT_DLL") + if self.options.fixbig: + self.cpp_info.cxxflags.append("-DDIME_FIXBIG") + + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) diff --git a/recipes/dime/all/test_package/CMakeLists.txt b/recipes/dime/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..78a1ddc2ab6be --- /dev/null +++ b/recipes/dime/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(dime CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} dime::dime) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/dime/all/test_package/conanfile.py b/recipes/dime/all/test_package/conanfile.py new file mode 100644 index 0000000000000..17d1e9ed261a6 --- /dev/null +++ b/recipes/dime/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + dxf_path = os.path.join(self.source_folder, "testFile_Bug01.dxf") + self.run("{} {}".format(bin_path, dxf_path), run_environment=True) diff --git a/recipes/dime/all/test_package/testFile_Bug01.dxf b/recipes/dime/all/test_package/testFile_Bug01.dxf new file mode 100644 index 0000000000000..0e5c47430e86d --- /dev/null +++ b/recipes/dime/all/test_package/testFile_Bug01.dxf @@ -0,0 +1,104 @@ + 0 +SECTION + 2 +ENTITIES + 0 +POLYLINE + 5 +205 + 8 +0 + 66 + 1 + 10 +0.0 + 20 +0.0 + 30 +0.0 + 0 +VERTEX + 5 +279 + 8 +0 + 10 +-176.07272753254799 + 20 +-907.11665722290854 + 30 +0.0 + 0 +VERTEX + 5 +27A + 8 +0 + 10 +-176.07272753254799 + 20 +-157.11665722290871 + 30 +0.0 + 42 +-0.4142135623730951 + 0 +VERTEX + 5 +27B + 8 +0 + 10 +73.927272467451957 + 20 +92.883342777091343 + 30 +0.0 + 0 +VERTEX + 5 +27C + 8 +0 + 10 +573.92727246745198 + 20 +92.883342777091343 + 30 +0.0 + 42 +0.4142135623730951 + 0 +VERTEX + 5 +27D + 8 +0 + 10 +823.92727246745187 + 20 +342.88334277709129 + 30 +0.0 + 0 +VERTEX + 5 +27E + 8 +0 + 10 +823.92727246745187 + 20 +1092.883342777091 + 30 +0.0 + 0 +SEQEND + 5 +27F + 8 +0 + 0 +ENDSEC + 0 +EOF diff --git a/recipes/dime/all/test_package/test_package.cpp b/recipes/dime/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2b3fd63e8e439 --- /dev/null +++ b/recipes/dime/all/test_package/test_package.cpp @@ -0,0 +1,24 @@ +#include + +#include +#include +#include + +int main(int argc, char* argv[]) { + if (argc < 2) { + return 1; + } + const char* filename = argv[1]; + + dimeInput in; + + if (!in.setFile(filename)) { + std::cerr << "could not read dxf file : " << filename << std::endl; + return 1; + } + + dimeModel model; + model.read(&in); + + return 0; +} diff --git a/recipes/dime/config.yml b/recipes/dime/config.yml new file mode 100644 index 0000000000000..d25f7a4b69da5 --- /dev/null +++ b/recipes/dime/config.yml @@ -0,0 +1,3 @@ +versions: + "0.9.1": + folder: "all" diff --git a/recipes/discount/all/conandata.yml b/recipes/discount/all/conandata.yml new file mode 100644 index 0000000000000..dc0fe14a1af08 --- /dev/null +++ b/recipes/discount/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "2.2.7": + url: "https://www.pell.portland.or.us/~orc/Code/discount/discount-2.2.7.tar.bz2" + sha256: "b1262be5d7b04f3c4e2cee3a0937369b12786af18f65f599f334eefbc0ee9508" +patches: + "2.2.7": + - patch_file: "patches/0001-fix-cmake-install.patch" + - patch_file: "patches/0002-fix-incomplete-type.patch" diff --git a/recipes/discount/all/conanfile.py b/recipes/discount/all/conanfile.py new file mode 100644 index 0000000000000..75f806fa8b9b9 --- /dev/null +++ b/recipes/discount/all/conanfile.py @@ -0,0 +1,96 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +import os + +required_conan_version = ">=1.50.0" + + +class DiscountConan(ConanFile): + name = "discount" + description = "DISCOUNT is a implementation of John Gruber & Aaron Swartz's Markdown markup language." + license = "BSD-3-Clause" + topics = ("discount", "markdown") + homepage = "http://www.pell.portland.or.us/~orc/Code/discount" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def validate(self): + if hasattr(self, "settings_build") and cross_building(self): + raise ConanInvalidConfiguration("discount doesn't support cross-build yet") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["DISCOUNT_MAKE_INSTALL"] = True + tc.variables["DISCOUNT_INSTALL_SAMPLES"] = False + tc.variables["DISCOUNT_ONLY_LIBRARY"] = True + # For shared msvc + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + # Relocatable shared lib on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "cmake")) + cmake.build() + + def package(self): + copy(self, "COPYRIGHT", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "discount") + self.cpp_info.set_property("cmake_target_name", "discount::libmarkdown") + self.cpp_info.set_property("pkg_config_name", "libmarkdown") + # TODO: back to global scope in conan v2 once cmake_find_package_* & pkg_config generators removed + self.cpp_info.components["_discount"].libs = ["markdown"] + + # TODO: to remove in conan v2 once cmake_find_package_* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "discount" + self.cpp_info.names["cmake_find_package_multi"] = "discount" + self.cpp_info.names["pkg_config"] = "libmarkdown" + self.cpp_info.components["_discount"].names["cmake_find_package"] = "libmarkdown" + self.cpp_info.components["_discount"].names["cmake_find_package_multi"] = "libmarkdown" + self.cpp_info.components["_discount"].set_property("pkg_config_name", "libmarkdown") diff --git a/recipes/discount/all/patches/0001-fix-cmake-install.patch b/recipes/discount/all/patches/0001-fix-cmake-install.patch new file mode 100644 index 0000000000000..00f48437d17fa --- /dev/null +++ b/recipes/discount/all/patches/0001-fix-cmake-install.patch @@ -0,0 +1,14 @@ +--- a/cmake/CMakeLists.txt ++++ b/cmake/CMakeLists.txt +@@ -182,7 +182,10 @@ if(${PROJECT_NAME}_MAKE_INSTALL) + target_include_directories(libmarkdown INTERFACE + $ + ) +- set(_TARGETS libmarkdown markdown) ++ set(_TARGETS libmarkdown) ++ if(NOT ${PROJECT_NAME}_ONLY_LIBRARY) ++ list(APPEND _TARGETS markdown) ++ endif() + if(${PROJECT_NAME}_INSTALL_SAMPLES) + list(APPEND _TARGETS mkd2html makepage) + endif() diff --git a/recipes/discount/all/patches/0002-fix-incomplete-type.patch b/recipes/discount/all/patches/0002-fix-incomplete-type.patch new file mode 100644 index 0000000000000..b5d6f3bbb14df --- /dev/null +++ b/recipes/discount/all/patches/0002-fix-incomplete-type.patch @@ -0,0 +1,11 @@ +--- a/setup.c ++++ b/setup.c +@@ -31,7 +31,7 @@ mkd_initialize() + } + + +-void DESTRUCTOR ++void + mkd_shlib_destructor() + { + mkd_deallocate_tags(); diff --git a/recipes/discount/all/test_package/CMakeLists.txt b/recipes/discount/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a38ae26b913bf --- /dev/null +++ b/recipes/discount/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(discount REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE discount::libmarkdown) diff --git a/recipes/discount/all/test_package/conanfile.py b/recipes/discount/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/discount/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/discount/all/test_package/test_package.c b/recipes/discount/all/test_package/test_package.c new file mode 100644 index 0000000000000..3846e8db833e9 --- /dev/null +++ b/recipes/discount/all/test_package/test_package.c @@ -0,0 +1,6 @@ +#include + +int main(void) { + mkd_initialize(); + return 0; +} diff --git a/recipes/discount/all/test_v1_package/CMakeLists.txt b/recipes/discount/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4e7a2a3fdc6d8 --- /dev/null +++ b/recipes/discount/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(discount REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE discount::libmarkdown) diff --git a/recipes/discount/all/test_v1_package/conanfile.py b/recipes/discount/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/discount/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/discount/config.yml b/recipes/discount/config.yml new file mode 100644 index 0000000000000..bbfb8846cd874 --- /dev/null +++ b/recipes/discount/config.yml @@ -0,0 +1,3 @@ +versions: + "2.2.7": + folder: all diff --git a/recipes/djinni-generator/all/conandata.yml b/recipes/djinni-generator/all/conandata.yml index 65bba71a817f5..f0faa524fc522 100644 --- a/recipes/djinni-generator/all/conandata.yml +++ b/recipes/djinni-generator/all/conandata.yml @@ -14,3 +14,18 @@ sources: "1.0.0": url: https://github.com/cross-language-cpp/djinni-generator/releases/download/v1.0.0/djinni sha256: "a5dc94cd5175f228eb17e93e0f4cec93c18615758b139707a05f20dc7001f55f" + "1.1.0": + url: https://github.com/cross-language-cpp/djinni-generator/releases/download/v1.1.0/djinni + sha256: "4efd4f68cf913af7c9dd7dd975a8aa2d2a90e8efd9d3b556979ff577923e0d44" + "1.2.0": + url: https://github.com/cross-language-cpp/djinni-generator/releases/download/v1.2.0/djinni + sha256: "6340da0c0ae916d9cc317a03f151e4bb49c3403b76d18cbcdb3600bf47bc59bd" + "1.3.0": + url: https://github.com/cross-language-cpp/djinni-generator/releases/download/v1.3.0/djinni + sha256: "013623e9fcc1c279459b299f0235687202a292015252526113b2015287031424" + "1.3.1": + url: https://github.com/cross-language-cpp/djinni-generator/releases/download/v1.3.1/djinni + sha256: "bfba34fcb83cd42e41657b4951615b823677e3de7674e66d2b26e436e202dd5a" + "1.3.2": + url: https://github.com/cross-language-cpp/djinni-generator/releases/download/v1.3.2/djinni + sha256: "8e618aeb8e9138e7fefaca804263317846799fee59d9465a4eee6625b8266ea1" diff --git a/recipes/djinni-generator/all/conanfile.py b/recipes/djinni-generator/all/conanfile.py index 88cc8b79ba87e..ae2c62ed78bb5 100644 --- a/recipes/djinni-generator/all/conanfile.py +++ b/recipes/djinni-generator/all/conanfile.py @@ -32,5 +32,6 @@ def package(self): self.copy("LICENSE", dst="licenses", keep_path=False) def package_info(self): + self.cpp_info.includedirs = [] self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/djinni-generator/config.yml b/recipes/djinni-generator/config.yml index 58b468609fdaf..47d0ee6875d8a 100644 --- a/recipes/djinni-generator/config.yml +++ b/recipes/djinni-generator/config.yml @@ -9,3 +9,13 @@ versions: folder: "all" "1.0.0": folder: "all" + "1.1.0": + folder: "all" + "1.2.0": + folder: "all" + "1.3.0": + folder: "all" + "1.3.1": + folder: "all" + "1.3.2": + folder: "all" diff --git a/recipes/djinni-support-lib/1.x.x/conandata.yml b/recipes/djinni-support-lib/1.x.x/conandata.yml index 98dce74469b6b..d35c553da9ba8 100644 --- a/recipes/djinni-support-lib/1.x.x/conandata.yml +++ b/recipes/djinni-support-lib/1.x.x/conandata.yml @@ -2,3 +2,12 @@ sources: "1.0.0": url: https://github.com/cross-language-cpp/djinni-support-lib/archive/v1.0.0.tar.gz sha256: "25f8c648c3bec78a54d5387a792f1d7cd3c073c4477dc50ad2b9c5270a590779" + "1.1.0": + url: https://github.com/cross-language-cpp/djinni-support-lib/archive/v1.1.0.tar.gz + sha256: "3a67d1c26959a9df5c158fdf0792e036149009b206ed89fcee8c7b1608187336" + "1.2.0": + url: https://github.com/cross-language-cpp/djinni-support-lib/archive/v1.2.0.tar.gz + sha256: "3630870c2b3305dc6216f8ca8e37139f3f59f2ea7bd600a1154c5aa1c4d983a9" + "1.2.1": + url: https://github.com/cross-language-cpp/djinni-support-lib/archive/v1.2.1.tar.gz + sha256: "ed64d3466ad7f13971913b5bd70c608a558a6b8574d9dbd8779dcdce9b97521b" diff --git a/recipes/djinni-support-lib/1.x.x/conanfile.py b/recipes/djinni-support-lib/1.x.x/conanfile.py index 114142ab0cd85..61920459f5086 100644 --- a/recipes/djinni-support-lib/1.x.x/conanfile.py +++ b/recipes/djinni-support-lib/1.x.x/conanfile.py @@ -3,6 +3,7 @@ from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration + class DjinniSuppotLib(ConanFile): name = "djinni-support-lib" homepage = "https://djinni.xlcpp.dev" @@ -12,14 +13,22 @@ class DjinniSuppotLib(ConanFile): license = "Apache-2.0" settings = "os", "arch", "compiler", "build_type" options = {"shared": [True, False], - "fPIC": [True, False], - "target": ["jni", "objc", "python", "cppcli", "auto"], - "system_java": [True, False] + "fPIC": [True, False], + "target": ["jni", "objc", "python", "cppcli", "auto", "deprecated"], + "with_jni": [True, False, "auto"], + "with_objc": [True, False, "auto"], + "with_python": [True, False, "auto"], + "with_cppcli": [True, False, "auto"], + "system_java": [True, False] } default_options = {"shared": False, - "fPIC": True , - "target": "auto", - "system_java": False, + "fPIC": True, + "target": "deprecated", + "with_jni": "auto", + "with_objc": "auto", + "with_python": "auto", + "with_cppcli": "auto", + "system_java": False, } exports_sources = ["CMakeLists.txt"] generators = "cmake", "cmake_find_package" @@ -28,28 +37,28 @@ class DjinniSuppotLib(ConanFile): @property def _objc_support(self): - if self.options.target == "auto": + if self.options.with_objc == "auto" or self.options.target == "auto": return tools.is_apple_os(self.settings.os) else: - return self.options.target == "objc" + return self.options.with_objc == True or self.options.target == "objc" @property def _jni_support(self): - if self.options.target == "auto": + if self.options.with_jni == "auto" or self.options.target == "auto": return self.settings.os == "Android" else: - return self.options.target == "jni" + return self.options.with_jni == True or self.options.target == "jni" @property def _python_support(self): - return self.options.target == "python" + return self.options.with_python == True or self.options.target == "python" @property def _cppcli_support(self): - if self.options.target == "auto": - return self.settings.os == "Windows" + if self.options.with_cppcli == "auto" or self.options.target == "auto": + return self.settings.os == "Windows" else: - return self.options.target == "cppcli" + return self.options.with_cppcli == True or self.options.target == "cppcli" def configure(self): if self.settings.compiler == "Visual Studio" or self.options.shared: @@ -61,7 +70,7 @@ def _source_subfolder(self): def build_requirements(self): if not self.options.system_java and self._jni_support: - self.build_requires("zulu-openjdk/11.0.8@") + self.build_requires("zulu-openjdk/11.0.12@") def config_options(self): if self.settings.os == "Windows": @@ -79,12 +88,23 @@ def _supported_compilers(self): } def validate(self): + if self.options.target != "deprecated": + self.output.warn("The 'target' option is deprecated and will be removed soon. Use 'with_jni', 'with_objc', 'with_python' or 'with_cppcli' options instead.") if not (self._objc_support or self._jni_support or self._python_support or self._cppcli_support): - raise ConanInvalidConfiguration("Target language could not be determined automatically. Set target explicitly to one of 'jni', 'objc', 'python' or 'cppcli'") - if self._cppcli_support and (self.settings.compiler.runtime == "MT" or self.settings.compiler.runtime == "MTd"): - raise ConanInvalidConfiguration("'/clr' and '/MT' command-line options are incompatible") - if self.options.shared and self._cppcli_support: - raise ConanInvalidConfiguration("C++/CLI does not support building as shared library") + raise ConanInvalidConfiguration("Target language could not be determined automatically. Set at least one of 'with_jni', 'with_objc', 'with_python' or 'with_cppcli' options to `True`.") + if self._cppcli_support: + if self.settings.os != "Windows": + raise ConanInvalidConfiguration("C++/CLI has been enabled on a non-Windows operating system. This is not supported.") + if self.options.shared: + raise ConanInvalidConfiguration("C++/CLI does not support building as shared library") + if self.settings.compiler.runtime == "MT" or self.settings.compiler.runtime == "MTd": + raise ConanInvalidConfiguration("'/clr' and '/MT' command-line options are incompatible") + if self._objc_support or self._jni_support or self._python_support: + raise ConanInvalidConfiguration( + "C++/CLI is not yet supported with other languages enabled as well. Disable 'with_jni', 'with_objc' and 'with_python' options for a valid configuration.") + if self._python_support: + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("Python on Windows is not fully yet supported, please see https://github.com/cross-language-cpp/djinni-support-lib/issues.") if self.settings.get_safe("compiler.cppstd"): tools.check_min_cppstd(self, "17") try: diff --git a/recipes/djinni-support-lib/all/conanfile.py b/recipes/djinni-support-lib/all/conanfile.py index 88059a739a055..97c05458fb360 100644 --- a/recipes/djinni-support-lib/all/conanfile.py +++ b/recipes/djinni-support-lib/all/conanfile.py @@ -39,11 +39,6 @@ def jni_support(self): else: return self.options.target == "jni" - - def configure(self): - if self.settings.compiler == 'Visual Studio': - del self.options.fPIC - @property def _source_subfolder(self): return "source_subfolder" @@ -61,8 +56,8 @@ def configure(self): del self.options.fPIC def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) def _configure_cmake(self): if self._cmake: diff --git a/recipes/djinni-support-lib/config.yml b/recipes/djinni-support-lib/config.yml index 5a5f5fb88a8a1..7faa090829836 100644 --- a/recipes/djinni-support-lib/config.yml +++ b/recipes/djinni-support-lib/config.yml @@ -1,5 +1,11 @@ versions: - "0.0.1": - folder: "all" - "1.0.0": - folder: "1.x.x" + "0.0.1": + folder: "all" + "1.0.0": + folder: "1.x.x" + "1.1.0": + folder: "1.x.x" + "1.2.0": + folder: "1.x.x" + "1.2.1": + folder: "1.x.x" diff --git a/recipes/dlib/all/CMakeLists.txt b/recipes/dlib/all/CMakeLists.txt index e90c4c693057c..1c22f04937945 100644 --- a/recipes/dlib/all/CMakeLists.txt +++ b/recipes/dlib/all/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) # Include the dlib subdirectory to skip a check add_subdirectory(source_subfolder/dlib) diff --git a/recipes/dlib/all/conandata.yml b/recipes/dlib/all/conandata.yml index 6d0c6d7c2d95e..8896193f464de 100644 --- a/recipes/dlib/all/conandata.yml +++ b/recipes/dlib/all/conandata.yml @@ -1,7 +1,13 @@ sources: - "19.19": - sha256: 7af455bb422d3ae5ef369c51ee64e98fa68c39435b0fa23be2e5d593a3d45b87 - url: https://github.com/davisking/dlib/archive/v19.19.tar.gz + "19.24": + url: "https://github.com/davisking/dlib/archive/refs/tags/v19.24.tar.gz" + sha256: "3cc42e84c7b1bb926c6451a21ad1595f56c5b10be3a1d7aa2f3c716a25b7ae39" + "19.23": + url: "https://github.com/davisking/dlib/archive/v19.23.tar.gz" + sha256: "0fc74a39d2046ad15819bab25a695333a63e740c91ed3c620c8594381c132e88" "19.21": - sha256: 116f52e58be04b47dab52057eaad4b5c4d5c3032d927fe23d55b0741fc4107a0 - url: https://github.com/davisking/dlib/archive/v19.21.tar.gz + url: "https://github.com/davisking/dlib/archive/v19.21.tar.gz" + sha256: "116f52e58be04b47dab52057eaad4b5c4d5c3032d927fe23d55b0741fc4107a0" + "19.19": + url: "https://github.com/davisking/dlib/archive/v19.19.tar.gz" + sha256: "7af455bb422d3ae5ef369c51ee64e98fa68c39435b0fa23be2e5d593a3d45b87" diff --git a/recipes/dlib/all/conanfile.py b/recipes/dlib/all/conanfile.py index 816d557e5dade..a15a2fc95a7d5 100644 --- a/recipes/dlib/all/conanfile.py +++ b/recipes/dlib/all/conanfile.py @@ -1,7 +1,10 @@ -import os - +from conan.tools.microsoft import is_msvc from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.45.0" class DlibConan(ConanFile): @@ -11,8 +14,6 @@ class DlibConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "http://dlib.net" license = "BSL-1.0" - exports_sources = "CMakeLists.txt" - generators = "cmake" settings = "os", "arch", "compiler", "build_type" options = { @@ -21,22 +22,29 @@ class DlibConan(ConanFile): "with_gif": [True, False], "with_jpeg": [True, False], "with_png": [True, False], + "with_webp": [True, False], + "with_sqlite3": [True, False], "with_sse2": [True, False, "auto"], "with_sse4": [True, False, "auto"], - "with_avx": [True, False, "auto"] + "with_avx": [True, False, "auto"], + "with_openblas": [True, False], } default_options = { "shared": False, "fPIC": True, - "with_gif": False, # Doesn't work out-of-the-box with MSVC + "with_gif": True, "with_jpeg": True, "with_png": True, + "with_webp": True, + "with_sqlite3": True, "with_sse2": "auto", "with_sse4": "auto", - "with_avx": "auto" + "with_avx": "auto", + "with_openblas": True, } - _cmake = None + exports_sources = "CMakeLists.txt" + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): @@ -46,6 +54,10 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _has_with_webp_option(self): + return tools.Version(self.version) >= "19.24" + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -53,12 +65,12 @@ def config_options(self): del self.options.with_sse2 del self.options.with_sse4 del self.options.with_avx + if not self._has_with_webp_option: + del self.options.with_webp def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler == "Visual Studio" and self.options.shared: - raise ConanInvalidConfiguration("dlib can not be built as a shared library with Visual Studio") def requirements(self): if self.options.with_gif: @@ -67,39 +79,89 @@ def requirements(self): self.requires("libjpeg/9d") if self.options.with_png: self.requires("libpng/1.6.37") + if self.options.get_safe("with_webp"): + self.requires("libwebp/1.2.2") + if self.options.with_sqlite3: + self.requires("sqlite3/3.38.5") + if self.options.with_openblas: + self.requires("openblas/0.3.17") + + def validate(self): + if is_msvc(self) and self.options.shared: + raise ConanInvalidConfiguration("dlib can not be built as a shared library with Visual Studio") + if self.settings.os == "Macos" and self.settings.arch == "armv8": + raise ConanInvalidConfiguration("dlib doesn't support macOS M1") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + dlib_cmakelists = os.path.join(self._source_subfolder, "dlib", "CMakeLists.txt") + # robust giflib injection + tools.replace_in_file(dlib_cmakelists, "${GIF_LIBRARY}", "GIF::GIF") + # robust libjpeg injection + for cmake_file in [ + dlib_cmakelists, + os.path.join(self._source_subfolder, "dlib", "cmake_utils", "find_libjpeg.cmake"), + os.path.join(self._source_subfolder, "dlib", "cmake_utils", "test_for_libjpeg", "CMakeLists.txt"), + ]: + tools.replace_in_file(cmake_file, "${JPEG_LIBRARY}", "JPEG::JPEG") + # robust libpng injection + for cmake_file in [ + dlib_cmakelists, + os.path.join(self._source_subfolder, "dlib", "cmake_utils", "find_libpng.cmake"), + os.path.join(self._source_subfolder, "dlib", "cmake_utils", "test_for_libpng", "CMakeLists.txt"), + ]: + tools.replace_in_file(cmake_file, "${PNG_LIBRARIES}", "PNG::PNG") + # robust sqlite3 injection + tools.replace_in_file(dlib_cmakelists, "find_library(sqlite sqlite3)", "find_package(SQLite3 REQUIRED)") + tools.replace_in_file(dlib_cmakelists, "find_path(sqlite_path sqlite3.h)", "") + tools.replace_in_file(dlib_cmakelists, "if (sqlite AND sqlite_path)", "if(1)") + tools.replace_in_file(dlib_cmakelists, "${sqlite}", "SQLite::SQLite3") + # robust libwebp injection + if self._has_with_webp_option: + tools.replace_in_file(dlib_cmakelists, "include(cmake_utils/find_libwebp.cmake)", "find_package(WebP REQUIRED)") + tools.replace_in_file(dlib_cmakelists, "if (WEBP_FOUND)", "if(1)") + tools.replace_in_file(dlib_cmakelists, "${WEBP_LIBRARY}", "WebP::webp") + + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) + cmake = CMake(self) # With in-project builds dlib is always built as a static library, # we want to be able to build it as a shared library too - self._cmake.definitions["DLIB_IN_PROJECT_BUILD"] = "OFF" + cmake.definitions["DLIB_IN_PROJECT_BUILD"] = False + + cmake.definitions["DLIB_ISO_CPP_ONLY"] = False + cmake.definitions["DLIB_NO_GUI_SUPPORT"] = True # Configure external dependencies - self._cmake.definitions["DLIB_GIF_SUPPORT"] = self.options.with_gif - self._cmake.definitions["DLIB_JPEG_SUPPORT"] = self.options.with_jpeg - self._cmake.definitions["DLIB_PNG_SUPPORT"] = self.options.with_png + cmake.definitions["DLIB_JPEG_SUPPORT"] = self.options.with_jpeg + if self._has_with_webp_option: + cmake.definitions["DLIB_WEBP_SUPPORT"] = self.options.with_webp + cmake.definitions["DLIB_LINK_WITH_SQLITE3"] = self.options.with_sqlite3 + cmake.definitions["DLIB_USE_BLAS"] = True # FIXME: all the logic behind is not sufficiently under control + cmake.definitions["DLIB_USE_LAPACK"] = True # FIXME: all the logic behind is not sufficiently under control + cmake.definitions["DLIB_USE_CUDA"] = False # TODO: add with_cuda option? + cmake.definitions["DLIB_PNG_SUPPORT"] = self.options.with_png + cmake.definitions["DLIB_GIF_SUPPORT"] = self.options.with_gif + cmake.definitions["DLIB_USE_MKL_FFT"] = False # Configure SIMD options if possible if self.settings.arch in ["x86", "x86_64"]: if self.options.with_sse2 != "auto": - self._cmake.definitions["USE_SSE2_INSTRUCTIONS"] = self.options.with_sse2 + cmake.definitions["USE_SSE2_INSTRUCTIONS"] = self.options.with_sse2 if self.options.with_sse4 != "auto": - self._cmake.definitions["USE_SSE4_INSTRUCTIONS"] = self.options.with_sse4 + cmake.definitions["USE_SSE4_INSTRUCTIONS"] = self.options.with_sse4 if self.options.with_avx != "auto": - self._cmake.definitions["USE_AVX_INSTRUCTIONS"] = self.options.with_avx + cmake.definitions["USE_AVX_INSTRUCTIONS"] = self.options.with_avx - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + cmake.configure(build_folder=self._build_subfolder) + return cmake def build(self): + self._patch_sources() cmake = self._configure_cmake() cmake.build() @@ -119,9 +181,13 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, dir_to_remove)) def package_info(self): - self.cpp_info.names["pkg_config"] = "dlib-1" + self.cpp_info.set_property("cmake_file_name", "dlib") + self.cpp_info.set_property("cmake_target_name", "dlib::dlib") + self.cpp_info.set_property("pkg_config_name", "dlib-1") self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["pthread"] elif self.settings.os == "Windows": self.cpp_info.system_libs = ["ws2_32", "winmm", "comctl32", "gdi32", "imm32"] + + self.cpp_info.names["pkg_config"] = "dlib-1" diff --git a/recipes/dlib/all/test_package/CMakeLists.txt b/recipes/dlib/all/test_package/CMakeLists.txt index 4199210b00040..50caaa372ec83 100644 --- a/recipes/dlib/all/test_package/CMakeLists.txt +++ b/recipes/dlib/all/test_package/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package LANGUAGES CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(dlib REQUIRED CONFIG) diff --git a/recipes/dlib/all/test_package/conanfile.py b/recipes/dlib/all/test_package/conanfile.py index 6e28c1a0081cc..38f4483872d47 100644 --- a/recipes/dlib/all/test_package/conanfile.py +++ b/recipes/dlib/all/test_package/conanfile.py @@ -1,10 +1,9 @@ -import os.path - from conans import ConanFile, CMake, tools +import os -class DlibTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -13,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/dlib/all/test_package/test_package.cpp b/recipes/dlib/all/test_package/test_package.cpp index 5b9a88b0df2ef..ec4d7d59863d7 100644 --- a/recipes/dlib/all/test_package/test_package.cpp +++ b/recipes/dlib/all/test_package/test_package.cpp @@ -8,8 +8,8 @@ dlib::logger dlog("conan-test"); int main() { // Every logger has a logging level (given by dlog.level()). Each log message is tagged with a - // level and only levels equal to or higher than dlog.level() will be printed. By default all - // loggers start with level() == LERROR. In this case I'm going to set the lowest level LALL + // level and only levels equal to or higher than dlog.level() will be printed. By default all + // loggers start with level() == LERROR. In this case I'm going to set the lowest level LALL // which means that dlog will print all logging messages it gets. dlog.set_level(dlib::LALL); @@ -22,7 +22,7 @@ int main() // the logger can be used pretty much like any ostream object. But you have to give a logging // level first. But after that you can chain << operators like normal. - + if (variable > 4) dlog << dlib::LWARN << "The variable is bigger than 4! Its value is " << variable; @@ -32,4 +32,5 @@ int main() dlog << dlib::LINFO << "we just woke up"; dlog << dlib::LINFO << "program ending"; + return 0; } diff --git a/recipes/dlib/config.yml b/recipes/dlib/config.yml index a5037509a69fe..4d03ed4f4b36d 100644 --- a/recipes/dlib/config.yml +++ b/recipes/dlib/config.yml @@ -1,5 +1,9 @@ versions: - "19.19": + "19.24": + folder: all + "19.23": folder: all "19.21": folder: all + "19.19": + folder: all diff --git a/recipes/docopt.cpp/all/conandata.yml b/recipes/docopt.cpp/all/conandata.yml index 043d2e7ba1df2..9c028b4d8773f 100644 --- a/recipes/docopt.cpp/all/conandata.yml +++ b/recipes/docopt.cpp/all/conandata.yml @@ -1,11 +1,16 @@ sources: - "0.6.2": - url: "https://github.com/docopt/docopt.cpp/archive/v0.6.2.tar.gz" - sha256: "c05542245232420d735c7699098b1ea130e3a92bade473b64baf876cdf098a17" "0.6.3": url: "https://github.com/docopt/docopt.cpp/archive/v0.6.3.tar.gz" sha256: "28af5a0c482c6d508d22b14d588a3b0bd9ff97135f99c2814a5aa3cbff1d6632" + "0.6.2": + url: "https://github.com/docopt/docopt.cpp/archive/v0.6.2.tar.gz" + sha256: "c05542245232420d735c7699098b1ea130e3a92bade473b64baf876cdf098a17" patches: + "0.6.3": + - patch_file: "patches/cmake-library-0.6.3.patch" + base_path: "source_subfolder" + - patch_file: "patches/msvc-dll-export-0.6.3.patch" + base_path: "source_subfolder" "0.6.2": - patch_file: "patches/include-stdexcept.patch" base_path: "source_subfolder" @@ -13,8 +18,3 @@ patches: base_path: "source_subfolder" - patch_file: "patches/msvc-dll-export-0.6.2.patch" base_path: "source_subfolder" - "0.6.3": - - patch_file: "patches/cmake-library-0.6.3.patch" - base_path: "source_subfolder" - - patch_file: "patches/msvc-dll-export-0.6.3.patch" - base_path: "source_subfolder" diff --git a/recipes/docopt.cpp/all/conanfile.py b/recipes/docopt.cpp/all/conanfile.py index e58713521b5f7..1342254943457 100644 --- a/recipes/docopt.cpp/all/conanfile.py +++ b/recipes/docopt.cpp/all/conanfile.py @@ -1,20 +1,31 @@ from conans import ConanFile, CMake, tools import os +import textwrap + +required_conan_version = ">=1.43.0" class DocoptCppConan(ConanFile): name = "docopt.cpp" license = "MIT" + description = "C++11 port of docopt" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/docopt/docopt.cpp" - settings = "os", "compiler", "build_type", "arch" - description = "C++11 port of docopt" - options = {"shared": [True, False], "fPIC": [True, False], "boost_regex": [True, False]} - default_options = {"shared": False, "fPIC": True, "boost_regex": False} - topics = ("CLI", "getopt", "options", "argparser") - generators = "cmake", "cmake_find_package" - exports_sources = ["patches/**", "CMakeLists.txt"] + topics = ("cli", "getopt", "options", "argparser") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "boost_regex": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "boost_regex": False, + } + + generators = "cmake", "cmake_find_package" _cmake = None @property @@ -25,6 +36,15 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -32,17 +52,18 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, "11") def requirements(self): if self.options.boost_regex: - self.requires("boost/1.74.0") + self.requires("boost/1.76.0") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "11") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -65,18 +86,51 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {self._cmake_target: "docopt::{}".format(self._cmake_target)} + ) + + @property + def _cmake_target(self): + return "docopt" if self.options.shared else "docopt_s" + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + def package_info(self): - # TODO: imported CMake target shouldn't be namespaced - self.cpp_info.names["cmake_find_package"] = "docopt" - self.cpp_info.names["cmake_find_package_multi"] = "docopt" - self.cpp_info.names["pkg_config"] = "docopt" - cmake_target = "docopt" if self.options.shared else "docopt_s" - self.cpp_info.components["docopt"].names["cmake_find_package"] = cmake_target - self.cpp_info.components["docopt"].names["cmake_find_package_multi"] = cmake_target + self.cpp_info.set_property("cmake_file_name", "docopt") + self.cpp_info.set_property("cmake_target_name", self._cmake_target) + self.cpp_info.set_property("pkg_config_name", "docopt") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed self.cpp_info.components["docopt"].libs = ["docopt"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["docopt"].system_libs = ["m"] - if self.settings.compiler == "Visual Studio" and self.options.shared: + if self._is_msvc and self.options.shared: self.cpp_info.components["docopt"].defines = ["DOCOPT_DLL"] if self.options.boost_regex: self.cpp_info.components["docopt"].requires.append("boost::boost") + + # TODO: to remove in conan v2 once cmake_find_package_* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "docopt" + self.cpp_info.names["cmake_find_package_multi"] = "docopt" + self.cpp_info.names["pkg_config"] = "docopt" + self.cpp_info.components["docopt"].names["cmake_find_package"] = self._cmake_target + self.cpp_info.components["docopt"].names["cmake_find_package_multi"] = self._cmake_target + self.cpp_info.components["docopt"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["docopt"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["docopt"].set_property("cmake_target_name", self._cmake_target) diff --git a/recipes/docopt.cpp/all/test_package/CMakeLists.txt b/recipes/docopt.cpp/all/test_package/CMakeLists.txt index a8ea94779f874..bfb18efe2d7e0 100644 --- a/recipes/docopt.cpp/all/test_package/CMakeLists.txt +++ b/recipes/docopt.cpp/all/test_package/CMakeLists.txt @@ -2,15 +2,14 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(docopt REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) -# TODO: remove docopt:: namespace when fixed in conanfile -if(DOCOPTCPP_SHARED) - target_link_libraries(${PROJECT_NAME} docopt::docopt) +if(TARGET docopt_s) + target_link_libraries(${PROJECT_NAME} docopt_s) else() - target_link_libraries(${PROJECT_NAME} docopt::docopt_s) + target_link_libraries(${PROJECT_NAME} docopt) endif() diff --git a/recipes/docopt.cpp/all/test_package/conanfile.py b/recipes/docopt.cpp/all/test_package/conanfile.py index e516e3bbe2fab..96f53ca4b9bf0 100644 --- a/recipes/docopt.cpp/all/test_package/conanfile.py +++ b/recipes/docopt.cpp/all/test_package/conanfile.py @@ -3,25 +3,15 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) - cmake.definitions["DOCOPTCPP_SHARED"] = self.options["docopt.cpp"].shared cmake.configure() cmake.build() def test(self): - if tools.cross_building(self.settings): - if self.settings.os == "Emscripten": - exe_name = "test_package.js" - elif tools.os_info.is_windows: - exe_name = "test_package.exe" - else: - exe_name = "test_package" - - assert(os.path.exists(os.path.join("bin", exe_name))) - else: + if not tools.cross_building(self): exec_path = os.path.join("bin", "test_package") self.run("{} --help".format(exec_path), run_environment=True) diff --git a/recipes/docopt.cpp/config.yml b/recipes/docopt.cpp/config.yml index c786abf88b322..5adc30b2f3c24 100644 --- a/recipes/docopt.cpp/config.yml +++ b/recipes/docopt.cpp/config.yml @@ -1,5 +1,5 @@ versions: - "0.6.2": - folder: all "0.6.3": folder: all + "0.6.2": + folder: all diff --git a/recipes/doctest/2.x.x/conandata.yml b/recipes/doctest/2.x.x/conandata.yml index 731888fee3d6d..e3e67654dc467 100644 --- a/recipes/doctest/2.x.x/conandata.yml +++ b/recipes/doctest/2.x.x/conandata.yml @@ -1,28 +1,37 @@ sources: "2.3.5": - url: "https://github.com/onqtam/doctest/archive/2.3.5.tar.gz" + url: "https://github.com/doctest/doctest/archive/2.3.5.tar.gz" sha256: "71d1ca0916bfea8f4550de196b66f2226f2fdb5fd4a2885a3b4c2dd8f035a8c9" "2.3.6": - url: "https://github.com/onqtam/doctest/archive/2.3.6.tar.gz" + url: "https://github.com/doctest/doctest/archive/2.3.6.tar.gz" sha256: "f63c3c01021ba3fb35a0702127abfaa6fc44aaefd309e2c246e62a083deffa1f" "2.3.7": - url: "https://github.com/onqtam/doctest/archive/2.3.7.tar.gz" + url: "https://github.com/doctest/doctest/archive/2.3.7.tar.gz" sha256: "a70cd25875029879e577b08cfaa57a76c7bea62c473ca94d85ec87ea53af7177" "2.3.8": - url: "https://github.com/onqtam/doctest/archive/2.3.8.tar.gz" + url: "https://github.com/doctest/doctest/archive/2.3.8.tar.gz" sha256: "d7232437eceb46ad5de03cacdee770c80f2e53e7b8efc1c8a8ed29539f64efa5" "2.4.0": - url: "https://github.com/onqtam/doctest/archive/2.4.0.tar.gz" + url: "https://github.com/doctest/doctest/archive/2.4.0.tar.gz" sha256: "f689f48e92c088928d88d8481e769c8e804f0a608b484ab8ef3d6ab6045b5444" "2.4.1": - url: "https://github.com/onqtam/doctest/archive/2.4.1.tar.gz" + url: "https://github.com/doctest/doctest/archive/2.4.1.tar.gz" sha256: "0a0f0be21ee23e36ff6b8b9d63c06a7792e04cce342e1df3dee0e40d1e21b9f0" "2.4.3": - url: "https://github.com/onqtam/doctest/archive/2.4.3.tar.gz" + url: "https://github.com/doctest/doctest/archive/2.4.3.tar.gz" sha256: "18c0f87f526bf34bb595c2841a2f0f33b28ab8c817d7c71ed1ba4665815d9ef6" "2.4.4": - url: "https://github.com/onqtam/doctest/archive/2.4.4.tar.gz" + url: "https://github.com/doctest/doctest/archive/2.4.4.tar.gz" sha256: "3bcb62ad316bf4230873a336fcc6eb6292116568a6e19ab8cdd37a1610773d70" "2.4.5": - url: "https://github.com/onqtam/doctest/archive/2.4.5.tar.gz" + url: "https://github.com/doctest/doctest/archive/2.4.5.tar.gz" sha256: "b76ece19f0e473e3afa5c545dbdce2dd70bfef98ed0f383443b2f9fd9f86d5b4" + "2.4.6": + url: "https://github.com/doctest/doctest/archive/2.4.6.tar.gz" + sha256: "39110778e6baf373ef04342d7cb3fe35da104cb40769103e8a2f0035f5a5f1cb" + "2.4.8": + url: "https://github.com/doctest/doctest/archive/v2.4.8.tar.gz" + sha256: "f52763630aa17bd9772b54e14b6cdd632c87adf0169455a86a49bd94abf2cd83" + "2.4.9": + url: "https://github.com/doctest/doctest/archive/v2.4.9.tar.gz" + sha256: "19b2df757f2f3703a5e63cee553d85596875f06d91a3333acd80a969ef210856" diff --git a/recipes/doctest/2.x.x/conanfile.py b/recipes/doctest/2.x.x/conanfile.py index db899278087d4..4a5f3a48700e9 100644 --- a/recipes/doctest/2.x.x/conanfile.py +++ b/recipes/doctest/2.x.x/conanfile.py @@ -1,5 +1,6 @@ -from conans import ConanFile, tools, CMake import os +from conan import ConanFile +from conan.tools import files class DoctestConan(ConanFile): @@ -17,7 +18,7 @@ def _is_mingw(self): return self.settings.os == "Windows" and self.settings.compiler == "gcc" def source(self): - tools.get(**self.conan_data["sources"][self.version]) + files.get(self, **self.conan_data["sources"][self.version]) extracted_dir = self.name + "-" + self.version os.rename(extracted_dir, self._source_subfolder) @@ -46,4 +47,4 @@ def package_info(self): self.cpp_info.build_modules.append("lib/cmake/doctest.cmake") def package_id(self): - self.info.header_only() + self.info.clear() diff --git a/recipes/doctest/2.x.x/test_package/CMakeLists.txt b/recipes/doctest/2.x.x/test_package/CMakeLists.txt index ad9b6b6c4895f..98cc84abb27fb 100644 --- a/recipes/doctest/2.x.x/test_package/CMakeLists.txt +++ b/recipes/doctest/2.x.x/test_package/CMakeLists.txt @@ -12,4 +12,4 @@ target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) enable_testing() -doctest_discover_tests(${PROJECT_NAME}) +add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) diff --git a/recipes/doctest/config.yml b/recipes/doctest/config.yml index 792adaed5ebb7..61380be849cb7 100644 --- a/recipes/doctest/config.yml +++ b/recipes/doctest/config.yml @@ -17,3 +17,9 @@ versions: folder: 2.x.x 2.4.5: folder: 2.x.x + 2.4.6: + folder: 2.x.x + 2.4.8: + folder: 2.x.x + "2.4.9": + folder: 2.x.x diff --git a/recipes/double-conversion/all/CMakeLists.txt b/recipes/double-conversion/all/CMakeLists.txt deleted file mode 100644 index a4fe554120405..0000000000000 --- a/recipes/double-conversion/all/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -if(BUILD_SHARED_LIBS AND MSVC) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - -add_subdirectory("source_subfolder") diff --git a/recipes/double-conversion/all/conandata.yml b/recipes/double-conversion/all/conandata.yml index b52b6e2c039b8..7e987d626c73a 100644 --- a/recipes/double-conversion/all/conandata.yml +++ b/recipes/double-conversion/all/conandata.yml @@ -1,7 +1,19 @@ sources: - "3.1.4": - url: "https://github.com/google/double-conversion/archive/v3.1.4.tar.gz" - sha256: "95004b65e43fefc6100f337a25da27bb99b9ef8d4071a36a33b5e83eb1f82021" + "3.2.1": + url: "https://github.com/google/double-conversion/archive/v3.2.1.tar.gz" + sha256: "e40d236343cad807e83d192265f139481c51fc83a1c49e406ac6ce0a0ba7cd35" + "3.2.0": + url: "https://github.com/google/double-conversion/archive/v3.2.0.tar.gz" + sha256: "3dbcdf186ad092a8b71228a5962009b5c96abde9a315257a3452eb988414ea3b" + "3.1.7": + url: "https://github.com/google/double-conversion/archive/v3.1.7.tar.gz" + sha256: "a0204d6ab48223f2c8f53a932014e7f245125e7a5267764b1fbeebe4fa0ee8b9" + "3.1.6": + url: https://github.com/google/double-conversion/archive/v3.1.6.tar.gz + sha256: 8a79e87d02ce1333c9d6c5e47f452596442a343d8c3e9b234e8a62fce1b1d49c "3.1.5": url: "https://github.com/google/double-conversion/archive/v3.1.5.tar.gz" sha256: "a63ecb93182134ba4293fd5f22d6e08ca417caafa244afaa751cbfddf6415b13" + "3.1.4": + url: "https://github.com/google/double-conversion/archive/v3.1.4.tar.gz" + sha256: "95004b65e43fefc6100f337a25da27bb99b9ef8d4071a36a33b5e83eb1f82021" diff --git a/recipes/double-conversion/all/conanfile.py b/recipes/double-conversion/all/conanfile.py index 8807ee353b2f0..d55569734dafe 100644 --- a/recipes/double-conversion/all/conanfile.py +++ b/recipes/double-conversion/all/conanfile.py @@ -1,7 +1,11 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir, rm +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -from conans.tools import Version + +required_conan_version = ">=1.50.0" class DoubleConversionConan(ConanFile): @@ -10,22 +14,17 @@ class DoubleConversionConan(ConanFile): homepage = "https://github.com/google/double-conversion" description = "Efficient binary-decimal and decimal-binary conversion routines for IEEE doubles." license = "BSD-3-Clause" - topics = ("conan", "double-conversion", "google", "decimal-binary", "conversion") - exports_sources = ["CMakeLists.txt"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + topics = ("double-conversion", "google", "decimal-binary", "conversion") - @property - def _build_subfolder(self): - return "build_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } def config_options(self): if self.settings.os == "Windows": @@ -34,32 +33,39 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.os == "Windows" and \ - self.settings.compiler == "Visual Studio" and \ - Version(self.settings.compiler.version.value) < "14": + + def validate(self): + if self.settings.compiler == "Visual Studio" and \ + Version(self.settings.compiler.version) < "14": raise ConanInvalidConfiguration("Double Convertion could not be built by MSVC <14") + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib","cmake")) - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "double-conversion") + self.cpp_info.set_property("cmake_target_name", "double-conversion::double-conversion") + self.cpp_info.libs = ["double-conversion"] diff --git a/recipes/double-conversion/all/test_package/CMakeLists.txt b/recipes/double-conversion/all/test_package/CMakeLists.txt index 0ca11d373ac55..cdc70c7766f8f 100644 --- a/recipes/double-conversion/all/test_package/CMakeLists.txt +++ b/recipes/double-conversion/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES CXX) find_package(double-conversion REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} double-conversion::double-conversion) +target_link_libraries(${PROJECT_NAME} PRIVATE double-conversion::double-conversion) diff --git a/recipes/double-conversion/all/test_package/conanfile.py b/recipes/double-conversion/all/test_package/conanfile.py index 7e2dfe859bb27..3a8c6c5442b33 100644 --- a/recipes/double-conversion/all/test_package/conanfile.py +++ b/recipes/double-conversion/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/double-conversion/all/test_package/test_package.cpp b/recipes/double-conversion/all/test_package/test_package.cpp index 50225d016e188..c026f07be141c 100644 --- a/recipes/double-conversion/all/test_package/test_package.cpp +++ b/recipes/double-conversion/all/test_package/test_package.cpp @@ -3,6 +3,10 @@ #include "double-conversion/utils.h" #include "double-conversion/ieee.h" +#ifndef UINT64_2PART_C +#define UINT64_2PART_C(a, b) DOUBLE_CONVERSION_UINT64_2PART_C(a, b) +#endif + int main() { uint64_t ordered = UINT64_2PART_C(0x01234567, 89ABCDEF); std::cout << "A value: " << double_conversion::Double(ordered).value() << std::endl; diff --git a/recipes/double-conversion/all/test_v1_package/CMakeLists.txt b/recipes/double-conversion/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..92ad1c8732fe6 --- /dev/null +++ b/recipes/double-conversion/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(double-conversion REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE double-conversion::double-conversion) diff --git a/recipes/double-conversion/all/test_v1_package/conanfile.py b/recipes/double-conversion/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/double-conversion/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/double-conversion/config.yml b/recipes/double-conversion/config.yml index df3c03102ed36..af0b0f2b2e22d 100644 --- a/recipes/double-conversion/config.yml +++ b/recipes/double-conversion/config.yml @@ -1,5 +1,13 @@ versions: - "3.1.4": + "3.2.1": + folder: all + "3.2.0": + folder: all + "3.1.7": + folder: all + "3.1.6": folder: all "3.1.5": folder: all + "3.1.4": + folder: all diff --git a/recipes/doxygen/all/conandata.yml b/recipes/doxygen/all/conandata.yml index 761f1be0632b2..610b80f65e242 100644 --- a/recipes/doxygen/all/conandata.yml +++ b/recipes/doxygen/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.9.4": + url: "https://sourceforge.net/projects/doxygen/files/doxygen-1.9.4.src.tar.gz" + sha256: "a15e9cd8c0d02b7888bc8356eac200222ecff1defd32f3fe05257d81227b1f37" + "1.9.2": + url: "https://sourceforge.net/projects/doxygen/files/doxygen-1.9.2.src.tar.gz" + sha256: "060f254bcef48673cc7ccf542736b7455b67c110b30fdaa33512a5b09bbecee5" "1.9.1": url: "https://sourceforge.net/projects/doxygen/files/doxygen-1.9.1.src.tar.gz" sha256: "67aeae1be4e1565519898f46f1f7092f1973cce8a767e93101ee0111717091d1" @@ -12,6 +18,9 @@ sources: url: "https://sourceforge.net/projects/doxygen/files/doxygen-1.8.17.src.tar.gz" sha256: "2cba988af2d495541cbbe5541b3bee0ee11144dcb23a81eada19f5501fd8b599" patches: + "1.9.2": + - patch_file: "patches/1.9.2-0001-imported-target.patch" + base_path: "source_subfolder" "1.9.1": - patch_file: "patches/1.9.1-0001-imported-target.patch" base_path: "source_subfolder" diff --git a/recipes/doxygen/all/conanfile.py b/recipes/doxygen/all/conanfile.py index 7eb00bb2a1b9a..319d913d5acc5 100644 --- a/recipes/doxygen/all/conanfile.py +++ b/recipes/doxygen/all/conanfile.py @@ -1,17 +1,31 @@ -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.scm import Version +from conan import tools +from conans import CMake +from conan.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.50.2" + class DoxygenConan(ConanFile): name = "doxygen" description = "A documentation system for C++, C, Java, IDL and PHP --- Note: Dot is disabled in this package" - topics = ("conan", "doxygen", "installer", "devtool", "documentation") + topics = ("doxygen", "installer", "devtool", "documentation") homepage = "https://github.com/doxygen/doxygen" license = "GPL-2.0-or-later" url = "https://github.com/conan-io/conan-center-index" settings = "os", "arch", "compiler", "build_type" - exports_sources = "CMakeLists.txt", "patches/**" + options = { + "enable_parse": [True, False], + "enable_search": [True, False], + } + default_options = { + "enable_parse": True, + "enable_search": True, + } + + exports_sources = "CMakeLists.txt", "patches/*" generators = "cmake", "cmake_find_package" short_paths = True @@ -25,43 +39,64 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" - _minimum_compiler_version = { - "gcc": 5, - } + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def _minimum_compiler_version(self): + if Version(self.version) <= "1.9.1": + return { + "gcc": 5, + }.get(str(self.settings.compiler)) + return { + "gcc": 7, # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66297 + "Visual Studio": 15, + }.get(str(self.settings.compiler)) def configure(self): - minimum_compiler_version = self._minimum_compiler_version.get(str(self.settings.compiler)) - if minimum_compiler_version is not None: - if tools.Version(self.settings.compiler.version) < minimum_compiler_version: - raise ConanInvalidConfiguration("Compiler version too old. At least {} is required.".format(minimum_compiler_version)) - if (self.settings.compiler == "Visual Studio" and - tools.Version(self.settings.compiler.version.value) <= 14 and - tools.Version(self.version) == "1.8.18"): - raise ConanInvalidConfiguration("Doxygen version {} broken with VS {}.".format(self.version, - self.settings.compiler.version)) del self.settings.compiler.cppstd - def requirements(self): - self.requires("xapian-core/1.4.18") - self.requires("zlib/1.2.11") + if self.options.enable_search: + self.requires("xapian-core/1.4.19", private=True) + self.requires("zlib/1.2.13", private=True) def build_requirements(self): - if tools.os_info.is_windows: - self.build_requires("winflexbison/2.5.22") + if self._settings_build.os == "Windows": + self.build_requires("winflexbison/2.5.24") else: self.build_requires("flex/2.6.4") self.build_requires("bison/3.7.1") + def validate(self): + minimum_compiler_version = self._minimum_compiler_version() + if minimum_compiler_version is not None: + if Version(self.settings.compiler.version) < minimum_compiler_version: + raise ConanInvalidConfiguration(f"Compiler version too old. At least {minimum_compiler_version} is required.") + if (self.settings.compiler == "Visual Studio" and + Version(self.settings.compiler.version) <= "14" and + Version(self.version) == "1.8.18"): + raise ConanInvalidConfiguration(f"Doxygen version {self.version} broken with VS {self.settings.compiler.version}.") + + def package_id(self): + del self.info.settings.compiler + + # Doxygen doesn't make code. Any package that will run is ok to use. + # It's ok in general to use a release version of the tool that matches the + # build os and architecture. + compatible_pkg = self.info.clone() + compatible_pkg.settings.build_type = "Release" + self.compatible_packages.append(compatible_pkg) + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + tools.files.get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - self._cmake.definitions["build_parse"] = True - self._cmake.definitions["build_search"] = True + self._cmake.definitions["build_parse"] = self.options.enable_parse + self._cmake.definitions["build_search"] = self.options.enable_search self._cmake.definitions["use_libc++"] = self.settings.compiler.get_safe("libcxx") == "libc++" self._cmake.definitions["win_static"] = "MT" in self.settings.compiler.get_safe("runtime", "") self._cmake.configure(build_folder=self._build_subfolder) @@ -73,7 +108,7 @@ def build(self): if os.path.isfile("Findbison.cmake"): os.unlink("Findbison.cmake") for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + tools.files.patch(self, **patch) cmake = self._configure_cmake() cmake.build() @@ -82,10 +117,9 @@ def package(self): cmake = self._configure_cmake() cmake.install() - def package_id(self): - del self.info.settings.compiler - def package_info(self): + self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.output.info(f"Appending PATH environment variable: {bin_path}") self.env_info.PATH.append(bin_path) diff --git a/recipes/doxygen/all/patches/1.9.2-0001-imported-target.patch b/recipes/doxygen/all/patches/1.9.2-0001-imported-target.patch new file mode 100644 index 0000000000000..57875eaf4cec1 --- /dev/null +++ b/recipes/doxygen/all/patches/1.9.2-0001-imported-target.patch @@ -0,0 +1,37 @@ +--- addon/doxysearch/CMakeLists.txt ++++ addon/doxysearch/CMakeLists.txt +@@ -15,7 +15,7 @@ + doxyindexer.cpp + ) + target_link_libraries(doxyindexer +- ${XAPIAN_LIBRARIES} ++ CONAN_PKG::xapian-core + ${ZLIB_LIBRARIES} + ${WIN_EXTRA_LIBS} + ${COVERAGE_LINKER_FLAGS} +@@ -28,7 +28,7 @@ add_executable(doxysearch.cgi + ) + target_link_libraries(doxysearch.cgi + doxygen_version +- ${XAPIAN_LIBRARIES} ++ CONAN_PKG::xapian-core + ${ZLIB_LIBRARIES} + ${WIN_EXTRA_LIBS} + ) +--- libmscgen/mscgen_bool.h ++++ libmscgen/mscgen_bool.h +@@ -23,6 +23,14 @@ + #ifndef MSCGEN_BOOL_H + #define MSCGEN_BOOL_H + ++/* Some system headers define TRUE and FALSE so undefine them first */ ++#ifdef TRUE ++#undef TRUE ++#endif ++#ifdef FALSE ++#undef FALSE ++#endif ++ + typedef enum + { + FALSE = 0, diff --git a/recipes/doxygen/all/test_package/CMakeLists.txt b/recipes/doxygen/all/test_package/CMakeLists.txt index 5a8aefbe861eb..08bb0b438cb03 100644 --- a/recipes/doxygen/all/test_package/CMakeLists.txt +++ b/recipes/doxygen/all/test_package/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.3) -project(test_package) +project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) diff --git a/recipes/doxygen/all/test_package/conanfile.py b/recipes/doxygen/all/test_package/conanfile.py index fc52c2151a388..a0fbd76152051 100644 --- a/recipes/doxygen/all/test_package/conanfile.py +++ b/recipes/doxygen/all/test_package/conanfile.py @@ -1,18 +1,20 @@ from conans import ConanFile, CMake, tools +from conans.errors import ConanException import os class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" generators = "cmake" def build(self): - if not tools.cross_building(self.settings, skip_x64_x86=True): + if not tools.cross_building(self, skip_x64_x86=True): cmake = CMake(self) cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self, skip_x64_x86=True): if not os.path.isdir(os.path.join(self.build_folder, "html")): raise ConanException("doxygen did not create html documentation directory") diff --git a/recipes/doxygen/config.yml b/recipes/doxygen/config.yml index 7088304d926c6..2157880ecf476 100644 --- a/recipes/doxygen/config.yml +++ b/recipes/doxygen/config.yml @@ -1,4 +1,8 @@ versions: + "1.9.4": + folder: "all" + "1.9.2": + folder: "all" "1.9.1": folder: "all" "1.8.20": diff --git a/recipes/draco/all/CMakeLists.txt b/recipes/draco/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/draco/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/draco/all/conandata.yml b/recipes/draco/all/conandata.yml index e6fb7418138c2..5105546d4c2a2 100644 --- a/recipes/draco/all/conandata.yml +++ b/recipes/draco/all/conandata.yml @@ -1,4 +1,19 @@ sources: + "1.5.5": + url: "https://github.com/google/draco/archive/refs/tags/1.5.5.tar.gz" + sha256: "6b7994150bbc513abcdbe22ad778d6b2df10fc8cdc7035e916985b2a209ab826" + "1.5.4": + url: "https://github.com/google/draco/archive/refs/tags/1.5.4.tar.gz" + sha256: "7698cce91c24725562fb73811d24823f0f0a25e3ac0941e792993c5191d3baee" + "1.5.3": + url: "https://github.com/google/draco/archive/refs/tags/1.5.3.tar.gz" + sha256: "7882a942a1da14a9ae9d557b1a3af7f44bdee7f5d42b745c4e474fb8b28d4e5e" + "1.5.2": + url: "https://github.com/google/draco/archive/1.5.2.tar.gz" + sha256: "a887e311ec04a068ceca0bd6f3865083042334fbff26e65bc809e8978b2ce9cd" + "1.4.3": + url: "https://github.com/google/draco/archive/1.4.3.tar.gz" + sha256: "02a620a7ff8388c57d6f6e0941eecc10d0c23ab47c45942fb52f64a6245c44f5" "1.3.6": url: "https://github.com/google/draco/archive/1.3.6.tar.gz" sha256: "80eaa54ef5fc687c9aeebb9bd24d936d3e6d2c6048f358be8b83fa088ef4b2cb" @@ -6,6 +21,14 @@ sources: url: "https://github.com/google/draco/archive/1.3.5.tar.gz" sha256: "a3ac692397574166ad99493ff1efcd7b5c69b580e7eb4500d5d181b2f676aa6e" patches: + "1.5.2": + - patch_file: "patches/0001-fix-cmake-1.5.2.patch" + "1.4.3": + - patch_file: "patches/0001-fix-cmake-1.4.3.patch" "1.3.6": - - patch_file: "patches/non-copy-ellision-workaround.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-fix-cmake-1.3.6.patch" + - patch_file: "patches/0002-v1.3.6-gcc-11.patch" + - patch_file: "patches/0003-non-copy-ellision-workaround.patch" + "1.3.5": + - patch_file: "patches/0001-fix-cmake-1.3.5.patch" + - patch_file: "patches/0002-v1.3.5-gcc-11.patch" diff --git a/recipes/draco/all/conanfile.py b/recipes/draco/all/conanfile.py index 075c76ea7c9ae..fcf412b2c827e 100644 --- a/recipes/draco/all/conanfile.py +++ b/recipes/draco/all/conanfile.py @@ -1,6 +1,12 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.52.0" + class DracoConan(ConanFile): name = "draco" @@ -8,126 +14,144 @@ class DracoConan(ConanFile): "geometric meshes and point clouds. It is intended to " \ "improve the storage and transmission of 3D graphics." license = "Apache-2.0" - topics = ("conan", "draco", "3d", "graphics", "mesh", "compression", "decompression") + topics = ("draco", "3d", "graphics", "mesh", "compression", "decompression") homepage = "https://google.github.io/draco/" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" - short_paths = True options = { "shared": [True, False], "fPIC": [True, False], - "target": ["encode_and_decode", "encode_only", "decode_only"], + "target": ["draco", "encode_and_decode", "encode_only", "decode_only"], "enable_point_cloud_compression": [True, False], "enable_mesh_compression": [True, False], "enable_standard_edgebreaker": [True, False], "enable_predictive_edgebreaker": [True, False], - "enable_backwards_compatibility": [True, False] + "enable_backwards_compatibility": [True, False], } default_options = { "shared": False, "fPIC": True, - "target": "encode_and_decode", + "target": "draco", "enable_point_cloud_compression": True, "enable_mesh_compression": True, "enable_standard_edgebreaker": True, "enable_predictive_edgebreaker": True, - "enable_backwards_compatibility": True + "enable_backwards_compatibility": True, } - @property - def _source_subfolder(self): - return "source_subfolder" + short_paths = True - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass if not self.options.enable_mesh_compression: del self.options.enable_standard_edgebreaker del self.options.enable_predictive_edgebreaker + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + + # use different cmake definitions based on package version + if Version(self.version) < "1.4.0": + tc.variables["ENABLE_POINT_CLOUD_COMPRESSION"] = self.options.enable_point_cloud_compression + tc.variables["ENABLE_MESH_COMPRESSION"] = self.options.enable_mesh_compression + if self.options.enable_mesh_compression: + tc.variables["ENABLE_STANDARD_EDGEBREAKER"] = self.options.enable_standard_edgebreaker + tc.variables["ENABLE_PREDICTIVE_EDGEBREAKER"] = self.options.enable_predictive_edgebreaker + tc.variables["ENABLE_BACKWARDS_COMPATIBILITY"] = self.options.enable_backwards_compatibility + + # BUILD_FOR_GLTF is not needed, it is equivalent to: + # - enable_point_cloud_compression=False + # - enable_mesh_compression=True + # - enable_standard_edgebreaker=True + # - enable_predictive_edgebreaker=False + # - enable_backwards_compatibility=False + tc.variables["BUILD_FOR_GLTF"] = False + + tc.variables["BUILD_UNITY_PLUGIN"] = False + tc.variables["BUILD_MAYA_PLUGIN"] = False + tc.variables["BUILD_USD_PLUGIN"] = False + + tc.variables["ENABLE_CCACHE"] = False + tc.variables["ENABLE_DISTCC"] = False + tc.variables["ENABLE_EXTRA_SPEED"] = False + tc.variables["ENABLE_EXTRA_WARNINGS"] = False + tc.variables["ENABLE_GOMA"] = False + tc.variables["ENABLE_JS_GLUE"] = False + tc.variables["ENABLE_DECODER_ATTRIBUTE_DEDUPLICATION"] = False + tc.variables["ENABLE_TESTS"] = False + tc.variables["ENABLE_WASM"] = False + tc.variables["ENABLE_WERROR"] = False + tc.variables["ENABLE_WEXTRA"] = False + tc.variables["IGNORE_EMPTY_BUILD_TYPE"] = False + tc.variables["BUILD_ANIMATION_ENCODING"] = False + else: + tc.variables["DRACO_POINT_CLOUD_COMPRESSION"] = self.options.enable_point_cloud_compression + tc.variables["DRACO_MESH_COMPRESSION"] = self.options.enable_mesh_compression + if self.options.enable_mesh_compression: + tc.variables["DRACO_STANDARD_EDGEBREAKER"] = self.options.enable_standard_edgebreaker + tc.variables["DRACO_PREDICTIVE_EDGEBREAKER"] = self.options.enable_predictive_edgebreaker + tc.variables["DRACO_ANIMATION_ENCODING"] = False + tc.variables["DRACO_BACKWARDS_COMPATIBILITY"] = self.options.enable_backwards_compatibility + tc.variables["DRACO_DECODER_ATTRIBUTE_DEDUPLICATION"] = False + tc.variables["DRACO_FAST"] = False + # DRACO_GLTF True overrides options by enabling + # DRACO_MESH_COMPRESSION_SUPPORTED, + # DRACO_NORMAL_ENCODING_SUPPORTED, + # DRACO_STANDARD_EDGEBREAKER_SUPPORTED + tc.variables["DRACO_GLTF"] = False + tc.variables["DRACO_JS_GLUE"] = False + tc.variables["DRACO_MAYA_PLUGIN"] = False + tc.variables["DRACO_TESTS"] = False + tc.variables["DRACO_UNITY_PLUGIN"] = False + tc.variables["DRACO_WASM"] = False + + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() - cmake.build(target=self._get_target()) - - def _configure_cmake(self): + apply_conandata_patches(self) cmake = CMake(self) - cmake.definitions["ENABLE_POINT_CLOUD_COMPRESSION"] = self.options.enable_point_cloud_compression - cmake.definitions["ENABLE_MESH_COMPRESSION"] = self.options.enable_mesh_compression - if self.options.enable_mesh_compression: - cmake.definitions["ENABLE_STANDARD_EDGEBREAKER"] = self.options.enable_standard_edgebreaker - cmake.definitions["ENABLE_PREDICTIVE_EDGEBREAKER"] = self.options.enable_predictive_edgebreaker - cmake.definitions["ENABLE_BACKWARDS_COMPATIBILITY"] = self.options.enable_backwards_compatibility - - # BUILD_FOR_GLTF is not needed, it is equivalent to: - # - enable_point_cloud_compression=False - # - enable_mesh_compression=True - # - enable_standard_edgebreaker=True - # - enable_predictive_edgebreaker=False - # - enable_backwards_compatibility=False - cmake.definitions["BUILD_FOR_GLTF"] = False - - cmake.definitions["BUILD_UNITY_PLUGIN"] = False - cmake.definitions["BUILD_MAYA_PLUGIN"] = False - cmake.definitions["BUILD_USD_PLUGIN"] = False - - cmake.definitions["ENABLE_CCACHE"] = False - cmake.definitions["ENABLE_DISTCC"] = False - cmake.definitions["ENABLE_EXTRA_SPEED"] = False - cmake.definitions["ENABLE_EXTRA_WARNINGS"] = False - cmake.definitions["ENABLE_GOMA"] = False - cmake.definitions["ENABLE_JS_GLUE"] = False - cmake.definitions["ENABLE_DECODER_ATTRIBUTE_DEDUPLICATION"] = False - cmake.definitions["ENABLE_TESTS"] = False - cmake.definitions["ENABLE_WASM"] = False - cmake.definitions["ENABLE_WERROR"] = False - cmake.definitions["ENABLE_WEXTRA"] = False - cmake.definitions["IGNORE_EMPTY_BUILD_TYPE"] = False - cmake.definitions["BUILD_ANIMATION_ENCODING"] = False - - cmake.configure(build_folder=self._build_subfolder) - return cmake - - def _get_target(self): - return { - "encode_and_decode": "draco", - "encode_only": "dracoenc", - "decode_only": "dracodec" - }.get(str(self.options.target)) + cmake.configure() + cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - - self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "src")) - self.copy(pattern="*.h", dst=os.path.join("include", "draco"), src=os.path.join(self._build_subfolder, "draco")) - - build_lib_dir = os.path.join(self._build_subfolder, "lib") - build_bin_dir = os.path.join(self._build_subfolder, "bin") - self.copy(pattern="*.a", dst="lib", src=build_lib_dir, keep_path=False) - self.copy(pattern="*.lib", dst="lib", src=build_lib_dir, keep_path=False) - self.copy(pattern="*.dylib", dst="lib", src=build_lib_dir, keep_path=False) - self.copy(pattern="*.so*", dst="lib", src=build_lib_dir, keep_path=False, symlinks=True) - self.copy(pattern="*.dll", dst="bin", src=build_bin_dir, keep_path=False) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + if Version(self.version) < "1.4.0": + rmdir(self, os.path.join(self.package_folder, "lib", "draco")) + else: + rmdir(self, os.path.join(self.package_folder, "share")) + if self.options.shared: + rm(self, "*draco.a", os.path.join(self.package_folder, "lib")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "Draco" - self.cpp_info.names["cmake_find_package_multi"] = "Draco" - self.cpp_info.names["pkg_config"] = "draco" - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.set_property("cmake_file_name", "draco") + self.cpp_info.set_property("cmake_target_name", "draco::draco") + self.cpp_info.set_property("pkg_config_name", "draco") + self.cpp_info.libs = ["draco"] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") diff --git a/recipes/draco/all/patches/0001-fix-cmake-1.3.5.patch b/recipes/draco/all/patches/0001-fix-cmake-1.3.5.patch new file mode 100644 index 0000000000000..0b8abdd51f389 --- /dev/null +++ b/recipes/draco/all/patches/0001-fix-cmake-1.3.5.patch @@ -0,0 +1,24 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1107,7 +1107,7 @@ else () + + # Draco app targets. + add_executable(draco_decoder "${draco_src_root}/tools/draco_decoder.cc") +- target_link_libraries(draco_decoder PRIVATE dracodec) ++ target_link_libraries(draco_decoder PRIVATE draco) + add_executable(draco_encoder + "${draco_src_root}/tools/draco_encoder.cc") + target_link_libraries(draco_encoder PRIVATE draco) +@@ -1138,8 +1138,10 @@ else () + endif () + + # Add install rules for lib and executable targets. +- install(TARGETS dracodec dracoenc draco +- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") ++ install(TARGETS draco ++ RUNTIME DESTINATION bin ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib) + if (BUILD_UNITY_PLUGIN) + install(TARGETS dracodec_unity + DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/recipes/draco/all/patches/0001-fix-cmake-1.3.6.patch b/recipes/draco/all/patches/0001-fix-cmake-1.3.6.patch new file mode 100644 index 0000000000000..ff3287e3f4b83 --- /dev/null +++ b/recipes/draco/all/patches/0001-fix-cmake-1.3.6.patch @@ -0,0 +1,24 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1044,7 +1044,7 @@ else() + # Draco app targets. + add_executable(draco_decoder "${draco_src_root}/tools/draco_decoder.cc" + ${draco_io_sources}) +- target_link_libraries(draco_decoder PRIVATE dracodec) ++ target_link_libraries(draco_decoder PRIVATE draco) + add_executable(draco_encoder "${draco_src_root}/tools/draco_encoder.cc" + ${draco_io_sources}) + target_link_libraries(draco_encoder PRIVATE draco) +@@ -1073,8 +1073,10 @@ else() + endif() + + # Add install rules for lib and executable targets. +- install(TARGETS dracodec dracoenc draco DESTINATION +- "${CMAKE_INSTALL_PREFIX}/lib") ++ install(TARGETS draco ++ RUNTIME DESTINATION bin ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib) + if(BUILD_UNITY_PLUGIN) + install(TARGETS dracodec_unity DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") + endif() diff --git a/recipes/draco/all/patches/0001-fix-cmake-1.4.3.patch b/recipes/draco/all/patches/0001-fix-cmake-1.4.3.patch new file mode 100644 index 0000000000000..b18161cfbf66d --- /dev/null +++ b/recipes/draco/all/patches/0001-fix-cmake-1.4.3.patch @@ -0,0 +1,19 @@ +--- a/cmake/draco_install.cmake ++++ b/cmake/draco_install.cmake +@@ -70,14 +70,12 @@ macro(draco_setup_install_target) + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") + + if(MSVC) +- install(TARGETS draco DESTINATION +- "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") ++ install(TARGETS draco RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) + else() + install(TARGETS draco_static DESTINATION + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + if(BUILD_SHARED_LIBS) +- install(TARGETS draco_shared DESTINATION +- "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") ++ install(TARGETS draco_shared RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) + endif() + endif() + diff --git a/recipes/draco/all/patches/0001-fix-cmake-1.5.2.patch b/recipes/draco/all/patches/0001-fix-cmake-1.5.2.patch new file mode 100644 index 0000000000000..dbaee4fdaf2b4 --- /dev/null +++ b/recipes/draco/all/patches/0001-fix-cmake-1.5.2.patch @@ -0,0 +1,17 @@ +--- a/cmake/draco_install.cmake ++++ b/cmake/draco_install.cmake +@@ -84,12 +84,12 @@ macro(draco_setup_install_target) + endif() + + if(MSVC) +- install(TARGETS draco DESTINATION "${libs_path}") ++ install(TARGETS draco RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) + else() + install(TARGETS draco_static DESTINATION "${libs_path}") + + if(BUILD_SHARED_LIBS) +- install(TARGETS draco_shared DESTINATION "${libs_path}") ++ install(TARGETS draco_shared RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) + endif() + endif() + diff --git a/recipes/draco/all/patches/0002-v1.3.5-gcc-11.patch b/recipes/draco/all/patches/0002-v1.3.5-gcc-11.patch new file mode 100644 index 0000000000000..6a24b6c9ce15b --- /dev/null +++ b/recipes/draco/all/patches/0002-v1.3.5-gcc-11.patch @@ -0,0 +1,24 @@ +diff --git a/src/draco/core/hash_utils.h b/src/draco/core/hash_utils.h +index 0e8da60..ec28e85 100644 +--- a/src/draco/core/hash_utils.h ++++ b/src/draco/core/hash_utils.h +@@ -16,6 +16,7 @@ + #define DRACO_CORE_HASH_UTILS_H_ + + #include ++#include + #include + + // TODO(fgalligan): Move this to core. +diff --git a/src/draco/io/parser_utils.cc b/src/draco/io/parser_utils.cc +index 0a22ba1..f6d040a 100644 +--- a/src/draco/io/parser_utils.cc ++++ b/src/draco/io/parser_utils.cc +@@ -18,6 +18,7 @@ + #include + #include + #include ++#include + + namespace draco { + namespace parser { diff --git a/recipes/draco/all/patches/0002-v1.3.6-gcc-11.patch b/recipes/draco/all/patches/0002-v1.3.6-gcc-11.patch new file mode 100644 index 0000000000000..5980643ec3156 --- /dev/null +++ b/recipes/draco/all/patches/0002-v1.3.6-gcc-11.patch @@ -0,0 +1,25 @@ +diff --git a/src/draco/core/hash_utils.h b/src/draco/core/hash_utils.h +index dd910d0..ec28e85 100644 +--- a/src/draco/core/hash_utils.h ++++ b/src/draco/core/hash_utils.h +@@ -16,7 +16,7 @@ + #define DRACO_CORE_HASH_UTILS_H_ + + #include +- ++#include + #include + + // TODO(fgalligan): Move this to core. +diff --git a/src/draco/io/parser_utils.cc b/src/draco/io/parser_utils.cc +index 6e42a58..45df9d1 100644 +--- a/src/draco/io/parser_utils.cc ++++ b/src/draco/io/parser_utils.cc +@@ -18,6 +18,7 @@ + #include + #include + #include ++#include + + namespace draco { + namespace parser { diff --git a/recipes/draco/all/patches/non-copy-ellision-workaround.patch b/recipes/draco/all/patches/0003-non-copy-ellision-workaround.patch similarity index 100% rename from recipes/draco/all/patches/non-copy-ellision-workaround.patch rename to recipes/draco/all/patches/0003-non-copy-ellision-workaround.patch diff --git a/recipes/draco/all/test_package/CMakeLists.txt b/recipes/draco/all/test_package/CMakeLists.txt index 33ae887aa6aea..df800aa1ddc46 100644 --- a/recipes/draco/all/test_package/CMakeLists.txt +++ b/recipes/draco/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(draco REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE draco::draco) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/draco/all/test_package/conanfile.py b/recipes/draco/all/test_package/conanfile.py index ea57a464900be..0a6bc68712d90 100644 --- a/recipes/draco/all/test_package/conanfile.py +++ b/recipes/draco/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/draco/all/test_v1_package/CMakeLists.txt b/recipes/draco/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4d130e35e6014 --- /dev/null +++ b/recipes/draco/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(draco REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE draco::draco) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/draco/all/test_v1_package/conanfile.py b/recipes/draco/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/draco/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/draco/config.yml b/recipes/draco/config.yml index 10d3a845bf8c7..1d0bf1ab356f5 100644 --- a/recipes/draco/config.yml +++ b/recipes/draco/config.yml @@ -1,4 +1,14 @@ versions: + "1.5.5": + folder: all + "1.5.4": + folder: all + "1.5.3": + folder: all + "1.5.2": + folder: all + "1.4.3": + folder: all "1.3.6": folder: all "1.3.5": diff --git a/recipes/dragonbox/all/conandata.yml b/recipes/dragonbox/all/conandata.yml new file mode 100644 index 0000000000000..fbf31246d5c77 --- /dev/null +++ b/recipes/dragonbox/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "1.1.3": + url: "https://github.com/jk-jeon/dragonbox/archive/refs/tags/1.1.3.tar.gz" + sha256: "09d63b05e9c594ec423778ab59b7a5aa1d76fdd71d25c7048b0258c4ec9c3384" +patches: + "1.1.3": + - patch_file: "patches/1.1.3-fix-include-directory.patch" + patch_description: "fix include path" + patch_type: "conan" diff --git a/recipes/dragonbox/all/conanfile.py b/recipes/dragonbox/all/conanfile.py new file mode 100644 index 0000000000000..89c3a6984496c --- /dev/null +++ b/recipes/dragonbox/all/conanfile.py @@ -0,0 +1,98 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout + +import os + + +required_conan_version = ">=1.53.0" + + +class DragonboxConan(ConanFile): + name = "dragonbox" + description = "Reference implementation of Dragonbox in C++" + license = ("Apache-2.0", "LLVM-exception", "BSL-1.0") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/jk-jeon/dragonbox" + topics = ("float-to-string", "grisu", "grisu-exact") + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + } + default_options = { + "fPIC": True, + } + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "clang": "7", + "apple-clang": "10", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + check_min_vs(self, 192) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.variables["DRAGONBOX_INSTALL_TO_CHARS"] = True + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE*", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_module_file_name", "dragonbox") + self.cpp_info.components["_dragonbox"].set_property("cmake_target_name", "dragonbox::dragonbox") + self.cpp_info.components["dragonbox_to_chars_headers"].set_property("cmake_target_name", "dragonbox::dragonbox_to_chars") + self.cpp_info.components["dragonbox_to_chars_headers"].libs = ["dragonbox_to_chars"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "dragonbox" + self.cpp_info.filenames["cmake_find_package_multi"] = "dragonbox" + self.cpp_info.names["cmake_find_package"] = "dragonbox" + self.cpp_info.names["cmake_find_package_multi"] = "dragonbox" + self.cpp_info.components["_dragonbox"].names["cmake_find_package"] = "dragonbox" + self.cpp_info.components["_dragonbox"].names["cmake_find_package_multi"] = "dragonbox" + self.cpp_info.components["dragonbox_to_chars_headers"].names["cmake_find_package"] = "dragonbox_to_chars" + self.cpp_info.components["dragonbox_to_chars_headers"].names["cmake_find_package_multi"] = "dragonbox_to_chars" diff --git a/recipes/dragonbox/all/patches/1.1.3-fix-include-directory.patch b/recipes/dragonbox/all/patches/1.1.3-fix-include-directory.patch new file mode 100644 index 0000000000000..906ca02b2235e --- /dev/null +++ b/recipes/dragonbox/all/patches/1.1.3-fix-include-directory.patch @@ -0,0 +1,13 @@ +diff --git a/a/CMakeLists.txt b/b/CMakeLists.txt +index a9d80b9..e0417d7 100644 +--- a/a/CMakeLists.txt ++++ b/b/CMakeLists.txt +@@ -58,7 +58,7 @@ option(DRAGONBOX_INSTALL_TO_CHARS + On) + + set(dragonbox_directory "dragonbox-${PROJECT_VERSION}") +-set(dragonbox_include_directory "${CMAKE_INSTALL_INCLUDEDIR}/${dragonbox_directory}") ++set(dragonbox_include_directory "${CMAKE_INSTALL_INCLUDEDIR}") + set(dragonbox_install_targets "dragonbox") + + if (DRAGONBOX_INSTALL_TO_CHARS) diff --git a/recipes/dragonbox/all/test_package/CMakeLists.txt b/recipes/dragonbox/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7523e1c1d0d5d --- /dev/null +++ b/recipes/dragonbox/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +find_package(dragonbox REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE dragonbox::dragonbox_to_chars) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/dragonbox/all/test_package/conanfile.py b/recipes/dragonbox/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/dragonbox/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/dragonbox/all/test_package/test_package.cpp b/recipes/dragonbox/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7f20adde8e681 --- /dev/null +++ b/recipes/dragonbox/all/test_package/test_package.cpp @@ -0,0 +1,23 @@ +#include +#include + +#include "dragonbox/dragonbox_to_chars.h" + +int main(void) { + constexpr int buffer_length = 1 + // for '\0' + jkj::dragonbox::max_output_string_length; + double x = 1.234; // Also works for float + char buffer[buffer_length]; + + // Null-terminate the buffer and return the pointer to the null character + // Hence, the length of the string is (end_ptr - buffer) + // buffer is now { '1', '.', '2', '3', '4', 'E', '0', '\0', (garbages) } + char* end_ptr = jkj::dragonbox::to_chars(x, buffer); + + // Does not null-terminate the buffer; returns the next-to-end pointer + // buffer is now { '1', '.', '2', '3', '4', 'E', '0', (garbages) } + // you can wrap the buffer with things like std::string_view + end_ptr = jkj::dragonbox::to_chars_n(x, buffer); + + return 0; +} diff --git a/recipes/dragonbox/all/test_v1_package/CMakeLists.txt b/recipes/dragonbox/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/dragonbox/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/dragonbox/all/test_v1_package/conanfile.py b/recipes/dragonbox/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/dragonbox/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/dragonbox/config.yml b/recipes/dragonbox/config.yml new file mode 100644 index 0000000000000..e1c4f3be24983 --- /dev/null +++ b/recipes/dragonbox/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.3": + folder: all diff --git a/recipes/drflac/all/CMakeLists.txt b/recipes/drflac/all/CMakeLists.txt new file mode 100644 index 0000000000000..f2a49258562bf --- /dev/null +++ b/recipes/drflac/all/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.4) +project(dr_flac LANGUAGES C) + +include(GNUInstallDirs) + +set(BUFFER_SIZE "0" CACHE STRING "Value for define DR_FLAC_BUFFER_SIZE. 0 means default buffer size.") +option(NO_CRC "Build with define DR_FLAC_NO_CRC" OFF) +option(NO_OGG "Build with define DR_FLAC_NO_OGG" OFF) +option(NO_SIMD "Build with define DR_FLAC_NO_SIMD" OFF) +option(NO_STDIO "Build with define DR_FLAC_NO_STDIO" OFF) +option(NO_WCHAR "Build with define DR_FLAC_NO_WCHAR" OFF) + +add_library(${CMAKE_PROJECT_NAME} dr_flac.c) + +target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${DRFLAC_SRC_DIR}) + +set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES + PUBLIC_HEADER ${DRFLAC_SRC_DIR}/dr_flac.h + C_STANDARD 99 +) + +if(BUILD_SHARED_LIBS) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDRFLAC_DLL) +endif() +if(NOT BUFFER_SIZE STREQUAL "0") + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC "-DDR_FLAC_BUFFER_SIZE=${BUFFER_SIZE}") +endif() +if(NO_CRC) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDR_FLAC_NO_CRC) +endif() +if(NO_OGG) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDR_FLAC_NO_OGG) +endif() +if(NO_SIMD) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDR_FLAC_NO_SIMD) +endif() +if(NO_STDIO) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDR_FLAC_NO_STDIO) +endif() +if(NO_WCHAR) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDR_FLAC_NO_WCHAR) +endif() + +install(TARGETS ${CMAKE_PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/drflac/all/conandata.yml b/recipes/drflac/all/conandata.yml new file mode 100644 index 0000000000000..4b8f26778e5b0 --- /dev/null +++ b/recipes/drflac/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + # NOTE: https://github.com/mackron/dr_libs/blob/dd762b861ecadf5ddd5fb03e9ca1db6707b54fbb/dr_flac.h#L3 + "0.12.39": + url: https://github.com/mackron/dr_libs/archive/dd762b861ecadf5ddd5fb03e9ca1db6707b54fbb.zip + sha256: "077d6b29a78da5132065fcc9b44ca50e7e168b94250f2c25614101d3f808bcc1" + # NOTE: https://github.com/mackron/dr_libs/blob/089deaa62268e6dacf2026754b1b228e54eb3993/dr_flac.h#L3 + "0.12.38": + url: https://github.com/mackron/dr_libs/archive/089deaa62268e6dacf2026754b1b228e54eb3993.zip + sha256: "1b9fa02c56c2b42c99dd070c7dc3d4e8dee6a4e49139055e7f79e21aa88070d7" diff --git a/recipes/drflac/all/conanfile.py b/recipes/drflac/all/conanfile.py new file mode 100644 index 0000000000000..ae9f5ee425002 --- /dev/null +++ b/recipes/drflac/all/conanfile.py @@ -0,0 +1,94 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.46.0" + + +class DrflacConan(ConanFile): + name = "drflac" + description = "FLAC audio decoder." + homepage = "https://mackron.github.io/dr_flac" + topics = ("audio", "flac", "sound") + license = ("Unlicense", "MIT-0") + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "buffer_size": ["ANY"], + "no_crc": [True, False], + "no_ogg": [True, False], + "no_simd": [True, False], + "no_stdio": [True, False], + "no_wchar": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "buffer_size": 0, # zero means the default buffer size is used + "no_crc": False, + "no_ogg": False, + "no_simd": False, + "no_stdio": False, + "no_wchar": False + } + exports_sources = ["CMakeLists.txt", "dr_flac.c"] + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if Version(self.version) < "0.12.39": + del self.options.no_wchar + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def layout(self): + cmake_layout(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["DRFLAC_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["BUFFER_SIZE"] = self.options.buffer_size + tc.variables["NO_CRC"] = self.options.no_crc + tc.variables["NO_OGG"] = self.options.no_ogg + tc.variables["NO_SIMD"] = self.options.no_simd + tc.variables["NO_STDIO"] = self.options.no_stdio + tc.variables["NO_WCHAR"] = self.options.get_safe("no_wchar", False) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["dr_flac"] + if self.options.shared: + self.cpp_info.defines.append("DRFLAC_DLL") + if self.options.buffer_size != "0": + self.cpp_info.defines.append("DR_FLAC_BUFFER_SIZE={}".format(self.options.buffer_size)) + if self.options.no_crc: + self.cpp_info.defines.append("DR_FLAC_NO_CRC") + if self.options.no_ogg: + self.cpp_info.defines.append("DR_FLAC_NO_OGG") + if self.options.no_simd: + self.cpp_info.defines.append("DR_FLAC_NO_SIMD") + if self.options.no_stdio: + self.cpp_info.defines.append("DR_FLAC_NO_STDIO") + if self.options.get_safe("no_wchar", False): + self.cpp_info.defines.append("DR_FLAC_NO_WCHAR") diff --git a/recipes/drflac/all/dr_flac.c b/recipes/drflac/all/dr_flac.c new file mode 100644 index 0000000000000..8d3599cc734f1 --- /dev/null +++ b/recipes/drflac/all/dr_flac.c @@ -0,0 +1,3 @@ +#define DR_FLAC_IMPLEMENTATION + +#include "dr_flac.h" diff --git a/recipes/drflac/all/test_package/CMakeLists.txt b/recipes/drflac/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f1c86abcb3be6 --- /dev/null +++ b/recipes/drflac/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(drflac CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} drflac::drflac) +set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/drflac/all/test_package/conanfile.py b/recipes/drflac/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/drflac/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/drflac/all/test_package/test_package.c b/recipes/drflac/all/test_package/test_package.c new file mode 100644 index 0000000000000..992ab6220085f --- /dev/null +++ b/recipes/drflac/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include +#include "dr_flac.h" + +int main(void) { + const char *version = drflac_version_string(); + printf("dr_flac version: %s\n", version); + + return 0; +} diff --git a/recipes/drflac/all/test_v1_package/CMakeLists.txt b/recipes/drflac/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d9f4971c6bf0a --- /dev/null +++ b/recipes/drflac/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(drflac CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} drflac::drflac) +set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/drflac/all/test_v1_package/conanfile.py b/recipes/drflac/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/drflac/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/drflac/config.yml b/recipes/drflac/config.yml new file mode 100644 index 0000000000000..f7ff0941f9f1b --- /dev/null +++ b/recipes/drflac/config.yml @@ -0,0 +1,5 @@ +versions: + "0.12.39": + folder: all + "0.12.38": + folder: all diff --git a/recipes/drmp3/all/CMakeLists.txt b/recipes/drmp3/all/CMakeLists.txt new file mode 100644 index 0000000000000..c44a0bb77d180 --- /dev/null +++ b/recipes/drmp3/all/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.4) +project(dr_mp3 LANGUAGES C) + +include(GNUInstallDirs) + +option(NO_SIMD "Build with define DR_MP3_NO_SIMD" OFF) +option(NO_STDIO "Build with define DR_MP3_NO_STDIO" OFF) + +add_library(${CMAKE_PROJECT_NAME} dr_mp3.c) + +target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${DRMP3_SRC_DIR}) + +set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES + PUBLIC_HEADER ${DRMP3_SRC_DIR}/dr_mp3.h + C_STANDARD 99 +) + +if(BUILD_SHARED_LIBS) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDRMP3_DLL) +endif() +if(NO_SIMD) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDR_MP3_NO_SIMD) +endif() +if(NO_STDIO) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDR_MP3_NO_STDIO) +endif() + +install(TARGETS ${CMAKE_PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/drmp3/all/conandata.yml b/recipes/drmp3/all/conandata.yml new file mode 100644 index 0000000000000..a26d9e9dbb871 --- /dev/null +++ b/recipes/drmp3/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + # NOTE: https://github.com/mackron/dr_libs/blob/dd762b861ecadf5ddd5fb03e9ca1db6707b54fbb/dr_mp3.h#L3 + "0.6.34": + url: https://github.com/mackron/dr_libs/archive/dd762b861ecadf5ddd5fb03e9ca1db6707b54fbb.zip + sha256: "077d6b29a78da5132065fcc9b44ca50e7e168b94250f2c25614101d3f808bcc1" + # NOTE: https://github.com/mackron/dr_libs/blob/9497270f581f43e6b795ce5d98d8764861fb6a50/dr_mp3.h#L3 + "0.6.32": + url: https://github.com/mackron/dr_libs/archive/9497270f581f43e6b795ce5d98d8764861fb6a50.zip + sha256: "572b59ec9719cf8f4938f982bc1f2e52689a3fbf6cceb4f27478942d7e35456b" diff --git a/recipes/drmp3/all/conanfile.py b/recipes/drmp3/all/conanfile.py new file mode 100644 index 0000000000000..e21eeff31877c --- /dev/null +++ b/recipes/drmp3/all/conanfile.py @@ -0,0 +1,73 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.46.0" + + +class Drmp3Conan(ConanFile): + name = "drmp3" + description = "MP3 audio decoder." + homepage = "https://mackron.github.io/" + topics = ("audio", "mp3", "sound") + license = ("Unlicense", "MIT-0") + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "no_simd": [True, False], + "no_stdio": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "no_simd": False, + "no_stdio": False + } + exports_sources = ["CMakeLists.txt", "dr_mp3.c"] + + _cmake = None + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def layout(self): + cmake_layout(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["DRMP3_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["NO_SIMD"] = self.options.no_simd + tc.variables["NO_STDIO"] = self.options.no_stdio + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["dr_mp3"] + if self.options.shared: + self.cpp_info.defines.append("DRMP3_DLL") + if self.options.no_simd: + self.cpp_info.defines.append("DR_MP3_NO_SIMD") + if self.options.no_stdio: + self.cpp_info.defines.append("DR_MP3_NO_STDIO") diff --git a/recipes/drmp3/all/dr_mp3.c b/recipes/drmp3/all/dr_mp3.c new file mode 100644 index 0000000000000..c1514c4731e49 --- /dev/null +++ b/recipes/drmp3/all/dr_mp3.c @@ -0,0 +1,3 @@ +#define DR_MP3_IMPLEMENTATION + +#include "dr_mp3.h" diff --git a/recipes/drmp3/all/test_package/CMakeLists.txt b/recipes/drmp3/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b5b2e6102e202 --- /dev/null +++ b/recipes/drmp3/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(drmp3 CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} drmp3::drmp3) +set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/drmp3/all/test_package/conanfile.py b/recipes/drmp3/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/drmp3/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/drmp3/all/test_package/test_package.c b/recipes/drmp3/all/test_package/test_package.c new file mode 100644 index 0000000000000..9760fc154c008 --- /dev/null +++ b/recipes/drmp3/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include +#include "dr_mp3.h" + +int main(void) { + const char *version = drmp3_version_string(); + printf("dr_mp3 version: %s\n", version); + + return 0; +} diff --git a/recipes/drmp3/all/test_v1_package/CMakeLists.txt b/recipes/drmp3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..bfd7908ef1c6f --- /dev/null +++ b/recipes/drmp3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(drmp3 CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} drmp3::drmp3) +set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/drmp3/all/test_v1_package/conanfile.py b/recipes/drmp3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/drmp3/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/drmp3/config.yml b/recipes/drmp3/config.yml new file mode 100644 index 0000000000000..dda44114b507b --- /dev/null +++ b/recipes/drmp3/config.yml @@ -0,0 +1,5 @@ +versions: + "0.6.34": + folder: all + "0.6.32": + folder: all diff --git a/recipes/drogon/all/conandata.yml b/recipes/drogon/all/conandata.yml new file mode 100644 index 0000000000000..08abde0a27bf2 --- /dev/null +++ b/recipes/drogon/all/conandata.yml @@ -0,0 +1,28 @@ +sources: + "1.8.0": + url: "https://github.com/drogonframework/drogon/archive/refs/tags/v1.8.0.tar.gz" + sha256: "bc6503cf213ed961d4a5e9fd7cb8e75b6b11045a67840ea2241e57321dd8711b" + "1.7.5": + url: "https://github.com/drogonframework/drogon/archive/refs/tags/v1.7.5.tar.gz" + sha256: "e2af7c55dcabafef16f26f5b3242692f5a2b54c19b7b626840bf9132d24766f6" +patches: + "1.8.0": + - patch_file: "patches/1.8.0-0001-disable-unused-data.patch" + patch_description: "Consume Trantor package from Conan instead of using the subproject" + patch_type: "conan" + - patch_file: "patches/1.8.0-0002-find-package-jsoncpp.patch" + patch_description: "Fix jsoncpp cmake target name" + patch_type: "conan" + "1.7.5": + - patch_file: "patches/1.7.5-0001-disable_trantor.patch" + patch_description: "Consume Trantor package from Conan instead of using the subproject" + patch_type: "conan" + - patch_file: "patches/1.7.5-0002-remove-boost-components.patch" + patch_description: "Do not consume specific Boost components" + patch_type: "conan" + - patch_file: "patches/1.7.5-0003-find-package-trantor.patch" + patch_description: "Fix Trantor cmake target name" + patch_type: "conan" + - patch_file: "patches/1.7.5-0004-find-package-jsoncpp.patch" + patch_description: "Fix jsoncpp cmake target name" + patch_type: "conan" diff --git a/recipes/drogon/all/conanfile.py b/recipes/drogon/all/conanfile.py new file mode 100644 index 0000000000000..c5ca4457d0f24 --- /dev/null +++ b/recipes/drogon/all/conanfile.py @@ -0,0 +1,167 @@ +from conan import ConanFile +from conan.tools.cmake import cmake_layout, CMakeToolchain, CMakeDeps, CMake +from conan.tools.files import copy, get, apply_conandata_patches, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +import os + + +required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" + +class DrogonConan(ConanFile): + name = "drogon" + description = "A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows" + topics = ("http-server", "non-blocking-io", "http-framework", "asynchronous-programming") + license = "MIT" + homepage = "https://github.com/drogonframework/drogon" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [False, True], + "fPIC": [True, False], + "with_boost": [True, False], + "with_ctl": [True, False], + "with_orm": [True, False], + "with_profile": [True, False], + "with_brotli": [True, False], + "with_postgres": [True, False], + "with_postgres_batch": [True, False], + "with_mysql": [True, False], + "with_sqlite": [True, False], + "with_redis": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_boost": True, + "with_ctl": False, + "with_orm": True, + "with_profile": False, + "with_brotli": False, + "with_postgres": False, + "with_postgres_batch": False, + "with_mysql": False, + "with_sqlite": False, + "with_redis": False, + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + self.options["trantor"].shared = True + if not self.options.with_orm: + del self.options.with_postgres + del self.options.with_postgres_batch + del self.options.with_mysql + del self.options.with_sqlite + del self.options.with_redis + elif not self.options.with_postgres: + del self.options.with_postgres_batch + + @property + def _compilers_minimum_version(self): + return { + "gcc": "6", + "Visual Studio": "15.0", + "clang": "5", + "apple-clang": "10", + } + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, "14") + + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version: + if Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration("{} requires C++14, which your compiler does not support.".format(self.name)) + else: + self.output.warn("{} requires C++14. Your compiler is unknown. Assuming it supports C++14.".format(self.name)) + + def requirements(self): + self.requires("trantor/1.5.8") + self.requires("jsoncpp/1.9.5") + self.requires("openssl/1.1.1s") + self.requires("zlib/1.2.13") + if self.settings.os == "Linux": + self.requires("libuuid/1.0.3") + if self.options.with_profile: + self.requires("coz/cci.20210322") + if self.options.with_boost: + self.requires("boost/1.80.0") + if self.options.with_brotli: + self.requires("brotli/1.0.9") + if self.options.get_safe("with_postgres"): + self.requires("libpq/14.5") + if self.options.get_safe("with_mysql"): + self.requires("libmysqlclient/8.0.30") + if self.options.get_safe("with_sqlite"): + self.requires("sqlite3/3.40.0") + if self.options.get_safe("with_redis"): + self.requires("hiredis/1.0.2") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def layout(self): + cmake_layout(self, src_folder="src") + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_CTL"] = self.options.with_ctl + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_ORM"] = self.options.with_orm + tc.variables["COZ_PROFILING"] = self.options.with_profile + tc.variables["BUILD_DROGON_SHARED"] = self.options.shared + tc.variables["BUILD_DOC"] = False + tc.variables["BUILD_BROTLI"] = self.options.with_brotli + tc.variables["BUILD_POSTGRESQL"] = self.options.get_safe("with_postgres", False) + tc.variables["BUILD_POSTGRESQL_BATCH"] = self.options.get_safe("with_postgres_batch", False) + tc.variables["BUILD_MYSQL"] = self.options.get_safe("with_mysql", False) + tc.variables["BUILD_SQLITE"] = self.options.get_safe("with_sqlite", False) + tc.variables["BUILD_REDIS"] = self.options.get_safe("with_redis", False) + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.libs = ["drogon"] + if self.settings.os == "Windows": + self.cpp_info.system_libs.extend(["rpcrt4", "ws2_32", "crypt32", "advapi32"]) + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version).major == "8": + self.cpp_info.system_libs.append("stdc++fs") + + if self.options.with_ctl: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + + self.cpp_info.set_property("cmake_file_name", "Drogon") + self.cpp_info.set_property("cmake_target_name", "Drogon::Drogon") + + # TODO: Remove after Conan 2.0 + self.cpp_info.filenames["cmake_find_package"] = "Drogon" + self.cpp_info.filenames["cmake_find_package_multi"] = "Drogon" + self.cpp_info.names["cmake_find_package"] = "Drogon" + self.cpp_info.names["cmake_find_package_multi"] = "Drogon" diff --git a/recipes/drogon/all/patches/1.7.5-0001-disable_trantor.patch b/recipes/drogon/all/patches/1.7.5-0001-disable_trantor.patch new file mode 100644 index 0000000000000..bd56d16c697b5 --- /dev/null +++ b/recipes/drogon/all/patches/1.7.5-0001-disable_trantor.patch @@ -0,0 +1,29 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 146d2b8..f83e119 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -52,7 +52,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + endif () + + if (BUILD_DROGON_SHARED) +- set(BUILD_TRANTOR_SHARED TRUE) + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + find_package(Threads) + # set(BUILD_EXAMPLES FALSE) +@@ -110,7 +109,6 @@ target_include_directories( + $ + $ + $ +- $ + $ + $) + +@@ -120,8 +118,6 @@ if (WIN32) + PRIVATE $) + endif (WIN32) + +-add_subdirectory(trantor) +- + target_link_libraries(${PROJECT_NAME} PUBLIC trantor) + + if(${CMAKE_SYSTEM_NAME} STREQUAL "Haiku") diff --git a/recipes/drogon/all/patches/1.7.5-0002-remove-boost-components.patch b/recipes/drogon/all/patches/1.7.5-0002-remove-boost-components.patch new file mode 100644 index 0000000000000..6823964b810ea --- /dev/null +++ b/recipes/drogon/all/patches/1.7.5-0002-remove-boost-components.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f83e119..46a23fd 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -177,7 +177,8 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Android") + endif () + + if(NEED_BOOST_FS) +- find_package(Boost 1.49.0 COMPONENTS filesystem system REQUIRED) ++ # TODO: component specified find_package is always failed. Need to fix it. ++ find_package(Boost 1.49.0 REQUIRED) + message(STATUS "Using Boost filesytem::path") + message(STATUS "Boost include dir: " ${Boost_INCLUDE_DIR}) + include_directories(${BOOST_INCLUDE_DIRS}) diff --git a/recipes/drogon/all/patches/1.7.5-0003-find-package-trantor.patch b/recipes/drogon/all/patches/1.7.5-0003-find-package-trantor.patch new file mode 100644 index 0000000000000..d2e449648defd --- /dev/null +++ b/recipes/drogon/all/patches/1.7.5-0003-find-package-trantor.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 46a23fd..d2e2f69 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -118,7 +118,8 @@ if (WIN32) + PRIVATE $) + endif (WIN32) + +-target_link_libraries(${PROJECT_NAME} PUBLIC trantor) ++find_package(Trantor REQUIRED) ++target_link_libraries(${PROJECT_NAME} PUBLIC Trantor::Trantor) + + if(${CMAKE_SYSTEM_NAME} STREQUAL "Haiku") + target_link_libraries(${PROJECT_NAME} PRIVATE network) diff --git a/recipes/drogon/all/patches/1.7.5-0004-find-package-jsoncpp.patch b/recipes/drogon/all/patches/1.7.5-0004-find-package-jsoncpp.patch new file mode 100644 index 0000000000000..dc4849690a251 --- /dev/null +++ b/recipes/drogon/all/patches/1.7.5-0004-find-package-jsoncpp.patch @@ -0,0 +1,17 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d2e2f69..61fb3bf 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -199,9 +199,9 @@ else() + endif() + + # jsoncpp +-find_package(Jsoncpp REQUIRED) +-target_link_libraries(${PROJECT_NAME} PUBLIC Jsoncpp_lib) +-list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${JSONCPP_INCLUDE_DIRS}) ++find_package(jsoncpp REQUIRED) ++target_link_libraries(${PROJECT_NAME} PUBLIC jsoncpp_lib) ++list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${jsoncpp_INCLUDE_DIRS}) + + if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" + AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" diff --git a/recipes/drogon/all/patches/1.8.0-0001-disable-unused-data.patch b/recipes/drogon/all/patches/1.8.0-0001-disable-unused-data.patch new file mode 100644 index 0000000000000..3038da266a3a2 --- /dev/null +++ b/recipes/drogon/all/patches/1.8.0-0001-disable-unused-data.patch @@ -0,0 +1,41 @@ +index ca6dff2..ba015d2 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -16,7 +16,6 @@ option(BUILD_CTL "Build drogon_ctl" ${BUILD_PROGRAMS}) + option(BUILD_EXAMPLES "Build examples" ${BUILD_PROGRAMS}) + option(BUILD_ORM "Build orm" ON) + option(COZ_PROFILING "Use coz for profiling" OFF) +-option(BUILD_SHARED_LIBS "Build drogon as a shared lib" OFF) + option(BUILD_DOC "Build Doxygen documentation" OFF) + option(BUILD_BROTLI "Build Brotli" ON) + +@@ -106,7 +105,6 @@ target_include_directories( + $ + $ + $ +- $ + $ + $) + +@@ -116,9 +114,8 @@ if (WIN32) + PRIVATE $) + endif (WIN32) + +-add_subdirectory(trantor) +- +-target_link_libraries(${PROJECT_NAME} PUBLIC trantor) ++find_package(Trantor REQUIRED) ++target_link_libraries(${PROJECT_NAME} PUBLIC Trantor::Trantor) + + if(${CMAKE_SYSTEM_NAME} STREQUAL "Haiku") + target_link_libraries(${PROJECT_NAME} PRIVATE network) +@@ -177,7 +174,8 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Android") + endif () + + if(NEED_BOOST_FS) +- find_package(Boost 1.49.0 COMPONENTS filesystem system REQUIRED) ++ # TODO: component specified find_package is always failed. Need to fix it. ++ find_package(Boost 1.49.0 REQUIRED) + message(STATUS "Using Boost filesytem::path") + message(STATUS "Boost include dir: " ${Boost_INCLUDE_DIR}) + include_directories(${BOOST_INCLUDE_DIRS}) diff --git a/recipes/drogon/all/patches/1.8.0-0002-find-package-jsoncpp.patch b/recipes/drogon/all/patches/1.8.0-0002-find-package-jsoncpp.patch new file mode 100644 index 0000000000000..2402bc2bfdf71 --- /dev/null +++ b/recipes/drogon/all/patches/1.8.0-0002-find-package-jsoncpp.patch @@ -0,0 +1,17 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ba015d2..02c2ccc 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -195,9 +195,9 @@ else() + endif() + + # jsoncpp +-find_package(Jsoncpp REQUIRED) +-target_link_libraries(${PROJECT_NAME} PUBLIC Jsoncpp_lib) +-list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${JSONCPP_INCLUDE_DIRS}) ++find_package(jsoncpp REQUIRED) ++target_link_libraries(${PROJECT_NAME} PUBLIC jsoncpp_lib) ++list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${jsoncpp_INCLUDE_DIRS}) + + if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" + AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" diff --git a/recipes/drogon/all/test_package/CMakeLists.txt b/recipes/drogon/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..634b92448f47a --- /dev/null +++ b/recipes/drogon/all/test_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(Drogon CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} Drogon::Drogon) + +# drogon uses string_view when MSVC_VERSION is greater than 1900. +# https://github.com/drogonframework/drogon/blob/v1.7.5/lib/inc/drogon/utils/string_view.h#L16 +if(DEFINED MSVC_VERSION AND MSVC_VERSION GREATER 1900) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +endif() diff --git a/recipes/drogon/all/test_package/conanfile.py b/recipes/drogon/all/test_package/conanfile.py new file mode 100644 index 0000000000000..84eaa369e4a72 --- /dev/null +++ b/recipes/drogon/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type", + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/drogon/all/test_package/test_package.cpp b/recipes/drogon/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4676e2ff59d38 --- /dev/null +++ b/recipes/drogon/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include "drogon/drogon.h" + +int main() { + trantor::Logger::setLogLevel(trantor::Logger::kTrace); + + auto client = drogon::HttpClient::newHttpClient("http://www.example.com"); + auto req = drogon::HttpRequest::newHttpRequest(); + req->setMethod(drogon::Get); + req->setPath("/s"); + req->setParameter("wd", "wx"); + req->setParameter("oq", "wx"); + + return 0; +} diff --git a/recipes/drogon/all/test_v1_package/CMakeLists.txt b/recipes/drogon/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3bd4427985a7e --- /dev/null +++ b/recipes/drogon/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Drogon CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} Drogon::Drogon) + +# drogon uses string_view when MSVC_VERSION is greater than 1900. +# https://github.com/drogonframework/drogon/blob/v1.7.5/lib/inc/drogon/utils/string_view.h#L16 +if(DEFINED MSVC_VERSION AND MSVC_VERSION GREATER 1900) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +endif() diff --git a/recipes/drogon/all/test_v1_package/conanfile.py b/recipes/drogon/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..db6f728ae05ec --- /dev/null +++ b/recipes/drogon/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, CMake +from conan.tools.build import cross_building + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type", + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/drogon/config.yml b/recipes/drogon/config.yml new file mode 100644 index 0000000000000..6f8a6d82d9377 --- /dev/null +++ b/recipes/drogon/config.yml @@ -0,0 +1,5 @@ +versions: + "1.8.0": + folder: "all" + "1.7.5": + folder: "all" diff --git a/recipes/drwav/all/CMakeLists.txt b/recipes/drwav/all/CMakeLists.txt new file mode 100644 index 0000000000000..64cb2f4533122 --- /dev/null +++ b/recipes/drwav/all/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.4) +project(dr_wav LANGUAGES C) + +include(GNUInstallDirs) + +option(NO_CONVERSION_API "Build with define DR_WAV_NO_CONVERSION_API" OFF) +option(NO_STDIO "Build with define DR_WAV_NO_STDIO" OFF) +option(NO_WCHAR "Build with define DR_WAV_NO_WCHAR" OFF) + +add_library(${CMAKE_PROJECT_NAME} dr_wav.c) + +target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${DRWAV_SRC_DIR}) + +set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES + PUBLIC_HEADER ${DRWAV_SRC_DIR}/dr_wav.h + C_STANDARD 99 +) + +if(BUILD_SHARED_LIBS) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDRWAV_DLL) +endif() +if(NO_CONVERSION_API) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDR_WAV_NO_CONVERSION_API) +endif() +if(NO_STDIO) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDR_WAV_NO_STDIO) +endif() +if(NO_WCHAR) + target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DDR_WAV_NO_WCHAR) +endif() + +install(TARGETS ${CMAKE_PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/drwav/all/conandata.yml b/recipes/drwav/all/conandata.yml new file mode 100644 index 0000000000000..449e35d180bee --- /dev/null +++ b/recipes/drwav/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + # NOTE: https://github.com/mackron/dr_libs/blob/4f6da71ed357ade92dc91f00e6be7301ec9a82a3/dr_wav.h#L3 + "0.13.7": + url: https://github.com/mackron/dr_libs/archive/4f6da71ed357ade92dc91f00e6be7301ec9a82a3.zip + sha256: "0a77850ca558633e0516a68383481fb36823064256f2c50911056714420bc5b1" + # NOTE: https://github.com/mackron/dr_libs/blob/15f37e3ab01654c1a3bc98cff2a9ca64e8296fa9/dr_wav.h#L3 + "0.13.6": + url: https://github.com/mackron/dr_libs/archive/15f37e3ab01654c1a3bc98cff2a9ca64e8296fa9.zip + sha256: "39ea8c1f9b60a945735dfe4a2e0a2a6bd3bc921619fa7d2612dbc284b68c2419" diff --git a/recipes/drwav/all/conanfile.py b/recipes/drwav/all/conanfile.py new file mode 100644 index 0000000000000..634d49129395e --- /dev/null +++ b/recipes/drwav/all/conanfile.py @@ -0,0 +1,76 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.46.0" + + +class DrwavConan(ConanFile): + name = "drwav" + description = "WAV audio loader and writer." + homepage = "https://mackron.github.io/dr_wav" + topics = ("audio", "wav", "wave", "sound") + license = ("Unlicense", "MIT-0") + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "no_conversion_api": [True, False], + "no_stdio": [True, False], + "no_wchar": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "no_conversion_api": False, + "no_stdio": False, + "no_wchar": False + } + exports_sources = ["CMakeLists.txt", "dr_wav.c"] + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def layout(self): + cmake_layout(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["DRWAV_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["NO_CONVERSION_API"] = self.options.no_conversion_api + tc.variables["NO_STDIO"] = self.options.no_stdio + tc.variables["NO_WCHAR"] = self.options.no_wchar + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["dr_wav"] + if self.options.shared: + self.cpp_info.defines.append("DRWAV_DLL") + if self.options.no_conversion_api: + self.cpp_info.defines.append("DR_WAV_NO_CONVERSION_API") + if self.options.no_stdio: + self.cpp_info.defines.append("DR_WAV_NO_STDIO") + if self.options.no_wchar: + self.cpp_info.defines.append("DR_WAV_NO_WCHAR") diff --git a/recipes/drwav/all/dr_wav.c b/recipes/drwav/all/dr_wav.c new file mode 100644 index 0000000000000..79c6c57152b37 --- /dev/null +++ b/recipes/drwav/all/dr_wav.c @@ -0,0 +1,3 @@ +#define DRWAV_IMPLEMENTATION + +#include "dr_wav.h" diff --git a/recipes/drwav/all/test_package/CMakeLists.txt b/recipes/drwav/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8eb51f5f1843e --- /dev/null +++ b/recipes/drwav/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(drwav CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} drwav::drwav) +set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/drwav/all/test_package/conanfile.py b/recipes/drwav/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/drwav/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/drwav/all/test_package/test_package.c b/recipes/drwav/all/test_package/test_package.c new file mode 100644 index 0000000000000..17e551d634202 --- /dev/null +++ b/recipes/drwav/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include +#include "dr_wav.h" + +int main(void) { + const char *version = drwav_version_string(); + printf("dr_wav version: %s\n", version); + + return 0; +} diff --git a/recipes/drwav/all/test_v1_package/CMakeLists.txt b/recipes/drwav/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b7b4d6635b758 --- /dev/null +++ b/recipes/drwav/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(drwav CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} drwav::drwav) +set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/drwav/all/test_v1_package/conanfile.py b/recipes/drwav/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/drwav/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/drwav/config.yml b/recipes/drwav/config.yml new file mode 100644 index 0000000000000..6c8f065f79d49 --- /dev/null +++ b/recipes/drwav/config.yml @@ -0,0 +1,5 @@ +versions: + "0.13.7": + folder: all + "0.13.6": + folder: all diff --git a/recipes/dtl/all/conandata.yml b/recipes/dtl/all/conandata.yml index 653aaf31feb03..7ae1dc4743d98 100644 --- a/recipes/dtl/all/conandata.yml +++ b/recipes/dtl/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.20": + url: "https://github.com/cubicdaiya/dtl/archive/v1.20.tar.gz" + sha256: "579f81bca88f4b9760a59d99c5a95bd8dd5dc2f20f33f1f9b5f64cb08979f54d" "1.19": url: "https://github.com/cubicdaiya/dtl/archive/v1.19.tar.gz" sha256: "f47b99dd11e5d771ad32a8dc960db4ab2fbe349fb0346fa0795f53c846a99c5d" diff --git a/recipes/dtl/all/conanfile.py b/recipes/dtl/all/conanfile.py index cf90564cb27a4..6d45ac4104004 100644 --- a/recipes/dtl/all/conanfile.py +++ b/recipes/dtl/all/conanfile.py @@ -1,20 +1,24 @@ from conans import ConanFile, tools import os +required_conan_version = ">=1.33.0" class DtlConan(ConanFile): name = "dtl" description = "diff template library written by C++" topics = ("diff", "library", "algorithm") + license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/cubicdaiya/dtl" - license = "BSD-3-Clause" no_copy_source = True @property def _source_subfolder(self): return "source_subfolder" - + + def package_id(self): + self.info.header_only() + def source(self): tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) @@ -22,5 +26,3 @@ def package(self): self.copy(os.path.join("dtl", "*.hpp"), dst="include", src=self._source_subfolder) self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - def package_id(self): - self.info.header_only() diff --git a/recipes/dtl/all/test_package/CMakeLists.txt b/recipes/dtl/all/test_package/CMakeLists.txt index 6a01def66fcec..9710bb88ce36c 100644 --- a/recipes/dtl/all/test_package/CMakeLists.txt +++ b/recipes/dtl/all/test_package/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(dtl CONFIG REQUIRED) add_executable(test_package test_package.cpp) +target_link_libraries(test_package PUBLIC dtl::dtl) diff --git a/recipes/dtl/all/test_package/conanfile.py b/recipes/dtl/all/test_package/conanfile.py index bd7165a553cf4..49a3a66ea5bad 100644 --- a/recipes/dtl/all/test_package/conanfile.py +++ b/recipes/dtl/all/test_package/conanfile.py @@ -4,7 +4,7 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/dtl/config.yml b/recipes/dtl/config.yml index aa91faae41e0a..66e68aaaf6fad 100644 --- a/recipes/dtl/config.yml +++ b/recipes/dtl/config.yml @@ -1,4 +1,6 @@ versions: + "1.20": + folder: "all" "1.19": folder: "all" "cci.20210404": diff --git a/recipes/duckdb/all/conandata.yml b/recipes/duckdb/all/conandata.yml new file mode 100644 index 0000000000000..4304099c6ee03 --- /dev/null +++ b/recipes/duckdb/all/conandata.yml @@ -0,0 +1,20 @@ +sources: + "0.6.0": + url: "https://github.com/duckdb/duckdb/archive/refs/tags/v0.6.0.tar.gz" + sha256: "700b09114f8b99892a9d19ba21ca962ae65d1ea8085622418a2fa50ff915b244" + "0.5.1": + url: "https://github.com/duckdb/duckdb/archive/refs/tags/v0.5.1.tar.gz" + sha256: "3dab7ba0d0f8d024d3c73fd3d4fb8834203c31d7b0ddb1e8539ee266e11b0e9b" + +patches: + "0.6.0": + - patch_file: "patches/0.6.0-0001-fix-cmake.patch" + patch_description: "install static of shared library, add installation for odbc extention" + patch_type: "portability" + - patch_file: "patches/0.6.0-0002-include-stdlib.patch" + patch_description: "include stdlib for abort function" + patch_type: "portability" + "0.5.1": + - patch_file: "patches/0.5.1-0001-fix-cmake.patch" + patch_description: "install static of shared library, add installation for odbc extention" + patch_type: "portability" diff --git a/recipes/duckdb/all/conanfile.py b/recipes/duckdb/all/conanfile.py new file mode 100644 index 0000000000000..6e8d8bec8f4ca --- /dev/null +++ b/recipes/duckdb/all/conanfile.py @@ -0,0 +1,207 @@ +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir, replace_in_file +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.microsoft import is_msvc +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.52.0" + +class DuckdbConan(ConanFile): + name = "duckdb" + description = "DuckDB is an embeddable SQL OLAP Database Management System" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/cwida/duckdb" + topics = ("sql", "database", "olap", "embedded-database") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_icu": [True, False], + "with_parquet": [True, False], + "with_tpch": [True, False], + "with_tpcds": [True, False], + "with_fts": [True, False], + "with_httpfs": [True, False], + "with_visualizer": [True, False], + "with_json": [True, False], + "with_excel": [True, False], + "with_sqlsmith": [True, False], + "with_odbc": [True, False], + "with_query_log": [True, False], + "with_shell": [True, False], + "with_threads": [True, False], + "with_rdtsc": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_icu": False, + "with_parquet": False, + "with_tpch": False, + "with_tpcds": False, + "with_fts": False, + "with_httpfs": False, + "with_visualizer": False, + "with_json": False, + "with_excel": False, + "with_sqlsmith": False, + "with_odbc": False, + "with_query_log": False, + "with_shell": False, + "with_threads": True, + "with_rdtsc": False, + } + short_paths = True + + @property + def _minimum_cpp_standard(self): + return 11 + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + # FIXME: duckdb vendors a bunch of deps by modify the source code to have their own namespace + if self.options.with_odbc: + self.requires("odbc/2.3.11") + if self.options.with_httpfs: + self.requires("openssl/3.0.5") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["DUCKDB_MAJOR_VERSION"] = Version(self.version).major + tc.variables["DUCKDB_MINOR_VERSION"] = Version(self.version).minor + tc.variables["DUCKDB_PATCH_VERSION"] = Version(self.version).patch + tc.variables["DUCKDB_DEV_ITERATION"] = 0 + tc.variables["BUILD_ICU_EXTENSION"] = self.options.with_icu + tc.variables["BUILD_PARQUET_EXTENSION"] = self.options.with_parquet + tc.variables["BUILD_TPCH_EXTENSION"] = self.options.with_tpch + tc.variables["BUILD_TPCDS_EXTENSION"] = self.options.with_tpcds + tc.variables["BUILD_FTS_EXTENSION"] = self.options.with_fts + tc.variables["BUILD_HTTPFS_EXTENSION"] = self.options.with_httpfs + tc.variables["BUILD_VISUALIZER_EXTENSION"] = self.options.with_visualizer + tc.variables["BUILD_JSON_EXTENSION"] = self.options.with_json + tc.variables["BUILD_EXCEL_EXTENSION"] = self.options.with_excel + tc.variables["BUILD_SQLSMITH_EXTENSION"] = self.options.with_sqlsmith + tc.variables["BUILD_ODBC_DRIVER"] = self.options.with_odbc + tc.variables["FORCE_QUERY_LOG"] = self.options.with_query_log + tc.variables["BUILD_SHELL"] = self.options.with_shell + tc.variables["DISABLE_THREADS"] = not self.options.with_threads + tc.variables["BUILD_UNITTESTS"] = False + tc.variables["BUILD_RDTSC"] = self.options.with_rdtsc + tc.variables["EXTENSION_STATIC_BUILD"] = not self.options.shared + tc.variables["ENABLE_SANITIZER"] = False + tc.variables["ENABLE_UBSAN"] = False + if is_msvc(self) and not self.options.shared: + tc.preprocessor_definitions["DUCKDB_API"] = "" + tc.generate() + + dpes = CMakeDeps(self) + dpes.generate() + + def build(self): + apply_conandata_patches(self) + if is_msvc(self) and not self.options.shared: + replace_in_file(self, os.path.join(self.source_folder, "src", "include", "duckdb.h"), + "#define DUCKDB_API __declspec(dllimport)", + "#define DUCKDB_API" + ) + replace_in_file(self, os.path.join(self.source_folder, "src", "include", "duckdb", "common", "winapi.hpp"), + "#define DUCKDB_API __declspec(dllimport)", + "#define DUCKDB_API" + ) + + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + if self.options.shared: + rm(self, "*.a", os.path.join(self.package_folder, "lib")) + rm(self, "duckdb_*.lib", os.path.join(self.package_folder, "lib")) + + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + + def package_info(self): + if self.options.shared: + self.cpp_info.libs = ["duckdb"] + else: + self.cpp_info.libs = [ + "duckdb_static", + "duckdb_fmt", + "duckdb_pg_query", + "duckdb_re2", + "duckdb_miniz", + "duckdb_utf8proc", + "duckdb_hyperloglog", + "duckdb_fastpforlib", + "duckdb_mbedtls", + ] + if Version(self.version) >= "0.6.0": + self.cpp_info.libs.append("duckdb_fsst") + + if self.options.with_icu: + self.cpp_info.libs.append("icu_extension") + if self.options.with_parquet: + self.cpp_info.libs.append("parquet_extension") + if self.options.with_tpch: + self.cpp_info.libs.append("tpch_extension") + if self.options.with_tpcds: + self.cpp_info.libs.append("tpcds_extension") + if self.options.with_fts: + self.cpp_info.libs.append("fts_extension") + if self.options.with_httpfs: + self.cpp_info.libs.append("httpfs_extension") + if self.options.with_visualizer: + self.cpp_info.libs.append("visualizer_extension") + if Version(self.version) >= "0.6.0" and self.settings.os == "Linux": + self.cpp_info.libs.append("jemalloc_extension") + if self.options.with_json: + self.cpp_info.libs.append("json_extension") + if self.options.with_excel: + self.cpp_info.libs.append("excel_extension") + if self.options.with_sqlsmith: + self.cpp_info.libs.append("sqlsmith_extension") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") + self.cpp_info.system_libs.append("dl") + self.cpp_info.system_libs.append("m") + + if self.settings.os == "Windows": + self.cpp_info.system_libs.append("ws2_32") + + if self.options.with_shell: + binpath = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH env var: {binpath}") + self.env_info.PATH.append(binpath) diff --git a/recipes/duckdb/all/patches/0.5.1-0001-fix-cmake.patch b/recipes/duckdb/all/patches/0.5.1-0001-fix-cmake.patch new file mode 100644 index 0000000000000..4c586f0038760 --- /dev/null +++ b/recipes/duckdb/all/patches/0.5.1-0001-fix-cmake.patch @@ -0,0 +1,82 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cc43104..5b034d2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -196,6 +196,8 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") + set(SUN TRUE) + endif() + ++if(0) # conan patch ++ + execute_process( + COMMAND git log -1 --format=%h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +@@ -236,6 +238,10 @@ else() + set(DUCKDB_VERSION "v${DUCKDB_MAJOR_VERSION}.${DUCKDB_MINOR_VERSION}.${DUCKDB_PATCH_VERSION}-dev${DUCKDB_DEV_ITERATION}") + endif() + ++else() # conan patch ++set(DUCKDB_VERSION "v${DUCKDB_MAJOR_VERSION}.${DUCKDB_MINOR_VERSION}.${DUCKDB_PATCH_VERSION}-dev${DUCKDB_DEV_ITERATION}") ++endif() # conan patch ++ + option(AMALGAMATION_BUILD + "Build from the amalgamation files, rather than from the normal sources." + FALSE) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 7e07a47..8027d90 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -166,9 +166,18 @@ if(BUILD_PYTHON + endif() + endif() + +-install( +- TARGETS duckdb duckdb_static +- EXPORT "${DUCKDB_EXPORT_SET}" +- LIBRARY DESTINATION "${INSTALL_LIB_DIR}" +- ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" +- RUNTIME DESTINATION "${INSTALL_BIN_DIR}") ++if(BUILD_SHARED_LIBS) ++ install( ++ TARGETS duckdb ++ EXPORT "${DUCKDB_EXPORT_SET}" ++ LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" ++ RUNTIME DESTINATION "${INSTALL_BIN_DIR}") ++else() ++ install( ++ TARGETS duckdb_static ++ EXPORT "${DUCKDB_EXPORT_SET}" ++ LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" ++ RUNTIME DESTINATION "${INSTALL_BIN_DIR}") ++endif() +diff --git a/tools/odbc/CMakeLists.txt b/tools/odbc/CMakeLists.txt +index 9d116b9..b46e5bd 100644 +--- a/tools/odbc/CMakeLists.txt ++++ b/tools/odbc/CMakeLists.txt +@@ -53,3 +53,11 @@ add_library( + set_target_properties(duckdb_odbc PROPERTIES DEFINE_SYMBOL "DUCKDB_ODBC_API") + + target_link_libraries(duckdb_odbc ${LINK_LIB_LIST} duckdb_static) ++ ++install( ++ TARGETS duckdb_odbc ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ++) +diff --git a/tools/sqlite3_api_wrapper/CMakeLists.txt b/tools/sqlite3_api_wrapper/CMakeLists.txt +index cef9622..ca7e1f1 100644 +--- a/tools/sqlite3_api_wrapper/CMakeLists.txt ++++ b/tools/sqlite3_api_wrapper/CMakeLists.txt +@@ -14,7 +14,7 @@ add_library(sqlite3_api_wrapper_static STATIC sqlite3_api_wrapper.cpp + target_link_libraries(sqlite3_api_wrapper_static duckdb_static duckdb_utf8proc) + link_threads(sqlite3_api_wrapper_static) + +-if(NOT WIN32) ++if(BUILD_SHARED_LIBS AND NOT WIN32) + add_library(sqlite3_api_wrapper SHARED sqlite3_api_wrapper.cpp + ${ALL_OBJECT_FILES}) + target_link_libraries(sqlite3_api_wrapper duckdb ${DUCKDB_EXTRA_LINK_FLAGS}) diff --git a/recipes/duckdb/all/patches/0.6.0-0001-fix-cmake.patch b/recipes/duckdb/all/patches/0.6.0-0001-fix-cmake.patch new file mode 100644 index 0000000000000..d43649a21a753 --- /dev/null +++ b/recipes/duckdb/all/patches/0.6.0-0001-fix-cmake.patch @@ -0,0 +1,58 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index b1bb843..4a4949c 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -167,9 +167,18 @@ if(BUILD_PYTHON + endif() + endif() + +-install( +- TARGETS duckdb duckdb_static +- EXPORT "${DUCKDB_EXPORT_SET}" +- LIBRARY DESTINATION "${INSTALL_LIB_DIR}" +- ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" +- RUNTIME DESTINATION "${INSTALL_BIN_DIR}") ++if(BUILD_SHARED_LIBS) ++ install( ++ TARGETS duckdb ++ EXPORT "${DUCKDB_EXPORT_SET}" ++ LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" ++ RUNTIME DESTINATION "${INSTALL_BIN_DIR}") ++else() ++ install( ++ TARGETS duckdb_static ++ EXPORT "${DUCKDB_EXPORT_SET}" ++ LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" ++ RUNTIME DESTINATION "${INSTALL_BIN_DIR}") ++endif() +diff --git a/tools/odbc/CMakeLists.txt b/tools/odbc/CMakeLists.txt +index 9d116b9..b46e5bd 100644 +--- a/tools/odbc/CMakeLists.txt ++++ b/tools/odbc/CMakeLists.txt +@@ -53,3 +53,11 @@ add_library( + set_target_properties(duckdb_odbc PROPERTIES DEFINE_SYMBOL "DUCKDB_ODBC_API") + + target_link_libraries(duckdb_odbc ${LINK_LIB_LIST} duckdb_static) ++ ++install( ++ TARGETS duckdb_odbc ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ++) +diff --git a/tools/sqlite3_api_wrapper/CMakeLists.txt b/tools/sqlite3_api_wrapper/CMakeLists.txt +index e785d4f..922746f 100644 +--- a/tools/sqlite3_api_wrapper/CMakeLists.txt ++++ b/tools/sqlite3_api_wrapper/CMakeLists.txt +@@ -17,7 +17,7 @@ add_library(sqlite3_api_wrapper_static STATIC ${SQLITE_API_WRAPPER_FILES}) + target_link_libraries(sqlite3_api_wrapper_static duckdb_static duckdb_utf8proc) + link_threads(sqlite3_api_wrapper_static) + +-if(NOT WIN32) ++if(BUILD_SHARED_LIBS AND NOT WIN32) + add_library(sqlite3_api_wrapper SHARED ${SQLITE_API_WRAPPER_FILES}) + target_link_libraries(sqlite3_api_wrapper duckdb ${DUCKDB_EXTRA_LINK_FLAGS}) + link_threads(sqlite3_api_wrapper) diff --git a/recipes/duckdb/all/patches/0.6.0-0002-include-stdlib.patch b/recipes/duckdb/all/patches/0.6.0-0002-include-stdlib.patch new file mode 100644 index 0000000000000..e9e04e59a49cc --- /dev/null +++ b/recipes/duckdb/all/patches/0.6.0-0002-include-stdlib.patch @@ -0,0 +1,12 @@ +diff --git a/extension/jemalloc/jemalloc/include/jemalloc/internal/jemalloc_preamble.h b/extension/jemalloc/jemalloc/include/jemalloc/internal/jemalloc_preamble.h +index 47455cb..cfd73bc 100644 +--- a/extension/jemalloc/jemalloc/include/jemalloc/internal/jemalloc_preamble.h ++++ b/extension/jemalloc/jemalloc/include/jemalloc/internal/jemalloc_preamble.h +@@ -4,6 +4,7 @@ + #include + #include + #include ++#include + + #include "jemalloc/internal/jemalloc_internal_defs.h" + #include "jemalloc/internal/jemalloc_internal_decls.h" diff --git a/recipes/duckdb/all/test_package/CMakeLists.txt b/recipes/duckdb/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..139856fb65898 --- /dev/null +++ b/recipes/duckdb/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(duckdb REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE duckdb::duckdb) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/duckdb/all/test_package/conanfile.py b/recipes/duckdb/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fbb7f543162 --- /dev/null +++ b/recipes/duckdb/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/duckdb/all/test_package/test_package.cpp b/recipes/duckdb/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..66bd4253c138b --- /dev/null +++ b/recipes/duckdb/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include +#include "duckdb.hpp" + +int main() { + duckdb::DuckDB db(nullptr); + duckdb::Connection con(db); +} diff --git a/recipes/duckdb/all/test_v1_package/CMakeLists.txt b/recipes/duckdb/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9319256c43756 --- /dev/null +++ b/recipes/duckdb/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(duckdb REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE duckdb::duckdb) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/duckdb/all/test_v1_package/conanfile.py b/recipes/duckdb/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/duckdb/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/duckdb/config.yml b/recipes/duckdb/config.yml new file mode 100644 index 0000000000000..77c93c26d7515 --- /dev/null +++ b/recipes/duckdb/config.yml @@ -0,0 +1,5 @@ +versions: + "0.6.0": + folder: "all" + "0.5.1": + folder: "all" diff --git a/recipes/duktape/all/CMakeLists.txt b/recipes/duktape/all/CMakeLists.txt index 60c910d05eafb..76bab4dba57c0 100644 --- a/recipes/duktape/all/CMakeLists.txt +++ b/recipes/duktape/all/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12) project(duktape C) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/src/*.c) file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/src/*.h) diff --git a/recipes/duktape/all/conandata.yml b/recipes/duktape/all/conandata.yml index e582badf650c4..c2be9628e480b 100644 --- a/recipes/duktape/all/conandata.yml +++ b/recipes/duktape/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "2.7.0": + url: "https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz" + sha256: "90f8d2fa8b5567c6899830ddef2c03f3c27960b11aca222fa17aa7ac613c2890" + "2.6.0": + url: "https://github.com/svaarala/duktape/releases/download/v2.6.0/duktape-2.6.0.tar.xz" + sha256: "96f4a05a6c84590e53b18c59bb776aaba80a205afbbd92b82be609ba7fe75fa7" "2.5.0": - sha256: 83d411560a1cd36ea132bd81d8d9885efe9285c6bc6685c4b71e69a0c4329616 - url: https://github.com/svaarala/duktape/releases/download/v2.5.0/duktape-2.5.0.tar.xz + url: "https://github.com/svaarala/duktape/releases/download/v2.5.0/duktape-2.5.0.tar.xz" + sha256: "83d411560a1cd36ea132bd81d8d9885efe9285c6bc6685c4b71e69a0c4329616" diff --git a/recipes/duktape/all/conanfile.py b/recipes/duktape/all/conanfile.py index d763158a1eca1..3e582932bd595 100644 --- a/recipes/duktape/all/conanfile.py +++ b/recipes/duktape/all/conanfile.py @@ -1,7 +1,7 @@ import os - from conans import CMake, ConanFile, tools +required_conan_version = ">=1.33.0" class DuktapeConan(ConanFile): name = "duktape" @@ -30,13 +30,13 @@ def config_options(self): del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def _configure_cmake(self): if self._cmake: diff --git a/recipes/duktape/all/test_package/conanfile.py b/recipes/duktape/all/test_package/conanfile.py index 1c1f92aa1caa9..ca9da95670911 100644 --- a/recipes/duktape/all/test_package/conanfile.py +++ b/recipes/duktape/all/test_package/conanfile.py @@ -13,5 +13,5 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/duktape/config.yml b/recipes/duktape/config.yml index 5cfb6fafcaf21..feada510c6875 100644 --- a/recipes/duktape/config.yml +++ b/recipes/duktape/config.yml @@ -1,3 +1,7 @@ versions: + "2.7.0": + folder: "all" + "2.6.0": + folder: "all" "2.5.0": folder: "all" diff --git a/recipes/earcut/all/conandata.yml b/recipes/earcut/all/conandata.yml index 61e767e55db9c..e7672ce5fb5f3 100644 --- a/recipes/earcut/all/conandata.yml +++ b/recipes/earcut/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "2.2.4": + url: "https://github.com/mapbox/earcut.hpp/archive/v2.2.4.tar.gz" + sha256: "fcfa6a47a52d4c94dc960bdb747f17e077609235517b0bb5ce8097d6b747695a" + "2.2.3": + url: "https://github.com/mapbox/earcut.hpp/archive/v2.2.3.tar.gz" + sha256: "f382616de763289c698f37ec3a5b9fcd3d6d821cbef0b3c72e43bdd909c81b5a" "0.12.4": sha256: "d935feac891fd39b4872074d968b1ddfe4b9128c5db1604e15447b87f7c70970" url: "https://github.com/mapbox/earcut.hpp/archive/refs/tags/v0.12.4.zip" diff --git a/recipes/earcut/config.yml b/recipes/earcut/config.yml index 6ad07c81af7a6..dc295dd4a8376 100644 --- a/recipes/earcut/config.yml +++ b/recipes/earcut/config.yml @@ -1,3 +1,7 @@ versions: + "2.2.4": + folder: "all" + "2.2.3": + folder: "all" "0.12.4": folder: "all" diff --git a/recipes/eastl/all/conandata.yml b/recipes/eastl/all/conandata.yml index 2d2bf034d9b6d..f1c15b1dc7308 100644 --- a/recipes/eastl/all/conandata.yml +++ b/recipes/eastl/all/conandata.yml @@ -1,42 +1,50 @@ sources: - 3.15.00: - url: "https://github.com/electronicarts/EASTL/archive/3.15.00.tar.gz" - sha256: "1578a2935ca490920b96c960fb570dab025280bb978fba40c88eb9ac74760c14" - 3.16.01: - url: "https://github.com/electronicarts/EASTL/archive/3.16.01.tar.gz" - sha256: "80b0754ea02364dfd3f94e3b65c93087849a8d407196702c0cae59097fbe8d21" - 3.16.05: - url: "https://github.com/electronicarts/EASTL/archive/3.16.05.tar.gz" - sha256: "deebff248ec0d4da35ca006cec39abdcfe65ccbd7294f6fbdb42fc92232368b6" - 3.16.07: - url: "https://github.com/electronicarts/EASTL/archive/3.16.07.tar.gz" - sha256: "f997a81c8cb36618bd4526ea7a02d026c8111d15fbc138c67ba8f4606680d551" - 3.17.03: - url: "https://github.com/electronicarts/EASTL/archive/3.17.03.tar.gz" - sha256: "50a072066e30fda364d482df6733572d8ca440a33825d81254b59a6ca9f4375a" - 3.17.06: + "3.18.00": + url: "https://github.com/electronicarts/EASTL/archive/refs/tags/3.18.00.tar.gz" + sha256: "a3c5b970684be02e81fb16fbf92ed2584e055898704fde87c72d0331afdea12b" + "3.17.06": url: "https://github.com/electronicarts/EASTL/archive/3.17.06.tar.gz" sha256: "9ebeef26cdf091877ee348450d2711cd0bb60ae435309126c0adf8fec9a01ea5" + "3.17.03": + url: "https://github.com/electronicarts/EASTL/archive/3.17.03.tar.gz" + sha256: "50a072066e30fda364d482df6733572d8ca440a33825d81254b59a6ca9f4375a" + "3.16.07": + url: "https://github.com/electronicarts/EASTL/archive/3.16.07.tar.gz" + sha256: "f997a81c8cb36618bd4526ea7a02d026c8111d15fbc138c67ba8f4606680d551" + "3.16.05": + url: "https://github.com/electronicarts/EASTL/archive/3.16.05.tar.gz" + sha256: "deebff248ec0d4da35ca006cec39abdcfe65ccbd7294f6fbdb42fc92232368b6" + "3.16.01": + url: "https://github.com/electronicarts/EASTL/archive/3.16.01.tar.gz" + sha256: "80b0754ea02364dfd3f94e3b65c93087849a8d407196702c0cae59097fbe8d21" + "3.15.00": + url: "https://github.com/electronicarts/EASTL/archive/3.15.00.tar.gz" + sha256: "1578a2935ca490920b96c960fb570dab025280bb978fba40c88eb9ac74760c14" patches: - 3.15.00: - - patch_file: "patches/3.15.00-0001-cmake-shared-use-conan-add-install.patch" - base_path: "source_subfolder" - 3.16.01: - - patch_file: "patches/3.15.00-0001-cmake-shared-use-conan-add-install.patch" - base_path: "source_subfolder" - 3.16.05: - - patch_file: "patches/3.15.00-0001-cmake-shared-use-conan-add-install.patch" + "3.18.00": + - patch_file: "patches/3.17.03-0001-cmake-shared-use-conan-add-install.patch" base_path: "source_subfolder" - 3.16.07: - - patch_file: "patches/3.15.00-0001-cmake-shared-use-conan-add-install.patch" + - patch_file: "patches/3.17.03-0002-revert-c++14-constexpr.patch" base_path: "source_subfolder" - 3.17.03: + "3.17.06": - patch_file: "patches/3.17.03-0001-cmake-shared-use-conan-add-install.patch" base_path: "source_subfolder" - patch_file: "patches/3.17.03-0002-revert-c++14-constexpr.patch" base_path: "source_subfolder" - 3.17.06: + "3.17.03": - patch_file: "patches/3.17.03-0001-cmake-shared-use-conan-add-install.patch" base_path: "source_subfolder" - patch_file: "patches/3.17.03-0002-revert-c++14-constexpr.patch" base_path: "source_subfolder" + "3.16.07": + - patch_file: "patches/3.15.00-0001-cmake-shared-use-conan-add-install.patch" + base_path: "source_subfolder" + "3.16.05": + - patch_file: "patches/3.15.00-0001-cmake-shared-use-conan-add-install.patch" + base_path: "source_subfolder" + "3.16.01": + - patch_file: "patches/3.15.00-0001-cmake-shared-use-conan-add-install.patch" + base_path: "source_subfolder" + "3.15.00": + - patch_file: "patches/3.15.00-0001-cmake-shared-use-conan-add-install.patch" + base_path: "source_subfolder" diff --git a/recipes/eastl/all/conanfile.py b/recipes/eastl/all/conanfile.py index 8e6e19f2a23af..faccbd629bec0 100644 --- a/recipes/eastl/all/conanfile.py +++ b/recipes/eastl/all/conanfile.py @@ -1,6 +1,8 @@ -import os from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" class EastlConan(ConanFile): @@ -8,16 +10,22 @@ class EastlConan(ConanFile): description = "EASTL stands for Electronic Arts Standard Template Library. " \ "It is an extensive and robust implementation that has an " \ "emphasis on high performance." - topics = ("conan", "eastl", "stl", "high-performance") + topics = ("eastl", "stl", "high-performance") license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/electronicarts/EASTL" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "compiler", "arch", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "cmake" _cmake = None @property @@ -41,25 +49,33 @@ def _minimum_compilers_version(self): "apple-clang": "4.3", } + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler.cppstd: + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("eabase/2.09.06") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, self._minimum_cpp_standard) mininum_compiler_version = self._minimum_compilers_version.get(str(self.settings.compiler)) if mininum_compiler_version and tools.Version(self.settings.compiler.version) < mininum_compiler_version: raise ConanInvalidConfiguration("Compiler is too old for c++ {}".format(self._minimum_cpp_standard)) - def requirements(self): - self.requires("eabase/2.09.05") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - folder_name = "EASTL-{}".format(self.version) - os.rename(folder_name, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -71,7 +87,7 @@ def _configure_cmake(self): return self._cmake def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) tools.replace_path_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), "include(CommonCppFlags)", @@ -89,10 +105,12 @@ def package(self): cmake.install() def package_info(self): - self.cpp_info.names["cmake_find_package"] = "EASTL" - self.cpp_info.names["cmake_find_package_multi"] = "EASTL" self.cpp_info.libs = ["EASTL"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("pthread") if self.options.shared: self.cpp_info.defines.append("EA_DLL") + + # Do not use these names in set_property, it was a mistake, eastl doesn't export its target + self.cpp_info.names["cmake_find_package"] = "EASTL" + self.cpp_info.names["cmake_find_package_multi"] = "EASTL" diff --git a/recipes/eastl/all/test_package/conanfile.py b/recipes/eastl/all/test_package/conanfile.py index bd7165a553cf4..5c09494bc67c0 100644 --- a/recipes/eastl/all/test_package/conanfile.py +++ b/recipes/eastl/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/eastl/config.yml b/recipes/eastl/config.yml index 2384188c97999..bfb95b02f09c0 100644 --- a/recipes/eastl/config.yml +++ b/recipes/eastl/config.yml @@ -1,13 +1,15 @@ versions: - "3.15.00": + "3.18.00": folder: "all" - "3.16.01": + "3.17.06": folder: "all" - "3.16.05": + "3.17.03": folder: "all" "3.16.07": folder: "all" - "3.17.03": + "3.16.05": folder: "all" - "3.17.06": + "3.16.01": + folder: "all" + "3.15.00": folder: "all" diff --git a/recipes/easy_profiler/all/conandata.yml b/recipes/easy_profiler/all/conandata.yml index 753771f92e779..912612b74f23d 100644 --- a/recipes/easy_profiler/all/conandata.yml +++ b/recipes/easy_profiler/all/conandata.yml @@ -2,3 +2,7 @@ sources: "2.1.0": url: "https://github.com/yse/easy_profiler/archive/v2.1.0.tar.gz" sha256: "fabf95d59ede9da4873aebd52ef8a762fa8578dcdbcc6d7cdd811b5a7c3367ad" +patches: + "2.1.0": + - patch_file: "patches/0001-fix-cmake-bundle-install.patch" + base_path: "source_subfolder" diff --git a/recipes/easy_profiler/all/conanfile.py b/recipes/easy_profiler/all/conanfile.py index 90a431c61af45..8d7e8ffb71515 100644 --- a/recipes/easy_profiler/all/conanfile.py +++ b/recipes/easy_profiler/all/conanfile.py @@ -1,6 +1,9 @@ from conans import ConanFile, tools, CMake +from conans.errors import ConanInvalidConfiguration import os -import glob +import textwrap + +required_conan_version = ">=1.33.0" class EasyProfilerConan(ConanFile): @@ -21,7 +24,6 @@ class EasyProfilerConan(ConanFile): "shared": False, "fPIC": True } - short_paths = True _cmake = None @@ -41,13 +43,21 @@ def configure(self): if self.options.shared: del self.options.fPIC + def validate(self): + if self.settings.compiler == "Visual Studio" and self.settings.compiler.runtime == "MTd" and \ + self.options.shared and tools.Version(self.settings.compiler.version) >= "15": + raise ConanInvalidConfiguration( + "{} {} with MTd runtime not supported".format(self.settings.compiler, + self.settings.compiler.version) + ) + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - url = self.conan_data["sources"][self.version]["url"] - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) cmake = self._configure_cmake() cmake.build() @@ -57,6 +67,7 @@ def _configure_cmake(self): self._cmake = CMake(self) # Don't build the GUI because it is dependent on Qt self._cmake.definitions["EASY_PROFILER_NO_GUI"] = True + self._cmake.definitions["EASY_PROFILER_NO_SAMPLES"] = True self._cmake.configure(build_folder=self._build_subfolder) return self._cmake @@ -70,17 +81,49 @@ def package(self): os.remove(os.path.join(self.package_folder, "LICENSE.MIT")) os.remove(os.path.join(self.package_folder, "LICENSE.APACHE")) if self.settings.os == "Windows": - for dll_file in \ - glob.glob(os.path.join(self.package_folder, "bin", "*.dll")): - if os.path.basename(dll_file).startswith(("concrt", "msvcp", - "vcruntime")): - os.remove(dll_file) + for dll_prefix in ["concrt", "msvcp", "vcruntime"]: + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), + "{}*.dll".format(dll_prefix)) + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"easy_profiler": "easy_profiler::easy_profiler"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake") + + @property + def _module_file_rel_path(self): + return os.path.join(self._module_subfolder, + "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): + self.cpp_info.names["cmake_find_package"] = "easy_profiler" + self.cpp_info.names["cmake_find_package_multi"] = "easy_profiler" + self.cpp_info.builddirs.append(self._module_subfolder) + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] self.cpp_info.libs = ["easy_profiler"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m", "pthread"] elif self.settings.os == "Windows": self.cpp_info.system_libs = ["psapi", "ws2_32"] if not self.options.shared: self.cpp_info.defines.append("EASY_PROFILER_STATIC") + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/easy_profiler/all/patches/0001-fix-cmake-bundle-install.patch b/recipes/easy_profiler/all/patches/0001-fix-cmake-bundle-install.patch new file mode 100644 index 0000000000000..8d955636585ac --- /dev/null +++ b/recipes/easy_profiler/all/patches/0001-fix-cmake-bundle-install.patch @@ -0,0 +1,10 @@ +--- a/easy_profiler_converter/CMakeLists.txt ++++ b/easy_profiler_converter/CMakeLists.txt +@@ -15,7 +15,6 @@ target_link_libraries(profiler_converter easy_profiler) + install( + TARGETS + profiler_converter +- RUNTIME + DESTINATION + bin + ) diff --git a/recipes/easy_profiler/all/test_package/CMakeLists.txt b/recipes/easy_profiler/all/test_package/CMakeLists.txt index 0b469543406df..cc877a386be85 100644 --- a/recipes/easy_profiler/all/test_package/CMakeLists.txt +++ b/recipes/easy_profiler/all/test_package/CMakeLists.txt @@ -2,8 +2,10 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(easy_profiler REQUIRED CONFIG) add_executable(${PROJECT_NAME} example.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} easy_profiler) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/easy_profiler/all/test_package/conanfile.py b/recipes/easy_profiler/all/test_package/conanfile.py index 5934fccac45b2..fe3069158de8a 100644 --- a/recipes/easy_profiler/all/test_package/conanfile.py +++ b/recipes/easy_profiler/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) diff --git a/recipes/easyexif/all/CMakeLists.txt b/recipes/easyexif/all/CMakeLists.txt index 22135247879f7..de50a2ead5152 100644 --- a/recipes/easyexif/all/CMakeLists.txt +++ b/recipes/easyexif/all/CMakeLists.txt @@ -4,21 +4,16 @@ project(easyexif) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD 11) -include(conanbuildinfo.cmake) -conan_basic_setup() - if(WIN32 AND BUILD_SHARED_LIBS) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() -set(SOURCE_SUBFOLDER "source_subfolder") - -add_library(easyexif ${SOURCE_SUBFOLDER}/exif.cpp) -target_include_directories(easyexif PUBLIC ${SOURCE_SUBFOLDER}/exif.h) +add_library(easyexif exif.cpp) +target_include_directories(easyexif PUBLIC exif.h) install(TARGETS easyexif RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -install(FILES ${SOURCE_SUBFOLDER}/exif.h DESTINATION include/easyexif) +install(FILES exif.h DESTINATION include/easyexif) diff --git a/recipes/easyexif/all/conanfile.py b/recipes/easyexif/all/conanfile.py index 6deb69e5aa23b..c2f91926a073b 100644 --- a/recipes/easyexif/all/conanfile.py +++ b/recipes/easyexif/all/conanfile.py @@ -1,5 +1,11 @@ import os -from conans import CMake, ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get + +required_conan_version = ">=1.53.0" + class EasyExifConan(ConanFile): name = "easyexif" @@ -15,44 +21,38 @@ class EasyExifConan(ConanFile): "fPIC": [True, False] } default_options = {"shared": False, "fPIC": True} - generators = "cmake" - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" def config_options(self): if self.settings.os == "Windows": - del self.options.fPIC + self.options.rm_safe("fPIC") def configure(self): if self.options.shared: - del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + self.options.rm_safe("fPIC") + + def validate(self): + if self.info.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) def package_info(self): self.cpp_info.libs = ["easyexif"] diff --git a/recipes/easyexif/all/test_v1_package/CMakeLists.txt b/recipes/easyexif/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a84ec58a29d01 --- /dev/null +++ b/recipes/easyexif/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(easyexif REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/example.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE easyexif::easyexif) diff --git a/recipes/easyexif/all/test_v1_package/conanfile.py b/recipes/easyexif/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a691174f8ed16 --- /dev/null +++ b/recipes/easyexif/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + diff --git a/recipes/easyloggingpp/all/CMakeLists.txt b/recipes/easyloggingpp/all/CMakeLists.txt new file mode 100644 index 0000000000000..f6fc5c33e69b0 --- /dev/null +++ b/recipes/easyloggingpp/all/CMakeLists.txt @@ -0,0 +1,67 @@ +cmake_minimum_required(VERSION 3.2) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() +option(enable_crash_log "Enable crash log handler" OFF) +option(enable_thread_safe "Enable thread safety for use in multithreaded env" OFF) +option(enable_debug_errors "Enable debug errors in case of configuration issues" OFF) +option(enable_default_logfile "Enable creation of default logfile" ON) +option(disable_logs "Disables all logs" OFF) +option(disable_debug_logs "Disables debug logs" OFF) +option(disable_info_logs "Disables info logs" OFF) +option(disable_warning_logs "Disables warning logs" OFF) +option(disable_error_logs "Disables error logs" OFF) +option(disable_fatal_logs "Disables fatal logs" OFF) +option(disable_verbose_logs "Disables verbose logs" OFF) +option(disable_trace_logs "Disables trace logs" OFF) + +if (enable_crash_log) + add_definitions(-DELPP_FEATURE_CRASH_LOG) +endif() + +if (enable_thread_safe) + add_definitions(-DELPP_THREAD_SAFE) +endif() + +if (enable_debug_errors) + add_definitions(-DELPP_DEBUG_ERRORS) +endif() + +if (NOT enable_default_logfile) + add_definitions(-DELPP_NO_DEFAULT_LOG_FILE) +endif() + +if (disable_logs) + add_definitions(-DELPP_DISABLE_LOGS) +endif() + +if (disable_debug_logs) + add_definitions(-DELPP_DISABLE_DEBUG_LOGS) +endif() + +if (disable_info_logs) + add_definitions(-DELPP_DISABLE_INFO_LOGS) +endif() + +if (disable_warning_logs) + add_definitions(-DELPP_DISABLE_WARNING_LOGS) +endif() + +if (disable_error_logs) + add_definitions(-DELPP_DISABLE_ERROR_LOGS) +endif() + +if (disable_fatal_logs) + add_definitions(-DELPP_DISABLE_FATAL_LOGS) +endif() + +if (disable_verbose_logs) + add_definitions(-DELPP_DISABLE_VERBOSE_LOGS) +endif() + +if (disable_trace_logs) + add_definitions(-DELPP_DISABLE_TRACE_LOGS) +endif() + +add_subdirectory("source_subfolder") diff --git a/recipes/easyloggingpp/all/conandata.yml b/recipes/easyloggingpp/all/conandata.yml new file mode 100644 index 0000000000000..5649e78f158cc --- /dev/null +++ b/recipes/easyloggingpp/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "9.97.0": + url: "https://github.com/amrayn/easyloggingpp/archive/v9.97.0.tar.gz" + sha256: "9110638e21ef02428254af8688bf9e766483db8cc2624144aa3c59006907ce22" diff --git a/recipes/easyloggingpp/all/conanfile.py b/recipes/easyloggingpp/all/conanfile.py new file mode 100644 index 0000000000000..b5d1f9b44e060 --- /dev/null +++ b/recipes/easyloggingpp/all/conanfile.py @@ -0,0 +1,121 @@ +import os +from conans import CMake +from conan.tools import files +from conan import ConanFile + + +required_conan_version = ">=1.33.0" + +class EasyloggingppConan(ConanFile): + name = "easyloggingpp" + license = "The MIT License (MIT)" + homepage = "https://github.com/amrayn/easyloggingpp" + url = "https://github.com/conan-io/conan-center-index" + description = "Single header C++ logging library." + topics = ("logging", "stacktrace", "efficient-logging") + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + exports_sources = "CMakeLists.txt", + options = { + "enable_crash_log": [True, False], + "enable_thread_safe": [True, False], + "enable_debug_errors": [True, False], + "enable_default_logfile": [True, False], + "disable_logs": [True, False], + "disable_debug_logs": [True, False], + "disable_info_logs": [True, False], + "disable_warning_logs": [True, False], + "disable_error_logs": [True, False], + "disable_fatal_logs": [True, False], + "disable_verbose_logs": [True, False], + "disable_trace_logs": [True, False] + } + default_options = { + "enable_crash_log": False, + "enable_thread_safe": False, + "enable_debug_errors": False, + "enable_default_logfile": True, + "disable_logs": False, + "disable_debug_logs": False, + "disable_info_logs": False, + "disable_warning_logs": False, + "disable_error_logs": False, + "disable_fatal_logs": False, + "disable_verbose_logs": False, + "disable_trace_logs": False + } + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def _configure_cmake(self): + if self._cmake is not None: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["build_static_lib"] = True + self._cmake.definitions["enable_crash_log"] = self.options.enable_crash_log + self._cmake.definitions["enable_thread_safe"] = self.options.enable_thread_safe + self._cmake.definitions["enable_debug_errors"] = self.options.enable_debug_errors + self._cmake.definitions["enable_default_logfile"] = self.options.enable_default_logfile + self._cmake.definitions["disable_logs"] = self.options.disable_logs + self._cmake.definitions["disable_debug_logs"] = self.options.disable_debug_logs + self._cmake.definitions["disable_info_logs"] = self.options.disable_info_logs + self._cmake.definitions["disable_warning_logs"] = self.options.disable_warning_logs + self._cmake.definitions["disable_error_logs"] = self.options.disable_error_logs + self._cmake.definitions["disable_fatal_logs"] = self.options.disable_fatal_logs + self._cmake.definitions["disable_verbose_logs"] = self.options.disable_verbose_logs + self._cmake.definitions["disable_trace_logs"] = self.options.disable_trace_logs + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + files.rmdir(self, os.path.join(self.package_folder, "share")) + self.copy(pattern="LICENSE", + dst="licenses", + src=self._source_subfolder) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "easyloggingpp" + self.cpp_info.names["cmake_find_package_multi"] = "easyloggingpp" + self.cpp_info.libs = ["easyloggingpp"] + if self.options.enable_crash_log: + self.cpp_info.defines.append("ELPP_FEATURE_CRASH_LOG") + if self.options.enable_thread_safe: + self.cpp_info.defines.append("ELPP_THREAD_SAFE") + if self.options.enable_debug_errors: + self.cpp_info.defines.append("ELPP_DEBUG_ERRORS") + if self.options.enable_default_logfile: + self.cpp_info.defines.append("ELPP_NO_DEFAULT_LOG_FILE") + if self.options.disable_logs: + self.cpp_info.defines.append("ELPP_DISABLE_LOGS") + if self.options.disable_debug_logs: + self.cpp_info.defines.append("ELPP_DISABLE_DEBUG_LOGS") + if self.options.disable_info_logs: + self.cpp_info.defines.append("ELPP_DISABLE_INFO_LOGS") + if self.options.disable_warning_logs: + self.cpp_info.defines.append("ELPP_DISABLE_WARNING_LOGS") + if self.options.disable_error_logs: + self.cpp_info.defines.append("ELPP_DISABLE_ERROR_LOGS") + if self.options.disable_fatal_logs: + self.cpp_info.defines.append("ELPP_DISABLE_FATAL_LOGS") + if self.options.disable_verbose_logs: + self.cpp_info.defines.append("ELPP_DISABLE_VERBOSE_LOGS") + if self.options.disable_trace_logs: + self.cpp_info.defines.append("ELPP_DISABLE_TRACE_LOGS") + diff --git a/recipes/easyloggingpp/all/test_package/CMakeLists.txt b/recipes/easyloggingpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e515e14d7e6ad --- /dev/null +++ b/recipes/easyloggingpp/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(easyloggingpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE easyloggingpp::easyloggingpp) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/easyloggingpp/all/test_package/conanfile.py b/recipes/easyloggingpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/easyloggingpp/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/easyloggingpp/all/test_package/test_package.cpp b/recipes/easyloggingpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..9f1fc4b8dad34 --- /dev/null +++ b/recipes/easyloggingpp/all/test_package/test_package.cpp @@ -0,0 +1,20 @@ +#include "easylogging++.h" +INITIALIZE_EASYLOGGINGPP + +#ifdef ELPP_FEATURE_CRASH_LOG +void myCrashHandler(int sig) { + LOG(ERROR) << "Woops! Crashed!"; + el::Helpers::logCrashReason(sig, true); + // FOLLOWING LINE IS ABSOLUTELY NEEDED AT THE END IN ORDER TO ABORT APPLICATION + el::Helpers::crashAbort(sig); +} +#endif + +int main() { + LOG(INFO) << "My first info log using default logger"; + #ifdef ELPP_FEATURE_CRASH_LOG + LOG(INFO) << "Installed crash handler"; + el::Helpers::setCrashHandler(myCrashHandler); + #endif + return 0; +} diff --git a/recipes/easyloggingpp/config.yml b/recipes/easyloggingpp/config.yml new file mode 100644 index 0000000000000..8f835ce7bab04 --- /dev/null +++ b/recipes/easyloggingpp/config.yml @@ -0,0 +1,3 @@ +versions: + "9.97.0": + folder: all diff --git a/recipes/ecos/all/conandata.yml b/recipes/ecos/all/conandata.yml new file mode 100644 index 0000000000000..3034805590c75 --- /dev/null +++ b/recipes/ecos/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "2.0.8": + url: "https://github.com/embotech/ecos/archive/refs/tags/v2.0.8.tar.gz" + sha256: "d905d16599efd927a75b29852c3476ff1ffd0b97ab27d5b8ad63bb4ff2ad8130" +patches: + "2.0.8": + - patch_file: "patches/0001-fix-cmake.patch" + - patch_file: "patches/0002-missing-include.patch" diff --git a/recipes/ecos/all/conanfile.py b/recipes/ecos/all/conanfile.py new file mode 100644 index 0000000000000..6947c543e0352 --- /dev/null +++ b/recipes/ecos/all/conanfile.py @@ -0,0 +1,88 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +import os + +required_conan_version = ">=1.52.0" + + +class EcosConan(ConanFile): + name = "ecos" + description = "ECOS is a numerical software for solving convex second-order cone programs (SOCPs)." + license = "GPL-3.0-or-later" + topics = ("ecos", "conic-solver") + homepage = "https://github.com/embotech/ecos" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "use_long": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "use_long": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + # TODO: unvendor suitesparse + pass + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["USE_LONG"] = self.options.use_long + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "ecos") + self.cpp_info.set_property("cmake_target_name", "ecos::ecos") + self.cpp_info.libs = ["ecos"] + self.cpp_info.defines.append("CTRLC=1") + if self.options.use_long: + self.cpp_info.defines.extend(["LDL_LONG", "DLONG"]) + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/ecos/all/patches/0001-fix-cmake.patch b/recipes/ecos/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..896d894e5eb55 --- /dev/null +++ b/recipes/ecos/all/patches/0001-fix-cmake.patch @@ -0,0 +1,15 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -77,11 +77,9 @@ set(ecos_sources + ) + + # ECOS library +-add_library(ecos SHARED ${ecos_headers} ${ecos_sources}) ++add_library(ecos ${ecos_headers} ${ecos_sources}) + + # Set compiler options and definitions +-target_compile_options(ecos PRIVATE "$<$:${DEBUG_OPTIONS}>") +-target_compile_options(ecos PRIVATE "$<$:${RELEASE_OPTIONS}>") + target_compile_definitions(ecos PUBLIC CTRLC=1) + if(USE_LONG) + target_compile_definitions(ecos PUBLIC LDL_LONG DLONG) diff --git a/recipes/ecos/all/patches/0002-missing-include.patch b/recipes/ecos/all/patches/0002-missing-include.patch new file mode 100644 index 0000000000000..e58ddb2eb47cf --- /dev/null +++ b/recipes/ecos/all/patches/0002-missing-include.patch @@ -0,0 +1,10 @@ +--- a/ecos_bb/ecos_bb.c ++++ b/ecos_bb/ecos_bb.c +@@ -31,6 +31,7 @@ + #include "math.h" + #include "equil.h" + #include "spla.h" ++#include + + #define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) + diff --git a/recipes/ecos/all/test_package/CMakeLists.txt b/recipes/ecos/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..006729666b6b5 --- /dev/null +++ b/recipes/ecos/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(ecos REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE ecos::ecos) diff --git a/recipes/ecos/all/test_package/conanfile.py b/recipes/ecos/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/ecos/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/ecos/all/test_package/test_package.c b/recipes/ecos/all/test_package/test_package.c new file mode 100644 index 0000000000000..e2355977706cc --- /dev/null +++ b/recipes/ecos/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include + +#include + +int main(void) { + printf("ECOS version %s\n", ECOS_ver()); + return 0; +} diff --git a/recipes/ecos/all/test_v1_package/CMakeLists.txt b/recipes/ecos/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..465202cc7e581 --- /dev/null +++ b/recipes/ecos/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ecos REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE ecos::ecos) diff --git a/recipes/ecos/all/test_v1_package/conanfile.py b/recipes/ecos/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/ecos/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ecos/config.yml b/recipes/ecos/config.yml new file mode 100644 index 0000000000000..ebde7c07fe491 --- /dev/null +++ b/recipes/ecos/config.yml @@ -0,0 +1,3 @@ +versions: + "2.0.8": + folder: all diff --git a/recipes/editline/all/conanfile.py b/recipes/editline/all/conanfile.py index 662be782e2858..2f03c73a34aa9 100644 --- a/recipes/editline/all/conanfile.py +++ b/recipes/editline/all/conanfile.py @@ -1,8 +1,9 @@ from conans import ConanFile, tools, AutoToolsBuildEnvironment from conans.errors import ConanInvalidConfiguration -import glob import os +required_conan_version = ">=1.33.0" + class EditlineConan(ConanFile): name = "editline" @@ -29,15 +30,6 @@ class EditlineConan(ConanFile): def _source_subfolder(self): return "source_subfolder" - def requirements(self): - if self.options.terminal_db == "termcap": - self.requires("termcap/1.3.1") - elif self.options.terminal_db == "ncurses": - self.requires("ncurses/6.2") - elif self.options.terminal_db == "tinfo": - # TODO - Add tinfo when available - raise ConanInvalidConfiguration("tinfo is not (yet) available on CCI") - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -47,13 +39,23 @@ def configure(self): del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + + def requirements(self): + if self.options.terminal_db == "termcap": + self.requires("termcap/1.3.1") + elif self.options.terminal_db == "ncurses": + self.requires("ncurses/6.2") + + def validate(self): if self.settings.os == "Windows": raise ConanInvalidConfiguration("Windows is not supported by libedit (missing termios.h)") + if self.options.terminal_db == "tinfo": + # TODO - Add tinfo when available + raise ConanInvalidConfiguration("tinfo is not (yet) available on CCI") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - archive_name = glob.glob("{}-*-{}".format("libedit", self.version))[0] - os.rename(archive_name, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_autotools(self): if self._autotools: @@ -62,7 +64,7 @@ def _configure_autotools(self): self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) self._autotools.libs = [] - configure_args = [] + configure_args = ["--disable-examples"] if self.options.shared: configure_args.extend(["--disable-static", "--enable-shared"]) else: diff --git a/recipes/edlib/all/CMakeLists.txt b/recipes/edlib/all/CMakeLists.txt deleted file mode 100644 index 8dd13164d6810..0000000000000 --- a/recipes/edlib/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/edlib/all/conandata.yml b/recipes/edlib/all/conandata.yml index 05f6fa9eaca7a..88db7a2db84b8 100644 --- a/recipes/edlib/all/conandata.yml +++ b/recipes/edlib/all/conandata.yml @@ -1,8 +1,10 @@ sources: + "1.2.7": + url: "https://github.com/Martinsos/edlib/archive/v1.2.7.tar.gz" + sha256: "8767bc1b04a1a67282d57662e5702c4908996e96b1753b5520921ff189974621" "1.2.6": url: "https://github.com/Martinsos/edlib/archive/v1.2.6.tar.gz" sha256: "0436f14b0339dabd2aab7faf3779ac1b4bbbdc46246c1bff49be997fe4b4e2c7" patches: "1.2.6": - patch_file: "patches/cmake-install-and-export-symbols.patch" - base_path: "source_subfolder" diff --git a/recipes/edlib/all/conanfile.py b/recipes/edlib/all/conanfile.py index bcda1f1df31a8..a6092b1452f30 100644 --- a/recipes/edlib/all/conanfile.py +++ b/recipes/edlib/all/conanfile.py @@ -1,26 +1,37 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version +from conans import tools as tools_legacy import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" + class EdlibConan(ConanFile): name = "edlib" description = "Lightweight, super fast C/C++ (& Python) library for " \ "sequence alignment using edit (Levenshtein) distance." + topics = ("edlib", "sequence-alignment", "edit-distance", "levehnstein-distance", "alignment-path") license = "MIT" - topics = ("conan", "edlib", "sequence-alignment", "edit-distance", "levehnstein-distance", "alignment-path") homepage = "https://github.com/Martinsos/edlib" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -29,39 +40,71 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "15", + "gcc": "5", + "clang": "5", + "apple-clang": "5.1", + } + + def validate(self): + if Version(self.version) < "1.2.7": + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + return + + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 14) + + minimum_version = self._minimum_compilers_version.get(str(self.info.settings.compiler), False) + if not minimum_version: + self.output.warn("{}/{} requires C++14. Your compiler is unknown. Assuming it supports C++14.".format(self.name, self.version)) + elif Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration("{}/{} requires C++14, which your compiler does not support.".format(self.name, self.version)) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.definitions["EDLIB_BUILD_EXAMPLES"] = False - self._cmake.definitions["EDLIB_BUILD_UTILITIES"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.variables["EDLIB_BUILD_EXAMPLES"] = False + tc.variables["EDLIB_BUILD_UTILITIES"] = False + if Version(self.version) >= "1.2.7": + tc.variables["EDLIB_ENABLE_INSTALL"] = True + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0063"] = "NEW" + # Needed because upstream CMakeLists overrides BUILD_SHARED_LIBS as a cache variable + tc.cache_variables["BUILD_SHARED_LIBS"] = "ON" if self.options.shared else "OFF" + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.names["pkg_config"] = "edlib-{}".format(tools.Version(self.version).major) + self.cpp_info.set_property("cmake_file_name", "edlib") + self.cpp_info.set_property("cmake_target_name", "edlib::edlib") + self.cpp_info.set_property("pkg_config_name", "edlib-{}".format(Version(self.version).major)) self.cpp_info.libs = ["edlib"] if self.options.shared: self.cpp_info.defines = ["EDLIB_SHARED"] - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.system_libs = [tools.stdcpp_library(self)] + if not self.options.shared: + stdcpp_library = tools_legacy.stdcpp_library(self) + if stdcpp_library: + self.cpp_info.system_libs.append(stdcpp_library) diff --git a/recipes/edlib/all/test_package/CMakeLists.txt b/recipes/edlib/all/test_package/CMakeLists.txt index 1cee608b1d426..502714cc3a9ba 100644 --- a/recipes/edlib/all/test_package/CMakeLists.txt +++ b/recipes/edlib/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C) find_package(edlib REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} edlib::edlib) +target_link_libraries(${PROJECT_NAME} PRIVATE edlib::edlib) diff --git a/recipes/edlib/all/test_package/conanfile.py b/recipes/edlib/all/test_package/conanfile.py index c6580760bfee2..3a8c6c5442b33 100644 --- a/recipes/edlib/all/test_package/conanfile.py +++ b/recipes/edlib/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/edlib/all/test_v1_package/CMakeLists.txt b/recipes/edlib/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..1e3a08ac13187 --- /dev/null +++ b/recipes/edlib/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(edlib REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE edlib::edlib) diff --git a/recipes/edlib/all/test_v1_package/conanfile.py b/recipes/edlib/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/edlib/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/edlib/config.yml b/recipes/edlib/config.yml index 3696b346a8679..10801ad040b22 100644 --- a/recipes/edlib/config.yml +++ b/recipes/edlib/config.yml @@ -1,3 +1,5 @@ versions: + "1.2.7": + folder: all "1.2.6": folder: all diff --git a/recipes/edyn/all/conandata.yml b/recipes/edyn/all/conandata.yml new file mode 100644 index 0000000000000..4f8e161949ad2 --- /dev/null +++ b/recipes/edyn/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.2.1": + url: "https://github.com/xissburg/edyn/archive/refs/tags/v1.2.1.tar.gz" + sha256: "d088dac1bebed65cd342c76f27661fbb557b95f959a67137f4df1000d9698b13" diff --git a/recipes/edyn/all/conanfile.py b/recipes/edyn/all/conanfile.py new file mode 100644 index 0000000000000..9e0c289bac789 --- /dev/null +++ b/recipes/edyn/all/conanfile.py @@ -0,0 +1,112 @@ +from conan import ConanFile +from conan.tools.files import rmdir, rm, copy, get, collect_libs +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.layout import cmake_layout +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain +import os + +required_conan_version = ">=1.50.0" + +class EdynConan(ConanFile): + name = "edyn" + description = "Edyn is a real-time physics engine organized as an ECS" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/xissburg/edyn" + topics = ("physics", "game-development", "ecs") + settings = "os", "arch", "compiler", "build_type" + + options = { + "shared": [True, False], + "fPIC": [True, False], + "floating_type": ["float", "double"], + } + default_options = { + "shared": False, + "fPIC": True, + "floating_type": "float", + } + + @property + def _compiler_required(self): + return { + "gcc": "9.3", # GCC 9.3 started supporting attributes in constructor arguments + "clang": "8", + "apple-clang": "10", + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("entt/3.10.1") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 17) + check_min_vs(self, 192) + if not is_msvc(self): + try: + minimum_required_compiler_version = self._compiler_required[str(self.settings.compiler)] + if Version(self.settings.compiler.version) < minimum_required_compiler_version: + raise ConanInvalidConfiguration("This package requires C++17 support. The current compiler does not support it.") + except KeyError: + self.output.warn("This recipe has no support for the current compiler. Please consider adding it.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["EDYN_INSTALL"] = True + tc.variables["EDYN_BUILD_EXAMPLES"] = False + if self.options.floating_type == "double": + tc.variables["EDYN_CONFIG_DOUBLE"] = True + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, pattern="*.pdb", folder=self.package_folder, recursive=True) + + def package_info(self): + self.cpp_info.libs = collect_libs(self) + + self.cpp_info.set_property("cmake_file_name", "Edyn") + self.cpp_info.set_property("cmake_target_name", "Edyn::Edyn") + self.cpp_info.set_property("pkg_config_name", "Edyn") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs += ["m", "pthread"] + elif self.settings.os == "Windows": + self.cpp_info.system_libs = ["winmm"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "Edyn" + self.cpp_info.filenames["cmake_find_package_multi"] = "Edyn" + self.cpp_info.names["cmake_find_package"] = "Edyn" + self.cpp_info.names["cmake_find_package_multi"] = "Edyn" diff --git a/recipes/edyn/all/test_package/CMakeLists.txt b/recipes/edyn/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3298fd461a4e3 --- /dev/null +++ b/recipes/edyn/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package LANGUAGES CXX) + +find_package(Edyn REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) +target_link_libraries(${PROJECT_NAME} Edyn::Edyn) diff --git a/recipes/edyn/all/test_package/conanfile.py b/recipes/edyn/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a52c6b7a0d922 --- /dev/null +++ b/recipes/edyn/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.layout import cmake_layout +from conan.tools.cmake import CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/edyn/all/test_package/test_package.cpp b/recipes/edyn/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..ec6be85f6dfe0 --- /dev/null +++ b/recipes/edyn/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include +#include + +int main() +{ + edyn::vector3 const v0{ 0, 1, 2 }; + edyn::vector3 const v1{ -2, -1, -0 }; + + std::printf("%f\n", edyn::dot(v0, v1)); + assert(edyn::dot(v0, v1) == -1); +} diff --git a/recipes/edyn/all/test_v1_package/CMakeLists.txt b/recipes/edyn/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..26c41f72889f8 --- /dev/null +++ b/recipes/edyn/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Edyn REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) +target_link_libraries(${PROJECT_NAME} Edyn::Edyn) diff --git a/recipes/edyn/all/test_v1_package/conanfile.py b/recipes/edyn/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/edyn/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/edyn/all/test_v1_package/test_package.cpp b/recipes/edyn/all/test_v1_package/test_package.cpp new file mode 100644 index 0000000000000..ec6be85f6dfe0 --- /dev/null +++ b/recipes/edyn/all/test_v1_package/test_package.cpp @@ -0,0 +1,11 @@ +#include +#include + +int main() +{ + edyn::vector3 const v0{ 0, 1, 2 }; + edyn::vector3 const v1{ -2, -1, -0 }; + + std::printf("%f\n", edyn::dot(v0, v1)); + assert(edyn::dot(v0, v1) == -1); +} diff --git a/recipes/edyn/config.yml b/recipes/edyn/config.yml new file mode 100644 index 0000000000000..b230418434b61 --- /dev/null +++ b/recipes/edyn/config.yml @@ -0,0 +1,3 @@ +versions: + "1.2.1": + folder: all diff --git a/recipes/effcee/all/CMakeLists.txt b/recipes/effcee/all/CMakeLists.txt new file mode 100644 index 0000000000000..a53ad7e107d11 --- /dev/null +++ b/recipes/effcee/all/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.4) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +add_subdirectory(source_subfolder/) diff --git a/recipes/effcee/all/conandata.yml b/recipes/effcee/all/conandata.yml new file mode 100644 index 0000000000000..688296fd06354 --- /dev/null +++ b/recipes/effcee/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "2019.1": + sha256: 332586221ef53a615cc6595cc54643610b1f9f77acd2862860a1eda6f03de8b9 + url: https://github.com/google/effcee/archive/refs/tags/v2019.1.zip +patches: + "2019.1": + - patch_file: "patches/0001-fix-cmake.patch" + base_path: "source_subfolder" diff --git a/recipes/effcee/all/conanfile.py b/recipes/effcee/all/conanfile.py new file mode 100644 index 0000000000000..6f5840a5a392b --- /dev/null +++ b/recipes/effcee/all/conanfile.py @@ -0,0 +1,88 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + + +class EffceeConan(ConanFile): + name = "effcee" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/google/effcee/" + description = "Effcee is a C++ library for stateful pattern matching" \ + " of strings, inspired by LLVM's FileCheck" + topics = ("conan", "effcee", "strings", "algorithm", "matcher") + license = "Apache-2.0" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("re2/20210601") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "11") + if self.settings.compiler == "Visual Studio" and \ + self.options.shared and "MT" in self.settings.compiler.runtime: + raise ConanInvalidConfiguration("Visual Studio build for shared" + " library with MT runtime is not" + " supported") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["EFFCEE_BUILD_TESTING"] = False + self._cmake.definitions["EFFCEE_BUILD_SAMPLES"] = False + if self.settings.os == "Windows": + if self.settings.compiler == "Visual Studio": + self._cmake.definitions["EFFCEE_ENABLE_SHARED_CRT"] = \ + "MD" in self.settings.compiler.runtime + else: + # Do not force linkage to static libgcc and libstdc++ for MinGW + self._cmake.definitions["EFFCEE_ENABLE_SHARED_CRT"] = True + + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", + src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["effcee"] diff --git a/recipes/effcee/all/patches/0001-fix-cmake.patch b/recipes/effcee/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..ad916f3755d34 --- /dev/null +++ b/recipes/effcee/all/patches/0001-fix-cmake.patch @@ -0,0 +1,35 @@ +Use external re2 +Fix installation of dll + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -33,7 +33,7 @@ include(cmake/setup_build.cmake) + include(cmake/utils.cmake) + include(GNUInstallDirs) + +-add_subdirectory(third_party) ++find_package(re2 REQUIRED CONFIG) + add_subdirectory(effcee) + add_subdirectory(fuzzer) + +--- a/effcee/CMakeLists.txt ++++ b/effcee/CMakeLists.txt +@@ -4,8 +4,8 @@ add_library(effcee + effcee_default_compile_options(effcee) + # We need to expose RE2's StringPiece. + target_include_directories(effcee +- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/.. ${EFFCEE_RE2_DIR}) +-target_link_libraries(effcee PUBLIC re2 ${CMAKE_THREADS_LIB_INIT}) ++ PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..) ++target_link_libraries(effcee PUBLIC re2::re2 ${CMAKE_THREADS_LIB_INIT}) + + # TODO(dneto): Avoid installing gtest and gtest_main. ?! + install( +@@ -14,6 +14,7 @@ install( + DESTINATION + include/effcee) + install(TARGETS effcee ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + diff --git a/recipes/effcee/all/test_package/CMakeLists.txt b/recipes/effcee/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f42f881c6aad0 --- /dev/null +++ b/recipes/effcee/all/test_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(effcee REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) + +target_link_libraries(${PROJECT_NAME} effcee::effcee) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/effcee/all/test_package/conanfile.py b/recipes/effcee/all/test_package/conanfile.py new file mode 100644 index 0000000000000..12dd810a6ab3b --- /dev/null +++ b/recipes/effcee/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/effcee/all/test_package/test_package.cpp b/recipes/effcee/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..74d98eec5216e --- /dev/null +++ b/recipes/effcee/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include "effcee/effcee.h" + +int main(void) { + auto match = effcee::Match("foo bar qux", "foo", + effcee::Options().SetChecksName("checks")); + return 0; +} diff --git a/recipes/effcee/config.yml b/recipes/effcee/config.yml new file mode 100644 index 0000000000000..97d49d4ebd089 --- /dev/null +++ b/recipes/effcee/config.yml @@ -0,0 +1,3 @@ +versions: + "2019.1": + folder: all diff --git a/recipes/effolkronium-random/all/conandata.yml b/recipes/effolkronium-random/all/conandata.yml index 5ff27ac71e96d..caf25d2461065 100644 --- a/recipes/effolkronium-random/all/conandata.yml +++ b/recipes/effolkronium-random/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.4.1": + url: "https://github.com/effolkronium/random/archive/v1.4.1.tar.gz" + sha256: "ec6beb67496ad2ce722d311d3fa5efb7e847dac5fd1c16b8920b51562fe20f53" + "1.4.0": + url: "https://github.com/effolkronium/random/archive/v1.4.0.tar.gz" + sha256: "228baa24736a409b37bbe31df40ef7537f04bfbe3921dfed3d806d4eef112632" "1.3.1": url: "https://github.com/effolkronium/random/archive/v1.3.1.tar.gz" sha256: "556CD0E050D533B3C787958088C8418A337760A16230C6543FDBA6B6059A5BC0" diff --git a/recipes/effolkronium-random/config.yml b/recipes/effolkronium-random/config.yml index 71bf3f0e1bada..c0455a0dac1c9 100644 --- a/recipes/effolkronium-random/config.yml +++ b/recipes/effolkronium-random/config.yml @@ -1,3 +1,7 @@ versions: + "1.4.1": + folder: "all" + "1.4.0": + folder: "all" "1.3.1": folder: "all" diff --git a/recipes/egl-headers/all/conandata.yml b/recipes/egl-headers/all/conandata.yml new file mode 100644 index 0000000000000..9599f3d0a9488 --- /dev/null +++ b/recipes/egl-headers/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20220525": + url: "https://github.com/KhronosGroup/EGL-Registry/archive/84f25dd4c04a01ea48480f7296ba9d64d435fa87.tar.gz" + sha256: "6a4cbc7cf8b9057250c5c3982939b2bf46b1c2bfe0795e1445b8f7f39bd33988" diff --git a/recipes/egl-headers/all/conanfile.py b/recipes/egl-headers/all/conanfile.py new file mode 100644 index 0000000000000..5f6e1786a60cb --- /dev/null +++ b/recipes/egl-headers/all/conanfile.py @@ -0,0 +1,46 @@ +from conan import ConanFile +from conan.tools.files import copy, get, load, save +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class EglHeadersConan(ConanFile): + name = "egl-headers" + description = "EGL Header files." + license = "Apache-2.0" + topics = ("egl-headers", "egl") + homepage = "https://github.com/KhronosGroup/EGL-Registry" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("khrplatform/cci.20200529") + + def package_id(self): + self.info.clear() + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + license_data = load(self, os.path.join(self.source_folder, "api", "EGL", "egl.h")) + begin = license_data.find("/*") + len("/*") + end = license_data.find("*/") + license_data = license_data[begin:end] + license_data = license_data.replace("**", "") + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), license_data) + + copy(self, "*", src=os.path.join(self.source_folder, "api", "EGL"), dst=os.path.join(self.package_folder, "include", "EGL")) + + def package_info(self): + pass diff --git a/recipes/egl-headers/all/test_package/CMakeLists.txt b/recipes/egl-headers/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8c6a625d847ec --- /dev/null +++ b/recipes/egl-headers/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(egl-headers REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} egl-headers::egl-headers) diff --git a/recipes/egl-headers/all/test_package/conanfile.py b/recipes/egl-headers/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/egl-headers/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/egl-headers/all/test_package/test_package.c b/recipes/egl-headers/all/test_package/test_package.c new file mode 100644 index 0000000000000..966cb253f7d85 --- /dev/null +++ b/recipes/egl-headers/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include "EGL/egl.h" +#include "EGL/eglext.h" +#include +#include + +int main() { + EGLBoolean value = EGL_TRUE; + printf("EGL_TRUE: %d\n", value); + return EXIT_SUCCESS; +} diff --git a/recipes/egl-headers/all/test_v1_package/CMakeLists.txt b/recipes/egl-headers/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..de3b75d9538de --- /dev/null +++ b/recipes/egl-headers/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/egl-headers/all/test_v1_package/conanfile.py b/recipes/egl-headers/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..90f7a062ba0d0 --- /dev/null +++ b/recipes/egl-headers/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conans import CMake +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/egl-headers/config.yml b/recipes/egl-headers/config.yml new file mode 100644 index 0000000000000..cc6aac6874544 --- /dev/null +++ b/recipes/egl-headers/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220525": + folder: all diff --git a/recipes/egl/system/conanfile.py b/recipes/egl/system/conanfile.py index 6911d5abc94a1..2139b499f3f52 100644 --- a/recipes/egl/system/conanfile.py +++ b/recipes/egl/system/conanfile.py @@ -1,5 +1,9 @@ -from conans import ConanFile, tools -from conans.errors import ConanException, ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanException, ConanInvalidConfiguration +from conan.tools.system import package_manager +from conans import tools + +required_conan_version = ">=1.47" class SysConfigEGLConan(ConanFile): @@ -10,12 +14,12 @@ class SysConfigEGLConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.khronos.org/egl" license = "MIT" - settings = "os" + settings = "os", "arch", "compiler", "build_type" def configure(self): if self.settings.os not in ["Linux", "FreeBSD"]: raise ConanInvalidConfiguration("This recipes supports only Linux and FreeBSD") - + def package_id(self): self.info.header_only() @@ -40,30 +44,29 @@ def _fill_cppinfo_from_pkgconfig(self, name): self.cpp_info.cxxflags.extend(cflags) def system_requirements(self): - packages = [] - if tools.os_info.is_linux and self.settings.os == "Linux": - if tools.os_info.with_yum: - packages = ["mesa-libEGL-devel"] - elif tools.os_info.with_apt: - ubuntu_20_or_later = tools.os_info.linux_distro == "ubuntu" and tools.os_info.os_version >= "20" - debian_11_or_later = tools.os_info.linux_distro == "debian" and tools.os_info.os_version >= "11" - pop_os_20_or_later = tools.os_info.linux_distro == "pop" and tools.os_info.os_version >= "20" - if ubuntu_20_or_later or debian_11_or_later or pop_os_20_or_later: - packages = ["libegl-dev"] - else: - packages = ["libegl1-mesa-dev"] - elif tools.os_info.with_pacman: - packages = ["libglvnd"] - elif tools.os_info.with_zypper: - packages = ["Mesa-libEGL-devel"] - else: - self.output.warn("Don't know how to install EGL for your distro.") - if tools.os_info.is_freebsd and self.settings.os == "FreeBSD": - packages = ["mesa-libs"] - if packages: - package_tool = tools.SystemPackageTool(conanfile=self, default_mode='verify') - for p in packages: - package_tool.install(update=True, packages=p) + dnf = package_manager.Dnf(self) + dnf.install(["mesa-libEGL-devel"], update=True, check=True) + + yum = package_manager.Yum(self) + yum.install(["mesa-libEGL-devel"], update=True, check=True) + + apt = package_manager.Apt(self) + ubuntu_20_or_later = tools.os_info.linux_distro == "ubuntu" and tools.os_info.os_version >= "20" + debian_11_or_later = tools.os_info.linux_distro == "debian" and tools.os_info.os_version >= "11" + pop_os_20_or_later = tools.os_info.linux_distro == "pop" and tools.os_info.os_version >= "20" + if ubuntu_20_or_later or debian_11_or_later or pop_os_20_or_later: + apt.install(["libegl-dev"], update=True, check=True) + else: + apt.install(["libegl1-mesa-dev"], update=True, check=True) + + pacman = package_manager.PacMan(self) + pacman.install(["libglvnd"], update=True, check=True) + + zypper = package_manager.Zypper(self) + zypper.install(["Mesa-libEGL-devel"], update=True, check=True) + + pkg = package_manager.Pkg(self) + pkg.install(["libglvnd"], update=True, check=True) def package_info(self): # TODO: Workaround for #2311 until a better solution can be found diff --git a/recipes/eigen/all/conandata.yml b/recipes/eigen/all/conandata.yml index 2055fabe560cb..6e757c6f87da5 100644 --- a/recipes/eigen/all/conandata.yml +++ b/recipes/eigen/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.4.0": + url: "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.bz2" + sha256: "b4c198460eba6f28d34894e3a5710998818515104d6e74e5cc331ce31e46e626" "3.3.9": url: "https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.bz2" sha256: "0fa5cafe78f66d2b501b43016858070d52ba47bd9b1016b0165a7b8e04675677" @@ -9,6 +12,16 @@ sources: url: "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.bz2" sha256: "685adf14bd8e9c015b78097c1dc22f2f01343756f196acdc76a678e1ae352e11" patches: + "3.3.9": + - patch_file: "patches/0002-cmake-minimum-required.patch" + patch_description: "CMake: Move cmake_minimum_required() before project()" + patch_type: "conan" "3.3.8": - patch_file: "patches/0001-assert-exception-upstream-issue-2011.patch" - base_path: "source_subfolder" + - patch_file: "patches/0002-cmake-minimum-required.patch" + patch_description: "CMake: Move cmake_minimum_required() before project()" + patch_type: "conan" + "3.3.7": + - patch_file: "patches/0002-cmake-minimum-required.patch" + patch_description: "CMake: Move cmake_minimum_required() before project()" + patch_type: "conan" diff --git a/recipes/eigen/all/conanfile.py b/recipes/eigen/all/conanfile.py index f4990984fa933..e988fa6d4d9e5 100644 --- a/recipes/eigen/all/conanfile.py +++ b/recipes/eigen/all/conanfile.py @@ -1,52 +1,80 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain +from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, rmdir import os -from conans import ConanFile, tools, CMake + +required_conan_version = ">=1.52.0" class EigenConan(ConanFile): name = "eigen" url = "https://github.com/conan-io/conan-center-index" homepage = "http://eigen.tuxfamily.org" - description = "Eigen is a C++ template library for linear algebra: matrices, vectors, \ - numerical solvers, and related algorithms." - license = ("MPL-2.0", "LGPL-3.0-or-later") - topics = ("eigen", "algebra", "linear-algebra", "vector", "numerical") - settings = "os", "compiler", "build_type", "arch" - options = {"MPL2_only": [True, False]} - default_options = {"MPL2_only": False} - exports_sources = ["patches/*"] - no_copy_source = True - - @property - def _source_subfolder(self): - return "source_subfolder" + description = "Eigen is a C++ template library for linear algebra: matrices, vectors," \ + " numerical solvers, and related algorithms." + topics = ("algebra", "linear-algebra", "matrix", "vector", "numerical") + license = ("MPL-2.0", "LGPL-3.0-or-later") # Taking into account the default value of MPL2_only option + + settings = "os", "arch", "compiler", "build_type" + options = { + "MPL2_only": [True, False], + } + default_options = { + "MPL2_only": False, + } + + def export_sources(self): + export_conandata_patches(self) + + def configure(self): + self.license = "MPL-2.0" if self.options.MPL2_only else ("MPL-2.0", "LGPL-3.0-or-later") + + def layout(self): + cmake_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("eigen-{}".format(self.version), self._source_subfolder) - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["BUILD_TESTING"] = not self.conf.get("tools.build:skip_test", default=True, check_type=bool) + tc.cache_variables["EIGEN_TEST_NOQT"] = True + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): cmake = CMake(self) - cmake.definitions["BUILD_TESTING"] = False - cmake.definitions["EIGEN_TEST_NOQT"] = True - cmake.configure(source_folder=self._source_subfolder) cmake.install() - self.copy("COPYING.*", dst="licenses", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "share")) - - def package_id(self): - self.info.header_only() + copy(self, "COPYING.*", self.source_folder, os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Eigen3") + self.cpp_info.set_property("cmake_target_name", "Eigen3::Eigen") + self.cpp_info.set_property("pkg_config_name", "eigen3") + # TODO: back to global scope once cmake_find_package* generators removed + self.cpp_info.components["eigen3"].bindirs = [] + self.cpp_info.components["eigen3"].libdirs = [] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["eigen3"].system_libs = ["m"] + if self.options.MPL2_only: + self.cpp_info.components["eigen3"].defines = ["EIGEN_MPL2_ONLY"] + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self.cpp_info.names["cmake_find_package"] = "Eigen3" self.cpp_info.names["cmake_find_package_multi"] = "Eigen3" self.cpp_info.names["pkg_config"] = "eigen3" self.cpp_info.components["eigen3"].names["cmake_find_package"] = "Eigen" self.cpp_info.components["eigen3"].names["cmake_find_package_multi"] = "Eigen" + self.cpp_info.components["eigen3"].set_property("cmake_target_name", "Eigen3::Eigen") self.cpp_info.components["eigen3"].includedirs = [os.path.join("include", "eigen3")] - if self.settings.os == "Linux": - self.cpp_info.components["eigen3"].system_libs = ["m"] - if self.options.MPL2_only: - self.cpp_info.components["eigen3"].defines = ["EIGEN_MPL2_ONLY"] diff --git a/recipes/eigen/all/patches/0002-cmake-minimum-required.patch b/recipes/eigen/all/patches/0002-cmake-minimum-required.patch new file mode 100644 index 0000000000000..ed2fc38f4da97 --- /dev/null +++ b/recipes/eigen/all/patches/0002-cmake-minimum-required.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,6 +1,6 @@ ++cmake_minimum_required(VERSION 2.8.5) + project(Eigen3) + +-cmake_minimum_required(VERSION 2.8.5) + + # guard against in-source builds + diff --git a/recipes/eigen/all/test_package/CMakeLists.txt b/recipes/eigen/all/test_package/CMakeLists.txt index a0fedc238ddc1..7a24919989d14 100644 --- a/recipes/eigen/all/test_package/CMakeLists.txt +++ b/recipes/eigen/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(Eigen3 REQUIRED) +find_package(Eigen3 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} Eigen3::Eigen) +target_link_libraries(${PROJECT_NAME} PRIVATE Eigen3::Eigen) diff --git a/recipes/eigen/all/test_package/conanfile.py b/recipes/eigen/all/test_package/conanfile.py index 23ba95e79f465..c0ba081cf41ea 100644 --- a/recipes/eigen/all/test_package/conanfile.py +++ b/recipes/eigen/all/test_package/conanfile.py @@ -1,9 +1,19 @@ -from conans import ConanFile, CMake, tools import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,6 +21,5 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/recipes/eigen/all/test_package/test_package.cpp b/recipes/eigen/all/test_package/test_package.cpp index 69a884db4af91..a253d7f1b2200 100644 --- a/recipes/eigen/all/test_package/test_package.cpp +++ b/recipes/eigen/all/test_package/test_package.cpp @@ -9,8 +9,8 @@ int main(void) Eigen::MatrixXi A(N, N); A.setRandom(); - std::cout << "A =\n" << A << '\n' <= "0.186": + if self.settings.compiler in ["Visual Studio", "apple-clang", "msvc"]: + raise ConanInvalidConfiguration("Compiler %s not supported. " + "elfutils only supports gcc and clang" % self.settings.compiler) + else: + if self.settings.compiler in ["Visual Studio", "clang", "apple-clang", "msvc"]: + raise ConanInvalidConfiguration("Compiler %s not supported. " + "elfutils only supports gcc" % self.settings.compiler) if self.settings.compiler != "gcc": self.output.warn("Compiler %s is not gcc." % self.settings.compiler) def requirements(self): + self.requires("zlib/1.2.12") if self.options.with_sqlite3: - self.requires("sqlite3/3.31.1") + self.requires("sqlite3/3.38.5") if self.options.with_bzlib: - self.requires("bzip2/1.0.6") - if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("bzip2/1.0.8") if self.options.with_lzma: - self.requires("xz_utils/5.2.4") + self.requires("xz_utils/5.2.5") + if self.options.get_safe("libdebuginfod"): + self.requires("libcurl/7.83.0") if self.options.debuginfod: # FIXME: missing recipe for libmicrohttpd raise ConanInvalidConfiguration("libmicrohttpd is not available (yet) on CCI") + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def build_requirements(self): - self.build_requires("automake/1.16.2") - self.build_requires("m4/1.4.18") + self.build_requires("automake/1.16.4") + self.build_requires("m4/1.4.19") self.build_requires("flex/2.6.4") - self.build_requires("bison/3.5.3") - self.build_requires("pkgconf/1.7.3") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH") and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") + self.build_requires("bison/3.7.6") + self.build_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "elfutils" + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) def _configure_autotools(self): if not self._autotools: @@ -88,12 +104,15 @@ def _configure_autotools(self): "--enable-static={}".format("no" if self.options.shared else "yes"), "--enable-deterministic-archives", "--enable-silent-rules", - "--with-zlib" if self.options.with_zlib else "--without-zlib", + "--with-zlib", "--with-bzlib" if self.options.with_bzlib else "--without-bzlib", "--with-lzma" if self.options.with_lzma else "--without-lzma", "--enable-debuginfod" if self.options.debuginfod else "--disable-debuginfod", - 'BUILD_STATIC={}'.format("0" if self.options.shared else "1"), ] + if tools.Version(self.version) >= "0.186": + args.append("--enable-libdebuginfod" if self.options.libdebuginfod else "--disable-libdebuginfod") + args.append('BUILD_STATIC={}'.format("0" if self.options.shared else "1")) + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) self._autotools.configure(configure_dir=self._source_subfolder, args=args) return self._autotools @@ -110,16 +129,14 @@ def package(self): self.copy(pattern="COPYING*", dst="licenses", src=self._source_subfolder) autotools = self._configure_autotools() autotools.install() + tools.rmdir(os.path.join(self.package_folder, "etc")) tools.rmdir(os.path.join(self.package_folder, "share")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) if self.options.shared: - for f in glob.glob(os.path.join(self.package_folder, "lib", "*.a")): - os.remove(f) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.a") else: - for f in glob.glob(os.path.join(self.package_folder, "lib", "*.so")): - os.remove(f) - for f in glob.glob(os.path.join(self.package_folder, "lib", "*.so.1")): - os.remove(f) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.so") + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.so.1") def package_info(self): # library components @@ -127,12 +144,20 @@ def package_info(self): self.cpp_info.components["libelf"].requires = ["zlib::zlib"] self.cpp_info.components["libdw"].libs = ["dw"] - self.cpp_info.components["libdw"].requires = ["libelf", "zlib::zlib", "bzip2::bzip2", "xz_utils::xz_utils"] + self.cpp_info.components["libdw"].requires = ["libelf", "zlib::zlib"] + if self.options.with_bzlib: + self.cpp_info.components["libdw"].requires.append("bzip2::bzip2") + if self.options.with_lzma: + self.cpp_info.components["libdw"].requires.append("xz_utils::xz_utils") self.cpp_info.components["libasm"].includedirs = ["include/elfutils"] self.cpp_info.components["libasm"].libs = ["asm"] self.cpp_info.components["libasm"].requires = ["libelf", "libdw"] + if self.options.get_safe("libdebuginfod"): + self.cpp_info.components["libdebuginfod"].libs = ["debuginfod"] + self.cpp_info.components["libdebuginfod"].requires = ["libcurl::curl"] + # utilities bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH env var with : {}".format(bin_path)) diff --git a/recipes/elfutils/all/patches/0001-Add-enable-werror-configure-option.patch b/recipes/elfutils/all/patches/0.180-0001-Add-enable-werror-configure-option.patch similarity index 100% rename from recipes/elfutils/all/patches/0001-Add-enable-werror-configure-option.patch rename to recipes/elfutils/all/patches/0.180-0001-Add-enable-werror-configure-option.patch diff --git a/recipes/elfutils/all/patches/0002-add-enable-static-option-to-configure.patch b/recipes/elfutils/all/patches/0.180-0002-add-enable-static-option-to-configure.patch similarity index 100% rename from recipes/elfutils/all/patches/0002-add-enable-static-option-to-configure.patch rename to recipes/elfutils/all/patches/0.180-0002-add-enable-static-option-to-configure.patch diff --git a/recipes/elfutils/all/patches/0.186-0001-Add-enable-werror-configure-option.patch b/recipes/elfutils/all/patches/0.186-0001-Add-enable-werror-configure-option.patch new file mode 100644 index 0000000000000..789694c1fe951 --- /dev/null +++ b/recipes/elfutils/all/patches/0.186-0001-Add-enable-werror-configure-option.patch @@ -0,0 +1,41 @@ +--- config/eu.am ++++ config/eu.am +@@ -91,7 +91,6 @@ AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \ + -Wold-style-definition -Wstrict-prototypes $(TRAMPOLINES_WARNING) \ + $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \ + $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \ +- $(if $($(*F)_no_Werror),,-Werror) \ + $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ + $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \ + $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \ +@@ -101,7 +101,6 @@ AM_CXXFLAGS = -std=c++11 -Wall -Wshadow \ + $(TRAMPOLINES_WARNING) \ + $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \ + $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \ +- $(if $($(*F)_no_Werror),,-Werror) \ + $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ + $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \ + $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \ +diff --git a/source/source_subfolder/configure.ac b/source/source_subfolder/configure.ac +index 74cc749..634858d 100644 +--- configure.ac ++++ configure.ac +@@ -262,6 +262,18 @@ + esac + AC_SUBST([DEBUGPRED], $use_debugpred_val) + ++dnl Enable -Werror ++AC_MSG_CHECKING([whether to treat warnings as errors]) ++AC_ARG_ENABLE([werror], ++AS_HELP_STRING([--enable-werror],[treat warnings as errors]), ++[werror=$enableval], [werror=yes]) ++if test "x$werror" = xyes; then ++ AC_MSG_RESULT([yes]) ++ CFLAGS="$CFLAGS -Werror" ++else ++ AC_MSG_RESULT([no]) ++fi ++ + dnl Enable gprof support. + AC_ARG_ENABLE([gprof], + AS_HELP_STRING([--enable-gprof],[build binaries with gprof support]), [use_gprof=$enableval], [use_gprof=no]) diff --git a/recipes/elfutils/all/patches/0.186-0002-add-enable-static-option-to-configure.patch b/recipes/elfutils/all/patches/0.186-0002-add-enable-static-option-to-configure.patch new file mode 100644 index 0000000000000..440b815d4edbf --- /dev/null +++ b/recipes/elfutils/all/patches/0.186-0002-add-enable-static-option-to-configure.patch @@ -0,0 +1,29 @@ +--- configure.ac ++++ configure.ac +@@ -364,8 +364,25 @@ + [install_elfh=$enableval], [install_elfh=no]) + AM_CONDITIONAL(INSTALL_ELFH, test "$install_elfh" = yes) + ++ ++AC_MSG_CHECKING([whether to build elfutils as a static library]) ++AC_ARG_ENABLE([static], ++AS_HELP_STRING([--enable-static],[build elfutils as static libraries]), ++[static_elfutils=$enableval], [static_elfutils=no]) ++ ++static_elfutils=$static_elfutils ++ ++if test "$static_elfutils" = yes ; then ++ AC_MSG_RESULT([yes]) ++else ++ if test "$use_gprof" = yes -o "$use_gcov" = yes ; then ++ AC_MSG_ERROR([cannot build a shared elfutils with gprof or gcov enabled]) ++ fi ++ AC_MSG_RESULT([no]) ++fi ++ + AM_CONDITIONAL(BUILD_STATIC, [dnl +-test "$use_gprof" = yes -o "$use_gcov" = yes]) ++test "$static_elfutils" = yes]) + + AC_ARG_ENABLE([tests-rpath], + AS_HELP_STRING([--enable-tests-rpath],[build $ORIGIN-using rpath into tests]), diff --git a/recipes/elfutils/config.yml b/recipes/elfutils/config.yml index 9bda4f4440cd3..837391aa2d05d 100644 --- a/recipes/elfutils/config.yml +++ b/recipes/elfutils/config.yml @@ -1,3 +1,5 @@ versions: + "0.186": + folder: all "0.180": folder: all diff --git a/recipes/embree3/all/CMakeLists.txt b/recipes/embree3/all/CMakeLists.txt deleted file mode 100644 index 27f20e640dcb8..0000000000000 --- a/recipes/embree3/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.0.0) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/embree3/all/conandata.yml b/recipes/embree3/all/conandata.yml index ebc69622c4db6..2254366a65cdf 100644 --- a/recipes/embree3/all/conandata.yml +++ b/recipes/embree3/all/conandata.yml @@ -1,4 +1,34 @@ sources: + "3.13.5": + url: "https://github.com/embree/embree/archive/v3.13.5.tar.gz" + sha256: "b8c22d275d9128741265537c559d0ea73074adbf2f2b66b0a766ca52c52d665b" + "3.13.3": + url: "https://github.com/embree/embree/archive/v3.13.3.tar.gz" + sha256: "74ec785afb8f14d28ea5e0773544572c8df2e899caccdfc88509f1bfff58716f" + "3.13.1": + url: "https://github.com/embree/embree/archive/refs/tags/v3.13.1.tar.gz" + sha256: "00dbd852f19ae2b95f5106dd055ca4b304486436ced0ccf842aec4e38a4df425" "3.12.0": - url: https://github.com/embree/embree/archive/v3.12.0.zip - sha256: "647c792669d254de527ca89a9fddb15392666e17de4f84bc84158f4a38338eb9" + url: "https://github.com/embree/embree/archive/refs/tags/v3.12.0.tar.gz" + sha256: "f3646977c45a9ece1fb0cfe107567adcc645b1c77c27b36572d0aa98b888190c" +patches: + "3.13.5": + - patch_file: "patches/3.13.x-0001-cmake-minimum-required.patch" + patch_description: "CMake: Fix position of cmake_minimum_required()" + patch_type: "backport" + patch_source: "https://github.com/embree/embree/pull/406" + "3.13.3": + - patch_file: "patches/3.13.x-0001-cmake-minimum-required.patch" + patch_description: "CMake: Fix position of cmake_minimum_required()" + patch_type: "backport" + patch_source: "https://github.com/embree/embree/pull/406" + "3.13.1": + - patch_file: "patches/3.13.x-0001-cmake-minimum-required.patch" + patch_description: "CMake: Fix position of cmake_minimum_required()" + patch_type: "backport" + patch_source: "https://github.com/embree/embree/pull/406" + "3.12.0": + - patch_file: "patches/3.12.x-0001-cmake-minimum-required.patch" + patch_description: "CMake: Fix position of cmake_minimum_required()" + patch_type: "backport" + patch_source: "https://github.com/embree/embree/pull/406" diff --git a/recipes/embree3/all/conanfile.py b/recipes/embree3/all/conanfile.py index c102ce31ce4db..f8e429587b3e0 100644 --- a/recipes/embree3/all/conanfile.py +++ b/recipes/embree3/all/conanfile.py @@ -1,24 +1,36 @@ - +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, load, rm, rmdir, save +from conan.tools.microsoft import check_min_vs +from conan.tools.apple import is_apple_os +from conan.tools.scm import Version import glob import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +import textwrap + +required_conan_version = ">=1.52.0" -class Embree(ConanFile): +class EmbreeConan(ConanFile): name = "embree3" license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "embree", "raytracing", "rendering") + topics = ("embree", "raytracing", "rendering") description = "Intel's collection of high-performance ray tracing kernels." - generators = "cmake" homepage = "https://embree.github.io/" - exports_sources = "CMakeLists.txt" - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], + "sse2": [True, False], + "sse42": [True, False], + "avx": [True, False], + "avx2": [True, False], + "avx512": [True, False], + "neon": [True, False], + "neon2x": [True, False], "geometry_curve": [True, False], "geometry_grid": [True, False], "geometry_instance": [True, False], @@ -30,11 +42,19 @@ class Embree(ConanFile): "ray_masking": [True, False], "backface_culling": [True, False], "ignore_invalid_rays": [True, False], + "with_tbb": [True, False], } default_options = { "shared": False, "fPIC": True, + "sse2": True, + "sse42": False, + "avx": False, + "avx2": False, + "avx512": False, + "neon": False, + "neon2x": False, "geometry_curve": True, "geometry_grid": True, "geometry_instance": True, @@ -46,109 +66,214 @@ class Embree(ConanFile): "ray_masking": False, "backface_culling": False, "ignore_invalid_rays": False, + "with_tbb": False, } - _cmake = None - + + @property + def _has_sse_avx(self): + return self.settings.arch in ["x86", "x86_64"] + @property - def _source_subfolder(self): - return "source_subfolder" + def _embree_has_neon_support(self): + return Version(self.version) >= "3.13.0" @property - def _build_subfolder(self): - return "build_subfolder" + def _embree_has_neon2x_support(self): + return Version(self.version) >= "3.13.4" + + @property + def _has_neon(self): + return "arm" in self.settings.arch + + @property + def _has_neon2x(self): + return "arm" in self.settings.arch and is_apple_os(self) + + @property + def _num_isa(self): + num_isa = 0 + if self._has_neon: + if self._embree_has_neon_support and self.options.neon: + num_isa += 1 + if self._embree_has_neon2x_support and self.options.neon2x: + num_isa += 1 + for simd_option in ["sse2", "sse42", "avx", "avx2", "avx512"]: + if self.options.get_safe(simd_option): + num_isa += 1 + return num_isa + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - + if not self._has_sse_avx: + del self.options.sse2 + del self.options.sse42 + del self.options.avx + del self.options.avx2 + del self.options.avx512 + if not self._has_neon: + del self.options.neon + del self.options.neon2x + else: + if not self._embree_has_neon_support: + del self.options.neon + if not self._embree_has_neon2x_support: + del self.options.neon2x + def configure(self): - version = tools.Version(self.settings.compiler.version) - if self.settings.compiler == "clang" and version < "4": + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_tbb: + self.requires("onetbb/2021.6.0") + + def validate(self): + if not (self._has_sse_avx or (self._embree_has_neon_support and self._has_neon)): + raise ConanInvalidConfiguration("Embree {} doesn't support {}".format(self.version, self.settings.arch)) + + compiler_version = Version(self.info.settings.compiler.version) + if self.info.settings.compiler == "clang" and compiler_version < "4": raise ConanInvalidConfiguration("Clang < 4 is not supported") - elif self.settings.compiler == "Visual Studio" and version < "15": - raise ConanInvalidConfiguration("Visual Studio < 15 is not supported") - if self._is_linux_clang_libcxx: - raise ConanInvalidConfiguration("conan recipe for Embree v{0} \ - cannot be built with clang libc++, use libstdc++ instead".format(self.version)) + check_min_vs(self, 191) - elif self._is_mac_apple_clang_static: - raise ConanInvalidConfiguration("Embree cannot be built into static library with apple-clang,\ - try shared library instead") + if self.info.settings.os == "Linux" and self.info.settings.compiler == "clang" and self.info.settings.compiler.libcxx == "libc++": + raise ConanInvalidConfiguration(f"{self.ref} cannot be built with clang libc++, use libstdc++ instead") + + if self.info.settings.compiler == "apple-clang" and not self.info.options.shared and compiler_version >= "9.0" and self._num_isa > 1: + raise ConanInvalidConfiguration("Embree static with apple-clang >=9 and multiple ISA (simd) is not supported") + + if self._num_isa == 0: + raise ConanInvalidConfiguration("At least one ISA (simd) must be enabled") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - target_name = "{0}-{1}".format("embree", self.version) - os.rename(target_name, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - - # Configure CMake library build: - self._cmake.definitions["EMBREE_STATIC_LIB"] = not self.options.shared - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.definitions["EMBREE_TUTORIALS"] = False - self._cmake.definitions["EMBREE_GEOMETRY_CURVE"] = self.options.geometry_curve - self._cmake.definitions["EMBREE_GEOMETRY_GRID"] = self.options.geometry_grid - self._cmake.definitions["EMBREE_GEOMETRY_INSTANCE"] = self.options.geometry_instance - self._cmake.definitions["EMBREE_GEOMETRY_QUAD"] = self.options.geometry_quad - self._cmake.definitions["EMBREE_GEOMETRY_SUBDIVISION"] = self.options.geometry_subdivision - self._cmake.definitions["EMBREE_GEOMETRY_TRIANGLE"] = self.options.geometry_triangle - self._cmake.definitions["EMBREE_GEOMETRY_USER"] = self.options.geometry_user - self._cmake.definitions["EMBREE_RAY_PACKETS"] = self.options.ray_packets - self._cmake.definitions["EMBREE_RAY_MASK"] = self.options.ray_masking - self._cmake.definitions["EMBREE_BACKFACE_CULLING"] = self.options.backface_culling - self._cmake.definitions["EMBREE_IGNORE_INVALID_RAYS"] = self.options.ignore_invalid_rays - self._cmake.definitions["EMBREE_ISPC_SUPPORT"] = False - self._cmake.definitions["EMBREE_TASKING_SYSTEM"] = "INTERNAL" - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["EMBREE_STATIC_LIB"] = not self.options.shared + tc.variables["BUILD_TESTING"] = False + tc.variables["EMBREE_TUTORIALS"] = False + tc.variables["EMBREE_GEOMETRY_CURVE"] = self.options.geometry_curve + tc.variables["EMBREE_GEOMETRY_GRID"] = self.options.geometry_grid + tc.variables["EMBREE_GEOMETRY_INSTANCE"] = self.options.geometry_instance + tc.variables["EMBREE_GEOMETRY_QUAD"] = self.options.geometry_quad + tc.variables["EMBREE_GEOMETRY_SUBDIVISION"] = self.options.geometry_subdivision + tc.variables["EMBREE_GEOMETRY_TRIANGLE"] = self.options.geometry_triangle + tc.variables["EMBREE_GEOMETRY_USER"] = self.options.geometry_user + tc.variables["EMBREE_RAY_PACKETS"] = self.options.ray_packets + tc.variables["EMBREE_RAY_MASK"] = self.options.ray_masking + tc.variables["EMBREE_BACKFACE_CULLING"] = self.options.backface_culling + tc.variables["EMBREE_IGNORE_INVALID_RAYS"] = self.options.ignore_invalid_rays + tc.variables["EMBREE_ISPC_SUPPORT"] = False + tc.variables["EMBREE_TASKING_SYSTEM"] = "TBB" if self.options.with_tbb else "INTERNAL" + tc.variables["EMBREE_MAX_ISA"] = "NONE" + if self._embree_has_neon_support: + tc.variables["EMBREE_ISA_NEON"] = self.options.get_safe("neon", False) + if self._embree_has_neon2x_support: + tc.variables["EMBREE_ISA_NEON2X"] = self.options.get_safe("neon2x", False) + + tc.variables["EMBREE_ISA_SSE2"] = self.options.get_safe("sse2", False) + tc.variables["EMBREE_ISA_SSE42"] = self.options.get_safe("sse42", False) + tc.variables["EMBREE_ISA_AVX"] = self.options.get_safe("avx", False) + tc.variables["EMBREE_ISA_AVX2"] = self.options.get_safe("avx2", False) + if Version(self.version) < "3.12.2": + # TODO: probably broken if avx512 enabled, must cumbersome to add specific options in the recipe + tc.variables["EMBREE_ISA_AVX512KNL"] = self.options.get_safe("avx512", False) + tc.variables["EMBREE_ISA_AVX512SKX"] = self.options.get_safe("avx512", False) + else: + tc.variables["EMBREE_ISA_AVX512"] = self.options.get_safe("avx512", False) + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # some compilers (e.g. clang) do not like UTF-16 sources + rc = os.path.join(self.source_folder, "kernels", "embree.rc") + content = load(self, rc, encoding="utf_16_le") + if content[0] == '\ufeff': + content = content[1:] + content = "#pragma code_page(65001)\n" + content + save(self, rc, content) + os.remove(os.path.join(self.source_folder, "common", "cmake", "FindTBB.cmake")) def build(self): - os.remove(os.path.join(self._source_subfolder, "common", "cmake", "FindTBB.cmake")) - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses") - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, 'lib', 'cmake')) - for command_file in glob.glob(os.path.join(self.package_folder, "*.command")): - os.remove(command_file) - for cmake_file in glob.glob(os.path.join(self.package_folder, "*.cmake")): - os.remove(cmake_file) - - tools.rmdir(os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.command", os.path.join(self.package_folder)) + rm(self, "*.cmake", os.path.join(self.package_folder)) - if self.options.shared: + if self.settings.os == "Windows" and self.options.shared: for dll_pattern_to_remove in ["concrt*.dll", "msvcp*.dll", "vcruntime*.dll"]: - for dll_to_remove in glob.glob(os.path.join(self.package_folder, "bin", dll_pattern_to_remove)): - os.remove(dll_to_remove) + rm(self, dll_pattern_to_remove, os.path.join(self.package_folder, "bin")) else: - tools.rmdir(os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "bin")) - def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["dl", "m", "pthread"] - - @property - def _is_linux_clang_libcxx(self): - return ( - self.settings.os == 'Linux' and - self.settings.compiler == 'clang' and - self.settings.compiler.libcxx == 'libc++' + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"embree": "embree::embree"} ) + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + @property - def _is_mac_apple_clang_static(self): - return ( - self.settings.os == 'Macos' and - self.settings.compiler == 'apple-clang' and - self.options.shared == False - ) + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "embree") + self.cpp_info.set_property("cmake_target_name", "embree") + + def _lib_exists(name): + return bool(glob.glob(os.path.join(self.package_folder, "lib", f"*{name}.*"))) + + self.cpp_info.libs = ["embree3"] + if not self.options.shared: + self.cpp_info.libs.extend(["sys", "math", "simd", "lexers", "tasking"]) + simd_libs = ["embree_sse42", "embree_avx", "embree_avx2"] + simd_libs.extend(["embree_avx512knl", "embree_avx512skx"] if Version(self.version) < "3.12.2" else ["embree_avx512"]) + for lib in simd_libs: + if _lib_exists(lib): + self.cpp_info.libs.append(lib) + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["dl", "m", "pthread"]) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "embree" + self.cpp_info.names["cmake_find_package_multi"] = "embree" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/embree3/all/patches/3.12.x-0001-cmake-minimum-required.patch b/recipes/embree3/all/patches/3.12.x-0001-cmake-minimum-required.patch new file mode 100644 index 0000000000000..d07ff0aa4e590 --- /dev/null +++ b/recipes/embree3/all/patches/3.12.x-0001-cmake-minimum-required.patch @@ -0,0 +1,17 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,6 @@ + ## Copyright 2009-2020 Intel Corporation + ## SPDX-License-Identifier: Apache-2.0 ++CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) + + SET(EMBREE_VERSION_MAJOR 3) + SET(EMBREE_VERSION_MINOR 12) +@@ -12,7 +13,6 @@ SET(CPACK_RPM_PACKAGE_RELEASE 1) + + PROJECT(embree${EMBREE_VERSION_MAJOR}) + +-CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) + + # We use our own strip tool on macOS to sign during install. This is required as CMake modifies RPATH of the binary during install. + IF (APPLE AND EMBREE_SIGN_FILE) diff --git a/recipes/embree3/all/patches/3.13.x-0001-cmake-minimum-required.patch b/recipes/embree3/all/patches/3.13.x-0001-cmake-minimum-required.patch new file mode 100644 index 0000000000000..6208148722846 --- /dev/null +++ b/recipes/embree3/all/patches/3.13.x-0001-cmake-minimum-required.patch @@ -0,0 +1,17 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,6 @@ + ## Copyright 2009-2021 Intel Corporation + ## SPDX-License-Identifier: Apache-2.0 ++CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) + + SET(EMBREE_VERSION_MAJOR 3) + SET(EMBREE_VERSION_MINOR 13) +@@ -12,7 +13,6 @@ SET(CPACK_RPM_PACKAGE_RELEASE 1) + + PROJECT(embree${EMBREE_VERSION_MAJOR}) + +-CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) + + # We use our own strip tool on macOS to sign during install. This is required as CMake modifies RPATH of the binary during install. + IF (APPLE AND EMBREE_SIGN_FILE) diff --git a/recipes/embree3/all/test_package/CMakeLists.txt b/recipes/embree3/all/test_package/CMakeLists.txt index b0026dee30afb..fe2724327bb76 100644 --- a/recipes/embree3/all/test_package/CMakeLists.txt +++ b/recipes/embree3/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup(TARGETS) +find_package(embree REQUIRED CONFIG) -add_executable(${PROJECT_NAME} pkg_test.cpp) -target_link_libraries(${PROJECT_NAME} CONAN_PKG::embree3) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE embree) diff --git a/recipes/embree3/all/test_package/conanfile.py b/recipes/embree3/all/test_package/conanfile.py index 7d45e5e877baa..0a6bc68712d90 100644 --- a/recipes/embree3/all/test_package/conanfile.py +++ b/recipes/embree3/all/test_package/conanfile.py @@ -1,11 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - name = "pkgtest_embree3" - generators = "cmake" - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -13,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/embree3/all/test_package/pkg_test.cpp b/recipes/embree3/all/test_package/pkg_test.cpp deleted file mode 100644 index 59ae91a3ff7c7..0000000000000 --- a/recipes/embree3/all/test_package/pkg_test.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - -#include -RTC_NAMESPACE_OPEN - -#include - -#if !defined(_MM_SET_DENORMALS_ZERO_MODE) -#define _MM_DENORMALS_ZERO_ON (0x0040) -#define _MM_DENORMALS_ZERO_OFF (0x0000) -#define _MM_DENORMALS_ZERO_MASK (0x0040) -#define _MM_SET_DENORMALS_ZERO_MODE(x) \ - (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x))) -#endif - -int main(int p_arg_count, char **p_arg_vector) { - std::cout << "'Embree package test (compilation, linking, and execution)." - << std::endl; - - _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); - _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); - - std::cout << "Creating a new Embree device ..." << std::endl; - RTCDevice device = rtcNewDevice("verbose=1"); - std::cout << "Releasing the Embree device ..." << std::endl; - rtcReleaseDevice(device); - - std::cout << "'Embree package works!" << std::endl; - return EXIT_SUCCESS; -} diff --git a/recipes/embree3/all/test_package/test_package.cpp b/recipes/embree3/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..acf78e712339a --- /dev/null +++ b/recipes/embree3/all/test_package/test_package.cpp @@ -0,0 +1,49 @@ +#include + +#include +#include + +int main() +{ + RTCDevice device = rtcNewDevice(NULL); + RTCScene scene = rtcNewScene(device); + RTCGeometry geom = rtcNewGeometry(device, RTC_GEOMETRY_TYPE_TRIANGLE); + + float* vb = (float*) rtcSetNewGeometryBuffer(geom, + RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, 3*sizeof(float), 3); + vb[0] = 0.f; vb[1] = 0.f; vb[2] = 0.f; // 1st vertex + vb[3] = 1.f; vb[4] = 0.f; vb[5] = 0.f; // 2nd vertex + vb[6] = 0.f; vb[7] = 1.f; vb[8] = 0.f; // 3rd vertex + + unsigned* ib = (unsigned*) rtcSetNewGeometryBuffer(geom, + RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, 3*sizeof(unsigned), 1); + ib[0] = 0; ib[1] = 1; ib[2] = 2; + + rtcCommitGeometry(geom); + rtcAttachGeometry(scene, geom); + rtcReleaseGeometry(geom); + rtcCommitScene(scene); + + RTCRayHit rayhit; + rayhit.ray.org_x = 0.f; rayhit.ray.org_y = 0.f; rayhit.ray.org_z = -1.f; + rayhit.ray.dir_x = 0.f; rayhit.ray.dir_y = 0.f; rayhit.ray.dir_z = 1.f; + rayhit.ray.tnear = 0.f; + rayhit.ray.tfar = std::numeric_limits::infinity(); + rayhit.hit.geomID = RTC_INVALID_GEOMETRY_ID; + + RTCIntersectContext context; + rtcInitIntersectContext(&context); + + rtcIntersect1(scene, &context, &rayhit); + + if (rayhit.hit.geomID != RTC_INVALID_GEOMETRY_ID) { + std::cout << "Intersection at t = " << rayhit.ray.tfar << std::endl; + } else { + std::cout << "No Intersection" << std::endl; + } + + rtcReleaseScene(scene); + rtcReleaseDevice(device); + + return 0; +} diff --git a/recipes/embree3/all/test_v1_package/CMakeLists.txt b/recipes/embree3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..42932a8412566 --- /dev/null +++ b/recipes/embree3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(embree REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE embree) diff --git a/recipes/embree3/all/test_v1_package/conanfile.py b/recipes/embree3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/embree3/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/embree3/config.yml b/recipes/embree3/config.yml index 77752fef96e45..f3cd7c6b5617a 100644 --- a/recipes/embree3/config.yml +++ b/recipes/embree3/config.yml @@ -1,3 +1,9 @@ versions: + "3.13.5": + folder: all + "3.13.3": + folder: all + "3.13.1": + folder: all "3.12.0": folder: all diff --git a/recipes/emsdk/all/conandata.yml b/recipes/emsdk/all/conandata.yml new file mode 100644 index 0000000000000..97335d64e50ee --- /dev/null +++ b/recipes/emsdk/all/conandata.yml @@ -0,0 +1,52 @@ +sources: + "3.1.23": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.23.tar.gz" + sha256: "a2609fd97580e4e332acbf49b6cc363714982f06cb6970d54c9789df8e91381c" + "3.1.20": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.20.tar.gz" + sha256: "fd336c6d3e51c7205a8ec68e835c442dcbb187f92e50c42b3d7d54a312072ef7" + "3.1.18": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.18.tar.gz" + sha256: "6479c60710bfb1d146a8bdd8619b693699e73185c850a6eb79ef2bd7e2a8e411" + "3.1.17": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.17.tar.gz" + sha256: "f52359d3f265162dc875ac4c9d4570abc9d012e30bef8d380cb74f0e427800a3" + "3.1.16": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.16.tar.gz" + sha256: "0a7a822e09bb22d081a49bf4229377689aef473376f36b5fe62db040d7e1c065" + "3.1.15": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.15.tar.gz" + sha256: "74c7c54b3544555ec38d1e9dcc7e90b9f49ed0e04f2cc3fd44663c598af24124" + "3.1.12": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.12.tar.gz" + sha256: "1b8d8fdebf9f155131ba74f91d2c0dd572b2ba5d1d4a22fb123d20d3ca258e30" + "3.1.7": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.7.tar.gz" + sha256: "bcceced0b7cad2e08375adf74ef20fa431230abbae8766bdad268c43e34f8d03" + "3.1.5": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.5.tar.gz" + sha256: "ae540d681aa04f32b92afbda1c9ef737aa03c81222c1ce3fd567de5af7d36625" + "3.1.4": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.4.tar.gz" + sha256: "7dc13d967705582e11ff62ae143425dbc63c38372f1a1b14f0cb681fda413714" + "3.1.3": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.3.tar.gz" + sha256: "c03767ad4b6d24f143c0a4922735c80ec17d745191ebf54b8f97dbe5d81eb52f" + "3.1.0": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.0.tar.gz" + sha256: "a2c5f3cf36525cf6a4b569f9d25500e3b2f7341c6e6779b54bcf4703b834202d" + "3.0.1": + url: "https://github.com/emscripten-core/emsdk/archive/3.0.1.tar.gz" + sha256: "3a51e17d45878a5c6d1b6c20f35d308b95d58d56dbfbee4ec058e2ee216b2c90" + "3.0.0": + url: "https://github.com/emscripten-core/emsdk/archive/3.0.0.tar.gz" + sha256: "a41dccfd15be9e85f923efaa0ac21943cbab77ec8d39e52f25eca1ec61a9ac9e" + "2.0.34": + url: "https://github.com/emscripten-core/emsdk/archive/2.0.34.tar.gz" + sha256: "a96ddf34de8de779c78be2785df04ae63c9a557da9e83e85332cda3d01bca250" + "2.0.31": + url: "https://github.com/emscripten-core/emsdk/archive/2.0.31.tar.gz" + sha256: "6bf70f4522308de1941200f8cdb9bde6967ba7aacb03445e9d136a5dd812b728" + "2.0.30": + url: https://github.com/emscripten-core/emsdk/archive/refs/tags/2.0.30.tar.gz + sha256: 69050d76c8907a58f99b08831e8cb7a4fba857efec6037d5e59df4b73111ba36 diff --git a/recipes/emsdk/all/conanfile.py b/recipes/emsdk/all/conanfile.py new file mode 100644 index 0000000000000..b9f626ca08eef --- /dev/null +++ b/recipes/emsdk/all/conanfile.py @@ -0,0 +1,191 @@ +from conan import ConanFile, conan_version +from conan.tools.build import cross_building +from conan.tools.env import Environment +from conan.tools.files import chdir, copy, get, replace_in_file +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +import json +import os + +required_conan_version = ">=1.52.0" + + +class EmSDKConan(ConanFile): + name = "emsdk" + description = "Emscripten SDK. Emscripten is an Open Source LLVM to JavaScript compiler" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/kripken/emscripten" + topics = ("emsdk", "emscripten", "sdk") + license = "MIT" + settings = "os", "arch", "compiler", "build_type" + + short_paths = True + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("nodejs/16.3.0") + # self.requires("python") # FIXME: Not available as Conan package + # self.requires("wasm") # FIXME: Not available as Conan package + + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + @property + def _relative_paths(self): + return ["bin", os.path.join("bin", "upstream", "emscripten")] + + @property + def _paths(self): + return [os.path.join(self.package_folder, path) for path in self._relative_paths] + + @property + def _emsdk(self): + return os.path.join(self.package_folder, "bin") + + @property + def _emscripten(self): + return os.path.join(self.package_folder, "bin", "upstream", "emscripten") + + @property + def _em_config(self): + return os.path.join(self.package_folder, "bin", ".emscripten") + + @property + def _em_cache(self): + return os.path.join(self.package_folder, "bin", ".emscripten_cache") + + def generate(self): + env = Environment() + env.prepend_path("PATH", self._paths) + env.define_path("EMSDK", self._emsdk) + env.define_path("EMSCRIPTEN", self._emscripten) + env.define_path("EM_CONFIG", self._em_config) + env.define_path("EM_CACHE", self._em_cache) + env.vars(self, scope="emsdk").save_script("emsdk_env_file") + + @staticmethod + def _chmod_plus_x(filename): + if os.name == "posix": + os.chmod(filename, os.stat(filename).st_mode | 0o111) + + def _tools_for_version(self): + ret = {} + # Select release-upstream from version (wasm-binaries) + with open(os.path.join(self.source_folder, "emscripten-releases-tags.json"), "r") as f: + data = json.load(f) + ret["wasm"] = f"releases-upstream-{data['releases'][self.version]}-64bit" + # Select python and node versions + with open(os.path.join(self.source_folder, "emsdk_manifest.json"), "r") as f: + data = json.load(f) + tools = data["tools"] + if self.settings.os == "Windows": + python = next((it for it in tools if (it["id"] == "python" and not it.get("is_old", False))), None) + ret["python"] = f"python-{python['version']}-64bit" + node = next((it for it in tools if (it["id"] == "node" and not it.get("is_old", False))), None) + ret["nodejs"] = f"node-{node['version']}-64bit" + return ret + + def build(self): + with chdir(self, self.source_folder): + emsdk = "emsdk.bat" if self._settings_build.os == "Windows" else "./emsdk" + self._chmod_plus_x("emsdk") + + # Install required tools + required_tools = self._tools_for_version() + for key, value in required_tools.items(): + if key != 'nodejs': + self.run(f"{emsdk} install {value}") + self.run(f"{emsdk} activate {value}") + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=self.source_folder, dst=os.path.join(self.package_folder, "bin")) + emscripten = os.path.join(self.package_folder, "bin", "upstream", "emscripten") + toolchain = os.path.join(emscripten, "cmake", "Modules", "Platform", "Emscripten.cmake") + # FIXME: conan should add the root of conan package requirements to CMAKE_PREFIX_PATH (LIBRARY/INCLUDE -> ONLY; PROGRAM -> NEVER) + # allow to find conan libraries + replace_in_file(self, toolchain, + "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)", + "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)") + replace_in_file(self, toolchain, + "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)", + "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)") + replace_in_file(self, toolchain, + "set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)", + "set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)") + if not cross_building(self): + self.run("embuilder build MINIMAL", env="conanemsdk") # force cache population + # the line below forces emscripten to accept the cache as-is, even after re-location + # https://github.com/emscripten-core/emscripten/issues/15053#issuecomment-920950710 + os.remove(os.path.join(self._em_cache, "sanity.txt")) + + def _define_tool_var(self, value): + suffix = ".bat" if self.settings.os == "Windows" else "" + path = os.path.join(self._emscripten, f"{value}{suffix}") + self._chmod_plus_x(path) + return path + + def package_info(self): + self.cpp_info.bindirs = self._relative_paths + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # If we are not building for Emscripten, probably we don't want to inject following environment variables, + # but it might be legit use cases... until we find them, let's be conservative. + if not hasattr(self, "settings_target") or self.settings_target is None: + return + + if self.settings_target.os != "Emscripten": + self.output.warn(f"You've added {self.name}/{self.version} as a build requirement, while os={self.settings_target.os} != Emscripten") + return + + toolchain = os.path.join(self.package_folder, "bin", "upstream", "emscripten", "cmake", "Modules", "Platform", "Emscripten.cmake") + self.conf_info.prepend("tools.cmake.cmaketoolchain:user_toolchain", toolchain) + + self.buildenv_info.define_path("EMSDK", self._emsdk) + self.buildenv_info.define_path("EMSCRIPTEN", self._emscripten) + self.buildenv_info.define_path("EM_CONFIG", self._em_config) + self.buildenv_info.define_path("EM_CACHE", self._em_cache) + + self.buildenv_info.define_path("CC", self._define_tool_var("emcc")) + self.buildenv_info.define_path("CXX", self._define_tool_var("em++")) + self.buildenv_info.define_path("AR", self._define_tool_var("emar")) + self.buildenv_info.define_path("NM", self._define_tool_var("emnm")) + self.buildenv_info.define_path("RANLIB", self._define_tool_var("emranlib")) + self.buildenv_info.define_path("STRIP", self._define_tool_var("emstrip")) + + self.cpp_info.builddirs = [ + os.path.join("bin", "releases", "src"), + os.path.join("bin", "upstream", "emscripten", "cmake", "Modules"), + os.path.join("bin", "upstream", "emscripten", "cmake", "Modules", "Platform"), + os.path.join("bin", "upstream", "emscripten", "system", "lib", "libunwind", "cmake", "Modules"), + os.path.join("bin", "upstream", "emscripten", "system", "lib", "libunwind", "cmake"), + os.path.join("bin", "upstream", "emscripten", "tests", "cmake", "target_library"), + os.path.join("bin", "upstream", "lib", "cmake", "llvm"), + ] + + if Version(conan_version).major < 2: + self.env_info.PATH.extend(self._paths) + self.env_info.CONAN_CMAKE_TOOLCHAIN_FILE = toolchain + self.env_info.EMSDK = self._emsdk + self.env_info.EMSCRIPTEN = self._emscripten + self.env_info.EM_CONFIG = self._em_config + self.env_info.EM_CACHE = self._em_cache + self.env_info.CC = self._define_tool_var("emcc") + self.env_info.CXX = self._define_tool_var("em++") + self.env_info.AR = self._define_tool_var("emar") + self.env_info.NM = self._define_tool_var("emnm") + self.env_info.RANLIB = self._define_tool_var("emranlib") + self.env_info.STRIP = self._define_tool_var("emstrip") diff --git a/recipes/emsdk/all/test_package/CMakeLists.txt b/recipes/emsdk/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f776bcb524ea6 --- /dev/null +++ b/recipes/emsdk/all/test_package/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +add_executable(${PROJECT_NAME} test_package.cpp) diff --git a/recipes/emsdk/all/test_package/conanfile.py b/recipes/emsdk/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5bce241404bf4 --- /dev/null +++ b/recipes/emsdk/all/test_package/conanfile.py @@ -0,0 +1,40 @@ +from conan import ConanFile +from conan.tools.env import Environment +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + if self.settings.os == "Emscripten": + env = Environment() + env.define_path("EM_CACHE", os.path.join(self.build_folder, ".emcache")) + envvars = env.vars(self, scope="build") + envvars.save_script("em_cache") + + def build(self): + # It only makes sense to build a library, if the target os is Emscripten + if self.settings.os == "Emscripten": + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + # Check the package provides working binaries + self.run("emcc -v") + self.run("em++ -v") + + # Run the project that was built using emsdk + if self.settings.os == "Emscripten": + test_file = os.path.join(self.cpp.build.bindirs[0], "test_package.js") + self.run(f"node {test_file}") diff --git a/recipes/emsdk/all/test_package/test_package.cpp b/recipes/emsdk/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..dc0f143f2972b --- /dev/null +++ b/recipes/emsdk/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + std::cout << "conan-center-index\n"; + return EXIT_SUCCESS; +} diff --git a/recipes/emsdk/all/test_v1_package/CMakeLists.txt b/recipes/emsdk/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f7c5ddc942cf1 --- /dev/null +++ b/recipes/emsdk/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) diff --git a/recipes/emsdk/all/test_v1_package/conanfile.py b/recipes/emsdk/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..434f5772df524 --- /dev/null +++ b/recipes/emsdk/all/test_v1_package/conanfile.py @@ -0,0 +1,30 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + generators = "cmake" + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + + def build(self): + # It only makes sense to build a library, if the target os is Emscripten + if self.settings.os == "Emscripten": + with tools.environment_append({"EM_CACHE": os.path.join(self.build_folder, ".emcache")}): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + # Check the package provides working binaries + if not tools.cross_building(self): + self.run("emcc -v", run_environment=True) + self.run("em++ -v", run_environment=True) + + # Run the project that was built using emsdk + if self.settings.os == "Emscripten": + test_file = os.path.join("bin", "test_package.js") + self.run(f"node {test_file}", run_environment=True) diff --git a/recipes/emsdk/config.yml b/recipes/emsdk/config.yml new file mode 100644 index 0000000000000..7591f3687c322 --- /dev/null +++ b/recipes/emsdk/config.yml @@ -0,0 +1,35 @@ +versions: + "3.1.23": + folder: all + "3.1.20": + folder: all + "3.1.18": + folder: all + "3.1.17": + folder: all + "3.1.16": + folder: all + "3.1.15": + folder: all + "3.1.12": + folder: all + "3.1.7": + folder: all + "3.1.5": + folder: all + "3.1.4": + folder: all + "3.1.3": + folder: all + "3.1.0": + folder: all + "3.0.1": + folder: all + "3.0.0": + folder: all + "2.0.34": + folder: all + "2.0.31": + folder: all + "2.0.30": + folder: all diff --git a/recipes/enchant/all/CMakeLists.txt b/recipes/enchant/all/CMakeLists.txt new file mode 100644 index 0000000000000..5c44e31e17e0f --- /dev/null +++ b/recipes/enchant/all/CMakeLists.txt @@ -0,0 +1,102 @@ +cmake_minimum_required(VERSION 3.2) + +project(enchant VERSION "${CONAN_enchant_VERSION}") + +set(root "${PROJECT_SOURCE_DIR}/source_subfolder") +set(src "${root}/src") +set(bin "${PROJECT_BINARY_DIR}") + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS KEEP_RPATHS) + +# ---- Config headers ---- + +include(configure.cmake) + +# ---- Setup ---- + +find_package(glib REQUIRED CONFIG) + +include(GenerateExportHeader) + +function(target_set_visibility target) + set_target_properties( + "${target}" PROPERTIES + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN YES + ) +endfunction() + +set(providers "") +macro(add_provider target) + add_library("${target}" MODULE ${ARGN}) + set_property(TARGET "${target}" PROPERTY DEFINE_SYMBOL enchant_module_EXPORTS) + target_set_visibility("${target}") + target_link_libraries("${target}" PRIVATE enchant) + if(NOT providers) + generate_export_header("${target}" BASE_NAME enchant_module) + endif() + list(APPEND providers "${target}") +endmacro() + +if(MSVC) + add_compile_options(/wd4996) +endif() + +# ---- Library ---- + +add_library( + enchant SHARED + "${root}/lib/relocatable.c" + "${src}/lib.c" + "${src}/libenchant.rc" + "${src}/pwl.c" +) + +target_compile_definitions(enchant PRIVATE NO_XMALLOC=1 PIC=1 ENABLE_COSTLY_RELOCATABLE=1) +target_include_directories(enchant PUBLIC "${bin}" "${src}" "${root}/lib") +target_link_libraries(enchant PRIVATE glib::glib-2.0 glib::gmodule-2.0 ${DLADDR_LIBRARIES}) + +generate_export_header(enchant) +target_set_visibility(enchant) +set_target_properties( + enchant PROPERTIES + VERSION "${PROJECT_VERSION}" + SOVERSION "${PROJECT_VERSION_MAJOR}" +) + +# ---- Providers ---- + +# There is only this provider in CCI for now +add_provider(enchant_hunspell "${root}/providers/enchant_hunspell.cpp") +target_compile_features(enchant_hunspell PRIVATE cxx_std_11) + +find_package(hunspell REQUIRED CONFIG) +target_link_libraries(enchant_hunspell PRIVATE hunspell::hunspell glib::glib-2.0) + +# ---- Install rules ---- + +include(GNUInstallDirs) + +install( + TARGETS enchant + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +if(NOT providers STREQUAL "") + install( + TARGETS ${providers} + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/enchant-${PROJECT_VERSION_MAJOR}" + ) +endif() + +install( + FILES + "${src}/enchant++.h" + "${src}/enchant.h" + "${bin}/enchant_export.h" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) diff --git a/recipes/enchant/all/conandata.yml b/recipes/enchant/all/conandata.yml new file mode 100644 index 0000000000000..0e74282d629d1 --- /dev/null +++ b/recipes/enchant/all/conandata.yml @@ -0,0 +1,18 @@ +sources: + "2.3.2": + sha256: "ce9ba47fd4d34031bd69445598a698a6611602b2b0e91d705e91a6f5099ead6e" + url: https://github.com/AbiWord/enchant/releases/download/v2.3.2/enchant-2.3.2.tar.gz +patches: + "2.3.2": + - patch_file: patches/0001-add-visibility-annotations.patch + base_path: source_subfolder + - patch_file: patches/0002-remove-strchrnul-usage.patch + base_path: source_subfolder + - patch_file: patches/0003-fix-file-locking.patch + base_path: source_subfolder + - patch_file: patches/0004-fix-ssize_t-in-headers.patch + base_path: source_subfolder + - patch_file: patches/0005-fix-relocatable.patch + base_path: source_subfolder + - patch_file: patches/0006-add-macos-support.patch + base_path: source_subfolder diff --git a/recipes/enchant/all/conanfile.py b/recipes/enchant/all/conanfile.py new file mode 100644 index 0000000000000..de37d8e54862f --- /dev/null +++ b/recipes/enchant/all/conanfile.py @@ -0,0 +1,57 @@ +import functools + +from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.43.0" + + +class EnchantConan(ConanFile): + name = "enchant" + description = ( + "Enchant aims to provide a simple but comprehensive abstraction for " + "dealing with different spell checking libraries in a consistent way" + ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://abiword.github.io/enchant/" + topics = "enchant", "spell", "spell-check" + license = "LGPL-2.1-or-later" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + requires = "glib/2.71.3", "hunspell/1.7.0" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + self.copy("configmake.h") + self.copy("configure.cmake") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def source(self): + root = self._source_subfolder + get_args = self.conan_data["sources"][self.version] + tools.get(**get_args, destination=root, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["CONAN_enchant_VERSION"] = self.version + cmake.configure() + return cmake + + def build(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + self._configure_cmake().build() + + def package(self): + self.copy("COPYING.LIB", "licenses", self._source_subfolder) + self._configure_cmake().install() + + def package_info(self): + self.cpp_info.libs = ["enchant"] + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["dl"] diff --git a/recipes/enchant/all/configmake.h b/recipes/enchant/all/configmake.h new file mode 100644 index 0000000000000..eebd0272c402c --- /dev/null +++ b/recipes/enchant/all/configmake.h @@ -0,0 +1,13 @@ +/* Relocation requires the INSTALLDIR define to end with a path segment that is + * equal to the final installation for the library file. Note that on Windows + * the convention is /bin while on other platforms it's /lib */ +#ifdef _WIN32 +#define INSTALLDIR "/usr/local/bin" +#else +#define INSTALLDIR "/usr/local/lib" +#endif + +#define INSTALLPREFIX "/usr/local" +#define PKGDATADIR "/usr/local/share/enchant" +#define PKGLIBDIR "/usr/local/lib/enchant" +#define SYSCONFDIR "/usr/local/etc" diff --git a/recipes/enchant/all/configure.cmake b/recipes/enchant/all/configure.cmake new file mode 100644 index 0000000000000..5e067b9fc7047 --- /dev/null +++ b/recipes/enchant/all/configure.cmake @@ -0,0 +1,42 @@ +# ---- Autotools style compile checks ---- + +set(DLADDR_LIBRARIES "") +set(ENABLE_RELOCATABLE 1) + +if(NOT WIN32) + include(CheckFunctionExists) + include(CheckLibraryExists) + + check_library_exists(dl dladdr "" HAVE_DLADDR_IN_DL) + if(HAVE_DLADDR_IN_DL) + set(HAVE_DLADDR 1) + set(DLADDR_LIBRARIES dl) + else() + check_function_exists(dladdr HAVE_DLADDR) + endif() + + check_function_exists(flock HAVE_FLOCK) +endif() + +# ---- Write config headers ---- + +set_directory_properties(PROPERTIES CMAKE_CONFIGURE_DEPENDS config.h.in) +file(READ "${root}/config.h.in" content) +string(REGEX REPLACE "#[ \t]*undef ([^\r\n ]+)" "#cmakedefine \\1 @\\1@" content "${content}") +string(CONFIGURE "${content} +#cmakedefine HAVE_DLADDR @HAVE_DLADDR@ +" content @ONLY) +file( + WRITE "${bin}/config.h.tmp" "${content}" + "#define ENCHANT_MAJOR_VERSION \"${PROJECT_VERSION_MAJOR}\"\n" + "#define ENCHANT_VERSION_STRING \"${PROJECT_VERSION}\"\n" +) + +configure_file(configmake.h configmake.h COPYONLY) +execute_process( + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${bin}/config.h.tmp" "${bin}/config.h" + RESULT_VARIABLE result +) +if(NOT result STREQUAL "0") + message(FATAL_ERROR "Copy failed: ${result}") +endif() diff --git a/recipes/enchant/all/patches/0001-add-visibility-annotations.patch b/recipes/enchant/all/patches/0001-add-visibility-annotations.patch new file mode 100644 index 0000000000000..66e53772d5511 --- /dev/null +++ b/recipes/enchant/all/patches/0001-add-visibility-annotations.patch @@ -0,0 +1,283 @@ +--- src/enchant.h ++++ src/enchant.h +@@ -30,6 +30,7 @@ + #ifndef ENCHANT_H + #define ENCHANT_H + ++#include "enchant_export.h" /* for ENCHANT_EXPORT */ + #include /* for uint32_t */ + #include /* for size_t, ssize_t */ + +@@ -41,7 +42,7 @@ + typedef struct str_enchant_broker EnchantBroker; + typedef struct str_enchant_dict EnchantDict; + +-const char *enchant_get_version (void); ++ENCHANT_EXPORT const char *enchant_get_version (void); + + /** + * enchant_broker_init +@@ -49,7 +50,7 @@ + * Returns: A new broker object capable of requesting + * dictionaries from providers. + */ +-EnchantBroker *enchant_broker_init (void); ++ENCHANT_EXPORT EnchantBroker *enchant_broker_init (void); + + /** + * enchant_broker_free +@@ -57,7 +58,7 @@ + * + * Destroys the broker object. Must only be called once per broker init + */ +-void enchant_broker_free (EnchantBroker * broker); ++ENCHANT_EXPORT void enchant_broker_free (EnchantBroker * broker); + + /** + * enchant_broker_request_dict +@@ -66,7 +67,7 @@ + * + * Returns: An #EnchantDict, or %null if no suitable dictionary could be found. This dictionary is reference counted. + */ +-EnchantDict *enchant_broker_request_dict (EnchantBroker * broker, const char *const tag); ++ENCHANT_EXPORT EnchantDict *enchant_broker_request_dict (EnchantBroker * broker, const char *const tag); + + /** + * enchant_broker_request_pwl_dict +@@ -78,7 +79,7 @@ + * + * Returns: An EnchantDict. This dictionary is reference counted. + */ +-EnchantDict *enchant_broker_request_pwl_dict (EnchantBroker * broker, const char *const pwl); ++ENCHANT_EXPORT EnchantDict *enchant_broker_request_pwl_dict (EnchantBroker * broker, const char *const pwl); + + /** + * enchant_broker_free_dict +@@ -87,7 +88,7 @@ + * + * Releases the dictionary when you are done using it. Must only be called once per dictionary request + */ +-void enchant_broker_free_dict (EnchantBroker * broker, EnchantDict * dict); ++ENCHANT_EXPORT void enchant_broker_free_dict (EnchantBroker * broker, EnchantDict * dict); + + /** + * enchant_broker_dict_exists +@@ -96,7 +97,7 @@ + * + * Return existance of the requested dictionary (1 == true, 0 == false) + */ +-int enchant_broker_dict_exists (EnchantBroker * broker, const char * const tag); ++ENCHANT_EXPORT int enchant_broker_dict_exists (EnchantBroker * broker, const char * const tag); + + /** + * enchant_broker_set_ordering +@@ -110,7 +111,7 @@ + * be used as a language tag to declare a default ordering for any + * language that does not explictly declare an ordering. + */ +-void enchant_broker_set_ordering (EnchantBroker * broker, ++ENCHANT_EXPORT void enchant_broker_set_ordering (EnchantBroker * broker, + const char * const tag, + const char * const ordering); + /** +@@ -121,7 +122,7 @@ + * WARNING: error is transient and is likely cleared as soon as the + * next broker operation happens + */ +-const char *enchant_broker_get_error (EnchantBroker * broker); ++ENCHANT_EXPORT const char *enchant_broker_get_error (EnchantBroker * broker); + + /** + * EnchantBrokerDescribeFn +@@ -146,7 +147,7 @@ + * Enumerates the Enchant providers and tells + * you some rudimentary information about them. + */ +-void enchant_broker_describe (EnchantBroker * broker, ++ENCHANT_EXPORT void enchant_broker_describe (EnchantBroker * broker, + EnchantBrokerDescribeFn fn, + void * user_data); + +@@ -161,7 +162,7 @@ + * + * Returns: 0 if the word is correctly spelled, positive if not, negative if error + */ +-int enchant_dict_check (EnchantDict * dict, const char *const word, ssize_t len); ++ENCHANT_EXPORT int enchant_dict_check (EnchantDict * dict, const char *const word, ssize_t len); + + /** + * enchant_dict_suggest +@@ -175,7 +176,7 @@ + * + * Returns: A %null terminated list of UTF-8 encoded suggestions, or %null + */ +-char **enchant_dict_suggest (EnchantDict * dict, const char *const word, ++ENCHANT_EXPORT char **enchant_dict_suggest (EnchantDict * dict, const char *const word, + ssize_t len, size_t * out_n_suggs); + + /** +@@ -187,7 +188,7 @@ + * Remarks: if the word exists in the exclude dictionary, it will be removed from the + * exclude dictionary + */ +-void enchant_dict_add (EnchantDict * dict, const char *const word, ssize_t len); ++ENCHANT_EXPORT void enchant_dict_add (EnchantDict * dict, const char *const word, ssize_t len); + + /** + * enchant_dict_add_to_session +@@ -196,7 +197,7 @@ + * @len: The byte length of @word, or -1 for strlen (@word) + * + */ +-void enchant_dict_add_to_session (EnchantDict * dict, const char *const word, ssize_t len); ++ENCHANT_EXPORT void enchant_dict_add_to_session (EnchantDict * dict, const char *const word, ssize_t len); + + /** + * enchant_dict_remove +@@ -206,7 +207,7 @@ + * @len: The byte length of @word, or -1 for strlen (@word) + * + */ +-void enchant_dict_remove (EnchantDict * dict, const char *const word, ssize_t len); ++ENCHANT_EXPORT void enchant_dict_remove (EnchantDict * dict, const char *const word, ssize_t len); + + /** + * enchant_dict_remove_from_session +@@ -215,7 +216,7 @@ + * @len: The byte length of @word, or -1 for strlen (@word) + * + */ +-void enchant_dict_remove_from_session (EnchantDict * dict, const char *const word, ssize_t len); ++ENCHANT_EXPORT void enchant_dict_remove_from_session (EnchantDict * dict, const char *const word, ssize_t len); + + /** + * enchant_dict_is_added +@@ -223,7 +224,7 @@ + * @word: The word you wish to see if it has been added (to your session or dict) in UTF8 encoding + * @len: the byte length of @word, or -1 for strlen (@word) + */ +-int enchant_dict_is_added (EnchantDict * dict, const char *const word, ssize_t len); ++ENCHANT_EXPORT int enchant_dict_is_added (EnchantDict * dict, const char *const word, ssize_t len); + + /** + * enchant_dict_is_removed +@@ -231,7 +232,7 @@ + * @word: The word you wish to see if it has been removed (from your session or dict) in UTF8 encoding + * @len: the byte length of @word, or -1 for strlen (@word) + */ +-int enchant_dict_is_removed (EnchantDict * dict, const char *const word, ssize_t len); ++ENCHANT_EXPORT int enchant_dict_is_removed (EnchantDict * dict, const char *const word, ssize_t len); + + /** + * enchant_dict_store_replacement +@@ -245,7 +246,7 @@ + * that future occurrences of @mis will be replaced with @cor. So it might + * bump @cor up in the suggestion list. + */ +-void enchant_dict_store_replacement (EnchantDict * dict, ++ENCHANT_EXPORT void enchant_dict_store_replacement (EnchantDict * dict, + const char *const mis, ssize_t mis_len, + const char *const cor, ssize_t cor_len); + +@@ -256,7 +257,7 @@ + * + * Releases the string list + */ +-void enchant_dict_free_string_list (EnchantDict * dict, char **string_list); ++ENCHANT_EXPORT void enchant_dict_free_string_list (EnchantDict * dict, char **string_list); + + /** + * enchant_dict_get_error +@@ -266,7 +267,7 @@ + * WARNING: error is transient. It will likely be cleared as soon as + * the next dictionary operation is called. + */ +-const char *enchant_dict_get_error (EnchantDict * dict); ++ENCHANT_EXPORT const char *enchant_dict_get_error (EnchantDict * dict); + + /** + * enchant_dict_get_extra_word_characters +@@ -282,7 +283,7 @@ + * Note that for some back-ends the result may be a guess, in which case it + * may include characters not actually allowed in the given dictionary. + */ +-const char *enchant_dict_get_extra_word_characters (EnchantDict * dict); ++ENCHANT_EXPORT const char *enchant_dict_get_extra_word_characters (EnchantDict * dict); + + /** + * enchant_dict_is_word_character +@@ -304,7 +305,7 @@ + * If @dict is %null, a built-in implementation is used (FIXME: We should document + * behavior for this). If @n is not 0, 1 or 2, then a false flag is returned. + */ +-int enchant_dict_is_word_character (EnchantDict * dict, uint32_t uc, size_t n); ++ENCHANT_EXPORT int enchant_dict_is_word_character (EnchantDict * dict, uint32_t uc, size_t n); + + /** + * EnchantDictDescribeFn +@@ -330,7 +331,7 @@ + * + * Describes an individual dictionary + */ +-void enchant_dict_describe (EnchantDict * dict, ++ENCHANT_EXPORT void enchant_dict_describe (EnchantDict * dict, + EnchantDictDescribeFn fn, + void * user_data); + +@@ -343,7 +344,7 @@ + * Enumerates the dictionaries available from + * all Enchant providers. + */ +-void enchant_broker_list_dicts (EnchantBroker * broker, ++ENCHANT_EXPORT void enchant_broker_list_dicts (EnchantBroker * broker, + EnchantDictDescribeFn fn, + void * user_data); + +@@ -355,7 +356,7 @@ + * auto-detection does not work. + * + */ +-void enchant_set_prefix_dir(const char *); ++ENCHANT_EXPORT void enchant_set_prefix_dir(const char *); + + #ifdef __cplusplus + } +--- src/enchant-provider.h ++++ src/enchant-provider.h +@@ -62,7 +62,7 @@ + * + * The returned string must be free'd. + */ +-char *enchant_get_user_config_dir (void); ++ENCHANT_EXPORT char *enchant_get_user_config_dir (void); + + /** + * enchant_get_conf_dirs +@@ -89,7 +89,7 @@ + * + * The return value must be free'd. + */ +-char *enchant_get_prefix_dir(void); ++ENCHANT_EXPORT char *enchant_get_prefix_dir(void); + + /** + * enchant_relocate +--- providers/enchant_hunspell.cpp ++++ providers/enchant_hunspell.cpp +@@ -42,6 +42,7 @@ + #include + #include + ++#include + #include "enchant-provider.h" + #include "unused-parameter.h" + +@@ -503,7 +504,7 @@ + return "Hunspell Provider"; + } + +-EnchantProvider *init_enchant_provider (void); ++ENCHANT_MODULE_EXPORT EnchantProvider *init_enchant_provider (void); + + EnchantProvider * + init_enchant_provider (void) diff --git a/recipes/enchant/all/patches/0002-remove-strchrnul-usage.patch b/recipes/enchant/all/patches/0002-remove-strchrnul-usage.patch new file mode 100644 index 0000000000000..9a737af139e72 --- /dev/null +++ b/recipes/enchant/all/patches/0002-remove-strchrnul-usage.patch @@ -0,0 +1,33 @@ +--- src/lib.c ++++ src/lib.c +@@ -177,12 +177,17 @@ + enchant_normalize_dictionary_tag (const char * const dict_tag) + { + char * new_tag = g_strstrip (strdup (dict_tag)); ++ char * tmp; + + /* strip off en_GB@euro */ +- *strchrnul (new_tag, '@') = '\0'; ++ if ((tmp = strchr (new_tag, '@'))) { ++ *tmp = '\0'; ++ } + + /* strip off en_GB.UTF-8 */ +- *strchrnul (new_tag, '.') = '\0'; ++ if ((tmp = strchr (new_tag, '.'))) { ++ *tmp = '\0'; ++ } + + /* turn en-GB into en_GB */ + char * needle; +@@ -190,7 +195,9 @@ + *needle = '_'; + + /* everything before first '_' is converted to lower case */ +- needle = strchrnul (new_tag, '_'); ++ if (!(needle = strchr (new_tag, '_'))) { ++ return new_tag; ++ } + for (gchar *it = new_tag; it != needle; ++it) + *it = g_ascii_tolower (*it); + /* everything after first '_' is converted to upper case */ diff --git a/recipes/enchant/all/patches/0003-fix-file-locking.patch b/recipes/enchant/all/patches/0003-fix-file-locking.patch new file mode 100644 index 0000000000000..05322a067b5ce --- /dev/null +++ b/recipes/enchant/all/patches/0003-fix-file-locking.patch @@ -0,0 +1,100 @@ +--- src/pwl.c ++++ src/pwl.c +@@ -54,14 +54,24 @@ + + #include "config.h" + ++#define _DEFAULT_SOURCE 1 ++ + #include + #include + #include + #include + #include +-#include + #include + ++#if defined _WIN32 ++# include ++# include ++#elif defined HAVE_FLOCK ++# include ++#else ++# include ++#endif ++ + #include + #include + #include "enchant-provider.h" +@@ -182,8 +192,69 @@ + + static int edit_dist(const char* word1, const char* word2); + +-#define enchant_lock_file(f) flock (fileno (f), LOCK_EX) +-#define enchant_unlock_file(f) flock (fileno (f), LOCK_UN) ++static void enchant_lock_file(FILE * f) ++{ ++#if defined _WIN32 ++ const DWORD all_bits = ~(DWORD)0; ++ int descriptor = -1; ++ HANDLE handle = INVALID_HANDLE_VALUE; ++ OVERLAPPED overlapped = {0}; ++ ++ if ((descriptor = _fileno (f)) == -1) ++ goto warning; ++ ++ if ((handle = (HANDLE) _get_osfhandle (descriptor)) == INVALID_HANDLE_VALUE) ++ goto warning; ++ ++ if (LockFileEx (handle, LOCKFILE_EXCLUSIVE_LOCK, 0, all_bits, all_bits, &overlapped) == TRUE) ++ return; ++#elif defined HAVE_FLOCK ++ int descriptor = fileno (f); ++ ++ if (descriptor != -1 && flock (descriptor, LOCK_EX) == 0) ++ return; ++#else ++ int descriptor = fileno (f); ++ ++ if (descriptor != -1 && lockf (descriptor, F_LOCK, 0) == 0) ++ return; ++#endif ++ ++warning: ++ g_warning("Could not lock file\n"); ++} ++ ++static void enchant_unlock_file(FILE * f) ++{ ++#if defined _WIN32 ++ const DWORD all_bits = ~(DWORD)0; ++ int descriptor = -1; ++ HANDLE handle = INVALID_HANDLE_VALUE; ++ OVERLAPPED overlapped = {0}; ++ ++ if ((descriptor = _fileno (f)) == -1) ++ goto warning; ++ ++ if ((handle = (HANDLE) _get_osfhandle (descriptor)) == INVALID_HANDLE_VALUE) ++ goto warning; ++ ++ if (UnlockFileEx (handle, 0, all_bits, all_bits, &overlapped)) ++ return; ++#elif defined HAVE_FLOCK ++ int descriptor = fileno (f); ++ ++ if (descriptor != -1 && flock (descriptor, LOCK_UN) == 0) ++ return; ++#else ++ int descriptor = fileno (f); ++ ++ if (descriptor != -1 && lockf (descriptor, F_ULOCK, 0) == 0) ++ return; ++#endif ++ ++warning: ++ g_warning("Could not unlock file\n"); ++} + + /** + * enchant_pwl_init diff --git a/recipes/enchant/all/patches/0004-fix-ssize_t-in-headers.patch b/recipes/enchant/all/patches/0004-fix-ssize_t-in-headers.patch new file mode 100644 index 0000000000000..51400604efabd --- /dev/null +++ b/recipes/enchant/all/patches/0004-fix-ssize_t-in-headers.patch @@ -0,0 +1,13 @@ +--- src/enchant.h ++++ src/enchant.h +@@ -34,6 +34,10 @@ + #include /* for uint32_t */ + #include /* for size_t, ssize_t */ + ++#ifdef _WIN32 ++# include ++# define ssize_t SSIZE_T ++#endif + + #ifdef __cplusplus + extern "C" { diff --git a/recipes/enchant/all/patches/0005-fix-relocatable.patch b/recipes/enchant/all/patches/0005-fix-relocatable.patch new file mode 100644 index 0000000000000..299998652be31 --- /dev/null +++ b/recipes/enchant/all/patches/0005-fix-relocatable.patch @@ -0,0 +1,10 @@ +--- lib/relocatable.c ++++ lib/relocatable.c +@@ -25,6 +25,7 @@ + + #define _GL_USE_STDLIB_ALLOC 1 + #include ++#include + + /* Specification. */ + #include "relocatable.h" diff --git a/recipes/enchant/all/patches/0006-add-macos-support.patch b/recipes/enchant/all/patches/0006-add-macos-support.patch new file mode 100644 index 0000000000000..372732b910dfb --- /dev/null +++ b/recipes/enchant/all/patches/0006-add-macos-support.patch @@ -0,0 +1,51 @@ +--- lib/relocatable.c ++++ lib/relocatable.c +@@ -37,6 +37,10 @@ + #include + #include + ++#ifdef HAVE_DLADDR ++# include ++#endif ++ + #ifdef NO_XMALLOC + # define xmalloc malloc + #else +@@ -389,6 +393,19 @@ + return 1; + } + ++#elif defined HAVE_DLADDR ++ ++static Dl_info lib_info; ++ ++static void ++find_shared_library_fullname (void) ++{ ++ if (dladdr (&lib_info, &lib_info)) ++ { ++ shared_library_fullname = strdup (lib_info.dli_fname); ++ } ++} ++ + #else /* Unix */ + + static void +@@ -444,7 +461,7 @@ + #endif + } + +-#endif /* Native Windows / EMX / Unix */ ++#endif /* Native Windows / EMX / BSD / Unix */ + + /* Return the full pathname of the current shared library. + Return NULL if unknown. +@@ -452,7 +469,7 @@ + static char * + get_shared_library_fullname () + { +-#if !(defined _WIN32 && !defined __CYGWIN__) && !defined __EMX__ ++#if (!(defined _WIN32 && !defined __CYGWIN__) && !defined __EMX__) || defined HAVE_DLADDR + static bool tried_find_shared_library_fullname; + if (!tried_find_shared_library_fullname) + { diff --git a/recipes/enchant/all/test_package/CMakeLists.txt b/recipes/enchant/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..71e01b224abd1 --- /dev/null +++ b/recipes/enchant/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS KEEP_RPATHS) + +find_package(enchant REQUIRED CONFIG) + +add_executable(test_package test_package.c) +target_link_libraries(test_package PRIVATE enchant::enchant) diff --git a/recipes/enchant/all/test_package/conanfile.py b/recipes/enchant/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a8c92dea63335 --- /dev/null +++ b/recipes/enchant/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/enchant/all/test_package/test_package.c b/recipes/enchant/all/test_package/test_package.c new file mode 100644 index 0000000000000..3fdb81bea3e70 --- /dev/null +++ b/recipes/enchant/all/test_package/test_package.c @@ -0,0 +1,48 @@ +#include +#include +#include + +static void for_each_provider(const char* const provider_name, + const char* const provider_desc, + const char* const provider_dll_file, + void* user_data) +{ + (void)provider_desc; + (void)provider_dll_file; + + ++*(int*)user_data; + (void)puts(provider_name); +} + +int main(void) +{ + EnchantBroker* broker = enchant_broker_init(); + char* prefix_dir = NULL; + int counter = 0; + int return_code = 0; + + if (broker == NULL) { + (void)fputs("Failed to init the broker", stderr); + return 1; + } + + (void)puts("Providers found:"); + enchant_broker_describe(broker, for_each_provider, &counter); + if (counter == 0) { + (void)puts("(none)"); + } + /* NOTE: this is temporary, since the recipe always uses the hunspell + * provider */ + if (counter != 1) { + (void)fflush(stdout); + (void)fprintf(stderr, + "Expected to find exactly 1 provider, found %d\n", + counter); + return_code = 1; + } else { + (void)printf("\nenchant version %s\n", enchant_get_version()); + } + + enchant_broker_free(broker); + return return_code; +} diff --git a/recipes/enchant/config.yml b/recipes/enchant/config.yml new file mode 100644 index 0000000000000..aee8de619ec30 --- /dev/null +++ b/recipes/enchant/config.yml @@ -0,0 +1,3 @@ +versions: + "2.3.2": + folder: all diff --git a/recipes/enet/all/CMakeLists.txt b/recipes/enet/all/CMakeLists.txt deleted file mode 100644 index 1848ca5a77c35..0000000000000 --- a/recipes/enet/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/enet/all/conandata.yml b/recipes/enet/all/conandata.yml index 923a0ea5f456a..872fdb0986138 100644 --- a/recipes/enet/all/conandata.yml +++ b/recipes/enet/all/conandata.yml @@ -1,26 +1,22 @@ sources: - "1.3.14": - url: "http://enet.bespin.org/download/enet-1.3.14.tar.gz" - sha256: "98f6f57aab0a424469619ed3047728f0d3901ce8f0dea919c11e7966d807e870" - "1.3.15": - url: "https://github.com/lsalzman/enet/archive/v1.3.15.tar.gz" - sha256: "e749887a19b5a4a0a16daae2d695fd7ed581ec517f3b15aedc3cdce2d999d471" - "1.3.16": - url: "https://github.com/lsalzman/enet/archive/v1.3.16.tar.gz" - sha256: "b3aa85b43e4309fec9441b4e6639c268e22962a578bd5e2307bb3a7b6fe73714" "1.3.17": url: "https://github.com/lsalzman/enet/archive/v1.3.17.tar.gz" sha256: "1e0b4bc0b7127a2d779dd7928f0b31830f5b3dcb7ec9588c5de70033e8d2434a" -patches: - "1.3.14": - - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" + "1.3.16": + url: "https://github.com/lsalzman/enet/archive/v1.3.16.tar.gz" + sha256: "b3aa85b43e4309fec9441b4e6639c268e22962a578bd5e2307bb3a7b6fe73714" "1.3.15": + url: "https://github.com/lsalzman/enet/archive/v1.3.15.tar.gz" + sha256: "e749887a19b5a4a0a16daae2d695fd7ed581ec517f3b15aedc3cdce2d999d471" + "1.3.14": + url: "http://enet.bespin.org/download/enet-1.3.14.tar.gz" + sha256: "98f6f57aab0a424469619ed3047728f0d3901ce8f0dea919c11e7966d807e870" +patches: + "1.3.17": - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" "1.3.16": - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" - "1.3.17": + "1.3.15": + - patch_file: "patches/fix-cmake.patch" + "1.3.14": - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" diff --git a/recipes/enet/all/conanfile.py b/recipes/enet/all/conanfile.py index 7d37bf00f70c6..9cc3b378394fc 100644 --- a/recipes/enet/all/conanfile.py +++ b/recipes/enet/all/conanfile.py @@ -1,23 +1,33 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.microsoft import is_msvc import os +required_conan_version = ">=1.50.0" + class EnetConan(ConanFile): name = "enet" description = "ENet reliable UDP networking library" - topics = ("conan", "enet", "udp", "networking") + topics = ("enet", "udp", "networking") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/lsalzman/enet" license = "MIT" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -26,35 +36,43 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + # Relocatable shared lib on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - include_folder = os.path.join(self._source_subfolder, "include") - self.copy(pattern="*", dst="include", src=include_folder) - self.copy(pattern="*.lib", dst="lib", src="lib", keep_path=False) - self.copy(pattern="*.a", dst="lib", src="lib", keep_path=False) - self.copy(pattern="*.dylib", dst="lib", src="lib", keep_path=False) - self.copy(pattern="*.so*", dst="lib", src="lib", keep_path=False, symlinks=True) - self.copy(pattern="*.dll", dst="bin", src="bin", keep_path=False) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() def package_info(self): - self.cpp_info.names["pkg_config"] = "libenet" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("pkg_config_name", "libenet") + self.cpp_info.libs = ["enet"] if self.settings.os == "Windows": self.cpp_info.system_libs.extend(["ws2_32", "winmm"]) - if self.settings.compiler == "Visual Studio" and self.options.shared: + if is_msvc(self) and self.options.shared: self.cpp_info.defines.append("ENET_DLL") diff --git a/recipes/enet/all/patches/fix-cmake.patch b/recipes/enet/all/patches/fix-cmake.patch index 198b1bd824329..2355cb635cfd6 100644 --- a/recipes/enet/all/patches/fix-cmake.patch +++ b/recipes/enet/all/patches/fix-cmake.patch @@ -1,6 +1,6 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -84,11 +84,15 @@ set(SOURCE_FILES +@@ -84,11 +84,27 @@ set(SOURCE_FILES source_group(include FILES ${INCLUDE_FILES}) source_group(source FILES ${SOURCE_FILES}) @@ -18,3 +18,15 @@ +if(WIN32) target_link_libraries(enet winmm ws2_32) endif() ++ ++include(GNUInstallDirs) ++install( ++ TARGETS enet ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++) ++install( ++ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/enet ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ++) diff --git a/recipes/enet/all/test_package/CMakeLists.txt b/recipes/enet/all/test_package/CMakeLists.txt index 196188113685c..4d708d2778b59 100644 --- a/recipes/enet/all/test_package/CMakeLists.txt +++ b/recipes/enet/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(enet REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE enet::enet) diff --git a/recipes/enet/all/test_package/conanfile.py b/recipes/enet/all/test_package/conanfile.py index bd7165a553cf4..3a8c6c5442b33 100644 --- a/recipes/enet/all/test_package/conanfile.py +++ b/recipes/enet/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/enet/all/test_package/test_package.cpp b/recipes/enet/all/test_package/test_package.c similarity index 100% rename from recipes/enet/all/test_package/test_package.cpp rename to recipes/enet/all/test_package/test_package.c diff --git a/recipes/enet/all/test_v1_package/CMakeLists.txt b/recipes/enet/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a9be27f4a22a2 --- /dev/null +++ b/recipes/enet/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(enet REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE enet::enet) diff --git a/recipes/enet/all/test_v1_package/conanfile.py b/recipes/enet/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/enet/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/enet/config.yml b/recipes/enet/config.yml index dde9a60b0bacb..1e0720325112a 100644 --- a/recipes/enet/config.yml +++ b/recipes/enet/config.yml @@ -1,9 +1,9 @@ versions: - "1.3.14": - folder: all - "1.3.15": + "1.3.17": folder: all "1.3.16": folder: all - "1.3.17": + "1.3.15": + folder: all + "1.3.14": folder: all diff --git a/recipes/enhex-generic_serialization/all/conandata.yml b/recipes/enhex-generic_serialization/all/conandata.yml new file mode 100644 index 0000000000000..5c26732b3e9b0 --- /dev/null +++ b/recipes/enhex-generic_serialization/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.0": + url: "https://github.com/Enhex/generic_serialization/archive/refs/tags/v1.0.0.zip" + sha256: a3a09fb0c026662a06075fbcf993458d9611db03cb8fdc6db31268afa9314400 diff --git a/recipes/enhex-generic_serialization/all/conanfile.py b/recipes/enhex-generic_serialization/all/conanfile.py new file mode 100644 index 0000000000000..9dbb338a5b3f4 --- /dev/null +++ b/recipes/enhex-generic_serialization/all/conanfile.py @@ -0,0 +1,50 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +class EnhexGenericserializationConan(ConanFile): + name = "enhex-generic_serialization" + license = "MIT" + description = "Lightweight and extensible generic serialization library" + topics = ("serialization") + homepage = "https://github.com/Enhex/generic_serialization" + url = "https://github.com/conan-io/conan-center-index" + no_copy_source = True + settings = ("compiler") + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 17) + + minimal_version = { + "Visual Studio": "15", + "gcc": "7", + "clang": "5.0", + "apple-clang": "9.1" + } + compiler = str(self.settings.compiler) + compiler_version = tools.Version(self.settings.compiler.version) + + if compiler not in minimal_version: + self.output.info("{} requires a compiler that supports at least C++17".format(self.name)) + return + + # Exclude compilers not supported + if compiler_version < minimal_version[compiler]: + raise ConanInvalidConfiguration("{} requires a compiler that supports at least C++17. {} {} is not".format( + self.name, compiler, tools.Version(self.settings.compiler.version.value))) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + + def package_id(self): + self.info.header_only() diff --git a/recipes/enhex-generic_serialization/all/test_package/CMakeLists.txt b/recipes/enhex-generic_serialization/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..60c63e2f06ba6 --- /dev/null +++ b/recipes/enhex-generic_serialization/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(enhex-generic_serialization CONFIG REQUIRED) + +add_executable(example example.cpp) +target_link_libraries(example enhex-generic_serialization::enhex-generic_serialization) +set_target_properties(example PROPERTIES CXX_STANDARD 17) diff --git a/recipes/enhex-generic_serialization/all/test_package/conanfile.py b/recipes/enhex-generic_serialization/all/test_package/conanfile.py new file mode 100644 index 0000000000000..6ab1666628a5d --- /dev/null +++ b/recipes/enhex-generic_serialization/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class EnhexGenericserializationTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/enhex-generic_serialization/all/test_package/example.cpp b/recipes/enhex-generic_serialization/all/test_package/example.cpp new file mode 100644 index 0000000000000..8f8955be3a79d --- /dev/null +++ b/recipes/enhex-generic_serialization/all/test_package/example.cpp @@ -0,0 +1,123 @@ +#define _CRT_SECURE_NO_WARNINGS + +#include +#include +#include + +using namespace std; + + +// Example for serializing a POD type (without references/pointers since memory addresses change) +struct Vector3 { + float x, y, z; + + void print() const { + std::cout << + "x: " << x << '\n' << + "x: " << y << '\n' << + "y: " << z << '\n'; + } +}; + +namespace gs +{ +template +void serialize(Stream& stream, Vector3& value) { + gs::read_or_write_bytes(stream, value); +} +} + + +// example class +struct A +{ + int x = 0; + float y = 0; + char z[3]; + Vector3 vec3; + + void print() const { + cout + << "x: " << x << '\n' + << "x: " << y << '\n' + << "z: " << z << '\n' + << "vec3:\n"; + vec3.print(); + + } +}; + +namespace gs +{ + //TODO alternatively can be a member function so we don't have to pass A and we can access members directly. Requires using SFINAE to check if the method is available. + template + void serialize(Stream& stream, A& value) { + // choose which members to serialize + gs::serializer(stream, value.x, value.y, value.z, value.vec3); // members' types' already have serialization implemented + } +} + + +#include + + +namespace test +{ + void serialization() + { + A a; + + a.x = 5; + a.y = 7.5; + a.z[0] = 'a'; + a.z[1] = 'b'; + a.z[2] = '\0'; + a.vec3 = { 1,2,3 }; + + puts("writing:"); + puts("========"); + a.print(); + putchar('\n'); + + // serialize to file + { + ofstream f("test", ofstream::binary); + gs::serializer(f, a); + } + + a.x = 0; + a.y = 0; + a.z[0] = '0'; + a.z[1] = '0'; + a.vec3 = { 0,0,0 }; + + // read back from file + { + ifstream f("test", ios::binary); + gs::serializer(f, a); + } + + puts("reading:"); + puts("========"); + a.print(); + putchar('\n'); + + assert(a.x == 5); + assert(a.y == 7.5); + assert(a.z[0] == 'a'); + assert(a.z[1] == 'b'); + assert(a.z[2] == '\0'); + assert(a.vec3.x == 1); + assert(a.vec3.y == 2); + assert(a.vec3.z == 3); + } +} + + +int main() +{ + puts("Serialization test"); + puts("=================="); + + test::serialization(); +} diff --git a/recipes/enhex-generic_serialization/config.yml b/recipes/enhex-generic_serialization/config.yml new file mode 100644 index 0000000000000..c7f13630776fb --- /dev/null +++ b/recipes/enhex-generic_serialization/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.0": + folder: "all" diff --git a/recipes/enhex-strong_type/all/conandata.yml b/recipes/enhex-strong_type/all/conandata.yml new file mode 100644 index 0000000000000..4f41faaea9d53 --- /dev/null +++ b/recipes/enhex-strong_type/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.0": + url: "https://github.com/Enhex/strong_type/archive/refs/tags/v1.0.0.zip" + sha256: b7897146f8dfa12bfe466147760840f1d1631754f6ba3672542f8a0bb3372856 diff --git a/recipes/enhex-strong_type/all/conanfile.py b/recipes/enhex-strong_type/all/conanfile.py new file mode 100644 index 0000000000000..40601c5f9d3e8 --- /dev/null +++ b/recipes/enhex-strong_type/all/conanfile.py @@ -0,0 +1,50 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +class EnhexStrongTypeConan(ConanFile): + name = "enhex-strong_type" + license = "MIT" + description = "Create new type from existing type without changing the interface." + topics = ("strong_type", "safety") + homepage = "https://github.com/Enhex/strong_type" + url = "https://github.com/conan-io/conan-center-index" + no_copy_source = True + settings = ("compiler") + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 17) + + minimal_version = { + "Visual Studio": "15", + "gcc": "7", + "clang": "5.0", + "apple-clang": "9.1" + } + compiler = str(self.settings.compiler) + compiler_version = tools.Version(self.settings.compiler.version) + + if compiler not in minimal_version: + self.output.info("{} requires a compiler that supports at least C++17".format(self.name)) + return + + # Exclude compilers not supported + if compiler_version < minimal_version[compiler]: + raise ConanInvalidConfiguration("{} requires a compiler that supports at least C++17. {} {} is not".format( + self.name, compiler, tools.Version(self.settings.compiler.version.value))) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + + def package_id(self): + self.info.header_only() diff --git a/recipes/enhex-strong_type/all/test_package/CMakeLists.txt b/recipes/enhex-strong_type/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ee8f5992e5656 --- /dev/null +++ b/recipes/enhex-strong_type/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(enhex-strong_type CONFIG REQUIRED) + +add_executable(example example.cpp) +target_link_libraries(example enhex-strong_type::enhex-strong_type) +set_target_properties(example PROPERTIES CXX_STANDARD 17) diff --git a/recipes/enhex-strong_type/all/test_package/conanfile.py b/recipes/enhex-strong_type/all/test_package/conanfile.py new file mode 100644 index 0000000000000..c48d1d23bfccd --- /dev/null +++ b/recipes/enhex-strong_type/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class EnhexStrongTypeTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/enhex-strong_type/all/test_package/example.cpp b/recipes/enhex-strong_type/all/test_package/example.cpp new file mode 100644 index 0000000000000..f99b50095864c --- /dev/null +++ b/recipes/enhex-strong_type/all/test_package/example.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +using namespace std; + +STRONG_TYPE(ST, string); + +int main() +{ + ST st = "strong_type"; + cout << "hello " << st << "!\n"; +} diff --git a/recipes/enhex-strong_type/config.yml b/recipes/enhex-strong_type/config.yml new file mode 100644 index 0000000000000..c7f13630776fb --- /dev/null +++ b/recipes/enhex-strong_type/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.0": + folder: "all" diff --git a/recipes/enjincppsdk/all/CMakeLists.txt b/recipes/enjincppsdk/all/CMakeLists.txt new file mode 100644 index 0000000000000..9d48e327cd88a --- /dev/null +++ b/recipes/enjincppsdk/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory("source_subfolder") diff --git a/recipes/enjincppsdk/all/conandata.yml b/recipes/enjincppsdk/all/conandata.yml new file mode 100644 index 0000000000000..51b1a6998b1de --- /dev/null +++ b/recipes/enjincppsdk/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "1.0.0-beta.1": + url: "https://github.com/enjin/enjin-cpp-sdk/archive/1.0.0.2000.tar.gz" + sha256: "ba1ea4800a73dc25e0e5261108cf7245531ec5bfd3a12b989f72cf5c23778d7e" + "1.0.0-alpha.7": + url: "https://github.com/enjin/enjin-cpp-sdk/archive/1.0.0.1006.tar.gz" + sha256: "3b75bf2bb5b0fb9dc995e7c319dc0795d3bee802ebdbd7ed5565a944bf87f6ec" + "1.0.0-alpha.6": + url: "https://github.com/enjin/enjin-cpp-sdk/archive/1.0.0.1005.tar.gz" + sha256: "18c064089ee9dd4bbd3f98329fab38e6c4e8c46284c39d07269222be58fa6eb3" + "1.0.0-alpha.5": + url: "https://github.com/enjin/enjin-cpp-sdk/archive/1.0.0.1004.tar.gz" + sha256: "37affa40d5509cdd3c9133f0d9517f2e90ce4a86fd6342367423d5602ea3879e" diff --git a/recipes/enjincppsdk/all/conanfile.py b/recipes/enjincppsdk/all/conanfile.py new file mode 100644 index 0000000000000..172ca8e02037d --- /dev/null +++ b/recipes/enjincppsdk/all/conanfile.py @@ -0,0 +1,136 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.43.0" + + +class EnjinCppSdk(ConanFile): + name = "enjincppsdk" + description = "A C++ SDK for development on the Enjin blockchain platform." + license = "Apache-2.0" + topics = ("enjin", "sdk", "blockchain") + homepage = "https://github.com/enjin/enjin-cpp-sdk" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "compiler", "arch", "build_type" + generators = "cmake", "cmake_find_package", "cmake_find_package_multi" + + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_default_http_client": [True, False], + "with_default_ws_client": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_default_http_client": False, + "with_default_ws_client": False, + } + + _cmake = None + short_paths = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "gcc": "9", + "clang": "10", + } + + def export_sources(self): + self.copy("CMakeLists.txt") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + if self.options.with_default_http_client: + self.options["cpp-httplib"].with_openssl = True + + self.options["spdlog"].header_only = True + + def requirements(self): + if self.options.with_default_http_client: + self.requires("cpp-httplib/0.8.5") + + if self.options.with_default_ws_client: + self.requires("ixwebsocket/11.0.4") + + self.requires("rapidjson/1.1.0") + self.requires("spdlog/1.8.2") + + def build_requirements(self): + self.build_requires("cmake/3.16.9") + + def validate(self): + # Validations for OS + if self.settings.os == "Macos": + raise ConanInvalidConfiguration("macOS is not supported at this time. Contributions are welcomed.") + + # Validations for minimum required C++ standard + compiler = self.settings.compiler + + if compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 17) + + minimum_version = self._minimum_compilers_version.get(str(compiler), False) + if not minimum_version: + self.output.warn("C++17 support is required. Your compiler is unknown. Assuming it supports C++17.") + elif tools.Version(compiler.version) < minimum_version: + raise ConanInvalidConfiguration("C++17 support is required, which your compiler does not support.") + + if compiler == "clang" and compiler.libcxx != "libstdc++11": + raise ConanInvalidConfiguration("libstdc++11 is required for clang.") + + # Validations for dependencies + if not self.options["spdlog"].header_only: + raise ConanInvalidConfiguration(f"{self.name} requires spdlog:header_only=True to be enabled.") + + if self.options.with_default_http_client and not self.options["cpp-httplib"].with_openssl: + raise ConanInvalidConfiguration(f"{self.name} requires cpp-httplib:with_openssl=True when using " + f"with_default_http_client=True.") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + + self._cmake = CMake(self) + self._cmake.definitions["ENJINSDK_BUILD_SHARED"] = self.options.shared + self._cmake.definitions["ENJINSDK_BUILD_TESTS"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE*", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "enjinsdk")) + + def package_info(self): + self.cpp_info.set_property("cmake_target_name", "enjinsdk::enjinsdk") + self.cpp_info.names["cmake_find_package"] = "enjinsdk" + self.cpp_info.names["cmake_find_package_multi"] = "enjinsdk" + self.cpp_info.libs = ["enjinsdk"] diff --git a/recipes/enjincppsdk/all/test_package/CMakeLists.txt b/recipes/enjincppsdk/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..30e76e5090606 --- /dev/null +++ b/recipes/enjincppsdk/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(enjinsdk REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} enjinsdk::enjinsdk) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) diff --git a/recipes/enjincppsdk/all/test_package/conanfile.py b/recipes/enjincppsdk/all/test_package/conanfile.py new file mode 100644 index 0000000000000..4a5eb7410ea85 --- /dev/null +++ b/recipes/enjincppsdk/all/test_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.43.0" + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/enjincppsdk/all/test_package/test_package.cpp b/recipes/enjincppsdk/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4d2320a487e90 --- /dev/null +++ b/recipes/enjincppsdk/all/test_package/test_package.cpp @@ -0,0 +1,90 @@ +#include "enjinsdk/GraphqlQueryRegistry.hpp" +#include "enjinsdk/models/AccessToken.hpp" +#include "enjinsdk/project/AuthProject.hpp" +#include +#include +#include +#include +#include + +using namespace enjin::sdk::graphql; +using namespace enjin::sdk::models; +using namespace enjin::sdk::project; + +void test_model_deserialization(); + +void test_query_registry(); + +void test_request_serialization(); + +int main() { + test_model_deserialization(); + test_query_registry(); + test_request_serialization(); + + return 0; +} + +void test_model_deserialization() { + const std::string token = "xyz"; + const long expiration = 100L; + + std::stringstream json_stream; + json_stream << R"({"accessToken":")" << token << R"(","expiresIn":)" << expiration << R"(})"; + const std::string json = json_stream.str(); + + AccessToken access_token; + access_token.deserialize(json); + + const std::optional & token_opt = access_token.get_token(); + if (!token_opt.has_value()) { + throw std::runtime_error(R"(Field "token" was not serialized)"); + } + + const std::optional& expiration_opt = access_token.get_expires_in(); + if (!expiration_opt.has_value()) { + throw std::runtime_error(R"(Field "expiresIn" was not serialized)"); + } + + std::cout << "AccessToken result:" + << "\n* token: [" << token_opt.value() << "] (expected: [" << token << "])" + << "\n* expiresIn: [" << expiration_opt.value() << "] (expected: [" << expiration << "])" + << "\n" << std::endl; +} + +void test_query_registry() { + const GraphqlQueryRegistry registry; + const AuthProject req; + + const std::string& req_namespace = req.get_namespace(); + const bool has_operation = registry.has_operation_for_name(req_namespace); + + if (!has_operation) { + throw std::runtime_error("Could not find operation for namespace \"" + req_namespace + "\""); + } + + std::cout << "GraphqlQueryRegistry result:" + << "\n* Found operation for namespace \"" << req_namespace << "\"" + << "\n" << std::endl; +} + +void test_request_serialization() { + const std::string uuid = "TestUuid"; + const std::string secret = "TestSecret"; + + AuthProject req = AuthProject().set_uuid(uuid).set_secret(secret); + const std::string req_json = req.serialize(); + + if (req_json.find(uuid) == std::string::npos) { + throw std::runtime_error("Did not find UUID in serialized JSON"); + } + + if (req_json.find(secret) == std::string::npos) { + throw std::runtime_error("Did not find secret in serialized JSON"); + } + + std::cout << "AuthProject result:" + << "\n* Request JSON: " << req_json + << "\n* Found UUID and secret in serialized JSON" + << "\n" << std::endl; +} diff --git a/recipes/enjincppsdk/config.yml b/recipes/enjincppsdk/config.yml new file mode 100644 index 0000000000000..cd6f8cc467b7b --- /dev/null +++ b/recipes/enjincppsdk/config.yml @@ -0,0 +1,9 @@ +versions: + "1.0.0-beta.1": + folder: all + "1.0.0-alpha.7": + folder: all + "1.0.0-alpha.6": + folder: all + "1.0.0-alpha.5": + folder: all diff --git a/recipes/enkits/all/conandata.yml b/recipes/enkits/all/conandata.yml index a7800edfecfae..9604c7fcf2b72 100644 --- a/recipes/enkits/all/conandata.yml +++ b/recipes/enkits/all/conandata.yml @@ -1,8 +1,20 @@ sources: + "1.11": + url: "https://github.com/dougbinks/enkiTS/archive/v1.11.tar.gz" + sha256: "b57a782a6a68146169d29d180d3553bfecb9f1a0e87a5159082331920e7d297e" + "1.10": + url: "https://github.com/dougbinks/enkiTS/archive/v1.10.tar.gz" + sha256: "578f285fc7c2744bf831548f35b855c6ab06c0d541d08c9cc50b6b72a250811a" "1.8": url: "https://github.com/dougbinks/enkiTS/archive/v1.8.zip" sha256: "b96d8d439502d52f9dc419539b12b588df10750f4631ad5518586f7048cdfaef" patches: + "1.11": + - patch_file: "patches/cmake-install-lib-location.patch" + base_path: "source_subfolder" + "1.10": + - patch_file: "patches/cmake-install-lib-location.patch" + base_path: "source_subfolder" "1.8": - patch_file: "patches/cmake-install-lib-location.patch" base_path: "source_subfolder" diff --git a/recipes/enkits/config.yml b/recipes/enkits/config.yml index a9ab800606ddf..a23bb21b6345f 100644 --- a/recipes/enkits/config.yml +++ b/recipes/enkits/config.yml @@ -1,3 +1,7 @@ versions: + "1.11": + folder: all + "1.10": + folder: all "1.8": folder: all diff --git a/recipes/entityx/all/CMakeLists.txt b/recipes/entityx/all/CMakeLists.txt deleted file mode 100644 index bd3083b512cb9..0000000000000 --- a/recipes/entityx/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/entityx/all/conandata.yml b/recipes/entityx/all/conandata.yml index db83ec1fb0725..2b201a5dfe96a 100644 --- a/recipes/entityx/all/conandata.yml +++ b/recipes/entityx/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "1.3.0": - patch_file: "patches/0001-cmake-not-force-libcpp.patch" - base_path: "source_subfolder" diff --git a/recipes/entityx/all/conanfile.py b/recipes/entityx/all/conanfile.py index 2ac47ba895c8c..5f5cad42e9c30 100644 --- a/recipes/entityx/all/conanfile.py +++ b/recipes/entityx/all/conanfile.py @@ -1,20 +1,26 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.microsoft import is_msvc import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration - - -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.50.0" class EntityXConan(ConanFile): name = "entityx" + description = ( + "EntityX is an EC system that uses C++11 features to provide type-safe " + "component management, event delivery, etc." + ) url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/alecthomas/entityx/" - topics = ("entity", "c++11", "type-safe", "component", "conan") + topics = ("entity", "c++11", "type-safe", "component") license = "MIT" - description = "EntityX is an EC system that uses C++11 features to provide type-safe component management, event delivery, etc." - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -23,19 +29,10 @@ class EntityXConan(ConanFile): "shared": False, "fPIC": True, } - generators = "cmake" - - exports_sources = "CMakeLists.txt", "patches/**" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -45,40 +42,41 @@ def configure(self): if self.options.shared: del self.options.fPIC + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("entityx-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) def validate(self): - if self.settings.compiler == "Visual Studio" and self.options.shared: + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + if is_msvc(self) and self.info.options.shared: raise ConanInvalidConfiguration("entityx shared library does not export all symbols with Visual Studio") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENTITYX_BUILD_SHARED"] = self.options.shared - self._cmake.definitions["ENTITYX_BUILD_TESTING"] = False - self._cmake.definitions["ENTITYX_RUN_BENCHMARKS"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENTITYX_BUILD_SHARED"] = self.options.shared + tc.variables["ENTITYX_BUILD_TESTING"] = False + tc.variables["ENTITYX_RUN_BENCHMARKS"] = False + # Relocatable shared lib on macOS + tc.variables["CMAKE_MACOSX_RPATH"] = True + tc.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy("COPYING", src=self._source_subfolder, dst="licenses", keep_path=False) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["pkg_config"] = "entityx" - debug = "-d" if self.settings.build_type == "Debug" else "" - self.cpp_info.libs = ["entityx{}".format(debug)] + self.cpp_info.set_property("pkg_config_name", "entityx") + suffix = "-d" if self.settings.build_type == "Debug" else "" + self.cpp_info.libs = [f"entityx{suffix}"] diff --git a/recipes/entityx/all/test_package/CMakeLists.txt b/recipes/entityx/all/test_package/CMakeLists.txt index 80c2cc28e5114..3469e1c7a6f88 100644 --- a/recipes/entityx/all/test_package/CMakeLists.txt +++ b/recipes/entityx/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(entityx REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} entityx::entityx) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE entityx::entityx) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/entityx/all/test_package/conanfile.py b/recipes/entityx/all/test_package/conanfile.py index 6c9d5dba712c7..d120a992c06a6 100644 --- a/recipes/entityx/all/test_package/conanfile.py +++ b/recipes/entityx/all/test_package/conanfile.py @@ -1,9 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/entityx/all/test_v1_package/CMakeLists.txt b/recipes/entityx/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2d78aabc2eace --- /dev/null +++ b/recipes/entityx/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(entityx REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE entityx::entityx) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/entityx/all/test_v1_package/conanfile.py b/recipes/entityx/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/entityx/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/entt/3.x.x/conandata.yml b/recipes/entt/3.x.x/conandata.yml index d60890b304acb..b55145bf44224 100644 --- a/recipes/entt/3.x.x/conandata.yml +++ b/recipes/entt/3.x.x/conandata.yml @@ -1,34 +1,67 @@ sources: - "3.2.2": - url: https://github.com/skypjack/entt/archive/v3.2.2.tar.gz - sha256: 94592270b6750dd0b057a4af9d2c1ea8798369b3bb127927a8f70db232808f93 - "3.3.0": - url: https://github.com/skypjack/entt/archive/v3.3.0.tar.gz - sha256: d21a45df4960adc86a8f23a8c3c0cea6d2cecc4ef6946a8040e336d8e5266ab3 - "3.3.1": - url: https://github.com/skypjack/entt/archive/v3.3.1.tar.gz - sha256: 432f31a80fb0463960dfd36e103c206dd67f1bfa91fc48408594c28aa790a3f5 - "3.3.2": - url: https://github.com/skypjack/entt/archive/v3.3.2.tar.gz - sha256: 150cd89b45bffbcd7643d39bbce282e8fa38307bb5ed25567b79e337376ba1c7 - "3.4.0": - url: https://github.com/skypjack/entt/archive/v3.4.0.tar.gz - sha256: 07086b8c5b1d84a1b76b39b0ce257c36c4f1521b77e664368b3d5ca7c00264e2 - "3.5.0": - url: https://github.com/skypjack/entt/archive/v3.5.0.tar.gz - sha256: 89cba5ddf90bcec0dcf8d9554d9acf5ad86f5ce305e3acacf795007ee65c93f8 - "3.5.1": - url: https://github.com/skypjack/entt/archive/v3.5.1.tar.gz - sha256: f442ece6881ec24863e7f0fbdc4bf641e01b0f87955f49dc4687b2fa564e9c83 - "3.5.2": - url: https://github.com/skypjack/entt/archive/v3.5.2.tar.gz - sha256: f9271293c44518386c402c9a2188627819748f66302df48af4f6d08e30661036 - "3.6.0": - url: https://github.com/skypjack/entt/archive/v3.6.0.tar.gz - sha256: 94b7dc874acd0961cfc28cf6b0342eeb0b7c58250ddde8bdc6c101e84b74c190 - "3.7.0": - url: https://github.com/skypjack/entt/archive/refs/tags/v3.7.0.tar.gz - sha256: 39ad5c42acf3434f8c37e0baa18a8cb562c0845383a6b4da17fdbacc9f0a7695 + "3.11.1": + url: "https://github.com/skypjack/entt/archive/refs/tags/v3.11.1.tar.gz" + sha256: "0ac010f232d3089200c5e545bcbd6480cf68b705de6930d8ff7cdb0a29f5b47b" + "3.11.0": + url: "https://github.com/skypjack/entt/archive/refs/tags/v3.11.0.tar.gz" + sha256: "7cca2bd4d4aeef6c5bdbe06b9e047e7f2519ebaff901207cc81ac71a2bbe185e" + "3.10.3": + url: "https://github.com/skypjack/entt/archive/refs/tags/v3.10.3.tar.gz" + sha256: "315918fc678e89a326ce1c13b0e9d3e53882dd9c58a63fef413325917a5c753b" + "3.10.1": + url: "https://github.com/skypjack/entt/archive/refs/tags/v3.10.1.tar.gz" + sha256: "f7031545130bfc06f5fe6b2f8c87dcbd4c1254fab86657e2788b70dfeea57965" + "3.10.0": + url: "https://github.com/skypjack/entt/archive/refs/tags/v3.10.0.tar.gz" + sha256: "4c716cebf4f2964824da158dd58cc81d9f1e056a083538e22fb03ae2d64805ee" + "3.9.0": + url: "https://github.com/skypjack/entt/archive/refs/tags/v3.9.0.tar.gz" + sha256: "1b06f1f6627c3702486855877bdeab6885f5d821d3dd78862126d4308c627c23" + "3.8.1": + url: "https://github.com/skypjack/entt/archive/v3.8.1.tar.gz" + sha256: "a2b767f06bca67a73a4d71fb9ebb6ed823bb5146faad3c282b9dbbbdae1aa01b" + "3.8.0": + url: "https://github.com/skypjack/entt/archive/refs/tags/v3.8.0.tar.gz" + sha256: "71c8ff5a604e8e214571a8b2218dfeaf61be59e2fe2ff5b550b4810c37d4da3c" "3.7.1": - url: https://github.com/skypjack/entt/archive/refs/tags/v3.7.1.tar.gz - sha256: fe3ce773c17797c0c57ffa97f73902854fcc8e7afc7e09bea373e0c64fa24a23 + url: "https://github.com/skypjack/entt/archive/refs/tags/v3.7.1.tar.gz" + sha256: "fe3ce773c17797c0c57ffa97f73902854fcc8e7afc7e09bea373e0c64fa24a23" + "3.7.0": + url: "https://github.com/skypjack/entt/archive/refs/tags/v3.7.0.tar.gz" + sha256: "39ad5c42acf3434f8c37e0baa18a8cb562c0845383a6b4da17fdbacc9f0a7695" + "3.6.0": + url: "https://github.com/skypjack/entt/archive/v3.6.0.tar.gz" + sha256: "94b7dc874acd0961cfc28cf6b0342eeb0b7c58250ddde8bdc6c101e84b74c190" + "3.5.2": + url: "https://github.com/skypjack/entt/archive/v3.5.2.tar.gz" + sha256: "f9271293c44518386c402c9a2188627819748f66302df48af4f6d08e30661036" + "3.5.1": + url: "https://github.com/skypjack/entt/archive/v3.5.1.tar.gz" + sha256: "f442ece6881ec24863e7f0fbdc4bf641e01b0f87955f49dc4687b2fa564e9c83" + "3.5.0": + url: "https://github.com/skypjack/entt/archive/v3.5.0.tar.gz" + sha256: "89cba5ddf90bcec0dcf8d9554d9acf5ad86f5ce305e3acacf795007ee65c93f8" + "3.4.0": + url: "https://github.com/skypjack/entt/archive/v3.4.0.tar.gz" + sha256: "07086b8c5b1d84a1b76b39b0ce257c36c4f1521b77e664368b3d5ca7c00264e2" + "3.3.2": + url: "https://github.com/skypjack/entt/archive/v3.3.2.tar.gz" + sha256: "150cd89b45bffbcd7643d39bbce282e8fa38307bb5ed25567b79e337376ba1c7" + "3.3.1": + url: "https://github.com/skypjack/entt/archive/v3.3.1.tar.gz" + sha256: "432f31a80fb0463960dfd36e103c206dd67f1bfa91fc48408594c28aa790a3f5" + "3.3.0": + url: "https://github.com/skypjack/entt/archive/v3.3.0.tar.gz" + sha256: "d21a45df4960adc86a8f23a8c3c0cea6d2cecc4ef6946a8040e336d8e5266ab3" + "3.2.2": + url: "https://github.com/skypjack/entt/archive/v3.2.2.tar.gz" + sha256: "94592270b6750dd0b057a4af9d2c1ea8798369b3bb127927a8f70db232808f93" +patches: + "3.11.1": + - patch_file: "patches/0001-3.11.0-fix-gcc-7.0-7.3.patch" + patch_description: "Fix GCC 7.0 to 7.3" + patch_type: "portability" + "3.11.0": + - patch_file: "patches/0001-3.11.0-fix-gcc-7.0-7.3.patch" + patch_description: "Fix GCC 7.0 to 7.3" + patch_type: "portability" diff --git a/recipes/entt/3.x.x/conanfile.py b/recipes/entt/3.x.x/conanfile.py index 55950c2612ac4..bcce48c1ce46c 100644 --- a/recipes/entt/3.x.x/conanfile.py +++ b/recipes/entt/3.x.x/conanfile.py @@ -1,66 +1,79 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get +from conan.tools.layout import basic_layout import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.52.0" class EnttConan(ConanFile): name = "entt" description = "Gaming meets modern C++ - a fast and reliable entity-component system (ECS) and much more" - topics = ("conan", "entt", "gaming", "entity", "ecs") + topics = ("entt", "gaming", "entity", "ecs") homepage = "https://github.com/skypjack/entt" url = "https://github.com/conan-io/conan-center-index" license = "MIT" - no_copy_source = True - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" @property - def _source_subfolder(self): - return "source_subfolder" + def _min_cppstd(self): + return "17" - def configure(self): - minimal_cpp_standard = "17" - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, minimal_cpp_standard) - - minimal_version = { + @property + def _compilers_minimum_version(self): + return { "Visual Studio": "15.9", + "msvc": "191", "gcc": "7", "clang": "5", - "apple-clang": "10" + "apple-clang": "10", } - compiler = str(self.settings.compiler) - if compiler not in minimal_version: - self.output.warn( - "%s recipe lacks information about the %s compiler standard version support" % (self.name, compiler)) - self.output.warn( - "%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) - return + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + # TODO: use self.info.settings in validate() instead of self.settings + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) - # Compare versions asuming minor satisfies if not explicitly set - def lazy_lt_semver(v1, v2): + def loose_lt_semver(v1, v2): lv1 = [int(v) for v in v1.split(".")] lv2 = [int(v) for v in v2.split(".")] min_length = min(len(lv1), len(lv2)) return lv1[:min_length] < lv2[:min_length] - if lazy_lt_semver(str(self.settings.compiler.version), minimal_version[compiler]): + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): raise ConanInvalidConfiguration( - "%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) - - def package_id(self): - self.info.header_only() + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.", + ) def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + apply_conandata_patches(self) def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "src")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "EnTT") + self.cpp_info.set_property("cmake_target_name", "EnTT::EnTT") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + # TODO: to remove in conan v2 self.cpp_info.names["cmake_find_package"] = "EnTT" self.cpp_info.names["cmake_find_package_multi"] = "EnTT" diff --git a/recipes/entt/3.x.x/patches/0001-3.11.0-fix-gcc-7.0-7.3.patch b/recipes/entt/3.x.x/patches/0001-3.11.0-fix-gcc-7.0-7.3.patch new file mode 100644 index 0000000000000..f525e3855f87c --- /dev/null +++ b/recipes/entt/3.x.x/patches/0001-3.11.0-fix-gcc-7.0-7.3.patch @@ -0,0 +1,20 @@ +--- a/src/entt/meta/meta.hpp ++++ b/src/entt/meta/meta.hpp +@@ -1613,7 +1613,7 @@ public: + using reference = value_type; + using iterator_category = std::input_iterator_tag; + +- constexpr meta_iterator() noexcept ++ meta_iterator() noexcept + : ctx{}, + vtable{}, + handle{} {} +@@ -1707,7 +1707,7 @@ public: + using reference = value_type; + using iterator_category = std::input_iterator_tag; + +- constexpr meta_iterator() noexcept ++ meta_iterator() noexcept + : ctx{}, + vtable{}, + handle{} {} diff --git a/recipes/entt/3.x.x/test_package/CMakeLists.txt b/recipes/entt/3.x.x/test_package/CMakeLists.txt index 96a305473e8ef..317de178fe28d 100644 --- a/recipes/entt/3.x.x/test_package/CMakeLists.txt +++ b/recipes/entt/3.x.x/test_package/CMakeLists.txt @@ -1,14 +1,11 @@ cmake_minimum_required(VERSION 3.8) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_output_dirs_setup() +project(test_package LANGUAGES CXX) find_package(EnTT REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} EnTT::EnTT) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) +target_link_libraries(${PROJECT_NAME} PRIVATE EnTT::EnTT) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) if(EnTT_VERSION VERSION_LESS "3.4.0") - target_compile_definitions(${PROJECT_NAME} PRIVATE "ENTT_LESS_3_4_0") + target_compile_definitions(${PROJECT_NAME} PRIVATE "ENTT_LESS_3_4_0") endif() diff --git a/recipes/entt/3.x.x/test_package/conanfile.py b/recipes/entt/3.x.x/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/entt/3.x.x/test_package/conanfile.py +++ b/recipes/entt/3.x.x/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/entt/3.x.x/test_v1_package/CMakeLists.txt b/recipes/entt/3.x.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/entt/3.x.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/entt/3.x.x/test_v1_package/conanfile.py b/recipes/entt/3.x.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/entt/3.x.x/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/entt/config.yml b/recipes/entt/config.yml index cd3835caa18fb..0000b93d983f2 100644 --- a/recipes/entt/config.yml +++ b/recipes/entt/config.yml @@ -1,23 +1,39 @@ versions: - "3.2.2": + "3.11.1": folder: 3.x.x - "3.3.0": + "3.11.0": folder: 3.x.x - "3.3.1": + "3.10.3": folder: 3.x.x - "3.3.2": + "3.10.1": folder: 3.x.x - "3.4.0": + "3.10.0": folder: 3.x.x - "3.5.0": + "3.9.0": folder: 3.x.x - "3.5.1": + "3.8.1": folder: 3.x.x - "3.5.2": + "3.8.0": folder: 3.x.x - "3.6.0": + "3.7.1": folder: 3.x.x "3.7.0": folder: 3.x.x - "3.7.1": + "3.6.0": + folder: 3.x.x + "3.5.2": + folder: 3.x.x + "3.5.1": + folder: 3.x.x + "3.5.0": + folder: 3.x.x + "3.4.0": + folder: 3.x.x + "3.3.2": + folder: 3.x.x + "3.3.1": + folder: 3.x.x + "3.3.0": + folder: 3.x.x + "3.2.2": folder: 3.x.x diff --git a/recipes/enum-flags/0.1a/conandata.yml b/recipes/enum-flags/0.1a/conandata.yml deleted file mode 100644 index d66c5931610b6..0000000000000 --- a/recipes/enum-flags/0.1a/conandata.yml +++ /dev/null @@ -1,4 +0,0 @@ -sources: - "0.1a": - url: "https://github.com/grisumbras/enum-flags/archive/v0.1a.zip" - sha256: "ee1a819d48b52f2d0088a154976e1a36bb3ae511104610b61ff77fc307037fb3" diff --git a/recipes/enum-flags/0.1a/conanfile.py b/recipes/enum-flags/0.1a/conanfile.py deleted file mode 100644 index 7f2b10fab40ee..0000000000000 --- a/recipes/enum-flags/0.1a/conanfile.py +++ /dev/null @@ -1,48 +0,0 @@ -from conans import ConanFile, tools -import os - -required_conan_version = ">=1.28.0" - -class EnumFlagsConan(ConanFile): - name = "enum-flags" - description = "Bit flags for C++11 scoped enums" - homepage = "https://github.com/grisumbras/enum-flags" - url = "https://github.com/conan-io/conan-center-index" - topics = ("bitmask", "enum") - license = "MIT" - settings = "compiler" - options = {"forbid_implicit_conversions": [True, False]} - default_options = {"forbid_implicit_conversions": True} - generators = "cmake" - no_copy_source = True - - @property - def _source_subfolder(self): - return "source_subfolder" - - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) - - def package_id(self): - self.info.header_only() - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def package(self): - self.copy("include*", src=self._source_subfolder) - self.copy("*LICENSE", dst="licenses", keep_path=False) - - def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "enumflags" - self.cpp_info.filenames["cmake_find_package_multi"] = "enumflags" - self.cpp_info.names["cmake_find_package"] = "EnumFlags" - self.cpp_info.names["cmake_find_package_multi"] = "EnumFlags" - # Yes, there is a typo in the macro name. - # This macro is only useful when using regular C enums, - # since enum classes prevent implicit conversions already. - if self.options.forbid_implicit_conversions: - self.cpp_info.defines = ["ENUM_CLASS_FLAGS_FORBID_IMPLICT_CONVERSION"] diff --git a/recipes/enum-flags/0.1a/test_package/CMakeLists.txt b/recipes/enum-flags/0.1a/test_package/CMakeLists.txt deleted file mode 100644 index be06370daa883..0000000000000 --- a/recipes/enum-flags/0.1a/test_package/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(enumflags REQUIRED CONFIG) - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} EnumFlags::EnumFlags) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/enum-flags/0.1a/test_package/conanfile.py b/recipes/enum-flags/0.1a/test_package/conanfile.py deleted file mode 100644 index db8b24b0978af..0000000000000 --- a/recipes/enum-flags/0.1a/test_package/conanfile.py +++ /dev/null @@ -1,24 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - exe_name = "test_package" - if self.settings.os == "Emscripten": - exe_name += ".js" - elif tools.os_info.is_windows: - exe_name += ".exe" - exec_path = os.path.join("bin", exe_name) - if tools.cross_building(self.settings): - assert(os.path.exists(exec_path)) - else: - self.run(exec_path, run_environment=True) diff --git a/recipes/enum-flags/all/conandata.yml b/recipes/enum-flags/all/conandata.yml new file mode 100644 index 0000000000000..d29d7bbf48ded --- /dev/null +++ b/recipes/enum-flags/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.1a": + url: "https://github.com/grisumbras/enum-flags/archive/refs/tags/v0.1a.tar.gz" + sha256: "34a952a39e9f079357003566da01cabae434e3679c52fafc6bc09f94d0b9d525" diff --git a/recipes/enum-flags/all/conanfile.py b/recipes/enum-flags/all/conanfile.py new file mode 100644 index 0000000000000..81ac78601093a --- /dev/null +++ b/recipes/enum-flags/all/conanfile.py @@ -0,0 +1,64 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class EnumFlagsConan(ConanFile): + name = "enum-flags" + description = "Bit flags for C++11 scoped enums" + homepage = "https://github.com/grisumbras/enum-flags" + url = "https://github.com/conan-io/conan-center-index" + topics = ("bitmask", "enum") + license = "MIT" + + settings = "os", "arch", "compiler", "build_type" + options = { + "forbid_implicit_conversions": [True, False], + } + default_options = { + "forbid_implicit_conversions": True, + } + + no_copy_source = True + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "enumflags") + self.cpp_info.set_property("cmake_target_name", "EnumFlags::EnumFlags") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + # Yes, there is a typo in the macro name. + # This macro is only useful when using regular C enums, + # since enum classes prevent implicit conversions already. + if self.options.forbid_implicit_conversions: + self.cpp_info.defines = ["ENUM_CLASS_FLAGS_FORBID_IMPLICT_CONVERSION"] + + # TODO: to remove in conan v2 + self.cpp_info.filenames["cmake_find_package"] = "enumflags" + self.cpp_info.filenames["cmake_find_package_multi"] = "enumflags" + self.cpp_info.names["cmake_find_package"] = "EnumFlags" + self.cpp_info.names["cmake_find_package_multi"] = "EnumFlags" diff --git a/recipes/enum-flags/all/test_package/CMakeLists.txt b/recipes/enum-flags/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..62594120f0543 --- /dev/null +++ b/recipes/enum-flags/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(enumflags REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE EnumFlags::EnumFlags) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/enum-flags/all/test_package/conanfile.py b/recipes/enum-flags/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/enum-flags/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/enum-flags/0.1a/test_package/test_package.cpp b/recipes/enum-flags/all/test_package/test_package.cpp similarity index 100% rename from recipes/enum-flags/0.1a/test_package/test_package.cpp rename to recipes/enum-flags/all/test_package/test_package.cpp diff --git a/recipes/enum-flags/all/test_v1_package/CMakeLists.txt b/recipes/enum-flags/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/enum-flags/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/enum-flags/all/test_v1_package/conanfile.py b/recipes/enum-flags/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/enum-flags/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/enum-flags/config.yml b/recipes/enum-flags/config.yml index b03833f25d2c0..26aefcacb9d5d 100644 --- a/recipes/enum-flags/config.yml +++ b/recipes/enum-flags/config.yml @@ -1,3 +1,3 @@ versions: "0.1a": - folder: "0.1a" + folder: all diff --git a/recipes/erikzenker-hsm/all/conandata.yml b/recipes/erikzenker-hsm/all/conandata.yml new file mode 100644 index 0000000000000..cf53ed0fed4b1 --- /dev/null +++ b/recipes/erikzenker-hsm/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "2.1.0": + url: "https://github.com/erikzenker/hsm/archive/v2.1.0.tar.gz" + sha256: "956eb4950e1bee3074e10fe85279164386ba34e4e96fabe694aaf20b24adcdef" + "1.4.7": + sha256: e56fd4a71337448727dbb9e2abe18992224d496a7ab5567030d6717a00680364 + url: https://github.com/erikzenker/hsm/archive/refs/tags/v1.4.7.tar.gz diff --git a/recipes/erikzenker-hsm/all/conanfile.py b/recipes/erikzenker-hsm/all/conanfile.py new file mode 100644 index 0000000000000..67b3efc1712c4 --- /dev/null +++ b/recipes/erikzenker-hsm/all/conanfile.py @@ -0,0 +1,71 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.0" + + +class HsmConan(ConanFile): + name = "erikzenker-hsm" + license = "MIT" + homepage = "https://github.com/erikzenker/hsm.git" + url = "https://github.com/conan-io/conan-center-index" + description = ( + "The hana state machine (hsm) is a finite state machine library based " + "on the boost hana meta programming library. It follows the principles " + "of the boost msm and boost sml libraries, but tries to reduce own " + "complex meta programming code to a minimum." + ) + topics = ("state-machine", "template-meta-programming") + + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps" + + def requirements(self): + self.requires("boost/1.79.0") + + def package_id(self): + self.info.clear() + + def validate(self): + # FIXME: should use self.info.settings instead of self.settings for conan v2 + # https://github.com/erikzenker/hsm#dependencies + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 17) + if self.settings.compiler == "clang" and Version(self.settings.compiler.version) < "8": + raise ConanInvalidConfiguration("clang 8+ is required") + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "8": + raise ConanInvalidConfiguration("GCC 8+ is required") + + def layout(self): + cmake_layout(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "hsm" + self.cpp_info.names["cmake_find_package_multi"] = "hsm" + self.cpp_info.set_property("cmake_file_name", "hsm") + self.cpp_info.set_property("cmake_target_name", "hsm::hsm") + self.cpp_info.requires = ["boost::headers"] diff --git a/recipes/erikzenker-hsm/all/test_package/CMakeLists.txt b/recipes/erikzenker-hsm/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2fe2bc0003d31 --- /dev/null +++ b/recipes/erikzenker-hsm/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(hsm CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE hsm::hsm) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/erikzenker-hsm/all/test_package/conanfile.py b/recipes/erikzenker-hsm/all/test_package/conanfile.py new file mode 100644 index 0000000000000..185c9f3ab199a --- /dev/null +++ b/recipes/erikzenker-hsm/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class HsmTestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/erikzenker-hsm/all/test_package/test_package.cpp b/recipes/erikzenker-hsm/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..5401fc4d4e36e --- /dev/null +++ b/recipes/erikzenker-hsm/all/test_package/test_package.cpp @@ -0,0 +1,62 @@ +#include "hsm/hsm.h" + +#include +#include + +// States +struct Locked { +}; +struct Unlocked { +}; + +// Events +struct Push { +}; +struct Coin { +}; + +// Guards +const auto noError = [](auto /*event*/, auto /*source*/, auto /*target*/) { return true; }; + +// Actions +constexpr auto beep + = [](auto /*event*/, auto /*source*/, auto /*target*/) { std::cout << "beep!" << std::endl; }; +constexpr auto blink = [](auto /*event*/, auto /*source*/, auto /*target*/) { + std::cout << "blink, blink, blink!" << std::endl; +}; + +struct Turnstile { + static constexpr auto make_transition_table() + { + // clang-format off + return hsm::transition_table( + // Source + Event [Guard] / Action = Target + // +-------------------+-----------------+---------+--------+----------------------+ + * hsm::state + hsm::event / beep = hsm::state , + hsm::state + hsm::event [noError] / blink = hsm::state, + // +--------------------+---------------------+---------+--------+------------------------+ + hsm::state + hsm::event [noError] = hsm::state , + hsm::state + hsm::event / blink = hsm::state + // +--------------------+---------------------+---------+--------+------------------------+ + ); + // clang-format on + } +}; + +auto main() -> int +{ + hsm::sm turnstileSm; + + // The turnstile is initially locked + assert(turnstileSm.is(hsm::state)); + + // Inserting a coin unlocks it + turnstileSm.process_event(Coin {}); + assert(turnstileSm.is(hsm::state)); + + // Entering the turnstile will lock it again + turnstileSm.process_event(Push {}); + assert(turnstileSm.is(hsm::state)); + + return 0; +} diff --git a/recipes/erikzenker-hsm/all/test_v1_package/CMakeLists.txt b/recipes/erikzenker-hsm/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..be32b126aba4d --- /dev/null +++ b/recipes/erikzenker-hsm/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(hsm REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE hsm::hsm) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/erikzenker-hsm/all/test_v1_package/conanfile.py b/recipes/erikzenker-hsm/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/erikzenker-hsm/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/erikzenker-hsm/config.yml b/recipes/erikzenker-hsm/config.yml new file mode 100644 index 0000000000000..c4e6cb2ec4176 --- /dev/null +++ b/recipes/erikzenker-hsm/config.yml @@ -0,0 +1,5 @@ +versions: + "2.1.0": + folder: all + "1.4.7": + folder: all diff --git a/recipes/erkir/all/conandata.yml b/recipes/erkir/all/conandata.yml new file mode 100644 index 0000000000000..24a6857c0b7eb --- /dev/null +++ b/recipes/erkir/all/conandata.yml @@ -0,0 +1,25 @@ +sources: + "2.0.0": + url: "https://github.com/vahancho/erkir/archive/refs/tags/v2.0.0.tar.gz" + sha256: "98d095adcf0f2f11e3ba345bd5bbe890568cde69de9680b2c2a424f0008453ac" + "1.0.0": + url: "https://github.com/vahancho/erkir/archive/refs/tags/1.0.0.tar.gz" + sha256: "0bc5122fe2fef0f9036de275483af7f8adb947f6e8dd63fc18ac085ef31e9421" +patches: + "2.0.0": + - patch_file: "patches/2.0.0-0001-remove-specify-architecture.patch" + patch_description: "fix supported architectures limited to x86/x86_64" + patch_type: "conan" + - patch_file: "patches/2.0.0-0002-fix-cmake.patch" + patch_description: "disable shared and fPIC options" + patch_type: "conan" + - patch_file: "patches/2.0.0-0003-fix-erkir_export.patch" + patch_description: "define ERKIR_EXPORT as empty on static build" + patch_type: "conan" + "1.0.0": + - patch_file: "patches/1.0.0-0001-remove-testing.patch" + patch_description: "stop executing test codes" + patch_type: "conan" + - patch_file: "patches/1.0.0-0002-export-symbols.patch" + patch_description: "export all symbols on windows" + patch_type: "backport" diff --git a/recipes/erkir/all/conanfile.py b/recipes/erkir/all/conanfile.py new file mode 100644 index 0000000000000..66b56ca8db092 --- /dev/null +++ b/recipes/erkir/all/conanfile.py @@ -0,0 +1,85 @@ +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.52.0" + +class ErkirConan(ConanFile): + name = "erkir" + description = "a C++ library for geodetic and trigonometric calculations" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/vahancho/erkir" + topics = ("earth", "geodesy", "geography", "coordinate-systems", "geodetic", "datum") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _minimum_cpp_standard(self): + return 11 + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CODE_COVERAGE"] = False + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + if Version(self.version) < "2.0.0": + copy(self, pattern="*", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + copy(self, pattern="*.lib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) + copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=self.build_folder, keep_path=False) + copy(self, pattern="*.dylib*", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) + copy(self, pattern="*.so", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) + copy(self, pattern="*.a", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) + else: + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + postfix = "d" if Version(self.version) >= "2.0.0" and self.settings.build_type == "Debug" else "" + self.cpp_info.libs = [f"erkir{postfix}"] diff --git a/recipes/erkir/all/patches/1.0.0-0001-remove-testing.patch b/recipes/erkir/all/patches/1.0.0-0001-remove-testing.patch new file mode 100644 index 0000000000000..379ea53449dae --- /dev/null +++ b/recipes/erkir/all/patches/1.0.0-0001-remove-testing.patch @@ -0,0 +1,24 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 673e4b8..851f78a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -21,19 +21,8 @@ add_library(erkir + ) + add_library(erkir::erkir ALIAS erkir) + +-add_executable(erkir_test +- test/test.cpp +-) +- +-target_link_libraries(erkir_test PRIVATE erkir) +- + # Includes + target_include_directories(erkir PUBLIC include) +-target_include_directories(erkir_test PRIVATE include) +-target_include_directories(erkir_test PRIVATE src) +- +-enable_testing() +-add_test(NAME Test COMMAND erkir_test) + + # Coverage support. + option(CODE_COVERAGE "Enable coverage reporting" ON) diff --git a/recipes/erkir/all/patches/1.0.0-0002-export-symbols.patch b/recipes/erkir/all/patches/1.0.0-0002-export-symbols.patch new file mode 100644 index 0000000000000..190ff9b9a3f95 --- /dev/null +++ b/recipes/erkir/all/patches/1.0.0-0002-export-symbols.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 851f78a..6575859 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -24,6 +24,8 @@ add_library(erkir::erkir ALIAS erkir) + # Includes + target_include_directories(erkir PUBLIC include) + ++set_target_properties(erkir PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) ++ + # Coverage support. + option(CODE_COVERAGE "Enable coverage reporting" ON) + if (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") diff --git a/recipes/erkir/all/patches/2.0.0-0001-remove-specify-architecture.patch b/recipes/erkir/all/patches/2.0.0-0001-remove-specify-architecture.patch new file mode 100644 index 0000000000000..0a3aad55accce --- /dev/null +++ b/recipes/erkir/all/patches/2.0.0-0001-remove-specify-architecture.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 52e5571..b97d9d0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -17,7 +17,7 @@ include(GNUInstallDirs) + option(BUILD_SHARED_LIBS "Build using shared libraries" ON) + option(ENABLE_TESTING "Enable unit test build" OFF) + +-if (NOT MSVC) ++if (0) + # Specify the target architecture (Linux). For Windows based generator use rather + # '-A Win32' or '-A x64 options' + set(TARGET_ARCH x86 CACHE STRING "the target architecture") diff --git a/recipes/erkir/all/patches/2.0.0-0002-fix-cmake.patch b/recipes/erkir/all/patches/2.0.0-0002-fix-cmake.patch new file mode 100644 index 0000000000000..50bd8af00a0b8 --- /dev/null +++ b/recipes/erkir/all/patches/2.0.0-0002-fix-cmake.patch @@ -0,0 +1,20 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b97d9d0..0152f84 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.9) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # The project definition + project(erkir VERSION 2.0.0 +@@ -14,7 +13,6 @@ project(erkir VERSION 2.0.0 + include(GNUInstallDirs) + + # General options +-option(BUILD_SHARED_LIBS "Build using shared libraries" ON) + option(ENABLE_TESTING "Enable unit test build" OFF) + + if (0) diff --git a/recipes/erkir/all/patches/2.0.0-0003-fix-erkir_export.patch b/recipes/erkir/all/patches/2.0.0-0003-fix-erkir_export.patch new file mode 100644 index 0000000000000..cef30fbc03eea --- /dev/null +++ b/recipes/erkir/all/patches/2.0.0-0003-fix-erkir_export.patch @@ -0,0 +1,28 @@ +diff --git a/include/export.h b/include/export.h +index edcb0b3..e090174 100644 +--- a/include/export.h ++++ b/include/export.h +@@ -1,7 +1,7 @@ + #ifndef __EXPORT_H_ + #define __EXPORT_H_ + +-#ifdef _WIN32 ++#if defined(_WIN32) && defined(ERKIR_SHARED) + #ifdef MAKEDLL + # define ERKIR_EXPORT __declspec(dllexport) + #else +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index ccb807b..8eb005d 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -37,6 +37,10 @@ if (MSVC) + target_compile_definitions(${TARGET} PUBLIC MAKEDLL) + endif() + ++if (BUILD_SHARED_LIBS) ++ target_compile_definitions(${TARGET} PUBLIC ERKIR_SHARED) ++endif() ++ + ############################################################################### + # The installation and packaging + # diff --git a/recipes/erkir/all/test_package/CMakeLists.txt b/recipes/erkir/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..135087f122cde --- /dev/null +++ b/recipes/erkir/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +find_package(erkir REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE erkir::erkir) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/erkir/all/test_package/conanfile.py b/recipes/erkir/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/erkir/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/erkir/all/test_package/test_package.cpp b/recipes/erkir/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..887871e867da3 --- /dev/null +++ b/recipes/erkir/all/test_package/test_package.cpp @@ -0,0 +1,27 @@ +#include +#include +#include + +int main(int argc, char **argv) +{ + // Calculate great-circle distance between two points. + erkir::spherical::Point p1{ 52.205, 0.119 }; + erkir::spherical::Point p2{ 48.857, 2.351 }; + auto d = p1.distanceTo(p2); // 404.3 km + + // Get destination point by given distance (shortest) and bearing from start point. + erkir::spherical::Point p3{ 51.4778, -0.0015 }; + auto dest = p3.destinationPoint(7794.0, 300.7); // 51.5135°N, 000.0983°W + + // Convert a point from one coordinates system to another. + erkir::ellipsoidal::Point pWGS84(51.4778, -0.0016, 0, erkir::ellipsoidal::Datum::Type::WGS84); + auto pOSGB = pWGS84.toDatum(erkir::ellipsoidal::Datum::Type::OSGB36); // 51.4778°N, 000.0000°E + + // Convert to Cartesian coordinates. + auto cartesian = pWGS84.toCartesianPoint(); + + // Convert Cartesian point to a geodetic one. + auto geoPoint = cartesian->toGeoPoint(); + + return 0; +} diff --git a/recipes/erkir/all/test_v1_package/CMakeLists.txt b/recipes/erkir/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b00f9ba781174 --- /dev/null +++ b/recipes/erkir/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(erkir REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE erkir::erkir) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/erkir/all/test_v1_package/conanfile.py b/recipes/erkir/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/erkir/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/erkir/config.yml b/recipes/erkir/config.yml new file mode 100644 index 0000000000000..870fb33e55af0 --- /dev/null +++ b/recipes/erkir/config.yml @@ -0,0 +1,5 @@ +versions: + "2.0.0": + folder: all + "1.0.0": + folder: all diff --git a/recipes/eternal/all/conandata.yml b/recipes/eternal/all/conandata.yml new file mode 100644 index 0000000000000..8214ea0955a49 --- /dev/null +++ b/recipes/eternal/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.1": + url: "https://github.com/mapbox/eternal/archive/refs/tags/v1.0.1.tar.gz" + sha256: "7d799381b3786d0bd987eea75df2a81f581a64ee962e922a2f7a7d3d0c3d0421" diff --git a/recipes/eternal/all/conanfile.py b/recipes/eternal/all/conanfile.py new file mode 100644 index 0000000000000..fd3a53c2138bb --- /dev/null +++ b/recipes/eternal/all/conanfile.py @@ -0,0 +1,69 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.layout import basic_layout +import os + + +required_conan_version = ">=1.51.3" + + +class EternalConan(ConanFile): + name = "eternal" + description = "A C++14 compile-time/constexpr map and hash map with minimal binary footprint" + license = "ISC" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/mapbox/eternal" + topics = ("hashing", "map", "constexpr", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _minimum_cpp_standard(self): + return 14 + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "15", + "msvc": "191", + "gcc": "5", + "clang": "4", + "apple-clang": "10", + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.get_safe("compiler.version")) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, pattern="LICENSE.md", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="*.hpp", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/eternal/all/test_package/CMakeLists.txt b/recipes/eternal/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8d5920de9d2e0 --- /dev/null +++ b/recipes/eternal/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +find_package(eternal REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE eternal::eternal) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/eternal/all/test_package/conanfile.py b/recipes/eternal/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/eternal/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/eternal/all/test_package/test_package.cpp b/recipes/eternal/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..11565bc6294ec --- /dev/null +++ b/recipes/eternal/all/test_package/test_package.cpp @@ -0,0 +1,41 @@ +#include +#include +#include + +#include "mapbox/eternal.hpp" + +struct Color { + constexpr inline Color() { + } + constexpr inline Color(unsigned char r_, unsigned char g_, unsigned char b_, float a_) + : r(r_), g(g_), b(b_), a(a_ > 1 ? 1 : a_ < 0 ? 0 : a_) { + } + unsigned char r = 0, g = 0, b = 0; + float a = 1.0f; + + constexpr bool operator==(const Color& rhs) const { + return r == rhs.r && g == rhs.g && b == rhs.b && + (a >= rhs.a ? a - rhs.a : rhs.a - a) < std::numeric_limits::epsilon(); + } +}; + +MAPBOX_ETERNAL_CONSTEXPR const auto multi_colors = mapbox::eternal::map({ + { "red", { 255, 0, 0, 1 } }, + { "yellow", { 255, 255, 0, 1 } }, + { "white", { 255, 255, 255, 1 } }, // comes before yellow! + { "yellow", { 255, 220, 0, 1 } }, // a darker yellow +}); + +int main(void) { + static_assert(!multi_colors.unique(), "multi_colors are not unique"); + static_assert(multi_colors.find("yellow") != multi_colors.end(), "colors contains yellow"); + static_assert(multi_colors.find("yellow")->second == Color(255, 255, 0, 1), "yellow returns the correct color"); + static_assert((++multi_colors.find("yellow"))->second == Color(255, 220, 0, 1), "yellow returns the correct color"); + static_assert(multi_colors.equal_range("white").first == multi_colors.find("white"), "white range returns the correct begin"); + static_assert(multi_colors.equal_range("white").second == multi_colors.find("yellow"), "white range end is the next color"); + static_assert(multi_colors.equal_range("yellow").first == multi_colors.find("yellow"), "yellow range returns the correct begin"); + static_assert(multi_colors.equal_range("yellow").second == multi_colors.end(), "yellow range end returns end"); + static_assert(multi_colors.count("yellow") == 2, "has 2 yellows"); + + return EXIT_SUCCESS; +} diff --git a/recipes/eternal/all/test_v1_package/CMakeLists.txt b/recipes/eternal/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e900db203f73f --- /dev/null +++ b/recipes/eternal/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(eternal REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE eternal::eternal) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/eternal/all/test_v1_package/conanfile.py b/recipes/eternal/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/eternal/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/eternal/config.yml b/recipes/eternal/config.yml new file mode 100644 index 0000000000000..715e55357a17b --- /dev/null +++ b/recipes/eternal/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.1": + folder: all diff --git a/recipes/etl/all/conandata.yml b/recipes/etl/all/conandata.yml new file mode 100644 index 0000000000000..ed362fa1d4ebd --- /dev/null +++ b/recipes/etl/all/conandata.yml @@ -0,0 +1,25 @@ +sources: + "20.35.5": + url: "https://github.com/ETLCPP/etl/archive/20.35.5.tar.gz" + sha256: "d67aead4f1c023eaeb9ae67b62b0aed76138aa1b7dac48f627530ab3ea366281" + "20.35.0": + url: "https://github.com/ETLCPP/etl/archive/20.35.0.tar.gz" + sha256: "1bfbc5679bce41625add0e5d7354ab8521dc4811f13e1627a9816af65f49f42b" + "20.34.0": + url: "https://github.com/ETLCPP/etl/archive/20.34.0.tar.gz" + sha256: "56e25968f20167a161ee50c3eecda3daa91f696660ba59654c1afd22e502c465" + "20.33.0": + url: "https://github.com/ETLCPP/etl/archive/20.33.0.tar.gz" + sha256: "46068e44cc3cbd626fc8adc5344101b4654c675b9a5faec0c80989176419cd7d" + "20.32.1": + url: "https://github.com/ETLCPP/etl/archive/20.32.1.tar.gz" + sha256: "f39c8ccf33190303946dbcb2b251c86b4516234f57e0e87b83c0a28a1bdb059d" + "20.31.3": + url: "https://github.com/ETLCPP/etl/archive/20.31.3.tar.gz" + sha256: "dabfeaec4e0aaee6920ee429ab262959595b78d65ef7846df13b5fe68ea85f4b" + "20.30.1": + url: "https://github.com/ETLCPP/etl/archive/20.30.1.tar.gz" + sha256: "10b50ca3ae406ae379e85504546843fc9d97be18924e71d8eb7e8e5a418e91cd" + "20.29.3": + url: "https://github.com/ETLCPP/etl/archive/20.29.3.tar.gz" + sha256: "8a0df2b475ea99bb27dd4ee04c39bda69e29be93b3709a1e243dcc2599e92ff4" diff --git a/recipes/etl/all/conanfile.py b/recipes/etl/all/conanfile.py new file mode 100644 index 0000000000000..11f8a49e83bd4 --- /dev/null +++ b/recipes/etl/all/conanfile.py @@ -0,0 +1,69 @@ +from conan import ConanFile +from conan.tools.files import get, copy, save +import os +import textwrap + + +required_conan_version = ">=1.50.0" + + +class EmbeddedTemplateLibraryConan(ConanFile): + name = "etl" + description = "A C++ template library for embedded applications" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.etlcpp.com/" + topics = ("cpp", "embedded", "template", "container", "utility", "framework", "messaging") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, "*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + self, + os.path.join(self.package_folder, self._module_file_rel_path), + {"etl": "etl::etl"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(conanfile, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(conanfile, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "etl") + self.cpp_info.set_property("cmake_target_name", "etl") + + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + self.cpp_info.builddirs.append(os.path.join("lib", "cmake")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/etl/all/test_package/CMakeLists.txt b/recipes/etl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5755c51bbf480 --- /dev/null +++ b/recipes/etl/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(etl REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +target_link_libraries(${PROJECT_NAME} etl) diff --git a/recipes/etl/all/test_package/conanfile.py b/recipes/etl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..220ec13c13be3 --- /dev/null +++ b/recipes/etl/all/test_package/conanfile.py @@ -0,0 +1,24 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/recipes/etl/all/test_package/test_package.cpp b/recipes/etl/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..767f8cbf18649 --- /dev/null +++ b/recipes/etl/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + const etl::array data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + return (data.size() == 10)?0:1; +} diff --git a/recipes/etl/all/test_v1_package/CMakeLists.txt b/recipes/etl/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b8e7ad788b821 --- /dev/null +++ b/recipes/etl/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(etl REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +target_link_libraries(${PROJECT_NAME} etl) diff --git a/recipes/etl/all/test_v1_package/conanfile.py b/recipes/etl/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2490acfa82ff8 --- /dev/null +++ b/recipes/etl/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/etl/config.yml b/recipes/etl/config.yml new file mode 100644 index 0000000000000..5ddb457979cc3 --- /dev/null +++ b/recipes/etl/config.yml @@ -0,0 +1,17 @@ +versions: + "20.35.5": + folder: all + "20.35.0": + folder: all + "20.34.0": + folder: all + "20.33.0": + folder: all + "20.32.1": + folder: all + "20.31.3": + folder: all + "20.30.1": + folder: all + "20.29.3": + folder: all diff --git a/recipes/exiv2/all/conandata.yml b/recipes/exiv2/all/conandata.yml new file mode 100644 index 0000000000000..5352f4d8920bf --- /dev/null +++ b/recipes/exiv2/all/conandata.yml @@ -0,0 +1,21 @@ +sources: + "0.27.5": + url: "https://github.com/Exiv2/exiv2/archive/refs/tags/v0.27.5.tar.gz" + sha256: "1da1721f84809e4d37b3f106adb18b70b1b0441c860746ce6812bb3df184ed6c" + "0.27.4": + url: "https://github.com/Exiv2/exiv2/archive/refs/tags/v0.27.4.tar.gz" + sha256: "9fb2752c92f63c9853e0bef9768f21138eeac046280f40ded5f37d06a34880d9" +patches: + "0.27.5": + - patch_file: "patches/0001-link-0.27.5.patch" + - patch_file: "patches/0003-fix-ios.patch" + - patch_file: "patches/0004-find-expat.patch" + patch_description: "enforce usage of FindEXPAT.cmake" + patch_type: "conan" + "0.27.4": + - patch_file: "patches/0001-link.patch" + - patch_file: "patches/0002-fpic.patch" + - patch_file: "patches/0003-fix-ios.patch" + - patch_file: "patches/0004-find-expat.patch" + patch_description: "enforce usage of FindEXPAT.cmake" + patch_type: "conan" diff --git a/recipes/exiv2/all/conanfile.py b/recipes/exiv2/all/conanfile.py new file mode 100644 index 0000000000000..ba73c4ac8d363 --- /dev/null +++ b/recipes/exiv2/all/conanfile.py @@ -0,0 +1,166 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, copy, rmdir, save, export_conandata_patches, apply_conandata_patches +from conan.tools.microsoft import is_msvc, msvc_runtime_flag +import os +import textwrap + +required_conan_version = ">=1.52.0" + + +class Exiv2Conan(ConanFile): + name = "exiv2" + description = "Exiv2 is a C++ library and a command-line utility " \ + "to read, write, delete and modify Exif, IPTC, XMP and ICC image metadata." + license = "GPL-2.0" + topics = ("image", "exif", "xmp") + homepage = "https://www.exiv2.org" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_png": [True, False], + "with_xmp": [False, "bundled", "external"], + "with_curl": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_png": True, + "with_xmp": "bundled", + "with_curl": False, + } + + provides = [] + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + if self.options.with_xmp == "bundled": + # recipe has bundled xmp-toolkit-sdk of old version + # avoid conflict with a future xmp recipe + self.provides.append("xmp-toolkit-sdk") + + def requirements(self): + self.requires("libiconv/1.17") + if self.options.with_png: + self.requires("libpng/1.6.38") + if self.options.with_xmp == "bundled": + self.requires("expat/2.4.9") + if self.options.with_curl: + self.requires("libcurl/7.85.0") + + def validate(self): + if self.options.with_xmp == "external": + raise ConanInvalidConfiguration("adobe-xmp-toolkit is not available on cci (yet)") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["EXIV2_BUILD_SAMPLES"] = False + tc.variables["EXIV2_BUILD_EXIV2_COMMAND"] = False + tc.variables["EXIV2_ENABLE_PNG"] = self.options.with_png + tc.variables["EXIV2_ENABLE_XMP"] = self.options.with_xmp == "bundled" + tc.variables["EXIV2_ENABLE_EXTERNAL_XMP"] = self.options.with_xmp == "external" + # NLS is used only for tool which is not built + tc.variables["EXIV2_ENABLE_NLS"] = False + tc.variables["EXIV2_ENABLE_WEBREADY"] = self.options.with_curl + tc.variables["EXIV2_ENABLE_CURL"] = self.options.with_curl + tc.variables["EXIV2_ENABLE_SSH"] = False + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + + if is_msvc(self): + tc.variables["EXIV2_ENABLE_DYNAMIC_RUNTIME"] = "MD" in msvc_runtime_flag(self) + # set PIC manually because of object target exiv2_int + tc.cache_variables["CMAKE_POSITION_INDEPENDENT_CODE"] = bool(self.options.get_safe("fPIC", True)) + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + targets = {"exiv2lib": "exiv2::exiv2lib"} + if self.options.with_xmp == "bundled": + targets.update({"exiv2-xmp": "exiv2::exiv2-xmp"}) + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + targets + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "exiv2") + self.cpp_info.set_property("pkg_config_name", "exiv2") + + # component exiv2lib + self.cpp_info.components["exiv2lib"].set_property("cmake_target_name", "exiv2lib") + self.cpp_info.components["exiv2lib"].libs = ["exiv2"] + self.cpp_info.components["exiv2lib"].requires = [ "libiconv::libiconv"] + if self.options.with_png: + self.cpp_info.components["exiv2lib"].requires.append("libpng::libpng") + if self.options.with_curl: + self.cpp_info.components["exiv2lib"].requires.append("libcurl::libcurl") + + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.components["exiv2lib"].system_libs.extend(["pthread"]) + if self.settings.os == "Windows": + self.cpp_info.components["exiv2lib"].system_libs.extend(["psapi", "ws2_32"]) + self.cpp_info.components["exiv2lib"].defines.append("WIN32_LEAN_AND_MEAN") + + # component exiv2-xmp + if self.options.with_xmp == "bundled": + self.cpp_info.components["exiv2-xmp"].set_property("cmake_target_name", "exiv2-xmp") + self.cpp_info.components["exiv2-xmp"].libs = ["exiv2-xmp"] + self.cpp_info.components["exiv2-xmp"].requires = [ "expat::expat" ] + self.cpp_info.components["exiv2lib"].requires.append("exiv2-xmp") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["exiv2lib"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["exiv2lib"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + if self.options.with_xmp == "bundled": + self.cpp_info.components["exiv2-xmp"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["exiv2-xmp"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/exiv2/all/patches/0001-link-0.27.5.patch b/recipes/exiv2/all/patches/0001-link-0.27.5.patch new file mode 100644 index 0000000000000..b94b7e7a8c10c --- /dev/null +++ b/recipes/exiv2/all/patches/0001-link-0.27.5.patch @@ -0,0 +1,29 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 26e5a951..141211ef 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -142,11 +142,6 @@ if (MSVC) + set_target_properties(exiv2lib PROPERTIES LINK_FLAGS "/ignore:4099") + endif() + +-set_target_properties( exiv2lib_int PROPERTIES +- POSITION_INDEPENDENT_CODE ON +- COMPILE_DEFINITIONS exiv2lib_EXPORTS +-) +- + # NOTE: Cannot use target_link_libraries on OBJECT libraries with old versions of CMake + target_include_directories(exiv2lib_int PRIVATE ${ZLIB_INCLUDE_DIR}) + target_include_directories(exiv2lib SYSTEM PRIVATE +diff --git a/xmpsdk/CMakeLists.txt b/xmpsdk/CMakeLists.txt +index a22698fb..9ef87970 100644 +--- a/xmpsdk/CMakeLists.txt ++++ b/xmpsdk/CMakeLists.txt +@@ -28,7 +28,7 @@ add_library(exiv2-xmp STATIC + + target_link_libraries(exiv2-xmp + PRIVATE +- $ ++ EXPAT::EXPAT + ) + + target_include_directories(exiv2-xmp diff --git a/recipes/exiv2/all/patches/0001-link.patch b/recipes/exiv2/all/patches/0001-link.patch new file mode 100644 index 0000000000000..fd93d6c5c3698 --- /dev/null +++ b/recipes/exiv2/all/patches/0001-link.patch @@ -0,0 +1,26 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index c52b352f..2c270c5f 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -215,7 +215,7 @@ else() + endif() + + if( EXIV2_ENABLE_PNG ) +- target_link_libraries( exiv2lib PRIVATE $) ++ target_link_libraries( exiv2lib PRIVATE ZLIB::ZLIB) + endif() + + if( EXIV2_ENABLE_NLS ) +diff --git a/xmpsdk/CMakeLists.txt b/xmpsdk/CMakeLists.txt +index a22698fb..9ef87970 100644 +--- a/xmpsdk/CMakeLists.txt ++++ b/xmpsdk/CMakeLists.txt +@@ -28,7 +28,7 @@ add_library(exiv2-xmp STATIC + + target_link_libraries(exiv2-xmp + PRIVATE +- $ ++ EXPAT::EXPAT + ) + + target_include_directories(exiv2-xmp diff --git a/recipes/exiv2/all/patches/0002-fpic.patch b/recipes/exiv2/all/patches/0002-fpic.patch new file mode 100644 index 0000000000000..680f251bd8de4 --- /dev/null +++ b/recipes/exiv2/all/patches/0002-fpic.patch @@ -0,0 +1,16 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index c52b352f..92fcd847 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -142,11 +142,6 @@ if (MSVC) + set_target_properties(exiv2lib PROPERTIES LINK_FLAGS "/ignore:4099") + endif() + +-set_target_properties( exiv2lib_int PROPERTIES +- POSITION_INDEPENDENT_CODE ON +- COMPILE_DEFINITIONS exiv2lib_EXPORTS +-) +- + target_include_directories(exiv2lib_int PRIVATE ${ZLIB_INCLUDE_DIR}) + target_include_directories(exiv2lib PRIVATE + $ diff --git a/recipes/exiv2/all/patches/0003-fix-ios.patch b/recipes/exiv2/all/patches/0003-fix-ios.patch new file mode 100644 index 0000000000000..062b6990f2cb2 --- /dev/null +++ b/recipes/exiv2/all/patches/0003-fix-ios.patch @@ -0,0 +1,30 @@ +patch from https://github.com/Exiv2/exiv2/pull/1718 + +--- a/src/futils.cpp ++++ b/src/futils.cpp +@@ -47,8 +47,11 @@ + #if defined(_MSC_VER) + #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) + #elif defined(__APPLE__) ++#include ++#ifndef TARGET_OS_IPHONE + #include + #endif ++#endif + + #if defined(__FreeBSD__) + #include +@@ -445,11 +448,13 @@ namespace Exiv2 { + CloseHandle(processHandle); + } + #elif defined(__APPLE__) ++ #ifndef TARGET_OS_IPHONE + const int pid = getpid(); + char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; + if (proc_pidpath (pid, pathbuf, sizeof(pathbuf)) > 0) { + ret = pathbuf; + } ++ #endif + #elif defined(__FreeBSD__) + unsigned int n; + char buffer[PATH_MAX] = {}; diff --git a/recipes/exiv2/all/patches/0004-find-expat.patch b/recipes/exiv2/all/patches/0004-find-expat.patch new file mode 100644 index 0000000000000..5bb571eb0f807 --- /dev/null +++ b/recipes/exiv2/all/patches/0004-find-expat.patch @@ -0,0 +1,15 @@ +Ensure to use FindEXPAT.cmake instead of expat-config.cmake +(side effect of CMAKE_FIND_PACKAGE_PREFER_CONFIG ON, see https://github.com/conan-io/conan/issues/10387) +diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake +index ec3a43f5..27bf42d3 100644 +--- a/cmake/findDependencies.cmake ++++ b/cmake/findDependencies.cmake +@@ -42,7 +42,7 @@ if (EXIV2_ENABLE_XMP AND EXIV2_ENABLE_EXTERNAL_XMP) + message(FATAL_ERROR "EXIV2_ENABLE_XMP AND EXIV2_ENABLE_EXTERNAL_XMP are mutually exclusive. You can only choose one of them") + else() + if (EXIV2_ENABLE_XMP) +- find_package(EXPAT REQUIRED) ++ find_package(EXPAT REQUIRED MODULE) + elseif (EXIV2_ENABLE_EXTERNAL_XMP) + find_package(XmpSdk REQUIRED) + endif () diff --git a/recipes/exiv2/all/test_package/CMakeLists.txt b/recipes/exiv2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3bd4318c428ba --- /dev/null +++ b/recipes/exiv2/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +find_package(exiv2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} exiv2lib) diff --git a/recipes/exiv2/all/test_package/conanfile.py b/recipes/exiv2/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/exiv2/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/exiv2/all/test_package/test_package.cpp b/recipes/exiv2/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..e92e73571e294 --- /dev/null +++ b/recipes/exiv2/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main() { + std::cout << Exiv2::versionString() << std::endl; + return 0; +} diff --git a/recipes/exiv2/all/test_v1_package/CMakeLists.txt b/recipes/exiv2/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f62a34fb6ca55 --- /dev/null +++ b/recipes/exiv2/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(exiv2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} exiv2lib) diff --git a/recipes/exiv2/all/test_v1_package/conanfile.py b/recipes/exiv2/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..b6a26067f365d --- /dev/null +++ b/recipes/exiv2/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os + +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/exiv2/config.yml b/recipes/exiv2/config.yml new file mode 100644 index 0000000000000..470d3a327a30b --- /dev/null +++ b/recipes/exiv2/config.yml @@ -0,0 +1,5 @@ +versions: + "0.27.5": + folder: all + "0.27.4": + folder: all diff --git a/recipes/expat/all/CMakeLists.txt b/recipes/expat/all/CMakeLists.txt deleted file mode 100644 index 1848ca5a77c35..0000000000000 --- a/recipes/expat/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/expat/all/conandata.yml b/recipes/expat/all/conandata.yml index c42d7251650f7..f3b9d575c901c 100644 --- a/recipes/expat/all/conandata.yml +++ b/recipes/expat/all/conandata.yml @@ -1,23 +1,40 @@ sources: - "2.2.7": - sha256: 42241742da97d40557857726cc4f02008cd14f2b44134c6e33af043967cd9d15 - url: https://github.com/libexpat/libexpat/releases/download/R_2_2_7/expat-2.2.7.tar.gz - "2.2.8": - sha256: bd507cba42716ca9afe46dd3687fb0d46c09347517beb9770f53a435d2c67ea0 - url: https://github.com/libexpat/libexpat/releases/download/R_2_2_8/expat-2.2.8.tar.gz - "2.2.9": - sha256: 4456e0aa72ecc7e1d4b3368cd545a5eec7f9de5133a8dc37fdb1efa6174c4947 - url: https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.gz - "2.2.10": - sha256: bf42d1f52371d23684de36cc6d2f0f1acd02de264d1105bdc17792bbeb7e7ceb - url: https://github.com/libexpat/libexpat/releases/download/R_2_2_10/expat-2.2.10.tar.gz - "2.3.0": - sha256: 89df123c62f2c2e2b235692d9fe76def6a9ab03dbe95835345bf412726eb1987 - url: https://github.com/libexpat/libexpat/releases/download/R_2_3_0/expat-2.3.0.tar.gz + "2.5.0": + url: "https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.xz" + sha256: "ef2420f0232c087801abf705e89ae65f6257df6b7931d37846a193ef2e8cdcbe" + "2.4.9": + sha256: "6e8c0728fe5c7cd3f93a6acce43046c5e4736c7b4b68e032e9350daa0efc0354" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_4_9/expat-2.4.9.tar.xz" + "2.4.8": + sha256: "f79b8f904b749e3e0d20afeadecf8249c55b2e32d4ebb089ae378df479dcaf25" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.xz" + "2.4.7": + sha256: "9875621085300591f1e64c18fd3da3a0eeca4a74f884b9abac2758ad1bd07a7d" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_4_7/expat-2.4.7.tar.xz" + "2.4.6": + sha256: "de55794b7a9bc214852fdc075beaaecd854efe1361597e6268ee87946951289b" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_4_6/expat-2.4.6.tar.xz" + "2.4.5": + sha256: "f2af8fc7cdc63a87920da38cd6d12cb113c3c3a3f437495b1b6541e0cff32579" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_4_5/expat-2.4.5.tar.xz" + "2.4.4": + sha256: "b5d25d6e373351c2ed19b562b4732d01d2589ac8c8e9e7962d8df1207cc311b8" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_4_4/expat-2.4.4.tar.xz" + "2.4.3": + sha256: "b1f9f1b1a5ebb0acaa88c9ff79bfa4e145823b78aa5185e5c5d85f060824778a" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_4_3/expat-2.4.3.tar.xz" + "2.4.2": + sha256: "a2fb692e8e610406168296f25ba500ae8ce22cb4c8947a8689894d744b6deb02" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_4_2/expat-2.4.2.tar.gz" "2.4.1": - sha256: a00ae8a6b96b63a3910ddc1100b1a7ef50dc26dceb65ced18ded31ab392f132b - url: https://github.com/libexpat/libexpat/releases/download/R_2_4_1/expat-2.4.1.tar.gz + sha256: "a00ae8a6b96b63a3910ddc1100b1a7ef50dc26dceb65ced18ded31ab392f132b" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_4_1/expat-2.4.1.tar.gz" + "2.3.0": + sha256: "89df123c62f2c2e2b235692d9fe76def6a9ab03dbe95835345bf412726eb1987" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_3_0/expat-2.3.0.tar.gz" + "2.2.10": + sha256: "bf42d1f52371d23684de36cc6d2f0f1acd02de264d1105bdc17792bbeb7e7ceb" + url: "https://github.com/libexpat/libexpat/releases/download/R_2_2_10/expat-2.2.10.tar.gz" patches: "2.3.0": - - patch_file: "patches/relax-vs-restriction.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-2.3.0-relax-vs-restriction.patch" diff --git a/recipes/expat/all/conanfile.py b/recipes/expat/all/conanfile.py index 9e61ff2504185..04caae4cbe008 100644 --- a/recipes/expat/all/conanfile.py +++ b/recipes/expat/all/conanfile.py @@ -1,23 +1,33 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime import os +required_conan_version = ">=1.53.0" + class ExpatConan(ConanFile): name = "expat" description = "Fast streaming XML parser written in C." - topics = ("conan", "expat", "xml", "parsing") + license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/libexpat/libexpat" - license = "MIT" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - generators = "cmake" - exports_sources = ["CMakeLists.txt", "patches/*"] - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + topics = ("xml", "parsing") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "char_type": ["char", "wchar_t", "ushort"], + } + default_options = { + "shared": False, + "fPIC": True, + "char_type": "char", + } - _cmake = None + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -25,53 +35,62 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - if tools.Version(self.version) < "2.2.8": - self._cmake.definitions["BUILD_doc"] = "Off" - self._cmake.definitions["BUILD_examples"] = "Off" - self._cmake.definitions["BUILD_shared"] = self.options.shared - self._cmake.definitions["BUILD_tests"] = "Off" - self._cmake.definitions["BUILD_tools"] = "Off" - else: - # These options were renamed in 2.2.8 to be more consistent - self._cmake.definitions["EXPAT_BUILD_DOCS"] = "Off" - self._cmake.definitions["EXPAT_BUILD_EXAMPLES"] = "Off" - self._cmake.definitions["EXPAT_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["EXPAT_BUILD_TESTS"] = "Off" - self._cmake.definitions["EXPAT_BUILD_TOOLS"] = "Off" + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["EXPAT_BUILD_DOCS"] = False + tc.variables["EXPAT_BUILD_EXAMPLES"] = False + tc.variables["EXPAT_SHARED_LIBS"] = self.options.shared + tc.variables["EXPAT_BUILD_TESTS"] = False + tc.variables["EXPAT_BUILD_TOOLS"] = False + tc.variables["EXPAT_CHAR_TYPE"] = self.options.char_type + if is_msvc(self): + tc.variables["EXPAT_MSVC_STATIC_CRT"] = is_msvc_static_runtime(self) + tc.variables["EXPAT_BUILD_PKGCONFIG"] = False + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "EXPAT" - self.cpp_info.names["cmake_find_package_multi"] = "expat" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_module_file_name", "EXPAT") + self.cpp_info.set_property("cmake_module_target_name", "EXPAT::EXPAT") + self.cpp_info.set_property("cmake_file_name", "expat") + self.cpp_info.set_property("cmake_target_name", "expat::expat") + self.cpp_info.set_property("pkg_config_name", "expat") + + self.cpp_info.libs = collect_libs(self) if not self.options.shared: self.cpp_info.defines = ["XML_STATIC"] + if self.options.get_safe("char_type") in ("wchar_t", "ushort"): + self.cpp_info.defines.append("XML_UNICODE") + elif self.options.get_safe("char_type") == "wchar_t": + self.cpp_info.defines.append("XML_UNICODE_WCHAR_T") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + + # TODO: to remove in conan v2 + self.cpp_info.names["cmake_find_package"] = "EXPAT" + self.cpp_info.names["cmake_find_package_multi"] = "expat" diff --git a/recipes/expat/all/patches/relax-vs-restriction.patch b/recipes/expat/all/patches/0001-2.3.0-relax-vs-restriction.patch similarity index 100% rename from recipes/expat/all/patches/relax-vs-restriction.patch rename to recipes/expat/all/patches/0001-2.3.0-relax-vs-restriction.patch diff --git a/recipes/expat/all/test_package/CMakeLists.txt b/recipes/expat/all/test_package/CMakeLists.txt index 65748d8865a87..5129dd0d2152f 100644 --- a/recipes/expat/all/test_package/CMakeLists.txt +++ b/recipes/expat/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(expat REQUIRED CONFIG) -find_package(EXPAT REQUIRED) - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} EXPAT::EXPAT) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE expat::expat) diff --git a/recipes/expat/all/test_package/conanfile.py b/recipes/expat/all/test_package/conanfile.py index 1d0bdd3779793..98ab55852ad56 100644 --- a/recipes/expat/all/test_package/conanfile.py +++ b/recipes/expat/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/expat/all/test_package/test_package.c b/recipes/expat/all/test_package/test_package.c new file mode 100644 index 0000000000000..71ad7b8f7ebc2 --- /dev/null +++ b/recipes/expat/all/test_package/test_package.c @@ -0,0 +1,64 @@ +/* This is simple demonstration of how to use expat. This program + reads an XML document from standard input and writes a line with + the name of each element to standard output indenting child + elements by one tab stop more than their parent element. + It must be used with Expat compiled for UTF-8 output. +*/ + +#include +#include "expat.h" + +#ifdef XML_UNICODE_WCHAR_T +#include +#endif + +#ifdef XML_LARGE_SIZE +#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 +#define XML_FMT_INT_MOD "I64" +#else +#define XML_FMT_INT_MOD "ll" +#endif +#else +#define XML_FMT_INT_MOD "l" +#endif + +static void XMLCALL +startElement(void *userData, const XML_Char *name, const XML_Char **atts) +{ + int i; + int *depthPtr = (int *)userData; + (void)atts; + + for (i = 0; i < *depthPtr; i++) + putchar('\t'); +#ifdef XML_UNICODE_WCHAR_T + fputws(name, stdout); +#else + puts(name); +#endif + *depthPtr += 1; +} + +static void XMLCALL +endElement(void *userData, const XML_Char *name) +{ + int *depthPtr = (int *)userData; + (void)name; + + *depthPtr -= 1; +} + +int +main(int argc, char *argv[]) +{ + XML_Parser parser = XML_ParserCreate(NULL); + int depth = 0; + (void)argc; + (void)argv; + + XML_SetUserData(parser, &depth); + XML_SetElementHandler(parser, startElement, endElement); + XML_ParserFree(parser); + printf("Test application successfully ran!\n"); + return 0; +} diff --git a/recipes/expat/all/test_package/test_package.cpp b/recipes/expat/all/test_package/test_package.cpp deleted file mode 100644 index bb7139f12e9d9..0000000000000 --- a/recipes/expat/all/test_package/test_package.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* This is simple demonstration of how to use expat. This program - reads an XML document from standard input and writes a line with - the name of each element to standard output indenting child - elements by one tab stop more than their parent element. - It must be used with Expat compiled for UTF-8 output. -*/ - -#include -#include "expat.h" - -#ifdef XML_LARGE_SIZE -#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 -#define XML_FMT_INT_MOD "I64" -#else -#define XML_FMT_INT_MOD "ll" -#endif -#else -#define XML_FMT_INT_MOD "l" -#endif - -static void XMLCALL -startElement(void *userData, const char *name, const char **atts) -{ - int i; - int *depthPtr = (int *)userData; - (void)atts; - - for (i = 0; i < *depthPtr; i++) - putchar('\t'); - puts(name); - *depthPtr += 1; -} - -static void XMLCALL -endElement(void *userData, const char *name) -{ - int *depthPtr = (int *)userData; - (void)name; - - *depthPtr -= 1; -} - -int -main(int argc, char *argv[]) -{ - XML_Parser parser = XML_ParserCreate(NULL); - int depth = 0; - (void)argc; - (void)argv; - - XML_SetUserData(parser, &depth); - XML_SetElementHandler(parser, startElement, endElement); - XML_ParserFree(parser); - printf("Test application successfully ran!\n"); - return 0; -} diff --git a/recipes/expat/all/test_package_module/CMakeLists.txt b/recipes/expat/all/test_package_module/CMakeLists.txt new file mode 100644 index 0000000000000..cc3b096a67958 --- /dev/null +++ b/recipes/expat/all/test_package_module/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.10) +project(test_package LANGUAGES C) + +find_package(EXPAT REQUIRED MODULE) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE EXPAT::EXPAT) + +# Test whether variables from https://cmake.org/cmake/help/latest/module/FindEXPAT.html +# are properly defined in conan generators +set(_custom_vars + EXPAT_INCLUDE_DIRS + EXPAT_LIBRARIES + EXPAT_FOUND +) +foreach(_custom_var ${_custom_vars}) + if(DEFINED _custom_var) + message(STATUS "${_custom_var}: ${${_custom_var}}") + else() + message(FATAL_ERROR "${_custom_var} not defined") + endif() +endforeach() diff --git a/recipes/expat/all/test_package_module/conanfile.py b/recipes/expat/all/test_package_module/conanfile.py new file mode 100644 index 0000000000000..98ab55852ad56 --- /dev/null +++ b/recipes/expat/all/test_package_module/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/expat/all/test_v1_package/CMakeLists.txt b/recipes/expat/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..de3b75d9538de --- /dev/null +++ b/recipes/expat/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/expat/all/test_v1_package/conanfile.py b/recipes/expat/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/expat/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/expat/all/test_v1_package_module/CMakeLists.txt b/recipes/expat/all/test_v1_package_module/CMakeLists.txt new file mode 100644 index 0000000000000..1626621388ae7 --- /dev/null +++ b/recipes/expat/all/test_v1_package_module/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package_module/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package_module/) diff --git a/recipes/expat/all/test_v1_package_module/conanfile.py b/recipes/expat/all/test_v1_package_module/conanfile.py new file mode 100644 index 0000000000000..5f9efeb33878b --- /dev/null +++ b/recipes/expat/all/test_v1_package_module/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/expat/config.yml b/recipes/expat/config.yml index 458ab8d9240e4..e09e9d75495cc 100644 --- a/recipes/expat/config.yml +++ b/recipes/expat/config.yml @@ -1,13 +1,25 @@ versions: - "2.2.7": + "2.5.0": folder: all - "2.2.8": + "2.4.9": folder: all - "2.2.9": + "2.4.8": folder: all - "2.2.10": + "2.4.7": folder: all - "2.3.0": + "2.4.6": + folder: all + "2.4.5": + folder: all + "2.4.4": + folder: all + "2.4.3": + folder: all + "2.4.2": folder: all "2.4.1": folder: all + "2.3.0": + folder: all + "2.2.10": + folder: all diff --git a/recipes/expected-lite/all/conandata.yml b/recipes/expected-lite/all/conandata.yml index cc470b993f09b..164f98f702d8b 100644 --- a/recipes/expected-lite/all/conandata.yml +++ b/recipes/expected-lite/all/conandata.yml @@ -1,10 +1,19 @@ sources: - "0.3.0": - url: https://github.com/martinmoene/expected-lite/archive/v0.3.0.tar.gz - sha256: fc942ce0614e9498bff6f35f1ee8d58f83026bac904d9ab427a2e822b5bdfcbd - "0.4.0": - url: https://github.com/martinmoene/expected-lite/archive/v0.4.0.tar.gz - sha256: bf4c0ceec0f1197f33dbab1d5cce43af8722d9507143c6ec837ee3288e29f80c + "0.6.2": + url: "https://github.com/martinmoene/expected-lite/archive/v0.6.2.tar.gz" + sha256: "8e3c58fddb32abc22a429543440554f1ae50d1de3fb9a0abf699bc3f247dc1da" + "0.6.1": + url: "https://github.com/martinmoene/expected-lite/archive/v0.6.1.tar.gz" + sha256: "91724069aaab7491d48ac0711f9af7fd4fd1a3b0f95406c3a773b7944e67f125" + "0.6.0": + url: "https://github.com/martinmoene/expected-lite/archive/v0.6.0.tar.gz" + sha256: "90478ff7345100bf7539b12ea2c5ff04a7b6290bc5c280f02b473d5c65165342" "0.5.0": - url: https://github.com/martinmoene/expected-lite/archive/v0.5.0.tar.gz - sha256: 80f8c91d228cdc5cac3698141c0321d51dcdb0239c2fdcdeae7d46a9a58f2297 + url: "https://github.com/martinmoene/expected-lite/archive/v0.5.0.tar.gz" + sha256: "80f8c91d228cdc5cac3698141c0321d51dcdb0239c2fdcdeae7d46a9a58f2297" + "0.4.0": + url: "https://github.com/martinmoene/expected-lite/archive/v0.4.0.tar.gz" + sha256: "bf4c0ceec0f1197f33dbab1d5cce43af8722d9507143c6ec837ee3288e29f80c" + "0.3.0": + url: "https://github.com/martinmoene/expected-lite/archive/v0.3.0.tar.gz" + sha256: "fc942ce0614e9498bff6f35f1ee8d58f83026bac904d9ab427a2e822b5bdfcbd" diff --git a/recipes/expected-lite/all/conanfile.py b/recipes/expected-lite/all/conanfile.py index 843d8c52f5b00..bb539b3e7df62 100644 --- a/recipes/expected-lite/all/conanfile.py +++ b/recipes/expected-lite/all/conanfile.py @@ -1,42 +1,56 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.50.0" + class ExpectedLiteConan(ConanFile): name = "expected-lite" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/martinmoene/expected-lite" description = "expected lite - Expected objects in C++11 and later in a single-file header-only library" - topics = ("conan", "cpp11", "cpp14", "cpp17", "expected", "expected-implementations") + topics = ("cpp11", "cpp14", "cpp17", "expected", "expected-implementations") license = "BSL-1.0" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) - def package_id(self): - self.info.header_only() + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "expected-lite") + self.cpp_info.set_property("cmake_target_name", "nonstd::expected-lite") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "expected-lite" self.cpp_info.filenames["cmake_find_package_multi"] = "expected-lite" self.cpp_info.names["cmake_find_package"] = "nonstd" self.cpp_info.names["cmake_find_package_multi"] = "nonstd" self.cpp_info.components["expectedlite"].names["cmake_find_package"] = "expected-lite" self.cpp_info.components["expectedlite"].names["cmake_find_package_multi"] = "expected-lite" + self.cpp_info.components["expectedlite"].set_property("cmake_target_name", "nonstd::expected-lite") diff --git a/recipes/expected-lite/all/test_package/CMakeLists.txt b/recipes/expected-lite/all/test_package/CMakeLists.txt index 0bf8db199e758..1d87701ed4e32 100644 --- a/recipes/expected-lite/all/test_package/CMakeLists.txt +++ b/recipes/expected-lite/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(expected-lite REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} nonstd::expected-lite) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::expected-lite) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/expected-lite/all/test_package/conanfile.py b/recipes/expected-lite/all/test_package/conanfile.py index abcaeed3f89b6..d120a992c06a6 100644 --- a/recipes/expected-lite/all/test_package/conanfile.py +++ b/recipes/expected-lite/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/expected-lite/all/test_v1_package/CMakeLists.txt b/recipes/expected-lite/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d57a2501c92f1 --- /dev/null +++ b/recipes/expected-lite/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(expected-lite REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::expected-lite) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/expected-lite/all/test_v1_package/conanfile.py b/recipes/expected-lite/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/expected-lite/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/expected-lite/config.yml b/recipes/expected-lite/config.yml index e82cf91c0c79f..ad5f08f24e4fd 100644 --- a/recipes/expected-lite/config.yml +++ b/recipes/expected-lite/config.yml @@ -1,7 +1,13 @@ versions: - "0.3.0": + "0.6.2": folder: all - "0.4.0": + "0.6.1": + folder: all + "0.6.0": folder: all "0.5.0": folder: all + "0.4.0": + folder: all + "0.3.0": + folder: all diff --git a/recipes/exprtk/all/conandata.yml b/recipes/exprtk/all/conandata.yml new file mode 100755 index 0000000000000..7cc52941e132f --- /dev/null +++ b/recipes/exprtk/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.0.1": + url: "https://github.com/ArashPartow/exprtk/archive/refs/tags/0.0.1.tar.gz" + sha256: "fb72791c88ae3b3426e14fdad630027715682584daf56b973569718c56e33f28" diff --git a/recipes/exprtk/all/conanfile.py b/recipes/exprtk/all/conanfile.py new file mode 100755 index 0000000000000..659e03b1f7e7e --- /dev/null +++ b/recipes/exprtk/all/conanfile.py @@ -0,0 +1,42 @@ +import os +from conans import ConanFile, tools + +required_conan_version = ">=1.33.0" + + +class ExprTkConan(ConanFile): + name = "exprtk" + description = "C++ Mathematical Expression Parsing And Evaluation Library ExprTk" + license = ("MIT") + topics = ("exprtk", "cpp", "math", "mathematics", "parser", "lexer", "numerical") + homepage = "https://www.partow.net/programming/exprtk/index.html" + url = "https://github.com/conan-io/conan-center-index" + settings = "compiler" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _extract_license(self): + exprtk_header_file = "exprtk.hpp" + file = os.path.join(self.source_folder, self._source_subfolder, exprtk_header_file) + file_content = tools.load(file) + license_end = "/MIT *" + license_contents = file_content[2:file_content.find(license_end) + len(license_end)] + tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), license_contents) + + def package(self): + self._extract_license() + self.copy("exprtk.hpp", dst="include" , src=self._source_subfolder) diff --git a/recipes/exprtk/all/test_package/CMakeLists.txt b/recipes/exprtk/all/test_package/CMakeLists.txt new file mode 100755 index 0000000000000..d2caf6eebd908 --- /dev/null +++ b/recipes/exprtk/all/test_package/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.1) + +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) + +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) + +if (MSVC) + target_compile_options(${PROJECT_NAME} PRIVATE "/bigobj") +endif (MSVC) + +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/exprtk/all/test_package/conanfile.py b/recipes/exprtk/all/test_package/conanfile.py new file mode 100755 index 0000000000000..5c09494bc67c0 --- /dev/null +++ b/recipes/exprtk/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/exprtk/all/test_package/test_package.cpp b/recipes/exprtk/all/test_package/test_package.cpp new file mode 100755 index 0000000000000..8ae4a2288e7ce --- /dev/null +++ b/recipes/exprtk/all/test_package/test_package.cpp @@ -0,0 +1,78 @@ +/* + ************************************************************** + * C++ Mathematical Expression Toolkit Library * + * * + * Exprtk Test Package * + * Author: Arash Partow (1999-2022) * + * URL: https://www.partow.net/programming/exprtk/index.html * + * * + * Copyright notice: * + * Free use of the Mathematical Expression Toolkit Library is * + * permitted under the guidelines and in accordance with the * + * most current version of the MIT License. * + * http://www.opensource.org/licenses/MIT * + * * + ************************************************************** +*/ + + +#include +#include + +#include + + +template +void test_function() +{ + typedef exprtk::symbol_table symbol_table_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; + typedef exprtk::parser_error::type error_t; + + symbol_table_t symbol_table; + expression_t expression; + parser_t parser; + + T x = 1; + T y = 2; + + const std::string expression_string = "x * y + 3"; + + symbol_table.add_variable("x",x); + symbol_table.add_variable("y",y); + + expression.register_symbol_table(symbol_table); + + if (!parser.compile(expression_string,expression)) + { + printf("Error: %s\tExpression: %s\n", + parser.error().c_str(), + expression_string.c_str()); + + for (std::size_t i = 0; i < parser.error_count(); ++i) + { + const error_t error = parser.get_error(i); + + printf("Error: %02d Position: %02d " + "Type: [%s] " + "Message: %s " + "Expression: %s\n", + static_cast(i), + static_cast(error.token.position), + exprtk::parser_error::to_str(error.mode).c_str(), + error.diagnostic.c_str(), + expression_string.c_str()); + } + + return; + } + + expression.value(); +} + +int main() +{ + test_function(); + return 0; +} diff --git a/recipes/exprtk/config.yml b/recipes/exprtk/config.yml new file mode 100755 index 0000000000000..fcaa7fd847f94 --- /dev/null +++ b/recipes/exprtk/config.yml @@ -0,0 +1,3 @@ +versions: + "0.0.1": + folder: "all" diff --git a/recipes/extra-cmake-modules/all/conandata.yml b/recipes/extra-cmake-modules/all/conandata.yml index 8f7f6ed9ed4b4..c1c71096d72a6 100644 --- a/recipes/extra-cmake-modules/all/conandata.yml +++ b/recipes/extra-cmake-modules/all/conandata.yml @@ -5,3 +5,9 @@ sources: "5.80.0": url: "https://download.kde.org/stable/frameworks/5.80/extra-cmake-modules-5.80.0.tar.xz" sha256: "2370fd80f685533d0b96efa6fa443ceea68e0ceba4e8a9d7c151d297b1c96f64" + "5.84.0": + url: "https://download.kde.org/stable/frameworks/5.84/extra-cmake-modules-5.84.0.tar.xz" + sha256: "bb085ef2e177c182ff46988516b6b31849d1497beb2ff5301165ad2ba12a1c41" + "5.93.0": + url: "https://download.kde.org/stable/frameworks/5.93/extra-cmake-modules-5.93.0.tar.xz" + sha256: "093dea7b11647bc5f74e6971d47ef15b5c410cba2b4620acae00f008d5480b21" diff --git a/recipes/extra-cmake-modules/config.yml b/recipes/extra-cmake-modules/config.yml index 97de1e24a57d6..c17f03346f04f 100644 --- a/recipes/extra-cmake-modules/config.yml +++ b/recipes/extra-cmake-modules/config.yml @@ -3,3 +3,7 @@ versions: folder: "all" "5.80.0": folder: "all" + "5.84.0": + folder: "all" + "5.93.0": + folder: "all" diff --git a/recipes/ezc3d/all/CMakeLists.txt b/recipes/ezc3d/all/CMakeLists.txt deleted file mode 100644 index 361b35d4c17d9..0000000000000 --- a/recipes/ezc3d/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/ezc3d/all/conandata.yml b/recipes/ezc3d/all/conandata.yml index c73e1fb08a97e..7c22e7d856992 100644 --- a/recipes/ezc3d/all/conandata.yml +++ b/recipes/ezc3d/all/conandata.yml @@ -1,11 +1,15 @@ sources: + "1.5.0": + url: "https://github.com/pyomeca/ezc3d/archive/refs/tags/Release_1.5.0.tar.gz" + sha256: "8387857d989f5bbb62869ec930b417e6d0a303eef9b39e8b0e6b35437d5809ce" + "1.4.8": + url: "https://github.com/pyomeca/ezc3d/archive/refs/tags/Release_1.4.8.tar.gz" + sha256: "ebe69a97ba64b463b0d4b0bd1657fa55af9bc17572a3b6bf9e8b321846cd30c8" "1.3.8": url: "https://github.com/pyomeca/ezc3d/archive/Release_1.3.8.tar.gz" sha256: "888cb191c7939b31891e93356aa5bfcf21edb8785d3b5d4d9ec215984bc8b83e" - "1.3.7": - url: "https://github.com/pyomeca/ezc3d/archive/Release_1.3.7.tar.gz" - sha256: "17cd3d4e20840710d58b8987c01ef0f880bc0c063ab52e0cb86ba41665ec33a0" patches: - "1.3.7": - - patch_file: "patches/fix-export-symbols.patch" - base_path: "source_subfolder" + "1.4.8": + - patch_file: "patches/0001-fix-cmake-1.4.8.patch" + "1.3.8": + - patch_file: "patches/0001-fix-cmake-1.3.8.patch" diff --git a/recipes/ezc3d/all/conanfile.py b/recipes/ezc3d/all/conanfile.py index b9182068cdba8..d28fe42575811 100644 --- a/recipes/ezc3d/all/conanfile.py +++ b/recipes/ezc3d/all/conanfile.py @@ -1,25 +1,35 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir, save +from conan.tools.scm import Version import os +import textwrap + +required_conan_version = ">=1.50.0" -from conans import ConanFile, CMake, tools class Ezc3dConan(ConanFile): name = "ezc3d" description = "EZC3D is an easy to use reader, modifier and writer for C3D format files." license = "MIT" - topics = ("conan", "ezc3d", "c3d") + topics = ("ezc3d", "c3d") homepage = "https://github.com/pyomeca/ezc3d" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -28,60 +38,77 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "ezc3d-Release_{}".format(self.version) - os.rename(extracted_dir, self._source_subfolder) - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - # don't force PIC - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "") - # fix install - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "set(${PROJECT_NAME}_LIB_FOLDER Lib)", - "set(${PROJECT_NAME}_LIB_FOLDER lib)") - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "set(${PROJECT_NAME}_LIB_FOLDER lib/${PROJECT_NAME})", - "set(${PROJECT_NAME}_LIB_FOLDER lib)") - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "set(${PROJECT_NAME}_BIN_FOLDER lib/${PROJECT_NAME})", - "set(${PROJECT_NAME}_BIN_FOLDER bin)") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["USE_MATRIX_FAST_ACCESSOR"] = True - self._cmake.definitions["BINDER_PYTHON3"] = False - self._cmake.definitions["BINDER_MATLAB"] = False - self._cmake.definitions["BUILD_EXAMPLE"] = False - self._cmake.definitions["BUILD_DOC"] = False - self._cmake.definitions["GET_OFFICIAL_DOCUMENTATION"] = False - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["USE_MATRIX_FAST_ACCESSOR"] = True + tc.variables["BINDER_PYTHON3"] = False + tc.variables["BINDER_MATLAB"] = False + if Version(self.version) >= "1.4.3": + tc.variables["BINDER_OCTAVE"] = False + tc.variables["BUILD_EXAMPLE"] = False + tc.variables["BUILD_DOC"] = False + tc.variables["GET_OFFICIAL_DOCUMENTATION"] = False + tc.variables["BUILD_TESTS"] = False + tc.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "CMake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove once cmake_find_package* removed in conan v2 + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"ezc3d": "ezc3d::ezc3d"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): - # FIXME: remove namespace for imported target + self.cpp_info.set_property("cmake_file_name", "ezc3d") + self.cpp_info.set_property("cmake_target_name", "ezc3d") + self.cpp_info.includedirs.append(os.path.join("include", "ezc3d")) lib_suffix = {"Debug": "_debug"}.get(str(self.settings.build_type), "") self.cpp_info.libs = ["ezc3d" + lib_suffix] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] + + # TODO: to remove once cmake_find_package* removed in conan v2 + self.cpp_info.names["cmake_find_package"] = "ezc3d" + self.cpp_info.names["cmake_find_package_multi"] = "ezc3d" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/ezc3d/all/patches/0001-fix-cmake-1.3.8.patch b/recipes/ezc3d/all/patches/0001-fix-cmake-1.3.8.patch new file mode 100644 index 0000000000000..29143b93ecbef --- /dev/null +++ b/recipes/ezc3d/all/patches/0001-fix-cmake-1.3.8.patch @@ -0,0 +1,35 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.8) + cmake_policy(SET CMP0048 NEW) + project(ezc3d VERSION 1.3.7) + set(EZC3D_NAME ${PROJECT_NAME}) +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) + set(EZC3D_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) + set(EZC3D_VERSION_MINOR ${PROJECT_VERSION_MINOR}) + set(EZC3D_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +@@ -45,6 +43,7 @@ if (BUILD_SHARED_LIBS) + else() + add_library(${PROJECT_NAME} STATIC ${SRC_LIST}) + endif() ++target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) + set_target_properties(${PROJECT_NAME} PROPERTIES + DEBUG_POSTFIX "_debug" + CXX_VISIBILITY_PRESET hidden +@@ -79,12 +78,12 @@ target_include_directories(${PROJECT_NAME} INTERFACE + + # Install target + if(WIN32) +- set(${PROJECT_NAME}_LIB_FOLDER Lib) ++ set(${PROJECT_NAME}_LIB_FOLDER lib) + set(${PROJECT_NAME}_BIN_FOLDER bin) + set(${PROJECT_NAME}_INCLUDE_FOLDER include/${PROJECT_NAME}) + else() +- set(${PROJECT_NAME}_LIB_FOLDER lib/${PROJECT_NAME}) +- set(${PROJECT_NAME}_BIN_FOLDER lib/${PROJECT_NAME}) ++ set(${PROJECT_NAME}_LIB_FOLDER lib) ++ set(${PROJECT_NAME}_BIN_FOLDER bin) + set(${PROJECT_NAME}_INCLUDE_FOLDER include/${PROJECT_NAME}) + endif() + install(TARGETS ${PROJECT_NAME} EXPORT ezc3dTargets diff --git a/recipes/ezc3d/all/patches/0001-fix-cmake-1.4.8.patch b/recipes/ezc3d/all/patches/0001-fix-cmake-1.4.8.patch new file mode 100644 index 0000000000000..5edaea8bb062b --- /dev/null +++ b/recipes/ezc3d/all/patches/0001-fix-cmake-1.4.8.patch @@ -0,0 +1,35 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -3,8 +3,6 @@ cmake_policy(SET CMP0048 NEW) + project(ezc3d VERSION 1.4.8) + set(EZC3D_NAME ${PROJECT_NAME}) + set(EZC3D_ROOT_FOLDER ${PROJECT_SOURCE_DIR}) +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) + set(EZC3D_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) + set(EZC3D_VERSION_MINOR ${PROJECT_VERSION_MINOR}) + set(EZC3D_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +@@ -56,6 +54,7 @@ if (BUILD_SHARED_LIBS) + else() + add_library(${PROJECT_NAME} STATIC ${SRC_LIST}) + endif() ++target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) + set_target_properties(${PROJECT_NAME} PROPERTIES + DEBUG_POSTFIX "_debug" + CXX_VISIBILITY_PRESET hidden +@@ -91,12 +90,12 @@ target_include_directories(${PROJECT_NAME} INTERFACE + # Install target + if(WIN32) + # NOTE: Maybe use GNUInstallDirs? +- set(${PROJECT_NAME}_LIB_FOLDER Lib CACHE STRING "ARCHIVE/LIBRARY DESTINATION") ++ set(${PROJECT_NAME}_LIB_FOLDER lib CACHE STRING "ARCHIVE/LIBRARY DESTINATION") + set(${PROJECT_NAME}_BIN_FOLDER bin CACHE STRING "RUNTIME DESTINATION") + set(${PROJECT_NAME}_INCLUDE_FOLDER include/${PROJECT_NAME} CACHE STRING "INCLUDE DESTINATION") + else() +- set(${PROJECT_NAME}_LIB_FOLDER lib/${PROJECT_NAME} CACHE STRING "ARCHIVE/LIBRARY DESTINATION") +- set(${PROJECT_NAME}_BIN_FOLDER lib/${PROJECT_NAME} CACHE STRING "RUNTIME DESTINATION") ++ set(${PROJECT_NAME}_LIB_FOLDER lib CACHE STRING "ARCHIVE/LIBRARY DESTINATION") ++ set(${PROJECT_NAME}_BIN_FOLDER bin CACHE STRING "RUNTIME DESTINATION") + set(${PROJECT_NAME}_INCLUDE_FOLDER include/${PROJECT_NAME} CACHE STRING "INCLUDE DESTINATION") + endif() + install(TARGETS ${PROJECT_NAME} EXPORT ezc3dTargets diff --git a/recipes/ezc3d/all/patches/fix-export-symbols.patch b/recipes/ezc3d/all/patches/fix-export-symbols.patch deleted file mode 100644 index d5b75eec8da68..0000000000000 --- a/recipes/ezc3d/all/patches/fix-export-symbols.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -40,11 +40,16 @@ set(SRC_LIST - - set(BUILD_SHARED_LIBS TRUE CACHE BOOL "Choose if build should be a dynamic or static library") - if (BUILD_SHARED_LIBS) -+ set(EZC3D_SHARED TRUE) - add_library(${PROJECT_NAME} SHARED ${SRC_LIST}) - else() - add_library(${PROJECT_NAME} STATIC ${SRC_LIST}) - endif() --set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_debug") -+set_target_properties(${PROJECT_NAME} PROPERTIES -+ DEBUG_POSTFIX "_debug" -+ CXX_VISIBILITY_PRESET hidden -+ VISIBILITY_INLINES_HIDDEN ON -+) - - # Remember the CMAKE_CURRENT_BINARY_DIR (important if ezc3d is used as submodule) - set(EZC3D_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) ---- a/include/ezc3dConfig.h.in -+++ b/include/ezc3dConfig.h.in -@@ -1,12 +1,18 @@ - #ifndef EZC3D_CONFIG_H - #define EZC3D_CONFIG_H - -+#cmakedefine EZC3D_SHARED -+ - // dllexport/import declaration --#ifdef _WIN32 -- #ifdef EZC3D_API_EXPORTS -- #define EZC3D_API __declspec(dllexport) -+#ifdef EZC3D_SHARED -+ #ifdef _WIN32 -+ #ifdef EZC3D_API_EXPORTS -+ #define EZC3D_API __declspec(dllexport) -+ #else -+ #define EZC3D_API __declspec(dllimport) -+ #endif - #else -- #define EZC3D_API __declspec(dllimport) -+ #define EZC3D_API __attribute__ ((visibility ("default"))) - #endif - #else - #define EZC3D_API diff --git a/recipes/ezc3d/all/test_package/CMakeLists.txt b/recipes/ezc3d/all/test_package/CMakeLists.txt index 05dca2cc237fe..b1b2099ff3c1c 100644 --- a/recipes/ezc3d/all/test_package/CMakeLists.txt +++ b/recipes/ezc3d/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(ezc3d REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ezc3d::ezc3d) # TODO: remove ezc3d namespace when fixed in conanfile -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE ezc3d) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/ezc3d/all/test_package/conanfile.py b/recipes/ezc3d/all/test_package/conanfile.py index c6580760bfee2..3a8c6c5442b33 100644 --- a/recipes/ezc3d/all/test_package/conanfile.py +++ b/recipes/ezc3d/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/ezc3d/all/test_v1_package/CMakeLists.txt b/recipes/ezc3d/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..05feb4e3a5565 --- /dev/null +++ b/recipes/ezc3d/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ezc3d REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ezc3d) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/ezc3d/all/test_v1_package/conanfile.py b/recipes/ezc3d/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/ezc3d/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ezc3d/config.yml b/recipes/ezc3d/config.yml index ebf6cb93990c7..3d5d9b1cd1d49 100644 --- a/recipes/ezc3d/config.yml +++ b/recipes/ezc3d/config.yml @@ -1,5 +1,7 @@ versions: - "1.3.8": + "1.5.0": + folder: all + "1.4.8": folder: all - "1.3.7": + "1.3.8": folder: all diff --git a/recipes/faac/all/conandata.yml b/recipes/faac/all/conandata.yml new file mode 100644 index 0000000000000..187de5684ab94 --- /dev/null +++ b/recipes/faac/all/conandata.yml @@ -0,0 +1,11 @@ +sources: + "1.30": + url: "https://github.com/knik0/faac/archive/1_30.tar.gz" + sha256: "adc387ce588cca16d98c03b6ec1e58f0ffd9fc6eadb00e254157d6b16203b2d2" + "1.28": + url: "https://github.com/knik0/faac/archive/refs/tags/faac1_28.tar.gz" + sha256: "fec821797a541e8359f086fef454b947a7f7246fe8ec6207668968b86606a7dd" +patches: + "1.30": + - patch_file: "patches/001-fix-out-of-root-build.patch" + base_path: "source_subfolder" diff --git a/recipes/faac/all/conanfile.py b/recipes/faac/all/conanfile.py new file mode 100644 index 0000000000000..bd64d9ff6cbb8 --- /dev/null +++ b/recipes/faac/all/conanfile.py @@ -0,0 +1,129 @@ +from conan.tools.files import apply_conandata_patches +from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.33.0" + + +class FaacConan(ConanFile): + name = "faac" + description = "Freeware Advanced Audio Coder" + topics = ("audio", "mp4", "encoder", "aac", "m4a", "faac") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://sourceforge.net/projects/faac" + license = "LGPL-2.0-only" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_mp4": [True, False], + "drm": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_mp4": False, + "drm": False, + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _is_mingw(self): + return self.settings.os == "Windows" and self.settings.compiler == "gcc" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _has_mp4_option(self): + return tools.Version(self.version) < "1.29.1" + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if not self._has_mp4_option: + del self.options.with_mp4 + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + # FIXME: libfaac depends on kissfft. Try to unvendor this dependency + pass + + def validate(self): + if self._is_msvc: + # FIXME: add msvc support since there are MSBuild files upstream + raise ConanInvalidConfiguration("libfaac conan-center recipe doesn't support building with Visual Studio yet") + if self.options.get_safe("with_mp4"): + # TODO: as mpv4v2 as a conan package + raise ConanInvalidConfiguration("building with mp4v2 is not supported currently") + + def build_requirements(self): + self.build_requires("libtool/2.4.6") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + @functools.lru_cache(1) + def _configure_autotools(self): + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-drm={}".format(yes_no(self.options.drm)), + ] + if self._has_mp4_option: + args.append("--with-mp4v2={}".format(yes_no(self.options.with_mp4))) + autotools.configure(configure_dir=self._source_subfolder, args=args) + return autotools + + def build(self): + apply_conandata_patches(self) + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name @rpath/") + if self._is_mingw and self.options.shared: + tools.replace_in_file(os.path.join("libfaac", "Makefile"), + "\nlibfaac_la_LIBADD = ", + "\nlibfaac_la_LIBADD = -no-undefined ") + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + + def package_info(self): + self.cpp_info.libs = ["faac"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) diff --git a/recipes/faac/all/patches/001-fix-out-of-root-build.patch b/recipes/faac/all/patches/001-fix-out-of-root-build.patch new file mode 100644 index 0000000000000..134c51ffeb5d1 --- /dev/null +++ b/recipes/faac/all/patches/001-fix-out-of-root-build.patch @@ -0,0 +1,29 @@ +From c8d12a5c7c5b6f1c4593f0a6c1eeceacc4d7c941 Mon Sep 17 00:00:00 2001 +From: Christopher Degawa +Date: Sun, 29 Dec 2019 21:10:15 +0000 +Subject: [PATCH] frontend: fix out-of-root build + +from https://github.com/m-ab-s/media-autobuild_suite/commit/11d58abd8fde7c70378993029bad7bbaeb5f7e3e +--- + frontend/Makefile.am | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/frontend/Makefile.am b/frontend/Makefile.am +index dbe88c4..745a2f1 100644 +--- a/frontend/Makefile.am ++++ b/frontend/Makefile.am +@@ -14,10 +14,10 @@ bin_PROGRAMS += faacgui + faacgui_SOURCES = maingui.c input.c input.h resource.h + faac_LDADD += -lws2_32 icon.o + faacgui_LDADD = $(faac_LDADD) faacguires.o -lcomdlg32 +-faacguires.o: +- $(WINDRES) faacgui.rc faacguires.o +-icon.o: +- $(WINDRES) icon.rc icon.o ++faacguires.o: faacgui.rc ++ $(WINDRES) $(top_srcdir)/frontend/faacgui.rc faacguires.o ++icon.o: icon.rc ++ $(WINDRES) $(top_srcdir)/frontend/icon.rc icon.o + endif + + endif # !USE_DRM diff --git a/recipes/faac/all/test_package/CMakeLists.txt b/recipes/faac/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..366ecce0962e7 --- /dev/null +++ b/recipes/faac/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1.0) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(faac REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} faac::faac) diff --git a/recipes/faac/all/test_package/conanfile.py b/recipes/faac/all/test_package/conanfile.py new file mode 100644 index 0000000000000..697dfef261b53 --- /dev/null +++ b/recipes/faac/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/faac/all/test_package/test_package.c b/recipes/faac/all/test_package/test_package.c new file mode 100644 index 0000000000000..91e3f9bf61bbb --- /dev/null +++ b/recipes/faac/all/test_package/test_package.c @@ -0,0 +1,21 @@ +#include +#include + +int main() +{ + char *faac_id_string; + char *faac_copyright_string; + // get faac version + if (faacEncGetVersion(&faac_id_string, &faac_copyright_string) == + FAAC_CFG_VERSION) + { + fprintf(stderr, "Freeware Advanced Audio Coder\nFAAC %s\n", + faac_id_string); + } + else + { + fprintf(stderr, __FILE__ "(%d): wrong libfaac version\n", __LINE__); + return 1; + } + return 0; +} diff --git a/recipes/faac/config.yml b/recipes/faac/config.yml new file mode 100644 index 0000000000000..e34a7ad292edb --- /dev/null +++ b/recipes/faac/config.yml @@ -0,0 +1,5 @@ +versions: + "1.30": + folder: all + "1.28": + folder: all diff --git a/recipes/fakeit/all/conandata.yml b/recipes/fakeit/all/conandata.yml index b142a9e318b4d..822858ea79ad4 100644 --- a/recipes/fakeit/all/conandata.yml +++ b/recipes/fakeit/all/conandata.yml @@ -1,7 +1,19 @@ sources: - "2.0.7": - url: https://github.com/eranpeer/FakeIt/archive/refs/tags/2.0.7.tar.gz - sha256: e28ad1181487447a7add926a289d0db0bbb354a64d3395f75066b74750a93769 + "2.3.0": + url: "https://github.com/eranpeer/FakeIt/archive/2.3.0.tar.gz" + sha256: "990469c1e4608ebf662d64e979aa607a0c32faa40cc5ffe38b74c7dd6968ed2d" + "2.2.0": + url: "https://github.com/eranpeer/FakeIt/archive/2.2.0.tar.gz" + sha256: "a54267fc5787acda229be11d3f5ea9a80339a385685e0e0c4d7df0a304a6f57d" + "2.1.0": + url: "https://github.com/eranpeer/FakeIt/archive/2.1.0.tar.gz" + sha256: "695826dc5c3012e57f2c7aa9801c7af1d1a8677f88c624343b3039c6b5c59871" + "2.0.9": + url: "https://github.com/eranpeer/FakeIt/archive/2.0.9.tar.gz" + sha256: "dc4ee7b17a84c959019b92c20fce6dc9426e9e170b6edf84db6cb2e188520cd7" "2.0.8": - url: https://github.com/eranpeer/FakeIt/archive/refs/tags/2.0.8.tar.gz - sha256: beff681216e6645ede25af1cc4dc743d525f38cba1fa4a58f964efcaba0dd7e5 + url: "https://github.com/eranpeer/FakeIt/archive/2.0.8.tar.gz" + sha256: "beff681216e6645ede25af1cc4dc743d525f38cba1fa4a58f964efcaba0dd7e5" + "2.0.7": + url: "https://github.com/eranpeer/FakeIt/archive/2.0.7.tar.gz" + sha256: "e28ad1181487447a7add926a289d0db0bbb354a64d3395f75066b74750a93769" diff --git a/recipes/fakeit/all/conanfile.py b/recipes/fakeit/all/conanfile.py index 1cd82fc64805d..864bd2d4f2bb1 100644 --- a/recipes/fakeit/all/conanfile.py +++ b/recipes/fakeit/all/conanfile.py @@ -2,15 +2,16 @@ from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.33.0" class FakeItConan(ConanFile): name = "fakeit" + description = "C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking." + topics = ("mock", "fake", "spy") license = "MIT" homepage = "https://github.com/eranpeer/FakeIt" url = "https://github.com/conan-io/conan-center-index" - description = "C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking." - topics = ("mock", "fake", "spy") - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" options = { "integration": ["boost", "catch", "cute", "gtest", "mettle", "nunit", "mstest", "qtest", "standalone", "tpunit"] } @@ -23,31 +24,29 @@ def _source_subfolder(self): def requirements(self): if self.options.integration == "boost": - self.requires("boost/1.75.0") + self.requires("boost/1.79.0") elif self.options.integration == "catch": - self.requires("catch2/2.13.4") + self.requires("catch2/2.13.9") elif self.options.integration == "gtest": - self.requires("gtest/cci.20210126") + self.requires("gtest/1.11.0") elif self.options.integration == "qtest": - self.requires("qt/6.0.2") + self.requires("qt/6.3.0") elif self.options.integration == "standalone": pass else: raise ConanInvalidConfiguration("%s is not (yet) available on cci" % self.options.integration) - def configure(self): + def package_id(self): + self.info.header_only() + + def validate(self): minimal_cpp_standard = "11" - if self.settings.compiler.cppstd: + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, minimal_cpp_standard) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "FakeIt-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def package(self): self.copy(pattern="fakeit.hpp", dst="include", src=os.path.join(self._source_subfolder, "single_header", str(self.options.integration))) self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - - def package_id(self): - del self.settings.compiler diff --git a/recipes/fakeit/all/test_package/CMakeLists.txt b/recipes/fakeit/all/test_package/CMakeLists.txt index aa0960b7b2a6d..3053452921673 100644 --- a/recipes/fakeit/all/test_package/CMakeLists.txt +++ b/recipes/fakeit/all/test_package/CMakeLists.txt @@ -1,9 +1,11 @@ -cmake_minimum_required(VERSION 3.1.3) -project(PackageTest CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) -add_executable(example example.cpp) -set_target_properties(example PROPERTIES CXX_STANDARD 11) -target_link_libraries(example CONAN_PKG::fakeit) +find_package(fakeit REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +target_link_libraries(${PROJECT_NAME} fakeit::fakeit) diff --git a/recipes/fakeit/all/test_package/conanfile.py b/recipes/fakeit/all/test_package/conanfile.py index d7d9228e18181..304d96151d752 100644 --- a/recipes/fakeit/all/test_package/conanfile.py +++ b/recipes/fakeit/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class FakeItTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,5 +12,5 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "example"), run_environment=True) + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/fakeit/all/test_package/example.cpp b/recipes/fakeit/all/test_package/test_package.cpp similarity index 100% rename from recipes/fakeit/all/test_package/example.cpp rename to recipes/fakeit/all/test_package/test_package.cpp diff --git a/recipes/fakeit/config.yml b/recipes/fakeit/config.yml index 801680c5609c1..46e3c97d8884a 100644 --- a/recipes/fakeit/config.yml +++ b/recipes/fakeit/config.yml @@ -1,5 +1,13 @@ versions: - "2.0.7": + "2.3.0": + folder: all + "2.2.0": + folder: all + "2.1.0": + folder: all + "2.0.9": folder: all "2.0.8": folder: all + "2.0.7": + folder: all diff --git a/recipes/farmhash/all/CMakeLists.txt b/recipes/farmhash/all/CMakeLists.txt new file mode 100644 index 0000000000000..fd338ded4ae99 --- /dev/null +++ b/recipes/farmhash/all/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.4) +project(farmhash LANGUAGES CXX) + +include(GNUInstallDirs) + +if(NOT FARMHASH_NO_BUILTIN_EXPECT) + # Transcribed from farmhash/src/Makefile.am + include(CheckCXXSourceCompiles) + check_cxx_source_compiles( + "int main(int argc, char* argv[]) { return (int)__builtin_expect(0, 0); }" + FARMHASH_HAS_BUILTIN_EXPECT + ) +endif() + +add_library(farmhash "${FARMHASH_SRC_DIR}/src/farmhash.cc" ) +target_include_directories(farmhash PRIVATE "${FARMHASH_SRC_DIR}/src") + +if(NOT FARMHASH_HAS_BUILTIN_EXPECT) + target_compile_definitions(farmhash PUBLIC FARMHASH_NO_BUILTIN_EXPECT) +endif() + +set_target_properties(farmhash + PROPERTIES + PUBLIC_HEADER "${FARMHASH_SRC_DIR}/src/farmhash.h" + WINDOWS_EXPORT_ALL_SYMBOLS ON +) + +install(TARGETS farmhash + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/farmhash/all/conandata.yml b/recipes/farmhash/all/conandata.yml new file mode 100644 index 0000000000000..64c0c2f2f2894 --- /dev/null +++ b/recipes/farmhash/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20190513": + url: "https://github.com/google/farmhash/archive/0d859a811870d10f53a594927d0d0b97573ad06d.tar.gz" + sha256: "18392cf0736e1d62ecbb8d695c31496b6507859e8c75541d7ad0ba092dc52115" diff --git a/recipes/farmhash/all/conanfile.py b/recipes/farmhash/all/conanfile.py new file mode 100644 index 0000000000000..181eb1efed8e6 --- /dev/null +++ b/recipes/farmhash/all/conanfile.py @@ -0,0 +1,63 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.46.0" + + +class FarmhashConan(ConanFile): + name = "farmhash" + description = "A family of hash functions" + topics = ("hash", "google", "family") + license = "MIT" + homepage = "https://github.com/google/farmhash" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "no_builtin_expect": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "no_builtin_expect": False, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FARMHASH_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["FARMHASH_NO_BUILTIN_EXPECT"] = self.options.no_builtin_expect + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["farmhash"] diff --git a/recipes/farmhash/all/test_package/CMakeLists.txt b/recipes/farmhash/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8229712d40a9e --- /dev/null +++ b/recipes/farmhash/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(farmhash REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE farmhash::farmhash) diff --git a/recipes/farmhash/all/test_package/conanfile.py b/recipes/farmhash/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/farmhash/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/farmhash/all/test_package/test_package.cpp b/recipes/farmhash/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..22e5ba91f7634 --- /dev/null +++ b/recipes/farmhash/all/test_package/test_package.cpp @@ -0,0 +1,17 @@ +#include + +#include +#include + +int main() { + + std::string aString = "Conan"; + uint32_t hashResult; + + hashResult = util::Hash32(aString); + + std::cout << "Input string: " << aString << std::endl; + std::cout << "Generated hash: " << hashResult << std::endl; + + return 0; +} diff --git a/recipes/farmhash/all/test_v1_package/CMakeLists.txt b/recipes/farmhash/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a9619dd221925 --- /dev/null +++ b/recipes/farmhash/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(farmhash REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE farmhash::farmhash) diff --git a/recipes/farmhash/all/test_v1_package/conanfile.py b/recipes/farmhash/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/farmhash/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/farmhash/config.yml b/recipes/farmhash/config.yml new file mode 100644 index 0000000000000..a94d138fcd02f --- /dev/null +++ b/recipes/farmhash/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20190513": + folder: all diff --git a/recipes/fast-cdr/all/conandata.yml b/recipes/fast-cdr/all/conandata.yml new file mode 100644 index 0000000000000..31c8bc7e11e9e --- /dev/null +++ b/recipes/fast-cdr/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "1.0.24": + url: "https://github.com/eProsima/Fast-CDR/archive/v1.0.24.tar.gz" + sha256: "ecd688ab89ff1c03b9031c314891ae60995e2e73d919b93569eb840d6e87dec2" + "1.0.23": + url: "https://github.com/eProsima/Fast-CDR/archive/v1.0.23.tar.gz" + sha256: "6f7c9c6c0c82c150b5ea2b0a58d5c9a466b87a1fcfca40d5786d99d4963a6721" + "1.0.22": + url: "https://github.com/eProsima/Fast-CDR/archive/v1.0.22.tar.gz" + sha256: "7ca7f09c633963622431bdb216eeb4145e378f81a2ce5113e341b9eee55e4f44" + "1.0.21": + url: "https://github.com/eProsima/Fast-CDR/archive/refs/tags/v1.0.21.tar.gz" + sha256: "C1F32BDD76910ADA00D551EB8828DE7561AD2B2846D063CB4316F9262C03C77D" diff --git a/recipes/fast-cdr/all/conanfile.py b/recipes/fast-cdr/all/conanfile.py new file mode 100644 index 0000000000000..b334d42bb6789 --- /dev/null +++ b/recipes/fast-cdr/all/conanfile.py @@ -0,0 +1,109 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import collect_libs, copy, get, rm, rmdir, save +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +import os +import textwrap + +required_conan_version = ">=1.51.1" + + +class FastCDRConan(ConanFile): + name = "fast-cdr" + license = "Apache-2.0" + homepage = "https://github.com/eProsima/Fast-CDR" + url = "https://github.com/conan-io/conan-center-index" + description = "eProsima FastCDR library for serialization" + topics = ("dds", "middleware", "serialization") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.info.options.shared and is_msvc(self) and is_msvc_static_runtime(self): + # This combination leads to an fast-cdr error when linking + # linking dynamic '*.dll' and static MT runtime + # see https://github.com/eProsima/Fast-CDR/blob/v1.0.21/include/fastcdr/eProsima_auto_link.h#L37 + # (2021-05-31) + raise ConanInvalidConfiguration("Mixing a dll eprosima library with a static runtime is a bad idea") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_STATIC"] = not self.options.shared + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"fastcdr": "fastcdr::fastcdr"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "fastcdr") + self.cpp_info.set_property("cmake_target_name", "fastcdr") + self.cpp_info.libs = collect_libs(self) + if self.settings.os == "Windows" and self.options.shared: + self.cpp_info.defines.append("FASTCDR_DYN_LINK") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "fastcdr" + self.cpp_info.names["cmake_find_package_multi"] = "fastcdr" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/fast-cdr/all/test_package/CMakeLists.txt b/recipes/fast-cdr/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2a71d2d409cc4 --- /dev/null +++ b/recipes/fast-cdr/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(fastcdr REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE fastcdr) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fast-cdr/all/test_package/conanfile.py b/recipes/fast-cdr/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/fast-cdr/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fast-cdr/all/test_package/test_package.cpp b/recipes/fast-cdr/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..3a437b366c3c4 --- /dev/null +++ b/recipes/fast-cdr/all/test_package/test_package.cpp @@ -0,0 +1,74 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include +#include +#include + +#define N_ARR_ELEMENTS 5 + +static const char char_seq_t[N_ARR_ELEMENTS] = {'E', 'D', 'C', 'B', 'A'}; +static const std::wstring wstring_t = L"Hola a todos, esto es un test con widestring"; + +using namespace eprosima::fastcdr; + +#define BUFFER_LENGTH 2000 + + +void check_good_case() +{ + char buffer[BUFFER_LENGTH]; + const std::wstring& input_value = wstring_t; + + // Serialization. + { + FastBuffer cdrbuffer(buffer, BUFFER_LENGTH); + Cdr cdr_ser(cdrbuffer); + cdr_ser << input_value; + } + + // Deserialization. + { + FastBuffer cdrbuffer(buffer, BUFFER_LENGTH); + Cdr cdr_des(cdrbuffer); + std::wstring output_value{}; + + cdr_des >> output_value; + } +} + + +int main() +{ + check_good_case(); + + char buffer[BUFFER_LENGTH]; + + // Serialization. + FastBuffer cdrbuffer(buffer, BUFFER_LENGTH); + Cdr cdr_ser(cdrbuffer); + cdr_ser.serializeSequence(char_seq_t, 5); + + // Deserialization. + Cdr cdr_des(cdrbuffer); + + char* char_seq_value = NULL; size_t char_seq_len = 0; + + cdr_des.deserializeSequence(char_seq_value, char_seq_len); + + return 0; +} diff --git a/recipes/fast-cdr/all/test_v1_package/CMakeLists.txt b/recipes/fast-cdr/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..16d0cd412b0f9 --- /dev/null +++ b/recipes/fast-cdr/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fastcdr REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE fastcdr) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fast-cdr/all/test_v1_package/conanfile.py b/recipes/fast-cdr/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/fast-cdr/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fast-cdr/config.yml b/recipes/fast-cdr/config.yml new file mode 100644 index 0000000000000..27fb208178630 --- /dev/null +++ b/recipes/fast-cdr/config.yml @@ -0,0 +1,9 @@ +versions: + "1.0.24": + folder: all + "1.0.23": + folder: all + "1.0.22": + folder: all + "1.0.21": + folder: all diff --git a/recipes/fast-cpp-csv-parser/all/conandata.yml b/recipes/fast-cpp-csv-parser/all/conandata.yml index 6d52b052654a2..87d270e80c74e 100644 --- a/recipes/fast-cpp-csv-parser/all/conandata.yml +++ b/recipes/fast-cpp-csv-parser/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "cci.20211104": + url: "https://github.com/ben-strasser/fast-cpp-csv-parser/archive/5a417973b4cea674a5e4a3b88a23098a2ab75479.zip" + sha256: "33a22bda2603a87b8f36c79673339490f58656d92a4882e788de3f4ef7ec57b2" "cci.20200830": url: "https://github.com/ben-strasser/fast-cpp-csv-parser/archive/1165be530d19ed730228dd122f2df0896be8f64e.zip" sha256: "28ae9e3b95dcb7a78086ff1425f3bd1258407ebedc34d8517c5bcb8084b5833e" diff --git a/recipes/fast-cpp-csv-parser/all/conanfile.py b/recipes/fast-cpp-csv-parser/all/conanfile.py index bfded29c6ef6c..f20fc50349a4e 100644 --- a/recipes/fast-cpp-csv-parser/all/conanfile.py +++ b/recipes/fast-cpp-csv-parser/all/conanfile.py @@ -1,43 +1,58 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools +required_conan_version = ">=1.50.0" + class FastcppcsvparserConan(ConanFile): name = "fast-cpp-csv-parser" description = "C++11 header-only library for reading comma separated value (CSV) files." license = "BSD-3-Clause" - topics = ("conan", "fast-cpp-csv-parser", "csv", "parser", "header-only") - homepage = "https://github.com/ben-strasser/fast-cpp-csv-parser" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler" + homepage = "https://github.com/ben-strasser/fast-cpp-csv-parser" + topics = ("csv", "parser", "header-only") + + settings = "os", "arch", "compiler", "build_type" + options = { + "with_thread": [True, False], + } + default_options = { + "with_thread": True, + } + no_copy_source = True - options = {"with_thread": [True, False]} - default_options = {"with_thread": True} - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - url = self.conan_data["sources"][self.version]["url"] - extracted_dir = self.name + "-" + os.path.splitext(os.path.basename(url))[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("csv.h", dst=os.path.join("include", "fast-cpp-csv-parser"), src=self._source_subfolder) + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "csv.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include", "fast-cpp-csv-parser")) def package_info(self): - self.cpp_info.includedirs = ["include", os.path.join("include", "fast-cpp-csv-parser")] + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + self.cpp_info.includedirs.append(os.path.join("include", "fast-cpp-csv-parser")) if not self.options.with_thread: self.cpp_info.defines.append("CSV_IO_NO_THREAD") - if self.settings.os == "Linux" and self.options.with_thread: + if self.settings.os in ["Linux", "FreeBSD"] and self.options.with_thread: self.cpp_info.system_libs.append("pthread") diff --git a/recipes/fast-cpp-csv-parser/all/test_package/CMakeLists.txt b/recipes/fast-cpp-csv-parser/all/test_package/CMakeLists.txt index 829b5ca81b9ce..9136830af77ff 100644 --- a/recipes/fast-cpp-csv-parser/all/test_package/CMakeLists.txt +++ b/recipes/fast-cpp-csv-parser/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(fast-cpp-csv-parser REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE fast-cpp-csv-parser::fast-cpp-csv-parser) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fast-cpp-csv-parser/all/test_package/conanfile.py b/recipes/fast-cpp-csv-parser/all/test_package/conanfile.py index fe0992e2e1be2..ca068b831644c 100644 --- a/recipes/fast-cpp-csv-parser/all/test_package/conanfile.py +++ b/recipes/fast-cpp-csv-parser/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") csv_name = os.path.join(self.source_folder, "test_package.csv") - bin_path = os.path.join("bin", "test_package") - self.run("{0} {1}".format(bin_path, csv_name), run_environment=True) + self.run(f"{bin_path} {csv_name}", env="conanrun") diff --git a/recipes/fast-cpp-csv-parser/all/test_v1_package/CMakeLists.txt b/recipes/fast-cpp-csv-parser/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..c53b3fb245385 --- /dev/null +++ b/recipes/fast-cpp-csv-parser/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fast-cpp-csv-parser REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE fast-cpp-csv-parser::fast-cpp-csv-parser) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fast-cpp-csv-parser/all/test_v1_package/conanfile.py b/recipes/fast-cpp-csv-parser/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..47d6b79839192 --- /dev/null +++ b/recipes/fast-cpp-csv-parser/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + csv_name = os.path.join(self.source_folder, os.pardir, "test_package", "test_package.csv") + self.run(f"{bin_path} {csv_name}", run_environment=True) diff --git a/recipes/fast-cpp-csv-parser/config.yml b/recipes/fast-cpp-csv-parser/config.yml index 41487018aaf44..ca4b1e35049ab 100644 --- a/recipes/fast-cpp-csv-parser/config.yml +++ b/recipes/fast-cpp-csv-parser/config.yml @@ -1,4 +1,6 @@ versions: + "cci.20211104": + folder: all "cci.20200830": folder: all "20191004": diff --git a/recipes/libzip/all/CMakeLists.txt b/recipes/fast-dds/all/CMakeLists.txt similarity index 100% rename from recipes/libzip/all/CMakeLists.txt rename to recipes/fast-dds/all/CMakeLists.txt diff --git a/recipes/fast-dds/all/conandata.yml b/recipes/fast-dds/all/conandata.yml new file mode 100644 index 0000000000000..ea3e09684b01e --- /dev/null +++ b/recipes/fast-dds/all/conandata.yml @@ -0,0 +1,20 @@ +sources: + "2.3.4": + url: "https://github.com/eProsima/Fast-DDS/archive/refs/tags/v2.3.4.tar.gz" + sha256: "b1b2322de0ca55a16495666e3fbda8aca32b888bbfaecda29f2ffc4b072ef7ac" + "2.3.3": + url: "https://github.com/eProsima/Fast-DDS/archive/refs/tags/v2.3.3.tar.gz" + sha256: "5ebf27d810c6ab68eef7d42937cd421d85e50509ae96883239979a1b3a2f4f82" + "2.3.2": + url: "https://github.com/eProsima/Fast-DDS/archive/refs/tags/v2.3.2.tar.gz" + sha256: "4d8183cf4d37c3de9e6fd28d2850dd08023a9079001c4880b23c95f0d8c0b5ce" +patches: + "2.3.4": + - patch_file: "patches/2.3.X-0001-fix-find-asio-and-tinyxml2.patch" + base_path: "source_subfolder" + "2.3.3": + - patch_file: "patches/2.3.X-0001-fix-find-asio-and-tinyxml2.patch" + base_path: "source_subfolder" + "2.3.2": + - patch_file: "patches/2.3.2-0001-fix-find-asio-and-tinyxml2.patch" + base_path: "source_subfolder" diff --git a/recipes/fast-dds/all/conanfile.py b/recipes/fast-dds/all/conanfile.py new file mode 100644 index 0000000000000..c7f1a37d3d3bd --- /dev/null +++ b/recipes/fast-dds/all/conanfile.py @@ -0,0 +1,189 @@ +from conan.tools.microsoft import msvc_runtime_flag +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os +import textwrap + +required_conan_version = ">=1.43.0" + + +class FastDDSConan(ConanFile): + name = "fast-dds" + license = "Apache-2.0" + homepage = "https://fast-dds.docs.eprosima.com/" + url = "https://github.com/conan-io/conan-center-index" + description = "The most complete OSS DDS implementation for embedded systems." + topics = ("dds", "middleware", "ipc") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_ssl": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_ssl": False, + } + + generators = "cmake", "cmake_find_package" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _minimum_cpp_standard(self): + return 11 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "gcc": "5", + "clang": "3.9", + "apple-clang": "8", + } + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("tinyxml2/9.0.0") + self.requires("asio/1.21.0") + self.requires("fast-cdr/1.0.23") + self.requires("foonathan-memory/0.7.1") + self.requires("boost/1.75.0") # boost/1.76 is required by version 2.3.2, boost/1.75.0 required for 2.3.3 by Windows + if self.options.with_ssl: + self.requires("openssl/1.1.1m") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if min_version and tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration( + "{} requires C++{} support. {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, + self.settings.compiler, self.settings.compiler.version + ) + ) + if self.options.shared and self._is_msvc and "MT" in msvc_runtime_flag(self): + # This combination leads to an fast-dds error when linking + # linking dynamic '*.dll' and static MT runtime + raise ConanInvalidConfiguration("Mixing a dll {} library with a static runtime is a bad idea".format(self.name)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, + destination=self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_MEMORY_TOOLS"] = False + self._cmake.definitions["NO_TLS"] = not self.options.with_ssl + self._cmake.definitions["SECURITY"] = self.options.with_ssl + self._cmake.definitions["EPROSIMA_INSTALLER_MINION"] = False + self._cmake.configure() + return self._cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + tools.rename( + src=os.path.join(self.package_folder, "tools"), + dst=os.path.join(os.path.join(self.package_folder, "bin", "tools")) + ) + tools.remove_files_by_mask( + directory=os.path.join(self.package_folder, "lib"), + pattern="*.pdb" + ) + tools.remove_files_by_mask( + directory=os.path.join(self.package_folder, "bin"), + pattern="*.pdb" + ) + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"fastrtps": "fastdds::fastrtps"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "fastdds") + + # component fastrtps + self.cpp_info.components["fastrtps"].set_property("cmake_target_name", "fastrtps") + self.cpp_info.components["fastrtps"].libs = tools.collect_libs(self) + self.cpp_info.components["fastrtps"].requires = [ + "fast-cdr::fast-cdr", + "asio::asio", + "tinyxml2::tinyxml2", + "foonathan-memory::foonathan-memory", + "boost::boost" + ] + if self.settings.os in ["Linux", "FreeBSD", "Neutrino"]: + self.cpp_info.components["fastrtps"].system_libs.append("pthread") + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["fastrtps"].system_libs.extend(["rt", "dl", "atomic"]) + elif self.settings.os == "Windows": + self.cpp_info.components["fastrtps"].system_libs.extend(["iphlpapi","shlwapi"]) + if self.options.shared: + self.cpp_info.components["fastrtps"].defines.append("FASTRTPS_DYN_LINK") + if self.options.with_ssl: + self.cpp_info.components["fastrtps"].requires.append("openssl::openssl") + + # component fast-discovery + # FIXME: actually conan generators don't know how to create an executable imported target + self.cpp_info.components["fast-discovery-server"].set_property("cmake_target_name", "fastdds::fast-discovery-server") + self.cpp_info.components["fast-discovery-server"].bindirs = ["bin"] + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH env var for fast-dds::fast-discovery-server with: {}".format(bin_path)), + self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "fastdds" + self.cpp_info.names["cmake_find_package_multi"] = "fastdds" + self.cpp_info.components["fastrtps"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["fastrtps"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["fast-discovery-server"].names["cmake_find_package"] = "fast-discovery-server" + self.cpp_info.components["fast-discovery-server"].names["cmake_find_package_multi"] = "fast-discovery-server" diff --git a/recipes/fast-dds/all/patches/2.3.2-0001-fix-find-asio-and-tinyxml2.patch b/recipes/fast-dds/all/patches/2.3.2-0001-fix-find-asio-and-tinyxml2.patch new file mode 100644 index 0000000000000..4530f0222378b --- /dev/null +++ b/recipes/fast-dds/all/patches/2.3.2-0001-fix-find-asio-and-tinyxml2.patch @@ -0,0 +1,28 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8a9cb0209..400c681e7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -225,8 +225,8 @@ if(NOT BUILD_SHARED_LIBS) + endif() + + eprosima_find_package(fastcdr REQUIRED) +-eprosima_find_thirdparty(Asio asio VERSION 1.10.8) +-eprosima_find_thirdparty(TinyXML2 tinyxml2) ++eprosima_find_thirdparty(asio REQUIRED) ++eprosima_find_thirdparty(tinyxml2 REQUIRED) + + find_package(foonathan_memory REQUIRED) + message(STATUS "Found foonathan_memory: ${foonathan_memory_DIR}") +diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt +index 04d313bf2..c7d64f04d 100644 +--- a/src/cpp/CMakeLists.txt ++++ b/src/cpp/CMakeLists.txt +@@ -455,7 +455,7 @@ elseif(NOT EPROSIMA_INSTALLER) + # Link library to external libraries. + target_link_libraries(${PROJECT_NAME} ${PRIVACY} fastcdr foonathan_memory + ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} +- ${TINYXML2_LIBRARY} ++ tinyxml2::tinyxml2 + $<$:OpenSSL::SSL$OpenSSL::Crypto> + $<$:iphlpapi$Shlwapi> + ${THIRDPARTY_BOOST_LINK_LIBS} diff --git a/recipes/fast-dds/all/patches/2.3.3-0001-fix-find-asio-and-tinyxml2.patch b/recipes/fast-dds/all/patches/2.3.3-0001-fix-find-asio-and-tinyxml2.patch new file mode 100644 index 0000000000000..a597b73998c04 --- /dev/null +++ b/recipes/fast-dds/all/patches/2.3.3-0001-fix-find-asio-and-tinyxml2.patch @@ -0,0 +1,28 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8a9cb0209..400c681e7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -225,8 +225,8 @@ if(NOT BUILD_SHARED_LIBS) + endif() + + eprosima_find_package(fastcdr REQUIRED) +-eprosima_find_thirdparty(Asio asio VERSION 1.10.8) +-eprosima_find_thirdparty(TinyXML2 tinyxml2) ++eprosima_find_thirdparty(asio REQUIRED) ++eprosima_find_thirdparty(tinyxml2 REQUIRED) + + find_package(foonathan_memory REQUIRED) + message(STATUS "Found foonathan_memory: ${foonathan_memory_DIR}") +diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt +index d26915242..f00e36ea6 100644 +--- a/src/cpp/CMakeLists.txt ++++ b/src/cpp/CMakeLists.txt +@@ -456,7 +456,7 @@ elseif(NOT EPROSIMA_INSTALLER) + # Link library to external libraries. + target_link_libraries(${PROJECT_NAME} ${PRIVACY} fastcdr foonathan_memory + ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} +- ${TINYXML2_LIBRARY} ++ tinyxml2::tinyxml2 + $<$:OpenSSL::SSL$OpenSSL::Crypto$<$:$crypt32.lib>> + $<$:iphlpapi$Shlwapi> + ${THIRDPARTY_BOOST_LINK_LIBS} diff --git a/recipes/fast-dds/all/patches/2.3.X-0001-fix-find-asio-and-tinyxml2.patch b/recipes/fast-dds/all/patches/2.3.X-0001-fix-find-asio-and-tinyxml2.patch new file mode 100644 index 0000000000000..a597b73998c04 --- /dev/null +++ b/recipes/fast-dds/all/patches/2.3.X-0001-fix-find-asio-and-tinyxml2.patch @@ -0,0 +1,28 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8a9cb0209..400c681e7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -225,8 +225,8 @@ if(NOT BUILD_SHARED_LIBS) + endif() + + eprosima_find_package(fastcdr REQUIRED) +-eprosima_find_thirdparty(Asio asio VERSION 1.10.8) +-eprosima_find_thirdparty(TinyXML2 tinyxml2) ++eprosima_find_thirdparty(asio REQUIRED) ++eprosima_find_thirdparty(tinyxml2 REQUIRED) + + find_package(foonathan_memory REQUIRED) + message(STATUS "Found foonathan_memory: ${foonathan_memory_DIR}") +diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt +index d26915242..f00e36ea6 100644 +--- a/src/cpp/CMakeLists.txt ++++ b/src/cpp/CMakeLists.txt +@@ -456,7 +456,7 @@ elseif(NOT EPROSIMA_INSTALLER) + # Link library to external libraries. + target_link_libraries(${PROJECT_NAME} ${PRIVACY} fastcdr foonathan_memory + ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} +- ${TINYXML2_LIBRARY} ++ tinyxml2::tinyxml2 + $<$:OpenSSL::SSL$OpenSSL::Crypto$<$:$crypt32.lib>> + $<$:iphlpapi$Shlwapi> + ${THIRDPARTY_BOOST_LINK_LIBS} diff --git a/recipes/fast-dds/all/test_package/CMakeLists.txt b/recipes/fast-dds/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8d075b0d63dcf --- /dev/null +++ b/recipes/fast-dds/all/test_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fastdds REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} + test_package.cpp + msg/HelloWorld.cxx + msg/HelloWorldPubSubTypes.cxx +) + +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} fastrtps) diff --git a/recipes/fast-dds/all/test_package/conanfile.py b/recipes/fast-dds/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1bf1c7e26255d --- /dev/null +++ b/recipes/fast-dds/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fast-dds/all/test_package/msg/HelloWorld.cxx b/recipes/fast-dds/all/test_package/msg/HelloWorld.cxx new file mode 100644 index 0000000000000..b850b450127bf --- /dev/null +++ b/recipes/fast-dds/all/test_package/msg/HelloWorld.cxx @@ -0,0 +1,207 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "HelloWorld.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +HelloWorld::HelloWorld() +{ + // m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@1622f1b + m_index = 0; + // m_message com.eprosima.idl.parser.typecode.StringTypeCode@70e8f8e + m_message =""; + +} + +HelloWorld::~HelloWorld() +{ + + +} + +HelloWorld::HelloWorld(const HelloWorld &x) +{ + m_index = x.m_index; + m_message = x.m_message; +} + +HelloWorld::HelloWorld(HelloWorld &&x) +{ + m_index = x.m_index; + m_message = std::move(x.m_message); +} + +HelloWorld& HelloWorld::operator=(const HelloWorld &x) +{ + + m_index = x.m_index; + m_message = x.m_message; + + return *this; +} + +HelloWorld& HelloWorld::operator=(HelloWorld &&x) +{ + + m_index = x.m_index; + m_message = std::move(x.m_message); + + return *this; +} + +size_t HelloWorld::getMaxCdrSerializedSize(size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1; + + + return current_alignment - initial_alignment; +} + +size_t HelloWorld::getCdrSerializedSize(const HelloWorld& data, size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; + + + return current_alignment - initial_alignment; +} + +void HelloWorld::serialize(eprosima::fastcdr::Cdr &scdr) const +{ + + scdr << m_index; + scdr << m_message; +} + +void HelloWorld::deserialize(eprosima::fastcdr::Cdr &dcdr) +{ + + dcdr >> m_index; + dcdr >> m_message; +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void HelloWorld::index(uint32_t _index) +{ +m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t HelloWorld::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& HelloWorld::index() +{ + return m_index; +} + +/*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ +void HelloWorld::message(const std::string &_message) +{ +m_message = _message; +} + +/*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ +void HelloWorld::message(std::string &&_message) +{ +m_message = std::move(_message); +} + +/*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ +const std::string& HelloWorld::message() const +{ + return m_message; +} + +/*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ +std::string& HelloWorld::message() +{ + return m_message; +} + +size_t HelloWorld::getKeyMaxCdrSerializedSize(size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + return current_align; +} + +bool HelloWorld::isKeyDefined() +{ + return false; +} + +void HelloWorld::serializeKey(eprosima::fastcdr::Cdr &scdr) const +{ + (void) scdr; + + +} diff --git a/recipes/fast-dds/all/test_package/msg/HelloWorld.h b/recipes/fast-dds/all/test_package/msg/HelloWorld.h new file mode 100644 index 0000000000000..380f487456147 --- /dev/null +++ b/recipes/fast-dds/all/test_package/msg/HelloWorld.h @@ -0,0 +1,206 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _HELLOWORLD_H_ +#define _HELLOWORLD_H_ + +// TODO Poner en el contexto. + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif +#else +#define eProsima_user_DllExport +#endif + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(HelloWorld_SOURCE) +#define HelloWorld_DllAPI __declspec( dllexport ) +#else +#define HelloWorld_DllAPI __declspec( dllimport ) +#endif // HelloWorld_SOURCE +#else +#define HelloWorld_DllAPI +#endif +#else +#define HelloWorld_DllAPI +#endif // _WIN32 + +namespace eprosima +{ + namespace fastcdr + { + class Cdr; + } +} + + +/*! + * @brief This class represents the structure HelloWorld defined by the user in the IDL file. + * @ingroup HELLOWORLD + */ +class HelloWorld +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport HelloWorld(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~HelloWorld(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld(const HelloWorld &x); + + /*! + * @brief Move constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld(HelloWorld &&x); + + /*! + * @brief Copy assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator=(const HelloWorld &x); + + /*! + * @brief Move assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator=(HelloWorld &&x); + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index(uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + /*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ + eProsima_user_DllExport void message(const std::string &_message); + + /*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ + eProsima_user_DllExport void message(std::string &&_message); + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::string& message() const; + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::string& message(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize(size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize(const HelloWorld& data, size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const; + +private: + uint32_t m_index; + std::string m_message; +}; + +#endif // _HELLOWORLD_H_ diff --git a/recipes/fast-dds/all/test_package/msg/HelloWorld.idl b/recipes/fast-dds/all/test_package/msg/HelloWorld.idl new file mode 100644 index 0000000000000..0fd2c355aeefa --- /dev/null +++ b/recipes/fast-dds/all/test_package/msg/HelloWorld.idl @@ -0,0 +1,5 @@ +struct HelloWorld +{ + unsigned long index; + string message; +}; diff --git a/recipes/fast-dds/all/test_package/msg/HelloWorldPubSubTypes.cxx b/recipes/fast-dds/all/test_package/msg/HelloWorldPubSubTypes.cxx new file mode 100644 index 0000000000000..89e89cc8581e8 --- /dev/null +++ b/recipes/fast-dds/all/test_package/msg/HelloWorldPubSubTypes.cxx @@ -0,0 +1,133 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "HelloWorldPubSubTypes.h" + +using namespace eprosima::fastrtps; +using namespace eprosima::fastrtps::rtps; + +HelloWorldPubSubType::HelloWorldPubSubType() +{ + setName("HelloWorld"); + m_typeSize = static_cast(HelloWorld::getMaxCdrSerializedSize()) + 4 /*encapsulation*/; + m_isGetKeyDefined = HelloWorld::isKeyDefined(); + size_t keyLength = HelloWorld::getKeyMaxCdrSerializedSize()>16 ? HelloWorld::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +HelloWorldPubSubType::~HelloWorldPubSubType() +{ + if(m_keyBuffer!=nullptr) + free(m_keyBuffer); +} + +bool HelloWorldPubSubType::serialize(void *data, SerializedPayload_t *payload) +{ + HelloWorld *p_type = static_cast(data); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); // Object that manages the raw buffer. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + p_type->serialize(ser); // Serialize the object: + } + catch(eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + payload->length = static_cast(ser.getSerializedDataLength()); //Get the serialized length + return true; +} + +bool HelloWorldPubSubType::deserialize(SerializedPayload_t* payload, void* data) +{ + HelloWorld* p_type = static_cast(data); //Convert DATA to pointer of your type + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); // Object that manages the raw buffer. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data. + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + try + { + p_type->deserialize(deser); //Deserialize the object: + } + catch(eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function HelloWorldPubSubType::getSerializedSizeProvider(void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4 /*encapsulation*/; + }; +} + +void* HelloWorldPubSubType::createData() +{ + return reinterpret_cast(new HelloWorld()); +} + +void HelloWorldPubSubType::deleteData(void* data) +{ + delete(reinterpret_cast(data)); +} + +bool HelloWorldPubSubType::getKey(void *data, InstanceHandle_t* handle, bool force_md5) +{ + if(!m_isGetKeyDefined) + return false; + HelloWorld* p_type = static_cast(data); + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer),HelloWorld::getKeyMaxCdrSerializedSize()); // Object that manages the raw buffer. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); // Object that serializes the data. + p_type->serializeKey(ser); + if(force_md5 || HelloWorld::getKeyMaxCdrSerializedSize()>16) { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for(uint8_t i = 0;i<16;++i) { + handle->value[i] = m_md5.digest[i]; + } + } + else { + for(uint8_t i = 0;i<16;++i) { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} + diff --git a/recipes/fast-dds/all/test_package/msg/HelloWorldPubSubTypes.h b/recipes/fast-dds/all/test_package/msg/HelloWorldPubSubTypes.h new file mode 100644 index 0000000000000..7afa612cc5925 --- /dev/null +++ b/recipes/fast-dds/all/test_package/msg/HelloWorldPubSubTypes.h @@ -0,0 +1,57 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _HELLOWORLD_PUBSUBTYPES_H_ +#define _HELLOWORLD_PUBSUBTYPES_H_ + +#include +#include + +#include "HelloWorld.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error Generated HelloWorld is not compatible with current installed Fast-RTPS. Please, regenerate it with fastrtpsgen. +#endif + +/*! + * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. + * @ingroup HELLOWORLD + */ +class HelloWorldPubSubType : public eprosima::fastrtps::TopicDataType { +public: + typedef HelloWorld type; + + eProsima_user_DllExport HelloWorldPubSubType(); + + eProsima_user_DllExport virtual ~HelloWorldPubSubType(); + eProsima_user_DllExport virtual bool serialize(void *data, eprosima::fastrtps::rtps::SerializedPayload_t *payload) override; + eProsima_user_DllExport virtual bool deserialize(eprosima::fastrtps::rtps::SerializedPayload_t *payload, void *data) override; + eProsima_user_DllExport virtual std::function getSerializedSizeProvider(void* data) override; + eProsima_user_DllExport virtual bool getKey(void *data, eprosima::fastrtps::rtps::InstanceHandle_t *ihandle, + bool force_md5 = false) override; + eProsima_user_DllExport virtual void* createData() override; + eProsima_user_DllExport virtual void deleteData(void * data) override; + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _HELLOWORLD_PUBSUBTYPES_H_ diff --git a/recipes/fast-dds/all/test_package/test_package.cpp b/recipes/fast-dds/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..89ac973375f14 --- /dev/null +++ b/recipes/fast-dds/all/test_package/test_package.cpp @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include +#include + +#include "msg/HelloWorld.h" +#include "msg/HelloWorldPubSubTypes.h" + +int main() +{ + // Define msg to send + HelloWorld hello; + hello.index(0); + hello.message("HelloWorld"); + + eprosima::fastrtps::Participant *participant; + eprosima::fastrtps::Publisher *publisher; + + eprosima::fastrtps::ParticipantAttributes PParam; + PParam.rtps.setName("Participant_pub"); + participant = eprosima::fastrtps::Domain::createParticipant(PParam); + + if (participant == nullptr) + { + return 1; + } + + HelloWorldPubSubType type; + + eprosima::fastrtps::Domain::registerType(participant, &type); + + //CREATE THE PUBLISHER + eprosima::fastrtps::PublisherAttributes Wparam; + Wparam.topic.topicKind = eprosima::fastrtps::rtps::TopicKind_t::NO_KEY; + Wparam.topic.topicDataType = "HelloWorld"; + Wparam.topic.topicName = "HelloWorldTopic"; + Wparam.topic.historyQos.kind = eprosima::fastrtps::KEEP_LAST_HISTORY_QOS; + Wparam.topic.historyQos.depth = 30; + Wparam.topic.resourceLimitsQos.max_samples = 50; + Wparam.topic.resourceLimitsQos.allocated_samples = 20; + Wparam.times.heartbeatPeriod.seconds = 2; + Wparam.times.heartbeatPeriod.nanosec = 200 * 1000 * 1000; + publisher = eprosima::fastrtps::Domain::createPublisher(participant, Wparam); + if (publisher == nullptr) + { + return 1; + } + + publisher->write((void*)&hello); + + eprosima::fastrtps::Domain::removeParticipant(participant); + + return 0; +} diff --git a/recipes/fast-dds/config.yml b/recipes/fast-dds/config.yml new file mode 100644 index 0000000000000..e8d99700ff1a0 --- /dev/null +++ b/recipes/fast-dds/config.yml @@ -0,0 +1,7 @@ +versions: + "2.3.4": + folder: all + "2.3.3": + folder: all + "2.3.2": + folder: all diff --git a/recipes/fast_double_parser/all/conandata.yml b/recipes/fast_double_parser/all/conandata.yml new file mode 100644 index 0000000000000..e6359076757f6 --- /dev/null +++ b/recipes/fast_double_parser/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "0.7.0": + url: "https://github.com/lemire/fast_double_parser/archive/v0.7.0.tar.gz" + sha256: "eb80a1d9c406bbe8cb22fffd3c007651f716abd03225009302d8aba8e9c4df77" + "0.6.0": + url: "https://github.com/lemire/fast_double_parser/archive/refs/tags/v0.6.0.tar.gz" + sha256: "90835c770a2577a38442601e92330207ad8b917f956614938303b8439d13b282" + "0.5.0": + url: "https://github.com/lemire/fast_double_parser/archive/refs/tags/v0.5.0.tar.gz" + sha256: "afbd2d42facd037bf3859856a8fe4112e4d7ded942255f6c0e6c17689d41f645" diff --git a/recipes/fast_double_parser/all/conanfile.py b/recipes/fast_double_parser/all/conanfile.py new file mode 100644 index 0000000000000..a704c8e783d7f --- /dev/null +++ b/recipes/fast_double_parser/all/conanfile.py @@ -0,0 +1,38 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class FastDoubleParserConan(ConanFile): + name = "fast_double_parser" + description = "Fast function to parse strings into double (binary64) floating-point values, enforces the RFC 7159 (JSON standard) grammar: 4x faster than strtod" + topics = ("numerical", "header-only") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/lemire/fast_double_parser" + license = ("Apache-2.0", "BSL-1.0") + + settings = "os", "compiler", "build_type", "arch" + no_copy_source = True + + def layout(self): + basic_layout(self) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def package_id(self): + self.info.clear() + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def package(self): + include_folder = os.path.join(self.source_folder, "include") + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=include_folder) + copy(self, pattern="LICENSE*", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) diff --git a/recipes/fast_double_parser/all/test_package/CMakeLists.txt b/recipes/fast_double_parser/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..00ff6376bfebe --- /dev/null +++ b/recipes/fast_double_parser/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(fast_double_parser REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} fast_double_parser::fast_double_parser) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fast_double_parser/all/test_package/conanfile.py b/recipes/fast_double_parser/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e845ae751a301 --- /dev/null +++ b/recipes/fast_double_parser/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fast_double_parser/all/test_package/test_package.cpp b/recipes/fast_double_parser/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..02cddc31a03a3 --- /dev/null +++ b/recipes/fast_double_parser/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main() { + std::string a = "0."; + double x; + bool ok = fast_double_parser::parse_number(a.c_str(), &x); + return 0; +} diff --git a/recipes/fast_double_parser/all/test_v1_package/CMakeLists.txt b/recipes/fast_double_parser/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/fast_double_parser/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/fast_double_parser/all/test_v1_package/conanfile.py b/recipes/fast_double_parser/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..90eb89e3f2f46 --- /dev/null +++ b/recipes/fast_double_parser/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fast_double_parser/config.yml b/recipes/fast_double_parser/config.yml new file mode 100644 index 0000000000000..d61439bae1bc3 --- /dev/null +++ b/recipes/fast_double_parser/config.yml @@ -0,0 +1,7 @@ +versions: + "0.7.0": + folder: all + "0.6.0": + folder: all + "0.5.0": + folder: all diff --git a/recipes/fast_float/all/conandata.yml b/recipes/fast_float/all/conandata.yml index 7319001557376..671eec2eea6bf 100644 --- a/recipes/fast_float/all/conandata.yml +++ b/recipes/fast_float/all/conandata.yml @@ -1,4 +1,37 @@ sources: + "3.8.1": + url: "https://github.com/fastfloat/fast_float/archive/v3.8.1.tar.gz" + sha256: "823d7f8df7fadc3ed24738eb0cf4a40f0450068edd92805698916be40966d87a" + "3.8.0": + url: "https://github.com/fastfloat/fast_float/archive/v3.8.0.tar.gz" + sha256: "8cb82dc35da3b745b3beb1a9974402307c9ded0e875aea077dbb3ea63833dd2e" + "3.7.0": + url: "https://github.com/fastfloat/fast_float/archive/v3.7.0.tar.gz" + sha256: "4a30c43d14bbc979130a7807aecb2de5ff513951dd99a8b77cc32acfc610f850" + "3.6.0": + url: "https://github.com/fastfloat/fast_float/archive/v3.6.0.tar.gz" + sha256: "0852175e5ebf2b59bcde9c3be2ccd50441f2997350884652302d034785a4fbf5" + "3.5.1": + url: "https://github.com/fastfloat/fast_float/archive/v3.5.1.tar.gz" + sha256: "8558bf9c66ccd2f7d03c94461a107f49ad9cf6e4f6c0c84e148fec0aa32b4dd9" + "3.4.0": + url: "https://github.com/fastfloat/fast_float/archive/v3.4.0.tar.gz" + sha256: "a242877d2fae81ca412033f5ebf5dbc43cb029c56b4af78e33106b9a69f8f58e" + "3.2.0": + url: "https://github.com/fastfloat/fast_float/archive/v3.2.0.tar.gz" + sha256: "c26d78b2b76704b117c416292bc47fa3e4bb69a131e82debe0e8fd5c7afdf18e" + "3.1.0": + url: "https://github.com/fastfloat/fast_float/archive/v3.1.0.tar.gz" + sha256: "755ee0bdde8ee0cc10ae16e1f283c2833d9cfa7ea114950ab807dc7ee108f722" + "2.0.0": + url: "https://github.com/fastfloat/fast_float/archive/v2.0.0.tar.gz" + sha256: "5d528ec20811577c5f2b2873528c085c500fdcd2b2c0901450509a71de5f1fa4" + "1.1.2": + url: "https://github.com/fastfloat/fast_float/archive/v1.1.2.tar.gz" + sha256: "580655a9ad2aeac7507de4433dcf985d8699ae8128b97c2cabc0962aa5beb513" + "1.1.1": + url: "https://github.com/fastfloat/fast_float/archive/refs/tags/v1.1.1.tar.gz" + sha256: "d17eb86f597e9f4972a1d5f81c42c7dee041aaae2e826b80685ed90dad5b3593" "1.0.0": url: "https://github.com/fastfloat/fast_float/archive/v1.0.0.tar.gz" sha256: "694e87e6f5e08d4a5f22efcc8fb1977e30f3d63bfc7995a6a7a7288c3d581d75" diff --git a/recipes/fast_float/all/conanfile.py b/recipes/fast_float/all/conanfile.py index aae6671737fd8..3750e947efcf2 100644 --- a/recipes/fast_float/all/conanfile.py +++ b/recipes/fast_float/all/conanfile.py @@ -1,41 +1,55 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.50.0" + class FastFloatConan(ConanFile): name = "fast_float" description = "Fast and exact implementation of the C++ from_chars " \ "functions for float and double types." - license = "Apache-2.0" - topics = ("conan", "fast_float", "conversion", "from_chars") + license = ("Apache-2.0", "MIT") + topics = ("fast_float", "conversion", "from_chars") homepage = "https://github.com/fastfloat/fast_float" url = "https://github.com/conan-io/conan-center-index" - - settings = "compiler" - + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() - def configure(self): + def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) + check_min_cppstd(self, 11) - def package_id(self): - self.info.header_only() + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "FastFloat") + self.cpp_info.set_property("cmake_target_name", "FastFloat::fast_float") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once legacy generators removed self.cpp_info.names["cmake_find_package"] = "FastFloat" self.cpp_info.names["cmake_find_package_multi"] = "FastFloat" self.cpp_info.components["fastfloat"].names["cmake_find_package"] = "fast_float" self.cpp_info.components["fastfloat"].names["cmake_find_package_multi"] = "fast_float" + self.cpp_info.components["fastfloat"].set_property("cmake_target_name", "FastFloat::fast_float") diff --git a/recipes/fast_float/all/test_package/CMakeLists.txt b/recipes/fast_float/all/test_package/CMakeLists.txt index f15b684bbdbbd..4e77f3f59c71c 100644 --- a/recipes/fast_float/all/test_package/CMakeLists.txt +++ b/recipes/fast_float/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(FastFloat REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} FastFloat::fast_float) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE FastFloat::fast_float) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fast_float/all/test_package/conanfile.py b/recipes/fast_float/all/test_package/conanfile.py index a9f777f7680ff..d120a992c06a6 100644 --- a/recipes/fast_float/all/test_package/conanfile.py +++ b/recipes/fast_float/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fast_float/all/test_v1_package/CMakeLists.txt b/recipes/fast_float/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e5e8bb319fc1f --- /dev/null +++ b/recipes/fast_float/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(FastFloat REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE FastFloat::fast_float) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fast_float/all/test_v1_package/conanfile.py b/recipes/fast_float/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/fast_float/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fast_float/config.yml b/recipes/fast_float/config.yml index f9e0211f523b2..d1bb7ba803813 100644 --- a/recipes/fast_float/config.yml +++ b/recipes/fast_float/config.yml @@ -1,4 +1,26 @@ versions: + "3.8.1": + folder: all + "3.8.0": + folder: all + "3.7.0": + folder: all + "3.6.0": + folder: all + "3.5.1": + folder: all + "3.4.0": + folder: all + "3.2.0": + folder: all + "3.1.0": + folder: all + "2.0.0": + folder: all + "1.1.2": + folder: all + "1.1.1": + folder: all "1.0.0": folder: all "0.9.0": diff --git a/recipes/fastpfor/all/CMakeLists.txt b/recipes/fastpfor/all/CMakeLists.txt new file mode 100644 index 0000000000000..7d5ba25565b0a --- /dev/null +++ b/recipes/fastpfor/all/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.4) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +add_subdirectory(source_subfolder) diff --git a/recipes/fastpfor/all/conandata.yml b/recipes/fastpfor/all/conandata.yml new file mode 100644 index 0000000000000..79aae084fc25c --- /dev/null +++ b/recipes/fastpfor/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "cci.20220205": + url: "https://github.com/lemire/FastPFor/archive/773283d4a11fa2440a1b3b28fd77f775e86d7898.tar.gz" + sha256: "d4419512420f3bcc65862c5c367021f201b5ba3e8cb0dad895cdf444e0867b30" + +patches: + "cci.20220205": + - patch_file: "patches/cci.20220205-0001-fix-cmake.patch" + base_path: "source_subfolder" diff --git a/recipes/fastpfor/all/conanfile.py b/recipes/fastpfor/all/conanfile.py new file mode 100644 index 0000000000000..03c242e83bf88 --- /dev/null +++ b/recipes/fastpfor/all/conanfile.py @@ -0,0 +1,83 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os +import functools + +required_conan_version = ">=1.43.0" + +class FastPFORConan(ConanFile): + name = "fastpfor" + description = "Fast integer compression" + topics = ("compression", "sorted-lists", "simd", "x86", "x86-64") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/lemire/FastPFor" + license = "Apache-2.0" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.arch != "x86_64": + raise ConanInvalidConfiguration("{} architecture is not supported".format(self.settings.arch)) + + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "11") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure() + return cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["FastPFOR"] + + self.cpp_info.set_property("cmake_file_name", "FastPFOR") + self.cpp_info.set_property("cmake_target_name", "FastPFOR::FastPFOR") + + self.cpp_info.filenames["cmake_find_package"] = "FastPFOR" + self.cpp_info.filenames["cmake_find_package_multi"] = "FastPFOR" + self.cpp_info.names["cmake_find_package"] = "FastPFOR" + self.cpp_info.names["cmake_find_package_multi"] = "FastPFOR" diff --git a/recipes/fastpfor/all/patches/cci.20220205-0001-fix-cmake.patch b/recipes/fastpfor/all/patches/cci.20220205-0001-fix-cmake.patch new file mode 100644 index 0000000000000..831aaf49de782 --- /dev/null +++ b/recipes/fastpfor/all/patches/cci.20220205-0001-fix-cmake.patch @@ -0,0 +1,72 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5520747..dfccbc1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -94,6 +94,10 @@ elseif(WIN32) + if(NOT MSVC12) + message(STATUS "On Windows, only MSVC version 12 is supported!") + endif() ++ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:AVX") ++ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:AVX") ++ set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /arch:AVX") ++ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /arch:AVX") + else () + message(FATAL_ERROR "Please, use GCC, Clang, or the Intel compiler!") + endif() +@@ -108,7 +112,7 @@ MESSAGE( STATUS "CMAKE_C_FLAGS_RELEASE: " ${CMAKE_C_FLAGS_RELEASE} ) + + # library target + include_directories(headers) +-add_library(FastPFOR STATIC ++add_library(FastPFOR + src/bitpacking.cpp + src/bitpackingaligned.cpp + src/bitpackingunaligned.cpp +@@ -117,9 +121,8 @@ add_library(FastPFOR STATIC + src/simdbitpacking.cpp + src/varintdecode.c + src/streamvbyte.c) +-set_target_properties(FastPFOR PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +- + ++if(0) + # other executables + add_executable(gapstats src/gapstats.cpp) + add_executable(partitionbylength src/partitionbylength.cpp) +@@ -132,6 +135,7 @@ if( SUPPORT_SSE42 ) + add_executable(benchbitpacking src/benchbitpacking.cpp) + target_link_libraries(benchbitpacking FastPFOR) + endif() ++endif(0) + + find_package(snappy) + if(NOT ${snappy_FOUND}) +@@ -141,6 +145,8 @@ else() + message(STATUS "Snappy was found. Building additional targets " + "codecssnappy and inmemorybenchmarksnappy.") + include_directories(${snappy_INCLUDE_DIRS}) ++ ++ if(0) + add_executable(codecssnappy src/codecs.cpp) + set_target_properties(codecssnappy PROPERTIES DEFINE_SYMBOL USESNAPPY) + target_link_libraries(codecssnappy FastPFOR ${snappy_LIBRARIES}) +@@ -148,8 +154,10 @@ else() + add_executable(inmemorybenchmarksnappy src/inmemorybenchmark.cpp) + set_target_properties(inmemorybenchmarksnappy PROPERTIES DEFINE_SYMBOL USESNAPPY) + target_link_libraries(inmemorybenchmarksnappy FastPFOR ${snappy_LIBRARIES}) ++ endif(0) + endif() + ++if(0) + # Download and unpack googletest at configure time + configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . +@@ -207,7 +215,7 @@ target_link_libraries(FastPFOR_unittest gtest FastPFOR) + enable_testing() + add_test("unit" unit) + add_test("FastPFOR_unittest" FastPFOR_unittest) +- ++endif(0) + + include(GNUInstallDirs) + install(TARGETS FastPFOR diff --git a/recipes/fastpfor/all/test_package/CMakeLists.txt b/recipes/fastpfor/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..0a186fecd6200 --- /dev/null +++ b/recipes/fastpfor/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(FastPFOR REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} FastPFOR::FastPFOR) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fastpfor/all/test_package/conanfile.py b/recipes/fastpfor/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/fastpfor/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fastpfor/all/test_package/test_package.cpp b/recipes/fastpfor/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..acd0edc6fe5da --- /dev/null +++ b/recipes/fastpfor/all/test_package/test_package.cpp @@ -0,0 +1,30 @@ +#include "fastpfor/codecfactory.h" +#include "fastpfor/deltautil.h" + +int main() { + using namespace FastPForLib; + + IntegerCODEC &codec = *CODECFactory::getFromName("simdfastpfor256"); + + size_t N = 10 * 1000; + std::vector mydata(N); + for (uint32_t i = 0; i < N; i += 150) + mydata[i] = i; + + std::vector compressed_output(N + 1024); + + size_t compressedsize = compressed_output.size(); + codec.encodeArray(mydata.data(), mydata.size(), compressed_output.data(), + compressedsize); + + compressed_output.resize(compressedsize); + compressed_output.shrink_to_fit(); + + std::cout << std::setprecision(3); + std::cout << "You are using " + << 32.0 * static_cast(compressed_output.size()) / + static_cast(mydata.size()) + << " bits per integer. " << std::endl; + + return 0; +} diff --git a/recipes/fastpfor/config.yml b/recipes/fastpfor/config.yml new file mode 100644 index 0000000000000..19127b42445cc --- /dev/null +++ b/recipes/fastpfor/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220205": + folder: all diff --git a/recipes/fastprng/all/conandata.yml b/recipes/fastprng/all/conandata.yml new file mode 100644 index 0000000000000..7df6c1bcf5865 --- /dev/null +++ b/recipes/fastprng/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20200628": + url: "https://github.com/BrutPitt/fastPRNG/archive/5ce17711a65965b3726b3f0c62c7dcbd967a7b0f.zip" + sha256: "ab185d52bbc4d3d02cf258a3be01059e7c28a0d9e6320a0c1dba7aa74a27b201" diff --git a/recipes/fastprng/all/conanfile.py b/recipes/fastprng/all/conanfile.py new file mode 100644 index 0000000000000..c83ba01f89440 --- /dev/null +++ b/recipes/fastprng/all/conanfile.py @@ -0,0 +1,40 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.layout import basic_layout +from conan.tools.files import get, copy +import os + +required_conan_version = ">=1.50.0" + + +class FastPRNGConan(ConanFile): + name = "fastprng" + description = "FAST 32/64 bit PRNG (pseudo-random generator), highly optimized, based on xoshiro* / xoroshiro*, xorshift and other Marsaglia algorithms." + topics = ("random", "prng", "xorshift", "xoshiro", ) + license = "BSD-2-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/BrutPitt/fastPRNG" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def layout(self): + basic_layout(self) + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, "11") + + def source(self): + get( + self, + **self.conan_data["sources"][self.version], + destination=self.source_folder, + strip_root=True + ) + + def package(self): + copy(self, "*.h", self.source_folder, os.path.join(self.package_folder, "include")) + copy(self, "license.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) diff --git a/recipes/fastprng/all/test_package/CMakeLists.txt b/recipes/fastprng/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a0f34e4c094ac --- /dev/null +++ b/recipes/fastprng/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(fastprng CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE fastprng::fastprng) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fastprng/all/test_package/conanfile.py b/recipes/fastprng/all/test_package/conanfile.py new file mode 100644 index 0000000000000..48499fa0989d9 --- /dev/null +++ b/recipes/fastprng/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fastprng/all/test_package/test_package.cpp b/recipes/fastprng/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..1ddf23d672e5a --- /dev/null +++ b/recipes/fastprng/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include "fastPRNG.h" + +#include + +int main() { + fastPRNG::fastXS64 fastR; + + std::cout << fastR.xoshiro256p() << std::endl; + + return 0; +} diff --git a/recipes/fastprng/all/test_v1_package/CMakeLists.txt b/recipes/fastprng/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7ea0378c83fe1 --- /dev/null +++ b/recipes/fastprng/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/fastprng/all/test_v1_package/conanfile.py b/recipes/fastprng/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..aaf25befb2087 --- /dev/null +++ b/recipes/fastprng/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, CMake, tools + +class TestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fastprng/config.yml b/recipes/fastprng/config.yml new file mode 100644 index 0000000000000..d47d739245183 --- /dev/null +++ b/recipes/fastprng/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20200628": + folder: "all" diff --git a/recipes/fcl/all/CMakeLists.txt b/recipes/fcl/all/CMakeLists.txt deleted file mode 100644 index 4d393c7a86c09..0000000000000 --- a/recipes/fcl/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory("source_subfolder") diff --git a/recipes/fcl/all/conandata.yml b/recipes/fcl/all/conandata.yml index 3dab85f3d9323..2d2965127b1cf 100644 --- a/recipes/fcl/all/conandata.yml +++ b/recipes/fcl/all/conandata.yml @@ -1,12 +1,15 @@ sources: + "0.7.0": + url: "https://github.com/flexible-collision-library/fcl/archive/refs/tags/0.7.0.tar.gz" + sha256: "90409e940b24045987506a6b239424a4222e2daf648c86dd146cbcb692ebdcbc" "0.6.1": url: "https://github.com/flexible-collision-library/fcl/archive/v0.6.1.tar.gz" sha256: "c8a68de8d35a4a5cd563411e7577c0dc2c626aba1eef288cb1ca88561f8d8019" patches: + "0.7.0": + - patch_file: "patches/0001-fix-cmake-0.7.0.patch" + - patch_file: "patches/0002-fix-mingw-bigobj.patch" "0.6.1": - - patch_file: "patches/conanize-cmake-0.6.1.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix-mingw-bigobj.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix-alias-type-msvc2015.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-fix-cmake-0.6.1.patch" + - patch_file: "patches/0002-fix-mingw-bigobj.patch" + - patch_file: "patches/0003-fix-alias-type-msvc2015.patch" diff --git a/recipes/fcl/all/conanfile.py b/recipes/fcl/all/conanfile.py index 88b04825f383c..2c8e8687c5122 100644 --- a/recipes/fcl/all/conanfile.py +++ b/recipes/fcl/all/conanfile.py @@ -1,9 +1,13 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir, save +from conan.tools.scm import Version import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" class FclConan(ConanFile): @@ -11,32 +15,25 @@ class FclConan(ConanFile): description = "C++11 library for performing three types of proximity " \ "queries on a pair of geometric models composed of triangles." license = "BSD-3-Clause" - topics = ("conan", "fcl", "geometry", "collision") + topics = ("fcl", "geometry", "collision") homepage = "https://github.com/flexible-collision-library/fcl" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "with_octomap": [True, False] + "with_octomap": [True, False], } default_options = { "shared": False, "fPIC": True, - "with_octomap": True + "with_octomap": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -45,66 +42,76 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("{0} {1} doesn't properly support shared lib on Windows".format(self.name, - self.version)) def requirements(self): - self.requires("eigen/3.3.9") + self.requires("eigen/3.4.0") self.requires("libccd/2.1") if self.options.with_octomap: - self.requires("octomap/1.9.6") + self.requires("octomap/1.9.7") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + if self.info.settings.os == "Windows" and self.info.options.shared: + raise ConanInvalidConfiguration( + "fcl {} doesn't properly support shared lib on Windows".format(self.version) + ) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FCL_ENABLE_PROFILING"] = False + tc.variables["FCL_TREAT_WARNINGS_AS_ERRORS"] = False + tc.variables["FCL_HIDE_ALL_SYMBOLS"] = False + tc.variables["FCL_STATIC_LIBRARY"] = not self.options.shared + tc.variables["FCL_USE_X64_SSE"] = False # Let consumer decide to add relevant compile options, fcl doesn't have simd intrinsics + tc.variables["FCL_USE_HOST_NATIVE_ARCH"] = False + tc.variables["FCL_USE_SSE"] = False + tc.variables["FCL_COVERALLS"] = False + tc.variables["FCL_COVERALLS_UPLOAD"] = False + tc.variables["FCL_WITH_OCTOMAP"] = self.options.with_octomap + if self.options.with_octomap: + octomap_version_str = self.dependencies["octomap"].ref.version + tc.variables["OCTOMAP_VERSION"] = octomap_version_str + octomap_version = Version(octomap_version_str) + tc.variables["OCTOMAP_MAJOR_VERSION"] = octomap_version.major + tc.variables["OCTOMAP_MINOR_VERSION"] = octomap_version.minor + tc.variables["OCTOMAP_PATCH_VERSION"] = octomap_version.patch + tc.variables["BUILD_TESTING"] = False + tc.variables["FCL_NO_DEFAULT_RPATH"] = False + tc.generate() + + cd = CMakeDeps(self) + cd.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["FCL_ENABLE_PROFILING"] = False - self._cmake.definitions["FCL_TREAT_WARNINGS_AS_ERRORS"] = False - self._cmake.definitions["FCL_HIDE_ALL_SYMBOLS"] = False - self._cmake.definitions["FCL_STATIC_LIBRARY"] = not self.options.shared - self._cmake.definitions["FCL_USE_X64_SSE"] = False # Let consumer decide to add relevant compile options, ftl doesn't have simd intrinsics - self._cmake.definitions["FCL_USE_HOST_NATIVE_ARCH"] = False - self._cmake.definitions["FCL_USE_SSE"] = False - self._cmake.definitions["FCL_COVERALLS"] = False - self._cmake.definitions["FCL_COVERALLS_UPLOAD"] = False - self._cmake.definitions["FCL_WITH_OCTOMAP"] = self.options.with_octomap - if self.options.with_octomap: - octomap_major, octomap_minor, octomap_patch = self.deps_cpp_info["octomap"].version.split(".") - self._cmake.definitions["OCTOMAP_MAJOR_VERSION"] = octomap_major - self._cmake.definitions["OCTOMAP_MINOR_VERSION"] = octomap_minor - self._cmake.definitions["OCTOMAP_PATCH_VERSION"] = octomap_patch - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "CMake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "CMake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {"fcl": "fcl::fcl"} ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): content += textwrap.dedent("""\ @@ -113,22 +120,23 @@ def _create_cmake_module_alias_targets(module_file, targets): set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + save(self, module_file, content) @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "fcl" - self.cpp_info.names["cmake_find_package_multi"] = "fcl" - self.cpp_info.builddirs.append(self._module_subfolder) + self.cpp_info.set_property("cmake_file_name", "fcl") + self.cpp_info.set_property("cmake_target_name", "fcl") + self.cpp_info.set_property("pkg_config_name", "fcl") + self.cpp_info.libs = ["fcl"] + + # TODO: to remove if required_conan_version updated to 1.51.1 (see https://github.com/conan-io/conan/pull/11790) + self.cpp_info.requires = ["eigen::eigen", "libccd::libccd"] + if self.options.with_octomap: + self.cpp_info.requires.append("octomap::octomap") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - self.cpp_info.names["pkg_config"] = "fcl" - self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/fcl/all/patches/0001-fix-cmake-0.6.1.patch b/recipes/fcl/all/patches/0001-fix-cmake-0.6.1.patch new file mode 100644 index 0000000000000..87690d911d402 --- /dev/null +++ b/recipes/fcl/all/patches/0001-fix-cmake-0.6.1.patch @@ -0,0 +1,22 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -72,7 +72,7 @@ if(MSVC OR MSVC90 OR MSVC10) + endif (MSVC OR MSVC90 OR MSVC10) + + set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) +-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") + include(CMakePackageConfigHelpers) + include(GenerateExportHeader) + include(GNUInstallDirs) +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -103,6 +103,8 @@ if(FCL_HAVE_OCTOMAP) + # available, otherwise fall back to OCTOMAP_INCLUDE_DIRS and OCTOMAP_LIBRARIES + if(TARGET octomap) + target_link_libraries(${PROJECT_NAME} PUBLIC octomap) ++ elseif(TARGET octomap-static) ++ target_link_libraries(${PROJECT_NAME} PUBLIC octomap-static) + elseif(OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARIES) + target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${OCTOMAP_INCLUDE_DIRS}") + target_link_libraries(${PROJECT_NAME} PUBLIC "${OCTOMAP_LIBRARIES}") diff --git a/recipes/fcl/all/patches/0001-fix-cmake-0.7.0.patch b/recipes/fcl/all/patches/0001-fix-cmake-0.7.0.patch new file mode 100644 index 0000000000000..54b12b1ddcc5a --- /dev/null +++ b/recipes/fcl/all/patches/0001-fix-cmake-0.7.0.patch @@ -0,0 +1,22 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -66,7 +66,7 @@ if(MSVC OR MSVC90 OR MSVC10) + endif (MSVC OR MSVC90 OR MSVC10) + + set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) +-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") + include(CMakePackageConfigHelpers) + include(GenerateExportHeader) + include(GNUInstallDirs) +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -103,6 +103,8 @@ if(FCL_HAVE_OCTOMAP) + # available, otherwise fall back to OCTOMAP_INCLUDE_DIRS and OCTOMAP_LIBRARIES + if(TARGET octomap) + target_link_libraries(${PROJECT_NAME} PUBLIC octomap) ++ elseif(TARGET octomap-static) ++ target_link_libraries(${PROJECT_NAME} PUBLIC octomap-static) + elseif(OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARIES) + target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${OCTOMAP_INCLUDE_DIRS}") + target_link_libraries(${PROJECT_NAME} PUBLIC "${OCTOMAP_LIBRARIES}") diff --git a/recipes/fcl/all/patches/fix-mingw-bigobj.patch b/recipes/fcl/all/patches/0002-fix-mingw-bigobj.patch similarity index 100% rename from recipes/fcl/all/patches/fix-mingw-bigobj.patch rename to recipes/fcl/all/patches/0002-fix-mingw-bigobj.patch diff --git a/recipes/fcl/all/patches/fix-alias-type-msvc2015.patch b/recipes/fcl/all/patches/0003-fix-alias-type-msvc2015.patch similarity index 100% rename from recipes/fcl/all/patches/fix-alias-type-msvc2015.patch rename to recipes/fcl/all/patches/0003-fix-alias-type-msvc2015.patch diff --git a/recipes/fcl/all/patches/conanize-cmake-0.6.1.patch b/recipes/fcl/all/patches/conanize-cmake-0.6.1.patch deleted file mode 100644 index 5f650800aa804..0000000000000 --- a/recipes/fcl/all/patches/conanize-cmake-0.6.1.patch +++ /dev/null @@ -1,169 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -142,20 +142,6 @@ set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON) - # - # If Eigen3 is not found, manually set the cache variable EIGEN3_INCLUDE_DIR - #=============================================================================== --find_package(Eigen3 3.0.5 QUIET CONFIG) -- --# If Eigen3Config.cmake is not found, use the FindEigen3.cmake module --if(NOT Eigen3_FOUND) -- find_package(Eigen3 3.0.5 QUIET MODULE) -- set(Eigen3_FOUND ON) --endif() -- --if(Eigen3_FOUND) -- set(FCL_HAVE_EIGEN TRUE) --else() -- message(SEND_ERROR "EIGEN3 (>= 3.0.5) is required by FCL") -- set(FCL_HAVE_EIGEN FALSE) --endif() - - #=============================================================================== - # Find required dependency libccd -@@ -163,41 +149,6 @@ endif() - # If libccd is not found, manually set the cache variables CCD_INCLUDE_DIR and - # CCD_LIBRARY - #=============================================================================== --find_package(ccd QUIET) -- --# If ccd-config.cmake is not found, use pkg-config and/or find_path() and --# find_library() --if(NOT ccd_FOUND) -- if(PKG_CONFIG_FOUND) -- pkg_check_modules(PC_CCD ccd) -- pkg_check_modules(PC_LIBCCD libccd) -- endif() -- -- find_path(CCD_INCLUDE_DIR ccd/ccd.h -- HINTS "${PC_CCD_INCLUDE_DIRS}" "${PC_LIBCCD_INCLUDE_DIRS}") -- -- # Using find_library() even if pkg-config is available ensures that the full -- # path to the ccd library is available in CCD_LIBRARIES -- find_library(CCD_LIBRARY ccd -- HINTS "${PC_CCD_LIBRARY_DIRS}" "${PC_LIBCCD_LIBRARY_DIRS}") -- -- # libccd links to LibM on UNIX. -- if(CYGWIN OR NOT WIN32) -- find_library(M_LIBRARY m) -- endif() -- -- if(CCD_INCLUDE_DIR AND CCD_LIBRARY) -- set(CCD_INCLUDE_DIRS "${CCD_INCLUDE_DIR}") -- set(CCD_LIBRARIES "${CCD_LIBRARY}" "${M_LIBRARY}") -- set(ccd_FOUND ON) -- -- mark_as_advanced(CCD_INCLUDE_DIR CCD_LIBRARY) -- endif() --endif() -- --if(NOT ccd_FOUND) -- message(FATAL_ERROR "CCD is required by FCL") --endif() - - set(PKG_EXTERNAL_DEPS "ccd eigen3") - -@@ -211,58 +162,9 @@ option(FCL_WITH_OCTOMAP "OctoMap library support" ON) - set(FCL_HAVE_OCTOMAP 0) - - if(FCL_WITH_OCTOMAP) -- find_package(octomap QUIET) -- -- # Older versions of octomap-config.cmake may not define OCTOMAP_VERSION so -- # fall back to pkg-config -- if(NOT octomap_FOUND OR NOT OCTOMAP_VERSION) -- if(PKG_CONFIG_FOUND) -- pkg_check_modules(PC_OCTOMAP octomap) -- endif() -- -- find_path(OCTOMAP_INCLUDE_DIR octomap/octomap.h -- HINTS "${PC_OCTOMAP_INCLUDE_DIRS}") -- -- # Using find_library() even if pkg-config is available ensures that the full -- # paths to the octomap and octomath libraries are set in OCTOMAP_LIBRARIES -- find_library(OCTOMAP_LIBRARY octomap -- HINTS "${PC_OCTOMAP_LIBRARY_DIRS}") -- -- find_library(OCTOMATH_LIBRARY octomath -- HINTS "${PC_OCTOMAP_LIBRARY_DIRS}") -- -- # Use a cache variable so that the version can be manually set if pkg-config -- # is not available -- set(OCTOMAP_VERSION "${PC_OCTOMAP_VERSION}" -- CACHE STRING "octomap version (major.minor.patch)") -- -- if(OCTOMAP_INCLUDE_DIR AND OCTOMAP_LIBRARY AND OCTOMATH_LIBRARY AND OCTOMAP_VERSION) -- set(OCTOMAP_INCLUDE_DIRS "${OCTOMAP_INCLUDE_DIR}") -- set(OCTOMAP_LIBRARIES "${OCTOMAP_LIBRARY}" "${OCTOMATH_LIBRARY}") -- set(octomap_FOUND ON) -- -- mark_as_advanced(OCTOMAP_INCLUDE_DIR OCTOMAP_LIBRARY OCTOMATH_LIBRARY OCTOMAP_VERSION) -- else() -- set(octomap_FOUND OFF) -- endif() -- endif() -- -- if(octomap_FOUND) -- if(NOT OCTOMAP_MAJOR_VERSION AND NOT OCTOMAP_MINOR_VERSION AND NOT OCTOMAP_PATCH_VERSION) -- string(REPLACE "." ";" VERSION_LIST "${OCTOMAP_VERSION}") -- list(GET VERSION_LIST 0 OCTOMAP_MAJOR_VERSION) -- list(GET VERSION_LIST 1 OCTOMAP_MINOR_VERSION) -- list(GET VERSION_LIST 2 OCTOMAP_PATCH_VERSION) -- endif() -- -- set(FCL_HAVE_OCTOMAP 1) -- message(STATUS "FCL uses OctoMap") -- set(PKG_EXTERNAL_DEPS "${PKG_EXTERNAL_DEPS} octomap") -- else() -- message(STATUS "FCL does not use OctoMap") -- endif() --else() -- message(STATUS "FCL does not use OctoMap (as requested)") -+ set(FCL_HAVE_OCTOMAP 1) -+ message(STATUS "FCL uses OctoMap") -+ set(PKG_EXTERNAL_DEPS "${PKG_EXTERNAL_DEPS} octomap") - endif() - - if(TARGET ccd) ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -77,36 +77,17 @@ endif() - - # Use the IMPORTED target from newer versions of ccd-config.cmake if available, - # otherwise fall back to CCD_INCLUDE_DIRS and CCD_LIBRARIES --if(TARGET ccd) -- target_link_libraries(${PROJECT_NAME} PUBLIC ccd) --else() -- target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${CCD_INCLUDE_DIRS}") -- target_link_libraries(${PROJECT_NAME} PUBLIC "${CCD_LIBRARIES}") --endif() -+target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::libccd) - - # Use the IMPORTED target from newer versions of Eigen3Config.cmake if - # available, otherwise fall back to EIGEN3_INCLUDE_DIRS from older versions of - # Eigen3Config.cmake or EIGEN3_INCLUDE_DIR from FindEigen3.cmake --if(TARGET Eigen3::Eigen) -- # Note that Eigen3::Eigen is an INTERFACE library, so the INCLUDE_DIRECTORIES -- # and INTERFACE_INCLUDE_DIRECTORIES are populated, but nothing is actually -- # linked -- target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen) --elseif(EIGEN3_INCLUDE_DIRS) -- target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${EIGEN3_INCLUDE_DIRS}") --else() -- target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${EIGEN3_INCLUDE_DIR}") --endif() -+target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::eigen) - - if(FCL_HAVE_OCTOMAP) - # Use the IMPORTED target from newer versions of octomap-config.cmake if - # available, otherwise fall back to OCTOMAP_INCLUDE_DIRS and OCTOMAP_LIBRARIES -- if(TARGET octomap) -- target_link_libraries(${PROJECT_NAME} PUBLIC octomap) -- elseif(OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARIES) -- target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${OCTOMAP_INCLUDE_DIRS}") -- target_link_libraries(${PROJECT_NAME} PUBLIC "${OCTOMAP_LIBRARIES}") -- endif() -+ target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::octomap) - endif() - - target_include_directories(${PROJECT_NAME} INTERFACE diff --git a/recipes/fcl/all/test_package/CMakeLists.txt b/recipes/fcl/all/test_package/CMakeLists.txt index 1472682b8f083..8f41ad8aed5d9 100644 --- a/recipes/fcl/all/test_package/CMakeLists.txt +++ b/recipes/fcl/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(fcl REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} fcl) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE fcl) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fcl/all/test_package/conanfile.py b/recipes/fcl/all/test_package/conanfile.py index a9f777f7680ff..3a8c6c5442b33 100644 --- a/recipes/fcl/all/test_package/conanfile.py +++ b/recipes/fcl/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fcl/all/test_v1_package/CMakeLists.txt b/recipes/fcl/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..94f82041a6218 --- /dev/null +++ b/recipes/fcl/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fcl REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE fcl) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/fcl/all/test_v1_package/conanfile.py b/recipes/fcl/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/fcl/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fcl/config.yml b/recipes/fcl/config.yml index b0963ca9332e2..20ca85280a5a5 100644 --- a/recipes/fcl/config.yml +++ b/recipes/fcl/config.yml @@ -1,3 +1,5 @@ versions: + "0.7.0": + folder: all "0.6.1": folder: all diff --git a/recipes/ffmpeg/all/conandata.yml b/recipes/ffmpeg/all/conandata.yml new file mode 100644 index 0000000000000..13f029f130a72 --- /dev/null +++ b/recipes/ffmpeg/all/conandata.yml @@ -0,0 +1,16 @@ +sources: + "5.0": + url: "https://ffmpeg.org/releases/ffmpeg-5.0.tar.bz2" + sha256: "c0130b8db2c763430fd1c6905288d61bc44ee0548ad5fcd2dfd650b88432bed9" + "4.4.3": + url: "https://ffmpeg.org/releases/ffmpeg-4.4.3.tar.bz2" + sha256: "33b8c2dbcd530fe1db5710415345609b4ca227bd0da1e3a9332dbb0f11fd273a" + "4.4": + url: "https://ffmpeg.org/releases/ffmpeg-4.4.tar.bz2" + sha256: "42093549751b582cf0f338a21a3664f52e0a9fbe0d238d3c992005e493607d0e" + "4.3.2": + url: "https://ffmpeg.org/releases/ffmpeg-4.3.2.tar.bz2" + sha256: "ab3a6d6a70358ba0a5f67f37f91f6656b7302b02e98e5b8c846c16763c99913a" + "4.2.1": + url: "https://ffmpeg.org/releases/ffmpeg-4.2.1.tar.bz2" + sha256: "682a9fa3f6864d7f0dbf224f86b129e337bc60286e0d00dffcd710998d521624" diff --git a/recipes/ffmpeg/all/conanfile.py b/recipes/ffmpeg/all/conanfile.py new file mode 100644 index 0000000000000..a5907c7b7ccb3 --- /dev/null +++ b/recipes/ffmpeg/all/conanfile.py @@ -0,0 +1,911 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building +from conan.tools.files import get, rename, rmdir +from conan.tools.scm import Version +from conans import AutoToolsBuildEnvironment, tools +import os +import contextlib +import glob +import shutil +import re + +required_conan_version = ">=1.51.3" + + +class FFMpegConan(ConanFile): + name = "ffmpeg" + url = "https://github.com/conan-io/conan-center-index" + description = "A complete, cross-platform solution to record, convert and stream audio and video" + # https://github.com/FFmpeg/FFmpeg/blob/master/LICENSE.md + license = ("LGPL-2.1-or-later", "GPL-2.0-or-later") + homepage = "https://ffmpeg.org" + topics = ("ffmpeg", "multimedia", "audio", "video", "encoder", "decoder", "encoding", "decoding", + "transcoding", "multiplexer", "demultiplexer", "streaming") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "avdevice": [True, False], + "avcodec": [True, False], + "avformat": [True, False], + "swresample": [True, False], + "swscale": [True, False], + "postproc": [True, False], + "avfilter": [True, False], + "with_asm": [True, False], + "with_zlib": [True, False], + "with_bzip2": [True, False], + "with_lzma": [True, False], + "with_libiconv": [True, False], + "with_freetype": [True, False], + "with_openjpeg": [True, False], + "with_openh264": [True, False], + "with_opus": [True, False], + "with_vorbis": [True, False], + "with_zeromq": [True, False], + "with_sdl": [True, False], + "with_libx264": [True, False], + "with_libx265": [True, False], + "with_libvpx": [True, False], + "with_libmp3lame": [True, False], + "with_libfdk_aac": [True, False], + "with_libwebp": [True, False], + "with_ssl": [False, "openssl", "securetransport"], + "with_libalsa": [True, False], + "with_pulse": [True, False], + "with_vaapi": [True, False], + "with_vdpau": [True, False], + "with_vulkan": [True, False], + "with_xcb": [True, False], + "with_appkit": [True, False], + "with_avfoundation": [True, False], + "with_coreimage": [True, False], + "with_audiotoolbox": [True, False], + "with_videotoolbox": [True, False], + "with_programs": [True, False], + "disable_everything": [True, False], + "disable_all_encoders": [True, False], + "disable_encoders": "ANY", + "enable_encoders": "ANY", + "disable_all_decoders": [True, False], + "disable_decoders": "ANY", + "enable_decoders": "ANY", + "disable_all_hardware_accelerators": [True, False], + "disable_hardware_accelerators": "ANY", + "enable_hardware_accelerators": "ANY", + "disable_all_muxers": [True, False], + "disable_muxers": "ANY", + "enable_muxers": "ANY", + "disable_all_demuxers": [True, False], + "disable_demuxers": "ANY", + "enable_demuxers": "ANY", + "disable_all_parsers": [True, False], + "disable_parsers": "ANY", + "enable_parsers": "ANY", + "disable_all_bitstream_filters": [True, False], + "disable_bitstream_filters": "ANY", + "enable_bitstream_filters": "ANY", + "disable_all_protocols": [True, False], + "disable_protocols": "ANY", + "enable_protocols": "ANY", + "disable_all_devices": [True, False], + "disable_all_input_devices": [True, False], + "disable_input_devices": "ANY", + "enable_input_devices": "ANY", + "disable_all_output_devices": [True, False], + "disable_output_devices": "ANY", + "enable_output_devices": "ANY", + "disable_all_filters": [True, False], + "disable_filters": "ANY", + "enable_filters": "ANY", + } + default_options = { + "shared": False, + "fPIC": True, + "avdevice": True, + "avcodec": True, + "avformat": True, + "swresample": True, + "swscale": True, + "postproc": True, + "avfilter": True, + "with_asm": True, + "with_zlib": True, + "with_bzip2": True, + "with_lzma": True, + "with_libiconv": True, + "with_freetype": True, + "with_openjpeg": True, + "with_openh264": True, + "with_opus": True, + "with_vorbis": True, + "with_zeromq": False, + "with_sdl": False, + "with_libx264": True, + "with_libx265": True, + "with_libvpx": True, + "with_libmp3lame": True, + "with_libfdk_aac": True, + "with_libwebp": True, + "with_ssl": "openssl", + "with_libalsa": True, + "with_pulse": True, + "with_vaapi": True, + "with_vdpau": True, + "with_vulkan": True, + "with_xcb": True, + "with_appkit": True, + "with_avfoundation": True, + "with_coreimage": True, + "with_audiotoolbox": True, + "with_videotoolbox": True, + "with_programs": True, + "disable_everything": False, + "disable_all_encoders": False, + "disable_encoders": None, + "enable_encoders": None, + "disable_all_decoders": False, + "disable_decoders": None, + "enable_decoders": None, + "disable_all_hardware_accelerators": False, + "disable_hardware_accelerators": None, + "enable_hardware_accelerators": None, + "disable_all_muxers": False, + "disable_muxers": None, + "enable_muxers": None, + "disable_all_demuxers": False, + "disable_demuxers": None, + "enable_demuxers": None, + "disable_all_parsers": False, + "disable_parsers": None, + "enable_parsers": None, + "disable_all_bitstream_filters": False, + "disable_bitstream_filters": None, + "enable_bitstream_filters": None, + "disable_all_protocols": False, + "disable_protocols": None, + "enable_protocols": None, + "disable_all_devices": False, + "disable_all_input_devices": False, + "disable_input_devices": None, + "enable_input_devices": None, + "disable_all_output_devices": False, + "disable_output_devices": None, + "enable_output_devices": None, + "disable_all_filters": False, + "disable_filters": None, + "enable_filters": None, + } + + generators = "pkg_config" + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _dependencies(self): + return { + "avformat": ["avcodec"], + "avdevice": ["avcodec", "avformat"], + "avfilter": ["avformat"], + "with_bzip2": ["avformat"], + "with_ssl": ["avformat"], + "with_zlib": ["avcodec"], + "with_lzma": ["avcodec"], + "with_libiconv": ["avcodec"], + "with_openjpeg": ["avcodec"], + "with_openh264": ["avcodec"], + "with_vorbis": ["avcodec"], + "with_opus": ["avcodec"], + "with_libx264": ["avcodec"], + "with_libx265": ["avcodec"], + "with_libvpx": ["avcodec"], + "with_libmp3lame": ["avcodec"], + "with_libfdk_aac": ["avcodec"], + "with_libwebp": ["avcodec"], + "with_freetype": ["avfilter"], + "with_zeromq": ["avfilter", "avformat"], + "with_libalsa": ["avdevice"], + "with_xcb": ["avdevice"], + "with_pulse": ["avdevice"], + "with_sdl": ["with_programs"], + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if not self.settings.os in ["Linux", "FreeBSD"]: + del self.options.with_vaapi + del self.options.with_vdpau + del self.options.with_vulkan + del self.options.with_xcb + del self.options.with_libalsa + del self.options.with_pulse + if self.settings.os != "Macos": + del self.options.with_appkit + if self.settings.os not in ["Macos", "iOS", "tvOS"]: + del self.options.with_coreimage + del self.options.with_audiotoolbox + del self.options.with_videotoolbox + if not is_apple_os(self): + del self.options.with_avfoundation + if not self._version_supports_vulkan(): + del self.options.with_vulkan + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + if self.options.with_zlib: + self.requires("zlib/1.2.13") + if self.options.with_bzip2: + self.requires("bzip2/1.0.8") + if self.options.with_lzma: + self.requires("xz_utils/5.2.5") + if self.options.with_libiconv: + self.requires("libiconv/1.17") + if self.options.with_freetype: + self.requires("freetype/2.12.1") + if self.options.with_openjpeg: + self.requires("openjpeg/2.5.0") + if self.options.with_openh264: + self.requires("openh264/2.1.1") + if self.options.with_vorbis: + self.requires("vorbis/1.3.7") + if self.options.with_opus: + self.requires("opus/1.3.1") + if self.options.with_zeromq: + self.requires("zeromq/4.3.4") + if self.options.with_sdl: + self.requires("sdl/2.24.1") + if self.options.with_libx264: + self.requires("libx264/cci.20220602") + if self.options.with_libx265: + self.requires("libx265/3.4") + if self.options.with_libvpx: + self.requires("libvpx/1.11.0") + if self.options.with_libmp3lame: + self.requires("libmp3lame/3.100") + if self.options.with_libfdk_aac: + self.requires("libfdk_aac/2.0.2") + if self.options.with_libwebp: + self.requires("libwebp/1.2.4") + if self.options.with_ssl == "openssl": + self.requires("openssl/1.1.1s") + if self.options.get_safe("with_libalsa"): + self.requires("libalsa/1.2.7.2") + if self.options.get_safe("with_xcb") or self.options.get_safe("with_vaapi"): + self.requires("xorg/system") + if self.options.get_safe("with_pulse"): + self.requires("pulseaudio/14.2") + if self.options.get_safe("with_vaapi"): + self.requires("vaapi/system") + if self.options.get_safe("with_vdpau"): + self.requires("vdpau/system") + if self._version_supports_vulkan() and self.options.get_safe("with_vulkan"): + self.requires("vulkan-loader/1.3.231.1") + + def validate(self): + if self.options.with_ssl == "securetransport" and not is_apple_os(self): + raise ConanInvalidConfiguration( + "securetransport is only available on Apple") + + for dependency, features in self._dependencies.items(): + if not self.options.get_safe(dependency): + continue + used = False + for feature in features: + used = used or self.options.get_safe(feature) + if not used: + raise ConanInvalidConfiguration("FFmpeg '{}' option requires '{}' option to be enabled".format( + dependency, "' or '".join(features))) + + def build_requirements(self): + if self.settings.arch in ("x86", "x86_64"): + self.build_requires("yasm/1.3.0") + self.build_requires("pkgconf/1.9.3") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @property + def _target_arch(self): + triplet = tools.get_gnu_triplet( + "Macos" if is_apple_os(self) else str(self.settings.os), + str(self.settings.arch), + str(self.settings.compiler) if self.settings.os == "Windows" else None, + ) + target_arch = triplet.split("-")[0] + return target_arch + + @property + def _target_os(self): + if self._is_msvc: + return "win32" + else: + triplet = tools.get_gnu_triplet( + "Macos" if is_apple_os(self) else str(self.settings.os), + str(self.settings.arch), + str(self.settings.compiler) if self.settings.os == "Windows" else None, + ) + target_os = triplet.split("-")[2] + if target_os == "gnueabihf": + target_os = "gnu" # could also be "linux" + return target_os + + def _patch_sources(self): + if self._is_msvc and self.options.with_libx264 and not self.options["libx264"].shared: + # suppress MSVC linker warnings: https://trac.ffmpeg.org/ticket/7396 + # warning LNK4049: locally defined symbol x264_levels imported + # warning LNK4049: locally defined symbol x264_bit_depth imported + tools.replace_in_file(os.path.join(self._source_subfolder, "libavcodec", "libx264.c"), + "#define X264_API_IMPORTS 1", "") + if self.options.with_ssl == "openssl": + # https://trac.ffmpeg.org/ticket/5675 + openssl_libraries = " ".join( + ["-l%s" % lib for lib in self.deps_cpp_info["openssl"].libs]) + tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), + "check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||", + "check_lib openssl openssl/ssl.h OPENSSL_init_ssl %s || " % openssl_libraries) + + @contextlib.contextmanager + def _build_context(self): + with tools.environment_append({"PKG_CONFIG_PATH": tools.unix_path(self.build_folder)}): + if self._is_msvc: + with tools.vcvars(self): + yield + else: + yield + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment( + self, win_bash=tools.os_info.is_windows) + self._autotools.libs = [] + + def opt_enable_disable( + what, v): return "--{}-{}".format("enable" if v else "disable", what) + + def opt_append_disable_if_set(args, what, v): + if v: + args.append("--disable-{}".format(what)) + + args = [ + "--pkg-config-flags=--static", + "--disable-doc", + opt_enable_disable("cross-compile", cross_building(self)), + opt_enable_disable("asm", self.options.with_asm), + # Libraries + opt_enable_disable("shared", self.options.shared), + opt_enable_disable("static", not self.options.shared), + opt_enable_disable("pic", self.options.get_safe("fPIC", True)), + # Components + opt_enable_disable("avdevice", self.options.avdevice), + opt_enable_disable("avcodec", self.options.avcodec), + opt_enable_disable("avformat", self.options.avformat), + opt_enable_disable("swresample", self.options.swresample), + opt_enable_disable("swscale", self.options.swscale), + opt_enable_disable("postproc", self.options.postproc), + opt_enable_disable("avfilter", self.options.avfilter), + + # Dependencies + opt_enable_disable("bzlib", self.options.with_bzip2), + opt_enable_disable("zlib", self.options.with_zlib), + opt_enable_disable("lzma", self.options.with_lzma), + opt_enable_disable("iconv", self.options.with_libiconv), + opt_enable_disable("libopenjpeg", self.options.with_openjpeg), + opt_enable_disable("libopenh264", self.options.with_openh264), + opt_enable_disable("libvorbis", self.options.with_vorbis), + opt_enable_disable("libopus", self.options.with_opus), + opt_enable_disable("libzmq", self.options.with_zeromq), + opt_enable_disable("sdl2", self.options.with_sdl), + opt_enable_disable("libx264", self.options.with_libx264), + opt_enable_disable("libx265", self.options.with_libx265), + opt_enable_disable("libvpx", self.options.with_libvpx), + opt_enable_disable("libmp3lame", self.options.with_libmp3lame), + opt_enable_disable("libfdk-aac", self.options.with_libfdk_aac), + opt_enable_disable("libwebp", self.options.with_libwebp), + opt_enable_disable("openssl", self.options.with_ssl == "openssl"), + opt_enable_disable("alsa", self.options.get_safe("with_libalsa")), + opt_enable_disable( + "libpulse", self.options.get_safe("with_pulse")), + opt_enable_disable("vaapi", self.options.get_safe("with_vaapi")), + opt_enable_disable("vdpau", self.options.get_safe("with_vdpau")), + opt_enable_disable("libxcb", self.options.get_safe("with_xcb")), + opt_enable_disable( + "libxcb-shm", self.options.get_safe("with_xcb")), + opt_enable_disable( + "libxcb-shape", self.options.get_safe("with_xcb")), + opt_enable_disable( + "libxcb-xfixes", self.options.get_safe("with_xcb")), + opt_enable_disable("appkit", self.options.get_safe("with_appkit")), + opt_enable_disable( + "avfoundation", self.options.get_safe("with_avfoundation")), + opt_enable_disable( + "coreimage", self.options.get_safe("with_coreimage")), + opt_enable_disable( + "audiotoolbox", self.options.get_safe("with_audiotoolbox")), + opt_enable_disable( + "videotoolbox", self.options.get_safe("with_videotoolbox")), + opt_enable_disable("securetransport", + self.options.with_ssl == "securetransport"), + "--disable-cuda", # FIXME: CUDA support + "--disable-cuvid", # FIXME: CUVID support + # Licenses + opt_enable_disable("nonfree", self.options.with_libfdk_aac or (self.options.with_ssl and ( + self.options.with_libx264 or self.options.with_libx265 or self.options.postproc))), + opt_enable_disable( + "gpl", self.options.with_libx264 or self.options.with_libx265 or self.options.postproc) + ] + + # Individual Component Options + opt_append_disable_if_set(args, "everything", self.options.disable_everything) + opt_append_disable_if_set(args, "encoders", self.options.disable_all_encoders) + opt_append_disable_if_set(args, "decoders", self.options.disable_all_decoders) + opt_append_disable_if_set(args, "hwaccels", self.options.disable_all_hardware_accelerators) + opt_append_disable_if_set(args, "muxers", self.options.disable_all_muxers) + opt_append_disable_if_set(args, "demuxers", self.options.disable_all_demuxers) + opt_append_disable_if_set(args, "parsers", self.options.disable_all_parsers) + opt_append_disable_if_set(args, "bsfs", self.options.disable_all_bitstream_filters) + opt_append_disable_if_set(args, "protocols", self.options.disable_all_protocols) + opt_append_disable_if_set(args, "devices", self.options.disable_all_devices) + opt_append_disable_if_set(args, "indevs", self.options.disable_all_input_devices) + opt_append_disable_if_set(args, "outdevs", self.options.disable_all_output_devices) + opt_append_disable_if_set(args, "filters", self.options.disable_all_filters) + + args.extend(self._split_and_format_options_string( + "enable-encoder", self.options.enable_encoders)) + args.extend(self._split_and_format_options_string( + "disable-encoder", self.options.disable_encoders)) + args.extend(self._split_and_format_options_string( + "enable-decoder", self.options.enable_decoders)) + args.extend(self._split_and_format_options_string( + "disable-decoder", self.options.disable_decoders)) + args.extend(self._split_and_format_options_string( + "enable-hwaccel", self.options.enable_hardware_accelerators)) + args.extend(self._split_and_format_options_string( + "disable-hwaccel", self.options.disable_hardware_accelerators)) + args.extend(self._split_and_format_options_string( + "enable-muxer", self.options.enable_muxers)) + args.extend(self._split_and_format_options_string( + "disable-muxer", self.options.disable_muxers)) + args.extend(self._split_and_format_options_string( + "enable-demuxer", self.options.enable_demuxers)) + args.extend(self._split_and_format_options_string( + "disable-demuxer", self.options.disable_demuxers)) + args.extend(self._split_and_format_options_string( + "enable-parser", self.options.enable_parsers)) + args.extend(self._split_and_format_options_string( + "disable-parser", self.options.disable_parsers)) + args.extend(self._split_and_format_options_string( + "enable-bsf", self.options.enable_bitstream_filters)) + args.extend(self._split_and_format_options_string( + "disable-bsf", self.options.disable_bitstream_filters)) + args.extend(self._split_and_format_options_string( + "enable-protocol", self.options.enable_protocols)) + args.extend(self._split_and_format_options_string( + "disable-protocol", self.options.disable_protocols)) + args.extend(self._split_and_format_options_string( + "enable-indev", self.options.enable_input_devices)) + args.extend(self._split_and_format_options_string( + "disable-indev", self.options.disable_input_devices)) + args.extend(self._split_and_format_options_string( + "enable-outdev", self.options.enable_output_devices)) + args.extend(self._split_and_format_options_string( + "disable-outdev", self.options.disable_output_devices)) + args.extend(self._split_and_format_options_string( + "enable-filter", self.options.enable_filters)) + args.extend(self._split_and_format_options_string( + "disable-filter", self.options.disable_filters)) + + if self._version_supports_vulkan(): + args.append(opt_enable_disable( + "vulkan", self.options.get_safe("with_vulkan"))) + if is_apple_os(self): + # relocatable shared libs + args.append("--install-name-dir=@rpath") + args.append("--arch={}".format(self._target_arch)) + if self.settings.build_type == "Debug": + args.extend([ + "--disable-optimizations", + "--disable-mmx", + "--disable-stripping", + "--enable-debug", + ]) + if not self.options.with_programs: + args.append("--disable-programs") + # since ffmpeg"s build system ignores CC and CXX + if tools.get_env("AS"): + args.append("--as={}".format(tools.get_env("AS"))) + if tools.get_env("CC"): + args.append("--cc={}".format(tools.get_env("CC"))) + if tools.get_env("CXX"): + args.append("--cxx={}".format(tools.get_env("CXX"))) + extra_cflags = [] + extra_ldflags = [] + if is_apple_os(self) and self.settings.os.version: + extra_cflags.append(tools.apple_deployment_target_flag( + self.settings.os, self.settings.os.version)) + extra_ldflags.append(tools.apple_deployment_target_flag( + self.settings.os, self.settings.os.version)) + if self._is_msvc: + args.append("--pkg-config={}".format(tools.get_env("PKG_CONFIG"))) + args.append("--toolchain=msvc") + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) <= "12": + # Visual Studio 2013 (and earlier) doesn't support "inline" keyword for C (only for C++) + self._autotools.defines.append("inline=__inline") + if cross_building(self): + if self._target_os == "emscripten": + args.append("--target-os=none") + else: + args.append("--target-os={}".format(self._target_os)) + + if is_apple_os(self): + if self.options.with_audiotoolbox: + args.append("--disable-outdev=audiotoolbox") + + xcrun = tools.XCRun(self.settings) + apple_arch = tools.to_apple_arch(str(self.settings.arch)) + extra_cflags.extend( + ["-arch {}".format(apple_arch), "-isysroot {}".format(xcrun.sdk_path)]) + extra_ldflags.extend( + ["-arch {}".format(apple_arch), "-isysroot {}".format(xcrun.sdk_path)]) + + args.append("--extra-cflags={}".format(" ".join(extra_cflags))) + args.append("--extra-ldflags={}".format(" ".join(extra_ldflags))) + + self._autotools.configure( + args=args, configure_dir=self._source_subfolder, build=False, host=False, target=False) + return self._autotools + + def _split_and_format_options_string(self, flag_name, options_list): + if not options_list: + return [] + + def _format_options_list_item(flag_name, options_item): + return "--{}={}".format(flag_name, options_item) + + def _split_options_string(options_string): + return list(filter(None, "".join(options_string.split()).split(","))) + + options_string = str(options_list) + return [_format_options_list_item(flag_name, item) for item in _split_options_string(options_string)] + + def build(self): + self._patch_sources() + tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), + "echo libx264.lib", "echo x264.lib") + if self.options.with_libx264: + shutil.copy("x264.pc", "libx264.pc") + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + if self._is_msvc: + if self.options.shared: + # ffmpeg created `.lib` files in the `/bin` folder + for fn in os.listdir(os.path.join(self.package_folder, "bin")): + if fn.endswith(".lib"): + rename(self, os.path.join(self.package_folder, "bin", fn), + os.path.join(self.package_folder, "lib", fn)) + tools.remove_files_by_mask(os.path.join( + self.package_folder, "lib"), "*.def") + else: + # ffmpeg produces `.a` files that are actually `.lib` files + with tools.chdir(os.path.join(self.package_folder, "lib")): + for lib in glob.glob("*.a"): + rename(self, lib, lib[3:-2] + ".lib") + + def _read_component_version(self, component_name): + version_file_name = os.path.join(self.package_folder, + "include", "lib%s" % component_name, + "version.h") + version_file = open(version_file_name, "r") + pattern = "define LIB%s_VERSION_(MAJOR|MINOR|MICRO)[ \t]+(\\d+)" % ( + component_name.upper()) + version = dict() + for line in version_file: + match = re.search(pattern, line) + if match: + version[match[1]] = match[2] + if "MAJOR" in version and "MINOR" in version and "MICRO" in version: + return f"{version['MAJOR']}.{version['MINOR']}.{version['MICRO']}" + return None + + def _set_component_version(self, component_name): + version = self._read_component_version(component_name) + if version is not None: + self.cpp_info.components[component_name].version = version + else: + self.output.warn("cannot determine version of " + "lib%s packaged with ffmpeg!" % component_name) + + def package_info(self): + if self.options.with_programs: + if self.options.with_sdl: + self.cpp_info.components["programs"].requires = [ + "sdl::libsdl2"] + + if self.options.avdevice: + self.cpp_info.components["avdevice"].set_property( + "pkg_config_name", "libavdevice") + self.cpp_info.components["avdevice"].libs = ["avdevice"] + self.cpp_info.components["avdevice"].requires = ["avutil"] + if self.options.avfilter: + self.cpp_info.components["avdevice"].requires.append( + "avfilter") + if self.options.swscale: + self.cpp_info.components["avdevice"].requires.append("swscale") + if self.options.avformat: + self.cpp_info.components["avdevice"].requires.append( + "avformat") + if self.options.avcodec: + self.cpp_info.components["avdevice"].requires.append("avcodec") + if self.options.swresample: + self.cpp_info.components["avdevice"].requires.append( + "swresample") + if self.options.postproc: + self.cpp_info.components["avdevice"].requires.append( + "postproc") + self._set_component_version("avdevice") + + if self.options.avfilter: + self.cpp_info.components["avfilter"].set_property( + "pkg_config_name", "libavfilter") + self.cpp_info.components["avfilter"].libs = ["avfilter"] + self.cpp_info.components["avfilter"].requires = ["avutil"] + if self.options.swscale: + self.cpp_info.components["avfilter"].requires.append("swscale") + if self.options.avformat: + self.cpp_info.components["avfilter"].requires.append( + "avformat") + if self.options.avcodec: + self.cpp_info.components["avfilter"].requires.append("avcodec") + if self.options.swresample: + self.cpp_info.components["avfilter"].requires.append( + "swresample") + if self.options.postproc: + self.cpp_info.components["avfilter"].requires.append( + "postproc") + self._set_component_version("avfilter") + + if self.options.avformat: + self.cpp_info.components["avformat"].set_property( + "pkg_config_name", "libavformat") + self.cpp_info.components["avformat"].libs = ["avformat"] + self.cpp_info.components["avformat"].requires = ["avutil"] + if self.options.avcodec: + self.cpp_info.components["avformat"].requires.append("avcodec") + if self.options.swresample: + self.cpp_info.components["avformat"].requires.append( + "swresample") + self._set_component_version("avformat") + + if self.options.avcodec: + self.cpp_info.components["avcodec"].set_property( + "pkg_config_name", "libavcodec") + self.cpp_info.components["avcodec"].libs = ["avcodec"] + self.cpp_info.components["avcodec"].requires = ["avutil"] + if self.options.swresample: + self.cpp_info.components["avcodec"].requires.append( + "swresample") + self._set_component_version("avcodec") + + if self.options.swscale: + self.cpp_info.components["swscale"].set_property( + "pkg_config_name", "libswscale") + self.cpp_info.components["swscale"].libs = ["swscale"] + self.cpp_info.components["swscale"].requires = ["avutil"] + self._set_component_version("swscale") + + if self.options.swresample: + self.cpp_info.components["swresample"].set_property( + "pkg_config_name", "libswresample") + self.cpp_info.components["swresample"].libs = ["swresample"] + self.cpp_info.components["swresample"].requires = ["avutil"] + self._set_component_version("swresample") + + if self.options.postproc: + self.cpp_info.components["postproc"].set_property( + "pkg_config_name", "libpostproc") + self.cpp_info.components["postproc"].libs = ["postproc"] + self.cpp_info.components["postproc"].requires = ["avutil"] + self._set_component_version("postproc") + + self.cpp_info.components["avutil"].set_property( + "pkg_config_name", "libavutil") + self.cpp_info.components["avutil"].libs = ["avutil"] + self._set_component_version("avutil") + + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.components["avutil"].system_libs = [ + "pthread", "m", "dl"] + if self.options.swresample: + self.cpp_info.components["swresample"].system_libs = ["m"] + if self.options.swscale: + self.cpp_info.components["swscale"].system_libs = ["m"] + if self.options.postproc: + self.cpp_info.components["postproc"].system_libs = ["m"] + if self.options.get_safe("fPIC"): + if self.settings.compiler in ("gcc", "clang"): + # https://trac.ffmpeg.org/ticket/1713 + # https://ffmpeg.org/platform.html#Advanced-linking-configuration + # https://ffmpeg.org/pipermail/libav-user/2014-December/007719.html + self.cpp_info.components["avcodec"].exelinkflags.append( + "-Wl,-Bsymbolic") + self.cpp_info.components["avcodec"].sharedlinkflags.append( + "-Wl,-Bsymbolic") + if self.options.avformat: + self.cpp_info.components["avformat"].system_libs = ["m"] + if self.options.avfilter: + self.cpp_info.components["avfilter"].system_libs = [ + "m", "pthread"] + if self.options.avdevice: + self.cpp_info.components["avdevice"].system_libs = ["m"] + elif self.settings.os == "Windows": + if self.options.avcodec: + self.cpp_info.components["avcodec"].system_libs = [ + "Mfplat", "Mfuuid", "strmiids"] + if self.options.avdevice: + self.cpp_info.components["avdevice"].system_libs = [ + "ole32", "psapi", "strmiids", "uuid", "oleaut32", "shlwapi", "gdi32", "vfw32"] + self.cpp_info.components["avutil"].system_libs = [ + "user32", "bcrypt"] + self.cpp_info.components["avformat"].system_libs = ["secur32"] + elif is_apple_os(self): + if self.options.avdevice: + self.cpp_info.components["avdevice"].frameworks = [ + "CoreFoundation", "Foundation", "CoreGraphics"] + if self.options.avfilter: + self.cpp_info.components["avfilter"].frameworks = [ + "CoreGraphics"] + if self.options.avcodec: + self.cpp_info.components["avcodec"].frameworks = [ + "CoreFoundation", "CoreVideo", "CoreMedia"] + if self.settings.os == "Macos": + if self.options.avdevice: + self.cpp_info.components["avdevice"].frameworks.append( + "OpenGL") + if self.options.avfilter: + self.cpp_info.components["avfilter"].frameworks.append( + "OpenGL") + + if self.options.avdevice: + if self.options.get_safe("with_libalsa"): + self.cpp_info.components["avdevice"].requires.append( + "libalsa::libalsa") + if self.options.get_safe("with_xcb"): + self.cpp_info.components["avdevice"].requires.append( + "xorg::xcb") + if self.options.get_safe("with_pulse"): + self.cpp_info.components["avdevice"].requires.append( + "pulseaudio::pulseaudio") + if self.options.get_safe("with_appkit"): + self.cpp_info.components["avdevice"].frameworks.append( + "AppKit") + if self.options.get_safe("with_avfoundation"): + self.cpp_info.components["avdevice"].frameworks.append( + "AVFoundation") + if self.options.get_safe("with_audiotoolbox"): + self.cpp_info.components["avdevice"].frameworks.append( + "CoreAudio") + + if self.options.avcodec: + if self.options.with_zlib: + self.cpp_info.components["avcodec"].requires.append( + "zlib::zlib") + if self.options.with_lzma: + self.cpp_info.components["avcodec"].requires.append( + "xz_utils::xz_utils") + if self.options.with_libiconv: + self.cpp_info.components["avcodec"].requires.append( + "libiconv::libiconv") + if self.options.with_openjpeg: + self.cpp_info.components["avcodec"].requires.append( + "openjpeg::openjpeg") + if self.options.with_openh264: + self.cpp_info.components["avcodec"].requires.append( + "openh264::openh264") + if self.options.with_vorbis: + self.cpp_info.components["avcodec"].requires.append( + "vorbis::vorbis") + if self.options.with_opus: + self.cpp_info.components["avcodec"].requires.append( + "opus::opus") + if self.options.with_libx264: + self.cpp_info.components["avcodec"].requires.append( + "libx264::libx264") + if self.options.with_libx265: + self.cpp_info.components["avcodec"].requires.append( + "libx265::libx265") + if self.options.with_libvpx: + self.cpp_info.components["avcodec"].requires.append( + "libvpx::libvpx") + if self.options.with_libmp3lame: + self.cpp_info.components["avcodec"].requires.append( + "libmp3lame::libmp3lame") + if self.options.with_libfdk_aac: + self.cpp_info.components["avcodec"].requires.append( + "libfdk_aac::libfdk_aac") + if self.options.with_libwebp: + self.cpp_info.components["avcodec"].requires.append( + "libwebp::libwebp") + if self.options.get_safe("with_audiotoolbox"): + self.cpp_info.components["avcodec"].frameworks.append( + "AudioToolbox") + if self.options.get_safe("with_videotoolbox"): + self.cpp_info.components["avcodec"].frameworks.append( + "VideoToolbox") + + if self.options.avformat: + if self.options.with_bzip2: + self.cpp_info.components["avformat"].requires.append( + "bzip2::bzip2") + if self.options.with_zeromq: + self.cpp_info.components["avformat"].requires.append( + "zeromq::libzmq") + if self.options.with_ssl == "openssl": + self.cpp_info.components["avformat"].requires.append( + "openssl::ssl") + elif self.options.with_ssl == "securetransport": + self.cpp_info.components["avformat"].frameworks.append( + "Security") + + if self.options.avfilter: + if self.options.with_freetype: + self.cpp_info.components["avfilter"].requires.append( + "freetype::freetype") + if self.options.with_zeromq: + self.cpp_info.components["avfilter"].requires.append( + "zeromq::libzmq") + if self.options.get_safe("with_appkit"): + self.cpp_info.components["avfilter"].frameworks.append( + "AppKit") + if self.options.get_safe("with_coreimage"): + self.cpp_info.components["avfilter"].frameworks.append( + "CoreImage") + if Version(self.version) >= "5.0" and is_apple_os(self): + self.cpp_info.components["avfilter"].frameworks.append("Metal") + + if self.options.get_safe("with_vaapi"): + self.cpp_info.components["avutil"].requires.extend( + ["vaapi::vaapi", "xorg::x11"]) + + if self.options.get_safe("with_vdpau"): + self.cpp_info.components["avutil"].requires.append("vdpau::vdpau") + + if self._version_supports_vulkan() and self.options.get_safe("with_vulkan"): + self.cpp_info.components["avutil"].requires.append( + "vulkan-loader::vulkan-loader") + + def _version_supports_vulkan(self): + return Version(self.version) >= "4.3.0" diff --git a/recipes/ffmpeg/all/test_package/CMakeLists.txt b/recipes/ffmpeg/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d2e36b81236a9 --- /dev/null +++ b/recipes/ffmpeg/all/test_package/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ffmpeg REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ffmpeg::avutil) +if (TARGET ffmpeg::avdevice) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVDEVICE) + target_link_libraries(${PROJECT_NAME} ffmpeg::avdevice) +endif () +if (TARGET ffmpeg::avfilter) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVFILTER) + target_link_libraries(${PROJECT_NAME} ffmpeg::avfilter) +endif () +if (TARGET ffmpeg::avformat) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVFORMAT) + target_link_libraries(${PROJECT_NAME} ffmpeg::avformat) +endif () +if (TARGET ffmpeg::avcodec) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_AVCODEC) + target_link_libraries(${PROJECT_NAME} ffmpeg::avcodec) +endif () +if (TARGET ffmpeg::swscale) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_SWSCALE) + target_link_libraries(${PROJECT_NAME} ffmpeg::swscale) +endif () +if (TARGET ffmpeg::swresample) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_SWRESAMPLE) + target_link_libraries(${PROJECT_NAME} ffmpeg::swresample) +endif () +if (TARGET ffmpeg::postproc) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FFMPEG_POSTPROC) + target_link_libraries(${PROJECT_NAME} ffmpeg::postproc) +endif () diff --git a/recipes/ffmpeg/all/test_package/conanfile.py b/recipes/ffmpeg/all/test_package/conanfile.py new file mode 100644 index 0000000000000..c7039d41e93dc --- /dev/null +++ b/recipes/ffmpeg/all/test_package/conanfile.py @@ -0,0 +1,29 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + if self.options["ffmpeg"].with_programs: + self.run("ffmpeg --help", run_environment=True) + + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ffmpeg/all/test_package/test_package.c b/recipes/ffmpeg/all/test_package/test_package.c new file mode 100644 index 0000000000000..a868a90f9d1a1 --- /dev/null +++ b/recipes/ffmpeg/all/test_package/test_package.c @@ -0,0 +1,55 @@ +#ifdef HAVE_FFMPEG_AVCODEC +# include +#endif +#ifdef HAVE_FFMPEG_AVFORMAT +# include +#endif +#ifdef HAVE_FFMPEG_AVFILTER +# include +#endif +#ifdef HAVE_FFMPEG_AVDEVICE +# include +#endif +#ifdef HAVE_FFMPEG_SWRESAMPLE +# include +#endif +#ifdef HAVE_FFMPEG_SWSCALE +# include +#endif +#include + +#include +#include + +int main() +{ + #ifdef HAVE_FFMPEG_AVCODEC + printf("configuration: %s\n", avcodec_configuration()); + printf("avcodec version: %d.%d.%d\n", AV_VERSION_MAJOR(avcodec_version()), AV_VERSION_MINOR(avcodec_version()), AV_VERSION_MICRO(avcodec_version())); + #else + printf("avcodec is disabled!\n"); + #endif + #ifdef HAVE_FFMPEG_AVFILTER + printf("avfilter version: %d.%d.%d\n", AV_VERSION_MAJOR(avfilter_version()), AV_VERSION_MINOR(avfilter_version()), AV_VERSION_MICRO(avfilter_version())); + #else + printf("avfilter is disabled!\n"); + #endif + #ifdef HAVE_FFMPEG_AVDEVICE + avdevice_register_all(); + printf("avdevice version: %d.%d.%d\n", AV_VERSION_MAJOR(avdevice_version()), AV_VERSION_MINOR(avdevice_version()), AV_VERSION_MICRO(avdevice_version())); + #else + printf("avdevice is disabled!\n"); + #endif + #ifdef HAVE_FFMPEG_SWRESAMPLE + printf("swresample version: %d.%d.%d\n", AV_VERSION_MAJOR(swresample_version()), AV_VERSION_MINOR(swresample_version()), AV_VERSION_MICRO(swresample_version())); + #else + printf("swresample is disabled!\n"); + #endif + #ifdef HAVE_FFMPEG_SWSCALE + printf("swscale version: %d.%d.%d\n", AV_VERSION_MAJOR(swscale_version()), AV_VERSION_MINOR(swscale_version()), AV_VERSION_MICRO(swscale_version())); + #else + printf("swscale is disabled!\n"); + #endif + + return EXIT_SUCCESS; +} diff --git a/recipes/ffmpeg/config.yml b/recipes/ffmpeg/config.yml new file mode 100644 index 0000000000000..bd4009285d1b8 --- /dev/null +++ b/recipes/ffmpeg/config.yml @@ -0,0 +1,11 @@ +versions: + "5.0": + folder: "all" + "4.4.3": + folder: "all" + "4.4": + folder: "all" + "4.3.2": + folder: "all" + "4.2.1": + folder: "all" diff --git a/recipes/fft/all/CMakeLists.txt b/recipes/fft/all/CMakeLists.txt index 96f4dbe8c72df..373435ea9437a 100644 --- a/recipes/fft/all/CMakeLists.txt +++ b/recipes/fft/all/CMakeLists.txt @@ -1,23 +1,18 @@ cmake_minimum_required(VERSION 3.2) - project(fft LANGUAGES C) -include(conanbuildinfo.cmake) -conan_basic_setup() - -option(THREADS "use threads") +option(FFT_THREADS "use threads" OFF) -set(SOURCES "fft_build.c") set(HEADERS "fft.h;fft2.h;fft3.h;dct.h;${CMAKE_CURRENT_BINARY_DIR}/fft_export.h") -add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS}) +add_library(${PROJECT_NAME} fft_build.c) set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${HEADERS}" C_VISIBILITY_PRESET hidden) -target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(${PROJECT_NAME} PRIVATE ${FFT_SRC_DIR} ${CMAKE_CURRENT_BINARY_DIR}) -if(THREADS) +if(FFT_THREADS) find_package(Threads REQUIRED) if(WIN32) target_compile_definitions(${PROJECT_NAME} PRIVATE USE_CDFT_WINTHREADS) @@ -28,13 +23,13 @@ if(THREADS) target_compile_definitions(${PROJECT_NAME} PRIVATE USE_FFT2D_PTHREADS) target_compile_definitions(${PROJECT_NAME} PRIVATE USE_FFT3D_PTHREADS) endif() - target_compile_definitions(${PROJECT_NAME} PRIVATE CDFT_THREADS_BEGIN_N ${THREADS_BEGIN_WITH}) - target_compile_definitions(${PROJECT_NAME} PRIVATE CDFT_4THREADS_BEGIN_N ${THREADS_BEGIN_WITH}) - target_compile_definitions(${PROJECT_NAME} PRIVATE FFT2D_THREADS_BEGIN_N ${THREADS_BEGIN_WITH}) - target_compile_definitions(${PROJECT_NAME} PRIVATE FFT2D_MAX_THREADS ${MAX_THREADS}) - target_compile_definitions(${PROJECT_NAME} PRIVATE FFT3D_THREADS_BEGIN_N ${THREADS_BEGIN_WITH}) - target_compile_definitions(${PROJECT_NAME} PRIVATE FFT3D_MAX_THREADS ${MAX_THREADS}) - + target_compile_definitions(${PROJECT_NAME} PRIVATE "CDFT_THREADS_BEGIN_N=${FFT_THREADS_BEGIN_N}") + target_compile_definitions(${PROJECT_NAME} PRIVATE "CDFT_4THREADS_BEGIN_N=${FFT_THREADS_BEGIN_N}") + target_compile_definitions(${PROJECT_NAME} PRIVATE "FFT2D_THREADS_BEGIN_N=${FFT_THREADS_BEGIN_N}") + target_compile_definitions(${PROJECT_NAME} PRIVATE "FFT2D_MAX_THREADS=${FFT_MAX_THREADS}") + target_compile_definitions(${PROJECT_NAME} PRIVATE "FFT3D_THREADS_BEGIN_N=${FFT_THREADS_BEGIN_N}") + target_compile_definitions(${PROJECT_NAME} PRIVATE "FFT3D_MAX_THREADS=${FFT_MAX_THREADS}") + target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads) endif() diff --git a/recipes/fft/all/conanfile.py b/recipes/fft/all/conanfile.py index 63be0f826922c..0c2d7fca71f8c 100644 --- a/recipes/fft/all/conanfile.py +++ b/recipes/fft/all/conanfile.py @@ -1,6 +1,10 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import get, save import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.47.0" class FftConan(ConanFile): @@ -8,80 +12,94 @@ class FftConan(ConanFile): license = "LicenseRef-LICENSE" url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html" - description = "This is a package to calculate Discrete Fourier/Cosine/Sine Transforms of 2,3-dimensional sequences of length 2^N." - topics = ("conan", "fft", "fft2d", "fft3d", "dct", "dst", "dft") - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False], - "threads": [True, False], - "max_threads": "ANY", - "threads_begin_n": "ANY"} - default_options = {"shared": False, - "fPIC": True, - "threads": False, - "max_threads": 4, - "threads_begin_n": 65536} - exports_sources = ["CMakeLists.txt", "fft_build.c", "fft.h", "fft2.h", "fft3.h", "dct.h"] - generators = "cmake", + description = ( + "This is a package to calculate Discrete Fourier/Cosine/Sine " + "Transforms of 2,3-dimensional sequences of length 2^N." + ) + topics = ("fft", "fft2d", "fft3d", "dct", "dst", "dft") - @property - def _build_subfolder(self): - return "_build_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "threads": [True, False], + "max_threads": ["ANY"], + "threads_begin_n": ["ANY"], + } + default_options = { + "shared": False, + "fPIC": True, + "threads": False, + "max_threads": 4, + "threads_begin_n": 65536, + } - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True) + exports_sources = ["CMakeLists.txt", "fft_build.c", "fft.h", "fft2.h", "fft3.h", "dct.h"] def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - + def configure(self): if self.options.shared: del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass if not self.options.threads: del self.options.max_threads del self.options.threads_begin_n - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - + def validate(self): def _is_power_of_two(n): return (n != 0) and (n & (n-1) == 0) - if self.options.threads: - if not self.options.max_threads.value.isdigit(): + if self.info.options.threads: + if not self.info.options.max_threads.isdigit(): raise ConanInvalidConfiguration("max_threads must be an integer") - if not self.options.threads_begin_n.value.isdigit(): + if not self.info.options.threads_begin_n.isdigit(): raise ConanInvalidConfiguration("threads_begin_n must be an integer") - if not _is_power_of_two(int(self.options.max_threads.value)): + if not _is_power_of_two(int(self.info.options.max_threads)): raise ConanInvalidConfiguration("max_threads must be a power of 2") - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["THREADS"] = self.options.threads + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FFT_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["FFT_THREADS"] = self.options.threads if self.options.threads: - cmake.definitions["MAX_THREADS"] = self.options.max_threads - cmake.definitions["THREADS_BEGIN_N"] = self.options.threads_begin_n - cmake.configure(build_folder=self._build_subfolder) - return cmake + tc.variables["FFT_MAX_THREADS"] = self.options.max_threads + tc.variables["FFT_THREADS_BEGIN_N"] = self.options.threads_begin_n + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), """Copyright Copyright(C) 1997,2001 Takuya OOURA (email: ooura@kurims.kyoto-u.ac.jp). - You may use, copy, modify this code for any purpose and + You may use, copy, modify this code for any purpose and without fee. You may distribute this ORIGINAL package.""") - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() def package_info(self): self.cpp_info.libs = ["fft"] if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") if self.options.threads: self.cpp_info.system_libs.append("pthread") - if self.settings.os == "Linux": - self.cpp_info.system_libs.append("m") diff --git a/recipes/fft/all/test_package/CMakeLists.txt b/recipes/fft/all/test_package/CMakeLists.txt index 99d4168340699..a87685a9ccd7a 100644 --- a/recipes/fft/all/test_package/CMakeLists.txt +++ b/recipes/fft/all/test_package/CMakeLists.txt @@ -1,12 +1,10 @@ cmake_minimum_required(VERSION 3.1) project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(fft REQUIRED CONFIG) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE fft::fft) if(MSVC) - add_definitions("-D_CRT_SECURE_NO_WARNINGS=1") + target_compile_definitions(${PROJECT_NAME} PRIVATE "CRT_SECURE_NO_WARNINGS=1") endif() - -add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/fft/all/test_package/conanfile.py b/recipes/fft/all/test_package/conanfile.py index ec9ea3795547b..3a8c6c5442b33 100644 --- a/recipes/fft/all/test_package/conanfile.py +++ b/recipes/fft/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fft/all/test_v1_package/CMakeLists.txt b/recipes/fft/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b02d7f9d31172 --- /dev/null +++ b/recipes/fft/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fft REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE fft::fft) +if(MSVC) + target_compile_definitions(${PROJECT_NAME} PRIVATE "CRT_SECURE_NO_WARNINGS=1") +endif() diff --git a/recipes/fft/all/test_v1_package/conanfile.py b/recipes/fft/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/fft/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fftw/all/CMakeLists.txt b/recipes/fftw/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/fftw/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/fftw/all/conandata.yml b/recipes/fftw/all/conandata.yml index 43968663d69ad..8588823dd80ee 100644 --- a/recipes/fftw/all/conandata.yml +++ b/recipes/fftw/all/conandata.yml @@ -1,18 +1,16 @@ sources: "3.3.9": - url: "http://www.fftw.org/fftw-3.3.9.tar.gz" + url: + [ + "https://www.fftw.org/fftw-3.3.9.tar.gz", + "https://fftw.org/fftw-3.3.9.tar.gz", + ] sha256: "bf2c7ce40b04ae811af714deb512510cc2c17b9ab9d6ddcf49fe4487eea7af3d" "3.3.8": url: "http://www.fftw.org/fftw-3.3.8.tar.gz" sha256: "6113262f6e92c5bd474f2875fa1b01054c4ad5040f6b0da7c03c98821d9ae303" patches: "3.3.9": - - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" - patch_file: "patches/fix-simd.patch" - base_path: "source_subfolder" "3.3.8": - - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" - patch_file: "patches/fix-simd.patch" - base_path: "source_subfolder" diff --git a/recipes/fftw/all/conanfile.py b/recipes/fftw/all/conanfile.py index fd43008ba58e5..6fc7fd577d259 100644 --- a/recipes/fftw/all/conanfile.py +++ b/recipes/fftw/all/conanfile.py @@ -1,8 +1,11 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir import os -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.47.0" + class FFTWConan(ConanFile): name = "fftw" @@ -10,34 +13,31 @@ class FFTWConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.fftw.org/" license = "GPL-2.0" - topics = ("conan", "fftw", "dft", "dct", "dst") - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False], - "precision": ["double", "single", "longdouble"], - "openmp": [True, False], - "threads": [True, False], - "combinedthreads": [True, False], - "simd": ["sse", "sse2", "avx", "avx2", False]} - default_options = {"shared": False, - "fPIC": True, - "precision": "double", - "openmp": False, - "threads": False, - "combinedthreads": False, - "simd": False} - - _cmake = None + topics = ("fftw", "dft", "dct", "dst") - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "precision": ["double", "single", "longdouble"], + "openmp": [True, False], + "threads": [True, False], + "combinedthreads": [True, False], + "simd": ["sse", "sse2", "avx", "avx2", False], + } + default_options = { + "shared": False, + "fPIC": True, + "precision": "double", + "openmp": False, + "threads": False, + "combinedthreads": False, + "simd": False, + } - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -46,50 +46,59 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass if not self.options.threads: del self.options.combinedthreads + + def validate(self): if self.settings.os == "Windows" and self.options.shared: if self.options.openmp: raise ConanInvalidConfiguration("Shared fftw with openmp can't be built on Windows") if self.options.threads and not self.options.combinedthreads: raise ConanInvalidConfiguration("Shared fftw with threads and not combinedthreads can't be built on Windows") + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["ENABLE_OPENMP"] = self.options.openmp - self._cmake.definitions["ENABLE_THREADS"] = self.options.threads - self._cmake.definitions["WITH_COMBINED_THREADS"] = self.options.get_safe("combinedthreads", False) - self._cmake.definitions["ENABLE_FLOAT"] = self.options.precision == "single" - self._cmake.definitions["ENABLE_LONG_DOUBLE"] = self.options.precision == "longdouble" - self._cmake.definitions["ENABLE_SSE"] = self.options.simd == "sse" - self._cmake.definitions["ENABLE_SSE2"] = self.options.simd == "sse2" - self._cmake.definitions["ENABLE_AVX"] = self.options.simd == "avx" - self._cmake.definitions["ENABLE_AVX2"] = self.options.simd == "avx2" - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTS"] = False + tc.variables["ENABLE_OPENMP"] = self.options.openmp + tc.variables["ENABLE_THREADS"] = self.options.threads + tc.variables["WITH_COMBINED_THREADS"] = self.options.get_safe("combinedthreads", False) + tc.variables["ENABLE_FLOAT"] = self.options.precision == "single" + tc.variables["ENABLE_LONG_DOUBLE"] = self.options.precision == "longdouble" + tc.variables["ENABLE_SSE"] = self.options.simd == "sse" + tc.variables["ENABLE_SSE2"] = self.options.simd == "sse2" + tc.variables["ENABLE_AVX"] = self.options.simd == "avx" + tc.variables["ENABLE_AVX2"] = self.options.simd == "avx2" + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYRIGHT", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYRIGHT", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): prec_suffix = self._prec_suffix[str(self.options.precision)] @@ -98,24 +107,32 @@ def package_info(self): cmake_target_name = "fftw3" + prec_suffix pkgconfig_name = "fftw3" + prec_suffix lib_name = "fftw3" + prec_suffix - self.cpp_info.filenames["cmake_find_package"] = cmake_config_name - self.cpp_info.filenames["cmake_find_package_multi"] = cmake_config_name - self.cpp_info.names["cmake_find_package"] = cmake_namespace - self.cpp_info.names["cmake_find_package_multi"] = cmake_namespace - self.cpp_info.names["pkg_config"] = pkgconfig_name - self.cpp_info.components["fftwlib"].names["cmake_find_package"] = cmake_target_name - self.cpp_info.components["fftwlib"].names["cmake_find_package_multi"] = cmake_target_name - self.cpp_info.components["fftwlib"].names["pkg_config"] = pkgconfig_name + + self.cpp_info.set_property("cmake_file_name", cmake_config_name) + self.cpp_info.set_property("cmake_target_name", "{}::{}".format(cmake_namespace, cmake_target_name)) + self.cpp_info.set_property("pkg_config_name", pkgconfig_name) + + # TODO: back to global scope in conan v2 once cmake_find_package_* & pkg_config generators removed if self.options.openmp: self.cpp_info.components["fftwlib"].libs.append(lib_name + "_omp") if self.options.threads and not self.options.combinedthreads: self.cpp_info.components["fftwlib"].libs.append(lib_name + "_threads") self.cpp_info.components["fftwlib"].libs.append(lib_name) - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["fftwlib"].system_libs.append("m") if self.options.threads: self.cpp_info.components["fftwlib"].system_libs.append("pthread") + # TODO: to remove in conan v2 once cmake_find_package_* & pkg_config generators removed + self.cpp_info.filenames["cmake_find_package"] = cmake_config_name + self.cpp_info.filenames["cmake_find_package_multi"] = cmake_config_name + self.cpp_info.names["cmake_find_package"] = cmake_namespace + self.cpp_info.names["cmake_find_package_multi"] = cmake_namespace + self.cpp_info.components["fftwlib"].names["cmake_find_package"] = cmake_target_name + self.cpp_info.components["fftwlib"].names["cmake_find_package_multi"] = cmake_target_name + self.cpp_info.components["fftwlib"].set_property("cmake_target_name", "{}::{}".format(cmake_namespace, cmake_target_name)) + self.cpp_info.components["fftwlib"].set_property("pkg_config_name", pkgconfig_name) + @property def _prec_suffix(self): return { diff --git a/recipes/fftw/all/patches/fix-cmake.patch b/recipes/fftw/all/patches/fix-cmake.patch deleted file mode 100644 index 8e232d86a7c99..0000000000000 --- a/recipes/fftw/all/patches/fix-cmake.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -364,10 +364,10 @@ install(TARGETS ${fftw3_lib} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - - install (FILES api/fftw3.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) --if (EXISTS ${CMAKE_SOURCE_DIR}/api/fftw3.f) -+if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/api/fftw3.f) - install (FILES api/fftw3.f api/fftw3l.f03 api/fftw3q.f03 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - endif () --if (EXISTS ${CMAKE_SOURCE_DIR}/api/fftw3.f03.in) -+if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/api/fftw3.f03.in) - file (READ api/fftw3.f03.in FFTW3_F03_IN OFFSET 42) - file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/fftw3.f03 "! Generated automatically. DO NOT EDIT!\n\n") - file (APPEND ${CMAKE_CURRENT_BINARY_DIR}/fftw3.f03 " integer, parameter :: C_FFTW_R2R_KIND = ${C_FFTW_R2R_KIND}\n\n") diff --git a/recipes/fftw/all/test_package/CMakeLists.txt b/recipes/fftw/all/test_package/CMakeLists.txt index fd248e0f8438a..3943d935ac8c2 100644 --- a/recipes/fftw/all/test_package/CMakeLists.txt +++ b/recipes/fftw/all/test_package/CMakeLists.txt @@ -1,13 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) option(ENABLE_DOUBLE_PRECISION "Enable FFTW single precision" ON) option(ENABLE_SINGLE_PRECISION "Enable FFTW single precision" OFF) option(ENABLE_LONG_DOUBLE_PRECISION "Enable FFTW single precision" OFF) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - if(ENABLE_SINGLE_PRECISION) find_package(FFTW3f REQUIRED CONFIG) elseif(ENABLE_LONG_DOUBLE_PRECISION) @@ -16,7 +13,7 @@ else() find_package(FFTW3 REQUIRED CONFIG) endif() -add_executable(${PROJECT_NAME} test_package.cpp) +add_executable(${PROJECT_NAME} test_package.c) target_link_libraries(${PROJECT_NAME} $<$:FFTW3::fftw3> $<$:FFTW3::fftw3f> diff --git a/recipes/fftw/all/test_package/conanfile.py b/recipes/fftw/all/test_package/conanfile.py index fb6eb8e19d6b0..54a72f37e7a08 100644 --- a/recipes/fftw/all/test_package/conanfile.py +++ b/recipes/fftw/all/test_package/conanfile.py @@ -1,20 +1,32 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_DOUBLE_PRECISION"] = self.dependencies["fftw"].options.precision == "double" + tc.variables["ENABLE_SINGLE_PRECISION"] = self.dependencies["fftw"].options.precision == "single" + tc.variables["ENABLE_LONG_DOUBLE_PRECISION"] = self.dependencies["fftw"].options.precision == "longdouble" + tc.generate() def build(self): cmake = CMake(self) - cmake.definitions["ENABLE_DOUBLE_PRECISION"] = self.options["fftw"].precision == "double" - cmake.definitions["ENABLE_SINGLE_PRECISION"] = self.options["fftw"].precision == "single" - cmake.definitions["ENABLE_LONG_DOUBLE_PRECISION"] = self.options["fftw"].precision == "longdouble" cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fftw/all/test_package/test_package.cpp b/recipes/fftw/all/test_package/test_package.c similarity index 100% rename from recipes/fftw/all/test_package/test_package.cpp rename to recipes/fftw/all/test_package/test_package.c diff --git a/recipes/fftw/all/test_v1_package/CMakeLists.txt b/recipes/fftw/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..30bfee7a37424 --- /dev/null +++ b/recipes/fftw/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +option(ENABLE_DOUBLE_PRECISION "Enable FFTW single precision" ON) +option(ENABLE_SINGLE_PRECISION "Enable FFTW single precision" OFF) +option(ENABLE_LONG_DOUBLE_PRECISION "Enable FFTW single precision" OFF) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +if(ENABLE_SINGLE_PRECISION) + find_package(FFTW3f REQUIRED CONFIG) +elseif(ENABLE_LONG_DOUBLE_PRECISION) + find_package(FFTW3l REQUIRED CONFIG) +else() + find_package(FFTW3 REQUIRED CONFIG) +endif() + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} + $<$:FFTW3::fftw3> + $<$:FFTW3::fftw3f> + $<$:FFTW3::fftw3l>) + +target_compile_options(${PROJECT_NAME} PRIVATE + $<$:-DENABLE_SINGLE_PRECISION=1> + $<$:-DENABLE_LONG_DOUBLE_PRECISION=1>) diff --git a/recipes/fftw/all/test_v1_package/conanfile.py b/recipes/fftw/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..51b0480e60c8e --- /dev/null +++ b/recipes/fftw/all/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["ENABLE_DOUBLE_PRECISION"] = self.options["fftw"].precision == "double" + cmake.definitions["ENABLE_SINGLE_PRECISION"] = self.options["fftw"].precision == "single" + cmake.definitions["ENABLE_LONG_DOUBLE_PRECISION"] = self.options["fftw"].precision == "longdouble" + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/flac/all/CMakeLists.txt b/recipes/flac/all/CMakeLists.txt deleted file mode 100644 index bd3083b512cb9..0000000000000 --- a/recipes/flac/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/flac/all/conandata.yml b/recipes/flac/all/conandata.yml index 3c896fa7b2129..b7edb40c63666 100644 --- a/recipes/flac/all/conandata.yml +++ b/recipes/flac/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "1.3.3": - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" diff --git a/recipes/flac/all/conanfile.py b/recipes/flac/all/conanfile.py index 63bbf05fc4692..43cf472dcf5c0 100644 --- a/recipes/flac/all/conanfile.py +++ b/recipes/flac/all/conanfile.py @@ -1,18 +1,21 @@ -from conans import ConanFile, tools, CMake +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, get, rmdir import os +required_conan_version = ">=1.47.0" + class FlacConan(ConanFile): name = "flac" description = "Free Lossless Audio Codec" - topics = ("conan", "flac", "codec", "audio", ) + topics = ("flac", "codec", "audio", ) url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/xiph/flac" license = ("BSD-3-Clause", "GPL-2.0-or-later", "LPGL-2.1-or-later", "GFDL-1.2") - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake", - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -22,11 +25,9 @@ class FlacConan(ConanFile): "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -37,59 +38,75 @@ def configure(self): del self.options.fPIC def requirements(self): - self.requires("ogg/1.3.4") + self.requires("ogg/1.3.5") def build_requirements(self): - self.build_requires("nasm/2.14") + if self.settings.arch in ["x86", "x86_64"]: + self.tool_requires("nasm/2.15.05") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{}-{}".format(self.name, self.version) - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["BUILD_DOCS"] = False - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_DOCS"] = False + tc.variables["BUILD_TESTING"] = False + tc.generate() + cd = CMakeDeps(self) + cd.generate() + if self.settings.arch in ["x86", "x86_64"]: + envbuild = VirtualBuildEnv(self) + envbuild.generate(scope="build") def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - self.copy(pattern="COPYING.*", dst="licenses", src=self._source_subfolder, keep_path=False) - self.copy(pattern="*.h", dst=os.path.join("include", "share"), src=os.path.join(self._source_subfolder, "include", "share"), keep_path=False) - self.copy(pattern="*.h", dst=os.path.join("include", "share", "grabbag"), - src=os.path.join(self._source_subfolder, "include", "share", "grabbag"), keep_path=False) - tools.rmdir(os.path.join(self.package_folder, "share")) + copy(self, "COPYING.*", src=self.source_folder, + dst=os.path.join(self.package_folder, "licenses"), keep_path=False) + copy(self, "*.h", src=os.path.join(self.source_folder, "include", "share"), + dst=os.path.join(self.package_folder, "include", "share"), keep_path=False) + copy(self, "*.h", src=os.path.join(self.source_folder, "include", "share", "grabbag"), + dst=os.path.join(self.package_folder, "include", "share", "grabbag"), keep_path=False) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "flac" - self.cpp_info.filenames["cmake_find_package_multi"] = "flac" - self.cpp_info.names["cmake_find_package"] = "FLAC" - self.cpp_info.names["cmake_find_package_multi"] = "FLAC" + self.cpp_info.set_property("cmake_file_name", "flac") + self.cpp_info.components["libflac"].set_property("cmake_target_name", "FLAC::FLAC") + self.cpp_info.components["libflac"].set_property("pkg_config_name", "flac") self.cpp_info.components["libflac"].libs = ["FLAC"] - self.cpp_info.components["libflac"].names["cmake_find_package"] = "FLAC" - self.cpp_info.components["libflac"].names["cmake_find_package_multi"] = "FLAC" - self.cpp_info.components["libflac"].names["pkg_config"] = "flac" self.cpp_info.components["libflac"].requires = ["ogg::ogg"] + self.cpp_info.components["libflac++"].set_property("cmake_target_name", "FLAC::FLAC++") + self.cpp_info.components["libflac++"].set_property("pkg_config_name", "flac++") self.cpp_info.components["libflac++"].libs = ["FLAC++"] self.cpp_info.components["libflac++"].requires = ["libflac"] - self.cpp_info.components["libflac++"].names["cmake_find_package"] = "FLAC++" - self.cpp_info.components["libflac++"].names["cmake_find_package_multi"] = "FLAC++" - self.cpp_info.components["libflac++"].names["pkg_config"] = "flac++" if not self.options.shared: self.cpp_info.components["libflac"].defines = ["FLAC__NO_DLL"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libflac"].system_libs += ["m"] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "flac" + self.cpp_info.filenames["cmake_find_package_multi"] = "flac" + self.cpp_info.names["cmake_find_package"] = "FLAC" + self.cpp_info.names["cmake_find_package_multi"] = "FLAC" + self.cpp_info.components["libflac"].names["cmake_find_package"] = "FLAC" + self.cpp_info.components["libflac"].names["cmake_find_package_multi"] = "FLAC" + self.cpp_info.components["libflac++"].names["cmake_find_package"] = "FLAC++" + self.cpp_info.components["libflac++"].names["cmake_find_package_multi"] = "FLAC++" diff --git a/recipes/flac/all/patches/fix-cmake.patch b/recipes/flac/all/patches/fix-cmake.patch index d902b61217bb6..ec7db2f2d00aa 100644 --- a/recipes/flac/all/patches/fix-cmake.patch +++ b/recipes/flac/all/patches/fix-cmake.patch @@ -1,5 +1,14 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt +@@ -13,7 +13,7 @@ option(BUILD_EXAMPLES "Build and install examples" ON) + option(WITH_OGG "ogg support (default: test for libogg)" ON) + + if(WITH_OGG) +- find_package(OGG REQUIRED) ++ find_package(Ogg REQUIRED CONFIG) + endif() + + if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") @@ -25,9 +25,6 @@ endif() if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef") @@ -19,6 +28,14 @@ endif() include_directories("include") +--- a/src/flac/CMakeLists.txt ++++ b/src/flac/CMakeLists.txt +@@ -21,4 +21,4 @@ if(TARGET win_utf8_io) + endif() + + install(TARGETS flacapp EXPORT targets +- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") ++ DESTINATION "${CMAKE_INSTALL_BINDIR}") --- a/src/libFLAC/CMakeLists.txt +++ b/src/libFLAC/CMakeLists.txt @@ -102,7 +102,7 @@ target_compile_definitions(FLAC @@ -30,8 +47,20 @@ if(TARGET Ogg::ogg) target_link_libraries(FLAC PUBLIC Ogg::ogg) endif() +--- a/src/metaflac/CMakeLists.txt ++++ b/src/metaflac/CMakeLists.txt +@@ -15,4 +15,4 @@ if(TARGET win_utf8_io) + endif() + + install(TARGETS metaflac EXPORT targets +- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") ++ DESTINATION "${CMAKE_INSTALL_BINDIR}") --- a/src/share/getopt/CMakeLists.txt +++ b/src/share/getopt/CMakeLists.txt -@@ -3,1 +3,1 @@ +@@ -1,6 +1,5 @@ + check_include_file("string.h" HAVE_STRING_H) + -find_package(Intl) -+ + + add_library(getopt STATIC getopt.c getopt1.c) + diff --git a/recipes/flac/all/test_package/CMakeLists.txt b/recipes/flac/all/test_package/CMakeLists.txt index 0af71408fb041..3b8634d9cb495 100644 --- a/recipes/flac/all/test_package/CMakeLists.txt +++ b/recipes/flac/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(flac REQUIRED COMPONENTS FLAC) +find_package(flac REQUIRED FLAC++ CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} PRIVATE FLAC::FLAC++) diff --git a/recipes/flac/all/test_package/conanfile.py b/recipes/flac/all/test_package/conanfile.py index 1d0bdd3779793..3a8c6c5442b33 100644 --- a/recipes/flac/all/test_package/conanfile.py +++ b/recipes/flac/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/flac/all/test_v1_package/CMakeLists.txt b/recipes/flac/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3da5fc64af2ab --- /dev/null +++ b/recipes/flac/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(flac REQUIRED FLAC++ CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE FLAC::FLAC++) diff --git a/recipes/flac/all/test_v1_package/conanfile.py b/recipes/flac/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/flac/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/flann/all/CMakeLists.txt b/recipes/flann/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/flann/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/flann/all/conandata.yml b/recipes/flann/all/conandata.yml index da6db6d75a8c7..820886a139772 100644 --- a/recipes/flann/all/conandata.yml +++ b/recipes/flann/all/conandata.yml @@ -1,8 +1,13 @@ sources: + "1.9.2": + url: "https://github.com/tkircher/flann/archive/1.9.2.tar.gz" + sha256: "e26829bb0017f317d9cc45ab83ddcb8b16d75ada1ae07157006c1e7d601c8824" "1.9.1": - sha256: b23b5f4e71139faa3bcb39e6bbcc76967fbaf308c4ee9d4f5bfbeceaa76cc5d3 - url: https://github.com/mariusmuja/flann/archive/1.9.1.tar.gz + url: "https://github.com/mariusmuja/flann/archive/1.9.1.tar.gz" + sha256: "b23b5f4e71139faa3bcb39e6bbcc76967fbaf308c4ee9d4f5bfbeceaa76cc5d3" patches: + "1.9.2": + - patch_file: "patches/cxx-11-required.patch" + - patch_file: "patches/cmake-lz4.patch" "1.9.1": - patch_file: "patches/external-lz4-and-export-symbols.patch" - base_path: "source_subfolder" diff --git a/recipes/flann/all/conanfile.py b/recipes/flann/all/conanfile.py index eeec770f904be..0668657726b10 100644 --- a/recipes/flann/all/conanfile.py +++ b/recipes/flann/all/conanfile.py @@ -1,40 +1,35 @@ -import glob +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file, rm, rmdir, save +from conan.tools.scm import Version +from conans import tools as tools_legacy import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.50.0" -class LibFlannConan(ConanFile): +class FlannConan(ConanFile): name = "flann" description = "Fast Library for Approximate Nearest Neighbors" - topics = "conan", "flann" + topics = ("flann", "nns", "nearest-neighbor-search", "knn", "kd-tree") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.cs.ubc.ca/research/flann/" license = "BSD-3-Clause" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "with_hdf5": [True, False] } default_options = { "shared": False, "fPIC": True, - "with_hdf5": False } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -45,98 +40,111 @@ def configure(self): del self.options.fPIC def requirements(self): - self.requires("lz4/1.9.2") - if self.options.with_hdf5: - self.requires("hdf5/1.12.0") + self.requires("lz4/1.9.3") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def validate(self): + if Version(self.version) >= "1.9.2" and self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, {}): - tools.patch(**patch) - # Workaround issue with empty sources for a CMake target - flann_cpp_dir = os.path.join(self._source_subfolder, "src", "cpp") - tools.save(os.path.join(flann_cpp_dir, "empty.cpp"), "\n") - - tools.replace_in_file( - os.path.join(flann_cpp_dir, "CMakeLists.txt"), - 'add_library(flann_cpp SHARED "")', - 'add_library(flann_cpp SHARED empty.cpp)' - ) - tools.replace_in_file( - os.path.join(flann_cpp_dir, "CMakeLists.txt"), - 'add_library(flann SHARED "")', - 'add_library(flann SHARED empty.cpp)' - ) - # remove embeded lz4 - tools.rmdir(os.path.join(self._source_subfolder, "src", "cpp", "flann", "ext")) - - def _configure_cmake(self): - if self._cmake is not None: - return self._cmake - self._cmake = CMake(self) - - self._cmake.definitions["BUILD_C_BINDINGS"] = True + def layout(self): + cmake_layout(self, src_folder="src") - # Only build the C++ libraries - self._cmake.definitions["BUILD_DOC"] = False - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["BUILD_MATLAB_BINDINGS"] = False - self._cmake.definitions["BUILD_PYTHON_BINDINGS"] = False + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_C_BINDINGS"] = True + # Only build the C++ libraries + tc.variables["BUILD_DOC"] = False + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_TESTS"] = False + tc.variables["BUILD_MATLAB_BINDINGS"] = False + tc.variables["BUILD_PYTHON_BINDINGS"] = False # OpenMP support can be added later if needed - self._cmake.definitions["USE_OPENMP"] = False + tc.variables["USE_OPENMP"] = False + # Generate a relocatable shared lib on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + cd = CMakeDeps(self) + cd.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + # remove embedded lz4 + rmdir(self, os.path.join(self.source_folder, "src", "cpp", "flann", "ext")) + + if Version(self.version) < "1.9.2": + # Workaround issue with empty sources for a CMake target + flann_cpp_dir = os.path.join(self.source_folder, "src", "cpp") + save(self, os.path.join(flann_cpp_dir, "empty.cpp"), "\n") + + replace_in_file(self, + os.path.join(flann_cpp_dir, "CMakeLists.txt"), + 'add_library(flann_cpp SHARED "")', + 'add_library(flann_cpp SHARED empty.cpp)' + ) + replace_in_file(self, + os.path.join(flann_cpp_dir, "CMakeLists.txt"), + 'add_library(flann SHARED "")', + 'add_library(flann SHARED empty.cpp)' + ) def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + # Remove vc runtimes + if self.settings.os == "Windows": + if self.options.shared: + for dll_pattern_to_remove in ["concrt*.dll", "msvcp*.dll", "vcruntime*.dll"]: + rm(self, dll_pattern_to_remove, os.path.join(self.package_folder, "bin")) + else: + rmdir(self, os.path.join(self.package_folder, "bin")) # Remove static/dynamic libraries depending on the build mode - if self.options.shared: - # Remove MS runtime files - for dll_pattern_to_remove in ["concrt*.dll", "msvcp*.dll", "vcruntime*.dll"]: - for dll_to_remove in glob.glob(os.path.join(self.package_folder, "bin", dll_pattern_to_remove)): - os.remove(dll_to_remove) - else: - tools.rmdir(os.path.join(self.package_folder, "bin")) libs_pattern_to_remove = ["*flann_cpp_s.*", "*flann_s.*"] if self.options.shared else ["*flann_cpp.*", "*flann.*"] for lib_pattern_to_remove in libs_pattern_to_remove: - for lib_to_remove in glob.glob(os.path.join(self.package_folder, "lib", lib_pattern_to_remove)): - os.remove(lib_to_remove) + rm(self, lib_pattern_to_remove, os.path.join(self.package_folder, "lib")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "Flann" - self.cpp_info.names["cmake_find_package_multi"] = "flann" + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_module_file_name", "Flann") + self.cpp_info.set_property("cmake_file_name", "flann") + self.cpp_info.set_property("pkg_config_name", "flann") + # flann_cpp flann_cpp_lib = "flann_cpp" if self.options.shared else "flann_cpp_s" - self.cpp_info.components["flann_cpp"].names["cmake_find_package"] = flann_cpp_lib - self.cpp_info.components["flann_cpp"].names["cmake_find_package_multi"] = flann_cpp_lib + self.cpp_info.components["flann_cpp"].set_property("cmake_target_name", "flann::{}".format(flann_cpp_lib)) self.cpp_info.components["flann_cpp"].libs = [flann_cpp_lib] - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.components["flann_cpp"].system_libs.append(tools.stdcpp_library(self)) + if not self.options.shared and tools_legacy.stdcpp_library(self): + self.cpp_info.components["flann_cpp"].system_libs.append(tools_legacy.stdcpp_library(self)) self.cpp_info.components["flann_cpp"].requires = ["lz4::lz4"] - if self.options.with_hdf5: - self.cpp_info.components["flann_cpp"].requires = ["hdf5::hdf5"] + # flann flann_c_lib = "flann" if self.options.shared else "flann_s" - self.cpp_info.components["flann_c"].names["cmake_find_package"] = flann_c_lib - self.cpp_info.components["flann_c"].names["cmake_find_package_multi"] = flann_c_lib + self.cpp_info.components["flann_c"].set_property("cmake_target_name", "flann::{}".format(flann_c_lib)) self.cpp_info.components["flann_c"].libs = [flann_c_lib] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["flann_c"].system_libs.append("m") if not self.options.shared: self.cpp_info.components["flann_c"].defines.append("FLANN_STATIC") self.cpp_info.components["flann_c"].requires = ["flann_cpp"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "Flann" + self.cpp_info.names["cmake_find_package_multi"] = "flann" + self.cpp_info.components["flann_cpp"].names["cmake_find_package"] = flann_cpp_lib + self.cpp_info.components["flann_cpp"].names["cmake_find_package_multi"] = flann_cpp_lib + self.cpp_info.components["flann_c"].names["cmake_find_package"] = flann_c_lib + self.cpp_info.components["flann_c"].names["cmake_find_package_multi"] = flann_c_lib diff --git a/recipes/flann/all/patches/cmake-lz4.patch b/recipes/flann/all/patches/cmake-lz4.patch new file mode 100644 index 0000000000000..41ee873f7e054 --- /dev/null +++ b/recipes/flann/all/patches/cmake-lz4.patch @@ -0,0 +1,55 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e1a6f54..2dfa2b5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -146,9 +146,7 @@ if (BUILD_CUDA_LIB) + endif(CUDA_FOUND) + endif(BUILD_CUDA_LIB) + +-find_package(PkgConfig REQUIRED) +-pkg_check_modules(LZ4 REQUIRED liblz4) +-include_directories(${LZ4_INCLUDE_DIRS}) ++find_package(lz4 REQUIRED) + + #set the C/C++ include path to the "include" directory + include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src/cpp) +diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt +index daec3d6..b613f20 100644 +--- a/src/cpp/CMakeLists.txt ++++ b/src/cpp/CMakeLists.txt +@@ -10,7 +10,7 @@ file(GLOB_RECURSE CU_SOURCES *.cu) + + add_library(flann_cpp_s STATIC ${CPP_SOURCES}) + target_compile_features(flann_cpp_s PUBLIC cxx_std_11) +-target_link_libraries(flann_cpp_s ${LZ4_LINK_LIBRARIES}) ++target_link_libraries(flann_cpp_s PRIVATE lz4::lz4) + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) + set_target_properties(flann_cpp_s PROPERTIES COMPILE_FLAGS -fPIC) + endif() +@@ -44,7 +44,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC) + endif() + else() + add_library(flann_cpp SHARED ${CPP_SOURCES}) +- target_link_libraries(flann_cpp ${LZ4_LINK_LIBRARIES}) ++ target_link_libraries(flann_cpp PRIVATE lz4::lz4) + # export lz4 headers, so that MSVC to creates flann_cpp.lib + set_target_properties(flann_cpp PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES) + if (BUILD_CUDA_LIB) +@@ -83,7 +83,7 @@ endif() + if (BUILD_C_BINDINGS) + add_library(flann_s STATIC ${C_SOURCES}) + target_compile_features(flann_s PRIVATE cxx_std_11) +- target_link_libraries(flann_s ${LZ4_LINK_LIBRARIES}) ++ target_link_libraries(flann_s PRIVATE lz4::lz4) + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) + set_target_properties(flann_s PROPERTIES COMPILE_FLAGS -fPIC) + endif() +@@ -95,7 +95,7 @@ if (BUILD_C_BINDINGS) + target_link_libraries(flann -Wl,-whole-archive flann_s -Wl,-no-whole-archive) + else() + add_library(flann SHARED ${C_SOURCES}) +- target_link_libraries(flann ${LZ4_LINK_LIBRARIES}) ++ target_link_libraries(flann PRIVATE lz4::lz4) + + if(MINGW AND OPENMP_FOUND) + target_link_libraries(flann gomp) diff --git a/recipes/flann/all/patches/cxx-11-required.patch b/recipes/flann/all/patches/cxx-11-required.patch new file mode 100644 index 0000000000000..9015d84efa567 --- /dev/null +++ b/recipes/flann/all/patches/cxx-11-required.patch @@ -0,0 +1,28 @@ +diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt +index d8bff04..daec3d6 100644 +--- a/src/cpp/CMakeLists.txt ++++ b/src/cpp/CMakeLists.txt +@@ -9,6 +9,7 @@ file(GLOB_RECURSE CPP_SOURCES flann_cpp.cpp) + file(GLOB_RECURSE CU_SOURCES *.cu) + + add_library(flann_cpp_s STATIC ${CPP_SOURCES}) ++target_compile_features(flann_cpp_s PUBLIC cxx_std_11) + target_link_libraries(flann_cpp_s ${LZ4_LINK_LIBRARIES}) + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) + set_target_properties(flann_cpp_s PROPERTIES COMPILE_FLAGS -fPIC) +@@ -31,6 +32,7 @@ endif() + + if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC) + add_library(flann_cpp SHARED dummy.c) ++ target_compile_features(flann_cpp PUBLIC cxx_std_11) + set_target_properties(flann_cpp PROPERTIES LINKER_LANGUAGE CXX) + target_link_libraries(flann_cpp -Wl,-whole-archive flann_cpp_s -Wl,-no-whole-archive) + +@@ -80,6 +82,7 @@ endif() + + if (BUILD_C_BINDINGS) + add_library(flann_s STATIC ${C_SOURCES}) ++ target_compile_features(flann_s PRIVATE cxx_std_11) + target_link_libraries(flann_s ${LZ4_LINK_LIBRARIES}) + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) + set_target_properties(flann_s PROPERTIES COMPILE_FLAGS -fPIC) diff --git a/recipes/flann/all/test_package/CMakeLists.txt b/recipes/flann/all/test_package/CMakeLists.txt index af0154e468f34..78713ac43c143 100644 --- a/recipes/flann/all/test_package/CMakeLists.txt +++ b/recipes/flann/all/test_package/CMakeLists.txt @@ -1,14 +1,11 @@ cmake_minimum_required(VERSION 3.1) project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - find_package(flann REQUIRED CONFIG) -add_executable(${CMAKE_PROJECT_NAME} test_package.c) -if(FLANN_SHARED) - target_link_libraries(${CMAKE_PROJECT_NAME} flann::flann) +add_executable(${PROJECT_NAME} test_package.c) +if(TARGET flann::flann_s) + target_link_libraries(${PROJECT_NAME} PRIVATE flann::flann_s) else() - target_link_libraries(${CMAKE_PROJECT_NAME} flann::flann_s) + target_link_libraries(${PROJECT_NAME} PRIVATE flann::flann) endif() diff --git a/recipes/flann/all/test_package/conanfile.py b/recipes/flann/all/test_package/conanfile.py index 6ead28e15819e..3a8c6c5442b33 100644 --- a/recipes/flann/all/test_package/conanfile.py +++ b/recipes/flann/all/test_package/conanfile.py @@ -1,19 +1,25 @@ -import os.path +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os -from conans import ConanFile, CMake, tools +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" -class FlannTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) - cmake.definitions["FLANN_SHARED"] = self.options["flann"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/flann/all/test_v1_package/CMakeLists.txt b/recipes/flann/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e25fe67f56dda --- /dev/null +++ b/recipes/flann/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(flann REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +if(TARGET flann::flann_s) + target_link_libraries(${PROJECT_NAME} PRIVATE flann::flann_s) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE flann::flann) +endif() diff --git a/recipes/flann/all/test_v1_package/conanfile.py b/recipes/flann/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/flann/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/flann/config.yml b/recipes/flann/config.yml index d107b03e40374..524442a72b4f3 100644 --- a/recipes/flann/config.yml +++ b/recipes/flann/config.yml @@ -1,3 +1,5 @@ versions: + "1.9.2": + folder: all "1.9.1": folder: all diff --git a/recipes/flatbuffers/all/CMakeLists.txt b/recipes/flatbuffers/all/CMakeLists.txt deleted file mode 100644 index 5899618da26ba..0000000000000 --- a/recipes/flatbuffers/all/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -if (WIN32 AND MSVC AND FLATBUFFERS_BUILD_SHAREDLIB) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif(WIN32 AND MSVC AND FLATBUFFERS_BUILD_SHAREDLIB) - -add_subdirectory("source_subfolder") diff --git a/recipes/flatbuffers/all/cmake/FlatcTargets.cmake b/recipes/flatbuffers/all/cmake/FlatcTargets.cmake new file mode 100644 index 0000000000000..cddc331b7f319 --- /dev/null +++ b/recipes/flatbuffers/all/cmake/FlatcTargets.cmake @@ -0,0 +1,31 @@ +if(NOT TARGET flatbuffers::flatc) + if(CMAKE_CROSSCOMPILING) + find_program(FLATBUFFERS_FLATC_EXECUTABLE + NAMES flatc + PATHS ENV PATH + NO_DEFAULT_PATH + ) + else() + find_program(FLATBUFFERS_FLATC_EXECUTABLE + NAMES flatc + PATHS "${CMAKE_CURRENT_LIST_DIR}/../../bin/" + NO_DEFAULT_PATH + ) + endif() + # TODO: In conan v2 with CMakeToolchain, can be replaced by: + # find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc) + # # Nice enough to handle flatbuffers not in build_requires for native build + # if(NOT FLATBUFFERS_FLATC_EXECUTABLE AND NOT CMAKE_CROSSCOMPILING) + # find_program(FLATBUFFERS_FLATC_EXECUTABLE + # NAMES flatc + # PATHS "${CMAKE_CURRENT_LIST_DIR}/../../bin/" + # NO_DEFAULT_PATH + # ) + # endif() + + if(FLATBUFFERS_FLATC_EXECUTABLE) + get_filename_component(FLATBUFFERS_FLATC_EXECUTABLE "${FLATBUFFERS_FLATC_EXECUTABLE}" ABSOLUTE) + add_executable(flatbuffers::flatc IMPORTED) + set_property(TARGET flatbuffers::flatc PROPERTY IMPORTED_LOCATION ${FLATBUFFERS_FLATC_EXECUTABLE}) + endif() +endif() diff --git a/recipes/flatbuffers/all/conandata.yml b/recipes/flatbuffers/all/conandata.yml index ed9781e339181..a637b19cca0ad 100644 --- a/recipes/flatbuffers/all/conandata.yml +++ b/recipes/flatbuffers/all/conandata.yml @@ -1,14 +1,45 @@ sources: - 1.11.0: - url: "https://github.com/google/flatbuffers/archive/v1.11.0.tar.gz" - sha256: "3f4a286642094f45b1b77228656fbd7ea123964f19502f9ecfd29933fd23a50b" - 1.12.0: + "22.12.06": + url: "https://github.com/google/flatbuffers/archive/v22.12.06.tar.gz" + sha256: "209823306f2cbedab6ff70997e0d236fcfd1864ca9ad082cbfdb196e7386daed" + "22.11.23": + url: "https://github.com/google/flatbuffers/archive/v22.11.23.tar.gz" + sha256: "8e9bacc942db59ca89a383dd7923f3e69a377d6e579d1ba13557de1fdfddf56a" + "22.10.26": + url: "https://github.com/google/flatbuffers/archive/v22.10.26.tar.gz" + sha256: "34f1820cfd78a3d92abc880fbb1a644c7fb31a71238995f4ed6b5915a1ad4e79" + "22.9.29": + url: "https://github.com/google/flatbuffers/archive/refs/tags/v22.9.29.tar.gz" + sha256: "372df01795c670f6538055a7932fc7eb3e81b3653be4a216c081e9c3c26b1b6d" + "22.9.24": + url: "https://github.com/google/flatbuffers/archive/refs/tags/v22.9.24.tar.gz" + sha256: "40e0788873012def4d66a2fdbac15fbe012784473c01a703ccb5be33383556bf" + "2.0.8": + url: "https://github.com/google/flatbuffers/archive/refs/tags/v2.0.8.tar.gz" + sha256: "f97965a727d26386afaefff950badef2db3ab6af9afe23ed6d94bfb65f95f37e" + "2.0.6": + url: "https://github.com/google/flatbuffers/archive/refs/tags/v2.0.6.tar.gz" + sha256: "e2dc24985a85b278dd06313481a9ca051d048f9474e0f199e372fea3ea4248c9" + "2.0.5": + url: "https://github.com/google/flatbuffers/archive/refs/tags/v2.0.5.tar.gz" + sha256: "b01e97c988c429e164c5c7df9e87c80007ca87f593c0d73733ba536ddcbc8f98" + "2.0.0": + url: "https://github.com/google/flatbuffers/archive/v2.0.0.tar.gz" + sha256: "9ddb9031798f4f8754d00fca2f1a68ecf9d0f83dfac7239af1311e4fd9a565c4" + "1.12.0": url: "https://github.com/google/flatbuffers/archive/v1.12.0.tar.gz" sha256: "62f2223fb9181d1d6338451375628975775f7522185266cd5296571ac152bc45" + "1.11.0": + url: "https://github.com/google/flatbuffers/archive/v1.11.0.tar.gz" + sha256: "3f4a286642094f45b1b77228656fbd7ea123964f19502f9ecfd29933fd23a50b" patches: - 1.11.0: - - patch_file: "patches/0001-buildflatbuffers-cmake.patch" - base_path: "source_subfolder" - 1.12.0: - - patch_file: "patches/0001-buildflatbuffers-cmake.patch" - base_path: "source_subfolder" + "2.0.6": + - patch_file: "patches/0004-no-flatc-execution-build-time.patch" + "2.0.5": + - patch_file: "patches/0002-apple-no-universal-build.patch" + - patch_file: "patches/0003-no-flatc-execution-build-time.patch" + "1.11.0": + - patch_file: "patches/0001-fix-copy-ctor.patch" + patch_description: "Fix build with Clang" + patch_type: "portability" + patch_source: "https://github.com/google/flatbuffers/pull/5650" diff --git a/recipes/flatbuffers/all/conanfile.py b/recipes/flatbuffers/all/conanfile.py index ad96a89b794b7..7a56fe8b533bc 100644 --- a/recipes/flatbuffers/all/conanfile.py +++ b/recipes/flatbuffers/all/conanfile.py @@ -1,9 +1,12 @@ -import glob +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.build import check_min_cppstd, valid_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get, replace_in_file, rmdir +from conan.tools.scm import Version import os -import shutil -from conans import ConanFile, CMake, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.51.3" class FlatbuffersConan(ConanFile): @@ -11,132 +14,161 @@ class FlatbuffersConan(ConanFile): license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" homepage = "http://google.github.io/flatbuffers" - topics = ("conan", "flatbuffers", "serialization", "rpc", "json-parser") + topics = ("flatbuffers", "serialization", "rpc", "json-parser") description = "Memory Efficient Serialization Library" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], - "fPIC": [True, False], - "header_only": [True, False], - "flatc": [True, False], - "flatbuffers": [True, False], - "options_from_context": [True, False]} - default_options = {"shared": False, - "fPIC": True, "header_only": False, - "flatc": True, - "flatbuffers": True, - "options_from_context": True} - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - - _cmake = None - _header_only = False + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "header_only": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "header_only": False, + } @property - def _source_subfolder(self): - return "source_subfolder" + def _has_flatc(self): + # don't build flatc when it makes little sense or not supported + return self.settings.os not in ["Android", "iOS", "watchOS", "tvOS", "Neutrino"] - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def export_sources(self): + copy(self, os.path.join("cmake", "FlatcTargets.cmake"), self.recipe_folder, self.export_sources_folder) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) - def configure(self): + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - # Detect if host or build context - if self.options.options_from_context: - settings_target = getattr(self, 'settings_target', None) - self.options.flatc = settings_target is not None - self.options.flatbuffers = settings_target is None - del self.options.options_from_context - - if not self.options.flatbuffers: - del self.options.header_only - self._header_only = False - else: - self._header_only = self.options.header_only + def build_requirements(self): + if Version(self.version) >= "2.0.7": + self.tool_requires("cmake/3.24.0") - if (self.options.shared and self.options.flatbuffers) or self._header_only or (not self.options.flatbuffers and self.options.flatc): + def configure(self): + if self.options.shared or self.options.header_only: del self.options.fPIC - - if self._header_only and not self.options.flatc: + if self.options.header_only: del self.options.shared - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) - def package_id(self): - if self._header_only and not self.options.flatc: - self.info.header_only() + if self.options.header_only and not self._has_flatc: + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["FLATBUFFERS_BUILD_TESTS"] = False - self._cmake.definitions["FLATBUFFERS_BUILD_SHAREDLIB"] = self.options.flatbuffers and self.options.shared - self._cmake.definitions["FLATBUFFERS_BUILD_FLATLIB"] = self.options.flatbuffers and not self.options.shared - self._cmake.definitions["FLATBUFFERS_BUILD_FLATC"] = self.options.flatc - self._cmake.definitions["FLATBUFFERS_BUILD_FLATHASH"] = False - self._cmake.definitions["FLATBUFFERS_STATIC_FLATC"] = not self.options.shared - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FLATBUFFERS_BUILD_TESTS"] = False + tc.variables["FLATBUFFERS_INSTALL"] = True + tc.variables["FLATBUFFERS_BUILD_FLATLIB"] = not self.options.header_only and not self.options.shared + tc.variables["FLATBUFFERS_BUILD_FLATC"] = self._has_flatc + tc.variables["FLATBUFFERS_STATIC_FLATC"] = False + tc.variables["FLATBUFFERS_BUILD_FLATHASH"] = False + tc.variables["FLATBUFFERS_BUILD_SHAREDLIB"] = not self.options.header_only and self.options.shared + # Honor conan profile + tc.variables["FLATBUFFERS_LIBCXX_WITH_CLANG"] = False + # Mimic upstream CMake/Version.cmake removed in _patch_sources() + version = Version(self.version) + tc.cache_variables["VERSION_MAJOR"] = str(version.major) + tc.cache_variables["VERSION_MINOR"] = str(version.minor or "0") + tc.cache_variables["VERSION_PATCH"] = str(version.patch or "0") + tc.cache_variables["VERSION_COMMIT"] = str(version.pre or "0") + # For msvc shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + # Relocatable shared libs on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # Fix iOS/tvOS/watchOS + if is_apple_os(self): + tc.variables["CMAKE_MACOSX_BUNDLE"] = False + # Inject at least C++11 standard (would be more elegant to rely on cxx_std_11 compile feature upstream) + if not valid_min_cppstd(self, 11): + tc.variables["CMAKE_CXX_STANDARD"] = 11 + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + # Prefer manual injection of current version in build(), otherwise it tries to call git + replace_in_file(self, cmakelists, "include(CMake/Version.cmake)", "") + # No warnings as errors + replace_in_file(self, cmakelists, "/WX", "") + replace_in_file(self, cmakelists, "-Werror ", "") + # Install dll to bin folder + replace_in_file(self, cmakelists, + "RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}", + "RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}") def build(self): self._patch_sources() - if (self.options.flatbuffers and not self._header_only) or self.options.flatc: - cmake = self._configure_cmake() - cmake.build() + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - - # Run cmake if there is anything to build - if (self.options.flatbuffers and not self._header_only) or self.options.flatc: - cmake = self._configure_cmake() - cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - - if self.options.flatbuffers: - self.copy(pattern="BuildFlatBuffers.cmake", dst="bin/cmake", src=os.path.join(self._source_subfolder, "CMake")) - - if self._header_only: - header_dir = os.path.join(self._source_subfolder, "include", "flatbuffers") - dst_dir = os.path.join("include", "flatbuffers") - self.copy("*.h", dst=dst_dir, src=header_dir) - - if not self._header_only: - if self.settings.os == "Windows" and self.options.shared: - tools.mkdir(os.path.join(self.package_folder, "bin")) - for dll_path in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")): - shutil.move(dll_path, os.path.join(self.package_folder, "bin", os.path.basename(dll_path))) - elif self.options.flatc: - tools.rmdir(os.path.join(self.package_folder, "include")) + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + copy(self, "FlatcTargets.cmake", + src=os.path.join(self.source_folder, os.pardir, "cmake"), + dst=os.path.join(self.package_folder, self._module_path)) + copy(self, "BuildFlatBuffers.cmake", + src=os.path.join(self.source_folder, "CMake"), + dst=os.path.join(self.package_folder, self._module_path)) + + @property + def _module_path(self): + return os.path.join("lib", "cmake") def package_info(self): - if self.options.flatbuffers: - self.cpp_info.filenames["cmake_find_package"] = "Flatbuffers" - self.cpp_info.filenames["cmake_find_package_multi"] = "Flatbuffers" - self.cpp_info.names["cmake_find_package"] = "flatbuffers" - self.cpp_info.names["cmake_find_package_multi"] = "flatbuffers" - if not self._header_only: - cmake_target = "flatbuffers_shared" if self.options.shared else "flatbuffers" - self.cpp_info.components["libflatbuffers"].names["cmake_find_package"] = cmake_target - self.cpp_info.components["libflatbuffers"].names["cmake_find_package_multi"] = cmake_target - self.cpp_info.components["libflatbuffers"].libs = tools.collect_libs(self) - self.cpp_info.components["libflatbuffers"].builddirs.append("bin/cmake") - self.cpp_info.components["libflatbuffers"].build_modules.append("bin/cmake/BuildFlatBuffers.cmake") - if self.settings.os == "Linux": - self.cpp_info.components["libflatbuffers"].system_libs.append("m") - else: - self.cpp_info.builddirs.append("bin/cmake") - self.cpp_info.build_modules.append("bin/cmake/BuildFlatBuffers.cmake") - if self.options.flatc: + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_module_file_name", "flatbuffers") + self.cpp_info.set_property("cmake_file_name", "flatbuffers") + cmake_target = "flatbuffers" + if not self.options.header_only and self.options.shared: + cmake_target += "_shared" + self.cpp_info.set_property("cmake_target_name", f"flatbuffers::{cmake_target}") + self.cpp_info.set_property("pkg_config_name", "flatbuffers") + + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + if not self.options.header_only: + self.cpp_info.components["libflatbuffers"].libs = collect_libs(self) + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["libflatbuffers"].system_libs.append("m") + + # Provide flatbuffers::flatc target and CMake functions from BuildFlatBuffers.cmake + build_modules = [ + os.path.join(self._module_path, "FlatcTargets.cmake"), + os.path.join(self._module_path, "BuildFlatBuffers.cmake"), + ] + self.cpp_info.set_property("cmake_build_modules", build_modules) + if self._has_flatc: bindir = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.output.info(f"Appending PATH environment variable: {bindir}") self.env_info.PATH.append(bindir) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.filenames["cmake_find_package"] = "flatbuffers" + self.cpp_info.filenames["cmake_find_package_multi"] = "flatbuffers" + self.cpp_info.names["cmake_find_package"] = "flatbuffers" + self.cpp_info.names["cmake_find_package_multi"] = "flatbuffers" + self.cpp_info.components["libflatbuffers"].names["cmake_find_package"] = cmake_target + self.cpp_info.components["libflatbuffers"].names["cmake_find_package_multi"] = cmake_target + self.cpp_info.components["libflatbuffers"].build_modules["cmake_find_package"] = build_modules + self.cpp_info.components["libflatbuffers"].build_modules["cmake_find_package_multi"] = build_modules + self.cpp_info.components["libflatbuffers"].set_property("cmake_file_name", f"flatbuffers::{cmake_target}") + self.cpp_info.components["libflatbuffers"].set_property("pkg_config_name", "flatbuffers") diff --git a/recipes/flatbuffers/all/patches/0001-buildflatbuffers-cmake.patch b/recipes/flatbuffers/all/patches/0001-buildflatbuffers-cmake.patch deleted file mode 100644 index b54f5042542e0..0000000000000 --- a/recipes/flatbuffers/all/patches/0001-buildflatbuffers-cmake.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMake/BuildFlatBuffers.cmake b/CMake/BuildFlatBuffers.cmake -index 835f4b80..edc2fde7 100644 ---- a/CMake/BuildFlatBuffers.cmake -+++ b/CMake/BuildFlatBuffers.cmake -@@ -60,7 +60,7 @@ function(build_flatbuffers flatbuffers_schemas - set(FLATC_TARGET "") - set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE}) - else() -- set(FLATC_TARGET flatc) -+ set(FLATC_TARGET "") - set(FLATC flatc) - endif() - set(FLATC_SCHEMA_ARGS --gen-mutable) diff --git a/recipes/flatbuffers/all/patches/0001-fix-copy-ctor.patch b/recipes/flatbuffers/all/patches/0001-fix-copy-ctor.patch new file mode 100644 index 0000000000000..0dad562100bfb --- /dev/null +++ b/recipes/flatbuffers/all/patches/0001-fix-copy-ctor.patch @@ -0,0 +1,24 @@ +diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h +index a1a95f0..ef293f2 100644 +--- a/include/flatbuffers/flatbuffers.h ++++ b/include/flatbuffers/flatbuffers.h +@@ -1709,6 +1709,7 @@ class FlatBufferBuilder { + /// @cond FLATBUFFERS_INTERNAL + template struct TableKeyComparator { + TableKeyComparator(vector_downward &buf) : buf_(buf) {} ++ TableKeyComparator(const TableKeyComparator &other) : buf_(other.buf_) {} + bool operator()(const Offset &a, const Offset &b) const { + auto table_a = reinterpret_cast(buf_.data_at(a.o)); + auto table_b = reinterpret_cast(buf_.data_at(b.o)); +@@ -1717,7 +1718,10 @@ class FlatBufferBuilder { + vector_downward &buf_; + + private: +- TableKeyComparator &operator=(const TableKeyComparator &); ++ TableKeyComparator &operator=(const TableKeyComparator &other) { ++ buf_ = other.buf_; ++ return *this; ++ } + }; + /// @endcond + diff --git a/recipes/flatbuffers/all/patches/0002-apple-no-universal-build.patch b/recipes/flatbuffers/all/patches/0002-apple-no-universal-build.patch new file mode 100644 index 0000000000000..43e3e8f6ab5a3 --- /dev/null +++ b/recipes/flatbuffers/all/patches/0002-apple-no-universal-build.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -282,7 +282,6 @@ elseif(CMAKE_COMPILER_IS_GNUCXX) + + elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + if(APPLE) +- set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") diff --git a/recipes/flatbuffers/all/patches/0003-no-flatc-execution-build-time.patch b/recipes/flatbuffers/all/patches/0003-no-flatc-execution-build-time.patch new file mode 100644 index 0000000000000..8716b3ba7ccf4 --- /dev/null +++ b/recipes/flatbuffers/all/patches/0003-no-flatc-execution-build-time.patch @@ -0,0 +1,18 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -514,6 +514,7 @@ function(compile_flatbuffers_schema_to_embedded_binary SRC_FBS OPT) + register_generated_output(${GEN_BFBS_HEADER}) + endfunction() + ++if(0) + # Look if we have python 3 installed so that we can run the generate code python + # script after flatc is built. + find_package(PythonInterp 3) +@@ -544,6 +545,7 @@ if(PYTHONINTERP_FOUND AND + else() + message("No Python3 interpreter found! Unable to generate files automatically.") + endif() ++endif() + + if(FLATBUFFERS_BUILD_TESTS) + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/recipes/flatbuffers/all/patches/0004-no-flatc-execution-build-time.patch b/recipes/flatbuffers/all/patches/0004-no-flatc-execution-build-time.patch new file mode 100644 index 0000000000000..11da02ea5d8c9 --- /dev/null +++ b/recipes/flatbuffers/all/patches/0004-no-flatc-execution-build-time.patch @@ -0,0 +1,20 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 21e90151..2ce3eb48 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -536,6 +536,7 @@ function(compile_flatbuffers_schema_to_embedded_binary SRC_FBS OPT) + register_generated_output(${GEN_BFBS_HEADER}) + endfunction() + ++if(0) + # Look if we have python 3.5 installed so that we can run the generate code + # python script after flatc is built. + find_package(Python3 3.5 COMPONENTS Interpreter) +@@ -559,6 +560,7 @@ if(Python3_Interpreter_FOUND) + else() + message("No Python3 interpreter found! Unable to generate files automatically.") + endif() ++endif() + + if(FLATBUFFERS_BUILD_TESTS) + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/recipes/flatbuffers/all/test_package/CMakeLists.txt b/recipes/flatbuffers/all/test_package/CMakeLists.txt index 23ae8edada0ca..e4d22dcbf68fe 100644 --- a/recipes/flatbuffers/all/test_package/CMakeLists.txt +++ b/recipes/flatbuffers/all/test_package/CMakeLists.txt @@ -1,18 +1,36 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(Flatbuffers REQUIRED CONFIG) +find_package(FlatBuffers REQUIRED CONFIG) +if(TARGET flatbuffers::flatbuffers_shared) + set(FLATBUFFERS_TARGET flatbuffers::flatbuffers_shared) +else() + set(FLATBUFFERS_TARGET flatbuffers::flatbuffers) +endif() add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ${FLATBUFFERS_TARGET}) if(FLATBUFFERS_HEADER_ONLY) - target_compile_definitions(${PROJECT_NAME} PRIVATE FLATBUFFERS_HEADER_ONLY) + target_compile_definitions(${PROJECT_NAME} PRIVATE FLATBUFFERS_HEADER_ONLY) endif() -if(FLATBUFFERS_SHARED) - target_link_libraries(${PROJECT_NAME} flatbuffers::flatbuffers_shared) -else() - target_link_libraries(${PROJECT_NAME} flatbuffers::flatbuffers) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +if(NOT (CMAKE_CROSSCOMPILING AND FLATBUFFERS_HEADER_ONLY)) # due to missing package id of build requirement if header_only + add_executable(sample_binary sample_binary.cpp) + target_link_libraries(sample_binary PRIVATE ${FLATBUFFERS_TARGET}) + target_compile_features(sample_binary PRIVATE cxx_std_11) + + set(MONSTER_GENERATED_HEADER ${CMAKE_CURRENT_BINARY_DIR}/monster_generated.h) + set(MONSTER_FBS ${CMAKE_CURRENT_SOURCE_DIR}/monster.fbs) + add_custom_command( + OUTPUT ${MONSTER_GENERATED_HEADER} + COMMAND $ + --cpp + -o ${CMAKE_CURRENT_BINARY_DIR} + ${MONSTER_FBS} + DEPENDS ${MONSTER_FBS} + ) + add_custom_target(generate_monster_header DEPENDS ${MONSTER_GENERATED_HEADER}) + add_dependencies(sample_binary generate_monster_header) + target_include_directories(sample_binary PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) endif() -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/flatbuffers/all/test_package/conanfile.py b/recipes/flatbuffers/all/test_package/conanfile.py index f9493969b50ae..6cfe4c15fdd50 100644 --- a/recipes/flatbuffers/all/test_package/conanfile.py +++ b/recipes/flatbuffers/all/test_package/conanfile.py @@ -1,23 +1,37 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run, cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + if not (hasattr(self, "settings_build") and cross_building(self) and self.options["flatbuffers"].header_only): + self.tool_requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FLATBUFFERS_HEADER_ONLY"] = self.dependencies["flatbuffers"].options.header_only + tc.generate() def build(self): - if self.options["flatbuffers"].flatbuffers: - cmake = CMake(self) - cmake.definitions["FLATBUFFERS_HEADER_ONLY"] = self.options["flatbuffers"].header_only - cmake.definitions["FLATBUFFERS_SHARED"] = not self.options["flatbuffers"].header_only and self.options["flatbuffers"].shared - cmake.configure() - cmake.build() + cmake = CMake(self) + cmake.configure() + cmake.build() def test(self): - if not tools.cross_building(self.settings): - if self.options["flatbuffers"].flatbuffers: - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - if self.options["flatbuffers"].flatc: - self.run("flatc --version", run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + sample_binary = os.path.join(self.cpp.build.bindirs[0], "sample_binary") + self.run(sample_binary, env="conanrun") diff --git a/recipes/flatbuffers/all/test_package/monster.fbs b/recipes/flatbuffers/all/test_package/monster.fbs new file mode 100644 index 0000000000000..af224512ee724 --- /dev/null +++ b/recipes/flatbuffers/all/test_package/monster.fbs @@ -0,0 +1,33 @@ +// Example IDL file for our monster's schema. + +namespace MyGame.Sample; + +enum Color:byte { Red = 0, Green, Blue = 2 } + +union Equipment { Weapon } // Optionally add more tables. + +struct Vec3 { + x:float; + y:float; + z:float; +} + +table Monster { + pos:Vec3; + mana:short = 150; + hp:short = 100; + name:string; + friendly:bool = false (deprecated); + inventory:[ubyte]; + color:Color = Blue; + weapons:[Weapon]; + equipped:Equipment; + path:[Vec3]; +} + +table Weapon { + name:string; + damage:short; +} + +root_type Monster; diff --git a/recipes/flatbuffers/all/test_package/sample_binary.cpp b/recipes/flatbuffers/all/test_package/sample_binary.cpp new file mode 100644 index 0000000000000..b8f4f1f6c37fd --- /dev/null +++ b/recipes/flatbuffers/all/test_package/sample_binary.cpp @@ -0,0 +1,104 @@ +/* + * Copyright 2015 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "monster_generated.h" // Already includes "flatbuffers/flatbuffers.h". + +using namespace MyGame::Sample; + +// Example how to use FlatBuffers to create and read binary buffers. + +int main(int /*argc*/, const char * /*argv*/[]) { + // Build up a serialized buffer algorithmically: + flatbuffers::FlatBufferBuilder builder; + + // First, lets serialize some weapons for the Monster: A 'sword' and an 'axe'. + auto weapon_one_name = builder.CreateString("Sword"); + short weapon_one_damage = 3; + + auto weapon_two_name = builder.CreateString("Axe"); + short weapon_two_damage = 5; + + // Use the `CreateWeapon` shortcut to create Weapons with all fields set. + auto sword = CreateWeapon(builder, weapon_one_name, weapon_one_damage); + auto axe = CreateWeapon(builder, weapon_two_name, weapon_two_damage); + + // Create a FlatBuffer's `vector` from the `std::vector`. + std::vector> weapons_vector; + weapons_vector.push_back(sword); + weapons_vector.push_back(axe); + auto weapons = builder.CreateVector(weapons_vector); + + // Second, serialize the rest of the objects needed by the Monster. + auto position = Vec3(1.0f, 2.0f, 3.0f); + + auto name = builder.CreateString("MyMonster"); + + unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + auto inventory = builder.CreateVector(inv_data, 10); + + // Shortcut for creating monster with all fields set: + auto orc = CreateMonster(builder, &position, 150, 80, name, inventory, + Color_Red, weapons, Equipment_Weapon, axe.Union()); + + builder.Finish(orc); // Serialize the root of the object. + + // We now have a FlatBuffer we can store on disk or send over a network. + + // ** file/network code goes here :) ** + // access builder.GetBufferPointer() for builder.GetSize() bytes + + // Instead, we're going to access it right away (as if we just received it). + + // Get access to the root: + auto monster = GetMonster(builder.GetBufferPointer()); + + // Get and test some scalar types from the FlatBuffer. + assert(monster->hp() == 80); + assert(monster->mana() == 150); // default + assert(monster->name()->str() == "MyMonster"); + + // Get and test a field of the FlatBuffer's `struct`. + auto pos = monster->pos(); + assert(pos); + assert(pos->z() == 3.0f); + (void)pos; + + // Get a test an element from the `inventory` FlatBuffer's `vector`. + auto inv = monster->inventory(); + assert(inv); + assert(inv->Get(9) == 9); + (void)inv; + + // Get and test the `weapons` FlatBuffers's `vector`. + std::string expected_weapon_names[] = { "Sword", "Axe" }; + short expected_weapon_damages[] = { 3, 5 }; + auto weps = monster->weapons(); + for (unsigned int i = 0; i < weps->size(); i++) { + assert(weps->Get(i)->name()->str() == expected_weapon_names[i]); + assert(weps->Get(i)->damage() == expected_weapon_damages[i]); + } + (void)expected_weapon_names; + (void)expected_weapon_damages; + + // Get and test the `Equipment` union (`equipped` field). + assert(monster->equipped_type() == Equipment_Weapon); + auto equipped = static_cast(monster->equipped()); + assert(equipped->name()->str() == "Axe"); + assert(equipped->damage() == 5); + (void)equipped; + + printf("The FlatBuffer was successfully created and verified!\n"); +} diff --git a/recipes/flatbuffers/all/test_package/test_package.cpp b/recipes/flatbuffers/all/test_package/test_package.cpp index 4f27cc9981717..b5846ed266944 100644 --- a/recipes/flatbuffers/all/test_package/test_package.cpp +++ b/recipes/flatbuffers/all/test_package/test_package.cpp @@ -36,12 +36,11 @@ int main(int /*argc*/, const char * /*argv*/ []) { } #ifndef FLATBUFFERS_HEADER_ONLY - const std::string filename("conanbuildinfo.cmake"); + const std::string filename("conanbuildinfo.txt"); if (flatbuffers::FileExists(filename.c_str())) { std::cout << "File " << filename << " exists.\n"; } else { std::cout << "File " << filename << " does not exist.\n"; - return EXIT_FAILURE; } #endif diff --git a/recipes/flatbuffers/all/test_v1_package/CMakeLists.txt b/recipes/flatbuffers/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2afd0f99c22b5 --- /dev/null +++ b/recipes/flatbuffers/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(FlatBuffers REQUIRED CONFIG) +if(TARGET flatbuffers::flatbuffers_shared) + set(FLATBUFFERS_TARGET flatbuffers::flatbuffers_shared) +else() + set(FLATBUFFERS_TARGET flatbuffers::flatbuffers) +endif() + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ${FLATBUFFERS_TARGET}) +if(FLATBUFFERS_HEADER_ONLY) + target_compile_definitions(${PROJECT_NAME} PRIVATE FLATBUFFERS_HEADER_ONLY) +endif() +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +if(NOT (CMAKE_CROSSCOMPILING AND FLATBUFFERS_HEADER_ONLY)) # due to missing package id of build requirement if header_only + add_executable(sample_binary ../test_package/sample_binary.cpp) + target_link_libraries(sample_binary PRIVATE ${FLATBUFFERS_TARGET}) + target_compile_features(sample_binary PRIVATE cxx_std_11) + + set(MONSTER_GENERATED_HEADER ${CMAKE_CURRENT_BINARY_DIR}/monster_generated.h) + set(MONSTER_FBS ${CMAKE_CURRENT_SOURCE_DIR}/../test_package/monster.fbs) + add_custom_command( + OUTPUT ${MONSTER_GENERATED_HEADER} + COMMAND $ + --cpp + -o ${CMAKE_CURRENT_BINARY_DIR} + ${MONSTER_FBS} + DEPENDS ${MONSTER_FBS} + ) + add_custom_target(generate_monster_header DEPENDS ${MONSTER_GENERATED_HEADER}) + add_dependencies(sample_binary generate_monster_header) + target_include_directories(sample_binary PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +endif() diff --git a/recipes/flatbuffers/all/test_v1_package/conanfile.py b/recipes/flatbuffers/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..91ff65abd57aa --- /dev/null +++ b/recipes/flatbuffers/all/test_v1_package/conanfile.py @@ -0,0 +1,27 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + if hasattr(self, "settings_build") and tools.cross_building(self) and \ + not self.options["flatbuffers"].header_only: # due to missing package id of build requirement if header_only + self.build_requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.definitions["FLATBUFFERS_HEADER_ONLY"] = self.options["flatbuffers"].header_only + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) + self.run(os.path.join("bin", "sample_binary"), run_environment=True) diff --git a/recipes/flatbuffers/config.yml b/recipes/flatbuffers/config.yml index 5e3fdb16129e6..014a45840cfb2 100644 --- a/recipes/flatbuffers/config.yml +++ b/recipes/flatbuffers/config.yml @@ -1,6 +1,23 @@ ---- versions: - "1.11.0": + "22.12.06": + folder: all + "22.11.23": + folder: all + "22.10.26": + folder: all + "22.9.29": + folder: all + "22.9.24": + folder: all + "2.0.8": + folder: all + "2.0.6": + folder: all + "2.0.5": + folder: all + "2.0.0": folder: all "1.12.0": folder: all + "1.11.0": + folder: all diff --git a/recipes/flatbush/all/conandata.yml b/recipes/flatbush/all/conandata.yml new file mode 100644 index 0000000000000..3d50fc3bd1efd --- /dev/null +++ b/recipes/flatbush/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.1.0": + url: "https://github.com/chusitoo/flatbush/archive/refs/tags/v1.1.0.zip" + sha256: "3ef034110b0ea6f7514d3cdc362976e2a9ab321cc9e4b2c847167ad26df0c0f1" diff --git a/recipes/flatbush/all/conanfile.py b/recipes/flatbush/all/conanfile.py new file mode 100644 index 0000000000000..c9dd4bc6e1a67 --- /dev/null +++ b/recipes/flatbush/all/conanfile.py @@ -0,0 +1,25 @@ +from conans import ConanFile, tools + +class FlatbushConan(ConanFile): + name = "flatbush" + license = "MIT" + homepage = "https://github.com/chusitoo/flatbush" + description = "Flatbush for C++" + topics = ("header-only", "flatbush", "r-tree", "hilbert", "zero-copy", "spatial-index") + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "compiler", "build_type", "arch" + no_copy_source = True + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True) + + def package(self): + self.copy(pattern="LICENSE", dst="licenses") + self.copy(pattern="flatbush.h", dst="include") + + def package_id(self): + self.info.header_only() + + def package_info(self): + if not tools.valid_min_cppstd(self, "20"): + self.cpp_info.defines = ["FLATBUSH_SPAN"] diff --git a/recipes/flatbush/all/test_package/CMakeLists.txt b/recipes/flatbush/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6ad4f7bcfdd6b --- /dev/null +++ b/recipes/flatbush/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.12) + +project(test_package VERSION 1.0.0 LANGUAGES CXX) +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) +find_package(flatbush CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} "test_package.cpp") + +target_link_libraries(${PROJECT_NAME} flatbush::flatbush) + +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/flatbush/all/test_package/conanfile.py b/recipes/flatbush/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5b0ef1df32f11 --- /dev/null +++ b/recipes/flatbush/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +from conans.tools import Version +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/flatbush/all/test_package/test_package.cpp b/recipes/flatbush/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..36860193e4ed8 --- /dev/null +++ b/recipes/flatbush/all/test_package/test_package.cpp @@ -0,0 +1,33 @@ +/* +MIT License + +Copyright (c) 2021 Alex Emirov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "flatbush.h" + +int main(int argc, char** argv) +{ + flatbush::FlatbushBuilder wBuilder; + wBuilder.add({ 0, 0, 0, 0 }); + auto wIndex = wBuilder.finish(); + auto wIds = wIndex.search({ 0, 0, 1, 1 }); +} diff --git a/recipes/flatbush/config.yml b/recipes/flatbush/config.yml new file mode 100644 index 0000000000000..11b7aff3a5ac4 --- /dev/null +++ b/recipes/flatbush/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.0": + folder: "all" diff --git a/recipes/flatc/all/conanfile.py b/recipes/flatc/all/conanfile.py index 74aaf1cb623cc..0968794e0610f 100644 --- a/recipes/flatc/all/conanfile.py +++ b/recipes/flatc/all/conanfile.py @@ -12,7 +12,7 @@ class FlatcConan(ConanFile): homepage = "http://google.github.io/flatbuffers/" topics = ("conan", "flatbuffers", "serialization", "rpc", "json-parser", "installer") description = "Memory Efficient Serialization Library" - settings = "os_build", "arch_build" + settings = "os", "arch" exports_sources = ["CMakeLists.txt","patches/**"] generators = "cmake" @@ -50,7 +50,7 @@ def build(self): def package(self): self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - extension = ".exe" if self.settings.os_build == "Windows" else "" + extension = ".exe" if self.settings.os == "Windows" else "" bin_dir = os.path.join(self._build_subfolder, "bin") self.copy(pattern="flatc" + extension, dst="bin", src=bin_dir) self.copy(pattern="flathash" + extension, dst="bin", src=bin_dir) diff --git a/recipes/flatc/all/test_package/conanfile.py b/recipes/flatc/all/test_package/conanfile.py index 2db80dfce5d0e..ab7f129616778 100644 --- a/recipes/flatc/all/test_package/conanfile.py +++ b/recipes/flatc/all/test_package/conanfile.py @@ -1,4 +1,4 @@ -from conans import ConanFile, CMake +from conans import ConanFile, CMake, tools import os @@ -6,11 +6,16 @@ class TestPackageConan(ConanFile): settings = "os", "arch" generators = "cmake", "cmake_find_package" + def build_requirements(self): + if tools.cross_building(self.settings): + self.build_requires(str(self.requires["flatc"])) + def build(self): cmake = CMake(self) cmake.configure() cmake.build(target="flatbuffers") def test(self): - self.run("flatc --version", run_environment=True) - self.run("flathash fnv1_16 conan", run_environment=True) + if not tools.cross_building(self, skip_x64_x86=True): + self.run("flatc --version", run_environment=True) + self.run("flathash fnv1_16 conan", run_environment=True) diff --git a/recipes/flatcc/all/conandata.yml b/recipes/flatcc/all/conandata.yml index 66d44b5b9fb85..f71d236804bce 100644 --- a/recipes/flatcc/all/conandata.yml +++ b/recipes/flatcc/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "0.6.1": + url: "https://github.com/dvidelabs/flatcc/archive/v0.6.1.tar.gz" + sha256: "2533c2f1061498499f15acc7e0937dcf35bc68e685d237325124ae0d6c600c2b" "0.6.0": - sha256: a92da3566d11e19bb807a83554b1a2c644a5bd91c9d9b088514456bb56e1c666 - url: https://github.com/dvidelabs/flatcc/archive/v0.6.0.tar.gz + url: "https://github.com/dvidelabs/flatcc/archive/v0.6.0.tar.gz" + sha256: "a92da3566d11e19bb807a83554b1a2c644a5bd91c9d9b088514456bb56e1c666" diff --git a/recipes/flatcc/all/conanfile.py b/recipes/flatcc/all/conanfile.py index ab5e2882412dd..09f5cab415518 100644 --- a/recipes/flatcc/all/conanfile.py +++ b/recipes/flatcc/all/conanfile.py @@ -1,14 +1,18 @@ -import os from conans import CMake, ConanFile, tools from conans.errors import ConanInvalidConfiguration +import os +import functools + +required_conan_version = ">=1.33.0" class FlatccConan(ConanFile): name = "flatcc" description = "C language binding for Flatbuffers, an efficient cross platform serialization library" - topics = ("conan", "flatbuffers", "serialization") + license = "Apache-2.0" + topics = ("flatbuffers", "serialization") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/dvidelabs/flatcc" - license = "Apache-2.0" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "portable": [True, False], @@ -33,13 +37,9 @@ class FlatccConan(ConanFile): "fast_double": False, "ignore_const_condition": False } - settings = "os", "arch", "compiler", "build_type" generators = "cmake" exports_sources = ["CMakeLists.txt"] - _cmake = None - - @property def _source_subfolder(self): return "source_subfolder" @@ -53,43 +53,44 @@ def config_options(self): del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): if self.settings.os == "Windows": if self.settings.compiler == "Visual Studio" and self.options.shared: #Building flatcc shared libs with Visual Studio is broken raise ConanInvalidConfiguration("Building flatcc libraries shared is not supported") - if self.settings.compiler == "gcc": + if tools.Version(self.version) == "0.6.0" and self.settings.compiler == "gcc": raise ConanInvalidConfiguration("Building flatcc with MinGW is not supported") - if self.options.shared: - del self.options.fPIC def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + @functools.lru_cache(1) def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["FLATCC_PORTABLE"] = self.options.portable - self._cmake.definitions["FLATCC_GNU_POSIX_MEMALIGN"] = self.options.gnu_posix_memalign - self._cmake.definitions["FLATCC_RTONLY"] = self.options.runtime_lib_only - self._cmake.definitions["FLATCC_INSTALL"] = True - self._cmake.definitions["FLATCC_COVERAGE"] = False - self._cmake.definitions["FLATCC_DEBUG_VERIFY"] = self.options.verify_assert - self._cmake.definitions["FLATCC_TRACE_VERIFY"] = self.options.verify_trace - self._cmake.definitions["FLATCC_REFLECTION"] = self.options.reflection - self._cmake.definitions["FLATCC_NATIVE_OPTIM"] = self.options.native_optim - self._cmake.definitions["FLATCC_FAST_DOUBLE"] = self.options.fast_double - self._cmake.definitions["FLATCC_IGNORE_CONST_COND"] = self.options.ignore_const_condition - self._cmake.definitions["FLATCC_TEST"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + cmake = CMake(self) + cmake.definitions["FLATCC_PORTABLE"] = self.options.portable + cmake.definitions["FLATCC_GNU_POSIX_MEMALIGN"] = self.options.gnu_posix_memalign + cmake.definitions["FLATCC_RTONLY"] = self.options.runtime_lib_only + cmake.definitions["FLATCC_INSTALL"] = True + cmake.definitions["FLATCC_COVERAGE"] = False + cmake.definitions["FLATCC_DEBUG_VERIFY"] = self.options.verify_assert + cmake.definitions["FLATCC_TRACE_VERIFY"] = self.options.verify_trace + cmake.definitions["FLATCC_REFLECTION"] = self.options.reflection + cmake.definitions["FLATCC_NATIVE_OPTIM"] = self.options.native_optim + cmake.definitions["FLATCC_FAST_DOUBLE"] = self.options.fast_double + cmake.definitions["FLATCC_IGNORE_CONST_COND"] = self.options.ignore_const_condition + cmake.definitions["FLATCC_TEST"] = False + cmake.definitions["FLATCC_ALLOW_WERROR"] = False + cmake.configure(build_folder=self._build_subfolder) + return cmake def build(self): cmake = self._configure_cmake() cmake.build() - def package(self): cmake = self._configure_cmake() cmake.install() diff --git a/recipes/flatcc/all/test_package/CMakeLists.txt b/recipes/flatcc/all/test_package/CMakeLists.txt index 965cebe862a97..3a1e3c2e0ae88 100644 --- a/recipes/flatcc/all/test_package/CMakeLists.txt +++ b/recipes/flatcc/all/test_package/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.1) project(flatcc_example) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(flatcc REQUIRED CONFIG) set(INC_DIR "${PROJECT_SOURCE_DIR}/include") set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") @@ -28,5 +30,4 @@ if (NOT MACOS_SIP_WORKAROUND) add_dependencies(monster gen_monster_fbs) endif() - -target_link_libraries(monster ${CONAN_LIBS}) +target_link_libraries(monster flatcc::flatcc) diff --git a/recipes/flatcc/all/test_package/conanfile.py b/recipes/flatcc/all/test_package/conanfile.py index 41cc0f44916ca..35aa66924f6ab 100644 --- a/recipes/flatcc/all/test_package/conanfile.py +++ b/recipes/flatcc/all/test_package/conanfile.py @@ -1,13 +1,17 @@ import os.path from conans import ConanFile, CMake, tools, RunEnvironment +from conans.errors import ConanException class FlatccTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): + if tools.cross_building(self): + return + env_build = RunEnvironment(self) with tools.environment_append(env_build.vars): cmake = CMake(self) @@ -22,6 +26,10 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): + if tools.cross_building(self): + bin_path = os.path.join(self.deps_cpp_info["flatcc"].rootpath, "bin", "flatcc") + if not os.path.isfile(bin_path) or not os.access(bin_path, os.X_OK): + raise ConanException("flatcc doesn't exist.") + else: bin_path = os.path.join(self.build_folder, "bin", "monster") self.run(bin_path, cwd=self.source_folder, run_environment=True) diff --git a/recipes/flatcc/config.yml b/recipes/flatcc/config.yml index f471d193a0d97..72628ee9e8a7f 100644 --- a/recipes/flatcc/config.yml +++ b/recipes/flatcc/config.yml @@ -1,3 +1,5 @@ versions: + 0.6.1: + folder: all 0.6.0: folder: all diff --git a/recipes/flecs/all/CMakeLists.txt b/recipes/flecs/all/CMakeLists.txt deleted file mode 100644 index 361b35d4c17d9..0000000000000 --- a/recipes/flecs/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/flecs/all/conandata.yml b/recipes/flecs/all/conandata.yml index 1239f5a1fd877..5eff0caa1c101 100644 --- a/recipes/flecs/all/conandata.yml +++ b/recipes/flecs/all/conandata.yml @@ -1,4 +1,25 @@ sources: + "3.1.1": + url: "https://github.com/SanderMertens/flecs/archive/refs/tags/v3.1.1.tar.gz" + sha256: "f31edfa258b90d086c311ad5ccc60e8e1ab0448aa10856d96e9e503cc15c1c63" + "3.1.0": + url: "https://github.com/SanderMertens/flecs/archive/refs/tags/v3.1.0.tar.gz" + sha256: "67e7cf4ff2abe661d9269b9d7f52ec7c39192f22e69bab638f27ef4337c12905" + "3.0.4": + url: "https://github.com/SanderMertens/flecs/archive/refs/tags/v3.0.4.tar.gz" + sha256: "370e2bf1bd9fd6dc79b515887e7f048be676b0d95e23d43b2c8b76a5e645c8f4" + "3.0.1": + url: "https://github.com/SanderMertens/flecs/archive/refs/tags/v3.0.1.tar.gz" + sha256: "a7c80dea0677721f83433623169cd4094c48270022c19adedac28331d546b539" + "2.4.8": + url: "https://github.com/SanderMertens/flecs/archive/refs/tags/v2.4.8.tar.gz" + sha256: "9a8040a197e4b5e032524bc7183f68faa7b2f759c67b983b40018a7726561cac" + "2.4.7": + url: "https://github.com/SanderMertens/flecs/archive/refs/tags/v2.4.7.tar.gz" + sha256: "ef3952fee5b83991fbd9aa77212c45171393b2dfd14001b2d1c7b97861934afa" + "2.4.6": + url: "https://github.com/SanderMertens/flecs/archive/refs/tags/v2.4.6.tar.gz" + sha256: "e74798d4b387c85272b05ee574d991cbe1fb844680a1fc3d68818a02b5f59299" "2.3.2": url: "https://github.com/SanderMertens/flecs/archive/v2.3.2.tar.gz" sha256: "ff2690953941b3f08d4e934e299fa8902e46ce8532edd176388d467ace33eebf" diff --git a/recipes/flecs/all/conanfile.py b/recipes/flecs/all/conanfile.py index b1188859e297c..b4d76faa5ed41 100644 --- a/recipes/flecs/all/conanfile.py +++ b/recipes/flecs/all/conanfile.py @@ -1,6 +1,11 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.scm import Version import os +required_conan_version = ">=1.53.0" + class FlecsConan(ConanFile): name = "flecs" @@ -13,16 +18,14 @@ class FlecsConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - exports_sources = "CMakeLists.txt" - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } def config_options(self): if self.settings.os == "Windows": @@ -30,41 +33,58 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["FLECS_STATIC_LIBS"] = not self.options.shared - self._cmake.definitions["FLECS_PIC"] = self.options.get_safe("fPIC", True) - self._cmake.definitions["FLECS_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["FLECS_DEVELOPER_WARNINGS"] = False - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) < "3.0.1": + tc.variables["FLECS_STATIC_LIBS"] = not self.options.shared + tc.variables["FLECS_SHARED_LIBS"] = self.options.shared + tc.variables["FLECS_DEVELOPER_WARNINGS"] = False + else: + tc.variables["FLECS_STATIC"] = not self.options.shared + tc.variables["FLECS_SHARED"] = self.options.shared + tc.variables["FLECS_PIC"] = self.options.get_safe("fPIC", True) + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "flecs" - self.cpp_info.names["cmake_find_package_multi"] = "flecs" - target_and_lib_name = "flecs" if self.options.shared else "flecs_static" - self.cpp_info.components["_flecs"].names["cmake_find_package"] = target_and_lib_name - self.cpp_info.components["_flecs"].names["cmake_find_package_multi"] = target_and_lib_name - self.cpp_info.components["_flecs"].libs = [target_and_lib_name] + suffix = "" if self.options.shared else "_static" + self.cpp_info.set_property("cmake_file_name", "flecs") + self.cpp_info.set_property("cmake_target_name", f"flecs::flecs{suffix}") + + # TODO: back to global scope once cmake_find_package* generators removed + self.cpp_info.components["_flecs"].libs = [f"flecs{suffix}"] if not self.options.shared: self.cpp_info.components["_flecs"].defines.append("flecs_STATIC") + if Version(self.version) >= "3.0.0": + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["_flecs"].system_libs.append("pthread") + elif self.settings.os == "Windows": + self.cpp_info.components["_flecs"].system_libs.extend(["wsock32", "ws2_32"]) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "flecs" + self.cpp_info.names["cmake_find_package_multi"] = "flecs" + self.cpp_info.components["_flecs"].names["cmake_find_package"] = f"flecs{suffix}" + self.cpp_info.components["_flecs"].names["cmake_find_package_multi"] = f"flecs{suffix}" + self.cpp_info.components["_flecs"].set_property("cmake_target_name", f"flecs::flecs{suffix}") diff --git a/recipes/flecs/all/test_package/CMakeLists.txt b/recipes/flecs/all/test_package/CMakeLists.txt index 0cf68bcd93a4f..fc32143d0f19f 100644 --- a/recipes/flecs/all/test_package/CMakeLists.txt +++ b/recipes/flecs/all/test_package/CMakeLists.txt @@ -1,15 +1,11 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(flecs REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -if(FLECS_SHARED) - target_link_libraries(${PROJECT_NAME} flecs::flecs) +if(TARGET flecs::flecs_static) + target_link_libraries(${PROJECT_NAME} PRIVATE flecs::flecs_static) else() - target_link_libraries(${PROJECT_NAME} flecs::flecs_static) + target_link_libraries(${PROJECT_NAME} PRIVATE flecs::flecs) endif() diff --git a/recipes/flecs/all/test_package/conanfile.py b/recipes/flecs/all/test_package/conanfile.py index 954ecce3d786a..0a6bc68712d90 100644 --- a/recipes/flecs/all/test_package/conanfile.py +++ b/recipes/flecs/all/test_package/conanfile.py @@ -1,18 +1,26 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) - cmake.definitions["FLECS_SHARED"] = self.options["flecs"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/flecs/all/test_package/test_package.c b/recipes/flecs/all/test_package/test_package.c index 647e56ca2c2f9..6b277544863db 100644 --- a/recipes/flecs/all/test_package/test_package.c +++ b/recipes/flecs/all/test_package/test_package.c @@ -12,7 +12,7 @@ int main() { ECS_COMPONENT(world, Position); - ecs_entity_t e = ecs_set(world, 0, EcsName, {"MyEntity"}); + ecs_entity_t e = ecs_new_id(world); ecs_set(world, e, Position, {10.0f, 20.0f}); const char *name = ecs_get_name(world, e); diff --git a/recipes/flecs/all/test_v1_package/CMakeLists.txt b/recipes/flecs/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/flecs/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/flecs/all/test_v1_package/conanfile.py b/recipes/flecs/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/flecs/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/flecs/config.yml b/recipes/flecs/config.yml index aee8de619ec30..dd4804a999874 100644 --- a/recipes/flecs/config.yml +++ b/recipes/flecs/config.yml @@ -1,3 +1,17 @@ versions: + "3.1.1": + folder: all + "3.1.0": + folder: all + "3.0.4": + folder: all + "3.0.1": + folder: all + "2.4.8": + folder: all + "2.4.7": + folder: all + "2.4.6": + folder: all "2.3.2": folder: all diff --git a/recipes/flex/all/conanfile.py b/recipes/flex/all/conanfile.py index c6677f2eebffc..9bfc21b1ff79c 100644 --- a/recipes/flex/all/conanfile.py +++ b/recipes/flex/all/conanfile.py @@ -1,91 +1,95 @@ from conans import ConanFile, AutoToolsBuildEnvironment, tools from conans.errors import ConanInvalidConfiguration -import contextlib +import functools import os +required_conan_version = ">=1.33.0" + class FlexConan(ConanFile): name = "flex" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/westes/flex" description = "Flex, the fast lexical analyzer generator" - topics = ("conan", "flex", "lex", "lexer", "lexical analyzer generator") - license = "BSD-2-Clause" + topics = ("lex", "lexer", "lexical analyzer generator") + license = "BSD-2-Clause" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _autotools = None + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } @property def _source_subfolder(self): return "source_subfolder" def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def requirements(self): - self.requires("m4/1.4.18") + self.requires("m4/1.4.19") + + def build_requirements(self): + self.build_requires("m4/1.4.19") + if hasattr(self, "settings_build") and tools.cross_building(self): + self.build_requires(f"{self.name}/{self.version}") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd if self.settings.os == "Windows": raise ConanInvalidConfiguration("Flex package is not compatible with Windows. Consider using winflexbison instead.") + @functools.lru_cache(1) def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self) + autotools = AutoToolsBuildEnvironment(self) yes_no = lambda v: "yes" if v else "no" configure_args = [ "--enable-shared={}".format(yes_no(self.options.shared)), "--enable-static={}".format(not yes_no(self.options.shared)), "--disable-nls", + "--disable-bootstrap", "HELP2MAN=/bin/true", "M4=m4", - ] - - if self.settings.os == "Linux": # https://github.com/westes/flex/issues/247 - configure_args.extend(["ac_cv_func_malloc_0_nonnull=yes", "ac_cv_func_realloc_0_nonnull=yes"]) + "ac_cv_func_malloc_0_nonnull=yes", "ac_cv_func_realloc_0_nonnull=yes", # https://github.com/easybuilders/easybuild-easyconfigs/pull/5792 - configure_args.append("ac_cv_func_reallocarray=no") - - # stage1flex must be built on native arch: https://github.com/westes/flex/issues/78 - # This requires flex to depend on itself. - # conan does not support this (currently), so cross build of flex is not possible atm - - self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) - return self._autotools + "ac_cv_func_reallocarray=no", + ] - @contextlib.contextmanager - def _build_context(self): - env = {} - # FIXME: when conan receives full cross building support, fetch CC_FOR_BUILD from build context - if tools.get_env("CC") and not tools.get_env("CC_FOR_BUILD"): - env["CC_FOR_BUILD"] = tools.get_env("CC") - with tools.environment_append(env): - yield + autotools.configure(args=configure_args, configure_dir=self._source_subfolder) + return autotools def build(self): - if tools.cross_building(self.settings, skip_x64_x86=True): - raise ConanInvalidConfiguration("This recipe does not support cross building atm (missing conan support)") - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() + autotools = self._configure_autotools() + autotools.make() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + autotools = self._configure_autotools() + autotools.install() tools.rmdir(os.path.join(self.package_folder, "share")) - os.unlink(os.path.join(self.package_folder, "lib", "libfl.la")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") def package_info(self): self.cpp_info.libs = ["fl"] - self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) + + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) + + lex_path = os.path.join(bindir, "flex").replace("\\", "/") + self.output.info("Setting LEX environment variable: {}".format(lex_path)) + self.env_info.LEX = lex_path diff --git a/recipes/flex/all/test_package/CMakeLists.txt b/recipes/flex/all/test_package/CMakeLists.txt index 78e7092647184..f1594602f9e1c 100644 --- a/recipes/flex/all/test_package/CMakeLists.txt +++ b/recipes/flex/all/test_package/CMakeLists.txt @@ -1,12 +1,20 @@ cmake_minimum_required(VERSION 3.1) project(test_package) +# Find FLEX before `conanbuildinfo.cmake` because that file will let `find_program` +# look for executables in host packages (let's hope conan 2.0 fixes this) +find_package(FLEX REQUIRED) + include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(FLEX REQUIRED) flex_target(flex_scanner basic_nr.l "${PROJECT_BINARY_DIR}/basic_nr.cpp") add_executable(${PROJECT_NAME} basic_nr.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_include_directories(${PROJECT_NAME} PRIVATE ${FLEX_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${FLEX_LIBRARIES}) + +add_executable(test_yywrap test_yywrap.c) +target_link_libraries(test_yywrap PRIVATE ${FLEX_LIBRARIES}) diff --git a/recipes/flex/all/test_package/basic_nr.l b/recipes/flex/all/test_package/basic_nr.l index 51c6c2b67b0cb..71fa5d65f82c6 100644 --- a/recipes/flex/all/test_package/basic_nr.l +++ b/recipes/flex/all/test_package/basic_nr.l @@ -1,20 +1,20 @@ /* * This file is part of flex. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -86,4 +86,4 @@ int main( int argc, const char *argv[]) { while(lexer->yylex() != 0) ; return 0; - } +} diff --git a/recipes/flex/all/test_package/conanfile.py b/recipes/flex/all/test_package/conanfile.py index 800e6596ba770..ea2fd2ff6d920 100644 --- a/recipes/flex/all/test_package/conanfile.py +++ b/recipes/flex/all/test_package/conanfile.py @@ -4,23 +4,37 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake" + test_type = "explicit" - def build(self): - if not tools.cross_building(self.settings, skip_x64_x86=True): - self.run("flex --version", run_environment=True) + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + def build(self): + if not hasattr(self, "settings_build"): + # Only test location of flex executable when not cross building flex_bin = tools.which("flex") if not flex_bin.startswith(self.deps_cpp_info["flex"].rootpath): raise ConanException("Wrong flex executable captured") + + if not tools.cross_building(self, skip_x64_x86=True) or hasattr(self, "settings_build"): + self.run("flex --version", run_environment=not hasattr(self, "settings_build")) + + print(os.environ["PATH"]) cmake = CMake(self) cmake.definitions["FLEX_ROOT"] = self.deps_cpp_info["flex"].rootpath cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings, skip_x64_x86=True): + if not tools.cross_building(self, skip_x64_x86=True): bin_path = os.path.join("bin", "test_package") src = os.path.join(self.source_folder, "basic_nr.txt") self.run("{} {}".format(bin_path, src), run_environment=True) + + test_yywrap = os.path.join("bin", "test_yywrap") + self.run(test_yywrap, run_environment=True) diff --git a/recipes/flex/all/test_package/test_yywrap.c b/recipes/flex/all/test_package/test_yywrap.c new file mode 100644 index 0000000000000..c98a000f1dc22 --- /dev/null +++ b/recipes/flex/all/test_package/test_yywrap.c @@ -0,0 +1,10 @@ +#include + +int yywrap(void); +int yylex(void) { + return 0; +} + +int main() { + printf("yywrap() returned: %d.\n", yywrap()); +} diff --git a/recipes/geographiclib/all/CMakeLists.txt b/recipes/flint/all/CMakeLists.txt similarity index 100% rename from recipes/geographiclib/all/CMakeLists.txt rename to recipes/flint/all/CMakeLists.txt diff --git a/recipes/flint/all/conandata.yml b/recipes/flint/all/conandata.yml new file mode 100644 index 0000000000000..ca7fe5127f757 --- /dev/null +++ b/recipes/flint/all/conandata.yml @@ -0,0 +1,18 @@ +sources: + "2.8.1": + url: "https://github.com/wbhart/flint2/archive/refs/tags/v2.8.1.tar.gz" + sha256: "93c4d6acd46d7a4357a2abe313e5f0625fa7e94a1a0e53048f9066f55a7acd49" + "2.7.1": + url: "https://github.com/wbhart/flint2/archive/refs/tags/v2.7.1.tar.gz" + sha256: "bcadc2252e61092a9b3a3198b337e20abeac56078eaa19793ab99ff7a987efb7" +patches: + "2.8.1": + - patch_file: "patches/0001-cmake-2.8.1.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-msvc-alloca.patch" + base_path: "source_subfolder" + "2.7.1": + - patch_file: "patches/0001-cmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-msvc-alloca.patch" + base_path: "source_subfolder" diff --git a/recipes/flint/all/conanfile.py b/recipes/flint/all/conanfile.py new file mode 100644 index 0000000000000..29a0ae933dc5f --- /dev/null +++ b/recipes/flint/all/conanfile.py @@ -0,0 +1,91 @@ +import os + +from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.33.0" + + +class FlintConan(ConanFile): + name = "flint" + description = "FLINT (Fast Library for Number Theory)" + license = "LGPL-2.1-or-later" + topics = ("math", "numerical") + homepage = "https://www.flintlib.org" + url = "https://github.com/conan-io/conan-center-index" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("gmp/6.2.1") + self.requires("mpfr/4.1.0") + if self.settings.compiler == "Visual Studio": + self.requires("pthreads4w/3.0.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_TESTING"] = False + self._cmake.definitions["BUILD_DOCS"] = False + self._cmake.definitions["WITH_NTL"] = False + # IPO/LTO breaks clang builds + self._cmake.definitions["IPO_SUPPORTED"] = False + # No BLAS yet + self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_CBLAS"] = True + # handle run in a cross-build + if tools.cross_building(self): + self._cmake.definitions["FLINT_USES_POPCNT_EXITCODE"] = "1" + self._cmake.definitions["FLINT_USES_POPCNT_EXITCODE__TRYRUN_OUTPUT"] = "" + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "libflint" + self.cpp_info.names["cmake_find_package_multi"] = "libflint" + + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs = ["pthread", "m"] + + self.cpp_info.includedirs.append(os.path.join("include", "flint")) + self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/flint/all/patches/0001-cmake-2.8.1.patch b/recipes/flint/all/patches/0001-cmake-2.8.1.patch new file mode 100644 index 0000000000000..bfb50ddd978c7 --- /dev/null +++ b/recipes/flint/all/patches/0001-cmake-2.8.1.patch @@ -0,0 +1,63 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2616d0669..6fa4cf5f7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -46,7 +46,10 @@ endif() + # pthread configuration + + if(MSVC) +- find_package(PThreads REQUIRED) ++ #find_package(PThreads REQUIRED) ++ set(PThreads_FOUND TRUE) ++ set(PThreads_LIBRARIES "${CONAN_LIBS_PTHREADS4W}") ++ set(PThreads_INCLUDE_DIRS "${CONAN_INCLUDE_DIRS_PTHREADS4W}") + set(FLINT_USES_PTHREAD ON CACHE BOOL "Use POSIX Threads.") + else() + option(CMAKE_THREAD_PREFER_PTHREAD "Prefer pthreads" yes) +@@ -101,9 +104,9 @@ set(HEADERS + ) + + foreach (build_dir IN LISTS BUILD_DIRS TEMPLATE_DIRS) +- file(GLOB TEMP RELATIVE "${CMAKE_SOURCE_DIR}" "${build_dir}/*.c") ++ file(GLOB TEMP RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${build_dir}/*.c") + list(APPEND SOURCES ${TEMP}) +- file(GLOB TEMP RELATIVE "${CMAKE_SOURCE_DIR}" "${build_dir}/*.h") ++ file(GLOB TEMP RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${build_dir}/*.h") + list(APPEND HEADERS ${TEMP}) + endforeach () + +@@ -112,7 +115,7 @@ execute_process( + " + from os.path import join + +-with open(join('${CMAKE_SOURCE_DIR}','qadic', 'CPimport.txt')) as fin: ++with open(join('${CMAKE_CURRENT_SOURCE_DIR}','qadic', 'CPimport.txt')) as fin: + with open('CPimport.h.in', 'w+') as fout: + while True: + l = fin.readline() +@@ -212,14 +215,14 @@ endif() + set(TEMP ${HEADERS}) + set(HEADERS ) + foreach(header IN LISTS TEMP) +- if(EXISTS ${CMAKE_SOURCE_DIR}/${header}) ++ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${header}) + list(APPEND HEADERS ${header}) + else() +- list(APPEND HEADERS ${CMAKE_BINARY_DIR}/${header}) ++ list(APPEND HEADERS ${CMAKE_CURRENT_BINARY_DIR}/${header}) + endif() + endforeach() + +-file(GLOB TEMP "${CMAKE_SOURCE_DIR}/*.h") ++file(GLOB TEMP "${CMAKE_CURRENT_SOURCE_DIR}/*.h") + list(APPEND HEADERS ${TEMP}) + + add_library(flint ${SOURCES}) +@@ -236,6 +239,7 @@ endif() + target_include_directories(flint PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} ${GMP_INCLUDE_DIRS} ${MPFR_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} ${PThreads_INCLUDE_DIRS} ++ ${CMAKE_BINARY_DIR} + ${NTL_INCLUDE_DIR} + ) + diff --git a/recipes/flint/all/patches/0001-cmake.patch b/recipes/flint/all/patches/0001-cmake.patch new file mode 100644 index 0000000000000..9e5780c52e94b --- /dev/null +++ b/recipes/flint/all/patches/0001-cmake.patch @@ -0,0 +1,63 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 11ff789a7..80a45f90f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -46,7 +46,10 @@ endif() + # pthread configuration + + if(MSVC) +- find_package(PThreads REQUIRED) ++ #find_package(PThreads REQUIRED) ++ set(PThreads_FOUND TRUE) ++ set(PThreads_LIBRARIES "${CONAN_LIBS_PTHREADS4W}") ++ set(PThreads_INCLUDE_DIRS "${CONAN_INCLUDE_DIRS_PTHREADS4W}") + set(FLINT_USES_PTHREAD ON CACHE BOOL "Use POSIX Threads.") + else() + option(CMAKE_THREAD_PREFER_PTHREAD "Prefer pthreads" yes) +@@ -99,9 +102,9 @@ set(HEADERS + ) + + foreach (build_dir IN LISTS BUILD_DIRS TEMPLATE_DIRS) +- file(GLOB TEMP RELATIVE "${CMAKE_SOURCE_DIR}" "${build_dir}/*.c") ++ file(GLOB TEMP RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${build_dir}/*.c") + list(APPEND SOURCES ${TEMP}) +- file(GLOB TEMP RELATIVE "${CMAKE_SOURCE_DIR}" "${build_dir}/*.h") ++ file(GLOB TEMP RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${build_dir}/*.h") + list(APPEND HEADERS ${TEMP}) + endforeach () + +@@ -110,7 +113,7 @@ execute_process( + " + from os.path import join + +-with open(join('${CMAKE_SOURCE_DIR}','qadic', 'CPimport.txt')) as fin: ++with open(join('${CMAKE_CURRENT_SOURCE_DIR}','qadic', 'CPimport.txt')) as fin: + with open('CPimport.h.in', 'w+') as fout: + while True: + l = fin.readline() +@@ -210,14 +213,14 @@ endif() + set(TEMP ${HEADERS}) + set(HEADERS ) + foreach(header IN LISTS TEMP) +- if(EXISTS ${CMAKE_SOURCE_DIR}/${header}) ++ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${header}) + list(APPEND HEADERS ${header}) + else() +- list(APPEND HEADERS ${CMAKE_BINARY_DIR}/${header}) ++ list(APPEND HEADERS ${CMAKE_CURRENT_BINARY_DIR}/${header}) + endif() + endforeach() + +-file(GLOB TEMP "${CMAKE_SOURCE_DIR}/*.h") ++file(GLOB TEMP "${CMAKE_CURRENT_SOURCE_DIR}/*.h") + list(APPEND HEADERS ${TEMP}) + + add_library(flint ${SOURCES}) +@@ -234,6 +237,7 @@ endif() + target_include_directories(flint PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} ${GMP_INCLUDE_DIRS} ${MPFR_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} ${PThreads_INCLUDE_DIRS} ++ ${CMAKE_BINARY_DIR} + ${NTL_INCLUDE_DIR} + ) + diff --git a/recipes/flint/all/patches/0002-msvc-alloca.patch b/recipes/flint/all/patches/0002-msvc-alloca.patch new file mode 100644 index 0000000000000..5e616ee7e08a3 --- /dev/null +++ b/recipes/flint/all/patches/0002-msvc-alloca.patch @@ -0,0 +1,13 @@ +diff --git a/flint.h b/flint.h +index f4e98b2e9..62ac39222 100644 +--- a/flint.h ++++ b/flint.h +@@ -26,7 +26,7 @@ + /* MinGW and FreeBSD have alloca, but not alloca.h */ + #include + #endif +-#if defined(__MINGW32__) ++#if defined(__MINGW32__) || defined(_MSC_VER) + #include /* for alloca on MinGW */ + #endif + #include "limits.h" diff --git a/recipes/flint/all/test_package/CMakeLists.txt b/recipes/flint/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e0200ac7628d3 --- /dev/null +++ b/recipes/flint/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libflint REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} libflint::libflint) diff --git a/recipes/flint/all/test_package/conanfile.py b/recipes/flint/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b6a26067f365d --- /dev/null +++ b/recipes/flint/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os + +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/flint/all/test_package/test_package.cpp b/recipes/flint/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..6ce46f2b7921e --- /dev/null +++ b/recipes/flint/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + flint_printf("OK\n"); + return 0; +} diff --git a/recipes/flint/config.yml b/recipes/flint/config.yml new file mode 100644 index 0000000000000..fed2a63c4da2b --- /dev/null +++ b/recipes/flint/config.yml @@ -0,0 +1,5 @@ +versions: + "2.8.1": + folder: all + "2.7.1": + folder: all diff --git a/recipes/fltk/all/CMakeLists.txt b/recipes/fltk/all/CMakeLists.txt new file mode 100644 index 0000000000000..60dd71d7363c3 --- /dev/null +++ b/recipes/fltk/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8) +project(cmake_wrapper) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/fltk/all/conandata.yml b/recipes/fltk/all/conandata.yml new file mode 100644 index 0000000000000..1b3f085545004 --- /dev/null +++ b/recipes/fltk/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "1.3.8": + url: "https://github.com/fltk/fltk/archive/refs/tags/release-1.3.8.tar.gz" + sha256: "abddf697bf1b0a59462a0d2ec57557f4bfb9c634627e6fa50d8c664112642811" + +patches: + "1.3.8": + - base_path: "source_subfolder" + patch_file: "patches/1.3.8-0001-remove-fluid.patch" + - base_path: "source_subfolder" + patch_file: "patches/1.3.8-0002-fix-resources.patch" + - base_path: "source_subfolder" + patch_file: "patches/1.3.8-0003-build-static-only-on-static.patch" diff --git a/recipes/fltk/all/conanfile.py b/recipes/fltk/all/conanfile.py new file mode 100644 index 0000000000000..f086bb805af59 --- /dev/null +++ b/recipes/fltk/all/conanfile.py @@ -0,0 +1,118 @@ +from conans import CMake, ConanFile, tools +import os + +required_conan_version = ">=1.43.0" + +class FltkConan(ConanFile): + name = "fltk" + description = "Fast Light Toolkit is a cross-platform C++ GUI toolkit" + topics = ("fltk", "gui") + homepage = "https://www.fltk.org" + url = "https://github.com/conan-io/conan-center-index" + license = "LGPL-2.0-custom" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_gl": [True, False], + "with_threads": [True, False], + "with_gdiplus": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_gl": True, + "with_threads": True, + "with_gdiplus": True, + } + generators = "cmake", "cmake_find_package_multi" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + else: + del self.options.with_gdiplus + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("zlib/1.2.12") + self.requires("libjpeg/9d") + self.requires("libpng/1.6.37") + if self.settings.os == "Linux": + self.requires("opengl/system") + self.requires("glu/system") + self.requires("fontconfig/2.13.93") + self.requires("xorg/system") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions['OPTION_BUILD_SHARED_LIBS'] = self.options.shared + cmake.definitions['FLTK_BUILD_TEST'] = False + cmake.definitions['FLTK_BUILD_EXAMPLES'] = False + cmake.definitions['OPTION_USE_GL'] = self.options.with_gl + cmake.definitions['OPTION_USE_THREADS'] = self.options.with_threads + cmake.definitions['OPTION_BUILD_HTML_DOCUMENTATION'] = False + cmake.definitions['OPTION_BUILD_PDF_DOCUMENTATION'] = False + cmake.configure() + return cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "FLTK.framework")) + tools.rmdir(os.path.join(self.package_folder, "CMake")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "fltk-config*") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "fltk") + self.cpp_info.set_property("cmake_target_name", "fltk::fltk") + + self.cpp_info.names["cmake_find_package"] = "fltk" + self.cpp_info.names["cmake_find_package_multi"] = "fltk" + + if self.options.shared and self.settings.os == "Windows": + self.cpp_info.defines.append("FL_DLL") + self.cpp_info.libs = tools.collect_libs(self) + if self.settings.os in ("Linux", "FreeBSD"): + if self.options.with_threads: + self.cpp_info.system_libs.extend(['pthread', 'dl']) + if self.options.with_gl: + self.cpp_info.system_libs.extend(['GL', 'GLU']) + if self.settings.os == "Macos": + self.cpp_info.frameworks = ['Cocoa', 'OpenGL', 'IOKit', 'Carbon', 'CoreFoundation', 'CoreVideo'] + if self.settings.os == "Windows": + self.cpp_info.system_libs = [ + "gdi32", + "imm32", + "msimg32", + "ole32", + "oleaut32", + "uuid", + ] + if self.options.get_safe("with_gdiplus"): + self.cpp_info.system_libs.append("gdiplus") diff --git a/recipes/fltk/all/patches/1.3.8-0001-remove-fluid.patch b/recipes/fltk/all/patches/1.3.8-0001-remove-fluid.patch new file mode 100644 index 0000000000000..051b9e9f6be9c --- /dev/null +++ b/recipes/fltk/all/patches/1.3.8-0001-remove-fluid.patch @@ -0,0 +1,20 @@ +diff --git a/CMake/export.cmake b/CMake/export.cmake +index 6e8bc5d..5118cb4 100644 +--- a/CMake/export.cmake ++++ b/CMake/export.cmake +@@ -20,6 +20,7 @@ + ####################################################################### + + # Set the fluid executable path ++if (0) + if (CMAKE_CROSSCOMPILING) + find_file(FLUID_PATH + NAMES fluid fluid.exe +@@ -37,6 +38,7 @@ else () + set (FLTK_FLUID_EXECUTABLE fluid) + set (FLUID fluid) # export + endif (CMAKE_CROSSCOMPILING) ++endif() + + add_subdirectory(src) + diff --git a/recipes/fltk/all/patches/1.3.8-0002-fix-resources.patch b/recipes/fltk/all/patches/1.3.8-0002-fix-resources.patch new file mode 100644 index 0000000000000..ef15cfc93c479 --- /dev/null +++ b/recipes/fltk/all/patches/1.3.8-0002-fix-resources.patch @@ -0,0 +1,78 @@ +diff --git a/CMake/options.cmake b/CMake/options.cmake +index ddd650f..28c4190 100644 +--- a/CMake/options.cmake ++++ b/CMake/options.cmake +@@ -327,12 +327,22 @@ endif (debug_threads) + unset (debug_threads) + + ####################################################################### ++if (0) ++ + option (OPTION_USE_SYSTEM_ZLIB "use system zlib" ON) + + if (OPTION_USE_SYSTEM_ZLIB) + include (FindZLIB) + endif (OPTION_USE_SYSTEM_ZLIB) + ++else() ++ ++option (OPTION_USE_SYSTEM_ZLIB "use system zlib" ON) ++find_package(ZLIB) ++set (FLTK_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) ++ ++endif() ++ + if (ZLIB_FOUND) + set (FLTK_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) + include_directories (${ZLIB_INCLUDE_DIRS}) +@@ -352,6 +362,8 @@ endif (ZLIB_FOUND) + set (HAVE_LIBZ 1) + + ####################################################################### ++if (0) ++ + if (APPLE) + option (OPTION_USE_SYSTEM_LIBJPEG "use system libjpeg" OFF) + else () +@@ -377,9 +389,22 @@ else () + set (FLTK_BUILTIN_JPEG_FOUND TRUE) + endif (JPEG_FOUND) + ++else() ++ ++option (OPTION_USE_SYSTEM_LIBJPEG "use system libjpeg" ON) ++find_package(JPEG REQUIRED) ++set (FLTK_JPEG_LIBRARIES ${JPEG_LIBRARIES}) ++set (FLTK_BUILTIN_JPEG_FOUND FALSE) ++ ++endif() ++ ++ ++ + set (HAVE_LIBJPEG 1) + + ####################################################################### ++if(0) ++ + if (APPLE) + option (OPTION_USE_SYSTEM_LIBPNG "use system libpng" OFF) + else () +@@ -409,6 +434,18 @@ else() + set (FLTK_BUILTIN_PNG_FOUND TRUE) + endif (PNG_FOUND) + ++else() ++ ++option (OPTION_USE_SYSTEM_LIBPNG "use system libpng" ON) ++find_package(PNG REQUIRED) ++set (FLTK_PNG_LIBRARIES ${PNG_LIBRARIES}) ++set (FLTK_BUILTIN_PNG_FOUND FALSE) ++set (HAVE_PNG_H 1) ++set (HAVE_PNG_GET_VALID 1) ++set (HAVE_PNG_SET_TRNS_TO_ALPHA 1) ++ ++endif() ++ + set (HAVE_LIBPNG 1) + + ####################################################################### diff --git a/recipes/fltk/all/patches/1.3.8-0003-build-static-only-on-static.patch b/recipes/fltk/all/patches/1.3.8-0003-build-static-only-on-static.patch new file mode 100644 index 0000000000000..382aef3e36be6 --- /dev/null +++ b/recipes/fltk/all/patches/1.3.8-0003-build-static-only-on-static.patch @@ -0,0 +1,20 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index d153b1c..ef5a492 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -303,6 +303,7 @@ if (USE_XFT) + endif (LIB_fontconfig) + endif (USE_XFT) + ++if (NOT OPTION_BUILD_SHARED_LIBS) + ####################################################################### + + FL_ADD_LIBRARY (fltk STATIC "${STATIC_FILES}") +@@ -342,6 +343,7 @@ if (OPENGL_FOUND) + FL_ADD_LIBRARY (fltk_gl STATIC "${GLCPPFILES}") + target_link_libraries (fltk_gl fltk ${OPENGL_LIBRARIES}) + endif (OPENGL_FOUND) ++endif (NOT OPTION_BUILD_SHARED_LIBS) + + ####################################################################### + # Build shared libraries (optional) diff --git a/recipes/fltk/all/test_package/CMakeLists.txt b/recipes/fltk/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a163bc26a443b --- /dev/null +++ b/recipes/fltk/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fltk REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} fltk::fltk) diff --git a/recipes/fltk/all/test_package/conanfile.py b/recipes/fltk/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a500b98343c74 --- /dev/null +++ b/recipes/fltk/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fltk/all/test_package/test_package.cpp b/recipes/fltk/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..0f01ca1d8f94f --- /dev/null +++ b/recipes/fltk/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include "FL/Fl.H" + +#include + +int main(int argc, char* argv[]) +{ + std::cout << "fltk version : " << Fl::version() << std::endl; + std::cout << "fltk api version : " << Fl::api_version() << std::endl; + std::cout << "fltk abi version : " << Fl::abi_version() << std::endl; + + return 0; +} diff --git a/recipes/fltk/config.yml b/recipes/fltk/config.yml new file mode 100644 index 0000000000000..76eba86fa7f6d --- /dev/null +++ b/recipes/fltk/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3.8": + folder: "all" diff --git a/recipes/fmt/all/CMakeLists.txt b/recipes/fmt/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/fmt/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/fmt/all/conandata.yml b/recipes/fmt/all/conandata.yml index a47b129ee53c8..226084f79cbb0 100644 --- a/recipes/fmt/all/conandata.yml +++ b/recipes/fmt/all/conandata.yml @@ -1,53 +1,25 @@ sources: - "5.3.0": - sha256: defa24a9af4c622a7134076602070b45721a43c51598c8456ec6f2c4dbb51c89 - url: https://github.com/fmtlib/fmt/archive/5.3.0.tar.gz - "6.0.0": - sha256: f1907a58d5e86e6c382e51441d92ad9e23aea63827ba47fd647eacc0d3a16c78 - url: https://github.com/fmtlib/fmt/archive/6.0.0.tar.gz - "6.1.0": - sha256: 8fb84291a7ed6b4db4769115b57fa56d5467b1ab8c3ba5bdf78c820e4bd17944 - url: https://github.com/fmtlib/fmt/archive/6.1.0.tar.gz - "6.1.1": - sha256: bf4e50955943c1773cc57821d6c00f7e2b9e10eb435fafdd66739d36056d504e - url: https://github.com/fmtlib/fmt/archive/6.1.1.tar.gz - "6.1.2": - sha256: 1cafc80701b746085dddf41bd9193e6d35089e1c6ec1940e037fcb9c98f62365 - url: https://github.com/fmtlib/fmt/archive/6.1.2.tar.gz - "6.2.0": - sha256: fe6e4ff397e01c379fc4532519339c93da47404b9f6674184a458a9967a76575 - url: https://github.com/fmtlib/fmt/archive/6.2.0.tar.gz - "6.2.1": - sha256: 5edf8b0f32135ad5fafb3064de26d063571e95e8ae46829c2f4f4b52696bbff0 - url: https://github.com/fmtlib/fmt/archive/6.2.1.tar.gz - "7.0.1": - sha256: ac335a4ca6beaebec4ddb2bc35b9ae960b576f3b64a410ff2c379780f0cd4948 - url: https://github.com/fmtlib/fmt/archive/7.0.1.tar.gz - "7.0.2": - sha256: 7697e022f9cdc4f90b5e0a409643faa2cde0a6312f85e575c8388a1913374de5 - url: https://github.com/fmtlib/fmt/archive/7.0.2.tar.gz - "7.0.3": - sha256: b4b51bc16288e2281cddc59c28f0b4f84fed58d016fb038273a09f05f8473297 - url: https://github.com/fmtlib/fmt/archive/7.0.3.tar.gz - "7.1.0": - sha256: a53bce7e3b7ee8c7374723262a43356afff176b1684b86061748409e6f8b56c5 - url: https://github.com/fmtlib/fmt/archive/7.1.0.tar.gz - "7.1.1": - sha256: b3bc4dc01978b9a001fa1bc07900d6bd2a17e552a39a1c2dad9aad3bfdb868e3 - url: https://github.com/fmtlib/fmt/archive/7.1.1.tar.gz - "7.1.2": - sha256: 4119a1c34dff91631e1d0a3707428f764f1ea22fe3cd5e70af5b4ccd5513831c - url: https://github.com/fmtlib/fmt/archive/7.1.2.tar.gz + "9.1.0": + url: "https://github.com/fmtlib/fmt/archive/9.1.0.tar.gz" + sha256: "5dea48d1fcddc3ec571ce2058e13910a0d4a6bab4cc09a809d8b1dd1c88ae6f2" + "9.0.0": + url: "https://github.com/fmtlib/fmt/archive/9.0.0.tar.gz" + sha256: "9a1e0e9e843a356d65c7604e2c8bf9402b50fe294c355de0095ebd42fb9bd2c5" + "8.1.1": + url: "https://github.com/fmtlib/fmt/archive/8.1.1.tar.gz" + sha256: "3d794d3cf67633b34b2771eb9f073bde87e846e0d395d254df7b211ef1ec7346" + "8.0.1": + url: "https://github.com/fmtlib/fmt/archive/8.0.1.tar.gz" + sha256: "b06ca3130158c625848f3fb7418f235155a4d389b2abc3a6245fb01cb0eb1e01" "7.1.3": sha256: 5cae7072042b3043e12d53d50ef404bbb76949dad1de368d7f993a15c8c05ecc url: https://github.com/fmtlib/fmt/archive/7.1.3.tar.gz + "6.2.1": + sha256: 5edf8b0f32135ad5fafb3064de26d063571e95e8ae46829c2f4f4b52696bbff0 + url: https://github.com/fmtlib/fmt/archive/6.2.1.tar.gz + "5.3.0": + sha256: defa24a9af4c622a7134076602070b45721a43c51598c8456ec6f2c4dbb51c89 + url: https://github.com/fmtlib/fmt/archive/5.3.0.tar.gz patches: "5.3.0": - patch_file: "patches/fix-install-5.3.0.patch" - base_path: "source_subfolder" - "6.0.0": - - patch_file: "patches/fix-install-6.0.0.patch" - base_path: "source_subfolder" - "6.1.0": - - patch_file: "patches/fix-mingw-msvc2015-export-assert-fail-6.1.0.patch" - base_path: "source_subfolder" diff --git a/recipes/fmt/all/conanfile.py b/recipes/fmt/all/conanfile.py index 785ccc00939e4..66516fa1027c3 100644 --- a/recipes/fmt/all/conanfile.py +++ b/recipes/fmt/all/conanfile.py @@ -1,93 +1,145 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration import os +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.layout import basic_layout +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version + +required_conan_version = ">=1.52.0" + class FmtConan(ConanFile): name = "fmt" homepage = "https://github.com/fmtlib/fmt" description = "A safe and fast alternative to printf and IOStreams." - topics = ("conan", "fmt", "format", "iostream", "printf") + topics = ("format", "iostream", "printf") url = "https://github.com/conan-io/conan-center-index" license = "MIT" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "header_only": [True, False], "fPIC": [True, False], "with_fmt_alias": [True, False]} - default_options = {"shared": False, "header_only": False, "fPIC": True, "with_fmt_alias": False} - - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "header_only": [True, False], + "shared": [True, False], + "fPIC": [True, False], + "with_fmt_alias": [True, False], + "with_os_api": [True, False], + } + default_options = { + "header_only": False, + "shared": False, + "fPIC": True, + "with_fmt_alias": False, + "with_os_api": True, + } @property - def _source_subfolder(self): - return "source_subfolder" + def _has_with_os_api_option(self): + return Version(self.version) >= "7.0.0" - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) + + def generate(self): + if not self.options.header_only: + tc = CMakeToolchain(self) + tc.cache_variables["FMT_DOC"] = False + tc.cache_variables["FMT_TEST"] = False + tc.cache_variables["FMT_INSTALL"] = True + tc.cache_variables["FMT_LIB_DIR"] = "lib" + if self._has_with_os_api_option: + tc.cache_variables["FMT_OS"] = bool(self.options.with_os_api) + tc.generate() + + def layout(self): + if self.options.header_only: + basic_layout(self, src_folder="src") + else: + cmake_layout(self, src_folder="src") def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if not self._has_with_os_api_option: + del self.options.with_os_api + elif str(self.settings.os) == "baremetal": + self.options.with_os_api = False def configure(self): if self.options.header_only: - self.settings.clear() - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass del self.options.shared + try: + del self.options.with_os_api + except Exception: + pass elif self.options.shared: - del self.options.fPIC - if self.settings.compiler == "Visual Studio" and "MT" in self.settings.compiler.runtime: - raise ConanInvalidConfiguration("Visual Studio build for shared library with MT runtime is not supported") + try: + del self.options.fPIC + except Exception: + pass + + def package_id(self): + if self.info.options.header_only: + self.info.clear() + else: + del self.info.options.with_fmt_alias + + def validate(self): + if self.info.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, 11) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["FMT_DOC"] = False - self._cmake.definitions["FMT_TEST"] = False - self._cmake.definitions["FMT_INSTALL"] = True - self._cmake.definitions["FMT_LIB_DIR"] = "lib" - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) if not self.options.header_only: - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE.rst", dst="licenses", src=self._source_subfolder) + copy(self, pattern="*LICENSE.rst", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) if self.options.header_only: - self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, pattern="*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) else: - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) - - def package_id(self): - if self.options.header_only: - self.info.header_only() - else: - del self.info.options.with_fmt_alias + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "res")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): + target = "fmt-header-only" if self.options.header_only else "fmt" + self.cpp_info.set_property("cmake_file_name", "fmt") + self.cpp_info.set_property("cmake_target_name", f"fmt::{target}") + self.cpp_info.set_property("pkg_config_name", "fmt") + + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + if self.options.with_fmt_alias: + self.cpp_info.components["_fmt"].defines.append("FMT_STRING_ALIAS=1") + if self.options.header_only: - self.cpp_info.components["fmt-header-only"].defines.append("FMT_HEADER_ONLY=1") - if self.options.with_fmt_alias: - self.cpp_info.components["fmt-header-only"].defines.append("FMT_STRING_ALIAS=1") + self.cpp_info.components["_fmt"].defines.append("FMT_HEADER_ONLY=1") else: - self.cpp_info.libs = tools.collect_libs(self) - if self.options.with_fmt_alias: - self.cpp_info.defines.append("FMT_STRING_ALIAS=1") + postfix = "d" if self.settings.build_type == "Debug" else "" + libname = "fmt" + postfix + self.cpp_info.components["_fmt"].libs = [libname] + if self.settings.os == "Linux": + self.cpp_info.components["_fmt"].system_libs.extend(["m"]) if self.options.shared: - self.cpp_info.defines.append("FMT_SHARED") + self.cpp_info.components["_fmt"].defines.append("FMT_SHARED") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "fmt" + self.cpp_info.names["cmake_find_package_multi"] = "fmt" + self.cpp_info.names["pkg_config"] = "fmt" + self.cpp_info.components["_fmt"].names["cmake_find_package"] = target + self.cpp_info.components["_fmt"].names["cmake_find_package_multi"] = target + self.cpp_info.components["_fmt"].set_property("cmake_target_name", f"fmt::{target}") diff --git a/recipes/fmt/all/test_package/CMakeLists.txt b/recipes/fmt/all/test_package/CMakeLists.txt index bd15d2410c37e..a71cd67f135ec 100644 --- a/recipes/fmt/all/test_package/CMakeLists.txt +++ b/recipes/fmt/all/test_package/CMakeLists.txt @@ -1,25 +1,20 @@ -cmake_minimum_required(VERSION 3.1.2) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(fmt REQUIRED CONFIG) -find_package(fmt REQUIRED) - -# TEST_PACKAGE ################################################################# -add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) -set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 14) +add_executable(test_package test_package.cpp) +target_compile_features(test_package PRIVATE cxx_std_14) if(FMT_HEADER_ONLY) - target_link_libraries(${CMAKE_PROJECT_NAME} fmt::fmt-header-only) + target_link_libraries(test_package PRIVATE fmt::fmt-header-only) else() - target_link_libraries(${CMAKE_PROJECT_NAME} fmt::fmt) + target_link_libraries(test_package PRIVATE fmt::fmt) endif() -# TEST_RANGES ################################################################## add_executable(test_ranges test_ranges.cpp) -set_property(TARGET test_ranges PROPERTY CXX_STANDARD 14) +target_compile_features(test_ranges PRIVATE cxx_std_14) if(FMT_HEADER_ONLY) - target_link_libraries(test_ranges fmt::fmt-header-only) + target_link_libraries(test_ranges PRIVATE fmt::fmt-header-only) else() - target_link_libraries(test_ranges fmt::fmt) + target_link_libraries(test_ranges PRIVATE fmt::fmt) endif() diff --git a/recipes/fmt/all/test_package/conanfile.py b/recipes/fmt/all/test_package/conanfile.py index 966ad2003426a..5fe5679b8d954 100644 --- a/recipes/fmt/all/test_package/conanfile.py +++ b/recipes/fmt/all/test_package/conanfile.py @@ -1,18 +1,31 @@ import os -from conans import ConanFile, CMake, tools - +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package", "cmake" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FMT_HEADER_ONLY"] = self.dependencies[self.tested_reference_str].options.header_only + tc.generate() + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) - cmake.definitions["FMT_HEADER_ONLY"] = self.options["fmt"].header_only cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin","test_package"), run_environment=True) - self.run(os.path.join("bin","test_ranges"), run_environment=True) + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") + self.run(os.path.join(self.cpp.build.bindirs[0], "test_ranges"), env="conanrun") diff --git a/recipes/fmt/all/test_package/test_package.cpp b/recipes/fmt/all/test_package/test_package.cpp index 76a2416d79aae..bcd009407212d 100644 --- a/recipes/fmt/all/test_package/test_package.cpp +++ b/recipes/fmt/all/test_package/test_package.cpp @@ -1,14 +1,15 @@ #include #include +#include #include #include #include -#include "fmt/format.h" -#include "fmt/printf.h" -#include "fmt/ostream.h" -#include "fmt/color.h" +#include +#include +#include +#include void vreport(const char *format, fmt::format_args args) { @@ -30,6 +31,12 @@ class Date { } }; +#if FMT_VERSION >= 90000 +namespace fmt { + template <> struct formatter : ostream_formatter {}; +} +#endif + int main() { const std::string thing("World"); fmt::print("PRINT: Hello {}!\n", thing); @@ -39,7 +46,7 @@ int main() { fmt::print("{}\n", formatted); fmt::memory_buffer buf; - fmt::format_to(buf, "{}", 2.7182818); + fmt::format_to(std::begin(buf), "{}", 2.7182818); fmt::print("Euler number: {}\n", fmt::to_string(buf)); const std::string date = fmt::format("The date is {}\n", Date(2012, 12, 9)); diff --git a/recipes/fmt/all/test_v1_package/CMakeLists.txt b/recipes/fmt/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/fmt/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/fmt/all/test_v1_package/conanfile.py b/recipes/fmt/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..f99cfc80791d2 --- /dev/null +++ b/recipes/fmt/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["FMT_HEADER_ONLY"] = self.options["fmt"].header_only + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) + self.run(os.path.join("bin", "test_ranges"), run_environment=True) diff --git a/recipes/fmt/config.yml b/recipes/fmt/config.yml index db8ca6a61f22b..7251dde3fac9f 100644 --- a/recipes/fmt/config.yml +++ b/recipes/fmt/config.yml @@ -1,29 +1,15 @@ versions: - "5.3.0": - folder: all - "6.0.0": + "9.1.0": folder: all - "6.1.0": + "9.0.0": folder: all - "6.1.1": + "8.1.1": folder: all - "6.1.2": + "8.0.1": folder: all - "6.2.0": + "7.1.3": folder: all "6.2.1": folder: all - "7.0.1": - folder: all - "7.0.2": - folder: all - "7.0.3": - folder: all - "7.1.0": - folder: all - "7.1.1": - folder: all - "7.1.2": - folder: all - "7.1.3": + "5.3.0": folder: all diff --git a/recipes/fmtlog/all/conandata.yml b/recipes/fmtlog/all/conandata.yml new file mode 100644 index 0000000000000..181d1e80ed96e --- /dev/null +++ b/recipes/fmtlog/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "2.2.1": + url: "https://github.com/MengRao/fmtlog/archive/refs/tags/v2.2.1.tar.gz" + sha256: "9bc2f1ea37eece0f4807689962b529d2d4fa07654baef184f051319b4eac9304" +patches: + "2.2.1": + - patch_file: "patches/2.2.1-0001-fix-cmake.patch" + patch_description: "make shared, static library separately" + patch_type: "conan" diff --git a/recipes/fmtlog/all/conanfile.py b/recipes/fmtlog/all/conanfile.py new file mode 100644 index 0000000000000..e1fd99b8fca24 --- /dev/null +++ b/recipes/fmtlog/all/conanfile.py @@ -0,0 +1,119 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.layout import basic_layout +import os + + +required_conan_version = ">=1.52.0" + + +class PackageConan(ConanFile): + name = "fmtlog" + description = "fmtlog is a performant fmtlib-style logging library with latency in nanoseconds." + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/MengRao/fmtlog" + topics = ("logging", "low-latency", "topic3") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "header_only": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "header_only": False, + } + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "15.7", + "msvc": "191", + "clang": "7", + "apple-clang": "10", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + if self.options.header_only: + basic_layout(self, src_folder="src") + else: + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("fmt/9.1.0") + + def package_id(self): + if self.options.header_only: + self.info.clear() + + def validate(self): + # FIXME: self.info.settings.compiler does not work with header-only packages + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + if self.options.header_only: + return + + tc = CMakeToolchain(self) + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + if self.options.header_only: + return + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + if self.options.header_only: + copy(self, pattern="fmtlog*.h", dst=os.path.join(self.package_folder, "include", "fmtlog"), src=self.source_folder) + else: + cmake = CMake(self) + cmake.install() + + def package_info(self): + if self.options.header_only: + self.cpp_info.defines.append("FMTLOG_HEADER_ONLY") + else: + self.cpp_info.libs = ["fmtlog-shared" if self.options.shared else "fmtlog-static"] + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/fmtlog/all/patches/2.2.1-0001-fix-cmake.patch b/recipes/fmtlog/all/patches/2.2.1-0001-fix-cmake.patch new file mode 100644 index 0000000000000..08354bb048c10 --- /dev/null +++ b/recipes/fmtlog/all/patches/2.2.1-0001-fix-cmake.patch @@ -0,0 +1,39 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c45e569..6dc75d4 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -12,23 +12,24 @@ else() + link_libraries(pthread) + endif() + +-link_directories(.) +-include_directories(fmt/include) ++find_package(fmt REQUIRED CONFIG) + ++if(BUILD_SHARED_LIBS) + add_library(fmtlog-shared SHARED fmtlog.cc) +-if(MSVC) +- target_link_libraries(fmtlog-shared fmt) ++if(1) ++ target_link_libraries(fmtlog-shared PUBLIC fmt::fmt) + endif() ++set_property(TARGET fmtlog-shared PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) + install(TARGETS fmtlog-shared) + ++else() ++ + add_library(fmtlog-static fmtlog.cc) +-if(MSVC) +- target_link_libraries(fmtlog-static fmt) ++if(1) ++ target_link_libraries(fmtlog-static PUBLIC fmt::fmt) + endif() + install(TARGETS fmtlog-static) + +-add_subdirectory(fmt) +-add_subdirectory(test) +-if(NOT MSVC) +- add_subdirectory(bench) + endif() ++ ++install(FILES fmtlog.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fmtlog) diff --git a/recipes/fmtlog/all/test_package/CMakeLists.txt b/recipes/fmtlog/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..42a1ef5c3a35e --- /dev/null +++ b/recipes/fmtlog/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +find_package(fmtlog REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE fmtlog::fmtlog) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/fmtlog/all/test_package/conanfile.py b/recipes/fmtlog/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/fmtlog/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fmtlog/all/test_package/test_package.cpp b/recipes/fmtlog/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..25429fa8fbed2 --- /dev/null +++ b/recipes/fmtlog/all/test_package/test_package.cpp @@ -0,0 +1,5 @@ +#include "fmtlog/fmtlog.h" +int main() +{ + FMTLOG(fmtlog::INF, "The answer is {}.", 42); +} diff --git a/recipes/fmtlog/all/test_v1_package/CMakeLists.txt b/recipes/fmtlog/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..885bdb9ba0ee8 --- /dev/null +++ b/recipes/fmtlog/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fmtlog REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE fmtlog::fmtlog) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/fmtlog/all/test_v1_package/conanfile.py b/recipes/fmtlog/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/fmtlog/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fmtlog/config.yml b/recipes/fmtlog/config.yml new file mode 100644 index 0000000000000..a816d92f78ee3 --- /dev/null +++ b/recipes/fmtlog/config.yml @@ -0,0 +1,3 @@ +versions: + "2.2.1": + folder: all diff --git a/recipes/folly/all/CMakeLists.txt b/recipes/folly/all/CMakeLists.txt index c986d294c7547..61f3d3b039e2b 100644 --- a/recipes/folly/all/CMakeLists.txt +++ b/recipes/folly/all/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory("source_subfolder") diff --git a/recipes/folly/all/conandata.yml b/recipes/folly/all/conandata.yml index 9ab6899e5e47a..8fcc8945ab40d 100644 --- a/recipes/folly/all/conandata.yml +++ b/recipes/folly/all/conandata.yml @@ -5,6 +5,9 @@ sources: "2020.08.10.00": url: "https://github.com/facebook/folly/archive/v2020.08.10.00.tar.gz" sha256: "e81140d04a4e89e3f848e528466a9b3d3ae37d7eeb9e65467fca50d70918eef6" + "2022.01.31.00": + url: "https://github.com/facebook/folly/archive/v2022.01.31.00.tar.gz" + sha256: "d764b9a7832d967bb7cfea4bcda15d650315aa4d559fde1da2a52b015cd88b9c" patches: "2019.10.21.00": - patch_file: "patches/0001-find-packages.patch" @@ -23,6 +26,8 @@ patches: base_path: "source_subfolder" - patch_file: "patches/0013-include-bit.patch" base_path: "source_subfolder" + - patch_file: "patches/0020-include-ssizet.patch" + base_path: "source_subfolder" "2020.08.10.00": - patch_file: "patches/0008-find-packages.patch" base_path: "source_subfolder" @@ -38,3 +43,14 @@ patches: base_path: "source_subfolder" - patch_file: "patches/0015-benchmark-format-macros.patch" base_path: "source_subfolder" + "2022.01.31.00": + - patch_file: "patches/0016-find-packages.patch" + base_path: "source_subfolder" + - patch_file: "patches/0017-compiler-flags.patch" + base_path: "source_subfolder" + - patch_file: "patches/0018-find-glog.patch" + base_path: "source_subfolder" + - patch_file: "patches/0019-exclude-example.patch" + base_path: "source_subfolder" + - patch_file: "patches/0022-fix-windows-minmax.patch" + base_path: "source_subfolder" diff --git a/recipes/folly/all/conanfile.py b/recipes/folly/all/conanfile.py index afd1f7bc2f03d..06dc6965155a7 100755 --- a/recipes/folly/all/conanfile.py +++ b/recipes/folly/all/conanfile.py @@ -1,25 +1,37 @@ +from conan.tools.microsoft import is_msvc, msvc_runtime_flag +from conan.tools.build import can_run +from conan.tools.scm import Version +from conan.tools import files +from conan import ConanFile +from conans import CMake, tools +from conan.errors import ConanInvalidConfiguration +import functools import os -from conans import ConanFile, CMake, tools -from conans.tools import Version -from conans.errors import ConanInvalidConfiguration -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.45.0" class FollyConan(ConanFile): name = "folly" description = "An open-source C++ components library developed and used at Facebook" - topics = ("conan", "folly", "facebook", "components", "core", "efficiency") + topics = ("facebook", "components", "core", "efficiency") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/facebook/folly" license = "Apache-2.0" + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake", "cmake_find_package" + options = { + "shared": [True, False], + "fPIC": [True, False], + "use_sse4_2" : [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "use_sse4_2" : False + } - _cmake = None + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): @@ -27,7 +39,7 @@ def _source_subfolder(self): @property def _minimum_cpp_standard(self): - return 14 + return 17 if Version(self.version) >= "2022.01.31.00" else 14 @property def _minimum_compilers_version(self): @@ -36,51 +48,44 @@ def _minimum_compilers_version(self): "gcc": "5", "clang": "6", "apple-clang": "8", + } if self._minimum_cpp_standard == 14 else { + "gcc": "7", + "Visual Studio": "16", + "clang": "6", + "apple-clang": "10", } + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if str(self.settings.arch) not in ['x86', 'x86_64']: + del self.options.use_sse4_2 + def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._minimum_cpp_standard) - min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) - if not min_version: - self.output.warn("{} recipe lacks information about the {} compiler support.".format(self.name, self.settings.compiler)) - else: - if tools.Version(self.settings.compiler.version) < min_version: - raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( - self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) - - if self.settings.os == "Windows" and self.settings.arch != "x86_64": - raise ConanInvalidConfiguration("Folly requires a 64bit target architecture on Windows") - - if self.settings.os in ["Macos", "Windows"] and self.options.shared: - raise ConanInvalidConfiguration("Folly could not be built on {} as shared library".format(self.settings.os)) - - if self.version == "2020.08.10.00" and self.settings.compiler == "clang" and self.options.shared: - raise ConanInvalidConfiguration("Folly could not be built by clang as a shared library") - - # Freeze max. CMake version at 3.16.2 to fix the Linux build - def build_requirements(self): - self.build_requires("cmake/3.16.2") def requirements(self): - self.requires("boost/1.75.0") + self.requires("boost/1.78.0") self.requires("bzip2/1.0.8") - self.requires("double-conversion/3.1.5") + self.requires("double-conversion/3.2.0") self.requires("gflags/2.2.2") self.requires("glog/0.4.0") self.requires("libevent/2.1.12") + self.requires("openssl/1.1.1q") self.requires("lz4/1.9.3") - self.requires("openssl/1.1.1i") - self.requires("snappy/1.1.8") - self.requires("zlib/1.2.11") - self.requires("zstd/1.4.8") - self.requires("libdwarf/20191104") + self.requires("snappy/1.1.9") + self.requires("zlib/1.2.12") + self.requires("zstd/1.5.2") + if not is_msvc(self): + self.requires("libdwarf/20191104") self.requires("libsodium/1.0.18") self.requires("xz_utils/5.2.5") # FIXME: Causing compilation issues on clang: self.requires("jemalloc/5.2.1") @@ -88,13 +93,38 @@ def requirements(self): self.requires("libiberty/9.1.0") self.requires("libunwind/1.5.0") if Version(self.version) >= "2020.08.10.00": - self.requires("fmt/7.0.3") + self.requires("fmt/7.1.3") @property def _required_boost_components(self): return ["context", "filesystem", "program_options", "regex", "system", "thread"] def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format(self.name, self.settings.compiler)) + else: + if Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) + + if Version(self.version) < "2022.01.31.00" and self.settings.os != "Linux": + raise ConanInvalidConfiguration("Conan support for non-Linux platforms starts with Folly version 2022.01.31.00") + + if self.settings.os == "Macos" and self.settings.arch != "x86_64": + raise ConanInvalidConfiguration("Conan currently requires a 64bit target architecture for Folly on Macos") + + if self.settings.os == "Windows" and self.settings.arch != "x86_64": + raise ConanInvalidConfiguration("Folly requires a 64bit target architecture on Windows") + + if self.settings.os in ["Macos", "Windows"] and self.options.shared: + raise ConanInvalidConfiguration("Folly could not be built on {} as shared library".format(self.settings.os)) + + if Version(self.version) == "2020.08.10.00" and self.settings.compiler == "clang" and self.options.shared: + raise ConanInvalidConfiguration("Folly could not be built by clang as a shared library") + if self.options["boost"].header_only: raise ConanInvalidConfiguration("Folly could not be built with a header only Boost") @@ -102,24 +132,61 @@ def validate(self): if miss_boost_required_comp: raise ConanInvalidConfiguration("Folly requires these boost components: {}".format(", ".join(self._required_boost_components))) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format(self.name, self.settings.compiler)) + else: + if Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) + + if self.options.get_safe("use_sse4_2") and str(self.settings.arch) not in ['x86', 'x86_64']: + raise ConanInvalidConfiguration(f"{self.ref} can use the option use_sse4_2 only on x86 and x86_64 archs.") + + # FIXME: Freeze max. CMake version at 3.16.2 to fix the Linux build + def build_requirements(self): + self.build_requires("cmake/3.16.9") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + @functools.lru_cache(1) def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) - self._cmake.definitions["CXX_STD"] = self.settings.compiler.get_safe("cppstd") or "c++14" - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["MSVC_ENABLE_ALL_WARNINGS"] = False - self._cmake.definitions["MSVC_USE_STATIC_RUNTIME"] = "MT" in self.settings.compiler.runtime - self._cmake.configure() - return self._cmake + cmake = CMake(self) + if can_run(self): + cmake.definitions["FOLLY_HAVE_UNALIGNED_ACCESS_EXITCODE"] = "0" + cmake.definitions["FOLLY_HAVE_UNALIGNED_ACCESS_EXITCODE__TRYRUN_OUTPUT"] = "" + cmake.definitions["FOLLY_HAVE_LINUX_VDSO_EXITCODE"] = "0" + cmake.definitions["FOLLY_HAVE_LINUX_VDSO_EXITCODE__TRYRUN_OUTPUT"] = "" + cmake.definitions["FOLLY_HAVE_WCHAR_SUPPORT_EXITCODE"] = "0" + cmake.definitions["FOLLY_HAVE_WCHAR_SUPPORT_EXITCODE__TRYRUN_OUTPUT"] = "" + cmake.definitions["HAVE_VSNPRINTF_ERRORS_EXITCODE"] = "0" + cmake.definitions["HAVE_VSNPRINTF_ERRORS_EXITCODE__TRYRUN_OUTPUT"] = "" + + if self.options.get_safe("use_sse4_2") and str(self.settings.arch) in ['x86', 'x86_64']: + # in folly, if simd >=sse4.2, we also needs -mfma flag to avoid compiling error. + if not is_msvc(self): + cmake.definitions["CMAKE_C_FLAGS"] = "-mfma" + cmake.definitions["CMAKE_CXX_FLAGS"] = "-mfma" + else: + cmake.definitions["CMAKE_C_FLAGS"] = "/arch:FMA" + cmake.definitions["CMAKE_CXX_FLAGS"] = "/arch:FMA" + + cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) + + cxx_std_flag = tools.cppstd_flag(self.settings) + cxx_std_value = cxx_std_flag.split('=')[1] if cxx_std_flag else "c++{}".format(self._minimum_cpp_standard) + cmake.definitions["CXX_STD"] = cxx_std_value + if is_msvc: + cmake.definitions["MSVC_LANGUAGE_VERSION"] = cxx_std_value + cmake.definitions["MSVC_ENABLE_ALL_WARNINGS"] = False + cmake.definitions["MSVC_USE_STATIC_RUNTIME"] = "MT" in msvc_runtime_flag(self) + cmake.configure() + return cmake + def build(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) cmake = self._configure_cmake() cmake.build() @@ -128,26 +195,22 @@ def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "folly" - self.cpp_info.filenames["cmake_find_package_multi"] = "folly" - self.cpp_info.names["cmake_find_package"] = "Folly" - self.cpp_info.names["cmake_find_package_multi"] = "Folly" - self.cpp_info.names["pkg_config"] = "libfolly" - self.cpp_info.components["libfolly"].names["cmake_find_package"] = "folly" - self.cpp_info.components["libfolly"].names["cmake_find_package_multi"] = "folly" - self.cpp_info.components["libfolly"].names["pkg_config"] = "libfolly" + self.cpp_info.set_property("cmake_file_name", "folly") + self.cpp_info.set_property("cmake_target_name", "Folly::folly") + self.cpp_info.set_property("pkg_config_name", "libfolly") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed if Version(self.version) == "2019.10.21.00": self.cpp_info.components["libfolly"].libs = [ "follybenchmark", "folly_test_util", "folly" ] - if Version(self.version) == "2020.08.10.00": + elif Version(self.version) >= "2020.08.10.00": if self.settings.os == "Linux": self.cpp_info.components["libfolly"].libs = [ "folly_exception_counter", @@ -163,6 +226,7 @@ def package_info(self): "follybenchmark", "folly" ] + self.cpp_info.components["libfolly"].requires = [ "boost::boost", "bzip2::bzip2", @@ -175,10 +239,11 @@ def package_info(self): "snappy::snappy", "zlib::zlib", "zstd::zstd", - "libdwarf::libdwarf", "libsodium::libsodium", "xz_utils::xz_utils" ] + if not is_msvc(self): + self.cpp_info.components["libfolly"].requires.append("libdwarf::libdwarf") if self.settings.os == "Linux": self.cpp_info.components["libfolly"].requires.extend(["libiberty::libiberty", "libunwind::libunwind"]) self.cpp_info.components["libfolly"].system_libs.extend(["pthread", "dl", "rt"]) @@ -186,7 +251,7 @@ def package_info(self): if Version(self.version) >= "2020.08.10.00": self.cpp_info.components["libfolly"].requires.append("fmt::fmt") if self.settings.os == "Linux": - self.cpp_info.components["libfolly"].defines.append("FOLLY_HAVE_ELF") + self.cpp_info.components["libfolly"].defines.extend(["FOLLY_HAVE_ELF", "FOLLY_HAVE_DWARF"]) elif self.settings.os == "Windows": self.cpp_info.components["libfolly"].system_libs.extend(["ws2_32", "iphlpapi", "crypt32"]) @@ -196,3 +261,47 @@ def package_info(self): (self.settings.os == "Macos" and self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version.value) == "9.0" and self.settings.compiler.libcxx == "libc++"): self.cpp_info.components["libfolly"].system_libs.append("atomic") + + if self.settings.os == "Macos" and self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version.value) >= "11.0": + self.cpp_info.components["libfolly"].system_libs.append("c++abi") + + if self.options.get_safe("use_sse4_2") and str(self.settings.arch) in ['x86', 'x86_64']: + self.cpp_info.components["libfolly"].defines = ["FOLLY_SSE=4", "FOLLY_SSE_MINOR=2"] + + # TODO: to remove in conan v2 once cmake_find_package_* & pkg_config generators removed + self.cpp_info.filenames["cmake_find_package"] = "folly" + self.cpp_info.filenames["cmake_find_package_multi"] = "folly" + self.cpp_info.names["cmake_find_package"] = "Folly" + self.cpp_info.names["cmake_find_package_multi"] = "Folly" + self.cpp_info.names["pkg_config"] = "libfolly" + self.cpp_info.components["libfolly"].names["cmake_find_package"] = "folly" + self.cpp_info.components["libfolly"].names["cmake_find_package_multi"] = "folly" + self.cpp_info.components["libfolly"].set_property("cmake_target_name", "Folly::folly") + self.cpp_info.components["libfolly"].set_property("pkg_config_name", "libfolly") + + if Version(self.version) >= "2019.10.21.00": + self.cpp_info.components["follybenchmark"].set_property("cmake_target_name", "Folly::follybenchmark") + self.cpp_info.components["follybenchmark"].set_property("pkg_config_name", "libfollybenchmark") + self.cpp_info.components["follybenchmark"].libs = ["follybenchmark"] + self.cpp_info.components["follybenchmark"].requires = ["libfolly"] + + self.cpp_info.components["folly_test_util"].set_property("cmake_target_name", "Folly::folly_test_util") + self.cpp_info.components["folly_test_util"].set_property("pkg_config_name", "libfolly_test_util") + self.cpp_info.components["folly_test_util"].libs = ["folly_test_util"] + self.cpp_info.components["folly_test_util"].requires = ["libfolly"] + + if Version(self.version) >= "2020.08.10.00" and self.settings.os == "Linux": + self.cpp_info.components["folly_exception_tracer_base"].set_property("cmake_target_name", "Folly::folly_exception_tracer_base") + self.cpp_info.components["folly_exception_tracer_base"].set_property("pkg_config_name", "libfolly_exception_tracer_base") + self.cpp_info.components["folly_exception_tracer_base"].libs = ["folly_exception_tracer_base"] + self.cpp_info.components["folly_exception_tracer_base"].requires = ["libfolly"] + + self.cpp_info.components["folly_exception_tracer"].set_property("cmake_target_name", "Folly::folly_exception_tracer") + self.cpp_info.components["folly_exception_tracer"].set_property("pkg_config_name", "libfolly_exception_tracer") + self.cpp_info.components["folly_exception_tracer"].libs = ["folly_exception_tracer"] + self.cpp_info.components["folly_exception_tracer"].requires = ["folly_exception_tracer_base"] + + self.cpp_info.components["folly_exception_counter"].set_property("cmake_target_name", "Folly::folly_exception_counter") + self.cpp_info.components["folly_exception_counter"].set_property("pkg_config_name", "libfolly_exception_counter") + self.cpp_info.components["folly_exception_counter"].libs = ["folly_exception_counter"] + self.cpp_info.components["folly_exception_counter"].requires = ["folly_exception_tracer"] diff --git a/recipes/folly/all/patches/0016-find-packages.patch b/recipes/folly/all/patches/0016-find-packages.patch new file mode 100644 index 0000000000000..c6cd14fad52c9 --- /dev/null +++ b/recipes/folly/all/patches/0016-find-packages.patch @@ -0,0 +1,80 @@ +diff --git a/CMake/folly-deps.cmake b/CMake/folly-deps.cmake +index 9c9d9ea60..e78611542 100644 +--- a/CMake/folly-deps.cmake ++++ b/CMake/folly-deps.cmake +@@ -48,25 +48,25 @@ find_package(Boost 1.51.0 MODULE + list(APPEND FOLLY_LINK_LIBRARIES ${Boost_LIBRARIES}) + list(APPEND FOLLY_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS}) + +-find_package(DoubleConversion MODULE REQUIRED) ++find_package(double-conversion MODULE REQUIRED) + list(APPEND FOLLY_LINK_LIBRARIES ${DOUBLE_CONVERSION_LIBRARY}) + list(APPEND FOLLY_INCLUDE_DIRECTORIES ${DOUBLE_CONVERSION_INCLUDE_DIR}) + +-find_package(Gflags MODULE) +-set(FOLLY_HAVE_LIBGFLAGS ${LIBGFLAGS_FOUND}) +-if(LIBGFLAGS_FOUND) +- list(APPEND FOLLY_LINK_LIBRARIES ${LIBGFLAGS_LIBRARY}) +- list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBGFLAGS_INCLUDE_DIR}) +- set(FOLLY_LIBGFLAGS_LIBRARY ${LIBGFLAGS_LIBRARY}) +- set(FOLLY_LIBGFLAGS_INCLUDE ${LIBGFLAGS_INCLUDE_DIR}) ++find_package(gflags MODULE) ++set(FOLLY_HAVE_LIBGFLAGS ${gflags_FOUND}) ++if(gflags_FOUND) ++ list(APPEND FOLLY_LINK_LIBRARIES ${gflags_LIBRARIES}) ++ list(APPEND FOLLY_INCLUDE_DIRECTORIES ${gflags_INCLUDE_DIRS}) ++ set(FOLLY_LIBGFLAGS_LIBRARY ${gflags_LIBRARIES}) ++ set(FOLLY_LIBGFLAGS_INCLUDE ${gflags_INCLUDE_DIRS}) + endif() + +-find_package(Glog MODULE) ++find_package(glog MODULE) + set(FOLLY_HAVE_LIBGLOG ${GLOG_FOUND}) + list(APPEND FOLLY_LINK_LIBRARIES ${GLOG_LIBRARY}) + list(APPEND FOLLY_INCLUDE_DIRECTORIES ${GLOG_INCLUDE_DIR}) + +-find_package(LibEvent MODULE REQUIRED) ++find_package(Libevent MODULE REQUIRED) + list(APPEND FOLLY_LINK_LIBRARIES ${LIBEVENT_LIB}) + list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBEVENT_INCLUDE_DIR}) + +@@ -104,14 +104,14 @@ if (LIBLZMA_FOUND) + list(APPEND FOLLY_LINK_LIBRARIES ${LIBLZMA_LIBRARIES}) + endif() + +-find_package(LZ4 MODULE) ++find_package(lz4 MODULE) + set(FOLLY_HAVE_LIBLZ4 ${LZ4_FOUND}) + if (LZ4_FOUND) + list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LZ4_INCLUDE_DIR}) + list(APPEND FOLLY_LINK_LIBRARIES ${LZ4_LIBRARY}) + endif() + +-find_package(Zstd MODULE) ++find_package(zstd MODULE) + set(FOLLY_HAVE_LIBZSTD ${ZSTD_FOUND}) + if(ZSTD_FOUND) + list(APPEND FOLLY_INCLUDE_DIRECTORIES ${ZSTD_INCLUDE_DIR}) +@@ -125,11 +125,11 @@ if (SNAPPY_FOUND) + list(APPEND FOLLY_LINK_LIBRARIES ${SNAPPY_LIBRARY}) + endif() + +-find_package(LibDwarf) ++find_package(libdwarf) + list(APPEND FOLLY_LINK_LIBRARIES ${LIBDWARF_LIBRARIES}) + list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBDWARF_INCLUDE_DIRS}) + +-find_package(Libiberty) ++find_package(libiberty) + list(APPEND FOLLY_LINK_LIBRARIES ${LIBIBERTY_LIBRARIES}) + list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBIBERTY_INCLUDE_DIRS}) + +@@ -141,7 +141,7 @@ find_package(LibUring) + list(APPEND FOLLY_LINK_LIBRARIES ${LIBURING_LIBRARIES}) + list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBURING_INCLUDE_DIRS}) + +-find_package(Libsodium) ++find_package(libsodium) + list(APPEND FOLLY_LINK_LIBRARIES ${LIBSODIUM_LIBRARIES}) + list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBSODIUM_INCLUDE_DIRS}) + diff --git a/recipes/folly/all/patches/0017-compiler-flags.patch b/recipes/folly/all/patches/0017-compiler-flags.patch new file mode 100644 index 0000000000000..1290e801ba4ba --- /dev/null +++ b/recipes/folly/all/patches/0017-compiler-flags.patch @@ -0,0 +1,24 @@ +diff --git a/CMake/FollyCompilerUnix.cmake b/CMake/FollyCompilerUnix.cmake +index 8dcaf14..200fe8d 100644 +--- a/CMake/FollyCompilerUnix.cmake ++++ b/CMake/FollyCompilerUnix.cmake +@@ -28,9 +28,9 @@ set( + ) + mark_as_advanced(CXX_STD) + +-set(CMAKE_CXX_FLAGS_COMMON "-g -Wall -Wextra") ++set(CMAKE_CXX_FLAGS_COMMON "-Wall -Wextra") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_COMMON}") +-set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_COMMON} -O3") ++set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_COMMON}") + + # Note that CMAKE_REQUIRED_FLAGS must be a string, not a list + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=${CXX_STD}") +@@ -43,7 +43,6 @@ function(apply_folly_compile_options_to_target THETARGET) + ) + target_compile_options(${THETARGET} + PRIVATE +- -g + -std=${CXX_STD} + -finput-charset=UTF-8 + -fsigned-char diff --git a/recipes/folly/all/patches/0018-find-glog.patch b/recipes/folly/all/patches/0018-find-glog.patch new file mode 100644 index 0000000000000..b2d17ad455a7b --- /dev/null +++ b/recipes/folly/all/patches/0018-find-glog.patch @@ -0,0 +1,16 @@ +diff --git a/build/fbcode_builder/CMake/FindGlog.cmake b/build/fbcode_builder/CMake/FindGlog.cmake +index 752647c..aa2fa1c 100644 +--- a/build/fbcode_builder/CMake/FindGlog.cmake ++++ b/build/fbcode_builder/CMake/FindGlog.cmake +@@ -10,9 +10,9 @@ include(FindPackageHandleStandardArgs) + include(SelectLibraryConfigurations) + + find_library(GLOG_LIBRARY_RELEASE glog +- PATHS ${GLOG_LIBRARYDIR}) ++ PATHS ${CONAN_GLOG_ROOT}) + find_library(GLOG_LIBRARY_DEBUG glogd +- PATHS ${GLOG_LIBRARYDIR}) ++ PATHS ${CONAN_GLOG_ROOT}) + + find_path(GLOG_INCLUDE_DIR glog/logging.h + PATHS ${GLOG_INCLUDEDIR}) diff --git a/recipes/folly/all/patches/0019-exclude-example.patch b/recipes/folly/all/patches/0019-exclude-example.patch new file mode 100644 index 0000000000000..d2afb310ff8a0 --- /dev/null +++ b/recipes/folly/all/patches/0019-exclude-example.patch @@ -0,0 +1,12 @@ +diff --git a/folly/CMakeLists.txt b/folly/CMakeLists.txt +index 883f27c..2d2086f 100644 +--- a/folly/CMakeLists.txt ++++ b/folly/CMakeLists.txt +@@ -28,7 +28,6 @@ install( + ) + + add_subdirectory(experimental/exception_tracer) +-add_subdirectory(logging/example) + + if (PYTHON_EXTENSIONS) + # Create tree of symbolic links in structure required for successful diff --git a/recipes/folly/all/patches/0020-include-ssizet.patch b/recipes/folly/all/patches/0020-include-ssizet.patch new file mode 100644 index 0000000000000..0575fecd13e84 --- /dev/null +++ b/recipes/folly/all/patches/0020-include-ssizet.patch @@ -0,0 +1,12 @@ +diff --git a/folly/executors/ExecutorWithPriority.h b/folly/executors/ExecutorWithPriority.h +index b95a6c4..18b8110 100644 +--- a/folly/executors/ExecutorWithPriority.h ++++ b/folly/executors/ExecutorWithPriority.h +@@ -18,6 +18,7 @@ + + #include + #include ++#include + + namespace folly { + diff --git a/recipes/folly/all/patches/0021-typedef-clockid.patch b/recipes/folly/all/patches/0021-typedef-clockid.patch new file mode 100644 index 0000000000000..fb46c057d58ce --- /dev/null +++ b/recipes/folly/all/patches/0021-typedef-clockid.patch @@ -0,0 +1,12 @@ +diff --git a/folly/portability/Time.h b/folly/portability/Time.h +index 994a09e5d70..e4f0d101ca9 100644 +--- a/folly/portability/Time.h ++++ b/folly/portability/Time.h +@@ -49,7 +49,6 @@ + #define CLOCK_PROCESS_CPUTIME_ID 2 + #define CLOCK_THREAD_CPUTIME_ID 3 + +-typedef uint8_t clockid_t; + extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts); + extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts); + #endif diff --git a/recipes/folly/all/patches/0022-fix-windows-minmax.patch b/recipes/folly/all/patches/0022-fix-windows-minmax.patch new file mode 100644 index 0000000000000..1fc69a43a83e5 --- /dev/null +++ b/recipes/folly/all/patches/0022-fix-windows-minmax.patch @@ -0,0 +1,12 @@ +diff --git a/CMake/FollyCompilerMSVC.cmake b/CMake/FollyCompilerMSVC.cmake +index ec2ce1a1d..16deda71c 100644 +--- a/CMake/FollyCompilerMSVC.cmake ++++ b/CMake/FollyCompilerMSVC.cmake +@@ -289,6 +289,7 @@ function(apply_folly_compile_options_to_target THETARGET) + # And the extra defines: + target_compile_definitions(${THETARGET} + PUBLIC ++ NOMINMAX + _CRT_NONSTDC_NO_WARNINGS # Don't deprecate posix names of functions. + _CRT_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps. + _SCL_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps. diff --git a/recipes/folly/all/test_package/CMakeLists.txt b/recipes/folly/all/test_package/CMakeLists.txt index 4d8c46e80145c..6a9df4ea0b752 100644 --- a/recipes/folly/all/test_package/CMakeLists.txt +++ b/recipes/folly/all/test_package/CMakeLists.txt @@ -1,11 +1,16 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.15) +project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(folly CONFIG REQUIRED) +find_package(folly REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} Folly::folly) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +target_link_libraries(${PROJECT_NAME} + Folly::folly + Folly::follybenchmark) + + +if (${FOLLY_VERSION} VERSION_LESS "2021.07.20.00") + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +else() + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) +endif() diff --git a/recipes/folly/all/test_package/conanfile.py b/recipes/folly/all/test_package/conanfile.py index c8cdde9e51383..63889d5258fa5 100644 --- a/recipes/folly/all/test_package/conanfile.py +++ b/recipes/folly/all/test_package/conanfile.py @@ -1,10 +1,25 @@ -from conans import ConanFile, CMake, tools import os +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout +required_conan_version = ">=1.43.0" class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FOLLY_VERSION"] = self.dependencies["folly"].ref.version + tc.generate() + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +27,5 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(command=bin_path, run_environment=True) + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/recipes/folly/all/test_package/test_package.cpp b/recipes/folly/all/test_package/test_package.cpp index 07f30e9c9006f..cc522b8b0280d 100644 --- a/recipes/folly/all/test_package/test_package.cpp +++ b/recipes/folly/all/test_package/test_package.cpp @@ -1,30 +1,29 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#if FOLLY_HAVE_ELF -#include -#endif - -static void print_uri(const folly::fbstring& value) { - const folly::Uri uri(value); - const auto authority = folly::format("The authority from {} is {}", value, uri.authority()); - std::cout << authority << std::endl; -} - -int main() { - folly::ThreadedExecutor executor; - folly::Promise promise; - folly::Future future = promise.getSemiFuture().via(&executor); - folly::Future unit = std::move(future).thenValue(print_uri); - promise.setValue("https://github.com/bincrafters"); - std::move(unit).get(); -#if FOLLY_HAVE_ELF - folly::symbolizer::ElfFile elffile; -#endif - return EXIT_SUCCESS; -} +#include +#include +#include +#include +#include +#include +#include +#include +#if FOLLY_HAVE_ELF +#include +#endif + +static void print_uri(const folly::fbstring& value) { + const folly::Uri uri(value); + std::cout << "The authority from " << value << " is " << uri.authority() << std::endl; +} + +int main() { + folly::ThreadedExecutor executor; + folly::Promise promise; + folly::Future future = promise.getSemiFuture().via(&executor); + folly::Future unit = std::move(future).thenValue(print_uri); + promise.setValue("https://github.com/bincrafters"); + std::move(unit).get(); +#if FOLLY_HAVE_ELF + folly::symbolizer::ElfFile elffile; +#endif + return EXIT_SUCCESS; +} diff --git a/recipes/folly/all/test_v1_package/CMakeLists.txt b/recipes/folly/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f8cc697ab67d2 --- /dev/null +++ b/recipes/folly/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(folly CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} Folly::folly) + + +if (${FOLLY_VERSION} VERSION_LESS "2021.07.20.00") + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +else() + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) +endif() diff --git a/recipes/folly/all/test_v1_package/conanfile.py b/recipes/folly/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..8b8cfae4c1882 --- /dev/null +++ b/recipes/folly/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["FOLLY_VERSION"] = self.deps_cpp_info["folly"].version + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(command=bin_path, run_environment=True) diff --git a/recipes/folly/all/test_v1_package/test_package.cpp b/recipes/folly/all/test_v1_package/test_package.cpp new file mode 100644 index 0000000000000..cc522b8b0280d --- /dev/null +++ b/recipes/folly/all/test_v1_package/test_package.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#if FOLLY_HAVE_ELF +#include +#endif + +static void print_uri(const folly::fbstring& value) { + const folly::Uri uri(value); + std::cout << "The authority from " << value << " is " << uri.authority() << std::endl; +} + +int main() { + folly::ThreadedExecutor executor; + folly::Promise promise; + folly::Future future = promise.getSemiFuture().via(&executor); + folly::Future unit = std::move(future).thenValue(print_uri); + promise.setValue("https://github.com/bincrafters"); + std::move(unit).get(); +#if FOLLY_HAVE_ELF + folly::symbolizer::ElfFile elffile; +#endif + return EXIT_SUCCESS; +} diff --git a/recipes/folly/config.yml b/recipes/folly/config.yml index 7f8bc5795d5a4..6a14a274c3fe9 100644 --- a/recipes/folly/config.yml +++ b/recipes/folly/config.yml @@ -3,3 +3,5 @@ versions: folder: all "2020.08.10.00": folder: all + "2022.01.31.00": + folder: all diff --git a/recipes/fontconfig/all/conandata.yml b/recipes/fontconfig/all/conandata.yml index fd40e267adbc1..d4f92f5455a44 100644 --- a/recipes/fontconfig/all/conandata.yml +++ b/recipes/fontconfig/all/conandata.yml @@ -1,7 +1,4 @@ sources: - "2.13.93": - url: "https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.93.tar.gz" - sha256: "0f302a18ee52dde0793fe38b266bf269dfe6e0c0ae140e30d72c6cca5dc08db5" "2.13.92": url: "https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.92.tar.gz" sha256: "3406a05b83a42231e3df68d02bc0a0cf47b3f2e8f11c8ede62267daf5f130016" diff --git a/recipes/fontconfig/all/conanfile.py b/recipes/fontconfig/all/conanfile.py index 0f07239dba69d..57f5865cd7ba6 100644 --- a/recipes/fontconfig/all/conanfile.py +++ b/recipes/fontconfig/all/conanfile.py @@ -1,8 +1,12 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import files, microsoft +from conans import tools, AutoToolsBuildEnvironment + +import functools import os -import glob -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.50.2" class FontconfigConan(ConanFile): @@ -11,104 +15,140 @@ class FontconfigConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" description = "Fontconfig is a library for configuring and customizing font access" homepage = "https://gitlab.freedesktop.org/fontconfig/fontconfig" - topics = ("conan", "fontconfig", "fonts", "freedesktop") - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - generators = "pkg_config" + topics = ("fonts", "freedesktop") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - _autotools = None + generators = "pkg_config" @property def _source_subfolder(self): return "source_subfolder" + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("Visual Studio builds are not supported.") if self.options.shared: del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd def requirements(self): - self.requires("freetype/2.10.4") - self.requires("expat/2.3.0") + self.requires("freetype/2.12.1") + self.requires("expat/2.4.9") if self.settings.os == "Linux": self.requires("libuuid/1.0.3") + def validate(self): + if microsoft.is_msvc(self): + raise ConanInvalidConfiguration("fontconfig does not support Visual Studio for versions < 2.13.93.") + def build_requirements(self): self.build_requires("gperf/3.1") self.build_requires("pkgconf/1.7.4") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): + if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str): self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extrated_dir = self.name + "-" + self.version - os.rename(extrated_dir, self._source_subfolder) + files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + @functools.lru_cache(1) def _configure_autotools(self): - if not self._autotools: - args = ["--enable-static=%s" % ("no" if self.options.shared else "yes"), - "--enable-shared=%s" % ("yes" if self.options.shared else "no"), - "--disable-docs", - "--disable-nls", - ] - args.append("--sysconfdir=%s" % tools.unix_path(os.path.join(self.package_folder, "bin", "etc"))) - args.append("--datadir=%s" % tools.unix_path(os.path.join(self.package_folder, "bin", "share"))) - args.append("--datarootdir=%s" % tools.unix_path(os.path.join(self.package_folder, "bin", "share"))) - args.append("--localstatedir=%s" % tools.unix_path(os.path.join(self.package_folder, "bin", "var"))) - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.libs = [] - self._autotools.configure(configure_dir=self._source_subfolder, args=args) - tools.replace_in_file("Makefile", "po-conf test", "po-conf") - return self._autotools + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--disable-docs", + "--disable-nls", + "--sysconfdir={}".format(tools.unix_path(os.path.join(self.package_folder, "bin", "etc"))), + "--datadir={}".format(tools.unix_path(os.path.join(self.package_folder, "bin", "share"))), + "--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "bin", "share"))), + "--localstatedir={}".format(tools.unix_path(os.path.join(self.package_folder, "bin", "var"))), + ] + autotools.configure(configure_dir=self._source_subfolder, args=args) + files.replace_in_file(self, "Makefile", "po-conf test", "po-conf") + return autotools def _patch_files(self): - # - fontconfig requires libtool version number, change it for the corresponding freetype one - tools.replace_in_file(os.path.join(self._source_subfolder, 'configure'), '21.0.15', '2.8.1') + files.apply_conandata_patches(self) + # fontconfig requires libtool version number, change it for the corresponding freetype one + files.replace_in_file(self, os.path.join(self.install_folder, "freetype2.pc"), + "Version: {}".format(self.deps_cpp_info["freetype"].version), + "Version: {}".format(self.deps_user_info["freetype"].LIBTOOL_VERSION)) # disable fc-cache test to enable cross compilation but also builds with shared libraries on MacOS - tools.replace_in_file( - os.path.join(self._source_subfolder, 'Makefile.in'), - '@CROSS_COMPILING_TRUE@RUN_FC_CACHE_TEST = false', - 'RUN_FC_CACHE_TEST=false' + files.replace_in_file(self, + os.path.join(self._source_subfolder, "Makefile.in"), + "@CROSS_COMPILING_TRUE@RUN_FC_CACHE_TEST = false", + "RUN_FC_CACHE_TEST=false" ) def build(self): - # Patch files from dependencies self._patch_files() + # relocatable shared lib on macOS + files.replace_in_file(self, + os.path.join(self._source_subfolder, "configure"), + "-install_name \\$rpath/", + "-install_name @rpath/" + ) with tools.run_environment(self): autotools = self._configure_autotools() autotools.make() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) + self.copy("COPYING", src=self._source_subfolder, dst="licenses") with tools.run_environment(self): autotools = self._configure_autotools() autotools.install() - os.unlink(os.path.join(self.package_folder, "lib", "libfontconfig.la")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - for f in glob.glob(os.path.join(self.package_folder, "bin", "etc", "fonts", "conf.d", "*.conf")): - if os.path.islink(f): - os.unlink(f) - for def_file in glob.glob(os.path.join(self.package_folder, "lib", "*.def")): - os.remove(def_file) + + files.rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + files.rm(self, "*.conf", os.path.join(self.package_folder, "bin", "etc", "fonts", "conf.d")) + files.rm(self, "*.def", os.path.join(self.package_folder, "lib")) + files.rm(self, "*.la", os.path.join(self.package_folder, "lib")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + files.rmdir(self, os.path.join(self.package_folder, "etc")) + files.rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "Fontconfig") + self.cpp_info.set_property("cmake_target_name", "Fontconfig::Fontconfig") + self.cpp_info.set_property("pkg_config_name", "fontconfig") self.cpp_info.libs = ["fontconfig"] - if self.settings.os in ["Linux", "FreeBSD"]: + if self.settings.os in ("Linux", "FreeBSD"): self.cpp_info.system_libs.extend(["m", "pthread"]) + self.cpp_info.names["cmake_find_package"] = "Fontconfig" self.cpp_info.names["cmake_find_package_multi"] = "Fontconfig" fontconfig_file = os.path.join(self.package_folder, "bin", "etc", "fonts", "fonts.conf") - self.output.info("Creating FONTCONFIG_FILE environment variable: {}".format(fontconfig_file)) - self.env_info.FONTCONFIG_FILE = fontconfig_file + self.output.info(f"Creating FONTCONFIG_FILE environment variable: {fontconfig_file}") + self.runenv_info.prepend_path("FONTCONFIG_FILE", fontconfig_file) + self.env_info.FONTCONFIG_FILE = fontconfig_file # TODO: remove in conan v2? + fontconfig_path = os.path.join(self.package_folder, "bin", "etc", "fonts") - self.output.info("Creating FONTCONFIG_PATH environment variable: {}".format(fontconfig_path)) - self.env_info.FONTCONFIG_PATH = fontconfig_path + self.output.info(f"Creating FONTCONFIG_PATH environment variable: {fontconfig_path}") + self.runenv_info.prepend_path("FONTCONFIG_PATH", fontconfig_path) + self.env_info.FONTCONFIG_PATH = fontconfig_path # TODO: remove in conan v2? diff --git a/recipes/fontconfig/all/patches/0001-meson-win32.patch b/recipes/fontconfig/all/patches/0001-meson-win32.patch new file mode 100644 index 0000000000000..c8a4911fc8e45 --- /dev/null +++ b/recipes/fontconfig/all/patches/0001-meson-win32.patch @@ -0,0 +1,19 @@ +--- conf.d/link_confs.py ++++ conf.d/link_confs.py +@@ -3,6 +3,7 @@ + import os + import sys + import argparse ++import platform + + if __name__=='__main__': + parser = argparse.ArgumentParser() +@@ -26,7 +27,7 @@ if __name__=='__main__': + break + except OSError as e: + # Symlink privileges are not available +- if len(e.args) == 1 and 'privilege' in e.args[0]: ++ if platform.system().lower() == 'windows' and e.winerror == 1314: + break + raise + except FileExistsError: diff --git a/recipes/fontconfig/all/test_package/CMakeLists.txt b/recipes/fontconfig/all/test_package/CMakeLists.txt index 898750bf8dcb3..b6e6cbcb01868 100644 --- a/recipes/fontconfig/all/test_package/CMakeLists.txt +++ b/recipes/fontconfig/all/test_package/CMakeLists.txt @@ -1,12 +1,11 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest C) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(Fontconfig REQUIRED) -add_executable(example example.c) -target_link_libraries(example Fontconfig::Fontconfig) -set_target_properties(example PROPERTIES C_STANDARD 99) - +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} Fontconfig::Fontconfig) +set_target_properties(${PROJECT_NAME} PROPERTIES C_STANDARD 99) diff --git a/recipes/fontconfig/all/test_package/conanfile.py b/recipes/fontconfig/all/test_package/conanfile.py index b9477071b4082..f66887c4fac91 100644 --- a/recipes/fontconfig/all/test_package/conanfile.py +++ b/recipes/fontconfig/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -import os from conans import ConanFile, CMake, tools +import os -class FontconfigTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package" + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") + def build(self): cmake = CMake(self) cmake.configure() @@ -12,4 +22,5 @@ def build(self): def test(self): if not tools.cross_building(self, skip_x64_x86=True): - self.run(os.path.join("bin", "example"), run_environment=True) + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fontconfig/all/test_package/example.c b/recipes/fontconfig/all/test_package/example.c deleted file mode 100644 index 5b35a9578017b..0000000000000 --- a/recipes/fontconfig/all/test_package/example.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -int main() { - FcConfig* config = FcInitLoadConfigAndFonts(); - FcPattern* pat = FcNameParse((const FcChar8*)"Arial"); - FcConfigSubstitute(config, pat, FcMatchPattern); - FcDefaultSubstitute(pat); - char* fontFile; - FcResult result; - FcPattern* font = FcFontMatch(config, pat, &result); - if (font) { - FcChar8* file = NULL; - if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) { - fontFile = (char*)file; - printf("%s\n",fontFile); - } - } else { - printf("Ops! I can't find any font!\n"); - } - FcPatternDestroy(pat); - return EXIT_SUCCESS; -} diff --git a/recipes/fontconfig/all/test_package/test_package.c b/recipes/fontconfig/all/test_package/test_package.c new file mode 100644 index 0000000000000..7703ab64bbdec --- /dev/null +++ b/recipes/fontconfig/all/test_package/test_package.c @@ -0,0 +1,24 @@ +#include +#include +#include + +int main() { + FcConfig* config = FcInitLoadConfigAndFonts(); + FcPattern* pat = FcNameParse((const FcChar8*)"Arial"); + FcConfigSubstitute(config, pat, FcMatchPattern); + FcDefaultSubstitute(pat); + char* fontFile; + FcResult result; + FcPattern* font = FcFontMatch(config, pat, &result); + if (font) { + FcChar8* file = NULL; + if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) { + fontFile = (char*)file; + printf("%s\n",fontFile); + } + } else { + printf("Ops! I can't find any font!\n"); + } + FcPatternDestroy(pat); + return EXIT_SUCCESS; +} diff --git a/recipes/fontconfig/config.yml b/recipes/fontconfig/config.yml index 50284f29c712d..266274964008f 100644 --- a/recipes/fontconfig/config.yml +++ b/recipes/fontconfig/config.yml @@ -1,6 +1,6 @@ versions: "2.13.93": - folder: all + folder: meson "2.13.92": folder: all "2.13.91": diff --git a/recipes/fontconfig/meson/conandata.yml b/recipes/fontconfig/meson/conandata.yml new file mode 100644 index 0000000000000..473f136c77b81 --- /dev/null +++ b/recipes/fontconfig/meson/conandata.yml @@ -0,0 +1,10 @@ +sources: + "2.13.93": + url: "https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.93.tar.gz" + sha256: "0f302a18ee52dde0793fe38b266bf269dfe6e0c0ae140e30d72c6cca5dc08db5" +patches: + "2.13.93": + - patch_file: "patches/0001-meson-win32.patch" + patch_type: "backport" + patch_source: "https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/7bfbaecf819a8b1630dfc8f56126e31f985d5fb3" + patch_description: "Windows: Fix symlink privilege error detection" diff --git a/recipes/fontconfig/meson/conanfile.py b/recipes/fontconfig/meson/conanfile.py new file mode 100644 index 0000000000000..325f9afad288e --- /dev/null +++ b/recipes/fontconfig/meson/conanfile.py @@ -0,0 +1,137 @@ +from conan import ConanFile +from conan.tools.files import ( + apply_conandata_patches, + copy, + export_conandata_patches, + get, + rename, + replace_in_file, + rm, + rmdir +) +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +from conan.tools.env import VirtualBuildEnv +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.gnu import PkgConfigDeps + +import os + +required_conan_version = ">=1.53.0" + + +class FontconfigConan(ConanFile): + name = "fontconfig" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + description = "Fontconfig is a library for configuring and customizing font access" + homepage = "https://gitlab.freedesktop.org/fontconfig/fontconfig" + topics = ("fonts", "freedesktop") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def requirements(self): + self.requires("freetype/2.12.1") + self.requires("expat/2.5.0") + if self.settings.os == "Linux": + self.requires("libuuid/1.0.3") + + def build_requirements(self): + self.tool_requires("gperf/3.1") + self.tool_requires("meson/0.63.3") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/1.9.3") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self.source_folder) + + def layout(self): + basic_layout(self, src_folder="src") + + def generate(self): + deps = PkgConfigDeps(self) + deps.generate() + + tc = MesonToolchain(self) + tc.project_options.update({ + "doc": "disabled", + "nls": "disabled", + "tests": "disabled", + "tools": "disabled" + }) + tc.generate() + + env = VirtualBuildEnv(self) + env.generate() + + def _patch_files(self): + apply_conandata_patches(self) + replace_in_file(self, os.path.join(self.source_folder, "meson.build"), + "freetype_req = '>= 21.0.15'", + f"freetype_req = '{Version(self.deps_cpp_info['freetype'].version)}'") + + def build(self): + self._patch_files() + meson = Meson(self) + meson.configure() + meson.build() + + def package(self): + meson = Meson(self) + meson.install() + if is_msvc(self): + if os.path.isfile(os.path.join(self.package_folder, "lib", "libfontconfig.a")): + rename(self, os.path.join(self.package_folder, "lib", "libfontconfig.a"), + os.path.join(self.package_folder, "lib", "fontconfig.lib")) + + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + rm(self, "*.conf", os.path.join(self.package_folder, "bin", "etc", "fonts", "conf.d")) + rm(self, "*.def", os.path.join(self.package_folder, "lib")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "etc")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "Fontconfig") + self.cpp_info.set_property("cmake_target_name", "Fontconfig::Fontconfig") + self.cpp_info.set_property("pkg_config_name", "fontconfig") + self.cpp_info.libs = ["fontconfig"] + if self.settings.os in ("Linux", "FreeBSD"): + self.cpp_info.system_libs.extend(["m", "pthread"]) + + self.cpp_info.names["cmake_find_package"] = "Fontconfig" + self.cpp_info.names["cmake_find_package_multi"] = "Fontconfig" + + fontconfig_file = os.path.join(self.package_folder, "bin", "etc", "fonts", "fonts.conf") + self.output.info(f"Creating FONTCONFIG_FILE environment variable: {fontconfig_file}") + self.runenv_info.prepend_path("FONTCONFIG_FILE", fontconfig_file) + self.env_info.FONTCONFIG_FILE = fontconfig_file # TODO: remove in conan v2? + + fontconfig_path = os.path.join(self.package_folder, "bin", "etc", "fonts") + self.output.info(f"Creating FONTCONFIG_PATH environment variable: {fontconfig_path}") + self.runenv_info.prepend_path("FONTCONFIG_PATH", fontconfig_path) + self.env_info.FONTCONFIG_PATH = fontconfig_path # TODO: remove in conan v2? diff --git a/recipes/fontconfig/meson/patches/0001-meson-win32.patch b/recipes/fontconfig/meson/patches/0001-meson-win32.patch new file mode 100644 index 0000000000000..c8a4911fc8e45 --- /dev/null +++ b/recipes/fontconfig/meson/patches/0001-meson-win32.patch @@ -0,0 +1,19 @@ +--- conf.d/link_confs.py ++++ conf.d/link_confs.py +@@ -3,6 +3,7 @@ + import os + import sys + import argparse ++import platform + + if __name__=='__main__': + parser = argparse.ArgumentParser() +@@ -26,7 +27,7 @@ if __name__=='__main__': + break + except OSError as e: + # Symlink privileges are not available +- if len(e.args) == 1 and 'privilege' in e.args[0]: ++ if platform.system().lower() == 'windows' and e.winerror == 1314: + break + raise + except FileExistsError: diff --git a/recipes/fontconfig/meson/test_package/CMakeLists.txt b/recipes/fontconfig/meson/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..cf73820fd98bc --- /dev/null +++ b/recipes/fontconfig/meson/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +find_package(Fontconfig CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE Fontconfig::Fontconfig) +set_target_properties(${PROJECT_NAME} PROPERTIES C_STANDARD 99) diff --git a/recipes/fontconfig/meson/test_package/conanfile.py b/recipes/fontconfig/meson/test_package/conanfile.py new file mode 100644 index 0000000000000..42aa9d19c7fbe --- /dev/null +++ b/recipes/fontconfig/meson/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fontconfig/meson/test_package/test_package.c b/recipes/fontconfig/meson/test_package/test_package.c new file mode 100644 index 0000000000000..7703ab64bbdec --- /dev/null +++ b/recipes/fontconfig/meson/test_package/test_package.c @@ -0,0 +1,24 @@ +#include +#include +#include + +int main() { + FcConfig* config = FcInitLoadConfigAndFonts(); + FcPattern* pat = FcNameParse((const FcChar8*)"Arial"); + FcConfigSubstitute(config, pat, FcMatchPattern); + FcDefaultSubstitute(pat); + char* fontFile; + FcResult result; + FcPattern* font = FcFontMatch(config, pat, &result); + if (font) { + FcChar8* file = NULL; + if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) { + fontFile = (char*)file; + printf("%s\n",fontFile); + } + } else { + printf("Ops! I can't find any font!\n"); + } + FcPatternDestroy(pat); + return EXIT_SUCCESS; +} diff --git a/recipes/fontconfig/meson/test_v1_package/CMakeLists.txt b/recipes/fontconfig/meson/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9e65290cb3f89 --- /dev/null +++ b/recipes/fontconfig/meson/test_v1_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/ +) diff --git a/recipes/fontconfig/meson/test_v1_package/conanfile.py b/recipes/fontconfig/meson/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/fontconfig/meson/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/foonathan-lexy/all/conandata.yml b/recipes/foonathan-lexy/all/conandata.yml new file mode 100644 index 0000000000000..f7151e22f94ba --- /dev/null +++ b/recipes/foonathan-lexy/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2022.05.01": + url: "https://github.com/foonathan/lexy/releases/download/v2022.05.1/lexy-src.zip" + sha256: "de2199f8233ea5ed9d4dbe86a8eaf88d754decd28e28554329a7b29b4d952773" diff --git a/recipes/foonathan-lexy/all/conanfile.py b/recipes/foonathan-lexy/all/conanfile.py new file mode 100644 index 0000000000000..bc8d75798a2d5 --- /dev/null +++ b/recipes/foonathan-lexy/all/conanfile.py @@ -0,0 +1,107 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.files import get, copy, rm, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.53.0" + +class FoonathanLexyConan(ConanFile): + name = "foonathan-lexy" + description = "lexy is a parser combinator library for C++17 and onwards." + license = "BSL-1.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/foonathan/lexy" + topics = ("parser", "parser-combinators", "grammar") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + options = { + "fPIC": [True, False], + } + default_options = { + "fPIC": True, + } + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8", + "clang": "7", + "apple-clang": "10", + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + check_min_vs(self, 192) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + def build_requirements(self): + self.tool_requires("cmake/3.18.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LEXY_BUILD_EXAMPLES"] = False + tc.variables["LEXY_BUILD_TESTS"] = False + tc.variables["LEXY_BUILD_PACKAGE"] = False + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + # some files extensions and folders are not allowed. Please, read the FAQs to get informed. + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "lexy") + self.cpp_info.set_property("cmake_target_name", "foonathan::lexy") + + self.cpp_info.components["lexy_core"].set_property("cmake_target_name", "foonathan::lexy::lexy_core") + + self.cpp_info.components["lexy_file"].set_property("cmake_target_name", "foonathan::lexy::lexy_file") + self.cpp_info.components["lexy_file"].libs = ["lexy_file"] + + self.cpp_info.components["lexy_unicode"].set_property("cmake_target_name", "lexy::lexy_unicode") + self.cpp_info.components["lexy_unicode"].defines.append("LEXY_HAS_UNICODE_DATABASE=1") + + self.cpp_info.components["lexy_ext"].set_property("cmake_target_name", "lexy::lexy_ext") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "lexy" + self.cpp_info.filenames["cmake_find_package_multi"] = "lexy" + self.cpp_info.names["cmake_find_package"] = "foonathan" + self.cpp_info.names["cmake_find_package_multi"] = "foonathan" + self.cpp_info.components["foonathan"].names["cmake_find_package"] = "lexy" + self.cpp_info.components["foonathan"].names["cmake_find_package_multi"] = "lexy" diff --git a/recipes/foonathan-lexy/all/test_package/CMakeLists.txt b/recipes/foonathan-lexy/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..caf4fe13f8177 --- /dev/null +++ b/recipes/foonathan-lexy/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package LANGUAGES CXX) + +find_package(lexy REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE foonathan::lexy) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/foonathan-lexy/all/test_package/conanfile.py b/recipes/foonathan-lexy/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1111583fea732 --- /dev/null +++ b/recipes/foonathan-lexy/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/foonathan-lexy/all/test_package/test_package.cpp b/recipes/foonathan-lexy/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..6efe05caf5ed2 --- /dev/null +++ b/recipes/foonathan-lexy/all/test_package/test_package.cpp @@ -0,0 +1,43 @@ +#include + +#include +#include +#include +#include +#include + +struct Color +{ + std::uint8_t r, g, b; +}; + +namespace grammar +{ +namespace dsl = lexy::dsl; + +struct channel +{ + static constexpr auto rule = dsl::integer(dsl::n_digits<2, dsl::hex>); + static constexpr auto value = lexy::forward; +}; + +struct color +{ + static constexpr auto rule = dsl::hash_sign + dsl::times<3>(dsl::p); + static constexpr auto value = lexy::construct; +}; +} // namespace grammar + +int main() { + unsigned char array[] = {'#', '5', '5', 'A', 'A', '0', '5'}; + + auto input = lexy::string_input(array, array + 7); + auto result = lexy::parse(input, lexy_ext::report_error); + if (result.has_value()) + { + auto color = result.value(); + std::printf("#%02x%02x%02x\n", color.r, color.g, color.b); + } + + return result ? 0 : 1; +} diff --git a/recipes/foonathan-lexy/all/test_v1_package/CMakeLists.txt b/recipes/foonathan-lexy/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/foonathan-lexy/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/foonathan-lexy/all/test_v1_package/conanfile.py b/recipes/foonathan-lexy/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/foonathan-lexy/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/foonathan-lexy/config.yml b/recipes/foonathan-lexy/config.yml new file mode 100644 index 0000000000000..0ce23eac9b55d --- /dev/null +++ b/recipes/foonathan-lexy/config.yml @@ -0,0 +1,3 @@ +versions: + "2022.05.01": + folder: all diff --git a/recipes/foonathan-memory/all/conandata.yml b/recipes/foonathan-memory/all/conandata.yml new file mode 100644 index 0000000000000..7a847a5e8afc7 --- /dev/null +++ b/recipes/foonathan-memory/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "0.7.2": + url: "https://github.com/foonathan/memory/archive/refs/tags/v0.7-2.tar.gz" + sha256: "8aba7211bb0e59b7538decda453e492cc6e36f8781508ed92b38cbafe8a48762" + "0.7.1": + url: "https://github.com/foonathan/memory/archive/refs/tags/v0.7-1.tar.gz" + sha256: "19eb61c5cba6ccc40b8ee741350fd29402a46641ba752c30b7079528d87dbc79" + "0.7.0": + url: "https://github.com/foonathan/memory/archive/refs/tags/v0.7.tar.gz" + sha256: "01a7cc5a5ebddbd71bec69c89562a4a2ecd7c29334c0a29d38d83e7f7f66eb53" +patches: + "0.7.0": + - patch_file: "patches/0.7.0-0001-fix-virtualAllocFromApp.patch" diff --git a/recipes/foonathan-memory/all/conanfile.py b/recipes/foonathan-memory/all/conanfile.py new file mode 100644 index 0000000000000..b341ffe0edc58 --- /dev/null +++ b/recipes/foonathan-memory/all/conanfile.py @@ -0,0 +1,119 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get, rm, rmdir, save +import os +import textwrap + +required_conan_version = ">=1.53.0" + + +class FoonathanMemoryConan(ConanFile): + name = "foonathan-memory" + license = "Zlib" + homepage = "https://github.com/foonathan/memory" + url = "https://github.com/conan-io/conan-center-index" + description = "STL compatible C++ memory allocator library" + topics = ("memory", "STL", "RawAllocator") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_tools": [True, False], + "with_sizecheck":[True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_tools": True, + "with_sizecheck": True, + } + + short_paths = True + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def validate(self): + # FIXME: jenkins servers throw error with this combination + # quick fix until somebody can reproduce + if hasattr(self, "settings_build") and cross_building(self): + raise ConanInvalidConfiguration("Cross building is not yet supported. Contributions are welcome") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FOONATHAN_MEMORY_BUILD_EXAMPLES"] = False + tc.variables["FOONATHAN_MEMORY_BUILD_TESTS"] = False + tc.variables["FOONATHAN_MEMORY_BUILD_TOOLS"] = self.options.with_tools + tc.variables["FOONATHAN_MEMORY_CHECK_ALLOCATION_SIZE"] = self.options.with_sizecheck + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "foonathan_memory", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + + # TODO: to remove in conan v2 once legacy generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"foonathan_memory": "foonathan_memory::foonathan_memory"}, + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "foonathan_memory") + self.cpp_info.set_property("cmake_target_name", "foonathan_memory") + self.cpp_info.libs = collect_libs(self) + self.cpp_info.includedirs = [os.path.join("include", "foonathan_memory")] + + if self.options.with_tools: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH env var with : {bin_path}"), + self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.names["cmake_find_package"] = "foonathan_memory" + self.cpp_info.names["cmake_find_package_multi"] = "foonathan_memory" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/foonathan-memory/all/patches/0.7.0-0001-fix-virtualAllocFromApp.patch b/recipes/foonathan-memory/all/patches/0.7.0-0001-fix-virtualAllocFromApp.patch new file mode 100755 index 0000000000000..7961ecb88013c --- /dev/null +++ b/recipes/foonathan-memory/all/patches/0.7.0-0001-fix-virtualAllocFromApp.patch @@ -0,0 +1,22 @@ +diff --git a/src/virtual_memory.cpp b/src/virtual_memory.cpp +index 74d1c4e..d0e5fd5 100644 +--- a/src/virtual_memory.cpp ++++ b/src/virtual_memory.cpp +@@ -37,7 +37,7 @@ const std::size_t foonathan::memory::virtual_memory_page_size = get_page_size(); + void* foonathan::memory::virtual_memory_reserve(std::size_t no_pages) noexcept + { + auto pages = +-#if (_MSC_VER <= 1900) ++#if (_MSC_VER <= 1900) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + VirtualAlloc(nullptr, no_pages * virtual_memory_page_size, MEM_RESERVE, PAGE_READWRITE); + #else + VirtualAllocFromApp(nullptr, no_pages * virtual_memory_page_size, MEM_RESERVE, +@@ -55,7 +55,7 @@ void foonathan::memory::virtual_memory_release(void* pages, std::size_t) noexcep + void* foonathan::memory::virtual_memory_commit(void* memory, std::size_t no_pages) noexcept + { + auto region = +-#if (_MSC_VER <= 1900) ++#if (_MSC_VER <= 1900) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + VirtualAlloc(memory, no_pages * virtual_memory_page_size, MEM_COMMIT, PAGE_READWRITE); + #else + VirtualAllocFromApp(memory, no_pages * virtual_memory_page_size, MEM_COMMIT, diff --git a/recipes/foonathan-memory/all/test_package/CMakeLists.txt b/recipes/foonathan-memory/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f778dab17e9aa --- /dev/null +++ b/recipes/foonathan-memory/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(foonathan_memory REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE foonathan_memory) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/foonathan-memory/all/test_package/conanfile.py b/recipes/foonathan-memory/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/foonathan-memory/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/foonathan-memory/all/test_package/test_package.cpp b/recipes/foonathan-memory/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..20153e0cbe2dc --- /dev/null +++ b/recipes/foonathan-memory/all/test_package/test_package.cpp @@ -0,0 +1,69 @@ + +// Copyright (C) 2015-2021 Müller +// This file is subject to the license terms in the LICENSE file +// found in the top-level directory of this distribution. + +// this example shows how to store allocators by reference and type-erased +// see https://memory.foonathan.net/md_doc_adapters_storage.html for further details + +#include +#include + +#include // allocator_reference, any_allocator_reference +#include // heap_allocator +#include // memory_stack + +// alias namespace foonathan::memory as memory for easier access +#include + +template +void do_sth(memory::allocator_reference ref); + +int main() +{ + using namespace memory::literals; + + // storing stateless allocator by reference + // heap_allocator is stateless so it does not need to be actually referenced + // the reference can take it as a temporary and construct it on the fly + memory::allocator_reference ref_stateless(memory::heap_allocator{}); + do_sth(ref_stateless); + + // create a memory_stack + // allocates a memory block - initially 4KiB big - and allocates from it in a stack-like manner + // deallocation is only done via unwinding to a previously queried marker + memory::memory_stack<> stack(4_KiB); + + // storing stateful allocator by reference + // memory_stack is stateful and thus the reference actually takes the address of the object + // the user has to ensure that the referenced object lives long enough + memory::allocator_reference> ref_stateful(stack); + do_sth(ref_stateful); + + // storing a reference type-erased + // any_allocator_reference is an alias for allocator_reference + // it triggers a specialization that uses type-erasure + // the tag type can be passed to any class that uses an allocator_reference internally, + // like std_allocator or the deep_copy_ptr from the other example + memory::any_allocator_reference any1( + ref_stateful); // initialize with another allocator reference, will "unwrap" + do_sth(any1); + + memory::any_allocator_reference any2(stack); // initialize with a "normal" RawAllocator + do_sth(any2); + + memory::any_allocator_reference any3( + std::allocator{}); // normal Allocators are RawAllocators, too, so this works + do_sth(any3); +} + +template +void do_sth(memory::allocator_reference ref) +{ + // ref is a full-blown RawAllocator that provides all member functions, + // so there is no need to use the allocator_traits + + auto node = ref.allocate_node(sizeof(int), alignof(int)); + std::cout << "Got memory for an int " << node << '\n'; + ref.deallocate_node(node, sizeof(int), alignof(int)); +} diff --git a/recipes/foonathan-memory/all/test_v1_package/CMakeLists.txt b/recipes/foonathan-memory/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9d54a092e0a67 --- /dev/null +++ b/recipes/foonathan-memory/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/foonathan-memory/all/test_v1_package/conanfile.py b/recipes/foonathan-memory/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/foonathan-memory/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/foonathan-memory/config.yml b/recipes/foonathan-memory/config.yml new file mode 100644 index 0000000000000..75789cf28caa8 --- /dev/null +++ b/recipes/foonathan-memory/config.yml @@ -0,0 +1,7 @@ +versions: + "0.7.2": + folder: all + "0.7.1": + folder: all + "0.7.0": + folder: all diff --git a/recipes/forestdb/all/CMakeLists.txt b/recipes/forestdb/all/CMakeLists.txt new file mode 100644 index 0000000000000..78b537ac50f88 --- /dev/null +++ b/recipes/forestdb/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.10) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/forestdb/all/conandata.yml b/recipes/forestdb/all/conandata.yml new file mode 100644 index 0000000000000..935f0559af335 --- /dev/null +++ b/recipes/forestdb/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "cci.20220727": + url: "https://github.com/ForestDB-KVStore/Simple-ForestDB/archive/123dc7b2e4e99f85df6ed7a5b995393ec2197b09.tar.gz" + sha256: f847321479b525dccd9918799d9672d16140de65a3e07b8a2cc1cf92ff41bb65 +patches: + "cci.20220727": + - patch_file: "patches/0001-proper-cxx-std-flag.patch" + base_path: "source_subfolder" diff --git a/recipes/forestdb/all/conanfile.py b/recipes/forestdb/all/conanfile.py new file mode 100644 index 0000000000000..526ab2f1f2069 --- /dev/null +++ b/recipes/forestdb/all/conanfile.py @@ -0,0 +1,87 @@ +import os +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + +class ForestDBConan(ConanFile): + name = "forestdb" + description = "ForestDB is a KeyValue store based on a Hierarchical B+-Tree." + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/ForestDB-KVStore/forestdb" + topics = ("kv-store", "mvcc", "wal") + settings = "os", "arch", "compiler", "build_type" + + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_snappy": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "with_snappy": False, + } + + generators = "cmake" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def requirements(self): + if self.options.with_snappy: + self.requires("snappy/1.1.9") + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("Windows Builds Unsupported") + if self.settings.compiler == "clang": + if self.settings.compiler.libcxx == "libc++" and self.options.shared == False: + raise ConanInvalidConfiguration("LibC++ Static Builds Unsupported") + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, 11) + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = CMake(self) + cmake.definitions["SNAPPY_OPTION"] = "Disable" + if self.options.with_snappy: + cmake.definitions["SNAPPY_OPTION"] = "Enable" + cmake.configure() + lib_target = "forestdb" + if not self.options.shared: + lib_target = "static_lib" + cmake.build(target=lib_target) + + def package(self): + self.copy("LICENSE", dst="licenses/", src=self._source_subfolder ) + # Parent Build system does not support library type selection + # and will only install the shared object from cmake; so we must + # handpick our libraries. + self.copy("*.a*", dst="lib", src="lib") + self.copy("*.lib", dst="lib", src="lib") + self.copy("*.so*", dst="lib", src="lib", symlinks=True) + self.copy("*.dylib*", dst="lib", src="lib", symlinks=True) + self.copy("*.dll*", dst="lib", src="lib") + self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "include"), keep_path=True) + + def package_info(self): + self.cpp_info.libs = ["forestdb"] + self.cpp_info.system_libs.extend(["pthread", "m", "dl"]) + if self.settings.os == "Linux": + self.cpp_info.system_libs.extend(["rt"]) diff --git a/recipes/forestdb/all/patches/0001-proper-cxx-std-flag.patch b/recipes/forestdb/all/patches/0001-proper-cxx-std-flag.patch new file mode 100644 index 0000000000000..e21c0fb1e24c6 --- /dev/null +++ b/recipes/forestdb/all/patches/0001-proper-cxx-std-flag.patch @@ -0,0 +1,25 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 22f58c7..af6e3e2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,18 +5,8 @@ IF (${CMAKE_MAJOR_VERSION} GREATER 2) + CMAKE_POLICY(SET CMP0042 NEW) + ENDIF (${CMAKE_MAJOR_VERSION} GREATER 2) + +-INCLUDE(CheckCXXCompilerFlag) +-CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) +-CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) +-IF (COMPILER_SUPPORTS_CXX11) +- SET(STD_VERSION "-std=c++11") +-ELSEIF(COMPILER_SUPPORTS_CXX0X) +- SET(STD_VERSION "-std=c++0x") +-ELSE() +- IF (NOT WIN32) +- MESSAGE(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.") +- ENDIF() +-ENDIF() ++set(CMAKE_CXX_STANDARD 11) ++set(STD_VERSION "") + + INCLUDE(CheckFunctionExists) + INCLUDE(CheckIncludeFileCXX) diff --git a/recipes/forestdb/all/test_package/CMakeLists.txt b/recipes/forestdb/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..9912b39ed8da5 --- /dev/null +++ b/recipes/forestdb/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(forestdb REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} forestdb::forestdb) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/forestdb/all/test_package/conanfile.py b/recipes/forestdb/all/test_package/conanfile.py new file mode 100644 index 0000000000000..751b9d5bc7b9c --- /dev/null +++ b/recipes/forestdb/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools, RunEnvironment +from conan.tools.build import cross_building +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/forestdb/all/test_package/test_package.cpp b/recipes/forestdb/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..3f6128efe9bfd --- /dev/null +++ b/recipes/forestdb/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +int main(void) { + fdb_config default_config = fdb_get_default_config(); + fdb_status const status = fdb_init(&default_config); + if (FDB_RESULT_SUCCESS != status) return -1; + return 0; +} diff --git a/recipes/forestdb/config.yml b/recipes/forestdb/config.yml new file mode 100644 index 0000000000000..df66b73b532f4 --- /dev/null +++ b/recipes/forestdb/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220727": + folder: all diff --git a/recipes/foxglove-websocket/all/conandata.yml b/recipes/foxglove-websocket/all/conandata.yml new file mode 100644 index 0000000000000..e0bef4a6e6152 --- /dev/null +++ b/recipes/foxglove-websocket/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + 0.0.1: + url: https://github.com/foxglove/ws-protocol/archive/refs/tags/releases/cpp/v0.0.1.tar.gz + sha256: 94766f44973f0c0ce7e87039b9ef9d5b4a8bc73727047568170ac61262625c9b diff --git a/recipes/foxglove-websocket/all/conanfile.py b/recipes/foxglove-websocket/all/conanfile.py new file mode 100644 index 0000000000000..2d4424bef585f --- /dev/null +++ b/recipes/foxglove-websocket/all/conanfile.py @@ -0,0 +1,40 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + + +class FoxgloveWebSocketConan(ConanFile): + name = "foxglove-websocket" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/foxglove/ws-protocol" + description = "A C++ server implementation of the Foxglove WebSocket Protocol" + license = "MIT" + topics = ("foxglove", "websocket") + + settings = ("os", "compiler", "build_type", "arch") + requires = ("nlohmann_json/3.10.5", "websocketpp/0.8.2") + generators = ("cmake", "cmake_find_package") + + _source_root = "source_root" + _source_package_path = os.path.join(_source_root, "cpp", "foxglove-websocket") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_root) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "17") + if (self.settings.compiler == "gcc" or self.settings.compiler == "clang") and tools.Version(self.settings.compiler.version) <= 8: + raise ConanInvalidConfiguration("Compiler version is not supported, c++17 support is required") + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) <= "16.8": + raise ConanInvalidConfiguration("Compiler version is not supported, c++17 support is required") + + def configure(self): + self.options["websocketpp"].asio = "standalone" + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_package_path) + self.copy("include/*", src=self._source_package_path) + + def package_id(self): + self.info.header_only() diff --git a/recipes/foxglove-websocket/all/test_package/CMakeLists.txt b/recipes/foxglove-websocket/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2b26900ab008c --- /dev/null +++ b/recipes/foxglove-websocket/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(foxglove-websocket REQUIRED CONFIG) + +add_executable(test_package test_package.cpp) +set_target_properties(test_package PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) +target_link_libraries(test_package foxglove-websocket::foxglove-websocket) diff --git a/recipes/foxglove-websocket/all/test_package/conanfile.py b/recipes/foxglove-websocket/all/test_package/conanfile.py new file mode 100644 index 0000000000000..005eae16e0474 --- /dev/null +++ b/recipes/foxglove-websocket/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = ("os", "arch", "compiler", "build_type") + generators = ("cmake", "cmake_find_package_multi") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/foxglove-websocket/all/test_package/test_package.cpp b/recipes/foxglove-websocket/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..13842a1ec1a3b --- /dev/null +++ b/recipes/foxglove-websocket/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include +#include + +int main() { + foxglove::websocket::Server server{0, "example"}; + server.getEndpoint().set_timer(0, [&](std::error_code const& ec) { + server.stop(); + }); + server.run(); + return 0; +} diff --git a/recipes/foxglove-websocket/config.yml b/recipes/foxglove-websocket/config.yml new file mode 100644 index 0000000000000..768a10bf6dc2b --- /dev/null +++ b/recipes/foxglove-websocket/config.yml @@ -0,0 +1,3 @@ +versions: + 0.0.1: + folder: all diff --git a/recipes/foxi/all/CMakeLists.txt b/recipes/foxi/all/CMakeLists.txt deleted file mode 100644 index bd3083b512cb9..0000000000000 --- a/recipes/foxi/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/foxi/all/conandata.yml b/recipes/foxi/all/conandata.yml index fd5de7215a10b..b242c7b479adf 100644 --- a/recipes/foxi/all/conandata.yml +++ b/recipes/foxi/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "cci.20210217": - patch_file: "patches/fix-conflicting-types.patch" - base_path: "source_subfolder" diff --git a/recipes/foxi/all/conanfile.py b/recipes/foxi/all/conanfile.py index 61ff46adc3e82..1215880aee391 100644 --- a/recipes/foxi/all/conanfile.py +++ b/recipes/foxi/all/conanfile.py @@ -1,74 +1,82 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rename, replace_in_file import glob import os -import shutil + +required_conan_version = ">=1.46.0" class FoxiConan(ConanFile): name = "foxi" description = "ONNXIFI with Facebook Extension." license = "MIT" - topics = ("conan", "foxi", "onnxifi") + topics = ("foxi", "onnxifi") homepage = "https://github.com/houseroad/foxi" url = "https://github.com/conan-io/conan-center-index" settings = "os", "arch", "compiler", "build_type" - options = {"fPIC": [True, False]} - default_options = {"fPIC": True} - - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - _cmake = None + options = { + "fPIC": [True, False], + } + default_options = { + "fPIC": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("foxi-*")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FOXI_WERROR"] = False + tc.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") - tools.replace_in_file(cmakelists, "add_msvc_runtime_flag(foxi_loader)", "") - tools.replace_in_file(cmakelists, "add_msvc_runtime_flag(foxi_dummy)", "") - tools.replace_in_file(cmakelists, + apply_conandata_patches(self) + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + replace_in_file(self, cmakelists, "add_msvc_runtime_flag(foxi_loader)", "") + replace_in_file(self, cmakelists, "add_msvc_runtime_flag(foxi_dummy)", "") + replace_in_file(self, cmakelists, "DESTINATION lib", "RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["FOXI_WERROR"] = False - self._cmake.configure() - return self._cmake - def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() # Move plugin to bin folder on Windows for dll_file in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")): - shutil.move(dll_file, os.path.join(self.package_folder, "bin", os.path.basename(dll_file))) + rename(self, src=dll_file, dst=os.path.join(self.package_folder, "bin", os.path.basename(dll_file))) def package_info(self): self.cpp_info.libs = ["foxi_dummy", "foxi_loader"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["dl"] diff --git a/recipes/foxi/all/test_package/CMakeLists.txt b/recipes/foxi/all/test_package/CMakeLists.txt index 7b9b613cbb24a..ab378d1724765 100644 --- a/recipes/foxi/all/test_package/CMakeLists.txt +++ b/recipes/foxi/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(foxi REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE foxi::foxi) diff --git a/recipes/foxi/all/test_package/conanfile.py b/recipes/foxi/all/test_package/conanfile.py index 5216332f39f5c..3a8c6c5442b33 100644 --- a/recipes/foxi/all/test_package/conanfile.py +++ b/recipes/foxi/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/foxi/all/test_v1_package/CMakeLists.txt b/recipes/foxi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a1ab465c8f39c --- /dev/null +++ b/recipes/foxi/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(foxi REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE foxi::foxi) diff --git a/recipes/foxi/all/test_v1_package/conanfile.py b/recipes/foxi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/foxi/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fp16/all/conandata.yml b/recipes/fp16/all/conandata.yml index 29a147edc46d4..cf80322a4b8bb 100644 --- a/recipes/fp16/all/conandata.yml +++ b/recipes/fp16/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "cci.20210320": + url: "https://github.com/Maratyszcza/FP16/archive/0a92994d729ff76a58f692d3028ca1b64b145d91.zip" + sha256: "e66e65515fa09927b348d3d584c68be4215cfe664100d01c9dbc7655a5716d70" "cci.20200514": url: "https://github.com/Maratyszcza/FP16/archive/4dfe081cf6bcd15db339cf2680b9281b8451eeb3.zip" sha256: "d973501a40c55126b31accc2d9f08d931ec3cc190c0430309a5e341d3c0ce32a" diff --git a/recipes/fp16/all/conanfile.py b/recipes/fp16/all/conanfile.py index 971e7f2d0585d..75666c9f3bd71 100644 --- a/recipes/fp16/all/conanfile.py +++ b/recipes/fp16/all/conanfile.py @@ -1,33 +1,41 @@ -from conans import ConanFile, tools -import glob +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.52.0" + class Fp16Conan(ConanFile): name = "fp16" description = "Conversion to/from half-precision floating point formats." license = "MIT" - topics = ("conan", "fp16", "half-precision-floating-point") + topics = ("half-precision-floating-point") homepage = "https://github.com/Maratyszcza/FP16" url = "https://github.com/conan-io/conan-center-index" - + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): - self.requires("psimd/cci.20200517") + self.requires("psimd/cci.20200517", transitive_headers=True) def package_id(self): - self.info.header_only() + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("FP16-*")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/fp16/all/test_package/CMakeLists.txt b/recipes/fp16/all/test_package/CMakeLists.txt index fd126a732c403..1e502f0857d7c 100644 --- a/recipes/fp16/all/test_package/CMakeLists.txt +++ b/recipes/fp16/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(fp16 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) +target_link_libraries(${PROJECT_NAME} PRIVATE fp16::fp16) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/fp16/all/test_package/conanfile.py b/recipes/fp16/all/test_package/conanfile.py index 5216332f39f5c..0a6bc68712d90 100644 --- a/recipes/fp16/all/test_package/conanfile.py +++ b/recipes/fp16/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fp16/all/test_v1_package/CMakeLists.txt b/recipes/fp16/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d609dc2f83e68 --- /dev/null +++ b/recipes/fp16/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fp16 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE fp16::fp16) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/fp16/all/test_v1_package/conanfile.py b/recipes/fp16/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/fp16/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fp16/config.yml b/recipes/fp16/config.yml index 4c30f333f3dbd..97367a08f7fea 100644 --- a/recipes/fp16/config.yml +++ b/recipes/fp16/config.yml @@ -1,3 +1,5 @@ versions: + "cci.20210320": + folder: all "cci.20200514": folder: all diff --git a/recipes/fpgen/all/conandata.yml b/recipes/fpgen/all/conandata.yml new file mode 100644 index 0000000000000..89315a6f71ce4 --- /dev/null +++ b/recipes/fpgen/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.1.0": + url: "https://github.com/jay-tux/fpgen/archive/refs/tags/v1.1.0.tar.gz" + sha256: "5e5faf1fbdcb3d93306bd8a838f805afdccdbb9076d78356ad5443943555be7d" + "1.1.0-clang": + url: "https://github.com/jay-tux/fpgen/archive/refs/tags/v1.1.0-clang.tar.gz" + sha256: "02936c1e790bcdba1479cf8164596b05cfc5b7401b3c71e0a1fd77e51fe8b93f" diff --git a/recipes/fpgen/all/conanfile.py b/recipes/fpgen/all/conanfile.py new file mode 100644 index 0000000000000..b9e1ea43fa34a --- /dev/null +++ b/recipes/fpgen/all/conanfile.py @@ -0,0 +1,94 @@ +import os + +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration + + +class FpgenConan(ConanFile): + name = "fpgen" + description = " Functional programming in C++ using C++20 coroutines." + license = ["MPL2"] + topics = ( + "generators", + "coroutines", + "c++20", + "header-only", + "functional-programming", + "functional", + ) + homepage = "https://github.com/jay-tux/fpgen/" + url = "https://github.com/conan-io/conan-center-index" + settings = "arch", "os", "compiler", "build_type" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _min_cppstd(self): + return "20" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "11", + "clang": "13", + } + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + destination=self._source_subfolder, + strip_root=True, + ) + + def validate(self): + if self.settings.compiler == "clang" and "clang" not in str(self.version): + raise ConanInvalidConfiguration( + f"Use '{self.version}-clang' for Clang support." + ) + + if ( + self.settings.compiler == "clang" + and not self.settings.compiler.libcxx == "libc++" + ): + raise ConanInvalidConfiguration( + f"Use 'compiler.libcxx=libc++' for {self.name} on Clang." + ) + + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._min_cppstd) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get( + str(self.settings.compiler), False + ) + if not minimum_version: + raise ConanInvalidConfiguration( + f"{self.name} is currently not available for your compiler." + ) + elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++20, which your compiler does not support." + ) + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy( + pattern="*.hpp", + dst=os.path.join("include", "fpgen"), + src=self._source_subfolder, + keep_path=False, + ) + + def package_info(self): + self.cpp_info.includedirs.append(os.path.join("include", "fpgen")) diff --git a/recipes/fpgen/all/test_package/CMakeLists.txt b/recipes/fpgen/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2d7e6737381f9 --- /dev/null +++ b/recipes/fpgen/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(fpgen REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} main.cpp) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20) +target_link_libraries(${PROJECT_NAME} fpgen::fpgen) diff --git a/recipes/fpgen/all/test_package/conanfile.py b/recipes/fpgen/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3f4a9f50f389e --- /dev/null +++ b/recipes/fpgen/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fpgen/all/test_package/main.cpp b/recipes/fpgen/all/test_package/main.cpp new file mode 100644 index 0000000000000..43bf51fe320f0 --- /dev/null +++ b/recipes/fpgen/all/test_package/main.cpp @@ -0,0 +1,13 @@ +#include +#include +#include "fpgen/fpgen.hpp" + +int main() { + std::vector vals = {0,1,2,3}; + auto gen = fpgen::from(vals); + + for(auto &&val : gen) { + std::cout << val << std::endl; + } + return 0; +} diff --git a/recipes/fpgen/config.yml b/recipes/fpgen/config.yml new file mode 100644 index 0000000000000..ec935d5cf64ff --- /dev/null +++ b/recipes/fpgen/config.yml @@ -0,0 +1,5 @@ +versions: + "1.1.0": + folder: all + "1.1.0-clang": + folder: all diff --git a/recipes/freeglut/all/conandata.yml b/recipes/freeglut/all/conandata.yml index 23cb4c420e8a3..1b8ca276b4eda 100644 --- a/recipes/freeglut/all/conandata.yml +++ b/recipes/freeglut/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.2.2": + sha256: "c5944a082df0bba96b5756dddb1f75d0cd72ce27b5395c6c1dde85c2ff297a50" + url: "https://github.com/FreeGLUTProject/freeglut/releases/download/v3.2.2/freeglut-3.2.2.tar.gz" "3.2.1": sha256: "d4000e02102acaf259998c870e25214739d1f16f67f99cb35e4f46841399da68" - url: "http://downloads.sourceforge.net/freeglut/freeglut/freeglut-3.2.1.tar.gz" + url: "https://github.com/FreeGLUTProject/freeglut/releases/download/v3.2.1/freeglut-3.2.1.tar.gz" diff --git a/recipes/freeglut/all/conanfile.py b/recipes/freeglut/all/conanfile.py index a6a8ead2389f6..4fbf2e2eb4cf5 100644 --- a/recipes/freeglut/all/conanfile.py +++ b/recipes/freeglut/all/conanfile.py @@ -1,19 +1,21 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.scm import Version +from conan.tools.files import get, rmdir, collect_libs +from conans import CMake import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.47.0" class freeglutConan(ConanFile): name = "freeglut" description = "Open-source alternative to the OpenGL Utility Toolkit (GLUT) library" - topics = ("conan", "freeglut", "opengl", "gl", "glut", "utility", "toolkit", "graphics") + topics = ("freeglut", "opengl", "gl", "glut", "utility", "toolkit", "graphics") url = "https://github.com/conan-io/conan-center-index" homepage = "http://freeglut.sourceforge.net" license = "X11" - exports_sources = ["CMakeLists.txt", "*.patch"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -21,6 +23,7 @@ class freeglutConan(ConanFile): "gles": [True, False], "print_errors_at_runtime": [True, False], "print_warnings_at_runtime": [True, False], + "replace_glut": [True, False], } default_options = { "shared": False, @@ -28,7 +31,10 @@ class freeglutConan(ConanFile): "gles": False, "print_errors_at_runtime": True, "print_warnings_at_runtime": True, + "replace_glut": True, } + + generators = "cmake" _cmake = None @property @@ -39,16 +45,18 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.options.shared: del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd def requirements(self): self.requires("opengl/system") @@ -62,13 +70,15 @@ def validate(self): # and https://sourceforge.net/p/freeglut/bugs/218/ # also, it seems to require `brew cask install xquartz` raise ConanInvalidConfiguration("%s does not support macos" % self.name) - if (self.settings.compiler == "gcc" and self.settings.compiler.version >= tools.Version("10.0")) or \ - (self.settings.compiler == "clang" and self.settings.compiler.version >= tools.Version("11.0")): - # see https://github.com/dcnieho/FreeGLUT/issues/86 - raise ConanInvalidConfiguration("%s does not support gcc >= 10 and clang >= 11" % self.name) + if Version(self.version) < "3.2.2": + if (self.settings.compiler == "gcc" and Version(self.settings.compiler.version) >= "10.0") or \ + (self.settings.compiler == "clang" and Version(self.settings.compiler.version) >= "11.0"): + # see https://github.com/dcnieho/FreeGLUT/issues/86 + raise ConanInvalidConfiguration("%s does not support gcc >= 10 and clang >= 11" % self.name) def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) def _configure_cmake(self): if self._cmake: @@ -85,6 +95,7 @@ def _configure_cmake(self): self._cmake.definitions["FREEGLUT_PRINT_WARNINGS"] = self.options.print_warnings_at_runtime self._cmake.definitions["FREEGLUT_INSTALL_PDB"] = False self._cmake.definitions["INSTALL_PDB"] = False + self._cmake.definitions["FREEGLUT_REPLACE_GLUT"] = self.options.replace_glut # cmake.definitions["FREEGLUT_WAYLAND"] = "ON" if self.options.wayland else "OFF" # nightly version only as of now self._cmake.configure(build_folder=self._build_subfolder) @@ -98,31 +109,39 @@ def package(self): self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "FreeGLUT" - self.cpp_info.filenames["cmake_find_package_multi"] = "FreeGLUT" - self.cpp_info.names["cmake_find_package"] = "FreeGLUT" - self.cpp_info.names["cmake_find_package_multi"] = "FreeGLUT" - - self.cpp_info.components["freeglut_"].libs = tools.collect_libs(self) - - self.cpp_info.components["freeglut_"].names["cmake_find_package"] = "freeglut" if self.options.shared else "freeglut_static" - self.cpp_info.components["freeglut_"].names["cmake_find_package_multi"] = "freeglut" if self.options.shared else "freeglut_static" - self.cpp_info.components["freeglut_"].names["pkg_config"] = "freeglut" if self.settings.os == "Windows" else "glut" - - self.cpp_info.components["freeglut_"].requires.append("opengl::opengl") - self.cpp_info.components["freeglut_"].requires.append("glu::glu") + config_target = "freeglut" if self.options.shared else "freeglut_static" + pkg_config = "freeglut" if self.settings.os == "Windows" else "glut" + + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_module_file_name", "GLUT") + self.cpp_info.set_property("cmake_module_target_name", "GLUT::GLUT") + self.cpp_info.set_property("cmake_file_name", "FreeGLUT") + self.cpp_info.set_property("cmake_target_name", "FreeGLUT::{}".format(config_target)) + self.cpp_info.set_property("pkg_config_name", pkg_config) + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["freeglut_"].libs = collect_libs(self) if self.settings.os == "Linux": - self.cpp_info.components["freeglut_"].requires.append("xorg::xorg") - - if self.settings.os == "Windows": + self.cpp_info.components["freeglut_"].system_libs.extend(["pthread", "m", "dl", "rt"]) + elif self.settings.os == "Windows": if not self.options.shared: self.cpp_info.components["freeglut_"].defines.append("FREEGLUT_STATIC=1") self.cpp_info.components["freeglut_"].defines.append("FREEGLUT_LIB_PRAGMAS=0") self.cpp_info.components["freeglut_"].system_libs.extend(["glu32", "gdi32", "winmm", "user32"]) + # TODO: to remove in conan v2 once cmake_find_package_* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "GLUT" + self.cpp_info.names["cmake_find_package_multi"] = "FreeGLUT" + self.cpp_info.names["pkg_config"] = pkg_config + self.cpp_info.components["freeglut_"].names["cmake_find_package"] = "GLUT" + self.cpp_info.components["freeglut_"].set_property("cmake_module_target_name", "GLUT::GLUT") + self.cpp_info.components["freeglut_"].names["cmake_find_package_multi"] = config_target + self.cpp_info.components["freeglut_"].set_property("cmake_target_name", "FreeGLUT::{}".format(config_target)) + self.cpp_info.components["freeglut_"].set_property("pkg_config_name", pkg_config) + self.cpp_info.components["freeglut_"].requires.extend(["opengl::opengl", "glu::glu"]) if self.settings.os == "Linux": - self.cpp_info.components["freeglut_"].system_libs.extend(["pthread", "m", "dl", "rt"]) + self.cpp_info.components["freeglut_"].requires.append("xorg::xorg") diff --git a/recipes/freeglut/all/test_package/CMakeLists.txt b/recipes/freeglut/all/test_package/CMakeLists.txt index afa2476357074..79ed7279f6790 100644 --- a/recipes/freeglut/all/test_package/CMakeLists.txt +++ b/recipes/freeglut/all/test_package/CMakeLists.txt @@ -1,9 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) - +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(GLUT REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} GLUT::GLUT) diff --git a/recipes/freeglut/all/test_package/conanfile.py b/recipes/freeglut/all/test_package/conanfile.py index bd7165a553cf4..19e6a0c06e3d8 100644 --- a/recipes/freeglut/all/test_package/conanfile.py +++ b/recipes/freeglut/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/freeglut/config.yml b/recipes/freeglut/config.yml index c09805f11822d..31ef026aaa09c 100644 --- a/recipes/freeglut/config.yml +++ b/recipes/freeglut/config.yml @@ -1,3 +1,5 @@ versions: + "3.2.2": + folder: all "3.2.1": folder: all diff --git a/recipes/freeimage/all/CMakeLists.txt b/recipes/freeimage/all/CMakeLists.txt new file mode 100644 index 0000000000000..fa022c569a005 --- /dev/null +++ b/recipes/freeimage/all/CMakeLists.txt @@ -0,0 +1,164 @@ +cmake_minimum_required(VERSION 3.8) +project(FreeImage LANGUAGES C CXX) + +include(GNUInstallDirs) + +find_package(ZLIB REQUIRED) +if(FREEIMAGE_WITH_PNG) + find_package(PNG REQUIRED) +endif() +if(FREEIMAGE_WITH_JPEG) + find_package(JPEG REQUIRED) +endif() +if(FREEIMAGE_WITH_OPENJPEG) + find_package(OpenJPEG REQUIRED CONFIG) +endif() +if(FREEIMAGE_WITH_WEBP) + find_package(WebP REQUIRED CONFIG) +endif() +if(FREEIMAGE_WITH_JXR) + find_package(jxrlib REQUIRED CONFIG) +endif() +if(FREEIMAGE_WITH_RAW) + find_package(libraw REQUIRED CONFIG) +endif() +if(FREEIMAGE_WITH_OPENEXR OR FREEIMAGE_WITH_TIFF) + find_package(OpenEXR REQUIRED CONFIG) +endif() +if(FREEIMAGE_WITH_TIFF) + find_package(TIFF REQUIRED) +endif() + +# FreeImage + +file(GLOB FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/*.cpp ${FREEIMAGE_FOLDER}/Source/FreeImage/*.c) +list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginG3.cpp) +if(NOT FREEIMAGE_WITH_PNG) + list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginPNG.cpp) +endif() +if(NOT FREEIMAGE_WITH_JPEG) + list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginJPEG.cpp) +endif() +if(NOT FREEIMAGE_WITH_OPENJPEG) + list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginJP2.cpp) + list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginJ2K.cpp) + list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/J2KHelper.cpp) +endif() +if(NOT FREEIMAGE_WITH_WEBP) + list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginWebP.cpp) +endif() +if(NOT FREEIMAGE_WITH_JXR) + list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginJXR.cpp) +endif() +if(NOT FREEIMAGE_WITH_RAW) + list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginRAW.cpp) +endif() +if(NOT FREEIMAGE_WITH_OPENEXR) + list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginEXR.cpp) +endif() +if(NOT FREEIMAGE_WITH_TIFF) + list(REMOVE_ITEM FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImage/PluginTIFF.cpp) +endif() +if(MSVC) + list(APPEND FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/FreeImage.rc) +endif(MSVC) + +file(GLOB FREEIMAGETOOLKIT_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImageToolkit/*.cpp ${FREEIMAGE_FOLDER}/Source/FreeImageToolkit/*.c) +list(REMOVE_ITEM FREEIMAGETOOLKIT_SOURCES ${FREEIMAGE_FOLDER}/Source/FreeImageToolkit/JPEGTransform.cpp) + +file(GLOB METADATA_SOURCES ${FREEIMAGE_FOLDER}/Source/Metadata/*.cpp ${FREEIMAGE_FOLDER}/Source/Metadata/*.c) +if(NOT FREEIMAGE_WITH_TIFF) + list(REMOVE_ITEM METADATA_SOURCES ${FREEIMAGE_FOLDER}/Source/Metadata/XTIFF.cpp) +endif() + +add_library(FreeImage ${FREEIMAGE_SOURCES} ${FREEIMAGETOOLKIT_SOURCES} ${METADATA_SOURCES}) +target_compile_features(FreeImage PRIVATE cxx_std_11) +set_target_properties(FreeImage PROPERTIES + OUTPUT_NAME "freeimage" + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON +) +target_include_directories(FreeImage PRIVATE + ${FREEIMAGE_FOLDER}/Source + ${FREEIMAGE_FOLDER}/Source/FreeImage + ${FREEIMAGE_FOLDER}/Source/FreeImageToolkit + ${FREEIMAGE_FOLDER}/Source/Metadata +) +target_link_libraries(FreeImage PRIVATE ZLIB::ZLIB) +if(FREEIMAGE_WITH_PNG) + target_compile_definitions(FreeImage PRIVATE FREEIMAGE_WITH_PNG) + target_link_libraries(FreeImage PRIVATE PNG::PNG) +endif() +if(FREEIMAGE_WITH_JPEG) + target_compile_definitions(FreeImage PRIVATE FREEIMAGE_WITH_JPEG) + target_link_libraries(FreeImage PRIVATE JPEG::JPEG) +endif() +if(FREEIMAGE_WITH_OPENJPEG) + target_compile_definitions(FreeImage PRIVATE FREEIMAGE_WITH_OPENJPEG) + target_link_libraries(FreeImage PRIVATE openjp2) +endif() +if(FREEIMAGE_WITH_WEBP) + target_compile_definitions(FreeImage PRIVATE FREEIMAGE_WITH_WEBP) + target_link_libraries(FreeImage PRIVATE WebP::webp WebP::webpdecoder WebP::libwebpmux WebP::webpdemux) +endif() +if(FREEIMAGE_WITH_JXR) + target_compile_definitions(FreeImage PRIVATE FREEIMAGE_WITH_JXR) + target_link_libraries(FreeImage PRIVATE jxrlib::jxrlib) +endif() +if(FREEIMAGE_WITH_RAW) + target_compile_definitions(FreeImage PRIVATE FREEIMAGE_WITH_RAW) + target_link_libraries(FreeImage PRIVATE libraw::libraw) +endif() +if(FREEIMAGE_WITH_OPENEXR) + target_compile_definitions(FreeImage PRIVATE FREEIMAGE_WITH_OPENEXR) + target_link_libraries(FreeImage PRIVATE openexr::openexr) # TODO: link to exact required components +endif() +if(FREEIMAGE_WITH_TIFF) + target_compile_definitions(FreeImage PRIVATE FREEIMAGE_WITH_TIFF) + target_link_libraries(FreeImage PRIVATE TIFF::TIFF IlmBase::Half) +endif() +if(BUILD_SHARED_LIBS) + target_compile_definitions(FreeImage PRIVATE FREEIMAGE_EXPORTS) +else() + target_compile_definitions(FreeImage PUBLIC FREEIMAGE_LIB) +endif() + +install(TARGETS FreeImage + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +set(FREEIMAGE_HEADERS ${FREEIMAGE_FOLDER}/Source/FreeImage.h) +install(FILES ${FREEIMAGE_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# FreeImagePlus + +set(FREEIMAGEPLUS_HEADERS ${FREEIMAGE_FOLDER}/Wrapper/FreeImagePlus/FreeImagePlus.h) +file(GLOB FREEIMAGEPLUS_SOURCES ${FREEIMAGE_FOLDER}/Wrapper/FreeImagePlus/src/*.cpp ${FREEIMAGE_FOLDER}/Wrapper/FreeImagePlus/src/*.c) +if(MSVC) + list(APPEND FREEIMAGE_SOURCES ${FREEIMAGE_FOLDER}/Wrapper/FreeImagePlus/FreeImagePlus.rc) +endif(MSVC) +add_library(FreeImagePlus ${FREEIMAGEPLUS_SOURCES}) +target_compile_features(FreeImagePlus PUBLIC cxx_std_11) +set_target_properties(FreeImagePlus PROPERTIES + OUTPUT_NAME "freeimageplus" + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON +) +target_link_libraries(FreeImagePlus PUBLIC FreeImage) +target_include_directories(FreeImagePlus PRIVATE + ${FREEIMAGE_FOLDER}/Wrapper/FreeImagePlus + ${FREEIMAGE_FOLDER}/Source +) +if(BUILD_SHARED_LIBS) + target_compile_definitions(FreeImagePlus PRIVATE FIP_EXPORTS) +endif() + +install(TARGETS FreeImagePlus + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install(FILES ${FREEIMAGEPLUS_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/freeimage/all/conandata.yml b/recipes/freeimage/all/conandata.yml new file mode 100644 index 0000000000000..ab58bf12a8d2b --- /dev/null +++ b/recipes/freeimage/all/conandata.yml @@ -0,0 +1,20 @@ +sources: + "3.18.0": + url: "http://downloads.sourceforge.net/project/freeimage/Source Distribution/3.18.0/FreeImage3180.zip" + sha256: "f41379682f9ada94ea7b34fe86bf9ee00935a3147be41b6569c9605a53e438fd" +patches: + "3.18.0": + - patch_file: "patches/001_disable-plugins-depending-on-internal-third-party-libraries.patch" + - patch_file: "patches/002_fix-function-overload.patch" + - patch_file: "patches/003_use-external-jpeg.patch" + - patch_file: "patches/004_use-external-jxrlib.patch" + - patch_file: "patches/005_use-external-libtiff.patch" + - patch_file: "patches/006_use-external-openexr.patch" + - patch_file: "patches/007_use-external-openjpeg.patch" + - patch_file: "patches/008_use-external-png-zlib.patch" + - patch_file: "patches/009_use-external-rawlib.patch" + - patch_file: "patches/010_use-external-webp.patch" + - patch_file: "patches/011_update-libraw-support.patch" + - patch_file: "patches/012_use-functions-to-override-libtiff-warning-error-handlers.patch" + - patch_file: "patches/013_use-typedef-as-already-declared.patch" + - patch_file: "patches/014_no_auto_ptr.patch" diff --git a/recipes/freeimage/all/conanfile.py b/recipes/freeimage/all/conanfile.py new file mode 100644 index 0000000000000..44eea75a589aa --- /dev/null +++ b/recipes/freeimage/all/conanfile.py @@ -0,0 +1,164 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +import os + +required_conan_version = ">=1.50.0" + + +class FreeImageConan(ConanFile): + name = "freeimage" + description = "Open Source library project for developers who would like to support popular graphics image formats"\ + "like PNG, BMP, JPEG, TIFF and others as needed by today's multimedia applications." + homepage = "https://freeimage.sourceforge.io" + url = "https://github.com/conan-io/conan-center-index" + license = "FreeImage", "GPL-3.0-or-later", "GPL-2.0-or-later" + topics = ("freeimage", "image", "decoding", "graphics") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_jpeg": [False, "libjpeg", "libjpeg-turbo"], + "with_png": [True, False], + "with_tiff": [True, False], + "with_jpeg2000": [True, False], + "with_openexr": [True, False], + "with_eigen": [True, False], + "with_webp": [True, False], + "with_raw": [True, False], + "with_jxr": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_jpeg": "libjpeg", + "with_png": True, + "with_tiff": True, + "with_jpeg2000": True, + "with_openexr": True, + "with_eigen": True, + "with_webp": True, + "with_raw": True, + "with_jxr": True, + } + + short_paths = True + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + self.output.warn("G3 plugin and JPEGTransform are disabled.") + if bool(self.options.with_jpeg): + if self.options.with_tiff: + self.options["libtiff"].jpeg = self.options.with_jpeg + + def requirements(self): + self.requires("zlib/1.2.12") + if self.options.with_jpeg == "libjpeg": + self.requires("libjpeg/9d") + elif self.options.with_jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/2.1.4") + if self.options.with_jpeg2000: + self.requires("openjpeg/2.5.0") + if self.options.with_png: + self.requires("libpng/1.6.37") + if self.options.with_webp: + self.requires("libwebp/1.2.4") + if self.options.with_tiff or self.options.with_openexr: + # can't upgrade to openexr/3.x.x because plugin tiff requires openexr/2.x.x header files + self.requires("openexr/2.5.7") + if self.options.with_raw: + self.requires("libraw/0.20.2") + if self.options.with_jxr: + self.requires("jxrlib/cci.20170615") + if self.options.with_tiff: + self.requires("libtiff/4.4.0") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, "11") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["FREEIMAGE_FOLDER"] = self.source_folder.replace("\\", "/") + tc.variables["FREEIMAGE_WITH_JPEG"] = self.options.with_jpeg != False + tc.variables["FREEIMAGE_WITH_OPENJPEG"] = self.options.with_jpeg2000 + tc.variables["FREEIMAGE_WITH_PNG"] = self.options.with_png + tc.variables["FREEIMAGE_WITH_WEBP"] = self.options.with_webp + tc.variables["FREEIMAGE_WITH_OPENEXR"] = self.options.with_openexr + tc.variables["FREEIMAGE_WITH_RAW"] = self.options.with_raw + tc.variables["FREEIMAGE_WITH_JXR"] = self.options.with_jxr + tc.variables["FREEIMAGE_WITH_TIFF"] = self.options.with_tiff + tc.generate() + cd = CMakeDeps(self) + cd.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + rmdir(self, os.path.join(self.source_folder, "Source", "LibPNG")) + rmdir(self, os.path.join(self.source_folder, "Source", "LibTIFF4")) + rmdir(self, os.path.join(self.source_folder, "Source", "LibOpenJPEG")) + rmdir(self, os.path.join(self.source_folder, "Source", "LibJXR")) + rmdir(self, os.path.join(self.source_folder, "Source", "LibWebP")) + rmdir(self, os.path.join(self.source_folder, "Source", "LibRawLite")) + rmdir(self, os.path.join(self.source_folder, "Source", "OpenEXR")) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + for license in ["license-fi.txt", "license-gplv3.txt", "license-fi.txt"]: + copy(self, license, src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + def imageformats_deps(): + components = [] + components.append("zlib::zlib") + if self.options.with_jpeg: + components.append("{0}::{0}".format(self.options.with_jpeg)) + if self.options.with_jpeg2000: + components.append("openjpeg::openjpeg") + if self.options.with_png: + components.append("libpng::libpng") + if self.options.with_webp: + components.append("libwebp::libwebp") + if self.options.with_openexr or self.options.with_tiff: + components.append("openexr::openexr") + if self.options.with_raw: + components.append("libraw::libraw") + if self.options.with_jxr: + components.append("jxrlib::jxrlib") + if self.options.with_tiff: + components.append("libtiff::libtiff") + return components + + self.cpp_info.components["FreeImage"].libs = ["freeimage"] + self.cpp_info.components["FreeImage"].requires = imageformats_deps() + self.cpp_info.components["FreeImagePlus"].libs = ["freeimageplus"] + self.cpp_info.components["FreeImagePlus"].requires = ["FreeImage"] + + if not self.options.shared: + self.cpp_info.components["FreeImage"].defines.append("FREEIMAGE_LIB") diff --git a/recipes/freeimage/all/patches/001_disable-plugins-depending-on-internal-third-party-libraries.patch b/recipes/freeimage/all/patches/001_disable-plugins-depending-on-internal-third-party-libraries.patch new file mode 100644 index 0000000000000..2a8015b31b1cd --- /dev/null +++ b/recipes/freeimage/all/patches/001_disable-plugins-depending-on-internal-third-party-libraries.patch @@ -0,0 +1,136 @@ +diff --git a/Source/FreeImage.h b/Source/FreeImage.h +index 12182cd..ebd0453 100644 +--- a/Source/FreeImage.h ++++ b/Source/FreeImage.h +@@ -410,16 +410,20 @@ FI_ENUM(FREE_IMAGE_FORMAT) { + FIF_DDS = 24, + FIF_GIF = 25, + FIF_HDR = 26, +- FIF_FAXG3 = 27, +- FIF_SGI = 28, +- FIF_EXR = 29, +- FIF_J2K = 30, +- FIF_JP2 = 31, +- FIF_PFM = 32, +- FIF_PICT = 33, +- FIF_RAW = 34, +- FIF_WEBP = 35, +- FIF_JXR = 36 ++/* conan: The G3 fax format plugin is deliberately disabled in our build of ++ FreeImage, since it requires usage of the vendored copy of libtiff. */ ++#if 0 ++ FIF_FAXG3 = 27, ++#endif ++ FIF_SGI = 27, ++ FIF_EXR = 28, ++ FIF_J2K = 29, ++ FIF_JP2 = 30, ++ FIF_PFM = 31, ++ FIF_PICT = 32, ++ FIF_RAW = 33, ++ FIF_WEBP = 34, ++ FIF_JXR = 35 + }; + + /** Image type used in FreeImage. +@@ -476,6 +480,9 @@ FI_ENUM(FREE_IMAGE_DITHER) { + /** Lossless JPEG transformations + Constants used in FreeImage_JPEGTransform + */ ++/* conan: The JPEGTransform functions are deliberately disabled in our build ++ of FreeImage, since they require usage of the vendored copy of libjpeg. */ ++#if 0 + FI_ENUM(FREE_IMAGE_JPEG_OPERATION) { + FIJPEG_OP_NONE = 0, //! no transformation + FIJPEG_OP_FLIP_H = 1, //! horizontal flip +@@ -486,6 +493,7 @@ FI_ENUM(FREE_IMAGE_JPEG_OPERATION) { + FIJPEG_OP_ROTATE_180 = 6, //! 180-degree rotation + FIJPEG_OP_ROTATE_270 = 7 //! 270-degree clockwise (or 90 ccw) + }; ++#endif + + /** Tone mapping operators. + Constants used in FreeImage_ToneMapping. +@@ -1089,6 +1097,9 @@ DLL_API const char* DLL_CALLCONV FreeImage_TagToString(FREE_IMAGE_MDMODEL model, + // JPEG lossless transformation routines + // -------------------------------------------------------------------------- + ++/* conan: The JPEGTransform functions are deliberately disabled in our build ++ of FreeImage, since they require usage of the vendored copy of libjpeg. */ ++#if 0 + DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransform(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE)); + DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE)); + DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom); +@@ -1097,7 +1108,7 @@ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformFromHandle(FreeImageIO* src_io, + DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombined(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); + DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); + DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedFromMemory(FIMEMORY* src_stream, FIMEMORY* dst_stream, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE)); +- ++#endif + + // -------------------------------------------------------------------------- + // Image manipulation toolkit +diff --git a/Source/FreeImage/Plugin.cpp b/Source/FreeImage/Plugin.cpp +index 11e7294..0119ba7 100644 +--- a/Source/FreeImage/Plugin.cpp ++++ b/Source/FreeImage/Plugin.cpp +@@ -238,7 +238,9 @@ + */ + s_plugins->AddNode(InitBMP); + s_plugins->AddNode(InitICO); ++#if FREEIMAGE_WITH_JPEG + s_plugins->AddNode(InitJPEG); ++#endif + s_plugins->AddNode(InitJNG); + s_plugins->AddNode(InitKOALA); + s_plugins->AddNode(InitIFF); +@@ -249,12 +251,16 @@ + s_plugins->AddNode(InitPCX); + s_plugins->AddNode(InitPNM, NULL, "PGM", "Portable Greymap (ASCII)", "pgm", "^P2"); + s_plugins->AddNode(InitPNM, NULL, "PGMRAW", "Portable Greymap (RAW)", "pgm", "^P5"); ++#if FREEIMAGE_WITH_PNG + s_plugins->AddNode(InitPNG); ++#endif + s_plugins->AddNode(InitPNM, NULL, "PPM", "Portable Pixelmap (ASCII)", "ppm", "^P3"); + s_plugins->AddNode(InitPNM, NULL, "PPMRAW", "Portable Pixelmap (RAW)", "ppm", "^P6"); + s_plugins->AddNode(InitRAS); + s_plugins->AddNode(InitTARGA); ++#if FREEIMAGE_WITH_TIFF + s_plugins->AddNode(InitTIFF); ++#endif + s_plugins->AddNode(InitWBMP); + s_plugins->AddNode(InitPSD); + s_plugins->AddNode(InitCUT); +@@ -263,18 +269,32 @@ + s_plugins->AddNode(InitDDS); + s_plugins->AddNode(InitGIF); + s_plugins->AddNode(InitHDR); ++/* conan: The G3 fax format plugin is deliberately disabled in our build of FreeImage ++ since it requires usage of the vendored copy of libtiff. */ ++#if 0 + s_plugins->AddNode(InitG3); ++#endif + s_plugins->AddNode(InitSGI); ++#if FREEIMAGE_WITH_OPENEXR + s_plugins->AddNode(InitEXR); ++#endif ++#if FREEIMAGE_WITH_OPENJPEG + s_plugins->AddNode(InitJ2K); + s_plugins->AddNode(InitJP2); ++#endif + s_plugins->AddNode(InitPFM); + s_plugins->AddNode(InitPICT); ++#if FREEIMAGE_WITH_RAW + s_plugins->AddNode(InitRAW); ++#endif ++#if FREEIMAGE_WITH_WEBP + s_plugins->AddNode(InitWEBP); ++#endif ++#if FREEIMAGE_WITH_JXR + #if !(defined(_MSC_VER) && (_MSC_VER <= 1310)) + s_plugins->AddNode(InitJXR); + #endif // unsupported by MS Visual Studio 2003 !!! ++#endif + + // external plugin initialization + diff --git a/recipes/freeimage/all/patches/002_fix-function-overload.patch b/recipes/freeimage/all/patches/002_fix-function-overload.patch new file mode 100644 index 0000000000000..adb1164f6d132 --- /dev/null +++ b/recipes/freeimage/all/patches/002_fix-function-overload.patch @@ -0,0 +1,40 @@ +diff --git a/Source/FreeImage/PluginJPEG.cpp b/Source/FreeImage/PluginJPEG.cpp +index 8db177d..efa2c4e 100644 +--- a/Source/FreeImage/PluginJPEG.cpp ++++ b/Source/FreeImage/PluginJPEG.cpp +@@ -503,7 +503,7 @@ marker_is_icc(jpeg_saved_marker_ptr marker) { + return FALSE. You might want to issue an error message instead. + */ + static BOOL +-jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned *icc_data_len) { ++jpeg_read_icc_profile_(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned *icc_data_len) { + jpeg_saved_marker_ptr marker; + int num_markers = 0; + int seq_no; +@@ -745,7 +745,7 @@ read_markers(j_decompress_ptr cinfo, FIBITMAP *dib) { + BYTE *icc_profile = NULL; + unsigned icc_length = 0; + +- if( jpeg_read_icc_profile(cinfo, &icc_profile, &icc_length) ) { ++ if( jpeg_read_icc_profile_(cinfo, &icc_profile, &icc_length) ) { + // copy ICC profile data + FreeImage_CreateICCProfile(dib, icc_profile, icc_length); + // clean up +@@ -785,7 +785,7 @@ jpeg_write_comment(j_compress_ptr cinfo, FIBITMAP *dib) { + Write JPEG_APP2 marker (ICC profile) + */ + static BOOL +-jpeg_write_icc_profile(j_compress_ptr cinfo, FIBITMAP *dib) { ++jpeg_write_icc_profile_(j_compress_ptr cinfo, FIBITMAP *dib) { + // marker identifying string "ICC_PROFILE" (null-terminated) + BYTE icc_signature[12] = { 0x49, 0x43, 0x43, 0x5F, 0x50, 0x52, 0x4F, 0x46, 0x49, 0x4C, 0x45, 0x00 }; + +@@ -1038,7 +1038,7 @@ write_markers(j_compress_ptr cinfo, FIBITMAP *dib) { + jpeg_write_comment(cinfo, dib); + + // write ICC profile +- jpeg_write_icc_profile(cinfo, dib); ++ jpeg_write_icc_profile_(cinfo, dib); + + // write IPTC profile + jpeg_write_iptc_profile(cinfo, dib); diff --git a/recipes/freeimage/all/patches/003_use-external-jpeg.patch b/recipes/freeimage/all/patches/003_use-external-jpeg.patch new file mode 100644 index 0000000000000..5e98e5f24b235 --- /dev/null +++ b/recipes/freeimage/all/patches/003_use-external-jpeg.patch @@ -0,0 +1,23 @@ +diff --git a/Source/FreeImage/PluginJPEG.cpp b/Source/FreeImage/PluginJPEG.cpp +index 573989c..aaeefa4 100644 +--- a/Source/FreeImage/PluginJPEG.cpp ++++ b/Source/FreeImage/PluginJPEG.cpp +@@ -35,9 +35,15 @@ extern "C" { + #undef FAR + #include + +-#include "../LibJPEG/jinclude.h" +-#include "../LibJPEG/jpeglib.h" +-#include "../LibJPEG/jerror.h" ++#ifndef FALSE ++#define FALSE 0 ++#endif ++#ifndef TRUE ++#define TRUE 1 ++#endif ++#include ++#include ++#include + } + + #include "FreeImage.h" diff --git a/recipes/freeimage/all/patches/004_use-external-jxrlib.patch b/recipes/freeimage/all/patches/004_use-external-jxrlib.patch new file mode 100644 index 0000000000000..0363694c6df41 --- /dev/null +++ b/recipes/freeimage/all/patches/004_use-external-jxrlib.patch @@ -0,0 +1,13 @@ +diff --git a/Source/FreeImage/PluginJXR.cpp b/Source/FreeImage/PluginJXR.cpp +index 0e14e09..8eb9d5d 100644 +--- a/Source/FreeImage/PluginJXR.cpp ++++ b/Source/FreeImage/PluginJXR.cpp +@@ -23,7 +23,7 @@ + #include "Utilities.h" + #include "../Metadata/FreeImageTag.h" + +-#include "../LibJXR/jxrgluelib/JXRGlue.h" ++#include + + // ========================================================== + // Plugin Interface diff --git a/recipes/freeimage/all/patches/005_use-external-libtiff.patch b/recipes/freeimage/all/patches/005_use-external-libtiff.patch new file mode 100644 index 0000000000000..d602f55194431 --- /dev/null +++ b/recipes/freeimage/all/patches/005_use-external-libtiff.patch @@ -0,0 +1,204 @@ +diff --git a/Source/FreeImage/PluginTIFF.cpp b/Source/FreeImage/PluginTIFF.cpp +index 5068d94..8947b03 100644 +--- a/Source/FreeImage/PluginTIFF.cpp ++++ b/Source/FreeImage/PluginTIFF.cpp +@@ -37,9 +37,9 @@ + + #include "FreeImage.h" + #include "Utilities.h" +-#include "../LibTIFF4/tiffiop.h" ++#include + #include "../Metadata/FreeImageTag.h" + #include "../OpenEXR/Half/half.h" + + #include "FreeImageIO.h" + #include "PSDParser.h" +@@ -199,15 +199,18 @@ Open a TIFF file for reading or writing + @param name + @param mode + */ ++/* + TIFF* + TIFFOpen(const char* name, const char* mode) { + return 0; + } ++*/ + + // ---------------------------------------------------------- + // TIFF library FreeImage-specific routines. + // ---------------------------------------------------------- + ++/* + void* + _TIFFmalloc(tmsize_t s) { + return malloc(s); +@@ -245,6 +248,7 @@ int + _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c) { + return (memcmp(p1, p2, (size_t) c)); + } ++*/ + + // ---------------------------------------------------------- + // in FreeImage warnings and errors are disabled + +diff --git a/Source/Metadata/XTIFF.cpp b/Source/Metadata/XTIFF.cpp +index d5be902..8dbcd5d 100644 +--- a/Source/Metadata/XTIFF.cpp ++++ b/Source/Metadata/XTIFF.cpp +@@ -29,7 +29,7 @@ + #pragma warning (disable : 4786) // identifier was truncated to 'number' characters + #endif + +-#include "../LibTIFF4/tiffiop.h" ++#include + + #include "FreeImage.h" + #include "Utilities.h" +@@ -40,6 +40,43 @@ + // Extended TIFF Directory GEO Tag Support + // ---------------------------------------------------------- + ++// conan: function imported from libtiff/tif_dirinfo.c, in which it is not exported ++/* ++ * Return size of TIFFDataType in bytes. ++ * ++ * XXX: We need a separate function to determine the space needed ++ * to store the value. For TIFF_RATIONAL values TIFFDataWidth() returns 8, ++ * but we use 4-byte float to represent rationals. ++ */ ++int ++FreeImage_TIFFDataSize(TIFFDataType type) ++{ ++ switch (type) ++ { ++ case TIFF_BYTE: ++ case TIFF_SBYTE: ++ case TIFF_ASCII: ++ case TIFF_UNDEFINED: ++ return 1; ++ case TIFF_SHORT: ++ case TIFF_SSHORT: ++ return 2; ++ case TIFF_LONG: ++ case TIFF_SLONG: ++ case TIFF_FLOAT: ++ case TIFF_IFD: ++ case TIFF_RATIONAL: ++ case TIFF_SRATIONAL: ++ return 4; ++ case TIFF_DOUBLE: ++ case TIFF_LONG8: ++ case TIFF_SLONG8: ++ case TIFF_IFD8: ++ return 8; ++ default: ++ return 0; ++ } ++} + /** + Tiff info structure. + Entry format: +@@ -224,6 +261,33 @@ tiff_write_geotiff_profile(TIFF *tif, FIBITMAP *dib) { + // TIFF EXIF tag reading & writing + // ---------------------------------------------------------- + ++static uint32 exif_tag_ids[] = { ++ EXIFTAG_EXPOSURETIME, EXIFTAG_FNUMBER, EXIFTAG_EXPOSUREPROGRAM, ++ EXIFTAG_SPECTRALSENSITIVITY, EXIFTAG_ISOSPEEDRATINGS, EXIFTAG_OECF, ++ EXIFTAG_EXIFVERSION, EXIFTAG_DATETIMEORIGINAL, EXIFTAG_DATETIMEDIGITIZED, ++ EXIFTAG_COMPONENTSCONFIGURATION, EXIFTAG_COMPRESSEDBITSPERPIXEL, ++ EXIFTAG_SHUTTERSPEEDVALUE, EXIFTAG_APERTUREVALUE, ++ EXIFTAG_BRIGHTNESSVALUE, EXIFTAG_EXPOSUREBIASVALUE, ++ EXIFTAG_MAXAPERTUREVALUE, EXIFTAG_SUBJECTDISTANCE, EXIFTAG_METERINGMODE, ++ EXIFTAG_LIGHTSOURCE, EXIFTAG_FLASH, EXIFTAG_FOCALLENGTH, ++ EXIFTAG_SUBJECTAREA, EXIFTAG_MAKERNOTE, EXIFTAG_USERCOMMENT, ++ EXIFTAG_SUBSECTIME, EXIFTAG_SUBSECTIMEORIGINAL, ++ EXIFTAG_SUBSECTIMEDIGITIZED, EXIFTAG_FLASHPIXVERSION, EXIFTAG_COLORSPACE, ++ EXIFTAG_PIXELXDIMENSION, EXIFTAG_PIXELYDIMENSION, ++ EXIFTAG_RELATEDSOUNDFILE, EXIFTAG_FLASHENERGY, ++ EXIFTAG_SPATIALFREQUENCYRESPONSE, EXIFTAG_FOCALPLANEXRESOLUTION, ++ EXIFTAG_FOCALPLANEYRESOLUTION, EXIFTAG_FOCALPLANERESOLUTIONUNIT, ++ EXIFTAG_SUBJECTLOCATION, EXIFTAG_EXPOSUREINDEX, EXIFTAG_SENSINGMETHOD, ++ EXIFTAG_FILESOURCE, EXIFTAG_SCENETYPE, EXIFTAG_CFAPATTERN, ++ EXIFTAG_CUSTOMRENDERED, EXIFTAG_EXPOSUREMODE, EXIFTAG_WHITEBALANCE, ++ EXIFTAG_DIGITALZOOMRATIO, EXIFTAG_FOCALLENGTHIN35MMFILM, ++ EXIFTAG_SCENECAPTURETYPE, EXIFTAG_GAINCONTROL, EXIFTAG_CONTRAST, ++ EXIFTAG_SATURATION, EXIFTAG_SHARPNESS, EXIFTAG_DEVICESETTINGDESCRIPTION, ++ EXIFTAG_SUBJECTDISTANCERANGE, EXIFTAG_GAINCONTROL, EXIFTAG_GAINCONTROL, ++ EXIFTAG_IMAGEUNIQUEID ++}; ++static int nExifTags = sizeof(exif_tag_ids) / sizeof(exif_tag_ids[0]); ++ + /** + Read a single Exif tag + +@@ -575,43 +639,10 @@ tiff_read_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) { + + // loop over all Core Directory Tags + // ### uses private data, but there is no other way ++ // -> conan: Best we can do without private headers is to hard-code a list of known EXIF tags and read those + if(md_model == TagLib::EXIF_MAIN) { +- const TIFFDirectory *td = &tif->tif_dir; +- +- uint32 lastTag = 0; //<- used to prevent reading some tags twice (as stored in tif_fieldinfo) +- +- for (int fi = 0, nfi = (int)tif->tif_nfields; nfi > 0; nfi--, fi++) { +- const TIFFField *fld = tif->tif_fields[fi]; +- +- const uint32 tag_id = TIFFFieldTag(fld); +- +- if(tag_id == lastTag) { +- continue; +- } +- +- // test if tag value is set +- // (lifted directly from LibTiff _TIFFWriteDirectory) +- +- if( fld->field_bit == FIELD_CUSTOM ) { +- int is_set = FALSE; +- +- for(int ci = 0; ci < td->td_customValueCount; ci++ ) { +- is_set |= (td->td_customValues[ci].info == fld); +- } +- +- if( !is_set ) { +- continue; +- } +- +- } else if(!TIFFFieldSet(tif, fld->field_bit)) { +- continue; +- } +- +- // process *all* other tags (some will be ignored) +- +- tiff_read_exif_tag(tif, tag_id, dib, md_model); +- +- lastTag = tag_id; ++ for (int i = 0; i < nExifTags; ++i) { ++ tiff_read_exif_tag(tif, exif_tag_ids[i], dib, md_model); + } + + } +@@ -723,10 +754,9 @@ tiff_write_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) { + + TagLib& tag_lib = TagLib::instance(); + +- for (int fi = 0, nfi = (int)tif->tif_nfields; nfi > 0; nfi--, fi++) { +- const TIFFField *fld = tif->tif_fields[fi]; +- +- const uint32 tag_id = TIFFFieldTag(fld); ++ for (int fi = 0, nfi = nExifTags; nfi > 0; nfi--, fi++) { ++ const uint32 tag_id = exif_tag_ids[fi]; ++ const TIFFField *fld = TIFFFieldWithTag(tif, tag_id); + + if(skip_write_field(tif, tag_id)) { + // skip tags that are already handled by the LibTIFF writing process +@@ -749,7 +779,7 @@ tiff_write_exif_tags(TIFF *tif, TagLib::MDMODEL md_model, FIBITMAP *dib) { + continue; + } + // type of storage may differ (e.g. rationnal array vs float array type) +- if((unsigned)_TIFFDataSize(tif_tag_type) != FreeImage_TagDataWidth(tag_type)) { ++ if((unsigned)FreeImage_TIFFDataSize(tif_tag_type) != FreeImage_TagDataWidth(tag_type)) { + // skip tag or _TIFFmemcpy will fail + continue; + } diff --git a/recipes/freeimage/all/patches/006_use-external-openexr.patch b/recipes/freeimage/all/patches/006_use-external-openexr.patch new file mode 100644 index 0000000000000..08915da726807 --- /dev/null +++ b/recipes/freeimage/all/patches/006_use-external-openexr.patch @@ -0,0 +1,44 @@ +diff --git a/Source/FreeImage/PluginEXR.cpp b/Source/FreeImage/PluginEXR.cpp +index b286430..82b3b72 100644 +--- a/Source/FreeImage/PluginEXR.cpp ++++ b/Source/FreeImage/PluginEXR.cpp +@@ -28,16 +28,16 @@ + #pragma warning (disable : 4800) // ImfVersion.h - 'const int' : forcing value to bool 'true' or 'false' (performance warning) + #endif + +-#include "../OpenEXR/IlmImf/ImfIO.h" +-#include "../OpenEXR/Iex/Iex.h" +-#include "../OpenEXR/IlmImf/ImfOutputFile.h" +-#include "../OpenEXR/IlmImf/ImfInputFile.h" +-#include "../OpenEXR/IlmImf/ImfRgbaFile.h" +-#include "../OpenEXR/IlmImf/ImfChannelList.h" +-#include "../OpenEXR/IlmImf/ImfRgba.h" +-#include "../OpenEXR/IlmImf/ImfArray.h" +-#include "../OpenEXR/IlmImf/ImfPreviewImage.h" +-#include "../OpenEXR/Half/half.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + + + // ========================================================== +diff --git a/Source/FreeImage/PluginTIFF.cpp b/Source/FreeImage/PluginTIFF.cpp +index 562fdd7..ce12649 100644 +--- a/Source/FreeImage/PluginTIFF.cpp ++++ b/Source/FreeImage/PluginTIFF.cpp +@@ -39,7 +39,7 @@ + #include "Utilities.h" + #include + #include "../Metadata/FreeImageTag.h" +-#include "../OpenEXR/Half/half.h" ++#include + + #include "FreeImageIO.h" + #include "PSDParser.h" diff --git a/recipes/freeimage/all/patches/007_use-external-openjpeg.patch b/recipes/freeimage/all/patches/007_use-external-openjpeg.patch new file mode 100644 index 0000000000000..fa4f8e7b6e791 --- /dev/null +++ b/recipes/freeimage/all/patches/007_use-external-openjpeg.patch @@ -0,0 +1,39 @@ +diff --git a/Source/FreeImage/J2KHelper.cpp b/Source/FreeImage/J2KHelper.cpp +index 1776c3b..538f1c5 100644 +--- a/Source/FreeImage/J2KHelper.cpp ++++ b/Source/FreeImage/J2KHelper.cpp +@@ -21,7 +21,7 @@ + + #include "FreeImage.h" + #include "Utilities.h" +-#include "../LibOpenJPEG/openjpeg.h" ++#include + #include "J2KHelper.h" + + // -------------------------------------------------------------------------- +diff --git a/Source/FreeImage/PluginJ2K.cpp b/Source/FreeImage/PluginJ2K.cpp +index b8bcfc8..621a903 100644 +--- a/Source/FreeImage/PluginJ2K.cpp ++++ b/Source/FreeImage/PluginJ2K.cpp +@@ -21,7 +21,7 @@ + + #include "FreeImage.h" + #include "Utilities.h" +-#include "../LibOpenJPEG/openjpeg.h" ++#include + #include "J2KHelper.h" + + // ========================================================== +diff --git a/Source/FreeImage/PluginJP2.cpp b/Source/FreeImage/PluginJP2.cpp +index 742fe2c..c57f626 100644 +--- a/Source/FreeImage/PluginJP2.cpp ++++ b/Source/FreeImage/PluginJP2.cpp +@@ -21,7 +21,7 @@ + + #include "FreeImage.h" + #include "Utilities.h" +-#include "../LibOpenJPEG/openjpeg.h" ++#include + #include "J2KHelper.h" + + // ========================================================== diff --git a/recipes/freeimage/all/patches/008_use-external-png-zlib.patch b/recipes/freeimage/all/patches/008_use-external-png-zlib.patch new file mode 100644 index 0000000000000..da489b6b82cd4 --- /dev/null +++ b/recipes/freeimage/all/patches/008_use-external-png-zlib.patch @@ -0,0 +1,40 @@ +diff --git a/Source/FreeImage/PluginPNG.cpp b/Source/FreeImage/PluginPNG.cpp +index ba2ef17..c3c5cd6 100644 +--- a/Source/FreeImage/PluginPNG.cpp ++++ b/Source/FreeImage/PluginPNG.cpp +@@ -40,8 +40,8 @@ + + // ---------------------------------------------------------- + +-#include "../ZLib/zlib.h" +-#include "../LibPNG/png.h" ++#include ++#include + + // ---------------------------------------------------------- + +diff --git a/Source/FreeImage/ZLibInterface.cpp b/Source/FreeImage/ZLibInterface.cpp +index 3ab6d32..725618b 100644 +--- a/Source/FreeImage/ZLibInterface.cpp ++++ b/Source/FreeImage/ZLibInterface.cpp +@@ -19,10 +19,9 @@ + // Use at your own risk! + // ========================================================== + +-#include "../ZLib/zlib.h" ++#include + #include "FreeImage.h" + #include "Utilities.h" +-#include "../ZLib/zutil.h" /* must be the last header because of error C3163 in VS2008 (_vsnprintf defined in stdio.h) */ + + /** + Compresses a source buffer into a target buffer, using the ZLib library. +@@ -115,7 +114,7 @@ FreeImage_ZLibGZip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_s + return 0; + case Z_OK: { + // patch header, setup crc and length (stolen from mod_trace_output) +- BYTE *p = target + 8; *p++ = 2; *p = OS_CODE; // xflags, os_code ++ BYTE *p = target + 8; *p++ = 2; *p = 0x03; // xflags, os_code + crc = crc32(crc, source, source_size); + memcpy(target + 4 + dest_len, &crc, 4); + memcpy(target + 8 + dest_len, &source_size, 4); diff --git a/recipes/freeimage/all/patches/009_use-external-rawlib.patch b/recipes/freeimage/all/patches/009_use-external-rawlib.patch new file mode 100644 index 0000000000000..6afa0bffa2549 --- /dev/null +++ b/recipes/freeimage/all/patches/009_use-external-rawlib.patch @@ -0,0 +1,13 @@ +diff --git a/Source/FreeImage/PluginRAW.cpp b/Source/FreeImage/PluginRAW.cpp +index e9bd5bf..c7f8758 100644 +--- a/Source/FreeImage/PluginRAW.cpp ++++ b/Source/FreeImage/PluginRAW.cpp +@@ -19,7 +19,7 @@ + // Use at your own risk! + // ========================================================== + +-#include "../LibRawLite/libraw/libraw.h" ++#include + + #include "FreeImage.h" + #include "Utilities.h" diff --git a/recipes/freeimage/all/patches/010_use-external-webp.patch b/recipes/freeimage/all/patches/010_use-external-webp.patch new file mode 100644 index 0000000000000..4d1757c395fd7 --- /dev/null +++ b/recipes/freeimage/all/patches/010_use-external-webp.patch @@ -0,0 +1,17 @@ +diff --git a/Source/FreeImage/PluginWebP.cpp b/Source/FreeImage/PluginWebP.cpp +index 7c9f62f..c401447 100644 +--- a/Source/FreeImage/PluginWebP.cpp ++++ b/Source/FreeImage/PluginWebP.cpp +@@ -24,9 +24,9 @@ + + #include "../Metadata/FreeImageTag.h" + +-#include "../LibWebP/src/webp/decode.h" +-#include "../LibWebP/src/webp/encode.h" +-#include "../LibWebP/src/webp/mux.h" ++#include ++#include ++#include + + // ========================================================== + // Plugin Interface diff --git a/recipes/freeimage/all/patches/011_update-libraw-support.patch b/recipes/freeimage/all/patches/011_update-libraw-support.patch new file mode 100644 index 0000000000000..666b98d8aff3a --- /dev/null +++ b/recipes/freeimage/all/patches/011_update-libraw-support.patch @@ -0,0 +1,149 @@ +diff --git a/Source/FreeImage/PluginRAW.cpp b/Source/FreeImage/PluginRAW.cpp +index e9bd5bf..c7f8758 100644 +--- a/Source/FreeImage/PluginRAW.cpp ++++ b/Source/FreeImage/PluginRAW.cpp +@@ -59,21 +59,18 @@ + } + + int valid() { +- return (_io && _handle); ++ return (_io && _handle) ? 1 : 0; + } + + int read(void *buffer, size_t size, size_t count) { +- if(substream) return substream->read(buffer, size, count); + return _io->read_proc(buffer, (unsigned)size, (unsigned)count, _handle); + } + + int seek(INT64 offset, int origin) { +- if(substream) return substream->seek(offset, origin); + return _io->seek_proc(_handle, (long)offset, origin); + } + + INT64 tell() { +- if(substream) return substream->tell(); + return _io->tell_proc(_handle); + } + +@@ -83,19 +80,21 @@ + + int get_char() { + int c = 0; +- if(substream) return substream->get_char(); +- if(!_io->read_proc(&c, 1, 1, _handle)) return -1; ++ if (!_io->read_proc(&c, 1, 1, _handle)) { ++ return -1; ++ } + return c; + } + + char* gets(char *buffer, int length) { +- if (substream) return substream->gets(buffer, length); + memset(buffer, 0, length); + for(int i = 0; i < length; i++) { +- if(!_io->read_proc(&buffer[i], 1, 1, _handle)) ++ if (!_io->read_proc(&buffer[i], 1, 1, _handle)) { + return NULL; +- if(buffer[i] == 0x0A) ++ } ++ if (buffer[i] == 0x0A) { + break; ++ } + } + return buffer; + } +@@ -104,7 +103,6 @@ + std::string buffer; + char element = 0; + bool bDone = false; +- if(substream) return substream->scanf_one(fmt,val); + do { + if(_io->read_proc(&element, 1, 1, _handle) == 1) { + switch(element) { +@@ -127,7 +125,6 @@ + } + + int eof() { +- if(substream) return substream->eof(); + return (_io->tell_proc(_handle) >= _eof); + } + +@@ -564,48 +561,58 @@ + { 0x4D, 0x4D, 0x00, 0x2A } Classic TIFF, big-endian + */ + // Canon (CR2), little-endian byte order +- const BYTE CR2_II[] = { 0x49, 0x49, 0x2A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x43, 0x52, 0x02, 0x00 }; ++ static const BYTE CR2_II[] = { 0x49, 0x49, 0x2A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x43, 0x52, 0x02, 0x00 }; + // Canon (CRW), little-endian byte order +- const BYTE CRW_II[] = { 0x49, 0x49, 0x1A, 0x00, 0x00, 0x00, 0x48, 0x45, 0x41, 0x50, 0x43, 0x43, 0x44, 0x52, 0x02, 0x00 }; ++ static const BYTE CRW_II[] = { 0x49, 0x49, 0x1A, 0x00, 0x00, 0x00, 0x48, 0x45, 0x41, 0x50, 0x43, 0x43, 0x44, 0x52, 0x02, 0x00 }; + // Minolta (MRW) +- const BYTE MRW[] = { 0x00, 0x4D, 0x52, 0x4D, 0x00 }; ++ static const BYTE MRW[] = { 0x00, 0x4D, 0x52, 0x4D, 0x00 }; + // Olympus (ORF), little-endian byte order +- const BYTE ORF_IIRS[] = { 0x49, 0x49, 0x52, 0x53, 0x08, 0x00, 0x00, 0x00 }; +- const BYTE ORF_IIRO[] = { 0x49, 0x49, 0x52, 0x4F, 0x08, 0x00, 0x00, 0x00 }; ++ static const BYTE ORF_IIRS[] = { 0x49, 0x49, 0x52, 0x53, 0x08, 0x00, 0x00, 0x00 }; ++ static const BYTE ORF_IIRO[] = { 0x49, 0x49, 0x52, 0x4F, 0x08, 0x00, 0x00, 0x00 }; + // Olympus (ORF), big-endian byte order +- const BYTE ORF_MMOR[] = { 0x4D, 0x4D, 0x4F, 0x52, 0x00, 0x00, 0x00, 0x08 }; ++ static const BYTE ORF_MMOR[] = { 0x4D, 0x4D, 0x4F, 0x52, 0x00, 0x00, 0x00, 0x08 }; + // Fujifilm (RAF) +- const BYTE RAF[] = { 0x46, 0x55, 0x4A, 0x49, 0x46, 0x49, 0x4C, 0x4D, 0x43, 0x43, 0x44, 0x2D, 0x52, 0x41, 0x57, 0x20 }; ++ static const BYTE RAF[] = { 0x46, 0x55, 0x4A, 0x49, 0x46, 0x49, 0x4C, 0x4D, 0x43, 0x43, 0x44, 0x2D, 0x52, 0x41, 0x57, 0x20 }; + // Panasonic (RW2) or Leica (RWL), little-endian byte order +- const BYTE RWx_II[] = { 0x49, 0x49, 0x55, 0x00, 0x18, 0x00, 0x00, 0x00, 0x88, 0xE7, 0x74, 0xD8, 0xF8, 0x25, 0x1D, 0x4D, 0x94, 0x7A, 0x6E, 0x77, 0x82, 0x2B, 0x5D, 0x6A }; ++ static const BYTE RWx_II[] = { 0x49, 0x49, 0x55, 0x00, 0x18, 0x00, 0x00, 0x00, 0x88, 0xE7, 0x74, 0xD8, 0xF8, 0x25, 0x1D, 0x4D, 0x94, 0x7A, 0x6E, 0x77, 0x82, 0x2B, 0x5D, 0x6A }; + // Panasonic (RAW) or Leica (RAW), little-endian byte order +- const BYTE RAW_II[] = { 0x49, 0x49, 0x55, 0x00, 0x08, 0x00, 0x00, 0x00, 0x22, 0x00, 0x01, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00 }; ++ static const BYTE RAW_II[] = { 0x49, 0x49, 0x55, 0x00, 0x08, 0x00, 0x00, 0x00, 0x22, 0x00, 0x01, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00 }; + // Foveon (X3F) +- const BYTE X3F[] = { 0x46, 0x4F, 0x56, 0x62 }; ++ static const BYTE X3F[] = { 0x46, 0x4F, 0x56, 0x62 }; + + if(io->read_proc(signature, 1, signature_size, handle) != signature_size) { + return FALSE; + } +- if(memcmp(CR2_II, signature, 12) == 0) ++ if (memcmp(CR2_II, signature, 12) == 0) { + return TRUE; +- if(memcmp(CRW_II, signature, 16) == 0) ++ } ++ if (memcmp(CRW_II, signature, 16) == 0) { + return TRUE; +- if(memcmp(MRW, signature, 5) == 0) ++ } ++ if (memcmp(MRW, signature, 5) == 0) { + return TRUE; +- if(memcmp(ORF_IIRS, signature, 8) == 0) ++ } ++ if (memcmp(ORF_IIRS, signature, 8) == 0) { + return TRUE; +- if(memcmp(ORF_IIRO, signature, 8) == 0) ++ } ++ if (memcmp(ORF_IIRO, signature, 8) == 0) { + return TRUE; +- if(memcmp(ORF_MMOR, signature, 8) == 0) ++ } ++ if (memcmp(ORF_MMOR, signature, 8) == 0) { + return TRUE; +- if(memcmp(RAF, signature, 16) == 0) ++ } ++ if (memcmp(RAF, signature, 16) == 0) { + return TRUE; +- if(memcmp(RWx_II, signature, 24) == 0) ++ } ++ if (memcmp(RWx_II, signature, 24) == 0) { + return TRUE; +- if(memcmp(RAW_II, signature, 18) == 0) ++ } ++ if (memcmp(RAW_II, signature, 18) == 0) { + return TRUE; +- if(memcmp(X3F, signature, 4) == 0) ++ } ++ if (memcmp(X3F, signature, 4) == 0) { + return TRUE; ++ } + + return FALSE; + } diff --git a/recipes/freeimage/all/patches/012_use-functions-to-override-libtiff-warning-error-handlers.patch b/recipes/freeimage/all/patches/012_use-functions-to-override-libtiff-warning-error-handlers.patch new file mode 100644 index 0000000000000..7c62447a68a50 --- /dev/null +++ b/recipes/freeimage/all/patches/012_use-functions-to-override-libtiff-warning-error-handlers.patch @@ -0,0 +1,31 @@ +diff --git a/Source/FreeImage/PluginTIFF.cpp b/Source/FreeImage/PluginTIFF.cpp +index a9fcf0e..b1f7b32 100644 +--- a/Source/FreeImage/PluginTIFF.cpp ++++ b/Source/FreeImage/PluginTIFF.cpp +@@ -258,7 +258,7 @@ static void + msdosWarningHandler(const char* module, const char* fmt, va_list ap) { + } + +-TIFFErrorHandler _TIFFwarningHandler = msdosWarningHandler; ++//TIFFErrorHandler _TIFFwarningHandler = msdosWarningHandler; + + static void + msdosErrorHandler(const char* module, const char* fmt, va_list ap) { +@@ -273,7 +273,7 @@ msdosErrorHandler(const char* module, const char* fmt, va_list ap) { + */ + } + +-TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler; ++//TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler; + + // ---------------------------------------------------------- + +@@ -2659,6 +2659,8 @@ InitTIFF(Plugin *plugin, int format_id) { + // Set up the callback for extended TIFF directory tag support (see XTIFF.cpp) + // Must be called before using libtiff + XTIFFInitialize(); ++ TIFFSetWarningHandler(msdosWarningHandler); ++ TIFFSetErrorHandler(msdosErrorHandler); + + plugin->format_proc = Format; + plugin->description_proc = Description; diff --git a/recipes/freeimage/all/patches/013_use-typedef-as-already-declared.patch b/recipes/freeimage/all/patches/013_use-typedef-as-already-declared.patch new file mode 100644 index 0000000000000..27428582075c5 --- /dev/null +++ b/recipes/freeimage/all/patches/013_use-typedef-as-already-declared.patch @@ -0,0 +1,15 @@ +diff --git a/Source/FreeImage.h b/Source/FreeImage.h +index 1fd9c2f..59de277 100644 +--- a/Source/FreeImage.h ++++ b/Source/FreeImage.h +@@ -155,8 +155,8 @@ typedef uint8_t BYTE; + typedef uint16_t WORD; + typedef uint32_t DWORD; + typedef int32_t LONG; +-typedef int64_t INT64; +-typedef uint64_t UINT64; ++typedef long long int INT64; ++typedef long long unsigned int UINT64; + #else + // MS is not C99 ISO compliant + typedef long BOOL; diff --git a/recipes/freeimage/all/patches/014_no_auto_ptr.patch b/recipes/freeimage/all/patches/014_no_auto_ptr.patch new file mode 100644 index 0000000000000..31d357cd93617 --- /dev/null +++ b/recipes/freeimage/all/patches/014_no_auto_ptr.patch @@ -0,0 +1,24 @@ +--- /Source/FreeImage/MultiPage.cpp ++++ /Source/FreeImage/MultiPage.cpp +@@ -271,8 +271,8 @@ FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL crea + } + } + +- std::auto_ptr bitmap (new FIMULTIBITMAP); +- std::auto_ptr header (new MULTIBITMAPHEADER); ++ std::unique_ptr bitmap (new FIMULTIBITMAP); ++ std::unique_ptr header (new MULTIBITMAPHEADER); + header->m_filename = filename; + // io is default + header->node = node; +@@ -337,8 +337,8 @@ FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_h + PluginNode *node = list->FindNodeFromFIF(fif); + + if (node) { +- std::auto_ptr bitmap (new FIMULTIBITMAP); +- std::auto_ptr header (new MULTIBITMAPHEADER); ++ std::unique_ptr bitmap (new FIMULTIBITMAP); ++ std::unique_ptr header (new MULTIBITMAPHEADER); + header->io = *io; + header->node = node; + header->fif = fif; diff --git a/recipes/freeimage/all/test_package/CMakeLists.txt b/recipes/freeimage/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a3aaf996ceb62 --- /dev/null +++ b/recipes/freeimage/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(freeimage CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE freeimage::freeimage) diff --git a/recipes/freeimage/all/test_package/conanfile.py b/recipes/freeimage/all/test_package/conanfile.py new file mode 100644 index 0000000000000..de9c0e321b02f --- /dev/null +++ b/recipes/freeimage/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + bees = os.path.join(self.source_folder, "test.png") + self.run(f"{bin_path} {bees}", env="conanrun") diff --git a/recipes/freeimage/all/test_package/test.png b/recipes/freeimage/all/test_package/test.png new file mode 100644 index 0000000000000..11640c7488fb1 Binary files /dev/null and b/recipes/freeimage/all/test_package/test.png differ diff --git a/recipes/freeimage/all/test_package/test_package.cpp b/recipes/freeimage/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..0adc1a0375b01 --- /dev/null +++ b/recipes/freeimage/all/test_package/test_package.cpp @@ -0,0 +1,53 @@ +#include + +#include + +#if defined(FREEIMAGE_LIB) || !defined(WIN32) +#define NEED_INIT 1 +#endif + +void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char* message) +{ + std::cerr << "FreeImage error: " << message << std::endl; +} + +int main(int argc, char** argv ) +{ + if (argc < 2) { + std::cerr << "Need at least one argument" << std::endl; + return 1; + } + +#if NEED_INIT + FreeImage_Initialise(); +#endif + + FreeImage_SetOutputMessage(FreeImageErrorHandler); + + std::cout << "FreeImage " << FreeImage_GetVersion() << ", with:" << std::endl; + + for (int i = 0; i < FreeImage_GetFIFCount(); ++i) + { + std::cout << "\t- " << FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i) << std::endl; + } + + const char * image_file = argv[1]; + FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; + fif = FreeImage_GetFileType(image_file, 0); + if (fif == FIF_UNKNOWN) { + fif = FreeImage_GetFIFFromFilename(image_file); + } + if ((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) { + FIBITMAP* dib = FreeImage_Load(fif, image_file, 0); + if (dib) + { + FreeImage_Unload(dib); + } + } + +#if NEED_INIT + FreeImage_DeInitialise(); +#endif + + return 0; +} diff --git a/recipes/freeimage/all/test_v1_package/CMakeLists.txt b/recipes/freeimage/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..194a54c3b3a89 --- /dev/null +++ b/recipes/freeimage/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(freeimage REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE freeimage::freeimage) diff --git a/recipes/freeimage/all/test_v1_package/conanfile.py b/recipes/freeimage/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..6895afd01c85c --- /dev/null +++ b/recipes/freeimage/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + bees = os.path.join(self.source_folder, os.pardir, "test_package", "test.png") + self.run(f"{bin_path} {bees}", run_environment=True) diff --git a/recipes/freeimage/config.yml b/recipes/freeimage/config.yml new file mode 100644 index 0000000000000..7e5f545547ca1 --- /dev/null +++ b/recipes/freeimage/config.yml @@ -0,0 +1,3 @@ +versions: + "3.18.0": + folder: all diff --git a/recipes/freetype/all/CMakeLists.txt b/recipes/freetype/all/CMakeLists.txt deleted file mode 100644 index bd3083b512cb9..0000000000000 --- a/recipes/freetype/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/freetype/all/conandata.yml b/recipes/freetype/all/conandata.yml index 3aa4122aa9c95..d87a9087670e2 100644 --- a/recipes/freetype/all/conandata.yml +++ b/recipes/freetype/all/conandata.yml @@ -1,25 +1,19 @@ sources: - "2.10.4": - url: [ - "https://download.savannah.gnu.org/releases/freetype/freetype-2.10.4.tar.gz", - "https://sourceforge.net/projects/freetype/files/freetype2/2.10.4/freetype-2.10.4.tar.gz/download", - ] - sha256: "5eab795ebb23ac77001cfb68b7d4d50b5d6c7469247b0b01b2c953269f658dac" - "2.10.2": + "2.12.1": url: [ - "https://download.savannah.gnu.org/releases/freetype/freetype-2.10.2.tar.gz", - "https://sourceforge.net/projects/freetype/files/freetype2/2.10.2/freetype-2.10.2.tar.gz/download", + "https://download.savannah.gnu.org/releases/freetype/freetype-2.12.1.tar.gz", + "https://sourceforge.net/projects/freetype/files/freetype2/2.12.1/freetype-2.12.1.tar.gz/download", ] - sha256: "e09aa914e4f7a5d723ac381420949c55c0b90b15744adce5d1406046022186ab" - "2.10.1": + sha256: "efe71fd4b8246f1b0b1b9bfca13cfff1c9ad85930340c27df469733bbb620938" + "2.11.1": url: [ - "https://download.savannah.gnu.org/releases/freetype/freetype-2.10.1.tar.gz", - "https://sourceforge.net/projects/freetype/files/freetype2/2.10.1/freetype-2.10.1.tar.gz/download", + "https://download.savannah.gnu.org/releases/freetype/freetype-2.11.1.tar.gz", + "https://sourceforge.net/projects/freetype/files/freetype2/2.11.1/freetype-2.11.1.tar.gz/download", ] - sha256: "3a60d391fd579440561bf0e7f31af2222bc610ad6ce4d9d7bd2165bca8669110" - "2.10.0": + sha256: "f8db94d307e9c54961b39a1cc799a67d46681480696ed72ecf78d4473770f09b" + "2.10.4": url: [ - "https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.gz", - "https://sourceforge.net/projects/freetype/files/freetype2/2.10.0/freetype-2.10.0.tar.gz/download", + "https://download.savannah.gnu.org/releases/freetype/freetype-2.10.4.tar.gz", + "https://sourceforge.net/projects/freetype/files/freetype2/2.10.4/freetype-2.10.4.tar.gz/download", ] - sha256: "955e17244e9b38adb0c98df66abb50467312e6bb70eac07e49ce6bd1a20e809a" + sha256: "5eab795ebb23ac77001cfb68b7d4d50b5d6c7469247b0b01b2c953269f658dac" diff --git a/recipes/freetype/all/conanfile.py b/recipes/freetype/all/conanfile.py index 9007a2818523a..934fe24eeba5e 100644 --- a/recipes/freetype/all/conanfile.py +++ b/recipes/freetype/all/conanfile.py @@ -1,20 +1,21 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import collect_libs, copy, load, get, rename, replace_in_file, rmdir, save +from conan.tools.scm import Version import os -import shutil +import re import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.52.0" class FreetypeConan(ConanFile): name = "freetype" - - _libtool_version = "23.0.17" # check docs/version.txt, this is a different version mumber! description = "FreeType is a freely available software library to render fonts." url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.freetype.org" license = "FTL" - topics = ("conan", "freetype", "fonts") + topics = ("freetype", "fonts") settings = "os", "arch", "compiler", "build_type" options = { @@ -24,6 +25,7 @@ class FreetypeConan(ConanFile): "with_zlib": [True, False], "with_bzip2": [True, False], "with_brotli": [True, False], + "subpixel": [True, False], } default_options = { "shared": False, @@ -31,24 +33,13 @@ class FreetypeConan(ConanFile): "with_png": True, "with_zlib": True, "with_bzip2": True, - "with_brotli": True + "with_brotli": True, + "subpixel": False } - exports_sources = "CMakeLists.txt" - generators = "cmake", "cmake_find_package" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - @property def _has_with_brotli_option(self): - return tools.Version(self.version) >= "2.10.2" + return Version(self.version) >= "2.10.2" def config_options(self): if self.settings.os == "Windows": @@ -58,115 +49,178 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): if self.options.with_png: - self.requires("libpng/1.6.37") + self.requires("libpng/1.6.39") if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.with_bzip2: self.requires("bzip2/1.0.8") if self.options.get_safe("with_brotli"): self.requires("brotli/1.0.9") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{0}-{1}".format(self.name, self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + + cmake = CMakeToolchain(self) + if Version(self.version) >= "2.11.0": + cmake.variables["FT_REQUIRE_ZLIB"] = self.options.with_zlib + cmake.variables["FT_DISABLE_ZLIB"] = not self.options.with_zlib + cmake.variables["FT_REQUIRE_PNG"] = self.options.with_png + cmake.variables["FT_DISABLE_PNG"] = not self.options.with_png + cmake.variables["FT_REQUIRE_BZIP2"] = self.options.with_bzip2 + cmake.variables["FT_DISABLE_BZIP2"] = not self.options.with_bzip2 + # TODO: Harfbuzz can be added as an option as soon as it is available. + cmake.variables["FT_REQUIRE_HARFBUZZ"] = False + cmake.variables["FT_DISABLE_HARFBUZZ"] = True + if self._has_with_brotli_option: + cmake.variables["FT_REQUIRE_BROTLI"] = self.options.with_brotli + cmake.variables["FT_DISABLE_BROTLI"] = not self.options.with_brotli + else: + cmake.variables["FT_WITH_ZLIB"] = self.options.with_zlib + cmake.variables["FT_WITH_PNG"] = self.options.with_png + cmake.variables["FT_WITH_BZIP2"] = self.options.with_bzip2 + # TODO: Harfbuzz can be added as an option as soon as it is available. + cmake.variables["FT_WITH_HARFBUZZ"] = False + if self._has_with_brotli_option: + cmake.variables["FT_WITH_BROTLI"] = self.options.with_brotli + # Generate a relocatable shared lib on Macos + cmake.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + cmake.generate() def _patch_sources(self): # Do not accidentally enable dependencies we have disabled - cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") - find_harfbuzz = "find_package(HarfBuzz {})".format("1.3.0" if tools.Version(self.version) < "2.10.2" else "${HARFBUZZ_MIN_VERSION}") - tools.replace_in_file(cmakelists, find_harfbuzz, "") - tools.replace_in_file(cmakelists, "if (HARFBUZZ_FOUND)", "if(0)") + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + find_harfbuzz = "find_package(HarfBuzz {})".format("1.3.0" if Version(self.version) < "2.10.2" else "${HARFBUZZ_MIN_VERSION}") + if_harfbuzz_found = "if ({})".format("HARFBUZZ_FOUND" if Version(self.version) < "2.11.0" else "HarfBuzz_FOUND") + replace_in_file(self, cmakelists, find_harfbuzz, "") + replace_in_file(self, cmakelists, if_harfbuzz_found, "if(0)") if not self.options.with_png: - tools.replace_in_file(cmakelists, "find_package(PNG)", "") - tools.replace_in_file(cmakelists, "if (PNG_FOUND)", "if(0)") + replace_in_file(self, cmakelists, "find_package(PNG)", "") + replace_in_file(self, cmakelists, "if (PNG_FOUND)", "if(0)") if not self.options.with_zlib: - tools.replace_in_file(cmakelists, "find_package(ZLIB)", "") - tools.replace_in_file(cmakelists, "if (ZLIB_FOUND)", "if(0)") + replace_in_file(self, cmakelists, "find_package(ZLIB)", "") + replace_in_file(self, cmakelists, "if (ZLIB_FOUND)", "if(0)") if not self.options.with_bzip2: - tools.replace_in_file(cmakelists, "find_package(BZip2)", "") - tools.replace_in_file(cmakelists, "if (BZIP2_FOUND)", "if(0)") + replace_in_file(self, cmakelists, "find_package(BZip2)", "") + replace_in_file(self, cmakelists, "if (BZIP2_FOUND)", "if(0)") if self._has_with_brotli_option: # the custom FindBrotliDec of upstream is too fragile - tools.replace_in_file(cmakelists, + replace_in_file(self, cmakelists, "find_package(BrotliDec REQUIRED)", "find_package(Brotli REQUIRED)\n" "set(BROTLIDEC_FOUND 1)\n" - "set(BROTLIDEC_LIBRARIES \"Brotli::Brotli\")") + "set(BROTLIDEC_LIBRARIES \"brotli::brotli\")") if not self.options.with_brotli: - tools.replace_in_file(cmakelists, "find_package(BrotliDec)", "") - tools.replace_in_file(cmakelists, "if (BROTLIDEC_FOUND)", "if(0)") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["PROJECT_VERSION"] = self._libtool_version - self._cmake.definitions["FT_WITH_ZLIB"] = self.options.with_zlib - self._cmake.definitions["FT_WITH_PNG"] = self.options.with_png - self._cmake.definitions["FT_WITH_BZIP2"] = self.options.with_bzip2 - # TODO: Harfbuzz can be added as an option as soon as it is available. - self._cmake.definitions["FT_WITH_HARFBUZZ"] = False - if self._has_with_brotli_option: - self._cmake.definitions["FT_WITH_BROTLI"] = self.options.with_brotli - self._cmake.configure(build_dir=self._build_subfolder) - return self._cmake + replace_in_file(self, cmakelists, "find_package(BrotliDec)", "") + replace_in_file(self, cmakelists, "if (BROTLIDEC_FOUND)", "if(0)") + + config_h = os.path.join(self.source_folder, "include", "freetype", "config", "ftoption.h") + if self.options.subpixel: + replace_in_file(self, config_h, "/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */", "#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() - def _make_freetype_config(self): - freetype_config_in = os.path.join(self._source_subfolder, "builds", "unix", "freetype-config.in") + def _make_freetype_config(self, version): + freetype_config_in = os.path.join(self.source_folder, "builds", "unix", "freetype-config.in") if not os.path.isdir(os.path.join(self.package_folder, "bin")): os.makedirs(os.path.join(self.package_folder, "bin")) freetype_config = os.path.join(self.package_folder, "bin", "freetype-config") - shutil.copy(freetype_config_in, freetype_config) + rename(self, freetype_config_in, freetype_config) libs = "-lfreetyped" if self.settings.build_type == "Debug" else "-lfreetype" - staticlibs = "-lm %s" % libs if self.settings.os == "Linux" else libs - tools.replace_in_file(freetype_config, r"%PKG_CONFIG%", r"/bin/false") # never use pkg-config - tools.replace_in_file(freetype_config, r"%prefix%", r"$conan_prefix") - tools.replace_in_file(freetype_config, r"%exec_prefix%", r"$conan_exec_prefix") - tools.replace_in_file(freetype_config, r"%includedir%", r"$conan_includedir") - tools.replace_in_file(freetype_config, r"%libdir%", r"$conan_libdir") - tools.replace_in_file(freetype_config, r"%ft_version%", r"$conan_ftversion") - tools.replace_in_file(freetype_config, r"%LIBSSTATIC_CONFIG%", r"$conan_staticlibs") - tools.replace_in_file(freetype_config, r"-lfreetype", libs) - tools.replace_in_file(freetype_config, r"export LC_ALL", """export LC_ALL -BINDIR=$(dirname $0) -conan_prefix=$(dirname $BINDIR) -conan_exec_prefix=${{conan_prefix}}/bin -conan_includedir=${{conan_prefix}}/include -conan_libdir=${{conan_prefix}}/lib -conan_ftversion={version} -conan_staticlibs="{staticlibs}" -""".format(version=self._libtool_version, staticlibs=staticlibs)) + staticlibs = f"-lm {libs}" if self.settings.os == "Linux" else libs + replace_in_file(self, freetype_config, r"%PKG_CONFIG%", r"/bin/false") # never use pkg-config + replace_in_file(self, freetype_config, r"%prefix%", r"$conan_prefix") + replace_in_file(self, freetype_config, r"%exec_prefix%", r"$conan_exec_prefix") + replace_in_file(self, freetype_config, r"%includedir%", r"$conan_includedir") + replace_in_file(self, freetype_config, r"%libdir%", r"$conan_libdir") + replace_in_file(self, freetype_config, r"%ft_version%", r"$conan_ftversion") + replace_in_file(self, freetype_config, r"%LIBSSTATIC_CONFIG%", r"$conan_staticlibs") + replace_in_file(self, freetype_config, r"-lfreetype", libs) + replace_in_file(self, freetype_config, r"export LC_ALL", textwrap.dedent("""\ + export LC_ALL + BINDIR=$(dirname $0) + conan_prefix=$(dirname $BINDIR) + conan_exec_prefix=${{conan_prefix}}/bin + conan_includedir=${{conan_prefix}}/include + conan_libdir=${{conan_prefix}}/lib + conan_ftversion={version} + conan_staticlibs="{staticlibs}" + """).format(version=version, staticlibs=staticlibs)) + + def _extract_libtool_version(self): + conf_raw = load(self, os.path.join(self.source_folder, "builds", "unix", "configure.raw")) + return next(re.finditer(r"^version_info='([0-9:]+)'", conf_raw, flags=re.M)).group(1).replace(":", ".") + + @property + def _libtool_version_txt(self): + return os.path.join(self.package_folder, "res", "freetype-libtool-version.txt") def package(self): - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - self._make_freetype_config() - self.copy("FTL.TXT", dst="licenses", src=os.path.join(self._source_subfolder, "docs")) - self.copy("GPLv2.TXT", dst="licenses", src=os.path.join(self._source_subfolder, "docs")) - self.copy("LICENSE.TXT", dst="licenses", src=os.path.join(self._source_subfolder, "docs")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + libtool_version = self._extract_libtool_version() + save(self, self._libtool_version_txt, libtool_version) + self._make_freetype_config(libtool_version) + + doc_folder = os.path.join(self.source_folder, "docs") + license_folder = os.path.join(self.package_folder, "licenses") + copy(self, "FTL.TXT", doc_folder, license_folder) + copy(self, "GPLv2.TXT", doc_folder, license_folder) + copy(self, "LICENSE.TXT", doc_folder, license_folder) + + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_vars_rel_path) + ) self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._module_file_rel_path), - { - "freetype": "Freetype::Freetype", - } + os.path.join(self.package_folder, self._module_target_rel_path), + {"freetype": "Freetype::Freetype"} ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_variables(self, module_file): + content = textwrap.dedent("""\ + set(FREETYPE_FOUND TRUE) + if(DEFINED Freetype_INCLUDE_DIRS) + set(FREETYPE_INCLUDE_DIRS ${Freetype_INCLUDE_DIRS}) + endif() + if(DEFINED Freetype_LIBRARIES) + set(FREETYPE_LIBRARIES ${Freetype_LIBRARIES}) + endif() + if(DEFINED Freetype_VERSION) + set(FREETYPE_VERSION_STRING ${Freetype_VERSION}) + endif() + """) + save(self, module_file, content) + + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): content += textwrap.dedent("""\ @@ -175,16 +229,15 @@ def _create_cmake_module_alias_targets(module_file, targets): set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) + save(self, module_file, content) @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + def _module_vars_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") @property - def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + def _module_target_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") @staticmethod def _chmod_plus_x(filename): @@ -192,19 +245,33 @@ def _chmod_plus_x(filename): os.chmod(filename, os.stat(filename).st_mode | 0o111) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_module_file_name", "Freetype") + self.cpp_info.set_property("cmake_module_target_name", "Freetype::Freetype") + self.cpp_info.set_property("cmake_file_name", "freetype") + self.cpp_info.set_property("cmake_target_name", "freetype") + self.cpp_info.set_property("cmake_build_modules", [self._module_vars_rel_path]) + self.cpp_info.set_property("pkg_config_name", "freetype2") + self.cpp_info.libs = collect_libs(self) + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") self.cpp_info.includedirs.append(os.path.join("include", "freetype2")) + + libtool_version = load(self, self._libtool_version_txt).strip() + self.conf_info.define("user.freetype:libtool_version", libtool_version) + # FIXME: need to do override the pkg_config version (pkg_config_custom_content does not work) + # self.cpp_info.version["pkg_config"] = pkg_config_version + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.filenames["cmake_find_package"] = "Freetype" + self.cpp_info.filenames["cmake_find_package_multi"] = "freetype" + self.cpp_info.names["cmake_find_package"] = "Freetype" + self.cpp_info.names["cmake_find_package_multi"] = "Freetype" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_vars_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_target_rel_path] + self.cpp_info.names["pkg_config"] = "freetype2" freetype_config = os.path.join(self.package_folder, "bin", "freetype-config") self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) self.env_info.FT2_CONFIG = freetype_config - self.user_info.LIBTOOL_VERSION = self._libtool_version self._chmod_plus_x(freetype_config) - # cmake's FindFreetype.cmake module with imported target: Freetype::Freetype - self.cpp_info.names["cmake_find_package"] = "Freetype" - self.cpp_info.filenames["cmake_find_package_multi"] = "freetype" - self.cpp_info.names["cmake_find_package_multi"] = "Freetype" - self.cpp_info.builddirs.append(self._module_subfolder) - self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - self.cpp_info.names["pkg_config"] = "freetype2" + self.user_info.LIBTOOL_VERSION = libtool_version diff --git a/recipes/freetype/all/test_package/CMakeLists.txt b/recipes/freetype/all/test_package/CMakeLists.txt index 86b3f9ba7ecd4..9ac9bd88e8a63 100644 --- a/recipes/freetype/all/test_package/CMakeLists.txt +++ b/recipes/freetype/all/test_package/CMakeLists.txt @@ -1,13 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/OpenSans-Bold.ttf - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -find_package(Freetype REQUIRED) +find_package(freetype REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} Freetype::Freetype) +target_link_libraries(${PROJECT_NAME} PRIVATE freetype) diff --git a/recipes/freetype/all/test_package/conanfile.py b/recipes/freetype/all/test_package/conanfile.py index 1d0bdd3779793..5da019d033eb1 100644 --- a/recipes/freetype/all/test_package/conanfile.py +++ b/recipes/freetype/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + font_path = os.path.join(self.source_folder, "OpenSans-Bold.ttf") + self.run(f"{bin_path} {font_path}", env="conanrun") diff --git a/recipes/freetype/all/test_package/test_package.c b/recipes/freetype/all/test_package/test_package.c index bf99686fa82ed..332eeaeae1c39 100644 --- a/recipes/freetype/all/test_package/test_package.c +++ b/recipes/freetype/all/test_package/test_package.c @@ -3,14 +3,14 @@ /* This small program shows how to print a rotated string with the */ /* FreeType 2 library. */ +#include "ft2build.h" +#include FT_FREETYPE_H #include #include #include #include -#include "ft2build.h" -#include FT_FREETYPE_H #define WIDTH 640 @@ -69,9 +69,13 @@ main( int argc, int target_height; size_t n, num_chars; + if (argc < 2) { + fprintf(stderr, "Usage: %s FONT\n", argv[0]); + return EXIT_FAILURE; + } - filename = "OpenSans-Bold.ttf"; - text = "Bincrafters"; + filename = argv[1]; + text = "conan-center-index"; num_chars = strlen( text ); angle = ( 25.0 / 360 ) * 3.14159 * 2; /* use 25 degrees */ target_height = HEIGHT; @@ -114,7 +118,7 @@ main( int argc, FT_Set_Transform( face, &matrix, &pen ); /* load glyph image into the slot (erase previous one) */ - error = FT_Load_Char( face, text[n], FT_LOAD_RENDER ); + error = FT_Load_Char( face, text[n], FT_LOAD_RENDER); if (error) { exit(EXIT_FAILURE); } diff --git a/recipes/freetype/all/test_package_module/CMakeLists.txt b/recipes/freetype/all/test_package_module/CMakeLists.txt new file mode 100644 index 0000000000000..3a9f9ffa7c630 --- /dev/null +++ b/recipes/freetype/all/test_package_module/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(Freetype REQUIRED MODULE) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE Freetype::Freetype) + +# Test whether variables from https://cmake.org/cmake/help/latest/module/FindFreetype.html +# are properly defined in conan generators +set(_custom_vars + FREETYPE_FOUND + FREETYPE_INCLUDE_DIRS + FREETYPE_LIBRARIES + FREETYPE_VERSION_STRING +) +foreach(_custom_var ${_custom_vars}) + if(DEFINED _custom_var) + message(STATUS "${_custom_var}: ${${_custom_var}}") + else() + message(FATAL_ERROR "${_custom_var} not defined") + endif() +endforeach() diff --git a/recipes/freetype/all/test_package_module/conanfile.py b/recipes/freetype/all/test_package_module/conanfile.py new file mode 100644 index 0000000000000..e789c017730b3 --- /dev/null +++ b/recipes/freetype/all/test_package_module/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + font_path = os.path.join(self.source_folder, os.pardir, "test_package", "OpenSans-Bold.ttf") + self.run(f"{bin_path} {font_path}", env="conanrun") diff --git a/recipes/freetype/all/test_v1_package/CMakeLists.txt b/recipes/freetype/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/freetype/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/freetype/all/test_v1_package/conanfile.py b/recipes/freetype/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..da2d908b1d4a7 --- /dev/null +++ b/recipes/freetype/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + font_path = os.path.join(self.source_folder, os.pardir, "test_package", "OpenSans-Bold.ttf") + self.run(f"{bin_path} {font_path}", run_environment=True) diff --git a/recipes/freetype/all/test_v1_package_module/CMakeLists.txt b/recipes/freetype/all/test_v1_package_module/CMakeLists.txt new file mode 100644 index 0000000000000..27f7a57e7a0b3 --- /dev/null +++ b/recipes/freetype/all/test_v1_package_module/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package_module + ${CMAKE_CURRENT_BINARY_DIR}/test_package_module) diff --git a/recipes/freetype/all/test_v1_package_module/conanfile.py b/recipes/freetype/all/test_v1_package_module/conanfile.py new file mode 100644 index 0000000000000..7834358365541 --- /dev/null +++ b/recipes/freetype/all/test_v1_package_module/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + font_path = os.path.join(self.source_folder, os.pardir, "test_package", "OpenSans-Bold.ttf") + self.run(f"{bin_path} {font_path}", run_environment=True) diff --git a/recipes/freetype/config.yml b/recipes/freetype/config.yml index 51971f6d64f0a..3617de8da17d5 100644 --- a/recipes/freetype/config.yml +++ b/recipes/freetype/config.yml @@ -1,9 +1,7 @@ versions: - "2.10.4": - folder: all - "2.10.2": + "2.12.1": folder: all - "2.10.1": + "2.11.1": folder: all - "2.10.0": + "2.10.4": folder: all diff --git a/recipes/freexl/all/conandata.yml b/recipes/freexl/all/conandata.yml index 5c4fe59a1d87b..cad6629b77bd2 100644 --- a/recipes/freexl/all/conandata.yml +++ b/recipes/freexl/all/conandata.yml @@ -1,16 +1,16 @@ sources: - "1.0.5": - url: "http://www.gaia-gis.it/gaia-sins/freexl-sources/freexl-1.0.5.tar.gz" - sha256: "3dc9b150d218b0e280a3d6a41d93c1e45f4d7155829d75f1e5bf3e0b0de6750d" "1.0.6": url: "http://www.gaia-gis.it/gaia-sins/freexl-sources/freexl-1.0.6.tar.gz" sha256: "3de8b57a3d130cb2881ea52d3aa9ce1feedb1b57b7daa4eb37f751404f90fc22" + "1.0.5": + url: "http://www.gaia-gis.it/gaia-sins/freexl-sources/freexl-1.0.5.tar.gz" + sha256: "3dc9b150d218b0e280a3d6a41d93c1e45f4d7155829d75f1e5bf3e0b0de6750d" patches: + "1.0.6": + - patch_file: "patches/fix-nmake-1.0.6.patch" + base_path: "source_subfolder" "1.0.5": - patch_file: "patches/fix-nmake-1.0.5.patch" base_path: "source_subfolder" - patch_file: "patches/msvc-round-lround.patch" base_path: "source_subfolder" - "1.0.6": - - patch_file: "patches/fix-nmake-1.0.6.patch" - base_path: "source_subfolder" diff --git a/recipes/freexl/all/conanfile.py b/recipes/freexl/all/conanfile.py index 1d551bb026b2c..008d173e58af5 100644 --- a/recipes/freexl/all/conanfile.py +++ b/recipes/freexl/all/conanfile.py @@ -1,27 +1,50 @@ -import glob +from conans import ConanFile, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment, tools +import functools import os +import shutil + +required_conan_version = ">=1.36.0" -from conans import ConanFile, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment, tools class FreexlConan(ConanFile): name = "freexl" description = "FreeXL is an open source library to extract valid data " \ "from within an Excel (.xls) spreadsheet." license = ["MPL-1.0", "GPL-2.0-only", "LGPL-2.1-only"] - topics = ("conan", "freexl", "excel", "xls") + topics = ("freexl", "excel", "xls") homepage = "https://www.gaia-gis.it/fossil/freexl/index" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "patches/**" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _autotools= None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } @property def _source_subfolder(self): return "source_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -36,20 +59,30 @@ def requirements(self): self.requires("libiconv/1.16") def build_requirements(self): - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio" and \ - "CONAN_BASH_PATH" not in os.environ and tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20200517") + if not self._is_msvc: + self.build_requires("gnu-config/cci.20201022") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - if self.settings.compiler == "Visual Studio": + + if self._is_msvc: self._build_msvc() else: + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) + # relocatable shared lib on macOS + tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), + "-install_name \\$rpath/", + "-install_name @rpath/") autotools = self._configure_autotools() autotools.make() @@ -60,18 +93,20 @@ def _build_msvc(self): with tools.environment_append(VisualStudioBuildEnvironment(self).vars): self.run("nmake -f makefile.vc {}".format(args)) + @functools.lru_cache(1) def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - args = ["--disable-static" if self.options.shared else "--enable-static", - "--enable-shared" if self.options.shared else "--disable-shared"] - self._autotools.configure(args=args, configure_dir=self._source_subfolder) - return self._autotools + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + ] + autotools.configure(args=args, configure_dir=self._source_subfolder) + return autotools def package(self): self.copy("COPYING", dst="licenses", src=self._source_subfolder) - if self.settings.compiler == "Visual Studio": + if self._is_msvc: self.copy("freexl.h", dst="include", src=os.path.join(self._source_subfolder, "headers")) self.copy("*.lib", dst="lib", src=self._source_subfolder) self.copy("*.dll", dst="bin", src=self._source_subfolder) @@ -79,10 +114,11 @@ def package(self): autotools = self._configure_autotools() autotools.install() tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - for la_file in glob.glob(os.path.join(self.package_folder, "lib", "*.la")): - os.remove(la_file) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.set_property("pkg_config_name", "freexl") + suffix = "_i" if self._is_msvc and self.options.shared else "" + self.cpp_info.libs = ["freexl{}".format(suffix)] + if self.settings.os in ("FreeBSD", "Linux"): self.cpp_info.system_libs.append("m") diff --git a/recipes/freexl/all/test_package/CMakeLists.txt b/recipes/freexl/all/test_package/CMakeLists.txt index 7b9b613cbb24a..a9baa640ef0d8 100644 --- a/recipes/freexl/all/test_package/CMakeLists.txt +++ b/recipes/freexl/all/test_package/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(freexl REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} freexl::freexl) diff --git a/recipes/freexl/all/test_package/conanfile.py b/recipes/freexl/all/test_package/conanfile.py index f3d786058ba51..e8957977baa1d 100644 --- a/recipes/freexl/all/test_package/conanfile.py +++ b/recipes/freexl/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conans import ConanFile, CMake, tools import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") def build(self): cmake = CMake(self) @@ -12,7 +21,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): xls_path = os.path.join(self.source_folder, "simple2003_21.xls") bin_path = os.path.join("bin", "test_package") self.run("{0} {1}".format(bin_path, xls_path), run_environment=True) diff --git a/recipes/freexl/config.yml b/recipes/freexl/config.yml index 5a87ca8f08361..06269eb399e91 100644 --- a/recipes/freexl/config.yml +++ b/recipes/freexl/config.yml @@ -1,5 +1,5 @@ versions: - "1.0.5": - folder: all "1.0.6": folder: all + "1.0.5": + folder: all diff --git a/recipes/fribidi/all/conandata.yml b/recipes/fribidi/all/conandata.yml index 5cfb52f11f63e..08937af14f728 100644 --- a/recipes/fribidi/all/conandata.yml +++ b/recipes/fribidi/all/conandata.yml @@ -1,8 +1,13 @@ sources: + "1.0.12": + url: "https://github.com/fribidi/fribidi/releases/download/v1.0.12/fribidi-1.0.12.tar.xz" + sha256: "0cd233f97fc8c67bb3ac27ce8440def5d3ffacf516765b91c2cc654498293495" + "1.0.10": + url: "https://github.com/fribidi/fribidi/releases/download/v1.0.10/fribidi-1.0.10.tar.xz" + sha256: "7f1c687c7831499bcacae5e8675945a39bacbad16ecaa945e9454a32df653c01" "1.0.9": url: "https://github.com/fribidi/fribidi/releases/download/v1.0.9/fribidi-1.0.9.tar.xz" sha256: "c5e47ea9026fb60da1944da9888b4e0a18854a0e2410bbfe7ad90a054d36e0c7" patches: "1.0.9": - - patch_file: "patches/0001-meson-no-tests-bin.patch" - base_path: "source_subfolder" + - patch_file: "patches/1.0.9-0001-meson-no-tests-bin.patch" diff --git a/recipes/fribidi/all/conanfile.py b/recipes/fribidi/all/conanfile.py index a199fc5b13680..b303aebbbf036 100644 --- a/recipes/fribidi/all/conanfile.py +++ b/recipes/fribidi/all/conanfile.py @@ -1,17 +1,24 @@ -from conans import tools, ConanFile, Meson -import glob +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, get, rm, rmdir +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.scm import Version import os +required_conan_version = ">=1.51.0" + class FriBiDiCOnan(ConanFile): name = "fribidi" description = "The Free Implementation of the Unicode Bidirectional Algorithm" - topics = ("conan", "fribidi", "unicode", "bidirectional", "text") + topics = ("fribidi", "unicode", "bidirectional", "text") license = "LGPL-2.1" homepage = "https://github.com/fribidi/fribidi" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -22,69 +29,86 @@ class FriBiDiCOnan(ConanFile): "fPIC": True, "with_deprecated": True, } - exports_sources = "patches/**" - - _meson = None - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd if self.settings.os == "Windows": del self.options.fPIC def configure(self): if self.options.shared: del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass def build_requirements(self): - self.build_requires("meson/0.53.0") - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("fribidi-{}".format(self.version), self._source_subfolder) + self.tool_requires("meson/0.63.1") - def _configure_meson(self): - if self._meson: - return self._meson - self._meson = Meson(self) - self._meson.options["deprecated"] = self.options.with_deprecated - self._meson.options["docs"] = False - self._meson.configure(build_folder=self._build_subfolder, source_folder=self._source_subfolder) - return self._meson + def layout(self): + basic_layout(self, src_folder="src") - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = MesonToolchain(self) + tc.project_options["deprecated"] = self.options.with_deprecated + tc.project_options["docs"] = False + if Version(self.version) >= "1.0.10": + tc.project_options["bin"] = False + tc.project_options["tests"] = False + tc.generate() + env = VirtualBuildEnv(self) + env.generate() def build(self): - self._patch_sources() - meson = self._configure_meson() + apply_conandata_patches(self) + meson = Meson(self) + meson.configure() meson.build() def package(self): - self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses") - meson = self._configure_meson() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + meson = Meson(self) meson.install() - - if self.settings.compiler == "Visual Studio": - lib_a = os.path.join(self.package_folder, "lib", "libfribidi.a") - if os.path.isfile(lib_a): - os.rename(lib_a, os.path.join(self.package_folder, "lib", "fribidi.lib")) - for pdb in glob.glob(os.path.join(self.package_folder, "bin", "*.pdb")): - os.unlink(pdb) - - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + fix_apple_shared_install_name(self) + fix_msvc_libname(self) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "fribidi") self.cpp_info.libs = ["fribidi"] self.cpp_info.includedirs.append(os.path.join("include", "fribidi")) if not self.options.shared: - self.cpp_info.defines.append("FRIBIDI_STATIC") + if Version(self.version) >= "1.0.10": + self.cpp_info.defines.append("FRIBIDI_LIB_STATIC") + else: + self.cpp_info.defines.append("FRIBIDI_STATIC") + +def fix_msvc_libname(conanfile, remove_lib_prefix=True): + """remove lib prefix & change extension to .lib""" + from conan.tools.files import rename + from conan.tools.microsoft import is_msvc + import glob + if not is_msvc(conanfile): + return + libdirs = getattr(conanfile.cpp.package, "libdirs") + for libdir in libdirs: + for ext in [".dll.a", ".dll.lib", ".a"]: + full_folder = os.path.join(conanfile.package_folder, libdir) + for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")): + libname = os.path.basename(filepath)[0:-len(ext)] + if remove_lib_prefix and libname[0:3] == "lib": + libname = libname[3:] + rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib")) diff --git a/recipes/fribidi/all/patches/0001-meson-no-tests-bin.patch b/recipes/fribidi/all/patches/1.0.9-0001-meson-no-tests-bin.patch similarity index 100% rename from recipes/fribidi/all/patches/0001-meson-no-tests-bin.patch rename to recipes/fribidi/all/patches/1.0.9-0001-meson-no-tests-bin.patch diff --git a/recipes/fribidi/all/test_package/CMakeLists.txt b/recipes/fribidi/all/test_package/CMakeLists.txt index c82738960e61d..7afbb0e9ea3b3 100644 --- a/recipes/fribidi/all/test_package/CMakeLists.txt +++ b/recipes/fribidi/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 3.0) -project(test_package C) +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +find_package(fribidi REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE fribidi::fribidi) diff --git a/recipes/fribidi/all/test_package/conanfile.py b/recipes/fribidi/all/test_package/conanfile.py index 89e0715e386f2..d120a992c06a6 100644 --- a/recipes/fribidi/all/test_package/conanfile.py +++ b/recipes/fribidi/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +20,6 @@ def build(self): cmake.build() def test(self): - if tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fribidi/all/test_v1_package/CMakeLists.txt b/recipes/fribidi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e0e1750238bcb --- /dev/null +++ b/recipes/fribidi/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fribidi REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE fribidi::fribidi) diff --git a/recipes/fribidi/all/test_v1_package/conanfile.py b/recipes/fribidi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/fribidi/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fribidi/config.yml b/recipes/fribidi/config.yml index 529891ecefeac..1a912a9e71c6e 100644 --- a/recipes/fribidi/config.yml +++ b/recipes/fribidi/config.yml @@ -1,3 +1,7 @@ versions: + "1.0.12": + folder: all + "1.0.10": + folder: all "1.0.9": folder: all diff --git a/recipes/frozen/all/conandata.yml b/recipes/frozen/all/conandata.yml index ab87ab3792120..4d9b977925cb2 100644 --- a/recipes/frozen/all/conandata.yml +++ b/recipes/frozen/all/conandata.yml @@ -1,7 +1,10 @@ sources: + "1.1.1": + url: "https://github.com/serge-sans-paille/frozen/archive/1.1.1.tar.gz" + sha256: "f7c7075750e8fceeac081e9ef01944f221b36d9725beac8681cbd2838d26be45" + "1.0.1": + url: "https://github.com/serge-sans-paille/frozen/archive/1.0.1.tar.gz" + sha256: "29ab5de4eb6bebfb803cd4bd33e324777488fb035116dab1aea27f9118809d0d" "1.0.0": - url: https://github.com/serge-sans-paille/frozen/archive/1.0.0.tar.gz - sha256: 590440d45dd53c6150b47df86071bba5128055e823ccc8715b363f75fc531269 - "1.0.1": - url: https://github.com/serge-sans-paille/frozen/archive/1.0.1.tar.gz - sha256: 29ab5de4eb6bebfb803cd4bd33e324777488fb035116dab1aea27f9118809d0d + url: "https://github.com/serge-sans-paille/frozen/archive/1.0.0.tar.gz" + sha256: "590440d45dd53c6150b47df86071bba5128055e823ccc8715b363f75fc531269" diff --git a/recipes/frozen/all/conanfile.py b/recipes/frozen/all/conanfile.py index 17ac78e40e9cd..e1444fa2a4c65 100644 --- a/recipes/frozen/all/conanfile.py +++ b/recipes/frozen/all/conanfile.py @@ -1,6 +1,13 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.50.0" + class FrozenConan(ConanFile): name = "frozen" @@ -9,39 +16,52 @@ class FrozenConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" license = "Apache-2.0" topics = ("gperf", "constexpr", "header-only") + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - settings = "compiler" - _source_subfolder = "source_subfolder" - - def configure(self): - minimal_cpp_standard = "14" - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, minimal_cpp_standard) - minimal_version = { + + @property + def _min_cppstd(self): + return "14" + + @property + def _minimum_compilers_version(self): + return { "gcc": "5", "clang": "3.4", "apple-clang": "10", - "Visual Studio": "14" + "Visual Studio": "14", + "msvc": "190", } - compiler = str(self.settings.compiler) - if compiler not in minimal_version: - self.output.warn( - "%s recipe lacks information about the %s compiler standard version support" % (self.name, compiler)) - self.output.warn( - "%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) - return - version = tools.Version(self.settings.compiler.version) - if version < minimal_version[compiler]: - raise ConanInvalidConfiguration("%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._minimum_compilers_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.", + ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + copy(self, "*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "frozen") + self.cpp_info.set_property("cmake_target_name", "frozen::frozen") + self.cpp_info.set_property("cmake_target_aliases", ["frozen::frozen-headers"]) + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/frozen/all/test_package/CMakeLists.txt b/recipes/frozen/all/test_package/CMakeLists.txt index 3300ff7750277..bf59d5df3d910 100644 --- a/recipes/frozen/all/test_package/CMakeLists.txt +++ b/recipes/frozen/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(frozen REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +target_link_libraries(${PROJECT_NAME} PRIVATE frozen::frozen) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/frozen/all/test_package/conanfile.py b/recipes/frozen/all/test_package/conanfile.py index 2cdb1d2b3578c..0a6bc68712d90 100644 --- a/recipes/frozen/all/test_package/conanfile.py +++ b/recipes/frozen/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join(self.build_folder, "bin", "test_package") - self.run(command=bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/frozen/all/test_v1_package/CMakeLists.txt b/recipes/frozen/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..ed695ba529434 --- /dev/null +++ b/recipes/frozen/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(frozen REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE frozen::frozen) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/frozen/all/test_v1_package/conanfile.py b/recipes/frozen/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/frozen/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/frozen/config.yml b/recipes/frozen/config.yml index 5e61e3082c4f0..9234b604d8ed1 100644 --- a/recipes/frozen/config.yml +++ b/recipes/frozen/config.yml @@ -1,5 +1,7 @@ versions: - "1.0.0": + "1.1.1": folder: all "1.0.1": folder: all + "1.0.0": + folder: all diff --git a/recipes/frugally-deep/all/conandata.yml b/recipes/frugally-deep/all/conandata.yml index 68ed00b739cb9..5db89f0f8f389 100644 --- a/recipes/frugally-deep/all/conandata.yml +++ b/recipes/frugally-deep/all/conandata.yml @@ -1,4 +1,16 @@ sources: + "0.15.19-p0": + url: "https://github.com/Dobiasd/frugally-deep/archive/v0.15.19-p0.tar.gz" + sha256: "acaba428ae19ef8d57a53b3767373cd96770c190dd57909e52d2759be89ac942" + "0.15.18-p0": + url: "https://github.com/Dobiasd/frugally-deep/archive/v0.15.18-p0.tar.gz" + sha256: "b721bd7b2fa842a1a10f00008e079c057fab7a5cfc4c394d64238ee59ad7e189" + "0.15.16-p0": + url: "https://github.com/Dobiasd/frugally-deep/archive/v0.15.16-p0.tar.gz" + sha256: "778b8cf0da847239a2ad21c611331b231831c6c175154c68ca30dd87489336a5" + "0.15.13-p0": + url: "https://github.com/Dobiasd/frugally-deep/archive/v0.15.13-p0.tar.gz" + sha256: "ca18c7b8dc0df3a36dba3c2578df35592e61ff51e5bbaa1c1ed3e6c529e14075" "0.15.1-p0": url: "https://github.com/Dobiasd/frugally-deep/archive/v0.15.1-p0.tar.gz" sha256: "ab15cb540a8ddeffa56cd8235bfdf709f5d6b3b2543d9ec83658c5d9bad02f18" diff --git a/recipes/frugally-deep/all/conanfile.py b/recipes/frugally-deep/all/conanfile.py index bb5ba90376abe..2588afa778f5b 100644 --- a/recipes/frugally-deep/all/conanfile.py +++ b/recipes/frugally-deep/all/conanfile.py @@ -1,9 +1,8 @@ -import os - from conans import ConanFile, tools from conans.errors import ConanInvalidConfiguration +import os -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.43.0" class FrugallyDeepConan(ConanFile): @@ -29,8 +28,13 @@ def _compilers_minimum_version(self): "apple-clang": "9", } + def requirements(self): + self.requires("eigen/3.4.0") + self.requires("functionalplus/0.2.18-p0") + self.requires("nlohmann_json/3.10.5") + def validate(self): - if self.settings.compiler.cppstd: + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, 14) def lazy_lt_semver(v1, v2): @@ -45,27 +49,21 @@ def lazy_lt_semver(v1, v2): elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): raise ConanInvalidConfiguration("frugally-deep requires C++14, which your compiler does not support.") - def requirements(self): - self.requires("eigen/3.3.9") - self.requires("functionalplus/0.2.13-p0") - self.requires("nlohmann_json/3.9.1") - def package_id(self): self.info.header_only() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("frugally-deep-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "frugally-deep" - self.cpp_info.names["cmake_find_package_multi"] = "frugally-deep" - self.cpp_info.components["fdeep"].names["cmake_find_package"] = "fdeep" - self.cpp_info.components["fdeep"].names["cmake_find_package_multi"] = "fdeep" + self.cpp_info.set_property("cmake_file_name", "frugally-deep") + self.cpp_info.set_property("cmake_target_name", "frugally-deep::fdeep") + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed self.cpp_info.components["fdeep"].requires = ["eigen::eigen", "functionalplus::functionalplus", "nlohmann_json::nlohmann_json"] diff --git a/recipes/frugally-deep/all/test_package/conanfile.py b/recipes/frugally-deep/all/test_package/conanfile.py index a9f777f7680ff..38f4483872d47 100644 --- a/recipes/frugally-deep/all/test_package/conanfile.py +++ b/recipes/frugally-deep/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/frugally-deep/config.yml b/recipes/frugally-deep/config.yml index 015a22b5d91e1..5b45f70613267 100644 --- a/recipes/frugally-deep/config.yml +++ b/recipes/frugally-deep/config.yml @@ -1,3 +1,11 @@ versions: + "0.15.19-p0": + folder: all + "0.15.18-p0": + folder: all + "0.15.16-p0": + folder: all + "0.15.13-p0": + folder: all "0.15.1-p0": folder: all diff --git a/recipes/ftjam/all/conandata.yml b/recipes/ftjam/all/conandata.yml index e20c51ea2ee4b..11d1d96f36866 100644 --- a/recipes/ftjam/all/conandata.yml +++ b/recipes/ftjam/all/conandata.yml @@ -8,3 +8,5 @@ patches: base_path: "source_subfolder" - patch_file: "patches/0002-msvc-mingw-fix-makefile.patch" base_path: "source_subfolder" + - patch_file: "patches/0003-missing-includes.patch" + base_path: "source_subfolder" diff --git a/recipes/ftjam/all/conanfile.py b/recipes/ftjam/all/conanfile.py index 69c0da7e9d81a..3a86cd556cb4a 100644 --- a/recipes/ftjam/all/conanfile.py +++ b/recipes/ftjam/all/conanfile.py @@ -2,6 +2,8 @@ from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.33.0" + class FtjamConan(ConanFile): name = "ftjam" @@ -20,29 +22,39 @@ def _source_subfolder(self): return "source_subfolder" def configure(self): - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("ftjam does not work, built with Visual Studio") del self.settings.compiler.libcxx del self.settings.compiler.cppstd - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("ftjam-{}".format(self.version), self._source_subfolder) + def validate(self): + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("ftjam doesn't build with Visual Studio yet") + if hasattr(self, "settings_build") and tools.cross_building(self): + raise ConanInvalidConfiguration("ftjam can't be cross-built") + + def package_id(self): + del self.info.settings.compiler + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def build_requirements(self): - if tools.os_info.is_windows and "CONAN_BASH_PATH" not in os.environ and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") if self.settings.compiler == "Visual Studio": self.build_requires("automake/1.16.2") if self.settings.os != "Windows": - self.build_requires("bison/3.5.3") + self.build_requires("bison/3.7.1") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) tools.replace_in_file(os.path.join(self._source_subfolder, "jamgram.c"), "\n#line", "\n//#line") - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) def _configure_autotools(self): if self._autotools: @@ -55,47 +67,38 @@ def _configure_autotools(self): return self._autotools def build(self): - if self.settings.build_type != "Release": - raise ConanInvalidConfiguration("This build_type is disabled in order to diminish the number of builds") - if self.settings.compiler == "Visual Studio": - if self.settings.compiler.runtime != "MT": - raise ConanInvalidConfiguration("This runtime is disabled in order to diminish the number of builds") - - # toolset name of the system building ftjam - jam_toolset = self._jam_toolset(self.settings.os, self.settings.compiler) - autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - autotools.libs = [] - env = autotools.vars self._patch_sources() with tools.chdir(self._source_subfolder): - if self.settings.compiler == "Visual Studio": - autotools = AutoToolsBuildEnvironment(self) + if self.settings.os == "Windows": + # toolset name of the system building ftjam + jam_toolset = self._jam_toolset(self.settings.os, self.settings.compiler) + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) autotools.libs = [] + env = autotools.vars with tools.environment_append(env): - with tools.vcvars(self.settings): - self.run("nmake -f builds/win32-visualc.mk JAM_TOOLSET={}".format(jam_toolset)) - else: - if self.settings.os == "Windows": - with tools.environment_append(env): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self.settings): + self.run("nmake -f builds/win32-visualc.mk JAM_TOOLSET={}".format(jam_toolset)) + else: with tools.environment_append({"PATH": [os.getcwd()]}): autotools.make(args=["JAM_TOOLSET={}".format(jam_toolset), "-f", "builds/win32-gcc.mk"]) - else: - autotools = self._configure_autotools() - autotools.make() + else: + autotools = self._configure_autotools() + autotools.make() def package(self): txt = tools.load(os.path.join(self._source_subfolder, "jam.c")) license_txt = txt[:txt.find("*/")+3] tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), license_txt) - if self.settings.compiler == "Visual Studio": - pass - else: - if self.settings.os == "Windows": - self.copy("*.exe", src=os.path.join(self._source_subfolder, "bin.nt"), dst=os.path.join(self.package_folder, "bin")) + if self.settings.os == "Windows": + if self.settings.compiler == "Visual Studio": + pass else: - with tools.chdir(self._source_subfolder): - autotools = self._configure_autotools() - autotools.install() + self.copy("*.exe", src=os.path.join(self._source_subfolder, "bin.nt"), dst=os.path.join(self.package_folder, "bin")) + else: + with tools.chdir(self._source_subfolder): + autotools = self._configure_autotools() + autotools.install() def _jam_toolset(self, os, compiler): if compiler == "Visual Studio": @@ -106,10 +109,6 @@ def _jam_toolset(self, os, compiler): return "MINGW" return None - def package_id(self): - del self.info.settings.build_type - del self.info.settings.compiler - def package_info(self): jam_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(jam_path)) @@ -119,7 +118,7 @@ def package_info(self): if self.settings.os == "Windows": jam_bin += ".exe" self.output.info("Setting JAM environment variable: {}".format(jam_bin)) - self.env_info.JAM.append(jam_bin) + self.env_info.JAM = jam_bin # toolset of the system using ftjam jam_toolset = self._jam_toolset(self.settings.os, self.settings.compiler) diff --git a/recipes/ftjam/all/patches/0003-missing-includes.patch b/recipes/ftjam/all/patches/0003-missing-includes.patch new file mode 100644 index 0000000000000..b84deefc435b2 --- /dev/null +++ b/recipes/ftjam/all/patches/0003-missing-includes.patch @@ -0,0 +1,26 @@ +--- a/execunix.c ++++ b/execunix.c +@@ -60,6 +60,8 @@ + # define wait my_wait + static int my_wait( int *status ); + # endif ++# else ++# include + # endif + + static int intr = 0; +--- a/make1.c ++++ b/make1.c +@@ -62,6 +62,12 @@ + # include "command.h" + # include "execcmd.h" + ++# ifdef _MSC_VER ++# include ++# else ++# include ++# endif ++ + static void make1a( TARGET *t, TARGET *parent ); + static void make1b( TARGET *t ); + static void make1c( TARGET *t ); diff --git a/recipes/ftjam/all/test_package/conanfile.py b/recipes/ftjam/all/test_package/conanfile.py index 9bfff3bf200ec..da7d45af31ef5 100644 --- a/recipes/ftjam/all/test_package/conanfile.py +++ b/recipes/ftjam/all/test_package/conanfile.py @@ -6,12 +6,16 @@ class TestPackage(ConanFile): settings = "os", "arch", "compiler", "build_type" + def build_requirements(self): + if hasattr(self, "settings_build"): + self.build_requires(str(self.requires["ftjam"])) + def build(self): for f in ("header.h", "main.c", "source.c", "Jamfile"): shutil.copy(os.path.join(self.source_folder, f), os.path.join(self.build_folder, f)) - if not tools.cross_building(self.settings): - assert os.path.isfile(os.environ["JAM"]) + if not tools.cross_building(self): + assert os.path.isfile(tools.get_env("JAM")) vars = AutoToolsBuildEnvironment(self).vars vars["CCFLAGS"] = vars["CFLAGS"] @@ -19,9 +23,9 @@ def build(self): vars["LINKFLAGS"] = vars["LDFLAGS"] vars["LINKLIBS"] = vars["LIBS"] with tools.environment_append(vars): - self.run("{} -d7".format(os.environ["JAM"]), run_environment=True) + self.run("{} -d7".format(tools.get_env("JAM")), run_environment=True) def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join(".", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/ftxui/all/CMakeLists.txt b/recipes/ftxui/all/CMakeLists.txt new file mode 100644 index 0000000000000..26553983b8de0 --- /dev/null +++ b/recipes/ftxui/all/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.11) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +add_subdirectory(source_subfolder) diff --git a/recipes/ftxui/all/conandata.yml b/recipes/ftxui/all/conandata.yml new file mode 100644 index 0000000000000..84aba68ff064c --- /dev/null +++ b/recipes/ftxui/all/conandata.yml @@ -0,0 +1,16 @@ +sources: + "3.0.0": + url: "https://github.com/ArthurSonzogni/FTXUI/archive/refs/tags/v3.0.0.tar.gz" + sha256: "a8f2539ab95caafb21b0c534e8dfb0aeea4e658688797bb9e5539729d9258cc1" + "2.0.0": + url: "https://github.com/ArthurSonzogni/FTXUI/archive/refs/tags/v2.0.0.tar.gz" + sha256: "d891695ef22176f0c09f8261a37af9ad5b262dd670a81e6b83661a23abc2c54f" +patches: + "3.0.0": + - patch_file: "patches/0002-install-dll.patch" + base_path: "source_subfolder" + "2.0.0": + - patch_file: "patches/0001-lib-prefix.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-install-dll.patch" + base_path: "source_subfolder" diff --git a/recipes/ftxui/all/conanfile.py b/recipes/ftxui/all/conanfile.py new file mode 100644 index 0000000000000..ab985f7b93858 --- /dev/null +++ b/recipes/ftxui/all/conanfile.py @@ -0,0 +1,105 @@ +import os +import functools + +from conan.tools.microsoft import is_msvc, msvc_runtime_flag +import conan.tools.files +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.43.0" + + +class FTXUIConan(ConanFile): + name = "ftxui" + description = "C++ Functional Terminal User Interface." + license = "MIT" + topics = ("ncurses", "terminal", "screen", "tui") + homepage = "https://github.com/ArthurSonzogni/FTXUI" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + compiler = self.settings.compiler + version = tools.Version(self.settings.compiler.version) + if compiler == 'gcc' and version < '8': + raise ConanInvalidConfiguration("gcc 8 required") + if compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "17") + if is_msvc(self) and self.options.shared and "MT" in msvc_runtime_flag(self): + raise ConanInvalidConfiguration("shared with static runtime not supported") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["FTXUI_BUILD_DOCS"] = False + cmake.definitions["FTXUI_BUILD_EXAMPLES"] = False + cmake.configure() + return cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + conan.tools.files.patch(self, **patch) + + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "ftxui") + + self.cpp_info.components["ftxui-dom"].set_property("cmake_target_name", "ftxui::dom") + self.cpp_info.components["ftxui-dom"].libs = ["ftxui-dom"] + self.cpp_info.components["ftxui-dom"].requires = ["ftxui-screen"] + + self.cpp_info.components["ftxui-screen"].set_property("cmake_target_name", "ftxui::screen") + self.cpp_info.components["ftxui-screen"].libs = ["ftxui-screen"] + + self.cpp_info.components["ftxui-component"].set_property("cmake_target_name", "ftxui::component") + self.cpp_info.components["ftxui-component"].libs = ["ftxui-component"] + self.cpp_info.components["ftxui-component"].requires = ["ftxui-dom"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["ftxui-component"].system_libs.append("pthread") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["ftxui-dom"].names["cmake_find_package"] = "dom" + self.cpp_info.components["ftxui-dom"].names["cmake_find_package_multi"] = "dom" + self.cpp_info.components["ftxui-screen"].names["cmake_find_package"] = "screen" + self.cpp_info.components["ftxui-screen"].names["cmake_find_package_multi"] = "screen" + self.cpp_info.components["ftxui-component"].names["cmake_find_package"] = "component" + self.cpp_info.components["ftxui-component"].names["cmake_find_package_multi"] = "component" diff --git a/recipes/ftxui/all/patches/0001-lib-prefix.patch b/recipes/ftxui/all/patches/0001-lib-prefix.patch new file mode 100644 index 0000000000000..ea9742245acd9 --- /dev/null +++ b/recipes/ftxui/all/patches/0001-lib-prefix.patch @@ -0,0 +1,23 @@ +From 71fdd3961c1311319709b976bf9065b1bb010800 Mon Sep 17 00:00:00 2001 +From: ericLemanissier +Date: Fri, 18 Feb 2022 14:58:28 +0100 +Subject: [PATCH] Don't override PREFIX target property + +PREFIX is by default "lib", which most of the libraries use. +this changes makes the library files libftxui-foo.a +as ArthurSonzogni/FTXUI#140 intended originally +--- + cmake/ftxui_set_options.cmake | 2 +- + 2 files changed, 8 insertions(+), 4 deletions(-) + +diff --git a/cmake/ftxui_set_options.cmake b/cmake/ftxui_set_options.cmake +index 9021cbcc..46e806c7 100644 +--- a/cmake/ftxui_set_options.cmake ++++ b/cmake/ftxui_set_options.cmake +@@ -1,5 +1,5 @@ + function(ftxui_set_options library) +- set_target_properties(${library} PROPERTIES PREFIX "ftxui-") ++ set_target_properties(${library} PROPERTIES OUTPUT_NAME "ftxui-${library}") + + + target_include_directories(${library} diff --git a/recipes/ftxui/all/patches/0002-install-dll.patch b/recipes/ftxui/all/patches/0002-install-dll.patch new file mode 100644 index 0000000000000..2b6bf21726448 --- /dev/null +++ b/recipes/ftxui/all/patches/0002-install-dll.patch @@ -0,0 +1,10 @@ +--- a/cmake/ftxui_install.cmake ++++ b/cmake/ftxui_install.cmake +@@ -1,6 +1,7 @@ + include(GNUInstallDirs) + install(TARGETS screen dom component + EXPORT ftxui-export ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) diff --git a/recipes/ftxui/all/test_package/CMakeLists.txt b/recipes/ftxui/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f4c3b1f828f16 --- /dev/null +++ b/recipes/ftxui/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ftxui REQUIRED CONFIG) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ftxui::dom ftxui::screen) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/ftxui/all/test_package/conanfile.py b/recipes/ftxui/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e788460ad0765 --- /dev/null +++ b/recipes/ftxui/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ftxui/all/test_package/test_package.cpp b/recipes/ftxui/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7b4065ab9bc13 --- /dev/null +++ b/recipes/ftxui/all/test_package/test_package.cpp @@ -0,0 +1,24 @@ +#include // for operator|, text, Element, hcenter, Fit, hbox, size, window, Elements, bold, dim, EQUAL, WIDTH +#include // for Screen +#include // for allocator, shared_ptr +#include // for string, to_string +#include // for move + +int main(int argc, char *argv[]) +{ + using namespace ftxui; + auto make_box = [](const std::string& title) { + return window(text(title) | hcenter | bold, text("content") | hcenter | dim); + }; + + Elements content; + for (int x = 3; x < 30; ++x) { + content.push_back(make_box(std::to_string(x)) | size(WIDTH, EQUAL, x)); + } + + auto document = hbox(std::move(content)); + auto screen = Screen::Create(Dimension::Fit(document)); + + return 0; +} + diff --git a/recipes/ftxui/config.yml b/recipes/ftxui/config.yml new file mode 100644 index 0000000000000..70df618778342 --- /dev/null +++ b/recipes/ftxui/config.yml @@ -0,0 +1,5 @@ +versions: + "3.0.0": + folder: all + "2.0.0": + folder: all diff --git a/recipes/function2/all/conandata.yml b/recipes/function2/all/conandata.yml index 9bdc4c56aae2d..4a8c1d45eb5f5 100644 --- a/recipes/function2/all/conandata.yml +++ b/recipes/function2/all/conandata.yml @@ -1,4 +1,13 @@ sources: + "4.2.2": + url: "https://github.com/Naios/function2/archive/refs/tags/4.2.2.tar.gz" + sha256: "f755cb79712dfb9ceefcf7f7ff3225f7c99d22a164dae109044dbfad55d7111e" + "4.2.1": + url: "https://github.com/Naios/function2/archive/4.2.1.tar.gz" + sha256: "dfaf12f6cc4dadc4fc7051af7ac57be220c823aaccfd2fecebcb45a0a03a6eb0" + "4.2.0": + url: "https://github.com/Naios/function2/archive/4.2.0.tar.gz" + sha256: "fd1194b236e55f695c3a0c17f2440d6965b800c9309d0d5937e0185bcfe7ae6e" "4.1.0": sha256: "C3AAEAF93BF90C0F4505A18F1094B51FE28881CE202C3BF78EC4EFB336C51981" url: "https://github.com/Naios/function2/archive/4.1.0.tar.gz" diff --git a/recipes/function2/all/conanfile.py b/recipes/function2/all/conanfile.py index 7dfb1cbbe3253..e29faac1dac09 100644 --- a/recipes/function2/all/conanfile.py +++ b/recipes/function2/all/conanfile.py @@ -1,7 +1,12 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.50.0" class Function2Conan(ConanFile): @@ -11,42 +16,53 @@ class Function2Conan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/Naios/function2" license = "BSL-1.0" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True @property - def _source_subfolder(self): - return "source_subfolder" - - def configure(self): - minimal_cpp_standard = "14" - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, minimal_cpp_standard) - minimal_version = { + def _min_cppstd(self): + return 14 + + @property + def _compiler_minimal_version(self): + return { "gcc": "5", "clang": "3.4", "apple-clang": "10", "Visual Studio": "14" } + + def layout(self): + basic_layout(self) + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) compiler = str(self.settings.compiler) - if compiler not in minimal_version: + if compiler not in self._compiler_minimal_version: self.output.warn( "%s recipe lacks information about the %s compiler standard version support" % (self.name, compiler)) self.output.warn( - "%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) + "%s requires a compiler that supports at least C++%s" % (self.name, self._min_cppstd)) return - version = tools.Version(self.settings.compiler.version) - if version < minimal_version[compiler]: - raise ConanInvalidConfiguration("%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) + version = Version(self.settings.compiler.version) + if version < self._compiler_minimal_version[compiler]: + raise ConanInvalidConfiguration("%s requires a compiler that supports at least C++%s" % (self.name, self._min_cppstd)) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "function2-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*.hpp", dst=os.path.join("include", "function2"), src=os.path.join(self._source_subfolder, "include", "function2")) + copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", os.path.join(self.source_folder, "include"), os.path.join(self.package_folder, "include")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/function2/all/test_package/CMakeLists.txt b/recipes/function2/all/test_package/CMakeLists.txt index 6cce16a47a8f1..85a339e09a26c 100644 --- a/recipes/function2/all/test_package/CMakeLists.txt +++ b/recipes/function2/all/test_package/CMakeLists.txt @@ -1,16 +1,11 @@ -cmake_minimum_required(VERSION 3.0.2) -project(test_package) +cmake_minimum_required(VERSION 3.10) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package CXX) -add_executable(${PROJECT_NAME} test_package.cpp) +find_package(function2 REQUIRED CONFIG) -set_target_properties( - ${PROJECT_NAME} PROPERTIES +add_executable(${PROJECT_NAME} test_package.cpp) - CXX_STANDARD 14 - CXX_STANDARD_REQUIRED ON -) +target_link_libraries(${PROJECT_NAME} PRIVATE function2::function2) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/function2/all/test_package/conanfile.py b/recipes/function2/all/test_package/conanfile.py index bd7165a553cf4..b4a4c16800289 100644 --- a/recipes/function2/all/test_package/conanfile.py +++ b/recipes/function2/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/function2/all/test_v1_package/CMakeLists.txt b/recipes/function2/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..5816ff152bbfe --- /dev/null +++ b/recipes/function2/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.10) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(function2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) + +target_link_libraries(${PROJECT_NAME} PRIVATE function2::function2) + +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/function2/all/test_v1_package/conanfile.py b/recipes/function2/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..8037a9296cc42 --- /dev/null +++ b/recipes/function2/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/function2/config.yml b/recipes/function2/config.yml index 702888c159594..955cd0773fc58 100644 --- a/recipes/function2/config.yml +++ b/recipes/function2/config.yml @@ -1,3 +1,9 @@ versions: + "4.2.2": + folder: all + "4.2.1": + folder: all + "4.2.0": + folder: all "4.1.0": folder: all diff --git a/recipes/functionalplus/all/conandata.yml b/recipes/functionalplus/all/conandata.yml index b253c385e219b..ca33489d4d5de 100644 --- a/recipes/functionalplus/all/conandata.yml +++ b/recipes/functionalplus/all/conandata.yml @@ -1,4 +1,19 @@ sources: + "0.2.18-p0": + url: "https://github.com/Dobiasd/FunctionalPlus/archive/v0.2.18-p0.tar.gz" + sha256: "ffc63fc86f89a205accafa85c35790eda307adf5f1d6d51bb7ceb5c5e21e013b" + "0.2.17-p0": + url: "https://github.com/Dobiasd/FunctionalPlus/archive/v0.2.17-p0.tar.gz" + sha256: "c41514b24a81ad47a8f98b3ef3a3bd3fe8109085f7965e9678386b08721e3620" + "0.2.16": + url: "https://github.com/Dobiasd/FunctionalPlus/archive/v0.2.16-p0.tar.gz" + sha256: "6026e64260afbd6941aaf19559d6e5dc51cbb3e045ef8d8e158d96bcd8651ed6" + "0.2.15": + url: "https://github.com/Dobiasd/FunctionalPlus/archive/v0.2.15-p0.tar.gz" + sha256: "4c76104ec8f6da5e66ed768380bdf128e0ba01725056c40a3c1b850cf4b441ad" + "0.2.14-p0": + url: "https://github.com/Dobiasd/FunctionalPlus/archive/refs/tags/v0.2.14-p0.tar.gz" + sha256: "68a0e715aa18d2fe558fede06d65ec125959895efe4d0ef21b102037c9864ba1" "0.2.13-p0": url: "https://github.com/Dobiasd/FunctionalPlus/archive/v0.2.13-p0.tar.gz" sha256: "62f61ce6500859f0d77306b1644b5c6992287688de38e170b17b8a66b2448b54" diff --git a/recipes/functionalplus/all/conanfile.py b/recipes/functionalplus/all/conanfile.py index 32ef7f1521c9e..e87d42e53ba37 100644 --- a/recipes/functionalplus/all/conanfile.py +++ b/recipes/functionalplus/all/conanfile.py @@ -1,62 +1,82 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.50.0" + class FunctionalPlusConan(ConanFile): name = "functionalplus" description = "Functional Programming Library for C++." license = "BSL-1.0" - topics = ("conan", "functionalplus", "fplus", "functional programming") + topics = ("functionalplus", "fplus", "functional programming") homepage = "https://github.com/Dobiasd/FunctionalPlus" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - @property def _compilers_minimum_version(self): return { "gcc": "4.9", "Visual Studio": "14", + "msvc": "190", "clang": "3.7", "apple-clang": "9", } - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 14) + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 14) - def lazy_lt_semver(v1, v2): + def loose_lt_semver(v1, v2): lv1 = [int(v) for v in v1.split(".")] lv2 = [int(v) for v in v2.split(".")] min_length = min(len(lv1), len(lv2)) return lv1[:min_length] < lv2[:min_length] minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if not minimum_version: - self.output.warn("functionalplus requires C++14. Your compiler is unknown. Assuming it supports C++14.") - elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): raise ConanInvalidConfiguration("functionalplus requires C++14, which your compiler does not support.") - def package_id(self): - self.info.header_only() + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("FunctionalPlus-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "FunctionalPlus") + self.cpp_info.set_property("cmake_target_name", "FunctionalPlus::fplus") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["fplus"].system_libs = ["pthread"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.names["cmake_find_package"] = "FunctionalPlus" self.cpp_info.names["cmake_find_package_multi"] = "FunctionalPlus" self.cpp_info.components["fplus"].names["cmake_find_package"] = "fplus" self.cpp_info.components["fplus"].names["cmake_find_package_multi"] = "fplus" - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["fplus"].system_libs = ["pthread"] + self.cpp_info.components["fplus"].set_property("cmake_target_name", "FunctionalPlus::fplus") + self.cpp_info.components["fplus"].bindirs = [] + self.cpp_info.components["fplus"].frameworkdirs = [] + self.cpp_info.components["fplus"].libdirs = [] + self.cpp_info.components["fplus"].resdirs = [] diff --git a/recipes/functionalplus/all/test_package/CMakeLists.txt b/recipes/functionalplus/all/test_package/CMakeLists.txt index 5f94e4be5de9a..ee3481206b2db 100644 --- a/recipes/functionalplus/all/test_package/CMakeLists.txt +++ b/recipes/functionalplus/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(FunctionalPlus REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} FunctionalPlus::fplus) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +target_link_libraries(${PROJECT_NAME} PRIVATE FunctionalPlus::fplus) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/functionalplus/all/test_package/conanfile.py b/recipes/functionalplus/all/test_package/conanfile.py index a9f777f7680ff..d120a992c06a6 100644 --- a/recipes/functionalplus/all/test_package/conanfile.py +++ b/recipes/functionalplus/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/functionalplus/all/test_v1_package/CMakeLists.txt b/recipes/functionalplus/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d0b01f5d3cd02 --- /dev/null +++ b/recipes/functionalplus/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(FunctionalPlus REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE FunctionalPlus::fplus) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/functionalplus/all/test_v1_package/conanfile.py b/recipes/functionalplus/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/functionalplus/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/functionalplus/config.yml b/recipes/functionalplus/config.yml index d3f6aa7efad32..42d00dd1c341a 100644 --- a/recipes/functionalplus/config.yml +++ b/recipes/functionalplus/config.yml @@ -1,3 +1,13 @@ versions: + "0.2.18-p0": + folder: all + "0.2.17-p0": + folder: all + "0.2.16": + folder: all + "0.2.15": + folder: all + "0.2.14-p0": + folder: all "0.2.13-p0": folder: all diff --git a/recipes/hiredis/all/CMakeLists.txt b/recipes/functions-framework-cpp/all/CMakeLists.txt similarity index 100% rename from recipes/hiredis/all/CMakeLists.txt rename to recipes/functions-framework-cpp/all/CMakeLists.txt diff --git a/recipes/functions-framework-cpp/all/conandata.yml b/recipes/functions-framework-cpp/all/conandata.yml new file mode 100644 index 0000000000000..c01327cda0d09 --- /dev/null +++ b/recipes/functions-framework-cpp/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.0.0": + url: "https://github.com/GoogleCloudPlatform/functions-framework-cpp/archive/refs/tags/v1.0.0.tar.gz" + sha256: "005f2fbe3b8be9f6f0bf7a4a5d218a23b0f62d854a5e84c56872dd3a4d2820f7" +patches: + "1.0.0": + - patch_file: "patches/0001-dont-skip-namelink.patch" + base_path: "source_subfolder" diff --git a/recipes/functions-framework-cpp/all/conanfile.py b/recipes/functions-framework-cpp/all/conanfile.py new file mode 100644 index 0000000000000..96389274771c4 --- /dev/null +++ b/recipes/functions-framework-cpp/all/conanfile.py @@ -0,0 +1,154 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.43.0" + + +class FunctionsFrameworkCppConan(ConanFile): + name = "functions-framework-cpp" + description = "An open source FaaS (Functions as a Service) framework" + license = "Apache-2.0" + topics = ("google", "cloud", "functions-as-a-service", "faas-framework") + homepage = "https://github.com/GoogleCloudPlatform/functions-framework-cpp" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "cmake", "cmake_find_package_multi", "cmake_find_package" + short_paths = True + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("abseil/20211102.0") + self.requires("boost/1.78.0") + self.requires("nlohmann_json/3.10.5") + + @property + def _compilers_minimum_version(self): + return { + "gcc": "9", + "Visual Studio": "15.7", + "clang": "7", + "apple-clang": "11", + } + + @property + def _required_boost_components(self): + return ["program_options"] + + def validate(self): + miss_boost_required_comp = \ + any(getattr(self.options["boost"], + "without_{}".format(boost_comp), + True) for boost_comp in self._required_boost_components) + if self.options["boost"].header_only or miss_boost_required_comp: + raise ConanInvalidConfiguration( + "{0} requires non-header-only boost with these components: {1}".format( + self.name, ", ".join(self._required_boost_components) + ) + ) + + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 17) + + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + "{} requires C++17, which your compiler does not support.".format(self.name) + ) + + if self._is_msvc and self.options.shared: + raise ConanInvalidConfiguration("Fails to build for Visual Studio as a DLL") + + if hasattr(self, "settings_build") and tools.cross_building(self): + raise ConanInvalidConfiguration( + "Recipe not prepared for cross-building (yet)" + ) + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + destination=self._source_subfolder, + strip_root=True + ) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_TESTING"] = False + self._cmake.definitions["FUNCTIONS_FRAMEWORK_CPP_TEST_EXAMPLES"] = False + + self._cmake.configure() + return self._cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "functions_framework_cpp") + self.cpp_info.set_property("cmake_target_name", "functions-framework-cpp::framework") + self.cpp_info.set_property("pkg_config_name", "functions_framework_cpp") + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["framework"].libs = ["functions_framework_cpp"] + self.cpp_info.components["framework"].requires = [ + "abseil::absl_time", + "boost::headers", + "boost::program_options", + "nlohmann_json::nlohmann_json", + ] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["framework"].system_libs.append("pthread") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.filenames["cmake_find_package"] = "functions_framework_cpp" + self.cpp_info.filenames["cmake_find_package_multi"] = "functions_framework_cpp" + self.cpp_info.names["pkg_config"] = "functions_framework_cpp" + self.cpp_info.components["framework"].set_property("cmake_target_name", "functions-framework-cpp::framework") + self.cpp_info.components["framework"].set_property("pkg_config_name", "functions_framework_cpp") diff --git a/recipes/functions-framework-cpp/all/patches/0001-dont-skip-namelink.patch b/recipes/functions-framework-cpp/all/patches/0001-dont-skip-namelink.patch new file mode 100644 index 0000000000000..eeaf81a81461c --- /dev/null +++ b/recipes/functions-framework-cpp/all/patches/0001-dont-skip-namelink.patch @@ -0,0 +1,10 @@ +--- a/google/cloud/functions/CMakeLists.txt ++++ b/google/cloud/functions/CMakeLists.txt +@@ -132,7 +132,6 @@ install( + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT runtime +- NAMELINK_SKIP + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT development + NAMELINK_COMPONENT development diff --git a/recipes/functions-framework-cpp/all/test_package/CMakeLists.txt b/recipes/functions-framework-cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d4b4a2212f334 --- /dev/null +++ b/recipes/functions-framework-cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(functions_framework_cpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} functions-framework-cpp::framework) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/functions-framework-cpp/all/test_package/conanfile.py b/recipes/functions-framework-cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/functions-framework-cpp/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/functions-framework-cpp/all/test_package/test_package.cpp b/recipes/functions-framework-cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..d3e5b1cd6c630 --- /dev/null +++ b/recipes/functions-framework-cpp/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main(int, char*[]) { + std::cout << google::cloud::functions::VersionString() << "\n"; + return 0; +} diff --git a/recipes/functions-framework-cpp/config.yml b/recipes/functions-framework-cpp/config.yml new file mode 100644 index 0000000000000..c7f13630776fb --- /dev/null +++ b/recipes/functions-framework-cpp/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.0": + folder: "all" diff --git a/recipes/fusepp/all/CMakeLists.txt b/recipes/fusepp/all/CMakeLists.txt new file mode 100644 index 0000000000000..661f0d421c545 --- /dev/null +++ b/recipes/fusepp/all/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.4) +project(cmake_wrapper) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(KEEP_RPATHS) + +set(SOURCE_SUBFOLDER ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) + +file(GLOB_RECURSE INCLUDE_FILES "${SOURCE_SUBFOLDER}/Fuse*.h" "${SOURCE_SUBFOLDER}/Fuse.cpp") + +add_library(fusepp ${SOURCE_SUBFOLDER}/Fuse.cpp) + +set_target_properties(fusepp PROPERTIES PUBLIC_HEADER "${INCLUDE_FILES}") +install(TARGETS fusepp + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/fusepp/all/conandata.yml b/recipes/fusepp/all/conandata.yml new file mode 100644 index 0000000000000..f0eeba285988d --- /dev/null +++ b/recipes/fusepp/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20210820": + url: "https://github.com/jachappell/Fusepp/archive/4a457accb1ae4686b0ccc2805a317bc29a5cddf8.zip" + sha256: "2ea6379f0d76b9a8e7e805d7c6941863a7254653633e2f63a551c2ef6c4605e8" diff --git a/recipes/fusepp/all/conanfile.py b/recipes/fusepp/all/conanfile.py new file mode 100644 index 0000000000000..f23b9daa7e874 --- /dev/null +++ b/recipes/fusepp/all/conanfile.py @@ -0,0 +1,78 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + + +class FuseppConan(ConanFile): + name = "fusepp" + description = "A simple C++ wrapper for the FUSE filesystem." + license = "MIT" + topics = ("fuse", "fusepp", "wrapper", "filesystem") + homepage = "https://github.com/jachappell/Fusepp" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True + } + exports_sources = "CMakeLists.txt" + + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "11") + if self.settings.compiler == "gcc": + if tools.Version(self.settings.compiler.version) < "6": + raise ConanInvalidConfiguration("gcc < 6 is unsupported") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + def requirements(self): + self.requires("libfuse/3.10.5") + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure() + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["fusepp"] + # TODO: Remove after Conan 2.0 + self.cpp_info.names["cmake_find_package"] = "fusepp" + self.cpp_info.names["cmake_find_package_multi"] = "fusepp" + + self.cpp_info.set_property("cmake_file_name", "fusepp") + self.cpp_info.set_property("cmake_target_name", "fusepp") diff --git a/recipes/fusepp/all/test_package/CMakeLists.txt b/recipes/fusepp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..00168e2e07000 --- /dev/null +++ b/recipes/fusepp/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fusepp CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} example.cpp) +target_link_libraries(${PROJECT_NAME} fusepp::fusepp) diff --git a/recipes/fusepp/all/test_package/conanfile.py b/recipes/fusepp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..46d9d6bbaf311 --- /dev/null +++ b/recipes/fusepp/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run("%s --version" % bin_path, run_environment=True) diff --git a/recipes/fusepp/all/test_package/example.cpp b/recipes/fusepp/all/test_package/example.cpp new file mode 100644 index 0000000000000..1c551d1dc8302 --- /dev/null +++ b/recipes/fusepp/all/test_package/example.cpp @@ -0,0 +1,9 @@ +#include "Fuse.h" +#include "Fuse-impl.h" + +class MyFilesystem : public Fusepp::Fuse { +}; + +int main() { + MyFilesystem(); +} diff --git a/recipes/fusepp/config.yml b/recipes/fusepp/config.yml new file mode 100644 index 0000000000000..312f834c7fcdf --- /dev/null +++ b/recipes/fusepp/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210820": + folder: all diff --git a/recipes/fxdiv/all/conanfile.py b/recipes/fxdiv/all/conanfile.py index ad825b7b97165..30d0773e14a46 100644 --- a/recipes/fxdiv/all/conanfile.py +++ b/recipes/fxdiv/all/conanfile.py @@ -1,31 +1,41 @@ -from conans import ConanFile, tools -import glob +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.50.0" + class FxdivConan(ConanFile): name = "fxdiv" description = "C99/C++ header-only library for division via fixed-point " \ "multiplication by inverse." license = "MIT" - topics = ("conan", "fxdiv", "integer-division") + topics = ("fxdiv", "integer-division") homepage = "https://github.com/Maratyszcza/FXdiv" url = "https://github.com/conan-io/conan-center-index" - + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("FXdiv-*")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/fxdiv/all/test_package/CMakeLists.txt b/recipes/fxdiv/all/test_package/CMakeLists.txt index fd126a732c403..4681666d5bdaf 100644 --- a/recipes/fxdiv/all/test_package/CMakeLists.txt +++ b/recipes/fxdiv/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(fxdiv REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) +target_link_libraries(${PROJECT_NAME} PRIVATE fxdiv::fxdiv) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/fxdiv/all/test_package/conanfile.py b/recipes/fxdiv/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/fxdiv/all/test_package/conanfile.py +++ b/recipes/fxdiv/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fxdiv/all/test_v1_package/CMakeLists.txt b/recipes/fxdiv/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b7f38eca2a76d --- /dev/null +++ b/recipes/fxdiv/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(fxdiv REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE fxdiv::fxdiv) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/fxdiv/all/test_v1_package/conanfile.py b/recipes/fxdiv/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/fxdiv/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/g3log/all/CMakeLists.txt b/recipes/g3log/all/CMakeLists.txt deleted file mode 100644 index 5c72216ed01c4..0000000000000 --- a/recipes/g3log/all/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.1.0) - -project(cmake_wrapper) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/g3log/all/conandata.yml b/recipes/g3log/all/conandata.yml index c7c03b270de4d..140d23e5b67d1 100644 --- a/recipes/g3log/all/conandata.yml +++ b/recipes/g3log/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.3.4": + url: "https://github.com/KjellKod/g3log/archive/refs/tags/1.3.4.tar.gz" + sha256: "2fe8815e5f5afec6b49bdfedfba1e86b8e58a5dc89fd97f4868fb7f3141aed19" "1.3.3": url: "https://github.com/KjellKod/g3log/archive/1.3.3.tar.gz" sha256: "d8cae14e1508490145d710f10178b2da9b86ce03fb2428a684fff35576fe5d5c" @@ -11,4 +14,3 @@ sources: patches: "1.3.2": - patch_file: "patches/0002-remove-explicit-stdlib-setting.patch" - base_path: "source_subfolder" diff --git a/recipes/g3log/all/conanfile.py b/recipes/g3log/all/conanfile.py index ca8cc461541b7..298068a223096 100644 --- a/recipes/g3log/all/conanfile.py +++ b/recipes/g3log/all/conanfile.py @@ -1,8 +1,14 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir, save +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os -from os import path -from conans import ConanFile, CMake, tools -from conans.tools import Version -from conans.errors import ConanInvalidConfiguration +import textwrap + +required_conan_version = ">=1.50.0" class G3logConan(ConanFile): @@ -10,87 +16,140 @@ class G3logConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/KjellKod/g3log" license = "The Unlicense" - description = """G3log is an asynchronous, "crash safe", logger that is easy to use with default logging sinks or you can add your own.""" - topics = ("conan", "g3log", "log") - settings = "os", "compiler", "build_type", "arch" + description = ( + "G3log is an asynchronous, \"crash safe\", logger that is easy to use " + "with default logging sinks or you can add your own." + ) + topics = ("g3log", "log") + + settings = "os", "arch", "compiler", "build_type" options = { - "shared": [True, False], - "fPIC": [True, False], - "use_dynamic_logging_levels": [True, False], - "change_debug_to_dbug": [True, False], - "use_dynamic_max_message_size": [True, False], - "log_full_filename": [True, False], - "enable_fatal_signal_handling": [True, False], - "enable_vectored_exception_handling": [True, False], - "debug_break_at_fatal_signal": [True, False] + "shared": [True, False], + "fPIC": [True, False], + "use_dynamic_logging_levels": [True, False], + "change_debug_to_dbug": [True, False], + "use_dynamic_max_message_size": [True, False], + "log_full_filename": [True, False], + "enable_fatal_signal_handling": [True, False], + "enable_vectored_exception_handling": [True, False], + "debug_break_at_fatal_signal": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "use_dynamic_logging_levels": False, + "change_debug_to_dbug": False, + "use_dynamic_max_message_size": True, + "log_full_filename": False, + "enable_fatal_signal_handling": True, + "enable_vectored_exception_handling": True, + "debug_break_at_fatal_signal": False, } - default_options = {key: False for key in options.keys()} - default_options["use_dynamic_max_message_size"] = True - default_options["enable_fatal_signal_handling"] = True - default_options["enable_vectored_exception_handling"] = True - default_options["fPIC"] = True - generators = "cmake" - exports_sources = ["CMakeLists.txt", "patches/*"] - _source_subfolder = "source_subfolder" - - def _has_support_for_cpp14(self): - supported_compilers = [("apple-clang", 5.1), ("clang", 3.4), ("gcc", 6.1), ("Visual Studio", 15.0)] - compiler, version = self.settings.compiler, Version(self.settings.compiler.version) - return any(compiler == sc[0] and version >= sc[1] for sc in supported_compilers) - def configure(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "14") - if not self._has_support_for_cpp14(): - raise ConanInvalidConfiguration("g3log requires C++14 or higher support standard." - " {} {} is not supported." - .format(self.settings.compiler, - self.settings.compiler.version)) + @property + def _compilers_minimum_version(self): + return { + "gcc": "6.1", + "clang": "3.4", + "apple-clang": "5.1", + "Visual Studio": "15", + } - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - dir_postfix = self.conan_data["sources"][self.version]["url"].split("/")[-1][:-7] - os.rename("g3log-{}".format(dir_postfix), self._source_subfolder) + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if self.settings.compiler != "Visual Studio": + if not is_msvc(self): del self.options.enable_vectored_exception_handling del self.options.debug_break_at_fatal_signal - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions['VERSION'] = self.version - cmake.definitions["G3_SHARED_LIB"] = self.options.shared - cmake.definitions["USE_DYNAMIC_LOGGING_LEVELS"] = self.options.use_dynamic_logging_levels - cmake.definitions["CHANGE_G3LOG_DEBUG_TO_DBUG"] = self.options.change_debug_to_dbug - cmake.definitions["USE_G3_DYNAMIC_MAX_MESSAGE_SIZE"] = self.options.use_dynamic_max_message_size - cmake.definitions["G3_LOG_FULL_FILENAME"] = self.options.log_full_filename - cmake.definitions["ENABLE_FATAL_SIGNALHANDLING"] = self.options.enable_fatal_signal_handling - if self.settings.compiler == "Visual Studio": - cmake.definitions["ENABLE_VECTORED_EXCEPTIONHANDLING"] = self.options.enable_vectored_exception_handling - cmake.definitions["DEBUG_BREAK_AT_FATAL_SIGNAL"] = self.options.debug_break_at_fatal_signal - cmake.definitions["ADD_FATAL_EXAMPLE"] = "OFF" - cmake.definitions["ADD_G3LOG_PERFORMANCE"] = "OFF" - cmake.definitions["ADD_G3LOG_UNIT_TEST"] = "OFF" - cmake.configure() - return cmake + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, "14") + + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and loose_lt_semver(str(self.info.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + "{} requires C++14, which your compiler does not support.".format(self.name) + ) + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["VERSION"] = self.version + tc.variables["G3_SHARED_LIB"] = self.options.shared + tc.variables["USE_DYNAMIC_LOGGING_LEVELS"] = self.options.use_dynamic_logging_levels + tc.variables["CHANGE_G3LOG_DEBUG_TO_DBUG"] = self.options.change_debug_to_dbug + tc.variables["USE_G3_DYNAMIC_MAX_MESSAGE_SIZE"] = self.options.use_dynamic_max_message_size + tc.variables["G3_LOG_FULL_FILENAME"] = self.options.log_full_filename + tc.variables["ENABLE_FATAL_SIGNALHANDLING"] = self.options.enable_fatal_signal_handling + if is_msvc(self): + tc.variables["ENABLE_VECTORED_EXCEPTIONHANDLING"] = self.options.enable_vectored_exception_handling + tc.variables["DEBUG_BREAK_AT_FATAL_SIGNAL"] = self.options.debug_break_at_fatal_signal + tc.variables["ADD_FATAL_EXAMPLE"] = "OFF" + tc.variables["ADD_G3LOG_PERFORMANCE"] = "OFF" + tc.variables["ADD_G3LOG_UNIT_TEST"] = "OFF" + tc.generate() def build(self): - if "patches" in self.conan_data and self.version in self.conan_data["patches"]: - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once legacy generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"g3log": "g3log::g3log"}, + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.libs = ["g3logger"] - if str(self.settings.os) in ["Linux", "Android"]: - self.cpp_info.system_libs.append('pthread') + self.cpp_info.set_property("cmake_file_name", "g3log") + self.cpp_info.set_property("cmake_target_name", "g3log") + self.cpp_info.libs = ["g3logger" if Version(self.version) < "1.3.4" else "g3log"] + if self.settings.os in ["Linux", "Android"]: + self.cpp_info.system_libs.append("pthread") + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/g3log/all/test_package/CMakeLists.txt b/recipes/g3log/all/test_package/CMakeLists.txt index c9f8bcd46cb58..6bcbaa08a0d71 100644 --- a/recipes/g3log/all/test_package/CMakeLists.txt +++ b/recipes/g3log/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1.2) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_EXTENSIONS OFF) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +find_package(g3log REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} CONAN_PKG::g3log) +target_link_libraries(${PROJECT_NAME} PRIVATE g3log) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/g3log/all/test_package/conanfile.py b/recipes/g3log/all/test_package/conanfile.py index 4903f1a7e8fa0..3a8c6c5442b33 100644 --- a/recipes/g3log/all/test_package/conanfile.py +++ b/recipes/g3log/all/test_package/conanfile.py @@ -1,9 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/g3log/all/test_v1_package/CMakeLists.txt b/recipes/g3log/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a12ddaa2ea948 --- /dev/null +++ b/recipes/g3log/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(g3log REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE g3log) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/g3log/all/test_v1_package/conanfile.py b/recipes/g3log/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/g3log/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/g3log/config.yml b/recipes/g3log/config.yml index 2dad1116b158d..c34ce10c74ca3 100644 --- a/recipes/g3log/config.yml +++ b/recipes/g3log/config.yml @@ -1,8 +1,9 @@ versions: + "1.3.4": + folder: all "1.3.3": folder: all "1.3.2-86": folder: all "1.3.2": folder: all - diff --git a/recipes/gainput/all/conandata.yml b/recipes/gainput/all/conandata.yml new file mode 100644 index 0000000000000..663b4be81a94a --- /dev/null +++ b/recipes/gainput/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.0.0": + url: "https://github.com/jkuhlmann/gainput/archive/refs/tags/v1.0.0.tar.gz" + sha256: "e1444f2093d0b8c1a0a127668e957b91517177aa1ece292efefacc127a56bd96" +patches: + "1.0.0": + - patch_file: "patches/0001-fix-cmake.patch" diff --git a/recipes/gainput/all/conanfile.py b/recipes/gainput/all/conanfile.py new file mode 100644 index 0000000000000..609bad1913a9e --- /dev/null +++ b/recipes/gainput/all/conanfile.py @@ -0,0 +1,85 @@ +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get +import os + +required_conan_version = ">=1.52.0" + + +class GainputConan(ConanFile): + name = "gainput" + description = "Cross-platform C++ input library supporting gamepads, keyboard, mouse, touch." + license = "MIT" + topics = ("gainput", "input", "keyboard", "gamepad", "mouse", "multi-touch") + homepage = "https://gainput.johanneskuhlmann.de" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.settings.os in ["Linux", "FreeBSD"]: + self.requires("xorg/system") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["GAINPUT_SAMPLES"] = False + tc.variables["GAINPUT_TESTS"] = False + tc.variables["GAINPUT_BUILD_SHARED"] = self.options.shared + tc.variables["GAINPUT_BUILD_STATIC"] = not self.options.shared + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + suffix = "{}{}".format("" if self.options.shared else "static", + "-d" if self.settings.build_type == "Debug" else "") + self.cpp_info.libs = ["gainput" + suffix] + if self.settings.os == "Windows": + self.cpp_info.system_libs.extend(["xinput", "ws2_32"]) + elif self.settings.os == "Android": + self.cpp_info.system_libs.extend(["native_app_glue", "log", "android"]) + elif is_apple_os(self): + self.cpp_info.frameworks.extend(["CoreFoundation", "CoreGraphics", "Foundation", "IOKit", "GameController"]) + if self.settings.os == "iOS": + self.cpp_info.frameworks.extend(["UIKit", "CoreMotion"]) + else: + self.cpp_info.frameworks.append("AppKit") diff --git a/recipes/gainput/all/patches/0001-fix-cmake.patch b/recipes/gainput/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..39ae12ecf689f --- /dev/null +++ b/recipes/gainput/all/patches/0001-fix-cmake.patch @@ -0,0 +1,52 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,5 @@ + cmake_minimum_required(VERSION 2.8) ++project(gainput) + set(GAINPUT_MAJOR_VERSION 1) + set(GAINPUT_MINOR_VERSION 0) + set(GAINPUT_PATCH_VERSION 0) +@@ -9,7 +10,7 @@ option(GAINPUT_TESTS "Build Tests for Gainput" ON) + option(GAINPUT_BUILD_SHARED "BUILD_SHARED" ON) + option(GAINPUT_BUILD_STATIC "BUILD_STATIC" ON) + +-if(!WIN32) ++if(NOT WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra") + else() + set(XINPUT "Xinput9_1_0") +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -1,10 +1,8 @@ +-project(gainput) + message(STATUS "GAINPUT version ${GAINPUT_VERSION}") + + set(CMAKE_MACOSX_RPATH 1) + + if(CMAKE_COMPILER_IS_GNUCXX) +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -Wall -Wextra -pedantic -Wshadow -Wno-variadic-macros") + endif() + + include_directories (include/) +@@ -36,12 +34,11 @@ if (GAINPUT_BUILD_STATIC) + set(install_libs ${install_libs} gainputstatic) + endif (GAINPUT_BUILD_STATIC) + ++if(GAINPUT_BUILD_SHARED) + if(WIN32) + target_link_libraries(gainput ${XINPUT} ws2_32) +- target_link_libraries(gainputstatic ${XINPUT} ws2_32) + add_definitions(-DGAINPUT_LIB_DYNAMIC=1) + elseif(ANDROID) +- target_link_libraries(gainputstatic native_app_glue log android) + target_link_libraries(gainput native_app_glue log android) + elseif(APPLE) + find_library(FOUNDATION Foundation) +@@ -58,6 +55,7 @@ elseif(APPLE) + target_link_libraries(gainput ${APPKIT}) + endif() + endif() ++endif() + + # Library installation directory + if(NOT DEFINED CMAKE_INSTALL_LIBDIR) diff --git a/recipes/gainput/all/test_package/CMakeLists.txt b/recipes/gainput/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f0a0ee2f13583 --- /dev/null +++ b/recipes/gainput/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(gainput REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gainput::gainput) diff --git a/recipes/gainput/all/test_package/conanfile.py b/recipes/gainput/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/gainput/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gainput/all/test_package/test_package.cpp b/recipes/gainput/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..ca866c0b7fbf9 --- /dev/null +++ b/recipes/gainput/all/test_package/test_package.cpp @@ -0,0 +1,21 @@ +#include + +int main() { + enum Button + { + ButtonConfirm + }; + + gainput::InputManager manager; + manager.SetDisplaySize(800, 600); + const gainput::DeviceId keyboardId = manager.CreateDevice(); + const gainput::DeviceId padId = manager.CreateDevice(); + const gainput::DeviceId touchId = manager.CreateDevice(); + + gainput::InputMap map(manager); + map.MapBool(ButtonConfirm, keyboardId, gainput::KeyReturn); + map.MapBool(ButtonConfirm, padId, gainput::PadButtonA); + map.MapBool(ButtonConfirm, touchId, gainput::Touch0Down); + + return 0; +} diff --git a/recipes/gainput/all/test_v1_package/CMakeLists.txt b/recipes/gainput/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7e3274020b8ef --- /dev/null +++ b/recipes/gainput/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gainput REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gainput::gainput) diff --git a/recipes/gainput/all/test_v1_package/conanfile.py b/recipes/gainput/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/gainput/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gainput/config.yml b/recipes/gainput/config.yml new file mode 100644 index 0000000000000..40341aa3db6cd --- /dev/null +++ b/recipes/gainput/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.0": + folder: all diff --git a/recipes/gamenetworkingsockets/all/CMakeLists.txt b/recipes/gamenetworkingsockets/all/CMakeLists.txt new file mode 100644 index 0000000000000..7a80c0b2c26dc --- /dev/null +++ b/recipes/gamenetworkingsockets/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.11) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory("source_subfolder") diff --git a/recipes/gamenetworkingsockets/all/conandata.yml b/recipes/gamenetworkingsockets/all/conandata.yml new file mode 100644 index 0000000000000..882c3ee20c6d7 --- /dev/null +++ b/recipes/gamenetworkingsockets/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "1.3.0": + url: "https://github.com/ValveSoftware/GameNetworkingSockets/archive/refs/tags/v1.3.0.zip" + sha256: "22e409546babc449c44f492b253b547a2f5f11abe11a100686a10a990b5091cd" +patches: + "1.3.0": + - patch_file: "patches/001-disable-runtime-override.patch" + base_path: "source_subfolder" + - patch_file: "patches/002-either-static-or-shared.patch" + base_path: "source_subfolder" diff --git a/recipes/gamenetworkingsockets/all/conanfile.py b/recipes/gamenetworkingsockets/all/conanfile.py new file mode 100644 index 0000000000000..cb91ff14df39f --- /dev/null +++ b/recipes/gamenetworkingsockets/all/conanfile.py @@ -0,0 +1,126 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + + +class GameNetworkingSocketsConan(ConanFile): + name = "gamenetworkingsockets" + description = "GameNetworkingSockets is a basic transport layer for games." + topics = ("networking", "game-development") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/ValveSoftware/GameNetworkingSockets" + license = "BSD-3-Clause" + generators = "cmake", "pkg_config" + settings = "os", "arch", "compiler", "build_type" + exports_sources = ["CMakeLists.txt", "patches/**"] + + options = { + "shared": [True, False], + "fPIC": [True, False], + "encryption": ["openssl", "libsodium", "bcrypt"] + } + + default_options = { + "shared": False, + "fPIC": True, + "encryption": "openssl" + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + if self.options.encryption == "bcrypt" and self.settings.os != "Windows": + raise ConanInvalidConfiguration("bcrypt is only valid on Windows") + + def build_requirements(self): + self.build_requires("protobuf/3.17.1") + + def requirements(self): + self.requires("protobuf/3.17.1") + if self.options.encryption == "openssl": + self.requires("openssl/1.1.1l") + elif self.options.encryption == "libsodium": + self.requires("libsodium/1.0.18") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_STATIC"] = not self.options.shared + self._cmake.definitions["BUILD_SHARED"] = self.options.shared + self._cmake.definitions["GAMENETWORKINGSOCKETS_BUILD_EXAMPLES"] = False + self._cmake.definitions["GAMENETWORKINGSOCKETS_BUILD_TESTS"] = False + self._cmake.definitions["Protobuf_USE_STATIC_LIBS"] = not self.options["protobuf"].shared + crypto = {"openssl": "OpenSSL", "libsodium": "libsodium", "bcrypt": "BCrypt"} + self._cmake.definitions["USE_CRYPTO"] = crypto[str(self.options.encryption)] + crypto25519 = {"openssl": "OpenSSL", "libsodium": "libsodium", "bcrypt": "Reference"} + self._cmake.definitions["USE_CRYPTO25519"] = crypto25519[str(self.options.encryption)] + if self.options.encryption == "openssl": + self._cmake.definitions["OPENSSL_NEW_ENOUGH"] = True + self._cmake.definitions["OPENSSL_HAS_25519_RAW"] = True + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "GameNetworkingSockets" + self.cpp_info.names["cmake_find_package_multi"] = "GameNetworkingSockets" + self.cpp_info.names["pkg_config"] = "GameNetworkingSockets" + self.cpp_info.includedirs.append(os.path.join("include", "GameNetworkingSockets")) + if self.options.shared: + self.cpp_info.libs = ["GameNetworkingSockets"] + else: + self.cpp_info.libs = ["GameNetworkingSockets_s"] + self.cpp_info.defines = ["STEAMNETWORKINGSOCKETS_STATIC_LINK"] + + self.cpp_info.requires = ["protobuf::libprotobuf"] + if self.options.encryption == "openssl": + self.cpp_info.requires += ["openssl::crypto"] + elif self.options.encryption == "libsodium": + self.cpp_info.requires += ["libsodium::libsodium"] + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["pthread"] + elif self.settings.os == "Windows": + self.cpp_info.system_libs = ["ws2_32", "crypt32", "winmm"] + if self.options.encryption == "bcrypt": + self.cpp_info.system_libs += ["bcrypt"] + diff --git a/recipes/gamenetworkingsockets/all/patches/001-disable-runtime-override.patch b/recipes/gamenetworkingsockets/all/patches/001-disable-runtime-override.patch new file mode 100644 index 0000000000000..652aea2685bb8 --- /dev/null +++ b/recipes/gamenetworkingsockets/all/patches/001-disable-runtime-override.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/tmp/CMakeLists.txt +index 3471701..49efee3 100644 +--- a/CMakeLists.txt ++++ b/tmp/CMakeLists.txt +@@ -35,7 +35,7 @@ endif() + + include(FlagsMSVC) + set(MSVC_RUNTIME "dynamic") +-configure_msvc_runtime() ++# configure_msvc_runtime() + print_default_msvc_flags() + + add_definitions( -DVALVE_CRYPTO_ENABLE_25519 ) diff --git a/recipes/gamenetworkingsockets/all/patches/002-either-static-or-shared.patch b/recipes/gamenetworkingsockets/all/patches/002-either-static-or-shared.patch new file mode 100644 index 0000000000000..47b3eec1ee41e --- /dev/null +++ b/recipes/gamenetworkingsockets/all/patches/002-either-static-or-shared.patch @@ -0,0 +1,49 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 7040ab3..c75897e 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -282,28 +282,38 @@ macro(gamenetworkingsockets_common GNS_TARGET) + + endmacro() + ++if (BUILD_SHARED) + add_library(GameNetworkingSockets SHARED "") + add_library(GameNetworkingSockets::GameNetworkingSockets ALIAS GameNetworkingSockets) + add_library(GameNetworkingSockets::shared ALIAS GameNetworkingSockets) + gamenetworkingsockets_common(GameNetworkingSockets) + ++install( ++ TARGETS GameNetworkingSockets ++ EXPORT GameNetworkingSockets ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++) ++endif() ++ ++if (BUILD_STATIC) + add_library(GameNetworkingSockets_s STATIC "") + add_library(GameNetworkingSockets::GameNetworkingSockets_s ALIAS GameNetworkingSockets_s) + add_library(GameNetworkingSockets::static ALIAS GameNetworkingSockets_s) + target_compile_definitions(GameNetworkingSockets_s INTERFACE STEAMNETWORKINGSOCKETS_STATIC_LINK) + gamenetworkingsockets_common(GameNetworkingSockets_s) + +-# Install rules +- + install( +- TARGETS +- GameNetworkingSockets +- GameNetworkingSockets_s ++ TARGETS GameNetworkingSockets_s + EXPORT GameNetworkingSockets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +- ) ++) ++endif() ++ ++# Install rules + + install(DIRECTORY ../include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GameNetworkingSockets) + diff --git a/recipes/gamenetworkingsockets/all/test_package/CMakeLists.txt b/recipes/gamenetworkingsockets/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..cb6bc1b893324 --- /dev/null +++ b/recipes/gamenetworkingsockets/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(GameNetworkingSockets REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} GameNetworkingSockets::GameNetworkingSockets) diff --git a/recipes/gamenetworkingsockets/all/test_package/conanfile.py b/recipes/gamenetworkingsockets/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/gamenetworkingsockets/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gamenetworkingsockets/all/test_package/test_package.cpp b/recipes/gamenetworkingsockets/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..558f03d11e7d6 --- /dev/null +++ b/recipes/gamenetworkingsockets/all/test_package/test_package.cpp @@ -0,0 +1,55 @@ +#include +#include +#include + +#include +#include + +static FILE* g_fpLog = NULL; +static SteamNetworkingMicroseconds g_logTimeZero; + +static void DebugOutput(ESteamNetworkingSocketsDebugOutputType eType, char const* pszMsg) +{ + SteamNetworkingMicroseconds time = SteamNetworkingUtils()->GetLocalTimestamp() - g_logTimeZero; + if (g_fpLog) { + fprintf(g_fpLog, "%10.6f %s\n", time * 1e-6, pszMsg); + } + + if (eType <= k_ESteamNetworkingSocketsDebugOutputType_Msg) { + printf("%10.6f %s\n", time * 1e-6, pszMsg); + fflush(stdout); + } + + if (eType == k_ESteamNetworkingSocketsDebugOutputType_Bug) { + fflush(stdout); + fflush(stderr); + if (g_fpLog) { + fflush(g_fpLog); + } + + if (strstr(pszMsg, "SteamNetworkingGlobalLock held for")) { + return; + } + + assert(!"TEST FAILED"); + } +} + +int main() +{ + g_fpLog = stderr; + g_logTimeZero = SteamNetworkingUtils()->GetLocalTimestamp(); + + SteamNetworkingUtils()->SetDebugOutputFunction(k_ESteamNetworkingSocketsDebugOutputType_Debug, DebugOutput); + SteamNetworkingUtils()->SetDebugOutputFunction(k_ESteamNetworkingSocketsDebugOutputType_Verbose, DebugOutput); + SteamNetworkingUtils()->SetDebugOutputFunction(k_ESteamNetworkingSocketsDebugOutputType_Msg, DebugOutput); + + SteamDatagramErrMsg errMsg; + if (!GameNetworkingSockets_Init(NULL, errMsg)) { + fprintf(stderr, "GameNetworkingSockets_Init failed. %s", errMsg); + return 1; + } + + GameNetworkingSockets_Kill(); + return 0; +} diff --git a/recipes/gamenetworkingsockets/config.yml b/recipes/gamenetworkingsockets/config.yml new file mode 100644 index 0000000000000..426a0e4c79e9b --- /dev/null +++ b/recipes/gamenetworkingsockets/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3.0": + folder: all diff --git a/recipes/gamma/all/CMakeLists.txt b/recipes/gamma/all/CMakeLists.txt new file mode 100644 index 0000000000000..d7ab29edac81b --- /dev/null +++ b/recipes/gamma/all/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 3.8) +project(Gamma LANGUAGES CXX) + +option(GAMMA_AUDIO_IO "Provide Audio Class" ON) +option(GAMMA_SOUNDFILE "Provide SoundFile Class" ON) + +include(GNUInstallDirs) + +file(GLOB GAMMA_PUBLIC_HEADERS ${GAMMA_SRC_DIR}/Gamma/*.h) + +add_library(Gamma + ${GAMMA_SRC_DIR}/src/arr.cpp + ${GAMMA_SRC_DIR}/src/Conversion.cpp + ${GAMMA_SRC_DIR}/src/Domain.cpp + ${GAMMA_SRC_DIR}/src/DFT.cpp + ${GAMMA_SRC_DIR}/src/FFT_fftpack.cpp + ${GAMMA_SRC_DIR}/src/fftpack++1.cpp + ${GAMMA_SRC_DIR}/src/fftpack++2.cpp + ${GAMMA_SRC_DIR}/src/Print.cpp + ${GAMMA_SRC_DIR}/src/scl.cpp + ${GAMMA_SRC_DIR}/src/Recorder.cpp + ${GAMMA_SRC_DIR}/src/Scheduler.cpp + ${GAMMA_SRC_DIR}/src/Timer.cpp +) +target_include_directories(Gamma PUBLIC ${GAMMA_SRC_DIR}) +target_compile_features(Gamma PUBLIC cxx_std_14) +set_target_properties(Gamma PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + +find_library(LIBM NAMES m) +if(LIBM) + target_link_libraries(Gamma PRIVATE ${LIBM}) +endif() + +if(GAMMA_AUDIO_IO) + find_package(portaudio REQUIRED CONFIG) + target_link_libraries(Gamma PRIVATE portaudio::portaudio) + target_sources(Gamma PRIVATE ${GAMMA_SRC_DIR}/src/AudioIO.cpp) +else() + list(FILTER GAMMA_PUBLIC_HEADERS EXCLUDE REGEX ".*AudioIO\\.h$") +endif() + +if(GAMMA_SOUNDFILE) + find_package(SndFile REQUIRED CONFIG) + target_link_libraries(Gamma PRIVATE SndFile::sndfile) + target_sources(Gamma PRIVATE ${GAMMA_SRC_DIR}/src/SoundFile.cpp) + target_compile_definitions(Gamma PRIVATE GAM_USE_LIBSNDFILE) +else() + list(FILTER GAMMA_PUBLIC_HEADERS EXCLUDE REGEX ".*SoundFile\\.h$") +endif() + +install( + TARGETS Gamma + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +install(FILES ${GAMMA_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Gamma) diff --git a/recipes/gamma/all/conandata.yml b/recipes/gamma/all/conandata.yml new file mode 100644 index 0000000000000..4cabf0af40040 --- /dev/null +++ b/recipes/gamma/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20220221": + url: "https://github.com/LancePutnam/Gamma/archive/cd192cad292d78210b6ecd6202a7799c6ab976fc.tar.gz" + sha256: "96b70ce3bf876a7f71a3b698b2a2030240649b54ae57209d9851f9c3062b30a2" diff --git a/recipes/gamma/all/conanfile.py b/recipes/gamma/all/conanfile.py new file mode 100644 index 0000000000000..451083af4f13c --- /dev/null +++ b/recipes/gamma/all/conanfile.py @@ -0,0 +1,92 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.51.1" + + +class Gammaconan(ConanFile): + name = "gamma" + description = ( + "Gamma is a cross-platform, C++ library for doing generic synthesis " + "and filtering of signals." + ) + license = "MIT" + topics = ("signal-processing", "sound", "audio") + homepage = "https://github.com/LancePutnam/Gamma" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "audio_io": [True, False], + "soundfile": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "audio_io": False, + "soundfile": True, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.soundfile: + self.requires("libsndfile/1.0.31") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 14) + + if self.info.options.audio_io: + # TODO: add audio_io support once portaudio added to CCI + raise ConanInvalidConfiguration( + "gamma:audio_io=True requires portaudio, not available in conan-center yet" + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["GAMMA_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["GAMMA_AUDIO_IO"] = self.options.audio_io + tc.variables["GAMMA_SOUNDFILE"] = self.options.soundfile + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["Gamma"] + if not self.options.shared and self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/gamma/all/test_package/CMakeLists.txt b/recipes/gamma/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..98f55fe7ea287 --- /dev/null +++ b/recipes/gamma/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(gamma REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gamma::gamma) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/gamma/all/test_package/conanfile.py b/recipes/gamma/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/gamma/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gamma/all/test_package/test_package.cpp b/recipes/gamma/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..217ea581adcd5 --- /dev/null +++ b/recipes/gamma/all/test_package/test_package.cpp @@ -0,0 +1,85 @@ +#include +#include +#include + +#include +#include + +using namespace gam; +using namespace gam::gen; + +int main(){ + + const unsigned size = 32; + float table[size]; + //unsigned indices[size]; + + for(unsigned i=0; i>1]; + featureI = arr::maxima(peaks, table, size); + printf("Maxima (%d):\n", featureI); + for(unsigned long i=0; i + +int main() +{ + puts("Hello, World!\n"); + return 0; +} + diff --git a/recipes/gcc/all/test_package/hello.cpp b/recipes/gcc/all/test_package/hello.cpp new file mode 100644 index 0000000000000..e59b7b15826e3 --- /dev/null +++ b/recipes/gcc/all/test_package/hello.cpp @@ -0,0 +1,8 @@ +#include + +int main() +{ + std::cout << "Hello, World!\n"; + return 0; +} + diff --git a/recipes/gcc/config.yml b/recipes/gcc/config.yml new file mode 100644 index 0000000000000..204a7032b0bc4 --- /dev/null +++ b/recipes/gcc/config.yml @@ -0,0 +1,5 @@ +versions: + "10.2.0": + folder: all + "12.2.0": + folder: all diff --git a/recipes/gcem/all/conandata.yml b/recipes/gcem/all/conandata.yml index b9fad5164c1e7..58f1cc5b754a9 100644 --- a/recipes/gcem/all/conandata.yml +++ b/recipes/gcem/all/conandata.yml @@ -1,7 +1,13 @@ sources: + "1.16.0": + url: "https://github.com/kthohr/gcem/archive/v1.16.0.tar.gz" + sha256: "119c742b9371c0adc7d9cd710c3cbc575459a98fb63f6be4c636215dcf8404ce" + "1.14.1": + url: "https://github.com/kthohr/gcem/archive/v1.14.1.tar.gz" + sha256: "fd0860e89f47eeddf5a2280dd6fb3f9b021ce36fe8798116b3f703fa0e01409d" "1.13.1": url: "https://github.com/kthohr/gcem/archive/v1.13.1.tar.gz" sha256: "69a1973f146a4a5e584193af062359f50bd5b948c4175d58ea2622e1c066b99b" "1.12.0": - sha256: debbd6bf125126fb92499026b37aab70ed08df819baf9cf3948a2623fd5fa165 - url: https://github.com/kthohr/gcem/archive/v1.12.0.tar.gz + url: "https://github.com/kthohr/gcem/archive/v1.12.0.tar.gz" + sha256: "debbd6bf125126fb92499026b37aab70ed08df819baf9cf3948a2623fd5fa165" diff --git a/recipes/gcem/all/conanfile.py b/recipes/gcem/all/conanfile.py index 57dfd6ff8b467..90bc15dd9edc5 100644 --- a/recipes/gcem/all/conanfile.py +++ b/recipes/gcem/all/conanfile.py @@ -1,5 +1,11 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get, save +from conan.tools.layout import basic_layout import os +import textwrap + +required_conan_version = ">=1.50.0" class GcemConan(ConanFile): @@ -7,23 +13,60 @@ class GcemConan(ConanFile): description = "A C++ compile-time math library using generalized " \ "constant expressions." license = "Apache-2.0" - topics = ("conan", "gcem", "math", "header-only") + topics = ("gcem", "math", "header-only") homepage = "https://github.com/kthohr/gcem" url = "https://github.com/conan-io/conan-center-index" no_copy_source = True + settings = "os", "arch", "compiler", "build_type", - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy(pattern="*", dst="include", - src=os.path.join(self._source_subfolder, "include")) - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) - def package_id(self): - self.info.header_only() + # TODO: to remove in conan v2 + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"gcem": "gcem::gcem"}, + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "gcem") + self.cpp_info.set_property("cmake_target_name", "gcem") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + # TODO: to remove in conan v2 + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/gcem/all/test_package/CMakeLists.txt b/recipes/gcem/all/test_package/CMakeLists.txt index 1baaed448aea7..434ba12e4a1c5 100644 --- a/recipes/gcem/all/test_package/CMakeLists.txt +++ b/recipes/gcem/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(gcem REQUIRED CONFIG) add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) -target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE gcem) +target_compile_features(${CMAKE_PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/gcem/all/test_package/conanfile.py b/recipes/gcem/all/test_package/conanfile.py index b03af749d7f01..0a6bc68712d90 100644 --- a/recipes/gcem/all/test_package/conanfile.py +++ b/recipes/gcem/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,5 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin","test_package"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gcem/all/test_v1_package/CMakeLists.txt b/recipes/gcem/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/gcem/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/gcem/all/test_v1_package/conanfile.py b/recipes/gcem/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..071ca3ed857af --- /dev/null +++ b/recipes/gcem/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type", + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin","test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gcem/config.yml b/recipes/gcem/config.yml index 2cd8b2011a151..cc18649bfe195 100644 --- a/recipes/gcem/config.yml +++ b/recipes/gcem/config.yml @@ -1,4 +1,8 @@ versions: + "1.16.0": + folder: all + "1.14.1": + folder: all "1.13.1": folder: all "1.12.0": diff --git a/recipes/gdal/all/conandata.yml b/recipes/gdal/all/conandata.yml deleted file mode 100644 index 207c532d7441b..0000000000000 --- a/recipes/gdal/all/conandata.yml +++ /dev/null @@ -1,68 +0,0 @@ -sources: - "3.1.0": - url: "https://github.com/OSGeo/gdal/releases/download/v3.1.0/gdal-3.1.0.tar.gz" - sha256: "6793ddb2b1ca042494d938ac82c71d06b9125bbb00c9bb9414a7c5e3a707c639" - "3.1.2": - url: "https://github.com/OSGeo/gdal/releases/download/v3.1.2/gdal-3.1.2.tar.gz" - sha256: "39713b8af4e4dcd5e0d2d84a7f94660da59bb710cca80bcac07e719435add6dc" - "3.1.4": - url: "https://github.com/OSGeo/gdal/releases/download/v3.1.4/gdal-3.1.4.tar.gz" - sha256: "5f09ea6ca797e296b608d261e08e18ffa43a12fa28d460ae139d2a026ee2b0c0" - "3.2.1": - url: "https://github.com/OSGeo/gdal/releases/download/v3.2.1/gdal-3.2.1.tar.gz" - sha256: "43d40ba940e3927e38f9e98062ff62f9fa993ceade82f26f16fab7e73edb572e" -patches: - "3.1.0": - - patch_file: "patches/3.1.x/fix-autotools-3.1.0.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-nmake-common.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-nmake-opt-3.1.0.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-import-dll-msvc.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/ogrflatgeobuflayer-stdexcept.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/makefile-mitigate-long-line.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-include-jsonc.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-include-xerces-3.1.0.patch" - base_path: "source_subfolder" - "3.1.2": - - patch_file: "patches/3.1.x/fix-autotools-3.1.0.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-nmake-common.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-nmake-opt-3.1.2.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-import-dll-msvc.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-include-jsonc.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-include-xerces-3.1.2.patch" - base_path: "source_subfolder" - "3.1.4": - - patch_file: "patches/3.1.x/fix-autotools-3.1.4.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-nmake-common.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-nmake-opt-3.1.2.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-import-dll-msvc.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-include-jsonc.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.1.x/fix-include-xerces-3.1.2.patch" - base_path: "source_subfolder" - "3.2.1": - - patch_file: "patches/3.2.x/fix-autotools.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.2.x/fix-nmake.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.2.x/fix-include-jsonc.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.2.x/fix-include-xerces.patch" - base_path: "source_subfolder" - - patch_file: "patches/3.2.x/fix-ogrelasticlayer-gcc-less-5.patch" - base_path: "source_subfolder" diff --git a/recipes/gdal/all/conanfile.py b/recipes/gdal/all/conanfile.py deleted file mode 100644 index 8abe90b4e2d6e..0000000000000 --- a/recipes/gdal/all/conanfile.py +++ /dev/null @@ -1,812 +0,0 @@ -from contextlib import contextmanager -import os - -from conans import ConanFile, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration - -required_conan_version = ">=1.33.0" - - -class GdalConan(ConanFile): - name = "gdal" - description = "GDAL is an open source X/MIT licensed translator library " \ - "for raster and vector geospatial data formats." - license = "MIT" - topics = ("conan", "gdal", "osgeo", "geospatial", "raster", "vector") - homepage = "https://github.com/OSGeo/gdal" - url = "https://github.com/conan-io/conan-center-index" - exports_sources = "patches/**" - generators = "pkg_config" - settings = "os", "arch", "compiler", "build_type" - options = { - "shared": [True, False], - "fPIC": [True, False], - "simd_intrinsics": [None, "sse", "ssse3", "avx"], - "threadsafe": [True, False], - "with_zlib": [True, False], - "with_libdeflate": [True, False], - "with_libiconv": [True, False], - "with_zstd": [True, False], - "with_pg": [True, False], - # "with_libgrass": [True, False], - "with_cfitsio": [True, False], - "with_pcraster": [True, False], - "with_png": [True, False], - "with_dds": [True, False], - "with_gta": [True, False], - "with_pcidsk": [True, False], - "with_jpeg": [None, "libjpeg", "libjpeg-turbo"], - "with_charls": [True, False], - "with_gif": [True, False], - # "with_ogdi": [True, False], - # "with_sosi": [True, False], - "with_mongocxx": [True, False], - "with_hdf4": [True, False], - "with_hdf5": [True, False], - "with_kea": [True, False], - "with_netcdf": [True, False], - "with_jasper": [True, False], - "with_openjpeg": [True, False], - # "with_fgdb": [True, False], - "with_gnm": [True, False], - "with_mysql": [None, "libmysqlclient", "mariadb-connector-c"], - "with_xerces": [True, False], - "with_expat": [True, False], - "with_libkml": [True, False], - "with_odbc": [True, False], - # "with_dods_root": [True, False], - "with_curl": [True, False], - "with_xml2": [True, False], - # "with_spatialite": [True, False], - "with_sqlite3": [True, False], - # "with_rasterlite2": [True, False], - "with_pcre": [True, False], - # "with_epsilon": [True, False], - "with_webp": [True, False], - "with_geos": [True, False], - # "with_sfcgal": [True, False], - "with_qhull": [True, False], - "with_opencl": [True, False], - "with_freexl": [True, False], - "without_pam": [True, False], - "with_poppler": [True, False], - "with_podofo": [True, False], - # "with_pdfium": [True, False], - # "with_tiledb": [True, False], - # "with_rasdaman": [True, False], - # "with_armadillo": [True, False], - "with_cryptopp": [True, False], - "with_crypto": [True, False], - "without_lerc": [True, False], - "with_null": [True, False], - "with_exr": [True, False], - "with_heif": [True, False], - } - default_options = { - "shared": False, - "fPIC": True, - "simd_intrinsics": "sse", - "threadsafe": True, - "with_zlib": True, - "with_libdeflate": True, - "with_libiconv": True, - "with_zstd": False, - "with_pg": False, - # "with_libgrass": False, - "with_cfitsio": False, - "with_pcraster": True, - "with_png": True, - "with_dds": False, - "with_gta": False, - "with_pcidsk": True, - "with_jpeg": "libjpeg", - "with_charls": False, - "with_gif": True, - # "with_ogdi": False, - # "with_sosi": False, - "with_mongocxx": False, - "with_hdf4": False, - "with_hdf5": False, - "with_kea": False, - "with_netcdf": False, - "with_jasper": False, - "with_openjpeg": False, - # "with_fgdb": False, - "with_gnm": True, - "with_mysql": None, - "with_xerces": False, - "with_expat": False, - "with_libkml": False, - "with_odbc": False, - # "with_dods_root": False, - "with_curl": False, - "with_xml2": False, - # "with_spatialite": False, - "with_sqlite3": True, - # "with_rasterlite2": False, - "with_pcre": False, - # "with_epsilon": False, - "with_webp": False, - "with_geos": True, - # "with_sfcgal": False, - "with_qhull": True, - "with_opencl": False, - "with_freexl": False, - "without_pam": False, - "with_poppler": False, - "with_podofo": False, - # "with_pdfium": False, - # "with_tiledb": False, - # "with_rasdaman": False, - # "with_armadillo": False, - "with_cryptopp": False, - "with_crypto": False, - "without_lerc": False, - "with_null": False, - "with_exr": False, - "with_heif": False, - } - - _autotools= None - _nmake_args = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _has_with_exr_option(self): - return tools.Version(self.version) >= "3.1.0" - - @property - def _has_with_libdeflate_option(self): - return tools.Version(self.version) >= "3.2.0" - - @property - def _has_with_heif_option(self): - return tools.Version(self.version) >= "3.2.0" - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - # if tools.Version(self.version) < "3.0.0": - # del self.options.with_tiledb - if not self._has_with_exr_option: - del self.options.with_exr - if not self._has_with_libdeflate_option: - del self.options.with_libdeflate - if not self._has_with_heif_option: - del self.options.with_heif - - def configure(self): - if self.options.shared: - del self.options.fPIC - if self.settings.compiler.cppstd: - min_cppstd = 14 if self.options.with_charls else 11 - tools.check_min_cppstd(self, min_cppstd) - if self.settings.arch not in ["x86", "x86_64"]: - del self.options.simd_intrinsics - if self.options.without_lerc: - del self.options.with_zstd - # if self.options.with_spatialite: - # del self.options.with_sqlite3 - if not self.options.get_safe("with_sqlite3", False): - del self.options.with_pcre - if self.settings.compiler == "Visual Studio": - del self.options.threadsafe - del self.options.with_null - del self.options.with_zlib # zlib and png are always used in nmake build, - del self.options.with_png # and it's not trivial to fix - else: - del self.options.with_libiconv - if self.options.get_safe("with_libdeflate") and not self.options.get_safe("with_zlib", True): - raise ConanInvalidConfiguration("gdal:with_libdeflate=True requires gdal:with_zlib=True") - self._strict_options_requirements() - - # FIXME: Visual Studio 2015 & 2017 are supported but CI of CCI lacks several Win SDK components - if tools.Version(self.version) >= "3.2.0" and self.settings.compiler == "Visual Studio" and \ - tools.Version(self.settings.compiler.version) < "16": - raise ConanInvalidConfiguration("Visual Studio < 2019 not yet supported in this recipe for gdal {}".format(self.version)) - - def _strict_options_requirements(self): - if self.options.with_qhull: - self.options["qhull"].reentrant = False - - def requirements(self): - self.requires("json-c/0.15") - self.requires("libgeotiff/1.6.0") - # self.requires("libopencad/0.0.2") # TODO: use conan recipe when available instead of internal one - self.requires("libtiff/4.2.0") - self.requires("proj/8.0.1") - if tools.Version(self.version) >= "3.1.0": - self.requires("flatbuffers/1.12.0") - if self.options.get_safe("with_zlib", True): - self.requires("zlib/1.2.11") - if self.options.get_safe("with_libdeflate"): - self.requires("libdeflate/1.7") - if self.options.get_safe("with_libiconv", True): - self.requires("libiconv/1.16") - if self.options.get_safe("with_zstd"): - self.requires("zstd/1.4.9") - if self.options.with_pg: - self.requires("libpq/13.2") - # if self.options.with_libgrass: - # self.requires("libgrass/x.x.x") - if self.options.with_cfitsio: - self.requires("cfitsio/3.490") - # if self.options.with_pcraster: - # self.requires("pcraster-rasterformat/1.3.2") - if self.options.get_safe("with_png", True): - self.requires("libpng/1.6.37") - if self.options.with_dds: - self.requires("crunch/cci.20190615") - if self.options.with_gta: - self.requires("libgta/1.2.1") - # if self.options.with_pcidsk: - # self.requires("pcidsk/x.x.x") - if self.options.with_jpeg == "libjpeg": - self.requires("libjpeg/9d") - elif self.options.with_jpeg == "libjpeg-turbo": - self.requires("libjpeg-turbo/2.1.0") - if self.options.with_charls: - self.requires("charls/2.1.0") - if self.options.with_gif: - self.requires("giflib/5.2.1") - # if self.options.with_ogdi: - # self.requires("ogdi/4.1.0") - # if self.options.with_sosi: - # self.requires("fyba/4.1.1") - if self.options.with_mongocxx: - self.requires("mongo-cxx-driver/3.6.2") - if self.options.with_hdf4: - self.requires("hdf4/4.2.15") - if self.options.with_hdf5: - self.requires("hdf5/1.12.0") - if self.options.with_kea: - self.requires("kealib/1.4.14") - if self.options.with_netcdf: - self.requires("netcdf/4.7.4") - if self.options.with_jasper: - self.requires("jasper/2.0.32") - if self.options.with_openjpeg: - self.requires("openjpeg/2.4.0") - # if self.options.with_fgdb: - # self.requires("file-geodatabase-api/x.x.x") - if self.options.with_mysql == "libmysqlclient": - self.requires("libmysqlclient/8.0.17") - elif self.options.with_mysql == "mariadb-connector-c": - self.requires("mariadb-connector-c/3.1.12") - if self.options.with_xerces: - self.requires("xerces-c/3.2.3") - if self.options.with_expat: - self.requires("expat/2.3.0") - if self.options.with_libkml: - self.requires("libkml/1.3.0") - if self.options.with_odbc and self.settings.os != "Windows": - self.requires("odbc/2.3.7") - # if self.options.with_dods_root: - # self.requires("libdap/3.20.6") - if self.options.with_curl: - self.requires("libcurl/7.75.0") - if self.options.with_xml2: - self.requires("libxml2/2.9.10") - # if self.options.with_spatialite: - # self.requires("libspatialite/4.3.0a") - if self.options.get_safe("with_sqlite3"): - self.requires("sqlite3/3.35.5") - # if self.options.with_rasterlite2: - # self.requires("rasterlite2/x.x.x") - if self.options.get_safe("with_pcre"): - self.requires("pcre/8.44") - # if self.options.with_epsilon: - # self.requires("epsilon/0.9.2") - if self.options.with_webp: - self.requires("libwebp/1.2.0") - if self.options.with_geos: - self.requires("geos/3.9.1") - # if self.options.with_sfcgal: - # self.requires("sfcgal/1.3.7") - if self.options.with_qhull: - self.requires("qhull/8.0.1") - if self.options.with_opencl: - self.requires("opencl-headers/2020.06.16") - self.requires("opencl-icd-loader/2020.06.16") - if self.options.with_freexl: - self.requires("freexl/1.0.6") - if self.options.with_poppler: - self.requires("poppler/20.09.0") - if self.options.with_podofo: - self.requires("podofo/0.9.7") - # if self.options.with_pdfium: - # self.requires("pdfium/x.x.x") - # if self.options.get_safe("with_tiledb"): - # self.requires("tiledb/2.0.2") - # if self.options.with_rasdaman: - # self.requires("raslib/x.x.x") - # if self.options.with_armadillo: - # self.requires("armadillo/9.880.1") - if self.options.with_cryptopp: - self.requires("cryptopp/8.5.0") - if self.options.with_crypto: - self.requires("openssl/1.1.1k") - # if not self.options.without_lerc: - # self.requires("lerc/2.1") # TODO: use conan recipe (not possible yet because lerc API is broken for GDAL) - if self.options.get_safe("with_exr"): - self.requires("openexr/2.5.5") - if self.options.get_safe("with_heif"): - self.requires("libheif/1.12.0") - - def validate(self): - if self.options.with_qhull and self.options["qhull"].reentrant: - raise ConanInvalidConfiguration("gdal depends on non-reentrant qhull.") - - def _validate_dependency_graph(self): - if tools.Version(self.deps_cpp_info["libtiff"].version) < "4.0.0": - raise ConanInvalidConfiguration("gdal {} requires libtiff >= 4.0.0".format(self.version)) - if self.options.with_mongocxx: - mongocxx_version = tools.Version(self.deps_cpp_info["mongo-cxx-driver"].version) - if mongocxx_version < "3.0.0": - # TODO: handle mongo-cxx-driver v2 - raise ConanInvalidConfiguration("gdal with mongo-cxx-driver < 3.0.0 not yet supported in this recipe.") - elif mongocxx_version < "3.4.0": - raise ConanInvalidConfiguration("gdal with mongo-cxx-driver v3 requires 3.4.0 at least.") - - def build_requirements(self): - if self.settings.compiler != "Visual Studio": - self.build_requires("libtool/2.4.6") - self.build_requires("pkgconf/1.7.4") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") - - def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - - # Remove embedded dependencies - embedded_libs = [ - os.path.join("alg", "internal_libqhull"), - os.path.join("frmts", "gif", "giflib"), - os.path.join("frmts", "jpeg", "libjpeg"), - os.path.join("frmts", "png", "libpng"), - os.path.join("frmts", "zlib"), - # os.path.join("ogr", "ogrsf_frmts", "cad", "libopencad"), # TODO: uncomment when libopencad available - os.path.join("ogr", "ogrsf_frmts", "geojson", "libjson"), - ] - if tools.Version(self.version) >= "3.1.0": - embedded_libs.append(os.path.join("ogr", "ogrsf_frmts", "flatgeobuf", "flatbuffers")) - for lib_subdir in embedded_libs: - tools.rmdir(os.path.join(self._source_subfolder, lib_subdir)) - - # OpenCL headers - tools.replace_in_file(os.path.join(self._source_subfolder, "alg", "gdalwarpkernel_opencl.h"), - "#include ", - "#include ") - - # More patches for autotools build - if self.settings.compiler != "Visual Studio": - configure_ac = os.path.join(self._source_subfolder, "configure.ac") - # Workaround for nc-config not packaged in netcdf recipe (gdal relies on it to check nc4 and hdf4 support in netcdf): - if self.options.with_netcdf and self.options["netcdf"].netcdf4 and self.options["netcdf"].with_hdf5: - tools.replace_in_file(configure_ac, - "NETCDF_HAS_NC4=no", - "NETCDF_HAS_NC4=yes") - # Fix zlib checks and -lz injection to ensure to use external zlib and not fail others checks - if self.options.get_safe("with_zlib", True): - zlib_name = self.deps_cpp_info["zlib"].libs[0] - tools.replace_in_file(configure_ac, - "AC_CHECK_LIB(z,", - "AC_CHECK_LIB({},".format(zlib_name)) - tools.replace_in_file(configure_ac, - "-lz ", - "-l{} ".format(zlib_name)) - - def _edit_nmake_opt(self): - simd_intrinsics = str(self.options.get_safe("simd_intrinsics", False)) - if simd_intrinsics != "avx": - self._replace_in_nmake_opt("AVXFLAGS = /DHAVE_AVX_AT_COMPILE_TIME", "") - if simd_intrinsics not in ["sse3", "avx"]: - self._replace_in_nmake_opt("SSSE3FLAGS = /DHAVE_SSSE3_AT_COMPILE_TIME", "") - if simd_intrinsics not in ["sse", "sse3", "avx"]: - self._replace_in_nmake_opt("SSEFLAGS = /DHAVE_SSE_AT_COMPILE_TIME", "") - if self.options.without_pam: - self._replace_in_nmake_opt("PAM_SETTING=-DPAM_ENABLED", "") - if not self.options.with_gnm: - self._replace_in_nmake_opt("INCLUDE_GNM_FRMTS = YES", "") - if not self.options.with_odbc: - self._replace_in_nmake_opt("ODBC_SUPPORTED = 1", "") - if not bool(self.options.with_jpeg): - self._replace_in_nmake_opt("JPEG_SUPPORTED = 1", "") - self._replace_in_nmake_opt("JPEG12_SUPPORTED = 1", "") - if not self.options.with_pcidsk: - self._replace_in_nmake_opt("PCIDSK_SETTING=INTERNAL", "") - if self.options.with_pg: - self._replace_in_nmake_opt("#PG_LIB = n:\\pkg\\libpq_win32\\lib\\libpqdll.lib wsock32.lib", "PG_LIB=") - if bool(self.options.with_mysql): - self._replace_in_nmake_opt("#MYSQL_LIB = D:\\Software\\MySQLServer4.1\\lib\\opt\\libmysql.lib advapi32.lib", "MYSQL_LIB=") - if self.options.get_safe("with_sqlite3"): - self._replace_in_nmake_opt("#SQLITE_LIB=N:\\pkg\\sqlite-win32\\sqlite3_i.lib", "SQLITE_LIB=") - if self.options.with_curl: - self._replace_in_nmake_opt("#CURL_LIB = $(CURL_DIR)/libcurl.lib wsock32.lib wldap32.lib winmm.lib", "CURL_LIB=") - if self.options.with_freexl: - self._replace_in_nmake_opt("#FREEXL_LIBS = e:/freexl-1.0.0a/freexl_i.lib", "FREEXL_LIBS=") - if not (self.options.get_safe("with_zlib", True) and self.options.get_safe("with_png", True) and bool(self.options.with_jpeg)): - self._replace_in_nmake_opt("MRF_SETTING=yes", "") - if self.options.with_charls: - self._replace_in_nmake_opt("#CHARLS_LIB=e:\\work\\GIS\gdal\\supportlibs\\charls\\bin\\Release\\x86\\CharLS.lib", "CHARLS_LIB=") - # Inject required systems libs of dependencies - self._replace_in_nmake_opt("ADD_LIBS =", "ADD_LIBS={}".format(" ".join([lib + ".lib" for lib in self.deps_cpp_info.system_libs]))) - # Trick to enable OpenCL (option missing in upstream nmake files) - if self.options.with_opencl: - tools.replace_in_file(os.path.join(self._source_subfolder, "alg", "makefile.vc"), - "$(GEOS_CFLAGS)", "$(GEOS_CFLAGS) /DHAVE_OPENCL") - - def _replace_in_nmake_opt(self, str1, str2): - tools.replace_in_file(os.path.join(self.build_folder, self._source_subfolder, "nmake.opt"), str1, str2) - - def _get_nmake_args(self): - if self._nmake_args: - return self._nmake_args - - args = [] - args.append("GDAL_HOME=\"{}\"".format(self.package_folder)) - args.append("DATADIR=\"{}\"".format(os.path.join(self.package_folder, "res", "gdal"))) - if self.settings.arch == "x86_64": - args.append("WIN64=1") - args.append("DEBUG={}".format("1" if self.settings.build_type == "Debug" else "0")) - args.append("DLLBUILD={}".format("1" if self.options.shared else "0")) - args.append("PROJ_INCLUDE=\"-I{}\"".format(" -I".join(self.deps_cpp_info["proj"].include_paths))) - if self.options.with_libiconv: - args.append("LIBICONV_INCLUDE=\"-I{}\"".format(" -I".join(self.deps_cpp_info["libiconv"].include_paths))) - args.append("LIBICONV_CFLAGS=\"-DICONV_CONST=\"") - args.append("JPEG_EXTERNAL_LIB=1") - if self.options.with_jpeg == "libjpeg": - args.append("JPEGDIR=\"{}\"".format(" -I".join(self.deps_cpp_info["libjpeg"].include_paths))) - elif self.options.with_jpeg == "libjpeg-turbo": - args.append("JPEGDIR=\"{}\"".format(" -I".join(self.deps_cpp_info["libjpeg-turbo"].include_paths))) - args.append("PNG_EXTERNAL_LIB=1") - args.append("PNGDIR=\"{}\"".format(" -I".join(self.deps_cpp_info["libpng"].include_paths))) - if self.options.with_gif: - args.append("GIF_SETTING=EXTERNAL") - if self.options.with_pcraster: - args.append("PCRASTER_SETTING=INTERNAL") - args.append("TIFF_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["libtiff"].include_paths))) - args.append("GEOTIFF_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["libgeotiff"].include_paths))) - if self.options.with_libkml: - args.append("LIBKML_DIR=\"{}\"".format(self.deps_cpp_info["libkml"].rootpath)) - if self.options.with_expat: - args.append("EXPAT_DIR=\"{}\"".format(self.deps_cpp_info["expat"].rootpath)) - args.append("EXPAT_INCLUDE=\"-I{}\"".format(" -I".join(self.deps_cpp_info["expat"].include_paths))) - if self.options.with_xerces: - args.append("XERCES_DIR=\"{}\"".format(self.deps_cpp_info["xerces-c"].rootpath)) - args.append("XERCES_INCLUDE=\"-I{}\"".format(" -I".join(self.deps_cpp_info["xerces-c"].include_paths))) - if self.options.with_jasper: - args.append("JASPER_DIR=\"{}\"".format(self.deps_cpp_info["jasper"].rootpath)) - if self.options.with_hdf4: - args.append("HDF4_DIR=\"{}\"".format(self.deps_cpp_info["hdf4"].rootpath)) - args.append("HDF4_INCLUDE=\"{}\"".format(" -I".join(self.deps_cpp_info["hdf4"].include_paths))) - if tools.Version(self.deps_cpp_info["hdf4"].version) >= "4.2.5": - args.append("HDF4_HAS_MAXOPENFILES=YES") - if self.options.with_hdf5: - args.append("HDF5_DIR=\"{}\"".format(self.deps_cpp_info["hdf5"].rootpath)) - if self.options.with_kea: - args.append("KEA_CFLAGS=\"-I{}\"".format(" -I".join(self.deps_cpp_info["kealib"].include_paths))) - if self.options.with_pg: - args.append("PG_INC_DIR=\"{}\"".format(" -I".join(self.deps_cpp_info["libpq"].include_paths))) - if self.options.with_mysql == "libmysqlclient": - args.append("MYSQL_INC_DIR=\"{}\"".format(" -I".join(self.deps_cpp_info["libmysqlclient"].include_paths))) - elif self.options.with_mysql == "mariadb-connector-c": - args.append("MYSQL_INC_DIR=\"{}\"".format(" -I".join(self.deps_cpp_info["mariadb-connector-c"].include_paths))) - if self.options.get_safe("with_sqlite3"): - args.append("SQLITE_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["sqlite3"].include_paths))) - if self.options.get_safe("with_pcre"): - args.append("PCRE_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["pcre"].include_paths))) - if self.options.with_cfitsio: - args.append("FITS_INC_DIR=\"{}\"".format(" -I".join(self.deps_cpp_info["cfitsio"].include_paths))) - if self.options.with_netcdf: - args.extend([ - "NETCDF_SETTING=YES", - "NETCDF_INC_DIR=\"{}\"".format(" -I".join(self.deps_cpp_info["netcdf"].include_paths)) - ]) - if self.options["netcdf"].netcdf4 and self.options["netcdf"].with_hdf5: - args.append("NETCDF_HAS_NC4=YES") - if self.options.with_curl: - args.append("CURL_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["libcurl"].include_paths))) - if self.options.with_geos: - args.append("GEOS_CFLAGS=\"-I{} -DHAVE_GEOS\"".format(" -I".join(self.deps_cpp_info["geos"].include_paths))) - if self.options.with_openjpeg: - args.append("OPENJPEG_ENABLED=YES") - if self.options.get_safe("with_zlib", True): - args.append("ZLIB_EXTERNAL_LIB=1") - args.append("ZLIB_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["zlib"].include_paths))) - if self.options.get_safe("with_libdeflate"): - args.append("LIBDEFLATE_CFLAGS=\"-I{}\"".format(" -I".join(self.deps_cpp_info["libdeflate"].include_paths))) - if self.options.with_poppler: - poppler_version = tools.Version(self.deps_cpp_info["poppler"].version) - args.extend([ - "POPPLER_ENABLED=YES", - "POPPLER_MAJOR_VERSION={}".format(poppler_version.major), - "POPPLER_MINOR_VERSION={}".format(poppler_version.minor) - ]) - if self.options.with_podofo: - args.append("PODOFO_ENABLED=YES") - if self.options.get_safe("with_zstd"): - args.append("ZSTD_CFLAGS=\"-I{}\"".format(" -I".join(self.deps_cpp_info["zstd"].include_paths))) - if self.options.with_webp: - args.append("WEBP_ENABLED=YES") - args.append("WEBP_CFLAGS=\"-I{}\"".format(" -I".join(self.deps_cpp_info["libwebp"].include_paths))) - if self.options.with_xml2: - args.append("LIBXML2_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["libxml2"].include_paths))) - if self.options.with_gta: - args.append("GTA_CFLAGS=\"-I{}\"".format(" -I".join(self.deps_cpp_info["libgta"].include_paths))) - if self.options.with_mongocxx: - args.append("MONGOCXXV3_CFLAGS=\"-I{}\"".format(" -I".join(self.deps_cpp_info["mongo-cxx-driver"].include_paths))) - args.append("QHULL_SETTING={}".format("EXTERNAL" if self.options.with_qhull else "NO")) - if self.options.with_cryptopp: - args.append("CRYPTOPP_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["cryptopp"].include_paths))) - if self.options["cryptopp"].shared: - args.append("USE_ONLY_CRYPTODLL_ALG=YES") - if self.options.with_crypto: - args.append("OPENSSL_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["openssl"].include_paths))) - if self.options.without_lerc: - args.append("HAVE_LERC=0") - if self.options.with_charls: - charls_version = tools.Version(self.deps_cpp_info["charls"].version) - if charls_version >= "2.1.0": - args.append("CHARLS_FLAGS=-DCHARLS_2_1") - elif charls_version >= "2.0.0": - args.append("CHARLS_FLAGS=-DCHARLS_2") - if self.options.with_dds: - args.append("CRUNCH_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["crunch"].include_paths))) - if self.options.get_safe("with_exr"): - args.append("EXR_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["openexr"].include_paths))) - if self.options.get_safe("with_heif"): - args.append("HEIF_INC=\"-I{}\"".format(" -I".join(self.deps_cpp_info["libheif"].include_paths))) - - self._nmake_args = args - return self._nmake_args - - def _gather_libs(self, p): - libs = self.deps_cpp_info[p].libs + self.deps_cpp_info[p].system_libs - for dep in self.deps_cpp_info[p].public_deps: - for l in self._gather_libs(dep): - if not l in libs: - libs.append(l) - return libs - - def _configure_autotools(self): - if self._autotools: - return self._autotools - - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - - args = [] - args.append("--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res")))) - # Shared/Static - if self.options.shared: - args.extend(["--disable-static", "--enable-shared"]) - else: - args.extend(["--disable-shared", "--enable-static"]) - # Enable C++14 if requested in conan profile or if with_charls enabled - if (self.settings.compiler.cppstd and tools.valid_min_cppstd(self, 14)) or self.options.with_charls: - args.append("--with-cpp14") - # Debug - if self.settings.build_type == "Debug": - args.append("--enable-debug") - # SIMD Intrinsics - simd_intrinsics = self.options.get_safe("simd_intrinsics", False) - if not simd_intrinsics: - args.extend(["--without-sse", "--without-ssse3", "--without-avx"]) - elif simd_intrinsics == "sse": - args.extend(["--with-sse", "--without-ssse3", "--without-avx"]) - elif simd_intrinsics == "ssse3": - args.extend(["--with-sse", "--with-ssse3", "--without-avx"]) - elif simd_intrinsics == "avx": - args.extend(["--with-sse", "--with-ssse3", "--with-avx"]) - # LTO (disabled) - args.append("--disable-lto") - # Symbols - args.append("--with-hide_internal_symbols") - # Do not add /usr/local/lib and /usr/local/include - args.append("--without-local") - # Threadsafe - args.append("--with-threads={}".format("yes" if self.options.threadsafe else "no")) - # Depencencies: - args.append("--with-proj=yes") # always required ! - args.append("--with-libz={}".format("yes" if self.options.with_zlib else "no")) - if self._has_with_libdeflate_option: - args.append("--with-libdeflate={}".format("yes" if self.options.with_libdeflate else "no")) - args.append("--with-libiconv-prefix={}".format(tools.unix_path(self.deps_cpp_info["libiconv"].rootpath))) - args.append("--with-liblzma=no") # always disabled: liblzma is an optional transitive dependency of gdal (through libtiff). - args.append("--with-zstd={}".format("yes" if self.options.get_safe("with_zstd") else "no")) # Optional direct dependency of gdal only if lerc lib enabled - # Drivers: - if not (self.options.with_zlib and self.options.with_png and bool(self.options.with_jpeg)): - # MRF raster driver always depends on zlib, libpng and libjpeg: https://github.com/OSGeo/gdal/issues/2581 - if tools.Version(self.version) < "3.0.0": - args.append("--without-mrf") - else: - args.append("--disable-driver-mrf") - args.append("--with-pg={}".format("yes" if self.options.with_pg else "no")) - args.extend(["--without-grass", "--without-libgrass"]) # TODO: to implement when libgrass lib available - args.append("--with-cfitsio={}".format(tools.unix_path(self.deps_cpp_info["cfitsio"].rootpath) if self.options.with_cfitsio else "no")) - args.append("--with-pcraster={}".format("internal" if self.options.with_pcraster else "no")) # TODO: use conan recipe when available instead of internal one - args.append("--with-png={}".format(tools.unix_path(self.deps_cpp_info["libpng"].rootpath) if self.options.with_png else "no")) - args.append("--with-dds={}".format(tools.unix_path(self.deps_cpp_info["crunch"].rootpath) if self.options.with_dds else "no")) - args.append("--with-gta={}".format(tools.unix_path(self.deps_cpp_info["libgta"].rootpath) if self.options.with_gta else "no")) - args.append("--with-pcidsk={}".format("internal" if self.options.with_pcidsk else "no")) # TODO: use conan recipe when available instead of internal one - args.append("--with-libtiff={}".format(tools.unix_path(self.deps_cpp_info["libtiff"].rootpath))) # always required ! - args.append("--with-geotiff={}".format(tools.unix_path(self.deps_cpp_info["libgeotiff"].rootpath))) # always required ! - if self.options.with_jpeg == "libjpeg": - args.append("--with-jpeg={}".format(tools.unix_path(self.deps_cpp_info["libjpeg"].rootpath))) - elif self.options.with_jpeg == "libjpeg-turbo": - args.append("--with-jpeg={}".format(tools.unix_path(self.deps_cpp_info["libjpeg-turbo"].rootpath))) - else: - args.append("--without-jpeg") - args.append("--without-jpeg12") # disabled: it requires internal libjpeg and libgeotiff - args.append("--with-charls={}".format("yes" if self.options.with_charls else "no")) - args.append("--with-gif={}".format(tools.unix_path(self.deps_cpp_info["giflib"].rootpath) if self.options.with_gif else "no")) - args.append("--without-ogdi") # TODO: to implement when ogdi lib available (https://sourceforge.net/projects/ogdi/) - args.append("--without-fme") # commercial library - args.append("--without-sosi") # TODO: to implement when fyba lib available - args.append("--without-mongocxx") # TODO: handle mongo-cxx-driver v2 - args.append("--with-mongocxxv3={}".format("yes" if self.options.with_mongocxx else "no")) - args.append("--with-hdf4={}".format("yes" if self.options.with_hdf4 else "no")) - args.append("--with-hdf5={}".format("yes" if self.options.with_hdf5 else "no")) - args.append("--with-kea={}".format("yes" if self.options.with_kea else "no")) - args.append("--with-netcdf={}".format(tools.unix_path(self.deps_cpp_info["netcdf"].rootpath) if self.options.with_netcdf else "no")) - args.append("--with-jasper={}".format(tools.unix_path(self.deps_cpp_info["jasper"].rootpath) if self.options.with_jasper else "no")) - args.append("--with-openjpeg={}".format("yes" if self.options.with_openjpeg else "no")) - args.append("--without-fgdb") # TODO: to implement when file-geodatabase-api lib available - args.append("--without-ecw") # commercial library - args.append("--without-kakadu") # commercial library - args.extend(["--without-mrsid", "--without-jp2mrsid", "--without-mrsid_lidar"]) # commercial library - args.append("--without-jp2lura") # commercial library - args.append("--without-msg") # commercial library - args.append("--without-oci") # TODO - args.append("--with-gnm={}".format("yes" if self.options.with_gnm else "no")) - args.append("--with-mysql={}".format("yes" if bool(self.options.with_mysql) else "no")) - args.append("--without-ingres") # commercial library - args.append("--with-xerces={}".format(tools.unix_path(self.deps_cpp_info["xerces-c"].rootpath) if self.options.with_xerces else "no")) - args.append("--with-expat={}".format("yes" if self.options.with_expat else "no")) - args.append("--with-libkml={}".format(tools.unix_path(self.deps_cpp_info["libkml"].rootpath) if self.options.with_libkml else "no")) - if self.options.with_odbc: - args.append("--with-odbc={}".format("yes" if self.settings.os == "Windows" else tools.unix_path(self.deps_cpp_info["odbc"].rootpath))) - else: - args.append("--without-odbc") - args.append("--without-dods-root") # TODO: to implement when libdap lib available - args.append("--with-curl={}".format("yes" if self.options.with_curl else "no")) - args.append("--with-xml2={}".format("yes" if self.options.with_xml2 else "no")) - args.append("--without-spatialite") # TODO: to implement when libspatialite lib available - args.append("--with-sqlite3={}".format("yes" if self.options.get_safe("with_sqlite3") else "no")) - args.append("--without-rasterlite2") # TODO: to implement when rasterlite2 lib available - args.append("--with-pcre={}".format("yes" if self.options.get_safe("with_pcre") else "no")) - args.append("--without-teigha") # commercial library - args.append("--without-idb") # commercial library - if tools.Version(self.version) < "3.2.0": - args.append("--without-sde") # commercial library - args.append("--without-epsilon") # TODO: to implement when epsilon lib available - args.append("--with-webp={}".format(tools.unix_path(self.deps_cpp_info["libwebp"].rootpath) if self.options.with_webp else "no")) - args.append("--with-geos={}".format("yes" if self.options.with_geos else "no")) - args.append("--without-sfcgal") # TODO: to implement when sfcgal lib available - args.append("--with-qhull={}".format("yes" if self.options.with_qhull else "no")) - if self.options.with_opencl: - args.extend([ - "--with-opencl", - "--with-opencl-include={}".format(tools.unix_path(self.deps_cpp_info["opencl-headers"].include_paths[0])), - "--with-opencl-lib=-L{}".format(tools.unix_path(self.deps_cpp_info["opencl-icd-loader"].lib_paths[0])) - ]) - else: - args.append("--without-opencl") - args.append("--with-freexl={}".format("yes" if self.options.with_freexl else "no")) - args.append("--with-libjson-c={}".format(tools.unix_path(self.deps_cpp_info["json-c"].rootpath))) # always required ! - if self.options.without_pam: - args.append("--without-pam") - args.append("--with-poppler={}".format("yes" if self.options.with_poppler else "no")) - if self.options.with_podofo: - args.extend([ - "--with-podofo={}".format(tools.unix_path(self.deps_cpp_info["podofo"].rootpath)), - "--with-podofo-lib=-l{}".format(" -l".join(self._gather_libs("podofo"))) - ]) - else: - args.append("--without-podofo") - args.append("--without-pdfium") # TODO: to implement when pdfium lib available - args.append("--without-perl") - args.append("--without-python") - args.append("--without-java") - args.append("--without-hdfs") - if tools.Version(self.version) >= "3.0.0": - args.append("--without-tiledb") # TODO: to implement when tiledb lib available - args.append("--without-mdb") - args.append("--without-rasdaman") # TODO: to implement when rasdaman lib available - if tools.Version(self.version) >= "3.1.0": - args.append("--without-rdb") # commercial library - args.append("--without-armadillo") # TODO: to implement when armadillo lib available - args.append("--with-cryptopp={}".format(tools.unix_path(self.deps_cpp_info["cryptopp"].rootpath) if self.options.with_cryptopp else "no")) - args.append("--with-crypto={}".format("yes" if self.options.with_crypto else "no")) - args.append("--with-lerc={}".format("no" if self.options.without_lerc else "yes")) - if self.options.with_null: - args.append("--with-null") - if self._has_with_exr_option: - args.append("--with-exr={}".format("yes" if self.options.with_exr else "no")) - if self._has_with_heif_option: - args.append("--with-heif={}".format("yes" if self.options.with_heif else "no")) - - # Inject -stdlib=libc++ for clang with libc++ - env_build_vars = self._autotools.vars - if self.settings.compiler == "clang" and \ - self.settings.os == "Linux" and tools.stdcpp_library(self) == "c++": - env_build_vars["LDFLAGS"] = "-stdlib=libc++ {}".format(env_build_vars["LDFLAGS"]) - - self._autotools.configure(args=args, vars=env_build_vars) - return self._autotools - - @contextmanager - def _msvc_build_environment(self): - with tools.chdir(self._source_subfolder): - with tools.vcvars(self.settings): - with tools.environment_append(VisualStudioBuildEnvironment(self).vars): - yield - - @contextmanager - def _autotools_build_environment(self): - with tools.chdir(self._source_subfolder): - with tools.run_environment(self): - with tools.environment_append({"PKG_CONFIG_PATH": tools.unix_path(self.build_folder)}): - yield - - def build(self): - self._validate_dependency_graph() - self._patch_sources() - if self.settings.compiler == "Visual Studio": - self._edit_nmake_opt() - with self._msvc_build_environment(): - self.run("nmake -f makefile.vc {}".format(" ".join(self._get_nmake_args()))) - else: - with self._autotools_build_environment(): - self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) - autotools = self._configure_autotools() - autotools.make() - - def package(self): - self.copy("LICENSE.TXT", dst="licenses", src=self._source_subfolder) - if self.settings.compiler == "Visual Studio": - with self._msvc_build_environment(): - self.run("nmake -f makefile.vc devinstall {}".format(" ".join(self._get_nmake_args()))) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.pdb") - else: - with self._autotools_build_environment(): - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "gdalplugins")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") - - def package_info(self): - self.cpp_info.names["cmake_find_package"] = "GDAL" - self.cpp_info.names["cmake_find_package_multi"] = "GDAL" - self.cpp_info.names["pkg_config"] = "gdal" - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": - self.cpp_info.system_libs.extend(["dl", "m"]) - if self.options.threadsafe: - self.cpp_info.system_libs.append("pthread") - elif self.settings.os == "Windows": - self.cpp_info.system_libs.extend(["psapi", "ws2_32"]) - if tools.Version(self.version) >= "3.2.0" and self.settings.compiler == "Visual Studio": - self.cpp_info.system_libs.append("wbemuuid") - if self.options.with_odbc and not self.options.shared: - self.cpp_info.system_libs.extend(["odbc32", "odbccp32"]) - if self.settings.compiler == "Visual Studio": - self.cpp_info.system_libs.append("legacy_stdio_definitions") - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.system_libs.append(tools.stdcpp_library(self)) - - gdal_data_path = os.path.join(self.package_folder, "res", "gdal") - self.output.info("Creating GDAL_DATA environment variable: {}".format(gdal_data_path)) - self.env_info.GDAL_DATA = gdal_data_path - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) diff --git a/recipes/gdal/all/patches/3.1.x/fix-autotools-3.1.0.patch b/recipes/gdal/all/patches/3.1.x/fix-autotools-3.1.0.patch deleted file mode 100644 index f133d96568f94..0000000000000 --- a/recipes/gdal/all/patches/3.1.x/fix-autotools-3.1.0.patch +++ /dev/null @@ -1,280 +0,0 @@ ---- a/GDALmake.opt.in -+++ b/GDALmake.opt.in -@@ -601,7 +601,7 @@ endif - - ifeq ($(HAVE_LIBTOOL), yes) - --CONFIG_LIBS = $(GDAL_ROOT)/$(LIBGDAL) -+CONFIG_LIBS = $(GDAL_ROOT)/$(LIBGDAL) $(LIBS) - ifeq ($(MACOSX_FRAMEWORK),yes) - CONFIG_LIBS_INS = -L$(INST_LIB)/unix/lib -lgdal - else ---- a/configure.ac -+++ b/configure.ac -@@ -1214,6 +1214,7 @@ dnl --------------------------------------------------------------------------- - dnl PROJ.6 related stuff - dnl --------------------------------------------------------------------------- - -+PKG_PROG_PKG_CONFIG([0.21]) - AC_MSG_CHECKING([for PROJ >= 6 library]) - - AC_ARG_WITH(proj,[ --with-proj=ARG Compile with PROJ.x (ARG=yes or path)],,) -@@ -1229,11 +1230,7 @@ if test "x$with_proj" = "xno" ; then - else - - if test "x$with_proj" = "xyes" -o "x$with_proj" = "x"; then -- ORIG_LIBS="$LIBS" -- LIBS="-lproj $ORIG_LIBS" -- AC_LANG_PUSH([C++]) -- AC_CHECK_LIB(proj,proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,) -- AC_LANG_POP([C++]) -+ PROJ_FOUND=yes - if test "$PROJ_FOUND" = "no"; then - AC_LANG_PUSH([C++]) - AC_CHECK_LIB(proj,internal_proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,) -@@ -1876,7 +1873,6 @@ else - - DDS_SETTING=yes - CRUNCHDIR="$with_dds" -- LIBS="-L$with_dds/lib/ -lcrunch $LIBS" - echo "using libcrunch from $with_dds." - - fi -@@ -2019,7 +2015,7 @@ else - AC_MSG_RESULT([using libtiff from ${with_libtiff}.]) - - dnl Check for the BigTIFF enabled library (libtiff >= 4.0) -- AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,) -+ AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,$LIBS) - - fi - -@@ -2089,7 +2085,6 @@ else - - dnl We now require libgeotiff 1.5.0 - dnl first check if $with_geotiff/lib has the library: -- AC_CHECK_LIB(geotiff,GTIFAttachPROJContext,GEOTIFF_SETTING=external,GEOTIFF_SETTING=not_found,-L$with_geotiff/lib) - - if test $GEOTIFF_SETTING = "external" ; then - LIBS="-L$with_geotiff/lib -lgeotiff $LIBS" -@@ -2649,6 +2644,10 @@ if test x"$with_hdf4" = x"no" ; then - - echo "hdf4 support disabled." - -+elif test x"$with_hdf4" = x"yes" ; then -+ PKG_CHECK_MODULES([HDF4], [hdf], [HAVE_HDF4=yes], [HAVE_HDF4=no]) -+ PKG_CHECK_MODULES([HDF4], [hdf >= 4.2.5], [HDF4_HAS_MAXOPENFILES=yes], [HDF4_HAS_MAXOPENFILES=no]) -+ HDF4_INCLUDE="$HDF4_CFLAGS" - else - - if test x"$with_hdf4" = x"yes" -o x"$with_hdf4" = x"" ; then -@@ -2779,7 +2778,6 @@ elif test "$with_hdf5" = "yes" -o "$with_hdf5" = "" ; then - # Test that the package found is for the right architecture - saved_LIBS="$LIBS" - LIBS="$HDF5_LIBS" -- AC_CHECK_LIB(hdf5,H5Fopen, [HAVE_HDF5=yes], [HAVE_HDF5=no]) - LIBS="$saved_LIBS" - - if test "$HAVE_HDF5" = "yes"; then -@@ -2848,21 +2846,21 @@ KEA_CONFIG=no - - AC_ARG_WITH(kea,[ --with-kea[=ARG] Include kealib (ARG=path to kea-config) [[default=yes]]],,) - -+AC_MSG_CHECKING([for kea]) - if test "$with_kea" = "yes" -o "x$with_kea" = "x" ; then -- AC_PATH_PROG(KEA_CONFIG, kea-config, no) -+ HAVE_KEA=yes -+ AC_MSG_RESULT([yes]) - else -- KEA_CONFIG=$with_kea -+ HAVE_KEA=no -+ AC_MSG_RESULT([no]) - fi - --AC_MSG_CHECKING([for kea]) - - if test "$KEA_CONFIG" = "no" ; then - -- HAVE_KEA=no - KEA_LIB= - KEA_INC= - -- AC_MSG_RESULT([no]) - - else - if test -d $KEA_CONFIG ; then -@@ -3714,18 +3712,15 @@ MYSQL_CONFIG=no - AC_ARG_WITH(mysql,[ --with-mysql[=ARG] Include MySQL (ARG=path to mysql_config) [[default=no]]],,) - - if test "$with_mysql" = "yes" ; then -- AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no) -+ HAVE_MYSQL=yes - else -- if test "x$with_mysql" != "x" ; then -- MYSQL_CONFIG=$with_mysql -- fi -+ HAVE_MYSQL=no - fi - - AC_MSG_CHECKING([for MySQL]) - - if test "$MYSQL_CONFIG" = "no" ; then - -- HAVE_MYSQL=no - MYSQL_LIB= - MYSQL_INC= - -@@ -3819,8 +3814,11 @@ dnl Check for Expat configuration. - dnl --------------------------------------------------------------------------- - - dnl Expat 1.95.0 released in 2000-09-28 --EXPAT_REQ_VERSION="1.95.0" --AX_LIB_EXPAT($EXPAT_REQ_VERSION) -+# AX_LIB_EXPAT is too fragile, it doesn't properly handle debug expat on Windows -+HAVE_EXPAT=no -+AC_ARG_WITH([expat], AS_HELP_STRING([--with-expat[=ARG]], [use Expat library (ARG=yes or no)]),,) -+if test x"$with_expat" = x"yes" ; then -+PKG_CHECK_MODULES([EXPAT], [expat >= 1.95.0], [HAVE_EXPAT=yes], [HAVE_EXPAT=no]) - - if test "$HAVE_EXPAT" = "yes"; then - LIBS="$EXPAT_LDFLAGS $LIBS" -@@ -3833,6 +3831,7 @@ m4_foreach_w([frmt],EXPAT_DRIVERS,[ - fi - ]) - -+fi - fi - - AC_SUBST([HAVE_EXPAT], $HAVE_EXPAT) -@@ -4058,29 +4057,16 @@ AC_ARG_WITH(curl, - dnl Clear some cache variables - unset ac_cv_path_LIBCURL - --if test "`basename xx/$with_curl`" = "curl-config" ; then -- LIBCURL_CONFIG="$with_curl" --elif test "$with_curl" = "no" ; then -- LIBCURL_CONFIG=no -+if test "$with_curl" = "yes" ; then -+ PKG_CHECK_MODULES([CURL], [libcurl], [CURL_SETTING=yes], [CURL_SETTING=no]) - else -- AC_PATH_PROG(LIBCURL_CONFIG, curl-config, no) --fi -- --if test "$LIBCURL_CONFIG" != "no" ; then -- -- CURL_VERNUM=`$LIBCURL_CONFIG --vernum` -- CURL_VER=`$LIBCURL_CONFIG --version | awk '{print $2}'` -- -- AC_MSG_RESULT([ found libcurl version $CURL_VER]) -- -- AC_CHECK_LIB(curl,curl_global_init,CURL_SETTING=yes,CURL_SETTING=no,`$LIBCURL_CONFIG --libs`) -- -+ CURL_SETTING=no - fi - - if test "$CURL_SETTING" = "yes" ; then - -- CURL_INC=`$LIBCURL_CONFIG --cflags` -- CURL_LIB=`$LIBCURL_CONFIG --libs` -+ CURL_INC="$CURL_CFLAGS" -+ CURL_LIB="$CURL_LIBS" - m4_foreach_w([frmt],CURL_FORMATS,[ - driver_enabled=m4_join([_],[$INTERNAL_FORMAT],frmt,[ENABLED]) - if test "x$driver_enabled" = "xyes"; then -@@ -4120,7 +4106,6 @@ if test "x$with_xml2" = "xyes" -o "x$with_xml2" = "x" ; then - if test "${HAVE_LIBXML2}" = "yes"; then - SAVED_LIBS="${LIBS}" - LIBS="${LIBXML2_LIBS}" -- AC_CHECK_LIB(xml2,xmlParseDoc,HAVE_LIBXML2=yes,HAVE_LIBXML2=no) - LIBS="${SAVED_LIBS}" - fi - -@@ -4241,9 +4226,12 @@ dnl --------------------------------------------------------------------------- - dnl Check for SQLite (only if SpatiaLite is not detected) - dnl --------------------------------------------------------------------------- - -+HAVE_SQLITE3=no -+AC_ARG_WITH(sqlite3, AS_HELP_STRING([--with-sqlite3[=ARG]], [use SQLite 3 library (ARG=yes or no)]),,) - if test "${HAVE_SPATIALITE}" = "no" -o "${HAVE_SPATIALITE}" = "dlopen" ; then -- SQLITE3_REQ_VERSION="3.0.0" -- AX_LIB_SQLITE3($SQLITE3_REQ_VERSION) -+ if test x"$with_sqlite3" = x"yes" ; then -+ PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.0.0], [HAVE_SQLITE3=yes], [HAVE_SQLITE3=no]) -+ fi - - if test "$HAVE_SQLITE3" = "yes"; then - LIBS="$SQLITE3_LDFLAGS $LIBS" -@@ -4596,8 +4584,12 @@ dnl --------------------------------------------------------------------------- - dnl Check if geos library is available. - dnl --------------------------------------------------------------------------- - --GEOS_INIT(3.1.0) -+AC_ARG_WITH(geos, AS_HELP_STRING([--with-geos[=ARG]], [Include GEOS support (ARG=yes or no)]),,) - HAVE_GEOS_RESULT="no" -+if test x"$with_geos" = x"no" ; then -+ AC_MSG_RESULT([GEOS support disabled]) -+else -+ PKG_CHECK_MODULES([GEOS], [geos >= 3.1.0], [HAVE_GEOS=yes], [HAVE_GEOS=no]) - if test "${HAVE_GEOS}" = "yes" ; then - - AC_MSG_NOTICE([Using C API from GEOS $GEOS_VERSION]) -@@ -4606,6 +4598,7 @@ if test "${HAVE_GEOS}" = "yes" ; then - LIBS="${GEOS_LIBS} ${LIBS}" - HAVE_GEOS_RESULT="yes" - fi -+fi - - dnl --------------------------------------------------------------------------- - dnl Check if SFCGAL library is available. -@@ -4640,20 +4633,18 @@ elif test "$with_qhull" = "yes" -o "$with_qhull" = "" ; then - # qhull/qhull.h - AC_CHECK_HEADERS([qhull/libqhull.h]) - if test "$ac_cv_header_qhull_libqhull_h" = "yes"; then -- AC_CHECK_LIB(qhull,qh_new_qhull,QHULL_SETTING=yes,QHULL_SETTING=no,) -+ QHULL_SETTING=yes - if test "$QHULL_SETTING" = "yes"; then - QHULL_SETTING=external - QHULL_INCLUDE_SUBDIR_IS_LIBQHULL=0 -- LIBS="-lqhull $LIBS" - fi - fi - AC_CHECK_HEADERS([libqhull/libqhull.h]) - if test "$ac_cv_header_libqhull_libqhull_h" = "yes"; then -- AC_CHECK_LIB(qhull,qh_new_qhull,QHULL_SETTING=yes,QHULL_SETTING=no,) -+ QHULL_SETTING=yes - if test "$QHULL_SETTING" = "yes"; then - QHULL_SETTING=external - QHULL_INCLUDE_SUBDIR_IS_LIBQHULL=1 -- LIBS="-lqhull $LIBS" - fi - fi - -@@ -4740,7 +4731,9 @@ AC_MSG_CHECKING([for FreeXL support]) - HAVE_FREEXL=no - FREEXL_INCLUDE= - --if test "$with_freexl" = "" -o "$with_freexl" = "yes" ; then -+if test "$with_freexl" = "yes"; then -+ PKG_CHECK_MODULES([FREEXL], [freexl >= 1.0.0], [HAVE_FREEXL=yes], [HAVE_FREEXL=no]) -+elif test "$with_freexl" = ""; then - AC_CHECK_HEADERS(freexl.h) - AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl",FREEXL_LIBS=missing) - -@@ -4846,8 +4839,7 @@ if test "$with_libjson_c" = "external" -o "$with_libjson_c" = "" -o "$with_libjs - elif test "$with_libjson_c" = "internal" ; then - LIBJSONC_SETTING=internal - elif test "$with_libjson_c" != "no"; then -- LIBS="-L$with_libjson_c/lib $LIBS" -- AC_CHECK_LIB(json-c,json_object_set_serializer,LIBJSONC_SETTING=external,LIBJSONC_SETTING=internal,-L$with_libjson_c/lib) -+ LIBJSONC_SETTING=external - else - AC_MSG_ERROR([libjson-c (internal or external) is required]) - fi -@@ -5951,7 +5943,6 @@ else - # Test that the package found is for the right architecture - saved_LIBS="$LIBS" - LIBS="$EXR_LIBS" -- AC_CHECK_LIB(IlmImf,ImfTiledInputReadTile, [HAVE_EXR=yes], [HAVE_EXR=no]) - LIBS="$saved_LIBS" - - if test "$HAVE_EXR" = "yes"; then diff --git a/recipes/gdal/all/patches/3.1.x/fix-include-xerces-3.1.0.patch b/recipes/gdal/all/patches/3.1.x/fix-include-xerces-3.1.0.patch deleted file mode 100644 index 07aa44a5fb4e5..0000000000000 --- a/recipes/gdal/all/patches/3.1.x/fix-include-xerces-3.1.0.patch +++ /dev/null @@ -1,63 +0,0 @@ ---- a/ogr/ogr_xerces_headers.h -+++ b/ogr/ogr_xerces_headers.h -@@ -33,9 +33,9 @@ - #pragma GCC system_header - #endif - --#include --#include --#include -+#include -+#include -+#include - - #ifdef XERCES_CPP_NAMESPACE_USE - XERCES_CPP_NAMESPACE_USE ---- a/ogr/ogrsf_frmts/gml/xercesc_headers.h -+++ b/ogr/ogrsf_frmts/gml/xercesc_headers.h -@@ -39,13 +39,13 @@ - #define INFINITY INFINITY_XERCES - #endif - --#include --#include --#include --#include --#include --#include --#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include - - #ifdef XERCES_CPP_NAMESPACE_USE - XERCES_CPP_NAMESPACE_USE ---- a/ogr/ogrsf_frmts/ili/xercesc_headers.h -+++ b/ogr/ogrsf_frmts/ili/xercesc_headers.h -@@ -39,14 +39,14 @@ - #define INFINITY INFINITY_XERCES - #endif - --#include --#include --#include --#include --#include --#include --#include --#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include - - #ifdef XERCES_CPP_NAMESPACE_USE - XERCES_CPP_NAMESPACE_USE diff --git a/recipes/gdal/all/patches/3.1.x/fix-nmake-opt-3.1.0.patch b/recipes/gdal/all/patches/3.1.x/fix-nmake-opt-3.1.0.patch deleted file mode 100644 index 5759c64a92a8f..0000000000000 --- a/recipes/gdal/all/patches/3.1.x/fix-nmake-opt-3.1.0.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/nmake.opt -+++ b/nmake.opt -@@ -148,9 +148,9 @@ CXX_PDB_FLAGS= - - !IFNDEF OPTFLAGS - !IF "$(DEBUG)" == "0" --OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /nologo /MP$(CPU_COUNT) /MD /EHsc /Ox /FC /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DNDEBUG -+OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /nologo /MP$(CPU_COUNT) /EHsc /FC /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DNDEBUG - !ELSE --OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /nologo /MP$(CPU_COUNT) /MDd /EHsc /FC /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DDEBUG -+OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /nologo /MP$(CPU_COUNT) /EHsc /FC /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DDEBUG - !ENDIF - !ENDIF # OPTFLAGS - diff --git a/recipes/gdal/all/patches/3.1.x/makefile-mitigate-long-line.patch b/recipes/gdal/all/patches/3.1.x/makefile-mitigate-long-line.patch deleted file mode 100644 index 89ff8cc7c166f..0000000000000 --- a/recipes/gdal/all/patches/3.1.x/makefile-mitigate-long-line.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/GNUmakefile -+++ b/GNUmakefile -@@ -64,8 +64,17 @@ $(GDAL_SLIB): $(GDAL_OBJ) $(GDAL_LIB) - $(LD_SHARED) $(GDAL_SLIB_SONAME) $(GDAL_OBJ) $(GDAL_LIBS) $(LDFLAGS) $(LIBS) \ - -o $(GDAL_SLIB) - -+# split potentially long lines -+SORTED := $(sort $(wildcard $(GDAL_OBJ:.o=.lo))) -+NSORTED := $(words $(SORTED)) -+# mid left and right indices -+MIDL := $(shell echo $$(( $(NSORTED) / 2 )) ) -+MIDR := $(shell echo $$(( $(MIDL) + 1 )) ) -+ - $(LIBGDAL): $(GDAL_OBJ:.o=.lo) -- $(LD) $(LDFLAGS) $(LIBS) -o $@ $(sort $(wildcard $(GDAL_OBJ:.o=.lo))) \ -+ $(LD) $(LDFLAGS) $(LIBS) -o $@ \ -+ $(wordlist 1,$(MIDL),$(SORTED)) \ -+ $(wordlist $(MIDR),$(words $(SORTED)),$(SORTED)) \ - -rpath $(INST_LIB) \ - -no-undefined \ - -version-info $(LIBGDAL_CURRENT):$(LIBGDAL_REVISION):$(LIBGDAL_AGE) diff --git a/recipes/gdal/all/patches/3.1.x/ogrflatgeobuflayer-stdexcept.patch b/recipes/gdal/all/patches/3.1.x/ogrflatgeobuflayer-stdexcept.patch deleted file mode 100644 index f6fcc720c582a..0000000000000 --- a/recipes/gdal/all/patches/3.1.x/ogrflatgeobuflayer-stdexcept.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/ogr/ogrsf_frmts/flatgeobuf/ogrflatgeobuflayer.cpp -+++ b/ogr/ogrsf_frmts/flatgeobuf/ogrflatgeobuflayer.cpp -@@ -39,6 +39,7 @@ - #include "geometrywriter.h" - - #include -+#include - - using namespace flatbuffers; - using namespace FlatGeobuf; diff --git a/recipes/gdal/all/patches/3.2.x/fix-ogrelasticlayer-gcc-less-5.patch b/recipes/gdal/all/patches/3.2.x/fix-ogrelasticlayer-gcc-less-5.patch deleted file mode 100644 index 068b28648aa92..0000000000000 --- a/recipes/gdal/all/patches/3.2.x/fix-ogrelasticlayer-gcc-less-5.patch +++ /dev/null @@ -1,43 +0,0 @@ -Fix compilation failure in elastic driver with gcc < 5 in GDAL 3.2.1 -patch from https://github.com/OSGeo/gdal/pull/3440 - ---- a/ogr/ogrsf_frmts/elastic/ogrelasticlayer.cpp -+++ b/ogr/ogrsf_frmts/elastic/ogrelasticlayer.cpp -@@ -3507,21 +3507,16 @@ OGRErr OGRElasticLayer::GetExtent(int iGeomField, OGREnvelope *psExtent, int bFo - return OGRERR_FAILURE; - } - -- const auto DefaultGetExtent = [this, iGeomField, psExtent, bForce]() -- { -- m_bUseSingleQueryParams = true; -- const auto eRet = OGRLayer::GetExtentInternal(iGeomField, psExtent, bForce); -- m_bUseSingleQueryParams = false; -- return eRet; -- }; -- - // geo_shape aggregation is only available since ES 7.8, but only with XPack - // for now - if( !m_abIsGeoPoint[iGeomField] && - !(m_poDS->m_nMajorVersion > 7 || - (m_poDS->m_nMajorVersion == 7 && m_poDS->m_nMinorVersion >= 8)) ) - { -- return DefaultGetExtent(); -+ m_bUseSingleQueryParams = true; -+ const auto eRet = OGRLayer::GetExtentInternal(iGeomField, psExtent, bForce); -+ m_bUseSingleQueryParams = false; -+ return eRet; - } - - CPLString osFilter = CPLSPrintf("{ \"size\": 0, \"aggs\" : { \"bbox\" : { \"geo_bounds\" : { \"field\" : \"%s\" } } } }", -@@ -3564,7 +3559,10 @@ OGRErr OGRElasticLayer::GetExtent(int iGeomField, OGREnvelope *psExtent, int bFo - if( poTopLeftLon == nullptr || poTopLeftLat == nullptr || - poBottomRightLon == nullptr || poBottomRightLat == nullptr ) - { -- eErr = DefaultGetExtent(); -+ m_bUseSingleQueryParams = true; -+ const auto eRet = OGRLayer::GetExtentInternal(iGeomField, psExtent, bForce); -+ m_bUseSingleQueryParams = false; -+ return eRet; - } - else - { diff --git a/recipes/gdal/all/test_package/CMakeLists.txt b/recipes/gdal/all/test_package/CMakeLists.txt deleted file mode 100644 index 6f7213d81cf1b..0000000000000 --- a/recipes/gdal/all/test_package/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(GDAL REQUIRED) - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} GDAL::GDAL) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) - -add_executable(${PROJECT_NAME}_c test_package.c) -target_link_libraries(${PROJECT_NAME}_c GDAL::GDAL) diff --git a/recipes/gdal/all/test_package/conanfile.py b/recipes/gdal/all/test_package/conanfile.py deleted file mode 100644 index aa34b054f40a6..0000000000000 --- a/recipes/gdal/all/test_package/conanfile.py +++ /dev/null @@ -1,20 +0,0 @@ -import os - -from conans import ConanFile, CMake, tools - -class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self.settings): - self.run("gdal_translate --formats", run_environment=True) - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - bin_path_c = os.path.join("bin", "test_package_c") - self.run(bin_path_c, run_environment=True) diff --git a/recipes/gdal/config.yml b/recipes/gdal/config.yml index 8645bbf5c7551..3a324b7465d34 100644 --- a/recipes/gdal/config.yml +++ b/recipes/gdal/config.yml @@ -1,9 +1,15 @@ versions: - "3.1.0": - folder: all - "3.1.2": - folder: all + "3.5.2": + folder: "post_3.5.0" + "3.5.1": + folder: "post_3.5.0" + "3.4.3": + folder: "pre_3.5.0" + "3.4.1": + folder: "pre_3.5.0" + "3.3.3": + folder: "pre_3.5.0" + "3.2.3": + folder: "pre_3.5.0" "3.1.4": - folder: all - "3.2.1": - folder: all + folder: "pre_3.5.0" diff --git a/recipes/gdal/post_3.5.0/CMakeLists.txt b/recipes/gdal/post_3.5.0/CMakeLists.txt new file mode 100644 index 0000000000000..c0e666f41f1de --- /dev/null +++ b/recipes/gdal/post_3.5.0/CMakeLists.txt @@ -0,0 +1,117 @@ +cmake_minimum_required(VERSION 3.15) +project(gdal_cmake_wrapper) + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +include(CMakePushCheckState) + + +if (${GDAL_USE_POPPLER}) + find_package(poppler) + set(Poppler_VERSION_STRING ${poppler_VERSION}) + add_library(Poppler::Poppler ALIAS poppler::libpoppler) +endif() + +file(GLOB CONAN_GENERATED_CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Find*.cmake") +foreach(CMAKE_FILE ${CONAN_GENERATED_CMAKE_FILES}) + include(${CMAKE_FILE}) +endforeach() + +if (${GDAL_USE_ARROW}) + find_package(Arrow REQUIRED) + add_library(arrow_shared ALIAS arrow::arrow) +endif() + +if (${GDAL_USE_CRYPTOPP}) + find_package(cryptopp REQUIRED) + add_library(CRYPTOPP::CRYPTOPP ALIAS cryptopp::cryptopp-static) +endif() + +if (${GDAL_USE_DEFLATE}) + find_package(libdeflate REQUIRED) + add_library(Deflate::Deflate ALIAS libdeflate::libdeflate) +endif() + +if (${GDAL_USE_LZ4}) + find_package(lz4 REQUIRED) + add_library(LZ4::LZ4 ALIAS lz4::lz4) +endif() + +if (${GDAL_USE_BLOSC}) + find_package(c-blosc REQUIRED) + add_library(Blosc::Blosc ALIAS c-blosc::c-blosc) +endif() + +if (${GDAL_USE_OPENEXR}) + find_package(Imath REQUIRED) + find_package(OpenEXR REQUIRED) + add_library(OpenEXR::IlmImf ALIAS OpenEXR::IlmThread) + add_library(OpenEXR::IlmImfUtil ALIAS OpenEXR::OpenEXR) + add_library(OpenEXR::Half ALIAS Imath::Imath) + # gdal includes without "Imath/" folder prefix + target_include_directories(Imath::Imath INTERFACE ${Imath_INCLUDE_DIR}) + # and also without "OpenEXR/" prefix + target_include_directories(OpenEXR::OpenEXR INTERFACE ${OpenEXR_INCLUDE_DIR}) +endif() + +if (${GDAL_USE_FREEXL}) + find_package(freexl REQUIRED) + add_library(FREEXL::freexl ALIAS freexl::freexl) +endif() + +if (${GDAL_USE_OPENJPEG}) + add_library(OPENJPEG::OpenJPEG ALIAS OpenJPEG::OpenJPEG) +endif() + +if (${GDAL_USE_GIF}) + find_package(GIF REQUIRED) +endif() + +if (${GDAL_USE_CFITSIO}) + find_package(cfitsio) + add_library(CFITSIO::CFITSIO ALIAS cfitsio::cfitsio) +endif() + +if (${GDAL_USE_SQLITE3}) + find_package(SQLite3) +endif() + +if (${GDAL_USE_LIBXML2}) + find_package(LibXml2) +endif() + +if (${GDAL_USE_POSTGRESQL}) + find_package(PostgreSQL) + add_library(PostgreSQL::PostgreSQL ALIAS PostgreSQL::pq) +endif() + +if (${GDAL_USE_HDF5}) + find_package(HDF5) + set(HDF5_C_LIBRARIES HDF5::C) +endif() + +if ("${GDAL_CONAN_PACKAGE_FOR_MYSQL}" STREQUAL "libmysqlclient") + find_package(mysql REQUIRED) +endif() +if ("${GDAL_CONAN_PACKAGE_FOR_MYSQL}" STREQUAL "mariadb-connector-c") + find_package(mariadb-connector-c REQUIRED) +endif() + +if (${GDAL_USE_ZLIB}) + find_package(ZLIB) +endif() + +if ("${GDAL_CONAN_PACKAGE_FOR_JPEG}" STREQUAL "libjpeg-turbo") + find_package(libjpeg-turbo REQUIRED) + add_library(JPEG::JPEG ALIAS ${TARGET_FOR_JPEG}) +endif() + +if (${GDAL_USE_PCRE2}) + find_package(PCRE2 REQUIRED) + add_library(PCRE2::PCRE2-8 ALIAS PCRE2::8BIT) +endif() + + +add_subdirectory("source_subfolder") diff --git a/recipes/gdal/post_3.5.0/conandata.yml b/recipes/gdal/post_3.5.0/conandata.yml new file mode 100644 index 0000000000000..2dbc2d17b374f --- /dev/null +++ b/recipes/gdal/post_3.5.0/conandata.yml @@ -0,0 +1,14 @@ +sources: + "3.5.2": + url: "https://github.com/OSGeo/gdal/releases/download/v3.5.2/gdal-3.5.2.tar.gz" + sha256: "fbd696e1b2a858fbd2eb3718db16b14ed9ba82521d3578770d480c74fe1146d2" + "3.5.1": + url: "https://github.com/OSGeo/gdal/releases/download/v3.5.1/gdal-3.5.1.tar.gz" + sha256: "7c4406ca010dc8632703a0a326f39e9db25d9f1f6ebaaeca64a963e3fac123d1" +patches: + "3.5.2": + - patch_file: "patches/3.5.2/0-replace-find-package.patch" + base_path: "source_subfolder" + "3.5.1": + - patch_file: "patches/3.5.1/0-replace-find-package.patch" + base_path: "source_subfolder" diff --git a/recipes/gdal/post_3.5.0/conanfile.py b/recipes/gdal/post_3.5.0/conanfile.py new file mode 100644 index 0000000000000..d03de4e5125cc --- /dev/null +++ b/recipes/gdal/post_3.5.0/conanfile.py @@ -0,0 +1,899 @@ +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, get, files +from conan.errors import ConanInvalidConfiguration +from conans import CMake +import functools +import os + +class GdalConan(ConanFile): + name = "gdal" + description = "GDAL is an open source X/MIT licensed translator library " \ + "for raster and vector geospatial data formats." + license = "MIT" + topics = ("osgeo", "geospatial", "raster", "vector") + homepage = "https://github.com/OSGeo/gdal" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + + generators = "cmake", "cmake_find_package", "cmake_find_package_multi" + + # A list of gdal dependencies can be taken from cmake/helpers/CheckDependentLibraries.cmake + # within gdal sources with the command: + # grep -E '^[ \t]*gdal_check_package\(' cmake/helpers/CheckDependentLibraries.cmake \ + # | sed 's/[ \t]*gdal_check_package(\([a-zA-Z_0-9]\+\) "\(.*\)"\(.*\)/{ 'dep': \'\1\', 'descr': \'\2\' },/' \ + # | sort | uniq + + options = { + "shared": [True, False], + "fPIC": [True, False], + "tools": [True, False], + "with_armadillo": [True, False], + "with_arrow": [True, False], + "with_blosc": [True, False], + "with_cfitsio": [True, False], + # with_cypto option has been renamed with_openssl in version 3.5.1 + "with_crypto": [True, False, "deprecated"], + "with_cryptopp": [True, False], + "with_curl": [True, False], + "with_dds": [True, False], + "with_expat": [True, False], + "with_exr": [True, False], + "with_freexl": [True, False], + "with_geos": [True, False], + "with_gif": [True, False], + "with_gta": [True, False], + "with_hdf4": [True, False], + "with_hdf5": [True, False], + "with_heif": [True, False], + "with_kea": [True, False], + "with_libdeflate": [True, False], + "with_libiconv": [True, False], + "with_jpeg": [None, "libjpeg", "libjpeg-turbo"], + "with_libkml": [True, False], + "with_libtiff": [True, False], + "with_lz4": [True, False], + "with_mongocxx": [True, False], + "with_mysql": [None, "libmysqlclient", "mariadb-connector-c"], + "with_netcdf": [True, False], + "with_odbc": [True, False], + "with_openjpeg": [True, False], + "with_openssl": [True, False], + "with_pcre": [True, False], + "with_pcre2": [True, False], + "with_pg": [True, False], + "with_png": [True, False], + "with_podofo": [True, False], + "with_poppler": [True, False], + "with_proj": [True, False], + "with_qhull": [True, False], + "with_sqlite3": [True, False], + "with_webp": [True, False], + "with_xerces": [True, False], + "with_xml2": [True, False], + "with_zlib": [True, False], + "with_zstd": [True, False], + } + + default_options = { + "shared": False, + "fPIC": True, + "tools": False, + "with_armadillo": False, + "with_arrow": False, + "with_blosc": False, + "with_cfitsio": False, + "with_crypto": "deprecated", + "with_cryptopp": False, + "with_curl": False, + "with_dds": False, + "with_expat": False, + "with_exr": False, + "with_freexl": False, + "with_geos": True, + "with_gif": True, + "with_gta": False, + "with_hdf4": False, + "with_hdf5": False, + "with_heif": False, + "with_kea": False, + "with_libdeflate": True, + "with_libiconv": True, + "with_jpeg": "libjpeg", + "with_libkml": False, + "with_libtiff": True, + "with_lz4": False, + "with_mongocxx": False, + "with_mysql": None, + "with_netcdf": False, + "with_odbc": False, + "with_openjpeg": False, + "with_openssl": False, + "with_pcre": False, + "with_pcre2": False, + "with_pg": False, + "with_png": True, + "with_podofo": False, + "with_poppler": False, + "with_proj": True, + "with_qhull": True, + "with_sqlite3": True, + "with_webp": False, + "with_xerces": False, + "with_xml2": False, + "with_zlib": True, + "with_zstd": False, + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.with_crypto != "deprecated": + self.output.error("with_crypto option is deprecated, use with_openssl instead.") + + if self.options.shared: + try: + del self.options.fPIC + except: + pass + + def requirements(self): + self.requires("json-c/0.16") + self.requires("libgeotiff/1.7.1") + + if self.options.with_armadillo: + self.requires("armadillo/10.7.3") + + if self.options.with_arrow: + self.requires("arrow/8.0.1") + + if self.options.with_blosc: + self.requires("c-blosc/1.21.1") + + if self.options.with_cfitsio: + self.requires("cfitsio/4.1.0") + + if self.options.with_cryptopp: + self.requires("cryptopp/8.7.0") + + if self.options.with_curl: + self.requires("libcurl/7.85.0") + + if self.options.with_dds: + self.requires("crunch/cci.20190615") + + if self.options.with_expat: + self.requires("expat/2.4.9") + + if self.options.with_exr: + self.requires("openexr/3.1.5") + self.requires("imath/3.1.5") + + if self.options.with_freexl: + self.requires("freexl/1.0.6") + + if self.options.with_geos: + self.requires("geos/3.11.0") + + if self.options.with_gif: + self.requires("giflib/5.2.1") + + if self.options.with_gta: + self.requires("libgta/1.2.1") + + if self.options.with_hdf4: + self.requires("hdf4/4.2.15") + + if self.options.with_hdf5: + self.requires("hdf5/1.13.1") + + if self.options.with_heif: + self.requires("libheif/1.13.0") + + if self.options.with_jpeg == "libjpeg": + self.requires("libjpeg/9e") + elif self.options.with_jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/2.1.4") + + if self.options.with_kea: + self.requires("kealib/1.4.14") + + if self.options.with_libdeflate: + self.requires("libdeflate/1.12") + + if self.options.with_libiconv: + self.requires("libiconv/1.17") + + if self.options.with_libkml: + self.requires("libkml/1.3.0") + + if self.options.with_libtiff: + self.requires("libtiff/4.4.0") + + if self.options.with_lz4: + self.requires("lz4/1.9.4") + + if self.options.with_mongocxx: + self.requires("mongo-cxx-driver/3.6.7") + + if self.options.with_mysql == "libmysqlclient": + self.requires("libmysqlclient/8.0.30") + elif self.options.with_mysql == "mariadb-connector-c": + self.requires("mariadb-connector-c/3.1.12") + + if self.options.with_netcdf: + self.requires("netcdf/4.8.1") + + if self.options.with_odbc: + self.requires("odbc/2.3.11") + + if self.options.with_openjpeg: + self.requires("openjpeg/2.5.0") + + if self.options.with_openssl: + self.requires("openssl/1.1.1q") + + if self.options.with_pcre: + self.requires("pcre/8.45") + + if self.options.with_pcre2: + self.requires("pcre2/10.40") + + if self.options.with_pg: + self.requires("libpq/14.5") + + if self.options.with_png: + self.requires("libpng/1.6.38") + + if self.options.with_podofo: + self.requires("podofo/0.9.7") + + if self.options.with_poppler: + self.requires("poppler/21.07.0") + + if self.options.with_proj: + self.requires("proj/9.0.1") + + if self.options.with_qhull: + self.requires("qhull/8.0.1") + + if self.options.with_sqlite3: + self.requires("sqlite3/3.39.3") + + if self.options.with_webp: + self.requires("libwebp/1.2.4") + + if self.options.with_xerces: + self.requires("xerces-c/3.2.3") + + if self.options.with_xml2: + self.requires("libxml2/2.9.14") + + if self.options.with_zlib: + self.requires("zlib/1.2.12") + + if self.options.with_zstd: + self.requires("zstd/1.5.2") + + def package_id(self): + del self.info.options.with_crypto + + def validate(self): + if self.options.get_safe("with_pcre") and self.options.get_safe("with_pcre2"): + raise ConanInvalidConfiguration("Enable either pcre or pcre2, not both") + + if self.options.get_safe("with_sqlite3") and not self.options["sqlite3"].enable_column_metadata: + raise ConanInvalidConfiguration("gdql requires sqlite3:enable_column_metadata=True") + + if self.options.get_safe("with_libtiff") and self.options["libtiff"].jpeg != self.options.get_safe("with_jpeg"): + msg = "libtiff:jpeg and gdal:with_jpeg must be set to the same value, either libjpeg or libjpeg-turbo." + # For some reason, the ConanInvalidConfiguration message is not shown, only + # ERROR: At least two recipes provides the same functionality: + # - 'libjpeg' provided by 'libjpeg-turbo/2.1.2', 'libjpeg/9d' + # So we print the error message manually. + self.output.error(msg) + raise ConanInvalidConfiguration(msg) + + if self.options.get_safe("with_poppler") and self.options["poppler"].with_libjpeg != self.options.get_safe("with_jpeg"): + msg = "poppler:with_libjpeg and gdal:with_jpeg must be set to the same value, either libjpeg or libjpeg-turbo." + self.output.error(msg) + raise ConanInvalidConfiguration(msg) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + + if self.options.get_safe("fPIC", True): + cmake.definitions[ + "GDAL_OBJECT_LIBRARIES_POSITION_INDEPENDENT_CODE"] = True + + cmake.definitions["BUILD_JAVA_BINDINGS"] = False + cmake.definitions["BUILD_CSHARP_BINDINGS"] = False + cmake.definitions["BUILD_PYTHON_BINDINGS"] = False + + cmake.definitions["BUILD_TESTING"] = False + cmake.definitions["GDAL_USE_ZLIB_INTERNAL"] = False + cmake.definitions["GDAL_USE_JSONC_INTERNAL"] = False + cmake.definitions["GDAL_USE_JPEG_INTERNAL"] = False + cmake.definitions["GDAL_USE_JPEG12_INTERNAL"] = False + cmake.definitions["GDAL_USE_TIFF_INTERNAL"] = False + cmake.definitions["GDAL_USE_GEOTIFF_INTERNAL"] = False + cmake.definitions["GDAL_USE_GIF_INTERNAL"] = False + cmake.definitions["GDAL_USE_PNG_INTERNAL"] = False + + cmake.definitions["GDAL_USE_LERC_INTERNAL"] = True + cmake.definitions["GDAL_USE_SHAPELIB_INTERNAL"] = True + + cmake.definitions["BUILD_APPS"] = self.options.tools + + cmake.definitions["SQLite3_HAS_COLUMN_METADATA"] = \ + self.options["sqlite3"].enable_column_metadata + + cmake.definitions["SQLite3_HAS_RTREE"] = self.options[ + "sqlite3"].enable_rtree + + cmake.definitions["GDAL_USE_JSONC"] = True + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_JSONC"] = "json-c" + + cmake.definitions["GDAL_USE_GEOTIFF"] = True + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_GEOTIFF"] = "libgeotiff" + cmake.definitions["TARGET_FOR_GEOTIFF"] = "GeoTIFF::GeoTIFF" + + cmake.definitions["GDAL_USE_ARMADILLO"] = self.options.with_armadillo + if self.options.with_armadillo: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_ARMADILLO"] = "armadillo" + cmake.definitions["TARGET_FOR_ARMADILLO"] = \ + self.dependencies["armadillo"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["Armadillo_FOUND"] = False + + cmake.definitions["GDAL_USE_ARROW"] = self.options.with_arrow + if self.options.with_arrow: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_ARROW"] = "arrow" + cmake.definitions["TARGET_FOR_ARROW"] = \ + self.dependencies["arrow"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["Arrow_FOUND"] = False + + cmake.definitions["GDAL_USE_BLOSC"] = self.options.with_blosc + if self.options.with_blosc: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_BLOSC"] = "c-blosc" + cmake.definitions["TARGET_FOR_BLOSC"] = \ + self.dependencies["c-blosc"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["Blosc_FOUND"] = False + + cmake.definitions["GDAL_USE_CFITSIO"] = self.options.with_cfitsio + if self.options.with_cfitsio: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_CFITSIO"] = "cfitsio" + cmake.definitions["TARGET_FOR_CFITSIO"] = \ + self.dependencies["cfitsio"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["CFITSIO_FOUND"] = False + + cmake.definitions["GDAL_USE_CRYPTOPP"] = self.options.with_cryptopp + if self.options.with_cryptopp: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_CRYPTOPP"] = "cryptopp" + cmake.definitions["TARGET_FOR_CRYPTOPP"] = \ + self.dependencies["cryptopp"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["CryptoPP_FOUND"] = False + + cmake.definitions["GDAL_USE_CURL"] = self.options.with_curl + if self.options.with_curl: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_CURL"] = "libcurl" + cmake.definitions["TARGET_FOR_CURL"] = \ + self.dependencies["libcurl"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["CURL_FOUND"] = False + + cmake.definitions["GDAL_USE_CRNLIB"] = self.options.with_dds + if self.options.with_dds: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_CRNLIB"] = "crunch" + cmake.definitions["TARGET_FOR_CRNLIB"] = \ + self.dependencies["crunch"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["Crnlib_FOUND"] = False + + cmake.definitions["GDAL_USE_EXPAT"] = self.options.with_expat + if self.options.with_expat: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_EXPAT"] = "expat" + cmake.definitions["TARGET_FOR_EXPAT"] = "EXPAT::EXPAT" + else: + cmake.definitions["EXPAT_FOUND"] = False + + cmake.definitions["GDAL_USE_OPENEXR"] = self.options.with_exr + if self.options.with_exr: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_OPENEXR"] = "openexr" + cmake.definitions["TARGET_FOR_OPENEXR"] = \ + self.dependencies["openexr"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["OpenEXR_FOUND"] = False + + cmake.definitions["GDAL_USE_FREEXL"] = self.options.with_freexl + if self.options.with_freexl: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_FREEXL"] = "freexl" + cmake.definitions["TARGET_FOR_FREEXL"] = "freexl::freexl" + else: + cmake.definitions["FreeXL_FOUND"] = False + + cmake.definitions["GDAL_USE_GEOS"] = self.options.with_geos + if self.options.with_geos: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_GEOS"] = "geos" + cmake.definitions["TARGET_FOR_GEOS"] = \ + self.dependencies["geos"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["GEOS_FOUND"] = False + + cmake.definitions["GDAL_USE_GIF"] = self.options.with_gif + if self.options.with_gif: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_GIF"] = "giflib" + cmake.definitions["TARGET_FOR_GIF"] = \ + self.dependencies["giflib"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["GIF_FOUND"] = False + + cmake.definitions["GDAL_USE_GTA"] = self.options.with_gta + if self.options.with_gta: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_GTA"] = "libgta" + cmake.definitions["TARGET_FOR_GTA"] = \ + self.dependencies["libgta"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["GTA_FOUND"] = False + + cmake.definitions["GDAL_USE_HDF4"] = self.options.with_hdf4 + if self.options.with_hdf4: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_HDF4"] = "hdf4" + cmake.definitions["TARGET_FOR_HDF4"] = \ + self.dependencies["hdf4"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["HDF4_FOUND"] = False + + cmake.definitions["GDAL_USE_HDF5"] = self.options.with_hdf5 + if self.options.with_hdf5: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_HDF5"] = "hdf5" + cmake.definitions["TARGET_FOR_HDF5"] = \ + self.dependencies["hdf5"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["HDF5_FOUND"] = False + + cmake.definitions["GDAL_USE_HEIF"] = self.options.with_heif + if self.options.with_heif: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_HEIF"] = "libheif" + cmake.definitions["TARGET_FOR_HEIF"] = \ + self.dependencies["libheif"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["HEIF_FOUND"] = False + + cmake.definitions["GDAL_USE_KEA"] = self.options.with_kea + if self.options.with_kea: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_KEA"] = "kealib" + cmake.definitions["TARGET_FOR_KEA"] = \ + self.dependencies["kealib"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["KEA_FOUND"] = False + + cmake.definitions["GDAL_USE_DEFLATE"] = self.options.with_libdeflate + if self.options.with_libdeflate: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_DEFLATE"] = "libdeflate" + cmake.definitions["TARGET_FOR_DEFLATE"] = \ + self.dependencies["libdeflate"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["Deflate_FOUND"] = False + + cmake.definitions["GDAL_USE_ICONV"] = self.options.with_libiconv + if self.options.with_libiconv: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_ICONV"] = "libiconv" + cmake.definitions["TARGET_FOR_ICONV"] = \ + self.dependencies["libiconv"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["Iconv_FOUND"] = False + + if self.options.with_jpeg == "libjpeg" or self.options.with_jpeg == "libjpeg-turbo": + print(f'self.options.with_jpeg: {self.options.with_jpeg}') + cmake.definitions["GDAL_USE_JPEG"] = True + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_JPEG"] = self.options.with_jpeg + cmake.definitions["TARGET_FOR_JPEG"] = ( + "JPEG::JPEG" if self.options.with_jpeg == "libjpeg" else + self.dependencies["libjpeg-turbo"].cpp_info.components["turbojpeg"] \ + .get_property("cmake_target_name")) + else: + cmake.definitions["JPEG_FOUND"] = False + + cmake.definitions["GDAL_USE_LIBKML"] = self.options.with_libkml + if self.options.with_libkml: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_LIBKML"] = "libkml" + cmake.definitions["TARGET_FOR_LIBKML"] = \ + self.dependencies["libkml"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["LibKML_FOUND"] = False + + cmake.definitions["GDAL_USE_TIFF"] = self.options.with_libtiff + if self.options.with_libtiff: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_TIFF"] = "libtiff" + cmake.definitions["TARGET_FOR_TIFF"] = \ + self.dependencies["libtiff"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["TIFF_FOUND"] = False + + cmake.definitions["GDAL_USE_LZ4"] = self.options.with_lz4 + if self.options.with_lz4: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_LZ4"] = "lz4" + cmake.definitions["TARGET_FOR_LZ4"] = \ + self.dependencies["lz4"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["LZ4_FOUND"] = False + + cmake.definitions["GDAL_USE_MONGOCXX"] = self.options.with_mongocxx + if self.options.with_mongocxx: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_MONGOCXX"] = "mongo-cxx-driver" + cmake.definitions["TARGET_FOR_MONGOCXX"] = \ + self.dependencies["mongo-cxx-driver"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["MONGOCXX_FOUND"] = False + + if self.options.with_mysql == "libmysqlclient" or self.options.with_mysql == "mariadb-connector-c": + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_MYSQL"] = str(self.options.with_mysql) + cmake.definitions["TARGET_FOR_MYSQL"] = \ + "mariadb-connector-c::mariadb-connector-c" \ + if self.options.with_mysql == "mariadb-connector-c" \ + else "libmysqlclient::libmysqlclient" + else: + cmake.definitions["MYSQL_FOUND"] = False + + cmake.definitions["GDAL_USE_NETCDF"] = self.options.with_netcdf + if self.options.with_netcdf: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_NETCDF"] = "netcdf" + cmake.definitions["TARGET_FOR_NETCDF"] = \ + self.dependencies["netcdf"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["NetCDF_FOUND"] = False + + cmake.definitions["GDAL_USE_ODBC"] = self.options.with_odbc + if self.options.with_odbc: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_ODBC"] = "odbc" + cmake.definitions["TARGET_FOR_ODBC"] = \ + self.dependencies["odbc"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["ODBC_FOUND"] = False + + cmake.definitions["GDAL_USE_OPENJPEG"] = self.options.with_openjpeg + if self.options.with_openjpeg: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_OPENJPEG"] = "openjpeg" + cmake.definitions["TARGET_FOR_OPENJPEG"] = \ + self.dependencies["openjpeg"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["OPENJPEG_FOUND"] = False + + cmake.definitions["GDAL_USE_OPENSSL"] = self.options.with_openssl + if self.options.with_openssl: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_OPENSSL"] = "openssl" + cmake.definitions["TARGET_FOR_OPENSSL"] = \ + self.dependencies["openssl"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["OpenSSL_FOUND"] = False + + cmake.definitions["GDAL_USE_PCRE"] = self.options.with_pcre + if self.options.with_pcre: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_PCRE"] = "pcre" + cmake.definitions["TARGET_FOR_PCRE"] = \ + self.dependencies["pcre"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["PCRE_FOUND"] = False + + cmake.definitions["GDAL_USE_PCRE2"] = self.options.with_pcre2 + if self.options.with_pcre2: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_PCRE2"] = "pcre2" + cmake.definitions["TARGET_FOR_PCRE2"] = \ + self.dependencies["pcre2"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["PCRE2_FOUND"] = False + + cmake.definitions["GDAL_USE_PDFIUM"] = False + cmake.definitions["PDFIUM_FOUND"] = False + + cmake.definitions["GDAL_USE_POSTGRESQL"] = self.options.with_pg + if self.options.with_pg: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_POSTGRESQL"] = "libpq" + cmake.definitions["TARGET_FOR_POSTGRESQL"] = \ + self.dependencies["libpq"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["PostgreSQL_FOUND"] = False + + cmake.definitions["GDAL_USE_PNG"] = self.options.with_png + if self.options.with_png: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_PNG"] = "libpng" + cmake.definitions["TARGET_FOR_PNG"] = \ + self.dependencies["libpng"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["PNG_FOUND"] = False + + cmake.definitions["GDAL_USE_PODOFO"] = self.options.with_podofo + if self.options.with_podofo: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_PODOFO"] = "podofo" + cmake.definitions["TARGET_FOR_PODOFO"] = \ + self.dependencies["podofo"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["Podofo_FOUND"] = False + + cmake.definitions["GDAL_USE_POPPLER"] = self.options.with_poppler + if self.options.with_poppler: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_POPPLER"] = "poppler" + cmake.definitions["TARGET_FOR_POPPLER"] = \ + self.dependencies["poppler"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["Poppler_FOUND"] = False + + cmake.definitions["GDAL_USE_PROJ"] = self.options.with_proj + if self.options.with_proj: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_PROJ"] = "proj" + cmake.definitions["TARGET_FOR_PROJ"] = \ + self.dependencies["proj"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["PROJ_FOUND"] = False + + cmake.definitions["GDAL_USE_QHULL"] = self.options.with_qhull + if self.options.with_qhull: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_QHULL"] = "qhull" + cmake.definitions["TARGET_FOR_QHULL"] = \ + self.dependencies["qhull"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["QHULL_FOUND"] = False + + cmake.definitions["GDAL_USE_SQLITE3"] = self.options.with_sqlite3 + if self.options.with_sqlite3: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_SQLITE3"] = "sqlite3" + cmake.definitions["TARGET_FOR_SQLITE3"] = \ + self.dependencies["sqlite3"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["SQLite3_FOUND"] = False + + cmake.definitions["GDAL_USE_WEBP"] = self.options.with_webp + if self.options.with_webp: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_WEBP"] = "libwebp" + cmake.definitions["TARGET_FOR_WEBP"] = \ + self.dependencies["libwebp"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["WebP_FOUND"] = False + + cmake.definitions["GDAL_USE_XERCESC"] = self.options.with_xerces + if self.options.with_xerces: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_XERCESC"] = "xerces-c" + cmake.definitions["TARGET_FOR_XERCESC"] = \ + self.dependencies["xerces-c"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["XercesC_FOUND"] = False + + cmake.definitions["GDAL_USE_LIBXML2"] = self.options.with_xml2 + if self.options.with_xml2: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_LIBXML2"] = "libxml2" + cmake.definitions["TARGET_FOR_LIBXML2"] = \ + self.dependencies["libxml2"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["LibXml2_FOUND"] = False + + cmake.definitions["GDAL_USE_ZLIB"] = self.options.with_zlib + if self.options.with_zlib: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_ZLIB"] = "zlib" + cmake.definitions["TARGET_FOR_ZLIB"] = \ + self.dependencies["zlib"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["ZLIB_FOUND"] = False + + cmake.definitions["GDAL_USE_ZSTD"] = self.options.with_zstd + if self.options.with_zstd: + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_ZSTD"] = "zstd" + cmake.definitions["TARGET_FOR_ZSTD"] = \ + self.dependencies["zstd"].cpp_info.get_property("cmake_target_name") + else: + cmake.definitions["ZSTD_FOUND"] = False + + + for k, v in cmake.definitions.items(): + print(k, " = ", v) + + cmake.configure(build_folder=self._build_subfolder) + return cmake + + def build(self): + apply_conandata_patches(self) + cmake = self._configure_cmake() + + cmake.build() + + def package(self): + self.copy("LICENSE.TXT", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + files.rmdir(self, os.path.join(self.package_folder, "share")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + + self.cpp_info.set_property("cmake_file_name", "GDAL") + self.cpp_info.set_property("cmake_target_name", "GDAL::GDAL") + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("pkg_config_name", "gdal") + + self.cpp_info.names["cmake_find_package"] = "GDAL" + self.cpp_info.names["cmake_find_package_multi"] = "GDAL" + self.cpp_info.filenames["cmake_find_package"] = "GDAL" + self.cpp_info.filenames["cmake_find_package_multi"] = "GDAL" + + libname = "gdal" + if self.settings.os == "Windows": + if self.settings.build_type == "Debug": + libname += "d" + self.cpp_info.libs = [ libname ] + + self.cpp_info.requires.extend(['json-c::json-c']) + self.cpp_info.requires.extend(['libgeotiff::libgeotiff']) + + if self.options.with_armadillo: + self.cpp_info.requires.extend(['armadillo::armadillo']) + + if self.options.with_arrow: + self.cpp_info.requires.extend(['arrow::libarrow']) + + if self.options.with_blosc: + self.cpp_info.requires.extend(['c-blosc::c-blosc']) + + if self.options.with_cfitsio: + self.cpp_info.requires.extend(['cfitsio::cfitsio']) + + if self.options.with_cryptopp: + self.cpp_info.requires.extend(['cryptopp::libcryptopp']) + + if self.options.with_curl: + self.cpp_info.requires.extend(['libcurl::curl']) + + if self.options.with_dds: + self.cpp_info.requires.extend(['crunch::crunch']) + + if self.options.with_expat: + self.cpp_info.requires.extend(['expat::expat']) + + if self.options.with_exr: + self.cpp_info.requires.extend(['openexr::openexr', 'imath::imath']) + + if self.options.with_freexl: + self.cpp_info.requires.extend(['freexl::freexl']) + + if self.options.with_geos: + self.cpp_info.requires.extend(['geos::geos_c']) + + if self.options.with_gif: + self.cpp_info.requires.extend(['giflib::giflib']) + + if self.options.with_gta: + self.cpp_info.requires.extend(['libgta::libgta']) + + if self.options.with_hdf4: + self.cpp_info.requires.extend(['hdf4::hdf4']) + + if self.options.with_hdf5: + self.cpp_info.requires.extend(['hdf5::hdf5_c']) + + if self.options.with_heif: + self.cpp_info.requires.extend(['libheif::libheif']) + + if self.options.with_kea: + self.cpp_info.requires.extend(['kealib::kealib']) + + if self.options.with_libdeflate: + self.cpp_info.requires.extend(['libdeflate::libdeflate']) + + if self.options.with_libiconv: + self.cpp_info.requires.extend(['libiconv::libiconv']) + + if self.options.with_jpeg == "libjpeg": + self.cpp_info.requires.extend(['libjpeg::libjpeg']) + elif self.options.with_jpeg == "libjpeg-turbo": + self.cpp_info.requires.extend(['libjpeg-turbo::turbojpeg']) + + if self.options.with_libkml: + self.cpp_info.requires.extend(['libkml::kmldom', 'libkml::kmlengine']) + + if self.options.with_libtiff: + self.cpp_info.requires.extend(['libtiff::libtiff']) + + if self.options.with_lz4: + self.cpp_info.requires.extend(['lz4::lz4']) + + if self.options.with_mongocxx: + self.cpp_info.requires.extend(['mongo-cxx-driver::mongo-cxx-driver']) + + if self.options.with_mysql == "libmysqlclient": + self.cpp_info.requires.extend(['libmysqlclient::libmysqlclient']) + elif self.options.with_mysql == "mariadb-connector-c": + self.cpp_info.requires.extend(['mariadb-connector-c::mariadb-connector-c']) + + if self.options.with_netcdf: + self.cpp_info.requires.extend(['netcdf::netcdf']) + + if self.options.with_odbc: + self.cpp_info.requires.extend(['odbc::odbc']) + + if self.options.with_openjpeg: + self.cpp_info.requires.extend(['openjpeg::openjpeg']) + + if self.options.with_openssl: + self.cpp_info.requires.extend(['openssl::ssl']) + + if self.options.with_pcre: + self.cpp_info.requires.extend(['pcre::pcre']) + + if self.options.with_pcre2: + self.cpp_info.requires.extend(['pcre2::pcre2-8']) + + if self.options.with_pg: + self.cpp_info.requires.extend(['libpq::pq']) + + if self.options.with_png: + self.cpp_info.requires.extend(['libpng::libpng']) + + if self.options.with_podofo: + self.cpp_info.requires.extend(['podofo::podofo']) + + if self.options.with_poppler: + self.cpp_info.requires.extend(['poppler::libpoppler']) + + if self.options.with_proj: + self.cpp_info.requires.extend(['proj::projlib']) + + if self.options.with_qhull: + self.cpp_info.requires.extend(['qhull::libqhull']) + + if self.options.with_sqlite3: + self.cpp_info.requires.extend(['sqlite3::sqlite']) + + if self.options.with_webp: + self.cpp_info.requires.extend(['libwebp::libwebp']) + + if self.options.with_xerces: + self.cpp_info.requires.extend(['xerces-c::xerces-c']) + + if self.options.with_xml2: + self.cpp_info.requires.extend(['libxml2::libxml2']) + + if self.options.with_zlib: + self.cpp_info.requires.extend(['zlib::zlib']) + + if self.options.with_zstd: + self.cpp_info.requires.extend(['zstd::zstdlib']) + + gdal_data_path = os.path.join(self.package_folder, "res", "gdal") + self.output.info( + "Prepending to GDAL_DATA environment variable: {}".format( + gdal_data_path)) + self.runenv_info.prepend_path("GDAL_DATA", gdal_data_path) + # TODO: to remove after conan v2, it allows to not break consumers still relying on virtualenv generator + self.env_info.GDAL_DATA = gdal_data_path + + if self.options.tools: + self.buildenv_info.prepend_path("GDAL_DATA", gdal_data_path) + bin_path = os.path.join(self.package_folder, "bin") + self.output.info( + "Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/gdal/post_3.5.0/patches/3.5.1/0-replace-find-package.patch b/recipes/gdal/post_3.5.0/patches/3.5.1/0-replace-find-package.patch new file mode 100644 index 0000000000000..e790a586d8abd --- /dev/null +++ b/recipes/gdal/post_3.5.0/patches/3.5.1/0-replace-find-package.patch @@ -0,0 +1,266 @@ +diff --git a/alg/CMakeLists.txt b/alg/CMakeLists.txt +index edf75158c7..4200309ca8 100644 +--- a/alg/CMakeLists.txt ++++ b/alg/CMakeLists.txt +@@ -72,7 +72,7 @@ if (GDAL_USE_OPENCL) + target_sources(alg PRIVATE gdalwarpkernel_opencl.h gdalwarpkernel_opencl.cpp) + endif () + +-gdal_target_link_libraries(alg PRIVATE PROJ::proj) ++target_link_libraries(alg PUBLIC PROJ::proj) + + if (GDAL_USE_QHULL_INTERNAL) + target_compile_definitions(alg PRIVATE -DINTERNAL_QHULL) +diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt +index a49165d14a..91d6170067 100644 +--- a/apps/CMakeLists.txt ++++ b/apps/CMakeLists.txt +@@ -25,7 +25,7 @@ target_include_directories( + appslib PRIVATE $ $ + $ $) + +-gdal_target_link_libraries(appslib PRIVATE PROJ::proj) ++target_link_libraries(appslib PUBLIC PROJ::proj) + + set_property(TARGET appslib PROPERTY POSITION_INDEPENDENT_CODE ${GDAL_OBJECT_LIBRARIES_POSITION_INDEPENDENT_CODE}) + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) +diff --git a/cmake/helpers/CheckDependentLibraries.cmake b/cmake/helpers/CheckDependentLibraries.cmake +index 7fa3b565c7..77a610f223 100644 +--- a/cmake/helpers/CheckDependentLibraries.cmake ++++ b/cmake/helpers/CheckDependentLibraries.cmake +@@ -11,7 +11,10 @@ Detect GDAL dependencies and set variable HAVE_* + include(CheckFunctionExists) + include(CMakeDependentOption) + include(FeatureSummary) +-include(DefineFindPackage2) ++ ++# Conan recipes should rely on config files from generators so let's just disble GDAL's ++include(ConanFindPackage) ++ + include(CheckSymbolExists) + + option( +@@ -111,47 +114,7 @@ macro (gdal_check_package name purpose) + set(_find_dependency_args "") + find_package2(${name} QUIET OUT_DEPENDENCY _find_dependency) + if (NOT DEFINED ${key}_FOUND) +- set(_find_package_args) +- if (_GCP_VERSION) +- list(APPEND _find_package_args ${_GCP_VERSION}) +- endif () +- if (_GCP_CONFIG) +- list(APPEND _find_package_args CONFIG) +- endif () +- if (_GCP_COMPONENTS) +- list(APPEND _find_package_args COMPONENTS ${_GCP_COMPONENTS}) +- endif () +- if (_GCP_PATHS) +- list(APPEND _find_package_args PATHS ${_GCP_PATHS}) +- endif () +- if (_GCP_NAMES) +- set(GDAL_CHECK_PACKAGE_${name}_NAMES "${_GCP_NAMES}" CACHE STRING "Config file name for ${name}") +- mark_as_advanced(GDAL_CHECK_PACKAGE_${name}_NAMES) +- endif () +- if (_GCP_TARGETS) +- set(GDAL_CHECK_PACKAGE_${name}_TARGETS "${_GCP_TARGETS}" CACHE STRING "Target name candidates for ${name}") +- mark_as_advanced(GDAL_CHECK_PACKAGE_${name}_TARGETS) +- endif () +- if (GDAL_CHECK_PACKAGE_${name}_NAMES) +- find_package(${name} NAMES ${GDAL_CHECK_PACKAGE_${name}_NAMES} ${_find_package_args}) +- gdal_check_package_target(${name} ${GDAL_CHECK_PACKAGE_${name}_TARGETS} REQUIRED) +- if (${name}_FOUND) +- get_filename_component(_find_dependency_args "${${name}_CONFIG}" NAME) +- string(REPLACE ";" " " _find_dependency_args "${name} NAMES ${GDAL_CHECK_PACKAGE_${name}_NAMES} CONFIGS ${_find_dependency_args} ${_find_package_args}") +- endif () +- endif () +- if (NOT ${name}_FOUND) +- find_package(${name} ${_find_package_args}) +- if (${name}_FOUND) +- gdal_check_package_target(${name} ${GDAL_CHECK_PACKAGE_${name}_TARGETS}) +- elseif (${key}_FOUND) # Some find modules do not set _FOUND +- gdal_check_package_target(${key} ${GDAL_CHECK_PACKAGE_${name}_TARGETS}) +- set(${name}_FOUND "${key}_FOUND") +- endif () +- if (${name}_FOUND) +- string(REPLACE ";" " " _find_dependency_args "${name} ${_find_package_args}") +- endif() +- endif () ++ message(FATAL_ERROR "Conan recipes should rely on config files from generators so let's just disble GDAL's") + endif () + if (${key}_FOUND OR ${name}_FOUND) + set(HAVE_${key} ON) +@@ -321,14 +284,15 @@ if (GDAL_USE_CRYPTOPP) + endif () + + # First check with CMake config files (starting at version 8, due to issues with earlier ones), and then fallback to the FindPROJ module. +-find_package(PROJ 9 CONFIG QUIET) +-if (NOT PROJ_FOUND) +- find_package(PROJ 8 CONFIG QUIET) +-endif() ++find_package2(PROJ) ++target_include_directories(PROJ::proj INTERFACE ${PROJ_INCLUDE_DIRS}) ++#if (NOT PROJ_FOUND) ++# find_package(proj 8 CONFIG QUIET) ++#endif() + if (PROJ_FOUND) + string(APPEND GDAL_IMPORT_DEPENDENCIES "find_dependency(PROJ ${PROJ_VERSION_MAJOR} CONFIG)\n") + else() +- find_package(PROJ 6.0 REQUIRED) ++ find_package(proj 6.0 REQUIRED) + string(APPEND GDAL_IMPORT_DEPENDENCIES "find_dependency(PROJ 6.0)\n") + endif () + +@@ -379,15 +343,10 @@ gdal_check_package(JSONC "json-c library (external)" CAN_DISABLE + TARGETS json-c::json-c JSONC::JSONC + ) + gdal_internal_library(JSONC REQUIRED) +-if(TARGET json-c::json-c) +- get_target_property(include_dirs json-c::json-c INTERFACE_INCLUDE_DIRECTORIES) +- find_path(GDAL_JSON_INCLUDE_DIR NAMES json.h PATHS ${include_dirs} PATH_SUFFIXES json-c NO_DEFAULT_PATH) +- list(APPEND include_dirs "${GDAL_JSON_INCLUDE_DIR}") +- list(REMOVE_DUPLICATES include_dirs) +- set_target_properties(json-c::json-c PROPERTIES +- INTERFACE_INCLUDE_DIRECTORIES "${GDAL_JSON_INCLUDE_DIR}" +- ) +-endif() ++get_target_property(include_dirs json-c::json-c INTERFACE_INCLUDE_DIRECTORIES) ++list(APPEND include_dirs "${JSONC_INCLUDE_DIRS}/json-c") ++set_target_properties(json-c::json-c PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include_dirs}") ++message("Setting include for json-c: ${include_dirs}") + + gdal_check_package(OpenCAD "libopencad (external, used by OpenCAD driver)" CAN_DISABLE) + gdal_internal_library(OPENCAD) +@@ -482,7 +441,7 @@ if (GDAL_USE_RASTERLITE2) + endif () + cmake_dependent_option(GDAL_USE_RASTERLITE2 "Set ON to use Rasterlite2" ON HAVE_RASTERLITE2 OFF) + +-find_package(LibKML COMPONENTS DOM ENGINE) ++find_package(LibKML COMPONENTS kmlengine kmldom kmlbase) + if (GDAL_USE_LIBKML) + if (NOT LibKML_FOUND) + message(FATAL_ERROR "Configured to use GDAL_USE_LIBKML, but not found") +diff --git a/cmake/helpers/ConanFindPackage.cmake b/cmake/helpers/ConanFindPackage.cmake +new file mode 100644 +index 0000000000..9dfa8193a3 +--- /dev/null ++++ b/cmake/helpers/ConanFindPackage.cmake +@@ -0,0 +1,43 @@ ++ ++function(define_find_package2 pkgname include_file library_name) ++endfunction() ++ ++function(find_package2 pkgname) ++ set(_options QUIET REQUIRED) ++ set(_oneValueArgs OUT_DEPENDENCY) ++ set(_multiValueArgs) ++ cmake_parse_arguments(arg "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) ++ if(arg_QUIET) ++ set(${pkgname}_FIND_QUIETLY TRUE) ++ endif() ++ if(arg_REQUIRED) ++ set(${pkgname}_FIND_REQUIRED TRUE) ++ endif() ++ ++ string(TOUPPER ${pkgname} key) ++ ++ set(docstring "Configured for conan package ${GDAL_CONAN_PACKAGE_FOR_${key}}") ++ if (DEFINED GDAL_CONAN_PACKAGE_FOR_${key}) ++ message("Using conan package ${GDAL_CONAN_PACKAGE_FOR_${key}} for dependency ${pkgname}") ++ set(conan_package ${GDAL_CONAN_PACKAGE_FOR_${key}}) ++ string(TOUPPER ${conan_package} conan_package_upper) ++ ++ set(${key}_INCLUDE_DIRS "${CONAN_INCLUDE_DIRS_${conan_package_upper}}" CACHE STRING ${docstring}) ++ if (NOT TARGET_FOR_${key}) ++ set(TARGET_FOR_${key} "${conan_package}::${conan_package}") ++ endif() ++ set(${key}_LIBRARIES "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${key}_LIBRARY "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${key}_TARGET "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${pkgname}_INCLUDE_DIRS "CONAN_INCLUDE_DIRS_${conan_package_upper}" CACHE STRING ${docstring}) ++ set(${pkgname}_LIBRARIES "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${pkgname}_LIBRARY "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${pkgname}_TARGET "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${key}_FOUND TRUE CACHE BOOL ${docstring}) ++ ++ else () ++ message("dependency ${pkgname} has no conan package") ++ set(${key}_FOUND FALSE CACHE BOOL ${docstring}) ++ endif() ++ ++endfunction() +diff --git a/frmts/hfa/CMakeLists.txt b/frmts/hfa/CMakeLists.txt +index e5b7138e91..039cac7361 100644 +--- a/frmts/hfa/CMakeLists.txt ++++ b/frmts/hfa/CMakeLists.txt +@@ -15,7 +15,8 @@ add_gdal_driver( + hfa_overviews.cpp + BUILTIN) + gdal_standard_includes(gdal_HFA) +-target_include_directories(gdal_HFA PRIVATE $) ++target_link_libraries(gdal_HFA INTERFACE PROJ::proj) ++target_include_directories(gdal_HFA PRIVATE ${PROJ_INCLUDE_DIRS}) + target_compile_definitions(gdal_HFA PRIVATE $) + + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12) +diff --git a/gdal.cmake b/gdal.cmake +index ff1ca7e6f6..e98875f1b9 100644 +--- a/gdal.cmake ++++ b/gdal.cmake +@@ -795,25 +795,6 @@ if (NOT GDAL_ENABLE_MACOSX_FRAMEWORK) + ${CMAKE_CURRENT_BINARY_DIR}/GDALConfig.cmake @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/GDALConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gdal/) + +- # Generate gdal-config utility command and pkg-config module gdal.pc +- include(GdalGenerateConfig) +- gdal_generate_config( +- TARGET +- "${GDAL_LIB_TARGET_NAME}" +- GLOBAL_PROPERTY +- "gdal_private_link_libraries" +- GDAL_CONFIG +- "${PROJECT_BINARY_DIR}/apps/gdal-config" +- PKG_CONFIG +- "${CMAKE_CURRENT_BINARY_DIR}/gdal.pc") +- install( +- PROGRAMS ${PROJECT_BINARY_DIR}/apps/gdal-config +- DESTINATION ${CMAKE_INSTALL_BINDIR} +- COMPONENT applications) +- install( +- FILES ${CMAKE_CURRENT_BINARY_DIR}/gdal.pc +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig +- COMPONENT libraries) + endif () + + configure_file(${GDAL_CMAKE_TEMPLATE_PATH}/uninstall.cmake.in ${PROJECT_BINARY_DIR}/cmake_uninstall.cmake @ONLY) +diff --git a/ogr/CMakeLists.txt b/ogr/CMakeLists.txt +index 19ba4e12fe..87cd123c54 100644 +--- a/ogr/CMakeLists.txt ++++ b/ogr/CMakeLists.txt +@@ -88,12 +88,12 @@ endif () + + target_compile_definitions(ogr PRIVATE HAVE_MITAB) + +-gdal_target_link_libraries(ogr PRIVATE PROJ::proj) ++target_link_libraries(ogr PUBLIC PROJ::proj) + + # External libs then + if (GDAL_USE_GEOS) + target_compile_definitions(ogr PRIVATE -DHAVE_GEOS=1) +- gdal_target_link_libraries(ogr PRIVATE ${GEOS_TARGET}) ++ target_link_libraries(ogr PUBLIC ${GEOS_TARGET}) + endif () + + if (GDAL_USE_SFCGAL) +diff --git a/ogr/ogr_proj_p.h b/ogr/ogr_proj_p.h +index 88928ad1ad..7cdd587db7 100644 +--- a/ogr/ogr_proj_p.h ++++ b/ogr/ogr_proj_p.h +@@ -29,7 +29,7 @@ + #ifndef OGR_PROJ_P_H_INCLUDED + #define OGR_PROJ_P_H_INCLUDED + +-#include "proj.h" ++#include + + #include "cpl_mem_cache.h" + diff --git a/recipes/gdal/post_3.5.0/patches/3.5.2/0-replace-find-package.patch b/recipes/gdal/post_3.5.0/patches/3.5.2/0-replace-find-package.patch new file mode 100644 index 0000000000000..b01b5b271034c --- /dev/null +++ b/recipes/gdal/post_3.5.0/patches/3.5.2/0-replace-find-package.patch @@ -0,0 +1,266 @@ +diff --git a/alg/CMakeLists.txt b/alg/CMakeLists.txt +index edf75158c7..4200309ca8 100644 +--- a/alg/CMakeLists.txt ++++ b/alg/CMakeLists.txt +@@ -72,7 +72,7 @@ if (GDAL_USE_OPENCL) + target_sources(alg PRIVATE gdalwarpkernel_opencl.h gdalwarpkernel_opencl.cpp) + endif () + +-gdal_target_link_libraries(alg PRIVATE PROJ::proj) ++target_link_libraries(alg PUBLIC PROJ::proj) + + if (GDAL_USE_QHULL_INTERNAL) + target_compile_definitions(alg PRIVATE -DINTERNAL_QHULL) +diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt +index 8b02cea456..ad4adbfc9e 100644 +--- a/apps/CMakeLists.txt ++++ b/apps/CMakeLists.txt +@@ -25,7 +25,7 @@ target_include_directories( + appslib PRIVATE $ $ + $ $) + +-gdal_target_link_libraries(appslib PRIVATE PROJ::proj) ++target_link_libraries(appslib PUBLIC PROJ::proj) + + set_property(TARGET appslib PROPERTY POSITION_INDEPENDENT_CODE ${GDAL_OBJECT_LIBRARIES_POSITION_INDEPENDENT_CODE}) + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) +diff --git a/cmake/helpers/CheckDependentLibraries.cmake b/cmake/helpers/CheckDependentLibraries.cmake +index 0a66b44fec..152ff42ff7 100644 +--- a/cmake/helpers/CheckDependentLibraries.cmake ++++ b/cmake/helpers/CheckDependentLibraries.cmake +@@ -11,7 +11,10 @@ Detect GDAL dependencies and set variable HAVE_* + include(CheckFunctionExists) + include(CMakeDependentOption) + include(FeatureSummary) +-include(DefineFindPackage2) ++ ++# Conan recipes should rely on config files from generators so let's just disble GDAL's ++include(ConanFindPackage) ++ + include(CheckSymbolExists) + + option( +@@ -111,47 +114,7 @@ macro (gdal_check_package name purpose) + set(_find_dependency_args "") + find_package2(${name} QUIET OUT_DEPENDENCY _find_dependency) + if (NOT DEFINED ${key}_FOUND) +- set(_find_package_args) +- if (_GCP_VERSION) +- list(APPEND _find_package_args ${_GCP_VERSION}) +- endif () +- if (_GCP_CONFIG) +- list(APPEND _find_package_args CONFIG) +- endif () +- if (_GCP_COMPONENTS) +- list(APPEND _find_package_args COMPONENTS ${_GCP_COMPONENTS}) +- endif () +- if (_GCP_PATHS) +- list(APPEND _find_package_args PATHS ${_GCP_PATHS}) +- endif () +- if (_GCP_NAMES) +- set(GDAL_CHECK_PACKAGE_${name}_NAMES "${_GCP_NAMES}" CACHE STRING "Config file name for ${name}") +- mark_as_advanced(GDAL_CHECK_PACKAGE_${name}_NAMES) +- endif () +- if (_GCP_TARGETS) +- set(GDAL_CHECK_PACKAGE_${name}_TARGETS "${_GCP_TARGETS}" CACHE STRING "Target name candidates for ${name}") +- mark_as_advanced(GDAL_CHECK_PACKAGE_${name}_TARGETS) +- endif () +- if (GDAL_CHECK_PACKAGE_${name}_NAMES) +- find_package(${name} NAMES ${GDAL_CHECK_PACKAGE_${name}_NAMES} ${_find_package_args}) +- gdal_check_package_target(${name} ${GDAL_CHECK_PACKAGE_${name}_TARGETS} REQUIRED) +- if (${name}_FOUND) +- get_filename_component(_find_dependency_args "${${name}_CONFIG}" NAME) +- string(REPLACE ";" " " _find_dependency_args "${name} NAMES ${GDAL_CHECK_PACKAGE_${name}_NAMES} CONFIGS ${_find_dependency_args} ${_find_package_args}") +- endif () +- endif () +- if (NOT ${name}_FOUND) +- find_package(${name} ${_find_package_args}) +- if (${name}_FOUND) +- gdal_check_package_target(${name} ${GDAL_CHECK_PACKAGE_${name}_TARGETS}) +- elseif (${key}_FOUND) # Some find modules do not set _FOUND +- gdal_check_package_target(${key} ${GDAL_CHECK_PACKAGE_${name}_TARGETS}) +- set(${name}_FOUND "${key}_FOUND") +- endif () +- if (${name}_FOUND) +- string(REPLACE ";" " " _find_dependency_args "${name} ${_find_package_args}") +- endif() +- endif () ++ message(FATAL_ERROR "Conan recipes should rely on config files from generators so let's just disble GDAL's") + endif () + if (${key}_FOUND OR ${name}_FOUND) + set(HAVE_${key} ON) +@@ -345,14 +308,15 @@ if (GDAL_USE_CRYPTOPP) + endif () + + # First check with CMake config files (starting at version 8, due to issues with earlier ones), and then fallback to the FindPROJ module. +-find_package(PROJ 9 CONFIG QUIET) +-if (NOT PROJ_FOUND) +- find_package(PROJ 8 CONFIG QUIET) +-endif() ++find_package2(PROJ) ++target_include_directories(PROJ::proj INTERFACE ${PROJ_INCLUDE_DIRS}) ++#if (NOT PROJ_FOUND) ++# find_package(proj 8 CONFIG QUIET) ++#endif() + if (PROJ_FOUND) + string(APPEND GDAL_IMPORT_DEPENDENCIES "find_dependency(PROJ ${PROJ_VERSION_MAJOR} CONFIG)\n") + else() +- find_package(PROJ 6.0 REQUIRED) ++ find_package(proj 6.0 REQUIRED) + string(APPEND GDAL_IMPORT_DEPENDENCIES "find_dependency(PROJ 6.0)\n") + endif () + +@@ -412,15 +376,10 @@ gdal_check_package(JSONC "json-c library (external)" CAN_DISABLE + TARGETS json-c::json-c JSONC::JSONC + ) + gdal_internal_library(JSONC REQUIRED) +-if(TARGET json-c::json-c) +- get_target_property(include_dirs json-c::json-c INTERFACE_INCLUDE_DIRECTORIES) +- find_path(GDAL_JSON_INCLUDE_DIR NAMES json.h PATHS ${include_dirs} PATH_SUFFIXES json-c NO_DEFAULT_PATH) +- list(APPEND include_dirs "${GDAL_JSON_INCLUDE_DIR}") +- list(REMOVE_DUPLICATES include_dirs) +- set_target_properties(json-c::json-c PROPERTIES +- INTERFACE_INCLUDE_DIRECTORIES "${GDAL_JSON_INCLUDE_DIR}" +- ) +-endif() ++get_target_property(include_dirs json-c::json-c INTERFACE_INCLUDE_DIRECTORIES) ++list(APPEND include_dirs "${JSONC_INCLUDE_DIRS}/json-c") ++set_target_properties(json-c::json-c PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include_dirs}") ++message("Setting include for json-c: ${include_dirs}") + + gdal_check_package(OpenCAD "libopencad (external, used by OpenCAD driver)" CAN_DISABLE) + gdal_internal_library(OPENCAD) +@@ -517,7 +476,7 @@ if (GDAL_USE_RASTERLITE2) + endif () + cmake_dependent_option(GDAL_USE_RASTERLITE2 "Set ON to use Rasterlite2" ON HAVE_RASTERLITE2 OFF) + +-find_package(LibKML COMPONENTS DOM ENGINE) ++find_package(LibKML COMPONENTS kmlengine kmldom kmlbase) + if (GDAL_USE_LIBKML) + if (NOT LibKML_FOUND) + message(FATAL_ERROR "Configured to use GDAL_USE_LIBKML, but not found") +diff --git a/cmake/helpers/ConanFindPackage.cmake b/cmake/helpers/ConanFindPackage.cmake +new file mode 100644 +index 0000000000..9dfa8193a3 +--- /dev/null ++++ b/cmake/helpers/ConanFindPackage.cmake +@@ -0,0 +1,43 @@ ++ ++function(define_find_package2 pkgname include_file library_name) ++endfunction() ++ ++function(find_package2 pkgname) ++ set(_options QUIET REQUIRED) ++ set(_oneValueArgs OUT_DEPENDENCY) ++ set(_multiValueArgs) ++ cmake_parse_arguments(arg "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) ++ if(arg_QUIET) ++ set(${pkgname}_FIND_QUIETLY TRUE) ++ endif() ++ if(arg_REQUIRED) ++ set(${pkgname}_FIND_REQUIRED TRUE) ++ endif() ++ ++ string(TOUPPER ${pkgname} key) ++ ++ set(docstring "Configured for conan package ${GDAL_CONAN_PACKAGE_FOR_${key}}") ++ if (DEFINED GDAL_CONAN_PACKAGE_FOR_${key}) ++ message("Using conan package ${GDAL_CONAN_PACKAGE_FOR_${key}} for dependency ${pkgname}") ++ set(conan_package ${GDAL_CONAN_PACKAGE_FOR_${key}}) ++ string(TOUPPER ${conan_package} conan_package_upper) ++ ++ set(${key}_INCLUDE_DIRS "${CONAN_INCLUDE_DIRS_${conan_package_upper}}" CACHE STRING ${docstring}) ++ if (NOT TARGET_FOR_${key}) ++ set(TARGET_FOR_${key} "${conan_package}::${conan_package}") ++ endif() ++ set(${key}_LIBRARIES "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${key}_LIBRARY "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${key}_TARGET "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${pkgname}_INCLUDE_DIRS "CONAN_INCLUDE_DIRS_${conan_package_upper}" CACHE STRING ${docstring}) ++ set(${pkgname}_LIBRARIES "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${pkgname}_LIBRARY "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${pkgname}_TARGET "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${key}_FOUND TRUE CACHE BOOL ${docstring}) ++ ++ else () ++ message("dependency ${pkgname} has no conan package") ++ set(${key}_FOUND FALSE CACHE BOOL ${docstring}) ++ endif() ++ ++endfunction() +diff --git a/frmts/hfa/CMakeLists.txt b/frmts/hfa/CMakeLists.txt +index e5b7138e91..039cac7361 100644 +--- a/frmts/hfa/CMakeLists.txt ++++ b/frmts/hfa/CMakeLists.txt +@@ -15,7 +15,8 @@ add_gdal_driver( + hfa_overviews.cpp + BUILTIN) + gdal_standard_includes(gdal_HFA) +-target_include_directories(gdal_HFA PRIVATE $) ++target_link_libraries(gdal_HFA INTERFACE PROJ::proj) ++target_include_directories(gdal_HFA PRIVATE ${PROJ_INCLUDE_DIRS}) + target_compile_definitions(gdal_HFA PRIVATE $) + + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12) +diff --git a/gdal.cmake b/gdal.cmake +index 4bae2e2760..7695df40c8 100644 +--- a/gdal.cmake ++++ b/gdal.cmake +@@ -787,25 +787,6 @@ if (NOT GDAL_ENABLE_MACOSX_FRAMEWORK) + ${CMAKE_CURRENT_BINARY_DIR}/GDALConfig.cmake @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/GDALConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gdal/) + +- # Generate gdal-config utility command and pkg-config module gdal.pc +- include(GdalGenerateConfig) +- gdal_generate_config( +- TARGET +- "${GDAL_LIB_TARGET_NAME}" +- GLOBAL_PROPERTY +- "gdal_private_link_libraries" +- GDAL_CONFIG +- "${PROJECT_BINARY_DIR}/apps/gdal-config" +- PKG_CONFIG +- "${CMAKE_CURRENT_BINARY_DIR}/gdal.pc") +- install( +- PROGRAMS ${PROJECT_BINARY_DIR}/apps/gdal-config +- DESTINATION ${CMAKE_INSTALL_BINDIR} +- COMPONENT applications) +- install( +- FILES ${CMAKE_CURRENT_BINARY_DIR}/gdal.pc +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig +- COMPONENT libraries) + endif () + + configure_file(${GDAL_CMAKE_TEMPLATE_PATH}/uninstall.cmake.in ${PROJECT_BINARY_DIR}/cmake_uninstall.cmake @ONLY) +diff --git a/ogr/CMakeLists.txt b/ogr/CMakeLists.txt +index 19ba4e12fe..87cd123c54 100644 +--- a/ogr/CMakeLists.txt ++++ b/ogr/CMakeLists.txt +@@ -88,12 +88,12 @@ endif () + + target_compile_definitions(ogr PRIVATE HAVE_MITAB) + +-gdal_target_link_libraries(ogr PRIVATE PROJ::proj) ++target_link_libraries(ogr PUBLIC PROJ::proj) + + # External libs then + if (GDAL_USE_GEOS) + target_compile_definitions(ogr PRIVATE -DHAVE_GEOS=1) +- gdal_target_link_libraries(ogr PRIVATE ${GEOS_TARGET}) ++ target_link_libraries(ogr PUBLIC ${GEOS_TARGET}) + endif () + + if (GDAL_USE_SFCGAL) +diff --git a/ogr/ogr_proj_p.h b/ogr/ogr_proj_p.h +index 88928ad1ad..7cdd587db7 100644 +--- a/ogr/ogr_proj_p.h ++++ b/ogr/ogr_proj_p.h +@@ -29,7 +29,7 @@ + #ifndef OGR_PROJ_P_H_INCLUDED + #define OGR_PROJ_P_H_INCLUDED + +-#include "proj.h" ++#include + + #include "cpl_mem_cache.h" + diff --git a/recipes/gdal/post_3.5.0/test_package/CMakeLists.txt b/recipes/gdal/post_3.5.0/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..861d8d69409b0 --- /dev/null +++ b/recipes/gdal/post_3.5.0/test_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(GDAL REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} GDAL::GDAL) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) + +add_executable(${PROJECT_NAME}_c test_package.c) +target_link_libraries(${PROJECT_NAME}_c GDAL::GDAL) diff --git a/recipes/gdal/post_3.5.0/test_package/conanfile.py b/recipes/gdal/post_3.5.0/test_package/conanfile.py new file mode 100644 index 0000000000000..9dced2ad9cf71 --- /dev/null +++ b/recipes/gdal/post_3.5.0/test_package/conanfile.py @@ -0,0 +1,23 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conans import CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + if self.options["gdal"].tools: + self.run("gdal_translate --formats", run_environment=True) + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + bin_path_c = os.path.join("bin", "test_package_c") + self.run(bin_path_c, run_environment=True) diff --git a/recipes/gdal/all/test_package/test_package.c b/recipes/gdal/post_3.5.0/test_package/test_package.c similarity index 100% rename from recipes/gdal/all/test_package/test_package.c rename to recipes/gdal/post_3.5.0/test_package/test_package.c diff --git a/recipes/gdal/all/test_package/test_package.cpp b/recipes/gdal/post_3.5.0/test_package/test_package.cpp similarity index 100% rename from recipes/gdal/all/test_package/test_package.cpp rename to recipes/gdal/post_3.5.0/test_package/test_package.cpp diff --git a/recipes/gdal/pre_3.5.0/conandata.yml b/recipes/gdal/pre_3.5.0/conandata.yml new file mode 100644 index 0000000000000..e05a3af06bfda --- /dev/null +++ b/recipes/gdal/pre_3.5.0/conandata.yml @@ -0,0 +1,76 @@ +sources: + "3.4.3": + url: "https://github.com/OSGeo/gdal/releases/download/v3.4.3/gdal-3.4.3.tar.gz" + sha256: "7244962628c82921b4a4903dbb721c7222b7d82ed5928fef55a52f87f68ad1fe" + "3.4.1": + url: "https://github.com/OSGeo/gdal/releases/download/v3.4.1/gdal-3.4.1.tar.gz" + sha256: "e360387bc25ec24940f46afbeada48002d72c74aaf9eccf2a40e8d74e711a2e4" + "3.3.3": + url: "https://github.com/OSGeo/gdal/releases/download/v3.3.3/gdal-3.3.3.tar.gz" + sha256: "28925ea4717b02185ee208bfc121a94fa0bc1dfe9cb862fd3868c2a0394d605a" + "3.2.3": + url: "https://github.com/OSGeo/gdal/releases/download/v3.2.3/gdal-3.2.3.tar.gz" + sha256: "86a35aad60a1eb87c2c0c145f9bccd83a47c4781254544ed5246f64d55ee1f18" + "3.1.4": + url: "https://github.com/OSGeo/gdal/releases/download/v3.1.4/gdal-3.1.4.tar.gz" + sha256: "5f09ea6ca797e296b608d261e08e18ffa43a12fa28d460ae139d2a026ee2b0c0" +patches: + "3.4.3": + - patch_file: "patches/3.4.x/fix-autotools-3.4.3.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.4.x/fix-nmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.4.x/fix-include-jsonc-3.4.3.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.4.x/fix-include-xerces.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.4.x/fix-include-podofo.patch" + base_path: "source_subfolder" + "3.4.1": + - patch_file: "patches/3.4.x/fix-autotools-3.4.1.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.4.x/fix-nmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.4.x/fix-include-jsonc-3.4.1.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.4.x/fix-include-xerces.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.4.x/fix-include-podofo.patch" + base_path: "source_subfolder" + "3.3.3": + - patch_file: "patches/3.3.x/fix-autotools-3.3.3.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.3.x/fix-nmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.3.x/fix-include-jsonc.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.3.x/fix-include-xerces.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.3.x/fix-include-podofo.patch" + base_path: "source_subfolder" + "3.2.3": + - patch_file: "patches/3.2.x/fix-autotools.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.2.x/fix-nmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.2.x/fix-include-jsonc.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.2.x/fix-include-xerces.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.2.x/fix-include-podofo.patch" + base_path: "source_subfolder" + "3.1.4": + - patch_file: "patches/3.1.x/fix-autotools-3.1.4.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.1.x/fix-nmake-common.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.1.x/fix-nmake-opt-3.1.2.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.1.x/fix-import-dll-msvc.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.1.x/fix-include-jsonc.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.1.x/fix-include-xerces-3.1.2.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.1.x/fix-include-podofo.patch" + base_path: "source_subfolder" diff --git a/recipes/gdal/pre_3.5.0/conanfile.py b/recipes/gdal/pre_3.5.0/conanfile.py new file mode 100644 index 0000000000000..18506b71dd2ea --- /dev/null +++ b/recipes/gdal/pre_3.5.0/conanfile.py @@ -0,0 +1,962 @@ +from conan.tools.files import apply_conandata_patches +from conan.tools.microsoft import is_msvc +from conans import ConanFile, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration +from contextlib import contextmanager +import functools +import os + +required_conan_version = ">=1.45.0" + + +class GdalConan(ConanFile): + name = "gdal" + description = "GDAL is an open source X/MIT licensed translator library " \ + "for raster and vector geospatial data formats." + license = "MIT" + topics = ("osgeo", "geospatial", "raster", "vector") + homepage = "https://github.com/OSGeo/gdal" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "simd_intrinsics": [None, "sse", "ssse3", "avx"], + "threadsafe": [True, False], + "tools": [True, False], + "with_zlib": [True, False], + "with_libdeflate": [True, False], + "with_libiconv": [True, False], + "with_zstd": [True, False], + "with_blosc": [True, False], + "with_lz4": [True, False], + "with_pg": [True, False], + # "with_libgrass": [True, False], + "with_cfitsio": [True, False], + "with_pcraster": [True, False], + "with_png": [True, False], + "with_dds": [True, False], + "with_gta": [True, False], + "with_pcidsk": [True, False], + "with_jpeg": [None, "libjpeg", "libjpeg-turbo"], + "with_charls": [True, False], + "with_gif": [True, False], + # "with_ogdi": [True, False], + # "with_sosi": [True, False], + "with_mongocxx": [True, False], + "with_hdf4": [True, False], + "with_hdf5": [True, False], + "with_kea": [True, False], + "with_netcdf": [True, False], + "with_jasper": [True, False], + "with_openjpeg": [True, False], + # "with_fgdb": [True, False], + "with_gnm": [True, False], + "with_mysql": [None, "libmysqlclient", "mariadb-connector-c"], + "with_xerces": [True, False], + "with_expat": [True, False], + "with_libkml": [True, False], + "with_odbc": [True, False], + # "with_dods_root": [True, False], + "with_curl": [True, False], + "with_xml2": [True, False], + # "with_spatialite": [True, False], + "with_sqlite3": [True, False], + # "with_rasterlite2": [True, False], + "with_pcre": [True, False], + "with_pcre2": [True, False], + "with_webp": [True, False], + "with_geos": [True, False], + # "with_sfcgal": [True, False], + "with_qhull": [True, False], + "with_opencl": [True, False], + "with_freexl": [True, False], + "without_pam": [True, False], + "with_poppler": [True, False], + "with_podofo": [True, False], + # "with_pdfium": [True, False], + # "with_tiledb": [True, False], + # "with_rasdaman": [True, False], + "with_brunsli": [True, False], + # "with_armadillo": [True, False], + "with_cryptopp": [True, False], + "with_crypto": [True, False], + "without_lerc": [True, False], + "with_null": [True, False], + "with_exr": [True, False], + "with_heif": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "simd_intrinsics": "sse", + "threadsafe": True, + "tools": False, + "with_zlib": True, + "with_libdeflate": True, + "with_libiconv": True, + "with_zstd": False, + "with_blosc": False, + "with_lz4": False, + "with_pg": False, + # "with_libgrass": False, + "with_cfitsio": False, + "with_pcraster": True, + "with_png": True, + "with_dds": False, + "with_gta": False, + "with_pcidsk": True, + "with_jpeg": "libjpeg", + "with_charls": False, + "with_gif": True, + # "with_ogdi": False, + # "with_sosi": False, + "with_mongocxx": False, + "with_hdf4": False, + "with_hdf5": False, + "with_kea": False, + "with_netcdf": False, + "with_jasper": False, + "with_openjpeg": False, + # "with_fgdb": False, + "with_gnm": True, + "with_mysql": None, + "with_xerces": False, + "with_expat": False, + "with_libkml": False, + "with_odbc": False, + # "with_dods_root": False, + "with_curl": False, + "with_xml2": False, + # "with_spatialite": False, + "with_sqlite3": True, + # "with_rasterlite2": False, + "with_pcre": False, + "with_pcre2": False, + "with_webp": False, + "with_geos": True, + # "with_sfcgal": False, + "with_qhull": True, + "with_opencl": False, + "with_freexl": False, + "without_pam": False, + "with_poppler": False, + "with_podofo": False, + # "with_pdfium": False, + # "with_tiledb": False, + # "with_rasdaman": False, + "with_brunsli": False, + # "with_armadillo": False, + "with_cryptopp": False, + "with_crypto": False, + "without_lerc": False, + "with_null": False, + "with_exr": False, + "with_heif": False, + } + + generators = "pkg_config" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _has_with_exr_option(self): + return tools.Version(self.version) >= "3.1.0" + + @property + def _has_with_libdeflate_option(self): + return tools.Version(self.version) >= "3.2.0" + + @property + def _has_with_heif_option(self): + return tools.Version(self.version) >= "3.2.0" + + @property + def _has_with_blosc_option(self): + return tools.Version(self.version) >= "3.4.0" + + @property + def _has_with_lz4_option(self): + return tools.Version(self.version) >= "3.4.0" + + @property + def _has_with_brunsli_option(self): + return tools.Version(self.version) >= "3.4.0" + + @property + def _has_with_pcre2_option(self): + return tools.Version(self.version) >= "3.4.1" + + @property + def _has_reentrant_qhull_support(self): + return tools.Version(self.version) >= "3.4.1" + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + # if tools.Version(self.version) < "3.0.0": + # del self.options.with_tiledb + if not self._has_with_exr_option: + del self.options.with_exr + if not self._has_with_libdeflate_option: + del self.options.with_libdeflate + if not self._has_with_heif_option: + del self.options.with_heif + if not self._has_with_blosc_option: + del self.options.with_blosc + if not self._has_with_lz4_option: + del self.options.with_lz4 + if not self._has_with_brunsli_option: + del self.options.with_brunsli + if not self._has_with_pcre2_option: + del self.options.with_pcre2 + + def configure(self): + if self.options.shared: + del self.options.fPIC + if self.settings.arch not in ["x86", "x86_64"]: + del self.options.simd_intrinsics + if self.options.without_lerc: + del self.options.with_zstd + # if self.options.with_spatialite: + # del self.options.with_sqlite3 + if not self.options.get_safe("with_sqlite3", False): + del self.options.with_pcre + del self.options.with_pcre2 + if is_msvc(self): + del self.options.threadsafe + del self.options.with_null + del self.options.with_zlib # zlib and png are always used in nmake build, + del self.options.with_png # and it's not trivial to fix + self._strict_options_requirements() + + def _strict_options_requirements(self): + if self.options.with_qhull: + self.options["qhull"].reentrant = self._has_reentrant_qhull_support + + def requirements(self): + self.requires("json-c/0.15") + self.requires("libgeotiff/1.7.1") + # self.requires("libopencad/0.0.2") # TODO: use conan recipe when available instead of internal one + self.requires("libtiff/4.3.0") + self.requires("proj/9.0.0") + if tools.Version(self.version) >= "3.1.0": + self.requires("flatbuffers/2.0.5") + if self.options.get_safe("with_zlib", True): + self.requires("zlib/1.2.12") + if self.options.get_safe("with_libdeflate"): + self.requires("libdeflate/1.12") + if self.options.with_libiconv: + self.requires("libiconv/1.16") + if self.options.get_safe("with_zstd"): + self.requires("zstd/1.5.2") + if self.options.get_safe("with_blosc"): + self.requires("c-blosc/1.21.1") + if self.options.get_safe("with_lz4"): + self.requires("lz4/1.9.3") + if self.options.with_pg: + self.requires("libpq/14.2") + # if self.options.with_libgrass: + # self.requires("libgrass/x.x.x") + if self.options.with_cfitsio: + self.requires("cfitsio/4.1.0") + # if self.options.with_pcraster: + # self.requires("pcraster-rasterformat/1.3.2") + if self.options.get_safe("with_png", True): + self.requires("libpng/1.6.37") + if self.options.with_dds: + self.requires("crunch/cci.20190615") + if self.options.with_gta: + self.requires("libgta/1.2.1") + # if self.options.with_pcidsk: + # self.requires("pcidsk/x.x.x") + if self.options.with_jpeg == "libjpeg": + self.requires("libjpeg/9d") + elif self.options.with_jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/2.1.2") + if self.options.with_charls: + self.requires("charls/2.3.4") + if self.options.with_gif: + self.requires("giflib/5.2.1") + # if self.options.with_ogdi: + # self.requires("ogdi/4.1.0") + # if self.options.with_sosi: + # self.requires("fyba/4.1.1") + if self.options.with_mongocxx: + self.requires("mongo-cxx-driver/3.6.6") + if self.options.with_hdf4: + self.requires("hdf4/4.2.15") + if self.options.with_hdf5: + self.requires("hdf5/1.12.1") + if self.options.with_kea: + self.requires("kealib/1.4.14") + if self.options.with_netcdf: + self.requires("netcdf/4.8.1") + if self.options.with_jasper: + self.requires("jasper/2.0.33") + if self.options.with_openjpeg: + self.requires("openjpeg/2.5.0") + # if self.options.with_fgdb: + # self.requires("file-geodatabase-api/x.x.x") + if self.options.with_mysql == "libmysqlclient": + self.requires("libmysqlclient/8.0.29") + elif self.options.with_mysql == "mariadb-connector-c": + self.requires("mariadb-connector-c/3.1.12") + if self.options.with_xerces: + self.requires("xerces-c/3.2.3") + if self.options.with_expat: + self.requires("expat/2.4.8") + if self.options.with_libkml: + self.requires("libkml/1.3.0") + if self.options.with_odbc and self.settings.os != "Windows": + self.requires("odbc/2.3.9") + # if self.options.with_dods_root: + # self.requires("libdap/3.20.6") + if self.options.with_curl: + self.requires("libcurl/7.83.1") + if self.options.with_xml2: + self.requires("libxml2/2.9.14") + # if self.options.with_spatialite: + # self.requires("libspatialite/4.3.0a") + if self.options.get_safe("with_sqlite3"): + self.requires("sqlite3/3.38.5") + # if self.options.with_rasterlite2: + # self.requires("rasterlite2/x.x.x") + if self.options.get_safe("with_pcre"): + self.requires("pcre/8.45") + if self.options.get_safe("with_pcre2"): + self.requires("pcre2/10.40") + if self.options.with_webp: + self.requires("libwebp/1.2.2") + if self.options.with_geos: + self.requires("geos/3.10.2") + # if self.options.with_sfcgal: + # self.requires("sfcgal/1.3.7") + if self.options.with_qhull: + self.requires("qhull/8.0.1") + if self.options.with_opencl: + self.requires("opencl-headers/2022.01.04") + self.requires("opencl-icd-loader/2022.01.04") + if self.options.with_freexl: + self.requires("freexl/1.0.6") + if self.options.with_poppler: + self.requires("poppler/21.07.0") + if self.options.with_podofo: + self.requires("podofo/0.9.7") + # if self.options.with_pdfium: + # self.requires("pdfium/x.x.x") + # if self.options.get_safe("with_tiledb"): + # self.requires("tiledb/2.0.2") + # if self.options.with_rasdaman: + # self.requires("raslib/x.x.x") + # if self.options.with_armadillo: + # self.requires("armadillo/9.880.1") + if self.options.with_cryptopp: + self.requires("cryptopp/8.6.0") + if self.options.with_crypto: + self.requires("openssl/1.1.1o") + # if not self.options.without_lerc: + # self.requires("lerc/2.1") # TODO: use conan recipe (not possible yet because lerc API is broken for GDAL) + if self.options.get_safe("with_exr"): + self.requires("openexr/3.1.5") + if self.options.get_safe("with_heif"): + self.requires("libheif/1.12.0") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + min_cppstd = 14 if self.options.with_charls else 11 + tools.check_min_cppstd(self, min_cppstd) + if self.options.get_safe("with_pcre") and self.options.get_safe("with_pcre2"): + raise ConanInvalidConfiguration("Enable either pcre or pcre2, not both") + if self.options.get_safe("with_pcre2") and not self.options["pcre2"].build_pcre2_8: + raise ConanInvalidConfiguration("gdal:with_pcre2=True requires pcre2:build_pcre2_8=True") + if self.options.get_safe("with_brunsli"): + raise ConanInvalidConfiguration("brunsli not available in conan-center yet") + if self.options.get_safe("with_libdeflate") and not self.options.get_safe("with_zlib", True): + raise ConanInvalidConfiguration("gdal:with_libdeflate=True requires gdal:with_zlib=True") + if self.options.with_qhull: + if self._has_reentrant_qhull_support and not self.options["qhull"].reentrant: + raise ConanInvalidConfiguration("gdal {} depends on reentrant qhull.".format(self.version)) + elif not self._has_reentrant_qhull_support and self.options["qhull"].reentrant: + raise ConanInvalidConfiguration("gdal {} depends on non-reentrant qhull.".format(self.version)) + if hasattr(self, "settings_build") and tools.cross_building(self): + if self.options.shared: + raise ConanInvalidConfiguration("GDAL build system can't cross-build shared lib") + if self.options.tools: + raise ConanInvalidConfiguration("GDAL build system can't cross-build tools") + + def _validate_dependency_graph(self): + if tools.Version(self.deps_cpp_info["libtiff"].version) < "4.0.0": + raise ConanInvalidConfiguration("gdal {} requires libtiff >= 4.0.0".format(self.version)) + if self.options.with_mongocxx: + mongocxx_version = tools.Version(self.deps_cpp_info["mongo-cxx-driver"].version) + if mongocxx_version < "3.0.0": + # TODO: handle mongo-cxx-driver v2 + raise ConanInvalidConfiguration("gdal with mongo-cxx-driver < 3.0.0 not yet supported in this recipe.") + elif mongocxx_version < "3.4.0": + raise ConanInvalidConfiguration("gdal with mongo-cxx-driver v3 requires 3.4.0 at least.") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + if not is_msvc(self): + self.build_requires("libtool/2.4.6") + self.build_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + apply_conandata_patches(self) + + # Remove embedded dependencies + embedded_libs = [ + os.path.join("alg", "internal_libqhull"), + os.path.join("frmts", "gif", "giflib"), + os.path.join("frmts", "jpeg", "libjpeg"), + os.path.join("frmts", "png", "libpng"), + os.path.join("frmts", "zlib"), + # os.path.join("ogr", "ogrsf_frmts", "cad", "libopencad"), # TODO: uncomment when libopencad available + os.path.join("ogr", "ogrsf_frmts", "geojson", "libjson"), + ] + if tools.Version(self.version) >= "3.1.0": + embedded_libs.append(os.path.join("ogr", "ogrsf_frmts", "flatgeobuf", "flatbuffers")) + for lib_subdir in embedded_libs: + tools.rmdir(os.path.join(self._source_subfolder, lib_subdir)) + + # OpenCL headers + tools.replace_in_file(os.path.join(self._source_subfolder, "alg", "gdalwarpkernel_opencl.h"), + "#include ", + "#include ") + + # More patches for autotools build + if not is_msvc(self): + configure_ac = os.path.join(self._source_subfolder, "configure.ac") + # Workaround for nc-config not packaged in netcdf recipe (gdal relies on it to check nc4 and hdf4 support in netcdf): + if self.options.with_netcdf and self.options["netcdf"].netcdf4 and self.options["netcdf"].with_hdf5: + tools.replace_in_file(configure_ac, + "NETCDF_HAS_NC4=no", + "NETCDF_HAS_NC4=yes") + # Fix zlib checks and -lz injection to ensure to use external zlib and not fail others checks + if self.options.get_safe("with_zlib", True): + zlib_name = self.deps_cpp_info["zlib"].libs[0] + tools.replace_in_file(configure_ac, + "AC_CHECK_LIB(z,", + "AC_CHECK_LIB({},".format(zlib_name)) + tools.replace_in_file(configure_ac, + "-lz ", + "-l{} ".format(zlib_name)) + # Workaround for autoconf 2.71 + with open(os.path.join(self._source_subfolder, "config.rpath"), "w"): + pass + + # Disable tools + if not self.options.tools: + # autotools + gnumakefile_apps = os.path.join(self._source_subfolder, "apps", "GNUmakefile") + tools.replace_in_file(gnumakefile_apps, + "default: gdal-config-inst gdal-config $(BIN_LIST)", + "default: gdal-config-inst gdal-config") + if tools.Version(self.version) < "3.4.0": + clean_pattern = "$(RM) *.o $(BIN_LIST) core gdal-config gdal-config-inst" + else: + clean_pattern = "$(RM) *.o $(BIN_LIST) $(NON_DEFAULT_LIST) core gdal-config gdal-config-inst" + tools.replace_in_file(gnumakefile_apps, + clean_pattern, + "$(RM) *.o core gdal-config gdal-config-inst") + tools.replace_in_file(gnumakefile_apps, + "for f in $(BIN_LIST) ; do $(INSTALL) $$f $(DESTDIR)$(INST_BIN) ; done", + "") + # msvc + vcmakefile_apps = os.path.join(self._source_subfolder, "apps", "makefile.vc") + tools.replace_in_file(vcmakefile_apps, + "default: ", + "default: \n\nold-default: ") + tools.replace_in_file(vcmakefile_apps, + "copy *.exe $(BINDIR)", + "") + + def _edit_nmake_opt(self): + simd_intrinsics = str(self.options.get_safe("simd_intrinsics", False)) + if simd_intrinsics != "avx": + self._replace_in_nmake_opt("AVXFLAGS = /DHAVE_AVX_AT_COMPILE_TIME", "") + if simd_intrinsics not in ["sse3", "avx"]: + self._replace_in_nmake_opt("SSSE3FLAGS = /DHAVE_SSSE3_AT_COMPILE_TIME", "") + if simd_intrinsics not in ["sse", "sse3", "avx"]: + self._replace_in_nmake_opt("SSEFLAGS = /DHAVE_SSE_AT_COMPILE_TIME", "") + if self.options.without_pam: + self._replace_in_nmake_opt("PAM_SETTING=-DPAM_ENABLED", "") + if not self.options.with_gnm: + self._replace_in_nmake_opt("INCLUDE_GNM_FRMTS = YES", "") + if not self.options.with_odbc: + self._replace_in_nmake_opt("ODBC_SUPPORTED = 1", "") + if not bool(self.options.with_jpeg): + self._replace_in_nmake_opt("JPEG_SUPPORTED = 1", "") + self._replace_in_nmake_opt("JPEG12_SUPPORTED = 1", "") + if not self.options.with_pcidsk: + self._replace_in_nmake_opt("PCIDSK_SETTING=INTERNAL", "") + if self.options.with_pg: + self._replace_in_nmake_opt("#PG_LIB = n:\\pkg\\libpq_win32\\lib\\libpqdll.lib wsock32.lib", "PG_LIB=") + if bool(self.options.with_mysql): + self._replace_in_nmake_opt("#MYSQL_LIB = D:\\Software\\MySQLServer4.1\\lib\\opt\\libmysql.lib advapi32.lib", "MYSQL_LIB=") + if self.options.get_safe("with_sqlite3"): + self._replace_in_nmake_opt("#SQLITE_LIB=N:\\pkg\\sqlite-win32\\sqlite3_i.lib", "SQLITE_LIB=") + if self.options.with_curl: + self._replace_in_nmake_opt("#CURL_LIB = $(CURL_DIR)/libcurl.lib wsock32.lib wldap32.lib winmm.lib", "CURL_LIB=") + if self.options.with_freexl: + self._replace_in_nmake_opt("#FREEXL_LIBS = e:/freexl-1.0.0a/freexl_i.lib", "FREEXL_LIBS=") + if not (self.options.get_safe("with_zlib", True) and self.options.get_safe("with_png", True) and bool(self.options.with_jpeg)): + self._replace_in_nmake_opt("MRF_SETTING=yes", "") + if self.options.with_charls: + self._replace_in_nmake_opt("#CHARLS_LIB=e:\\work\\GIS\\gdal\\supportlibs\\charls\\bin\\Release\\x86\\CharLS.lib", "CHARLS_LIB=") + # Inject required systems libs of dependencies + self._replace_in_nmake_opt("ADD_LIBS =", "ADD_LIBS={}".format(" ".join([lib + ".lib" for lib in self.deps_cpp_info.system_libs]))) + # Trick to enable OpenCL (option missing in upstream nmake files) + if self.options.with_opencl: + tools.replace_in_file(os.path.join(self._source_subfolder, "alg", "makefile.vc"), + "$(GEOS_CFLAGS)", "$(GEOS_CFLAGS) /DHAVE_OPENCL") + + def _replace_in_nmake_opt(self, str1, str2): + tools.replace_in_file(os.path.join(self.build_folder, self._source_subfolder, "nmake.opt"), str1, str2) + + @property + def _nmake_args(self): + rootpath = lambda req: self.deps_cpp_info[req].rootpath + include_paths = lambda req: " -I".join(self.deps_cpp_info[req].include_paths) + version = lambda req: tools.Version(self.deps_cpp_info[req].version) + + args = [] + args.append("GDAL_HOME=\"{}\"".format(self.package_folder)) + args.append("INCDIR=\"{}\"".format(os.path.join(self.package_folder, "include", "gdal"))) + args.append("DATADIR=\"{}\"".format(os.path.join(self.package_folder, "res", "gdal"))) + if self.settings.arch == "x86_64": + args.append("WIN64=1") + args.append("DEBUG={}".format("1" if self.settings.build_type == "Debug" else "0")) + args.append("DLLBUILD={}".format("1" if self.options.shared else "0")) + args.append("PROJ_INCLUDE=\"-I{}\"".format(include_paths("proj"))) + if self.options.with_libiconv: + args.append("LIBICONV_INCLUDE=\"-I{}\"".format(include_paths("libiconv"))) + args.append("LIBICONV_CFLAGS=\"-DICONV_CONST=\"") + args.append("JPEG_EXTERNAL_LIB=1") + if self.options.with_jpeg == "libjpeg": + args.append("JPEGDIR=\"{}\"".format(include_paths("libjpeg"))) + elif self.options.with_jpeg == "libjpeg-turbo": + args.append("JPEGDIR=\"{}\"".format(include_paths("libjpeg-turbo"))) + args.append("PNG_EXTERNAL_LIB=1") + args.append("PNGDIR=\"{}\"".format(include_paths("libpng"))) + if self.options.with_gif: + args.append("GIF_SETTING=EXTERNAL") + if self.options.with_pcraster: + args.append("PCRASTER_SETTING=INTERNAL") + args.append("TIFF_INC=\"-I{}\"".format(include_paths("libtiff"))) + args.append("GEOTIFF_INC=\"-I{}\"".format(include_paths("libgeotiff"))) + if self.options.with_libkml: + args.append("LIBKML_DIR=\"{}\"".format(rootpath("libkml"))) + if self.options.with_expat: + args.append("EXPAT_DIR=\"{}\"".format(rootpath("expat"))) + args.append("EXPAT_INCLUDE=\"-I{}\"".format(include_paths("expat"))) + if self.options.with_xerces: + args.append("XERCES_DIR=\"{}\"".format(rootpath("xerces-c"))) + args.append("XERCES_INCLUDE=\"-I{}\"".format(include_paths("xerces-c"))) + if self.options.with_jasper: + args.append("JASPER_DIR=\"{}\"".format(rootpath("jasper"))) + if self.options.with_hdf4: + args.append("HDF4_DIR=\"{}\"".format(rootpath("hdf4"))) + args.append("HDF4_INCLUDE=\"{}\"".format(include_paths("hdf4"))) + if version("hdf4") >= "4.2.5": + args.append("HDF4_HAS_MAXOPENFILES=YES") + if self.options.with_hdf5: + args.append("HDF5_DIR=\"{}\"".format(rootpath("hdf5"))) + if self.options.with_kea: + args.append("KEA_CFLAGS=\"-I{}\"".format(include_paths("kealib"))) + if self.options.with_pg: + args.append("PG_INC_DIR=\"{}\"".format(include_paths("libpq"))) + if self.options.with_mysql == "libmysqlclient": + args.append("MYSQL_INC_DIR=\"{}\"".format(include_paths("libmysqlclient"))) + elif self.options.with_mysql == "mariadb-connector-c": + args.append("MYSQL_INC_DIR=\"{}\"".format(include_paths("mariadb-connector-c"))) + if self.options.get_safe("with_sqlite3"): + args.append("SQLITE_INC=\"-I{}\"".format(include_paths("sqlite3"))) + if self.options.get_safe("with_pcre2"): + args.append("PCRE2_INC=\"-I{}\"".format(include_paths("pcre2"))) + if self.options.get_safe("with_pcre"): + args.append("PCRE_INC=\"-I{}\"".format(include_paths("pcre"))) + if self.options.with_cfitsio: + args.append("FITS_INC_DIR=\"{}\"".format(include_paths("cfitsio"))) + if self.options.with_netcdf: + args.extend([ + "NETCDF_SETTING=YES", + "NETCDF_INC_DIR=\"{}\"".format(include_paths("netcdf")) + ]) + if self.options["netcdf"].netcdf4 and self.options["netcdf"].with_hdf5: + args.append("NETCDF_HAS_NC4=YES") + if tools.Version(self.version) >= "3.3.0" and \ + os.path.isfile(os.path.join(self.deps_cpp_info["netcdf"].rootpath, "include", "netcdf_mem.h")): + args.append("NETCDF_HAS_NETCDF_MEM=YES") + if self.options.with_curl: + args.append("CURL_INC=\"-I{}\"".format(include_paths("libcurl"))) + if self.options.with_geos: + args.append("GEOS_CFLAGS=\"-I{} -DHAVE_GEOS\"".format(include_paths("geos"))) + if self.options.with_openjpeg: + args.append("OPENJPEG_ENABLED=YES") + if self.options.get_safe("with_zlib", True): + args.append("ZLIB_EXTERNAL_LIB=1") + args.append("ZLIB_INC=\"-I{}\"".format(include_paths("zlib"))) + if self.options.get_safe("with_libdeflate"): + args.append("LIBDEFLATE_CFLAGS=\"-I{}\"".format(include_paths("libdeflate"))) + if self.options.with_poppler: + poppler_version = version("poppler") + args.extend([ + "POPPLER_ENABLED=YES", + "POPPLER_MAJOR_VERSION={}".format(poppler_version.major), + "POPPLER_MINOR_VERSION={}".format(poppler_version.minor) + ]) + if self.options.with_podofo: + args.append("PODOFO_ENABLED=YES") + if self.options.get_safe("with_zstd"): + args.append("ZSTD_CFLAGS=\"-I{}\"".format(include_paths("zstd"))) + if self.options.get_safe("with_blosc"): + args.append("BLOSC_CFLAGS=\"-I{}\"".format(include_paths("c-blosc"))) + if self.options.get_safe("with_lz4"): + args.append("LZ4_CFLAGS=\"-I{}\"".format(include_paths("lz4"))) + if self.options.with_webp: + args.append("WEBP_ENABLED=YES") + args.append("WEBP_CFLAGS=\"-I{}\"".format(include_paths("libwebp"))) + if self.options.with_xml2: + args.append("LIBXML2_INC=\"-I{}\"".format(include_paths("libxml2"))) + if self.options.with_gta: + args.append("GTA_CFLAGS=\"-I{}\"".format(include_paths("libgta"))) + if self.options.with_mongocxx: + args.append("MONGOCXXV3_CFLAGS=\"-I{}\"".format(include_paths("mongo-cxx-driver"))) + args.append("QHULL_SETTING={}".format("EXTERNAL" if self.options.with_qhull else "NO")) + if self.options.with_qhull and self.options["qhull"].reentrant: + args.append("QHULL_IS_LIBQHULL_R=1") + if self.options.with_cryptopp: + args.append("CRYPTOPP_INC=\"-I{}\"".format(include_paths("cryptopp"))) + if self.options["cryptopp"].shared: + args.append("USE_ONLY_CRYPTODLL_ALG=YES") + if self.options.with_crypto: + args.append("OPENSSL_INC=\"-I{}\"".format(include_paths("openssl"))) + if self.options.without_lerc: + args.append("HAVE_LERC=0") + if self.options.get_safe("with_brunsli"): + args.extend([ + "BRUNSLI_DIR=\"{}\"".format(rootpath("brunsli")), + "BRUNSLI_INC=\"{}\"".format(include_paths("brunsli")), + ]) + if self.options.with_charls: + charls_version = version("charls") + if charls_version >= "2.1.0": + args.append("CHARLS_FLAGS=-DCHARLS_2_1") + elif charls_version >= "2.0.0": + args.append("CHARLS_FLAGS=-DCHARLS_2") + if self.options.with_dds: + args.append("CRUNCH_INC=\"-I{}\"".format(include_paths("crunch"))) + if self.options.get_safe("with_exr"): + args.append("EXR_INC=\"-I{}\"".format(include_paths("openexr"))) + if self.options.get_safe("with_heif"): + args.append("HEIF_INC=\"-I{}\"".format(include_paths("libheif"))) + + return args + + def _gather_libs(self, p): + libs = self.deps_cpp_info[p].libs + self.deps_cpp_info[p].system_libs + for dep in self.deps_cpp_info[p].public_deps: + for l in self._gather_libs(dep): + if not l in libs: + libs.append(l) + return libs + + @functools.lru_cache(1) + def _configure_autotools(self): + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + + yes_no = lambda v: "yes" if v else "no" + internal_no = lambda v: "internal" if v else "no" + rootpath = lambda req: tools.unix_path(self.deps_cpp_info[req].rootpath) + rootpath_no = lambda v, req: rootpath(req) if v else "no" + + args = [] + args.append("--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res")))) + # Shared/Static + args.extend([ + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-shared={}".format(yes_no(self.options.shared)), + ]) + args.append("--includedir={}".format(tools.unix_path(os.path.join(self.package_folder, "include", "gdal")))) + + # Enable C++14 if requested in conan profile or if with_charls enabled + if (self.settings.compiler.cppstd and tools.valid_min_cppstd(self, 14)) or self.options.with_charls: + args.append("--with-cpp14") + # Debug + if self.settings.build_type == "Debug": + args.append("--enable-debug") + # SIMD Intrinsics + simd_intrinsics = self.options.get_safe("simd_intrinsics", False) + if not simd_intrinsics: + args.extend(["--without-sse", "--without-ssse3", "--without-avx"]) + elif simd_intrinsics == "sse": + args.extend(["--with-sse", "--without-ssse3", "--without-avx"]) + elif simd_intrinsics == "ssse3": + args.extend(["--with-sse", "--with-ssse3", "--without-avx"]) + elif simd_intrinsics == "avx": + args.extend(["--with-sse", "--with-ssse3", "--with-avx"]) + # LTO (disabled) + args.append("--disable-lto") + # Symbols + args.append("--with-hide_internal_symbols") + # Do not add /usr/local/lib and /usr/local/include + args.append("--without-local") + # Threadsafe + args.append("--with-threads={}".format(yes_no(self.options.threadsafe))) + # Depencencies: + args.append("--with-proj=yes") # always required ! + args.append("--with-libz={}".format(yes_no(self.options.with_zlib))) + if self._has_with_libdeflate_option: + args.append("--with-libdeflate={}".format(yes_no(self.options.with_libdeflate))) + args.append("--with-libiconv-prefix={}".format(rootpath_no(self.options.with_libiconv, "libiconv"))) + args.append("--with-liblzma=no") # always disabled: liblzma is an optional transitive dependency of gdal (through libtiff). + args.append("--with-zstd={}".format(yes_no(self.options.get_safe("with_zstd")))) # Optional direct dependency of gdal only if lerc lib enabled + if self._has_with_blosc_option: + args.append("--with-blosc={}".format(yes_no(self.options.with_blosc))) + if self._has_with_lz4_option: + args.append("--with-lz4={}".format(yes_no(self.options.with_lz4))) + # Drivers: + if not (self.options.with_zlib and self.options.with_png and bool(self.options.with_jpeg)): + # MRF raster driver always depends on zlib, libpng and libjpeg: https://github.com/OSGeo/gdal/issues/2581 + if tools.Version(self.version) < "3.0.0": + args.append("--without-mrf") + else: + args.append("--disable-driver-mrf") + args.append("--with-pg={}".format(yes_no(self.options.with_pg))) + args.extend(["--without-grass", "--without-libgrass"]) # TODO: to implement when libgrass lib available + args.append("--with-cfitsio={}".format(rootpath_no(self.options.with_cfitsio, "cfitsio"))) + args.append("--with-pcraster={}".format(internal_no(self.options.with_pcraster))) # TODO: use conan recipe when available instead of internal one + args.append("--with-png={}".format(rootpath_no(self.options.with_png, "libpng"))) + args.append("--with-dds={}".format(rootpath_no(self.options.with_dds, "crunch"))) + args.append("--with-gta={}".format(rootpath_no(self.options.with_gta, "libgta"))) + args.append("--with-pcidsk={}".format(internal_no(self.options.with_pcidsk))) # TODO: use conan recipe when available instead of internal one + args.append("--with-libtiff={}".format(rootpath("libtiff"))) # always required ! + args.append("--with-geotiff={}".format(rootpath("libgeotiff"))) # always required ! + if self.options.with_jpeg == "libjpeg": + args.append("--with-jpeg={}".format(rootpath("libjpeg"))) + elif self.options.with_jpeg == "libjpeg-turbo": + args.append("--with-jpeg={}".format(rootpath("libjpeg-turbo"))) + else: + args.append("--without-jpeg") + args.append("--without-jpeg12") # disabled: it requires internal libjpeg and libgeotiff + args.append("--with-charls={}".format(yes_no(self.options.with_charls))) + args.append("--with-gif={}".format(rootpath_no(self.options.with_gif, "giflib"))) + args.append("--without-ogdi") # TODO: to implement when ogdi lib available (https://sourceforge.net/projects/ogdi/) + args.append("--without-fme") # commercial library + args.append("--without-sosi") # TODO: to implement when fyba lib available + args.append("--without-mongocxx") # TODO: handle mongo-cxx-driver v2 + args.append("--with-mongocxxv3={}".format(yes_no(self.options.with_mongocxx))) + args.append("--with-hdf4={}".format(yes_no(self.options.with_hdf4))) + args.append("--with-hdf5={}".format(yes_no(self.options.with_hdf5))) + args.append("--with-kea={}".format(yes_no(self.options.with_kea))) + args.append("--with-netcdf={}".format(rootpath_no(self.options.with_netcdf, "netcdf"))) + args.append("--with-jasper={}".format(rootpath_no(self.options.with_jasper, "jasper"))) + args.append("--with-openjpeg={}".format(yes_no(self.options.with_openjpeg))) + args.append("--without-fgdb") # TODO: to implement when file-geodatabase-api lib available + args.append("--without-ecw") # commercial library + args.append("--without-kakadu") # commercial library + args.extend(["--without-mrsid", "--without-jp2mrsid", "--without-mrsid_lidar"]) # commercial library + args.append("--without-jp2lura") # commercial library + args.append("--without-msg") # commercial library + args.append("--without-oci") # TODO + args.append("--with-gnm={}".format(yes_no(self.options.with_gnm))) + args.append("--with-mysql={}".format(yes_no(self.options.with_mysql))) + args.append("--without-ingres") # commercial library + args.append("--with-xerces={}".format(rootpath_no(self.options.with_xerces, "xerces-c"))) + args.append("--with-expat={}".format(yes_no(self.options.with_expat))) + args.append("--with-libkml={}".format(rootpath_no(self.options.with_libkml, "libkml"))) + if self.options.with_odbc: + args.append("--with-odbc={}".format("yes" if self.settings.os == "Windows" else rootpath("odbc"))) + else: + args.append("--without-odbc") + args.append("--without-dods-root") # TODO: to implement when libdap lib available + args.append("--with-curl={}".format(yes_no(self.options.with_curl))) + args.append("--with-xml2={}".format(yes_no(self.options.with_xml2))) + args.append("--without-spatialite") # TODO: to implement when libspatialite lib available + args.append("--with-sqlite3={}".format(yes_no(self.options.get_safe("with_sqlite3")))) + args.append("--without-rasterlite2") # TODO: to implement when rasterlite2 lib available + if self._has_with_pcre2_option: + args.append("--with-pcre2={}".format(yes_no(self.options.get_safe("with_pcre2")))) + args.append("--with-pcre={}".format(yes_no(self.options.get_safe("with_pcre")))) + args.append("--without-teigha") # commercial library + args.append("--without-idb") # commercial library + if tools.Version(self.version) < "3.2.0": + args.append("--without-sde") # commercial library + if tools.Version(self.version) < "3.3.0": + args.append("--without-epsilon") + args.append("--with-webp={}".format(rootpath_no(self.options.with_webp, "libwebp"))) + args.append("--with-geos={}".format(yes_no(self.options.with_geos))) + args.append("--without-sfcgal") # TODO: to implement when sfcgal lib available + args.append("--with-qhull={}".format(yes_no(self.options.with_qhull))) + if self.options.with_opencl: + args.extend([ + "--with-opencl", + "--with-opencl-include={}".format(tools.unix_path(self.deps_cpp_info["opencl-headers"].include_paths[0])), + "--with-opencl-lib=-L{}".format(tools.unix_path(self.deps_cpp_info["opencl-icd-loader"].lib_paths[0])) + ]) + else: + args.append("--without-opencl") + args.append("--with-freexl={}".format(yes_no(self.options.with_freexl))) + args.append("--with-libjson-c={}".format(rootpath("json-c"))) # always required ! + if self.options.without_pam: + args.append("--without-pam") + args.append("--with-poppler={}".format(yes_no(self.options.with_poppler))) + args.append("--with-podofo={}".format(rootpath_no(self.options.with_podofo, "podofo"))) + if self.options.with_podofo: + args.append("--with-podofo-lib=-l{}".format(" -l".join(self._gather_libs("podofo")))) + args.append("--without-pdfium") # TODO: to implement when pdfium lib available + args.append("--without-perl") + args.append("--without-python") + args.append("--without-java") + args.append("--without-hdfs") + if tools.Version(self.version) >= "3.0.0": + args.append("--without-tiledb") # TODO: to implement when tiledb lib available + args.append("--without-mdb") + args.append("--without-rasdaman") # TODO: to implement when rasdaman lib available + if self._has_with_brunsli_option: + args.append("--with-brunsli={}".format(yes_no(self.options.with_brunsli))) + if tools.Version(self.version) >= "3.1.0": + args.append("--without-rdb") # commercial library + args.append("--without-armadillo") # TODO: to implement when armadillo lib available + args.append("--with-cryptopp={}".format(rootpath_no(self.options.with_cryptopp, "cryptopp"))) + args.append("--with-crypto={}".format(yes_no(self.options.with_crypto))) + if tools.Version(self.version) >= "3.3.0": + args.append("--with-lerc={}".format(internal_no(not self.options.without_lerc))) + else: + args.append("--with-lerc={}".format(yes_no(not self.options.without_lerc))) + if self.options.with_null: + args.append("--with-null") + if self._has_with_exr_option: + args.append("--with-exr={}".format(yes_no(self.options.with_exr))) + if self._has_with_heif_option: + args.append("--with-heif={}".format(yes_no(self.options.with_heif))) + + # Inject -stdlib=libc++ for clang with libc++ + env_build_vars = autotools.vars + if self.settings.compiler == "clang" and \ + self.settings.os == "Linux" and tools.stdcpp_library(self) == "c++": + env_build_vars["LDFLAGS"] = "-stdlib=libc++ {}".format(env_build_vars["LDFLAGS"]) + + autotools.configure(args=args, vars=env_build_vars) + return autotools + + @contextmanager + def _msvc_build_environment(self): + with tools.chdir(self._source_subfolder): + with tools.vcvars(self.settings): + with tools.environment_append(VisualStudioBuildEnvironment(self).vars): + yield + + @contextmanager + def _autotools_build_environment(self): + with tools.chdir(self._source_subfolder): + with tools.run_environment(self): + with tools.environment_append({"PKG_CONFIG_PATH": tools.unix_path(self.build_folder)}): + yield + + def build(self): + self._validate_dependency_graph() + self._patch_sources() + if is_msvc(self): + self._edit_nmake_opt() + with self._msvc_build_environment(): + self.run("nmake -f makefile.vc {}".format(" ".join(self._nmake_args))) + else: + with self._autotools_build_environment(): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + # Required for cross-build to iOS, see https://github.com/OSGeo/gdal/issues/4123 + tools.replace_in_file(os.path.join("port", "cpl_config.h.in"), + "/* port/cpl_config.h.in", + "#pragma once\n/* port/cpl_config.h.in") + # Relocatable shared lib on macOS + tools.replace_in_file("configure", + "-install_name \\$rpath/", + "-install_name @rpath/") + # avoid SIP issues on macOS when dependencies are shared + if tools.is_apple_os(self.settings.os): + libpaths = ":".join(self.deps_cpp_info.lib_paths) + tools.replace_in_file( + "configure", + "#! /bin/sh\n", + "#! /bin/sh\nexport DYLD_LIBRARY_PATH={}:$DYLD_LIBRARY_PATH\n".format(libpaths), + ) + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("LICENSE.TXT", dst="licenses", src=self._source_subfolder) + if is_msvc(self): + with self._msvc_build_environment(): + self.run("nmake -f makefile.vc devinstall {}".format(" ".join(self._nmake_args))) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.pdb") + else: + with self._autotools_build_environment(): + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "gdalplugins")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "GDAL") + self.cpp_info.set_property("cmake_target_name", "GDAL::GDAL") + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("pkg_config_name", "gdal") + + self.cpp_info.names["cmake_find_package"] = "GDAL" + self.cpp_info.names["cmake_find_package_multi"] = "GDAL" + self.cpp_info.filenames["cmake_find_package"] = "GDAL" + self.cpp_info.filenames["cmake_find_package_multi"] = "GDAL" + self.cpp_info.includedirs.append(os.path.join("include", "gdal")) + + lib_suffix = "" + if is_msvc(self): + if self.options.shared: + lib_suffix += "_i" + if self.settings.build_type == "Debug": + lib_suffix += "_d" + self.cpp_info.libs = ["gdal{}".format(lib_suffix)] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["dl", "m"]) + if self.options.threadsafe: + self.cpp_info.system_libs.append("pthread") + elif self.settings.os == "Windows": + self.cpp_info.system_libs.extend(["psapi", "ws2_32"]) + if tools.Version(self.version) >= "3.2.0" and is_msvc(self): + self.cpp_info.system_libs.append("wbemuuid") + if self.options.with_odbc and not self.options.shared: + self.cpp_info.system_libs.extend(["odbc32", "odbccp32"]) + if is_msvc(self): + self.cpp_info.system_libs.append("legacy_stdio_definitions") + if not self.options.shared and tools.stdcpp_library(self): + self.cpp_info.system_libs.append(tools.stdcpp_library(self)) + + gdal_data_path = os.path.join(self.package_folder, "res", "gdal") + self.output.info("Prepending to GDAL_DATA environment variable: {}".format(gdal_data_path)) + self.runenv_info.prepend_path("GDAL_DATA", gdal_data_path) + # TODO: to remove after conan v2, it allows to not break consumers still relying on virtualenv generator + self.env_info.GDAL_DATA = gdal_data_path + + if self.options.tools: + self.buildenv_info.prepend_path("GDAL_DATA", gdal_data_path) + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/gdal/all/patches/3.1.x/fix-autotools-3.1.4.patch b/recipes/gdal/pre_3.5.0/patches/3.1.x/fix-autotools-3.1.4.patch similarity index 92% rename from recipes/gdal/all/patches/3.1.x/fix-autotools-3.1.4.patch rename to recipes/gdal/pre_3.5.0/patches/3.1.x/fix-autotools-3.1.4.patch index 05e541c117509..974146f6a3f7a 100644 --- a/recipes/gdal/all/patches/3.1.x/fix-autotools-3.1.4.patch +++ b/recipes/gdal/pre_3.5.0/patches/3.1.x/fix-autotools-3.1.4.patch @@ -62,7 +62,7 @@ echo "hdf4 support disabled." +elif test x"$with_hdf4" = x"yes" ; then -+ PKG_CHECK_MODULES([HDF4], [hdf], [HAVE_HDF4=yes], [HAVE_HDF4=no]) ++ PKG_CHECK_MODULES([HDF4], [hdf], [HAVE_HDF4=yes], [AC_MSG_ERROR([hdf4 not found...])]) + PKG_CHECK_MODULES([HDF4], [hdf >= 4.2.5], [HDF4_HAS_MAXOPENFILES=yes], [HDF4_HAS_MAXOPENFILES=no]) + HDF4_INCLUDE="$HDF4_CFLAGS" else @@ -134,7 +134,7 @@ +HAVE_EXPAT=no +AC_ARG_WITH([expat], AS_HELP_STRING([--with-expat[=ARG]], [use Expat library (ARG=yes or no)]),,) +if test x"$with_expat" = x"yes" ; then -+PKG_CHECK_MODULES([EXPAT], [expat >= 1.95.0], [HAVE_EXPAT=yes], [HAVE_EXPAT=no]) ++PKG_CHECK_MODULES([EXPAT], [expat >= 1.95.0], [HAVE_EXPAT=yes], [AC_MSG_ERROR([expat not found...])]) if test "$HAVE_EXPAT" = "yes"; then LIBS="$EXPAT_LDFLAGS $LIBS" @@ -168,7 +168,7 @@ - AC_CHECK_LIB(curl,curl_global_init,CURL_SETTING=yes,CURL_SETTING=no,`$LIBCURL_CONFIG --libs`) +if test "$with_curl" = "yes" ; then -+ PKG_CHECK_MODULES([CURL], [libcurl], [CURL_SETTING=yes], [CURL_SETTING=no]) ++ PKG_CHECK_MODULES([CURL], [libcurl], [CURL_SETTING=yes], [AC_MSG_ERROR([libcurl not found...])]) +else + CURL_SETTING=no fi @@ -200,34 +200,36 @@ - SQLITE3_REQ_VERSION="3.0.0" - AX_LIB_SQLITE3($SQLITE3_REQ_VERSION) + if test x"$with_sqlite3" = x"yes" ; then -+ PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.0.0], [HAVE_SQLITE3=yes], [HAVE_SQLITE3=no]) ++ PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.0.0], [HAVE_SQLITE3=yes], [AC_MSG_ERROR([sqlite3 not found...])]) + fi if test "$HAVE_SQLITE3" = "yes"; then LIBS="$SQLITE3_LDFLAGS $LIBS" -@@ -4597,8 +4586,12 @@ dnl --------------------------------------------------------------------------- +@@ -4597,8 +4586,13 @@ dnl --------------------------------------------------------------------------- dnl Check if geos library is available. dnl --------------------------------------------------------------------------- -GEOS_INIT(3.1.0) +AC_ARG_WITH(geos, AS_HELP_STRING([--with-geos[=ARG]], [Include GEOS support (ARG=yes or no)]),,) HAVE_GEOS_RESULT="no" ++HAVE_GEOS=no +if test x"$with_geos" = x"no" ; then + AC_MSG_RESULT([GEOS support disabled]) +else -+ PKG_CHECK_MODULES([GEOS], [geos >= 3.1.0], [HAVE_GEOS=yes], [HAVE_GEOS=no]) ++ PKG_CHECK_MODULES([GEOS], [geos >= 3.1.0], [HAVE_GEOS=yes], [AC_MSG_ERROR([geos not found...])]) if test "${HAVE_GEOS}" = "yes" ; then AC_MSG_NOTICE([Using C API from GEOS $GEOS_VERSION]) -@@ -4607,6 +4600,7 @@ if test "${HAVE_GEOS}" = "yes" ; then +@@ -4607,6 +4601,8 @@ if test "${HAVE_GEOS}" = "yes" ; then LIBS="${GEOS_LIBS} ${LIBS}" HAVE_GEOS_RESULT="yes" fi +fi ++AC_SUBST(HAVE_GEOS, $HAVE_GEOS) dnl --------------------------------------------------------------------------- dnl Check if SFCGAL library is available. -@@ -4641,20 +4635,18 @@ elif test "$with_qhull" = "yes" -o "$with_qhull" = "" ; then +@@ -4641,20 +4637,18 @@ elif test "$with_qhull" = "yes" -o "$with_qhull" = "" ; then # qhull/qhull.h AC_CHECK_HEADERS([qhull/libqhull.h]) if test "$ac_cv_header_qhull_libqhull_h" = "yes"; then @@ -250,18 +252,18 @@ fi fi -@@ -4741,7 +4733,9 @@ AC_MSG_CHECKING([for FreeXL support]) +@@ -4741,7 +4735,9 @@ AC_MSG_CHECKING([for FreeXL support]) HAVE_FREEXL=no FREEXL_INCLUDE= -if test "$with_freexl" = "" -o "$with_freexl" = "yes" ; then +if test "$with_freexl" = "yes"; then -+ PKG_CHECK_MODULES([FREEXL], [freexl >= 1.0.0], [HAVE_FREEXL=yes], [HAVE_FREEXL=no]) ++ PKG_CHECK_MODULES([FREEXL], [freexl >= 1.0.0], [HAVE_FREEXL=yes], [AC_MSG_ERROR([freexl not found...])]) +elif test "$with_freexl" = ""; then AC_CHECK_HEADERS(freexl.h) AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl",FREEXL_LIBS=missing) -@@ -4847,8 +4841,7 @@ if test "$with_libjson_c" = "external" -o "$with_libjson_c" = "" -o "$with_libjs +@@ -4847,8 +4843,7 @@ if test "$with_libjson_c" = "external" -o "$with_libjson_c" = "" -o "$with_libjs elif test "$with_libjson_c" = "internal" ; then LIBJSONC_SETTING=internal elif test "$with_libjson_c" != "no"; then @@ -271,7 +273,7 @@ else AC_MSG_ERROR([libjson-c (internal or external) is required]) fi -@@ -5952,7 +5945,6 @@ else +@@ -5952,7 +5947,6 @@ else # Test that the package found is for the right architecture saved_LIBS="$LIBS" LIBS="$EXR_LIBS" diff --git a/recipes/gdal/all/patches/3.1.x/fix-import-dll-msvc.patch b/recipes/gdal/pre_3.5.0/patches/3.1.x/fix-import-dll-msvc.patch similarity index 100% rename from recipes/gdal/all/patches/3.1.x/fix-import-dll-msvc.patch rename to recipes/gdal/pre_3.5.0/patches/3.1.x/fix-import-dll-msvc.patch diff --git a/recipes/gdal/all/patches/3.1.x/fix-include-jsonc.patch b/recipes/gdal/pre_3.5.0/patches/3.1.x/fix-include-jsonc.patch similarity index 100% rename from recipes/gdal/all/patches/3.1.x/fix-include-jsonc.patch rename to recipes/gdal/pre_3.5.0/patches/3.1.x/fix-include-jsonc.patch diff --git a/recipes/gdal/pre_3.5.0/patches/3.1.x/fix-include-podofo.patch b/recipes/gdal/pre_3.5.0/patches/3.1.x/fix-include-podofo.patch new file mode 100644 index 0000000000000..aa86489f0296b --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.1.x/fix-include-podofo.patch @@ -0,0 +1,11 @@ +--- a/frmts/pdf/pdfsdk_headers.h ++++ b/frmts/pdf/pdfsdk_headers.h +@@ -103,7 +103,7 @@ typedef unsigned char Guchar; + #undef GetObject + #endif + +-#include "podofo.h" ++#include + #endif // HAVE_PODOFO + + #ifdef HAVE_PDFIUM diff --git a/recipes/gdal/all/patches/3.1.x/fix-include-xerces-3.1.2.patch b/recipes/gdal/pre_3.5.0/patches/3.1.x/fix-include-xerces-3.1.2.patch similarity index 100% rename from recipes/gdal/all/patches/3.1.x/fix-include-xerces-3.1.2.patch rename to recipes/gdal/pre_3.5.0/patches/3.1.x/fix-include-xerces-3.1.2.patch diff --git a/recipes/gdal/all/patches/3.1.x/fix-nmake-common.patch b/recipes/gdal/pre_3.5.0/patches/3.1.x/fix-nmake-common.patch similarity index 100% rename from recipes/gdal/all/patches/3.1.x/fix-nmake-common.patch rename to recipes/gdal/pre_3.5.0/patches/3.1.x/fix-nmake-common.patch diff --git a/recipes/gdal/all/patches/3.1.x/fix-nmake-opt-3.1.2.patch b/recipes/gdal/pre_3.5.0/patches/3.1.x/fix-nmake-opt-3.1.2.patch similarity index 100% rename from recipes/gdal/all/patches/3.1.x/fix-nmake-opt-3.1.2.patch rename to recipes/gdal/pre_3.5.0/patches/3.1.x/fix-nmake-opt-3.1.2.patch diff --git a/recipes/gdal/all/patches/3.2.x/fix-autotools.patch b/recipes/gdal/pre_3.5.0/patches/3.2.x/fix-autotools.patch similarity index 92% rename from recipes/gdal/all/patches/3.2.x/fix-autotools.patch rename to recipes/gdal/pre_3.5.0/patches/3.2.x/fix-autotools.patch index 9a30598e36f3e..52c88a271ee47 100644 --- a/recipes/gdal/all/patches/3.2.x/fix-autotools.patch +++ b/recipes/gdal/pre_3.5.0/patches/3.2.x/fix-autotools.patch @@ -57,7 +57,7 @@ - LIBCURL_CONFIG=no +PKG_PROG_PKG_CONFIG([0.21]) +if test "$with_curl" = "yes" ; then -+ PKG_CHECK_MODULES([CURL], [libcurl], [CURL_SETTING=yes], [CURL_SETTING=no]) ++ PKG_CHECK_MODULES([CURL], [libcurl], [CURL_SETTING=yes], [AC_MSG_ERROR([libcurl not found...])]) else - AC_PATH_PROG(LIBCURL_CONFIG, curl-config, no) -fi @@ -84,7 +84,7 @@ +HAVE_SQLITE3=no +AC_ARG_WITH(sqlite3, AS_HELP_STRING([--with-sqlite3[=ARG]], [use SQLite 3 library (ARG=yes or no)]),,) +if test x"$with_sqlite3" = x"yes" ; then -+ PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.0.0], [HAVE_SQLITE3=yes], [HAVE_SQLITE3=no]) ++ PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.0.0], [HAVE_SQLITE3=yes], [AC_MSG_ERROR([sqlite3 not found...])]) +fi if test "$HAVE_SQLITE3" = "yes"; then @@ -134,7 +134,7 @@ echo "hdf4 support disabled." +elif test x"$with_hdf4" = x"yes" ; then -+ PKG_CHECK_MODULES([HDF4], [hdf], [HAVE_HDF4=yes], [HAVE_HDF4=no]) ++ PKG_CHECK_MODULES([HDF4], [hdf], [HAVE_HDF4=yes], [AC_MSG_ERROR([hdf4 not found...])]) + PKG_CHECK_MODULES([HDF4], [hdf >= 4.2.5], [HDF4_HAS_MAXOPENFILES=yes], [HDF4_HAS_MAXOPENFILES=no]) + HDF4_INCLUDE="$HDF4_CFLAGS" else @@ -206,7 +206,7 @@ +HAVE_EXPAT=no +AC_ARG_WITH([expat], AS_HELP_STRING([--with-expat[=ARG]], [use Expat library (ARG=yes or no)]),,) +if test x"$with_expat" = x"yes" ; then -+PKG_CHECK_MODULES([EXPAT], [expat >= 1.95.0], [HAVE_EXPAT=yes], [HAVE_EXPAT=no]) ++PKG_CHECK_MODULES([EXPAT], [expat >= 1.95.0], [HAVE_EXPAT=yes], [AC_MSG_ERROR([expat not found...])]) if test "$HAVE_EXPAT" = "yes"; then LIBS="$EXPAT_LDFLAGS $LIBS" @@ -226,29 +226,31 @@ LIBS="${SAVED_LIBS}" fi -@@ -4567,8 +4559,12 @@ dnl --------------------------------------------------------------------------- +@@ -4567,8 +4559,13 @@ dnl --------------------------------------------------------------------------- dnl Check if geos library is available. dnl --------------------------------------------------------------------------- -GEOS_INIT(3.1.0) +AC_ARG_WITH(geos, AS_HELP_STRING([--with-geos[=ARG]], [Include GEOS support (ARG=yes or no)]),,) HAVE_GEOS_RESULT="no" ++HAVE_GEOS=no +if test x"$with_geos" = x"no" ; then + AC_MSG_RESULT([GEOS support disabled]) +else -+ PKG_CHECK_MODULES([GEOS], [geos >= 3.1.0], [HAVE_GEOS=yes], [HAVE_GEOS=no]) ++ PKG_CHECK_MODULES([GEOS], [geos >= 3.1.0], [HAVE_GEOS=yes], [AC_MSG_ERROR([geos not found...])]) if test "${HAVE_GEOS}" = "yes" ; then AC_MSG_NOTICE([Using C API from GEOS $GEOS_VERSION]) -@@ -4577,6 +4573,7 @@ if test "${HAVE_GEOS}" = "yes" ; then +@@ -4577,6 +4574,8 @@ if test "${HAVE_GEOS}" = "yes" ; then LIBS="${GEOS_LIBS} ${LIBS}" HAVE_GEOS_RESULT="yes" fi +fi ++AC_SUBST(HAVE_GEOS, $HAVE_GEOS) dnl --------------------------------------------------------------------------- dnl Check if SFCGAL library is available. -@@ -4611,20 +4608,18 @@ elif test "$with_qhull" = "yes" -o "$with_qhull" = "" ; then +@@ -4611,20 +4610,18 @@ elif test "$with_qhull" = "yes" -o "$with_qhull" = "" ; then # qhull/qhull.h AC_CHECK_HEADERS([qhull/libqhull.h]) if test "$ac_cv_header_qhull_libqhull_h" = "yes"; then @@ -271,18 +273,18 @@ fi fi -@@ -4711,7 +4706,9 @@ AC_MSG_CHECKING([for FreeXL support]) +@@ -4711,7 +4708,9 @@ AC_MSG_CHECKING([for FreeXL support]) HAVE_FREEXL=no FREEXL_INCLUDE= -if test "$with_freexl" = "" -o "$with_freexl" = "yes" ; then +if test "$with_freexl" = "yes"; then -+ PKG_CHECK_MODULES([FREEXL], [freexl >= 1.0.0], [HAVE_FREEXL=yes], [HAVE_FREEXL=no]) ++ PKG_CHECK_MODULES([FREEXL], [freexl >= 1.0.0], [HAVE_FREEXL=yes], [AC_MSG_ERROR([freexl not found...])]) +elif test "$with_freexl" = ""; then AC_CHECK_HEADERS(freexl.h) AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl",FREEXL_LIBS=missing) -@@ -4817,8 +4814,7 @@ if test "$with_libjson_c" = "external" -o "$with_libjson_c" = "" -o "$with_libjs +@@ -4817,8 +4816,7 @@ if test "$with_libjson_c" = "external" -o "$with_libjson_c" = "" -o "$with_libjs elif test "$with_libjson_c" = "internal" ; then LIBJSONC_SETTING=internal elif test "$with_libjson_c" != "no"; then @@ -292,7 +294,7 @@ else AC_MSG_ERROR([libjson-c (internal or external) is required]) fi -@@ -5928,7 +5924,6 @@ else +@@ -5928,7 +5926,6 @@ else # Test that the package found is for the right architecture saved_LIBS="$LIBS" LIBS="$EXR_LIBS" diff --git a/recipes/gdal/all/patches/3.2.x/fix-include-jsonc.patch b/recipes/gdal/pre_3.5.0/patches/3.2.x/fix-include-jsonc.patch similarity index 100% rename from recipes/gdal/all/patches/3.2.x/fix-include-jsonc.patch rename to recipes/gdal/pre_3.5.0/patches/3.2.x/fix-include-jsonc.patch diff --git a/recipes/gdal/pre_3.5.0/patches/3.2.x/fix-include-podofo.patch b/recipes/gdal/pre_3.5.0/patches/3.2.x/fix-include-podofo.patch new file mode 100644 index 0000000000000..aa86489f0296b --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.2.x/fix-include-podofo.patch @@ -0,0 +1,11 @@ +--- a/frmts/pdf/pdfsdk_headers.h ++++ b/frmts/pdf/pdfsdk_headers.h +@@ -103,7 +103,7 @@ typedef unsigned char Guchar; + #undef GetObject + #endif + +-#include "podofo.h" ++#include + #endif // HAVE_PODOFO + + #ifdef HAVE_PDFIUM diff --git a/recipes/gdal/all/patches/3.2.x/fix-include-xerces.patch b/recipes/gdal/pre_3.5.0/patches/3.2.x/fix-include-xerces.patch similarity index 100% rename from recipes/gdal/all/patches/3.2.x/fix-include-xerces.patch rename to recipes/gdal/pre_3.5.0/patches/3.2.x/fix-include-xerces.patch diff --git a/recipes/gdal/all/patches/3.2.x/fix-nmake.patch b/recipes/gdal/pre_3.5.0/patches/3.2.x/fix-nmake.patch similarity index 100% rename from recipes/gdal/all/patches/3.2.x/fix-nmake.patch rename to recipes/gdal/pre_3.5.0/patches/3.2.x/fix-nmake.patch diff --git a/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-autotools-3.3.3.patch b/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-autotools-3.3.3.patch new file mode 100644 index 0000000000000..a5746b4d1e05f --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-autotools-3.3.3.patch @@ -0,0 +1,302 @@ +--- a/GDALmake.opt.in ++++ b/GDALmake.opt.in +@@ -600,7 +600,7 @@ endif + + ifeq ($(HAVE_LIBTOOL), yes) + +-CONFIG_LIBS = $(GDAL_ROOT)/$(LIBGDAL) ++CONFIG_LIBS = $(GDAL_ROOT)/$(LIBGDAL) $(LIBS) + ifeq ($(MACOSX_FRAMEWORK),yes) + CONFIG_LIBS_INS = -L$(INST_LIB)/unix/lib -lgdal + else +--- a/configure.ac ++++ b/configure.ac +@@ -1175,6 +1175,10 @@ AC_ARG_WITH(libdeflate, + [enable libdeflate usage (optional for faster Deflate support (still requires zlib) (ARG=yes/no/prefix), enabled by default)]),,) + + if test "$with_libdeflate" != "no" ; then ++# AC_CHECK_LIB tests not robust enough (don't handle static libdeflate on windows) ++if test "$with_libdeflate" = "yes" ; then ++ LIBDEFLATE_SETTING=yes ++else + + if test "$with_libdeflate" != "" -a "$with_libdeflate" != "yes"; then + AC_CHECK_LIB(deflate, libdeflate_zlib_decompress, [libdeflate_lib=yes], [libdeflate_lib=no],-L$with_libdeflate/lib) +@@ -1204,13 +1208,13 @@ if test "$with_libdeflate" != "no" ; then + fi + + fi ++fi + + if test "$LIBDEFLATE_SETTING" = "yes" ; then + if test "$with_libdeflate" != "" -a "$with_libdeflate" != "yes"; then + EXTRA_INCLUDES="-I$with_libdeflate/include $EXTRA_INCLUDES" + LIBS="-L$with_libdeflate/lib -ldeflate $LIBS" +- else +- LIBS="-ldeflate $LIBS" ++ # Too fragile: libdeflate static lib name on windows is libdeflatestatic + fi + fi + +@@ -1378,7 +1382,7 @@ else + AC_MSG_RESULT([using libtiff from ${with_libtiff}.]) + + dnl Check for the BigTIFF enabled library (libtiff >= 4.0) +- AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,) ++ AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,$LIBS) + + fi + +@@ -1402,23 +1406,11 @@ AC_ARG_WITH(curl, + dnl Clear some cache variables + unset ac_cv_path_LIBCURL + +-if test "`basename xx/$with_curl`" = "curl-config" ; then +- LIBCURL_CONFIG="$with_curl" +-elif test "$with_curl" = "no" ; then +- LIBCURL_CONFIG=no ++PKG_PROG_PKG_CONFIG([0.21]) ++if test "$with_curl" = "yes" ; then ++ PKG_CHECK_MODULES([CURL], [libcurl], [CURL_SETTING=yes], [AC_MSG_ERROR([libcurl not found...])]) + else +- AC_PATH_PROG(LIBCURL_CONFIG, curl-config, no) +-fi +- +-if test "$LIBCURL_CONFIG" != "no" ; then +- +- CURL_VERNUM=`$LIBCURL_CONFIG --vernum` +- CURL_VER=`$LIBCURL_CONFIG --version | awk '{print $2}'` +- +- AC_MSG_RESULT([ found libcurl version $CURL_VER]) +- +- AC_CHECK_LIB(curl,curl_global_init,CURL_SETTING=yes,CURL_SETTING=no,`$LIBCURL_CONFIG --libs`) +- ++ CURL_SETTING=no + fi + + AC_SUBST(CURL_SETTING,$CURL_SETTING) +@@ -1430,8 +1422,11 @@ dnl Check for SQLite + dnl Proj depends on it so it must appear before. + dnl --------------------------------------------------------------------------- + +-SQLITE3_REQ_VERSION="3.0.0" +-AX_LIB_SQLITE3($SQLITE3_REQ_VERSION) ++HAVE_SQLITE3=no ++AC_ARG_WITH(sqlite3, AS_HELP_STRING([--with-sqlite3[=ARG]], [use SQLite 3 library (ARG=yes or no)]),,) ++if test x"$with_sqlite3" = x"yes" ; then ++ PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.0.0], [HAVE_SQLITE3=yes], [AC_MSG_ERROR([sqlite3 not found...])]) ++fi + + if test "$HAVE_SQLITE3" = "yes"; then + LIBS="$SQLITE3_LDFLAGS $LIBS" +@@ -1462,11 +1457,7 @@ if test "x$with_proj" = "xno" ; then + else + + if test "x$with_proj" = "xyes" -o "x$with_proj" = "x"; then +- ORIG_LIBS="$LIBS" +- LIBS="-lproj $with_proj_extra_lib_for_test $ORIG_LIBS" +- AC_LANG_PUSH([C++]) +- AC_CHECK_LIB(proj,proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,) +- AC_LANG_POP([C++]) ++ PROJ_FOUND=yes + if test "$PROJ_FOUND" = "no"; then + AC_LANG_PUSH([C++]) + AC_CHECK_LIB(proj,internal_proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,) +@@ -1889,8 +1880,8 @@ fi + + if test "$CURL_SETTING" = "yes" ; then + +- CURL_INC=`$LIBCURL_CONFIG --cflags` +- CURL_LIB=`$LIBCURL_CONFIG --libs` ++ CURL_INC="$CURL_CFLAGS" ++ CURL_LIB="$CURL_LIBS" + m4_foreach_w([frmt],CURL_FORMATS,[ + driver_enabled=m4_join([_],[$INTERNAL_FORMAT],frmt,[ENABLED]) + if test "x$driver_enabled" = "xyes"; then +@@ -2222,7 +2213,6 @@ else + + DDS_SETTING=yes + CRUNCHDIR="$with_dds" +- LIBS="-L$with_dds/lib/ -lcrunch $LIBS" + echo "using libcrunch from $with_dds." + + fi +@@ -2373,7 +2363,6 @@ else + + dnl We now require libgeotiff 1.5.0 + dnl first check if $with_geotiff/lib has the library: +- AC_CHECK_LIB(geotiff,GTIFAttachPROJContext,GEOTIFF_SETTING=external,GEOTIFF_SETTING=not_found,-L$with_geotiff/lib) + + if test $GEOTIFF_SETTING = "external" ; then + LIBS="-L$with_geotiff/lib -lgeotiff $LIBS" +@@ -2875,6 +2864,10 @@ if test x"$with_hdf4" = x"no" ; then + + echo "hdf4 support disabled." + ++elif test x"$with_hdf4" = x"yes" ; then ++ PKG_CHECK_MODULES([HDF4], [hdf], [HAVE_HDF4=yes], [AC_MSG_ERROR([hdf4 not found...])]) ++ PKG_CHECK_MODULES([HDF4], [hdf >= 4.2.5], [HDF4_HAS_MAXOPENFILES=yes], [HDF4_HAS_MAXOPENFILES=no]) ++ HDF4_INCLUDE="$HDF4_CFLAGS" + else + + if test x"$with_hdf4" = x"yes" -o x"$with_hdf4" = x"" ; then +@@ -3005,7 +2998,6 @@ elif test "$with_hdf5" = "yes" -o "$with_hdf5" = "" ; then + # Test that the package found is for the right architecture + saved_LIBS="$LIBS" + LIBS="$HDF5_LIBS" +- AC_CHECK_LIB(hdf5,H5Fopen, [HAVE_HDF5=yes], [HAVE_HDF5=no]) + LIBS="$saved_LIBS" + + if test "$HAVE_HDF5" = "yes"; then +@@ -3074,21 +3066,21 @@ KEA_CONFIG=no + + AC_ARG_WITH(kea,[ --with-kea[=ARG] Include kealib (ARG=path to kea-config) [[default=yes]]],,) + ++AC_MSG_CHECKING([for kea]) + if test "$with_kea" = "yes" -o "x$with_kea" = "x" ; then +- AC_PATH_PROG(KEA_CONFIG, kea-config, no) ++ HAVE_KEA=yes ++ AC_MSG_RESULT([yes]) + else +- KEA_CONFIG=$with_kea ++ HAVE_KEA=no ++ AC_MSG_RESULT([no]) + fi + +-AC_MSG_CHECKING([for kea]) + + if test "$KEA_CONFIG" = "no" ; then + +- HAVE_KEA=no + KEA_LIB= + KEA_INC= + +- AC_MSG_RESULT([no]) + + else + if test -d $KEA_CONFIG ; then +@@ -3940,18 +3932,15 @@ MYSQL_CONFIG=no + AC_ARG_WITH(mysql,[ --with-mysql[=ARG] Include MySQL (ARG=path to mysql_config) [[default=no]]],,) + + if test "$with_mysql" = "yes" ; then +- AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no) ++ HAVE_MYSQL=yes + else +- if test "x$with_mysql" != "x" ; then +- MYSQL_CONFIG=$with_mysql +- fi ++ HAVE_MYSQL=no + fi + + AC_MSG_CHECKING([for MySQL]) + + if test "$MYSQL_CONFIG" = "no" ; then + +- HAVE_MYSQL=no + MYSQL_LIB= + MYSQL_INC= + +@@ -4045,8 +4034,11 @@ dnl Check for Expat configuration. + dnl --------------------------------------------------------------------------- + + dnl Expat 1.95.0 released in 2000-09-28 +-EXPAT_REQ_VERSION="1.95.0" +-AX_LIB_EXPAT($EXPAT_REQ_VERSION) ++# AX_LIB_EXPAT is too fragile, it doesn't properly handle debug expat on Windows ++HAVE_EXPAT=no ++AC_ARG_WITH([expat], AS_HELP_STRING([--with-expat[=ARG]], [use Expat library (ARG=yes or no)]),,) ++if test x"$with_expat" = x"yes" ; then ++PKG_CHECK_MODULES([EXPAT], [expat >= 1.95.0], [HAVE_EXPAT=yes], [AC_MSG_ERROR([expat not found...])]) + + if test "$HAVE_EXPAT" = "yes"; then + LIBS="$EXPAT_LDFLAGS $LIBS" +@@ -4059,6 +4051,7 @@ m4_foreach_w([frmt],EXPAT_DRIVERS,[ + fi + ]) + ++fi + fi + + AC_SUBST([HAVE_EXPAT], $HAVE_EXPAT) +@@ -4305,7 +4298,6 @@ if test "x$with_xml2" = "xyes" -o "x$with_xml2" = "x" ; then + if test "${HAVE_LIBXML2}" = "yes"; then + SAVED_LIBS="${LIBS}" + LIBS="${LIBXML2_LIBS}" +- AC_CHECK_LIB(xml2,xmlParseDoc,HAVE_LIBXML2=yes,HAVE_LIBXML2=no) + LIBS="${SAVED_LIBS}" + fi + +@@ -4550,13 +4542,18 @@ dnl --------------------------------------------------------------------------- + dnl Check if geos library is available. + dnl --------------------------------------------------------------------------- + +-GEOS_INIT(3.1.0) ++AC_ARG_WITH(geos, AS_HELP_STRING([--with-geos[=ARG]], [Include GEOS support (ARG=yes or no)]),,) ++HAVE_GEOS=no ++if test x"$with_geos" = x"no" ; then ++ AC_MSG_RESULT([GEOS support disabled]) ++else ++ PKG_CHECK_MODULES([GEOS], [geos >= 3.1.0], [HAVE_GEOS=yes], [AC_MSG_ERROR([geos not found...])]) + if test "${HAVE_GEOS}" = "yes" ; then + AC_MSG_NOTICE([Using C API from GEOS $GEOS_VERSION]) +- STRIP_SYSTEM_LIBRARY_PATHS("${GEOS_LIBS}") +- GEOS_LIBS="$STRIPPED_LIBRARY_NAME" + LIBS="${GEOS_LIBS} ${LIBS}" + fi ++fi ++AC_SUBST(HAVE_GEOS, $HAVE_GEOS) + + dnl --------------------------------------------------------------------------- + dnl Check if SFCGAL library is available. +@@ -4588,20 +4585,18 @@ elif test "$with_qhull" = "yes" -o "$with_qhull" = "" ; then + # qhull/qhull.h + AC_CHECK_HEADERS([qhull/libqhull.h]) + if test "$ac_cv_header_qhull_libqhull_h" = "yes"; then +- AC_CHECK_LIB(qhull,qh_new_qhull,QHULL_SETTING=yes,QHULL_SETTING=no,) ++ QHULL_SETTING=yes + if test "$QHULL_SETTING" = "yes"; then + QHULL_SETTING=external + QHULL_INCLUDE_SUBDIR_IS_LIBQHULL=0 +- LIBS="-lqhull $LIBS" + fi + fi + AC_CHECK_HEADERS([libqhull/libqhull.h]) + if test "$ac_cv_header_libqhull_libqhull_h" = "yes"; then +- AC_CHECK_LIB(qhull,qh_new_qhull,QHULL_SETTING=yes,QHULL_SETTING=no,) ++ QHULL_SETTING=yes + if test "$QHULL_SETTING" = "yes"; then + QHULL_SETTING=external + QHULL_INCLUDE_SUBDIR_IS_LIBQHULL=1 +- LIBS="-lqhull $LIBS" + fi + fi + +@@ -4688,7 +4683,9 @@ AC_MSG_CHECKING([for FreeXL support]) + HAVE_FREEXL=no + FREEXL_INCLUDE= + +-if test "$with_freexl" = "" -o "$with_freexl" = "yes" ; then ++if test "$with_freexl" = "yes"; then ++ PKG_CHECK_MODULES([FREEXL], [freexl >= 1.0.0], [HAVE_FREEXL=yes], [AC_MSG_ERROR([freexl not found...])]) ++elif test "$with_freexl" = ""; then + AC_CHECK_HEADERS(freexl.h) + AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl",FREEXL_LIBS=missing) + +@@ -4794,8 +4791,7 @@ if test "$with_libjson_c" = "external" -o "$with_libjson_c" = "" -o "$with_libjs + elif test "$with_libjson_c" = "internal" ; then + LIBJSONC_SETTING=internal + elif test "$with_libjson_c" != "no"; then +- LIBS="-L$with_libjson_c/lib $LIBS" +- AC_CHECK_LIB(json-c,json_object_set_serializer,LIBJSONC_SETTING=external,LIBJSONC_SETTING=internal,-L$with_libjson_c/lib) ++ LIBJSONC_SETTING=external + else + AC_MSG_ERROR([libjson-c (internal or external) is required]) + fi +@@ -5953,7 +5949,6 @@ else + # Test that the package found is for the right architecture + saved_LIBS="$LIBS" + LIBS="$EXR_LIBS" +- AC_CHECK_LIB(IlmImf,ImfTiledInputReadTile, [HAVE_EXR=yes], [HAVE_EXR=no]) + LIBS="$saved_LIBS" + + if test "$HAVE_EXR" = "yes"; then diff --git a/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-include-jsonc.patch b/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-include-jsonc.patch new file mode 100644 index 0000000000000..e88043df4189f --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-include-jsonc.patch @@ -0,0 +1,104 @@ +--- a/gcore/gdal_rat.cpp ++++ b/gcore/gdal_rat.cpp +@@ -50,7 +50,7 @@ + #pragma clang diagnostic ignored "-Wunknown-pragmas" + #pragma clang diagnostic ignored "-Wdocumentation" + #endif +-#include "json.h" ++#include + #ifdef __clang__ + #pragma clang diagnostic pop + #endif +--- a/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp +@@ -37,7 +37,7 @@ + + #include "cpl_conv.h" + #include "cpl_error.h" +-#include "json.h" ++#include + // #include "json_object.h" + // #include "json_tokener.h" + #include "ogr_api.h" +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsondatasource.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsondatasource.cpp +@@ -41,7 +41,7 @@ + #include "cpl_string.h" + #include "cpl_vsi.h" + #include "cpl_vsi_error.h" +-#include "json.h" ++#include + // #include "json_object.h" + #include "gdal_utils.h" + #include "gdal.h" +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonlayer.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonlayer.cpp +@@ -37,7 +37,7 @@ + # endif + #endif // !DEBUG_VERBOSE + +-#include ++#include + + #if !DEBUG_JSON + # ifdef __clang +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp +@@ -32,7 +32,7 @@ + #include "ogrgeojsonreader.h" + #include "ogrgeojsonutils.h" + #include "ogr_geojson.h" +-#include // JSON-C ++#include + + #if (!defined(JSON_C_VERSION_NUM)) || (JSON_C_VERSION_NUM < JSON_C_VER_013) + #include // just for sizeof(struct json_object) +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonutils.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonutils.cpp +@@ -32,7 +32,7 @@ + #include + #include + #include +-#include // JSON-C ++#include + + #include + #include +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp +@@ -33,13 +33,13 @@ + #include "ogrgeojsonutils.h" + #include "ogr_geojson.h" + #include "ogrgeojsonreader.h" +-#include // JSON-C ++#include + + #if (!defined(JSON_C_VERSION_NUM)) || (JSON_C_VERSION_NUM < JSON_C_VER_013) + #include + #endif + +-#include ++#include + #include + #include + +--- a/ogr/ogrsf_frmts/geojson/ogrtopojsonreader.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrtopojsonreader.cpp +@@ -30,5 +30,5 @@ + #include "ogrgeojsonutils.h" + #include "ogr_geojson.h" +-#include // JSON-C ++#include + #include + +--- a/port/cpl_json_header.h ++++ b/port/cpl_json_header.h +@@ -33,7 +33,7 @@ + #pragma GCC system_header + #endif + +-#include ++#include + + #undef json_object_object_foreachC + #define json_object_object_foreachC(obj,iter) \ diff --git a/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-include-podofo.patch b/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-include-podofo.patch new file mode 100644 index 0000000000000..aa86489f0296b --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-include-podofo.patch @@ -0,0 +1,11 @@ +--- a/frmts/pdf/pdfsdk_headers.h ++++ b/frmts/pdf/pdfsdk_headers.h +@@ -103,7 +103,7 @@ typedef unsigned char Guchar; + #undef GetObject + #endif + +-#include "podofo.h" ++#include + #endif // HAVE_PODOFO + + #ifdef HAVE_PDFIUM diff --git a/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-include-xerces.patch b/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-include-xerces.patch new file mode 100644 index 0000000000000..8b08760381794 --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-include-xerces.patch @@ -0,0 +1,63 @@ +--- a/ogr/ogr_xerces_headers.h ++++ b/ogr/ogr_xerces_headers.h +@@ -33,9 +33,9 @@ + #pragma GCC system_header + #endif + +-#include +-#include +-#include ++#include ++#include ++#include + + #ifdef XERCES_CPP_NAMESPACE_USE + XERCES_CPP_NAMESPACE_USE +--- a/ogr/ogrsf_frmts/gml/xercesc_headers.h ++++ b/ogr/ogrsf_frmts/gml/xercesc_headers.h +@@ -33,13 +33,13 @@ + #pragma GCC system_header + #endif + +-#include +-#include +-#include +-#include +-#include +-#include +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + + #ifdef XERCES_CPP_NAMESPACE_USE + XERCES_CPP_NAMESPACE_USE +--- a/ogr/ogrsf_frmts/ili/xercesc_headers.h ++++ b/ogr/ogrsf_frmts/ili/xercesc_headers.h +@@ -33,14 +33,14 @@ + #pragma GCC system_header + #endif + +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + + #ifdef XERCES_CPP_NAMESPACE_USE + XERCES_CPP_NAMESPACE_USE diff --git a/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-nmake.patch b/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-nmake.patch new file mode 100644 index 0000000000000..4c0ef454c2aac --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.3.x/fix-nmake.patch @@ -0,0 +1,179 @@ +--- a/alg/makefile.vc ++++ b/alg/makefile.vc +@@ -14,7 +14,7 @@ EXTRAFLAGS = -I../frmts/vrt -I../ogr/ogrsf_frmts $(GEOS_CFLAGS) $(PROJ_FLAGS) $( + EXTRAFLAGS = $(EXTRAFLAGS) -DINTERNAL_QHULL + !ELSE + !IF "$(QHULL_SETTING)" == "EXTERNAL" +-EXTRAFLAGS = $(EXTRAFLAGS) -DEXTERNAL_QHULL $(QHULL_INC) ++EXTRAFLAGS = $(EXTRAFLAGS) -DEXTERNAL_QHULL -DQHULL_INCLUDE_SUBDIR_IS_LIBQHULL=1 $(QHULL_INC) + !ENDIF + !ENDIF + !ENDIF +--- a/apps/makefile.vc ++++ b/apps/makefile.vc +@@ -8,6 +8,9 @@ EXTRAFLAGS = -I..\frmts\vrt -I..\ogr\ogrsf_frmts\geojson\libjson -I..\ogr\ogrsf_ + !INCLUDE ..\nmake.opt + + LIBS = $(GDALLIB) ++!IF "$(DLLBUILD)" != "1" ++LIBS = $(LIBS) $(EXTERNAL_LIBS) ++!ENDIF + + !IFDEF INCLUDE_OGR_FRMTS + OGR_PROGRAMS = gdal_contour.exe gdaltindex.exe gdal_rasterize.exe \ +--- a/frmts/gif/makefile.vc ++++ b/frmts/gif/makefile.vc +@@ -10,14 +10,8 @@ EXTRAFLAGS = -Igiflib + + default: $(OBJ) + xcopy /D /Y *.obj ..\o +- cd giflib +- $(MAKE) /f makefile.vc +- cd .. + + clean: + -del *.obj +- cd giflib +- $(MAKE) /f makefile.vc clean +- cd .. + + +--- a/frmts/jpeg/makefile.vc ++++ b/frmts/jpeg/makefile.vc +@@ -29,12 +29,16 @@ default: $(EXTRA_DEP) $(OBJ) + + clean: + -del *.obj ++!IFNDEF JPEG_EXTERNAL_LIB + cd libjpeg + $(MAKE) /f makefile.vc clean + cd .. ++!ENDIF ++!IFDEF JPEG12_SUPPORTED + cd libjpeg12 + $(MAKE) /f makefile.vc clean + cd .. ++!ENDIF + + libjpeg12src: + cd libjpeg12 +--- a/frmts/kea/makefile.vc ++++ b/frmts/kea/makefile.vc +@@ -1,7 +1,7 @@ + + OBJ = keaband.obj keacopy.obj keadataset.obj keadriver.obj keamaskband.obj keaoverview.obj kearat.obj + +-EXTRAFLAGS = $(KEA_CFLAGS) -DH5_BUILT_AS_DYNAMIC_LIB ++EXTRAFLAGS = $(KEA_CFLAGS) + + GDAL_ROOT = ..\.. + +--- a/frmts/makefile.vc ++++ b/frmts/makefile.vc +@@ -3,11 +3,11 @@ GDAL_ROOT = .. + + EXTRAFLAGS = -DFRMT_ceos -DFRMT_aigrid -DFRMT_elas -DFRMT_hfa -DFRMT_gtiff\ + -DFRMT_sdts -DFRMT_raw -DFRMT_gxf -DFRMT_ceos2 -DFRMT_png \ +- -DFRMT_dted -DFRMT_mem -DFRMT_jdem -DFRMT_gif -DFRMT_esric \ ++ -DFRMT_dted -DFRMT_mem -DFRMT_jdem -DFRMT_esric \ + -DFRMT_envisat -DFRMT_aaigrid -DFRMT_usgsdem -DFRMT_l1b \ + -DFRMT_fit -DFRMT_vrt -DFRMT_xpm -DFRMT_bmp -DFRMT_rmf \ +- -DFRMT_nitf -DFRMT_pcidsk -DFRMT_airsar -DFRMT_rs2 \ +- -DFRMT_ilwis -DFRMT_msgn -DFRMT_rik -DFRMT_pcraster \ ++ -DFRMT_nitf -DFRMT_airsar -DFRMT_rs2 \ ++ -DFRMT_ilwis -DFRMT_msgn -DFRMT_rik \ + -DFRMT_leveller -DFRMT_sgi -DFRMT_srtmhgt -DFRMT_idrisi \ + -DFRMT_jaxapalsar -DFRMT_ers -DFRMT_ingr -DFRMT_dimap \ + -DFRMT_gff -DFRMT_terragen -DFRMT_gsg -DFRMT_cosar -DFRMT_pds \ +@@ -32,6 +32,22 @@ PLUGINDIRLIST = $(PLUGINFLAGS:-DFRMT_=) + EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_postgisraster + !ENDIF + ++!IFDEF GIF_SETTING ++EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_gif ++!ENDIF ++ ++!IFDEF PCIDSK_SETTING ++EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_pcidsk ++!ENDIF ++ ++!IFDEF PCRASTER_SETTING ++EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_pcraster ++!ENDIF ++ ++!IFDEF EXR_INC ++EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_exr ++!ENDIF ++ + !IFDEF JPEG_SUPPORTED + EXTRAFLAGS = -DFRMT_jpeg $(EXTRAFLAGS) + !ENDIF +--- a/frmts/pcidsk/makefile.vc ++++ b/frmts/pcidsk/makefile.vc +@@ -14,7 +14,11 @@ OBJ = pcidskdataset2.obj ogrpcidsklayer.obj vsi_pcidsk_io.obj gdal_edb.obj + !ENDIF + + !IF "$(PCIDSK_SETTING)" == "INTERNAL" ++!IFDEF JPEG_SUPPORTED + PCIDSKFLAGS = -Isdk -DPCIDSK_INTERNAL -DHAVE_LIBJPEG ++!ELSE ++PCIDSKFLAGS = -Isdk -DPCIDSK_INTERNAL ++!ENDIF + + OBJ = pcidskdataset2.obj ogrpcidsklayer.obj vsi_pcidsk_io.obj gdal_edb.obj \ + sdk\blockdir\asciitiledir.obj \ +@@ -70,11 +74,13 @@ OBJ = pcidskdataset2.obj ogrpcidsklayer.obj vsi_pcidsk_io.obj gdal_edb.obj \ + + !ENDIF + ++!IFDEF JPEG_SUPPORTED + !IFDEF JPEG_EXTERNAL_LIB + JPEGFLAGS = -I$(JPEGDIR) + !ELSE + JPEGFLAGS = -I..\jpeg\libjpeg + !ENDIF ++!ENDIF + + .cpp.obj: + $(CC) $(CFLAGS) $(PCIDSKFLAGS) $(JPEGFLAGS) /c $*.cpp /Fo$*.obj +--- a/makefile.vc ++++ b/makefile.vc +@@ -84,7 +84,7 @@ staticlib: $(LIB_DEPENDS) + call <= 4.0) +- AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,) ++ AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,$LIBS) + + fi + +@@ -1395,23 +1399,11 @@ AC_ARG_WITH(curl, + dnl Clear some cache variables + unset ac_cv_path_LIBCURL + +-if test "`basename xx/$with_curl`" = "curl-config" ; then +- LIBCURL_CONFIG="$with_curl" +-elif test "$with_curl" = "no" ; then +- LIBCURL_CONFIG=no ++PKG_PROG_PKG_CONFIG([0.21]) ++if test "$with_curl" = "yes" ; then ++ PKG_CHECK_MODULES([CURL], [libcurl], [CURL_SETTING=yes], [AC_MSG_ERROR([libcurl not found...])]) + else +- AC_PATH_PROG(LIBCURL_CONFIG, curl-config, no) +-fi +- +-if test "$LIBCURL_CONFIG" != "no" ; then +- +- CURL_VERNUM=`$LIBCURL_CONFIG --vernum` +- CURL_VER=`$LIBCURL_CONFIG --version | awk '{print $2}'` +- +- AC_MSG_RESULT([ found libcurl version $CURL_VER]) +- +- AC_CHECK_LIB(curl,curl_global_init,CURL_SETTING=yes,CURL_SETTING=no,`$LIBCURL_CONFIG --libs`) +- ++ CURL_SETTING=no + fi + + AC_SUBST(CURL_SETTING,$CURL_SETTING) +@@ -1423,8 +1415,11 @@ dnl Check for SQLite + dnl Proj depends on it so it must appear before. + dnl --------------------------------------------------------------------------- + +-SQLITE3_REQ_VERSION="3.0.0" +-AX_LIB_SQLITE3($SQLITE3_REQ_VERSION) ++HAVE_SQLITE3=no ++AC_ARG_WITH(sqlite3, AS_HELP_STRING([--with-sqlite3[=ARG]], [use SQLite 3 library (ARG=yes or no)]),,) ++if test x"$with_sqlite3" = x"yes" ; then ++ PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.0.0], [HAVE_SQLITE3=yes], [AC_MSG_ERROR([sqlite3 not found...])]) ++fi + + if test "$HAVE_SQLITE3" = "yes"; then + LIBS="$SQLITE3_LDFLAGS $LIBS" +@@ -1455,11 +1450,7 @@ if test "x$with_proj" = "xno" ; then + else + + if test "x$with_proj" = "xyes" -o "x$with_proj" = "x"; then +- ORIG_LIBS="$LIBS" +- LIBS="-lproj $with_proj_extra_lib_for_test $ORIG_LIBS" +- AC_LANG_PUSH([C++]) +- AC_CHECK_LIB(proj,proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,) +- AC_LANG_POP([C++]) ++ PROJ_FOUND=yes + if test "$PROJ_FOUND" = "no"; then + AC_LANG_PUSH([C++]) + AC_CHECK_LIB(proj,internal_proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,) +@@ -1690,6 +1681,8 @@ dnl --------------------------------------------------------------------------- + AC_ARG_WITH(blosc,[ --with-blosc[=ARG] Include blosc support (ARG=yes/no/installation_prefix)],,) + + if test "$with_blosc" = "" -o "$with_blosc" = "yes" ; then ++ HAVE_BLOSC=yes ++ if false; then + AC_CHECK_LIB(blosc,blosc_cbuffer_validate,HAVE_BLOSC=yes,HAVE_BLOSC=no,) + + if test "$HAVE_BLOSC" = "yes" ; then +@@ -1701,6 +1694,7 @@ if test "$with_blosc" = "" -o "$with_blosc" = "yes" ; then + echo "libblosc not found - BLOSC support disabled" + fi + fi ++ fi + elif test "$with_blosc" != "" -a "$with_blosc" != "no"; then + + AC_CHECK_LIB(blosc,blosc_cbuffer_validate,HAVE_BLOSC=yes,HAVE_BLOSC=no,-L$with_blosc/lib) +@@ -1953,8 +1947,8 @@ fi + + if test "$CURL_SETTING" = "yes" ; then + +- CURL_INC=`$LIBCURL_CONFIG --cflags` +- CURL_LIB=`$LIBCURL_CONFIG --libs` ++ CURL_INC="$CURL_CFLAGS" ++ CURL_LIB="$CURL_LIBS" + m4_foreach_w([frmt],CURL_FORMATS,[ + driver_enabled=m4_join([_],[$INTERNAL_FORMAT],frmt,[ENABLED]) + if test "x$driver_enabled" = "xyes"; then +@@ -2286,7 +2280,6 @@ else + + DDS_SETTING=yes + CRUNCHDIR="$with_dds" +- LIBS="-L$with_dds/lib/ -lcrunch $LIBS" + echo "using libcrunch from $with_dds." + + fi +@@ -2437,7 +2430,6 @@ else + + dnl We now require libgeotiff 1.5.0 + dnl first check if $with_geotiff/lib has the library: +- AC_CHECK_LIB(geotiff,GTIFAttachPROJContext,GEOTIFF_SETTING=external,GEOTIFF_SETTING=not_found,-L$with_geotiff/lib) + + if test $GEOTIFF_SETTING = "external" ; then + LIBS="-L$with_geotiff/lib -lgeotiff $LIBS" +@@ -2924,6 +2916,10 @@ if test x"$with_hdf4" = x"no" ; then + + echo "hdf4 support disabled." + ++elif test x"$with_hdf4" = x"yes" ; then ++ PKG_CHECK_MODULES([HDF4], [hdf], [HAVE_HDF4=yes], [AC_MSG_ERROR([hdf4 not found...])]) ++ PKG_CHECK_MODULES([HDF4], [hdf >= 4.2.5], [HDF4_HAS_MAXOPENFILES=yes], [HDF4_HAS_MAXOPENFILES=no]) ++ HDF4_INCLUDE="$HDF4_CFLAGS" + else + + if test x"$with_hdf4" = x"yes" -o x"$with_hdf4" = x"" ; then +@@ -3054,7 +3050,6 @@ elif test "$with_hdf5" = "yes" -o "$with_hdf5" = "" ; then + # Test that the package found is for the right architecture + saved_LIBS="$LIBS" + LIBS="$HDF5_LIBS" +- AC_CHECK_LIB(hdf5,H5Fopen, [HAVE_HDF5=yes], [HAVE_HDF5=no]) + LIBS="$saved_LIBS" + + if test "$HAVE_HDF5" = "yes"; then +@@ -3123,21 +3118,21 @@ KEA_CONFIG=no + + AC_ARG_WITH(kea,[ --with-kea[=ARG] Include kealib (ARG=path to kea-config) [[default=yes]]],,) + ++AC_MSG_CHECKING([for kea]) + if test "$with_kea" = "yes" -o "x$with_kea" = "x" ; then +- AC_PATH_PROG(KEA_CONFIG, kea-config, no) ++ HAVE_KEA=yes ++ AC_MSG_RESULT([yes]) + else +- KEA_CONFIG=$with_kea ++ HAVE_KEA=no ++ AC_MSG_RESULT([no]) + fi + +-AC_MSG_CHECKING([for kea]) + + if test "$KEA_CONFIG" = "no" ; then + +- HAVE_KEA=no + KEA_LIB= + KEA_INC= + +- AC_MSG_RESULT([no]) + + else + if test -d $KEA_CONFIG ; then +@@ -4001,18 +3996,15 @@ MYSQL_CONFIG=no + AC_ARG_WITH(mysql,[ --with-mysql[=ARG] Include MySQL (ARG=path to mysql_config) [[default=no]]],,) + + if test "$with_mysql" = "yes" ; then +- AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no) ++ HAVE_MYSQL=yes + else +- if test "x$with_mysql" != "x" ; then +- MYSQL_CONFIG=$with_mysql +- fi ++ HAVE_MYSQL=no + fi + + AC_MSG_CHECKING([for MySQL]) + + if test "$MYSQL_CONFIG" = "no" ; then + +- HAVE_MYSQL=no + MYSQL_LIB= + MYSQL_INC= + +@@ -4106,8 +4098,11 @@ dnl Check for Expat configuration. + dnl --------------------------------------------------------------------------- + + dnl Expat 1.95.0 released in 2000-09-28 +-EXPAT_REQ_VERSION="1.95.0" +-AX_LIB_EXPAT($EXPAT_REQ_VERSION) ++# AX_LIB_EXPAT is too fragile, it doesn't properly handle debug expat on Windows ++HAVE_EXPAT=no ++AC_ARG_WITH([expat], AS_HELP_STRING([--with-expat[=ARG]], [use Expat library (ARG=yes or no)]),,) ++if test x"$with_expat" = x"yes" ; then ++PKG_CHECK_MODULES([EXPAT], [expat >= 1.95.0], [HAVE_EXPAT=yes], [AC_MSG_ERROR([expat not found...])]) + + if test "$HAVE_EXPAT" = "yes"; then + LIBS="$EXPAT_LDFLAGS $LIBS" +@@ -4120,6 +4115,7 @@ m4_foreach_w([frmt],EXPAT_DRIVERS,[ + fi + ]) + ++fi + fi + + AC_SUBST([HAVE_EXPAT], $HAVE_EXPAT) +@@ -4366,7 +4362,6 @@ if test "x$with_xml2" = "xyes" -o "x$with_xml2" = "x" ; then + if test "${HAVE_LIBXML2}" = "yes"; then + SAVED_LIBS="${LIBS}" + LIBS="${LIBXML2_LIBS}" +- AC_CHECK_LIB(xml2,xmlParseDoc,HAVE_LIBXML2=yes,HAVE_LIBXML2=no) + LIBS="${SAVED_LIBS}" + fi + +@@ -4453,10 +4448,9 @@ else + AC_MSG_ERROR([cannot find pcre2.h]) + fi + else +- AC_CHECK_LIB(pcre2-8,pcre2_compile_8,HAVE_PCRE2=yes,HAVE_PCRE2=no,) ++ HAVE_PCRE2=yes + if test "$HAVE_PCRE2" = "yes" ; then + HAVE_PCRE2=yes +- LIBS="$LIBS -lpcre2-8" + else + if test "$with_pcre2" = "yes"; then + AC_MSG_ERROR([cannot find libpcre2]) +@@ -4487,10 +4481,9 @@ elif test "$HAVE_PCRE2" = "no"; then + AC_MSG_ERROR([cannot find pcre.h]) + fi + else +- AC_CHECK_LIB(pcre,pcre_compile,HAVE_PCRE=yes,HAVE_PCRE=no,) ++ HAVE_PCRE=yes + if test "$HAVE_PCRE" = "yes" ; then + HAVE_PCRE=yes +- LIBS="$LIBS -lpcre" + else + if test "$with_pcre" = "yes"; then + AC_MSG_ERROR([cannot find libpcre]) +@@ -4648,13 +4641,18 @@ dnl --------------------------------------------------------------------------- + dnl Check if geos library is available. + dnl --------------------------------------------------------------------------- + +-GEOS_INIT(3.1.0) ++AC_ARG_WITH(geos, AS_HELP_STRING([--with-geos[=ARG]], [Include GEOS support (ARG=yes or no)]),,) ++HAVE_GEOS=no ++if test x"$with_geos" = x"no" ; then ++ AC_MSG_RESULT([GEOS support disabled]) ++else ++ PKG_CHECK_MODULES([GEOS], [geos >= 3.1.0], [HAVE_GEOS=yes], [AC_MSG_ERROR([geos not found...])]) + if test "${HAVE_GEOS}" = "yes" ; then + AC_MSG_NOTICE([Using C API from GEOS $GEOS_VERSION]) +- STRIP_SYSTEM_LIBRARY_PATHS("${GEOS_LIBS}") +- GEOS_LIBS="$STRIPPED_LIBRARY_NAME" + LIBS="${GEOS_LIBS} ${LIBS}" + fi ++fi ++AC_SUBST(HAVE_GEOS, $HAVE_GEOS) + + dnl --------------------------------------------------------------------------- + dnl Check if SFCGAL library is available. +@@ -4684,11 +4682,10 @@ elif test "$with_qhull" = "yes" -o "$with_qhull" = "" ; then + + AC_CHECK_HEADERS([libqhull_r/libqhull_r.h]) + if test "$ac_cv_header_libqhull_r_libqhull_r_h" = "yes"; then +- AC_CHECK_LIB(qhull_r,qh_new_qhull,QHULL_SETTING=yes,QHULL_SETTING=no,) ++ QHULL_SETTING=yes + if test "$QHULL_SETTING" = "yes"; then + QHULL_SETTING=external + QHULL_IS_LIBQHULL_R=1 +- LIBS="-lqhull_r $LIBS" + fi + else + # Only qhull 2012 is reliable on certain datasets. Older Ubuntu have +@@ -4798,7 +4795,9 @@ AC_MSG_CHECKING([for FreeXL support]) + HAVE_FREEXL=no + FREEXL_INCLUDE= + +-if test "$with_freexl" = "" -o "$with_freexl" = "yes" ; then ++if test "$with_freexl" = "yes"; then ++ PKG_CHECK_MODULES([FREEXL], [freexl >= 1.0.0], [HAVE_FREEXL=yes], [AC_MSG_ERROR([freexl not found...])]) ++elif test "$with_freexl" = ""; then + AC_CHECK_HEADERS(freexl.h) + AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl",FREEXL_LIBS=missing) + +@@ -4904,8 +4903,7 @@ if test "$with_libjson_c" = "external" -o "$with_libjson_c" = "" -o "$with_libjs + elif test "$with_libjson_c" = "internal" ; then + LIBJSONC_SETTING=internal + elif test "$with_libjson_c" != "no"; then +- LIBS="-L$with_libjson_c/lib $LIBS" +- AC_CHECK_LIB(json-c,json_object_set_serializer,LIBJSONC_SETTING=external,LIBJSONC_SETTING=internal,-L$with_libjson_c/lib) ++ LIBJSONC_SETTING=external + else + AC_MSG_ERROR([libjson-c (internal or external) is required]) + fi +@@ -6079,7 +6077,6 @@ else + # Test that the package found is for the right architecture + saved_LIBS="$LIBS" + LIBS="$EXR_LIBS" +- AC_CHECK_LIB(IlmImf,ImfTiledInputReadTile, [HAVE_EXR=yes], [HAVE_EXR=no]) + if test "$HAVE_EXR" = "no"; then + dnl Try with OpenEXR >= 3 name + AC_CHECK_LIB(OpenEXR,ImfTiledInputReadTile, [HAVE_EXR=yes], [HAVE_EXR=no]) diff --git a/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-autotools-3.4.3.patch b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-autotools-3.4.3.patch new file mode 100644 index 0000000000000..4aac2e1660963 --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-autotools-3.4.3.patch @@ -0,0 +1,333 @@ +--- a/GDALmake.opt.in ++++ b/GDALmake.opt.in +@@ -620,7 +620,7 @@ endif + + ifeq ($(HAVE_LIBTOOL), yes) + +-CONFIG_LIBS = $(GDAL_ROOT)/$(LIBGDAL) ++CONFIG_LIBS = $(GDAL_ROOT)/$(LIBGDAL) $(LIBS) + ifeq ($(MACOSX_FRAMEWORK),yes) + CONFIG_LIBS_INS = -L$(INST_LIB)/unix/lib -lgdal + else +--- a/configure.ac ++++ b/configure.ac +@@ -1168,6 +1168,10 @@ AC_ARG_WITH(libdeflate, + [enable libdeflate usage (optional for faster Deflate support (still requires zlib) (ARG=yes/no/prefix), enabled by default)]),,) + + if test "$with_libdeflate" != "no" ; then ++# AC_CHECK_LIB tests not robust enough (don't handle static libdeflate on windows) ++if test "$with_libdeflate" = "yes" ; then ++ LIBDEFLATE_SETTING=yes ++else + + if test "$with_libdeflate" != "" -a "$with_libdeflate" != "yes"; then + AC_CHECK_LIB(deflate, libdeflate_zlib_decompress, [libdeflate_lib=yes], [libdeflate_lib=no],-L$with_libdeflate/lib) +@@ -1197,13 +1201,13 @@ if test "$with_libdeflate" != "no" ; then + fi + + fi ++fi + + if test "$LIBDEFLATE_SETTING" = "yes" ; then + if test "$with_libdeflate" != "" -a "$with_libdeflate" != "yes"; then + EXTRA_INCLUDES="-I$with_libdeflate/include $EXTRA_INCLUDES" + LIBS="-L$with_libdeflate/lib -ldeflate $LIBS" +- else +- LIBS="-ldeflate $LIBS" ++ # Too fragile: libdeflate static lib name on windows is libdeflatestatic + fi + fi + +@@ -1371,7 +1375,7 @@ else + AC_MSG_RESULT([using libtiff from ${with_libtiff}.]) + + dnl Check for the BigTIFF enabled library (libtiff >= 4.0) +- AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,) ++ AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,$LIBS) + + fi + +@@ -1395,23 +1399,11 @@ AC_ARG_WITH(curl, + dnl Clear some cache variables + unset ac_cv_path_LIBCURL + +-if test "`basename xx/$with_curl`" = "curl-config" ; then +- LIBCURL_CONFIG="$with_curl" +-elif test "$with_curl" = "no" ; then +- LIBCURL_CONFIG=no ++PKG_PROG_PKG_CONFIG([0.21]) ++if test "$with_curl" = "yes" ; then ++ PKG_CHECK_MODULES([CURL], [libcurl], [CURL_SETTING=yes], [AC_MSG_ERROR([libcurl not found...])]) + else +- AC_PATH_PROG(LIBCURL_CONFIG, curl-config, no) +-fi +- +-if test "$LIBCURL_CONFIG" != "no" ; then +- +- CURL_VERNUM=`$LIBCURL_CONFIG --vernum` +- CURL_VER=`$LIBCURL_CONFIG --version | awk '{print $2}'` +- +- AC_MSG_RESULT([ found libcurl version $CURL_VER]) +- +- AC_CHECK_LIB(curl,curl_global_init,CURL_SETTING=yes,CURL_SETTING=no,`$LIBCURL_CONFIG --libs`) +- ++ CURL_SETTING=no + fi + + AC_SUBST(CURL_SETTING,$CURL_SETTING) +@@ -1423,8 +1415,11 @@ dnl Check for SQLite + dnl Proj depends on it so it must appear before. + dnl --------------------------------------------------------------------------- + +-SQLITE3_REQ_VERSION="3.0.0" +-AX_LIB_SQLITE3($SQLITE3_REQ_VERSION) ++HAVE_SQLITE3=no ++AC_ARG_WITH(sqlite3, AS_HELP_STRING([--with-sqlite3[=ARG]], [use SQLite 3 library (ARG=yes or no)]),,) ++if test x"$with_sqlite3" = x"yes" ; then ++ PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.0.0], [HAVE_SQLITE3=yes], [AC_MSG_ERROR([sqlite3 not found...])]) ++fi + + if test "$HAVE_SQLITE3" = "yes"; then + LIBS="$SQLITE3_LDFLAGS $LIBS" +@@ -1455,11 +1450,7 @@ if test "x$with_proj" = "xno" ; then + else + + if test "x$with_proj" = "xyes" -o "x$with_proj" = "x"; then +- ORIG_LIBS="$LIBS" +- LIBS="-lproj $with_proj_extra_lib_for_test $ORIG_LIBS" +- AC_LANG_PUSH([C++]) +- AC_CHECK_LIB(proj,proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,) +- AC_LANG_POP([C++]) ++ PROJ_FOUND=yes + if test "$PROJ_FOUND" = "no"; then + AC_LANG_PUSH([C++]) + AC_CHECK_LIB(proj,internal_proj_create_from_wkt,PROJ_FOUND=yes,PROJ_FOUND=no,) +@@ -1690,6 +1681,8 @@ dnl --------------------------------------------------------------------------- + AC_ARG_WITH(blosc,[ --with-blosc[=ARG] Include blosc support (ARG=yes/no/installation_prefix)],,) + + if test "$with_blosc" = "" -o "$with_blosc" = "yes" ; then ++ HAVE_BLOSC=yes ++ if false; then + AC_CHECK_LIB(blosc,blosc_cbuffer_validate,HAVE_BLOSC=yes,HAVE_BLOSC=no,) + + if test "$HAVE_BLOSC" = "yes" ; then +@@ -1701,6 +1694,7 @@ if test "$with_blosc" = "" -o "$with_blosc" = "yes" ; then + echo "libblosc not found - BLOSC support disabled" + fi + fi ++ fi + elif test "$with_blosc" != "" -a "$with_blosc" != "no"; then + + AC_CHECK_LIB(blosc,blosc_cbuffer_validate,HAVE_BLOSC=yes,HAVE_BLOSC=no,-L$with_blosc/lib) +@@ -1953,8 +1947,8 @@ fi + + if test "$CURL_SETTING" = "yes" ; then + +- CURL_INC=`$LIBCURL_CONFIG --cflags` +- CURL_LIB=`$LIBCURL_CONFIG --libs` ++ CURL_INC="$CURL_CFLAGS" ++ CURL_LIB="$CURL_LIBS" + m4_foreach_w([frmt],CURL_FORMATS,[ + driver_enabled=m4_join([_],[$INTERNAL_FORMAT],frmt,[ENABLED]) + if test "x$driver_enabled" = "xyes"; then +@@ -2286,7 +2280,6 @@ else + + DDS_SETTING=yes + CRUNCHDIR="$with_dds" +- LIBS="-L$with_dds/lib/ -lcrunch $LIBS" + echo "using libcrunch from $with_dds." + + fi +@@ -2437,7 +2430,6 @@ else + + dnl We now require libgeotiff 1.5.0 + dnl first check if $with_geotiff/lib has the library: +- AC_CHECK_LIB(geotiff,GTIFAttachPROJContext,GEOTIFF_SETTING=external,GEOTIFF_SETTING=not_found,-L$with_geotiff/lib) + + if test $GEOTIFF_SETTING = "external" ; then + LIBS="-L$with_geotiff/lib -lgeotiff $LIBS" +@@ -2924,6 +2916,10 @@ if test x"$with_hdf4" = x"no" ; then + + echo "hdf4 support disabled." + ++elif test x"$with_hdf4" = x"yes" ; then ++ PKG_CHECK_MODULES([HDF4], [hdf], [HAVE_HDF4=yes], [AC_MSG_ERROR([hdf4 not found...])]) ++ PKG_CHECK_MODULES([HDF4], [hdf >= 4.2.5], [HDF4_HAS_MAXOPENFILES=yes], [HDF4_HAS_MAXOPENFILES=no]) ++ HDF4_INCLUDE="$HDF4_CFLAGS" + else + + if test x"$with_hdf4" = x"yes" -o x"$with_hdf4" = x"" ; then +@@ -3054,7 +3050,6 @@ elif test "$with_hdf5" = "yes" -o "$with_hdf5" = "" ; then + # Test that the package found is for the right architecture + saved_LIBS="$LIBS" + LIBS="$HDF5_LIBS" +- AC_CHECK_LIB(hdf5,H5Fopen, [HAVE_HDF5=yes], [HAVE_HDF5=no]) + LIBS="$saved_LIBS" + + if test "$HAVE_HDF5" = "yes"; then +@@ -3123,21 +3118,21 @@ KEA_CONFIG=no + + AC_ARG_WITH(kea,[ --with-kea[=ARG] Include kealib (ARG=path to kea-config) [[default=yes]]],,) + ++AC_MSG_CHECKING([for kea]) + if test "$with_kea" = "yes" -o "x$with_kea" = "x" ; then +- AC_PATH_PROG(KEA_CONFIG, kea-config, no) ++ HAVE_KEA=yes ++ AC_MSG_RESULT([yes]) + else +- KEA_CONFIG=$with_kea ++ HAVE_KEA=no ++ AC_MSG_RESULT([no]) + fi + +-AC_MSG_CHECKING([for kea]) + + if test "$KEA_CONFIG" = "no" ; then + +- HAVE_KEA=no + KEA_LIB= + KEA_INC= + +- AC_MSG_RESULT([no]) + + else + if test -d $KEA_CONFIG ; then +@@ -4001,18 +3996,15 @@ MYSQL_CONFIG=no + AC_ARG_WITH(mysql,[ --with-mysql[=ARG] Include MySQL (ARG=path to mysql_config) [[default=no]]],,) + + if test "$with_mysql" = "yes" ; then +- AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no) ++ HAVE_MYSQL=yes + else +- if test "x$with_mysql" != "x" ; then +- MYSQL_CONFIG=$with_mysql +- fi ++ HAVE_MYSQL=no + fi + + AC_MSG_CHECKING([for MySQL]) + + if test "$MYSQL_CONFIG" = "no" ; then + +- HAVE_MYSQL=no + MYSQL_LIB= + MYSQL_INC= + +@@ -4106,8 +4098,11 @@ dnl Check for Expat configuration. + dnl --------------------------------------------------------------------------- + + dnl Expat 1.95.0 released in 2000-09-28 +-EXPAT_REQ_VERSION="1.95.0" +-AX_LIB_EXPAT($EXPAT_REQ_VERSION) ++# AX_LIB_EXPAT is too fragile, it doesn't properly handle debug expat on Windows ++HAVE_EXPAT=no ++AC_ARG_WITH([expat], AS_HELP_STRING([--with-expat[=ARG]], [use Expat library (ARG=yes or no)]),,) ++if test x"$with_expat" = x"yes" ; then ++PKG_CHECK_MODULES([EXPAT], [expat >= 1.95.0], [HAVE_EXPAT=yes], [AC_MSG_ERROR([expat not found...])]) + + if test "$HAVE_EXPAT" = "yes"; then + LIBS="$EXPAT_LDFLAGS $LIBS" +@@ -4120,6 +4115,7 @@ m4_foreach_w([frmt],EXPAT_DRIVERS,[ + fi + ]) + ++fi + fi + + AC_SUBST([HAVE_EXPAT], $HAVE_EXPAT) +@@ -4366,7 +4362,6 @@ if test "x$with_xml2" = "xyes" -o "x$with_xml2" = "x" ; then + if test "${HAVE_LIBXML2}" = "yes"; then + SAVED_LIBS="${LIBS}" + LIBS="${LIBXML2_LIBS}" +- AC_CHECK_LIB(xml2,xmlParseDoc,HAVE_LIBXML2=yes,HAVE_LIBXML2=no) + LIBS="${SAVED_LIBS}" + fi + +@@ -4453,10 +4448,9 @@ else + AC_MSG_ERROR([cannot find pcre2.h]) + fi + else +- AC_CHECK_LIB(pcre2-8,pcre2_compile_8,HAVE_PCRE2=yes,HAVE_PCRE2=no,) ++ HAVE_PCRE2=yes + if test "$HAVE_PCRE2" = "yes" ; then + HAVE_PCRE2=yes +- LIBS="$LIBS -lpcre2-8" + else + if test "$with_pcre2" = "yes"; then + AC_MSG_ERROR([cannot find libpcre2]) +@@ -4487,10 +4481,9 @@ elif test "$HAVE_PCRE2" = "no"; then + AC_MSG_ERROR([cannot find pcre.h]) + fi + else +- AC_CHECK_LIB(pcre,pcre_compile,HAVE_PCRE=yes,HAVE_PCRE=no,) ++ HAVE_PCRE=yes + if test "$HAVE_PCRE" = "yes" ; then + HAVE_PCRE=yes +- LIBS="$LIBS -lpcre" + else + if test "$with_pcre" = "yes"; then + AC_MSG_ERROR([cannot find libpcre]) +@@ -4648,13 +4641,18 @@ dnl --------------------------------------------------------------------------- + dnl Check if geos library is available. + dnl --------------------------------------------------------------------------- + +-GEOS_INIT(3.1.0) ++AC_ARG_WITH(geos, AS_HELP_STRING([--with-geos[=ARG]], [Include GEOS support (ARG=yes or no)]),,) ++HAVE_GEOS=no ++if test x"$with_geos" = x"no" ; then ++ AC_MSG_RESULT([GEOS support disabled]) ++else ++ PKG_CHECK_MODULES([GEOS], [geos >= 3.1.0], [HAVE_GEOS=yes], [AC_MSG_ERROR([geos not found...])]) + if test "${HAVE_GEOS}" = "yes" ; then + AC_MSG_NOTICE([Using C API from GEOS $GEOS_VERSION]) +- STRIP_SYSTEM_LIBRARY_PATHS("${GEOS_LIBS}") +- GEOS_LIBS="$STRIPPED_LIBRARY_NAME" + LIBS="${GEOS_LIBS} ${LIBS}" + fi ++fi ++AC_SUBST(HAVE_GEOS, $HAVE_GEOS) + + dnl --------------------------------------------------------------------------- + dnl Check if SFCGAL library is available. +@@ -4684,11 +4682,10 @@ elif test "$with_qhull" = "yes" -o "$with_qhull" = "" ; then + + AC_CHECK_HEADERS([libqhull_r/libqhull_r.h]) + if test "$ac_cv_header_libqhull_r_libqhull_r_h" = "yes"; then +- AC_CHECK_LIB(qhull_r,qh_new_qhull,QHULL_SETTING=yes,QHULL_SETTING=no,) ++ QHULL_SETTING=yes + if test "$QHULL_SETTING" = "yes"; then + QHULL_SETTING=external + QHULL_IS_LIBQHULL_R=1 +- LIBS="-lqhull_r $LIBS" + fi + else + # Only qhull 2012 is reliable on certain datasets. Older Ubuntu have +@@ -4798,7 +4795,9 @@ AC_MSG_CHECKING([for FreeXL support]) + HAVE_FREEXL=no + FREEXL_INCLUDE= + +-if test "$with_freexl" = "" -o "$with_freexl" = "yes" ; then ++if test "$with_freexl" = "yes"; then ++ PKG_CHECK_MODULES([FREEXL], [freexl >= 1.0.0], [HAVE_FREEXL=yes], [AC_MSG_ERROR([freexl not found...])]) ++elif test "$with_freexl" = ""; then + AC_CHECK_HEADERS(freexl.h) + AC_CHECK_LIB(freexl,freexl_open,FREEXL_LIBS="-lfreexl",FREEXL_LIBS=missing) + +@@ -4904,8 +4903,7 @@ if test "$with_libjson_c" = "external" -o "$with_libjson_c" = "" -o "$with_libjs + elif test "$with_libjson_c" = "internal" ; then + LIBJSONC_SETTING=internal + elif test "$with_libjson_c" != "no"; then +- LIBS="-L$with_libjson_c/lib $LIBS" +- AC_CHECK_LIB(json-c,json_object_set_serializer,LIBJSONC_SETTING=external,LIBJSONC_SETTING=internal,-L$with_libjson_c/lib) ++ LIBJSONC_SETTING=external + else + AC_MSG_ERROR([libjson-c (internal or external) is required]) + fi +@@ -6113,7 +6111,6 @@ else + # Test that the package found is for the right architecture + saved_LIBS="$LIBS" + LIBS="$EXR_LIBS" +- AC_CHECK_LIB(IlmImf,ImfTiledInputReadTile, [HAVE_EXR=yes], [HAVE_EXR=no]) + if test "$HAVE_EXR" = "no"; then + dnl Try with OpenEXR >= 3 name + AC_CHECK_LIB(OpenEXR,ImfTiledInputReadTile, [HAVE_EXR=yes], [HAVE_EXR=no]) diff --git a/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-jsonc-3.4.1.patch b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-jsonc-3.4.1.patch new file mode 100644 index 0000000000000..4760275af3a27 --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-jsonc-3.4.1.patch @@ -0,0 +1,104 @@ +--- a/gcore/gdal_rat.cpp ++++ b/gcore/gdal_rat.cpp +@@ -50,7 +50,7 @@ + #pragma clang diagnostic ignored "-Wunknown-pragmas" + #pragma clang diagnostic ignored "-Wdocumentation" + #endif +-#include "json.h" ++#include + #ifdef __clang__ + #pragma clang diagnostic pop + #endif +--- a/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp +@@ -37,7 +37,7 @@ + + #include "cpl_conv.h" + #include "cpl_error.h" +-#include "json.h" ++#include + // #include "json_object.h" + // #include "json_tokener.h" + #include "ogr_api.h" +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsondatasource.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsondatasource.cpp +@@ -41,7 +41,7 @@ + #include "cpl_string.h" + #include "cpl_vsi.h" + #include "cpl_vsi_error.h" +-#include "json.h" ++#include + // #include "json_object.h" + #include "gdal_utils.h" + #include "gdal.h" +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonlayer.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonlayer.cpp +@@ -37,7 +37,7 @@ + # endif + #endif // !DEBUG_VERBOSE + +-#include ++#include + + #if !DEBUG_JSON + # ifdef __clang +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp +@@ -32,7 +32,7 @@ + #include "ogrgeojsonreader.h" + #include "ogrgeojsonutils.h" + #include "ogr_geojson.h" +-#include // JSON-C ++#include + + #if (!defined(JSON_C_VERSION_NUM)) || (JSON_C_VERSION_NUM < JSON_C_VER_013) + #include // just for sizeof(struct json_object) +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonutils.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonutils.cpp +@@ -32,7 +32,7 @@ + #include "cpl_port.h" + #include "cpl_conv.h" + #include "ogr_geometry.h" +-#include // JSON-C ++#include + + #include + #include +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp +@@ -33,13 +33,13 @@ + #include "ogrgeojsonutils.h" + #include "ogr_geojson.h" + #include "ogrgeojsonreader.h" +-#include // JSON-C ++#include + + #if (!defined(JSON_C_VERSION_NUM)) || (JSON_C_VERSION_NUM < JSON_C_VER_013) + #include + #endif + +-#include ++#include + #include "ogr_api.h" + #include "ogr_p.h" + +--- a/ogr/ogrsf_frmts/geojson/ogrtopojsonreader.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrtopojsonreader.cpp +@@ -30,5 +30,5 @@ + #include "ogrgeojsonutils.h" + #include "ogr_geojson.h" +-#include // JSON-C ++#include + #include "ogr_api.h" + +--- a/port/cpl_json_header.h ++++ b/port/cpl_json_header.h +@@ -33,7 +33,7 @@ + #pragma GCC system_header + #endif + +-#include ++#include + + #undef json_object_object_foreachC + #define json_object_object_foreachC(obj,iter) \ diff --git a/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-jsonc-3.4.3.patch b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-jsonc-3.4.3.patch new file mode 100644 index 0000000000000..a6252aae80718 --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-jsonc-3.4.3.patch @@ -0,0 +1,104 @@ +--- a/gcore/gdal_rat.cpp ++++ b/gcore/gdal_rat.cpp +@@ -51,7 +51,7 @@ + #pragma clang diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic ignored "-Wold-style-cast" + #endif +-#include "json.h" ++#include + #ifdef __clang__ + #pragma clang diagnostic pop + #endif +--- a/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogresrijsonreader.cpp +@@ -37,7 +37,7 @@ + + #include "cpl_conv.h" + #include "cpl_error.h" +-#include "json.h" ++#include + // #include "json_object.h" + // #include "json_tokener.h" + #include "ogr_api.h" +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsondatasource.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsondatasource.cpp +@@ -41,7 +41,7 @@ + #include "cpl_string.h" + #include "cpl_vsi.h" + #include "cpl_vsi_error.h" +-#include "json.h" ++#include + // #include "json_object.h" + #include "gdal_utils.h" + #include "gdal.h" +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonlayer.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonlayer.cpp +@@ -38,7 +38,7 @@ + # endif + #endif // !DEBUG_VERBOSE + +-#include ++#include + + #if !DEBUG_JSON + # ifdef __clang +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp +@@ -32,7 +32,7 @@ + #include "ogrgeojsonreader.h" + #include "ogrgeojsonutils.h" + #include "ogr_geojson.h" +-#include // JSON-C ++#include + + #if (!defined(JSON_C_VERSION_NUM)) || (JSON_C_VERSION_NUM < JSON_C_VER_013) + #include // just for sizeof(struct json_object) +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonutils.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonutils.cpp +@@ -32,7 +32,7 @@ + #include "cpl_port.h" + #include "cpl_conv.h" + #include "ogr_geometry.h" +-#include // JSON-C ++#include + + #include + #include +--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp +@@ -33,13 +33,13 @@ + #include "ogrgeojsonutils.h" + #include "ogr_geojson.h" + #include "ogrgeojsonreader.h" +-#include // JSON-C ++#include + + #if (!defined(JSON_C_VERSION_NUM)) || (JSON_C_VERSION_NUM < JSON_C_VER_013) + #include + #endif + +-#include ++#include + #include "ogr_api.h" + #include "ogr_p.h" + +--- a/ogr/ogrsf_frmts/geojson/ogrtopojsonreader.cpp ++++ b/ogr/ogrsf_frmts/geojson/ogrtopojsonreader.cpp +@@ -30,5 +30,5 @@ + #include "ogrgeojsonutils.h" + #include "ogr_geojson.h" +-#include // JSON-C ++#include + #include "ogr_api.h" + +--- a/port/cpl_json_header.h ++++ b/port/cpl_json_header.h +@@ -33,7 +33,7 @@ + #pragma GCC system_header + #endif + +-#include ++#include + + #undef json_object_object_foreachC + #define json_object_object_foreachC(obj,iter) \ diff --git a/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-podofo.patch b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-podofo.patch new file mode 100644 index 0000000000000..aa86489f0296b --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-podofo.patch @@ -0,0 +1,11 @@ +--- a/frmts/pdf/pdfsdk_headers.h ++++ b/frmts/pdf/pdfsdk_headers.h +@@ -103,7 +103,7 @@ typedef unsigned char Guchar; + #undef GetObject + #endif + +-#include "podofo.h" ++#include + #endif // HAVE_PODOFO + + #ifdef HAVE_PDFIUM diff --git a/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-xerces.patch b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-xerces.patch new file mode 100644 index 0000000000000..830883f5eaae3 --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-include-xerces.patch @@ -0,0 +1,48 @@ +--- a/ogr/ogrsf_frmts/gml/xercesc_headers.h ++++ b/ogr/ogrsf_frmts/gml/xercesc_headers.h +@@ -33,13 +33,13 @@ + #pragma GCC system_header + #endif + +-#include +-#include +-#include +-#include +-#include +-#include +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + + using namespace XERCES_CPP_NAMESPACE; + +--- a/ogr/ogrsf_frmts/ili/xercesc_headers.h ++++ b/ogr/ogrsf_frmts/ili/xercesc_headers.h +@@ -33,14 +33,14 @@ + #pragma GCC system_header + #endif + +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include + + using namespace XERCES_CPP_NAMESPACE; + diff --git a/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-nmake.patch b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-nmake.patch new file mode 100644 index 0000000000000..446e886dcd8b3 --- /dev/null +++ b/recipes/gdal/pre_3.5.0/patches/3.4.x/fix-nmake.patch @@ -0,0 +1,168 @@ +--- a/apps/makefile.vc ++++ b/apps/makefile.vc +@@ -8,6 +8,9 @@ EXTRAFLAGS = -I..\frmts\vrt -I..\ogr\ogrsf_frmts\geojson\libjson -I..\ogr\ogrsf_ + !INCLUDE ..\nmake.opt + + LIBS = $(GDALLIB) ++!IF "$(DLLBUILD)" != "1" ++LIBS = $(LIBS) $(EXTERNAL_LIBS) ++!ENDIF + + !IFDEF INCLUDE_OGR_FRMTS + OGR_PROGRAMS = gdal_contour.exe gdaltindex.exe gdal_rasterize.exe \ +--- a/frmts/gif/makefile.vc ++++ b/frmts/gif/makefile.vc +@@ -10,14 +10,8 @@ EXTRAFLAGS = -Igiflib + + default: $(OBJ) + xcopy /D /Y *.obj ..\o +- cd giflib +- $(MAKE) /f makefile.vc +- cd .. + + clean: + -del *.obj +- cd giflib +- $(MAKE) /f makefile.vc clean +- cd .. + + +--- a/frmts/jpeg/makefile.vc ++++ b/frmts/jpeg/makefile.vc +@@ -29,12 +29,16 @@ default: $(EXTRA_DEP) $(OBJ) + + clean: + -del *.obj ++!IFNDEF JPEG_EXTERNAL_LIB + cd libjpeg + $(MAKE) /f makefile.vc clean + cd .. ++!ENDIF ++!IFDEF JPEG12_SUPPORTED + cd libjpeg12 + $(MAKE) /f makefile.vc clean + cd .. ++!ENDIF + + libjpeg12src: + cd libjpeg12 +--- a/frmts/kea/makefile.vc ++++ b/frmts/kea/makefile.vc +@@ -1,7 +1,7 @@ + + OBJ = keaband.obj keacopy.obj keadataset.obj keadriver.obj keamaskband.obj keaoverview.obj kearat.obj + +-EXTRAFLAGS = $(KEA_CFLAGS) -DH5_BUILT_AS_DYNAMIC_LIB ++EXTRAFLAGS = $(KEA_CFLAGS) + + GDAL_ROOT = ..\.. + +--- a/frmts/makefile.vc ++++ b/frmts/makefile.vc +@@ -3,11 +3,11 @@ GDAL_ROOT = .. + + EXTRAFLAGS = -DFRMT_ceos -DFRMT_aigrid -DFRMT_elas -DFRMT_hfa -DFRMT_gtiff\ + -DFRMT_sdts -DFRMT_raw -DFRMT_gxf -DFRMT_ceos2 -DFRMT_png \ +- -DFRMT_dted -DFRMT_mem -DFRMT_jdem -DFRMT_gif -DFRMT_esric \ ++ -DFRMT_dted -DFRMT_mem -DFRMT_jdem -DFRMT_esric \ + -DFRMT_envisat -DFRMT_aaigrid -DFRMT_usgsdem -DFRMT_l1b \ + -DFRMT_fit -DFRMT_vrt -DFRMT_xpm -DFRMT_bmp -DFRMT_rmf \ +- -DFRMT_nitf -DFRMT_pcidsk -DFRMT_airsar -DFRMT_rs2 \ +- -DFRMT_ilwis -DFRMT_msgn -DFRMT_rik -DFRMT_pcraster \ ++ -DFRMT_nitf -DFRMT_airsar -DFRMT_rs2 \ ++ -DFRMT_ilwis -DFRMT_msgn -DFRMT_rik \ + -DFRMT_leveller -DFRMT_sgi -DFRMT_srtmhgt -DFRMT_idrisi \ + -DFRMT_jaxapalsar -DFRMT_ers -DFRMT_ingr -DFRMT_dimap \ + -DFRMT_gff -DFRMT_terragen -DFRMT_gsg -DFRMT_cosar -DFRMT_pds \ +@@ -32,6 +32,22 @@ PLUGINDIRLIST = $(PLUGINFLAGS:-DFRMT_=) + EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_postgisraster + !ENDIF + ++!IFDEF GIF_SETTING ++EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_gif ++!ENDIF ++ ++!IFDEF PCIDSK_SETTING ++EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_pcidsk ++!ENDIF ++ ++!IFDEF PCRASTER_SETTING ++EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_pcraster ++!ENDIF ++ ++!IFDEF EXR_INC ++EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_exr ++!ENDIF ++ + !IFDEF JPEG_SUPPORTED + EXTRAFLAGS = -DFRMT_jpeg $(EXTRAFLAGS) + !ENDIF +--- a/frmts/pcidsk/makefile.vc ++++ b/frmts/pcidsk/makefile.vc +@@ -14,7 +14,11 @@ OBJ = pcidskdataset2.obj ogrpcidsklayer.obj vsi_pcidsk_io.obj gdal_edb.obj + !ENDIF + + !IF "$(PCIDSK_SETTING)" == "INTERNAL" ++!IFDEF JPEG_SUPPORTED + PCIDSKFLAGS = -Isdk -DPCIDSK_INTERNAL -DHAVE_LIBJPEG ++!ELSE ++PCIDSKFLAGS = -Isdk -DPCIDSK_INTERNAL ++!ENDIF + + OBJ = pcidskdataset2.obj ogrpcidsklayer.obj vsi_pcidsk_io.obj gdal_edb.obj \ + sdk\blockdir\asciitiledir.obj \ +@@ -70,11 +74,13 @@ OBJ = pcidskdataset2.obj ogrpcidsklayer.obj vsi_pcidsk_io.obj gdal_edb.obj \ + + !ENDIF + ++!IFDEF JPEG_SUPPORTED + !IFDEF JPEG_EXTERNAL_LIB + JPEGFLAGS = -I$(JPEGDIR) + !ELSE + JPEGFLAGS = -I..\jpeg\libjpeg + !ENDIF ++!ENDIF + + .cpp.obj: + $(CC) $(CFLAGS) $(PCIDSKFLAGS) $(JPEGFLAGS) /c $*.cpp /Fo$*.obj +--- a/makefile.vc ++++ b/makefile.vc +@@ -84,7 +84,7 @@ staticlib: $(LIB_DEPENDS) + call < + +#include +#include + +int main() { + GDALAllRegister(); + + const char *pszDriverName = "ESRI Shapefile"; + GDALDriverH hDriver = GDALGetDriverByName(pszDriverName); + if (!hDriver) { + printf("%s driver not available.\n", pszDriverName); + exit(1); + } + + GDALDatasetH hDS = GDALCreate(hDriver, "point_out_c.shp", 0, 0, 0, GDT_Unknown, NULL); + if (!hDS) { + printf("Creation of output file failed.\n"); + exit(1); + } + + OGRLayerH hLayer = GDALDatasetCreateLayer(hDS, "point_out", NULL, wkbPoint, NULL); + if (!hLayer) { + printf("Layer creation failed.\n"); + exit(1); + } + + OGRFieldDefnH hFieldDefn = OGR_Fld_Create("Name", OFTString); + + OGR_Fld_SetWidth(hFieldDefn, 32); + + if (OGR_L_CreateField(hLayer, hFieldDefn, TRUE) != OGRERR_NONE) { + printf("Creating Name field failed.\n"); + exit(1); + } + + OGR_Fld_Destroy(hFieldDefn); + + OGRFeatureH hFeature = OGR_F_Create(OGR_L_GetLayerDefn(hLayer)); + OGR_F_SetFieldString(hFeature, OGR_F_GetFieldIndex(hFeature, "Name"), "conan"); + + OGRGeometryH hPt = OGR_G_CreateGeometry(wkbPoint); + OGR_G_SetPoint_2D(hPt, 0, 40.74, -27.891); + + OGR_F_SetGeometry(hFeature, hPt); + OGR_G_DestroyGeometry(hPt); + + if (OGR_L_CreateFeature(hLayer, hFeature) != OGRERR_NONE) { + printf("Failed to create feature in shapefile.\n"); + exit(1); + } + + OGR_F_Destroy(hFeature); + + GDALClose(hDS); + + return 0; +} diff --git a/recipes/gdal/pre_3.5.0/test_package/test_package.cpp b/recipes/gdal/pre_3.5.0/test_package/test_package.cpp new file mode 100644 index 0000000000000..ec77987bc5ece --- /dev/null +++ b/recipes/gdal/pre_3.5.0/test_package/test_package.cpp @@ -0,0 +1,54 @@ +#include + +#include +#include + +int main() { + GDALAllRegister(); + + const char *pszDriverName = "ESRI Shapefile"; + GDALDriver *poDriver = GetGDALDriverManager()->GetDriverByName(pszDriverName); + if (!poDriver) { + printf("%s driver not available.\n", pszDriverName); + exit(1); + } + + GDALDataset *poDS = poDriver->Create("point_out_cpp.shp", 0, 0, 0, GDT_Unknown, NULL); + if (!poDS) { + printf("Creation of output file failed.\n"); + exit(1); + } + + OGRLayer *poLayer = poDS->CreateLayer("point_out", NULL, wkbPoint, NULL); + if (!poLayer) { + printf("Layer creation failed.\n"); + exit(1); + } + + OGRFieldDefn oField("Name", OFTString); + oField.SetWidth(32); + + if (poLayer->CreateField(&oField) != OGRERR_NONE) { + printf("Creating Name field failed.\n"); + exit(1); + } + + OGRFeature *poFeature = OGRFeature::CreateFeature(poLayer->GetLayerDefn()); + poFeature->SetField("Name", "conan"); + + OGRPoint pt; + pt.setX(40.74); + pt.setY(-27.891); + poFeature->SetGeometry(&pt); + + if (poLayer->CreateFeature(poFeature) != OGRERR_NONE) { + printf("Failed to create feature in shapefile.\n"); + exit( 1 ); + } + + OGRFeature::DestroyFeature(poFeature); + + GDALClose(poDS); + + return 0; +} diff --git a/recipes/gdbm/all/conandata.yml b/recipes/gdbm/all/conandata.yml index b9d5ef48f033c..bac7f3ad5d141 100644 --- a/recipes/gdbm/all/conandata.yml +++ b/recipes/gdbm/all/conandata.yml @@ -11,3 +11,7 @@ sources: "https://mirrors.tripadvisor.com/gnu/gdbm/gdbm-1.19.tar.gz", ] sha256: "37ed12214122b972e18a0d94995039e57748191939ef74115b1d41d8811364bc" +patches: + "1.18.1": + - patch_file: "patches/0001-fix-multiple-definitions.patch" + base_path: "source_subfolder" diff --git a/recipes/gdbm/all/conanfile.py b/recipes/gdbm/all/conanfile.py index 97243b93f9b86..823adce58d090 100644 --- a/recipes/gdbm/all/conanfile.py +++ b/recipes/gdbm/all/conanfile.py @@ -1,6 +1,9 @@ from conans import ConanFile, AutoToolsBuildEnvironment, tools from conans.errors import ConanInvalidConfiguration import os +import shutil + +required_conan_version = ">=1.33.0" class GdbmConan(ConanFile): @@ -34,41 +37,51 @@ class GdbmConan(ConanFile): "with_nls": True, } + exports_sources = "patches/**" _autotools = None @property def _source_subfolder(self): return "source_subfolder" - def config_options(self): - if self.settings.os == "Windows": - raise ConanInvalidConfiguration("gdbm is not supported on Windows") - def configure(self): - # Disabling NLS will render the dependency on libiconv and gettext moot - # as the configure script will no longer look for that - if not self.options.with_nls: - if self.options.with_libiconv: - raise ConanInvalidConfiguration( - "with_libiconv=True when with_nls=False is not possible " - "as it's NLS that requires libiconv") - + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + if not self.options.with_nls: + del self.options.with_libiconv def requirements(self): - if self.options.with_libiconv: + if self.options.get_safe("with_libiconv"): self.requires("libiconv/1.16") if self.options.with_readline: - self.requires("readline/8.0") + self.requires("readline/8.1.2") + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("gdbm is not supported on Windows") def build_requirements(self): - self.build_requires("bison/3.5.3") + self.build_requires("bison/3.7.6") self.build_requires("flex/2.6.4") + self.build_requires("gnu-config/cci.20210814") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("gdbm-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", None) or self.deps_user_info + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "build-aux", "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "build-aux", "config.guess")) def _configure_autotools(self): if self._autotools: @@ -87,13 +100,13 @@ def _configure_autotools(self): else: conf_args.extend([ "--disable-shared", "--enable-static", - "--with-pic" if self.options.fPIC else "--without-pic"] + "--with-pic" if self.options.get_safe("fPIC", True) else "--without-pic"] ) if not self.options.with_nls: conf_args.extend(["--disable-nls"]) - if self.options.with_libiconv: + if self.options.get_safe("with_libiconv"): conf_args.extend([ "--with-libiconv-prefix={}" .format(self.deps_cpp_info["libiconv"].rootpath), @@ -107,6 +120,7 @@ def _configure_autotools(self): return self._autotools def build(self): + self._patch_sources() with tools.chdir(self._source_subfolder): autotools = self._configure_autotools() with tools.chdir("src"): @@ -118,11 +132,7 @@ def package(self): with tools.chdir(self._source_subfolder): autotools = self._configure_autotools() autotools.install() - os.unlink(os.path.join(self.package_folder, "lib", "libgdbm.la")) - compat_la = os.path.join(self.package_folder, "lib", - "libgdbm_compat.la") - if (os.path.exists(compat_la)): - os.unlink(compat_la) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") tools.rmdir(os.path.join(self.package_folder, "share")) def package_info(self): diff --git a/recipes/gdbm/all/patches/0001-fix-multiple-definitions.patch b/recipes/gdbm/all/patches/0001-fix-multiple-definitions.patch new file mode 100644 index 0000000000000..341fa514fb44d --- /dev/null +++ b/recipes/gdbm/all/patches/0001-fix-multiple-definitions.patch @@ -0,0 +1,11 @@ +--- a/src/parseopt.c ++++ b/src/parseopt.c +@@ -255,8 +255,6 @@ print_option_descr (const char *descr, size_t lmargin, size_t rmargin) + } + + char *parseopt_program_name; +-char *parseopt_program_doc; +-char *parseopt_program_args; + const char *program_bug_address = "<" PACKAGE_BUGREPORT ">"; + void (*parseopt_help_hook) (FILE *stream); + diff --git a/recipes/gdbm/all/test_package/test_package.c b/recipes/gdbm/all/test_package/test_package.c index e9210b8f9a85a..ab72c72ff801f 100644 --- a/recipes/gdbm/all/test_package/test_package.c +++ b/recipes/gdbm/all/test_package/test_package.c @@ -12,7 +12,7 @@ int main(int argc, char *argv[]) { gdbm_count_t count; datum key, content, fetch; - file = gdbm_open("test.db", 512, GDBM_WRCREAT, O_RDWR | O_CREAT, NULL); + file = gdbm_open("test.db", 512, GDBM_WRCREAT, 0644, NULL); if (file == NULL) { puts("gdbm_open failed\n"); return EXIT_FAILURE; diff --git a/recipes/gdcm/all/conandata.yml b/recipes/gdcm/all/conandata.yml new file mode 100644 index 0000000000000..01421f07c195d --- /dev/null +++ b/recipes/gdcm/all/conandata.yml @@ -0,0 +1,44 @@ +sources: + "3.0.20": + url: "https://github.com/malaterre/GDCM/archive/refs/tags/v3.0.20.tar.gz" + sha256: "18161bd76008f4e8a0a33dab72fa34684147e8164f25a4735f373ad4bd909636" + "3.0.9": + url: "https://github.com/malaterre/GDCM/archive/refs/tags/v3.0.9.tar.gz" + sha256: "fcfc50ea8809bd4a173550c7d7bb4f8722ae0781fbf17240ce84a04e90af0e9b" +patches: + "3.0.20": + - patch_file: "patches/0001-charls-linking.patch" + patch_description: "fix symbol export for gdcmcharls" + patch_type: "portability" + - patch_file: "patches/0002-3.0.20-openjpeg.patch" + patch_description: "fix variable names for openjpeg" + patch_type: "conan" + - patch_file: "patches/0004-3.0.20-find-expat.patch" + patch_description: "enforce usage of FindEXPAT.cmake" + patch_type: "conan" + - patch_file: "patches/0005-3.0.20-openssl.patch" + patch_description: "skip check_cxx_source_compiles usage for openssl" + patch_type: "conan" + - patch_file: "patches/0006-json.patch" + patch_description: "skip check_cxx_source_compiles usage for json-c" + patch_type: "conan" + "3.0.9": + - patch_file: "patches/0001-charls-linking.patch" + patch_description: "fix symbol export for gdcmcharls" + patch_type: "portability" + - patch_file: "patches/0002-3.0.9-openjpeg.patch" + patch_description: "fix variable names for openjpeg" + patch_type: "conan" + - patch_file: "patches/0003-gcc-11-compilation.patch" + patch_description: "add missing includes for GCC 11" + patch_type: "backport" + patch_source: "https://github.com/malaterre/GDCM/commit/4404b770be337bd0d5d3c2289abfd34426433db2" + - patch_file: "patches/0004-3.0.9-find-expat.patch" + patch_description: "enforce usage of FindEXPAT.cmake" + patch_type: "conan" + - patch_file: "patches/0005-3.0.9-openssl.patch" + patch_description: "skip check_cxx_source_compiles usage for openssl" + patch_type: "conan" + - patch_file: "patches/0006-json.patch" + patch_description: "skip check_cxx_source_compiles usage for json-c" + patch_type: "conan" diff --git a/recipes/gdcm/all/conanfile.py b/recipes/gdcm/all/conanfile.py new file mode 100644 index 0000000000000..1ef89c6475efc --- /dev/null +++ b/recipes/gdcm/all/conanfile.py @@ -0,0 +1,246 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import check_min_cppstd, valid_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir, save +from conan.tools.microsoft import is_msvc_static_runtime +from conan.tools.scm import Version +import os +import textwrap + + +required_conan_version = ">=1.53.0" + + +class GDCMConan(ConanFile): + name = "gdcm" + description = "C++ library for DICOM medical files" + license = "BSD-3-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://gdcm.sourceforge.net/" + topics = ("dicom", "images", "medical-imaging") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_json": [True, False], + "with_openssl": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_json": True, + "with_openssl": True, + } + + @property + def _min_cppstd(self): + return 11 + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("expat/2.5.0") + self.requires("openjpeg/2.5.0") + self.requires("zlib/1.2.13") + if self.settings.os != "Windows": + self.requires("libuuid/1.0.3") + if Version(self.version) >= Version("3.0.20"): + self.requires("libiconv/1.17") + if self.options.with_json: + self.requires("json-c/0.16") + if self.options.with_openssl: + self.requires("openssl/1.1.1s") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + if is_msvc_static_runtime(self) and self.info.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} does not support shared and static runtime together.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["GDCM_BUILD_DOCBOOK_MANPAGES"] = False + tc.variables["GDCM_BUILD_SHARED_LIBS"] = bool(self.options.shared) + # FIXME: unvendor deps https://github.com/conan-io/conan-center-index/pull/5705#discussion_r647224146 + tc.variables["GDCM_USE_SYSTEM_EXPAT"] = True + tc.variables["GDCM_USE_SYSTEM_JSON"] = self.options.with_json + tc.variables["GDCM_USE_SYSTEM_OPENJPEG"] = True + tc.variables["GDCM_USE_SYSTEM_OPENSSL"] = self.options.with_openssl + tc.variables["GDCM_USE_SYSTEM_UUID"] = self.settings.os != "Windows" + tc.variables["GDCM_USE_SYSTEM_ZLIB"] = True + + if not valid_min_cppstd(self, self._min_cppstd): + tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="Copyright.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + if self.settings.os == "Windows": + bin_dir = os.path.join(self.package_folder, "bin") + rm(self, "[!gs]*.dll", bin_dir) + rm(self, "*.pdb", bin_dir) + + rm(self, "[!U]*.cmake", os.path.join(self.package_folder, "lib", self._gdcm_subdir)) #leave UseGDCM.cmake untouched + rmdir(self, os.path.join(self.package_folder, "share")) + self._create_cmake_variables(os.path.join(self.package_folder, self._gdcm_cmake_variables_path)) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets() + + def _create_cmake_variables(self, variables_file): + v = Version(self.version) + content = textwrap.dedent(f"""\ + # The GDCM version number. + set(GDCM_MAJOR_VERSION "{v.major}") + set(GDCM_MINOR_VERSION "{v.minor}") + set(GDCM_BUILD_VERSION "{v.patch}") + + get_filename_component(SELF_DIR "${{CMAKE_CURRENT_LIST_FILE}}" PATH) + + # The libraries. + set(GDCM_LIBRARIES "") + + # The CMake macros dir. + set(GDCM_CMAKE_DIR "") + + # The configuration options. + set(GDCM_BUILD_SHARED_LIBS "{"ON" if self.options.shared else "OFF"}") + + set(GDCM_USE_VTK "OFF") + + # The "use" file. + set(GDCM_USE_FILE ${{SELF_DIR}}/UseGDCM.cmake) + + # The VTK options. + set(GDCM_VTK_DIR "") + + get_filename_component(GDCM_INCLUDE_ROOT "${{SELF_DIR}}/../../include/{self._gdcm_subdir}" ABSOLUTE) + set(GDCM_INCLUDE_DIRS ${{GDCM_INCLUDE_ROOT}}) + get_filename_component(GDCM_LIB_ROOT "${{SELF_DIR}}/../../lib" ABSOLUTE) + set(GDCM_LIBRARY_DIRS ${{GDCM_LIB_ROOT}}) + """) + save(self, variables_file, content) + + def _create_cmake_module_alias_targets(self): + module_file = os.path.join(self.package_folder, self._gdcm_cmake_module_aliases_path) + targets = {library: f"GDCM::{library}" for library in self._gdcm_libraries} + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _gdcm_builddir(self): + return os.path.join("lib", self._gdcm_subdir) + + @property + def _gdcm_cmake_module_aliases_path(self): + return os.path.join("lib", self._gdcm_subdir, "conan-official-gdcm-targets.cmake") + + @property + def _gdcm_cmake_variables_path(self): + return os.path.join("lib", self._gdcm_subdir, "conan-official-gdcm-variables.cmake") + + @property + def _gdcm_build_modules(self): + return [self._gdcm_cmake_module_aliases_path, self._gdcm_cmake_variables_path] + + @property + def _gdcm_libraries(self): + gdcm_libs = ["gdcmcharls", + "gdcmCommon", + "gdcmDICT", + "gdcmDSED", + "gdcmIOD", + "gdcmjpeg12", + "gdcmjpeg16", + "gdcmjpeg8", + "gdcmMEXD", + "gdcmMSFF", + "socketxx"] + if self.settings.os == "Windows": + gdcm_libs.append("gdcmgetopt") + return gdcm_libs + + @property + def _gdcm_subdir(self): + v = Version(self.version) + return f"gdcm-{v.major}.{v.minor}" + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "GDCM") + self.cpp_info.set_property("cmake_build_modules", [self._gdcm_cmake_variables_path]) + + for lib in self._gdcm_libraries: + self.cpp_info.components[lib].set_property("cmake_target_name", lib) + self.cpp_info.components[lib].libs = [lib] + self.cpp_info.components[lib].includedirs = [os.path.join("include", self._gdcm_subdir)] + self.cpp_info.components[lib].builddirs.append(self._gdcm_builddir) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.components[lib].build_modules["cmake"] = [self._gdcm_cmake_module_aliases_path] + self.cpp_info.components[lib].build_modules["cmake_find_package"] = self._gdcm_build_modules + self.cpp_info.components[lib].build_modules["cmake_find_package_multi"] = self._gdcm_build_modules + + if self.options.with_openssl: + self.cpp_info.components["gdcmCommon"].requires.append("openssl::openssl") + self.cpp_info.components["gdcmDSED"].requires.extend(["gdcmCommon", "zlib::zlib"]) + self.cpp_info.components["gdcmIOD"].requires.extend(["gdcmDSED", "gdcmCommon", "expat::expat"]) + self.cpp_info.components["gdcmMSFF"].requires.extend(["gdcmIOD", "gdcmDSED", "gdcmDICT", "openjpeg::openjpeg"]) + if self.options.with_json: + self.cpp_info.components["gdcmMSFF"].requires.append("json-c::json-c") + if self.settings.os != "Windows": + self.cpp_info.components["gdcmMSFF"].requires.append("libuuid::libuuid") + if Version(self.version) >= Version("3.0.20"): + self.cpp_info.components["gdcmMSFF"].requires.append("libiconv::libiconv") + if not self.options.shared: + self.cpp_info.components["gdcmDICT"].requires.extend(["gdcmDSED", "gdcmIOD"]) + self.cpp_info.components["gdcmMEXD"].requires.extend(["gdcmMSFF", "gdcmDICT", "gdcmDSED", "gdcmIOD", "socketxx"]) + self.cpp_info.components["gdcmMSFF"].requires.extend(["gdcmjpeg8", "gdcmjpeg12", "gdcmjpeg16", "gdcmcharls"]) + + if self.settings.os == "Windows": + self.cpp_info.components["gdcmCommon"].system_libs = ["ws2_32", "crypt32"] + self.cpp_info.components["gdcmMSFF"].system_libs = ["rpcrt4"] + self.cpp_info.components["socketxx"].system_libs = ["ws2_32"] + else: + self.cpp_info.components["gdcmCommon"].system_libs = ["dl"] + if is_apple_os(self): + self.cpp_info.components["gdcmCommon"].frameworks = ["CoreFoundation"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "GDCM" + self.cpp_info.names["cmake_find_package_multi"] = "GDCM" diff --git a/recipes/gdcm/all/patches/0001-charls-linking.patch b/recipes/gdcm/all/patches/0001-charls-linking.patch new file mode 100644 index 0000000000000..57df8966f04ba --- /dev/null +++ b/recipes/gdcm/all/patches/0001-charls-linking.patch @@ -0,0 +1,38 @@ +--- a/Utilities/gdcmcharls/CMakeLists.txt ++++ b/Utilities/gdcmcharls/CMakeLists.txt +@@ -61,12 +61,10 @@ endif() + #option(charls_BUILD_SHARED_LIBS "Build CharLS with shared libraries." OFF) + #set(BUILD_SHARED_LIBS ${charls_BUILD_SHARED_LIBS}) + +-if(WIN32) +- if(BUILD_SHARED_LIBS) +- add_definitions(-DCHARLS_DLL_BUILD) +- else() +- add_definitions(-DCHARLS_STATIC) +- endif() ++if(BUILD_SHARED_LIBS) ++ add_definitions(-DCHARLS_DLL_BUILD) ++else() ++ add_definitions(-DCHARLS_STATIC) + endif() + + add_library(${CHARLS_LIBRARY_NAME} +--- a/Utilities/gdcmcharls/charls.h ++++ b/Utilities/gdcmcharls/charls.h +@@ -13,12 +13,12 @@ + #define CHARLS_IMEXPORT(returntype) __declspec(dllexport) returntype __stdcall + #endif + +-// Non-windows (static linking) +-#if !defined(CHARLS_IMEXPORT) && !defined(_WIN32) +-# define CHARLS_IMEXPORT(returntype) returntype ++// Non-windows (dynamic linking) ++#if !defined(WIN32) && (defined(CHARLS_DLL) || defined(CHARLS_DLL_BUILD)) ++#define CHARLS_IMEXPORT(returntype) __attribute__((visibility("default"))) returntype + #endif + +-// Windows static linking ++// Static linking + #if !defined(CHARLS_IMEXPORT) && defined(CHARLS_STATIC) + # define CHARLS_IMEXPORT(returntype) returntype + #endif diff --git a/recipes/gdcm/all/patches/0002-3.0.20-openjpeg.patch b/recipes/gdcm/all/patches/0002-3.0.20-openjpeg.patch new file mode 100644 index 0000000000000..59aa76d14cfc8 --- /dev/null +++ b/recipes/gdcm/all/patches/0002-3.0.20-openjpeg.patch @@ -0,0 +1,22 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -360,7 +360,7 @@ endif() + + if(GDCM_USE_SYSTEM_OPENJPEG) + find_package(OpenJPEG 2.0.0 REQUIRED) +- set(GDCM_OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARIES}) ++ set(GDCM_OPENJPEG_LIBRARIES ${OpenJPEG_LIBRARIES}) + else() + set(GDCM_OPENJPEG_LIBRARIES gdcmopenjp2) + endif() +--- a/Source/MediaStorageAndFileFormat/CMakeLists.txt ++++ b/Source/MediaStorageAndFileFormat/CMakeLists.txt +@@ -161,7 +161,7 @@ else() + ) + endif() + if(GDCM_USE_SYSTEM_OPENJPEG) +- include_directories(${OPENJPEG_INCLUDE_DIRS} ) ++ include_directories(${OpenJPEG_INCLUDE_DIRS} ) + else() + include_directories( + "${GDCM_BINARY_DIR}/Utilities/gdcmopenjpeg" diff --git a/recipes/gdcm/all/patches/0002-3.0.9-openjpeg.patch b/recipes/gdcm/all/patches/0002-3.0.9-openjpeg.patch new file mode 100644 index 0000000000000..a85da145a8462 --- /dev/null +++ b/recipes/gdcm/all/patches/0002-3.0.9-openjpeg.patch @@ -0,0 +1,22 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -364,7 +364,7 @@ endif() + + if(GDCM_USE_SYSTEM_OPENJPEG) + find_package(OpenJPEG 2.0.0 REQUIRED) +- set(GDCM_OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARIES}) ++ set(GDCM_OPENJPEG_LIBRARIES ${OpenJPEG_LIBRARIES}) + else() + set(GDCM_OPENJPEG_LIBRARIES gdcmopenjp2) + endif() +--- a/Source/MediaStorageAndFileFormat/CMakeLists.txt ++++ b/Source/MediaStorageAndFileFormat/CMakeLists.txt +@@ -149,7 +149,7 @@ else() + ) + endif() + if(GDCM_USE_SYSTEM_OPENJPEG) +- include_directories(${OPENJPEG_INCLUDE_DIRS} ) ++ include_directories(${OpenJPEG_INCLUDE_DIRS} ) + else() + include_directories( + "${GDCM_BINARY_DIR}/Utilities/gdcmopenjpeg" diff --git a/recipes/gdcm/all/patches/0003-gcc-11-compilation.patch b/recipes/gdcm/all/patches/0003-gcc-11-compilation.patch new file mode 100644 index 0000000000000..ff438c185dc4f --- /dev/null +++ b/recipes/gdcm/all/patches/0003-gcc-11-compilation.patch @@ -0,0 +1,68 @@ +From 4404b770be337bd0d5d3c2289abfd34426433db2 Mon Sep 17 00:00:00 2001 +From: Axel Braun +Date: Mon, 7 Jun 2021 16:27:52 +0200 +Subject: [PATCH] gdcm fails to build with gcc11 compiler + +gdcm fails to build with gcc11 compiler: +cd +/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/build/Source/MediaStorageAndFileFormat +&& /usr/bin/c++ -DgdcmMSFF_EXPORTS +-I/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/Source/Common +-I/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/build/Source/Common +-I/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/Source/DataStructureAndEncodingDefinition +-I/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/Source/DataDictionary +-I/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/Source/InformationObjectDefinition +-I/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/Source/MediaStorageAndFileFormat +-I/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/Utilities +-I/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/build/Utilities +-I/usr/include/charls -I/usr/include/openjpeg-2.4 -I/usr/include/json-c +-I/usr/include/json -O2 -Wall -D_FORTIFY_SOURCE=2 +-fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables +-fstack-clash-protection -Werror=return-type -flto=auto -g -fpermissive +-O2 -g -DNDEBUG -fPIC -MD -MT +Source/MediaStorageAndFileFormat/CMakeFiles/gdcmMSFF.dir/gdcmImageChangePhotometricInterpretation.cxx.o +-MF +CMakeFiles/gdcmMSFF.dir/gdcmImageChangePhotometricInterpretation.cxx.o.d +-o +CMakeFiles/gdcmMSFF.dir/gdcmImageChangePhotometricInterpretation.cxx.o +-c +/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.cxx +[ 131s] In file included from +/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.cxx:14: +[ 131s] +/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h: +In function 'T gdcm::Clamp(int)': +[ 131s] +/home/abuild/rpmbuild/BUILD/gdcm-3.0.8/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h:67:32: +error: 'numeric_limits' is not a member of 'std' +[ 131s] 67 | return v < 0 ? 0 : (v > std::numeric_limits::max() +? std::numeric_limits::max() : v); +--- + Source/MediaStorageAndFileFormat/gdcmImage.cxx | 1 + + .../gdcmImageChangePhotometricInterpretation.h | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/Source/MediaStorageAndFileFormat/gdcmImage.cxx b/Source/MediaStorageAndFileFormat/gdcmImage.cxx +index f59fdd7b7..78a1f7a5c 100644 +--- a/Source/MediaStorageAndFileFormat/gdcmImage.cxx ++++ b/Source/MediaStorageAndFileFormat/gdcmImage.cxx +@@ -20,6 +20,7 @@ + #include "gdcmFragment.h" + + #include ++#include + + namespace gdcm + { +diff --git a/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h b/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h +index d55a5ee47..798d3dfa6 100644 +--- a/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h ++++ b/Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h +@@ -16,6 +16,7 @@ + + #include "gdcmImageToImageFilter.h" + #include "gdcmPhotometricInterpretation.h" ++#include + + namespace gdcm + { diff --git a/recipes/gdcm/all/patches/0004-3.0.20-find-expat.patch b/recipes/gdcm/all/patches/0004-3.0.20-find-expat.patch new file mode 100644 index 0000000000000..8922436502476 --- /dev/null +++ b/recipes/gdcm/all/patches/0004-3.0.20-find-expat.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -419,7 +419,7 @@ endif() + + if(GDCM_USE_SYSTEM_EXPAT) + # If user say so, then this is a requirement ! +- find_package(EXPAT REQUIRED) ++ find_package(EXPAT REQUIRED MODULE) + set(GDCM_EXPAT_LIBRARIES ${EXPAT_LIBRARIES}) + else() + set(GDCM_EXPAT_LIBRARIES "gdcmexpat") diff --git a/recipes/gdcm/all/patches/0004-3.0.9-find-expat.patch b/recipes/gdcm/all/patches/0004-3.0.9-find-expat.patch new file mode 100644 index 0000000000000..174d4de82d842 --- /dev/null +++ b/recipes/gdcm/all/patches/0004-3.0.9-find-expat.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -423,7 +423,7 @@ endif() + + if(GDCM_USE_SYSTEM_EXPAT) + # If user say so, then this is a requirement ! +- find_package(EXPAT REQUIRED) ++ find_package(EXPAT REQUIRED MODULE) + set(GDCM_EXPAT_LIBRARIES ${EXPAT_LIBRARIES}) + else() + set(GDCM_EXPAT_LIBRARIES "gdcmexpat") diff --git a/recipes/gdcm/all/patches/0005-3.0.20-openssl.patch b/recipes/gdcm/all/patches/0005-3.0.20-openssl.patch new file mode 100644 index 0000000000000..f66b7d5bc18bd --- /dev/null +++ b/recipes/gdcm/all/patches/0005-3.0.20-openssl.patch @@ -0,0 +1,23 @@ +--- a/Source/Common/CMakeLists.txt ++++ b/Source/Common/CMakeLists.txt +@@ -68,18 +68,8 @@ CHECK_CXX_SOURCE_COMPILES( + "\#include \n#include \n#include \nint main() { std::u16string u16; std::string utf8 = std::wstring_convert, char16_t>{}.to_bytes(u16); }" + GDCM_HAVE_CODECVT) + if(GDCM_USE_SYSTEM_OPENSSL) +-set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) +-set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES} +- ${CMAKE_DL_LIBS} # FIXME ?? +- ) +-CHECK_CXX_SOURCE_COMPILES( +- # "\#include \nint main() { CMS_add0_recipient_key(0); return 0;}" +- #HAVE_CMS_RECIPIENT_KEY) +- "\#include \nint main() { CMS_add0_recipient_password(0,0,0,0,0,0,0); return 0;}" +- GDCM_HAVE_CMS_RECIPIENT_PASSWORD) +-CHECK_CXX_SOURCE_COMPILES( +- "\#include \nint main() { const void*mem; int len; BIO_new_mem_buf(mem, len); }" +- OPENSSL_HAS_CONST_VOID_BIO_NEW_MEM_BUF) ++ set(GDCM_HAVE_CMS_RECIPIENT_PASSWORD ON CACHE INTERNAL "") ++ set(OPENSSL_HAS_CONST_VOID_BIO_NEW_MEM_BUF ON CACHE INTERNAL "") + endif() + + #----------------------------------------------------------------------------- diff --git a/recipes/gdcm/all/patches/0005-3.0.9-openssl.patch b/recipes/gdcm/all/patches/0005-3.0.9-openssl.patch new file mode 100644 index 0000000000000..fe118a13f6970 --- /dev/null +++ b/recipes/gdcm/all/patches/0005-3.0.9-openssl.patch @@ -0,0 +1,19 @@ +--- a/Source/Common/CMakeLists.txt ++++ b/Source/Common/CMakeLists.txt +@@ -65,15 +65,7 @@ CHECK_CXX_SOURCE_COMPILES( + "\#include \nint main() { const wchar_t fn[10] = {}; std::ifstream is( fn ); return 0;}" + GDCM_HAVE_WCHAR_IFSTREAM) + if(GDCM_USE_SYSTEM_OPENSSL) +-set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) +-set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES} +- ${CMAKE_DL_LIBS} # FIXME ?? +- ) +-CHECK_CXX_SOURCE_COMPILES( +- # "\#include \nint main() { CMS_add0_recipient_key(0); return 0;}" +- #HAVE_CMS_RECIPIENT_KEY) +- "\#include \nint main() { CMS_add0_recipient_password(0,0,0,0,0,0,0); return 0;}" +- GDCM_HAVE_CMS_RECIPIENT_PASSWORD) ++ set(GDCM_HAVE_CMS_RECIPIENT_PASSWORD ON CACHE INTERNAL "") + endif() + + #----------------------------------------------------------------------------- diff --git a/recipes/gdcm/all/patches/0006-json.patch b/recipes/gdcm/all/patches/0006-json.patch new file mode 100644 index 0000000000000..5010643b169c4 --- /dev/null +++ b/recipes/gdcm/all/patches/0006-json.patch @@ -0,0 +1,13 @@ +--- a/Source/Common/CMakeLists.txt ++++ b/Source/Common/CMakeLists.txt +@@ -52,9 +52,7 @@ unset(CMAKE_REQUIRED_LIBRARIES) + CHECK_FUNCTION_EXISTS(gettimeofday GDCM_HAVE_GETTIMEOFDAY) + # json-c API changed: + if(GDCM_USE_SYSTEM_JSON) +- set(CMAKE_REQUIRED_INCLUDES ${JSON_INCLUDE_DIRS}) +- set(CMAKE_REQUIRED_LIBRARIES ${JSON_LIBRARIES}) +- CHECK_SYMBOL_EXISTS(json_object_object_get_ex "json.h" GDCM_HAVE_JSON_OBJECT_OBJECT_GET_EX) ++ set(GDCM_HAVE_JSON_OBJECT_OBJECT_GET_EX ON CACHE INTERNAL "") + endif() + + include(CheckCXXSourceCompiles) diff --git a/recipes/gdcm/all/test_package/CMakeLists.txt b/recipes/gdcm/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5465ea8e54b6d --- /dev/null +++ b/recipes/gdcm/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(GDCM REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +include(${GDCM_USE_FILE}) +target_link_libraries(${PROJECT_NAME} PRIVATE gdcmMSFF) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/gdcm/all/test_package/DCMTK_JPEGExt_12Bits.dcm b/recipes/gdcm/all/test_package/DCMTK_JPEGExt_12Bits.dcm new file mode 100644 index 0000000000000..a38d4be8214fc Binary files /dev/null and b/recipes/gdcm/all/test_package/DCMTK_JPEGExt_12Bits.dcm differ diff --git a/recipes/gdcm/all/test_package/conanfile.py b/recipes/gdcm/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1f94130dd62ec --- /dev/null +++ b/recipes/gdcm/all/test_package/conanfile.py @@ -0,0 +1,30 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +from conan.tools.files import mkdir +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + input_file = os.path.join(self.source_folder, "DCMTK_JPEGExt_12Bits.dcm") + test_dir = "test_dir" + mkdir(self, test_dir) + output_file = os.path.join(test_dir, "output.dcm") + self.run(f"\"{bin_path}\" \"{input_file}\" \"{output_file}\"", env="conanrun") diff --git a/recipes/gdcm/all/test_package/test_package.cpp b/recipes/gdcm/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..38a0b1316570a --- /dev/null +++ b/recipes/gdcm/all/test_package/test_package.cpp @@ -0,0 +1,104 @@ +/*========================================================================= + + Program: GDCM (Grassroots DICOM). A DICOM library + + Copyright (c) 2006-2011 Mathieu Malaterre + All rights reserved. + See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ +/* + * This example is ... guess what this is for :) + */ + +#include "gdcmReader.h" +#include "gdcmUIDGenerator.h" +#include "gdcmWriter.h" +#include "gdcmAttribute.h" + +#include + +#ifdef GDCM_USE_SYSTEM_OPENSSL +#include "gdcmCryptoFactory.h" +void test_openssl_link() +{ + (void)gdcm::CryptoFactory::GetFactoryInstance(gdcm::CryptoFactory::OPENSSL); +} +#endif + +#ifdef GDCM_USE_SYSTEM_JSON +#include "gdcmJSON.h" +void test_json_link() +{ + gdcm::JSON json; + json.PrettyPrintOn(); +} +#endif + +bool test_uid() +{ + gdcm::UIDGenerator uid; + uid.SetRoot( "1.2.3.4.0.0.1" ); + const char *s = uid.Generate(); + return gdcm::UIDGenerator::IsValid(s); +} + +int main(int argc, char* argv[]) +{ + if (argc < 3) + { + std::cerr << argv[0] << " input.dcm output.dcm" << std::endl; + return 1; + } + const char* filename = argv[1]; + const char* outfilename = argv[2]; + + // Instanciate the reader: + gdcm::Reader reader; + reader.SetFileName(filename); + if (!reader.Read()) + { + std::cerr << "Could not read: " << filename << std::endl; + return 1; + } + + // If we reach here, we know for sure only 1 thing: + // It is a valid DICOM file (potentially an old ACR-NEMA 1.0/2.0 file) + // (Maybe, it's NOT a Dicom image -could be a DICOMDIR, a RTSTRUCT, etc-) + + // The output of gdcm::Reader is a gdcm::File + gdcm::File& file = reader.GetFile(); + + // the dataset is the the set of element we are interested in: + gdcm::DataSet& ds = file.GetDataSet(); + + // Contruct a static(*) type for Image Comments : + gdcm::Attribute<0x0020, 0x4000> imagecomments; + imagecomments.SetValue("Hello, World !"); + + // Now replace the Image Comments from the dataset with our: + ds.Replace(imagecomments.GetAsDataElement()); + + // Write the modified DataSet back to disk + gdcm::Writer writer; + writer.CheckFileMetaInformationOff(); // Do not attempt to reconstruct the file meta to preserve the file + // as close to the original as possible. + writer.SetFileName(outfilename); + writer.SetFile(file); + if (!writer.Write()) + { + std::cerr << "Could not write: " << outfilename << std::endl; + return 1; + } + std::cout << "GDCM test: success\n"; + return 0; +} + +/* + * (*) static type, means that extra DICOM information VR & VM are computed at compilation time. + * The compiler is deducing those values from the template arguments of the class. + */ diff --git a/recipes/gdcm/all/test_v1_package/CMakeLists.txt b/recipes/gdcm/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/gdcm/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/gdcm/all/test_v1_package/conanfile.py b/recipes/gdcm/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a38d3dbb55dca --- /dev/null +++ b/recipes/gdcm/all/test_v1_package/conanfile.py @@ -0,0 +1,23 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +from conan.tools.files import mkdir +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + input_file = os.path.join(self.source_folder, os.pardir, "test_package", "DCMTK_JPEGExt_12Bits.dcm") + test_dir = "test_dir" + mkdir(self, test_dir) + output_file = os.path.join(test_dir, "output.dcm") + self.run([bin_path, input_file, output_file], run_environment=True) diff --git a/recipes/gdcm/config.yml b/recipes/gdcm/config.yml new file mode 100644 index 0000000000000..f1b37cf5e936f --- /dev/null +++ b/recipes/gdcm/config.yml @@ -0,0 +1,5 @@ +versions: + "3.0.20": + folder: "all" + "3.0.9": + folder: "all" diff --git a/recipes/gdk-pixbuf/all/conandata.yml b/recipes/gdk-pixbuf/all/conandata.yml index 34211e04c8cf4..20b0c843bbfec 100644 --- a/recipes/gdk-pixbuf/all/conandata.yml +++ b/recipes/gdk-pixbuf/all/conandata.yml @@ -1,10 +1,20 @@ sources: - "2.42.0": - url: "http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.0.tar.xz" - sha256: "73441338d1a901dc7a3940113cb0aac22776b2832f7eab8f8ec7ec5755adaec7" - "2.42.2": - url: "http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.2.tar.xz" - sha256: "83c66a1cfd591d7680c144d2922c5955d38b4db336d7cd3ee109f7bcf9afef15" - "2.42.4": - url: "https://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.4.tar.xz" - sha256: "fe9c5dd88f486194ea2bc09b8814c1ed895bb6c530f37cbbf259757c4e482e4d" + "2.42.10": + url: "https://download.gnome.org/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.10.tar.xz" + sha256: "ee9b6c75d13ba096907a2e3c6b27b61bcd17f5c7ebeab5a5b439d2f2e39fe44b" + "2.42.9": + url: "https://download.gnome.org/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.9.tar.xz" + sha256: "28f7958e7bf29a32d4e963556d241d0a41a6786582ff6a5ad11665e0347fc962" + "2.42.8": + url: "https://download.gnome.org/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.8.tar.xz" + sha256: "84acea3acb2411b29134b32015a5b1aaa62844b19c4b1ef8b8971c6b0759f4c6" + "2.42.6": + url: "https://download.gnome.org/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.6.tar.xz" + sha256: "c4a6b75b7ed8f58ca48da830b9fa00ed96d668d3ab4b1f723dcf902f78bde77f" + +patches: + "2.42.8": + - patch_file: "patches/define_dllmain_only_when_shared.patch" + patch_type: backport + patch_description: Disable relocation when built as a static libary on Windows + patch_source: "https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/136" diff --git a/recipes/gdk-pixbuf/all/conanfile.py b/recipes/gdk-pixbuf/all/conanfile.py index 9ec1296454050..c7ef320ce9ef9 100644 --- a/recipes/gdk-pixbuf/all/conanfile.py +++ b/recipes/gdk-pixbuf/all/conanfile.py @@ -1,21 +1,34 @@ -from conans import ConanFile, Meson, tools -from conans.errors import ConanInvalidConfiguration -import os -import shutil - +from conan import ConanFile +from conan.tools.meson import MesonToolchain, Meson +from conan.tools.gnu import PkgConfigDeps +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import ( + apply_conandata_patches, + copy, + export_conandata_patches, + get, + rename, + replace_in_file, + rm, + rmdir +) +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration -required_conan_version = ">=1.29.1" +import os +required_conan_version = ">=1.53.0" -class LibnameConan(ConanFile): +class GdkPixbufConan(ConanFile): name = "gdk-pixbuf" description = "toolkit for image loading and pixel buffer manipulation" - topics = ("conan", "gdk-pixbuf", "image") + topics = ("gdk-pixbuf", "image") url = "https://github.com/conan-io/conan-center-index" homepage = "https://developer.gnome.org/gdk-pixbuf/" license = "LGPL-2.1-or-later" - generators = "pkg_config" settings = "os", "arch", "compiler", "build_type" options = { @@ -24,100 +37,190 @@ class LibnameConan(ConanFile): "with_libpng": [True, False], "with_libtiff": [True, False], "with_libjpeg": ["libjpeg", "libjpeg-turbo", False], - "with_jasper": [True, False], - } + "with_introspection": [True, False], + } default_options = { "shared": False, "fPIC": True, "with_libpng": True, "with_libtiff": True, "with_libjpeg": "libjpeg", - "with_jasper": False, - } - - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + "with_introspection": False, + } + short_paths = True def config_options(self): - if self.settings.os == 'Windows': - del self.options.fPIC + if self.settings.os == "Windows": + self.options.rm_safe("fPIC") def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.settings.os == "Macos": + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + if self.options.shared: + self.options["glib"].shared = True + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if self.info.options.shared and not self.dependencies["glib"].options.shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) + if self.info.settings.os == "Macos": # when running gdk-pixbuf-query-loaders # dyld: malformed mach-o: load commands size (97560) > 32768 - raise ConanInvalidConfiguration('This package does not support Macos currently') - - def build_requirements(self): - self.build_requires('meson/0.57.1') - self.build_requires('pkgconf/1.7.3') - + raise ConanInvalidConfiguration("This package does not support Macos currently") + if self.dependencies["glib"].options.shared and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) + + @property + def _requires_compiler_rt(self): + return self.settings.compiler == "clang" and Version(self.settings.compiler.version) <= "12" and self.settings.build_type == "Debug" + + def generate(self): + def is_enabled(value): + return "enabled" if value else "disabled" + + def is_true(value): + return "true" if value else "false" + + deps = PkgConfigDeps(self) + deps.generate() + + tc = MesonToolchain(self) + tc.project_options.update({ + "builtin_loaders": "all", + "gio_sniffing": "false", + "introspection": is_enabled(self.options.with_introspection), + "docs": "false", + "man": "false", + "installed_tests": "false" + }) + if Version(self.version) < "2.42.0": + tc.project_options["gir"] = "false" + + if Version(self.version) >= "2.42.8": + tc.project_options.update({ + "png": is_enabled(self.options.with_libpng), + "tiff": is_enabled(self.options.with_libtiff), + "jpeg": is_enabled(self.options.with_libjpeg) + }) + else: + tc.project_options.update({ + "png": is_true(self.options.with_libpng), + "tiff": is_true(self.options.with_libtiff), + "jpeg": is_true(self.options.with_libjpeg) + }) + + # Workaround for https://bugs.llvm.org/show_bug.cgi?id=16404 + # Only really for the purposes of building on CCI - end users can + # workaround this by appropriately setting global linker flags in their profile + if self._requires_compiler_rt: + tc.c_link_args.append("-rtlib=compiler-rt") + tc.generate() + + venv = VirtualBuildEnv(self) + venv.generate() + def requirements(self): - self.requires('glib/2.68.0') + self.requires("glib/2.75.0") if self.options.with_libpng: - self.requires('libpng/1.6.37') + self.requires("libpng/1.6.39") if self.options.with_libtiff: - self.requires('libtiff/4.2.0') + self.requires("libtiff/4.4.0") if self.options.with_libjpeg == "libjpeg-turbo": - self.requires("libjpeg-turbo/2.0.6") + self.requires("libjpeg-turbo/2.1.4") elif self.options.with_libjpeg == "libjpeg": - self.requires("libjpeg/9d") - if self.options.with_jasper: - self.requires('jasper/2.0.27') + self.requires("libjpeg/9e") + + def build_requirements(self): + self.tool_requires("meson/0.64.1") + self.tool_requires("pkgconf/1.9.3") + if self.options.with_introspection: + self.tool_requires("gobject-introspection/1.72.0") + + def export_sources(self): + export_conandata_patches(self) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - tools.replace_in_file(os.path.join(self._source_subfolder, 'meson.build'), "subdir('tests')", "#subdir('tests')") - tools.replace_in_file(os.path.join(self._source_subfolder, 'meson.build'), "subdir('thumbnailer')", "#subdir('thumbnailer')") - tools.replace_in_file(os.path.join(self._source_subfolder, "meson.build"), "gmodule_dep.get_pkgconfig_variable('gmodule_supported')", "'true'") - - def _configure_meson(self): - meson = Meson(self) - defs = {} - defs['gir'] = 'false' - defs['docs'] = 'false' - defs['man'] = 'false' - defs['installed_tests'] = 'false' - defs['png'] = 'true' if self.options.with_libpng else 'false' - defs['tiff'] = 'true' if self.options.with_libtiff else 'false' - defs['jpeg'] = 'true' if self.options.with_libjpeg else 'false' - defs['jasper'] = 'true' if self.options.with_jasper else 'false' - defs['x11'] = 'false' - defs['builtin_loaders'] = 'all' - defs['gio_sniffing'] = 'false' - args=[] - args.append('--wrap-mode=nofallback') - meson.configure(defs=defs, build_folder=self._build_subfolder, source_folder=self._source_subfolder, pkg_config_paths='.', args=args) - return meson + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def _patch_sources(self): + apply_conandata_patches(self) + + meson_build = os.path.join(self.source_folder, "meson.build") + replace_in_file(self, meson_build, "subdir('tests')", "#subdir('tests')") + replace_in_file(self, meson_build, "subdir('thumbnailer')", "#subdir('thumbnailer')") + replace_in_file(self, meson_build, + "gmodule_dep.get_variable(pkgconfig: 'gmodule_supported')" if Version(self.version) >= "2.42.6" + else "gmodule_dep.get_pkgconfig_variable('gmodule_supported')", "'true'") + # workaround https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/203 + if Version(self.version) >= "2.42.6": + replace_in_file(self, os.path.join(self.source_folder, "build-aux", "post-install.py"), + "close_fds=True", "close_fds=(sys.platform != 'win32')") + if Version(self.version) >= "2.42.9": + replace_in_file(self, meson_build, "is_msvc_like ? 'png' : 'libpng'", "'libpng'") + replace_in_file(self, meson_build, "is_msvc_like ? 'jpeg' : 'libjpeg'", "'libjpeg'") + replace_in_file(self, meson_build, "is_msvc_like ? 'tiff' : 'libtiff-4'", "'libtiff-4'") def build(self): - shutil.move('libpng.pc', 'libpng16.pc') - meson = self._configure_meson() + self._patch_sources() + meson = Meson(self) + meson.configure() meson.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - with tools.environment_append({'LD_LIBRARY_PATH': os.path.join(self.package_folder, 'lib')}): - meson = self._configure_meson() - meson.install() - if self.settings.compiler == "Visual Studio" and not self.options.shared: - os.rename(os.path.join(self.package_folder, 'lib', 'libgdk_pixbuf-2.0.a'), os.path.join(self.package_folder, 'lib', 'gdk_pixbuf-2.0.lib')) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.remove_files_by_mask(self.package_folder, "*.pdb") + meson = Meson(self) + meson.install() + + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + if is_msvc(self) and not self.options.shared: + rename(self, os.path.join(self.package_folder, "lib", "libgdk_pixbuf-2.0.a"), os.path.join(self.package_folder, "lib", "gdk_pixbuf-2.0.lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.pdb", self.package_folder, recursive=True) + + def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - self.cpp_info.includedirs = ['include/gdk-pixbuf-2.0'] - self.cpp_info.names['pkg_config'] = 'gdk-pixbuf-2.0' + self.cpp_info.set_property("pkg_config_name", "gdk-pixbuf-2.0") + self.cpp_info.libs = ["gdk_pixbuf-2.0"] + self.cpp_info.includedirs = [os.path.join("include", "gdk-pixbuf-2.0")] if not self.options.shared: - self.cpp_info.defines.append('GDK_PIXBUF_STATIC_COMPILATION') - if self.settings.os == 'Linux': - self.cpp_info.system_libs = ['m'] - self.env_info.GDK_PIXBUF_PIXDATA = os.path.join(self.package_folder, 'bin', 'gdk-pixbuf-pixdata') + self.cpp_info.defines.append("GDK_PIXBUF_STATIC_COMPILATION") + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["m"] + if self._requires_compiler_rt: + ldflags = ["-rtlib=compiler-rt"] + self.cpp_info.exelinkflags = ldflags + self.cpp_info.sharedlinkflags = ldflags + + pkgconfig_variables = { + "bindir": "${prefix}/bin", + "gdk_pixbuf_binary_version": "2.10.0", + "gdk_pixbuf_binarydir": "${libdir1}/gdk-pixbuf-2.0/2.10", + "gdk_pixbuf_moduledir": "${gdk_pixbuf_binarydir}/loaders", + "gdk_pixbuf_cache_file": "${gdk_pixbuf_binarydir}/loaders.cache", + "gdk_pixbuf_csource": "${bindir}/gdk-pixbuf-csource", + "gdk_pixbuf_pixdata": "${bindir}/gdk-pixbuf-pixdata", + "gdk_pixbuf_query_loaders": "${bindir}/gdk-pixbuf-query-loaders" + } + self.cpp_info.set_property( + "pkg_config_custom_content", + "\n".join(f"{key}={value}" for key, value in pkgconfig_variables.items())) + + gdk_pixbuf_pixdata = os.path.join(self.package_folder, "bin", "gdk-pixbuf-pixdata") + self.runenv_info.define_path("GDK_PIXBUF_PIXDATA", gdk_pixbuf_pixdata) + self.env_info.GDK_PIXBUF_PIXDATA = gdk_pixbuf_pixdata # remove in conan v2? + + # TODO: to remove in conan v2 once pkg_config generator removed + self.cpp_info.names["pkg_config"] = "gdk-pixbuf-2.0" + + def package_id(self): + if not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() diff --git a/recipes/gdk-pixbuf/all/patches/define_dllmain_only_when_shared.patch b/recipes/gdk-pixbuf/all/patches/define_dllmain_only_when_shared.patch new file mode 100644 index 0000000000000..27d2f92f061eb --- /dev/null +++ b/recipes/gdk-pixbuf/all/patches/define_dllmain_only_when_shared.patch @@ -0,0 +1,63 @@ +commit 9521539021d6c8e57fd40d1bf0ff34abf2edbd6b +Author: Hesham Essam +Date: Fri Jun 3 13:29:28 2022 +0200 + + Enable static builds on Windows + +diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c +index 182781178..e207d8143 100644 +--- a/gdk-pixbuf/gdk-pixbuf-io.c ++++ b/gdk-pixbuf/gdk-pixbuf-io.c +@@ -182,6 +182,8 @@ get_file_formats (void) + return file_formats; + } + ++#ifdef GDK_PIXBUF_RELOCATABLE // implies that gdk-pixbuf is built as a dll on windows ++ + #ifdef G_OS_WIN32 + + /* DllMain function needed to tuck away the gdk-pixbuf DLL handle */ +@@ -203,9 +205,6 @@ DllMain (HINSTANCE hinstDLL, + } + #endif + +- +-#ifdef GDK_PIXBUF_RELOCATABLE +- + gchar * + gdk_pixbuf_get_toplevel (void) + { +diff --git a/gdk-pixbuf/queryloaders.c b/gdk-pixbuf/queryloaders.c +index ddcae7b6f..1d39b442e 100644 +--- a/gdk-pixbuf/queryloaders.c ++++ b/gdk-pixbuf/queryloaders.c +@@ -280,7 +280,7 @@ query_module (GString *contents, const char *dir, const char *file) + g_free (path); + } + +-#ifdef G_OS_WIN32 ++#if defined(G_OS_WIN32) && defined(GDK_PIXBUF_RELOCATABLE) + + static char * + get_libdir (void) +diff --git a/meson.build b/meson.build +index ed82464e4..6b123847f 100644 +--- a/meson.build ++++ b/meson.build +@@ -382,7 +382,7 @@ endif + # Determine whether we enable application bundle relocation support, and we use + # this always on Windows + if host_system == 'windows' +- relocatable = true ++ relocatable = (get_option('default_library') != 'static') + else + relocatable = get_option('relocatable') + endif +@@ -445,6 +445,6 @@ summary('MediaLib', use_medialib, section: 'Build') + summary('Introspection', build_gir, section: 'Build') + summary('Documentation', build_docs, section: 'Build') + summary('Manual pages', get_option('man'), section: 'Build') +-summary('Relocatable', get_option('relocatable'), section: 'Build') ++summary('Relocatable', relocatable, section: 'Build') + summary('Installed tests', get_option('installed_tests'), section: 'Build') + diff --git a/recipes/gdk-pixbuf/all/test_package/CMakeLists.txt b/recipes/gdk-pixbuf/all/test_package/CMakeLists.txt index afa2476357074..f31a35477a32f 100644 --- a/recipes/gdk-pixbuf/all/test_package/CMakeLists.txt +++ b/recipes/gdk-pixbuf/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(gdk-pixbuf REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} gdk-pixbuf::gdk-pixbuf) diff --git a/recipes/gdk-pixbuf/all/test_package/conanfile.py b/recipes/gdk-pixbuf/all/test_package/conanfile.py index 1afb874cf3521..f04bef385c6cc 100644 --- a/recipes/gdk-pixbuf/all/test_package/conanfile.py +++ b/recipes/gdk-pixbuf/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools import build import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,7 +21,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run("gdk-pixbuf-pixdata -v", run_environment=True) - self.run(bin_path, run_environment=True) + if not build.can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + self.run("gdk-pixbuf-pixdata -v", env="conanrun") diff --git a/recipes/gdk-pixbuf/all/test_v1_package/CMakeLists.txt b/recipes/gdk-pixbuf/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..cb19ae21c7964 --- /dev/null +++ b/recipes/gdk-pixbuf/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gdk-pixbuf REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} gdk-pixbuf::gdk-pixbuf) diff --git a/recipes/gdk-pixbuf/all/test_v1_package/conanfile.py b/recipes/gdk-pixbuf/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..42f6f019466b0 --- /dev/null +++ b/recipes/gdk-pixbuf/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run("gdk-pixbuf-pixdata -v", run_environment=True) + self.run(bin_path, run_environment=True) diff --git a/recipes/gdk-pixbuf/config.yml b/recipes/gdk-pixbuf/config.yml index a078aa079106a..5fd1bb955b361 100644 --- a/recipes/gdk-pixbuf/config.yml +++ b/recipes/gdk-pixbuf/config.yml @@ -1,7 +1,9 @@ versions: - "2.42.0": + "2.42.10": folder: all - "2.42.2": + "2.42.9": folder: all - "2.42.4": + "2.42.8": + folder: all + "2.42.6": folder: all diff --git a/recipes/gemmlowp/all/conandata.yml b/recipes/gemmlowp/all/conandata.yml new file mode 100644 index 0000000000000..5f6290c4c906d --- /dev/null +++ b/recipes/gemmlowp/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "cci.20210928": + url: "https://github.com/google/gemmlowp/archive/daf630d3d0c439dbe22229838a5ba1bc5f82908d.zip" + sha256: "7b48199021cfad7d06ea84b975b5ff3c259b8f7c0d3d289e0c99e1708704e6db" +patches: + "cci.20210928": + - patch_file: "patches/build-static-libraries.patch" diff --git a/recipes/gemmlowp/all/conanfile.py b/recipes/gemmlowp/all/conanfile.py new file mode 100644 index 0000000000000..14a41c63d1d09 --- /dev/null +++ b/recipes/gemmlowp/all/conanfile.py @@ -0,0 +1,79 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.microsoft import is_msvc +import os + +required_conan_version = ">=1.51.1" + + +class GemmlowpConan(ConanFile): + name = "gemmlowp" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/google/gemmlowp" + description = "Low-precision matrix multiplication" + topics = ("gemm", "matrix") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "contrib")) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "gemmlowp") + self.cpp_info.set_property("cmake_target_name", "gemmlowp::gemmlowp") + + self.cpp_info.components["eight_bit_int_gemm"].set_property("cmake_target_name", "gemmlowp::eight_bit_int_gemm") + self.cpp_info.components["eight_bit_int_gemm"].includedirs.append(os.path.join("include", "gemmlowp")) + self.cpp_info.components["eight_bit_int_gemm"].libs = ["eight_bit_int_gemm"] + if is_msvc(self): + self.cpp_info.components["eight_bit_int_gemm"].defines = ["NOMINMAX"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["eight_bit_int_gemm"].system_libs.extend(["pthread"]) diff --git a/recipes/gemmlowp/all/patches/build-static-libraries.patch b/recipes/gemmlowp/all/patches/build-static-libraries.patch new file mode 100644 index 0000000000000..67de837875aee --- /dev/null +++ b/recipes/gemmlowp/all/patches/build-static-libraries.patch @@ -0,0 +1,19 @@ +diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt +index d6833e8..e2932f8 100644 +--- a/contrib/CMakeLists.txt ++++ b/contrib/CMakeLists.txt +@@ -47,12 +47,8 @@ list(APPEND gemmlowp_test_headers ${gemmlowp_headers}) + file(GLOB fixedpoint_private_headers "${gemmlowp_src}/fixedpoint/*.h") + list(APPEND fixedpoint_private_headers "${gemmlowp_src}/internal/common.h") + +-# Eight bit int gemm library +-if(WIN32) +- add_library(eight_bit_int_gemm STATIC ${eight_bit_int_gemm_sources_with_no_headers}) +-else() +- add_library(eight_bit_int_gemm SHARED ${eight_bit_int_gemm_sources_with_no_headers}) +-endif() ++add_library(eight_bit_int_gemm ${eight_bit_int_gemm_sources_with_no_headers}) ++set_target_properties(eight_bit_int_gemm PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + target_link_libraries(eight_bit_int_gemm ${EXTERNAL_LIBRARIES}) + + # INTERFACE target to help header include diff --git a/recipes/gemmlowp/all/test_package/CMakeLists.txt b/recipes/gemmlowp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f1605354570fc --- /dev/null +++ b/recipes/gemmlowp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(gemmlowp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gemmlowp::gemmlowp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/gemmlowp/all/test_package/conanfile.py b/recipes/gemmlowp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/gemmlowp/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gemmlowp/all/test_package/test_package.cpp b/recipes/gemmlowp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..78f4042de621a --- /dev/null +++ b/recipes/gemmlowp/all/test_package/test_package.cpp @@ -0,0 +1,60 @@ +#include +#include +#include + +#include + +template +std::ostream& operator<<(std::ostream& s, + const gemmlowp::MatrixMap& m) { + for (int i = 0; i < m.rows(); i++) { + for (int j = 0; j < m.cols(); j++) { + if (j) { + s << '\t'; + } + s << static_cast(m(i, j)); + } + s << '\n'; + } + return s; +} + +int main() { + const int rows = 2; + const int cols = 3; + const auto kOrder = gemmlowp::MapOrder::RowMajor; + + std::array lhs{ + 1, 2, 3, + 4, 5, 6 + }; + + std::array rhs{ + 7, 8, + 9, 10, + 11, 12 + }; + + std::array result{}; + + const gemmlowp::MatrixMap lhs_map(lhs.data(), rows, cols); + const gemmlowp::MatrixMap rhs_map(rhs.data(), cols, rows); + std::cout << "LHS:\n " << lhs_map << "\n"; + std::cout << "RHS:\n " << rhs_map << "\n\n"; + gemmlowp::MatrixMap result_map(result.data(), rows, rows); + + gemmlowp::GemmContext gemm_context{}; + gemmlowp::Gemm( + &gemm_context, + lhs_map, + rhs_map, + &result_map, + 0, + 0, + 0, + 1, + 0); + + std::cout << "Result LHSxRHS: \n" << result_map << std::endl; + return 0; +} diff --git a/recipes/gemmlowp/all/test_v1_package/CMakeLists.txt b/recipes/gemmlowp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d3568415c41be --- /dev/null +++ b/recipes/gemmlowp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gemmlowp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gemmlowp::gemmlowp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/gemmlowp/all/test_v1_package/conanfile.py b/recipes/gemmlowp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/gemmlowp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gemmlowp/config.yml b/recipes/gemmlowp/config.yml new file mode 100644 index 0000000000000..5c798b981f84b --- /dev/null +++ b/recipes/gemmlowp/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210928": + folder: "all" diff --git a/recipes/genie/all/conandata.yml b/recipes/genie/all/conandata.yml index 4b325facfd7e7..1b0883fe01d12 100644 --- a/recipes/genie/all/conandata.yml +++ b/recipes/genie/all/conandata.yml @@ -2,3 +2,12 @@ sources: "1141": url: "https://github.com/bkaradzic/GENie/archive/44918162588e56512ddac6264b08ca6ba4e67468.zip" sha256: "cadbdccf6c0931f10f1a17eae06f5776c5eb81db47e581a898158e882f354b3f" + "1157": + url: "https://github.com/bkaradzic/GENie/archive/5fecb127855ee069df345f20d17fea78220fee93.zip" + sha256: "88efc5d16665cbda9885d86b1665388e3307f0426df3da46c4598350caa893d9" + "1160": + url: "https://github.com/bkaradzic/GENie/archive/f9bd455a8439dbcb807816c0be9e4aedf5991bc3.zip" + sha256: "6fe7e2f0107c965ebe9d099b0168128dfcaee67d7368d4b15b42d80808e3d373" + "1170": + url: "https://github.com/bkaradzic/GENie/archive/22cc907a4351db46c55f73e6aa901f1b2f0c52ad.zip" + sha256: "C7691E50F8FB6F2346D0D3CEED14A26F9DE7AEE658CE30B61770F8BE87C1FE00" diff --git a/recipes/genie/all/conanfile.py b/recipes/genie/all/conanfile.py index ceebeaf5b5ed4..d29587bee35bc 100644 --- a/recipes/genie/all/conanfile.py +++ b/recipes/genie/all/conanfile.py @@ -1,6 +1,15 @@ -import os, glob -from conans import AutoToolsBuildEnvironment, ConanFile, tools - +from conan import ConanFile +from conan.tools.files import get, replace_in_file, copy +from conan.tools.build import cross_building +from conan.tools.layout import basic_layout +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.microsoft import VCVars, is_msvc +from conan.tools.gnu import AutotoolsToolchain, Autotools +from conan.tools.apple import is_apple_os +import os + +required_conan_version = ">=1.51.3" class GenieConan(ConanFile): name = "genie" @@ -8,32 +17,38 @@ class GenieConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/bkaradzic/GENie" description = "Project generator tool" - topics = ("conan", "genie", "project", "generator", "build") + topics = ("genie", "project", "generator", "build", "build-systems") settings = "os", "arch", "compiler", "build_type" @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + # TODO: Remove for Conan v2 + return getattr(self, "settings_build", self.settings) - def build_requirements(self): - if self.settings.compiler == "Visual Studio": - self.build_requires("cccl/1.1") + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + del self.info.settings.compiler - if self.settings.os == "Windows" and tools.os_info.is_windows: - if "make" not in os.environ.get("CONAN_MAKE_PROGRAM", ""): - self.build_requires("make/4.2.1") + def validate(self): + if hasattr(self, "settings_build") and cross_building(self): + raise ConanInvalidConfiguration("Cross building is not yet supported. Contributions are welcome") - if "CONAN_BASH_PATH" not in os.environ and tools.os_info.detect_windows_subsystem() != 'msys2': - self.build_requires("msys2/20200517") + def build_requirements(self): + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): + self.tool_requires("msys2/cci.latest") + if is_msvc(self): + self.tool_requires("cccl/1.3") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("GENie-*")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) @property def _os(self): - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): return "darwin" return { "Windows": "windows", @@ -42,23 +57,31 @@ def _os(self): }[str(self.settings.os)] def _patch_compiler(self, cc, cxx): - tools.replace_in_file(os.path.join(self._source_subfolder, "build", "gmake.{}".format(self._os), "genie.make"), "CC = gcc", "CC = {}".format(cc)) - tools.replace_in_file(os.path.join(self._source_subfolder, "build", "gmake.{}".format(self._os), "genie.make"), "CXX = g++", "CXX = {}".format(cxx)) + replace_in_file(self, os.path.join(self.source_folder, "build", f"gmake.{self._os}", "genie.make"), "CC = gcc", f"CC = {cc}") + replace_in_file(self, os.path.join(self.source_folder, "build", f"gmake.{self._os}", "genie.make"), "CXX = g++", f"CXX = {cxx}") @property def _genie_config(self): return "debug" if self.settings.build_type == "Debug" else "release" + def generate(self): + vbe = VirtualBuildEnv(self) + vbe.generate() + if is_msvc(self): + ms = VCVars(self) + ms.generate() + else: + tc = AutotoolsToolchain(self) + tc.generate() + def build(self): - if self.settings.compiler == "Visual Studio": + if is_msvc(self): self._patch_compiler("cccl", "cccl") - with tools.vcvars(self.settings): - with tools.chdir(self._source_subfolder): - self.run("make", win_bash=tools.os_info.is_windows) + self.run("make", cwd=self.source_folder) else: - cc = tools.get_env("CC") - cxx = tools.get_env("CXX") - if tools.is_apple_os(self.settings.os): + cc = os.environ.get("CC") + cxx = os.environ.get("CXX") + if is_apple_os(self): if not cc: cc = "clang" if not cxx: @@ -70,26 +93,26 @@ def build(self): cxx = "clang++" if self.settings.compiler == "clang" else "g++" self._patch_compiler(cc, cxx) - autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - with tools.chdir(self._source_subfolder): - autotools.make(args=["OS={}".format(self._os), "config={}".format(self._genie_config)]) + autotools = Autotools(self) + autotools.make(args=[f"-C {self.source_folder}", f"OS={self._os}", f"config={self._genie_config}"]) def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + copy(self, pattern="LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) bin_ext = ".exe" if self.settings.os == "Windows" else "" - self.copy("genie{}".format(bin_ext), dst="bin", src=os.path.join(self._source_subfolder, "bin", self._os)) + copy(self, pattern=f"genie{bin_ext}", src=os.path.join(self.source_folder, "bin", self._os), dst=os.path.join(self.package_folder, "bin")) if self.settings.build_type == "Debug": - self.copy("*.lua", dst="res", src=os.path.join(self._source_subfolder, "src")) - - def package_id(self): - del self.info.settings.compiler + copy(self, pattern="*.lua", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder,"res")) def package_info(self): + self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] + + #TODO remove for conan v2 bindir = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.output.info(f"Appending PATH environment variable: {bindir}") self.env_info.PATH.append(bindir) if self.settings.build_type == "Debug": resdir = os.path.join(self.package_folder, "res") - self.output.info("Appending PREMAKE_PATH environment variable: {}".format(resdir)) + self.output.info(f"Appending PREMAKE_PATH environment variable: {resdir}") self.env_info.PREMAKE_PATH.append(resdir) diff --git a/recipes/genie/all/test_package/conanfile.py b/recipes/genie/all/test_package/conanfile.py index c42e447e51741..aeafeb9ac53d2 100644 --- a/recipes/genie/all/test_package/conanfile.py +++ b/recipes/genie/all/test_package/conanfile.py @@ -1,10 +1,16 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import can_run +required_conan_version = ">=1.49.0" class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "VirtualBuildEnv" + test_type = "explicit" - settings = "os", "arch" + def build_requirements(self): + self.tool_requires(self.tested_reference_str) def test(self): - if not tools.cross_building(self.settings): - self.run('genie ninja --scripts="{}"'.format(self.source_folder), run_environment=True) + if can_run(self): + self.run("genie ninja") diff --git a/recipes/genie/all/test_v1_package/conanfile.py b/recipes/genie/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..00bbdee2789b3 --- /dev/null +++ b/recipes/genie/all/test_v1_package/conanfile.py @@ -0,0 +1,11 @@ +from conans import ConanFile, tools +import os + + +class TestPackageConan(ConanFile): + + settings = "os", "arch", "compiler", "build_type" + + def test(self): + if not tools.cross_building(self): + self.run("genie ninja", run_environment=True, cwd=os.path.join(self.source_folder, "..", "test_package")) diff --git a/recipes/genie/config.yml b/recipes/genie/config.yml index b24b09b97cd2a..f8c262eda3d07 100644 --- a/recipes/genie/config.yml +++ b/recipes/genie/config.yml @@ -1,3 +1,9 @@ versions: "1141": folder: "all" + "1157": + folder: "all" + "1160": + folder: "all" + "1170": + folder: "all" diff --git a/recipes/geographiclib/all/conandata.yml b/recipes/geographiclib/all/conandata.yml index 13c1e395dbf37..c7a7d43bcf927 100644 --- a/recipes/geographiclib/all/conandata.yml +++ b/recipes/geographiclib/all/conandata.yml @@ -1,7 +1,27 @@ sources: + "1.52": + url: "https://sourceforge.net/projects/geographiclib/files/distrib/GeographicLib-1.52.tar.gz" + sha256: "5d4145cd16ebf51a2ff97c9244330a340787d131165cfd150e4b2840c0e8ac2b" + "1.51": + url: "https://sourceforge.net/projects/geographiclib/files/distrib/GeographicLib-1.51.tar.gz" + sha256: "34370949617df5105bd6961e0b91581aef758dc455fe8629eb5858516022d310" "1.50.1": url: "https://sourceforge.net/projects/geographiclib/files/distrib/GeographicLib-1.50.1.tar.gz" sha256: "d1765009e068b8cc5e76957e5d6be45ce6cff08c4aad8e5995e84a28354385f1" +patches: + "1.52": + - patch_file: "patches/0002-cmake-minimum-required-1.52.patch" + patch_description: "Add cmake_minimum_required() to top CMakeLists" + patch_type: "backport" + patch_source: "https://github.com/geographiclib/geographiclib/commit/d9ca6c6ec0b721326b9a690eee259eac643b927f" "1.51": - url: "https://sourceforge.net/projects/geographiclib/files/distrib/GeographicLib-1.51.tar.gz" - sha256: "34370949617df5105bd6961e0b91581aef758dc455fe8629eb5858516022d310" + - patch_file: "patches/0002-cmake-minimum-required-1.51.patch" + patch_description: "Add cmake_minimum_required() to top CMakeLists" + patch_type: "backport" + patch_source: "https://github.com/geographiclib/geographiclib/commit/d9ca6c6ec0b721326b9a690eee259eac643b927f" + "1.50.1": + - patch_file: "patches/0001-streamoff.patch" + - patch_file: "patches/0002-cmake-minimum-required-1.50.1.patch" + patch_description: "Add cmake_minimum_required() to top CMakeLists" + patch_type: "backport" + patch_source: "https://github.com/geographiclib/geographiclib/commit/d9ca6c6ec0b721326b9a690eee259eac643b927f" diff --git a/recipes/geographiclib/all/conanfile.py b/recipes/geographiclib/all/conanfile.py index 31c115976c737..39ad5c7f95f2a 100644 --- a/recipes/geographiclib/all/conanfile.py +++ b/recipes/geographiclib/all/conanfile.py @@ -1,14 +1,18 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get, replace_in_file, rm, rmdir +from conan.tools.scm import Version import os -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.50.0" class GeographiclibConan(ConanFile): name = "geographiclib" description = "Convert geographic units and solve geodesic problems" - topics = ("conan", "geographiclib", "geodesic") + topics = ("geographiclib", "geodesic") url = "https://github.com/conan-io/conan-center-index" homepage = "https://geographiclib.sourceforge.io" license = "MIT" @@ -18,48 +22,41 @@ class GeographiclibConan(ConanFile): "shared": [True, False], "fPIC": [True, False], "precision": ["float", "double", "extended", "quadruple", "variable"], - "tools": [True, False] + "tools": [True, False], } default_options = { "shared": False, "fPIC": True, "precision": "double", - "tools": True + "tools": True, } - exports_sources = ["CMakeLists.txt"] - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + @property - def _min_compiler_version_default_cxx11(self): + def _compilers_minimum_version(self): # Minimum compiler version having C++11 math functions return { "apple-clang": "3.3", "gcc": "4.9", "clang": "6", - "Visual Studio": "14", # guess - }.get(str(self.settings.compiler), False) + "Visual Studio": "14", # guess + } - def configure(self): - if self.options.shared: - del self.options.fPIC - - if tools.Version(self.version) >= "1.51": - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + def validate(self): + if Version(self.version) >= "1.51": + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) def lazy_lt_semver(v1, v2): lv1 = [int(v) for v in v1.split(".")] @@ -67,41 +64,21 @@ def lazy_lt_semver(v1, v2): min_length = min(len(lv1), len(lv2)) return lv1[:min_length] < lv2[:min_length] - minimum_version = self._min_compiler_version_default_cxx11 - if not minimum_version: - self.output.warn("geographiclib {} requires C++11 math functions. Your compiler is unknown. Assuming it supports this feature.".format(self.version)) - elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and lazy_lt_semver(str(self.info.settings.compiler.version), minimum_version): raise ConanInvalidConfiguration("geographiclib {} requires C++11 math functions, which your compiler does not support.".format(self.version)) - if self.options.precision not in ["float", "double"]: + if self.info.options.precision not in ["float", "double"]: # FIXME: add support for extended, quadruple and variable precisions # (may require external libs: boost multiprecision for quadruple, mpfr for variable) raise ConanInvalidConfiguration("extended, quadruple and variable precisions not yet supported in this recipe") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "GeographicLib-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _patch_sources(self): - cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") - # it does not work on Windows but is not needed - tools.replace_in_file(cmakelists, "add_subdirectory (js)", "") - # Don't install system libs - tools.replace_in_file(cmakelists, "include (InstallRequiredSystemLibraries)", "") - # Don't build tools if asked - if not self.options.tools: - tools.replace_in_file(cmakelists, "add_subdirectory (tools)", "") - tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "CMakeLists.txt"), - "${TOOLS}", "") + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["GEOGRAPHICLIB_LIB_TYPE"] = "SHARED" if self.options.shared else "STATIC" - self._cmake.definitions["GEOGRAPHICLIB_PRECISION"] = self._cmake_option_precision - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) @property def _cmake_option_precision(self): @@ -113,29 +90,58 @@ def _cmake_option_precision(self): "variable": 5, }.get(str(self.options.precision)) + def generate(self): + tc = CMakeToolchain(self) + tc.variables["GEOGRAPHICLIB_LIB_TYPE"] = "SHARED" if self.options.shared else "STATIC" + tc.variables["GEOGRAPHICLIB_PRECISION"] = self._cmake_option_precision + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + # it does not work on Windows but is not needed + replace_in_file(self, cmakelists, "add_subdirectory (js)", "") + # Don't install system libs + replace_in_file(self, cmakelists, "include (InstallRequiredSystemLibraries)", "") + # Don't build tools if asked + if not self.options.tools: + replace_in_file(self, cmakelists, "add_subdirectory (tools)", "") + replace_in_file(self, os.path.join(self.source_folder, "cmake", "CMakeLists.txt"), + "${TOOLS}", "") + def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - for folder in ["share", os.path.join("lib", "python"), os.path.join("lib", "pkgconfig"), - os.path.join("lib", "cmake"), "sbin", "python", "matlab", "doc", "cmake"]: - tools.rmdir(os.path.join(os.path.join(self.package_folder, folder))) - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + for folder in [ + "share", "sbin", "python", "matlab", "doc", "cmake", + os.path.join("lib", "python"), + os.path.join("lib", "pkgconfig"), + os.path.join("lib", "cmake"), + ]: + rmdir(self, os.path.join(os.path.join(self.package_folder, folder))) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "geographiclib" - self.cpp_info.filenames["cmake_find_package_multi"] = "geographiclib" - self.cpp_info.names["cmake_find_package"] = "GeographicLib" - self.cpp_info.names["cmake_find_package_multi"] = "GeographicLib" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "geographiclib") + self.cpp_info.set_property("cmake_target_name", "GeographicLib::GeographicLib") + self.cpp_info.set_property("pkg_config_name", "geographiclib") + self.cpp_info.libs = collect_libs(self) self.cpp_info.defines.append("GEOGRAPHICLIB_SHARED_LIB={}".format("1" if self.options.shared else "0")) if self.options.tools: bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "geographiclib" + self.cpp_info.filenames["cmake_find_package_multi"] = "geographiclib" + self.cpp_info.names["cmake_find_package"] = "GeographicLib" + self.cpp_info.names["cmake_find_package_multi"] = "GeographicLib" diff --git a/recipes/geographiclib/all/patches/0001-streamoff.patch b/recipes/geographiclib/all/patches/0001-streamoff.patch new file mode 100644 index 0000000000000..203a1711939ec --- /dev/null +++ b/recipes/geographiclib/all/patches/0001-streamoff.patch @@ -0,0 +1,38 @@ +--- a/src/SphericalEngine.cpp ++++ b/src/SphericalEngine.cpp +@@ -134,6 +134,8 @@ + #include + #include + ++#include ++ + #if defined(_MSC_VER) + // Squelch warnings about constant conditional expressions and potentially + // uninitialized local variables +@@ -409,22 +411,22 @@ namespace GeographicLib { + SphericalEngine::coeff::Csize(N0, M )) * sizeof(double); + if (N == N0) { + Utility::readarray(stream, C); +- if (skip) stream.seekg(std::ios::streamoff(skip), ios::cur); ++ if (skip) stream.seekg(streamoff(skip), ios::cur); + Utility::readarray(stream, S); +- if (skip) stream.seekg(std::ios::streamoff(skip), ios::cur); ++ if (skip) stream.seekg(streamoff(skip), ios::cur); + } else { + for (int m = 0, k = 0; m <= M; ++m) { + Utility::readarray(stream, &C[k], N + 1 - m); + stream.seekg((N0 - N) * sizeof(double), ios::cur); + k += N + 1 - m; + } +- if (skip) stream.seekg(std::ios::streamoff(skip), ios::cur); ++ if (skip) stream.seekg(streamoff(skip), ios::cur); + for (int m = 1, k = 0; m <= M; ++m) { + Utility::readarray(stream, &S[k], N + 1 - m); + stream.seekg((N0 - N) * sizeof(double), ios::cur); + k += N + 1 - m; + } +- if (skip) stream.seekg(std::ios::streamoff(skip), ios::cur); ++ if (skip) stream.seekg(streamoff(skip), ios::cur); + } + return; + } diff --git a/recipes/geographiclib/all/patches/0002-cmake-minimum-required-1.50.1.patch b/recipes/geographiclib/all/patches/0002-cmake-minimum-required-1.50.1.patch new file mode 100644 index 0000000000000..b288ab87c7f7a --- /dev/null +++ b/recipes/geographiclib/all/patches/0002-cmake-minimum-required-1.50.1.patch @@ -0,0 +1,15 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,3 +1,4 @@ ++cmake_minimum_required (VERSION 3.13.0) + project (GeographicLib) + + # Version information +@@ -47,7 +48,6 @@ set (LIBVERSION_BUILD 19.0.1) + string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) + string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER) + +-cmake_minimum_required (VERSION 3.1.0) # This version was released 2014-12-15 + + # User-settable variables + diff --git a/recipes/geographiclib/all/patches/0002-cmake-minimum-required-1.51.patch b/recipes/geographiclib/all/patches/0002-cmake-minimum-required-1.51.patch new file mode 100644 index 0000000000000..1919e3213be84 --- /dev/null +++ b/recipes/geographiclib/all/patches/0002-cmake-minimum-required-1.51.patch @@ -0,0 +1,15 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,3 +1,4 @@ ++cmake_minimum_required (VERSION 3.13.0) + project (GeographicLib) + + # Version information +@@ -47,7 +48,6 @@ set (LIBVERSION_BUILD 19.1.0) + string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) + string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER) + +-cmake_minimum_required (VERSION 3.7.0) # This version was released 2016-11-11 + + # User-settable variables + diff --git a/recipes/geographiclib/all/patches/0002-cmake-minimum-required-1.52.patch b/recipes/geographiclib/all/patches/0002-cmake-minimum-required-1.52.patch new file mode 100644 index 0000000000000..7f25113816c11 --- /dev/null +++ b/recipes/geographiclib/all/patches/0002-cmake-minimum-required-1.52.patch @@ -0,0 +1,15 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,3 +1,4 @@ ++cmake_minimum_required (VERSION 3.13.0) + project (GeographicLib) + + # Version information +@@ -47,7 +48,6 @@ set (LIBVERSION_BUILD 19.2.0) + string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) + string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER) + +-cmake_minimum_required (VERSION 3.7.0) # This version was released 2016-11-11 + + # User-settable variables + diff --git a/recipes/geographiclib/all/test_package/CMakeLists.txt b/recipes/geographiclib/all/test_package/CMakeLists.txt index 8072fb794b8d8..91e2ed38f5138 100644 --- a/recipes/geographiclib/all/test_package/CMakeLists.txt +++ b/recipes/geographiclib/all/test_package/CMakeLists.txt @@ -1,14 +1,11 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(geographiclib CONFIG REQUIRED) +find_package(geographiclib REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} GeographicLib::GeographicLib) +target_link_libraries(${PROJECT_NAME} PRIVATE GeographicLib::GeographicLib) if(geographiclib_VERSION VERSION_GREATER_EQUAL "1.51") - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) endif() diff --git a/recipes/geographiclib/all/test_package/conanfile.py b/recipes/geographiclib/all/test_package/conanfile.py index 910ae60d10438..3a8c6c5442b33 100644 --- a/recipes/geographiclib/all/test_package/conanfile.py +++ b/recipes/geographiclib/all/test_package/conanfile.py @@ -1,9 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/geographiclib/all/test_v1_package/CMakeLists.txt b/recipes/geographiclib/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9164dbad5458a --- /dev/null +++ b/recipes/geographiclib/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(geographiclib REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE GeographicLib::GeographicLib) + +if(geographiclib_VERSION VERSION_GREATER_EQUAL "1.51") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +endif() diff --git a/recipes/geographiclib/all/test_v1_package/conanfile.py b/recipes/geographiclib/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/geographiclib/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/geographiclib/config.yml b/recipes/geographiclib/config.yml index 65cd32bf8e28d..6c3b63fe79e7e 100644 --- a/recipes/geographiclib/config.yml +++ b/recipes/geographiclib/config.yml @@ -1,5 +1,7 @@ versions: - "1.50.1": + "1.52": folder: all "1.51": folder: all + "1.50.1": + folder: all diff --git a/recipes/geos/all/CMakeLists.txt b/recipes/geos/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/geos/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/geos/all/conandata.yml b/recipes/geos/all/conandata.yml index 19fff07a6224e..df46a03c432bc 100644 --- a/recipes/geos/all/conandata.yml +++ b/recipes/geos/all/conandata.yml @@ -1,26 +1,13 @@ sources: - "3.9.1": - url: "https://git.osgeo.org/gitea/geos/geos/archive/3.9.1.tar.gz" - sha256: "f1103d9efd2d563be93c85cc7342414f39610d3e97070ae119fcfc73a668141f" - "3.9.0": - url: "https://git.osgeo.org/gitea/geos/geos/archive/3.9.0.tar.gz" - sha256: "fd962c548d2aef6772bd1778d9bbf6a3ac362f78b14f042649722e8c7ae720c3" - "3.8.1": - url: "https://git.osgeo.org/gitea/geos/geos/archive/3.8.1.tar.gz" - sha256: "6753ea1d21d6711e7f653f9a327e6bbd803eb8f090a4b98c5a3d1012c2822206" - "3.8.0": - url: "https://git.osgeo.org/gitea/geos/geos/archive/3.8.0.tar.gz" - sha256: "90e2ea9db689f5ca8c0bd61e671ac47c749e85998a867b777c3ded8a6399a695" -patches: - "3.9.1": - - patch_file: "patches/fix-cmake-3.9.1.patch" - base_path: "source_subfolder" - "3.9.0": - - patch_file: "patches/fix-cmake-3.9.0.patch" - base_path: "source_subfolder" - "3.8.1": - - patch_file: "patches/fix-cmake-3.8.1.patch" - base_path: "source_subfolder" - "3.8.0": - - patch_file: "patches/fix-cmake-3.8.0.patch" - base_path: "source_subfolder" + "3.11.1": + url: "https://github.com/libgeos/geos/releases/download/3.11.1/geos-3.11.1.tar.bz2" + sha256: "be83ed195ffb82373710c90befc580911ea0eb57003a2d703e30101c5b262f62" + "3.11.0": + url: "https://github.com/libgeos/geos/releases/download/3.11.0/geos-3.11.0.tar.bz2" + sha256: "79ab8cabf4aa8604d161557b52e3e4d84575acdc0d08cb09ab3f7aaefa4d858a" + "3.10.3": + url: "https://github.com/libgeos/geos/archive/refs/tags/3.10.3.tar.gz" + sha256: "5af5a7ba0cc1225e7301fdcd7818521d65eb77e2f06647168e1969276d800cc1" + "3.10.2": + url: "https://github.com/libgeos/geos/archive/refs/tags/3.10.2.tar.gz" + sha256: "d71932b444c9bd5d0bdf9eab4d22f25d9c31c122a73d619e2ec15294fb32147d" diff --git a/recipes/geos/all/conanfile.py b/recipes/geos/all/conanfile.py index a1919660cd641..48dc382e82ae4 100644 --- a/recipes/geos/all/conanfile.py +++ b/recipes/geos/all/conanfile.py @@ -1,97 +1,124 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.scm import Version +from conans import tools as tools_legacy import os -from conans import ConanFile, CMake, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.53.0" + class GeosConan(ConanFile): name = "geos" description = "C++11 library for performing operations on two-dimensional vector geometries" license = "LGPL-2.1" - topics = ("conan", "geos", "osgeo", "geometry", "topology", "geospatial") + topics = ("geos", "osgeo", "geometry", "topology", "geospatial") homepage = "https://trac.osgeo.org/geos" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "inline": [True, False] + "inline": [True, False], + "utils": [True, False], } default_options = { "shared": False, "fPIC": True, - "inline": True + "inline": True, + "utils": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - @property - def _build_subfolder(self): - return "build_subfolder" + def _has_inline_option(self): + return Version(self.version) < "3.11.0" def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if not self._has_inline_option: + del self.options.inline def configure(self): if self.options.shared: - del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + self.options.rm_safe("fPIC") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_BENCHMARKS"] = False + if self._has_inline_option: + tc.variables["DISABLE_GEOS_INLINE"] = not self.options.inline + tc.variables["BUILD_TESTING"] = False + tc.variables["BUILD_DOCUMENTATION"] = False + tc.variables["BUILD_ASTYLE"] = False + tc.variables["BUILD_GEOSOP"] = self.options.utils + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, {}): - tools.patch(**patch) - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - if tools.Version(self.version) >= "3.9.1": - self._cmake.definitions["BUILD_BENCHMARKS"] = False - self._cmake.definitions["DISABLE_GEOS_INLINE"] = not self.options.inline - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy("geos.h", dst="include", src=os.path.join(self._source_subfolder, "include")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + copy(self, "geos.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "geos") + # Avoid to create unwanted geos::geos target + # (geos_c component overrides this global target and it's fine since it depends on all other components) + self.cpp_info.set_property("cmake_target_name", "GEOS::geos_c") + self.cpp_info.set_property("pkg_config_name", "geos") + self.cpp_info.filenames["cmake_find_package"] = "geos" self.cpp_info.filenames["cmake_find_package_multi"] = "geos" self.cpp_info.names["cmake_find_package"] = "GEOS" self.cpp_info.names["cmake_find_package_multi"] = "GEOS" + # GEOS::geos_cxx_flags + self.cpp_info.components["geos_cxx_flags"].set_property("cmake_target_name", "GEOS::geos_cxx_flags") self.cpp_info.components["geos_cxx_flags"].defines.append("USE_UNSTABLE_GEOS_CPP_API") - if self.options.inline: + if self.options.get_safe("inline"): self.cpp_info.components["geos_cxx_flags"].defines.append("GEOS_INLINE") if self.settings.os == "Windows": self.cpp_info.components["geos_cxx_flags"].defines.append("TTMATH_NOASM") + # GEOS::geos + self.cpp_info.components["geos_cpp"].set_property("cmake_target_name", "GEOS::geos") self.cpp_info.components["geos_cpp"].names["cmake_find_package"] = "geos" self.cpp_info.components["geos_cpp"].names["cmake_find_package_multi"] = "geos" self.cpp_info.components["geos_cpp"].libs = ["geos"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["geos_cpp"].system_libs.append("m") - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.components["geos_cpp"].system_libs.append(tools.stdcpp_library(self)) + if not self.options.shared: + stdcpp_library = tools_legacy.stdcpp_library(self) + if stdcpp_library: + self.cpp_info.components["geos_cpp"].system_libs.append(stdcpp_library) self.cpp_info.components["geos_cpp"].requires = ["geos_cxx_flags"] + # GEOS::geos_c + self.cpp_info.components["geos_c"].set_property("cmake_target_name", "GEOS::geos_c") self.cpp_info.components["geos_c"].libs = ["geos_c"] self.cpp_info.components["geos_c"].requires = ["geos_cpp"] + + if self.options.utils: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/geos/all/patches/fix-cmake-3.8.0.patch b/recipes/geos/all/patches/fix-cmake-3.8.0.patch deleted file mode 100644 index 09630cb5bd807..0000000000000 --- a/recipes/geos/all/patches/fix-cmake-3.8.0.patch +++ /dev/null @@ -1,78 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -19,7 +19,6 @@ set(DEFAULT_BUILD_TYPE Release) - # Require CMake 3.13+ with VS generator for complete support of VS versions - # and support by AppVeyor. - if(${CMAKE_GENERATOR} MATCHES "Visual Studio") -- cmake_minimum_required(VERSION 3.13 FATAL_ERROR) - endif() - - list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -@@ -224,7 +223,7 @@ add_subdirectory(src) - - if(BUILD_SHARED_LIBS) - target_compile_definitions(geos -- PRIVATE $<$:GEOS_DLL_EXPORT>) -+ PRIVATE $,GEOS_DLL_EXPORT,DLL_EXPORT>) # fix to not build inline obj if shared and inline with MinGW - - set_target_properties(geos PROPERTIES VERSION ${GEOS_VERSION}) - set_target_properties(geos PROPERTIES SOVERSION ${GEOS_VERSION}) -@@ -238,7 +237,7 @@ target_link_libraries(geos_c PRIVATE geos) - - if(BUILD_SHARED_LIBS) - target_compile_definitions(geos_c -- PRIVATE $<$:GEOS_DLL_EXPORT>) -+ PRIVATE $,GEOS_DLL_EXPORT,DLL_EXPORT>) # fix to not build inline obj if shared and inline with MinGW - - set_target_properties(geos_c PROPERTIES VERSION ${CAPI_VERSION}) - if(NOT WIN32) -@@ -259,12 +258,10 @@ endif() - #----------------------------------------------------------------------------- - # Benchmarks - #----------------------------------------------------------------------------- --add_subdirectory(benchmarks) - - #----------------------------------------------------------------------------- - # Documentation/Examples - #----------------------------------------------------------------------------- --add_subdirectory(doc) - - #----------------------------------------------------------------------------- - # Install and export targets - support 'make install' or equivalent -@@ -281,7 +278,7 @@ configure_file(cmake/geos-config.cmake - - install(TARGETS geos geos_cxx_flags - EXPORT geos-targets -- LIBRARY DESTINATION lib NAMELINK_SKIP -+ LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include -@@ -309,10 +306,16 @@ install(DIRECTORY - "${CMAKE_CURRENT_BINARY_DIR}/include/geos" - DESTINATION include - FILES_MATCHING PATTERN "*.h") -+if(NOT DISABLE_GEOS_INLINE) -+ install(DIRECTORY -+ "${CMAKE_CURRENT_LIST_DIR}/include/geos" -+ "${CMAKE_CURRENT_BINARY_DIR}/include/geos" -+ DESTINATION include -+ FILES_MATCHING PATTERN "*.inl") -+endif() - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/capi/geos_c.h" - DESTINATION include) - --add_subdirectory(tools) - - #----------------------------------------------------------------------------- - # Uninstall -@@ -372,9 +375,6 @@ add_custom_target(check COMMAND ${CMAKE_BUILD_TOOL} test) - # "make distcheck" workalike - #----------------------------------------------------------------------------- - if(NOT _is_multi_config_generator) -- find_package(MakeDistCheck) -- AddMakeDistCheck() -- message(STATUS "GEOS: Configured 'distcheck' target") - endif() - - unset(_is_multi_config_generator) diff --git a/recipes/geos/all/patches/fix-cmake-3.8.1.patch b/recipes/geos/all/patches/fix-cmake-3.8.1.patch deleted file mode 100644 index a8db27aa6b160..0000000000000 --- a/recipes/geos/all/patches/fix-cmake-3.8.1.patch +++ /dev/null @@ -1,68 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -19,7 +19,6 @@ set(DEFAULT_BUILD_TYPE Release) - # Require CMake 3.13+ with VS generator for complete support of VS versions - # and support by AppVeyor. - if(${CMAKE_GENERATOR} MATCHES "Visual Studio") -- cmake_minimum_required(VERSION 3.13 FATAL_ERROR) - endif() - - list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -@@ -224,7 +223,7 @@ add_subdirectory(src) - - if(BUILD_SHARED_LIBS) - target_compile_definitions(geos -- PRIVATE $<$:GEOS_DLL_EXPORT>) -+ PRIVATE $,GEOS_DLL_EXPORT,DLL_EXPORT>) # fix to not build inline obj if shared and inline with MinGW - - set_target_properties(geos PROPERTIES VERSION ${GEOS_VERSION}) - set_target_properties(geos PROPERTIES SOVERSION ${GEOS_VERSION}) -@@ -238,7 +237,7 @@ target_link_libraries(geos_c PRIVATE geos) - - if(BUILD_SHARED_LIBS) - target_compile_definitions(geos_c -- PRIVATE $<$:GEOS_DLL_EXPORT>) -+ PRIVATE $,GEOS_DLL_EXPORT,DLL_EXPORT>) # fix to not build inline obj if shared and inline with MinGW - - set_target_properties(geos_c PROPERTIES VERSION ${CAPI_VERSION}) - if(NOT WIN32) -@@ -259,12 +258,10 @@ endif() - #----------------------------------------------------------------------------- - # Benchmarks - #----------------------------------------------------------------------------- --add_subdirectory(benchmarks) - - #----------------------------------------------------------------------------- - # Documentation/Examples - #----------------------------------------------------------------------------- --add_subdirectory(doc) - - #----------------------------------------------------------------------------- - # Install and export targets - support 'make install' or equivalent -@@ -281,7 +278,7 @@ configure_file(cmake/geos-config.cmake - - install(TARGETS geos geos_cxx_flags - EXPORT geos-targets -- LIBRARY DESTINATION lib NAMELINK_SKIP -+ LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include -@@ -319,7 +316,6 @@ endif() - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/capi/geos_c.h" - DESTINATION include) - --add_subdirectory(tools) - - #----------------------------------------------------------------------------- - # Uninstall -@@ -379,9 +375,6 @@ add_custom_target(check COMMAND ${CMAKE_BUILD_TOOL} test) - # "make distcheck" workalike - #----------------------------------------------------------------------------- - if(NOT _is_multi_config_generator) -- find_package(MakeDistCheck) -- AddMakeDistCheck() -- message(STATUS "GEOS: Configured 'distcheck' target") - endif() - - unset(_is_multi_config_generator) diff --git a/recipes/geos/all/patches/fix-cmake-3.9.0.patch b/recipes/geos/all/patches/fix-cmake-3.9.0.patch deleted file mode 100644 index d279a0a25422a..0000000000000 --- a/recipes/geos/all/patches/fix-cmake-3.9.0.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -19,7 +19,6 @@ set(DEFAULT_BUILD_TYPE Release) - # Require CMake 3.13+ with VS generator for complete support of VS versions - # and support by AppVeyor. - if(${CMAKE_GENERATOR} MATCHES "Visual Studio") -- cmake_minimum_required(VERSION 3.13 FATAL_ERROR) - endif() - - list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -@@ -282,12 +281,10 @@ endif() - #----------------------------------------------------------------------------- - # Benchmarks - #----------------------------------------------------------------------------- --add_subdirectory(benchmarks) - - #----------------------------------------------------------------------------- - # Documentation/Examples - #----------------------------------------------------------------------------- --add_subdirectory(doc) - - #----------------------------------------------------------------------------- - # Install and export targets - support 'make install' or equivalent -@@ -343,7 +340,6 @@ endif() - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/capi/geos_c.h" - DESTINATION include) - --add_subdirectory(tools) - - #----------------------------------------------------------------------------- - # Uninstall -@@ -403,9 +399,6 @@ add_custom_target(check COMMAND ${CMAKE_BUILD_TOOL} test) - # "make distcheck" workalike - #----------------------------------------------------------------------------- - if(NOT _is_multi_config_generator) -- find_package(MakeDistCheck) -- AddMakeDistCheck() -- message(STATUS "GEOS: Configured 'distcheck' target") - endif() - - unset(_is_multi_config_generator) diff --git a/recipes/geos/all/patches/fix-cmake-3.9.1.patch b/recipes/geos/all/patches/fix-cmake-3.9.1.patch deleted file mode 100644 index ab5ca66c7c98f..0000000000000 --- a/recipes/geos/all/patches/fix-cmake-3.9.1.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -19,7 +19,6 @@ set(DEFAULT_BUILD_TYPE Release) - # Require CMake 3.13+ with VS generator for complete support of VS versions - # and support by AppVeyor. - if(${CMAKE_GENERATOR} MATCHES "Visual Studio") -- cmake_minimum_required(VERSION 3.13 FATAL_ERROR) - endif() - - list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -@@ -290,7 +289,6 @@ endif() - #----------------------------------------------------------------------------- - # Documentation/Examples - #----------------------------------------------------------------------------- --add_subdirectory(doc) - - #----------------------------------------------------------------------------- - # Install and export targets - support 'make install' or equivalent -@@ -346,7 +344,6 @@ endif() - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/capi/geos_c.h" - DESTINATION include) - --add_subdirectory(tools) - - #----------------------------------------------------------------------------- - # Uninstall -@@ -405,7 +402,7 @@ add_custom_target(check COMMAND ${CMAKE_BUILD_TOOL} test) - #----------------------------------------------------------------------------- - # "make distcheck" workalike - #----------------------------------------------------------------------------- --if(NOT _is_multi_config_generator) -+if(0) - find_package(MakeDistCheck) - AddMakeDistCheck() - message(STATUS "GEOS: Configured 'distcheck' target") diff --git a/recipes/geos/all/test_package/CMakeLists.txt b/recipes/geos/all/test_package/CMakeLists.txt index 24ad462b3f34d..18b308026f83b 100644 --- a/recipes/geos/all/test_package/CMakeLists.txt +++ b/recipes/geos/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C) find_package(geos CONFIG REQUIRED geos_c) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} GEOS::geos_c) +target_link_libraries(${PROJECT_NAME} PRIVATE GEOS::geos_c) diff --git a/recipes/geos/all/test_package/conanfile.py b/recipes/geos/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/geos/all/test_package/conanfile.py +++ b/recipes/geos/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/geos/all/test_v1_package/CMakeLists.txt b/recipes/geos/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/geos/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/geos/all/test_v1_package/conanfile.py b/recipes/geos/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/geos/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/geos/config.yml b/recipes/geos/config.yml index 6e33af042e3ff..40c19a7a4131d 100644 --- a/recipes/geos/config.yml +++ b/recipes/geos/config.yml @@ -1,9 +1,9 @@ versions: - "3.9.1": + "3.11.1": folder: all - "3.9.0": + "3.11.0": folder: all - "3.8.1": + "3.10.3": folder: all - "3.8.0": + "3.10.2": folder: all diff --git a/recipes/geotrans/all/CMakeLists.txt b/recipes/geotrans/all/CMakeLists.txt new file mode 100644 index 0000000000000..70f2583ebeb4e --- /dev/null +++ b/recipes/geotrans/all/CMakeLists.txt @@ -0,0 +1,76 @@ +cmake_minimum_required(VERSION 3.8) +project(geotrans LANGUAGES CXX) + +#### +# Directories +#### + +set(DTCCDIR "${GEOTRANS_SRC_DIR}/CCS/src/dtcc/CoordinateSystems") +set(CCSERVICEDIR "${GEOTRANS_SRC_DIR}/CCS/src") +set(SRCDIR "${GEOTRANS_SRC_DIR}/GEOTRANS3/java_gui/geotrans3/jni") + +#### +# Sources +#### +file(GLOB_RECURSE DTCCSRCS "${DTCCDIR}/*.cpp") +set(CCSSRCS "${CCSERVICEDIR}/CoordinateConversion/CoordinateConversionService.cpp") +file(GLOB_RECURSE CCSERVICESRCS "${CCSERVICEDIR}/dtcc/*.cpp") +list(FILTER CCSERVICESRCS EXCLUDE REGEX ".*${DTCCDIR}.*") +set(SRCS "${SRCDIR}/strtoval.cpp" "${SRCDIR}/fiomeths.cpp") + +#### +# Includes +#### + +# Construct DTCC includes +file(GLOB_RECURSE DTCC_HEADERS "${DTCCDIR}/*.h") +set(DTTCINCS "") +foreach(file ${DTCC_HEADERS}) + get_filename_component(DIR_PATH ${file} PATH) + set(DTTCINCS ${DTTCINCS} ${DIR_PATH}) +endforeach() +list(REMOVE_DUPLICATES DTTCINCS) + +# Construct CCS includes. This is all headers not in DTTCINCS +file(GLOB_RECURSE CCS_HEADERS "${CCSERVICEDIR}/*.h") +set(INCS ${SRCDIR}) +foreach(file ${CCS_HEADERS}) + get_filename_component(DIR_PATH ${file} PATH) + set(INCS ${INCS} ${DIR_PATH}) +endforeach() +list(REMOVE_DUPLICATES INCS) +list(FILTER INCS EXCLUDE REGEX ".*${DTCCDIR}.*") + +set(PUBLIC_HEADERS ${DTTC_HEADERS} ${CCS_HEADERS}) + +#### +# Dependencies +#### + +find_package(Threads REQUIRED) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +# Create libMSPdtcc +add_library(MSPdtcc ${DTCCSRCS} ${CCSERVICESRCS}) +target_compile_features(MSPdtcc PUBLIC cxx_std_11) +if (WIN32) + add_compile_definitions(MSPdtcc PRIVATE LITTLE_ENDIAN=1) +endif(WIN32) +target_include_directories(MSPdtcc PUBLIC include ${DTTCINCS} ${INCS}) +set_target_properties(MSPdtcc PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") +target_link_libraries(MSPdtcc PRIVATE Threads::Threads) + +# Create libMSPCoordinateConversionService +add_library(MSPCoordinateConversionService ${CCSSRCS} ${CCSERVICESRCS}) +target_compile_features(MSPCoordinateConversionService PUBLIC cxx_std_11) +target_include_directories(MSPCoordinateConversionService PUBLIC include ${DTTCINCS} ${INCS}) +set_target_properties(MSPCoordinateConversionService PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") +target_link_libraries(MSPCoordinateConversionService PUBLIC MSPdtcc) + +include(GNUInstallDirs) +install(TARGETS MSPdtcc MSPCoordinateConversionService + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) +install(DIRECTORY "${GEOTRANS_SRC_DIR}/data/" DESTINATION res) diff --git a/recipes/geotrans/all/conandata.yml b/recipes/geotrans/all/conandata.yml new file mode 100644 index 0000000000000..d74641c250a30 --- /dev/null +++ b/recipes/geotrans/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "3.8": + url: "https://c3i.jfrog.io/artifactory/cci-sources-backup/sources/geotrans/geotrans-3.8.tgz" + sha256: "baa72d3b1ae12f237a8ad30f2deb3fed2b80feb759528ea0a72b4b42cb77c565" +patches: + "3.8": + - patch_file: "patches/3.8-fix-for-cxx20.patch" diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py new file mode 100644 index 0000000000000..45f53bc792fe5 --- /dev/null +++ b/recipes/geotrans/all/conanfile.py @@ -0,0 +1,100 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get +import os + +required_conan_version = ">=1.53.0" + + +class GeotransConan(ConanFile): + name = "geotrans" + license = ( + "NGA GEOTRANS ToS (https://earth-info.nga.mil/php/download.php?file=wgs-terms)" + ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://earth-info.nga.mil/" + description = "MSP GEOTRANS is the NGA and DOD approved coordinate converter and datum translator." + topics = ( + "geotrans", + "geodesic", + "geographic", + "coordinate", + "datum", + "geodetic", + "conversion", + "transformation", + ) + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder) + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["GEOTRANS_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "*.txt", + src=os.path.join(self.source_folder, "GEOTRANS3", "docs"), + dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.components["dtcc"].libs = ["MSPdtcc"] + self.cpp_info.components["dtcc"].includedirs = [ + path[0] for path in os.walk("include") + ] + self.cpp_info.components["dtcc"].res = ["res"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["dtcc"].system_libs.append("pthread") + self.cpp_info.components["dtcc"].system_libs.append("m") + + self.cpp_info.components["ccs"].libs = ["MSPCoordinateConversionService"] + self.cpp_info.components["ccs"].requires = ["dtcc"] + self.cpp_info.components["ccs"].includedirs = [ + path[0] for path in os.walk("include") + ] + self.cpp_info.components["ccs"].res = ["res"] + + mspccs_data_path = os.path.join(self.package_folder, "res") + self.runenv_info.define_path("MSPCCS_DATA", mspccs_data_path) + # TODO: to remove after conan v2, it allows to not break consumers still relying on virtualenv generator + self.env_info.MSPCCS_DATA = mspccs_data_path diff --git a/recipes/geotrans/all/patches/3.8-fix-for-cxx20.patch b/recipes/geotrans/all/patches/3.8-fix-for-cxx20.patch new file mode 100644 index 0000000000000..c26083bb3f299 --- /dev/null +++ b/recipes/geotrans/all/patches/3.8-fix-for-cxx20.patch @@ -0,0 +1,15 @@ +Only in b/CCS/src/dtcc/CoordinateSystems/gars: .GARS.cpp.swp +diff -ru a/CCS/src/dtcc/CoordinateSystems/gars/GARS.cpp b/CCS/src/dtcc/CoordinateSystems/gars/GARS.cpp +--- a/CCS/src/dtcc/CoordinateSystems/gars/GARS.cpp 2019-05-09 08:43:20.000000000 +0800 ++++ b/CCS/src/dtcc/CoordinateSystems/gars/GARS.cpp 2022-06-23 08:04:37.949610100 +0800 +@@ -199,8 +199,8 @@ + char _15_minute_value_str[2] = ""; + char _5_minute_value_str[2] = ""; + double round_error = 5.0e-11; +- char* _15_minute_array[2][2] = {{"3", "1"}, {"4", "2"}}; +- char* _5_minute_array[3][3] = {{"7", "4", "1"}, {"8", "5", "2"}, {"9", "6", "3"}}; ++ const char* _15_minute_array[2][2] = {{"3", "1"}, {"4", "2"}}; ++ const char* _5_minute_array[3][3] = {{"7", "4", "1"}, {"8", "5", "2"}, {"9", "6", "3"}}; + double long_minutes, lat_minutes; + double long_remainder, lat_remainder; + long horiz_index_30, vert_index_30; diff --git a/recipes/geotrans/all/test_package/CMakeLists.txt b/recipes/geotrans/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5e9431340ab31 --- /dev/null +++ b/recipes/geotrans/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(geotrans REQUIRED dtcc ccs CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE geotrans::dtcc geotrans::ccs) diff --git a/recipes/geotrans/all/test_package/conanfile.py b/recipes/geotrans/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/geotrans/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/geotrans/all/test_package/test_package.cpp b/recipes/geotrans/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..dcdb44554da17 --- /dev/null +++ b/recipes/geotrans/all/test_package/test_package.cpp @@ -0,0 +1,576 @@ +// Classification : UNCLASSIFIED + +/****************************************************************************** +* Filename : testCoordinateConversionSample.h +* +* Copyright 2007 BAE Systems National Security Solutions Inc. 1989-2006 +* ALL RIGHTS RESERVED +* +* MODIFICATION HISTORY: +* +* DATE NAME DR# DESCRIPTION +* +* 05/12/10 S Gillis BAEts26542 MSP TS MSL-HAE conversion +* should use CCS +* 06/11/10 S. Gillis BAEts26724 Fixed memory error problem +* when MSPCCS_DATA is not set +* 08/26/11 K Ou BAEts27716 Improved CCS sample code +* +******************************************************************************/ + +#include +#include + +#include "CoordinateConversionService.h" +#include "CoordinateSystemParameters.h" +#include "GeodeticParameters.h" +#include "CoordinateTuple.h" +#include "GeodeticCoordinates.h" +#include "CartesianCoordinates.h" +#include "Accuracy.h" +#include "MGRSorUSNGCoordinates.h" +#include "UTMParameters.h" +#include "UTMCoordinates.h" +#include "CoordinateType.h" +#include "HeightType.h" +#include "CoordinateConversionException.h" +/** + * Sample code to demontrate how to use the MSP Coordinate Conversion Service. + * + * Includes the following conversions: + * + * |=============================|=============================| + * | Source | Target | + * |=============================+=============================| + * | Geodetic (Ellipsoid Height) | Geocentric | + * | Geocentric | Geodetic (Ellipsoid Height) | + * |-----------------------------+-----------------------------| + * | Geocentric | Geodetic (MSL EGM 96 15M) | + * |-----------------------------+-----------------------------| + * | Geodetic (Ellipsoid Height) | Geodetic (MSL EGM 96 15M) | + * | Geodetic (MSL EGM 96 15M) | Geodetic (Ellipsoid Height) | + * |-----------------------------+-----------------------------| + * | Geocentric | UTM | + * |-----------------------------+-----------------------------| + * | Geocentric | MGRS | + * |-----------------------------+-----------------------------| + * + **/ + + +/** + * Function which uses the given Geodetic (Ellipsoid Height) to Geocentric + * Coordinate Conversion Service, 'ccsGeodeticEllipsoidToGeocentric', to + * convert the given lat, lon, and height to x, y, z coordinates. + **/ +void convertGeodeticEllipsoidToGeocentric( + MSP::CCS::CoordinateConversionService& ccsGeodeticEllipsoidToGeocentric, + double lat, + double lon, + double height, + double& x, + double& y, + double& z) +{ + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + MSP::CCS::GeodeticCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geodetic, lon, lat, height); + MSP::CCS::CartesianCoordinates targetCoordinates( + MSP::CCS::CoordinateType::geocentric); + + ccsGeodeticEllipsoidToGeocentric.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy); + + x = targetCoordinates.x(); + y = targetCoordinates.y(); + z = targetCoordinates.z(); +} + + +/** + * Function which uses the given Geodetic (Ellipsoid Height) to Geocentric + * Coordinate Conversion Service, 'ccsGeodeticEllipsoidToGeocentric', to + * convert the given x, y, z coordinates to a lat, lon, and height. + **/ +void convertGeocentricToGeodeticEllipsoid( + MSP::CCS::CoordinateConversionService& ccsGeodeticEllipsoidToGeocentric, + double x, + double y, + double z, + double& lat, + double& lon, + double& height) +{ + MSP::CCS::Accuracy geocentricAccuracy; + MSP::CCS::Accuracy geodeticAccuracy; + MSP::CCS::CartesianCoordinates geocentricCoordinates( + MSP::CCS::CoordinateType::geocentric, x, y, z); + MSP::CCS::GeodeticCoordinates geodeticCoordinates; + + // Note that the Geodetic (Ellipsoid Height) to Geocentric Coordinate + // Conversion Service is used here in conjunction with the + // convertTargetToSource() method (as opposed to a Geocentric to + // Geodetic (Ellipsoid Height) Coordinate Conversion Service in + // conjunction with the convertSourceToTarget() method) + ccsGeodeticEllipsoidToGeocentric.convertTargetToSource( + &geocentricCoordinates, + &geocentricAccuracy, + geodeticCoordinates, + geodeticAccuracy); + + lat = geodeticCoordinates.latitude(); + lon = geodeticCoordinates.longitude(); + height = geodeticCoordinates.height(); +} + + +/** + * Function which uses the given Geocentric to Geodetic (MSL EGM 96 15M) + * Coordinate Conversion Service, 'ccsGeocentricToGeodeticMslEgm96', to + * convert the given x, y, z coordinates to a lat, lon, and height. + **/ +void convertGeocentricToGeodeticMslEgm96( + MSP::CCS::CoordinateConversionService& ccsGeocentricToGeodeticMslEgm96, + double x, + double y, + double z, + double& lat, + double& lon, + double& height) +{ + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + MSP::CCS::CartesianCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geocentric, x, y, z); + MSP::CCS::GeodeticCoordinates targetCoordinates( + MSP::CCS::CoordinateType::geodetic, lon, lat, height); + + ccsGeocentricToGeodeticMslEgm96.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy ); + + lat = targetCoordinates.latitude(); + lon = targetCoordinates.longitude(); + height = targetCoordinates.height(); +} + + +/** + * Function which uses the given Geodetic (MSL EGM 96 15M) to Geodetic + * (Ellipsoid Height) Coordinate Conversion Service, + * 'ccsMslEgm96ToEllipsoidHeight', to convert the given MSL height at the + * given lat, lon, to an Ellipsoid height. + **/ +void convertMslEgm96ToEllipsoidHeight( + MSP::CCS::CoordinateConversionService& ccsMslEgm96ToEllipsoidHeight, + double lat, + double lon, + double mslHeight, + double& ellipsoidHeight) +{ + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + MSP::CCS::GeodeticCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geodetic, lon, lat, mslHeight); + MSP::CCS::GeodeticCoordinates targetCoordinates; + + ccsMslEgm96ToEllipsoidHeight.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy); + + ellipsoidHeight = targetCoordinates.height(); +} + + +/** + * Function which uses the given Geodetic (Ellipsoid Height) to Geodetic + * (MSL EGM 96 15M) Coordinate Conversion Service, + * 'ccsEllipsoidHeightToMslEgm96', to convert the given Ellipsoid height at + * the given lat, lon, to an MSL height. + **/ +void convertEllipsoidHeightToMslEgm96( + MSP::CCS::CoordinateConversionService& ccsEllipsoidHeightToMslEgm96, + double lat, + double lon, + double ellipsoidHeight, + double& mslHeight) +{ + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + + MSP::CCS::GeodeticCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geodetic, lon, lat, ellipsoidHeight); + MSP::CCS::GeodeticCoordinates targetCoordinates; + + ccsEllipsoidHeightToMslEgm96.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy); + + mslHeight = targetCoordinates.height(); +} + + +/** + * Function which uses the given Geocentric to UTM Coordinate Conversion + * Service, 'ccsGeocentricToUtm', to convert the given x, y, z coordinates + * a UTM zone, hemisphere, Easting and Northing. + **/ +void convertGeocentricToUtm( + MSP::CCS::CoordinateConversionService& ccsGeocentricToUtm, + double x, + double y, + double z, + long& zone, + char& hemisphere, + double& easting, + double& northing) +{ + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + MSP::CCS::CartesianCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geocentric, x, y, z); + MSP::CCS::UTMCoordinates targetCoordinates; + + ccsGeocentricToUtm.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy); + + zone = targetCoordinates.zone(); + hemisphere = targetCoordinates.hemisphere(); + easting = targetCoordinates.easting(); + northing = targetCoordinates.northing(); +} + + +/** + * Function which uses the given Geocentric to MGRS Coordinate Conversion + * Service, 'ccsGeocentricToMgrs', to convert the given x, y, z coordinates + * to an MGRS string and precision. + **/ +std::string convertGeocentricToMgrs( + MSP::CCS::CoordinateConversionService& ccsGeocentricToMgrs, + double x, + double y, + double z, + MSP::CCS::Precision::Enum& precision) +{ + char* p; + std::string mgrsString; + + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + MSP::CCS::CartesianCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geocentric, x, y, z); + MSP::CCS::MGRSorUSNGCoordinates targetCoordinates; + + ccsGeocentricToMgrs.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy ); + + // Returned value, 'p', points to targetCoordinate's internal character + // array so assign/copy the character array to mgrsString to avoid + // introducing memory management issues + p = targetCoordinates.MGRSString(); + mgrsString = p; + + precision = targetCoordinates.precision(); + + return mgrsString; +} + + +/****************************************************************************** + * Main function + ******************************************************************************/ + +int main(int argc, char **argv) +{ + const char* WGE = "WGE"; + + // initialize status value to one, indicating an error condition + int status = 1; + + std::cout << "Coordinate Conversion Service Sample Test Driver" << std::endl; + std::cout << std::endl; + + // + // Coordinate System Parameters + // + MSP::CCS::GeodeticParameters ellipsoidParameters( + MSP::CCS::CoordinateType::geodetic, + MSP::CCS::HeightType::ellipsoidHeight); + + MSP::CCS::CoordinateSystemParameters geocentricParameters( + MSP::CCS::CoordinateType::geocentric); + + MSP::CCS::GeodeticParameters mslEgm96Parameters( + MSP::CCS::CoordinateType::geodetic, + MSP::CCS::HeightType::EGM96FifteenMinBilinear); + + MSP::CCS::UTMParameters utmParameters( + MSP::CCS::CoordinateType::universalTransverseMercator, + 1, + 0); + + MSP::CCS::CoordinateSystemParameters mgrsParameters( + MSP::CCS::CoordinateType::militaryGridReferenceSystem); + + // + // Coordinate Conversion Services + // + MSP::CCS::CoordinateConversionService ccsGeodeticEllipsoidToGeocentric( + WGE, &ellipsoidParameters, + WGE, &geocentricParameters); + + MSP::CCS::CoordinateConversionService ccsGeocentricToGeodeticMslEgm96( + WGE, &geocentricParameters, + WGE, &mslEgm96Parameters); + + MSP::CCS::CoordinateConversionService ccsMslEgm96ToEllipsoidHeight( + WGE, &mslEgm96Parameters, + WGE, &ellipsoidParameters); + MSP::CCS::CoordinateConversionService ccsEllipsoidHeightToMslEgm96( + WGE, &ellipsoidParameters, + WGE, &mslEgm96Parameters); + + MSP::CCS::CoordinateConversionService ccsGeocentricToUtm( + WGE, &geocentricParameters, + WGE, &utmParameters); + MSP::CCS::CoordinateConversionService ccsGeocentricToMgrs( + WGE, &geocentricParameters, + WGE, &mgrsParameters); + + try { + + // + // Geodetic (Ellipsoid Height) to Geocentric + // + double lat = 0.56932; + double lon = -2.04552; + double height = 0.0; + + double x, y, z; + + std::cout << "convertGeodeticEllipsoidToGeocentric" << '\n'; + convertGeodeticEllipsoidToGeocentric( + ccsGeodeticEllipsoidToGeocentric, + lat, lon, height, + x, y, z); + + std::cout << "Convert Geodetic (Ellipsoid Height) to Geocentric" << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "Height(m): " << height << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl; + + // + // Geocentric to Geodetic (Ellipsoid Height) + // + + // function convertGeocentricToGeodeticEllipsoid() reuses the + // ccsGeodeticEllipsoidToGeocentric instance to perform the reverse + // conversion + convertGeocentricToGeodeticEllipsoid( + ccsGeodeticEllipsoidToGeocentric, + x, y, z, + lat, lon, height); + + std::cout << "Revert Geocentric To Geodetic (Ellipsoid Height): " << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "Height(m): " << height << std::endl + << std::endl; + + + // reuse ccsGeodeticEllipsoidToGeocentric instance to perform another + // Geodetic (Ellipsoid Height) to Geocentric conversions + lat = 0.76388; + lon = 0.60566; + height = 11.0; + + convertGeodeticEllipsoidToGeocentric( + ccsGeodeticEllipsoidToGeocentric, + lat, lon, height, + x, y, z); + + std::cout << "Convert Geodetic (Ellipsoid Height) to Geocentric" << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "Height(m): " << height << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl; + + // reuse ccsGeodeticEllipsoidToGeocentric instance to perform another + // Geodetic (Ellipsoid Height) to Geocentric conversions + lat = 0.71458; + lon = 0.88791; + height = 22.0; + + convertGeodeticEllipsoidToGeocentric( + ccsGeodeticEllipsoidToGeocentric, + lat, lon, height, + x, y, z); + + std::cout << "Convert Geodetic (Ellipsoid Height) to Geocentric" << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "Height(m): " << height << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl; + + // + // Geocentric to Geodetic (MSL EGM96 15M) + // + x = 3851747; + y = 3719589; + z = 3454013; + + double mslHeight; + + convertGeocentricToGeodeticMslEgm96( + ccsGeocentricToGeodeticMslEgm96, + x, y, z, + lat, lon, mslHeight); + + std::cout << "Convert Geocentric To Geodetic MSL EGM96: " << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "MSL EGM96 15M Height: " << mslHeight << std::endl + << std::endl; + + // + // Geodetic (MSL EGM96 15M) to Geodetic (Ellipsoid Height) + // + convertMslEgm96ToEllipsoidHeight( + ccsMslEgm96ToEllipsoidHeight, + lat, lon, mslHeight, + height); + + std::cout << "Convert Geodetic (MSL EMG96 15M Height) To Geodetic (Ellipsoid Height)" << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "MSL EGM96 15M Height: " << mslHeight << std::endl + << std::endl + << "Ellipsoid Height: " << height << std::endl + << std::endl; + + // + // Geodetic (Ellipsoid Height) to Geodetic (MSL EMG96 15M) + // + convertEllipsoidHeightToMslEgm96( + ccsEllipsoidHeightToMslEgm96, + lat, lon, height, + mslHeight); + + std::cout << "Revert Geodetic (Ellipsoid Height) To Geodetic (MSL EGM96 15M) Height" << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "Height(m): " << height << std::endl + << std::endl + << "MSL EGM96 15M Height: " << mslHeight << std::endl + << std::endl; + + // + // Geocentric to UTM + // + long zone; + char hemi; + double easting, northing; + convertGeocentricToUtm( + ccsGeocentricToUtm, + x, y, z, + zone, hemi, easting, northing); + + std::cout << "Convert Geocentric To UTM: " << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl + << "Zone: " << zone << std::endl + << "Hemisphere: " << hemi << std::endl + << "Easting: " << easting << std::endl + << "Northing: " << northing<< std::endl + << std::endl; + + // + // Geocentric to MGRS + // + std::string mgrsString; + MSP::CCS::Precision::Enum precision; + + mgrsString = convertGeocentricToMgrs( + ccsGeocentricToMgrs, + x, y, z, + precision); + + std::cout << "Convert Geocentric To MGRS: " << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl + << "MGRS: " << mgrsString << std::endl + << "Precision: " << precision << std::endl + << std::endl; + + // set status value to zero to indicate successful completion + status = 0; + + } catch(MSP::CCS::CoordinateConversionException& e) { + // catch and report any exceptions thrown by the Coordinate + // Conversion Service + std::cerr + << "ERROR: Coordinate Conversion Service exception encountered - " + << e.getMessage() + << std::endl; + + } catch(std::exception& e) { + // catch and report any unexpected exceptions thrown + std::cerr << "ERROR: Unexpected exception encountered - " + << e.what() << std::endl; + } + + return status; +} + +// Classification : UNCLASSIFIED diff --git a/recipes/geotrans/all/test_v1_package/CMakeLists.txt b/recipes/geotrans/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/geotrans/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/geotrans/all/test_v1_package/conanfile.py b/recipes/geotrans/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2f992fa32bae6 --- /dev/null +++ b/recipes/geotrans/all/test_v1_package/conanfile.py @@ -0,0 +1,29 @@ +from conans import ConanFile, CMake, tools +from contextlib import contextmanager +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + @contextmanager + def _workaround_2profiles(self): + if hasattr(self, "settings_build"): + with tools.environment_append( + {"MSPCCS_DATA": os.path.join(self.deps_cpp_info["geotrans"].rootpath, "res")} + ): + yield + else: + yield + + def test(self): + if not tools.cross_building(self): + with self._workaround_2profiles(): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/geotrans/config.yml b/recipes/geotrans/config.yml new file mode 100644 index 0000000000000..a874c72606420 --- /dev/null +++ b/recipes/geotrans/config.yml @@ -0,0 +1,3 @@ +versions: + "3.8": + folder: all diff --git a/recipes/getopt-for-visual-studio/all/conandata.yml b/recipes/getopt-for-visual-studio/all/conandata.yml index 85bf85a9e1a46..5da98d58a5952 100644 --- a/recipes/getopt-for-visual-studio/all/conandata.yml +++ b/recipes/getopt-for-visual-studio/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "20200201": - patch_file: "patches/0001-allow-usage-in-multiple-compilation-units.patch" - base_path: "source_subfolder" diff --git a/recipes/getopt-for-visual-studio/all/conanfile.py b/recipes/getopt-for-visual-studio/all/conanfile.py index 18f43d1820f2d..79b25ed563631 100644 --- a/recipes/getopt-for-visual-studio/all/conanfile.py +++ b/recipes/getopt-for-visual-studio/all/conanfile.py @@ -1,42 +1,53 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, copy, get, load, save +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc import os +required_conan_version = ">=1.50.0" -class GetoptForVisualStudio(ConanFile): + +class GetoptForVisualStudioConan(ConanFile): name = "getopt-for-visual-studio" description = "GNU getopt for Visual Studio" - topics = ("conan", "getopt", "cli", "command line", "options") + topics = ("getopt", "cli", "command line", "options") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/skandhurkat/Getopt-for-Visual-Studio" license = "MIT", "BSD-2-Clause" - exports_sources = "patches/**" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def package_id(self): + self.info.clear() - def configure(self): - if self.settings.compiler != "Visual Studio": + def validate(self): + if not is_msvc(self): raise ConanInvalidConfiguration("getopt-for-visual-studio is only supported for Visual Studio") - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("Getopt-for-Visual-Studio-{}".format(os.path.splitext(os.path.basename(self.conan_data["sources"][self.version]["url"]))[0]), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + apply_conandata_patches(self) @property def _license_text(self): - content = tools.load(os.path.join(self._source_subfolder, "getopt.h")) + content = load(self, os.path.join(self.source_folder, "getopt.h")) return "\n".join(list(l.strip() for l in content[content.find("/**", 3):content.find("#pragma")].split("\n"))) def package(self): - tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), self._license_text) - self.copy("getopt.h", src=self._source_subfolder, dst="include") + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._license_text) + copy(self, "getopt.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/getopt-for-visual-studio/all/test_package/CMakeLists.txt b/recipes/getopt-for-visual-studio/all/test_package/CMakeLists.txt index b21ba22ce6d14..9a45d31295100 100644 --- a/recipes/getopt-for-visual-studio/all/test_package/CMakeLists.txt +++ b/recipes/getopt-for-visual-studio/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.0) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(getopt-for-visual-studio) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE getopt-for-visual-studio::getopt-for-visual-studio) diff --git a/recipes/getopt-for-visual-studio/all/test_package/conanfile.py b/recipes/getopt-for-visual-studio/all/test_package/conanfile.py index 1511c156191f2..d120a992c06a6 100644 --- a/recipes/getopt-for-visual-studio/all/test_package/conanfile.py +++ b/recipes/getopt-for-visual-studio/all/test_package/conanfile.py @@ -1,17 +1,25 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) - cmake.verbose = True cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/getopt-for-visual-studio/all/test_v1_package/CMakeLists.txt b/recipes/getopt-for-visual-studio/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2e0409f1c8ebf --- /dev/null +++ b/recipes/getopt-for-visual-studio/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.0) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(getopt-for-visual-studio) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE getopt-for-visual-studio::getopt-for-visual-studio) diff --git a/recipes/getopt-for-visual-studio/all/test_v1_package/conanfile.py b/recipes/getopt-for-visual-studio/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/getopt-for-visual-studio/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gettext/all/conandata.yml b/recipes/gettext/all/conandata.yml index 7b9f07043ec76..1c02d8978221d 100644 --- a/recipes/gettext/all/conandata.yml +++ b/recipes/gettext/all/conandata.yml @@ -1,12 +1,18 @@ sources: + "0.21": + url: "https://ftp.gnu.org/pub/gnu/gettext/gettext-0.21.tar.gz" + sha256: "c77d0da3102aec9c07f43671e60611ebff89a996ef159497ce8e59d075786b12" "0.20.1": - sha256: "66415634c6e8c3fa8b71362879ec7575e27da43da562c798a8a2f223e6e47f5c" url: "https://ftp.gnu.org/pub/gnu/gettext/gettext-0.20.1.tar.gz" + sha256: "66415634c6e8c3fa8b71362879ec7575e27da43da562c798a8a2f223e6e47f5c" patches: + "0.21": + - patch_file: "patches/0002-memmove-is-intrinsic-function-on-MSVC.patch" + base_path: "source_subfolder" "0.20.1": - - patch_file: "patches/0001-build-Fix-build-errors-with-MSVC.patch" + - patch_file: "patches/0.20.1-0001-fix-build-errors-with-MSVC.patch" base_path: "source_subfolder" - patch_file: "patches/0002-memmove-is-intrinsic-function-on-MSVC.patch" base_path: "source_subfolder" - - patch_file: "patches/0003-Reported-by-Gabor-Z.-Papp-gzp-papp.hu.patch" + - patch_file: "patches/0.20.1-0003-Reported-by-Gabor-Z.-Papp-gzp-papp.hu.patch" base_path: "source_subfolder" diff --git a/recipes/gettext/all/conanfile.py b/recipes/gettext/all/conanfile.py index b0d0132ed8929..d7020710e49c9 100644 --- a/recipes/gettext/all/conanfile.py +++ b/recipes/gettext/all/conanfile.py @@ -1,20 +1,21 @@ from conans import ConanFile, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration +import contextlib import os -import shutil -import glob + +required_conan_version = ">=1.33.0" class GetTextConan(ConanFile): name = "gettext" description = "An internationalization and localization system for multilingual programs" - topics = ("conan", "gettext", "intl", "libintl", "i18n") + topics = ("gettext", "intl", "libintl", "i18n") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.gnu.org/software/gettext" license = "GPL-3.0-or-later" - settings = "os_build", "arch_build", "compiler" - exports_sources = ["patches/*.patch"] + settings = "os", "arch", "compiler" - requires = [("libiconv/1.16", "private")] + exports_sources = "patches/*" _autotools = None @@ -23,100 +24,136 @@ def _source_subfolder(self): return "source_subfolder" @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) @property - def _make_args(self): - return None + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + @property + def _is_msvc(self): + return self.settings.compiler == "Visual Studio" def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def requirements(self): + self.requires("libiconv/1.17") + def build_requirements(self): - if tools.os_info.is_windows: - if "CONAN_BASH_PATH" not in os.environ and tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") if self._is_msvc: - self.build_requires("automake/1.16.1") + self.build_requires("automake/1.16.5") + + def validate(self): + if tools.Version(self.version) < "0.21" and self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("MSVC builds of gettext for versions < 0.21 are not supported.") # FIXME: it used to be possible. What changed? + + def package_id(self): + del self.info.settings.compiler def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "gettext-" + self.version - os.rename(extracted_dir, self._source_subfolder) - + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + env = { + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "LD": "link -nologo", + "NM": "dumpbin -symbols", + "STRIP": ":", + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), + "RANLIB": ":", + } + with tools.vcvars(self): + with tools.environment_append(VisualStudioBuildEnvironment(self).vars): + with tools.environment_append(env): + yield + else: + yield + def _configure_autotools(self): if self._autotools: return self._autotools - libiconv_prefix = self.deps_cpp_info["libiconv"].rootpath - libiconv_prefix = tools.unix_path(libiconv_prefix) if tools.os_info.is_windows else libiconv_prefix - args = ["HELP2MAN=/bin/true", - "EMACS=no", - "--disable-nls", - "--disable-dependency-tracking", - "--enable-relocatable", - "--disable-c++", - "--disable-java", - "--disable-csharp", - "--disable-libasprintf", - "--disable-curses", - "--with-libiconv-prefix=%s" % libiconv_prefix] + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + self._autotools.libs = [] + libiconv_prefix = tools.unix_path(self.deps_cpp_info["libiconv"].rootpath) + args = [ + "HELP2MAN=/bin/true", + "EMACS=no", + "--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), + "--with-libiconv-prefix={}".format(libiconv_prefix), + "--disable-shared", + "--disable-static", + "--disable-nls", + "--disable-dependency-tracking", + "--enable-relocatable", + "--disable-c++", + "--disable-java", + "--disable-csharp", + "--disable-libasprintf", + "--disable-curses", + ] build = None host = None - rc = None - args.extend(["--disable-shared", "--disable-static"]) if self._is_msvc: + rc = None + self._autotools.flags.append("-FS") # INSTALL.windows: Native binaries, built using the MS Visual C/C++ tool chain. build = False - if self.settings.arch_build == "x86": + if self.settings.arch == "x86": host = "i686-w64-mingw32" rc = "windres --target=pe-i386" - elif self.settings.arch_build == "x86_64": + elif self.settings.arch == "x86_64": host = "x86_64-w64-mingw32" rc = "windres --target=pe-x86-64" - automake_perldir = tools.unix_path(os.path.join(self.deps_cpp_info['automake'].rootpath, "bin", "share", "automake-1.16")) - args.extend(["CC=%s/compile cl -nologo" % automake_perldir, - "LD=link", - "NM=dumpbin -symbols", - "STRIP=:", - "AR=%s/ar-lib lib" % automake_perldir, - "RANLIB=:"]) if rc: - args.extend(['RC=%s' % rc, 'WINDRES=%s' % rc]) - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - if self._is_msvc: - self._autotools.flags.append("-FS") - self._autotools.configure(args=args, build=build, host=host) + args.extend([ + "RC={}".format(rc), + "WINDRES={}".format(rc), + ]) + self._autotools.configure(args=args, configure_dir=self._source_subfolder, build=build, host=host) return self._autotools def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): - with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): - with tools.chdir(os.path.join(self._source_subfolder)): - env_build = self._configure_autotools() - env_build.make(self._make_args) + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + tools.replace_in_file(os.path.join(self._source_subfolder, "gettext-tools", "misc", "autopoint.in"), "@prefix@", "$GETTEXT_ROOT_UNIX") + tools.replace_in_file(os.path.join(self._source_subfolder, "gettext-tools", "misc", "autopoint.in"), "@datarootdir@", "$prefix/res") + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): - with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): - with tools.chdir(os.path.join(self._source_subfolder)): - env_build = self._configure_autotools() - env_build.install() - tools.rmdir(os.path.join(self.package_folder, 'share')) - tools.rmdir(os.path.join(self.package_folder, 'lib')) - tools.rmdir(os.path.join(self.package_folder, 'include')) - - def package_id(self): - self.info.include_build_settings() - del self.info.settings.compiler + self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses") + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "lib")) + tools.rmdir(os.path.join(self.package_folder, "include")) + tools.rmdir(os.path.join(self.package_folder, "share", "doc")) + tools.rmdir(os.path.join(self.package_folder, "share", "info")) + tools.rmdir(os.path.join(self.package_folder, "share", "man")) def package_info(self): + self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] + bindir = os.path.join(self.package_folder, "bin") - self.output.info('Appending PATH environment variable: {}'.format(bindir)) + self.output.info("Appending PATH environment variable: {}".format(bindir)) self.env_info.PATH.append(bindir) + aclocal = tools.unix_path(os.path.join(self.package_folder, "res", "aclocal")) + self.output.info("Appending AUTOMAKE_CONAN_INCLUDES environment variable: {}".format(aclocal)) + self.env_info.AUTOMAKE_CONAN_INCLUDES.append(aclocal) + + autopoint = tools.unix_path(os.path.join(self.package_folder, "bin", "autopoint")) + self.output.info("Setting AUTOPOINT environment variable: {}".format(autopoint)) + self.env_info.AUTOPOINT = autopoint + self.env_info.GETTEXT_ROOT_UNIX = tools.unix_path(self.package_folder) diff --git a/recipes/gettext/all/patches/0001-build-Fix-build-errors-with-MSVC.patch b/recipes/gettext/all/patches/0.20.1-0001-fix-build-errors-with-MSVC.patch similarity index 100% rename from recipes/gettext/all/patches/0001-build-Fix-build-errors-with-MSVC.patch rename to recipes/gettext/all/patches/0.20.1-0001-fix-build-errors-with-MSVC.patch diff --git a/recipes/gettext/all/patches/0003-Reported-by-Gabor-Z.-Papp-gzp-papp.hu.patch b/recipes/gettext/all/patches/0.20.1-0003-Reported-by-Gabor-Z.-Papp-gzp-papp.hu.patch similarity index 100% rename from recipes/gettext/all/patches/0003-Reported-by-Gabor-Z.-Papp-gzp-papp.hu.patch rename to recipes/gettext/all/patches/0.20.1-0003-Reported-by-Gabor-Z.-Papp-gzp-papp.hu.patch diff --git a/recipes/gettext/all/test_package/conanfile.py b/recipes/gettext/all/test_package/conanfile.py index d217063663cbd..9e810ecf433fc 100644 --- a/recipes/gettext/all/test_package/conanfile.py +++ b/recipes/gettext/all/test_package/conanfile.py @@ -1,10 +1,51 @@ -from conans import ConanFile +from conans import ConanFile, tools, AutoToolsBuildEnvironment +import contextlib +import os +import shutil class TestPackageConan(ConanFile): - settings = "os", "arch" - generators = "txt" + settings = "os", "arch", "compiler" + exports_sources = "configure.ac", + test_type = "explicit" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + self.build_requires("automake/1.16.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self): + env = { + "CC": "cl -nologo", + "LD": "link -nologo", + } + with tools.environment_append(env): + yield + else: + yield + + def build(self): + for src in self.exports_sources: + shutil.copy(os.path.join(self.source_folder, src), os.path.join(self.build_folder, src)) + + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows, run_environment=True) + with self._build_context(): + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools.libs = [] + autotools.configure() def test(self): - for exe in ['gettext', 'ngettext', 'msgcat', 'msgmerge']: - self.run("%s --version" % exe, run_environment=True) + if not tools.cross_building(self, skip_x64_x86=True): + for exe in ["gettext", "ngettext", "msgcat", "msgmerge"]: + self.run("{} --version".format(exe), run_environment=True) diff --git a/recipes/gettext/all/test_package/configure.ac b/recipes/gettext/all/test_package/configure.ac new file mode 100644 index 0000000000000..b2c4f352a64de --- /dev/null +++ b/recipes/gettext/all/test_package/configure.ac @@ -0,0 +1,6 @@ +AC_INIT([test_package_gettext],[1.0]) +AC_PREREQ([2.69]) + +AM_GNU_GETTEXT_REQUIRE_VERSION([0.20]) +AM_GNU_GETTEXT([external], [need-ngettext]) +AM_ICONV diff --git a/recipes/gettext/config.yml b/recipes/gettext/config.yml index 4ea7b582de7b7..dc03f51a1d462 100644 --- a/recipes/gettext/config.yml +++ b/recipes/gettext/config.yml @@ -1,3 +1,5 @@ versions: + "0.21": + folder: all "0.20.1": folder: all diff --git a/recipes/gf-complete/all/conandata.yml b/recipes/gf-complete/all/conandata.yml index b6913b8b5394c..58f9543628ba7 100644 --- a/recipes/gf-complete/all/conandata.yml +++ b/recipes/gf-complete/all/conandata.yml @@ -1,7 +1,11 @@ sources: - "1.03": - url: "https://github.com/ceph/gf-complete/archive/58eebabd204998364355eee293402929502bf1a9.tar.gz" - sha256: "ba9d90b5818b8356073fdc21704bdd8b70e80aceb51700374386393f39cb1b0e" "cci.20170410": url: "https://github.com/ceph/gf-complete/archive/a6862d10c9db467148f20eef2c6445ac9afd94d8.tar.gz" sha256: "f7a8f61eb3c6718b4d8011c75b75a1bedd820e6851d71a65e491af805e8749aa" + "1.03": # 20141225 + url: "https://github.com/ceph/gf-complete/archive/58eebabd204998364355eee293402929502bf1a9.tar.gz" + sha256: "ba9d90b5818b8356073fdc21704bdd8b70e80aceb51700374386393f39cb1b0e" +patches: + "cci.20170410": + - patch_file: "patches/0001-fix-msvc-cci.20170410.patch" + base_path: "source_subfolder" diff --git a/recipes/gf-complete/all/conanfile.py b/recipes/gf-complete/all/conanfile.py index a7ef73ad0d5c5..0947d375fcf7d 100644 --- a/recipes/gf-complete/all/conanfile.py +++ b/recipes/gf-complete/all/conanfile.py @@ -1,7 +1,9 @@ from conans import ConanFile, AutoToolsBuildEnvironment, tools from conans.errors import ConanInvalidConfiguration +import contextlib import os -import glob + +required_conan_version = ">=1.33.0" class GfCompleteConan(ConanFile): @@ -28,13 +30,16 @@ class GfCompleteConan(ConanFile): "avx": "auto" } - _source_subfolder = "source_subfolder" + exports_sources = "patches/**" _autotools = None - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob(self.name + "-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): if self.settings.os == 'Windows': @@ -46,71 +51,112 @@ def config_options(self): del self.options.neon def configure(self): - if tools.os_info.is_windows and not self.settings.compiler == "gcc": - # Building on Windows is currently only supported using the MSYS2 - # subsystem. In theory, the gf-complete library can be build using - # MSVC. However, some adjustments to the build-system are needed - # and the CLI tools cannot be build. - # - # A suitable profile for MSYS2 can be found in the documentation: - # https://github.com/conan-io/docs/blob/b712aa7c0dc99607c46c57585787ced2ae66ac33/systems_cross_building/windows_subsystems.rst - raise ConanInvalidConfiguration( - "Windows is only supported using the MSYS2 subsystem") - + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd - def _configure_autotools(self): - if self._autotools: - return self._autotools + def requirements(self): + if self.settings.compiler == "Visual Studio": + self.requires("getopt-for-visual-studio/20200201") - self._autotools = AutoToolsBuildEnvironment( - self, win_bash=tools.os_info.is_windows) + def validate(self): + if self.settings.compiler == "Visual Studio": + if self.options.shared: + raise ConanInvalidConfiguration("gf-complete doesn't support shared with Visual Studio") + if self.version == "1.03": + raise ConanInvalidConfiguration("gf-complete 1.03 doesn't support Visual Studio") - with tools.environment_append(self._autotools.vars): - with tools.chdir(self._source_subfolder): - self.run("./autogen.sh", win_bash=tools.os_info.is_windows) + def build_requirements(self): + self.build_requires("libtool/2.4.6") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") - if "x86" in self.settings.arch: - self._autotools.flags.append('-mstackrealign') + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + # Don't build tests and examples (and also tools if Visual Studio) + to_build = ["src"] + if self.settings.compiler != "Visual Studio": + to_build.append("tools") + tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.am"), + "SUBDIRS = src tools test examples", + "SUBDIRS = {}".format(" ".join(to_build))) + # Honor build type settings and fPIC option + for subdir in ["src", "tools"]: + for flag in ["-O3", "-fPIC"]: + tools.replace_in_file(os.path.join(self._source_subfolder, subdir, "Makefile.am"), + flag, "") + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self): + env = { + "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), + "LD": "{} link -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), + "AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), + } + with tools.environment_append(env): + yield + else: + yield - configure_args = [ - "--enable-shared=%s" % ("yes" if self.options.shared else "no"), - "--enable-static=%s" % ("no" if self.options.shared else "yes") + def _configure_autotools(self): + if self._autotools: + return self._autotools + + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + self._autotools.libs = [] + if self.settings.compiler == "Visual Studio": + self._autotools.flags.append("-FS") + elif "x86" in self.settings.arch: + self._autotools.flags.append("-mstackrealign") + + yes_no = lambda v: "yes" if v else "no" + conf_args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), ] if "arm" in self.settings.arch: if self.options.neon != "auto": - configure_args.append("--{}-neon".format( - "enable" if self.options.neon else "disable")) + conf_args.append("--enable-neon={}".format(yes_no(self.options.neon))) if self.settings.arch in ["x86", "x86_64"]: if self.options.sse != "auto": - configure_args.append("--{}-sse".format( - "enable" if self.options.sse else "disable")) + conf_args.append("--enable-sse={}".format(yes_no(self.options.sse))) if self.options.avx != "auto": - configure_args.append("--{}-avx".format( - "enable" if self.options.avx else "disable")) + conf_args.append("--enable-avx={}".format(yes_no(self.options.avx))) - self._autotools.configure(args=configure_args, - configure_dir=self._source_subfolder) + self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) return self._autotools def build(self): - autotools = self._configure_autotools() - autotools.make() + self._patch_sources() + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() def package(self): self.copy("COPYING", dst="licenses", src=self._source_subfolder) - autotools = self._configure_autotools() - autotools.install() - - # don't package la file - la_file = os.path.join(self.package_folder, "lib", "libgf_complete.la") - if os.path.isfile(la_file): - os.unlink(la_file) + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["gf_complete"] + + if self.settings.compiler != "Visual Studio": + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/gf-complete/all/patches/0001-fix-msvc-cci.20170410.patch b/recipes/gf-complete/all/patches/0001-fix-msvc-cci.20170410.patch new file mode 100644 index 0000000000000..8a4f75ba1757e --- /dev/null +++ b/recipes/gf-complete/all/patches/0001-fix-msvc-cci.20170410.patch @@ -0,0 +1,70 @@ +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -11,13 +11,13 @@ AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include + # with SIMD_FLAGS, this static library will get linked into gf_complete.so + noinst_LTLIBRARIES = libgf_util.la + libgf_util_la_SOURCES = gf_method.c +-libgf_util_la_CFLAGS = -O3 -fPIC -Wsign-compare ++libgf_util_la_CFLAGS = -O3 -fPIC + + # we narrowly use SIMD_FLAGS for code that needs it + lib_LTLIBRARIES = libgf_complete.la + libgf_complete_la_SOURCES = gf.c gf_wgen.c gf_w4.c gf_w8.c gf_w16.c gf_w32.c \ + gf_w64.c gf_w128.c gf_rand.c gf_general.c gf_cpu.c +-libgf_complete_la_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC -Wsign-compare ++libgf_complete_la_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC + libgf_complete_la_LIBADD = libgf_util.la + + if HAVE_NEON +--- a/src/gf.c ++++ b/src/gf.c +@@ -13,6 +13,10 @@ + #include + #include + #include "gf_cpu.h" ++#ifdef _MSC_VER ++#include ++#define bzero(s, n) {memset(s, 0, n);} ++#endif + + int _gf_errno = GF_E_DEFAULT; + +--- a/src/gf_w16.c ++++ b/src/gf_w16.c +@@ -13,6 +13,10 @@ + #include + #include "gf_w16.h" + #include "gf_cpu.h" ++#ifdef _MSC_VER ++#include ++#define bzero(s, n) {memset(s, 0, n);} ++#endif + + #define AB2(ip, am1 ,am2, b, t1, t2) {\ + t1 = (b << 1) & am1;\ +--- a/src/gf_w4.c ++++ b/src/gf_w4.c +@@ -13,6 +13,10 @@ + #include + #include "gf_w4.h" + #include "gf_cpu.h" ++#ifdef _MSC_VER ++#include ++#define bzero(s, n) {memset(s, 0, n);} ++#endif + + #define AB2(ip, am1 ,am2, b, t1, t2) {\ + t1 = (b << 1) & am1;\ +--- a/src/gf_w8.c ++++ b/src/gf_w8.c +@@ -14,6 +14,10 @@ + #include + #include + #include "gf_cpu.h" ++#ifdef _MSC_VER ++#include ++#define bzero(s, n) {memset(s, 0, n);} ++#endif + + #define AB2(ip, am1 ,am2, b, t1, t2) {\ + t1 = (b << 1) & am1;\ diff --git a/recipes/gf-complete/all/test_package/conanfile.py b/recipes/gf-complete/all/test_package/conanfile.py index b88a6525524a6..6bc1a2f31ef01 100644 --- a/recipes/gf-complete/all/test_package/conanfile.py +++ b/recipes/gf-complete/all/test_package/conanfile.py @@ -1,4 +1,4 @@ -from conans import ConanFile, CMake +from conans import ConanFile, CMake, tools import os @@ -12,5 +12,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not tools.cross_building(self, skip_x64_x86=True): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gf-complete/all/test_package/test_package.c b/recipes/gf-complete/all/test_package/test_package.c index 1c295d9201cce..7ef15121f223f 100644 --- a/recipes/gf-complete/all/test_package/test_package.c +++ b/recipes/gf-complete/all/test_package/test_package.c @@ -1,8 +1,7 @@ -#include +#include -#include "gf_complete.h" - -int main(int argc, char *argv[]) { +int main(void) { gf_t gf; + gf_init_easy(&gf, 16); return 0; } diff --git a/recipes/gf-complete/config.yml b/recipes/gf-complete/config.yml index f81bbb66d896e..661448b09007f 100644 --- a/recipes/gf-complete/config.yml +++ b/recipes/gf-complete/config.yml @@ -1,5 +1,5 @@ versions: - "1.03": - folder: all "cci.20170410": folder: all + "1.03": # 20141225 + folder: all diff --git a/recipes/gflags/all/CMakeLists.txt b/recipes/gflags/all/CMakeLists.txt deleted file mode 100644 index 5544c114ce2e6..0000000000000 --- a/recipes/gflags/all/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -message("Conan CMake Wrapper") -include("conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/gflags/all/conanfile.py b/recipes/gflags/all/conanfile.py index 66bdef09ce606..fda8b67b4cb6e 100644 --- a/recipes/gflags/all/conanfile.py +++ b/recipes/gflags/all/conanfile.py @@ -1,24 +1,26 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import collect_libs, copy, get, rmdir, save import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.47.0" class GflagsConan(ConanFile): name = "gflags" description = "The gflags package contains a C++ library that implements commandline flags processing" - topics = ("conan", "gflags", "cli", "flags", "commandline") + topics = ("gflags", "cli", "flags", "commandline") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/gflags/gflags" license = "BSD-3-Clause" - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "nothreads": [True, False], - "namespace": "ANY", + "namespace": ["ANY"], } default_options = { "shared": False, @@ -27,18 +29,6 @@ class GflagsConan(ConanFile): "namespace": "gflags", } - exports_sources = "CMakeLists.txt" - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -47,75 +37,73 @@ def configure(self): if self.options.shared: del self.options.fPIC + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename("%s-%s" % (self.name, self.version), self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["BUILD_STATIC_LIBS"] = not self.options.shared - self._cmake.definitions["BUILD_gflags_LIB"] = not self.options.nothreads - self._cmake.definitions["BUILD_gflags_nothreads_LIB"] = self.options.nothreads - self._cmake.definitions["BUILD_PACKAGING"] = False - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.definitions["INSTALL_HEADERS"] = True - self._cmake.definitions["INSTALL_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["INSTALL_STATIC_LIBS"] = not self.options.shared - self._cmake.definitions["REGISTER_BUILD_DIR"] = False - self._cmake.definitions["REGISTER_INSTALL_PREFIX"] = False - self._cmake.definitions["GFLAGS_NAMESPACE"] = self.options.namespace - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_SHARED_LIBS"] = self.options.shared + tc.variables["BUILD_STATIC_LIBS"] = not self.options.shared + tc.variables["BUILD_gflags_LIB"] = not self.options.nothreads + tc.variables["BUILD_gflags_nothreads_LIB"] = self.options.nothreads + tc.variables["BUILD_PACKAGING"] = False + tc.variables["BUILD_TESTING"] = False + tc.variables["INSTALL_HEADERS"] = True + tc.variables["INSTALL_SHARED_LIBS"] = self.options.shared + tc.variables["INSTALL_STATIC_LIBS"] = not self.options.shared + tc.variables["REGISTER_BUILD_DIR"] = False + tc.variables["REGISTER_INSTALL_PREFIX"] = False + tc.variables["GFLAGS_NAMESPACE"] = self.options.namespace + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once legacy generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {"gflags": "gflags::gflags"} ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + """) + save(self, module_file, content) @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.names["cmake_find_package"] = "gflags" - self.cpp_info.names["cmake_find_package_multi"] = "gflags" - self.cpp_info.builddirs.append(self._module_subfolder) - self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] - self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - self.cpp_info.names["pkg_config"] = "gflags" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "gflags") + self.cpp_info.set_property("cmake_target_name", "gflags::gflags") + self.cpp_info.set_property("cmake_target_aliases", ["gflags"]) + self.cpp_info.set_property("pkg_config_name", "gflags") + self.cpp_info.libs = collect_libs(self) if self.settings.os == "Windows": self.cpp_info.system_libs.extend(["shlwapi"]) - elif self.settings.os == "Linux": + elif self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["pthread", "m"]) + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/gflags/all/test_package/CMakeLists.txt b/recipes/gflags/all/test_package/CMakeLists.txt index 3fd22e600dac6..5b23a3ac87bb6 100644 --- a/recipes/gflags/all/test_package/CMakeLists.txt +++ b/recipes/gflags/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(gflags REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} gflags::gflags) +target_link_libraries(${PROJECT_NAME} PRIVATE gflags::gflags) diff --git a/recipes/gflags/all/test_package/conanfile.py b/recipes/gflags/all/test_package/conanfile.py index 6b296552e59dd..3a8c6c5442b33 100644 --- a/recipes/gflags/all/test_package/conanfile.py +++ b/recipes/gflags/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +20,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gflags/all/test_v1_package/CMakeLists.txt b/recipes/gflags/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..ea0c4e2bee799 --- /dev/null +++ b/recipes/gflags/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gflags REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gflags::gflags) diff --git a/recipes/gflags/all/test_v1_package/conanfile.py b/recipes/gflags/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/gflags/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gflags/config.yml b/recipes/gflags/config.yml index 0eb4bc4ba8e82..6d6cfc66eae07 100644 --- a/recipes/gflags/config.yml +++ b/recipes/gflags/config.yml @@ -1,4 +1,3 @@ ---- versions: "2.2.2": folder: all diff --git a/recipes/gfortran/all/conandata.yml b/recipes/gfortran/all/conandata.yml index 9585b50f82122..7baa9c9b5ccf6 100644 --- a/recipes/gfortran/all/conandata.yml +++ b/recipes/gfortran/all/conandata.yml @@ -1,13 +1,14 @@ sources: "10.2": - "url": - "Windows": - url: https://downloads.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/ray_linn/GCC-10.X-with-ada/GCC-10.2.0-crt-8.0.0-with-ada-20201019.7z - filename: GCC-10.2.0-crt-8.0.0-with-ada-20201019.7z - sha256: 5c3fc254494bc24eb201870f4b781d401cf7279bd03ea1aba6f2ffae771ded44 - "Linux": - url: https://gfortran.meteodat.ch/download/x86_64/snapshots/gcc-10-20210109.tar.xz - sha256: 494e9d881d6d9bb4a5707bfa149f77001599f093090c6c78fdb19cefbacda7b8 - "Macos": - url: https://downloads.sourceforge.net/project/hpc/hpc/g95/gfortran-10.2-bin.tar.gz - sha256: 2de46f571eefc2b544db4ed6c958c78a5e3e78c4b4b5daab38aabc1b08dd5666 + "Windows": + "x86_64": + url: "https://downloads.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/ray_linn/GCC-10.X-with-ada/GCC-10.2.0-crt-8.0.0-with-ada-20201019.7z" + sha256: "5c3fc254494bc24eb201870f4b781d401cf7279bd03ea1aba6f2ffae771ded44" + "Linux": + "x86_64": + url: "https://gfortran.meteodat.ch/download/x86_64/releases/gcc-10.2.0.tar.xz" + sha256: "5cfaf152db442bb967963ca62d4590980cb2664c5902c1a9578fc8a9c6efe40f" + "Macos": + "x86_64": + url: "https://downloads.sourceforge.net/project/hpc/hpc/g95/gfortran-10.2-bin.tar.gz" + sha256: "2de46f571eefc2b544db4ed6c958c78a5e3e78c4b4b5daab38aabc1b08dd5666" diff --git a/recipes/gfortran/all/conanfile.py b/recipes/gfortran/all/conanfile.py index 43279cdb234c8..209997c47d1fa 100644 --- a/recipes/gfortran/all/conanfile.py +++ b/recipes/gfortran/all/conanfile.py @@ -1,11 +1,9 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import copy, get, load, save, download import os -import glob - - -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.46.0" class GFortranConan(ConanFile): name = "gfortran" @@ -14,12 +12,9 @@ class GFortranConan(ConanFile): homepage = "https://gcc.gnu.org/fortran" topics = ("gnu", "gcc", "fortran", "compiler") license = "GPL-3.0-or-later" - settings = "os", "arch" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - - @property - def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder_{}".format(str(self.settings.os))) + short_paths = True def validate(self): if self.settings.arch != "x86_64": @@ -29,38 +24,56 @@ def validate(self): def build_requirements(self): if self.settings.os == "Windows": - self.build_requires("7zip/19.00") + self.tool_requires("7zip/19.00") + + def build(self): + if self.settings.os == "Windows": + filename = os.path.join(self.build_folder, "GCC-10.2.0-crt-8.0.0-with-ada-20201019.7z") + download(self, **self.conan_data["sources"][self.version][str(self.settings.os)]["x86_64"], filename=filename) + self.run(f"7z x {filename}") + else: + get(self, **self.conan_data["sources"][self.version][str(self.settings.os)]["x86_64"], + destination=self.build_folder, strip_root=True) - def source(self): - url = self.conan_data["sources"][self.version]["url"] - for it in url.keys(): - if self.settings.os == "Windows" and it == "Windows": - filename = url[it]["filename"] - tools.download(**url[it]) - self.run("7z x {0}".format(filename)) - os.unlink(filename) - os.rename("mingw64", "source_subfolder_Windows") - elif it != "Windows": - tools.get(**url[it]) - pattern = "gcc-*" if it == "Linux" else "usr" - os.rename(glob.glob(pattern)[0], "source_subfolder_{}".format(it)) + @property + def _archive_contents_path(self): + if self.settings.os == "Macos": + return os.path.join(self.build_folder, "local") + elif self.settings.os == "Windows": + return os.path.join(self.build_folder, "mingw64") + else: + return os.path.join(self.build_folder) + + @property + def _license_path(self): + return os.path.join(self._archive_contents_path, "share", "info") + + @property + def _library_source_path(self): + return os.path.join(self._archive_contents_path, { + "Linux": "lib64", + "Macos": "lib", + "Windows": os.path.join("lib", "gcc", "x86_64-w64-mingw32", "10.2.0") + }[str(self.settings.os)]) def _extract_license(self): - info = tools.load(os.path.join(self.source_folder, "source_subfolder_Linux", "share", "info", "gfortran.info")) + info = load(self, os.path.join(self._license_path, "gfortran.info")) license_contents = info[info.find("Version 3"):info.find("END OF TERMS", 1)] - tools.save("LICENSE", license_contents) + save(self, os.path.join(self.build_folder, "LICENSE"), license_contents) + + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type # The binaries are not specific def package(self): self._extract_license() - self.copy("LICENSE", dst="licenses") - self.copy("gfortran*", dst="bin", src=os.path.join(self._source_subfolder, "bin")) - self.copy("gfortran", dst="bin", src=os.path.join(self._source_subfolder, "local", "bin")) - self.copy("libgfortran.a", dst="lib", src=os.path.join(self._source_subfolder, "lib64")) - self.copy("libgfortran.a", dst="lib", src=os.path.join(self._source_subfolder, "local", "lib")) - self.copy("libgfortran.a", dst="lib", src=os.path.join(self._source_subfolder, "lib", "gcc", "x86_64-w64-mingw32", "10.2.0")) + copy(self, "LICENSE", src=self.build_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "gfortran*", src=os.path.join(self._archive_contents_path, "bin"), dst=os.path.join(self.package_folder, "bin")) + copy(self, "libgfortran.a", src=self._library_source_path, dst=os.path.join(self.package_folder, "lib")) def package_info(self): bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.cpp_info.includedirs = [] self.env_info.PATH.append(bin_path) self.cpp_info.libs = ["gfortran"] diff --git a/recipes/gfortran/all/test_package/conanfile.py b/recipes/gfortran/all/test_package/conanfile.py index c9380771129c0..9d3aaf213929b 100644 --- a/recipes/gfortran/all/test_package/conanfile.py +++ b/recipes/gfortran/all/test_package/conanfile.py @@ -1,8 +1,14 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import can_run class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) def test(self): - if not tools.cross_building(self): - self.run("gfortran --version", run_environment=True) + if can_run(self): + self.run("gfortran --version", env="conanrun") diff --git a/recipes/gfortran/all/test_v1_package/conanfile.py b/recipes/gfortran/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c9380771129c0 --- /dev/null +++ b/recipes/gfortran/all/test_v1_package/conanfile.py @@ -0,0 +1,8 @@ +from conans import ConanFile, tools + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def test(self): + if not tools.cross_building(self): + self.run("gfortran --version", run_environment=True) diff --git a/recipes/ghc-filesystem/all/conandata.yml b/recipes/ghc-filesystem/all/conandata.yml index ac69caa3f7a9f..934a94aaf88eb 100644 --- a/recipes/ghc-filesystem/all/conandata.yml +++ b/recipes/ghc-filesystem/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.5.12": + url: "https://github.com/gulrak/filesystem/archive/v1.5.12.tar.gz" + sha256: "7d62c5746c724d28da216d9e11827ba4e573df15ef40720292827a4dfd33f2e9" + "1.5.8": + url: "https://github.com/gulrak/filesystem/archive/v1.5.8.tar.gz" + sha256: "726f8ccb2ec844f4c66cc4b572369497327df31b86c04cefad6b311964107139" "1.4.0": url: "https://github.com/gulrak/filesystem/archive/v1.4.0.tar.gz" sha256: "332fb8afda06671090c755c623da15889b66cfdedcf6f343d38a28a930ea5304" diff --git a/recipes/ghc-filesystem/all/conanfile.py b/recipes/ghc-filesystem/all/conanfile.py index a6f41d56f7d61..e7b402102ac33 100644 --- a/recipes/ghc-filesystem/all/conanfile.py +++ b/recipes/ghc-filesystem/all/conanfile.py @@ -1,49 +1,61 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.50.0" class GhcFilesystemRecipe(ConanFile): name = "ghc-filesystem" description = "A header-only single-file std::filesystem compatible helper library" - topics = ("conan", "ghc-filesystem", "header-only", "filesystem") + topics = ("ghc-filesystem", "header-only", "filesystem") homepage = "https://github.com/gulrak/filesystem" url = "https://github.com/conan-io/conan-center-index" license = "MIT" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + cmake_layout(self) + + def package_id(self): + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "filesystem-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["GHC_FILESYSTEM_BUILD_TESTING"] = False - self._cmake.definitions["GHC_FILESYSTEM_BUILD_EXAMPLES"] = False - self._cmake.definitions["GHC_FILESYSTEM_WITH_INSTALL"] = True - self._cmake.configure(source_folder=self._source_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + + tc.variables["GHC_FILESYSTEM_BUILD_TESTING"] = False + tc.variables["GHC_FILESYSTEM_BUILD_EXAMPLES"] = False + tc.variables["GHC_FILESYSTEM_WITH_INSTALL"] = True + + tc.generate() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder,"licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.configure() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib")) - - def package_id(self): - self.info.header_only() + rmdir(self, os.path.join(self.package_folder, "lib")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "ghc_filesystem") + self.cpp_info.set_property("cmake_target_name", "ghcFilesystem::ghc_filesystem") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["ghc_filesystem"].bindirs = [] + self.cpp_info.components["ghc_filesystem"].frameworkdirs = [] + self.cpp_info.components["ghc_filesystem"].libdirs = [] + self.cpp_info.components["ghc_filesystem"].resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "ghc_filesystem" + self.cpp_info.filenames["cmake_find_package_multi"] = "ghc_filesystem" self.cpp_info.names["cmake_find_package"] = "ghcFilesystem" self.cpp_info.names["cmake_find_package_multi"] = "ghcFilesystem" - self.cpp_info.components["filesystem"].names["cmake_find_package"] = "ghc_filesystem" - self.cpp_info.components["filesystem"].names["cmake_find_package_multi"] = "ghc_filesystem" + self.cpp_info.components["ghc_filesystem"].names["cmake_find_package"] = "ghc_filesystem" + self.cpp_info.components["ghc_filesystem"].names["cmake_find_package_multi"] = "ghc_filesystem" + self.cpp_info.components["ghc_filesystem"].set_property("cmake_target_name", "ghcFilesystem::ghc_filesystem") diff --git a/recipes/ghc-filesystem/all/test_package/CMakeLists.txt b/recipes/ghc-filesystem/all/test_package/CMakeLists.txt index b501b197dab0f..b3075eb110867 100644 --- a/recipes/ghc-filesystem/all/test_package/CMakeLists.txt +++ b/recipes/ghc-filesystem/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(ghcFilesystem REQUIRED CONFIG) +find_package(ghc_filesystem REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ghcFilesystem::ghc_filesystem) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE ghcFilesystem::ghc_filesystem) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/ghc-filesystem/all/test_package/conanfile.py b/recipes/ghc-filesystem/all/test_package/conanfile.py index 3f4a9f50f389e..0a6bc68712d90 100644 --- a/recipes/ghc-filesystem/all/test_package/conanfile.py +++ b/recipes/ghc-filesystem/all/test_package/conanfile.py @@ -1,11 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools - class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -13,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/ghc-filesystem/all/test_v1_package/CMakeLists.txt b/recipes/ghc-filesystem/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/ghc-filesystem/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/ghc-filesystem/all/test_v1_package/conanfile.py b/recipes/ghc-filesystem/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/ghc-filesystem/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ghc-filesystem/config.yml b/recipes/ghc-filesystem/config.yml index eed35319fcea1..a66760cf157ac 100644 --- a/recipes/ghc-filesystem/config.yml +++ b/recipes/ghc-filesystem/config.yml @@ -1,3 +1,7 @@ versions: + "1.5.12": + folder: "all" + "1.5.8": + folder: "all" "1.4.0": folder: "all" diff --git a/recipes/giflib/all/conandata.yml b/recipes/giflib/5.1.x/conandata.yml similarity index 100% rename from recipes/giflib/all/conandata.yml rename to recipes/giflib/5.1.x/conandata.yml diff --git a/recipes/giflib/5.1.x/conanfile.py b/recipes/giflib/5.1.x/conanfile.py new file mode 100644 index 0000000000000..9853dbf433ace --- /dev/null +++ b/recipes/giflib/5.1.x/conanfile.py @@ -0,0 +1,169 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os +import shutil + +required_conan_version = ">=1.43.0" + + +class GiflibConan(ConanFile): + name = "giflib" + description = "A library and utilities for reading and writing GIF images." + url = "https://github.com/conan-io/conan-center-index" + license = "MIT" + homepage = "http://giflib.sourceforge.net" + topics = ("giflib", "image", "multimedia", "format", "graphics") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + # The exported files I took them from https://github.com/bjornblissing/osg-3rdparty-cmake/tree/master/giflib + # refactored a little + exports_sources = ["unistd.h", "gif_lib.h"] + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def build_requirements(self): + if not self._is_msvc: + self.build_requires("gnu-config/cci.20201022") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def build(self): + # disable util build - tools and internal libs + tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), + "SUBDIRS = lib util pic $(am__append_1)", + "SUBDIRS = lib pic $(am__append_1)") + + if self._is_msvc: + self.build_visual() + else: + self.build_configure() + + def build_visual(self): + # fully replace gif_lib.h for VS, with patched version + ver_components = self.version.split(".") + tools.replace_in_file("gif_lib.h", "@GIFLIB_MAJOR@", ver_components[0]) + tools.replace_in_file("gif_lib.h", "@GIFLIB_MINOR@", ver_components[1]) + tools.replace_in_file("gif_lib.h", "@GIFLIB_RELEASE@", ver_components[2]) + shutil.copy("gif_lib.h", os.path.join(self._source_subfolder, "lib")) + # add unistd.h for VS + shutil.copy("unistd.h", os.path.join(self._source_subfolder, "lib")) + + with tools.chdir(self._source_subfolder): + if self.settings.arch == "x86": + host = "i686-w64-mingw32" + elif self.settings.arch == "x86_64": + host = "x86_64-w64-mingw32" + else: + raise ConanInvalidConfiguration("unsupported architecture %s" % self.settings.arch) + if self.options.shared: + options = "--disable-static --enable-shared" + else: + options = "--enable-static --disable-shared" + + cflags = "" + if not self.options.shared: + cflags = "-DUSE_GIF_LIB" + + prefix = tools.unix_path(os.path.abspath(self.package_folder)) + with tools.vcvars(self.settings): + command = "./configure " \ + "{options} " \ + "--host={host} " \ + "--prefix={prefix} " \ + 'CC="$PWD/compile cl -nologo" ' \ + 'CFLAGS="-{runtime} {cflags}" ' \ + 'CXX="$PWD/compile cl -nologo" ' \ + 'CXXFLAGS="-{runtime} {cflags}" ' \ + 'CPPFLAGS="-I{prefix}/include" ' \ + 'LDFLAGS="-L{prefix}/lib" ' \ + 'LD="link" ' \ + 'NM="dumpbin -symbols" ' \ + 'STRIP=":" ' \ + 'AR="$PWD/ar-lib lib" ' \ + 'RANLIB=":" '.format(host=host, prefix=prefix, options=options, + runtime=self.settings.compiler.runtime, cflags=cflags) + self.run(command, win_bash=True) + self.run("make", win_bash=True) + self.run("make install", win_bash=True) + + def build_configure(self): + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) + env_build = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + ] + with tools.chdir(self._source_subfolder): + if tools.is_apple_os(self.settings.os): + # relocatable shared lib on macOS + tools.replace_in_file( + "configure", + "-install_name \\$rpath/\\$soname", + "-install_name \\@rpath/\\$soname" + ) + + self.run("chmod +x configure") + env_build.configure(args=args) + env_build.make() + env_build.make(args=["install"]) + + def package(self): + self.copy(pattern="COPYING*", dst="licenses", src=self._source_subfolder, ignore_case=True, keep_path=False) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + tools.rmdir(os.path.join(self.package_folder, "share")) + if self._is_msvc and self.options.shared: + tools.rename(os.path.join(self.package_folder, "lib", "gif.dll.lib"), + os.path.join(self.package_folder, "lib", "gif.lib")) + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "GIF") + self.cpp_info.set_property("cmake_target_name", "GIF::GIF") + + self.cpp_info.names["cmake_find_package"] = "GIF" + self.cpp_info.names["cmake_find_package_multi"] = "GIF" + + self.cpp_info.libs = ["gif"] + if self._is_msvc: + self.cpp_info.defines.append("USE_GIF_DLL" if self.options.shared else "USE_GIF_LIB") diff --git a/recipes/giflib/all/gif_lib.h b/recipes/giflib/5.1.x/gif_lib.h similarity index 100% rename from recipes/giflib/all/gif_lib.h rename to recipes/giflib/5.1.x/gif_lib.h diff --git a/recipes/giflib/5.1.x/test_package/CMakeLists.txt b/recipes/giflib/5.1.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..95fca5bec20b2 --- /dev/null +++ b/recipes/giflib/5.1.x/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(GIF REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} GIF::GIF) +set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/giflib/5.1.x/test_package/conanfile.py b/recipes/giflib/5.1.x/test_package/conanfile.py new file mode 100644 index 0000000000000..9c22b9663e80c --- /dev/null +++ b/recipes/giflib/5.1.x/test_package/conanfile.py @@ -0,0 +1,28 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + img_name = os.path.join(self.source_folder, "testimg.gif") + bin_path = os.path.join("bin", "test_package") + command = "{} {}".format(bin_path, img_name) + self.run(command, run_environment=True) diff --git a/recipes/giflib/all/test_package/test_package.c b/recipes/giflib/5.1.x/test_package/test_package.c similarity index 100% rename from recipes/giflib/all/test_package/test_package.c rename to recipes/giflib/5.1.x/test_package/test_package.c diff --git a/recipes/giflib/all/unistd.h b/recipes/giflib/5.1.x/unistd.h similarity index 100% rename from recipes/giflib/all/unistd.h rename to recipes/giflib/5.1.x/unistd.h diff --git a/recipes/giflib/5.2.x/CMakeLists.txt b/recipes/giflib/5.2.x/CMakeLists.txt index d3488899fb18e..2d4e86b610d29 100644 --- a/recipes/giflib/5.2.x/CMakeLists.txt +++ b/recipes/giflib/5.2.x/CMakeLists.txt @@ -1,27 +1,62 @@ -cmake_minimum_required(VERSION 2.8.12) -project(gif C) +cmake_minimum_required(VERSION 3.1) +project(gif LANGUAGES C) -include("${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +include(GNUInstallDirs) -set(SOURCE_FILES - "source_subfolder/dgif_lib.c" - "source_subfolder/egif_lib.c" - "source_subfolder/gifalloc.c" - "source_subfolder/gif_err.c" - "source_subfolder/gif_font.c" - "source_subfolder/gif_hash.c" - "source_subfolder/openbsd-reallocarray.c" +add_library(gif + "${GIFLIB_SRC_DIR}/dgif_lib.c" + "${GIFLIB_SRC_DIR}/egif_lib.c" + "${GIFLIB_SRC_DIR}/gifalloc.c" + "${GIFLIB_SRC_DIR}/gif_err.c" + "${GIFLIB_SRC_DIR}/gif_font.c" + "${GIFLIB_SRC_DIR}/gif_hash.c" + "${GIFLIB_SRC_DIR}/openbsd-reallocarray.c" ) - -if(NOT BUILD_SHARED_LIBS) - add_definitions(-DUSE_GIF_LIB) +if(WIN32) + if(BUILD_SHARED_LIBS) + set_property(TARGET gif PROPERTY PREFIX "") + target_compile_definitions(gif INTERFACE USE_GIF_DLL) + else() + target_compile_definitions(gif PUBLIC USE_GIF_LIB) + endif() endif() -add_library(${PROJECT_NAME} ${SOURCE_FILES}) +install( + TARGETS gif + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) +install( + FILES "${GIFLIB_SRC_DIR}/gif_lib.h" + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) -install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION "lib" - LIBRARY DESTINATION "lib" - RUNTIME DESTINATION "bin") -install(FILES "source_subfolder/gif_lib.h" DESTINATION "include") +if(UTILS) + add_library(giflib_util STATIC + "${GIFLIB_SRC_DIR}/qprintf.c" + "${GIFLIB_SRC_DIR}/quantize.c" + "${GIFLIB_SRC_DIR}/getarg.c" + ) + target_link_libraries(giflib_util PRIVATE gif) + + set(GIF_UTILS + gif2rgb + gifbuild + giffix + giftext + giftool + gifclrmp + ) + foreach(GIF_UTIL ${GIF_UTILS}) + add_executable(${GIF_UTIL} "${GIFLIB_SRC_DIR}/${GIF_UTIL}.c") + target_link_libraries(${GIF_UTIL} PRIVATE gif giflib_util) + endforeach() + find_library(LIBM NAMES m) + target_link_libraries(gifclrmp PRIVATE $<$:${LIBM}>) + if(MSVC) + find_package(getopt-for-visual-studio REQUIRED CONFIG) + target_link_libraries(giftool PRIVATE getopt-for-visual-studio::getopt-for-visual-studio) + endif() + install(TARGETS ${GIF_UTILS} DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/recipes/giflib/5.2.x/conandata.yml b/recipes/giflib/5.2.x/conandata.yml index cdd8ed57ce314..e36e2cd9d7be2 100644 --- a/recipes/giflib/5.2.x/conandata.yml +++ b/recipes/giflib/5.2.x/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "5.2.1": - patch_file: "patches/0001-msvc-unistd.patch" - base_path: "source_subfolder" diff --git a/recipes/giflib/5.2.x/conanfile.py b/recipes/giflib/5.2.x/conanfile.py index adc0a7535cedb..a310e9327cab1 100644 --- a/recipes/giflib/5.2.x/conanfile.py +++ b/recipes/giflib/5.2.x/conanfile.py @@ -1,25 +1,35 @@ -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get +from conan.tools.microsoft import is_msvc import os +required_conan_version = ">=1.53.0" + + class GiflibConan(ConanFile): name = "giflib" description = "A library and utilities for reading and writing GIF images." url = "https://github.com/conan-io/conan-center-index" license = "MIT" homepage = "http://giflib.sourceforge.net" - topics = ("conan", "giflib", "image", "multimedia", "format", "graphics") - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" + topics = ("gif", "image", "multimedia", "format", "graphics") - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "utils" : [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "utils" : True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -27,42 +37,51 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("%s-%s" % (self.name, self.version), self._source_subfolder) + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - if self._cmake: - return self._cmake + def requirements(self): + if is_msvc(self) and self.options.utils: + self.requires("getopt-for-visual-studio/20200201") - self._cmake = CMake(self) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["GIFLIB_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["UTILS"] = self.options.utils + tc.generate() - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + if is_msvc(self): + cd = CMakeDeps(self) + cd.generate() def build(self): - self._patch_sources() - - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "GIF") + self.cpp_info.set_property("cmake_target_name", "GIF::GIF") + self.cpp_info.libs = ["gif"] + if is_msvc(self): + self.cpp_info.defines.append("USE_GIF_DLL" if self.options.shared else "USE_GIF_LIB") + + # TODO: to remove in conan v2 self.cpp_info.names["cmake_find_package"] = "GIF" self.cpp_info.names["cmake_find_package_multi"] = "GIF" - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.compiler == "Visual Studio": - self.cpp_info.defines.append("USE_GIF_DLL" if self.options.shared else "USE_GIF_LIB") + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/giflib/5.2.x/test_package/CMakeLists.txt b/recipes/giflib/5.2.x/test_package/CMakeLists.txt index 34af13462f44f..909c7abfcc3fc 100644 --- a/recipes/giflib/5.2.x/test_package/CMakeLists.txt +++ b/recipes/giflib/5.2.x/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(GIF REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE GIF::GIF) diff --git a/recipes/giflib/5.2.x/test_package/conanfile.py b/recipes/giflib/5.2.x/test_package/conanfile.py index 188432bc4f733..b9fa3f37a5fb4 100644 --- a/recipes/giflib/5.2.x/test_package/conanfile.py +++ b/recipes/giflib/5.2.x/test_package/conanfile.py @@ -1,9 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -11,7 +21,10 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - command = "%s testimg.gif" % bin_path - self.run(command, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(f"{bin_path} testimg.gif", env="conanrun") + assert os.path.isfile("testimg.gif") + if self.options["giflib"].utils: + self.run("gif2rgb -o testimg.rgb testimg.gif", env="conanrun") + assert os.path.isfile("testimg.rgb.R") diff --git a/recipes/giflib/5.2.x/test_package/test_package.c b/recipes/giflib/5.2.x/test_package/test_package.c index 7e36b181016e3..7c3b23c1cd736 100644 --- a/recipes/giflib/5.2.x/test_package/test_package.c +++ b/recipes/giflib/5.2.x/test_package/test_package.c @@ -1,92 +1,96 @@ -#include -#include -#include -#include - #include "gif_lib.h" +#include +#include +#include +#include -#define LINE_LEN 40 -#define IMAGEWIDTH LINE_LEN*GIF_FONT_WIDTH +#define LINE_LEN 40 +#define IMAGEWIDTH LINE_LEN*GIF_FONT_WIDTH static int BackGround = 0; static void QuitGifError(GifFileType *GifFile); static void GenRasterTextLine(GifRowType *RasterBuffer, char *TextLine, - int BufferWidth, int ForeGroundIndex); + int BufferWidth, int ForeGroundIndex); /****************************************************************************** Interpret the command line and generate the given GIF file. ******************************************************************************/ int main(int argc, char **argv) { - int i, j, l, ColorMapSize, ErrorCode; + int i, j, l, ColorMapSize, ErrorCode; char Line[LINE_LEN]; GifRowType RasterBuffer[GIF_FONT_HEIGHT]; ColorMapObject *ColorMap; GifFileType *GifFile; - GifColorType ScratchMap[256]; + GifColorType ScratchMap[256]; + + if (argc < 2) { + fprintf(stderr, "Usage: %s OUTPUTGIF\n", argv[0]); + exit(1); + } /* Allocate the raster buffer for GIF_FONT_HEIGHT scan lines. */ for (i = 0; i < GIF_FONT_HEIGHT; i++) { - if ((RasterBuffer[i] = (GifRowType) malloc(sizeof(GifPixelType) * - IMAGEWIDTH)) == NULL) - exit(1); + if ((RasterBuffer[i] = (GifRowType) malloc(sizeof(GifPixelType) * IMAGEWIDTH)) == NULL) + exit(1); } /* Open stdout for the output file: */ - if ((GifFile = EGifOpenFileName("out.gif", 0, &ErrorCode)) == NULL) { - printf("error: %d\n", ErrorCode); - exit(EXIT_FAILURE); + if ((GifFile = EGifOpenFileName(argv[1], 0, &ErrorCode)) == NULL) { + printf("error: %d\n", ErrorCode); + exit(EXIT_FAILURE); } /* Read the color map in ColorFile into this color map: */ for (ColorMapSize = 0; ColorMapSize < 256; ColorMapSize++) { ScratchMap[ColorMapSize].Red = ColorMapSize; - ScratchMap[ColorMapSize].Green = ColorMapSize; - ScratchMap[ColorMapSize].Blue = ColorMapSize; + ScratchMap[ColorMapSize].Green = ColorMapSize; + ScratchMap[ColorMapSize].Blue = ColorMapSize; } if ((ColorMap = GifMakeMapObject(1 << GifBitSize(ColorMapSize), ScratchMap)) == NULL) - exit(1); + exit(1); if (EGifPutScreenDesc(GifFile, - IMAGEWIDTH, ColorMapSize * GIF_FONT_HEIGHT, - GifBitSize(ColorMapSize), - BackGround, ColorMap) == GIF_ERROR) - QuitGifError(GifFile); + IMAGEWIDTH, ColorMapSize * GIF_FONT_HEIGHT, + GifBitSize(ColorMapSize), + BackGround, ColorMap) == GIF_ERROR) + QuitGifError(GifFile); /* Dump out the image descriptor: */ if (EGifPutImageDesc(GifFile, - 0, 0, IMAGEWIDTH, ColorMapSize * GIF_FONT_HEIGHT, false, NULL) == GIF_ERROR) - QuitGifError(GifFile); + 0, 0, IMAGEWIDTH, ColorMapSize * GIF_FONT_HEIGHT, false, NULL) == GIF_ERROR) + QuitGifError(GifFile); printf("\n%s: Image 1 at (%d, %d) [%dx%d]: \n", - "test_package", GifFile->Image.Left, GifFile->Image.Top, - GifFile->Image.Width, GifFile->Image.Height); - - for (i = l = 0; i < ColorMap->ColorCount; i++) { - (void)snprintf(Line, sizeof(Line), - "Color %-3d: [%-3d, %-3d, %-3d] ", i, - ColorMap->Colors[i].Red, - ColorMap->Colors[i].Green, - ColorMap->Colors[i].Blue); - GenRasterTextLine(RasterBuffer, Line, IMAGEWIDTH, i); - for (j = 0; j < GIF_FONT_HEIGHT; j++) { - if (EGifPutLine(GifFile, RasterBuffer[j], IMAGEWIDTH) == GIF_ERROR) - QuitGifError(GifFile); - printf("\b\b\b\b%-4d", l++); - } - } + "test_package", GifFile->Image.Left, GifFile->Image.Top, + GifFile->Image.Width, GifFile->Image.Height); - if (EGifCloseFile(GifFile, &ErrorCode) == GIF_ERROR) + for (i = l = 0; i < ColorMap->ColorCount; i++) { + (void)snprintf(Line, sizeof(Line), + "Color %-3d: [%-3d, %-3d, %-3d] ", i, + ColorMap->Colors[i].Red, + ColorMap->Colors[i].Green, + ColorMap->Colors[i].Blue); + GenRasterTextLine(RasterBuffer, Line, IMAGEWIDTH, i); + for (j = 0; j < GIF_FONT_HEIGHT; j++) + { + if (EGifPutLine(GifFile, RasterBuffer[j], IMAGEWIDTH) == GIF_ERROR) + QuitGifError(GifFile); + printf("\b\b\b\b%-4d", l++); + } + } + + if (EGifCloseFile(GifFile, &ErrorCode) == GIF_ERROR) { printf("error: %d\n", ErrorCode); - if (GifFile != NULL) { - EGifCloseFile(GifFile, NULL); - } - exit(EXIT_FAILURE); + if (GifFile != NULL) { + EGifCloseFile(GifFile, NULL); + } + exit(EXIT_FAILURE); } return 0; @@ -96,23 +100,24 @@ int main(int argc, char **argv) Close output file (if open), and exit. ******************************************************************************/ static void GenRasterTextLine(GifRowType *RasterBuffer, char *TextLine, - int BufferWidth, int ForeGroundIndex) + int BufferWidth, int ForeGroundIndex) { unsigned char c; unsigned char Byte, Mask; int i, j, k, CharPosX, Len = (int)strlen(TextLine); for (i = 0; i < BufferWidth; i++) - for (j = 0; j < GIF_FONT_HEIGHT; j++) RasterBuffer[j][i] = BackGround; + for (j = 0; j < GIF_FONT_HEIGHT; j++) + RasterBuffer[j][i] = BackGround; for (i = CharPosX = 0; i < Len; i++, CharPosX += GIF_FONT_WIDTH) { - c = TextLine[i]; - for (j = 0; j < GIF_FONT_HEIGHT; j++) { - Byte = GifAsciiTable8x8[(unsigned short)c][j]; - for (k = 0, Mask = 128; k < GIF_FONT_WIDTH; k++, Mask >>= 1) - if (Byte & Mask) - RasterBuffer[j][CharPosX + k] = ForeGroundIndex; - } + c = TextLine[i]; + for (j = 0; j < GIF_FONT_HEIGHT; j++) { + Byte = GifAsciiTable8x8[(unsigned short)c][j]; + for (k = 0, Mask = 128; k < GIF_FONT_WIDTH; k++, Mask >>= 1) + if (Byte & Mask) + RasterBuffer[j][CharPosX + k] = ForeGroundIndex; + } } } @@ -123,9 +128,7 @@ static void QuitGifError(GifFileType *GifFile) { if (GifFile != NULL) { printf("error: %d\n", GifFile->Error); - EGifCloseFile(GifFile, NULL); + EGifCloseFile(GifFile, NULL); } exit(EXIT_FAILURE); } - -/* vim: ts=8 sw=8 et */ diff --git a/recipes/giflib/5.2.x/test_v1_package/CMakeLists.txt b/recipes/giflib/5.2.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/giflib/5.2.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/giflib/5.2.x/test_v1_package/conanfile.py b/recipes/giflib/5.2.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..15e08a8cf4897 --- /dev/null +++ b/recipes/giflib/5.2.x/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(f"{bin_path} testimg.gif", run_environment=True) + assert os.path.isfile("testimg.gif") + if self.options["giflib"].utils: + self.run("gif2rgb -o testimg.rgb testimg.gif", run_environment=True) + assert os.path.isfile("testimg.rgb.R") diff --git a/recipes/giflib/all/conanfile.py b/recipes/giflib/all/conanfile.py deleted file mode 100644 index 5d4ee3b4e9609..0000000000000 --- a/recipes/giflib/all/conanfile.py +++ /dev/null @@ -1,142 +0,0 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration -import os -import shutil -import platform - - -class GiflibConan(ConanFile): - name = "giflib" - description = "A library and utilities for reading and writing GIF images." - url = "https://github.com/conan-io/conan-center-index" - license = "MIT" - homepage = "http://giflib.sourceforge.net" - topics = ("conan", "giflib", "image", "multimedia", "format", "graphics") - exports_sources = ["unistd.h", "gif_lib.h"] - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - # The exported files I took them from https://github.com/bjornblissing/osg-3rdparty-cmake/tree/master/giflib - # refactored a little - - _source_subfolder = "source_subfolder" - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - def configure(self): - if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - - def build_requirements(self): - if tools.os_info.is_windows and "CONAN_BASH_PATH" not in os.environ and \ - tools.os_info.detect_windows_subsystem() not in ("cygwin", "msys2"): - self.build_requires("msys2/20190524") - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - zip_name = "%s-%s" % (self.name, self.version) - os.rename(zip_name, self._source_subfolder) - - def build(self): - # disable util build - tools and internal libs - tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), - "SUBDIRS = lib util pic $(am__append_1)", - "SUBDIRS = lib pic $(am__append_1)") - - if self.settings.compiler == "Visual Studio": - self.build_visual() - else: - self.build_configure() - - def build_visual(self): - # fully replace gif_lib.h for VS, with patched version - ver_components = self.version.split(".") - tools.replace_in_file("gif_lib.h", "@GIFLIB_MAJOR@", ver_components[0]) - tools.replace_in_file("gif_lib.h", "@GIFLIB_MINOR@", ver_components[1]) - tools.replace_in_file("gif_lib.h", "@GIFLIB_RELEASE@", ver_components[2]) - shutil.copy("gif_lib.h", os.path.join(self._source_subfolder, "lib")) - # add unistd.h for VS - shutil.copy("unistd.h", os.path.join(self._source_subfolder, "lib")) - - with tools.chdir(self._source_subfolder): - if self.settings.arch == "x86": - host = "i686-w64-mingw32" - elif self.settings.arch == "x86_64": - host = "x86_64-w64-mingw32" - else: - raise ConanInvalidConfiguration("unsupported architecture %s" % self.settings.arch) - if self.options.shared: - options = "--disable-static --enable-shared" - else: - options = "--enable-static --disable-shared" - - cflags = "" - if not self.options.shared: - cflags = "-DUSE_GIF_LIB" - - prefix = tools.unix_path(os.path.abspath(self.package_folder)) - with tools.vcvars(self.settings): - command = "./configure " \ - "{options} " \ - "--host={host} " \ - "--prefix={prefix} " \ - 'CC="$PWD/compile cl -nologo" ' \ - 'CFLAGS="-{runtime} {cflags}" ' \ - 'CXX="$PWD/compile cl -nologo" ' \ - 'CXXFLAGS="-{runtime} {cflags}" ' \ - 'CPPFLAGS="-I{prefix}/include" ' \ - 'LDFLAGS="-L{prefix}/lib" ' \ - 'LD="link" ' \ - 'NM="dumpbin -symbols" ' \ - 'STRIP=":" ' \ - 'AR="$PWD/ar-lib lib" ' \ - 'RANLIB=":" '.format(host=host, prefix=prefix, options=options, - runtime=self.settings.compiler.runtime, cflags=cflags) - self.run(command, win_bash=True) - self.run("make", win_bash=True) - self.run("make install", win_bash=True) - - def build_configure(self): - env_build = AutoToolsBuildEnvironment(self, win_bash=self.settings.os == "Windows" and - platform.system() == "Windows") - - prefix = os.path.abspath(self.package_folder) - if self.settings.os == "Windows": - prefix = tools.unix_path(prefix) - args = ["--prefix=%s" % prefix] - if self.options.shared: - args.extend(["--disable-static", "--enable-shared"]) - else: - args.extend(["--enable-static", "--disable-shared"]) - - with tools.chdir(self._source_subfolder): - if self.settings.os == "Macos": - tools.replace_in_file("configure", r"-install_name \$rpath/\$soname", r"-install_name \$soname") - - self.run("chmod +x configure") - env_build.configure(args=args) - env_build.make() - env_build.make(args=["install"]) - - def package(self): - self.copy(pattern="COPYING*", dst="licenses", src=self._source_subfolder, ignore_case=True, keep_path=False) - # remove la files - la_file = os.path.join(self.package_folder, "lib", "libgif.la") - if os.path.isfile(la_file): - os.unlink(la_file) - tools.rmdir(os.path.join(self.package_folder, "share")) - - def package_info(self): - self.cpp_info.names["cmake_find_package"] = "GIF" - self.cpp_info.names["cmake_find_package_multi"] = "GIF" - self.cpp_info.libs = ["gif"] - if self.settings.compiler == "Visual Studio": - if self.options.shared: - self.cpp_info.libs = [lib + ".dll.lib" for lib in self.cpp_info.libs] - self.cpp_info.defines.append("USE_GIF_DLL") - else: - self.cpp_info.defines.append("USE_GIF_LIB") diff --git a/recipes/giflib/all/test_package/CMakeLists.txt b/recipes/giflib/all/test_package/CMakeLists.txt deleted file mode 100644 index f1c391badac73..0000000000000 --- a/recipes/giflib/all/test_package/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/giflib/all/test_package/conanfile.py b/recipes/giflib/all/test_package/conanfile.py deleted file mode 100644 index 51b5745fca6b1..0000000000000 --- a/recipes/giflib/all/test_package/conanfile.py +++ /dev/null @@ -1,18 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - img_name = os.path.join(self.source_folder, "testimg.gif") - bin_path = os.path.join("bin", "test_package") - command = "%s %s" % (bin_path, img_name) - self.run(command, run_environment=True) diff --git a/recipes/giflib/config.yml b/recipes/giflib/config.yml index cacd3446d1dfb..1ccf672c09135 100644 --- a/recipes/giflib/config.yml +++ b/recipes/giflib/config.yml @@ -1,5 +1,5 @@ versions: - "5.1.4": - folder: "all" "5.2.1": folder: "5.2.x" + "5.1.4": + folder: "5.1.x" diff --git a/recipes/ginkgo/all/conandata.yml b/recipes/ginkgo/all/conandata.yml index 050dec8428deb..80b4abc10b2df 100644 --- a/recipes/ginkgo/all/conandata.yml +++ b/recipes/ginkgo/all/conandata.yml @@ -1,10 +1,17 @@ sources: + "1.4.0": + url: "https://github.com/ginkgo-project/ginkgo/archive/v1.4.0.tar.gz" + sha256: "6dcadbd3e93f6ec58ef6cda5b980fbf51ea3c7c13e27952ef38804058ac93f08" "1.3.0": - sha256: 1b0e907b4046cdf7cef16d1730c12ba812b38f2764f49f74f454239a27f63596 - url: https://github.com/ginkgo-project/ginkgo/archive/v1.3.0.tar.gz + url: "https://github.com/ginkgo-project/ginkgo/archive/v1.3.0.tar.gz" + sha256: "1b0e907b4046cdf7cef16d1730c12ba812b38f2764f49f74f454239a27f63596" patches: + "1.4.0": + - patch_file: "patches/windows-symbols.patch" + base_path: "source_subfolder" "1.3.0": - patch_file: "patches/cmake-fixes.patch" base_path: "source_subfolder" - patch_file: "patches/windows-iterator.patch" base_path: "source_subfolder" + diff --git a/recipes/ginkgo/all/conanfile.py b/recipes/ginkgo/all/conanfile.py index e1944aaa5dbfa..759ce0c647076 100644 --- a/recipes/ginkgo/all/conanfile.py +++ b/recipes/ginkgo/all/conanfile.py @@ -1,23 +1,37 @@ +from conan.tools.microsoft import msvc_runtime_flag from conans import ConanFile, tools, CMake from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.43.0" + class GinkgoConan(ConanFile): name = "ginkgo" license = "BSD-3-Clause" homepage = "https://github.com/ginkgo-project/ginkgo" url = "https://github.com/conan-io/conan-center-index" - description = "High-performance linear algebra library for manycore systems, with a focus on sparse solution of linear systems." + description = ( + "High-performance linear algebra library for manycore systems, with a " + "focus on sparse solution of linear systems." + ) topics = ("hpc", "linear-algebra") - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False], "openmp": [ - True, False], "cuda": [True, False]} - default_options = {"shared": False, "fPIC": False, - "openmp": False, "cuda": False} - generators = "cmake" - exports_sources = ["CMakeLists.txt", "patches/**"] + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "openmp": [True, False], + "cuda": [True, False], + } + default_options = { + "shared": False, + "fPIC": False, + "openmp": False, + "cuda": False, + } + + generators = "cmake" _cmake = None @property @@ -28,6 +42,10 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + @property def _minimum_cpp_standard(self): return 14 @@ -42,6 +60,11 @@ def _minimum_compilers_version(self): "intel": "18" } + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -49,21 +72,34 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC + + def validate(self): if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, self._minimum_cpp_standard) - min_version = self._minimum_compilers_version.get( - str(self.settings.compiler)) - if not min_version: - self.output.warn("{} recipe lacks information about the {} compiler support.".format( - self.name, self.settings.compiler)) - else: - if tools.Version(self.settings.compiler.version) < min_version: - raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( - self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) + + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + "{} requires C++{} support. The current compiler {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, + self.settings.compiler, self.settings.compiler.version + ) + ) + + if self.options.shared and self._is_msvc and "MT" in msvc_runtime_flag(self): + raise ConanInvalidConfiguration( + "Ginkgo does not support mixing static CRT and shared library" + ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -77,12 +113,14 @@ def _configure_cmake(self): self._cmake.definitions["GINKGO_BUILD_OMP"] = self.options.openmp self._cmake.definitions["GINKGO_BUILD_CUDA"] = self.options.cuda self._cmake.definitions["GINKGO_BUILD_HIP"] = False + self._cmake.definitions["GINKGO_BUILD_DPCPP"] = False + self._cmake.definitions["GINKGO_BUILD_HWLOC"] = False self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared self._cmake.configure(build_folder=self._build_subfolder) return self._cmake def build(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) cmake = self._configure_cmake() cmake.build() @@ -95,34 +133,62 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "Ginkgo" - self.cpp_info.names["cmake_find_package_multi"] = "Ginkgo" - self.cpp_info.names["pkg_config"] = "ginkgo" + self.cpp_info.set_property("cmake_file_name", "Ginkgo") + self.cpp_info.set_property("cmake_target_name", "Ginkgo::ginkgo") + self.cpp_info.set_property("pkg_config_name", "ginkgo") debug_suffix = "d" if self.settings.build_type == "Debug" else "" + has_dpcpp_device = tools.Version(self.version) >= "1.4.0" - self.cpp_info.components["ginkgo_core"].names["cmake_find_package"] = "ginkgo" - self.cpp_info.components["ginkgo_core"].names["cmake_find_package_multi"] = "ginkgo" - self.cpp_info.components["ginkgo_core"].names["pkg_config"] = "ginkgo" - self.cpp_info.components["ginkgo_core"].libs = ["ginkgo" + debug_suffix] + self.cpp_info.components["ginkgo_core"].set_property("cmake_target_name", "Ginkgo::ginkgo") + self.cpp_info.components["ginkgo_core"].set_property("pkg_config_name", "ginkgo") + self.cpp_info.components["ginkgo_core"].libs = [ + "ginkgo" + debug_suffix] self.cpp_info.components["ginkgo_core"].requires = [ "ginkgo_omp", "ginkgo_cuda", "ginkgo_reference", "ginkgo_hip" ] - self.cpp_info.components["ginkgo_cuda"].names["cmake_find_package"] = "ginkgo_cuda" - self.cpp_info.components["ginkgo_cuda"].names["cmake_find_package_multi"] = "ginkgo_cuda" - self.cpp_info.components["ginkgo_cuda"].libs = ["ginkgo_cuda" + debug_suffix] + self.cpp_info.components["ginkgo_cuda"].set_property("cmake_target_name", "Ginkgo::ginkgo_cuda") + self.cpp_info.components["ginkgo_cuda"].libs = [ + "ginkgo_cuda" + debug_suffix] self.cpp_info.components["ginkgo_cuda"].requires = ["ginkgo_hip"] - self.cpp_info.components["ginkgo_omp"].names["cmake_find_package"] = "ginkgo_omp" - self.cpp_info.components["ginkgo_omp"].names["cmake_find_package_multi"] = "ginkgo_omp" - self.cpp_info.components["ginkgo_omp"].libs = ["ginkgo_omp" + debug_suffix] - self.cpp_info.components["ginkgo_omp"].requires = ["ginkgo_cuda", "ginkgo_hip"] - - self.cpp_info.components["ginkgo_hip"].names["cmake_find_package"] = "ginkgo_hip" - self.cpp_info.components["ginkgo_hip"].names["cmake_find_package_multi"] = "ginkgo_hip" - self.cpp_info.components["ginkgo_hip"].libs = ["ginkgo_hip" + debug_suffix] - - self.cpp_info.components["ginkgo_reference"].names["cmake_find_package"] = "ginkgo_reference" - self.cpp_info.components["ginkgo_reference"].names["cmake_find_package_multi"] = "ginkgo_reference" - self.cpp_info.components["ginkgo_reference"].libs = ["ginkgo_reference" + debug_suffix] + self.cpp_info.components["ginkgo_omp"].set_property("cmake_target_name", "Ginkgo::ginkgo_omp") + self.cpp_info.components["ginkgo_omp"].libs = [ + "ginkgo_omp" + debug_suffix] + self.cpp_info.components["ginkgo_omp"].requires = [ + "ginkgo_cuda", "ginkgo_hip"] + + self.cpp_info.components["ginkgo_hip"].set_property("cmake_target_name", "Ginkgo::ginkgo_hip") + self.cpp_info.components["ginkgo_hip"].libs = [ + "ginkgo_hip" + debug_suffix] + + self.cpp_info.components["ginkgo_reference"].set_property("cmake_target_name", "Ginkgo::ginkgo_reference") + self.cpp_info.components["ginkgo_reference"].libs = [ + "ginkgo_reference" + debug_suffix] + + if has_dpcpp_device: # Always add these components + # See https://github.com/conan-io/conan-center-index/pull/7044#discussion_r698181588 + self.cpp_info.components["ginkgo_core"].requires += ["ginkgo_dpcpp"] + self.cpp_info.components["ginkgo_core"].requires += ["ginkgo_device"] + + self.cpp_info.components["ginkgo_dpcpp"].set_property("cmake_target_name", "Ginkgo::ginkgo_dpcpp") + self.cpp_info.components["ginkgo_dpcpp"].libs = [ + "ginkgo_dpcpp" + debug_suffix] + + self.cpp_info.components["ginkgo_device"].set_property("cmake_target_name", "Ginkgo::ginkgo_device") + self.cpp_info.components["ginkgo_device"].libs = [ + "ginkgo_device" + debug_suffix] + + self.cpp_info.components["ginkgo_omp"].requires += [ + "ginkgo_dpcpp", "ginkgo_device"] + self.cpp_info.components["ginkgo_reference"].requires += ["ginkgo_device"] + self.cpp_info.components["ginkgo_hip"].requires += ["ginkgo_device"] + self.cpp_info.components["ginkgo_cuda"].requires += ["ginkgo_device"] + self.cpp_info.components["ginkgo_dpcpp"].requires += ["ginkgo_device"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "Ginkgo" + self.cpp_info.names["cmake_find_package_multi"] = "Ginkgo" + self.cpp_info.components["ginkgo_core"].names["cmake_find_package"] = "ginkgo" + self.cpp_info.components["ginkgo_core"].names["cmake_find_package_multi"] = "ginkgo" diff --git a/recipes/ginkgo/all/patches/windows-symbols.patch b/recipes/ginkgo/all/patches/windows-symbols.patch new file mode 100644 index 0000000000000..ea60add6e6c1f --- /dev/null +++ b/recipes/ginkgo/all/patches/windows-symbols.patch @@ -0,0 +1,710 @@ +diff --git a/core/base/array.cpp b/core/base/array.cpp +index 0f31b3d9ba7..3a2ad7b5568 100644 +--- a/core/base/array.cpp ++++ b/core/base/array.cpp +@@ -42,20 +42,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + namespace gko { + namespace conversion { ++namespace { + + + GKO_REGISTER_OPERATION(convert, components::convert_precision); + + ++} // anonymous namespace + } // namespace conversion + + + namespace array { ++namespace { + + + GKO_REGISTER_OPERATION(fill_array, components::fill_array); + + ++} // anonymous namespace + } // namespace array + + +diff --git a/core/base/composition.cpp b/core/base/composition.cpp +index d383b0174b6..3a67a8ebff6 100644 +--- a/core/base/composition.cpp ++++ b/core/base/composition.cpp +@@ -46,11 +46,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + namespace gko { + namespace composition { ++namespace { + + + GKO_REGISTER_OPERATION(fill_array, components::fill_array); + + ++} // anonymous namespace + } // namespace composition + + +diff --git a/core/factorization/ic.cpp b/core/factorization/ic.cpp +index 3c8b6dd29ba..34bbbcb048d 100644 +--- a/core/factorization/ic.cpp ++++ b/core/factorization/ic.cpp +@@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace factorization { + namespace ic_factorization { ++namespace { + + + GKO_REGISTER_OPERATION(compute, ic_factorization::compute); +@@ -58,6 +59,7 @@ GKO_REGISTER_OPERATION(initialize_row_ptrs_l, + GKO_REGISTER_OPERATION(initialize_l, factorization::initialize_l); + + ++} // anonymous namespace + } // namespace ic_factorization + + +diff --git a/core/factorization/ilu.cpp b/core/factorization/ilu.cpp +index 1518853b9b8..8359bf3f465 100644 +--- a/core/factorization/ilu.cpp ++++ b/core/factorization/ilu.cpp +@@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace factorization { + namespace ilu_factorization { ++namespace { + + + GKO_REGISTER_OPERATION(compute_ilu, ilu_factorization::compute_lu); +@@ -58,6 +59,7 @@ GKO_REGISTER_OPERATION(initialize_row_ptrs_l_u, + GKO_REGISTER_OPERATION(initialize_l_u, factorization::initialize_l_u); + + ++} // anonymous namespace + } // namespace ilu_factorization + + +diff --git a/core/factorization/par_ic.cpp b/core/factorization/par_ic.cpp +index 33e40d85bb0..6266816a059 100644 +--- a/core/factorization/par_ic.cpp ++++ b/core/factorization/par_ic.cpp +@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace factorization { + namespace par_ic_factorization { ++namespace { + + + GKO_REGISTER_OPERATION(add_diagonal_elements, +@@ -66,6 +67,7 @@ GKO_REGISTER_OPERATION(csr_transpose, csr::transpose); + GKO_REGISTER_OPERATION(convert_to_coo, csr::convert_to_coo); + + ++} // anonymous namespace + } // namespace par_ic_factorization + + +diff --git a/core/factorization/par_ict.cpp b/core/factorization/par_ict.cpp +index 69025ecd305..93050b5c67a 100644 +--- a/core/factorization/par_ict.cpp ++++ b/core/factorization/par_ict.cpp +@@ -57,6 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace factorization { + namespace par_ict_factorization { ++namespace { + + + GKO_REGISTER_OPERATION(threshold_select, +@@ -77,6 +78,7 @@ GKO_REGISTER_OPERATION(convert_to_coo, csr::convert_to_coo); + GKO_REGISTER_OPERATION(spgemm, csr::spgemm); + + ++} // anonymous namespace + } // namespace par_ict_factorization + + +diff --git a/core/factorization/par_ilu.cpp b/core/factorization/par_ilu.cpp +index 3b5bf605a4c..995902b9bb4 100644 +--- a/core/factorization/par_ilu.cpp ++++ b/core/factorization/par_ilu.cpp +@@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace factorization { + namespace par_ilu_factorization { ++namespace { + + + GKO_REGISTER_OPERATION(add_diagonal_elements, +@@ -64,6 +65,7 @@ GKO_REGISTER_OPERATION(compute_l_u_factors, + GKO_REGISTER_OPERATION(csr_transpose, csr::transpose); + + ++} // anonymous namespace + } // namespace par_ilu_factorization + + +diff --git a/core/factorization/par_ilut.cpp b/core/factorization/par_ilut.cpp +index 69370659cc3..3cd7f12b0f7 100644 +--- a/core/factorization/par_ilut.cpp ++++ b/core/factorization/par_ilut.cpp +@@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace factorization { + namespace par_ilut_factorization { ++namespace { + + + GKO_REGISTER_OPERATION(threshold_select, +@@ -77,6 +78,7 @@ GKO_REGISTER_OPERATION(convert_to_coo, csr::convert_to_coo); + GKO_REGISTER_OPERATION(spgemm, csr::spgemm); + + ++} // anonymous namespace + } // namespace par_ilut_factorization + + +diff --git a/core/matrix/coo.cpp b/core/matrix/coo.cpp +index efa2b160a92..4eda43b2dd8 100644 +--- a/core/matrix/coo.cpp ++++ b/core/matrix/coo.cpp +@@ -53,9 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + namespace gko { + namespace matrix { +- +- + namespace coo { ++namespace { + + + GKO_REGISTER_OPERATION(spmv, coo::spmv); +@@ -72,6 +71,7 @@ GKO_REGISTER_OPERATION(outplace_absolute_array, + components::outplace_absolute_array); + + ++} // anonymous namespace + } // namespace coo + + +diff --git a/core/matrix/csr.cpp b/core/matrix/csr.cpp +index cd09474cf63..571a90ca351 100644 +--- a/core/matrix/csr.cpp ++++ b/core/matrix/csr.cpp +@@ -55,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace matrix { + namespace csr { ++namespace { + + + GKO_REGISTER_OPERATION(spmv, csr::spmv); +@@ -90,6 +91,7 @@ GKO_REGISTER_OPERATION(outplace_absolute_array, + components::outplace_absolute_array); + + ++} // anonymous namespace + } // namespace csr + + +diff --git a/core/matrix/dense.cpp b/core/matrix/dense.cpp +index abf0fe57ac5..ef997adbaf7 100644 +--- a/core/matrix/dense.cpp ++++ b/core/matrix/dense.cpp +@@ -59,6 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace matrix { + namespace dense { ++namespace { + + + GKO_REGISTER_OPERATION(simple_apply, dense::simple_apply); +@@ -102,6 +103,7 @@ GKO_REGISTER_OPERATION(get_real, dense::get_real); + GKO_REGISTER_OPERATION(get_imag, dense::get_imag); + + ++} // anonymous namespace + } // namespace dense + + +diff --git a/core/matrix/diagonal.cpp b/core/matrix/diagonal.cpp +index 8a6d36a8759..9f158bc1650 100644 +--- a/core/matrix/diagonal.cpp ++++ b/core/matrix/diagonal.cpp +@@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace matrix { + namespace diagonal { ++namespace { + + + GKO_REGISTER_OPERATION(apply_to_dense, diagonal::apply_to_dense); +@@ -60,6 +61,7 @@ GKO_REGISTER_OPERATION(outplace_absolute_array, + components::outplace_absolute_array); + + ++} // anonymous namespace + } // namespace diagonal + + +diff --git a/core/matrix/ell.cpp b/core/matrix/ell.cpp +index fcb198106cd..5cd026c6310 100644 +--- a/core/matrix/ell.cpp ++++ b/core/matrix/ell.cpp +@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace matrix { + namespace ell { ++namespace { + + + GKO_REGISTER_OPERATION(spmv, ell::spmv); +@@ -70,6 +71,7 @@ GKO_REGISTER_OPERATION(outplace_absolute_array, + components::outplace_absolute_array); + + ++} // anonymous namespace + } // namespace ell + + +diff --git a/core/matrix/fbcsr.cpp b/core/matrix/fbcsr.cpp +index 9e4a264b3e6..8911b72ff43 100644 +--- a/core/matrix/fbcsr.cpp ++++ b/core/matrix/fbcsr.cpp +@@ -57,6 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace matrix { + namespace fbcsr { ++namespace { + + + GKO_REGISTER_OPERATION(spmv, fbcsr::spmv); +@@ -80,6 +81,7 @@ GKO_REGISTER_OPERATION(outplace_absolute_array, + components::outplace_absolute_array); + + ++} // anonymous namespace + } // namespace fbcsr + + +diff --git a/core/matrix/hybrid.cpp b/core/matrix/hybrid.cpp +index f6cf69f2955..7ad40dfe529 100644 +--- a/core/matrix/hybrid.cpp ++++ b/core/matrix/hybrid.cpp +@@ -54,6 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace matrix { + namespace hybrid { ++namespace { + + + GKO_REGISTER_OPERATION(convert_to_dense, hybrid::convert_to_dense); +@@ -68,6 +69,7 @@ GKO_REGISTER_OPERATION(outplace_absolute_array, + components::outplace_absolute_array); + + ++} // anonymous namespace + } // namespace hybrid + + +diff --git a/core/matrix/sellp.cpp b/core/matrix/sellp.cpp +index 07542e3ab40..d51b0fb04c7 100644 +--- a/core/matrix/sellp.cpp ++++ b/core/matrix/sellp.cpp +@@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace matrix { + namespace sellp { ++namespace { + + + GKO_REGISTER_OPERATION(spmv, sellp::spmv); +@@ -66,6 +67,7 @@ GKO_REGISTER_OPERATION(outplace_absolute_array, + components::outplace_absolute_array); + + ++} // anonymous namespace + } // namespace sellp + + +diff --git a/core/matrix/sparsity_csr.cpp b/core/matrix/sparsity_csr.cpp +index d253792c6a3..e5a45557934 100644 +--- a/core/matrix/sparsity_csr.cpp ++++ b/core/matrix/sparsity_csr.cpp +@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace matrix { + namespace sparsity_csr { ++namespace { + + + GKO_REGISTER_OPERATION(spmv, sparsity_csr::spmv); +@@ -62,6 +63,7 @@ GKO_REGISTER_OPERATION(is_sorted_by_column_index, + sparsity_csr::is_sorted_by_column_index); + + ++} // anonymous namespace + } // namespace sparsity_csr + + +diff --git a/core/multigrid/amgx_pgm.cpp b/core/multigrid/amgx_pgm.cpp +index e38d10d27c3..ff4e2423636 100644 +--- a/core/multigrid/amgx_pgm.cpp ++++ b/core/multigrid/amgx_pgm.cpp +@@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace multigrid { + namespace amgx_pgm { ++namespace { + + + GKO_REGISTER_OPERATION(match_edge, amgx_pgm::match_edge); +@@ -64,6 +65,7 @@ GKO_REGISTER_OPERATION(fill_array, components::fill_array); + GKO_REGISTER_OPERATION(fill_seq_array, components::fill_seq_array); + + ++} // anonymous namespace + } // namespace amgx_pgm + + +diff --git a/core/preconditioner/isai.cpp b/core/preconditioner/isai.cpp +index 7247b9a04e7..4ee7d718db3 100644 +--- a/core/preconditioner/isai.cpp ++++ b/core/preconditioner/isai.cpp +@@ -58,6 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace preconditioner { + namespace isai { ++namespace { + + + GKO_REGISTER_OPERATION(generate_tri_inverse, isai::generate_tri_inverse); +@@ -71,6 +72,7 @@ GKO_REGISTER_OPERATION(initialize_row_ptrs_l, + GKO_REGISTER_OPERATION(initialize_l, factorization::initialize_l); + + ++} // anonymous namespace + } // namespace isai + + +diff --git a/core/preconditioner/jacobi.cpp b/core/preconditioner/jacobi.cpp +index d62d97ec0b5..d908a7e0ac3 100644 +--- a/core/preconditioner/jacobi.cpp ++++ b/core/preconditioner/jacobi.cpp +@@ -55,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace preconditioner { + namespace jacobi { ++namespace { + + + GKO_REGISTER_OPERATION(simple_apply, jacobi::simple_apply); +@@ -73,6 +74,7 @@ GKO_REGISTER_OPERATION(scalar_convert_to_dense, + GKO_REGISTER_OPERATION(initialize_precisions, jacobi::initialize_precisions); + + ++} // anonymous namespace + } // namespace jacobi + + +diff --git a/core/reorder/rcm.cpp b/core/reorder/rcm.cpp +index f2ec8f0fd63..7224bad4ef3 100644 +--- a/core/reorder/rcm.cpp ++++ b/core/reorder/rcm.cpp +@@ -54,12 +54,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace reorder { + namespace rcm { ++namespace { + + + GKO_REGISTER_OPERATION(get_permutation, rcm::get_permutation); + GKO_REGISTER_OPERATION(get_degree_of_nodes, rcm::get_degree_of_nodes); + + ++} // anonymous namespace + } // namespace rcm + + +diff --git a/core/solver/bicg.cpp b/core/solver/bicg.cpp +index f79832dedc0..0f67a4f1ce1 100644 +--- a/core/solver/bicg.cpp ++++ b/core/solver/bicg.cpp +@@ -47,9 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + namespace gko { + namespace solver { +- +- + namespace bicg { ++namespace { + + + GKO_REGISTER_OPERATION(initialize, bicg::initialize); +@@ -57,6 +56,7 @@ GKO_REGISTER_OPERATION(step_1, bicg::step_1); + GKO_REGISTER_OPERATION(step_2, bicg::step_2); + + ++} // anonymous namespace + } // namespace bicg + + +diff --git a/core/solver/bicgstab.cpp b/core/solver/bicgstab.cpp +index 7c8c852fa11..cf583b5dbd6 100644 +--- a/core/solver/bicgstab.cpp ++++ b/core/solver/bicgstab.cpp +@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace solver { + namespace bicgstab { ++namespace { + + + GKO_REGISTER_OPERATION(initialize, bicgstab::initialize); +@@ -56,6 +57,7 @@ GKO_REGISTER_OPERATION(step_3, bicgstab::step_3); + GKO_REGISTER_OPERATION(finalize, bicgstab::finalize); + + ++} // anonymous namespace + } // namespace bicgstab + + +diff --git a/core/solver/cb_gmres.cpp b/core/solver/cb_gmres.cpp +index 8478ea49b5e..104d77ccbbb 100644 +--- a/core/solver/cb_gmres.cpp ++++ b/core/solver/cb_gmres.cpp +@@ -54,9 +54,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + namespace gko { + namespace solver { +- +- + namespace cb_gmres { ++namespace { + + + GKO_REGISTER_OPERATION(initialize_1, cb_gmres::initialize_1); +@@ -65,6 +64,7 @@ GKO_REGISTER_OPERATION(step_1, cb_gmres::step_1); + GKO_REGISTER_OPERATION(step_2, cb_gmres::step_2); + + ++} // anonymous namespace + } // namespace cb_gmres + + +diff --git a/core/solver/cg.cpp b/core/solver/cg.cpp +index 4dc624584e8..ae0fb37f2a9 100644 +--- a/core/solver/cg.cpp ++++ b/core/solver/cg.cpp +@@ -47,9 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + namespace gko { + namespace solver { +- +- + namespace cg { ++namespace { + + + GKO_REGISTER_OPERATION(initialize, cg::initialize); +@@ -57,6 +56,7 @@ GKO_REGISTER_OPERATION(step_1, cg::step_1); + GKO_REGISTER_OPERATION(step_2, cg::step_2); + + ++} // anonymous namespace + } // namespace cg + + +diff --git a/core/solver/cgs.cpp b/core/solver/cgs.cpp +index c33a3b7b9c1..16589ffbeb3 100644 +--- a/core/solver/cgs.cpp ++++ b/core/solver/cgs.cpp +@@ -46,9 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + namespace gko { + namespace solver { +- +- + namespace cgs { ++namespace { + + + GKO_REGISTER_OPERATION(initialize, cgs::initialize); +@@ -57,6 +56,7 @@ GKO_REGISTER_OPERATION(step_2, cgs::step_2); + GKO_REGISTER_OPERATION(step_3, cgs::step_3); + + ++} // anonymous namespace + } // namespace cgs + + +diff --git a/core/solver/fcg.cpp b/core/solver/fcg.cpp +index ee1eff61434..fc081a21b23 100644 +--- a/core/solver/fcg.cpp ++++ b/core/solver/fcg.cpp +@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace solver { + namespace fcg { ++namespace { + + + GKO_REGISTER_OPERATION(initialize, fcg::initialize); +@@ -54,6 +55,7 @@ GKO_REGISTER_OPERATION(step_1, fcg::step_1); + GKO_REGISTER_OPERATION(step_2, fcg::step_2); + + ++} // anonymous namespace + } // namespace fcg + + +diff --git a/core/solver/gmres.cpp b/core/solver/gmres.cpp +index ac0c484a34b..f5e933631c8 100644 +--- a/core/solver/gmres.cpp ++++ b/core/solver/gmres.cpp +@@ -50,9 +50,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + namespace gko { + namespace solver { +- +- + namespace gmres { ++namespace { + + + GKO_REGISTER_OPERATION(initialize_1, gmres::initialize_1); +@@ -61,6 +60,7 @@ GKO_REGISTER_OPERATION(step_1, gmres::step_1); + GKO_REGISTER_OPERATION(step_2, gmres::step_2); + + ++} // anonymous namespace + } // namespace gmres + + +diff --git a/core/solver/idr.cpp b/core/solver/idr.cpp +index 411ab892dd9..d3190414678 100644 +--- a/core/solver/idr.cpp ++++ b/core/solver/idr.cpp +@@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace solver { + namespace idr { ++namespace { + + + GKO_REGISTER_OPERATION(initialize, idr::initialize); +@@ -58,6 +59,7 @@ GKO_REGISTER_OPERATION(compute_omega, idr::compute_omega); + GKO_REGISTER_OPERATION(fill_array, components::fill_array); + + ++} // anonymous namespace + } // namespace idr + + +diff --git a/core/solver/ir.cpp b/core/solver/ir.cpp +index 5d7aa749b87..9b61d78cb33 100644 +--- a/core/solver/ir.cpp ++++ b/core/solver/ir.cpp +@@ -43,11 +43,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace solver { + namespace ir { ++namespace { + + + GKO_REGISTER_OPERATION(initialize, ir::initialize); + + ++} // anonymous namespace + } // namespace ir + + +diff --git a/core/solver/lower_trs.cpp b/core/solver/lower_trs.cpp +index 9c9f8306a92..cbe5f332f9a 100644 +--- a/core/solver/lower_trs.cpp ++++ b/core/solver/lower_trs.cpp +@@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace solver { + namespace lower_trs { ++namespace { + + + GKO_REGISTER_OPERATION(generate, lower_trs::generate); +@@ -60,6 +61,7 @@ GKO_REGISTER_OPERATION(should_perform_transpose, + GKO_REGISTER_OPERATION(solve, lower_trs::solve); + + ++} // anonymous namespace + } // namespace lower_trs + + +diff --git a/core/solver/upper_trs.cpp b/core/solver/upper_trs.cpp +index d4529fefd69..bae00182fc8 100644 +--- a/core/solver/upper_trs.cpp ++++ b/core/solver/upper_trs.cpp +@@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace solver { + namespace upper_trs { ++namespace { + + + GKO_REGISTER_OPERATION(generate, upper_trs::generate); +@@ -60,6 +61,7 @@ GKO_REGISTER_OPERATION(should_perform_transpose, + GKO_REGISTER_OPERATION(solve, upper_trs::solve); + + ++} // anonymous namespace + } // namespace upper_trs + + +diff --git a/core/stop/criterion.cpp b/core/stop/criterion.cpp +index 59d1db2839e..ca902912307 100644 +--- a/core/stop/criterion.cpp ++++ b/core/stop/criterion.cpp +@@ -39,11 +39,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace stop { + namespace criterion { ++namespace { + + + GKO_REGISTER_OPERATION(set_all_statuses, set_all_statuses::set_all_statuses); + + ++} // anonymous namespace + } // namespace criterion + + +diff --git a/core/stop/residual_norm.cpp b/core/stop/residual_norm.cpp +index 73630204a22..bd31e67caef 100644 +--- a/core/stop/residual_norm.cpp ++++ b/core/stop/residual_norm.cpp +@@ -40,21 +40,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace gko { + namespace stop { + namespace residual_norm { ++namespace { + + + GKO_REGISTER_OPERATION(residual_norm, residual_norm::residual_norm); + + ++} // anonymous namespace + } // namespace residual_norm + + + namespace implicit_residual_norm { ++namespace { + + + GKO_REGISTER_OPERATION(implicit_residual_norm, + implicit_residual_norm::implicit_residual_norm); + + ++} // anonymous namespace + } // namespace implicit_residual_norm + + diff --git a/recipes/ginkgo/all/test_package/CMakeLists.txt b/recipes/ginkgo/all/test_package/CMakeLists.txt index 8a43a12a6870a..f3372b703d4f2 100644 --- a/recipes/ginkgo/all/test_package/CMakeLists.txt +++ b/recipes/ginkgo/all/test_package/CMakeLists.txt @@ -1,11 +1,11 @@ cmake_minimum_required(VERSION 3.1) -project(test_install) +project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) find_package(Ginkgo REQUIRED CONFIG) -add_executable(test_install test_install.cpp) -target_link_libraries(test_install Ginkgo::ginkgo) -set_target_properties(test_install PROPERTIES CXX_STANDARD 14) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} Ginkgo::ginkgo) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14) diff --git a/recipes/ginkgo/all/test_package/conanfile.py b/recipes/ginkgo/all/test_package/conanfile.py index e5782e1f9ae58..38f4483872d47 100644 --- a/recipes/ginkgo/all/test_package/conanfile.py +++ b/recipes/ginkgo/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_install") + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/ginkgo/all/test_package/test_install.cpp b/recipes/ginkgo/all/test_package/test_package.cpp similarity index 100% rename from recipes/ginkgo/all/test_package/test_install.cpp rename to recipes/ginkgo/all/test_package/test_package.cpp diff --git a/recipes/ginkgo/config.yml b/recipes/ginkgo/config.yml index 426a0e4c79e9b..25c9b4921636c 100644 --- a/recipes/ginkgo/config.yml +++ b/recipes/ginkgo/config.yml @@ -1,3 +1,5 @@ versions: + "1.4.0": + folder: all "1.3.0": folder: all diff --git a/recipes/gklib/all/CMakeLists.txt b/recipes/gklib/all/CMakeLists.txt new file mode 100644 index 0000000000000..17aa471de5c7b --- /dev/null +++ b/recipes/gklib/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.4) +project(cmake_wrapper LANGUAGES C) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/gklib/all/conandata.yml b/recipes/gklib/all/conandata.yml new file mode 100644 index 0000000000000..65acd4434d084 --- /dev/null +++ b/recipes/gklib/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "5.1.1": + url: "https://github.com/KarypisLab/GKlib/archive/refs/tags/METIS-v5.1.1-DistDGL-0.5.tar.gz" + sha256: "52aa0d383d42360f4faa0ae9537ba2ca348eeab4db5f2dfd6343192d0ff4b833" +patches: + "5.1.1": + - patch_file: "patches/001-install-win32-headers.patch" + base_path: "source_subfolder" + - patch_file: "patches/002-disable-tests.patch" + base_path: "source_subfolder" + - patch_file: "patches/003-install-runtime.patch" + base_path: "source_subfolder" diff --git a/recipes/gklib/all/conanfile.py b/recipes/gklib/all/conanfile.py new file mode 100644 index 0000000000000..c9233e206a92a --- /dev/null +++ b/recipes/gklib/all/conanfile.py @@ -0,0 +1,96 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches + +required_conan_version = ">=1.43.0" + + +class GKlibConan(ConanFile): + name = "gklib" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/KarypisLab/GKlib" + description = "A library of various helper routines and frameworks" \ + " used by many of the lab's software" + topics = ("karypislab") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _is_mingw(self): + return self.settings.os == "Windows" and self.settings.compiler == "gcc" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def validate(self): + if self.options.shared and self._is_msvc: + raise ConanInvalidConfiguration( + f"{self.name} {self.version} shared not supported with Visual Studio") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + apply_conandata_patches(self) + + def _configure_cmake(self): + if not self._cmake: + self._cmake = CMake(self) + self._cmake.definitions["ASSERT"] = self.settings.build_type == "Debug" + self._cmake.definitions["ASSERT2"] = self.settings.build_type == "Debug" + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses") + + def package_info(self): + self.cpp_info.libs = ["GKlib"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + if self._is_msvc or self._is_mingw: + self.cpp_info.defines.append("USE_GKREGEX") + if self._is_msvc: + self.cpp_info.defines.append("__thread=__declspec(thread)") diff --git a/recipes/gklib/all/patches/001-install-win32-headers.patch b/recipes/gklib/all/patches/001-install-win32-headers.patch new file mode 100644 index 0000000000000..ef49a65a88c55 --- /dev/null +++ b/recipes/gklib/all/patches/001-install-win32-headers.patch @@ -0,0 +1,21 @@ +Install headers for Visual Studio +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -29,3 +29,6 @@ install(TARGETS GKlib + ARCHIVE DESTINATION lib/${LINSTALL_PATH} + LIBRARY DESTINATION lib/${LINSTALL_PATH}) + install(FILES ${GKlib_includes} DESTINATION include/${HINSTALL_PATH}) ++if(MSVC) ++ install(FILES ${GKlib_win32_includes} DESTINATION include/${HINSTALL_PATH}/win32) ++endif() +diff --git a/GKlibSystem.cmake b/GKlibSystem.cmake +index d83b208..3dc5a7b 100644 +--- a/GKlibSystem.cmake ++++ b/GKlibSystem.cmake +@@ -135,3 +135,6 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GKlib_COPTIONS} ${GKlib_COPTS}") + # Find GKlib sources. + file(GLOB GKlib_sources ${GKLIB_PATH}/*.c) + file(GLOB GKlib_includes ${GKLIB_PATH}/*.h) ++if(MSVC) ++ file(GLOB GKlib_win32_includes ${GKLIB_PATH}/win32/*.h) ++endif() diff --git a/recipes/gklib/all/patches/002-disable-tests.patch b/recipes/gklib/all/patches/002-disable-tests.patch new file mode 100644 index 0000000000000..318b570bf934c --- /dev/null +++ b/recipes/gklib/all/patches/002-disable-tests.patch @@ -0,0 +1,12 @@ +Do not build tests +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -22,8 +22,6 @@ if(UNIX) + target_link_libraries(GKlib m) + endif(UNIX) + +-include_directories("test") +-add_subdirectory("test") + + install(TARGETS GKlib + ARCHIVE DESTINATION lib/${LINSTALL_PATH} diff --git a/recipes/gklib/all/patches/003-install-runtime.patch b/recipes/gklib/all/patches/003-install-runtime.patch new file mode 100644 index 0000000000000..f0d360d1a2c59 --- /dev/null +++ b/recipes/gklib/all/patches/003-install-runtime.patch @@ -0,0 +1,11 @@ +Add install destination for runtime +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -24,6 +24,7 @@ endif(UNIX) + + + install(TARGETS GKlib ++ RUNTIME DESTINATION bin/${LINSTALL_PATH} + ARCHIVE DESTINATION lib/${LINSTALL_PATH} + LIBRARY DESTINATION lib/${LINSTALL_PATH}) + install(FILES ${GKlib_includes} DESTINATION include/${HINSTALL_PATH}) diff --git a/recipes/gklib/all/test_package/CMakeLists.txt b/recipes/gklib/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b012d77ecf242 --- /dev/null +++ b/recipes/gklib/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gklib REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} gklib::gklib) diff --git a/recipes/gklib/all/test_package/conanfile.py b/recipes/gklib/all/test_package/conanfile.py new file mode 100644 index 0000000000000..46d71712aba54 --- /dev/null +++ b/recipes/gklib/all/test_package/conanfile.py @@ -0,0 +1,24 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + self.build_requires("cmake/3.20.1") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gklib/all/test_package/test_package.c b/recipes/gklib/all/test_package/test_package.c new file mode 100644 index 0000000000000..bbc1fb69c1776 --- /dev/null +++ b/recipes/gklib/all/test_package/test_package.c @@ -0,0 +1,72 @@ +/*! +\file strings.c +\brief Testing module for the string functions in GKlib +\date Started 3/5/2007 +\author George +\version\verbatim $Id: strings.c 10711 2011-08-31 22:23:04Z karypis $ \endverbatim +*/ + +#include + + +/*************************************************************************/ +/*! Testing module for gk_strstr_replace() */ +/*************************************************************************/ +void test_strstr_replace() +{ + char *new_str; + int rc; + + rc = gk_strstr_replace("This is a simple string", "s", "S", "", &new_str); + printf("%d, %s.\n", rc, new_str); + gk_free((void **)&new_str, LTERM); + + + rc = gk_strstr_replace("This is a simple string", "s", "S", "g", &new_str); + printf("%d, %s.\n", rc, new_str); + gk_free((void **)&new_str, LTERM); + + + rc = gk_strstr_replace("This is a simple SS & ss string", "s", "T", "g", &new_str); + printf("%d, %s.\n", rc, new_str); + gk_free((void **)&new_str, LTERM); + + + rc = gk_strstr_replace("This is a simple SS & ss string", "s", "T", "ig", &new_str); + printf("%d, %s.\n", rc, new_str); + gk_free((void **)&new_str, LTERM); + + rc = gk_strstr_replace("This is a simple SS & ss string", "\\b\\w(\\w+)\\w\\b", "$1", "ig", &new_str); + printf("%d, %s.\n", rc, new_str); + gk_free((void **)&new_str, LTERM); + + rc = gk_strstr_replace("This is a simple SS & ss string", "\\b\\w+\\b", "word", "ig", &new_str); + printf("%d, %s.\n", rc, new_str); + gk_free((void **)&new_str, LTERM); + + rc = gk_strstr_replace("http://www.cs.umn.edu/This-is-something-T12323?pp=20&page=4", + "(http://www\\.cs\\.umn\\.edu/)(.*)-T(\\d+)", "$1$2-P$3", "g", &new_str); + printf("%d, %s.\n", rc, new_str); + gk_free((void **)&new_str, LTERM); + + rc = gk_strstr_replace("http://www.cs.umn.edu/This-is-something-T12323?pp=20&page=4", + "(\\d+)", "number:$1", "ig", &new_str); + printf("%d, %s.\n", rc, new_str); + gk_free((void **)&new_str, LTERM); + + + rc = gk_strstr_replace("http://www.cs.umn.edu/This-is-something-T12323?pp=20&page=4", + "(http://www\\.cs\\.umn\\.edu/)", "[$1]", "g", &new_str); + printf("%d, %s.\n", rc, new_str); + gk_free((void **)&new_str, LTERM); +} + +void test_gk_cur_jbufs_linking(void) { + printf("%d", gk_cur_jbufs); +} + +int main() +{ + test_strstr_replace(); + test_gk_cur_jbufs_linking(); +} diff --git a/recipes/gklib/config.yml b/recipes/gklib/config.yml new file mode 100644 index 0000000000000..e7148244c2a2f --- /dev/null +++ b/recipes/gklib/config.yml @@ -0,0 +1,3 @@ +versions: + "5.1.1": + folder: all diff --git a/recipes/glad/all/conandata.yml b/recipes/glad/all/conandata.yml index 51e42df9afb21..e0ca7c0f4e158 100644 --- a/recipes/glad/all/conandata.yml +++ b/recipes/glad/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "0.1.36": + url: "https://github.com/Dav1dde/glad/archive/v0.1.36.tar.gz" + sha256: "8470ed1b0e9fbe88e10c34770505c8a1dc8ccb78cadcf673331aaf5224f963d2" + "0.1.35": + url: "https://github.com/Dav1dde/glad/archive/v0.1.35.tar.gz" + sha256: "5fc384062960bc38f26128b9bfef3c667e405e592f121a235ecbecb20f8ec8af" "0.1.34": url: "https://github.com/Dav1dde/glad/archive/v0.1.34.tar.gz" sha256: "4be2900ff76ac71a2aab7a8be301eb4c0338491c7e205693435b09aad4969ecd" @@ -6,6 +12,12 @@ sources: url: "https://github.com/Dav1dde/glad/archive/v0.1.33.tar.gz" sha256: "4bc850062e9bcfc182bd4095d45b987517507d8ec0edcc424ed58f67b4ea9e37" patches: + "0.1.36": + - patch_file: "patches/0003-CMake-handle-all-specs.patch" + base_path: "source_subfolder" + "0.1.35": + - patch_file: "patches/0003-CMake-handle-all-specs.patch" + base_path: "source_subfolder" "0.1.34": - patch_file: "patches/0002-CMake-handle-all-specs.patch" base_path: "source_subfolder" diff --git a/recipes/glad/all/patches/0003-CMake-handle-all-specs.patch b/recipes/glad/all/patches/0003-CMake-handle-all-specs.patch new file mode 100644 index 0000000000000..92a43a1a5cf8d --- /dev/null +++ b/recipes/glad/all/patches/0003-CMake-handle-all-specs.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0466e11..0726557 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -90,10 +90,17 @@ else() + foreach(spec ${spec_list}) + if(${spec} STREQUAL "gl") + list(APPEND GLAD_HEADERS "${GLAD_INCLUDE_DIRS}/glad/glad.h") +- list(APPEND GLAD_SOURCES +- "${GLAD_INCLUDE_DIRS}/glad/glad.h" +- "${GLAD_OUT_DIR}/src/glad.c" +- ) ++ if(GLAD_SPEC STREQUAL "gl") ++ list(APPEND GLAD_SOURCES ++ "${GLAD_OUT_DIR}/src/glad.c" ++ "${GLAD_INCLUDE_DIRS}/glad/glad.h" ++ ) ++ else() ++ list(APPEND GLAD_SOURCES ++ "${GLAD_OUT_DIR}/src/glad_${GLAD_SPEC}.c" ++ "${GLAD_INCLUDE_DIRS}/glad/glad_${GLAD_SPEC}.h" ++ ) ++ endif() + else() + list(APPEND GLAD_HEADERS "${GLAD_INCLUDE_DIRS}/glad/glad_${spec}.h") + list(APPEND GLAD_SOURCES diff --git a/recipes/glad/config.yml b/recipes/glad/config.yml index 1bbe0f17b00c8..20bf40ac113d1 100644 --- a/recipes/glad/config.yml +++ b/recipes/glad/config.yml @@ -1,4 +1,8 @@ versions: + "0.1.36": + folder: all + "0.1.35": + folder: all "0.1.34": folder: all "0.1.33": diff --git a/recipes/glaze/all/conandata.yml b/recipes/glaze/all/conandata.yml new file mode 100644 index 0000000000000..8e87549aa8761 --- /dev/null +++ b/recipes/glaze/all/conandata.yml @@ -0,0 +1,22 @@ +sources: + "0.1.8": + url: "https://github.com/stephenberry/glaze/archive/v0.1.8.tar.gz" + sha256: "8268ec2a8e0f2d9de2e65830ad9f7a623577c7bd47d465d4c6e4bed9d266ad48" + "0.1.7": + url: "https://github.com/stephenberry/glaze/archive/v0.1.7.tar.gz" + sha256: "7dc31ceaa444fd92339a48a69be638e92daa2858c3228f347b1df54a824b8f62" + "0.1.4": + url: "https://github.com/stephenberry/glaze/archive/v0.1.4.tar.gz" + sha256: "dd46e77973fe5b3cf4cd68fd597ba6b1010ecffd3e10cd8ccbd6cd615e6ffaff" + "0.1.3": + url: "https://github.com/stephenberry/glaze/archive/v0.1.3.tar.gz" + sha256: "291e71244bf6fde5e57daf53d8e2fdd4793a7e93fe68c546f746f43a0e534d07" + "0.1.2": + url: "https://github.com/stephenberry/glaze/archive/v0.1.2.tar.gz" + sha256: "5de894dbad95a773a7b1e3c43eeb42ec79bf30bc04355d4d055db0cba1ae52db" + "0.1.0": + url: "https://github.com/stephenberry/glaze/archive/v0.1.0.tar.gz" + sha256: "bb709637217b68c835c5c17d49d6e1d10682a9fb5d3899b4452f737f64961a67" + "0.0.7": + url: "https://github.com/stephenberry/glaze/archive/refs/tags/v0.0.7.tar.gz" + sha256: "124f7e8fea58c012b548ba1b643684fe428c7dbfeb8d8a5f701eb7db4356a759" diff --git a/recipes/glaze/all/conanfile.py b/recipes/glaze/all/conanfile.py new file mode 100644 index 0000000000000..0b0ed09d3669b --- /dev/null +++ b/recipes/glaze/all/conanfile.py @@ -0,0 +1,82 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.51.1" + +class GlazeConan(ConanFile): + name = "glaze" + description = "Extremely fast, in memory, JSON and interface library for modern C++" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/stephenberry/glaze" + topics = ("json", "memory", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _minimum_cpp_standard(self): + return 20 + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "16", + "msvc": "192", + "gcc": "11", + "clang": "12", + "apple-clang": "13.1", + } + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("fmt/9.1.0") + self.requires("fast_float/3.8.1") + self.requires("frozen/1.1.1") + self.requires("nanorange/20200505") + if Version(self.version) >= "0.1.5": + self.requires("dragonbox/1.1.3") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._minimum_cpp_standard}, which your compiler does not support.", + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy( + self, + pattern="*.hpp", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include"), + ) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/glaze/all/test_package/CMakeLists.txt b/recipes/glaze/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..4811c5114c3c2 --- /dev/null +++ b/recipes/glaze/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) + +find_package(glaze REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE glaze::glaze) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) diff --git a/recipes/glaze/all/test_package/conanfile.py b/recipes/glaze/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/glaze/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/glaze/all/test_package/test_package.cpp b/recipes/glaze/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..19dbb41c1ae8f --- /dev/null +++ b/recipes/glaze/all/test_package/test_package.cpp @@ -0,0 +1,33 @@ +#include "glaze/glaze.hpp" +#include "glaze/json/json_ptr.hpp" +#include "glaze/api/impl.hpp" + +struct my_struct +{ + int i = 287; + double d = 3.14; + std::string hello = "Hello World"; + std::array arr = { 1, 2, 3 }; +}; + +template <> +struct glz::meta { + using T = my_struct; + static constexpr auto value = object( + "i", &T::i, + "d", &T::d, + "hello", &T::hello, + "arr", &T::arr + ); +}; + +int main(void) { + std::string buffer = R"({"i":287,"d":3.14,"hello":"Hello World","arr":[1,2,3]})"; + auto s = glz::read_json(buffer); + + (void)s.d; + (void)s.hello; + (void)s.arr; + + return 0; +} diff --git a/recipes/glaze/all/test_v1_package/CMakeLists.txt b/recipes/glaze/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9652e22fc19d5 --- /dev/null +++ b/recipes/glaze/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.12) + +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/glaze/all/test_v1_package/conanfile.py b/recipes/glaze/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/glaze/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/glaze/config.yml b/recipes/glaze/config.yml new file mode 100644 index 0000000000000..fadabfa051e7c --- /dev/null +++ b/recipes/glaze/config.yml @@ -0,0 +1,15 @@ +versions: + "0.1.8": + folder: all + "0.1.7": + folder: all + "0.1.4": + folder: all + "0.1.3": + folder: all + "0.1.2": + folder: all + "0.1.0": + folder: all + "0.0.7": + folder: all diff --git a/recipes/glbinding/all/CMakeLists.txt b/recipes/glbinding/all/CMakeLists.txt deleted file mode 100644 index 361b35d4c17d9..0000000000000 --- a/recipes/glbinding/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/glbinding/all/conandata.yml b/recipes/glbinding/all/conandata.yml index b76c1679b402b..c3868ee88cb4c 100644 --- a/recipes/glbinding/all/conandata.yml +++ b/recipes/glbinding/all/conandata.yml @@ -5,4 +5,4 @@ sources: patches: "3.1.0": - patch_file: "patches/cmake-install.patch" - base_path: "source_subfolder" + - patch_file: "patches/getProcAddr.patch" diff --git a/recipes/glbinding/all/conanfile.py b/recipes/glbinding/all/conanfile.py index 1e7133e4202b2..995638a6477cf 100644 --- a/recipes/glbinding/all/conanfile.py +++ b/recipes/glbinding/all/conanfile.py @@ -1,26 +1,33 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file, rmdir import os +required_conan_version = ">=1.50.0" + class GlbindingConan(ConanFile): name = "glbinding" description = "A C++ binding for the OpenGL API, generated using the gl.xml specification." license = "MIT" - topics = ("conan", "glbinding", "opengl", "binding") + topics = ("glbinding", "opengl", "binding") homepage = "https://glbinding.org/" url = "https://github.com/conan-io/conan-center-index" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - _cmake = None + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -29,70 +36,85 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["OPTION_SELF_CONTAINED"] = False + tc.variables["OPTION_BUILD_TESTS"] = False + tc.variables["OPTION_BUILD_DOCS"] = False + tc.variables["OPTION_BUILD_TOOLS"] = False + tc.variables["OPTION_BUILD_EXAMPLES"] = False + tc.variables["OPTION_BUILD_WITH_BOOST_THREAD"] = False + tc.variables["OPTION_BUILD_CHECK"] = False + # TODO: might be a good idea to fix upstream CMakeLists to not rely on + # WriteCompilerDetectionHeader, and just use cxx_std_11 compile feature + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0120"] = "OLD" + tc.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) + compile_options = os.path.join(self.source_folder, "cmake", "CompileOptions.cmake") + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") # Don't force PIC - tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "CompileOptions.cmake"), - "POSITION_INDEPENDENT_CODE ON", "") + replace_in_file(self, compile_options, "POSITION_INDEPENDENT_CODE ON", "") # Don't replace /W3 by /W4 - tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "CompileOptions.cmake"), - "/W4", "") + replace_in_file(self, compile_options, "/W4", "") # No whole program optimization - tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "CompileOptions.cmake"), - "/GL", "") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["OPTION_SELF_CONTAINED"] = False - self._cmake.definitions["OPTION_BUILD_TESTS"] = False - self._cmake.definitions["OPTION_BUILD_DOCS"] = False - self._cmake.definitions["OPTION_BUILD_TOOLS"] = False - self._cmake.definitions["OPTION_BUILD_EXAMPLES"] = False - self._cmake.definitions["OPTION_BUILD_WITH_BOOST_THREAD"] = False - self._cmake.definitions["OPTION_BUILD_CHECK"] = False - self._cmake.configure() - return self._cmake + replace_in_file(self, compile_options, "/GL", "") + # Don't populate rpath + replace_in_file(self, cmakelists, "if(NOT SYSTEM_DIR_INSTALL)", "if(0)") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "cmake")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "glbinding" - self.cpp_info.names["cmake_find_package_multi"] = "glbinding" + self.cpp_info.set_property("cmake_file_name", "glbinding") suffix = "d" if self.settings.build_type == "Debug" else "" # glbinding - self.cpp_info.components["_glbinding"].names["cmake_find_package"] = "glbinding" - self.cpp_info.components["_glbinding"].names["cmake_find_package_multi"] = "glbinding" + self.cpp_info.components["_glbinding"].set_property("cmake_target_name", "glbinding::glbinding") self.cpp_info.components["_glbinding"].libs = ["glbinding" + suffix] self.cpp_info.components["_glbinding"].requires = ["khrplatform"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["_glbinding"].system_libs = ["dl", "pthread"] # glbinding-aux - self.cpp_info.components["glbinding-aux"].names["cmake_find_package"] = "glbinding-aux" - self.cpp_info.components["glbinding-aux"].names["cmake_find_package_multi"] = "glbinding-aux" + self.cpp_info.components["glbinding-aux"].set_property("cmake_target_name", "glbinding::glbinding-aux") self.cpp_info.components["glbinding-aux"].libs = ["glbinding-aux" + suffix] self.cpp_info.components["glbinding-aux"].requires = ["_glbinding"] # KHRplatform + self.cpp_info.components["khrplatform"].set_property("cmake_target_name", "glbinding::KHRplatform") + self.cpp_info.components["khrplatform"].libdirs = [] + + # workaround to propagate all components in CMakeDeps generator + self.cpp_info.set_property("cmake_target_name", "glbinding::glbinding-aux") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "glbinding" + self.cpp_info.names["cmake_find_package_multi"] = "glbinding" + self.cpp_info.components["_glbinding"].names["cmake_find_package"] = "glbinding" + self.cpp_info.components["_glbinding"].names["cmake_find_package_multi"] = "glbinding" + self.cpp_info.components["glbinding-aux"].names["cmake_find_package"] = "glbinding-aux" + self.cpp_info.components["glbinding-aux"].names["cmake_find_package_multi"] = "glbinding-aux" self.cpp_info.components["khrplatform"].names["cmake_find_package"] = "KHRplatform" self.cpp_info.components["khrplatform"].names["cmake_find_package_multi"] = "KHRplatform" - self.cpp_info.components["khrplatform"].libdirs = [] diff --git a/recipes/glbinding/all/patches/getProcAddr.patch b/recipes/glbinding/all/patches/getProcAddr.patch new file mode 100644 index 0000000000000..6ce27e5135994 --- /dev/null +++ b/recipes/glbinding/all/patches/getProcAddr.patch @@ -0,0 +1,21 @@ +--- a/source/glbinding/source/getProcAddress.cpp ++++ b/source/glbinding/source/getProcAddress.cpp +@@ -21,7 +21,7 @@ ProcAddress getProcAddress(const char * name) + static auto module = LoadLibrary(_T("OPENGL32.DLL")); + + // Prevent static linking of opengl32 +- static auto wglGetProcAddress_ = reinterpret_cast(::GetProcAddress(module, "wglGetProcAddress")); ++ static auto wglGetProcAddress_ = reinterpret_cast((uintptr_t)::GetProcAddress(module, "wglGetProcAddress")); + assert(wglGetProcAddress_ != nullptr); + + auto procAddress = wglGetProcAddress_(name); +@@ -30,7 +30,7 @@ ProcAddress getProcAddress(const char * name) + return reinterpret_cast(procAddress); + } + +- procAddress = ::GetProcAddress(module, name); ++ procAddress = (void*)::GetProcAddress(module, name); + return reinterpret_cast(procAddress); + } + + diff --git a/recipes/glbinding/all/test_package/CMakeLists.txt b/recipes/glbinding/all/test_package/CMakeLists.txt index 4838c8dc3dd91..ff080ea67fff7 100644 --- a/recipes/glbinding/all/test_package/CMakeLists.txt +++ b/recipes/glbinding/all/test_package/CMakeLists.txt @@ -1,11 +1,9 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(glbinding REQUIRED CONFIG) +find_package(glfw3 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} glbinding::glbinding CONAN_PKG::glfw) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE glbinding::glbinding glfw) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/glbinding/all/test_package/conanfile.py b/recipes/glbinding/all/test_package/conanfile.py index 87d56dad8f7f4..1a18c15c05fda 100644 --- a/recipes/glbinding/all/test_package/conanfile.py +++ b/recipes/glbinding/all/test_package/conanfile.py @@ -1,13 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" def requirements(self): - self.requires("glfw/3.3.2") + self.requires(self.tested_reference_str) + self.requires("glfw/3.3.8") + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -15,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/glbinding/all/test_v1_package/CMakeLists.txt b/recipes/glbinding/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d7d5df21ee2a2 --- /dev/null +++ b/recipes/glbinding/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(glbinding REQUIRED CONFIG) +find_package(glfw3 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE glbinding::glbinding glfw) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/glbinding/all/test_v1_package/conanfile.py b/recipes/glbinding/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..da42acb6c46c8 --- /dev/null +++ b/recipes/glbinding/all/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def requirements(self): + self.requires("glfw/3.3.8") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/glew/all/CMakeLists.txt b/recipes/glew/all/CMakeLists.txt deleted file mode 100644 index ca89317f027dc..0000000000000 --- a/recipes/glew/all/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.0) -project(conan_glew) - -include("conanbuildinfo.cmake") -conan_basic_setup() -include(GNUInstallDirs) - -add_subdirectory("source_subfolder/build/cmake") diff --git a/recipes/glew/all/conandata.yml b/recipes/glew/all/conandata.yml index 8cfd90ad63ca0..c4c27b1a2cf9f 100644 --- a/recipes/glew/all/conandata.yml +++ b/recipes/glew/all/conandata.yml @@ -6,6 +6,14 @@ sources: sha256: "04de91e7e6763039bc11940095cd9c7f880baba82196a7765f727ac05a993c95" url: "https://github.com/nigels-com/glew/releases/download/glew-2.1.0/glew-2.1.0.tgz" patches: + "2.2.0": + - patch_file: "patches/0001-fix-cmake-2.2.0.patch" + patch_description: "Fix CMake: cmake_minimum_required() before project()" + patch_type: conan "2.1.0": - - patch_file: "patches/vs16-release-fix.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-fix-cmake-2.1.0.patch" + patch_description: "Fix CMake: cmake_minimum_required() before project()" + patch_type: conan + - patch_file: "patches/0002-vs16-release-fix.patch" + patch_type: "backport" + patch_source: "https://github.com/nigels-com/glew/commit/4bbe8aa2ab70a6eb847ee5751735422d0ba623cd" diff --git a/recipes/glew/all/conanfile.py b/recipes/glew/all/conanfile.py index 05ca6a4f16472..75e5f17da8e37 100644 --- a/recipes/glew/all/conanfile.py +++ b/recipes/glew/all/conanfile.py @@ -1,39 +1,33 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir import os -import glob -from conans import ConanFile, CMake, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.52.0" + class GlewConan(ConanFile): name = "glew" description = "The GLEW library" url = "https://github.com/conan-io/conan-center-index" homepage = "http://github.com/nigels-com/glew" - topics = ("conan", "glew", "opengl", "wrangler", "loader", "binding") + topics = ("glew", "opengl", "wrangler", "loader", "binding") license = "MIT" - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" - settings = "os", "arch", "build_type", "compiler" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "with_egl": [True, False] + "with_egl": [True, False], } default_options = { "shared": False, "fPIC": True, - "with_egl": False + "with_egl": False, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -42,52 +36,76 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): self.requires("opengl/system") self.requires("glu/system") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("%s-%s" % (self.name, self.version), self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_UTILS"] = False - self._cmake.definitions["GLEW_EGL"] = self.options.get_safe("with_egl", False) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_UTILS"] = False + tc.variables["GLEW_EGL"] = self.options.get_safe("with_egl", False) + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "build", "cmake")) cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - for pdb_file in glob.glob(os.path.join(self.package_folder, "lib", "*.pdb")): - os.remove(pdb_file) + def package_info(self): + glewlib_target_name = "glew" if self.options.shared else "glew_s" + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_module_file_name", "GLEW") + self.cpp_info.set_property("cmake_file_name", "glew") + self.cpp_info.set_property("cmake_target_name", "GLEW::GLEW") + self.cpp_info.set_property("pkg_config_name", "glew") + self.cpp_info.components["glewlib"].set_property("cmake_module_target_name", "GLEW::GLEW") + self.cpp_info.components["glewlib"].set_property("cmake_target_name", f"GLEW::{glewlib_target_name}") + self.cpp_info.components["glewlib"].set_property("pkg_config_name", "glew") - self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) + if self.settings.os == "Windows": + lib_name = "glew32" if self.options.shared else "libglew32" + else: + lib_name = "GLEW" + if self.settings.build_type == "Debug": + lib_name += "d" + self.cpp_info.components["glewlib"].libs = [lib_name] + if self.settings.os == "Windows" and not self.options.shared: + self.cpp_info.components["glewlib"].defines.append("GLEW_STATIC") + self.cpp_info.components["glewlib"].requires = ["opengl::opengl", "glu::glu"] - def package_info(self): + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.filenames["cmake_find_package"] = "GLEW" self.cpp_info.filenames["cmake_find_package_multi"] = "glew" self.cpp_info.names["cmake_find_package"] = "GLEW" self.cpp_info.names["cmake_find_package_multi"] = "GLEW" self.cpp_info.components["glewlib"].names["cmake_find_package"] = "GLEW" - self.cpp_info.components["glewlib"].names["cmake_find_package_multi"] = "glew" if self.options.shared else "glew_s" - self.cpp_info.components["glewlib"].libs = tools.collect_libs(self) - if self.settings.os == "Windows" and not self.options.shared: - self.cpp_info.components["glewlib"].defines.append("GLEW_STATIC") - self.cpp_info.components["glewlib"].requires = ["opengl::opengl", "glu::glu"] + self.cpp_info.components["glewlib"].names["cmake_find_package_multi"] = glewlib_target_name diff --git a/recipes/glew/all/patches/0001-fix-cmake-2.1.0.patch b/recipes/glew/all/patches/0001-fix-cmake-2.1.0.patch new file mode 100644 index 0000000000000..d64b6d88a9c4b --- /dev/null +++ b/recipes/glew/all/patches/0001-fix-cmake-2.1.0.patch @@ -0,0 +1,15 @@ +--- a/build/cmake/CMakeLists.txt ++++ b/build/cmake/CMakeLists.txt +@@ -1,10 +1,10 @@ ++cmake_minimum_required (VERSION 2.8.12) ++project (glew C) + if ( NOT DEFINED CMAKE_BUILD_TYPE ) + set( CMAKE_BUILD_TYPE Release CACHE STRING "Build type" ) + endif () + +-project (glew) + +-cmake_minimum_required (VERSION 2.8.12) + + include(GNUInstallDirs) + diff --git a/recipes/glew/all/patches/0001-fix-cmake-2.2.0.patch b/recipes/glew/all/patches/0001-fix-cmake-2.2.0.patch new file mode 100644 index 0000000000000..8373c5364c4dd --- /dev/null +++ b/recipes/glew/all/patches/0001-fix-cmake-2.2.0.patch @@ -0,0 +1,15 @@ +--- a/build/cmake/CMakeLists.txt ++++ b/build/cmake/CMakeLists.txt +@@ -1,10 +1,10 @@ ++cmake_minimum_required (VERSION 2.8.12) ++project (glew C) + if ( NOT DEFINED CMAKE_BUILD_TYPE ) + set( CMAKE_BUILD_TYPE Release CACHE STRING "Build type" ) + endif () + +-project (glew C) + +-cmake_minimum_required (VERSION 2.8.12) + + include(GNUInstallDirs) + diff --git a/recipes/glew/all/patches/vs16-release-fix.patch b/recipes/glew/all/patches/0002-vs16-release-fix.patch similarity index 100% rename from recipes/glew/all/patches/vs16-release-fix.patch rename to recipes/glew/all/patches/0002-vs16-release-fix.patch diff --git a/recipes/glew/all/test_package/CMakeLists.txt b/recipes/glew/all/test_package/CMakeLists.txt index 422bc6d4a3332..f7e367639f538 100644 --- a/recipes/glew/all/test_package/CMakeLists.txt +++ b/recipes/glew/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C) find_package(GLEW REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} GLEW::GLEW) +target_link_libraries(${PROJECT_NAME} PRIVATE GLEW::GLEW) diff --git a/recipes/glew/all/test_package/conanfile.py b/recipes/glew/all/test_package/conanfile.py index a831367c532bc..0a6bc68712d90 100644 --- a/recipes/glew/all/test_package/conanfile.py +++ b/recipes/glew/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,5 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/glew/all/test_v1_package/CMakeLists.txt b/recipes/glew/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..abaffb362cf82 --- /dev/null +++ b/recipes/glew/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(GLEW REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE GLEW::GLEW) diff --git a/recipes/glew/all/test_v1_package/conanfile.py b/recipes/glew/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/glew/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/glext/all/conandata.yml b/recipes/glext/all/conandata.yml new file mode 100644 index 0000000000000..c92de73c28c2b --- /dev/null +++ b/recipes/glext/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20210420": + url: "https://github.com/KhronosGroup/OpenGL-Registry/raw/8e729daa702d45597ccffa0c964bba1eca10a9e6/api/GL/glext.h" + sha256: "d19f1fd288d7e997eb797b11700e96f42344d22163a67bcae8e8747fcc5cc6b7" diff --git a/recipes/glext/all/conanfile.py b/recipes/glext/all/conanfile.py new file mode 100644 index 0000000000000..746356cd3af89 --- /dev/null +++ b/recipes/glext/all/conanfile.py @@ -0,0 +1,35 @@ +import os +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration + + +required_conan_version = ">=1.37.0" + +class GlextConan(ConanFile): + name = "glext" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.khronos.org/registry/OpenGL/index_gl.php" + description = "OpenGL 1.2 and above compatibility profile and extension interfaces" + topics = ("opengl", "gl", "glext") + no_copy_source = True + + def requirements(self): + self.requires("opengl/system") + self.requires("khrplatform/cci.20200529") + + def source(self): + tools.download(filename="glext.h", **self.conan_data["sources"][self.version]) + + def package(self): + self.copy(pattern="glext.h", dst=os.path.join("include", "GL")) + license_data = tools.load(os.path.join(self.source_folder, "glext.h")) + begin = license_data.find("/*") + len("/*") + end = license_data.find("*/") + license_data = license_data[begin:end] + license_data = license_data.replace("**", "") + tools.save("LICENSE", license_data) + self.copy("LICENSE", dst="licenses") + + def package_id(self): + self.info.header_only() diff --git a/recipes/glext/all/test_package/CMakeLists.txt b/recipes/glext/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b455e673a3ef0 --- /dev/null +++ b/recipes/glext/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(glext REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE glext::glext) diff --git a/recipes/glext/all/test_package/conanfile.py b/recipes/glext/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/glext/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/glext/all/test_package/test_package.c b/recipes/glext/all/test_package/test_package.c new file mode 100644 index 0000000000000..9d878cd4be06b --- /dev/null +++ b/recipes/glext/all/test_package/test_package.c @@ -0,0 +1,19 @@ +#include +#include + +#ifdef _MSC_VER +# include +#endif +#ifdef __APPLE__ +# include +# include +#else +# include +#endif +#include + +int main() +{ + printf("GL_GLEXT_VERSION: %d\n", GL_GLEXT_VERSION); + return EXIT_SUCCESS; +} diff --git a/recipes/glext/config.yml b/recipes/glext/config.yml new file mode 100644 index 0000000000000..f7fca403f982f --- /dev/null +++ b/recipes/glext/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210420": + folder: "all" diff --git a/recipes/glfw/all/conandata.yml b/recipes/glfw/all/conandata.yml index 7ac738bced47f..f81e146ca342e 100644 --- a/recipes/glfw/all/conandata.yml +++ b/recipes/glfw/all/conandata.yml @@ -1,4 +1,16 @@ sources: + "3.3.8": + url: "https://github.com/glfw/glfw/archive/refs/tags/3.3.8.tar.gz" + sha256: "f30f42e05f11e5fc62483e513b0488d5bceeab7d9c5da0ffe2252ad81816c713" + "3.3.7": + url: "https://github.com/glfw/glfw/archive/refs/tags/3.3.7.tar.gz" + sha256: "fd21a5f65bcc0fc3c76e0f8865776e852de09ef6fbc3620e09ce96d2b2807e04" + "3.3.6": + url: "https://github.com/glfw/glfw/archive/refs/tags/3.3.6.tar.gz" + sha256: "ed07b90e334dcd39903e6288d90fa1ae0cf2d2119fec516cf743a0a404527c02" + "3.3.5": + url: "https://github.com/glfw/glfw/archive/refs/tags/3.3.5.tar.gz" + sha256: "32fdb8705784adfe3082f97e0d41e7c515963e977b5a14c467a887cf0da827b5" "3.3.4": url: "https://github.com/glfw/glfw/archive/3.3.4.tar.gz" sha256: "cc8ac1d024a0de5fd6f68c4133af77e1918261396319c24fd697775a6bc93b63" @@ -11,4 +23,3 @@ sources: patches: "3.3.2": - patch_file: "patches/fix-objc-cmake3.19+.patch" - base_path: "source_subfolder" diff --git a/recipes/glfw/all/conanfile.py b/recipes/glfw/all/conanfile.py index 4b8b17d13da58..f263935f089e9 100644 --- a/recipes/glfw/all/conanfile.py +++ b/recipes/glfw/all/conanfile.py @@ -1,8 +1,11 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir, save +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime import os -import glob -from conans import ConanFile, CMake, tools +import textwrap -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.53.0" class GlfwConan(ConanFile): @@ -13,7 +16,7 @@ class GlfwConan(ConanFile): license = "Zlib" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/glfw/glfw" - topics = ("conan", "gflw", "opengl", "vulkan", "opengl-es") + topics = ("graphics", "opengl", "vulkan", "opengl-es") settings = "os", "arch", "build_type", "compiler" options = { @@ -27,13 +30,8 @@ class GlfwConan(ConanFile): "vulkan_static": False, } - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -41,100 +39,111 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): self.requires("opengl/system") if self.options.vulkan_static: - self.requires("vulkan-loader/1.2.162.0") - if self.settings.os == "Linux": + self.requires("vulkan-loader/1.3.231.1") + if self.settings.os in ["Linux", "FreeBSD"]: self.requires("xorg/system") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{}-{}".format(self.name, self.version) - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["GLFW_BUILD_EXAMPLES"] = False + tc.variables["GLFW_BUILD_TESTS"] = False + tc.variables["GLFW_BUILD_DOCS"] = False + tc.variables["GLFW_INSTALL"] = True + tc.variables["GLFW_VULKAN_STATIC"] = self.options.vulkan_static + if is_msvc(self): + tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) + tc.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) # don't force PIC - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), "POSITION_INDEPENDENT_CODE ON", "") # Allow to link vulkan-loader into shared glfw if self.options.vulkan_static: - cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") - tools.replace_in_file(cmakelists, - 'message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library")', - "") - tools.replace_in_file(cmakelists, - 'list(APPEND glfw_PKG_DEPS "vulkan")', - ('list(APPEND glfw_PKG_DEPS "vulkan")\n' - 'list(APPEND glfw_LIBRARIES "{}")').format(self.deps_cpp_info["vulkan-loader"].libs[0])) - - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["GLFW_BUILD_EXAMPLES"] = False - self._cmake.definitions["GLFW_BUILD_TESTS"] = False - self._cmake.definitions["GLFW_BUILD_DOCS"] = False - self._cmake.definitions["GLFW_INSTALL"] = True - self._cmake.definitions["GLFW_VULKAN_STATIC"] = self.options.vulkan_static - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["USE_MSVC_RUNTIME_LIBRARY_DLL"] = "MD" in self.settings.compiler.runtime - self._cmake.configure() - return self._cmake + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + replace_in_file( + self, + cmakelists, + 'message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library")', + "", + ) + vulkan_lib = self.dependencies["vulkan-loader"].cpp_info.libs[0] + replace_in_file( + self, + cmakelists, + 'list(APPEND glfw_PKG_DEPS "vulkan")', + f'list(APPEND glfw_PKG_DEPS "vulkan")\nlist(APPEND glfw_LIBRARIES "{vulkan_lib}")', + ) def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE*", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._module_subfolder, self._module_file), + os.path.join(self.package_folder, self._module_file_rel_path), {"glfw": "glfw::glfw"} ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += ( - "if(TARGET {aliased} AND NOT TARGET {alias})\n" - " add_library({alias} INTERFACE IMPORTED)\n" - " set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})\n" - "endif()\n" - ).format(alias=alias, aliased=aliased) - tools.save(module_file, content) + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") - - @property - def _module_file(self): - return "conan-official-{}-targets.cmake".format(self.name) + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "glfw3" - self.cpp_info.filenames["cmake_find_package_multi"] = "glfw3" - self.cpp_info.names["cmake_find_package"] = "glfw" - self.cpp_info.names["cmake_find_package_multi"] = "glfw" - self.cpp_info.names["pkg_config"] = "glfw3" - self.cpp_info.builddirs.append(self._module_subfolder) - self.cpp_info.build_modules = [os.path.join(self._module_subfolder, self._module_file)] - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.set_property("cmake_file_name", "glfw3") + self.cpp_info.set_property("cmake_target_name", "glfw") + self.cpp_info.set_property("pkg_config_name", "glfw3") + libname = "glfw" + if self.settings.os == "Windows" or not self.options.shared: + libname += "3" + if is_msvc(self) and self.options.shared: + libname += "dll" + self.cpp_info.libs = [libname] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["m", "pthread", "dl", "rt"]) elif self.settings.os == "Windows": self.cpp_info.system_libs.append("gdi32") elif self.settings.os == "Macos": self.cpp_info.frameworks.extend(["Cocoa", "IOKit", "CoreFoundation"]) + + # backward support of cmake_find_package, cmake_find_package_multi & pkg_config generators + self.cpp_info.filenames["cmake_find_package"] = "glfw3" + self.cpp_info.filenames["cmake_find_package_multi"] = "glfw3" + self.cpp_info.names["cmake_find_package"] = "glfw" + self.cpp_info.names["cmake_find_package_multi"] = "glfw" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.names["pkg_config"] = "glfw3" diff --git a/recipes/glfw/all/test_package/CMakeLists.txt b/recipes/glfw/all/test_package/CMakeLists.txt index 2a9b212c8d9ec..b6a8569c50ff8 100644 --- a/recipes/glfw/all/test_package/CMakeLists.txt +++ b/recipes/glfw/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(glfw3 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} glfw) +target_link_libraries(${PROJECT_NAME} PRIVATE glfw) diff --git a/recipes/glfw/all/test_package/conanfile.py b/recipes/glfw/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/glfw/all/test_package/conanfile.py +++ b/recipes/glfw/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/glfw/all/test_v1_package/CMakeLists.txt b/recipes/glfw/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/glfw/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/glfw/all/test_v1_package/conanfile.py b/recipes/glfw/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/glfw/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/glfw/config.yml b/recipes/glfw/config.yml index dc65da9f768de..a0746c2e38c76 100644 --- a/recipes/glfw/config.yml +++ b/recipes/glfw/config.yml @@ -1,4 +1,12 @@ versions: + "3.3.8": + folder: all + "3.3.7": + folder: all + "3.3.6": + folder: all + "3.3.5": + folder: all "3.3.4": folder: all "3.3.3": diff --git a/recipes/glib/all/conandata.yml b/recipes/glib/all/conandata.yml index 0c94c01d933d7..997e550aba596 100644 --- a/recipes/glib/all/conandata.yml +++ b/recipes/glib/all/conandata.yml @@ -1,49 +1,39 @@ sources: - "2.65.0": - url: "https://download.gnome.org/sources/glib/2.65/glib-2.65.0.tar.xz" - sha256: "b041e63cd0ac1fccb486374022ade040d907aad29b278e27d9e43e9294a6e7a3" - "2.65.1": - url: "https://download.gnome.org/sources/glib/2.65/glib-2.65.1.tar.xz" - sha256: "bc63bf6c32713e0ee1dddc28e03f23b4a20c78bcb9a2c5b0f4eea41e46fb9cee" - "2.65.2": - url: "https://download.gnome.org/sources/glib/2.65/glib-2.65.2.tar.xz" - sha256: "445b1951eaa82d7a8af46bdff5dcc8030406db1ceeb0f0c3a88983f70152c555" - "2.65.3": - url: "https://download.gnome.org/sources/glib/2.65/glib-2.65.3.tar.xz" - sha256: "efd894e4693068bca945cb20d168b088510fa24d48a577f5edaf3d55912c60c2" - "2.66.0": - url: "https://download.gnome.org/sources/glib/2.66/glib-2.66.0.tar.xz" - sha256: "c5a66bf143065648c135da4c943d2ac23cce15690fc91c358013b2889111156c" - "2.66.1": - url: "https://download.gnome.org/sources/glib/2.66/glib-2.66.1.tar.xz" - sha256: "a269ffe69fbcc3a21ff1acb1b6146b2a5723499d6e2de33ae16ccb6d2438ef60" - "2.66.2": - url: "https://download.gnome.org/sources/glib/2.66/glib-2.66.2.tar.xz" - sha256: "ec390bed4e8dd0f89e918f385e8d4cfd7470b1ef7c1ce93ec5c4fc6e3c6a17c4" - "2.67.0": - url: "https://download.gnome.org/sources/glib/2.67/glib-2.67.0.tar.xz" - sha256: "0b15e57ab6c2bb90ced4e24a1b0d8d6e9a13af8a70266751aa3a45baffeed7c1" - "2.67.1": - url: "https://gitlab.gnome.org/GNOME/glib/-/archive/2.67.1/glib-2.67.1.tar.gz" - sha256: "99861fb444a2801c1885c63504efb4cbff4d1acc0cf276c21f2c96f6b95020ad" - "2.67.2": - url: "https://gitlab.gnome.org/GNOME/glib/-/archive/2.67.2/glib-2.67.2.tar.gz" - sha256: "2ea1676b9247ffee99cbd35e8ebbba6d093707c8fa9bdfaa54e3029af208ffe0" - "2.67.3": - url: "https://gitlab.gnome.org/GNOME/glib/-/archive/2.67.3/glib-2.67.3.tar.gz" - sha256: "aa29c0472fbce6ebce5700c0e927d313bf9a7b061339a4899a8ffcf1c1bf7575" - "2.67.4": - url: "https://gitlab.gnome.org/GNOME/glib/-/archive/2.67.4/glib-2.67.4.tar.gz" - sha256: "ec82bcb30d696e3b4679b3134db1f418dabc034f3b6180ebbb40b1815d09e3d7" - "2.67.5": - url: "https://gitlab.gnome.org/GNOME/glib/-/archive/2.67.5/glib-2.67.5.tar.gz" - sha256: "410966db712638dc749054c0a3c3087545d5106643139c25806399a51a8d4ab1" - "2.67.6": - url: "https://gitlab.gnome.org/GNOME/glib/-/archive/2.67.6/glib-2.67.6.tar.gz" - sha256: "2698198b349021bae45a899e21c42bdc8cdf6e508f38a35d8c2bb474964c1240" - "2.68.0": - url: "https://gitlab.gnome.org/GNOME/glib/-/archive/2.68.0/glib-2.68.0.tar.gz" - sha256: "9d99ba95ee2e5271e0246cb6faf411d00d815fefc6aab921191f2918c0dffbbc" - "2.68.1": - url: "https://gitlab.gnome.org/GNOME/glib/-/archive/2.68.1/glib-2.68.1.tar.gz" - sha256: "10b8786f533efd2bf253ce1978ec39fe0f0848c963a57cd51c760eee5595ca8b" + "2.75.0": + url: "https://download.gnome.org/sources/glib/2.75/glib-2.75.0.tar.xz" + sha256: "6dde8e55cc4a2c83d96797120b08bcffb5f645b2e212164ae22d63c40e0e6360" + "2.74.1": + url: "https://download.gnome.org/sources/glib/2.74/glib-2.74.1.tar.xz" + sha256: "0ab981618d1db47845e56417b0d7c123f81a3427b2b9c93f5a46ff5bbb964964" + "2.74.0": + url: "https://download.gnome.org/sources/glib/2.74/glib-2.74.0.tar.xz" + sha256: "3652c7f072d7b031a6b5edd623f77ebc5dcd2ae698598abcc89ff39ca75add30" + "2.73.3": + url: "https://download.gnome.org/sources/glib/2.73/glib-2.73.3.tar.xz" + sha256: "df1a2b841667d6b48b2ef6969ebda4328243829f6e45866726f806f90f64eead" + "2.72.4": + url: "https://download.gnome.org/sources/glib/2.72/glib-2.72.4.tar.xz" + sha256: "8848aba518ba2f4217d144307a1d6cb9afcc92b54e5c13ac1f8c4d4608e96f0e" + "2.71.3": + url: "https://download.gnome.org/sources/glib/2.71/glib-2.71.3.tar.xz" + sha256: "288549404c26db3d52cf7a37f2f42b495b31ccffce2b4cb2439a64099c740343" + "2.70.5": + url: "https://download.gnome.org/sources/glib/2.70/glib-2.70.5.tar.xz" + sha256: "f70bf76ebcc84e0705722f038be8e2f9a58d17e1a700810c635fcc18b8974b7e" + "2.69.3": + url: "https://download.gnome.org/sources/glib/2.69/glib-2.69.3.tar.xz" + sha256: "47af2c6e06becee44d447ae7d1212dbab255b002b5141d9b62a4357c0ecc058f" + "2.68.3": + url: "https://download.gnome.org/sources/glib/2.68/glib-2.68.3.tar.xz" + sha256: "e7e1a3c20c026109c45c9ec4a31d8dcebc22e86c69486993e565817d64be3138" +patches: + "2.74.0": + - patch_file: "patches/0001-2.74.0-clang-static-assert.patch" + patch_type: backport + patch_description: fix for clang compilation + patch_source: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2898 + "2.73.3": + - patch_file: "patches/0001-2.73.3-clang-static-assert.patch" + patch_type: backport + patch_description: fix for clang compilation + patch_source: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2898 diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index a71e4349f2b7b..45a32d15f9f33 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -1,17 +1,27 @@ -from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.gnu import PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os import shutil -import glob + + +required_conan_version = ">=1.52.0" class GLibConan(ConanFile): name = "glib" description = "GLib provides the core application building blocks for libraries and applications written in C" - topics = ("conan", "glib", "gobject", "gio", "gmodule") + topics = ("gobject", "gio", "gmodule") url = "https://github.com/conan-io/conan-center-index" homepage = "https://gitlab.gnome.org/GNOME/glib" - license = "LGPL-2.1" + license = "LGPL-2.1-or-later" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -22,122 +32,142 @@ class GLibConan(ConanFile): "with_mount": [True, False], } default_options = { - "shared": False, + "shared": True, "fPIC": True, "with_pcre": True, "with_elf": True, "with_mount": True, "with_selinux": True, } - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" short_paths = True - generators = "pkg_config" - @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" - - def configure(self): - if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.settings.os == "Windows" and not self.options.shared: - raise ConanInvalidConfiguration( - "glib can not be built as static library on Windows. " - "see https://gitlab.gnome.org/GNOME/glib/-/issues/692" - ) - if tools.Version(self.version) < "2.67.0" and not self.options.with_elf: - raise ConanInvalidConfiguration("libelf dependency can't be disabled in glib < 2.67.0") + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - self.options.shared = True + if Version(self.version) < "2.71.1": + self.options.shared = True if self.settings.os != "Linux": del self.options.with_mount del self.options.with_selinux + if is_msvc(self): + del self.options.with_elf - def build_requirements(self): - self.build_requires("meson/0.56.2") - self.build_requires("pkgconf/1.7.3") + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): - self.requires("zlib/1.2.11") - self.requires("libffi/3.3") + self.requires("zlib/1.2.13") + self.requires("libffi/3.4.3") if self.options.with_pcre: - self.requires("pcre/8.44") - if self.options.with_elf: + if Version(self.version) >= "2.73.2": + self.requires("pcre2/10.40") + else: + self.requires("pcre/8.45") + if self.options.get_safe("with_elf"): self.requires("libelf/0.8.13") if self.options.get_safe("with_mount"): - self.requires("libmount/2.36") + self.requires("libmount/2.36.2") if self.options.get_safe("with_selinux"): - self.requires("libselinux/3.1") + self.requires("libselinux/3.3") if self.settings.os != "Linux": # for Linux, gettext is provided by libc - self.requires("libgettext/0.20.1") + self.requires("libgettext/0.21") - if tools.is_apple_os(self.settings.os): - self.requires("libiconv/1.16") + if is_apple_os(self): + self.requires("libiconv/1.17") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def validate(self): + if Version(self.version) >= "2.69.0" and not self.info.options.with_pcre: + raise ConanInvalidConfiguration("option glib:with_pcre must be True for glib >= 2.69.0") + if self.info.settings.os == "Windows" and not self.info.options.shared and Version(self.version) < "2.71.1": + raise ConanInvalidConfiguration( + "glib < 2.71.1 can not be built as static library on Windows. " + "see https://gitlab.gnome.org/GNOME/glib/-/issues/692" + ) + if Version(self.version) < "2.67.0" and not is_msvc(self) and not self.info.options.with_elf: + raise ConanInvalidConfiguration("libelf dependency can't be disabled in glib < 2.67.0") - def _configure_meson(self): - meson = Meson(self) - defs = dict() - if tools.is_apple_os(self.settings.os): - defs["iconv"] = "external" # https://gitlab.gnome.org/GNOME/glib/issues/1557 - defs["selinux"] = "enabled" if self.options.get_safe("with_selinux") else "disabled" - defs["libmount"] = "enabled" if self.options.get_safe("with_mount") else "disabled" - defs["internal_pcre"] = not self.options.with_pcre + def build_requirements(self): + self.tool_requires("meson/0.63.3") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/1.9.3") - if self.settings.os == "FreeBSD": - defs["xattr"] = "false" - defs["tests"] = "false" + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - if tools.Version(self.version) >= "2.67.0": - defs["libelf"] = "enabled" if self.options.with_elf else "disabled" + def generate(self): + virtual_build_env = VirtualBuildEnv(self) + virtual_build_env.generate() + tc = PkgConfigDeps(self) + tc.generate() + tc = MesonToolchain(self) - meson.configure( - source_folder=self._source_subfolder, - args=["--wrap-mode=nofallback"], - build_folder=self._build_subfolder, - defs=defs, - ) - return meson + if is_apple_os(self): + tc.project_options["iconv"] = "external" # https://gitlab.gnome.org/GNOME/glib/issues/1557 + tc.project_options["selinux"] = "enabled" if self.options.get_safe("with_selinux") else "disabled" + tc.project_options["libmount"] = "enabled" if self.options.get_safe("with_mount") else "disabled" + if Version(self.version) < "2.69.0": + tc.project_options["internal_pcre"] = not self.options.with_pcre + if self.settings.os == "FreeBSD": + tc.project_options["xattr"] = "false" + if Version(self.version) >= "2.67.2": + tc.project_options["tests"] = "false" + if Version(self.version) >= "2.67.0": + tc.project_options["libelf"] = "enabled" if self.options.get_safe("with_elf") else "disabled" + tc.generate() def _patch_sources(self): - if self.version < "2.67.2": - tools.replace_in_file( - os.path.join(self._source_subfolder, "meson.build"), + apply_conandata_patches(self) + if Version(self.version) < "2.67.2": + replace_in_file(self, + os.path.join(self.source_folder, "meson.build"), "build_tests = not meson.is_cross_build() or (meson.is_cross_build() and meson.has_exe_wrapper())", "build_tests = false", ) - tools.replace_in_file( - os.path.join(self._source_subfolder, "meson.build"), + replace_in_file(self, + os.path.join(self.source_folder, "meson.build"), "subdir('fuzzing')", "#subdir('fuzzing')", ) # https://gitlab.gnome.org/GNOME/glib/-/issues/2152 - for filename in [ - os.path.join(self._source_subfolder, "meson.build"), - os.path.join(self._source_subfolder, "glib", "meson.build"), - os.path.join(self._source_subfolder, "gobject", "meson.build"), - os.path.join(self._source_subfolder, "gio", "meson.build"), - ]: - tools.replace_in_file(filename, "subdir('tests')", "#subdir('tests')") - # allow to find gettext - tools.replace_in_file( - os.path.join(self._source_subfolder, "meson.build"), - "libintl = cc.find_library('intl', required : false)", - "libintl = cc.find_library('gnuintl', required : false)", - ) - tools.replace_in_file( + if Version(self.version) < "2.73.2": + for filename in [ + os.path.join(self.source_folder, "meson.build"), + os.path.join(self.source_folder, "glib", "meson.build"), + os.path.join(self.source_folder, "gobject", "meson.build"), + os.path.join(self.source_folder, "gio", "meson.build"), + ]: + replace_in_file(self, filename, "subdir('tests')", "#subdir('tests')") + if self.settings.os != "Linux": + # allow to find gettext + replace_in_file(self, + os.path.join(self.source_folder, "meson.build"), + "libintl = cc.find_library('intl', required : false)" if Version(self.version) < "2.73.1" \ + else "libintl = dependency('intl', required: false)", + "libintl = dependency('libgettext', method : 'pkg-config', required : false)", + ) + + replace_in_file(self, os.path.join( - self._source_subfolder, + self.source_folder, "gio", "gdbus-2.0", "codegen", @@ -146,149 +176,162 @@ def _patch_sources(self): "'share'", "'res'", ) - if self.settings.os != "Linux": - tools.replace_in_file( - os.path.join(self._source_subfolder, "meson.build"), - "if cc.has_function('ngettext')", - "if false #cc.has_function('ngettext')", - ) def build(self): self._patch_sources() - with tools.environment_append( - VisualStudioBuildEnvironment(self).vars - ) if self._is_msvc else tools.no_op(): - meson = self._configure_meson() - meson.build() - - def _fix_library_names(self): - if self.settings.compiler == "Visual Studio": - with tools.chdir(os.path.join(self.package_folder, "lib")): - for filename_old in glob.glob("*.a"): - filename_new = filename_old[3:-2] + ".lib" - self.output.info("rename %s into %s" % (filename_old, filename_new)) - shutil.move(filename_old, filename_new) + meson = Meson(self) + meson.configure() + meson.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - with tools.environment_append( - VisualStudioBuildEnvironment(self).vars - ) if self._is_msvc else tools.no_op(): - meson = self._configure_meson() - meson.install() - self._fix_library_names() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + if Version(self.version) < "2.73.0": + copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + else: + copy(self, pattern="LGPL-2.1-or-later.txt", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "LICENSES")) + meson = Meson(self) + meson.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "libexec")) shutil.move( os.path.join(self.package_folder, "share"), os.path.join(self.package_folder, "res"), ) - for pdb_file in glob.glob(os.path.join(self.package_folder, "bin", "*.pdb")): - os.unlink(pdb_file) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + fix_apple_shared_install_name(self) + fix_msvc_libname(self) def package_info(self): - + self.cpp_info.components["glib-2.0"].set_property("pkg_config_name", "glib-2.0") self.cpp_info.components["glib-2.0"].libs = ["glib-2.0"] - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["glib-2.0"].system_libs.append("pthread") - if self.settings.os == "Windows": - self.cpp_info.components["glib-2.0"].system_libs.extend( - ["ws2_32", "ole32", "shell32", "user32", "advapi32"] - ) - if self.settings.os == "Macos": - self.cpp_info.components["glib-2.0"].system_libs.append("resolv") - self.cpp_info.components["glib-2.0"].frameworks.extend( - ["Foundation", "CoreServices", "CoreFoundation"] - ) - self.cpp_info.components["glib-2.0"].includedirs.append( - os.path.join("include", "glib-2.0") - ) - self.cpp_info.components["glib-2.0"].includedirs.append( + self.cpp_info.components["glib-2.0"].includedirs += [ + os.path.join("include", "glib-2.0"), os.path.join("lib", "glib-2.0", "include") - ) - if self.options.with_pcre: - self.cpp_info.components["glib-2.0"].requires.append("pcre::pcre") - if self.settings.os != "Linux": - self.cpp_info.components["glib-2.0"].requires.append( - "libgettext::libgettext" - ) - if tools.is_apple_os(self.settings.os): - self.cpp_info.components["glib-2.0"].requires.append("libiconv::libiconv") + ] + self.cpp_info.components["glib-2.0"].resdirs = ["res"] + self.cpp_info.components["gmodule-no-export-2.0"].set_property("pkg_config_name", "gmodule-no-export-2.0") self.cpp_info.components["gmodule-no-export-2.0"].libs = ["gmodule-2.0"] - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append( - "pthread" - ) - self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append("dl") + self.cpp_info.components["gmodule-no-export-2.0"].resdirs = ["res"] self.cpp_info.components["gmodule-no-export-2.0"].requires.append("glib-2.0") - self.cpp_info.components["gmodule-export-2.0"].requires.extend( - ["gmodule-no-export-2.0", "glib-2.0"] - ) - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["gmodule-export-2.0"].sharedlinkflags.append( - "-Wl,--export-dynamic" - ) + self.cpp_info.components["gmodule-export-2.0"].set_property("pkg_config_name", "gmodule-export-2.0") + self.cpp_info.components["gmodule-export-2.0"].requires += ["gmodule-no-export-2.0", "glib-2.0"] - self.cpp_info.components["gmodule-2.0"].requires.extend( - ["gmodule-no-export-2.0", "glib-2.0"] - ) - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["gmodule-2.0"].sharedlinkflags.append( - "-Wl,--export-dynamic" - ) + self.cpp_info.components["gmodule-2.0"].set_property("pkg_config_name", "gmodule-2.0") + self.cpp_info.components["gmodule-2.0"].requires += ["gmodule-no-export-2.0", "glib-2.0"] + self.cpp_info.components["gobject-2.0"].set_property("pkg_config_name", "gobject-2.0") self.cpp_info.components["gobject-2.0"].libs = ["gobject-2.0"] - self.cpp_info.components["gobject-2.0"].requires.append("glib-2.0") - self.cpp_info.components["gobject-2.0"].requires.append("libffi::libffi") + self.cpp_info.components["gobject-2.0"].resdirs = ["res"] + self.cpp_info.components["gobject-2.0"].requires += ["glib-2.0", "libffi::libffi"] + self.cpp_info.components["gthread-2.0"].set_property("pkg_config_name", "gthread-2.0") self.cpp_info.components["gthread-2.0"].libs = ["gthread-2.0"] - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["gthread-2.0"].system_libs.append("pthread") + self.cpp_info.components["gthread-2.0"].resdirs = ["res"] self.cpp_info.components["gthread-2.0"].requires.append("glib-2.0") + self.cpp_info.components["gio-2.0"].set_property("pkg_config_name", "gio-2.0") self.cpp_info.components["gio-2.0"].libs = ["gio-2.0"] - if self.settings.os == "Linux": - self.cpp_info.components["gio-2.0"].system_libs.append("resolv") + self.cpp_info.components["gio-2.0"].resdirs = ["res"] + self.cpp_info.components["gio-2.0"].requires += ["glib-2.0", "gobject-2.0", "gmodule-2.0", "zlib::zlib"] + + self.cpp_info.components["gresource"].set_property("pkg_config_name", "gresource") + self.cpp_info.components["gresource"].libs = [] # this is actually an executable + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["glib-2.0"].system_libs.append("pthread") + self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append("pthread") + self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append("dl") + self.cpp_info.components["gmodule-export-2.0"].sharedlinkflags.append("-Wl,--export-dynamic") + self.cpp_info.components["gmodule-2.0"].sharedlinkflags.append("-Wl,--export-dynamic") + self.cpp_info.components["gthread-2.0"].system_libs.append("pthread") self.cpp_info.components["gio-2.0"].system_libs.append("dl") - self.cpp_info.components["gio-2.0"].requires.extend( - ["glib-2.0", "gobject-2.0", "gmodule-2.0", "zlib::zlib"] - ) + + if self.settings.os == "Windows": + self.cpp_info.components["glib-2.0"].system_libs += ["ws2_32", "ole32", "shell32", "user32", "advapi32"] + self.cpp_info.components["gio-2.0"].system_libs.extend(["iphlpapi", "dnsapi", "shlwapi"]) + self.cpp_info.components["gio-windows-2.0"].set_property("pkg_config_name", "gio-windows-2.0") + self.cpp_info.components["gio-windows-2.0"].requires = ["gobject-2.0", "gmodule-no-export-2.0", "gio-2.0"] + self.cpp_info.components["gio-windows-2.0"].includedirs = [os.path.join("include", "gio-win32-2.0")] + else: + self.cpp_info.components["gio-unix-2.0"].set_property("pkg_config_name", "gio-unix-2.0") + self.cpp_info.components["gio-unix-2.0"].requires += ["gobject-2.0", "gio-2.0"] + self.cpp_info.components["gio-unix-2.0"].includedirs = [os.path.join("include", "gio-unix-2.0")] + if self.settings.os == "Macos": + self.cpp_info.components["glib-2.0"].system_libs.append("resolv") + self.cpp_info.components["glib-2.0"].frameworks += ["Foundation", "CoreServices", "CoreFoundation"] self.cpp_info.components["gio-2.0"].frameworks.append("AppKit") + + if is_apple_os(self): + self.cpp_info.components["glib-2.0"].requires.append("libiconv::libiconv") + + if self.options.with_pcre: + if Version(self.version) >= "2.73.2": + self.cpp_info.components["glib-2.0"].requires.append("pcre2::pcre2") + else: + self.cpp_info.components["glib-2.0"].requires.append("pcre::pcre") + + if self.settings.os == "Linux": + self.cpp_info.components["gio-2.0"].system_libs.append("resolv") + else: + self.cpp_info.components["glib-2.0"].requires.append("libgettext::libgettext") + if self.options.get_safe("with_mount"): self.cpp_info.components["gio-2.0"].requires.append("libmount::libmount") + if self.options.get_safe("with_selinux"): - self.cpp_info.components["gio-2.0"].requires.append( - "libselinux::libselinux" - ) - if self.settings.os == "Windows": - self.cpp_info.components["gio-windows-2.0"].requires = [ - "gobject-2.0", - "gmodule-no-export-2.0", - "gio-2.0", - ] - self.cpp_info.components["gio-windows-2.0"].includedirs = [ - os.path.join("include", "gio-win32-2.0") - ] - else: - self.cpp_info.components["gio-unix-2.0"].requires.extend( - ["gobject-2.0", "gio-2.0"] - ) - self.cpp_info.components["gio-unix-2.0"].includedirs = [ - os.path.join("include", "gio-unix-2.0") - ] - self.env_info.GLIB_COMPILE_SCHEMAS = os.path.join( - self.package_folder, "bin", "glib-compile-schemas" - ) + self.cpp_info.components["gio-2.0"].requires.append("libselinux::libselinux") - self.cpp_info.components["gresource"].libs = [] # this is actually an executable - if self.options.get_safe("with_elf", True): - self.cpp_info.components["gresource"].requires.append( - "libelf::libelf" - ) # this is actually an executable + if self.options.get_safe("with_elf"): + self.cpp_info.components["gresource"].requires.append("libelf::libelf") # this is actually an executable + self.env_info.GLIB_COMPILE_SCHEMAS = os.path.join(self.package_folder, "bin", "glib-compile-schemas") bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH env var with: {}".format(bin_path)) + self.output.info(f"Appending PATH env var with: {bin_path}") self.env_info.PATH.append(bin_path) + + pkgconfig_variables = { + 'datadir': '${prefix}/res', + 'schemasdir': '${datadir}/glib-2.0/schemas', + 'bindir': '${prefix}/bin', + # Can't use libdir here as it is libdir1 when using the PkgConfigDeps generator. + 'giomoduledir': '${prefix}/lib/gio/modules', + 'gio': '${bindir}/gio', + 'gio_querymodules': '${bindir}/gio-querymodules', + 'glib_compile_schemas': '${bindir}/glib-compile-schemas', + 'glib_compile_resources': '${bindir}/glib-compile-resources', + 'gdbus': '${bindir}/gdbus', + 'gdbus_codegen': '${bindir}/gdbus-codegen', + 'gresource': '${bindir}/gresource', + 'gsettings': '${bindir}/gsettings' + } + self.cpp_info.components["gio-2.0"].set_property( + "pkg_config_custom_content", + "\n".join(f"{key}={value}" for key,value in pkgconfig_variables.items())) + + pkgconfig_variables = { + 'bindir': '${prefix}/bin', + 'glib_genmarshal': '${bindir}/glib-genmarshal', + 'gobject_query': '${bindir}/gobject-query', + 'glib_mkenums': '${bindir}/glib-mkenums' + } + self.cpp_info.components["glib-2.0"].set_property( + "pkg_config_custom_content", + "\n".join(f"{key}={value}" for key, value in pkgconfig_variables.items())) + +def fix_msvc_libname(conanfile, remove_lib_prefix=True): + """remove lib prefix & change extension to .lib""" + from conan.tools.files import rename + import glob + if not is_msvc(conanfile): + return + libdirs = getattr(conanfile.cpp.package, "libdirs") + for libdir in libdirs: + for ext in [".dll.a", ".dll.lib", ".a"]: + full_folder = os.path.join(conanfile.package_folder, libdir) + for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")): + libname = os.path.basename(filepath)[0:-len(ext)] + if remove_lib_prefix and libname[0:3] == "lib": + libname = libname[3:] + rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib")) diff --git a/recipes/glib/all/patches/0001-2.73.3-clang-static-assert.patch b/recipes/glib/all/patches/0001-2.73.3-clang-static-assert.patch new file mode 100644 index 0000000000000..c46f5e071d71c --- /dev/null +++ b/recipes/glib/all/patches/0001-2.73.3-clang-static-assert.patch @@ -0,0 +1,33 @@ +diff --git a/gio/gio-launch-desktop.c b/gio/gio-launch-desktop.c +index 29bf9d5d4..47717b987 100644 +--- a/gio/gio-launch-desktop.c ++++ b/gio/gio-launch-desktop.c +@@ -39,7 +39,6 @@ + + #if defined(__linux__) && !defined(__BIONIC__) + #include +-#include + #include + #include + #include +@@ -48,6 +47,9 @@ + #include + + #include "gjournal-private.h" ++#define GLIB_COMPILATION ++#include "gmacros.h" /* For G_STATIC_ASSERT define */ ++#undef GLIB_COMPILATION + + /* + * write_all: +@@ -119,8 +121,8 @@ journal_stream_fd (const char *identifier, + /* Arbitrary large size for the sending buffer, from systemd */ + int large_buffer_size = 8 * 1024 * 1024; + +- static_assert (LOG_EMERG == 0, "Linux ABI defines LOG_EMERG"); +- static_assert (LOG_DEBUG == 7, "Linux ABI defines LOG_DEBUG"); ++ G_STATIC_ASSERT (LOG_EMERG == 0 && sizeof "Linux ABI defines LOG_EMERG"); ++ G_STATIC_ASSERT (LOG_DEBUG == 7 && sizeof "Linux ABI defines LOG_DEBUG"); + + fd = socket (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); + diff --git a/recipes/glib/all/patches/0001-2.74.0-clang-static-assert.patch b/recipes/glib/all/patches/0001-2.74.0-clang-static-assert.patch new file mode 100644 index 0000000000000..c9481d079569d --- /dev/null +++ b/recipes/glib/all/patches/0001-2.74.0-clang-static-assert.patch @@ -0,0 +1,15 @@ +diff --git a/gio/gio-launch-desktop.c b/gio/gio-launch-desktop.c +index 26b9ae1a1..47717b987 100644 +--- a/gio/gio-launch-desktop.c ++++ b/gio/gio-launch-desktop.c +@@ -121,8 +121,8 @@ journal_stream_fd (const char *identifier, + /* Arbitrary large size for the sending buffer, from systemd */ + int large_buffer_size = 8 * 1024 * 1024; + +- G_STATIC_ASSERT (LOG_EMERG == 0 && "Linux ABI defines LOG_EMERG"); +- G_STATIC_ASSERT (LOG_DEBUG == 7 && "Linux ABI defines LOG_DEBUG"); ++ G_STATIC_ASSERT (LOG_EMERG == 0 && sizeof "Linux ABI defines LOG_EMERG"); ++ G_STATIC_ASSERT (LOG_DEBUG == 7 && sizeof "Linux ABI defines LOG_DEBUG"); + + fd = socket (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); + diff --git a/recipes/glib/all/test_package/CMakeLists.txt b/recipes/glib/all/test_package/CMakeLists.txt index 2fc8d95eec4d4..44f2423e0f831 100644 --- a/recipes/glib/all/test_package/CMakeLists.txt +++ b/recipes/glib/all/test_package/CMakeLists.txt @@ -1,9 +1,17 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() -find_package(glib REQUIRED) +cmake_minimum_required(VERSION 3.6) +project(test_package LANGUAGES C) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} glib::glib-2.0 glib::gio-2.0 glib::gmodule-2.0 glib::gobject-2.0 glib::gthread-2.0) + +if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + find_package(glib CONFIG REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE glib::glib-2.0 glib::gio-2.0 glib::gmodule-2.0 glib::gobject-2.0 glib::gthread-2.0) +else() + find_package(PkgConfig REQUIRED) + pkg_check_modules(glib-2.0 REQUIRED IMPORTED_TARGET glib-2.0) + pkg_check_modules(gio-2.0 REQUIRED IMPORTED_TARGET gio-2.0) + pkg_check_modules(gmodule-2.0 REQUIRED IMPORTED_TARGET gmodule-2.0) + pkg_check_modules(gobject-2.0 REQUIRED IMPORTED_TARGET gobject-2.0) + pkg_check_modules(gthread-2.0 REQUIRED IMPORTED_TARGET gthread-2.0) + target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::glib-2.0 PkgConfig::gio-2.0 PkgConfig::gmodule-2.0 PkgConfig::gobject-2.0 PkgConfig::gthread-2.0) +endif() diff --git a/recipes/glib/all/test_package/conanfile.py b/recipes/glib/all/test_package/conanfile.py index af85be7756944..22973c4baccc5 100644 --- a/recipes/glib/all/test_package/conanfile.py +++ b/recipes/glib/all/test_package/conanfile.py @@ -1,20 +1,55 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake, CMakeDeps, CMakeToolchain +from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv +from conan.tools.gnu import PkgConfig, PkgConfigDeps import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package", "pkg_config" + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" - def build(self): - if self.settings.os != "Windows": - self.run("gdbus-codegen -h", run_environment=True) + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + if self.settings.os != "Windows" and not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/1.9.3") + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + virtual_run_env = VirtualRunEnv(self) + virtual_run_env.generate() + if self.settings.os == "Windows": + deps = CMakeDeps(self) + deps.generate() + else: + # todo Remove the following workaround after https://github.com/conan-io/conan/issues/11962 is fixed. + env = Environment() + env.prepend_path("PKG_CONFIG_PATH", self.generators_folder) + envvars = env.vars(self) + envvars.save_script("pkg_config") + virtual_build_env = VirtualBuildEnv(self) + virtual_build_env.generate() + pkg_config_deps = PkgConfigDeps(self) + pkg_config_deps.generate() + + def build(self): cmake = CMake(self) cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + + if self.settings.os != "Windows": + pkg_config = PkgConfig(self, "gio-2.0", pkg_config_path=self.generators_folder) + gdbus_codegen = pkg_config.variables["gdbus_codegen"] + self.run(f"{gdbus_codegen} -h", env="conanrun") diff --git a/recipes/glib/all/test_package/test_package.c b/recipes/glib/all/test_package/test_package.c index 40e91666d379a..c75317a5f7f06 100644 --- a/recipes/glib/all/test_package/test_package.c +++ b/recipes/glib/all/test_package/test_package.c @@ -5,74 +5,22 @@ #include "gmodule.h" #include "gio/gio.h" -void test_gmodule() -{ - if (g_module_supported()) - printf("gmodule supported\n"); - else - printf("gmodule not supported\n"); -} - -void test_glib() -{ - GQueue *queue = g_queue_new(); - if (!g_queue_is_empty(queue)) - { - return; - } - - g_queue_push_tail(queue, "Alice"); - g_queue_push_tail(queue, "Bob"); - g_queue_push_tail(queue, "Fred"); +int main() { + printf("glib %d.%d.%d\n", glib_major_version, glib_minor_version, glib_micro_version); + printf("glib interface age: %d\n", glib_interface_age); + printf("glib binary age: %d\n", glib_binary_age); - printf("head: %s\n", (const char *)g_queue_peek_head(queue)); - printf("tail: %s\n", (const char *)g_queue_peek_tail(queue)); - printf("length: %d\n", g_queue_get_length(queue)); - printf("pop: %s\n", (const char *)g_queue_pop_head(queue)); - printf("length: %d\n", g_queue_get_length(queue)); - printf("head: %s\n", (const char *)g_queue_peek_head(queue)); - g_queue_push_head(queue, "Big Jim"); - printf("length: %d\n", g_queue_get_length(queue)); - printf("head: %s\n", (const char *)g_queue_peek_head(queue)); + GQueue *queue = g_queue_new(); g_queue_free(queue); -} -void test_gio() -{ - GInetAddress *add = g_inet_address_new_any(G_SOCKET_FAMILY_IPV4); - printf("Any ipv4 address: %s\n", g_inet_address_to_string(add)); - g_object_unref(add); -} + printf("glib module supported: %s\n", g_module_supported() ? "true" : "false"); -void test_gthread() -{ GMutex m; g_mutex_init(&m); - g_mutex_lock(&m); - g_mutex_unlock(&m); g_mutex_clear(&m); -} -void test_gobject() -{ printf("type name for char: %s\n", g_type_name(G_TYPE_CHAR)); -} - -int main(int argc, char **argv) -{ - printf("glib %d.%d.%d\n", glib_major_version, glib_minor_version, glib_micro_version); - printf("glib interface age: %d\n", glib_interface_age); - printf("glib binary age: %d\n", glib_binary_age); - test_glib(); - - test_gmodule(); - - test_gio(); - - test_gthread(); - - test_gobject(); return EXIT_SUCCESS; } diff --git a/recipes/glib/all/test_v1_package/CMakeLists.txt b/recipes/glib/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/glib/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/glib/all/test_v1_package/conanfile.py b/recipes/glib/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..ed236807fcf7e --- /dev/null +++ b/recipes/glib/all/test_v1_package/conanfile.py @@ -0,0 +1,27 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi", "pkg_config" + + def build_requirements(self): + if self.settings.os != "Windows": + self.build_requires("pkgconf/1.9.3") + + def build(self): + if self.settings.os != "Windows": + with tools.environment_append({'PKG_CONFIG_PATH': "."}): + pkg_config = tools.PkgConfig("gio-2.0") + self.run(f"{pkg_config.variables['gdbus_codegen']} -h", run_environment=True) + + with tools.environment_append({'PKG_CONFIG_PATH': "."}): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/glib/config.yml b/recipes/glib/config.yml index d30732de04502..a3f68d3f20d1a 100644 --- a/recipes/glib/config.yml +++ b/recipes/glib/config.yml @@ -1,33 +1,19 @@ versions: - "2.65.0": + "2.75.0": folder: all - "2.65.1": + "2.74.1": folder: all - "2.65.2": + "2.74.0": folder: all - "2.65.3": + "2.73.3": folder: all - "2.66.0": + "2.72.4": folder: all - "2.66.1": + "2.71.3": folder: all - "2.66.2": + "2.70.5": folder: all - "2.67.0": + "2.69.3": folder: all - "2.67.1": - folder: all - "2.67.2": - folder: all - "2.67.3": - folder: all - "2.67.4": - folder: all - "2.67.5": - folder: all - "2.67.6": - folder: all - "2.68.0": - folder: all - "2.68.1": + "2.68.3": folder: all diff --git a/recipes/glibmm/all/conandata.yml b/recipes/glibmm/all/conandata.yml new file mode 100644 index 0000000000000..9134c71e80aa3 --- /dev/null +++ b/recipes/glibmm/all/conandata.yml @@ -0,0 +1,19 @@ +sources: + "2.72.1": + url: "https://download.gnome.org/sources/glibmm/2.72/glibmm-2.72.1.tar.xz" + sha256: "2a7649a28ab5dc53ac4dabb76c9f61599fbc628923ab6a7dd74bf675d9155cd8" + "2.66.4": + url: "https://download.gnome.org/sources/glibmm/2.66/glibmm-2.66.4.tar.xz" + sha256: "199ace5682d81b15a1d565480b4a950682f2db6402c8aa5dd7217d71edff81d5" + +patches: + "2.72.1": + - patch_file: "patches/enable_static_libs_2_72_1.patch" + base_path: "source_subfolder" + - patch_file: "patches/fix_initialization_order_fiasco_2_72_1.patch" + base_path: "source_subfolder" + "2.66.4": + - patch_file: "patches/enable_static_libs_2_66_4.patch" + base_path: "source_subfolder" + - patch_file: "patches/fix_initialization_order_fiasco_2_66_4.patch" + base_path: "source_subfolder" diff --git a/recipes/glibmm/all/conanfile.py b/recipes/glibmm/all/conanfile.py new file mode 100644 index 0000000000000..6f564ef425241 --- /dev/null +++ b/recipes/glibmm/all/conanfile.py @@ -0,0 +1,201 @@ +import os +import glob +import shutil + +from conan import ConanFile +from conan.tools import ( + build, + files, + microsoft, + scm +) +from conan.errors import ConanInvalidConfiguration +from conans import Meson, tools + +required_conan_version = ">=1.50.0" + + +class GlibmmConan(ConanFile): + name = "glibmm" + homepage = "https://gitlab.gnome.org/GNOME/glibmm" + license = "LGPL-2.1" + url = "https://github.com/conan-io/conan-center-index" + description = "glibmm is a C++ API for parts of glib that are useful for C++." + topics = ["glibmm", "giomm"] + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + generators = "pkg_config" + exports_sources = "patches/**" + short_paths = True + + @property + def _abi_version(self): + return "2.68" if scm.Version(self.version) >= "2.68.0" else "2.4" + + @property + def _glibmm_lib(self): + return f"glibmm-{self._abi_version}" + + @property + def _giomm_lib(self): + return f"giomm-{self._abi_version}" + + def validate(self): + if hasattr(self, "settings_build") and build.cross_building(self): + raise ConanInvalidConfiguration("Cross-building not implemented") + + if self.settings.compiler.get_safe("cppstd"): + if self._abi_version == "2.68": + build.check_min_cppstd(self, 17) + else: + build.check_min_cppstd(self, 11) + + if self.options.shared and not self.options["glib"].shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) + + if self.options["glib"].shared and microsoft.is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def build_requirements(self): + self.build_requires("meson/0.64.1") + self.build_requires("pkgconf/1.9.3") + + def requirements(self): + self.requires("glib/2.75.0") + + if self._abi_version == "2.68": + self.requires("libsigcpp/3.0.7") + else: + self.requires("libsigcpp/2.10.8") + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _patch_sources(self): + files.apply_conandata_patches(self) + meson_build = os.path.join(self._source_subfolder, "meson.build") + files.replace_in_file(self, meson_build, "subdir('tests')", "") + if microsoft.is_msvc(self): + # GLiBMM_GEN_EXTRA_DEFS_STATIC is not defined anywhere and is not + # used anywhere except here + # when building a static build !defined(GLiBMM_GEN_EXTRA_DEFS_STATIC) + # evaluates to 0 + if not self.options.shared: + files.replace_in_file(self, + os.path.join(self._source_subfolder, "tools", + "extra_defs_gen", "generate_extra_defs.h"), + "#if defined (_MSC_VER) && !defined (GLIBMM_GEN_EXTRA_DEFS_STATIC)", + "#if 0", + ) + + # when using cpp_std=c++NM the /permissive- flag is added which + # attempts enforcing standard conformant c++ code + # the problem is that older versions of Windows SDK is not standard + # conformant! see: + # https://developercommunity.visualstudio.com/t/error-c2760-in-combaseapih-with-windows-sdk-81-and/185399 + files.replace_in_file(self, meson_build, "cpp_std=c++", "cpp_std=vc++") + + def configure(self): + if self.options.shared: + del self.options.fPIC + if self.options.shared: + self.options["glib"].shared = True + + def build(self): + self._patch_sources() + with tools.environment_append(tools.RunEnvironment(self).vars): + meson = self._configure_meson() + meson.build() + + def _configure_meson(self): + meson = Meson(self) + defs = { + "build-examples": "false", + "build-documentation": "false", + "msvc14x-parallel-installable": "false", + "default_library": "shared" if self.options.shared else "static", + } + + meson.configure( + defs=defs, + build_folder=self._build_subfolder, + source_folder=self._source_subfolder, + pkg_config_paths=[self.install_folder], + ) + + return meson + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + meson = self._configure_meson() + meson.install() + + if microsoft.is_msvc(self): + files.rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + if not self.options.shared: + files.rename( + self, + os.path.join(self.package_folder, "lib", f"libglibmm-{self._abi_version}.a"), + os.path.join(self.package_folder, "lib", f"{self._glibmm_lib}.lib") + ) + files.rename( + self, + os.path.join(self.package_folder, "lib", f"libgiomm-{self._abi_version}.a"), + os.path.join(self.package_folder, "lib", f"{self._giomm_lib}.lib") + ) + files.rename( + self, + os.path.join(self.package_folder, "lib", f"libglibmm_generate_extra_defs-{self._abi_version}.a"), + os.path.join(self.package_folder, "lib", f"glibmm_generate_extra_defs-{self._abi_version}.lib"), + ) + + for directory in [self._glibmm_lib, self._giomm_lib]: + directory_path = os.path.join(self.package_folder, "lib", directory, "include", "*.h") + for header_file in glob.glob(directory_path): + shutil.move( + header_file, + os.path.join(self.package_folder, "include", directory, os.path.basename(header_file)), + ) + + for dir_to_remove in ["pkgconfig", self._glibmm_lib, self._giomm_lib]: + files.rmdir(self, os.path.join(self.package_folder, "lib", dir_to_remove)) + + def package_info(self): + glibmm_component = f"glibmm-{self._abi_version}" + giomm_component = f"giomm-{self._abi_version}" + + self.cpp_info.components[glibmm_component].set_property("pkg_config_name", glibmm_component) + self.cpp_info.components[glibmm_component].libs = [glibmm_component] + self.cpp_info.components[glibmm_component].includedirs = [os.path.join("include", glibmm_component)] + + if self._abi_version == "2.68": + self.cpp_info.components[glibmm_component].requires = ["glib::gobject-2.0", "libsigcpp::sigc++"] + else: + self.cpp_info.components[glibmm_component].requires = ["glib::gobject-2.0", "libsigcpp::sigc++-2.0"] + + self.cpp_info.components[giomm_component].set_property("pkg_config_name", giomm_component) + self.cpp_info.components[giomm_component].libs = [giomm_component] + self.cpp_info.components[giomm_component].includedirs = [ os.path.join("include", giomm_component)] + self.cpp_info.components[giomm_component].requires = [glibmm_component, "glib::gio-2.0"] + + def package_id(self): + if not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() diff --git a/recipes/glibmm/all/patches/enable_static_libs_2_66_4.patch b/recipes/glibmm/all/patches/enable_static_libs_2_66_4.patch new file mode 100644 index 0000000000000..c94b5200949f7 --- /dev/null +++ b/recipes/glibmm/all/patches/enable_static_libs_2_66_4.patch @@ -0,0 +1,32 @@ +diff --git a/glib/glibmmconfig.h.meson b/glib/glibmmconfig.h.meson +index e50dcccf..19e64a46 100644 +--- a/glib/glibmmconfig.h.meson ++++ b/glib/glibmmconfig.h.meson +@@ -47,7 +47,9 @@ + # if defined(_MSC_VER) + # define GLIBMM_MSC 1 + # define GLIBMM_WIN32 1 +-# define GLIBMM_DLL 1 ++# ifndef GLIBMM_STATIC_LIB ++# define GLIBMM_DLL 1 ++# endif + # elif defined(__CYGWIN__) + # define GLIBMM_CONFIGURE 1 + # elif defined(__MINGW32__) +diff --git a/glib/meson.build b/glib/meson.build +index 4feee0fd..9382645a 100644 +--- a/glib/meson.build ++++ b/glib/meson.build +@@ -36,12 +36,6 @@ pkg_conf_data.set('MSVC_TOOLSET_VER', msvc14x_toolset_ver) + + library_build_type = get_option('default_library') + +-if cpp_compiler.get_argument_syntax() == 'msvc' +- if library_build_type == 'static' or library_build_type == 'both' +- error('Static builds are not supported by MSVC-style builds') +- endif +-endif +- + if library_build_type == 'static' + pkg_conf_data.set('GLIBMM_STATIC_LIB', 1) + pkg_conf_data.set('GIOMM_STATIC_LIB', 1) diff --git a/recipes/glibmm/all/patches/enable_static_libs_2_72_1.patch b/recipes/glibmm/all/patches/enable_static_libs_2_72_1.patch new file mode 100644 index 0000000000000..b9ec412d84d2e --- /dev/null +++ b/recipes/glibmm/all/patches/enable_static_libs_2_72_1.patch @@ -0,0 +1,32 @@ +diff --git a/glib/glibmmconfig.h.meson b/glib/glibmmconfig.h.meson +index ef4753d..58b343c 100644 +--- a/glib/glibmmconfig.h.meson ++++ b/glib/glibmmconfig.h.meson +@@ -27,7 +27,9 @@ + # if defined(_MSC_VER) + # define GLIBMM_MSC 1 + # define GLIBMM_WIN32 1 +-# define GLIBMM_DLL 1 ++# ifndef GLIBMM_STATIC_LIB ++# define GLIBMM_DLL 1 ++# endif + # elif defined(__CYGWIN__) + # define GLIBMM_CONFIGURE 1 + # elif defined(__MINGW32__) +diff --git a/glib/meson.build b/glib/meson.build +index 0c20a91..6b8baa0 100644 +--- a/glib/meson.build ++++ b/glib/meson.build +@@ -36,12 +36,6 @@ pkg_conf_data.set('MSVC_TOOLSET_VER', msvc14x_toolset_ver) + + library_build_type = get_option('default_library') + +-if cpp_compiler.get_argument_syntax() == 'msvc' +- if library_build_type == 'static' or library_build_type == 'both' +- error('Static builds are not supported by MSVC-style builds') +- endif +-endif +- + if library_build_type == 'static' + pkg_conf_data.set('GLIBMM_STATIC_LIB', 1) + pkg_conf_data.set('GIOMM_STATIC_LIB', 1) diff --git a/recipes/glibmm/all/patches/fix_initialization_order_fiasco_2_66_4.patch b/recipes/glibmm/all/patches/fix_initialization_order_fiasco_2_66_4.patch new file mode 100644 index 0000000000000..3cf9f867ed1f0 --- /dev/null +++ b/recipes/glibmm/all/patches/fix_initialization_order_fiasco_2_66_4.patch @@ -0,0 +1,163 @@ +Author: Hesham +Date: Fri May 6 20:02:25 2022 +0000 + + Fix initialization order fiasco + + By default global static initialization with shared libraries begins down + the linking chain upwards, so that the deepest dependency initializes first + This is not guaranteed with static libraries, which might cause glibmm to + initialize before glib. This fix uses lazy initialization for static vars + in glibmm that depend on glib. + +diff --git a/glib/glibmm/class.cc b/glib/glibmm/class.cc +index 057abed..e51d01b 100644 +--- a/glib/glibmm/class.cc ++++ b/glib/glibmm/class.cc +@@ -170,7 +170,11 @@ Class::clone_custom_type( + } + + // Initialize the static quark to store/get custom type properties. ++#if GLIB_STATIC_COMPILATION ++GQuark Class::iface_properties_quark = 0; ++#else + GQuark Class::iface_properties_quark = g_quark_from_string("gtkmm_CustomObject_iface_properties"); ++#endif + + // static + void +diff --git a/glib/glibmm/init.cc b/glib/glibmm/init.cc +index ab96892..267a6c0 100644 +--- a/glib/glibmm/init.cc ++++ b/glib/glibmm/init.cc +@@ -14,15 +14,25 @@ + * License along with this library. If not, see . + */ + ++#include + #include + #include + ++#if GLIB_STATIC_COMPILATION ++#include ++#endif ++ + namespace Glib + { + + void + init() + { ++#if GLIB_STATIC_COMPILATION ++ Glib::Class::iface_properties_quark = ++ g_quark_from_string("gtkmm_CustomObject_iface_properties"); ++#endif ++ + // Also calls Glib::wrap_register_init() and Glib::wrap_init(). + Glib::Error::register_init(); + } +diff --git a/glib/glibmm/property.cc b/glib/glibmm/property.cc +index a2624e5..d9f1095 100644 +--- a/glib/glibmm/property.cc ++++ b/glib/glibmm/property.cc +@@ -89,8 +89,10 @@ struct custom_properties_type + }; + + // The quark used for storing/getting the custom properties of custom types. +-static const GQuark custom_properties_quark = +- g_quark_from_string("gtkmm_CustomObject_custom_properties"); ++static const GQuark& custom_properties_quark() { ++ static const GQuark custom_properties_quark_ = g_quark_from_string("gtkmm_CustomObject_custom_properties"); ++ return custom_properties_quark_; ++} + + // Delete the custom properties data when an object of a custom type is finalized. + void destroy_notify_obj_custom_props(void* data) +@@ -111,12 +113,12 @@ custom_properties_type* + get_obj_custom_props(GObject* obj) + { + auto obj_custom_props = +- static_cast(g_object_get_qdata(obj, custom_properties_quark)); ++ static_cast(g_object_get_qdata(obj, custom_properties_quark())); + if (!obj_custom_props) + { + obj_custom_props = new custom_properties_type(); + g_object_set_qdata_full( +- obj, custom_properties_quark, obj_custom_props, destroy_notify_obj_custom_props); ++ obj, custom_properties_quark(), obj_custom_props, destroy_notify_obj_custom_props); + } + return obj_custom_props; + } +diff --git a/untracked/gio/giomm/application.cc b/untracked/gio/giomm/application.cc +index 43ae9df..0d12c9d 100644 +--- a/untracked/gio/giomm/application.cc ++++ b/untracked/gio/giomm/application.cc +@@ -51,8 +51,13 @@ struct ExtraApplicationData + } + }; + +-GQuark quark_extra_application_data = +- g_quark_from_string("glibmm__Gio::Application::quark_extra_application_data"); ++static GQuark& ++quark_extra_application_data() ++{ ++ static GQuark quark_extra_application_data_ = ++ g_quark_from_string("glibmm__Gio::Application::quark_extra_application_data"); ++ return quark_extra_application_data_; ++} + + void + Application_delete_extra_application_data(gpointer data) +@@ -465,11 +470,11 @@ Application::add_main_option_entry_private(GOptionArg arg, const Glib::ustring& + gchar* arg_desc = arg_description.empty() ? nullptr : g_strdup(arg_description.c_str()); + + ExtraApplicationData* extra_application_data = +- static_cast(g_object_get_qdata(gobject_, quark_extra_application_data)); ++ static_cast(g_object_get_qdata(gobject_, quark_extra_application_data())); + if (!extra_application_data) + { + extra_application_data = new ExtraApplicationData(); +- g_object_set_qdata_full(gobject_, quark_extra_application_data, extra_application_data, ++ g_object_set_qdata_full(gobject_, quark_extra_application_data(), extra_application_data, + Application_delete_extra_application_data); + } + +@@ -1546,5 +1551,3 @@ void Gio::Application::run_mainloop_vfunc() + + + } // namespace Gio +- +- +diff --git a/untracked/glib/glibmm/binding.cc b/untracked/glib/glibmm/binding.cc +index d0d4f47..0528893 100644 +--- a/untracked/glib/glibmm/binding.cc ++++ b/untracked/glib/glibmm/binding.cc +@@ -29,7 +29,10 @@ + namespace + { + // TODO: When we can break ABI, replace this GQuark by a new data member in Glib::Binding. +-GQuark quark_manage = g_quark_from_string("glibmm__Glib::Binding::manage"); ++GQuark& quark_manage() { ++ static GQuark quark_manage_ = g_quark_from_string("glibmm__Glib::Binding::manage"); ++ return quark_manage_; ++} + + struct BindingTransformSlots + { +@@ -150,7 +153,7 @@ Binding::unbind() + void + Binding::unreference() const + { +- if (!g_object_get_qdata(gobject_, quark_manage)) ++ if (!g_object_get_qdata(gobject_, quark_manage())) + { + GBinding* const binding = const_cast(gobj()); + +@@ -168,7 +171,7 @@ void + Binding::set_manage() + { + // Any pointer can be set, just not nullptr. +- g_object_set_qdata(gobject_, quark_manage, this); ++ g_object_set_qdata(gobject_, quark_manage(), this); + } + + const Glib::RefPtr& diff --git a/recipes/glibmm/all/patches/fix_initialization_order_fiasco_2_72_1.patch b/recipes/glibmm/all/patches/fix_initialization_order_fiasco_2_72_1.patch new file mode 100644 index 0000000000000..e2f8e705abbe0 --- /dev/null +++ b/recipes/glibmm/all/patches/fix_initialization_order_fiasco_2_72_1.patch @@ -0,0 +1,95 @@ +Author: Hesham +Date: Fri May 6 19:37:32 2022 +0000 + + Fix initialization order fiasco + + By default global static initialization with shared libraries begins down + the linking chain upwards, so that the deepest dependency initializes first + This is not guaranteed with static libraries, which might cause glibmm to + initialize before glib. This fix uses lazy initialization for static vars + in glibmm that depend on glib. + +diff --git a/glib/glibmm/class.cc b/glib/glibmm/class.cc +index 36c3c4b..f735129 100644 +--- a/glib/glibmm/class.cc ++++ b/glib/glibmm/class.cc +@@ -157,7 +157,11 @@ Class::clone_custom_type( + } + + // Initialize the static quark to store/get custom type properties. ++#if GLIB_STATIC_COMPILATION ++GQuark Class::iface_properties_quark = 0; ++#else + GQuark Class::iface_properties_quark = g_quark_from_string("gtkmm_CustomObject_iface_properties"); ++#endif + + // static + void +diff --git a/glib/glibmm/init.cc b/glib/glibmm/init.cc +index 0b34447..6b70a4c 100644 +--- a/glib/glibmm/init.cc ++++ b/glib/glibmm/init.cc +@@ -14,12 +14,17 @@ + * License along with this library. If not, see . + */ + ++#include + #include + #include + #include + #include + #include + ++#if GLIB_STATIC_COMPILATION ++#include ++#endif ++ + namespace + { + bool init_to_users_preferred_locale = true; +@@ -45,6 +50,11 @@ void init() + if (is_initialized) + return; + ++#if GLIB_STATIC_COMPILATION ++ Glib::Class::iface_properties_quark = ++ g_quark_from_string("gtkmm_CustomObject_iface_properties"); ++#endif ++ + if (init_to_users_preferred_locale) + { + try +diff --git a/glib/glibmm/property.cc b/glib/glibmm/property.cc +index 56dad84..630b35b 100644 +--- a/glib/glibmm/property.cc ++++ b/glib/glibmm/property.cc +@@ -89,8 +89,12 @@ struct custom_properties_type + }; + + // The quark used for storing/getting the custom properties of custom types. +-static const GQuark custom_properties_quark = +- g_quark_from_string("gtkmm_CustomObject_custom_properties"); ++static const GQuark& ++custom_properties_quark() ++{ ++ static GQuark custom_properties_quark_ = g_quark_from_string("gtkmm_CustomObject_custom_properties"); ++ return custom_properties_quark_; ++} + + // Delete the custom properties data when an object of a custom type is finalized. + void destroy_notify_obj_custom_props(void* data) +@@ -111,12 +115,12 @@ custom_properties_type* + get_obj_custom_props(GObject* obj) + { + auto obj_custom_props = +- static_cast(g_object_get_qdata(obj, custom_properties_quark)); ++ static_cast(g_object_get_qdata(obj, custom_properties_quark())); + if (!obj_custom_props) + { + obj_custom_props = new custom_properties_type(); + g_object_set_qdata_full( +- obj, custom_properties_quark, obj_custom_props, destroy_notify_obj_custom_props); ++ obj, custom_properties_quark(), obj_custom_props, destroy_notify_obj_custom_props); + } + return obj_custom_props; + } diff --git a/recipes/glibmm/all/test_package/CMakeLists.txt b/recipes/glibmm/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c47425885e86c --- /dev/null +++ b/recipes/glibmm/all/test_package/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.6) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGET) + +find_package(glibmm REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) + +if (TARGET glibmm::glibmm-2.68) + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) + target_link_libraries(${PROJECT_NAME} glibmm::glibmm-2.68 glibmm::giomm-2.68) +else() + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) + target_link_libraries(${PROJECT_NAME} glibmm::glibmm-2.4 glibmm::giomm-2.4) +endif() + diff --git a/recipes/glibmm/all/test_package/conanfile.py b/recipes/glibmm/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/glibmm/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/glibmm/all/test_package/test_package.cpp b/recipes/glibmm/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..6b7e7a7a9270c --- /dev/null +++ b/recipes/glibmm/all/test_package/test_package.cpp @@ -0,0 +1,63 @@ +/* Copyright (C) 2004 The glibmm Development Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#include +#include +#include +#include + +int +main(int, char**) +{ + Glib::init(); + /* Reusing one regex pattern: */ + const auto regex = Glib::Regex::create("(a)?(b)"); + std::cout << "Pattern=" << regex->get_pattern() << ", with string=abcd, result=" << std::boolalpha + << regex->match("abcd") << std::endl; + std::cout << "Pattern=" << regex->get_pattern() << ", with string=1234, result=" << std::boolalpha + << regex->match("1234") << std::endl; + std::cout << std::endl; + + /* Using the static function without a regex instance: */ + std::cout << "Pattern=b* with string=abcd, result=" << std::boolalpha + << Glib::Regex::match_simple("b*", "abcd") << std::endl; + + Gio::init(); + try + { + auto directory = Gio::File::create_for_path("."); + if(!directory) + std::cerr << "Gio::File::create_for_path() returned an empty RefPtr." << std::endl; + + auto enumerator = directory->enumerate_children(); + if(!enumerator) + std::cerr << "Gio::File::enumerate_children() returned an empty RefPtr." << std::endl; + + auto file_info = enumerator->next_file(); + while(file_info) + { + std::cout << "file: " << file_info->get_name() << std::endl; + file_info = enumerator->next_file(); + } + + } + catch(const Glib::Error& ex) + { + std::cerr << "Exception caught: " << ex.what() << std::endl; + } + + return 0; +} diff --git a/recipes/glibmm/config.yml b/recipes/glibmm/config.yml new file mode 100644 index 0000000000000..51960e64ef7eb --- /dev/null +++ b/recipes/glibmm/config.yml @@ -0,0 +1,5 @@ +versions: + "2.72.1": + folder: "all" + "2.66.4": + folder: "all" diff --git a/recipes/glm/all/conandata.yml b/recipes/glm/all/conandata.yml index 2b97df27f9875..125c6b973082e 100644 --- a/recipes/glm/all/conandata.yml +++ b/recipes/glm/all/conandata.yml @@ -1,13 +1,19 @@ sources: - "0.9.9.5": - url: "https://github.com/g-truc/glm/archive/0.9.9.5.tar.gz" - sha256: "5e33b6131cea6a904339734b015110d4342b7dc02d995164fdb86332d28a5aa4" - "0.9.9.6": - url: "https://github.com/g-truc/glm/archive/0.9.9.6.tar.gz" - sha256: "30b05f31f5d8528caa9fc8fe8132e5a0444d55b1c39db53fe4db8857654afafc" - "0.9.9.7": - url: "https://github.com/g-truc/glm/archive/0.9.9.7.tar.gz" - sha256: "2ec9e33a80b548892af64fbd84a947f93f0e725423b1b7bec600f808057a8239" + "cci.20220420": + url: "https://github.com/g-truc/glm/archive/cc98465e3508535ba8c7f6208df934c156a018dc.zip" + sha256: "06d48e336857777d2d1f7da9ccd59e4b9d79720dbd70886d48837d19cda997bb" "0.9.9.8": url: "https://github.com/g-truc/glm/archive/0.9.9.8.tar.gz" sha256: "7d508ab72cb5d43227a3711420f06ff99b0a0cb63ee2f93631b162bfe1fe9592" + "0.9.9.7": + url: "https://github.com/g-truc/glm/archive/0.9.9.7.tar.gz" + sha256: "2ec9e33a80b548892af64fbd84a947f93f0e725423b1b7bec600f808057a8239" + "0.9.9.6": + url: "https://github.com/g-truc/glm/archive/0.9.9.6.tar.gz" + sha256: "30b05f31f5d8528caa9fc8fe8132e5a0444d55b1c39db53fe4db8857654afafc" + "0.9.9.5": + url: "https://github.com/g-truc/glm/archive/0.9.9.5.tar.gz" + sha256: "5e33b6131cea6a904339734b015110d4342b7dc02d995164fdb86332d28a5aa4" + "0.9.5.4": + url: "https://github.com/g-truc/glm/archive/refs/tags/0.9.5.4.tar.gz" + sha256: "39c7ee0db54289f78350c7629ea2531664d71c6a494bbb86db48a86536de9ff2" diff --git a/recipes/glm/all/conanfile.py b/recipes/glm/all/conanfile.py index c4da1c5853014..5607f01a9ed01 100644 --- a/recipes/glm/all/conanfile.py +++ b/recipes/glm/all/conanfile.py @@ -1,37 +1,44 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import copy, get, load, save +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +required_conan_version = ">=1.50.0" + class GlmConan(ConanFile): name = "glm" description = "OpenGL Mathematics (GLM)" - topics = ("conan", "glm", "opengl", "mathematics") + topics = ("glm", "opengl", "mathematics") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/g-truc/glm" license = "MIT" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - if tools.Version(self._get_semver()) < "0.9.9" or \ - (tools.Version(self._get_semver()) == "0.9.9" and self._get_tweak_number() < 6): - tools.save(os.path.join(self.package_folder, "licenses", "copying.txt"), self._get_license()) + glm_version = self.version if self.version.startswith("cci") else Version(self._get_semver()) + if glm_version == "0.9.8" or (glm_version == "0.9.9" and self._get_tweak_number() < 6): + save(self, os.path.join(self.package_folder, "licenses", "copying.txt"), self._get_license()) else: - self.copy("copying.txt", dst="licenses", src=self._source_subfolder) - headers_src_dir = os.path.join(self.source_folder, self._source_subfolder, "glm") - self.copy("*.hpp", dst=os.path.join("include", "glm"), src=headers_src_dir) - self.copy("*.inl", dst=os.path.join("include", "glm"), src=headers_src_dir) - self.copy("*.h", dst=os.path.join("include", "glm"), src=headers_src_dir) + copy(self, "copying.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + for headers in ("*.hpp", "*.inl", "*.h"): + copy(self, headers, src=os.path.join(self.source_folder, "glm"), + dst=os.path.join(self.package_folder, "include", "glm")) def _get_semver(self): return self.version.rsplit(".", 1)[0] @@ -40,7 +47,15 @@ def _get_tweak_number(self): return int(self.version.rsplit(".", 1)[-1]) def _get_license(self): - manual = tools.load(os.path.join(self.source_folder, self._source_subfolder, "manual.md")) + manual = load(self, os.path.join(self.source_folder, "manual.md")) begin = manual.find("### The Happy Bunny License (Modified MIT License)") end = manual.find("\n![](./doc/manual/frontpage2.png)", begin) return manual[begin:end] + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "glm") + self.cpp_info.set_property("cmake_target_name", "glm::glm") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/glm/all/test_package/CMakeLists.txt b/recipes/glm/all/test_package/CMakeLists.txt index 196188113685c..a15bbd78f6de4 100644 --- a/recipes/glm/all/test_package/CMakeLists.txt +++ b/recipes/glm/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(glm REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE glm::glm) diff --git a/recipes/glm/all/test_package/conanfile.py b/recipes/glm/all/test_package/conanfile.py index bd7165a553cf4..d120a992c06a6 100644 --- a/recipes/glm/all/test_package/conanfile.py +++ b/recipes/glm/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/glm/all/test_v1_package/CMakeLists.txt b/recipes/glm/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b00ed742dac15 --- /dev/null +++ b/recipes/glm/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(glm REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE glm::glm) diff --git a/recipes/glm/all/test_v1_package/conanfile.py b/recipes/glm/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/glm/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/glm/config.yml b/recipes/glm/config.yml index ab85c89495e5c..33c1a13ccdf3d 100644 --- a/recipes/glm/config.yml +++ b/recipes/glm/config.yml @@ -1,9 +1,13 @@ versions: - "0.9.9.5": + "cci.20220420": folder: all - "0.9.9.6": + "0.9.9.8": folder: all "0.9.9.7": folder: all - "0.9.9.8": + "0.9.9.6": + folder: all + "0.9.9.5": + folder: all + "0.9.5.4": folder: all diff --git a/recipes/glog/all/CMakeLists.txt b/recipes/glog/all/CMakeLists.txt deleted file mode 100644 index 68bfd75fb1882..0000000000000 --- a/recipes/glog/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include("conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/glog/all/conandata.yml b/recipes/glog/all/conandata.yml index 4506b6c5fc4a5..280f568cd746b 100644 --- a/recipes/glog/all/conandata.yml +++ b/recipes/glog/all/conandata.yml @@ -1,8 +1,15 @@ sources: + "0.6.0": + sha256: 8a83bf982f37bb70825df71a9709fa90ea9f4447fb3c099e1d720a439d88bad6 + url: https://github.com/google/glog/archive/refs/tags/v0.6.0.tar.gz + "0.5.0": + sha256: eede71f28371bf39aa69b45de23b329d37214016e2055269b3b5e7cfd40b59f5 + url: https://github.com/google/glog/archive/refs/tags/v0.5.0.tar.gz "0.4.0": sha256: f28359aeba12f30d73d9e4711ef356dc842886968112162bc73002645139c39c url: https://github.com/google/glog/archive/v0.4.0.tar.gz patches: - "0.4.0": - - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" + "0.5.0": + - patch_file: "patches/0001-fix-msvc-snprintf.patch" + patch_description: "Use stdio.h instead of cstdio.h for snprintf" + patch_type: "conan" diff --git a/recipes/glog/all/conanfile.py b/recipes/glog/all/conanfile.py index 64bdd4b627c10..2d7a2e163db5b 100644 --- a/recipes/glog/all/conanfile.py +++ b/recipes/glog/all/conanfile.py @@ -1,6 +1,12 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file, rmdir +from conan.tools.scm import Version import os +required_conan_version = ">=1.51.1" + class GlogConan(ConanFile): name = "glog" @@ -9,21 +15,32 @@ class GlogConan(ConanFile): description = "Google logging library" topics = ("conan", "glog", "logging") license = "BSD-3-Clause" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False], "with_gflags": [True, False], "with_threads": [True, False]} - default_options = {"shared": False, "fPIC": True, "with_gflags": True, "with_threads": True} - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_gflags": [True, False], + "with_threads": [True, False], + "with_unwind": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_gflags": True, + "with_threads": True, + "with_unwind": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.settings.os not in ["Linux", "FreeBSD"] or Version(self.version) < "0.5.0": + del self.options.with_unwind def configure(self): if self.options.shared: @@ -31,45 +48,86 @@ def configure(self): if self.options.with_gflags: self.options["gflags"].shared = self.options.shared + def layout(self): + cmake_layout(self, src_folder="src") + def requirements(self): if self.options.with_gflags: self.requires("gflags/2.2.2") + # 0.4.0 requires libunwind unconditionally + if self.options.get_safe("with_unwind") or (Version(self.version) < "0.5.0" and self.settings.os in ["Linux", "FreeBSD"]): + self.requires("libunwind/1.6.2") + + def build_requirements(self): + if Version(self.version) >= "0.6.0": + self.tool_requires("cmake/3.22.3") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["WITH_GFLAGS"] = self.options.with_gflags - self._cmake.definitions["WITH_THREADS"] = self.options.with_threads - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_GFLAGS"] = self.options.with_gflags + tc.variables["WITH_THREADS"] = self.options.with_threads + tc.variables["BUILD_SHARED_LIBS"] = self.options.shared + if Version(self.version) >= "0.5.0": + tc.variables["WITH_PKGCONFIG"] = True + if self.settings.os == "Emscripten": + tc.variables["WITH_SYMBOLIZE"] = False + tc.variables["HAVE_SYSCALL_H"] = False + tc.variables["HAVE_SYS_SYSCALL_H"] = False + else: + tc.variables["WITH_SYMBOLIZE"] = True + tc.variables["WITH_UNWIND"] = self.options.get_safe("with_unwind", default=False) + tc.variables["BUILD_TESTING"] = False + tc.variables["WITH_GTEST"] = False + tc.generate() + + tc = CMakeDeps(self) + tc.generate() + + tc = VirtualBuildEnv(self) + tc.generate(scope="build") + + def _patch_sources(self): + apply_conandata_patches(self) + # do not force PIC + if Version(self.version) <= "0.5.0": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set_target_properties (glog PROPERTIES POSITION_INDEPENDENT_CODE ON)", + "") + # INFO: avoid "CONAN_LIB::gflags_gflags_nothreads_RELEASE" but the target was not found. + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "determine_gflags_namespace", + "# determine_gflags_namespace") def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - self.cpp_info.names["pkgconfig"] = ["libglog"] + self.cpp_info.set_property("cmake_file_name", "glog") + self.cpp_info.set_property("cmake_target_name", "glog::glog") + self.cpp_info.set_property("pkg_config_name", "libglog") + postfix = "d" if self.settings.build_type == "Debug" else "" + self.cpp_info.libs = ["glog" + postfix] if self.settings.os == "Linux": self.cpp_info.system_libs = ["pthread"] elif self.settings.os == "Windows": + self.cpp_info.system_libs = ["dbghelp"] self.cpp_info.defines = ["GLOG_NO_ABBREVIATED_SEVERITIES"] decl = "__declspec(dllimport)" if self.options.shared else "" - self.cpp_info.defines.append("GOOGLE_GLOG_DLL_DECL={}".format(decl)) + self.cpp_info.defines.append(f"GOOGLE_GLOG_DLL_DECL={decl}") if self.options.with_gflags and not self.options.shared: self.cpp_info.defines.extend(["GFLAGS_DLL_DECLARE_FLAG=", "GFLAGS_DLL_DEFINE_FLAG="]) diff --git a/recipes/glog/all/patches/0001-fix-msvc-snprintf.patch b/recipes/glog/all/patches/0001-fix-msvc-snprintf.patch new file mode 100644 index 0000000000000..c92d98cb82e67 --- /dev/null +++ b/recipes/glog/all/patches/0001-fix-msvc-snprintf.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -141,7 +141,7 @@ check_cxx_compiler_flag (-Wunnamed-type-template-args + + # NOTE: Cannot use check_function_exists here since >=vc-14.0 can define + # snprintf as an inline function +-check_symbol_exists (snprintf cstdio HAVE_SNPRINTF) ++check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF) + + check_library_exists (dbghelp UnDecorateSymbolName "" HAVE_DBGHELP) + diff --git a/recipes/glog/all/patches/fix-cmake.patch b/recipes/glog/all/patches/fix-cmake.patch deleted file mode 100644 index c7075af7aeec3..0000000000000 --- a/recipes/glog/all/patches/fix-cmake.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 808330e..9b0f2c4 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -469,7 +469,6 @@ add_library (glog - ) - add_library(glog::glog ALIAS glog) - --set_target_properties (glog PROPERTIES POSITION_INDEPENDENT_CODE ON) - - if (UNWIND_LIBRARY) - target_link_libraries (glog PUBLIC ${UNWIND_LIBRARY}) -@@ -489,7 +488,7 @@ if (WIN32 AND HAVE_SNPRINTF) - endif (WIN32 AND HAVE_SNPRINTF) - - if (gflags_FOUND) -- target_link_libraries (glog PUBLIC gflags) -+ target_link_libraries (glog PUBLIC gflags::gflags) - - if (NOT BUILD_SHARED_LIBS) - # Don't use __declspec(dllexport|dllimport) if this is a static build diff --git a/recipes/glog/all/test_package/CMakeLists.txt b/recipes/glog/all/test_package/CMakeLists.txt index 6266127b686eb..286cd0d4348c1 100644 --- a/recipes/glog/all/test_package/CMakeLists.txt +++ b/recipes/glog/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(glog REQUIRED) +find_package(glog REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} glog::glog) diff --git a/recipes/glog/all/test_package/conanfile.py b/recipes/glog/all/test_package/conanfile.py index 1d0bdd3779793..8a5bb47f50c4c 100644 --- a/recipes/glog/all/test_package/conanfile.py +++ b/recipes/glog/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/glog/all/test_v1_package/CMakeLists.txt b/recipes/glog/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3473c9c27d148 --- /dev/null +++ b/recipes/glog/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(glog REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} glog::glog) diff --git a/recipes/glog/all/test_v1_package/conanfile.py b/recipes/glog/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2490acfa82ff8 --- /dev/null +++ b/recipes/glog/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/glog/config.yml b/recipes/glog/config.yml index af29e78bd9b25..babcbfb79d964 100644 --- a/recipes/glog/config.yml +++ b/recipes/glog/config.yml @@ -1,3 +1,7 @@ versions: + "0.6.0": + folder: all + "0.5.0": + folder: all "0.4.0": folder: all diff --git a/recipes/glpk/all/conandata.yml b/recipes/glpk/all/conandata.yml new file mode 100644 index 0000000000000..a355fe0344e5f --- /dev/null +++ b/recipes/glpk/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "5.0": + url: "https://ftp.gnu.org/gnu/glpk/glpk-5.0.tar.gz" + sha256: "4a1013eebb50f728fc601bdd833b0b2870333c3b3e5a816eeba921d95bec6f15" diff --git a/recipes/glpk/all/conanfile.py b/recipes/glpk/all/conanfile.py new file mode 100644 index 0000000000000..e03f104fe6d73 --- /dev/null +++ b/recipes/glpk/all/conanfile.py @@ -0,0 +1,150 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conan.tools.files import rename +from conan.tools.microsoft import is_msvc +from contextlib import contextmanager +import os + +required_conan_version = ">=1.45.0" + + +class GlpkConan(ConanFile): + name = "glpk" + description = "GNU Linear Programming Kit" + homepage = "https://www.gnu.org/software/glpk" + topics = ("linear", "programming", "simplex", "solver") + url = "https://github.com/conan-io/conan-center-index" + license = "GPL-3.0-or-later" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + + default_options = { + "shared": False, + "fPIC": True, + } + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def build_requirements(self): + self.build_requires("libtool/2.4.6") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, + destination=self._source_subfolder) + + @contextmanager + def _build_context(self): + if is_msvc(self): + with tools.vcvars(self): + env = { + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "LD": "{} link -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), + } + with tools.environment_append(env): + yield + else: + yield + + def _patch_source(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows, run_environment=True) + tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), + r"-install_name \$rpath/", + "-install_name @rpath/") + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + + self._autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--with-pic={}".format(yes_no(self.options.get_safe("fPIC", True))) + ] + + if is_msvc(self): + self._autotools.defines.append("__WOE__") + if self.settings.compiler == "Visual Studio" and \ + tools.Version(self.settings.compiler.version) >= "12": + self._autotools.flags.append("-FS") + self._autotools.configure(args=args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + #self._patch_source() + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + + if is_msvc(self) and self.options.shared: + pjoin = lambda p: os.path.join(self.package_folder, "lib", p) + rename(self, pjoin("glpk.dll.lib"), pjoin("glpk.lib")) + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "glpk") + self.cpp_info.set_property("cmake_target_name", "glpk::glpk") + self.cpp_info.set_property("pkg_config_name", "glpk") + + self.cpp_info.components["libglpk"].set_property("cmake_target_name", "glpk::glpk") + self.cpp_info.components["libglpk"].libs = ["glpk"] + + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.components["libglpk"].system_libs = ["m"] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment var: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "glpk" + self.cpp_info.names["cmake_find_package_multi"] = "glpk" + self.cpp_info.components["libglpk"].names["cmake_find_package"] = "glpk" + self.cpp_info.components["libglpk"].names["cmake_find_package_multi"] = "glpk" + + diff --git a/recipes/glpk/all/test_package/CMakeLists.txt b/recipes/glpk/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3258d5f78ee30 --- /dev/null +++ b/recipes/glpk/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(glpk CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE glpk::glpk) diff --git a/recipes/glpk/all/test_package/conanfile.py b/recipes/glpk/all/test_package/conanfile.py new file mode 100644 index 0000000000000..66177d47bc143 --- /dev/null +++ b/recipes/glpk/all/test_package/conanfile.py @@ -0,0 +1,24 @@ +import os +from conans import ConanFile, CMake, tools + + +class GlpkTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + #def build_requirements(self): + # if self.settings.os == "Macos" and self.settings.arch == "armv8": + # # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # # set. This could be because you are using a Mac OS X version less than 10.5 + # # or because CMake's platform configuration is corrupt. + # self.build_requires("cmake/3.20.1") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/glpk/all/test_package/test_package.c b/recipes/glpk/all/test_package/test_package.c new file mode 100644 index 0000000000000..965bd82a292c4 --- /dev/null +++ b/recipes/glpk/all/test_package/test_package.c @@ -0,0 +1,54 @@ +/** + * The example program from the GLPK documentation + * Can be found in examples/sample.c + */ + +#include +#include +#include + +int main(void) +{ glp_prob *lp; + int ia[1+1000], ja[1+1000]; + double ar[1+1000], z, x1, x2, x3; +s1: lp = glp_create_prob(); +s2: glp_set_prob_name(lp, "sample"); +s3: glp_set_obj_dir(lp, GLP_MAX); +s4: glp_add_rows(lp, 3); +s5: glp_set_row_name(lp, 1, "p"); +s6: glp_set_row_bnds(lp, 1, GLP_UP, 0.0, 100.0); +s7: glp_set_row_name(lp, 2, "q"); +s8: glp_set_row_bnds(lp, 2, GLP_UP, 0.0, 600.0); +s9: glp_set_row_name(lp, 3, "r"); +s10: glp_set_row_bnds(lp, 3, GLP_UP, 0.0, 300.0); +s11: glp_add_cols(lp, 3); +s12: glp_set_col_name(lp, 1, "x1"); +s13: glp_set_col_bnds(lp, 1, GLP_LO, 0.0, 0.0); +s14: glp_set_obj_coef(lp, 1, 10.0); +s15: glp_set_col_name(lp, 2, "x2"); +s16: glp_set_col_bnds(lp, 2, GLP_LO, 0.0, 0.0); +s17: glp_set_obj_coef(lp, 2, 6.0); +s18: glp_set_col_name(lp, 3, "x3"); +s19: glp_set_col_bnds(lp, 3, GLP_LO, 0.0, 0.0); +s20: glp_set_obj_coef(lp, 3, 4.0); +s21: ia[1] = 1, ja[1] = 1, ar[1] = 1.0; /* a[1,1] = 1 */ +s22: ia[2] = 1, ja[2] = 2, ar[2] = 1.0; /* a[1,2] = 1 */ +s23: ia[3] = 1, ja[3] = 3, ar[3] = 1.0; /* a[1,3] = 1 */ +s24: ia[4] = 2, ja[4] = 1, ar[4] = 10.0; /* a[2,1] = 10 */ +s25: ia[5] = 3, ja[5] = 1, ar[5] = 2.0; /* a[3,1] = 2 */ +s26: ia[6] = 2, ja[6] = 2, ar[6] = 4.0; /* a[2,2] = 4 */ +s27: ia[7] = 3, ja[7] = 2, ar[7] = 2.0; /* a[3,2] = 2 */ +s28: ia[8] = 2, ja[8] = 3, ar[8] = 5.0; /* a[2,3] = 5 */ +s29: ia[9] = 3, ja[9] = 3, ar[9] = 6.0; /* a[3,3] = 6 */ +s30: glp_load_matrix(lp, 9, ia, ja, ar); +s31: glp_simplex(lp, NULL); +s32: z = glp_get_obj_val(lp); +s33: x1 = glp_get_col_prim(lp, 1); +s34: x2 = glp_get_col_prim(lp, 2); +s35: x3 = glp_get_col_prim(lp, 3); +s36: printf("\nz = %g; x1 = %g; x2 = %g; x3 = %g\n", + z, x1, x2, x3); +s37: glp_delete_prob(lp); + return 0; +} + diff --git a/recipes/glpk/config.yml b/recipes/glpk/config.yml new file mode 100644 index 0000000000000..d27c85493de54 --- /dev/null +++ b/recipes/glpk/config.yml @@ -0,0 +1,3 @@ +versions: + "5.0": + folder: all diff --git a/recipes/glshaderpp/all/conandata.yml b/recipes/glshaderpp/all/conandata.yml new file mode 100644 index 0000000000000..44a4436634860 --- /dev/null +++ b/recipes/glshaderpp/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.0": + url: "https://gitlab-lepuy.iut.uca.fr/opengl/glshaderpp/-/package_files/7/download" + sha256: "0be41a89185e173255f82e9b149ab6562019b0da793bd1af1c44594fa8347da1" diff --git a/recipes/glshaderpp/all/conanfile.py b/recipes/glshaderpp/all/conanfile.py new file mode 100644 index 0000000000000..5f5d7e6cc487c --- /dev/null +++ b/recipes/glshaderpp/all/conanfile.py @@ -0,0 +1,55 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + +class GLShaderPPConan(ConanFile): + name = "glshaderpp" + homepage = "https://gitlab-lepuy.iut.uca.fr/opengl/glshaderpp" + description = "A lightweight header-only library to compile and link OpenGL GLSL shaders." + topics = ("opengl", "glsl", "shader", "header-only") + url = "https://github.com/conan-io/conan-center-index" + no_copy_source = True + license = "LGPL-3.0-or-later" + settings = "compiler", "os", "arch", "build_type" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def package_id(self): + self.info.header_only() + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "17", + "gcc": "7", + "clang": "6", + "apple-clang": "10", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn(f"{self.name} recipe lacks information about the {self.settings.compiler} compiler support.") + else: + if tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration(f"{self.name} requires C++{self._minimum_cpp_standard} support. The current compiler {self.settings.compiler} {self.settings.compiler.version} does not support it.") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + self.copy("*", src=os.path.join(self._source_subfolder, "include"), dst="include") + + def package_info(self): + self.cpp_info.includedirs.append(os.path.join("include", "GLShaderPP")) diff --git a/recipes/glshaderpp/all/test_package/CMakeLists.txt b/recipes/glshaderpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7f0e01ff5256f --- /dev/null +++ b/recipes/glshaderpp/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(glew CONFIG REQUIRED) +find_package(glshaderpp CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} example.cpp) +target_link_libraries(${PROJECT_NAME} glshaderpp::glshaderpp GLEW::GLEW) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) diff --git a/recipes/glshaderpp/all/test_package/conanfile.py b/recipes/glshaderpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b5aad28ecae40 --- /dev/null +++ b/recipes/glshaderpp/all/test_package/conanfile.py @@ -0,0 +1,19 @@ +import os +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def requirements(self): + self.requires("glew/2.2.0") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "PackageTest") + self.run(bin_path, run_environment=True) diff --git a/recipes/glshaderpp/all/test_package/example.cpp b/recipes/glshaderpp/all/test_package/example.cpp new file mode 100644 index 0000000000000..eb8a668f50e89 --- /dev/null +++ b/recipes/glshaderpp/all/test_package/example.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include +#include + +int main() { + GLShaderPP::CShaderException e("If you read this, GLShaderPP is happy :)", GLShaderPP::CShaderException::ExceptionType::LinkError); + std::cout << e.what() << '\n'; + return EXIT_SUCCESS; +} diff --git a/recipes/glshaderpp/config.yml b/recipes/glshaderpp/config.yml new file mode 100644 index 0000000000000..40341aa3db6cd --- /dev/null +++ b/recipes/glshaderpp/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.0": + folder: all diff --git a/recipes/glslang/all/CMakeLists.txt b/recipes/glslang/all/CMakeLists.txt index 217b9530b904d..17ed662273267 100644 --- a/recipes/glslang/all/CMakeLists.txt +++ b/recipes/glslang/all/CMakeLists.txt @@ -1,7 +1,16 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) -include(conanbuildinfo.cmake) -conan_basic_setup() +# TODO: +# - It should be find_package(SPIRV-Tools-opt REQUIRED CONFIG), but it can't be +# modeled yet in spirv-tools recipe. +# - Upstream CMakeLists is not very neat, and doesn't always link +# Spirv-Tools-opt in all required targets. Keep in mind that it works thanks +# to global injection of include dirs/interface definitions from +# conan_basic_setup(). It won't work without patches when moving to +# CMakeToolchain + CMakeDeps. +if(ENABLE_OPT) + find_package(SPIRV-Tools REQUIRED CONFIG) +endif() -add_subdirectory("source_subfolder") +add_subdirectory(src) diff --git a/recipes/glslang/all/conandata.yml b/recipes/glslang/all/conandata.yml index f400b06e15a79..5f989bd0af008 100644 --- a/recipes/glslang/all/conandata.yml +++ b/recipes/glslang/all/conandata.yml @@ -1,8 +1,45 @@ sources: + "1.3.231.1": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.231.1.tar.gz" + sha256: "df3857f01c1aa9ee1927d2feaaa431406d243958e07791e9aed4cb5ab22a5f2b" + "1.3.224.0": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.224.0.tar.gz" + sha256: "c43c6aa149fa1165e01b375b4d95cbc23b4fc72bd9972a89c55dd1eaa8a360ca" + "1.3.216.0": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.216.0.tar.gz" + sha256: "3f80a926390faedd33e6ed17ec68340abace83913b285174e2dee87156577be5" + "1.3.211.0": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.211.0.tar.gz" + sha256: "4335eec84b87d64130e860dad5d6dc1f722277d4e0ff5027153e2743628cb221" + "1.3.204.0": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/sdk-1.3.204.0.tar.gz" + sha256: "c6bec993194377944fb8d6d585a90e1288994660782d709e30fa1d91810d6820" + "11.7.0": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/11.7.0.tar.gz" + sha256: "b6c83864c3606678d11675114fa5f358c519fe1dad9a781802bcc87fb8fa32d5" + "11.6.0": + url: "https://github.com/KhronosGroup/glslang/archive/refs/tags/11.6.0.tar.gz" + sha256: "99ecd3a0c2c2219293d76723846f762a9f3e7dd0dc2a4f346d0fc3a05a0ce000" + "11.5.0": + url: "https://github.com/KhronosGroup/glslang/archive/11.5.0.tar.gz" + sha256: "fd0b5e3bda591bb08bd3049655a99a0a55f0de4059b9c8f7b397e4b19cf5d51f" "8.13.3559": url: "https://github.com/KhronosGroup/glslang/archive/8.13.3559.tar.gz" sha256: "c58fdcf7e00943ba10f9ae565b2725ec9d5be7dab7c8e82cac72fcaa83c652ca" patches: - "8.13.3559": - - patch_file: "patches/conanize-cmake-8.13.3559.patch" - base_path: "source_subfolder" + "1.3.231.1": + - patch_file: "patches/0001-no-force-glslang-pic.patch" + "1.3.224.0": + - patch_file: "patches/0001-no-force-glslang-pic.patch" + "1.3.216.0": + - patch_file: "patches/0001-no-force-glslang-pic.patch" + "1.3.211.0": + - patch_file: "patches/0001-no-force-glslang-pic.patch" + "1.3.204.0": + - patch_file: "patches/0001-no-force-glslang-pic.patch" + "11.7.0": + - patch_file: "patches/0001-no-force-glslang-pic.patch" + "11.6.0": + - patch_file: "patches/0001-no-force-glslang-pic.patch" + "11.5.0": + - patch_file: "patches/0001-no-force-glslang-pic.patch" diff --git a/recipes/glslang/all/conanfile.py b/recipes/glslang/all/conanfile.py index 809bf879b95cc..b5f950bef195e 100644 --- a/recipes/glslang/all/conanfile.py +++ b/recipes/glslang/all/conanfile.py @@ -1,8 +1,13 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir +from conan.tools.scm import Version import os -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.52.0" class GlslangConan(ConanFile): @@ -10,20 +15,18 @@ class GlslangConan(ConanFile): description = "Khronos-reference front end for GLSL/ESSL, partial front " \ "end for HLSL, and a SPIR-V generator." license = ["BSD-3-Clause", "NVIDIA"] - topics = ("conan", "glslang", "glsl", "hlsl", "spirv", "spir-v", "validation", "translation") + topics = ("glsl", "hlsl", "spirv", "spir-v", "validation", "translation") homepage = "https://github.com/KhronosGroup/glslang" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" - short_paths = True options = { "shared": [True, False], "fPIC": [True, False], "build_executables": [True, False], "spv_remapper": [True, False], "hlsl": [True, False], - "enable_optimizer": [True, False] + "enable_optimizer": [True, False], } default_options = { "shared": False, @@ -31,18 +34,14 @@ class GlslangConan(ConanFile): "build_executables": True, "spv_remapper": True, "hlsl": True, - "enable_optimizer": True + "enable_optimizer": True, } - _cmake = None + short_paths = True - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -50,123 +49,218 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) - if self.options.shared and self.settings.os in ["Windows", "Macos"]: - raise ConanInvalidConfiguration("Current glslang shared library build is broken on Windows and Macos") + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + @property + def _get_compatible_spirv_tools_version(self): + return { + "11.7.0": "2021.4", + "11.6.0": "2021.3", + "11.5.0": "2021.2", + "8.13.3559": "2020.5", + }.get(str(self.version), self.version) def requirements(self): if self.options.enable_optimizer: - self.requires("spirv-tools/2020.5") + self.requires(f"spirv-tools/{self._get_compatible_spirv_tools_version}") def validate(self): - if self.options.enable_optimizer and self.options["spirv-tools"].shared: - raise ConanInvalidConfiguration("glslang with enable_optimizer requires static spirv-tools, because SPIRV-Tools-opt is not built if shared") + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + # see https://github.com/KhronosGroup/glslang/issues/2283 + glslang_version = Version(self.version) + if (self.info.options.shared and + (self.info.settings.os == "Windows" or \ + (glslang_version >= "7.0.0" and glslang_version < "11.0.0" and is_apple_os(self))) + ): + raise ConanInvalidConfiguration(f"{self.ref} shared library build is broken on {self.info.settings.os}") + + if self.info.options.enable_optimizer and self.dependencies["spirv-tools"].options.shared: + raise ConanInvalidConfiguration( + f"{self.ref} with enable_optimizer requires static spirv-tools, " + "because SPIRV-Tools-opt is not built if shared" + ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def build(self): - self._patches_sources() - cmake = self._configure_cmake() - cmake.build() + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_EXTERNAL"] = False + tc.variables["SKIP_GLSLANG_INSTALL"] = False + tc.variables["ENABLE_SPVREMAPPER"] = self.options.spv_remapper + tc.variables["ENABLE_GLSLANG_BINARIES"] = self.options.build_executables + glslang_version = Version(self.version) + if glslang_version < "7.0.0" or glslang_version >= "8.13.3743": + tc.variables["ENABLE_GLSLANG_JS"] = False + tc.variables["ENABLE_GLSLANG_WEBMIN"] = False + tc.variables["ENABLE_GLSLANG_WEBMIN_DEVEL"] = False + else: + tc.variables["ENABLE_GLSLANG_WEB"] = False + tc.variables["ENABLE_GLSLANG_WEB_DEVEL"] = False + tc.variables["ENABLE_EMSCRIPTEN_SINGLE_FILE"] = False + tc.variables["ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE"] = False + tc.variables["ENABLE_HLSL"] = self.options.hlsl + if glslang_version < "7.0.0" or glslang_version >= "8.13.3743": + tc.variables["ENABLE_RTTI"] = True + tc.variables["ENABLE_OPT"] = self.options.enable_optimizer + if self.options.enable_optimizer: + tc.variables["spirv-tools_SOURCE_DIR"] = self.dependencies["spirv-tools"].package_folder.replace("\\", "/") + tc.variables["ENABLE_PCH"] = False + tc.variables["ENABLE_CTEST"] = False + tc.variables["USE_CCACHE"] = False + if (glslang_version < "7.0.0" or glslang_version >= "11.6.0") and self.settings.os == "Windows": + tc.variables["OVERRIDE_MSVCCRT"] = False + if is_apple_os(self): + tc.variables["CMAKE_MACOSX_BUNDLE"] = False + if glslang_version < "1.3.231" or glslang_version >= "7.0.0": + # Generate a relocatable shared lib on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() - def _patches_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - # Do not force PIC if static (but keep it if shared, because OGLCompiler and OSDependent are still static) + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # Do not force PIC if static (but keep it if shared, because OGLCompiler, OSDependent, + # GenericCodeGen and MachineIndependent are still static and linked to glslang shared) if not self.options.shared: cmake_files_to_fix = [ {"target": "OGLCompiler", "relpath": os.path.join("OGLCompilersDLL", "CMakeLists.txt")}, {"target": "SPIRV" , "relpath": os.path.join("SPIRV", "CMakeLists.txt")}, {"target": "SPVRemapper", "relpath": os.path.join("SPIRV", "CMakeLists.txt")}, - {"target": "glslang" , "relpath": os.path.join("glslang", "CMakeLists.txt")}, {"target": "OSDependent", "relpath": os.path.join("glslang", "OSDependent", "Unix","CMakeLists.txt")}, {"target": "OSDependent", "relpath": os.path.join("glslang", "OSDependent", "Windows","CMakeLists.txt")}, {"target": "HLSL" , "relpath": os.path.join("hlsl", "CMakeLists.txt")}, ] + glslang_version = Version(self.version) + if glslang_version >= "7.0.0" and glslang_version < "11.0.0": + cmake_files_to_fix.append({"target": "glslang", "relpath": os.path.join("glslang", "CMakeLists.txt")}) + else: + cmake_files_to_fix.append({"target": "glslang-default-resource-limits", "relpath": os.path.join("StandAlone" , "CMakeLists.txt")}) + cmake_files_to_fix.append({"target": "MachineIndependent", "relpath": os.path.join("glslang", "CMakeLists.txt")}) + cmake_files_to_fix.append({"target": "GenericCodeGen", "relpath": os.path.join("glslang", "CMakeLists.txt")}) for cmake_file in cmake_files_to_fix: - tools.replace_in_file(os.path.join(self._source_subfolder, cmake_file["relpath"]), + replace_in_file(self, os.path.join(self.source_folder, cmake_file["relpath"]), "set_property(TARGET {} PROPERTY POSITION_INDEPENDENT_CODE ON)".format(cmake_file["target"]), "") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_EXTERNAL"] = False - self._cmake.definitions["SKIP_GLSLANG_INSTALL"] = False - self._cmake.definitions["ENABLE_SPVREMAPPER"] = self.options.spv_remapper - self._cmake.definitions["ENABLE_GLSLANG_BINARIES"] = self.options.build_executables - if tools.Version(self.version) >= "8.13.3743": - self._cmake.definitions["ENABLE_GLSLANG_JS"] = False - self._cmake.definitions["ENABLE_GLSLANG_WEBMIN"] = False - self._cmake.definitions["ENABLE_GLSLANG_WEBMIN_DEVEL"] = False - else: - self._cmake.definitions["ENABLE_GLSLANG_WEB"] = False - self._cmake.definitions["ENABLE_GLSLANG_WEB_DEVEL"] = False - self._cmake.definitions["ENABLE_EMSCRIPTEN_SINGLE_FILE"] = False - self._cmake.definitions["ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE"] = False - self._cmake.definitions["ENABLE_HLSL"] = self.options.hlsl - if tools.Version(self.version) >= "8.13.3743": - self._cmake.definitions["ENABLE_RTTI"] = False - self._cmake.definitions["ENABLE_OPT"] = self.options.enable_optimizer - self._cmake.definitions["ENABLE_PCH"] = True - self._cmake.definitions["ENABLE_CTEST"] = False - self._cmake.definitions["USE_CCACHE"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() def package(self): - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - # TODO: glslang exports non-namespaced targets but without config file... + self.cpp_info.set_property("cmake_file_name", "glslang") + self.cpp_info.set_property("cmake_target_name", "glslang::glslang-do-not-use") # because glslang-core target is glslang::glslang + lib_suffix = "d" if self.settings.os == "Windows" and self.settings.build_type == "Debug" else "" - # OSDependent - self.cpp_info.components["osdependent"].names["cmake_find_package"] = "OSDependent" - self.cpp_info.components["osdependent"].names["cmake_find_package_multi"] = "OSDependent" - self.cpp_info.components["osdependent"].libs = ["OSDependent" + lib_suffix] - if self.settings.os == "Linux": - self.cpp_info.components["osdependent"].system_libs.append("pthread") - # OGLCompiler - self.cpp_info.components["oglcompiler"].names["cmake_find_package"] = "OGLCompiler" - self.cpp_info.components["oglcompiler"].names["cmake_find_package_multi"] = "OGLCompiler" - self.cpp_info.components["oglcompiler"].libs = ["OGLCompiler" + lib_suffix] + + glslang_version = Version(self.version) + has_machineindependent = (glslang_version < "7.0.0" or glslang_version >= "11.0.0") and not self.options.shared + has_genericcodegen = (glslang_version < "7.0.0" or glslang_version >= "11.0.0") and not self.options.shared + has_osdependent = glslang_version < "1.3.231" or glslang_version >= "7.0.0" or not self.options.shared + has_oglcompiler = glslang_version < "1.3.231" or glslang_version >= "7.0.0" or not self.options.shared + # glslang + self.cpp_info.components["glslang-core"].set_property("cmake_target_name", "glslang::glslang") self.cpp_info.components["glslang-core"].names["cmake_find_package"] = "glslang" self.cpp_info.components["glslang-core"].names["cmake_find_package_multi"] = "glslang" - self.cpp_info.components["glslang-core"].libs = ["glslang" + lib_suffix] - if self.settings.os == "Linux": + self.cpp_info.components["glslang-core"].libs = [f"glslang{lib_suffix}"] + if (glslang_version < "7.0.0" or glslang_version >= "11.0.0") and self.options.shared: + self.cpp_info.components["glslang-core"].defines.append("GLSLANG_IS_SHARED_LIBRARY") + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["glslang-core"].system_libs.extend(["m", "pthread"]) - self.cpp_info.components["glslang-core"].requires = ["oglcompiler", "osdependent"] + if has_machineindependent: + self.cpp_info.components["glslang-core"].requires.append("machineindependent") + if has_genericcodegen: + self.cpp_info.components["glslang-core"].requires.append("genericcodegen") + if has_osdependent: + self.cpp_info.components["glslang-core"].requires.append("osdependent") + if has_oglcompiler: + self.cpp_info.components["glslang-core"].requires.append("oglcompiler") + if self.options.hlsl: + self.cpp_info.components["glslang-core"].defines.append("ENABLE_HLSL") + self.cpp_info.components["glslang-core"].requires.append("hlsl") + + if has_machineindependent: + # MachineIndependent + self.cpp_info.components["machineindependent"].set_property("cmake_target_name", "glslang::MachineIndependent") + self.cpp_info.components["machineindependent"].names["cmake_find_package"] = "MachineIndependent" + self.cpp_info.components["machineindependent"].names["cmake_find_package_multi"] = "MachineIndependent" + self.cpp_info.components["machineindependent"].libs = [f"MachineIndependent{lib_suffix}"] + if has_genericcodegen: + self.cpp_info.components["machineindependent"].requires.append("genericcodegen") + if has_osdependent: + self.cpp_info.components["machineindependent"].requires.append("osdependent") + if has_oglcompiler: + self.cpp_info.components["machineindependent"].requires.append("oglcompiler") + + if has_genericcodegen: + # GenericCodeGen + self.cpp_info.components["genericcodegen"].set_property("cmake_target_name", "glslang::GenericCodeGen") + self.cpp_info.components["genericcodegen"].names["cmake_find_package"] = "GenericCodeGen" + self.cpp_info.components["genericcodegen"].names["cmake_find_package_multi"] = "GenericCodeGen" + self.cpp_info.components["genericcodegen"].libs = [f"GenericCodeGen{lib_suffix}"] + + if has_osdependent: + # OSDependent + self.cpp_info.components["osdependent"].set_property("cmake_target_name", "glslang::OSDependent") + self.cpp_info.components["osdependent"].names["cmake_find_package"] = "OSDependent" + self.cpp_info.components["osdependent"].names["cmake_find_package_multi"] = "OSDependent" + self.cpp_info.components["osdependent"].libs = [f"OSDependent{lib_suffix}"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["osdependent"].system_libs.append("pthread") + + if has_oglcompiler: + # OGLCompiler + self.cpp_info.components["oglcompiler"].set_property("cmake_target_name", "glslang::OGLCompiler") + self.cpp_info.components["oglcompiler"].names["cmake_find_package"] = "OGLCompiler" + self.cpp_info.components["oglcompiler"].names["cmake_find_package_multi"] = "OGLCompiler" + self.cpp_info.components["oglcompiler"].libs = [f"OGLCompiler{lib_suffix}"] + # SPIRV + self.cpp_info.components["spirv"].set_property("cmake_target_name", "glslang::SPIRV") self.cpp_info.components["spirv"].names["cmake_find_package"] = "SPIRV" self.cpp_info.components["spirv"].names["cmake_find_package_multi"] = "SPIRV" - self.cpp_info.components["spirv"].libs = ["SPIRV" + lib_suffix] + self.cpp_info.components["spirv"].libs = [f"SPIRV{lib_suffix}"] self.cpp_info.components["spirv"].requires = ["glslang-core"] if self.options.enable_optimizer: self.cpp_info.components["spirv"].requires.append("spirv-tools::spirv-tools-opt") self.cpp_info.components["spirv"].defines.append("ENABLE_OPT") + # HLSL if self.options.hlsl: + self.cpp_info.components["hlsl"].set_property("cmake_target_name", "glslang::HLSL") self.cpp_info.components["hlsl"].names["cmake_find_package"] = "HLSL" self.cpp_info.components["hlsl"].names["cmake_find_package_multi"] = "HLSL" - self.cpp_info.components["hlsl"].libs = ["HLSL" + lib_suffix] - self.cpp_info.components["glslang-core"].requires.append("hlsl") - self.cpp_info.components["glslang-core"].defines.append("ENABLE_HLSL") + self.cpp_info.components["hlsl"].libs = [f"HLSL{lib_suffix}"] + # SPVRemapper if self.options.spv_remapper: + self.cpp_info.components["spvremapper"].set_property("cmake_target_name", "glslang::SPVRemapper") self.cpp_info.components["spvremapper"].names["cmake_find_package"] = "SPVRemapper" self.cpp_info.components["spvremapper"].names["cmake_find_package_multi"] = "SPVRemapper" - self.cpp_info.components["spvremapper"].libs = ["SPVRemapper" + lib_suffix] + self.cpp_info.components["spvremapper"].libs = [f"SPVRemapper{lib_suffix}"] if self.options.build_executables: - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/glslang/all/patches/0001-no-force-glslang-pic.patch b/recipes/glslang/all/patches/0001-no-force-glslang-pic.patch new file mode 100644 index 0000000000000..00e2266d3a9ae --- /dev/null +++ b/recipes/glslang/all/patches/0001-no-force-glslang-pic.patch @@ -0,0 +1,10 @@ +--- a/glslang/CMakeLists.txt ++++ b/glslang/CMakeLists.txt +@@ -167,7 +167,6 @@ + add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS}) + set_target_properties(glslang PROPERTIES + FOLDER glslang +- POSITION_INDEPENDENT_CODE ON + VERSION "${GLSLANG_VERSION}" + SOVERSION "${GLSLANG_VERSION_MAJOR}") + target_link_libraries(glslang PRIVATE OGLCompiler OSDependent MachineIndependent) diff --git a/recipes/glslang/all/patches/conanize-cmake-8.13.3559.patch b/recipes/glslang/all/patches/conanize-cmake-8.13.3559.patch deleted file mode 100644 index ecb798ab88fde..0000000000000 --- a/recipes/glslang/all/patches/conanize-cmake-8.13.3559.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -163,10 +163,6 @@ if(BUILD_EXTERNAL AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/External) - add_subdirectory(External) - endif() - --if(NOT TARGET SPIRV-Tools-opt) -- set(ENABLE_OPT OFF) --endif() -- - if(ENABLE_OPT) - message(STATUS "optimizer enabled") - add_definitions(-DENABLE_OPT=1) ---- a/SPIRV/CMakeLists.txt -+++ b/SPIRV/CMakeLists.txt -@@ -54,14 +54,7 @@ if(WIN32 AND BUILD_SHARED_LIBS) - endif() - - if(ENABLE_OPT) -- target_include_directories(SPIRV -- PRIVATE ${spirv-tools_SOURCE_DIR}/include -- PRIVATE ${spirv-tools_SOURCE_DIR}/source -- ) -- target_link_libraries(SPIRV glslang SPIRV-Tools-opt) -- target_include_directories(SPIRV PUBLIC -- $ -- $) -+ target_link_libraries(SPIRV glslang ${CONAN_LIBS}) - else() - target_link_libraries(SPIRV glslang) - endif(ENABLE_OPT) diff --git a/recipes/glslang/all/test_package/CMakeLists.txt b/recipes/glslang/all/test_package/CMakeLists.txt index 33ae887aa6aea..02d778d679219 100644 --- a/recipes/glslang/all/test_package/CMakeLists.txt +++ b/recipes/glslang/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(glslang REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE glslang::glslang) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/glslang/all/test_package/conanfile.py b/recipes/glslang/all/test_package/conanfile.py index 425616771f3a5..216f67362e0fd 100644 --- a/recipes/glslang/all/test_package/conanfile.py +++ b/recipes/glslang/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,8 +21,8 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") shader_name = os.path.join(self.source_folder, "test_package.vert") - self.run("glslangValidator \"{}\"".format(shader_name), run_environment=True) + self.run(f"glslangValidator \"{shader_name}\"", env="conanrun") diff --git a/recipes/glslang/all/test_v1_package/CMakeLists.txt b/recipes/glslang/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/glslang/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/glslang/all/test_v1_package/conanfile.py b/recipes/glslang/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..d939929a7a456 --- /dev/null +++ b/recipes/glslang/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + shader_name = os.path.join(self.source_folder, os.pardir, "test_package", "test_package.vert") + self.run(f"glslangValidator \"{shader_name}\"", run_environment=True) diff --git a/recipes/glslang/config.yml b/recipes/glslang/config.yml index c322472059f7b..eb0c5a565bc36 100644 --- a/recipes/glslang/config.yml +++ b/recipes/glslang/config.yml @@ -1,3 +1,19 @@ versions: + "1.3.231.1": + folder: all + "1.3.224.0": + folder: all + "1.3.216.0": + folder: all + "1.3.211.0": + folder: all + "1.3.204.0": + folder: all + "11.7.0": + folder: all + "11.6.0": + folder: all + "11.5.0": + folder: all "8.13.3559": folder: all diff --git a/recipes/glu/all/conanfile.py b/recipes/glu/all/conanfile.py index 835d22619c375..42fc9acb237e8 100644 --- a/recipes/glu/all/conanfile.py +++ b/recipes/glu/all/conanfile.py @@ -1,38 +1,40 @@ -from conans import ConanFile, tools -from conans.errors import ConanException -import os +from conan import ConanFile +from conan.errors import ConanException +from conan.tools.system import package_manager +from conans import tools + +required_conan_version = ">=1.47" class SysConfigGLUConan(ConanFile): name = "glu" version = "system" description = "cross-platform virtual conan package for the GLU support" - topics = ("conan", "opengl", "glu") + topics = ("opengl", "glu") url = "https://github.com/conan-io/conan-center-index" homepage = "https://cgit.freedesktop.org/mesa/glu/" license = "SGI-B-2.0" - settings = "os" + settings = "os", "arch", "compiler", "build_type" requires = "opengl/system" def system_requirements(self): - packages = [] - if tools.os_info.is_linux and self.settings.os == "Linux": - if tools.os_info.with_yum or tools.os_info.with_dnf: - packages = ["mesa-libGLU-devel"] - elif tools.os_info.with_apt: - packages = ["libglu1-mesa-dev"] - elif tools.os_info.with_pacman: - packages = ["glu"] - elif tools.os_info.with_zypper: - packages = ["Mesa-libGLU-devel"] - else: - self.output.warn("Don't know how to install GLU for your distro") - if tools.os_info.is_freebsd and self.settings.os == "FreeBSD": - packages = ["libGLU"] - if packages: - package_tool = tools.SystemPackageTool(conanfile=self, default_mode='verify') - for p in packages: - package_tool.install(update=True, packages=p) + dnf = package_manager.Dnf(self) + dnf.install(["mesa-libGLU-devel"], update=True, check=True) + + yum = package_manager.Yum(self) + yum.install(["mesa-libGLU-devel"], update=True, check=True) + + apt = package_manager.Apt(self) + apt.install(["libglu1-mesa-dev"], update=True, check=True) + + pacman = package_manager.PacMan(self) + pacman.install(["glu"], update=True, check=True) + + zypper = package_manager.Zypper(self) + zypper.install(["glu-devel"], update=True, check=True) + + pkg = package_manager.Pkg(self) + pkg.install(["libGLU"], update=True, check=True) def _fill_cppinfo_from_pkgconfig(self, name): pkg_config = tools.PkgConfig(name) @@ -55,7 +57,7 @@ def _fill_cppinfo_from_pkgconfig(self, name): self.cpp_info.cxxflags.extend(cflags) def package_info(self): - self.cpp_info.include_dirs = [] + self.cpp_info.includedirs = [] self.cpp_info.libdirs = [] if self.settings.os == "Windows": diff --git a/recipes/glu/all/test_package/conanfile.py b/recipes/glu/all/test_package/conanfile.py index 4903f1a7e8fa0..fdb9f346a1da9 100644 --- a/recipes/glu/all/test_package/conanfile.py +++ b/recipes/glu/all/test_package/conanfile.py @@ -11,6 +11,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/gm2calc/all/conandata.yml b/recipes/gm2calc/all/conandata.yml index 943b5e3d4ad66..5246438fdf67a 100644 --- a/recipes/gm2calc/all/conandata.yml +++ b/recipes/gm2calc/all/conandata.yml @@ -2,3 +2,13 @@ sources: "1.7.5": url: "https://github.com/GM2Calc/GM2Calc/archive/v1.7.5.tar.gz" sha256: "5b44b3d51c763238a1f53845c10559c0a8c9a88e524377d698d2c2306b117a7f" + "2.0.0": + url: "https://github.com/GM2Calc/GM2Calc/archive/v2.0.0.tar.gz" + sha256: "1e5fcdc2fc170d1dade7080504ff622c55bdd4167b5c4d1b09f616b403910de5" + "2.1.0": + url: "https://github.com/GM2Calc/GM2Calc/archive/v2.1.0.tar.gz" + sha256: "33fd0d6da089e25ae0a6ac81b70e9bc9152952e7be4383f4c0baa862af7921bb" +patches: + "1.7.5": + - patch_file: "patches/0001-update-1.7.5-to-FindMathematica-3.6.0.patch" + base_path: "source_subfolder" diff --git a/recipes/gm2calc/all/conanfile.py b/recipes/gm2calc/all/conanfile.py index ef53c0dfd9ed0..5332dc62195c9 100644 --- a/recipes/gm2calc/all/conanfile.py +++ b/recipes/gm2calc/all/conanfile.py @@ -1,4 +1,5 @@ import os +import conan from conans import ConanFile, CMake, tools required_conan_version = ">=1.30.0" @@ -9,8 +10,8 @@ class Gm2calcConan(ConanFile): license = "GPL-3.0" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/GM2Calc/GM2Calc" - description = "C++ library to calculate the anomalous magnetic moment of the muon in the MSSM" - topics = ("conan", "high-energy", "physics", "hep", "magnetic moment", "muon", "MSSM") + description = "C++ library to calculate the anomalous magnetic moment of the muon in the MSSM and 2HDM" + topics = ("high-energy", "physics", "hep", "magnetic moment", "muon", "mssm", "2hdm") settings = "os", "compiler", "build_type", "arch" options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True} @@ -26,6 +27,10 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -40,9 +45,11 @@ def requirements(self): def source(self): tools.get(**self.conan_data["sources"][self.version]) - os.rename("GM2Calc-{}".format(self.version), self._source_subfolder) + conan.tools.files.rename(self, "GM2Calc-{}".format(self.version), self._source_subfolder) def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) cmake = self._configure_cmake() cmake.build() diff --git a/recipes/gm2calc/all/patches/0001-update-1.7.5-to-FindMathematica-3.6.0.patch b/recipes/gm2calc/all/patches/0001-update-1.7.5-to-FindMathematica-3.6.0.patch new file mode 100644 index 0000000000000..4236e508a89c2 --- /dev/null +++ b/recipes/gm2calc/all/patches/0001-update-1.7.5-to-FindMathematica-3.6.0.patch @@ -0,0 +1,285 @@ +diff --git a/cmake/Mathematica/FindMathematica.cmake b/cmake/Mathematica/FindMathematica.cmake +index 6e721a0..8ae7595 100644 +--- a/cmake/Mathematica/FindMathematica.cmake ++++ b/cmake/Mathematica/FindMathematica.cmake +@@ -3,7 +3,7 @@ + # See the FindMathematica manual for usage hints. + # + #============================================================================= +-# Copyright 2010-2020 Sascha Kratky ++# Copyright 2010-2021 Sascha Kratky + # + # Permission is hereby granted, free of charge, to any person) + # obtaining a copy of this software and associated documentation) +@@ -34,7 +34,7 @@ cmake_minimum_required(VERSION 2.8.12) + cmake_policy(POP) + + set (Mathematica_CMAKE_MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}") +-set (Mathematica_CMAKE_MODULE_VERSION "3.3.0") ++set (Mathematica_CMAKE_MODULE_VERSION "3.6.0") + + # activate select policies + if (POLICY CMP0025) +@@ -242,10 +242,14 @@ endmacro() + macro (_get_program_names _outProgramNames) + set (${_outProgramNames} "") + # Mathematica products in order of preference +- set (_MathematicaApps "Mathematica" "Wolfram Desktop" "Wolfram Engine" "gridMathematica Server") ++ set (_MathematicaApps ++ "Mathematica" "mathematica" ++ "Wolfram Desktop" "Wolfram Engine" ++ "gridMathematica Server") + # Mathematica product versions in order of preference + set (_MathematicaVersions +- "12.1" "12.0" ++ "13.0" ++ "12.3" "12.2" "12.1" "12.0" + "11.3" "11.2" "11.1" "11.0" + "10.4" "10.3" "10.2" "10.1" "10.0" + "9.0" "8.0" "7.0" "6.0" "5.2") +@@ -348,8 +352,10 @@ function (_add_launch_services_search_paths _outSearchPaths) + # the executable usually resides in the LaunchServices framework Support directory + # The LaunchServices framework is a sub-framework of the CoreServices umbrella framework + cmake_find_frameworks(CoreServices) +- find_program (Mathematica_LSRegister_EXECUTABLE NAMES "lsregister" PATH_SUFFIXES "Support" +- HINTS "${CoreServices_FRAMEWORKS}/Frameworks/LaunchServices.framework") ++ find_program (Mathematica_LSRegister_EXECUTABLE ++ NAMES "lsregister" ++ PATH_SUFFIXES "/Frameworks/LaunchServices.framework/Support" ++ HINTS ${CoreServices_FRAMEWORKS}) + mark_as_advanced( + Mathematica_CoreServices_DIR + Mathematica_LaunchServices_DIR +@@ -361,7 +367,7 @@ function (_add_launch_services_search_paths _outSearchPaths) + foreach (_bundleID IN ITEMS ${ARGN}) + execute_process( + COMMAND "${Mathematica_LSRegister_EXECUTABLE}" "-dump" +- COMMAND "grep" "--before-context=20" "--after-context=20" " ${_bundleID} " ++ COMMAND "grep" "--before-context=20" "--after-context=20" "${_bundleID}" + COMMAND "grep" "--only-matching" "/.*\\.app" + TIMEOUT 10 OUTPUT_VARIABLE _queryResult ERROR_QUIET) + string (REPLACE ";" "\\;" _queryResult "${_queryResult}") +@@ -461,6 +467,14 @@ macro (_get_search_paths _outSearchPaths) + list (APPEND ${_outSearchPaths} "${_unixPath}/Wolfram Research" ) + endif() + endforeach() ++ # add default installation path ++ if (IS_DIRECTORY "C:/Program Files/Wolfram Research") ++ list (APPEND ${_outSearchPaths} "C:/Program Files/Wolfram Research" ) ++ endif() ++ # Windows container paths may be lowercase ++ if (IS_DIRECTORY "C:/Program Files/wolfram research") ++ list (APPEND ${_outSearchPaths} "C:/Program Files/wolfram research" ) ++ endif() + elseif (CMAKE_HOST_APPLE) + # add standard Mathematica Mac OS X installation paths + list (APPEND ${_outSearchPaths} "~/Applications;/Applications") +@@ -500,6 +514,8 @@ macro (_systemNameToSystemID _systemName _systemProcessor _outSystemIDs) + set (${_outSystemIDs} "MacOSX-x86") + elseif ("${_systemProcessor}" STREQUAL "x86_64") + set (${_outSystemIDs} "MacOSX-x86-64") ++ elseif ("${_systemProcessor}" STREQUAL "arm64") ++ set (${_outSystemIDs} "MacOSX-ARM64") + elseif ("${_systemProcessor}" MATCHES "ppc64|powerpc64") + set (${_outSystemIDs} "Darwin-PowerPC64") + elseif ("${_systemProcessor}" MATCHES "ppc|powerpc") +@@ -648,7 +664,12 @@ macro (_get_host_system_IDs _outSystemIDs) + endmacro() + + macro (_get_supported_systemIDs _version _outSystemIDs) +- if (NOT "${_version}" VERSION_LESS "12.1") ++ if (NOT "${_version}" VERSION_LESS "12.3") ++ set (${_outSystemIDs} ++ "Windows-x86-64" ++ "Linux-x86-64" "Linux-ARM" ++ "MacOSX-x86-64" "MacOSX-ARM64") ++ elseif (NOT "${_version}" VERSION_LESS "12.1") + set (${_outSystemIDs} + "Windows-x86-64" + "Linux-x86-64" "Linux-ARM" +@@ -741,6 +762,19 @@ macro (_get_compatible_system_IDs _systemID _outSystemIDs) + else() + list (APPEND ${_outSystemIDs} "MacOSX-x86-64" "MacOSX-x86") + endif() ++ elseif ("${_systemID}" MATCHES "MacOSX-ARM64") ++ if (Mathematica_VERSION) ++ # Mathematica 12.3 added support for MacOSX-ARM64 ++ if (NOT "${Mathematica_VERSION}" VERSION_LESS "12.3") ++ list (APPEND ${_outSystemIDs} "MacOSX-ARM64") ++ endif() ++ # Mathematica 6 added support for MacOSX-x86-64 ++ if (NOT "${Mathematica_VERSION}" VERSION_LESS "6.0") ++ list (APPEND ${_outSystemIDs} "MacOSX-x86-64") ++ endif() ++ else() ++ list (APPEND ${_outSystemIDs} "MacOSX-ARM64" "MacOSX-x86-64") ++ endif() + elseif ("${_systemID}" STREQUAL "Darwin-PowerPC64") + if (Mathematica_VERSION) + if (NOT "${Mathematica_VERSION}" VERSION_LESS "5.2" AND +@@ -801,7 +835,7 @@ macro(_get_developer_kit_system_IDs _outSystemIDs) + set (${_outSystemIDs} "") + else() + # Mathematica versions after 9 have a system ID subdirectory +- set (${_outSystemIDs} "MacOSX-x86-64") ++ set (${_outSystemIDs} "MacOSX-x86-64" "MacOSX-ARM64") + endif() + else() + _get_system_IDs(${_outSystemIDs}) +@@ -819,8 +853,8 @@ macro(_get_host_developer_kit_system_IDs _outSystemIDs) + if ("${Mathematica_VERSION}" VERSION_LESS "9.0") + set (${_outSystemIDs} "") + else() +- # The MacOSX-x86-64 DeveloperKit is a universal binary with architectures i386 and x86_64 +- set (${_outSystemIDs} "MacOSX-x86-64") ++ # Mathematica versions after 9 have a system ID subdirectory ++ set (${_outSystemIDs} "MacOSX-x86-64" "MacOSX-ARM64") + endif() + else() + _get_host_system_IDs(${_outSystemIDs}) +@@ -1175,7 +1209,10 @@ macro (_append_WSTP_needed_system_libraries _outLibraries) + if (DEFINED Mathematica_WSTP_VERSION_MINOR) + if ("${Mathematica_WSTP_VERSION_MINOR}" GREATER 24) + # Linux WSTP API revision >= 25 has dependency on libdl and libuuid +- list (APPEND ${_outLibraries} dl uuid) ++ list (APPEND ${_outLibraries} ${CMAKE_DL_LIBS}) ++ find_library (Mathematica_uuid_LIBRARY uuid) ++ mark_as_advanced(Mathematica_uuid_LIBRARY) ++ list (APPEND ${_outLibraries} ${Mathematica_uuid_LIBRARY}) + endif() + endif() + endif() +@@ -1262,7 +1299,7 @@ macro (_setup_mathematica_systemIDs) + _get_system_IDs(Mathematica_SYSTEM_IDS) + # default target platform system ID is first one in Mathematica_SYSTEM_IDS + list(GET Mathematica_SYSTEM_IDS 0 Mathematica_SYSTEM_ID) +- if (COMMAND Mathematica_EXECUTE) ++ if (Mathematica_RUN_KERNEL_ON_CONFIGURE AND COMMAND Mathematica_EXECUTE) + # determine true host system ID which depends on both Mathematica version + # and OS variant by running Mathematica kernel + Mathematica_EXECUTE( +@@ -1315,7 +1352,7 @@ endmacro() + + # internal macro to set up Mathematica base directory variable + macro (_setup_mathematica_base_directory) +- if (COMMAND Mathematica_EXECUTE) ++ if (Mathematica_RUN_KERNEL_ON_CONFIGURE AND COMMAND Mathematica_EXECUTE) + # determine true $BaseDirectory + Mathematica_EXECUTE( + CODE "Print[StandardForm[$BaseDirectory]]" +@@ -1367,7 +1404,7 @@ endmacro() + + # internal macro to set up Mathematica user base directory variable + macro (_setup_mathematica_userbase_directory) +- if (COMMAND Mathematica_EXECUTE) ++ if (Mathematica_RUN_KERNEL_ON_CONFIGURE AND COMMAND Mathematica_EXECUTE) + # determine true $UserBaseDirectory + Mathematica_EXECUTE( + CODE "Print[StandardForm[$UserBaseDirectory]]" +@@ -1461,6 +1498,16 @@ macro (_setup_findmathematica_options) + option (Mathematica_DEBUG + "enable FindMathematica debugging output?" + ${Mathematica_DEBUG_INIT}) ++ if (NOT DEFINED Mathematica_RUN_KERNEL_ON_CONFIGURE_INIT) ++ if (DEFINED Mathematica_RUN_KERNEL_ON_CONFIGURE) ++ set (Mathematica_RUN_KERNEL_ON_CONFIGURE_INIT ${Mathematica_RUN_KERNEL_ON_CONFIGURE}) ++ else() ++ set (Mathematica_RUN_KERNEL_ON_CONFIGURE_INIT TRUE) ++ endif() ++ endif() ++ option (Mathematica_RUN_KERNEL_ON_CONFIGURE ++ "allow FindMathematica to implicitly run the Mathematica kernel at CMake configure time?" ++ ${Mathematica_RUN_KERNEL_ON_CONFIGURE_INIT}) + endmacro() + + # internal macro to find Mathematica installation +@@ -1940,7 +1987,7 @@ endmacro() + + # internal macro to find MUnit package + macro (_find_munit_package) +- if (COMMAND Mathematica_FIND_PACKAGE) ++ if (Mathematica_RUN_KERNEL_ON_CONFIGURE AND COMMAND Mathematica_FIND_PACKAGE) + Mathematica_FIND_PACKAGE(Mathematica_MUnit_PACKAGE_FILE "MUnit`MUnit`") + # determine enclosing MUnit package directory + if (Mathematica_MUnit_PACKAGE_FILE) +@@ -1954,7 +2001,7 @@ endmacro() + + # internal macro to find LibaryLink package + macro (_find_librarylink_package) +- if (COMMAND Mathematica_FIND_PACKAGE) ++ if (Mathematica_RUN_KERNEL_ON_CONFIGURE AND COMMAND Mathematica_FIND_PACKAGE) + Mathematica_FIND_PACKAGE(Mathematica_LibraryLink_PACKAGE_FILE "LibraryLink`LibraryLink`") + # determine enclosing LibraryLink package directory + if (Mathematica_LibraryLink_PACKAGE_FILE) +@@ -2449,6 +2496,31 @@ macro (_log_found_variables) + message (STATUS "MUnit not found") + endif() + endif() ++ # warn explicitly about common mistakes users make ++ if (UNIX AND NOT APPLE) ++ if (DEFINED Mathematica_uuid_LIBRARY) ++ if (Mathematica_uuid_LIBRARY MATCHES "-NOTFOUND$") ++ message (WARNING "WSTP and MathLink require libuuid. Install libuuid with the system package manager.") ++ endif() ++ endif() ++ endif() ++ if (DEFINED Mathematica_VERSION) ++ if (CMAKE_SIZEOF_VOID_P EQUAL 4) ++ if (WINDOWS) ++ if (NOT "${Mathematica_VERSION}" VERSION_LESS "12.1") ++ message (WARNING "Windows Mathematica ${Mathematica_VERSION} does not support 32-bit.") ++ endif() ++ elseif (APPLE) ++ if (NOT "${Mathematica_VERSION}" VERSION_LESS "9.0") ++ message (WARNING "Mac Mathematica ${Mathematica_VERSION} does not support 32-bit.") ++ endif() ++ elseif (UNIX) ++ if (NOT "${Mathematica_VERSION}" VERSION_LESS "11.3") ++ message (WARNING "Linux Mathematica ${Mathematica_VERSION} does not support 32-bit.") ++ endif() ++ endif() ++ endif() ++ endif() + if (DEFINED Mathematica_VERSION_MAJOR AND + DEFINED Mathematica_VERSION_MINOR AND + DEFINED Mathematica_SYSTEM_IDS) +@@ -3009,6 +3081,8 @@ macro (_add_launch_prefix _cmdVar _systemIDVar) + list (APPEND ${_cmdVar} "/usr/bin/arch" "-i386") + elseif("${${_systemIDVar}}" STREQUAL "MacOSX-x86-64") + list (APPEND ${_cmdVar} "/usr/bin/arch" "-x86_64") ++ elseif("${${_systemIDVar}}" STREQUAL "MacOSX-ARM64") ++ list (APPEND ${_cmdVar} "/usr/bin/arch" "-arm64") + elseif("${${_systemIDVar}}" MATCHES "Darwin|MacOSX") + list (APPEND ${_cmdVar} "/usr/bin/arch" "-ppc") + elseif("${${_systemIDVar}}" STREQUAL "Darwin-PowerPC64") +@@ -3999,7 +4073,7 @@ function (Mathematica_MathLink_ADD_EXECUTABLE _executableName _templateFile) + _get_mprep_output_file(${_templateFile} _outfile) + Mathematica_MathLink_MPREP_TARGET(${_templateFile} OUTPUT ${_outfile}) + add_executable (${_executableName} WIN32 ${_outfile} ${ARGN}) +- target_link_libraries(${_executableName} ${Mathematica_MathLink_LIBRARIES}) ++ target_link_libraries(${_executableName} PRIVATE ${Mathematica_MathLink_LIBRARIES}) + if (Mathematica_MathLink_LINKER_FLAGS) + set_target_properties(${_executableName} PROPERTIES LINK_FLAGS "${Mathematica_MathLink_LINKER_FLAGS}") + endif() +@@ -4129,7 +4203,7 @@ function (Mathematica_WSTP_ADD_EXECUTABLE _executableName _templateFile) + _get_mprep_output_file("${_templateFile}" _outfile) + Mathematica_WSTP_WSPREP_TARGET(${_templateFile} OUTPUT ${_outfile}) + add_executable (${_executableName} WIN32 ${_outfile} ${ARGN}) +- target_link_libraries(${_executableName} ${Mathematica_WSTP_LIBRARIES}) ++ target_link_libraries(${_executableName} PRIVATE ${Mathematica_WSTP_LIBRARIES}) + if (Mathematica_WSTP_LINKER_FLAGS) + set_target_properties(${_executableName} PROPERTIES LINK_FLAGS "${Mathematica_WSTP_LINKER_FLAGS}") + endif() +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 5741f1c..1bc7e72 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -51,7 +68,7 @@ if(Mathematica_MathLink_FOUND) + Mathematica_MathLink_ADD_EXECUTABLE( + gm2calc.mx + gm2calc.tm) +- target_link_libraries(gm2calc.mx GM2Calc::GM2Calc) ++ target_link_libraries(gm2calc.mx PRIVATE GM2Calc::GM2Calc) + target_include_directories(gm2calc.mx + PRIVATE ${Mathematica_MathLink_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + install( diff --git a/recipes/gm2calc/all/test_package/conanfile.py b/recipes/gm2calc/all/test_package/conanfile.py index ff47fd2d9d893..ab40ee8b181e8 100644 --- a/recipes/gm2calc/all/test_package/conanfile.py +++ b/recipes/gm2calc/all/test_package/conanfile.py @@ -13,5 +13,5 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/gm2calc/config.yml b/recipes/gm2calc/config.yml index 6550f3aaeaffe..008d442d385b9 100644 --- a/recipes/gm2calc/config.yml +++ b/recipes/gm2calc/config.yml @@ -1,3 +1,7 @@ versions: "1.7.5": folder: all + "2.0.0": + folder: all + "2.1.0": + folder: all diff --git a/recipes/gmp/all/conanfile.py b/recipes/gmp/all/conanfile.py index 006945140df38..5ccdd6563bbde 100644 --- a/recipes/gmp/all/conanfile.py +++ b/recipes/gmp/all/conanfile.py @@ -1,32 +1,62 @@ from conans import ConanFile, AutoToolsBuildEnvironment, tools from conans.errors import ConanInvalidConfiguration -from contextlib import contextmanager +import contextlib +import functools import os import stat -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.36.0" class GmpConan(ConanFile): name = "gmp" - description = "GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers." + description = ( + "GMP is a free library for arbitrary precision arithmetic, operating " + "on signed integers, rational numbers, and floating-point numbers." + ) url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "gmp", "math") + topics = ("gmp", "math", "arbitrary", "precision", "integer") license = ("LGPL-3.0", "GPL-2.0") homepage = "https://gmplib.org" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False], - "disable_assembly": [True, False], "enable_fat": [True, False], - "run_checks": [True, False], "enable_cxx": [True, False]} - default_options = {"shared": False, "fPIC": True, "disable_assembly": True, "enable_fat": False, "run_checks": False, "enable_cxx": True} - exports_sources = "patches/*" - _autotools = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "disable_assembly": [True, False], + "enable_fat": [True, False], + "run_checks": [True, False], + "enable_cxx": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "disable_assembly": True, + "enable_fat": False, + "run_checks": False, + "enable_cxx": True, + } @property def _source_subfolder(self): return "source_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -34,8 +64,6 @@ def config_options(self): del self.options.enable_fat def configure(self): - if self.settings.compiler == "Visual Studio" and self.options.shared: - raise ConanInvalidConfiguration("Cannot build a shared library using Visual Studio: some error occurs at link time") if self.options.shared: del self.options.fPIC if self.options.get_safe("enable_fat"): @@ -44,29 +72,37 @@ def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def validate(self): + if self._is_msvc and self.options.shared: + raise ConanInvalidConfiguration("Cannot build a shared library using Visual Studio: some error occurs at link time") + def package_id(self): del self.info.options.run_checks # run_checks doesn't affect package's ID def build_requirements(self): - self.build_requires("m4/1.4.18") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") - if self.settings.compiler == "Visual Studio": + self.build_requires("m4/1.4.19") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + if self._is_msvc: self.build_requires("yasm/1.3.0") - self.build_requires("automake/1.16.3") + self.build_requires("automake/1.16.4") def source(self): tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + # Relocatable shared lib on macOS & fix permission issue if tools.is_apple_os(self.settings.os): configure_file = os.path.join(self._source_subfolder, "configure") - tools.replace_in_file(configure_file, r"-install_name \$rpath/", "-install_name ") + tools.replace_in_file(configure_file, "-install_name \\$rpath/", "-install_name @rpath/") configure_stats = os.stat(configure_file) os.chmod(configure_file, configure_stats.st_mode | stat.S_IEXEC) + + @functools.lru_cache(1) + def _configure_autotools(self): + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) yes_no = lambda v: "yes" if v else "no" configure_args = [ "--with-pic={}".format(yes_no(self.options.get_safe("fPIC", True))), @@ -77,21 +113,22 @@ def _configure_autotools(self): "--enable-static={}".format(yes_no(not self.options.shared)), "--srcdir={}".format(os.path.join(self.source_folder, self._source_subfolder).replace("\\", "/")), ] - if self.settings.compiler == "Visual Studio": + if self._is_msvc: configure_args.extend([ "ac_cv_c_restrict=restrict", "gmp_cv_asm_label_suffix=:", "lt_cv_sys_global_symbol_pipe=cat", # added to get further in shared MSVC build, but it gets stuck later ]) - self._autotools.flags.append("-FS") - # self._autotools.cxx_flags.append("-EHsc") - self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) - return self._autotools + if not (self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < 12): + autotools.flags.append("-FS") + autotools.cxx_flags.append("-EHsc") + autotools.configure(args=configure_args, configure_dir=self._source_subfolder) + return autotools - @contextmanager + @contextlib.contextmanager def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): + if self._is_msvc: + with tools.vcvars(self): yasm_machine = { "x86": "x86", "x86_64": "amd64", @@ -100,9 +137,9 @@ def _build_context(self): "CC": "cl -nologo", "CCAS": "{} -a x86 -m {} -p gas -r raw -f win32 -g null -X gnu".format(os.path.join(self.build_folder, "yasm_wrapper.sh").replace("\\", "/"), yasm_machine), "CXX": "cl -nologo", - "AR": "{} lib".format(self.deps_user_info["automake"].ar_lib.replace("\\", "/")), + "AR": "{} lib".format(self._user_info_build["automake"].ar_lib.replace("\\", "/")), "LD": "link -nologo", - "NM": "python {}/{}".format(self.build_folder.replace("\\", "/"), "dumpbin_nm.py"), + "NM": "python {}".format(tools.unix_path(os.path.join(self.build_folder, "dumpbin_nm.py"))), } with tools.environment_append(env): yield @@ -110,8 +147,7 @@ def _build_context(self): yield def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + self._patch_sources() with self._build_context(): autotools = self._configure_autotools() autotools.make() @@ -131,13 +167,21 @@ def package(self): tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") def package_info(self): + # Workaround to always provide a pkgconfig file depending on all components + self.cpp_info.set_property("pkg_config_name", "gmp-all-do-not-use") + + self.cpp_info.components["libgmp"].set_property("pkg_config_name", "gmp") self.cpp_info.components["libgmp"].libs = ["gmp"] - self.cpp_info.components["libgmp"].names["cmake_find_package"] = "GMP" - self.cpp_info.components["libgmp"].names["cmake_find_package_multi"] = "GMP" - self.cpp_info.components["libgmp"].names["pkg_config"] = "gmp" if self.options.enable_cxx: + self.cpp_info.components["gmpxx"].set_property("pkg_config_name", "gmpxx") self.cpp_info.components["gmpxx"].libs = ["gmpxx"] self.cpp_info.components["gmpxx"].requires = ["libgmp"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + # GMP doesn't have any official CMake Find nor config file, do not port these names to CMakeDeps + self.cpp_info.names["pkg_config"] = "gmp-all-do-not-use" + self.cpp_info.components["libgmp"].names["cmake_find_package"] = "GMP" + self.cpp_info.components["libgmp"].names["cmake_find_package_multi"] = "GMP" + if self.options.enable_cxx: self.cpp_info.components["gmpxx"].names["cmake_find_package"] = "GMPXX" self.cpp_info.components["gmpxx"].names["cmake_find_package_multi"] = "GMPXX" - self.cpp_info.components["gmpxx"].names["pkg_config"] = "gmpxx" diff --git a/recipes/gmp/all/patches/0001-msvc-dumpbin-yasm-wrapper.patch b/recipes/gmp/all/patches/0001-msvc-dumpbin-yasm-wrapper.patch index f67c8341c96d8..c802a6bfec0b6 100644 --- a/recipes/gmp/all/patches/0001-msvc-dumpbin-yasm-wrapper.patch +++ b/recipes/gmp/all/patches/0001-msvc-dumpbin-yasm-wrapper.patch @@ -1,6 +1,6 @@ --- /dev/null +++ dumpbin_nm.py -@@ -0,0 +1,27 @@ +@@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import re @@ -8,7 +8,8 @@ +import sys +#print(open(sys.argv[1], "rb").read()) +#output = subprocess.check_output(["dumpbin", "-nologo", "-symbols"] + sys.argv[1:], stderr=subprocess.STDOUT, text=True, shell=True) -+output = subprocess.check_output("dumpbin -nologo -symbols {}".format(sys.argv[1]), stderr=subprocess.STDOUT, text=True, shell=True) ++output = subprocess.check_output("dumpbin -nologo -symbols {}".format(sys.argv[1]), stderr=subprocess.STDOUT, shell=True) ++output = output.decode() +for line in output.splitlines(): + d = re.split("[ |]+", line.strip()) + if len(d) == 6: diff --git a/recipes/gmp/all/test_package/conanfile.py b/recipes/gmp/all/test_package/conanfile.py index 68704c6fb6281..605e1da44137b 100644 --- a/recipes/gmp/all/test_package/conanfile.py +++ b/recipes/gmp/all/test_package/conanfile.py @@ -14,7 +14,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) if self.options["gmp"].enable_cxx: diff --git a/recipes/gmp/config.yml b/recipes/gmp/config.yml index 533161c1da19f..7beafba5ffe63 100644 --- a/recipes/gmp/config.yml +++ b/recipes/gmp/config.yml @@ -1,7 +1,7 @@ versions: - "6.2.0": - folder: all "6.2.1": folder: all + "6.2.0": + folder: all "6.1.2": folder: all diff --git a/recipes/gn/all/conanfile.py b/recipes/gn/all/conanfile.py index 0891ab97d4f91..14fc7169fc53f 100644 --- a/recipes/gn/all/conanfile.py +++ b/recipes/gn/all/conanfile.py @@ -1,11 +1,14 @@ from conans import ConanFile, tools from conans.errors import ConanInvalidConfiguration from contextlib import contextmanager +import conan.tools.files as tools_files +import conan.tools.scm as tools_scm import os +import sys import textwrap import time -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.46.0" class GnConan(ConanFile): @@ -30,12 +33,12 @@ def _minimum_compiler_version_supporting_cxx17(self): "apple-clang": 10, }.get(str(self.settings.compiler)) - def configure(self): + def validate(self): if self.settings.compiler.cppstd: tools.check_min_cppstd(self, 17) else: if self._minimum_compiler_version_supporting_cxx17: - if tools.Version(self.settings.compiler.version) < self._minimum_compiler_version_supporting_cxx17: + if tools_scm.Version(self.settings.compiler.version) < self._minimum_compiler_version_supporting_cxx17: raise ConanInvalidConfiguration("gn requires a compiler supporting c++17") else: self.output.warn("gn recipe does not recognize the compiler. gn requires a compiler supporting c++17. Assuming it does.") @@ -44,7 +47,7 @@ def package_id(self): del self.info.settings.compiler def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder) + tools_files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder) def build_requirements(self): # FIXME: add cpython build requirements for `build/gen.py`. @@ -104,7 +107,7 @@ def build(self): ] if self.settings.build_type == "Debug": conf_args.append("-d") - self.run("python build/gen.py {}".format(" ".join(conf_args)), run_environment=True) + self.run("{} build/gen.py {}".format(sys.executable, " ".join(conf_args)), run_environment=True) # Try sleeping one second to avoid time skew of the generated ninja.build file (and having to re-run build/gen.py) time.sleep(1) build_args = [ @@ -122,3 +125,4 @@ def package_info(self): bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) + self.cpp_info.includedirs = [] diff --git a/recipes/gnu-config/all/conandata.yml b/recipes/gnu-config/all/conandata.yml index e0d1abc9d57ff..c687fcf43a384 100644 --- a/recipes/gnu-config/all/conandata.yml +++ b/recipes/gnu-config/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "cci.20210814": + url: "http://git.savannah.gnu.org/cgit/config.git/snapshot/config-191bcb948f7191c36eefe634336f5fc5c0c4c2be.tar.gz" + sha256: "302e5e7f3c4996976c58efde8b2f28f71d51357e784330eeed738e129300dc33" "cci.20201022": url: "http://git.savannah.gnu.org/cgit/config.git/snapshot/config-1c4398015583eb77bc043234f5734be055e64bea.tar.gz" sha256: "339eb64757bf5af9e23ca15daa136acdd9d778753377190ce17fba7e1b222aff" diff --git a/recipes/gnu-config/all/conanfile.py b/recipes/gnu-config/all/conanfile.py index aab759f79086d..58814fbffa9e0 100644 --- a/recipes/gnu-config/all/conanfile.py +++ b/recipes/gnu-config/all/conanfile.py @@ -1,28 +1,37 @@ -from conans import ConanFile, tools -from conans.errors import ConanException -import glob +from conan import ConanFile +from conan.errors import ConanException +from conan.tools.files import copy, get, load, save +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.52.0" + class GnuConfigConan(ConanFile): name = "gnu-config" description = "The GNU config.guess and config.sub scripts" homepage = "https://savannah.gnu.org/projects/config/" url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "gnu", "config", "autotools", "canonical", "host", "build", "target", "triplet") + topics = ("gnu", "config", "autotools", "canonical", "host", "build", "target", "triplet") license = "GPL-3.0-or-later", "autoconf-special-exception" + os = "arch", "compiler", "build_type", "arch" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(glob.glob("config*")[0], self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def _extract_license(self): - txt_lines = tools.load(os.path.join(self.source_folder, self._source_subfolder, "config.guess")).splitlines() + txt_lines = load(self, os.path.join(self.source_folder, "config.guess")).splitlines() start_index = None end_index = None for line_i, line in enumerate(txt_lines): @@ -37,17 +46,19 @@ def _extract_license(self): return "\n".join(txt_lines[start_index:end_index]) def package(self): - tools.save(os.path.join(self.package_folder, "licenses", "COPYING"), self._extract_license()) - self.copy("config.guess", src=self._source_subfolder, dst="bin") - self.copy("config.sub", src=self._source_subfolder, dst="bin") - - def package_id(self): - self.info.header_only() + save(self, os.path.join(self.package_folder, "licenses", "COPYING"), self._extract_license()) + copy(self, "config.guess", src=self.source_folder, dst=os.path.join(self.package_folder, "bin")) + copy(self, "config.sub", src=self.source_folder, dst=os.path.join(self.package_folder, "bin")) def package_info(self): + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) + self.conf_info.define("user.gnu-config:config_guess", os.path.join(bin_path, "config.guess")) + self.conf_info.define("user.gnu-config:config_sub", os.path.join(bin_path, "config.sub")) + # TODO: to remove in conan v2 self.user_info.CONFIG_GUESS = os.path.join(bin_path, "config.guess") self.user_info.CONFIG_SUB = os.path.join(bin_path, "config.sub") + self.env_info.PATH.append(bin_path) diff --git a/recipes/gnu-config/all/test_package/conanfile.py b/recipes/gnu-config/all/test_package/conanfile.py index c309b00b7f721..d50d33bfc8962 100644 --- a/recipes/gnu-config/all/test_package/conanfile.py +++ b/recipes/gnu-config/all/test_package/conanfile.py @@ -1,18 +1,27 @@ -from conans import ConanFile, tools -from conans.errors import ConanException +from conan import ConanFile +from conan.errors import ConanException +from conans import tools as tools_legacy -class TestConan(ConanFile): +class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + win_bash = True + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20190524") + self.tool_requires(self.tested_reference_str) + if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") def test(self): - triplet = tools.get_gnu_triplet(str(self.settings.os), str(self.settings.arch), str(self.settings.compiler)) - self.run("config.guess", run_environment=True, win_bash=tools.os_info.is_windows) + self.run("config.guess") try: - self.run("config.sub {}".format(triplet), run_environment=True, win_bash=tools.os_info.is_windows) + triplet = tools_legacy.get_gnu_triplet(str(self.settings.os), str(self.settings.arch), str(self.settings.compiler)) + self.run(f"config.sub {triplet}") except ConanException: self.output.info("Current configuration is not supported by GNU config.\nIgnoring...") diff --git a/recipes/gnu-config/all/test_v1_package/conanfile.py b/recipes/gnu-config/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..f98dcb17dfac3 --- /dev/null +++ b/recipes/gnu-config/all/test_v1_package/conanfile.py @@ -0,0 +1,22 @@ +from conans import ConanFile, tools +from conans.errors import ConanException + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def test(self): + self.run("config.guess", run_environment=True, win_bash=tools.os_info.is_windows) + try: + triplet = tools.get_gnu_triplet(str(self.settings.os), str(self.settings.arch), str(self.settings.compiler)) + self.run(f"config.sub {triplet}", run_environment=True, win_bash=tools.os_info.is_windows) + except ConanException: + self.output.info("Current configuration is not supported by GNU config.\nIgnoring...") diff --git a/recipes/gnu-config/config.yml b/recipes/gnu-config/config.yml index b38dca059d021..cf1827d502db3 100644 --- a/recipes/gnu-config/config.yml +++ b/recipes/gnu-config/config.yml @@ -1,3 +1,5 @@ versions: + "cci.20210814": + folder: "all" "cci.20201022": folder: "all" diff --git a/recipes/gnulib/all/conanfile.py b/recipes/gnulib/all/conanfile.py index 57a28e398ed20..8f85099afedec 100644 --- a/recipes/gnulib/all/conanfile.py +++ b/recipes/gnulib/all/conanfile.py @@ -1,28 +1,28 @@ from conans import ConanFile, tools import os -import re import shutil +required_conan_version = ">=1.33.0" + class GnuLibConanFile(ConanFile): name = "gnulib" description = "Gnulib is a central location for common GNU code, intended to be shared among GNU packages." homepage = "https://www.gnu.org/software/gnulib/" url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "gnulib", "library", "gnu") + topics = ("gnulib", "library", "gnu") license = ("GPL-3.0-or-later", "LGPL-3.0-or-later", "Unlicense") - no_copy_source = True - # Added to test on CI - settings = "os_build", "arch_build" + no_copy_source = True _source_subfolder = "source_subfolder" + def package_id(self): + self.info.header_only() + def source(self): - hash = re.search(r"h=([0-9a-f]*)", self.conan_data["sources"][self.version]["url"]).group(1) - dirname = "{}-{}".format(self.name, hash[:7]) - tools.get(**self.conan_data["sources"][self.version], filename="gnulib-{}.tar.gz".format(dirname)) - os.rename(dirname, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True, filename="gnulib.tar.gz") def package(self): self.copy("COPYING", src=self._source_subfolder, dst="licenses") @@ -43,10 +43,9 @@ def package(self): dst = os.path.join(dstdir, file) shutil.copy(src, dst) - def package_id(self): - self.info.include_build_settings() - def package_info(self): + self.cpp_info.libdirs = [] + binpath = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment var: {}".format(binpath)) self.env_info.PATH.append(binpath) diff --git a/recipes/gnulib/all/test_package/conanfile.py b/recipes/gnulib/all/test_package/conanfile.py index 6060c6a6a4e25..39d8fd2e49aac 100644 --- a/recipes/gnulib/all/test_package/conanfile.py +++ b/recipes/gnulib/all/test_package/conanfile.py @@ -1,5 +1,5 @@ from conans import ConanFile, tools, AutoToolsBuildEnvironment -from contextlib import contextmanager +import contextlib import os import shutil @@ -8,16 +8,19 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" exports_sources = "configure.ac", "Makefile.am", "test_package.c" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH") and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") - self.build_requires("automake/1.16.1") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + self.build_requires("automake/1.16.4") - @contextmanager + @contextlib.contextmanager def _build_context(self): if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): + with tools.vcvars(self): env = { "AR": "{} lib".format(tools.unix_path(os.path.join(self.build_folder, "build-aux", "ar-lib"))), "CC": "cl -nologo", @@ -39,9 +42,12 @@ def build(self): with tools.chdir(self.build_folder): for fn in ("COPYING", "NEWS", "INSTALL", "README", "AUTHORS", "ChangeLog"): tools.save(fn, "\n") - self.run("gnulib-tool --list", win_bash=tools.os_info.is_windows) - self.run("gnulib-tool --import getopt-posix", win_bash=tools.os_info.is_windows) - self.run("{} -ifv".format(os.environ["AUTORECONF"]), win_bash=tools.os_info.is_windows) + with tools.run_environment(self): + self.run("gnulib-tool --list", win_bash=tools.os_info.is_windows, run_environment=True) + self.run("gnulib-tool --import getopt-posix", win_bash=tools.os_info.is_windows, run_environment=True) + # m4 built with Visual Studio does not support executing *nix utils (e.g. `test`) + with tools.environment_append({"M4":None}) if self.settings.os == "Windows" else tools.no_op(): + self.run("{} -fiv".format(os.environ["AUTORECONF"]), win_bash=tools.os_info.is_windows, run_environment=True) with self._build_context(): autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) @@ -49,6 +55,6 @@ def build(self): autotools.make() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join(".", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/gobject-introspection/all/conandata.yml b/recipes/gobject-introspection/all/conandata.yml index 0d47aa99763e1..47eccc41d1faf 100644 --- a/recipes/gobject-introspection/all/conandata.yml +++ b/recipes/gobject-introspection/all/conandata.yml @@ -1,4 +1,13 @@ sources: + "1.72.0": + sha256: "02fe8e590861d88f83060dd39cda5ccaa60b2da1d21d0f95499301b186beaabc" + url: "https://download.gnome.org/sources/gobject-introspection/1.72/gobject-introspection-1.72.0.tar.xz" + "1.70.0": + url: "https://download.gnome.org/sources/gobject-introspection/1.70/gobject-introspection-1.70.0.tar.xz" + sha256: "902b4906e3102d17aa2fcb6dad1c19971c70f2a82a159ddc4a94df73a3cafc4a" + "1.69.0": + url: "https://download.gnome.org/sources/gobject-introspection/1.69/gobject-introspection-1.69.0.tar.xz" + sha256: "c668cbe4a3aad7539e2cf669ab576ce7fbadac6890472f4095ca215dbbebee99" "1.68.0": url: "https://download.gnome.org/sources/gobject-introspection/1.68/gobject-introspection-1.68.0.tar.xz" sha256: "d229242481a201b84a0c66716de1752bca41db4133672cfcfb37c93eb6e54a27" diff --git a/recipes/gobject-introspection/all/conanfile.py b/recipes/gobject-introspection/all/conanfile.py index 3fe487fe8e09e..4e30ffbb5f86f 100644 --- a/recipes/gobject-introspection/all/conanfile.py +++ b/recipes/gobject-introspection/all/conanfile.py @@ -4,6 +4,7 @@ import shutil import glob +required_conan_version = ">=1.36.0" class GobjectIntrospectionConan(ConanFile): name = "gobject-introspection" @@ -36,26 +37,29 @@ def config_options(self): raise ConanInvalidConfiguration("%s recipe does not support windows. Contributions are welcome!" % self.name) def build_requirements(self): - self.build_requires("meson/0.56.2") - self.build_requires("pkgconf/1.7.3") + if tools.Version(self.version) >= "1.71.0": + self.build_requires("meson/0.62.2") + else: + # https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/414 + self.build_requires("meson/0.59.3") + self.build_requires("pkgconf/1.7.4") if self.settings.os == "Windows": - self.build_requires("winflexbison/2.5.22") + self.build_requires("winflexbison/2.5.24") else: self.build_requires("flex/2.6.4") - self.build_requires("bison/3.7.1") + self.build_requires("bison/3.7.6") def requirements(self): - self.requires("glib/2.67.1") + self.requires("glib/2.73.0") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def _configure_meson(self): meson = Meson(self) defs = dict() defs["build_introspection_data"] = self.options["glib"].shared + defs["datadir"] = os.path.join(self.package_folder, "res") meson.configure( source_folder=self._source_subfolder, @@ -93,10 +97,7 @@ def package(self): meson = self._configure_meson() meson.install() tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - shutil.move( - os.path.join(self.package_folder, "share"), - os.path.join(self.package_folder, "res"), - ) + tools.rmdir(os.path.join(self.package_folder, "share")) for pdb_file in glob.glob(os.path.join(self.package_folder, "bin", "*.pdb")): os.unlink(pdb_file) @@ -110,3 +111,19 @@ def package_info(self): bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH env var with: {}".format(bin_path)) self.env_info.PATH.append(bin_path) + + exe_ext = ".exe" if self.settings.os == "Windows" else "" + + pkgconfig_variables = { + 'datadir': '${prefix}/res', + 'bindir': '${prefix}/bin', + 'g_ir_scanner': '${bindir}/g-ir-scanner', + 'g_ir_compiler': '${bindir}/g-ir-compiler%s' % exe_ext, + 'g_ir_generate': '${bindir}/g-ir-generate%s' % exe_ext, + 'gidatadir': '${datadir}/gobject-introspection-1.0', + 'girdir': '${datadir}/gir-1.0', + 'typelibdir': '${libdir}/girepository-1.0', + } + self.cpp_info.set_property( + "pkg_config_custom_content", + "\n".join("%s=%s" % (key, value) for key,value in pkgconfig_variables.items())) diff --git a/recipes/gobject-introspection/all/test_package/conanfile.py b/recipes/gobject-introspection/all/test_package/conanfile.py index c3dfda05c0109..32d4b65e5f11e 100644 --- a/recipes/gobject-introspection/all/test_package/conanfile.py +++ b/recipes/gobject-introspection/all/test_package/conanfile.py @@ -8,18 +8,19 @@ class TestPackageConan(ConanFile): def build(self): if self.settings.os != 'Windows': - self.run('g-ir-annotation-tool --version', run_environment=True) - self.run('g-ir-compiler --version', run_environment=True) - self.run('g-ir-generate --version', run_environment=True) - self.run('g-ir-inspect -h', run_environment=True) - self.run('g-ir-scanner --version', run_environment=True) + with tools.environment_append({'PKG_CONFIG_PATH': "."}): + pkg_config = tools.PkgConfig("gobject-introspection-1.0") + for tool in ["g_ir_compiler", "g_ir_generate", "g_ir_scanner"]: + self.run('%s --version' % pkg_config.variables[tool], run_environment=True) + self.run('g-ir-annotation-tool --version', run_environment=True) + self.run('g-ir-inspect -h', run_environment=True) cmake = CMake(self) cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/gobject-introspection/config.yml b/recipes/gobject-introspection/config.yml index ae69c06642666..06afabf3f5bc4 100644 --- a/recipes/gobject-introspection/config.yml +++ b/recipes/gobject-introspection/config.yml @@ -1,4 +1,10 @@ versions: + "1.72.0": + folder: all + "1.70.0": + folder: all + "1.69.0": + folder: all "1.68.0": folder: all "1.67.1": diff --git a/recipes/godot-cpp/all/conandata.yml b/recipes/godot-cpp/all/conandata.yml index a97d9e60449aa..ce95c40023693 100644 --- a/recipes/godot-cpp/all/conandata.yml +++ b/recipes/godot-cpp/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.3.4": + url: "https://github.com/godotengine/godot-cpp/archive/godot-3.3.4-stable.tar.gz" + sha256: "fa12b8dd8652109eceae7aecf134f64529edfb34ec33d24b1a9c220b40599575" "cci.3.2-20200130": url: "https://github.com/godotengine/godot-cpp/archive/aba8766618c6aa40c6f7b40b513e8e47cfa807f4.zip" sha256: "a6dba9cda3c36c669ffca2bb9dd4e372bcd1fbf23c74076505467247c15f0e77" diff --git a/recipes/godot-cpp/all/conanfile.py b/recipes/godot-cpp/all/conanfile.py index 3b26e9af59e6a..625aabfb6d902 100644 --- a/recipes/godot-cpp/all/conanfile.py +++ b/recipes/godot-cpp/all/conanfile.py @@ -96,6 +96,10 @@ def configure(self): "{} requires a compiler that supports at least C++{}".format(self.name, minimal_cpp_standard)) def build(self): + self.run("python --version") + if self.settings.os == "Macos": + self.run("which python") + self.run("scons --version") self.run( " ".join([ "scons", diff --git a/recipes/godot-cpp/all/test_package/conanfile.py b/recipes/godot-cpp/all/test_package/conanfile.py index 4aebe114eeb59..4dea15a1318e1 100644 --- a/recipes/godot-cpp/all/test_package/conanfile.py +++ b/recipes/godot-cpp/all/test_package/conanfile.py @@ -13,6 +13,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/godot-cpp/config.yml b/recipes/godot-cpp/config.yml index 9d35fa87c839a..0d66aae9da011 100644 --- a/recipes/godot-cpp/config.yml +++ b/recipes/godot-cpp/config.yml @@ -1,3 +1,5 @@ versions: + "3.3.4": + folder: all "cci.3.2-20200130": folder: all diff --git a/recipes/godot_headers/all/conandata.yml b/recipes/godot_headers/all/conandata.yml index fbe3297584025..8764611b2ac9a 100644 --- a/recipes/godot_headers/all/conandata.yml +++ b/recipes/godot_headers/all/conandata.yml @@ -1,7 +1,22 @@ sources: - "cci.3.2-20200130": - url: "https://github.com/godotengine/godot-headers/archive/ddf67cc7b8274c5fb77a71c828bab2991f1ee12a.zip" - sha256: "d62b1a2ae5b19ba1d116de754efb22c66a4425f31a4887b59249d9c0f073cc48" + "3.5.1": + url: "https://github.com/godotengine/godot-headers/archive/godot-3.5.1-stable.tar.gz" + sha256: "1c38268031425a4881c0d6d41926a0f1bf5847f05dc24c29332609e318276b6b" + "3.4.4": + url: "https://github.com/godotengine/godot-headers/archive/godot-3.4.4-stable.tar.gz" + sha256: "bb0eac00a4d5b800a4ca2555d11b4a35981bdb730b630e9bd31a0649fa1d6fd7" + "3.4": + url: "https://github.com/godotengine/godot-headers/archive/refs/tags/godot-3.4-stable.zip" + sha256: "584c8fedb9c521e0f21b37aed60a7bf76f417a196bb79205cf41b4e79a866237" + "3.3.4": + url: "https://github.com/godotengine/godot-headers/archive/godot-3.3.4-stable.tar.gz" + sha256: "14cff754199cc48dcf29b326ad4758c0bc71613acea9942de780815903a0d5a5" + "3.3.2": + url: "https://github.com/godotengine/godot-headers/archive/refs/tags/godot-3.3.2-stable.zip" + sha256: "0297aa9d0eb4374ecb82eb844f588343c6efbc39028473b96de12ca703aa1834" "3.2.3": url: "https://github.com/godotengine/godot-headers/archive/refs/tags/godot-3.2.3-stable.zip" sha256: "91815415a134ec061e1126a78d773bb13b28417f6dff34e02d54a38bf1b7e27d" + "cci.3.2-20200130": + url: "https://github.com/godotengine/godot-headers/archive/ddf67cc7b8274c5fb77a71c828bab2991f1ee12a.zip" + sha256: "d62b1a2ae5b19ba1d116de754efb22c66a4425f31a4887b59249d9c0f073cc48" diff --git a/recipes/godot_headers/all/conanfile.py b/recipes/godot_headers/all/conanfile.py index cf491e1038cb2..0a0d46219f9db 100644 --- a/recipes/godot_headers/all/conanfile.py +++ b/recipes/godot_headers/all/conanfile.py @@ -1,5 +1,9 @@ -import glob -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" class GodotHeadersConan(ConanFile): @@ -9,20 +13,28 @@ class GodotHeadersConan(ConanFile): homepage = "https://github.com/godotengine/godot_headers" description = "Godot Native interface headers" topics = ("game-engine", "game-development") + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - tools.rename(glob.glob("godot-headers-*")[0], self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE*", dst="licenses", src=self._source_subfolder) - self.copy("*.h", dst="include", src=self._source_subfolder) - self.copy("api.json", dst="res", src=self._source_subfolder) + copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) + copy(self, "api.json", src=self.source_folder, dst=os.path.join(self.package_folder, "res")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = ["res"] diff --git a/recipes/godot_headers/all/test_package/CMakeLists.txt b/recipes/godot_headers/all/test_package/CMakeLists.txt index df47d72ddd962..60556215726fc 100644 --- a/recipes/godot_headers/all/test_package/CMakeLists.txt +++ b/recipes/godot_headers/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project("test_package" LANGUAGES C) +project(test_package LANGUAGES C) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +find_package(godot_headers REQUIRED CONFIG) -add_executable("${PROJECT_NAME}" "test_package.c") -target_link_libraries("${PROJECT_NAME}" ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE godot_headers::godot_headers) diff --git a/recipes/godot_headers/all/test_package/conanfile.py b/recipes/godot_headers/all/test_package/conanfile.py index a59a26a52c8dc..0a6bc68712d90 100644 --- a/recipes/godot_headers/all/test_package/conanfile.py +++ b/recipes/godot_headers/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/godot_headers/all/test_v1_package/CMakeLists.txt b/recipes/godot_headers/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..643dedc50d02a --- /dev/null +++ b/recipes/godot_headers/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(godot_headers REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE godot_headers::godot_headers) diff --git a/recipes/godot_headers/all/test_v1_package/conanfile.py b/recipes/godot_headers/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/godot_headers/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/godot_headers/config.yml b/recipes/godot_headers/config.yml index 70bfd0d338fc1..3ded438e58f33 100644 --- a/recipes/godot_headers/config.yml +++ b/recipes/godot_headers/config.yml @@ -1,5 +1,15 @@ versions: - "cci.3.2-20200130": + "3.5.1": + folder: all + "3.4.4": + folder: all + "3.4": + folder: all + "3.3.4": + folder: all + "3.3.2": folder: all "3.2.3": folder: all + "cci.3.2-20200130": + folder: all diff --git a/recipes/google-cloud-cpp/all/CMakeLists.txt b/recipes/google-cloud-cpp/all/CMakeLists.txt index 16d33ed296f4b..a342eb16dcf1a 100644 --- a/recipes/google-cloud-cpp/all/CMakeLists.txt +++ b/recipes/google-cloud-cpp/all/CMakeLists.txt @@ -6,4 +6,9 @@ conan_basic_setup() set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +if(MSVC) + add_definitions("-D_SILENCE_CXX20_REL_OPS_DEPRECATION_WARNING") + add_definitions("-D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING") +endif() + add_subdirectory("source_subfolder") diff --git a/recipes/google-cloud-cpp/all/conandata.yml b/recipes/google-cloud-cpp/all/conandata.yml index 6050548850107..a410b93b2e064 100644 --- a/recipes/google-cloud-cpp/all/conandata.yml +++ b/recipes/google-cloud-cpp/all/conandata.yml @@ -2,7 +2,22 @@ sources: "1.26.1": url: "https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v1.26.1.tar.gz" sha256: "83108515fc59c72cdb87f178712256f4b0098e1ca5dc6f64c2c20dd2f1e1559d" + "1.27.0": + url: "https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v1.27.0.tar.gz" + sha256: "84a7ac7b63db986bb737462e374c11fc6f35f6020ccaacec1d0e4d61ec929528" + "1.30.1": + url: "https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v1.30.1.tar.gz" + sha256: "b651a58cb44bd715f0cb8e42c7ea58490b3e768a35ede01d798b983eef88e143" + "1.31.1": + url: "https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v1.31.1.tar.gz" + sha256: "dc7cbf95b506a84b48cf71e0462985d262183edeaabdacaaee2109852394a609" + "1.40.1": + url: "https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v1.40.1.tar.gz" + sha256: "fb62f0e7dc964c5d3cd0d85977b85f3e0e7dce97e9029abf9c32ecc29db07043" patches: "1.26.1": - patch_file: "patches/0001-googleapis-folder.patch" base_path: "source_subfolder" + "1.27.0": + - patch_file: "patches/0001-googleapis-folder.patch" + base_path: "source_subfolder" diff --git a/recipes/google-cloud-cpp/all/conanfile.py b/recipes/google-cloud-cpp/all/conanfile.py index 5a61edb9d2fda..30fac004d5e19 100644 --- a/recipes/google-cloud-cpp/all/conanfile.py +++ b/recipes/google-cloud-cpp/all/conanfile.py @@ -1,9 +1,11 @@ import os +import textwrap +import functools from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.33.0" class GoogleCloudCppConan(ConanFile): name = "google-cloud-cpp" @@ -12,7 +14,6 @@ class GoogleCloudCppConan(ConanFile): topics = "google", "cloud", "google-cloud-storage", "google-cloud-platform", "google-cloud-pubsub", "google-cloud-spanner", "google-cloud-bigtable" homepage = "https://github.com/googleapis/google-cloud-cpp" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/*"] generators = "cmake", "cmake_find_package_multi", "cmake_find_package" settings = "os", "arch", "compiler", "build_type" options = { @@ -31,6 +32,11 @@ class GoogleCloudCppConan(ConanFile): def _source_subfolder(self): return "source_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -38,10 +44,18 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - + + def validate(self): if self.settings.os == 'Windows' and self.options.shared: raise ConanInvalidConfiguration("Fails to compile for Windows as a DLL") + if hasattr(self, "settings_build") and tools.cross_building(self): + raise ConanInvalidConfiguration("Recipe not prepared for cross-building (yet)") + + if tools.Version(self.version) >= "1.30.0": + if self.settings.compiler == 'clang' and tools.Version(self.settings.compiler.version) < "6.0": + raise ConanInvalidConfiguration("Clang version must be at least 6.0.") + if self.settings.compiler.cppstd: tools.check_min_cppstd(self, 11) @@ -56,39 +70,56 @@ def source(self): tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def requirements(self): - self.requires('protobuf/3.15.5') - self.requires('grpc/1.37.1') - self.requires('nlohmann_json/3.9.1') - self.requires('crc32c/1.1.1') - self.requires('abseil/20210324.0') - self.requires('libcurl/7.75.0') - self.requires('openssl/1.1.1k') + self.requires('protobuf/3.20.0') + self.requires('grpc/1.45.2') + self.requires('nlohmann_json/3.10.5') + self.requires('crc32c/1.1.2') + self.requires('abseil/20211102.0') + self.requires('libcurl/7.80.0') + self.requires('openssl/1.1.1n') # TODO: Add googleapis once it is available in CCI (now it is embedded) + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = 0 - - self._cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_MACOS_OPENSSL_CHECK"] = False - - self._cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_BIGTABLE"] = True - self._cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_BIGQUERY"] = True - self._cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_SPANNER"] = True - self._cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_STORAGE"] = True - self._cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_FIRESTORE"] = True - self._cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_PUBSUB"] = True - self._cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_IAM"] = True - self._cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_LOGGING"] = True - self._cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_GENERATOR"] = True - - self._cmake.configure() - return self._cmake - - def build(self): + # Do not build in parallel for certain configurations, it fails writting/reading files at the same time + parallel = not (self.settings.compiler == "Visual Studio" and self.settings.compiler.version == "16" and self.version in ["1.31.1", "1.30.1"]) + cmake = CMake(self, parallel=parallel) + cmake.definitions["BUILD_TESTING"] = 0 + + cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_MACOS_OPENSSL_CHECK"] = False + + cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_BIGTABLE"] = True + cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_BIGQUERY"] = True + cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_SPANNER"] = True + cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_STORAGE"] = True + cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_FIRESTORE"] = True + cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_PUBSUB"] = True + cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_IAM"] = True + cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_LOGGING"] = True + cmake.definitions["GOOGLE_CLOUD_CPP_ENABLE_GENERATOR"] = True + + cmake.configure() + return cmake + + def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) + + if tools.Version(self.version) < "1.33.0": + # Do not override CMAKE_CXX_STANDARD if provided + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + textwrap.dedent("""\ + set(CMAKE_CXX_STANDARD + 11 + CACHE STRING "Configure the C++ standard version for all targets.")"""), + textwrap.dedent("""\ + if(NOT "${CMAKE_CXX_STANDARD}") + set(CMAKE_CXX_STANDARD 11 CACHE STRING "Configure the C++ standard version for all targets.") + endif() + """)) + + def build(self): + self._patch_sources() cmake = self._configure_cmake() cmake.build() @@ -100,180 +131,244 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) def package_info(self): - # Using componen google-cloud-common, so it reduces the risk of conflict (pkgconfig generator) - self.cpp_info.components["google-cloud-common"].requires = ["abseil::absl_any", "abseil::absl_flat_hash_map", "abseil::absl_memory", "abseil::absl_optional", "abseil::absl_time"] - self.cpp_info.components["google-cloud-common"].libs = ["google_cloud_cpp_common"] - self.cpp_info.components["google-cloud-common"].names["cmake_find_package"] = "common" - self.cpp_info.components["google-cloud-common"].names["cmake_find_package_multi"] = "common" + self.cpp_info.components["common"].requires = ["abseil::absl_any", "abseil::absl_flat_hash_map", "abseil::absl_memory", "abseil::absl_optional", "abseil::absl_time"] + self.cpp_info.components["common"].libs = ["google_cloud_cpp_common"] + self.cpp_info.components["common"].names["pkg_config"] = "google_cloud_cpp_common" - self.cpp_info.components["experimental-bigquery"].requires = ["grpc_utils", "google-cloud-common", "cloud_bigquery_protos"] + self.cpp_info.components["experimental-bigquery"].requires = ["grpc_utils", "common", "cloud_bigquery_protos"] self.cpp_info.components["experimental-bigquery"].libs = ["google_cloud_cpp_bigquery"] + self.cpp_info.components["experimental-bigquery"].names["pkg_config"] = "google_cloud_cpp_bigquery" - self.cpp_info.components["bigtable"].requires = ["abseil::absl_memory", "bigtable_protos", "google-cloud-common", "grpc_utils", "grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] + self.cpp_info.components["bigtable"].requires = ["abseil::absl_memory", "bigtable_protos", "common", "grpc_utils", "grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["bigtable"].libs = ["google_cloud_cpp_bigtable"] + self.cpp_info.components["bigtable"].names["pkg_config"] = "google_cloud_cpp_bigtable" - self.cpp_info.components["experimental-firestore"].requires = ["google-cloud-common"] - self.cpp_info.components["experimental-firestore"].libs = ["google_cloud_cpp_firestore"] - + if tools.Version(self.version) < "1.40.1": # FIXME: Probably this library was removed before + self.cpp_info.components["experimental-firestore"].requires = ["common"] + self.cpp_info.components["experimental-firestore"].libs = ["google_cloud_cpp_firestore"] + self.cpp_info.components["experimental-firestore"].names["pkg_config"] = "google_cloud_cpp_firestore" + self.cpp_info.components["bigtable_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "api_resource_protos", "iam_v1_iam_policy_protos", "iam_v1_policy_protos", "longrunning_operations_protos", "rpc_status_protos", "api_auth_protos"] self.cpp_info.components["bigtable_protos"].libs = ["google_cloud_cpp_bigtable_protos"] + self.cpp_info.components["bigtable_protos"].names["pkg_config"] = "google_cloud_cpp_bigtable_protos" self.cpp_info.components["cloud_bigquery_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "api_resource_protos", "iam_v1_iam_policy_protos", "iam_v1_policy_protos", "rpc_status_protos", "api_http_protos"] self.cpp_info.components["cloud_bigquery_protos"].libs = ["google_cloud_cpp_cloud_bigquery_protos"] + self.cpp_info.components["cloud_bigquery_protos"].names["pkg_config"] = "google_cloud_cpp_cloud_bigquery_protos" self.cpp_info.components["cloud_speech_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "longrunning_operations_protos", "rpc_status_protos"] self.cpp_info.components["cloud_speech_protos"].libs = ["google_cloud_cpp_cloud_speech_protos"] + self.cpp_info.components["cloud_speech_protos"].names["pkg_config"] = "google_cloud_cpp_cloud_speech_protos" self.cpp_info.components["cloud_texttospeech_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos"] self.cpp_info.components["cloud_texttospeech_protos"].libs = ["google_cloud_cpp_cloud_texttospeech_protos"] + self.cpp_info.components["cloud_texttospeech_protos"].names["pkg_config"] = "google_cloud_cpp_cloud_texttospeech_protos" self.cpp_info.components["iam_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "api_resource_protos"] self.cpp_info.components["iam_protos"].libs = ["google_cloud_cpp_iam_protos"] + self.cpp_info.components["iam_protos"].names["pkg_config"] = "google_cloud_cpp_iam_protos" self.cpp_info.components["pubsub_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "api_resource_protos"] self.cpp_info.components["pubsub_protos"].libs = ["google_cloud_cpp_pubsub_protos"] + self.cpp_info.components["pubsub_protos"].names["pkg_config"] = "google_cloud_cpp_pubsub_protos" self.cpp_info.components["spanner_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "api_resource_protos", "iam_v1_iam_policy_protos", "iam_v1_policy_protos", "longrunning_operations_protos", "rpc_status_protos"] self.cpp_info.components["spanner_protos"].libs = ["google_cloud_cpp_spanner_protos"] + self.cpp_info.components["spanner_protos"].names["pkg_config"] = "google_cloud_cpp_spanner_protos" self.cpp_info.components["storage_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "iam_v1_iam_policy_protos", "iam_v1_policy_protos"] self.cpp_info.components["storage_protos"].libs = ["google_cloud_cpp_storage_protos"] + self.cpp_info.components["storage_protos"].names["pkg_config"] = "google_cloud_cpp_storage_protos" self.cpp_info.components["longrunning_operations_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "rpc_status_protos"] self.cpp_info.components["longrunning_operations_protos"].libs = ["google_cloud_cpp_longrunning_operations_protos"] + self.cpp_info.components["longrunning_operations_protos"].names["pkg_config"] = "google_cloud_cpp_longrunning_operations_protos" self.cpp_info.components["api_http_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["api_http_protos"].libs = ["google_cloud_cpp_api_http_protos"] + self.cpp_info.components["api_http_protos"].names["pkg_config"] = "google_cloud_cpp_api_http_protos" self.cpp_info.components["api_annotations_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_http_protos"] self.cpp_info.components["api_annotations_protos"].libs = ["google_cloud_cpp_api_annotations_protos"] + self.cpp_info.components["api_annotations_protos"].names["pkg_config"] = "google_cloud_cpp_api_annotations_protos" self.cpp_info.components["api_auth_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos"] self.cpp_info.components["api_auth_protos"].libs = ["google_cloud_cpp_api_auth_protos"] + self.cpp_info.components["api_auth_protos"].names["pkg_config"] = "google_cloud_cpp_api_auth_protos" self.cpp_info.components["api_client_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["api_client_protos"].libs = ["google_cloud_cpp_api_client_protos"] + self.cpp_info.components["api_client_protos"].names["pkg_config"] = "google_cloud_cpp_api_client_protos" self.cpp_info.components["api_distribution_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["api_distribution_protos"].libs = ["google_cloud_cpp_api_distribution_protos"] + self.cpp_info.components["api_distribution_protos"].names["pkg_config"] = "google_cloud_cpp_api_distribution_protos" self.cpp_info.components["api_field_behavior_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["api_field_behavior_protos"].libs = ["google_cloud_cpp_api_field_behavior_protos"] + self.cpp_info.components["api_field_behavior_protos"].names["pkg_config"] = "google_cloud_cpp_api_field_behavior_protos" self.cpp_info.components["api_label_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["api_label_protos"].libs = ["google_cloud_cpp_api_label_protos"] + self.cpp_info.components["api_label_protos"].names["pkg_config"] = "google_cloud_cpp_api_label_protos" self.cpp_info.components["api_launch_stage_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["api_launch_stage_protos"].libs = ["google_cloud_cpp_api_launch_stage_protos"] + self.cpp_info.components["api_launch_stage_protos"].names["pkg_config"] = "google_cloud_cpp_api_launch_stage_protos" self.cpp_info.components["api_metric_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_launch_stage_protos", "api_label_protos"] self.cpp_info.components["api_metric_protos"].libs = ["google_cloud_cpp_api_metric_protos"] + self.cpp_info.components["api_metric_protos"].names["pkg_config"] = "google_cloud_cpp_api_metric_protos" self.cpp_info.components["api_monitored_resource_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_launch_stage_protos", "api_label_protos"] self.cpp_info.components["api_monitored_resource_protos"].libs = ["google_cloud_cpp_api_monitored_resource_protos"] + self.cpp_info.components["api_monitored_resource_protos"].names["pkg_config"] = "google_cloud_cpp_api_monitored_resource_protos" self.cpp_info.components["api_resource_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["api_resource_protos"].libs = ["google_cloud_cpp_api_resource_protos"] + self.cpp_info.components["api_resource_protos"].names["pkg_config"] = "google_cloud_cpp_api_resource_protos" self.cpp_info.components["devtools_cloudtrace_v2_trace_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_field_behavior_protos", "api_resource_protos", "rpc_status_protos"] self.cpp_info.components["devtools_cloudtrace_v2_trace_protos"].libs = ["google_cloud_cpp_devtools_cloudtrace_v2_trace_protos"] + self.cpp_info.components["devtools_cloudtrace_v2_trace_protos"].names["pkg_config"] = "google_cloud_cpp_devtools_cloudtrace_v2_trace_protos" self.cpp_info.components["devtools_cloudtrace_v2_tracing_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "devtools_cloudtrace_v2_trace_protos", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "rpc_status_protos"] self.cpp_info.components["devtools_cloudtrace_v2_tracing_protos"].libs = ["google_cloud_cpp_devtools_cloudtrace_v2_tracing_protos"] - - self.cpp_info.components["logging_type_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos"] - self.cpp_info.components["logging_type_protos"].libs = ["google_cloud_cpp_logging_type_protos"] - - self.cpp_info.components["logging_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_distribution_protos", "api_field_behavior_protos", "api_metric_protos", "api_monitored_resource_protos", "api_resource_protos", "logging_type_protos", "rpc_status_protos"] + self.cpp_info.components["devtools_cloudtrace_v2_tracing_protos"].names["pkg_config"] = "google_cloud_cpp_devtools_cloudtrace_v2_tracing_protos" + + cmp_logging_type_type_protos = None + if tools.Version(self.version) < "1.40.1": # FIXME: Probably this library was removed before + cmp_logging_type_type_protos = "logging_type_protos" + self.cpp_info.components[cmp_logging_type_type_protos].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos"] + self.cpp_info.components[cmp_logging_type_type_protos].libs = ["google_cloud_cpp_logging_type_protos"] + self.cpp_info.components[cmp_logging_type_type_protos].names["pkg_config"] = "google_cloud_cpp_logging_type_protos" + else: + cmp_logging_type_type_protos = "logging_type_type_protos" + self.cpp_info.components[cmp_logging_type_type_protos].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos"] + self.cpp_info.components[cmp_logging_type_type_protos].libs = ["google_cloud_cpp_logging_type_type_protos"] + self.cpp_info.components[cmp_logging_type_type_protos].names["pkg_config"] = "google_cloud_cpp_logging_type_type_protos" + + self.cpp_info.components["logging_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_distribution_protos", "api_field_behavior_protos", "api_metric_protos", "api_monitored_resource_protos", "api_resource_protos", cmp_logging_type_type_protos, "rpc_status_protos"] self.cpp_info.components["logging_protos"].libs = ["google_cloud_cpp_logging_protos"] + self.cpp_info.components["logging_protos"].names["pkg_config"] = "google_cloud_cpp_logging_protos" self.cpp_info.components["monitoring_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_distribution_protos", "api_field_behavior_protos", "api_label_protos", "api_launch_stage_protos", "api_metric_protos", "api_monitored_resource_protos", "api_resource_protos", "rpc_status_protos", "type_calendar_period_protos"] self.cpp_info.components["monitoring_protos"].libs = ["google_cloud_cpp_monitoring_protos"] + self.cpp_info.components["monitoring_protos"].names["pkg_config"] = "google_cloud_cpp_monitoring_protos" self.cpp_info.components["iam_v1_options_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos"] self.cpp_info.components["iam_v1_options_protos"].libs = ["google_cloud_cpp_iam_v1_options_protos"] + self.cpp_info.components["iam_v1_options_protos"].names["pkg_config"] = "google_cloud_cpp_iam_v1_options_protos" self.cpp_info.components["iam_v1_policy_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "type_expr_protos"] self.cpp_info.components["iam_v1_policy_protos"].libs = ["google_cloud_cpp_iam_v1_policy_protos"] + self.cpp_info.components["iam_v1_policy_protos"].names["pkg_config"] = "google_cloud_cpp_iam_v1_policy_protos" self.cpp_info.components["iam_v1_iam_policy_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "api_resource_protos", "iam_v1_options_protos", "iam_v1_policy_protos"] self.cpp_info.components["iam_v1_iam_policy_protos"].libs = ["google_cloud_cpp_iam_v1_iam_policy_protos"] + self.cpp_info.components["iam_v1_iam_policy_protos"].names["pkg_config"] = "google_cloud_cpp_iam_v1_iam_policy_protos" self.cpp_info.components["rpc_error_details_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["rpc_error_details_protos"].libs = ["google_cloud_cpp_rpc_error_details_protos"] + self.cpp_info.components["rpc_error_details_protos"].names["pkg_config"] = "google_cloud_cpp_rpc_error_details_protos" self.cpp_info.components["rpc_status_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "rpc_error_details_protos"] self.cpp_info.components["rpc_status_protos"].libs = ["google_cloud_cpp_rpc_status_protos"] + self.cpp_info.components["rpc_status_protos"].names["pkg_config"] = "google_cloud_cpp_rpc_status_protos" self.cpp_info.components["type_calendar_period_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_calendar_period_protos"].libs = ["google_cloud_cpp_type_calendar_period_protos"] + self.cpp_info.components["type_calendar_period_protos"].names["pkg_config"] = "google_cloud_cpp_type_calendar_period_protos" self.cpp_info.components["type_color_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_color_protos"].libs = ["google_cloud_cpp_type_color_protos"] + self.cpp_info.components["type_color_protos"].names["pkg_config"] = "google_cloud_cpp_type_color_protos" self.cpp_info.components["type_date_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_date_protos"].libs = ["google_cloud_cpp_type_date_protos"] + self.cpp_info.components["type_date_protos"].names["pkg_config"] = "google_cloud_cpp_type_date_protos" self.cpp_info.components["type_datetime_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_datetime_protos"].libs = ["google_cloud_cpp_type_datetime_protos"] + self.cpp_info.components["type_datetime_protos"].names["pkg_config"] = "google_cloud_cpp_type_datetime_protos" self.cpp_info.components["type_dayofweek_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_dayofweek_protos"].libs = ["google_cloud_cpp_type_dayofweek_protos"] + self.cpp_info.components["type_dayofweek_protos"].names["pkg_config"] = "google_cloud_cpp_type_dayofweek_protos" self.cpp_info.components["type_expr_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_expr_protos"].libs = ["google_cloud_cpp_type_expr_protos"] + self.cpp_info.components["type_expr_protos"].names["pkg_config"] = "google_cloud_cpp_type_expr_protos" self.cpp_info.components["type_fraction_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_fraction_protos"].libs = ["google_cloud_cpp_type_fraction_protos"] + self.cpp_info.components["type_fraction_protos"].names["pkg_config"] = "google_cloud_cpp_type_fraction_protos" self.cpp_info.components["type_interval_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_interval_protos"].libs = ["google_cloud_cpp_type_interval_protos"] + self.cpp_info.components["type_interval_protos"].names["pkg_config"] = "google_cloud_cpp_type_interval_protos" self.cpp_info.components["type_latlng_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_latlng_protos"].libs = ["google_cloud_cpp_type_latlng_protos"] + self.cpp_info.components["type_latlng_protos"].names["pkg_config"] = "google_cloud_cpp_type_latlng_protos" self.cpp_info.components["type_localized_text_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_localized_text_protos"].libs = ["google_cloud_cpp_type_localized_text_protos"] + self.cpp_info.components["type_localized_text_protos"].names["pkg_config"] = "google_cloud_cpp_type_localized_text_protos" self.cpp_info.components["type_money_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_money_protos"].libs = ["google_cloud_cpp_type_money_protos"] + self.cpp_info.components["type_money_protos"].names["pkg_config"] = "google_cloud_cpp_type_money_protos" self.cpp_info.components["type_month_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_month_protos"].libs = ["google_cloud_cpp_type_month_protos"] + self.cpp_info.components["type_month_protos"].names["pkg_config"] = "google_cloud_cpp_type_month_protos" self.cpp_info.components["type_phone_number_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_phone_number_protos"].libs = ["google_cloud_cpp_type_phone_number_protos"] + self.cpp_info.components["type_phone_number_protos"].names["pkg_config"] = "google_cloud_cpp_type_phone_number_protos" self.cpp_info.components["type_postal_address_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_postal_address_protos"].libs = ["google_cloud_cpp_type_postal_address_protos"] + self.cpp_info.components["type_postal_address_protos"].names["pkg_config"] = "google_cloud_cpp_type_postal_address_protos" self.cpp_info.components["type_quaternion_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_quaternion_protos"].libs = ["google_cloud_cpp_type_quaternion_protos"] + self.cpp_info.components["type_quaternion_protos"].names["pkg_config"] = "google_cloud_cpp_type_quaternion_protos" self.cpp_info.components["type_timeofday_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf"] self.cpp_info.components["type_timeofday_protos"].libs = ["google_cloud_cpp_type_timeofday_protos"] + self.cpp_info.components["type_timeofday_protos"].names["pkg_config"] = "google_cloud_cpp_type_timeofday_protos" self.cpp_info.components["cloud_dialogflow_v2_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "api_resource_protos", "longrunning_operations_protos", "rpc_status_protos", "type_latlng_protos"] self.cpp_info.components["cloud_dialogflow_v2_protos"].libs = ["google_cloud_cpp_cloud_dialogflow_v2_protos"] + self.cpp_info.components["cloud_dialogflow_v2_protos"].names["pkg_config"] = "google_cloud_cpp_cloud_dialogflow_v2_protos" - self.cpp_info.components["cloud_dialogflow_v2beta1_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "api_resource_protos", "longrunning_operations_protos", "rpc_status_protos", "type_latlng_protos"] - self.cpp_info.components["cloud_dialogflow_v2beta1_protos"].libs = ["google_cloud_cpp_cloud_dialogflow_v2beta1_protos"] + if tools.Version(self.version) < "1.40.1": # FIXME: Probably this library was removed before + self.cpp_info.components["cloud_dialogflow_v2beta1_protos"].requires = ["grpc::grpc++", "grpc::grpc", "protobuf::libprotobuf", "api_annotations_protos", "api_client_protos", "api_field_behavior_protos", "api_resource_protos", "longrunning_operations_protos", "rpc_status_protos", "type_latlng_protos"] + self.cpp_info.components["cloud_dialogflow_v2beta1_protos"].libs = ["google_cloud_cpp_cloud_dialogflow_v2beta1_protos"] + self.cpp_info.components["cloud_dialogflow_v2beta1_protos"].names["pkg_config"] = "google_cloud_cpp_cloud_dialogflow_v2beta1_protos" - self.cpp_info.components["grpc_utils"].requires = ["abseil::absl_function_ref", "abseil::absl_memory", "abseil::absl_time", "rpc_status_protos", "google-cloud-common", "grpc::grpc++", "grpc::grpc"] + self.cpp_info.components["grpc_utils"].requires = ["abseil::absl_function_ref", "abseil::absl_memory", "abseil::absl_time", "rpc_status_protos", "common", "grpc::grpc++", "grpc::grpc"] self.cpp_info.components["grpc_utils"].libs = ["google_cloud_cpp_grpc_utils"] + self.cpp_info.components["grpc_utils"].names["pkg_config"] = "google_cloud_cpp_grpc_utils" - self.cpp_info.components["experimental-iam"].requires = ["grpc_utils", "google-cloud-common", "iam_protos"] + self.cpp_info.components["experimental-iam"].requires = ["grpc_utils", "common", "iam_protos"] self.cpp_info.components["experimental-iam"].libs = ["google_cloud_cpp_iam"] + self.cpp_info.components["experimental-iam"].names["pkg_config"] = "google_cloud_cpp_iam" - self.cpp_info.components["experimental-logging"].requires = ["grpc_utils", "google-cloud-common", "logging_protos"] + self.cpp_info.components["experimental-logging"].requires = ["grpc_utils", "common", "logging_protos"] self.cpp_info.components["experimental-logging"].libs = ["google_cloud_cpp_logging"] + self.cpp_info.components["experimental-logging"].names["pkg_config"] = "google_cloud_cpp_logging" - self.cpp_info.components["pubsub"].requires = ["grpc_utils", "google-cloud-common", "pubsub_protos", "abseil::absl_flat_hash_map"] + self.cpp_info.components["pubsub"].requires = ["grpc_utils", "common", "pubsub_protos", "abseil::absl_flat_hash_map"] self.cpp_info.components["pubsub"].libs = ["google_cloud_cpp_pubsub"] + self.cpp_info.components["pubsub"].names["pkg_config"] = "google_cloud_cpp_pubsub" - self.cpp_info.components["spanner"].requires = ["abseil::absl_fixed_array", "abseil::absl_memory", "abseil::absl_numeric", "abseil::absl_strings", "abseil::absl_time", "grpc_utils", "google-cloud-common", "spanner_protos"] + self.cpp_info.components["spanner"].requires = ["abseil::absl_fixed_array", "abseil::absl_memory", "abseil::absl_numeric", "abseil::absl_strings", "abseil::absl_time", "grpc_utils", "common", "spanner_protos"] self.cpp_info.components["spanner"].libs = ["google_cloud_cpp_spanner"] + self.cpp_info.components["spanner"].names["pkg_config"] = "google_cloud_cpp_spanner" - self.cpp_info.components["storage"].requires = ["abseil::absl_memory", "abseil::absl_strings", "abseil::absl_str_format", "abseil::absl_time", "abseil::absl_variant", "google-cloud-common", "nlohmann_json::nlohmann_json", "crc32c::crc32c", "libcurl::libcurl", "openssl::ssl", "openssl::crypto"] + self.cpp_info.components["storage"].requires = ["abseil::absl_memory", "abseil::absl_strings", "abseil::absl_str_format", "abseil::absl_time", "abseil::absl_variant", "common", "nlohmann_json::nlohmann_json", "crc32c::crc32c", "libcurl::libcurl", "openssl::ssl", "openssl::crypto"] self.cpp_info.components["storage"].libs = ["google_cloud_cpp_storage"] - + self.cpp_info.components["storage"].names["pkg_config"] = "google_cloud_cpp_storage" diff --git a/recipes/google-cloud-cpp/config.yml b/recipes/google-cloud-cpp/config.yml index 1c836b17b3afa..79daaecfa3b4d 100644 --- a/recipes/google-cloud-cpp/config.yml +++ b/recipes/google-cloud-cpp/config.yml @@ -1,3 +1,11 @@ versions: "1.26.1": folder: "all" + "1.27.0": + folder: "all" + "1.30.1": + folder: "all" + "1.31.1": + folder: "all" + "1.40.1": + folder: "all" diff --git a/recipes/googleapis/all/CMakeLists.txt b/recipes/googleapis/all/CMakeLists.txt new file mode 100644 index 0000000000000..78db768f95305 --- /dev/null +++ b/recipes/googleapis/all/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.20) +# CMake >= 3.20 is required. There is a proto with dots in the name 'k8s.min.proto' and CMake fails to generate project files + +project(googleapis) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(Protobuf REQUIRED CONFIG) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) diff --git a/recipes/googleapis/all/conandata.yml b/recipes/googleapis/all/conandata.yml new file mode 100644 index 0000000000000..719b54343e312 --- /dev/null +++ b/recipes/googleapis/all/conandata.yml @@ -0,0 +1,21 @@ +# Source code for googleapis is vendorized in (at least) two other libreries: grpc and google-cloud-cpp, +# these libraries use an specific commit from googleapis repository. +# +# - google-cloud-cpp: https://github.com/googleapis/google-cloud-cpp/blob/main/cmake/GoogleapisConfig.cmake +# - grpc: +# (old versions) https://github.com/grpc/grpc/tree/v1.46.3/third_party +# (master branch) https://github.com/grpc/grpc/blob/master/CMakeLists.txt#L347 + +sources: + "cci.20220711": + url: "https://github.com/googleapis/googleapis/archive/220b13e335ea8e0153c84c56a135a19d15384621.zip" + sha256: "0a8aac018f49f8595fc0fbfe53f46d73b2fb42661a425746be802302928e6ac2" + "cci.20220531": # Used by google-cloud-cpp 1.41.0 + url: "https://github.com/googleapis/googleapis/archive/f19049fdd8dfc8b6eba387f4ef6d1d8b4d0103e7.zip" + sha256: "d4ebe22c0a8a884adbeb63f72ab1fee4b15bad0a535de37cabba427a37711ee8" + "cci.20211122": # Used by google-cloud-cpp 1.34.1 + url: "https://github.com/googleapis/googleapis/archive/eddd3d845b5d462c0f2fb2d1bf764b921ae70a93.zip" + sha256: "3d49dc722113100617dc02ee6b3331e61fa28a1616777375553f3d8e25d4e302" + "cci.20210730": # Used by grpc 1.46.3 + url: "https://github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.zip" + sha256: "c53ef0768e07bd4e2334cdacba8c6672d2252bef307a889f94893652e8e7f3a4" diff --git a/recipes/googleapis/all/conanfile.py b/recipes/googleapis/all/conanfile.py new file mode 100644 index 0000000000000..022bfade0055c --- /dev/null +++ b/recipes/googleapis/all/conanfile.py @@ -0,0 +1,183 @@ +import os +import functools +import glob +from io import StringIO + +from conans import CMake, tools + +from conan import ConanFile +from conan.tools.files import get, copy +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version + +from conan.errors import ConanInvalidConfiguration + +from helpers import parse_proto_libraries + +required_conan_version = ">=1.45.0" + +class GoogleAPIS(ConanFile): + name = "googleapis" + description = "Public interface definitions of Google APIs" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/googleapis/googleapis" + topics = "google", "protos", "api" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + exports = "helpers.py" + short_paths = True + + def export_sources(self): + self.copy("CMakeLists.txt") + + def source(self): + get(self, **self.conan_data["sources"][str(self.version)], destination=self.source_folder, strip_root=True) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + self.options["protobuf"].shared = True + + def validate(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, 11) + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) <= "5": + raise ConanInvalidConfiguration("Build with GCC 5 fails") + + if is_msvc(self) and self.options.shared: + raise ConanInvalidConfiguration("Source code generated from protos is missing some export macro") + if self.options.shared and not self.options["protobuf"].shared: + raise ConanInvalidConfiguration("If built as shared, protobuf must be shared as well. Please, use `protobuf:shared=True`") + + def requirements(self): + self.requires('protobuf/3.21.4') + + @property + def _cmake_new_enough(self): + try: + import re + output = StringIO() + self.run("cmake --version", output=output) + m = re.search(r'cmake version (\d+)\.(\d+)\.(\d+)', output.getvalue()) + major, minor = int(m.group(1)), int(m.group(2)) + assert major >= 3 and minor >= 20 + except: + return False + else: + return True + + def build_requirements(self): + self.build_requires('protobuf/3.21.4') + # CMake >= 3.20 is required. There is a proto with dots in the name 'k8s.min.proto' and CMake fails to generate project files + if not self._cmake_new_enough: + self.build_requires('cmake/3.23.2') + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure() + return cmake + + @functools.lru_cache(1) + def _parse_proto_libraries(self): + # Generate the libraries to build dynamically + proto_libraries = [] + for filename in glob.iglob(os.path.join(self.source_folder, 'google', '**', 'BUILD.bazel'), recursive=True): + proto_libraries += parse_proto_libraries(filename, self.source_folder, self.output.error) + + for filename in glob.iglob(os.path.join(self.source_folder, 'grafeas', '**', 'BUILD.bazel'), recursive=True): + proto_libraries += parse_proto_libraries(filename, self.source_folder, self.output.error) + + # Validate that all files exist and all dependencies are found + all_deps = [f"{it.qname}:{it.name}" for it in proto_libraries] + all_deps += ["protobuf::libprotobuf"] + for it in proto_libraries: + it.validate(self.source_folder, all_deps) + + # Mark the libraries we need recursively (C++ context) + all_dict = {f"{it.qname}:{it.name}": it for it in proto_libraries} + + def activate_library(proto_library): + proto_library.is_used = True + for it_dep in proto_library.deps: + if it_dep == "protobuf::libprotobuf": + continue + activate_library(all_dict[it_dep]) + + for it in filter(lambda u: u.is_used, proto_libraries): + activate_library(it) + + # Tweaks + def deactivate_library(key): + if key in all_dict: + all_dict[key].is_used = False + # - Inconvenient macro names from usr/include/sys/syslimits.h in some macOS SDKs: GID_MAX + # Patched here: https://github.com/protocolbuffers/protobuf/commit/f138d5de2535eb7dd7c8d0ad5eb16d128ab221fd + # as of 3.21.4 issue still exist + if Version(self.deps_cpp_info["protobuf"].version) <= "3.21.5" and self.settings.os == "Macos" or \ + self.settings.os == "Android": + deactivate_library("//google/storagetransfer/v1:storagetransfer_proto") + # - Inconvenient macro names from /usr/include/math.h : DOMAIN + if (self.settings.os == "Linux" and self.settings.compiler == "clang" and self.settings.compiler.libcxx == "libc++") or \ + self.settings.compiler in ["Visual Studio", "msvc"]: + deactivate_library("//google/cloud/channel/v1:channel_proto") + deactivate_library("//google/cloud/channel/v1:channel_cc_proto") + # - Inconvenient names for android + if self.settings.os == "Android": + deactivate_library("//google/identity/accesscontextmanager/type:type_proto") + deactivate_library("//google/identity/accesscontextmanager/type:type_cc_proto") + deactivate_library("//google/identity/accesscontextmanager/v1:accesscontextmanager_proto") + deactivate_library("//google/identity/accesscontextmanager/v1:accesscontextmanager_cc_proto") + deactivate_library("//google/devtools/testing/v1:testing_proto") + deactivate_library("//google/devtools/testing/v1:testing_cc_proto") + deactivate_library("//google/devtools/resultstore/v2:resultstore_proto") + deactivate_library("//google/devtools/resultstore/v2:resultstore_cc_proto") + deactivate_library("//google/cloud/talent/v4beta1:talent_proto") + deactivate_library("//google/cloud/talent/v4beta1:talent_cc_proto") + deactivate_library("//google/cloud/talent/v4:talent_proto") + deactivate_library("//google/cloud/talent/v4:talent_cc_proto") + deactivate_library("//google/cloud/asset/v1:asset_proto") + deactivate_library("//google/cloud/asset/v1:asset_cc_proto") + + return proto_libraries + + def build(self): + proto_libraries = self._parse_proto_libraries() + with open(os.path.join(self.source_folder, "CMakeLists.txt"), "a", encoding="utf-8") as f: + for it in filter(lambda u: u.is_used, proto_libraries): + f.write(it.cmake_content) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, pattern="*.proto", src=self.source_folder, dst=os.path.join(self.package_folder, "res")) + copy(self, pattern="*.pb.h", src=self.build_folder, dst=os.path.join(self.package_folder, "include")) + + copy(self, pattern="*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, pattern="*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False) + copy(self, pattern="*.so*", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, pattern="*.dylib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, pattern="*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + + def package_id(self): + self.info.requires["protobuf"].full_package_mode() + + def package_info(self): + # We are not creating components, we can just collect the libraries + self.cpp_info.libs = tools.collect_libs(self) + if self.settings.os == "Linux": + self.cpp_info.system_libs.extend(["m"]) diff --git a/recipes/googleapis/all/helpers.py b/recipes/googleapis/all/helpers.py new file mode 100644 index 0000000000000..9f3881f847e6f --- /dev/null +++ b/recipes/googleapis/all/helpers.py @@ -0,0 +1,169 @@ +import os +import re +import textwrap + +class _ProtoLibrary: + name: str = None + qname: str = None + srcs: list = None + deps: list = None + is_cc: bool = False + is_used: bool = False + + def __init__(self, is_cc) -> None: + self.srcs = [] + self.deps = set(["protobuf::libprotobuf"]) # Add to all libraries even if not explicitly set + self.is_cc = is_cc + self.is_used = self.is_cc + + def validate(self, source_folder, all_deps): + # Check all files exists + for it in self.srcs: + assert os.path.exists(os.path.join(source_folder, it)), f"{self.qname}:{self.name} - file '{it}' doesn't exist" + # Check all deps exists + for it in self.deps: + assert it in all_deps, f"{self.qname}:{self.name} - dep '{it}' not found" + + def dumps(self): + import json + return json.dumps({ + "name": self.name, + "qname": self.qname, + "srcs": self.srcs, + "deps": list(self.deps), + "is_cc": self.is_cc, + }, indent=4) + + @property + def cmake_target(self): + qname = self.qname + if self.qname.startswith("//"): + qname = qname[2:] + return f'{qname.replace("/", "_")}_{self.name}' + + @property + def cmake_deps(self): + def to_cmake_target(item): + if item.startswith("//"): + return item[2:].replace("/", "_").replace(":", "_") + return item + return [to_cmake_target(it) for it in self.deps] + + @property + def cmake_content(self): + content = f"\n\n# {self.cmake_target}\n" + content += "\n".join([f"#{it}" for it in self.dumps().split('\n')]) + content += "\n" + if not self.srcs: + content += textwrap.dedent(f"""\ + add_library({self.cmake_target} INTERFACE) + """) + else: + content += textwrap.dedent(f"""\ + set({self.cmake_target}_PROTOS {" ".join(["${CMAKE_SOURCE_DIR}/"+it for it in self.srcs])}) + add_library({self.cmake_target} ${{{self.cmake_target}_PROTOS}}) + target_include_directories({self.cmake_target} PUBLIC ${{CMAKE_BINARY_DIR}}) + target_compile_features({self.cmake_target} PUBLIC cxx_std_11) + protobuf_generate(LANGUAGE cpp + TARGET {self.cmake_target} + PROTOS ${{{self.cmake_target}_PROTOS}} + IMPORT_DIRS ${{CMAKE_SOURCE_DIR}} + ) + """) + + if self.deps: + content += textwrap.dedent(f"""\ + target_link_libraries({self.cmake_target} {"PUBLIC" if self.srcs else "INTERFACE"} {" ".join(self.cmake_deps)}) + """) + + return content + +def parse_proto_libraries(filename, source_folder, error): + # Generate the libraries to build dynamically + re_name = re.compile(r'name = "(.*)"') + re_srcs_oneline = re.compile(r'srcs = \["(.*)"\],') + re_deps_oneline = re.compile(r'deps = \["(.*)"\],') + re_add_varname = re.compile(r'] \+ (.*),') + + proto_libraries = [] + + basedir = os.path.dirname(filename) + current_folder_str = os.path.relpath(basedir, source_folder).replace('\\', '/') # We need forward slashes because of Windows + proto_library = None + + def parsing_sources(line): + proto_path = os.path.relpath(os.path.join(basedir, line.strip(",").strip("\"")), source_folder).replace('\\', '/') + proto_library.srcs.append(proto_path) + + def parsing_deps(line): + line = line.strip(",").strip("\"") + if line.startswith("@com_google_protobuf//:"): + proto_library.deps.add("protobuf::libprotobuf") + elif line.startswith("@com_google_googleapis//"): + proto_library.deps.add(line[len("@com_google_googleapis"):]) + elif line.startswith(":"): + proto_library.deps.add(f"//{current_folder_str}{line}") + elif line.startswith("//google/"): + proto_library.deps.add(line) + elif line.startswith("//grafeas/"): + proto_library.deps.add(line) + else: + error(f"Unrecognized dep: {line} -- {os.path.relpath(filename, source_folder)}") + + def collecting_items(collection, line): + line = line.strip(",").strip("\"") + collection.append(line) + + with open(filename, 'r') as f: + action = None + parsing_variable = None + variables = {} + for line in f.readlines(): + line = line.strip() + + if line == "proto_library(": + assert proto_library == None + proto_library = _ProtoLibrary(is_cc=False) + elif line == "cc_proto_library(": + assert proto_library == None + proto_library = _ProtoLibrary(is_cc=True) + elif line == '_PROTO_SUBPACKAGE_DEPS = [': + variables["_PROTO_SUBPACKAGE_DEPS"] = [] + parsing_variable = lambda u: collecting_items(variables["_PROTO_SUBPACKAGE_DEPS"], u) + elif parsing_variable != None: + if line == "]": + parsing_variable = None + else: + parsing_variable(line) + elif proto_library != None: + if line.startswith("name ="): + proto_library.name = re_name.search(line).group(1) + proto_library.qname = f"//{current_folder_str}" + elif line.startswith("srcs = "): + m = re_srcs_oneline.search(line) + if m: + parsing_sources(m.group(1)) + else: + action = parsing_sources + elif line.startswith("deps = "): + m = re_deps_oneline.search(line) + if m: + parsing_deps(m.group(1)) + else: + action = parsing_deps + elif line.startswith("visibility = "): + pass + elif line == ")": + proto_libraries.append(proto_library) + proto_library = None + action = None + elif line == "],": + action = None + elif line.startswith("] + "): + varname = re_add_varname.search(line).group(1) + for it in variables[varname]: + action(it) + elif action: + action(line) + + return proto_libraries diff --git a/recipes/googleapis/all/test_package/CMakeLists.txt b/recipes/googleapis/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d676bb7ea7cdc --- /dev/null +++ b/recipes/googleapis/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(googleapis REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE googleapis::googleapis) diff --git a/recipes/googleapis/all/test_package/conanfile.py b/recipes/googleapis/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e279a6afcd236 --- /dev/null +++ b/recipes/googleapis/all/test_package/conanfile.py @@ -0,0 +1,29 @@ +import os +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain +from conan.tools.build import cross_building as tools_cross_building +from conan.tools.layout import cmake_layout + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools_cross_building(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/recipes/googleapis/all/test_package/test_package.cpp b/recipes/googleapis/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..32f0b086e3717 --- /dev/null +++ b/recipes/googleapis/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include +#include "google/type/color.pb.h" + +int main() { + std::cout << "Conan - test package for googleapis\n"; + + google::type::Color c; + c.set_red(255); + c.set_blue(255); + + std::cout << c.DebugString(); + + return 0; +} diff --git a/recipes/googleapis/all/test_v1_package/CMakeLists.txt b/recipes/googleapis/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d1b58c810713b --- /dev/null +++ b/recipes/googleapis/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(googleapis REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE googleapis::googleapis) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/googleapis/all/test_v1_package/conanfile.py b/recipes/googleapis/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/recipes/googleapis/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/googleapis/config.yml b/recipes/googleapis/config.yml new file mode 100644 index 0000000000000..0df9fcd3465bb --- /dev/null +++ b/recipes/googleapis/config.yml @@ -0,0 +1,9 @@ +versions: + "cci.20220711": + folder: all + "cci.20220531": + folder: all + "cci.20211122": + folder: all + "cci.20210730": + folder: all diff --git a/recipes/gperf/all/conandata.yml b/recipes/gperf/all/conandata.yml index 67db34810f28b..abb928a47430d 100644 --- a/recipes/gperf/all/conandata.yml +++ b/recipes/gperf/all/conandata.yml @@ -2,3 +2,7 @@ sources: "3.1": url: "https://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz" sha256: "588546b945bba4b70b6a3a616e80b4ab466e3f33024a352fc2198112cdbb3ae2" +patches: + "3.1": + - patch_file: "patches/0001-remove-register-keyword.patch" + base_path: "source_subfolder" diff --git a/recipes/gperf/all/conanfile.py b/recipes/gperf/all/conanfile.py index 886c1ee8d6457..216d9b3fea59d 100644 --- a/recipes/gperf/all/conanfile.py +++ b/recipes/gperf/all/conanfile.py @@ -1,82 +1,98 @@ from conans import ConanFile, tools, AutoToolsBuildEnvironment +from contextlib import contextmanager import os +required_conan_version = ">=1.33.0" + + class GperfConan(ConanFile): name = "gperf" license = "GPL-3.0-or-later" url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.gnu.org/software/gperf" description = "GNU gperf is a perfect hash function generator" - topics = ("conan", "gperf", "hash-generator", "hash") - settings = "os", "arch", "compiler" - _source_subfolder = "source_subfolder" + topics = ("gperf", "hash-generator", "hash") + + settings = "os", "arch", "compiler", "build_type" + + exports_sources = "patches/*" _autotools = None + @property + def _source_subfolder(self): + return "source_subfolder" + @property def _is_msvc(self): return self.settings.compiler == "Visual Studio" + def package_id(self): + del self.info.settings.compiler + @property - def _is_mingw_windows(self): - return self.settings.os == "Windows" and tools.os_info.is_windows and self.settings.compiler == "gcc" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def build_requirements(self): - if self.settings.os == "Windows" and tools.os_info.is_windows: - if "CONAN_BASH_PATH" not in os.environ and tools.os_info.detect_windows_subsystem() != 'msys2': - self.build_requires("msys2/20190524") + if self._is_msvc: + self.build_requires("automake/1.16.3") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_autotools(self): if not self._autotools: - args = [] - cwd = os.getcwd() - win_bash = self._is_msvc or self._is_mingw_windows - self._autotools = AutoToolsBuildEnvironment(self, win_bash=win_bash) - if self._is_msvc: - args.extend(["CC={}/build-aux/compile cl -nologo".format(cwd), - "CFLAGS=-{}".format(self.settings.compiler.runtime), - "CXX={}/build-aux/compile cl -nologo".format(cwd), - "CXXFLAGS=-{}".format(self.settings.compiler.runtime), - "CPPFLAGS=-D_WIN32_WINNT=_WIN32_WINNT_WIN8", - "LD=link", - "NM=dumpbin -symbols", - "STRIP=:", - "AR={}/build-aux/ar-lib lib".format(cwd), - "RANLIB=:"]) - elif self.settings.compiler == "gcc" and self.settings.os == "Windows": - self._autotools.link_flags.extend(["-static", "-static-libgcc"]) - - self._autotools.configure(args=args) + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + if self._is_msvc and tools.Version(self.settings.compiler.version) >= "12": + self._autotools.flags.append("-FS") + self._autotools.configure() return self._autotools - def _build_configure(self): + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + @contextmanager + def _build_context(self): with tools.chdir(self._source_subfolder): - autotools = self._configure_autotools() - autotools.make() + if self._is_msvc: + with tools.vcvars(self.settings): + env = { + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CFLAGS": "-{}".format(self.settings.compiler.runtime), + "CXXLAGS": "-{}".format(self.settings.compiler.runtime), + "CPPFLAGS": "-D_WIN32_WINNT=_WIN32_WINNT_WIN8", + "LD": "link", + "NM": "dumpbin -symbols", + "STRIP": ":", + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), + "RANLIB": ":", + } + with tools.environment_append(env): + yield + else: + yield def build(self): - if self._is_msvc: - with tools.vcvars(self.settings): - self._build_configure() - else: - self._build_configure() + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() def package(self): self.copy("COPYING", dst="licenses", src=self._source_subfolder) - with tools.chdir(self._source_subfolder): + with self._build_context(): autotools = self._configure_autotools() autotools.install() tools.rmdir(os.path.join(self.package_folder, "share")) - def package_id(self): - self.info.include_build_settings() - del self.info.settings.compiler - def package_info(self): + self.cpp_info.includedirs = [] bindir = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bindir)) self.env_info.PATH.append(bindir) diff --git a/recipes/gperf/all/patches/0001-remove-register-keyword.patch b/recipes/gperf/all/patches/0001-remove-register-keyword.patch new file mode 100644 index 0000000000000..8af66429ebaaa --- /dev/null +++ b/recipes/gperf/all/patches/0001-remove-register-keyword.patch @@ -0,0 +1,13 @@ +diff --git a/lib/getline.cc b/lib/getline.cc +index ecc3e85..2d97644 100644 (file) +--- a/lib/getline.cc ++++ b/lib/getline.cc +@@ -55,7 +55,7 @@ getstr (char **lineptr, size_t *n, FILE *stream, char terminator, size_t offset) + + for (;;) + { +- register int c = getc (stream); ++ int c = getc (stream); + + /* We always want at least one char left in the buffer, since we + always (unless we get an error while reading the first char) diff --git a/recipes/gperf/all/test_package/conanfile.py b/recipes/gperf/all/test_package/conanfile.py index 42eb4b5e978fc..5ea7c84d8f6b0 100644 --- a/recipes/gperf/all/test_package/conanfile.py +++ b/recipes/gperf/all/test_package/conanfile.py @@ -2,10 +2,8 @@ class TestPackageConan(ConanFile): - - settings = "arch_build", "os_build" + settings = "os", "arch" def test(self): - bin_ext = ".exe" if self.settings.os_build == "Windows" else "" - if not tools.cross_building(self.settings): - self.run("gperf{} --version".format(bin_ext)) + if not tools.cross_building(self): + self.run("gperf --version", run_environment=True) diff --git a/recipes/graphene/all/conandata.yml b/recipes/graphene/all/conandata.yml index 7d5c5b17d13b4..b181922a1829a 100644 --- a/recipes/graphene/all/conandata.yml +++ b/recipes/graphene/all/conandata.yml @@ -8,3 +8,6 @@ sources: "1.10.6": url: "https://github.com/ebassi/graphene/archive/1.10.6.tar.gz" sha256: "7eba972751d404316a9b59a7c1e0782de263c3cf9dd5ebf1503ba9b8354cc948" + "1.10.8": + url: "https://github.com/ebassi/graphene/archive/1.10.8.tar.gz" + sha256: "922dc109d2dc5dc56617a29bd716c79dd84db31721a8493a13a5f79109a4a4ed" diff --git a/recipes/graphene/all/conanfile.py b/recipes/graphene/all/conanfile.py index 2dea280231270..24a18f93603a5 100644 --- a/recipes/graphene/all/conanfile.py +++ b/recipes/graphene/all/conanfile.py @@ -1,18 +1,31 @@ -from conans import ConanFile, Meson, tools -from conans.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.29.0" +from conan import ConanFile +from conan.tools.meson import MesonToolchain, Meson +from conan.tools.gnu import PkgConfigDeps +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import ( + copy, + get, + rename, + rm, + rmdir +) +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version +from conan.tools.layout import basic_layout +from conan.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.52.0" + class LibnameConan(ConanFile): name = "graphene" description = "A thin layer of graphic data types." - topics = ("conan", "graphene") + topics = ("graphic", "canvas", "types") url = "https://github.com/conan-io/conan-center-index" homepage = "http://ebassi.github.io/graphene/" license = "MIT" - generators = "pkg_config" - settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -25,78 +38,100 @@ class LibnameConan(ConanFile): "with_glib": True, } - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if self.settings.compiler == "gcc": - if tools.Version(self.settings.compiler.version) < "5.0": - raise ConanInvalidConfiguration("graphene does not support GCC before 5.0") - + def build_requirements(self): - self.build_requires("meson/0.57.1") - self.build_requires("pkgconf/1.7.3") - + self.tool_requires("meson/0.63.3") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/1.9.3") + def requirements(self): if self.options.with_glib: - self.requires("glib/2.67.6") + self.requires("glib/2.74.1") def configure(self): if self.options.shared: del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + if self.options.shared and self.options.with_glib: + self.options["glib"].shared = True - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def validate(self): + if self.settings.compiler == "gcc": + if Version(self.settings.compiler.version) < "5.0": + raise ConanInvalidConfiguration("graphene does not support GCC before 5.0") - def _configure_meson(self): - meson = Meson(self) - defs = {} - defs["gobject_types"] = "true" if self.options.with_glib else "false" - if tools.Version(self.version) < "1.10.4": - defs["introspection"] = "false" + if self.info.options.with_glib: + glib_is_shared = self.dependencies["glib"].options.shared + if self.info.options.shared and not glib_is_shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) + if glib_is_shared and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) + + def layout(self): + basic_layout(self, src_folder="src") + + def generate(self): + deps = PkgConfigDeps(self) + deps.generate() + + meson = MesonToolchain(self) + meson.project_options.update({ + "tests": "false", + "installed_tests": "false", + "gtk_doc": "false" + }) + meson.project_options["gobject_types"] = "true" if self.options.with_glib else "false" + if Version(self.version) < "1.10.4": + meson.project_options["introspection"] = "false" else: - defs["introspection"] = "disabled" - defs["tests"] = "false" - defs["installed_tests"] = "false" - defs["gtk_doc"] = "false" - args=[] - args.append("--wrap-mode=nofallback") - meson.configure(defs=defs, build_folder=self._build_subfolder, source_folder=self._source_subfolder, pkg_config_paths=[self.install_folder], args=args) - return meson + meson.project_options["introspection"] = "disabled" + meson.generate() + + venv = VirtualBuildEnv(self) + venv.generate() + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) def build(self): - with tools.environment_append(tools.RunEnvironment(self).vars): - meson = self._configure_meson() - meson.build() + meson = Meson(self) + meson.configure() + meson.build() def package(self): - self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - meson = self._configure_meson() - with tools.environment_append({"PKG_CONFIG_PATH": self.install_folder}): - meson.install() - - if self.settings.compiler == "Visual Studio" and not self.options.shared: - with tools.chdir(os.path.join(self.package_folder, "lib")): - if os.path.isfile("libgraphene-1.0.a"): - tools.rename("libgraphene-1.0.a", "graphene-1.0.lib") - - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(self.package_folder, "*.pdb") + meson = Meson(self) + meson.install() + copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) + + if is_msvc(self) and not self.options.shared: + libfolder = os.path.join(self.package_folder, "lib") + rename(self, os.path.join(libfolder, "libgraphene-1.0.a"), os.path.join(libfolder, "graphene-1.0.lib")) + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.pdb", self.package_folder, recursive=True) def package_info(self): + self.cpp_info.components["graphene-1.0"].set_property("pkg_config_name", "graphene-1.0") self.cpp_info.components["graphene-1.0"].libs = ["graphene-1.0"] self.cpp_info.components["graphene-1.0"].includedirs = [os.path.join("include", "graphene-1.0"), os.path.join("lib", "graphene-1.0", "include")] - self.cpp_info.components["graphene-1.0"].names["pkg_config"] = "graphene-1.0" + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["graphene-1.0"].system_libs = ["m", "pthread"] if self.options.with_glib: self.cpp_info.components["graphene-1.0"].requires = ["glib::gobject-2.0"] if self.options.with_glib: + self.cpp_info.components["graphene-gobject-1.0"].set_property("pkg_config_name","graphene-gobject-1.0") self.cpp_info.components["graphene-gobject-1.0"].includedirs = [os.path.join("include", "graphene-1.0")] - self.cpp_info.components["graphene-gobject-1.0"].names["pkg_config"] = "graphene-gobject-1.0" self.cpp_info.components["graphene-gobject-1.0"].requires = ["graphene-1.0", "glib::gobject-2.0"] + + def package_id(self): + if self.options.with_glib and not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() diff --git a/recipes/graphene/all/test_package/CMakeLists.txt b/recipes/graphene/all/test_package/CMakeLists.txt index afa2476357074..086ffbaad4058 100644 --- a/recipes/graphene/all/test_package/CMakeLists.txt +++ b/recipes/graphene/all/test_package/CMakeLists.txt @@ -1,9 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(graphene CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE graphene::graphene) diff --git a/recipes/graphene/all/test_package/conanfile.py b/recipes/graphene/all/test_package/conanfile.py index bd7165a553cf4..6c64a877f7976 100644 --- a/recipes/graphene/all/test_package/conanfile.py +++ b/recipes/graphene/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -from conans import ConanFile, CMake, tools import os +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run + class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +22,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/graphene/all/test_package/test_package.c b/recipes/graphene/all/test_package/test_package.c index fce49bb77045e..77235d38af7ed 100644 --- a/recipes/graphene/all/test_package/test_package.c +++ b/recipes/graphene/all/test_package/test_package.c @@ -1,5 +1,4 @@ #include "graphene.h" -#include int main (int argc, char **argv) { diff --git a/recipes/graphene/all/test_v1_package/CMakeLists.txt b/recipes/graphene/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0eed825b22dae --- /dev/null +++ b/recipes/graphene/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(graphene CONFIG REQUIRED) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/graphene/all/test_v1_package/conanfile.py b/recipes/graphene/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/graphene/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/graphene/config.yml b/recipes/graphene/config.yml index fb227f38a2523..17c2fa360d757 100644 --- a/recipes/graphene/config.yml +++ b/recipes/graphene/config.yml @@ -5,3 +5,5 @@ versions: folder: "all" "1.10.6": folder: "all" + "1.10.8": + folder: "all" diff --git a/recipes/greatest/all/conandata.yml b/recipes/greatest/all/conandata.yml index 3444607fe55f2..79a70bd7bbd68 100644 --- a/recipes/greatest/all/conandata.yml +++ b/recipes/greatest/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.5.0": + url: "https://github.com/silentbicycle/greatest/archive/v1.5.0.tar.gz" + sha256: "33e4c93b1b7f631fec173b8675582d1739b1238a5440b7f4ad50582f0cf38c34" "1.4.2": url: "https://github.com/silentbicycle/greatest/archive/v1.4.2.tar.gz" sha256: "9adea2add921513a9106b7197d82e608f96ad37be808a4def3342cf8e7445998" diff --git a/recipes/greatest/all/conanfile.py b/recipes/greatest/all/conanfile.py index 61ccd5f9fe142..cda1c077e6c1d 100644 --- a/recipes/greatest/all/conanfile.py +++ b/recipes/greatest/all/conanfile.py @@ -1,5 +1,4 @@ from conans import ConanFile, tools -import os class GreatestConan(ConanFile): @@ -8,7 +7,7 @@ class GreatestConan(ConanFile): license = "ISC" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/silentbicycle/greatest" - topics = ("conan", "testing", "testing-framework", "unit-testing", "header-only") + topics = ("testing", "testing-framework", "unit-testing", "header-only") no_copy_source = True @property @@ -16,9 +15,8 @@ def _source_subfolder(self): return "source_subfolder" def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "{0}-{1}".format(self.name, self.version) - os.rename(extracted_folder, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) diff --git a/recipes/greatest/all/test_package/conanfile.py b/recipes/greatest/all/test_package/conanfile.py index b88a6525524a6..d4128b0450777 100644 --- a/recipes/greatest/all/test_package/conanfile.py +++ b/recipes/greatest/all/test_package/conanfile.py @@ -1,4 +1,4 @@ -from conans import ConanFile, CMake +from conans import ConanFile, CMake, tools import os @@ -12,5 +12,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/greatest/config.yml b/recipes/greatest/config.yml index ba127d382373b..e11ce33fecb95 100644 --- a/recipes/greatest/config.yml +++ b/recipes/greatest/config.yml @@ -1,3 +1,5 @@ versions: + "1.5.0": + folder: all "1.4.2": folder: all diff --git a/recipes/greg7mdp-gtl/all/conandata.yml b/recipes/greg7mdp-gtl/all/conandata.yml new file mode 100644 index 0000000000000..03c557a0c1185 --- /dev/null +++ b/recipes/greg7mdp-gtl/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "1.1.5": + url: "https://github.com/greg7mdp/gtl/archive/v1.1.5.tar.gz" + sha256: "2d943d2ccc33c6c662918efc51782dac414354a1458441f16041a98eec164bda" + "1.1.4": + url: "https://github.com/greg7mdp/gtl/archive/v1.1.4.tar.gz" + sha256: "b51b9951d11fb73ed22360a96a3f6c691c15202c3b14c79dcdd498da80b6502d" + "1.1.3": + url: "https://github.com/greg7mdp/gtl/archive/refs/tags/v1.1.3.tar.gz" + sha256: "c667690eeecf37f660d8a61bca1076e845154bc535c44ec0d2404c04c66ae228" + "1.1.2": + url: "https://github.com/greg7mdp/gtl/archive/refs/tags/v1.1.2.tar.gz" + sha256: "22ac9fb43608c7ddccb983096f5dadb036e5d3122d9194cdb42fee67d754c552" diff --git a/recipes/greg7mdp-gtl/all/conanfile.py b/recipes/greg7mdp-gtl/all/conanfile.py new file mode 100644 index 0000000000000..44af92f813395 --- /dev/null +++ b/recipes/greg7mdp-gtl/all/conanfile.py @@ -0,0 +1,74 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.layout import basic_layout +import os + + +required_conan_version = ">=1.51.3" + + +class Greg7mdpGtlConan(ConanFile): + name = "greg7mdp-gtl" + description = "Greg's Template Library of useful classes." + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/greg7mdp/gtl" + topics = ("bitset", "memoize", "containers", "bitvector", "unordered-set", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _minimum_cpp_standard(self): + return 20 + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "16", + "msvc": "192", + "gcc": "8", + "clang": "10", + "apple-clang": "10", + } + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.get_safe("compiler.version")) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="*.hpp", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + self.cpp_info.set_property("cmake_file_name", "gtl") + self.cpp_info.set_property("cmake_target_name", "gtl::gtl") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "gtl" + self.cpp_info.filenames["cmake_find_package_multi"] = "gtl" + self.cpp_info.names["cmake_find_package"] = "gtl" + self.cpp_info.names["cmake_find_package_multi"] = "gtl" diff --git a/recipes/greg7mdp-gtl/all/test_package/CMakeLists.txt b/recipes/greg7mdp-gtl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a2b5f552d2486 --- /dev/null +++ b/recipes/greg7mdp-gtl/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.12) + +project(test_package CXX) + +find_package(gtl REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gtl::gtl) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) diff --git a/recipes/greg7mdp-gtl/all/test_package/conanfile.py b/recipes/greg7mdp-gtl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/greg7mdp-gtl/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/greg7mdp-gtl/all/test_package/test_package.cpp b/recipes/greg7mdp-gtl/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..543ef825d77e7 --- /dev/null +++ b/recipes/greg7mdp-gtl/all/test_package/test_package.cpp @@ -0,0 +1,28 @@ +// this code is referred from README.md of https://github.com/greg7mdp/gtl +#include +#include +#include + +using gtl::flat_hash_map; + +int main() { + // Create an unordered_map of three strings (that map to strings) + flat_hash_map email = + { + { "tom", "tom@gmail.com"}, + { "jeff", "jk@gmail.com"}, + { "jim", "jimg@microsoft.com"} + }; + + // Iterate and print keys and values + for (const auto& n : email) + std::cout << n.first << "'s email is: " << n.second << "\n"; + + // Add a new entry + email["bill"] = "bg@whatever.com"; + + // and print it + std::cout << "bill's email is: " << email["bill"] << "\n"; + + return 0; +} diff --git a/recipes/greg7mdp-gtl/all/test_v1_package/CMakeLists.txt b/recipes/greg7mdp-gtl/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7967c88037332 --- /dev/null +++ b/recipes/greg7mdp-gtl/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.12) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gtl REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gtl::gtl) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) diff --git a/recipes/greg7mdp-gtl/all/test_v1_package/conanfile.py b/recipes/greg7mdp-gtl/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/greg7mdp-gtl/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/greg7mdp-gtl/config.yml b/recipes/greg7mdp-gtl/config.yml new file mode 100644 index 0000000000000..94e2cbf33f6be --- /dev/null +++ b/recipes/greg7mdp-gtl/config.yml @@ -0,0 +1,9 @@ +versions: + "1.1.5": + folder: all + "1.1.4": + folder: all + "1.1.3": + folder: all + "1.1.2": + folder: all diff --git a/recipes/grpc-proto/all/CMakeLists.txt b/recipes/grpc-proto/all/CMakeLists.txt new file mode 100644 index 0000000000000..51fa11b5ca0d8 --- /dev/null +++ b/recipes/grpc-proto/all/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.4) + +project(grpc-proto) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(Protobuf REQUIRED CONFIG) +find_package(googleapis REQUIRED CONFIG) + +set(IMPORT_DIRS ${CMAKE_SOURCE_DIR} ${GOOGLEAPIS_PROTO_DIRS}) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) diff --git a/recipes/grpc-proto/all/conandata.yml b/recipes/grpc-proto/all/conandata.yml new file mode 100644 index 0000000000000..b76746f043b85 --- /dev/null +++ b/recipes/grpc-proto/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "cci.20211106": # Synced here https://github.com/grpc/grpc/pull/27957 + url: "https://github.com/grpc/grpc-proto/archive/8e3fec8612bc0708e857950dccadfd5063703e04.zip" + sha256: "8675b46d7997f9b6b80b37e8c30c359e0f919632ca3d8d6076944c7893c2d4cf" + "cci.20220627": + url: "https://github.com/grpc/grpc-proto/archive/d653c6d98105b2af937511aa6e46610c7e677e6e.zip" + sha256: "365c0c8d9ae90aa11a8bd7fa870d8962a13600cfc851405acd5327907f9f4c56" diff --git a/recipes/grpc-proto/all/conanfile.py b/recipes/grpc-proto/all/conanfile.py new file mode 100644 index 0000000000000..aff2e90b78de9 --- /dev/null +++ b/recipes/grpc-proto/all/conanfile.py @@ -0,0 +1,118 @@ +import os +import functools +from conan import ConanFile +from conans import CMake, tools +from conan.tools.files import get, copy +from conans.errors import ConanInvalidConfiguration + +from helpers import parse_proto_libraries + + +class GRPCProto(ConanFile): + name = "grpc-proto" + description = "gRPC-defined protobufs for peripheral services such as health checking, load balancing, etc" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/grpc/grpc-proto" + topics = "google", "protos", "api" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + exports = "helpers.py" + + def export_sources(self): + self.copy("CMakeLists.txt") + + def source(self): + get(self, **self.conan_data["sources"][str(self.version)], destination=self.source_folder, strip_root=True) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + self.options["protobuf"].shared = True + self.options["googleapis"].shared = True + + def validate(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, 11) + + if self.options.shared and (not self.options["protobuf"].shared or not self.options["googleapis"].shared): + raise ConanInvalidConfiguration("If built as shared, protobuf and googleapis must be shared as well. Please, use `protobuf:shared=True` and `googleapis:shared=True`") + + def requirements(self): + self.requires('protobuf/3.21.4') + self.requires('googleapis/cci.20220711') + + def build_requirements(self): + self.build_requires('protobuf/3.21.4') + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["GOOGLEAPIS_PROTO_DIRS"] = self.dependencies["googleapis"].cpp_info.resdirs[0].replace("\\", "/") + cmake.configure() + return cmake + + @functools.lru_cache(1) + def _parse_proto_libraries(self): + # Generate the libraries to build dynamically + proto_libraries = parse_proto_libraries(os.path.join(self.source_folder, 'BUILD.bazel'), self.source_folder, self.output.error) + + # Validate that all files exist and all dependencies are found + all_deps = [it.cmake_target for it in proto_libraries] + all_deps += ["googleapis::googleapis", "protobuf::libprotobuf"] + for it in proto_libraries: + it.validate(self.source_folder, all_deps) + + # Mark the libraries we need recursively (C++ context) + all_dict = {it.cmake_target: it for it in proto_libraries} + def activate_library(proto_library): + proto_library.is_used = True + for it_dep in proto_library.deps: + if it_dep in ["googleapis::googleapis", "protobuf::libprotobuf"]: + continue + activate_library(all_dict[it_dep]) + + for it in filter(lambda u: u.is_used, proto_libraries): + activate_library(it) + + return proto_libraries + + def build(self): + proto_libraries = self._parse_proto_libraries() + with open(os.path.join(self.source_folder, "CMakeLists.txt"), "a", encoding="utf-8") as f: + for it in filter(lambda u: u.is_used, proto_libraries): + f.write(it.cmake_content) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, pattern="*.proto", src=self.source_folder, dst=os.path.join(self.package_folder, "res")) + copy(self, pattern="*.pb.h", src=self.build_folder, dst=os.path.join(self.package_folder, "include")) + + copy(self, pattern="*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, pattern="*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False) + copy(self, pattern="*.so*", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, pattern="*.dylib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, pattern="*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + + def package_id(self): + self.info.requires["protobuf"].full_package_mode() + + def package_info(self): + # We are not creating components, we can just collect the libraries + self.cpp_info.libs = tools.collect_libs(self) + if self.settings.os == "Linux": + self.cpp_info.system_libs.extend(["m"]) diff --git a/recipes/grpc-proto/all/helpers.py b/recipes/grpc-proto/all/helpers.py new file mode 100644 index 0000000000000..85d23a77ff1de --- /dev/null +++ b/recipes/grpc-proto/all/helpers.py @@ -0,0 +1,151 @@ +import os +import re +import textwrap + + +def grpc_target_name(internal_name): + return f"grpc_{internal_name}" + + +class _ProtoLibrary: + name: str = None + srcs: list = None + deps: list = None + is_used: bool = False + + def __init__(self) -> None: + self.srcs = [] + self.deps = set(["protobuf::libprotobuf"]) # Add to all libraries even if not explicitly set + self.is_used = True + + def validate(self, source_folder, all_deps): + # Check all files exists + for it in self.srcs: + assert os.path.exists(os.path.join(source_folder, it)), f"{self.name} - file '{it}' doesn't exist" + # Check all deps exists + for it in self.deps: + assert it in all_deps, f"{self.name} - dep '{it}' not found" + + def dumps(self): + import json + return json.dumps({ + "name": self.name, + "srcs": self.srcs, + "deps": list(self.deps), + }, indent=4) + + @property + def cmake_target(self): + return grpc_target_name(self.name) + + @property + def cmake_deps(self): + def to_cmake_target(item): + if item.startswith("//"): + return item[2:].replace("/", "_").replace(":", "_") + return item + return [to_cmake_target(it) for it in self.deps] + + @property + def cmake_content(self): + content = f"\n\n# {self.cmake_target}\n" + content += "\n".join([f"#{it}" for it in self.dumps().split('\n')]) + content += "\n" + if not self.srcs: + content += textwrap.dedent(f"""\ + add_library({self.cmake_target} INTERFACE) + """) + else: + content += textwrap.dedent(f"""\ + set({self.cmake_target}_PROTOS {" ".join(["${CMAKE_SOURCE_DIR}/"+it for it in self.srcs])}) + add_library({self.cmake_target} ${{{self.cmake_target}_PROTOS}}) + target_include_directories({self.cmake_target} PUBLIC ${{CMAKE_BINARY_DIR}}) + target_compile_features({self.cmake_target} PUBLIC cxx_std_11) + protobuf_generate(LANGUAGE cpp + TARGET {self.cmake_target} + PROTOS ${{{self.cmake_target}_PROTOS}} + IMPORT_DIRS ${{IMPORT_DIRS}} + ) + """) + + if self.deps: + content += textwrap.dedent(f"""\ + target_link_libraries({self.cmake_target} {"PUBLIC" if self.srcs else "INTERFACE"} {" ".join(self.cmake_deps)}) + """) + + return content + + +def parse_proto_libraries(filename, source_folder, error): + # Generate the libraries to build dynamically + re_name = re.compile(r'name = "(.*)"') + re_srcs_oneline = re.compile(r'srcs = \["(.*)"\],') + re_deps_oneline = re.compile(r'deps = \["(.*)"\],') + re_add_varname = re.compile(r'] \+ (.*),') + + proto_libraries = [] + + basedir = os.path.dirname(filename) + proto_library = None + + def parsing_sources(line): + proto_path = os.path.relpath(os.path.join(basedir, line.strip(",").strip("\"")), source_folder).replace('\\', '/') + proto_library.srcs.append(proto_path) + + def parsing_deps(line): + line = line.strip(",").strip("\"") + if line.startswith("@com_google_protobuf//:"): + proto_library.deps.add("protobuf::libprotobuf") + elif line.startswith("@com_google_googleapis//"): + proto_library.deps.add("googleapis::googleapis") + elif line.startswith(":"): + proto_library.deps.add(grpc_target_name(line[1:])) + else: + error(f"Unrecognized dep: {line} -- {os.path.relpath(filename, source_folder)}") + + with open(filename, 'r') as f: + action = None + parsing_variable = None + variables = {} + for line in f.readlines(): + line = line.strip() + + if line == "proto_library(": + assert proto_library == None + proto_library = _ProtoLibrary() + elif parsing_variable != None: + if line == "]": + parsing_variable = None + else: + parsing_variable(line) + elif proto_library != None: + if line.startswith("name ="): + proto_library.name = re_name.search(line).group(1) + elif line.startswith("srcs = "): + m = re_srcs_oneline.search(line) + if m: + parsing_sources(m.group(1)) + else: + action = parsing_sources + elif line.startswith("deps = "): + m = re_deps_oneline.search(line) + if m: + parsing_deps(m.group(1)) + else: + action = parsing_deps + elif line.startswith("visibility = "): + pass + elif line == ")": + proto_libraries.append(proto_library) + proto_library = None + action = None + elif line == "],": + action = None + elif line.startswith("] + "): + varname = re_add_varname.search(line).group(1) + for it in variables[varname]: + action(it) + elif action: + action(line) + + return proto_libraries diff --git a/recipes/grpc-proto/all/test_package/CMakeLists.txt b/recipes/grpc-proto/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ea5be5f993fd1 --- /dev/null +++ b/recipes/grpc-proto/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(grpc-proto REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE grpc-proto::grpc-proto) diff --git a/recipes/grpc-proto/all/test_package/conanfile.py b/recipes/grpc-proto/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e279a6afcd236 --- /dev/null +++ b/recipes/grpc-proto/all/test_package/conanfile.py @@ -0,0 +1,29 @@ +import os +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain +from conan.tools.build import cross_building as tools_cross_building +from conan.tools.layout import cmake_layout + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools_cross_building(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/recipes/grpc-proto/all/test_package/test_package.cpp b/recipes/grpc-proto/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..781e968605dab --- /dev/null +++ b/recipes/grpc-proto/all/test_package/test_package.cpp @@ -0,0 +1,13 @@ +#include +#include "grpc/health/v1/health.pb.h" + +int main() { + std::cout << "Conan - test package for grpc-proto\n"; + + grpc::health::v1::HealthCheckResponse h; + h.set_status(::grpc::health::v1::HealthCheckResponse_ServingStatus::HealthCheckResponse_ServingStatus_NOT_SERVING); + + std::cout << h.DebugString(); + + return 0; +} diff --git a/recipes/grpc-proto/config.yml b/recipes/grpc-proto/config.yml new file mode 100644 index 0000000000000..a3f9e213cb226 --- /dev/null +++ b/recipes/grpc-proto/config.yml @@ -0,0 +1,5 @@ +versions: + "cci.20211106": + folder: all + "cci.20220627": + folder: all diff --git a/recipes/grpc/all/CMakeLists.txt b/recipes/grpc/all/CMakeLists.txt index 1848ca5a77c35..8ad4fadf5f276 100644 --- a/recipes/grpc/all/CMakeLists.txt +++ b/recipes/grpc/all/CMakeLists.txt @@ -2,6 +2,25 @@ cmake_minimum_required(VERSION 2.8.12) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) + +find_package(grpc-proto CONFIG REQUIRED) +find_package(googleapis CONFIG REQUIRED) + +set(googleapis_RES_DIRS + $<$:${googleapis_RES_DIRS_RELEASE}> + $<$:${googleapis_RES_DIRS_RELWITHDEBINFO}> + $<$:${googleapis_RES_DIRS_MINSIZEREL}> + $<$:${googleapis_RES_DIRS_DEBUG}>) +set(grpc-proto_RES_DIRS + $<$:${grpc-proto_RES_DIRS_RELEASE}> + $<$:${grpc-proto_RES_DIRS_RELWITHDEBINFO}> + $<$:${grpc-proto_RES_DIRS_MINSIZEREL}> + $<$:${grpc-proto_RES_DIRS_DEBUG}>) add_subdirectory("source_subfolder") + +# TODO: move to a patch? It avoids link errors while resolving abseil symbols with gcc +if (TARGET check_epollexclusive) + set_target_properties(check_epollexclusive PROPERTIES LINKER_LANGUAGE CXX) +endif() diff --git a/recipes/grpc/all/cmake/grpc_cpp_plugin.cmake b/recipes/grpc/all/cmake/grpc_cpp_plugin.cmake deleted file mode 100644 index 3229591ca3c58..0000000000000 --- a/recipes/grpc/all/cmake/grpc_cpp_plugin.cmake +++ /dev/null @@ -1,18 +0,0 @@ -if(NOT TARGET gRPC::grpc_cpp_plugin) - if(CMAKE_CROSSCOMPILING) - find_program(GRPC_CPP_PLUGIN_PROGRAM - NAMES grpc_cpp_plugin - PATHS ENV - PATH NO_DEFAULT_PATH) - else() - find_program(GRPC_CPP_PLUGIN_PROGRAM - NAMES grpc_cpp_plugin - PATHS "${CMAKE_CURRENT_LIST_DIR}/../../bin/" - NO_DEFAULT_PATH) - endif() - - get_filename_component(GRPC_CPP_PLUGIN_PROGRAM "${GRPC_CPP_PLUGIN_PROGRAM}" ABSOLUTE) - - add_executable(gRPC::grpc_cpp_plugin IMPORTED) - set_property(TARGET gRPC::grpc_cpp_plugin PROPERTY IMPORTED_LOCATION ${GRPC_CPP_PLUGIN_PROGRAM}) -endif() diff --git a/recipes/grpc/all/cmake/grpc_plugin_template.cmake.in b/recipes/grpc/all/cmake/grpc_plugin_template.cmake.in new file mode 100644 index 0000000000000..4685c5c34b8fc --- /dev/null +++ b/recipes/grpc/all/cmake/grpc_plugin_template.cmake.in @@ -0,0 +1,31 @@ +if(NOT TARGET @target_name@) + if(CMAKE_CROSSCOMPILING) + find_program(@find_program_variable@ + NAMES @executable_name@ + PATHS ENV PATH + NO_DEFAULT_PATH + ) + else() + find_program(@find_program_variable@ + NAMES @executable_name@ + PATHS "${CMAKE_CURRENT_LIST_DIR}/@relative_path@bin/" + NO_DEFAULT_PATH + ) + endif() + # TODO: In conan v2 with CMakeToolchain, can be replaced by: + # find_program(@find_program_variable@ NAMES @executable_name@)) + # # Nice enough to handle grpc not in build_requires for native build + # if(NOT @find_program_variable@ AND NOT CMAKE_CROSSCOMPILING) + # find_program(@find_program_variable@ + # NAMES @executable_name@ + # PATHS "${CMAKE_CURRENT_LIST_DIR}/@relative_path@bin/" + # NO_DEFAULT_PATH + # ) + # endif() + + if(@find_program_variable@) + get_filename_component(@find_program_variable@ "${@find_program_variable@}" ABSOLUTE) + add_executable(@target_name@ IMPORTED) + set_property(TARGET @target_name@ PROPERTY IMPORTED_LOCATION ${@find_program_variable@}) + endif() +endif() diff --git a/recipes/grpc/all/conandata.yml b/recipes/grpc/all/conandata.yml index 0b8584f555925..7dec80ae52456 100644 --- a/recipes/grpc/all/conandata.yml +++ b/recipes/grpc/all/conandata.yml @@ -1,7 +1,42 @@ sources: - "1.37.1": - url: "https://github.com/grpc/grpc/archive/v1.37.1.tar.gz" - sha256: "acf247ec3a52edaee5dee28644a4e485c5e5badf46bdb24a80ca1d76cb8f1174" - "1.37.0": - url: https://github.com/grpc/grpc/archive/refs/tags/v1.37.0.tar.gz - sha256: "c2dc8e876ea12052d6dd16704492fd8921df8c6d38c70c4708da332cf116df22" + "1.50.1": + url: "https://github.com/grpc/grpc/archive/v1.50.1.tar.gz" + sha256: "fb1ed98eb3555877d55eb2b948caca44bc8601c6704896594de81558639709ef" + "1.50.0": + url: "https://github.com/grpc/grpc/archive/v1.50.0.tar.gz" + sha256: "76900ab068da86378395a8e125b5cc43dfae671e09ff6462ddfef18676e2165a" + "1.48.0": + url: "https://github.com/grpc/grpc/archive/v1.48.0.tar.gz" + sha256: "9b1f348b15a7637f5191e4e673194549384f2eccf01fcef7cc1515864d71b424" + "1.47.1": + url: "https://github.com/grpc/grpc/archive/v1.47.1.tar.gz" + sha256: "ba7c36989ad8a52c813adeebb0c65869283448f496dbb2868c75f69941dec6a9" + "1.46.3": + url: "https://github.com/grpc/grpc/archive/refs/tags/v1.46.3.tar.gz" + sha256: "d6cbf22cb5007af71b61c6be316a79397469c58c82a942552a62e708bce60964" +patches: + "1.50.1": + - patch_file: "patches/v1.50.x/001-disable-cppstd-override.patch" + base_path: "source_subfolder" + - patch_file: "patches/v1.50.x/002-consume-protos-from-requirements.patch" + base_path: "source_subfolder" + "1.50.0": + - patch_file: "patches/v1.50.x/001-disable-cppstd-override.patch" + base_path: "source_subfolder" + - patch_file: "patches/v1.50.x/002-consume-protos-from-requirements.patch" + base_path: "source_subfolder" + "1.48.0": + - patch_file: "patches/v1.48.x/001-disable-cppstd-override.patch" + base_path: "source_subfolder" + - patch_file: "patches/v1.48.x/002-consume-protos-from-requirements.patch" + base_path: "source_subfolder" + "1.47.1": + - patch_file: "patches/v1.47.x/001-disable-cppstd-override.patch" + base_path: "source_subfolder" + - patch_file: "patches/v1.47.x/002-consume-protos-from-requirements.patch" + base_path: "source_subfolder" + "1.46.3": + - patch_file: "patches/v1.46.x/001-disable-cppstd-override.patch" + base_path: "source_subfolder" + - patch_file: "patches/v1.46.x/002-consume-protos-from-requirements.patch" + base_path: "source_subfolder" diff --git a/recipes/grpc/all/conanfile.py b/recipes/grpc/all/conanfile.py index a2b323ba07de1..b6bf2b1a2b355 100644 --- a/recipes/grpc/all/conanfile.py +++ b/recipes/grpc/all/conanfile.py @@ -1,23 +1,29 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -from conans.tools import Version +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building, valid_min_cppstd, check_min_cppstd +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, replace_in_file, rmdir +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.scm import Version +from conans import CMake import os +import shutil + +required_conan_version = ">=1.52.0" class grpcConan(ConanFile): name = "grpc" description = "Google's RPC (remote procedure call) library and framework." - topics = ("conan", "grpc", "rpc") + license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/grpc/grpc" - license = "Apache-2.0" - exports_sources = ["CMakeLists.txt", "cmake/*"] - generators = "cmake", "cmake_find_package", "cmake_find_package_multi" - short_paths = True + topics = ("rpc") settings = "os", "arch", "compiler", "build_type" - # TODO: Add shared option + options = { + "shared": [True, False], "fPIC": [True, False], "codegen": [True, False], "csharp_ext": [True, False], @@ -27,9 +33,11 @@ class grpcConan(ConanFile): "objective_c_plugin": [True, False], "php_plugin": [True, False], "python_plugin": [True, False], - "ruby_plugin": [True, False] + "ruby_plugin": [True, False], + "secure": [True, False] } default_options = { + "shared": False, "fPIC": True, "codegen": True, "csharp_ext": False, @@ -40,8 +48,11 @@ class grpcConan(ConanFile): "php_plugin": True, "python_plugin": True, "ruby_plugin": True, + "secure": False, } + short_paths = True + generators = "cmake", "cmake_find_package", "cmake_find_package_multi" _cmake = None @property @@ -52,26 +63,81 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" - def requirements(self): - self.requires('zlib/1.2.11') - self.requires('openssl/1.1.1k') - self.requires('protobuf/3.15.5') - self.requires('c-ares/1.17.1') - self.requires('abseil/20210324.0') - self.requires('re2/20210202') + @property + def _grpc_plugin_template(self): + return "grpc_plugin_template.cmake.in" + + @property + def _cxxstd_required(self): + return 14 if Version(self.version) >= "1.47" else 11 + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + copy(self, f"cmake/{self._grpc_plugin_template}", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler == "Visual Studio": - compiler_version = tools.Version(self.settings.compiler.version) - if compiler_version < 14: - raise ConanInvalidConfiguration("gRPC can only be built with Visual Studio 2015 or higher.") + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + self.options["protobuf"].shared = True + self.options["googleapis"].shared = True + self.options["grpc-proto"].shared = True + + def layout(self): + pass + + def requirements(self): + if is_msvc(self) and Version(self.version) < "1.47": + self.requires("abseil/20211102.0") + else: + self.requires("abseil/20220623.0") + self.requires("c-ares/1.18.1") + self.requires("openssl/1.1.1s") + self.requires("re2/20220601") + self.requires("zlib/1.2.13") + self.requires("protobuf/3.21.4") + self.requires("googleapis/cci.20220711") + self.requires("grpc-proto/cci.20220627") + + def package_id(self): + del self.info.options.secure + self.info.requires["protobuf"].full_package_mode() + + def validate(self): + check_min_vs(self, "190") + if is_msvc(self) and self.info.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} shared not supported by Visual Studio") + + if Version(self.version) >= "1.47" and self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) < "6": + raise ConanInvalidConfiguration("GCC older than 6 is not supported") + + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._cxxstd_required) + + if self.info.options.shared and \ + (not self.dependencies["protobuf"].options.shared or not self.dependencies["googleapis"].options.shared or not self.dependencies["grpc-proto"].options.shared): + raise ConanInvalidConfiguration( + "If built as shared, protobuf, googleapis and grpc-proto must be shared as well. " + "Please, use `protobuf:shared=True` and `googleapis:shared=True` and `grpc-proto:shared=True`", + ) + + def build_requirements(self): + if hasattr(self, "settings_build"): + self.build_requires('protobuf/3.21.4') + # when cross compiling we need pre compiled grpc plugins for protoc + if cross_building(self): + self.build_requires('grpc/{}'.format(self.version)) def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake is not None: @@ -91,6 +157,7 @@ def _configure_cmake(self): # We need the generated cmake/ files (bc they depend on the list of targets, which is dynamic) self._cmake.definitions["gRPC_INSTALL"] = True + self._cmake.definitions["gRPC_INSTALL_SHAREDIR"] = "res/grpc" # tell grpc to use the find_package versions self._cmake.definitions["gRPC_ZLIB_PROVIDER"] = "package" @@ -108,139 +175,272 @@ def _configure_cmake(self): self._cmake.definitions["gRPC_BUILD_GRPC_PYTHON_PLUGIN"] = self.options.python_plugin self._cmake.definitions["gRPC_BUILD_GRPC_RUBY_PLUGIN"] = self.options.ruby_plugin + # Consumed targets (abseil) via interface target_compiler_feature can propagate newer standards + if not valid_min_cppstd(self, self._cxxstd_required): + self._cmake.definitions["CMAKE_CXX_STANDARD"] = self._cxxstd_required + + if cross_building(self): + # otherwise find_package() can't find config files since + # conan doesn't populate CMAKE_FIND_ROOT_PATH + self._cmake.definitions["CMAKE_FIND_ROOT_PATH_MODE_PACKAGE"] = "BOTH" + + if is_apple_os(self): + # workaround for: install TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable + self._cmake.definitions["CMAKE_MACOSX_BUNDLE"] = False + + if is_msvc(self) and Version(self.version) >= "1.48": + self._cmake.definitions["CMAKE_SYSTEM_VERSION"] = "10.0.18362.0" + self._cmake.configure(build_folder=self._build_subfolder) return self._cmake + def _patch_sources(self): + apply_conandata_patches(self) + + # Clean existing proto files, they will be taken from requirements + shutil.rmtree(os.path.join(self._source_subfolder, "src", "proto", "grpc")) + + if Version(self.version) >= "1.47": + # Take googleapis from requirement instead of vendored/hardcoded version + replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), + "if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/googleapis)", + "if (FALSE) # Do not download, it is provided by Conan" + ) + + # We are fine with protobuf::protoc coming from conan generated Find/config file + # TODO: to remove when moving to CMakeToolchain (see https://github.com/conan-io/conan/pull/10186) + replace_in_file(self, os.path.join(self._source_subfolder, "cmake", "protobuf.cmake"), + "find_program(_gRPC_PROTOBUF_PROTOC_EXECUTABLE protoc)", + "set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE $)" + ) + def build(self): + self._patch_sources() cmake = self._configure_cmake() cmake.build() def package(self): + copy(self, "LICENSE", src=os.path.join(self.source_folder, self._source_subfolder), dst=os.path.join(self.package_folder, "licenses")) cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*.cmake", dst=os.path.join("lib", "cmake"), src=os.path.join(self.source_folder, "cmake")) - - def package_info(self): - bindir = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bindir)) - self.env_info.PATH.append(bindir) + # Create one custom module file per executable in order to emulate + # CMake executables imported targets of grpc + for plugin_option, values in self._grpc_plugins.items(): + if self.options.get_safe(plugin_option): + target = values["target"] + executable = values["executable"] + self._create_executable_module_file(target, executable) + @property + def _grpc_plugins(self): + return { + "cpp_plugin": { + "target": "gRPC::grpc_cpp_plugin", + "executable": "grpc_cpp_plugin", + }, + "csharp_plugin": { + "target": "gRPC::grpc_csharp_plugin", + "executable": "grpc_csharp_plugin", + }, + "node_plugin": { + "target": "gRPC::grpc_node_plugin", + "executable": "grpc_node_plugin", + }, + "objective_c_plugin": { + "target": "gRPC::grpc_objective_c_plugin", + "executable": "grpc_objective_c_plugin", + }, + "php_plugin": { + "target": "gRPC::grpc_php_plugin", + "executable": "grpc_php_plugin", + }, + "python_plugin": { + "target": "gRPC::grpc_python_plugin", + "executable": "grpc_python_plugin", + }, + "ruby_plugin": { + "target": "gRPC::grpc_ruby_plugin", + "executable": "grpc_ruby_plugin", + }, + } + + def _create_executable_module_file(self, target, executable): + module_abs_path = os.path.join(self.package_folder, self._module_path) + + # Copy our CMake module template file to package folder + copy(self, self._grpc_plugin_template, src=os.path.join(self.source_folder, "cmake"), dst=module_abs_path) + + # Rename it + dst_file = os.path.join(module_abs_path, f"{executable}.cmake") + rename(self, os.path.join(module_abs_path, self._grpc_plugin_template), dst_file) + + # Replace placeholders + replace_in_file(self, dst_file, "@target_name@", target) + replace_in_file(self, dst_file, "@executable_name@", executable) + + find_program_var = "{}_PROGRAM".format(executable.upper()) + replace_in_file(self, dst_file, "@find_program_variable@", find_program_var) + + module_folder_depth = len(os.path.normpath(self._module_path).split(os.path.sep)) + rel_path = "".join(["../"] * module_folder_depth) + replace_in_file(self, dst_file, "@relative_path@", rel_path) + + @property + def _module_path(self): + return os.path.join("lib", "cmake", "conan_trick") + + @property + def _grpc_components(self): + def libm(): + return ["m"] if self.settings.os in ["Linux", "FreeBSD"] else [] + + def pthread(): + return ["pthread"] if self.settings.os in ["Linux", "FreeBSD"] else [] + + def crypt32(): + return ["crypt32"] if self.settings.os == "Windows" else [] + + def ws2_32(): + return ["ws2_32"] if self.settings.os == "Windows" else [] + + def wsock32(): + return ["wsock32"] if self.settings.os == "Windows" else [] + + def corefoundation(): + return ["CoreFoundation"] if is_apple_os(self) else [] + + components = { + "address_sorting": { + "lib": "address_sorting", + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "gpr": { + "lib": "gpr", + "requires": [ + "upb", "abseil::absl_base", "abseil::absl_memory", + "abseil::absl_status", "abseil::absl_str_format", + "abseil::absl_strings", "abseil::absl_synchronization", + "abseil::absl_time", "abseil::absl_optional", + ], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "_grpc": { + "lib": "grpc", + "requires": [ + "address_sorting", "gpr", "upb", "abseil::absl_bind_front", + "abseil::absl_flat_hash_map", "abseil::absl_inlined_vector", + "abseil::absl_statusor", "abseil::absl_random_random", + "c-ares::cares", "openssl::crypto", + "openssl::ssl", "re2::re2", "zlib::zlib", + ], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + "frameworks": corefoundation(), + }, + "grpc++": { + "lib": "grpc++", + "requires": ["_grpc", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "grpc++_alts": { + "lib": "grpc++_alts", + "requires": ["grpc++", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "grpc++_error_details": { + "lib": "grpc++_error_details", + "requires": ["grpc++", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "upb": { + "lib": "upb", + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "grpc_plugin_support": { + "lib": "grpc_plugin_support", + "requires": ["protobuf::libprotoc", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + } + + if not self.options.secure: + components.update({ + "grpc_unsecure": { + "lib": "grpc_unsecure", + "requires": [ + "address_sorting", "gpr", "upb", "abseil::absl_flat_hash_map", + "abseil::absl_inlined_vector", "abseil::absl_statusor", + "c-ares::cares", "re2::re2", "zlib::zlib", + "abseil::absl_random_random", + ], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + "frameworks": corefoundation(), + }, + "grpc++_unsecure": { + "lib": "grpc++_unsecure", + "requires": ["grpc_unsecure", "protobuf::libprotobuf"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + }) + + if self.options.codegen: + components.update({ + "grpc++_reflection": { + "lib": "grpc++_reflection", + "requires": ["grpc++", "protobuf::libprotobuf", "grpc-proto::grpc-proto", "googleapis::googleapis"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + "grpcpp_channelz": { + "lib": "grpcpp_channelz", + "requires": ["grpc++", "protobuf::libprotobuf", "grpc-proto::grpc-proto", "googleapis::googleapis"], + "system_libs": libm() + pthread() + crypt32() + ws2_32() + wsock32(), + }, + }) + + return components + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "gRPC") + self.cpp_info.resdirs = ["res"] + ssl_roots_file_path = os.path.join(self.package_folder, "res", "grpc", "roots.pem") + self.runenv_info.define_path("GRPC_DEFAULT_SSL_ROOTS_FILE_PATH", ssl_roots_file_path) + self.env_info.GRPC_DEFAULT_SSL_ROOTS_FILE_PATH = ssl_roots_file_path # remove in conan v2? + + for component, values in self._grpc_components.items(): + target = values.get("lib") + lib = values.get("lib") + self.cpp_info.components[component].set_property("cmake_target_name", "gRPC::{}".format(target)) + # actually only gpr, grpc, grpc_unsecure, grpc++ and grpc++_unsecure should have a .pc file + self.cpp_info.components[component].set_property("pkg_config_name", target) + self.cpp_info.components[component].libs = [lib] + self.cpp_info.components[component].requires = values.get("requires", []) + self.cpp_info.components[component].system_libs = values.get("system_libs", []) + self.cpp_info.components[component].frameworks = values.get("frameworks", []) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components[component].names["cmake_find_package"] = target + self.cpp_info.components[component].names["cmake_find_package_multi"] = target + + # Executable imported targets are added through custom CMake module files, + # since conan generators don't know how to emulate these kind of targets. + grpc_modules = [] + for plugin_option, values in self._grpc_plugins.items(): + if self.options.get_safe(plugin_option): + grpc_module_filename = "{}.cmake".format(values["executable"]) + grpc_modules.append(os.path.join(self._module_path, grpc_module_filename)) + self.cpp_info.set_property("cmake_build_modules", grpc_modules) + + if any(self.options.get_safe(plugin_option) for plugin_option in self._grpc_plugins.keys()): + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.names["cmake_find_package"] = "gRPC" self.cpp_info.names["cmake_find_package_multi"] = "gRPC" - - _system_libs = [] - if self.settings.os in ["Macos", "Linux"]: - _system_libs = ['m', 'pthread'] - elif self.settings.os == 'Windows': - _system_libs = ['wsock32', 'ws2_32', 'crypt32'] - - # gRPC::address_sorting - self.cpp_info.components["address_sorting"].names["cmake_find_package"] = "address_sorting" - self.cpp_info.components["address_sorting"].names["cmake_find_package_multi"] = "address_sorting" - self.cpp_info.components["address_sorting"].system_libs = _system_libs - self.cpp_info.components["address_sorting"].libs = ["address_sorting"] - - # gRPC::gpr - self.cpp_info.components["gpr"].names["cmake_find_package"] = "gpr" - self.cpp_info.components["gpr"].names["cmake_find_package_multi"] = "gpr" - self.cpp_info.components["gpr"].requires = ["abseil::absl_base", "abseil::absl_memory", "abseil::absl_status", "abseil::absl_str_format", "abseil::absl_strings", "abseil::absl_synchronization", "abseil::absl_time", "abseil::absl_optional"] - if self.settings.os in ['Linux', 'Macos']: - self.cpp_info.components["gpr"].system_libs = _system_libs - self.cpp_info.components["gpr"].libs = ["gpr"] - - # gRPC::grpc - self.cpp_info.components["_grpc"].names["cmake_find_package"] = "grpc" - self.cpp_info.components["_grpc"].names["cmake_find_package_multi"] = "grpc" - self.cpp_info.components["_grpc"].requires = ["zlib::zlib", "c-ares::cares", "address_sorting", "re2::re2", "upb", "abseil::absl_flat_hash_map", "abseil::absl_inlined_vector", "abseil::absl_bind_front", "abseil::absl_statusor", "gpr", "openssl::ssl", "openssl::crypto", "address_sorting", "upb"] - self.cpp_info.components["_grpc"].frameworks = ["CoreFoundation"] - self.cpp_info.components["_grpc"].system_libs = _system_libs - self.cpp_info.components["_grpc"].libs = ["grpc"] - - # gRPC::grpc_unsecure - self.cpp_info.components["grpc_unsecure"].names["cmake_find_package"] = "grpc_unsecure" - self.cpp_info.components["grpc_unsecure"].names["cmake_find_package_multi"] = "grpc_unsecure" - self.cpp_info.components["grpc_unsecure"].requires = ["zlib::zlib", "c-ares::cares", "address_sorting", "re2::re2", "upb", "abseil::absl_flat_hash_map", "abseil::absl_inlined_vector", "abseil::absl_statusor", "gpr", "address_sorting", "upb"] - self.cpp_info.components["grpc_unsecure"].frameworks = ["CoreFoundation"] - self.cpp_info.components["grpc_unsecure"].system_libs = _system_libs - self.cpp_info.components["grpc_unsecure"].libs = ["grpc_unsecure"] - - # gRPC::grpc++ - self.cpp_info.components["grpc++"].names["cmake_find_package"] = "grpc++" - self.cpp_info.components["grpc++"].names["cmake_find_package_multi"] = "grpc++" - self.cpp_info.components["grpc++"].requires = ["protobuf::libprotobuf", "_grpc"] - self.cpp_info.components["grpc++"].system_libs = _system_libs - self.cpp_info.components["grpc++"].libs = ["grpc++"] - - # gRPC::grpc++_alts - self.cpp_info.components["grpc++_alts"].names["cmake_find_package"] = "grpc++_alts" - self.cpp_info.components["grpc++_alts"].names["cmake_find_package_multi"] = "grpc++_alts" - self.cpp_info.components["grpc++_alts"].requires = ["protobuf::libprotobuf", "grpc++"] - self.cpp_info.components["grpc++_alts"].system_libs = _system_libs - self.cpp_info.components["grpc++_alts"].libs = ["grpc++_alts"] - - # gRPC::grpc++_error_details - self.cpp_info.components["grpc++_error_details"].names["cmake_find_package"] = "grpc++_error_details" - self.cpp_info.components["grpc++_error_details"].names["cmake_find_package_multi"] = "grpc++_error_details" - self.cpp_info.components["grpc++_error_details"].requires = ["protobuf::libprotobuf", "grpc++"] - if self.settings.os in ['Macos', 'Linux']: - self.cpp_info.components["grpc++_error_details"].system_libs = _system_libs - self.cpp_info.components["grpc++_error_details"].libs = ["grpc++_error_details"] - - # gRPC::grpc++_reflection - self.cpp_info.components["grpc++_reflection"].names["cmake_find_package"] = "grpc++_reflection" - self.cpp_info.components["grpc++_reflection"].names["cmake_find_package_multi"] = "grpc++_reflection" - self.cpp_info.components["grpc++_reflection"].requires = ["protobuf::libprotobuf", "grpc++"] - if self.settings.os in ['Macos', 'Linux']: - self.cpp_info.components["grpc++_reflection"].system_libs = _system_libs - self.cpp_info.components["grpc++_reflection"].libs = ["grpc++_reflection"] - - # gRPC::grpc++_unsecure - self.cpp_info.components["grpc++_unsecure"].names["cmake_find_package"] = "grpc++_unsecure" - self.cpp_info.components["grpc++_unsecure"].names["cmake_find_package_multi"] = "grpc++_unsecure" - self.cpp_info.components["grpc++_unsecure"].requires = ["protobuf::libprotobuf", "grpc_unsecure"] - self.cpp_info.components["grpc++_unsecure"].system_libs = _system_libs - self.cpp_info.components["grpc++_unsecure"].libs = ["grpc++_unsecure"] - - # gRPC::grpc_plugin_support - self.cpp_info.components["grpc_plugin_support"].names["cmake_find_package"] = "grpc_plugin_support" - self.cpp_info.components["grpc_plugin_support"].names["cmake_find_package_multi"] = "grpc_plugin_support" - self.cpp_info.components["grpc_plugin_support"].requires = ["protobuf::libprotoc", "protobuf::libprotobuf"] - if self.settings.os in ['Macos', 'Linux']: - self.cpp_info.components["grpc_plugin_support"].system_libs = _system_libs - self.cpp_info.components["grpc_plugin_support"].libs = ["grpc_plugin_support"] - - # gRPC::grpcpp_channelz - self.cpp_info.components["grpcpp_channelz"].names["cmake_find_package"] = "grpcpp_channelz" - self.cpp_info.components["grpcpp_channelz"].names["cmake_find_package_multi"] = "grpcpp_channelz" - if self.settings.os in ['Macos', 'Linux']: - self.cpp_info.components["grpcpp_channelz"].requires = ["protobuf::libprotobuf", "_grpc"] - self.cpp_info.components["grpcpp_channelz"].system_libs = _system_libs - elif self.settings.os in ['Windows']: - self.cpp_info.components["grpcpp_channelz"].requires = ["protobuf::libprotobuf", "grpc++"] - self.cpp_info.components["grpcpp_channelz"].libs = ["grpcpp_channelz"] - - # gRPC::upb - self.cpp_info.components["upb"].names["cmake_find_package"] = "upb" - self.cpp_info.components["upb"].names["cmake_find_package_multi"] = "upb" - if self.settings.os in ['Macos', 'Linux']: - self.cpp_info.components["upb"].system_libs = _system_libs - self.cpp_info.components["upb"].libs = ["upb"] - - # Executables - # gRPC::grpc_cpp_plugin - if self.options.cpp_plugin: - module_target_rel_path = os.path.join("lib", "cmake", "grpc_cpp_plugin.cmake") - self.cpp_info.components["execs"].build_modules["cmake_find_package"] = [module_target_rel_path] - self.cpp_info.components["execs"].build_modules["cmake_find_package_multi"] = [module_target_rel_path] - # gRPC::grpc_csharp_plugin - # gRPC::grpc_node_plugin - # gRPC::grpc_objective_c_plugin - # gRPC::grpc_php_plugin - # gRPC::grpc_python_plugin - # gRPC::grpc_ruby_plugin + if grpc_modules: + self.cpp_info.components["grpc_execs"].build_modules["cmake_find_package"] = grpc_modules + self.cpp_info.components["grpc_execs"].build_modules["cmake_find_package_multi"] = grpc_modules diff --git a/recipes/grpc/all/patches/v1.46.x/001-disable-cppstd-override.patch b/recipes/grpc/all/patches/v1.46.x/001-disable-cppstd-override.patch new file mode 100644 index 0000000000000..a260124675947 --- /dev/null +++ b/recipes/grpc/all/patches/v1.46.x/001-disable-cppstd-override.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7a97604b75..7ae815042f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -222,21 +222,6 @@ if (NOT DEFINED CMAKE_C_STANDARD) + set(CMAKE_C_STANDARD 99) + endif() + +-# Add c++11 flags +-if (NOT DEFINED CMAKE_CXX_STANDARD) +- set(CMAKE_CXX_STANDARD 11) +-else() +- if (CMAKE_CXX_STANDARD LESS 11) +- message(FATAL_ERROR "CMAKE_CXX_STANDARD is less than 11, please specify at least SET(CMAKE_CXX_STANDARD 11)") +- endif() +-endif() +-if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) +- set(CMAKE_CXX_STANDARD_REQUIRED ON) +-endif() +-if (NOT DEFINED CMAKE_CXX_EXTENSIONS) +- set(CMAKE_CXX_EXTENSIONS OFF) +-endif() +- + if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + endif() diff --git a/recipes/grpc/all/patches/v1.46.x/002-consume-protos-from-requirements.patch b/recipes/grpc/all/patches/v1.46.x/002-consume-protos-from-requirements.patch new file mode 100644 index 0000000000000..ff27fa43b34ea --- /dev/null +++ b/recipes/grpc/all/patches/v1.46.x/002-consume-protos-from-requirements.patch @@ -0,0 +1,290 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2db10e5..612d2cf 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -329,7 +329,7 @@ function(protobuf_generate_grpc_cpp) + return() + endif() + +- set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}) ++ set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR} -I ${googleapis_RES_DIRS} -I ${grpc-proto_RES_DIRS}) + foreach(FIL ${ARGN}) + get_filename_component(ABS_FIL ${FIL} ABSOLUTE) + get_filename_component(FIL_WE ${FIL} NAME_WE) +@@ -348,18 +348,15 @@ function(protobuf_generate_grpc_cpp) + OUTPUT "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc" + "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h" + "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h" +- "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc" +- "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h" + COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE} + ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR} +- --cpp_out=${_gRPC_PROTO_GENS_DIR} + --plugin=protoc-gen-grpc=${_gRPC_CPP_PLUGIN} + ${_protobuf_include_path} +- ${REL_FIL} +- DEPENDS ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} ${_gRPC_CPP_PLUGIN} ++ ${FIL} ++ DEPENDS ${_gRPC_PROTOBUF_PROTOC} ${_gRPC_CPP_PLUGIN} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Running gRPC C++ protocol buffer compiler on ${FIL}" +- VERBATIM) ++ ) + endforeach() + endfunction() + +@@ -413,178 +410,28 @@ add_custom_target(tools + DEPENDS tools_c tools_cxx) + + protobuf_generate_grpc_cpp( +- src/proto/grpc/channelz/channelz.proto ++ grpc/channelz/v1/channelz.proto + ) + protobuf_generate_grpc_cpp( +- src/proto/grpc/core/stats.proto ++ grpc/core/stats.proto + ) + protobuf_generate_grpc_cpp( +- src/proto/grpc/health/v1/health.proto ++ grpc/health/v1/health.proto + ) + protobuf_generate_grpc_cpp( +- src/proto/grpc/lb/v1/load_balancer.proto ++ grpc/lb/v1/load_balancer.proto + ) + protobuf_generate_grpc_cpp( +- src/proto/grpc/lookup/v1/rls.proto ++ grpc/lookup/v1/rls.proto + ) + protobuf_generate_grpc_cpp( +- src/proto/grpc/lookup/v1/rls_config.proto ++ grpc/lookup/v1/rls_config.proto + ) + protobuf_generate_grpc_cpp( +- src/proto/grpc/reflection/v1alpha/reflection.proto ++ grpc/reflection/v1alpha/reflection.proto + ) + protobuf_generate_grpc_cpp( +- src/proto/grpc/status/status.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/benchmark_service.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/control.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/duplicate/echo_duplicate.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/echo.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/echo_messages.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/empty.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/messages.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/payloads.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/report_qps_scenario_service.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/simple_messages.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/stats.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/test.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/worker_service.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/ads_for_test.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/cds_for_test.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/eds_for_test.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/lds_rds_for_test.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/lrs_for_test.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/address.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/ads.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/aggregate_cluster.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/base.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/cluster.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/config_dump.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/config_source.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/csds.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/discovery.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/endpoint.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/expr.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/extension.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/fault.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/fault_common.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/http_connection_manager.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/http_filter_rbac.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/listener.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/load_report.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/lrs.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/metadata.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/orca_load_report.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/orca_service.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/path.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/percent.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/protocol.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/range.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/rbac.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/regex.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/route.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/router.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/string.proto +-) +-protobuf_generate_grpc_cpp( +- src/proto/grpc/testing/xds/v3/tls.proto ++ grpc/status/status.proto + ) + protobuf_generate_grpc_cpp( + test/core/tsi/alts/fake_handshaker/handshaker.proto +@@ -3275,10 +3122,8 @@ endif() + + if(gRPC_BUILD_CODEGEN) + add_library(grpc++_reflection +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.pb.h +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h ++ ${_gRPC_PROTO_GENS_DIR}/grpc/reflection/v1alpha/reflection.grpc.pb.cc ++ ${_gRPC_PROTO_GENS_DIR}/grpc/reflection/v1alpha/reflection.grpc.pb.h + src/cpp/ext/proto_server_reflection.cc + src/cpp/ext/proto_server_reflection_plugin.cc + ) +@@ -3317,6 +3162,7 @@ target_link_libraries(grpc++_reflection + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++ ++ grpc-proto::grpc-proto + ) + + foreach(_hdr +@@ -3872,10 +3718,8 @@ endif() + # See https://github.com/grpc/grpc/issues/19473 + if(gRPC_BUILD_CODEGEN AND NOT gRPC_USE_PROTO_LITE) + add_library(grpcpp_channelz +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h ++ ${_gRPC_PROTO_GENS_DIR}/grpc/channelz/v1/channelz.grpc.pb.cc ++ ${_gRPC_PROTO_GENS_DIR}/grpc/channelz/v1/channelz.grpc.pb.h + src/cpp/server/channelz/channelz_service.cc + src/cpp/server/channelz/channelz_service_plugin.cc + ) +@@ -3914,6 +3758,7 @@ target_link_libraries(grpcpp_channelz + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++ ++ grpc-proto::grpc-proto + ) + + foreach(_hdr +diff --git a/src/cpp/ext/proto_server_reflection.h b/src/cpp/ext/proto_server_reflection.h +index 04f1e63..82837e8 100644 +--- a/src/cpp/ext/proto_server_reflection.h ++++ b/src/cpp/ext/proto_server_reflection.h +@@ -24,7 +24,7 @@ + + #include + +-#include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h" ++#include "grpc/reflection/v1alpha/reflection.grpc.pb.h" + + namespace grpc { + +diff --git a/src/cpp/server/channelz/channelz_service.h b/src/cpp/server/channelz/channelz_service.h +index 824f0a9..bfa31a1 100644 +--- a/src/cpp/server/channelz/channelz_service.h ++++ b/src/cpp/server/channelz/channelz_service.h +@@ -23,7 +23,7 @@ + + #include + +-#include "src/proto/grpc/channelz/channelz.grpc.pb.h" ++#include "grpc/channelz/v1/channelz.grpc.pb.h" + + namespace grpc { + diff --git a/recipes/grpc/all/patches/v1.47.x/001-disable-cppstd-override.patch b/recipes/grpc/all/patches/v1.47.x/001-disable-cppstd-override.patch new file mode 100644 index 0000000000000..0ba329e6480bc --- /dev/null +++ b/recipes/grpc/all/patches/v1.47.x/001-disable-cppstd-override.patch @@ -0,0 +1,31 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index db075cbe4a..289cc52215 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -220,26 +220,6 @@ if(WIN32) + set(_gRPC_PLATFORM_WINDOWS ON) + endif() + +- # Use C11 standard +-if (NOT DEFINED CMAKE_C_STANDARD) +- set(CMAKE_C_STANDARD 11) +-endif() +- +-# Add c++14 flags +-if (NOT DEFINED CMAKE_CXX_STANDARD) +- set(CMAKE_CXX_STANDARD 14) +-else() +- if (CMAKE_CXX_STANDARD LESS 14) +- message(FATAL_ERROR "CMAKE_CXX_STANDARD is less than 14, please specify at least SET(CMAKE_CXX_STANDARD 14)") +- endif() +-endif() +-if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) +- set(CMAKE_CXX_STANDARD_REQUIRED ON) +-endif() +-if (NOT DEFINED CMAKE_CXX_EXTENSIONS) +- set(CMAKE_CXX_EXTENSIONS OFF) +-endif() +- + if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + endif() diff --git a/recipes/grpc/all/patches/v1.47.x/002-consume-protos-from-requirements.patch b/recipes/grpc/all/patches/v1.47.x/002-consume-protos-from-requirements.patch new file mode 100644 index 0000000000000..9ead7f09de502 --- /dev/null +++ b/recipes/grpc/all/patches/v1.47.x/002-consume-protos-from-requirements.patch @@ -0,0 +1,309 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c1eaeba..706e6d1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -445,7 +445,7 @@ function(protobuf_generate_grpc_cpp_with_import_path_correction FILE_LOCATION IM + endif() + + # Sets the include path for ProtoBuf files +- set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}) ++ set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR} -I ${googleapis_RES_DIRS} -I ${grpc-proto_RES_DIRS}) + # The absolute path of the expected place for the input proto file + # For example, health proto has package name grpc.health.v1, it's expected to be: + # ${_gRPC_PROTO_SRCS_DIR}/grpc/health/v1/health.proto +@@ -470,8 +470,8 @@ function(protobuf_generate_grpc_cpp_with_import_path_correction FILE_LOCATION IM + # path. For example, health proto has package name grpc.health.v1, the bash + # equivalent would be: + # cp src/proto/grpc/health/v1/health.proto ${_gRPC_PROTO_SRCS_DIR}/grpc/health/v1 +- file(MAKE_DIRECTORY ${_gRPC_PROTO_SRCS_DIR}/${REL_DIR}) +- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_LOCATION} DESTINATION ${_gRPC_PROTO_SRCS_DIR}/${REL_DIR}) ++ # file(MAKE_DIRECTORY ${_gRPC_PROTO_SRCS_DIR}/${REL_DIR}) ++ # file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_LOCATION} DESTINATION ${_gRPC_PROTO_SRCS_DIR}/${REL_DIR}) + + #if cross-compiling, find host plugin + if(CMAKE_CROSSCOMPILING) +@@ -484,18 +484,15 @@ function(protobuf_generate_grpc_cpp_with_import_path_correction FILE_LOCATION IM + OUTPUT "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc" + "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h" + "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h" +- "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc" +- "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h" + COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE} + ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR} +- --cpp_out=${_gRPC_PROTO_GENS_DIR} + --plugin=protoc-gen-grpc=${_gRPC_CPP_PLUGIN} + ${_protobuf_include_path} +- ${REL_FIL} +- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_LOCATION} ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin ++ ${FILE_LOCATION} ++ DEPENDS ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin + WORKING_DIRECTORY ${_gRPC_PROTO_SRCS_DIR} +- COMMENT "Running gRPC C++ protocol buffer compiler for ${IMPORT_PATH}" +- VERBATIM) ++ COMMENT "Running gRPC C++ protocol buffer compiler for ${FILE_LOCATION}" ++ ) + endfunction() + + # These options allow users to enable or disable the building of the various +@@ -548,181 +545,28 @@ add_custom_target(tools + DEPENDS tools_c tools_cxx) + + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/channelz/channelz.proto src/proto/grpc/channelz/channelz.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/core/stats.proto src/proto/grpc/core/stats.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/health/v1/health.proto src/proto/grpc/health/v1/health.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/lb/v1/load_balancer.proto src/proto/grpc/lb/v1/load_balancer.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/lookup/v1/rls.proto src/proto/grpc/lookup/v1/rls.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/lookup/v1/rls_config.proto src/proto/grpc/lookup/v1/rls_config.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/reflection/v1alpha/reflection.proto src/proto/grpc/reflection/v1alpha/reflection.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/status/status.proto src/proto/grpc/status/status.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/benchmark_service.proto src/proto/grpc/testing/benchmark_service.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/control.proto src/proto/grpc/testing/control.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/duplicate/echo_duplicate.proto src/proto/grpc/testing/duplicate/echo_duplicate.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/echo.proto src/proto/grpc/testing/echo.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/echo_messages.proto src/proto/grpc/testing/echo_messages.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/empty.proto src/proto/grpc/testing/empty.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/messages.proto src/proto/grpc/testing/messages.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/payloads.proto src/proto/grpc/testing/payloads.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/report_qps_scenario_service.proto src/proto/grpc/testing/report_qps_scenario_service.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/simple_messages.proto src/proto/grpc/testing/simple_messages.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/stats.proto src/proto/grpc/testing/stats.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/test.proto src/proto/grpc/testing/test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/worker_service.proto src/proto/grpc/testing/worker_service.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/ads_for_test.proto src/proto/grpc/testing/xds/ads_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/cds_for_test.proto src/proto/grpc/testing/xds/cds_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/eds_for_test.proto src/proto/grpc/testing/xds/eds_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/lds_rds_for_test.proto src/proto/grpc/testing/xds/lds_rds_for_test.proto ++ grpc/channelz/v1/channelz.proto grpc/channelz/v1/channelz.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/lrs_for_test.proto src/proto/grpc/testing/xds/lrs_for_test.proto ++ grpc/core/stats.proto grpc/core/stats.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/address.proto src/proto/grpc/testing/xds/v3/address.proto ++ grpc/health/v1/health.proto grpc/health/v1/health.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/ads.proto src/proto/grpc/testing/xds/v3/ads.proto ++ grpc/lb/v1/load_balancer.proto grpc/lb/v1/load_balancer.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/aggregate_cluster.proto src/proto/grpc/testing/xds/v3/aggregate_cluster.proto ++ grpc/lookup/v1/rls.proto grpc/lookup/v1/rls.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/base.proto src/proto/grpc/testing/xds/v3/base.proto ++ grpc/lookup/v1/rls_config.proto grpc/lookup/v1/rls_config.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/cluster.proto src/proto/grpc/testing/xds/v3/cluster.proto ++ grpc/reflection/v1alpha/reflection.proto grpc/reflection/v1alpha/reflection.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/config_dump.proto src/proto/grpc/testing/xds/v3/config_dump.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/config_source.proto src/proto/grpc/testing/xds/v3/config_source.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/csds.proto src/proto/grpc/testing/xds/v3/csds.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/discovery.proto src/proto/grpc/testing/xds/v3/discovery.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/endpoint.proto src/proto/grpc/testing/xds/v3/endpoint.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/expr.proto src/proto/grpc/testing/xds/v3/expr.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/extension.proto src/proto/grpc/testing/xds/v3/extension.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/fault.proto src/proto/grpc/testing/xds/v3/fault.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/fault_common.proto src/proto/grpc/testing/xds/v3/fault_common.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/http_connection_manager.proto src/proto/grpc/testing/xds/v3/http_connection_manager.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/http_filter_rbac.proto src/proto/grpc/testing/xds/v3/http_filter_rbac.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/listener.proto src/proto/grpc/testing/xds/v3/listener.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/load_report.proto src/proto/grpc/testing/xds/v3/load_report.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/lrs.proto src/proto/grpc/testing/xds/v3/lrs.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/metadata.proto src/proto/grpc/testing/xds/v3/metadata.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/orca_load_report.proto src/proto/grpc/testing/xds/v3/orca_load_report.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/orca_service.proto src/proto/grpc/testing/xds/v3/orca_service.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/outlier_detection.proto src/proto/grpc/testing/xds/v3/outlier_detection.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/path.proto src/proto/grpc/testing/xds/v3/path.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/percent.proto src/proto/grpc/testing/xds/v3/percent.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/protocol.proto src/proto/grpc/testing/xds/v3/protocol.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/range.proto src/proto/grpc/testing/xds/v3/range.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/rbac.proto src/proto/grpc/testing/xds/v3/rbac.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/regex.proto src/proto/grpc/testing/xds/v3/regex.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/route.proto src/proto/grpc/testing/xds/v3/route.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/router.proto src/proto/grpc/testing/xds/v3/router.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/string.proto src/proto/grpc/testing/xds/v3/string.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/tls.proto src/proto/grpc/testing/xds/v3/tls.proto ++ grpc/status/status.proto grpc/status/status.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( + test/core/tsi/alts/fake_handshaker/handshaker.proto test/core/tsi/alts/fake_handshaker/handshaker.proto +@@ -3446,10 +3290,8 @@ endif() + + if(gRPC_BUILD_CODEGEN) + add_library(grpc++_reflection +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.pb.h +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h ++ ${_gRPC_PROTO_GENS_DIR}/grpc/reflection/v1alpha/reflection.grpc.pb.cc ++ ${_gRPC_PROTO_GENS_DIR}/grpc/reflection/v1alpha/reflection.grpc.pb.h + src/cpp/ext/proto_server_reflection.cc + src/cpp/ext/proto_server_reflection_plugin.cc + ) +@@ -3488,6 +3330,7 @@ target_link_libraries(grpc++_reflection + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++ ++ grpc-proto::grpc-proto + ) + + foreach(_hdr +@@ -4076,10 +3919,8 @@ endif() + # See https://github.com/grpc/grpc/issues/19473 + if(gRPC_BUILD_CODEGEN AND NOT gRPC_USE_PROTO_LITE) + add_library(grpcpp_channelz +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h ++ ${_gRPC_PROTO_GENS_DIR}/grpc/channelz/v1/channelz.grpc.pb.cc ++ ${_gRPC_PROTO_GENS_DIR}/grpc/channelz/v1/channelz.grpc.pb.h + src/cpp/server/channelz/channelz_service.cc + src/cpp/server/channelz/channelz_service_plugin.cc + ) +@@ -4118,6 +3959,7 @@ target_link_libraries(grpcpp_channelz + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++ ++ grpc-proto::grpc-proto + ) + + foreach(_hdr +diff --git a/src/cpp/ext/proto_server_reflection.h b/src/cpp/ext/proto_server_reflection.h +index a9b5db0..528e75b 100644 +--- a/src/cpp/ext/proto_server_reflection.h ++++ b/src/cpp/ext/proto_server_reflection.h +@@ -29,8 +29,8 @@ + #include + #include + +-#include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h" +-#include "src/proto/grpc/reflection/v1alpha/reflection.pb.h" ++#include "grpc/reflection/v1alpha/reflection.grpc.pb.h" ++#include "grpc/reflection/v1alpha/reflection.pb.h" + + namespace grpc { + +diff --git a/src/cpp/server/channelz/channelz_service.h b/src/cpp/server/channelz/channelz_service.h +index 91936da..a84c57a 100644 +--- a/src/cpp/server/channelz/channelz_service.h ++++ b/src/cpp/server/channelz/channelz_service.h +@@ -24,8 +24,8 @@ + #include + #include + +-#include "src/proto/grpc/channelz/channelz.grpc.pb.h" +-#include "src/proto/grpc/channelz/channelz.pb.h" ++#include "grpc/channelz/v1/channelz.grpc.pb.h" ++#include "grpc/channelz/v1/channelz.pb.h" + + namespace grpc { + diff --git a/recipes/grpc/all/patches/v1.48.x/001-disable-cppstd-override.patch b/recipes/grpc/all/patches/v1.48.x/001-disable-cppstd-override.patch new file mode 100644 index 0000000000000..65b655ba1f8b5 --- /dev/null +++ b/recipes/grpc/all/patches/v1.48.x/001-disable-cppstd-override.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 25990a5..f37849c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -226,21 +226,6 @@ if (NOT DEFINED CMAKE_C_STANDARD) + set(CMAKE_C_STANDARD 11) + endif() + +-# Add c++14 flags +-if (NOT DEFINED CMAKE_CXX_STANDARD) +- set(CMAKE_CXX_STANDARD 14) +-else() +- if (CMAKE_CXX_STANDARD LESS 14) +- message(FATAL_ERROR "CMAKE_CXX_STANDARD is less than 14, please specify at least SET(CMAKE_CXX_STANDARD 14)") +- endif() +-endif() +-if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) +- set(CMAKE_CXX_STANDARD_REQUIRED ON) +-endif() +-if (NOT DEFINED CMAKE_CXX_EXTENSIONS) +- set(CMAKE_CXX_EXTENSIONS OFF) +-endif() +- + if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + endif() diff --git a/recipes/grpc/all/patches/v1.48.x/002-consume-protos-from-requirements.patch b/recipes/grpc/all/patches/v1.48.x/002-consume-protos-from-requirements.patch new file mode 100644 index 0000000000000..5fd52235a25e3 --- /dev/null +++ b/recipes/grpc/all/patches/v1.48.x/002-consume-protos-from-requirements.patch @@ -0,0 +1,327 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7d23aa5..457188b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -451,7 +451,7 @@ function(protobuf_generate_grpc_cpp_with_import_path_correction FILE_LOCATION IM + endif() + + # Sets the include path for ProtoBuf files +- set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}) ++ set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR} -I ${googleapis_RES_DIRS} -I ${grpc-proto_RES_DIRS}) + # The absolute path of the expected place for the input proto file + # For example, health proto has package name grpc.health.v1, it's expected to be: + # ${_gRPC_PROTO_SRCS_DIR}/grpc/health/v1/health.proto +@@ -476,8 +476,8 @@ function(protobuf_generate_grpc_cpp_with_import_path_correction FILE_LOCATION IM + # path. For example, health proto has package name grpc.health.v1, the bash + # equivalent would be: + # cp src/proto/grpc/health/v1/health.proto ${_gRPC_PROTO_SRCS_DIR}/grpc/health/v1 +- file(MAKE_DIRECTORY ${_gRPC_PROTO_SRCS_DIR}/${REL_DIR}) +- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_LOCATION} DESTINATION ${_gRPC_PROTO_SRCS_DIR}/${REL_DIR}) ++ # file(MAKE_DIRECTORY ${_gRPC_PROTO_SRCS_DIR}/${REL_DIR}) ++ # file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_LOCATION} DESTINATION ${_gRPC_PROTO_SRCS_DIR}/${REL_DIR}) + + #if cross-compiling, find host plugin + if(CMAKE_CROSSCOMPILING) +@@ -490,18 +490,15 @@ function(protobuf_generate_grpc_cpp_with_import_path_correction FILE_LOCATION IM + OUTPUT "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc" + "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h" + "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h" +- "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc" +- "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h" + COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE} + ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR} +- --cpp_out=${_gRPC_PROTO_GENS_DIR} + --plugin=protoc-gen-grpc=${_gRPC_CPP_PLUGIN} + ${_protobuf_include_path} +- ${REL_FIL} +- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_LOCATION} ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin ++ ${FILE_LOCATION} ++ DEPENDS ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin + WORKING_DIRECTORY ${_gRPC_PROTO_SRCS_DIR} +- COMMENT "Running gRPC C++ protocol buffer compiler for ${IMPORT_PATH}" +- VERBATIM) ++ COMMENT "Running gRPC C++ protocol buffer compiler for ${FILE_LOCATION}" ++ ) + endfunction() + + # These options allow users to enable or disable the building of the various +@@ -554,199 +551,28 @@ add_custom_target(tools + DEPENDS tools_c tools_cxx) + + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/channelz/channelz.proto src/proto/grpc/channelz/channelz.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/core/stats.proto src/proto/grpc/core/stats.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/health/v1/health.proto src/proto/grpc/health/v1/health.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/lb/v1/load_balancer.proto src/proto/grpc/lb/v1/load_balancer.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/lookup/v1/rls.proto src/proto/grpc/lookup/v1/rls.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/lookup/v1/rls_config.proto src/proto/grpc/lookup/v1/rls_config.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/reflection/v1alpha/reflection.proto src/proto/grpc/reflection/v1alpha/reflection.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/status/status.proto src/proto/grpc/status/status.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/benchmark_service.proto src/proto/grpc/testing/benchmark_service.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/control.proto src/proto/grpc/testing/control.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/duplicate/echo_duplicate.proto src/proto/grpc/testing/duplicate/echo_duplicate.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/echo.proto src/proto/grpc/testing/echo.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/echo_messages.proto src/proto/grpc/testing/echo_messages.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/empty.proto src/proto/grpc/testing/empty.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/istio_echo.proto src/proto/grpc/testing/istio_echo.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/messages.proto src/proto/grpc/testing/messages.proto ++ grpc/channelz/v1/channelz.proto grpc/channelz/v1/channelz.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/payloads.proto src/proto/grpc/testing/payloads.proto ++ grpc/core/stats.proto grpc/core/stats.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/report_qps_scenario_service.proto src/proto/grpc/testing/report_qps_scenario_service.proto ++ grpc/health/v1/health.proto grpc/health/v1/health.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/simple_messages.proto src/proto/grpc/testing/simple_messages.proto ++ grpc/lb/v1/load_balancer.proto grpc/lb/v1/load_balancer.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/stats.proto src/proto/grpc/testing/stats.proto ++ grpc/lookup/v1/rls.proto grpc/lookup/v1/rls.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/test.proto src/proto/grpc/testing/test.proto ++ grpc/lookup/v1/rls_config.proto grpc/lookup/v1/rls_config.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/worker_service.proto src/proto/grpc/testing/worker_service.proto ++ grpc/reflection/v1alpha/reflection.proto grpc/reflection/v1alpha/reflection.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/ads_for_test.proto src/proto/grpc/testing/xds/ads_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/cds_for_test.proto src/proto/grpc/testing/xds/cds_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/eds_for_test.proto src/proto/grpc/testing/xds/eds_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/lds_rds_for_test.proto src/proto/grpc/testing/xds/lds_rds_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/lrs_for_test.proto src/proto/grpc/testing/xds/lrs_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/address.proto src/proto/grpc/testing/xds/v3/address.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/ads.proto src/proto/grpc/testing/xds/v3/ads.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/aggregate_cluster.proto src/proto/grpc/testing/xds/v3/aggregate_cluster.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/base.proto src/proto/grpc/testing/xds/v3/base.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/cluster.proto src/proto/grpc/testing/xds/v3/cluster.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/config_dump.proto src/proto/grpc/testing/xds/v3/config_dump.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/config_source.proto src/proto/grpc/testing/xds/v3/config_source.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/csds.proto src/proto/grpc/testing/xds/v3/csds.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/discovery.proto src/proto/grpc/testing/xds/v3/discovery.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/endpoint.proto src/proto/grpc/testing/xds/v3/endpoint.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/expr.proto src/proto/grpc/testing/xds/v3/expr.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/extension.proto src/proto/grpc/testing/xds/v3/extension.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/fault.proto src/proto/grpc/testing/xds/v3/fault.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/fault_common.proto src/proto/grpc/testing/xds/v3/fault_common.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/http_connection_manager.proto src/proto/grpc/testing/xds/v3/http_connection_manager.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/http_filter_rbac.proto src/proto/grpc/testing/xds/v3/http_filter_rbac.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/listener.proto src/proto/grpc/testing/xds/v3/listener.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/load_report.proto src/proto/grpc/testing/xds/v3/load_report.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/lrs.proto src/proto/grpc/testing/xds/v3/lrs.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/metadata.proto src/proto/grpc/testing/xds/v3/metadata.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/orca_load_report.proto src/proto/grpc/testing/xds/v3/orca_load_report.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/orca_service.proto src/proto/grpc/testing/xds/v3/orca_service.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/outlier_detection.proto src/proto/grpc/testing/xds/v3/outlier_detection.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/path.proto src/proto/grpc/testing/xds/v3/path.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/percent.proto src/proto/grpc/testing/xds/v3/percent.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/protocol.proto src/proto/grpc/testing/xds/v3/protocol.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/range.proto src/proto/grpc/testing/xds/v3/range.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/rbac.proto src/proto/grpc/testing/xds/v3/rbac.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/regex.proto src/proto/grpc/testing/xds/v3/regex.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/ring_hash.proto src/proto/grpc/testing/xds/v3/ring_hash.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/round_robin.proto src/proto/grpc/testing/xds/v3/round_robin.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/route.proto src/proto/grpc/testing/xds/v3/route.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/router.proto src/proto/grpc/testing/xds/v3/router.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/string.proto src/proto/grpc/testing/xds/v3/string.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/tls.proto src/proto/grpc/testing/xds/v3/tls.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/typed_struct.proto src/proto/grpc/testing/xds/v3/typed_struct.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/udpa_typed_struct.proto src/proto/grpc/testing/xds/v3/udpa_typed_struct.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/wrr_locality.proto src/proto/grpc/testing/xds/v3/wrr_locality.proto ++ src/proto/grpc/status/status.proto grpc/status/status.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( + test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.proto test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.proto +@@ -3497,10 +3323,8 @@ endif() + + if(gRPC_BUILD_CODEGEN) + add_library(grpc++_reflection +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.pb.h +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h ++ ${_gRPC_PROTO_GENS_DIR}/grpc/reflection/v1alpha/reflection.grpc.pb.cc ++ ${_gRPC_PROTO_GENS_DIR}/grpc/reflection/v1alpha/reflection.grpc.pb.h + src/cpp/ext/proto_server_reflection.cc + src/cpp/ext/proto_server_reflection_plugin.cc + ) +@@ -3539,6 +3363,7 @@ target_link_libraries(grpc++_reflection + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++ ++ grpc-proto::grpc-proto + ) + + foreach(_hdr +@@ -4096,10 +3921,8 @@ endif() + # See https://github.com/grpc/grpc/issues/19473 + if(gRPC_BUILD_CODEGEN AND NOT gRPC_USE_PROTO_LITE) + add_library(grpcpp_channelz +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h ++ ${_gRPC_PROTO_GENS_DIR}/grpc/channelz/v1/channelz.grpc.pb.cc ++ ${_gRPC_PROTO_GENS_DIR}/grpc/channelz/v1/channelz.grpc.pb.h + src/cpp/server/channelz/channelz_service.cc + src/cpp/server/channelz/channelz_service_plugin.cc + ) +@@ -4138,6 +3961,7 @@ target_link_libraries(grpcpp_channelz + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++ ++ grpc-proto::grpc-proto + ) + + foreach(_hdr +diff --git a/src/cpp/ext/proto_server_reflection.h b/src/cpp/ext/proto_server_reflection.h +index a9b5db0..528e75b 100644 +--- a/src/cpp/ext/proto_server_reflection.h ++++ b/src/cpp/ext/proto_server_reflection.h +@@ -29,8 +29,8 @@ + #include + #include + +-#include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h" +-#include "src/proto/grpc/reflection/v1alpha/reflection.pb.h" ++#include "grpc/reflection/v1alpha/reflection.grpc.pb.h" ++#include "grpc/reflection/v1alpha/reflection.pb.h" + + namespace grpc { + +diff --git a/src/cpp/server/channelz/channelz_service.h b/src/cpp/server/channelz/channelz_service.h +index 91936da..a84c57a 100644 +--- a/src/cpp/server/channelz/channelz_service.h ++++ b/src/cpp/server/channelz/channelz_service.h +@@ -24,8 +24,8 @@ + #include + #include + +-#include "src/proto/grpc/channelz/channelz.grpc.pb.h" +-#include "src/proto/grpc/channelz/channelz.pb.h" ++#include "grpc/channelz/v1/channelz.grpc.pb.h" ++#include "grpc/channelz/v1/channelz.pb.h" + + namespace grpc { + diff --git a/recipes/grpc/all/patches/v1.50.x/001-disable-cppstd-override.patch b/recipes/grpc/all/patches/v1.50.x/001-disable-cppstd-override.patch new file mode 100644 index 0000000000000..a9339dbcc896b --- /dev/null +++ b/recipes/grpc/all/patches/v1.50.x/001-disable-cppstd-override.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7052846..259fa93 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -227,21 +227,6 @@ if (NOT DEFINED CMAKE_C_STANDARD) + set(CMAKE_C_STANDARD 11) + endif() + +-# Add c++14 flags +-if (NOT DEFINED CMAKE_CXX_STANDARD) +- set(CMAKE_CXX_STANDARD 14) +-else() +- if (CMAKE_CXX_STANDARD LESS 14) +- message(FATAL_ERROR "CMAKE_CXX_STANDARD is less than 14, please specify at least SET(CMAKE_CXX_STANDARD 14)") +- endif() +-endif() +-if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) +- set(CMAKE_CXX_STANDARD_REQUIRED ON) +-endif() +-if (NOT DEFINED CMAKE_CXX_EXTENSIONS) +- set(CMAKE_CXX_EXTENSIONS OFF) +-endif() +- + if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + endif() diff --git a/recipes/grpc/all/patches/v1.50.x/002-consume-protos-from-requirements.patch b/recipes/grpc/all/patches/v1.50.x/002-consume-protos-from-requirements.patch new file mode 100644 index 0000000000000..515291213b267 --- /dev/null +++ b/recipes/grpc/all/patches/v1.50.x/002-consume-protos-from-requirements.patch @@ -0,0 +1,326 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 259fa93..fb05774 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -452,7 +452,7 @@ function(protobuf_generate_grpc_cpp_with_import_path_correction FILE_LOCATION IM + endif() + + # Sets the include path for ProtoBuf files +- set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}) ++ set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR} -I ${googleapis_RES_DIRS} -I ${grpc-proto_RES_DIRS}) + # The absolute path of the expected place for the input proto file + # For example, health proto has package name grpc.health.v1, it's expected to be: + # ${_gRPC_PROTO_SRCS_DIR}/grpc/health/v1/health.proto +@@ -477,8 +477,6 @@ function(protobuf_generate_grpc_cpp_with_import_path_correction FILE_LOCATION IM + # path. For example, health proto has package name grpc.health.v1, the bash + # equivalent would be: + # cp src/proto/grpc/health/v1/health.proto ${_gRPC_PROTO_SRCS_DIR}/grpc/health/v1 +- file(MAKE_DIRECTORY ${_gRPC_PROTO_SRCS_DIR}/${REL_DIR}) +- file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_LOCATION} DESTINATION ${_gRPC_PROTO_SRCS_DIR}/${REL_DIR}) + + #if cross-compiling, find host plugin + if(CMAKE_CROSSCOMPILING) +@@ -491,18 +489,15 @@ function(protobuf_generate_grpc_cpp_with_import_path_correction FILE_LOCATION IM + OUTPUT "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc" + "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.h" + "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}_mock.grpc.pb.h" +- "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.cc" +- "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.pb.h" + COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE} + ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR} +- --cpp_out=${_gRPC_PROTO_GENS_DIR} + --plugin=protoc-gen-grpc=${_gRPC_CPP_PLUGIN} + ${_protobuf_include_path} +- ${REL_FIL} +- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_LOCATION} ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} ${_gRPC_CPP_PLUGIN} ++ ${FILE_LOCATION} ++ DEPENDS ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin + WORKING_DIRECTORY ${_gRPC_PROTO_SRCS_DIR} +- COMMENT "Running gRPC C++ protocol buffer compiler for ${IMPORT_PATH}" +- VERBATIM) ++ COMMENT "Running gRPC C++ protocol buffer compiler for ${FILE_LOCATION}" ++ ) + endfunction() + + # These options allow users to enable or disable the building of the various +@@ -554,199 +549,28 @@ add_custom_target(tools + DEPENDS tools_c tools_cxx) + + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/channelz/channelz.proto src/proto/grpc/channelz/channelz.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/core/stats.proto src/proto/grpc/core/stats.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/health/v1/health.proto src/proto/grpc/health/v1/health.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/lb/v1/load_balancer.proto src/proto/grpc/lb/v1/load_balancer.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/lookup/v1/rls.proto src/proto/grpc/lookup/v1/rls.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/lookup/v1/rls_config.proto src/proto/grpc/lookup/v1/rls_config.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/reflection/v1alpha/reflection.proto src/proto/grpc/reflection/v1alpha/reflection.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/status/status.proto src/proto/grpc/status/status.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/benchmark_service.proto src/proto/grpc/testing/benchmark_service.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/control.proto src/proto/grpc/testing/control.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/duplicate/echo_duplicate.proto src/proto/grpc/testing/duplicate/echo_duplicate.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/echo.proto src/proto/grpc/testing/echo.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/echo_messages.proto src/proto/grpc/testing/echo_messages.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/empty.proto src/proto/grpc/testing/empty.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/istio_echo.proto src/proto/grpc/testing/istio_echo.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/messages.proto src/proto/grpc/testing/messages.proto ++ grpc/channelz/v1/channelz.proto grpc/channelz/v1/channelz.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/payloads.proto src/proto/grpc/testing/payloads.proto ++ grpc/core/stats.proto grpc/core/stats.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/report_qps_scenario_service.proto src/proto/grpc/testing/report_qps_scenario_service.proto ++ grpc/health/v1/health.proto grpc/health/v1/health.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/simple_messages.proto src/proto/grpc/testing/simple_messages.proto ++ grpc/lb/v1/load_balancer.proto grpc/lb/v1/load_balancer.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/stats.proto src/proto/grpc/testing/stats.proto ++ grpc/lookup/v1/rls.proto grpc/lookup/v1/rls.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/test.proto src/proto/grpc/testing/test.proto ++ grpc/lookup/v1/rls_config.proto grpc/lookup/v1/rls_config.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/worker_service.proto src/proto/grpc/testing/worker_service.proto ++ grpc/reflection/v1alpha/reflection.proto grpc/reflection/v1alpha/reflection.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/ads_for_test.proto src/proto/grpc/testing/xds/ads_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/cds_for_test.proto src/proto/grpc/testing/xds/cds_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/eds_for_test.proto src/proto/grpc/testing/xds/eds_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/lds_rds_for_test.proto src/proto/grpc/testing/xds/lds_rds_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/lrs_for_test.proto src/proto/grpc/testing/xds/lrs_for_test.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/address.proto src/proto/grpc/testing/xds/v3/address.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/ads.proto src/proto/grpc/testing/xds/v3/ads.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/aggregate_cluster.proto src/proto/grpc/testing/xds/v3/aggregate_cluster.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/base.proto src/proto/grpc/testing/xds/v3/base.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/cluster.proto src/proto/grpc/testing/xds/v3/cluster.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/config_dump.proto src/proto/grpc/testing/xds/v3/config_dump.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/config_source.proto src/proto/grpc/testing/xds/v3/config_source.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/csds.proto src/proto/grpc/testing/xds/v3/csds.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/discovery.proto src/proto/grpc/testing/xds/v3/discovery.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/endpoint.proto src/proto/grpc/testing/xds/v3/endpoint.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/expr.proto src/proto/grpc/testing/xds/v3/expr.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/extension.proto src/proto/grpc/testing/xds/v3/extension.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/fault.proto src/proto/grpc/testing/xds/v3/fault.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/fault_common.proto src/proto/grpc/testing/xds/v3/fault_common.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/http_connection_manager.proto src/proto/grpc/testing/xds/v3/http_connection_manager.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/http_filter_rbac.proto src/proto/grpc/testing/xds/v3/http_filter_rbac.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/listener.proto src/proto/grpc/testing/xds/v3/listener.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/load_report.proto src/proto/grpc/testing/xds/v3/load_report.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/lrs.proto src/proto/grpc/testing/xds/v3/lrs.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/metadata.proto src/proto/grpc/testing/xds/v3/metadata.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/orca_load_report.proto src/proto/grpc/testing/xds/v3/orca_load_report.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/orca_service.proto src/proto/grpc/testing/xds/v3/orca_service.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/outlier_detection.proto src/proto/grpc/testing/xds/v3/outlier_detection.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/path.proto src/proto/grpc/testing/xds/v3/path.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/percent.proto src/proto/grpc/testing/xds/v3/percent.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/protocol.proto src/proto/grpc/testing/xds/v3/protocol.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/range.proto src/proto/grpc/testing/xds/v3/range.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/rbac.proto src/proto/grpc/testing/xds/v3/rbac.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/regex.proto src/proto/grpc/testing/xds/v3/regex.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/ring_hash.proto src/proto/grpc/testing/xds/v3/ring_hash.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/round_robin.proto src/proto/grpc/testing/xds/v3/round_robin.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/route.proto src/proto/grpc/testing/xds/v3/route.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/router.proto src/proto/grpc/testing/xds/v3/router.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/string.proto src/proto/grpc/testing/xds/v3/string.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/tls.proto src/proto/grpc/testing/xds/v3/tls.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/typed_struct.proto src/proto/grpc/testing/xds/v3/typed_struct.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/udpa_typed_struct.proto src/proto/grpc/testing/xds/v3/udpa_typed_struct.proto +-) +-protobuf_generate_grpc_cpp_with_import_path_correction( +- src/proto/grpc/testing/xds/v3/wrr_locality.proto src/proto/grpc/testing/xds/v3/wrr_locality.proto ++ src/proto/grpc/status/status.proto grpc/status/status.proto + ) + protobuf_generate_grpc_cpp_with_import_path_correction( + test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.proto test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.proto +@@ -3536,10 +3360,8 @@ endif() + + if(gRPC_BUILD_CODEGEN) + add_library(grpc++_reflection +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.pb.h +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h ++ ${_gRPC_PROTO_GENS_DIR}/grpc/reflection/v1alpha/reflection.grpc.pb.cc ++ ${_gRPC_PROTO_GENS_DIR}/grpc/reflection/v1alpha/reflection.grpc.pb.h + src/cpp/ext/proto_server_reflection.cc + src/cpp/ext/proto_server_reflection_plugin.cc + ) +@@ -3578,6 +3400,7 @@ target_link_libraries(grpc++_reflection + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++ ++ grpc-proto::grpc-proto + ) + + foreach(_hdr +@@ -4149,10 +3972,8 @@ endif() + # See https://github.com/grpc/grpc/issues/19473 + if(gRPC_BUILD_CODEGEN AND NOT gRPC_USE_PROTO_LITE) + add_library(grpcpp_channelz +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.cc +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.pb.h +- ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/channelz/channelz.grpc.pb.h ++ ${_gRPC_PROTO_GENS_DIR}/grpc/channelz/v1/channelz.grpc.pb.cc ++ ${_gRPC_PROTO_GENS_DIR}/grpc/channelz/v1/channelz.grpc.pb.h + src/cpp/server/channelz/channelz_service.cc + src/cpp/server/channelz/channelz_service_plugin.cc + ) +@@ -4191,6 +4012,7 @@ target_link_libraries(grpcpp_channelz + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++ ++ grpc-proto::grpc-proto + ) + + foreach(_hdr +diff --git a/src/cpp/ext/proto_server_reflection.h b/src/cpp/ext/proto_server_reflection.h +index a9b5db0..528e75b 100644 +--- a/src/cpp/ext/proto_server_reflection.h ++++ b/src/cpp/ext/proto_server_reflection.h +@@ -29,8 +29,8 @@ + #include + #include + +-#include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h" +-#include "src/proto/grpc/reflection/v1alpha/reflection.pb.h" ++#include "grpc/reflection/v1alpha/reflection.grpc.pb.h" ++#include "grpc/reflection/v1alpha/reflection.pb.h" + + namespace grpc { + +diff --git a/src/cpp/server/channelz/channelz_service.h b/src/cpp/server/channelz/channelz_service.h +index 91936da..0172493 100644 +--- a/src/cpp/server/channelz/channelz_service.h ++++ b/src/cpp/server/channelz/channelz_service.h +@@ -24,8 +24,9 @@ + #include + #include + +-#include "src/proto/grpc/channelz/channelz.grpc.pb.h" +-#include "src/proto/grpc/channelz/channelz.pb.h" ++#include "grpc/channelz/v1/channelz.grpc.pb.h" ++#include "grpc/channelz/v1/channelz.pb.h" ++ + + namespace grpc { + diff --git a/recipes/grpc/all/test_package/CMakeLists.txt b/recipes/grpc/all/test_package/CMakeLists.txt index e0b3331f48ad1..0ada3fb25d2c8 100644 --- a/recipes/grpc/all/test_package/CMakeLists.txt +++ b/recipes/grpc/all/test_package/CMakeLists.txt @@ -1,53 +1,30 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.12) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -if(WIN32) - add_definitions(-D_WIN32_WINNT=0x600) -endif() -set(CMAKE_CXX_STANDARD 11) - -# Find Protobuf installation - -set(protobuf_MODULE_COMPATIBLE TRUE) find_package(protobuf CONFIG REQUIRED) -message(STATUS "Using protobuf ${protobuf_VERSION}") - -# Find gRPC installation find_package(gRPC CONFIG REQUIRED) -message(STATUS "Using gRPC ${gRPC_VERSION}") -set(_GRPC_CPP_PLUGIN_EXECUTABLE $) - -# Proto file -get_filename_component(hw_proto "helloworld.proto" ABSOLUTE) -get_filename_component(hw_proto_path "${hw_proto}" PATH) -# Generated sources -set(hw_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.cc") -set(hw_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.h") -set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc") -set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.h") -add_custom_command( - OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}" "${hw_grpc_srcs}" "${hw_grpc_hdrs}" - COMMAND ${Protobuf_PROTOC_EXECUTABLE} - ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" - --cpp_out "${CMAKE_CURRENT_BINARY_DIR}" - -I "${hw_proto_path}" - --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" - "${hw_proto}" - DEPENDS "${hw_proto}") - -# Build generated sources as an object library -add_library(hw_proto_obj OBJECT ${hw_proto_srcs} ${hw_grpc_srcs}) - -# Include generated *.pb.h files -include_directories("${CMAKE_CURRENT_BINARY_DIR}") - -# Targets greeter_[async_](client) -foreach(_target greeter_client_server) -# greeter_async_client greeter_async_server) - add_executable(${_target} "${_target}.cc" $) - target_link_libraries(${_target} gRPC::grpc++_unsecure) -endforeach() +add_executable(${PROJECT_NAME} test_package.cpp helloworld.proto) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) # grpc 1.47.0 requires c++14 +target_link_libraries(${PROJECT_NAME} + PRIVATE + protobuf::libprotobuf + $,gRPC::grpc++_unsecure,gRPC::grpc++> +) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +if(TEST_ACTUAL_SERVER) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DTEST_ACTUAL_SERVER) +endif() +protobuf_generate( + TARGET ${PROJECT_NAME} + LANGUAGE cpp +) +protobuf_generate( + TARGET ${PROJECT_NAME} + LANGUAGE grpc + GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc + PLUGIN protoc-gen-grpc=$ +) diff --git a/recipes/grpc/all/test_package/conanfile.py b/recipes/grpc/all/test_package/conanfile.py index d2e0614668385..711d400cf235d 100644 --- a/recipes/grpc/all/test_package/conanfile.py +++ b/recipes/grpc/all/test_package/conanfile.py @@ -1,21 +1,44 @@ from conans import ConanFile, CMake, tools +import contextlib import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build_requirements(self): - if tools.cross_building(self.settings): - self.build_requires(str(self.requires['protobuf'])) - + if hasattr(self, "settings_build"): + self.build_requires(str(self.requires["grpc"])) + + @contextlib.contextmanager + def _buildenv(self): + # TODO: conan v2: replace by VirtualBuildEnv and always add grpc to build requirements + if tools.cross_building(self): + yield + else: + with tools.run_environment(self): + yield + def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() + # TODO: always build in conan v2 + # this is a limitation of conan v1: + # at build time we want to inject PATH/LD_LIBRARY/DYLD_LIBRARY_PATH + # of build requirements so that gprc_cpp_plugin can find its + # shared dependencies (in build context as well) + # should be fixed by using: CMakeToolchain + VirtualBuildEnv + if tools.cross_building(self) and self.options["grpc"].shared: + return + with self._buildenv(): + cmake = CMake(self) + # FIXME: This combination of settings randomly fails in CI + cmake.definitions["TEST_ACTUAL_SERVER"] = not (self.settings.compiler == "Visual Studio" + and self.settings.compiler.version == "15" + and self.settings.build_type == "Release") + cmake.configure() + cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join(".", "bin", "greeter_client_server") + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/grpc/all/test_package/greeter_client_server.cc b/recipes/grpc/all/test_package/greeter_client_server.cc deleted file mode 100644 index 54ab4bce36951..0000000000000 --- a/recipes/grpc/all/test_package/greeter_client_server.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include -#include -#include -#include - -#include -#include "helloworld.grpc.pb.h" - -using grpc::Channel; -using grpc::ClientContext; -using grpc::Server; -using grpc::ServerBuilder; -using grpc::ServerContext; -using grpc::Status; -using helloworld::HelloRequest; -using helloworld::HelloReply; -using helloworld::Greeter; - -class GreeterClient { - public: - GreeterClient(std::shared_ptr channel) - : stub_(Greeter::NewStub(channel)) {} - - // Assembles the client's payload, sends it and presents the response back - // from the server. - std::string SayHello(const std::string& user) { - // Data we are sending to the server. - HelloRequest request; - request.set_name(user); - - // Container for the data we expect from the server. - HelloReply reply; - - // Context for the client. It could be used to convey extra information to - // the server and/or tweak certain RPC behaviors. - ClientContext context; - - // The actual RPC. - Status status = stub_->SayHello(&context, request, &reply); - - // Act upon its status. - if (status.ok()) { - return reply.message(); - } else { - std::cout << status.error_code() << ": " << status.error_message() - << std::endl; - return "RPC failed"; - } - } - - private: - std::unique_ptr stub_; -}; - -// Logic and data behind the server's behavior. -class GreeterServiceImpl final : public Greeter::Service { - Status SayHello(ServerContext* context, const HelloRequest* request, - HelloReply* reply) override { - std::string prefix("Hello "); - reply->set_message(prefix + request->name()); - return Status::OK; - } -}; - -int main(int argc, char** argv) { - std::string server_address("127.0.0.1:0"); - GreeterServiceImpl service; - - ServerBuilder builder; - int selected_port = 0; - // Listen on the given address without any authentication mechanism. - builder.AddListeningPort(server_address, grpc::InsecureServerCredentials(), - &selected_port); - // Register "service" as the instance through which we'll communicate with - // clients. In this case it corresponds to an *synchronous* service. - builder.RegisterService(&service); - // Finally assemble the server. - std::unique_ptr server(builder.BuildAndStart()); - std::cout << "Server listening on 127.0.0.1:" << selected_port << std::endl; - - // Instantiate the client. It requires a channel, out of which the actual RPCs - // are created. This channel models a connection to an endpoint (in this case, - // localhost at the selected port). We indicate that the channel isn't - // authenticated (use of InsecureChannelCredentials()). - std::ostringstream addr; - addr << "localhost:" << selected_port; - GreeterClient greeter(grpc::CreateChannel( - addr.str(), grpc::InsecureChannelCredentials())); - std::string user("world"); - std::string reply = greeter.SayHello(user); - std::cout << "Greeter received: " << reply << std::endl; - - server->Shutdown(); - server->Wait(); - - return 0; -} diff --git a/recipes/grpc/all/test_package/test_package.cpp b/recipes/grpc/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..18a37cf90692e --- /dev/null +++ b/recipes/grpc/all/test_package/test_package.cpp @@ -0,0 +1,122 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include + +#include +#include "helloworld.grpc.pb.h" + +using grpc::Channel; +using grpc::ClientContext; +using grpc::Server; +using grpc::ServerBuilder; +using grpc::ServerContext; +using grpc::Status; +using helloworld::HelloRequest; +using helloworld::HelloReply; +using helloworld::Greeter; + +class GreeterClient { + public: + GreeterClient(std::shared_ptr channel) + : stub_(Greeter::NewStub(channel)) {} + + // Assembles the client's payload, sends it and presents the response back + // from the server. + std::string SayHello(const std::string& user) { + // Data we are sending to the server. + HelloRequest request; + request.set_name(user); + + // Container for the data we expect from the server. + HelloReply reply; + + // Context for the client. It could be used to convey extra information to + // the server and/or tweak certain RPC behaviors. + ClientContext context; + + // The actual RPC. + Status status = stub_->SayHello(&context, request, &reply); + + // Act upon its status. + if (status.ok()) { + return reply.message(); + } else { + std::cout << status.error_code() << ": " << status.error_message() + << std::endl; + return "RPC failed"; + } + } + + private: + std::unique_ptr stub_; +}; + +// Logic and data behind the server's behavior. +class GreeterServiceImpl final : public Greeter::Service { + Status SayHello(ServerContext* context, const HelloRequest* request, + HelloReply* reply) override { + std::string prefix("Hello "); + reply->set_message(prefix + request->name()); + return Status::OK; + } +}; + +int main(int argc, char** argv) { + std::string server_address("127.0.0.1:0"); + GreeterServiceImpl service; + + ServerBuilder builder; + int selected_port = 0; + // Listen on the given address without any authentication mechanism. + builder.AddListeningPort(server_address, grpc::InsecureServerCredentials(), &selected_port); + // Register "service" as the instance through which we'll communicate with + // clients. In this case it corresponds to an *synchronous* service. + builder.RegisterService(&service); + + // Finally assemble the server. +#ifdef TEST_ACTUAL_SERVER + std::unique_ptr server(builder.BuildAndStart()); + std::thread serverThread([&](){ + std::cout << "Server listening on 127.0.0.1:" << selected_port << std::endl; + server->Wait(); + std::cout << "Server closed" << std::endl; + }); +#endif + + // Instantiate the client. It requires a channel, out of which the actual RPCs + // are created. This channel models a connection to an endpoint (in this case, + // localhost at the selected port). We indicate that the channel isn't + // authenticated (use of InsecureChannelCredentials()). + std::ostringstream addr; + addr << "localhost:" << selected_port; + GreeterClient greeter(grpc::CreateChannel(addr.str(), grpc::InsecureChannelCredentials())); + std::string user("world"); + std::string reply = greeter.SayHello(user); + std::cout << "Greeter received: " << reply << std::endl; + +#ifdef TEST_ACTUAL_SERVER + server->Shutdown(); + serverThread.join(); +#endif + return 0; +} diff --git a/recipes/grpc/config.yml b/recipes/grpc/config.yml index c1703a09d6e51..4d7fb36be2c32 100644 --- a/recipes/grpc/config.yml +++ b/recipes/grpc/config.yml @@ -1,5 +1,11 @@ versions: - "1.37.1": + "1.50.1": folder: "all" - "1.37.0": + "1.50.0": + folder: "all" + "1.48.0": + folder: "all" + "1.47.1": + folder: "all" + "1.46.3": folder: "all" diff --git a/recipes/gsl-lite/all/conandata.yml b/recipes/gsl-lite/all/conandata.yml index 91ac109a23203..010ad6b469c3c 100644 --- a/recipes/gsl-lite/all/conandata.yml +++ b/recipes/gsl-lite/all/conandata.yml @@ -1,16 +1,22 @@ sources: - "0.34.0": - sha256: 44255fd8aab1780773a5a2a16703c9c5a95f8c944d95caa7c468b229c0fcd1ff - url: https://github.com/martinmoene/gsl-lite/archive/v0.34.0.zip - "0.36.0": - sha256: ab1bb560611dcf9cef2265b8e40e59689bb4af1fd64914aa4a8eff945dd75057 - url: https://github.com/martinmoene/gsl-lite/archive/v0.36.0.zip - "0.37.0": - sha256: 980c8e91dd25bfaac7bfbd7151f04027fa68ff0bf652baa11de137242641e399 - url: https://github.com/gsl-lite/gsl-lite/archive/0.37.0.zip - "0.38.0": - sha256: 03c5380b08dd57c0f3d1102a1966cf5e4ec65e72daf75608ab125276b0ae17f8 - url: https://github.com/gsl-lite/gsl-lite/archive/v0.38.0.zip + "0.40.0": + url: "https://github.com/gsl-lite/gsl-lite/archive/v0.40.0.tar.gz" + sha256: "65af4ec8a1050dac4f1ca4622881bb02a9c3978a9baec289fb56e25412d6cac7" + "0.39.0": + url: "https://github.com/gsl-lite/gsl-lite/archive/v0.39.0.tar.gz" + sha256: "f80ec07d9f4946097a1e2554e19cee4b55b70b45d59e03a7d2b7f80d71e467e9" "0.38.1": url: "https://github.com/gsl-lite/gsl-lite/archive/v0.38.1.tar.gz" sha256: "c2fa2315fff312f3897958903ed4d4e027f73fa44235459ecb467ad7b7d62b18" + "0.38.0": + url: "https://github.com/gsl-lite/gsl-lite/archive/v0.38.0.zip" + sha256: "03c5380b08dd57c0f3d1102a1966cf5e4ec65e72daf75608ab125276b0ae17f8" + "0.37.0": + url: "https://github.com/gsl-lite/gsl-lite/archive/0.37.0.zip" + sha256: "980c8e91dd25bfaac7bfbd7151f04027fa68ff0bf652baa11de137242641e399" + "0.36.0": + url: "https://github.com/martinmoene/gsl-lite/archive/v0.36.0.zip" + sha256: "ab1bb560611dcf9cef2265b8e40e59689bb4af1fd64914aa4a8eff945dd75057" + "0.34.0": + url: "https://github.com/martinmoene/gsl-lite/archive/v0.34.0.zip" + sha256: "44255fd8aab1780773a5a2a16703c9c5a95f8c944d95caa7c468b229c0fcd1ff" diff --git a/recipes/gsl-lite/all/conanfile.py b/recipes/gsl-lite/all/conanfile.py index 12de12cf0e47c..d59ea8610e6a3 100644 --- a/recipes/gsl-lite/all/conanfile.py +++ b/recipes/gsl-lite/all/conanfile.py @@ -1,18 +1,20 @@ -from conans import tools, ConanFile +from conan import ConanFile +from conan.tools.files import get, copy import os -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.47.0" + class GslLiteConan(ConanFile): name = "gsl-lite" license = "MIT" url = "https://github.com/conan-io/conan-center-index" - generators = "cmake" homepage = "https://github.com/martinmoene/gsl-lite" topics = ("GSL") description = "A single-file header-only version of ISO C++ " \ "Guideline Support Library (GSL) for C++98, C++11 and later" - no_copy_source = True + + settings = "os", "arch", "compiler", "build_type" # There are three configuration options for this GSL implementation's behavior # when pre/post conditions on the GSL types are violated: # @@ -27,9 +29,11 @@ class GslLiteConan(ConanFile): "on_contract_violation": "terminate", } + no_copy_source = True + @property def _source_subfolder(self): - return "source_subfolder" + return os.path.join(self.source_folder, "source_subfolder") @property def _contract_map(self): @@ -40,22 +44,27 @@ def _contract_map(self): } def package_id(self): - self.info.header_only() + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def package(self): - self.copy("*gsl-lite.hpp", src=self._source_subfolder) - self.copy("*LICENSE", dst="licenses", keep_path=False) + copy(self, "*gsl-lite.hpp", src=self._source_subfolder, dst=self.package_folder) + copy(self, "LICENSE", src=self._source_subfolder, dst=os.path.join(self.package_folder, "licenses")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "gsl-lite") + self.cpp_info.set_property("cmake_target_name", "gsl::gsl-lite") + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["gsllite"].defines = [self._contract_map[str(self.options.on_contract_violation)]] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "gsl-lite" self.cpp_info.filenames["cmake_find_package_multi"] = "gsl-lite" self.cpp_info.names["cmake_find_package"] = "gsl" self.cpp_info.names["cmake_find_package_multi"] = "gsl" self.cpp_info.components["gsllite"].names["cmake_find_package"] = "gsl-lite" self.cpp_info.components["gsllite"].names["cmake_find_package_multi"] = "gsl-lite" - self.cpp_info.components["gsllite"].defines = [self._contract_map[str(self.options.on_contract_violation)]] + self.cpp_info.components["gsllite"].set_property("cmake_target_name", "gsl::gsl-lite") diff --git a/recipes/gsl-lite/all/test_package/CMakeLists.txt b/recipes/gsl-lite/all/test_package/CMakeLists.txt index 4fe72430eee01..0063a1958556f 100644 --- a/recipes/gsl-lite/all/test_package/CMakeLists.txt +++ b/recipes/gsl-lite/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.15) project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(gsl-lite REQUIRED CONFIG) +find_package(gsl-lite REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} gsl::gsl-lite) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/gsl-lite/all/test_package/conanfile.py b/recipes/gsl-lite/all/test_package/conanfile.py index 7e2dfe859bb27..d60b533632ddd 100644 --- a/recipes/gsl-lite/all/test_package/conanfile.py +++ b/recipes/gsl-lite/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gsl-lite/all/test_v1_package/CMakeLists.txt b/recipes/gsl-lite/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6042a2363b626 --- /dev/null +++ b/recipes/gsl-lite/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gsl-lite REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gsl::gsl-lite) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/gsl-lite/all/test_v1_package/conanfile.py b/recipes/gsl-lite/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..db36d97f3c465 --- /dev/null +++ b/recipes/gsl-lite/all/test_v1_package/conanfile.py @@ -0,0 +1,23 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conans import CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gsl-lite/config.yml b/recipes/gsl-lite/config.yml index e5f45b1d6eb1a..d21a23d317e33 100644 --- a/recipes/gsl-lite/config.yml +++ b/recipes/gsl-lite/config.yml @@ -1,11 +1,15 @@ versions: - "0.34.0": + "0.40.0": folder: all - "0.36.0": + "0.39.0": folder: all - "0.37.0": + "0.38.1": folder: all "0.38.0": folder: all - "0.38.1": + "0.37.0": + folder: all + "0.36.0": + folder: all + "0.34.0": folder: all diff --git a/recipes/gsl/all/conandata.yml b/recipes/gsl/all/conandata.yml new file mode 100644 index 0000000000000..ae4c67c1283a1 --- /dev/null +++ b/recipes/gsl/all/conandata.yml @@ -0,0 +1,14 @@ +sources: + "2.7": + url: "https://ftp.gnu.org/gnu/gsl/gsl-2.7.tar.gz" + sha256: "efbbf3785da0e53038be7907500628b466152dbc3c173a87de1b5eba2e23602b" + "2.6": + url: "https://ftp.gnu.org/gnu/gsl/gsl-2.6.tar.gz" + sha256: "b782339fc7a38fe17689cb39966c4d821236c28018b6593ddb6fd59ee40786a8" +patches: + "2.7": + - patch_file: "patches/0001-windows-support.patch" + - patch_file: "patches/0002-export-all-gsl_-symbols.patch" + "2.6": + - patch_file: "patches/0001-windows-support.patch" + - patch_file: "patches/0002-export-all-gsl_-symbols.patch" diff --git a/recipes/gsl/all/conanfile.py b/recipes/gsl/all/conanfile.py new file mode 100644 index 0000000000000..a722ffd447fe9 --- /dev/null +++ b/recipes/gsl/all/conanfile.py @@ -0,0 +1,153 @@ +from conan import ConanFile +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, replace_in_file, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.53.0" + + +class GslConan(ConanFile): + name = "gsl" + description = "GNU Scientific Library" + homepage = "https://www.gnu.org/software/gsl" + topics = ("numerical", "math", "random", "scientific") + url = "https://github.com/conan-io/conan-center-index" + license = "GPL-3.0-or-later" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + basic_layout(self, src_folder="src") + + def build_requirements(self): + self.tool_requires("libtool/2.4.7") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + if self.settings.os == "Windows": + tc.extra_defines.extend(["HAVE_WIN_IEEE_INTERFACE", "WIN32"]) + if self.options.shared: + tc.extra_defines.append("GSL_DLL") + if self.settings.os == "Linux" and "x86" in self.settings.arch: + tc.extra_defines.append("HAVE_GNUX86_IEEE_INTERFACE") + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + if is_msvc(self): + tc.configure_args.extend([ + "ac_cv_func_memcpy=yes", + "ac_cv_func_memmove=yes", + "ac_cv_c_c99inline=no", + ]) + tc.generate() + + if is_msvc(self): + env = Environment() + compile_wrapper = unix_path(self, self._user_info_build["automake"].compile) + ar_wrapper = unix_path(self, self._user_info_build["automake"].ar_lib) + env.define("CC", f"{compile_wrapper} cl -nologo") + env.define("CXX", f"{compile_wrapper} cl -nologo") + env.define("LD", "link -nologo") + env.define("AR", f"{ar_wrapper} \"lib -nologo\"") + env.define("NM", "dumpbin -symbols") + env.define("OBJDUMP", ":") + env.define("RANLIB", ":") + env.define("STRIP", ":") + env.vars(self).save_script("conanbuild_gsl_msvc") + + def build(self): + apply_conandata_patches(self) + autotools = Autotools(self) + autotools.autoreconf() + # TODO: use fix_apple_shared_install_name() (requires conan >=1.54.0, see https://github.com/conan-io/conan/pull/12249) + replace_in_file(self, os.path.join(self.source_folder, "configure"), + "-install_name \\$rpath/", + "-install_name @rpath/") + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rm(self, "*.c", os.path.join(self.package_folder, "include", "gsl")) + rm(self, "gsl-config", os.path.join(self.package_folder, "bin")) + if is_msvc(self) and self.options.shared: + pjoin = lambda p: os.path.join(self.package_folder, "lib", p) + rename(self, pjoin("gsl.dll.lib"), pjoin("gsl.lib")) + rename(self, pjoin("gslcblas.dll.lib"), pjoin("gslcblas.lib")) + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "GSL") + self.cpp_info.set_property("cmake_target_name", "GSL::gsl") + self.cpp_info.set_property("pkg_config_name", "gsl") + + self.cpp_info.components["libgsl"].set_property("cmake_target_name", "GSL::gsl") + self.cpp_info.components["libgsl"].libs = ["gsl"] + self.cpp_info.components["libgsl"].requires = ["libgslcblas"] + + self.cpp_info.components["libgslcblas"].set_property("cmake_target_name", "GSL::gslcblas") + self.cpp_info.components["libgslcblas"].libs = ["gslcblas"] + + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.components["libgsl"].system_libs = ["m"] + self.cpp_info.components["libgslcblas"].system_libs = ["m"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "GSL" + self.cpp_info.names["cmake_find_package_multi"] = "GSL" + self.cpp_info.components["libgsl"].names["cmake_find_package"] = "gsl" + self.cpp_info.components["libgsl"].names["cmake_find_package_multi"] = "gsl" + self.cpp_info.components["libgslcblas"].names["cmake_find_package"] = "gslcblas" + self.cpp_info.components["libgslcblas"].names["cmake_find_package_multi"] = "gslcblas" + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/gsl/all/patches/0001-windows-support.patch b/recipes/gsl/all/patches/0001-windows-support.patch new file mode 100644 index 0000000000000..37c78c8b5731a --- /dev/null +++ b/recipes/gsl/all/patches/0001-windows-support.patch @@ -0,0 +1,90 @@ +From https://github.com/ampl/gsl/blob/master/ieee-utils/fp-win.c + +--- /dev/null ++++ ieee-utils/fp-win.c +@@ -0,0 +1,70 @@ ++/* fp-win.c ++ * ++ * Author: Brian Gladman ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or (at ++ * your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ */ ++ ++#include ++ ++#include ++#include ++#include ++ ++const char *fp_env_string = "round-to-nearest,double-precision,mask-all"; ++ ++int ++gsl_ieee_set_mode (int precision, int rounding, int exception_mask) ++{ ++ unsigned int old, mode = _DN_SAVE, mask = _MCW_DN | _MCW_RC | _MCW_EM; ++ ++ switch(precision) ++ { ++ case GSL_IEEE_SINGLE_PRECISION: mode |= _PC_24; break; ++ case GSL_IEEE_EXTENDED_PRECISION: mode |= _PC_64; break; ++ case GSL_IEEE_DOUBLE_PRECISION: ++ default: mode |= _PC_53; ++ } ++#ifndef _M_AMD64 ++ mask |= _MCW_PC; ++#endif ++ ++ switch(rounding) ++ { ++ case GSL_IEEE_ROUND_DOWN: mode |= _RC_DOWN; break; ++ case GSL_IEEE_ROUND_UP: mode |= _RC_UP; break; ++ case GSL_IEEE_ROUND_TO_ZERO: mode |= _RC_CHOP; break; ++ case GSL_IEEE_ROUND_TO_NEAREST: ++ default: mode |= _RC_NEAR; ++ } ++ ++ if(exception_mask & GSL_IEEE_MASK_INVALID) ++ mode |= _EM_INVALID; ++ if(exception_mask & GSL_IEEE_MASK_DENORMALIZED) ++ mode |= _EM_DENORMAL; ++ if(exception_mask & GSL_IEEE_MASK_DIVISION_BY_ZERO) ++ mode |= _EM_ZERODIVIDE; ++ if(exception_mask & GSL_IEEE_MASK_OVERFLOW) ++ mode |= _EM_OVERFLOW; ++ if(exception_mask & GSL_IEEE_MASK_UNDERFLOW) ++ mode |= _EM_UNDERFLOW; ++ if(exception_mask & GSL_IEEE_TRAP_INEXACT) ++ mode &= ~_EM_INEXACT; ++ else ++ mode |= _EM_INEXACT; ++ ++ _controlfp_s( &old, mode, mask); ++ return GSL_SUCCESS; ++} +--- ieee-utils/fp.c ++++ ieee-utils/fp.c +@@ -26,8 +26,10 @@ + #include "fp-freebsd.c" + #elif HAVE_OS2EMX_IEEE_INTERFACE + #include "fp-os2emx.c" +-#elif HAVE_NETBSD_IEEE_INTERFACE +-#include "fp-netbsd.c" ++#elif HAVE_WIN_IEEE_INTERFACE ++#include "fp-win.c" ++#elif HAVE_OPENBSD_IEEE_INTERFACE ++#include "fp-openbsd.c" + #elif HAVE_OPENBSD_IEEE_INTERFACE + #include "fp-openbsd.c" + /* Try to handle universal binaries */ diff --git a/recipes/gsl/all/patches/0002-export-all-gsl_-symbols.patch b/recipes/gsl/all/patches/0002-export-all-gsl_-symbols.patch new file mode 100644 index 0000000000000..f06b70f58939f --- /dev/null +++ b/recipes/gsl/all/patches/0002-export-all-gsl_-symbols.patch @@ -0,0 +1,12 @@ +Fixes building a shared library with mingw@Windows +--- Makefile.am ++++ Makefile.am +@@ -20,7 +20,7 @@ + lib_LTLIBRARIES = libgsl.la + libgsl_la_SOURCES = version.c + libgsl_la_LIBADD = $(GSL_LIBADD) $(SUBLIBS) +-libgsl_la_LDFLAGS = $(GSL_LDFLAGS) -version-info $(GSL_LT_VERSION) ++libgsl_la_LDFLAGS = $(GSL_LDFLAGS) -version-info $(GSL_LT_VERSION) -export-symbols-regex '^gsl_' + noinst_HEADERS = templates_on.h templates_off.h build.h + + m4datadir = $(datadir)/aclocal diff --git a/recipes/gsl/all/test_package/CMakeLists.txt b/recipes/gsl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..808366bc0e673 --- /dev/null +++ b/recipes/gsl/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(GSL REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE GSL::gsl) diff --git a/recipes/gsl/all/test_package/conanfile.py b/recipes/gsl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/gsl/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gsl/all/test_package/test_package.c b/recipes/gsl/all/test_package/test_package.c new file mode 100644 index 0000000000000..f0b03b16cad40 --- /dev/null +++ b/recipes/gsl/all/test_package/test_package.c @@ -0,0 +1,14 @@ +#include +#include + +/** + * The example program from the GSL documentation + * http://www.gnu.org/software/gsl/doc/html/usage.html#an-example-program + */ + +int main() { + double x = 5.0; + double y = gsl_sf_bessel_J0 (x); + printf ("J0(%g) = %.18e\n", x, y); + return 0; +} diff --git a/recipes/gsl/all/test_v1_package/CMakeLists.txt b/recipes/gsl/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/gsl/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/gsl/all/test_v1_package/conanfile.py b/recipes/gsl/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/gsl/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gsl/config.yml b/recipes/gsl/config.yml new file mode 100644 index 0000000000000..15814520e1bfd --- /dev/null +++ b/recipes/gsl/config.yml @@ -0,0 +1,5 @@ +versions: + "2.7": + folder: all + "2.6": + folder: all diff --git a/recipes/gsoap/all/CMakeLists.txt b/recipes/gsoap/all/CMakeLists.txt index e27ef444fdb05..ff37f753a87ae 100644 --- a/recipes/gsoap/all/CMakeLists.txt +++ b/recipes/gsoap/all/CMakeLists.txt @@ -1,29 +1,29 @@ cmake_minimum_required(VERSION 3.0) project(gSOAP) +include(GNUInstallDirs) + option(BUILD_TOOLS "Build soapcpp2 and wsdl2h" ON) option(BUILD_GSOAP "Build gsoap library" ON) -if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") - include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -else() - include(conanbuildinfo.cmake) -endif() -conan_basic_setup() - message("Generate gSOAP from sources at ${GSOAP_PATH}") +if(${WITH_OPENSSL}) + find_package(OpenSSL REQUIRED) + find_package(ZLIB REQUIRED) +endif() + # Tools if(${BUILD_TOOLS}) - include(${CMAKE_SOURCE_DIR}/src/soapcpp2.cmake) - include(${CMAKE_SOURCE_DIR}/src/wsdl2h.cmake) + include(${PROJECT_SOURCE_DIR}/cmake/soapcpp2.cmake) + include(${PROJECT_SOURCE_DIR}/cmake/wsdl2h.cmake) - install(FILES ${CMAKE_SOURCE_DIR}/${GSOAP_PATH}/gsoap/typemap.dat DESTINATION res) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/${GSOAP_PATH}/gsoap/import DESTINATION . + install(FILES ${GSOAP_PATH}/gsoap/typemap.dat DESTINATION res) + install(DIRECTORY ${GSOAP_PATH}/gsoap/import DESTINATION ${CMAKE_INSTALL_BINDIR} FILES_MATCHING PATTERN "*.h") endif() # Libraries if(${BUILD_GSOAP}) - include(${CMAKE_SOURCE_DIR}/src/gsoap.cmake) + include(${PROJECT_SOURCE_DIR}/cmake/gsoap.cmake) endif() diff --git a/recipes/gsoap/all/cmake/gsoap.cmake b/recipes/gsoap/all/cmake/gsoap.cmake new file mode 100644 index 0000000000000..c42821ef6f350 --- /dev/null +++ b/recipes/gsoap/all/cmake/gsoap.cmake @@ -0,0 +1,71 @@ + +# Generate requested libraries: +# - gsoap +# - gsoap++ +# - gsoapssl +# - gsoapssl++ + + +# C library +set(SRCS_GSOAP_C + ${GSOAP_PATH}/gsoap/stdsoap2.c + ${GSOAP_PATH}/gsoap/dom.c +) +set_source_files_properties(${SRCS_GSOAP_C} PROPERTIES LANGUAGE C) +add_library(gsoap ${SRCS_GSOAP_C} ${GSOAP_PATH}/gsoap/stdsoap2.h) +set_target_properties(gsoap PROPERTIES + PUBLIC_HEADER ${GSOAP_PATH}/gsoap/stdsoap2.h + DEFINE_SYMBOL "SOAP_STD_EXPORTS" + LINKER_LANGUAGE C + ) +install(TARGETS gsoap + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) + + +# CXX library +set(SRCS_GSOAP_CXX + ${GSOAP_PATH}/gsoap/stdsoap2.cpp + ${GSOAP_PATH}/gsoap/dom.cpp +) +set_source_files_properties(${SRCS_GSOAP_CXX} PROPERTIES LANGUAGE CXX) +add_library(gsoap++ ${SRCS_GSOAP_CXX} ${GSOAP_PATH}/gsoap/stdsoap2.h) +set_target_properties(gsoap++ PROPERTIES + PUBLIC_HEADER ${GSOAP_PATH}/gsoap/stdsoap2.h + DEFINE_SYMBOL "SOAP_STD_EXPORTS" + LINKER_LANGUAGE CXX + ) +install(TARGETS gsoap++ + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) + +# Add SSL if requested +if(${WITH_OPENSSL}) + target_include_directories(gsoap PRIVATE ${GSOAP_PATH}/gsoap/plugin) + target_compile_definitions(gsoap PUBLIC WITH_OPENSSL WITH_GZIP) + set_target_properties(gsoap PROPERTIES OUTPUT_NAME gsoapssl) + target_link_libraries(gsoap PUBLIC OpenSSL::Crypto OpenSSL::SSL ZLIB::ZLIB) + + target_include_directories(gsoap++ PRIVATE ${GSOAP_PATH}/gsoap/plugin) + target_compile_definitions(gsoap++ PUBLIC WITH_OPENSSL WITH_GZIP) + set_target_properties(gsoap++ PROPERTIES OUTPUT_NAME gsoapssl++) + target_link_libraries(gsoap++ PUBLIC OpenSSL::Crypto OpenSSL::SSL ZLIB::ZLIB) +endif() +if(${WITH_IPV6}) + target_compile_definitions(gsoap PUBLIC WITH_IPV6) + target_compile_definitions(gsoap++ PUBLIC WITH_IPV6) +endif() +if(${WITH_COOKIES}) + target_compile_definitions(gsoap PUBLIC WITH_COOKIES) + target_compile_definitions(gsoap++ PUBLIC WITH_COOKIES) +endif() +if(${WITH_C_LOCALE}) + target_compile_definitions(gsoap PUBLIC WITH_C_LOCALE) + target_compile_definitions(gsoap++ PUBLIC WITH_C_LOCALE) +endif() diff --git a/recipes/gsoap/all/cmake/soapcpp2.cmake b/recipes/gsoap/all/cmake/soapcpp2.cmake new file mode 100644 index 0000000000000..c625c2461a633 --- /dev/null +++ b/recipes/gsoap/all/cmake/soapcpp2.cmake @@ -0,0 +1,65 @@ + +# Generate project for soapcpp2 executable + +set(STDCPP2_PATH ${GSOAP_PATH}/gsoap/src) + +set(SRC_CPP + ${STDCPP2_PATH}/symbol2.c + ${STDCPP2_PATH}/error2.c + ${STDCPP2_PATH}/init2.c + ${STDCPP2_PATH}/soapcpp2.c + ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c + ${CMAKE_BINARY_DIR}/generated/lex.yy.c + ) +set_source_files_properties(${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c PROPERTIES GENERATED TRUE) +set_source_files_properties(${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.h PROPERTIES GENERATED TRUE) +set_source_files_properties(${CMAKE_BINARY_DIR}/generated/lex.yy.c PROPERTIES GENERATED TRUE) + +# Create the generated folder +add_custom_target(create-generated-folder ALL + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/generated) + +if(WIN32) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c + COMMAND win_bison.exe -d -v -o ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c ${STDCPP2_PATH}/soapcpp2_yacc.y + COMMENT "Run BISON on soapcpp2" + ) + + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/generated/lex.yy.c + COMMAND win_flex.exe -o ${CMAKE_BINARY_DIR}/generated/lex.yy.c ${STDCPP2_PATH}/soapcpp2_lex.l + COMMENT "Run FLEX on soapcpp2" + ) + +else() + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c + COMMAND yacc -d -v -o ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c ${STDCPP2_PATH}/soapcpp2_yacc.y + COMMENT "Run YACC on soapcpp2" + ) + + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/generated/lex.yy.c + COMMAND flex -o ${CMAKE_BINARY_DIR}/generated/lex.yy.c ${STDCPP2_PATH}/soapcpp2_lex.l + COMMENT "Run FLEX on soapcpp2" + ) +endif() + +add_custom_target(FLEXBISON_GENERATORS + DEPENDS + ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c + ${CMAKE_BINARY_DIR}/generated/lex.yy.c) + + +add_dependencies(FLEXBISON_GENERATORS create-generated-folder) + +add_executable(soapcpp2 ${SRC_CPP}) +if(${WITH_OPENSSL}) + target_compile_definitions(soapcpp2 PUBLIC WITH_OPENSSL WITH_GZIP) + target_link_libraries(soapcpp2 PUBLIC OpenSSL::Crypto OpenSSL::SSL ZLIB::ZLIB) +endif() +target_include_directories(soapcpp2 PRIVATE ${STDCPP2_PATH}) +set_source_files_properties(${SRC_CPP} PROPERTIES LANGUAGE C) +add_dependencies(soapcpp2 FLEXBISON_GENERATORS) +install(TARGETS soapcpp2 DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/recipes/gsoap/all/cmake/wsdl2h.cmake b/recipes/gsoap/all/cmake/wsdl2h.cmake new file mode 100644 index 0000000000000..2165d031400e0 --- /dev/null +++ b/recipes/gsoap/all/cmake/wsdl2h.cmake @@ -0,0 +1,64 @@ + +# Generate project for wsdl2h + +set(WSDL2H_PATH ${GSOAP_PATH}/gsoap/wsdl) + +set(SRC_CPP + ${WSDL2H_PATH}/wsdl2h.cpp + ${WSDL2H_PATH}/wsdl.cpp + ${WSDL2H_PATH}/wadl.cpp + ${WSDL2H_PATH}/schema.cpp + ${WSDL2H_PATH}/soap.cpp + ${WSDL2H_PATH}/mime.cpp + ${WSDL2H_PATH}/wsp.cpp + ${WSDL2H_PATH}/bpel.cpp + ${WSDL2H_PATH}/types.cpp + ${WSDL2H_PATH}/service.cpp + ${WSDL2H_PATH}/../stdsoap2.cpp + ${CMAKE_BINARY_DIR}/generated/wsdlC.cpp + ) + +if(${WITH_OPENSSL}) + list(APPEND SRC_CPP + ${GSOAP_PATH}/gsoap/plugin/httpda.c + ${GSOAP_PATH}/gsoap/plugin/smdevp.c + ${GSOAP_PATH}/gsoap/plugin/threads.c + ) +endif() + +set_source_files_properties(${SRC_CPP} PROPERTIES LANGUAGE CXX) +set_source_files_properties(${CMAKE_BINARY_DIR}/generated/wsdlC.cpp PROPERTIES GENERATED TRUE) + +# Search for soapcpp2 executable +if(CMAKE_CROSSCOMPILING) + find_program(SOAPCPP2_PROGRAM soapcpp2 PATHS ENV PATH NO_DEFAULT_PATH) +endif() +if(NOT SOAPCPP2_PROGRAM) + set(SOAPCPP2_PROGRAM $) +endif() + +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/generated/wsdlC.cpp + COMMAND ${SOAPCPP2_PROGRAM} -I${GSOAP_PATH}/gsoap/import -SC -pwsdl -d${CMAKE_BINARY_DIR}/generated ${WSDL2H_PATH}/wsdl.h + COMMENT "Parsing WSDL and Schema definitions" + WORKING_DIRECTORY ${WSDL2H_PATH} + ) + +add_custom_target(WSDL2H_GENERATORS + DEPENDS + ${CMAKE_BINARY_DIR}/generated/wsdlC.cpp) + +add_executable(wsdl2h ${SRC_CPP}) +target_include_directories(wsdl2h + PRIVATE ${GSOAP_PATH}/gsoap + PRIVATE ${CMAKE_BINARY_DIR}/generated + PRIVATE ${WSDL2H_PATH}) +add_dependencies(wsdl2h WSDL2H_GENERATORS) +if(${WITH_OPENSSL}) + find_package(ZLIB REQUIRED) + target_include_directories(wsdl2h PRIVATE ${GSOAP_PATH}/gsoap/plugin) + target_compile_definitions(wsdl2h PRIVATE WITH_OPENSSL WITH_GZIP) + target_link_libraries(wsdl2h OpenSSL::Crypto OpenSSL::SSL ZLIB::ZLIB) +endif() + +install(TARGETS wsdl2h DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/recipes/gsoap/all/conandata.yml b/recipes/gsoap/all/conandata.yml index 1d468f628b6d8..4a616af7b7a29 100644 --- a/recipes/gsoap/all/conandata.yml +++ b/recipes/gsoap/all/conandata.yml @@ -1,13 +1,21 @@ sources: - "2.8.103": - sha256: "7ddafb1aa016bf5cedde689267b4149f68a48ee848f712bbda92947cecf6d6c4" - url: "https://github.com/conan-io/cci-sources-backup/raw/main/gsoap/gsoap2-code-r186.zip" - "2.8.104": - sha256: "2ed385f2aeb753f0a17007f0e6fdb08770185ad7cd2f531ae051cc322411abcc" - url: "https://github.com/conan-io/cci-sources-backup/raw/main/gsoap/gsoap2-code-r187.zip" - "2.8.105": - sha256: "c60b973a1c23574ca673da86f018bd36b38fc810f1fa23b0fae2430889c9be4c" - url: "https://github.com/conan-io/cci-sources-backup/raw/main/gsoap/gsoap2-code-r188.zip" - "2.8.106": - sha256: "be001b765be9ad2ad0a560d64d84ae10a30a961a2904bfe86f9f57f49a5555d7" - url: "https://github.com/conan-io/cci-sources-backup/raw/main/gsoap/gsoap2-code-r189.zip" + "2.8.117": + url: + - "https://sourceforge.net/projects/gsoap2/files/gsoap_2.8.117.zip/download" + - "https://c3i.jfrog.io/artifactory/cci-sources-backup/sources/gsoap/gsoap_2.8.117.zip" + sha256: "7cadf8808cfd982629948fe09e4fa6cd18e23cafd40df0aaaff1b1f5b695c442" + "2.8.116": + url: + - "https://sourceforge.net/projects/gsoap2/files/gsoap_2.8.116.zip/download" + - "https://c3i.jfrog.io/artifactory/cci-sources-backup/sources/gsoap/gsoap_2.8.116.zip" + sha256: "2a41e42aaddbcd603b99004af95bb83559dbd4fd2d842920f003d24867599192" + "2.8.115": + url: + - "https://sourceforge.net/projects/gsoap2/files/gsoap_2.8.115.zip/download" + - "https://c3i.jfrog.io/artifactory/cci-sources-backup/sources/gsoap/gsoap_2.8.115.zip" + sha256: "6f6813b189d201022254a2879cc8ee005bdb1bcf126bc03238710f19ec4e7268" + "2.8.114": + url: + - "https://sourceforge.net/projects/gsoap2/files/gsoap_2.8.114.zip/download" + - "https://c3i.jfrog.io/artifactory/cci-sources-backup/sources/gsoap/gsoap_2.8.114.zip" + sha256: "aa70a999258100c170a3f8750c1f91318a477d440f6a28117f68bc1ded32327f" diff --git a/recipes/gsoap/all/conanfile.py b/recipes/gsoap/all/conanfile.py index b0beeeb45fa81..49ca4cbe85bbd 100644 --- a/recipes/gsoap/all/conanfile.py +++ b/recipes/gsoap/all/conanfile.py @@ -1,72 +1,97 @@ -from conans import ConanFile, CMake, tools -import os, shutil +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get +from conan.tools.microsoft import is_msvc +import os +required_conan_version = ">=1.52.0" -class ConanFileDefault(ConanFile): + +class GsoapConan(ConanFile): name = "gsoap" description = "The gSOAP toolkit is a C and C++ software development toolkit for SOAP and " \ "REST XML Web services and generic C/C++ XML data bindings." - topics = ("conan", "gsoap", "logging") + license = ("gSOAP-1.3b", "GPL-2.0-or-later") url = "https://github.com/conan-io/conan-center-index" homepage = "https://sourceforge.net/projects/gsoap2" - license = ("gSOAP-1.3b", "GPL-2.0-or-later") - exports_sources = ["CMakeLists.txt", "src/*.cmake", "src/*.txt"] - generators = "cmake" - short_paths = True + topics = ("gsoap", "logging") + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + "with_openssl": [True, False], + "with_ipv6": [True, False], + "with_cookies": [True, False], + "with_c_locale": [True, False], + } + default_options = { + "fPIC": True, + "with_openssl": True, + "with_ipv6": True, + "with_cookies": True, + "with_c_locale": True, + } - _cmake = None + exports_sources = "CMakeLists.txt", "cmake/*.cmake" + short_paths = True @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) - @property - def _build_subfolder(self): - return "build_subfolder" + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC - settings = "os", "arch", "compiler", "build_type" - options = {"with_openssl": [True, False], - "with_ipv6": [True, False], - "with_cookies": [True, False], - "with_c_locale": [True, False]} - default_options = { - 'with_openssl': True, - 'with_ipv6': True, - 'with_cookies': True, - 'with_c_locale': True} + def layout(self): + cmake_layout(self, src_folder="src") + def requirements(self): + if self.options.with_openssl: + self.requires("openssl/1.1.1s") + self.requires("zlib/1.2.13") + + def build_requirements(self): + if cross_building(self, skip_x64_x86=True) and hasattr(self, "settings_build"): + self.tool_requires(f"gsoap/{self.version}") + + if is_msvc(self, build_context=True): + self.tool_requires("winflexbison/2.5.24") + else: + self.tool_requires("bison/3.7.6") + self.tool_requires("flex/2.6.4") def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + toolchain = CMakeToolchain(self) + toolchain.variables["GSOAP_PATH"] = self.source_folder.replace("\\", "/") + toolchain.variables["BUILD_TOOLS"] = True + toolchain.variables["WITH_OPENSSL"] = self.options.with_openssl + toolchain.variables["WITH_IPV6"] = self.options.with_ipv6 + toolchain.variables["WITH_COOKIES"] = self.options.with_cookies + toolchain.variables["WITH_C_LOCALE"] = self.options.with_c_locale + toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + ms = VirtualBuildEnv(self) + ms.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() - def build_requirements(self): - if tools.os_info.is_windows: - self.build_requires("winflexbison/2.5.22") - else: - self.build_requires("bison/3.5.3") - self.build_requires("flex/2.6.4") - - def requirements(self): - if self.options.with_openssl: - self.requires("openssl/1.1.1h") - self.requires("zlib/1.2.11") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["GSOAP_PATH"] = self._source_subfolder - self._cmake.definitions["BUILD_TOOLS"] = True - self._cmake.definitions["WITH_OPENSSL"] = self.options.with_openssl - self._cmake.definitions["WITH_IPV6"] = self.options.with_ipv6 - self._cmake.definitions["WITH_COOKIES"] = self.options.with_cookies - self._cmake.definitions["WITH_C_LOCALE"] = self.options.with_c_locale - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def package(self): + copy(self, "GPLv2_license.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() def package_info(self): defines = [] @@ -85,10 +110,3 @@ def package_info(self): if self.options.with_c_locale: defines.append("WITH_C_LOCALE") self.cpp_info.defines = defines - - def package(self): - self.copy(pattern="GPLv2_license.txt", dst="licenses", src=self._source_subfolder) - self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() - cmake.install() - shutil.move(os.path.join(self.package_folder, 'import'), os.path.join(self.package_folder, 'bin', 'import')) diff --git a/recipes/gsoap/all/src/gsoap.cmake b/recipes/gsoap/all/src/gsoap.cmake deleted file mode 100644 index 4a3bf38834072..0000000000000 --- a/recipes/gsoap/all/src/gsoap.cmake +++ /dev/null @@ -1,74 +0,0 @@ - -# Generate requested libraries: -# - gsoap -# - gsoap++ -# - gsoapssl -# - gsoapssl++ - - -# C library -set(SRCS_GSOAP_C - ${GSOAP_PATH}/gsoap/stdsoap2.c - ${GSOAP_PATH}/gsoap/dom.c -) -set_source_files_properties(${SRCS_GSOAP_C} PROPERTIES LANGUAGE C) -add_library(gsoap ${SRCS_GSOAP_C} ${GSOAP_PATH}/gsoap/stdsoap2.h) -set_target_properties(gsoap PROPERTIES - COMPILE_PDB_OUTPUT_DIRECTORY bin - PDB_OUTPUT_DIRECTORY bin - PUBLIC_HEADER ${GSOAP_PATH}/gsoap/stdsoap2.h - LINKER_LANGUAGE C - ) -install(TARGETS gsoap - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - PUBLIC_HEADER DESTINATION include - ) - - -# CXX library -set(SRCS_GSOAP_CXX - ${GSOAP_PATH}/gsoap/stdsoap2.cpp - ${GSOAP_PATH}/gsoap/dom.cpp -) -set_source_files_properties(${SRCS_GSOAP_CXX} PROPERTIES LANGUAGE CXX) -add_library(gsoap++ ${SRCS_GSOAP_CXX} ${GSOAP_PATH}/gsoap/stdsoap2.h) -set_target_properties(gsoap++ PROPERTIES - COMPILE_PDB_OUTPUT_DIRECTORY bin - PDB_OUTPUT_DIRECTORY bin - PUBLIC_HEADER ${GSOAP_PATH}/gsoap/stdsoap2.h - LINKER_LANGUAGE CXX - ) -install(TARGETS gsoap++ - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - PUBLIC_HEADER DESTINATION include - ) - -# Add SSL if requested -if(${WITH_OPENSSL}) - - target_include_directories(gsoap PRIVATE ${GSOAP_PATH}/gsoap/plugin) - target_compile_definitions(gsoap PUBLIC WITH_OPENSSL WITH_GZIP) - set_target_properties(gsoap PROPERTIES OUTPUT_NAME gsoapssl) - target_link_libraries(gsoap ${CONAN_LIBS}) - - target_include_directories(gsoap++ PRIVATE ${GSOAP_PATH}/gsoap/plugin) - target_compile_definitions(gsoap++ PUBLIC WITH_OPENSSL WITH_GZIP) - set_target_properties(gsoap++ PROPERTIES OUTPUT_NAME gsoapssl++) - target_link_libraries(gsoap++ ${CONAN_LIBS}) -endif() -if(${WITH_IPV6}) - target_compile_definitions(gsoap PUBLIC WITH_IPV6) - target_compile_definitions(gsoap++ PUBLIC WITH_IPV6) -endif() -if(${WITH_COOKIES}) - target_compile_definitions(gsoap PUBLIC WITH_COOKIES) - target_compile_definitions(gsoap++ PUBLIC WITH_COOKIES) -endif() -if(${WITH_C_LOCALE}) - target_compile_definitions(gsoap PUBLIC WITH_C_LOCALE) - target_compile_definitions(gsoap++ PUBLIC WITH_C_LOCALE) -endif() diff --git a/recipes/gsoap/all/src/soapcpp2.cmake b/recipes/gsoap/all/src/soapcpp2.cmake deleted file mode 100644 index 29f6014673d14..0000000000000 --- a/recipes/gsoap/all/src/soapcpp2.cmake +++ /dev/null @@ -1,61 +0,0 @@ - -# Generate project for soapcpp2 executable - -set(STDCPP2_PATH ${CMAKE_SOURCE_DIR}/${GSOAP_PATH}/gsoap/src) - -set(SRC_CPP - ${STDCPP2_PATH}/symbol2.c - ${STDCPP2_PATH}/error2.c - ${STDCPP2_PATH}/init2.c - ${STDCPP2_PATH}/soapcpp2.c - ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c - ${CMAKE_BINARY_DIR}/generated/lex.yy.c - ) -set_source_files_properties(${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c PROPERTIES GENERATED TRUE) -set_source_files_properties(${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.h PROPERTIES GENERATED TRUE) -set_source_files_properties(${CMAKE_BINARY_DIR}/generated/lex.yy.c PROPERTIES GENERATED TRUE) - -# Create the generated folder -add_custom_target(create-generated-folder ALL - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/generated) - -if(WIN32) - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c - COMMAND ${CONAN_WINFLEXBISON_ROOT}/bin/win_bison.exe -d -v -o ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c ${STDCPP2_PATH}/soapcpp2_yacc.y - COMMENT "Run BISON on soapcpp2" - ) - - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/generated/lex.yy.c - COMMAND ${CONAN_WINFLEXBISON_ROOT}/bin/win_flex.exe -o ${CMAKE_BINARY_DIR}/generated/lex.yy.c ${STDCPP2_PATH}/soapcpp2_lex.l - COMMENT "Run FLEX on soapcpp2" - ) - -else() - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c - COMMAND ${CONAN_BISON_ROOT}/bin/yacc -d -v -o ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c ${STDCPP2_PATH}/soapcpp2_yacc.y - COMMENT "Run YACC on soapcpp2" - ) - - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/generated/lex.yy.c - COMMAND ${CONAN_FLEX_ROOT}/bin/flex -o ${CMAKE_BINARY_DIR}/generated/lex.yy.c ${STDCPP2_PATH}/soapcpp2_lex.l - COMMENT "Run FLEX on soapcpp2" - ) -endif() - -add_custom_target(FLEXBISON_GENERATORS - DEPENDS - ${CMAKE_BINARY_DIR}/generated/soapcpp2_yacc.tab.c - ${CMAKE_BINARY_DIR}/generated/lex.yy.c) - - -add_dependencies(FLEXBISON_GENERATORS create-generated-folder) - -add_executable(soapcpp2 ${SRC_CPP}) -target_include_directories(soapcpp2 PRIVATE ${STDCPP2_PATH}) -set_source_files_properties(${SRC_CPP} PROPERTIES LANGUAGE C) -add_dependencies(soapcpp2 FLEXBISON_GENERATORS) -install(TARGETS soapcpp2 RUNTIME DESTINATION bin) diff --git a/recipes/gsoap/all/src/wsdl2h.cmake b/recipes/gsoap/all/src/wsdl2h.cmake deleted file mode 100644 index 7dcd71312a08c..0000000000000 --- a/recipes/gsoap/all/src/wsdl2h.cmake +++ /dev/null @@ -1,55 +0,0 @@ - -# Generate project for wsdl2h - -set(WSDL2H_PATH ${CMAKE_SOURCE_DIR}/${GSOAP_PATH}/gsoap/wsdl) - -set(SRC_CPP - ${WSDL2H_PATH}/wsdl2h.cpp - ${WSDL2H_PATH}/wsdl.cpp - ${WSDL2H_PATH}/wadl.cpp - ${WSDL2H_PATH}/schema.cpp - ${WSDL2H_PATH}/soap.cpp - ${WSDL2H_PATH}/mime.cpp - ${WSDL2H_PATH}/wsp.cpp - ${WSDL2H_PATH}/bpel.cpp - ${WSDL2H_PATH}/types.cpp - ${WSDL2H_PATH}/service.cpp - ${WSDL2H_PATH}/../stdsoap2.cpp - ${CMAKE_BINARY_DIR}/generated/wsdlC.cpp - ) - -if(${WITH_OPENSSL}) - list(APPEND SRC_CPP - ${GSOAP_PATH}/gsoap/plugin/httpda.c - ${GSOAP_PATH}/gsoap/plugin/smdevp.c - ${GSOAP_PATH}/gsoap/plugin/threads.c - ) -endif() - -set_source_files_properties(${SRC_CPP} PROPERTIES LANGUAGE CXX) -set_source_files_properties(${CMAKE_BINARY_DIR}/generated/wsdlC.cpp PROPERTIES GENERATED TRUE) - -add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/generated/wsdlC.cpp - COMMAND $ -I${GSOAP_PATH}/gsoap/import -SC -pwsdl -d${CMAKE_BINARY_DIR}/generated ${WSDL2H_PATH}/wsdl.h - COMMENT "Parsing WSDL and Schema definitions" - WORKING_DIRECTORY ${WSDL2H_PATH} - ) - -add_custom_target(WSDL2H_GENERATORS - DEPENDS - ${CMAKE_BINARY_DIR}/generated/wsdlC.cpp) - -add_executable(wsdl2h ${SRC_CPP}) -target_include_directories(wsdl2h - PRIVATE ${GSOAP_PATH}/gsoap - PRIVATE ${CMAKE_BINARY_DIR}/generated - PRIVATE ${WSDL2H_PATH}) -add_dependencies(wsdl2h WSDL2H_GENERATORS) -if(${WITH_OPENSSL}) - target_include_directories(wsdl2h PRIVATE ${GSOAP_PATH}/gsoap/plugin) - target_compile_definitions(wsdl2h PRIVATE WITH_OPENSSL WITH_GZIP) - target_link_libraries(wsdl2h ${CONAN_LIBS}) -endif() - -install(TARGETS wsdl2h RUNTIME DESTINATION bin) diff --git a/recipes/gsoap/all/test_package/CMakeLists.txt b/recipes/gsoap/all/test_package/CMakeLists.txt index 4722f48984645..1464ab750d83b 100644 --- a/recipes/gsoap/all/test_package/CMakeLists.txt +++ b/recipes/gsoap/all/test_package/CMakeLists.txt @@ -1,14 +1,12 @@ -cmake_minimum_required(VERSION 3.0) -project(gsoap_example CXX) +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +find_package(gsoap REQUIRED CONFIG) add_executable(${PROJECT_NAME} - example.cpp - ${CMAKE_BINARY_DIR}/soapC.cpp - ${CMAKE_BINARY_DIR}/soapcalcProxy.cpp) - -target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR} ${GSOAP_INCLUDE_DIR}) - -target_link_libraries(${PROJECT_NAME} CONAN_PKG::gsoap) + test_package.cpp + ${CMAKE_BINARY_DIR}/soapC.cpp + ${CMAKE_BINARY_DIR}/soapcalcProxy.cpp +) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}) +target_link_libraries(${PROJECT_NAME} PRIVATE gsoap::gsoap) diff --git a/recipes/gsoap/all/test_package/conanfile.py b/recipes/gsoap/all/test_package/conanfile.py index 658d2370d13f9..b6f1a8aefca6f 100644 --- a/recipes/gsoap/all/test_package/conanfile.py +++ b/recipes/gsoap/all/test_package/conanfile.py @@ -1,20 +1,35 @@ +from conan import ConanFile +from conan.tools.build import can_run, cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools + class TestGsoapConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): - calc_wsdl = os.path.join(os.path.dirname(__file__), 'calc.wsdl') - self.run("wsdl2h -o calc.h {}".format(calc_wsdl), run_environment=True) - self.run("soapcpp2 -j -CL -I{} calc.h".format(os.path.join(self.deps_cpp_info["gsoap"].rootpath, 'bin', 'import')), run_environment=True) + # TODO: Add some test for the cross-building scenario + + if not cross_building(self): + calc_wsdl = os.path.join(self.source_folder, "calc.wsdl") + self.output.info(f"Generating code from WSDL '{calc_wsdl}'") + self.run(f"wsdl2h -o calc.h {calc_wsdl}", env="conanrun") + import_dir = os.path.join(self.deps_cpp_info["gsoap"].rootpath, "bin", "import") + self.run(f"soapcpp2 -j -CL -I{import_dir} calc.h", env="conanrun") - cmake = CMake(self) - cmake.configure() - cmake.build() + cmake = CMake(self) + cmake.configure() + cmake.build() def test(self): - if not tools.cross_building(self.settings, skip_x64_x86=True): - bin_path = os.path.join("bin", "gsoap_example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gsoap/all/test_package/example.cpp b/recipes/gsoap/all/test_package/example.cpp deleted file mode 100644 index c4c654374a074..0000000000000 --- a/recipes/gsoap/all/test_package/example.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -#include "calc.nsmap" // XML namespace mapping table (only needed once at the global level) -#include "soapcalcProxy.h" // the proxy class, also #includes "soapH.h" and "soapStub.h" -#include - -int main() -{ - calcProxy calc; - double sum; - if (calc.add(1.23, 4.56, sum) == SOAP_OK) - { - std::cout << "Sum = " << sum << std::endl; - } - else - { - calc.soap_stream_fault(std::cerr); - } - calc.destroy(); // same as: soap_destroy(calc.soap); soap_end(calc.soap); -} diff --git a/recipes/gsoap/all/test_package/test_package.cpp b/recipes/gsoap/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..bf5391ec2d579 --- /dev/null +++ b/recipes/gsoap/all/test_package/test_package.cpp @@ -0,0 +1,20 @@ + +#include "calc.nsmap" // XML namespace mapping table (only needed once at the global level) +#include "soapcalcProxy.h" // the proxy class, also #includes "soapH.h" and "soapStub.h" +#include + +int main() +{ + calcProxy calc; + double sum; + if (calc.add(1.23, 4.56, sum) == SOAP_OK) + { + std::cout << "Sum = " << sum << std::endl; + } + else + { + std::cout << "Cannot sum" << std::endl; + calc.soap_stream_fault(std::cerr); + } + calc.destroy(); // same as: soap_destroy(calc.soap); soap_end(calc.soap); +} diff --git a/recipes/gsoap/all/test_v1_package/CMakeLists.txt b/recipes/gsoap/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/gsoap/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/gsoap/all/test_v1_package/conanfile.py b/recipes/gsoap/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..efaa7d687c237 --- /dev/null +++ b/recipes/gsoap/all/test_v1_package/conanfile.py @@ -0,0 +1,26 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + # TODO: Add some test for the cross-building scenario + + if not tools.cross_building(self): + calc_wsdl = os.path.join(self.source_folder, os.pardir, "test_package", "calc.wsdl") + self.output.info(f"Generating code from WSDL '{calc_wsdl}'") + self.run(f"wsdl2h -o calc.h {calc_wsdl}", run_environment=True) + import_dir = os.path.join(self.deps_cpp_info["gsoap"].rootpath, "bin", "import") + self.run(f"soapcpp2 -j -CL -I{import_dir} calc.h", run_environment=True) + + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gsoap/config.yml b/recipes/gsoap/config.yml index 707bf566b1b76..01534d05392ba 100644 --- a/recipes/gsoap/config.yml +++ b/recipes/gsoap/config.yml @@ -1,9 +1,9 @@ versions: - "2.8.103": + "2.8.117": folder: all - "2.8.104": + "2.8.116": folder: all - "2.8.105": + "2.8.115": folder: all - "2.8.106": + "2.8.114": folder: all diff --git a/recipes/gst-libav/all/conandata.yml b/recipes/gst-libav/all/conandata.yml new file mode 100644 index 0000000000000..a62d1f5aa8b77 --- /dev/null +++ b/recipes/gst-libav/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.19.1": + url: "https://gitlab.freedesktop.org/gstreamer/gst-libav/-/archive/1.19.1/gst-libav-1.19.1.tar.bz2" + sha256 : "771b55f9de7f81153b12c0d2d562e82d4119fcb6e5983bcf51c872dfbe2f5edc" diff --git a/recipes/gst-libav/all/conanfile.py b/recipes/gst-libav/all/conanfile.py new file mode 100644 index 0000000000000..04e247c12ac12 --- /dev/null +++ b/recipes/gst-libav/all/conanfile.py @@ -0,0 +1,170 @@ +from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment +from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import msvc_runtime_flag +import glob +import os +import shutil + + +class GStLibAVConan(ConanFile): + name = "gst-libav" + description = "GStreamer is a development framework for creating applications like media players, video editors, " \ + "streaming media broadcasters and so on" + topics = ("gstreamer", "multimedia", "video", "audio", "broadcasting", "framework", "media") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gstreamer.freedesktop.org/" + license = "GPL-2.0-only" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_introspection": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_introspection": False, + } + _source_subfolder = "source_subfolder" + _build_subfolder = "build_subfolder" + exports_sources = ["patches/*.patch"] + + generators = "pkg_config" + + @property + def _is_msvc(self): + return self.settings.compiler == "Visual Studio" + + def validate(self): + if self.options.shared != self.options["gstreamer"].shared or \ + self.options.shared != self.options["glib"].shared or \ + self.options.shared != self.options["gst-plugins-base"].shared: + # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/133 + raise ConanInvalidConfiguration("GLib, GStreamer and GstPlugins must be either all shared, or all static") + if tools.Version(self.version) >= "1.18.2" and\ + self.settings.compiler == "gcc" and\ + tools.Version(self.settings.compiler.version) < "5": + raise ConanInvalidConfiguration( + "gst-plugins-good %s does not support gcc older than 5" % self.version + ) + if self.options.shared and str(msvc_runtime_flag(self)).startswith("MT"): + raise ConanInvalidConfiguration('shared build with static runtime is not supported due to the FlsAlloc limit') + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + self.options['gstreamer'].shared = self.options.shared + self.options['gst-plugins-base'].shared = self.options.shared + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def requirements(self): + self.requires("glib/2.70.1") + self.requires("gstreamer/1.19.1") + self.requires("gst-plugins-base/1.19.1") + self.requires('ffmpeg/4.4') + if self.settings.os == 'Linux': + self.requires('libalsa/1.2.5.1') # temp - conflict with gst-plugins-base + + def build_requirements(self): + self.build_requires("meson/0.54.2") + if not tools.which("pkg-config"): + self.build_requires("pkgconf/1.7.4") + if self.settings.os == 'Windows': + self.build_requires("winflexbison/2.5.24") + else: + self.build_requires("bison/3.7.6") + self.build_requires("flex/2.6.4") + if self.options.with_introspection: + self.build_requires("gobject-introspection/1.68.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_meson(self): + defs = dict() + + def add_flag(name, value): + if name in defs: + defs[name] += " " + value + else: + defs[name] = value + + def add_compiler_flag(value): + add_flag("c_args", value) + add_flag("cpp_args", value) + + def add_linker_flag(value): + add_flag("c_link_args", value) + add_flag("cpp_link_args", value) + + meson = Meson(self) + if self.settings.compiler == "Visual Studio": + add_linker_flag("-lws2_32") + add_compiler_flag("-%s" % self.settings.compiler.runtime) + if int(str(self.settings.compiler.version)) < 14: + add_compiler_flag("-Dsnprintf=_snprintf") + if self.settings.get_safe("compiler.runtime"): + defs["b_vscrt"] = str(self.settings.compiler.runtime).lower() + defs["tools"] = "disabled" + defs["examples"] = "disabled" + defs["benchmarks"] = "disabled" + defs["tests"] = "disabled" + defs["wrap_mode"] = "nofallback" + defs["introspection"] = "enabled" if self.options.with_introspection else "disabled" + meson.configure(build_folder=self._build_subfolder, + source_folder=self._source_subfolder, + defs=defs) + return meson + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.build() + + def _fix_library_names(self, path): + # regression in 1.16 + if self.settings.compiler == "Visual Studio": + with tools.chdir(path): + for filename_old in glob.glob("*.a"): + filename_new = filename_old[3:-2] + ".lib" + self.output.info("rename %s into %s" % (filename_old, filename_new)) + shutil.move(filename_old, filename_new) + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.install() + + self._fix_library_names(os.path.join(self.package_folder, "lib")) + self._fix_library_names(os.path.join(self.package_folder, "lib", "gstreamer-1.0")) + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "gstreamer-1.0", "pkgconfig")) + tools.remove_files_by_mask(self.package_folder, "*.pdb") + + def package_info(self): + + plugins = ["libav"] + + gst_plugin_path = os.path.join(self.package_folder, "lib", "gstreamer-1.0") + if self.options.shared: + self.output.info("Appending GST_PLUGIN_PATH env var : %s" % gst_plugin_path) + self.cpp_info.bindirs.append(gst_plugin_path) + self.runenv_info.prepend_path("GST_PLUGIN_PATH", gst_plugin_path) + self.env_info.GST_PLUGIN_PATH.append(gst_plugin_path) + else: + self.cpp_info.defines.append("GST_LIBAV_STATIC") + self.cpp_info.libdirs.append(gst_plugin_path) + self.cpp_info.libs.extend(["gst%s" % plugin for plugin in plugins]) + + self.cpp_info.includedirs = ["include", os.path.join("include", "gstreamer-1.0")] diff --git a/recipes/gst-libav/all/test_package/CMakeLists.txt b/recipes/gst-libav/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f22364a6eaec9 --- /dev/null +++ b/recipes/gst-libav/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gst-libav CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} gst-libav::gst-libav) diff --git a/recipes/gst-libav/all/test_package/conanfile.py b/recipes/gst-libav/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/gst-libav/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gst-libav/all/test_package/test_package.cpp b/recipes/gst-libav/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..290f444c910bd --- /dev/null +++ b/recipes/gst-libav/all/test_package/test_package.cpp @@ -0,0 +1,34 @@ +#include +#include + +#ifdef GST_LIBAV_STATIC + +extern "C" +{ + GST_PLUGIN_STATIC_DECLARE(libav); +} + +#endif + +#include + +int main(int argc, char * argv[]) +{ + gst_init(&argc, &argv); + +#ifdef GST_LIBAV_STATIC + + GST_PLUGIN_STATIC_REGISTER(libav); + +#endif + + GstElement * avdec_mjpeg = gst_element_factory_make("avdec_mjpeg", NULL); + if (!avdec_mjpeg) { + std::cerr << "failed to create avdec_mjpeg element" << std::endl; + return -1; + } else { + std::cout << "avdec_mjpeg has been created successfully" << std::endl; + } + gst_object_unref(GST_OBJECT(avdec_mjpeg)); + return 0; +} diff --git a/recipes/gst-libav/config.yml b/recipes/gst-libav/config.yml new file mode 100644 index 0000000000000..e20650f02a0e5 --- /dev/null +++ b/recipes/gst-libav/config.yml @@ -0,0 +1,3 @@ +versions: + "1.19.1": + folder: all diff --git a/recipes/gst-plugins-bad/all/conandata.yml b/recipes/gst-plugins-bad/all/conandata.yml new file mode 100644 index 0000000000000..602ab1c11e3e2 --- /dev/null +++ b/recipes/gst-plugins-bad/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.19.1": + url: "https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/archive/1.19.1/gst-plugins-bad-1.19.1.tar.bz2" + sha256 : "eef44e835a8425a79d69241853040a24769067707c1012ade5cae55175392dcf" diff --git a/recipes/gst-plugins-bad/all/conanfile.py b/recipes/gst-plugins-bad/all/conanfile.py new file mode 100644 index 0000000000000..12454eb3c5747 --- /dev/null +++ b/recipes/gst-plugins-bad/all/conanfile.py @@ -0,0 +1,232 @@ +from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment +from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import msvc_runtime_flag +import glob +import os +import shutil + + +class GStPluginsBadConan(ConanFile): + name = "gst-plugins-bad" + description = "GStreamer is a development framework for creating applications like media players, video editors, " \ + "streaming media broadcasters and so on" + topics = ("gstreamer", "multimedia", "video", "audio", "broadcasting", "framework", "media") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gstreamer.freedesktop.org/" + license = "GPL-2.0-only" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_introspection": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_introspection": False, + } + _source_subfolder = "source_subfolder" + _build_subfolder = "build_subfolder" + exports_sources = ["patches/*.patch"] + + generators = "pkg_config" + + @property + def _is_msvc(self): + return self.settings.compiler == "Visual Studio" + + def validate(self): + if self.options.shared != self.options["gstreamer"].shared or \ + self.options.shared != self.options["glib"].shared or \ + self.options.shared != self.options["gst-plugins-base"].shared: + # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/133 + raise ConanInvalidConfiguration("GLib, GStreamer and GstPlugins must be either all shared, or all static") + if tools.Version(self.version) >= "1.18.2" and\ + self.settings.compiler == "gcc" and\ + tools.Version(self.settings.compiler.version) < "5": + raise ConanInvalidConfiguration( + "gst-plugins-bad %s does not support gcc older than 5" % self.version + ) + if self.options.shared and str(msvc_runtime_flag(self)).startswith("MT"): + raise ConanInvalidConfiguration('shared build with static runtime is not supported due to the FlsAlloc limit') + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + self.options['gstreamer'].shared = self.options.shared + self.options['gst-plugins-base'].shared = self.options.shared + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def requirements(self): + self.requires("glib/2.70.1") + self.requires("gstreamer/1.19.1") + self.requires("gst-plugins-base/1.19.1") + + def build_requirements(self): + self.build_requires("meson/0.54.2") + if not tools.which("pkg-config"): + self.build_requires("pkgconf/1.7.4") + if self.settings.os == 'Windows': + self.build_requires("winflexbison/2.5.24") + else: + self.build_requires("bison/3.7.6") + self.build_requires("flex/2.6.4") + if self.options.with_introspection: + self.build_requires("gobject-introspection/1.68.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_meson(self): + defs = dict() + + def add_flag(name, value): + if name in defs: + defs[name] += " " + value + else: + defs[name] = value + + def add_compiler_flag(value): + add_flag("c_args", value) + add_flag("cpp_args", value) + + def add_linker_flag(value): + add_flag("c_link_args", value) + add_flag("cpp_link_args", value) + + meson = Meson(self) + if self.settings.compiler == "Visual Studio": + add_linker_flag("-lws2_32") + add_compiler_flag("-%s" % self.settings.compiler.runtime) + if int(str(self.settings.compiler.version)) < 14: + add_compiler_flag("-Dsnprintf=_snprintf") + if self.settings.get_safe("compiler.runtime"): + defs["b_vscrt"] = str(self.settings.compiler.runtime).lower() + defs["tools"] = "disabled" + defs["examples"] = "disabled" + defs["benchmarks"] = "disabled" + defs["tests"] = "disabled" + defs["wrap_mode"] = "nofallback" + defs["introspection"] = "enabled" if self.options.with_introspection else "disabled" + meson.configure(build_folder=self._build_subfolder, + source_folder=self._source_subfolder, + defs=defs) + return meson + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.build() + + def _fix_library_names(self, path): + # regression in 1.16 + if self.settings.compiler == "Visual Studio": + with tools.chdir(path): + for filename_old in glob.glob("*.a"): + filename_new = filename_old[3:-2] + ".lib" + self.output.info("rename %s into %s" % (filename_old, filename_new)) + shutil.move(filename_old, filename_new) + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.install() + + self._fix_library_names(os.path.join(self.package_folder, "lib")) + self._fix_library_names(os.path.join(self.package_folder, "lib", "gstreamer-1.0")) + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "gstreamer-1.0", "pkgconfig")) + tools.remove_files_by_mask(self.package_folder, "*.pdb") + + def package_info(self): + + plugins = ["accurip", + "adpcmdec", + "adpcmenc", + "aiff", + "asfmux", + "audiobuffersplit", + "audiofxbad", + "audiolatency", + "audiomixmatrix", + "audiovisualizers", + "autoconvert", + "bayer", + "camerabin", + "codecalpha", + "coloreffects", + "debugutilsbad", + "dvbsubenc", + "dvbsuboverlay", + "dvdspu", + "faceoverlay", + "festival", + "fieldanalysis", + "freeverb", + "frei0r", + "gaudieffects", + "gdp", + "geometrictransform", + "id3tag", + "inter", + "interlace", + "ivfparse", + "ivtc", + "jp2kdecimator", + "jpegformat", + "rfbsrc", + "midi", + "mpegpsdemux", + "mpegpsmux", + "mpegtsdemux", + "mpegtsmux", + "mxf", + "netsim", + "rtponvif", + "pcapparse", + "pnm", + "proxy", + "legacyrawparse", + "removesilence", + "rist", + "rtmp2", + "rtpmanagerbad", + "sdpelem", + "segmentclip", + "siren", + "smooth", + "speed", + "subenc", + "switchbin", + "timecode", + "transcode", + "videofiltersbad", + "videoframe_audiolevel", + "videoparsersbad", + "videosignal", + "vmnc", + "y4mdec"] + + gst_plugin_path = os.path.join(self.package_folder, "lib", "gstreamer-1.0") + if self.options.shared: + self.output.info("Appending GST_PLUGIN_PATH env var : %s" % gst_plugin_path) + self.cpp_info.bindirs.append(gst_plugin_path) + self.runenv_info.prepend_path("GST_PLUGIN_PATH", gst_plugin_path) + self.env_info.GST_PLUGIN_PATH.append(gst_plugin_path) + else: + self.cpp_info.defines.append("GST_PLUGINS_BAD_STATIC") + self.cpp_info.libdirs.append(gst_plugin_path) + self.cpp_info.libs.extend(["gst%s" % plugin for plugin in plugins]) + + self.cpp_info.includedirs = ["include", os.path.join("include", "gstreamer-1.0")] diff --git a/recipes/gst-plugins-bad/all/test_package/CMakeLists.txt b/recipes/gst-plugins-bad/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a585dafd3e413 --- /dev/null +++ b/recipes/gst-plugins-bad/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gst-plugins-bad CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} gst-plugins-bad::gst-plugins-bad) diff --git a/recipes/gst-plugins-bad/all/test_package/conanfile.py b/recipes/gst-plugins-bad/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/gst-plugins-bad/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gst-plugins-bad/all/test_package/test_package.cpp b/recipes/gst-plugins-bad/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4c05ffed8b6c3 --- /dev/null +++ b/recipes/gst-plugins-bad/all/test_package/test_package.cpp @@ -0,0 +1,34 @@ +#include +#include + +#ifdef GST_PLUGINS_BAD_STATIC + +extern "C" +{ + GST_PLUGIN_STATIC_DECLARE(mpegpsdemux); +} + +#endif + +#include + +int main(int argc, char * argv[]) +{ + gst_init(&argc, &argv); + +#ifdef GST_PLUGINS_BAD_STATIC + + GST_PLUGIN_STATIC_REGISTER(mpegpsdemux); + +#endif + + GstElement * mpegpsdemux = gst_element_factory_make("mpegpsdemux", NULL); + if (!mpegpsdemux) { + std::cerr << "failed to create mpegpsdemux element" << std::endl; + return -1; + } else { + std::cout << "mpegpsdemux has been created successfully" << std::endl; + } + gst_object_unref(GST_OBJECT(mpegpsdemux)); + return 0; +} diff --git a/recipes/gst-plugins-bad/config.yml b/recipes/gst-plugins-bad/config.yml new file mode 100644 index 0000000000000..e20650f02a0e5 --- /dev/null +++ b/recipes/gst-plugins-bad/config.yml @@ -0,0 +1,3 @@ +versions: + "1.19.1": + folder: all diff --git a/recipes/gst-plugins-base/all/conandata.yml b/recipes/gst-plugins-base/all/conandata.yml new file mode 100644 index 0000000000000..7c043aceb40a4 --- /dev/null +++ b/recipes/gst-plugins-base/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.19.2": + url: "https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/archive/1.19.2/gst-plugins-base-1.19.2.tar.gz" + sha256: "567b3bf2d08ed6602fb56b7aa9debbd5ff4b5957eb8fbb1f945b491695bc8198" + "1.19.1": + url: "https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/archive/1.19.1/gst-plugins-base-1.19.1.tar.bz2" + sha256: "b39338e306502570b49043a9b9df5704043e02c8a2ccba3a5a4f1f6ea410d4b1" diff --git a/recipes/gst-plugins-base/all/conanfile.py b/recipes/gst-plugins-base/all/conanfile.py new file mode 100644 index 0000000000000..55f105d03d691 --- /dev/null +++ b/recipes/gst-plugins-base/all/conanfile.py @@ -0,0 +1,696 @@ +from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment +from conans.errors import ConanInvalidConfiguration +import glob +import os +import shutil + + +class GStPluginsBaseConan(ConanFile): + name = "gst-plugins-base" + description = "GStreamer is a development framework for creating applications like media players, video editors, " \ + "streaming media broadcasters and so on" + topics = ("gstreamer", "multimedia", "video", "audio", "broadcasting", "framework", "media") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gstreamer.freedesktop.org/" + license = "GPL-2.0-only" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_libalsa": [True, False], + "with_libpng": [True, False], + "with_libjpeg": [False, "libjpeg", "libjpeg-turbo"], + "with_graphene": [True, False], + "with_pango": [True, False], + "with_ogg": [True, False], + "with_opus": [True, False], + "with_theora": [True, False], + "with_vorbis": [True, False], + "with_gl": [True, False], + "with_egl": [True, False], + "with_wayland": [True, False], + "with_xorg": [True, False], + "with_introspection": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_libalsa": True, + "with_libpng": True, + "with_libjpeg": "libjpeg", + "with_graphene": True, + "with_pango": True, + "with_ogg": True, + "with_opus": True, + "with_theora": True, + "with_vorbis": True, + "with_gl": True, + "with_egl": True, + "with_wayland": True, + "with_xorg": True, + "with_introspection": False, + } + _source_subfolder = "source_subfolder" + _build_subfolder = "build_subfolder" + exports_sources = ["patches/*.patch"] + + generators = "pkg_config" + + _gl_api = None + _gl_platform = None + _gl_winsys = None + + @property + def _is_msvc(self): + return self.settings.compiler == "Visual Studio" + + def validate(self): + if not self.options["glib"].shared and self.options.shared: + # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/133 + raise ConanInvalidConfiguration("shared GStreamer cannot link to static GLib") + if self.options.shared != self.options["gstreamer"].shared: + # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/133 + raise ConanInvalidConfiguration("GStreamer and GstPlugins must be either all shared, or all static") + if tools.Version(self.version) >= "1.18.2" and\ + self.settings.compiler == "gcc" and\ + tools.Version(self.settings.compiler.version) < "5": + raise ConanInvalidConfiguration( + "gst-plugins-base %s does not support gcc older than 5" % self.version + ) + if self.options.with_gl and self.options.get_safe("with_wayland") and not self.options.get_safe("with_egl"): + raise ConanInvalidConfiguration("OpenGL support with Wayland requires 'with_egl' turned on!") + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + self.options['gstreamer'].shared = self.options.shared + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + if self.settings.os != "Linux": + del self.options.with_libalsa + del self.options.with_wayland + if self.settings.os not in ["Linux", "FreeBSD"]: + del self.options.with_egl + del self.options.with_xorg + + def requirements(self): + self.requires("zlib/1.2.12") + self.requires("glib/2.72.0") + self.requires("gstreamer/1.19.2") + if self.options.get_safe("with_libalsa"): + self.requires("libalsa/1.2.5.1") + if self.options.get_safe("with_xorg"): + self.requires("xorg/system") + if self.options.with_gl: + self.requires("opengl/system") + if self.settings.os == "Windows": + self.requires("wglext/cci.20200813") + self.requires('glext/cci.20210420') + if self.options.get_safe("with_egl"): + self.requires("egl/system") + if self.options.get_safe("with_wayland"): + self.requires("wayland/1.20.0") + self.requires("wayland-protocols/1.25") + if self.options.with_graphene: + self.requires("graphene/1.10.8") + if self.options.with_libpng: + self.requires("libpng/1.6.37") + if self.options.with_libjpeg == "libjpeg": + self.requires("libjpeg/9d") + elif self.options.with_libjpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/2.1.2") + if self.options.with_ogg: + self.requires("ogg/1.3.5") + if self.options.with_opus: + self.requires("opus/1.3.1") + if self.options.with_theora: + self.requires("theora/1.1.1") + if self.options.with_vorbis: + self.requires("vorbis/1.3.7") + if self.options.with_pango: + self.requires("pango/1.49.3") + + def build_requirements(self): + self.build_requires("meson/0.61.2") + if not tools.which("pkg-config"): + self.build_requires("pkgconf/1.7.4") + if self.settings.os == 'Windows': + self.build_requires("winflexbison/2.5.24") + else: + self.build_requires("bison/3.7.6") + self.build_requires("flex/2.6.4") + if self.options.with_introspection: + self.build_requires("gobject-introspection/1.70.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _gl_config(self): + if not self._gl_api or not self._gl_platform or not self._gl_winsys: + gl_api = set() + gl_platform = set() + gl_winsys = set() # TODO: winrt, dispamnx, viv-fb, gbm, android + if self.options.get_safe("with_egl"): + gl_api.add("opengl") + gl_platform.add("egl") + gl_winsys.add("egl") + if self.options.get_safe("with_xorg"): + gl_api.add("opengl") + gl_platform.add("glx") + gl_winsys.add("x11") + if self.options.get_safe("with_wayland"): + gl_api.add("opengl") + gl_platform.add("egl") + gl_winsys.add("wayland") + if self.settings.os == "Macos": + gl_api.add("opengl") + gl_platform.add("cgl") + gl_winsys.add("cocoa") + elif self.settings.os in ["iOS", "tvOS", "watchOS"]: + gl_api.add("gles2") + gl_platform.add("eagl") + gl_winsys.add("eagl") + elif self.settings.os == "Windows": + gl_api.add("opengl") + gl_platform.add("wgl") + gl_winsys.add("win32") + self._gl_api = list(gl_api) + self._gl_platform = list(gl_platform) + self._gl_winsys = list(gl_winsys) + return self._gl_api, self._gl_platform, self._gl_winsys + + def _configure_meson(self): + defs = dict() + + def add_flag(name, value): + if name in defs: + defs[name] += " " + value + else: + defs[name] = value + + def add_compiler_flag(value): + add_flag("c_args", value) + add_flag("cpp_args", value) + + def add_linker_flag(value): + add_flag("c_link_args", value) + add_flag("cpp_link_args", value) + + meson = Meson(self) + if self.settings.compiler == "Visual Studio": + add_linker_flag("-lws2_32") + add_compiler_flag("-%s" % self.settings.compiler.runtime) + if int(str(self.settings.compiler.version)) < 14: + add_compiler_flag("-Dsnprintf=_snprintf") + if self.settings.get_safe("compiler.runtime"): + defs["b_vscrt"] = str(self.settings.compiler.runtime).lower() + + gl_api, gl_platform, gl_winsys = self._gl_config() + + defs["tools"] = "disabled" + defs["examples"] = "disabled" + defs["tests"] = "disabled" + defs["wrap_mode"] = "nofallback" + defs["introspection"] = "enabled" if self.options.with_introspection else "disabled" + defs["orc"] = "disabled" # TODO: orc + defs["gl"] = "enabled" if self.options.with_gl else "disabled" + defs["gl-graphene"] = "enabled" if self.options.with_gl and self.options.with_graphene else "disabled" + defs["gl-png"] = "enabled" if self.options.with_gl and self.options.with_libpng else "disabled" + defs["gl-jpeg"] = "enabled" if self.options.with_gl and self.options.with_libjpeg else "disabled" + defs["gl_api"] = gl_api + defs["gl_platform"] = gl_platform + defs["gl_winsys"] = gl_winsys + defs["alsa"] = "enabled" if self.options.get_safe("with_libalsa") else "disabled" + defs["cdparanoia"] = "disabled" # "enabled" if self.options.with_cdparanoia else "disabled" # TODO: cdparanoia + defs["libvisual"] = "disabled" # "enabled" if self.options.with_libvisual else "disabled" # TODO: libvisual + defs["ogg"] = "enabled" if self.options.with_ogg else "disabled" + defs["opus"] = "enabled" if self.options.with_opus else "disabled" + defs["pango"] = "enabled" if self.options.with_pango else "disabled" + defs["theora"] = "enabled" if self.options.with_theora else "disabled" + defs["tremor"] = "disabled" # "enabled" if self.options.with_tremor else "disabled" # TODO: tremor - only useful on machines without floating-point support + defs["vorbis"] = "enabled" if self.options.with_vorbis else "disabled" + defs["x11"] = "enabled" if self.options.get_safe("with_xorg") else "disabled" + defs["xshm"] = "enabled" if self.options.get_safe("with_xorg") else "disabled" + defs["xvideo"] = "enabled" if self.options.get_safe("with_xorg") else "disabled" + meson.configure(build_folder=self._build_subfolder, + source_folder=self._source_subfolder, + defs=defs) + return meson + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.build() + + def _fix_library_names(self, path): + # regression in 1.16 + if self.settings.compiler == "Visual Studio": + with tools.chdir(path): + for filename_old in glob.glob("*.a"): + filename_new = filename_old[3:-2] + ".lib" + self.output.info("rename %s into %s" % (filename_old, filename_new)) + shutil.move(filename_old, filename_new) + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.install() + + self._fix_library_names(os.path.join(self.package_folder, "lib")) + self._fix_library_names(os.path.join(self.package_folder, "lib", "gstreamer-1.0")) + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "gstreamer-1.0", "pkgconfig")) + tools.remove_files_by_mask(self.package_folder, "*.pdb") + + def package_id(self): + self.info.requires["glib"].full_package_mode() + self.info.requires["gstreamer"].full_package_mode() + + def package_info(self): + gst_plugins = [] + gst_plugin_path = os.path.join(self.package_folder, "lib", "gstreamer-1.0") + gst_include_path = os.path.join(self.package_folder, "include", "gstreamer-1.0") + + pkgconfig_variables = { + "exec_prefix": "${prefix}", + "toolsdir": "${exec_prefix}/bin", + "pluginsdir": "${libdir}/gstreamer-1.0", + "datarootdir": "${prefix}/share", + "datadir": "${datarootdir}", + "girdir": "${datadir}/gir-1.0", + "typelibdir": "${libdir}/girepository-1.0", + "libexecdir": "${prefix}/libexec" + } + pkgconfig_custom_content = "\n".join("{}={}".format(key, value) for key, value in pkgconfig_variables.items()) + + if self.options.shared: + self.output.info("Appending GST_PLUGIN_PATH env var : %s" % gst_plugin_path) + self.env_info.GST_PLUGIN_PATH.append(gst_plugin_path) + + # Plugins ('gst') + self.cpp_info.components["gstadder"].libs = ["gstadder"] + self.cpp_info.components["gstadder"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstadder"].requires = ["gstreamer-audio-1.0"] # TODO: orc + gst_plugins.append("gstadder") + + self.cpp_info.components["gstapp"].libs = ["gstapp"] + self.cpp_info.components["gstapp"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstapp"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer-app-1.0", "gstreamer-tag-1.0"] + gst_plugins.append("gstapp") + + self.cpp_info.components["gstaudioconvert"].libs = ["gstaudioconvert"] + self.cpp_info.components["gstaudioconvert"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstaudioconvert"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer-audio-1.0"] + gst_plugins.append("gstaudioconvert") + + self.cpp_info.components["gstaudiomixer"].libs = ["gstaudiomixer"] + self.cpp_info.components["gstaudiomixer"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstaudiomixer"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer-audio-1.0"] # TODO: orc + gst_plugins.append("gstaudiomixer") + + self.cpp_info.components["gstaudiorate"].libs = ["gstaudiorate"] + self.cpp_info.components["gstaudiorate"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstaudiorate"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer-audio-1.0"] + gst_plugins.append("gstaudiorate") + + self.cpp_info.components["gstaudioresample"].libs = ["gstaudioresample"] + self.cpp_info.components["gstaudioresample"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstaudioresample"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer-audio-1.0"] + if self.settings.os == "Linux": + self.cpp_info.components["gstaudioresample"].system_libs = ["m"] + gst_plugins.append("gstaudioresample") + + self.cpp_info.components["gstaudiotestsrc"].libs = ["gstaudiotestsrc"] + self.cpp_info.components["gstaudiotestsrc"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstaudiotestsrc"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer-audio-1.0"] + if self.settings.os == "Linux": + self.cpp_info.components["gstaudiotestsrc"].system_libs = ["m"] + gst_plugins.append("gstaudiotestsrc") + + self.cpp_info.components["gstcompositor"].libs = ["gstcompositor"] + self.cpp_info.components["gstcompositor"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstcompositor"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer-video-1.0"] # TODO: orc + if self.settings.os == "Linux": + self.cpp_info.components["gstcompositor"].system_libs = ["m"] + gst_plugins.append("gstcompositor") + + self.cpp_info.components["gstencoding"].libs = ["gstencoding"] + self.cpp_info.components["gstencoding"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstencoding"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer-video-1.0", "gstreamer-pbutils-1.0"] + gst_plugins.append("gstencoding") + + self.cpp_info.components["gstgio"].libs = ["gstgio"] + self.cpp_info.components["gstgio"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstgio"].requires = ["gstreamer::gstreamer-base-1.0", "glib::gio-2.0"] + gst_plugins.append("gstgio") + + self.cpp_info.components["gstoverlaycomposition"].libs = ["gstoverlaycomposition"] + self.cpp_info.components["gstoverlaycomposition"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstoverlaycomposition"].requires = ["gstreamer-video-1.0"] + gst_plugins.append("gstoverlaycomposition") + + self.cpp_info.components["gstpbtypes"].libs = ["gstpbtypes"] + self.cpp_info.components["gstpbtypes"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstpbtypes"].requires = ["gstreamer-video-1.0"] + gst_plugins.append("gstpbtypes") + + self.cpp_info.components["gstplayback"].libs = ["gstplayback"] + self.cpp_info.components["gstplayback"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstplayback"].requires = ["gstreamer-audio-1.0", "gstreamer-video-1.0", "gstreamer-pbutils-1.0", "gstreamer-tag-1.0"] + gst_plugins.append("gstplayback") + + self.cpp_info.components["gstrawparse"].libs = ["gstrawparse"] + self.cpp_info.components["gstrawparse"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstrawparse"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer-audio-1.0", "gstreamer-video-1.0"] + gst_plugins.append("gstrawparse") + + self.cpp_info.components["gstsubparse"].libs = ["gstsubparse"] + self.cpp_info.components["gstsubparse"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstsubparse"].requires = ["gstreamer::gstreamer-base-1.0"] + gst_plugins.append("gstsubparse") + + self.cpp_info.components["gsttcp"].libs = ["gsttcp"] + self.cpp_info.components["gsttcp"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gsttcp"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer::gstreamer-net-1.0", "glib::gio-2.0"] + gst_plugins.append("gsttcp") + + self.cpp_info.components["gsttypefindfunctions"].libs = ["gsttypefindfunctions"] + self.cpp_info.components["gsttypefindfunctions"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gsttypefindfunctions"].requires = ["gstreamer::gstreamer-base-1.0", "gstreamer-pbutils-1.0", "glib::gio-2.0"] + gst_plugins.append("gsttypefindfunctions") + + self.cpp_info.components["gstvideoconvert"].libs = ["gstvideoconvert"] + self.cpp_info.components["gstvideoconvert"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstvideoconvert"].requires = ["gstreamer-video-1.0"] + gst_plugins.append("gstvideoconvert") + + self.cpp_info.components["gstvideorate"].libs = ["gstvideorate"] + self.cpp_info.components["gstvideorate"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstvideorate"].requires = ["gstreamer-video-1.0"] + gst_plugins.append("gstvideorate") + + self.cpp_info.components["gstvideoscale"].libs = ["gstvideoscale"] + self.cpp_info.components["gstvideoscale"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstvideoscale"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-video-1.0", "glib::glib-2.0", "glib::gobject-2.0"] + gst_plugins.append("gstvideoscale") + + self.cpp_info.components["gstvideotestsrc"].libs = ["gstvideotestsrc"] + self.cpp_info.components["gstvideotestsrc"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstvideotestsrc"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-video-1.0", "glib::glib-2.0", "glib::gobject-2.0"] # TODO: orc + if self.settings.os == "Linux": + self.cpp_info.components["gstvideotestsrc"].system_libs = ["m"] + gst_plugins.append("gstvideotestsrc") + + self.cpp_info.components["gstvolume"].libs = ["gstvolume"] + self.cpp_info.components["gstvolume"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstvolume"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-audio-1.0", "glib::glib-2.0", "glib::gobject-2.0"] # TODO: orc + gst_plugins.append("gstvolume") + + # Plugins ('ext') + if self.options.get_safe("with_libalsa"): + self.cpp_info.components["gstalsa"].libs = ["gstalsa"] + self.cpp_info.components["gstalsa"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstalsa"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-audio-1.0", "gstreamer-tag-1.0", + "libalsa::libalsa", "glib::glib-2.0", "glib::gobject-2.0"] + gst_plugins.append("gstalsa") + + # if self.options.with_cdparanoia: # TODO: cdparanoia + # self.cpp_info.components["gstcdparanoia"].libs = ["gstcdparanoia"] + # self.cpp_info.components["gstcdparanoia"].libdirs.append(gst_plugin_path) + # self.cpp_info.components["gstcdparanoia"].requires = [ + # "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", "gstreamer-audio-1.0", + # "cdparanoia::cdparanoia", "glib::glib-2.0", "glib::gobject-2.0"] + # gst_plugins.append("gstcdparanoia") + + if self.options.with_gl: + self.cpp_info.components["gstopengl"].libs = ["gstopengl"] + self.cpp_info.components["gstopengl"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstopengl"].requires = [ + "gstreamer::gstreamer-base-1.0", "gstreamer::gstreamer-controller-1.0", + "gstreamer-video-1.0", "gstreamer-allocators-1.0", "opengl::opengl"] # TODO: bcm, nvbuf_utils + if self.settings.os == "Macos": + self.cpp_info.components["gstopengl"].frameworks = ["CoreFoundation", "Foundation", "QuartzCore"] + if self.options.with_graphene: + self.cpp_info.components["gstopengl"].requires.append("graphene::graphene-gobject-1.0") + if self.options.with_libpng: + self.cpp_info.components["gstopengl"].requires.append("libpng::libpng") + if self.options.with_libjpeg == "libjpeg": + self.cpp_info.components["gstopengl"].requires.append("libjpeg::libjpeg") + elif self.options.with_libjpeg == "libjpeg-turbo": + self.cpp_info.components["gstopengl"].requires.append("libjpeg-turbo::libjpeg-turbo") + if self.options.get_safe("with_xorg"): + self.cpp_info.components["gstopengl"].requires.append("xorg::x11") + if self.settings.os == "Linux": + self.cpp_info.components["gstopengl"].system_libs = ["m"] + gst_plugins.append("gstopengl") + + # if self.options.with_libvisual: # TODO: libvisual + # self.cpp_info.components["gstlibvisual"].libs = ["gstlibvisual"] + # self.cpp_info.components["gstlibvisual"].libdirs.append(gst_plugin_path) + # self.cpp_info.components["gstlibvisual"].requires = [ + # "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + # "gstreamer-audio-1.0", "gstreamer-video-1.0", "gstreamer-pbutils-1.0", + # "libvisual::libvisual", "glib::glib-2.0", "glib::gobject-2.0"] + # gst_plugins.append("gstlibvisual") + + if self.options.with_ogg: + self.cpp_info.components["gstogg"].libs = ["gstogg"] + self.cpp_info.components["gstogg"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstogg"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-audio-1.0", "gstreamer-pbutils-1.0", "gstreamer-tag-1.0", "gstreamer-riff-1.0", + "ogg::ogglib", "glib::glib-2.0", "glib::gobject-2.0"] + gst_plugins.append("gstogg") + + if self.options.with_opus: + self.cpp_info.components["gstopus"].libs = ["gstopus"] + self.cpp_info.components["gstopus"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstopus"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-audio-1.0", "gstreamer-pbutils-1.0", "gstreamer-tag-1.0", + "opus::libopus", "glib::glib-2.0", "glib::gobject-2.0"] + if self.settings.os == "Linux": + self.cpp_info.components["gstopus"].system_libs = ["m"] + gst_plugins.append("gstopus") + + if self.options.with_pango: + self.cpp_info.components["gstpango"].libs = ["gstpango"] + self.cpp_info.components["gstpango"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstpango"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-video-1.0", + "pango::pangocairo", "glib::glib-2.0", "glib::gobject-2.0"] + if self.settings.os == "Linux": + self.cpp_info.components["gstpango"].system_libs = ["m"] + gst_plugins.append("gstpango") + + if self.options.with_theora: + self.cpp_info.components["gsttheora"].libs = ["gsttheora"] + self.cpp_info.components["gsttheora"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gsttheora"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-video-1.0", "gstreamer-tag-1.0", + "theora::theoraenc", "theora::theoradec", "glib::glib-2.0", "glib::gobject-2.0"] + gst_plugins.append("gsttheora") + + if self.options.with_vorbis: + self.cpp_info.components["gstvorbis"].libs = ["gstvorbis"] + self.cpp_info.components["gstvorbis"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstvorbis"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-audio-1.0", "gstreamer-tag-1.0", + "vorbis::vorbismain", "vorbis::vorbisenc", "glib::glib-2.0", "glib::gobject-2.0"] + gst_plugins.append("gstvorbis") + + # if self.options.with_tremor: # TODO: tremor + # self.cpp_info.components["gstivorbisdec"].libs = ["gstivorbisdec"] + # self.cpp_info.components["gstivorbisdec"].libdirs.append(gst_plugin_path) + # self.cpp_info.components["gstivorbisdec"].requires = [ + # "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + # "gstreamer-audio-1.0", "gstreamer-tag-1.0", + # "tremor::tremor", "glib::glib-2.0", "glib::gobject-2.0"] + # gst_plugins.append("gstivorbisdec") + + # Plugins ('sys') + if self.options.get_safe("with_xorg"): + self.cpp_info.components["gstximagesink"].libs = ["gstximagesink"] + self.cpp_info.components["gstximagesink"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstximagesink"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-video-1.0", + "xorg::x11", "xorg::xext", "glib::glib-2.0", "glib::gobject-2.0"] + gst_plugins.append("gstximagesink") + + self.cpp_info.components["gstxvimagesink"].libs = ["gstxvimagesink"] + self.cpp_info.components["gstxvimagesink"].libdirs.append(gst_plugin_path) + self.cpp_info.components["gstxvimagesink"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-video-1.0", + "xorg::x11", "xorg::xext", "xorg::xv", "glib::glib-2.0", "glib::gobject-2.0"] + if self.settings.os == "Linux": + self.cpp_info.components["gstxvimagesink"].system_libs = ["m"] + gst_plugins.append("gstxvimagesink") + + # Libraries + self.cpp_info.components["gstreamer-plugins-base-1.0"].names["pkg_config"] = "gstreamer-plugins-base-1.0" + self.cpp_info.components["gstreamer-plugins-base-1.0"].requires = ["gstreamer::gstreamer-1.0"] + self.cpp_info.components["gstreamer-plugins-base-1.0"].includedirs = [gst_include_path] + if not self.options.shared: + self.cpp_info.components["gstreamer-plugins-base-1.0"].defines.append("GST_PLUGINS_BASE_STATIC") + self.cpp_info.components["gstreamer-plugins-base-1.0"].requires.extend(gst_plugins) + else: + self.cpp_info.components["gstreamer-plugins-base-1.0"].bindirs.append(gst_plugin_path) + self.cpp_info.components["gstreamer-plugins-base-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + self.cpp_info.components["gstreamer-allocators-1.0"].names["pkg_config"] = "gstreamer-allocators-1.0" + self.cpp_info.components["gstreamer-allocators-1.0"].libs = ["gstallocators-1.0"] + self.cpp_info.components["gstreamer-allocators-1.0"].requires = ["gstreamer::gstreamer-1.0"] + self.cpp_info.components["gstreamer-allocators-1.0"].includedirs = [gst_include_path] + self.cpp_info.components["gstreamer-allocators-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + self.cpp_info.components["gstreamer-app-1.0"].names["pkg_config"] = "gstreamer-app-1.0" + self.cpp_info.components["gstreamer-app-1.0"].libs = ["gstapp-1.0"] + self.cpp_info.components["gstreamer-app-1.0"].requires = ["gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0"] + self.cpp_info.components["gstreamer-app-1.0"].includedirs = [gst_include_path] + self.cpp_info.components["gstreamer-app-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + self.cpp_info.components["gstreamer-audio-1.0"].names["pkg_config"] = "gstreamer-audio-1.0" + self.cpp_info.components["gstreamer-audio-1.0"].libs = ["gstaudio-1.0"] + self.cpp_info.components["gstreamer-audio-1.0"].requires = ["gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", "gstreamer-tag-1.0"] # TODO: orc + self.cpp_info.components["gstreamer-audio-1.0"].includedirs = [gst_include_path] + if self.settings.os == "Linux": + self.cpp_info.components["gstreamer-audio-1.0"].system_libs = ["m"] + self.cpp_info.components["gstreamer-audio-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + self.cpp_info.components["gstreamer-fft-1.0"].names["pkg_config"] = "gstreamer-fft-1.0" + self.cpp_info.components["gstreamer-fft-1.0"].libs = ["gstfft-1.0"] + self.cpp_info.components["gstreamer-fft-1.0"].requires = ["gstreamer::gstreamer-1.0"] + self.cpp_info.components["gstreamer-fft-1.0"].includedirs = [gst_include_path] + if self.settings.os == "Linux": + self.cpp_info.components["gstreamer-fft-1.0"].system_libs = ["m"] + self.cpp_info.components["gstreamer-fft-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + if self.options.with_gl: + gl_api, gl_platform, gl_winsys = self._gl_config() + gl_variables = { + **pkgconfig_variables, + "gl_apis": " ".join(gl_api), + "gl_platforms": " ".join(gl_platform), + "gl_winsys": " ".join(gl_winsys) + } + gl_custom_content = "\n".join("{}={}".format(key, value) for key, value in gl_variables.items()) + + self.cpp_info.components["gstreamer-gl-1.0"].names["pkg_config"] = "gstreamer-gl-1.0" + self.cpp_info.components["gstreamer-gl-1.0"].libs = ["gstgl-1.0"] + self.cpp_info.components["gstreamer-gl-1.0"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-allocators-1.0", "gstreamer-video-1.0", + "glib::gmodule-no-export-2.0", "opengl::opengl"] # TODO: bcm + if self.options.get_safe("with_egl"): + self.cpp_info.components["gstreamer-gl-1.0"].requires.extend(["egl::egl"]) + if self.options.get_safe("with_xorg"): + self.cpp_info.components["gstreamer-gl-1.0"].requires.extend(["xorg::x11", "xorg::x11-xcb"]) + if self.options.get_safe("with_wayland"): + self.cpp_info.components["gstreamer-gl-1.0"].requires.extend([ + "wayland::wayland-client", "wayland::wayland-cursor", "wayland::wayland-egl", + "wayland-protocols::wayland-protocols"]) + if self.settings.os == "Windows": + self.cpp_info.components["gstreamer-gl-1.0"].requires.append("wglext::wglext") + self.cpp_info.components["gstreamer-gl-1.0"].requires.extend(['glext::glext']) + self.cpp_info.components["gstreamer-gl-1.0"].system_libs = ["gdi32"] + if self.settings.os in ["Macos", "iOS", "tvOS", "watchOS"]: + self.cpp_info.components["gstreamer-gl-1.0"].frameworks = ["CoreFoundation", "Foundation", "QuartzCore", "Cocoa"] + if self.settings.os in ["iOS", "tvOS", "watchOS"]: + self.cpp_info.components["gstreamer-gl-1.0"].frameworks.extend(["CoreGraphics", "UIkit"]) + self.cpp_info.components["gstreamer-gl-1.0"].includedirs = [os.path.join(self.package_folder, "include"), gst_include_path] + self.cpp_info.components["gstreamer-gl-1.0"].includedirs.append(os.path.join(gst_plugin_path, "include")) + self.cpp_info.components["gstreamer-gl-1.0"].set_property("pkg_config_custom_content", gl_custom_content) + + self.cpp_info.components["gstreamer-gl-prototypes-1.0"].names["pkg_config"] = "gstreamer-gl-prototypes-1.0" + self.cpp_info.components["gstreamer-gl-prototypes-1.0"].requires = ["gstreamer-gl-1.0", "opengl::opengl"] + + if self.options.get_safe("with_egl"): + self.cpp_info.components["gstreamer-gl-egl-1.0"].names["pkg_config"] = "gstreamer-gl-egl-1.0" + self.cpp_info.components["gstreamer-gl-egl-1.0"].requires = ["gstreamer-gl-1.0", "egl::egl"] + + if self.options.get_safe("with_wayland"): + self.cpp_info.components["gstreamer-gl-wayland-1.0"].names["pkg_config"] = "gstreamer-gl-wayland-1.0" + self.cpp_info.components["gstreamer-gl-wayland-1.0"].requires = [ + "gstreamer-gl-1.0", "wayland::wayland-client", "wayland::wayland-egl", + "wayland-protocols::wayland-protocols"] + + if self.options.get_safe("with_xorg"): + self.cpp_info.components["gstreamer-gl-x11-1.0"].names["pkg_config"] = "gstreamer-gl-x11-1.0" + self.cpp_info.components["gstreamer-gl-x11-1.0"].requires = ["gstreamer-gl-1.0", "xorg::x11-xcb"] + + self.cpp_info.components["gstreamer-pbutils-1.0"].names["pkg_config"] = "gstreamer-pbutils-1.0" + self.cpp_info.components["gstreamer-pbutils-1.0"].libs = ["gstpbutils-1.0"] + self.cpp_info.components["gstreamer-pbutils-1.0"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-audio-1.0", "gstreamer-video-1.0", "gstreamer-tag-1.0"] + self.cpp_info.components["gstreamer-pbutils-1.0"].includedirs = [gst_include_path] + self.cpp_info.components["gstreamer-pbutils-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + self.cpp_info.components["gstreamer-riff-1.0"].names["pkg_config"] = "gstreamer-riff-1.0" + self.cpp_info.components["gstreamer-riff-1.0"].libs = ["gstriff-1.0"] + self.cpp_info.components["gstreamer-riff-1.0"].requires = ["gstreamer::gstreamer-1.0", "gstreamer-audio-1.0", "gstreamer-tag-1.0"] + self.cpp_info.components["gstreamer-riff-1.0"].includedirs = [gst_include_path] + self.cpp_info.components["gstreamer-riff-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + self.cpp_info.components["gstreamer-rtp-1.0"].names["pkg_config"] = "gstreamer-rtp-1.0" + self.cpp_info.components["gstreamer-rtp-1.0"].libs = ["gstrtp-1.0"] + self.cpp_info.components["gstreamer-rtp-1.0"].requires = ["gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", "gstreamer-audio-1.0"] + self.cpp_info.components["gstreamer-rtp-1.0"].includedirs = [gst_include_path] + self.cpp_info.components["gstreamer-rtp-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + self.cpp_info.components["gstreamer-rtsp-1.0"].names["pkg_config"] = "gstreamer-rtsp-1.0" + self.cpp_info.components["gstreamer-rtsp-1.0"].libs = ["gstrtsp-1.0"] + self.cpp_info.components["gstreamer-rtsp-1.0"].requires = [ + "gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", + "gstreamer-sdp-1.0", "glib::gio-2.0"] + if self.settings.os == "Linux": + self.cpp_info.components["gstreamer-rtsp-1.0"].system_libs = ["m"] + elif self.settings.os == "Windows": + self.cpp_info.components["gstreamer-rtsp-1.0"].system_libs = ["ws2_32"] + self.cpp_info.components["gstreamer-rtsp-1.0"].includedirs = [gst_include_path] + self.cpp_info.components["gstreamer-rtsp-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + self.cpp_info.components["gstreamer-sdp-1.0"].names["pkg_config"] = "gstreamer-sdp-1.0" + self.cpp_info.components["gstreamer-sdp-1.0"].libs = ["gstsdp-1.0"] + self.cpp_info.components["gstreamer-sdp-1.0"].requires = ["gstreamer::gstreamer-1.0", "gstreamer-rtp-1.0", "glib::glib-2.0", "glib::gio-2.0"] + self.cpp_info.components["gstreamer-sdp-1.0"].includedirs = [gst_include_path] + self.cpp_info.components["gstreamer-sdp-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + self.cpp_info.components["gstreamer-tag-1.0"].names["pkg_config"] = "gstreamer-tag-1.0" + self.cpp_info.components["gstreamer-tag-1.0"].libs = ["gsttag-1.0"] + self.cpp_info.components["gstreamer-tag-1.0"].requires = ["gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0", "zlib::zlib"] + if self.settings.os == "Linux": + self.cpp_info.components["gstreamer-tag-1.0"].system_libs = ["m"] + self.cpp_info.components["gstreamer-tag-1.0"].includedirs = [gst_include_path] + self.cpp_info.components["gstreamer-tag-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) + + self.cpp_info.components["gstreamer-video-1.0"].names["pkg_config"] = "gstreamer-video-1.0" + self.cpp_info.components["gstreamer-video-1.0"].libs = ["gstvideo-1.0"] + self.cpp_info.components["gstreamer-video-1.0"].requires = ["gstreamer::gstreamer-1.0", "gstreamer::gstreamer-base-1.0"] # TODO: orc + if self.settings.os == "Linux": + self.cpp_info.components["gstreamer-video-1.0"].system_libs = ["m"] + self.cpp_info.components["gstreamer-video-1.0"].includedirs = [gst_include_path] + self.cpp_info.components["gstreamer-video-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) diff --git a/recipes/gst-plugins-base/all/test_package/CMakeLists.txt b/recipes/gst-plugins-base/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a872f34009a12 --- /dev/null +++ b/recipes/gst-plugins-base/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gst-plugins-base CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} gst-plugins-base::gstreamer-plugins-base-1.0) diff --git a/recipes/gst-plugins-base/all/test_package/conanfile.py b/recipes/gst-plugins-base/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/gst-plugins-base/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gst-plugins-base/all/test_package/test_package.cpp b/recipes/gst-plugins-base/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..89721999b15cf --- /dev/null +++ b/recipes/gst-plugins-base/all/test_package/test_package.cpp @@ -0,0 +1,44 @@ +#include +#include + +#ifdef GST_PLUGINS_BASE_STATIC + +extern "C" +{ + GST_PLUGIN_STATIC_DECLARE(audiotestsrc); + GST_PLUGIN_STATIC_DECLARE(videotestsrc); +} + +#endif + +#include + +int main(int argc, char * argv[]) +{ + gst_init(&argc, &argv); + +#ifdef GST_PLUGINS_BASE_STATIC + + GST_PLUGIN_STATIC_REGISTER(audiotestsrc); + GST_PLUGIN_STATIC_REGISTER(videotestsrc); + +#endif + + GstElement * audiotestsrc = gst_element_factory_make("audiotestsrc", NULL); + if (!audiotestsrc) { + std::cerr << "failed to create audiotestsrc element" << std::endl; + return -1; + } else { + std::cout << "audiotestsrc has been created successfully" << std::endl; + } + gst_object_unref(GST_OBJECT(audiotestsrc)); + GstElement * videotestsrc = gst_element_factory_make("videotestsrc", NULL); + if (!videotestsrc) { + std::cerr << "failed to create videotestsrc element" << std::endl; + return -1; + } else { + std::cout << "videotestsrc has been created successfully" << std::endl; + } + gst_object_unref(GST_OBJECT(videotestsrc)); + return 0; +} diff --git a/recipes/gst-plugins-base/config.yml b/recipes/gst-plugins-base/config.yml new file mode 100644 index 0000000000000..00bb72b6988b8 --- /dev/null +++ b/recipes/gst-plugins-base/config.yml @@ -0,0 +1,5 @@ +versions: + "1.19.2": + folder: all + "1.19.1": + folder: all diff --git a/recipes/gst-plugins-good/all/conandata.yml b/recipes/gst-plugins-good/all/conandata.yml new file mode 100644 index 0000000000000..d7297bec108c9 --- /dev/null +++ b/recipes/gst-plugins-good/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.19.1": + url: "https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/archive/1.19.1/gst-plugins-good-1.19.1.tar.bz2" + sha256 : "c2c97b8bfeac812dbdca3a72a15a874de4845e4a042693dad8447272c8767a64" diff --git a/recipes/gst-plugins-good/all/conanfile.py b/recipes/gst-plugins-good/all/conanfile.py new file mode 100644 index 0000000000000..37aae306fba09 --- /dev/null +++ b/recipes/gst-plugins-good/all/conanfile.py @@ -0,0 +1,209 @@ +from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment +from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import msvc_runtime_flag +import glob +import os +import shutil + + +class GStPluginsGoodConan(ConanFile): + name = "gst-plugins-good" + description = "GStreamer is a development framework for creating applications like media players, video editors, " \ + "streaming media broadcasters and so on" + topics = ("gstreamer", "multimedia", "video", "audio", "broadcasting", "framework", "media") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gstreamer.freedesktop.org/" + license = "GPL-2.0-only" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_introspection": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_introspection": False, + } + _source_subfolder = "source_subfolder" + _build_subfolder = "build_subfolder" + exports_sources = ["patches/*.patch"] + + generators = "pkg_config" + + @property + def _is_msvc(self): + return self.settings.compiler == "Visual Studio" + + def validate(self): + if self.options.shared != self.options["gstreamer"].shared or \ + self.options.shared != self.options["glib"].shared or \ + self.options.shared != self.options["gst-plugins-base"].shared: + # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/133 + raise ConanInvalidConfiguration("GLib, GStreamer and GstPlugins must be either all shared, or all static") + if tools.Version(self.version) >= "1.18.2" and\ + self.settings.compiler == "gcc" and\ + tools.Version(self.settings.compiler.version) < "5": + raise ConanInvalidConfiguration( + "gst-plugins-good %s does not support gcc older than 5" % self.version + ) + if self.options.shared and str(msvc_runtime_flag(self)).startswith("MT"): + raise ConanInvalidConfiguration('shared build with static runtime is not supported due to the FlsAlloc limit') + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + self.options['gstreamer'].shared = self.options.shared + self.options['gst-plugins-base'].shared = self.options.shared + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def requirements(self): + self.requires("glib/2.70.0") + self.requires("gstreamer/1.19.1") + self.requires("gst-plugins-base/1.19.1") + + def build_requirements(self): + self.build_requires("meson/0.54.2") + if not tools.which("pkg-config"): + self.build_requires("pkgconf/1.7.4") + if self.settings.os == 'Windows': + self.build_requires("winflexbison/2.5.24") + else: + self.build_requires("bison/3.7.6") + self.build_requires("flex/2.6.4") + if self.options.with_introspection: + self.build_requires("gobject-introspection/1.68.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_meson(self): + defs = dict() + + def add_flag(name, value): + if name in defs: + defs[name] += " " + value + else: + defs[name] = value + + def add_compiler_flag(value): + add_flag("c_args", value) + add_flag("cpp_args", value) + + def add_linker_flag(value): + add_flag("c_link_args", value) + add_flag("cpp_link_args", value) + + meson = Meson(self) + if self.settings.compiler == "Visual Studio": + add_linker_flag("-lws2_32") + add_compiler_flag("-%s" % self.settings.compiler.runtime) + if int(str(self.settings.compiler.version)) < 14: + add_compiler_flag("-Dsnprintf=_snprintf") + if self.settings.get_safe("compiler.runtime"): + defs["b_vscrt"] = str(self.settings.compiler.runtime).lower() + defs["tools"] = "disabled" + defs["examples"] = "disabled" + defs["benchmarks"] = "disabled" + defs["tests"] = "disabled" + defs["wrap_mode"] = "nofallback" + defs["introspection"] = "enabled" if self.options.with_introspection else "disabled" + meson.configure(build_folder=self._build_subfolder, + source_folder=self._source_subfolder, + defs=defs) + return meson + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.build() + + def _fix_library_names(self, path): + # regression in 1.16 + if self.settings.compiler == "Visual Studio": + with tools.chdir(path): + for filename_old in glob.glob("*.a"): + filename_new = filename_old[3:-2] + ".lib" + self.output.info("rename %s into %s" % (filename_old, filename_new)) + shutil.move(filename_old, filename_new) + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.install() + + self._fix_library_names(os.path.join(self.package_folder, "lib")) + self._fix_library_names(os.path.join(self.package_folder, "lib", "gstreamer-1.0")) + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "gstreamer-1.0", "pkgconfig")) + tools.remove_files_by_mask(self.package_folder, "*.pdb") + + def package_info(self): + + plugins = ["alpha", "alphacolor", + "apetag", + "audiofx", + "audioparsers", + "auparse", + "autodetect", + "avi", + "cutter", + "debug", + "deinterlace", + "dtmf", + "effectv", + "equalizer", + "flv", + "flxdec", + "goom", + "goom2k1", + "icydemux", + "id3demux", + "imagefreeze", + "interleave", + "isomp4", + "alaw", "mulaw", + "level", + "matroska", + "monoscope", + "multifile", + "multipart", + "replaygain", + "rtp", + "rtpmanager", + "rtsp", + "shapewipe", + "smpte", + "spectrum", + "udp", + "videobox", + "videocrop", + "videofilter", + "videomixer", + "wavenc", + "wavparse", + "y4menc"] + + gst_plugin_path = os.path.join(self.package_folder, "lib", "gstreamer-1.0") + if self.options.shared: + self.output.info("Appending GST_PLUGIN_PATH env var : %s" % gst_plugin_path) + self.cpp_info.bindirs.append(gst_plugin_path) + self.runenv_info.prepend_path("GST_PLUGIN_PATH", gst_plugin_path) + self.env_info.GST_PLUGIN_PATH.append(gst_plugin_path) + else: + self.cpp_info.defines.append("GST_PLUGINS_GOOD_STATIC") + self.cpp_info.libdirs.append(gst_plugin_path) + self.cpp_info.libs.extend(["gst%s" % plugin for plugin in plugins]) + + self.cpp_info.includedirs = ["include", os.path.join("include", "gstreamer-1.0")] diff --git a/recipes/gst-plugins-good/all/test_package/CMakeLists.txt b/recipes/gst-plugins-good/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..12ca5f526ed07 --- /dev/null +++ b/recipes/gst-plugins-good/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gst-plugins-good CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} gst-plugins-good::gst-plugins-good) diff --git a/recipes/gst-plugins-good/all/test_package/conanfile.py b/recipes/gst-plugins-good/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/gst-plugins-good/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gst-plugins-good/all/test_package/test_package.cpp b/recipes/gst-plugins-good/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..bc7a25a413ef3 --- /dev/null +++ b/recipes/gst-plugins-good/all/test_package/test_package.cpp @@ -0,0 +1,34 @@ +#include +#include + +#ifdef GST_PLUGINS_GOOD_STATIC + +extern "C" +{ + GST_PLUGIN_STATIC_DECLARE(wavparse); +} + +#endif + +#include + +int main(int argc, char * argv[]) +{ + gst_init(&argc, &argv); + +#ifdef GST_PLUGINS_GOOD_STATIC + + GST_PLUGIN_STATIC_REGISTER(wavparse); + +#endif + + GstElement * wavparse = gst_element_factory_make("wavparse", NULL); + if (!wavparse) { + std::cerr << "failed to create wavparse element" << std::endl; + return -1; + } else { + std::cout << "wavparse has been created successfully" << std::endl; + } + gst_object_unref(GST_OBJECT(wavparse)); + return 0; +} diff --git a/recipes/gst-plugins-good/config.yml b/recipes/gst-plugins-good/config.yml new file mode 100644 index 0000000000000..e20650f02a0e5 --- /dev/null +++ b/recipes/gst-plugins-good/config.yml @@ -0,0 +1,3 @@ +versions: + "1.19.1": + folder: all diff --git a/recipes/gst-plugins-ugly/all/conandata.yml b/recipes/gst-plugins-ugly/all/conandata.yml new file mode 100644 index 0000000000000..a6f4354cc6a61 --- /dev/null +++ b/recipes/gst-plugins-ugly/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.19.1": + url: "https://gitlab.freedesktop.org/gstreamer/gst-plugins-ugly/-/archive/1.19.1/gst-plugins-ugly-1.19.1.tar.bz2" + sha256 : "b9ae94a04eaf9d93bc36500b3d7eda864f82142d2ce950c1e92a4288924227e6" diff --git a/recipes/gst-plugins-ugly/all/conanfile.py b/recipes/gst-plugins-ugly/all/conanfile.py new file mode 100644 index 0000000000000..b889700ec4e84 --- /dev/null +++ b/recipes/gst-plugins-ugly/all/conanfile.py @@ -0,0 +1,171 @@ +from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment +from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import msvc_runtime_flag +import glob +import os +import shutil + + +class GStPluginsUglyConan(ConanFile): + name = "gst-plugins-ugly" + description = "GStreamer is a development framework for creating applications like media players, video editors, " \ + "streaming media broadcasters and so on" + topics = ("gstreamer", "multimedia", "video", "audio", "broadcasting", "framework", "media") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gstreamer.freedesktop.org/" + license = "GPL-2.0-only" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_introspection": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_introspection": False, + } + _source_subfolder = "source_subfolder" + _build_subfolder = "build_subfolder" + exports_sources = ["patches/*.patch"] + + generators = "pkg_config" + + @property + def _is_msvc(self): + return self.settings.compiler == "Visual Studio" + + def validate(self): + if self.options.shared != self.options["gstreamer"].shared or \ + self.options.shared != self.options["glib"].shared or \ + self.options.shared != self.options["gst-plugins-base"].shared: + # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/133 + raise ConanInvalidConfiguration("GLib, GStreamer and GstPlugins must be either all shared, or all static") + if tools.Version(self.version) >= "1.18.2" and\ + self.settings.compiler == "gcc" and\ + tools.Version(self.settings.compiler.version) < "5": + raise ConanInvalidConfiguration( + "gst-plugins-ugly%s does not support gcc older than 5" % self.version + ) + if self.options.shared and str(msvc_runtime_flag(self)).startswith("MT"): + raise ConanInvalidConfiguration('shared build with static runtime is not supported due to the FlsAlloc limit') + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + self.options['gstreamer'].shared = self.options.shared + self.options['gst-plugins-base'].shared = self.options.shared + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def requirements(self): + self.requires("glib/2.70.1") + self.requires("gstreamer/1.19.1") + self.requires("gst-plugins-base/1.19.1") + + def build_requirements(self): + self.build_requires("meson/0.54.2") + if not tools.which("pkg-config"): + self.build_requires("pkgconf/1.7.4") + if self.settings.os == 'Windows': + self.build_requires("winflexbison/2.5.24") + else: + self.build_requires("bison/3.7.6") + self.build_requires("flex/2.6.4") + if self.options.with_introspection: + self.build_requires("gobject-introspection/1.68.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_meson(self): + defs = dict() + + def add_flag(name, value): + if name in defs: + defs[name] += " " + value + else: + defs[name] = value + + def add_compiler_flag(value): + add_flag("c_args", value) + add_flag("cpp_args", value) + + def add_linker_flag(value): + add_flag("c_link_args", value) + add_flag("cpp_link_args", value) + + meson = Meson(self) + if self.settings.compiler == "Visual Studio": + add_linker_flag("-lws2_32") + add_compiler_flag("-%s" % self.settings.compiler.runtime) + if int(str(self.settings.compiler.version)) < 14: + add_compiler_flag("-Dsnprintf=_snprintf") + if self.settings.get_safe("compiler.runtime"): + defs["b_vscrt"] = str(self.settings.compiler.runtime).lower() + defs["tools"] = "disabled" + defs["examples"] = "disabled" + defs["benchmarks"] = "disabled" + defs["tests"] = "disabled" + defs["wrap_mode"] = "nofallback" + defs["introspection"] = "enabled" if self.options.with_introspection else "disabled" + meson.configure(build_folder=self._build_subfolder, + source_folder=self._source_subfolder, + defs=defs) + return meson + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.build() + + def _fix_library_names(self, path): + # regression in 1.16 + if self.settings.compiler == "Visual Studio": + with tools.chdir(path): + for filename_old in glob.glob("*.a"): + filename_new = filename_old[3:-2] + ".lib" + self.output.info("rename %s into %s" % (filename_old, filename_new)) + shutil.move(filename_old, filename_new) + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): + meson = self._configure_meson() + meson.install() + + self._fix_library_names(os.path.join(self.package_folder, "lib")) + self._fix_library_names(os.path.join(self.package_folder, "lib", "gstreamer-1.0")) + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "gstreamer-1.0", "pkgconfig")) + tools.remove_files_by_mask(self.package_folder, "*.pdb") + + def package_info(self): + + plugins = ["asf", + "dvdlpcmdec", + "dvdsub", + "realmedia", + "xingmux"] + + gst_plugin_path = os.path.join(self.package_folder, "lib", "gstreamer-1.0") + if self.options.shared: + self.output.info("Appending GST_PLUGIN_PATH env var : %s" % gst_plugin_path) + self.cpp_info.bindirs.append(gst_plugin_path) + self.runenv_info.prepend_path("GST_PLUGIN_PATH", gst_plugin_path) + self.env_info.GST_PLUGIN_PATH.append(gst_plugin_path) + else: + self.cpp_info.defines.append("GST_PLUGINS_UGLY_STATIC") + self.cpp_info.libdirs.append(gst_plugin_path) + self.cpp_info.libs.extend(["gst%s" % plugin for plugin in plugins]) + + self.cpp_info.includedirs = ["include", os.path.join("include", "gstreamer-1.0")] diff --git a/recipes/gst-plugins-ugly/all/test_package/CMakeLists.txt b/recipes/gst-plugins-ugly/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..86125a5ca6402 --- /dev/null +++ b/recipes/gst-plugins-ugly/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(gst-plugins-ugly CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} gst-plugins-ugly::gst-plugins-ugly) diff --git a/recipes/gst-plugins-ugly/all/test_package/conanfile.py b/recipes/gst-plugins-ugly/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/gst-plugins-ugly/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gst-plugins-ugly/all/test_package/test_package.cpp b/recipes/gst-plugins-ugly/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..9824c176d4b22 --- /dev/null +++ b/recipes/gst-plugins-ugly/all/test_package/test_package.cpp @@ -0,0 +1,34 @@ +#include +#include + +#ifdef GST_PLUGINS_UGLY_STATIC + +extern "C" +{ + GST_PLUGIN_STATIC_DECLARE(asf); +} + +#endif + +#include + +int main(int argc, char * argv[]) +{ + gst_init(&argc, &argv); + +#ifdef GST_PLUGINS_UGLY_STATIC + + GST_PLUGIN_STATIC_REGISTER(asf); + +#endif + + GstElement * asfdemux = gst_element_factory_make("asfdemux", NULL); + if (!asfdemux) { + std::cerr << "failed to create asfdemux element" << std::endl; + return -1; + } else { + std::cout << "asfdemux has been created successfully" << std::endl; + } + gst_object_unref(GST_OBJECT(asfdemux)); + return 0; +} diff --git a/recipes/gst-plugins-ugly/config.yml b/recipes/gst-plugins-ugly/config.yml new file mode 100644 index 0000000000000..e20650f02a0e5 --- /dev/null +++ b/recipes/gst-plugins-ugly/config.yml @@ -0,0 +1,3 @@ +versions: + "1.19.1": + folder: all diff --git a/recipes/gstreamer/all/conandata.yml b/recipes/gstreamer/all/conandata.yml index aa42006a84c17..5c2457feed4e9 100644 --- a/recipes/gstreamer/all/conandata.yml +++ b/recipes/gstreamer/all/conandata.yml @@ -11,3 +11,9 @@ sources: "1.18.4": url: "https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/1.18.4/gstreamer-1.18.4.tar.gz" sha256: "f0956c2056281f5909d030945a9896810e55084f29b6bcfc401b53e91ddf1c7f" + "1.19.1": + url: "https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/1.19.1/gstreamer-1.19.1.tar.gz" + sha256: "2e51f61e59564e48883b5f1996871b0d1c404406aadb9aa1b306de8a2a331a90" + "1.19.2": + url: "https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/1.19.2/gstreamer-1.19.2.tar.gz" + sha256: "6ec8494867d9b58f145c0c357da631faf21c2c72c7cd8b637b440188fe904ab8" diff --git a/recipes/gstreamer/all/conanfile.py b/recipes/gstreamer/all/conanfile.py index d505f4e4580ff..f2f81654473da 100644 --- a/recipes/gstreamer/all/conanfile.py +++ b/recipes/gstreamer/all/conanfile.py @@ -1,4 +1,5 @@ from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment +from conans.errors import ConanInvalidConfiguration import glob import os import shutil @@ -13,8 +14,16 @@ class GStreamerConan(ConanFile): homepage = "https://gstreamer.freedesktop.org/" license = "GPL-2.0-only" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_introspection": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_introspection": False, + } generators = "pkg_config" _meson = None @@ -27,7 +36,7 @@ def _build_subfolder(self): return "build_subfolder" def requirements(self): - self.requires("glib/2.67.1") + self.requires("glib/2.72.0") @property def _is_msvc(self): @@ -43,13 +52,20 @@ def config_options(self): if self.settings.os == 'Windows': del self.options.fPIC + def validate(self): + if not self.options["glib"].shared and self.options.shared: + # https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/133 + raise ConanInvalidConfiguration("shared GStreamer cannot link to static GLib") + def build_requirements(self): - self.build_requires("meson/0.56.2") - self.build_requires("pkgconf/1.7.3") + self.build_requires("meson/0.61.2") + self.build_requires("pkgconf/1.7.4") + if self.options.with_introspection: + self.build_requires("gobject-introspection/1.70.0") if self.settings.os == 'Windows': - self.build_requires("winflexbison/2.5.22") + self.build_requires("winflexbison/2.5.24") else: - self.build_requires("bison/3.7.1") + self.build_requires("bison/3.7.6") self.build_requires("flex/2.6.4") def source(self): @@ -70,6 +86,7 @@ def _configure_meson(self): meson.options["examples"] = "disabled" meson.options["benchmarks"] = "disabled" meson.options["tests"] = "disabled" + meson.options["introspection"] = "enabled" if self.options.with_introspection else "disabled" meson.configure(build_folder=self._build_subfolder, source_folder=self._source_subfolder, args=['--wrap-mode=nofallback']) @@ -103,9 +120,25 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "share")) tools.remove_files_by_mask(self.package_folder, "*.pdb") + def package_id(self): + self.info.requires["glib"].full_package_mode() + def package_info(self): gst_plugin_path = os.path.join(self.package_folder, "lib", "gstreamer-1.0") + pkgconfig_variables = { + "exec_prefix": "${prefix}", + "toolsdir": "${exec_prefix}/bin", + "pluginsdir": "${libdir}/gstreamer-1.0", + "datarootdir": "${prefix}/share", + "datadir": "${datarootdir}", + "girdir": "${datadir}/gir-1.0", + "typelibdir": "${libdir}/girepository-1.0", + "libexecdir": "${prefix}/libexec", + "pluginscannerdir": "${libexecdir}/gstreamer-1.0", + } + pkgconfig_custom_content = "\n".join("{}={}".format(key, value) for key, value in pkgconfig_variables.items()) + self.cpp_info.components["gstreamer-1.0"].names["pkg_config"] = "gstreamer-1.0" self.cpp_info.components["gstreamer-1.0"].requires = ["glib::glib-2.0", "glib::gobject-2.0"] if not self.options.shared: @@ -113,26 +146,37 @@ def package_info(self): self.cpp_info.components["gstreamer-1.0"].defines.append("GST_STATIC_COMPILATION") self.cpp_info.components["gstreamer-1.0"].libs = ["gstreamer-1.0"] self.cpp_info.components["gstreamer-1.0"].includedirs = [os.path.join("include", "gstreamer-1.0")] + if self.settings.os == "Linux": + self.cpp_info.components["gstreamer-1.0"].system_libs = ["m"] + self.cpp_info.components["gstreamer-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) self.cpp_info.components["gstreamer-base-1.0"].names["pkg_config"] = "gstreamer-base-1.0" self.cpp_info.components["gstreamer-base-1.0"].requires = ["gstreamer-1.0"] self.cpp_info.components["gstreamer-base-1.0"].libs = ["gstbase-1.0"] self.cpp_info.components["gstreamer-base-1.0"].includedirs = [os.path.join("include", "gstreamer-1.0")] + self.cpp_info.components["gstreamer-base-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) self.cpp_info.components["gstreamer-controller-1.0"].names["pkg_config"] = "gstreamer-controller-1.0" self.cpp_info.components["gstreamer-controller-1.0"].requires = ["gstreamer-1.0"] self.cpp_info.components["gstreamer-controller-1.0"].libs = ["gstcontroller-1.0"] self.cpp_info.components["gstreamer-controller-1.0"].includedirs = [os.path.join("include", "gstreamer-1.0")] + if self.settings.os == "Linux": + self.cpp_info.components["gstreamer-controller-1.0"].system_libs = ["m"] + self.cpp_info.components["gstreamer-controller-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) self.cpp_info.components["gstreamer-net-1.0"].names["pkg_config"] = "gstreamer-net-1.0" self.cpp_info.components["gstreamer-net-1.0"].requires = ["gstreamer-1.0", "glib::gio-2.0"] self.cpp_info.components["gstreamer-net-1.0"].libs = ["gstnet-1.0"] self.cpp_info.components["gstreamer-net-1.0"].includedirs = [os.path.join("include", "gstreamer-1.0")] + self.cpp_info.components["gstreamer-net-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) self.cpp_info.components["gstreamer-check-1.0"].names["pkg_config"] = "gstreamer-check-1.0" self.cpp_info.components["gstreamer-check-1.0"].requires = ["gstreamer-1.0"] self.cpp_info.components["gstreamer-check-1.0"].libs = ["gstcheck-1.0"] self.cpp_info.components["gstreamer-check-1.0"].includedirs = [os.path.join("include", "gstreamer-1.0")] + if self.settings.os == "Linux": + self.cpp_info.components["gstreamer-check-1.0"].system_libs = ["rt", "m"] + self.cpp_info.components["gstreamer-check-1.0"].set_property("pkg_config_custom_content", pkgconfig_custom_content) # gstcoreelements and gstcoretracers are plugins which should be loaded dynamicaly, and not linked to directly if not self.options.shared: diff --git a/recipes/gstreamer/all/test_package/CMakeLists.txt b/recipes/gstreamer/all/test_package/CMakeLists.txt index 196188113685c..4e7b0a54031d8 100644 --- a/recipes/gstreamer/all/test_package/CMakeLists.txt +++ b/recipes/gstreamer/all/test_package/CMakeLists.txt @@ -1,8 +1,15 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +find_package(gstreamer REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} + gstreamer::gstreamer-1.0 gstreamer::gstreamer-base-1.0 gstreamer::gstreamer-controller-1.0 + gstreamer::gstreamer-net-1.0 gstreamer::gstreamer-check-1.0) +if (TARGET gstreamer::gstcoreelements) + target_link_libraries(${PROJECT_NAME} gstreamer::gstcoreelements) +endif () diff --git a/recipes/gstreamer/all/test_package/conanfile.py b/recipes/gstreamer/all/test_package/conanfile.py index bd7165a553cf4..49a3a66ea5bad 100644 --- a/recipes/gstreamer/all/test_package/conanfile.py +++ b/recipes/gstreamer/all/test_package/conanfile.py @@ -4,7 +4,7 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/gstreamer/all/test_package/test_package.c b/recipes/gstreamer/all/test_package/test_package.c new file mode 100644 index 0000000000000..910eb6a5fcf47 --- /dev/null +++ b/recipes/gstreamer/all/test_package/test_package.c @@ -0,0 +1,35 @@ +#include +#include +#include + +#ifdef GST_STATIC_COMPILATION +GST_PLUGIN_STATIC_DECLARE(coreelements); +#endif + +int main(int argc, char * argv[]) +{ + gst_init(&argc, &argv); + printf("GStreamer version: %s\n", gst_version_string()); + +#ifdef GST_STATIC_COMPILATION + GST_PLUGIN_STATIC_REGISTER(coreelements); +#endif + + GstElement * fakesink = gst_element_factory_make("fakesink", NULL); + if (!fakesink) { + printf("failed to create fakesink element\n"); + return EXIT_FAILURE; + } else { + printf("fakesink has been created successfully\n"); + } + gst_object_unref(GST_OBJECT(fakesink)); + GstElement * fakesrc = gst_element_factory_make("fakesrc", NULL); + if (!fakesrc) { + printf("failed to create fakesrc element\n"); + return EXIT_FAILURE; + } else { + printf("fakesrc has been created successfully\n"); + } + gst_object_unref(GST_OBJECT(fakesrc)); + return EXIT_SUCCESS; +} diff --git a/recipes/gstreamer/all/test_package/test_package.cpp b/recipes/gstreamer/all/test_package/test_package.cpp deleted file mode 100644 index 854fea9b4fc01..0000000000000 --- a/recipes/gstreamer/all/test_package/test_package.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include - -#ifdef GST_STATIC_COMPILATION - -extern "C" -{ - GST_PLUGIN_STATIC_DECLARE(coreelements); -} - -#endif - -int main(int argc, char * argv[]) -{ - gst_init(&argc, &argv); - std::cout << "GStreamer version: " << gst_version_string() << std::endl; - -#ifdef GST_STATIC_COMPILATION - - GST_PLUGIN_STATIC_REGISTER(coreelements); - -#endif - - GstElement * fakesink = gst_element_factory_make("fakesink", NULL); - if (!fakesink) { - std::cerr << "failed to create fakesink element" << std::endl; - return -1; - } else { - std::cout << "fakesink has been created successfully" << std::endl; - } - gst_object_unref(GST_OBJECT(fakesink)); - GstElement * fakesrc = gst_element_factory_make("fakesrc", NULL); - if (!fakesrc) { - std::cerr << "failed to create fakesrc element" << std::endl; - return -1; - } else { - std::cout << "fakesrc has been created successfully" << std::endl; - } - gst_object_unref(GST_OBJECT(fakesrc)); - return 0; -} diff --git a/recipes/gstreamer/config.yml b/recipes/gstreamer/config.yml index c153cab1145d5..e2a4a362c2d1c 100644 --- a/recipes/gstreamer/config.yml +++ b/recipes/gstreamer/config.yml @@ -7,3 +7,7 @@ versions: folder: all "1.18.4": folder: all + "1.19.1": + folder: all + "1.19.2": + folder: all diff --git a/recipes/gtest/all/CMakeLists.txt b/recipes/gtest/all/CMakeLists.txt deleted file mode 100644 index 85997b1584ee4..0000000000000 --- a/recipes/gtest/all/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() - -option(GTEST_NO_MAIN "Generate google main libraries" OFF) - -if(MSVC) - if(MSVC_VERSION AND MSVC_VERSION GREATER_EQUAL 1910) - add_definitions(-DGTEST_LANG_CXX11=1 -DGTEST_HAS_TR1_TUPLE=0) - endif(MSVC_VERSION AND MSVC_VERSION GREATER_EQUAL 1910) -endif(MSVC) - -add_subdirectory("source_subfolder") diff --git a/recipes/gtest/all/conandata.yml b/recipes/gtest/all/conandata.yml index eed122e278a00..57289aca6e374 100644 --- a/recipes/gtest/all/conandata.yml +++ b/recipes/gtest/all/conandata.yml @@ -1,22 +1,16 @@ sources: - "1.8.1": - url: "https://github.com/google/googletest/archive/release-1.8.1.tar.gz" - sha256: "9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c" + "1.12.1": + url: "https://github.com/google/googletest/archive/release-1.12.1.tar.gz" + sha256: "81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2" "1.10.0": url: "https://github.com/google/googletest/archive/release-1.10.0.tar.gz" sha256: "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb" - "cci.20210126": - url: "https://github.com/google/googletest/archive/273f8cb059a4e7b089731036392422b5ef489791.tar.gz" - sha256: "2937e96827aa44b291d42c4f0ffaa6a7637445822cf873d0fa6a889df84b8628" patches: - "1.8.1": - - patch_file: "patches/gtest-1.8.1.patch" - base_path: "source_subfolder" "1.10.0": - patch_file: "patches/gtest-1.10.0.patch" - base_path: "source_subfolder" + patch_description: "add CUSTOM_DEBUG_POSTFIX option" + patch_type: "conan" - patch_file: "patches/gtest-1.10.0-override.patch" - base_path: "source_subfolder" - "cci.20210126": - - patch_file: "patches/gtest-1.10.0.patch" - base_path: "source_subfolder" + patch_description: "prevent compiler from complaining while compiling" + patch_type: "backport" + patch_source: "https://github.com/google/googletest/pull/2507" diff --git a/recipes/gtest/all/conanfile.py b/recipes/gtest/all/conanfile.py index 625e7532cbae5..cdbad83c02fff 100644 --- a/recipes/gtest/all/conanfile.py +++ b/recipes/gtest/all/conanfile.py @@ -1,145 +1,189 @@ -import glob +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.53.0" class GTestConan(ConanFile): name = "gtest" description = "Google's C++ test framework" + license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/google/googletest" - license = "BSD-3-Clause" - topics = ("conan", "gtest", "testing", "google-testing", "unit-test") - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" + topics = ("testing", "google-testing", "unit-test") settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "build_gmock": [True, False], "fPIC": [True, False], "no_main": [True, False], "debug_postfix": "ANY", "hide_symbols": [True, False]} - default_options = {"shared": False, "build_gmock": True, "fPIC": True, "no_main": False, "debug_postfix": 'd', "hide_symbols": False} - _source_subfolder = "source_subfolder" + options = { + "shared": [True, False], + "fPIC": [True, False], + "build_gmock": [True, False], + "no_main": [True, False], + "hide_symbols": [True, False], + "debug_postfix": ["ANY"], + } + default_options = { + "shared": False, + "fPIC": True, + "build_gmock": True, + "no_main": False, + "hide_symbols": False, + "debug_postfix": "d", + } @property def _minimum_cpp_standard(self): - if self.version == "1.8.1": - return 98 - else: - return 11 + return 11 @property def _minimum_compilers_version(self): - if self.version == "1.8.1": - return { - "Visual Studio": "14" - } - elif self.version == "1.10.0": - return { - "Visual Studio": "14", - "gcc": "4.8.1", - "clang": "3.3", - "apple-clang": "5.0" - } - else: - return { - "Visual Studio": "14", - "gcc": "5", - "clang": "5", - "apple-clang": "9.1" - } - + return { + "Visual Studio": "14", + "msvc": "190", + "gcc": "4.8.1" if Version(self.version) < "1.11.0" else "5", + "clang": "3.3" if Version(self.version) < "1.11.0" else "5", + "apple-clang": "5.0" if Version(self.version) < "1.11.0" else "9.1", + } + @property - def _postfix(self): - return self.options.debug_postfix if self.settings.build_type == "Debug" else "" + def _is_clang_cl(self): + return self.settings.os == "Windows" and self.settings.compiler == "clang" + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if self.settings.build_type != "Debug": + if Version(self.version) >= "1.12.0" or self.settings.build_type != "Debug": del self.options.debug_postfix def configure(self): - if self.settings.get_safe("compiler.cppstd"): - tools.check_min_cppstd(self, self._minimum_cpp_standard) - min_version = self._minimum_compilers_version.get( - str(self.settings.compiler)) + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def package_id(self): + del self.info.options.no_main # Only used to expose more targets + + def validate(self): + if self.info.options.shared and (is_msvc(self) or self._is_clang_cl) and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "gtest:shared=True with compiler=\"Visual Studio\" is not " + "compatible with compiler.runtime=MT/MTd" + ) + + if self.info.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) - def lazy_lt_semver(v1, v2): + def loose_lt_semver(v1, v2): lv1 = [int(v) for v in v1.split(".")] lv2 = [int(v) for v in v2.split(".")] min_length = min(len(lv1), len(lv2)) return lv1[:min_length] < lv2[:min_length] - if not min_version: - self.output.warn("{} recipe lacks information about {} compiler support.".format( - self.name, self.settings.compiler)) - else: - if lazy_lt_semver(str(self.settings.compiler.version), min_version): - raise ConanInvalidConfiguration("{0} requires {1} {2}. The current compiler is {1} {3}.".format( - self.name, self.settings.compiler, min_version, self.settings.compiler.version)) + compiler = self.info.settings.compiler + min_version = self._minimum_compilers_version.get(str(compiler)) + if min_version and loose_lt_semver(str(compiler.version), min_version): + raise ConanInvalidConfiguration( + f"{self.ref} requires {compiler} {min_version}. The current compiler is {compiler} {compiler.version}." + ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("googletest-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - cmake = CMake(self) - if self.settings.build_type == "Debug": - cmake.definitions["CUSTOM_DEBUG_POSTFIX"] = self.options.debug_postfix - if self.settings.os == "Windows" and self.settings.get_safe("compiler.runtime"): - cmake.definitions["gtest_force_shared_crt"] = "MD" in str(self.settings.compiler.runtime) - cmake.definitions["BUILD_GMOCK"] = self.options.build_gmock - cmake.definitions["GTEST_NO_MAIN"] = self.options.no_main + def generate(self): + tc = CMakeToolchain(self) + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.variables["BUILD_GMOCK"] = bool(self.options.build_gmock) + tc.variables["gtest_hide_internal_symbols"] = bool(self.options.hide_symbols) + + if self.settings.build_type == "Debug" and Version(self.version) < "1.12.0": + tc.cache_variables["CUSTOM_DEBUG_POSTFIX"] = str(self.options.debug_postfix) + + if is_msvc(self) or self._is_clang_cl: + tc.variables["gtest_force_shared_crt"] = not is_msvc_static_runtime(self) if self.settings.os == "Windows" and self.settings.compiler == "gcc": - cmake.definitions["gtest_disable_pthreads"] = True - cmake.definitions["gtest_hide_internal_symbols"] = self.options.hide_symbols - cmake.configure() - return cmake + tc.variables["gtest_disable_pthreads"] = True + tc.generate() + + def _patch_sources(self): + internal_utils = os.path.join(self.source_folder, "googletest", + "cmake", "internal_utils.cmake") + apply_conandata_patches(self) + if Version(self.version) < "1.12.0": + replace_in_file(self, internal_utils, "-Werror", "") + + if is_msvc(self) or self._is_clang_cl: + # No warnings as errors + replace_in_file(self, internal_utils, "-WX", "") def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - for pdb_file in glob.glob(os.path.join(self.package_folder, "lib", "*.pdb")): - os.unlink(pdb_file) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) - def package_id(self): - del self.info.options.no_main + @property + def _postfix(self): + return self.options.get_safe("debug_postfix", "") def package_info(self): - self.cpp_info.names["cmake_find_package"] = "GTest" - self.cpp_info.names["cmake_find_package_multi"] = "GTest" - self.cpp_info.components["libgtest"].names["cmake_find_package"] = "gtest" - self.cpp_info.components["libgtest"].names["cmake_find_package_multi"] = "gtest" - self.cpp_info.components["libgtest"].libs = ["gtest{}".format(self._postfix)] - if self.settings.os == "Linux": + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "GTest") + + # gtest + self.cpp_info.components["libgtest"].set_property("cmake_target_name", "GTest::gtest") + self.cpp_info.components["libgtest"].set_property("cmake_target_aliases", ["GTest::GTest"]) + self.cpp_info.components["libgtest"].set_property("pkg_config_name", "gtest") + self.cpp_info.components["libgtest"].libs = [f"gtest{self._postfix}"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["libgtest"].system_libs.append("m") self.cpp_info.components["libgtest"].system_libs.append("pthread") - if self.settings.os == "Neutrino" and self.settings.os.version == "7.1": self.cpp_info.components["libgtest"].system_libs.append("regex") - if self.options.shared: self.cpp_info.components["libgtest"].defines.append("GTEST_LINKED_AS_SHARED_LIBRARY=1") - if self.settings.compiler == "Visual Studio": - if tools.Version(self.settings.compiler.version.value) >= "15": - self.cpp_info.components["libgtest"].defines.append("GTEST_LANG_CXX11=1") - self.cpp_info.components["libgtest"].defines.append("GTEST_HAS_TR1_TUPLE=0") - + # gtest_main if not self.options.no_main: - self.cpp_info.components["gtest_main"].libs = ["gtest_main{}".format(self._postfix)] + self.cpp_info.components["gtest_main"].set_property("cmake_target_name", "GTest::gtest_main") + self.cpp_info.components["gtest_main"].set_property("cmake_target_aliases", ["GTest::Main"]) + self.cpp_info.components["gtest_main"].set_property("pkg_config_name", "gtest_main") + self.cpp_info.components["gtest_main"].libs = [f"gtest_main{self._postfix}"] self.cpp_info.components["gtest_main"].requires = ["libgtest"] + # gmock if self.options.build_gmock: - self.cpp_info.components["gmock"].libs = ["gmock{}".format(self._postfix)] + self.cpp_info.components["gmock"].set_property("cmake_target_name", "GTest::gmock") + self.cpp_info.components["gmock"].set_property("pkg_config_name", "gmock") + self.cpp_info.components["gmock"].libs = [f"gmock{self._postfix}"] self.cpp_info.components["gmock"].requires = ["libgtest"] + + # gmock_main if not self.options.no_main: - self.cpp_info.components["gmock_main"].libs = ["gmock_main{}".format(self._postfix)] + self.cpp_info.components["gmock_main"].set_property("cmake_target_name", "GTest::gmock_main") + self.cpp_info.components["gmock_main"].set_property("pkg_config_name", "gmock_main") + self.cpp_info.components["gmock_main"].libs = [f"gmock_main{self._postfix}"] self.cpp_info.components["gmock_main"].requires = ["gmock"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "GTest" + self.cpp_info.names["cmake_find_package_multi"] = "GTest" + self.cpp_info.components["libgtest"].names["cmake_find_package"] = "gtest" + self.cpp_info.components["libgtest"].names["cmake_find_package_multi"] = "gtest" diff --git a/recipes/gtest/all/patches/gtest-1.8.1.patch b/recipes/gtest/all/patches/gtest-1.8.1.patch deleted file mode 100644 index 838ab42c89f02..0000000000000 --- a/recipes/gtest/all/patches/gtest-1.8.1.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake -index 8c1f9ba..2203d3c 100644 ---- a/googletest/cmake/internal_utils.cmake -+++ b/googletest/cmake/internal_utils.cmake -@@ -166,7 +166,7 @@ function(cxx_library_with_type name type cxx_flags) - # Generate debug library name with a postfix. - set_target_properties(${name} - PROPERTIES -- DEBUG_POSTFIX "d") -+ DEBUG_POSTFIX "${CUSTOM_DEBUG_POSTFIX}") - if (BUILD_SHARED_LIBS OR type STREQUAL "SHARED") - set_target_properties(${name} - PROPERTIES diff --git a/recipes/gtest/all/test_package/CMakeLists.txt b/recipes/gtest/all/test_package/CMakeLists.txt index 22f7c7cc80581..b62a59b30f394 100644 --- a/recipes/gtest/all/test_package/CMakeLists.txt +++ b/recipes/gtest/all/test_package/CMakeLists.txt @@ -1,30 +1,22 @@ -cmake_minimum_required(VERSION 3.1.2) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(GTest REQUIRED) -if(WITH_MAIN) - add_executable(${PROJECT_NAME} test_package.cpp) -else() - add_executable(${PROJECT_NAME} main.cpp test_package.cpp) -endif() +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gtest) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) if(WITH_MAIN) - target_link_libraries(${PROJECT_NAME} GTest::gtest GTest::gtest_main ) + target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gtest_main) if(WITH_GMOCK) - target_link_libraries(${PROJECT_NAME} GTest::gmock GTest::gmock_main) + target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gmock_main) endif() else() - target_link_libraries(${PROJECT_NAME} GTest::gtest) - if(WITH_GMOCK) - target_link_libraries(${PROJECT_NAME} GTest::gmock) - endif() + target_sources(${PROJECT_NAME} PRIVATE main.cpp) endif() -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) if(WITH_GMOCK) + target_link_libraries(${PROJECT_NAME} PRIVATE GTest::gmock) target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_GMOCK) endif() diff --git a/recipes/gtest/all/test_package/conanfile.py b/recipes/gtest/all/test_package/conanfile.py index 02131a8592414..1bddd2ba2988a 100644 --- a/recipes/gtest/all/test_package/conanfile.py +++ b/recipes/gtest/all/test_package/conanfile.py @@ -1,22 +1,38 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- import os -from conans import ConanFile, CMake, tools + +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + + with_gmock = bool(self.dependencies[self.tested_reference_str].options.build_gmock) + tc.cache_variables['WITH_GMOCK'] = with_gmock + if with_gmock: + tc.preprocessor_definitions['WITH_GMOCK'] = 1 + + tc.variables['WITH_MAIN'] = not bool(self.dependencies[self.tested_reference_str].options.no_main) + tc.generate() def build(self): cmake = CMake(self) - cmake.definitions['WITH_GMOCK'] = self.options['gtest'].build_gmock - cmake.definitions['WITH_MAIN'] = not self.options['gtest'].no_main cmake.configure() cmake.build() def test(self): - assert os.path.isfile(os.path.join(self.deps_cpp_info["gtest"].rootpath, "licenses", "LICENSE")) - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gtest/all/test_package/prime_tables.h b/recipes/gtest/all/test_package/prime_tables.h deleted file mode 100644 index 55a3b44efd857..0000000000000 --- a/recipes/gtest/all/test_package/prime_tables.h +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2008 Google Inc. -// All Rights Reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) -// Author: vladl@google.com (Vlad Losev) - -// This provides interface PrimeTable that determines whether a number is a -// prime and determines a next prime number. This interface is used -// in Google Test samples demonstrating use of parameterized tests. - -#ifndef GTEST_SAMPLES_PRIME_TABLES_H_ -#define GTEST_SAMPLES_PRIME_TABLES_H_ - -#include - -// The prime table interface. -class PrimeTable { - public: - virtual ~PrimeTable() {} - - // Returns true iff n is a prime number. - virtual bool IsPrime(int n) const = 0; - - // Returns the smallest prime number greater than p; or returns -1 - // if the next prime is beyond the capacity of the table. - virtual int GetNextPrime(int p) const = 0; -}; - -// Implementation #1 calculates the primes on-the-fly. -class OnTheFlyPrimeTable : public PrimeTable { - public: - virtual bool IsPrime(int n) const { - if (n <= 1) return false; - - for (int i = 2; i*i <= n; i++) { - // n is divisible by an integer other than 1 and itself. - if ((n % i) == 0) return false; - } - - return true; - } - - virtual int GetNextPrime(int p) const { - for (int n = p + 1; n > 0; n++) { - if (IsPrime(n)) return n; - } - - return -1; - } -}; - -// Implementation #2 pre-calculates the primes and stores the result -// in an array. -class PreCalculatedPrimeTable : public PrimeTable { - public: - // 'max' specifies the maximum number the prime table holds. - explicit PreCalculatedPrimeTable(int max) - : is_prime_size_(max + 1), is_prime_(new bool[max + 1]) { - CalculatePrimesUpTo(max); - } - virtual ~PreCalculatedPrimeTable() { delete[] is_prime_; } - - virtual bool IsPrime(int n) const { - return 0 <= n && n < is_prime_size_ && is_prime_[n]; - } - - virtual int GetNextPrime(int p) const { - for (int n = p + 1; n < is_prime_size_; n++) { - if (is_prime_[n]) return n; - } - - return -1; - } - - private: - void CalculatePrimesUpTo(int max) { - ::std::fill(is_prime_, is_prime_ + is_prime_size_, true); - is_prime_[0] = is_prime_[1] = false; - - // Checks every candidate for prime number (we know that 2 is the only even - // prime). - for (int i = 2; i*i <= max; i += i%2+1) { - if (!is_prime_[i]) continue; - - // Marks all multiples of i (except i itself) as non-prime. - // We are starting here from i-th multiplier, because all smaller - // complex numbers were already marked. - for (int j = i*i; j <= max; j += i) { - is_prime_[j] = false; - } - } - } - - const int is_prime_size_; - bool* const is_prime_; - - // Disables compiler warning "assignment operator could not be generated." - void operator=(const PreCalculatedPrimeTable& rhs); -}; - -#endif // GTEST_SAMPLES_PRIME_TABLES_H_ diff --git a/recipes/gtest/all/test_package/test_package.cpp b/recipes/gtest/all/test_package/test_package.cpp index 4a1f9d2acf990..36d68c62eb3c5 100644 --- a/recipes/gtest/all/test_package/test_package.cpp +++ b/recipes/gtest/all/test_package/test_package.cpp @@ -50,138 +50,3 @@ TEST(SalutationTest, Static) { EXPECT_EQ(string("Hello World!"), Salutation::greet("World")); } - -#if GTEST_HAS_COMBINE -#include "prime_tables.h" - -// Suppose we want to introduce a new, improved implementation of PrimeTable -// which combines speed of PrecalcPrimeTable and versatility of -// OnTheFlyPrimeTable (see prime_tables.h). Inside it instantiates both -// PrecalcPrimeTable and OnTheFlyPrimeTable and uses the one that is more -// appropriate under the circumstances. But in low memory conditions, it can be -// told to instantiate without PrecalcPrimeTable instance at all and use only -// OnTheFlyPrimeTable. -class HybridPrimeTable : public PrimeTable { - public: - HybridPrimeTable(bool force_on_the_fly, int max_precalculated) - : on_the_fly_impl_(new OnTheFlyPrimeTable), - precalc_impl_(force_on_the_fly ? NULL : - new PreCalculatedPrimeTable(max_precalculated)), - max_precalculated_(max_precalculated) {} - virtual ~HybridPrimeTable() { - delete on_the_fly_impl_; - delete precalc_impl_; - } - - virtual bool IsPrime(int n) const { - if (precalc_impl_ != NULL && n < max_precalculated_) - return precalc_impl_->IsPrime(n); - else - return on_the_fly_impl_->IsPrime(n); - } - - virtual int GetNextPrime(int p) const { - int next_prime = -1; - if (precalc_impl_ != NULL && p < max_precalculated_) - next_prime = precalc_impl_->GetNextPrime(p); - - return next_prime != -1 ? next_prime : on_the_fly_impl_->GetNextPrime(p); - } - - private: - OnTheFlyPrimeTable* on_the_fly_impl_; - PreCalculatedPrimeTable* precalc_impl_; - int max_precalculated_; -}; - -using ::testing::TestWithParam; -using ::testing::Bool; -using ::testing::Values; -using ::testing::Combine; - -// To test all code paths for HybridPrimeTable we must test it with numbers -// both within and outside PreCalculatedPrimeTable's capacity and also with -// PreCalculatedPrimeTable disabled. We do this by defining fixture which will -// accept different combinations of parameters for instantiating a -// HybridPrimeTable instance. -class PrimeTableTest : public TestWithParam< ::testing::tuple > { - protected: - virtual void SetUp() { - // This can be written as - // - // bool force_on_the_fly; - // int max_precalculated; - // tie(force_on_the_fly, max_precalculated) = GetParam(); - // - // once the Google C++ Style Guide allows use of ::std::tr1::tie. - // - bool force_on_the_fly = ::testing::get<0>(GetParam()); - int max_precalculated = ::testing::get<1>(GetParam()); - table_ = new HybridPrimeTable(force_on_the_fly, max_precalculated); - } - virtual void TearDown() { - delete table_; - table_ = NULL; - } - HybridPrimeTable* table_; -}; - -TEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) { - // Inside the test body, you can refer to the test parameter by GetParam(). - // In this case, the test parameter is a PrimeTable interface pointer which - // we can use directly. - // Please note that you can also save it in the fixture's SetUp() method - // or constructor and use saved copy in the tests. - - EXPECT_FALSE(table_->IsPrime(-5)); - EXPECT_FALSE(table_->IsPrime(0)); - EXPECT_FALSE(table_->IsPrime(1)); - EXPECT_FALSE(table_->IsPrime(4)); - EXPECT_FALSE(table_->IsPrime(6)); - EXPECT_FALSE(table_->IsPrime(100)); -} - -TEST_P(PrimeTableTest, ReturnsTrueForPrimes) { - EXPECT_TRUE(table_->IsPrime(2)); - EXPECT_TRUE(table_->IsPrime(3)); - EXPECT_TRUE(table_->IsPrime(5)); - EXPECT_TRUE(table_->IsPrime(7)); - EXPECT_TRUE(table_->IsPrime(11)); - EXPECT_TRUE(table_->IsPrime(131)); -} - -TEST_P(PrimeTableTest, CanGetNextPrime) { - EXPECT_EQ(2, table_->GetNextPrime(0)); - EXPECT_EQ(3, table_->GetNextPrime(2)); - EXPECT_EQ(5, table_->GetNextPrime(3)); - EXPECT_EQ(7, table_->GetNextPrime(5)); - EXPECT_EQ(11, table_->GetNextPrime(7)); - EXPECT_EQ(131, table_->GetNextPrime(128)); -} - -// In order to run value-parameterized tests, you need to instantiate them, -// or bind them to a list of values which will be used as test parameters. -// You can instantiate them in a different translation module, or even -// instantiate them several times. -// -// Here, we instantiate our tests with a list of parameters. We must combine -// all variations of the boolean flag suppressing PrecalcPrimeTable and some -// meaningful values for tests. We choose a small value (1), and a value that -// will put some of the tested numbers beyond the capability of the -// PrecalcPrimeTable instance and some inside it (10). Combine will produce all -// possible combinations. -INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters, - PrimeTableTest, - Combine(Bool(), Values(1, 10))); - -#else - -// Google Test may not support Combine() with some compilers. If we -// use conditional compilation to compile out all code referring to -// the gtest_main library, MSVC linker will not link that library at -// all and consequently complain about missing entry point defined in -// that library (fatal error LNK1561: entry point must be -// defined). This dummy test keeps gtest_main linked in. -TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {} - -#endif // GTEST_HAS_COMBINE diff --git a/recipes/gtest/all/test_v1_package/CMakeLists.txt b/recipes/gtest/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/gtest/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/gtest/all/test_v1_package/conanfile.py b/recipes/gtest/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..1490f15fbb3c6 --- /dev/null +++ b/recipes/gtest/all/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +import os + +from conan.tools.build import cross_building +from conans import ConanFile, CMake + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.definitions['WITH_GMOCK'] = self.options['gtest'].build_gmock + cmake.definitions['WITH_MAIN'] = not self.options['gtest'].no_main + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gtest/config.yml b/recipes/gtest/config.yml index ef88df4e76413..0ca5dd0b1675e 100644 --- a/recipes/gtest/config.yml +++ b/recipes/gtest/config.yml @@ -1,7 +1,5 @@ versions: - "1.8.1": + "1.12.1": folder: all "1.10.0": folder: all - "cci.20210126": - folder: all diff --git a/recipes/gtk-doc-stub/all/conandata.yml b/recipes/gtk-doc-stub/all/conandata.yml new file mode 100644 index 0000000000000..f0e15055fe310 --- /dev/null +++ b/recipes/gtk-doc-stub/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "cci.20181216": + url: "https://gitlab.gnome.org/GNOME/gtk-doc-stub/-/archive/d26c9b8343540661080eccbff393ee5709a673f4/gtk-doc-stub-d26c9b8343540661080eccbff393ee5709a673f4.tar.gz" + sha256: "50da38b540d9cf8a865b4c9a10d45f09471d29f7dd946dd63cfc94b44fee8479" +patches: + "cci.20181216": + - patch_file: "patches/0001-relocatable-gtkdocize.patch" + base_path: "source_subfolder" diff --git a/recipes/gtk-doc-stub/all/conanfile.py b/recipes/gtk-doc-stub/all/conanfile.py new file mode 100644 index 0000000000000..dc86c338bb133 --- /dev/null +++ b/recipes/gtk-doc-stub/all/conanfile.py @@ -0,0 +1,65 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +import functools +import os + +required_conan_version = ">=1.33.0" + + +class GtkDocStubConan(ConanFile): + name = "gtk-doc-stub" + homepage = "https://gitlab.gnome.org/GNOME/gtk-doc-stub" + description = "Helper scripts for generating GTK documentation" + url = "https://github.com/conan-io/conan-center-index" + license = "GPL-2.0-or-later" + topics = ("gtk", "documentation", "gtkdocize") + settings = "os" + + exports_sources = "patches/*" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_autotools(self): + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + args = [ + "--datadir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), + "--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), + ] + autotools.configure(args=args, configure_dir=self._source_subfolder) + return autotools + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + autotools = self._configure_autotools() + autotools.install() + + def package_info(self): + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = ["res"] + + automake_dir = tools.unix_path(os.path.join(self.package_folder, "res", "aclocal")) + self.output.info("Appending AUTOMAKE_CONAN_INCLUDES environment variable: {}".format(automake_dir)) + self.env_info.AUTOMAKE_CONAN_INCLUDES.append(automake_dir) diff --git a/recipes/gtk-doc-stub/all/patches/0001-relocatable-gtkdocize.patch b/recipes/gtk-doc-stub/all/patches/0001-relocatable-gtkdocize.patch new file mode 100644 index 0000000000000..c9e5d61667830 --- /dev/null +++ b/recipes/gtk-doc-stub/all/patches/0001-relocatable-gtkdocize.patch @@ -0,0 +1,15 @@ +--- gtkdocize.in ++++ gtkdocize.in +@@ -6,9 +6,9 @@ + PACKAGE=gtk-doc + VERSION=1.1000 + +-prefix=@prefix@ +-datarootdir=@datarootdir@ +-datadir=@datadir@ ++SCRIPT_HOME=`dirname $0 | while read a; do cd $a && pwd && break; done` ++datarootdir=$SCRIPT_HOME/../res ++datadir=$datarootdir + + # options + copy=no diff --git a/recipes/gtk-doc-stub/all/test_package/conanfile.py b/recipes/gtk-doc-stub/all/test_package/conanfile.py new file mode 100644 index 0000000000000..9346d5cf9cd7a --- /dev/null +++ b/recipes/gtk-doc-stub/all/test_package/conanfile.py @@ -0,0 +1,37 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +import os +import shutil + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + exports_sources = "configure.ac", + test_type = "explicit" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + self.build_requires("automake/1.16.4") + + def build(self): + for src in self.exports_sources: + shutil.copy(os.path.join(self.source_folder, src), + os.path.join(self.build_folder, src)) + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), run_environment=True, win_bash=tools.os_info.is_windows) + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + args = [ + "--enable-option-checking=fatal", + "--enable-gtk-doc=no", + ] + autotools.configure(args=args) + + def test(self): + self.run("gtkdocize --copy", run_environment=True, win_bash=tools.os_info.is_windows) diff --git a/recipes/gtk-doc-stub/all/test_package/configure.ac b/recipes/gtk-doc-stub/all/test_package/configure.ac new file mode 100644 index 0000000000000..1764b280fd98b --- /dev/null +++ b/recipes/gtk-doc-stub/all/test_package/configure.ac @@ -0,0 +1,7 @@ +AC_INIT([test_package], [1.0]) + +AC_CONFIG_SRCDIR([configure.ac]) + +GTK_DOC_CHECK + +AC_OUTPUT diff --git a/recipes/gtk-doc-stub/config.yml b/recipes/gtk-doc-stub/config.yml new file mode 100644 index 0000000000000..4d27ee8819880 --- /dev/null +++ b/recipes/gtk-doc-stub/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20181216": + folder: "all" diff --git a/recipes/gtk/all/conandata.yml b/recipes/gtk/all/conandata.yml index abe622f66ed0d..2fd377b60695c 100644 --- a/recipes/gtk/all/conandata.yml +++ b/recipes/gtk/all/conandata.yml @@ -1,4 +1,19 @@ sources: + "4.7.0": + sha256: "913fcd9d065efb348723e18c3b9113e23b92072e927ebd2f61d32745c8228b94" + url: "https://download.gnome.org/sources/gtk/4.7/gtk-4.7.0.tar.xz" + "4.6.2": + url: "https://download.gnome.org/sources/gtk/4.6/gtk-4.6.2.tar.xz" + sha256: "ff263af609a50eb76056653592d929459aef4819a444c436f6d52c6f63c1faec" + "4.4.0": + url: "https://download.gnome.org/sources/gtk/4.4/gtk-4.4.0.tar.xz" + sha256: "e0a1508f441686c3a20dfec48af533b19a4b2e017c18eaee31dccdb7d292505b" + "4.3.2": + url: "https://download.gnome.org/sources/gtk/4.3/gtk-4.3.2.tar.xz" + sha256: "20639bb2be8b9f58304f14480e3d957abd2c9fa3f671bb7e05193f9a8389d93f" + "4.2.1": + url: "https://download.gnome.org/sources/gtk/4.2/gtk-4.2.1.tar.xz" + sha256: "023169775de43f0a1fde066fbc19d78545ea6a7562c1915abde9b8ae4a7309e6" "4.1.2": url: "https://download.gnome.org/sources/gtk/4.1/gtk-4.1.2.tar.xz" sha256: "33407da437c5e5ac09e7a463ba3bd025da3d80ba1953b8bbe2bce97dd2609677" @@ -8,3 +23,19 @@ sources: "3.24.24": url: "https://download.gnome.org/sources/gtk+/3.24/gtk+-3.24.24.tar.xz" sha256: "cc9d4367c55b724832f6b09ab85481738ea456871f0381768a6a99335a98378a" +patches: + "4.4.0": + - patch_file: "patches/0001-fix-UAC-manifest-rc.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-fix-version-resource-for-Windows-11-sdk.patch" + base_path: "source_subfolder" + "4.3.2": + - patch_file: "patches/0001-fix-UAC-manifest-rc.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-fix-version-resource-for-Windows-11-sdk.patch" + base_path: "source_subfolder" + "4.2.1": + - patch_file: "patches/0001-fix-UAC-manifest-rc.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-fix-version-resource-for-Windows-11-sdk.patch" + base_path: "source_subfolder" diff --git a/recipes/gtk/all/conanfile.py b/recipes/gtk/all/conanfile.py index 551b6c0162419..3d742625f585d 100644 --- a/recipes/gtk/all/conanfile.py +++ b/recipes/gtk/all/conanfile.py @@ -8,7 +8,7 @@ class GtkConan(ConanFile): name = "gtk" description = "libraries used for creating graphical user interfaces for applications." - topics = ("conan", "gtk", "widgets") + topics = ("gtk", "widgets") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.gtk.org" license = "LGPL-2.1-or-later" @@ -20,14 +20,25 @@ class GtkConan(ConanFile): "fPIC": [True, False], "with_wayland": [True, False], "with_x11": [True, False], - "with_pango": [True, False] + "with_pango": [True, False], + "with_ffmpeg": [True, False], + "with_gstreamer": [True, False], + "with_cups": [True, False], + "with_cloudprint": [True, False] } default_options = { "shared": False, "fPIC": True, "with_wayland": False, "with_x11": True, - "with_pango": True} + "with_pango": True, + "with_ffmpeg": False, + "with_gstreamer": False, + "with_cups": False, + "with_cloudprint": False + } + + short_paths = True @property def _source_subfolder(self): @@ -40,14 +51,26 @@ def _build_subfolder(self): @property def _gtk4(self): return tools.Version("4.0.0") <= tools.Version(self.version) < tools.Version("5.0.0") - @property + @property def _gtk3(self): return tools.Version("3.0.0") <= tools.Version(self.version) < tools.Version("4.0.0") + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + # Fix duplicate definitions of DllMain + self.options["gdk-pixbuf"].shared = True + # Fix segmentation fault + self.options["cairo"].shared = True + if tools.Version(self.version) >= "4.1.0": + # The upstream meson file does not create a static library + # See https://github.com/GNOME/gtk/commit/14f0a0addb9a195bad2f8651f93b95450b186bd6 + self.options.shared = True if self.settings.os != "Linux": del self.options.with_wayland del self.options.with_x11 @@ -55,6 +78,16 @@ def config_options(self): def validate(self): if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5": raise ConanInvalidConfiguration("this recipes does not support GCC before version 5. contributions are welcome") + if str(self.settings.compiler) in ["Visual Studio", "msvc"]: + if tools.Version(self.version) < "4.2": + raise ConanInvalidConfiguration("MSVC support of this recipe requires at least gtk/4.2") + if not self.options["gdk-pixbuf"].shared: + raise ConanInvalidConfiguration("MSVC build requires shared gdk-pixbuf") + if not self.options["cairo"].shared: + raise ConanInvalidConfiguration("MSVC build requires shared cairo") + if tools.Version(self.version) >= "4.1.0": + if not self.options.shared: + raise ConanInvalidConfiguration("gtk supports only shared since 4.1.0") def configure(self): if self.options.shared: @@ -65,38 +98,46 @@ def configure(self): if self.options.with_wayland or self.options.with_x11: if not self.options.with_pango: raise ConanInvalidConfiguration("with_pango option is mandatory when with_wayland or with_x11 is used") - if self.settings.os == "Windows": - raise ConanInvalidConfiguration("GTK recipe is not yet compatible with Windows. Contributions are welcome.") def build_requirements(self): - self.build_requires("meson/0.57.1") - self.build_requires("pkgconf/1.7.3") + self.build_requires("meson/0.62.2") + if self._gtk4: + self.build_requires("libxml2/2.9.14") # for xmllint + self.build_requires("pkgconf/1.7.4") if self._gtk4: - self.build_requires("sassc/3.6.1") + self.build_requires("sassc/3.6.2") def requirements(self): - self.requires("gdk-pixbuf/2.42.4") - self.requires("glib/2.68.0") - if self.settings.compiler != "Visual Studio": + self.requires("gdk-pixbuf/2.42.6") + self.requires("glib/2.73.0") + if self._gtk4 or self.settings.compiler != "Visual Studio": self.requires("cairo/1.17.4") if self._gtk4: - self.requires("graphene/1.10.4") + self.requires("graphene/1.10.8") + self.requires("fribidi/1.0.12") + self.requires("libpng/1.6.37") + self.requires("libtiff/4.3.0") + self.requires("libjpeg/9d") if self.settings.os == "Linux": if self._gtk4: - self.requires("xkbcommon/1.1.0") + self.requires("xkbcommon/1.4.1") if self._gtk3: self.requires("at-spi2-atk/2.38.0") if self.options.with_wayland: if self._gtk3: - self.requires("xkbcommon/1.1.0") - self.requires("wayland/1.19.0") + self.requires("xkbcommon/1.4.1") + self.requires("wayland/1.20.0") if self.options.with_x11: self.requires("xorg/system") if self._gtk3: - self.requires("atk/2.36.0") - self.requires("libepoxy/1.5.5") + self.requires("atk/2.38.0") + self.requires("libepoxy/1.5.10") if self.options.with_pango: - self.requires("pango/1.48.3") + self.requires("pango/1.50.7") + if self.options.with_ffmpeg: + self.requires("ffmpeg/5.0") + if self.options.with_gstreamer: + self.requires("gstreamer/1.19.2") def source(self): tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) @@ -108,22 +149,40 @@ def _configure_meson(self): defs["wayland_backend" if self._gtk3 else "wayland-backend"] = "true" if self.options.with_wayland else "false" defs["x11_backend" if self._gtk3 else "x11-backend"] = "true" if self.options.with_x11 else "false" defs["introspection"] = "false" if self._gtk3 else "disabled" - defs["documentation"] = "false" - defs["man-pages"] = "false" + defs["gtk_doc"] = "false" + defs["man-pages" if self._gtk4 else "man"] = "false" defs["tests" if self._gtk3 else "build-tests"] = "false" defs["examples" if self._gtk3 else "build-examples"] = "false" defs["demos"] = "false" defs["datadir"] = os.path.join(self.package_folder, "res", "share") defs["localedir"] = os.path.join(self.package_folder, "res", "share", "locale") defs["sysconfdir"] = os.path.join(self.package_folder, "res", "etc") + + if self._gtk4: + enabled_disabled = lambda opt : "enabled" if opt else "disabled" + defs["media-ffmpeg"] = enabled_disabled(self.options.with_ffmpeg) + defs["media-gstreamer"] = enabled_disabled(self.options.with_gstreamer) + defs["print-cups"] = enabled_disabled(self.options.with_cups) + if tools.Version(self.version) < "4.3.2": + defs["print-cloudprint"] = enabled_disabled(self.options.with_cloudprint) args=[] args.append("--wrap-mode=nofallback") meson.configure(defs=defs, build_folder=self._build_subfolder, source_folder=self._source_subfolder, pkg_config_paths=[self.install_folder], args=args) return meson def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) if self._gtk3: tools.replace_in_file(os.path.join(self._source_subfolder, "meson.build"), "\ntest(\n", "\nfalse and test(\n") + if "4.2.0" <= tools.Version(self.version) < "4.6.1": + tools.replace_in_file(os.path.join(self._source_subfolder, "meson.build"), + "gtk_update_icon_cache: true", + "gtk_update_icon_cache: false") + if "4.6.2" <= tools.Version(self.version): + tools.replace_in_file(os.path.join(self._source_subfolder, "meson.build"), + "dependency(is_msvc_like ? ", + "dependency(false ? ") with tools.environment_append(tools.RunEnvironment(self).vars): meson = self._configure_meson() meson.build() @@ -138,6 +197,8 @@ def package(self): self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses") tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.pdb") def package_info(self): if self._gtk3: diff --git a/recipes/gtk/all/patches/0001-fix-UAC-manifest-rc.patch b/recipes/gtk/all/patches/0001-fix-UAC-manifest-rc.patch new file mode 100644 index 0000000000000..7994c91a214fc --- /dev/null +++ b/recipes/gtk/all/patches/0001-fix-UAC-manifest-rc.patch @@ -0,0 +1,36 @@ +From 53705a537c1aa51ffbecfaaf685501b9ea1cb6ba Mon Sep 17 00:00:00 2001 +From: Chun-wei Fan +Date: Wed, 13 Oct 2021 12:17:44 +0800 +Subject: [PATCH] tools/generate-uac-manifest.py: Fix UAC manifest .rc + +The resource compiler in the Windows 11 SDK does not allow one to include +winuser.h directly in resource scripts (.rc) with a rather cryptic error +message, so fix generating the .rc file to embed the UAC manifest by including +windows.h with WIN32_LEAN_AND_MEAN instead. +--- + tools/generate-uac-manifest.py | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/tools/generate-uac-manifest.py b/tools/generate-uac-manifest.py +index ede6ba5044..62f063a8bb 100644 +--- a/tools/generate-uac-manifest.py ++++ b/tools/generate-uac-manifest.py +@@ -24,7 +24,7 @@ def main(): + help='require admin access to application') + parser.add_argument('--input-resource-file', dest='resource', + default=None, +- help='existing .rc file to embed UAC manifest (do not generate a new .rc file), must have included winuser.h in it') ++ help='existing .rc file to embed UAC manifest (do not generate a new .rc file), must have included windows.h in it') + parser.add_argument('--output-dir', dest='outdir', + default=None, + help='directory to output resulting files') +@@ -92,7 +92,8 @@ def write_rc_file(name, resource, outdir): + + if resource is None: + outfile = open(output_file_base_name + '.rc', 'w+') +- outfile.write('#include ') ++ outfile.write('#define WIN32_LEAN_AND_MEAN\n') ++ outfile.write('#include \n') + else: + if resource != output_file_base_name + '.rc': + outfile = open(output_file_base_name + '.rc', 'w+') diff --git a/recipes/gtk/all/patches/0002-fix-version-resource-for-Windows-11-sdk.patch b/recipes/gtk/all/patches/0002-fix-version-resource-for-Windows-11-sdk.patch new file mode 100644 index 0000000000000..5233563a36001 --- /dev/null +++ b/recipes/gtk/all/patches/0002-fix-version-resource-for-Windows-11-sdk.patch @@ -0,0 +1,25 @@ +From 3481ebdafb474ce7e312914e998e7212ecdbc5ba Mon Sep 17 00:00:00 2001 +From: Chun-wei Fan +Date: Wed, 13 Oct 2021 12:16:06 +0800 +Subject: [PATCH] gtk: Fix version resource on for Windows 11 SDK + +The rc.exe that comes with the Windows 11 SDK does not allow one to include +winuser.h directly in the .rc scripts, so make sure that it is not included +by gtk-win32.rc.body.in, but instead include windows.h with WIN32_LEAN_AND_MEAN +defined. +--- + gtk/gtk-win32.rc.body.in | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gtk/gtk-win32.rc.body.in b/gtk/gtk-win32.rc.body.in +index b876a6ddf5..fc2dfd2ed3 100644 +--- a/gtk/gtk-win32.rc.body.in ++++ b/gtk/gtk-win32.rc.body.in +@@ -1,5 +1,5 @@ +-#include +-#include ++#define WIN32_LEAN_AND_MEAN ++#include + + GTK_ICON ICON "gtk.ico" + diff --git a/recipes/gtk/all/test_package/conanfile.py b/recipes/gtk/all/test_package/conanfile.py index bd7165a553cf4..d4128b0450777 100644 --- a/recipes/gtk/all/test_package/conanfile.py +++ b/recipes/gtk/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/gtk/config.yml b/recipes/gtk/config.yml index 871932093ec29..d1ce9d2211eee 100644 --- a/recipes/gtk/config.yml +++ b/recipes/gtk/config.yml @@ -1,6 +1,16 @@ versions: "system": folder: "system" + "4.7.0": + folder: all + "4.6.2": + folder: all + "4.4.0": + folder: all + "4.3.2": + folder: all + "4.2.1": + folder: all "4.1.2": folder: all "4.0.2": diff --git a/recipes/gtk/system/conanfile.py b/recipes/gtk/system/conanfile.py index ef496e60614dd..eaa08c92e96a6 100644 --- a/recipes/gtk/system/conanfile.py +++ b/recipes/gtk/system/conanfile.py @@ -1,5 +1,9 @@ -from conans import ConanFile, tools -from conans.errors import ConanException, ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration, ConanException +from conan.tools.system import package_manager +from conans import tools + +required_conan_version = ">=1.47" class ConanGTK(ConanFile): @@ -8,22 +12,22 @@ class ConanGTK(ConanFile): license = "LGPL-2.1-or-later" homepage = "https://www.gtk.org" description = "A free and open-source cross-platform widget toolkit for creating graphical user interfaces" - settings = "os" + settings = "os", "arch", "compiler", "build_type" options = {"version": [2, 3]} default_options = {"version": 2} topics = ("gui", "widget", "graphical") - def configure(self): + def validate(self): if self.settings.os not in ["Linux", "FreeBSD"]: raise ConanInvalidConfiguration("This recipe supports only Linux and FreeBSD") - + def package_id(self): self.info.settings.clear() def _fill_cppinfo_from_pkgconfig(self, name): pkg_config = tools.PkgConfig(name) if not pkg_config.provides: - raise ConanException("GTK-{} development files aren't available, give up.".format(self.options.version)) + raise ConanException(f"GTK-{self.options.version} development files aren't available, give up.") libs = [lib[2:] for lib in pkg_config.libs_only_l] lib_dirs = [lib[2:] for lib in pkg_config.libs_only_L] ldflags = [flag for flag in pkg_config.libs_only_other] @@ -41,27 +45,24 @@ def _fill_cppinfo_from_pkgconfig(self, name): self.cpp_info.components[name].cxxflags = cflags def system_requirements(self): - packages = [] - if tools.os_info.is_linux and self.settings.os == "Linux": - if tools.os_info.with_apt: - packages = ["libgtk2.0-dev"] if self.options.version == 2 else ["libgtk-3-dev"] - elif tools.os_info.with_yum or tools.os_info.with_dnf: - packages = ["gtk{}-devel".format(self.options.version)] - elif tools.os_info.with_pacman: - packages = ["gtk{}".format(self.options.version)] - elif tools.os_info.with_zypper: - packages = ["gtk{}-devel".format(self.options.version)] - else: - self.output.warn("Do not know how to install 'GTK-{}' for {}." - .format(self.options.version, - tools.os_info.linux_distro)) - if tools.os_info.is_freebsd and self.settings.os == "FreeBSD": - packages = ["gtk{}".format(self.options.version)] - if packages: - package_tool = tools.SystemPackageTool(conanfile=self, default_mode="verify") - for p in packages: - package_tool.install(update=True, packages=p) + dnf = package_manager.Dnf(self) + dnf.install([f"gtk{self.options.version}-devel"], update=True, check=True) + + yum = package_manager.Yum(self) + yum.install([f"gtk{self.options.version}-devel"], update=True, check=True) + + apt = package_manager.Apt(self) + apt.install(["libgtk2.0-dev"] if self.options.version == 2 else ["libgtk-3-dev"], update=True, check=True) + + pacman = package_manager.PacMan(self) + pacman.install([f"gtk{self.options.version}"], update=True, check=True) + + zypper = package_manager.Zypper(self) + zypper.install([f"gtk{self.options.version}-devel"], update=True, check=True) + + pkg = package_manager.Pkg(self) + pkg.install([f"gtk{self.options.version}"], update=True, check=True) def package_info(self): - for name in ["gtk+-{}.0".format(self.options.version)]: + for name in [f"gtk+-{self.options.version}.0"]: self._fill_cppinfo_from_pkgconfig(name) diff --git a/recipes/gtsam/all/CMakeLists.txt b/recipes/gtsam/all/CMakeLists.txt index f52f2456d347d..04c96c99f25c3 100644 --- a/recipes/gtsam/all/CMakeLists.txt +++ b/recipes/gtsam/all/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.15) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory("source_subfolder") diff --git a/recipes/gtsam/all/conandata.yml b/recipes/gtsam/all/conandata.yml index be9b2302c5966..65a33ee134c24 100644 --- a/recipes/gtsam/all/conandata.yml +++ b/recipes/gtsam/all/conandata.yml @@ -1,14 +1,26 @@ sources: - "4.0.2": - url: "https://github.com/borglab/gtsam/archive/4.0.2.tar.gz" - sha256: "8770a440f1af98c3f0d9d4dffd568de2d4c21b245e7231e987e26bc236aeb5aa" + "4.1.1": + url: "https://github.com/borglab/gtsam/archive/4.1.1.tar.gz" + sha256: "c7b5e6cdad52b141c272778f47baf628975457be3e26ed96a7bc2ae685a00af0" "4.0.3": url: "https://github.com/borglab/gtsam/archive/4.0.3.tar.gz" sha256: "eaa561749edf7a2d402981828253e28aed6c717dae35738301c5ab23e2595f25" -patches: "4.0.2": - - patch_file: "patches/conan-4.0.2.patch" + url: "https://github.com/borglab/gtsam/archive/4.0.2.tar.gz" + sha256: "8770a440f1af98c3f0d9d4dffd568de2d4c21b245e7231e987e26bc236aeb5aa" +patches: + "4.1.1": + - patch_file: "patches/0001-conan-4.1.1.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-macos-rpath-4.1.1.patch" base_path: "source_subfolder" "4.0.3": - - patch_file: "patches/conan-4.0.3.patch" + - patch_file: "patches/0001-conan-4.0.3.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-macos-rpath-4.0.3.patch" + base_path: "source_subfolder" + "4.0.2": + - patch_file: "patches/0001-conan-4.0.2.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-macos-rpath-4.0.2.patch" base_path: "source_subfolder" diff --git a/recipes/gtsam/all/conanfile.py b/recipes/gtsam/all/conanfile.py index dade01dc5e7b9..09dde9bc58be5 100644 --- a/recipes/gtsam/all/conanfile.py +++ b/recipes/gtsam/all/conanfile.py @@ -1,122 +1,102 @@ -import os -import stat +from conan.tools.microsoft import msvc_runtime_flag, is_msvc from conans import ConanFile, tools, CMake from conans.errors import ConanInvalidConfiguration -from conans.tools import Version +import os +import textwrap + +required_conan_version = ">=1.43.0" -required_conan_version = ">=1.32.0" -class gtsamConan(ConanFile): +class GtsamConan(ConanFile): name = "gtsam" license = "BSD-3-Clause" homepage = "https://github.com/borglab/gtsam" url = "https://github.com/conan-io/conan-center-index" description = ("GTSAM is a library of C++ classes that implement\ smoothing and mapping (SAM) in robotics and vision") - topics = ("conan", "gtsam", "mapping", "smoothing") + topics = ("gtsam", "mapping", "smoothing") + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False], - "use_quaternions": [True, False], - "pose3_expmap": [True, False], - "rot3_expmap": [True, False], - "enable_consistency_checks": [True, False], - "with_TBB": [True, False], - "with_eigen_MKL": [True, False], - "with_eigen_MKL_OPENMP": [True, False], - "throw_cheirality_exception": [True, False], - "allow_deprecated_since_V4": [True, False], - "typedef_points_to_vectors": [True, False], - "support_nested_dissection": [True, False], - "tangent_preintegration": [True, False], - "build_wrap": [True, False], - "wrap_serialization": [True, False], - "build_unstable": [True, False], - "disable_new_timers": [True, False], - "build_type_postfixes": [True, False], - "install_matlab_toolbox": [True, False], - "install_cython_toolbox": [True, False], - "install_cppunitlite": [True, False], - "install_geographiclib": [True, False, "deprecated"]} - - default_options = {"shared": False, - "fPIC": True, - "use_quaternions": False, - "pose3_expmap": False, - "rot3_expmap": False, - "enable_consistency_checks": False, - "with_TBB": False, - "with_eigen_MKL": False, - "with_eigen_MKL_OPENMP": False, - "throw_cheirality_exception": True, - "allow_deprecated_since_V4": True, - "typedef_points_to_vectors": False, - "support_nested_dissection": False, - "tangent_preintegration": False, - "build_wrap": False, - "wrap_serialization": True, - "build_unstable": True, - "disable_new_timers": False, - "build_type_postfixes": True, - "install_matlab_toolbox": False, - "install_cython_toolbox": False, - "install_cppunitlite": True, - "install_geographiclib": "deprecated"} + options = { + "shared": [True, False], + "fPIC": [True, False], + "use_quaternions": [True, False], + "pose3_expmap": [True, False], + "rot3_expmap": [True, False], + "enable_consistency_checks": [True, False], + "with_TBB": [True, False], + "with_eigen_MKL": [True, False], + "with_eigen_MKL_OPENMP": [True, False], + "throw_cheirality_exception": [True, False], + "allow_deprecated_since_V4": [True, False], + "typedef_points_to_vectors": [True, False], + "support_nested_dissection": [True, False], + "tangent_preintegration": [True, False], + "build_wrap": [True, False], + "wrap_serialization": [True, False], + "build_unstable": [True, False], + "disable_new_timers": [True, False], + "build_type_postfixes": [True, False], + "install_matlab_toolbox": [True, False], + "install_cython_toolbox": [True, False], + "install_cppunitlite": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "use_quaternions": False, + "pose3_expmap": False, + "rot3_expmap": False, + "enable_consistency_checks": False, + "with_TBB": False, + "with_eigen_MKL": False, + "with_eigen_MKL_OPENMP": False, + "throw_cheirality_exception": True, + "allow_deprecated_since_V4": True, + "typedef_points_to_vectors": False, + "support_nested_dissection": False, + "tangent_preintegration": False, + "build_wrap": False, + "wrap_serialization": True, + "build_unstable": True, + "disable_new_timers": False, + "build_type_postfixes": True, + "install_matlab_toolbox": False, + "install_cython_toolbox": False, + "install_cppunitlite": True, + } generators = "cmake", "cmake_find_package" - exports_sources = ["CMakeLists.txt", "patches/*"] - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" _cmake = None - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["GTSAM_USE_QUATERNIONS"] = self.options.use_quaternions - self._cmake.definitions["GTSAM_POSE3_EXPMAP"] = self.options.pose3_expmap - self._cmake.definitions["GTSAM_ROT3_EXPMAP"] = self.options.rot3_expmap - self._cmake.definitions["GTSAM_ENABLE_CONSISTENCY_CHECKS"] = self.options.enable_consistency_checks - self._cmake.definitions["GTSAM_WITH_TBB"] = self.options.with_TBB - self._cmake.definitions["GTSAM_WITH_EIGEN_MKL"] = self.options.with_eigen_MKL - self._cmake.definitions["GTSAM_WITH_EIGEN_MKL_OPENMP"] = self.options.with_eigen_MKL_OPENMP - self._cmake.definitions["GTSAM_THROW_CHEIRALITY_EXCEPTION"] = self.options.throw_cheirality_exception - self._cmake.definitions["GTSAM_ALLOW_DEPRECATED_SINCE_V4"] = self.options.allow_deprecated_since_V4 - self._cmake.definitions["GTSAM_TYPEDEF_POINTS_TO_VECTORS"] = self.options.typedef_points_to_vectors - self._cmake.definitions["GTSAM_SUPPORT_NESTED_DISSECTION"] = self.options.support_nested_dissection - self._cmake.definitions["GTSAM_TANGENT_PREINTEGRATION"] = self.options.tangent_preintegration - self._cmake.definitions["GTSAM_BUILD_UNSTABLE"] = self.options.build_unstable - self._cmake.definitions["GTSAM_DISABLE_NEW_TIMERS"] = self.options.disable_new_timers - self._cmake.definitions["GTSAM_BUILD_TYPE_POSTFIXES"] = self.options.build_type_postfixes - self._cmake.definitions["GTSAM_BUILD_TESTS"] = False - self._cmake.definitions["Boost_USE_STATIC_LIBS"] = not self.options["boost"].shared - self._cmake.definitions["Boost_NO_SYSTEM_PATHS"] = True - self._cmake.definitions["GTSAM_BUILD_DOCS"] = False - self._cmake.definitions["GTSAM_BUILD_DOC_HTML"] = False - self._cmake.definitions["GTSAM_BUILD_EXAMPLES_ALWAYS"] = False - self._cmake.definitions["GTSAM_BUILD_WRAP"] = self.options.build_wrap - self._cmake.definitions["GTSAM_BUILD_WITH_MARCH_NATIVE"] = False - self._cmake.definitions["GTSAM_WRAP_SERIALIZATION"] = self.options.wrap_serialization - self._cmake.definitions["GTSAM_INSTALL_MATLAB_TOOLBOX"] = self.options.install_matlab_toolbox - self._cmake.definitions["GTSAM_INSTALL_CYTHON_TOOLBOX"] = self.options.install_cython_toolbox - self._cmake.definitions["GTSAM_INSTALL_CPPUNITLITE"] = self.options.install_cppunitlite - self._cmake.definitions["GTSAM_INSTALL_GEOGRAPHICLIB"] = False - self._cmake.definitions["GTSAM_USE_SYSTEM_EIGEN"] = True #Set to false to use eigen sources contained in GTSAM - self._cmake.definitions["GTSAM_BUILD_TYPE_POSTFIXES"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + @property + def _source_subfolder(self): + return "source_subfolder" - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - # compiler.runtime field only exists on Windows therefore we patch it on the recipe + @property + def _build_subfolder(self): + return "build_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): if self.settings.os == "Windows": - tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "GtsamBuildTypes.cmake"), - "/MD ", - "/{} ".format(self.settings.compiler.runtime)) - tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "GtsamBuildTypes.cmake"), - "/MDd ", - "/{} ".format(self.settings.compiler.runtime)) + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + if self.options.with_TBB: + self.options["onetbb"].tbbmalloc = True + + def requirements(self): + self.requires("boost/1.78.0") + self.requires("eigen/3.4.0") + if self.options.with_TBB: + self.requires("onetbb/2020.3") @property def _required_boost_components(self): @@ -125,30 +105,74 @@ def _required_boost_components(self): def validate(self): miss_boost_required_comp = any(getattr(self.options["boost"], "without_{}".format(boost_comp), True) for boost_comp in self._required_boost_components) if self.options["boost"].header_only or miss_boost_required_comp: - raise ConanInvalidConfiguration("{0} requires non header-only boost with these components: {1}".format(self.name, ", ".join(self._required_boost_components))) + raise ConanInvalidConfiguration( + "{0} requires non header-only boost with these components: {1}".format( + self.name, ", ".join(self._required_boost_components) + ) + ) - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC + if self.options.with_TBB and not self.options["onetbb"].tbbmalloc: + raise ConanInvalidConfiguration("gtsam with tbb requires onetbb:tbbmalloc=True") - def configure(self): - if self.settings.os == "Windows": - if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < 15: - raise ConanInvalidConfiguration ("GTSAM requires MSVC >= 15") - if self.options.install_geographiclib != "deprecated": - self.output.warn("install_geographiclib option is deprecated (GTSAM doesn't use geographiclib). If you want it add is a requirement in your project") + if is_msvc(self) and tools.Version(self.settings.compiler.version) < 15: + raise ConanInvalidConfiguration ("GTSAM requires MSVC >= 15") - def requirements(self): - self.requires("boost/1.75.0") - self.requires("eigen/3.3.9") - if self.options.with_TBB: - self.requires("tbb/2020.3") - self.options["tbb"].tbbmalloc = True + if is_msvc(self) and tools.Version(self.version) >= '4.1' \ + and self.options.shared: + raise ConanInvalidConfiguration("GTSAM does not support shared builds on MSVC. see https://github.com/borglab/gtsam/issues/1087") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + if is_msvc(self): + tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "GtsamBuildTypes.cmake"), + "/MD ", + "/{} ".format(msvc_runtime_flag(self))) + tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "GtsamBuildTypes.cmake"), + "/MDd ", + "/{} ".format(msvc_runtime_flag(self))) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared + self._cmake.definitions["GTSAM_USE_QUATERNIONS"] = self.options.use_quaternions + self._cmake.definitions["GTSAM_POSE3_EXPMAP"] = self.options.pose3_expmap + self._cmake.definitions["GTSAM_ROT3_EXPMAP"] = self.options.rot3_expmap + self._cmake.definitions["GTSAM_ENABLE_CONSISTENCY_CHECKS"] = self.options.enable_consistency_checks + self._cmake.definitions["GTSAM_WITH_TBB"] = self.options.with_TBB + self._cmake.definitions["GTSAM_WITH_EIGEN_MKL"] = self.options.with_eigen_MKL + self._cmake.definitions["GTSAM_WITH_EIGEN_MKL_OPENMP"] = self.options.with_eigen_MKL_OPENMP + self._cmake.definitions["GTSAM_THROW_CHEIRALITY_EXCEPTION"] = self.options.throw_cheirality_exception + self._cmake.definitions["GTSAM_ALLOW_DEPRECATED_SINCE_V4"] = self.options.allow_deprecated_since_V4 + self._cmake.definitions["GTSAM_TYPEDEF_POINTS_TO_VECTORS"] = self.options.typedef_points_to_vectors + self._cmake.definitions["GTSAM_SUPPORT_NESTED_DISSECTION"] = self.options.support_nested_dissection + self._cmake.definitions["GTSAM_TANGENT_PREINTEGRATION"] = self.options.tangent_preintegration + self._cmake.definitions["GTSAM_BUILD_UNSTABLE"] = self.options.build_unstable + self._cmake.definitions["GTSAM_DISABLE_NEW_TIMERS"] = self.options.disable_new_timers + self._cmake.definitions["GTSAM_BUILD_TYPE_POSTFIXES"] = self.options.build_type_postfixes + self._cmake.definitions["GTSAM_BUILD_TESTS"] = False + self._cmake.definitions["Boost_USE_STATIC_LIBS"] = not self.options["boost"].shared + self._cmake.definitions["Boost_NO_SYSTEM_PATHS"] = True + self._cmake.definitions["GTSAM_BUILD_DOCS"] = False + self._cmake.definitions["GTSAM_BUILD_DOC_HTML"] = False + self._cmake.definitions["GTSAM_BUILD_EXAMPLES_ALWAYS"] = False + self._cmake.definitions["GTSAM_BUILD_WRAP"] = self.options.build_wrap + self._cmake.definitions["GTSAM_BUILD_WITH_MARCH_NATIVE"] = False + self._cmake.definitions["GTSAM_WRAP_SERIALIZATION"] = self.options.wrap_serialization + self._cmake.definitions["GTSAM_INSTALL_MATLAB_TOOLBOX"] = self.options.install_matlab_toolbox + self._cmake.definitions["GTSAM_INSTALL_CYTHON_TOOLBOX"] = self.options.install_cython_toolbox + self._cmake.definitions["GTSAM_INSTALL_CPPUNITLITE"] = self.options.install_cppunitlite + self._cmake.definitions["GTSAM_INSTALL_GEOGRAPHICLIB"] = False + self._cmake.definitions["GTSAM_USE_SYSTEM_EIGEN"] = True #Set to false to use eigen sources contained in GTSAM + self._cmake.definitions["GTSAM_BUILD_TYPE_POSTFIXES"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake def build(self): self._patch_sources() @@ -163,40 +187,83 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "CMake")) - def package_id(self): - del self.info.options.install_geographiclib + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + { + "gtsam": "GTSAM::gtsam", + "gtsam_unstable": "GTSAM::gtsam_unstable", + "metis-gtsam": "GTSAM::metis-gtsam", + "CppUnitLite": "GTSAM::CppUnitLite", + } + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): - # FIXME: official imported targets are not namespaced - self.cpp_info.names["cmake_find_package"] = "GTSAM" - self.cpp_info.names["cmake_find_package_multi"] = "GTSAM" + self.cpp_info.set_property("cmake_file_name", "GTSAM") - self.cpp_info.components["libgtsam"].libs = ["libgtsam" if self.settings.os == "Windows" and not self.options.shared else "gtsam"] - self.cpp_info.components["libgtsam"].names["cmake_find_package"] = "gtsam" - self.cpp_info.components["libgtsam"].names["cmake_find_package_multi"] = "gtsam" + prefix = "lib" if is_msvc(self) and not self.options.shared else "" + + self.cpp_info.components["libgtsam"].set_property("cmake_target_name", "gtsam") + self.cpp_info.components["libgtsam"].libs = ["{}gtsam".format(prefix)] self.cpp_info.components["libgtsam"].requires = ["boost::{}".format(component) for component in self._required_boost_components] self.cpp_info.components["libgtsam"].requires.append("eigen::eigen") if self.options.with_TBB: - self.cpp_info.components["libgtsam"].requires.append("tbb::tbb") + self.cpp_info.components["libgtsam"].requires.append("onetbb::onetbb") if self.options.support_nested_dissection: self.cpp_info.components["libgtsam"].requires.append("libmetis-gtsam") if self.settings.os == "Windows" and tools.Version(self.version) >= "4.0.3": self.cpp_info.components["libgtsam"].system_libs = ["dbghelp"] if self.options.build_unstable: - self.cpp_info.components["libgtsam_unstable"].libs = ["libgtsam_unstable" if self.settings.os == "Windows" and not self.options.shared else "gtsam_unstable"] - self.cpp_info.components["libgtsam_unstable"].names["cmake_find_package"] = "gtsam_unstable" - self.cpp_info.components["libgtsam_unstable"].names["cmake_find_package_multi"] = "gtsam_unstable" + self.cpp_info.components["libgtsam_unstable"].set_property("cmake_target_name", "gtsam_unstable") + self.cpp_info.components["libgtsam_unstable"].libs = ["{}gtsam_unstable".format(prefix)] self.cpp_info.components["libgtsam_unstable"].requires = ["libgtsam"] if self.options.support_nested_dissection: - self.cpp_info.components["libmetis-gtsam"].libs = ["libmetis-gtsam" if self.settings.os == "Windows" and not self.options.shared else "metis-gtsam"] - self.cpp_info.components["libmetis-gtsam"].names["cmake_find_package"] = "metis-gtsam" - self.cpp_info.components["libmetis-gtsam"].names["cmake_find_package_multi"] = "metis-gtsam" + self.cpp_info.components["libmetis-gtsam"].set_property("cmake_target_name", "metis-gtsam") + self.cpp_info.components["libmetis-gtsam"].libs = ["metis-gtsam"] self.cpp_info.components["libmetis-gtsam"].names["pkg_config"] = "metis-gtsam" if self.options.install_cppunitlite: + self.cpp_info.components["gtsam_CppUnitLite"].set_property("cmake_target_name", "CppUnitLite") self.cpp_info.components["gtsam_CppUnitLite"].libs = ["CppUnitLite"] + self.cpp_info.components["gtsam_CppUnitLite"].requires = ["boost::boost"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "GTSAM" + self.cpp_info.names["cmake_find_package_multi"] = "GTSAM" + self.cpp_info.components["libgtsam"].names["cmake_find_package"] = "gtsam" + self.cpp_info.components["libgtsam"].names["cmake_find_package_multi"] = "gtsam" + self.cpp_info.components["libgtsam"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["libgtsam"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + if self.options.build_unstable: + self.cpp_info.components["libgtsam_unstable"].names["cmake_find_package"] = "gtsam_unstable" + self.cpp_info.components["libgtsam_unstable"].names["cmake_find_package_multi"] = "gtsam_unstable" + self.cpp_info.components["libgtsam_unstable"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["libgtsam_unstable"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + if self.options.support_nested_dissection: + self.cpp_info.components["libmetis-gtsam"].names["cmake_find_package"] = "metis-gtsam" + self.cpp_info.components["libmetis-gtsam"].names["cmake_find_package_multi"] = "metis-gtsam" + self.cpp_info.components["libmetis-gtsam"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["libmetis-gtsam"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + if self.options.install_cppunitlite: self.cpp_info.components["gtsam_CppUnitLite"].names["cmake_find_package"] = "CppUnitLite" self.cpp_info.components["gtsam_CppUnitLite"].names["cmake_find_package_multi"] = "CppUnitLite" - self.cpp_info.components["gtsam_CppUnitLite"].requires = ["boost::boost"] + self.cpp_info.components["gtsam_CppUnitLite"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["gtsam_CppUnitLite"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/gtsam/all/patches/conan-4.0.2.patch b/recipes/gtsam/all/patches/0001-conan-4.0.2.patch similarity index 100% rename from recipes/gtsam/all/patches/conan-4.0.2.patch rename to recipes/gtsam/all/patches/0001-conan-4.0.2.patch diff --git a/recipes/gtsam/all/patches/conan-4.0.3.patch b/recipes/gtsam/all/patches/0001-conan-4.0.3.patch similarity index 100% rename from recipes/gtsam/all/patches/conan-4.0.3.patch rename to recipes/gtsam/all/patches/0001-conan-4.0.3.patch diff --git a/recipes/gtsam/all/patches/0001-conan-4.1.1.patch b/recipes/gtsam/all/patches/0001-conan-4.1.1.patch new file mode 100644 index 0000000000000..ccc216be860c8 --- /dev/null +++ b/recipes/gtsam/all/patches/0001-conan-4.1.1.patch @@ -0,0 +1,27 @@ +diff --git a/cmake/HandleBoost.cmake b/cmake/HandleBoost.cmake +--- a/cmake/HandleBoost.cmake ++++ b/cmake/HandleBoost.cmake +@@ -25,13 +25,7 @@ endif() + set(BOOST_FIND_MINIMUM_VERSION 1.65) + set(BOOST_FIND_MINIMUM_COMPONENTS serialization system filesystem thread program_options date_time timer chrono regex) + +-find_package(Boost ${BOOST_FIND_MINIMUM_VERSION} COMPONENTS ${BOOST_FIND_MINIMUM_COMPONENTS}) +- +-# Required components +-if(NOT Boost_SERIALIZATION_LIBRARY OR NOT Boost_SYSTEM_LIBRARY OR NOT Boost_FILESYSTEM_LIBRARY OR +- NOT Boost_THREAD_LIBRARY OR NOT Boost_DATE_TIME_LIBRARY) +- message(FATAL_ERROR "Missing required Boost components >= v1.65, please install/upgrade Boost or configure your search paths.") +-endif() ++find_package(Boost ${BOOST_FIND_MINIMUM_VERSION} COMPONENTS ${BOOST_FIND_MINIMUM_COMPONENTS} REQUIRED) + + option(GTSAM_DISABLE_NEW_TIMERS "Disables using Boost.chrono for timing" OFF) + # Allow for not using the timer libraries on boost < 1.48 (GTSAM timing code falls back to old timer library) +@@ -47,7 +41,7 @@ if (GTSAM_DISABLE_NEW_TIMERS) + message("WARNING: GTSAM timing instrumentation manually disabled") + list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC DGTSAM_DISABLE_NEW_TIMERS) + else() +- if(Boost_TIMER_LIBRARY) ++ if(TARGET Boost::timer) + list(APPEND GTSAM_BOOST_LIBRARIES Boost::timer Boost::chrono) + else() + list(APPEND GTSAM_BOOST_LIBRARIES rt) # When using the header-only boost timer library, need -lrt diff --git a/recipes/gtsam/all/patches/0002-macos-rpath-4.0.2.patch b/recipes/gtsam/all/patches/0002-macos-rpath-4.0.2.patch new file mode 100644 index 0000000000000..6bc74d30d7ff1 --- /dev/null +++ b/recipes/gtsam/all/patches/0002-macos-rpath-4.0.2.patch @@ -0,0 +1,34 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.0) + # new feature to Cmake Version > 2.8.12 + # Mac ONLY. Define Relative Path on Mac OS + if(NOT DEFINED CMAKE_MACOSX_RPATH) +- set(CMAKE_MACOSX_RPATH 0) + endif() + + # Set the version number for the library +--- a/gtsam/CMakeLists.txt ++++ b/gtsam/CMakeLists.txt +@@ -177,9 +177,6 @@ if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with + endif() + + if (APPLE AND BUILD_SHARED_LIBS) +- set_target_properties(gtsam PROPERTIES +- INSTALL_NAME_DIR +- "${CMAKE_INSTALL_PREFIX}/lib") + endif() + + install( +--- a/gtsam/3rdparty/metis/libmetis/CMakeLists.txt ++++ b/gtsam/3rdparty/metis/libmetis/CMakeLists.txt +@@ -16,9 +16,6 @@ if(WIN32) + endif() + + if (APPLE) +- set_target_properties(metis PROPERTIES +- INSTALL_NAME_DIR +- "${CMAKE_INSTALL_PREFIX}/lib") + endif() + + install(TARGETS metis EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) diff --git a/recipes/gtsam/all/patches/0002-macos-rpath-4.0.3.patch b/recipes/gtsam/all/patches/0002-macos-rpath-4.0.3.patch new file mode 100644 index 0000000000000..c172edcd2dcc4 --- /dev/null +++ b/recipes/gtsam/all/patches/0002-macos-rpath-4.0.3.patch @@ -0,0 +1,30 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.0) + # new feature to Cmake Version > 2.8.12 + # Mac ONLY. Define Relative Path on Mac OS + if(NOT DEFINED CMAKE_MACOSX_RPATH) +- set(CMAKE_MACOSX_RPATH 0) + endif() + + # Set the version number for the library +@@ -347,7 +346,6 @@ endif() + + if (APPLE AND BUILD_SHARED_LIBS) + # Set the default install directory on macOS +- set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") + endif() + + ############################################################################### +--- a/gtsam/3rdparty/metis/libmetis/CMakeLists.txt ++++ b/gtsam/3rdparty/metis/libmetis/CMakeLists.txt +@@ -16,9 +16,6 @@ if(WIN32) + endif() + + if (APPLE) +- set_target_properties(metis-gtsam PROPERTIES +- INSTALL_NAME_DIR +- "${CMAKE_INSTALL_PREFIX}/lib") + endif() + + install(TARGETS metis-gtsam EXPORT GTSAM-exports diff --git a/recipes/gtsam/all/patches/0002-macos-rpath-4.1.1.patch b/recipes/gtsam/all/patches/0002-macos-rpath-4.1.1.patch new file mode 100644 index 0000000000000..84336aaee8564 --- /dev/null +++ b/recipes/gtsam/all/patches/0002-macos-rpath-4.1.1.patch @@ -0,0 +1,27 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.0) + # new feature to Cmake Version > 2.8.12 + # Mac ONLY. Define Relative Path on Mac OS + if(NOT DEFINED CMAKE_MACOSX_RPATH) +- set(CMAKE_MACOSX_RPATH 0) + endif() + + # Set the version number for the library +diff --git a/gtsam/3rdparty/metis/libmetis/CMakeLists.txt b/gtsam/3rdparty/metis/libmetis/CMakeLists.txt +--- a/gtsam/3rdparty/metis/libmetis/CMakeLists.txt ++++ b/gtsam/3rdparty/metis/libmetis/CMakeLists.txt +@@ -16,12 +16,6 @@ if(WIN32) + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/../../../bin") + endif() + +-if (APPLE) +- set_target_properties(metis-gtsam PROPERTIES +- INSTALL_NAME_DIR +- "${CMAKE_INSTALL_PREFIX}/lib") +- endif() +- + install(TARGETS metis-gtsam EXPORT GTSAM-exports + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/recipes/gtsam/all/test_package/CMakeLists.txt b/recipes/gtsam/all/test_package/CMakeLists.txt index ea7da7360a676..bac6d84e2319d 100644 --- a/recipes/gtsam/all/test_package/CMakeLists.txt +++ b/recipes/gtsam/all/test_package/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.cpp) +find_package(GTSAM REQUIRED CONFIG) -find_package(GTSAM REQUIRED) -target_link_libraries(${PROJECT_NAME} GTSAM::gtsam) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} gtsam) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/gtsam/all/test_package/conanfile.py b/recipes/gtsam/all/test_package/conanfile.py index 86a9b5e546a07..38f4483872d47 100644 --- a/recipes/gtsam/all/test_package/conanfile.py +++ b/recipes/gtsam/all/test_package/conanfile.py @@ -1,9 +1,10 @@ -import os from conans import ConanFile, CMake, tools +import os + -class gtsamTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -11,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/gtsam/config.yml b/recipes/gtsam/config.yml index 7d4d713f6cc00..6f380a83ebb14 100644 --- a/recipes/gtsam/config.yml +++ b/recipes/gtsam/config.yml @@ -1,5 +1,7 @@ versions: - "4.0.2": + "4.1.1": folder: all "4.0.3": folder: all + "4.0.2": + folder: all diff --git a/recipes/gumbo-parser/all/conandata.yml b/recipes/gumbo-parser/all/conandata.yml index 6f417f3459ec8..5a4bd28857b65 100644 --- a/recipes/gumbo-parser/all/conandata.yml +++ b/recipes/gumbo-parser/all/conandata.yml @@ -1,4 +1,4 @@ sources: "0.10.1": - sha256: 28463053d44a5dfbc4b77bcf49c8cee119338ffa636cc17fc3378421d714efad url: "https://github.com/google/gumbo-parser/archive/v0.10.1.tar.gz" + sha256: "28463053d44a5dfbc4b77bcf49c8cee119338ffa636cc17fc3378421d714efad" diff --git a/recipes/gumbo-parser/all/conanfile.py b/recipes/gumbo-parser/all/conanfile.py index 0e9147b23edd7..579047bc3a0aa 100644 --- a/recipes/gumbo-parser/all/conanfile.py +++ b/recipes/gumbo-parser/all/conanfile.py @@ -1,69 +1,89 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path import os +required_conan_version = ">=1.53.0" + class GumboParserConan(ConanFile): name = "gumbo-parser" description = "An HTML5 parsing library in pure C99" - topics = ("conan", "parser") + topics = ("parser", "html") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/google/gumbo-parser" license = "Apache-2.0" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _autotools = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("This recipe does not support Visual Studio") + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration("gumbo-parser recipe does not support Visual Studio yet") def build_requirements(self): - self.build_requires("libtool/2.4.6") + self.tool_requires("libtool/2.4.7") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "gumbo-parser-{0}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_autotools(self): - if not self._autotools: - with tools.chdir(self._source_subfolder): - self.run("./autogen.sh", win_bash=tools.os_info.is_windows) - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - args = [] - if self.options.shared: - args.extend(['--disable-static', '--enable-shared']) - else: - args.extend(['--disable-shared', '--enable-static']) - self._autotools.configure(configure_dir=self._source_subfolder, args=args) - return self._autotools + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.generate() def build(self): - autotools = self._configure_autotools() + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() autotools.make() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) - os.unlink(os.path.join(self.package_folder, 'lib', 'libgumbo.la')) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) def package_info(self): - self.cpp_info.names["pkg_config"] = "gumbo" + self.cpp_info.set_property("pkg_config_name", "gumbo") self.cpp_info.libs = ["gumbo"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") diff --git a/recipes/gumbo-parser/all/test_package/CMakeLists.txt b/recipes/gumbo-parser/all/test_package/CMakeLists.txt index 7b9b613cbb24a..29e92f880421a 100644 --- a/recipes/gumbo-parser/all/test_package/CMakeLists.txt +++ b/recipes/gumbo-parser/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(gumbo-parser REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE gumbo-parser::gumbo-parser) diff --git a/recipes/gumbo-parser/all/test_package/conanfile.py b/recipes/gumbo-parser/all/test_package/conanfile.py index bd7165a553cf4..0a6bc68712d90 100644 --- a/recipes/gumbo-parser/all/test_package/conanfile.py +++ b/recipes/gumbo-parser/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gumbo-parser/all/test_v1_package/CMakeLists.txt b/recipes/gumbo-parser/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/gumbo-parser/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/gumbo-parser/all/test_v1_package/conanfile.py b/recipes/gumbo-parser/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/gumbo-parser/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gzip-hpp/all/conandata.yml b/recipes/gzip-hpp/all/conandata.yml new file mode 100644 index 0000000000000..dc56977498952 --- /dev/null +++ b/recipes/gzip-hpp/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.1.0": + url: "https://github.com/mapbox/gzip-hpp/archive/refs/tags/v0.1.0.tar.gz" + sha256: "7ce3908cd13f186987820be97083fc5e62a7c6df0877af44b334a92e868eff06" diff --git a/recipes/gzip-hpp/all/conanfile.py b/recipes/gzip-hpp/all/conanfile.py new file mode 100644 index 0000000000000..9401872c82770 --- /dev/null +++ b/recipes/gzip-hpp/all/conanfile.py @@ -0,0 +1,56 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import get, copy +from conan.tools.layout import basic_layout + +import os + + +required_conan_version = ">=1.52.0" + + +class GzipHppConan(ConanFile): + name = "gzip-hpp" + description = "Gzip header-only C++ library " + license = "BSD-2-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/mapbox/gzip-hpp" + topics = ("gzip", "zlib", "compression", "decompression", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _min_cppstd(self): + return 11 + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("zlib/1.2.13", transitive_headers=True) + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, pattern="LICENSE.md", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy( + self, + pattern="*.hpp", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include"), + ) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/gzip-hpp/all/test_package/CMakeLists.txt b/recipes/gzip-hpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..84ca7198a323c --- /dev/null +++ b/recipes/gzip-hpp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(gzip-hpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gzip-hpp::gzip-hpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/gzip-hpp/all/test_package/conanfile.py b/recipes/gzip-hpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e845ae751a301 --- /dev/null +++ b/recipes/gzip-hpp/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gzip-hpp/all/test_package/test_package.cpp b/recipes/gzip-hpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..72042fe701b60 --- /dev/null +++ b/recipes/gzip-hpp/all/test_package/test_package.cpp @@ -0,0 +1,28 @@ +// Include the specific gzip headers your code needs, for example... +#include +#include +#include +#include +#include + +#include + +int main() { + // All function calls must pass in a pointer of an + // immutable character sequence (aka a string in C) and its size + std::string data = "hello"; + const char* pointer = data.data(); + std::size_t size = data.size(); + + // Check if compressed. Can check both gzip and zlib. + bool c = gzip::is_compressed(pointer, size); // false + + // Compress returns a std::string + std::string compressed_data = gzip::compress(pointer, size); + + // Decompress returns a std::string and decodes both zlib and gzip + const char* compressed_pointer = compressed_data.data(); + std::string decompressed_data = gzip::decompress(compressed_pointer, compressed_data.size()); + + return 0; +} diff --git a/recipes/gzip-hpp/all/test_v1_package/CMakeLists.txt b/recipes/gzip-hpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9d54a092e0a67 --- /dev/null +++ b/recipes/gzip-hpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/gzip-hpp/all/test_v1_package/conanfile.py b/recipes/gzip-hpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/gzip-hpp/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/gzip-hpp/config.yml b/recipes/gzip-hpp/config.yml new file mode 100644 index 0000000000000..6c11a439d0bc2 --- /dev/null +++ b/recipes/gzip-hpp/config.yml @@ -0,0 +1,3 @@ +versions: + "0.1.0": + folder: all diff --git a/recipes/h3/all/CMakeLists.txt b/recipes/h3/all/CMakeLists.txt deleted file mode 100644 index 2289b0ac7f4bc..0000000000000 --- a/recipes/h3/all/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -set(CMAKE_C_STANDARD 99) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/h3/all/conandata.yml b/recipes/h3/all/conandata.yml index 6d9ce46a59cb6..829bf4afe8a32 100644 --- a/recipes/h3/all/conandata.yml +++ b/recipes/h3/all/conandata.yml @@ -1,17 +1,27 @@ -patches: - 3.6.4: - - base_path: source_subfolder - patch_file: patches/fix-cmake-install-3.6.4.patch sources: - 3.6.3: - sha256: 3ba219959ecb0ef6956f05113aa659d7b605e4eebbdca561b8243ce309e4684e - url: https://github.com/uber/h3/archive/v3.6.3.tar.gz - 3.6.4: - sha256: b80c2eee2b3e645de77893e27ca149e63d3bb6bf95d33e3a384e3f390e2681bb - url: https://github.com/uber/h3/archive/v3.6.4.tar.gz - 3.7.0: - sha256: 7b59780781750d2ccc64c50b6364d706947a684b0cb996c1b104f448562d2d7c - url: https://github.com/uber/h3/archive/v3.7.0.tar.gz - 3.7.1: - sha256: cfa3b4e1d46251929bd30575f09c89edb2c209be7ad8b0af15ff3f9a04132688 - url: https://github.com/uber/h3/archive/v3.7.1.tar.gz + "3.7.2": + url: "https://github.com/uber/h3/archive/refs/tags/v3.7.2.tar.gz" + sha256: "803a7fbbeb01f1f65cae9398bda9579a0529e7bafffc6e0e0a6d81a71b305629" + "3.7.1": + url: "https://github.com/uber/h3/archive/v3.7.1.tar.gz" + sha256: "cfa3b4e1d46251929bd30575f09c89edb2c209be7ad8b0af15ff3f9a04132688" + "3.7.0": + url: "https://github.com/uber/h3/archive/v3.7.0.tar.gz" + sha256: "7b59780781750d2ccc64c50b6364d706947a684b0cb996c1b104f448562d2d7c" + "3.6.4": + url: "https://github.com/uber/h3/archive/v3.6.4.tar.gz" + sha256: "b80c2eee2b3e645de77893e27ca149e63d3bb6bf95d33e3a384e3f390e2681bb" + "3.6.3": + url: "https://github.com/uber/h3/archive/v3.6.3.tar.gz" + sha256: "3ba219959ecb0ef6956f05113aa659d7b605e4eebbdca561b8243ce309e4684e" +patches: + "3.7.2": + - patch_file: "patches/fix-cmake-3.7.x.patch" + "3.7.1": + - patch_file: "patches/fix-cmake-3.7.x.patch" + "3.7.0": + - patch_file: "patches/fix-cmake-3.7.x.patch" + "3.6.4": + - patch_file: "patches/fix-cmake-3.6.4.patch" + "3.6.3": + - patch_file: "patches/fix-cmake-3.6.3.patch" diff --git a/recipes/h3/all/conanfile.py b/recipes/h3/all/conanfile.py index 6265a9690191b..ff33c9fa665be 100644 --- a/recipes/h3/all/conanfile.py +++ b/recipes/h3/all/conanfile.py @@ -1,39 +1,36 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.47.0" + class H3Conan(ConanFile): name = "h3" description = "Hexagonal hierarchical geospatial indexing system." license = "Apache-2.0" - topics = ("conan", "h3", "hierarchical", "geospatial", "indexing") + topics = ("h3", "hierarchical", "geospatial", "indexing") homepage = "https://github.com/uber/h3" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "build_filters": [True, False], - "h3_prefix": "ANY" + "h3_prefix": ["ANY"], } default_options = { "shared": False, "fPIC": True, "build_filters": True, - "h3_prefix": "" + "h3_prefix": "", } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -42,45 +39,54 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["H3_PREFIX"] = self.options.h3_prefix + tc.variables["ENABLE_COVERAGE"] = False + tc.variables["BUILD_BENCHMARKS"] = False + tc.variables["BUILD_FILTERS"] = self.options.build_filters + tc.variables["BUILD_GENERATORS"] = False + tc.variables["WARNINGS_AS_ERRORS"] = False + tc.variables["ENABLE_FORMAT"] = False + tc.variables["ENABLE_LINTING"] = False + tc.variables["ENABLE_DOCS"] = False + tc.variables["BUILD_TESTING"] = False + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["H3_PREFIX"] = self.options.h3_prefix - self._cmake.definitions["ENABLE_COVERAGE"] = False - self._cmake.definitions["BUILD_BENCHMARKS"] = False - self._cmake.definitions["BUILD_FILTERS"] = self.options.build_filters - self._cmake.definitions["BUILD_GENERATORS"] = False - self._cmake.definitions["WARNINGS_AS_ERRORS"] = False - self._cmake.definitions["ENABLE_LINTING"] = False - self._cmake.definitions["ENABLE_DOCS"] = False - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "h3") + self.cpp_info.set_property("cmake_target_name", "h3::h3") + self.cpp_info.libs = ["h3"] self.cpp_info.defines.append("H3_PREFIX={}".format(self.options.h3_prefix)) - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") if self.options.build_filters: diff --git a/recipes/h3/all/patches/fix-cmake-3.6.3.patch b/recipes/h3/all/patches/fix-cmake-3.6.3.patch new file mode 100644 index 0000000000000..9e69a89b18b77 --- /dev/null +++ b/recipes/h3/all/patches/fix-cmake-3.6.3.patch @@ -0,0 +1,56 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -13,6 +13,10 @@ + # limitations under the License. + + cmake_minimum_required(VERSION 3.1) ++file(READ VERSION H3_VERSION LIMIT_COUNT 1) ++# Clean any newlines ++string(REPLACE "\n" "" H3_VERSION "${H3_VERSION}") ++project(h3 LANGUAGES C VERSION ${H3_VERSION}) + + set(H3_PREFIX "" CACHE STRING "Prefix for exported symbols") + +@@ -24,9 +28,6 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +-set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain.cmake" +- CACHE FILEPATH +- "Toolchain to use for building this project") + + option(ENABLE_COVERAGE "Enable compiling tests with coverage." ON) + option(BUILD_BENCHMARKS "Build benchmarking applications." ON) +@@ -45,16 +46,12 @@ else() + set(LIBRARY_OUTPUT_PATH lib) + endif() + +-file(READ VERSION H3_VERSION LIMIT_COUNT 1) +-# Clean any newlines +-string(REPLACE "\n" "" H3_VERSION "${H3_VERSION}") + string(REPLACE "." ";" H3_VERSION_LIST "${H3_VERSION}") + list(GET H3_VERSION_LIST 0 H3_VERSION_MAJOR) + list(GET H3_VERSION_LIST 1 H3_VERSION_MINOR) + list(GET H3_VERSION_LIST 2 H3_VERSION_PATCH) + set(H3_SOVERSION 1) + +-project(h3 LANGUAGES C VERSION ${H3_VERSION}) + + set(H3_COMPILE_FLAGS "") + set(H3_LINK_FLAGS "") +@@ -203,6 +200,7 @@ set(INSTALL_TARGETS h3) + # Build the H3 library + add_library(h3 ${LIB_SOURCE_FILES} ${CONFIGURED_API_HEADER}) + ++target_compile_features(h3 PUBLIC c_std_99) + target_compile_options(h3 PRIVATE ${H3_COMPILE_FLAGS}) + target_link_libraries(h3 PRIVATE ${H3_LINK_FLAGS}) + +@@ -602,6 +600,7 @@ install( + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" ++ BUNDLE DESTINATION "bin" + INCLUDES DESTINATION "${include_install_dir}" + ) + diff --git a/recipes/h3/all/patches/fix-cmake-3.6.4.patch b/recipes/h3/all/patches/fix-cmake-3.6.4.patch new file mode 100644 index 0000000000000..e98b3fe8f56fc --- /dev/null +++ b/recipes/h3/all/patches/fix-cmake-3.6.4.patch @@ -0,0 +1,65 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -13,6 +13,10 @@ + # limitations under the License. + + cmake_minimum_required(VERSION 3.1) ++file(READ VERSION H3_VERSION LIMIT_COUNT 1) ++# Clean any newlines ++string(REPLACE "\n" "" H3_VERSION "${H3_VERSION}") ++project(h3 LANGUAGES C VERSION ${H3_VERSION}) + + set(H3_PREFIX "" CACHE STRING "Prefix for exported symbols") + set(H3_ALLOC_PREFIX "" CACHE STRING "Prefix for allocation functions") +@@ -25,9 +29,6 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +-set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain.cmake" +- CACHE FILEPATH +- "Toolchain to use for building this project") + + option(ENABLE_COVERAGE "Enable compiling tests with coverage." ON) + option(BUILD_BENCHMARKS "Build benchmarking applications." ON) +@@ -46,16 +47,12 @@ else() + set(LIBRARY_OUTPUT_PATH lib) + endif() + +-file(READ VERSION H3_VERSION LIMIT_COUNT 1) +-# Clean any newlines +-string(REPLACE "\n" "" H3_VERSION "${H3_VERSION}") + string(REPLACE "." ";" H3_VERSION_LIST "${H3_VERSION}") + list(GET H3_VERSION_LIST 0 H3_VERSION_MAJOR) + list(GET H3_VERSION_LIST 1 H3_VERSION_MINOR) + list(GET H3_VERSION_LIST 2 H3_VERSION_PATCH) + set(H3_SOVERSION 1) + +-project(h3 LANGUAGES C VERSION ${H3_VERSION}) + + set(H3_COMPILE_FLAGS "") + set(H3_LINK_FLAGS "") +@@ -205,6 +202,7 @@ set(INSTALL_TARGETS) + function(add_h3_library name h3_alloc_prefix_override) + add_library(${name} ${LIB_SOURCE_FILES} ${CONFIGURED_API_HEADER}) + ++ target_compile_features(${name} PUBLIC c_std_99) + target_compile_options(${name} PRIVATE ${H3_COMPILE_FLAGS}) + target_link_libraries(${name} PRIVATE ${H3_LINK_FLAGS}) + +@@ -647,7 +645,7 @@ configure_package_config_file( + install( + TARGETS ${INSTALL_TARGETS} + EXPORT "${TARGETS_EXPORT_NAME}" +- RUNTIME DESTINATION "bin" ++ DESTINATION "bin" + COMPONENT h3 + ) + +@@ -656,6 +654,7 @@ install( + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" ++ RUNTIME DESTINATION "bin" + COMPONENT libh3 + ) + diff --git a/recipes/h3/all/patches/fix-cmake-3.7.x.patch b/recipes/h3/all/patches/fix-cmake-3.7.x.patch new file mode 100644 index 0000000000000..b8139d810b08e --- /dev/null +++ b/recipes/h3/all/patches/fix-cmake-3.7.x.patch @@ -0,0 +1,57 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -13,6 +13,10 @@ + # limitations under the License. + + cmake_minimum_required(VERSION 3.1) ++file(READ VERSION H3_VERSION LIMIT_COUNT 1) ++# Clean any newlines ++string(REPLACE "\n" "" H3_VERSION "${H3_VERSION}") ++project(h3 LANGUAGES C VERSION ${H3_VERSION}) + + set(H3_PREFIX "" CACHE STRING "Prefix for exported symbols") + set(H3_ALLOC_PREFIX "" CACHE STRING "Prefix for allocation functions") +@@ -25,9 +29,6 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +-set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain.cmake" +- CACHE FILEPATH +- "Toolchain to use for building this project") + + option(ENABLE_COVERAGE "Enable compiling tests with coverage." ON) + option(BUILD_BENCHMARKS "Build benchmarking applications." ON) +@@ -47,16 +48,12 @@ else() + set(LIBRARY_OUTPUT_PATH lib) + endif() + +-file(READ VERSION H3_VERSION LIMIT_COUNT 1) +-# Clean any newlines +-string(REPLACE "\n" "" H3_VERSION "${H3_VERSION}") + string(REPLACE "." ";" H3_VERSION_LIST "${H3_VERSION}") + list(GET H3_VERSION_LIST 0 H3_VERSION_MAJOR) + list(GET H3_VERSION_LIST 1 H3_VERSION_MINOR) + list(GET H3_VERSION_LIST 2 H3_VERSION_PATCH) + set(H3_SOVERSION 1) + +-project(h3 LANGUAGES C VERSION ${H3_VERSION}) + + set(H3_COMPILE_FLAGS "") + set(H3_LINK_FLAGS "") +@@ -213,6 +210,7 @@ set(INSTALL_TARGETS) + function(add_h3_library name h3_alloc_prefix_override) + add_library(${name} ${LIB_SOURCE_FILES} ${CONFIGURED_API_HEADER}) + ++ target_compile_features(${name} PUBLIC c_std_99) + target_compile_options(${name} PRIVATE ${H3_COMPILE_FLAGS}) + target_link_libraries(${name} PRIVATE ${H3_LINK_FLAGS}) + +@@ -666,7 +664,7 @@ configure_package_config_file( + install( + TARGETS ${INSTALL_TARGETS} + EXPORT "${TARGETS_EXPORT_NAME}" +- RUNTIME DESTINATION "bin" ++ DESTINATION "bin" + COMPONENT h3 + ) + diff --git a/recipes/h3/all/patches/fix-cmake-install-3.6.4.patch b/recipes/h3/all/patches/fix-cmake-install-3.6.4.patch deleted file mode 100644 index e03380cae04ae..0000000000000 --- a/recipes/h3/all/patches/fix-cmake-install-3.6.4.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -656,6 +656,7 @@ install( - EXPORT "${TARGETS_EXPORT_NAME}" - LIBRARY DESTINATION "lib" - ARCHIVE DESTINATION "lib" -+ RUNTIME DESTINATION "bin" - COMPONENT libh3 - ) - diff --git a/recipes/h3/all/test_package/CMakeLists.txt b/recipes/h3/all/test_package/CMakeLists.txt index 369805553c7e4..e307c995d2d4f 100644 --- a/recipes/h3/all/test_package/CMakeLists.txt +++ b/recipes/h3/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C) find_package(h3 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} h3::h3) +target_link_libraries(${PROJECT_NAME} PRIVATE h3::h3) diff --git a/recipes/h3/all/test_package/conanfile.py b/recipes/h3/all/test_package/conanfile.py index 84ee68733e516..3a8c6c5442b33 100644 --- a/recipes/h3/all/test_package/conanfile.py +++ b/recipes/h3/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/h3/all/test_v1_package/CMakeLists.txt b/recipes/h3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6b1eab908222a --- /dev/null +++ b/recipes/h3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(h3 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE h3::h3) diff --git a/recipes/h3/all/test_v1_package/conanfile.py b/recipes/h3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/h3/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/h3/config.yml b/recipes/h3/config.yml index 504cb6f156112..27faf2974af92 100644 --- a/recipes/h3/config.yml +++ b/recipes/h3/config.yml @@ -1,9 +1,11 @@ versions: - 3.6.3: + "3.7.2": folder: all - 3.6.4: + "3.7.1": folder: all - 3.7.0: + "3.7.0": folder: all - 3.7.1: + "3.6.4": + folder: all + "3.6.3": folder: all diff --git a/recipes/h5pp/all/conandata.yml b/recipes/h5pp/all/conandata.yml index 85a8aa509b37e..2aa0b94704f12 100644 --- a/recipes/h5pp/all/conandata.yml +++ b/recipes/h5pp/all/conandata.yml @@ -8,3 +8,12 @@ sources: "1.8.5": sha256: 1e1a42159fccd10b1022445ea0f0690c5314e94b0fc3d5c9fa0f02b165148c18 url: https://github.com/DavidAce/h5pp/archive/v1.8.5.tar.gz + "1.8.6": + sha256: 39d413c9383b00a87153b9480ab6a91ba356d3f30b3598de0c0c8f7f3bd802c7 + url: https://github.com/DavidAce/h5pp/archive/v1.8.6.tar.gz + "1.9.0": + sha256: f633b6f76ab20e1767f55068154cf8bf553e39d526ae80947388640c57ea2056 + url: https://github.com/DavidAce/h5pp/archive/v1.9.0.tar.gz + "1.10.0": + sha256: 27a3e42ed02d8d9341229d58a517134753e1ea46dab4c40d01bb309098c32f13 + url: https://github.com/DavidAce/h5pp/archive/v1.10.0.tar.gz diff --git a/recipes/h5pp/all/conanfile.py b/recipes/h5pp/all/conanfile.py index 7b6f6d07e2372..7179031345df5 100644 --- a/recipes/h5pp/all/conanfile.py +++ b/recipes/h5pp/all/conanfile.py @@ -1,20 +1,29 @@ -import os -from conans import ConanFile, CMake, tools +from conan.tools.microsoft import is_msvc +from conans import ConanFile, tools from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.45.0" -class h5ppConan(ConanFile): +class H5ppConan(ConanFile): name = "h5pp" description = "A C++17 wrapper for HDF5 with focus on simplicity" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/DavidAce/h5pp" - topics = ("conan","h5pp","hdf5", "binary", "storage") + topics = ("h5pp", "hdf5", "binary", "storage", "header-only", "cpp17") license = "MIT" - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" - requires = "eigen/3.3.9", "spdlog/1.8.2", "hdf5/1.12.0" - - _cmake = None + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + short_paths = True + options = { + "with_eigen": [True, False], + "with_spdlog": [True, False], + } + default_options = { + "with_eigen": True, + "with_spdlog": True, + } @property def _source_subfolder(self): @@ -29,23 +38,29 @@ def _compilers_minimum_version(self): "apple-clang": "10", } - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def config_options(self): + if tools.Version(self.version) < "1.10.0": + # These dependencies are always required before h5pp 1.10.0: + # * h5pp < 1.10.0 includes any version of headers indiscriminately (e.g. system headers), + # and can't tell if the the corresponding library will be linked. This makes the, + # build and /link steps non-deterministic. + # * h5pp >= 1.10.0 fixes the issue with H5PP_USE_ preprocessor flags, to make sure + # that including the headers is intentional. + del self.options.with_eigen + del self.options.with_spdlog - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["H5PP_ENABLE_TESTS"] = False - self._cmake.definitions["H5PP_BUILD_EXAMPLES"] = False - self._cmake.definitions["H5PP_PRINT_INFO"] = False - self._cmake.definitions["H5PP_DOWNLOAD_METHOD"] = "conan" - self._cmake.configure(source_folder=self._source_subfolder) - return self._cmake + def requirements(self): + self.requires("hdf5/1.12.1") + if tools.Version(self.version) < "1.10.0" or self.options.get_safe('with_eigen'): + self.requires("eigen/3.4.0") + if tools.Version(self.version) < "1.10.0" or self.options.get_safe('with_spdlog'): + self.requires("spdlog/1.10.0") - def configure(self): - if self.settings.compiler.cppstd: + def package_id(self): + self.info.header_only() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, 17) minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) if minimum_version: @@ -54,31 +69,51 @@ def configure(self): else: self.output.warn("h5pp requires C++17. Your compiler is unknown. Assuming it supports C++17.") - def build(self): - cmake = self._configure_cmake() - cmake.build() + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def package(self): - cmake = self._configure_cmake() - cmake.install() self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - tools.rmdir(os.path.join(self.package_folder, "share")) + if tools.Version(self.version) < "1.9.0": + includedir = os.path.join(self._source_subfolder, "h5pp", "include") + else: + includedir = os.path.join(self._source_subfolder, "include") + self.copy("*", src=includedir, dst="include") def package_info(self): + self.cpp_info.set_property("cmake_file_name", "h5pp") + self.cpp_info.set_property("cmake_target_name", "h5pp::h5pp") + self.cpp_info.components["h5pp_headers"].set_property("cmake_target_name", "h5pp::headers") + self.cpp_info.components["h5pp_deps"].set_property("cmake_target_name", "h5pp::deps") + self.cpp_info.components["h5pp_flags"].set_property("cmake_target_name", "h5pp::flags") + self.cpp_info.components["h5pp_deps"].requires = ["hdf5::hdf5"] + + if tools.Version(self.version) >= "1.10.0": + if self.options.with_eigen: + self.cpp_info.components["h5pp_deps"].requires.append("eigen::eigen") + self.cpp_info.components["h5pp_flags"].defines.append("H5PP_USE_EIGEN3") + if self.options.with_spdlog: + self.cpp_info.components["h5pp_deps"].requires.append("spdlog::spdlog") + self.cpp_info.components["h5pp_flags"].defines.append("H5PP_USE_SPDLOG") + self.cpp_info.components["h5pp_flags"].defines.append("H5PP_USE_FMT") + else: + self.cpp_info.components["h5pp_deps"].requires.append("eigen::eigen") + self.cpp_info.components["h5pp_deps"].requires.append("spdlog::spdlog") + + if (self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "9") or \ + (self.settings.compiler == "clang" and self.settings.compiler.get_safe("libcxx") in ["libstdc++", "libstdc++11"]): + self.cpp_info.components["h5pp_flags"].system_libs = ["stdc++fs"] + if is_msvc(self): + self.cpp_info.components["h5pp_flags"].defines.append("NOMINMAX") + self.cpp_info.components["h5pp_flags"].cxxflags = ["/permissive-"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.names["cmake_find_package"] = "h5pp" self.cpp_info.names["cmake_find_package_multi"] = "h5pp" self.cpp_info.components["h5pp_headers"].names["cmake_find_package"] = "headers" self.cpp_info.components["h5pp_headers"].names["cmake_find_package_multi"] = "headers" self.cpp_info.components["h5pp_deps"].names["cmake_find_package"] = "deps" self.cpp_info.components["h5pp_deps"].names["cmake_find_package_multi"] = "deps" - self.cpp_info.components["h5pp_deps"].requires = ["eigen::eigen", "spdlog::spdlog", "hdf5::hdf5"] self.cpp_info.components["h5pp_flags"].names["cmake_find_package"] = "flags" self.cpp_info.components["h5pp_flags"].names["cmake_find_package_multi"] = "flags" - if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "9": - self.cpp_info.components["h5pp_flags"].system_libs = ["stdc++fs"] - if self.settings.compiler == "Visual Studio": - self.cpp_info.components["h5pp_flags"].defines = ["NOMINMAX"] - self.cpp_info.components["h5pp_flags"].cxxflags = ["/permissive-"] - - def package_id(self): - self.info.header_only() diff --git a/recipes/h5pp/all/test_package/CMakeLists.txt b/recipes/h5pp/all/test_package/CMakeLists.txt index fc326171604b4..7b0b3d3e25936 100644 --- a/recipes/h5pp/all/test_package/CMakeLists.txt +++ b/recipes/h5pp/all/test_package/CMakeLists.txt @@ -1,12 +1,11 @@ -cmake_minimum_required(VERSION 3.1.2) +cmake_minimum_required(VERSION 3.8) project(test_package CXX) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) target_compile_features(${CMAKE_PROJECT_NAME} PRIVATE cxx_std_17) - -find_package(h5pp REQUIRED) +find_package(h5pp REQUIRED CONFIG) target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE h5pp::h5pp) - diff --git a/recipes/h5pp/all/test_package/conanfile.py b/recipes/h5pp/all/test_package/conanfile.py index 9294e13566895..ca45a778caa64 100644 --- a/recipes/h5pp/all/test_package/conanfile.py +++ b/recipes/h5pp/all/test_package/conanfile.py @@ -1,10 +1,10 @@ -import os from conans import ConanFile, CMake, tools +import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package", "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,5 +12,5 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run(os.path.join("bin","test_package"), run_environment=True) diff --git a/recipes/h5pp/all/test_package/test_package.cpp b/recipes/h5pp/all/test_package/test_package.cpp index b1a1c883369f1..384a3eda62383 100644 --- a/recipes/h5pp/all/test_package/test_package.cpp +++ b/recipes/h5pp/all/test_package/test_package.cpp @@ -1,252 +1,23 @@ - #include -#include - -/*! \brief Prints the content of a vector nicely */ -template -std::ostream &operator<<(std::ostream &out, const std::vector &v) { - if(!v.empty()) { - out << "[ "; - std::copy(v.begin(), v.end(), std::ostream_iterator(out, " ")); - out << "]"; - } - return out; -} - - - - -template -struct has_scalar2 { - private: - static constexpr bool test() { - if constexpr(h5pp::type::sfinae::has_value_type_v) - return h5pp::type::sfinae::is_Scalar2_v; - else if constexpr(h5pp::type::sfinae::has_Scalar_v) - return h5pp::type::sfinae::is_Scalar2_v; - else return false; - } - public: - static constexpr bool value = test(); -}; -template -inline constexpr bool has_scalar2_v = has_scalar2::value; - - -template -struct has_scalar3 { - private: - static constexpr bool test() { - if constexpr(h5pp::type::sfinae::has_value_type_v) - return h5pp::type::sfinae::is_Scalar3_v; - else if constexpr(h5pp::type::sfinae::has_Scalar_v) - return h5pp::type::sfinae::is_Scalar3_v; - else return false; - } - public: - static constexpr bool value = test(); -}; -template -inline constexpr bool has_scalar3_v = has_scalar3::value; - -template -struct has_scalarN { - private: - static constexpr bool test() { - return has_scalar2_v or has_scalar3_v; - } - public: - static constexpr bool value = test(); -}; -template -inline constexpr bool has_scalarN_v = has_scalarN::value; - - -template -void compareScalar(const T & lhs, const T & rhs){ - if constexpr(h5pp::type::sfinae::is_Scalar2_v){ - if(lhs.x != rhs.x) throw std::runtime_error("lhs.x != rhs.x"); - if(lhs.y != rhs.y) throw std::runtime_error("lhs.y != rhs.y"); - }else if constexpr(h5pp::type::sfinae::is_Scalar3_v){ - if(lhs.x != rhs.x) throw std::runtime_error("lhs.x != rhs.x"); - if(lhs.y != rhs.y) throw std::runtime_error("lhs.y != rhs.y"); - if(lhs.z != rhs.z) throw std::runtime_error("lhs.z != rhs.z"); - } -} - - -// Store some dummy data to an hdf5 file - -template -void test_h5pp(h5pp::File & file, const WriteType & writeData, std::string_view dsetpath, std::string tag = ""){ - if(tag.empty()) tag = dsetpath; - h5pp::logger::log->info("Writing {}",tag); - file.writeDataset(writeData,dsetpath); - h5pp::logger::log->debug("Reading {}",tag); - auto readData = file.readDataset(dsetpath); - if constexpr(h5pp::type::sfinae::is_ScalarN()) { - compareScalar(writeData,readData); - } - else if constexpr (has_scalarN_v){ - if(writeData.size()!= readData.size()) throw std::runtime_error("Size mismatch in ScalarN container"); - if constexpr(h5pp::type::sfinae::is_eigen_matrix_v) - for(size_t j = 0; j < static_cast(writeData.cols()); j++) - for(size_t i = 0; i < static_cast(writeData.rows()); i++) compareScalar(writeData(i,j),readData(i,j)); - else - for(size_t i = 0; i < static_cast(writeData.size()); i++) compareScalar(writeData[i],readData[i]); - } -//#if defined(H5PP_EIGEN3) - else if constexpr(h5pp::type::sfinae::is_eigen_tensor_v and h5pp::type::sfinae::is_eigen_tensor_v){ - Eigen::Map> tensorMap(writeData.data(), writeData.size()); - Eigen::Map> tensorMapRead(readData.data(), readData.size()); - if(tensorMap != tensorMapRead){ - if constexpr (WriteType::NumIndices == 4){ - for(int i = 0; i < writeData.dimension(0); i++) - for(int j = 0; j < writeData.dimension(1); j++) - for(int k = 0; k < writeData.dimension(2); k++) { - for(int l = 0; l < writeData.dimension(3); l++) - h5pp::print("[{} {} {} {}]: {} == {}",i,j,k,l,writeData(i, j, k, l),readData(i, j, k, l)); - h5pp::print("\n"); - } - } - if constexpr (WriteType::NumIndices == 3){ - for(int i = 0; i < writeData.dimension(0); i++) - for(int j = 0; j < writeData.dimension(1); j++) - for(int k = 0; k < writeData.dimension(2); k++) { - h5pp::print("[{} {} {}]: {} == {}",i,j,k,writeData(i, j, k),readData(i, j, k)); - h5pp::print("\n"); - } - } - throw std::runtime_error("tensor written != tensor read"); - } - } -//#endif - else{ - if(writeData != readData){ - if constexpr (h5pp::type::sfinae::is_streamable_v and h5pp::type::sfinae::is_streamable_v) - std::cerr << "Wrote: \n" << writeData << "\n" << "Read: \n" << readData << std::endl; - throw std::runtime_error("Data mismatch: Write != Read"); - - } - } - - h5pp::logger::log->debug("Success"); -} - -template -void test_h5pp(h5pp::File & file, const WriteType * writeData, const DimsType & dims, std::string_view dsetpath, std::string tag = ""){ - if(tag.empty()) tag = dsetpath; - h5pp::logger::log->info("Writing {}",tag); - file.writeDataset(writeData,dsetpath,dims); - h5pp::logger::log->debug("Reading {}",tag); - auto * readData = new ReadType[size]; - file.readDataset(readData,dsetpath,dims); - for(size_t i = 0; i < size; i++){ - if(writeData[i] != readData[i]){ - for(size_t j = 0; j < size; j++){ - if constexpr (h5pp::type::sfinae::is_streamable_v and h5pp::type::sfinae::is_streamable_v) - std::cerr << "Wrote [" << j << "]: " << writeData[j] << " | Read [" << j << "]: " << readData[j] << std::endl; - } - throw std::runtime_error("Data mismatch: Write != Read"); - } - } - - delete [] readData; - h5pp::logger::log->debug("Success"); -} - - - - int main() { using cplx = std::complex; static_assert(h5pp::type::sfinae::has_data>() and - "Compile time type-checker failed. Could not properly detect class member data. Check that you are using a supported compiler!"); + "h5pp ompile time type-checker failed. Could not properly detect class member data. Check that you are using a supported compiler!"); std::string outputFilename = "test_package.h5"; - size_t logLevel = 2; + size_t logLevel = 1; h5pp::File file(outputFilename, H5F_ACC_TRUNC | H5F_ACC_RDWR, logLevel); // Generate dummy data - std::vector emptyVector; - std::string stringDummy = "Dummy string with spaces"; - std::complex cplxFloat(1, 1); - std::vector vectorDouble = {1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 1.0}; - std::vector vectorComplex = {{-0.191154, 0.326211}, {0.964728, -0.712335}, {-0.0351791, -0.10264}, {0.177544, 0.99999}}; - auto *cStyleDoubleArray = new double[10]; - for(size_t i = 0; i < 10; i++) cStyleDoubleArray[i] = static_cast(i); - - struct Field2 { - double x; - double y; - }; - struct Field3 { - double x; - double y; - double z; - }; - Field2 field2{0.53, 0.45}; - Field3 field3{0.54, 0.56, 0.58}; - std::vector field2vector(10); - for(size_t i = 0; i < field2vector.size(); i++) { - field2vector[i].x = 2.3 * i; - field2vector[i].y = 20.5 * i; - } - std::vector field3vector(10); - for(size_t i = 0; i < field3vector.size(); i++) { - field3vector[i].x = 2.3 * i; - field3vector[i].y = 20.5 * i; - field3vector[i].z = 200.9 * i; - } -#ifdef H5PP_EIGEN3 - Eigen::MatrixXd matrixDouble = Eigen::MatrixXd::Random(3,2); - Eigen::Matrix matrixSizeTRowMajor = Eigen::Matrix::Random(3,2); - Eigen::Tensor tensorComplex(2, 3, 2, 3); - tensorComplex.setRandom(); - Eigen::Tensor tensorDoubleRowMajor(2, 3, 4); - tensorDoubleRowMajor.setRandom(); - - Eigen::Matrix field2Matrix(10, 10); - for(int row = 0; row < field2Matrix.rows(); row++) - for(int col = 0; col < field2Matrix.cols(); col++) field2Matrix(row, col) = {static_cast(row), static_cast(col)}; - - Eigen::Map vectorMapDouble(vectorDouble.data(), (long) vectorDouble.size()); - Eigen::Map matrixMapDouble(matrixDouble.data(), matrixDouble.rows(), matrixDouble.cols()); - Eigen::TensorMap> tensorMapDouble(matrixDouble.data(), matrixDouble.rows(), matrixDouble.cols()); - Eigen::MatrixXd vectorMatrix = Eigen::MatrixXd::Random(10,1); -#endif - - - // Test reading and writing dummy data - test_h5pp(file,emptyVector,"emptyVector"); - test_h5pp(file,stringDummy,"stringDummy"); - test_h5pp(file,cplxFloat,"cplxFloat"); - test_h5pp(file,vectorDouble,"vectorDouble"); - test_h5pp(file,vectorComplex,"vectorComplex"); - test_h5pp<10,double>(file,cStyleDoubleArray,10,"cStyleDoubleArray"); - delete[] cStyleDoubleArray; - test_h5pp(file,field2,"field2"); - test_h5pp(file,field3,"field3"); - test_h5pp(file,field2vector,"field2vector"); - test_h5pp(file,field3vector,"field3vector"); + std::vector vectorComplexWrite = {{-0.191154, 0.326211}, {0.964728, -0.712335}, {-0.0351791, -0.10264}, {0.177544, 0.99999}}; -#ifdef H5PP_EIGEN3 - test_h5pp(file,matrixDouble,"matrixDouble"); - test_h5pp(file,matrixSizeTRowMajor,"matrixSizeTRowMajor"); - test_h5pp(file,tensorComplex,"tensorComplex"); - test_h5pp(file,tensorDoubleRowMajor,"tensorDoubleRowMajor"); - test_h5pp(file,field2Matrix,"field2Matrix"); - test_h5pp ,Eigen::VectorXd>(file,vectorMapDouble,"vectorMapDouble"); - test_h5pp ,Eigen::MatrixXd>(file,matrixMapDouble,"matrixMapDouble"); - test_h5pp>,Eigen::Tensor >(file,tensorMapDouble,"tensorMapDouble"); - test_h5pp(file,vectorMatrix,"vectorMatrix"); -#endif + // Write dummy data to file + file.writeDataset(vectorComplexWrite, "vectorComplex"); - auto foundLinksInRoot = file.findDatasets(); - for(auto &link : foundLinksInRoot) h5pp::logger::log->info("Found Link: {}", link); + // Read dummy data from file + auto vectorComplexRead = file.readDataset>("vectorComplex"); return 0; } diff --git a/recipes/h5pp/config.yml b/recipes/h5pp/config.yml index f664419a614dc..a0e0d5427545b 100644 --- a/recipes/h5pp/config.yml +++ b/recipes/h5pp/config.yml @@ -5,3 +5,9 @@ versions: folder: "all" "1.8.5": folder: "all" + "1.8.6": + folder: "all" + "1.9.0": + folder: "all" + "1.10.0": + folder: "all" diff --git a/recipes/half/all/conandata.yml b/recipes/half/all/conandata.yml new file mode 100644 index 0000000000000..dd92109aef829 --- /dev/null +++ b/recipes/half/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.2.0": + url: "https://sourceforge.net/projects/half/files/half/2.2.0/half-2.2.0.zip" + sha256: "1d1d9e482fb95fcd7cab0953a4bd35e00b86578f11cb6939a067811a055a563b" diff --git a/recipes/half/all/conanfile.py b/recipes/half/all/conanfile.py new file mode 100644 index 0000000000000..64b104957470d --- /dev/null +++ b/recipes/half/all/conanfile.py @@ -0,0 +1,44 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class HalfConan(ConanFile): + name = "half" + description = ( + "C++ header-only library to provide an IEEE 754 conformant 16-bit " + "half-precision floating-point type along with corresponding " + "arithmetic operators, type conversions and common mathematical " + "functions." + ) + license = "MIT" + topics = ("half", "half-precision", "float", "arithmetic") + homepage = "https://sourceforge.net/projects/half" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "half.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/half/all/test_package/CMakeLists.txt b/recipes/half/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8909a3f1339ea --- /dev/null +++ b/recipes/half/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(half REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE half::half) diff --git a/recipes/half/all/test_package/conanfile.py b/recipes/half/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/half/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/half/all/test_package/test_package.cpp b/recipes/half/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..020dd06e55072 --- /dev/null +++ b/recipes/half/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include + +#include + +int main() { + half_float::half a(3.4), b(5); + half_float::half c = a * b; + c += 3; + std::cout << c << std::endl; + return 0; +} diff --git a/recipes/half/all/test_v1_package/CMakeLists.txt b/recipes/half/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..c8aa9412f7287 --- /dev/null +++ b/recipes/half/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(half REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE half::half) diff --git a/recipes/half/all/test_v1_package/conanfile.py b/recipes/half/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/half/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/half/config.yml b/recipes/half/config.yml new file mode 100644 index 0000000000000..1979b3114ab95 --- /dev/null +++ b/recipes/half/config.yml @@ -0,0 +1,3 @@ +versions: + "2.2.0": + folder: all diff --git a/recipes/hana/all/conandata.yml b/recipes/hana/all/conandata.yml index b9bcdf75d4c8b..5300848922c23 100644 --- a/recipes/hana/all/conandata.yml +++ b/recipes/hana/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.79.0": + url: "https://github.com/boostorg/hana/archive/boost-1.79.0.tar.gz" + sha256: "dcaaa99a2c09394c366347b40b001a0a762da59e6136485a4157a820759a9a58" + "boost-1.78.0": + url: "https://github.com/boostorg/hana/archive/boost-1.78.0.tar.gz" + sha256: "f713c2888e849f66b90c01fecb69924538a2d1440bfa432d92c8f600bc98ad49" "boost-1.74.0": url: "https://github.com/boostorg/hana/archive/boost-1.74.0.tar.gz" sha256: "d50b366aca035b7fbeaf1cadc3bad0edd9d68d98b297dcf9473bbfb0f52408b8" diff --git a/recipes/hana/all/conanfile.py b/recipes/hana/all/conanfile.py index 731b090ced83c..246b40e89dc55 100644 --- a/recipes/hana/all/conanfile.py +++ b/recipes/hana/all/conanfile.py @@ -1,9 +1,10 @@ from conans import ConanFile, tools from conans.errors import ConanInvalidConfiguration import os +import textwrap +required_conan_version = ">=1.33.0" -required_conan_version = ">=1.28.0" class HanaConan(ConanFile): name = "hana" @@ -15,43 +16,77 @@ class HanaConan(ConanFile): settings = "compiler" no_copy_source = True - _compiler_cpp14_support = { - "gcc": "4.9.3", - "Visual Studio": "14.0", - "clang": "3.4", - "apple-clang": "3.4", - } - @property def _source_subfolder(self): return "_source_subfolder" - def configure(self): - if self.settings.compiler.cppstd: + @property + def _compilers_minimum_version(self): + return { + "gcc": "5", + "Visual Studio": "14", + "clang": "3.4", + "apple-clang": "3.4", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, "14") - try: - minimum_required_version = self._compiler_cpp14_support[str(self.settings.compiler)] - if self.settings.compiler.version < tools.Version(minimum_required_version): - raise ConanInvalidConfiguration( - "This compiler is too old. This library needs a compiler with c++14 support") - except KeyError: - self.output.warn("This recipe might not support the compiler. Consider adding it.") + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if not minimum_version: + self.output.warn("{} {} requires C++14. Your compiler is unknown. Assuming it supports C++14.".format(self.name, self.version)) + elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration("{} {} requires C++14, which your compiler does not support.".format(self.name, self.version)) def package_id(self): self.info.header_only() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("hana-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def package(self): self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"hana": "hana::hana"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake") + + @property + def _module_file_rel_path(self): + return os.path.join(self._module_subfolder, + "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): - # TODO: CMake imported target shouldn't be namespaced (waiting https://github.com/conan-io/conan/issues/7615 to be implemented) self.cpp_info.filenames["cmake_find_package"] = "Hana" self.cpp_info.filenames["cmake_find_package_multi"] = "Hana" self.cpp_info.names["cmake_find_package"] = "hana" self.cpp_info.names["cmake_find_package_multi"] = "hana" + self.cpp_info.builddirs.append(self._module_subfolder) + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] self.cpp_info.names["pkg_config"] = "hana" diff --git a/recipes/hana/all/test_package/CMakeLists.txt b/recipes/hana/all/test_package/CMakeLists.txt index c8416449ae982..35d91de00798e 100644 --- a/recipes/hana/all/test_package/CMakeLists.txt +++ b/recipes/hana/all/test_package/CMakeLists.txt @@ -7,5 +7,5 @@ conan_basic_setup(TARGETS) find_package(Hana REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} hana::hana) # TODO: remove hana:: namespace when fixed in conanfile.py of hana +target_link_libraries(${PROJECT_NAME} hana) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) diff --git a/recipes/hana/config.yml b/recipes/hana/config.yml index fb2cf013fb412..034bff6f60fd2 100644 --- a/recipes/hana/config.yml +++ b/recipes/hana/config.yml @@ -1,4 +1,8 @@ versions: + "1.79.0": + folder: all + "boost-1.78.0": + folder: all "boost-1.74.0": folder: all "1.6.0": diff --git a/recipes/happly/all/conandata.yml b/recipes/happly/all/conandata.yml new file mode 100644 index 0000000000000..2e27bba5a746f --- /dev/null +++ b/recipes/happly/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20200822": + url: "https://github.com/nmwsharp/happly/archive/88f79725d32d78e0e637ebf42d8432d519e1c7d0.tar.gz" + sha256: 61c6d112ac011408eab2154f145a9b71e188fa4b60cf3903b95e08f3a0d1fb17 diff --git a/recipes/happly/all/conanfile.py b/recipes/happly/all/conanfile.py new file mode 100644 index 0000000000000..21fdcfcb45fd6 --- /dev/null +++ b/recipes/happly/all/conanfile.py @@ -0,0 +1,30 @@ +from conans import ConanFile, tools + + +class HapplyConan(ConanFile): + name = "happly" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/nmwsharp/happly" + topics = ("conan", "happly", "ply", "3D") + license = "MIT" + description = "A C++ header-only parser for the PLY file format. Parse .ply happily!" + settings = "compiler" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, 11) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + self.copy("happly.h", src=self._source_subfolder, dst="include") + + def package_id(self): + self.info.header_only() diff --git a/recipes/openexr/2.3.0/test_package/CMakeLists.txt b/recipes/happly/all/test_package/CMakeLists.txt similarity index 100% rename from recipes/openexr/2.3.0/test_package/CMakeLists.txt rename to recipes/happly/all/test_package/CMakeLists.txt diff --git a/recipes/happly/all/test_package/conanfile.py b/recipes/happly/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5a25a64cfaaa9 --- /dev/null +++ b/recipes/happly/all/test_package/conanfile.py @@ -0,0 +1,21 @@ +import glob +import os + +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + self.run(os.path.join("bin", "test_package")) + # Let's check if the *.ply file has been created successfully + ply_format_file = glob.glob("*.ply")[0] + assert os.path.exists(ply_format_file) diff --git a/recipes/happly/all/test_package/test_package.cpp b/recipes/happly/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..27aa667aff6c1 --- /dev/null +++ b/recipes/happly/all/test_package/test_package.cpp @@ -0,0 +1,24 @@ +#include + + +int main(int argc, char const *argv[]) +{ + // Suppose these hold your data + std::vector> meshVertexPositions; + std::vector> meshVertexColors; + std::vector> meshFaceIndices; + + // Create an empty object + happly::PLYData plyOut; + + // Add mesh data (elements are created automatically) + plyOut.addVertexPositions(meshVertexPositions); + plyOut.addVertexColors(meshVertexColors); + plyOut.addFaceIndices(meshFaceIndices); + + + // Write the object to file + plyOut.write("my_output_mesh_file.ply", happly::DataFormat::ASCII); + + return 0; +} diff --git a/recipes/happly/config.yml b/recipes/happly/config.yml new file mode 100644 index 0000000000000..2c1035136c9e0 --- /dev/null +++ b/recipes/happly/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20200822": + folder: all diff --git a/recipes/harfbuzz/all/CMakeLists.txt b/recipes/harfbuzz/all/CMakeLists.txt deleted file mode 100644 index ab8917b4ee2a2..0000000000000 --- a/recipes/harfbuzz/all/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -set(THIRD_PARTY_LIBS ${CONAN_LIBS}) - -add_subdirectory(source_subfolder) diff --git a/recipes/harfbuzz/all/conandata.yml b/recipes/harfbuzz/all/conandata.yml index ac647e301077c..a3c91fbe23361 100644 --- a/recipes/harfbuzz/all/conandata.yml +++ b/recipes/harfbuzz/all/conandata.yml @@ -1,44 +1,30 @@ sources: - "2.6.8": - sha256: "059054760ff471d81171659a136dd253a0ddff7faa9249727cca3d7dbd356a6c" - url: "https://github.com/harfbuzz/harfbuzz/archive/2.6.8.tar.gz" - "2.7.0": - sha256: "4dba05de1fd44705f54c40d801e0e3d4833555d004cb611cc18675173feae75b" - url: "https://github.com/harfbuzz/harfbuzz/archive/2.7.0.tar.gz" - "2.7.1": - sha256: "431c856ff18eeca89b2a36b58f2c2d56273cd522c34c0ffbc9dd6f7da4b9bd08" - url: "https://github.com/harfbuzz/harfbuzz/archive/2.7.1.tar.gz" - "2.7.2": - sha256: "8ec112ee108642477478b75fc7906422abed404d7530e47ba0a4875f553f1b59" - url: "https://github.com/harfbuzz/harfbuzz/archive/2.7.2.tar.gz" - "2.7.4": - sha256: "daff8a4003ac420a8550760ed303ce33b310c8ea17b7f15b307d1969cabcebcb" - url: "https://github.com/harfbuzz/harfbuzz/archive/2.7.4.tar.gz" - "2.8.0": - sha256: "9444358d1d8c1884c3a25b02fe702bd244172c4fdd2e98f5a165bc0987ef34f6" - url: "https://github.com/harfbuzz/harfbuzz/archive/2.8.0.tar.gz" - "2.8.1": - url: "https://github.com/harfbuzz/harfbuzz/archive/2.8.1.tar.gz" - sha256: "b3f17394c5bccee456172b2b30ddec0bb87e9c5df38b4559a973d14ccd04509d" + "3.2.0": + url: "https://github.com/harfbuzz/harfbuzz/releases/download/3.2.0/harfbuzz-3.2.0.tar.xz" + sha256: "0ada50a1c199bb6f70843ab893c55867743a443b84d087d54df08ad883ebc2cd" + "4.4.1": + url: "https://github.com/harfbuzz/harfbuzz/releases/download/4.4.1/harfbuzz-4.4.1.tar.xz" + sha256: "c5bc33ac099b2e52f01d27cde21cee4281b9d5bfec7684135e268512478bc9ee" + "5.1.0": + url: "https://github.com/harfbuzz/harfbuzz/releases/download/5.1.0/harfbuzz-5.1.0.tar.xz" + sha256: "2edb95db668781aaa8d60959d21be2ff80085f31b12053cdd660d9a50ce84f05" + "5.2.0": + url: "https://github.com/harfbuzz/harfbuzz/releases/download/5.2.0/harfbuzz-5.2.0.tar.xz" + sha256: "735a94917b47936575acb4d4fa7e7986522f8a89527e4635721474dee2bc942c" + "5.3.0": + url: "https://github.com/harfbuzz/harfbuzz/archive/5.3.0.tar.gz" + sha256: "94712b8cdae68f0b585ec8e3cd8c5160fdc241218119572236497a62dae770de" + "5.3.1": + url: "https://github.com/harfbuzz/harfbuzz/archive/5.3.1.tar.gz" + sha256: "77c8c903f4539b050a6d3a5be79705c7ccf7b1cb66d68152a651486e261edbd2" patches: - "2.6.8": - - patch_file: "patches/icu.patch" - base_path: "source_subfolder" - "2.7.0": - - patch_file: "patches/icu.patch" - base_path: "source_subfolder" - "2.7.1": - - patch_file: "patches/icu.patch" - base_path: "source_subfolder" - "2.7.2": - - patch_file: "patches/icu.patch" - base_path: "source_subfolder" - "2.7.4": - - patch_file: "patches/icu.patch" - base_path: "source_subfolder" - "2.8.0": - - patch_file: "patches/icu-2.8.x.patch" - base_path: "source_subfolder" - "2.8.1": - - patch_file: "patches/icu-2.8.x.patch" - base_path: "source_subfolder" + "4.4.1": + - patch_file: "patches/0000-fix-freetype-lookup-4.4.1.patch" + patch_type: "portability" + patch_description: "fix fretype and icu dependency lookup" + patch_source: "https://github.com/harfbuzz/harfbuzz/pull/3811" + "5.1.0": + - patch_file: "patches/0000-fix-freetype-lookup-5.1.0.patch" + patch_type: "portability" + patch_description: "fix fretype and icu dependency lookup" + patch_source: "https://github.com/harfbuzz/harfbuzz/pull/3811" diff --git a/recipes/harfbuzz/all/conanfile.py b/recipes/harfbuzz/all/conanfile.py index 22a7878a9ffd4..5f497e976e583 100644 --- a/recipes/harfbuzz/all/conanfile.py +++ b/recipes/harfbuzz/all/conanfile.py @@ -1,15 +1,37 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os, fix_apple_shared_install_name +from conan.tools.build import can_run +from conan.tools.env import VirtualBuildEnv +from conan.tools.gnu import PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.files import ( + copy, + apply_conandata_patches, + export_conandata_patches, + get, + rename, + rm, + rmdir +) +from conan.tools.microsoft import is_msvc_static_runtime, is_msvc +from conan.tools.scm import Version +from conans.tools import stdcpp_library + +import glob import os +required_conan_version = ">=1.53.0" + class HarfbuzzConan(ConanFile): name = "harfbuzz" description = "HarfBuzz is an OpenType text shaping engine." - topics = ("conan", "harfbuzz", "opentype", "text", "engine") + topics = ("opentype", "text", "engine") url = "https://github.com/conan-io/conan-center-index" homepage = "http://harfbuzz.org" license = "MIT" - settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -20,6 +42,7 @@ class HarfbuzzConan(ConanFile): "with_gdi": [True, False], "with_uniscribe": [True, False], "with_directwrite": [True, False], + "with_subset": [True, False], } default_options = { "shared": False, @@ -29,22 +52,14 @@ class HarfbuzzConan(ConanFile): "with_glib": True, "with_gdi": True, "with_uniscribe": True, - "with_directwrite": False + "with_directwrite": False, + "with_subset": False, } short_paths = True - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -56,63 +71,119 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + if self.options.shared and self.options.with_glib: + self.options["glib"].shared = True + + def validate(self): + if self.info.options.shared and self.info.options.with_glib and not self.dependencies["glib"].options.shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) + if Version(self.version) >= "4.4.0": + if self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) < "7": + raise ConanInvalidConfiguration("New versions of harfbuzz require at least gcc 7") + + if self.info.options.with_glib and self.dependencies["glib"].options.shared and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) def requirements(self): if self.options.with_freetype: - self.requires("freetype/2.10.4") + self.requires("freetype/2.12.1") if self.options.with_icu: - self.requires("icu/68.2") + self.requires("icu/71.1") if self.options.with_glib: - self.requires("glib/2.68.0") + self.requires("glib/2.75.0") + + def layout(self): + basic_layout(self, src_folder="src") + + def generate(self): + def is_enabled(value): + return "enabled" if value else "disabled" + + def meson_backend_and_flags(): + def is_vs_2017(): + version = Version(self.settings.compiler.version) + return version == "15" or version == "191" + + if is_msvc(self) and is_vs_2017() and self.settings.build_type == "Debug": + # Mitigate https://learn.microsoft.com/en-us/cpp/build/reference/zf?view=msvc-170 + return "vs", ["/bigobj"] + return "ninja", [] + + PkgConfigDeps(self).generate() + + backend, cxxflags = meson_backend_and_flags() + tc = MesonToolchain(self, backend=backend) + tc.project_options.update({ + "glib": is_enabled(self.options.with_glib), + "icu": is_enabled(self.options.with_icu), + "freetype": is_enabled(self.options.with_freetype), + "gdi": is_enabled(self.options.get_safe("with_gdi")), + "directwrite": is_enabled(self.options.get_safe("with_directwrite")), + "gobject": is_enabled(can_run(self) and self.options.with_glib), + "introspection": is_enabled(False), + "tests": "disabled", + "docs": "disabled", + "benchmark": "disabled", + "icu_builtin": "false" + }) + tc.cpp_args += cxxflags + tc.generate() + + VirtualBuildEnv(self).generate() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["HB_HAVE_FREETYPE"] = self.options.with_freetype - self._cmake.definitions["HB_HAVE_GRAPHITE2"] = False - self._cmake.definitions["HB_HAVE_GLIB"] = self.options.with_glib - self._cmake.definitions["HB_HAVE_ICU"] = self.options.with_icu - if tools.is_apple_os(self.settings.os): - self._cmake.definitions["HB_HAVE_CORETEXT"] = True - elif self.settings.os == "Windows": - self._cmake.definitions["HB_HAVE_GDI"] = self.options.with_gdi - self._cmake.definitions["HB_HAVE_UNISCRIBE"] = self.options.with_uniscribe - self._cmake.definitions["HB_HAVE_DIRECTWRITE"] = self.options.with_directwrite - self._cmake.definitions["HB_BUILD_UTILS"] = False - self._cmake.definitions["HB_BUILD_SUBSET"] = False - self._cmake.definitions["HB_HAVE_GOBJECT"] = False - self._cmake.definitions["HB_HAVE_INTROSPECTION"] = False - # fix for MinGW debug build - if self.settings.compiler == "gcc" and self.settings.os == "Windows": - self._cmake.definitions["CMAKE_C_FLAGS"] = "-Wa,-mbig-obj" - self._cmake.definitions["CMAKE_CXX_FLAGS"] = "-Wa,-mbig-obj" - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build_requirements(self): + self.tool_requires("meson/0.64.1") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/1.9.3") + self.tool_requires("glib/2.75.0") def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() - cmake.build() + apply_conandata_patches(self) + meson = Meson(self) + meson.configure() + meson.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() - cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + def fix_msvc_libname(remove_lib_prefix=True): + """remove lib prefix & change extension to .lib""" + if not is_msvc(self): + return + libdirs = getattr(self.cpp.package, "libdirs") + for libdir in libdirs: + for ext in [".dll.a", ".dll.lib", ".a"]: + full_folder = os.path.join(self.package_folder, libdir) + for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")): + libname = os.path.basename(filepath)[0:-len(ext)] + if remove_lib_prefix and libname[0:3] == "lib": + libname = libname[3:] + rename(self, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib")) + + meson = Meson(self) + meson.install() + fix_msvc_libname() + fix_apple_shared_install_name(self) + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): self.cpp_info.names["cmake_find_package"] = "harfbuzz" self.cpp_info.names["cmake_find_package_multi"] = "harfbuzz" + self.cpp_info.set_property("pkg_config_name", "harfbuzz") if self.options.with_icu: self.cpp_info.libs.append("harfbuzz-icu") + if self.options.with_subset: + self.cpp_info.libs.append("harfbuzz-subset") self.cpp_info.libs.append("harfbuzz") self.cpp_info.includedirs.append(os.path.join("include", "harfbuzz")) if self.settings.os == "Linux": @@ -127,9 +198,13 @@ def package_info(self): self.cpp_info.system_libs.append("usp10") if self.options.with_directwrite: self.cpp_info.system_libs.append("dwrite") - if self.settings.os == "Macos": - self.cpp_info.frameworks.extend(["CoreFoundation", "CoreGraphics", "CoreText"]) + if is_apple_os(self): + self.cpp_info.frameworks.extend(["CoreFoundation", "CoreGraphics", "CoreText", "ApplicationServices"]) if not self.options.shared: - libcxx = tools.stdcpp_library(self) + libcxx = stdcpp_library(self) if libcxx: self.cpp_info.system_libs.append(libcxx) + + def package_id(self): + if self.options.with_glib and not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() diff --git a/recipes/harfbuzz/all/patches/0000-fix-freetype-lookup-4.4.1.patch b/recipes/harfbuzz/all/patches/0000-fix-freetype-lookup-4.4.1.patch new file mode 100644 index 0000000000000..708b5d9734b00 --- /dev/null +++ b/recipes/harfbuzz/all/patches/0000-fix-freetype-lookup-4.4.1.patch @@ -0,0 +1,99 @@ +diff --git a/meson.build b/meson.build +index 4a69d6d9e..a82ff598c 100644 +--- a/meson.build ++++ b/meson.build +@@ -21,7 +21,7 @@ pkgmod = import('pkgconfig') + cpp = meson.get_compiler('cpp') + null_dep = dependency('', required: false) + +-if cpp.get_id() == 'msvc' ++if cpp.get_argument_syntax() == 'msvc' + # Ignore several spurious warnings for things HarfBuzz does very commonly. + # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it + # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once +@@ -83,25 +83,39 @@ check_funcs = [ + + m_dep = cpp.find_library('m', required: false) + +-# https://github.com/harfbuzz/harfbuzz/pull/2498 +-freetype_dep = dependency(cpp.get_argument_syntax() == 'msvc' ? 'freetype' : 'freetype2', +- required: get_option('freetype'), +- default_options: ['harfbuzz=disabled']) ++ ++# Try pkgconfig name ++freetype_dep = dependency('freetype2', required: false) ++if not freetype_dep.found() ++ # Try cmake name ++ freetype_dep = dependency('freetype', required: false) ++endif ++if not freetype_dep.found() ++ # Subproject fallback, `allow_fallback: true` means the fallback will be ++ # tried even if the freetype option is set to `auto`. ++ freetype_dep = dependency('freetype2', ++ required: get_option('freetype'), ++ default_options: ['harfbuzz=disabled'], ++ allow_fallback: true) ++endif + + glib_dep = dependency('glib-2.0', required: get_option('glib')) + gobject_dep = dependency('gobject-2.0', required: get_option('gobject')) + graphite2_dep = dependency('graphite2', required: get_option('graphite2')) + graphite_dep = dependency('graphite2', required: get_option('graphite')) + +-if cpp.get_argument_syntax() == 'msvc' ++# Try pkgconfig name ++icu_dep = dependency('icu-uc', required: false) ++if not icu_dep.found() ++ # Try cmake name + icu_dep = dependency('ICU', +- required: get_option('icu'), ++ required: false, + components: 'uc', + method: 'cmake') +-else +- icu_dep = dependency('icu-uc', +- required: get_option('icu'), +- method: 'pkg-config') ++endif ++if not icu_dep.found() ++ # Subproject fallback if icu option is enabled ++ icu_dep = dependency('icu-uc', required: get_option('icu')) + endif + + if icu_dep.found() and icu_dep.type_name() == 'pkgconfig' +@@ -118,7 +132,7 @@ if not get_option('cairo').disabled() + cairo_ft_dep = dependency('cairo-ft', required: false) + + if (not cairo_dep.found() and +- cpp.get_id() == 'msvc' and ++ cpp.get_argument_syntax() == 'msvc' and + cpp.has_header('cairo.h')) + cairo_dep = cpp.find_library('cairo', required: false) + if cairo_dep.found() and cpp.has_function('cairo_ft_font_face_create_for_ft_face', +@@ -198,6 +212,7 @@ if freetype_dep.found() + ['FT_Get_Var_Blend_Coordinates', {'deps': freetype_dep}], + ['FT_Set_Var_Blend_Coordinates', {'deps': freetype_dep}], + ['FT_Done_MM_Var', {'deps': freetype_dep}], ++ ['FT_Get_Transform', {'deps': freetype_dep}], + ] + + if freetype_dep.type_name() == 'internal' +@@ -232,17 +247,12 @@ if host_machine.system() == 'windows' and not get_option('gdi').disabled() + endif + + # DirectWrite (Windows) +-directwrite_dep = null_dep + if host_machine.system() == 'windows' and not get_option('directwrite').disabled() + if get_option('directwrite').enabled() and not cpp.has_header('dwrite_1.h') + error('DirectWrite was enabled explicitly, but required header is missing.') + endif + +- directwrite_dep = cpp.find_library('dwrite', required: get_option('directwrite')) +- +- if directwrite_dep.found() +- conf.set('HAVE_DIRECTWRITE', 1) +- endif ++ conf.set('HAVE_DIRECTWRITE', 1) + endif + + # CoreText (macOS) diff --git a/recipes/harfbuzz/all/patches/0000-fix-freetype-lookup-5.1.0.patch b/recipes/harfbuzz/all/patches/0000-fix-freetype-lookup-5.1.0.patch new file mode 100644 index 0000000000000..f3992bf9530f0 --- /dev/null +++ b/recipes/harfbuzz/all/patches/0000-fix-freetype-lookup-5.1.0.patch @@ -0,0 +1,72 @@ +diff --git a/meson.build b/meson.build +index df4443fb2..b8b143948 100644 +--- a/meson.build ++++ b/meson.build +@@ -21,7 +21,7 @@ pkgmod = import('pkgconfig') + cpp = meson.get_compiler('cpp') + null_dep = dependency('', required: false) + +-if cpp.get_id() == 'msvc' ++if cpp.get_argument_syntax() == 'msvc' + # Ignore several spurious warnings for things HarfBuzz does very commonly. + # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it + # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once +@@ -83,25 +83,39 @@ check_funcs = [ + + m_dep = cpp.find_library('m', required: false) + +-# https://github.com/harfbuzz/harfbuzz/pull/2498 +-freetype_dep = dependency(cpp.get_argument_syntax() == 'msvc' ? 'freetype' : 'freetype2', +- required: get_option('freetype'), +- default_options: ['harfbuzz=disabled']) ++ ++# Try pkgconfig name ++freetype_dep = dependency('freetype2', required: false) ++if not freetype_dep.found() ++ # Try cmake name ++ freetype_dep = dependency('freetype', required: false) ++endif ++if not freetype_dep.found() ++ # Subproject fallback, `allow_fallback: true` means the fallback will be ++ # tried even if the freetype option is set to `auto`. ++ freetype_dep = dependency('freetype2', ++ required: get_option('freetype'), ++ default_options: ['harfbuzz=disabled'], ++ allow_fallback: true) ++endif + + glib_dep = dependency('glib-2.0', required: get_option('glib')) + gobject_dep = dependency('gobject-2.0', required: get_option('gobject')) + graphite2_dep = dependency('graphite2', required: get_option('graphite2')) + graphite_dep = dependency('graphite2', required: get_option('graphite')) + +-if cpp.get_argument_syntax() == 'msvc' ++# Try pkgconfig name ++icu_dep = dependency('icu-uc', required: false) ++if not icu_dep.found() ++ # Try cmake name + icu_dep = dependency('ICU', +- required: get_option('icu'), ++ required: false, + components: 'uc', + method: 'cmake') +-else +- icu_dep = dependency('icu-uc', +- required: get_option('icu'), +- method: 'pkg-config') ++endif ++if not icu_dep.found() ++ # Subproject fallback if icu option is enabled ++ icu_dep = dependency('icu-uc', required: get_option('icu')) + endif + + if icu_dep.found() and icu_dep.type_name() == 'pkgconfig' +@@ -118,7 +132,7 @@ if not get_option('cairo').disabled() + cairo_ft_dep = dependency('cairo-ft', required: false) + + if (not cairo_dep.found() and +- cpp.get_id() == 'msvc' and ++ cpp.get_argument_syntax() == 'msvc' and + cpp.has_header('cairo.h')) + cairo_dep = cpp.find_library('cairo', required: false) + if cairo_dep.found() and cpp.has_function('cairo_ft_font_face_create_for_ft_face', diff --git a/recipes/harfbuzz/all/patches/icu-2.8.x.patch b/recipes/harfbuzz/all/patches/icu-2.8.x.patch deleted file mode 100644 index a0a28dc97ea79..0000000000000 --- a/recipes/harfbuzz/all/patches/icu-2.8.x.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -241,16 +241,16 @@ if (HB_HAVE_ICU) -- find_package(PkgConfig) -- pkg_check_modules(PC_ICU QUIET icu-uc) -+ # find_package(PkgConfig) -+ # pkg_check_modules(PC_ICU QUIET icu-uc) - -- find_path(ICU_INCLUDE_DIR NAMES unicode/utypes.h HINTS ${PC_ICU_INCLUDE_DIRS} ${PC_ICU_INCLUDEDIR}) -- find_library(ICU_LIBRARY NAMES libicuuc cygicuuc cygicuuc32 icuuc HINTS ${PC_ICU_LIBRARY_DIRS} ${PC_ICU_LIBDIR}) -+ # find_path(ICU_INCLUDE_DIR NAMES unicode/utypes.h HINTS ${PC_ICU_INCLUDE_DIRS} ${PC_ICU_INCLUDEDIR}) -+ # find_library(ICU_LIBRARY NAMES libicuuc cygicuuc cygicuuc32 icuuc HINTS ${PC_ICU_LIBRARY_DIRS} ${PC_ICU_LIBDIR}) - -- include_directories(${ICU_INCLUDE_DIR}) -+ # include_directories(${ICU_INCLUDE_DIR}) - - list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-icu.h) - -- list(APPEND THIRD_PARTY_LIBS ${ICU_LIBRARY}) -+ # list(APPEND THIRD_PARTY_LIBS ${ICU_LIBRARY}) - -- mark_as_advanced(ICU_INCLUDE_DIR ICU_LIBRARY) -+ # mark_as_advanced(ICU_INCLUDE_DIR ICU_LIBRARY) - endif () - - if (APPLE AND HB_HAVE_CORETEXT) diff --git a/recipes/harfbuzz/all/patches/icu.patch b/recipes/harfbuzz/all/patches/icu.patch deleted file mode 100644 index 5e8bb0f79b78b..0000000000000 --- a/recipes/harfbuzz/all/patches/icu.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -237,16 +237,16 @@ if (HB_HAVE_ICU) -- find_package(PkgConfig) -- pkg_check_modules(PC_ICU QUIET icu-uc) -+ # find_package(PkgConfig) -+ # pkg_check_modules(PC_ICU QUIET icu-uc) - -- find_path(ICU_INCLUDE_DIR NAMES unicode/utypes.h HINTS ${PC_ICU_INCLUDE_DIRS} ${PC_ICU_INCLUDEDIR}) -- find_library(ICU_LIBRARY NAMES libicuuc cygicuuc cygicuuc32 icuuc HINTS ${PC_ICU_LIBRARY_DIRS} ${PC_ICU_LIBDIR}) -+ # find_path(ICU_INCLUDE_DIR NAMES unicode/utypes.h HINTS ${PC_ICU_INCLUDE_DIRS} ${PC_ICU_INCLUDEDIR}) -+ # find_library(ICU_LIBRARY NAMES libicuuc cygicuuc cygicuuc32 icuuc HINTS ${PC_ICU_LIBRARY_DIRS} ${PC_ICU_LIBDIR}) - -- include_directories(${ICU_INCLUDE_DIR}) -+ # include_directories(${ICU_INCLUDE_DIR}) - - list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-icu.h) - -- list(APPEND THIRD_PARTY_LIBS ${ICU_LIBRARY}) -+ # list(APPEND THIRD_PARTY_LIBS ${ICU_LIBRARY}) - -- mark_as_advanced(ICU_INCLUDE_DIR ICU_LIBRARY) -+ # mark_as_advanced(ICU_INCLUDE_DIR ICU_LIBRARY) - endif () - - if (APPLE AND HB_HAVE_CORETEXT) diff --git a/recipes/harfbuzz/all/test_package/CMakeLists.txt b/recipes/harfbuzz/all/test_package/CMakeLists.txt index f6b87bd606ca0..80c151599daee 100644 --- a/recipes/harfbuzz/all/test_package/CMakeLists.txt +++ b/recipes/harfbuzz/all/test_package/CMakeLists.txt @@ -1,14 +1,8 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/example.ttf - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - find_package(harfbuzz REQUIRED CONFIG) -add_executable(${PROJECT_NAME} example.c) -target_link_libraries(${PROJECT_NAME} harfbuzz::harfbuzz) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE harfbuzz::harfbuzz) set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/harfbuzz/all/test_package/conanfile.py b/recipes/harfbuzz/all/test_package/conanfile.py index 5f8bb36dc8d1d..e9a060aba448d 100644 --- a/recipes/harfbuzz/all/test_package/conanfile.py +++ b/recipes/harfbuzz/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + test_type = "explicit" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,7 +22,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - + if can_run(self): + font = os.path.join(self.source_folder, "example.ttf") + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(f"{bin_path} {font}", env="conanrun") diff --git a/recipes/harfbuzz/all/test_package/example.c b/recipes/harfbuzz/all/test_package/example.c deleted file mode 100644 index 70550526517c1..0000000000000 --- a/recipes/harfbuzz/all/test_package/example.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright © 2011 Google, Inc. - * - * This is part of HarfBuzz, a text shaping library. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - * - * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN - * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * Google Author(s): Behdad Esfahbod - */ - -#include -#include -#include - -#include "harfbuzz/hb.h" -#include "harfbuzz/hb-ot.h" - -#define FONT_SIZE 36 -#define MARGIN (FONT_SIZE * .5) - -/* Use native open type implementation to load font - https://github.com/harfbuzz/harfbuzz/issues/255 */ -hb_font_t* -get_font_ot(const char *filename, int size) -{ - size_t result = 0; - FILE* file = fopen(filename, "rb"); - fseek(file, 0, SEEK_END); - unsigned int length = ftell(file); - fseek(file, 0, SEEK_SET); - - char* data = (char*) malloc(length); - result = fread(data, length, 1, file); - if (result != 1) - { - fputs ("Reading error", stderr); - exit (3); - } - fclose(file); - - hb_blob_t* blob = hb_blob_create(data, length, HB_MEMORY_MODE_WRITABLE, (void*)data, NULL); - hb_face_t* face = hb_face_create(blob, 0); - hb_font_t* font = hb_font_create(face); - - hb_ot_font_set_funcs(font); - hb_font_set_scale(font, size, size); - - return font; -} - -int -main(int argc, char **argv) -{ - const char *fontfile = "example.ttf"; - const char *text = "Bincrafters"; - - /* Create hb-ft font. */ - hb_font_t *hb_font; - hb_font = get_font_ot (fontfile, FONT_SIZE*64); - - /* Create hb-buffer and populate. */ - hb_buffer_t *hb_buffer; - hb_buffer = hb_buffer_create (); - hb_buffer_add_utf8 (hb_buffer, text, -1, 0, -1); - hb_buffer_guess_segment_properties (hb_buffer); - - /* Shape it! */ - hb_shape (hb_font, hb_buffer, NULL, 0); - - /* Get glyph information and positions out of the buffer. */ - unsigned int len = hb_buffer_get_length (hb_buffer); - hb_glyph_info_t *info = hb_buffer_get_glyph_infos (hb_buffer, NULL); - hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (hb_buffer, NULL); - - /* Print them out as is. */ - printf ("Raw buffer contents:\n"); - for (unsigned int i = 0; i < len; i++) - { - hb_codepoint_t gid = info[i].codepoint; - unsigned int cluster = info[i].cluster; - double x_advance = pos[i].x_advance / 64.; - double y_advance = pos[i].y_advance / 64.; - double x_offset = pos[i].x_offset / 64.; - double y_offset = pos[i].y_offset / 64.; - - char glyphname[32]; - hb_font_get_glyph_name (hb_font, gid, glyphname, sizeof (glyphname)); - - printf ("glyph='%s' cluster=%d advance=(%g,%g) offset=(%g,%g)\n", - glyphname, cluster, x_advance, y_advance, x_offset, y_offset); - } - - printf ("Converted to absolute positions:\n"); - /* And converted to absolute positions. */ - { - double current_x = 0; - double current_y = 0; - for (unsigned int i = 0; i < len; i++) - { - hb_codepoint_t gid = info[i].codepoint; - unsigned int cluster = info[i].cluster; - double x_position = current_x + pos[i].x_offset / 64.; - double y_position = current_y + pos[i].y_offset / 64.; - - - char glyphname[32]; - hb_font_get_glyph_name (hb_font, gid, glyphname, sizeof (glyphname)); - - printf ("glyph='%s' cluster=%d position=(%g,%g)\n", - glyphname, cluster, x_position, y_position); - - current_x += pos[i].x_advance / 64.; - current_y += pos[i].y_advance / 64.; - } - } - - hb_buffer_destroy (hb_buffer); - hb_font_destroy (hb_font); - - return 0; -} diff --git a/recipes/harfbuzz/all/test_package/test_package.c b/recipes/harfbuzz/all/test_package/test_package.c new file mode 100644 index 0000000000000..5f2ac9a8454e4 --- /dev/null +++ b/recipes/harfbuzz/all/test_package/test_package.c @@ -0,0 +1,141 @@ +/* + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#include +#include +#include + +#include "harfbuzz/hb.h" +#include "harfbuzz/hb-ot.h" + +#define FONT_SIZE 36 +#define MARGIN (FONT_SIZE * .5) + +/* Use native open type implementation to load font + https://github.com/harfbuzz/harfbuzz/issues/255 */ +hb_font_t* +get_font_ot(const char *filename, int size) +{ + size_t result = 0; + FILE* file = fopen(filename, "rb"); + fseek(file, 0, SEEK_END); + unsigned int length = ftell(file); + fseek(file, 0, SEEK_SET); + + char* data = (char*) malloc(length); + result = fread(data, length, 1, file); + if (result != 1) + { + fputs ("Reading error", stderr); + exit (3); + } + fclose(file); + + hb_blob_t* blob = hb_blob_create(data, length, HB_MEMORY_MODE_WRITABLE, (void*)data, NULL); + hb_face_t* face = hb_face_create(blob, 0); + hb_font_t* font = hb_font_create(face); + + hb_ot_font_set_funcs(font); + hb_font_set_scale(font, size, size); + + return font; +} + +int +main(int argc, char **argv) +{ + if (argc < 2) { + fprintf(stderr, "Usage: %s FONT\n", argv[0]); + return 1; + } + const char *fontfile = argv[1]; + const char *text = "conan-center-index"; + + /* Create hb-ft font. */ + hb_font_t *hb_font; + hb_font = get_font_ot (fontfile, FONT_SIZE*64); + + /* Create hb-buffer and populate. */ + hb_buffer_t *hb_buffer; + hb_buffer = hb_buffer_create (); + hb_buffer_add_utf8 (hb_buffer, text, -1, 0, -1); + hb_buffer_guess_segment_properties (hb_buffer); + + /* Shape it! */ + hb_shape (hb_font, hb_buffer, NULL, 0); + + /* Get glyph information and positions out of the buffer. */ + unsigned int len = hb_buffer_get_length (hb_buffer); + hb_glyph_info_t *info = hb_buffer_get_glyph_infos (hb_buffer, NULL); + hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (hb_buffer, NULL); + + /* Print them out as is. */ + printf ("Raw buffer contents:\n"); + for (unsigned int i = 0; i < len; i++) + { + hb_codepoint_t gid = info[i].codepoint; + unsigned int cluster = info[i].cluster; + double x_advance = pos[i].x_advance / 64.; + double y_advance = pos[i].y_advance / 64.; + double x_offset = pos[i].x_offset / 64.; + double y_offset = pos[i].y_offset / 64.; + + char glyphname[32]; + hb_font_get_glyph_name (hb_font, gid, glyphname, sizeof (glyphname)); + + printf ("glyph='%s' cluster=%d advance=(%g,%g) offset=(%g,%g)\n", + glyphname, cluster, x_advance, y_advance, x_offset, y_offset); + } + + printf ("Converted to absolute positions:\n"); + /* And converted to absolute positions. */ + { + double current_x = 0; + double current_y = 0; + for (unsigned int i = 0; i < len; i++) + { + hb_codepoint_t gid = info[i].codepoint; + unsigned int cluster = info[i].cluster; + double x_position = current_x + pos[i].x_offset / 64.; + double y_position = current_y + pos[i].y_offset / 64.; + + + char glyphname[32]; + hb_font_get_glyph_name (hb_font, gid, glyphname, sizeof (glyphname)); + + printf ("glyph='%s' cluster=%d position=(%g,%g)\n", + glyphname, cluster, x_position, y_position); + + current_x += pos[i].x_advance / 64.; + current_y += pos[i].y_advance / 64.; + } + } + + hb_buffer_destroy (hb_buffer); + hb_font_destroy (hb_font); + + return 0; +} diff --git a/recipes/harfbuzz/all/test_v1_package/CMakeLists.txt b/recipes/harfbuzz/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2f6b1a2f7ec79 --- /dev/null +++ b/recipes/harfbuzz/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/harfbuzz/all/test_v1_package/conanfile.py b/recipes/harfbuzz/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a4aa2f28304a1 --- /dev/null +++ b/recipes/harfbuzz/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + font = os.path.join(self.source_folder, "..", "test_package", "example.ttf") + bin_path = os.path.join("bin", "test_package") + self.run(f"{bin_path} {font}", run_environment=True) + diff --git a/recipes/harfbuzz/config.yml b/recipes/harfbuzz/config.yml index 1906573ccbede..72fcc32e11537 100644 --- a/recipes/harfbuzz/config.yml +++ b/recipes/harfbuzz/config.yml @@ -1,15 +1,13 @@ versions: - "2.6.8": + "3.2.0": folder: all - "2.7.0": + "4.4.1": folder: all - "2.7.1": + "5.1.0": folder: all - "2.7.2": + "5.2.0": folder: all - "2.7.4": + "5.3.0": folder: all - "2.8.0": - folder: all - "2.8.1": + "5.3.1": folder: all diff --git a/recipes/hash-library/all/CMakeLists.txt b/recipes/hash-library/all/CMakeLists.txt new file mode 100644 index 0000000000000..14405c91fb240 --- /dev/null +++ b/recipes/hash-library/all/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.4) +project(hash-library LANGUAGES CXX) + +add_library(hash-library + ${HASH_LIBRARY_SRC_DIR}/crc32.cpp + ${HASH_LIBRARY_SRC_DIR}/keccak.cpp + ${HASH_LIBRARY_SRC_DIR}/md5.cpp + ${HASH_LIBRARY_SRC_DIR}/sha1.cpp + ${HASH_LIBRARY_SRC_DIR}/sha256.cpp + ${HASH_LIBRARY_SRC_DIR}/sha3.cpp +) + +target_include_directories(hash-library PUBLIC ${HASH_LIBRARY_SRC_DIR}) + +set(HEADERS + ${HASH_LIBRARY_SRC_DIR}/crc32.h + ${HASH_LIBRARY_SRC_DIR}/hash.h + ${HASH_LIBRARY_SRC_DIR}/hmac.h + ${HASH_LIBRARY_SRC_DIR}/keccak.h + ${HASH_LIBRARY_SRC_DIR}/md5.h + ${HASH_LIBRARY_SRC_DIR}/sha1.h + ${HASH_LIBRARY_SRC_DIR}/sha256.h + ${HASH_LIBRARY_SRC_DIR}/sha3.h +) + +set_target_properties(hash-library PROPERTIES + PUBLIC_HEADER "${HEADERS}" + WINDOWS_EXPORT_ALL_SYMBOLS TRUE +) + +include(GNUInstallDirs) +install(TARGETS hash-library + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/hash-library/all/conandata.yml b/recipes/hash-library/all/conandata.yml new file mode 100644 index 0000000000000..e3155c060c064 --- /dev/null +++ b/recipes/hash-library/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "8.0": + url: "https://github.com/stbrumme/hash-library/archive/hash_library_v8.tar.gz" + sha256: "ddf9d398166e08482af1225aed968ac4c370f99648b5359b0a20c9ed56f7b1c7" +patches: + "8.0": + - patch_file: "patches/001-fix-macos.patch" diff --git a/recipes/hash-library/all/conanfile.py b/recipes/hash-library/all/conanfile.py new file mode 100644 index 0000000000000..83c2d2fdd2b74 --- /dev/null +++ b/recipes/hash-library/all/conanfile.py @@ -0,0 +1,63 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get +import os + +required_conan_version = ">=1.53.0" + + +class HashLibraryConan(ConanFile): + name = "hash-library" + description = "Portable C++ hashing library" + homepage = "https://create.stephan-brumme.com/hash-library/" + topics = ("hash", "digest", "hmac", "checksum", "crc32", "md5", "sha1", "sha2", "sha256", "sha3", "keccak") + license = "Zlib" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["HASH_LIBRARY_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["hash-library"] diff --git a/recipes/hash-library/all/patches/001-fix-macos.patch b/recipes/hash-library/all/patches/001-fix-macos.patch new file mode 100644 index 0000000000000..e138933e33525 --- /dev/null +++ b/recipes/hash-library/all/patches/001-fix-macos.patch @@ -0,0 +1,98 @@ +Fixes includes of endian.h on MacOS, see https://github.com/stbrumme/hash-library/pull/4. + +diff --git a/crc32.cpp b/crc32.cpp +--- a/crc32.cpp ++++ b/crc32.cpp +@@ -7,8 +7,10 @@ + #include "crc32.h" + + // big endian architectures need #define __BYTE_ORDER __BIG_ENDIAN +-#ifndef _MSC_VER +-#include ++#if defined(__APPLE__) ++ #include ++#elif !defined(_MSC_VER) ++ #include + #endif + + +diff --git a/keccak.cpp b/keccak.cpp +--- a/keccak.cpp ++++ b/keccak.cpp +@@ -7,8 +7,10 @@ + #include "keccak.h" + + // big endian architectures need #define __BYTE_ORDER __BIG_ENDIAN +-#ifndef _MSC_VER +-#include ++#if defined(__APPLE__) ++ #include ++#elif !defined(_MSC_VER) ++ #include + #endif + + +diff --git a/md5.cpp b/md5.cpp +--- a/md5.cpp ++++ b/md5.cpp +@@ -6,8 +6,10 @@ + + #include "md5.h" + +-#ifndef _MSC_VER +-#include ++#if defined(__APPLE__) ++ #include ++#elif !defined(_MSC_VER) ++ #include + #endif + + +diff --git a/sha1.cpp b/sha1.cpp +--- a/sha1.cpp ++++ b/sha1.cpp +@@ -7,8 +7,10 @@ + #include "sha1.h" + + // big endian architectures need #define __BYTE_ORDER __BIG_ENDIAN +-#ifndef _MSC_VER +-#include ++#if defined(__APPLE__) ++ #include ++#elif !defined(_MSC_VER) ++ #include + #endif + + +diff --git a/sha256.cpp b/sha256.cpp +--- a/sha256.cpp ++++ b/sha256.cpp +@@ -7,8 +7,10 @@ + #include "sha256.h" + + // big endian architectures need #define __BYTE_ORDER __BIG_ENDIAN +-#ifndef _MSC_VER +-#include ++#if defined(__APPLE__) ++ #include ++#elif !defined(_MSC_VER) ++ #include + #endif + + +diff --git a/sha3.cpp b/sha3.cpp +--- a/sha3.cpp ++++ b/sha3.cpp +@@ -7,8 +7,10 @@ + #include "sha3.h" + + // big endian architectures need #define __BYTE_ORDER __BIG_ENDIAN +-#ifndef _MSC_VER +-#include ++#if defined(__APPLE__) ++ #include ++#elif !defined(_MSC_VER) ++ #include + #endif + + #include diff --git a/recipes/hash-library/all/test_package/CMakeLists.txt b/recipes/hash-library/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d020276409c2e --- /dev/null +++ b/recipes/hash-library/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(hash-library CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE hash-library::hash-library) diff --git a/recipes/hash-library/all/test_package/conanfile.py b/recipes/hash-library/all/test_package/conanfile.py new file mode 100644 index 0000000000000..6dbd1de388288 --- /dev/null +++ b/recipes/hash-library/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + + +class HashLibraryTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/hash-library/all/test_package/test_package.cpp b/recipes/hash-library/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..8f47720724b8b --- /dev/null +++ b/recipes/hash-library/all/test_package/test_package.cpp @@ -0,0 +1,29 @@ +#include "crc32.h" +#include "keccak.h" +#include "md5.h" +#include "sha1.h" +#include "sha256.h" +#include "sha3.h" + +int main(void) { + if (CRC32()("abc") != "352441c2") { + return 1; + } + if (Keccak()("abc") != "4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45") { + return 2; + } + if (MD5()("abc") != "900150983cd24fb0d6963f7d28e17f72") { + return 3; + } + if (SHA1()("abc") != "a9993e364706816aba3e25717850c26c9cd0d89d") { + return 4; + } + if (SHA256()("abc") != "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") { + return 5; + } + if (SHA3()("abc") != "3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532") { + return 6; + } + + return 0; +} diff --git a/recipes/hash-library/all/test_v1_package/CMakeLists.txt b/recipes/hash-library/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/hash-library/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/hash-library/all/test_v1_package/conanfile.py b/recipes/hash-library/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..4265550ef4aee --- /dev/null +++ b/recipes/hash-library/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, tools, CMake + + +class HashLibraryTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hash-library/config.yml b/recipes/hash-library/config.yml new file mode 100644 index 0000000000000..2bb15eca7e86c --- /dev/null +++ b/recipes/hash-library/config.yml @@ -0,0 +1,3 @@ +versions: + "8.0": + folder: all diff --git a/recipes/hazelcast-cpp-client/all/conandata.yml b/recipes/hazelcast-cpp-client/all/conandata.yml index 468eebcc772d7..90b1afe2d9103 100644 --- a/recipes/hazelcast-cpp-client/all/conandata.yml +++ b/recipes/hazelcast-cpp-client/all/conandata.yml @@ -1,17 +1,19 @@ sources: + "5.0.0": + url: "https://github.com/hazelcast/hazelcast-cpp-client/archive/v5.0.0.tar.gz" + sha256: "0df7948bc6f4d219c60f51179355599938cab5b713335c2ea48d1d38be1b69dc" + "4.2.0": + url: "https://github.com/hazelcast/hazelcast-cpp-client/archive/v4.2.0.zip" + sha256: "18aeb755a875015a2e182d4c575cc46a041bdfb699937c5174d94534517e4708" + "4.1.1": + url: "https://github.com/hazelcast/hazelcast-cpp-client/archive/v4.1.1.zip" + sha256: "ca425c97eb871400de4bd2307ddaf3c557c9c1bae50d6a0db6507d72f435830c" "4.1.0": url: "https://github.com/hazelcast/hazelcast-cpp-client/archive/v4.1.0.zip" sha256: "8356bc76077fea354e83ffcd506096797137af10b292809c6b7843a8fbd084e3" "4.0.1": url: "https://github.com/hazelcast/hazelcast-cpp-client/archive/v4.0.1.zip" sha256: "4b3c6a876ebca2a4dcf23a556d3c3d4da2284e4ce1d2bbdf335df7f86b03fd28" - "4.0.0": - url: "https://github.com/hazelcast/hazelcast-cpp-client/archive/v4.0.0.zip" - sha256: "1bba72aec47951cefb367a99c196fd8989a2d621e527310fee9483313d347d1b" patches: "4.1.0": - patch_file: "patches/gcc_4.9_5_fix.patch" - base_path: "source_subfolder" - "4.0.0": - - patch_file: "patches/cmake_install.patch" - base_path: "source_subfolder" diff --git a/recipes/hazelcast-cpp-client/all/conanfile.py b/recipes/hazelcast-cpp-client/all/conanfile.py index af35073b34822..6f3062922937b 100644 --- a/recipes/hazelcast-cpp-client/all/conanfile.py +++ b/recipes/hazelcast-cpp-client/all/conanfile.py @@ -1,16 +1,20 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout +from conan.tools.scm import Version +from conan.tools import files +from conan.tools.build import check_min_cppstd + import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.50.0" class HazelcastCppClient(ConanFile): name = "hazelcast-cpp-client" description = "C++ client library for Hazelcast in-memory database." license = "Apache-2.0" - topics = ("conan", "hazelcast", "client", "database", "cache", "in-memory", "distributed", "computing", "ssl") - homepage = "https://github.com/hazelcast/hazelcast-cpp-client" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" + homepage = "https://github.com/hazelcast/hazelcast-cpp-client" + topics = ("hazelcast", "client", "database", "cache", "in-memory", "distributed", "computing", "ssl") settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -23,15 +27,9 @@ class HazelcastCppClient(ConanFile): "with_openssl": False } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _cmake_name(self): - return "hazelcastcxx" if tools.Version(self.version) <= "4.0.0" else "hazelcast-cpp-client" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + files.copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -40,50 +38,56 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self) def requirements(self): - self.requires("boost/1.76.0") + self.requires("boost/1.79.0") if self.options.with_openssl: - self.requires("openssl/1.1.1k") + self.requires("openssl/1.1.1q") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["WITH_OPENSSL"] = self.options.with_openssl - if tools.Version(self.version) <= "4.0.0": - self._cmake.definitions["BUILD_STATIC_LIB"] = not self.options.shared - self._cmake.definitions["BUILD_SHARED_LIB"] = self.options.shared + files.get(self, + **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + toolchain = CMakeToolchain(self) + toolchain.variables["WITH_OPENSSL"] = self.options.with_openssl + if Version(self.version) <= "4.0.0": + toolchain.variables["BUILD_STATIC_LIB"] = not self.options.shared + toolchain.variables["BUILD_SHARED_LIB"] = self.options.shared else: - self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.configure() - return self._cmake + toolchain.variables["BUILD_SHARED_LIBS"] = self.options.shared + toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + files.apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + self.copy("LICENSE", dst="licenses", src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = self._cmake_name - self.cpp_info.filenames["cmake_find_package_multi"] = self._cmake_name - self.cpp_info.names["cmake_find_package"] = self._cmake_name - self.cpp_info.names["cmake_find_package_multi"] = self._cmake_name + self.cpp_info.set_property("cmake_file_name", "hazelcast-cpp-client") + self.cpp_info.set_property("cmake_target_name", "hazelcast-cpp-client::hazelcast-cpp-client") - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["hazelcast-cpp-client"] self.cpp_info.defines = ["BOOST_THREAD_VERSION=5"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("pthread") + if self.settings.os == "Windows": + self.cpp_info.system_libs.append("ws2_32") diff --git a/recipes/hazelcast-cpp-client/all/test_package/CMakeLists.txt b/recipes/hazelcast-cpp-client/all/test_package/CMakeLists.txt index 22c6e17ef0142..47708a63a3ae9 100644 --- a/recipes/hazelcast-cpp-client/all/test_package/CMakeLists.txt +++ b/recipes/hazelcast-cpp-client/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.10) -project(PackageTest CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(hazelcast-cpp-client REQUIRED CONFIG) -add_executable(test_package test_package.cpp) -target_link_libraries(test_package PUBLIC ${CONAN_LIBS}) -set_property(TARGET test_package PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE hazelcast-cpp-client::hazelcast-cpp-client) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/hazelcast-cpp-client/all/test_package/conanfile.py b/recipes/hazelcast-cpp-client/all/test_package/conanfile.py index a91fd0cd063d1..f70d40a28931b 100644 --- a/recipes/hazelcast-cpp-client/all/test_package/conanfile.py +++ b/recipes/hazelcast-cpp-client/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools - class TestPackageHazelcastCppClient(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/hazelcast-cpp-client/all/test_v1_package/CMakeLists.txt b/recipes/hazelcast-cpp-client/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..87fd6b32ee2e1 --- /dev/null +++ b/recipes/hazelcast-cpp-client/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(hazelcast-cpp-client REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE hazelcast-cpp-client::hazelcast-cpp-client) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/hazelcast-cpp-client/all/test_v1_package/conanfile.py b/recipes/hazelcast-cpp-client/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/hazelcast-cpp-client/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hazelcast-cpp-client/config.yml b/recipes/hazelcast-cpp-client/config.yml index c841ba5aa8831..50e0bcc183e61 100644 --- a/recipes/hazelcast-cpp-client/config.yml +++ b/recipes/hazelcast-cpp-client/config.yml @@ -1,7 +1,11 @@ versions: + "5.0.0": + folder: all + "4.2.0": + folder: all + "4.1.1": + folder: all "4.1.0": folder: all "4.0.1": folder: all - "4.0.0": - folder: all diff --git a/recipes/hdf4/all/conanfile.py b/recipes/hdf4/all/conanfile.py index 334f76bda7b8c..2d8c7ea8622e4 100644 --- a/recipes/hdf4/all/conanfile.py +++ b/recipes/hdf4/all/conanfile.py @@ -1,6 +1,8 @@ +from conans import ConanFile, CMake, tools import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.33.0" + class Hdf4Conan(ConanFile): name = "hdf4" @@ -9,24 +11,25 @@ class Hdf4Conan(ConanFile): topics = ("conan", "hdf4", "hdf", "data") homepage = "https://portal.hdfgroup.org/display/HDF4/HDF4" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "jpegturbo": [True, False], "szip_support": [None, "with_libaec", "with_szip"], - "szip_encoding": [True, False] + "szip_encoding": [True, False], } default_options = { "shared": False, "fPIC": True, "jpegturbo": False, "szip_support": None, - "szip_encoding": False + "szip_encoding": False, } + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake", "cmake_find_package" _cmake = None @property @@ -50,19 +53,19 @@ def configure(self): del self.options.szip_encoding def requirements(self): - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.12") if self.options.jpegturbo: - self.requires("libjpeg-turbo/2.0.4") + self.requires("libjpeg-turbo/2.1.2") else: self.requires("libjpeg/9d") if self.options.szip_support == "with_libaec": - self.requires("libaec/1.0.4") + self.requires("libaec/1.0.6") elif self.options.szip_support == "with_szip": self.requires("szip/2.1.1") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("hdf-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): @@ -93,6 +96,9 @@ def _configure_cmake(self): self._cmake.definitions["HDF4_BUILD_TOOLS"] = False self._cmake.definitions["HDF4_BUILD_EXAMPLES"] = False self._cmake.definitions["HDF4_BUILD_JAVA"] = False + if tools.cross_building(self): + self._cmake.definitions["H4_PRINTF_LL_TEST_RUN"] = "0" + self._cmake.definitions["H4_PRINTF_LL_TEST_RUN__TRYRUN_OUTPUT"] = "" self._cmake.configure(build_folder=self._build_subfolder) return self._cmake diff --git a/recipes/hdf4/all/test_package/CMakeLists.txt b/recipes/hdf4/all/test_package/CMakeLists.txt index ff06419c573f4..a6de4b1271021 100644 --- a/recipes/hdf4/all/test_package/CMakeLists.txt +++ b/recipes/hdf4/all/test_package/CMakeLists.txt @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(hdf4 REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -if(HDF4_SHARED) +if(TARGET hdf4::hdf-shared) target_link_libraries(${PROJECT_NAME} hdf4::hdf-shared) else() target_link_libraries(${PROJECT_NAME} hdf4::hdf-static) diff --git a/recipes/hdf4/all/test_package/conanfile.py b/recipes/hdf4/all/test_package/conanfile.py index 57c5365359a03..612db2552bfca 100644 --- a/recipes/hdf4/all/test_package/conanfile.py +++ b/recipes/hdf4/all/test_package/conanfile.py @@ -1,18 +1,24 @@ +from conans import ConanFile, CMake, tools import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "cmake", "cmake_find_package" + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + self.build_requires("cmake/3.20.1") + def build(self): cmake = CMake(self) - cmake.definitions["HDF4_SHARED"] = self.options["hdf4"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/hdf5/all/CMakeLists.txt b/recipes/hdf5/all/CMakeLists.txt index 4d393c7a86c09..7bd2be5d08aa8 100644 --- a/recipes/hdf5/all/CMakeLists.txt +++ b/recipes/hdf5/all/CMakeLists.txt @@ -1,7 +1,12 @@ -cmake_minimum_required(VERSION 3.1.2) +cmake_minimum_required(VERSION 3.13) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +conan_basic_setup(TARGETS KEEP_RPATHS) + +if (MSVC) + add_compile_options("$<$:/Z7>") + add_link_options("$<$:/DEBUG:NONE>") +endif () add_subdirectory("source_subfolder") diff --git a/recipes/hdf5/all/conandata.yml b/recipes/hdf5/all/conandata.yml index 22fb212883072..d39b52a21d740 100644 --- a/recipes/hdf5/all/conandata.yml +++ b/recipes/hdf5/all/conandata.yml @@ -1,4 +1,13 @@ sources: + "1.13.1": + url: "https://github.com/HDFGroup/hdf5/archive/hdf5-1_13_1.tar.gz" + sha256: "92552458f35c7e58128ce1bfc2831abf901cc142ea0fdd2b056311e4452db7bf" + "1.12.2": + url: "https://github.com/HDFGroup/hdf5/archive/hdf5-1_12_2.tar.gz" + sha256: "1ca14cadff7bc4b61826eee591da1a330f44c107db66c9510ee95df3b2bc5f78" + "1.12.1": + url: "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.1/src/hdf5-1.12.1.tar.gz" + sha256: "79c66ff67e666665369396e9c90b32e238e501f345afd2234186bfb8331081ca" "1.12.0": url: "https://github.com/HDFGroup/hdf5/archive/hdf5-1_12_0.tar.gz" sha256: "c64ffec2539ae6b6041f97952a40b0893c3c0df4d5b1c0177fb8aba567808158" @@ -12,13 +21,28 @@ sources: url: "https://github.com/HDFGroup/hdf5/archive/hdf5-1_8_21.tar.gz" sha256: "753520e34a576a64809b8e02d9c015d6126f7974f678c7417a60492d835a88f4" patches: + "1.13.1": + - patch_file: "patches/conanize-link-szip-1.12.2+.patch" + base_path: "source_subfolder" + "1.12.2": + - patch_file: "patches/conanize-link-szip-1.12.2+.patch" + base_path: "source_subfolder" + "1.12.1": + - patch_file: "patches/conanize-link-szip-1.12.1+.patch" + base_path: "source_subfolder" "1.12.0": - patch_file: "patches/conanize-link-szip-1.10.5+.patch" base_path: "source_subfolder" "1.10.6": + - patch_file: "patches/fix-missing-function-prototypes-1.10.5+.patch" + base_path: "source_subfolder" + - patch_file: "patches/fix-missing-function-prototypes-1.10.6.patch" + base_path: "source_subfolder" - patch_file: "patches/conanize-link-szip-1.10.5+.patch" base_path: "source_subfolder" "1.10.5": + - patch_file: "patches/fix-missing-function-prototypes-1.10.5+.patch" + base_path: "source_subfolder" - patch_file: "patches/conanize-link-szip-1.10.5+.patch" base_path: "source_subfolder" - patch_file: "patches/build-either-static-or-shared-1.10.5.patch" diff --git a/recipes/hdf5/all/conanfile.py b/recipes/hdf5/all/conanfile.py index dec49dbfe1f30..3f219642650bc 100644 --- a/recipes/hdf5/all/conanfile.py +++ b/recipes/hdf5/all/conanfile.py @@ -1,18 +1,25 @@ -import glob +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import rmdir, copy, save, get, replace_in_file, apply_conandata_patches +from conan.tools.build import cross_building +from conan.tools.scm import Version +from conans import CMake +import functools import os +import textwrap + + +required_conan_version = ">=1.47.0" -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration class Hdf5Conan(ConanFile): name = "hdf5" description = "HDF5 is a data model, library, and file format for storing and managing data." license = "BSD-3-Clause" - topics = ("conan", "hdf5", "hdf", "data") + topics = ("hdf5", "hdf", "data") homepage = "https://portal.hdfgroup.org/display/HDF5/HDF5" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -22,7 +29,8 @@ class Hdf5Conan(ConanFile): "threadsafe": [True, False], "with_zlib": [True, False], "szip_support": [None, "with_libaec", "with_szip"], - "szip_encoding": [True, False] + "szip_encoding": [True, False], + "parallel": [True, False], } default_options = { "shared": False, @@ -32,10 +40,11 @@ class Hdf5Conan(ConanFile): "threadsafe": False, "with_zlib": True, "szip_support": None, - "szip_encoding": False + "szip_encoding": False, + "parallel": False, } - _cmake = None + generators = "cmake" @property def _source_subfolder(self): @@ -45,11 +54,18 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC if not self.options.enable_cxx: del self.settings.compiler.libcxx del self.settings.compiler.cppstd @@ -57,23 +73,32 @@ def configure(self): del self.options.threadsafe if not bool(self.options.szip_support): del self.options.szip_encoding - elif self.options.szip_support == "with_szip" and \ - self.options.szip_encoding and \ - not self.options["szip"].enable_encoding: - raise ConanInvalidConfiguration("encoding must be enabled in szip dependency (szip:enable_encoding=True)") def requirements(self): if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.szip_support == "with_libaec": - self.requires("libaec/1.0.4") + self.requires("libaec/1.0.6") elif self.options.szip_support == "with_szip": self.requires("szip/2.1.1") + if self.options.parallel: + self.requires("openmpi/4.1.0") + + def validate(self): + if hasattr(self, "settings_build") and cross_building(self, skip_x64_x86=True): + # While building it runs some executables like H5detect + raise ConanInvalidConfiguration("Current recipe doesn't support cross-building (yet)") + if self.options.parallel: + if self.options.enable_cxx: + raise ConanInvalidConfiguration("Parallel and C++ options are mutually exclusive") + if self.options.get_safe("threadsafe", False): + raise ConanInvalidConfiguration("Parallel and Threadsafe options are mutually exclusive") + if self.options.szip_support == "with_szip" and self.options.szip_encoding and \ + not self.options["szip"].enable_encoding: + raise ConanInvalidConfiguration("encoding must be enabled in szip dependency (szip:enable_encoding=True)") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{0}-{0}-{1}".format(self.name, self.version.replace('.', '_')) - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def build(self): self._patch_sources() @@ -81,93 +106,165 @@ def build(self): cmake.build() def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + apply_conandata_patches(self) # Do not force PIC - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), "set (CMAKE_POSITION_INDEPENDENT_CODE ON)", "") + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["HDF5_EXTERNALLY_CONFIGURED"] = True - self._cmake.definitions["HDF5_EXTERNAL_LIB_PREFIX"] = "" - self._cmake.definitions["HDF5_USE_FOLDERS"] = False - self._cmake.definitions["HDF5_NO_PACKAGES"] = True - self._cmake.definitions["ALLOW_UNSUPPORTED"] = False - if tools.Version(self.version) >= "1.10.6": - self._cmake.definitions["ONLY_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["BUILD_STATIC_EXECS"] = False - self._cmake.definitions["HDF5_ENABLE_COVERAGE"] = False - self._cmake.definitions["HDF5_ENABLE_USING_MEMCHECKER"] = False - if tools.Version(self.version) >= "1.10.0": - self._cmake.definitions["HDF5_MEMORY_ALLOC_SANITY_CHECK"] = False - if tools.Version(self.version) >= "1.10.5": - self._cmake.definitions["HDF5_ENABLE_PREADWRITE"] = True - self._cmake.definitions["HDF5_ENABLE_DEPRECATED_SYMBOLS"] = True - self._cmake.definitions["HDF5_BUILD_GENERATORS"] = False - self._cmake.definitions["HDF5_ENABLE_TRACE"] = False + cmake = CMake(self) + cmake.definitions["HDF5_EXTERNALLY_CONFIGURED"] = True + cmake.definitions["HDF5_EXTERNAL_LIB_PREFIX"] = "" + cmake.definitions["HDF5_USE_FOLDERS"] = False + cmake.definitions["HDF5_NO_PACKAGES"] = True + cmake.definitions["ALLOW_UNSUPPORTED"] = False + if Version(self.version) >= "1.10.6": + cmake.definitions["ONLY_SHARED_LIBS"] = self.options.shared + cmake.definitions["BUILD_STATIC_EXECS"] = False + cmake.definitions["HDF5_ENABLE_COVERAGE"] = False + cmake.definitions["HDF5_ENABLE_USING_MEMCHECKER"] = False + if Version(self.version) >= "1.10.0": + cmake.definitions["HDF5_MEMORY_ALLOC_SANITY_CHECK"] = False + if Version(self.version) >= "1.10.5": + cmake.definitions["HDF5_ENABLE_PREADWRITE"] = True + cmake.definitions["HDF5_ENABLE_DEPRECATED_SYMBOLS"] = True + cmake.definitions["HDF5_BUILD_GENERATORS"] = False + cmake.definitions["HDF5_ENABLE_TRACE"] = False if self.settings.build_type == "Debug": - self._cmake.definitions["HDF5_ENABLE_INSTRUMENT"] = False # Option? - self._cmake.definitions["HDF5_ENABLE_PARALLEL"] = False - self._cmake.definitions["HDF5_ENABLE_Z_LIB_SUPPORT"] = self.options.with_zlib - self._cmake.definitions["HDF5_ENABLE_SZIP_SUPPORT"] = bool(self.options.szip_support) + cmake.definitions["HDF5_ENABLE_INSTRUMENT"] = False # Option? + cmake.definitions["HDF5_ENABLE_PARALLEL"] = self.options.parallel + cmake.definitions["HDF5_ENABLE_Z_LIB_SUPPORT"] = self.options.with_zlib + cmake.definitions["HDF5_ENABLE_SZIP_SUPPORT"] = bool(self.options.szip_support) if bool(self.options.szip_support): - self._cmake.definitions["CONAN_SZIP_LIBNAME"] = self._get_szip_lib() # this variable is added by conanize-link-szip*.patch - self._cmake.definitions["HDF5_ENABLE_SZIP_ENCODING"] = self.options.get_safe("szip_encoding") or False - self._cmake.definitions["HDF5_PACKAGE_EXTLIBS"] = False - self._cmake.definitions["HDF5_ENABLE_THREADSAFE"] = self.options.get_safe("threadsafe") or False - self._cmake.definitions["HDF5_ENABLE_DEBUG_APIS"] = False # Option? - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.definitions["HDF5_INSTALL_INCLUDE_DIR"] = os.path.join(self.package_folder, "include", "hdf5") - self._cmake.definitions["HDF5_BUILD_TOOLS"] = False - self._cmake.definitions["HDF5_BUILD_EXAMPLES"] = False - self._cmake.definitions["HDF5_BUILD_HL_LIB"] = self.options.hl - self._cmake.definitions["HDF5_BUILD_FORTRAN"] = False - self._cmake.definitions["HDF5_BUILD_CPP_LIB"] = self.options.enable_cxx - if tools.Version(self.version) >= "1.10.0": - self._cmake.definitions["HDF5_BUILD_JAVA"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + cmake.definitions["CONAN_SZIP_LIBNAME"] = self._get_szip_lib() # this variable is added by conanize-link-szip*.patch + cmake.definitions["HDF5_ENABLE_SZIP_ENCODING"] = self.options.get_safe("szip_encoding", False) + cmake.definitions["HDF5_PACKAGE_EXTLIBS"] = False + cmake.definitions["HDF5_ENABLE_THREADSAFE"] = self.options.get_safe("threadsafe", False) + cmake.definitions["HDF5_ENABLE_DEBUG_APIS"] = False # Option? + cmake.definitions["BUILD_TESTING"] = False + cmake.definitions["HDF5_INSTALL_INCLUDE_DIR"] = os.path.join(self.package_folder, "include", "hdf5") + cmake.definitions["HDF5_BUILD_TOOLS"] = False + cmake.definitions["HDF5_BUILD_EXAMPLES"] = False + cmake.definitions["HDF5_BUILD_HL_LIB"] = self.options.hl + cmake.definitions["HDF5_BUILD_FORTRAN"] = False + cmake.definitions["HDF5_BUILD_CPP_LIB"] = self.options.enable_cxx + if Version(self.version) >= "1.10.0": + cmake.definitions["HDF5_BUILD_JAVA"] = False + + cmake.configure(build_folder=self._build_subfolder) + return cmake def _get_szip_lib(self): return { "with_libaec": "libaec", - "with_szip": "szip" + "with_szip": "szip", }.get(str(self.options.szip_support)) + def _components(self): + hdf5_requirements = [] + if self.options.with_zlib: + hdf5_requirements.append("zlib::zlib") + if self.options.szip_support == "with_libaec": + hdf5_requirements.append("libaec::libaec") + elif self.options.szip_support == "with_szip": + hdf5_requirements.append("szip::szip") + if self.options.parallel: + hdf5_requirements.append("openmpi::openmpi") + + return { + "hdf5_c": {"component": "C", "alias_target": "hdf5", "requirements": hdf5_requirements}, + "hdf5_hl": {"component": "HL", "alias_target": "hdf5_hl", "requirements": ["hdf5_c"]}, + "hdf5_cpp": {"component": "CXX", "alias_target": "hdf5_cpp", "requirements": ["hdf5_c"]}, + "hdf5_hl_cpp": {"component": "HL_CXX", "alias_target": "hdf5_hl_cpp", "requirements": ["hdf5_c", "hdf5_cpp", "hdf5_hl"]}, + } + + @staticmethod + def _create_cmake_module_alias_targets(conanfile, module_file, targets, is_parallel): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + + # add the additional hdf5_hl_cxx target when both CXX and HL components are specified + content += textwrap.dedent("""\ + if(TARGET HDF5::HL AND TARGET HDF5::CXX AND NOT TARGET hdf5::hdf5_hl_cpp) + add_library(hdf5::hdf5_hl_cpp INTERFACE IMPORTED) + set_property(TARGET hdf5::hdf5_hl_cpp PROPERTY INTERFACE_LINK_LIBRARIES HDF5::HL_CXX) + endif() + """) + content += textwrap.dedent("set(HDF5_IS_PARALLEL {})".format("ON" if is_parallel else "OFF")) + save(conanfile, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", + "conan-official-{}-targets.cmake".format(self.name)) + def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) + copy(self, "COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) os.remove(os.path.join(self.package_folder, "lib", "libhdf5.settings")) + # Mimic the official CMake FindHDF5 targets. HDF5::HDF5 refers to the global target as per conan, + # but component targets have a lower case namespace prefix. hdf5::hdf5 refers to the C library only + components = self._components() + self._create_cmake_module_alias_targets( + self, + os.path.join(self.package_folder, self._module_file_rel_path), + {"hdf5::{}".format(component["alias_target"]): "HDF5::{}".format(component["component"]) for component in components.values()}, + self.options.get_safe("parallel", False) + ) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "HDF5" - self.cpp_info.names["cmake_find_package_multi"] = "HDF5" - self.cpp_info.libs = self._get_ordered_libs() - self.cpp_info.includedirs.append(os.path.join(self.package_folder, "include", "hdf5")) - if self.options.shared: - self.cpp_info.defines.append("H5_BUILT_AS_DYNAMIC_LIB") + def add_component(component_name, component, alias_target, requirements): + def _config_libname(lib): + if self.settings.os == "Windows" and self.settings.compiler != "gcc" and not self.options.shared: + lib = "lib" + lib + if self.settings.build_type == "Debug": + debug_postfix = "_D" if self.settings.os == "Windows" else "_debug" + return lib + debug_postfix + # See config/cmake_ext_mod/HDFMacros.cmake + return lib + + self.cpp_info.components[component_name].set_property("cmake_target_name", f"hdf5::{alias_target}") + self.cpp_info.components[component_name].set_property("pkg_config_name", alias_target) + self.cpp_info.components[component_name].libs = [_config_libname(alias_target)] + self.cpp_info.components[component_name].requires = requirements + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components[component_name].names["cmake_find_package"] = component + self.cpp_info.components[component_name].names["cmake_find_package_multi"] = component + self.cpp_info.components[component_name].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components[component_name].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "HDF5") + self.cpp_info.set_property("cmake_target_name", "HDF5::HDF5") + self.cpp_info.set_property("pkg_config_name", "hdf5-all-do-not-use") # to avoid conflict with hdf5_c component + + components = self._components() + add_component("hdf5_c", **components["hdf5_c"]) + self.cpp_info.components["hdf5_c"].includedirs.append(os.path.join("include", "hdf5")) if self.settings.os == "Linux": - self.cpp_info.system_libs.extend(["dl", "m"]) + self.cpp_info.components["hdf5_c"].system_libs.extend(["dl", "m"]) if self.options.get_safe("threadsafe"): - self.cpp_info.system_libs.append("pthread") - - def _get_ordered_libs(self): - libs = ["hdf5"] - if self.options.enable_cxx: - libs.insert(0, "hdf5_cpp") - if self.options.hl: - libs.insert(0, "hdf5_hl") - if self.options.enable_cxx: - libs.insert(0, "hdf5_hl_cpp") - # See config/cmake_ext_mod/HDFMacros.cmake - if self.settings.os == "Windows" and self.settings.compiler != "gcc" and not self.options.shared: - libs = ["lib" + lib for lib in libs] - if self.settings.build_type == "Debug": - debug_postfix = "_D" if self.settings.os == "Windows" else "_debug" - libs = [lib + debug_postfix for lib in libs] - return libs + self.cpp_info.components["hdf5_c"].system_libs.append("pthread") + + if self.options.shared: + self.cpp_info.components["hdf5_c"].defines.append("H5_BUILT_AS_DYNAMIC_LIB") + if self.options.get_safe("enable_cxx"): + add_component("hdf5_cpp", **components["hdf5_cpp"]) + if self.options.get_safe("hl"): + add_component("hdf5_hl", **components["hdf5_hl"]) + if self.options.get_safe("enable_cxx"): + add_component("hdf5_hl_cpp", **components["hdf5_hl_cpp"]) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "HDF5" + self.cpp_info.names["cmake_find_package_multi"] = "HDF5" diff --git a/recipes/hdf5/all/patches/conanize-link-szip-1.12.1+.patch b/recipes/hdf5/all/patches/conanize-link-szip-1.12.1+.patch new file mode 100644 index 0000000000000..fdf084ea5a466 --- /dev/null +++ b/recipes/hdf5/all/patches/conanize-link-szip-1.12.1+.patch @@ -0,0 +1,51 @@ +--- CMakeFilters.cmake 2021-07-01 23:26:37.000000000 +0200 ++++ CMakeFilters2.cmake 2022-02-07 07:25:14.498269403 +0100 +@@ -109,44 +109,10 @@ + option (HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF) + if (HDF5_ENABLE_SZIP_SUPPORT) + option (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" OFF) +- if (NOT SZIP_USE_EXTERNAL) +- find_package (SZIP NAMES ${SZIP_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared) +- if (NOT SZIP_FOUND) +- find_package (SZIP) # Legacy find +- if (SZIP_FOUND) +- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) +- endif () +- endif () +- endif () +- if (SZIP_FOUND) +- set (H5_HAVE_FILTER_SZIP 1) +- set (H5_HAVE_SZLIB_H 1) +- set (H5_HAVE_LIBSZ 1) +- set (SZIP_INCLUDE_DIR_GEN ${SZIP_INCLUDE_DIR}) +- set (SZIP_INCLUDE_DIRS ${SZIP_INCLUDE_DIRS} ${SZIP_INCLUDE_DIR}) +- else () +- if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") +- EXTERNAL_SZIP_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT} ${HDF5_ENABLE_SZIP_ENCODING}) +- set (H5_HAVE_FILTER_SZIP 1) +- set (H5_HAVE_SZLIB_H 1) +- set (H5_HAVE_LIBSZ 1) +- if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") +- message (VERBOSE "Filter SZIP is built") +- endif () +- if (USE_LIBAEC) +- if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") +- message (VERBOSE "... with library AEC") +- endif () +- set (SZ_PACKAGE_NAME ${LIBAEC_PACKAGE_NAME}) +- else () +- set (SZ_PACKAGE_NAME ${SZIP_PACKAGE_NAME}) +- endif () +- else () +- message (FATAL_ERROR "SZIP is Required for SZIP support in HDF5") +- endif () +- endif () +- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_STATIC_LIBRARY}) +- INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) ++ set (LINK_COMP_LIBS ${LINK_COMP_LIBS} "CONAN_PKG::${CONAN_SZIP_LIBNAME}") ++ set (H5_HAVE_FILTER_SZIP 1) ++ set (H5_HAVE_SZLIB_H 1) ++ set (H5_HAVE_LIBSZ 1) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter SZIP is ON") + endif () diff --git a/recipes/hdf5/all/patches/conanize-link-szip-1.12.2+.patch b/recipes/hdf5/all/patches/conanize-link-szip-1.12.2+.patch new file mode 100644 index 0000000000000..1da6c95a320ba --- /dev/null +++ b/recipes/hdf5/all/patches/conanize-link-szip-1.12.2+.patch @@ -0,0 +1,64 @@ +diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake +index 725390b31b..085b18051e 100644 +--- a/CMakeFilters.cmake ++++ b/CMakeFilters.cmake +@@ -110,55 +110,10 @@ endif () + option (HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF) + if (HDF5_ENABLE_SZIP_SUPPORT) + option (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" OFF) +- if (NOT SZIP_USE_EXTERNAL) +- set(SZIP_FOUND FALSE) +- if (USE_LIBAEC) +- set(libaec_USE_STATIC_LIBS ${USE_LIBAEC_STATIC}) +- find_package (libaec 1.0.5 CONFIG) +- if (SZIP_FOUND) +- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) +- endif () +- endif () +- +- if (NOT SZIP_FOUND) +- find_package (SZIP NAMES ${SZIP_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared) +- if (NOT SZIP_FOUND) +- find_package (SZIP) # Legacy find +- if (SZIP_FOUND) +- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) +- endif () +- endif () +- endif () +- endif () +- if (SZIP_FOUND) +- set (H5_HAVE_FILTER_SZIP 1) +- set (H5_HAVE_SZLIB_H 1) +- set (H5_HAVE_LIBSZ 1) +- set (SZIP_INCLUDE_DIR_GEN ${SZIP_INCLUDE_DIR}) +- set (SZIP_INCLUDE_DIRS ${SZIP_INCLUDE_DIRS} ${SZIP_INCLUDE_DIR}) +- else () +- if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") +- EXTERNAL_SZIP_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT} ${HDF5_ENABLE_SZIP_ENCODING}) +- set (H5_HAVE_FILTER_SZIP 1) +- set (H5_HAVE_SZLIB_H 1) +- set (H5_HAVE_LIBSZ 1) +- if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") +- message (VERBOSE "Filter SZIP is built") +- endif () +- if (USE_LIBAEC) +- if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") +- message (VERBOSE "... with library AEC") +- endif () +- set (SZIP_PACKAGE_NAME ${LIBAEC_PACKAGE_NAME}) +- else () +- set (SZIP_PACKAGE_NAME ${SZIP_PACKAGE_NAME}) +- endif () +- else () +- message (FATAL_ERROR "SZIP is Required for SZIP support in HDF5") +- endif () +- endif () +- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_STATIC_LIBRARY}) +- INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) ++ set (LINK_COMP_LIBS ${LINK_COMP_LIBS} "CONAN_PKG::${CONAN_SZIP_LIBNAME}") ++ set (H5_HAVE_FILTER_SZIP 1) ++ set (H5_HAVE_SZLIB_H 1) ++ set (H5_HAVE_LIBSZ 1) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter SZIP is ON") + endif () diff --git a/recipes/hdf5/all/patches/fix-missing-function-prototypes-1.10.5+.patch b/recipes/hdf5/all/patches/fix-missing-function-prototypes-1.10.5+.patch new file mode 100644 index 0000000000000..5ef02437673c3 --- /dev/null +++ b/recipes/hdf5/all/patches/fix-missing-function-prototypes-1.10.5+.patch @@ -0,0 +1,34 @@ +diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c +index 9339b3df6c..052c296ac1 100644 +--- a/src/H5Fsuper.c ++++ b/src/H5Fsuper.c +@@ -54,6 +54,7 @@ + /********************/ + static herr_t H5F__super_ext_create(H5F_t *f, H5O_loc_t *ext_ptr); + static herr_t H5F__update_super_ext_driver_msg(H5F_t *f); ++herr_t H5O__fsinfo_set_version(H5F_t *f, H5O_fsinfo_t *fsinfo); + + + /*********************/ +diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c +index 33ed787440..b8e1af55ce 100644 +--- a/src/H5Odeprec.c ++++ b/src/H5Odeprec.c +@@ -54,6 +54,17 @@ + /********************/ + /* Local Prototypes */ + /********************/ ++herr_t ++H5CX_set_apl(hid_t *, const H5P_libclass_t *, ++ hid_t ++#ifndef H5_HAVE_PARALLEL ++H5_ATTR_UNUSED ++#endif /* H5_HAVE_PARALLEL */ ++, hbool_t ++#ifndef H5_HAVE_PARALLEL ++ H5_ATTR_UNUSED ++#endif /* H5_HAVE_PARALLEL */ ++); + + + /*********************/ diff --git a/recipes/hdf5/all/patches/fix-missing-function-prototypes-1.10.6.patch b/recipes/hdf5/all/patches/fix-missing-function-prototypes-1.10.6.patch new file mode 100644 index 0000000000000..e709d0b0d06b5 --- /dev/null +++ b/recipes/hdf5/all/patches/fix-missing-function-prototypes-1.10.6.patch @@ -0,0 +1,24 @@ +diff --git a/src/H5Oint.c b/src/H5Oint.c +index 543637c127..c8a6131a34 100644 +--- a/src/H5Oint.c ++++ b/src/H5Oint.c +@@ -82,6 +82,7 @@ static herr_t H5O__free_visit_visited(void *item, void *key, + static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info_t *linfo, + void *_udata); + static const H5O_obj_class_t *H5O__obj_class_real(const H5O_t *oh); ++H5_DLL herr_t H5CX_get_ohdr_flags(uint8_t *ohdr_flags); + + + /*********************/ +diff --git a/src/H5Rint.c b/src/H5Rint.c +index 159bccac34..b48d2a706d 100644 +--- a/src/H5Rint.c ++++ b/src/H5Rint.c +@@ -46,6 +46,7 @@ + /********************/ + /* Local Prototypes */ + /********************/ ++H5_DLL herr_t H5CX_set_libver_bounds(H5F_t *f); + + /*********************/ + /* Package Variables */ diff --git a/recipes/hdf5/all/test_package/CMakeLists.txt b/recipes/hdf5/all/test_package/CMakeLists.txt index b1332f3836691..61e2f5929ebe0 100644 --- a/recipes/hdf5/all/test_package/CMakeLists.txt +++ b/recipes/hdf5/all/test_package/CMakeLists.txt @@ -1,9 +1,28 @@ cmake_minimum_required(VERSION 3.1) - -project(test_package LANGUAGES CXX) +project(test_package LANGUAGES C CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +set(HDF5_COMPONENTS C) +if (HDF5_HL) + list(APPEND HDF5_COMPONENTS HL) +endif() +if (HDF5_CXX) + list(APPEND HDF5_COMPONENTS CXX) +endif() +find_package(HDF5 COMPONENTS ${HDF5_COMPONENTS}) + +add_executable(${PROJECT_NAME} test_package.c) -add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) -target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) +if (TARGET hdf5::hdf5_cpp) + target_compile_definitions(${PROJECT_NAME} PRIVATE CONAN_HDF5_CXX) + target_sources(${PROJECT_NAME} PRIVATE test_package.cpp) + target_link_libraries(${PROJECT_NAME} PRIVATE hdf5::hdf5_cpp) +elseif (HDF5_IS_PARALLEL) + target_compile_definitions(${PROJECT_NAME} PRIVATE CONAN_HDF5_PARALLEL) + target_sources(${PROJECT_NAME} PRIVATE test_parallel.c) + target_link_libraries(${PROJECT_NAME} PRIVATE hdf5::hdf5) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE hdf5::hdf5) +endif() diff --git a/recipes/hdf5/all/test_package/conanfile.py b/recipes/hdf5/all/test_package/conanfile.py index e215ed6f8e55b..4d4698a0afd36 100644 --- a/recipes/hdf5/all/test_package/conanfile.py +++ b/recipes/hdf5/all/test_package/conanfile.py @@ -1,17 +1,21 @@ -import os.path +from conans import ConanFile, CMake, tools +import os -from conans import ConanFile, CMake - -class Hdf5TestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" def build(self): cmake = CMake(self) + cmake.definitions.update({ + "HDF5_CXX": self.options["hdf5"].enable_cxx, + "HDF5_HL": self.options["hdf5"].hl, + }) cmake.configure() cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hdf5/all/test_package/test_package.c b/recipes/hdf5/all/test_package/test_package.c new file mode 100644 index 0000000000000..acc23d1bd8c5f --- /dev/null +++ b/recipes/hdf5/all/test_package/test_package.c @@ -0,0 +1,50 @@ +#include "hdf5.h" +#define FILE "dset.h5" + +extern void test_cxx_api(); +extern void test_parallel(); + +void test_c_api() +{ + + hid_t file_id, dataset_id, dataspace_id; /* identifiers */ + hsize_t dims[2]; + herr_t status; + + /* Create a new file using default properties. */ + file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* Create the data space for the dataset. */ + dims[0] = 4; + dims[1] = 6; + dataspace_id = H5Screate_simple(2, dims, NULL); + + /* Create the dataset. */ + dataset_id = + H5Dcreate2(file_id, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* End access to the dataset and release resources used by it. */ + status = H5Dclose(dataset_id); + + /* Terminate access to the data space. */ + status = H5Sclose(dataspace_id); + + /* Close the file. */ + status = H5Fclose(file_id); +} + +int main(int argc, char **argv) +{ + printf("Testing C API\n"); + test_c_api(); + #ifdef CONAN_HDF5_CXX + printf("Testing C++ API\n"); + test_cxx_api(); + #endif + #ifdef CONAN_HDF5_PARALLEL + printf("Testing HDF5 Parallel\n"); + test_parallel(argc, argv); + #endif + + return 0; +} diff --git a/recipes/hdf5/all/test_package/test_package.cpp b/recipes/hdf5/all/test_package/test_package.cpp index 2fbbea020f20b..ef3ec22b3871e 100644 --- a/recipes/hdf5/all/test_package/test_package.cpp +++ b/recipes/hdf5/all/test_package/test_package.cpp @@ -1,8 +1,8 @@ #include -int main() +extern "C" void test_cxx_api() { - hsize_t dimensions[] = {4, 6}; + hsize_t dimensions[] = {4, 6}; H5::H5File file("dataset.h5", H5F_ACC_TRUNC); H5::DataSpace dataspace(2, dimensions); H5::DataSet dataset = file.createDataSet("dataset", H5::PredType::STD_I32BE, dataspace); diff --git a/recipes/hdf5/all/test_package/test_parallel.c b/recipes/hdf5/all/test_package/test_parallel.c new file mode 100644 index 0000000000000..557e7c0f80372 --- /dev/null +++ b/recipes/hdf5/all/test_package/test_parallel.c @@ -0,0 +1,99 @@ +/* + * This example writes data to the HDF5 file. + * Number of processes is assumed to be 1 or multiples of 2 (up to 8) + */ + +#include "hdf5.h" +#include "stdlib.h" + +#define H5FILE_NAME "SDS.h5" +#define DATASETNAME "IntArray" +#define NX 8 /* dataset dimensions */ +#define NY 5 +#define RANK 2 + +int test_parallel(int argc, char **argv) +{ + /* + * HDF5 APIs definitions + */ + hid_t file_id, dset_id; /* file and dataset identifiers */ + hid_t filespace; /* file and memory dataspace identifiers */ + hsize_t dimsf[] = {NX, NY}; /* dataset dimensions */ + int *data; /* pointer to data buffer to write */ + hid_t plist_id; /* property list identifier */ + int i; + herr_t status; + + /* + * MPI variables + */ + int mpi_size, mpi_rank; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + + /* + * Initialize MPI + */ + MPI_Init(&argc, &argv); + MPI_Comm_size(comm, &mpi_size); + MPI_Comm_rank(comm, &mpi_rank); + + /* + * Initialize data buffer + */ + data = (int *) malloc(sizeof(int)*dimsf[0]*dimsf[1]); + for (i=0; i < dimsf[0]*dimsf[1]; i++) { + data[i] = i; + } + /* + * Set up file access property list with parallel I/O access + */ + plist_id = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_mpio(plist_id, comm, info); + + /* + * Create a new file collectively and release property list identifier. + */ + file_id = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, plist_id); + H5Pclose(plist_id); + + + /* + * Create the dataspace for the dataset. + */ + filespace = H5Screate_simple(RANK, dimsf, NULL); + + /* + * Create the dataset with default properties and close filespace. + */ + dset_id = H5Dcreate(file_id, DATASETNAME, H5T_NATIVE_INT, filespace, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + /* + * Create property list for collective dataset write. + */ + plist_id = H5Pcreate(H5P_DATASET_XFER); + H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE); + + /* + * To write dataset independently use + * + * H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_INDEPENDENT); + */ + + status = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + plist_id, data); + free(data); + + /* + * Close/release resources. + */ + H5Dclose(dset_id); + H5Sclose(filespace); + H5Pclose(plist_id); + H5Fclose(file_id); + + MPI_Finalize(); + + return 0; +} diff --git a/recipes/hdf5/config.yml b/recipes/hdf5/config.yml index 372ebdeb20842..354b7315d78c1 100644 --- a/recipes/hdf5/config.yml +++ b/recipes/hdf5/config.yml @@ -1,4 +1,10 @@ versions: + "1.13.1": + folder: all + "1.12.2": + folder: all + "1.12.1": + folder: all "1.12.0": folder: all "1.10.6": diff --git a/recipes/hdrhistogram-c/all/CMakeLists.txt b/recipes/hdrhistogram-c/all/CMakeLists.txt deleted file mode 100644 index 1848ca5a77c35..0000000000000 --- a/recipes/hdrhistogram-c/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/hdrhistogram-c/all/conandata.yml b/recipes/hdrhistogram-c/all/conandata.yml index 41b43fd72aa14..b4fa682a3e25b 100644 --- a/recipes/hdrhistogram-c/all/conandata.yml +++ b/recipes/hdrhistogram-c/all/conandata.yml @@ -8,4 +8,3 @@ sources: patches: "0.11.0": - patch_file: "patches/cmake-install.patch" - base_path: "source_subfolder" diff --git a/recipes/hdrhistogram-c/all/conanfile.py b/recipes/hdrhistogram-c/all/conanfile.py index cbcac4d81fd37..4166d96c192f3 100644 --- a/recipes/hdrhistogram-c/all/conanfile.py +++ b/recipes/hdrhistogram-c/all/conanfile.py @@ -1,6 +1,10 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, rmdir import os +required_conan_version = ">=1.52.0" + class HdrhistogramcConan(ConanFile): name = "hdrhistogram-c" @@ -9,19 +13,19 @@ class HdrhistogramcConan(ConanFile): homepage = "https://github.com/HdrHistogram/HdrHistogram_c" description = "'C' port of High Dynamic Range (HDR) Histogram" topics = ("libraries", "c", "histogram") - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" - settings = "os", "compiler", "build_type", "arch" - options = {"fPIC": [True, False], - "shared": [True, False]} - default_options = {"fPIC": True, - "shared": False} - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + "shared": [True, False], + } + default_options = { + "fPIC": True, + "shared": False, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -29,52 +33,72 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("HdrHistogram_c-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["HDR_HISTOGRAM_BUILD_PROGRAMS"] = False - self._cmake.definitions["HDR_HISTOGRAM_BUILD_SHARED"] = self.options.shared - self._cmake.definitions["HDR_HISTOGRAM_INSTALL_SHARED"] = self.options.shared - self._cmake.definitions["HDR_HISTOGRAM_BUILD_STATIC"] = not self.options.shared - self._cmake.definitions["HDR_HISTOGRAM_INSTALL_STATIC"] = not self.options.shared - self._cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = self.options.shared - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["HDR_HISTOGRAM_BUILD_PROGRAMS"] = False + tc.variables["HDR_HISTOGRAM_BUILD_SHARED"] = self.options.shared + tc.variables["HDR_HISTOGRAM_INSTALL_SHARED"] = self.options.shared + tc.variables["HDR_HISTOGRAM_BUILD_STATIC"] = not self.options.shared + tc.variables["HDR_HISTOGRAM_INSTALL_STATIC"] = not self.options.shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = self.options.shared + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) - self.copy("COPYING.txt", dst="licenses", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "COPYING.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + target = "hdr_histogram" if self.options.shared else "hdr_histogram_static" + self.cpp_info.set_property("cmake_file_name", "hdr_histogram") + self.cpp_info.set_property("cmake_target_name", f"hdr_histogram::{target}") + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["hdr_histrogram"].libs = collect_libs(self) + self.cpp_info.components["hdr_histrogram"].includedirs.append(os.path.join("include", "hdr")) + if not self.options.shared: + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["hdr_histrogram"].system_libs = ["m", "rt"] + elif self.settings.os == "Windows": + self.cpp_info.components["hdr_histrogram"].system_libs = ["ws2_32"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.names["cmake_find_package"] = "hdr_histogram" self.cpp_info.names["cmake_find_package_multi"] = "hdr_histogram" - hdr_histogram_target = "hdr_histogram" if self.options.shared else "hdr_histogram_static" - self.cpp_info.components["hdr_histrogram"].names["cmake_find_package"] = hdr_histogram_target - self.cpp_info.components["hdr_histrogram"].names["cmake_find_package_multi"] = hdr_histogram_target - self.cpp_info.components["hdr_histrogram"].libs = tools.collect_libs(self) - self.cpp_info.components["hdr_histrogram"].includedirs = ["include", os.path.join("include", "hdr")] + self.cpp_info.components["hdr_histrogram"].names["cmake_find_package"] = target + self.cpp_info.components["hdr_histrogram"].names["cmake_find_package_multi"] = target + self.cpp_info.components["hdr_histrogram"].set_property("cmake_target_name", f"hdr_histogram::{target}") self.cpp_info.components["hdr_histrogram"].requires = ["zlib::zlib"] - if self.settings.os == "Linux": - self.cpp_info.components["hdr_histrogram"].system_libs = ["m", "rt"] - elif self.settings.os == "Windows" and not self.options.shared: - self.cpp_info.components["hdr_histrogram"].system_libs = ["ws2_32"] diff --git a/recipes/hdrhistogram-c/all/test_package/CMakeLists.txt b/recipes/hdrhistogram-c/all/test_package/CMakeLists.txt index efa6503046a20..43cecb9cf0752 100644 --- a/recipes/hdrhistogram-c/all/test_package/CMakeLists.txt +++ b/recipes/hdrhistogram-c/all/test_package/CMakeLists.txt @@ -1,14 +1,11 @@ cmake_minimum_required(VERSION 3.1) project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - find_package(hdr_histogram REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -if(HDRHISTOGRAM_SHARED) - target_link_libraries(${PROJECT_NAME} hdr_histogram::hdr_histogram) +if(TARGET hdr_histogram::hdr_histogram_static) + target_link_libraries(${PROJECT_NAME} PRIVATE hdr_histogram::hdr_histogram_static) else() - target_link_libraries(${PROJECT_NAME} hdr_histogram::hdr_histogram_static) + target_link_libraries(${PROJECT_NAME} PRIVATE hdr_histogram::hdr_histogram) endif() diff --git a/recipes/hdrhistogram-c/all/test_package/conanfile.py b/recipes/hdrhistogram-c/all/test_package/conanfile.py index 3fdb80e904c42..0a6bc68712d90 100644 --- a/recipes/hdrhistogram-c/all/test_package/conanfile.py +++ b/recipes/hdrhistogram-c/all/test_package/conanfile.py @@ -1,18 +1,26 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) - cmake.definitions["HDRHISTOGRAM_SHARED"] = self.options["hdrhistogram-c"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/hdrhistogram-c/all/test_v1_package/CMakeLists.txt b/recipes/hdrhistogram-c/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0f3ffb58a6c47 --- /dev/null +++ b/recipes/hdrhistogram-c/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(hdr_histogram REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +if(TARGET hdr_histogram::hdr_histogram_static) + target_link_libraries(${PROJECT_NAME} PRIVATE hdr_histogram::hdr_histogram_static) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE hdr_histogram::hdr_histogram) +endif() diff --git a/recipes/hdrhistogram-c/all/test_v1_package/conanfile.py b/recipes/hdrhistogram-c/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/hdrhistogram-c/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/heatshrink/all/CMakeLists.txt b/recipes/heatshrink/all/CMakeLists.txt new file mode 100644 index 0000000000000..e739fade74253 --- /dev/null +++ b/recipes/heatshrink/all/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.8) +project(heatshrink LANGUAGES C) + +add_library(heatshrink + ${HEATSHRINK_SRC_DIR}/heatshrink_decoder.c + ${HEATSHRINK_SRC_DIR}/heatshrink_encoder.c +) +target_include_directories(heatshrink PUBLIC ${HEATSHRINK_SRC_DIR}) +set_target_properties(heatshrink PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) +target_compile_features(heatshrink PRIVATE c_std_99) + +include(GNUInstallDirs) +install( + FILES + ${HEATSHRINK_SRC_DIR}/heatshrink_common.h + ${HEATSHRINK_SRC_DIR}/heatshrink_config.h + ${HEATSHRINK_SRC_DIR}/heatshrink_decoder.h + ${HEATSHRINK_SRC_DIR}/heatshrink_encoder.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +install( + TARGETS heatshrink + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) diff --git a/recipes/heatshrink/all/conandata.yml b/recipes/heatshrink/all/conandata.yml new file mode 100644 index 0000000000000..520974039dd7a --- /dev/null +++ b/recipes/heatshrink/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.4.1": + url: "https://github.com/atomicobject/heatshrink/archive/refs/tags/v0.4.1.tar.gz" + sha256: "7529a1c8ac501191ad470b166773364e66d9926aad632690c72c63a1dea7e9a6" diff --git a/recipes/heatshrink/all/conanfile.py b/recipes/heatshrink/all/conanfile.py new file mode 100644 index 0000000000000..06cb55ed511e8 --- /dev/null +++ b/recipes/heatshrink/all/conanfile.py @@ -0,0 +1,84 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file +import os + +required_conan_version = ">=1.53.0" + + +class HeatshrinkConan(ConanFile): + name = "heatshrink" + license = "ISC" + url = "https://github.com/conan-io/conan-center-index" + description = "data compression library for embedded/real-time systems" + topics = ("compression", "embedded", "realtime") + homepage = "https://github.com/atomicobject/heatshrink" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [False, True], + "fPIC": [True, False], + "dynamic_alloc": [True, False], + "debug_log": [True, False], + "use_index": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "dynamic_alloc": True, + "debug_log": False, + "use_index": True, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["HEATSHRINK_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def _patch_sources(self): + config_file = os.path.join(self.source_folder, "heatshrink_config.h") + if not self.options.dynamic_alloc: + replace_in_file(self, config_file, + "#define HEATSHRINK_DYNAMIC_ALLOC 1", + "#define HEATSHRINK_DYNAMIC_ALLOC 0") + if self.options.debug_log: + replace_in_file(self, config_file, + "#define HEATSHRINK_DEBUGGING_LOGS 0", + "#define HEATSHRINK_DEBUGGING_LOGS 1") + if not self.options.use_index: + replace_in_file(self, config_file, + "#define HEATSHRINK_USE_INDEX 1", + "#define HEATSHRINK_USE_INDEX 0") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["heatshrink"] diff --git a/recipes/heatshrink/all/test_package/CMakeLists.txt b/recipes/heatshrink/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ac68508859a4c --- /dev/null +++ b/recipes/heatshrink/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(heatshrink REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE heatshrink::heatshrink) diff --git a/recipes/heatshrink/all/test_package/conanfile.py b/recipes/heatshrink/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/heatshrink/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/heatshrink/all/test_package/test_package.c b/recipes/heatshrink/all/test_package/test_package.c new file mode 100644 index 0000000000000..0e3338c2dbbc8 --- /dev/null +++ b/recipes/heatshrink/all/test_package/test_package.c @@ -0,0 +1,14 @@ +#include "heatshrink_encoder.h" + +int main() { +#if HEATSHRINK_DYNAMIC_ALLOC + heatshrink_encoder *hse = heatshrink_encoder_alloc(8, 7); + heatshrink_encoder_reset(hse); + heatshrink_encoder_free(hse); +#else + heatshrink_encoder hse; + heatshrink_encoder_reset(&hse); +#endif + + return 0; +} diff --git a/recipes/heatshrink/all/test_v1_package/CMakeLists.txt b/recipes/heatshrink/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/heatshrink/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/heatshrink/all/test_v1_package/conanfile.py b/recipes/heatshrink/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/heatshrink/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/heatshrink/config.yml b/recipes/heatshrink/config.yml new file mode 100644 index 0000000000000..3a9d5538921fc --- /dev/null +++ b/recipes/heatshrink/config.yml @@ -0,0 +1,3 @@ +versions: + "0.4.1": + folder: all diff --git a/recipes/hedley/all/conanfile.py b/recipes/hedley/all/conanfile.py index 8ae886f4acb6b..835a13a80a59b 100644 --- a/recipes/hedley/all/conanfile.py +++ b/recipes/hedley/all/conanfile.py @@ -1,6 +1,9 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -import glob + +required_conan_version = ">=1.50.0" class HedleyConan(ConanFile): @@ -9,22 +12,27 @@ class HedleyConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://nemequ.github.io/hedley/" description = "A C/C++ header to help move #ifdefs out of your code" - topics = ("header", 'header-only', 'preprocessor', "#ifdef", "cross-platform") + topics = ("header", "header-only", "preprocessor", "#ifdef", "cross-platform") + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob(self.name + "-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - include_folder = self._source_subfolder - self.copy(pattern="*.h", dst="include", src=include_folder) - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/hedley/all/test_package/CMakeLists.txt b/recipes/hedley/all/test_package/CMakeLists.txt index d4fdee1a8a79c..6cccdaf4798b6 100644 --- a/recipes/hedley/all/test_package/CMakeLists.txt +++ b/recipes/hedley/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(hedley REQUIRED CONFIG) -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE hedley::hedley) diff --git a/recipes/hedley/all/test_package/conanfile.py b/recipes/hedley/all/test_package/conanfile.py index b3f8b8942bc21..0a6bc68712d90 100644 --- a/recipes/hedley/all/test_package/conanfile.py +++ b/recipes/hedley/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/hedley/all/test_package/example.cpp b/recipes/hedley/all/test_package/test_package.cpp similarity index 100% rename from recipes/hedley/all/test_package/example.cpp rename to recipes/hedley/all/test_package/test_package.cpp diff --git a/recipes/hedley/all/test_v1_package/CMakeLists.txt b/recipes/hedley/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/hedley/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/hedley/all/test_v1_package/conanfile.py b/recipes/hedley/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/hedley/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hexl/all/CMakeLists.txt b/recipes/hexl/all/CMakeLists.txt new file mode 100644 index 0000000000000..8b3b9ef203c08 --- /dev/null +++ b/recipes/hexl/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.13.0) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory("source_subfolder") diff --git a/recipes/hexl/all/conandata.yml b/recipes/hexl/all/conandata.yml new file mode 100644 index 0000000000000..8ed6d6d348eaa --- /dev/null +++ b/recipes/hexl/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.2.4": + url: "https://github.com/intel/hexl/archive/refs/tags/v1.2.4.tar.gz" + sha256: "f91dd158e3faa8795035f618286cdef7dacbf488fd0ba4f44409880997b4549f" +patches: + "1.2.4": + - patch_file: "patches/fix-cmake.patch" + base_path: "source_subfolder" diff --git a/recipes/hexl/all/conanfile.py b/recipes/hexl/all/conanfile.py new file mode 100644 index 0000000000000..820c3b5030b0a --- /dev/null +++ b/recipes/hexl/all/conanfile.py @@ -0,0 +1,158 @@ +from conans import CMake, tools +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc +from conan.tools.files import get, rmdir +from conan.tools.scm import Version +from conan.tools.build import cross_building + +import os + +required_conan_version = ">=1.43.0" + +class HexlConan(ConanFile): + name = "hexl" + license = "Apache-2.0" + homepage = "https://github.com/intel/hexl" + url = "https://github.com/conan-io/conan-center-index" + description = "Intel Homomorphic Encryption (HE) Acceleration Library" + topics = ("homomorphic", "encryption", "privacy") + settings = "os", "compiler", "build_type", "arch" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake", "cmake_find_package" + + _cmake = None + + options = { + "shared": [True, False], + "fPIC": [True, False], + "experimental": [True, False], + "fpga_compatibility_dyadic_multiply": [True, False], + "fpga_compatibility_keyswitch": [True, False] + } + + default_options = { + "shared": False, + "fPIC": True, + "experimental": False, + "fpga_compatibility_dyadic_multiply": False, + "fpga_compatibility_keyswitch": False + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def build_requirements(self): + self.build_requires("cmake/3.22.0") + + def requirements(self): + self.requires("cpu_features/0.7.0") + + if self.settings.build_type == "Debug": + self.requires("easyloggingpp/9.97.0") + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "15.7", + "clang": "7", + "apple-clang": "11", + } + + def validate(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, 17) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version: + if Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration("{} requires C++17, which your compiler does not support.".format(self.name)) + else: + self.output.warn("{} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name)) + + if self.settings.arch not in ["x86", "x86_64"]: + raise ConanInvalidConfiguration("Hexl only supports x86 architecture") + + if self.options.shared and is_msvc(self): + raise ConanInvalidConfiguration("Hexl only supports static linking with msvc") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self); + + + self._cmake.definitions["HEXL_BENCHMARK"] = False + self._cmake.definitions["HEXL_TESTING"] = False + self._cmake.definitions["HEXL_EXPERIMENTAL"] = self.options.experimental + + + if self.options.fpga_compatibility_dyadic_multiply and self.options.fpga_compatibility_keyswitch: + self._cmake.definitions["HEXL_FPGA_COMPATIBILITY"] = 3 + elif self.options.fpga_compatibility_dyadic_multiply: + self._cmake.definitions["HEXL_FPGA_COMPATIBILITY"] = 1 + elif self.options.fpga_compatibility_keyswitch: + self._cmake.definitions["HEXL_FPGA_COMPATIBILITY"] = 2 + else: + self._cmake.definitions["HEXL_FPGA_COMPATIBILITY"] = 0 + + self._cmake.definitions["HEXL_SHARED_LIB"] = self.options.shared + self._cmake.definitions["HEXL_CROSS_COMPILED"] = cross_building(self) + + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Hexl") + # TODO: Remove in Conan 2.0 + self.cpp_info.names["cmake_find_package"] = "Hexl" + self.cpp_info.names["cmake_find_package_multi"] = "Hexl" + + if self.settings.build_type == "Debug": + if not is_msvc(self): + self.cpp_info.components["Hexl"].libs = ["hexl_debug"] + else: + self.cpp_info.components["Hexl"].libs = ["hexl"] + + self.cpp_info.components["Hexl"].requires.append("easyloggingpp::easyloggingpp") + else: + self.cpp_info.components["Hexl"].libs = ["hexl"] + + self.cpp_info.components["Hexl"].names["cmake_find_package"] = "hexl" + self.cpp_info.components["Hexl"].names["cmake_find_package_multi"] = "hexl" + self.cpp_info.components["Hexl"].set_property("cmake_target_name", "Hexl::hexl") + self.cpp_info.components["Hexl"].set_property("pkg_config_name", "hexl") + self.cpp_info.components["Hexl"].requires.append("cpu_features::libcpu_features") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["Hexl"].system_libs = ["pthread", "m"] + diff --git a/recipes/hexl/all/patches/fix-cmake.patch b/recipes/hexl/all/patches/fix-cmake.patch new file mode 100644 index 0000000000000..8aeb45bf1b421 --- /dev/null +++ b/recipes/hexl/all/patches/fix-cmake.patch @@ -0,0 +1,122 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1cee76b..0db1f9c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -28,10 +28,6 @@ if(CMAKE_BUILD_TYPE) + endif() + endif() + +-if(NOT CMAKE_BUILD_TYPE) +- set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE) +-endif() +- + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(HEXL_DEBUG ON) + else() +@@ -139,18 +135,12 @@ message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") + #------------------------------------------------------------------------------ + # Third-party code... + #------------------------------------------------------------------------------ +-find_package(CpuFeatures CONFIG) +-if (NOT CpuFeatures_FOUND) +- message(STATUS "CpuFeatures: pre-installed CpuFeatures not found") +- add_subdirectory(cmake/third-party/cpu-features) +-else() +- message(STATUS "CpuFeatures: found") +- add_library(cpu_features ALIAS CpuFeatures::cpu_features) +- get_target_property( +- CpuFeatures_INCLUDE_DIR +- CpuFeatures::cpu_features +- INTERFACE_INCLUDE_DIRECTORIES) +-endif() ++find_package(CpuFeatures REQUIRED) ++add_library(cpu_features ALIAS CpuFeatures::cpu_features) ++get_target_property( ++ CpuFeatures_INCLUDE_DIR ++ CpuFeatures::cpu_features ++ INTERFACE_INCLUDE_DIRECTORIES) + + if (HEXL_TESTING OR HEXL_BENCHMARK OR HEXL_DEBUG) + if(NOT TARGET Threads::Threads) +@@ -168,18 +158,11 @@ if (HEXL_BENCHMARK) + endif() + + if (HEXL_DEBUG) +- list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/third-party/easylogging") +- find_package(EASYLOGGINGPP MODULE) +- if (EASYLOGGINGPP_FOUND) +- message(STATUS "easyloggingpp: pre-installed easyloggingpp found") +- get_target_property( +- EASYLOGGINGPP_INCLUDE_DIR +- easyloggingpp +- INTERFACE_INCLUDE_DIRECTORIES) +- else() +- message(STATUS "easyloggingpp: pre-installed easyloggingpp NOT found, building from source") +- add_subdirectory(cmake/third-party/easylogging) +- endif() ++ find_package(easyloggingpp REQUIRED) ++ get_target_property( ++ EASYLOGGINGPP_INCLUDE_DIR ++ easyloggingpp::easyloggingpp ++ INTERFACE_INCLUDE_DIRECTORIES) + endif() + + #------------------------------------------------------------------------------ +diff --git a/hexl/CMakeLists.txt b/hexl/CMakeLists.txt +index 139f17c..6558256 100644 +--- a/hexl/CMakeLists.txt ++++ b/hexl/CMakeLists.txt +@@ -53,7 +53,8 @@ else() + endif() + add_library(HEXL::hexl ALIAS hexl) + +-hexl_add_asan_flag(hexl) ++# Should come from compiler.sanitizer=Address ++# hexl_add_asan_flag(hexl) + + set(HEXL_DEFINES_IN_FILENAME ${CMAKE_CURRENT_SOURCE_DIR}/include/hexl/util/defines.hpp.in) + set(HEXL_DEFINES_FILENAME ${CMAKE_CURRENT_SOURCE_DIR}/include/hexl/util/defines.hpp) +@@ -89,10 +90,15 @@ endif() + + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + target_compile_options(hexl PRIVATE -Wall -Wconversion -Wshadow -pedantic -Wextra +- -Wno-unknown-pragmas -march=native -O3 -fomit-frame-pointer ++ -Wno-unknown-pragmas -O3 -fomit-frame-pointer + -Wno-sign-conversion + -Wno-implicit-int-conversion + ) ++ ++ if(NOT HEXL_CROSS_COMPILED) ++ target_compile_options(hexl PRIVATE -march=native) ++ endif() ++ + # Avoid 3rd-party dependency warnings when including HEXL as a dependency + target_compile_options(hexl PUBLIC + -Wno-unknown-warning +@@ -121,7 +127,7 @@ if (HEXL_SHARED_LIB) + target_link_libraries(hexl PUBLIC easyloggingpp) + # Manually add logging include directory + target_include_directories(hexl +- PUBLIC $> ++ PUBLIC ${EASYLOGGINGPP_INCLUDE_DIR} + ) + endif() + else () +@@ -132,7 +138,7 @@ else () + if (HEXL_DEBUG) + # Manually add logging include directory + target_include_directories(hexl +- PUBLIC $> ++ PUBLIC ${EASYLOGGINGPP_INCLUDE_DIR} + ) + if (EASYLOGGINGPP_FOUND) + target_link_libraries(hexl PRIVATE easyloggingpp) +@@ -152,8 +158,6 @@ else () + PRIVATE $) + endif() + +-install(TARGETS hexl DESTINATION ${CMAKE_INSTALL_LIBDIR}) +- + #------------------------------------------------------------------------------ + # Config export... + #------------------------------------------------------------------------------ diff --git a/recipes/hexl/all/test_package/CMakeLists.txt b/recipes/hexl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..cf18c1281c79a --- /dev/null +++ b/recipes/hexl/all/test_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Hexl COMPONENTS hexl REQUIRED) +add_executable(example example.cpp) +target_link_libraries(example PRIVATE Hexl::hexl) + diff --git a/recipes/hexl/all/test_package/conanfile.py b/recipes/hexl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..417bb10e807de --- /dev/null +++ b/recipes/hexl/all/test_package/conanfile.py @@ -0,0 +1,20 @@ +import os + +from conans import ConanFile, CMake, tools +from conan.tools.build import cross_building + + +class HexlTestConan(ConanFile): + settings = "os", "build_type", "arch", "compiler" + generators = "cmake", "cmake_find_package" + + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/hexl/all/test_package/example.cpp b/recipes/hexl/all/test_package/example.cpp new file mode 100644 index 0000000000000..e276d0275eeb4 --- /dev/null +++ b/recipes/hexl/all/test_package/example.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "hexl/hexl.hpp" + +bool CheckEqual(const std::vector& x, + const std::vector& y) { + if (x.size() != y.size()) { + std::cout << "Not equal in size\n"; + return false; + } + uint64_t N = x.size(); + bool is_match = true; + for (size_t i = 0; i < N; ++i) { + if (x[i] != y[i]) { + std::cout << "Not equal at index " << i << "\n"; + is_match = false; + } + } + return is_match; +} + +bool ExampleEltwiseVectorVectorAddMod() { + std::vector op1{1, 2, 3, 4, 5, 6, 7, 8}; + std::vector op2{1, 3, 5, 7, 2, 4, 6, 8}; + uint64_t modulus = 10; + std::vector exp_out{2, 5, 8, 1, 7, 0, 3, 6}; + + intel::hexl::EltwiseAddMod(op1.data(), op1.data(), op2.data(), op1.size(), + modulus); + + return CheckEqual(op1, exp_out); +} + +int main() { + if(ExampleEltwiseVectorVectorAddMod()) + { + return 0; + } + + return -1; +} diff --git a/recipes/hexl/config.yml b/recipes/hexl/config.yml new file mode 100644 index 0000000000000..5c12183246809 --- /dev/null +++ b/recipes/hexl/config.yml @@ -0,0 +1,3 @@ +versions: + "1.2.4": + folder: all diff --git a/recipes/hffix/all/conandata.yml b/recipes/hffix/all/conandata.yml new file mode 100644 index 0000000000000..63e048eedc787 --- /dev/null +++ b/recipes/hffix/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.1.1": + url: "https://github.com/jamesdbrock/hffix/archive/refs/tags/v1.1.1.tar.gz" + sha256: "25dcaee8ded3590dd04225bd98909c9d78c8e39c26fb3c9880ec001a35464c07" diff --git a/recipes/hffix/all/conanfile.py b/recipes/hffix/all/conanfile.py new file mode 100644 index 0000000000000..b8be09b23ee81 --- /dev/null +++ b/recipes/hffix/all/conanfile.py @@ -0,0 +1,42 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class HffixConan(ConanFile): + name = "hffix" + description = "Financial Information Exchange Protocol C++ Library" + license = "BSD-2-Clause" + topics = ("fixprotocol", "financial") + homepage = "https://github.com/jamesdbrock/hffix" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + + no_copy_source = True + + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/hffix/all/test_package/CMakeLists.txt b/recipes/hffix/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..bea843560a088 --- /dev/null +++ b/recipes/hffix/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(hffix REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE hffix::hffix) diff --git a/recipes/hffix/all/test_package/conanfile.py b/recipes/hffix/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/hffix/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/hffix/all/test_package/test_package.cpp b/recipes/hffix/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..1efe3d51d13ff --- /dev/null +++ b/recipes/hffix/all/test_package/test_package.cpp @@ -0,0 +1,69 @@ +#include + +#include + +int main() { + int seq_send = 1; + + char buffer[1 << 13]; + + // We'll put a FIX Logon message in the buffer. + hffix::message_writer logon(buffer, buffer + sizeof(buffer)); + + logon.push_back_header("FIX.4.2"); // Write BeginString and BodyLength. + + // Logon MsgType. + logon.push_back_string (hffix::tag::MsgType, "A"); + logon.push_back_string (hffix::tag::SenderCompID, "AAAA"); + logon.push_back_string (hffix::tag::TargetCompID, "BBBB"); + logon.push_back_int (hffix::tag::MsgSeqNum, seq_send++); + logon.push_back_timestamp (hffix::tag::SendingTime, 2022, 02, 23, 11, 20, 0); + // No encryption. + logon.push_back_int (hffix::tag::EncryptMethod, 0); + // 10 second heartbeat interval. + logon.push_back_int (hffix::tag::HeartBtInt, 10); + + logon.push_back_trailer(); // write CheckSum. + + // Now the Logon message is written to the buffer. + + // Add a FIX New Order - Single message to the buffer, after the Logon + // message. + hffix::message_writer new_order(logon.message_end(), buffer + sizeof(buffer)); + + new_order.push_back_header("FIX.4.2"); + + // New Order - Single + new_order.push_back_string (hffix::tag::MsgType, "D"); + // Required Standard Header field. + new_order.push_back_string (hffix::tag::SenderCompID, "AAAA"); + new_order.push_back_string (hffix::tag::TargetCompID, "BBBB"); + new_order.push_back_int (hffix::tag::MsgSeqNum, seq_send++); + new_order.push_back_timestamp (hffix::tag::SendingTime, 2022, 2, 23, 11, 20, 0); + new_order.push_back_string (hffix::tag::ClOrdID, "A1"); + // Automated execution. + new_order.push_back_char (hffix::tag::HandlInst, '1'); + // Ticker symbol OIH. + new_order.push_back_string (hffix::tag::Symbol, "OIH"); + // Buy side. + new_order.push_back_char (hffix::tag::Side, '1'); + new_order.push_back_timestamp (hffix::tag::TransactTime, 2022, 2, 23, 11, 20, 0); + // 100 shares. + new_order.push_back_int (hffix::tag::OrderQty, 100); + // Limit order. + new_order.push_back_char (hffix::tag::OrdType, '2'); + // Limit price $500.01 = 50001*(10^-2). The push_back_decimal() method + // takes a decimal floating point number of the form mantissa*(10^exponent). + new_order.push_back_decimal (hffix::tag::Price, 50001, -2); + // Good Till Cancel. + new_order.push_back_char (hffix::tag::TimeInForce, '1'); + + new_order.push_back_trailer(); // write CheckSum. + + //Now the New Order message is in the buffer after the Logon message. + + // Write both messages to stdout. + std::cout.write(buffer, new_order.message_end() - buffer); + + return 0; +} diff --git a/recipes/hffix/all/test_v1_package/CMakeLists.txt b/recipes/hffix/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..31a17e5e32684 --- /dev/null +++ b/recipes/hffix/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(hffix REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE hffix::hffix) diff --git a/recipes/hffix/all/test_v1_package/conanfile.py b/recipes/hffix/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/hffix/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hffix/config.yml b/recipes/hffix/config.yml new file mode 100644 index 0000000000000..60d31991f5141 --- /dev/null +++ b/recipes/hffix/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.1": + folder: all diff --git a/recipes/hidapi/all/conandata.yml b/recipes/hidapi/all/conandata.yml index 332c97dc99f9f..51d6d194c4062 100644 --- a/recipes/hidapi/all/conandata.yml +++ b/recipes/hidapi/all/conandata.yml @@ -1,4 +1,13 @@ sources: + "0.12.0": + url: "https://github.com/libusb/hidapi/archive/hidapi-0.12.0.tar.gz" + sha256: "28ec1451f0527ad40c1a4c92547966ffef96813528c8b184a665f03ecbb508bc" + "0.11.2": + url: "https://github.com/libusb/hidapi/archive/hidapi-0.11.2.tar.gz" + sha256: "bc4ac0f32a6b21ef96258a7554c116152e2272dacdec1e4620fc44abeea50c27" + "0.11.0": + url: "https://github.com/libusb/hidapi/archive/hidapi-0.11.0.tar.gz" + sha256: "391d8e52f2d6a5cf76e2b0c079cfefe25497ba1d4659131297081fc0cd744632" "0.10.1": url: "https://github.com/libusb/hidapi/archive/refs/tags/hidapi-0.10.1.tar.gz" sha256: "f71dd8a1f46979c17ee521bc2117573872bbf040f8a4750e492271fc141f2644" diff --git a/recipes/hidapi/all/conanfile.py b/recipes/hidapi/all/conanfile.py index 9f25d7629117d..eaf53fb9ab72b 100644 --- a/recipes/hidapi/all/conanfile.py +++ b/recipes/hidapi/all/conanfile.py @@ -1,6 +1,9 @@ -import os from conans import ConanFile, AutoToolsBuildEnvironment, MSBuild, tools from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.36.0" class HidapiConan(ConanFile): @@ -11,7 +14,8 @@ class HidapiConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/libusb/hidapi" license = "GPL-3-or-later", "BSD-3-Clause" - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "fPIC": [True, False], "shared": [True, False], @@ -20,61 +24,68 @@ class HidapiConan(ConanFile): "fPIC": True, "shared": False, } + generators = "pkg_config" - _autotools = None @property def _source_subfolder(self): return "source_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if self.settings.compiler == "Visual Studio": + if self._is_msvc: self.options.shared = True def configure(self): - if self.settings.compiler == "Visual Studio" and not self.options.shared: - raise ConanInvalidConfiguration("Static libraries for Visual Studio are currently not available") if self.options.shared: del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + def requirements(self): + if self.settings.os in ["Linux", "FreeBSD"]: + self.requires("libusb/1.0.24") + + def validate(self): + if self._is_msvc and not self.options.shared: + raise ConanInvalidConfiguration("Static libraries for Visual Studio are currently not available") def build_requirements(self): - if self.settings.compiler != "Visual Studio": + if not self._is_msvc: self.build_requires("libtool/2.4.6") - def requirements(self): - if self.settings.os in ["Linux", "FreeBSD"]: - self.requires("libusb/1.0.24") + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def _patch_sources(self): tools.replace_in_file(os.path.join(self._source_subfolder, "configure.ac"), "AC_CONFIG_MACRO_DIR", "dnl AC_CONFIG_MACRO_DIR") + @functools.lru_cache(1) def _configure_autotools(self): - if self._autotools: - return self._autotools - with tools.chdir(self._source_subfolder): - self.run("./bootstrap") - if self.settings.os == "Macos": - tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), - r"-install_name \$rpath/", "-install_name ") - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - args = ["--enable-shared" if self.options.shared else "--disable-shared", - "--enable-static" if not self.options.shared else "--disable-static"] - self._autotools.configure(configure_dir=self._source_subfolder, args=args) - return self._autotools + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + ] + autotools.configure(configure_dir=self._source_subfolder, args=args) + return autotools def build(self): self._patch_sources() - if self.settings.compiler == "Visual Studio": + if self._is_msvc: self._build_msvc() else: + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + # relocatable shared lib on macOS + tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name @rpath/") autotools = self._configure_autotools() autotools.make() @@ -98,12 +109,12 @@ def package(self): def package_info(self): if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["libusb"].names["pkg_config"] = "hidapi-libusb" + self.cpp_info.components["libusb"].set_property("pkg_config_name", "hidapi-libusb") self.cpp_info.components["libusb"].libs = ["hidapi-libusb"] self.cpp_info.components["libusb"].requires = ["libusb::libusb"] self.cpp_info.components["libusb"].system_libs = ["pthread", "dl", "rt"] - self.cpp_info.components["hidraw"].names["pkg_config"] = "hidapi-hidraw" + self.cpp_info.components["hidraw"].set_property("pkg_config_name", "hidapi-hidraw") self.cpp_info.components["hidraw"].libs = ["hidapi-hidraw"] self.cpp_info.components["hidraw"].system_libs = ["pthread", "dl"] else: diff --git a/recipes/hidapi/all/test_package/conanfile.py b/recipes/hidapi/all/test_package/conanfile.py index 5afb671111068..8d1ff488f0374 100644 --- a/recipes/hidapi/all/test_package/conanfile.py +++ b/recipes/hidapi/all/test_package/conanfile.py @@ -6,11 +6,20 @@ class HidapiTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "cmake", "cmake_find_package_multi" + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") + def build(self): cmake = CMake(self) cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/hidapi/config.yml b/recipes/hidapi/config.yml index 36cf695df0df6..8ed4b3c67fc09 100644 --- a/recipes/hidapi/config.yml +++ b/recipes/hidapi/config.yml @@ -1,3 +1,9 @@ versions: + "0.12.0": + folder: all + "0.11.2": + folder: all + "0.11.0": + folder: all "0.10.1": folder: all diff --git a/recipes/highfive/all/conandata.yml b/recipes/highfive/all/conandata.yml new file mode 100644 index 0000000000000..22d7539389bd7 --- /dev/null +++ b/recipes/highfive/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "2.6.2": + url: "https://github.com/BlueBrain/HighFive/archive/refs/tags/v2.6.2.tar.gz" + sha256: "ab51b9fbb49e877dd1aa7b53b4b26875f41e4e0b8ee0fc2f1d735e0d1e43d708" + "2.5.1": + url: "https://github.com/BlueBrain/HighFive/archive/refs/tags/v2.5.1.tar.gz" + sha256: "1ba05aa31cdeda03d013094eebc10f932783e4e071e253e9eaa8889120f241c7" + "2.4.1": + url: "https://github.com/BlueBrain/HighFive/archive/refs/tags/v2.4.1.tar.gz" + sha256: "6826471ef5c645ebf947d29574b302991525a8a8ff1ef687aba7311d9a0ea36f" + "2.3.1": + url: "https://github.com/BlueBrain/HighFive/archive/refs/tags/v2.3.1.tar.gz" + sha256: "41728a1204bdfcdcef8cbc3ddffe5d744c5331434ce3dcef35614b831234fcd7" diff --git a/recipes/highfive/all/conanfile.py b/recipes/highfive/all/conanfile.py new file mode 100644 index 0000000000000..11ed9374f0a0a --- /dev/null +++ b/recipes/highfive/all/conanfile.py @@ -0,0 +1,139 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file, rmdir, save +import os +import textwrap + +required_conan_version = ">=1.50.0" + + +class HighFiveConan(ConanFile): + name = "highfive" + description = "HighFive is a modern header-only C++11 friendly interface for libhdf5." + license = "Boost Software License 1.0" + topics = ("hdf5", "hdf", "data") + homepage = "https://github.com/BlueBrain/HighFive" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "with_boost": [True, False], + "with_eigen": [True, False], + "with_xtensor": [True, False], + "with_opencv": [True, False], + } + default_options = { + "with_boost": True, + "with_eigen": True, + "with_xtensor": True, + "with_opencv": False, + } + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("hdf5/1.13.1") + if self.options.with_boost: + self.requires("boost/1.80.0") + if self.options.with_eigen: + self.requires("eigen/3.4.0") + if self.options.with_xtensor: + self.requires("xtensor/0.24.2") + if self.options.with_opencv: + self.requires("opencv/4.5.5") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["USE_BOOST"] = self.options.with_boost + tc.variables["USE_EIGEN"] = self.options.with_eigen + tc.variables["USE_XTENSOR"] = self.options.with_xtensor + tc.variables["USE_OPENCV"] = self.options.with_opencv + tc.variables["HIGHFIVE_UNIT_TESTS"] = False + tc.variables["HIGHFIVE_EXAMPLES"] = False + tc.variables["HIGHFIVE_BUILD_DOCS"] = False + tc.variables["HIGHFIVE_USE_INSTALL_DEPS"] = False + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + replace_in_file( + self, + os.path.join(self.source_folder, "CMake", "HighFiveTargetDeps.cmake"), + "find_package(Eigen3 NO_MODULE)", + "find_package(Eigen3 REQUIRED)", + ) + replace_in_file( + self, + os.path.join(self.source_folder, "CMake", "HighFiveTargetDeps.cmake"), + "EIGEN3_INCLUDE_DIRS", + "Eigen3_INCLUDE_DIRS", + ) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "share")) + + # TODO: to remove in conan v2 once legacy generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"HighFive": "HighFive::HighFive"}, + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "HighFive") + self.cpp_info.set_property("cmake_target_name", "HighFive") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + self.cpp_info.requires = ["hdf5::hdf5"] + if self.options.with_boost: + self.cpp_info.requires.append("boost::headers") + if self.options.with_eigen: + self.cpp_info.requires.append("eigen::eigen") + if self.options.with_xtensor: + self.cpp_info.requires.append("xtensor::xtensor") + if self.options.with_opencv: + self.cpp_info.requires.append("opencv::opencv") + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.names["cmake_find_package"] = "HighFive" + self.cpp_info.names["cmake_find_package_multi"] = "HighFive" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/highfive/all/test_package/CMakeLists.txt b/recipes/highfive/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..9094d8eb2cd6d --- /dev/null +++ b/recipes/highfive/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(HighFive REQUIRED CONFIG) + +add_executable(test_package test_package.cpp) +target_link_libraries(test_package PRIVATE HighFive) +target_compile_features(test_package PRIVATE cxx_std_11) diff --git a/recipes/highfive/all/test_package/conanfile.py b/recipes/highfive/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/highfive/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/highfive/all/test_package/test_package.cpp b/recipes/highfive/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..93c1b2f6ea391 --- /dev/null +++ b/recipes/highfive/all/test_package/test_package.cpp @@ -0,0 +1,77 @@ +/* + * This file was copied from https://github.com/BlueBrain/HighFive/blob/master/src/examples/create_attribute_string_integer.cpp + * and changed in terms of namespaces and const correctness. + */ +/* + * Copyright (c), 2017, Adrien Devresse + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + */ +#include +#include +#include + +#include +#include +#include +#include + +const std::string FILE_NAME("create_attribute.h5"); +const std::string DATASET_NAME("my_dataset"); + +const std::string ATTRIBUTE_NAME_NOTE("note"); +const std::string ATTRIBUTE_NAME_VERSION("version_string"); + +// create a dataset from a vector of string +// read it back and print it +int main(void) +{ + try + { + // Create a new file using the default property lists. + HighFive::File file(FILE_NAME, HighFive::File::ReadWrite | HighFive::File::Create | HighFive::File::Truncate); + + // Create a dummy dataset of one single integer + HighFive::DataSet dataset = + file.createDataSet(DATASET_NAME, HighFive::DataSpace(1), HighFive::AtomicType()); + + // Now let's add a attribute on this dataset + // This attribute will be named "note" + // and have the following content + std::string string_list("very important Dataset!"); + + HighFive::Attribute attribute = dataset.createAttribute( + ATTRIBUTE_NAME_NOTE, HighFive::DataSpace::From(string_list)); + attribute.write(string_list); + + // We also add a "version" attribute + // that will be an array 1x2 of integer + std::vector version; + version.push_back(1); + version.push_back(0); // version 1.0 + + HighFive::Attribute v = dataset.createAttribute(ATTRIBUTE_NAME_VERSION, + HighFive::DataSpace::From(version)); + v.write(version); + + // Ok all attributes are now written + + // let's list the keys of all attributes now + const std::vector all_attributes_keys = + dataset.listAttributeNames(); + for (const auto &attr : all_attributes_keys) + { + std::cout << "attribute: " << attr << std::endl; + } + } + catch (HighFive::Exception &err) + { + // catch and print any HDF5 error + std::cerr << err.what() << std::endl; + } + + return 0; // successfully terminated +} diff --git a/recipes/highfive/all/test_v1_package/CMakeLists.txt b/recipes/highfive/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..671f071b8ed9f --- /dev/null +++ b/recipes/highfive/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(HighFive REQUIRED CONFIG) + +add_executable(test_package ../test_package/test_package.cpp) +target_link_libraries(test_package PRIVATE HighFive) +target_compile_features(test_package PRIVATE cxx_std_11) diff --git a/recipes/highfive/all/test_v1_package/conanfile.py b/recipes/highfive/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..4453fcd822f20 --- /dev/null +++ b/recipes/highfive/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import CMake, ConanFile, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/highfive/config.yml b/recipes/highfive/config.yml new file mode 100644 index 0000000000000..68e95d416e0fd --- /dev/null +++ b/recipes/highfive/config.yml @@ -0,0 +1,9 @@ +versions: + "2.6.2": + folder: all + "2.5.1": + folder: all + "2.4.1": + folder: all + "2.3.1": + folder: all diff --git a/recipes/highway/all/CMakeLists.txt b/recipes/highway/all/CMakeLists.txt deleted file mode 100644 index 07ec7f05275cb..0000000000000 --- a/recipes/highway/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/highway/all/conandata.yml b/recipes/highway/all/conandata.yml index 5e1fbbff1738b..08bd07626134a 100644 --- a/recipes/highway/all/conandata.yml +++ b/recipes/highway/all/conandata.yml @@ -1,8 +1,27 @@ sources: + "1.0.2": + url: "https://github.com/google/highway/archive/1.0.2.tar.gz" + sha256: "e8ef71236ac0d97f12d553ec1ffc5b6375d57b5f0b860c7447dd69b6ed1072db" + "1.0.1": + url: "https://github.com/google/highway/archive/1.0.1.tar.gz" + sha256: "7ca6af7dc2e3e054de9e17b9dfd88609a7fd202812b1c216f43cc41647c97311" + "1.0.0": + url: "https://github.com/google/highway/archive/1.0.0.tar.gz" + sha256: "ab4f5f864932268356f9f6aa86f612fa4430a7db3c8de0391076750197e876b8" + "0.17.0": + url: "https://github.com/google/highway/archive/0.17.0.tar.gz" + sha256: "25158fd5c090b70ecea47fc246c860d150f07f801d2434e1e51ec14a6c15822c" + "0.16.0": + url: "https://github.com/google/highway/archive/0.16.0.tar.gz" + sha256: "746c9578446be6c5286e8846c5f0d4118c0c1f04219c401abadcb8a5f2051893" + "0.12.2": + url: "https://github.com/google/highway/archive/0.12.2.tar.gz" + sha256: "e1d47ce510429fdcf31f41697ca74fb0dcd59d933196e531a86d51751a56f4cc" "0.11.1": url: "https://github.com/google/highway/archive/0.11.1.tar.gz" sha256: "4c4bb9501c02b27a0944afde8923aaab554384690d37e5b2a7f97553426ea641" patches: + "0.16.0": + - patch_file: "patches/0.16.0-0001-fix-sys-random-h.patch" "0.11.1": - - patch_file: "patches/0001-remove-contrib.patch" - base_path: "source_subfolder" + - patch_file: "patches/0.11.1-0001-remove-contrib.patch" diff --git a/recipes/highway/all/conanfile.py b/recipes/highway/all/conanfile.py index 3adbb1da1074a..a659244ef92cd 100644 --- a/recipes/highway/all/conanfile.py +++ b/recipes/highway/all/conanfile.py @@ -1,28 +1,31 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir +from conan.tools.scm import Version import os +required_conan_version = ">=1.52.0" + class HighwayConan(ConanFile): name = "highway" description = "Performance-portable, length-agnostic SIMD with runtime " \ "dispatch" + topics = ("highway", "simd") license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/google/highway" - topics = ("highway", "simd") - - settings = "os", "compiler", "build_type", "arch" - options = {"fPIC": [True, False]} - default_options = {"fPIC": True} - - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } @property def _minimum_cpp_standard(self): @@ -31,64 +34,85 @@ def _minimum_cpp_standard(self): @property def _minimum_compilers_version(self): return { - "Visual Studio": "15", + "Visual Studio": "16", + "msvc": "192", "gcc": "8", "clang": "7", } + def export_sources(self): + export_conandata_patches(self) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, self._minimum_cpp_standard) - minimum_version = self._minimum_compilers_version.get( - str(self.settings.compiler)) - if not minimum_version: - self.output.warn( - "{} recipe lacks information about the {} compiler support." - .format(self.name, self.settings.compiler)) - elif tools.Version(self.settings.compiler.version) < minimum_version: + if Version(self.version) < "0.16.0": + del self.options.shared + elif self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + minimum_version = self._minimum_compilers_version.get(str(self.info.settings.compiler)) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: raise ConanInvalidConfiguration( - "{} requires a {} version >= {}" - .format(self.name, self.settings.compiler, - self.settings.compiler.version)) + f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support." + ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.variables["HWY_ENABLE_EXAMPLES"] = False + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + apply_conandata_patches(self) # Honor fPIC option - cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") - tools.replace_in_file(cmakelists, - "set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)", "") - tools.replace_in_file(cmakelists, - "set_property(TARGET hwy PROPERTY " - "POSITION_INDEPENDENT_CODE ON)", "") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure() - return self._cmake + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + replace_in_file(self, cmakelists, "set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)", "") + replace_in_file(self, cmakelists, + "set_property(TARGET hwy PROPERTY POSITION_INDEPENDENT_CODE ON)", + "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["pkg_config"] = "libhwy" - self.cpp_info.libs = ["hwy"] + self.cpp_info.components["hwy"].set_property("pkg_config_name", "libhwy") + self.cpp_info.components["hwy"].libs = ["hwy"] + if Version(self.version) >= "0.16.0": + self.cpp_info.components["hwy"].defines.append( + "HWY_SHARED_DEFINE" if self.options.shared else "HWY_STATIC_DEFINE" + ) + if Version(self.version) >= "0.12.1": + self.cpp_info.components["hwy_contrib"].set_property("pkg_config_name", "libhwy-contrib") + self.cpp_info.components["hwy_contrib"].libs = ["hwy_contrib"] + self.cpp_info.components["hwy_contrib"].requires = ["hwy"] + if Version(self.version) >= "0.15.0": + self.cpp_info.components["hwy_test"].set_property("pkg_config_name", "libhwy-test") + self.cpp_info.components["hwy_test"].libs = ["hwy_test"] + self.cpp_info.components["hwy_test"].requires = ["hwy"] diff --git a/recipes/highway/all/patches/0001-remove-contrib.patch b/recipes/highway/all/patches/0.11.1-0001-remove-contrib.patch similarity index 100% rename from recipes/highway/all/patches/0001-remove-contrib.patch rename to recipes/highway/all/patches/0.11.1-0001-remove-contrib.patch diff --git a/recipes/highway/all/patches/0.16.0-0001-fix-sys-random-h.patch b/recipes/highway/all/patches/0.16.0-0001-fix-sys-random-h.patch new file mode 100644 index 0000000000000..aee3b37dc1e43 --- /dev/null +++ b/recipes/highway/all/patches/0.16.0-0001-fix-sys-random-h.patch @@ -0,0 +1,50 @@ +diff --git a/hwy/contrib/sort/vqsort.cc b/hwy/contrib/sort/vqsort.cc +index 951a0bd..2009da8 100644 +--- a/hwy/contrib/sort/vqsort.cc ++++ b/hwy/contrib/sort/vqsort.cc +@@ -25,12 +25,43 @@ + // After foreach_target + #include "hwy/contrib/sort/shared-inl.h" + ++// Check if we have sys/random.h. First skip some systems on which the check ++// itself (features.h) might be problematic. ++#if defined(ANDROID) || defined(__ANDROID__) || HWY_ARCH_RVV ++#define VQSORT_GETRANDOM 0 ++#endif ++ ++#if !defined(VQSORT_GETRANDOM) && (defined(linux) || defined(__linux__)) ++#include ++ ++// ---- which libc ++#if defined(__UCLIBC__) ++#define VQSORT_GETRANDOM 1 // added Mar 2015, before uclibc-ng 1.0 ++ ++#elif defined(__GLIBC__) && defined(__GLIBC_PREREQ) ++#if __GLIBC_PREREQ(2, 25) ++#define VQSORT_GETRANDOM 1 ++#else ++#define VQSORT_GETRANDOM 0 ++#endif ++ ++#else ++// Assume MUSL, which has getrandom since 2018. There is no macro to test, see ++// https://www.openwall.com/lists/musl/2013/03/29/13. ++#define VQSORT_GETRANDOM 1 ++ ++#endif // ---- which libc ++#endif // linux ++ ++#if !defined(VQSORT_GETRANDOM) ++#define VQSORT_GETRANDOM 0 ++#endif ++ + // Seed source for SFC generator: 1=getrandom, 2=CryptGenRandom + // (not all Android support the getrandom wrapper) + #ifndef VQSORT_SECURE_SEED + +-#if (defined(linux) || defined(__linux__)) && \ +- !(defined(ANDROID) || defined(__ANDROID__) || HWY_ARCH_RVV) ++#if VQSORT_GETRANDOM + #define VQSORT_SECURE_SEED 1 + #elif defined(_WIN32) || defined(_WIN64) + #define VQSORT_SECURE_SEED 2 diff --git a/recipes/highway/all/test_package/CMakeLists.txt b/recipes/highway/all/test_package/CMakeLists.txt index 33ae887aa6aea..06e1e8678e6bd 100644 --- a/recipes/highway/all/test_package/CMakeLists.txt +++ b/recipes/highway/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(highway REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE highway::highway) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/highway/all/test_package/conanfile.py b/recipes/highway/all/test_package/conanfile.py index bd7165a553cf4..0a6bc68712d90 100644 --- a/recipes/highway/all/test_package/conanfile.py +++ b/recipes/highway/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/highway/all/test_package/test_package.cpp b/recipes/highway/all/test_package/test_package.cpp index 5864366457e13..b86c4bfed366c 100644 --- a/recipes/highway/all/test_package/test_package.cpp +++ b/recipes/highway/all/test_package/test_package.cpp @@ -24,7 +24,11 @@ void test() for (size_t i = 0; i < count; i += Lanes(d)) { const auto x = Load(d, &x_array[i]); +#if HWY_MAJOR == 0 && HWY_MINOR < 14 result += GetLane(SumOfLanes(x)); +#else + result += GetLane(SumOfLanes(d, x)); +#endif } std::cout << "result = " << result << ", expected = " << expected << '\n'; diff --git a/recipes/highway/all/test_v1_package/CMakeLists.txt b/recipes/highway/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/highway/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/highway/all/test_v1_package/conanfile.py b/recipes/highway/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/highway/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/highway/config.yml b/recipes/highway/config.yml index ddffd2420877d..a34a1de737c39 100644 --- a/recipes/highway/config.yml +++ b/recipes/highway/config.yml @@ -1,3 +1,15 @@ versions: + "1.0.2": + folder: all + "1.0.1": + folder: all + "1.0.0": + folder: all + "0.17.0": + folder: all + "0.16.0": + folder: all + "0.12.2": + folder: all "0.11.1": folder: all diff --git a/recipes/hipony-enumerate/all/CMakeLists.txt b/recipes/hipony-enumerate/all/CMakeLists.txt new file mode 100644 index 0000000000000..4beb13671fe5e --- /dev/null +++ b/recipes/hipony-enumerate/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8) +project(cmake_wrapper) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/hipony-enumerate/all/conandata.yml b/recipes/hipony-enumerate/all/conandata.yml new file mode 100644 index 0000000000000..9dd2b532a188d --- /dev/null +++ b/recipes/hipony-enumerate/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "2.4.1": + url: "https://github.com/hipony/enumerate/archive/v2.4.1.tar.gz" + sha256: "a071f6014711dcd09e752cd042651d96f2917925ff743208064ebd0d6bdc4e55" + "2.4.0": + url: "https://github.com/hipony/enumerate/archive/v2.4.0.tar.gz" + sha256: "21ee64fc3b1fda25356df0ee0e0292b529bb9b99931ee2b388222d2f498d7a45" + "2.2.1": + url: "https://github.com/hipony/enumerate/archive/refs/tags/v2.2.1.zip" + sha256: "0b6e208007fc0cdffe7f23686faddf5c2bc06f6794bacf2e612197e1e54140e7" diff --git a/recipes/hipony-enumerate/all/conanfile.py b/recipes/hipony-enumerate/all/conanfile.py new file mode 100644 index 0000000000000..d007bd9aa0946 --- /dev/null +++ b/recipes/hipony-enumerate/all/conanfile.py @@ -0,0 +1,116 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.43.0" + + +class HiponyEnumerateConan(ConanFile): + name = "hipony-enumerate" + license = "BSL-1.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/hipony/enumerate" + description = "C++11 compatible version of enumerate" + topics = ("enumerate", "header-only", "cpp", + "constexpr", "cpp17", "cpp11", "tuples") + + settings = "os", "arch", "compiler", "build_type" + options = { + "aggregates": [True, False], + } + default_options = { + "aggregates": False, + } + + generators = "cmake", "cmake_find_package_multi" + no_copy_source = True + exports_sources = ["CMakeLists.txt"] + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8" if self.options.aggregates else "6", + "Visual Studio": "16" if self.options.aggregates else "14", + "clang": "5.0" if self.options.aggregates else "3.9", + "apple-clang": "10", + } + + @property + def _minimum_standard(self): + return "17" if self.options.aggregates else "11" + + def requirements(self): + if self.options.aggregates: + self.requires("pfr/2.0.3") + + def package_id(self): + self.info.header_only() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd( + self, self._minimum_standard) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get( + str(self.settings.compiler), False) + if not minimum_version: + self.output.warn( + "{0} {1} requires C++{2}. Your compiler is unknown. Assuming it supports C++{2}." + .format(self.name, self.version, self._minimum_standard)) + elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + "{} {} requires C++{}, which your compiler does not support." + .format(self.name, self.version, self._minimum_standard)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_TESTING"] = "OFF" + cmake.definitions["HIPONY_ENUMERATE_AGGREGATES_ENABLED"] = self.options.aggregates + cmake.configure() + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "hipony-enumerate") + self.cpp_info.set_property("cmake_target_name", "hipony::enumerate") + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + if self.options.aggregates: + self.cpp_info.components["enumerate"].defines.append( + "HIPONY_ENUMERATE_AGGREGATES_ENABLED") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "hipony-enumerate" + self.cpp_info.filenames["cmake_find_package_multi"] = "hipony-enumerate" + self.cpp_info.names["cmake_find_package"] = "hipony" + self.cpp_info.names["cmake_find_package_multi"] = "hipony" + self.cpp_info.components["enumerate"].names["cmake_find_package"] = "enumerate" + self.cpp_info.components["enumerate"].names["cmake_find_package_multi"] = "enumerate" + self.cpp_info.components["enumerate"].set_property("cmake_target_name", "hipony::enumerate") + if self.options.aggregates: + self.cpp_info.components["enumerate"].requires.append("pfr::pfr") diff --git a/recipes/hipony-enumerate/all/test_package/CMakeLists.txt b/recipes/hipony-enumerate/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a77fd26125266 --- /dev/null +++ b/recipes/hipony-enumerate/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(hipony-enumerate REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE hipony::enumerate) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/hipony-enumerate/all/test_package/conanfile.py b/recipes/hipony-enumerate/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/hipony-enumerate/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hipony-enumerate/all/test_package/test_package.cpp b/recipes/hipony-enumerate/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f4232aad68348 --- /dev/null +++ b/recipes/hipony-enumerate/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include + +#include +#include + +int main() { + std::array array{0, 1, 2, 3, 4, 5}; + for (auto &&item : hipony::enumerate(array)) { + std::cout << item.index << ' ' << item.value << '\n'; + } +} diff --git a/recipes/hipony-enumerate/config.yml b/recipes/hipony-enumerate/config.yml new file mode 100644 index 0000000000000..5ccb72ceb5aff --- /dev/null +++ b/recipes/hipony-enumerate/config.yml @@ -0,0 +1,7 @@ +versions: + "2.4.1": + folder: "all" + "2.4.0": + folder: "all" + "2.2.1": + folder: "all" diff --git a/recipes/hiredis/0.14.1/conandata.yml b/recipes/hiredis/0.14.1/conandata.yml deleted file mode 100644 index c2a412b9486c1..0000000000000 --- a/recipes/hiredis/0.14.1/conandata.yml +++ /dev/null @@ -1,4 +0,0 @@ -sources: - "0.14.1": - sha256: 2663b2aed9fd430507e30fc5e63274ee40cdd1a296026e22eafd7d99b01c8913 - url: https://github.com/redis/hiredis/archive/v0.14.1.tar.gz diff --git a/recipes/hiredis/0.14.1/conanfile.py b/recipes/hiredis/0.14.1/conanfile.py deleted file mode 100644 index 5ef9108c1b3d4..0000000000000 --- a/recipes/hiredis/0.14.1/conanfile.py +++ /dev/null @@ -1,81 +0,0 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration - -import os - - -class HiredisConan(ConanFile): - name = "hiredis" - version = "0.14.1" - - description = "Minimalistic C client for Redis >= 1.2" - topics = ("conan", "c", "redis") - - license = "BSD-3-Clause" - settings = "os", "arch", "compiler", "build_type" - - homepage = "https://github.com/redis/hiredis" - url = "https://github.com/conan-io/conan-center-index" - - options = { - "fPIC": [True, False], - "shared": [True, False] - } - default_options = { - "fPIC": True, - "shared": False - } - - def _configure_autotools(self): - autoTools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - return autoTools - - @property - def _source_subfolder(self): - return "source_subfolder" - - def configure(self): - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx - - if self.settings.os == "Windows": - raise ConanInvalidConfiguration("hiredis %s is not supported on Windows." % self.version) - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = self.name + "-" + self.version - os.rename(extracted_folder, self._source_subfolder) - - def build(self): - # update makefile - makefile = os.path.join(self.source_folder, self._source_subfolder, "Makefile") - tools.replace_in_file(makefile, "-fPIC ", "", strict=False) - - with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)): - autoTools = self._configure_autotools() - autoTools.make() - - def package(self): - with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)): - autoTools = self._configure_autotools() - autoTools.install(vars={ - "DESTDIR": os.path.join(self.build_folder), - "PREFIX": "" - }) - - # headers - self.copy("*.h", dst=os.path.join("include", "hiredis"), src=os.path.join("include", "hiredis")) - - # libs - if self.options.shared: - self.copy("*.dylib", dst="lib", keep_path=False) - self.copy("*.so", dst="lib", keep_path=False) - self.copy("*.so.*", dst="lib", keep_path=False) - else: - self.copy("*.a", dst="lib", keep_path=False) - - # licenses - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - - def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/hiredis/0.14.1/test_package/CMakeLists.txt b/recipes/hiredis/0.14.1/test_package/CMakeLists.txt deleted file mode 100644 index b2390d8130af1..0000000000000 --- a/recipes/hiredis/0.14.1/test_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/hiredis/0.14.1/test_package/conanfile.py b/recipes/hiredis/0.14.1/test_package/conanfile.py deleted file mode 100644 index e0a12f24d4918..0000000000000 --- a/recipes/hiredis/0.14.1/test_package/conanfile.py +++ /dev/null @@ -1,17 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestHiredisConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) diff --git a/recipes/hiredis/0.14.1/test_package/src/main.cpp b/recipes/hiredis/0.14.1/test_package/src/main.cpp deleted file mode 100644 index 9f23a03230145..0000000000000 --- a/recipes/hiredis/0.14.1/test_package/src/main.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -#include - -int main() -{ - std::cout << "hiredis version: " << HIREDIS_MAJOR << "." - << HIREDIS_MINOR << "." - << HIREDIS_PATCH << std::endl; - - const char *hostname = "127.0.0.1"; - int port = 6379; - - redisContext *c = redisConnect(hostname, port); - if (c == NULL) - { - printf("Error: Can't allocate redis context\n"); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} diff --git a/recipes/hiredis/0.x.x/conandata.yml b/recipes/hiredis/0.x.x/conandata.yml new file mode 100644 index 0000000000000..0b74d88eff05f --- /dev/null +++ b/recipes/hiredis/0.x.x/conandata.yml @@ -0,0 +1,8 @@ +sources: + "0.14.1": + url: "https://github.com/redis/hiredis/archive/v0.14.1.tar.gz" + sha256: "2663b2aed9fd430507e30fc5e63274ee40cdd1a296026e22eafd7d99b01c8913" +patches: + "0.14.1": + - patch_file: "patches/0001-fix-makefile.patch" + base_path: "source_subfolder" diff --git a/recipes/hiredis/0.x.x/conanfile.py b/recipes/hiredis/0.x.x/conanfile.py new file mode 100644 index 0000000000000..f94cea21a0db9 --- /dev/null +++ b/recipes/hiredis/0.x.x/conanfile.py @@ -0,0 +1,78 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.36.0" + + +class HiredisConan(ConanFile): + name = "hiredis" + description = "Hiredis is a minimalistic C client library for the Redis database." + license = "BSD-3-Clause" + topics = ("hiredis", "redis", "client", "database") + homepage = "https://github.com/redis/hiredis" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("hiredis {} is not supported on Windows.".format(self.version)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + # Do not force PIC if static + if not self.options.shared: + makefile = os.path.join(self._source_subfolder, "Makefile") + tools.replace_in_file(makefile, "-fPIC ", "") + + def build(self): + self._patch_sources() + with tools.chdir(self._source_subfolder): + autoTools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autoTools.make() + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + with tools.chdir(self._source_subfolder): + autoTools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autoTools.install(vars={ + "DESTDIR": tools.unix_path(self.package_folder), + "PREFIX": "", + }) + tools.remove_files_by_mask( + os.path.join(self.package_folder, "lib"), + "*.a" if self.options.shared else "*.[so|dylib]*", + ) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "hiredis") + self.cpp_info.libs = ["hiredis"] diff --git a/recipes/hiredis/0.x.x/patches/0001-fix-makefile.patch b/recipes/hiredis/0.x.x/patches/0001-fix-makefile.patch new file mode 100644 index 0000000000000..52271f0ac9947 --- /dev/null +++ b/recipes/hiredis/0.x.x/patches/0001-fix-makefile.patch @@ -0,0 +1,42 @@ +--- a/Makefile_old ++++ b/Makefile +@@ -38,10 +38,8 @@ export REDIS_TEST_CONFIG + # Fallback to gcc when $CC is not in $PATH. + CC:=$(shell sh -c 'type $${CC%% *} >/dev/null 2>/dev/null && echo $(CC) || echo gcc') + CXX:=$(shell sh -c 'type $${CXX%% *} >/dev/null 2>/dev/null && echo $(CXX) || echo g++') +-OPTIMIZATION?=-O3 + WARNINGS=-Wall -W -Wstrict-prototypes -Wwrite-strings +-DEBUG_FLAGS?= -g -ggdb +-REAL_CFLAGS=$(OPTIMIZATION) -fPIC $(CFLAGS) $(WARNINGS) $(DEBUG_FLAGS) ++REAL_CFLAGS=-fPIC $(CFLAGS) $(WARNINGS) + REAL_LDFLAGS=$(LDFLAGS) + + DYLIBSUFFIX=so +@@ -49,7 +47,7 @@ STLIBSUFFIX=a + DYLIB_MINOR_NAME=$(LIBNAME).$(DYLIBSUFFIX).$(HIREDIS_SONAME) + DYLIB_MAJOR_NAME=$(LIBNAME).$(DYLIBSUFFIX).$(HIREDIS_MAJOR) + DYLIBNAME=$(LIBNAME).$(DYLIBSUFFIX) +-DYLIB_MAKE_CMD=$(CC) -shared -Wl,-soname,$(DYLIB_MINOR_NAME) -o $(DYLIBNAME) $(LDFLAGS) ++DYLIB_MAKE_CMD=$(CC) -shared -Wl,-soname,$(DYLIB_MINOR_NAME) -o $(DYLIBNAME) $(CFLAGS) $(LDFLAGS) + STLIBNAME=$(LIBNAME).$(STLIBSUFFIX) + STLIB_MAKE_CMD=ar rcs $(STLIBNAME) + +@@ -57,15 +55,15 @@ STLIB_MAKE_CMD=ar rcs $(STLIBNAME) + uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') + ifeq ($(uname_S),SunOS) + REAL_LDFLAGS+= -ldl -lnsl -lsocket +- DYLIB_MAKE_CMD=$(CC) -G -o $(DYLIBNAME) -h $(DYLIB_MINOR_NAME) $(LDFLAGS) ++ DYLIB_MAKE_CMD=$(CC) -G -o $(DYLIBNAME) -h $(DYLIB_MINOR_NAME) $(CFLAGS) $(LDFLAGS) + endif + ifeq ($(uname_S),Darwin) + DYLIBSUFFIX=dylib + DYLIB_MINOR_NAME=$(LIBNAME).$(HIREDIS_SONAME).$(DYLIBSUFFIX) +- DYLIB_MAKE_CMD=$(CC) -dynamiclib -Wl,-install_name,$(PREFIX)/$(LIBRARY_PATH)/$(DYLIB_MINOR_NAME) -o $(DYLIBNAME) $(LDFLAGS) ++ DYLIB_MAKE_CMD=$(CC) -dynamiclib -Wl,-install_name,$(PREFIX)/$(LIBRARY_PATH)/$(DYLIB_MINOR_NAME) -o $(DYLIBNAME) $(CFLAGS) $(LDFLAGS) + endif + +-all: $(DYLIBNAME) $(STLIBNAME) hiredis-test $(PKGCONFNAME) ++all: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME) + + # Deps (use make dep to generate this) + alloc.o: alloc.c fmacros.h alloc.h diff --git a/recipes/hiredis/0.x.x/test_package/CMakeLists.txt b/recipes/hiredis/0.x.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b9b613cbb24a --- /dev/null +++ b/recipes/hiredis/0.x.x/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/hiredis/0.x.x/test_package/conanfile.py b/recipes/hiredis/0.x.x/test_package/conanfile.py new file mode 100644 index 0000000000000..5c09494bc67c0 --- /dev/null +++ b/recipes/hiredis/0.x.x/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hiredis/0.x.x/test_package/test_package.c b/recipes/hiredis/0.x.x/test_package/test_package.c new file mode 100644 index 0000000000000..6df475bd4539a --- /dev/null +++ b/recipes/hiredis/0.x.x/test_package/test_package.c @@ -0,0 +1,21 @@ +#include + +#include +#include + +int main() +{ + printf("hiredis version: %i.%i.%i\n", HIREDIS_MAJOR, HIREDIS_MINOR, HIREDIS_PATCH); + + const char *hostname = "127.0.0.1"; + int port = 6379; + + redisContext *c = redisConnect(hostname, port); + if (c == NULL) + { + printf("Error: Can't allocate redis context\n"); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/recipes/hiredis/all/conandata.yml b/recipes/hiredis/all/conandata.yml index dde520eead76a..2063383701218 100644 --- a/recipes/hiredis/all/conandata.yml +++ b/recipes/hiredis/all/conandata.yml @@ -1,8 +1,29 @@ sources: + "1.1.0": + url: "https://github.com/redis/hiredis/archive/v1.1.0.tar.gz" + sha256: "fe6d21741ec7f3fc9df409d921f47dfc73a4d8ff64f4ac6f1d95f951bf7f53d6" + "1.0.2": + url: "https://github.com/redis/hiredis/archive/v1.0.2.tar.gz" + sha256: "e0ab696e2f07deb4252dda45b703d09854e53b9703c7d52182ce5a22616c3819" "1.0.0": url: "https://github.com/redis/hiredis/archive/v1.0.0.tar.gz" sha256: "2a0b5fe5119ec973a0c1966bfc4bd7ed39dbce1cb6d749064af9121fe971936f" patches: + "1.1.0": + - patch_file: "patches/0001-fix-cmake-1.1.0.patch" + patch_description: "divide static/shared build, fix openssl link name" + patch_type: "conan" + - patch_file: "patches/0002-fix-aix.patch" + patch_description: "support AIX build" + patch_type: "portability" + "1.0.2": + - patch_file: "patches/0001-fix-cmake-1.0.0.patch" + patch_description: "enable static/shared build, fix openssl link name" + patch_type: "conan" + - patch_file: "patches/0002-fix-aix.patch" + patch_description: "support AIX build" + patch_type: "portability" "1.0.0": - - base_path: "source_subfolder" - patch_file: "patches/fix-cmake.patch" + - patch_file: "patches/0001-fix-cmake-1.0.0.patch" + patch_description: "enable static/shared build, fix openssl link name" + patch_type: "conan" diff --git a/recipes/hiredis/all/conanfile.py b/recipes/hiredis/all/conanfile.py index e0ec1ef7882a2..40c8d8d1f2a2e 100644 --- a/recipes/hiredis/all/conanfile.py +++ b/recipes/hiredis/all/conanfile.py @@ -1,37 +1,35 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, replace_in_file +from conan.tools.scm import Version +from conan.tools.microsoft import is_msvc import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.52.0" class HiredisConan(ConanFile): name = "hiredis" description = "Hiredis is a minimalistic C client library for the Redis database." license = "BSD-3-Clause" - topics = ("conan", "hiredis", "redis", "client", "database") + topics = ("hiredis", "redis", "client", "database") homepage = "https://github.com/redis/hiredis" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "with_ssl": [True, False] + "with_ssl": [True, False], } default_options = { "shared": False, "fPIC": True, - "with_ssl": False + "with_ssl": False, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -39,55 +37,87 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): if self.options.with_ssl: - self.requires("openssl/1.1.1g") + self.requires("openssl/1.1.1s") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_SSL"] = self.options.with_ssl + tc.variables["DISABLE_TESTS"] = True + tc.variables["ENABLE_EXAMPLES"] = False + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_SSL"] = self.options.with_ssl - self._cmake.definitions["DISABLE_TESTS"] = True - self._cmake.definitions["ENABLE_EXAMPLES"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "build")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "hiredis") + + suffix = "" + if Version(self.version) >= "1.1.0": + if is_msvc(self) and not self.options.shared: + suffix += "_static" + if self.info.settings.build_type == "Debug": + suffix += "d" + # hiredis + self.cpp_info.components["hiredislib"].set_property("cmake_target_name", "hiredis::hiredis") + self.cpp_info.components["hiredislib"].set_property("pkg_config_name", "hiredis") self.cpp_info.components["hiredislib"].names["cmake_find_package"] = "hiredis" self.cpp_info.components["hiredislib"].names["cmake_find_package_multi"] = "hiredis" - self.cpp_info.components["hiredislib"].names["pkg_config"] = "hiredis" - self.cpp_info.components["hiredislib"].libs = ["hiredis"] + self.cpp_info.components["hiredislib"].libs = [f"hiredis{suffix}"] if self.settings.os == "Windows": self.cpp_info.components["hiredislib"].system_libs = ["ws2_32"] # hiredis_ssl if self.options.with_ssl: + self.cpp_info.components["hiredis_ssl"].set_property("cmake_target_name", "hiredis::hiredis_ssl") + self.cpp_info.components["hiredis_ssl"].set_property("pkg_config_name", "hiredis_ssl") self.cpp_info.components["hiredis_ssl"].names["cmake_find_package"] = "hiredis_ssl" self.cpp_info.components["hiredis_ssl"].names["cmake_find_package_multi"] = "hiredis_ssl" - self.cpp_info.components["hiredis_ssl"].names["pkg_config"] = "hiredis_ssl" - self.cpp_info.components["hiredis_ssl"].libs = ["hiredis_ssl"] + self.cpp_info.components["hiredis_ssl"].libs = [f"hiredis_ssl{suffix}"] self.cpp_info.components["hiredis_ssl"].requires = ["openssl::ssl"] if self.settings.os == "Windows": self.cpp_info.components["hiredis_ssl"].requires.append("hiredislib") + + # These cmake_target_name and pkg_config_name are unofficial. It avoids conflicts + # in conan generators between global target/pkg-config and hiredislib component. + # TODO: eventually remove the cmake_target_name trick if conan can implement smarter logic + # in CMakeDeps when a downstream recipe requires another recipe globally + # (link to all components directly instead of global target) + self.cpp_info.set_property("cmake_target_name", "hiredis::hiredis_all_unofficial") + self.cpp_info.set_property("pkg_config_name", "hiredis_all_unofficial") diff --git a/recipes/hiredis/all/patches/0001-fix-cmake-1.0.0.patch b/recipes/hiredis/all/patches/0001-fix-cmake-1.0.0.patch new file mode 100644 index 0000000000000..630a4c0250233 --- /dev/null +++ b/recipes/hiredis/all/patches/0001-fix-cmake-1.0.0.patch @@ -0,0 +1,40 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,6 +1,6 @@ +-CMAKE_MINIMUM_REQUIRED(VERSION 3.4.0) +-INCLUDE(GNUInstallDirs) ++CMAKE_MINIMUM_REQUIRED(VERSION 3.8) + PROJECT(hiredis) ++INCLUDE(GNUInstallDirs) + + OPTION(ENABLE_SSL "Build hiredis_ssl for SSL support" OFF) + OPTION(DISABLE_TESTS "If tests should be compiled or not" OFF) +@@ -40,7 +40,8 @@ IF(WIN32) + ADD_COMPILE_DEFINITIONS(_CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN) + ENDIF() + +-ADD_LIBRARY(hiredis SHARED ${hiredis_sources}) ++ADD_LIBRARY(hiredis ${hiredis_sources}) ++target_compile_features(hiredis PUBLIC c_std_99) + + SET_TARGET_PROPERTIES(hiredis + PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE +@@ -97,7 +98,7 @@ IF(ENABLE_SSL) + FIND_PACKAGE(OpenSSL REQUIRED) + SET(hiredis_ssl_sources + ssl.c) +- ADD_LIBRARY(hiredis_ssl SHARED ++ ADD_LIBRARY(hiredis_ssl + ${hiredis_ssl_sources}) + + IF (APPLE) +@@ -109,8 +110,7 @@ IF(ENABLE_SSL) + WINDOWS_EXPORT_ALL_SYMBOLS TRUE + VERSION "${HIREDIS_SONAME}") + +- TARGET_INCLUDE_DIRECTORIES(hiredis_ssl PRIVATE "${OPENSSL_INCLUDE_DIR}") +- TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE ${OPENSSL_LIBRARIES}) ++ TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE OpenSSL::SSL) + IF (WIN32 OR MINGW) + TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE hiredis) + ENDIF() diff --git a/recipes/hiredis/all/patches/0001-fix-cmake-1.1.0.patch b/recipes/hiredis/all/patches/0001-fix-cmake-1.1.0.patch new file mode 100644 index 0000000000000..02e57dfa04bfa --- /dev/null +++ b/recipes/hiredis/all/patches/0001-fix-cmake-1.1.0.patch @@ -0,0 +1,219 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3d52d0c..59f9e7a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,9 +1,5 @@ + CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0) + +-OPTION(ENABLE_SSL "Build hiredis_ssl for SSL support" OFF) +-OPTION(DISABLE_TESTS "If tests should be compiled or not" OFF) +-OPTION(ENABLE_SSL_TESTS "Should we test SSL connections" OFF) +-OPTION(ENABLE_ASYNC_TESTS "Should we run all asynchronous API tests" OFF) + + MACRO(getVersionBit name) + SET(VERSION_REGEX "^#define ${name} (.+)$") +@@ -22,6 +18,11 @@ MESSAGE("Detected version: ${VERSION}") + PROJECT(hiredis LANGUAGES "C" VERSION "${VERSION}") + INCLUDE(GNUInstallDirs) + ++OPTION(ENABLE_SSL "Build hiredis_ssl for SSL support" OFF) ++OPTION(DISABLE_TESTS "If tests should be compiled or not" OFF) ++OPTION(ENABLE_SSL_TESTS "Should we test SSL connections" OFF) ++OPTION(ENABLE_ASYNC_TESTS "Should we run all asynchronous API tests" OFF) ++ + # Hiredis requires C99 + SET(CMAKE_C_STANDARD 99) + SET(CMAKE_POSITION_INDEPENDENT_CODE ON) +@@ -44,36 +45,45 @@ IF(WIN32) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN) + ENDIF() + +-ADD_LIBRARY(hiredis SHARED ${hiredis_sources}) +-ADD_LIBRARY(hiredis_static STATIC ${hiredis_sources}) +-ADD_LIBRARY(hiredis::hiredis ALIAS hiredis) +-ADD_LIBRARY(hiredis::hiredis_static ALIAS hiredis_static) ++if(BUILD_SHARED_LIBS) ++ ADD_LIBRARY(hiredis SHARED ${hiredis_sources}) ++ ADD_LIBRARY(hiredis::hiredis ALIAS hiredis) ++ SET_TARGET_PROPERTIES(hiredis ++ PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE ++ VERSION "${HIREDIS_SONAME}") + +-IF(NOT MSVC) +- SET_TARGET_PROPERTIES(hiredis_static +- PROPERTIES OUTPUT_NAME hiredis) +-ENDIF() ++ IF(WIN32 OR MINGW) ++ TARGET_LINK_LIBRARIES(hiredis PUBLIC ws2_32 crypt32) ++ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") ++ TARGET_LINK_LIBRARIES(hiredis PUBLIC m) ++ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS") ++ TARGET_LINK_LIBRARIES(hiredis PUBLIC socket) ++ ENDIF() + +-SET_TARGET_PROPERTIES(hiredis +- PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE +- VERSION "${HIREDIS_SONAME}") +-IF(MSVC) +- SET_TARGET_PROPERTIES(hiredis_static +- PROPERTIES COMPILE_FLAGS /Z7) +-ENDIF() +-IF(WIN32 OR MINGW) +- TARGET_LINK_LIBRARIES(hiredis PUBLIC ws2_32 crypt32) +- TARGET_LINK_LIBRARIES(hiredis_static PUBLIC ws2_32 crypt32) +-ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") +- TARGET_LINK_LIBRARIES(hiredis PUBLIC m) +- TARGET_LINK_LIBRARIES(hiredis_static PUBLIC m) +-ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS") +- TARGET_LINK_LIBRARIES(hiredis PUBLIC socket) +- TARGET_LINK_LIBRARIES(hiredis_static PUBLIC socket) +-ENDIF() ++ TARGET_INCLUDE_DIRECTORIES(hiredis PUBLIC $ $) ++else() ++ ADD_LIBRARY(hiredis_static STATIC ${hiredis_sources}) ++ ADD_LIBRARY(hiredis::hiredis_static ALIAS hiredis_static) ++ ++ IF(NOT MSVC) ++ SET_TARGET_PROPERTIES(hiredis_static ++ PROPERTIES OUTPUT_NAME hiredis) ++ ENDIF() ++ IF(MSVC) ++ SET_TARGET_PROPERTIES(hiredis_static ++ PROPERTIES COMPILE_FLAGS /Z7) ++ ENDIF() + +-TARGET_INCLUDE_DIRECTORIES(hiredis PUBLIC $ $) +-TARGET_INCLUDE_DIRECTORIES(hiredis_static PUBLIC $ $) ++ IF(WIN32 OR MINGW) ++ TARGET_LINK_LIBRARIES(hiredis_static PUBLIC ws2_32 crypt32) ++ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") ++ TARGET_LINK_LIBRARIES(hiredis_static PUBLIC m) ++ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS") ++ TARGET_LINK_LIBRARIES(hiredis_static PUBLIC socket) ++ ENDIF() ++ ++ TARGET_INCLUDE_DIRECTORIES(hiredis_static PUBLIC $ $) ++endif() + + CONFIGURE_FILE(hiredis.pc.in hiredis.pc @ONLY) + +@@ -103,13 +113,21 @@ set(CPACK_RPM_PACKAGE_AUTOREQPROV ON) + + include(CPack) + +-INSTALL(TARGETS hiredis hiredis_static +- EXPORT hiredis-targets +- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++if(BUILD_SHARED_LIBS) ++ INSTALL(TARGETS hiredis ++ EXPORT hiredis-targets ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++else() ++ INSTALL(TARGETS hiredis_static ++ EXPORT hiredis-targets ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++endif() + +-if (MSVC) ++if (0) + INSTALL(FILES $ + DESTINATION ${CMAKE_INSTALL_BINDIR} + CONFIGURATIONS Debug RelWithDebInfo) +@@ -161,45 +179,57 @@ IF(ENABLE_SSL) + FIND_PACKAGE(OpenSSL REQUIRED) + SET(hiredis_ssl_sources + ssl.c) +- ADD_LIBRARY(hiredis_ssl SHARED +- ${hiredis_ssl_sources}) +- ADD_LIBRARY(hiredis_ssl_static STATIC +- ${hiredis_ssl_sources}) +- IF(NOT MSVC) +- SET_TARGET_PROPERTIES(hiredis_ssl_static +- PROPERTIES OUTPUT_NAME hiredis_ssl) +- ENDIF() +- +- IF (APPLE) +- SET_PROPERTY(TARGET hiredis_ssl PROPERTY LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup") +- ENDIF() + +- SET_TARGET_PROPERTIES(hiredis_ssl +- PROPERTIES +- WINDOWS_EXPORT_ALL_SYMBOLS TRUE +- VERSION "${HIREDIS_SONAME}") +- IF(MSVC) +- SET_TARGET_PROPERTIES(hiredis_ssl_static +- PROPERTIES COMPILE_FLAGS /Z7) +- ENDIF() +- +- TARGET_INCLUDE_DIRECTORIES(hiredis_ssl PRIVATE "${OPENSSL_INCLUDE_DIR}") +- TARGET_INCLUDE_DIRECTORIES(hiredis_ssl_static PRIVATE "${OPENSSL_INCLUDE_DIR}") ++ if(BUILD_SHARED_LIBS) ++ ADD_LIBRARY(hiredis_ssl SHARED ++ ${hiredis_ssl_sources}) ++ IF (APPLE) ++ SET_PROPERTY(TARGET hiredis_ssl PROPERTY LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup") ++ ENDIF() ++ SET_TARGET_PROPERTIES(hiredis_ssl ++ PROPERTIES ++ WINDOWS_EXPORT_ALL_SYMBOLS TRUE ++ VERSION "${HIREDIS_SONAME}") ++ TARGET_INCLUDE_DIRECTORIES(hiredis_ssl PRIVATE "${OPENSSL_INCLUDE_DIR}") ++ TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE OpenSSL::SSL) ++ ++ IF (WIN32 OR MINGW) ++ TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE hiredis) ++ ENDIF() ++ else() ++ ADD_LIBRARY(hiredis_ssl_static STATIC ++ ${hiredis_ssl_sources}) ++ IF(NOT MSVC) ++ SET_TARGET_PROPERTIES(hiredis_ssl_static ++ PROPERTIES OUTPUT_NAME hiredis_ssl) ++ ENDIF() ++ IF(MSVC) ++ SET_TARGET_PROPERTIES(hiredis_ssl_static ++ PROPERTIES COMPILE_FLAGS /Z7) ++ ENDIF() ++ TARGET_INCLUDE_DIRECTORIES(hiredis_ssl_static PRIVATE "${OPENSSL_INCLUDE_DIR}") ++ IF (WIN32 OR MINGW) ++ TARGET_LINK_LIBRARIES(hiredis_ssl_static PUBLIC hiredis_static) ++ ENDIF() ++ endif() + +- TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE ${OPENSSL_LIBRARIES}) +- IF (WIN32 OR MINGW) +- TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE hiredis) +- TARGET_LINK_LIBRARIES(hiredis_ssl_static PUBLIC hiredis_static) +- ENDIF() + CONFIGURE_FILE(hiredis_ssl.pc.in hiredis_ssl.pc @ONLY) + +- INSTALL(TARGETS hiredis_ssl hiredis_ssl_static +- EXPORT hiredis_ssl-targets +- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++ if(BUILD_SHARED_LIBS) ++ INSTALL(TARGETS hiredis_ssl ++ EXPORT hiredis_ssl-targets ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++ else() ++ INSTALL(TARGETS hiredis_ssl_static ++ EXPORT hiredis_ssl-targets ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++ endif() + +- if (MSVC) ++ if (0) + INSTALL(FILES $ + DESTINATION ${CMAKE_INSTALL_BINDIR} + CONFIGURATIONS Debug RelWithDebInfo) diff --git a/recipes/hiredis/all/patches/0002-fix-aix.patch b/recipes/hiredis/all/patches/0002-fix-aix.patch new file mode 100644 index 0000000000000..7aa6522eebdf3 --- /dev/null +++ b/recipes/hiredis/all/patches/0002-fix-aix.patch @@ -0,0 +1,15 @@ +diff --git a/fmacros.h b/fmacros.h +index 3227faa..754a53c 100644 +--- a/fmacros.h ++++ b/fmacros.h +@@ -1,8 +1,10 @@ + #ifndef __HIREDIS_FMACRO_H + #define __HIREDIS_FMACRO_H + ++#ifndef _AIX + #define _XOPEN_SOURCE 600 + #define _POSIX_C_SOURCE 200112L ++#endif + + #if defined(__APPLE__) && defined(__MACH__) + /* Enable TCP_KEEPALIVE */ diff --git a/recipes/hiredis/all/patches/fix-cmake.patch b/recipes/hiredis/all/patches/fix-cmake.patch deleted file mode 100644 index 7e792575ef6d4..0000000000000 --- a/recipes/hiredis/all/patches/fix-cmake.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -39,8 +39,8 @@ SET(hiredis_sources ${hiredis_sources}) - IF(WIN32) - ADD_COMPILE_DEFINITIONS(_CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN) - ENDIF() -- --ADD_LIBRARY(hiredis SHARED ${hiredis_sources}) -+SET(CMAKE_C_STANDARD 99) -+ADD_LIBRARY(hiredis ${hiredis_sources}) - - SET_TARGET_PROPERTIES(hiredis - PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE -@@ -97,7 +97,7 @@ IF(ENABLE_SSL) - FIND_PACKAGE(OpenSSL REQUIRED) - SET(hiredis_ssl_sources - ssl.c) -- ADD_LIBRARY(hiredis_ssl SHARED -+ ADD_LIBRARY(hiredis_ssl - ${hiredis_ssl_sources}) - - IF (APPLE) -@@ -109,8 +109,7 @@ IF(ENABLE_SSL) - WINDOWS_EXPORT_ALL_SYMBOLS TRUE - VERSION "${HIREDIS_SONAME}") - -- TARGET_INCLUDE_DIRECTORIES(hiredis_ssl PRIVATE "${OPENSSL_INCLUDE_DIR}") -- TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE ${OPENSSL_LIBRARIES}) -+ TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE OpenSSL::SSL) - IF (WIN32 OR MINGW) - TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE hiredis) - ENDIF() diff --git a/recipes/hiredis/all/test_package/CMakeLists.txt b/recipes/hiredis/all/test_package/CMakeLists.txt index 1012458696f73..49e1f3d74c74e 100644 --- a/recipes/hiredis/all/test_package/CMakeLists.txt +++ b/recipes/hiredis/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C) find_package(hiredis REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} hiredis::hiredis) +target_link_libraries(${PROJECT_NAME} PRIVATE hiredis::hiredis) diff --git a/recipes/hiredis/all/test_package/conanfile.py b/recipes/hiredis/all/test_package/conanfile.py index 84ee68733e516..0a6bc68712d90 100644 --- a/recipes/hiredis/all/test_package/conanfile.py +++ b/recipes/hiredis/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/hiredis/all/test_v1_package/CMakeLists.txt b/recipes/hiredis/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d1ea1807c4774 --- /dev/null +++ b/recipes/hiredis/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(hiredis REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE hiredis::hiredis) diff --git a/recipes/hiredis/all/test_v1_package/conanfile.py b/recipes/hiredis/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/hiredis/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hiredis/config.yml b/recipes/hiredis/config.yml index 690846b4148d3..b06a4f7517eb0 100644 --- a/recipes/hiredis/config.yml +++ b/recipes/hiredis/config.yml @@ -1,5 +1,9 @@ versions: - "0.14.1": - folder: "0.14.1" + "1.1.0": + folder: all + "1.0.2": + folder: all "1.0.0": folder: all + "0.14.1": + folder: "0.x.x" diff --git a/recipes/hlslpp/all/conandata.yml b/recipes/hlslpp/all/conandata.yml index 266b3399b5b2f..9962d3d912437 100644 --- a/recipes/hlslpp/all/conandata.yml +++ b/recipes/hlslpp/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "3.2": + url: "https://github.com/redorav/hlslpp/archive/3.2.tar.gz" + sha256: "23ab0b7f392c518185157e9b1e099eac0a560f4932cebbdf8ccb4a533a0d0336" + "3.1": + url: "https://github.com/redorav/hlslpp/archive/refs/tags/3.1.tar.gz" + sha256: "6f933e43bf8150a41d76a188377e59007897dc87e96be30608e7f2007605d5c4" "3.0": url: "https://github.com/redorav/hlslpp/archive/3.0.tar.gz" sha256: "2ba6d8d3cdfbd0f87d4ede0281a293e872eff8d6390d96d2aab063562072a830" diff --git a/recipes/hlslpp/all/conanfile.py b/recipes/hlslpp/all/conanfile.py index f6c80435571d5..875e16e21920d 100644 --- a/recipes/hlslpp/all/conanfile.py +++ b/recipes/hlslpp/all/conanfile.py @@ -1,32 +1,45 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.50.0" + class HlslppConan(ConanFile): name = "hlslpp" description = "Header-only Math library using hlsl syntax with SSE/NEON support" - topics = ("conan", "hlslpp", "hlsl", "math", "shader", "vector", "matrix", "quaternion") + topics = ("hlslpp", "hlsl", "math", "shader", "vector", "matrix", "quaternion") license = "MIT" homepage = "https://github.com/redorav/hlslpp" url = "https://github.com/conan-io/conan-center-index" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) - def package_id(self): - self.info.header_only() + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/hlslpp/all/test_package/CMakeLists.txt b/recipes/hlslpp/all/test_package/CMakeLists.txt index 33ae887aa6aea..c9f473983b37c 100644 --- a/recipes/hlslpp/all/test_package/CMakeLists.txt +++ b/recipes/hlslpp/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(hlslpp REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE hlslpp::hlslpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/hlslpp/all/test_package/conanfile.py b/recipes/hlslpp/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/hlslpp/all/test_package/conanfile.py +++ b/recipes/hlslpp/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/hlslpp/all/test_v1_package/CMakeLists.txt b/recipes/hlslpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3b23e4e379ffb --- /dev/null +++ b/recipes/hlslpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(hlslpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE hlslpp::hlslpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/hlslpp/all/test_v1_package/conanfile.py b/recipes/hlslpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/hlslpp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hlslpp/config.yml b/recipes/hlslpp/config.yml index 1f125b90dc5d9..b8a3a571e7b7d 100644 --- a/recipes/hlslpp/config.yml +++ b/recipes/hlslpp/config.yml @@ -1,4 +1,8 @@ versions: + "3.2": + folder: all + "3.1": + folder: all "3.0": folder: all "2.0": diff --git a/recipes/homog2d/all/conandata.yml b/recipes/homog2d/all/conandata.yml new file mode 100644 index 0000000000000..9703143edc4f0 --- /dev/null +++ b/recipes/homog2d/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "2.9": + url: "https://github.com/skramm/homog2d/archive/refs/tags/v2.9.tar.gz" + sha256: "7784237154fd0c1beea5b1ed4349e910ce86ad463d21f4f21019f553834c1dad" + +patches: + "2.9": + - patch_file: "patches/0001-include-array.patch" + patch_description: "include array to solve compilation error on appale-clang" + patch_type: "portability" + - patch_file: "patches/0002-pretty_function-for-msvc.patch" + patch_description: "use __FUNCSIG__ instead of __PRETTY_FUNCTION__ on MSVC" + patch_type: "portability" diff --git a/recipes/homog2d/all/conanfile.py b/recipes/homog2d/all/conanfile.py new file mode 100644 index 0000000000000..389de93f97426 --- /dev/null +++ b/recipes/homog2d/all/conanfile.py @@ -0,0 +1,73 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +from conan.tools.microsoft import is_msvc, check_min_vs +import os + + +required_conan_version = ">=1.52.0" + + +class Homog2dConan(ConanFile): + name = "homog2d" + description = "C++ 2D geometry library, handles points, lines, polylines, planar transformations(and other primitives), using homogeneous coordinates." + license = "MPL-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/skramm/homog2d" + topics = ("computational-geometry", "homography", "2d-geometric", "header-only") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _min_cppstd(self): + return 14 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "5", + "clang": "5", + "apple-clang": "5.1", + } + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + check_min_vs(self, 192) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def build(self): + apply_conandata_patches(self) + + def package(self): + copy(self, pattern="LICENCE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy( + self, + pattern="homog2d.hpp", + dst=os.path.join(self.package_folder, "include"), + src=self.source_folder, + ) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/homog2d/all/patches/0001-include-array.patch b/recipes/homog2d/all/patches/0001-include-array.patch new file mode 100644 index 0000000000000..0e50c1abf4225 --- /dev/null +++ b/recipes/homog2d/all/patches/0001-include-array.patch @@ -0,0 +1,12 @@ +diff --git a/homog2d.hpp b/homog2d.hpp +index 64191fb..f30d150 100644 +--- a/homog2d.hpp ++++ b/homog2d.hpp +@@ -30,6 +30,7 @@ See https://github.com/skramm/homog2d + #include + #include + #include ++#include + #include + #include + #include diff --git a/recipes/homog2d/all/patches/0002-pretty_function-for-msvc.patch b/recipes/homog2d/all/patches/0002-pretty_function-for-msvc.patch new file mode 100644 index 0000000000000..ea9cad9d77946 --- /dev/null +++ b/recipes/homog2d/all/patches/0002-pretty_function-for-msvc.patch @@ -0,0 +1,45 @@ +diff --git a/homog2d.hpp b/homog2d.hpp +index f30d150..68bc280 100644 +--- a/homog2d.hpp ++++ b/homog2d.hpp +@@ -115,12 +115,18 @@ See https://github.com/skramm/homog2d + #define HOMOG2D_BIND_Y y + #endif + ++#ifdef _MSC_VER ++ #define HOMOG2D_PRETTY_FUNCTION __FUNCSIG__ ++#else ++ #define HOMOG2D_PRETTY_FUNCTION __PRETTY_FUNCTION__ ++#endif ++ + /// Error throw wrapper macro + #define HOMOG2D_THROW_ERROR_1( msg ) \ + { \ + std::ostringstream oss; \ + oss << "homog2d: line " << __LINE__ << ", function:" << __FUNCTION__ << "(): " \ +- << msg << "\n -full function name: " << __PRETTY_FUNCTION__ \ ++ << msg << "\n -full function name: " << HOMOG2D_PRETTY_FUNCTION \ + << "\n -Error count=" << ++errorCount(); \ + throw std::runtime_error( oss.str() ); \ + } +@@ -130,7 +136,7 @@ See https://github.com/skramm/homog2d + { \ + std::ostringstream oss; \ + oss << "homog2d: line " << __LINE__ << ", function:" << func << "(): " \ +- << msg << "\n -full function name: " << __PRETTY_FUNCTION__ \ ++ << msg << "\n -full function name: " << HOMOG2D_PRETTY_FUNCTION \ + << "\n -Error count=" << ++errorCount(); \ + throw std::runtime_error( oss.str() ); \ + } +@@ -2914,11 +2920,6 @@ private: + h2d::operator * ( const h2d::Point2d_&, const h2d::Point2d_& ) + -> h2d::Line2d_; + +- template +- friend auto +- h2d::operator * ( const h2d::Homogr_&, const h2d::Line2d_& ) +- -> h2d::Line2d_; +- + template + friend base::LPBase + detail::crossProduct( const base::LPBase&, const base::LPBase& ); diff --git a/recipes/homog2d/all/test_package/CMakeLists.txt b/recipes/homog2d/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5abd7206722e3 --- /dev/null +++ b/recipes/homog2d/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(homog2d REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE homog2d::homog2d) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/homog2d/all/test_package/conanfile.py b/recipes/homog2d/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e845ae751a301 --- /dev/null +++ b/recipes/homog2d/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/homog2d/all/test_package/test_package.cpp b/recipes/homog2d/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..bb7225471a2b4 --- /dev/null +++ b/recipes/homog2d/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include + +#include "homog2d.hpp" +using namespace h2d; + +int main() { + Line2d l1( Point2d(10,10) ); // a line passing through (0,0) and (10,10) + Line2d l2( Point2d(0,10), Point2d(10,0) ); // a line passing through (0,10) and (10,0) + auto pt = l1 * l2; // intersection point (5,5) + Homogr H(2,3); // a translation matrix + std::cout << H * pt; // prints [7,8] + + return 0; +} diff --git a/recipes/homog2d/all/test_v1_package/CMakeLists.txt b/recipes/homog2d/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..be00a8c7f57c7 --- /dev/null +++ b/recipes/homog2d/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/homog2d/all/test_v1_package/conanfile.py b/recipes/homog2d/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/homog2d/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/homog2d/config.yml b/recipes/homog2d/config.yml new file mode 100644 index 0000000000000..15e714af2f48e --- /dev/null +++ b/recipes/homog2d/config.yml @@ -0,0 +1,3 @@ +versions: + "2.9": + folder: all diff --git a/recipes/http_parser/all/CMakeLists.txt b/recipes/http_parser/all/CMakeLists.txt index 2384ebe2656f0..d38794fd0cf94 100644 --- a/recipes/http_parser/all/CMakeLists.txt +++ b/recipes/http_parser/all/CMakeLists.txt @@ -1,18 +1,15 @@ cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper LANGUAGES C) +project(http_parser LANGUAGES C) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +include(GNUInstallDirs) -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - -add_library(http_parser - source_subfolder/http_parser.c) +add_library(http_parser ${HTTP_PARSER_SRC_DIR}/http_parser.c) +set_target_properties(http_parser PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) install(TARGETS http_parser - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES source_subfolder/http_parser.h - DESTINATION include) +install(FILES ${HTTP_PARSER_SRC_DIR}/http_parser.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/http_parser/all/conandata.yml b/recipes/http_parser/all/conandata.yml index b2cc49cdea8e6..463d6f2b2bbfd 100644 --- a/recipes/http_parser/all/conandata.yml +++ b/recipes/http_parser/all/conandata.yml @@ -1,10 +1,10 @@ sources: - "2.9.2": - url: https://github.com/nodejs/http-parser/archive/v2.9.2.tar.gz - sha256: "5199500e352584852c95c13423edc5f0cb329297c81dd69c3c8f52a75496da08" - "2.9.3": - url: https://github.com/nodejs/http-parser/archive/v2.9.3.tar.gz - sha256: "8fa0ab8770fd8425a9b431fdbf91623c4d7a9cdb842b9339289bd2b0b01b0d3d" "2.9.4": - url: https://github.com/nodejs/http-parser/archive/v2.9.4.tar.gz + url: "https://github.com/nodejs/http-parser/archive/v2.9.4.tar.gz" sha256: "467b9e30fd0979ee301065e70f637d525c28193449e1b13fbcb1b1fab3ad224f" + "2.9.3": + url: "https://github.com/nodejs/http-parser/archive/v2.9.3.tar.gz" + sha256: "8fa0ab8770fd8425a9b431fdbf91623c4d7a9cdb842b9339289bd2b0b01b0d3d" + "2.9.2": + url: "https://github.com/nodejs/http-parser/archive/v2.9.2.tar.gz" + sha256: "5199500e352584852c95c13423edc5f0cb329297c81dd69c3c8f52a75496da08" diff --git a/recipes/http_parser/all/conanfile.py b/recipes/http_parser/all/conanfile.py index 565d842898fd4..e764d7f53939c 100644 --- a/recipes/http_parser/all/conanfile.py +++ b/recipes/http_parser/all/conanfile.py @@ -1,17 +1,20 @@ -from conans import ConanFile, tools, CMake +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get import os +required_conan_version = ">=1.46.0" + class HttpParserConan(ConanFile): name = "http_parser" - description = "http request/response parser for c " - topics = ("conan", "http", "parser") + description = "http request/response parser for c" + topics = ("http", "parser") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/nodejs/http-parser" - license = ("MIT",) - exports_sources = "CMakeLists.txt", - generators = "cmake", - settings = "os", "compiler", "build_type", "arch" + license = "MIT" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -20,12 +23,8 @@ class HttpParserConan(ConanFile): "shared": False, "fPIC": True, } - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + exports_sources = "CMakeLists.txt" def config_options(self): if self.settings.os == "Windows": @@ -34,29 +33,35 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass - def _configure_cmake(self): - if self._cmake: - return self._cmake - - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "http-parser-{}".format(self.version) - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["HTTP_PARSER_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy("LICENSE-MIT", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE-MIT", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): diff --git a/recipes/http_parser/all/test_package/CMakeLists.txt b/recipes/http_parser/all/test_package/CMakeLists.txt index 196188113685c..901fc9ff7c382 100644 --- a/recipes/http_parser/all/test_package/CMakeLists.txt +++ b/recipes/http_parser/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(http_parser REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE http_parser::http_parser) diff --git a/recipes/http_parser/all/test_package/conanfile.py b/recipes/http_parser/all/test_package/conanfile.py index bd7165a553cf4..3a8c6c5442b33 100644 --- a/recipes/http_parser/all/test_package/conanfile.py +++ b/recipes/http_parser/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/http_parser/all/test_package/test_package.c b/recipes/http_parser/all/test_package/test_package.c new file mode 100644 index 0000000000000..b1c7b81473f04 --- /dev/null +++ b/recipes/http_parser/all/test_package/test_package.c @@ -0,0 +1,13 @@ +#include + +#include + +int main() +{ + unsigned long version = http_parser_version(); + unsigned major = (version >> 16) & 255; + unsigned minor = (version >> 8) & 255; + unsigned patch = version & 255; + printf("http_parser v%u.%u.%u\n", major, minor, patch); + return 0; +} diff --git a/recipes/http_parser/all/test_package/test_package.cpp b/recipes/http_parser/all/test_package/test_package.cpp deleted file mode 100644 index c8e705180e7b0..0000000000000 --- a/recipes/http_parser/all/test_package/test_package.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "http_parser.h" - -#include - -int main() -{ - unsigned long version = http_parser_version(); - unsigned major = (version >> 16) & 255; - unsigned minor = (version >> 8) & 255; - unsigned patch = version & 255; - printf("http_parser v%u.%u.%u\n", major, minor, patch); - return 0; -} diff --git a/recipes/http_parser/all/test_v1_package/CMakeLists.txt b/recipes/http_parser/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b0c36fbcd127a --- /dev/null +++ b/recipes/http_parser/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(http_parser REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE http_parser::http_parser) diff --git a/recipes/http_parser/all/test_v1_package/conanfile.py b/recipes/http_parser/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/http_parser/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/http_parser/config.yml b/recipes/http_parser/config.yml index b717244ea89f1..9c27cb28da423 100644 --- a/recipes/http_parser/config.yml +++ b/recipes/http_parser/config.yml @@ -1,7 +1,7 @@ versions: - "2.9.2": + "2.9.4": folder: all "2.9.3": folder: all - "2.9.4": + "2.9.2": folder: all diff --git a/recipes/huffman/all/conandata.yml b/recipes/huffman/all/conandata.yml index 1dde7f5fa7d17..25d1ea6cda398 100644 --- a/recipes/huffman/all/conandata.yml +++ b/recipes/huffman/all/conandata.yml @@ -1,4 +1,15 @@ sources: + "1.2.7": + # Don't use tar.gz because test data files in tar.gz has invalid paths on Windows. + url: "https://github.com/drichardson/huffman/archive/refs/tags/v1.2.7.zip" + sha256: "0d382f271daf47623676307710cb05d246839247370989b8ffa6fee82bea375a" "1.2.2": url: "https://github.com/drichardson/huffman/archive/refs/tags/v1.2.2.zip" sha256: "7968728c4a0e2705575e9f03e0252cb5195919756d3a64343255f518548cb533" +patches: + "1.2.7": + - patch_file: "patches/1.2.7-0001-use-_WIN32.patch" + base_path: "source_subfolder" + "1.2.2": + - patch_file: "patches/1.2.2-0001-use-_WIN32.patch" + base_path: "source_subfolder" diff --git a/recipes/huffman/all/conanfile.py b/recipes/huffman/all/conanfile.py index 7c9618e5cd386..6cbfd60d77f27 100644 --- a/recipes/huffman/all/conanfile.py +++ b/recipes/huffman/all/conanfile.py @@ -1,24 +1,27 @@ from conans import ConanFile, CMake, tools -import os +import functools +required_conan_version = ">=1.33.0" class HuffmanConan(ConanFile): name = "huffman" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/drichardson/huffman" description = "huffman encoder/decoder" - topics = ["huffman", "conan"] license = "Unlicense" - settings = "os", "compiler", "arch", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False]} - default_options = {'shared': False, - 'fPIC': True} + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/drichardson/huffman" + topics = ["huffman", "encoder", "decoder", "compression"] + settings = "os", "arch", "compiler","build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + 'shared': False, + 'fPIC': True, + } exports_sources = ["CMakeLists.txt"] generators = "cmake" - _cmake = None - @property def _source_subfolder(self): return "source_subfolder" @@ -27,25 +30,30 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd if self.options.shared: del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "huffman-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + cmake = CMake(self) + cmake.configure() + return cmake def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) cmake = self._configure_cmake() cmake.build() diff --git a/recipes/huffman/all/patches/1.2.2-0001-use-_WIN32.patch b/recipes/huffman/all/patches/1.2.2-0001-use-_WIN32.patch new file mode 100644 index 0000000000000..f04952ff087f5 --- /dev/null +++ b/recipes/huffman/all/patches/1.2.2-0001-use-_WIN32.patch @@ -0,0 +1,13 @@ +diff --git a/a/huffman.c b/b/huffman.c +index 81959cb..ecea371 100644 +--- a/a/huffman.c ++++ b/b/huffman.c +@@ -11,7 +11,7 @@ + #include + #include + +-#ifdef WIN32 ++#if defined _WIN32 || defined __CYGWIN__ + #include + #include + #else diff --git a/recipes/huffman/all/patches/1.2.7-0001-use-_WIN32.patch b/recipes/huffman/all/patches/1.2.7-0001-use-_WIN32.patch new file mode 100644 index 0000000000000..9c1fe246e8193 --- /dev/null +++ b/recipes/huffman/all/patches/1.2.7-0001-use-_WIN32.patch @@ -0,0 +1,13 @@ +diff --git a/a/huffman.c b/b/huffman.c +index 7cae8c1..34f3101 100644 +--- a/a/huffman.c ++++ b/b/huffman.c +@@ -6,7 +6,7 @@ + #include + #include + +-#ifdef WIN32 ++#if defined _WIN32 || defined __CYGWIN__ + #include + #include + #else diff --git a/recipes/huffman/all/test_package/CMakeLists.txt b/recipes/huffman/all/test_package/CMakeLists.txt index 9c43a46da45b0..cca65fc1e8c24 100644 --- a/recipes/huffman/all/test_package/CMakeLists.txt +++ b/recipes/huffman/all/test_package/CMakeLists.txt @@ -1,10 +1,11 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +find_package(huffman REQUIRED CONFIG) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} huffman::huffman) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/huffman/all/test_package/conanfile.py b/recipes/huffman/all/test_package/conanfile.py index 1d0bdd3779793..38f4483872d47 100644 --- a/recipes/huffman/all/test_package/conanfile.py +++ b/recipes/huffman/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/huffman/config.yml b/recipes/huffman/config.yml index af40d9653a378..1bf1c0d4bfeb0 100644 --- a/recipes/huffman/config.yml +++ b/recipes/huffman/config.yml @@ -1,3 +1,5 @@ versions: + "1.2.7": + folder: all "1.2.2": folder: all diff --git a/recipes/hunspell/all/CMakeLists.txt b/recipes/hunspell/all/CMakeLists.txt new file mode 100644 index 0000000000000..b2bc98f40adab --- /dev/null +++ b/recipes/hunspell/all/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.1) + +project(hunspell VERSION "${CONAN_hunspell_VERSION}" LANGUAGES CXX) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS KEEP_RPATHS) +set(src src/hunspell) + +# ---- Configure hunvisapi.h ---- + +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-fvisibility=hidden HAVE_VISIBILITY) +configure_file("${src}/hunvisapi.h.in" hunvisapi.h @ONLY) + +# ---- Library target ---- + +add_library( + hunspell + "${src}/affentry.cxx" + "${src}/affixmgr.cxx" + "${src}/csutil.cxx" + "${src}/filemgr.cxx" + "${src}/hashmgr.cxx" + "${src}/hunspell.cxx" + "${src}/hunzip.cxx" + "${src}/phonet.cxx" + "${src}/replist.cxx" + "${src}/suggestmgr.cxx" +) + +if(MSVC) + target_compile_options(hunspell PRIVATE /wd4267 /wd4996) +endif() + +if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(hunspell PRIVATE HUNSPELL_STATIC) +endif() +target_compile_definitions(hunspell PRIVATE BUILDING_LIBHUNSPELL) + +target_include_directories(hunspell PRIVATE "${src}" "${PROJECT_BINARY_DIR}") + +set_target_properties( + hunspell PROPERTIES + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN YES + VERSION "${PROJECT_VERSION}" + SOVERSION "${PROJECT_VERSION_MAJOR}" +) + +# ---- Install ---- + +include(GNUInstallDirs) + +install( + TARGETS hunspell + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +install( + FILES + "${src}/hunspell.hxx" + "${src}/hunspell.h" + "${src}/w_char.hxx" + "${src}/atypes.hxx" + "${PROJECT_BINARY_DIR}/hunvisapi.h" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hunspell" +) diff --git a/recipes/hunspell/all/conandata.yml b/recipes/hunspell/all/conandata.yml new file mode 100644 index 0000000000000..6c8c08bc2e4b0 --- /dev/null +++ b/recipes/hunspell/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.7.0": + sha256: "57be4e03ae9dd62c3471f667a0d81a14513e314d4d92081292b90435944ff951" + url: https://github.com/hunspell/hunspell/files/2573619/hunspell-1.7.0.tar.gz diff --git a/recipes/hunspell/all/conanfile.py b/recipes/hunspell/all/conanfile.py new file mode 100644 index 0000000000000..6c74ea78eaba7 --- /dev/null +++ b/recipes/hunspell/all/conanfile.py @@ -0,0 +1,67 @@ +import functools +import os + +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.43.0" + + +class HunspellConan(ConanFile): + name = "hunspell" + description = ( + "Hunspell is a free spell checker and morphological analyzer library" + ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://hunspell.github.io/" + topics = "spell", "spell-check" + license = "MPL-1.1", "GPL-2.0-or-later", "LGPL-2.1-or-later" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake" + # FIXME: Remove once the pending upstream PR for CMake support is merged + exports_sources = "CMakeLists.txt" + no_copy_source = True + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True) + # NOTE: The source contains a pre-configured hunvisapi.h and it would + # prevent no_copy_source and building without patches. + h = os.path.join(self.source_folder, "src", "hunspell", "hunvisapi.h") + os.remove(h) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["CONAN_hunspell_VERSION"] = self.version + cmake.configure() + return cmake + + def build(self): + self._configure_cmake().build() + + def package(self): + self._configure_cmake().install() + self.copy("COPYING", "licenses") + self.copy("COPYING.LESSER", "licenses") + self.copy("license.hunspell", "licenses") + + def package_info(self): + self.cpp_info.libs = ["hunspell"] + if not self.options.shared: + self.cpp_info.defines = ["HUNSPELL_STATIC"] diff --git a/recipes/hunspell/all/test_package/CMakeLists.txt b/recipes/hunspell/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..73177e055de6d --- /dev/null +++ b/recipes/hunspell/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(hunspell REQUIRED CONFIG) + +add_executable(test_package test_package.cxx) +target_link_libraries(test_package PRIVATE hunspell::hunspell) diff --git a/recipes/hunspell/all/test_package/conanfile.py b/recipes/hunspell/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a8c92dea63335 --- /dev/null +++ b/recipes/hunspell/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hunspell/all/test_package/test_package.cxx b/recipes/hunspell/all/test_package/test_package.cxx new file mode 100644 index 0000000000000..a504023ab95f9 --- /dev/null +++ b/recipes/hunspell/all/test_package/test_package.cxx @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char const* argv[]) +{ + (void)argc; + (void)argv; + + Hunspell_destroy(NULL); + + return 0; +} diff --git a/recipes/hunspell/config.yml b/recipes/hunspell/config.yml new file mode 100644 index 0000000000000..0f57b11de8fb0 --- /dev/null +++ b/recipes/hunspell/config.yml @@ -0,0 +1,3 @@ +versions: + "1.7.0": + folder: all diff --git a/recipes/hyperscan/all/conanfile.py b/recipes/hyperscan/all/conanfile.py index 636bbbf3ce4f5..f3eb36131b29f 100644 --- a/recipes/hyperscan/all/conanfile.py +++ b/recipes/hyperscan/all/conanfile.py @@ -1,7 +1,10 @@ from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.43.0" + class HyperscanConan(ConanFile): name = "hyperscan" license = "BSD-3-Clause" @@ -53,9 +56,15 @@ def build_requirements(self): self.build_requires("ragel/6.10"); def requirements(self): - self.requires("boost/1.75.0"); + self.requires("boost/1.79.0"); if self.options.build_chimera: - self.requires("pcre/8.44") + self.requires("pcre/8.45") + + def validate(self): + tools.check_min_cppstd(self, "11") + + if self.settings.arch not in ["x86", "x86_64"]: + raise ConanInvalidConfiguration("Hyperscan only support x86 architecture") def config_options(self): if self.settings.os == "Windows": @@ -78,8 +87,11 @@ def _configure_cmake(self): return self._cmake def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, "11") + if self.options.shared: + del self.options.fPIC + + if self.options.shared and self.options.build_chimera: + raise ConanInvalidConfiguration("Chimera build requires static building") def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): @@ -95,5 +107,39 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["pkg_config"] = "libhs" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.names["cmake_find_package"] = "hyperscan" + self.cpp_info.names["cmake_find_package_multi"] = "hyperscan" + + self.cpp_info.components["hs"].libs = ["hs"] + self.cpp_info.components["hs"].requires = ["boost::headers"] + self.cpp_info.components["hs"].names["cmake_find_package"] = "hs" + self.cpp_info.components["hs"].names["cmake_find_package_multi"] = "hs" + self.cpp_info.components["hs"].set_property("cmake_target_name", "hyperscan::hs") + self.cpp_info.components["hs"].set_property("pkg_config_name", "libhs") + + + self.cpp_info.components["hs_runtime"].libs = ["hs_runtime"] + self.cpp_info.components["hs_runtime"].names["cmake_find_package"] = "hs_runtime" + self.cpp_info.components["hs_runtime"].names["cmake_find_package_multi"] = "hs_runtime" + self.cpp_info.components["hs_runtime"].set_property("cmake_target_name", "hyperscan::hs_runtime") + self.cpp_info.components["hs_runtime"].set_property("pkg_config_name", "libhs_runtime") + + + if self.options.build_chimera: + self.cpp_info.components["chimera"].libs = ["chimera"] + self.cpp_info.components["chimera"].requires = ["pcre::libpcre", "hs"] + self.cpp_info.components["chimera"].names["cmake_find_package"] = "chimera" + self.cpp_info.components["chimera"].names["cmake_find_package_multi"] = "chimera" + self.cpp_info.components["chimera"].set_property("cmake_target_name", "hyperscan::chimera") + self.cpp_info.components["chimera"].set_property("pkg_config_name", "libchimera") + + + + if not self.options.shared: + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["hs"].system_libs = ["m"] + self.cpp_info.components["hs_runtime"].system_libs = ["m"] + + if self.options.build_chimera: + self.cpp_info.components["chimera"].system_libs = ["m"] + diff --git a/recipes/hyperscan/all/patches/fix-cmake.patch b/recipes/hyperscan/all/patches/fix-cmake.patch index ac38219b91688..0905e34e5bc47 100644 --- a/recipes/hyperscan/all/patches/fix-cmake.patch +++ b/recipes/hyperscan/all/patches/fix-cmake.patch @@ -220,6 +220,73 @@ index 8bc6077..579a7b4 100644 ) endif (BUILD_AVX512VBMI) add_library(hs_exec_common_shared OBJECT +diff --git chimera/CMakeLists.txt chimera/CMakeLists.txt +index 1cd66a3..ebb3b49 100644 +--- chimera/CMakeLists.txt ++++ chimera/CMakeLists.txt +@@ -44,6 +44,6 @@ if (NOT WIN32) + set(PRIVATE_LIBS "${PRIVATE_LIBS} -L${LIBDIR} -lpcre") + + configure_file(libch.pc.in libch.pc @ONLY) # only replace @ quoted vars +- install(FILES ${CMAKE_BINARY_DIR}/chimera/libch.pc ++ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libch.pc + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + endif() +diff --git chimera/ch_database.h chimera/ch_database.h +index 28bde86..d757c82 100644 +--- chimera/ch_database.h ++++ chimera/ch_database.h +@@ -38,7 +38,7 @@ extern "C" + { + #endif + +-#define PCRE_STATIC ++/* #define PCRE_STATIC */ + #include + + #include "ch_compile.h" // for CH_MODE_ flags +diff --git cmake/pcre.cmake cmake/pcre.cmake +index e0acda5..c68601f 100644 +--- cmake/pcre.cmake ++++ cmake/pcre.cmake +@@ -1,4 +1,5 @@ + # first look in pcre-$version or pcre subdirs ++ + if (PCRE_SOURCE) + # either provided on cmdline or we've seen it already + set (PCRE_BUILD_SOURCE TRUE) +@@ -50,14 +51,10 @@ if (PCRE_BUILD_SOURCE) + set(PCRE_INCLUDE_DIRS ${PCRE_SOURCE} ${PROJECT_BINARY_DIR}/pcre) + set(PCRE_LDFLAGS -L"${LIBDIR}" -lpcre) + else () +- # pkgconf should save us +- find_package(PkgConfig) +- pkg_check_modules(PCRE libpcre>=${PCRE_REQUIRED_VERSION}) +- if (PCRE_FOUND) ++ # conan should save us ++ find_package(PCRE) ++ if(PCRE_FOUND AND (PCRE_VERSION VERSION_GREATER_EQUAL PCRE_REQUIRED_VERSION)) + set(CORRECT_PCRE_VERSION TRUE) +- message(STATUS "PCRE version ${PCRE_REQUIRED_VERSION} or above") +- else () +- message(STATUS "PCRE version ${PCRE_REQUIRED_VERSION} or above not found") +- return () +- endif () ++ set(PCRE_LDFLAGS "PCRE::libpcre") ++ endif() + endif (PCRE_BUILD_SOURCE) +diff --git tools/CMakeLists.txt tools/CMakeLists.txt +index 6ca3fd8..378afd0 100644 +--- tools/CMakeLists.txt ++++ tools/CMakeLists.txt +@@ -1,3 +1,7 @@ ++ ++# Tools are not installed ++return () ++ + find_package(Threads) + + # remove some warnings diff --git tools/hsbench/CMakeLists.txt tools/hsbench/CMakeLists.txt index bbceda4..18545d0 100644 --- tools/hsbench/CMakeLists.txt diff --git a/recipes/hyperscan/all/test_package/CMakeLists.txt b/recipes/hyperscan/all/test_package/CMakeLists.txt index 6aab347eddf53..0e579ae32cbad 100644 --- a/recipes/hyperscan/all/test_package/CMakeLists.txt +++ b/recipes/hyperscan/all/test_package/CMakeLists.txt @@ -2,8 +2,15 @@ cmake_minimum_required(VERSION 3.1) project(PackageTest CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(hyperscan COMPONENTS hs REQUIRED) +add_executable(hs_example hs_example.cpp) +target_link_libraries(hs_example PRIVATE hyperscan::hs) + +if(BUILD_CHIMERA) + find_package(hyperscan COMPONENTS chimera REQUIRED) + add_executable(ch_example ch_example.cpp) + target_link_libraries(ch_example PRIVATE hyperscan::chimera) +endif() -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) -set_property(TARGET example PROPERTY CXX_STANDARD 11) diff --git a/recipes/hyperscan/all/test_package/ch_example.cpp b/recipes/hyperscan/all/test_package/ch_example.cpp new file mode 100644 index 0000000000000..7f6eaeecffe55 --- /dev/null +++ b/recipes/hyperscan/all/test_package/ch_example.cpp @@ -0,0 +1,100 @@ +#include +#include +#include +#include +#include "hs/ch.h" + +struct context_t +{ + const char* ref = nullptr; + int match_cnt = 0; + int capture_cnt = 0; +}; + +static int match_handler(unsigned int id, unsigned long long from, unsigned long long to, unsigned int flags, unsigned int size, const ch_capture_t *captured, void *context) +{ + std::printf("Found match %u from %llu to %llu\n", id, from, to); + if(size==2) + { + std::printf("Found capture from %llu to %llu\n", captured[1].from, captured[1].to); + if(captured[1].from == 6 && captured[1].to == 9) + { + ((context_t*)context)->capture_cnt++; + } + } + ((context_t*)context)->match_cnt++; + ++(*((int*)context)); + return 0; +} + + +static std::tuple, std::shared_ptr, ch_error_t> compile(const char* pattern) +{ + ch_compile_error_t* err = nullptr; + ch_database_t* db = nullptr; + + const auto result = ch_compile(pattern, 0, CH_MODE_GROUPS, nullptr, &db, &err); + + return std::tuple, std::shared_ptr, ch_error_t>( + std::shared_ptr(db, ch_free_database), + std::shared_ptr(err, ch_free_compile_error), + result + ); +} + +static std::pair, ch_error_t> alloc_scratch(ch_database_t& db) +{ + ch_scratch_t* scratch = nullptr; + + const auto result = ch_alloc_scratch(&db, &scratch); + + return std::pair, ch_error_t>( + std::shared_ptr(scratch, ch_free_scratch), + result + ); +} + +static ch_error_t scan(ch_database_t& db, ch_scratch_t& scratch, const char* data, ch_match_event_handler handler, void* context) +{ + const auto len = std::strlen(data); + return ch_scan(&db, data, len, 0, &scratch, match_handler, nullptr, context); +} + +int main(int argc, char **argv) +{ + printf("%s\n", ch_version()); + + context_t ctx; + ctx.ref = "123abcdefghijkl"; + std::shared_ptr err; + std::shared_ptr db; + + ch_error_t result; + + std::tie(db, err, result) = compile("abc(\\w+)ghi"); + + if (result != CH_SUCCESS) { + std::printf("Failed to compile database\n"); + std::printf("%s\n", err->message); + } + else + { + std::shared_ptr scratch; + + std::tie(scratch, result) = alloc_scratch(*db); + if (result != CH_SUCCESS) { + std::printf("Failed to allocate scratch space\n"); + } + else + { + if(scan(*db, *scratch, ctx.ref, &match_handler, &ctx) == CH_SUCCESS) + { + if (ctx.match_cnt == 1 && ctx.capture_cnt == 1) { + return 0; + } + } + } + } + + return -1; +} diff --git a/recipes/hyperscan/all/test_package/conanfile.py b/recipes/hyperscan/all/test_package/conanfile.py index ed03c4008f2fd..5ce555b9552f0 100644 --- a/recipes/hyperscan/all/test_package/conanfile.py +++ b/recipes/hyperscan/all/test_package/conanfile.py @@ -1,18 +1,25 @@ import os from conans import ConanFile, CMake, tools +from conan.tools.build import cross_building class HyperscanTestConan(ConanFile): settings = "os", "build_type", "arch", "compiler" - generators = "cmake" + generators = "cmake", "cmake_find_package" + def build(self): cmake = CMake(self) + cmake.definitions["BUILD_CHIMERA"] = self.options["hyperscan"].build_chimera cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") + if not cross_building(self): + bin_path = os.path.join("bin", "hs_example") self.run(bin_path, run_environment=True) + + if self.options["hyperscan"].build_chimera: + bin_path = os.path.join("bin", "ch_example") + self.run(bin_path, run_environment=True) diff --git a/recipes/hyperscan/all/test_package/example.cpp b/recipes/hyperscan/all/test_package/example.cpp deleted file mode 100644 index 4d207ba5e8f5f..0000000000000 --- a/recipes/hyperscan/all/test_package/example.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include "hs/hs.h" - -static int match_handler(unsigned int id, unsigned long long from, unsigned long long to, unsigned int flags, void *context) -{ - std::printf("Found match %u from %llu to %llu\n", id, from, to); - ++(*((int*)context)); - return 0; -} - -int main(int argc, char **argv) -{ - std::printf("%s\n", hs_version()); - - int retval = 0; - int match_cnt = 0; - hs_compile_error_t *err = nullptr; - hs_database_t *db = nullptr; - hs_scratch_t *scratch = nullptr; - - if (hs_compile("abc", HS_FLAG_SOM_LEFTMOST, HS_MODE_BLOCK, NULL, &db, &err) != HS_SUCCESS) { - std::printf("Failed to compile database\n"); - std::printf("%s\n", err->message); - retval = 1; - goto ret; - } - - if (hs_alloc_scratch(db, &scratch) != HS_SUCCESS) { - std::printf("Failed to allocate scratch space\n"); - retval = 1; - goto ret; - } - - if (hs_scan(db, "123abcdef", 9, 0, scratch, &match_handler, &match_cnt) != HS_SUCCESS) { - std::printf("Scan failed.\n"); - retval = 1; - goto ret; - } - - if (match_cnt != 1) { - retval = 1; - goto ret; - } - -ret: - hs_free_compile_error(err); - hs_free_database(db); - hs_free_scratch(scratch); - - return 0; -} diff --git a/recipes/hyperscan/all/test_package/hs_example.cpp b/recipes/hyperscan/all/test_package/hs_example.cpp new file mode 100644 index 0000000000000..428ae83a6294f --- /dev/null +++ b/recipes/hyperscan/all/test_package/hs_example.cpp @@ -0,0 +1,83 @@ +#include +#include +#include +#include +#include "hs/hs.h" + +static int match_handler(unsigned int id, unsigned long long from, unsigned long long to, unsigned int flags, void *context) +{ + std::printf("Found match %u from %llu to %llu\n", id, from, to); + ++(*((int*)context)); + return 0; +} + +static std::tuple, std::shared_ptr, hs_error_t> compile(const char* pattern) +{ + hs_compile_error_t* err = nullptr; + hs_database_t* db = nullptr; + + const auto result = hs_compile(pattern, HS_FLAG_SOM_LEFTMOST, HS_MODE_BLOCK, nullptr, &db, &err); + + return std::tuple, std::shared_ptr, hs_error_t>( + std::shared_ptr(db, hs_free_database), + std::shared_ptr(err, hs_free_compile_error), + result + ); +} + +static std::pair, hs_error_t> alloc_scratch(hs_database_t& db) +{ + hs_scratch_t* scratch = nullptr; + + const auto result = hs_alloc_scratch(&db, &scratch); + + return std::pair, hs_error_t>( + std::shared_ptr(scratch, hs_free_scratch), + result + ); +} + +static hs_error_t scan(hs_database_t& db, hs_scratch_t& scratch, const char* data, match_event_handler handler, void* context) +{ + const auto len = std::strlen(data); + return hs_scan(&db, data, len, 0, &scratch, match_handler, context); +} + +int main(int argc, char **argv) +{ + std::printf("%s\n", hs_version()); + + int retval = 0; + int match_cnt = 0; + + std::shared_ptr err; + std::shared_ptr db; + + hs_error_t result; + + std::tie(db, err, result) = compile("abc"); + + if (result != HS_SUCCESS) { + std::printf("Failed to compile database\n"); + std::printf("%s\n", err->message); + } + else + { + std::shared_ptr scratch; + + std::tie(scratch, result) = alloc_scratch(*db); + if (result != HS_SUCCESS) { + std::printf("Failed to allocate scratch space\n"); + } + else + { + if(scan(*db, *scratch, "123abcdef", &match_handler, &match_cnt) == HS_SUCCESS) + { + if (match_cnt == 1) { + return 0; + } + } + } + } + return -1; +} diff --git a/recipes/i2c-tools/all/conandata.yml b/recipes/i2c-tools/all/conandata.yml new file mode 100644 index 0000000000000..292823f71da26 --- /dev/null +++ b/recipes/i2c-tools/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "4.3": + url: "https://mirrors.edge.kernel.org/pub/software/utils/i2c-tools/i2c-tools-4.3.tar.gz" + sha256: "eec464e42301d93586cbeca3845ed61bff40f560670e5b35baec57301d438148" diff --git a/recipes/i2c-tools/all/conanfile.py b/recipes/i2c-tools/all/conanfile.py new file mode 100644 index 0000000000000..869b97a3d490e --- /dev/null +++ b/recipes/i2c-tools/all/conanfile.py @@ -0,0 +1,78 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +requires_conan_version = ">=1.33.0" + + +class I2cConan(ConanFile): + name = "i2c-tools" + license = "GPL-2.0-or-later", "LGPL-2.1" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://i2c.wiki.kernel.org/index.php/I2C_Tools" + description = "I2C tools for the linux kernel as well as an I2C library." + topics = ("i2c") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + self.requires("linux-headers-generic/5.14.9") + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("i2c-tools only support Linux") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile"), + "SRCDIRS := include lib eeprom stub tools $(EXTRA)", + "SRCDIRS := include lib $(EXTRA)") + + @property + def _make_args(self): + return [ + "PREFIX={}".format(self.package_folder), + "BUILD_DYNAMIC_LIB={}".format("1" if self.options.shared else "0"), + "BUILD_STATIC_LIB={}".format("0" if self.options.shared else "1"), + "USE_STATIC_LIB={}".format("0" if self.options.shared else "1"), + ] + + def build(self): + self._patch_sources() + autotools = AutoToolsBuildEnvironment(self) + autotools.flags += [f"-I{path}" for path in autotools.include_paths] + with tools.chdir(self._source_subfolder): + autotools.make(args=self._make_args) + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + self.copy("COPYING.LGPL", src=self._source_subfolder, dst="licenses") + autotools = AutoToolsBuildEnvironment(self) + autotools.flags += [f"-I{path}" for path in autotools.include_paths] + with tools.chdir(self._source_subfolder): + autotools.install(args=self._make_args) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["i2c"] diff --git a/recipes/i2c-tools/all/test_package/CMakeLists.txt b/recipes/i2c-tools/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8e909fdb64156 --- /dev/null +++ b/recipes/i2c-tools/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(i2c-tools REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE i2c-tools::i2c-tools) diff --git a/recipes/i2c-tools/all/test_package/conanfile.py b/recipes/i2c-tools/all/test_package/conanfile.py new file mode 100644 index 0000000000000..2780f5433abb4 --- /dev/null +++ b/recipes/i2c-tools/all/test_package/conanfile.py @@ -0,0 +1,15 @@ +from conans import ConanFile, CMake + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + # For obvious reasons, don't run the test package (we don't want to write data to some device) + pass diff --git a/recipes/i2c-tools/all/test_package/test_package.c b/recipes/i2c-tools/all/test_package/test_package.c new file mode 100644 index 0000000000000..e220611d6a44b --- /dev/null +++ b/recipes/i2c-tools/all/test_package/test_package.c @@ -0,0 +1,31 @@ +#include "i2c/smbus.h" + +#include +#include +#include + +int main(int argc, char *argv[]) { + if (argc < 2) { + fprintf(stderr, "Need an argument.\n"); + return 1; + } + int fd = open(argv[1], O_RDWR); + if (fd <= 0) { + fprintf(stderr, "Could not open %s.\n", argv[1]); + return 2; + } + + // Do more checks ... + + int res = i2c_smbus_write_byte(fd, 137); + if (res < 0) { + fprintf(stderr, "i2c_smbus_write_byte failed.\n"); + return 3; + } + + res = close(fd); + if (res < 0) { + fprintf(stderr, "close failed.\n"); + return 4; + } +} diff --git a/recipes/i2c-tools/config.yml b/recipes/i2c-tools/config.yml new file mode 100644 index 0000000000000..77cec98443737 --- /dev/null +++ b/recipes/i2c-tools/config.yml @@ -0,0 +1,3 @@ +versions: + "4.3": + folder: "all" diff --git a/recipes/icecream-cpp/all/conanfile.py b/recipes/icecream-cpp/all/conanfile.py index f2f1867d34c62..ad2f369b0f440 100644 --- a/recipes/icecream-cpp/all/conanfile.py +++ b/recipes/icecream-cpp/all/conanfile.py @@ -1,8 +1,8 @@ -import os - from conans import ConanFile, tools from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.33.0" + class IcecreamcppConan(ConanFile): name = "icecream-cpp" @@ -11,18 +11,16 @@ class IcecreamcppConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" description = "A little library to help with the print debugging on C++11 and forward." topics = ("debug", "single-header-lib", "print") - settings = ("compiler", ) + settings = "compiler" no_copy_source = True - _source_subfolder = "source_subfolder" - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename('icecream-cpp-{}'.format(self.version), self._source_subfolder) + @property + def _source_subfolder(self): + return "source_subfolder" - def configure(self): - minimal_cpp_standard = "11" - if self.settings.get_safe("compiler.cppstd"): - tools.check_min_cppstd(self, minimal_cpp_standard) + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5": raise ConanInvalidConfiguration( @@ -32,6 +30,13 @@ def configure(self): ) ) + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + def package(self): - self.copy('LICENSE.txt', dst='licenses', src=self._source_subfolder) - self.copy('icecream.hpp', dst='include', src=self._source_subfolder) + self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + self.copy("icecream.hpp", dst="include", src=self._source_subfolder) diff --git a/recipes/iceoryx/all/CMakeLists.txt b/recipes/iceoryx/all/CMakeLists.txt new file mode 100644 index 0000000000000..ae4d7a261b19e --- /dev/null +++ b/recipes/iceoryx/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.5) +project(cmake_wrapper) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder/iceoryx_meta") diff --git a/recipes/iceoryx/all/conandata.yml b/recipes/iceoryx/all/conandata.yml new file mode 100644 index 0000000000000..638b5224b83e0 --- /dev/null +++ b/recipes/iceoryx/all/conandata.yml @@ -0,0 +1,40 @@ +sources: + "2.0.2": + url: "https://github.com/eclipse-iceoryx/iceoryx/archive/v2.0.2.tar.gz" + sha256: "99871BCAA8DA4361D1BAAE9CF1507683058DE8572AC3080EDC41E590FFBA06C0" + "2.0.1": + url: "https://github.com/eclipse-iceoryx/iceoryx/archive/v2.0.1.tar.gz" + sha256: "A6750992EA668786F267E4EDA5588DE4D7585F30E59DCF8512620AF509D6690F" + "2.0.0": + url: "https://github.com/eclipse-iceoryx/iceoryx/archive/v2.0.0.tar.gz" + sha256: "C598DD0630F535D61EA9F8BDE5FE7DA3EF4C595419ECFBCD2384CA6FB4CA804F" + "1.0.1": + url: "https://github.com/eclipse-iceoryx/iceoryx/archive/v1.0.1.tar.gz" + sha256: "c47f2e1e6cb7660a2d1c2666fa3b640a2f57275d2e524d0c80160a51a781e0dc" + "1.0.0": + url: "https://github.com/eclipse-iceoryx/iceoryx/archive/refs/tags/v1.0.0.tar.gz" + sha256: "3D7BABCF92974F6D22E8A497E31198DE1D88DF8B20C942992DBBEC5DFB06C4BB" +patches: + "2.0.2": + - base_path: "source_subfolder" + patch_file: "patches/2.0.X-0001-fix-find-toml.patch" + "2.0.1": + - base_path: "source_subfolder" + patch_file: "patches/2.0.X-0001-fix-find-toml.patch" + "2.0.0": + - base_path: "source_subfolder" + patch_file: "patches/2.0.X-0001-fix-find-toml.patch" + "1.0.1": + - base_path: "source_subfolder" + patch_file: "patches/1.0.0-0001-fix-find-toml.patch" + - base_path: "source_subfolder" + patch_file: "patches/1.0.0-0002-fix-install-bundle.patch" + - base_path: "source_subfolder" + patch_file: "patches/1.0.0-0003-no-hardcoded-libcxx.patch" + "1.0.0": + - base_path: "source_subfolder" + patch_file: "patches/1.0.0-0001-fix-find-toml.patch" + - base_path: "source_subfolder" + patch_file: "patches/1.0.0-0002-fix-install-bundle.patch" + - base_path: "source_subfolder" + patch_file: "patches/1.0.0-0003-no-hardcoded-libcxx.patch" diff --git a/recipes/iceoryx/all/conanfile.py b/recipes/iceoryx/all/conanfile.py new file mode 100644 index 0000000000000..c14f7ee13f243 --- /dev/null +++ b/recipes/iceoryx/all/conanfile.py @@ -0,0 +1,298 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os +import textwrap + +required_conan_version = ">=1.43.0" + + +class IceoryxConan(ConanFile): + name = "iceoryx" + license = "Apache-2.0" + homepage = "https://iceoryx.io/" + url = "https://github.com/conan-io/conan-center-index" + description = "Eclipse iceoryx - true zero-copy inter-process-communication" + topics = ("Shared Memory", "IPC", "ROS", "Middleware") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "toml_config": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "toml_config": True, + } + + generators = ["cmake", "cmake_find_package"] + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.options.toml_config: + self.requires("cpptoml/0.1.1") + if self.settings.os == "Linux": + self.requires("acl/2.3.1") + + def build_requirements(self): + if tools.Version(self.version) >= "2.0.0": + self.tool_requires("cmake/3.16.2") + + def validate(self): + compiler = self.settings.compiler + version = tools.Version(self.settings.compiler.version) + + if compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 14) + + if compiler == "Visual Studio": + if version < "16": + raise ConanInvalidConfiguration("Iceoryx is just supported for Visual Studio 2019 and higher.") + if self.options.shared: + raise ConanInvalidConfiguration( + 'Using Iceoryx with Visual Studio currently just possible with "shared=False"') + elif compiler == "gcc": + if version < "6": + raise ConanInvalidConfiguration("Using Iceoryx with gcc requires gcc 6 or higher.") + if version < "9" and compiler.get_safe("libcxx") == "libstdc++": + raise ConanInvalidConfiguration("gcc < 9 with libstdc++ not supported") + if version == "6": + self.output.warn("Iceoryx package is compiled with gcc 6, it is recommended to use 7 or higher") + self.output.warn("GCC 6 will build with warnings.") + elif compiler == "clang": + if compiler.get_safe("libcxx") == "libstdc++": + raise ConanInvalidConfiguration("clang with libstdc++ not supported") + if version == "7.0" and compiler.get_safe("libcxx") == "libc++" and \ + self.options.shared and self.settings.build_type == "Debug": + raise ConanInvalidConfiguration("shared Debug with clang 7.0 and libc++ not supported") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + # Honor fPIC option + iceoryx_utils = "iceoryx_hoofs" if tools.Version(self.version) >= "2.0.0" else "iceoryx_utils" + for cmake_file in [ + os.path.join("iceoryx_binding_c", "CMakeLists.txt"), + os.path.join("iceoryx_posh", "CMakeLists.txt"), + os.path.join(iceoryx_utils, "CMakeLists.txt") + ]: + tools.replace_in_file(os.path.join(self._source_subfolder, cmake_file), "POSITION_INDEPENDENT_CODE ON", "") + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["TOML_CONFIG"] = self.options.toml_config + if tools.Version(self.version) >= "2.0.0": + self._cmake.definitions["DOWNLOAD_TOML_LIB"] = False + self._cmake.configure() + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + if self.options.toml_config: + tools.mkdir(os.path.join(self.package_folder, "res")) + tools.rename(os.path.join(self.package_folder, "etc", "roudi_config_example.toml"), + os.path.join(self.package_folder, "res", "roudi_config.toml")) + tools.rmdir(os.path.join(self.package_folder, "etc")) + # bring to default package structure + if (tools.Version(self.version) >= "2.0.0"): + include_paths = ["iceoryx_binding_c", "iceoryx_hoofs", "iceoryx_posh", "iceoryx_versions.hpp"] + for include_path in include_paths: + tools.rename( + os.path.join(self.package_folder, "include", "iceoryx", "v{}".format(self.version), include_path), + os.path.join(self.package_folder, "include", include_path)) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + if (tools.Version(self.version) >= "2.0.0"): + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {v["target"]: "iceoryx::{}".format(k) + for k, v in self._iceoryx_components["2.0.0"].items()}) + else: + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {v["target"]: "iceoryx::{}".format(k) + for k, v in self._iceoryx_components["1.0.X"].items()}) + + @property + def _iceoryx_components(self): + + def pthread(): + return ["pthread"] if self.settings.os in ["Linux", "FreeBSD"] else [] + + def rt(): + return ["rt"] if self.settings.os in ["Linux", "FreeBSD"] else [] + + def atomic(): + return ["atomic"] if self.settings.os == "Linux" else [] + + def acl(): + return ["acl::acl"] if self.settings.os == "Linux" else [] + + def cpptoml(): + return ["cpptoml::cpptoml"] if self.options.toml_config else [] + + def libcxx(): + libcxx = tools.stdcpp_library(self) + return [libcxx] if libcxx and not self.options.shared else [] + + return { + "1.0.X": { + "iceoryx_platform": { + "target": "iceoryx_utils::iceoryx_platform", + "system_libs": pthread(), + "requires": [] + }, + "iceoryx_utils": { + "target": "iceoryx_utils::iceoryx_utils", + "system_libs": pthread() + rt() + atomic(), + "requires": ["iceoryx_platform"] + acl() + }, + "iceoryx_posh": { + "target": "iceoryx_posh::iceoryx_posh", + "system_libs": pthread(), + "requires": ["iceoryx_utils"] + }, + "iceoryx_posh_roudi": { + "target": "iceoryx_posh::iceoryx_posh_roudi", + "system_libs": pthread(), + "requires": ["iceoryx_utils", "iceoryx_posh"] + cpptoml() + }, + "iceoryx_posh_gateway": { + "target": "iceoryx_posh::iceoryx_posh_gateway", + "system_libs": pthread(), + "requires": ["iceoryx_utils", "iceoryx_posh"] + }, + "iceoryx_posh_config": { + "target": "iceoryx_posh::iceoryx_posh_config", + "system_libs": pthread(), + "requires": ["iceoryx_posh_roudi", "iceoryx_utils", "iceoryx_posh"] + }, + "iceoryx_binding_c": { + "target": "iceoryx_binding_c::iceoryx_binding_c", + "system_libs": pthread() + libcxx(), + "requires": ["iceoryx_utils", "iceoryx_posh"] + } + }, + "2.0.0": { + "iceoryx_platform": { + "target": "iceoryx_hoofs::iceoryx_platform", + "system_libs": pthread() + rt(), + "requires": [], + "includeDir": False + }, + "iceoryx_hoofs": { + "target": "iceoryx_hoofs::iceoryx_hoofs", + "system_libs": pthread() + rt() + atomic(), + "requires": ["iceoryx_platform"] + acl(), + "includeDir": True + }, + "iceoryx_posh": { + "target": "iceoryx_posh::iceoryx_posh", + "system_libs": pthread() + rt(), + "requires": ["iceoryx_hoofs"], + "includeDir": True + }, + "iceoryx_posh_roudi": { + "target": "iceoryx_posh::iceoryx_posh_roudi", + "system_libs": pthread(), + "requires": ["iceoryx_hoofs", "iceoryx_posh"] + cpptoml(), + "includeDir": False + }, + "iceoryx_posh_gateway": { + "target": "iceoryx_posh::iceoryx_posh_gateway", + "system_libs": pthread(), + "requires": ["iceoryx_hoofs", "iceoryx_posh"], + "includeDir": False + }, + "iceoryx_posh_config": { + "target": "iceoryx_posh::iceoryx_posh_config", + "system_libs": pthread(), + "requires": ["iceoryx_posh_roudi", "iceoryx_hoofs", "iceoryx_posh"], + "includeDir": False + }, + "iceoryx_binding_c": { + "target": "iceoryx_binding_c::iceoryx_binding_c", + "system_libs": pthread() + libcxx(), + "requires": ["iceoryx_hoofs", "iceoryx_posh"], + "includeDir": True + } + } + } + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + + def package_info(self): + # FIXME: We should provide 3 CMake config files: + # iceoryx_utilsConfig.cmake, iceoryx_poshConfig.cmake and iceoryx_binding_cConfig.cmake + # It's not possible yet, see https://github.com/conan-io/conan/issues/9000 + self.cpp_info.set_property("cmake_file_name", "iceoryx") + + def _register_components(components): + for lib_name, values in components.items(): + cmake_target = values.get("target", []) + system_libs = values.get("system_libs", []) + requires = values.get("requires", []) + self.cpp_info.components[lib_name].set_property("cmake_target_name", cmake_target) + self.cpp_info.components[lib_name].libs = [lib_name] + self.cpp_info.components[lib_name].system_libs = system_libs + self.cpp_info.components[lib_name].requires = requires + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.components[lib_name].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components[lib_name].build_modules["cmake_find_package_multi"] = [ + self._module_file_rel_path + ] + + if tools.Version(self.version) >= "2.0.0": + _register_components(self._iceoryx_components["2.0.0"]) + else: + _register_components(self._iceoryx_components["1.0.X"]) + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/iceoryx/all/patches/1.0.0-0001-fix-find-toml.patch b/recipes/iceoryx/all/patches/1.0.0-0001-fix-find-toml.patch new file mode 100644 index 0000000000000..062232389f69a --- /dev/null +++ b/recipes/iceoryx/all/patches/1.0.0-0001-fix-find-toml.patch @@ -0,0 +1,21 @@ +diff --git a/iceoryx_posh/CMakeLists.txt b/iceoryx_posh/CMakeLists.txt +index 6df5429b..e7dedbc4 100644 +--- a/iceoryx_posh/CMakeLists.txt ++++ b/iceoryx_posh/CMakeLists.txt +@@ -27,8 +27,6 @@ option(TOML_CONFIG "TOML support for RouDi with dynamic configuration" ON) + option(ONE_TO_MANY_ONLY "Restricts communication to 1:n pattern" OFF) + + if(TOML_CONFIG) +- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpptoml/ ${CMAKE_BINARY_DIR}/dependencies/posh/cpptoml/prebuild) +- + find_package(cpptoml REQUIRED) + endif() + +@@ -325,7 +323,6 @@ if(TOML_CONFIG) + iceoryx_posh::iceoryx_posh + iceoryx_utils::iceoryx_utils + iceoryx_posh::iceoryx_posh_roudi +- cpptoml + ${ICEORYX_SANITIZER_FLAGS} + ) + diff --git a/recipes/iceoryx/all/patches/1.0.0-0002-fix-install-bundle.patch b/recipes/iceoryx/all/patches/1.0.0-0002-fix-install-bundle.patch new file mode 100644 index 0000000000000..bebf8b4d52e71 --- /dev/null +++ b/recipes/iceoryx/all/patches/1.0.0-0002-fix-install-bundle.patch @@ -0,0 +1,10 @@ +--- a/iceoryx_utils/cmake/IceoryxPackageHelper.cmake ++++ b/iceoryx_utils/cmake/IceoryxPackageHelper.cmake +@@ -78,6 +78,7 @@ Macro(install_target_directories_and_header) + TARGETS ${INSTALL_TARGETS} + EXPORT ${TARGETS_EXPORT_NAME} + RUNTIME DESTINATION ${DESTINATION_BINDIR} COMPONENT bin ++ BUNDLE DESTINATION ${DESTINATION_BINDIR} COMPONENT bin + LIBRARY DESTINATION ${DESTINATION_LIBDIR} COMPONENT bin + ARCHIVE DESTINATION ${DESTINATION_LIBDIR} COMPONENT bin + ) diff --git a/recipes/iceoryx/all/patches/1.0.0-0003-no-hardcoded-libcxx.patch b/recipes/iceoryx/all/patches/1.0.0-0003-no-hardcoded-libcxx.patch new file mode 100644 index 0000000000000..67d4c05d0c142 --- /dev/null +++ b/recipes/iceoryx/all/patches/1.0.0-0003-no-hardcoded-libcxx.patch @@ -0,0 +1,10 @@ +--- a/iceoryx_binding_c/CMakeLists.txt ++++ b/iceoryx_binding_c/CMakeLists.txt +@@ -88,7 +88,6 @@ target_include_directories(${PROJECT_NAME} + if(NOT (WIN32 OR QNX)) + target_link_libraries(${PROJECT_NAME} + PUBLIC +- stdc++ + pthread + PRIVATE + iceoryx_posh::iceoryx_posh diff --git a/recipes/iceoryx/all/patches/2.0.X-0001-fix-find-toml.patch b/recipes/iceoryx/all/patches/2.0.X-0001-fix-find-toml.patch new file mode 100644 index 0000000000000..fe7e89524991f --- /dev/null +++ b/recipes/iceoryx/all/patches/2.0.X-0001-fix-find-toml.patch @@ -0,0 +1,12 @@ +diff --git a/iceoryx_posh/CMakeLists.txt b/iceoryx_posh/CMakeLists.txt +index 8f28ac07b..c07b16b88 100644 +--- a/iceoryx_posh/CMakeLists.txt ++++ b/iceoryx_posh/CMakeLists.txt +@@ -350,7 +350,6 @@ if(TOML_CONFIG) + iceoryx_posh::iceoryx_posh + iceoryx_hoofs::iceoryx_hoofs + iceoryx_posh::iceoryx_posh_roudi +- cpptoml + ${ICEORYX_SANITIZER_FLAGS} + ) + diff --git a/recipes/iceoryx/all/test_package/CMakeLists.txt b/recipes/iceoryx/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..4d89e84377074 --- /dev/null +++ b/recipes/iceoryx/all/test_package/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +if (${MSVC}) + set(CMAKE_CXX_STANDARD 17) +else() + set(CMAKE_CXX_STANDARD 14) +endif() + +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(iceoryx REQUIRED CONFIG) + +add_executable(test_package main.cpp) +target_link_libraries(test_package iceoryx_posh::iceoryx_posh + iceoryx_posh::iceoryx_posh_roudi +) diff --git a/recipes/iceoryx/all/test_package/conanfile.py b/recipes/iceoryx/all/test_package/conanfile.py new file mode 100644 index 0000000000000..50e21d11f1ebd --- /dev/null +++ b/recipes/iceoryx/all/test_package/conanfile.py @@ -0,0 +1,21 @@ +import os +from conans import ConanFile, CMake + +class IceoryxTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = ["cmake", "cmake_find_package_multi"] + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + # ToDo : add an executable which can be + # executed in container. + # currently seems shared memory in container is + # a bad idea (checked on 3 different linux devices + # always ok - but in container get + # "fatal SIGBUS signal appeared caused by memset") + path, dirs, files = next(os.walk("bin")) + print("All %d example files are present" % (len(files))) diff --git a/recipes/iceoryx/all/test_package/main.cpp b/recipes/iceoryx/all/test_package/main.cpp new file mode 100644 index 0000000000000..84eb37579a34f --- /dev/null +++ b/recipes/iceoryx/all/test_package/main.cpp @@ -0,0 +1,24 @@ + +#include "iceoryx_posh/iceoryx_posh_config.hpp" +#include "iceoryx_posh/iceoryx_posh_types.hpp" +#include "iceoryx_posh/internal/roudi/roudi.hpp" +#include "iceoryx_posh/popo/publisher.hpp" +#include "iceoryx_posh/popo/subscriber.hpp" +#include "iceoryx_posh/roudi/iceoryx_roudi_components.hpp" +#include "iceoryx_posh/runtime/posh_runtime_single_process.hpp" + +#include +#include +#include +#include +#include +#include + +int main() { + + iox::log::LogManager::GetLogManager().SetDefaultLogLevel(iox::log::LogLevel::kError); + iox::RouDiConfig_t defaultRouDiConfig = iox::RouDiConfig_t().setDefaults(); + iox::roudi::IceOryxRouDiComponents roudiComponents(defaultRouDiConfig); + + return 0; +} diff --git a/recipes/iceoryx/config.yml b/recipes/iceoryx/config.yml new file mode 100644 index 0000000000000..bb084f4416dd3 --- /dev/null +++ b/recipes/iceoryx/config.yml @@ -0,0 +1,11 @@ +versions: + "2.0.2": + folder: all + "2.0.1": + folder: all + "2.0.0": + folder: all + "1.0.1": + folder: all + "1.0.0": + folder: all diff --git a/recipes/icu/all/conandata.yml b/recipes/icu/all/conandata.yml index a4bb66292989c..822f91ba171c8 100644 --- a/recipes/icu/all/conandata.yml +++ b/recipes/icu/all/conandata.yml @@ -1,31 +1,44 @@ sources: - "64.2": - url: "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-src.tgz" - sha256: "627d5d8478e6d96fc8c90fed4851239079a561a6a8b9e48b0892f24e82d31d6c" - "65.1": - url: "https://github.com/unicode-org/icu/releases/download/release-65-1/icu4c-65_1-src.tgz" - sha256: "53e37466b3d6d6d01ead029e3567d873a43a5d1c668ed2278e253b683136d948" - "66.1": - url: "https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-src.tgz" - sha256: "52a3f2209ab95559c1cf0a14f24338001f389615bf00e2585ef3dbc43ecf0a2e" - "67.1": - url: "https://github.com/unicode-org/icu/releases/download/release-67-1/icu4c-67_1-src.tgz" - sha256: "94a80cd6f251a53bd2a997f6f1b5ac6653fe791dfab66e1eb0227740fb86d5dc" - "68.1": - url: "https://github.com/unicode-org/icu/releases/download/release-68-1/icu4c-68_1-src.tgz" - sha256: "a9f2e3d8b4434b8e53878b4308bd1e6ee51c9c7042e2b1a376abefb6fbb29f2d" + "72.1": + url: "https://github.com/unicode-org/icu/releases/download/release-72-1/icu4c-72_1-src.tgz" + sha256: "a2d2d38217092a7ed56635e34467f92f976b370e20182ad325edea6681a71d68" + "71.1": + url: "https://github.com/unicode-org/icu/releases/download/release-71-1/icu4c-71_1-src.tgz" + sha256: "67a7e6e51f61faf1306b6935333e13b2c48abd8da6d2f46ce6adca24b1e21ebf" + "70.1": + url: "https://github.com/unicode-org/icu/releases/download/release-70-1/icu4c-70_1-src.tgz" + sha256: "8d205428c17bf13bb535300669ed28b338a157b1c01ae66d31d0d3e2d47c3fd5" + "69.1": + url: "https://github.com/unicode-org/icu/releases/download/release-69-1/icu4c-69_1-src.tgz" + sha256: "4cba7b7acd1d3c42c44bb0c14be6637098c7faf2b330ce876bc5f3b915d09745" "68.2": url: "https://github.com/unicode-org/icu/releases/download/release-68-2/icu4c-68_2-src.tgz" sha256: "c79193dee3907a2199b8296a93b52c5cb74332c26f3d167269487680d479d625" + "67.1": + url: "https://github.com/unicode-org/icu/releases/download/release-67-1/icu4c-67_1-src.tgz" + sha256: "94a80cd6f251a53bd2a997f6f1b5ac6653fe791dfab66e1eb0227740fb86d5dc" + "66.1": + url: "https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-src.tgz" + sha256: "52a3f2209ab95559c1cf0a14f24338001f389615bf00e2585ef3dbc43ecf0a2e" + "65.1": + url: "https://github.com/unicode-org/icu/releases/download/release-65-1/icu4c-65_1-src.tgz" + sha256: "53e37466b3d6d6d01ead029e3567d873a43a5d1c668ed2278e253b683136d948" patches: + "72.1": + - patch_file: "patches/0001-69.1-fix-mingw.patch" + "71.1": + - patch_file: "patches/0001-69.1-fix-mingw.patch" + - patch_file: "patches/0001-71.1-fix-undef-strict-ansi.patch" + - patch_file: "patches/0001-71.1-fix-emscripten.patch" + patch_description: "Add config file for wasm-emscripten platform" + patch_type: "portability" + patch_source: "https://gerrit.libreoffice.org/c/core/+/111130/9/external/icu/icu4c-emscripten-cross.patch.1" + "70.1": + - patch_file: "patches/0001-69.1-fix-mingw.patch" + "69.1": + - patch_file: "patches/0001-69.1-fix-mingw.patch" + "68.2": + - patch_file: "patches/0001-67.1-fix-mingw.patch" "67.1": - patch_file: "patches/6aba9344a18f4f32e8070ee53b79495630901c26.patch" - base_path: "source_subfolder" - - patch_file: "patches/0001-67.1-fix-mingw.patch" - base_path: "source_subfolder" - "68.1": - - patch_file: "patches/0001-67.1-fix-mingw.patch" - base_path: "source_subfolder" - "68.2": - patch_file: "patches/0001-67.1-fix-mingw.patch" - base_path: "source_subfolder" diff --git a/recipes/icu/all/conanfile.py b/recipes/icu/all/conanfile.py index 3d8ef312212c2..2f39693a0f674 100644 --- a/recipes/icu/all/conanfile.py +++ b/recipes/icu/all/conanfile.py @@ -1,230 +1,203 @@ +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, rename, replace_in_file, rm, rmdir, save +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version +from conans.tools import get_gnu_triplet, sha256sum, stdcpp_library import glob import os -import platform import shutil -from conans import ConanFile, tools, AutoToolsBuildEnvironment +required_conan_version = ">=1.53.0" -class ICUBase(ConanFile): +class ICUConan(ConanFile): name = "icu" homepage = "http://site.icu-project.org" license = "ICU" description = "ICU is a mature, widely used set of C/C++ and Java libraries " \ "providing Unicode and Globalization support for software applications." url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "icu", "icu4c", "i see you", "unicode") + topics = ("icu", "icu4c", "i see you", "unicode") + settings = "os", "arch", "compiler", "build_type" - exports_sources = "patches/*.patch" - options = {"shared": [True, False], - "fPIC": [True, False], - "data_packaging": ["files", "archive", "library", "static"], - "with_unit_tests": [True, False], - "silent": [True, False], - "with_dyload": [True, False]} - default_options = {"shared": False, - "fPIC": True, - "data_packaging": "archive", - "with_unit_tests": False, - "silent": True, - "with_dyload": True} - - _env_build = None + options = { + "shared": [True, False], + "fPIC": [True, False], + "data_packaging": ["files", "archive", "library", "static"], + "with_dyload": [True, False], + "dat_package_file": [None, "ANY"], + "with_icuio": [True, False], + "with_extras": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "data_packaging": "archive", + "with_dyload": True, + "dat_package_file": None, + "with_icuio": True, + "with_extras": False, + } @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) @property - def _build_subfolder(self): - return "build_subfolder" + def _enable_icu_tools(self): + return self.settings.os not in ["iOS", "tvOS", "watchOS", "Emscripten"] @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + def _with_unit_tests(self): + return not self.conf.get("tools.build:skip_test", default=True, check_type=bool) - @property - def _is_mingw(self): - return self.settings.os == "Windows" and self.settings.compiler == "gcc" - - @property - def _make_tool(self): - return "make" if self.settings.os != "FreeBSD" else "gmake" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + del self.options.data_packaging def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + + def layout(self): + basic_layout(self, src_folder="src") def package_id(self): - del self.info.options.with_unit_tests # ICU unit testing shouldn't affect the package's ID - del self.info.options.silent # Verbosity doesn't affect package's ID + if self.options.dat_package_file: + dat_package_file_sha256 = sha256sum(str(self.options.dat_package_file)) + self.info.options.dat_package_file = dat_package_file_sha256 def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("icu", self._source_subfolder) + if cross_building(self) and hasattr(self, "settings_build"): + self.tool_requires(self.ref) - def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - if self._is_msvc: - run_configure_icu_file = os.path.join(self._source_subfolder, "source", "runConfigureICU") - - flags = "-%s" % self.settings.compiler.runtime - if self.settings.build_type in ["Debug", "RelWithDebInfo"] and tools.Version(self.settings.compiler.version) >= "12": - flags += " -FS" - tools.replace_in_file(run_configure_icu_file, "-MDd", flags) - tools.replace_in_file(run_configure_icu_file, "-MD", flags) - - self._workaround_icu_20545() - - env_build = self._configure_autotools() - build_dir = os.path.join(self.build_folder, self._source_subfolder, "build") - os.mkdir(build_dir) - with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): - with tools.environment_append(env_build.vars): - with tools.chdir(build_dir): - # workaround for https://unicode-org.atlassian.net/browse/ICU-20531 - os.makedirs(os.path.join("data", "out", "tmp")) - - self.run(self._build_config_cmd, win_bash=tools.os_info.is_windows) - command = "{make} {silent} -j {cpu_count}".format(make=self._make_tool, - silent=self._silent, - cpu_count=tools.cpu_count()) - self.run(command, win_bash=tools.os_info.is_windows) - if self.options.with_unit_tests: - command = "{make} {silent} check".format(make=self._make_tool, - silent=self._silent) - self.run(command, win_bash=tools.os_info.is_windows) - - def _configure_autotools(self): - if self._env_build: - return self._env_build - self._env_build = AutoToolsBuildEnvironment(self) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + tc.extra_cxxflags.append("-FS") if not self.options.shared: - self._env_build.defines.append("U_STATIC_IMPLEMENTATION") - if tools.is_apple_os(self.settings.os): - self._env_build.defines.append("_DARWIN_C_SOURCE") - if "msys2" in self.deps_user_info: - self._env_build.vars["PYTHON"] = tools.unix_path(os.path.join(self.deps_env_info["msys2"].MSYS_BIN, "python"), tools.MSYS2) - return self._env_build - - def _workaround_icu_20545(self): - if tools.os_info.is_windows: + tc.extra_defines.append("U_STATIC_IMPLEMENTATION") + if is_apple_os(self): + tc.extra_defines.append("_DARWIN_C_SOURCE") + yes_no = lambda v: "yes" if v else "no" + tc.configure_args.extend([ + "--datarootdir=${prefix}/lib", # do not use share + f"--enable-release={yes_no(self.settings.build_type != 'Debug')}", + f"--enable-debug={yes_no(self.settings.build_type == 'Debug')}", + f"--enable-dyload={yes_no(self.options.with_dyload)}", + f"--enable-extras={yes_no(self.options.with_extras)}", + f"--enable-icuio={yes_no(self.options.with_icuio)}", + "--disable-layoutex", + "--disable-layout", + f"--enable-tools={yes_no(self._enable_icu_tools)}", + f"--enable-tests={yes_no(self._with_unit_tests)}", + "--disable-samples", + ]) + if cross_building(self): + base_path = unix_path(self, self.dependencies.build["icu"].package_folder) + tc.configure_args.append(f"--with-cross-build={base_path}") + if self.settings.os in ["iOS", "tvOS", "watchOS"]: + gnu_triplet = get_gnu_triplet("Macos", str(self.settings.arch)) + tc.configure_args.append(f"--host={gnu_triplet}") + elif is_msvc(self): + # ICU doesn't like GNU triplet of conan for msvc (see https://github.com/conan-io/conan/issues/12546) + host = get_gnu_triplet(str(self.settings.os), str(self.settings.arch), "gcc") + build = get_gnu_triplet(str(self._settings_build.os), str(self._settings_build.arch), "gcc") + tc.configure_args.extend([ + f"--host={host}", + f"--build={build}", + ]) + else: + arch64 = ["x86_64", "sparcv9", "ppc64", "ppc64le", "armv8", "armv8.3", "mips64"] + bits = "64" if self.settings.arch in arch64 else "32" + tc.configure_args.append(f"--with-library-bits={bits}") + if self.settings.os != "Windows": + # http://userguide.icu-project.org/icudata + # This is the only directly supported behavior on Windows builds. + tc.configure_args.append(f"--with-data-packaging={self.options.data_packaging}") + tc.generate() + + if is_msvc(self): + env = Environment() + env.define("CC", "cl -nologo") + env.define("CXX", "cl -nologo") + env.vars(self).save_script("conanbuild_icu_msvc") + + def _patch_sources(self): + apply_conandata_patches(self) + + if not self._with_unit_tests: + # Prevent any call to python during configuration, it's only needed for unit tests + replace_in_file( + self, + os.path.join(self.source_folder, "source", "configure"), + "if test -z \"$PYTHON\"", + "if true", + ) + + if self._settings_build.os == "Windows": # https://unicode-org.atlassian.net/projects/ICU/issues/ICU-20545 - srcdir = os.path.join(self.build_folder, self._source_subfolder, "source") - makeconv_cpp = os.path.join(srcdir, "tools", "makeconv", "makeconv.cpp") - tools.replace_in_file(makeconv_cpp, - "pathBuf.appendPathPart(arg, localError);", - "pathBuf.append(\"/\", localError); pathBuf.append(arg, localError);") + makeconv_cpp = os.path.join(self.source_folder, "source", "tools", "makeconv", "makeconv.cpp") + replace_in_file(self, makeconv_cpp, + "pathBuf.appendPathPart(arg, localError);", + "pathBuf.append(\"/\", localError); pathBuf.append(arg, localError);") + + # relocatable shared libs on macOS + mh_darwin = os.path.join(self.source_folder, "source", "config", "mh-darwin") + replace_in_file(self, mh_darwin, "-install_name $(libdir)/$(notdir", "-install_name @rpath/$(notdir") + replace_in_file(self, + mh_darwin, + "-install_name $(notdir $(MIDDLE_SO_TARGET)) $(PKGDATA_TRAILING_SPACE)", + "-install_name @rpath/$(notdir $(MIDDLE_SO_TARGET))", + ) + + # workaround for https://unicode-org.atlassian.net/browse/ICU-20531 + mkdir(self, os.path.join(self.build_folder, "data", "out", "tmp")) + + # workaround for "No rule to make target 'out/tmp/dirs.timestamp'" + save(self, os.path.join(self.build_folder, "data", "out", "tmp", "dirs.timestamp"), "") - @property - def _build_config_cmd(self): - prefix = self.package_folder.replace("\\", "/") - platform = {("Windows", "Visual Studio"): "Cygwin/MSVC", - ("Windows", "gcc"): "MinGW", - ("AIX", "gcc"): "AIX/GCC", - ("AIX", "xlc"): "AIX", - ("SunOS", "gcc"): "Solaris/GCC", - ("Linux", "gcc"): "Linux/gcc", - ("Linux", "clang"): "Linux", - ("Macos", "gcc"): "MacOSX", - ("Macos", "clang"): "MacOSX", - ("Macos", "apple-clang"): "MacOSX", - ("FreeBSD", "gcc"): "FreeBSD", - ("FreeBSD", "clang"): "FreeBSD"}.get((str(self.settings.os), - str(self.settings.compiler))) - arch64 = ['x86_64', 'sparcv9', 'ppc64', 'ppc64le', 'armv8', 'armv8.3', 'mips64'] - bits = "64" if self.settings.arch in arch64 else "32" - args = [platform, - "--prefix={0}".format(prefix), - "--with-library-bits={0}".format(bits), - "--disable-samples", - "--disable-layout", - "--disable-layoutex", - "--disable-extras"] - - if not self.options.with_dyload: - args += ["--disable-dyload"] - - env_build = self._configure_autotools() - if tools.cross_building(self.settings, skip_x64_x86=True): - if env_build.build: - args.append("--build=%s" % env_build.build) - if env_build.host: - args.append("--host=%s" % env_build.host) - if env_build.target: - args.append("--target=%s" % env_build.target) - - args.append("--with-data-packaging={0}".format(self.options.data_packaging)) - datadir = os.path.join(self.package_folder, "lib") - datadir = datadir.replace("\\", "/") if tools.os_info.is_windows else datadir - args.append("--datarootdir=%s" % datadir) # do not use share - bindir = os.path.join(self.package_folder, "bin") - bindir = bindir.replace("\\", "/") if tools.os_info.is_windows else bindir - args.append("--sbindir=%s" % bindir) - libdir = os.path.join(self.package_folder, "lib") - libdir = libdir.replace("\\", "/") if tools.os_info.is_windows else libdir - args.append("--libdir=%s" % libdir) - - if self._is_mingw: - mingw_chost = "i686-w64-mingw32" if self.settings.arch == "x86" else "x86_64-w64-mingw32" - args.extend(["--build={0}".format(mingw_chost), - "--host={0}".format(mingw_chost)]) - - if self.settings.build_type == "Debug": - args.extend(["--disable-release", "--enable-debug"]) - if self.options.shared: - args.extend(["--disable-static", "--enable-shared"]) - else: - args.extend(["--enable-static", "--disable-shared"]) - if not self.options.with_unit_tests: - args.append("--disable-tests") - return "../source/runConfigureICU %s" % " ".join(args) + def build(self): + self._patch_sources() - @property - def _silent(self): - return "--silent" if self.options.silent else "VERBOSE=1" + if self.options.dat_package_file: + dat_package_file = glob.glob(os.path.join(self.source_folder, "source", "data", "in", "*.dat")) + if dat_package_file: + shutil.copy(str(self.options.dat_package_file), dat_package_file[0]) - def package(self): - self.copy("LICENSE", dst="licenses", src=os.path.join(self.source_folder, self._source_subfolder)) - - env_build = self._configure_autotools() - build_dir = os.path.join(self.build_folder, self._source_subfolder, "build") - with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): - with tools.environment_append(env_build.vars): - with tools.chdir(build_dir): - command = "{make} {silent} install".format(make=self._make_tool, - silent=self._silent) - self.run(command, win_bash=tools.os_info.is_windows) - self._install_name_tool() - - for dll in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")): - shutil.move(dll, os.path.join(self.package_folder, "bin")) - - if self.options.data_packaging in ["files", "archive"]: - tools.mkdir(os.path.join(self.package_folder, "res")) - shutil.move(self._data_path, os.path.join(self.package_folder, "res")) - - tools.rmdir(os.path.join(self.package_folder, "lib", "icu")) - tools.rmdir(os.path.join(self.package_folder, "lib", "man")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) - - def _install_name_tool(self): - if tools.is_apple_os(self.settings.os): - with tools.chdir(os.path.join(self.package_folder, "lib")): - for dylib in glob.glob("*icu*.{0}.dylib".format(self.version)): - command = "install_name_tool -id {0} {1}".format(os.path.basename(dylib), dylib) - self.output.info(command) - self.run(command) + autotools = Autotools(self) + autotools.configure(build_script_folder=os.path.join(self.source_folder, "source")) + autotools.make() + if self._with_unit_tests: + autotools.make(target="check") + + @property + def _data_filename(self): + vtag = self.version.split(".")[0] + return f"icudt{vtag}l.dat" @property def _data_path(self): @@ -234,36 +207,61 @@ def _data_path(self): data_dir = os.path.join(self.package_folder, "lib", data_dir_name, self.version) return os.path.join(data_dir, self._data_filename) - @property - def _data_filename(self): - vtag = self.version.split(".")[0] - return "icudt{}l.dat".format(vtag) + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + + dll_files = glob.glob(os.path.join(self.package_folder, "lib", "*.dll")) + if dll_files: + bin_dir = os.path.join(self.package_folder, "bin") + mkdir(self, bin_dir) + for dll in dll_files: + dll_name = os.path.basename(dll) + rm(self, dll_name, bin_dir) + rename(self, src=dll, dst=os.path.join(bin_dir, dll_name)) + + if self.settings.os != "Windows" and self.options.data_packaging in ["files", "archive"]: + mkdir(self, os.path.join(self.package_folder, "res")) + rename(self, src=self._data_path, dst=os.path.join(self.package_folder, "res", self._data_filename)) + + # Copy some files required for cross-compiling + config_dir = os.path.join(self.package_folder, "config") + copy(self, "icucross.mk", src=os.path.join(self.build_folder, "config"), dst=config_dir) + copy(self, "icucross.inc", src=os.path.join(self.build_folder, "config"), dst=config_dir) + + rmdir(self, os.path.join(self.package_folder, "lib", "icu")) + rmdir(self, os.path.join(self.package_folder, "lib", "man")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "ICU" - self.cpp_info.names["cmake_find_package_multi"] = "ICU" + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "ICU") + + prefix = "s" if self.settings.os == "Windows" and not self.options.shared else "" + suffix = "d" if self.settings.os == "Windows" and self.settings.build_type == "Debug" else "" # icudata - self.cpp_info.components["icu-data"].names["cmake_find_package"] = "data" - self.cpp_info.components["icu-data"].names["cmake_find_package_multi"] = "data" - self.cpp_info.components["icu-data"].libs = [self._lib_name("icudt" if self.settings.os == "Windows" else "icudata")] + self.cpp_info.components["icu-data"].set_property("cmake_target_name", "ICU::data") + icudata_libname = "icudt" if self.settings.os == "Windows" else "icudata" + self.cpp_info.components["icu-data"].libs = [f"{prefix}{icudata_libname}{suffix}"] if not self.options.shared: self.cpp_info.components["icu-data"].defines.append("U_STATIC_IMPLEMENTATION") - - # icu uses c++, so add the c++ runtime - if tools.stdcpp_library(self): - self.cpp_info.components["icu-data"].system_libs.append(tools.stdcpp_library(self)) + # icu uses c++, so add the c++ runtime + libcxx = stdcpp_library(self) + if libcxx: + self.cpp_info.components["icu-data"].system_libs.append(libcxx) # Alias of data CMake component - self.cpp_info.components["icu-data-alias"].names["cmake_find_package"] = "dt" - self.cpp_info.components["icu-data-alias"].names["cmake_find_package_multi"] = "dt" + self.cpp_info.components["icu-data-alias"].set_property("cmake_target_name", "ICU::dt") self.cpp_info.components["icu-data-alias"].requires = ["icu-data"] # icuuc - self.cpp_info.components["icu-uc"].names["cmake_find_package"] = "uc" - self.cpp_info.components["icu-uc"].names["cmake_find_package_multi"] = "uc" - self.cpp_info.components["icu-uc"].names["pkg_config"] = "icu-uc" - self.cpp_info.components["icu-uc"].libs = [self._lib_name("icuuc")] + self.cpp_info.components["icu-uc"].set_property("cmake_target_name", "ICU::uc") + self.cpp_info.components["icu-uc"].set_property("pkg_config_name", "icu-uc") + self.cpp_info.components["icu-uc"].libs = [f"{prefix}icuuc{suffix}"] self.cpp_info.components["icu-uc"].requires = ["icu-data"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["icu-uc"].system_libs = ["m", "pthread"] @@ -273,54 +271,67 @@ def package_info(self): self.cpp_info.components["icu-uc"].system_libs = ["advapi32"] # icui18n - self.cpp_info.components["icu-i18n"].names["cmake_find_package"] = "i18n" - self.cpp_info.components["icu-i18n"].names["cmake_find_package_multi"] = "i18n" - self.cpp_info.components["icu-i18n"].names["pkg_config"] = "icu-i18n" - self.cpp_info.components["icu-i18n"].libs = [self._lib_name("icuin" if self.settings.os == "Windows" else "icui18n")] + self.cpp_info.components["icu-i18n"].set_property("cmake_target_name", "ICU::i18n") + self.cpp_info.components["icu-i18n"].set_property("pkg_config_name", "icu-i18n") + icui18n_libname = "icuin" if self.settings.os == "Windows" else "icui18n" + self.cpp_info.components["icu-i18n"].libs = [f"{prefix}{icui18n_libname}{suffix}"] self.cpp_info.components["icu-i18n"].requires = ["icu-uc"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["icu-i18n"].system_libs = ["m"] # Alias of i18n CMake component - self.cpp_info.components["icu-i18n-alias"].names["cmake_find_package"] = "in" - self.cpp_info.components["icu-i18n-alias"].names["cmake_find_package_multi"] = "in" + self.cpp_info.components["icu-i18n-alias"].set_property("cmake_target_name", "ICU::in") self.cpp_info.components["icu-i18n-alias"].requires = ["icu-i18n"] # icuio - self.cpp_info.components["icu-io"].names["cmake_find_package"] = "io" - self.cpp_info.components["icu-io"].names["cmake_find_package_multi"] = "io" - self.cpp_info.components["icu-io"].names["pkg_config"] = "icu-io" - self.cpp_info.components["icu-io"].libs = [self._lib_name("icuio")] - self.cpp_info.components["icu-io"].requires = ["icu-i18n", "icu-uc"] - - # icutu - self.cpp_info.components["icu-tu"].names["cmake_find_package"] = "tu" - self.cpp_info.components["icu-tu"].names["cmake_find_package_multi"] = "tu" - self.cpp_info.components["icu-tu"].libs = [self._lib_name("icutu")] - self.cpp_info.components["icu-tu"].requires = ["icu-i18n", "icu-uc"] - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["icu-tu"].system_libs = ["pthread"] - - # icutest - self.cpp_info.components["icu-test"].names["cmake_find_package"] = "test" - self.cpp_info.components["icu-test"].names["cmake_find_package_multi"] = "test" - self.cpp_info.components["icu-test"].libs = [self._lib_name("icutest")] - self.cpp_info.components["icu-test"].requires = ["icu-tu", "icu-uc"] - - if self.options.data_packaging in ["files", "archive"]: + if self.options.with_icuio: + self.cpp_info.components["icu-io"].set_property("cmake_target_name", "ICU::io") + self.cpp_info.components["icu-io"].set_property("pkg_config_name", "icu-io") + self.cpp_info.components["icu-io"].libs = [f"{prefix}icuio{suffix}"] + self.cpp_info.components["icu-io"].requires = ["icu-i18n", "icu-uc"] + + if self.settings.os != "Windows" and self.options.data_packaging in ["files", "archive"]: + self.cpp_info.components["icu-data"].resdirs = ["res"] data_path = os.path.join(self.package_folder, "res", self._data_filename).replace("\\", "/") - self.output.info("Appending ICU_DATA environment variable: {}".format(data_path)) + self.runenv_info.prepend_path("ICU_DATA", data_path) + if self._enable_icu_tools or self.options.with_extras: + self.buildenv_info.prepend_path("ICU_DATA", data_path) + + if self._enable_icu_tools: + # icutu + self.cpp_info.components["icu-tu"].set_property("cmake_target_name", "ICU::tu") + self.cpp_info.components["icu-tu"].libs = [f"{prefix}icutu{suffix}"] + self.cpp_info.components["icu-tu"].requires = ["icu-i18n", "icu-uc"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["icu-tu"].system_libs = ["pthread"] + + # icutest + self.cpp_info.components["icu-test"].set_property("cmake_target_name", "ICU::test") + self.cpp_info.components["icu-test"].libs = [f"{prefix}icutest{suffix}"] + self.cpp_info.components["icu-test"].requires = ["icu-tu", "icu-uc"] + + # TODO: to remove after conan v2 + self.cpp_info.names["cmake_find_package"] = "ICU" + self.cpp_info.names["cmake_find_package_multi"] = "ICU" + self.cpp_info.components["icu-data"].names["cmake_find_package"] = "data" + self.cpp_info.components["icu-data"].names["cmake_find_package_multi"] = "data" + self.cpp_info.components["icu-data-alias"].names["cmake_find_package"] = "dt" + self.cpp_info.components["icu-data-alias"].names["cmake_find_package_multi"] = "dt" + self.cpp_info.components["icu-uc"].names["cmake_find_package"] = "uc" + self.cpp_info.components["icu-uc"].names["cmake_find_package_multi"] = "uc" + self.cpp_info.components["icu-i18n"].names["cmake_find_package"] = "i18n" + self.cpp_info.components["icu-i18n"].names["cmake_find_package_multi"] = "i18n" + self.cpp_info.components["icu-i18n-alias"].names["cmake_find_package"] = "in" + self.cpp_info.components["icu-i18n-alias"].names["cmake_find_package_multi"] = "in" + if self.options.with_icuio: + self.cpp_info.components["icu-io"].names["cmake_find_package"] = "io" + self.cpp_info.components["icu-io"].names["cmake_find_package_multi"] = "io" + if self.settings.os != "Windows" and self.options.data_packaging in ["files", "archive"]: self.env_info.ICU_DATA.append(data_path) - - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) - - def _lib_name(self, lib): - name = lib - if self.settings.os == "Windows": - if not self.options.shared: - name = "s" + name - if self.settings.build_type == "Debug": - name += "d" - return name + if self._enable_icu_tools: + self.cpp_info.components["icu-tu"].names["cmake_find_package"] = "tu" + self.cpp_info.components["icu-tu"].names["cmake_find_package_multi"] = "tu" + self.cpp_info.components["icu-test"].names["cmake_find_package"] = "test" + self.cpp_info.components["icu-test"].names["cmake_find_package_multi"] = "test" + if self._enable_icu_tools or self.options.with_extras: + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/icu/all/patches/0001-69.1-fix-mingw.patch b/recipes/icu/all/patches/0001-69.1-fix-mingw.patch new file mode 100644 index 0000000000000..61d3b8f65314b --- /dev/null +++ b/recipes/icu/all/patches/0001-69.1-fix-mingw.patch @@ -0,0 +1,43 @@ +--- source/config/mh-mingw64 ++++ source/config/mh-mingw64 +@@ -94,7 +94,7 @@ + # This is also for backwards compatibility. + DATA_STUBNAME = dt + I18N_STUBNAME = in +-LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX) ++#LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX) + + #SH### copied from Makefile.inc + #SH## for icu-config to test with +@@ -102,13 +102,13 @@ + #SH#ICULIBS_COMMON_LIB_NAME_A="${LIBICU}${COMMON_STUBNAME}${ICULIBSUFFIX}.${A}" + + #SH#ICULIBS_DATA="-l$(ICUPREFIX)$(DATA_STUBNAME)$(ICULIBSUFFIX)" +-ICULIBS_DT="-l$(ICUPREFIX)$(DATA_STUBNAME)$(ICULIBSUFFIX)" +-ICULIBS_I18N="-l$(ICUPREFIX)$(I18N_STUBNAME)$(ICULIBSUFFIX)" +-ICULIBS_LX="-l$(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)$(LAYOUTEX_STUBNAME)$(ICULIBSUFFIX)" +-ICULIBS_IO="-l$(ICUPREFIX)$(IO_STUBNAME)$(ICULIBSUFFIX)" +-ICULIBS_UC="-l$(ICUPREFIX)$(COMMON_STUBNAME)$(ICULIBSUFFIX)" +-ICULIBS_CTESTFW="-l$(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)$(CTESTFW_STUBNAME)$(ICULIBSUFFIX)" +-ICULIBS_TOOLUTIL="-l$(ICUPREFIX)tu$(ICULIBSUFFIX)" ++#ICULIBS_DT="-l$(ICUPREFIX)$(DATA_STUBNAME)$(ICULIBSUFFIX)"" ++#ICULIBS_I18N="-l$(ICUPREFIX)$(I18N_STUBNAME)$(ICULIBSUFFIX)" ++#ICULIBS_LX="-l$(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)$(LAYOUTEX_STUBNAME)$(ICULIBSUFFIX)" ++#ICULIBS_IO="-l$(ICUPREFIX)$(IO_STUBNAME)$(ICULIBSUFFIX)" ++#ICULIBS_UC="-l$(ICUPREFIX)$(COMMON_STUBNAME)$(ICULIBSUFFIX)" ++#ICULIBS_CTESTFW="-l$(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)$(CTESTFW_STUBNAME)$(ICULIBSUFFIX)" ++#ICULIBS_TOOLUTIL="-l$(ICUPREFIX)tu$(ICULIBSUFFIX)" + #SH# + #SH## ICULIBS is the set of libraries your application should link + #SH## with usually. Many applications will want to add ${ICULIBS_I18N} as well. +--- source/data/Makefile.in ++++ source/data/Makefile.in +@@ -207,7 +207,7 @@ + ifneq ($(ICUDATA_SOURCE_IS_NATIVE_TARGET),YES) + # For MinGW, do we want the DLL to go in the bin location? + ifeq ($(MINGW_MOVEDLLSTOBINDIR),YES) +- $(PKGDATA_INVOKE) $(PKGDATA) -m $(PKGDATA_MODE) $(PKGDATA_VERSIONING) -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -s $(BUILDDIR) -p $(ICUDATA_NAME) $(PKGDATA_LIBNAME) $(PKGDATA_LIST) -I $(DESTDIR)$(bindir) ++ $(PKGDATA_INVOKE) $(PKGDATA) -m $(PKGDATA_MODE) $(PKGDATA_VERSIONING) -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -s $(BUILDDIR) -p $(ICUDATA_NAME) $(PKGDATA_LIBNAME) $(PKGDATA_LIST) -I $(ICUPKGDATA_INSTALL_DIR) + else + $(PKGDATA_INVOKE) $(PKGDATA) -m $(PKGDATA_MODE) $(PKGDATA_VERSIONING) -e $(ICUDATA_ENTRY_POINT) -T $(OUTTMPDIR) -s $(BUILDDIR) -p $(ICUDATA_NAME) $(PKGDATA_LIBNAME) $(PKGDATA_LIST) -I $(ICUPKGDATA_INSTALL_DIR) + endif diff --git a/recipes/icu/all/patches/0001-71.1-fix-emscripten.patch b/recipes/icu/all/patches/0001-71.1-fix-emscripten.patch new file mode 100644 index 0000000000000..5693ab70111d5 --- /dev/null +++ b/recipes/icu/all/patches/0001-71.1-fix-emscripten.patch @@ -0,0 +1,117 @@ +diff --git a/source/acinclude.m4 b/source/acinclude.m4 +index 507f41f..2980ef1 100644 +--- a/source/acinclude.m4 ++++ b/source/acinclude.m4 +@@ -84,6 +84,7 @@ x86_64-*-cygwin) + *-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;; + *-*-nto*) icu_cv_host_frag=mh-qnx ;; + *-ncr-*) icu_cv_host_frag=mh-mpras ;; ++wasm*-*-emscripten*) icu_cv_host_frag=mh-emscripten ;; + *) icu_cv_host_frag=mh-unknown ;; + esac + ] +diff --git a/source/config/mh-emscripten b/source/config/mh-emscripten +new file mode 100644 +index 0000000..ee2b90b +--- /dev/null ++++ b/source/config/mh-emscripten +@@ -0,0 +1,86 @@ ++## Emscripten-specific setup ++## Copyright (c) 1999-2013, International Business Machines Corporation and ++## others. All Rights Reserved. ++## Commands to generate dependency files ++GEN_DEPS.c= $(CC) -E -MM $(DEFS) $(CPPFLAGS) ++GEN_DEPS.cc= $(CXX) -E -MM $(DEFS) $(CPPFLAGS) $(CXXFLAGS) ++ ++## Flags for position independent code ++SHAREDLIBCFLAGS = -fPIC ++SHAREDLIBCXXFLAGS = -fPIC ++SHAREDLIBCPPFLAGS = -DPIC ++ ++## Additional flags when building libraries and with threads ++THREADSCPPFLAGS = -D_REENTRANT ++LIBCPPFLAGS = ++ ++## Compiler switch to embed a runtime search path ++LD_RPATH= -Wl,-zorigin,-rpath,'$$'ORIGIN ++LD_RPATH_PRE = -Wl,-rpath, ++ ++## Force RPATH=$ORIGIN to locate own dependencies w/o need for LD_LIBRARY_PATH: ++ENABLE_RPATH=YES ++RPATHLDFLAGS=${LD_RPATH_PRE}'$$ORIGIN' ++ ++## These are the library specific LDFLAGS ++#LDFLAGSICUDT=-nodefaultlibs -nostdlib ++# Debian change: linking icudata as data only causes too many problems. ++LDFLAGSICUDT= ++ ++## Compiler switch to embed a library name ++# The initial tab in the next line is to prevent icu-config from reading it. ++ LD_SONAME = -Wl,-soname -Wl,$(notdir $(MIDDLE_SO_TARGET)) ++#SH# # We can't depend on MIDDLE_SO_TARGET being set. ++#SH# LD_SONAME= ++ ++## Shared library options ++LD_SOOPTIONS= -Wl,-Bsymbolic-functions ++ ++## Shared object suffix ++SO = so ++## Non-shared intermediate object suffix ++STATIC_O = o ++ ++## Compilation rules ++# WASM needs -pthread for atomics support ++%.$(STATIC_O): $(srcdir)/%.c ++ $(call SILENT_COMPILE,$(strip $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS)) -pthread -o $@ $<) ++ ++%.$(STATIC_O): $(srcdir)/%.cpp ++ $(call SILENT_COMPILE,$(strip $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS)) -pthread -o $@ $<) ++ ++ ++## Dependency rules ++%.d: $(srcdir)/%.c ++ $(call ICU_MSG,(deps)) $< ++ @$(SHELL) -ec '$(GEN_DEPS.c) $< \ ++ | sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \ ++ [ -s $@ ] || rm -f $@' ++ ++%.d: $(srcdir)/%.cpp ++ $(call ICU_MSG,(deps)) $< ++ @$(SHELL) -ec '$(GEN_DEPS.cc) $< \ ++ | sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \ ++ [ -s $@ ] || rm -f $@' ++ ++## Versioned libraries rules ++ ++%.$(SO).$(SO_TARGET_VERSION_MAJOR): %.$(SO).$(SO_TARGET_VERSION) ++ $(RM) $@ && ln -s ${ header unless __STRICT_ANSI__ is defined. +-// __GNUC__ is set by both gcc and clang. +-#undef __STRICT_ANSI__ +-#endif +- + #include "locmap.h" + #include "unicode/ustdio.h" + diff --git a/recipes/icu/all/test_package/CMakeLists.txt b/recipes/icu/all/test_package/CMakeLists.txt index 5c4b04d3644b4..4275c0782ed46 100644 --- a/recipes/icu/all/test_package/CMakeLists.txt +++ b/recipes/icu/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(ICU REQUIRED uc) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ICU::uc) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE ICU::uc) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/icu/all/test_package/conanfile.py b/recipes/icu/all/test_package/conanfile.py index 868204167ae9a..0a6bc68712d90 100644 --- a/recipes/icu/all/test_package/conanfile.py +++ b/recipes/icu/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, tools, CMake +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -class ICUTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/icu/all/test_v1_package/CMakeLists.txt b/recipes/icu/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/icu/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/icu/all/test_v1_package/conanfile.py b/recipes/icu/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..9be729bcbe9ce --- /dev/null +++ b/recipes/icu/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, tools, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/icu/config.yml b/recipes/icu/config.yml index e819d0613838f..a50d69cbe08f0 100644 --- a/recipes/icu/config.yml +++ b/recipes/icu/config.yml @@ -1,13 +1,17 @@ versions: - "64.2": + "72.1": folder: all - "65.1": + "71.1": folder: all - "66.1": + "70.1": + folder: all + "69.1": + folder: all + "68.2": folder: all "67.1": folder: all - "68.1": + "66.1": folder: all - "68.2": + "65.1": folder: all diff --git a/recipes/ignition-cmake/all/CMakeLists.txt b/recipes/ignition-cmake/all/CMakeLists.txt index bd3083b512cb9..8d6da516c42c7 100644 --- a/recipes/ignition-cmake/all/CMakeLists.txt +++ b/recipes/ignition-cmake/all/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.10.2) project(cmake_wrapper) include(conanbuildinfo.cmake) diff --git a/recipes/ignition-cmake/all/conandata.yml b/recipes/ignition-cmake/all/conandata.yml index c10346cf38cbf..91e85702d37b5 100644 --- a/recipes/ignition-cmake/all/conandata.yml +++ b/recipes/ignition-cmake/all/conandata.yml @@ -1,8 +1,15 @@ sources: "2.5.0": - url: "https://github.com/ignitionrobotics/ign-cmake/archive/ignition-cmake2_2.5.0.zip" - sha256: "6d35f015e259ec955f3abda64358a705ce5b3376c3df2ab5f0c17bea4b4e2f68" + url: "https://github.com/gazebosim/gz-cmake/archive/ignition-cmake2_2.5.0.zip" + sha256: "30945958fbe598f654d30de926a798f9055b1c635f7d85441ecba1ebe0804d2d" + "2.10.0": + url: "https://github.com/gazebosim/gz-cmake/archive/refs/tags/ignition-cmake2_2.10.0.tar.gz" + sha256: "48a01131731b09c32cfc7d577c4db378fb02e49a071e24c9299624766e1d05a2" + patches: "2.5.0": - base_path: "source_subfolder" patch_file: "patches/0001-cmake-fixes.patch" + "2.10.0": + - base_path: "source_subfolder" + patch_file: "patches/0002-ignition-cmake-2.10.0-fixes.patch" diff --git a/recipes/ignition-cmake/all/conanfile.py b/recipes/ignition-cmake/all/conanfile.py index 4d25fe6104a13..f09f2bd8badbc 100644 --- a/recipes/ignition-cmake/all/conanfile.py +++ b/recipes/ignition-cmake/all/conanfile.py @@ -1,21 +1,26 @@ -import glob +from conans import CMake, ConanFile, tools, RunEnvironment +import conan.tools.files import os - -from conans import CMake, ConanFile, tools +import textwrap class IgnitionCmakeConan(ConanFile): name = "ignition-cmake" license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/ignitionrobotics/ign-cmake" + homepage = "https://github.com/gazebosim/gz-cmake" description = "A set of CMake modules that are used by the C++-based Ignition projects." topics = ("ignition", "robotics", "cmake") - generators = "cmake" + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" exports_sources = "CMakeLists.txt", "patches/**" _cmake = None + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") + @property def _source_subfolder(self): return "source_subfolder" @@ -28,14 +33,17 @@ def _configure_cmake(self): return self._cmake self._cmake = CMake(self) self._cmake.definitions["CMAKE_INSTALL_DATAROOTDIR"] = "lib" + self._cmake.definitions["SKIP_component_name"] = False self._cmake.configure(source_folder=self._source_subfolder) return self._cmake def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(glob.glob("ign-cmake*")[0], self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): + version_major = tools.Version(self.version).major + env_build = RunEnvironment(self) for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) cmake = self._configure_cmake() @@ -46,12 +54,62 @@ def package(self): cmake = self._configure_cmake() cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + version_major = tools.Version(self.version).major + cmake_config_files_dir = os.path.join(self.package_folder, "lib", "cmake",f"ignition-cmake{version_major}") + files = os.listdir(cmake_config_files_dir) + + # retain the special config file for utilities target provided by ignition-cmake + # removing it from the list + files.remove(f"ignition-cmake{version_major}-utilities-targets.cmake") + + # remove all other xxx.cmake files from the list + for file in files: + if file.endswith(".cmake"): + os.remove(os.path.join(cmake_config_files_dir, file)) + + # add version information for downstream dependencies consuming ign-cmake through cmake_find_package generators + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path), + tools.Version(self.version) + ) + + @staticmethod + def _create_cmake_module_variables(module_file, version): + # the version info is needed by downstream ignition-dependencies + content = textwrap.dedent("""\ + set(ignition-cmake{major}_VERSION_MAJOR {major}) + set(ignition-cmake{major}_VERSION_MINOR {minor}) + set(ignition-cmake{major}_VERSION_PATCH {patch}) + set(ignition-cmake{major}_VERSION_STRING "{major}.{minor}.{patch}") + """.format(major=version.major, minor=version.minor, patch=version.patch)) + tools.save(module_file, content) def package_info(self): version_major = tools.Version(self.version).major - self.cpp_info.names["cmake_find_package"] = "ignition-cmake{}".format(version_major) - self.cpp_info.names["cmake_find_package_multi"] = "ignition-cmake{}".format(version_major) - self.cpp_info.builddirs = [ - os.path.join("lib", "cmake", "ignition-cmake{}".format(version_major)), - os.path.join("lib", "cmake", "ignition-cmake{}".format(version_major), "cmake{}".format(version_major)), - ] + ign_cmake_component = f"ignition-cmake{version_major}" + base_module_path = os.path.join(self.package_folder, "lib", "cmake", ign_cmake_component) + ign_cmake_file = os.path.join(base_module_path, f"cmake{version_major}", "IgnCMake.cmake") + utils_targets_file = os.path.join(base_module_path, f"{ign_cmake_component}-utilities-targets.cmake") + + self.cpp_info.names["cmake_find_package"] = ign_cmake_component + self.cpp_info.names["cmake_find_package_multi"] = ign_cmake_component + self.cpp_info.names["cmake_paths"] = ign_cmake_component + + self.cpp_info.components[ign_cmake_component].names["cmake_find_package"] = ign_cmake_component + self.cpp_info.components[ign_cmake_component].names["cmake_find_package_multi"] = ign_cmake_component + self.cpp_info.components[ign_cmake_component].names["cmake_paths"] = ign_cmake_component + self.cpp_info.components[ign_cmake_component].builddirs.append(os.path.join(base_module_path, f"cmake{version_major}")) + + self.cpp_info.components[ign_cmake_component].build_modules["cmake_find_package"] = [self._module_file_rel_path, ign_cmake_file] + self.cpp_info.components[ign_cmake_component].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path, ign_cmake_file] + self.cpp_info.components[ign_cmake_component].build_modules["cmake_paths"] = [self._module_file_rel_path, ign_cmake_file] + + self.cpp_info.components["utilities"].names["cmake_find_package"] = "utilities" + self.cpp_info.components["utilities"].names["cmake_find_package_multi"] = "utilities" + self.cpp_info.components["utilities"].names["cmake_paths"] = "utilities" + self.cpp_info.components["utilities"].includedirs.append(f"include/ignition/cmake{version_major}") + + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path, ign_cmake_file]) + self.cpp_info.components["utilities"].build_modules["cmake_find_package"] = [self._module_file_rel_path, ign_cmake_file, utils_targets_file] + self.cpp_info.components["utilities"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path, ign_cmake_file, utils_targets_file] + self.cpp_info.components["utilities"].build_modules["cmake_paths"] = [self._module_file_rel_path, ign_cmake_file, utils_targets_file] diff --git a/recipes/ignition-cmake/all/patches/0001-cmake-fixes.patch b/recipes/ignition-cmake/all/patches/0001-cmake-fixes.patch index 1a11ae8d6b0e5..c08ee665467ac 100644 --- a/recipes/ignition-cmake/all/patches/0001-cmake-fixes.patch +++ b/recipes/ignition-cmake/all/patches/0001-cmake-fixes.patch @@ -1,3 +1,45 @@ +--- cmake/IgnCMake.cmake ++++ cmake/IgnCMake.cmake +@@ -36,3 +36,10 @@ include(IgnPkgConfig) + #============================================================================ + include(CMakePackageConfigHelpers) + include(CMakeParseArguments) ++ ++set(IGNITION_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}") ++set(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../..") ++set(IGNITION_CMAKE_DOXYGEN_DIR "${PACKAGE_PREFIX_DIR}/lib/ignition/ignition-cmake2/doxygen") ++set(IGNITION_CMAKE_CODECHECK_DIR "${PACKAGE_PREFIX_DIR}/lib/ignition/ignition-cmake2/codecheck") ++set(IGNITION_CMAKE_BENCHMARK_DIR "${PACKAGE_PREFIX_DIR}/lib/ignition/ignition-cmake2/benchmark") ++set(IGNITION_CMAKE_TOOLS_DIR "${PACKAGE_PREFIX_DIR}/lib/ignition/ignition-cmake2/tools") +\ No newline at end of file + +--- cmake/IgnSetCompilerFlags.cmake ++++ cmake/IgnSetCompilerFlags.cmake +@@ -77,9 +77,9 @@ macro(ign_setup_unix) + exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL + "processor type (i386 and x86_64)") +- if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") +- set(IGN_ADD_fPIC_TO_LIBRARIES true) +- endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") ++ #if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") ++ # set(IGN_ADD_fPIC_TO_LIBRARIES true) ++ #endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + endif(CMAKE_UNAME) + + endmacro() +@@ -93,7 +93,9 @@ macro(ign_setup_apple) + # 10.x.x = Mac OSX Snow Leopard (10.6) + # 11.x.x = Mac OSX Lion (10.7) + # 12.x.x = Mac OSX Mountain Lion (10.8) +- if(${CMAKE_SYSTEM_VERSION} LESS 10) ++ if(NOT CMAKE_SYSTEM_VERSION) ++ return() ++ elseif(${CMAKE_SYSTEM_VERSION} LESS 10) + add_definitions(-DMAC_OS_X_VERSION=1050) + elseif(${CMAKE_SYSTEM_VERSION} GREATER 10 AND ${CMAKE_SYSTEM_VERSION} LESS 11) + add_definitions(-DMAC_OS_X_VERSION=1060) + --- cmake/IgnUtils.cmake +++ cmake/IgnUtils.cmake @@ -1372,7 +1372,7 @@ macro(_ign_add_library_or_component) @@ -9,14 +51,3 @@ set(implementation_file_name "${binary_include_dir}/detail/Export.hh") ---- cmake/IgnSetCompilerFlags.cmake -+++ cmake/IgnSetCompilerFlags.cmake -@@ -78,7 +78,7 @@ macro(ign_setup_unix) - set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL - "processor type (i386 and x86_64)") - if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") -- set(IGN_ADD_fPIC_TO_LIBRARIES true) -+ #set(IGN_ADD_fPIC_TO_LIBRARIES true) - endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") - endif(CMAKE_UNAME) - diff --git a/recipes/ignition-cmake/all/patches/0002-ignition-cmake-2.10.0-fixes.patch b/recipes/ignition-cmake/all/patches/0002-ignition-cmake-2.10.0-fixes.patch new file mode 100644 index 0000000000000..1294ad7a56c4b --- /dev/null +++ b/recipes/ignition-cmake/all/patches/0002-ignition-cmake-2.10.0-fixes.patch @@ -0,0 +1,53 @@ +--- cmake/IgnCMake.cmake ++++ cmake/IgnCMake.cmake +@@ -36,3 +36,10 @@ include(IgnPkgConfig) + #============================================================================ + include(CMakePackageConfigHelpers) + include(CMakeParseArguments) ++ ++set(IGNITION_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}") ++set(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../..") ++set(IGNITION_CMAKE_DOXYGEN_DIR "${PACKAGE_PREFIX_DIR}/lib/ignition/ignition-cmake2/doxygen") ++set(IGNITION_CMAKE_CODECHECK_DIR "${PACKAGE_PREFIX_DIR}/lib/ignition/ignition-cmake2/codecheck") ++set(IGNITION_CMAKE_BENCHMARK_DIR "${PACKAGE_PREFIX_DIR}/lib/ignition/ignition-cmake2/benchmark") ++set(IGNITION_CMAKE_TOOLS_DIR "${PACKAGE_PREFIX_DIR}/lib/ignition/ignition-cmake2/tools") +\ No newline at end of file + +--- cmake/IgnSetCompilerFlags.cmake ++++ cmake/IgnSetCompilerFlags.cmake +@@ -77,9 +77,9 @@ macro(ign_setup_unix) + exec_program(${CMAKE_UNAME} ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL + "processor type (i386 and x86_64)") +- if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") +- set(IGN_ADD_fPIC_TO_LIBRARIES true) +- endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") ++ #if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") ++ # set(IGN_ADD_fPIC_TO_LIBRARIES true) ++ #endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + endif(CMAKE_UNAME) + + endmacro() +@@ -93,7 +93,9 @@ macro(ign_setup_apple) + # 10.x.x = Mac OSX Snow Leopard (10.6) + # 11.x.x = Mac OSX Lion (10.7) + # 12.x.x = Mac OSX Mountain Lion (10.8) +- if(${CMAKE_SYSTEM_VERSION} LESS 10) ++ if(NOT CMAKE_SYSTEM_VERSION) ++ return() ++ elseif(${CMAKE_SYSTEM_VERSION} LESS 10) + add_definitions(-DMAC_OS_X_VERSION=1050) + elseif(${CMAKE_SYSTEM_VERSION} GREATER 10 AND ${CMAKE_SYSTEM_VERSION} LESS 11) + add_definitions(-DMAC_OS_X_VERSION=1060) + +--- cmake/IgnUtils.cmake ++++ cmake/IgnUtils.cmake +@@ -1396,7 +1396,7 @@ macro(_ign_add_library_or_component) + # Generate export macro headers + # Note: INTERFACE libraries do not need the export header + set(binary_include_dir +- "${CMAKE_BINARY_DIR}/include/${include_dir}") ++ "${PROJECT_BINARY_DIR}/include/${include_dir}") + + set(implementation_file_name "${binary_include_dir}/detail/Export.hh") + diff --git a/recipes/ignition-cmake/all/test_package/CMakeLists.txt b/recipes/ignition-cmake/all/test_package/CMakeLists.txt index 914b0a5e144c8..9595663869a7f 100644 --- a/recipes/ignition-cmake/all/test_package/CMakeLists.txt +++ b/recipes/ignition-cmake/all/test_package/CMakeLists.txt @@ -4,9 +4,13 @@ project(test_package VERSION 1.0) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -find_package(ignition-cmake2 REQUIRED CONFIG) +set(IGN_CMAKE_VER "" CACHE STRING "Version of igition-cmake") -include(IgnUtils) +if(NOT IGN_CMAKE_VER) + message(FATAL_ERROR "IGN_CMAKE_VER not set") +endif() -ign_setup_packages() +find_package(ignition-cmake${IGN_CMAKE_VER} REQUIRED COMPONENTS utilities) + +ign_configure_project() ign_configure_build() diff --git a/recipes/ignition-cmake/all/test_package/conanfile.py b/recipes/ignition-cmake/all/test_package/conanfile.py index 8fc4d845e0a4a..5b49fe0a15144 100644 --- a/recipes/ignition-cmake/all/test_package/conanfile.py +++ b/recipes/ignition-cmake/all/test_package/conanfile.py @@ -5,10 +5,15 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package" + + test_type = "explicit" + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) + cmake.definitions["IGN_CMAKE_VER"] = tools.Version(self.deps_cpp_info["ignition-cmake"].version).major cmake.configure() cmake.build() diff --git a/recipes/ignition-cmake/all/test_package/src/CMakeLists.txt b/recipes/ignition-cmake/all/test_package/src/CMakeLists.txt index dfec859541ab1..e050db890afd7 100644 --- a/recipes/ignition-cmake/all/test_package/src/CMakeLists.txt +++ b/recipes/ignition-cmake/all/test_package/src/CMakeLists.txt @@ -1,2 +1,3 @@ cmake_minimum_required(VERSION 3.1) ign_add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ignition-cmake${IGN_CMAKE_VER}::utilities) diff --git a/recipes/ignition-cmake/all/test_package/src/test_package.cpp b/recipes/ignition-cmake/all/test_package/src/test_package.cpp index d7515ee191e44..e46519ac61f93 100644 --- a/recipes/ignition-cmake/all/test_package/src/test_package.cpp +++ b/recipes/ignition-cmake/all/test_package/src/test_package.cpp @@ -1,4 +1,6 @@ #include +#include +#include int main() { std::cout << "Hello world!\n"; diff --git a/recipes/ignition-cmake/config.yml b/recipes/ignition-cmake/config.yml index 6b8dbbbe27d93..90aed98c5dd74 100644 --- a/recipes/ignition-cmake/config.yml +++ b/recipes/ignition-cmake/config.yml @@ -1,3 +1,5 @@ versions: "2.5.0": folder: all + "2.10.0": + folder: all diff --git a/recipes/ignition-math/all/CMakeLists.txt b/recipes/ignition-math/all/CMakeLists.txt index bd3083b512cb9..4c95ca5e84716 100644 --- a/recipes/ignition-math/all/CMakeLists.txt +++ b/recipes/ignition-math/all/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.10.2) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) add_subdirectory(source_subfolder) diff --git a/recipes/ignition-math/all/conandata.yml b/recipes/ignition-math/all/conandata.yml index 37128bd784a00..ba2f8a5f8591e 100644 --- a/recipes/ignition-math/all/conandata.yml +++ b/recipes/ignition-math/all/conandata.yml @@ -1,10 +1,14 @@ sources: "6.7.0": - url: "https://github.com/ignitionrobotics/ign-math/archive/ignition-math6_6.7.0.zip" - sha256: "5427a17de6ef9f60ee497b9a170a4e92517de9496781dac91f50cdbeb3364b22" + url: "https://github.com/gazebosim/gz-math/archive/ignition-math6_6.7.0.tar.gz" + sha256: "e5dac5aca6a117af8bd07ebca6e4ec8255682453487bf8d706bdb0315d17d6af" + "6.10.0": + url: "https://github.com/gazebosim/gz-math/archive/ignition-math6_6.10.0.tar.gz" + sha256: "94e853e1dfba97ebec4b6152691a89af1e94660b02f4ecdf04356b763c2848bd" patches: "6.7.0": - base_path: "source_subfolder" - patch_file: "patches/0001-Define-time_regex-locally.patch" + patch_file: "patches/0001-ign-math-6.7.0-cmake-fixes.patch" + "6.10.0": - base_path: "source_subfolder" - patch_file: "patches/0002-cmake-fixes.patch" + patch_file: "patches/0002-ign-math-6.10.0-cmake-fixes.patch" diff --git a/recipes/ignition-math/all/conanfile.py b/recipes/ignition-math/all/conanfile.py index 7ca53982cf08a..3af2ddca7b420 100644 --- a/recipes/ignition-math/all/conanfile.py +++ b/recipes/ignition-math/all/conanfile.py @@ -1,7 +1,8 @@ import os - +import conan.tools.files from conans import CMake, ConanFile, tools from conans.errors import ConanInvalidConfiguration +import textwrap required_conan_version = ">=1.29.1" @@ -10,7 +11,7 @@ class IgnitionMathConan(ConanFile): name = "ignition-math" license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" - homepage = "https://ignitionrobotics.org/libs/math" + homepage = "https://gazebosim.org/libs/math" description = " Math classes and functions for robot applications" topics = ("ignition", "math", "robotics", "gazebo") settings = "os", "compiler", "build_type", "arch" @@ -66,17 +67,17 @@ def configure(self): def requirements(self): self.requires("eigen/3.3.9") + self.requires("doxygen/1.8.17") + self.requires("swig/4.0.2") def build_requirements(self): - self.build_requires("ignition-cmake/2.5.0") + if int(tools.Version(self.version).minor) <= 8: + self.build_requires("ignition-cmake/2.5.0") + else: + self.build_requires("ignition-cmake/2.10.0") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - version_major = self.version.split(".")[0] - os.rename( - "ign-math-ignition-math{}_{}".format(version_major, self.version), - self._source_subfolder, - ) + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def _configure_cmake(self): if self._cmake: @@ -99,32 +100,66 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "share")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path), + tools.Version(self.version)) + # Remove MS runtime files for dll_pattern_to_remove in ["concrt*.dll", "msvcp*.dll", "vcruntime*.dll"]: tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), dll_pattern_to_remove) + @staticmethod + def _create_cmake_module_variables(module_file, version): + content = textwrap.dedent("""\ + set(ignition-math{major}_VERSION_MAJOR {major}) + set(ignition-math{major}_VERSION_MINOR {minor}) + set(ignition-math{major}_VERSION_PATCH {patch}) + set(ignition-math{major}_VERSION_STRING "{major}.{minor}.{patch}") + set(ignition-math{major}_INCLUDE_DIRS "${{CMAKE_CURRENT_LIST_DIR}}/../../include/ignition/math{major}") + """.format(major=version.major, minor=version.minor, patch=version.patch)) + tools.save(module_file, content) + + def package_info(self): version_major = tools.Version(self.version).major - self.cpp_info.names["cmake_find_package"] = "ignition-math{}".format(version_major) - self.cpp_info.names["cmake_find_package_multi"] = "ignition-math{}".format(version_major) - - # cmake_find_package filename: ignition-math6-config.cmake - self.cpp_info.components["libignition-math"].libs = ["ignition-math{}".format(version_major)] - self.cpp_info.components["libignition-math"].includedirs.append("include/ignition/math{}".format(version_major)) - self.cpp_info.components["libignition-math"].names["cmake_find_package"] = "ignition-math{}".format(version_major) - self.cpp_info.components["libignition-math"].names["cmake_find_package_multi"] = "ignition-math{}".format(version_major) - self.cpp_info.components["libignition-math"].names["pkg_config"] = "ignition-math{}".format(version_major) - - # FIXME: create in file ignition-math6-eigen3-config.cmake - self.cpp_info.components["libignition-math-eigen3"].libs = [] - self.cpp_info.components["libignition-math-eigen3"].requires = ["libignition-math", "eigen::eigen"] - self.cpp_info.components["libignition-math-eigen3"].names["cmake_find_package"] = "ignition-math{}-eigen3".format(version_major) - self.cpp_info.components["libignition-math-eigen3"].names["cmake_find_package_multi"] = "ignition-math{}-eigen3".format(version_major) - self.cpp_info.components["libignition-math-eigen3"].names["pkg_config"] = "ignition-math{}-eigen3".format(version_major) - - # FIXME: create in file ignition-math6-all-config.cmake - self.cpp_info.components["libignition-math-all"].libs = [] - self.cpp_info.components["libignition-math-all"].requires = ["libignition-math-eigen3"] - self.cpp_info.components["libignition-math-all"].names["cmake_find_package"] = "ignition-math{}-all".format(version_major) - self.cpp_info.components["libignition-math-all"].names["cmake_find_package_multi"] = "ignition-math{}-all".format(version_major) + lib_name = f"ignition-math{version_major}" + + self.cpp_info.names["cmake_find_package"] = lib_name + self.cpp_info.names["cmake_find_package_multi"] = lib_name + self.cpp_info.names["cmake_paths"] = lib_name + + self.cpp_info.components[lib_name].names["cmake_find_package"] = lib_name + self.cpp_info.components[lib_name].names["cmake_find_package_multi"] = lib_name + self.cpp_info.components[lib_name].names["cmake_paths"] = lib_name + self.cpp_info.components[lib_name].libs = [lib_name] + self.cpp_info.components[lib_name].includedirs.append(os.path.join("include", "ignition", "math"+version_major)) + self.cpp_info.components[lib_name].requires = ["swig::swig", "eigen::eigen", "doxygen::doxygen"] + + self.cpp_info.components[lib_name].builddirs = [self._module_file_rel_dir] + self.cpp_info.components[lib_name].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components[lib_name].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components[lib_name].build_modules["cmake_paths"] = [self._module_file_rel_path] + + self.cpp_info.components["eigen3"].names["cmake_find_package"] = "eigen3" + self.cpp_info.components["eigen3"].names["cmake_find_package_multi"] = "eigen3" + self.cpp_info.components["eigen3"].names["cmake_paths"] = "eigen3" + self.cpp_info.components["eigen3"].includedirs.append(os.path.join("include", "ignition", "math"+version_major)) + self.cpp_info.components["eigen3"].requires = ["eigen::eigen"] + + self.cpp_info.components["eigen3"].builddirs = [self._module_file_rel_dir] + self.cpp_info.components["eigen3"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["eigen3"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["eigen3"].build_modules["cmake_paths"] = [self._module_file_rel_path] + + def validate(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + raise ConanInvalidConfiguration("sorry, M1 builds are not currently supported, give up!") + + @property + def _module_file_rel_dir(self): + return os.path.join("lib", "cmake") + + @property + def _module_file_rel_path(self): + return os.path.join(self._module_file_rel_dir, f"conan-official-{self.name}-variables.cmake") + diff --git a/recipes/ignition-math/all/patches/0001-Define-time_regex-locally.patch b/recipes/ignition-math/all/patches/0001-Define-time_regex-locally.patch deleted file mode 100644 index 8bc14e3ce6170..0000000000000 --- a/recipes/ignition-math/all/patches/0001-Define-time_regex-locally.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 24a9b3284fcbf05cfec09d9cbd4de4d9977c8318 Mon Sep 17 00:00:00 2001 -From: Juan Oxoby -Date: Fri, 16 Oct 2020 21:28:37 -0700 -Subject: [PATCH] Define time_regex locally - ---- - include/ignition/math/Helpers.hh | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/include/ignition/math/Helpers.hh b/include/ignition/math/Helpers.hh -index 2dd5cc6..bd4d35f 100644 ---- a/include/ignition/math/Helpers.hh -+++ b/include/ignition/math/Helpers.hh -@@ -870,7 +870,7 @@ namespace ignition - // The following regex takes a time string in the general format of - // "dd hh:mm:ss.nnn" where n is milliseconds, if just one number is - // provided, it is assumed to be seconds -- static const std::regex time_regex( -+ static const char* time_regex_str = - "^([0-9]+ ){0,1}" // day: - // Any positive integer - -@@ -887,7 +887,7 @@ namespace ignition - // 0 - 9 - // 00 - 59 - -- "(\\.[0-9]{1,3}){0,1})$"); // millisecond: -+ "(\\.[0-9]{1,3}){0,1})$"; // millisecond: - // .0 - .9 - // .00 - .99 - // .000 - 0.999 -@@ -907,6 +907,7 @@ namespace ignition - uint64_t & numberMinutes, uint64_t & numberSeconds, - uint64_t & numberMilliseconds) - { -+ static const std::regex time_regex(time_regex_str); - std::smatch matches; - - // `matches` should always be a size of 6 as there are 6 matching --- -2.17.1 - diff --git a/recipes/ignition-math/all/patches/0001-ign-math-6.7.0-cmake-fixes.patch b/recipes/ignition-math/all/patches/0001-ign-math-6.7.0-cmake-fixes.patch new file mode 100644 index 0000000000000..d20c1234623ee --- /dev/null +++ b/recipes/ignition-math/all/patches/0001-ign-math-6.7.0-cmake-fixes.patch @@ -0,0 +1,64 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -39,7 +39,7 @@ ign_find_package( + ######################################## + # Include swig + find_package(SWIG QUIET) +-if (NOT SWIG_FOUND) ++if (1) + IGN_BUILD_WARNING("Swig is missing: Language interfaces are disabled.") + message (STATUS "Searching for swig - not found.") + else() +@@ -47,7 +47,7 @@ else() + endif() + + # Include other languages if swig was found +-if (SWIG_FOUND) ++if (0) + ######################################## + # Include ruby + find_package(Ruby 1.9 QUIET) +@@ -74,9 +74,9 @@ ign_create_packages() + #============================================================================ + # Configure documentation + #============================================================================ +-configure_file(${CMAKE_SOURCE_DIR}/api.md.in ${CMAKE_BINARY_DIR}/api.md) +-configure_file(${CMAKE_SOURCE_DIR}/tutorials.md.in ${CMAKE_BINARY_DIR}/tutorials.md) ++configure_file(${PROJECT_SOURCE_DIR}/api.md.in ${PROJECT_BINARY_DIR}/api.md) ++configure_file(${PROJECT_SOURCE_DIR}/tutorials.md.in ${PROJECT_BINARY_DIR}/tutorials.md) + + ign_create_docs( +- API_MAINPAGE_MD "${CMAKE_BINARY_DIR}/api.md" +- TUTORIALS_MAINPAGE_MD "${CMAKE_BINARY_DIR}/tutorials.md") ++ API_MAINPAGE_MD "${PROJECT_BINARY_DIR}/api.md" ++ TUTORIALS_MAINPAGE_MD "${PROJECT_BINARY_DIR}/tutorials.md") + +--- include/ignition/math/Helpers.hh ++++ include/ignition/math/Helpers.hh +@@ -870,7 +870,7 @@ namespace ignition + // The following regex takes a time string in the general format of + // "dd hh:mm:ss.nnn" where n is milliseconds, if just one number is + // provided, it is assumed to be seconds +- static const std::regex time_regex( ++ static const char* time_regex_str = + "^([0-9]+ ){0,1}" // day: + // Any positive integer + +@@ -887,7 +887,7 @@ namespace ignition + // 0 - 9 + // 00 - 59 + +- "(\\.[0-9]{1,3}){0,1})$"); // millisecond: ++ "(\\.[0-9]{1,3}){0,1})$"; // millisecond: + // .0 - .9 + // .00 - .99 + // .000 - 0.999 +@@ -907,6 +907,7 @@ namespace ignition + uint64_t & numberMinutes, uint64_t & numberSeconds, + uint64_t & numberMilliseconds) + { ++ static const std::regex time_regex(time_regex_str); + std::smatch matches; + + // `matches` should always be a size of 6 as there are 6 matching + diff --git a/recipes/ignition-math/all/patches/0002-cmake-fixes.patch b/recipes/ignition-math/all/patches/0002-cmake-fixes.patch deleted file mode 100644 index 274699ec54ea0..0000000000000 --- a/recipes/ignition-math/all/patches/0002-cmake-fixes.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -39,7 +39,7 @@ ign_find_package( - ######################################## - # Include swig - find_package(SWIG QUIET) --if (NOT SWIG_FOUND) -+if (1) - IGN_BUILD_WARNING("Swig is missing: Language interfaces are disabled.") - message (STATUS "Searching for swig - not found.") - else() -@@ -47,7 +47,7 @@ else() - endif() - - # Include other languages if swig was found --if (SWIG_FOUND) -+if (0) - ######################################## - # Include ruby - find_package(Ruby 1.9 QUIET) -@@ -74,9 +74,9 @@ ign_create_packages() - #============================================================================ - # Configure documentation - #============================================================================ --configure_file(${CMAKE_SOURCE_DIR}/api.md.in ${CMAKE_BINARY_DIR}/api.md) --configure_file(${CMAKE_SOURCE_DIR}/tutorials.md.in ${CMAKE_BINARY_DIR}/tutorials.md) -+configure_file(${PROJECT_SOURCE_DIR}/api.md.in ${PROJECT_BINARY_DIR}/api.md) -+configure_file(${PROJECT_SOURCE_DIR}/tutorials.md.in ${PROJECT_BINARY_DIR}/tutorials.md) - - ign_create_docs( -- API_MAINPAGE_MD "${CMAKE_BINARY_DIR}/api.md" -- TUTORIALS_MAINPAGE_MD "${CMAKE_BINARY_DIR}/tutorials.md") -+ API_MAINPAGE_MD "${PROJECT_BINARY_DIR}/api.md" -+ TUTORIALS_MAINPAGE_MD "${PROJECT_BINARY_DIR}/tutorials.md") diff --git a/recipes/ignition-math/all/patches/0002-ign-math-6.10.0-cmake-fixes.patch b/recipes/ignition-math/all/patches/0002-ign-math-6.10.0-cmake-fixes.patch new file mode 100644 index 0000000000000..8773ec682ea55 --- /dev/null +++ b/recipes/ignition-math/all/patches/0002-ign-math-6.10.0-cmake-fixes.patch @@ -0,0 +1,35 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -49,7 +49,7 @@ ign_find_package( + ######################################## + # Include swig + find_package(SWIG QUIET) +-if (NOT SWIG_FOUND) ++if (1) + IGN_BUILD_WARNING("Swig is missing: Language interfaces are disabled.") + message (STATUS "Searching for swig - not found.") + else() +@@ -57,7 +57,7 @@ else() + endif() + + # Include other languages if swig was found +-if (SWIG_FOUND) ++if (0) + ######################################## + # Include ruby + find_package(Ruby 1.9 QUIET) +@@ -109,9 +109,9 @@ ign_create_packages() + #============================================================================ + # Configure documentation + #============================================================================ +-configure_file(${CMAKE_SOURCE_DIR}/api.md.in ${CMAKE_BINARY_DIR}/api.md) +-configure_file(${CMAKE_SOURCE_DIR}/tutorials.md.in ${CMAKE_BINARY_DIR}/tutorials.md) ++configure_file(${PROJECT_SOURCE_DIR}/api.md.in ${PROJECT_BINARY_DIR}/api.md) ++configure_file(${PROJECT_SOURCE_DIR}/tutorials.md.in ${PROJECT_BINARY_DIR}/tutorials.md) + + ign_create_docs( +- API_MAINPAGE_MD "${CMAKE_BINARY_DIR}/api.md" +- TUTORIALS_MAINPAGE_MD "${CMAKE_BINARY_DIR}/tutorials.md") ++ API_MAINPAGE_MD "${PROJECT_BINARY_DIR}/api.md" ++ TUTORIALS_MAINPAGE_MD "${PROJECT_BINARY_DIR}/tutorials.md") + diff --git a/recipes/ignition-math/all/test_package/test_package.cpp b/recipes/ignition-math/all/test_package/test_package.cpp index 5322fc6f45036..e12402d7867df 100644 --- a/recipes/ignition-math/all/test_package/test_package.cpp +++ b/recipes/ignition-math/all/test_package/test_package.cpp @@ -1,7 +1,23 @@ + +/** + * @file test_package.cpp + * @author ggulglia(gajendra.gulgulia@gmail.com) + * @brief test examples to verify that conan recipe for ignition-math + * can be consumed + */ + #include #include +#include -int main(int argc, char **argv) +int main(int argc, char** argv) { - ignition::math::Angle a; + std::cout << "hello world from ignition-math test_package\n"; + + ignition::math::Vector3d point1{1, 3, 5}; + ignition::math::Vector3d point2{2, 4, 6}; + + double distance = point1.Distance(point2); + std::cout << "Distance from (" << point1 << ") to " + << point2 << " is " << distance << std::endl; } diff --git a/recipes/ignition-math/config.yml b/recipes/ignition-math/config.yml index 228513d664e8a..14ea09e27cafc 100644 --- a/recipes/ignition-math/config.yml +++ b/recipes/ignition-math/config.yml @@ -1,3 +1,5 @@ versions: "6.7.0": folder: all + "6.10.0": + folder: all diff --git a/recipes/ignition-tools/all/CMakeLists.txt b/recipes/ignition-tools/all/CMakeLists.txt new file mode 100644 index 0000000000000..f980aea13cc6d --- /dev/null +++ b/recipes/ignition-tools/all/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10.2) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +add_subdirectory(source_subfolder) diff --git a/recipes/ignition-tools/all/conandata.yml b/recipes/ignition-tools/all/conandata.yml new file mode 100644 index 0000000000000..8a58ba77dc143 --- /dev/null +++ b/recipes/ignition-tools/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.4.0": + url: "https://github.com/ignitionrobotics/ign-tools/archive/refs/tags/ignition-tools_1.4.0.tar.gz" + sha256: "fa3f7984ebb8f412133ea93368395adce426ae36c715a9f94f9509af7dac3b03" +patches: + "1.4.0": + - base_path: "source_subfolder" + patch_file: "patches/0003-ign-tools-1.4.0-cmake-fixes.patch" diff --git a/recipes/ignition-tools/all/conanfile.py b/recipes/ignition-tools/all/conanfile.py new file mode 100644 index 0000000000000..ba8d22e6561de --- /dev/null +++ b/recipes/ignition-tools/all/conanfile.py @@ -0,0 +1,105 @@ +import os +from conans import CMake, ConanFile, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.29.1" + + +class IgnitionToolsConan(ConanFile): + name = "ignition-tools" + license = "Apache-2.0" + homepage = "https://ignitionrobotics.org/libs/tools" + url = "https://github.com/conan-io/conan-center-index" + description = "Provides general purpose classes and functions designed for robotic applications.." + topics = ("ignition", "robotics", "tools") + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + generators = "cmake", "cmake_find_package_multi" + exports_sources = "CMakeLists.txt", "patches/**" + _cmake = None + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "gcc": "7", + "clang": "5", + "apple-clang": "10", + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn( + "{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler + ) + ) + else: + if tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration( + "{} requires c++17 support. The current compiler {} {} does not support it.".format( + self.name, + self.settings.compiler, + self.settings.compiler.version, + ) + ) + + def source(self): + tools.get(**self.conan_data["sources"][self.version],destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake is not None: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_TESTING"] = False + self._cmake.configure() + return self._cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + # Remove MS runtime files + for dll_pattern_to_remove in ["concrt*.dll", "msvcp*.dll", "vcruntime*.dll"]: + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), dll_pattern_to_remove) + + def package_info(self): + version_major = tools.Version(self.version).major + self.cpp_info.names["cmake_find_package"] = "ignition-tools{}".format(version_major) + self.cpp_info.names["cmake_find_package_multi"] = "ignition-tools{}".format(version_major) + + self.cpp_info.components["libignition-tools"].libs = ["ignition-tools-backward"] + self.cpp_info.components["libignition-tools"].includedirs.append("include/ignition/tools{}".format(version_major)) + self.cpp_info.components["libignition-tools"].names["cmake_find_package"] = "ignition-tools{}".format(version_major) + self.cpp_info.components["libignition-tools"].names["cmake_find_package_multi"] = "ignition-tools{}".format(version_major) + self.cpp_info.components["libignition-tools"].names["pkg_config"] = "ignition-tools{}".format(version_major) diff --git a/recipes/ignition-tools/all/patches/0001-ign-tools-1.0.0-cmake-fixes.patch b/recipes/ignition-tools/all/patches/0001-ign-tools-1.0.0-cmake-fixes.patch new file mode 100644 index 0000000000000..a02000ed7c157 --- /dev/null +++ b/recipes/ignition-tools/all/patches/0001-ign-tools-1.0.0-cmake-fixes.patch @@ -0,0 +1,25 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -251,7 +251,7 @@ else (build_errors) + ######################################## + # Make the package config files + configure_file( +- ${CMAKE_SOURCE_DIR}/cmake/pkgconfig/ignition.in ++ ${PROJECT_SOURCE_DIR}/cmake/pkgconfig/ignition.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc + DESTINATION ${LIB_INSTALL_DIR}/pkgconfig + +--- doc/CMakeLists.txt ++++ doc/CMakeLists.txt +@@ -1,8 +1,8 @@ + find_package(Doxygen) + + if (DOXYGEN_FOUND) +- configure_file(${CMAKE_SOURCE_DIR}/doc/ignition.in +- ${CMAKE_BINARY_DIR}/ignition.dox @ONLY) ++ configure_file(${PROJECT_SOURCE_DIR}/doc/ignition.in ++ ${PROJECT_BINARY_DIR}/ignition.dox @ONLY) + + add_custom_target(doc + diff --git a/recipes/ignition-tools/all/patches/0002-ign-tools-1.2.0-cmake-fixes.patch b/recipes/ignition-tools/all/patches/0002-ign-tools-1.2.0-cmake-fixes.patch new file mode 100644 index 0000000000000..301608c99c533 --- /dev/null +++ b/recipes/ignition-tools/all/patches/0002-ign-tools-1.2.0-cmake-fixes.patch @@ -0,0 +1,25 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -257,7 +257,7 @@ else (build_errors) + "${CMAKE_INSTALL_PREFIX}" + ) + configure_file( +- ${CMAKE_SOURCE_DIR}/cmake/pkgconfig/ignition.in ++ ${PROJECT_SOURCE_DIR}/cmake/pkgconfig/ignition.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc + DESTINATION ${PC_CONFIG_INSTALL_DIR} + +--- doc/CMakeLists.txt ++++ doc/CMakeLists.txt +@@ -1,8 +1,8 @@ + find_package(Doxygen) + + if (DOXYGEN_FOUND) +- configure_file(${CMAKE_SOURCE_DIR}/doc/ignition.in +- ${CMAKE_BINARY_DIR}/ignition.dox @ONLY) ++ configure_file(${PROJECT_SOURCE_DIR}/doc/ignition.in ++ ${PROJECT_BINARY_DIR}/ignition.dox @ONLY) + + add_custom_target(doc + diff --git a/recipes/ignition-tools/all/patches/0003-ign-tools-1.4.0-cmake-fixes.patch b/recipes/ignition-tools/all/patches/0003-ign-tools-1.4.0-cmake-fixes.patch new file mode 100644 index 0000000000000..3e856a0a90956 --- /dev/null +++ b/recipes/ignition-tools/all/patches/0003-ign-tools-1.4.0-cmake-fixes.patch @@ -0,0 +1,25 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -185,7 +185,7 @@ else (build_errors) + "${CMAKE_INSTALL_PREFIX}" + ) + configure_file( +- ${CMAKE_SOURCE_DIR}/cmake/pkgconfig/ignition.in ++ ${PROJECT_SOURCE_DIR}/cmake/pkgconfig/ignition.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc + DESTINATION ${PC_CONFIG_INSTALL_DIR} + +--- doc/CMakeLists.txt ++++ doc/CMakeLists.txt +@@ -1,8 +1,8 @@ + find_package(Doxygen) + + if (DOXYGEN_FOUND) +- configure_file(${CMAKE_SOURCE_DIR}/doc/ignition.in +- ${CMAKE_BINARY_DIR}/ignition.dox @ONLY) ++ configure_file(${PROJECT_SOURCE_DIR}/doc/ignition.in ++ ${PROJECT_BINARY_DIR}/ignition.dox @ONLY) + + add_custom_target(doc + diff --git a/recipes/ignition-tools/all/test_package/CMakeLists.txt b/recipes/ignition-tools/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..294e2c5ebc47c --- /dev/null +++ b/recipes/ignition-tools/all/test_package/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +set(IGN_TOOLS_MAJOR_VER "" CACHE STRING "Version of igition-tools") + +if(NOT IGN_TOOLS_MAJOR_VER) + message(FATAL_ERROR "IGN_MAJOR_MAJOR_VER not set") +endif() + +find_package(ignition-tools${IGN_TOOLS_MAJOR_VER} REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ignition-tools${IGN_TOOLS_MAJOR_VER}::ignition-tools${IGN_TOOLS_MAJOR_VER}) +set_target_properties(${PROJECT_NAME} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS ON +) diff --git a/recipes/ignition-tools/all/test_package/conanfile.py b/recipes/ignition-tools/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ad00162038ccc --- /dev/null +++ b/recipes/ignition-tools/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["IGN_TOOLS_MAJOR_VER"] = tools.Version(self.deps_cpp_info["ignition-tools"].version).major + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ignition-tools/all/test_package/test_package.cpp b/recipes/ignition-tools/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..262e67cc01fba --- /dev/null +++ b/recipes/ignition-tools/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include + + +int main(int argc, char **argv) +{ + std::cout << "Hello from ignition-tools test_package\n"; +} diff --git a/recipes/ignition-tools/config.yml b/recipes/ignition-tools/config.yml new file mode 100644 index 0000000000000..c957e4bc2d3c7 --- /dev/null +++ b/recipes/ignition-tools/config.yml @@ -0,0 +1,3 @@ +versions: + "1.4.0": + folder: all diff --git a/recipes/ignition-utils/all/CMakeLists.txt b/recipes/ignition-utils/all/CMakeLists.txt new file mode 100644 index 0000000000000..df60a2f8782db --- /dev/null +++ b/recipes/ignition-utils/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.10.0) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(source_subfolder) diff --git a/recipes/ignition-utils/all/conandata.yml b/recipes/ignition-utils/all/conandata.yml new file mode 100644 index 0000000000000..5ab6a4db54d3c --- /dev/null +++ b/recipes/ignition-utils/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "1.3.0": + url: "https://github.com/gazebosim/gz-utils/archive/refs/tags/ignition-utils1_1.3.0.tar.gz" + sha256: "062bfbbdc185e1dacc4ffd9e70572fc01e32d11782e991ae027541ee02858e92" + +patches: + "1.3.0": + - base_path: "source_subfolder" + patch_file: "patches/0001-ign-utils-1.3.0-cmake-fixes.patch" diff --git a/recipes/ignition-utils/all/conanfile.py b/recipes/ignition-utils/all/conanfile.py new file mode 100644 index 0000000000000..0086df1bf32b9 --- /dev/null +++ b/recipes/ignition-utils/all/conanfile.py @@ -0,0 +1,175 @@ +import os +from conans import CMake, ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import conan.tools.files +import textwrap + +required_conan_version = ">=1.29.1" + + +class IgnitionUitlsConan(ConanFile): + name = "ignition-utils" + license = "Apache-2.0" + homepage = "https://gazebosim.org/libs/utils" + url = "https://github.com/conan-io/conan-center-index" + description = "Provides general purpose classes and functions designed for robotic applications.." + topics = ("ignition", "robotics", "utils") + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], + "fPIC": [True, False], + "ign_utils_vendor_cli11": [True, False] + } + default_options = {"shared": False, + "fPIC": True, + "ign_utils_vendor_cli11": True + } + generators = "cmake", "cmake_find_package_multi" + exports_sources = "CMakeLists.txt", "patches/**" + _cmake = None + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "gcc": "7", + "clang": "5", + "apple-clang": "10", + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + raise ConanInvalidConfiguration("sorry, M1 builds are not currently supported, give up!") + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn( + "{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler + ) + ) + else: + if tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration( + "{} requires c++17 support. The current compiler {} {} does not support it.".format( + self.name, + self.settings.compiler, + self.settings.compiler.version, + ) + ) + + def requirements(self): + self.requires("doxygen/1.9.2") + if self.options.ign_utils_vendor_cli11: + self.requires("cli11/2.1.2") + + def build_requirements(self): + self.build_requires("ignition-cmake/2.10.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _configure_cmake(self): + if self._cmake is not None: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_TESTING"] = False + self._cmake.definitions["IGN_UTILS_VENDOR_CLI11"] = self.options.ign_utils_vendor_cli11 + self._cmake.definitions["CMAKE_FIND_DEBUG_MODE"] = "1" + self._cmake.configure() + return self._cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cli_header_src = os.path.join(self._source_subfolder, "cli", "include") + if int(tools.Version(self.version).minor) == 0: + cli_header_src = os.path.join(cli_header_src, "ignition", "utils", "cli") + else: + cli_header_src = os.path.join(cli_header_src, "external-cli", "ignition", "utils", "cli") + self.copy("*.hpp", src=cli_header_src, + dst="include/ignition/utils1/ignition/utils/cli") + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + # Remove MS runtime files + for dll_pattern_to_remove in ["concrt*.dll", "msvcp*.dll", "vcruntime*.dll"]: + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), dll_pattern_to_remove) + + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path), + tools.Version(self.version) + ) + + @staticmethod + def _create_cmake_module_variables(module_file, version): + content = textwrap.dedent("""\ + set(ignition-utils{major}_VERSION_MAJOR {major}) + set(ignition-utils{major}_VERSION_MINOR {minor}) + set(ignition-utils{major}_VERSION_PATCH {patch}) + set(ignition-utils{major}_VERSION_STRING "{major}.{minor}.{patch}") + """.format(major=version.major, minor=version.minor, patch=version.patch)) + tools.save(module_file, content) + + def package_info(self): + version_major = tools.Version(self.version).major + lib_name = f"ignition-utils{version_major}" + build_dirs = os.path.join(self.package_folder, "lib", "cmake") + include_dir = os.path.join("include", "ignition", "utils"+version_major) + self.cpp_info.names["cmake_find_package"] = lib_name + self.cpp_info.names["cmake_find_package_multi"] = lib_name + self.cpp_info.names["cmake_paths"] = lib_name + + self.cpp_info.components[lib_name].names["cmake_find_package"] = lib_name + self.cpp_info.components[lib_name].names["cmake_find_package_multi"] = lib_name + self.cpp_info.components[lib_name].names["cmake_paths"] = lib_name + self.cpp_info.components[lib_name].libs = [lib_name] + self.cpp_info.components[lib_name].includedirs.append(include_dir) + self.cpp_info.components[lib_name].requires = ["doxygen::doxygen"] + if self.options.ign_utils_vendor_cli11: + self.cpp_info.components[lib_name].requires.append("cli11::cli11") + + self.cpp_info.components[lib_name].builddirs.append(build_dirs) + self.cpp_info.components[lib_name].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components[lib_name].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components[lib_name].build_modules["cmake_paths"] = [self._module_file_rel_path] + + self.cpp_info.components["cli"].names["cmake_find_package"] = "cli" + self.cpp_info.components["cli"].names["cmake_find_package_multi"] = "cli" + self.cpp_info.components["cli"].names["cmake_paths"] = "cli" + self.cpp_info.components["cli"].includedirs.append(os.path.join(include_dir, "ignition", "utils")) + if self.options.ign_utils_vendor_cli11: + self.cpp_info.components["cli"].requires = ["cli11::cli11"] + + self.cpp_info.components["cli"].builddirs.append(build_dirs) + self.cpp_info.components["cli"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["cli"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["cli"].build_modules["cmake_paths"] = [self._module_file_rel_path] + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") diff --git a/recipes/ignition-utils/all/patches/0001-ign-utils-1.3.0-cmake-fixes.patch b/recipes/ignition-utils/all/patches/0001-ign-utils-1.3.0-cmake-fixes.patch new file mode 100644 index 0000000000000..ee8c623c903c5 --- /dev/null +++ b/recipes/ignition-utils/all/patches/0001-ign-utils-1.3.0-cmake-fixes.patch @@ -0,0 +1,17 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -50,9 +50,9 @@ ign_create_packages() + #============================================================================ + # Configure documentation + #============================================================================ +-configure_file(${CMAKE_SOURCE_DIR}/api.md.in ${CMAKE_BINARY_DIR}/api.md) +-configure_file(${CMAKE_SOURCE_DIR}/tutorials.md.in ${CMAKE_BINARY_DIR}/tutorials.md) ++configure_file(${PROJECT_SOURCE_DIR}/api.md.in ${PROJECT_BINARY_DIR}/api.md) ++configure_file(${PROJECT_SOURCE_DIR}/tutorials.md.in ${PROJECT_BINARY_DIR}/tutorials.md) + + ign_create_docs( +- API_MAINPAGE_MD "${CMAKE_BINARY_DIR}/api.md" +- TUTORIALS_MAINPAGE_MD "${CMAKE_BINARY_DIR}/tutorials.md") ++ API_MAINPAGE_MD "${PROJECT_BINARY_DIR}/api.md" ++ TUTORIALS_MAINPAGE_MD "${PROJECT_BINARY_DIR}/tutorials.md") + diff --git a/recipes/ignition-utils/all/test_package/CMakeLists.txt b/recipes/ignition-utils/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..36dc2a4e5fc15 --- /dev/null +++ b/recipes/ignition-utils/all/test_package/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.10.0) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +set(IGN_UTILS_MAJOR_VER "" CACHE STRING "Version of igition-utils") + +if(NOT IGN_UTILS_MAJOR_VER) + message(FATAL_ERROR "IGN_UTILS_MAJOR_VER not set") +endif() + +find_package(ignition-cmake2 REQUIRED) +find_package(ignition-utils${IGN_UTILS_MAJOR_VER} REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ignition-utils${IGN_UTILS_MAJOR_VER}::ignition-utils${IGN_UTILS_MAJOR_VER}) +set_target_properties(${PROJECT_NAME} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS ON +) diff --git a/recipes/ignition-utils/all/test_package/conanfile.py b/recipes/ignition-utils/all/test_package/conanfile.py new file mode 100644 index 0000000000000..78990441f56be --- /dev/null +++ b/recipes/ignition-utils/all/test_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def requirements(self): + self.requires("ignition-cmake/2.10.0") + + def build(self): + cmake = CMake(self) + cmake.definitions["IGN_UTILS_MAJOR_VER"] = tools.Version(self.deps_cpp_info["ignition-utils"].version).major + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ignition-utils/all/test_package/test_package.cpp b/recipes/ignition-utils/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..918993e2bf116 --- /dev/null +++ b/recipes/ignition-utils/all/test_package/test_package.cpp @@ -0,0 +1,18 @@ +#include +#include +#include +#include + + +int main(int argc, char** argv) +{ + std::cout << "Hello from ignition-utils test_package\n"; + CLI::App app{"Using ignition-utils CLI wrapper"}; + + app.add_flag_callback("-v,--version", [](){ + std::cout << IGNITION_UTILS_VERSION_FULL << std::endl; + throw CLI::Success(); + }); + + CLI11_PARSE(app, argc, argv); +} diff --git a/recipes/ignition-utils/config.yml b/recipes/ignition-utils/config.yml new file mode 100644 index 0000000000000..426a0e4c79e9b --- /dev/null +++ b/recipes/ignition-utils/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3.0": + folder: all diff --git a/recipes/iir1/all/conandata.yml b/recipes/iir1/all/conandata.yml new file mode 100644 index 0000000000000..dcf07a8d3050e --- /dev/null +++ b/recipes/iir1/all/conandata.yml @@ -0,0 +1,30 @@ +sources: + "1.9.1": + url: "https://github.com/berndporr/iir1/archive/refs/tags/1.9.1.tar.gz" + sha256: "97b4a7d62fa4859ac0d80283696b0d91c320b61ec2a455cdd3d8cfbb2be3ad9a" + "1.9.0": + url: "https://github.com/berndporr/iir1/archive/refs/tags/1.9.0.tar.gz" + sha256: "bf2c3cd819151d5b85e84cc8349c1aa9dd5e4157a7070bdd143130278b4375e8" +patches: + "1.9.1": + - patch_file: "patches/1.9.0-0001-no-export-static-win.patch" + patch_description: "Avoid to define __declspec(dllexport) on windows at consume time & in static lib" + patch_type: "portability" + sha256: "b29a0a2f4e6f76c57b7a8e4051173a0e82d7d154571377a0fbd75fd73e4fa73c" + - patch_file: "patches/1.9.0-0003-disable-test-demo.patch" + patch_description: "Do not build test & demo" + patch_type: "conan" + sha256: "5b866e0a6d536f12386ecc212c47a993b9e891584879fd507f8b86f596f97cdd" + "1.9.0": + - patch_file: "patches/1.9.0-0001-no-export-static-win.patch" + patch_description: "Avoid to define __declspec(dllexport) on windows at consume time & in static lib" + patch_type: "portability" + sha256: "b29a0a2f4e6f76c57b7a8e4051173a0e82d7d154571377a0fbd75fd73e4fa73c" + - patch_file: "patches/1.9.0-0002-Add-runtime-export-to-install.patch" + patch_description: "Install dll to bin folder" + patch_type: "portability" + sha256: "2f423eb1ee633a03c30d60f58a125f118cf9323402983c908708e7a6478e4bf6" + - patch_file: "patches/1.9.0-0003-disable-test-demo.patch" + patch_description: "Do not build test & demo" + patch_type: "conan" + sha256: "5b866e0a6d536f12386ecc212c47a993b9e891584879fd507f8b86f596f97cdd" diff --git a/recipes/iir1/all/conanfile.py b/recipes/iir1/all/conanfile.py new file mode 100644 index 0000000000000..07124a82ae39d --- /dev/null +++ b/recipes/iir1/all/conanfile.py @@ -0,0 +1,105 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.52.0" + + +class Iir1Conan(ConanFile): + name = "iir1" + license = "MIT" + description = ( + "An infinite impulse response (IIR) filter library for Linux, Mac OSX " + "and Windows which implements Butterworth, RBJ, Chebychev filters and " + "can easily import coefficients generated by Python (scipy)." + ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/berndporr/iir1" + topics = ("dsp", "signals", "filtering") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "noexceptions": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "noexceptions": False, + } + + @property + def _min_cppstd(self): + return "11" + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if Version(self.version) < "1.9.1": + del self.options.noexceptions + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if self.options.get_safe("noexceptions"): + tc.preprocessor_definitions["IIR1_NO_EXCEPTIONS"] = "1" + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + if self.options.shared: + rm(self, "*iir_static.*", os.path.join(self.package_folder, "lib")) + else: + rmdir(self, os.path.join(self.package_folder, "bin")) + rm(self, "*iir.*", os.path.join(self.package_folder, "lib")) + + def package_info(self): + name = "iir" if self.options.shared else "iir_static" + self.cpp_info.set_property("cmake_file_name", "iir") + self.cpp_info.set_property("cmake_target_name", f"iir::{name}") + self.cpp_info.set_property("pkg_config_name", "iir") + # TODO: back to global scope in conan v2 + self.cpp_info.components["iir"].libs = [name] + if self.options.get_safe("noexceptions"): + self.cpp_info.components["iir"].defines.append("IIR1_NO_EXCEPTIONS") + + # TODO: to remove in conan v2 + self.cpp_info.names["cmake_find_package"] = "iir" + self.cpp_info.names["cmake_find_package_multi"] = "iir" + self.cpp_info.components["iir"].names["cmake_find_package"] = name + self.cpp_info.components["iir"].names["cmake_find_package_multi"] = name + self.cpp_info.components["iir"].set_property("cmake_target_name", f"iir::{name}") diff --git a/recipes/iir1/all/patches/1.9.0-0001-no-export-static-win.patch b/recipes/iir1/all/patches/1.9.0-0001-no-export-static-win.patch new file mode 100644 index 0000000000000..d704a63ab7b58 --- /dev/null +++ b/recipes/iir1/all/patches/1.9.0-0001-no-export-static-win.patch @@ -0,0 +1,14 @@ +--- a/iir/Common.h ++++ b/iir/Common.h +@@ -46,7 +46,11 @@ + + // This exports the classes/structures to the windows DLL + #ifdef _WIN32 ++#ifdef iir_EXPORTS + #define DllExport __declspec( dllexport ) ++#else ++#define DllExport ++#endif + #define _CRT_SECURE_NO_WARNINGS + #else + #define DllExport diff --git a/recipes/iir1/all/patches/1.9.0-0002-Add-runtime-export-to-install.patch b/recipes/iir1/all/patches/1.9.0-0002-Add-runtime-export-to-install.patch new file mode 100644 index 0000000000000..e23ec48224959 --- /dev/null +++ b/recipes/iir1/all/patches/1.9.0-0002-Add-runtime-export-to-install.patch @@ -0,0 +1,24 @@ +From 2330dcc88711e4909da925c1278be2866980c071 Mon Sep 17 00:00:00 2001 +From: Wouter Zirkzee +Date: Thu, 25 Nov 2021 23:30:53 +0100 +Subject: [PATCH 2/2] Add runtime export to install + +--- + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 816a676..794aff8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -68,6 +68,7 @@ install(TARGETS iir EXPORT iir-targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PRIVATE_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/iir) + + configure_file(iir.pc.in iir.pc @ONLY) +-- +2.25.1 + diff --git a/recipes/iir1/all/patches/1.9.0-0003-disable-test-demo.patch b/recipes/iir1/all/patches/1.9.0-0003-disable-test-demo.patch new file mode 100644 index 0000000000000..18bc682ab4948 --- /dev/null +++ b/recipes/iir1/all/patches/1.9.0-0003-disable-test-demo.patch @@ -0,0 +1,12 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -12,9 +12,6 @@ cmake_policy(SET CMP0048 NEW) # set VERSION in project() + cmake_policy(SET CMP0042 NEW) # enable MACOSX_RPATH by default + + include(GNUInstallDirs) +-add_subdirectory(test) +-add_subdirectory(demo) +-enable_testing () + + if (MSVC) + add_compile_options(/W4) diff --git a/recipes/iir1/all/test_package/CMakeLists.txt b/recipes/iir1/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..bfb108d7d9198 --- /dev/null +++ b/recipes/iir1/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(iir REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +if(TARGET iir::iir) + target_link_libraries(${PROJECT_NAME} PRIVATE iir::iir) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE iir::iir_static) +endif() +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/iir1/all/test_package/conanfile.py b/recipes/iir1/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/iir1/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/iir1/all/test_package/test_package.cpp b/recipes/iir1/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..3746899f046a0 --- /dev/null +++ b/recipes/iir1/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include "Iir.h" + +int main() +{ + const int order = 8; + + // Butterworth lowpass + Iir::Butterworth::LowPass f; + + return 0; +} diff --git a/recipes/iir1/all/test_v1_package/CMakeLists.txt b/recipes/iir1/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/iir1/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/iir1/all/test_v1_package/conanfile.py b/recipes/iir1/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/iir1/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/iir1/config.yml b/recipes/iir1/config.yml new file mode 100644 index 0000000000000..8e492271b1dfd --- /dev/null +++ b/recipes/iir1/config.yml @@ -0,0 +1,5 @@ +versions: + "1.9.1": + folder: "all" + "1.9.0": + folder: "all" diff --git a/recipes/imagemagick/all/conandata.yml b/recipes/imagemagick/all/conandata.yml new file mode 100644 index 0000000000000..2dc88685b5bf3 --- /dev/null +++ b/recipes/imagemagick/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "7.0.11-14": + source: + url: "https://github.com/ImageMagick/ImageMagick/archive/7.0.11-14.tar.gz" + sha256: "dfa5aa3f7f289f12c2f9ee6c7c19b02ae857b4eec02f40298f60f5c11048a016" + visualmagick: + "fcd198e4344576b9efc2facd952a2f0c57752c07": + url: "https://github.com/ImageMagick/VisualMagick/archive/fcd198e4344576b9efc2facd952a2f0c57752c07.zip" + sha256: "f793c1c48796ed2f295ba9cacb938f6aa7e4bf011226d96f977655911852bfda" +patches: + "7.0.11-14": + - patch_file: "patches/remove-unnecessary-dependencies.patch" + base_path: "VisualMagick" diff --git a/recipes/imagemagick/all/conanfile.py b/recipes/imagemagick/all/conanfile.py new file mode 100644 index 0000000000000..4e944b9046b3f --- /dev/null +++ b/recipes/imagemagick/all/conanfile.py @@ -0,0 +1,522 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment, MSBuild +from conans.errors import ConanInvalidConfiguration +import os +import glob + +required_conan_version = ">=1.33.0" + + +class ImageMagicConan(ConanFile): + name = "imagemagick" + description = ( + "ImageMagick is a free and open-source software suite for displaying, converting, and editing " + "raster image and vector image files" + ) + topics = ("imagemagick", "images", "manipulating") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://imagemagick.org" + license = "ImageMagick" + settings = "os", "arch", "compiler", "build_type" + generators = "pkg_config" + options = { + "shared": [True, False], + "fPIC": [True, False], + "hdri": [True, False], + "quantum_depth": [8, 16, 32], + "with_zlib": [True, False], + "with_bzlib": [True, False], + "with_lzma": [True, False], + "with_lcms": [True, False], + "with_openexr": [True, False], + "with_heic": [True, False], + "with_jbig": [True, False], + "with_jpeg": [None, "libjpeg", "libjpeg-turbo"], + "with_openjp2": [True, False], + "with_pango": [True, False], + "with_png": [True, False], + "with_tiff": [True, False], + "with_webp": [True, False], + "with_xml2": [True, False], + "with_freetype": [True, False], + "with_djvu": [True, False], + "utilities": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "hdri": True, + "quantum_depth": 16, + "with_zlib": True, + "with_bzlib": True, + "with_lzma": True, + "with_lcms": True, + "with_openexr": True, + "with_heic": True, + "with_jbig": True, + "with_jpeg": "libjpeg", + "with_openjp2": True, + "with_pango": True, + "with_png": True, + "with_tiff": True, + "with_webp": False, + "with_xml2": True, + "with_freetype": True, + "with_djvu": False, + "utilities": True, + } + exports_sources = "patches/*" + + _autotools = None + + @property + def _source_subfolder(self): + return ( + "ImageMagick" # name is important, VisualMagick uses relative paths to it + ) + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _is_msvc(self): + return self.settings.compiler == "Visual Studio" + + @property + def _modules(self): + return ["Magick++", "MagickWand", "MagickCore"] + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration( + "Windows builds of ImageMagick require MFC which cannot currently be sourced from CCI." + ) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.options.with_zlib: + self.requires("zlib/1.2.11") + if self.options.with_bzlib: + self.requires("bzip2/1.0.8") + if self.options.with_lzma: + self.requires("xz_utils/5.2.5") + if self.options.with_lcms: + self.requires("lcms/2.11") + if self.options.with_openexr: + self.requires("openexr/2.5.7") + if self.options.with_heic: + self.requires("libheif/1.12.0") + if self.options.with_jbig: + self.requires("jbig/20160605") + if self.options.with_jpeg == "libjpeg": + self.requires("libjpeg/9d") + elif self.options.with_jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/2.1.0") + if self.options.with_openjp2: + self.requires("openjpeg/2.4.0") + if self.options.with_pango: + self.requires("pango/1.50.7") + if self.options.with_png: + self.requires("libpng/1.6.37") + if self.options.with_tiff: + self.requires("libtiff/4.3.0") + if self.options.with_webp: + self.requires("libwebp/1.2.0") + if self.options.with_xml2: + self.requires("libxml2/2.9.10") + if self.options.with_freetype: + self.requires("freetype/2.10.4") + if self.options.with_djvu: + # FIXME: missing djvu recipe + self.output.warn( + "There is no djvu package available on Conan (yet). This recipe will use the one present on the system (if available)." + ) + + def source(self): + tools.get( + **self.conan_data["sources"][self.version]["source"], + destination=self._source_subfolder, + strip_root=True + ) + + if self._is_msvc: + visualmagick_version = list( + self.conan_data["sources"][self.version]["visualmagick"].keys() + )[0] + tools.get( + **self.conan_data["sources"][self.version]["visualmagick"][ + visualmagick_version + ], + destination="VisualMagick", + strip_root=True + ) + + def build(self): + if self._is_msvc: + self._build_msvc() + else: + with tools.chdir(self._source_subfolder): + env_build = self._build_configure() + env_build.make() + + def _build_msvc(self): + for patch in self.conan_data.get("patches", {}).get(self.version, {}): + tools.patch(**patch) + + # FIXME: package LiquidRescale aka liblqr + tools.replace_in_file( + os.path.join("VisualMagick", "lqr", "Config.txt"), + "#define MAGICKCORE_LQR_DELEGATE", + "", + ) + # FIXME: package LibRaw + tools.replace_in_file( + os.path.join("VisualMagick", "libraw", "Config.txt"), + "#define MAGICKCORE_RAW_R_DELEGATE", + "", + ) + + # FIXME: package FLIF (FLIF: Free Lossless Image Format) + tools.replace_in_file( + os.path.join("VisualMagick", "flif", "Config.txt"), + "#define MAGICKCORE_FLIF_DELEGATE", + "", + ) + + # FIXME: package librsvg + tools.replace_in_file( + os.path.join("VisualMagick", "librsvg", "Config.txt"), + "#define MAGICKCORE_RSVG_DELEGATE", + "", + ) + + if not self.options.shared: + for module in self._modules: + tools.replace_in_file( + os.path.join("VisualMagick", module, "Config.txt"), + "[DLL]", + "[STATIC]", + ) + tools.replace_in_file( + os.path.join("VisualMagick", "coders", "Config.txt"), + "[DLLMODULE]", + "[STATIC]\n[DEFINES]\n_MAGICKLIB_", + ) + + if self.settings.arch == "x86_64": + project = os.path.join("VisualMagick", "configure", "configure.vcxproj") + tools.replace_in_file(project, "Win32", "x64") + tools.replace_in_file(project, "/MACHINE:I386", "/MACHINE:x64") + + with tools.chdir(os.path.join("VisualMagick", "configure")): + + toolset = tools.msvs_toolset(self) + tools.replace_in_file( + "configure.vcxproj", + "v120", + "%s" % toolset, + ) + + msbuild = MSBuild(self) + # fatal error C1189: #error: Please use the /MD switch for _AFXDLL builds + msbuild.build_env.flags = ["/MD"] + msbuild.build( + project_file="configure.vcxproj", + platforms={"x86": "Win32"}, + force_vcvars=True, + ) + + # https://github.com/ImageMagick/ImageMagick-Windows/blob/master/AppVeyor/Build.ps1 + command = ["configure.exe", "/noWizard"] + msvc_version = { + 9: "/VS2002", + 10: "/VS2010", + 11: "/VS2012", + 12: "/VS2013", + 14: "/VS2015", + 15: "/VS2017", + 16: "/VS2019", + 17: "/VS2022", + }.get(int(str(self.settings.compiler.version))) + runtime = {"MT": "/smt", "MTd": "/smtd", "MD": "/dmt", "MDd": "/mdt"}.get( + str(self.settings.compiler.runtime) + ) + command.append(runtime) + command.append(msvc_version) + command.append("/hdri" if self.options.hdri else "/noHdri") + command.append("/Q%s" % self.options.quantum_depth) + if self.settings.arch == "x86_64": + command.append("/x64") + command = " ".join(command) + + self.output.info(command) + self.run(command, run_environment=True) + + # disable incorrectly detected OpenCL + baseconfig = os.path.join( + self._source_subfolder, "MagickCore", "magick-baseconfig.h" + ) + tools.replace_in_file( + baseconfig, + "#define MAGICKCORE__OPENCL", + "#undef MAGICKCORE__OPENCL", + strict=False, + ) + tools.replace_in_file( + baseconfig, + "#define MAGICKCORE_HAVE_CL_CL_H", + "#undef MAGICKCORE_HAVE_CL_CL_H", + strict=False, + ) + + suffix = { + "MT": "StaticMT", + "MTd": "StaticMTD", + "MD": "DynamicMT", + "MDd": "DynamicMT", + }.get(str(self.settings.compiler.runtime)) + + # GdiPlus requires C++, but ImageMagick has *.c files + project = ( + "IM_MOD_emf_%s.vcxproj" % suffix + if self.options.shared + else "CORE_coders_%s.vcxproj" % suffix + ) + tools.replace_in_file( + os.path.join("VisualMagick", "coders", project), + '', + '\n' + "CompileAsCpp", + ) + + for module in self._modules: + with tools.chdir(os.path.join("VisualMagick", module)): + msbuild = MSBuild(self) + msbuild.build( + project_file="CORE_%s_%s.vcxproj" % (module, suffix), + upgrade_project=False, + platforms={"x86": "Win32", "x86_64": "x64"}, + ) + + with tools.chdir(os.path.join("VisualMagick", "coders")): + pattern = ( + "IM_MOD_*_%s.vcxproj" % suffix + if self.options.shared + else "CORE_coders_%s.vcxproj" % suffix + ) + projects = glob.glob(pattern) + for project in projects: + msbuild = MSBuild(self) + msbuild.build( + project_file=project, + upgrade_project=False, + platforms={"x86": "Win32", "x86_64": "x64"}, + ) + + def _build_configure(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment( + self, win_bash=tools.os_info.is_windows + ) + + # FIXME: workaround for xorg/system adding system includes https://github.com/conan-io/conan-center-index/issues/6880 + if "/usr/include/uuid" in self._autotools.include_paths: + self._autotools.include_paths.remove("/usr/include/uuid") + + + def yes_no(o): + return "yes" if o else "no" + + args = [ + "--disable-openmp", + "--disable-docs", + "--with-perl=no", + "--with-x=no", + "--with-fontconfig=no", + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-hdri={}".format(yes_no(self.options.hdri)), + "--with-quantum-depth={}".format(self.options.quantum_depth), + "--with-zlib={}".format(yes_no(self.options.with_zlib)), + "--with-bzlib={}".format(yes_no(self.options.with_bzlib)), + "--with-lzma={}".format(yes_no(self.options.with_lzma)), + "--with-lcms={}".format(yes_no(self.options.with_lcms)), + "--with-openexr={}".format(yes_no(self.options.with_openexr)), + "--with-heic={}".format(yes_no(self.options.with_heic)), + "--with-jbig={}".format(yes_no(self.options.with_jbig)), + "--with-jpeg={}".format(yes_no(self.options.with_jpeg)), + "--with-openjp2={}".format(yes_no(self.options.with_openjp2)), + "--with-pango={}".format(yes_no(self.options.with_pango)), + "--with-png={}".format(yes_no(self.options.with_png)), + "--with-tiff={}".format(yes_no(self.options.with_tiff)), + "--with-webp={}".format(yes_no(self.options.with_webp)), + "--with-xml={}".format(yes_no(self.options.with_xml2)), + "--with-freetype={}".format(yes_no(self.options.with_freetype)), + "--with-djvu={}".format(yes_no(self.options.with_djvu)), + "--with-utilities={}".format(yes_no(self.options.utilities)), + ] + self._autotools.configure(args=args) + + return self._autotools + + def package(self): + with tools.chdir(self._source_subfolder): + env_build = self._build_configure() + env_build.install() + + with tools.chdir(self.package_folder): + # remove undesired files + tools.rmdir(os.path.join("lib", "pkgconfig")) # pc files + tools.rmdir("etc") + tools.rmdir("share") + tools.remove_files_by_mask("lib", "*.la") + + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + if self._is_msvc: + self.copy( + pattern="*CORE_*.lib", + dst="lib", + src=os.path.join("VisualMagick", "lib"), + keep_path=False, + ) + + self.copy( + pattern="*CORE_*.dll", + dst="bin", + src=os.path.join("VisualMagick", "bin"), + keep_path=False, + ) + self.copy( + pattern="*IM_MOD_*.dll", + dst="bin", + src=os.path.join("VisualMagick", "bin"), + keep_path=False, + ) + for module in self._modules: + self.copy( + pattern="*.h", + dst=os.path.join( + "include", + "ImageMagick-%s" % tools.Version(self.version).major, + module, + ), + src=os.path.join(self._source_subfolder, module), + ) + + def _libname(self, library): + if self._is_msvc: + infix = "DB" if self.settings.build_type == "Debug" else "RL" + return "CORE_%s_%s_" % (infix, library) + else: + suffix = "HDRI" if self.options.hdri else "" + return "%s-%s.Q%s%s" % ( + library, + tools.Version(self.version).major, + self.options.quantum_depth, + suffix, + ) + + def package_info(self): + # FIXME model official FindImageMagick https://cmake.org/cmake/help/latest/module/FindImageMagick.html + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + + core_requires = [] + if self.options.with_zlib: + core_requires.append("zlib::zlib") + if self.options.with_bzlib: + core_requires.append("bzip2::bzip2") + if self.options.with_lzma: + core_requires.append("xz_utils::xz_utils") + if self.options.with_lcms: + core_requires.append("lcms::lcms") + if self.options.with_openexr: + core_requires.append("openexr::openexr") + if self.options.with_heic: + core_requires.append("libheif::libheif") + if self.options.with_jbig: + core_requires.append("jbig::jbig") + if self.options.with_jpeg: + core_requires.append("{0}::{0}".format(self.options.with_jpeg)) + if self.options.with_openjp2: + core_requires.append("openjpeg::openjpeg") + if self.options.with_pango: + core_requires.append("pango::pango") + if self.options.with_png: + core_requires.append("libpng::libpng") + if self.options.with_tiff: + core_requires.append("libtiff::libtiff") + if self.options.with_webp: + core_requires.append("libwebp::libwebp") + if self.options.with_xml2: + core_requires.append("libxml2::libxml2") + if self.options.with_freetype: + core_requires.append("freetype::freetype") + + if self._is_msvc: + if not self.options.shared: + self.cpp_info.components["MagickCore"].libs.append( + self._libname("coders") + ) + if self.settings.os == "Linux": + self.cpp_info.components["MagickCore"].system_libs.append("pthread") + + self.cpp_info.components["MagickCore"].defines.append( + "MAGICKCORE_QUANTUM_DEPTH=%s" % self.options.quantum_depth + ) + self.cpp_info.components["MagickCore"].defines.append( + "MAGICKCORE_HDRI_ENABLE=%s" % int(bool(self.options.hdri)) + ) + self.cpp_info.components["MagickCore"].defines.append( + "_MAGICKDLL_=1" if self.options.shared else "_MAGICKLIB_=1" + ) + + imagemagick_include_dir = ( + "include/ImageMagick-%s" % tools.Version(self.version).major + ) + + self.cpp_info.components["MagickCore"].includedirs = [imagemagick_include_dir] + self.cpp_info.components["MagickCore"].libs.append(self._libname("MagickCore")) + self.cpp_info.components["MagickCore"].requires = core_requires + self.cpp_info.components["MagickCore"].names["pkg_config"] = ["MagicCore"] + + self.cpp_info.components[self._libname("MagickCore")].requires = ["MagickCore"] + self.cpp_info.components[self._libname("MagickCore")].names["pkg_config"] = [ + self._libname("MagickCore") + ] + + self.cpp_info.components["MagickWand"].includedirs = [ + imagemagick_include_dir + "/MagickWand" + ] + self.cpp_info.components["MagickWand"].libs = [self._libname("MagickWand")] + self.cpp_info.components["MagickWand"].requires = ["MagickCore"] + self.cpp_info.components["MagickWand"].names["pkg_config"] = ["MagickWand"] + + self.cpp_info.components[self._libname("MagickWand")].requires = ["MagickWand"] + self.cpp_info.components[self._libname("MagickWand")].names[ + "pkg_config" + ] = self._libname("MagickWand") + + self.cpp_info.components["Magick++"].includedirs = [ + imagemagick_include_dir + "/Magick++" + ] + self.cpp_info.components["Magick++"].libs = [self._libname("Magick++")] + self.cpp_info.components["Magick++"].requires = ["MagickWand"] + self.cpp_info.components["Magick++"].names["pkg_config"] = [ + "Magick++", + self._libname("Magick++"), + ] + + self.cpp_info.components[self._libname("Magick++")].requires = ["Magick++"] + self.cpp_info.components[self._libname("Magick++")].names[ + "pkg_config" + ] = self._libname("Magick++") diff --git a/recipes/imagemagick/all/patches/remove-unnecessary-dependencies.patch b/recipes/imagemagick/all/patches/remove-unnecessary-dependencies.patch new file mode 100644 index 0000000000000..081577d80fe74 --- /dev/null +++ b/recipes/imagemagick/all/patches/remove-unnecessary-dependencies.patch @@ -0,0 +1,194 @@ +diff --git a/MagickCore/Config.txt b/MagickCore/Config.txt +index e573f40..dd9b862 100644 +--- a/MagickCore/Config.txt ++++ b/MagickCore/Config.txt +@@ -24,12 +24,8 @@ vms.c + widget.c + + [DEPENDENCIES] +-bzlib + freetype +-lcms +-libxml + lqr +-zlib + + [WARNING_LEVEL] + 4 +diff --git a/coders/Config.dng.txt b/coders/Config.dng.txt +index 2e9b9d1..172ffda 100644 +--- a/coders/Config.dng.txt ++++ b/coders/Config.dng.txt +@@ -4,5 +4,4 @@ + [DEFINES_LIB] + LIBRAW_NODLL + +-[DEPENDENCIES] +-libraw +\ No newline at end of file ++[DEPENDENCIES] +\ No newline at end of file +diff --git a/coders/Config.exr.txt b/coders/Config.exr.txt +index 2624459..90f9cf0 100644 +--- a/coders/Config.exr.txt ++++ b/coders/Config.exr.txt +@@ -2,5 +2,4 @@ + ..\..\exr\openexr + ..\..\exr\openexr\IlmImf + +-[DEPENDENCIES] +-exr +\ No newline at end of file ++[DEPENDENCIES] +\ No newline at end of file +diff --git a/coders/Config.flif.txt b/coders/Config.flif.txt +index aa7d5bb..13f8be3 100644 +--- a/coders/Config.flif.txt ++++ b/coders/Config.flif.txt +@@ -2,7 +2,6 @@ + ..\..\flif\src\library + + [DEPENDENCIES] +-flif + + [VISUAL_STUDIO] + 2013 +diff --git a/coders/Config.heic.txt b/coders/Config.heic.txt +index 9684b8d..08e8633 100644 +--- a/coders/Config.heic.txt ++++ b/coders/Config.heic.txt +@@ -6,4 +6,3 @@ + LIBHEIF_STATIC_BUILD + + [DEPENDENCIES] +-libheif +diff --git a/coders/Config.jbig.txt b/coders/Config.jbig.txt +index d763d54..5d26be6 100644 +--- a/coders/Config.jbig.txt ++++ b/coders/Config.jbig.txt +@@ -2,4 +2,3 @@ + ..\..\jbig\libjbig + + [DEPENDENCIES] +-jbig +diff --git a/coders/Config.jp2.txt b/coders/Config.jp2.txt +index a991a0b..08cb26e 100644 +--- a/coders/Config.jp2.txt ++++ b/coders/Config.jp2.txt +@@ -2,4 +2,3 @@ + ..\..\openjpeg\src\lib\openjp2 + + [DEPENDENCIES] +-openjpeg +diff --git a/coders/Config.jpeg.txt b/coders/Config.jpeg.txt +index e473c26..c106aa0 100644 +--- a/coders/Config.jpeg.txt ++++ b/coders/Config.jpeg.txt +@@ -2,4 +2,3 @@ + ..\..\jpeg-turbo + + [DEPENDENCIES] +-jpeg-turbo +diff --git a/coders/Config.mat.txt b/coders/Config.mat.txt +index 8585d25..ed91809 100644 +--- a/coders/Config.mat.txt ++++ b/coders/Config.mat.txt +@@ -2,4 +2,3 @@ + ..\..\zlib + + [DEPENDENCIES] +-zlib +diff --git a/coders/Config.miff.txt b/coders/Config.miff.txt +index 92d3f74..0072180 100644 +--- a/coders/Config.miff.txt ++++ b/coders/Config.miff.txt +@@ -6,7 +6,4 @@ + [DEFINES_LIB] + LZMA_API_STATIC + +-[DEPENDENCIES] +-bzlib +-liblzma +-zlib +\ No newline at end of file ++[DEPENDENCIES] +\ No newline at end of file +diff --git a/coders/Config.msl.txt b/coders/Config.msl.txt +index d521b8f..9ebd750 100644 +--- a/coders/Config.msl.txt ++++ b/coders/Config.msl.txt +@@ -2,4 +2,3 @@ + ..\..\libxml\include + + [DEPENDENCIES] +-libxml +diff --git a/coders/Config.pango.txt b/coders/Config.pango.txt +index dbb5b72..d799970 100644 +--- a/coders/Config.pango.txt ++++ b/coders/Config.pango.txt +@@ -6,6 +6,3 @@ + ..\..\pango + + [DEPENDENCIES] +-cairo +-glib +-pango +diff --git a/coders/Config.png.txt b/coders/Config.png.txt +index e88a895..48890df 100644 +--- a/coders/Config.png.txt ++++ b/coders/Config.png.txt +@@ -3,5 +3,3 @@ + ..\..\zlib + + [DEPENDENCIES] +-png +-zlib +diff --git a/coders/Config.psd.txt b/coders/Config.psd.txt +index 8585d25..ed91809 100644 +--- a/coders/Config.psd.txt ++++ b/coders/Config.psd.txt +@@ -2,4 +2,3 @@ + ..\..\zlib + + [DEPENDENCIES] +-zlib +diff --git a/coders/Config.svg.txt b/coders/Config.svg.txt +index 44e96c7..1b32c1e 100644 +--- a/coders/Config.svg.txt ++++ b/coders/Config.svg.txt +@@ -9,7 +9,3 @@ + ..\..\librsvg\gdk-pixbuf + + [DEPENDENCIES] +-cairo +-glib +-libxml +-librsvg +diff --git a/coders/Config.tiff.txt b/coders/Config.tiff.txt +index 7e71723..619af78 100644 +--- a/coders/Config.tiff.txt ++++ b/coders/Config.tiff.txt +@@ -2,5 +2,4 @@ + ..\..\tiff\libtiff + + [DEPENDENCIES] +-tiff + coders>psd +diff --git a/coders/Config.url.txt b/coders/Config.url.txt +index d521b8f..9ebd750 100644 +--- a/coders/Config.url.txt ++++ b/coders/Config.url.txt +@@ -2,4 +2,3 @@ + ..\..\libxml\include + + [DEPENDENCIES] +-libxml +diff --git a/coders/Config.webp.txt b/coders/Config.webp.txt +index 407656f..b187605 100644 +--- a/coders/Config.webp.txt ++++ b/coders/Config.webp.txt +@@ -2,4 +2,3 @@ + ..\..\webp\src + + [DEPENDENCIES] +-webp diff --git a/recipes/imagemagick/all/test_package/CMakeLists.txt b/recipes/imagemagick/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b9b613cbb24a --- /dev/null +++ b/recipes/imagemagick/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/imagemagick/all/test_package/conanfile.py b/recipes/imagemagick/all/test_package/conanfile.py new file mode 100644 index 0000000000000..309b542d120cc --- /dev/null +++ b/recipes/imagemagick/all/test_package/conanfile.py @@ -0,0 +1,42 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + with open('delegates.txt') as f: + content = f.read() + + def check(option, token): + self.output.info('checking feature %s...' % token) + if option: + if token not in content.split(): + raise Exception("feature %s wasn't enabled!" % token) + self.output.info('checking feature %s... OK!' % token) + + check(self.options['imagemagick'].with_zlib, 'zlib') + check(self.options['imagemagick'].with_bzlib, 'bzlib') + check(self.options['imagemagick'].with_lzma, 'lzma') + check(self.options['imagemagick'].with_lcms, 'lcms') + check(self.options['imagemagick'].with_openexr, 'openexr') + check(self.options['imagemagick'].with_heic, 'heic') + check(self.options['imagemagick'].with_jbig, 'jbig') + check(self.options['imagemagick'].with_jpeg, 'jpeg') + check(self.options['imagemagick'].with_openjp2, 'jp2') + check(self.options['imagemagick'].with_pango, 'pangocairo') + check(self.options['imagemagick'].with_png, 'png') + check(self.options['imagemagick'].with_tiff, 'tiff') + check(self.options['imagemagick'].with_webp, 'webp') + check(self.options['imagemagick'].with_freetype, 'freetype') + check(self.options['imagemagick'].with_xml2, 'xml') diff --git a/recipes/imagemagick/all/test_package/test_package.c b/recipes/imagemagick/all/test_package/test_package.c new file mode 100644 index 0000000000000..bae5b33f6373e --- /dev/null +++ b/recipes/imagemagick/all/test_package/test_package.c @@ -0,0 +1,24 @@ +#include +#include + +int main() +{ + size_t version, range, depth; + printf("Imagemagick version : %s\n", GetMagickVersion(&version)); + printf("ImageMagick release data : %s\n", GetMagickReleaseDate()); + printf("ImageMagick quantum range: %s\n", GetMagickQuantumRange(&range)); + printf("ImageMagick quantum depth: %s\n", GetMagickQuantumDepth(&depth)); + printf("ImageMagick package name : %s\n", GetMagickPackageName()); + printf("ImageMagick license : %s\n", GetMagickLicense()); + printf("ImageMagick home URL : %s\n", GetMagickHomeURL()); + printf("ImageMagick features : %s\n", GetMagickFeatures()); + printf("ImageMagick delegates : %s\n", GetMagickDelegates()); + printf("ImageMagick copyright : %s\n", GetMagickCopyright()); + + FILE *fp; + fp = fopen("delegates.txt", "w+"); + fputs(GetMagickDelegates(), fp); + fclose(fp); + + return 0; +} diff --git a/recipes/imagemagick/config.yml b/recipes/imagemagick/config.yml new file mode 100644 index 0000000000000..7d02fe0c755da --- /dev/null +++ b/recipes/imagemagick/config.yml @@ -0,0 +1,4 @@ +versions: + "7.0.11-14": + folder: all + diff --git a/recipes/imagl/all/CMakeLists.txt b/recipes/imagl/all/CMakeLists.txt index d32836cbae4aa..434aea21733de 100644 --- a/recipes/imagl/all/CMakeLists.txt +++ b/recipes/imagl/all/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include("conanbuildinfo.cmake") -conan_basic_setup() +conan_basic_setup(TARGETS) add_subdirectory(source_subfolder) diff --git a/recipes/imagl/all/conandata.yml b/recipes/imagl/all/conandata.yml index 244b85fa5bc24..4c28973c33e6b 100644 --- a/recipes/imagl/all/conandata.yml +++ b/recipes/imagl/all/conandata.yml @@ -11,3 +11,16 @@ sources: "0.2.1": url: "https://gitlab-lepuy.iut-clermont.uca.fr/opengl/imagl/-/archive/v0.2.1/imagl-v0.2.1.tar.gz" sha256: "5a68cdeff4338e411695cca16c4230567de298f8efee2a9fadcc6fa644a70248" +patches: + "0.1.0": + - patch_file: "patches/0001-no-unmanaged-conan-0.1.x.patch" + base_path: "source_subfolder" + "0.1.1": + - patch_file: "patches/0001-no-unmanaged-conan-0.1.x.patch" + base_path: "source_subfolder" + "0.1.2": + - patch_file: "patches/0001-no-unmanaged-conan-0.1.x.patch" + base_path: "source_subfolder" + "0.2.1": + - patch_file: "patches/0001-no-unmanaged-conan-0.2.1.patch" + base_path: "source_subfolder" diff --git a/recipes/imagl/all/conanfile.py b/recipes/imagl/all/conanfile.py index 93e23ca95372b..a8994d4c2ba67 100644 --- a/recipes/imagl/all/conanfile.py +++ b/recipes/imagl/all/conanfile.py @@ -1,8 +1,7 @@ from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration, ConanException -import os +from conans.errors import ConanInvalidConfiguration -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.33.0" class ImaglConan(ConanFile): @@ -14,21 +13,19 @@ class ImaglConan(ConanFile): topics = ("opengl", "texture", "image") settings = "os", "compiler", "build_type", "arch" options = { - "shared": [True, False], - "fPIC": [True, False], - "with_png": [True, False], - "with_jpeg": [True, False], - "allow_clang_11": [None, True, False] + "shared": [True, False], + "fPIC": [True, False], + "with_png": [True, False], + "with_jpeg": [True, False], } default_options = { - "shared": False, - "fPIC": True, - "with_png": True, - "with_jpeg": True, - "allow_clang_11": None + "shared": False, + "fPIC": True, + "with_png": True, + "with_jpeg": True, } generators = "cmake" - exports_sources = "CMakeLists.txt" + exports_sources = ["CMakeLists.txt", "patches/**"] _cmake = None @property @@ -57,9 +54,21 @@ def _compilers_minimum_version(self): def _supports_jpeg(self): return tools.Version(self.version) >= "0.2.0" - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-v" + self.version, self._source_subfolder) + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if not self._supports_jpeg: + del self.options.with_jpeg + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.options.with_png: + self.requires("libpng/1.6.37") + if self._supports_jpeg and self.options.with_jpeg: + self.requires("libjpeg/9d") def validate(self): if self.settings.compiler.cppstd: @@ -82,30 +91,12 @@ def lazy_lt_semver(v1, v2): self.output.warn("imaGL requires C++20. Your compiler is unknown. Assuming it supports C++20.") elif lazy_lt_semver(compiler_version, minimum_version): raise ConanInvalidConfiguration("imaGL requires some C++20 features, which your {} {} compiler does not support.".format(str(self.settings.compiler), compiler_version)) - elif str(self.settings.compiler) == "clang" and compiler_version == "11" and not self.options.allow_clang_11: - raise ConanInvalidConfiguration("Clang 11 is not currently supported by conan center index. To build imaGL, append '-o imagl:allow_clang_11=True --build missing' to your 'conan install' command line.") else: print("Your compiler is {} {} and is compatible.".format(str(self.settings.compiler), compiler_version)) - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - if not self._supports_jpeg: - del self.options.with_jpeg - if not str(self.settings.compiler) == "clang" or not str(self.settings.compiler.version) == "11": - del self.options.allow_clang_11 - else: - self.output.warn("allow_clang_11 option will be removed in the future when conan center index will support clang 11.") - - def configure(self): - if self.options.shared: - del self.options.fPIC - - def requirements(self): - if self.options.with_png: - self.requires("libpng/1.6.37") - if self._supports_jpeg and self.options.with_jpeg: - self.requires("libjpeg/9d") + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -121,6 +112,8 @@ def _configure_cmake(self): return self._cmake def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) cmake = self._configure_cmake() cmake.build() diff --git a/recipes/imagl/all/patches/0001-no-unmanaged-conan-0.1.x.patch b/recipes/imagl/all/patches/0001-no-unmanaged-conan-0.1.x.patch new file mode 100644 index 0000000000000..c404a6d997e59 --- /dev/null +++ b/recipes/imagl/all/patches/0001-no-unmanaged-conan-0.1.x.patch @@ -0,0 +1,18 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -23,6 +23,7 @@ if(CMAKE_CXX_COMPILER MATCHES [[clang\+\+.*]]) + endif() + + # Generate conanfile.txt from current cmake cache configuration ++if(0) + file(STRINGS conanfile.in CONANFILE) + file(WRITE "${CMAKE_BINARY_DIR}/conanfile.txt" "# Do not modify this file, it is automatically generated by CMake\n") + foreach(CONANFILE_LINE ${CONANFILE}) +@@ -62,6 +63,7 @@ else() + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + endif() + conan_basic_setup(TARGETS) ++endif() + + set(CMAKE_DEBUG_POSTFIX d) + set(CMAKE_STATIC_LIBRARY_SUFFIX "s${CMAKE_STATIC_LIBRARY_SUFFIX}") diff --git a/recipes/imagl/all/patches/0001-no-unmanaged-conan-0.2.1.patch b/recipes/imagl/all/patches/0001-no-unmanaged-conan-0.2.1.patch new file mode 100644 index 0000000000000..69b7f5b75427a --- /dev/null +++ b/recipes/imagl/all/patches/0001-no-unmanaged-conan-0.2.1.patch @@ -0,0 +1,18 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -24,6 +24,7 @@ if(CMAKE_CXX_COMPILER MATCHES [[clang\+\+.*]]) + endif() + + # Generate conanfile.txt from current cmake cache configuration ++if(0) + file(STRINGS conanfile.in CONANFILE) + file(WRITE "${CMAKE_BINARY_DIR}/conanfile.txt" "# Do not modify this file, it is automatically generated by CMake\n") + foreach(CONANFILE_LINE ${CONANFILE}) +@@ -68,6 +69,7 @@ else() + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + endif() + conan_basic_setup(TARGETS) ++endif() + + set(CMAKE_DEBUG_POSTFIX d) + set(CMAKE_STATIC_LIBRARY_SUFFIX "s${CMAKE_STATIC_LIBRARY_SUFFIX}") diff --git a/recipes/imagl/all/test_package/CMakeLists.txt b/recipes/imagl/all/test_package/CMakeLists.txt index 4935b678899c5..15d229320021c 100644 --- a/recipes/imagl/all/test_package/CMakeLists.txt +++ b/recipes/imagl/all/test_package/CMakeLists.txt @@ -6,16 +6,4 @@ conan_basic_setup() add_executable(example example.cpp) target_link_libraries(example ${CONAN_LIBS}) - -if(STATIC_LIB) - add_compile_definitions(IMAGL_STATIC) -endif() - -set_property(TARGET example PROPERTY CXX_STANDARD 20) -set_property(TARGET example PROPERTY CXX_STANDARD_REQUIRED ON) - -# CTest is a testing tool that can be used to test your project. -# enable_testing() -# add_test(NAME example -# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin -# COMMAND example) +set_target_properties(example PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON) diff --git a/recipes/imake/all/conandata.yml b/recipes/imake/all/conandata.yml new file mode 100644 index 0000000000000..b60e9f5b7c62c --- /dev/null +++ b/recipes/imake/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "1.0.8": + url: "https://www.x.org/releases/individual/util/imake-1.0.8.tar.gz" + sha256: "8178a09bfef33ad5f61cb5cb62283df7d3a5682f014507d2e7cfd922485a5c00" +patches: + "1.0.8": + - patch_file: "patches/0001-reproducible-behavior.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-msvc-debug-build_type.patch" + base_path: "source_subfolder" diff --git a/recipes/imake/all/conanfile.py b/recipes/imake/all/conanfile.py new file mode 100644 index 0000000000000..f5048e50d11a2 --- /dev/null +++ b/recipes/imake/all/conanfile.py @@ -0,0 +1,141 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +import contextlib +import os + +required_conan_version = ">=1.33.0" + + +class ImakeConan(ConanFile): + name = "imake" + description = "Obsolete C preprocessor interface to the make utility" + topics = ("conan", "imake", "xmkmf", "preprocessor", "build", "system") + license = "MIT" + homepage = "https://gitlab.freedesktop.org/xorg/util/imake" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "ccmakedep": [True, False], + "cleanlinks": [True, False], + "makeg": [True, False], + "mergelib": [True, False], + "mkdirhier": [True, False], + "mkhtmlindex": [True, False], + "revpath": [True, False], + "xmkmf": [True, False], + } + default_options = { + "ccmakedep": True, + "cleanlinks": True, + "makeg": True, + "mergelib": True, + "mkdirhier": True, + "mkhtmlindex": True, + "revpath": True, + "xmkmf": True, + } + + exports_sources = "patches/*" + generators = "pkg_config" + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def requirements(self): + self.requires("xorg-proto/2021.4") + + def build_requirements(self): + self.build_requires("automake/1.16.3") + self.build_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows": + self.build_requires("msys2/cci.latest") + + def configure(self): + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def package_id(self): + del self.info.settings.compiler + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self): + env = { + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CPP": "{} cl -E".format(tools.unix_path(self._user_info_build["automake"].compile)), + } + with tools.environment_append(env): + yield + else: + yield + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=self._settings_build.os == "Windows") + self._autotools.libs = [] + if self.settings.os == "Windows": + self._autotools.defines.append("WIN32") + if self.settings.compiler == "Visual Studio": + self._autotools.defines.extend([ + "_CRT_SECURE_NO_WARNINGS", + "CROSSCOMPILE_CPP", + ]) + self._autotools.flags.append("-FS") + yes_no = lambda v: "yes" if v else "no" + conf_args = [ + "--enable-ccmakedep={}".format(yes_no(self.options.ccmakedep)), + "--enable-cleanlinks={}".format(yes_no(self.options.cleanlinks)), + "--enable-makeg={}".format(yes_no(self.options.makeg)), + "--enable-mergelib={}".format(yes_no(self.options.mergelib)), + "--enable-mkdirhier={}".format(yes_no(self.options.mkdirhier)), + "--enable-mkhtmlindex={}".format(yes_no(self.options.mkhtmlindex)), + "--enable-revpath={}".format(yes_no(self.options.revpath)), + "--enable-xmkmf={}".format(yes_no(self.options.xmkmf)), + ] + + # FIXME: RAWCPP (ac_cv_path_RAWCPP) is not compatible with MSVC preprocessor. It needs to be cpp. + if tools.get_env("CPP"): + conf_args.extend([ + "--with-script-preproc-cmd={}".format(tools.get_env("CPP")), + ]) + self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + # tools.replace_in_file(os.path.join(self._source_subfolder, "")) + with self._build_context(): + autotools = self._configure_autotools() + autotools.make(args=["V=1"]) + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libdirs = [] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/imake/all/patches/0001-reproducible-behavior.patch b/recipes/imake/all/patches/0001-reproducible-behavior.patch new file mode 100644 index 0000000000000..605ae7e7b2c1f --- /dev/null +++ b/recipes/imake/all/patches/0001-reproducible-behavior.patch @@ -0,0 +1,14 @@ +Hardcode gcc instead of using `PREPROC` (=compiler used when building imake). +This leads to more reproducible behavior. +(CC can be overridden by a CC environment variable or --cc argument) +--- mdepend.cpp ++++ mdepend.cpp +@@ -21,7 +21,7 @@ + XCOMM "-" (at least, that is what the documentation implies). + XCOMM + +-CC=PREPROC ++CC=gcc + + silent='-' + diff --git a/recipes/imake/all/patches/0002-msvc-debug-build_type.patch b/recipes/imake/all/patches/0002-msvc-debug-build_type.patch new file mode 100644 index 0000000000000..8af26fe967a05 --- /dev/null +++ b/recipes/imake/all/patches/0002-msvc-debug-build_type.patch @@ -0,0 +1,57 @@ +Needed when building MSVC with build_type=Debug + compiler.runtime=MTd +- escape comments with XCOMM +- avoid C4717: '_fstat64i32': recursive on all control paths, function will cause runtime stack overflow +- /tmp/xxxx does not exist on Windows +--- mdepend.cpp ++++ mdepend.cpp +@@ -125,9 +125,9 @@ + shift + ;; + +- # Flag to tell compiler to output dependencies directly +- # For example, with Sun compilers, -xM or -xM1 or +- # with gcc, -M ++ XCOMM Flag to tell compiler to output dependencies directly ++ XCOMM For example, with Sun compilers, -xM or -xM1 or ++ XCOMM with gcc, -M + -d) + compilerlistsdepends="y" + compilerlistdependsflag="$2" +--- imake.c ++++ imake.c +@@ -159,9 +159,6 @@ + #include + #include + #include +-#ifdef WIN32 +-# include "Xw32defs.h" +-#endif + #include + #include + #ifdef X_NOT_POSIX +@@ -252,6 +249,9 @@ + #if defined(__NetBSD__) /* see code clock in init() below */ + # include + #endif ++#ifdef WIN32 ++# include "Xw32defs.h" ++#endif + + typedef unsigned char boolean; + #define TRUE 1 +@@ -303,9 +303,14 @@ + const char *cpp = NULL; + + const char *tmpMakefile; ++#ifdef _WIN32 ++const char *tmpMakefileTemplate = "Imf.XXXXXX"; /* HACK: create temporary files in current folder */ ++const char *tmpImakefileTemplate = "IIf.XXXXXX"; /* HACK: create temporary files in current folder */ ++#else + const char *tmpMakefileTemplate = "/tmp/Imf.XXXXXX"; +-const char *tmpImakefile; + const char *tmpImakefileTemplate = "/tmp/IIf.XXXXXX"; ++#endif ++const char *tmpImakefile; + const char *make_argv[ ARGUMENTS ] = { + #ifdef WIN32 + "nmake" diff --git a/recipes/imake/all/test_package/Imake.tmpl b/recipes/imake/all/test_package/Imake.tmpl new file mode 100644 index 0000000000000..3b7cb31780b8f --- /dev/null +++ b/recipes/imake/all/test_package/Imake.tmpl @@ -0,0 +1,2 @@ +default: + @echo "IMAKE_TEMPLATE:" IMAKE_TEMPLATE diff --git a/recipes/imake/all/test_package/Imakefile b/recipes/imake/all/test_package/Imakefile new file mode 100644 index 0000000000000..8a9b031f63620 --- /dev/null +++ b/recipes/imake/all/test_package/Imakefile @@ -0,0 +1 @@ +# Imakefile diff --git a/recipes/imake/all/test_package/conanfile.py b/recipes/imake/all/test_package/conanfile.py new file mode 100644 index 0000000000000..99bf0a8a9c2d8 --- /dev/null +++ b/recipes/imake/all/test_package/conanfile.py @@ -0,0 +1,44 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +import contextlib +import os +import shutil + +required_conan_version = ">=1.36.0" + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + exports_sources = "Imakefile", "Imake.tmpl" + + def build_requirements(self): + if not tools.get_env("CONAN_MAKE_PROGRAM"): + self.build_requires("make/4.2.1") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self): + env = { + "CC": "cl -nologo", + } + with tools.environment_append(env): + yield + else: + yield + + def build(self): + for src in self.exports_sources: + shutil.copy(os.path.join(self.source_folder, src), os.path.join(self.build_folder, src)) + if not tools.cross_building(self): + with self._build_context(): + self.run("imake", run_environment=True) + + def test(self): + if not tools.cross_building(self): + autotools = AutoToolsBuildEnvironment(self) + autotools.make() diff --git a/recipes/imake/config.yml b/recipes/imake/config.yml new file mode 100644 index 0000000000000..28e3ee22ca8ac --- /dev/null +++ b/recipes/imake/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.8": + folder: all diff --git a/recipes/imath/all/conandata.yml b/recipes/imath/all/conandata.yml new file mode 100644 index 0000000000000..c74e535dae312 --- /dev/null +++ b/recipes/imath/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "3.1.6": + url: "https://github.com/AcademySoftwareFoundation/Imath/archive/v3.1.6.tar.gz" + sha256: "ea5592230f5ab917bea3ceab266cf38eb4aa4a523078d46eac0f5a89c52304db" + "3.1.5": + url: "https://github.com/AcademySoftwareFoundation/Imath/archive/refs/tags/v3.1.5.tar.gz" + sha256: "1e9c7c94797cf7b7e61908aed1f80a331088cc7d8873318f70376e4aed5f25fb" + "3.1.4": + url: "https://github.com/AcademySoftwareFoundation/Imath/archive/refs/tags/v3.1.4.tar.gz" + sha256: "fcca5fbb37d375a252bacd8a29935569bdc28b888f01ef1d9299ca0c9e87c17a" diff --git a/recipes/imath/all/conanfile.py b/recipes/imath/all/conanfile.py new file mode 100644 index 0000000000000..283ef1037345d --- /dev/null +++ b/recipes/imath/all/conanfile.py @@ -0,0 +1,94 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import collect_libs, copy, get, rmdir +import os + +required_conan_version = ">=1.50.0" + + +class ImathConan(ConanFile): + name = "imath" + description = ( + "Imath is a C++ and python library of 2D and 3D vector, matrix, and " + "math operations for computer graphics." + ) + license = "BSD-3-Clause" + topics = ("computer-graphics", "matrix", "openexr", "3d-vector") + homepage = "https://github.com/AcademySoftwareFoundation/Imath" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Imath") + self.cpp_info.set_property("cmake_target_name", "Imath::Imath") + self.cpp_info.set_property("pkg_config_name", "Imath") + + # Imath::ImathConfig - header only library + imath_config = self.cpp_info.components["imath_config"] + imath_config.set_property("cmake_target_name", "Imath::ImathConfig") + imath_config.includedirs.append(os.path.join("include", "Imath")) + + # Imath::Imath - linkable library + imath_lib = self.cpp_info.components["imath_lib"] + imath_lib.set_property("cmake_target_name", "Imath::Imath") + imath_lib.set_property("pkg_config_name", "Imath") + imath_lib.libs = collect_libs(self) + imath_lib.requires = ["imath_config"] + if self.settings.os == "Windows" and self.options.shared: + imath_lib.defines.append("IMATH_DLL") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "Imath" + self.cpp_info.names["cmake_find_package_multi"] = "Imath" + self.cpp_info.names["pkg_config"] = "Imath" + imath_config.names["cmake_find_package"] = "ImathConfig" + imath_config.names["cmake_find_package_multi"] = "ImathConfig" + imath_lib.names["cmake_find_package"] = "Imath" + imath_lib.names["cmake_find_package_multi"] = "Imath" + imath_lib.names["pkg_config"] = "Imath" diff --git a/recipes/imath/all/test_package/CMakeLists.txt b/recipes/imath/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..4c646b7678695 --- /dev/null +++ b/recipes/imath/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(Imath REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Imath::Imath) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/imath/all/test_package/conanfile.py b/recipes/imath/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/imath/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/imath/all/test_package/test_package.cpp b/recipes/imath/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..39d477384f30e --- /dev/null +++ b/recipes/imath/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + std::cout << Imath::half(1.0) << "\n"; + return 0; +} diff --git a/recipes/imath/all/test_v1_package/CMakeLists.txt b/recipes/imath/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..1094e6d0adf29 --- /dev/null +++ b/recipes/imath/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Imath REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Imath::Imath) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/imath/all/test_v1_package/conanfile.py b/recipes/imath/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/imath/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/imath/config.yml b/recipes/imath/config.yml new file mode 100644 index 0000000000000..566850eaffa71 --- /dev/null +++ b/recipes/imath/config.yml @@ -0,0 +1,7 @@ +versions: + "3.1.6": + folder: all + "3.1.5": + folder: all + "3.1.4": + folder: all diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index e95a12f261478..8c9bf128442ff 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -1,19 +1,12 @@ -cmake_minimum_required(VERSION 3.4) -project(imgui CXX) +cmake_minimum_required(VERSION 3.8) +project(imgui LANGUAGES CXX) -include(conanbuildinfo.cmake) -conan_basic_setup() - -if (WIN32 AND MSVC AND BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif(WIN32 AND MSVC AND BUILD_SHARED_LIBS) - -set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) -set(MISC_DIR ${SOURCE_DIR}/misc) +set(MISC_DIR ${IMGUI_SRC_DIR}/misc) set(EXTRA_FONTS_DIR ${MISC_DIR}/fonts) +set(IMGUI_EXPORT_HEADERS imgui_export_headers.h) -file(GLOB SOURCE_FILES ${SOURCE_DIR}/*.cpp) -file(GLOB HEADER_FILES ${SOURCE_DIR}/*.h) +file(GLOB SOURCE_FILES ${IMGUI_SRC_DIR}/*.cpp) +file(GLOB HEADER_FILES ${IMGUI_SRC_DIR}/*.h) file(GLOB EXTRA_FONTS_FILES ${EXTRA_FONTS_DIR}/*.ttf) if (MSVC) file(GLOB EXTRA_NATVIS_FILES ${MISC_DIR}/natvis/*.natvis) @@ -24,7 +17,21 @@ set(BINARY_TO_COMPRESSED_BIN binary_to_compressed_c) add_executable(${BINARY_TO_COMPRESSED_BIN} ${EXTRA_FONTS_DIR}/binary_to_compressed_c.cpp) add_library(${PROJECT_NAME} ${SOURCE_FILES}) -target_include_directories(${PROJECT_NAME} PRIVATE ${SOURCE_DIR}) +set_target_properties(${PROJECT_NAME} PROPERTIES + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON +) +include(GenerateExportHeader) +generate_export_header(${PROJECT_NAME} + EXPORT_MACRO_NAME IMGUI_API + EXPORT_FILE_NAME ${IMGUI_EXPORT_HEADERS} +) +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ + $ +) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) include(GNUInstallDirs) @@ -33,8 +40,8 @@ install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS ${BINARY_TO_COMPRESSED_BIN} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES ${HEADER_FILES} + DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES ${HEADER_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${IMGUI_EXPORT_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) install(FILES ${EXTRA_FONTS_FILES} diff --git a/recipes/imgui/all/conandata.yml b/recipes/imgui/all/conandata.yml index 2f73ce41b26a6..9ed281a0bbcaf 100644 --- a/recipes/imgui/all/conandata.yml +++ b/recipes/imgui/all/conandata.yml @@ -1,28 +1,26 @@ sources: - "1.74": - url: "https://github.com/ocornut/imgui/archive/v1.74.tar.gz" - sha256: "2f5f2b789edb00260aa71f03189da5f21cf4b5617c4fbba709e9fbcfc76a2f1e" - "1.75": - url: "https://github.com/ocornut/imgui/archive/v1.75.tar.gz" - sha256: "1023227fae4cf9c8032f56afcaea8902e9bfaad6d9094d6e48fb8f3903c7b866" - "1.76": - url: "https://github.com/ocornut/imgui/archive/v1.76.tar.gz" - sha256: "e482dda81330d38c87bd81597cacaa89f05e20ed2c4c4a93a64322e97565f6dc" - "1.77": - url: "https://github.com/ocornut/imgui/archive/v1.77.tar.gz" - sha256: "c0dae830025d4a1a169df97409709f40d9dfa19f8fc96b550052224cbb238fa8" - "1.78": - url: "https://github.com/ocornut/imgui/archive/v1.78.tar.gz" - sha256: "f70bbb17581ee2bd42fda526d9c3dc1a5165f3847ff047483d4d7980e166f9a3" - "1.79": - url: "https://github.com/ocornut/imgui/archive/v1.79.tar.gz" - sha256: "f1908501f6dc6db8a4d572c29259847f6f882684b10488d3a8d2da31744cd0a4" - "1.80": - url: "https://github.com/ocornut/imgui/archive/v1.80.tar.gz" - sha256: "d7e4e1c7233409018437a646680316040e6977b9a635c02da93d172baad94ce9" - "1.81": - url: "https://github.com/ocornut/imgui/archive/v1.81.tar.gz" - sha256: "f7c619e03a06c0f25e8f47262dbc32d61fd033d2c91796812bf0f8c94fca78fb" - "1.82": - url: "https://github.com/ocornut/imgui/archive/v1.82.tar.gz" - sha256: "fefa2804bd55f3d25b134af08c0e1f86d4d059ac94cef3ee7bd21e2f194e5ce5" + "1.89.1": + url: "https://github.com/ocornut/imgui/archive/v1.89.1.tar.gz" + sha256: "6d02a0079514d869e4b5f8f590f9060259385fcddd93a07ef21298b6a9610cbd" + "1.88": + url: "https://github.com/ocornut/imgui/archive/v1.88.tar.gz" + sha256: "9f14c788aee15b777051e48f868c5d4d959bd679fc5050e3d2a29de80d8fd32e" + "1.87": + url: "https://github.com/ocornut/imgui/archive/v1.87.tar.gz" + sha256: "b54ceb35bda38766e36b87c25edf7a1cd8fd2cb8c485b245aedca6fb85645a20" + "1.86": + url: "https://github.com/ocornut/imgui/archive/v1.86.tar.gz" + sha256: "6ba6ae8425a19bc52c5e067702c48b70e4403cd339cba02073a462730a63e825" + "1.85": + url: "https://github.com/ocornut/imgui/archive/v1.85.tar.gz" + sha256: "7ed49d1f4573004fa725a70642aaddd3e06bb57fcfe1c1a49ac6574a3e895a77" + + # These versions belong to the docking branch in ImGUI repository. This branch is declared stable and production ready, and + # it is synced with `master` regularly. These versions are taken from that branch using the commit where `master` was synced + # after a regular release + "cci.20220621+1.88.docking": + url: "https://github.com/ocornut/imgui/archive/9cd9c2eff99877a3f10a7f9c2a3a5b9c15ea36c6.tar.gz" + sha256: "61fb1ce5d48089bce1b4f92e9320fd234b2ce960f35f965b313c4842b3c8e440" + "cci.20220207+1.87.docking": + url: "https://github.com/ocornut/imgui/archive/1ee252772ae9c0a971d06257bb5c89f628fa696a.tar.gz" + sha256: "c50e263660e1deb6e85b10a0382bf8a6fc861645e44b7012bd32da5460829ae0" diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index d90f36c03f18d..8fc402938d64d 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -1,33 +1,32 @@ +from conan import ConanFile +from conan.tools.files import get, copy, replace_in_file +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import os -from conans import ConanFile, CMake, tools +import re +required_conan_version = ">=1.53.0" class IMGUIConan(ConanFile): name = "imgui" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/ocornut/imgui" description = "Bloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies" - topics = ("conan", "imgui", "gui", "graphical") license = "MIT" - - exports_sources = ["CMakeLists.txt"] - generators = "cmake" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/ocornut/imgui" + topics = ("gui", "graphical", "bloat-free") settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], - "fPIC": [True, False] + "fPIC": [True, False], } default_options = { "shared": False, - "fPIC": True + "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -35,40 +34,53 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["IMGUI_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def _patch_sources(self): + # Ensure we take into account export_headers + replace_in_file(self, + os.path.join(self.source_folder, "imgui.h"), + "#ifdef IMGUI_USER_CONFIG", + "#include \"imgui_export_headers.h\"\n\n#ifdef IMGUI_USER_CONFIG" + ) def build(self): - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - backends_folder = src=os.path.join( - self._source_subfolder, - "backends" if tools.Version(self.version) >= "1.80" else "examples" + copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + m = re.match(r'cci\.\d{8}\+(?P\d+\.\d+)\.docking', str(self.version)) + version = Version(m.group('version')) if m else Version(self.version) + backends_folder = os.path.join( + self.source_folder, + "backends" if version >= "1.80" else "examples" ) - self.copy(pattern="imgui_impl_*", - dst=os.path.join("res", "bindings"), - src=backends_folder) - cmake = self._configure_cmake() + copy(self, pattern="imgui_impl_*", + dst=os.path.join(self.package_folder, "res", "bindings"), + src=backends_folder) + cmake = CMake(self) cmake.install() def package_info(self): self.cpp_info.libs = ["imgui"] if self.settings.os == "Linux": self.cpp_info.system_libs.append("m") + if self.settings.os == "Windows": + self.cpp_info.system_libs.append("imm32") self.cpp_info.srcdirs = [os.path.join("res", "bindings")] bin_path = os.path.join(self.package_folder, "bin") diff --git a/recipes/imgui/all/test_package/CMakeLists.txt b/recipes/imgui/all/test_package/CMakeLists.txt index b2a875d0cfcc8..3e9ea943d420e 100644 --- a/recipes/imgui/all/test_package/CMakeLists.txt +++ b/recipes/imgui/all/test_package/CMakeLists.txt @@ -1,10 +1,12 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(imgui REQUIRED) +find_package(imgui REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} imgui::imgui) +target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui) +if (DOCKING) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DDOCKING) +endif() +target_compile_definitions(${PROJECT_NAME} PUBLIC "IMGUI_USER_CONFIG=\"${CMAKE_CURRENT_SOURCE_DIR}/my_imgui_config.h\"") +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/imgui/all/test_package/conanfile.py b/recipes/imgui/all/test_package/conanfile.py index 23ba95e79f465..a9fb96656f203 100644 --- a/recipes/imgui/all/test_package/conanfile.py +++ b/recipes/imgui/all/test_package/conanfile.py @@ -1,9 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/imgui/all/test_package/my_imgui_config.h b/recipes/imgui/all/test_package/my_imgui_config.h new file mode 100644 index 0000000000000..69f4176638fd1 --- /dev/null +++ b/recipes/imgui/all/test_package/my_imgui_config.h @@ -0,0 +1,11 @@ +#pragma once + +#include + + +namespace ImGui +{ + void MyFunction(const char* name) { + printf(" ImGui::MyFunction(%s)\n", name); + } +} diff --git a/recipes/imgui/all/test_package/test_package.cpp b/recipes/imgui/all/test_package/test_package.cpp index 613b3fa275647..6a0a221db872e 100644 --- a/recipes/imgui/all/test_package/test_package.cpp +++ b/recipes/imgui/all/test_package/test_package.cpp @@ -1,4 +1,8 @@ #include +#ifdef DOCKING + #include +#endif + #include int main(int, char**) @@ -6,6 +10,9 @@ int main(int, char**) ImGuiContext* context =ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); + ImGuiTextBuffer textBuffer; + textBuffer.append("Hello, ImGui"); + // Build atlas unsigned char* tex_pixels = NULL; int tex_w, tex_h; @@ -18,10 +25,19 @@ int main(int, char**) io.DeltaTime = 1.0f / 60.0f; ImGui::NewFrame(); +#ifdef DOCKING + auto dockspaceID = ImGui::GetID("MyDockSpace"); + static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None; + ImGui::DockSpace(dockspaceID, ImVec2(0.0f, 0.0f), dockspace_flags); + printf(" with docking\n"); +#endif + static float f = 0.0f; ImGui::Text("Hello, world!"); + ImGui::Text("%s", textBuffer.begin()); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); + ImGui::MyFunction("test_package"); // ensure we are using our provided IMGUI_USER_CONFIG ImGui::ShowDemoWindow(NULL); ImGui::Render(); diff --git a/recipes/imgui/all/test_v1_package/CMakeLists.txt b/recipes/imgui/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/imgui/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/imgui/all/test_v1_package/conanfile.py b/recipes/imgui/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..20d4d2e28d57e --- /dev/null +++ b/recipes/imgui/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/imgui/config.yml b/recipes/imgui/config.yml index ed3bbec220dfc..876df7dac7789 100644 --- a/recipes/imgui/config.yml +++ b/recipes/imgui/config.yml @@ -1,19 +1,19 @@ versions: - "1.74": + "1.89.1": folder: all - "1.75": + "1.88": folder: all - "1.76": + "1.87": folder: all - "1.77": + "1.86": folder: all - "1.78": + "1.85": folder: all - "1.79": + + # These versions belong to the docking branch in ImGUI repository. This branch is declared stable and production ready, and + # it is synced with `master` regularly. These versions are taken from that branch using the commit where `master` was synced + # after a regular release + "cci.20220621+1.88.docking": folder: all - "1.80": - folder: all - "1.81": - folder: all - "1.82": + "cci.20220207+1.87.docking": folder: all diff --git a/recipes/imguizmo/all/conandata.yml b/recipes/imguizmo/all/conandata.yml index 4a5b51cef7d8c..11e9cb824cab9 100644 --- a/recipes/imguizmo/all/conandata.yml +++ b/recipes/imguizmo/all/conandata.yml @@ -1,4 +1,4 @@ sources: - "cci.20210223": - url: "https://github.com/CedricGuillemet/ImGuizmo/archive/f7bbbe39971d9d45816417a70e9b53a0f698c56e.tar.gz" - sha256: "77e618cd7cd6f8d6b3a1426ac90dbbc5b4dcdd674e0fe5e5dec2c158eb54acb5" + "1.83": + url: "https://github.com/CedricGuillemet/ImGuizmo/archive/refs/tags/1.83.tar.gz" + sha256: "e6d05c5ebde802df7f6c342a06bc675bd2aa1c754d2d96755399a182187098a8" diff --git a/recipes/imguizmo/all/conanfile.py b/recipes/imguizmo/all/conanfile.py index 1d528cc4fd606..62c65e6489c8b 100644 --- a/recipes/imguizmo/all/conanfile.py +++ b/recipes/imguizmo/all/conanfile.py @@ -1,5 +1,4 @@ -import os -import glob +import functools from conans import ConanFile, CMake, tools @@ -8,13 +7,12 @@ class ImGuizmoConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/CedricGuillemet/ImGuizmo" description = "Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui" - topics = ("conan", "imgui", "3d", "graphics", "guizmo") + topics = ("imgui", "3d", "graphics", "guizmo") license = "MIT" settings = "os", "arch", "compiler", "build_type" exports_sources = ["CMakeLists.txt"] generators = "cmake" - requires = "imgui/1.82" options = { "shared": [True, False], @@ -25,8 +23,6 @@ class ImGuizmoConan(ConanFile): "fPIC": True } - _cmake = None - @property def _source_subfolder(self): return "source_subfolder" @@ -40,16 +36,17 @@ def configure(self): del self.options.fPIC def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("ImGuizmo-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def requirements(self): + self.requires("imgui/1.87") + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + cmake = CMake(self) + cmake.configure() + return cmake def build(self): cmake = self._configure_cmake() diff --git a/recipes/imguizmo/config.yml b/recipes/imguizmo/config.yml index ba1a801eb703b..cc1b28a70b3ee 100644 --- a/recipes/imguizmo/config.yml +++ b/recipes/imguizmo/config.yml @@ -1,3 +1,3 @@ versions: - "cci.20210223": + "1.83": folder: "all" diff --git a/recipes/immer/all/conandata.yml b/recipes/immer/all/conandata.yml index 415c26ec88772..811b858690dba 100644 --- a/recipes/immer/all/conandata.yml +++ b/recipes/immer/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "0.8.0": + url: "https://github.com/arximboldi/immer/archive/v0.8.0.tar.gz" + sha256: "4ed9e86a525f293e0ba053107b937d88b032674ec6e5db958816f2e412677fde" + "0.7.0": + url: "https://github.com/arximboldi/immer/archive/v0.7.0.tar.gz" + sha256: "cf67ab428aa3610eb0f72d0ea936c15cce3f91df26ee143ab783acd053507fe4" "0.6.2": url: "https://github.com/arximboldi/immer/archive/refs/tags/v0.6.2.tar.gz" sha256: "c3bb8847034437dee64adacb04e1e0163ae640b596c582eb4c0aa1d7c6447cd7" diff --git a/recipes/immer/all/conanfile.py b/recipes/immer/all/conanfile.py index 6c1041d141bb0..952501519b554 100644 --- a/recipes/immer/all/conanfile.py +++ b/recipes/immer/all/conanfile.py @@ -1,5 +1,6 @@ from conans import ConanFile, tools, errors +required_conan_version = ">=1.33.0" class ImmerConan(ConanFile): name = "immer" diff --git a/recipes/immer/all/test_package/conanfile.py b/recipes/immer/all/test_package/conanfile.py index adbb98652a54f..0242d96a644ca 100644 --- a/recipes/immer/all/test_package/conanfile.py +++ b/recipes/immer/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "example") self.run(bin_path, run_environment=True) diff --git a/recipes/immer/config.yml b/recipes/immer/config.yml index a09c617182ab2..9e53a8732b403 100644 --- a/recipes/immer/config.yml +++ b/recipes/immer/config.yml @@ -1,3 +1,7 @@ versions: + "0.8.0": + folder: all + "0.7.0": + folder: all "0.6.2": folder: all diff --git a/recipes/implot/all/CMakeLists.txt b/recipes/implot/all/CMakeLists.txt new file mode 100644 index 0000000000000..4a06ba1470e36 --- /dev/null +++ b/recipes/implot/all/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.4) +project(implot CXX) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +set(SOURCE_DIR source_subfolder) +file(GLOB SOURCE_FILES ${SOURCE_DIR}/*.cpp) +file(GLOB HEADER_FILES ${SOURCE_DIR}/*.h) + +add_library(${PROJECT_NAME} ${SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} PRIVATE ${SOURCE_DIR}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${CONAN_LIBS}) + +include(GNUInstallDirs) + +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(FILES ${HEADER_FILES} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) diff --git a/recipes/implot/all/conandata.yml b/recipes/implot/all/conandata.yml new file mode 100644 index 0000000000000..21af4dfe87312 --- /dev/null +++ b/recipes/implot/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "0.14": + url: "https://github.com/epezent/implot/archive/v0.14.tar.gz" + sha256: "1613af3e6554c0a74de20c6e60e9bce5ce35c2d4f9e1aa5ff963f7fe2d48af88" + "0.13": + url: "https://github.com/epezent/implot/archive/v0.13.tar.gz" + sha256: "acc8b012b6761c9b7ce1599a35fd861ac6dafb01368b1e938c90a3f654bd7589" + "0.12": + url: "https://github.com/epezent/implot/archive/v0.12.tar.gz" + sha256: "f8bc3b9b58dbabe3a0c0a2ebb8307d8e850012685332a85be36fcc4d4450be56" + "0.11": + url: "https://github.com/epezent/implot/archive/v0.11.tar.gz" + sha256: "1ec4c8501f70901132a9f14409c956b508a8ea3fe457e8518325b156dceada00" diff --git a/recipes/implot/all/conanfile.py b/recipes/implot/all/conanfile.py new file mode 100644 index 0000000000000..c90ba7a4fb427 --- /dev/null +++ b/recipes/implot/all/conanfile.py @@ -0,0 +1,65 @@ +from conans import ConanFile, CMake, tools +import functools + +required_conan_version = ">=1.33.0" + +class ImplotConan(ConanFile): + name = "implot" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/epezent/implot" + description = "Advanced 2D Plotting for Dear ImGui" + topics = ("imgui", "plot", "graphics", ) + license = "MIT" + settings = "os", "arch", "compiler", "build_type" + + exports_sources = ["CMakeLists.txt"] + generators = "cmake" + + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if tools.Version(self.version) >= "0.13": + self.requires("imgui/1.87") + else: + self.requires("imgui/1.86") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure() + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["implot"] diff --git a/recipes/implot/all/test_package/CMakeLists.txt b/recipes/implot/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..12c0824c90a91 --- /dev/null +++ b/recipes/implot/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(implot CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} implot::implot) diff --git a/recipes/implot/all/test_package/conanfile.py b/recipes/implot/all/test_package/conanfile.py new file mode 100644 index 0000000000000..4576de7f46804 --- /dev/null +++ b/recipes/implot/all/test_package/conanfile.py @@ -0,0 +1,15 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/implot/all/test_package/test_package.cpp b/recipes/implot/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..3e66b8ef948f6 --- /dev/null +++ b/recipes/implot/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + ImPlot::GetCurrentContext(); + return 0; +} diff --git a/recipes/implot/config.yml b/recipes/implot/config.yml new file mode 100644 index 0000000000000..d62abd0d999a8 --- /dev/null +++ b/recipes/implot/config.yml @@ -0,0 +1,9 @@ +versions: + "0.14": + folder: "all" + "0.13": + folder: "all" + "0.12": + folder: "all" + "0.11": + folder: "all" diff --git a/recipes/imutils-cpp/all/conandata.yml b/recipes/imutils-cpp/all/conandata.yml new file mode 100644 index 0000000000000..32d51c439957b --- /dev/null +++ b/recipes/imutils-cpp/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "1.0.1": + url: "https://github.com/thedevmanek/imutils-cpp/archive/refs/tags/v1.0.1.tar.gz" + sha256: "de79dce695a20550de1c383f74bf034ade22686f1197308ec612a1fb05fcf67a" +patches: + "1.0.1": + - patch_file: "patches/1.0.1-0001-fix-cmake.patch" + - patch_file: "patches/1.0.1-0002-unuse-bits_stdcpp_h.patch" + - patch_file: "patches/1.0.1-0003-fix-path-cast.patch" diff --git a/recipes/imutils-cpp/all/conanfile.py b/recipes/imutils-cpp/all/conanfile.py new file mode 100644 index 0000000000000..d577073c8baef --- /dev/null +++ b/recipes/imutils-cpp/all/conanfile.py @@ -0,0 +1,106 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout +from conan.tools import files +from conan.tools import scm +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches +from conan.tools.build import check_min_cppstd + +import os + +required_conan_version = ">=1.50.0" + +class ImutilsCppConan(ConanFile): + name = "imutils-cpp" + description = "This is a cpp version of popular python computer vision library imutils." + license = "Apache-2.0" + topics = ("opencv", "imutils", "computer vision", ) + homepage = "https://github.com/thedevmanek/imutils-cpp" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "9", + "Visual Studio": "15.7", + "msvc": "19.14", + "clang": "12", + "apple-clang": "10.14", + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + files.copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires("opencv/4.5.5") + self.requires("libcurl/7.84.0") + self.requires("openssl/1.1.1q") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and scm.Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + toolchain = CMakeToolchain(self) + toolchain.cache_variables["CMAKE_CXX_STANDARD"] = self._minimum_cpp_standard + toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + files.copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + files.rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + files.rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["imutils_cpp"] + + self.cpp_info.set_property("cmake_file_name", "imutils_cpp") + self.cpp_info.set_property("cmake_target_name", "imutils_cpp::imutils_cpp") + + self.cpp_info.requires.append("opencv::opencv") + self.cpp_info.requires.append("libcurl::libcurl") + + # TODO: Remove after Conan 2.0 + self.cpp_info.names["cmake_find_package"] = "imutils_cpp" + self.cpp_info.names["cmake_find_package_multi"] = "imutils_cpp" diff --git a/recipes/imutils-cpp/all/patches/1.0.1-0001-fix-cmake.patch b/recipes/imutils-cpp/all/patches/1.0.1-0001-fix-cmake.patch new file mode 100644 index 0000000000000..66ed5cd60c766 --- /dev/null +++ b/recipes/imutils-cpp/all/patches/1.0.1-0001-fix-cmake.patch @@ -0,0 +1,43 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7418a34..82b1777 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,13 +1,26 @@ + cmake_minimum_required(VERSION 3.9) + project(imutils_cpp VERSION 1.0.1 DESCRIPTION "imutils_cpp A series of convenience functions to make basic image processing functions such as translation, rotation, resizing and skeletonization easier with OpenCV ") ++set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + find_package(OpenCV REQUIRED) ++find_package(CURL REQUIRED) + include(GNUInstallDirs) +-add_library(imutils_cpp SHARED STATIC src/text.cpp include/imutils/text.h src/paths.cpp include/imutils/paths.h src/perspective.cpp include/imutils/perspective.h src/convenience.cpp include/imutils/convenience.h) +-set_target_properties(imutils_cpp PROPERTIES VERSION ${PROJECT_VERSION}) ++add_library(imutils_cpp src/text.cpp src/paths.cpp src/perspective.cpp src/convenience.cpp) ++set(IMUTILS_HEADERS include/imutils/text.h include/imutils/paths.h include/imutils/perspective.h include/imutils/convenience.h) ++set_target_properties(imutils_cpp PROPERTIES ++ VERSION ${PROJECT_VERSION} ++ PUBLIC_HEADER "${IMUTILS_HEADERS}" ++) + target_include_directories(imutils_cpp PRIVATE include) + target_include_directories(imutils_cpp PRIVATE src) + include(GNUInstallDirs) + install(TARGETS imutils_cpp + ${PROJECT_NAME} +- DESTINATION lib/${PROJECT_NAME}) +-target_link_libraries(imutils_cpp ${OpenCV_LIBS} curl) ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/imutils ++) ++target_link_libraries(imutils_cpp opencv::opencv CURL::libcurl) ++if (MSVC) ++ target_compile_options(imutils_cpp PRIVATE "/permissive-") ++endif() +diff --git b/build/.cmake/api/v1/query/client-vscode/query.json b/build/.cmake/api/v1/query/client-vscode/query.json +new file mode 100644 +index 0000000..82bb964 +--- /dev/null ++++ b/build/.cmake/api/v1/query/client-vscode/query.json +@@ -0,0 +1 @@ ++{"requests":[{"kind":"cache","version":2},{"kind":"codemodel","version":2},{"kind":"toolchains","version":1},{"kind":"cmakeFiles","version":1}]} +\ No newline at end of file diff --git a/recipes/imutils-cpp/all/patches/1.0.1-0002-unuse-bits_stdcpp_h.patch b/recipes/imutils-cpp/all/patches/1.0.1-0002-unuse-bits_stdcpp_h.patch new file mode 100644 index 0000000000000..2b2214447761b --- /dev/null +++ b/recipes/imutils-cpp/all/patches/1.0.1-0002-unuse-bits_stdcpp_h.patch @@ -0,0 +1,49 @@ +diff --git a/include/imutils/paths.h b/include/imutils/paths.h +index 29bc503..56b78e5 100644 +--- a/include/imutils/paths.h ++++ b/include/imutils/paths.h +@@ -5,7 +5,8 @@ + #define PATH_H + + #include "filesystem" +-#include "bits/stdc++.h" ++#include ++#include + /** @file paths.h **/ + /***************************************************************************//** + *@class Path +@@ -39,4 +40,4 @@ public: + std::vector + listFiles(std::string basePath, std::vector validExts = {}, std::string contains = "" + ); +-}; +\ No newline at end of file ++}; +diff --git a/src/paths.cpp b/src/paths.cpp +index 380be73..d0bc7f5 100644 +--- a/src/paths.cpp ++++ b/src/paths.cpp +@@ -2,7 +2,9 @@ + // Created by jonsnow on 07/02/22. + // + #include "filesystem" +-#include "bits/stdc++.h" ++#include ++#include ++#include + #include "../include/imutils/paths.h" + + namespace fs = std::filesystem; +diff --git a/src/text.cpp b/src/text.cpp +index 73bec10..6336964 100644 +--- a/src/text.cpp ++++ b/src/text.cpp +@@ -1,5 +1,7 @@ + #include "string" +-#include "bits/stdc++.h" ++#include ++#include ++#include + #include "opencv2/core.hpp" + #include "opencv2/imgproc.hpp" + diff --git a/recipes/imutils-cpp/all/patches/1.0.1-0003-fix-path-cast.patch b/recipes/imutils-cpp/all/patches/1.0.1-0003-fix-path-cast.patch new file mode 100644 index 0000000000000..7658e09e6bedd --- /dev/null +++ b/recipes/imutils-cpp/all/patches/1.0.1-0003-fix-path-cast.patch @@ -0,0 +1,22 @@ +diff --git a/src/paths.cpp b/src/paths.cpp +index d0bc7f5..d39ffb6 100644 +--- a/src/paths.cpp ++++ b/src/paths.cpp +@@ -19,14 +19,14 @@ std::vector Path::listFiles(std::string basePath, std::vector filesDirs; + for (const auto &dirEntry: fs::recursive_directory_iterator(basePath)) { + std::filesystem::path file = dirEntry.path(); +- if (contains != "" and ((std::string) file.filename()).find(contains) == std::string::npos) { ++ if (contains != "" and file.filename().string().find(contains) == std::string::npos) { + continue; + } + if (validExts.empty()) { +- filesDirs.push_back(dirEntry.path()); ++ filesDirs.push_back(dirEntry.path().string()); + } else { + if (std::find(validExts.begin(), validExts.end(), file.extension()) != validExts.end()){ +- filesDirs.push_back(dirEntry.path()); ++ filesDirs.push_back(dirEntry.path().string()); + + } + diff --git a/recipes/imutils-cpp/all/test_package/CMakeLists.txt b/recipes/imutils-cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7dc0936c26b56 --- /dev/null +++ b/recipes/imutils-cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +find_package(imutils_cpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE imutils_cpp::imutils_cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/imutils-cpp/all/test_package/conanfile.py b/recipes/imutils-cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..c7933801f1176 --- /dev/null +++ b/recipes/imutils-cpp/all/test_package/conanfile.py @@ -0,0 +1,22 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/imutils-cpp/all/test_package/test_package.cpp b/recipes/imutils-cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..42bfe878da9e8 --- /dev/null +++ b/recipes/imutils-cpp/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include + +#include + +int main() { + cv::Mat image1 = cv::Mat::eye(256, 256, CV_8UC3); + cv::Mat image2 = Convenience::translate(image1, 5.0, 3.0); + + return 0; +} diff --git a/recipes/imutils-cpp/all/test_v1_package/CMakeLists.txt b/recipes/imutils-cpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..529de77d0cf37 --- /dev/null +++ b/recipes/imutils-cpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(imutils_cpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE imutils_cpp::imutils_cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/imutils-cpp/all/test_v1_package/conanfile.py b/recipes/imutils-cpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2490acfa82ff8 --- /dev/null +++ b/recipes/imutils-cpp/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/imutils-cpp/config.yml b/recipes/imutils-cpp/config.yml new file mode 100644 index 0000000000000..715e55357a17b --- /dev/null +++ b/recipes/imutils-cpp/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.1": + folder: all diff --git a/recipes/incbin/all/conandata.yml b/recipes/incbin/all/conandata.yml new file mode 100644 index 0000000000000..9da2f972ac124 --- /dev/null +++ b/recipes/incbin/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20211107": + url: "https://github.com/graphitemaster/incbin/archive/6e576cae5ab5810f25e2631f2e0b80cbe7dc8cbf.tar.gz" + sha256: "d23582689c46604cad116495dbd8aceb1974b46164114a231e8c8144ae12b230" diff --git a/recipes/incbin/all/conanfile.py b/recipes/incbin/all/conanfile.py new file mode 100644 index 0000000000000..ec1c1be93ab74 --- /dev/null +++ b/recipes/incbin/all/conanfile.py @@ -0,0 +1,32 @@ +from conans.errors import ConanInvalidConfiguration +from conans import ConanFile, tools + +required_conan_version = ">=1.33.0" + +class IncbinConan(ConanFile): + name = "incbin" + license = "Unlicense" + url = "https://github.com/conan-io/conan-center-index" + description = "Include binary files in C/C++" + topics = ("include", "binary", "preprocess") + homepage = "https://github.com/graphitemaster/incbin/" + no_copy_source = True + settings = "compiler" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("Currently incbin recipe is not supported for Visual Studio because it requires external command 'incbin'.") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("UNLICENSE", "licenses", self._source_subfolder) + self.copy("incbin.h", "include", self._source_subfolder) + + def package_id(self): + self.info.header_only() diff --git a/recipes/incbin/all/test_package/CMakeLists.txt b/recipes/incbin/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..0016bcbe2bd7d --- /dev/null +++ b/recipes/incbin/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(incbin CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} incbin::incbin) +target_compile_definitions(${PROJECT_NAME} PUBLIC INCBIN_FILE="${CMAKE_SOURCE_DIR}/CMakeLists.txt") diff --git a/recipes/incbin/all/test_package/conanfile.py b/recipes/incbin/all/test_package/conanfile.py new file mode 100644 index 0000000000000..27c426e38df11 --- /dev/null +++ b/recipes/incbin/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/incbin/all/test_package/test_package.c b/recipes/incbin/all/test_package/test_package.c new file mode 100644 index 0000000000000..c79ecf17ddd08 --- /dev/null +++ b/recipes/incbin/all/test_package/test_package.c @@ -0,0 +1,15 @@ +#define INCBIN_PREFIX g_ +#define INCBIN_STYLE INCBIN_STYLE_SNAKE +#include "incbin.h" + +INCBIN(cmake, INCBIN_FILE); + +#include + +int main(int argc, char* argv[]) { + (void)g_cmake_data[0]; + (void)*g_cmake_end; + printf(INCBIN_FILE" size is %d\n", g_cmake_size); + + return 0; +} diff --git a/recipes/incbin/config.yml b/recipes/incbin/config.yml new file mode 100644 index 0000000000000..a9e4060c13dfa --- /dev/null +++ b/recipes/incbin/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20211107": + folder: all diff --git a/recipes/indicators/all/conandata.yml b/recipes/indicators/all/conandata.yml index 68036ded94180..3b571273f51e6 100644 --- a/recipes/indicators/all/conandata.yml +++ b/recipes/indicators/all/conandata.yml @@ -5,4 +5,7 @@ sources: "2.0": url: "https://github.com/p-ranav/indicators/archive/v2.0.tar.gz" sha256: "ef296fa614edcd798db0ac6c3c0f2990682cae8b83724a4db34eed17521c75f7" + "2.2": + url: "https://github.com/p-ranav/indicators/archive/v2.2.tar.gz" + sha256: "b768f1b7ca64a413503f72d5460cc617c1458c17fb7a8c0ee503d753e1f20d03" diff --git a/recipes/indicators/config.yml b/recipes/indicators/config.yml index 2fb677cdb0eb8..3e719d24708ab 100644 --- a/recipes/indicators/config.yml +++ b/recipes/indicators/config.yml @@ -3,3 +3,5 @@ versions: folder: "all" "2.0": folder: "all" + "2.2": + folder: "all" diff --git a/recipes/indirect_value/all/conandata.yml b/recipes/indirect_value/all/conandata.yml new file mode 100644 index 0000000000000..2e011d24cdb18 --- /dev/null +++ b/recipes/indirect_value/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.0.1": + url: https://github.com/jbcoe/indirect_value/archive/refs/tags/v0.0.1.tar.gz + sha256: 01b61737f9e6b3601fc588a0070833f2fbb67ab5fb1d1482d5b8ca8b64f44f33 diff --git a/recipes/indirect_value/all/conanfile.py b/recipes/indirect_value/all/conanfile.py new file mode 100644 index 0000000000000..ce84972958e04 --- /dev/null +++ b/recipes/indirect_value/all/conanfile.py @@ -0,0 +1,70 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.43.0" + + +class IndirectValueConan(ConanFile): + name = "indirect_value" + homepage = "https://github.com/jbcoe/indirect_value" + description = "Production-quality reference implementation of P1950: A Free-Store-Allocated Value Type For C++" + topics = ("std", "vocabulary-type", "value-semantics") + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "gcc": "8", + "clang": "8", + "apple-clang": "11" + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get( + str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} " + "compiler support.".format( + self.name, self.settings.compiler)) + else: + if tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration( + "{} requires C++{} support. " + "The current compiler {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, + self.settings.compiler, + self.settings.compiler.version)) + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + def package(self): + self.copy(pattern="indirect_value.*", dst="include", + src=self._source_subfolder) + self.copy("*LICENSE*", dst="licenses", keep_path=False) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "indirect_value") + self.cpp_info.set_property("cmake_target_name", "indirect_value::indirect_value") + + self.cpp_info.names["cmake_find_package"] = "indirect_value" + self.cpp_info.names["cmake_find_package_multi"] = "indirect_value" diff --git a/recipes/indirect_value/all/test_package/CMakeLists.txt b/recipes/indirect_value/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fd68256049f87 --- /dev/null +++ b/recipes/indirect_value/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(indirect_value REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE indirect_value::indirect_value) +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) diff --git a/recipes/indirect_value/all/test_package/conanfile.py b/recipes/indirect_value/all/test_package/conanfile.py new file mode 100644 index 0000000000000..9b63bd176646b --- /dev/null +++ b/recipes/indirect_value/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/indirect_value/all/test_package/test_package.cpp b/recipes/indirect_value/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..c2649413b40d1 --- /dev/null +++ b/recipes/indirect_value/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include + +using namespace isocpp_p1950; + +int main() +{ + indirect_value result{new int(EXIT_SUCCESS)}; + return *result; +} diff --git a/recipes/indirect_value/config.yml b/recipes/indirect_value/config.yml new file mode 100644 index 0000000000000..f6f5b5679b9d4 --- /dev/null +++ b/recipes/indirect_value/config.yml @@ -0,0 +1,3 @@ +versions: + "0.0.1": + folder: all diff --git a/recipes/inih/all/conandata.yml b/recipes/inih/all/conandata.yml index 8de8ba5ecf237..f45a313d7e7e2 100644 --- a/recipes/inih/all/conandata.yml +++ b/recipes/inih/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "56": + url: "https://github.com/benhoyt/inih/archive/r56.tar.gz" + sha256: "4f2ba6bd122d30281a8c7a4d5723b7af90b56aa828c0e88256d7fceda03a491a" + "55": + url: "https://github.com/benhoyt/inih/archive/r55.tar.gz" + sha256: "ba55f8ae2a8caf0653f30f48567241e14ea916acfc13481f502d8a9c8f507f68" "52": url: "https://github.com/benhoyt/inih/archive/r52.tar.gz" sha256: "439cff9ce9a8afc52d08772ac3e93b3cecd79c7707f871fb4534fb3a48201880" diff --git a/recipes/inih/all/conanfile.py b/recipes/inih/all/conanfile.py index ebd28d061f414..10b7f92326704 100644 --- a/recipes/inih/all/conanfile.py +++ b/recipes/inih/all/conanfile.py @@ -1,37 +1,34 @@ -from conans import ConanFile, Meson, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rmdir +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.microsoft import is_msvc import os +required_conan_version = ">=1.49.0" + class InihConan(ConanFile): name = "inih" description = "Simple .INI file parser in C, good for embedded systems " license = "BSD-3-Clause" - topics = ("conan", "inih", "ini", "configuration", "parser") + topics = ("inih", "ini", "configuration", "parser") homepage = "https://github.com/benhoyt/inih" url = "https://github.com/conan-io/conan-center-index" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], } - default_options = { "shared": False, "fPIC": True, } - _meson = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -39,40 +36,76 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.os == "Windows": - raise ConanInvalidConfiguration("Shared inih is not supported") - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def validate(self): + if self.info.options.shared and is_msvc(self): + raise ConanInvalidConfiguration("Shared inih is not supported with msvc") def build_requirements(self): - self.build_requires("meson/0.55.3") + self.tool_requires("meson/0.63.1") + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-r{}".format(self.name, self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = MesonToolchain(self) + tc.project_options["distro_install"] = True + tc.project_options["with_INIReader"] = True + # TODO: fixed in conan 1.51.0? + tc.project_options["bindir"] = "bin" + tc.project_options["libdir"] = "lib" + tc.generate() - def _configure_meson(self): - if self._meson: - return self._meson - self._meson = Meson(self) - self._meson.options["distro_install"] = True - self._meson.configure(source_folder=self._source_subfolder, build_folder=self._build_subfolder) - return self._meson + env = VirtualBuildEnv(self) + env.generate(scope="build") def build(self): - meson = self._configure_meson() + meson = Meson(self) + meson.configure() meson.build() def package(self): - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) - meson = self._configure_meson() + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + meson = Meson(self) meson.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - - if self.settings.compiler == "Visual Studio": - # https://github.com/mesonbuild/meson/issues/7378 - os.rename(os.path.join(self.package_folder, "lib", "libinih.a"), - os.path.join(self.package_folder, "lib", "inih.lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + fix_apple_shared_install_name(self) + fix_msvc_libname(self) def package_info(self): - self.cpp_info.libs = ["inih"] + self.cpp_info.set_property("pkg_config_name", "INIReader") + + self.cpp_info.components["libinih"].set_property("pkg_config_name", "inih") + self.cpp_info.components["libinih"].libs = ["inih"] + + self.cpp_info.components["inireader"].set_property("pkg_config_name", "INIReader") + self.cpp_info.components["inireader"].libs = ["INIReader"] + self.cpp_info.components["inireader"].requires = ["libinih"] + +def fix_msvc_libname(conanfile, remove_lib_prefix=True): + """remove lib prefix & change extension to .lib""" + from conan.tools.files import rename + import glob + if not is_msvc(conanfile): + return + libdirs = getattr(conanfile.cpp.package, "libdirs") + for libdir in libdirs: + for ext in [".dll.a", ".dll.lib", ".a"]: + full_folder = os.path.join(conanfile.package_folder, libdir) + for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")): + libname = os.path.basename(filepath)[0:-len(ext)] + if remove_lib_prefix and libname[0:3] == "lib": + libname = libname[3:] + rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib")) diff --git a/recipes/inih/all/test_package/CMakeLists.txt b/recipes/inih/all/test_package/CMakeLists.txt index 3a403dc404b41..6c1fdbf05ad25 100644 --- a/recipes/inih/all/test_package/CMakeLists.txt +++ b/recipes/inih/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +find_package(inih CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE inih::inih) diff --git a/recipes/inih/all/test_package/conanfile.py b/recipes/inih/all/test_package/conanfile.py index 091903032a6e8..43b19d1f08b9a 100644 --- a/recipes/inih/all/test_package/conanfile.py +++ b/recipes/inih/all/test_package/conanfile.py @@ -1,11 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os import textwrap class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,14 +21,14 @@ def build(self): cmake.build() def test(self): - with open("test.ini", "w") as fn: - fn.write(textwrap.dedent("""\ - [protocol] - version = 1337 - [user] - name = conan-center-index - email = info@conan.io - """)) - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + with open("test.ini", "w") as fn: + fn.write(textwrap.dedent("""\ + [protocol] + version = 1337 + [user] + name = conan-center-index + email = info@conan.io + """)) + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/inih/all/test_v1_package/CMakeLists.txt b/recipes/inih/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..65b2e905e1b37 --- /dev/null +++ b/recipes/inih/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(inih REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE inih::inih) diff --git a/recipes/inih/all/test_v1_package/conanfile.py b/recipes/inih/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..3394a39caa745 --- /dev/null +++ b/recipes/inih/all/test_v1_package/conanfile.py @@ -0,0 +1,27 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os +import textwrap + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + with open("test.ini", "w") as fn: + fn.write(textwrap.dedent("""\ + [protocol] + version = 1337 + [user] + name = conan-center-index + email = info@conan.io + """)) + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/inih/config.yml b/recipes/inih/config.yml index 6d613243b77f9..3746836949531 100644 --- a/recipes/inih/config.yml +++ b/recipes/inih/config.yml @@ -1,4 +1,8 @@ versions: + "56": + folder: "all" + "55": + folder: "all" "52": folder: "all" "51": diff --git a/recipes/inja/all/conandata.yml b/recipes/inja/all/conandata.yml index 637442705a29d..31e508b43a016 100644 --- a/recipes/inja/all/conandata.yml +++ b/recipes/inja/all/conandata.yml @@ -1,10 +1,13 @@ sources: - 3.0.0: - sha256: 99cdb0d90ab1adff9ec63b40a867ec14e1b217fe2d7ac07a6124de201de4ffd0 - url: https://github.com/pantor/inja/archive/v3.0.0.tar.gz - 3.1.0: - sha256: f4210493e7e3c62d3050ca6e5e9dd72823ec4125a469fa9b28519d7f32fc9731 - url: https://github.com/pantor/inja/archive/v3.1.0.tar.gz - 3.2.0: - sha256: 825e1f0076504b5aac99cc9ad8c4cbfdc33e57c06c40353f2d7b93a33caae17d - url: https://github.com/pantor/inja/archive/v3.2.0.tar.gz + "3.3.0": + url: "https://github.com/pantor/inja/archive/v3.3.0.tar.gz" + sha256: "e628d994762dcdaa9a97f63a9b8b73d9af51af0ffa5acea6bdbba0aceaf8ee25" + "3.2.0": + url: "https://github.com/pantor/inja/archive/v3.2.0.tar.gz" + sha256: "825e1f0076504b5aac99cc9ad8c4cbfdc33e57c06c40353f2d7b93a33caae17d" + "3.1.0": + url: "https://github.com/pantor/inja/archive/v3.1.0.tar.gz" + sha256: "f4210493e7e3c62d3050ca6e5e9dd72823ec4125a469fa9b28519d7f32fc9731" + "3.0.0": + url: "https://github.com/pantor/inja/archive/v3.0.0.tar.gz" + sha256: "99cdb0d90ab1adff9ec63b40a867ec14e1b217fe2d7ac07a6124de201de4ffd0" diff --git a/recipes/inja/all/conanfile.py b/recipes/inja/all/conanfile.py index bdf98d5eac8c1..ef0c873020773 100644 --- a/recipes/inja/all/conanfile.py +++ b/recipes/inja/all/conanfile.py @@ -1,7 +1,11 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.50.0" + class InjaConan(ConanFile): name = "inja" @@ -9,33 +13,52 @@ class InjaConan(ConanFile): homepage = "https://github.com/pantor/inja" url = "https://github.com/conan-io/conan-center-index" description = "Inja is a template engine for modern C++, loosely inspired by jinja for python" - topics = ("conan", "jinja2", "string templates", "templates engine") + topics = ("jinja2", "string templates", "templates engine") + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def requirements(self): - self.requires("nlohmann_json/3.9.1") + self.requires("nlohmann_json/3.11.2") def package_id(self): - self.info.header_only() + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "inja") + self.cpp_info.set_property("cmake_target_name", "pantor::inja") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once legacy generators removed self.cpp_info.filenames["cmake_find_package"] = "inja" self.cpp_info.filenames["cmake_find_package_multi"] = "inja" self.cpp_info.names["cmake_find_package"] = "pantor" self.cpp_info.names["cmake_find_package_multi"] = "pantor" self.cpp_info.components["libinja"].names["cmake_find_package"] = "inja" self.cpp_info.components["libinja"].names["cmake_find_package_multi"] = "inja" + self.cpp_info.components["libinja"].set_property("cmake_target_name", "pantor::inja") self.cpp_info.components["libinja"].requires = ["nlohmann_json::nlohmann_json"] + self.cpp_info.components["libinja"].bindirs = [] + self.cpp_info.components["libinja"].frameworkdirs = [] + self.cpp_info.components["libinja"].libdirs = [] + self.cpp_info.components["libinja"].resdirs = [] diff --git a/recipes/inja/all/test_package/CMakeLists.txt b/recipes/inja/all/test_package/CMakeLists.txt index a260e6888ede7..e938e7d47ed20 100644 --- a/recipes/inja/all/test_package/CMakeLists.txt +++ b/recipes/inja/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(inja REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} pantor::inja) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE pantor::inja) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/inja/all/test_package/conanfile.py b/recipes/inja/all/test_package/conanfile.py index 6c9d5dba712c7..d120a992c06a6 100644 --- a/recipes/inja/all/test_package/conanfile.py +++ b/recipes/inja/all/test_package/conanfile.py @@ -1,9 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/inja/all/test_v1_package/CMakeLists.txt b/recipes/inja/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..91d516c3ec515 --- /dev/null +++ b/recipes/inja/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(inja REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE pantor::inja) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/inja/all/test_v1_package/conanfile.py b/recipes/inja/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/inja/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/inja/config.yml b/recipes/inja/config.yml index fcbb897de4c0f..8b57847852970 100644 --- a/recipes/inja/config.yml +++ b/recipes/inja/config.yml @@ -1,7 +1,9 @@ versions: - 3.0.0: + "3.3.0": folder: all - 3.1.0: + "3.2.0": folder: all - 3.2.0: + "3.1.0": + folder: all + "3.0.0": folder: all diff --git a/recipes/innoextract/all/conandata.yml b/recipes/innoextract/all/conandata.yml new file mode 100644 index 0000000000000..a280c970476d1 --- /dev/null +++ b/recipes/innoextract/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "1.9.0": + url: + - "https://constexpr.org/innoextract/files/innoextract-1.9.tar.gz" + - "https://github.com/dscharrer/innoextract/releases/download/1.9/innoextract-1.9.tar.gz" + sha256: "6344a69fc1ed847d4ed3e272e0da5998948c6b828cb7af39c6321aba6cf88126" +patches: + "1.9.0": + - patch_file: "patches/0001-cmake-fix-module.patch" + - patch_file: "patches/0002-remove-custom-cmake-find-modules.patch" diff --git a/recipes/innoextract/all/conanfile.py b/recipes/innoextract/all/conanfile.py new file mode 100644 index 0000000000000..680179fce10a8 --- /dev/null +++ b/recipes/innoextract/all/conanfile.py @@ -0,0 +1,71 @@ +from conan import ConanFile +from conan.tools.files import get, rmdir, copy, apply_conandata_patches, export_conandata_patches +from conan.tools.cmake import cmake_layout, CMake, CMakeDeps, CMakeToolchain +from conan.tools.env import VirtualBuildEnv +import os + + +required_conan_version = ">=1.52.0" + + +class InnoextractConan(ConanFile): + name = "innoextract" + description = "Extract contents of Inno Setup installers" + license = "LicenseRef-LICENSE" + topics = ("inno-setup", "decompression") + homepage = "https://constexpr.org/innoextract" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("boost/1.80.0", private=True) + self.requires("xz_utils/5.2.5", private=True) + self.requires("libiconv/1.17", private=True) + + def package_id(self): + del self.info.settings.compiler + self.info.requires.clear() + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, + destination=self.source_folder) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = CMakeToolchain(self) + # Turn off static library detection, which is on by default on Windows. + # This keeps the CMakeLists.txt from trying to detect static Boost + # libraries and use Boost components for zlib and BZip2. Getting the + # libraries via Conan does the correct thing without other assistance. + tc.variables["USE_STATIC_LIBS"] = False + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + os.remove(os.path.join(self.source_folder, 'cmake', 'FindLZMA.cmake')) + os.remove(os.path.join(self.source_folder, 'cmake', 'Findiconv.cmake')) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + bindir = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH environment variable: {bindir}") + self.env_info.PATH.append(bindir) diff --git a/recipes/innoextract/all/patches/0001-cmake-fix-module.patch b/recipes/innoextract/all/patches/0001-cmake-fix-module.patch new file mode 100644 index 0000000000000..2997e1cb0a3a5 --- /dev/null +++ b/recipes/innoextract/all/patches/0001-cmake-fix-module.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index dbb64f1..a8a67e8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -105,7 +105,7 @@ endif() + + include(CheckSymbolExists) + +-set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # For custom cmake modules ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") # For custom cmake modules + include(BuildType) + include(CompileCheck) + include(CreateSourceGroups) diff --git a/recipes/innoextract/all/patches/0002-remove-custom-cmake-find-modules.patch b/recipes/innoextract/all/patches/0002-remove-custom-cmake-find-modules.patch new file mode 100644 index 0000000000000..7c56b3841dde6 --- /dev/null +++ b/recipes/innoextract/all/patches/0002-remove-custom-cmake-find-modules.patch @@ -0,0 +1,19 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a8a67e8..358703f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -140,10 +140,10 @@ if(USE_ARC4) + endif() + + if(USE_LZMA) +- find_package(LZMA REQUIRED) +- list(APPEND LIBRARIES ${LZMA_LIBRARIES}) +- include_directories(SYSTEM ${LZMA_INCLUDE_DIR}) +- add_definitions(${LZMA_DEFINITIONS}) ++ find_package(LibLZMA REQUIRED) ++ list(APPEND LIBRARIES ${LibLZMA_LIBRARIES}) ++ include_directories(SYSTEM ${LibLZMA_INCLUDE_DIR}) ++ add_definitions(${LibLZMA_DEFINITIONS}) + set(INNOEXTRACT_HAVE_LZMA 1) + else() + message(WARNING "\nDisabling LZMA decompression support.\n" diff --git a/recipes/innoextract/all/test_package/conanfile.py b/recipes/innoextract/all/test_package/conanfile.py new file mode 100644 index 0000000000000..6a4e652eac543 --- /dev/null +++ b/recipes/innoextract/all/test_package/conanfile.py @@ -0,0 +1,14 @@ +from conan import ConanFile +from conan.tools.build import can_run + +class TestPackageConan(ConanFile): + settings = "os", "arch", "build_type", "compiler" + generators = "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def test(self): + if can_run(self): + self.run("innoextract --version", env="conanrun") diff --git a/recipes/innoextract/all/test_v1_package/conanfile.py b/recipes/innoextract/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..dc77b21f20519 --- /dev/null +++ b/recipes/innoextract/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from six import StringIO +from conans import ConanFile, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "build_type", "compiler" + + def test(self): + if not tools.cross_building(self): + output = StringIO() + self.run("innoextract --version", output=output, + run_environment=True) + output_str = str(output.getvalue()) + self.output.info("Installed version: {}".format(output_str)) + require_version = str(self.deps_cpp_info["innoextract"].version) + require_version = ".".join(require_version.split(".")[:2]) + self.output.info("Expected version: {}".format(require_version)) + assert_innoextract_version = "innoextract %s" % require_version + assert(assert_innoextract_version in output_str) diff --git a/recipes/innoextract/config.yml b/recipes/innoextract/config.yml new file mode 100644 index 0000000000000..95efce85442dd --- /dev/null +++ b/recipes/innoextract/config.yml @@ -0,0 +1,3 @@ +versions: + "1.9.0": + folder: "all" diff --git a/recipes/intel-neon2sse/all/CMakeLists.txt b/recipes/intel-neon2sse/all/CMakeLists.txt new file mode 100644 index 0000000000000..d605c85283e5c --- /dev/null +++ b/recipes/intel-neon2sse/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper C) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/intel-neon2sse/all/conandata.yml b/recipes/intel-neon2sse/all/conandata.yml new file mode 100644 index 0000000000000..d8a2b36b77424 --- /dev/null +++ b/recipes/intel-neon2sse/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20210225": + url: "https://github.com/intel/ARM_NEON_2_x86_SSE/archive/a1652fd5253afbf3e39357b012974f93511f6108.tar.gz" + sha256: "a795f7e20b7bc4cec4a23bc54af2af3333c0c4b84c4fe2479642aa391e35844f" diff --git a/recipes/intel-neon2sse/all/conanfile.py b/recipes/intel-neon2sse/all/conanfile.py new file mode 100644 index 0000000000000..0ddd476cb87e2 --- /dev/null +++ b/recipes/intel-neon2sse/all/conanfile.py @@ -0,0 +1,68 @@ +from conans import ConanFile, tools, CMake +from conans.errors import ConanInvalidConfiguration +import os + + +required_conan_version = ">=1.33.0" + +class IntelNeon2sseConan(ConanFile): + name = "intel-neon2sse" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/intel/ARM_NEON_2_x86_SSE" + description = "Header only library intended to simplify ARM->IA32 porting" + license = "BSD-2-Clause" + topics = "neon", "sse", "port", "translation", "intrinsics" + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + exports_sources = "CMakeLists.txt" + options = { + "SSE4": [True, False], + "disable_performance_warnings": [True, False], + } + default_options = { + "SSE4": False, + "disable_performance_warnings": False, + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure() + return self._cmake + + def validate(self): + if self.settings.arch not in ("x86", "x86_64"): + raise ConanInvalidConfiguration("neon2sse only supports arch={x86,x86_64}") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + tools.rmdir(os.path.join(self.package_folder, "lib")) + + def package_id(self): + self.info.header_only() + + def package_info(self): + self.cpp_info.libdirs = [] + self.cpp_info.names["cmake_find_package"] = "NEON_2_SSE" + self.cpp_info.names["cmake_find_package_multi"] = "NEON_2_SSE" + if self.options.SSE4: + self.cpp_info.defines.append("USE_SSE4") + if self.options.disable_performance_warnings: + self.cpp_info.defines.append("NEON2SSE_DISABLE_PERFORMANCE_WARNING") diff --git a/recipes/intel-neon2sse/all/test_package/CMakeLists.txt b/recipes/intel-neon2sse/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..63169f693286c --- /dev/null +++ b/recipes/intel-neon2sse/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(NEON_2_SSE REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} NEON_2_SSE::NEON_2_SSE) diff --git a/recipes/intel-neon2sse/all/test_package/conanfile.py b/recipes/intel-neon2sse/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5493d58611803 --- /dev/null +++ b/recipes/intel-neon2sse/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/intel-neon2sse/all/test_package/test_package.c b/recipes/intel-neon2sse/all/test_package/test_package.c new file mode 100644 index 0000000000000..32dcf22c0c202 --- /dev/null +++ b/recipes/intel-neon2sse/all/test_package/test_package.c @@ -0,0 +1,26 @@ +#include +#include + +int main() +{ + uint64_t a = 0x0102030405060708; + uint64_t b = 0x0102030405060708; + union { + char c[8]; + uint64_t i; + } c; + uint8x8_t va = vcreate_u8(a); + uint8x8_t vb = vcreate_u8(b); + uint8x8_t vc = vmul_u8(va, vb); + + vst1_u8(c.c, vc); + + if (c.i != 0x0104091019243140) { + fprintf(stderr, "Wrong result\n"); + return 1; + } else { + printf("test_package ran successfully\n"); + } + + return 0; +} diff --git a/recipes/intel-neon2sse/config.yml b/recipes/intel-neon2sse/config.yml new file mode 100644 index 0000000000000..81399ac24675e --- /dev/null +++ b/recipes/intel-neon2sse/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210225": + folder: all diff --git a/recipes/inversify-cpp/all/conandata.yml b/recipes/inversify-cpp/all/conandata.yml new file mode 100644 index 0000000000000..1d68ebc9ec1d5 --- /dev/null +++ b/recipes/inversify-cpp/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.1.0": + url: "https://github.com/mosure/inversify-cpp/archive/refs/tags/2.1.0.tar.gz" + sha256: "6829b45a558c7eb4e15fdc08cb0dfe3c76f708c00bbdcc06d1fcdbd0a3ef55d1" diff --git a/recipes/inversify-cpp/all/conanfile.py b/recipes/inversify-cpp/all/conanfile.py new file mode 100644 index 0000000000000..3d897954ee020 --- /dev/null +++ b/recipes/inversify-cpp/all/conanfile.py @@ -0,0 +1,50 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + + +class InversifyCppConan(ConanFile): + name = "inversify-cpp" + description = "C++17 inversion of control and dependency injection container library" + topics = ("ioc", "container", "dependency", "injection") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/mosure/inversify-cpp" + license = "MIT" + settings = "compiler" + no_copy_source = True + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "15.7", + "clang": "6", + "apple-clang": "11", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 17) + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version: + if tools.Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration("{} requires C++17, which your compiler does not support.".format(self.name)) + else: + self.output.warn("{} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name)) + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + + def package_id(self): + self.info.header_only() diff --git a/recipes/inversify-cpp/all/test_package/CMakeLists.txt b/recipes/inversify-cpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fc7a3028bf1a1 --- /dev/null +++ b/recipes/inversify-cpp/all/test_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(inversify-cpp CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} inversify-cpp::inversify-cpp) + +set_target_properties(${PROJECT_NAME} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON +) diff --git a/recipes/inversify-cpp/all/test_package/conanfile.py b/recipes/inversify-cpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/inversify-cpp/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/inversify-cpp/all/test_package/test_package.cpp b/recipes/inversify-cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..3bf0d0cfb88a1 --- /dev/null +++ b/recipes/inversify-cpp/all/test_package/test_package.cpp @@ -0,0 +1,22 @@ +#include + +#include "mosure/inversify.hpp" + + +namespace inversify = mosure::inversify; + +namespace symbols { + using foo = inversify::Symbol; +} + + +int main() { + inversify::Container< + symbols::foo + > container; + + container.bind().toConstantValue(true); + + std::cout <<"working: " << container.get() << std::endl; + return 0; +} diff --git a/recipes/inversify-cpp/config.yml b/recipes/inversify-cpp/config.yml new file mode 100644 index 0000000000000..dfff490f9a9b6 --- /dev/null +++ b/recipes/inversify-cpp/config.yml @@ -0,0 +1,3 @@ +versions: + "2.1.0": + folder: all diff --git a/recipes/irrxml/all/CMakeLists.txt b/recipes/irrxml/all/CMakeLists.txt index f9f23cc0046f5..f6e0593393ea8 100644 --- a/recipes/irrxml/all/CMakeLists.txt +++ b/recipes/irrxml/all/CMakeLists.txt @@ -1,35 +1,20 @@ cmake_minimum_required(VERSION 3.4) -project(IrrXML CXX) +project(IrrXML LANGUAGES CXX) -include("conanbuildinfo.cmake") -conan_basic_setup() +include(GNUInstallDirs) -set(SOURCES - ${CMAKE_SOURCE_DIR}/source_subfolder/src/CXMLReaderImpl.h - ${CMAKE_SOURCE_DIR}/source_subfolder/src/fast_atof.h - ${CMAKE_SOURCE_DIR}/source_subfolder/src/heapsort.h - ${CMAKE_SOURCE_DIR}/source_subfolder/src/irrArray.h - ${CMAKE_SOURCE_DIR}/source_subfolder/src/irrString.h - ${CMAKE_SOURCE_DIR}/source_subfolder/src/irrTypes.h - ${CMAKE_SOURCE_DIR}/source_subfolder/src/irrXML.cpp - ${CMAKE_SOURCE_DIR}/source_subfolder/src/irrXML.h +add_library(IrrXML ${IRRXML_SRC_DIR}/src/irrXML.cpp) +set_target_properties(IrrXML PROPERTIES + WINDOWS_EXPORT_ALL_SYMBOLS ON + PUBLIC_HEADER ${IRRXML_SRC_DIR}/src/irrXML.h ) - -add_library(${CMAKE_PROJECT_NAME} ${SOURCES}) -if ( MSVC ) - target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE _SCL_SECURE_NO_WARNINGS) - target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS) -endif ( MSVC ) - -if (WIN32 AND BUILD_SHARED_LIBS) - set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) +if(MSVC) + target_compile_definitions(IrrXML PRIVATE _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS) endif() -set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES - PUBLIC_HEADER source_subfolder/src/irrXML.h) - -install(TARGETS ${CMAKE_PROJECT_NAME} - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - PUBLIC_HEADER DESTINATION include) +install(TARGETS IrrXML + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/irrxml/all/conandata.yml b/recipes/irrxml/all/conandata.yml index c0d401e4dccdd..05fd6b5cd1356 100644 --- a/recipes/irrxml/all/conandata.yml +++ b/recipes/irrxml/all/conandata.yml @@ -1,8 +1,7 @@ sources: "1.2": - sha256: 9b4f80639b2dee3caddbf75862389de684747df27bea7d25f96c7330606d7079 - url: http://prdownloads.sourceforge.net/irrlicht/irrxml-1.2.zip + url: "http://prdownloads.sourceforge.net/irrlicht/irrxml-1.2.zip" + sha256: "9b4f80639b2dee3caddbf75862389de684747df27bea7d25f96c7330606d7079" patches: "1.2": - - base_path: source_subfolder - patch_file: patches/1.2/irrtypes_debug_vs.patch + - patch_file: patches/1.2/irrtypes_debug_vs.patch diff --git a/recipes/irrxml/all/conanfile.py b/recipes/irrxml/all/conanfile.py index f5686d90b1185..e07a0f1dba815 100644 --- a/recipes/irrxml/all/conanfile.py +++ b/recipes/irrxml/all/conanfile.py @@ -1,5 +1,9 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, load, save import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.46.0" class IrrXMLConan(ConanFile): @@ -9,52 +13,59 @@ class IrrXMLConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" description = "irrXML is a simple and fast open source xml parser for C++" topics = ("xml", "xml-parser", "parser", "xml-reader") - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = self.name + "-" + self.version - os.rename(extracted_folder, self._source_subfolder) + def configure(self): + if self.options.shared: + del self.options.fPIC - def _extract_license(self): - header = tools.load(os.path.join(self.package_folder, "include", "irrXML.h")) - license_contents = header[header.find(r"\section license License")+25:header.find(r"\section history", 1)] - tools.save("LICENSE", license_contents) + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - cmake = CMake(self) - cmake.configure(build_folder=self._build_subfolder) - return cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["IRRXML_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() + def _extract_license(self): + header = load(self, os.path.join(self.source_folder, "src", "irrXML.h")) + license_contents = header[header.find(r"\section license License")+25:header.find(r"\section history", 1)] + return license_contents + def package(self): - cmake = self._configure_cmake() + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license()) + cmake = CMake(self) cmake.install() - self._extract_license() - self.copy(pattern="LICENSE", dst="licenses") def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["m"] + self.cpp_info.libs = ["IrrXML"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/irrxml/all/test_package/CMakeLists.txt b/recipes/irrxml/all/test_package/CMakeLists.txt index 196188113685c..6dc6a05d353a3 100644 --- a/recipes/irrxml/all/test_package/CMakeLists.txt +++ b/recipes/irrxml/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(irrxml REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE irrxml::irrxml) diff --git a/recipes/irrxml/all/test_package/conanfile.py b/recipes/irrxml/all/test_package/conanfile.py index bd7165a553cf4..f21acc4ed5535 100644 --- a/recipes/irrxml/all/test_package/conanfile.py +++ b/recipes/irrxml/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + xml_path = os.path.join(self.source_folder, "config.xml") + self.run(f"{bin_path} {xml_path}", env="conanrun") diff --git a/recipes/irrxml/all/test_package/test_package.cpp b/recipes/irrxml/all/test_package/test_package.cpp index e0848c9bd3645..d998e7474f7dc 100644 --- a/recipes/irrxml/all/test_package/test_package.cpp +++ b/recipes/irrxml/all/test_package/test_package.cpp @@ -1,13 +1,17 @@ #include -using namespace irr; -using namespace io; +#include #include // we use STL strings to store data in this example #include -int main() +int main(int argc, char const* argv[]) { - IrrXMLReader* xml = createIrrXMLReader("config.xml"); + if (argc != 2) { + std::cerr << "usage: " << argv[0] << " " << std::endl; + return 1; + } + + irr::io::IrrXMLReader* xml = irr::io::createIrrXMLReader(argv[1]); // strings for storing the data we want to get out of the file std::string modelFile; @@ -19,11 +23,11 @@ int main() { switch(xml->getNodeType()) { - case EXN_TEXT: + case irr::io::EXN_TEXT: // in this xml file, the only text which occurs is the messageText messageText = xml->getNodeData(); break; - case EXN_ELEMENT: + case irr::io::EXN_ELEMENT: { if (!strcmp("startUpModel", xml->getNodeName())) modelFile = xml->getAttributeValue("file"); diff --git a/recipes/irrxml/all/test_v1_package/CMakeLists.txt b/recipes/irrxml/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e26819dcc3af3 --- /dev/null +++ b/recipes/irrxml/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(irrxml REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE irrxml::irrxml) diff --git a/recipes/irrxml/all/test_v1_package/conanfile.py b/recipes/irrxml/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..433191cd50991 --- /dev/null +++ b/recipes/irrxml/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + xml_path = os.path.join(self.source_folder, os.pardir, "test_package", "config.xml") + self.run(f"{bin_path} {xml_path}", run_environment=True) diff --git a/recipes/isa-l/all/conandata.yml b/recipes/isa-l/all/conandata.yml new file mode 100644 index 0000000000000..3f7141d8278ab --- /dev/null +++ b/recipes/isa-l/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.30.0": + url: "https://github.com/intel/isa-l/archive/refs/tags/v2.30.0.tar.gz" + sha256: "bcf592c04fdfa19e723d2adf53d3e0f4efd5b956bb618fed54a1108d76a6eb56" diff --git a/recipes/isa-l/all/conanfile.py b/recipes/isa-l/all/conanfile.py new file mode 100644 index 0000000000000..56f45edf048a4 --- /dev/null +++ b/recipes/isa-l/all/conanfile.py @@ -0,0 +1,72 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration + +import os + +required_conan_version = ">=1.33.0" + +class LibisalConan(ConanFile): + name = "isa-l" + description = "Intel's Intelligent Storage Acceleration Library" + license = "BSD-3" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/intel/isa-l" + topics = ("isa-l", "compression") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC" :True + } + build_requires = ( + "libtool/2.4.6", + "nasm/2.15.05", + ) + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.arch not in [ "x86", "x86_64", "armv8" ]: + raise ConanInvalidConfiguration("CPU Architecture not supported") + if self.settings.os not in ["Linux", "FreeBSD"]: + raise ConanInvalidConfiguration("Only Linux and FreeBSD builds are supported") + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def build(self): + with tools.chdir(self._source_subfolder): + self.run("./autogen.sh") + env_build = AutoToolsBuildEnvironment(self) + extra_args = list() + if self.options.shared: + extra_args.extend(('--enable-static=no',)) + else: + extra_args.extend(('--enable-shared=no',)) + env_build.configure(".", args=extra_args, build=False, host=False, target=False) + env_build.make() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + self.copy("*/isa-l.h", dst="include/isa-l", keep_path=False) + self.copy("*.h", dst="include/isa-l", src="%s/include" % (self._source_subfolder) , keep_path=False) + if self.options.shared: + self.copy("*.dll", dst="bin", keep_path=False) + self.copy("*.so*", dst="lib", keep_path=False, symlinks=True) + self.copy("*.dylib", dst="lib", keep_path=False) + else: + self.copy("*.a", dst="lib", keep_path=False) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/isa-l/all/test_package/CMakeLists.txt b/recipes/isa-l/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..196188113685c --- /dev/null +++ b/recipes/isa-l/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/isa-l/all/test_package/conanfile.py b/recipes/isa-l/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e1f2192537436 --- /dev/null +++ b/recipes/isa-l/all/test_package/conanfile.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from conans import ConanFile, CMake, tools, RunEnvironment +from conan.tools.build import cross_building +import os +import subprocess +import re + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/isa-l/all/test_package/test_package.cpp b/recipes/isa-l/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..56025fdcff25a --- /dev/null +++ b/recipes/isa-l/all/test_package/test_package.cpp @@ -0,0 +1,18 @@ +#include +#include + +const uint16_t init_crc_16 = 0x8005; + +uint16_t getIsalCrc16 (unsigned char *buf, uint64_t len) { + return crc16_t10dif(init_crc_16, buf, len); +} + +int main(void) { + unsigned char buf[] = "32311E333530"; + if ( getIsalCrc16(buf, 12) != 0xb4c9 ) { + std::cout << "Failed to install ISA-L\n"; + return -1; + } + std::cout << "Success\n"; + return 0; +} diff --git a/recipes/isa-l/config.yml b/recipes/isa-l/config.yml new file mode 100644 index 0000000000000..ebe8d6f743f65 --- /dev/null +++ b/recipes/isa-l/config.yml @@ -0,0 +1,3 @@ +versions: + "2.30.0": + folder: all diff --git a/recipes/isl/all/conandata.yml b/recipes/isl/all/conandata.yml index a94a46214056d..cf2c5f3fb54ee 100644 --- a/recipes/isl/all/conandata.yml +++ b/recipes/isl/all/conandata.yml @@ -1,7 +1,10 @@ sources: + "0.24": + url: "https://libisl.sourceforge.io/isl-0.24.tar.gz" + sha256: "26e6e4d60ad59b3fff9948eb36743f0c874e124e410ef5bab930d0f546bc580d" "0.23": - url: "http://isl.gforge.inria.fr/isl-0.23.tar.gz" + url: "https://libisl.sourceforge.io/isl-0.23.tar.gz" sha256: "19e77cb562ab3da5a37f263208d6f902ae3a9d52c756bf6eb1a6b2f8a74b883c" "0.22": - url: "http://isl.gforge.inria.fr/isl-0.22.tar.gz" + url: "https://libisl.sourceforge.io/isl-0.22.tar.gz" sha256: "d0c6714e4427d3eb964388afe526a8e0f69687da7e944f1ad66ffa639923be46" diff --git a/recipes/isl/all/conanfile.py b/recipes/isl/all/conanfile.py index cc2f0f987811f..139d5fc0036f3 100644 --- a/recipes/isl/all/conanfile.py +++ b/recipes/isl/all/conanfile.py @@ -3,13 +3,15 @@ from contextlib import contextmanager import os +required_conan_version = ">=1.33.0" + class IslConan(ConanFile): name = "isl" description = "isl is a library for manipulating sets and relations of integer points bounded by linear constraints." - topics = ("conan", "isl", "integer", "set", "library") + topics = ("isl", "integer", "set", "library") license = "MIT" - homepage = "http://isl.gforge.inria.fr/" + homepage = "https://libisl.sourceforge.io" url = "https://github.com/conan-io/conan-center-index" settings = "os", "arch", "compiler", "build_type" options = { @@ -39,25 +41,35 @@ def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def validate(self): if self.settings.os == "Windows" and self.options.shared: raise ConanInvalidConfiguration("Cannot build shared isl library on Windows (due to libtool refusing to link to static/import libraries)") + if self.settings.os == "Macos" and self.settings.arch == "armv8": + raise ConanInvalidConfiguration("Apple M1 is not yet supported. Contributions are welcome") + if self.options.with_int != "gmp": + # FIXME: missing imath recipe + raise ConanInvalidConfiguration("imath is not (yet) available on cci") + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < 16 and self.settings.compiler.runtime == "MDd": + # gmp.lib(bdiv_dbm1c.obj) : fatal error LNK1318: Unexpected PDB error; OK (0) + raise ConanInvalidConfiguration("isl fails to link with this version of visual studio and MDd runtime") def requirements(self): if self.options.with_int == "gmp": self.requires("gmp/6.2.1") - else: - # FIXME: missing imath recipe - raise ConanInvalidConfiguration("imath is not (yet) available on cci") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.3") + self.build_requires("automake/1.16.4") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) @contextmanager def _build_context(self): @@ -94,6 +106,11 @@ def _configure_autotools(self): "--with-gmp=system", "--with-gmp-prefix={}".format(self.deps_cpp_info["gmp"].rootpath.replace("\\", "/")), ]) + if self.settings.compiler == "Visual Studio": + if tools.Version(self.settings.compiler.version) >= 15: + self._autotools.flags.append("-Zf") + if tools.Version(self.settings.compiler.version) >= 12: + self._autotools.flags.append("-FS") self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) return self._autotools diff --git a/recipes/isl/config.yml b/recipes/isl/config.yml index c12a773047f8c..e0fa5e44a1f96 100644 --- a/recipes/isl/config.yml +++ b/recipes/isl/config.yml @@ -1,4 +1,6 @@ versions: + "0.24": + folder: "all" "0.23": folder: "all" "0.22": diff --git a/recipes/itk/all/CMakeLists.txt b/recipes/itk/all/CMakeLists.txt index ad57fcb040811..7ae2d73951a0d 100644 --- a/recipes/itk/all/CMakeLists.txt +++ b/recipes/itk/all/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.10.2) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) # conan created FindXXX.cmake modules that create IMPORTED targets # that not have the GLOBAL option set. By requiring them here, diff --git a/recipes/itk/all/conandata.yml b/recipes/itk/all/conandata.yml index f81a07fcbb119..3cb9b81826a59 100644 --- a/recipes/itk/all/conandata.yml +++ b/recipes/itk/all/conandata.yml @@ -1,10 +1,14 @@ sources: + "5.1.2": + url: "https://github.com/InsightSoftwareConsortium/ITK/releases/download/v5.1.2/InsightToolkit-5.1.2.tar.gz" + sha256: "f1e5a78e11125348f68f655c6b89b617c3a8b2c09f710081f621054811a70c98" "5.1.0": url: "https://github.com/InsightSoftwareConsortium/ITK/releases/download/v5.1.0/InsightToolkit-5.1.0.tar.gz" sha256: "121020a1611508cec8123eb5226215598cec07be627d843a2e6b6da891e61d13" patches: - "5.1.0": + "5.1.2": - patch_file: "patches/0001-find-conan-packages.patch" base_path: "source_subfolder" - - patch_file: "patches/0002-gdcm-dependencies.patch" #FIXME: should be removed when gdcm is added as a cci recipe + "5.1.0": + - patch_file: "patches/0001-find-conan-packages.patch" base_path: "source_subfolder" diff --git a/recipes/itk/all/conanfile.py b/recipes/itk/all/conanfile.py index be49e838d4bbf..3c833fb68b446 100644 --- a/recipes/itk/all/conanfile.py +++ b/recipes/itk/all/conanfile.py @@ -2,8 +2,9 @@ from conans.errors import ConanInvalidConfiguration import glob import os +import textwrap -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.43.0" class ITKConan(ConanFile): @@ -13,7 +14,7 @@ class ITKConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" license = "Apache-2.0" description = "Insight Segmentation and Registration Toolkit" - exports_sources = "CMakeLists.txt", "patches/**" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -23,9 +24,9 @@ class ITKConan(ConanFile): "shared": False, "fPIC": True, } - generators = "cmake", "cmake_find_package" - short_paths = True + short_paths = True + generators = "cmake", "cmake_find_package" _cmake = None @property @@ -41,6 +42,11 @@ def _build_subfolder(self): # - vtk # - opencv + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -48,34 +54,55 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - - if self.settings.compiler == "apple-clang": - raise ConanInvalidConfiguration("itk does not support this compiler") def requirements(self): - self.requires("libjpeg/9d") - self.requires("dcmtk/3.6.5") - self.requires("double-conversion/3.1.5") - self.requires("eigen/3.3.9") - self.requires("expat/2.2.10") + self.requires("dcmtk/3.6.6") + self.requires("double-conversion/3.2.0") + self.requires("eigen/3.4.0") + self.requires("expat/2.4.8") self.requires("fftw/3.3.9") + self.requires("gdcm/3.0.9") self.requires("hdf5/1.12.0") - self.requires("icu/68.2") - self.requires("libtiff/4.2.0") + self.requires("icu/71.1") # TODO: to remove? Seems to be a transitivie dependency through dcmtk + self.requires("libjpeg/9d") self.requires("libpng/1.6.37") + self.requires("libtiff/4.3.0") self.requires("openjpeg/2.4.0") - self.requires("zlib/1.2.11") + self.requires("onetbb/2020.3") + self.requires("zlib/1.2.12") + + @property + def _minimum_cpp_standard(self): + return 11 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "14", + "gcc": "4.8.1", + "clang": "3.3", + "apple-clang": "9", + } def validate(self): if self.options.shared and not self.options["hdf5"].shared: raise ConanInvalidConfiguration("When building a shared itk, hdf5 needs to be shared too (or not linked to by the consumer).\n" "This is because H5::DataSpace::ALL might get initialized twice, which will cause a H5::DataSpaceIException to be thrown).") + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler)) + else: + if tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("InsightToolkit-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): @@ -96,6 +123,7 @@ def _configure_cmake(self): self._cmake.definitions["ITK_USE_SYSTEM_DOUBLECONVERSION"] = True self._cmake.definitions["ITK_USE_SYSTEM_EIGEN"] = True self._cmake.definitions["ITK_USE_SYSTEM_FFTW"] = True + self._cmake.definitions["ITK_USE_SYSTEM_GDCM"] = True self._cmake.definitions["ITK_USE_SYSTEM_HDF5"] = True self._cmake.definitions["ITK_USE_SYSTEM_ICU"] = True self._cmake.definitions["ITK_USE_SYSTEM_JPEG"] = True @@ -107,15 +135,12 @@ def _configure_cmake(self): self._cmake.definitions["ITK_USE_SYSTEM_KWIML"] = False # FIXME: Missing VXL recipe self._cmake.definitions["ITK_USE_SYSTEM_VXL"] = False - # FIXME: Missing gdcm recipe - self._cmake.definitions["ITK_USE_SYSTEM_GDCM"] = False self._cmake.definitions["GDCM_USE_SYSTEM_OPENJPEG"] = True self._cmake.definitions["ITK_BUILD_DEFAULT_MODULES"] = False self._cmake.definitions["Module_ITKDeprecated"] = False self._cmake.definitions["Module_ITKMINC"] = False self._cmake.definitions["Module_ITKIOMINC"] = False - self._cmake.definitions["Module_ITKV3Compatibility"] = False self._cmake.definitions["Module_ITKVideoBridgeOpenCV"] = False @@ -197,6 +222,7 @@ def _configure_cmake(self): self._cmake.definitions["Module_ITKSignedDistanceFunction"] = True self._cmake.definitions["Module_ITKSmoothing"] = True self._cmake.definitions["Module_ITKSpatialFunction"] = True + self._cmake.definitions["Module_ITKTBB"] = True self._cmake.definitions["Module_ITKThresholding"] = True self._cmake.definitions["Module_ITKVideoCore"] = True self._cmake.definitions["Module_ITKVideoFiltering"] = True @@ -234,6 +260,27 @@ def package(self): if os.path.basename(cmake_file) != "UseITK.cmake": os.remove(cmake_file) + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {target:"ITK::{}".format(target) for target in self._itk_components.keys()}, + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join(self._cmake_module_dir, "conan-official-{}-targets.cmake".format(self.name)) + @property def _cmake_module_dir(self): return os.path.join("lib", "cmake", self._itk_subdir) @@ -243,15 +290,219 @@ def _itk_subdir(self): v = tools.Version(self.version) return "ITK-{}.{}".format(v.major, v.minor) - def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) # FIXME: correct order? - self.cpp_info.includedirs.append(os.path.join("include", self._itk_subdir)) - if self.settings.os == "Linux": - self.cpp_info.system_libs.extend(["pthread", "dl", "rt"]) + @property + def _itk_components(self): + def libm(): + return ["m"] if self.settings.os in ["Linux", "FreeBSD"] else [] + + return { + "itksys": {}, + "itkvcl": {"system_libs": libm()}, + "itkv3p_netlib": {"system_libs": libm()}, + "itkvnl": {"requires": ["itkvcl"]}, + "itkvnl_algo": {"requires": ["itkv3p_netlib", "itkvnl"]}, + "itktestlib": {"requires": ["itkvcl"]}, + "ITKVNLInstantiation": { + "requires": [ + "itkvnl_algo", "itkvnl", "itkv3p_netlib", "itkvcl", + ], + }, + "ITKCommon": { + "requires": [ + "itksys", "ITKVNLInstantiation", "eigen::eigen", + "onetbb::onetbb", "double-conversion::double-conversion", + ], + "system_libs": libm(), + }, + "itkNetlibSlatec": {"requires": ["itkv3p_netlib"]}, + "ITKStatistics": {"requires": ["ITKCommon", "itkNetlibSlatec"]}, + "ITKTransform": {"requires": ["ITKCommon"]}, + "ITKMesh": {"requires": ["ITKTransform"]}, + "ITKMetaIO": {"requires": ["zlib::zlib"]}, + "ITKSpatialObjects": {"requires": ["ITKTransform", "ITKCommon", "ITKMesh"]}, + "ITKPath": {"requires": ["ITKCommon"]}, + "ITKImageIntensity": {}, + "ITKLabelMap": { + "requires": [ + "ITKCommon", "ITKStatistics", "ITKTransform", + "ITKSpatialObjects", "ITKPath", + ], + }, + "ITKQuadEdgeMesh": {"requires": ["ITKMesh"]}, + "ITKFastMarching": {}, + "ITKIOImageBase": {"requires": ["ITKCommon"]}, + "ITKSmoothing": {}, + "ITKImageFeature": {"requires": ["ITKSmoothing", "ITKSpatialObjects"]}, + "ITKOptimizers": {"requires": ["ITKStatistics"]}, + "ITKPolynomials": {"requires": ["ITKCommon"]}, + "ITKBiasCorrection": { + "requires": [ + "ITKCommon", "ITKStatistics", "ITKTransform", + "ITKSpatialObjects", "ITKPath", + ], + }, + "ITKColormap": {}, + "ITKFFT": {"requires": ["ITKCommon", "fftw::fftw"]}, + "ITKConvolution": { + "requires": [ + "ITKFFT", "ITKCommon", "ITKStatistics", "ITKTransform", + "ITKSpatialObjects", "ITKPath", + ], + }, + "ITKDICOMParser": {}, + "ITKDeformableMesh": { + "requires": [ + "ITKCommon", "ITKStatistics", "ITKTransform", "ITKImageFeature", + "ITKSpatialObjects", "ITKPath", "ITKMesh", + ], + }, + "ITKDenoising": {}, + "ITKDiffusionTensorImage": {}, + "ITKIOXML": {"requires": ["ITKIOImageBase", "expat::expat"]}, + "ITKIOSpatialObjects": {"requires": ["ITKSpatialObjects", "ITKIOXML", "ITKMesh"]}, + "ITKFEM": { + "requires": [ + "ITKCommon", "ITKStatistics", "ITKTransform", + "ITKSpatialObjects", "ITKPath", + "ITKSmoothing", "ITKImageFeature", "ITKOptimizers", "ITKMetaIO", + ], + }, + "ITKPDEDeformableRegistration": { + "requires": [ + "ITKCommon", "ITKStatistics", "ITKTransform", + "ITKSpatialObjects", "ITKPath", "ITKSmoothing", + "ITKImageFeature", "ITKOptimizers", + ], + }, + "ITKFEMRegistration": { + "requires": [ + "ITKFEM", "ITKImageFeature", "ITKCommon", "ITKSpatialObjects", + "ITKTransform", "ITKPDEDeformableRegistration", + ], + }, + "ITKznz": {"requires": ["zlib::zlib"]}, + "ITKniftiio": {"requires": ["ITKznz"], "system_libs": libm()}, + "ITKgiftiio": {"requires": ["ITKznz", "ITKniftiio", "expat::expat"]}, + "ITKIOBMP": {"requires": ["ITKIOImageBase"]}, + "ITKIOBioRad": {"requires": ["ITKIOImageBase"]}, + "ITKIOCSV": {"requires": ["ITKIOImageBase"]}, + "ITKIODCMTK": {"requires": ["ITKIOImageBase", "dcmtk::dcmtk", "icu::icu"]}, + "ITKIOGDCM": {"requires": ["ITKCommon", "ITKIOImageBase", "gdcm::gdcmDICT", "gdcm::gdcmMSFF"]}, + "ITKIOIPL": {"requires": ["ITKIOImageBase"]}, + "ITKIOGE": {"requires": ["ITKIOIPL", "ITKIOImageBase"]}, + "ITKIOGIPL": {"requires": ["ITKIOImageBase", "zlib::zlib"]}, + "ITKIOHDF5": {"requires": ["ITKIOImageBase", "hdf5::hdf5"]}, + "ITKIOJPEG": {"requires": ["ITKIOImageBase", "libjpeg::libjpeg"]}, + "ITKIOMeshBase": { + "requires": [ + "ITKCommon", "ITKIOImageBase", "ITKMesh", "ITKQuadEdgeMesh", + ], + }, + "ITKIOMeshBYU": {"requires": ["ITKCommon", "ITKIOMeshBase"]}, + "ITKIOMeshFreeSurfer": {"requires": ["ITKCommon", "ITKIOMeshBase"]}, + "ITKIOMeshGifti": {"requires": ["ITKCommon", "ITKIOMeshBase", "ITKgiftiio"]}, + "ITKIOMeshOBJ": {"requires": ["ITKCommon", "ITKIOMeshBase"]}, + "ITKIOMeshOFF": {"requires": ["ITKCommon", "ITKIOMeshBase"]}, + "ITKIOMeshVTK": {"requires": ["ITKCommon", "ITKIOMeshBase", "double-conversion::double-conversion"]}, + "ITKIOMeta": {"requires": ["ITKIOImageBase", "ITKMetaIO"]}, + "ITKIONIFTI": {"requires": ["ITKIOImageBase", "ITKznz", "ITKniftiio", "ITKTransform"]}, + "ITKNrrdIO": {"requires": ["zlib::zlib"]}, + "ITKIONRRD": {"requires": ["ITKIOImageBase", "ITKNrrdIO"]}, + "ITKIOPNG": {"requires": ["ITKIOImageBase", "libpng::libpng"]}, + "ITKIOPhilipsREC": {"requires": ["zlib::zlib"]}, + "ITKIOSiemens": {"requires": ["ITKIOImageBase", "ITKIOIPL"]}, + "ITKIOStimulate": {"requires": ["ITKIOImageBase"]}, + "ITKIOTIFF": {"requires": ["ITKIOImageBase", "libtiff::libtiff"]}, + "ITKTransformFactory": {"requires": ["ITKCommon", "ITKTransform"]}, + "ITKIOTransformBase": {"requires": ["ITKCommon", "ITKTransform", "ITKTransformFactory"]}, + "ITKIOTransformHDF5": {"requires": ["ITKIOTransformBase", "hdf5::hdf5"]}, + "ITKIOTransformInsightLegacy": {"requires": ["ITKIOTransformBase", "double-conversion::double-conversion"]}, + "ITKIOTransformMatlab": {"requires": ["ITKIOTransformBase"]}, + "ITKIOVTK": {"requires": ["ITKIOImageBase"]}, + "ITKKLMRegionGrowing": {"requires": ["ITKCommon"]}, + "itklbfgs": {}, + "ITKMarkovRandomFieldsClassifiers": { + "requires": [ + "ITKCommon", "ITKStatistics", "ITKTransform", + "ITKSpatialObjects", "ITKPath", + ], + }, + "ITKOptimizersv4": {"requires": ["ITKOptimizers", "itklbfgs"]}, + "itkopenjpeg": {"header_only": True, "requires": ["openjpeg::openjpeg"]}, + "ITKQuadEdgeMeshFiltering": {"requires": ["ITKMesh"]}, + "ITKRegionGrowing": { + "requires": [ + "ITKCommon", "ITKStatistics", "ITKTransform", + "ITKSpatialObjects", "ITKPath", + ], + }, + "ITKRegistrationMethodsv4": { + "requires": [ + "ITKCommon", "ITKOptimizersv4", "ITKStatistics", "ITKTransform", + "ITKSpatialObjects", "ITKPath", "ITKSmoothing", "ITKImageFeature", + "ITKOptimizers", + ], + }, + "ITKVTK": {"requires": ["ITKCommon"]}, + "ITKWatersheds": { + "requires": [ + "ITKCommon", "ITKStatistics", "ITKTransform", "ITKSpatialObjects", + "ITKPath", "ITKSmoothing", + ], + }, + "ITKReview": { + "requires": [ + "ITKCommon", "ITKStatistics", "ITKTransform", "ITKLabelMap", + "ITKSpatialObjects", "ITKPath", "ITKFastMarching", "ITKIOImageBase", + "ITKImageFeature", "ITKOptimizers", "ITKBiasCorrection", + "ITKDeformableMesh", "ITKDiffusionTensorImage", "ITKSmoothing", + "ITKFFT", "ITKIOBMP", "ITKIOBioRad", "ITKIOGDCM", "ITKIOGE", + "ITKIOGIPL", "ITKIOIPL", "ITKIOJPEG", "ITKIOMeta", "ITKIONIFTI", + "ITKIONRRD", "ITKIOPNG", "ITKIOSiemens", "ITKIOStimulate", "ITKIOTIFF", + "ITKIOTransformHDF5", "ITKIOTransformInsightLegacy", + "ITKIOTransformMatlab", "ITKIOVTK", "ITKIOXML", "ITKKLMRegionGrowing", + "ITKMarkovRandomFieldsClassifiers", "ITKMesh", "ITKPDEDeformableRegistration", + "ITKPolynomials", "ITKQuadEdgeMesh", "ITKQuadEdgeMeshFiltering", + "ITKRegionGrowing", "ITKVTK", "ITKWatersheds", "itkopenjpeg", + ], + }, + "ITKTestKernel": { + "requires": [ + "ITKCommon", "ITKIOImageBase", "ITKIOBMP", "ITKIOGDCM", "ITKIOGIPL", + "ITKIOJPEG", "ITKIOMeshBYU", "ITKIOMeshFreeSurfer", "ITKIOMeshGifti", + "ITKIOMeshOBJ", "ITKIOMeshOFF", "ITKIOMeshVTK", "ITKIOMeta", "ITKIONIFTI", + "ITKIONRRD", "ITKIOPNG", "ITKIOTIFF", "ITKIOVTK", + ], + }, + "ITKVideoCore": {"requires": ["ITKCommon"]}, + } - # FIXME: use conan components + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "ITK") + self.cpp_info.set_property("cmake_build_modules", [os.path.join(self._cmake_module_dir, "UseITK.cmake")]) + + itk_version = tools.Version(self.version) + lib_suffix = "-{}.{}".format(itk_version.major, itk_version.minor) + + for name, values in self._itk_components.items(): + is_header_only = values.get("header_only", False) + system_libs = values.get("system_libs", []) + requires = values.get("requires", []) + self.cpp_info.components[name].set_property("cmake_target_name", name) + self.cpp_info.components[name].builddirs.append(self._cmake_module_dir) + self.cpp_info.components[name].includedirs.append(os.path.join("include", self._itk_subdir)) + if not is_header_only: + self.cpp_info.components[name].libs = ["{}{}".format(name, lib_suffix)] + self.cpp_info.components[name].system_libs = system_libs + self.cpp_info.components[name].requires = requires + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.components[name].names["cmake_find_package"] = name + self.cpp_info.components[name].names["cmake_find_package_multi"] = name + self.cpp_info.components[name].build_modules.append(os.path.join(self._cmake_module_dir, "UseITK.cmake")) + self.cpp_info.components[name].build_modules["cmake_find_package"].append(self._module_file_rel_path) + self.cpp_info.components[name].build_modules["cmake_find_package_multi"].append(self._module_file_rel_path) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "ITK" self.cpp_info.names["cmake_find_package_multi"] = "ITK" - - self.cpp_info.builddirs.append(self._cmake_module_dir) - self.cpp_info.build_modules = [os.path.join(self._cmake_module_dir, "UseITK.cmake")] diff --git a/recipes/itk/all/patches/0001-find-conan-packages.patch b/recipes/itk/all/patches/0001-find-conan-packages.patch index 4808d6e7e1951..7cd839b147933 100644 --- a/recipes/itk/all/patches/0001-find-conan-packages.patch +++ b/recipes/itk/all/patches/0001-find-conan-packages.patch @@ -140,6 +140,33 @@ -itk_module_target(itkopenjpeg NO_INSTALL) +find_package(OpenJPEG REQUIRED) +add_library(itkopenjpeg INTERFACE) -+set_property(TARGET itkopenjpeg PROPERTY INTERFACE_LINK_LIBRARIES OpenJPEG::OpenJPEG) ++set_property(TARGET itkopenjpeg PROPERTY INTERFACE_LINK_LIBRARIES openjp2) +#target_compile_definitions(itkopenjpeg INTERFACE) +install(TARGETS itkopenjpeg EXPORT ${ITK3P_INSTALL_EXPORT_NAME}) +--- Modules/ThirdParty/TBB/CMakeLists.txt ++++ Modules/ThirdParty/TBB/CMakeLists.txt +@@ -8,14 +8,14 @@ set(ITKTBB_NO_SRC 1) + # When this module is loaded by an app, load TBB too. + set(ITKTBB_EXPORT_CODE_INSTALL " + set(TBB_DIR \"${TBB_DIR}\") +-find_package(TBB REQUIRED CONFIG) ++find_package(TBB REQUIRED) + ") + + # When this module is configured by an app, configure TBB too. + set(ITKTBB_EXPORT_CODE_BUILD " + if(NOT ITK_BINARY_DIR) + set(TBB_DIR \"${TBB_DIR}\") +- find_package(TBB REQUIRED CONFIG) ++ find_package(TBB REQUIRED) + endif() + ") + +diff --git a/Modules/ThirdParty/TBB/itk-module-init.cmake b/Modules/ThirdParty/TBB/itk-module-init.cmake +index 1b7ee20a..0859ef33 100644 +--- a/Modules/ThirdParty/TBB/itk-module-init.cmake ++++ b/Modules/ThirdParty/TBB/itk-module-init.cmake +@@ -1,2 +1,2 @@ +-find_package(TBB REQUIRED CONFIG) # must have TBBConfig.cmake, provided since version tbb2017_20170604oss ++find_package(TBB REQUIRED) + get_target_property(TBB_INCLUDE_DIRS TBB::tbb INTERFACE_INCLUDE_DIRECTORIES) diff --git a/recipes/itk/all/patches/0002-gdcm-dependencies.patch b/recipes/itk/all/patches/0002-gdcm-dependencies.patch deleted file mode 100644 index a3d41ab944121..0000000000000 --- a/recipes/itk/all/patches/0002-gdcm-dependencies.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/CMakeLists.txt -+++ Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/CMakeLists.txt -@@ -149,7 +149,8 @@ - ) - endif() - if(GDCM_USE_SYSTEM_OPENJPEG) -- include_directories(${OPENJPEG_INCLUDE_DIRS} ) -+ include_directories(${OpenJPEG_INCLUDE_DIRS} ) -+ link_libraries(OpenJPEG::OpenJPEG) - else() - include_directories( - "${GDCM_BINARY_DIR}/Utilities/gdcmopenjpeg" ---- Modules/ThirdParty/GDCM/src/gdcm/Utilities/CMakeLists.txt -+++ Modules/ThirdParty/GDCM/src/gdcm/Utilities/CMakeLists.txt -@@ -30,6 +30,6 @@ - set(OPENJPEG_INSTALL_INCLUDE_DIR ${GDCM_INSTALL_INCLUDE_DIR}/gdcmopenjpeg) - add_subdirectory(gdcmopenjpeg) - mark_as_advanced(BUILD_JPIP BUILD_JPWL BUILD_CODEC BUILD_DOC BUILD_MJ2 BUILD_PKGCONFIG_FILES BUILD_SHARED_LIBS BUILD_THIRDPARTY OPJ_DATA_ROOT OPJ_DISABLE_TPSOT_FIX OPJ_USE_THREAD) -+else() -+ find_package(OpenJPEG REQUIRED) - endif() -- --# Do jpegls (JPEG-LS aka near lossless implementation) diff --git a/recipes/itk/all/test_package/CMakeLists.txt b/recipes/itk/all/test_package/CMakeLists.txt index 33ae887aa6aea..f9c2acebbb0bb 100644 --- a/recipes/itk/all/test_package/CMakeLists.txt +++ b/recipes/itk/all/test_package/CMakeLists.txt @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(ITK REQUIRED CONFIG) +find_package(HDF5 COMPONENTS CXX) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} ITKCommon hdf5::hdf5_cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/itk/all/test_package/conanfile.py b/recipes/itk/all/test_package/conanfile.py index 1132e474befc2..38f4483872d47 100644 --- a/recipes/itk/all/test_package/conanfile.py +++ b/recipes/itk/all/test_package/conanfile.py @@ -2,9 +2,9 @@ import os -class HelloTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/itk/config.yml b/recipes/itk/config.yml index 591c7a897b8cd..989b5ee90fe13 100644 --- a/recipes/itk/config.yml +++ b/recipes/itk/config.yml @@ -1,3 +1,5 @@ versions: + "5.1.2": + folder: "all" "5.1.0": folder: "all" diff --git a/recipes/itlib/all/conandata.yml b/recipes/itlib/all/conandata.yml new file mode 100644 index 0000000000000..75c51a069dcdc --- /dev/null +++ b/recipes/itlib/all/conandata.yml @@ -0,0 +1,22 @@ +sources: + "1.6.3": + url: "https://github.com/iboB/itlib/archive/v1.6.3.tar.gz" + sha256: "d2e320d9218269c421407d6df819ca0bfae3ea5bc897b341b9babaedc0b7103f" + "1.6.1": + url: "https://github.com/iboB/itlib/archive/v1.6.1.tar.gz" + sha256: "bff70b95ca223b4fbca206d8e1c5f6c75fd5ac86d76c8f8f14f45c748d25866a" + "1.5.2": + url: "https://github.com/iboB/itlib/archive/v1.5.2.tar.gz" + sha256: "9ebff09fcdc873d2b01d8a2d0de2a7d7bd11844ef632f80ec5041f78bdc6ddec" + "1.5.1": + url: "https://github.com/iboB/itlib/archive/v1.5.1.tar.gz" + sha256: "70f3c3cd5b3d4baf440bf19848936882e50c06924ca319d0bf91763ae3a65570" + "1.5.0": + url: "https://github.com/iboB/itlib/archive/refs/tags/v1.5.0.tar.gz" + sha256: "940589080fb486e19d7cf8e79665bac017a55f1c8b8fa4fb889a77f80645f289" + "1.4.5": + url: "https://github.com/iboB/itlib/archive/refs/tags/v1.4.5.tar.gz" + sha256: "f1d3533014433316475b6196cd2b1890bb42db1ae3059616538788712e1a33aa" + "1.3.0": + url: "https://github.com/iboB/itlib/archive/refs/tags/v1.3.0.tar.gz" + sha256: "d3af2ea3cf0dae63fe1e186af79562e584bfb86bf02f358cab9675662fb9b5ef" diff --git a/recipes/itlib/all/conanfile.py b/recipes/itlib/all/conanfile.py new file mode 100644 index 0000000000000..5176ae5632fc2 --- /dev/null +++ b/recipes/itlib/all/conanfile.py @@ -0,0 +1,46 @@ +from conan import ConanFile +from conan.tools.files import get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.layout import basic_layout + +import os + +required_conan_version = ">=1.50.0" + +class ItlibConan(ConanFile): + name = "itlib" + description = "A collection of small single-header C++ libraries similar to or extending the C++ standard library." + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/iboB/itlib" + topics = ("template", "flatmatp", "static-vector") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _minimum_cpp_standard(self): + return 11 + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def package(self): + copy(self, pattern="*.hpp", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/itlib/all/test_package/CMakeLists.txt b/recipes/itlib/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..31ab408f84cc7 --- /dev/null +++ b/recipes/itlib/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +find_package(itlib REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE itlib::itlib) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/itlib/all/test_package/conanfile.py b/recipes/itlib/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/itlib/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/itlib/all/test_package/test_package.cpp b/recipes/itlib/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..65b58fcbcb286 --- /dev/null +++ b/recipes/itlib/all/test_package/test_package.cpp @@ -0,0 +1,18 @@ +#include + +#include + +struct my_pod +{ + int number; +}; + +int main() +{ + itlib::pod_vector vector; + vector.insert(vector.begin(), { 10 }); + + my_pod pod = vector[0]; + std::cout << "Number is " << pod.number << std::endl; + return 0; +} diff --git a/recipes/itlib/all/test_v1_package/CMakeLists.txt b/recipes/itlib/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..dd166aa657f7d --- /dev/null +++ b/recipes/itlib/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(itlib REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE itlib::itlib) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/itlib/all/test_v1_package/conanfile.py b/recipes/itlib/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/itlib/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/itlib/config.yml b/recipes/itlib/config.yml new file mode 100644 index 0000000000000..da2c4537319ae --- /dev/null +++ b/recipes/itlib/config.yml @@ -0,0 +1,15 @@ +versions: + "1.6.3": + folder: all + "1.6.1": + folder: all + "1.5.2": + folder: all + "1.5.1": + folder: all + "1.5.0": + folder: all + "1.4.5": + folder: all + "1.3.0": + folder: all diff --git a/recipes/ittapi/all/conandata.yml b/recipes/ittapi/all/conandata.yml new file mode 100644 index 0000000000000..fe25f2187adf4 --- /dev/null +++ b/recipes/ittapi/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.23.0": + url: "https://github.com/intel/ittapi/archive/v3.23.0.tar.gz" + sha256: "9af1231808c602c2f7a66924c8798b1741d3aa4b15f3874d82ca7a89b5dbb1b1" diff --git a/recipes/ittapi/all/conanfile.py b/recipes/ittapi/all/conanfile.py new file mode 100644 index 0000000000000..dc49d467bcae0 --- /dev/null +++ b/recipes/ittapi/all/conanfile.py @@ -0,0 +1,85 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file +import os + +required_conan_version = ">=1.47.0" + + +class IttApiConan(ConanFile): + name = "ittapi" + license = ("BSD-3-Clause", "GPL-2.0-only") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/intel/ittapi" + description = ( + "The Instrumentation and Tracing Technology (ITT) API enables your application" + " to generate and control the collection of trace data during its execution" + " across different Intel tools." + ) + topics = ("itt", "ittapi", "vtune", "profiler", "profiling") + + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + "ptmark": [True, False], + } + default_options = { + "fPIC": True, + "ptmark": False, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + # We have no C++ files, so we delete unused options. + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def _patch_sources(self): + # Don't force PIC + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -fPIC\")", + "" + ) + + def generate(self): + self._patch_sources() + toolchain = CMakeToolchain(self) + toolchain.variables["ITT_API_IPT_SUPPORT"] = self.options.ptmark + toolchain.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + if self.settings.os == "Windows": + copy(self, "libittnotify.lib", src=f"bin/{self.settings.build_type}", dst=os.path.join(self.package_folder, "lib")) + else: + copy(self, "libittnotify.a", src="bin", dst=os.path.join(self.package_folder, "lib")) + copy(self, "*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "BSD-3-Clause.txt", src=os.path.join(self.source_folder, "LICENSES"), dst=os.path.join(self.package_folder, "licenses")) + copy(self, "GPL-2.0-only.txt", src=os.path.join(self.source_folder, "LICENSES"), dst=os.path.join(self.package_folder, "licenses")) + + def package_info(self): + if self.settings.os == "Windows": + self.cpp_info.libs = ['libittnotify'] + else: + self.cpp_info.libs = ['ittnotify'] + self.cpp_info.system_libs = ['dl'] diff --git a/recipes/ittapi/all/test_package/CMakeLists.txt b/recipes/ittapi/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ac9d09057495e --- /dev/null +++ b/recipes/ittapi/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(ittapi REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ittapi::ittapi) diff --git a/recipes/ittapi/all/test_package/conanfile.py b/recipes/ittapi/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/ittapi/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/ittapi/all/test_package/test_package.cpp b/recipes/ittapi/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..630124964c151 --- /dev/null +++ b/recipes/ittapi/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include +#include + +// @note Domains cannot be destroyed. +__itt_domain* itt_domain = __itt_domain_create("Global Domain"); + +int main(){ + __itt_string_handle* nameHandle = __itt_string_handle_create("My name"); + __itt_task_begin(itt_domain, __itt_null, __itt_null, nameHandle); + std::cout << "Inside ITT range." << std::endl; + __itt_task_end(itt_domain); + + return 0; +} diff --git a/recipes/ittapi/all/test_v1_package/CMakeLists.txt b/recipes/ittapi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..bb7640b6417bb --- /dev/null +++ b/recipes/ittapi/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ittapi REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ittapi::ittapi) diff --git a/recipes/ittapi/all/test_v1_package/conanfile.py b/recipes/ittapi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/recipes/ittapi/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ittapi/config.yml b/recipes/ittapi/config.yml new file mode 100644 index 0000000000000..c34864bd34f7f --- /dev/null +++ b/recipes/ittapi/config.yml @@ -0,0 +1,3 @@ +versions: + "3.23.0": + folder: all diff --git a/recipes/ixwebsocket/all/CMakeLists.txt b/recipes/ixwebsocket/all/CMakeLists.txt index b436ec38d0bd0..16d33ed296f4b 100644 --- a/recipes/ixwebsocket/all/CMakeLists.txt +++ b/recipes/ixwebsocket/all/CMakeLists.txt @@ -1,7 +1,9 @@ -cmake_minimum_required(VERSION 3.1.2) +cmake_minimum_required(VERSION 3.4) project(cmake_wrapper) include(conanbuildinfo.cmake) conan_basic_setup() +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + add_subdirectory("source_subfolder") diff --git a/recipes/ixwebsocket/all/conandata.yml b/recipes/ixwebsocket/all/conandata.yml index 0b899b5ad0762..d9b4c849f8b9a 100644 --- a/recipes/ixwebsocket/all/conandata.yml +++ b/recipes/ixwebsocket/all/conandata.yml @@ -23,3 +23,6 @@ sources: "11.2.4": url: "https://github.com/machinezone/IXWebSocket/archive/refs/tags/v11.2.4.tar.gz" sha256: "e9d4bfc6192c5390f43a9e0534ef7e3a2821bc062a1ff8c94f80884df3b412a9" + "11.4.3": + url: "https://github.com/machinezone/IXWebSocket/archive/refs/tags/v11.4.3.tar.gz" + sha256: "aa2d02c9c71339943cc61eb4efeb2ffc3a5a0011128a67027b9251b7d8a6e0ac" diff --git a/recipes/ixwebsocket/all/conanfile.py b/recipes/ixwebsocket/all/conanfile.py index 488987739fac8..305f58f0e6970 100644 --- a/recipes/ixwebsocket/all/conanfile.py +++ b/recipes/ixwebsocket/all/conanfile.py @@ -2,6 +2,8 @@ from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.33.0" + class IXWebSocketConan(ConanFile): name = "ixwebsocket" @@ -13,13 +15,15 @@ class IXWebSocketConan(ConanFile): exports_sources = ["CMakeLists.txt"] settings = "os", "compiler", "build_type", "arch" short_paths = True - generators = "cmake" + generators = "cmake", "cmake_find_package" options = { + "shared": [True, False], "fPIC": [True, False], "tls": ["mbedtls", "openssl", "applessl", False], "with_zlib": [True, False] } default_options = { + "shared": False, "fPIC": True, "tls": "mbedtls", "with_zlib": True @@ -38,6 +42,19 @@ def config_options(self): # zlib is always required before 10.1.5 del self.options.with_zlib + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.options.get_safe("with_zlib", True): + self.requires("zlib/1.2.12") + if self.options.tls == "openssl": + self.requires("openssl/1.1.1q") + elif self.options.tls == "mbedtls": + self.requires("mbedtls/2.25.0") + + @property def _can_use_openssl(self): if self.settings.os == "Windows": # Future: support for OpenSSL on Windows was introduced in 7.9.3. Earlier versions force MbedTLS @@ -47,26 +64,46 @@ def _can_use_openssl(self): # Older versions doesn't support OpenSSL on Mac, but those are unlikely to be built now. return True - def configure(self): - if self.settings.compiler.cppstd: + def validate(self): + if self.settings.compiler.get_safe("cppstd"): # After version 11.0.8, IXWebSocket is fully compatible with C++ 11. https://github.com/machinezone/IXWebSocket/commit/ee5a2eb46ee0e109415dc02b0db85a9c76256090 tools.check_min_cppstd(self, 14 if tools.Version(self.version) < "11.0.8" else 11) if self.options.tls == "applessl" and not tools.is_apple_os(self.settings.os): raise ConanInvalidConfiguration("Can only use Apple SSL on Apple.") - elif not self._can_use_openssl() and self.options.tls == "openssl": + elif not self._can_use_openssl and self.options.tls == "openssl": raise ConanInvalidConfiguration("This version doesn't support OpenSSL with Windows; use v7.9.3 or newer for this to be valid") - def requirements(self): - if self.options.get_safe("with_zlib", True): - self.requires("zlib/1.2.11") - if self.options.tls == "openssl": - self.requires("openssl/1.1.1j") - elif self.options.tls == "mbedtls": - self.requires("mbedtls/2.16.3-apache") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("IXWebSocket-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") + # Use Find modules generated by conan + tools.replace_in_file(cmakelists, + "set(CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}\")", + "list(APPEND CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/CMake\")") + # Use CMake variables from FindMbedTLS.cmake generated by conan + tools.replace_in_file(cmakelists, "MBEDTLS_INCLUDE_DIRS", "MbedTLS_INCLUDE_DIRS") + tools.replace_in_file(cmakelists, "MBEDTLS_LIBRARIES", "MbedTLS_LIBRARIES") + # Do not force PIC + if tools.Version(self.version) >= "9.5.7": + tools.replace_in_file(cmakelists, "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "") + # Allow shared + if tools.Version(self.version) < "11.1.4": + tools.replace_in_file(cmakelists, "add_library( ixwebsocket STATIC", "add_library( ixwebsocket") + if tools.Version(self.version) < "9.8.5": + tools.replace_in_file(cmakelists, + "ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib", + "ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin") + elif tools.Version(self.version) < "11.4.3": + tools.replace_in_file(cmakelists, + "ARCHIVE DESTINATION lib", + "ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin") + else: + tools.replace_in_file(cmakelists, + "ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}", + "ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION bin") def _configure_cmake(self): if self._cmake: @@ -83,9 +120,7 @@ def _configure_cmake(self): return self._cmake def build(self): - if tools.Version(self.version) >= "9.5.7": - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "") + self._patch_sources() cmake = self._configure_cmake() cmake.build() @@ -96,6 +131,8 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + self.cpp_info.names["cmake_find_package"] = "ixwebsocket" + self.cpp_info.names["cmake_find_package_multi"] = "ixwebsocket" self.cpp_info.libs = tools.collect_libs(self) if self.settings.os == "Windows": self.cpp_info.system_libs.extend(["wsock32", "ws2_32", "shlwapi"]) diff --git a/recipes/ixwebsocket/config.yml b/recipes/ixwebsocket/config.yml index f6ab810249741..f77cd923f6b12 100644 --- a/recipes/ixwebsocket/config.yml +++ b/recipes/ixwebsocket/config.yml @@ -15,3 +15,5 @@ versions: folder: all "11.2.4": folder: all + "11.4.3": + folder: all diff --git a/recipes/jansson/all/CMakeLists.txt b/recipes/jansson/all/CMakeLists.txt deleted file mode 100644 index 1848ca5a77c35..0000000000000 --- a/recipes/jansson/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/jansson/all/conandata.yml b/recipes/jansson/all/conandata.yml index 4862bc9896cc8..ab2972ecb77c5 100644 --- a/recipes/jansson/all/conandata.yml +++ b/recipes/jansson/all/conandata.yml @@ -1,7 +1,10 @@ sources: - "2.12": - url: "https://github.com/akheron/jansson/archive/v2.12.tar.gz" - sha256: "76260d30e9bbd0ef392798525e8cd7fe59a6450c54ca6135672e3cd6a1642941" + "2.14": + url: "https://github.com/akheron/jansson/archive/v2.14.tar.gz" + sha256: "c739578bf6b764aa0752db9a2fdadcfe921c78f1228c7ec0bb47fa804c55d17b" "2.13.1": url: "https://github.com/akheron/jansson/archive/v2.13.1.tar.gz" sha256: "f22901582138e3203959c9257cf83eba9929ac41d7be4a42557213a22ebcc7a0" + "2.12": + url: "https://github.com/akheron/jansson/archive/v2.12.tar.gz" + sha256: "76260d30e9bbd0ef392798525e8cd7fe59a6450c54ca6135672e3cd6a1642941" diff --git a/recipes/jansson/all/conanfile.py b/recipes/jansson/all/conanfile.py index 10435f951faa6..9249c72709455 100644 --- a/recipes/jansson/all/conanfile.py +++ b/recipes/jansson/all/conanfile.py @@ -1,40 +1,34 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime import os +required_conan_version = ">=1.47.0" + class JanssonConan(ConanFile): name = "jansson" description = "C library for encoding, decoding and manipulating JSON data" - topics = ("conan", "jansson", "json", "encoding", "decoding", "manipulation") + topics = ("jansson", "json", "encoding", "decoding", "manipulation") url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.digip.org/jansson/" license = "MIT" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "use_urandom": [True, False], - "use_windows_cryptoapi": [True, False] + "use_windows_cryptoapi": [True, False], } default_options = { "shared": False, "fPIC": True, "use_urandom": True, - "use_windows_cryptoapi": True + "use_windows_cryptoapi": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -42,41 +36,50 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["JANSSON_BUILD_DOCS"] = False - self._cmake.definitions["JANSSON_BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["JANSSON_EXAMPLES"] = False - self._cmake.definitions["JANSSON_WITHOUT_TESTS"] = True - self._cmake.definitions["USE_URANDOM"] = self.options.use_urandom - self._cmake.definitions["USE_WINDOWS_CRYPTOAPI"] = self.options.use_windows_cryptoapi - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["JANSSON_STATIC_CRT"] = str(self.settings.compiler.runtime).startswith("MT") - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["JANSSON_BUILD_DOCS"] = False + tc.variables["JANSSON_BUILD_SHARED_LIBS"] = self.options.shared + tc.variables["JANSSON_EXAMPLES"] = False + tc.variables["JANSSON_WITHOUT_TESTS"] = True + tc.variables["USE_URANDOM"] = self.options.use_urandom + tc.variables["USE_WINDOWS_CRYPTOAPI"] = self.options.use_windows_cryptoapi + if is_msvc(self): + tc.variables["JANSSON_STATIC_CRT"] = is_msvc_static_runtime(self) + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - # drop pc and cmake file - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "cmake")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "jansson") + self.cpp_info.set_property("cmake_target_name", "jansson::jansson") + self.cpp_info.set_property("pkg_config_name", "jansson") + suffix = "_d" if self.settings.os == "Windows" and self.settings.build_type == "Debug" else "" + self.cpp_info.libs = [f"jansson{suffix}"] diff --git a/recipes/jansson/all/test_package/CMakeLists.txt b/recipes/jansson/all/test_package/CMakeLists.txt index 64f46b9d74105..3a833e6d5ed4b 100644 --- a/recipes/jansson/all/test_package/CMakeLists.txt +++ b/recipes/jansson/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C) find_package(jansson REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} jansson::jansson) +target_link_libraries(${PROJECT_NAME} PRIVATE jansson::jansson) diff --git a/recipes/jansson/all/test_package/conanfile.py b/recipes/jansson/all/test_package/conanfile.py index 7e2dfe859bb27..3a8c6c5442b33 100644 --- a/recipes/jansson/all/test_package/conanfile.py +++ b/recipes/jansson/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/jansson/all/test_v1_package/CMakeLists.txt b/recipes/jansson/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6dd0429552b1c --- /dev/null +++ b/recipes/jansson/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(jansson REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE jansson::jansson) diff --git a/recipes/jansson/all/test_v1_package/conanfile.py b/recipes/jansson/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/jansson/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/jansson/config.yml b/recipes/jansson/config.yml index 4ab5d37ba37c6..d0ee1feed8bfc 100644 --- a/recipes/jansson/config.yml +++ b/recipes/jansson/config.yml @@ -1,5 +1,7 @@ versions: - "2.12": + "2.14": folder: all "2.13.1": folder: all + "2.12": + folder: all diff --git a/recipes/jasper/all/CMakeLists.txt b/recipes/jasper/all/CMakeLists.txt index 7df41e7e800aa..daed229fb32e0 100644 --- a/recipes/jasper/all/CMakeLists.txt +++ b/recipes/jasper/all/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) set(CMAKE_MODULE_PATH ${CONAN_CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/source_subfolder/build/cmake/modules ${CMAKE_MODULE_PATH}) diff --git a/recipes/jasper/all/conandata.yml b/recipes/jasper/all/conandata.yml index 49062bc0d3ec4..6867be2627152 100644 --- a/recipes/jasper/all/conandata.yml +++ b/recipes/jasper/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "2.0.33": + url: "https://github.com/jasper-software/jasper/archive/refs/tags/version-2.0.33.tar.gz" + sha256: "38b8f74565ee9e7fec44657e69adb5c9b2a966ca5947ced5717cde18a7d2eca6" "2.0.32": url: "https://github.com/jasper-software/jasper/archive/version-2.0.32.tar.gz" sha256: "a3583a06698a6d6106f2fc413aa42d65d86bedf9a988d60e5cfa38bf72bc64b9" diff --git a/recipes/jasper/all/conanfile.py b/recipes/jasper/all/conanfile.py index f1fc171c20bad..796bf127244db 100644 --- a/recipes/jasper/all/conanfile.py +++ b/recipes/jasper/all/conanfile.py @@ -1,34 +1,35 @@ -from conans import ConanFile, CMake, tools -import glob +from conans import CMake +from conan import ConanFile +from conan.tools.files import get, save, rmdir, rm, replace_in_file, apply_conandata_patches, export_conandata_patches +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.53.0" class JasperConan(ConanFile): name = "jasper" - license = "JasPer License Version 2.0" + license = "JasPer-2.0" homepage = "https://jasper-software.github.io/jasper" url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "jasper", "tool-kit", "coding") + topics = ("tool-kit", "coding") description = "JasPer Image Processing/Coding Tool Kit" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "with_libjpeg": ["libjpeg", "libjpeg-turbo"], - "jpegturbo": [True, False] } default_options = { "shared": False, "fPIC": True, "with_libjpeg": "libjpeg", - "jpegturbo": False } + generators = "cmake", "cmake_find_package" _cmake = None @property @@ -39,33 +40,33 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + export_conandata_patches(self) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx - - # Handle deprecated libjpeg option - if self.options.jpegturbo: - self.output.warn("jpegturbo option is deprecated, use with_libjpeg option instead.") - if self.options.with_libjpeg == "libjpeg" and self.options.jpegturbo: - self.options.with_libjpeg = "libjpeg-turbo" - del self.options.jpegturbo + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") def requirements(self): if self.options.with_libjpeg == "libjpeg-turbo": - self.requires("libjpeg-turbo/2.0.6") + self.requires("libjpeg-turbo/2.1.2") elif self.options.with_libjpeg == "libjpeg": - self.requires("libjpeg/9d") + self.requires("libjpeg/9e") + + def validate(self): + if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) == "16": + raise ConanInvalidConfiguration(f"{self.name} Current can not build in CCI due to windows SDK version. See https://github.com/conan-io/conan-center-index/pull/13285 for the solution hopefully") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{}-version-{}".format(self.name, self.version) - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -79,9 +80,20 @@ def _configure_cmake(self): self._cmake.configure(build_folder=self._build_subfolder) return self._cmake + def _patch_sources(self): + apply_conandata_patches(self) + # Clean rpath in installed shared lib + cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") + cmds_to_remove = [ + "set(CMAKE_INSTALL_RPATH \"${CMAKE_INSTALL_PREFIX}/lib\")", + "set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)", + "set(CMAKE_INSTALL_RPATH\n \"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\")", + ] + for cmd_to_remove in cmds_to_remove: + replace_in_file(self, cmakelists, cmd_to_remove, "") + def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + self._patch_sources() cmake = self._configure_cmake() cmake.build() @@ -89,18 +101,16 @@ def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) if self.settings.os == "Windows": - for dll_file in glob.glob(os.path.join(self.package_folder, "bin", "*.dll")): - if os.path.basename(dll_file).startswith(("concrt", "msvcp", "vcruntime")): - os.unlink(dll_file) + for dll_prefix in ["concrt", "msvcp", "vcruntime"]: + rm(self, f"{dll_prefix}*.dll", os.path.join(self.package_folder, "bin")) self._create_cmake_module_variables( os.path.join(self.package_folder, self._module_file_rel_path) ) - @staticmethod - def _create_cmake_module_variables(module_file): + def _create_cmake_module_variables(self, module_file): content = textwrap.dedent("""\ if(DEFINED Jasper_FOUND) set(JASPER_FOUND ${Jasper_FOUND}) @@ -115,23 +125,23 @@ def _create_cmake_module_variables(module_file): set(JASPER_VERSION_STRING ${Jasper_VERSION}) endif() """) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + save(self, module_file, content) @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-variables.cmake".format(self.name)) + return os.path.join("lib", "cmake", "conan-official-{}-variables.cmake".format(self.name)) def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "Jasper") + self.cpp_info.set_property("cmake_target_name", "Jasper::Jasper") + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) + self.cpp_info.set_property("pkg_config_name", "jasper") + self.cpp_info.names["cmake_find_package"] = "Jasper" self.cpp_info.names["cmake_find_package_multi"] = "Jasper" - self.cpp_info.names["pkg_config"] = "jasper" - self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.libs = ["jasper"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") diff --git a/recipes/jasper/all/test_package/conanfile.py b/recipes/jasper/all/test_package/conanfile.py index 1d0bdd3779793..3da371b660e0a 100644 --- a/recipes/jasper/all/test_package/conanfile.py +++ b/recipes/jasper/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/jasper/config.yml b/recipes/jasper/config.yml index f7599c74426dd..61123bdc2e508 100644 --- a/recipes/jasper/config.yml +++ b/recipes/jasper/config.yml @@ -1,4 +1,6 @@ versions: + "2.0.33": + folder: all "2.0.32": folder: all "2.0.28": diff --git a/recipes/jbig/all/CMakeLists.txt b/recipes/jbig/all/CMakeLists.txt index a00f2f2837e48..d25dfd93d7dcd 100644 --- a/recipes/jbig/all/CMakeLists.txt +++ b/recipes/jbig/all/CMakeLists.txt @@ -1,42 +1,34 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.15) project(jbig LANGUAGES C) -include(conanbuildinfo.cmake) -conan_basic_setup() +include(GNUInstallDirs) if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() -add_library(${CMAKE_PROJECT_NAME} source_subfolder/libjbig/jbig.h - source_subfolder/libjbig/jbig.c - source_subfolder/libjbig/jbig_tab.c) -target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) -if (WIN32) - if (BUILD_SHARED_LIBS) - target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE _JBIGDLL_=1) - endif() +add_library(jbig + ${JBIG_SRC_DIR}/libjbig/jbig.c + ${JBIG_SRC_DIR}/libjbig/jbig_tab.c +) +target_include_directories(jbig PUBLIC ${JBIG_SRC_DIR}/libjbig) +if(MSVC AND BUILD_SHARED_LIBS) + target_compile_definitions(jbig PUBLIC _JBIGDLL_) endif() -include(GNUInstallDirs) +install(TARGETS jbig + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -set(OTHER_TARGETS) +install(FILES ${JBIG_SRC_DIR}/libjbig/jbig.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -if (BUILD_EXECUTABLES) - add_executable(pbmtojbg source_subfolder/pbmtools/pbmtojbg.c) - target_link_libraries(pbmtojbg ${CMAKE_PROJECT_NAME}) - target_include_directories(pbmtojbg PRIVATE source_subfolder/libjbig) +if(BUILD_EXECUTABLES) + add_executable(pbmtojbg ${JBIG_SRC_DIR}/pbmtools/pbmtojbg.c) + target_link_libraries(pbmtojbg PRIVATE jbig) - add_executable(jbgtopbm source_subfolder/pbmtools/jbgtopbm.c) - target_link_libraries(jbgtopbm ${CMAKE_PROJECT_NAME}) - target_include_directories(jbgtopbm PRIVATE source_subfolder/libjbig) + add_executable(jbgtopbm ${JBIG_SRC_DIR}/pbmtools/jbgtopbm.c) + target_link_libraries(jbgtopbm PRIVATE jbig) - set(OTHER_TARGETS jbgtopbm pbmtojbg) + install(TARGETS pbmtojbg jbgtopbm DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() - -install(TARGETS ${CMAKE_PROJECT_NAME} ${OTHER_TARGETS} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) - -install(FILES source_subfolder/libjbig/jbig.h DESTINATION include) diff --git a/recipes/jbig/all/conandata.yml b/recipes/jbig/all/conandata.yml index 7a2370ecd64f7..4d9eab51a4edd 100644 --- a/recipes/jbig/all/conandata.yml +++ b/recipes/jbig/all/conandata.yml @@ -4,7 +4,5 @@ sources: url: "https://github.com/ImageMagick/jbig/archive/5d8f5f6fa71766ced5e828bf7bfff642ddb8a6ad.zip" patches: "20160605": - - base_path: source_subfolder - patch_file: patches/0001-add-missing-export.patch - - base_path: source_subfolder - patch_file: patches/0002-fix-msvc-export.patch + - patch_file: patches/0001-add-missing-export.patch + - patch_file: patches/0002-fix-msvc-export.patch diff --git a/recipes/jbig/all/conanfile.py b/recipes/jbig/all/conanfile.py index d3d641bbd58e4..b98051851c45f 100644 --- a/recipes/jbig/all/conanfile.py +++ b/recipes/jbig/all/conanfile.py @@ -1,75 +1,80 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.microsoft import is_msvc import os -import glob -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.46.0" -class ConanJBig(ConanFile): + +class JBigConan(ConanFile): name = "jbig" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/ImageMagick/jbig" description = "jbig for the Windows build of ImageMagick" - topics = ("conan", "jbig", "imagemagick", "window", "graphic") + topics = ("jbig", "imagemagick", "window", "graphic") license = "GPL-2.0" - exports_sources = ['CMakeLists.txt', "*.patch"] - generators = 'cmake' + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "build_executables": [True, False] + "build_executables": [True, False], } default_options = { "shared": False, "fPIC": True, - "build_executables": True + "build_executables": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - for extracted_dir in glob.glob("jbig-*"): - os.rename(extracted_dir, self._source_subfolder) + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass - def _configure_cmake(self): - if self._cmake: - return self._cmake + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - self._cmake = CMake(self) - self._cmake.definitions["BUILD_EXECUTABLES"] = self.options.build_executables - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["JBIG_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["BUILD_EXECUTABLES"] = self.options.build_executables + tc.generate() def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.libs = [self.name] - if self.options.shared and self.settings.compiler == "Visual Studio": + self.cpp_info.libs = ["jbig"] + if self.options.shared and is_msvc(self): self.cpp_info.defines = ["_JBIGDLL_"] if self.options.build_executables: diff --git a/recipes/jbig/all/patches/0002-fix-msvc-export.patch b/recipes/jbig/all/patches/0002-fix-msvc-export.patch index cfec0243c7ae9..1e6829742e5af 100644 --- a/recipes/jbig/all/patches/0002-fix-msvc-export.patch +++ b/recipes/jbig/all/patches/0002-fix-msvc-export.patch @@ -10,7 +10,7 @@ index 214105a..a4f7781 100644 -#if defined(_MT) && defined(_DLL) && !defined(_JBIGDLL_) && !defined(_LIB) -# define _JBIGDLL_ + -+#if defined(WIN32) ++#if defined(_MSC_VER) +# if defined(jbig_EXPORTS) +# define SHARED_EXPORT_PREFIX __declspec(dllexport) +# else @@ -21,7 +21,7 @@ index 214105a..a4f7781 100644 #endif #if defined(_JBIGDLL_) -# if defined(_VISUALC_) -+# if defined(WIN32) ++# if defined(_MSC_VER) # pragma warning( disable : 4273 ) # endif -# if !defined(_JBIGLIB_) @@ -35,7 +35,7 @@ index 214105a..a4f7781 100644 #endif -#if defined(_VISUALC_) -+#if defined(WIN32) ++#if defined(_MSC_VER) # pragma warning( disable : 4018 ) # pragma warning( disable : 4244 ) # pragma warning( disable : 4142 ) diff --git a/recipes/jbig/all/test_package/CMakeLists.txt b/recipes/jbig/all/test_package/CMakeLists.txt index 7b9b613cbb24a..df5582d8098ae 100644 --- a/recipes/jbig/all/test_package/CMakeLists.txt +++ b/recipes/jbig/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(jbig REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE jbig::jbig) diff --git a/recipes/jbig/all/test_package/conanfile.py b/recipes/jbig/all/test_package/conanfile.py index be0a94674e5bd..3a8c6c5442b33 100644 --- a/recipes/jbig/all/test_package/conanfile.py +++ b/recipes/jbig/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +20,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/jbig/all/test_v1_package/CMakeLists.txt b/recipes/jbig/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..bffb62846421c --- /dev/null +++ b/recipes/jbig/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(jbig REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE jbig::jbig) diff --git a/recipes/jbig/all/test_v1_package/conanfile.py b/recipes/jbig/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/jbig/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/jbig/config.yml b/recipes/jbig/config.yml index f6cbcf68b0a08..431c8d420608d 100644 --- a/recipes/jbig/config.yml +++ b/recipes/jbig/config.yml @@ -1,4 +1,3 @@ ---- versions: "20160605": folder: all diff --git a/recipes/jeaiii-itoa/all/conandata.yml b/recipes/jeaiii-itoa/all/conandata.yml new file mode 100644 index 0000000000000..4d3c9e2b824e9 --- /dev/null +++ b/recipes/jeaiii-itoa/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20220602": + url: "https://github.com/jeaiii/itoa/archive/84f25b835c8bbcf69eb97802216f8095bf94ef13.tar.gz" + sha256: "a116159f9b49922124b1c87f9989a7a8592f582904d98a3d6398e9013eca3f0f" diff --git a/recipes/jeaiii-itoa/all/conanfile.py b/recipes/jeaiii-itoa/all/conanfile.py new file mode 100644 index 0000000000000..e7cabf3b1a327 --- /dev/null +++ b/recipes/jeaiii-itoa/all/conanfile.py @@ -0,0 +1,54 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.layout import basic_layout +from conan.tools.files import get, copy +import os + + +required_conan_version = ">=1.50.0" + + +class ItoaConan(ConanFile): + name = "jeaiii-itoa" + description = "Fast integer to ascii / integer to string conversion" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/jeaiii/itoa/" + topics = ("string-conversion", "itona", "integer-conversion",) + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _minimum_cpp_standard(self): + return 17 + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + + def package_id(self): + self.info.clear() + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/jeaiii-itoa/all/test_package/CMakeLists.txt b/recipes/jeaiii-itoa/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d27bc00b65615 --- /dev/null +++ b/recipes/jeaiii-itoa/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +find_package(jeaiii-itoa REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE jeaiii-itoa::jeaiii-itoa) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/jeaiii-itoa/all/test_package/conanfile.py b/recipes/jeaiii-itoa/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/jeaiii-itoa/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/jeaiii-itoa/all/test_package/test_package.cpp b/recipes/jeaiii-itoa/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..144466c23b699 --- /dev/null +++ b/recipes/jeaiii-itoa/all/test_package/test_package.cpp @@ -0,0 +1,26 @@ +#include + +#include "itoa/jeaiii_to_text.h" + +template +void itoa(T n, char* b) { + *jeaiii::to_text_from_integer(b, n) = '\0'; +} + +template +void show(T n) { + char text[32]; + itoa(n, text); + std::cout << text << "\n"; +} + +int main(void) { + show(-1); + show(1 << 31); + show(0x7fffffff); + show(-0x7fffffff - 1); + show(17999999999999999999ULL); + show(-5999999999999999999LL); + + return 0; +} diff --git a/recipes/jeaiii-itoa/all/test_v1_package/CMakeLists.txt b/recipes/jeaiii-itoa/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f35b931b51133 --- /dev/null +++ b/recipes/jeaiii-itoa/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(jeaiii-itoa REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE jeaiii-itoa::jeaiii-itoa) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/jeaiii-itoa/all/test_v1_package/conanfile.py b/recipes/jeaiii-itoa/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/jeaiii-itoa/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/jeaiii-itoa/config.yml b/recipes/jeaiii-itoa/config.yml new file mode 100644 index 0000000000000..68b626ef915e2 --- /dev/null +++ b/recipes/jeaiii-itoa/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220602": + folder: all diff --git a/recipes/jemalloc/all/conandata.yml b/recipes/jemalloc/all/conandata.yml index 35efd54bd2bc2..01ec764057557 100644 --- a/recipes/jemalloc/all/conandata.yml +++ b/recipes/jemalloc/all/conandata.yml @@ -1,4 +1,11 @@ sources: + "5.3.0": + url: "https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2" + sha256: "2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa" "5.2.1": url: "https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2" sha256: "34330e5ce276099e2e8950d9335db5a875689a4c6a56751ef3b1d8c537f887f6" + +patches: + "5.2.1": + - patch_file: "patches/0001-clang12-dont-declare-system-functions-as-nothrow.patch" diff --git a/recipes/jemalloc/all/conanfile.py b/recipes/jemalloc/all/conanfile.py index ca9e3d500e87c..03cf37de219b0 100644 --- a/recipes/jemalloc/all/conanfile.py +++ b/recipes/jemalloc/all/conanfile.py @@ -1,9 +1,15 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, MSBuild, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conans import AutoToolsBuildEnvironment, MSBuild +from conan.errors import ConanInvalidConfiguration +from conan.tools.scm import Version +from conans import tools as tools_legacy +from conan.tools.files import apply_conandata_patches, get, rename, replace_in_file +from conan.tools.layout import basic_layout import os import shutil import string +required_conan_version = ">=1.51.3" class JemallocConan(ConanFile): name = "jemalloc" @@ -26,6 +32,7 @@ class JemallocConan(ConanFile): "enable_debug_logging": [True, False], "enable_initial_exec_tls": [True, False], "enable_libdl": [True, False], + "enable_prof": [True, False], } default_options = { "shared": False, @@ -40,21 +47,28 @@ class JemallocConan(ConanFile): "enable_debug_logging": False, "enable_initial_exec_tls": True, "enable_libdl": True, + "enable_prof": False, } + exports_sources = ["patches/**"] _autotools = None - _source_subfolder = "source_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC + if not self.options.enable_cxx: + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def validate(self): if self.options.enable_cxx and \ self.settings.compiler.get_safe("libcxx") == "libc++" and \ self.settings.compiler == "clang" and \ - tools.Version(self.settings.compiler.version) < "10": + Version(self.settings.compiler.version) < "10": raise ConanInvalidConfiguration("clang and libc++ version {} (< 10) is missing a mutex implementation".format(self.settings.compiler.version)) if self.settings.compiler == "Visual Studio" and \ self.options.shared and \ @@ -63,23 +77,28 @@ def configure(self): if self.settings.compiler == "Visual Studio" and self.settings.compiler.version != "15": # https://github.com/jemalloc/jemalloc/issues/1703 raise ConanInvalidConfiguration("Only Visual Studio 15 2017 is supported. Please fix this if other versions are supported") - if self.options.shared: - del self.options.fPIC - if not self.options.enable_cxx: - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd if self.settings.build_type not in ("Release", "Debug", None): raise ConanInvalidConfiguration("Only Release and Debug build_types are supported") if self.settings.compiler == "Visual Studio" and self.settings.arch not in ("x86_64", "x86"): raise ConanInvalidConfiguration("Unsupported arch") + if self.settings.compiler == "clang" and Version(self.settings.compiler.version) <= "3.9": + raise ConanInvalidConfiguration("Unsupported compiler version") + if self.settings.os == "Macos" and self.settings.arch not in ("x86_64", "x86"): + raise ConanInvalidConfiguration("Unsupported arch") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + def layout(self): + basic_layout(self, src_folder="src") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def build_requirements(self): - if tools.os_info.is_windows and not os.environ.get("CONAN_BASH_PATH", None): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + self.build_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) @property def _autotools_args(self): @@ -93,9 +112,11 @@ def _autotools_args(self): "--enable-syscall" if self.options.enable_syscall else "--disable-syscall", "--enable-lazy-lock" if self.options.enable_lazy_lock else "--disable-lazy-lock", "--enable-log" if self.options.enable_debug_logging else "--disable-log", - "--enable-initial-exec-tld" if self.options.enable_initial_exec_tls else "--disable-initial-exec-tls", + "--enable-initial-exec-tls" if self.options.enable_initial_exec_tls else "--disable-initial-exec-tls", "--enable-libdl" if self.options.enable_libdl else "--disable-libdl", ] + if self.options.enable_prof: + conf_args.append("--enable-prof") if self.options.shared: conf_args.extend(["--enable-shared", "--disable-static"]) else: @@ -105,8 +126,8 @@ def _autotools_args(self): def _configure_autotools(self): if self._autotools: return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.configure(args=self._autotools_args, configure_dir=self._source_subfolder) + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools_legacy.os_info.is_windows) + self._autotools.configure(args=self._autotools_args, configure_dir=self.source_folder) return self._autotools @property @@ -118,29 +139,32 @@ def _msvc_build_type(self): def _patch_sources(self): if self.settings.os == "Windows": - makefile_in = os.path.join(self._source_subfolder, "Makefile.in") - tools.replace_in_file(makefile_in, + makefile_in = os.path.join(self.source_folder, "Makefile.in") + replace_in_file(self, makefile_in, "DSO_LDFLAGS = @DSO_LDFLAGS@", - "DSO_LDFLAGS = @DSO_LDFLAGS@ -Wl,--out-implib,lib/libjemalloc.a") - tools.replace_in_file(makefile_in, + "DSO_LDFLAGS = @DSO_LDFLAGS@ -Wl,--out-implib,lib/libjemalloc.a", strict=False) + replace_in_file(self, makefile_in, "\t$(INSTALL) -d $(LIBDIR)\n" "\t$(INSTALL) -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SOREV) $(LIBDIR)", "\t$(INSTALL) -d $(BINDIR)\n" "\t$(INSTALL) -d $(LIBDIR)\n" "\t$(INSTALL) -m 755 $(objroot)lib/$(LIBJEMALLOC).$(SOREV) $(BINDIR)\n" - "\t$(INSTALL) -m 644 $(objroot)lib/libjemalloc.a $(LIBDIR)") + "\t$(INSTALL) -m 644 $(objroot)lib/libjemalloc.a $(LIBDIR)", strict=False) + + apply_conandata_patches(self) + def build(self): self._patch_sources() if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op(): - with tools.environment_append({"CC": "cl", "CXX": "cl"}) if self.settings.compiler == "Visual Studio" else tools.no_op(): - with tools.chdir(self._source_subfolder): + with tools_legacy.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools_legacy.no_op(): + with tools_legacy.environment_append({"CC": "cl", "CXX": "cl"}) if self.settings.compiler == "Visual Studio" else tools_legacy.no_op(): + with tools_legacy.chdir(self.source_folder): # Do not use AutoToolsBuildEnvironment because we want to run configure as ./configure - self.run("./configure {}".format(" ".join(self._autotools_args)), win_bash=tools.os_info.is_windows) + self.run("./configure {}".format(" ".join(self._autotools_args)), win_bash=tools_legacy.os_info.is_windows) msbuild = MSBuild(self) # Do not use the 2015 solution: unresolved external symbols: test_hooks_libc_hook and test_hooks_arena_new_hook - sln_file = os.path.join(self._source_subfolder, "msvc", "jemalloc_vc2017.sln") + sln_file = os.path.join(self.source_folder, "msvc", "jemalloc_vc2017.sln") msbuild.build(sln_file, targets=["jemalloc"], build_type=self._msvc_build_type) else: autotools = self._configure_autotools() @@ -154,7 +178,7 @@ def _library_name(self): if self.settings.build_type == "Debug": libname += "d" else: - toolset = tools.msvs_toolset(self.settings) + toolset = tools_legacy.msvs_toolset(self.settings) toolset_number = "".join(c for c in toolset if c in string.digits) libname += "-vc{}-{}".format(toolset_number, self._msvc_build_type) else: @@ -167,16 +191,16 @@ def _library_name(self): return libname def package(self): - self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses") + self.copy(pattern="COPYING", src=self.source_folder, dst="licenses") if self.settings.compiler == "Visual Studio": arch_subdir = { "x86_64": "x64", "x86": "x86", }[str(self.settings.arch)] - self.copy("*.lib", src=os.path.join(self._source_subfolder, "msvc", arch_subdir, self._msvc_build_type), dst=os.path.join(self.package_folder, "lib")) - self.copy("*.dll", src=os.path.join(self._source_subfolder, "msvc", arch_subdir, self._msvc_build_type), dst=os.path.join(self.package_folder, "bin")) - self.copy("jemalloc.h", src=os.path.join(self._source_subfolder, "include", "jemalloc"), dst=os.path.join(self.package_folder, "include", "jemalloc"), keep_path=True) - shutil.copytree(os.path.join(self._source_subfolder, "include", "msvc_compat"), + self.copy("*.lib", src=os.path.join(self.source_folder, "msvc", arch_subdir, self._msvc_build_type), dst=os.path.join(self.package_folder, "lib")) + self.copy("*.dll", src=os.path.join(self.source_folder, "msvc", arch_subdir, self._msvc_build_type), dst=os.path.join(self.package_folder, "bin")) + self.copy("jemalloc.h", src=os.path.join(self.source_folder, "include", "jemalloc"), dst=os.path.join(self.package_folder, "include", "jemalloc"), keep_path=True) + shutil.copytree(os.path.join(self.source_folder, "include", "msvc_compat"), os.path.join(self.package_folder, "include", "msvc_compat")) else: autotools = self._configure_autotools() @@ -184,16 +208,13 @@ def package(self): autotools.make(target="install_lib_shared" if self.options.shared else "install_lib_static") autotools.make(target="install_include") if self.settings.os == "Windows" and self.settings.compiler == "gcc": - os.rename(os.path.join(self.package_folder, "lib", "{}.lib".format(self._library_name)), - os.path.join(self.package_folder, "lib", "lib{}.a".format(self._library_name))) + rename(self, os.path.join(self.package_folder, "lib", "{}.lib".format(self._library_name)), + os.path.join(self.package_folder, "lib", "lib{}.a".format(self._library_name))) if not self.options.shared: os.unlink(os.path.join(self.package_folder, "lib", "jemalloc.lib")) - def package_id(self): - if not self.settings.build_type: - self.info.settings.build_type = "Release" - def package_info(self): + self.cpp_info.names["pkg_config"] = "jemalloc" self.cpp_info.libs = [self._library_name] self.cpp_info.includedirs = [os.path.join(self.package_folder, "include"), os.path.join(self.package_folder, "include", "jemalloc")] @@ -201,5 +222,5 @@ def package_info(self): self.cpp_info.includedirs.append(os.path.join(self.package_folder, "include", "msvc_compat")) if not self.options.shared: self.cpp_info.defines = ["JEMALLOC_EXPORT="] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["dl", "pthread", "rt"]) diff --git a/recipes/jemalloc/all/patches/0001-clang12-dont-declare-system-functions-as-nothrow.patch b/recipes/jemalloc/all/patches/0001-clang12-dont-declare-system-functions-as-nothrow.patch new file mode 100644 index 0000000000000..d4442cb45bfdd --- /dev/null +++ b/recipes/jemalloc/all/patches/0001-clang12-dont-declare-system-functions-as-nothrow.patch @@ -0,0 +1,90 @@ +diff --git a/include/jemalloc/jemalloc_macros.h.in b/include/jemalloc/jemalloc_macros.h.in +index 59e29558..1ceb7b17 100644 +--- a/include/jemalloc/jemalloc_macros.h.in ++++ b/include/jemalloc/jemalloc_macros.h.in +@@ -71,6 +71,7 @@ + # endif + # define JEMALLOC_FORMAT_ARG(i) + # define JEMALLOC_FORMAT_PRINTF(s, i) ++# define JEMALLOC_FALLTHROUGH + # define JEMALLOC_NOINLINE __declspec(noinline) + # ifdef __cplusplus + # define JEMALLOC_NOTHROW __declspec(nothrow) +@@ -109,6 +110,11 @@ + # else + # define JEMALLOC_FORMAT_PRINTF(s, i) + # endif ++# ifdef JEMALLOC_HAVE_ATTR_FALLTHROUGH ++# define JEMALLOC_FALLTHROUGH JEMALLOC_ATTR(fallthrough) ++# else ++# define JEMALLOC_FALLTHROUGH ++# endif + # define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline) + # define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow) + # define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s)) +@@ -121,9 +127,16 @@ + # define JEMALLOC_ALLOC_SIZE2(s1, s2) + # define JEMALLOC_EXPORT + # define JEMALLOC_FORMAT_PRINTF(s, i) ++# define JEMALLOC_FALLTHROUGH + # define JEMALLOC_NOINLINE + # define JEMALLOC_NOTHROW + # define JEMALLOC_SECTION(s) + # define JEMALLOC_RESTRICT_RETURN + # define JEMALLOC_ALLOCATOR + #endif ++ ++#if defined(__APPLE__) && !defined(JEMALLOC_NO_RENAME) ++# define JEMALLOC_SYS_NOTHROW ++#else ++# define JEMALLOC_SYS_NOTHROW JEMALLOC_NOTHROW ++#endif +diff --git a/include/jemalloc/jemalloc_protos.h.in b/include/jemalloc/jemalloc_protos.h.in +index a78414b1..d75b2224 100644 +--- a/include/jemalloc/jemalloc_protos.h.in ++++ b/include/jemalloc/jemalloc_protos.h.in +@@ -8,21 +8,22 @@ extern JEMALLOC_EXPORT void (*@je_@malloc_message)(void *cbopaque, + const char *s); + + JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN +- void JEMALLOC_NOTHROW *@je_@malloc(size_t size) ++ void JEMALLOC_SYS_NOTHROW *@je_@malloc(size_t size) + JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1); + JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN +- void JEMALLOC_NOTHROW *@je_@calloc(size_t num, size_t size) ++ void JEMALLOC_SYS_NOTHROW *@je_@calloc(size_t num, size_t size) + JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE2(1, 2); +-JEMALLOC_EXPORT int JEMALLOC_NOTHROW @je_@posix_memalign(void **memptr, +- size_t alignment, size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(nonnull(1)); ++JEMALLOC_EXPORT int JEMALLOC_SYS_NOTHROW @je_@posix_memalign( ++ void **memptr, size_t alignment, size_t size) JEMALLOC_CXX_THROW ++ JEMALLOC_ATTR(nonnull(1)); + JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN +- void JEMALLOC_NOTHROW *@je_@aligned_alloc(size_t alignment, ++ void JEMALLOC_SYS_NOTHROW *@je_@aligned_alloc(size_t alignment, + size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) + JEMALLOC_ALLOC_SIZE(2); + JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN +- void JEMALLOC_NOTHROW *@je_@realloc(void *ptr, size_t size) ++ void JEMALLOC_SYS_NOTHROW *@je_@realloc(void *ptr, size_t size) + JEMALLOC_CXX_THROW JEMALLOC_ALLOC_SIZE(2); +-JEMALLOC_EXPORT void JEMALLOC_NOTHROW @je_@free(void *ptr) ++JEMALLOC_EXPORT void JEMALLOC_SYS_NOTHROW @je_@free(void *ptr) + JEMALLOC_CXX_THROW; + + JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN +@@ -55,12 +56,12 @@ JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW @je_@malloc_usable_size( + + #ifdef JEMALLOC_OVERRIDE_MEMALIGN + JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN +- void JEMALLOC_NOTHROW *@je_@memalign(size_t alignment, size_t size) ++ void JEMALLOC_SYS_NOTHROW *@je_@memalign(size_t alignment, size_t size) + JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc); + #endif + + #ifdef JEMALLOC_OVERRIDE_VALLOC + JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN +- void JEMALLOC_NOTHROW *@je_@valloc(size_t size) JEMALLOC_CXX_THROW ++ void JEMALLOC_SYS_NOTHROW *@je_@valloc(size_t size) JEMALLOC_CXX_THROW + JEMALLOC_ATTR(malloc); + #endif diff --git a/recipes/jemalloc/all/test_package/CMakeLists.txt b/recipes/jemalloc/all/test_package/CMakeLists.txt index f1c391badac73..0cc486467b601 100644 --- a/recipes/jemalloc/all/test_package/CMakeLists.txt +++ b/recipes/jemalloc/all/test_package/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -add_executable(${PROJECT_NAME} test_package.c) +add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY C_STANDARD 99) +set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/jemalloc/all/test_package/conanfile.py b/recipes/jemalloc/all/test_package/conanfile.py index b88a6525524a6..d4128b0450777 100644 --- a/recipes/jemalloc/all/test_package/conanfile.py +++ b/recipes/jemalloc/all/test_package/conanfile.py @@ -1,4 +1,4 @@ -from conans import ConanFile, CMake +from conans import ConanFile, CMake, tools import os @@ -12,5 +12,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/jemalloc/all/test_package/test_package.c b/recipes/jemalloc/all/test_package/test_package.cpp similarity index 100% rename from recipes/jemalloc/all/test_package/test_package.c rename to recipes/jemalloc/all/test_package/test_package.cpp diff --git a/recipes/jemalloc/config.yml b/recipes/jemalloc/config.yml index 7be9a7ca5a898..28cb9a5ecdcdf 100644 --- a/recipes/jemalloc/config.yml +++ b/recipes/jemalloc/config.yml @@ -1,3 +1,5 @@ versions: "5.2.1": folder: all + "5.3.0": + folder: all diff --git a/recipes/jerryscript/all/conandata.yml b/recipes/jerryscript/all/conandata.yml index 994c78e8c0a01..f587b0a08830d 100644 --- a/recipes/jerryscript/all/conandata.yml +++ b/recipes/jerryscript/all/conandata.yml @@ -5,11 +5,18 @@ sources: "2.3.0": sha256: 59b31bf519fcfd7c250815848820bf64439843bbfe54452b4060df2079e01d83 url: https://github.com/jerryscript-project/jerryscript/archive/v2.3.0.zip - + "2.4.0": + sha256: 08c950b8689f1229e9796a7beb2e6c5c911f49666db7712ddf006d76a0766b79 + url: https://github.com/jerryscript-project/jerryscript/archive/v2.4.0.zip patches: "2.2.0": - base_path: "source_subfolder" - patch_file: "patches/001-2.5.0-remove-werror.patch" + patch_file: "patches/0001-2.3.0-remove-werror.patch" "2.3.0": - base_path: "source_subfolder" - patch_file: "patches/001-2.5.0-remove-werror.patch" + patch_file: "patches/0001-2.3.0-remove-werror.patch" + "2.4.0": + - base_path: "source_subfolder" + patch_file: "patches/0002-2.4.0-remove-werror.patch" + - base_path: "source_subfolder" + patch_file: "patches/0003-2.4.0-no-CMAKE_SOURCE_DIR.patch" diff --git a/recipes/jerryscript/all/conanfile.py b/recipes/jerryscript/all/conanfile.py index 6d5f434b09a17..d7fc6037445eb 100644 --- a/recipes/jerryscript/all/conanfile.py +++ b/recipes/jerryscript/all/conanfile.py @@ -1,6 +1,8 @@ -import os from conans import CMake, ConanFile, tools from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" class JerryScriptStackConan(ConanFile): name = "jerryscript" @@ -14,15 +16,80 @@ class JerryScriptStackConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "tool_cmdline": [True, False], + "tool_cmdline_test": [True, False], + "tool_cmdline_snapshot": [True, False], + "default_port_implementation": [True, False], + "jerry_ext": [True, False], + "jerry_math": [True, False], + "link_time_optimization": [True, False], + "strip_symbols": [True, False], + "amalgamated": [True, False], + "debugger": [True, False], + "keep_line_info": [True, False], + "profile": "ANY", + "promise_callback": [True, False], + "external_context": [True, False], + "snapshot_execution": [True, False], + "snapshot_saving": [True, False], + "parser": [True, False], + "enable_dump_bytecode": [True, False], + "enable_dump_regexp_bytecode": [True, False], + "strict_regexp": [True, False], + "error_messages": [True, False], + "logging": [True, False], + "memory_statistics": [True, False], + "heap_size": "ANY", + "gc_limit": "ANY", + "gc_mark_limit": "ANY", + "stack_limit": "ANY", + "cpointer_32_bit": [True, False], + "system_allocator": [True, False], + "valgrind": [True, False], + "gc_before_each_alloc": [True, False], + "vm_exec_stop": [True, False], } default_options = { "shared": False, - "fPIC": True + "fPIC": True, + "tool_cmdline": True, + "tool_cmdline_test": False, + "tool_cmdline_snapshot": False, + "default_port_implementation": True, + "jerry_ext": True, + "jerry_math": False, # Initialized in `config_options` + "link_time_optimization": False, # Enabled by upstream, but disabled to be confirm cci (add -flto in your profile) + "strip_symbols": True, + "amalgamated": False, + "debugger": False, + "keep_line_info": False, + "profile": None, # Initialized in `config_options` + "promise_callback": False, + "external_context": False, + "snapshot_execution": False, + "snapshot_saving": False, + "parser": True, + "enable_dump_bytecode": False, + "enable_dump_regexp_bytecode": False, + "strict_regexp": False, + "error_messages": False, + "logging": False, + "memory_statistics": False, + "heap_size": 512, + "gc_limit": 0, + "gc_mark_limit": 8, + "stack_limit": 0, + "cpointer_32_bit": False, + "system_allocator": False, + "valgrind": False, + "gc_before_each_alloc": False, + "vm_exec_stop": False, } generators = "cmake" short_paths = True _cmake = None + _predefined_profiles = ["es.next", "es5.1", "minimal"] @property def _source_subfolder(self): @@ -32,21 +99,70 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _jerry_math(self): + return self.options.get_safe("jerry_math", False) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + # profile and jerry_match default option value depend on version + if tools.Version(self.version) < "2.4.0": + self.options.profile = "es5.1" + self.options.jerry_math = True + if self.settings.compiler == "Visual Studio": + del self.options.jerry_math # forced to False + else: + self.options.profile = "es.next" + self.options.jerry_math = False + + if self.settings.os == "Macos": + del self.options.jerry_math # forced to False + del self.options.link_time_optimization # forced to False + del self.options.strip # forced to False def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + + if not self.options.debugger: + del self.options.keep_line_info if self.settings.os == "Windows" and self.options.shared: raise ConanInvalidConfiguration("jerryscript shared lib is not yet supported under windows") + def validate(self): + # validate integers + try: + checks = ( + (0 <= int(self.options.heap_size), "heap_size must be bigger than or equal to 0"), + (0 <= int(self.options.gc_limit) <= 8192, "gc_limit must be in the range [0, 8192]"), + (0 <= int(self.options.gc_mark_limit), "gc_mark_limit must be bigger than or equal to 0"), + (0 <= int(self.options.stack_limit), "stack_limit must be bigger than or equal to 0"), + ) + for check_res, txt in checks: + if not check_res: + raise ConanInvalidConfiguration(txt) + except ValueError as e: + raise ConanInvalidConfiguration("jerryscript heap size, gc mark limit, stack limit, gc limit should be a positive integer") + # validate profile file + if self.options.profile not in self._predefined_profiles and not os.path.isfile(str(self.options.profile)): + raise ConanInvalidConfiguration("Invalid profile option. Feature profile must either be a valid file or one of these: es.next, es5.1, minimal") + # validate the use of the system allocator option + if self.settings.arch == "x86_64" and self.options.system_allocator: + raise ConanInvalidConfiguration("jerryscript system allocator not available on 64bit systems") + if self.options.system_allocator and not self.options.cpointer_32_bit: + raise ConanInvalidConfiguration("jerryscript system allocator must be used with 32 bit pointers") + + def package_id(self): + if self.options.profile not in self._predefined_profiles: + self.info.options.profile = tools.load(str(self.options.profile)) + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _patch_sources(self): for patch in self.conan_data["patches"][self.version]: @@ -56,8 +172,42 @@ def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - self._cmake.definitions["JERRY_CMDLINE"] = False - self._cmake.definitions["ENABLE_LTO"] = False + amalgamation_definition = "ENABLE_AMALGAM" + libmath_definition = "JERRY_MATH" + if tools.Version(self.version) < tools.Version("2.4.0"): + amalgamation_definition = "ENABLE_ALL_IN_ONE" + libmath_definition = "JERRY_LIBM" + self._cmake.definitions["JERRY_CMDLINE"] = self.options.tool_cmdline + self._cmake.definitions["JERRY_CMDLINE_TEST"] = self.options.tool_cmdline_test + self._cmake.definitions["JERRY_CMDLINE_SNAPSHOT"] = self.options.tool_cmdline_snapshot + self._cmake.definitions["JERRY_PORT_DEFAULT"] = self.options.default_port_implementation + self._cmake.definitions["JERRY_EXT"] = self.options.jerry_ext + self._cmake.definitions[libmath_definition] = self._jerry_math + self._cmake.definitions["ENABLE_STRIP"] = self.options.get_safe("jerry_strip", False) + self._cmake.definitions["ENABLE_LTO"] = self.options.get_safe("link_time_optimization", False) + self._cmake.definitions[amalgamation_definition] = self.options.amalgamated + self._cmake.definitions["JERRY_DEBUGGER"] = self.options.debugger + self._cmake.definitions["JERRY_LINE_INFO"] = self.options.get_safe("keep_line_info", False) + self._cmake.definitions["JERRY_PROFILE"] = self.options.profile + self._cmake.definitions["JERRY_EXTERNAL_CONTEXT"] = self.options.external_context + self._cmake.definitions["JERRY_SNAPSHOT_EXEC"] = self.options.snapshot_execution + self._cmake.definitions["JERRY_SNAPSHOT_SAVE"] = self.options.snapshot_saving + self._cmake.definitions["JERRY_PARSER"] = self.options.parser + self._cmake.definitions["JERRY_PARSER_DUMP_BYTE_CODE"] = self.options.enable_dump_bytecode + self._cmake.definitions["JERRY_REGEXP_DUMP_BYTE_CODE"] = self.options.enable_dump_regexp_bytecode + self._cmake.definitions["JERRY_REGEXP_STRICT_MODE"] = self.options.strict_regexp + self._cmake.definitions["JERRY_ERROR_MESSAGES"] = self.options.error_messages + self._cmake.definitions["JERRY_LOGGING"] = self.options.logging + self._cmake.definitions["JERRY_MEM_STATS"] = self.options.memory_statistics + self._cmake.definitions["JERRY_GLOBAL_HEAP_SIZE"] = "(%s)" % self.options.heap_size + self._cmake.definitions["JERRY_GC_LIMIT"] = "(%s)" % self.options.gc_limit + self._cmake.definitions["JERRY_GC_MARK_LIMIT"] = "(%s)" % self.options.gc_mark_limit + self._cmake.definitions["JERRY_STACK_LIMIT"] = "(%s)" % self.options.stack_limit + self._cmake.definitions["JERRY_CPOINTER_32_BIT"] = self.options.cpointer_32_bit + self._cmake.definitions["JERRY_SYSTEM_ALLOCATOR"] = self.options.system_allocator + self._cmake.definitions["JERRY_VALGRIND"] = self.options.valgrind + self._cmake.definitions["JERRY_MEM_GC_BEFORE_EACH_ALLOC"] = self.options.gc_before_each_alloc + self._cmake.definitions["JERRY_VM_EXEC_STOP"] = self.options.vm_exec_stop self._cmake.configure(build_folder=self._build_subfolder) return self._cmake @@ -73,6 +223,28 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["pthread"] + self.cpp_info.components["libjerry-port-default"].names["pkg_config"] = ["libjerry-port-default"] + self.cpp_info.components["libjerry-port-default"].libs = ["jerry-port-default"] + + if self._jerry_math: + mathlibname = "jerry-libm" if tools.Version(self.version) < "2.4.0" else "jerry-math" + self.cpp_info.components["libjerry-math"].names["pkg_config"] = "lib{}".format(mathlibname) + self.cpp_info.components["libjerry-math"].libs = [mathlibname] + self.cpp_info.components["libjerry-math"].requires = ["libjerry-port-default"] + self.cpp_info.components["libjerry-core"].requires.append("libjerry-math") + + if tools.Version(self.version) < "2.4.0": + self.cpp_info.components["libjerry-port-default-minimal"].names["pkg_config"] = ["libjerry-port-default-minimal"] + self.cpp_info.components["libjerry-port-default-minimal"].libs = ["jerry-port-default-minimal"] + self.cpp_info.components["libjerry-port-default"].requires.append("libjerry-port-default-minimal") + + self.cpp_info.components["libjerry-core"].names["pkg_config"] = "libjerry-core" + self.cpp_info.components["libjerry-core"].libs = ["jerry-core"] + # The pc file does not explicitly add the port. But it's needed for the test + self.cpp_info.components["libjerry-core"].requires = ["libjerry-port-default"] + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.components["libjerry-core"].system_libs.append("m") + + self.cpp_info.components["libjerry-ext"].names["pkg_config"] = "libjerry-ext" + self.cpp_info.components["libjerry-ext"].libs = ["jerry-ext"] + self.cpp_info.components["libjerry-ext"].requires = ["libjerry-core"] diff --git a/recipes/jerryscript/all/patches/001-2.5.0-remove-werror.patch b/recipes/jerryscript/all/patches/0001-2.3.0-remove-werror.patch similarity index 100% rename from recipes/jerryscript/all/patches/001-2.5.0-remove-werror.patch rename to recipes/jerryscript/all/patches/0001-2.3.0-remove-werror.patch diff --git a/recipes/jerryscript/all/patches/0002-2.4.0-remove-werror.patch b/recipes/jerryscript/all/patches/0002-2.4.0-remove-werror.patch new file mode 100644 index 0000000000000..1a78f4990c52e --- /dev/null +++ b/recipes/jerryscript/all/patches/0002-2.4.0-remove-werror.patch @@ -0,0 +1,21 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 43ac22ea..3002c869 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -167,7 +167,6 @@ endmacro() + macro(jerry_add_compile_warnings) + foreach(_warning ${ARGV}) + jerry_add_compile_flags(-W${_warning}) +- jerry_add_compile_flags(-Werror=${_warning}) + endforeach() + endmacro() + +@@ -212,7 +211,7 @@ if(USING_GCC OR USING_CLANG) + jerry_add_compile_flags(-fno-builtin) + endif() + jerry_add_compile_warnings(all extra format-nonliteral init-self conversion sign-conversion format-security missing-declarations shadow strict-prototypes undef old-style-definition) +- jerry_add_compile_flags(-Wno-stack-protector -Wno-attributes -Werror) ++ jerry_add_compile_flags(-Wno-stack-protector -Wno-attributes) + endif() + + if(USING_GCC) diff --git a/recipes/jerryscript/all/patches/0003-2.4.0-no-CMAKE_SOURCE_DIR.patch b/recipes/jerryscript/all/patches/0003-2.4.0-no-CMAKE_SOURCE_DIR.patch new file mode 100644 index 0000000000000..49c14b7b568df --- /dev/null +++ b/recipes/jerryscript/all/patches/0003-2.4.0-no-CMAKE_SOURCE_DIR.patch @@ -0,0 +1,11 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -16,7 +16,7 @@ + project (Jerry C) + + # Determining version +-execute_process(COMMAND python ${CMAKE_SOURCE_DIR}/tools/version.py ++execute_process(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/tools/version.py + OUTPUT_VARIABLE JERRY_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + diff --git a/recipes/jerryscript/all/test_package/CMakeLists.txt b/recipes/jerryscript/all/test_package/CMakeLists.txt index 33ae887aa6aea..7b9b613cbb24a 100644 --- a/recipes/jerryscript/all/test_package/CMakeLists.txt +++ b/recipes/jerryscript/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -add_executable(${PROJECT_NAME} test_package.cpp) +add_executable(${PROJECT_NAME} test_package.c) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/jerryscript/all/test_package/conanfile.py b/recipes/jerryscript/all/test_package/conanfile.py index 933dbf96533ae..bbf2351737349 100644 --- a/recipes/jerryscript/all/test_package/conanfile.py +++ b/recipes/jerryscript/all/test_package/conanfile.py @@ -1,6 +1,5 @@ -import os - from conans import ConanFile, CMake, tools +import os class TestConan(ConanFile): @@ -15,4 +14,4 @@ def build(self): def test(self): if not tools.cross_building(self.settings): bin_path = os.path.join("bin", "test_package") - bin_path = self.run(bin_path, run_environment=True) + self.run(bin_path, run_environment=True) diff --git a/recipes/jerryscript/all/test_package/test_package.c b/recipes/jerryscript/all/test_package/test_package.c new file mode 100644 index 0000000000000..6fb91c9d18268 --- /dev/null +++ b/recipes/jerryscript/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include "jerryscript.h" + +int main() +{ + const jerry_char_t script[] = "var str = 'Hello, World!';"; + + bool ret_value = jerry_run_simple(script, sizeof(script) - 1, JERRY_INIT_EMPTY); + + return (ret_value ? 0 : 1); +} diff --git a/recipes/jerryscript/all/test_package/test_package.cpp b/recipes/jerryscript/all/test_package/test_package.cpp deleted file mode 100644 index 82bee659d3770..0000000000000 --- a/recipes/jerryscript/all/test_package/test_package.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "jerryscript.h" - -int main(void) -{ - const jerry_char_t script[] = "var str = 'Hello, World!';"; - - bool ret_value = jerry_run_simple(script, sizeof(script) - 1, JERRY_INIT_EMPTY); - - return (ret_value ? 0 : 1); -} diff --git a/recipes/jerryscript/config.yml b/recipes/jerryscript/config.yml index 7712133f3e186..096f3e543ee8d 100644 --- a/recipes/jerryscript/config.yml +++ b/recipes/jerryscript/config.yml @@ -3,3 +3,5 @@ versions: folder: "all" "2.3.0": folder: "all" + "2.4.0": + folder: "all" diff --git a/recipes/jfalcou-eve/all/conandata.yml b/recipes/jfalcou-eve/all/conandata.yml new file mode 100644 index 0000000000000..05a5aeff2b5fd --- /dev/null +++ b/recipes/jfalcou-eve/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "v2021.10.0": + url: "https://github.com/jfalcou/eve/archive/refs/tags/v2021.10.0.tar.gz" + sha256: "580c40a8244039a700b93ea49fb0affc1c8d3c100eb6dc66368e101753f51e5c" + "v2022.03.0": + url: "https://github.com/jfalcou/eve/archive/refs/tags/v2022.03.0.tar.gz" + sha256: "8bf9faea516806e7dd468e778dcedc81c51f0b2c6a70b9c75987ce12bb759911" + "v2022.09.0": + url: "https://github.com/jfalcou/eve/archive/refs/tags/v2022.09.0.tar.gz" + sha256: "53a4e1944a1080c67380a6d7f4fb42998f1c1db35e2370e02d7853c3ac1e0a33" + "v2022.09.1": + url: "https://github.com/jfalcou/eve/archive/refs/tags/v2022.09.1.tar.gz" + sha256: "d8d3ae55f0ca2690f8a22883eaaa8251275b76702da0267e8e1725b22c51e978" diff --git a/recipes/jfalcou-eve/all/conanfile.py b/recipes/jfalcou-eve/all/conanfile.py new file mode 100644 index 0000000000000..d79178dde59e1 --- /dev/null +++ b/recipes/jfalcou-eve/all/conanfile.py @@ -0,0 +1,85 @@ +from conan import ConanFile +from conan.tools import files +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy +from conan.tools.scm import Version +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc +from conan.errors import ConanInvalidConfiguration +import os + + +required_conan_version = ">=1.51.3" + + +class JfalcouEveConan(ConanFile): + name = "jfalcou-eve" + description = ("Expressive Velocity Engine - reimplementation of the old " + "Boost.SIMD on C++20" + ) + homepage = "https://jfalcou.github.io/eve/" + topics = ("cpp", "simd") + license = ("MIT", "BSL-1.0") + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + + @property + def _min_cppstd(self): + return "20" + + @property + def _compilers_minimum_version(self): + return {"gcc": "11", + "Visual Studio": "16.9", + "msvc": "1928", + "clang": "13", + "apple-clang": "13"} + + def configure(self): + version = Version(self.version.strip("v")) + if version.major < 2022 or (version.major == 2022 and version.minor < 9): + self.license = "MIT" + else: + self.license = "BSL-1.0" + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + # FIXME: Need to use self.info.settings for header-only + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._min_cppstd) + if is_msvc(self): + raise ConanInvalidConfiguration("EVE does not support MSVC yet (https://github.com/jfalcou/eve/issues/1022).") + if self.settings.compiler == "apple-clang": + raise ConanInvalidConfiguration("EVE does not support apple Clang due to an incomplete libcpp.") + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if not minimum_version: + self.output.warn(f"{self.ref} requires C++{self._min_cppstd}. Your compiler is unknown. Assuming it supports C++{self._min_cppstd}.") + elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.") + + def package_id(self): + self.info.clear() + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self.source_folder) + + def package(self): + copy(self, pattern="*.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "LICENSE.md", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "eve" + self.cpp_info.names["cmake_find_package_multi"] = "eve" + self.cpp_info.set_property("cmake_file_name", "eve") + self.cpp_info.set_property("cmake_target_name", "eve::eve") diff --git a/recipes/jfalcou-eve/all/test_package/CMakeLists.txt b/recipes/jfalcou-eve/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..07df5491f5a34 --- /dev/null +++ b/recipes/jfalcou-eve/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package CXX) + +find_package(eve REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE eve::eve) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) diff --git a/recipes/jfalcou-eve/all/test_package/conanfile.py b/recipes/jfalcou-eve/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/jfalcou-eve/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/jfalcou-eve/all/test_package/test_package.cpp b/recipes/jfalcou-eve/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4ce2503134165 --- /dev/null +++ b/recipes/jfalcou-eve/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main() +{ + eve::wide> p{1.f,2.f,3.f,4.f}; + std::cout << "eve test: " << p + 10 * p << "\n"; + return 0; +} diff --git a/recipes/jfalcou-eve/all/test_v1_package/CMakeLists.txt b/recipes/jfalcou-eve/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7e31b52213165 --- /dev/null +++ b/recipes/jfalcou-eve/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(eve REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE eve::eve) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) diff --git a/recipes/jfalcou-eve/all/test_v1_package/conanfile.py b/recipes/jfalcou-eve/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..daab8195118f1 --- /dev/null +++ b/recipes/jfalcou-eve/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + + +class JfalcouEveConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/jfalcou-eve/config.yml b/recipes/jfalcou-eve/config.yml new file mode 100644 index 0000000000000..5db2eb32f0264 --- /dev/null +++ b/recipes/jfalcou-eve/config.yml @@ -0,0 +1,9 @@ +versions: + "v2021.10.0": + folder: all + "v2022.03.0": + folder: all + "v2022.09.0": + folder: all + "v2022.09.1": + folder: all diff --git a/recipes/jinja2cpp/all/conandata.yml b/recipes/jinja2cpp/all/conandata.yml index d90c57c0ac710..ba871764ca5c4 100644 --- a/recipes/jinja2cpp/all/conandata.yml +++ b/recipes/jinja2cpp/all/conandata.yml @@ -1,8 +1,14 @@ sources: + "1.2.1": + url: "https://github.com/jinja2cpp/Jinja2Cpp/archive/refs/tags/1.2.1.tar.gz" + sha256: "2e61516fd4fd77452c8dd7a6f958ad47c42990df9b7bdc62cf2deb8aa7819b6c" "1.1.0": - url: https://github.com/jinja2cpp/Jinja2Cpp/archive/1.1.0.tar.gz - sha256: 3d321a144f3774702d3a6252e3a6370cdaff9c96d8761d850bb79cdb45b372c5 + url: "https://github.com/jinja2cpp/Jinja2Cpp/archive/1.1.0.tar.gz" + sha256: "3d321a144f3774702d3a6252e3a6370cdaff9c96d8761d850bb79cdb45b372c5" patches: + "1.2.1": + - patch_file: "patches/fix-cmake-1.2.1.patch" + base_path: "source_subfolder" "1.1.0": - - patch_file: "patches/fix-cmake.patch" + - patch_file: "patches/fix-cmake-1.1.0.patch" base_path: "source_subfolder" diff --git a/recipes/jinja2cpp/all/conanfile.py b/recipes/jinja2cpp/all/conanfile.py index 01a5f3081af9f..5ccade1cbf22f 100644 --- a/recipes/jinja2cpp/all/conanfile.py +++ b/recipes/jinja2cpp/all/conanfile.py @@ -1,9 +1,10 @@ +from conan.tools.microsoft import msvc_runtime_flag from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.43.0" class Jinja2cppConan(ConanFile): @@ -12,13 +13,19 @@ class Jinja2cppConan(ConanFile): homepage = "https://jinja2cpp.dev/" url = "https://github.com/conan-io/conan-center-index" description = "Jinja2 C++ (and for C++) almost full-conformance template engine implementation" - topics = ("conan", "cpp14", "cpp17", "jinja2", "string templates", "templates engine") - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake", "cmake_find_package" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + topics = ("cpp14", "cpp17", "jinja2", "string templates", "templates engine") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake", "cmake_find_package" _cmake = None @property @@ -29,6 +36,15 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -36,22 +52,27 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 14) def requirements(self): - self.requires("boost/1.75.0") + self.requires("boost/1.78.0") self.requires("expected-lite/0.5.0") - self.requires("fmt/6.2.1") # not compatible with fmt >= 7.0.0 - self.requires("optional-lite/3.4.0") - self.requires("rapidjson/cci.20200410") + self.requires("optional-lite/3.5.0") + self.requires("rapidjson/cci.20211112") self.requires("string-view-lite/1.6.0") self.requires("variant-lite/2.0.0") + if self.version == "1.1.0": + self.requires("fmt/6.2.1") # not compatible with fmt >= 7.0.0 + else: + self.requires("nlohmann_json/3.10.5") + self.requires("fmt/8.1.1") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 14) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "Jinja2Cpp-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): @@ -73,21 +94,17 @@ def _configure_cmake(self): # but provide build-type-specific runtime type flag. For now, Jinja2C++ build scripts # need to know the build type is being built in order to setup internal flags correctly self._cmake.definitions["CMAKE_BUILD_TYPE"] = self.settings.build_type - compiler = self.settings.get_safe("compiler") - if compiler == "Visual Studio": + if self._is_msvc: # Runtime type configuration for Jinja2C++ should be strictly '/MT' or '/MD' - runtime = self.settings.get_safe("compiler.runtime") - if runtime == "MTd": - runtime = "MT" - if runtime == "MDd": - runtime = "MD" - self._cmake.definitions["JINJA2CPP_MSVC_RUNTIME_TYPE"] = "/" + runtime + runtime = "/MD" if "MD" in msvc_runtime_flag(self) else "/MT" + self._cmake.definitions["JINJA2CPP_MSVC_RUNTIME_TYPE"] = runtime self._cmake.configure(build_folder=self._build_subfolder) return self._cmake def build(self): - if tools.Version(self.deps_cpp_info["fmt"].version) >= "7.0.0": - raise ConanInvalidConfiguration("jinja2cpp requires fmt < 7.0.0") + if self.version == "1.1.0": + if tools.Version(self.deps_cpp_info["fmt"].version) >= "7.0.0": + raise ConanInvalidConfiguration("jinja2cpp requires fmt < 7.0.0") self._patch_sources() cmake = self._configure_cmake() cmake.build() @@ -98,8 +115,10 @@ def package(self): cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib", "jinja2cpp")) tools.rmdir(os.path.join(self.package_folder, "share")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._module_subfolder, self._module_file), + os.path.join(self.package_folder, self._module_file_rel_path), {"jinja2cpp": "jinja2cpp::jinja2cpp"} ) @@ -116,18 +135,14 @@ def _create_cmake_module_alias_targets(module_file, targets): tools.save(module_file, content) @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") - - @property - def _module_file(self): - return "conan-official-{}-targets.cmake".format(self.name) + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "jinja2cpp" - self.cpp_info.names["cmake_find_package_multi"] = "jinja2cpp" - self.cpp_info.builddirs.append(self._module_subfolder) - module_rel_path = os.path.join(self._module_subfolder, self._module_file) - self.cpp_info.build_modules["cmake_find_package"] = [module_rel_path] - self.cpp_info.build_modules["cmake_find_package_multi"] = [module_rel_path] + self.cpp_info.set_property("cmake_file_name", "jinja2cpp") + self.cpp_info.set_property("cmake_target_name", "jinja2cpp") self.cpp_info.libs = ["jinja2cpp"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/jinja2cpp/all/patches/fix-cmake.patch b/recipes/jinja2cpp/all/patches/fix-cmake-1.1.0.patch similarity index 100% rename from recipes/jinja2cpp/all/patches/fix-cmake.patch rename to recipes/jinja2cpp/all/patches/fix-cmake-1.1.0.patch diff --git a/recipes/jinja2cpp/all/patches/fix-cmake-1.2.1.patch b/recipes/jinja2cpp/all/patches/fix-cmake-1.2.1.patch new file mode 100644 index 0000000000000..d355b60a17daa --- /dev/null +++ b/recipes/jinja2cpp/all/patches/fix-cmake-1.2.1.patch @@ -0,0 +1,39 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bf603b0..6229f02 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -282,7 +282,7 @@ install( + InstallTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/jinja2cpp + ) + +diff --git a/src/helpers.h b/src/helpers.h +index 3af280f..a6a3205 100644 +--- a/src/helpers.h ++++ b/src/helpers.h +@@ -32,12 +32,21 @@ struct MultiStringLiteral + #endif + } + ++#if defined(_MSC_VER) && (_MSC_VER <= 1900) ++ template ++ auto GetValueStr() const ++ { ++ auto memPtr = SelectMemberPtr::GetPtr(); ++ return std::basic_string(this->*memPtr); ++ } ++#else + template + constexpr auto GetValueStr() const + { + constexpr auto memPtr = SelectMemberPtr::GetPtr(); + return std::basic_string(this->*memPtr); + } ++#endif + + template + struct SelectMemberPtr; diff --git a/recipes/jinja2cpp/all/test_package/conanfile.py b/recipes/jinja2cpp/all/test_package/conanfile.py index 28dd8e8061367..38f4483872d47 100644 --- a/recipes/jinja2cpp/all/test_package/conanfile.py +++ b/recipes/jinja2cpp/all/test_package/conanfile.py @@ -1,6 +1,7 @@ from conans import ConanFile, CMake, tools import os + class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" @@ -11,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/jinja2cpp/config.yml b/recipes/jinja2cpp/config.yml index b5c0d3cb2d409..97294286ce46b 100644 --- a/recipes/jinja2cpp/config.yml +++ b/recipes/jinja2cpp/config.yml @@ -1,3 +1,5 @@ versions: + "1.2.1": + folder: all "1.1.0": folder: all diff --git a/recipes/jom/all/conanfile.py b/recipes/jom/all/conanfile.py index df5ddcdd86ee8..d1824504b7e54 100644 --- a/recipes/jom/all/conanfile.py +++ b/recipes/jom/all/conanfile.py @@ -1,7 +1,9 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.files import get, download +from conan.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.47.0" class JomInstallerConan(ConanFile): name = "jom" @@ -9,21 +11,40 @@ class JomInstallerConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "http://wiki.qt.io/Jom" license = "GPL-3.0" - topics = ("conan", "jom", "build", "makefile", "make") + topics = ("build", "makefile", "make") - settings = "os" + settings = "os", "arch", "compiler", "build_type" - def configure(self): + # not needed but supress warning message from conan commands + def layout(self): + pass + + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type + + def validate(self): if self.settings.os != "Windows": raise ConanInvalidConfiguration("Only Windows supported") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - tools.download('https://code.qt.io/cgit/qt-labs/jom.git/plain/LICENSE.GPL?h=v%s' % self.version, filename='LICENSE.GPL') + get(self, **self.conan_data["sources"][self.version]) + download(self, f'https://code.qt.io/cgit/qt-labs/jom.git/plain/LICENSE.GPL?h=v{self.version}', filename='LICENSE.GPL') def package(self): self.copy("LICENSE.GPL", dst= 'licenses', src='') self.copy("*.exe", dst="bin", src="") - + def package_info(self): - self.env_info.path.append(os.path.join(self.package_folder, "bin")) + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + self.cpp_info.includedirs = [] + + bin_folder = os.path.join(self.package_folder, "bin") + # In case need to find packaged tools when building a package + self.buildenv_info.append("PATH", bin_folder) + # In case need to find packaged tools at runtime + self.runenv_info.append("PATH", bin_folder) + # TODO: Legacy, to be removed on Conan 2.0 + self.env_info.PATH.append(bin_folder) diff --git a/recipes/jpcre2/all/conandata.yml b/recipes/jpcre2/all/conandata.yml new file mode 100644 index 0000000000000..eafde8567d90c --- /dev/null +++ b/recipes/jpcre2/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "10.32.01": + sha256: 668cbc6d2c0a065bb6abe8494d5a1bb3549a14cd956a44a2df9095045623ea47 + url: https://github.com/jpcre2/jpcre2/archive/refs/tags/10.32.01.tar.gz diff --git a/recipes/jpcre2/all/conanfile.py b/recipes/jpcre2/all/conanfile.py new file mode 100644 index 0000000000000..f0f2f817d89da --- /dev/null +++ b/recipes/jpcre2/all/conanfile.py @@ -0,0 +1,33 @@ +from conans import ConanFile, tools +import os + +required_conan_version = ">=1.33.0" + + +class Jpcre2Conan(ConanFile): + name = "jpcre2" + homepage = "https://github.com/jpcre2/jpcre2" + description = "Header-only C++ wrapper for PCRE2 library." + topics = ("regex", "pcre2", "header-only", "single-header") + url = "https://github.com/conan-io/conan-center-index" + license = "BSD-3-Clause" + + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def requirements(self): + self.requires("pcre2/10.37") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + self.copy("jpcre2.hpp", dst="include", src=os.path.join(self._source_subfolder, "src")) + + def package_id(self): + self.info.header_only() diff --git a/recipes/jpcre2/all/test_package/CMakeLists.txt b/recipes/jpcre2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c2f7a55ce01f3 --- /dev/null +++ b/recipes/jpcre2/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(jpcre2 REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE jpcre2::jpcre2) diff --git a/recipes/jpcre2/all/test_package/conanfile.py b/recipes/jpcre2/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3da371b660e0a --- /dev/null +++ b/recipes/jpcre2/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/jpcre2/all/test_package/test_package.cpp b/recipes/jpcre2/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..dbaa3accd96c7 --- /dev/null +++ b/recipes/jpcre2/all/test_package/test_package.cpp @@ -0,0 +1,15 @@ +#include + +typedef jpcre2::select jp; + +int main(int, char**) +{ + jp::Regex re; + re.setPattern("Hello (\\S+?)").compile(); + if (!re.match("Hello conan-center-index")) + { + return 1; + } + + return 0; +} diff --git a/recipes/jpcre2/config.yml b/recipes/jpcre2/config.yml new file mode 100644 index 0000000000000..37404362b8cc6 --- /dev/null +++ b/recipes/jpcre2/config.yml @@ -0,0 +1,3 @@ +versions: + "10.32.01": + folder: all diff --git a/recipes/jpeg-compressor/all/CMakeLists.txt b/recipes/jpeg-compressor/all/CMakeLists.txt index 0e47d5a0562dd..dfd323b394ceb 100644 --- a/recipes/jpeg-compressor/all/CMakeLists.txt +++ b/recipes/jpeg-compressor/all/CMakeLists.txt @@ -1,33 +1,25 @@ -cmake_minimum_required(VERSION 3.4) -project(jpeg-compressor) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -set(JPEGCOMPRESSOR_SOURCE_SUBFOLDER "${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder") - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) +cmake_minimum_required(VERSION 3.8) +project(jpeg-compressor LANGUAGES CXX) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -# jgpd lib - -set(JPGD_SRC_LIST ${JPEGCOMPRESSOR_SOURCE_SUBFOLDER}/jpgd.cpp) -set(JPGD_HDR_LIST ${JPEGCOMPRESSOR_SOURCE_SUBFOLDER}/jpgd.h ${JPEGCOMPRESSOR_SOURCE_SUBFOLDER}/jpgd_idct.h) -add_library(jpgd ${JPGD_SRC_LIST} ${JPGD_HDR_LIST}) -target_include_directories(jpgd PUBLIC ${JPEGCOMPRESSOR_SOURCE_SUBFOLDER}) - -install(TARGETS jpgd) -install(FILES ${JPGD_HDR_LIST} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -# jgpe lib - -set(JPGE_SRC_LIST ${JPEGCOMPRESSOR_SOURCE_SUBFOLDER}/jpge.cpp) -set(JPGE_HDR_LIST ${JPEGCOMPRESSOR_SOURCE_SUBFOLDER}/jpge.h ${JPEGCOMPRESSOR_SOURCE_SUBFOLDER}/jpge.h) -add_library(jpge ${JPGE_SRC_LIST} ${JPGE_HDR_LIST}) -target_include_directories(jpge PUBLIC ${JPEGCOMPRESSOR_SOURCE_SUBFOLDER}) - -install(TARGETS jpge) -install(FILES ${JPGE_HDR_LIST} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +# jpgd lib +set(JPGD_HDR_LIST ${JPEGCOMPRESSOR_SRC_DIR}/jpgd.h ${JPEGCOMPRESSOR_SRC_DIR}/jpgd_idct.h) +add_library(jpgd ${JPEGCOMPRESSOR_SRC_DIR}/jpgd.cpp) +target_include_directories(jpgd PUBLIC ${JPEGCOMPRESSOR_SRC_DIR}) +target_compile_features(jpgd PRIVATE cxx_std_11) + +# jpge lib +set(JPGE_HDR_LIST ${JPEGCOMPRESSOR_SRC_DIR}/jpge.h ${JPEGCOMPRESSOR_SRC_DIR}/jpge.h) +add_library(jpge ${JPEGCOMPRESSOR_SRC_DIR}/jpge.cpp) +target_include_directories(jpge PUBLIC ${JPEGCOMPRESSOR_SRC_DIR}) +target_compile_features(jpge PRIVATE cxx_std_11) + +include(GNUInstallDirs) +install( + TARGETS jpgd jpge + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install(FILES ${JPGD_HDR_LIST} ${JPGE_HDR_LIST} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/jpeg-compressor/all/conandata.yml b/recipes/jpeg-compressor/all/conandata.yml index cbbfa966a7ab4..5118d6cb5cb15 100644 --- a/recipes/jpeg-compressor/all/conandata.yml +++ b/recipes/jpeg-compressor/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "cci.20200507": - patch_file: "patches/pr-18-remove-include-malloc.patch" - base_path: "source_subfolder" diff --git a/recipes/jpeg-compressor/all/conanfile.py b/recipes/jpeg-compressor/all/conanfile.py index 14f61cf565274..da12e25b8e6e5 100644 --- a/recipes/jpeg-compressor/all/conanfile.py +++ b/recipes/jpeg-compressor/all/conanfile.py @@ -1,19 +1,23 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, save +from conan.tools.microsoft import is_msvc_static_runtime import os -import glob -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.53.0" class JpegCompressorConan(ConanFile): name = "jpeg-compressor" description = "C++ JPEG compression/fuzzed low-RAM JPEG decompression codec with Public Domain or Apache 2.0 license" homepage = "https://github.com/richgel999/jpeg-compressor" - topics = ("conan", "jpeg", "image", "compression", "decompression") + topics = ("jpeg", "image", "compression", "decompression") url = "https://github.com/conan-io/conan-center-index" license = "Unlicense", "Apache-2.0", "MIT" + settings = "os", "arch", "compiler", "build_type" - generators = "cmake" - exports_sources = ["CMakeLists.txt", "patches/*"] options = { "shared": [True, False], "fPIC": [True, False], @@ -23,15 +27,9 @@ class JpegCompressorConan(ConanFile): "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -39,30 +37,34 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - if self.settings.compiler == "Visual Studio" and "MT" in self.settings.compiler.runtime: - raise ConanInvalidConfiguration("Visual Studio build for shared library with MT runtime is not supported") + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.info.options.shared and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration("Visual Studio build for shared library with MT runtime is not supported") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob(self.name + "-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["JPEGCOMPRESSOR_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def _extract_license(self): - with open(os.path.join(self._source_subfolder, "jpge.cpp")) as f: + with open(os.path.join(self.source_folder, "jpge.cpp")) as f: content_lines = f.readlines() license_content = [] for i in range(4, 20): @@ -70,10 +72,9 @@ def _extract_license(self): return "\n".join(license_content) def package(self): - cmake = self._configure_cmake() + save(self, os.path.join(self.package_folder, "licenses", "LICENCE.txt"), self._extract_license()) + cmake = CMake(self) cmake.install() - self._extract_license() - tools.save(os.path.join(self.package_folder, "licenses", "LICENCE.txt"), self._extract_license()) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["jpgd", "jpge"] diff --git a/recipes/jpeg-compressor/all/test_package/CMakeLists.txt b/recipes/jpeg-compressor/all/test_package/CMakeLists.txt index 33ae887aa6aea..25752a9cef844 100644 --- a/recipes/jpeg-compressor/all/test_package/CMakeLists.txt +++ b/recipes/jpeg-compressor/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(jpeg-compressor REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE jpeg-compressor::jpeg-compressor) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/jpeg-compressor/all/test_package/conanfile.py b/recipes/jpeg-compressor/all/test_package/conanfile.py index 89b0e07ae49fe..ea70607af0172 100644 --- a/recipes/jpeg-compressor/all/test_package/conanfile.py +++ b/recipes/jpeg-compressor/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,7 +21,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") img_path = os.path.join(self.source_folder, "testimg.jpg") - bin_path = os.path.join("bin", "test_package") - self.run("{} {}".format(bin_path, img_path), run_environment=True) + self.run(f"{bin_path} {img_path}", env="conanrun") diff --git a/recipes/jpeg-compressor/all/test_v1_package/CMakeLists.txt b/recipes/jpeg-compressor/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/jpeg-compressor/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/jpeg-compressor/all/test_v1_package/conanfile.py b/recipes/jpeg-compressor/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..ff285a92f9ca9 --- /dev/null +++ b/recipes/jpeg-compressor/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + img_path = os.path.join(self.source_folder, os.pardir, "test_package", "testimg.jpg") + self.run(f"{bin_path} {img_path}", run_environment=True) diff --git a/recipes/json-c/all/CMakeLists.txt b/recipes/json-c/all/CMakeLists.txt deleted file mode 100644 index 1848ca5a77c35..0000000000000 --- a/recipes/json-c/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/json-c/all/conandata.yml b/recipes/json-c/all/conandata.yml index d60885496b2e3..7ed706059e17c 100644 --- a/recipes/json-c/all/conandata.yml +++ b/recipes/json-c/all/conandata.yml @@ -1,16 +1,10 @@ sources: - "0.13.1": - url: "https://github.com/json-c/json-c/archive/json-c-0.13.1-20180305.tar.gz" - sha256: "5d867baeb7f540abe8f3265ac18ed7a24f91fe3c5f4fd99ac3caba0708511b90" - "0.14": - url: "https://github.com/json-c/json-c/archive/json-c-0.14-20200419.tar.gz" - sha256: "ec4eb70e0f6c0d707b9b1ec646cf7c860f4abb3562a90ea6e4d78d177fd95303" + "0.16": + url: "https://github.com/json-c/json-c/archive/json-c-0.16-20220414.tar.gz" + sha256: "3ecaeedffd99a60b1262819f9e60d7d983844073abc74e495cb822b251904185" "0.15": url: "https://github.com/json-c/json-c/archive/json-c-0.15-20200726.tar.gz" sha256: "4ba9a090a42cf1e12b84c64e4464bb6fb893666841d5843cc5bef90774028882" -patches: - "0.13.1": - - patch_file: "patches/fix-cmake-0.13.1.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix-exported-symbols-0.13.1.patch" - base_path: "source_subfolder" + "0.14": + url: "https://github.com/json-c/json-c/archive/json-c-0.14-20200419.tar.gz" + sha256: "ec4eb70e0f6c0d707b9b1ec646cf7c860f4abb3562a90ea6e4d78d177fd95303" diff --git a/recipes/json-c/all/conanfile.py b/recipes/json-c/all/conanfile.py index ee89c2f09763c..7bdf4d8251e6d 100644 --- a/recipes/json-c/all/conanfile.py +++ b/recipes/json-c/all/conanfile.py @@ -1,85 +1,72 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import collect_libs, copy, get, rmdir +from conan.tools.scm import Version import os +required_conan_version = ">=1.53.0" + class JSONCConan(ConanFile): name = "json-c" description = "JSON-C - A JSON implementation in C" - topics = ("conan", "json-c", "json", "encoding", "decoding", "manipulation") + topics = ("json-c", "json", "encoding", "decoding", "manipulation") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/json-c/json-c" license = "MIT" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], - "fPIC": [True, False] + "fPIC": [True, False], } default_options = { "shared": False, - "fPIC": True + "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - url = self.conan_data["sources"][self.version]["url"] - extracted_dir = self.name + "-" + url[url.rfind("/")+1:url.find(".tar.gz")] - os.rename(extracted_dir, self._source_subfolder) + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - if self._cmake: - return self._cmake - - if tools.Version(self.version) <= "0.13.1" and \ - tools.cross_building(self.settings) and self.settings.os != "Windows": - host = tools.get_gnu_triplet(str(self.settings.os), str(self.settings.arch)) - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "execute_process(COMMAND ./configure ", - "execute_process(COMMAND ./configure --host %s " % host) - - self._cmake = CMake(self) - - if tools.Version(self.version) >= "0.15": - self._cmake.definitions["BUILD_STATIC_LIBS"] = not self.options.shared - self._cmake.definitions["DISABLE_STATIC_FPIC"] = not self.options.get_safe("fPIC", True) - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) >= "0.15": + tc.variables["BUILD_STATIC_LIBS"] = not self.options.shared + tc.variables["DISABLE_STATIC_FPIC"] = not self.options.get_safe("fPIC", True) + # To install relocatable shared libs on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - self.cpp_info.names["cmake_find_package"] = "json-c" - self.cpp_info.names["cmake_find_package_multi"] = "json-c" - self.cpp_info.names["pkg_config"] = "json-c" + self.cpp_info.set_property("cmake_file_name", "json-c") + self.cpp_info.set_property("cmake_target_name", "json-c::json-c") + self.cpp_info.set_property("pkg_config_name", "json-c") + self.cpp_info.libs = collect_libs(self) diff --git a/recipes/json-c/all/patches/fix-cmake-0.13.1.patch b/recipes/json-c/all/patches/fix-cmake-0.13.1.patch deleted file mode 100644 index 2af22f1d39174..0000000000000 --- a/recipes/json-c/all/patches/fix-cmake-0.13.1.patch +++ /dev/null @@ -1,47 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 5e828ab..8ff05d6 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -66,9 +66,11 @@ set(JSON_C_PUBLIC_HEADERS - ./json_c_version.h - ./json_inttypes.h - ./json_object.h -+ ./json_object_iterator.h - ./json_pointer.h - ./json_tokener.h - ./json_util.h -+ ./json_visit.h - ./linkhash.h - ./printbuf.h - ) -@@ -101,22 +103,12 @@ set(JSON_C_SOURCES - ) - - add_library(json-c -- SHARED - ${JSON_C_SOURCES} - ${JSON_C_HEADERS} - ) -- --add_library(json-c-static -- STATIC -- ${JSON_C_SOURCES} -- ${JSON_C_HEADERS} --) -- - set_property(TARGET json-c PROPERTY C_STANDARD 99) --set_property(TARGET json-c-static PROPERTY C_STANDARD 99) --set_target_properties(json-c-static PROPERTIES OUTPUT_NAME json-c) - --install(TARGETS json-c json-c-static -+install(TARGETS json-c - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -@@ -132,5 +124,5 @@ if (UNIX) - set(VERSION ${PROJECT_VERSION}) - configure_file(json-c.pc.in json-c.pc @ONLY) - set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") -- install(FILES ${CMAKE_BINARY_DIR}/json-c.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}") -+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/json-c.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}") - endif () diff --git a/recipes/json-c/all/patches/fix-exported-symbols-0.13.1.patch b/recipes/json-c/all/patches/fix-exported-symbols-0.13.1.patch deleted file mode 100644 index 2d0505b53b41d..0000000000000 --- a/recipes/json-c/all/patches/fix-exported-symbols-0.13.1.patch +++ /dev/null @@ -1,355 +0,0 @@ ---- a/debug.h -+++ b/debug.h -@@ -23,14 +23,22 @@ - extern "C" { - #endif - --extern void mc_set_debug(int debug); --extern int mc_get_debug(void); -+#ifndef JSON_EXPORT -+#if defined(_MSC_VER) -+#define JSON_EXPORT __declspec(dllexport) -+#else -+#define JSON_EXPORT extern -+#endif -+#endif -+ -+JSON_EXPORT void mc_set_debug(int debug); -+JSON_EXPORT int mc_get_debug(void); - --extern void mc_set_syslog(int syslog); -+JSON_EXPORT void mc_set_syslog(int syslog); - --extern void mc_debug(const char *msg, ...); --extern void mc_error(const char *msg, ...); --extern void mc_info(const char *msg, ...); -+JSON_EXPORT void mc_debug(const char *msg, ...); -+JSON_EXPORT void mc_error(const char *msg, ...); -+JSON_EXPORT void mc_info(const char *msg, ...); - - #ifndef __STRING - #define __STRING(x) #x ---- a/json_c_version.h -+++ b/json_c_version.h -@@ -20,11 +20,19 @@ - JSON_C_MICRO_VERSION) - #define JSON_C_VERSION "0.13.1" - -+#ifndef JSON_EXPORT -+#if defined(_MSC_VER) -+#define JSON_EXPORT __declspec(dllexport) -+#else -+#define JSON_EXPORT extern -+#endif -+#endif -+ - /** - * @see JSON_C_VERSION - * @return the version of the json-c library as a string - */ --const char *json_c_version(void); /* Returns JSON_C_VERSION */ -+JSON_EXPORT const char *json_c_version(void); /* Returns JSON_C_VERSION */ - - /** - * The json-c version encoded into an int, with the low order 8 bits -@@ -35,6 +43,6 @@ const char *json_c_version(void); /* Returns JSON_C_VERSION */ - * @see JSON_C_VERSION_NUM - * @return the version of the json-c library as an int - */ --int json_c_version_num(void); /* Returns JSON_C_VERSION_NUM */ -+JSON_EXPORT int json_c_version_num(void); /* Returns JSON_C_VERSION_NUM */ - - #endif ---- a/json_object.h -+++ b/json_object.h -@@ -33,12 +33,6 @@ - #define JSON_C_CONST_FUNCTION(func) func - #endif - --#if defined(_MSC_VER) --#define JSON_EXPORT __declspec(dllexport) --#else --#define JSON_EXPORT extern --#endif -- - #include - #include "json_inttypes.h" - #include "printbuf.h" -@@ -828,7 +822,7 @@ JSON_EXPORT struct json_object* json_object_new_double_s(double d, const char *d - * - * @return -1 on errors, 0 on success. - */ --int json_c_set_serialization_double_format(const char *double_format, int global_or_thread); -+JSON_EXPORT int json_c_set_serialization_double_format(const char *double_format, int global_or_thread); - - - ---- a/json_object_iterator.h -+++ b/json_object_iterator.h -@@ -26,6 +26,14 @@ - - #include - -+#ifndef JSON_EXPORT -+#if defined(_MSC_VER) -+#define JSON_EXPORT __declspec(dllexport) -+#else -+#define JSON_EXPORT extern -+#endif -+#endif -+ - #ifdef __cplusplus - extern "C" { - #endif -@@ -72,7 +80,7 @@ struct json_object; - * - * @return json_object_iterator - */ --struct json_object_iterator -+JSON_EXPORT struct json_object_iterator - json_object_iter_init_default(void); - - /** Retrieves an iterator to the first pair of the JSON Object. -@@ -106,7 +114,7 @@ json_object_iter_init_default(void); - * - * @endcode - */ --struct json_object_iterator -+JSON_EXPORT struct json_object_iterator - json_object_iter_begin(struct json_object* obj); - - /** Retrieves the iterator that represents the position beyond the -@@ -137,7 +145,7 @@ json_object_iter_begin(struct json_object* obj); - * (i.e., NOT the last pair, but "beyond the last - * pair" value) - */ --struct json_object_iterator -+JSON_EXPORT struct json_object_iterator - json_object_iter_end(const struct json_object* obj); - - /** Returns an iterator to the next pair, if any -@@ -155,7 +163,7 @@ json_object_iter_end(const struct json_object* obj); - * of json_object_iter_end() for the same JSON Object - * instance. - */ --void -+JSON_EXPORT void - json_object_iter_next(struct json_object_iterator* iter); - - -@@ -174,7 +182,7 @@ json_object_iter_next(struct json_object_iterator* iter); - * deleted or modified, and MUST NOT be modified or - * freed by the user. - */ --const char* -+JSON_EXPORT const char* - json_object_iter_peek_name(const struct json_object_iterator* iter); - - -@@ -197,7 +205,7 @@ json_object_iter_peek_name(const struct json_object_iterator* iter); - * the JSON Null value as a NULL json_object instance - * pointer. - */ --struct json_object* -+JSON_EXPORT struct json_object* - json_object_iter_peek_value(const struct json_object_iterator* iter); - - -@@ -227,7 +235,7 @@ json_object_iter_peek_value(const struct json_object_iterator* iter); - * reference the same name/value pair or are both at - * "end"); zero if they are not equal. - */ --json_bool -+JSON_EXPORT json_bool - json_object_iter_equal(const struct json_object_iterator* iter1, - const struct json_object_iterator* iter2); - ---- a/json_pointer.h -+++ b/json_pointer.h -@@ -44,7 +44,7 @@ extern "C" { - * - * @return negative if an error (or not found), or 0 if succeeded - */ --int json_pointer_get(struct json_object *obj, const char *path, struct json_object **res); -+JSON_EXPORT int json_pointer_get(struct json_object *obj, const char *path, struct json_object **res); - - /** - * This is a variant of 'json_pointer_get()' that supports printf() style arguments. -@@ -62,7 +62,7 @@ int json_pointer_get(struct json_object *obj, const char *path, struct json_obje - * - * @return negative if an error (or not found), or 0 if succeeded - */ --int json_pointer_getf(struct json_object *obj, struct json_object **res, const char *path_fmt, ...); -+JSON_EXPORT int json_pointer_getf(struct json_object *obj, struct json_object **res, const char *path_fmt, ...); - - /** - * Sets JSON object 'value' in the 'obj' tree at the location specified -@@ -93,7 +93,7 @@ int json_pointer_getf(struct json_object *obj, struct json_object **res, const c - * - * @return negative if an error (or not found), or 0 if succeeded - */ --int json_pointer_set(struct json_object **obj, const char *path, struct json_object *value); -+JSON_EXPORT int json_pointer_set(struct json_object **obj, const char *path, struct json_object *value); - - /** - * This is a variant of 'json_pointer_set()' that supports printf() style arguments. -@@ -110,7 +110,7 @@ int json_pointer_set(struct json_object **obj, const char *path, struct json_obj - * - * @return negative if an error (or not found), or 0 if succeeded - */ --int json_pointer_setf(struct json_object **obj, struct json_object *value, const char *path_fmt, ...); -+JSON_EXPORT int json_pointer_setf(struct json_object **obj, struct json_object *value, const char *path_fmt, ...); - - - #ifdef __cplusplus ---- a/json_tokener.h -+++ b/json_tokener.h -@@ -113,7 +113,7 @@ typedef struct json_tokener json_tokener; - * - * @return a generic error message is returned if an invalid error value is provided. - */ --const char *json_tokener_error_desc(enum json_tokener_error jerr); -+JSON_EXPORT const char *json_tokener_error_desc(enum json_tokener_error jerr); - - /** - * Retrieve the error caused by the last call to json_tokener_parse_ex(), ---- a/json_util.h -+++ b/json_util.h -@@ -40,7 +40,7 @@ extern "C" { - * - * Returns -1 if something fails. See json_util_get_last_err() for details. - */ --extern struct json_object* json_object_from_file(const char *filename); -+JSON_EXPORT struct json_object* json_object_from_file(const char *filename); - - /** - * Create a JSON object from already opened file descriptor. -@@ -52,7 +52,7 @@ extern struct json_object* json_object_from_file(const char *filename); - * - * Returns -1 if something fails. See json_util_get_last_err() for details. - */ --extern struct json_object* json_object_from_fd(int fd); -+JSON_EXPORT struct json_object* json_object_from_fd(int fd); - - /** - * Equivalent to: -@@ -60,7 +60,7 @@ extern struct json_object* json_object_from_fd(int fd); - * - * Returns -1 if something fails. See json_util_get_last_err() for details. - */ --extern int json_object_to_file(const char *filename, struct json_object *obj); -+JSON_EXPORT int json_object_to_file(const char *filename, struct json_object *obj); - - /** - * Open and truncate the given file, creating it if necessary, then -@@ -68,7 +68,7 @@ extern int json_object_to_file(const char *filename, struct json_object *obj); - * - * Returns -1 if something fails. See json_util_get_last_err() for details. - */ --extern int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags); -+JSON_EXPORT int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags); - - /** - * Convert the json_object to a string and write it to the file descriptor. -@@ -80,24 +80,24 @@ extern int json_object_to_file_ext(const char *filename, struct json_object *obj - * @param flags flags to pass to json_object_to_json_string_ext() - * @return -1 if something fails. See json_util_get_last_err() for details. - */ --extern int json_object_to_fd(int fd, struct json_object *obj, int flags); -+JSON_EXPORT int json_object_to_fd(int fd, struct json_object *obj, int flags); - - /** - * Return the last error from various json-c functions, including: - * json_object_to_file{,_ext}, json_object_to_fd() or - * json_object_from_{file,fd}, or NULL if there is none. - */ --const char *json_util_get_last_err(void); -+JSON_EXPORT const char *json_util_get_last_err(void); - - --extern int json_parse_int64(const char *buf, int64_t *retval); --extern int json_parse_double(const char *buf, double *retval); -+JSON_EXPORT int json_parse_int64(const char *buf, int64_t *retval); -+JSON_EXPORT int json_parse_double(const char *buf, double *retval); - - /** - * Return a string describing the type of the object. - * e.g. "int", or "object", etc... - */ --extern const char *json_type_to_name(enum json_type o_type); -+JSON_EXPORT const char *json_type_to_name(enum json_type o_type); - - #ifdef __cplusplus - } ---- a/json_visit.h -+++ b/json_visit.h -@@ -31,7 +31,7 @@ typedef int (json_c_visit_userfunc)(json_object *jso, int flags, - * Returns <0 if an error occurred during iteration, including if - * userfunc returned JSON_C_VISIT_RETURN_ERROR. - */ --int json_c_visit(json_object *jso, int future_flags, -+JSON_EXPORT int json_c_visit(json_object *jso, int future_flags, - json_c_visit_userfunc *userfunc, void *userarg); - - /** ---- a/printbuf.h -+++ b/printbuf.h -@@ -23,6 +23,14 @@ - #ifndef _printbuf_h_ - #define _printbuf_h_ - -+#ifndef JSON_EXPORT -+#if defined(_MSC_VER) -+#define JSON_EXPORT __declspec(dllexport) -+#else -+#define JSON_EXPORT extern -+#endif -+#endif -+ - #ifdef __cplusplus - extern "C" { - #endif -@@ -34,7 +42,7 @@ struct printbuf { - }; - typedef struct printbuf printbuf; - --extern struct printbuf* -+JSON_EXPORT struct printbuf* - printbuf_new(void); - - /* As an optimization, printbuf_memappend_fast() is defined as a macro -@@ -45,7 +53,7 @@ printbuf_new(void); - * Your code should not use printbuf_memappend() directly unless it - * checks the return code. Use printbuf_memappend_fast() instead. - */ --extern int -+JSON_EXPORT int - printbuf_memappend(struct printbuf *p, const char *buf, int size); - - #define printbuf_memappend_fast(p, bufptr, bufsize) \ -@@ -89,7 +97,7 @@ do { \ - * - * If offset is -1, this starts at the end of the current data in the buffer. - */ --extern int -+JSON_EXPORT int - printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len); - - /** -@@ -106,13 +114,13 @@ printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len); - * printbuf_memappend() - * printbuf_strappend() - */ --extern int -+JSON_EXPORT int - sprintbuf(struct printbuf *p, const char *msg, ...); - --extern void -+JSON_EXPORT void - printbuf_reset(struct printbuf *p); - --extern void -+JSON_EXPORT void - printbuf_free(struct printbuf *p); - - #ifdef __cplusplus diff --git a/recipes/json-c/all/test_package/CMakeLists.txt b/recipes/json-c/all/test_package/CMakeLists.txt index 7b9b613cbb24a..5e91efdaa1c1c 100644 --- a/recipes/json-c/all/test_package/CMakeLists.txt +++ b/recipes/json-c/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(json-c REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE json-c::json-c) diff --git a/recipes/json-c/all/test_package/conanfile.py b/recipes/json-c/all/test_package/conanfile.py index bd7165a553cf4..0a6bc68712d90 100644 --- a/recipes/json-c/all/test_package/conanfile.py +++ b/recipes/json-c/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/json-c/all/test_v1_package/CMakeLists.txt b/recipes/json-c/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/json-c/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/json-c/all/test_v1_package/conanfile.py b/recipes/json-c/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/json-c/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/json-c/config.yml b/recipes/json-c/config.yml index c93465c6a9dcc..1e4023fe84046 100644 --- a/recipes/json-c/config.yml +++ b/recipes/json-c/config.yml @@ -1,7 +1,7 @@ versions: - "0.13.1": - folder: all - "0.14": + "0.16": folder: all "0.15": folder: all + "0.14": + folder: all diff --git a/recipes/json-schema-validator/all/conandata.yml b/recipes/json-schema-validator/all/conandata.yml index 30fb02cdd148b..122476811e03f 100644 --- a/recipes/json-schema-validator/all/conandata.yml +++ b/recipes/json-schema-validator/all/conandata.yml @@ -1,7 +1,24 @@ sources: + "2.2.0": + url: "https://github.com/pboettch/json-schema-validator/archive/refs/tags/2.2.0.tar.gz" + sha256: "03897867bd757ecac1db7545babf0c6c128859655b496582a9cea4809c2260aa" + "2.1.0": + url: "https://github.com/pboettch/json-schema-validator/archive/refs/tags/2.1.0.tar.gz" + sha256: "83f61d8112f485e0d3f1e72d51610ba3924b179926a8376aef3c038770faf202" "2.0.0": - url: "https://github.com/pboettch/json-schema-validator/archive/2.0.0.zip" - sha256: "8fddec7248581e2899b3543ae2cd1a0ae682f54e6866db999577627f230a6f1f" + url: "https://github.com/pboettch/json-schema-validator/archive/refs/tags/2.0.0.tar.gz" + sha256: "ca8e4ca5a88c49ea52b5f5c2a08a293dbf02b2fc66cb8c09d4cce5810ee98b57" +patches: + "2.2.0": + - patch_file: "patches/2.2.0-signed-char.patch" + patch_type: "portability" + patch_description: "Fix for PowerPC and ARM" + patch_source: "https://github.com/pboettch/json-schema-validator/pull/242" "2.1.0": - url: "https://github.com/pboettch/json-schema-validator/archive/2.1.0.zip" - sha256: "b94e09509e837e2d6db82190f3a6c7db67a2073b22f29e95030918ba15bcdb4e" + - patch_file: "patches/2.1.0-cmake_minimum_version.patch" + patch_type: "conan" + patch_description: "CMake: cmake_minimum_version() before project()" + "2.0.0": + - patch_file: "patches/2.0.0-cmake_minimum_version.patch" + patch_type: "conan" + patch_description: "CMake: cmake_minimum_version() before project()" diff --git a/recipes/json-schema-validator/all/conanfile.py b/recipes/json-schema-validator/all/conanfile.py index 74f12a6e5a1df..c9901f8fafff9 100644 --- a/recipes/json-schema-validator/all/conanfile.py +++ b/recipes/json-schema-validator/all/conanfile.py @@ -1,6 +1,11 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import build, files, microsoft, scm +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout import os +import textwrap + +required_conan_version = ">=1.53.0" class JsonSchemaValidatorConan(ConanFile): @@ -11,78 +16,121 @@ class JsonSchemaValidatorConan(ConanFile): description = "JSON schema validator for JSON for Modern C++ " topics = ("json-schema-validator", "modern-json", "schema-validation", "json") + settings = "os", "arch", "compiler", "build_type" - generators = "cmake" - exports_sources = ["CMakeLists.txt"] - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + short_paths = True - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + files.export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - version = tools.Version(self.version) + if self.options.shared: + self.options.rm_safe("fPIC") + + def requirements(self): + self.requires("nlohmann_json/3.11.2", transitive_headers=True) + + def validate(self): + version = scm.Version(self.version) min_vs_version = "16" if version < "2.1.0" else "14" - min_cppstd = "17" if self.settings.compiler == "Visual Studio" and version < "2.1.0" else "11" - if self.settings.get_safe("compiler.cppstd"): - tools.check_min_cppstd(self, min_cppstd) + min_cppstd = "17" if microsoft.is_msvc(self) and version < "2.1.0" else "11" + if self.info.settings.get_safe("compiler.cppstd"): + build.check_min_cppstd(self, min_cppstd) min_vs_version = "15" if version < "2.1.0" else "14" compilers = { "Visual Studio": min_vs_version, - "gcc": "5", + "gcc": "5" if version < "2.1.0" else "4.9", "clang": "4", "apple-clang": "9"} - min_version = compilers.get(str(self.settings.compiler)) + min_version = compilers.get(str(self.info.settings.compiler)) if not min_version: - self.output.warn("{} recipe lacks information about the {} compiler support.".format( - self.name, self.settings.compiler)) + self.output.warn(f"{self.name} recipe lacks information about the {self.info.settings.compiler} compiler support.") else: - if tools.Version(self.settings.compiler.version) < min_version: - raise ConanInvalidConfiguration("{} requires c++{} support. The current compiler {} {} does not support it.".format( - self.name, min_cppstd, self.settings.compiler, self.settings.compiler.version)) + if scm.Version(self.info.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration(f"{self.name} requires c++{min_cppstd} support. The current compiler {self.info.settings.compiler} {self.info.settings.compiler.version} does not support it.") - def requirements(self): - self.requires("nlohmann_json/3.9.1") + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + files.get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if scm.Version(self.version) < "2.2.0": + tc.variables["BUILD_TESTS"] = False + tc.variables["BUILD_EXAMPLES"] = False + else: + tc.variables["JSON_VALIDATOR_BUILD_TESTS"] = False + tc.variables["JSON_VALIDATOR_BUILD_EXAMPLES"] = False + if scm.Version(self.version) < "2.1.0": + tc.variables["NLOHMANN_JSON_DIR"] = ";".join(self.deps_cpp_info["nlohmann_json"].include_paths).replace("\\", "/") + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - cmake = self._configure_cmake() + files.apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(os.path.join("src", "json-schema.hpp"), dst=os.path.join("include", "nlohmann"), # This is not installed in 2.0.0 correctly - src=self._source_subfolder, keep_path=False) - cmake = self._configure_cmake() + files.copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + if scm.Version(self.version) < "2.1.0": + files.copy(self, "json-schema.hpp", + dst=os.path.join(self.package_folder, "include", "nlohmann"), + src=os.path.join(self.source_folder, "src")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"nlohmann_json_schema_validator": "nlohmann_json_schema_validator::nlohmann_json_schema_validator"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + files.save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "nlohmann_json_schema_validator") + self.cpp_info.set_property("cmake_target_name", "nlohmann_json_schema_validator") + self.cpp_info.libs = ["json-schema-validator" if scm.Version(self.version) < "2.1.0" else "nlohmann_json_schema_validator"] + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "nlohmann_json_schema_validator" self.cpp_info.names["cmake_find_package_multi"] = "nlohmann_json_schema_validator" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/json-schema-validator/all/patches/2.0.0-cmake_minimum_version.patch b/recipes/json-schema-validator/all/patches/2.0.0-cmake_minimum_version.patch new file mode 100644 index 0000000000000..511a6d5522051 --- /dev/null +++ b/recipes/json-schema-validator/all/patches/2.0.0-cmake_minimum_version.patch @@ -0,0 +1,15 @@ +--- a/CMakeLists.txt 2019-04-02 10:39:55.000000000 -0000 ++++ b/CMakeLists.txt 2022-11-07 17:09:53.295000000 -0000 +@@ -1,10 +1,10 @@ ++cmake_minimum_required(VERSION 3.2) ++ + project(json-schema-validator + LANGUAGES CXX) + + set(PROJECT_VERSION 2.0.0) + +-cmake_minimum_required(VERSION 3.2) +- + option(BUILD_TESTS "Build tests" ON) + option(BUILD_EXAMPLES "Build examples" ON) + diff --git a/recipes/json-schema-validator/all/patches/2.1.0-cmake_minimum_version.patch b/recipes/json-schema-validator/all/patches/2.1.0-cmake_minimum_version.patch new file mode 100644 index 0000000000000..7936e2adcfe40 --- /dev/null +++ b/recipes/json-schema-validator/all/patches/2.1.0-cmake_minimum_version.patch @@ -0,0 +1,15 @@ +--- a/CMakeLists.txt 2020-05-15 09:04:12.000000000 -0000 ++++ b/CMakeLists.txt 2022-11-07 16:57:29.655000000 -0000 +@@ -1,10 +1,10 @@ ++cmake_minimum_required(VERSION 3.2) ++ + project(nlohmann_json_schema_validator + LANGUAGES CXX) + + set(PROJECT_VERSION 2.1.0) + +-cmake_minimum_required(VERSION 3.2) +- + option(BUILD_TESTS "Build tests" ON) + option(BUILD_EXAMPLES "Build examples" ON) + diff --git a/recipes/json-schema-validator/all/patches/2.2.0-signed-char.patch b/recipes/json-schema-validator/all/patches/2.2.0-signed-char.patch new file mode 100644 index 0000000000000..ffea4bf7ef2e7 --- /dev/null +++ b/recipes/json-schema-validator/all/patches/2.2.0-signed-char.patch @@ -0,0 +1,64 @@ +From 3918616faf989fcf4a9206a34e3b87c23642a96a Mon Sep 17 00:00:00 2001 +From: Robert Joslyn +Date: Wed, 30 Nov 2022 13:07:29 -0800 +Subject: [PATCH] Fix assumed signed char + +The code assumes that char is signed, but whether char is signed or +unsigned is implementation defined. On some architectures like PowerPC, +GCC treats char as unsigned resulting in compile errors: + + smtp-address-validator.cpp:213:1: error: narrowing conversion of '-32' from 'int' to 'char' [-Wnarrowing] + +Fix this by specifying signed char. +--- + src/smtp-address-validator.cpp | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/src/smtp-address-validator.cpp b/src/smtp-address-validator.cpp +index a63ead0..3903b51 100644 +--- a/src/smtp-address-validator.cpp ++++ b/src/smtp-address-validator.cpp +@@ -63,7 +63,7 @@ static const short _address_key_offsets[] = { + 1363, 1365, 1367, 1368, 1370, 1388, 0 + }; + +-static const char _address_trans_keys[] = { ++static const signed char _address_trans_keys[] = { + -32, -19, -16, -12, 34, 45, 61, 63, + -62, -33, -31, -17, -15, -13, 33, 39, + 42, 43, 47, 57, 65, 90, 94, 126, +@@ -711,7 +711,7 @@ bool is_address(const char* p, const char* pe) + { + int _klen; + unsigned int _trans = 0; +- const char * _keys; ++ const signed char * _keys; + const signed char * _acts; + unsigned int _nacts; + _resume: {} +@@ -728,9 +728,9 @@ bool is_address(const char* p, const char* pe) + + _klen = (int)_address_single_lengths[cs]; + if ( _klen > 0 ) { +- const char *_lower = _keys; +- const char *_upper = _keys + _klen - 1; +- const char *_mid; ++ const signed char *_lower = _keys; ++ const signed char *_upper = _keys + _klen - 1; ++ const signed char *_mid; + while ( 1 ) { + if ( _upper < _lower ) { + _keys += _klen; +@@ -752,9 +752,9 @@ bool is_address(const char* p, const char* pe) + + _klen = (int)_address_range_lengths[cs]; + if ( _klen > 0 ) { +- const char *_lower = _keys; +- const char *_upper = _keys + (_klen<<1) - 2; +- const char *_mid; ++ const signed char *_lower = _keys; ++ const signed char *_upper = _keys + (_klen<<1) - 2; ++ const signed char *_mid; + while ( 1 ) { + if ( _upper < _lower ) { + _trans += (unsigned int)_klen; diff --git a/recipes/json-schema-validator/all/test_package/CMakeLists.txt b/recipes/json-schema-validator/all/test_package/CMakeLists.txt index dfa84881e88e8..c2d764c121782 100644 --- a/recipes/json-schema-validator/all/test_package/CMakeLists.txt +++ b/recipes/json-schema-validator/all/test_package/CMakeLists.txt @@ -1,12 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(nlohmann_json_schema_validator CONFIG REQUIRED) -add_executable(example example.cpp) -set_property(TARGET example PROPERTY CXX_STANDARD 11) - -target_link_libraries(example nlohmann_json_schema_validator::nlohmann_json_schema_validator) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} nlohmann_json_schema_validator) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/json-schema-validator/all/test_package/conanfile.py b/recipes/json-schema-validator/all/test_package/conanfile.py index 8bfedcbb6bb7e..e845ae751a301 100644 --- a/recipes/json-schema-validator/all/test_package/conanfile.py +++ b/recipes/json-schema-validator/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os -class JsonSchemaValidatorTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/json-schema-validator/all/test_package/example.cpp b/recipes/json-schema-validator/all/test_package/test_package.cpp similarity index 100% rename from recipes/json-schema-validator/all/test_package/example.cpp rename to recipes/json-schema-validator/all/test_package/test_package.cpp diff --git a/recipes/json-schema-validator/all/test_v1_package/CMakeLists.txt b/recipes/json-schema-validator/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/json-schema-validator/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/json-schema-validator/all/test_v1_package/conanfile.py b/recipes/json-schema-validator/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/json-schema-validator/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/json-schema-validator/config.yml b/recipes/json-schema-validator/config.yml index b3fb547334cde..ddf20dd4ca819 100644 --- a/recipes/json-schema-validator/config.yml +++ b/recipes/json-schema-validator/config.yml @@ -1,5 +1,7 @@ versions: - "2.0.0": - folder: all - "2.1.0": - folder: all + "2.2.0": + folder: all + "2.1.0": + folder: all + "2.0.0": + folder: all diff --git a/recipes/json_dto/all/conandata.yml b/recipes/json_dto/all/conandata.yml index 8632ddcf4c68e..3d6e5b35876d7 100644 --- a/recipes/json_dto/all/conandata.yml +++ b/recipes/json_dto/all/conandata.yml @@ -5,3 +5,18 @@ sources: "0.2.12": url: "https://github.com/Stiffstream/json_dto/archive/v.0.2.12.tar.gz" sha256: "3b1ca412a74c339c01bcbf739542fa69b2391d24c321742098a2d6dfa7402d84" + "0.2.13": + url: "https://github.com/Stiffstream/json_dto/archive/v.0.2.13.tar.gz" + sha256: "ed4138bf86e0724c95508a9c74bed6fa0c98814b96f4cb3a1b540857e2302663" + "0.2.14": + url: "https://github.com/Stiffstream/json_dto/archive/v.0.2.14.tar.gz" + sha256: "d885fe16cf621f7470a45fb6e955e8aded02958bb2212819dc151feac930905b" + "0.2.15": + url: "https://github.com/Stiffstream/json_dto/archive/v.0.2.15.tar.gz" + sha256: "d7631d21785ddddc81b2fe04a7998d0d49323c2224168568cb80cc32093da3ac" + "0.3.0": + url: "https://github.com/Stiffstream/json_dto/archive/v.0.3.0.tar.gz" + sha256: "cd497c9ee5556c45aaa3402a23ab935e6a90c1e62076562efd0708d1ec8f4c30" + "0.3.1": + url: "https://github.com/Stiffstream/json_dto/archive/v.0.3.1.tar.gz" + sha256: "515a2d1510d3d8f8b240eb2149f44aeb47a70d26a7071609cca45c0ee198d1d1" diff --git a/recipes/json_dto/all/conanfile.py b/recipes/json_dto/all/conanfile.py index 4a68e74cb23ff..ee89f2d2edf51 100644 --- a/recipes/json_dto/all/conanfile.py +++ b/recipes/json_dto/all/conanfile.py @@ -2,6 +2,9 @@ from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.43.0" + + class JsondtoConan(ConanFile): name = "json_dto" license = "BSD-3-Clause" @@ -9,26 +12,19 @@ class JsondtoConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" description = "A small header-only helper for converting data between json representation and c++ structs" topics = ("json", "dto", "serialization") - generators = "cmake" settings = "os", "compiler", "build_type", "arch" no_copy_source = True - _cmake = None - @property def _source_subfolder(self): return "source_subfolder" - @property - def _build_subfolder(self): - return "build_subfolder" - def requirements(self): self.requires("rapidjson/1.1.0") - def configure(self): + def validate(self): minimal_cpp_standard = "14" - if self.settings.compiler.cppstd: + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, minimal_cpp_standard) minimal_version = { "gcc": "5", @@ -42,34 +38,30 @@ def configure(self): "%s recipe lacks information about the %s compiler standard version support" % (self.name, compiler)) self.output.warn( "%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) - return - - version = tools.Version(self.settings.compiler.version) - if version < minimal_version[compiler]: + elif tools.Version(self.settings.compiler.version) < minimal_version[compiler]: raise ConanInvalidConfiguration("%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) + if self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) >= "11": + raise ConanInvalidConfiguration(f"{self.name} requires apple-clang less then version 11") - def _configure_cmake(self): - if self._cmake: - return self._cmake - - self._cmake = CMake(self) - self._cmake.definitions["JSON_DTO_INSTALL"] = True - self._cmake.definitions["JSON_DTO_FIND_DEPS"] = False - self._cmake.configure(source_folder=os.path.join(self._source_subfolder, "dev", "json_dto")) - return self._cmake + def package_id(self): + self.info.header_only() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-v." + self.version - os.rename(extracted_dir, self._source_subfolder ) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.definitions["JSON_DTO_INSTALL"] = True + cmake.definitions["JSON_DTO_FIND_DEPS"] = False + cmake.configure(source_folder=os.path.join(self._source_subfolder, "dev", "json_dto")) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "json-dto") + self.cpp_info.set_property("cmake_target_name", "json-dto::json-dto") + self.cpp_info.names["cmake_find_package"] = "json-dto" + self.cpp_info.names["cmake_find_package_multi"] = "json-dto" diff --git a/recipes/json_dto/all/test_package/CMakeLists.txt b/recipes/json_dto/all/test_package/CMakeLists.txt index 1b38e141c618f..45401a5b844ae 100644 --- a/recipes/json_dto/all/test_package/CMakeLists.txt +++ b/recipes/json_dto/all/test_package/CMakeLists.txt @@ -1,15 +1,11 @@ -cmake_minimum_required(VERSION 3.8) - -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - +cmake_minimum_required(VERSION 3.1) project(PackageTest CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -find_package(json_dto REQUIRED) +find_package(json-dto REQUIRED CONFIG) add_executable(example example.cpp) -target_link_libraries(example json_dto::json_dto) +target_link_libraries(example json-dto::json-dto) +set_property(TARGET example PROPERTY CXX_STANDARD 14) diff --git a/recipes/json_dto/all/test_package/conanfile.py b/recipes/json_dto/all/test_package/conanfile.py index 3d9c6e64e76d4..21d7adcc4bb1c 100644 --- a/recipes/json_dto/all/test_package/conanfile.py +++ b/recipes/json_dto/all/test_package/conanfile.py @@ -5,7 +5,7 @@ class JsondtoTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) diff --git a/recipes/json_dto/config.yml b/recipes/json_dto/config.yml index 4fe3ee34b95ee..464caddcd4136 100644 --- a/recipes/json_dto/config.yml +++ b/recipes/json_dto/config.yml @@ -3,3 +3,13 @@ versions: folder: all "0.2.12": folder: all + "0.2.13": + folder: all + "0.2.14": + folder: all + "0.2.15": + folder: all + "0.3.0": + folder: all + "0.3.1": + folder: all diff --git a/recipes/jsoncpp/all/CMakeLists.txt b/recipes/jsoncpp/all/CMakeLists.txt deleted file mode 100644 index 12f87e5b95400..0000000000000 --- a/recipes/jsoncpp/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/jsoncpp/all/conandata.yml b/recipes/jsoncpp/all/conandata.yml index bc01a0840f287..b5b4f5372dd99 100644 --- a/recipes/jsoncpp/all/conandata.yml +++ b/recipes/jsoncpp/all/conandata.yml @@ -1,33 +1,30 @@ sources: - "1.8.3": - url: https://github.com/open-source-parsers/jsoncpp/archive/1.8.3.tar.gz - sha256: 3671ba6051e0f30849942cc66d1798fdf0362d089343a83f704c09ee7156604f - "1.9.1": - url: https://github.com/open-source-parsers/jsoncpp/archive/1.9.1.tar.gz - sha256: c7b40f5605dd972108f503f031b20186f5e5bca2b65cd4b8bd6c3e4ba8126697 - "1.9.2": - url: https://github.com/open-source-parsers/jsoncpp/archive/1.9.2.tar.gz - sha256: 77a402fb577b2e0e5d0bdc1cf9c65278915cdb25171e3452c68b6da8a561f8f0 - "1.9.3": - url: https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz - sha256: 8593c1d69e703563d94d8c12244e2e18893eeb9a8a9f8aa3d09a327aa45c8f7d + "1.9.5": + url: https://github.com/open-source-parsers/jsoncpp/archive/1.9.5.tar.gz + sha256: f409856e5920c18d0c2fb85276e24ee607d2a09b5e7d5f0a371368903c275da2 "1.9.4": url: https://github.com/open-source-parsers/jsoncpp/archive/1.9.4.tar.gz sha256: e34a628a8142643b976c7233ef381457efad79468c67cb1ae0b83a33d7493999 -patches: - "1.8.3": - - patch_file: "patches/implicit-conversion-1.8.3.patch" - base_path: "source_subfolder" - "1.9.1": - - patch_file: "patches/implicit-conversion-1.9.1.patch" - base_path: "source_subfolder" - - patch_file: "patches/dont-force-pic-1.9.1.patch" - base_path: "source_subfolder" + "1.9.3": + url: https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz + sha256: 8593c1d69e703563d94d8c12244e2e18893eeb9a8a9f8aa3d09a327aa45c8f7d "1.9.2": - - patch_file: "patches/dont-force-pic-1.9.2.patch" - base_path: "source_subfolder" - - patch_file: "patches/no-examples.patch" - base_path: "source_subfolder" + url: https://github.com/open-source-parsers/jsoncpp/archive/1.9.2.tar.gz + sha256: 77a402fb577b2e0e5d0bdc1cf9c65278915cdb25171e3452c68b6da8a561f8f0 + "1.9.1": + url: https://github.com/open-source-parsers/jsoncpp/archive/1.9.1.tar.gz + sha256: c7b40f5605dd972108f503f031b20186f5e5bca2b65cd4b8bd6c3e4ba8126697 + "1.8.3": + url: https://github.com/open-source-parsers/jsoncpp/archive/1.8.3.tar.gz + sha256: 3671ba6051e0f30849942cc66d1798fdf0362d089343a83f704c09ee7156604f +patches: "1.9.3": - - patch_file: "patches/dont-force-pic-1.9.3.patch" - base_path: "source_subfolder" + - patch_file: "patches/dont-force-pic-1.9.3.patch" + "1.9.2": + - patch_file: "patches/dont-force-pic-1.9.2.patch" + - patch_file: "patches/no-examples.patch" + "1.9.1": + - patch_file: "patches/implicit-conversion-1.9.1.patch" + - patch_file: "patches/dont-force-pic-1.9.1.patch" + "1.8.3": + - patch_file: "patches/implicit-conversion-1.8.3.patch" diff --git a/recipes/jsoncpp/all/conanfile.py b/recipes/jsoncpp/all/conanfile.py index adbdee2837411..99b1d8ec06857 100644 --- a/recipes/jsoncpp/all/conanfile.py +++ b/recipes/jsoncpp/all/conanfile.py @@ -1,26 +1,33 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, save +from conan.tools.scm import Version import os import textwrap +required_conan_version = ">=1.53.0" + class JsoncppConan(ConanFile): name = "jsoncpp" license = "MIT" homepage = "https://github.com/open-source-parsers/jsoncpp" url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "json", "parser", "config") + topics = ("json", "parser", "config") description = "A C++ library for interacting with JSON." - settings = "os", "compiler", "arch", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -28,95 +35,95 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "jsoncpp-{}".format(self.version) - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["JSONCPP_WITH_TESTS"] = False + tc.variables["JSONCPP_WITH_WARNING_AS_ERROR"] = False + tc.variables["JSONCPP_WITH_CMAKE_PACKAGE"] = False + tc.variables["JSONCPP_WITH_STRICT_ISO"] = False + tc.variables["JSONCPP_WITH_PKGCONFIG_SUPPORT"] = False + jsoncpp_version = Version(self.version) + if jsoncpp_version < "1.9.0" or jsoncpp_version >= "1.9.4": + tc.variables["BUILD_STATIC_LIBS"] = not self.options.shared + if jsoncpp_version >= "1.9.3": + tc.variables["JSONCPP_WITH_EXAMPLE"] = False + if jsoncpp_version >= "1.9.4": + tc.variables["BUILD_OBJECT_LIBS"] = False + if jsoncpp_version < "1.9.0": + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + # No opt-out of ccache + if Version(self.version) < "1.9.3": + tc.cache_variables["CCACHE_FOUND"] = "" + else: + tc.cache_variables["CCACHE_EXECUTABLE"] = "" + tc.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "${jsoncpp_SOURCE_DIR}", - "${JSONCPP_SOURCE_DIR}") + apply_conandata_patches(self) if self.settings.compiler == "Visual Studio" and self.settings.compiler.version == "11": - tools.replace_in_file(os.path.join(self._source_subfolder, "include", "json", "value.h"), + replace_in_file(self, os.path.join(self.source_folder, "include", "json", "value.h"), "explicit operator bool()", "operator bool()") - if tools.Version(self.version) >= "1.9.0": - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "lib_json", "CMakeLists.txt"), - "$", - "") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["JSONCPP_WITH_TESTS"] = False - self._cmake.definitions["JSONCPP_WITH_WARNING_AS_ERROR"] = False - self._cmake.definitions["JSONCPP_WITH_CMAKE_PACKAGE"] = False - self._cmake.definitions["JSONCPP_WITH_STRICT_ISO"] = False - self._cmake.definitions["JSONCPP_WITH_PKGCONFIG_SUPPORT"] = False - jsoncpp_version = tools.Version(self.version) - if jsoncpp_version < "1.9.0" or jsoncpp_version >= "1.9.4": - self._cmake.definitions["BUILD_STATIC_LIBS"] = not self.options.shared - if jsoncpp_version >= "1.9.3": - self._cmake.definitions["JSONCPP_WITH_EXAMPLE"] = False - if jsoncpp_version >= "1.9.4": - self._cmake.definitions["BUILD_OBJECT_LIBS"] = False - self._cmake.configure() - return self._cmake - def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() + + # TODO: to remove in conan v2 once legacy generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), { + "JsonCpp::JsonCpp": "jsoncpp::jsoncpp", # alias target since 1.9.5 "jsoncpp_lib": "jsoncpp::jsoncpp", # imported target for shared lib, but also static between 1.9.0 & 1.9.3 "jsoncpp_static": "jsoncpp::jsoncpp", # imported target for static lib if >= 1.9.4 "jsoncpp_lib_static": "jsoncpp::jsoncpp", # imported target for static lib if < 1.9.0 } ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + """) + save(self, module_file, content) @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.names["cmake_find_package"] = "jsoncpp" - self.cpp_info.names["cmake_find_package_multi"] = "jsoncpp" - self.cpp_info.names["pkg_config"] = "jsoncpp" - self.cpp_info.builddirs.append(self._module_subfolder) - self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] - self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "jsoncpp") + self.cpp_info.set_property("cmake_target_name", "JsonCpp::JsonCpp") + self.cpp_info.set_property( + "cmake_target_aliases", + ["jsoncpp_lib"] if self.options.shared else ["jsoncpp_lib", "jsoncpp_static", "jsoncpp_lib_static"], + ) + self.cpp_info.set_property("pkg_config_name", "jsoncpp") + self.cpp_info.libs = ["jsoncpp"] if self.settings.os == "Windows" and self.options.shared: self.cpp_info.defines.append("JSON_DLL") + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/jsoncpp/all/test_package/CMakeLists.txt b/recipes/jsoncpp/all/test_package/CMakeLists.txt index eca023731497a..3a610a43f2758 100644 --- a/recipes/jsoncpp/all/test_package/CMakeLists.txt +++ b/recipes/jsoncpp/all/test_package/CMakeLists.txt @@ -1,15 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(jsoncpp REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -if(JSONCPP_SHARED) - target_link_libraries(${PROJECT_NAME} jsoncpp_lib) -else() - target_link_libraries(${PROJECT_NAME} jsoncpp_static) -endif() -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE JsonCpp::JsonCpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/jsoncpp/all/test_package/conanfile.py b/recipes/jsoncpp/all/test_package/conanfile.py index 58624a29f8edc..0a6bc68712d90 100644 --- a/recipes/jsoncpp/all/test_package/conanfile.py +++ b/recipes/jsoncpp/all/test_package/conanfile.py @@ -1,18 +1,26 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) - cmake.definitions["JSONCPP_SHARED"] = self.options["jsoncpp"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/jsoncpp/all/test_v1_package/CMakeLists.txt b/recipes/jsoncpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/jsoncpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/jsoncpp/all/test_v1_package/conanfile.py b/recipes/jsoncpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/jsoncpp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/jsoncpp/config.yml b/recipes/jsoncpp/config.yml index b2e28903772a4..e11b41080c02a 100644 --- a/recipes/jsoncpp/config.yml +++ b/recipes/jsoncpp/config.yml @@ -1,11 +1,13 @@ versions: - "1.8.3": + "1.9.5": folder: all - "1.9.1": + "1.9.4": + folder: all + "1.9.3": folder: all "1.9.2": folder: all - "1.9.3": + "1.9.1": folder: all - "1.9.4": + "1.8.3": folder: all diff --git a/recipes/minizip-ng/all/CMakeLists.txt b/recipes/jsonnet/all/CMakeLists.txt similarity index 100% rename from recipes/minizip-ng/all/CMakeLists.txt rename to recipes/jsonnet/all/CMakeLists.txt diff --git a/recipes/jsonnet/all/conandata.yml b/recipes/jsonnet/all/conandata.yml new file mode 100644 index 0000000000000..af6fab5053143 --- /dev/null +++ b/recipes/jsonnet/all/conandata.yml @@ -0,0 +1,26 @@ +sources: + "0.19.1": + url: "https://github.com/google/jsonnet/archive/v0.19.1.tar.gz" + sha256: "f5a20f2dc98fdebd5d42a45365f52fa59a7e6b174e43970fea4f9718a914e887" + "0.18.0": + url: "https://github.com/google/jsonnet/archive/v0.18.0.tar.gz" + sha256: "85c240c4740f0c788c4d49f9c9c0942f5a2d1c2ae58b2c71068107bc80a3ced4" + "0.17.0": + url: "https://github.com/google/jsonnet/archive/v0.17.0.tar.gz" + sha256: "076b52edf888c01097010ad4299e3b2e7a72b60a41abbc65af364af1ed3c8dbe" +patches: + "0.19.1": + - patch_file: "patches/0.18.0/0001-fix-nlohmann-include.patch" + base_path: "source_subfolder" + - patch_file: "patches/0.18.0/0002-cmake-fixes.patch" + base_path: "source_subfolder" + "0.18.0": + - patch_file: "patches/0.18.0/0001-fix-nlohmann-include.patch" + base_path: "source_subfolder" + - patch_file: "patches/0.18.0/0002-cmake-fixes.patch" + base_path: "source_subfolder" + "0.17.0": + - patch_file: "patches/0.17.0/0001-fix-nlohmann-include.patch" + base_path: "source_subfolder" + - patch_file: "patches/0.17.0/0002-cmake-fixes.patch" + base_path: "source_subfolder" diff --git a/recipes/jsonnet/all/conanfile.py b/recipes/jsonnet/all/conanfile.py new file mode 100644 index 0000000000000..ff9c2346a3e5f --- /dev/null +++ b/recipes/jsonnet/all/conanfile.py @@ -0,0 +1,109 @@ +import functools +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc, msvc_runtime_flag + +required_conan_version = ">=1.33.0" + + +class JsonnetConan(ConanFile): + name = "jsonnet" + description = "Jsonnet - The data templating language" + topics = ("config", "json", "functional", "configuration") + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/google/jsonnet" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake", "cmake_find_package" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + # This is a workround. + # If jsonnet is shared, rapidyaml must be built as shared, + # or the c4core functions that rapidyaml depends on will not be able to be found. + # This seems to be a issue of rapidyaml. + # https://github.com/conan-io/conan-center-index/pull/9786#discussion_r829887879 + if tools.Version(self.version) >= "0.18.0": + self.options["rapidyaml"].shared = True + + def requirements(self): + self.requires("nlohmann_json/3.10.5") + if tools.Version(self.version) >= "0.18.0": + self.requires("rapidyaml/0.4.1") + + def validate(self): + if hasattr(self, "settings_build") and tools.cross_building(self, skip_x64_x86=True): + raise ConanInvalidConfiguration("jsonnet does not support cross building") + + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, "11") + + if self.options.shared and is_msvc(self) and "d" in msvc_runtime_flag(self): + raise ConanInvalidConfiguration("shared {} is not supported with MTd/MDd runtime".format(self.name)) + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_TESTS"] = False + cmake.definitions["BUILD_STATIC_LIBS"] = not self.options.shared + cmake.definitions["BUILD_SHARED_BINARIES"] = False + cmake.definitions["BUILD_JSONNET"] = False + cmake.definitions["BUILD_JSONNETFMT"] = False + cmake.definitions["USE_SYSTEM_JSON"] = True + cmake.configure(build_folder=self._build_subfolder) + return cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.components["libjsonnet"].libs = ["jsonnet"] + self.cpp_info.components["libjsonnet"].requires = ["nlohmann_json::nlohmann_json"] + if tools.Version(self.version) >= "0.18.0": + self.cpp_info.components["libjsonnet"].requires.append("rapidyaml::rapidyaml") + + if tools.stdcpp_library(self): + self.cpp_info.components["libjsonnet"].system_libs.append(tools.stdcpp_library(self)) + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["libjsonnet"].system_libs.append("m") + + self.cpp_info.components["libjsonnetpp"].libs = ["jsonnet++"] + self.cpp_info.components["libjsonnetpp"].requires = ["libjsonnet"] diff --git a/recipes/jsonnet/all/patches/0.17.0/0001-fix-nlohmann-include.patch b/recipes/jsonnet/all/patches/0.17.0/0001-fix-nlohmann-include.patch new file mode 100644 index 0000000000000..71f250f322ba7 --- /dev/null +++ b/recipes/jsonnet/all/patches/0.17.0/0001-fix-nlohmann-include.patch @@ -0,0 +1,11 @@ +--- a/core/vm.cpp ++++ b/core/vm.cpp +@@ -23,7 +23,7 @@ limitations under the License. + + #include "desugarer.h" + #include "json.h" +-#include "json.hpp" ++#include + #include "md5.h" + #include "parser.h" + #include "state.h" diff --git a/recipes/jsonnet/all/patches/0.17.0/0002-cmake-fixes.patch b/recipes/jsonnet/all/patches/0.17.0/0002-cmake-fixes.patch new file mode 100644 index 0000000000000..6d8e892eb89a7 --- /dev/null +++ b/recipes/jsonnet/all/patches/0.17.0/0002-cmake-fixes.patch @@ -0,0 +1,87 @@ +- install headers +- optionally disable shared build +- add md5 objects to c library +- allow MSVC +--- core/CMakeLists.txt ++++ core/CMakeLists.txt +@@ -16,8 +16,8 @@ set(LIBJSONNET_HEADERS + string_utils.h + unicode.h + vm.h) +- +-set(LIBJSONNET_SOURCE ++install(FILES ../include/libjsonnet.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ++set(LIBJSONNET_SOURCE $ + desugarer.cpp + formatter.cpp + lexer.cpp +@@ -27,7 +27,7 @@ set(LIBJSONNET_SOURCE + static_analysis.cpp + string_utils.cpp + vm.cpp) +- ++if (NOT BUILD_STATIC_LIBS) + add_library(libjsonnet SHARED ${LIBJSONNET_HEADERS} ${LIBJSONNET_SOURCE}) + add_dependencies(libjsonnet md5 stdlib) + target_link_libraries(libjsonnet md5 nlohmann_json::nlohmann_json) +@@ -50,7 +50,7 @@ install(TARGETS libjsonnet +- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ++ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + target_include_directories(libjsonnet INTERFACE + $) +- ++endif() + if (BUILD_STATIC_LIBS) + # Static library for jsonnet command-line tool. + add_library(libjsonnet_static STATIC ${LIBJSONNET_SOURCE}) +--- cpp/CMakeLists.txt ++++ cpp/CMakeLists.txt +@@ -3,11 +3,11 @@ + set(LIBJSONNETPP_HEADERS + ../include/libjsonnet++.h + ) +- ++install(FILES ${LIBJSONNETPP_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + set(LIBJSONNETPP_SOURCE + libjsonnet++.cpp + ) +- ++if (NOT BUILD_STATIC_LIBS) + add_library(libjsonnet++ SHARED ${LIBJSONNETPP_HEADERS} ${LIBJSONNETPP_SOURCE}) + add_dependencies(libjsonnet++ jsonnet) +-# target_link_libraries(libjsonnet libjsonnet) ++target_link_libraries(libjsonnet++ libjsonnet) +@@ -24,7 +24,7 @@ +- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ++ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + target_include_directories(libjsonnet++ INTERFACE + $) +- ++endif() + if (BUILD_STATIC_LIBS) + # Static library for jsonnet command-line tool. + add_library(libjsonnet++_static STATIC ${LIBJSONNETPP_SOURCE}) +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -40,7 +40,7 @@ + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++11 -fPIC ${OPT}") + else() + # TODO: Windows support. +- message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported") ++ message(WARNING "Compiler ${CMAKE_CXX_COMPILER_ID} not supported") + endif() + + set(CMAKE_CXX_STANDARD 11) +--- stdlib/CMakeLists.txt ++++ stdlib/CMakeLists.txt +@@ -5,7 +5,7 @@ + # Custom command that will only build stdlib when it changes. + add_custom_command( + OUTPUT ${PROJECT_SOURCE_DIR}/core/std.jsonnet.h +- COMMAND ${GLOBAL_OUTPUT_PATH}/to_c_array ++ COMMAND to_c_array + ${PROJECT_SOURCE_DIR}/stdlib/std.jsonnet + ${PROJECT_SOURCE_DIR}/core/std.jsonnet.h + DEPENDS to_c_array std.jsonnet) + + diff --git a/recipes/jsonnet/all/patches/0.18.0/0001-fix-nlohmann-include.patch b/recipes/jsonnet/all/patches/0.18.0/0001-fix-nlohmann-include.patch new file mode 100644 index 0000000000000..7f3a0ce643004 --- /dev/null +++ b/recipes/jsonnet/all/patches/0.18.0/0001-fix-nlohmann-include.patch @@ -0,0 +1,13 @@ +diff --git a/core/vm.cpp b/core/vm.cpp +index 1fd8ab9..636d227 100644 +--- a/core/vm.cpp ++++ b/core/vm.cpp +@@ -23,7 +23,7 @@ limitations under the License. + + #include "desugarer.h" + #include "json.h" +-#include "json.hpp" ++#include + #include "md5.h" + #include "parser.h" + #include "ryml_std.hpp" // include this before any other ryml header diff --git a/recipes/jsonnet/all/patches/0.18.0/0002-cmake-fixes.patch b/recipes/jsonnet/all/patches/0.18.0/0002-cmake-fixes.patch new file mode 100644 index 0000000000000..505ce96c21e93 --- /dev/null +++ b/recipes/jsonnet/all/patches/0.18.0/0002-cmake-fixes.patch @@ -0,0 +1,103 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5df20ca..c14c93c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -40,7 +40,7 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++11 -fPIC ${OPT}") + else() + # TODO: Windows support. +- message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported") ++ message(WARNING "Compiler ${CMAKE_CXX_COMPILER_ID} not supported") + endif() + + set(CMAKE_CXX_STANDARD 11) +@@ -121,7 +121,6 @@ endif() + add_subdirectory(include) + add_subdirectory(stdlib) + add_subdirectory(third_party/md5) +-add_subdirectory(third_party/rapidyaml/rapidyaml ryml) + add_subdirectory(core) + add_subdirectory(cpp) + add_subdirectory(cmd) +diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt +index e62a858..c0389f8 100644 +--- a/core/CMakeLists.txt ++++ b/core/CMakeLists.txt +@@ -17,7 +17,8 @@ set(LIBJSONNET_HEADERS + unicode.h + vm.h) + +-set(LIBJSONNET_SOURCE ++install(FILES ../include/libjsonnet.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ++set(LIBJSONNET_SOURCE $ + desugarer.cpp + formatter.cpp + lexer.cpp +@@ -28,6 +29,7 @@ set(LIBJSONNET_SOURCE + string_utils.cpp + vm.cpp) + ++if (NOT BUILD_STATIC_LIBS) + add_library(libjsonnet SHARED ${LIBJSONNET_HEADERS} ${LIBJSONNET_SOURCE}) + add_dependencies(libjsonnet md5 stdlib) + target_link_libraries(libjsonnet md5 nlohmann_json::nlohmann_json ryml) +@@ -47,10 +49,10 @@ set_target_properties(libjsonnet PROPERTIES OUTPUT_NAME jsonnet + install(TARGETS libjsonnet + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" +- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ++ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + target_include_directories(libjsonnet INTERFACE + $) +- ++endif() + if (BUILD_STATIC_LIBS) + # Static library for jsonnet command-line tool. + add_library(libjsonnet_static STATIC ${LIBJSONNET_SOURCE}) +diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt +index eb7686c..cbf21bb 100644 +--- a/cpp/CMakeLists.txt ++++ b/cpp/CMakeLists.txt +@@ -4,13 +4,15 @@ set(LIBJSONNETPP_HEADERS + ../include/libjsonnet++.h + ) + ++install(FILES ${LIBJSONNETPP_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + set(LIBJSONNETPP_SOURCE + libjsonnet++.cpp + ) + ++if (NOT BUILD_STATIC_LIBS) + add_library(libjsonnet++ SHARED ${LIBJSONNETPP_HEADERS} ${LIBJSONNETPP_SOURCE}) + add_dependencies(libjsonnet++ jsonnet) +-# target_link_libraries(libjsonnet libjsonnet) ++target_link_libraries(libjsonnet++ libjsonnet) + + # CMake prepends CMAKE_SHARED_LIBRARY_PREFIX to shared libraries, so without + # this step the output would be |liblibjsonnet|. +@@ -21,10 +23,10 @@ set_target_properties(libjsonnet++ PROPERTIES OUTPUT_NAME jsonnet++ + install(TARGETS libjsonnet++ + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" +- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ++ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + target_include_directories(libjsonnet++ INTERFACE + $) +- ++endif() + if (BUILD_STATIC_LIBS) + # Static library for jsonnet command-line tool. + add_library(libjsonnet++_static STATIC ${LIBJSONNETPP_SOURCE}) +diff --git a/stdlib/CMakeLists.txt b/stdlib/CMakeLists.txt +index a481d9f..00ff502 100644 +--- a/stdlib/CMakeLists.txt ++++ b/stdlib/CMakeLists.txt +@@ -5,7 +5,7 @@ add_executable(to_c_array to_c_array.cpp) + # Custom command that will only build stdlib when it changes. + add_custom_command( + OUTPUT ${PROJECT_SOURCE_DIR}/core/std.jsonnet.h +- COMMAND ${GLOBAL_OUTPUT_PATH}/to_c_array ++ COMMAND to_c_array + ${PROJECT_SOURCE_DIR}/stdlib/std.jsonnet + ${PROJECT_SOURCE_DIR}/core/std.jsonnet.h + DEPENDS to_c_array std.jsonnet) diff --git a/recipes/jsonnet/all/test_package/CMakeLists.txt b/recipes/jsonnet/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b1f60f164ad79 --- /dev/null +++ b/recipes/jsonnet/all/test_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(jsonnet CONFIG REQUIRED) + +add_executable(${PROJECT_NAME}_c test_package.c) +target_link_libraries(${PROJECT_NAME}_c jsonnet::libjsonnet) + +add_executable(${PROJECT_NAME}_cxx test_package.cpp) +target_link_libraries(${PROJECT_NAME}_cxx jsonnet::libjsonnetpp) +set_property(TARGET ${PROJECT_NAME}_cxx PROPERTY CXX_STANDARD 11) diff --git a/recipes/jsonnet/all/test_package/conanfile.py b/recipes/jsonnet/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1460ef0546803 --- /dev/null +++ b/recipes/jsonnet/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package_c"), run_environment=True) + self.run(os.path.join("bin", "test_package_cxx"), run_environment=True) diff --git a/recipes/jsonnet/all/test_package/test_package.c b/recipes/jsonnet/all/test_package/test_package.c new file mode 100644 index 0000000000000..0ea235af13aac --- /dev/null +++ b/recipes/jsonnet/all/test_package/test_package.c @@ -0,0 +1,11 @@ +#include + +#include + +int main() { + struct JsonnetVm* vm = jsonnet_make(); + jsonnet_max_stack(vm, 10); + printf("%s\n", jsonnet_version()); + return 0; +} + diff --git a/recipes/jsonnet/all/test_package/test_package.cpp b/recipes/jsonnet/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..62c5fc4ccecc9 --- /dev/null +++ b/recipes/jsonnet/all/test_package/test_package.cpp @@ -0,0 +1,13 @@ +#include + +#include + +int main() { + // C++ library + jsonnet::Jsonnet j; + if (!j.init()) { + return 1; + } + std::cout << jsonnet::Jsonnet::version() << "\n"; + return 0; +} diff --git a/recipes/jsonnet/config.yml b/recipes/jsonnet/config.yml new file mode 100644 index 0000000000000..d98d76db4349a --- /dev/null +++ b/recipes/jsonnet/config.yml @@ -0,0 +1,7 @@ +versions: + "0.19.1": + folder: all + "0.18.0": + folder: all + "0.17.0": + folder: all diff --git a/recipes/jthread-lite/all/conanfile.py b/recipes/jthread-lite/all/conanfile.py index da138a965bd68..efd2ef2fde6ab 100644 --- a/recipes/jthread-lite/all/conanfile.py +++ b/recipes/jthread-lite/all/conanfile.py @@ -1,40 +1,59 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.50.0" + class JthreadLiteConan(ConanFile): name = "jthread-lite" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/martinmoene/jthread-lite" description = "jthread lite - C++20's jthread for C++11 and later in a single-file header-only library " - topics = ("conan", "jthread-lite", "jthread", "cpp11") - settings = "os" + topics = ("jthread-lite", "jthread", "cpp11") license = "BSL-1.0" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + basic_layout(self, src_folder="src") def package_id(self): - self.info.header_only() + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "jthread-lite") + self.cpp_info.set_property("cmake_target_name", "nonstd::jthread-lite") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + # TODO: back to global scope once cmake_find_package* generators removed + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["jthreadlite"].system_libs = ["pthread"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "jthread-lite" self.cpp_info.filenames["cmake_find_package_multi"] = "jthread-lite" self.cpp_info.names["cmake_find_package"] = "nonstd" self.cpp_info.names["cmake_find_package_multi"] = "nonstd" self.cpp_info.components["jthreadlite"].names["cmake_find_package"] = "jthread-lite" self.cpp_info.components["jthreadlite"].names["cmake_find_package_multi"] = "jthread-lite" - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["jthreadlite"].system_libs = ["pthread"] + self.cpp_info.components["jthreadlite"].set_property("cmake_target_name", "nonstd::jthread-lite") + self.cpp_info.components["jthreadlite"].bindirs = [] + self.cpp_info.components["jthreadlite"].libdirs = [] diff --git a/recipes/jthread-lite/all/test_package/CMakeLists.txt b/recipes/jthread-lite/all/test_package/CMakeLists.txt index 547069f72eba3..4310ed8c6ce1f 100644 --- a/recipes/jthread-lite/all/test_package/CMakeLists.txt +++ b/recipes/jthread-lite/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(jthread-lite REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} nonstd::jthread-lite) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE nonstd::jthread-lite) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/jthread-lite/all/test_package/conanfile.py b/recipes/jthread-lite/all/test_package/conanfile.py index abcaeed3f89b6..0a6bc68712d90 100644 --- a/recipes/jthread-lite/all/test_package/conanfile.py +++ b/recipes/jthread-lite/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/jthread-lite/all/test_v1_package/CMakeLists.txt b/recipes/jthread-lite/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/jthread-lite/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/jthread-lite/all/test_v1_package/conanfile.py b/recipes/jthread-lite/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/jthread-lite/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/jungle/all/CMakeLists.txt b/recipes/jungle/all/CMakeLists.txt new file mode 100644 index 0000000000000..d2b01e47d9d63 --- /dev/null +++ b/recipes/jungle/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.11) +project(jungle) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory("source_subfolder") diff --git a/recipes/jungle/all/conandata.yml b/recipes/jungle/all/conandata.yml new file mode 100644 index 0000000000000..66bd8466456e1 --- /dev/null +++ b/recipes/jungle/all/conandata.yml @@ -0,0 +1,21 @@ +sources: + "cci.20220801": + url: "https://github.com/eBay/Jungle/archive/f41b7123489f1bc942a6b76dc54485391485cd27.tar.gz" + sha256: 8667a114bcef661b2a93e627a68b0584931f182dc8b96693ce6901d903584ab8 +patches: + "cci.20220801": + - patch_file: "patches/0001-cmake-alterations.patch" + patch_description: "CMake dependency discovery outside subtree." + patch_type: "conan" + base_path: "source_subfolder" + sha256: "a7111a290e145717ae0cbdace9866db69c70782731c8568a806f8579e30759eb" + - patch_file: "patches/0002-forestdb-path.patch" + patch_description: "Update include macros for ForestDB headers." + patch_type: "conan" + base_path: "source_subfolder" + sha256: "84ec45a312c52e2fa8cb7ab615aaa11088f24dcb4e4b880340b46c2763900d6b" + - patch_file: "patches/0003-stdatomic.patch" + patch_description: "Include std::atomic from all compilers." + patch_type: "portability" + base_path: "source_subfolder" + sha256: "3ca66676f89e2425255eeb15bf18a77ae21c4f383124013bd6d1cb660cbc1544" diff --git a/recipes/jungle/all/conanfile.py b/recipes/jungle/all/conanfile.py new file mode 100644 index 0000000000000..5350d8f70668d --- /dev/null +++ b/recipes/jungle/all/conanfile.py @@ -0,0 +1,76 @@ +from os.path import join +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.build import check_min_cppstd +from conans import CMake + +required_conan_version = ">=1.50.0" + +class JungleConan(ConanFile): + name = "jungle" + homepage = "https://github.com/eBay/Jungle" + description = "Key-value storage library, based on a combined index of LSM-tree and copy-on-write B+tree" + topics = ("kv-store", "cow") + url = "https://github.com/conan-io/conan-center-index" + license = "Apache-2.0" + + settings = "os", "arch", "compiler", "build_type" + + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "cmake", "cmake_find_package" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch_file in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch_file["patch_file"]) + + def requirements(self): + self.requires("forestdb/cci.20220727") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + src_dir = join(self.source_folder, self._source_subfolder) + copy(self, "LICENSE*", src_dir, join(self.package_folder, "licenses")) + + hdr_src = join(src_dir, "include") + copy(self, "*.h", hdr_src, join(self.package_folder, "include"), keep_path=True) + + lib_dir = join(self.package_folder, "lib") + copy(self, "*.a", self.build_folder, lib_dir, keep_path=False) + copy(self, "*.lib", self.build_folder, lib_dir, keep_path=False) + copy(self, "*.so*", self.build_folder, lib_dir, keep_path=False) + copy(self, "*.dylib*", self.build_folder, lib_dir, keep_path=False) + copy(self, "*.dll*", self.build_folder, join(self.package_folder, "bin"), keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["jungle"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["pthread", "dl"]) diff --git a/recipes/jungle/all/patches/0001-cmake-alterations.patch b/recipes/jungle/all/patches/0001-cmake-alterations.patch new file mode 100644 index 0000000000000..77f5f46560539 --- /dev/null +++ b/recipes/jungle/all/patches/0001-cmake-alterations.patch @@ -0,0 +1,52 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -100,7 +100,8 @@ if (TESTSUITE_NO_COLOR GREATER 0) + add_definitions(-DTESTSUITE_NO_COLOR=1) + endif() + +-file(COPY ${CMAKE_SOURCE_DIR}/scripts/runtests.sh ++find_package(forestdb REQUIRED) ++file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/scripts/runtests.sh + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + + # === CUSTOM LOGGER === +@@ -187,16 +191,16 @@ set(JUNGLE_DEPS + ${LIBDL}) + + add_library(static_lib ${JUNGLE_CORE}) +-target_link_libraries(static_lib ${JUNGLE_DEPS}) ++target_link_libraries(static_lib forestdb::forestdb) + set_target_properties(static_lib PROPERTIES OUTPUT_NAME jungle + CLEAN_DIRECT_OUTPUT 1) + if (DETACH_LOGGER GREATER 0) + add_dependencies(static_lib simplelogger_lib) + endif () + +-add_subdirectory("${PROJECT_SOURCE_DIR}/examples") ++#add_subdirectory("${PROJECT_SOURCE_DIR}/examples") +-add_subdirectory("${PROJECT_SOURCE_DIR}/tests") ++#add_subdirectory("${PROJECT_SOURCE_DIR}/tests") +-add_subdirectory("${PROJECT_SOURCE_DIR}/tools") ++#add_subdirectory("${PROJECT_SOURCE_DIR}/tools") + + if (CODE_COVERAGE GREATER 0) + SETUP_TARGET_FOR_COVERAGE( +--- a/tests/CMakeLists.txt ++++ b/tests/CMakeLists.txt +@@ -1,14 +1,11 @@ + set(TEST_DIR ${PROJECT_SOURCE_DIR}/tests) + set(UNIT_TEST_DIR ${TEST_DIR}/unit) + set(JUNGLE_TEST_DIR ${TEST_DIR}/jungle) + set(STRESS_TEST_DIR ${TEST_DIR}/stress) + + set(JUNGLE_TEST_DEPS +- ${CMAKE_CURRENT_BINARY_DIR}/../libjungle.a +- ${LIBSIMPLELOGGER} +- ${FDB_LIB_DIR}/libforestdb.a +- ${LIBSNAPPY} +- ${LIBDL}) ++ static_lib ++ forestdb::forestdb) + + set(FILEOPS_TEST ${TEST_DIR}/unit/fileops_test.cc) + add_executable(fileops_test ${FILEOPS_TEST}) diff --git a/recipes/jungle/all/patches/0002-forestdb-path.patch b/recipes/jungle/all/patches/0002-forestdb-path.patch new file mode 100644 index 0000000000000..547b2635d3042 --- /dev/null +++ b/recipes/jungle/all/patches/0002-forestdb-path.patch @@ -0,0 +1,62 @@ +diff --git a/src/cmd_handler.cc b/src/cmd_handler.cc +index 12cf591..14c42b4 100644 +--- a/src/cmd_handler.cc ++++ b/src/cmd_handler.cc +@@ -22,7 +22,7 @@ limitations under the License. + #include "skiplist.h" + #include "table_mgr.h" + +-#include ++#include + + #include + #include +diff --git a/src/table_file.cc b/src/table_file.cc +index 69ca237..80c7648 100644 +--- a/src/table_file.cc ++++ b/src/table_file.cc +@@ -21,7 +21,7 @@ limitations under the License. + #include "internal_helper.h" + #include "table_mgr.h" + +-#include ++#include + + #include _MACRO_TO_STR(LOGGER_H) + +diff --git a/src/table_file.h b/src/table_file.h +index ab7a29d..fd4bc4c 100644 +--- a/src/table_file.h ++++ b/src/table_file.h +@@ -21,7 +21,7 @@ limitations under the License. + #include "table_lookup_booster.h" + + #include +-#include ++#include + + #include + #include +@@ -450,4 +450,3 @@ private: + + + } // namespace jungle +- +--- a/tests/jungle/builder_test.cc ++++ b/tests/jungle/builder_test.cc +@@ -16,7 +16,7 @@ limitations under the License. + + #include "jungle_test_common.h" + +-#include "jungle_builder.h" ++#include "tools/jungle_builder.h" + #include "libjungle/iterator.h" + #include "libjungle/jungle.h" + #include "libjungle/sized_buf.h" +@@ -275,4 +275,4 @@ int main(int argc, char** argv) { + ts.doTest("build an empty db test", build_an_empty_db_test); + + return 0; +-} +\ No newline at end of file ++} diff --git a/recipes/jungle/all/patches/0003-stdatomic.patch b/recipes/jungle/all/patches/0003-stdatomic.patch new file mode 100644 index 0000000000000..f56b9cb06270b --- /dev/null +++ b/recipes/jungle/all/patches/0003-stdatomic.patch @@ -0,0 +1,13 @@ +diff --git a/src/skiplist.h b/src/skiplist.h +index 15f5fb7..5c24461 100644 +--- a/src/skiplist.h ++++ b/src/skiplist.h +@@ -29,7 +29,7 @@ limitations under the License. + struct _skiplist_node; + + //#define _STL_ATOMIC (1) +-#ifdef __APPLE__ ++#if __has_include() + #define _STL_ATOMIC (1) + #endif + #if defined(_STL_ATOMIC) && defined(__cplusplus) diff --git a/recipes/jungle/all/test_package/CMakeLists.txt b/recipes/jungle/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..354670d11c755 --- /dev/null +++ b/recipes/jungle/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.11) +set(CMAKE_CXX_STANDARD 11) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(jungle CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} jungle::jungle) diff --git a/recipes/jungle/all/test_package/conanfile.py b/recipes/jungle/all/test_package/conanfile.py new file mode 100644 index 0000000000000..9ebf26743f34b --- /dev/null +++ b/recipes/jungle/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile +from conan.tools.build import cross_building +from conans import CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/jungle/all/test_package/test_package.cpp b/recipes/jungle/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..756f927a89ccd --- /dev/null +++ b/recipes/jungle/all/test_package/test_package.cpp @@ -0,0 +1,17 @@ +#include + +#include +#include + +int main(void) { + jungle::DB *dbInst; + jungle::Status s; + jungle::DBConfig db_config; + + s = jungle::DB::open(&dbInst, ".", db_config); + + assert(s.ok()); + + std::cout << "Success\n"; + return 0; +} diff --git a/recipes/jungle/config.yml b/recipes/jungle/config.yml new file mode 100644 index 0000000000000..2499184dd3f4b --- /dev/null +++ b/recipes/jungle/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220801": + folder: all diff --git a/recipes/jwasm/all/CMakeLists.txt b/recipes/jwasm/all/CMakeLists.txt deleted file mode 100644 index 361b35d4c17d9..0000000000000 --- a/recipes/jwasm/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/jwasm/all/conandata.yml b/recipes/jwasm/all/conandata.yml index 6bd2cbb5b502c..b89fdd80dcbde 100644 --- a/recipes/jwasm/all/conandata.yml +++ b/recipes/jwasm/all/conandata.yml @@ -5,4 +5,9 @@ sources: patches: "2.13": - patch_file: "patches/0001-2.13-fix-fatal-errors-msvc.patch" - base_path: "source_subfolder" + patch_description: "Fix 64-bit MSVC" + patch_type: "backport" + patch_source: "https://github.com/Baron-von-Riedesel/JWasm/pull/10" + - patch_file: "patches/0002-fix-cmake.patch" + patch_description: "Fix CMake to add an install target & honor vc runtime" + patch_type: "compatibility" diff --git a/recipes/jwasm/all/conanfile.py b/recipes/jwasm/all/conanfile.py index 2f215ffde2d5b..682db91532894 100644 --- a/recipes/jwasm/all/conanfile.py +++ b/recipes/jwasm/all/conanfile.py @@ -1,54 +1,66 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get import os +required_conan_version = ">=1.46.0" + class JwasmConan(ConanFile): name = "jwasm" description = "JWasm is intended to be a free Masm-compatible assembler." license = "Watcom-1.0" - topics = ("conan", "jwasm", "masm", "assembler") + topics = ("jwasm", "masm", "assembler") homepage = "https://github.com/JWasm/JWasm" url = "https://github.com/conan-io/conan-center-index" settings = "os", "arch", "compiler", "build_type" - exports_sources = "CMakeLists.txt", "patches/*" - generators = "cmake" - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass def package_id(self): del self.info.settings.compiler + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("JWasm-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - 'string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")', - "") + def generate(self): + tc = CMakeToolchain(self) + tc.generate() def build(self): - self._patch_sources() + apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() def package(self): - self.copy("License.txt", dst="licenses", src=self._source_subfolder) - suffix = ".exe" if self.settings.os == "Windows" else "" - self.copy("jwasm" + suffix, dst="bin", src="bin") + copy(self, "License.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() def package_info(self): + self.cpp_info.frameworkdirs = [] + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.output.info(f"Appending PATH environment variable: {bin_path}") self.env_info.PATH.append(bin_path) diff --git a/recipes/jwasm/all/patches/0001-2.13-fix-fatal-errors-msvc.patch b/recipes/jwasm/all/patches/0001-2.13-fix-fatal-errors-msvc.patch index 7ace77282cf5f..c21adbbcdf316 100644 --- a/recipes/jwasm/all/patches/0001-2.13-fix-fatal-errors-msvc.patch +++ b/recipes/jwasm/all/patches/0001-2.13-fix-fatal-errors-msvc.patch @@ -1,4 +1,3 @@ -https://github.com/Baron-von-Riedesel/JWasm/pull/10 --- main.c +++ main.c @@ -69,7 +69,7 @@ int main( int argc, char **argv ) diff --git a/recipes/jwasm/all/patches/0002-fix-cmake.patch b/recipes/jwasm/all/patches/0002-fix-cmake.patch new file mode 100644 index 0000000000000..74477754d1d0c --- /dev/null +++ b/recipes/jwasm/all/patches/0002-fix-cmake.patch @@ -0,0 +1,31 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,20 +1,9 @@ +-cmake_minimum_required (VERSION 2.8) ++cmake_minimum_required (VERSION 3.1) + +-project(jwasm) ++project(jwasm LANGUAGES C) + + include_directories(H) + if (WIN32) +-set(CompilerFlags +- CMAKE_CXX_FLAGS +- CMAKE_CXX_FLAGS_DEBUG +- CMAKE_CXX_FLAGS_RELEASE +- CMAKE_C_FLAGS +- CMAKE_C_FLAGS_DEBUG +- CMAKE_C_FLAGS_RELEASE +- ) +-foreach(CompilerFlag ${CompilerFlags}) +- string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") +-endforeach() + add_definitions(-D__NT__ -DNDEBUG -DDEBUG_OUT -D_CRT_SECURE_NO_WARNINGS) + else() + add_definitions(-D__UNIX__ -DNDEBUG -DDEBUG_OUT) +@@ -23,3 +12,5 @@ endif() + FILE(GLOB all_c_files *.c) + LIST(REMOVE_ITEM all_c_files ${CMAKE_CURRENT_SOURCE_DIR}/trmem.c) + add_executable(jwasm ${all_c_files}) ++include(GNUInstallDirs) ++install(TARGETS jwasm DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/recipes/jwasm/all/test_package/conanfile.py b/recipes/jwasm/all/test_package/conanfile.py index 4f5ea1fe98c33..ab2cfc01b81ac 100644 --- a/recipes/jwasm/all/test_package/conanfile.py +++ b/recipes/jwasm/all/test_package/conanfile.py @@ -1,17 +1,28 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.cmake import cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "arch" + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def test(self): - if not tools.cross_building(self.settings): - self.run("jwasm -h", run_environment=True, ignore_errors=True) - asm_file = os.path.join(self.source_folder, "Lin64_1.asm") # content from https://www.japheth.de/JWasm/Lin64_1.html - obj_file = os.path.join(self.build_folder, "Lin64_1.o") - self.run("jwasm -elf64 -Fo={obj} {asm}".format(asm=asm_file, obj=obj_file), run_environment=True) - if self.settings.os == "Linux" and self.settings.arch == "x86_64": - bin_file = os.path.join(self.build_folder, "Lin64_1") - self.run("ld {obj} -o {bin}".format(obj=obj_file, bin=bin_file)) - self.run(bin_file, ignore_errors=True) + self.run("jwasm -h", ignore_errors=True) + obj_file = os.path.join(self.build_folder, "Lin64_1.o") + asm_file = os.path.join(self.source_folder, "Lin64_1.asm") # content from https://www.japheth.de/JWasm/Lin64_1.html + self.run(f"jwasm -elf64 -Fo={obj_file} {asm_file}") + if self._settings_build.os == "Linux" and self._settings_build.arch == "x86_64": + bin_file = os.path.join(self.build_folder, "Lin64_1") + self.run(f"ld {obj_file} -o {bin_file}") + self.run(bin_file, ignore_errors=True) diff --git a/recipes/jwasm/all/test_v1_package/conanfile.py b/recipes/jwasm/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2f48a81c3461c --- /dev/null +++ b/recipes/jwasm/all/test_v1_package/conanfile.py @@ -0,0 +1,24 @@ +from conans import ConanFile +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + + def test(self): + self.run("jwasm -h", ignore_errors=True) + obj_file = os.path.join(self.build_folder, "Lin64_1.o") + asm_file = os.path.join(self.source_folder, os.pardir, "test_package", "Lin64_1.asm") # content from https://www.japheth.de/JWasm/Lin64_1.html + self.run(f"jwasm -elf64 -Fo={obj_file} {asm_file}") + if self._settings_build.os == "Linux" and self._settings_build.arch == "x86_64": + bin_file = os.path.join(self.build_folder, "Lin64_1") + self.run(f"ld {obj_file} -o {bin_file}") + self.run(bin_file, ignore_errors=True) diff --git a/recipes/jwt-cpp/all/conandata.yml b/recipes/jwt-cpp/all/conandata.yml index c58e5a4df800f..bf093248fb260 100644 --- a/recipes/jwt-cpp/all/conandata.yml +++ b/recipes/jwt-cpp/all/conandata.yml @@ -1,20 +1,37 @@ sources: - "0.5.0": - url: https://github.com/Thalhammer/jwt-cpp/archive/v0.5.0.tar.gz - sha256: 079a273f070dd11213e301712319a65881e51ab81535cc436d5313191df852a2 - "0.4.0": - url: https://github.com/Thalhammer/jwt-cpp/archive/v0.4.0.tar.gz - sha256: f0dcc7b0e8bef8f9c3f434e7121f9941145042c9fe3055a5bdd709085a4f2be4 - "0.3.1": - url: https://github.com/Thalhammer/jwt-cpp/archive/v0.3.1.tar.gz - sha256: 399345e81883f2959df658cd945de39548ddfefdab2acf7b23ee07b9e9a02938 + "0.6.0": + url: "https://github.com/Thalhammer/jwt-cpp/archive/v0.6.0.tar.gz" + sha256: "0227bd6e0356b211341075c7997c837f0b388c01379bd256aa525566a5553f03" + "0.5.1": + url: "https://github.com/Thalhammer/jwt-cpp/archive/v0.5.1.tar.gz" + sha256: "d8f5ffb361824630b3b6f4aad26c730c915081071040c232ac57947d6177ef4f" + "0.5.0": + url: "https://github.com/Thalhammer/jwt-cpp/archive/v0.5.0.tar.gz" + sha256: "079a273f070dd11213e301712319a65881e51ab81535cc436d5313191df852a2" + "0.4.0": + url: "https://github.com/Thalhammer/jwt-cpp/archive/v0.4.0.tar.gz" + sha256: "f0dcc7b0e8bef8f9c3f434e7121f9941145042c9fe3055a5bdd709085a4f2be4" + "0.3.1": + url: "https://github.com/Thalhammer/jwt-cpp/archive/v0.3.1.tar.gz" + sha256: "399345e81883f2959df658cd945de39548ddfefdab2acf7b23ee07b9e9a02938" patches: - "0.5.0": - - patch_file: patches/0004-fix-picojson-header-location-for-conan.patch - base_path: source_subfolder - "0.4.0": - - patch_file: patches/0003-fix-picojson-header-location-for-conan.patch - base_path: source_subfolder - "0.3.1": - - patch_file: patches/0002-fix-openssl-change-version.patch - base_path: source_subfolder + "0.6.0": + - patch_file: "patches/0005-fix-picojson-header-location-for-conan.patch" + patch_description: "Remove picojson namespace from its include" + patch_type: "conan" + "0.5.1": + - patch_file: "patches/0004-fix-picojson-header-location-for-conan.patch" + patch_description: "Remove picojson namespace from its include" + patch_type: "conan" + "0.5.0": + - patch_file: "patches/0004-fix-picojson-header-location-for-conan.patch" + patch_description: "Remove picojson namespace from its include" + patch_type: "conan" + "0.4.0": + - patch_file: "patches/0003-fix-picojson-header-location-for-conan.patch" + patch_description: "Remove picojson namespace from its include" + patch_type: "conan" + "0.3.1": + - patch_file: "patches/0002-fix-openssl-change-version.patch" + patch_description: "Remove picojson namespace from its include" + patch_type: "conan" diff --git a/recipes/jwt-cpp/all/conanfile.py b/recipes/jwt-cpp/all/conanfile.py index 06e60a19f8512..03a6ded8886d7 100644 --- a/recipes/jwt-cpp/all/conanfile.py +++ b/recipes/jwt-cpp/all/conanfile.py @@ -1,6 +1,10 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.scm import Version +from conan.tools.files import get, copy, apply_conandata_patches +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.50.0" class JwtCppConan(ConanFile): name = "jwt-cpp" @@ -8,34 +12,53 @@ class JwtCppConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/Thalhammer/jwt-cpp" description = "A C++ JSON Web Token library for encoding/decoding" - topics = ("jwt-cpp", "json", "jwt", "jose", "header-only") - exports_sources = ["patches/**"] + topics = ("jwt-cpp", "json", "jwt", "jws", "jwe", "jwk", "jwks", "jose", "header-only") + settings = "arch", "build_type", "compiler", "os" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - @property def _supports_generic_json(self): - return tools.Version(self.version) >= "0.5.0" + return Version(self.version) >= "0.5.0" + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def requirements(self): - self.requires("openssl/1.1.1j") + self.requires("openssl/1.1.1s") if not self._supports_generic_json: self.requires("picojson/1.3.0") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def layout(self): + basic_layout(self, src_folder="src") + + def build(self): + apply_conandata_patches(self) def package(self): - header_dir = os.path.join(self._source_subfolder, "include") - self.copy(pattern="jwt-cpp/*.h", dst="include", src=header_dir, keep_path=True) - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + header_dir = os.path.join(self.source_folder, "include", "jwt-cpp") + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include", "jwt-cpp"), src=header_dir, keep_path=True) + copy(self, "LICENSE", dst=os.path.join(self.package_folder,"licenses"), src=self.source_folder) def package_id(self): - self.info.header_only() + self.info.clear() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "jwt-cpp") + self.cpp_info.set_property("cmake_target_name", "jwt-cpp::jwt-cpp") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "jwt-cpp" + self.cpp_info.names["cmake_find_package_multi"] = "jwt-cpp" + + if self._supports_generic_json: + self.cpp_info.defines.append("JWT_DISABLE_PICOJSON") + + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/jwt-cpp/all/patches/0005-fix-picojson-header-location-for-conan.patch b/recipes/jwt-cpp/all/patches/0005-fix-picojson-header-location-for-conan.patch new file mode 100644 index 0000000000000..af50870b9da7f --- /dev/null +++ b/recipes/jwt-cpp/all/patches/0005-fix-picojson-header-location-for-conan.patch @@ -0,0 +1,12 @@ +diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h +--- a/include/jwt-cpp/jwt.h ++++ b/include/jwt-cpp/jwt.h +@@ -8,1 +8,1 @@ +-#include "picojson/picojson.h" ++#include "picojson.h" +diff --git a/include/jwt-cpp/traits/kazuho-picojson/traits.h b/include/jwt-cpp/traits/kazuho-picojson/traits.h +--- a/include/jwt-cpp/traits/kazuho-picojson/traits.h ++++ b/include/jwt-cpp/traits/kazuho-picojson/traits.h +@@ -7,1 +7,1 @@ +-#include "picojson/picojson.h" ++#include "picojson.h" diff --git a/recipes/jwt-cpp/all/test_package/CMakeLists.txt b/recipes/jwt-cpp/all/test_package/CMakeLists.txt index 38de6e5ebf0d9..020cb1aab4c7d 100644 --- a/recipes/jwt-cpp/all/test_package/CMakeLists.txt +++ b/recipes/jwt-cpp/all/test_package/CMakeLists.txt @@ -1,12 +1,17 @@ -cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup(TARGETS) +find_package(jwt-cpp REQUIRED CONFIG) +find_package(picojson REQUIRED CONFIG) -find_package(jwt-cpp REQUIRED) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE jwt-cpp::jwt-cpp picojson::picojson) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) -add_executable(example example.cpp) -set_property(TARGET example PROPERTY CXX_STANDARD 11) +if (jwt-cpp_VERSION VERSION_GREATER 0.4.0) + target_compile_definitions(${PROJECT_NAME} PRIVATE JSON_TRAITS_NEEDED) +endif() -target_link_libraries(example jwt-cpp::jwt-cpp CONAN_PKG::picojson) +if (jwt-cpp_VERSION VERSION_GREATER_EQUAL 0.6.0) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAS_DEFAULT_TRAITS) +endif() diff --git a/recipes/jwt-cpp/all/test_package/conanfile.py b/recipes/jwt-cpp/all/test_package/conanfile.py index bbfbb7ea084ed..8c80e56ec63d3 100644 --- a/recipes/jwt-cpp/all/test_package/conanfile.py +++ b/recipes/jwt-cpp/all/test_package/conanfile.py @@ -1,20 +1,27 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class JsonCppTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" def requirements(self): + self.requires(self.tested_reference_str) self.requires("picojson/1.3.0") + def layout(self): + cmake_layout(self) + def build(self): cmake = CMake(self) cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/jwt-cpp/all/test_package/example.cpp b/recipes/jwt-cpp/all/test_package/example.cpp deleted file mode 100644 index d7082b8a374a1..0000000000000 --- a/recipes/jwt-cpp/all/test_package/example.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -int main() { - auto token = jwt::create() - .set_issuer("auth0") - .set_issued_at(std::chrono::system_clock::now()) - .set_expires_at(std::chrono::system_clock::now() + std::chrono::seconds{3600}) - .sign(jwt::algorithm::hs256{"secret"}); - - auto decoded = jwt::decode(token); - for(auto& e : decoded.get_payload_claims()) - std::cout << e.first << " = " << e.second.to_json() << std::endl; - - auto verifier = jwt::verify() - .allow_algorithm(jwt::algorithm::hs256{"secret"}) - .with_issuer("auth0"); - - verifier.verify(decoded); -} diff --git a/recipes/jwt-cpp/all/test_package/test_package.cpp b/recipes/jwt-cpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..a7af84c85dc7c --- /dev/null +++ b/recipes/jwt-cpp/all/test_package/test_package.cpp @@ -0,0 +1,29 @@ +#include + +#ifdef JSON_TRAITS_NEEDED + #ifndef HAS_DEFAULT_TRAITS + #include "traits/defaults.h" + #else + #include + #endif +#endif + +#include + +int main() { + auto token = jwt::create() + .set_issuer("auth0") + .set_issued_at(std::chrono::system_clock::now()) + .set_expires_at(std::chrono::system_clock::now() + std::chrono::seconds{3600}) + .sign(jwt::algorithm::hs256{"secret"}); + + auto decoded = jwt::decode(token); + for(auto& e : decoded.get_payload_claims()) + std::cout << e.first << " = " << e.second.to_json() << std::endl; + + auto verifier = jwt::verify() + .allow_algorithm(jwt::algorithm::hs256{"secret"}) + .with_issuer("auth0"); + + verifier.verify(decoded); +} diff --git a/recipes/jwt-cpp/all/test_package/traits/defaults.h b/recipes/jwt-cpp/all/test_package/traits/defaults.h new file mode 100644 index 0000000000000..7ec119bedd233 --- /dev/null +++ b/recipes/jwt-cpp/all/test_package/traits/defaults.h @@ -0,0 +1,58 @@ +#ifndef JWT_CPP_KAZUHO_PICOJSON_DEFAULTS_H +#define JWT_CPP_KAZUHO_PICOJSON_DEFAULTS_H + +#include "traits.h" + +namespace jwt { + /** + * \brief a class to store a generic [picojson](https://github.com/kazuho/picojson) value as claim + * + * This type is the specialization of the \ref basic_claim class which + * uses the standard template types. + */ + using claim = basic_claim; + + /** + * Create a verifier using the default clock + * \return verifier instance + */ + inline verifier verify() { + return verify(default_clock{}); + } + + /** + * Return a builder instance to create a new token + */ + inline builder create() { return builder(); } + +#ifndef JWT_DISABLE_BASE64 + /** + * Decode a token + * \param token Token to decode + * \return Decoded token + * \throw std::invalid_argument Token is not in correct format + * \throw std::runtime_error Base64 decoding failed or invalid json + */ + inline decoded_jwt decode(const std::string& token) { + return decoded_jwt(token); + } +#endif + + /** + * Decode a token + * \tparam Decode is callabled, taking a string_type and returns a string_type. + * It should ensure the padding of the input and then base64url decode and + * return the results. + * \param token Token to decode + * \param decode The token to parse + * \return Decoded token + * \throw std::invalid_argument Token is not in correct format + * \throw std::runtime_error Base64 decoding failed or invalid json + */ + template + decoded_jwt decode(const std::string& token, Decode decode) { + return decoded_jwt(token, decode); + } +} // namespace jwt + +#endif // JWT_CPP_KAZUHO_PICOJSON_DEFAULTS_H diff --git a/recipes/jwt-cpp/all/test_package/traits/traits.h b/recipes/jwt-cpp/all/test_package/traits/traits.h new file mode 100644 index 0000000000000..099f0dc26ce34 --- /dev/null +++ b/recipes/jwt-cpp/all/test_package/traits/traits.h @@ -0,0 +1,76 @@ +#ifndef JWT_CPP_PICOJSON_TRAITS_H +#define JWT_CPP_PICOJSON_TRAITS_H + +#ifndef PICOJSON_USE_INT64 +#define PICOJSON_USE_INT64 +#endif +#include + +#ifndef JWT_DISABLE_PICOJSON +#define JWT_DISABLE_PICOJSON +#endif +#include "jwt-cpp/jwt.h" + +namespace jwt { + namespace traits { + struct kazuho_picojson { + using value_type = picojson::value; + using object_type = picojson::object; + using array_type = picojson::array; + using string_type = std::string; + using number_type = double; + using integer_type = int64_t; + using boolean_type = bool; + + static json::type get_type(const picojson::value& val) { + using json::type; + if (val.is()) return type::boolean; + if (val.is()) return type::integer; + if (val.is()) return type::number; + if (val.is()) return type::string; + if (val.is()) return type::array; + if (val.is()) return type::object; + + throw std::logic_error("invalid type"); + } + + static picojson::object as_object(const picojson::value& val) { + if (!val.is()) throw std::bad_cast(); + return val.get(); + } + + static std::string as_string(const picojson::value& val) { + if (!val.is()) throw std::bad_cast(); + return val.get(); + } + + static picojson::array as_array(const picojson::value& val) { + if (!val.is()) throw std::bad_cast(); + return val.get(); + } + + static int64_t as_int(const picojson::value& val) { + if (!val.is()) throw std::bad_cast(); + return val.get(); + } + + static bool as_bool(const picojson::value& val) { + if (!val.is()) throw std::bad_cast(); + return val.get(); + } + + static double as_number(const picojson::value& val) { + if (!val.is()) throw std::bad_cast(); + return val.get(); + } + + static bool parse(picojson::value& val, const std::string& str) { + return picojson::parse(val, str).empty(); + } + + static std::string serialize(const picojson::value& val) { return val.serialize(); } + }; + } // namespace traits +} // namespace jwt + +#endif diff --git a/recipes/jwt-cpp/all/test_v1_package/CMakeLists.txt b/recipes/jwt-cpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d58f9a64ba28e --- /dev/null +++ b/recipes/jwt-cpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(jwt-cpp REQUIRED CONFIG) +find_package(picojson REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE jwt-cpp::jwt-cpp picojson::picojson) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +if (jwt-cpp_VERSION VERSION_GREATER 0.4.0) + target_compile_definitions(${PROJECT_NAME} PRIVATE JSON_TRAITS_NEEDED) +endif() + +if (jwt-cpp_VERSION VERSION_GREATER_EQUAL 0.6.0) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAS_DEFAULT_TRAITS) +endif() diff --git a/recipes/jwt-cpp/all/test_v1_package/conanfile.py b/recipes/jwt-cpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..3f782b39bbd4f --- /dev/null +++ b/recipes/jwt-cpp/all/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def requirements(self): + self.requires("picojson/1.3.0") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/jwt-cpp/config.yml b/recipes/jwt-cpp/config.yml index 3be8d72545ad2..49536ba2e770d 100644 --- a/recipes/jwt-cpp/config.yml +++ b/recipes/jwt-cpp/config.yml @@ -1,7 +1,11 @@ versions: - "0.3.1": - folder: all - "0.4.0": - folder: all - "0.5.0": - folder: all + "0.6.0": + folder: all + "0.5.1": + folder: all + "0.5.0": + folder: all + "0.4.0": + folder: all + "0.3.1": + folder: all diff --git a/recipes/jxrlib/all/CMakeLists.txt b/recipes/jxrlib/all/CMakeLists.txt index a5327c20bf0d3..f4e654c29be7f 100644 --- a/recipes/jxrlib/all/CMakeLists.txt +++ b/recipes/jxrlib/all/CMakeLists.txt @@ -1,16 +1,13 @@ -cmake_minimum_required(VERSION 2.8.12) -project(jxrlib C) +cmake_minimum_required(VERSION 3.1) +project(jxrlib LANGUAGES C) -include(conanbuildinfo.cmake) -conan_basic_setup() - -set(JPEGXR_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) +include(GNUInstallDirs) +include(TestBigEndian) if(NOT MSVC) add_definitions(-D__ANSI__) endif() -include(TestBigEndian) test_big_endian(ISBIGENDIAN) if(ISBIGENDIAN) set(DEF_ENDIAN _BIG__ENDIAN_) @@ -80,8 +77,6 @@ install(TARGETS jxrglue LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) - - install(FILES ${JPEGXR_FOLDER}/jxrgluelib/JXRGlue.h ${JPEGXR_FOLDER}/jxrgluelib/JXRMeta.h diff --git a/recipes/jxrlib/all/conandata.yml b/recipes/jxrlib/all/conandata.yml index 7414fc84fbab7..478aec5f4b6b6 100644 --- a/recipes/jxrlib/all/conandata.yml +++ b/recipes/jxrlib/all/conandata.yml @@ -2,3 +2,6 @@ sources: "cci.20170615": url: "https://github.com/4creators/jxrlib/archive/f7521879862b9085318e814c6157490dd9dbbdb4.tar.gz" sha256: "8ab20a21f6c3f8cfdedd2511b03a2009e52cce7fa6550202c355063d0d83213e" +patches: + "cci.20170615": + - patch_file: patches/0001-missing-declarations.patch diff --git a/recipes/jxrlib/all/conanfile.py b/recipes/jxrlib/all/conanfile.py index 5840fb1761c6b..d4c71b54de455 100644 --- a/recipes/jxrlib/all/conanfile.py +++ b/recipes/jxrlib/all/conanfile.py @@ -1,6 +1,12 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get +from conan.tools.microsoft import is_msvc import os -import glob -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.52.0" + class JxrlibConan(ConanFile): name = "jxrlib" @@ -8,64 +14,76 @@ class JxrlibConan(ConanFile): homepage = "https://jxrlib.codeplex.com/" url = "https://github.com/conan-io/conan-center-index" license = "BSD-2-Clause" - topics = ("conan", "jxr", "jpeg", "xr") - exports_sources = ["CMakeLists.txt"] - generators = "cmake" + topics = ("jxr", "jpeg", "xr") + settings = "os", "arch", "compiler", "build_type" options = { + "shared": [True, False], "fPIC": [True, False], } default_options = { + "shared": False, "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if is_msvc(self) and self.info.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} shared not supported by Visual Studio") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob('jxrlib-*/')[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_dir=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["JPEGXR_FOLDER"] = self.source_folder.replace("\\", "/") + tc.generate() def build(self): - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libjxr") self.cpp_info.libs = ["jxrglue", "jpegxr"] - - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") - if self.settings.os != "Windows": + if not is_msvc(self): self.cpp_info.defines.append("__ANSI__") - self.cpp_info.names["pkg_config"] = "libjxr" + # TODO: to remove in conan v2, and do not port this to CMakeDeps, it was a mistake self.cpp_info.names["cmake_find_package"] = "JXR" self.cpp_info.names["cmake_find_package_multi"] = "JXR" diff --git a/recipes/jxrlib/all/patches/0001-missing-declarations.patch b/recipes/jxrlib/all/patches/0001-missing-declarations.patch new file mode 100644 index 0000000000000..767eec49ea788 --- /dev/null +++ b/recipes/jxrlib/all/patches/0001-missing-declarations.patch @@ -0,0 +1,26 @@ +--- a/image/decode/segdec.c ++++ b/image/decode/segdec.c +@@ -52,6 +52,13 @@ static Int DecodeSignificantAbsLevel (struct CAdaptiveHuffman *pAHexpt, BitIOInf + //================================================================ + // Memory access functions + //================================================================ ++#ifndef _BIG__ENDIAN_ ++#if (defined(WIN32) && !defined(UNDER_CE)) || (defined(UNDER_CE) && defined(_ARM_)) ++// WinCE ARM and Desktop x86 ++#else ++U32 _byteswap_ulong(U32 bits); ++#endif ++#endif + static U32 _FORCEINLINE _load4(void* pv) + { + #ifdef _BIG__ENDIAN_ +--- a/jxrgluelib/JXRGlueJxr.c ++++ b/jxrgluelib/JXRGlueJxr.c +@@ -27,6 +27,7 @@ + // + //*@@@---@@@@****************************************************************** + #include ++#include + #include + + diff --git a/recipes/jxrlib/all/test_package/CMakeLists.txt b/recipes/jxrlib/all/test_package/CMakeLists.txt index 7b9b613cbb24a..e7689f4130d27 100644 --- a/recipes/jxrlib/all/test_package/CMakeLists.txt +++ b/recipes/jxrlib/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(jxrlib REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE jxrlib::jxrlib) diff --git a/recipes/jxrlib/all/test_package/conanfile.py b/recipes/jxrlib/all/test_package/conanfile.py index d7ad3be43e392..b8d2e695e4b3a 100644 --- a/recipes/jxrlib/all/test_package/conanfile.py +++ b/recipes/jxrlib/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,7 +21,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") img_path = os.path.join(self.source_folder, "test.jxr") - self.run("{0} {1}".format(bin_path, img_path), run_environment=True) + self.run(f"{bin_path} {img_path}", env="conanrun") diff --git a/recipes/jxrlib/all/test_v1_package/CMakeLists.txt b/recipes/jxrlib/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..eb386b8f18cc0 --- /dev/null +++ b/recipes/jxrlib/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(JXR REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE JXR::JXR) diff --git a/recipes/jxrlib/all/test_v1_package/conanfile.py b/recipes/jxrlib/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..ffd0b1c74921b --- /dev/null +++ b/recipes/jxrlib/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + img_path = os.path.join(self.source_folder, os.pardir, "test_package", "test.jxr") + self.run(f"{bin_path} {img_path}", run_environment=True) diff --git a/recipes/kaitai_struct_cpp_stl_runtime/all/CMakeLists.txt b/recipes/kaitai_struct_cpp_stl_runtime/all/CMakeLists.txt new file mode 100644 index 0000000000000..fb2d4252387cd --- /dev/null +++ b/recipes/kaitai_struct_cpp_stl_runtime/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.3) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/kaitai_struct_cpp_stl_runtime/all/conandata.yml b/recipes/kaitai_struct_cpp_stl_runtime/all/conandata.yml new file mode 100644 index 0000000000000..47a6f881a3206 --- /dev/null +++ b/recipes/kaitai_struct_cpp_stl_runtime/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20210701": + url: "https://github.com/kaitai-io/kaitai_struct_cpp_stl_runtime/archive/cb09b3a84c7e905c6a3fecfe9617cf864d9af781.zip" + sha256: "058c01828692bf193cb862372651c572fcc43babbf2d664674409511b9f54e5b" diff --git a/recipes/kaitai_struct_cpp_stl_runtime/all/conanfile.py b/recipes/kaitai_struct_cpp_stl_runtime/all/conanfile.py new file mode 100644 index 0000000000000..4c031d48459e1 --- /dev/null +++ b/recipes/kaitai_struct_cpp_stl_runtime/all/conanfile.py @@ -0,0 +1,68 @@ +import os + +from conans import ConanFile, CMake, tools + + +class KaitaiStructCppStlRuntimeConan(ConanFile): + name = "kaitai_struct_cpp_stl_runtime" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://kaitai.io/" + description = "kaitai struct c++ runtime library" + topics = ("parsers", "streams", "dsl") + settings = "os", "compiler", "build_type", "arch" + exports_sources = "CMakeLists.txt" + generators = "cmake" + options = { + "with_zlib": [True, False], + "with_iconv": [True, False] + } + default_options = { + "with_zlib": False, + "with_iconv": False + } + short_paths = True + _cmake = None + + def requirements(self): + if self.options.with_zlib: + self.requires("zlib/1.2.11") + if self.options.with_iconv: + self.requires("libiconv/1.16") + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + + if self.options.with_iconv: + self._cmake.definitions["STRING_ENCODING_TYPE"] = "ICONV" + else: + self._cmake.definitions["STRING_ENCODING_TYPE"] = "NONE" + + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/kaitai_struct_cpp_stl_runtime/all/test_package/CMakeLists.txt b/recipes/kaitai_struct_cpp_stl_runtime/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..58f25efbaa92e --- /dev/null +++ b/recipes/kaitai_struct_cpp_stl_runtime/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(test_package test_package.cpp) +target_link_libraries(test_package ${CONAN_LIBS}) + diff --git a/recipes/simdjson/0.2.1/test_package/conanfile.py b/recipes/kaitai_struct_cpp_stl_runtime/all/test_package/conanfile.py similarity index 100% rename from recipes/simdjson/0.2.1/test_package/conanfile.py rename to recipes/kaitai_struct_cpp_stl_runtime/all/test_package/conanfile.py diff --git a/recipes/kaitai_struct_cpp_stl_runtime/all/test_package/test_package.cpp b/recipes/kaitai_struct_cpp_stl_runtime/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f1a6bf26f36bc --- /dev/null +++ b/recipes/kaitai_struct_cpp_stl_runtime/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + std::string buf; + std::istringstream is(buf); + kaitai::kstream ks(&is); +} diff --git a/recipes/kaitai_struct_cpp_stl_runtime/config.yml b/recipes/kaitai_struct_cpp_stl_runtime/config.yml new file mode 100644 index 0000000000000..596c3149dc59d --- /dev/null +++ b/recipes/kaitai_struct_cpp_stl_runtime/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210701": + folder: all diff --git a/recipes/kangaru/all/conandata.yml b/recipes/kangaru/all/conandata.yml index ce601effe9aaa..eb79fa1ae4766 100644 --- a/recipes/kangaru/all/conandata.yml +++ b/recipes/kangaru/all/conandata.yml @@ -2,7 +2,10 @@ sources: "4.2.4": url: "https://github.com/gracicot/kangaru/archive/v4.2.4.tar.gz" sha256: "0ef74825d98165c26919ce01026533b6594faa584ea93c2f275e1f275bda9dc5" + "4.3.0": + url: "https://github.com/gracicot/kangaru/archive/v4.3.0.tar.gz" + sha256: "98a0d7f2e5ac65d93fe83615ead1627fab2237b173e18151fb68d50234ed6eaf" patches: "4.2.4": - - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" + - patch_file: "patches/fix-cmake.patch" + base_path: "source_subfolder" diff --git a/recipes/kangaru/all/conanfile.py b/recipes/kangaru/all/conanfile.py index af90202ef06c1..3472c5810dbf4 100644 --- a/recipes/kangaru/all/conanfile.py +++ b/recipes/kangaru/all/conanfile.py @@ -1,23 +1,29 @@ from conans import ConanFile, tools, CMake import os +import textwrap + +required_conan_version = ">=1.43.0" class KangaruConan(ConanFile): name = "kangaru" description = "A dependency injection container for C++11, C++14 and later" license = "MIT" - topics = ("conan", "gracicot", "kangaru", - "DI", "IoC", "inversion of control") + topics = ("gracicot", "kangaru", "DI", "IoC", "inversion of control") homepage = "https://github.com/gracicot/kangaru/wiki" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "compiler", "build_type", "arch" - options = {"reverse_destruction": [True, False], - "no_exception": [True, False]} - default_options = {"reverse_destruction": True, - "no_exception": False} + options = { + "reverse_destruction": [True, False], + "no_exception": [True, False], + } + default_options = { + "reverse_destruction": True, + "no_exception": False, + } + generators = "cmake" _cmake = None @property @@ -28,16 +34,21 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" - def configure(self): - if self.settings.compiler.cppstd: + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, 11) def package_id(self): self.info.settings.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -59,3 +70,33 @@ def package(self): cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib")) self.copy(os.path.join(self._source_subfolder, "LICENSE"), "licenses") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"kangaru": "kangaru::kangaru"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "kangaru") + self.cpp_info.set_property("cmake_target_name", "kangaru") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/kangaru/all/test_package/CMakeLists.txt b/recipes/kangaru/all/test_package/CMakeLists.txt index d33539c8597c4..5b65007810d6a 100644 --- a/recipes/kangaru/all/test_package/CMakeLists.txt +++ b/recipes/kangaru/all/test_package/CMakeLists.txt @@ -2,11 +2,11 @@ cmake_minimum_required(VERSION 3.1) project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(kangaru REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} kangaru::kangaru) # TODO: remove kangaru:: namespace when fixed in cpp_info of conanfile.py +target_link_libraries(${PROJECT_NAME} kangaru) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) diff --git a/recipes/kangaru/all/test_package/conanfile.py b/recipes/kangaru/all/test_package/conanfile.py index 7e2dfe859bb27..38f4483872d47 100644 --- a/recipes/kangaru/all/test_package/conanfile.py +++ b/recipes/kangaru/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/kangaru/config.yml b/recipes/kangaru/config.yml index 25a55904363a3..4be017b5b8de6 100644 --- a/recipes/kangaru/config.yml +++ b/recipes/kangaru/config.yml @@ -1,3 +1,5 @@ versions: "4.2.4": folder: all + "4.3.0": + folder: all diff --git a/recipes/kcov/all/conandata.yml b/recipes/kcov/all/conandata.yml index 286746be619be..b98fb5f6098f5 100644 --- a/recipes/kcov/all/conandata.yml +++ b/recipes/kcov/all/conandata.yml @@ -1,8 +1,12 @@ sources: + "40": + url: "https://github.com/SimonKagstrom/kcov/archive/refs/tags/v40.tar.gz" + sha256: "6b1c11b066d57426d61375a31c3816f1fcd2610b447050c86d9920e22d5200b3" "38": url: "https://github.com/SimonKagstrom/kcov/archive/38.tar.gz" sha256: "b37af60d81a9b1e3b140f9473bdcb7975af12040feb24cc666f9bb2bb0be68b4" patches: + "40": [] "38": - patch_file: "patches/0001-fix-SOLIB-path.patch" base_path: "source_subfolder" diff --git a/recipes/kcov/all/conanfile.py b/recipes/kcov/all/conanfile.py index 0bedd51a5d309..563b33b2f010e 100644 --- a/recipes/kcov/all/conanfile.py +++ b/recipes/kcov/all/conanfile.py @@ -1,8 +1,8 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conans import CMake, tools from conans.errors import ConanInvalidConfiguration - class KcovConan(ConanFile): name = "kcov" license = "GPL-2.0" @@ -14,9 +14,9 @@ class KcovConan(ConanFile): topics = ("coverage", "linux", "debug") settings = "os", "compiler", "build_type", "arch" exports_sources = "CMakeLists.txt", "patches/**" - requires = ["zlib/1.2.11", + requires = ["zlib/1.2.12", "libiberty/9.1.0", - "libcurl/7.64.1", + "libcurl/7.83.1", "elfutils/0.180"] generators = "cmake" _cmake = None @@ -60,3 +60,4 @@ def package_info(self): self.output.info("Appending PATH environment variable: {}" .format(bindir)) self.env_info.PATH.append(bindir) + self.cpp_info.includedirs = [] diff --git a/recipes/kcov/all/test_package/conanfile.py b/recipes/kcov/all/test_package/conanfile.py index 95206a24f9239..ea5ad0c50ed3e 100644 --- a/recipes/kcov/all/test_package/conanfile.py +++ b/recipes/kcov/all/test_package/conanfile.py @@ -1,5 +1,3 @@ -import os - from conans import ConanFile, tools diff --git a/recipes/kcov/config.yml b/recipes/kcov/config.yml index 6d8412928d7b7..b36ca0e497b00 100644 --- a/recipes/kcov/config.yml +++ b/recipes/kcov/config.yml @@ -1,3 +1,5 @@ versions: + "40": + folder: all "38": - folder: "all" + folder: all diff --git a/recipes/kcp/all/conanfile.py b/recipes/kcp/all/conanfile.py index b573442b562fd..ea23c3a999a55 100644 --- a/recipes/kcp/all/conanfile.py +++ b/recipes/kcp/all/conanfile.py @@ -1,6 +1,8 @@ from conans import ConanFile, CMake, tools import os +required_conan_version = ">=1.33.0" + class KcpConan(ConanFile): name = "kcp" @@ -42,8 +44,8 @@ def configure(self): del self.settings.compiler.cppstd def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("kcp-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: diff --git a/recipes/kcp/all/test_package/CMakeLists.txt b/recipes/kcp/all/test_package/CMakeLists.txt index ee11610bc04ae..d5b08913be93b 100644 --- a/recipes/kcp/all/test_package/CMakeLists.txt +++ b/recipes/kcp/all/test_package/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(kcp REQUIRED CONFIG) diff --git a/recipes/kcp/all/test_package/conanfile.py b/recipes/kcp/all/test_package/conanfile.py index 732d6db31a2f8..f8eeed898d7bd 100644 --- a/recipes/kcp/all/test_package/conanfile.py +++ b/recipes/kcp/all/test_package/conanfile.py @@ -1,5 +1,5 @@ +from conans import ConanFile, CMake, tools import os -from conans import ConanFile, CMake class TestPackageConan(ConanFile): @@ -12,4 +12,5 @@ def build(self): cmake.build() def test(self): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if not tools.cross_building(self.settings): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/keychain/all/conanfile.py b/recipes/keychain/all/conanfile.py index 9e12ba214998d..d6ff7829ddf3c 100644 --- a/recipes/keychain/all/conanfile.py +++ b/recipes/keychain/all/conanfile.py @@ -11,6 +11,8 @@ class KeychainConan(ConanFile): settings = "os", "arch", "compiler", "build_type" exports_sources = ["CMakeLists.txt"] generators = "cmake", "pkg_config" + options = {'fPIC': [False, True]} + default_options = {'fPIC': True} @property def _source_subfolder(self): @@ -20,6 +22,10 @@ def configure(self): if self.settings.compiler.cppstd: tools.check_min_cppstd(self, 11) + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + def requirements(self): if self.settings.os == "Linux": self.requires("libsecret/0.20.4") diff --git a/recipes/khrplatform/all/conandata.yml b/recipes/khrplatform/all/conandata.yml new file mode 100644 index 0000000000000..f72ccbe3528fa --- /dev/null +++ b/recipes/khrplatform/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20200529": + url: "https://github.com/KhronosGroup/EGL-Registry/raw/f636b23410dd4db5055dffbe499f4754013759d5/api/KHR/khrplatform.h" + sha256: "e206a6931f98ffe1c5c7ece69c4f94bbe1c9279243f40cbe7782848a0d3fa2de" diff --git a/recipes/khrplatform/all/conanfile.py b/recipes/khrplatform/all/conanfile.py new file mode 100644 index 0000000000000..4125f97c39bdb --- /dev/null +++ b/recipes/khrplatform/all/conanfile.py @@ -0,0 +1,43 @@ +from conan import ConanFile +from conan.tools.files import copy, download, load, save +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class KhrplatformConan(ConanFile): + name = "khrplatform" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.khronos.org/registry/EGL/" + description = "Khronos EGL platform interfaces" + topics = ("opengl", "gl", "egl", "khr", "khronos") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def source(self): + download(self, filename="khrplatform.h", **self.conan_data["sources"][self.version]) + + def build(self): + pass + + def _extract_license(self): + license_data = load(self, os.path.join(self.source_folder, "khrplatform.h")) + begin = license_data.find("/*") + len("/*") + end = license_data.find("*/") + return license_data[begin:end].replace("**", "") + + def package(self): + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license()) + copy(self, "khrplatform.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include", "KHR")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/khrplatform/all/test_package/CMakeLists.txt b/recipes/khrplatform/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..34fae3a337730 --- /dev/null +++ b/recipes/khrplatform/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(khrplatform REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE khrplatform::khrplatform) diff --git a/recipes/khrplatform/all/test_package/conanfile.py b/recipes/khrplatform/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/khrplatform/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/khrplatform/all/test_package/test_package.c b/recipes/khrplatform/all/test_package/test_package.c new file mode 100644 index 0000000000000..54e5982027830 --- /dev/null +++ b/recipes/khrplatform/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include +#include +#include + +int main() +{ + khronos_int32_t value = KHRONOS_TRUE; + printf("KHRONOS_TRUE: %d\n", value); + return EXIT_SUCCESS; +} diff --git a/recipes/khrplatform/all/test_v1_package/CMakeLists.txt b/recipes/khrplatform/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/khrplatform/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/khrplatform/all/test_v1_package/conanfile.py b/recipes/khrplatform/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/khrplatform/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/khrplatform/config.yml b/recipes/khrplatform/config.yml new file mode 100644 index 0000000000000..2690f821c7da8 --- /dev/null +++ b/recipes/khrplatform/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20200529": + folder: "all" diff --git a/recipes/kissfft/all/CMakeLists.txt b/recipes/kissfft/all/CMakeLists.txt deleted file mode 100644 index 4d9b94cd529bf..0000000000000 --- a/recipes/kissfft/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(cmake_wrapper) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/kissfft/all/conanfile.py b/recipes/kissfft/all/conanfile.py index 915f57b02100e..203d563a1ced5 100644 --- a/recipes/kissfft/all/conanfile.py +++ b/recipes/kissfft/all/conanfile.py @@ -1,5 +1,9 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.47.0" class KissfftConan(ConanFile): @@ -8,32 +12,23 @@ class KissfftConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/mborgerding/kissfft" description = "a Fast Fourier Transform (FFT) library that tries to Keep it Simple, Stupid" - topics = ("conan", "fft", "kiss", "frequency-domain", "fast-fourier-transform") + topics = ("fft", "kiss", "frequency-domain", "fast-fourier-transform") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "datatype": ["float", "double", "int16_t", "int32_t", "simd"], "openmp": [True, False], - "use_alloca": [True, False] + "use_alloca": [True, False], } default_options = { "shared": False, "fPIC": True, "datatype": "float", "openmp": False, - "use_alloca": False + "use_alloca": False, } - exports_sources = ["CMakeLists.txt"] - generators = "cmake", - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def config_options(self): if self.settings.os == "Windows": @@ -42,47 +37,80 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass - def _configure_cmake(self): - if self._cmake: - return self._cmake - cmake = CMake(self) - cmake.definitions["KISSFFT_PKGCONFIG"] = False - cmake.definitions["KISSFFT_STATIC"] = not self.options.shared - cmake.definitions["KISSFFT_TEST"] = False - cmake.definitions["KISSFFT_TOOLS"] = False - cmake.definitions["KISSFFT_DATATYPE"] = self.options.datatype - cmake.definitions["KISSFFT_OPENMP"] = self.options.openmp - cmake.definitions["KISSFFT_USE_ALLOCA"] = self.options.use_alloca - cmake.configure() - self._cmake = cmake - return self._cmake + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["KISSFFT_PKGCONFIG"] = False + tc.variables["KISSFFT_STATIC"] = not self.options.shared + tc.variables["KISSFFT_TEST"] = False + tc.variables["KISSFFT_TOOLS"] = False + tc.variables["KISSFFT_DATATYPE"] = self.options.datatype + tc.variables["KISSFFT_OPENMP"] = self.options.openmp + tc.variables["KISSFFT_USE_ALLOCA"] = self.options.use_alloca + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): lib_name = "kissfft-{datatype}{openmp}".format( datatype=self.options.datatype, - openmp="-openmp" if self.options.openmp else "" + openmp="-openmp" if self.options.openmp else "", ) - self.cpp_info.names["cmake_find_package"] = "kissfft" - self.cpp_info.names["cmake_find_package_multi"] = "kissfft" - self.cpp_info.names["pkg_config"] = lib_name - self.cpp_info.components["libkissfft"].names["cmake_find_package"] = lib_name - self.cpp_info.components["libkissfft"].names["cmake_find_package_multi"] = lib_name - self.cpp_info.components["libkissfft"].names["pkg_config"] = lib_name + + self.cpp_info.set_property("cmake_file_name", "kissfft") + self.cpp_info.set_property("cmake_target_name", "kissfft::kissfft") + self.cpp_info.set_property("cmake_target_aliases", [f"kissfft::{lib_name}"]) + self.cpp_info.set_property("pkg_config_name", lib_name) + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["libkissfft"].includedirs.append(os.path.join("include", "kissfft")) self.cpp_info.components["libkissfft"].libs = [lib_name] + + # got to duplicate the logic from kissfft/CMakeLists.txt + if self.options.datatype in ["float", "double"]: + self.cpp_info.components["libkissfft"].defines.append(f"kiss_fft_scalar={self.options.datatype}") + elif self.options.datatype == "int16_t": + self.cpp_info.components["libkissfft"].defines.append("FIXED_POINT=16") + elif self.options.datatype == "int32_t": + self.cpp_info.components["libkissfft"].defines.append("FIXED_POINT=32") + elif self.options.datatype == "simd": + self.cpp_info.components["libkissfft"].defines.append("USE_SIMD") + + if self.options.use_alloca: + self.cpp_info.components["libkissfft"].defines.append("KISS_FFT_USE_ALLOCA") + if self.options.shared: self.cpp_info.components["libkissfft"].defines.append("KISS_FFT_SHARED") - if self.settings.os == "Linux": + + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libkissfft"].system_libs = ["m"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["pkg_config"] = lib_name + self.cpp_info.components["libkissfft"].names["cmake_find_package"] = lib_name + self.cpp_info.components["libkissfft"].names["cmake_find_package_multi"] = lib_name + self.cpp_info.components["libkissfft"].set_property("cmake_target_name", "kissfft::kissfft") + self.cpp_info.components["libkissfft"].set_property("pkg_config_name", lib_name) diff --git a/recipes/kissfft/all/test_package/CMakeLists.txt b/recipes/kissfft/all/test_package/CMakeLists.txt index 33ae887aa6aea..71865c254e395 100644 --- a/recipes/kissfft/all/test_package/CMakeLists.txt +++ b/recipes/kissfft/all/test_package/CMakeLists.txt @@ -1,9 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(kissfft REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE kissfft::kissfft) diff --git a/recipes/kissfft/all/test_package/conanfile.py b/recipes/kissfft/all/test_package/conanfile.py index 1d0bdd3779793..3a8c6c5442b33 100644 --- a/recipes/kissfft/all/test_package/conanfile.py +++ b/recipes/kissfft/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/kissfft/all/test_package/test_package.c b/recipes/kissfft/all/test_package/test_package.c new file mode 100644 index 0000000000000..f3592a535fe9a --- /dev/null +++ b/recipes/kissfft/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include + +#include + +int main() +{ + printf("kiss_fft_next_fast_size(1) = %i\n", kiss_fft_next_fast_size(1)); + return 0; +} diff --git a/recipes/kissfft/all/test_package/test_package.cpp b/recipes/kissfft/all/test_package/test_package.cpp deleted file mode 100644 index 09558a6c18585..0000000000000 --- a/recipes/kissfft/all/test_package/test_package.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include - -int main() -{ - std::cout << "kiss_fft_next_fast_size(1) = " << kiss_fft_next_fast_size(1) << std::endl; - return EXIT_SUCCESS; -} diff --git a/recipes/kissfft/all/test_v1_package/CMakeLists.txt b/recipes/kissfft/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..8aafff4327842 --- /dev/null +++ b/recipes/kissfft/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(kissfft REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE kissfft::kissfft) diff --git a/recipes/kissfft/all/test_v1_package/conanfile.py b/recipes/kissfft/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/kissfft/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/kitten/all/conandata.yml b/recipes/kitten/all/conandata.yml index ff9df5046b2f1..dcc23d90b8201 100644 --- a/recipes/kitten/all/conandata.yml +++ b/recipes/kitten/all/conandata.yml @@ -1,7 +1,7 @@ sources: - "0.0.1": - sha256: 6627bf4f5baad3be1ebb9c904b0a13fc67d9211f8c874ecab7f05cc38da3d083 - url: https://github.com/rvarago/kitten/archive/0.0.1.tar.gz "0.1.0": - sha256: fe04a3f58cd521effef2503ac6137eac37684d2d442034e9d19d77a2a01afd57 - url: https://github.com/rvarago/kitten/archive/0.1.0.tar.gz + url: "https://github.com/rvarago/kitten/archive/0.1.0.tar.gz" + sha256: "fe04a3f58cd521effef2503ac6137eac37684d2d442034e9d19d77a2a01afd57" + "0.0.1": + url: "https://github.com/rvarago/kitten/archive/0.0.1.tar.gz" + sha256: "6627bf4f5baad3be1ebb9c904b0a13fc67d9211f8c874ecab7f05cc38da3d083" diff --git a/recipes/kitten/all/conanfile.py b/recipes/kitten/all/conanfile.py index 0bb6b6ff0861c..7db05a55fbcac 100644 --- a/recipes/kitten/all/conanfile.py +++ b/recipes/kitten/all/conanfile.py @@ -1,9 +1,9 @@ from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration -from conans.tools import Version -import os.path +import os + +required_conan_version = ">=1.43.0" -required_conan_version = ">=1.28.0" class KittenConan(ConanFile): name = "kitten" @@ -12,35 +12,49 @@ class KittenConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" license = "MIT" topics = ("category-theory", "composition", "monadic-interface", "declarative-programming") + + settings = "os", "arch", "compiler", "build_type" + + no_copy_source = True exports_sources = "CMakeLists.txt" generators = "cmake" - no_copy_source = True - settings = "os", "compiler", "build_type", "arch" - _cmake = None @property def _source_subfolder(self): return "source_subfolder" - def _has_support_for_cpp17(self): - supported_compilers = [("apple-clang", 10), ("clang", 5), ("gcc", 7), ("Visual Studio", 15.7)] - compiler, version = self.settings.compiler, Version(self.settings.compiler.version) - return any(compiler == sc[0] and version >= sc[1] for sc in supported_compilers) + @property + def _minimum_compilers_version(self): + return { + "gcc": "7", + "clang": "5", + "Visual Studio": "15.7", + "apple-clang": "10", + } - def configure(self): - if self.settings.compiler.cppstd: + def validate(self): + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, 17) - if not self._has_support_for_cpp17(): - raise ConanInvalidConfiguration("Kitten requires support for C++17") + + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if min_version and loose_lt_semver(str(self.settings.compiler.version), min_version): + raise ConanInvalidConfiguration( + "{} requires C++17, which your compiler does not support.".format(self.name) + ) def package_id(self): self.info.header_only() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -61,9 +75,14 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "kitten") + self.cpp_info.set_property("cmake_target_name", "rvarago::kitten") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.filenames["cmake_find_package"] = "kitten" self.cpp_info.filenames["cmake_find_package_multi"] = "kitten" self.cpp_info.names["cmake_find_package"] = "rvarago" self.cpp_info.names["cmake_find_package_multi"] = "rvarago" self.cpp_info.components["libkitten"].names["cmake_find_package"] = "kitten" self.cpp_info.components["libkitten"].names["cmake_find_package_multi"] = "kitten" + self.cpp_info.components["libkitten"].set_property("cmake_target_name", "rvarago::kitten") diff --git a/recipes/kitten/all/test_package/CMakeLists.txt b/recipes/kitten/all/test_package/CMakeLists.txt index 9ce552d101d13..60b5b3b426db6 100644 --- a/recipes/kitten/all/test_package/CMakeLists.txt +++ b/recipes/kitten/all/test_package/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.8) project(test_package LANGUAGES CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(kitten REQUIRED CONFIG) diff --git a/recipes/kitten/all/test_package/conanfile.py b/recipes/kitten/all/test_package/conanfile.py index 7e2dfe859bb27..38f4483872d47 100644 --- a/recipes/kitten/all/test_package/conanfile.py +++ b/recipes/kitten/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/kitten/config.yml b/recipes/kitten/config.yml index ae8774c1d5872..fb992cd538525 100644 --- a/recipes/kitten/config.yml +++ b/recipes/kitten/config.yml @@ -1,5 +1,5 @@ versions: - "0.0.1": - folder: all "0.1.0": folder: all + "0.0.1": + folder: all diff --git a/recipes/kmod/all/conandata.yml b/recipes/kmod/all/conandata.yml new file mode 100644 index 0000000000000..adea0f2044a1e --- /dev/null +++ b/recipes/kmod/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "30": + url: "https://github.com/kmod-project/kmod/archive/v30.tar.gz" + sha256: "1fa3974abd80b992d61324bcc04fa65ea96cfe2e9e1150f48394833030c4b583" + "29": + sha256: "a49aaf9c4914cd1abd9eea43d86b5a2fd07d898935e088965e6d18793610f2e7" + url: "https://github.com/kmod-project/kmod/archive/refs/tags/v29.tar.gz" diff --git a/recipes/kmod/all/conanfile.py b/recipes/kmod/all/conanfile.py new file mode 100644 index 0000000000000..26122c967dc44 --- /dev/null +++ b/recipes/kmod/all/conanfile.py @@ -0,0 +1,113 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import copy, get, rm, rmdir, save +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.53.0" + + +class KModConan(ConanFile): + name = "kmod" + description = "linux kernel module handling library" + topics = ("libkmod", "linux", "kernel", "module") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/kmod-project/kmod" + license = "LGPL-2.1-only" + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + "with_zstd": [True, False], + "with_xz": [True, False], + "with_zlib": [True, False], + "with_openssl": [True, False], + "experimental": [True, False], + "logging": [True, False], + } + default_options = { + "fPIC": True, + "with_zstd": True, + "with_xz": True, + "with_zlib": True, + "with_openssl": True, + "experimental": False, + "logging": False, + } + + def configure(self): + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_zstd: + self.requires("zstd/1.5.2") + if self.options.with_xz: + self.requires("xz_utils/5.2.5") + if self.options.with_zlib: + self.requires("zlib/1.2.13") + if self.options.with_openssl: + self.requires("openssl/3.0.7") + + def validate(self): + if self.info.settings.os != "Linux": + raise ConanInvalidConfiguration("kmod is Linux-only!") + + def build_requirements(self): + self.tool_requires("libtool/2.4.7") + self.tool_requires("pkgconf/1.9.3") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") + + yes_no = lambda v: "yes" if v else "no" + tc = AutotoolsToolchain(self) + tc.configure_args.append("--with-zstd=%s" % yes_no(self.options.with_zstd)) + tc.configure_args.append("--with-xz=%s" % yes_no(self.options.with_xz)) + tc.configure_args.append("--with-zlib=%s" % yes_no(self.options.with_zlib)) + tc.configure_args.append("--with-openssl=%s" % yes_no(self.options.with_openssl)) + tc.configure_args.append("--enable-experimental=%s" % yes_no(self.options.experimental)) + tc.configure_args.append("--enable-logging=%s" % yes_no(self.options.logging)) + tc.configure_args.append("--enable-debug=%s" % yes_no(self.settings.build_type == "Debug")) + tc.configure_args.append("--enable-tools=no") + tc.configure_args.append("--enable-manpages=no") + tc.configure_args.append("--enable-test-modules=no") + tc.configure_args.append("--enable-python=no") + tc.configure_args.append("--enable-coverage=no") + tc.generate() + tc = PkgConfigDeps(self) + tc.generate() + tc = AutotoolsDeps(self) + tc.generate() + + def build(self): + save(self, os.path.join(self.source_folder, "libkmod", "docs", "gtk-doc.make"), "") + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libkmod") + self.cpp_info.libs = ["kmod"] + self.cpp_info.system_libs = ["pthread"] diff --git a/recipes/kmod/all/test_package/CMakeLists.txt b/recipes/kmod/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fb2eee3127d3e --- /dev/null +++ b/recipes/kmod/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(kmod REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE kmod::kmod) diff --git a/recipes/kmod/all/test_package/conanfile.py b/recipes/kmod/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/kmod/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/kmod/all/test_package/test_package.c b/recipes/kmod/all/test_package/test_package.c new file mode 100644 index 0000000000000..227ead0ea1cd1 --- /dev/null +++ b/recipes/kmod/all/test_package/test_package.c @@ -0,0 +1,23 @@ +#include +#include +#include "libkmod.h" + +int main(int argc, char * argv[]) +{ + struct kmod_ctx *ctx = kmod_new(NULL, NULL); + if (ctx) + { + struct kmod_list * list, * mod; + if (kmod_module_new_from_loaded(ctx, &list) >= 0) + { + kmod_list_foreach(mod, list) + { + struct kmod_module *kmod = kmod_module_get_module(mod); + printf("%s\n", kmod_module_get_name(kmod)); + } + kmod_module_unref_list(list); + } + kmod_unref(ctx); + } + return EXIT_SUCCESS; +} diff --git a/recipes/kmod/all/test_v1_package/CMakeLists.txt b/recipes/kmod/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/kmod/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/kmod/all/test_v1_package/conanfile.py b/recipes/kmod/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/kmod/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/kmod/config.yml b/recipes/kmod/config.yml new file mode 100644 index 0000000000000..61353908a11fc --- /dev/null +++ b/recipes/kmod/config.yml @@ -0,0 +1,5 @@ +versions: + "30": + folder: all + "29": + folder: all diff --git a/recipes/ktx/all/conandata.yml b/recipes/ktx/all/conandata.yml index d463f4dc1284d..955ee1b7c0556 100644 --- a/recipes/ktx/all/conandata.yml +++ b/recipes/ktx/all/conandata.yml @@ -8,3 +8,5 @@ patches: base_path: "source_subfolder" - patch_file: "patches/0002-lodepng-no-export-symbols.patch" base_path: "source_subfolder" + - patch_file: "patches/0003-clamp-include-algorithm.patch" + base_path: "source_subfolder" diff --git a/recipes/ktx/all/conanfile.py b/recipes/ktx/all/conanfile.py index f3e548cd893a5..b476c62299b82 100644 --- a/recipes/ktx/all/conanfile.py +++ b/recipes/ktx/all/conanfile.py @@ -1,14 +1,14 @@ from conans import ConanFile, CMake, tools import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.43.0" class KtxConan(ConanFile): name = "ktx" description = "Khronos Texture library and tool." license = "Apache-2.0" - topics = ("conan", "ktx", "texture", "khronos") + topics = ("ktx", "texture", "khronos") homepage = "https://github.com/KhronosGroup/KTX-Software" url = "https://github.com/conan-io/conan-center-index" @@ -26,7 +26,6 @@ class KtxConan(ConanFile): "tools": True, } - exports_sources = ["CMakeLists.txt", "patches/**"] generators = "cmake" _cmake = None @@ -38,6 +37,11 @@ def _source_subfolder(self): def _has_sse_support(self): return self.settings.arch in ["x86", "x86_64"] + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -50,12 +54,14 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) def requirements(self): self.requires("lodepng/cci.20200615") - self.requires("zstd/1.4.9") + self.requires("zstd/1.5.0") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) def source(self): tools.get(**self.conan_data["sources"][self.version], @@ -97,8 +103,7 @@ def _configure_cmake(self): self._cmake.definitions["KTX_FEATURE_LOADTEST_APPS"] = False self._cmake.definitions["KTX_FEATURE_STATIC_LIBRARY"] = not self.options.shared self._cmake.definitions["KTX_FEATURE_TESTS"] = False - if self._has_sse_support: - self._cmake.definitions["BASISU_SUPPORT_SSE"] = self.options.sse + self._cmake.definitions["BASISU_SUPPORT_SSE"] = self.options.get_safe("sse", False) self._cmake.configure() return self._cmake @@ -110,12 +115,16 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Ktx") + self.cpp_info.set_property("cmake_target_name", "KTX::ktx") + self.cpp_info.filenames["cmake_find_package"] = "Ktx" self.cpp_info.filenames["cmake_find_package_multi"] = "Ktx" self.cpp_info.names["cmake_find_package"] = "KTX" self.cpp_info.names["cmake_find_package_multi"] = "KTX" self.cpp_info.components["libktx"].names["cmake_find_package"] = "ktx" self.cpp_info.components["libktx"].names["cmake_find_package_multi"] = "ktx" + self.cpp_info.components["libktx"].libs = ["ktx"] self.cpp_info.components["libktx"].defines = [ "KTX_FEATURE_KTX1", "KTX_FEATURE_KTX2", "KTX_FEATURE_WRITE" diff --git a/recipes/ktx/all/patches/0003-clamp-include-algorithm.patch b/recipes/ktx/all/patches/0003-clamp-include-algorithm.patch new file mode 100644 index 0000000000000..8ac2fc8e9c6db --- /dev/null +++ b/recipes/ktx/all/patches/0003-clamp-include-algorithm.patch @@ -0,0 +1,23 @@ +from https://github.com/KhronosGroup/KTX-Software/pull/422 + +--- a/utils/ktxapp.h ++++ b/utils/ktxapp.h +@@ -5,6 +5,9 @@ + // SPDX-License-Identifier: Apache-2.0 + + #include ++#if (_MSVC_LANG >= 201703L || __cplusplus >= 201703L) ++#include ++#endif + #include + #include + +@@ -24,7 +27,7 @@ + using namespace std; + + // clamp is in std:: from c++17. +-#if ((defined(_MSVC_LANG) && _MSVC_LANG < 201703L) || __cplusplus < 201703L) ++#if !(_MSVC_LANG >= 201703L || __cplusplus >= 201703L) + template inline T clamp(T value, T low, T high) { + return (value < low) ? low : ((value > high) ? high : value); + } diff --git a/recipes/ktx/all/test_package/conanfile.py b/recipes/ktx/all/test_package/conanfile.py index 2042b14d6f254..8bf8322cf17d1 100644 --- a/recipes/ktx/all/test_package/conanfile.py +++ b/recipes/ktx/all/test_package/conanfile.py @@ -12,7 +12,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") ktx_path = os.path.join(self.source_folder, "etc1.ktx") self.run("{} {}".format(bin_path, ktx_path), run_environment=True) diff --git a/recipes/kuba-zip/all/conandata.yml b/recipes/kuba-zip/all/conandata.yml index c6e718d0e8173..687b00ee7e238 100644 --- a/recipes/kuba-zip/all/conandata.yml +++ b/recipes/kuba-zip/all/conandata.yml @@ -1,4 +1,22 @@ sources: + "0.2.6": + url: "https://github.com/kuba--/zip/archive/v0.2.6.tar.gz" + sha256: "6a00e10dc5242f614f76f1bd1d814726a41ee6e3856ef3caf7c73de0b63acf0b" + "0.2.5": + url: "https://github.com/kuba--/zip/archive/v0.2.5.tar.gz" + sha256: "e052f6cbe6713f69f8caec61214fda4e5ae5150d1fcba02c9e79f1a05d939305" + "0.2.4": + url: "https://github.com/kuba--/zip/archive/v0.2.4.tar.gz" + sha256: "a3dd762129d58c7ca7a6462f509d29388dbdb25bec559cb4dc03f75523d69cf2" + "0.2.3": + url: "https://github.com/kuba--/zip/archive/v0.2.3.tar.gz" + sha256: "800e9dc2d2834d92ad333dac29b438dfb495c765bc4e97c7b10101f4f22d53d4" + "0.2.2": + url: "https://github.com/kuba--/zip/archive/refs/tags/v0.2.2.tar.gz" + sha256: "f278b1da5e5382c7a1a1db1502cfa1f6df6b1e05e36253d661344d30277f9895" + "0.2.0": + url: "https://github.com/kuba--/zip/archive/refs/tags/v0.2.0.tar.gz" + sha256: "59ee52b717933b90ea1fff53d5381b612bab8ffbcb3b5f65d2cdfd0814b3068a" "0.1.31": url: "https://github.com/kuba--/zip/archive/refs/tags/v0.1.31.tar.gz" sha256: "65ad5e63497e48ee773fdec86a4c36752a92e53da9cd8da4f1f77b5d743794f1" diff --git a/recipes/kuba-zip/all/conanfile.py b/recipes/kuba-zip/all/conanfile.py index b07029be8319e..f2b2cdbf10c1b 100644 --- a/recipes/kuba-zip/all/conanfile.py +++ b/recipes/kuba-zip/all/conanfile.py @@ -1,7 +1,9 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file, rmdir import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.47.0" class ZipConan(ConanFile): @@ -10,7 +12,7 @@ class ZipConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/kuba--/zip" description = "A portable, simple zip library written in C" - topics = ("conan", "zip", "compression", "c", "miniz", "portable", "hacking") + topics = ("zip", "compression", "c", "miniz", "portable", "hacking") settings = "os", "arch", "compiler", "build_type" options = { @@ -22,14 +24,6 @@ class ZipConan(ConanFile): "fPIC": True, } - exports_sources = "CMakeLists.txt" - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -37,37 +31,51 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - cmake = CMake(self) - cmake.definitions["CMAKE_DISABLE_TESTING"] = True - cmake.definitions["ZIP_STATIC_PIC"] = self.options.get_safe("fPIC", True) - cmake.definitions["ZIP_BUILD_DOCS"] = False - cmake.configure() - self._cmake = cmake - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMAKE_DISABLE_TESTING"] = True + tc.variables["ZIP_STATIC_PIC"] = self.options.get_safe("fPIC", True) + tc.variables["ZIP_BUILD_DOCS"] = False + tc.generate() + + def _patch_sources(self): + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "-Werror", "") def build(self): - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("UNLICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "UNLICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "zip") + self.cpp_info.set_property("cmake_target_name", "zip::zip") + self.cpp_info.names["cmake_find_package"] = "zip" self.cpp_info.names["cmake_find_package_multi"] = "zip" + self.cpp_info.libs = ["zip"] if self.options.shared: self.cpp_info.defines.append("ZIP_SHARED") diff --git a/recipes/kuba-zip/all/test_package/CMakeLists.txt b/recipes/kuba-zip/all/test_package/CMakeLists.txt index 50d29c7ed4363..e346717f7b6ff 100644 --- a/recipes/kuba-zip/all/test_package/CMakeLists.txt +++ b/recipes/kuba-zip/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(zip REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} zip::zip) +target_link_libraries(${PROJECT_NAME} PRIVATE zip::zip) diff --git a/recipes/kuba-zip/all/test_package/conanfile.py b/recipes/kuba-zip/all/test_package/conanfile.py index a9f777f7680ff..d120a992c06a6 100644 --- a/recipes/kuba-zip/all/test_package/conanfile.py +++ b/recipes/kuba-zip/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/kuba-zip/all/test_v1_package/CMakeLists.txt b/recipes/kuba-zip/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4bc4ff0d96e4b --- /dev/null +++ b/recipes/kuba-zip/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(zip REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE zip::zip) diff --git a/recipes/kuba-zip/all/test_v1_package/conanfile.py b/recipes/kuba-zip/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/kuba-zip/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/kuba-zip/config.yml b/recipes/kuba-zip/config.yml index 3c1dba10fd889..7244cf3b53ff7 100644 --- a/recipes/kuba-zip/config.yml +++ b/recipes/kuba-zip/config.yml @@ -1,3 +1,15 @@ versions: + "0.2.6": + folder: "all" + "0.2.5": + folder: "all" + "0.2.4": + folder: "all" + "0.2.3": + folder: "all" + "0.2.2": + folder: "all" + "0.2.0": + folder: "all" "0.1.31": folder: "all" diff --git a/recipes/laszip/all/CMakeLists.txt b/recipes/laszip/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/laszip/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/laszip/all/conandata.yml b/recipes/laszip/all/conandata.yml index 385d9e5d3226d..4f7409d4b12f0 100644 --- a/recipes/laszip/all/conandata.yml +++ b/recipes/laszip/all/conandata.yml @@ -2,3 +2,7 @@ sources: "3.4.3": url: "https://github.com/LASzip/LASzip/archive/3.4.3.tar.gz" sha256: "862715affa00609b78b4f469ab5529fee659c597efd40b5006b4305dd56c22d3" +patches: + "3.4.3": + - patch_file: "patches/0001-no-build-laszip-api.patch" + - patch_file: "patches/0002-no-rpath-and-relocatable-macos.patch" diff --git a/recipes/laszip/all/conanfile.py b/recipes/laszip/all/conanfile.py index a8e1f300fbca3..0550e96992ca8 100644 --- a/recipes/laszip/all/conanfile.py +++ b/recipes/laszip/all/conanfile.py @@ -1,61 +1,74 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.scm import Version +from conans import tools as tools_legacy import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" + class LaszipConan(ConanFile): name = "laszip" description = "C++ library for lossless LiDAR compression." license = "LGPL-2.1" - topics = ("conan", "laszip", "las", "laz", "lidar", "compression", "decompression") + topics = ("laszip", "las", "laz", "lidar", "compression", "decompression") homepage = "https://github.com/LASzip/LASzip" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "CMakeLists.txt" - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("LASzip-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LASZIP_BUILD_STATIC"] = not self.options.shared + tc.generate() def build(self): - # Do not build laszip_api, only laszip - tools.replace_in_file(os.path.join(self._source_subfolder, "dll", "CMakeLists.txt"), - "LASZIP_ADD_LIBRARY(${LASZIP_API_LIB_NAME} ${LASZIP_API_SOURCES})", "") - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["LASZIP_BUILD_STATIC"] = not self.options.shared - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + suffix = Version(self.version).major if self.settings.os == "Windows" else "" + self.cpp_info.libs = [f"laszip{suffix}"] if self.options.shared: self.cpp_info.defines.append("LASZIP_DYN_LINK") - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["m"] + else: + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + libcxx = tools_legacy.stdcpp_library(self) + if libcxx: + self.cpp_info.system_libs.append(libcxx) diff --git a/recipes/laszip/all/patches/0001-no-build-laszip-api.patch b/recipes/laszip/all/patches/0001-no-build-laszip-api.patch new file mode 100644 index 0000000000000..b8fb1f96ec6fc --- /dev/null +++ b/recipes/laszip/all/patches/0001-no-build-laszip-api.patch @@ -0,0 +1,9 @@ +--- a/dll/CMakeLists.txt ++++ b/dll/CMakeLists.txt +@@ -3,6 +3,5 @@ set(LASZIP_API_SOURCES + laszip_api.c + ) + +-LASZIP_ADD_LIBRARY(${LASZIP_API_LIB_NAME} ${LASZIP_API_SOURCES}) + LASZIP_ADD_INCLUDES("laszip" "${LASZIP_HEADERS_DIR}/laszip_api.h" ${LASZIP_API_VERSION_H}) + diff --git a/recipes/laszip/all/patches/0002-no-rpath-and-relocatable-macos.patch b/recipes/laszip/all/patches/0002-no-rpath-and-relocatable-macos.patch new file mode 100644 index 0000000000000..68022a79a6394 --- /dev/null +++ b/recipes/laszip/all/patches/0002-no-rpath-and-relocatable-macos.patch @@ -0,0 +1,29 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -80,15 +80,11 @@ file(MAKE_DIRECTORY "${LASZIP_OUTPUT_BIN_DIR}") + # per http://www.cmake.org/Wiki/CMake_RPATH_handling + SET(CMAKE_SKIP_BUILD_RPATH FALSE) + SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +-SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + IF (APPLE) + SET(MACOSX_RPATH ON) + endif() + LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES + "${CMAKE_INSTALL_PREFIX}/${LASZIP_LIB_INSTALL_DIR}" isSystemDir) +-IF("${isSystemDir}" STREQUAL "-1") +- SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LASZIP_LIB_INSTALL_DIR}") +-ENDIF("${isSystemDir}" STREQUAL "-1") + + # wipe lib/ drectory on clean. It will have plugins that could be out of date + # in the next build +--- a/cmake/macros.cmake ++++ b/cmake/macros.cmake +@@ -71,8 +71,6 @@ macro(LASZIP_ADD_LIBRARY _name) + LIBRARY DESTINATION ${LASZIP_LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${LASZIP_LIB_INSTALL_DIR}) + if (APPLE) +- set_target_properties(${_name} PROPERTIES INSTALL_NAME_DIR +- "@executable_path/../lib") + endif() + endmacro(LASZIP_ADD_LIBRARY) + diff --git a/recipes/laszip/all/test_package/CMakeLists.txt b/recipes/laszip/all/test_package/CMakeLists.txt index 310ad26d06f9d..2732324131a2f 100644 --- a/recipes/laszip/all/test_package/CMakeLists.txt +++ b/recipes/laszip/all/test_package/CMakeLists.txt @@ -1,9 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(laszip REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) +target_link_libraries(${PROJECT_NAME} PRIVATE laszip::laszip) diff --git a/recipes/laszip/all/test_package/conanfile.py b/recipes/laszip/all/test_package/conanfile.py index ea57a464900be..3a8c6c5442b33 100644 --- a/recipes/laszip/all/test_package/conanfile.py +++ b/recipes/laszip/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/laszip/all/test_v1_package/CMakeLists.txt b/recipes/laszip/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..399dd5e75aa15 --- /dev/null +++ b/recipes/laszip/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(laszip REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE laszip::laszip) diff --git a/recipes/laszip/all/test_v1_package/conanfile.py b/recipes/laszip/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/laszip/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lcms/all/conandata.yml b/recipes/lcms/all/conandata.yml index 19413ff9057fc..55991f5faffdb 100644 --- a/recipes/lcms/all/conandata.yml +++ b/recipes/lcms/all/conandata.yml @@ -1,10 +1,19 @@ sources: - "2.9": - url: "https://github.com/mm2/Little-CMS/archive/lcms2.9.tar.gz" - sha256: "8e23a09dc81af856db37941a4ea26acdf6a45b0281ec5b7ee94b5a4e9f7afbf7" - "2.10": - url: "https://github.com/mm2/Little-CMS/archive/lcms2.10.tar.gz" - sha256: "f7529f90f0a9c7529c561a2c681043c10f2d30b78e6728fb44132828f89b666a" + "2.14": + url: "https://github.com/mm2/Little-CMS/archive/lcms2.14.tar.gz" + sha256: "05869269f14e589b0b6d05a76f510c68c67fabb304904d16c6bd818abec80a83" + "2.13.1": + url: "https://github.com/mm2/Little-CMS/archive/refs/tags/lcms2.13.1.tar.gz" + sha256: "6f84c942ecde1b4852b5a051894502ac8c98d010acb3400dec958c6db1bc94ef" + "2.12": + url: "https://github.com/mm2/Little-CMS/archive/2.12.tar.gz" + sha256: "e501f1482fc424550ef3abbf86bf1c66090e1661249e89552d39ed5bf935df66" "2.11": url: "https://github.com/mm2/Little-CMS/archive/2.11.tar.gz" sha256: "478c9c3938d7a91b1171de4616f8b04308a8676d73eadc19505b7ace41327f28" + "2.10": + url: "https://github.com/mm2/Little-CMS/archive/lcms2.10.tar.gz" + sha256: "f7529f90f0a9c7529c561a2c681043c10f2d30b78e6728fb44132828f89b666a" + "2.9": + url: "https://github.com/mm2/Little-CMS/archive/lcms2.9.tar.gz" + sha256: "8e23a09dc81af856db37941a4ea26acdf6a45b0281ec5b7ee94b5a4e9f7afbf7" diff --git a/recipes/lcms/all/conanfile.py b/recipes/lcms/all/conanfile.py index 0ac1a28d1fb55..e73dd6770d2e0 100644 --- a/recipes/lcms/all/conanfile.py +++ b/recipes/lcms/all/conanfile.py @@ -1,7 +1,9 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment, MSBuild import os +import re +import shutil -from conans import ConanFile, tools, AutoToolsBuildEnvironment, MSBuild -from conans.tools import Version +required_conan_version = ">=1.36.0" class LcmsConan(ConanFile): @@ -10,10 +12,17 @@ class LcmsConan(ConanFile): description = "A free, open source, CMM engine." license = "MIT" homepage = "https://github.com/mm2/Little-CMS" - topics = ("conan", "lcms", "cmm", "icc", "cmm-engine") + topics = ("lcms", "cmm", "icc", "cmm-engine") + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } _autotools = None @@ -21,6 +30,18 @@ class LcmsConan(ConanFile): def _source_subfolder(self): return "source_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -32,61 +53,87 @@ def configure(self): del self.settings.compiler.cppstd def build_requirements(self): - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio" and \ - not tools.get_env("CONAN_BASH_PATH") and tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20200517") + if not self._is_msvc: + self.build_requires("gnu-config/cci.20201022") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - if os.path.isdir("Little-CMS-lcms%s" % self.version): - os.rename("Little-CMS-lcms%s" % self.version, self._source_subfolder) - else: - os.rename("Little-CMS-%s" % self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _patch_sources(self): - if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "14": + compiler_version = tools.Version(self.settings.compiler.version) + if (self.settings.compiler == "Visual Studio" and compiler_version >= "14") or \ + str(self.settings.compiler) == "msvc": # since VS2015 vsnprintf is built-in path = os.path.join(self._source_subfolder, "src", "lcms2_internal.h") tools.replace_in_file(path, "# define vsnprintf _vsnprintf", "") - if self.settings.os == "Android" and tools.os_info.is_windows: + if (self.settings.compiler == "Visual Studio" and compiler_version >= "16") or \ + (str(self.settings.compiler) == "msvc" and compiler_version >= "192"): + # since VS2019, don't need to specify the WindowsTargetPlatformVersion + path = os.path.join(self._source_subfolder, "Projects", "VC2015", "lcms2_static", "lcms2_static.vcxproj") + tools.replace_in_file(path, "8.1", "") + if self.settings.os == "Android" and self._settings_build.os == "Windows": # remove escape for quotation marks, to make ndk on windows happy tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), "s/[ `~#$^&*(){}\\\\|;'\\\''\"<>?]/\\\\&/g", "s/[ `~#$^&*(){}\\\\|;<>?]/\\\\&/g") def _build_visual_studio(self): - with tools.chdir(os.path.join(self._source_subfolder, "Projects", "VC2013")): + if tools.Version(self.version) <= "2.11": + vc_sln_subdir = "VC2013" + else: + vc_sln_subdir = "VC2015" + with tools.chdir(os.path.join(self._source_subfolder, "Projects", vc_sln_subdir )): target = "lcms2_DLL" if self.options.shared else "lcms2_static" - upgrade_project = Version(self.settings.compiler.version) > "12" + if self.settings.compiler == "Visual Studio" and \ + tools.Version(self.settings.compiler.version) <= "12": + upgrade_project = False + else: + upgrade_project = True + # Enable LTO when CFLAGS contains -GL + if any(re.finditer("(^| )[/-]GL($| )", tools.get_env("CFLAGS", ""))): + lto = "true" + else: + lto = "false" + properties = { + "WholeProgramOptimization": lto, + } # run build msbuild = MSBuild(self) - msbuild.build("lcms2.sln", targets=[target], platforms={"x86": "Win32"}, upgrade_project=upgrade_project) + msbuild.build("lcms2.sln", targets=[target], platforms={"x86": "Win32"}, + upgrade_project=upgrade_project, properties=properties) def _configure_autotools(self): if self._autotools: return self._autotools self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - args = [] - if self.options.shared: - args.extend(["--disable-static", "--enable-shared"]) - else: - args.extend(["--disable-shared", "--enable-static"]) - args.append("--without-tiff") - args.append("--without-jpeg") + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--without-tiff", + "--without-jpeg", + ] self._autotools.configure(args=args, configure_dir=self._source_subfolder) return self._autotools def build(self): self._patch_sources() - if self.settings.compiler == "Visual Studio": + if self._is_msvc: self._build_visual_studio() else: + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) autotools = self._configure_autotools() autotools.make() def package(self): self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - if self.settings.compiler == "Visual Studio": + if self._is_msvc: self.copy(pattern="*.h", src=os.path.join(self._source_subfolder, "include"), dst="include", keep_path=True) if self.options.shared: self.copy(pattern="*.lib", src=os.path.join(self._source_subfolder, "bin"), dst="lib", keep_path=False) @@ -97,29 +144,22 @@ def package(self): else: autotools = self._configure_autotools() autotools.install() - # remove entire share directory tools.rmdir(os.path.join(self.package_folder, "share")) - # remove pkgconfig tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - # remove la files - la = os.path.join(self.package_folder, "lib", "liblcms2.la") - if os.path.isfile(la): - os.unlink(la) - # remove binaries - for bin_program in ["tificc", "linkicc", "transicc", "psicc", "jpgicc"]: - for ext in ["", ".exe"]: - try: - os.remove(os.path.join(self.package_folder, "bin", bin_program + ext)) - except: - pass + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + # remove utilities + if self.settings.os == "Windows" and self.options.shared: + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*[!.dll]") + else: + tools.rmdir(os.path.join(self.package_folder, "bin")) def package_info(self): - if self.settings.compiler == "Visual Studio": - self.cpp_info.libs = ["lcms2" if self.options.shared else "lcms2_static"] - if self.options.shared: - self.cpp_info.defines.append("CMS_DLL") - else: - self.cpp_info.libs = ["lcms2"] - self.cpp_info.names["pkg_config"] = "lcms2" - if self.settings.os == "Linux": + self.cpp_info.set_property("pkg_config_name", "lcms2") + suffix = "_static" if self._is_msvc and not self.options.shared else "" + self.cpp_info.libs = ["lcms2{}".format(suffix)] + if self._is_msvc and self.options.shared: + self.cpp_info.defines.append("CMS_DLL") + if self.settings.os in ("FreeBSD", "Linux"): self.cpp_info.system_libs.append("m") + + self.cpp_info.names["pkg_config"] = "lcms2" diff --git a/recipes/lcms/all/test_package/CMakeLists.txt b/recipes/lcms/all/test_package/CMakeLists.txt index 34af13462f44f..7b9b613cbb24a 100644 --- a/recipes/lcms/all/test_package/CMakeLists.txt +++ b/recipes/lcms/all/test_package/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() diff --git a/recipes/lcms/all/test_package/conanfile.py b/recipes/lcms/all/test_package/conanfile.py index bd7165a553cf4..d4128b0450777 100644 --- a/recipes/lcms/all/test_package/conanfile.py +++ b/recipes/lcms/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/lcms/config.yml b/recipes/lcms/config.yml index 89a8569f88571..82126a56f46e6 100644 --- a/recipes/lcms/config.yml +++ b/recipes/lcms/config.yml @@ -1,7 +1,13 @@ versions: - "2.9": + "2.14": folder: all - "2.10": + "2.13.1": + folder: all + "2.12": folder: all "2.11": folder: all + "2.10": + folder: all + "2.9": + folder: all diff --git a/recipes/ldns/all/conandata.yml b/recipes/ldns/all/conandata.yml new file mode 100644 index 0000000000000..a5e4b6259dffa --- /dev/null +++ b/recipes/ldns/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.8.1": + url: "https://nlnetlabs.nl/downloads/ldns/ldns-1.8.1.tar.gz" + sha256: "958229abce4d3aaa19a75c0d127666564b17216902186e952ca4aef47c6d7fa3" diff --git a/recipes/ldns/all/conanfile.py b/recipes/ldns/all/conanfile.py new file mode 100644 index 0000000000000..d942fc9b22eb7 --- /dev/null +++ b/recipes/ldns/all/conanfile.py @@ -0,0 +1,119 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + + +class LdnsConan(ConanFile): + name = "ldns" + license = "BSD-3-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.nlnetlabs.nl/projects/ldns" + description = "LDNS is a DNS library that facilitates DNS tool programming" + topics = ("dns") + + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("Windows is not supported by the ldns recipe. Contributions are welcome.") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def requirements(self): + self.requires("openssl/1.1.1o") + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + + def yes_no(v): return "yes" if v else "no" + args = [ + # libraries + f"--enable-shared={yes_no(self.options.shared)}", + f"--enable-static={yes_no(not self.options.shared)}", + f"--with-pic={yes_no(self.settings.os != 'Windows' and (self.options.shared or self.options.fPIC))}", + "--disable-rpath", + # dependencies + f"--with-ssl={self.deps_cpp_info['openssl'].rootpath}", + # DNSSEC algorithm support + "--enable-ecdsa", + "--enable-ed25519", + "--enable-ed448", + "--disable-dsa", + "--disable-gost", + "--enable-full-dane", + # tooling + "--disable-ldns-config", + "--without-drill", + "--without-examples", + # library bindings + "--without-pyldns", + "--without-p5-dns-ldns", + ] + if self.settings.compiler == "apple-clang": + args.append(f"--with-xcode-sdk={tools.XCRun(self.settings).sdk_version}") + + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + + # This fixes the issue of linking against ldns in combination of openssl:shared=False, ldns:shared=True, and an older GCC: + # > hidden symbol `pthread_atfork' in /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a(pthread_atfork.oS) is referenced by DSO + # OpenSSL adds -lpthread to link POSIX thread library explicitly. That is not correct because using the library + # may require setting various on compilation as well. The compiler has a dedicated -pthread option for that. + if self.settings.os == "Linux": + self._autotools.libs.remove("pthread") + env = self._autotools.vars + env["CFLAGS"] += " -pthread" + else: + env = None + + self._autotools.configure(configure_dir=self._source_subfolder, args=args, vars=env) + return self._autotools + + def build(self): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + autotools = self._configure_autotools() + for target in ["install-h", "install-lib"]: + autotools.make(target=target) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + + def package_info(self): + self.cpp_info.libs = ["ldns"] diff --git a/recipes/ldns/all/test_package/CMakeLists.txt b/recipes/ldns/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a7ad4d67ebd49 --- /dev/null +++ b/recipes/ldns/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest C) + +find_package(PkgConfig) +pkg_check_modules(LDNS REQUIRED "ldns") + +add_executable(example example.c) +target_include_directories(example PUBLIC ${LDNS_INCLUDE_DIRS}) +target_link_libraries(example PUBLIC ${LDNS_LDFLAGS}) diff --git a/recipes/ldns/all/test_package/conanfile.py b/recipes/ldns/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e6e81c8ee4894 --- /dev/null +++ b/recipes/ldns/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "pkg_config" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join(".", "example")) diff --git a/recipes/ldns/all/test_package/example.c b/recipes/ldns/all/test_package/example.c new file mode 100644 index 0000000000000..59b8be97c822b --- /dev/null +++ b/recipes/ldns/all/test_package/example.c @@ -0,0 +1,46 @@ +#include +#include + +static ldns_rr_list *rrset_from_str(const char *str) +{ + ldns_rr *rr = NULL; + if (ldns_rr_new_frm_str(&rr, str, 0, NULL, NULL) != LDNS_STATUS_OK) { + return NULL; + } + + ldns_rr_list *rrset = ldns_rr_list_new(); + if (rrset == NULL) { + ldns_rr_free(rr); + return NULL; + } + + if (!ldns_rr_list_push_rr(rrset, rr)) { + ldns_rr_free(rr); + ldns_rr_list_deep_free(rrset); + return NULL; + } + + return rrset; +} + + +int main(int argc, char *argv[]) +{ + ldns_rr_list *data = rrset_from_str("nlnetlabs.nl. 240 IN AAAA 2a04:b900::1:0:0:10"); + ldns_rr_list *rrsigs = rrset_from_str("nlnetlabs.nl. 240 IN RRSIG AAAA 8 2 240 20210316015010 20210216015010 42393 nlnetlabs.nl. sZ24Gr6kcWVUMU+pFsoEiW+R7TeE2f3g9EcuIq3Rh+aA38ZslHIv41fFjN9KdfQOdivHlgZ+d6cvhJfXczaHHYRTpLdvkz6s/mbJ7z+NnvpJdQa7g1qWXD6f2rHyC0TjyV15divsK+aogSs/xXuRZfUlPxqe5Lrwtaxp0r471GU="); + ldns_rr_list *dnskeys = rrset_from_str("nlnetlabs.nl. 3205 IN DNSKEY 256 3 8 AwEAAdR7XR95OaAN9Rz7TbtPalQ9guQk7zfxTHYNKhsiwTZA9z+F16nD0VeBlk7dNik3ETpT2GLAwr9sntG898JwurCDe353wHPvjZtMCdiTVp3cRCrjuCEvoFpmZNN82H0gaH/4v8mkv/QBDAkDSncYjz/FqHKAeYy3cMcjY6RyVweh"); + + int ret = ldns_verify_notime(data, rrsigs, dnskeys, NULL); + + ldns_rr_list_deep_free(data); + ldns_rr_list_deep_free(rrsigs); + ldns_rr_list_deep_free(dnskeys); + + if (ret != LDNS_STATUS_OK) { + printf("failed\n"); + return 1; + } + + printf("ok\n"); + return 0; +} diff --git a/recipes/ldns/config.yml b/recipes/ldns/config.yml new file mode 100644 index 0000000000000..c3578038cb2a3 --- /dev/null +++ b/recipes/ldns/config.yml @@ -0,0 +1,3 @@ +versions: + "1.8.1": + folder: all diff --git a/recipes/lemon/all/CMakeLists.txt b/recipes/lemon/all/CMakeLists.txt index 4492f0ecd9346..b3566d9546bb6 100644 --- a/recipes/lemon/all/CMakeLists.txt +++ b/recipes/lemon/all/CMakeLists.txt @@ -5,5 +5,5 @@ include(conanbuildinfo.cmake) conan_basic_setup() add_executable(lemon source_subfolder/tool/lemon.c) -install(TARGETS lemon RUNTIME DESTINATION bin) +install(TARGETS lemon DESTINATION bin) install(FILES source_subfolder/tool/lempar.c DESTINATION bin) diff --git a/recipes/lemon/all/conanfile.py b/recipes/lemon/all/conanfile.py index 1e66d803a3913..c627284798121 100644 --- a/recipes/lemon/all/conanfile.py +++ b/recipes/lemon/all/conanfile.py @@ -1,5 +1,7 @@ -import os from conans import CMake, ConanFile, tools +import os + +required_conan_version = ">=1.33.0" class LemonConan(ConanFile): @@ -24,11 +26,8 @@ def configure(self): del self.settings.compiler.cppstd def source(self): - tools.get(**self.conan_data["sources"][self.version]) - url = self.conan_data["sources"][self.version]["url"] - archive_name = os.path.basename(url) - archive_name = os.path.splitext(archive_name)[0] - os.rename(archive_name, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: diff --git a/recipes/leptonica/all/CMakeLists.txt b/recipes/leptonica/all/CMakeLists.txt deleted file mode 100644 index bd3083b512cb9..0000000000000 --- a/recipes/leptonica/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/leptonica/all/conandata.yml b/recipes/leptonica/all/conandata.yml index 814fee7be2213..452eea8cdafea 100644 --- a/recipes/leptonica/all/conandata.yml +++ b/recipes/leptonica/all/conandata.yml @@ -1,14 +1,19 @@ sources: - "1.78.0": - url: "https://github.com/DanBloomberg/leptonica/archive/1.78.0.tar.gz" - sha256: "f8ac4d93cc76b524c2c81d27850bfc342e68b91368aa7a1f7d69e34ce13adbb4" - "1.79.0": - url: "https://github.com/DanBloomberg/leptonica/archive/1.79.0.tar.gz" - sha256: "bf9716f91a4844c2682a07ef21eaf68b6f1077af1f63f27c438394fd66218e17" + "1.82.0": + url: "https://github.com/DanBloomberg/leptonica/archive/1.82.0.tar.gz" + sha256: "40fa9ac1e815b91e0fa73f0737e60c9eec433a95fa123f95f2573dd3127dd669" + "1.81.0": + url: "https://github.com/DanBloomberg/leptonica/archive/1.81.0.tar.gz" + sha256: "70ebc04ff8b9684205bd1d01843c635a8521255b74813bf7cce9a33368f7952c" "1.80.0": url: "https://github.com/DanBloomberg/leptonica/archive/1.80.0.tar.gz" sha256: "3952b974ec057d24267aae48c54bca68ead8275604bf084a73a4b953ff79196e" + "1.79.0": + url: "https://github.com/DanBloomberg/leptonica/archive/1.79.0.tar.gz" + sha256: "bf9716f91a4844c2682a07ef21eaf68b6f1077af1f63f27c438394fd66218e17" + "1.78.0": + url: "https://github.com/DanBloomberg/leptonica/archive/1.78.0.tar.gz" + sha256: "f8ac4d93cc76b524c2c81d27850bfc342e68b91368aa7a1f7d69e34ce13adbb4" patches: "1.78.0": - patch_file: "patches/fix-find-modules-variables.patch" - base_path: "source_subfolder" diff --git a/recipes/leptonica/all/conanfile.py b/recipes/leptonica/all/conanfile.py index 360d0436c15f8..399ac8b097d48 100644 --- a/recipes/leptonica/all/conanfile.py +++ b/recipes/leptonica/all/conanfile.py @@ -1,8 +1,14 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, replace_in_file, rmdir, save +from conan.tools.gnu import PkgConfigDeps +from conan.tools.scm import Version import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.52.0" class LeptonicaConan(ConanFile): @@ -10,7 +16,7 @@ class LeptonicaConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" description = "Library containing software that is broadly useful for " \ "image processing and image analysis applications." - topics = ("conan", "leptonica", "image", "multimedia", "format", "graphics") + topics = ("leptonica", "image", "multimedia", "format", "graphics") homepage = "http://leptonica.org" license = "BSD 2-Clause" @@ -20,201 +26,220 @@ class LeptonicaConan(ConanFile): "fPIC": [True, False], "with_zlib": [True, False], "with_gif": [True, False], - "with_jpeg": [True, False], + "with_jpeg": [False, "libjpeg", "libjpeg-turbo"], "with_png": [True, False], "with_tiff": [True, False], "with_openjpeg": [True, False], - "with_webp": [True, False] + "with_webp": [True, False], } default_options = { "shared": False, "fPIC": True, "with_zlib": True, "with_gif": True, - "with_jpeg": True, + "with_jpeg": "libjpeg", "with_png": True, "with_tiff": True, "with_openjpeg": True, - "with_webp": True + "with_webp": True, } - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package", "pkg_config" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): + if self.options.with_tiff: + self.options["libtiff"].jpeg = self.options.with_jpeg if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.with_gif: self.requires("giflib/5.2.1") - if self.options.with_jpeg: - self.requires("libjpeg/9d") + if self.options.with_jpeg == "libjpeg": + self.requires("libjpeg/9e") + if self.options.with_jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/2.1.4") if self.options.with_png: - self.requires("libpng/1.6.37") + self.requires("libpng/1.6.38") if self.options.with_tiff: - self.requires("libtiff/4.2.0") + self.requires("libtiff/4.4.0") if self.options.with_openjpeg: - self.requires("openjpeg/2.4.0") + self.requires("openjpeg/2.5.0") if self.options.with_webp: - self.requires("libwebp/1.1.0") + self.requires("libwebp/1.2.4") + + def validate(self): + libtiff = self.dependencies["libtiff"] + if libtiff.options.jpeg != self.info.options.with_jpeg: + raise ConanInvalidConfiguration(f"{self.ref} requires option value {self.name}:with_jpeg equal to libtiff:jpeg.") def build_requirements(self): if self.options.with_webp or self.options.with_openjpeg: - self.build_requires("pkgconf/1.7.3") + self.tool_requires("pkgconf/1.9.3") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) < "1.79.0": + tc.variables["STATIC"] = not self.options.shared + tc.variables["BUILD_PROG"] = False + tc.variables["SW_BUILD"] = False + tc.generate() + deps = CMakeDeps(self) + deps.generate() + if self.options.with_webp or self.options.with_openjpeg: + pc = PkgConfigDeps(self) + pc.generate() + env = VirtualBuildEnv(self) + env.generate() + # TODO: to remove when properly handled by conan (see https://github.com/conan-io/conan/issues/11962) + env = Environment() + env.prepend_path("PKG_CONFIG_PATH", self.generators_folder) + env.vars(self).save_script("conanbuildenv_pkg_config_path") def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) - cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") - cmakelists_src = os.path.join(self._source_subfolder, "src", "CMakeLists.txt") - cmake_configure = os.path.join(self._source_subfolder, "cmake", "Configure.cmake") - - # Fix installation - tools.replace_in_file(cmakelists_src, "${CMAKE_BINARY_DIR}", "${PROJECT_BINARY_DIR}") + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + cmakelists_src = os.path.join(self.source_folder, "src", "CMakeLists.txt") + cmake_configure = os.path.join(self.source_folder, "cmake", "Configure.cmake") # Honor options and inject dependencies definitions # TODO: submit a patch upstream ## zlib - tools.replace_in_file(cmakelists_src, "${ZLIB_LIBRARIES}", "ZLIB::ZLIB") + replace_in_file(self, cmakelists_src, "${ZLIB_LIBRARIES}", "ZLIB::ZLIB") if not self.options.with_zlib: - tools.replace_in_file(cmakelists_src, "if (ZLIB_LIBRARIES)", "if(0)") - tools.replace_in_file(cmake_configure, "if (ZLIB_FOUND)", "if(0)") + replace_in_file(self, cmakelists_src, "if (ZLIB_LIBRARIES)", "if(0)") + replace_in_file(self, cmake_configure, "if (ZLIB_FOUND)", "if(0)") ## giflib - tools.replace_in_file(cmakelists_src, "${GIF_LIBRARIES}", "GIF::GIF") + replace_in_file(self, cmakelists_src, "${GIF_LIBRARIES}", "GIF::GIF") if not self.options.with_gif: - tools.replace_in_file(cmakelists_src, "if (GIF_LIBRARIES)", "if(0)") - tools.replace_in_file(cmake_configure, "if (GIF_FOUND)", "if(0)") + replace_in_file(self, cmakelists_src, "if (GIF_LIBRARIES)", "if(0)") + replace_in_file(self, cmake_configure, "if (GIF_FOUND)", "if(0)") ## libjpeg - tools.replace_in_file(cmakelists_src, "${JPEG_LIBRARIES}", "JPEG::JPEG") + replace_in_file(self, cmakelists_src, "${JPEG_LIBRARIES}", "JPEG::JPEG") if not self.options.with_jpeg: - tools.replace_in_file(cmakelists_src, "if (JPEG_LIBRARIES)", "if(0)") - tools.replace_in_file(cmake_configure, "if (JPEG_FOUND)", "if(0)") + replace_in_file(self, cmakelists_src, "if (JPEG_LIBRARIES)", "if(0)") + replace_in_file(self, cmake_configure, "if (JPEG_FOUND)", "if(0)") ## libpng - tools.replace_in_file(cmakelists_src, "${PNG_LIBRARIES}", "PNG::PNG") + replace_in_file(self, cmakelists_src, "${PNG_LIBRARIES}", "PNG::PNG") if not self.options.with_png: - tools.replace_in_file(cmakelists_src, "if (PNG_LIBRARIES)", "if(0)") - tools.replace_in_file(cmake_configure, "if (PNG_FOUND)", "if(0)") + replace_in_file(self, cmakelists_src, "if (PNG_LIBRARIES)", "if(0)") + replace_in_file(self, cmake_configure, "if (PNG_FOUND)", "if(0)") ## libtiff - tools.replace_in_file(cmakelists_src, "${TIFF_LIBRARIES}", "TIFF::TIFF") + replace_in_file(self, cmakelists_src, "${TIFF_LIBRARIES}", "TIFF::TIFF") if not self.options.with_tiff: - tools.replace_in_file(cmakelists_src, "if (TIFF_LIBRARIES)", "if(0)") - tools.replace_in_file(cmake_configure, "if (TIFF_FOUND)", "if(0)") + replace_in_file(self, cmakelists_src, "if (TIFF_LIBRARIES)", "if(0)") + replace_in_file(self, cmake_configure, "if (TIFF_FOUND)", "if(0)") ## We have to be more aggressive with dependencies found with pkgconfig ## Injection of libdirs is ensured by conan_basic_setup() ## openjpeg - tools.replace_in_file(cmakelists, "if(NOT JP2K)", "if(0)") - tools.replace_in_file(cmakelists_src, + replace_in_file(self, cmakelists, "if(NOT JP2K)", "if(0)") + replace_in_file(self, cmakelists_src, "if (JP2K_FOUND)", "if (JP2K_FOUND)\n" + "target_link_directories(leptonica PRIVATE ${JP2K_LIBRARY_DIRS})\n" "target_compile_definitions(leptonica PRIVATE ${JP2K_CFLAGS_OTHER})") if not self.options.with_openjpeg: - tools.replace_in_file(cmakelists_src, "if (JP2K_FOUND)", "if(0)") - tools.replace_in_file(cmake_configure, "if (JP2K_FOUND)", "if(0)") + replace_in_file(self, cmakelists_src, "if (JP2K_FOUND)", "if(0)") + replace_in_file(self, cmake_configure, "if (JP2K_FOUND)", "if(0)") ## libwebp - tools.replace_in_file(cmakelists, "if(NOT WEBP)", "if(0)") - tools.replace_in_file(cmakelists_src, + replace_in_file(self, cmakelists, "if(NOT WEBP)", "if(0)") + replace_in_file(self, cmakelists_src, "if (WEBP_FOUND)", "if (WEBP_FOUND)\n" + "target_link_directories(leptonica PRIVATE ${WEBP_LIBRARY_DIRS} ${WEBPMUX_LIBRARY_DIRS})\n" "target_compile_definitions(leptonica PRIVATE ${WEBP_CFLAGS_OTHER} ${WEBPMUX_CFLAGS_OTHER})") - tools.replace_in_file(cmakelists_src, "${WEBP_LIBRARIES}", "${WEBP_LIBRARIES} ${WEBPMUX_LIBRARIES}") - if tools.Version(self.version) >= "1.79.0": - tools.replace_in_file(cmakelists, "if(NOT WEBPMUX)", "if(0)") + replace_in_file(self, cmakelists_src, "${WEBP_LIBRARIES}", "${WEBP_LIBRARIES} ${WEBPMUX_LIBRARIES}") + if Version(self.version) >= "1.79.0": + replace_in_file(self, cmakelists, "if(NOT WEBPMUX)", "if(0)") if not self.options.with_webp: - tools.replace_in_file(cmakelists_src, "if (WEBP_FOUND)", "if(0)") - tools.replace_in_file(cmake_configure, "if (WEBP_FOUND)", "if(0)") + replace_in_file(self, cmakelists_src, "if (WEBP_FOUND)", "if(0)") + replace_in_file(self, cmake_configure, "if (WEBP_FOUND)", "if(0)") # Remove detection of fmemopen() on macOS < 10.13 # CheckFunctionExists will find it in the link library. # There's no error because it's not including the header with the # deprecation macros. if self.settings.os == "Macos" and self.settings.os.version: - if tools.Version(self.settings.os.version) < "10.13": - tools.replace_in_file(cmake_configure, + if Version(self.settings.os.version) < "10.13": + replace_in_file(self, cmake_configure, "set(functions_list\n " "fmemopen\n fstatat\n)", "set(functions_list\n " "fstatat\n)") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - if tools.Version(self.version) < "1.79.0": - self._cmake.definitions["STATIC"] = not self.options.shared - self._cmake.definitions["BUILD_PROG"] = False - self._cmake.definitions["SW_BUILD"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - self.copy(pattern="leptonica-license.txt", dst="licenses", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "cmake")) + copy(self, "leptonica-license.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) # since 1.81.0 + rmdir(self, os.path.join(self.package_folder, "cmake")) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {"leptonica": "Leptonica::Leptonica"} ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + """) + save(self, module_file, content) @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.set_property("cmake_file_name", "Leptonica") + self.cpp_info.set_property("cmake_target_name", "leptonica") + self.cpp_info.set_property("pkg_config_name", "lept") + self.cpp_info.libs = collect_libs(self) + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] + self.cpp_info.includedirs.append(os.path.join("include", "leptonica")) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.names["cmake_find_package"] = "Leptonica" self.cpp_info.names["cmake_find_package_multi"] = "Leptonica" - self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] self.cpp_info.names["pkg_config"] = "lept" - self.cpp_info.includedirs.append(os.path.join("include", "leptonica")) diff --git a/recipes/leptonica/all/test_package/CMakeLists.txt b/recipes/leptonica/all/test_package/CMakeLists.txt index 4b216b1756f75..b498b89f556d8 100644 --- a/recipes/leptonica/all/test_package/CMakeLists.txt +++ b/recipes/leptonica/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(Leptonica REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} leptonica) +target_link_libraries(${PROJECT_NAME} PRIVATE leptonica) diff --git a/recipes/leptonica/all/test_package/conanfile.py b/recipes/leptonica/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/leptonica/all/test_package/conanfile.py +++ b/recipes/leptonica/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/leptonica/all/test_v1_package/CMakeLists.txt b/recipes/leptonica/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f86c2a9f99016 --- /dev/null +++ b/recipes/leptonica/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Leptonica REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE leptonica) diff --git a/recipes/leptonica/all/test_v1_package/conanfile.py b/recipes/leptonica/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/leptonica/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/leptonica/config.yml b/recipes/leptonica/config.yml index 773abaa5dc4ae..eb5d4ef99b906 100644 --- a/recipes/leptonica/config.yml +++ b/recipes/leptonica/config.yml @@ -1,7 +1,11 @@ versions: - "1.78.0": + "1.82.0": folder: all - "1.79.0": + "1.81.0": folder: all "1.80.0": folder: all + "1.79.0": + folder: all + "1.78.0": + folder: all diff --git a/recipes/lerc/all/CMakeLists.txt b/recipes/lerc/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/lerc/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/lerc/all/conandata.yml b/recipes/lerc/all/conandata.yml index a57cf7532b6a9..f1d58df7a46b7 100644 --- a/recipes/lerc/all/conandata.yml +++ b/recipes/lerc/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "4.0.0": + url: "https://github.com/Esri/lerc/archive/refs/tags/v4.0.0.tar.gz" + sha256: "91431c2b16d0e3de6cbaea188603359f87caed08259a645fd5a3805784ee30a0" "2.2": url: "https://github.com/Esri/lerc/archive/v2.2.tar.gz" sha256: "abc0c5c149144d39a8b351ff5a9a5940c0f66ba908ecf717d58f8f71065d11fe" @@ -6,9 +9,15 @@ sources: url: "https://github.com/Esri/lerc/archive/v2.1.tar.gz" sha256: "7c48de40cd5f09319de4b39c417ff4eec4ad4b6aa5d6144f6ffa9b10d18ec94e" patches: + "4.0.0": + - patch_file: "patches/4.0.0-include-algorithm.patch" + patch_description: "include algorithm header for std::min/max" + patch_type: "portability" "2.2": - - patch_file: "patches/add-CMakeLists-and-static.patch" - base_path: "source_subfolder" + - patch_file: "patches/2.1-add-CMakeLists-and-static.patch" + patch_description: "create CMakeLists.txt, redefine LERCDLL_API for static build" + patch_type: "conan" "2.1": - - patch_file: "patches/add-CMakeLists-and-static.patch" - base_path: "source_subfolder" + - patch_file: "patches/2.1-add-CMakeLists-and-static.patch" + patch_description: "create CMakeLists.txt, redefine LERCDLL_API for static build" + patch_type: "conan" diff --git a/recipes/lerc/all/conanfile.py b/recipes/lerc/all/conanfile.py index c5be4c5981e83..367095e05fd6b 100644 --- a/recipes/lerc/all/conanfile.py +++ b/recipes/lerc/all/conanfile.py @@ -1,57 +1,81 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import export_conandata_patches, apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.53.0" + class LercConan(ConanFile): name = "lerc" description = "C++ library for limited Error Raster Compression." license = "Apache-2.0" - topics = ("conan", "lerc", "lerclib", "compression", "decompression", "image", "raster") - homepage = "https://github.com/Esri/lerc" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + homepage = "https://github.com/Esri/lerc" + topics = ("lerc", "lerclib", "compression", "decompression", "image", "raster") settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } @property - def _source_subfolder(self): - return "source_subfolder" + def _min_cppstd(self): + return 11 - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() + if Version(self.version) >= "3.0": + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.libs = ["LercLib" if Version(self.version) < "4.0.0" else "Lerc"] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") + + if Version(self.version) >= "3.0": + self.cpp_info.set_property("pkg_config_name", "Lerc") + if not self.options.shared: + self.cpp_info.defines = ["LERC_STATIC"] diff --git a/recipes/lerc/all/patches/2.1-add-CMakeLists-and-static.patch b/recipes/lerc/all/patches/2.1-add-CMakeLists-and-static.patch new file mode 100644 index 0000000000000..8a5e59a7c1157 --- /dev/null +++ b/recipes/lerc/all/patches/2.1-add-CMakeLists-and-static.patch @@ -0,0 +1,61 @@ +--- /dev/null ++++ b/CMakeLists.txt +@@ -0,0 +1,24 @@ ++cmake_minimum_required(VERSION 3.8) ++project(Lerc) ++ ++file(GLOB SOURCES ++ "src/LercLib/*" ++ "src/LercLib/Lerc1Decode/*" ++) ++ ++add_library(LercLib ${SOURCES}) ++target_compile_features(LercLib PRIVATE cxx_std_11) ++if(BUILD_SHARED_LIBS) ++ set_target_properties(LercLib PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN TRUE) ++ if(WIN32) ++ target_compile_definitions(LercLib PRIVATE LERC_EXPORTS) ++ endif() ++endif() ++ ++set(HEADER_FILES include/Lerc_c_api.h include/Lerc_types.h) ++install(FILES ${HEADER_FILES} DESTINATION include) ++install(TARGETS LercLib ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++) +--- a/include/Lerc_c_api.h ++++ b/include/Lerc_c_api.h +@@ -28,13 +28,7 @@ Contributors: Thomas Maurer + extern "C" { + #endif + +-#if defined(_MSC_VER) +- #define LERCDLL_API __declspec(dllexport) +-#elif __GNUC__ >= 4 +- #define LERCDLL_API __attribute__((visibility("default"))) +-#else +- #define LERCDLL_API +-#endif ++#define LERCDLL_API + + + //! C-API for LERC library +--- a/src/LercLib/Lerc_c_api.h ++++ b/src/LercLib/Lerc_c_api.h +@@ -28,8 +28,12 @@ Contributors: Thomas Maurer + extern "C" { + #endif + +-#if defined(_MSC_VER) +- #define LERCDLL_API __declspec(dllexport) ++#ifdef _WIN32 ++ #ifdef LERC_EXPORTS ++ #define LERCDLL_API __declspec(dllexport) ++ #else ++ #define LERCDLL_API ++ #endif + #elif __GNUC__ >= 4 + #define LERCDLL_API __attribute__((visibility("default"))) + #else diff --git a/recipes/lerc/all/patches/4.0.0-include-algorithm.patch b/recipes/lerc/all/patches/4.0.0-include-algorithm.patch new file mode 100644 index 0000000000000..dea8f0292de5d --- /dev/null +++ b/recipes/lerc/all/patches/4.0.0-include-algorithm.patch @@ -0,0 +1,24 @@ +diff --git a/src/LercLib/fpl_EsriHuffman.cpp b/src/LercLib/fpl_EsriHuffman.cpp +index b72bd44..2f6ae7f 100644 +--- a/src/LercLib/fpl_EsriHuffman.cpp ++++ b/src/LercLib/fpl_EsriHuffman.cpp +@@ -28,6 +28,7 @@ Original coding 2021 Yuriy Yakimenko + #include + #include + #include ++#include + + USING_NAMESPACE_LERC + +diff --git a/src/LercLib/fpl_Lerc2Ext.cpp b/src/LercLib/fpl_Lerc2Ext.cpp +index b07104c..df184f5 100644 +--- a/src/LercLib/fpl_Lerc2Ext.cpp ++++ b/src/LercLib/fpl_Lerc2Ext.cpp +@@ -28,6 +28,7 @@ Original coding 2021 Yuriy Yakimenko + #include + #include + #include ++#include + + USING_NAMESPACE_LERC + diff --git a/recipes/lerc/all/patches/add-CMakeLists-and-static.patch b/recipes/lerc/all/patches/add-CMakeLists-and-static.patch deleted file mode 100644 index b134e632e8939..0000000000000 --- a/recipes/lerc/all/patches/add-CMakeLists-and-static.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- /dev/null -+++ b/CMakeLists.txt -@@ -0,0 +1,24 @@ -+cmake_minimum_required(VERSION 3.0.2) -+project(Lerc) -+ -+file(GLOB SOURCES -+ "src/LercLib/*" -+ "src/LercLib/Lerc1Decode/*" -+) -+ -+add_library(LercLib ${SOURCES}) -+set_property(TARGET LercLib PROPERTY CXX_STANDARD 11) -+if(BUILD_SHARED_LIBS) -+ set_property(TARGET LercLib PROPERTY CXX_VISIBILITY_PRESET hidden) -+ if(WIN32) -+ target_compile_definitions(LercLib PRIVATE LERC_EXPORTS) -+ endif() -+endif() -+ -+set(HEADER_FILES include/Lerc_c_api.h include/Lerc_types.h) -+install(FILES ${HEADER_FILES} DESTINATION include) -+install(TARGETS LercLib -+ RUNTIME DESTINATION bin -+ LIBRARY DESTINATION lib -+ ARCHIVE DESTINATION lib -+) ---- a/include/Lerc_c_api.h -+++ b/include/Lerc_c_api.h -@@ -28,13 +28,7 @@ Contributors: Thomas Maurer - extern "C" { - #endif - --#if defined(_MSC_VER) -- #define LERCDLL_API __declspec(dllexport) --#elif __GNUC__ >= 4 -- #define LERCDLL_API __attribute__((visibility("default"))) --#else -- #define LERCDLL_API --#endif -+#define LERCDLL_API - - - //! C-API for LERC library ---- a/src/LercLib/Lerc_c_api.h -+++ b/src/LercLib/Lerc_c_api.h -@@ -28,8 +28,12 @@ Contributors: Thomas Maurer - extern "C" { - #endif - --#if defined(_MSC_VER) -- #define LERCDLL_API __declspec(dllexport) -+#ifdef _WIN32 -+ #ifdef LERC_EXPORTS -+ #define LERCDLL_API __declspec(dllexport) -+ #else -+ #define LERCDLL_API -+ #endif - #elif __GNUC__ >= 4 - #define LERCDLL_API __attribute__((visibility("default"))) - #else diff --git a/recipes/lerc/all/test_package/CMakeLists.txt b/recipes/lerc/all/test_package/CMakeLists.txt index f1b77a1b4487a..50d07b3052d3e 100644 --- a/recipes/lerc/all/test_package/CMakeLists.txt +++ b/recipes/lerc/all/test_package/CMakeLists.txt @@ -1,8 +1,12 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(lerc REQUIRED CONFIG) add_executable(test_package test_package.cpp) -target_link_libraries(test_package ${CONAN_LIBS}) +target_link_libraries(test_package PRIVATE lerc::lerc) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +if(lerc_VERSION VERSION_GREATER_EQUAL "3.0") + target_compile_definitions(${PROJECT_NAME} PRIVATE -DLERC_VER3_LATER) +endif() diff --git a/recipes/lerc/all/test_package/conanfile.py b/recipes/lerc/all/test_package/conanfile.py index ea57a464900be..d120a992c06a6 100644 --- a/recipes/lerc/all/test_package/conanfile.py +++ b/recipes/lerc/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/lerc/all/test_package/test_package.cpp b/recipes/lerc/all/test_package/test_package.cpp index 5af4b7da62cfe..c399abcf8d219 100644 --- a/recipes/lerc/all/test_package/test_package.cpp +++ b/recipes/lerc/all/test_package/test_package.cpp @@ -55,7 +55,10 @@ void sample1() { lerc_status hr = lerc_computeCompressedSize(reinterpret_cast(&zImg[0]), // raw image data, row by row, band by band static_cast(dt_float), 1, w, h, 1, - &maskByteImg[0], // can give nullptr if all pixels are valid +#ifdef LERC_VER3_LATER + 1, +#endif + maskByteImg.data(), // can give nullptr if all pixels are valid maxZError, // max coding error per pixel, or precision &numBytesNeeded); // size of outgoing Lerc blob @@ -67,7 +70,10 @@ void sample1() { hr = lerc_encode(reinterpret_cast(&zImg[0]), // raw image data, row by row, band by band static_cast(dt_float), 1, w, h, 1, - &maskByteImg[0], // can give nullptr if all pixels are valid +#ifdef LERC_VER3_LATER + 1, +#endif + maskByteImg.data(), // can give nullptr if all pixels are valid maxZError, // max coding error per pixel, or precision &pLercBlob[0], // buffer to write to, function will fail if buffer too small numBytesBlob, // buffer size @@ -98,7 +104,11 @@ void sample1() { std::vector maskByteImg3(w * h); +#ifdef LERC_VER3_LATER + hr = lerc_decode(&pLercBlob[0], numBytesBlob, 1, maskByteImg3.data(), 1, w, h, 1, static_cast(dt_float), reinterpret_cast(&zImg3[0])); +#else hr = lerc_decode(&pLercBlob[0], numBytesBlob, &maskByteImg3[0], 1, w, h, 1, static_cast(dt_float), reinterpret_cast(&zImg3[0])); +#endif if (hr) std::cout << "lerc_decode(...) failed" << std::endl; @@ -124,88 +134,7 @@ void sample1() { std::cout << "max z error per pixel = " << maxDelta << std::endl; } -void sample2() { - const int h = 713; - const int w = 257; - - std::vector byteImg(3 * w * h); - - for (int k = 0, i = 0; i < h; i++) - for (int j = 0; j < w; j++, k++) - for (int m = 0; m < 3; m++) - byteImg[k * 3 + m] = std::rand() % 30; - - - // encode - - uint32 numBytesNeeded = 0; - uint32 numBytesWritten = 0; - - lerc_status hr = lerc_computeCompressedSize(reinterpret_cast(&byteImg[0]), // raw image data: nDim values per pixel, row by row, band by band - static_cast(dt_uchar), 3, w, h, 1, - 0, // can give nullptr if all pixels are valid - 0, // max coding error per pixel - &numBytesNeeded); // size of outgoing Lerc blob - - if (hr) - std::cout << "lerc_computeCompressedSize(...) failed" << std::endl; - - uint32 numBytesBlob = numBytesNeeded; - std::vector pLercBlob(numBytesBlob); - - hr = lerc_encode(reinterpret_cast(&byteImg[0]), // raw image data: nDim values per pixel, row by row, band by band - static_cast(dt_uchar), 3, w, h, 1, - 0, // can give nullptr if all pixels are valid - 0, // max coding error per pixel - &pLercBlob[0], // buffer to write to, function will fail if buffer too small - numBytesBlob, // buffer size - &numBytesWritten); // num bytes written to buffer - - if (hr) - std::cout << "lerc_encode(...) failed" << std::endl; - - double ratio = 3 * w * h / static_cast(numBytesBlob); - std::cout << "sample 2 compression ratio = " << ratio << std::endl; - - // decode - - uint32 infoArr[10]; - double dataRangeArr[3]; - hr = lerc_getBlobInfo(&pLercBlob[0], numBytesBlob, infoArr, dataRangeArr, 10, 3); - if (hr) - std::cout << "lerc_getBlobInfo(...) failed" << std::endl; - - BlobInfo_Print(infoArr); - - if (!BlobInfo_Equal(infoArr, 3, w, h, 1, static_cast(dt_uchar))) - std::cout << "got wrong lerc info" << std::endl; - - // new data storage - std::vector byteImg3(3 * w * h); - - hr = lerc_decode(&pLercBlob[0], numBytesBlob, 0, 3, w, h, 1, static_cast(dt_uchar), reinterpret_cast(&byteImg3[0])); - if (hr) - std::cout << "lerc_decode(...) failed" << std::endl; - - // compare to orig - - double maxDelta = 0; - for (int k = 0, i = 0; i < h; i++) - for (int j = 0; j < w; j++, k++) - for (int m = 0; m < 3; m++) - { - double delta = std::abs(byteImg3[k * 3 + m] - byteImg[k * 3 + m]); - if (delta > maxDelta) - maxDelta = delta; - } - - std::cout << "max z error per pixel = " << maxDelta << std::endl; -} - int main() { sample1(); - std::cout << std::endl; - sample2(); - std::cout << std::endl; return 0; } diff --git a/recipes/lerc/all/test_v1_package/CMakeLists.txt b/recipes/lerc/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/lerc/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/lerc/all/test_v1_package/conanfile.py b/recipes/lerc/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/lerc/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lerc/config.yml b/recipes/lerc/config.yml index 96c0b5a4124cb..6bcfdf0332e1f 100644 --- a/recipes/lerc/config.yml +++ b/recipes/lerc/config.yml @@ -1,4 +1,6 @@ versions: + "4.0.0": + folder: all "2.2": folder: all "2.1": diff --git a/recipes/leveldb/all/CMakeLists.txt b/recipes/leveldb/all/CMakeLists.txt deleted file mode 100644 index 361b35d4c17d9..0000000000000 --- a/recipes/leveldb/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/leveldb/all/conandata.yml b/recipes/leveldb/all/conandata.yml index de5608a61d6ae..904735bb768f7 100644 --- a/recipes/leveldb/all/conandata.yml +++ b/recipes/leveldb/all/conandata.yml @@ -1,4 +1,12 @@ sources: + "1.23": + sha256: 9a37f8a6174f09bd622bc723b55881dc541cd50747cbd08831c2a82d620f6d76 + url: https://github.com/google/leveldb/archive/1.23.tar.gz "1.22": sha256: 55423cac9e3306f4a9502c738a001e4a339d1a38ffbee7572d4a07d5d63949b2 url: https://github.com/google/leveldb/archive/1.22.tar.gz +patches: + "1.23": + - patch_file: "patches/check_library_exists.1.23.patch" + "1.22": + - patch_file: "patches/check_library_exists.1.22.patch" diff --git a/recipes/leveldb/all/conanfile.py b/recipes/leveldb/all/conanfile.py index 2bd2f42f87cc3..7aefd15a7bf6f 100644 --- a/recipes/leveldb/all/conanfile.py +++ b/recipes/leveldb/all/conanfile.py @@ -1,83 +1,98 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir import os -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration -from conans.tools import Version + +required_conan_version = ">=1.52.0" class LevelDBCppConan(ConanFile): name = "leveldb" - description = "LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values." + description = ( + "LevelDB is a fast key-value storage library written at Google that " + "provides an ordered mapping from string keys to string values." + ) url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/google/leveldb" - topics = ("conan", "leveldb", "google", "db") + topics = ("leveldb", "google", "db") license = ("BSD-3-Clause",) - exports_sources = ["CMakeLists.txt"] - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" options = { - "shared": [True, False], + "shared": [True, False], + "fPIC": [True, False], "with_snappy": [True, False], - "fPIC": [True, False] + "with_crc32c": [True, False], } default_options = { "shared": False, "fPIC": True, "with_snappy": True, + "with_crc32c": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - # FIXME: crc32, tcmalloc are also conditionally included in leveldb, but - # there are no "official" conan packages yet; when those are available, we - # can add similar with options for those - + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + def requirements(self): + # FIXME: tcmalloc is also conditionally included in leveldb, but + # there is no "official" conan package yet; when that is available, we + # can add similar with options for those if self.options.with_snappy: - self.requires("snappy/1.1.8") + self.requires("snappy/1.1.9") + if self.options.with_crc32c: + self.requires("crc32c/1.1.2") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["LEVELDB_BUILD_TESTS"] = False - self._cmake.definitions["LEVELDB_BUILD_BENCHMARKS"] = False - self._cmake.configure() - return self._cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _patch_sources(self): - if not self.options.with_snappy: - tools.replace_in_file( - os.path.join(self._source_subfolder, "CMakeLists.txt"), - ('''check_library_exists(snappy snappy_compress ''' - '''"" HAVE_SNAPPY)'''), "") + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LEVELDB_BUILD_TESTS"] = False + tc.variables["LEVELDB_BUILD_BENCHMARKS"] = False + tc.variables["HAVE_SNAPPY"] = self.options.with_snappy + tc.variables["HAVE_CRC32C"] = self.options.with_crc32c + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if not self.options.shared: - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["pthread"] + self.cpp_info.set_property("cmake_file_name", "leveldb") + self.cpp_info.set_property("cmake_target_name", "leveldb::leveldb") + self.cpp_info.libs = ["leveldb"] + if self.options.shared: + self.cpp_info.defines.append("LEVELDB_SHARED_LIBRARY") + elif self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/leveldb/all/patches/check_library_exists.1.22.patch b/recipes/leveldb/all/patches/check_library_exists.1.22.patch new file mode 100644 index 0000000000000..2c1857272519f --- /dev/null +++ b/recipes/leveldb/all/patches/check_library_exists.1.22.patch @@ -0,0 +1,30 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -35,8 +35,12 @@ include(CheckIncludeFile) + check_include_file("unistd.h" HAVE_UNISTD_H) + + include(CheckLibraryExists) +-check_library_exists(crc32c crc32c_value "" HAVE_CRC32C) +-check_library_exists(snappy snappy_compress "" HAVE_SNAPPY) ++if(HAVE_CRC32C) ++ find_package(Crc32c REQUIRED CONFIG) ++endif() ++if(HAVE_SNAPPY) ++ find_package(Snappy REQUIRED CONFIG) ++endif() + check_library_exists(tcmalloc malloc "" HAVE_TCMALLOC) + + include(CheckCXXSymbolExists) +@@ -246,10 +250,10 @@ if(HAVE_CLANG_THREAD_SAFETY) + endif(HAVE_CLANG_THREAD_SAFETY) + + if(HAVE_CRC32C) +- target_link_libraries(leveldb crc32c) ++ target_link_libraries(leveldb Crc32c::crc32c) + endif(HAVE_CRC32C) + if(HAVE_SNAPPY) +- target_link_libraries(leveldb snappy) ++ target_link_libraries(leveldb Snappy::snappy) + endif(HAVE_SNAPPY) + if(HAVE_TCMALLOC) + target_link_libraries(leveldb tcmalloc) diff --git a/recipes/leveldb/all/patches/check_library_exists.1.23.patch b/recipes/leveldb/all/patches/check_library_exists.1.23.patch new file mode 100644 index 0000000000000..f94de65f96893 --- /dev/null +++ b/recipes/leveldb/all/patches/check_library_exists.1.23.patch @@ -0,0 +1,30 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -38,8 +38,12 @@ include(CheckIncludeFile) + check_include_file("unistd.h" HAVE_UNISTD_H) + + include(CheckLibraryExists) +-check_library_exists(crc32c crc32c_value "" HAVE_CRC32C) +-check_library_exists(snappy snappy_compress "" HAVE_SNAPPY) ++if(HAVE_CRC32C) ++ find_package(Crc32c REQUIRED CONFIG) ++endif() ++if(HAVE_SNAPPY) ++ find_package(Snappy REQUIRED CONFIG) ++endif() + check_library_exists(tcmalloc malloc "" HAVE_TCMALLOC) + + include(CheckCXXSymbolExists) +@@ -268,10 +272,10 @@ if(HAVE_CLANG_THREAD_SAFETY) + endif(HAVE_CLANG_THREAD_SAFETY) + + if(HAVE_CRC32C) +- target_link_libraries(leveldb crc32c) ++ target_link_libraries(leveldb Crc32c::crc32c) + endif(HAVE_CRC32C) + if(HAVE_SNAPPY) +- target_link_libraries(leveldb snappy) ++ target_link_libraries(leveldb Snappy::snappy) + endif(HAVE_SNAPPY) + if(HAVE_TCMALLOC) + target_link_libraries(leveldb tcmalloc) diff --git a/recipes/leveldb/all/test_package/CMakeLists.txt b/recipes/leveldb/all/test_package/CMakeLists.txt index 33ae887aa6aea..c55600d5161fd 100644 --- a/recipes/leveldb/all/test_package/CMakeLists.txt +++ b/recipes/leveldb/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(leveldb REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE leveldb::leveldb) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/leveldb/all/test_package/conanfile.py b/recipes/leveldb/all/test_package/conanfile.py index a59a26a52c8dc..0a6bc68712d90 100644 --- a/recipes/leveldb/all/test_package/conanfile.py +++ b/recipes/leveldb/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/leveldb/all/test_v1_package/CMakeLists.txt b/recipes/leveldb/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..add355dae7008 --- /dev/null +++ b/recipes/leveldb/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(leveldb REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE leveldb::leveldb) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/leveldb/all/test_v1_package/conanfile.py b/recipes/leveldb/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/leveldb/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/leveldb/config.yml b/recipes/leveldb/config.yml index a04ddfaf17d5f..97b6b5c89c235 100644 --- a/recipes/leveldb/config.yml +++ b/recipes/leveldb/config.yml @@ -1,3 +1,5 @@ versions: + "1.23": + folder: "all" "1.22": folder: "all" diff --git a/recipes/lexbor/all/CMakeLists.txt b/recipes/lexbor/all/CMakeLists.txt new file mode 100644 index 0000000000000..96d7aa4b915cd --- /dev/null +++ b/recipes/lexbor/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper LANGUAGES C) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/lexbor/all/conandata.yml b/recipes/lexbor/all/conandata.yml new file mode 100644 index 0000000000000..21c6f4fc19465 --- /dev/null +++ b/recipes/lexbor/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.1.0": + url: "https://github.com/lexbor/lexbor/archive/v2.1.0.zip" + sha256: "58d684d19cec689e40d8d443b3b953697cfa677a0ca59a2cf1fc14cd37ac2404" diff --git a/recipes/lexbor/all/conanfile.py b/recipes/lexbor/all/conanfile.py new file mode 100644 index 0000000000000..64b27525d9645 --- /dev/null +++ b/recipes/lexbor/all/conanfile.py @@ -0,0 +1,93 @@ +from conans import ConanFile, CMake, tools +from conan.tools.microsoft import is_msvc +import functools + +required_conan_version = ">=1.43.0" + +class LexborConan(ConanFile): + name = "lexbor" + description = "Lexbor is development of an open source HTML Renderer library" + topics = ("html5", "css", "parser", "renderer") + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/lexbor/lexbor/" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "build_separately": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "build_separately": False, + } + generators = "cmake" + exports_sources = ["CMakeLists.txt", ] + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_mingw(self): + return self.settings.os == "Windows" and self.settings.compiler == "gcc" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def validate(self): + # static build on Windows will be support by future release. (https://github.com/lexbor/lexbor/issues/69) + if str(self.version) == "2.1.0" and self.options.shared == False and (is_msvc(self) or self._is_mingw): + raise tools.ConanInvalidConfiguration("{}/{} doesn't support static build on Windows(please use cci.20220301).".format(self.name, self.version)) + + if self.options.build_separately: + raise tools.ConanInvalidConfiguration("{}/{} doesn't support build_separately option(yet).".format(self.name, self.version)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + + cmake.definitions["LEXBOR_BUILD_SHARED"] = self.options.shared + cmake.definitions["LEXBOR_BUILD_STATIC"] = not self.options.shared + cmake.definitions["LEXBOR_TESTS_CPP"] = False + # TODO: enable build_separately option + cmake.definitions["LEXBOR_BUILD_SEPARATELY"] = self.options.build_separately + cmake.definitions["LEXBOR_INSTALL_HEADERS"] = True + + cmake.configure() + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + target = "lexbor" if self.options.shared else "lexbor_static" + self.cpp_info.set_property("cmake_file_name", "lexbor") + self.cpp_info.set_property("cmake_target_name", "lexbor::{}".format(target)) + self.cpp_info.names["cmake_find_package"] = "lexbor" + self.cpp_info.names["cmake_find_package_multi"] = "lexbor" + + self.cpp_info.components["_lexbor"].set_property("cmake_target_name", "lexbor::{}".format(target)) + self.cpp_info.components["_lexbor"].names["cmake_find_package"] = target + self.cpp_info.components["_lexbor"].names["cmake_find_package_multi"] = target + + self.cpp_info.components["_lexbor"].libs = [target] + self.cpp_info.components["_lexbor"].defines = ["LEXBOR_BUILD_SHARED" if self.options.shared else "LEXBOR_BUILD_STATIC"] diff --git a/recipes/lexbor/all/test_package/CMakeLists.txt b/recipes/lexbor/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2f7061d3b066d --- /dev/null +++ b/recipes/lexbor/all/test_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(lexbor CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) + +if(TARGET lexbor::lexbor_static) + target_link_libraries(${PROJECT_NAME} lexbor::lexbor_static) +else() + target_link_libraries(${PROJECT_NAME} lexbor::lexbor) +endif() diff --git a/recipes/lexbor/all/test_package/conanfile.py b/recipes/lexbor/all/test_package/conanfile.py new file mode 100644 index 0000000000000..54473a706ca69 --- /dev/null +++ b/recipes/lexbor/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class LexborTestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lexbor/all/test_package/test_package.c b/recipes/lexbor/all/test_package/test_package.c new file mode 100644 index 0000000000000..0143cae07e5b6 --- /dev/null +++ b/recipes/lexbor/all/test_package/test_package.c @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +int main() { + lxb_html_document_t* document = lxb_html_document_create(); + lxb_html_document_destroy(document); + + return 0; +} diff --git a/recipes/lexbor/config.yml b/recipes/lexbor/config.yml new file mode 100644 index 0000000000000..110c267dc74e0 --- /dev/null +++ b/recipes/lexbor/config.yml @@ -0,0 +1,3 @@ +versions: + "2.1.0": + folder: "all" diff --git a/recipes/libaec/all/CMakeLists.txt b/recipes/libaec/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/libaec/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libaec/all/conandata.yml b/recipes/libaec/all/conandata.yml index 8636be35b6ef3..f02aae783d14c 100644 --- a/recipes/libaec/all/conandata.yml +++ b/recipes/libaec/all/conandata.yml @@ -1,9 +1,22 @@ sources: + "1.0.6": + url: "https://gitlab.dkrz.de/k202009/libaec/uploads/45b10e42123edd26ab7b3ad92bcf7be2/libaec-1.0.6.tar.gz" + sha256: "032961877231113bb094ef224085e6d66fd670f85a3e17f53d0f131abf24f2fd" "1.0.4": - url: https://gitlab.dkrz.de/k202009/libaec/uploads/ea0b7d197a950b0c110da8dfdecbb71f/libaec-1.0.4.tar.gz - sha256: f2b1b232083bd8beaf8a54a024225de3dd72a673a9bcdf8c3ba96c39483f4309 - + url: "https://gitlab.dkrz.de/k202009/libaec/uploads/ea0b7d197a950b0c110da8dfdecbb71f/libaec-1.0.4.tar.gz" + sha256: "f2b1b232083bd8beaf8a54a024225de3dd72a673a9bcdf8c3ba96c39483f4309" patches: "1.0.4": - patch_file: "patches/0001-Fix-static-library-builds.patch" - base_path: "source_subfolder" + - patch_file: "patches/1.0.4-0001-Fix-static-library-builds.patch" + patch_type: "conan" + patch_description: "Fix static library builds" + - patch_file: "patches/1.0.4-0002-fix-install-ios.patch" + patch_type: "conan" + patch_description: "Fix install iOS" + "1.0.6": + - patch_file: "patches/1.0.6-0001-fix-library-builds.patch" + patch_type: "conan" + patch_description: "Fix library builds" + - patch_file: "patches/1.0.6-0002-fix-cmake-build-with-ninja.patch" + patch_type: "conan" + patch_description: "Ninja needs 'aec' binary to be put in a separate folder to an imaginary 'aec' object output" diff --git a/recipes/libaec/all/conanfile.py b/recipes/libaec/all/conanfile.py index d7a4b538362a1..e624f9f76f9b5 100644 --- a/recipes/libaec/all/conanfile.py +++ b/recipes/libaec/all/conanfile.py @@ -1,6 +1,13 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir, replace_in_file +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import os +required_conan_version = ">=1.52.0" + class LibaecConan(ConanFile): name = "libaec" @@ -8,7 +15,7 @@ class LibaecConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://gitlab.dkrz.de/k202009/libaec" description = "Adaptive Entropy Coding library" - topics = ("conan", "dsp", "libaec", "encoding", "decoding") + topics = "dsp", "encoding", "decoding" settings = "os", "compiler", "build_type", "arch" options = { "shared": [True, False], @@ -19,49 +26,81 @@ class LibaecConan(ConanFile): "fPIC": True, } - generators = "cmake" - exports_sources = ["CMakeLists.txt", "patches/*"] - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if Version(self.version) >= "1.0.6" and is_msvc(self): + # libaec/1.0.6 uses "restrict" keyword which seems to be supported since Visual Studio 16. + if Version(self.settings.compiler.version) < "16": + raise ConanInvalidConfiguration("{} does not support Visual Studio {}".format(self.name, self.settings.compiler.version)) + # In libaec/1.0.6, fail to build aec_client command with debug and shared settings in Visual Studio. + # Temporary, this recipe doesn't support these settings. + if self.options.shared and self.settings.build_type == "Debug": + raise ConanInvalidConfiguration("{} does not support debug and shared build in Visual Studio(currently)".format(self.name)) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - cmake = CMake(self) - cmake.configure(build_folder=self._build_subfolder) - return cmake + def generate(self): + tc = CMakeToolchain(self) + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - tools.patch(**self.conan_data["patches"][self.version]) - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), "add_subdirectory(tests)", "") - cmake = self._configure_cmake() + apply_conandata_patches(self) + if Version(self.version) < "1.0.6": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "add_subdirectory(tests)", "") + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="Copyright.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + if Version(self.version) < "1.0.6": + copy(self, pattern="Copyright.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + else: + copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, 'share')) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) def package_info(self): - if self.settings.os == "Windows" and self.options.shared: - self.cpp_info.libs = ["szip", "aec"] - else: - self.cpp_info.libs = ["sz", "aec"] + aec_name = "aec" + if self.settings.os == "Windows" and Version(self.version) >= "1.0.6" and not self.options.shared: + aec_name = "aec_static" + szip_name = "sz" + if self.settings.os == "Windows": + if Version(self.version) >= "1.0.6": + szip_name = "szip" if self.options.shared else "szip_static" + elif self.options.shared: + szip_name = "szip" + self.cpp_info.libs = [szip_name, aec_name] + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/libaec/all/patches/0001-Fix-static-library-builds.patch b/recipes/libaec/all/patches/1.0.4-0001-Fix-static-library-builds.patch similarity index 100% rename from recipes/libaec/all/patches/0001-Fix-static-library-builds.patch rename to recipes/libaec/all/patches/1.0.4-0001-Fix-static-library-builds.patch diff --git a/recipes/libaec/all/patches/1.0.4-0002-fix-install-ios.patch b/recipes/libaec/all/patches/1.0.4-0002-fix-install-ios.patch new file mode 100644 index 0000000000000..7d7d56d1f60b6 --- /dev/null +++ b/recipes/libaec/all/patches/1.0.4-0002-fix-install-ios.patch @@ -0,0 +1,10 @@ +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -53,7 +53,6 @@ install(FILES libaec.h szlib.h ${PROJECT_BINARY_DIR}/libaec_Export.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT headers) + install(TARGETS aec_client +- RUNTIME + DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT applications) + diff --git a/recipes/libaec/all/patches/1.0.6-0001-fix-library-builds.patch b/recipes/libaec/all/patches/1.0.6-0001-fix-library-builds.patch new file mode 100644 index 0000000000000..500c20a889d8c --- /dev/null +++ b/recipes/libaec/all/patches/1.0.6-0001-fix-library-builds.patch @@ -0,0 +1,113 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6f75ead..c974cce 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,7 +4,7 @@ project(libaec LANGUAGES C VERSION 1.0.6) + # Automatically export symbols for Windows DLLs + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + +-set(CMAKE_C_STANDARD 99) ++set(CMAKE_C_STANDARD 11) + set(CMAKE_C_VISIBILITY_PRESET hidden) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + include(CTest) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index a26f9b7..3cd8f72 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -10,12 +10,17 @@ target_include_directories(aec + "$" + "$") + +-# Create both static and shared aec library. ++if (NOT BUILD_SHARED_LIBS) ++ ++# Create aec library. + add_library(aec_static STATIC "$") + target_link_libraries(aec_static PUBLIC aec) + set_target_properties(aec_static + PROPERTIES +- OUTPUT_NAME $,aec_static,aec>) ++ OUTPUT_NAME $,aec_static,aec> ++ PUBLIC_HEADER ../include/libaec.h) ++ ++else() + + add_library(aec_shared SHARED "$") + target_link_libraries(aec_shared PUBLIC aec) +@@ -26,17 +31,24 @@ set_target_properties(aec_shared + OUTPUT_NAME aec + PUBLIC_HEADER ../include/libaec.h) + ++endif() ++ + # Wrapper for compatibility with szip + add_library(sz OBJECT sz_compat.c) + target_link_libraries(sz PUBLIC aec) + +-# Create both static and shared szip library. ++# Create szip library. ++if (NOT BUILD_SHARED_LIBS) ++ + add_library(sz_static STATIC "$" "$") + set_target_properties(sz_static + PROPERTIES +- OUTPUT_NAME $,szip_static,sz>) ++ OUTPUT_NAME $,szip_static,sz> ++ PUBLIC_HEADER ../include/szlib.h) + target_link_libraries(sz_static PUBLIC sz) + ++else() ++ + add_library(sz_shared SHARED "$" "$") + target_link_libraries(sz_shared PUBLIC sz) + set_target_properties(sz_shared +@@ -46,11 +58,16 @@ set_target_properties(sz_shared + OUTPUT_NAME $,szip,sz> + PUBLIC_HEADER ../include/szlib.h) + ++endif() ++ + # Simple client for testing and benchmarking. + # Can also be used stand-alone + add_executable(aec_client aec.c) + set_target_properties(aec_client PROPERTIES OUTPUT_NAME aec) + target_link_libraries(aec_client PUBLIC aec) ++if (MSVC) ++ target_compile_options(aec_client PUBLIC /FS /Z7) ++endif() + + include(GNUInstallDirs) + if(UNIX) +@@ -61,23 +78,14 @@ if(UNIX) + PROPERTIES + COMPILE_DEFINITIONS + "HAVE_VISIBILITY=$;BUILDING_LIBAEC") +- +- # The shell scripts for benchmarking are supported on unix only +- add_executable(utime EXCLUDE_FROM_ALL utime.c) +- target_include_directories(utime PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/..") +- add_custom_target(bench +- COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/benc.sh +- ${CMAKE_CURRENT_SOURCE_DIR}/../data/typical.rz +- COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bdec.sh +- DEPENDS aec_client utime) + endif() + +-if(UNIX OR MINGW) +- # Install manpage +- install( +- FILES aec.1 +- DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man1 +- COMPONENT doc) +-endif() ++if (NOT BUILD_SHARED_LIBS) + +-install(TARGETS aec_static aec_shared sz_static sz_shared aec_client) ++install(TARGETS aec_static sz_static aec_client) ++ ++else() ++ ++install(TARGETS aec_shared sz_shared aec_client) ++ ++endif() diff --git a/recipes/libaec/all/patches/1.0.6-0002-fix-cmake-build-with-ninja.patch b/recipes/libaec/all/patches/1.0.6-0002-fix-cmake-build-with-ninja.patch new file mode 100644 index 0000000000000..b3782f6654ad3 --- /dev/null +++ b/recipes/libaec/all/patches/1.0.6-0002-fix-cmake-build-with-ninja.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt 2021-09-17 19:28:01.000000000 +0800 ++++ b/CMakeLists.txt 2022-11-04 07:43:58.413439439 +0800 +@@ -12,6 +12,8 @@ + include(TestBigEndian) + test_big_endian(WORDS_BIGENDIAN) + ++set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) ++ + # Check for __builtin_clzll for faster decoding + include(CheckCSourceCompiles) + check_c_source_compiles( diff --git a/recipes/libaec/all/test_package/CMakeLists.txt b/recipes/libaec/all/test_package/CMakeLists.txt index aae00b641388d..f87e0b5ca8eb9 100644 --- a/recipes/libaec/all/test_package/CMakeLists.txt +++ b/recipes/libaec/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1.3) -project(test_package) +project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libaec CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} libaec::libaec) diff --git a/recipes/libaec/all/test_package/conanfile.py b/recipes/libaec/all/test_package/conanfile.py index bd7165a553cf4..75526b1d02b79 100644 --- a/recipes/libaec/all/test_package/conanfile.py +++ b/recipes/libaec/all/test_package/conanfile.py @@ -1,10 +1,26 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.scm import Version import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.dependencies["libaec"].ref.version) >= "1.0.6": + tc.variables["CMAKE_C_STANDARD"] = "11" + tc.generate() def build(self): cmake = CMake(self) @@ -12,6 +28,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libaec/all/test_v1_package/CMakeLists.txt b/recipes/libaec/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..454ad5fbc6eba --- /dev/null +++ b/recipes/libaec/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1.3) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libaec CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} libaec::libaec) diff --git a/recipes/libaec/all/test_v1_package/conanfile.py b/recipes/libaec/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..b07f7e5f677ac --- /dev/null +++ b/recipes/libaec/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + if tools.Version(self.deps_cpp_info["libaec"].version) >= "1.0.6": + cmake.definitions["CMAKE_C_STANDARD"] = "11" + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libaec/config.yml b/recipes/libaec/config.yml index c20e44b006f1a..a41a7cbb0ffc2 100644 --- a/recipes/libaec/config.yml +++ b/recipes/libaec/config.yml @@ -1,3 +1,5 @@ versions: + "1.0.6": + folder: all "1.0.4": folder: all diff --git a/recipes/libalsa/all/conandata.yml b/recipes/libalsa/all/conandata.yml index 9066e6e9fb34d..55a14a6d4051e 100644 --- a/recipes/libalsa/all/conandata.yml +++ b/recipes/libalsa/all/conandata.yml @@ -1,10 +1,22 @@ sources: - "1.1.9": - url: "https://github.com/alsa-project/alsa-lib/archive/v1.1.9.tar.gz" - sha256: "be3443c69dd2cb86e751c0abaa4b74343c75db28ef13d11d19a3130a5b0ff78d" - "1.2.2": - url: "https://github.com/alsa-project/alsa-lib/archive/v1.2.2.tar.gz" - sha256: "ad4fa29e3927c5bec0f71b24b6a88523f4e386905341fc9047abef5744805023" + "1.2.7.2": + url: "https://github.com/alsa-project/alsa-lib/archive/v1.2.7.2.tar.gz" + sha256: "2ed6d908120beb4a91c2271b01489181b28dc9f35f32229ef83bcd5ac8817654" + "1.2.7": + url: "https://github.com/alsa-project/alsa-lib/archive/v1.2.7.tar.gz" + sha256: "d76ac42f678b198d754c072fb6d0ce89f880a9bb9fd6a45f97d7be762ac0a384" + "1.2.5.1": + url: "https://github.com/alsa-project/alsa-lib/archive/v1.2.5.1.tar.gz" + sha256: "bc1d9ed505e183fc59413425d34e8106322a0e399befcde8466bd96e6764e6c8" "1.2.4": url: "https://github.com/alsa-project/alsa-lib/archive/v1.2.4.tar.gz" sha256: "0c6ab052d7ea980a01d0208da5e5e10849bd16c4c9961bbd5d2665083b74a6c0" + "1.2.2": + url: "https://github.com/alsa-project/alsa-lib/archive/v1.2.2.tar.gz" + sha256: "ad4fa29e3927c5bec0f71b24b6a88523f4e386905341fc9047abef5744805023" + "1.1.9": + url: "https://github.com/alsa-project/alsa-lib/archive/v1.1.9.tar.gz" + sha256: "be3443c69dd2cb86e751c0abaa4b74343c75db28ef13d11d19a3130a5b0ff78d" +patches: + "1.2.5.1": + - patch_file: "patches/1.2.5.1-0001-control-empty-fix-the-static-build.patch" diff --git a/recipes/libalsa/all/conanfile.py b/recipes/libalsa/all/conanfile.py index 1dfce018f5226..d8a78fbfec4c2 100644 --- a/recipes/libalsa/all/conanfile.py +++ b/recipes/libalsa/all/conanfile.py @@ -1,77 +1,109 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +required_conan_version = ">=1.53.0" + class LibalsaConan(ConanFile): name = "libalsa" - license = "LGPL-2.1" + license = "LGPL-2.1-or-later" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/alsa-project/alsa-lib" - topics = ("conan", "libalsa", "alsa", "sound", "audio", "midi") + topics = ("alsa", "sound", "audio", "midi") description = "Library of ALSA: The Advanced Linux Sound Architecture, that provides audio " \ "and MIDI functionality to the Linux operating system" - options = {"shared": [True, False], "fPIC": [True, False], "disable_python": [True, False]} - default_options = {'shared': False, 'fPIC': True, 'disable_python': True} - settings = "os", "compiler", "build_type", "arch" - _autotools = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "disable_python": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "disable_python": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def configure(self): - if self.settings.os != "Linux": - raise ConanInvalidConfiguration("Only Linux supported") - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("alsa-lib-{}".format(self.version), self._source_subfolder) + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.os != "Linux": + raise ConanInvalidConfiguration(f"{self.ref} only supports Linux") def build_requirements(self): - self.build_requires("libtool/2.4.6") + self.tool_requires("libtool/2.4.7") - def _configure_autotools(self): - if not self._autotools: - self.run("touch ltconfig", run_environment=True) - self.run("libtoolize --force --copy --automake", run_environment=True) - self.run("aclocal $ACLOCAL_FLAGS", run_environment=True) - self.run("autoheader", run_environment=True) - self.run("automake --foreign --copy --add-missing", run_environment=True) - self.run("touch depcomp", run_environment=True) - self.run("autoconf", run_environment=True) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + virtual_build_env = VirtualBuildEnv(self) + virtual_build_env.generate() - self._autotools = AutoToolsBuildEnvironment(self) - args = ["--enable-static=yes", "--enable-shared=no"] \ - if not self.options.shared else ["--enable-static=no", "--enable-shared=yes"] - args.append("--datarootdir=%s" % os.path.join(self.package_folder, "res")) - if self.options.disable_python: - args.append("--disable-python") - self._autotools.configure(args=args) - return self._autotools + tc = AutotoolsToolchain(self) + yes_no = lambda v: "yes" if v else "no" + tc.configure_args.extend([ + f"--enable-python={yes_no(not self.options.disable_python)}", + "--datarootdir=${prefix}/res", + "--datadir=${prefix}/res", + ]) + tc.generate() def build(self): - with tools.chdir(self._source_subfolder): - autotools = self._configure_autotools() + apply_conandata_patches(self) + autotools = Autotools(self) + if Version(self.version) > "1.2.4": + autotools.autoreconf() + autotools.configure() autotools.make() + else: + with chdir(self, self.source_folder): + autotools.autoreconf() + autotools.configure() + autotools.make() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - with tools.chdir(self._source_subfolder): - autotools = self._configure_autotools() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if Version(self.version) > "1.2.4": + autotools = Autotools(self) autotools.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - for l in ["asound", "atopology"]: - la_file = os.path.join(self.package_folder, "lib", "lib%s.la" % l) - if os.path.isfile(la_file): - os.unlink(la_file) + else: + with chdir(self, self.source_folder): + autotools = Autotools(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "ALSA") + self.cpp_info.set_property("cmake_target_name", "ALSA::ALSA") + self.cpp_info.set_property("pkg_config_name", "alsa") self.cpp_info.libs = ["asound"] + self.cpp_info.resdirs = ["res"] self.cpp_info.system_libs = ["dl", "m", "rt", "pthread"] - self.cpp_info.names['pkg_config'] = 'alsa' + alsa_config_dir = os.path.join(self.package_folder, "res", "alsa") + self.runenv_info.define_path("ALSA_CONFIG_DIR", alsa_config_dir) + + # TODO: to remove in conan v2? self.cpp_info.names["cmake_find_package"] = "ALSA" self.cpp_info.names["cmake_find_package_multi"] = "ALSA" - self.env_info.ALSA_CONFIG_DIR = os.path.join(self.package_folder, "res", "alsa") + self.cpp_info.names["pkg_config"] = "alsa" + self.env_info.ALSA_CONFIG_DIR = alsa_config_dir diff --git a/recipes/libalsa/all/patches/1.2.5.1-0001-control-empty-fix-the-static-build.patch b/recipes/libalsa/all/patches/1.2.5.1-0001-control-empty-fix-the-static-build.patch new file mode 100644 index 0000000000000..c39bc736320b5 --- /dev/null +++ b/recipes/libalsa/all/patches/1.2.5.1-0001-control-empty-fix-the-static-build.patch @@ -0,0 +1,25 @@ +From 81e7923fbfad45b2f353a4d6e3053af51f5f7d0b Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Tue, 15 Jun 2021 23:21:42 +0200 +Subject: [PATCH] control: empty - fix the static build + +Reported-by: Jan Palus +Fixes: https://github.com/alsa-project/alsa-lib/issues/157 +Signed-off-by: Jaroslav Kysela +--- + src/control/control_empty.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/control/control_empty.c b/src/control/control_empty.c +index 49d1026c..c9b048c1 100644 +--- a/src/control/control_empty.c ++++ b/src/control/control_empty.c +@@ -30,7 +30,7 @@ + + #ifndef PIC + /* entry for static linking */ +-const char *_snd_module_ctl_empty = ""; ++const char *_snd_module_control_empty = ""; + #endif + + /*! \page control_plugins diff --git a/recipes/libalsa/all/test_package/CMakeLists.txt b/recipes/libalsa/all/test_package/CMakeLists.txt index 02c504812e46d..ab0ad880535ac 100644 --- a/recipes/libalsa/all/test_package/CMakeLists.txt +++ b/recipes/libalsa/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(ALSA REQUIRED) -add_executable(example example.c) -target_link_libraries(example ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE ALSA::ALSA) diff --git a/recipes/libalsa/all/test_package/conanfile.py b/recipes/libalsa/all/test_package/conanfile.py index a13a609c3567e..0a6bc68712d90 100644 --- a/recipes/libalsa/all/test_package/conanfile.py +++ b/recipes/libalsa/all/test_package/conanfile.py @@ -1,9 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools -class LibalsaTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -11,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libalsa/all/test_package/example.c b/recipes/libalsa/all/test_package/test_package.c similarity index 100% rename from recipes/libalsa/all/test_package/example.c rename to recipes/libalsa/all/test_package/test_package.c diff --git a/recipes/libalsa/all/test_v1_package/CMakeLists.txt b/recipes/libalsa/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..690e8d6667c90 --- /dev/null +++ b/recipes/libalsa/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ALSA REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE ALSA::ALSA) diff --git a/recipes/libalsa/all/test_v1_package/conanfile.py b/recipes/libalsa/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/libalsa/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libalsa/config.yml b/recipes/libalsa/config.yml index c995707eadf3c..b1fdda2825fa6 100644 --- a/recipes/libalsa/config.yml +++ b/recipes/libalsa/config.yml @@ -1,7 +1,13 @@ versions: - "1.1.9": + "1.2.7.2": folder: all - "1.2.2": + "1.2.7": + folder: all + "1.2.5.1": folder: all "1.2.4": folder: all + "1.2.2": + folder: all + "1.1.9": + folder: all diff --git a/recipes/libaom-av1/all/CMakeLists.txt b/recipes/libaom-av1/all/CMakeLists.txt deleted file mode 100644 index 68bfd75fb1882..0000000000000 --- a/recipes/libaom-av1/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include("conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libaom-av1/all/conandata.yml b/recipes/libaom-av1/all/conandata.yml index ac1cc09e0026c..8a6a9a41576b7 100644 --- a/recipes/libaom-av1/all/conandata.yml +++ b/recipes/libaom-av1/all/conandata.yml @@ -1,7 +1,44 @@ sources: + "3.5.0": + url: "https://storage.googleapis.com/aom-releases/libaom-3.5.0.tar.gz" + sha256: "d37dbee372e2430a7efde813984ae6d78bdf1fc4080ebe32457c9115408b0738" + "3.4.0": + url: "https://storage.googleapis.com/aom-releases/libaom-3.4.0.tar.gz" + sha256: "bd754b58c3fa69f3ffd29da77de591bd9c26970e3b18537951336d6c0252e354" + "3.3.0": + url: "https://storage.googleapis.com/aom-releases/libaom-3.3.0.tar.gz" + sha256: "1dafde32bc2237bf0570294661ae61db30e818840f77dc4e90d1ebf5a6286664" + "3.1.2": + url: "https://storage.googleapis.com/aom-releases/libaom-3.1.2.tar.gz" + sha256: "a295eb3779657fad7d34217091ee4c6257d02580a82012231afef72792330075" + "3.1.1": + url: "https://storage.googleapis.com/aom-releases/libaom-3.1.1.tar.gz" + sha256: "7cd5e8e469268c37241df93fe61557ea0dc46980ca21b37e786e92a3d0729276" "2.0.1": - url: "https://aomedia.googlesource.com/aom/+archive/b52ee6d44adaef8a08f6984390de050d64df9faa.tar.gz" + url: "https://storage.googleapis.com/aom-releases/libaom-2.0.1.tar.gz" + sha256: "a0cff299621e2ef885aba219c498fa39a7d9a7ddf47585a118fd66c64ad1b312" patches: + "3.5.0": + - patch_file: "patches/0001-3.5.0-fix-install.patch" + patch_type: conan + patch_description: Install just aom library without aom_static. + "3.4.0": + - patch_file: "patches/0001-3.4.0-fix-install.patch" + patch_type: conan + patch_description: Install just aom library without aom_static. + "3.3.0": + - patch_file: "patches/0001-3.3.0-fix-install.patch" + patch_type: conan + patch_description: Install just aom library without aom_static. + "3.1.2": + - patch_file: "patches/0001-3.1.1-fix-install.patch" + patch_type: conan + patch_description: Install just aom library without aom_static. + "3.1.1": + - patch_file: "patches/0001-3.1.1-fix-install.patch" + patch_type: conan + patch_description: Install just aom library without aom_static. "2.0.1": - - base_path: "source_subfolder" - patch_file: "patches/0001-msvc-install.patch" + - patch_file: "patches/0001-2.0.1-fix-install.patch" + patch_type: conan + patch_description: Install just aom library without aom_static. diff --git a/recipes/libaom-av1/all/conanfile.py b/recipes/libaom-av1/all/conanfile.py index d1ca8cb7c9dea..e7216a0f083aa 100644 --- a/recipes/libaom-av1/all/conanfile.py +++ b/recipes/libaom-av1/all/conanfile.py @@ -1,114 +1,106 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version import os -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.47.0" -class LibaomAv1(ConanFile): + +class LibaomAv1Conan(ConanFile): name = "libaom-av1" description = "AV1 Codec Library" - topics = ("conan", "av1", "codec", "video", "encoding", "decoding") + topics = ("av1", "codec", "video", "encoding", "decoding") url = "https://github.com/conan-io/conan-center-index" homepage = "https://aomedia.googlesource.com/aom" license = "BSD-2-Clause" - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False], - "assembly": [True, False] - } - default_options = {"shared": False, - "fPIC": True, - "assembly": False - } - _cmake = None + options = { + "shared": [True, False], + "fPIC": [True, False], + "assembly": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "assembly": False, + } @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC + if self.settings.arch not in ("x86", "x86_64"): + del self.options.assembly def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) - - # Check compiler version - compiler = str(self.settings.compiler) - compiler_version = tools.Version(self.settings.compiler.version.value) - - minimal_version = { - "Visual Studio": "15", - "gcc": "5", - "clang": "5", - "apple-clang": "6" - } - if compiler not in minimal_version: - self.output.warn( - "%s recipe lacks information about the %s compiler standard version support" % (self.name, compiler)) - elif compiler_version < minimal_version[compiler]: - raise ConanInvalidConfiguration("{} requires a {} version >= {}".format(self.name, compiler, compiler_version)) - + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass def build_requirements(self): - if self.options.assembly: - self.build_requires("nasm/2.15.05") - if tools.os_info.is_windows: - self.build_requires("strawberryperl/5.30.0.1") - - def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder) + if self.options.get_safe("assembly", False): + self.tool_requires("nasm/2.15.05") + if self._settings_build.os == "Windows": + self.tool_requires("strawberryperl/5.30.0.1") - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_EXAMPLES"] = False - self._cmake.definitions["ENABLE_TESTS"] = False - self._cmake.definitions["ENABLE_DOCS"] = False - self._cmake.definitions["ENABLE_TOOLS"] = False - if not self.options.assembly: + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=Version(self.version) >= "3.3.0") + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_EXAMPLES"] = False + tc.variables["ENABLE_TESTS"] = False + tc.variables["ENABLE_DOCS"] = False + tc.variables["ENABLE_TOOLS"] = False + if not self.options.get_safe("assembly", False): # make non-assembly build - self._cmake.definitions["AOM_TARGET_CPU"] = "generic" + tc.variables["AOM_TARGET_CPU"] = "generic" # libyuv is used for examples, tests and non-essential 'dump_obu' tool so it is disabled # required to be 1/0 instead of False - self._cmake.definitions["CONFIG_LIBYUV"] = 0 + tc.variables["CONFIG_LIBYUV"] = 0 # webm is not yet packaged - self._cmake.definitions["CONFIG_WEBM_IO"] = 0 - # required out-of-source build - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + tc.variables["CONFIG_WEBM_IO"] = 0 + # Requires C99 or higher + tc.variables["CMAKE_C_STANDARD"] = "99" + tc.generate() + env = VirtualBuildEnv(self) + env.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - if self.options.shared: - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.a") + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "aom") self.cpp_info.libs = ["aom"] - self.cpp_info.names["cmake_find_package"] = "aom" - self.cpp_info.names["cmake_find_package_multi"] = "aom" - self.cpp_info.names["pkg_config"] = "libaom" - if self.settings.os == "Linux": + if self.settings.os in ("FreeBSD", "Linux"): self.cpp_info.system_libs = ["pthread", "m"] diff --git a/recipes/libaom-av1/all/patches/0001-2.0.1-fix-install.patch b/recipes/libaom-av1/all/patches/0001-2.0.1-fix-install.patch new file mode 100644 index 0000000000000..128bfeb7c4ea2 --- /dev/null +++ b/recipes/libaom-av1/all/patches/0001-2.0.1-fix-install.patch @@ -0,0 +1,34 @@ +--- a/build/cmake/aom_install.cmake ++++ b/build/cmake/aom_install.cmake +@@ -27,7 +27,7 @@ endif() + # Note: aom.pc generation uses GNUInstallDirs: + # https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html + macro(setup_aom_install_targets) +- if(NOT (MSVC OR XCODE)) ++ if(1) + include("GNUInstallDirs") + set(AOM_PKG_CONFIG_FILE "${AOM_CONFIG_DIR}/aom.pc") + +@@ -73,7 +73,8 @@ macro(setup_aom_install_targets) + endif() + + if(BUILD_SHARED_LIBS) +- set(AOM_INSTALL_LIBS aom aom_static) ++ set_target_properties(aom_static PROPERTIES OUTPUT_NAME aom_static) ++ set(AOM_INSTALL_LIBS aom) + else() + set(AOM_INSTALL_LIBS aom) + endif() +@@ -85,8 +86,10 @@ macro(setup_aom_install_targets) + install( + FILES "${AOM_PKG_CONFIG_FILE}" + DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig") +- install(TARGETS ${AOM_INSTALL_LIBS} DESTINATION +- "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") ++ install(TARGETS ${AOM_INSTALL_LIBS} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + if(ENABLE_EXAMPLES) + install(TARGETS ${AOM_INSTALL_BINS} DESTINATION diff --git a/recipes/libaom-av1/all/patches/0001-3.1.1-fix-install.patch b/recipes/libaom-av1/all/patches/0001-3.1.1-fix-install.patch new file mode 100644 index 0000000000000..af10132d05fe7 --- /dev/null +++ b/recipes/libaom-av1/all/patches/0001-3.1.1-fix-install.patch @@ -0,0 +1,34 @@ +--- a/build/cmake/aom_install.cmake ++++ b/build/cmake/aom_install.cmake +@@ -26,7 +26,7 @@ endif() + # Note: aom.pc generation uses GNUInstallDirs: + # https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html + macro(setup_aom_install_targets) +- if(NOT (MSVC OR XCODE)) ++ if(1) + include("GNUInstallDirs") + set(AOM_PKG_CONFIG_FILE "${AOM_CONFIG_DIR}/aom.pc") + +@@ -76,7 +76,8 @@ macro(setup_aom_install_targets) + endif() + + if(BUILD_SHARED_LIBS) +- set(AOM_INSTALL_LIBS aom aom_static) ++ set_target_properties(aom_static PROPERTIES OUTPUT_NAME aom_static) ++ set(AOM_INSTALL_LIBS aom) + else() + set(AOM_INSTALL_LIBS aom) + endif() +@@ -88,8 +89,10 @@ macro(setup_aom_install_targets) + install( + FILES "${AOM_PKG_CONFIG_FILE}" + DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig") +- install(TARGETS ${AOM_INSTALL_LIBS} DESTINATION +- "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") ++ install(TARGETS ${AOM_INSTALL_LIBS} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + if(ENABLE_EXAMPLES) + install(TARGETS ${AOM_INSTALL_BINS} DESTINATION diff --git a/recipes/libaom-av1/all/patches/0001-3.3.0-fix-install.patch b/recipes/libaom-av1/all/patches/0001-3.3.0-fix-install.patch new file mode 100644 index 0000000000000..0dc76d16fc7f5 --- /dev/null +++ b/recipes/libaom-av1/all/patches/0001-3.3.0-fix-install.patch @@ -0,0 +1,21 @@ +--- a/build/cmake/aom_install.cmake ++++ b/build/cmake/aom_install.cmake +@@ -27,7 +27,7 @@ endif() + # Note: aom.pc generation uses GNUInstallDirs: + # https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html + macro(setup_aom_install_targets) +- if(NOT XCODE) ++ if(1) + include("GNUInstallDirs") + set(AOM_PKG_CONFIG_FILE "${AOM_CONFIG_DIR}/aom.pc") + +@@ -77,7 +77,8 @@ macro(setup_aom_install_targets) + endif() + + if(BUILD_SHARED_LIBS) +- set(AOM_INSTALL_LIBS aom aom_static) ++ set_target_properties(aom_static PROPERTIES OUTPUT_NAME aom_static) ++ set(AOM_INSTALL_LIBS aom) + else() + set(AOM_INSTALL_LIBS aom) + endif() diff --git a/recipes/libaom-av1/all/patches/0001-3.4.0-fix-install.patch b/recipes/libaom-av1/all/patches/0001-3.4.0-fix-install.patch new file mode 100644 index 0000000000000..cdf8395c587c8 --- /dev/null +++ b/recipes/libaom-av1/all/patches/0001-3.4.0-fix-install.patch @@ -0,0 +1,21 @@ +--- a/build/cmake/aom_install.cmake ++++ b/build/cmake/aom_install.cmake +@@ -27,7 +27,7 @@ endif() + # Note: aom.pc generation uses GNUInstallDirs: + # https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html + macro(setup_aom_install_targets) +- if(NOT XCODE) ++ if(1) + include("GNUInstallDirs") + set(AOM_PKG_CONFIG_FILE "${AOM_CONFIG_DIR}/aom.pc") + +@@ -78,7 +78,8 @@ macro(setup_aom_install_targets) + endif() + + if(BUILD_SHARED_LIBS) +- set(AOM_INSTALL_LIBS aom aom_static) ++ set_target_properties(aom_static PROPERTIES OUTPUT_NAME aom_static) ++ set(AOM_INSTALL_LIBS aom) + else() + set(AOM_INSTALL_LIBS aom) + endif() diff --git a/recipes/libaom-av1/all/patches/0001-3.5.0-fix-install.patch b/recipes/libaom-av1/all/patches/0001-3.5.0-fix-install.patch new file mode 100644 index 0000000000000..cdf8395c587c8 --- /dev/null +++ b/recipes/libaom-av1/all/patches/0001-3.5.0-fix-install.patch @@ -0,0 +1,21 @@ +--- a/build/cmake/aom_install.cmake ++++ b/build/cmake/aom_install.cmake +@@ -27,7 +27,7 @@ endif() + # Note: aom.pc generation uses GNUInstallDirs: + # https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html + macro(setup_aom_install_targets) +- if(NOT XCODE) ++ if(1) + include("GNUInstallDirs") + set(AOM_PKG_CONFIG_FILE "${AOM_CONFIG_DIR}/aom.pc") + +@@ -78,7 +78,8 @@ macro(setup_aom_install_targets) + endif() + + if(BUILD_SHARED_LIBS) +- set(AOM_INSTALL_LIBS aom aom_static) ++ set_target_properties(aom_static PROPERTIES OUTPUT_NAME aom_static) ++ set(AOM_INSTALL_LIBS aom) + else() + set(AOM_INSTALL_LIBS aom) + endif() diff --git a/recipes/libaom-av1/all/patches/0001-msvc-install.patch b/recipes/libaom-av1/all/patches/0001-msvc-install.patch deleted file mode 100644 index d5d7ef2945387..0000000000000 --- a/recipes/libaom-av1/all/patches/0001-msvc-install.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/build/cmake/aom_install.cmake b/build/cmake/aom_install.cmake -index cd40fe424..31f0224af 100644 ---- a/build/cmake/aom_install.cmake -+++ b/build/cmake/aom_install.cmake -@@ -93,4 +93,21 @@ macro(setup_aom_install_targets) - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") - endif() - endif() -+ -+ if (MSVC) -+ if(BUILD_SHARED_LIBS) -+ set(AOM_INSTALL_LIBS aom aom_static) -+ else() -+ set(AOM_INSTALL_LIBS aom) -+ endif() -+ install( -+ FILES ${AOM_INSTALL_INCS} -+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aom") -+ install( -+ TARGETS ${AOM_INSTALL_LIBS} -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -+ endif() -+ - endmacro() diff --git a/recipes/libaom-av1/all/test_package/CMakeLists.txt b/recipes/libaom-av1/all/test_package/CMakeLists.txt index 33ae887aa6aea..f5305ced8fb6c 100644 --- a/recipes/libaom-av1/all/test_package/CMakeLists.txt +++ b/recipes/libaom-av1/all/test_package/CMakeLists.txt @@ -1,9 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libaom-av1 REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libaom-av1::libaom-av1) diff --git a/recipes/libaom-av1/all/test_package/conanfile.py b/recipes/libaom-av1/all/test_package/conanfile.py index 7e2dfe859bb27..d120a992c06a6 100644 --- a/recipes/libaom-av1/all/test_package/conanfile.py +++ b/recipes/libaom-av1/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libaom-av1/all/test_package/test_package.c b/recipes/libaom-av1/all/test_package/test_package.c new file mode 100644 index 0000000000000..eca39e0b4e6f9 --- /dev/null +++ b/recipes/libaom-av1/all/test_package/test_package.c @@ -0,0 +1,7 @@ +#include "aom/aom_codec.h" +#include + +int main() { + printf("Version: %s\n", aom_codec_version_str()); + return 0; +} diff --git a/recipes/libaom-av1/all/test_package/test_package.cpp b/recipes/libaom-av1/all/test_package/test_package.cpp deleted file mode 100644 index be0221b13f9f4..0000000000000 --- a/recipes/libaom-av1/all/test_package/test_package.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "aom/aom_codec.h" - -int main() { - std::cout << "Version: " << aom_codec_version_str() << std::endl; - return 0; -} diff --git a/recipes/libaom-av1/all/test_v1_package/CMakeLists.txt b/recipes/libaom-av1/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0041c8b205193 --- /dev/null +++ b/recipes/libaom-av1/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libaom-av1 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libaom-av1::libaom-av1) diff --git a/recipes/libaom-av1/all/test_v1_package/conanfile.py b/recipes/libaom-av1/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libaom-av1/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libaom-av1/config.yml b/recipes/libaom-av1/config.yml index bb7eb85dfac49..63fbe232d5922 100644 --- a/recipes/libaom-av1/config.yml +++ b/recipes/libaom-av1/config.yml @@ -1,3 +1,13 @@ versions: + "3.5.0": + folder: all + "3.4.0": + folder: all + "3.3.0": + folder: all + "3.1.2": + folder: all + "3.1.1": + folder: all "2.0.1": folder: all diff --git a/recipes/libarchive/all/CMakeLists.txt b/recipes/libarchive/all/CMakeLists.txt deleted file mode 100644 index 1848ca5a77c35..0000000000000 --- a/recipes/libarchive/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libarchive/all/conandata.yml b/recipes/libarchive/all/conandata.yml index abb60ad9babfd..dd56f7af959bf 100644 --- a/recipes/libarchive/all/conandata.yml +++ b/recipes/libarchive/all/conandata.yml @@ -1,14 +1,71 @@ sources: + "3.6.1": + url: "https://github.com/libarchive/libarchive/releases/download/v3.6.1/libarchive-3.6.1.tar.xz" + sha256: "5a411aceb978f43e626f0c2d1812ddd8807b645ed892453acabd532376c148e6" + "3.6.0": + url: "https://github.com/libarchive/libarchive/releases/download/v3.6.0/libarchive-3.6.0.tar.xz" + sha256: "df283917799cb88659a5b33c0a598f04352d61936abcd8a48fe7b64e74950de7" + "3.5.2": + url: "https://github.com/libarchive/libarchive/releases/download/v3.5.2/libarchive-3.5.2.tar.xz" + sha256: "f0b19ff39c3c9a5898a219497ababbadab99d8178acc980155c7e1271089b5a0" "3.5.1": - url: "https://github.com/libarchive/libarchive/releases/download/3.5.1/libarchive-3.5.1.tar.gz" - sha256: "9015d109ec00bb9ae1a384b172bf2fc1dff41e2c66e5a9eeddf933af9db37f5a" + url: "https://github.com/libarchive/libarchive/releases/download/v3.5.1/libarchive-3.5.1.tar.xz" + sha256: "0e17d3a8d0b206018693b27f08029b598f6ef03600c2b5d10c94ce58692e299b" "3.4.3": - url: "https://github.com/libarchive/libarchive/releases/download/v3.4.3/libarchive-3.4.3.tar.gz" - sha256: "ee1e749213c108cb60d53147f18c31a73d6717d7e3d2481c157e1b34c881ea39" + url: "https://github.com/libarchive/libarchive/releases/download/v3.4.3/libarchive-3.4.3.tar.xz" + sha256: "0bfc3fd40491768a88af8d9b86bf04a9e95b6d41a94f9292dbc0ec342288c05f" "3.4.0": url: "https://github.com/libarchive/libarchive/releases/download/v3.4.0/libarchive-3.4.0.tar.gz" sha256: "8643d50ed40c759f5412a3af4e353cffbce4fdf3b5cf321cb72cacf06b2d825e" patches: + "3.6.1": + - patch_file: "patches/0001-3.6.0-zlib-winapi.patch" + patch_description: "Remove broken ZLIB WINAPI check" + patch_type: "portability" + - patch_file: "patches/0003-3.6.0-cmake.patch" + patch_description: "Make CMake build-system compatible with Conan" + patch_type: "conan" + - patch_file: "patches/0004-3.6.0-android.patch" + patch_description: "Add missing include directory for Android" + patch_type: "portability" + "3.6.0": + - patch_file: "patches/0001-3.6.0-zlib-winapi.patch" + patch_description: "Remove broken ZLIB WINAPI check" + patch_type: "portability" + - patch_file: "patches/0003-3.6.0-cmake.patch" + patch_description: "Make CMake cooperate with Conan" + patch_type: "conan" + - patch_file: "patches/0004-3.6.0-android.patch" + patch_description: "Add missing include directory for Android" + patch_type: "portability" + "3.5.2": + - patch_file: "patches/0001-3.4.3-zlib-winapi.patch" + patch_description: "Remove broken ZLIB WINAPI check" + patch_type: "portability" + - patch_file: "patches/0003-3.5.2-cmake.patch" + patch_description: "Make CMake cooperate with Conan" + patch_type: "conan" + "3.5.1": + - patch_file: "patches/0001-3.4.3-zlib-winapi.patch" + patch_description: "Remove broken ZLIB WINAPI check" + patch_type: "portability" + - patch_file: "patches/0003-3.4.3-cmake.patch" + patch_description: "Make CMake cooperate with Conan" + patch_type: "conan" + "3.4.3": + - patch_file: "patches/0001-3.4.3-zlib-winapi.patch" + patch_description: "Remove broken ZLIB WINAPI check" + patch_type: "portability" + - patch_file: "patches/0003-3.4.3-cmake.patch" + patch_description: "Make CMake cooperate with Conan" + patch_type: "conan" "3.4.0": - - patch_file: "patches/msvc-no-we4061.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-3.4.0-zlib-winapi.patch" + patch_description: "Remove broken ZLIB WINAPI check" + patch_type: "portability" + - patch_file: "patches/0002-3.4.0-msvc-no-we4061.patch" + patch_description: "Remove MSVC compiler warning e4061" + patch_type: "portability" + - patch_file: "patches/0003-3.4.0-cmake.patch" + patch_description: "Make CMake cooperate with Conan" + patch_type: "conan" diff --git a/recipes/libarchive/all/conanfile.py b/recipes/libarchive/all/conanfile.py index 3a0ab1c24b7b2..32b26cd316c4b 100644 --- a/recipes/libarchive/all/conanfile.py +++ b/recipes/libarchive/all/conanfile.py @@ -1,19 +1,22 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, rmdir +from conan.tools.layout import cmake_layout +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.52.0" class LibarchiveConan(ConanFile): name = "libarchive" description = "Multi-format archive and compression library" - topics = ("conan", "libarchive", "tar", "data-compressor", "file-compression") + topics = "tar", "data-compressor", "file-compression" url = "https://github.com/conan-io/conan-center-index" homepage = "https://libarchive.org" license = "BSD-2-Clause" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -32,7 +35,9 @@ class LibarchiveConan(ConanFile): "with_lz4": [True, False], "with_lzo": [True, False], "with_lzma": [True, False], - "with_zstd": [True, False] + "with_zstd": [True, False], + "with_mbedtls": [True, False], + "with_xattr": [True, False], } default_options = { "shared": False, @@ -51,170 +56,140 @@ class LibarchiveConan(ConanFile): "with_lz4": False, "with_lzo": False, "with_lzma": False, - "with_zstd": False + "with_zstd": False, + "with_mbedtls": False, + "with_xattr": False, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if Version(self.version) < "3.4.2": + del self.options.with_mbedtls def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass def requirements(self): if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.with_bzip2: self.requires("bzip2/1.0.8") if self.options.with_libxml2: - self.requires("libxml2/2.9.10") + self.requires("libxml2/2.9.14") if self.options.with_expat: - self.requires("expat/2.2.10") + self.requires("expat/2.4.9") if self.options.with_iconv: - self.requires("libiconv/1.16") + self.requires("libiconv/1.17") if self.options.with_pcreposix: - self.requires("pcre/8.44") - if self.options.with_cng: - # TODO: add cng when available in CCI - raise ConanInvalidConfiguration("cng recipe not yet available in CCI.") + self.requires("pcre/8.45") if self.options.with_nettle: - self.requires("nettle/3.6") + self.requires("nettle/3.8.1") if self.options.with_openssl: - self.requires("openssl/1.1.1j") + self.requires("openssl/1.1.1q") if self.options.with_libb2: self.requires("libb2/20190723") if self.options.with_lz4: - self.requires("lz4/1.9.3") + self.requires("lz4/1.9.4") if self.options.with_lzo: self.requires("lzo/2.10") if self.options.with_lzma: self.requires("xz_utils/5.2.5") if self.options.with_zstd: - self.requires("zstd/1.4.9") + self.requires("zstd/1.5.2") + if self.options.get_safe("with_mbedtls"): + self.requires("mbedtls/3.2.1") def validate(self): - if self.options.with_expat and self.options.with_libxml2: + if self.info.settings.os != "Windows" and self.info.options.with_cng: + # TODO: add cng when available in CCI + raise ConanInvalidConfiguration("cng recipe not yet available in CCI.") + if self.info.options.with_expat and self.info.options.with_libxml2: raise ConanInvalidConfiguration("libxml2 and expat options are exclusive. They cannot be used together as XML engine") + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + cmake_deps = CMakeDeps(self) + cmake_deps.generate() + tc = CMakeToolchain(self) # turn off deps to avoid picking up them accidentally - self._cmake.definitions["ENABLE_NETTLE"] = self.options.with_nettle - self._cmake.definitions["ENABLE_OPENSSL"] = self.options.with_openssl - self._cmake.definitions["ENABLE_LIBB2"] = self.options.with_libb2 - self._cmake.definitions["ENABLE_LZ4"] = self.options.with_lz4 - self._cmake.definitions["ENABLE_LZO"] = self.options.with_lzo - self._cmake.definitions["ENABLE_LZMA"] = self.options.with_lzma - self._cmake.definitions["ENABLE_ZSTD"] = self.options.with_zstd - self._cmake.definitions["ENABLE_ZLIB"] = self.options.with_zlib - self._cmake.definitions["ENABLE_BZip2"] = self.options.with_bzip2 + tc.variables["ENABLE_NETTLE"] = self.options.with_nettle + tc.variables["ENABLE_OPENSSL"] = self.options.with_openssl + tc.variables["ENABLE_LIBB2"] = self.options.with_libb2 + tc.variables["ENABLE_LZ4"] = self.options.with_lz4 + tc.variables["ENABLE_LZO"] = self.options.with_lzo + tc.variables["ENABLE_LZMA"] = self.options.with_lzma + tc.variables["ENABLE_ZSTD"] = self.options.with_zstd + tc.variables["ENABLE_ZLIB"] = self.options.with_zlib + tc.variables["ENABLE_BZip2"] = self.options.with_bzip2 # requires LibXml2 cmake name - self._cmake.definitions["ENABLE_LIBXML2"] = self.options.with_libxml2 - self._cmake.definitions["ENABLE_ICONV"] = self.options.with_iconv - self._cmake.definitions["ENABLE_EXPAT"] = self.options.with_expat - self._cmake.definitions["ENABLE_PCREPOSIX"] = self.options.with_pcreposix + tc.variables["ENABLE_LIBXML2"] = self.options.with_libxml2 + tc.variables["ENABLE_ICONV"] = self.options.with_iconv + tc.variables["ENABLE_EXPAT"] = self.options.with_expat + tc.variables["ENABLE_PCREPOSIX"] = self.options.with_pcreposix if self.options.with_pcreposix: - self._cmake.definitions["POSIX_REGEX_LIB"] = "LIBPCREPOSIX" - self._cmake.definitions["ENABLE_LibGCC"] = False - self._cmake.definitions["ENABLE_CNG"] = self.options.with_cng + tc.variables["POSIX_REGEX_LIB"] = "LIBPCREPOSIX" + tc.variables["ENABLE_LibGCC"] = False + tc.variables["ENABLE_CNG"] = self.options.with_cng # turn off features - self._cmake.definitions["ENABLE_ACL"] = self.options.with_acl + tc.variables["ENABLE_ACL"] = self.options.with_acl # turn off components - self._cmake.definitions["ENABLE_TAR"] = False - self._cmake.definitions["ENABLE_CPIO"] = False - self._cmake.definitions["ENABLE_CAT"] = False - self._cmake.definitions["ENABLE_TEST"] = False + tc.variables["ENABLE_TAR"] = False + tc.variables["ENABLE_CPIO"] = False + tc.variables["ENABLE_CAT"] = False + tc.variables["ENABLE_TEST"] = False # too strict check - self._cmake.definitions["ENABLE_WERROR"] = False - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - - cmakelists_path = os.path.join(self._source_subfolder, "CMakeLists.txt") - - # it can possibly override CMAKE_MODULE_PATH provided by generator - tools.replace_in_file(cmakelists_path, - "SET(CMAKE_MODULE_PATH", - "LIST(APPEND CMAKE_MODULE_PATH") - # workaround due to case sensitivity and limitations in cmake_find_package - # see https://github.com/conan-io/conan/issues/7691 - if self.options.with_bzip2: - tools.replace_in_file(cmakelists_path, "BZIP2_FOUND", "BZip2_FOUND") - tools.replace_in_file(cmakelists_path, "BZIP2_INCLUDE_DIR", "BZip2_INCLUDE_DIR") - tools.replace_in_file(cmakelists_path, "BZIP2_LIBRARIES", "BZip2_LIBRARIES") - if self.options.with_openssl: - tools.replace_in_file(cmakelists_path, - "IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES \"Darwin\")", - "IF(ENABLE_OPENSSL)") - if self.options.with_lzma: - tools.replace_in_file(cmakelists_path, "LIBLZMA_FOUND", "LibLZMA_FOUND") - tools.replace_in_file(cmakelists_path, "LIBLZMA_INCLUDE_DIR", "LibLZMA_INCLUDE_DIR") - tools.replace_in_file(cmakelists_path, "LIBLZMA_LIBRARIES", "LibLZMA_LIBRARIES") - # add possible names for lz4 library - if not self.options.shared: - tools.replace_in_file(cmakelists_path, - "FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4)", - "FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4 lz4_static liblz4_static)") - - # Exclude static/shared targets from build - if self.options.shared: - tools.save(os.path.join(self._source_subfolder, "libarchive", "CMakeLists.txt"), - "set_target_properties(archive_static PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)", - append=True) - else: - tools.save(os.path.join(self._source_subfolder, "libarchive", "CMakeLists.txt"), - "set_target_properties(archive PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)", - append=True) - - # Exclude static/shared targets from install - if self.options.shared: - tools.replace_in_file(os.path.join(self._source_subfolder, "libarchive", "CMakeLists.txt"), - "INSTALL(TARGETS archive archive_static", - "INSTALL(TARGETS archive") - else: - tools.replace_in_file(os.path.join(self._source_subfolder, "libarchive", "CMakeLists.txt"), - "INSTALL(TARGETS archive archive_static", - "INSTALL(TARGETS archive_static") + tc.variables["ENABLE_WERROR"] = False + if Version(self.version) >= "3.4.2": + tc.variables["ENABLE_MBEDTLS"] = self.options.with_mbedtls + tc.variables["ENABLE_XATTR"] = self.options.with_xattr + tc.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "LibArchive") + self.cpp_info.set_property("cmake_target_name", "LibArchive::LibArchive") + self.cpp_info.set_property("pkg_config_name", "libarchive") + self.cpp_info.names["cmake_find_package"] = "LibArchive" self.cpp_info.names["cmake_find_package_multi"] = "LibArchive" - if self.settings.compiler == "Visual Studio" and not self.options.shared: + + self.cpp_info.libs = collect_libs(self) + if self.settings.os == "Windows" and self.options.with_cng: + self.cpp_info.system_libs.append("bcrypt") + if is_msvc(self) and not self.options.shared: self.cpp_info.defines = ["LIBARCHIVE_STATIC"] diff --git a/recipes/libarchive/all/patches/0001-3.4.0-zlib-winapi.patch b/recipes/libarchive/all/patches/0001-3.4.0-zlib-winapi.patch new file mode 100644 index 0000000000000..5acce6e86c2cd --- /dev/null +++ b/recipes/libarchive/all/patches/0001-3.4.0-zlib-winapi.patch @@ -0,0 +1,20 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4fd93d04..922efd15 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -415,14 +415,7 @@ IF(ZLIB_FOUND) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) + IF(WIN32 AND NOT CYGWIN) +- # +- # Test if ZLIB_WINAPI macro is needed to use. +- # +- TRY_MACRO_FOR_LIBRARY( +- "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" +- RUNS +- "#include \nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" +- ZLIB_WINAPI) ++ set(ZLIB_WINAPI yes) + IF(ZLIB_WINAPI) + ADD_DEFINITIONS(-DZLIB_WINAPI) + ELSE(ZLIB_WINAPI) diff --git a/recipes/libarchive/all/patches/0001-3.4.3-zlib-winapi.patch b/recipes/libarchive/all/patches/0001-3.4.3-zlib-winapi.patch new file mode 100644 index 0000000000000..b0d70de9dec3b --- /dev/null +++ b/recipes/libarchive/all/patches/0001-3.4.3-zlib-winapi.patch @@ -0,0 +1,20 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6b00410c..e0359b51 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -420,14 +420,7 @@ IF(ZLIB_FOUND) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) + IF(WIN32 AND NOT CYGWIN) +- # +- # Test if ZLIB_WINAPI macro is needed to use. +- # +- TRY_MACRO_FOR_LIBRARY( +- "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" +- RUNS +- "#include \nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" +- ZLIB_WINAPI) ++ set(ZLIB_WINAPI yes) + IF(ZLIB_WINAPI) + ADD_DEFINITIONS(-DZLIB_WINAPI) + ELSE(ZLIB_WINAPI) diff --git a/recipes/libarchive/all/patches/0001-3.6.0-zlib-winapi.patch b/recipes/libarchive/all/patches/0001-3.6.0-zlib-winapi.patch new file mode 100644 index 0000000000000..dceed2848f701 --- /dev/null +++ b/recipes/libarchive/all/patches/0001-3.6.0-zlib-winapi.patch @@ -0,0 +1,20 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7a0d300a..646e5ce7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -426,14 +426,7 @@ IF(ZLIB_FOUND) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) + IF(WIN32 AND NOT CYGWIN) +- # +- # Test if ZLIB_WINAPI macro is needed to use. +- # +- TRY_MACRO_FOR_LIBRARY( +- "${ZLIB_INCLUDE_DIR}" "${ZLIB_LIBRARIES}" +- RUNS +- "#include \nint main() {uLong f = zlibCompileFlags(); return (f&(1U<<10))?0:-1; }" +- ZLIB_WINAPI) ++ set(ZLIB_WINAPI yes) + IF(ZLIB_WINAPI) + ADD_DEFINITIONS(-DZLIB_WINAPI) + ELSE(ZLIB_WINAPI) diff --git a/recipes/libarchive/all/patches/0002-3.4.0-msvc-no-we4061.patch b/recipes/libarchive/all/patches/0002-3.4.0-msvc-no-we4061.patch new file mode 100644 index 0000000000000..ff6f218ef3e36 --- /dev/null +++ b/recipes/libarchive/all/patches/0002-3.4.0-msvc-no-we4061.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 922efd15..4ffd0930 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -157,7 +157,6 @@ IF (MSVC) + # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" + # Enable level 4 C4061: The enumerate has no associated handler in a switch + # statement. +- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4061") + # Enable level 4 C4254: A larger bit field was assigned to a smaller bit + # field. + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4254") diff --git a/recipes/libarchive/all/patches/0003-3.4.0-cmake.patch b/recipes/libarchive/all/patches/0003-3.4.0-cmake.patch new file mode 100644 index 0000000000000..7b724f1fba164 --- /dev/null +++ b/recipes/libarchive/all/patches/0003-3.4.0-cmake.patch @@ -0,0 +1,101 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4ffd0930..01e8592c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,7 +6,7 @@ endif() + # + PROJECT(libarchive C) + # +-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin) + endif() +@@ -412,7 +412,7 @@ IF(ZLIB_FOUND) + SET(HAVE_LIBZ 1) + SET(HAVE_ZLIB_H 1) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) +- LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) ++ LIST(APPEND ADDITIONAL_LIBS ZLIB::ZLIB) + IF(WIN32 AND NOT CYGWIN) + set(ZLIB_WINAPI yes) + IF(ZLIB_WINAPI) +@@ -474,7 +474,7 @@ IF(LIBLZMA_FOUND) + SET(HAVE_LIBLZMA 1) + SET(HAVE_LZMA_H 1) + CMAKE_PUSH_CHECK_STATE() +- SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIR}) ++ SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIRS}) + SET(CMAKE_REQUIRED_LIBRARIES ${LIBLZMA_LIBRARIES}) + INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) + LIST(APPEND ADDITIONAL_LIBS ${LIBLZMA_LIBRARIES}) +@@ -491,7 +491,7 @@ IF(LIBLZMA_FOUND) + ELSE(LIBLZMA_FOUND) + # LZMA not found and will not be used. + ENDIF(LIBLZMA_FOUND) +-MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIR) ++MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIRS) + MARK_AS_ADVANCED(CLEAR LIBLZMA_LIBRARY) + + # +@@ -561,7 +561,7 @@ IF(ENABLE_LZ4) + ENDIF (LZ4_INCLUDE_DIR) + + FIND_PATH(LZ4_INCLUDE_DIR lz4.h) +- FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4) ++ FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4 lz4_static liblz4_static) + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) + ELSE(ENABLE_LZ4) +@@ -757,7 +757,7 @@ ENDIF(ENABLE_NETTLE) + # Find OpenSSL + # (Except on Mac, where OpenSSL is deprecated.) + # +-IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") ++IF(ENABLE_OPENSSL) + FIND_PACKAGE(OpenSSL) + IF(OPENSSL_FOUND) + SET(HAVE_LIBCRYPTO 1) +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +index ec775bb4..8ef2d620 100644 +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -235,11 +235,15 @@ ELSEIF(ARCHIVE_ACL_SUNOS) + ENDIF() + + # Libarchive is a shared library ++if (BUILD_SHARED_LIBS) ++ + ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_INCLUDE_DIRECTORIES(archive PUBLIC .) + TARGET_LINK_LIBRARIES(archive ${ADDITIONAL_LIBS}) + SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION}) + ++else() ++ + # archive_static is a static library + ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS}) +@@ -249,13 +253,21 @@ SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS + IF(NOT WIN32 OR CYGWIN) + SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive) + ENDIF(NOT WIN32 OR CYGWIN) ++endif() + + IF(ENABLE_INSTALL) + # How to install the libraries +- INSTALL(TARGETS archive archive_static ++ if (BUILD_SHARED_LIBS) ++ INSTALL(TARGETS archive ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib) ++ else() ++ INSTALL(TARGETS archive_static + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) ++ endif() + INSTALL_MAN(${libarchive_MANS}) + INSTALL(FILES ${include_HEADERS} DESTINATION include) + ENDIF() diff --git a/recipes/libarchive/all/patches/0003-3.4.3-cmake.patch b/recipes/libarchive/all/patches/0003-3.4.3-cmake.patch new file mode 100644 index 0000000000000..5c46b58290b77 --- /dev/null +++ b/recipes/libarchive/all/patches/0003-3.4.3-cmake.patch @@ -0,0 +1,101 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6013d9e6..125b1cb3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,7 +6,7 @@ endif() + # + PROJECT(libarchive C) + # +-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin) + endif() +@@ -418,7 +418,7 @@ IF(ZLIB_FOUND) + SET(HAVE_LIBZ 1) + SET(HAVE_ZLIB_H 1) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) +- LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) ++ LIST(APPEND ADDITIONAL_LIBS ZLIB::ZLIB) + IF(WIN32 AND NOT CYGWIN) + set(ZLIB_WINAPI yes) + IF(ZLIB_WINAPI) +@@ -480,7 +480,7 @@ IF(LIBLZMA_FOUND) + SET(HAVE_LIBLZMA 1) + SET(HAVE_LZMA_H 1) + CMAKE_PUSH_CHECK_STATE() +- SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIR}) ++ SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIRS}) + SET(CMAKE_REQUIRED_LIBRARIES ${LIBLZMA_LIBRARIES}) + INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) + LIST(APPEND ADDITIONAL_LIBS ${LIBLZMA_LIBRARIES}) +@@ -497,7 +497,7 @@ IF(LIBLZMA_FOUND) + ELSE(LIBLZMA_FOUND) + # LZMA not found and will not be used. + ENDIF(LIBLZMA_FOUND) +-MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIR) ++MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIRS) + MARK_AS_ADVANCED(CLEAR LIBLZMA_LIBRARY) + + # +@@ -567,7 +567,7 @@ IF(ENABLE_LZ4) + ENDIF (LZ4_INCLUDE_DIR) + + FIND_PATH(LZ4_INCLUDE_DIR lz4.h) +- FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4) ++ FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4 lz4_static liblz4_static) + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) + ELSE(ENABLE_LZ4) +@@ -783,7 +783,7 @@ ENDIF(ENABLE_NETTLE) + # Find OpenSSL + # (Except on Mac, where OpenSSL is deprecated.) + # +-IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") ++IF(ENABLE_OPENSSL) + FIND_PACKAGE(OpenSSL) + IF(OPENSSL_FOUND) + SET(HAVE_LIBCRYPTO 1) +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +index 9389bbc9..76e0b5c7 100644 +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -236,11 +236,15 @@ ELSEIF(ARCHIVE_ACL_SUNOS) + ENDIF() + + # Libarchive is a shared library ++if (BUILD_SHARED_LIBS) ++ + ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_INCLUDE_DIRECTORIES(archive PUBLIC .) + TARGET_LINK_LIBRARIES(archive ${ADDITIONAL_LIBS}) + SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION}) + ++else() ++ + # archive_static is a static library + ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS}) +@@ -250,13 +254,21 @@ SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS + IF(NOT WIN32 OR CYGWIN) + SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive) + ENDIF(NOT WIN32 OR CYGWIN) ++endif() + + IF(ENABLE_INSTALL) + # How to install the libraries +- INSTALL(TARGETS archive archive_static ++ if (BUILD_SHARED_LIBS) ++ INSTALL(TARGETS archive ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib) ++ else() ++ INSTALL(TARGETS archive_static + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) ++ endif() + INSTALL_MAN(${libarchive_MANS}) + INSTALL(FILES ${include_HEADERS} DESTINATION include) + ENDIF() diff --git a/recipes/libarchive/all/patches/0003-3.5.2-cmake.patch b/recipes/libarchive/all/patches/0003-3.5.2-cmake.patch new file mode 100644 index 0000000000000..5584b5f1606bc --- /dev/null +++ b/recipes/libarchive/all/patches/0003-3.5.2-cmake.patch @@ -0,0 +1,101 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e0359b51..3927a742 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,7 +6,7 @@ endif() + # + PROJECT(libarchive C) + # +-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin) + endif() +@@ -418,7 +418,7 @@ IF(ZLIB_FOUND) + SET(HAVE_LIBZ 1) + SET(HAVE_ZLIB_H 1) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) +- LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) ++ LIST(APPEND ADDITIONAL_LIBS ZLIB::ZLIB) + IF(WIN32 AND NOT CYGWIN) + set(ZLIB_WINAPI yes) + IF(ZLIB_WINAPI) +@@ -480,7 +480,7 @@ IF(LIBLZMA_FOUND) + SET(HAVE_LIBLZMA 1) + SET(HAVE_LZMA_H 1) + CMAKE_PUSH_CHECK_STATE() +- SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIR}) ++ SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIRS}) + SET(CMAKE_REQUIRED_LIBRARIES ${LIBLZMA_LIBRARIES}) + INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) + LIST(APPEND ADDITIONAL_LIBS ${LIBLZMA_LIBRARIES}) +@@ -497,7 +497,7 @@ IF(LIBLZMA_FOUND) + ELSE(LIBLZMA_FOUND) + # LZMA not found and will not be used. + ENDIF(LIBLZMA_FOUND) +-MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIR) ++MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIRS) + MARK_AS_ADVANCED(CLEAR LIBLZMA_LIBRARY) + + # +@@ -567,7 +567,7 @@ IF(ENABLE_LZ4) + ENDIF (LZ4_INCLUDE_DIR) + + FIND_PATH(LZ4_INCLUDE_DIR lz4.h) +- FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4) ++ FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4 lz4_static liblz4_static) + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) + ELSE(ENABLE_LZ4) +@@ -783,7 +783,7 @@ ENDIF(ENABLE_NETTLE) + # Find OpenSSL + # (Except on Mac, where OpenSSL is deprecated.) + # +-IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") ++IF(ENABLE_OPENSSL) + FIND_PACKAGE(OpenSSL) + IF(OPENSSL_FOUND) + SET(HAVE_LIBCRYPTO 1) +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +index e1d76a51..792b26b3 100644 +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -238,11 +238,15 @@ ELSEIF(ARCHIVE_ACL_SUNOS) + ENDIF() + + # Libarchive is a shared library ++if (BUILD_SHARED_LIBS) ++ + ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_INCLUDE_DIRECTORIES(archive PUBLIC .) + TARGET_LINK_LIBRARIES(archive ${ADDITIONAL_LIBS}) + SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION}) + ++else() ++ + # archive_static is a static library + ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS}) +@@ -252,13 +256,21 @@ SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS + IF(NOT WIN32 OR CYGWIN) + SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive) + ENDIF(NOT WIN32 OR CYGWIN) ++endif() + + IF(ENABLE_INSTALL) + # How to install the libraries +- INSTALL(TARGETS archive archive_static ++ if (BUILD_SHARED_LIBS) ++ INSTALL(TARGETS archive ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib) ++ else() ++ INSTALL(TARGETS archive_static + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) ++ endif() + INSTALL_MAN(${libarchive_MANS}) + INSTALL(FILES ${include_HEADERS} DESTINATION include) + ENDIF() diff --git a/recipes/libarchive/all/patches/0003-3.6.0-cmake.patch b/recipes/libarchive/all/patches/0003-3.6.0-cmake.patch new file mode 100644 index 0000000000000..436c8194e3e4d --- /dev/null +++ b/recipes/libarchive/all/patches/0003-3.6.0-cmake.patch @@ -0,0 +1,112 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 646e5ce7..9bca273f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -9,7 +9,7 @@ endif() + # + PROJECT(libarchive C) + # +-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake") + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${libarchive_BINARY_DIR}/bin) + endif() +@@ -424,7 +424,7 @@ IF(ZLIB_FOUND) + SET(HAVE_LIBZ 1) + SET(HAVE_ZLIB_H 1) + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) +- LIST(APPEND ADDITIONAL_LIBS ${ZLIB_LIBRARIES}) ++ LIST(APPEND ADDITIONAL_LIBS ZLIB::ZLIB) + IF(WIN32 AND NOT CYGWIN) + set(ZLIB_WINAPI yes) + IF(ZLIB_WINAPI) +@@ -486,7 +486,7 @@ IF(LIBLZMA_FOUND) + SET(HAVE_LIBLZMA 1) + SET(HAVE_LZMA_H 1) + CMAKE_PUSH_CHECK_STATE() +- SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIR}) ++ SET(CMAKE_REQUIRED_INCLUDES ${LIBLZMA_INCLUDE_DIRS}) + SET(CMAKE_REQUIRED_LIBRARIES ${LIBLZMA_LIBRARIES}) + INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) + LIST(APPEND ADDITIONAL_LIBS ${LIBLZMA_LIBRARIES}) +@@ -503,7 +503,7 @@ IF(LIBLZMA_FOUND) + ELSE(LIBLZMA_FOUND) + # LZMA not found and will not be used. + ENDIF(LIBLZMA_FOUND) +-MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIR) ++MARK_AS_ADVANCED(CLEAR LIBLZMA_INCLUDE_DIRS) + MARK_AS_ADVANCED(CLEAR LIBLZMA_LIBRARY) + + # +@@ -573,7 +573,7 @@ IF(ENABLE_LZ4) + ENDIF (LZ4_INCLUDE_DIR) + + FIND_PATH(LZ4_INCLUDE_DIR lz4.h) +- FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4) ++ FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4 lz4_static liblz4_static) + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR) + ELSE(ENABLE_LZ4) +@@ -790,7 +790,7 @@ ENDIF(ENABLE_NETTLE) + # Find OpenSSL + # (Except on Mac, where OpenSSL is deprecated.) + # +-IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") ++IF(ENABLE_OPENSSL) + FIND_PACKAGE(OpenSSL) + IF(OPENSSL_FOUND) + SET(HAVE_LIBCRYPTO 1) +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +index e1d76a51..713c6496 100644 +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -5,6 +5,10 @@ + # + ############################################ + ++if (ANDROID) ++ include_directories(${PROJECT_SOURCE_DIR}/contrib/android/include) ++endif() ++ + # Public headers + SET(include_HEADERS + archive.h +@@ -238,11 +242,15 @@ ELSEIF(ARCHIVE_ACL_SUNOS) + ENDIF() + + # Libarchive is a shared library ++if (BUILD_SHARED_LIBS) ++ + ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_INCLUDE_DIRECTORIES(archive PUBLIC .) + TARGET_LINK_LIBRARIES(archive ${ADDITIONAL_LIBS}) + SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION}) + ++else() ++ + # archive_static is a static library + ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS}) + TARGET_LINK_LIBRARIES(archive_static ${ADDITIONAL_LIBS}) +@@ -252,13 +260,21 @@ SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS + IF(NOT WIN32 OR CYGWIN) + SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive) + ENDIF(NOT WIN32 OR CYGWIN) ++endif() + + IF(ENABLE_INSTALL) + # How to install the libraries +- INSTALL(TARGETS archive archive_static ++ if (BUILD_SHARED_LIBS) ++ INSTALL(TARGETS archive ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib) ++ else() ++ INSTALL(TARGETS archive_static + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) ++ endif() + INSTALL_MAN(${libarchive_MANS}) + INSTALL(FILES ${include_HEADERS} DESTINATION include) + ENDIF() diff --git a/recipes/libarchive/all/patches/0004-3.6.0-android.patch b/recipes/libarchive/all/patches/0004-3.6.0-android.patch new file mode 100644 index 0000000000000..c4c91d3ecb18a --- /dev/null +++ b/recipes/libarchive/all/patches/0004-3.6.0-android.patch @@ -0,0 +1,15 @@ +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +index 792b26b3..713c6496 100644 +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -5,6 +5,10 @@ + # + ############################################ + ++if (ANDROID) ++ include_directories(${PROJECT_SOURCE_DIR}/contrib/android/include) ++endif() ++ + # Public headers + SET(include_HEADERS + archive.h diff --git a/recipes/libarchive/all/patches/msvc-no-we4061.patch b/recipes/libarchive/all/patches/msvc-no-we4061.patch deleted file mode 100644 index 196cebcfb9baa..0000000000000 --- a/recipes/libarchive/all/patches/msvc-no-we4061.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -157,7 +157,6 @@ IF (MSVC) - # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" - # Enable level 4 C4061: The enumerate has no associated handler in a switch - # statement. -- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4061") - # Enable level 4 C4254: A larger bit field was assigned to a smaller bit - # field. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4254") diff --git a/recipes/libarchive/all/test_package/CMakeLists.txt b/recipes/libarchive/all/test_package/CMakeLists.txt index 34af13462f44f..925a2be0857c5 100644 --- a/recipes/libarchive/all/test_package/CMakeLists.txt +++ b/recipes/libarchive/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(LibArchive REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE LibArchive::LibArchive) diff --git a/recipes/libarchive/all/test_package/conanfile.py b/recipes/libarchive/all/test_package/conanfile.py index bd7165a553cf4..a9fb96656f203 100644 --- a/recipes/libarchive/all/test_package/conanfile.py +++ b/recipes/libarchive/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libarchive/all/test_v1_package/CMakeLists.txt b/recipes/libarchive/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/libarchive/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libarchive/all/test_v1_package/conanfile.py b/recipes/libarchive/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/libarchive/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libarchive/config.yml b/recipes/libarchive/config.yml index 6f124321b75a9..5e7bb50cad34c 100644 --- a/recipes/libarchive/config.yml +++ b/recipes/libarchive/config.yml @@ -1,4 +1,10 @@ versions: + "3.6.1": + folder: all + "3.6.0": + folder: all + "3.5.2": + folder: all "3.5.1": folder: all "3.4.3": diff --git a/recipes/libatomic_ops/all/conandata.yml b/recipes/libatomic_ops/all/conandata.yml index eb755e43841a6..59db3060423da 100644 --- a/recipes/libatomic_ops/all/conandata.yml +++ b/recipes/libatomic_ops/all/conandata.yml @@ -1,4 +1,10 @@ sources: - "7.6.10": - url: "https://github.com/ivmai/libatomic_ops/releases/download/v7.6.10/libatomic_ops-7.6.10.tar.gz" - sha256: "587edf60817f56daf1e1ab38a4b3c729b8e846ff67b4f62a6157183708f099af" + "7.6.14": + url: "https://github.com/ivmai/libatomic_ops/releases/download/v7.6.14/libatomic_ops-7.6.14.tar.gz" + sha256: "390f244d424714735b7050d056567615b3b8f29008a663c262fb548f1802d292" +patches: + "7.6.14": + - patch_file: "patches/enable-cmake-7_6_14.patch" + patch_description: "Support build with CMake" + patch_source: "https://github.com/ivmai/libatomic_ops/blob/044573903530c4a8e8318e20a830d4a0531b2035/CMakeLists.txt" + patch_type: "backport" diff --git a/recipes/libatomic_ops/all/conanfile.py b/recipes/libatomic_ops/all/conanfile.py index fd685a297dc2c..8bdc55215ddd6 100644 --- a/recipes/libatomic_ops/all/conanfile.py +++ b/recipes/libatomic_ops/all/conanfile.py @@ -1,9 +1,13 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from contextlib import contextmanager +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir, export_conandata_patches import os -class Libatomic_opsConan(ConanFile): +required_conan_version = ">=1.52.0" + + +class Atomic_opsConan(ConanFile): name = "libatomic_ops" homepage = "https://github.com/ivmai/libatomic_ops" description = "The atomic_ops project (Atomic memory update operations portable implementation)" @@ -12,6 +16,11 @@ class Libatomic_opsConan(ConanFile): license = "GPL-2.0-or-later" settings = "os", "compiler", "build_type", "arch" + _cmake_options_defaults = ( + ("assertions", False,), + ("atomic_intrinsics", True,), + ) + options = { "shared": [True, False], "fPIC": [True, False], @@ -20,75 +29,78 @@ class Libatomic_opsConan(ConanFile): "shared": False, "fPIC": True, } + for option, default in _cmake_options_defaults: + options[option] = [True, False] + default_options[option] = default - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.options.fPIC + except Exception: + pass - def build_requirements(self): - if tools.os_info.is_windows and "CONAN_BASH_PATH" not in os.environ \ - and tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libatomic_ops-{}".format(self.version), self._source_subfolder) - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - conf_args = [] - if self.options.shared: - conf_args.extend(["--enable-shared", "--disable-static"]) - else: - conf_args.extend(["--disable-shared", "--enable-static"]) - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return self._autotools - - @contextmanager - def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - with tools.environment_append({"CC": "cl -nologo", "CXX": "cl -nologo", - "LD": "link"}): - yield - else: - yield + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + for option, _ in self._cmake_options_defaults: + tc.variables["enable_{}".format(option)] = self.options.get_safe(option) + tc.variables["install_headers"] = True + tc.variables["build_tests"] = False + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + tc = CMakeDeps(self) + tc.generate() def build(self): - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() - - os.unlink(os.path.join(self.package_folder, "lib", "libatomic_ops.la")) - os.unlink(os.path.join(self.package_folder, "lib", "libatomic_ops_gpl.la")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.names["pkg_config"] = "atomic_ops" - libs = ["atomic_ops_gpl", "atomic_ops"] - if self.settings.os == "Windows" and self.options.shared: - ext = "lib" if self.settings.compiler == "Visual Studio" else "a" - libs = list("{}.dll.{}".format(lib, ext) for lib in libs) - self.cpp_info.libs = libs + self.cpp_info.set_property("cmake_file_name", "Atomic_ops") + self.cpp_info.set_property("cmake_target_name", "Atomic_ops::atomic_ops_gpl") # workaround to not define an unofficial target + + # TODO: Remove on Conan 2.0 + self.cpp_info.names["cmake_find_package"] = "Atomic_ops" + self.cpp_info.names["cmake_find_package_multi"] = "Atomic_ops" + + self.cpp_info.components["atomic_ops"].set_property("cmake_target_name", "Atomic_ops::atomic_ops") + self.cpp_info.components["atomic_ops"].set_property("pkg_config_name", "atomic_ops") + self.cpp_info.components["atomic_ops"].libs = ["atomic_ops"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["atomic_ops"].system_libs = ["pthread"] + + self.cpp_info.components["atomic_ops_gpl"].set_property("cmake_target_name", "Atomic_ops::atomic_ops_gpl") + self.cpp_info.components["atomic_ops_gpl"].libs = ["atomic_ops_gpl"] + self.cpp_info.components["atomic_ops_gpl"].requires = ["atomic_ops"] diff --git a/recipes/libatomic_ops/all/patches/enable-cmake-7_6_14.patch b/recipes/libatomic_ops/all/patches/enable-cmake-7_6_14.patch new file mode 100644 index 0000000000000..15470fd99352f --- /dev/null +++ b/recipes/libatomic_ops/all/patches/enable-cmake-7_6_14.patch @@ -0,0 +1,730 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +new file mode 100644 +index 0000000..8b26697 +--- /dev/null ++++ b/CMakeLists.txt +@@ -0,0 +1,341 @@ ++# ++# Copyright (c) 2021-2022 Ivan Maidanski ++## ++# Permission is hereby granted, free of charge, to any person obtaining a copy ++# of this software and associated documentation files (the "Software"), to deal ++# in the Software without restriction, including without limitation the rights ++# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++# copies of the Software, and to permit persons to whom the Software is ++# furnished to do so, subject to the following conditions: ++# ++# The above copyright notice and this permission notice shall be included in ++# all copies or substantial portions of the Software. ++# ++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++# SOFTWARE. ++## ++ ++cmake_minimum_required(VERSION 3.1) ++ ++set(PACKAGE_VERSION 7.6.14) ++# Version must match that in AC_INIT of configure.ac and that in README. ++# Version must conform to: [0-9]+[.][0-9]+[.][0-9]+ ++ ++# Info (current:revision:age) for the Libtool versioning system. ++# These values should match those in src/Makefile.am. ++set(LIBATOMIC_OPS_VER_INFO 2:1:1) ++set(LIBATOMIC_OPS_GPL_VER_INFO 2:3:1) ++ ++project(libatomic_ops C) ++ ++if (POLICY CMP0057) ++ # Required for CheckLinkerFlag, at least. ++ cmake_policy(SET CMP0057 NEW) ++endif() ++ ++include(CheckCCompilerFlag) ++include(CheckFunctionExists) ++include(CMakePackageConfigHelpers) ++include(CTest) ++include(GNUInstallDirs) ++ ++if (NOT (${CMAKE_VERSION} VERSION_LESS "3.18.0")) ++ include(CheckLinkerFlag) ++endif() ++ ++# Customize the build by passing "-D=ON|OFF" in the command line. ++option(BUILD_SHARED_LIBS "Build shared libraries" OFF) ++option(build_tests "Build tests" OFF) ++option(enable_assertions "Enable assertion checking" OFF) ++option(enable_werror "Treat warnings as errors" OFF) ++option(enable_atomic_intrinsics "Use GCC atomic intrinsics" ON) ++option(enable_docs "Build and install documentation" ON) ++option(install_headers "Install header and pkg-config metadata files" ON) ++ ++# Override the default build type to RelWithDebInfo (this instructs cmake to ++# pass -O2 -g -DNDEBUG options to the compiler). ++if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) ++ set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE ++ STRING "Choose the type of build." FORCE) ++ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY ++ STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel") ++endif() ++ ++# Convert VER_INFO values to [SO]VERSION ones. ++if (BUILD_SHARED_LIBS) ++ # atomic_ops: ++ string(REGEX REPLACE "(.+):.+:.+" "\\1" ao_cur ${LIBATOMIC_OPS_VER_INFO}) ++ string(REGEX REPLACE ".+:(.+):.+" "\\1" ao_rev ${LIBATOMIC_OPS_VER_INFO}) ++ string(REGEX REPLACE ".+:.+:(.+)$" "\\1" ao_age ${LIBATOMIC_OPS_VER_INFO}) ++ math(EXPR AO_SOVERSION "${ao_cur} - ${ao_age}") ++ set(AO_VERSION_PROP "${AO_SOVERSION}.${ao_age}.${ao_rev}") ++ message(STATUS "AO_VERSION_PROP = ${AO_VERSION_PROP}") ++ # atomic_ops_gpl: ++ string(REGEX REPLACE "(.+):.+:.+" "\\1" ao_gpl_cur ++ ${LIBATOMIC_OPS_GPL_VER_INFO}) ++ string(REGEX REPLACE ".+:(.+):.+" "\\1" ao_gpl_rev ++ ${LIBATOMIC_OPS_GPL_VER_INFO}) ++ string(REGEX REPLACE ".+:.+:(.+)$" "\\1" ao_gpl_age ++ ${LIBATOMIC_OPS_GPL_VER_INFO}) ++ math(EXPR AO_GPL_SOVERSION "${ao_gpl_cur} - ${ao_gpl_age}") ++ set(AO_GPL_VERSION_PROP "${AO_GPL_SOVERSION}.${ao_gpl_age}.${ao_gpl_rev}") ++ message(STATUS "AO_GPL_VERSION_PROP = ${AO_GPL_VERSION_PROP}") ++endif(BUILD_SHARED_LIBS) ++ ++# Output all warnings. ++if (MSVC) ++ # All warnings but ignoring "conditional expression is constant" ones. ++ add_compile_options(/W4 /wd4127) ++else() ++ add_compile_options(-Wall -Wextra) ++endif() ++ ++find_package(Threads REQUIRED) ++message(STATUS "Thread library: ${CMAKE_THREAD_LIBS_INIT}") ++include_directories(${Threads_INCLUDE_DIR}) ++set(THREADDLLIBS_LIST ${CMAKE_THREAD_LIBS_INIT}) ++ ++if (CMAKE_USE_PTHREADS_INIT) ++ # Required define if using POSIX threads. ++ add_compile_options(-D_REENTRANT) ++else() ++ # No pthreads library available. ++ add_compile_options(-DAO_NO_PTHREADS) ++endif() ++ ++if (enable_assertions) ++ # In case NDEBUG macro is defined e.g. by cmake -DCMAKE_BUILD_TYPE=Release. ++ add_compile_options(-UNDEBUG) ++else() ++ # Define to disable assertion checking. ++ add_compile_options(-DNDEBUG) ++endif() ++ ++if (NOT enable_atomic_intrinsics) ++ # Define to avoid GCC atomic intrinsics even if available. ++ add_compile_options(-DAO_DISABLE_GCC_ATOMICS) ++endif() ++ ++# AO API symbols export control. ++if (BUILD_SHARED_LIBS) ++ add_compile_options(-DAO_DLL) ++endif() ++ ++if (enable_werror) ++ if (MSVC) ++ add_compile_options(/WX) ++ else() ++ add_compile_options(-Werror) ++ endif() ++endif(enable_werror) ++ ++# Extra user-defined flags to pass to the C compiler. ++if (DEFINED CFLAGS_EXTRA) ++ separate_arguments(CFLAGS_EXTRA_LIST UNIX_COMMAND "${CFLAGS_EXTRA}") ++ add_compile_options(${CFLAGS_EXTRA_LIST}) ++endif() ++ ++set(SRC src/atomic_ops.c) ++ ++if (CMAKE_C_COMPILER_ID STREQUAL "SunPro") ++ # SunCC compiler on SunOS (Solaris). ++ set(SRC ${SRC} src/atomic_ops_sysdeps.S) ++endif() ++ ++add_library(atomic_ops ${SRC}) ++target_link_libraries(atomic_ops PRIVATE ${THREADDLLIBS_LIST}) ++target_include_directories(atomic_ops ++ PUBLIC "$" ++ INTERFACE "$") ++ ++set(AO_GPL_SRC src/atomic_ops_malloc.c src/atomic_ops_stack.c) ++add_library(atomic_ops_gpl ${AO_GPL_SRC}) ++check_function_exists(mmap HAVE_MMAP) ++if (HAVE_MMAP) ++ target_compile_definitions(atomic_ops_gpl PRIVATE HAVE_MMAP) ++endif() ++target_link_libraries(atomic_ops_gpl PRIVATE atomic_ops) ++target_include_directories(atomic_ops_gpl ++ PUBLIC "$" ++ INTERFACE "$") ++if (BUILD_SHARED_LIBS) ++ set_property(TARGET atomic_ops_gpl PROPERTY VERSION ${AO_GPL_VERSION_PROP}) ++ set_property(TARGET atomic_ops_gpl PROPERTY SOVERSION ${AO_GPL_SOVERSION}) ++endif() ++install(TARGETS atomic_ops_gpl EXPORT Atomic_opsTargets ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ++ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ++ ++if (BUILD_SHARED_LIBS) ++ if (${CMAKE_VERSION} VERSION_LESS "3.18.0") ++ set(WL_NO_UNDEFINED_OPT "-Wl,--no-undefined") ++ check_c_compiler_flag(${WL_NO_UNDEFINED_OPT} HAVE_FLAG_WL_NO_UNDEFINED) ++ else() ++ set(WL_NO_UNDEFINED_OPT "LINKER:--no-undefined") ++ check_linker_flag(C "${WL_NO_UNDEFINED_OPT}" HAVE_FLAG_WL_NO_UNDEFINED) ++ endif() ++ if (HAVE_FLAG_WL_NO_UNDEFINED) ++ # Declare that the libraries do not refer to external symbols. ++ if (${CMAKE_VERSION} VERSION_LESS "3.13.0") ++ target_link_libraries(atomic_ops PRIVATE ${WL_NO_UNDEFINED_OPT}) ++ target_link_libraries(atomic_ops_gpl PRIVATE ${WL_NO_UNDEFINED_OPT}) ++ else() ++ target_link_options(atomic_ops PRIVATE ${WL_NO_UNDEFINED_OPT}) ++ target_link_options(atomic_ops_gpl PRIVATE ${WL_NO_UNDEFINED_OPT}) ++ endif() ++ endif(HAVE_FLAG_WL_NO_UNDEFINED) ++ set_property(TARGET atomic_ops PROPERTY VERSION ${AO_VERSION_PROP}) ++ set_property(TARGET atomic_ops PROPERTY SOVERSION ${AO_SOVERSION}) ++endif(BUILD_SHARED_LIBS) ++ ++install(TARGETS atomic_ops EXPORT Atomic_opsTargets ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ++ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ++ ++if (install_headers) ++ install(FILES src/atomic_ops.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ++ install(FILES src/atomic_ops_malloc.h ++ src/atomic_ops_stack.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ++ ++ install(FILES src/atomic_ops/ao_version.h ++ src/atomic_ops/generalize-arithm.h ++ src/atomic_ops/generalize-small.h ++ src/atomic_ops/generalize.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/atomic_ops") ++ ++ install(FILES src/atomic_ops/sysdeps/all_acquire_release_volatile.h ++ src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h ++ src/atomic_ops/sysdeps/all_atomic_load_store.h ++ src/atomic_ops/sysdeps/all_atomic_only_load.h ++ src/atomic_ops/sysdeps/ao_t_is_int.h ++ src/atomic_ops/sysdeps/emul_cas.h ++ src/atomic_ops/sysdeps/generic_pthread.h ++ src/atomic_ops/sysdeps/ordered.h ++ src/atomic_ops/sysdeps/ordered_except_wr.h ++ src/atomic_ops/sysdeps/read_ordered.h ++ src/atomic_ops/sysdeps/standard_ao_double_t.h ++ src/atomic_ops/sysdeps/test_and_set_t_is_ao_t.h ++ src/atomic_ops/sysdeps/test_and_set_t_is_char.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/atomic_ops/sysdeps") ++ ++ install(FILES src/atomic_ops/sysdeps/armcc/arm_v6.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/atomic_ops/sysdeps/armcc") ++ install(FILES src/atomic_ops/sysdeps/gcc/aarch64.h ++ src/atomic_ops/sysdeps/gcc/alpha.h ++ src/atomic_ops/sysdeps/gcc/arm.h ++ src/atomic_ops/sysdeps/gcc/avr32.h ++ src/atomic_ops/sysdeps/gcc/cris.h ++ src/atomic_ops/sysdeps/gcc/generic-arithm.h ++ src/atomic_ops/sysdeps/gcc/generic-small.h ++ src/atomic_ops/sysdeps/gcc/generic.h ++ src/atomic_ops/sysdeps/gcc/hexagon.h ++ src/atomic_ops/sysdeps/gcc/hppa.h ++ src/atomic_ops/sysdeps/gcc/ia64.h ++ src/atomic_ops/sysdeps/gcc/m68k.h ++ src/atomic_ops/sysdeps/gcc/mips.h ++ src/atomic_ops/sysdeps/gcc/powerpc.h ++ src/atomic_ops/sysdeps/gcc/riscv.h ++ src/atomic_ops/sysdeps/gcc/s390.h ++ src/atomic_ops/sysdeps/gcc/sh.h ++ src/atomic_ops/sysdeps/gcc/sparc.h ++ src/atomic_ops/sysdeps/gcc/tile.h ++ src/atomic_ops/sysdeps/gcc/x86.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/atomic_ops/sysdeps/gcc") ++ ++ install(FILES src/atomic_ops/sysdeps/hpc/hppa.h ++ src/atomic_ops/sysdeps/hpc/ia64.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/atomic_ops/sysdeps/hpc") ++ install(FILES src/atomic_ops/sysdeps/ibmc/powerpc.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/atomic_ops/sysdeps/ibmc") ++ install(FILES src/atomic_ops/sysdeps/icc/ia64.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/atomic_ops/sysdeps/icc") ++ ++ install(FILES src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.h ++ src/atomic_ops/sysdeps/loadstore/atomic_load.h ++ src/atomic_ops/sysdeps/loadstore/atomic_store.h ++ src/atomic_ops/sysdeps/loadstore/char_acquire_release_volatile.h ++ src/atomic_ops/sysdeps/loadstore/char_atomic_load.h ++ src/atomic_ops/sysdeps/loadstore/char_atomic_store.h ++ src/atomic_ops/sysdeps/loadstore/double_atomic_load_store.h ++ src/atomic_ops/sysdeps/loadstore/int_acquire_release_volatile.h ++ src/atomic_ops/sysdeps/loadstore/int_atomic_load.h ++ src/atomic_ops/sysdeps/loadstore/int_atomic_store.h ++ src/atomic_ops/sysdeps/loadstore/ordered_loads_only.h ++ src/atomic_ops/sysdeps/loadstore/ordered_stores_only.h ++ src/atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h ++ src/atomic_ops/sysdeps/loadstore/short_atomic_load.h ++ src/atomic_ops/sysdeps/loadstore/short_atomic_store.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/atomic_ops/sysdeps/loadstore") ++ ++ install(FILES src/atomic_ops/sysdeps/msftc/arm.h ++ src/atomic_ops/sysdeps/msftc/common32_defs.h ++ src/atomic_ops/sysdeps/msftc/x86.h ++ src/atomic_ops/sysdeps/msftc/x86_64.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/atomic_ops/sysdeps/msftc") ++ install(FILES src/atomic_ops/sysdeps/sunc/sparc.h ++ src/atomic_ops/sysdeps/sunc/x86.h ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/atomic_ops/sysdeps/sunc") ++ ++ # Provide pkg-config metadata. ++ set(prefix "${CMAKE_INSTALL_PREFIX}") ++ set(exec_prefix \${prefix}) ++ set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") ++ set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") ++ string(REPLACE ";" " " THREADDLLIBS "${THREADDLLIBS_LIST}") ++ # PACKAGE_VERSION is defined above. ++ configure_file(pkgconfig/atomic_ops.pc.in pkgconfig/atomic_ops.pc @ONLY) ++ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/atomic_ops.pc" ++ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") ++endif(install_headers) ++ ++if (build_tests) ++ add_executable(test_stack tests/test_stack.c) ++ target_link_libraries(test_stack ++ PRIVATE atomic_ops atomic_ops_gpl ${THREADDLLIBS_LIST}) ++ add_test(NAME test_stack COMMAND test_stack) ++ ++ add_executable(test_malloc tests/test_malloc.c) ++ target_link_libraries(test_malloc ++ PRIVATE atomic_ops atomic_ops_gpl ${THREADDLLIBS_LIST}) ++ add_test(NAME test_malloc COMMAND test_malloc) ++endif(build_tests) ++ ++if (enable_docs) ++ install(FILES AUTHORS doc/LICENSING.txt README.md ++ doc/README_details.txt doc/README_win32.txt ++ DESTINATION "${CMAKE_INSTALL_DOCDIR}") ++ install(FILES COPYING doc/README_malloc.txt doc/README_stack.txt ++ DESTINATION "${CMAKE_INSTALL_DOCDIR}") ++endif(enable_docs) ++ ++# CMake config/targets files. ++install(EXPORT Atomic_opsTargets FILE Atomic_opsTargets.cmake ++ NAMESPACE Atomic_ops:: ++ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/atomic_ops") ++ ++configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in" ++ "${CMAKE_CURRENT_BINARY_DIR}/Atomic_opsConfig.cmake" ++ INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/atomic_ops" ++ NO_SET_AND_CHECK_MACRO) ++ ++write_basic_package_version_file( ++ "${CMAKE_CURRENT_BINARY_DIR}/Atomic_opsConfigVersion.cmake" ++ VERSION "${PACKAGE_VERSION}" COMPATIBILITY AnyNewerVersion) ++ ++install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Atomic_opsConfig.cmake" ++ "${CMAKE_CURRENT_BINARY_DIR}/Atomic_opsConfigVersion.cmake" ++ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/atomic_ops") ++ ++export(EXPORT Atomic_opsTargets ++ FILE "${CMAKE_CURRENT_BINARY_DIR}/Atomic_opsTargets.cmake") +diff --git a/Config.cmake.in b/Config.cmake.in +new file mode 100644 +index 0000000..034b456 +--- /dev/null ++++ b/Config.cmake.in +@@ -0,0 +1,5 @@ ++# The Atomic_ops CMake configuration file. ++ ++@PACKAGE_INIT@ ++include("${CMAKE_CURRENT_LIST_DIR}/Atomic_opsTargets.cmake") ++check_required_components(libatomic_ops) +diff --git a/configure.ac b/configure.ac +index ccf3230..eec3863 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -234,6 +234,12 @@ else + fi + AC_SUBST(THREADDLLIBS) + ++# AO API symbols export control. ++# Compile with AO_DLL defined unless building static libraries. ++if test x$enable_shared = xyes -a x$enable_static = xno; then ++ CFLAGS="-DAO_DLL $CFLAGS" ++fi ++ + AM_CONDITIONAL(ENABLE_SHARED, test x$enable_shared = xyes) + AM_CONDITIONAL(HAVE_PTHREAD_H, test x$have_pthreads = xtrue) + AM_CONDITIONAL(NEED_ASM, test x$need_asm = xtrue) +diff --git a/src/atomic_ops.c b/src/atomic_ops.c +index 5e6577f..1e5f3c9 100644 +--- a/src/atomic_ops.c ++++ b/src/atomic_ops.c +@@ -51,6 +51,10 @@ + # define _GNU_SOURCE 1 + #endif + ++#ifndef AO_BUILD ++# define AO_BUILD ++#endif ++ + #undef AO_REQUIRE_CAS + #include "atomic_ops.h" /* Without cas emulation! */ + +@@ -83,6 +87,8 @@ + + /* Lock for pthreads-based implementation. */ + #ifndef AO_NO_PTHREADS ++ AO_API pthread_mutex_t AO_pt_lock; ++ + pthread_mutex_t AO_pt_lock = PTHREAD_MUTEX_INITIALIZER; + #endif + +@@ -109,7 +115,7 @@ static AO_TS_t AO_locks[AO_HASH_SIZE] = { + AO_TS_INITIALIZER, AO_TS_INITIALIZER, AO_TS_INITIALIZER, AO_TS_INITIALIZER, + }; + +-void AO_pause(int); /* defined below */ ++AO_API void AO_pause(int); /* defined below */ + + static void lock_ool(volatile AO_TS_t *l) + { +@@ -156,8 +162,8 @@ AO_INLINE void unlock(volatile AO_TS_t *l) + } + #endif /* !AO_USE_NO_SIGNALS */ + +-AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, AO_t old_val, +- AO_t new_val) ++AO_API AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, ++ AO_t old_val, AO_t new_val) + { + AO_TS_t *my_lock = AO_locks + AO_HASH(addr); + AO_t fetched_val; +@@ -177,9 +183,10 @@ AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, AO_t old_val, + return fetched_val; + } + +-int AO_compare_double_and_swap_double_emulation(volatile AO_double_t *addr, +- AO_t old_val1, AO_t old_val2, +- AO_t new_val1, AO_t new_val2) ++AO_API int ++AO_compare_double_and_swap_double_emulation(volatile AO_double_t *addr, ++ AO_t old_val1, AO_t old_val2, ++ AO_t new_val1, AO_t new_val2) + { + AO_TS_t *my_lock = AO_locks + AO_HASH(addr); + int result; +@@ -204,7 +211,7 @@ int AO_compare_double_and_swap_double_emulation(volatile AO_double_t *addr, + return result; + } + +-void AO_store_full_emulation(volatile AO_t *addr, AO_t val) ++AO_API void AO_store_full_emulation(volatile AO_t *addr, AO_t val) + { + AO_TS_t *my_lock = AO_locks + AO_HASH(addr); + lock(my_lock); +@@ -237,7 +244,7 @@ static void AO_spin(int n) + AO_store(&spin_dummy, j); + } + +-void AO_pause(int n) ++AO_API void AO_pause(int n) + { + if (n < 12) + AO_spin(n); +diff --git a/src/atomic_ops.h b/src/atomic_ops.h +index 92d1f4a..1f996fe 100644 +--- a/src/atomic_ops.h ++++ b/src/atomic_ops.h +@@ -235,6 +235,30 @@ + # define AO_ALIGNOF_SUPPORTED 1 + #endif + ++#if defined(AO_DLL) && !defined(AO_API) ++# ifdef AO_BUILD ++# if defined(__CEGCC__) || (defined(__MINGW32__) && !defined(__cplusplus)) ++# define AO_API __declspec(dllexport) ++# elif defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CYGWIN__) \ ++ || defined(__DMC__) || defined(__MINGW32__) || defined(__WATCOMC__) ++# define AO_API extern __declspec(dllexport) ++# endif ++# else ++# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CEGCC__) \ ++ || defined(__CYGWIN__) || defined(__DMC__) ++# define AO_API __declspec(dllimport) ++# elif defined(__MINGW32_DELAY_LOAD__) ++# define AO_API __declspec(dllexport) ++# elif defined(__MINGW32__) || defined(__WATCOMC__) ++# define AO_API extern __declspec(dllimport) ++# endif ++# endif ++#endif /* AO_DLL */ ++ ++#ifndef AO_API ++# define AO_API extern ++#endif ++ + #ifdef AO_ALIGNOF_SUPPORTED + # define AO_ASSERT_ADDR_ALIGNED(addr) \ + assert(((size_t)(addr) & (__alignof__(*(addr)) - 1)) == 0) +diff --git a/src/atomic_ops/sysdeps/emul_cas.h b/src/atomic_ops/sysdeps/emul_cas.h +index e52f75a..c322a5b 100644 +--- a/src/atomic_ops/sysdeps/emul_cas.h ++++ b/src/atomic_ops/sysdeps/emul_cas.h +@@ -47,14 +47,15 @@ + extern "C" { + #endif + +-AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, AO_t old_val, +- AO_t new_val); ++AO_API AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, ++ AO_t old_val, AO_t new_val); + +-int AO_compare_double_and_swap_double_emulation(volatile AO_double_t *addr, +- AO_t old_val1, AO_t old_val2, +- AO_t new_val1, AO_t new_val2); ++AO_API int ++AO_compare_double_and_swap_double_emulation(volatile AO_double_t *addr, ++ AO_t old_val1, AO_t old_val2, ++ AO_t new_val1, AO_t new_val2); + +-void AO_store_full_emulation(volatile AO_t *addr, AO_t val); ++AO_API void AO_store_full_emulation(volatile AO_t *addr, AO_t val); + + #ifndef AO_HAVE_fetch_compare_and_swap_full + # define AO_fetch_compare_and_swap_full(addr, old, newval) \ +diff --git a/src/atomic_ops/sysdeps/generic_pthread.h b/src/atomic_ops/sysdeps/generic_pthread.h +index 854cb77..724b148 100644 +--- a/src/atomic_ops/sysdeps/generic_pthread.h ++++ b/src/atomic_ops/sysdeps/generic_pthread.h +@@ -39,7 +39,7 @@ + + /* We define only the full barrier variants, and count on the */ + /* generalization section below to fill in the rest. */ +-extern pthread_mutex_t AO_pt_lock; ++AO_API pthread_mutex_t AO_pt_lock; + + #ifdef __cplusplus + } /* extern "C" */ +diff --git a/src/atomic_ops_malloc.c b/src/atomic_ops_malloc.c +index adced80..19f49b2 100644 +--- a/src/atomic_ops_malloc.c ++++ b/src/atomic_ops_malloc.c +@@ -19,6 +19,10 @@ + # undef HAVE_MMAP + #endif + ++#ifndef AO_BUILD ++# define AO_BUILD ++#endif ++ + #define AO_REQUIRE_CAS + #include "atomic_ops_malloc.h" + +@@ -116,7 +120,7 @@ static volatile AO_t initial_heap_ptr = (AO_t)AO_initial_heap; + + static volatile AO_t mmap_enabled = 0; + +-void ++AO_API void + AO_malloc_enable_mmap(void) + { + # if defined(__sun) +@@ -200,7 +204,7 @@ AO_free_large(char * p) + + #else /* No MMAP */ + +-void ++AO_API void + AO_malloc_enable_mmap(void) + { + } +@@ -319,7 +323,7 @@ static unsigned msb(size_t s) + return result; + } + +-AO_ATTR_MALLOC AO_ATTR_ALLOC_SIZE(1) ++AO_API AO_ATTR_MALLOC AO_ATTR_ALLOC_SIZE(1) + void * + AO_malloc(size_t sz) + { +@@ -349,7 +353,7 @@ AO_malloc(size_t sz) + return result + 1; + } + +-void ++AO_API void + AO_free(void *p) + { + AO_t *base; +diff --git a/src/atomic_ops_malloc.h b/src/atomic_ops_malloc.h +index f9ed900..efd8880 100644 +--- a/src/atomic_ops_malloc.h ++++ b/src/atomic_ops_malloc.h +@@ -66,13 +66,13 @@ + # endif + #endif + +-void AO_free(void *); ++AO_API void AO_free(void *); + +-AO_ATTR_MALLOC AO_ATTR_ALLOC_SIZE(1) ++AO_API AO_ATTR_MALLOC AO_ATTR_ALLOC_SIZE(1) + void * AO_malloc(size_t); + + /* Allow use of mmap to grow the heap. No-op on some platforms. */ +-void AO_malloc_enable_mmap(void); ++AO_API void AO_malloc_enable_mmap(void); + + #ifdef __cplusplus + } /* extern "C" */ +diff --git a/src/atomic_ops_stack.c b/src/atomic_ops_stack.c +index c31c7bf..a5ac859 100644 +--- a/src/atomic_ops_stack.c ++++ b/src/atomic_ops_stack.c +@@ -19,6 +19,10 @@ + #include + #include + ++#ifndef AO_BUILD ++# define AO_BUILD ++#endif ++ + #define AO_REQUIRE_CAS + #include "atomic_ops_stack.h" + +@@ -36,7 +40,7 @@ + + #ifdef AO_USE_ALMOST_LOCK_FREE + +- void AO_pause(int); /* defined in atomic_ops.c */ ++ AO_API void AO_pause(int); /* defined in atomic_ops.c */ + + /* LIFO linked lists based on compare-and-swap. We need to avoid */ + /* the case of a node deletion and reinsertion while I'm deleting */ +@@ -58,8 +62,8 @@ + /* to be inserted. */ + /* Both list headers and link fields contain "perturbed" pointers, i.e. */ + /* pointers with extra bits "or"ed into the low order bits. */ +-void AO_stack_push_explicit_aux_release(volatile AO_t *list, AO_t *x, +- AO_stack_aux *a) ++AO_API void AO_stack_push_explicit_aux_release(volatile AO_t *list, AO_t *x, ++ AO_stack_aux *a) + { + AO_t x_bits = (AO_t)x; + AO_t next; +@@ -139,8 +143,8 @@ void AO_stack_push_explicit_aux_release(volatile AO_t *list, AO_t *x, + # define AO_load_next AO_load + #endif + +-AO_t * +-AO_stack_pop_explicit_aux_acquire(volatile AO_t *list, AO_stack_aux * a) ++AO_API AO_t *AO_stack_pop_explicit_aux_acquire(volatile AO_t *list, ++ AO_stack_aux *a) + { + unsigned i; + int j = 0; +@@ -254,7 +258,7 @@ AO_stack_pop_explicit_aux_acquire(volatile AO_t *list, AO_stack_aux * a) + volatile /* non-static */ AO_t AO_noop_sink; + #endif + +-void AO_stack_push_release(AO_stack_t *list, AO_t *element) ++AO_API void AO_stack_push_release(AO_stack_t *list, AO_t *element) + { + AO_t next; + +@@ -273,7 +277,7 @@ void AO_stack_push_release(AO_stack_t *list, AO_t *element) + # endif + } + +-AO_t *AO_stack_pop_acquire(AO_stack_t *list) ++AO_API AO_t *AO_stack_pop_acquire(AO_stack_t *list) + { + # if defined(__clang__) && !AO_CLANG_PREREQ(3, 5) + AO_t *volatile cptr; +@@ -307,7 +311,7 @@ AO_t *AO_stack_pop_acquire(AO_stack_t *list) + /* We have a wide CAS, but only does an AO_t-wide comparison. */ + /* We can't use the Treiber optimization, since we only check */ + /* for an unchanged version number, not an unchanged pointer. */ +-void AO_stack_push_release(AO_stack_t *list, AO_t *element) ++AO_API void AO_stack_push_release(AO_stack_t *list, AO_t *element) + { + AO_t version; + +@@ -323,7 +327,7 @@ void AO_stack_push_release(AO_stack_t *list, AO_t *element) + version+1, (AO_t) element)); + } + +-AO_t *AO_stack_pop_acquire(AO_stack_t *list) ++AO_API AO_t *AO_stack_pop_acquire(AO_stack_t *list) + { + AO_t *cptr; + AO_t next; +diff --git a/src/atomic_ops_stack.h b/src/atomic_ops_stack.h +index e03c186..4053071 100644 +--- a/src/atomic_ops_stack.h ++++ b/src/atomic_ops_stack.h +@@ -141,11 +141,11 @@ typedef struct AO__stack_aux { + /* The following two routines should not normally be used directly. */ + /* We make them visible here for the rare cases in which it makes sense */ + /* to share the AO_stack_aux between stacks. */ +-void ++AO_API void + AO_stack_push_explicit_aux_release(volatile AO_t *list, AO_t *x, + AO_stack_aux *); + +-AO_t * ++AO_API AO_t * + AO_stack_pop_explicit_aux_acquire(volatile AO_t *list, AO_stack_aux *); + + /* And now AO_stack_t for the real interface: */ +@@ -213,9 +213,9 @@ AO_INLINE void AO_stack_init(AO_stack_t *list) + #define AO_REAL_HEAD_PTR(x) (AO_t *)((x).AO_val2) + #define AO_REAL_NEXT_PTR(x) (AO_t *)(x) + +-void AO_stack_push_release(AO_stack_t *list, AO_t *new_element); ++AO_API void AO_stack_push_release(AO_stack_t *list, AO_t *new_element); + #define AO_HAVE_stack_push_release +-AO_t * AO_stack_pop_acquire(AO_stack_t *list); ++AO_API AO_t *AO_stack_pop_acquire(AO_stack_t *list); + #define AO_HAVE_stack_pop_acquire + + #endif /* Wide CAS case */ +diff --git a/tests/test_atomic.c b/tests/test_atomic.c +index a301ced..a905308 100644 +--- a/tests/test_atomic.c ++++ b/tests/test_atomic.c +@@ -192,11 +192,12 @@ int test_and_set_test(void) + extern "C" { + # endif + +- void AO_store_full_emulation(volatile AO_t *addr, AO_t val); +- AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, AO_t old_val, +- AO_t new_val); ++ AO_API void AO_store_full_emulation(volatile AO_t *addr, AO_t val); ++ AO_API AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, ++ AO_t old_val, AO_t new_val); + # ifdef AO_HAVE_double_t +- int AO_compare_double_and_swap_double_emulation(volatile AO_double_t *, ++ AO_API int ++ AO_compare_double_and_swap_double_emulation(volatile AO_double_t *, + AO_t old_val1, AO_t old_val2, + AO_t new_val1, AO_t new_val2); + # endif diff --git a/recipes/libatomic_ops/all/test_package/CMakeLists.txt b/recipes/libatomic_ops/all/test_package/CMakeLists.txt index 7b9b613cbb24a..2f1810f818b79 100644 --- a/recipes/libatomic_ops/all/test_package/CMakeLists.txt +++ b/recipes/libatomic_ops/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(Atomic_ops CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE Atomic_ops::atomic_ops Atomic_ops::atomic_ops_gpl) diff --git a/recipes/libatomic_ops/all/test_package/conanfile.py b/recipes/libatomic_ops/all/test_package/conanfile.py index b5ecfa88d3a13..fde7967ed16f1 100644 --- a/recipes/libatomic_ops/all/test_package/conanfile.py +++ b/recipes/libatomic_ops/all/test_package/conanfile.py @@ -1,10 +1,19 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import cmake_layout, CMake +from conan.tools.build import can_run class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package_multi", "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +21,5 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin","test_package"), run_environment=True) + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/recipes/libatomic_ops/all/test_v1_package/CMakeLists.txt b/recipes/libatomic_ops/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..c7f2e8e2e3a34 --- /dev/null +++ b/recipes/libatomic_ops/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(Atomic_ops CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE Atomic_ops::atomic_ops Atomic_ops::atomic_ops_gpl) diff --git a/recipes/libatomic_ops/all/test_v1_package/conanfile.py b/recipes/libatomic_ops/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/recipes/libatomic_ops/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libatomic_ops/config.yml b/recipes/libatomic_ops/config.yml index 2f8dcab2f579d..c989c79eb8c41 100644 --- a/recipes/libatomic_ops/config.yml +++ b/recipes/libatomic_ops/config.yml @@ -1,3 +1,3 @@ versions: - "7.6.10": + "7.6.14": folder: all diff --git a/recipes/libattr/all/conandata.yml b/recipes/libattr/all/conandata.yml new file mode 100644 index 0000000000000..af8ff8f208c73 --- /dev/null +++ b/recipes/libattr/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.5.1": + url: "http://download.savannah.nongnu.org/releases/attr/attr-2.5.1.tar.gz" + sha256: "BAE1C6949B258A0D68001367CE0C741CEBDACDD3B62965D17E5EB23CD78ADAF8" diff --git a/recipes/libattr/all/conanfile.py b/recipes/libattr/all/conanfile.py new file mode 100644 index 0000000000000..4019c132ebbba --- /dev/null +++ b/recipes/libattr/all/conanfile.py @@ -0,0 +1,109 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +import os +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + +class LibAttrConan(ConanFile): + name = "libattr" + description = "Commands for Manipulating Filesystem Extended Attributes" + topics = ("conan", "attr", "filesystem") + license = "GPL-2.0-or-later" + homepage = "https://savannah.nongnu.org/projects/attr/" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _pkg_etc(self): + return os.path.join( + self.package_folder, + "etc" + ) + + @property + def _pkg_res(self): + return os.path.join( + self.package_folder, + "res" + ) + + @property + def _doc_folder(self): + return os.path.join( + self._source_subfolder, + "doc" + ) + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration( + "libattr is just supported for Linux") + + def configure(self): + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, + destination=self._source_subfolder) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment( + self, win_bash=tools.os_info.is_windows) + conf_args = [ + "--prefix={}".format(tools.unix_path(self.package_folder)), + "--bindir={}".format(tools.unix_path( + os.path.join(self.package_folder, "bin"))), + "--libdir={}".format(tools.unix_path( + os.path.join(self.package_folder, "lib"))) + ] + if self.options.shared: + conf_args.extend(["--enable-shared", "--disable-static"]) + else: + conf_args.extend(["--disable-shared", "--enable-static"]) + self._autotools.configure(args=conf_args) + return self._autotools + + def build(self): + with tools.chdir(self._source_subfolder): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + with tools.chdir(self._source_subfolder): + autotools = self._configure_autotools() + autotools.install() + tools.mkdir(self._pkg_res) + tools.rename( + os.path.join(self._pkg_etc, "xattr.conf"), + os.path.join(self._pkg_res, "xattr.conf") + ) + self.copy("COPYING", dst="licenses", src=self._doc_folder) + tools.rmdir(os.path.join(self.package_folder,"lib","pkgconfig")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "etc")) + + def package_info(self): + self.cpp_info.names["pkg_config"] = "libattr" + self.cpp_info.names["cmake_find_package"] = "libattr" + self.cpp_info.names["cmake_find_package_multi"] = "libattr" + self.cpp_info.libs = ["attr"] diff --git a/recipes/libattr/all/test_package/CMakeLists.txt b/recipes/libattr/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3024422845688 --- /dev/null +++ b/recipes/libattr/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} example.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) + diff --git a/recipes/libattr/all/test_package/conanfile.py b/recipes/libattr/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b1340e4df3916 --- /dev/null +++ b/recipes/libattr/all/test_package/conanfile.py @@ -0,0 +1,15 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libattr/all/test_package/example.cpp b/recipes/libattr/all/test_package/example.cpp new file mode 100644 index 0000000000000..8cf42fee6329a --- /dev/null +++ b/recipes/libattr/all/test_package/example.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char* argv[]) +{ + char value[255]; + int len = sizeof(value); + const char *path = "file_not_exist.txt"; + const char *attr = "attr_not_exist"; + attr_get(path, attr, value, &len, 0); + return 0; +} diff --git a/recipes/libattr/config.yml b/recipes/libattr/config.yml new file mode 100644 index 0000000000000..b14f238429c81 --- /dev/null +++ b/recipes/libattr/config.yml @@ -0,0 +1,4 @@ +versions: + "2.5.1": + folder: all + diff --git a/recipes/libavif/all/conandata.yml b/recipes/libavif/all/conandata.yml new file mode 100644 index 0000000000000..8c5ef7fb45af6 --- /dev/null +++ b/recipes/libavif/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "0.9.3": + sha256: "bcd9a1f57f982a9615eb7e2faf87236dc88eb1d0c886f3471c7440ead605060d" + url: https://github.com/AOMediaCodec/libavif/archive/refs/tags/v0.9.3.tar.gz +patches: + "0.9.3": + - patch_file: patches/0001-disable-developer-only-codepaths.patch + - patch_file: patches/0002-fix-libyuv-version-handling.patch diff --git a/recipes/libavif/all/conanfile.py b/recipes/libavif/all/conanfile.py new file mode 100644 index 0000000000000..66b650db87d1d --- /dev/null +++ b/recipes/libavif/all/conanfile.py @@ -0,0 +1,145 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir, save +import os +import textwrap + +required_conan_version = ">=1.52.0" + + +class LibAVIFConan(ConanFile): + name = "libavif" + description = "Library for encoding and decoding .avif files" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/AOMediaCodec/libavif" + topics = "avif" + license = "BSD-2-Clause" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_decoder": ["aom", "dav1d"], + } + default_options = { + "shared": False, + "fPIC": True, + "with_decoder": "dav1d", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + @property + def _has_dav1d(self): + return self.options.with_decoder == "dav1d" + + def requirements(self): + self.requires("libaom-av1/3.4.0") + self.requires("libyuv/1841") + if self._has_dav1d: + self.requires("dav1d/1.0.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["AVIF_ENABLE_WERROR"] = False + tc.variables["AVIF_CODEC_AOM"] = True + tc.variables["AVIF_CODEC_DAV1D"] = self.options.with_decoder == "dav1d" + tc.variables["AVIF_CODEC_AOM_DECODE"] = self.options.with_decoder == "aom" + tc.variables["LIBYUV_VERSION"] = self.dependencies["libyuv"].ref.version + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + replace_in_file(self, cmakelists, "find_package(libyuv QUIET)", "find_package(libyuv REQUIRED CONFIG)") + replace_in_file(self, cmakelists, "${LIBYUV_LIBRARY}", "libyuv::libyuv") + replace_in_file(self, cmakelists, "find_package(dav1d REQUIRED)", "find_package(dav1d REQUIRED CONFIG)") + replace_in_file(self, cmakelists, "${DAV1D_LIBRARY}", "dav1d::dav1d") + replace_in_file(self, cmakelists, "find_package(aom REQUIRED)", "find_package(libaom-av1 REQUIRED CONFIG)") + replace_in_file(self, cmakelists, "${AOM_LIBRARIES}", "libaom-av1::libaom-av1") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + @property + def _alias_path(self): + return os.path.join("lib", "conan-official-avif-targets.cmake") + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + # TODO: remove in conan v2 + alias = os.path.join(self.package_folder, self._alias_path) + content = textwrap.dedent("""\ + if(TARGET avif::avif AND NOT TARGET avif) + add_library(avif INTERFACE IMPORTED) + set_property( + TARGET avif PROPERTY + INTERFACE_LINK_LIBRARIES avif::avif + ) + endif() + """) + save(self, alias, content) + + def package_info(self): + self.cpp_info.requires = ["libyuv::libyuv", "libaom-av1::libaom-av1"] + if self._has_dav1d: + self.cpp_info.requires.append("dav1d::dav1d") + + self.cpp_info.libs = ["avif"] + if self.options.shared: + self.cpp_info.defines = ["AVIF_DLL"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["pthread", "m"]) + if self._has_dav1d: + self.cpp_info.system_libs.append("dl") + + self.cpp_info.set_property("cmake_file_name", "libavif") + self.cpp_info.set_property("cmake_target_name", "avif") + self.cpp_info.set_property("pkg_config_name", "libavif") + + # TODO: remove in conan v2 + self.cpp_info.names["cmake_find_package"] = "avif" + self.cpp_info.names["cmake_find_package_multi"] = "avif" + self.cpp_info.filenames["cmake_find_package"] = "libavif" + self.cpp_info.filenames["cmake_find_package_multi"] = "libavif" + self.cpp_info.build_modules["cmake_find_package"] = [self._alias_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = \ + [self._alias_path] diff --git a/recipes/libavif/all/patches/0001-disable-developer-only-codepaths.patch b/recipes/libavif/all/patches/0001-disable-developer-only-codepaths.patch new file mode 100644 index 0000000000000..fe78a8cebb343 --- /dev/null +++ b/recipes/libavif/all/patches/0001-disable-developer-only-codepaths.patch @@ -0,0 +1,20 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -48,7 +48,7 @@ + if(AVIF_LOCAL_LIBGAV1) + enable_language(CXX) + endif() +- ++if("0") + if(APPLE) + set(XCRUN xcrun) + else() +@@ -193,7 +193,7 @@ + message(WARNING "libavif: Ignoring request for coverage (AVIF_ENABLE_COVERAGE); only clang is currently supported.") + endif() + endif() +- ++endif() + set(AVIF_SRCS + src/alpha.c + src/avif.c diff --git a/recipes/libavif/all/patches/0002-fix-libyuv-version-handling.patch b/recipes/libavif/all/patches/0002-fix-libyuv-version-handling.patch new file mode 100644 index 0000000000000..2198cabaca744 --- /dev/null +++ b/recipes/libavif/all/patches/0002-fix-libyuv-version-handling.patch @@ -0,0 +1,73 @@ +From ded15fb7b41b0513e138ba457034a2fb91c1f2c9 Mon Sep 17 00:00:00 2001 +From: Bruno Pagani +Date: Thu, 4 Nov 2021 21:05:15 +0400 +Subject: [PATCH] =?UTF-8?q?Fix=20compilation=20with=201755=20=E2=89=A4=20L?= + =?UTF-8?q?IBYUV=5FVERSION=20<=201774?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +ScalePlane_12 only provide optimization for 2x scale up using +linear/bilinear filter (when scaling up, box and bilinear are the same), +and for the rest cases, it simply calls ScalePlane_16, which handles 2x +scale up just fine (slower though). + +This optimization is thus optional and compilation can be allowed for +libyuv versions not providing it. + +Fixes GH-781 (the function was introduced in libavif +https://github.com/AOMediaCodec/libavif/commit/46104d6db42ec2a94a7da6fc0693f24fa90a1b98). +--- + CMakeLists.txt | 4 ++++ + src/scale.c | 8 ++++++++ + 2 files changed, 12 insertions(+) + + diff --git a/CMakeLists.txt b/CMakeLists.txt + index 3fc76dfb..e18156d4 100644 + --- a/CMakeLists.txt + +++ b/CMakeLists.txt + @@ -233,12 +233,16 @@ endif() + find_package(libyuv QUIET) # not required + if(libyuv_FOUND) + # libyuv 1755 exposed all of the I*Matrix() functions, which libavif relies on. + + # libyuv 1774 exposed ScalePlane_12 function, which libavif can use for some additional optimizations. + if(NOT LIBYUV_VERSION) + message(STATUS "libavif: libyuv found, but version unknown; libyuv-based fast paths disabled.") + elseif(LIBYUV_VERSION LESS 1755) + message(STATUS "libavif: libyuv (${LIBYUV_VERSION}) found, but is too old; libyuv-based fast paths disabled.") + else() + message(STATUS "libavif: libyuv (${LIBYUV_VERSION}) found; libyuv-based fast paths enabled.") + + if(LIBYUV_VERSION LESS 1774) + + message(STATUS "libavif: some libyuv optimizations require at least version 1774 to work.") + + endif() + set(AVIF_PLATFORM_DEFINITIONS ${AVIF_PLATFORM_DEFINITIONS} -DAVIF_LIBYUV_ENABLED=1) + set(AVIF_PLATFORM_INCLUDES ${AVIF_PLATFORM_INCLUDES} ${LIBYUV_INCLUDE_DIR}) + set(AVIF_PLATFORM_LIBRARIES ${AVIF_PLATFORM_LIBRARIES} ${LIBYUV_LIBRARY}) +diff --git a/src/scale.c b/src/scale.c +index 6ca651b2..1bbbdd86 100644 +--- a/src/scale.c ++++ b/src/scale.c +@@ -107,7 +107,11 @@ avifBool avifImageScale(avifImage * image, uint32_t dstWidth, uint32_t dstHeight + const uint32_t srcStride = srcYUVRowBytes[i] / 2; + uint16_t * const dstPlane = (uint16_t *)image->yuvPlanes[i]; + const uint32_t dstStride = image->yuvRowBytes[i] / 2; ++#if LIBYUV_VERSION >= 1774 + ScalePlane_12(srcPlane, srcStride, srcW, srcH, dstPlane, dstStride, dstW, dstH, AVIF_LIBYUV_FILTER_MODE); ++#else ++ ScalePlane_16(srcPlane, srcStride, srcW, srcH, dstPlane, dstStride, dstW, dstH, AVIF_LIBYUV_FILTER_MODE); ++#endif + } else { + uint8_t * const srcPlane = srcYUVPlanes[i]; + const uint32_t srcStride = srcYUVRowBytes[i]; +@@ -130,7 +134,11 @@ avifBool avifImageScale(avifImage * image, uint32_t dstWidth, uint32_t dstHeight + const uint32_t srcStride = srcAlphaRowBytes / 2; + uint16_t * const dstPlane = (uint16_t *)image->alphaPlane; + const uint32_t dstStride = image->alphaRowBytes / 2; ++#if LIBYUV_VERSION >= 1774 + ScalePlane_12(srcPlane, srcStride, srcWidth, srcHeight, dstPlane, dstStride, dstWidth, dstHeight, AVIF_LIBYUV_FILTER_MODE); ++#else ++ ScalePlane_16(srcPlane, srcStride, srcWidth, srcHeight, dstPlane, dstStride, dstWidth, dstHeight, AVIF_LIBYUV_FILTER_MODE); ++#endif + } else { + uint8_t * const srcPlane = srcAlphaPlane; + const uint32_t srcStride = srcAlphaRowBytes; diff --git a/recipes/libavif/all/test_package/CMakeLists.txt b/recipes/libavif/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b46c3a250bddb --- /dev/null +++ b/recipes/libavif/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libavif REQUIRED CONFIG) + +add_executable(test_package test_package.c) +target_link_libraries(test_package PRIVATE avif) diff --git a/recipes/libavif/all/test_package/conanfile.py b/recipes/libavif/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libavif/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libavif/all/test_package/test_package.c b/recipes/libavif/all/test_package/test_package.c new file mode 100644 index 0000000000000..178cbce61af42 --- /dev/null +++ b/recipes/libavif/all/test_package/test_package.c @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char const* argv[]) +{ + (void)argc; + (void)argv; + + avifFree(NULL); + + return 0; +} diff --git a/recipes/libavif/all/test_v1_package/CMakeLists.txt b/recipes/libavif/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..23152240acea8 --- /dev/null +++ b/recipes/libavif/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libavif REQUIRED CONFIG) + +add_executable(test_package ../test_package/test_package.c) +target_link_libraries(test_package PRIVATE avif) diff --git a/recipes/libavif/all/test_v1_package/conanfile.py b/recipes/libavif/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libavif/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libavif/config.yml b/recipes/libavif/config.yml new file mode 100644 index 0000000000000..5e19b05d9fa39 --- /dev/null +++ b/recipes/libavif/config.yml @@ -0,0 +1,3 @@ +versions: + "0.9.3": + folder: all diff --git a/recipes/libavrocpp/all/CMakeLists.txt b/recipes/libavrocpp/all/CMakeLists.txt index c3306c78ce9a9..596a2f6f95b12 100644 --- a/recipes/libavrocpp/all/CMakeLists.txt +++ b/recipes/libavrocpp/all/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.5) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory(source_subfolder/lang/c++) diff --git a/recipes/libavrocpp/all/conandata.yml b/recipes/libavrocpp/all/conandata.yml index 03e8e5ac1e025..5f1e3ccbae499 100644 --- a/recipes/libavrocpp/all/conandata.yml +++ b/recipes/libavrocpp/all/conandata.yml @@ -1,14 +1,38 @@ sources: + "1.11.0": + url: "https://github.com/apache/avro/archive/release-1.11.0.tar.gz" + sha256: "c205140e7936d552286ba7131122a34e522d66f601ee912f272109d801f89773" + "1.10.2": + url: "https://github.com/apache/avro/archive/release-1.10.2.tar.gz" + sha256: "c849ef7f7af58ce66e7b999b8d9815507d69ae434e7e058a44f7818515455a03" "1.10.1": url: "https://github.com/apache/avro/archive/release-1.10.1.tar.gz" sha256: "8fd1f850ce37e60835e6d8335c0027a959aaa316773da8a9660f7d33a66ac142" patches: + "1.11.0": + - base_path: "source_subfolder" + patch_file: "patches/0001-add-iterator-include-1-11-0.patch" + - base_path: "source_subfolder" + patch_file: "patches/0002-disable-tests-1-11-0.patch" + - base_path: "source_subfolder" + patch_file: "patches/0003-allow-static-boost-linkage-1-11-0.patch" + - base_path: "source_subfolder" + patch_file: "patches/0004-fix-windows-shared-installation-1-11-0.patch" + "1.10.2": + - base_path: "source_subfolder" + patch_file: "patches/0001-add-iterator-include.patch" + - base_path: "source_subfolder" + patch_file: "patches/0002-disable-tests-1-10-2.patch" + - base_path: "source_subfolder" + patch_file: "patches/0003-allow-static-boost-linkage.patch" + - base_path: "source_subfolder" + patch_file: "patches/0004-fix-windows-shared-installation-1-10-2.patch" "1.10.1": - base_path: "source_subfolder" patch_file: "patches/0001-add-iterator-include.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-disable-tests.patch" + patch_file: "patches/0002-disable-tests-1-10-1.patch" - base_path: "source_subfolder" patch_file: "patches/0003-allow-static-boost-linkage.patch" - base_path: "source_subfolder" - patch_file: "patches/0004-fix-windows-shared-installation.patch" + patch_file: "patches/0004-fix-windows-shared-installation-1-10-1.patch" diff --git a/recipes/libavrocpp/all/conanfile.py b/recipes/libavrocpp/all/conanfile.py index 4acdd4c7ad119..9056fdb84fb51 100644 --- a/recipes/libavrocpp/all/conanfile.py +++ b/recipes/libavrocpp/all/conanfile.py @@ -1,8 +1,9 @@ import os +import functools from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.33.0" class LibavrocppConan(ConanFile): name = "libavrocpp" @@ -11,22 +12,31 @@ class LibavrocppConan(ConanFile): description = "Avro is a data serialization system." homepage = "https://avro.apache.org/" topics = ("serialization", "deserialization") - exports_sources = ["CMakeLists.txt", "patches/*.patch"] generators = "cmake", "cmake_find_package" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + short_paths = True @property def _source_subfolder(self): - return os.path.join("source_subfolder", "lang", "c++") + return "source_subfolder" @property def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -34,31 +44,33 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC + + def validate(self): if self.settings.compiler.cppstd: tools.check_min_cppstd(self, "11") def requirements(self): - self.requires("boost/1.75.0") - self.requires("snappy/1.1.8") + self.requires("boost/1.78.0") + self.requires("snappy/1.1.9") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("avro-release-" + self.version, "source_subfolder") + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) tools.replace_in_file( - os.path.join(self._source_subfolder, "CMakeLists.txt"), + os.path.join(os.path.join(self._source_subfolder, "lang", "c++"), "CMakeLists.txt"), "${SNAPPY_LIBRARIES}", "${Snappy_LIBRARIES}" ) + @functools.lru_cache(1) def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["SNAPPY_ROOT_DIR"] = self.deps_cpp_info["snappy"].rootpath.replace("\\", "/") - self._cmake.configure() - return self._cmake + cmake = CMake(self) + cmake.definitions["SNAPPY_ROOT_DIR"] = self.deps_cpp_info["snappy"].rootpath.replace("\\", "/") + cmake.configure() + return cmake def build(self): self._patch_sources() @@ -66,11 +78,15 @@ def build(self): cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("NOTICE", dst="licenses", src=self._source_subfolder) + self.copy("LICENSE*", dst="licenses", src=self._source_subfolder) + self.copy("NOTICE*", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() + if self.settings.os == "Windows": + for dll_pattern_to_remove in ["concrt*.dll", "msvcp*.dll", "vcruntime*.dll"]: + tools.remove_files_by_mask(self.package_folder, dll_pattern_to_remove) + def package_info(self): # FIXME: avro does not install under a CMake namespace https://github.com/apache/avro/blob/351f589913b9691322966fb77fe72269a0a2ec82/lang/c%2B%2B/CMakeLists.txt#L193 target = "avrocpp" if self.options.shared else "avrocpp_s" diff --git a/recipes/libavrocpp/all/patches/0001-add-iterator-include-1-11-0.patch b/recipes/libavrocpp/all/patches/0001-add-iterator-include-1-11-0.patch new file mode 100644 index 0000000000000..40a93c52bb80f --- /dev/null +++ b/recipes/libavrocpp/all/patches/0001-add-iterator-include-1-11-0.patch @@ -0,0 +1,96 @@ +diff --git a/lang/c++/api/buffer/detail/BufferDetail.hh b/lang/c++/api/buffer/detail/BufferDetail.hh +index b487cdb..89783fb 100644 +--- a/lang/c++/api/buffer/detail/BufferDetail.hh ++++ b/lang/c++/api/buffer/detail/BufferDetail.hh +@@ -30,6 +30,7 @@ + #endif + #include + #include ++#include + #include + + /** +diff --git a/lang/c++/impl/DataFile.cc b/lang/c++/impl/DataFile.cc +index 18fb3f6..f8679a2 100644 +--- a/lang/c++/impl/DataFile.cc ++++ b/lang/c++/impl/DataFile.cc +@@ -20,6 +20,7 @@ + #include "Compiler.hh" + #include "Exception.hh" + ++#include + #include + + #include // for boost::crc_32_type +diff --git a/lang/c++/impl/Stream.cc b/lang/c++/impl/Stream.cc +index 63a8b4e..39556d1 100644 +--- a/lang/c++/impl/Stream.cc ++++ b/lang/c++/impl/Stream.cc +@@ -17,6 +17,7 @@ + */ + + #include "Stream.hh" ++#include + #include + + namespace avro { +diff --git a/lang/c++/impl/parsing/JsonCodec.cc b/lang/c++/impl/parsing/JsonCodec.cc +index 4fd0481..3de5150 100644 +--- a/lang/c++/impl/parsing/JsonCodec.cc ++++ b/lang/c++/impl/parsing/JsonCodec.cc +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + + #include "Decoder.hh" +diff --git a/lang/c++/impl/parsing/ResolvingDecoder.cc b/lang/c++/impl/parsing/ResolvingDecoder.cc +index d86f6e5..3b961ea 100644 +--- a/lang/c++/impl/parsing/ResolvingDecoder.cc ++++ b/lang/c++/impl/parsing/ResolvingDecoder.cc +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #include "Decoder.hh" + #include "Encoder.hh" +diff --git a/lang/c++/impl/parsing/ValidatingCodec.cc b/lang/c++/impl/parsing/ValidatingCodec.cc +index cfb8222..8a0817a 100644 +--- a/lang/c++/impl/parsing/ValidatingCodec.cc ++++ b/lang/c++/impl/parsing/ValidatingCodec.cc +@@ -19,6 +19,7 @@ + #include "ValidatingCodec.hh" + + #include ++#include + #include + #include + #include +diff --git a/lang/c++/test/CodecTests.cc b/lang/c++/test/CodecTests.cc +index a99cdd6..07f560c 100644 +--- a/lang/c++/test/CodecTests.cc ++++ b/lang/c++/test/CodecTests.cc +@@ -25,6 +25,7 @@ + #include "Specific.hh" + #include "ValidSchema.hh" + ++#include + #include + #include + #include +diff --git a/lang/c++/test/DataFileTests.cc b/lang/c++/test/DataFileTests.cc +index fec7f31..aced825 100644 +--- a/lang/c++/test/DataFileTests.cc ++++ b/lang/c++/test/DataFileTests.cc +@@ -24,6 +24,7 @@ + #include + + #include ++#include + #include + + #include diff --git a/recipes/libavrocpp/all/patches/0001-add-iterator-include.patch b/recipes/libavrocpp/all/patches/0001-add-iterator-include.patch index dfe26249cae49..f62d60b0c67cc 100644 --- a/recipes/libavrocpp/all/patches/0001-add-iterator-include.patch +++ b/recipes/libavrocpp/all/patches/0001-add-iterator-include.patch @@ -1,5 +1,23 @@ ---- lang/c++/api/buffer/detail/BufferDetail.hh -+++ lang/c++/api/buffer/detail/BufferDetail.hh +From 7cd46cc46a5742d91933eee75d2504022d2ab48f Mon Sep 17 00:00:00 2001 +From: Alejandro Colomar +Date: Sat, 29 May 2021 07:31:46 +0200 +Subject: [PATCH] add iterator include + +--- + lang/c++/api/buffer/detail/BufferDetail.hh | 1 + + lang/c++/impl/DataFile.cc | 1 + + lang/c++/impl/Stream.cc | 1 + + lang/c++/impl/parsing/JsonCodec.cc | 1 + + lang/c++/impl/parsing/ResolvingDecoder.cc | 1 + + lang/c++/impl/parsing/ValidatingCodec.cc | 1 + + lang/c++/test/CodecTests.cc | 1 + + lang/c++/test/DataFileTests.cc | 1 + + 8 files changed, 8 insertions(+) + +diff --git a/lang/c++/api/buffer/detail/BufferDetail.hh b/lang/c++/api/buffer/detail/BufferDetail.hh +index 03e237ef..b0a4b4b2 100644 +--- a/lang/c++/api/buffer/detail/BufferDetail.hh ++++ b/lang/c++/api/buffer/detail/BufferDetail.hh @@ -30,6 +30,7 @@ #include #include @@ -8,8 +26,10 @@ /** * \file BufferDetail.hh ---- lang/c++/impl/DataFile.cc -+++ lang/c++/impl/DataFile.cc +diff --git a/lang/c++/impl/DataFile.cc b/lang/c++/impl/DataFile.cc +index e20e6058..4c56d06b 100644 +--- a/lang/c++/impl/DataFile.cc ++++ b/lang/c++/impl/DataFile.cc @@ -20,6 +20,7 @@ #include "Compiler.hh" #include "Exception.hh" @@ -18,8 +38,10 @@ #include #include ---- lang/c++/impl/Stream.cc -+++ lang/c++/impl/Stream.cc +diff --git a/lang/c++/impl/Stream.cc b/lang/c++/impl/Stream.cc +index 7023f3f2..e8b2cf2f 100644 +--- a/lang/c++/impl/Stream.cc ++++ b/lang/c++/impl/Stream.cc @@ -17,6 +17,7 @@ */ @@ -28,8 +50,10 @@ #include namespace avro { ---- lang/c++/impl/parsing/JsonCodec.cc -+++ lang/c++/impl/parsing/JsonCodec.cc +diff --git a/lang/c++/impl/parsing/JsonCodec.cc b/lang/c++/impl/parsing/JsonCodec.cc +index 8bca2984..eda76141 100644 +--- a/lang/c++/impl/parsing/JsonCodec.cc ++++ b/lang/c++/impl/parsing/JsonCodec.cc @@ -23,6 +23,7 @@ #include #include @@ -38,8 +62,10 @@ #include #include "ValidatingCodec.hh" ---- lang/c++/impl/parsing/ResolvingDecoder.cc -+++ lang/c++/impl/parsing/ResolvingDecoder.cc +diff --git a/lang/c++/impl/parsing/ResolvingDecoder.cc b/lang/c++/impl/parsing/ResolvingDecoder.cc +index f6dbacab..b4987045 100644 +--- a/lang/c++/impl/parsing/ResolvingDecoder.cc ++++ b/lang/c++/impl/parsing/ResolvingDecoder.cc @@ -24,6 +24,7 @@ #include #include @@ -48,8 +74,10 @@ #include "ValidatingCodec.hh" #include "Symbol.hh" ---- lang/c++/impl/parsing/ValidatingCodec.cc -+++ lang/c++/impl/parsing/ValidatingCodec.cc +diff --git a/lang/c++/impl/parsing/ValidatingCodec.cc b/lang/c++/impl/parsing/ValidatingCodec.cc +index fdf6ef89..974427f8 100644 +--- a/lang/c++/impl/parsing/ValidatingCodec.cc ++++ b/lang/c++/impl/parsing/ValidatingCodec.cc @@ -22,6 +22,7 @@ #include #include @@ -58,8 +86,10 @@ #include #include "ValidSchema.hh" ---- lang/c++/test/CodecTests.cc -+++ lang/c++/test/CodecTests.cc +diff --git a/lang/c++/test/CodecTests.cc b/lang/c++/test/CodecTests.cc +index a1949a05..50eef90b 100644 +--- a/lang/c++/test/CodecTests.cc ++++ b/lang/c++/test/CodecTests.cc @@ -30,6 +30,7 @@ #include #include @@ -68,8 +98,10 @@ #include #include ---- lang/c++/test/DataFileTests.cc -+++ lang/c++/test/DataFileTests.cc +diff --git a/lang/c++/test/DataFileTests.cc b/lang/c++/test/DataFileTests.cc +index 8c4605f4..d74802d1 100644 +--- a/lang/c++/test/DataFileTests.cc ++++ b/lang/c++/test/DataFileTests.cc @@ -25,6 +25,7 @@ #include @@ -78,3 +110,6 @@ #include +-- +2.32.0.rc0 + diff --git a/recipes/libavrocpp/all/patches/0002-disable-tests.patch b/recipes/libavrocpp/all/patches/0002-disable-tests-1-10-1.patch similarity index 100% rename from recipes/libavrocpp/all/patches/0002-disable-tests.patch rename to recipes/libavrocpp/all/patches/0002-disable-tests-1-10-1.patch diff --git a/recipes/libavrocpp/all/patches/0002-disable-tests-1-10-2.patch b/recipes/libavrocpp/all/patches/0002-disable-tests-1-10-2.patch new file mode 100644 index 0000000000000..3e8dc4d43028d --- /dev/null +++ b/recipes/libavrocpp/all/patches/0002-disable-tests-1-10-2.patch @@ -0,0 +1,42 @@ +From 322a40e54b4cc1296a405c7fbf920101397d7f37 Mon Sep 17 00:00:00 2001 +From: Alejandro Colomar +Date: Tue, 2 Feb 2021 20:29:05 -0500 +Subject: [PATCH] Update CMakeLists.txt + +--- + lang/c++/CMakeLists.txt | 12 ------------ + 1 file changed, 12 deletions(-) + +diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt +index 4a1ac660..0d1ec70e 100644 +--- a/lang/c++/CMakeLists.txt ++++ b/lang/c++/CMakeLists.txt +@@ -161,10 +161,6 @@ target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIE + enable_testing() + + macro (unittest name) +- add_executable (${name} test/${name}.cc) +- target_link_libraries (${name} avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES}) +- add_test (NAME ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +- COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name}) + endmacro (unittest) + + unittest (buffertest) +@@ -180,14 +176,6 @@ unittest (AvrogencppTests) + unittest (CompilerTests) + unittest (AvrogencppTestReservedWords) + +-add_dependencies (AvrogencppTestReservedWords cpp_reserved_words_hh) +- +-add_dependencies (AvrogencppTests bigrecord_hh bigrecord_r_hh bigrecord2_hh +- tweet_hh +- union_array_union_hh union_map_union_hh union_conflict_hh +- recursive_hh reuse_hh circulardep_hh tree1_hh tree2_hh crossref_hh +- primitivetypes_hh empty_record_hh) +- + include (InstallRequiredSystemLibraries) + + set (CPACK_PACKAGE_FILE_NAME "avrocpp-${AVRO_VERSION_MAJOR}") +-- +2.32.0.rc0 + diff --git a/recipes/libavrocpp/all/patches/0002-disable-tests-1-11-0.patch b/recipes/libavrocpp/all/patches/0002-disable-tests-1-11-0.patch new file mode 100644 index 0000000000000..2e7b54bab02b8 --- /dev/null +++ b/recipes/libavrocpp/all/patches/0002-disable-tests-1-11-0.patch @@ -0,0 +1,30 @@ +diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt +index 4a37931..f371590 100644 +--- a/lang/c++/CMakeLists.txt ++++ b/lang/c++/CMakeLists.txt +@@ -168,10 +168,6 @@ target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIE + enable_testing() + + macro (unittest name) +- add_executable (${name} test/${name}.cc) +- target_link_libraries (${name} avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES}) +- add_test (NAME ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +- COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name}) + endmacro (unittest) + + unittest (buffertest) +@@ -187,14 +183,6 @@ unittest (AvrogencppTests) + unittest (CompilerTests) + unittest (AvrogencppTestReservedWords) + +-add_dependencies (AvrogencppTestReservedWords cpp_reserved_words_hh) +- +-add_dependencies (AvrogencppTests bigrecord_hh bigrecord_r_hh bigrecord2_hh +- tweet_hh +- union_array_union_hh union_map_union_hh union_conflict_hh +- recursive_hh reuse_hh circulardep_hh tree1_hh tree2_hh crossref_hh +- primitivetypes_hh empty_record_hh) +- + include (InstallRequiredSystemLibraries) + + set (CPACK_PACKAGE_FILE_NAME "avrocpp-${AVRO_VERSION_MAJOR}") diff --git a/recipes/libavrocpp/all/patches/0003-allow-static-boost-linkage-1-11-0.patch b/recipes/libavrocpp/all/patches/0003-allow-static-boost-linkage-1-11-0.patch new file mode 100644 index 0000000000000..695b26eb3ea4e --- /dev/null +++ b/recipes/libavrocpp/all/patches/0003-allow-static-boost-linkage-1-11-0.patch @@ -0,0 +1,18 @@ +diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt +index f371590..7f8c09a 100644 +--- a/lang/c++/CMakeLists.txt ++++ b/lang/c++/CMakeLists.txt +@@ -55,12 +55,7 @@ if (WIN32 AND NOT CYGWIN AND NOT MSYS) + add_definitions (/EHa) + add_definitions ( + -DNOMINMAX +- -DBOOST_REGEX_DYN_LINK +- -DBOOST_FILESYSTEM_DYN_LINK +- -DBOOST_SYSTEM_DYN_LINK +- -DBOOST_IOSTREAMS_DYN_LINK +- -DBOOST_PROGRAM_OPTIONS_DYN_LINK +- -DBOOST_ALL_NO_LIB) ++ ) + endif() + + if (CMAKE_COMPILER_IS_GNUCXX) diff --git a/recipes/libavrocpp/all/patches/0004-fix-windows-shared-installation.patch b/recipes/libavrocpp/all/patches/0004-fix-windows-shared-installation-1-10-1.patch similarity index 100% rename from recipes/libavrocpp/all/patches/0004-fix-windows-shared-installation.patch rename to recipes/libavrocpp/all/patches/0004-fix-windows-shared-installation-1-10-1.patch diff --git a/recipes/libavrocpp/all/patches/0004-fix-windows-shared-installation-1-10-2.patch b/recipes/libavrocpp/all/patches/0004-fix-windows-shared-installation-1-10-2.patch new file mode 100644 index 0000000000000..adc06812e15e7 --- /dev/null +++ b/recipes/libavrocpp/all/patches/0004-fix-windows-shared-installation-1-10-2.patch @@ -0,0 +1,34 @@ +From 303259ea4480493e148187193e8c0f6833a61aea Mon Sep 17 00:00:00 2001 +From: Chris Mc +Date: Tue, 2 Feb 2021 21:27:31 -0500 +Subject: [PATCH] fix windows shared installation + +--- + lang/c++/CMakeLists.txt | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt +index ee59f806..e0f855c1 100644 +--- a/lang/c++/CMakeLists.txt ++++ b/lang/c++/CMakeLists.txt +@@ -169,8 +169,6 @@ unittest (AvrogencppTests) + unittest (CompilerTests) + unittest (AvrogencppTestReservedWords) + +-include (InstallRequiredSystemLibraries) +- + set (CPACK_PACKAGE_FILE_NAME "avrocpp-${AVRO_VERSION_MAJOR}") + + include (CPack) +@@ -178,7 +176,7 @@ include (CPack) + install (TARGETS avrocpp avrocpp_s + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +- RUNTIME DESTINATION lib) ++ RUNTIME DESTINATION bin) + + install (TARGETS avrogencpp RUNTIME DESTINATION bin) + +-- +2.32.0.rc0 + diff --git a/recipes/libavrocpp/all/patches/0004-fix-windows-shared-installation-1-11-0.patch b/recipes/libavrocpp/all/patches/0004-fix-windows-shared-installation-1-11-0.patch new file mode 100644 index 0000000000000..0a5a35defb0d5 --- /dev/null +++ b/recipes/libavrocpp/all/patches/0004-fix-windows-shared-installation-1-11-0.patch @@ -0,0 +1,13 @@ +diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt +index 7f8c09a..aff0447 100644 +--- a/lang/c++/CMakeLists.txt ++++ b/lang/c++/CMakeLists.txt +@@ -187,7 +187,7 @@ include (CPack) + install (TARGETS avrocpp avrocpp_s + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +- RUNTIME DESTINATION lib) ++ RUNTIME DESTINATION bin) + + install (TARGETS avrogencpp RUNTIME DESTINATION bin) + diff --git a/recipes/libavrocpp/all/test_package/CMakeLists.txt b/recipes/libavrocpp/all/test_package/CMakeLists.txt index f3defd73756ad..68d787b464e8d 100644 --- a/recipes/libavrocpp/all/test_package/CMakeLists.txt +++ b/recipes/libavrocpp/all/test_package/CMakeLists.txt @@ -2,14 +2,14 @@ cmake_minimum_required(VERSION 3.8) project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(libavrocpp REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) -if(AVROCPP_SHARED) +if(TARGET libavrocpp::avrocpp) target_link_libraries(${PROJECT_NAME} libavrocpp::avrocpp) else() target_link_libraries(${PROJECT_NAME} libavrocpp::avrocpp_s) diff --git a/recipes/libavrocpp/all/test_package/conanfile.py b/recipes/libavrocpp/all/test_package/conanfile.py index 90df2700c3144..75634e62bcb66 100644 --- a/recipes/libavrocpp/all/test_package/conanfile.py +++ b/recipes/libavrocpp/all/test_package/conanfile.py @@ -9,12 +9,10 @@ class TestPackageConan(ConanFile): def build(self): cmake = CMake(self) - cmake.verbose = True - cmake.definitions["AVROCPP_SHARED"] = self.options["libavrocpp"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libavrocpp/config.yml b/recipes/libavrocpp/config.yml index 1999927fada2d..ed319d069e486 100644 --- a/recipes/libavrocpp/config.yml +++ b/recipes/libavrocpp/config.yml @@ -1,3 +1,7 @@ versions: + 1.11.0: + folder: all + 1.10.2: + folder: all 1.10.1: folder: all diff --git a/recipes/libbacktrace/all/conandata.yml b/recipes/libbacktrace/all/conandata.yml index 1357c342647ac..56d79ce7402eb 100644 --- a/recipes/libbacktrace/all/conandata.yml +++ b/recipes/libbacktrace/all/conandata.yml @@ -5,6 +5,4 @@ sources: patches: "cci.20210118": - patch_file: "patches/0001-pointer-arithmetic.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-msvc-unistd-alternative.patch" - base_path: "source_subfolder" diff --git a/recipes/libbacktrace/all/conanfile.py b/recipes/libbacktrace/all/conanfile.py index cc7c87a3d7ed8..ca9c6497fea49 100644 --- a/recipes/libbacktrace/all/conanfile.py +++ b/recipes/libbacktrace/all/conanfile.py @@ -1,9 +1,15 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration -from contextlib import contextmanager +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, rm +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.52.0" class LibbacktraceConan(ConanFile): @@ -12,18 +18,27 @@ class LibbacktraceConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/ianlancetaylor/libbacktrace" license = "BSD-3-Clause" - topics = ("conan", "backtrace", "stack-trace") - + topics = ("backtrace", "stack-trace") settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - exports_sources = "patches/**" - _autotools = None + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) @property - def _source_subfolder(self): - return "source_subfolder" + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -31,67 +46,79 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + basic_layout(self, src_folder="src") def validate(self): - if self.settings.compiler == "Visual Studio" and self.options.shared: + if is_msvc(self) and self.info.options.shared: raise ConanInvalidConfiguration("libbacktrace shared is not supported with Visual Studio") def build_requirements(self): - self.build_requires("libtool/2.4.6") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + self.tool_requires("msys2/cci.latest") + if is_msvc(self): + self.tool_requires("automake/1.16.5") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - @contextmanager - def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - env = { - "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "LD": "{} link -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), - "AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), - } - with tools.environment_append(env): - yield - else: - yield - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.libs = [] - if self.settings.compiler == "Visual Studio": - self._autotools.flags.append("-FS") - if self.options.shared: - args = ["--enable-shared", "--disable-static"] - else: - args = ["--disable-shared", "--enable-static"] - self._autotools.configure(configure_dir=self._source_subfolder, args=args) - return self._autotools + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + tc.generate() + + if is_msvc(self): + env = Environment() + compile_wrapper = unix_path(self, self._user_info_build["automake"].compile) + ar_wrapper = unix_path(self, self._user_info_build["automake"].ar_lib) + env.define("CC", f"{compile_wrapper} cl -nologo") + env.define("CXX", f"{compile_wrapper} cl -nologo") + env.define("LD", "link -nologo") + env.define("AR", f"{ar_wrapper} \"lib -nologo\"") + env.define("NM", "dumpbin -symbols") + env.define("OBJDUMP", ":") + env.define("RANLIB", ":") + env.define("STRIP", ":") + env.vars(self).save_script("conanbuild_libbacktrace_msvc") def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - with tools.chdir(self._source_subfolder): - self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() + apply_conandata_patches(self) + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # see https://github.com/conan-io/conan/issues/12006 + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + lib_folder = os.path.join(self.package_folder, "lib") + rm(self, "*.la", lib_folder) + fix_apple_shared_install_name(self) + if is_msvc(self): + rename(self, os.path.join(lib_folder, "libbacktrace.lib"), + os.path.join(lib_folder, "backtrace.lib")) def package_info(self): self.cpp_info.libs = ["backtrace"] diff --git a/recipes/libbacktrace/all/test_package/CMakeLists.txt b/recipes/libbacktrace/all/test_package/CMakeLists.txt index 31762006efa77..81b50a3407418 100644 --- a/recipes/libbacktrace/all/test_package/CMakeLists.txt +++ b/recipes/libbacktrace/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libbacktrace REQUIRED CONFIG) add_executable(test_package test_package.c) -target_link_libraries(test_package ${CONAN_LIBS}) +target_link_libraries(test_package PRIVATE libbacktrace::libbacktrace) diff --git a/recipes/libbacktrace/all/test_package/conanfile.py b/recipes/libbacktrace/all/test_package/conanfile.py index 879d06edd2858..0a6bc68712d90 100644 --- a/recipes/libbacktrace/all/test_package/conanfile.py +++ b/recipes/libbacktrace/all/test_package/conanfile.py @@ -1,11 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import CMake, ConanFile, tools - class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -13,7 +21,6 @@ def build(self): cmake.build() def test(self): - if tools.cross_building(self.settings): - return - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libbacktrace/all/test_v1_package/CMakeLists.txt b/recipes/libbacktrace/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..ee84a5e843025 --- /dev/null +++ b/recipes/libbacktrace/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libbacktrace REQUIRED CONFIG) + +add_executable(test_package ../test_package/test_package.c) +target_link_libraries(test_package PRIVATE libbacktrace::libbacktrace) diff --git a/recipes/libbacktrace/all/test_v1_package/conanfile.py b/recipes/libbacktrace/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e0a85886fc12c --- /dev/null +++ b/recipes/libbacktrace/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import CMake, ConanFile, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/hazelcast-cpp-client/all/CMakeLists.txt b/recipes/libbasisu/all/CMakeLists.txt similarity index 100% rename from recipes/hazelcast-cpp-client/all/CMakeLists.txt rename to recipes/libbasisu/all/CMakeLists.txt diff --git a/recipes/libbasisu/all/conandata.yml b/recipes/libbasisu/all/conandata.yml new file mode 100644 index 0000000000000..7cca98d66479b --- /dev/null +++ b/recipes/libbasisu/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.15.0": + url: "https://github.com/BinomialLLC/basis_universal/archive/refs/tags/v1_15.tar.gz" + sha256: "1f8de889beb2b8d899320693b651a6b8b62a954a9b86962aaa41007ee2dbe02b" +patches: + "1.15.0": + - patch_file: "patches/cmakelist_build_lib.patch" + base_path: "source_subfolder" diff --git a/recipes/libbasisu/all/conanfile.py b/recipes/libbasisu/all/conanfile.py new file mode 100644 index 0000000000000..6dfaf4ee7f3de --- /dev/null +++ b/recipes/libbasisu/all/conanfile.py @@ -0,0 +1,114 @@ +import os +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + + +class LibBasisUniversalConan(ConanFile): + name = "libbasisu" + description = "Basis Universal Supercompressed GPU Texture Codec" + homepage = "https://github.com/BinomialLLC/basis_universal" + topics = ("conan", "basis", "textures", "compression") + url = "https://github.com/conan-io/conan-center-index" + license = "Apache-2.0" + exports_sources = ["CMakeLists.txt", "patches/*"] + generators = "cmake" + settings = "os", "compiler", "build_type", "arch" + options = { + "fPIC": [True, False], + "shared": [True, False], + "use_sse4": [True, False], + "with_zstd": [True, False], + "enable_encoder": [True, False], + "custom_iterator_debug_level": [True, False] + } + default_options = { + "fPIC": True, + "shared": False, + "use_sse4": False, + "with_zstd": True, + "enable_encoder": True, + "custom_iterator_debug_level": False + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def _use_custom_iterator_debug_level(self): + return self.options.get_safe("custom_iterator_debug_level", default=self.default_options["custom_iterator_debug_level"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.compiler != "Visual Studio": + del self.options.custom_iterator_debug_level + + def _minimum_compiler_version(self) -> bool: + return { + "Visual Studio": "15", + "gcc": "5.4", + "clang": "3.9", + "apple-clang": "10" + } + + def validate(self): + min_version = self._minimum_compiler_version().get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler)) + elif tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} {} does not support compiler with version {} {}, minimum supported compiler version is {} ".format(self.name, self.version, self.settings.compiler, self.settings.compiler.version, min_version)) + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["SSE4"] = self.options.use_sse4 + self._cmake.definitions["ZSTD"] = self.options.with_zstd + self._cmake.definitions["ENABLE_ENCODER"] = self.options.enable_encoder + self._cmake.definitions["NO_ITERATOR_DEBUG_LEVEL"] = not self._use_custom_iterator_debug_level() + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + self.copy("*.h", dst=os.path.join("include", self.name, "transcoder"), src=os.path.join(self._source_subfolder, "transcoder")) + if self.options.enable_encoder: + self.copy("*.h", dst=os.path.join("include", self.name, "encoder"), src=os.path.join(self._source_subfolder, "encoder")) + self.copy(pattern="*.a", dst="lib", keep_path=False) + self.copy(pattern="*.so", dst="lib", keep_path=False) + self.copy(pattern="*.dylib*", dst="lib", keep_path=False) + self.copy(pattern="*.lib", dst="lib", keep_path=False) + self.copy(pattern="*.dll", dst="bin", keep_path=False) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.names["cmake_find_package"] = self.name + self.cpp_info.names["cmake_find_package_multi"] = self.name + self.cpp_info.includedirs = ["include", os.path.join("include", self.name)] + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["m", "pthread"] + self.cpp_info.defines.append("BASISU_NO_ITERATOR_DEBUG_LEVEL={}".format("1" if self._use_custom_iterator_debug_level() else "0")) diff --git a/recipes/libbasisu/all/patches/cmakelist_build_lib.patch b/recipes/libbasisu/all/patches/cmakelist_build_lib.patch new file mode 100644 index 0000000000000..043a9778c605d --- /dev/null +++ b/recipes/libbasisu/all/patches/cmakelist_build_lib.patch @@ -0,0 +1,205 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,39 +1,11 @@ +-project(basisu) +- + cmake_minimum_required(VERSION 3.0) +-option(BUILD_X64 "build 64-bit" TRUE) +-option(STATIC "static linking" FALSE) +-option(SSE "SSE 4.1 support" FALSE) +-option(ZSTD "ZSTD support for KTX2 transcoding/encoding" TRUE) + +-message("Initial BUILD_X64=${BUILD_X64}") +-message("Initial CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") +-message("Initial SSE=${SSE}") +-message("Initial ZSTD=${ZSTD}") +- +-if( NOT CMAKE_BUILD_TYPE ) +- set( CMAKE_BUILD_TYPE Release ) +-endif() ++project(basisu VERSION 1.15.0 LANGUAGES CXX) + +-message( ${PROJECT_NAME} " build type: " ${CMAKE_BUILD_TYPE} ) +- +-if (BUILD_X64) +- message("Building 64-bit") +-else() +- message("Building 32-bit") +-endif() +- +-if (SSE) +- message("SSE enabled") +-else() +- message("SSE disabled") +-endif() +- +-if (ZSTD) +- message("Zstandard enabled") +-else() +- message("Zstandard disabled") +-endif() ++option(SSE4 "SSE4 4.1 support" FALSE) ++option(ZSTD "ZSTD support for KTX2 transcoding/encoding" TRUE) ++option(NO_ITERATOR_DEBUG_LEVEL "Change Iterator debug level" FALSE) ++option(ENABLE_ENCODER "Build also encoder part of basisu library" TRUE) + + if (NOT MSVC) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") +@@ -42,38 +14,24 @@ if (NOT MSVC) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + +- set(CMAKE_CXX_FLAGS -std=c++11) +- set(GCC_COMPILE_FLAGS "-fvisibility=hidden -fPIC -fno-strict-aliasing -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wno-unused-local-typedefs -Wno-unused-value -Wno-unused-parameter -Wno-unused-variable") +- +- if (NOT BUILD_X64) +- set(GCC_COMPILE_FLAGS "${GCC_COMPILE_FLAGS} -m32") +- endif() ++ set(GCC_COMPILE_FLAGS "-fPIC -fno-strict-aliasing -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wno-unused-local-typedefs -Wno-unused-value -Wno-unused-parameter -Wno-unused-variable") + +- if (EMSCRIPTEN) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -DBASISU_SUPPORT_SSE=0") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -DBASISU_SUPPORT_SSE=0") +- +- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS}") +- elseif (STATIC) +- if (SSE) ++ if (NOT BUILD_SHARED_LIBS) ++ if (SSE4) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=1 -msse4.1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=1 -msse4.1") + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=0") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=0") +- endif() +- +- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -static-libgcc -static-libstdc++ -static") ++ endif() + else() +- if (SSE) ++ if (SSE4) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=1 -msse4.1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=1 -msse4.1") + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=0") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=0") +- endif() +- +- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -Wl,-rpath .") ++ endif() + endif() + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COMPILE_FLAGS}") +@@ -84,7 +42,7 @@ if (NOT MSVC) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${GCC_COMPILE_FLAGS}") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${GCC_COMPILE_FLAGS} -D_DEBUG") + else() +- if (SSE) ++ if (SSE4) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=1") + else() +@@ -93,64 +51,57 @@ else() + endif() + endif() + +-set(BASISU_SRC_LIST ${COMMON_SRC_LIST} +- basisu_tool.cpp +- encoder/basisu_backend.cpp +- encoder/basisu_basis_file.cpp +- encoder/basisu_comp.cpp +- encoder/basisu_enc.cpp +- encoder/basisu_etc.cpp +- encoder/basisu_frontend.cpp +- encoder/basisu_global_selector_palette_helpers.cpp +- encoder/basisu_gpu_texture.cpp +- encoder/basisu_pvrtc1_4.cpp +- encoder/basisu_resampler.cpp +- encoder/basisu_resample_filters.cpp +- encoder/basisu_ssim.cpp +- encoder/basisu_astc_decomp.cpp +- encoder/basisu_uastc_enc.cpp +- encoder/basisu_bc7enc.cpp +- encoder/lodepng.cpp +- encoder/apg_bmp.c +- encoder/jpgd.cpp +- encoder/basisu_kernels_sse.cpp +- transcoder/basisu_transcoder.cpp ++set(BASISU_SRC_LIST ${COMMON_SRC_LIST} transcoder/basisu_transcoder.cpp) ++ ++if (ENABLE_ENCODER) ++ set(BASISU_SRC_LIST ${BASISU_SRC_LIST} ++ encoder/basisu_backend.cpp ++ encoder/basisu_basis_file.cpp ++ encoder/basisu_comp.cpp ++ encoder/basisu_enc.cpp ++ encoder/basisu_etc.cpp ++ encoder/basisu_frontend.cpp ++ encoder/basisu_global_selector_palette_helpers.cpp ++ encoder/basisu_gpu_texture.cpp ++ encoder/basisu_pvrtc1_4.cpp ++ encoder/basisu_resampler.cpp ++ encoder/basisu_resample_filters.cpp ++ encoder/basisu_ssim.cpp ++ encoder/basisu_astc_decomp.cpp ++ encoder/basisu_uastc_enc.cpp ++ encoder/basisu_bc7enc.cpp ++ encoder/lodepng.cpp ++ encoder/apg_bmp.c ++ encoder/jpgd.cpp ++ encoder/basisu_kernels_sse.cpp + ) ++endif() + + if (ZSTD) + set(BASISU_SRC_LIST ${BASISU_SRC_LIST} zstd/zstd.c) + endif() + +-if (APPLE) +- set(BIN_DIRECTORY "bin_osx") ++add_library(${PROJECT_NAME} ${BASISU_SRC_LIST}) ++ ++if (NO_ITERATOR_DEBUG_LEVEL) ++ target_compile_definitions(${PROJECT_NAME} PRIVATE BASISU_NO_ITERATOR_DEBUG_LEVEL=1) + else() +- set(BIN_DIRECTORY "bin") ++ target_compile_definitions(${PROJECT_NAME} PRIVATE BASISU_NO_ITERATOR_DEBUG_LEVEL=0) + endif() + +-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${BIN_DIRECTORY}) +- +-add_executable(basisu ${BASISU_SRC_LIST}) +- + if (ZSTD) +- target_compile_definitions(basisu PRIVATE BASISD_SUPPORT_KTX2_ZSTD=1) ++ target_compile_definitions(${PROJECT_NAME} PRIVATE BASISD_SUPPORT_KTX2_ZSTD=1) + else() +- target_compile_definitions(basisu PRIVATE BASISD_SUPPORT_KTX2_ZSTD=0) ++ target_compile_definitions(${PROJECT_NAME} PRIVATE BASISD_SUPPORT_KTX2_ZSTD=0) + endif() + +-if (NOT MSVC) +- target_link_libraries(basisu m pthread) ++if (WIN32) ++ set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) ++else() ++ set(THREADS_PREFER_PTHREAD_FLAG ON) ++ find_package(Threads REQUIRED) ++ target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads m) + endif() + +-if (NOT EMSCRIPTEN) +- install(TARGETS basisu DESTINATION bin) +- +- if (UNIX) +- if (CMAKE_BUILD_TYPE STREQUAL Release) +- if (APPLE) +- add_custom_command(TARGET basisu POST_BUILD COMMAND strip -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu) +- else() +- add_custom_command(TARGET basisu POST_BUILD COMMAND strip -g -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu) +- endif() +- endif() +- endif() +-endif() ++target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) ++set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_EXTENSIONS OFF) diff --git a/recipes/libbasisu/all/test_package/CMakeLists.txt b/recipes/libbasisu/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2adca01f3e68a --- /dev/null +++ b/recipes/libbasisu/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_executable(${PROJECT_NAME} test_package.cpp) + +target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::libbasisu) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/libbasisu/all/test_package/conanfile.py b/recipes/libbasisu/all/test_package/conanfile.py new file mode 100644 index 0000000000000..12dd810a6ab3b --- /dev/null +++ b/recipes/libbasisu/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libbasisu/all/test_package/test_package.cpp b/recipes/libbasisu/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..15a9d4d02650c --- /dev/null +++ b/recipes/libbasisu/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main() { + basist::basisu_transcoder_init(); + std::cout << "Basisu successfuly initialized, format localized: " + << basist::basis_get_format_name(basist::transcoder_texture_format::cTFETC2_RGBA) + << std::endl; + return 0; +} diff --git a/recipes/libbasisu/config.yml b/recipes/libbasisu/config.yml new file mode 100644 index 0000000000000..d268f882f43e4 --- /dev/null +++ b/recipes/libbasisu/config.yml @@ -0,0 +1,3 @@ +versions: + "1.15.0": + folder: all diff --git a/recipes/libbigwig/all/conandata.yml b/recipes/libbigwig/all/conandata.yml new file mode 100644 index 0000000000000..e1b88454d66c1 --- /dev/null +++ b/recipes/libbigwig/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.4.7": + sha256: 8e057797011d93fa00e756600898af4fe6ca2d48959236efc9f296abe94916d9 + url: https://github.com/dpryan79/libBigWig/archive/refs/tags/0.4.7.tar.gz diff --git a/recipes/libbigwig/all/conanfile.py b/recipes/libbigwig/all/conanfile.py new file mode 100644 index 0000000000000..7caf0f129e795 --- /dev/null +++ b/recipes/libbigwig/all/conanfile.py @@ -0,0 +1,104 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import collect_libs, get, copy +from conan.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.50.0" + + +class LibBigWigConan(ConanFile): + name = "libbigwig" + description = "A C library for handling bigWig files" + topics = ("bioinformatics", "bigwig", "bigbed") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/dpryan79/libBigWig" + license = "MIT" + settings = "arch", "build_type", "compiler", "os" + + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_curl": [True, False], + "with_zlibng": [True, False] + } + + default_options = { + "shared": False, + "fPIC": True, + "with_curl": False, + "with_zlibng": False + } + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_curl: + self.requires("libcurl/7.85.0") + if self.options.with_zlibng: + self.requires("zlib-ng/2.0.6") + else: + self.requires("zlib/1.2.12") + + def validate(self): + if self.info.settings.os == "Windows": + raise ConanInvalidConfiguration(f"{self.ref} is not supported on Windows.") + + if self.info.options.with_zlibng: + zlib_ng = self.dependencies["zlib-ng"] + if not zlib_ng.options.zlib_compat: + raise ConanInvalidConfiguration(f"{self.ref} requires the dependency option zlib-ng:zlib_compat=True") + + if self.options.with_curl: + libcurl = self.dependencies["libcurl"] + if libcurl.options.with_imap or libcurl.options.with_pop3 or libcurl.options.with_smtp: + raise ConanInvalidConfiguration(f"{self.ref} requires libcurl using the follow options: -o libcurl:with_imap=False -o libcurl:with_pop3=False -o libcurl:with_smtp=False") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_TESTING"] = False + tc.variables["WITH_CURL"] = self.options.with_curl + tc.variables["WITH_ZLIBNG"] = self.options.with_zlibng + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" # honor BUILD_SHARED_LIBS + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["BigWig"] + self.cpp_info.system_libs = ["m"] + self.cpp_info.set_property("cmake_file_name", "BigWig") + self.cpp_info.set_property("cmake_target_name", "BigWig::BigWig") + + if not self.options.with_curl: + self.cpp_info.defines = ["NOCURL"] + + # TODO: Remove in Conan 2.0 + self.cpp_info.names["cmake_find_package"] = "BigWig" + self.cpp_info.names["cmake_find_package_multi"] = "BigWig" diff --git a/recipes/libbigwig/all/test_package/CMakeLists.txt b/recipes/libbigwig/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7a790b50c498a --- /dev/null +++ b/recipes/libbigwig/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package C) + +find_package(BigWig REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE BigWig::BigWig) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_11) diff --git a/recipes/libbigwig/all/test_package/conanfile.py b/recipes/libbigwig/all/test_package/conanfile.py new file mode 100644 index 0000000000000..8a6b7483b895d --- /dev/null +++ b/recipes/libbigwig/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +import os +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run + + +class TestPackageConan(ConanFile): + settings = "arch", "build_type", "compiler", "os" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libbigwig/all/test_package/test_package.c b/recipes/libbigwig/all/test_package/test_package.c new file mode 100644 index 0000000000000..7bf2175d15e63 --- /dev/null +++ b/recipes/libbigwig/all/test_package/test_package.c @@ -0,0 +1,15 @@ +#include +#include "libbigwig/bigWig.h" + + +int main(void) { + bigWigFile_t *fp = NULL; + + bwInit(1<<17); + fp = bwOpen("test_package.bw", NULL, "w"); + bwCreateHdr(fp, 10); + bwClose(fp); + bwCleanup(); + + return EXIT_SUCCESS; +} diff --git a/recipes/libbigwig/all/test_v1_package/CMakeLists.txt b/recipes/libbigwig/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0ef441c1d3786 --- /dev/null +++ b/recipes/libbigwig/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(BigWig REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE BigWig::BigWig) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_11) diff --git a/recipes/libbigwig/all/test_v1_package/conanfile.py b/recipes/libbigwig/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..fe504f17122b3 --- /dev/null +++ b/recipes/libbigwig/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +import os + +from conans import ConanFile, CMake +from conan.tools.build import cross_building + + +class TestPackageConan(ConanFile): + settings = "arch", "build_type", "compiler", "os" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libbigwig/config.yml b/recipes/libbigwig/config.yml new file mode 100644 index 0000000000000..0435ca37310c1 --- /dev/null +++ b/recipes/libbigwig/config.yml @@ -0,0 +1,3 @@ +versions: + "0.4.7": + folder: all diff --git a/recipes/libbpf/all/conandata.yml b/recipes/libbpf/all/conandata.yml new file mode 100644 index 0000000000000..80547c38b8b06 --- /dev/null +++ b/recipes/libbpf/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "0.5.0": + url: "https://github.com/libbpf/libbpf/archive/v0.5.0.tar.gz" + sha256: "d5b27980ceab9a80b6f28d3e67b51cea526fda49bd13151ba966e33548feb4f4" + "0.4.0": + url: "https://github.com/libbpf/libbpf/archive/refs/tags/v0.4.0.tar.gz" + sha256: "21cbee4df093e7fd29e76ed429650d3f3abe3a893f35e346ab9bc3484f6e68c0" diff --git a/recipes/libbpf/all/conanfile.py b/recipes/libbpf/all/conanfile.py new file mode 100644 index 0000000000000..0141cfa6106e4 --- /dev/null +++ b/recipes/libbpf/all/conanfile.py @@ -0,0 +1,90 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + + +class LibbpfConan(ConanFile): + name = "libbpf" + description = "eBPF helper library" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/libbpf/libbpf" + license = "LGPL-2.1", "BSD-2-Clause" + topics = ("bpf", "ebpf", "libbpf", "berkeley-packet-filter") + generators = "pkg_config" + settings = "os", "arch", "compiler", "build_type" + + _autotools = None + + options = { + "shared": [True, False], + "fPIC": [True, False] + } + + default_options = { + "shared": False, + "fPIC": True + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def build_requirements(self): + self.build_requires("make/4.2.1") + + def requirements(self): + self.requires("linux-headers-generic/5.13.9") + self.requires("libelf/0.8.13") + self.requires("zlib/1.2.11") + + def _configure_autotools(self): + make_args = [ + "--directory={}".format("src"), + "PREFIX={}".format(""), + "DESTDIR={}".format(self.package_folder), + "LIBSUBDIR={}".format("lib"), + ] + if not self.options.shared: + make_args.append("BUILD_STATIC_ONLY={}".format(1)) + + if self._autotools: + return self._autotools, make_args + self._autotools = AutoToolsBuildEnvironment(self) + return self._autotools, make_args + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("This library is only available on Linux") + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def build(self): + with tools.chdir(self._source_subfolder): + autotools, make_args = self._configure_autotools() + autotools.make(args=make_args) + + def package(self): + with tools.chdir(self._source_subfolder): + autotools, make_args = self._configure_autotools() + autotools.install(args=make_args) + + if self.options.shared: + os.remove(os.path.join(self.package_folder, "lib", "libbpf.a")) + + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + self.copy("LICENSE.BSD-2-Clause", dst="licenses", src=self._source_subfolder) + self.copy("LICENSE.LGPL-2.1", dst="licenses", src=self._source_subfolder) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.names["pkg_config"] = "libbpf" + self.cpp_info.libs = ["bpf"] diff --git a/recipes/libbpf/all/test_package/CMakeLists.txt b/recipes/libbpf/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..4c2c4b5007ecb --- /dev/null +++ b/recipes/libbpf/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(LibbpfTest C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(example example.c) +target_link_libraries(example ${CONAN_LIBS}) diff --git a/recipes/libbpf/all/test_package/conanfile.py b/recipes/libbpf/all/test_package/conanfile.py new file mode 100644 index 0000000000000..65d3351bbbfc6 --- /dev/null +++ b/recipes/libbpf/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class LibbpfTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/libbpf/all/test_package/example.c b/recipes/libbpf/all/test_package/example.c new file mode 100644 index 0000000000000..01f2adac98de4 --- /dev/null +++ b/recipes/libbpf/all/test_package/example.c @@ -0,0 +1,9 @@ +#include "bpf/libbpf.h" + +int main(int argc, char** argv) +{ + const char buffer[1] = { '\0' }; + struct bpf_object* obj = bpf_object__open_mem(buffer, 1, NULL); + bpf_object__close(obj); + return 0; +} diff --git a/recipes/libbpf/config.yml b/recipes/libbpf/config.yml new file mode 100644 index 0000000000000..d13fcfd021b7b --- /dev/null +++ b/recipes/libbpf/config.yml @@ -0,0 +1,5 @@ +versions: + "0.5.0": + folder: all + "0.4.0": + folder: all diff --git a/recipes/libbsd/all/conanfile.py b/recipes/libbsd/all/conanfile.py index 05cb317781976..d921957f06961 100644 --- a/recipes/libbsd/all/conanfile.py +++ b/recipes/libbsd/all/conanfile.py @@ -37,12 +37,14 @@ def configure(self): del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + + def validate(self): if not tools.is_apple_os(self.settings.os) and self.settings.os != "Linux": raise ConanInvalidConfiguration("libbsd is only available for GNU-like operating systems (e.g. Linux)") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(glob.glob("libbsd-*")[0], self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) def _configure_autotools(self): if self._autotools: @@ -86,9 +88,11 @@ def package_info(self): self.cpp_info.components["libbsd-overlay"].defines = ["LIBBSD_OVERLAY"] self.cpp_info.components["libbsd-overlay"].names["pkg_config"] = "libbsd-overlay" - self.cpp_info.components["libbsd-ctor"].libs = ["bsd-ctor"] - self.cpp_info.components["libbsd-ctor"].requires = ["bsd"] - if self.settings.os == "Linux": - self.cpp_info.components["libbsd-ctor"].exelinkflags = ["-Wl,-z,nodlopen", "-Wl,-u,libbsd_init_func"] - self.cpp_info.components["libbsd-ctor"].sharedlinkflags = ["-Wl,-z,nodlopen", "-Wl,-u,libbsd_init_func"] - self.cpp_info.components["libbsd-ctor"].names["pkg_config"] = "libbsd-ctor" + # on apple-clang, GNU .init_array section is not supported + if self.settings.compiler != "apple-clang": + self.cpp_info.components["libbsd-ctor"].libs = ["bsd-ctor"] + self.cpp_info.components["libbsd-ctor"].requires = ["bsd"] + if self.settings.os == "Linux": + self.cpp_info.components["libbsd-ctor"].exelinkflags = ["-Wl,-z,nodlopen", "-Wl,-u,libbsd_init_func"] + self.cpp_info.components["libbsd-ctor"].sharedlinkflags = ["-Wl,-z,nodlopen", "-Wl,-u,libbsd_init_func"] + self.cpp_info.components["libbsd-ctor"].names["pkg_config"] = "libbsd-ctor" diff --git a/recipes/libbsd/all/test_package/conanfile.py b/recipes/libbsd/all/test_package/conanfile.py index 6a83120b34aee..6128ac2ebae8f 100644 --- a/recipes/libbsd/all/test_package/conanfile.py +++ b/recipes/libbsd/all/test_package/conanfile.py @@ -8,7 +8,10 @@ class TestPackageConan(ConanFile): generators = "cmake", "cmake_find_package", "pkg_config" def build(self): - for f in ("libbsd", "libbsd-overlay", "libbsd-ctor"): + pcfiles = ["libbsd", "libbsd-overlay"] + if self.settings.compiler != "apple-clang": + pcfiles.append("libbsd-ctor") + for f in pcfiles: pc = "{}.pc".format(f) if not os.path.isfile(pc): raise ConanException("{} not created by pkg_config generator".format(pc)) diff --git a/recipes/libcap/all/conandata.yml b/recipes/libcap/all/conandata.yml index a6dd38fafbe50..847c16afd3b78 100644 --- a/recipes/libcap/all/conandata.yml +++ b/recipes/libcap/all/conandata.yml @@ -8,3 +8,44 @@ sources: "2.48": url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.48.tar.xz" sha256: "4de9590ee09a87c282d558737ffb5b6175ccbfd26d580add10df44d0f047f6c2" + "2.50": + url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.50.tar.xz" + sha256: "47a57b8bd238b84c93c921a9b4ff82337551dbcb0cca071316aadf3e23b19261" + "2.57": + url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.57.tar.xz" + sha256: "750221e347689e779a0ce2b22746ee9987d229712da934acb81b2d280684b7ab" + "2.58": + url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.58.tar.xz" + sha256: "41399a7d77497d348d20475dc9b2046f53e6b9755bf858ec78cc235101a11d4b" + "2.62": + url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.62.tar.xz" + sha256: "190c5baac9bee06a129eae20d3e827de62f664fe3507f0bf6c50a9a59fbd83a2" + "2.65": + url: "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.65.tar.xz" + sha256: "73e350020cc31fe15360879d19384ffa3395a825f065fcf6bda3a5cdf965bebd" + +patches: + "2.45": + - patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch" + - patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch" + "2.46": + - patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch" + - patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch" + "2.48": + - patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch" + - patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch" + "2.50": + - patch_file: "patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch" + - patch_file: "patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch" + "2.57": + - patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch" + - patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch" + "2.58": + - patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch" + - patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch" + "2.62": + - patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch" + - patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch" + "2.65": + - patch_file: "patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch" + - patch_file: "patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch" diff --git a/recipes/libcap/all/conanfile.py b/recipes/libcap/all/conanfile.py index 048303fb42649..735fde82a0243 100644 --- a/recipes/libcap/all/conanfile.py +++ b/recipes/libcap/all/conanfile.py @@ -1,7 +1,13 @@ import os -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.files import apply_conandata_patches, copy, chdir, get, rmdir +from conan.tools.layout import basic_layout +from conan.tools.gnu import Autotools, AutotoolsToolchain + +required_conan_version = ">=1.47.0" class LibcapConan(ConanFile): @@ -11,7 +17,7 @@ class LibcapConan(ConanFile): homepage = "https://git.kernel.org/pub/scm/libs/libcap/libcap.git" description = "This is a library for getting and setting POSIX.1e" \ " (formerly POSIX 6) draft 15 capabilities" - topics = ("conan", "libcap", "capabilities") + topics = ("libcap", "capabilities") settings = "os", "compiler", "build_type", "arch" options = { "shared": [True, False], @@ -23,94 +29,81 @@ class LibcapConan(ConanFile): "fPIC": True, "psx_syscals": False, } - _autotools = None - _autotools_env = None - - @property - def _source_subfolder(self): - return "source_subfolder" + exports_sources = "patches/**" def configure(self): - if self.settings.os != "Linux": - raise ConanInvalidConfiguration("Only Linux supported") if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def validate(self): + if self.info.settings.os != "Linux": + raise ConanInvalidConfiguration("Only Linux supported") + + def layout(self): + basic_layout(self, src_folder="source") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - src_folder = "{}-{}".format(self.name, self.version) - os.rename(src_folder, self._source_subfolder) - - def _configure_autotools(self): - if self._autotools: - return self._autotools, self._autotools_env - self._autotools = AutoToolsBuildEnvironment(self) - self._autotools.fpic = self.options.get_safe("fPIC", True) - self._autotools_env = self._autotools.vars - self._autotools_env["SHARED"] = \ - "yes" if self.options.shared else "no" - self._autotools_env["PTHREADS"] = \ - "yes" if self.options.psx_syscals else "no" - self._autotools_env["DESTDIR"] = self.package_folder - self._autotools_env["prefix"] = "/" - self._autotools_env["lib"] = "lib" - - if tools.cross_building(self.settings) and not tools.get_env("BUILD_CC"): - native_cc = tools.which("cc") + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = AutotoolsToolchain(self) + tc.fpic = self.options.get_safe("fPIC", True) + env = tc.environment() + env.define("SHARED", "yes" if self.options.shared else "no") + env.define("PTHREADS", "yes" if self.options.psx_syscals else "no") + env.define("DESTDIR", self.package_folder) + env.define("prefix", "/") + env.define("lib", "lib") + + if cross_building(self) and not env.vars(self).get("BUILD_CC"): + native_cc = "cc" self.output.info("Using native compiler '{}'".format(native_cc)) - self._autotools_env["BUILD_CC"] = native_cc + env.define("BUILD_CC", native_cc) - return self._autotools, self._autotools_env + tc.generate(env) def build(self): - make_rules = os.path.join(self._source_subfolder, "Make.Rules") - tools.replace_in_file( - make_rules, - "IPATH += -fPIC -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include", - "IPATH += -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include") - tools.replace_in_file( - make_rules, - "CC := $(CROSS_COMPILE)gcc", - "CC ?= $(CROSS_COMPILE)gcc") - tools.replace_in_file( - make_rules, - "AR := $(CROSS_COMPILE)ar", - "AR ?= $(CROSS_COMPILE)ar") - tools.replace_in_file( - make_rules, - "RANLIB := $(CROSS_COMPILE)ranlib", - "RANLIB ?= $(CROSS_COMPILE)ranlib") - - with tools.chdir(os.path.join(self._source_subfolder, self.name)): - env_build, env_build_vars = self._configure_autotools() - env_build.make(vars=env_build_vars) + apply_conandata_patches(self) - def package(self): - self.copy("License", dst="licenses", src=self._source_subfolder) + autotools = Autotools(self) + with chdir(self, os.path.join(self.source_folder, self.name)): + autotools.make() - with tools.chdir(os.path.join(self._source_subfolder, self.name)): - env_build, env_build_vars = self._configure_autotools() + def package(self): + copy(self, "License", self.source_folder, + os.path.join(self.package_folder, "licenses"), keep_path=False) - env_build.make(target="install-common-cap", vars=env_build_vars) + autotools = Autotools(self) + with chdir(self, os.path.join(self.source_folder, self.name)): + autotools.make(target="install-common-cap") install_cap = ("install-shared-cap" if self.options.shared else "install-static-cap") - env_build.make(target=install_cap, vars=env_build_vars) + autotools.make(target=install_cap) if self.options.psx_syscals: - env_build.make(target="install-common-psx", - vars=env_build_vars) + autotools.make(target="install-common-psx") install_psx = ("install-shared-psx" if self.options.shared else "install-static-psx") - env_build.make(target=install_psx, vars=env_build_vars) + autotools.make(target=install_psx) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.components["cap"].set_property("pkg_config_name", + "libcap") self.cpp_info.components["cap"].names["pkg_config"] = "libcap" self.cpp_info.components["cap"].libs = ["cap"] if self.options.psx_syscals: + self.cpp_info.components["psx"].set_property("pkg_config_name", + "libpsx") self.cpp_info.components["psx"].names["pkg_config"] = "libpsx" self.cpp_info.components["psx"].libs = ["psx"] self.cpp_info.components["psx"].system_libs = ["pthread"] diff --git a/recipes/libcap/all/patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch b/recipes/libcap/all/patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch new file mode 100644 index 0000000000000..b32820b0fbb55 --- /dev/null +++ b/recipes/libcap/all/patches/2.45/0001-Make.Rules-Remove-hardcoded-fPIC.patch @@ -0,0 +1,26 @@ +From bb2c4e80928e8221a31c3631f5a802c7b022aebd Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Sun, 29 Aug 2021 12:02:23 +0300 +Subject: [PATCH 1/2] Make.Rules: Remove hardcoded -fPIC + +Signed-off-by: Sergey Bobrenok +--- + Make.Rules | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Make.Rules b/Make.Rules +index cc6f95b..91099c6 100644 +--- a/Make.Rules ++++ b/Make.Rules +@@ -52,7 +52,7 @@ GOMAJOR=0 + # Compilation specifics + + KERNEL_HEADERS := $(topdir)/libcap/include/uapi +-IPATH += -fPIC -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include ++IPATH += -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include + + CC := $(CROSS_COMPILE)gcc + DEFINES := -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +-- +2.31.1 + diff --git a/recipes/libcap/all/patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch b/recipes/libcap/all/patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch new file mode 100644 index 0000000000000..5ac5d36200e61 --- /dev/null +++ b/recipes/libcap/all/patches/2.45/0002-Make.Rules-Make-compile-tools-configurable.patch @@ -0,0 +1,36 @@ +From 76e637ad20faa811f4091a8a08af4b29c528697b Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Sun, 29 Aug 2021 12:06:18 +0300 +Subject: [PATCH 2/2] Make.Rules: Make compile tools configurable + +Signed-off-by: Sergey Bobrenok +--- + Make.Rules | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/Make.Rules b/Make.Rules +index 91099c6..cd25495 100644 +--- a/Make.Rules ++++ b/Make.Rules +@@ -54,15 +54,15 @@ GOMAJOR=0 + KERNEL_HEADERS := $(topdir)/libcap/include/uapi + IPATH += -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include + +-CC := $(CROSS_COMPILE)gcc ++CC ?= $(CROSS_COMPILE)gcc + DEFINES := -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 + COPTS ?= -O2 + CFLAGS ?= $(COPTS) $(DEFINES) + BUILD_CC ?= $(CC) + BUILD_COPTS ?= -O2 + BUILD_CFLAGS ?= $(BUILD_COPTS) $(DEFINES) $(IPATH) +-AR := $(CROSS_COMPILE)ar +-RANLIB := $(CROSS_COMPILE)ranlib ++AR ?= $(CROSS_COMPILE)ar ++RANLIB ?= $(CROSS_COMPILE)ranlib + DEBUG = -g #-DDEBUG + WARNINGS=-Wall -Wwrite-strings \ + -Wpointer-arith -Wcast-qual -Wcast-align \ +-- +2.31.1 + diff --git a/recipes/libcap/all/patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch b/recipes/libcap/all/patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch new file mode 100644 index 0000000000000..bc612d7d38f9f --- /dev/null +++ b/recipes/libcap/all/patches/2.57/0001-libcap-Remove-hardcoded-fPIC.patch @@ -0,0 +1,27 @@ +From b70454fccba1816b14d50813b1715e9a50d7cca0 Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Sat, 11 Sep 2021 20:39:49 +0300 +Subject: [PATCH 1/2] libcap: Remove hardcoded -fPIC + +Signed-off-by: Sergey Bobrenok +--- + libcap/Makefile | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/libcap/Makefile b/libcap/Makefile +index 7706063..1b52eb9 100644 +--- a/libcap/Makefile ++++ b/libcap/Makefile +@@ -18,9 +18,6 @@ CAPMAGICOBJ=cap_magic.o + PSXFILES=../psx/psx + PSXMAGICOBJ=psx_magic.o + +-# Always build libcap sources this way: +-CFLAGS += -fPIC +- + # The linker magic needed to build a dynamic library as independently + # executable + MAGIC=-Wl,-e,__so_start +-- +2.31.1 + diff --git a/recipes/libcap/all/patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch b/recipes/libcap/all/patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch new file mode 100644 index 0000000000000..2807835a24217 --- /dev/null +++ b/recipes/libcap/all/patches/2.57/0002-Make.Rules-Make-compile-tools-configurable.patch @@ -0,0 +1,33 @@ +From a38f5a330d65cc877fcc1da02836526d11ead4f0 Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Sat, 11 Sep 2021 20:44:07 +0300 +Subject: [PATCH 2/2] Make.Rules: Make compile tools configurable + +Signed-off-by: Sergey Bobrenok +--- + Make.Rules | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Make.Rules b/Make.Rules +index 00f2a03..34831ae 100644 +--- a/Make.Rules ++++ b/Make.Rules +@@ -66,11 +66,11 @@ DEFINES := -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 + SYSTEM_HEADERS = /usr/include + + SUDO := sudo +-CC := $(CROSS_COMPILE)gcc ++CC ?= $(CROSS_COMPILE)gcc + LD := $(CC) -Wl,-x -shared +-AR := $(CROSS_COMPILE)ar +-RANLIB := $(CROSS_COMPILE)ranlib +-OBJCOPY := $(CROSS_COMPILE)objcopy ++AR ?= $(CROSS_COMPILE)ar ++RANLIB ?= $(CROSS_COMPILE)ranlib ++OBJCOPY ?= $(CROSS_COMPILE)objcopy + + # Reference: + # CPPFLAGS used for building .o files from .c & .h files +-- +2.31.1 + diff --git a/recipes/libcap/all/test_package/CMakeLists.txt b/recipes/libcap/all/test_package/CMakeLists.txt index 48b855b8a30aa..1e5f193ffe669 100644 --- a/recipes/libcap/all/test_package/CMakeLists.txt +++ b/recipes/libcap/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(PackageTest C) +cmake_minimum_required(VERSION 3.15) +project(PackageTest LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(PkgConfig REQUIRED) +pkg_check_modules(CAP REQUIRED IMPORTED_TARGET libcap) add_executable(example example.c) -target_link_libraries(example ${CONAN_LIBS}) +target_link_libraries(example PRIVATE PkgConfig::CAP) diff --git a/recipes/libcap/all/test_package/conanfile.py b/recipes/libcap/all/test_package/conanfile.py index f18fc21ff4db2..2e57d4c1e4055 100644 --- a/recipes/libcap/all/test_package/conanfile.py +++ b/recipes/libcap/all/test_package/conanfile.py @@ -1,11 +1,33 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake +from conan.tools.env import Environment +from conan.tools.cmake import cmake_layout + +required_conan_version = ">=1.38.0" class LibcapTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeToolchain", "PkgConfigDeps", "VirtualBuildEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.tool_requires("pkgconf/1.7.4") + + def layout(self): + cmake_layout(self) + + def generate(self): + env = Environment() + env.prepend_path("PKG_CONFIG_PATH", self.generators_folder) + envvars = env.vars(self) + envvars.save_script("pkg_config") def build(self): cmake = CMake(self) @@ -13,6 +35,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "example") + self.run(bin_path, env="conanrun") diff --git a/recipes/libcap/all/test_v1_package/CMakeLists.txt b/recipes/libcap/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2b3baa53f3347 --- /dev/null +++ b/recipes/libcap/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(PkgConfig REQUIRED) +pkg_check_modules(CAP REQUIRED IMPORTED_TARGET libcap) + +add_executable(example ../test_package/example.c) +target_link_libraries(example PRIVATE PkgConfig::CAP) diff --git a/recipes/libcap/all/test_v1_package/conanfile.py b/recipes/libcap/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..f90b4e8b52f6e --- /dev/null +++ b/recipes/libcap/all/test_v1_package/conanfile.py @@ -0,0 +1,23 @@ +import os + +from conan import ConanFile +from conan.tools.build import cross_building +from conans import CMake + + +class LibcapTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "pkg_config" + + def build_requirements(self): + self.tool_requires("pkgconf/1.7.4") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/libcap/config.yml b/recipes/libcap/config.yml index 056bac3a4e64f..ee4c4ae443408 100644 --- a/recipes/libcap/config.yml +++ b/recipes/libcap/config.yml @@ -5,3 +5,13 @@ versions: folder: all "2.48": folder: all + "2.50": + folder: all + "2.57": + folder: all + "2.58": + folder: all + "2.62": + folder: all + "2.65": + folder: all diff --git a/recipes/libcbor/all/CMakeLists.txt b/recipes/libcbor/all/CMakeLists.txt deleted file mode 100644 index 361b35d4c17d9..0000000000000 --- a/recipes/libcbor/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/libcbor/all/conandata.yml b/recipes/libcbor/all/conandata.yml index db11ba9108939..62e7073df986d 100644 --- a/recipes/libcbor/all/conandata.yml +++ b/recipes/libcbor/all/conandata.yml @@ -1,8 +1,13 @@ sources: + "0.9.0": + url: "https://github.com/PJK/libcbor/archive/v0.9.0.tar.gz" + sha256: "da81e4f9333e0086d4e2745183c7052f04ecc4dbcffcf910029df24f103c15d1" "0.7.0": - sha256: fb731afe0a9980581d85e4b8d4ef128b175f782d92e0cd898935f3d26dd3dde7 url: https://github.com/PJK/libcbor/archive/v0.7.0.tar.gz + sha256: "fb731afe0a9980581d85e4b8d4ef128b175f782d92e0cd898935f3d26dd3dde7" patches: + "0.9.0": + - patch_file: "patches/0.7.0/002_fix_cmake_module_path.patch" "0.7.0": - patch_file: "patches/0.7.0/001_fix_shared_build.patch" - base_path: "source_subfolder" + - patch_file: "patches/0.7.0/002_fix_cmake_module_path.patch" diff --git a/recipes/libcbor/all/conanfile.py b/recipes/libcbor/all/conanfile.py index 30ac5aba9fed7..2dcedcee9a1fc 100644 --- a/recipes/libcbor/all/conanfile.py +++ b/recipes/libcbor/all/conanfile.py @@ -1,6 +1,9 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir import os -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.53.0" class LibCborStackConan(ConanFile): @@ -8,70 +11,69 @@ class LibCborStackConan(ConanFile): license = "MIT" homepage = "https://github.com/PJK/libcbor" url = "https://github.com/conan-io/conan-center-index" - description = """CBOR protocol implementation for C""" + description = "CBOR protocol implementation for C" topics = ("cbor", "serialization", "messaging") - exports_sources = ['CMakeLists.txt', 'patches/*'] - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "custom_alloc": [True, False] + "custom_alloc": [True, False], + "pretty_printer": [True, False], + "buffer_growth_factor": ["ANY"], } default_options = { "shared": False, "fPIC": True, - "custom_alloc": False + "custom_alloc": False, + "pretty_printer": True, + "buffer_growth_factor": 2, } - generators = "cmake" - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["WITH_EXAMPLES"] = False - self._cmake.definitions["SANITIZE"] = False - self._cmake.definitions["CBOR_CUSTOM_ALLOC"] = self.options.custom_alloc + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_EXAMPLES"] = False + tc.variables["SANITIZE"] = False + tc.variables["CBOR_CUSTOM_ALLOC"] = self.options.custom_alloc + tc.variables["CBOR_PRETTY_PRINTER"] = self.options.pretty_printer + tc.variables["CBOR_BUFFER_GROWTH"] = self.options.buffer_growth_factor + # Relocatable shared libs on macOS + tc.variables["CMAKE_MACOSX_RPATH"] = True + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("pkg_config_name", "libcbor") + self.cpp_info.libs = ["cbor"] if self.settings.os == "Windows": self.cpp_info.system_libs = ["ws2_32"] diff --git a/recipes/libcbor/all/patches/0.7.0/002_fix_cmake_module_path.patch b/recipes/libcbor/all/patches/0.7.0/002_fix_cmake_module_path.patch new file mode 100644 index 0000000000000..3c9e0c835ddbe --- /dev/null +++ b/recipes/libcbor/all/patches/0.7.0/002_fix_cmake_module_path.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7552c0f..52185e7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,6 +1,6 @@ + cmake_minimum_required(VERSION 2.8) + project(libcbor) +-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/") ++set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/") + include(CTest) + + SET(CBOR_VERSION_MAJOR "0") diff --git a/recipes/libcbor/all/test_package/CMakeLists.txt b/recipes/libcbor/all/test_package/CMakeLists.txt index 196188113685c..fc2cbc0d5af6e 100644 --- a/recipes/libcbor/all/test_package/CMakeLists.txt +++ b/recipes/libcbor/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libcbor REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libcbor::libcbor) diff --git a/recipes/libcbor/all/test_package/conanfile.py b/recipes/libcbor/all/test_package/conanfile.py index 933dbf96533ae..0a6bc68712d90 100644 --- a/recipes/libcbor/all/test_package/conanfile.py +++ b/recipes/libcbor/all/test_package/conanfile.py @@ -1,11 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" -class TestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -13,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - bin_path = self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libcbor/all/test_package/test_package.cpp b/recipes/libcbor/all/test_package/test_package.c similarity index 100% rename from recipes/libcbor/all/test_package/test_package.cpp rename to recipes/libcbor/all/test_package/test_package.c diff --git a/recipes/libcbor/all/test_v1_package/CMakeLists.txt b/recipes/libcbor/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libcbor/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libcbor/all/test_v1_package/conanfile.py b/recipes/libcbor/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libcbor/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libcbor/config.yml b/recipes/libcbor/config.yml index eb2ae9deff25d..b4b6b81f6444e 100644 --- a/recipes/libcbor/config.yml +++ b/recipes/libcbor/config.yml @@ -1,4 +1,5 @@ ---- versions: + "0.9.0": + folder: "all" "0.7.0": folder: "all" diff --git a/recipes/libccd/all/CMakeLists.txt b/recipes/libccd/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/libccd/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libccd/all/conanfile.py b/recipes/libccd/all/conanfile.py index dc524d5a6c6b0..17228a62767e4 100644 --- a/recipes/libccd/all/conanfile.py +++ b/recipes/libccd/all/conanfile.py @@ -1,41 +1,32 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir, save import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" class LibccdConan(ConanFile): name = "libccd" description = "Library for collision detection between two convex shapes." license = "BSD-3-Clause" - topics = ("conan", "libccd", "collision", "3d") + topics = ("libccd", "collision", "3d") homepage = "https://github.com/danfis/libccd" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "CMakeLists.txt" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "enable_double_precision": [True, False] + "enable_double_precision": [True, False], } default_options = { "shared": False, "fPIC": True, - "enable_double_precision": False + "enable_double_precision": False, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -43,43 +34,49 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_DOCUMENTATION"] = False + tc.variables["ENABLE_DOUBLE_PRECISION"] = self.options.enable_double_precision + tc.variables["CCD_HIDE_ALL_SYMBOLS"] = not self.options.shared + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "${CMAKE_BINARY_DIR}", "${CMAKE_CURRENT_BINARY_DIR}") - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_DOCUMENTATION"] = False - self._cmake.definitions["ENABLE_DOUBLE_PRECISION"] = self.options.enable_double_precision - self._cmake.definitions["CCD_HIDE_ALL_SYMBOLS"] = not self.options.shared - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("BSD-LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "BSD-LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "ccd")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "ccd")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {"ccd": "ccd::ccd"} ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): content += textwrap.dedent("""\ @@ -88,26 +85,26 @@ def _create_cmake_module_alias_targets(module_file, targets): set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + save(self, module_file, content) @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "ccd") + self.cpp_info.set_property("cmake_target_name", "ccd") + self.cpp_info.set_property("pkg_config_name", "ccd") + + self.cpp_info.libs = ["ccd"] + if not self.options.shared: + self.cpp_info.defines.append("CCD_STATIC_DEFINE") + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self.cpp_info.names["cmake_find_package"] = "ccd" self.cpp_info.names["cmake_find_package_multi"] = "ccd" - self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] self.cpp_info.names["pkg_config"] = "ccd" - self.cpp_info.libs = tools.collect_libs(self) - if not self.options.shared: - self.cpp_info.defines.append("CCD_STATIC_DEFINE") - if self.settings.os == "Linux": - self.cpp_info.system_libs.append("m") diff --git a/recipes/libccd/all/test_package/CMakeLists.txt b/recipes/libccd/all/test_package/CMakeLists.txt index 73ed89eb9ce2d..776995184ae2f 100644 --- a/recipes/libccd/all/test_package/CMakeLists.txt +++ b/recipes/libccd/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(ccd REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ccd) +target_link_libraries(${PROJECT_NAME} PRIVATE ccd) diff --git a/recipes/libccd/all/test_package/conanfile.py b/recipes/libccd/all/test_package/conanfile.py index a9f777f7680ff..3a8c6c5442b33 100644 --- a/recipes/libccd/all/test_package/conanfile.py +++ b/recipes/libccd/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libccd/all/test_v1_package/CMakeLists.txt b/recipes/libccd/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e9d8dfb4f9d7b --- /dev/null +++ b/recipes/libccd/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ccd REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE ccd) diff --git a/recipes/libccd/all/test_v1_package/conanfile.py b/recipes/libccd/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/libccd/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libcds/all/CMakeLists.txt b/recipes/libcds/all/CMakeLists.txt deleted file mode 100644 index 593d981510a2f..0000000000000 --- a/recipes/libcds/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.0.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/libcds/all/conandata.yml b/recipes/libcds/all/conandata.yml index 64b24372bf082..2c037db058371 100644 --- a/recipes/libcds/all/conandata.yml +++ b/recipes/libcds/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "2.3.3": - patch_file: "patches/fix-cmake.patch" - base_path: "source_subfolder" diff --git a/recipes/libcds/all/conanfile.py b/recipes/libcds/all/conanfile.py index 3ea4be9a4c3d8..678232b29deac 100644 --- a/recipes/libcds/all/conanfile.py +++ b/recipes/libcds/all/conanfile.py @@ -1,25 +1,34 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get, rmdir import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.50.0" + class LibcdsConan(ConanFile): name = "libcds" description = "C++11 library of Concurrent Data Structures." license = "BSL-1.0" - topics = ("conan", "libcds", "concurrent", "lock-free", "containers", "hazard-pointer", "rcu") + topics = ("libcds", "concurrent", "lock-free", "containers", "hazard-pointer", "rcu") homepage = "https://github.com/khizmax/libcds" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -28,53 +37,65 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) def requirements(self): - self.requires("boost/1.74.0") + self.requires("boost/1.79.0") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + if self.info.settings.os == "Macos" and self.info.settings.arch == "armv8": + raise ConanInvalidConfiguration("Macos M1 not supported (yet)") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["WITH_TESTS"] = False - self._cmake.definitions["WITH_TESTS_COVERAGE"] = False - self._cmake.definitions["WITH_BOOST_ATOMIC"] = False - self._cmake.definitions["WITH_ASAN"] = False - self._cmake.definitions["WITH_TSAN"] = False - self._cmake.definitions["ENABLE_UNIT_TEST"] = False - self._cmake.definitions["ENABLE_STRESS_TEST"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_TESTS"] = False + tc.variables["WITH_TESTS_COVERAGE"] = False + tc.variables["WITH_BOOST_ATOMIC"] = False + tc.variables["WITH_ASAN"] = False + tc.variables["WITH_TSAN"] = False + tc.variables["ENABLE_UNIT_TEST"] = False + tc.variables["ENABLE_STRESS_TEST"] = False + tc.generate() + cd = CMakeDeps(self) + cd.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "LibCDS" - self.cpp_info.names["cmake_find_package_multi"] = "LibCDS" cmake_target = "cds" if self.options.shared else "cds-s" - self.cpp_info.components["_libcds"].names["cmake_find_package"] = cmake_target - self.cpp_info.components["_libcds"].names["cmake_find_package_multi"] = cmake_target - self.cpp_info.components["_libcds"].libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "LibCDS") + self.cpp_info.set_property("cmake_target_name", "LibCDS::{}".format(cmake_target)) + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["_libcds"].libs = collect_libs(self) if self.settings.os == "Windows" and not self.options.shared: self.cpp_info.components["_libcds"].defines = ["CDS_BUILD_STATIC_LIB"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["_libcds"].system_libs = ["pthread"] if self.settings.compiler in ["gcc", "clang", "apple-clang"] and self.settings.arch == "x86_64": self.cpp_info.components["_libcds"].cxxflags = ["-mcx16"] self.cpp_info.components["_libcds"].requires = ["boost::boost"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "LibCDS" + self.cpp_info.names["cmake_find_package_multi"] = "LibCDS" + self.cpp_info.components["_libcds"].names["cmake_find_package"] = cmake_target + self.cpp_info.components["_libcds"].names["cmake_find_package_multi"] = cmake_target + self.cpp_info.components["_libcds"].set_property("cmake_target_name", "LibCDS::{}".format(cmake_target)) diff --git a/recipes/libcds/all/test_package/CMakeLists.txt b/recipes/libcds/all/test_package/CMakeLists.txt index 7274c2bbc730b..481acf254620b 100644 --- a/recipes/libcds/all/test_package/CMakeLists.txt +++ b/recipes/libcds/all/test_package/CMakeLists.txt @@ -1,15 +1,12 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(LibCDS REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) -if(LIBCDS_SHARED) - target_link_libraries(${PROJECT_NAME} LibCDS::cds) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +if(TARGET LibCDS::cds-s) + target_link_libraries(${PROJECT_NAME} PRIVATE LibCDS::cds-s) else() - target_link_libraries(${PROJECT_NAME} LibCDS::cds-s) + target_link_libraries(${PROJECT_NAME} PRIVATE LibCDS::cds) endif() diff --git a/recipes/libcds/all/test_package/conanfile.py b/recipes/libcds/all/test_package/conanfile.py index d0f29df82a9cf..3a8c6c5442b33 100644 --- a/recipes/libcds/all/test_package/conanfile.py +++ b/recipes/libcds/all/test_package/conanfile.py @@ -1,18 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) - cmake.definitions["LIBCDS_SHARED"] = self.options["libcds"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libcds/all/test_v1_package/CMakeLists.txt b/recipes/libcds/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..fb01e094e9d0d --- /dev/null +++ b/recipes/libcds/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(LibCDS REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +if(TARGET LibCDS::cds-s) + target_link_libraries(${PROJECT_NAME} PRIVATE LibCDS::cds-s) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE LibCDS::cds) +endif() diff --git a/recipes/libcds/all/test_v1_package/conanfile.py b/recipes/libcds/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libcds/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libcheck/all/conanfile.py b/recipes/libcheck/all/conanfile.py index 3f0a26a6a7f17..5113b075852b0 100644 --- a/recipes/libcheck/all/conanfile.py +++ b/recipes/libcheck/all/conanfile.py @@ -1,16 +1,18 @@ from conans import CMake, ConanFile, tools import os +required_conan_version = ">=1.43.0" + class LibCheckConan(ConanFile): name = "libcheck" description = "A unit testing framework for C" - topics = "conan", "libcheck", "unit", "testing", "framework", "C" - license = "https://github.com/libcheck/check" + topics = ("libcheck", "unit", "testing", "framework", "C") + license = "LGPL-2.1-or-later" homepage = "https://github.com/libcheck/check" url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" - exports_sources = "CMakeLists.txt", "patches/**" options = { "shared": [True, False], "fPIC": [True, False], @@ -21,8 +23,8 @@ class LibCheckConan(ConanFile): "fPIC": True, "with_subunit": True, } - generators = "cmake", "cmake_find_package", "pkg_config" + generators = "cmake", "cmake_find_package" _cmake = None @property @@ -33,6 +35,15 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -47,15 +58,9 @@ def requirements(self): if self.options.with_subunit: self.requires("subunit/1.4.0") - def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") - if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.2") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("check-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -84,28 +89,31 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "check" - self.cpp_info.filenames["cmake_find_package_multi"] = "check" - self.cpp_info.filenames["pkg_config"] = "check" - - self.cpp_info.names["cmake_find_package"] = "Check" - self.cpp_info.names["cmake_find_package_multi"] = "Check" - - libsuffix = "" - if self.options.shared: - if self.settings.compiler == "Visual Studio": - libsuffix = "Dynamic" - - self.cpp_info.components["liblibcheck"].libs = ["check" + libsuffix] + target = "checkShared" if self.options.shared else "check" + self.cpp_info.set_property("cmake_file_name", "check") + self.cpp_info.set_property("cmake_target_name", "Check::{}".format(target)) + self.cpp_info.set_property("pkg_config_name", "check") + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + libsuffix = "Dynamic" if self._is_msvc and self.options.shared else "" + self.cpp_info.components["liblibcheck"].libs = ["check{}".format(libsuffix)] if self.options.with_subunit: self.cpp_info.components["liblibcheck"].requires.append("subunit::libsubunit") if not self.options.shared: - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["liblibcheck"].system_libs = ["m", "pthread", "rt"] - self.cpp_info.components["liblibcheck"].names["cmake_find_package"] = "checkShared" if self.options.shared else "check" - self.cpp_info.components["liblibcheck"].names["cmake_find_package_multi"] = "checkShared" if self.options.shared else "check" - bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "check" + self.cpp_info.filenames["cmake_find_package_multi"] = "check" + self.cpp_info.names["cmake_find_package"] = "Check" + self.cpp_info.names["cmake_find_package_multi"] = "Check" + self.cpp_info.names["pkg_config"] = "check" + self.cpp_info.components["liblibcheck"].names["cmake_find_package"] = target + self.cpp_info.components["liblibcheck"].names["cmake_find_package_multi"] = target + self.cpp_info.components["liblibcheck"].set_property("cmake_target_name", "Check::{}".format(target)) + self.cpp_info.components["liblibcheck"].set_property("pkg_config_name", "check") diff --git a/recipes/libcheck/all/test_package/CMakeLists.txt b/recipes/libcheck/all/test_package/CMakeLists.txt index 3a403dc404b41..d0ea6b764c70f 100644 --- a/recipes/libcheck/all/test_package/CMakeLists.txt +++ b/recipes/libcheck/all/test_package/CMakeLists.txt @@ -2,7 +2,13 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(check REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +if(TARGET Check::checkShared) + target_link_libraries(${PROJECT_NAME} Check::checkShared) +else() + target_link_libraries(${PROJECT_NAME} Check::check) +endif() diff --git a/recipes/libcheck/all/test_package/conanfile.py b/recipes/libcheck/all/test_package/conanfile.py index bd7165a553cf4..38f4483872d47 100644 --- a/recipes/libcheck/all/test_package/conanfile.py +++ b/recipes/libcheck/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libcoap/all/conandata.yml b/recipes/libcoap/all/conandata.yml index 17daed23722ed..933f8a2810d53 100644 --- a/recipes/libcoap/all/conandata.yml +++ b/recipes/libcoap/all/conandata.yml @@ -2,3 +2,6 @@ sources: "cci.20200424": sha256: 8402bf2dd9979d6d5f823a050cd3533619fe9b21e76be8c69a9b7d8b8ea175ab url: https://github.com/obgm/libcoap/archive/17957e1e687c2218b7752a8a959eac36dbf5cb62.zip + "4.3.0": + url: https://github.com/obgm/libcoap/archive/refs/tags/v4.3.0.tar.gz + sha256: 1a195adacd6188d3b71c476e7b21706fef7f3663ab1fb138652e8da49a9ec556 diff --git a/recipes/libcoap/all/conanfile.py b/recipes/libcoap/all/conanfile.py index 88c964d612e68..016cb1a3f6f02 100644 --- a/recipes/libcoap/all/conanfile.py +++ b/recipes/libcoap/all/conanfile.py @@ -38,9 +38,9 @@ def _build_subfolder(self): def requirements(self): if self.options.dtls_backend == "openssl": - self.requires("openssl/1.1.1h") + self.requires("openssl/1.1.1q") elif self.options.dtls_backend == "mbedtls": - self.requires("mbedtls/2.16.3-apache") + self.requires("mbedtls/2.25.0") elif self.options.dtls_backend == "gnutls": raise ConanInvalidConfiguration("gnu tls not available yet") elif self.options.dtls_backend == "tinydtls": @@ -59,11 +59,8 @@ def configure(self): del self.settings.compiler.cppstd def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + \ - os.path.basename( - self.conan_data["sources"][self.version]["url"]).split(".")[0] - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -72,6 +69,11 @@ def _configure_cmake(self): self._cmake.definitions["WITH_EPOLL"] = self.options.with_epoll self._cmake.definitions["ENABLE_DTLS"] = self.options.dtls_backend != None self._cmake.definitions["DTLS_BACKEND"] = self.options.dtls_backend + + if self.version != "cci.20200424": + self._cmake.definitions["ENABLE_DOCS"] = False + self._cmake.definitions["ENABLE_EXAMPLES"] = False + self._cmake.configure(build_folder=self._build_subfolder) return self._cmake @@ -86,12 +88,21 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - pkgconfig_filename = "libcoap-2{}".format("-{}".format(self.options.dtls_backend) if self.options.dtls_backend else "") - self.cpp_info.names["pkg_config"] = pkgconfig_filename + library_name = "" + pkgconfig_name = "" + if self.version == "cci.20200424": + library_name = "coap" + pkgconfig_name = "libcoap-2" + else: + library_name = "coap-3" + pkgconfig_name = "libcoap-3" + self.cpp_info.components["coap"].names["cmake_find_package"] = "coap" self.cpp_info.components["coap"].names["cmake_find_package_multi"] = "coap" + pkgconfig_filename = "{}{}".format(pkgconfig_name, "-{}".format(self.options.dtls_backend) if self.options.dtls_backend else "") self.cpp_info.components["coap"].names["pkg_config"] = pkgconfig_filename - self.cpp_info.components["coap"].libs = ["coap"] + self.cpp_info.components["coap"].libs = [library_name] + if self.settings.os == "Linux": self.cpp_info.components["coap"].system_libs = ["pthread"] if self.options.dtls_backend == "openssl": diff --git a/recipes/libcoap/all/test_package/CMakeLists.txt b/recipes/libcoap/all/test_package/CMakeLists.txt index a8acc4f57e48d..b81eef988f5b5 100644 --- a/recipes/libcoap/all/test_package/CMakeLists.txt +++ b/recipes/libcoap/all/test_package/CMakeLists.txt @@ -9,3 +9,4 @@ find_package(libcoap REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} libcoap::coap) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_compile_definitions(${PROJECT_NAME} PUBLIC LIB_VERSION=${LIB_VERSION}) diff --git a/recipes/libcoap/all/test_package/conanfile.py b/recipes/libcoap/all/test_package/conanfile.py index 6dffe66394a26..8bd5d5d915f3d 100644 --- a/recipes/libcoap/all/test_package/conanfile.py +++ b/recipes/libcoap/all/test_package/conanfile.py @@ -8,6 +8,13 @@ class TestConan(ConanFile): def build(self): cmake = CMake(self) + + version = self.deps_cpp_info["libcoap"].version; + if version == "cci.20200424": + cmake.definitions["LIB_VERSION"] = 2 + else: + cmake.definitions["LIB_VERSION"] = 3 + cmake.configure() cmake.build() diff --git a/recipes/libcoap/all/test_package/test_package.cpp b/recipes/libcoap/all/test_package/test_package.cpp index 8e75bb8972a71..889e1c8fa6d20 100644 --- a/recipes/libcoap/all/test_package/test_package.cpp +++ b/recipes/libcoap/all/test_package/test_package.cpp @@ -1,4 +1,11 @@ +#if LIB_VERSION == 2 #include "coap2/coap.h" +#elif LIB_VERSION == 3 +#include "coap3/coap.h" +#else +#error "Version not supported" +#endif + #include int main() { diff --git a/recipes/libcoap/config.yml b/recipes/libcoap/config.yml index 1293823b59323..2b90fe3a049b9 100644 --- a/recipes/libcoap/config.yml +++ b/recipes/libcoap/config.yml @@ -2,3 +2,5 @@ versions: "cci.20200424": folder: "all" + "4.3.0": + folder: "all" diff --git a/recipes/libconfuse/all/conandata.yml b/recipes/libconfuse/all/conandata.yml index c803311329f9b..d999ffda52886 100644 --- a/recipes/libconfuse/all/conandata.yml +++ b/recipes/libconfuse/all/conandata.yml @@ -1,7 +1,7 @@ sources: - "3.2.2": - url: "https://github.com/martinh/libconfuse/releases/download/v3.2.2/confuse-3.2.2.tar.gz" - sha256: "71316b55592f8d0c98924242c98dbfa6252153a8b6e7d89e57fe6923934d77d0" "3.3": url: "https://github.com/martinh/libconfuse/releases/download/v3.3/confuse-3.3.tar.gz" sha256: "3a59ded20bc652eaa8e6261ab46f7e483bc13dad79263c15af42ecbb329707b8" + "3.2.2": + url: "https://github.com/martinh/libconfuse/releases/download/v3.2.2/confuse-3.2.2.tar.gz" + sha256: "71316b55592f8d0c98924242c98dbfa6252153a8b6e7d89e57fe6923934d77d0" diff --git a/recipes/libconfuse/all/conanfile.py b/recipes/libconfuse/all/conanfile.py index 4f96441bf3703..6b372d54a5173 100644 --- a/recipes/libconfuse/all/conanfile.py +++ b/recipes/libconfuse/all/conanfile.py @@ -1,12 +1,20 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from contextlib import contextmanager +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import copy, get, rename, replace_in_file, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version import os +required_conan_version = ">=1.53.0" -class LibConfuse(ConanFile): + +class LibConfuseConan(ConanFile): name = "libconfuse" description = "Small configuration file parser library for C" - topics = ("conan", "libconfuse", "configuration", "parser") + topics = ("configuration", "parser") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/martinh/libconfuse" license = "ISC" @@ -20,11 +28,9 @@ class LibConfuse(ConanFile): "fPIC": True, } - _autotools = None - @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): if self.settings.os == "Windows": @@ -32,69 +38,67 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("confuse-{}".format(self.version), self._source_subfolder) + def layout(self): + basic_layout(self, src_folder="src") def build_requirements(self): - if tools.os_info.is_windows and not os.environ.get("CONAN_BASH_PATH") and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - conf_args = [] - if self.options.shared: - conf_args.extend(["--enable-shared", "--disable-static"]) - else: - conf_args.extend(["--disable-shared", "--enable-static"]) - self._autotools.configure(configure_dir=self._source_subfolder, args=conf_args) - return self._autotools - - @contextmanager - def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - with tools.environment_append({"CC": "cl -nologo", - "CXX": "cl -nologo", - "LD": "link"}): - yield - else: - yield + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + tc.generate() + + if is_msvc(self): + env = Environment() + env.define("CC", "cl -nologo") + env.define("CXX", "cl -nologo") + env.define("LD", "link -nologo") + env.vars(self).save_script("conanbuild_libconfuse_msvc") def _patch_sources(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.in"), + replace_in_file(self, os.path.join(self.source_folder, "Makefile.in"), "SUBDIRS = m4 po src $(EXAMPLES) tests doc", "SUBDIRS = m4 src") if not self.options.shared: - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "confuse.h"), + replace_in_file(self, os.path.join(self.source_folder, "src", "confuse.h"), "__declspec (dllimport)", "") def build(self): self._patch_sources() - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() - - os.unlink(os.path.join(self.package_folder, "lib", "libconfuse.la")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + if is_msvc(self) and self.options.shared: + rename(self, os.path.join(self.package_folder, "lib", "confuse.dll.lib"), + os.path.join(self.package_folder, "lib", "confuse.lib")) + fix_apple_shared_install_name(self) def package_info(self): - lib = "confuse" - if self.settings.os == "Windows" and self.options.shared: - lib += ".dll.{}".format("lib" if self.settings.compiler == "Visual Studio" else "a") - self.cpp_info.libs = [lib] - self.cpp_info.names["pkg_config"] = "libconfuse" + self.cpp_info.set_property("pkg_config_name", "libconfuse") + self.cpp_info.libs = ["confuse"] diff --git a/recipes/libconfuse/all/test_package/CMakeLists.txt b/recipes/libconfuse/all/test_package/CMakeLists.txt index 7b9b613cbb24a..c98d1db7c151d 100644 --- a/recipes/libconfuse/all/test_package/CMakeLists.txt +++ b/recipes/libconfuse/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libconfuse REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libconfuse::libconfuse) diff --git a/recipes/libconfuse/all/test_package/conanfile.py b/recipes/libconfuse/all/test_package/conanfile.py index 8e4aa1948864e..f7963cc87b0ba 100644 --- a/recipes/libconfuse/all/test_package/conanfile.py +++ b/recipes/libconfuse/all/test_package/conanfile.py @@ -1,11 +1,20 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout from io import StringIO import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -13,11 +22,11 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") config_path = os.path.join(self.source_folder, "hello.conf") output = StringIO() - self.run("{} {}".format(bin_path, config_path), run_environment=True, output=output) + self.run(f"{bin_path} {config_path}", env="conanrun", output=output) text = output.getvalue() print(text) assert "Neighbour" in text diff --git a/recipes/libconfuse/all/test_v1_package/CMakeLists.txt b/recipes/libconfuse/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libconfuse/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libconfuse/all/test_v1_package/conanfile.py b/recipes/libconfuse/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..6f8d199faef5a --- /dev/null +++ b/recipes/libconfuse/all/test_v1_package/conanfile.py @@ -0,0 +1,23 @@ +from conans import ConanFile, CMake, tools +from io import StringIO +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + config_path = os.path.join(self.source_folder, os.pardir, "test_package", "hello.conf") + output = StringIO() + self.run(f"{bin_path} {config_path}", run_environment=True, output=output) + text = output.getvalue() + print(text) + assert "Neighbour" in text diff --git a/recipes/libconfuse/config.yml b/recipes/libconfuse/config.yml index 4854c14488209..ed8415be53cb7 100644 --- a/recipes/libconfuse/config.yml +++ b/recipes/libconfuse/config.yml @@ -1,5 +1,5 @@ versions: - "3.2.2": - folder: all "3.3": folder: all + "3.2.2": + folder: all diff --git a/recipes/libcorrect/all/CMakeLists.txt b/recipes/libcorrect/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/libcorrect/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libcorrect/all/conandata.yml b/recipes/libcorrect/all/conandata.yml index 373b501c11a6c..bbabb165203bc 100644 --- a/recipes/libcorrect/all/conandata.yml +++ b/recipes/libcorrect/all/conandata.yml @@ -2,10 +2,7 @@ sources: "20181010": url: "https://github.com/quiet/libcorrect/archive/f5a28c74fba7a99736fe49d3a5243eca29517ae9.tar.gz" sha256: 5a4305aabe6c7d5b58f6677c41c54ad5e8d9003f7a5998f7344d93534e4c5760 - patches: "20181010": - patch_file: "patches/0001-Support-CMake-BUILD_SHARED_LIBS.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-Export-symbols-for-windows.patch" - base_path: "source_subfolder" diff --git a/recipes/libcorrect/all/conanfile.py b/recipes/libcorrect/all/conanfile.py index 4e8c02dd2f66e..a2cd26c5b3b8e 100644 --- a/recipes/libcorrect/all/conanfile.py +++ b/recipes/libcorrect/all/conanfile.py @@ -1,16 +1,20 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file import os -import glob +required_conan_version = ">=1.52.0" -class LibaecConan(ConanFile): + +class LibcorrectConan(ConanFile): name = "libcorrect" license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/quiet/libcorrect" description = "C library for Convolutional codes and Reed-Solomon" - topics = ("conan", "dsp", "libaec", "encoding", "decoding") - settings = "os", "compiler", "build_type", "arch" + topics = ("fec", "reed-solomon", "viterbi", "convolutional") + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -20,50 +24,61 @@ class LibaecConan(ConanFile): "fPIC": True, } - generators = "cmake" - exports_sources = ["CMakeLists.txt", "patches/*"] - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob(self.name + "-*")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - cmake = CMake(self) - cmake.configure(build_folder=self._build_subfolder) - return cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) + # Relocatable shared lib on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() - def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def _patch_sources(self): + apply_conandata_patches(self) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "-fPIC", "") + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "-fsanitize=address", "") - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), "-fPIC", "") - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), "-fsanitize=address", "") - cmake = self._configure_cmake() + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.libs = ["correct"] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") diff --git a/recipes/libcorrect/all/test_package/CMakeLists.txt b/recipes/libcorrect/all/test_package/CMakeLists.txt index aae00b641388d..37ccc2fe5dfaa 100644 --- a/recipes/libcorrect/all/test_package/CMakeLists.txt +++ b/recipes/libcorrect/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 3.1.3) -project(test_package) +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libcorrect REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libcorrect::libcorrect) diff --git a/recipes/libcorrect/all/test_package/conanfile.py b/recipes/libcorrect/all/test_package/conanfile.py index bd7165a553cf4..0a6bc68712d90 100644 --- a/recipes/libcorrect/all/test_package/conanfile.py +++ b/recipes/libcorrect/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libcorrect/all/test_v1_package/CMakeLists.txt b/recipes/libcorrect/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..37041d4cb4431 --- /dev/null +++ b/recipes/libcorrect/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libcorrect REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libcorrect::libcorrect) diff --git a/recipes/libcorrect/all/test_v1_package/conanfile.py b/recipes/libcorrect/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libcorrect/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libcpuid/all/conanfile.py b/recipes/libcpuid/all/conanfile.py index e71f07a22054c..68d83bcf3f7fc 100644 --- a/recipes/libcpuid/all/conanfile.py +++ b/recipes/libcpuid/all/conanfile.py @@ -2,14 +2,17 @@ from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.43.0" + class LibCpuidConan(ConanFile): name = "libcpuid" description = "libcpuid is a small C library for x86 CPU detection and feature extraction" - topics = ("conan", "libcpuid", "detec", "cpu", "intel", "amd", "x86_64") + topics = ("libcpuid", "detec", "cpu", "intel", "amd", "x86_64") license = "https://github.com/anrieff/libcpuid" homepage = "https://github.com/anrieff/libcpuid" url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -19,9 +22,8 @@ class LibCpuidConan(ConanFile): "shared": False, "fPIC": True, } - generators = "cmake" - exports_sources = "CMakeLists.txt", "patches/**" + generators = "cmake" _cmake = None @property @@ -32,6 +34,11 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -39,14 +46,16 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.arch not in ("x86", "x86_64"): - raise ConanInvalidConfiguration("libcpuid is only available for x86 and x86_64 architecture") del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def validate(self): + if self.settings.arch not in ("x86", "x86_64"): + raise ConanInvalidConfiguration("libcpuid is only available for x86 and x86_64 architecture") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -59,23 +68,26 @@ def _configure_cmake(self): def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - autotools = self._configure_cmake() - autotools.build() + cmake = self._configure_cmake() + cmake.build() def package(self): self.copy("COPYING", src=self._source_subfolder, dst="licenses") - autotools = self._configure_cmake() - autotools.install() - + cmake = self._configure_cmake() + cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "cpuid") + self.cpp_info.set_property("cmake_target_name", "cpuid::cpuid") + self.cpp_info.set_property("pkg_config_name", "libcpuid") self.cpp_info.libs = ["cpuid"] - self.cpp_info.names["cmake_find_package"] = "cpuid" - self.cpp_info.names["cmake_find_package_multi"] = "cpuid" - self.cpp_info.names["pkg_config"] = "libcpuid" bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "cpuid" + self.cpp_info.names["cmake_find_package_multi"] = "cpuid" diff --git a/recipes/libcpuid/all/patches/0.5.0-cmake-fixes.patch b/recipes/libcpuid/all/patches/0.5.0-cmake-fixes.patch index 61507e0f4af60..31d0f27ec5aad 100644 --- a/recipes/libcpuid/all/patches/0.5.0-cmake-fixes.patch +++ b/recipes/libcpuid/all/patches/0.5.0-cmake-fixes.patch @@ -1,19 +1,31 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -11,8 +11,8 @@ set(CMAKE_CXX_STANDARD 11) - set(CMAKE_C_STANDARD 99) +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -27,4 +27,3 @@ endif(UNIX) + # Include subdirectories + add_subdirectory(libcpuid) + add_subdirectory(cpuid_tool) +-add_subdirectory(tests) +--- a/cpuid_tool/CMakeLists.txt ++++ b/cpuid_tool/CMakeLists.txt +@@ -2,7 +2,7 @@ add_executable(cpuid_tool cpuid_tool.c) - # Global variables --set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -- -+set(PROJECT_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake") -+list(APPEND MAKE_MODULE_PATH "${PROJECT_CMAKE_DIR}/cmake") - if(UNIX) - include(GNUInstallDirs) - set(prefix "${CMAKE_INSTALL_PREFIX}") ---- libcpuid/CMakeLists.txt -+++ libcpuid/CMakeLists.txt -@@ -13,7 +13,7 @@ + target_link_libraries(cpuid_tool cpuid) + +-if(WIN32) ++if(0) + install( + TARGETS cpuid_tool + CONFIGURATIONS Debug +@@ -12,5 +12,5 @@ if(WIN32) + CONFIGURATIONS Release + RUNTIME DESTINATION bin/Release) + else() +- install(TARGETS cpuid_tool RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++ install(TARGETS cpuid_tool DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() +--- a/libcpuid/CMakeLists.txt ++++ b/libcpuid/CMakeLists.txt +@@ -13,7 +13,7 @@ if("${MSVC_CXX_ARCHITECTURE_ID}" MATCHES "x64") endif() if(UNIX) @@ -27,18 +39,7 @@ # Configure 'Config.cmake' Use variables: * TARGETS_EXPORT_NAME * PROJECT_NAME -configure_package_config_file("${CMAKE_MODULE_PATH}/Config.cmake.in" "${project_config}" -+configure_package_config_file("${PROJECT_CMAKE_DIR}/Config.cmake.in" "${project_config}" ++configure_package_config_file("${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in" "${project_config}" INSTALL_DESTINATION "${config_install_dir}") # Installation ---- cpuid_tool/CMakeLists.txt -+++ cpuid_tool/CMakeLists.txt -@@ -2,7 +2,7 @@ - - target_link_libraries(cpuid_tool cpuid) - --if(WIN32) -+if(0) - install( - TARGETS cpuid_tool - CONFIGURATIONS Debug diff --git a/recipes/libcpuid/all/test_package/conanfile.py b/recipes/libcpuid/all/test_package/conanfile.py index 2d8b6a9e253dc..a2a865893b40b 100644 --- a/recipes/libcpuid/all/test_package/conanfile.py +++ b/recipes/libcpuid/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -12,7 +12,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libcuckoo/all/conandata.yml b/recipes/libcuckoo/all/conandata.yml new file mode 100644 index 0000000000000..499f61880ad61 --- /dev/null +++ b/recipes/libcuckoo/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "0.3.1": + sha256: "a87122b963ef6b7eadca3e41cb4b533f3b6ad9b588ab2f2140eb6ab0db9a7ba8" + url: "https://github.com/efficient/libcuckoo/archive/refs/tags/v0.3.1.tar.gz" + "0.3.0": + sha256: "b91b77c49577059cd47b258e783f60d5b07dccc5e47258fea00cdedffd84afbe" + url: "https://github.com/efficient/libcuckoo/archive/refs/tags/v0.3.tar.gz" diff --git a/recipes/libcuckoo/all/conanfile.py b/recipes/libcuckoo/all/conanfile.py new file mode 100644 index 0000000000000..3f070f7ebb3fc --- /dev/null +++ b/recipes/libcuckoo/all/conanfile.py @@ -0,0 +1,56 @@ +import os +from conans import CMake, ConanFile, tools + +required_conan_version = ">=1.33.0" + + +class LibCuckooConan(ConanFile): + name = "libcuckoo" + description = "A high-performance, concurrent hash table" + license = "Apache-2.0" + homepage = "https://github.com/efficient/libcuckoo" + url = "https://github.com/conan-io/conan-center-index" + topics = ("concurrency", "hashmap", "header-only", "library", "cuckoo") + settings = "arch", "build_type", "compiler", "os" + generators = "cmake", "cmake_find_package_multi" + no_copy_source = True + + @property + def _minimum_cpp_standard(self): + return 11 + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + tools.check_min_cppstd(self, self._minimum_cpp_standard) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def package(self): + # Install with CMake + cmake = CMake(self) + cmake.definitions["BUILD_EXAMPLES"] = "OFF" + cmake.definitions["BUILD_STRESS_TESTS"] = "OFF" + cmake.definitions["BUILD_TESTS"] = "OFF" + cmake.definitions["BUILD_UNIT_TESTS"] = "OFF" + cmake.definitions["BUILD_UNIVERSAL_BENCHMARK"] = "OFF" + cmake.configure(source_folder=self._source_subfolder) + cmake.install() + # Copy license files + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + # Remove CMake config files (only files in share) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_id(self): + self.info.header_only() + + def package_info(self): + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["pthread"] + self.cpp_info.names["cmake_find_package"] = "libcuckoo" + self.cpp_info.names["cmake_find_package_multi"] = "libcuckoo" diff --git a/recipes/libcuckoo/all/test_package/CMakeLists.txt b/recipes/libcuckoo/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5bea3f6fd86e4 --- /dev/null +++ b/recipes/libcuckoo/all/test_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +set(CMAKE_CXX_STANDARD 11) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libcuckoo REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libcuckoo::libcuckoo) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_${CMAKE_CXX_STANDARD}) diff --git a/recipes/libcuckoo/all/test_package/conanfile.py b/recipes/libcuckoo/all/test_package/conanfile.py new file mode 100644 index 0000000000000..22583ef52742a --- /dev/null +++ b/recipes/libcuckoo/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run("{0}".format(bin_path), run_environment=True) diff --git a/recipes/libcuckoo/all/test_package/test_package.cpp b/recipes/libcuckoo/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..8df18dd175648 --- /dev/null +++ b/recipes/libcuckoo/all/test_package/test_package.cpp @@ -0,0 +1,22 @@ +#include +#include + +#include + +int main() { + libcuckoo::cuckoohash_map Table; + + for (int i = 0; i < 10; i++) { + Table.insert(i, "found"); + } + + std::string out; + for (int i = 0; i < 11; i++) { + + if (Table.find(i, out)) { + std::cout << i << " " << out << '\n'; + } else { + std::cout << i << " NOT FOUND\n"; + } + } +} diff --git a/recipes/libcuckoo/config.yml b/recipes/libcuckoo/config.yml new file mode 100644 index 0000000000000..f9de643fda854 --- /dev/null +++ b/recipes/libcuckoo/config.yml @@ -0,0 +1,5 @@ +versions: + "0.3.1": + folder: all + "0.3.0": + folder: all diff --git a/recipes/libcurl/all/CMakeLists.txt b/recipes/libcurl/all/CMakeLists.txt deleted file mode 100644 index 8658c4251a78c..0000000000000 --- a/recipes/libcurl/all/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.0) - -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libcurl/all/conandata.yml b/recipes/libcurl/all/conandata.yml index 1222352e285fe..65ff7d7373b90 100644 --- a/recipes/libcurl/all/conandata.yml +++ b/recipes/libcurl/all/conandata.yml @@ -1,50 +1,36 @@ sources: - "7.75.0": - sha256: 4d51346fe621624c3e4b9f86a8fd6f122a143820e17889f59c18f245d2d8e7a6 - url: https://curl.haxx.se/download/curl-7.75.0.tar.gz - "7.74.0": - sha256: e56b3921eeb7a2951959c02db0912b5fcd5fdba5aca071da819e1accf338bbd7 - url: https://curl.haxx.se/download/curl-7.74.0.tar.gz - "7.73.0": - sha256: ba98332752257b47b9dea6d8c0ad25ec1745c20424f1dd3ff2c99ab59e97cf91 - url: https://curl.haxx.se/download/curl-7.73.0.tar.gz - "7.72.0": - sha256: d4d5899a3868fbb6ae1856c3e55a32ce35913de3956d1973caccd37bd0174fa2 - url: https://curl.haxx.se/download/curl-7.72.0.tar.gz - "7.71.1": - sha256: 59ef1f73070de67b87032c72ee6037cedae71dcb1d7ef2d7f59487704aec069d - url: https://curl.haxx.se/download/curl-7.71.1.tar.gz - "7.71.0": - sha256: 62b2b1acee40c4de5a4913e27a4b4194813cf2b7815b73febec7ae53054646ca - url: https://curl.haxx.se/download/curl-7.71.0.tar.gz - "7.70.0": - sha256: ca2feeb8ef13368ce5d5e5849a5fd5e2dd4755fecf7d8f0cc94000a4206fb8e7 - url: https://curl.haxx.se/download/curl-7.70.0.tar.gz - "7.69.1": - sha256: 01ae0c123dee45b01bbaef94c0bc00ed2aec89cb2ee0fd598e0d302a6b5e0a98 - url: https://curl.haxx.se/download/curl-7.69.1.tar.gz - "7.68.0": - sha256: 1dd7604e418b0b9a9077f62f763f6684c1b092a7bc17e3f354b8ad5c964d7358 - url: https://curl.haxx.se/download/curl-7.68.0.tar.gz - "7.67.0": - sha256: 52af3361cf806330b88b4fe6f483b6844209d47ae196ac46da4de59bb361ab02 - url: https://curl.haxx.se/download/curl-7.67.0.tar.gz - "7.66.0": - sha256: d0393da38ac74ffac67313072d7fe75b1fa1010eb5987f63f349b024a36b7ffb - url: https://curl.haxx.se/download/curl-7.66.0.tar.gz - "7.64.1": - sha256: 432d3f466644b9416bc5b649d344116a753aeaa520c8beaf024a90cba9d3d35d - url: https://curl.haxx.se/download/curl-7.64.1.tar.gz + "7.86.0": + url: "https://curl.se/download/curl-7.86.0.tar.gz" + sha256: "3dfdd39ba95e18847965cd3051ea6d22586609d9011d91df7bc5521288987a82" + "7.85.0": + url: "https://curl.se/download/curl-7.85.0.tar.gz" + sha256: "78a06f918bd5fde3c4573ef4f9806f56372b32ec1829c9ec474799eeee641c27" + "7.84.0": + url: "https://curl.se/download/curl-7.84.0.tar.gz" + sha256: "3c6893d38d054d4e378267166858698899e9d87258e8ff1419d020c395384535" + "7.83.1": + url: "https://curl.se/download/curl-7.83.1.tar.gz" + sha256: "93fb2cd4b880656b4e8589c912a9fd092750166d555166370247f09d18f5d0c0" + "7.82.0": + url: "https://curl.se/download/curl-7.82.0.tar.gz" + sha256: "910cc5fe279dc36e2cca534172c94364cf3fcf7d6494ba56e6c61a390881ddce" + "7.80.0": + url: "https://curl.se/download/curl-7.80.0.tar.gz" + sha256: "dab997c9b08cb4a636a03f2f7f985eaba33279c1c52692430018fae4a4878dc7" + "7.79.1": + url: "https://curl.se/download/curl-7.79.1.tar.gz" + sha256: "370b11201349816287fb0ccc995e420277fbfcaf76206e309b3f60f0eda090c2" + "7.78.0": + url: "https://curl.se/download/curl-7.78.0.tar.gz" + sha256: "ed936c0b02c06d42cf84b39dd12bb14b62d77c7c4e875ade022280df5dcc81d7" + "7.77.0": + url: "https://curl.se/download/curl-7.77.0.tar.gz" + sha256: "b0a3428acb60fa59044c4d0baae4e4fc09ae9af1d8a3aa84b2e3fbcd99841f77" + "7.76.0": + url: "https://curl.se/download/curl-7.76.0.tar.gz" + sha256: "3b4378156ba09e224008e81dcce854b7ce4d182b1f9cfb97fe5ed9e9c18c6bd3" patches: - "7.72.0": - - patch_file: "patches/002-add-missing-file-FindZstd.patch" - base_path: "source_subfolder" - "7.67.0": - - patch_file: "patches/001-Update-FindLibSSH2.cmake-add-libssh2-as-possible-nam.patch" - base_path: "source_subfolder" - "7.66.0": - - patch_file: "patches/001-Update-FindLibSSH2.cmake-add-libssh2-as-possible-nam.patch" - base_path: "source_subfolder" - "7.64.1": - - patch_file: "patches/001-Update-FindLibSSH2.cmake-add-libssh2-as-possible-nam.patch" - base_path: "source_subfolder" + "7.79.0": + - patch_file: "patches/004-no-checksrc.patch" + patch_description: "don't run checksrc" + patch_type: "conan" diff --git a/recipes/libcurl/all/conanfile.py b/recipes/libcurl/all/conanfile.py index ff941d840fcc5..dd2fe94b93cc0 100644 --- a/recipes/libcurl/all/conanfile.py +++ b/recipes/libcurl/all/conanfile.py @@ -1,33 +1,49 @@ -import glob +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os, fix_apple_shared_install_name +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import apply_conandata_patches, copy, download, export_conandata_patches, get, load, replace_in_file, rm, rmdir, save +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version + import os import re -from conans import ConanFile, AutoToolsBuildEnvironment, CMake, tools -from conans.errors import ConanInvalidConfiguration -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.53.0" class LibcurlConan(ConanFile): name = "libcurl" - description = "command line tool and library for transferring data with URLs" - topics = ("conan", "curl", "libcurl", "data-transfer") + license = "curl" url = "https://github.com/conan-io/conan-center-index" - homepage = "https://curl.haxx.se" - license = "MIT" - exports_sources = ["lib_Makefile_add.am", "CMakeLists.txt", "patches/*"] - generators = "cmake", "cmake_find_package_multi", "pkg_config" - + homepage = "https://curl.se" + topics = ("curl", "data-transfer", + "ftp", "gopher", "http", "imap", "ldap", "mqtt", "pop3", "rtmp", "rtsp", + "scp", "sftp", "smb", "smtp", "telnet", "tftp") settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "with_ssl": [False, "openssl", "wolfssl", "schannel", "darwinssl"], - "with_openssl": [True, False, "deprecated"], - "with_wolfssl": [True, False, "deprecated"], - "with_winssl": [True, False, "deprecated"], - "darwin_ssl": [True, False, "deprecated"], + "with_file": [True, False], + "with_ftp": [True, False], + "with_http": [True, False], "with_ldap": [True, False], + "with_rtsp": [True, False], + "with_dict": [True, False], + "with_telnet": [True, False], + "with_tftp": [True, False], + "with_pop3": [True, False], + "with_imap": [True, False], + "with_smb": [True, False], + "with_smtp": [True, False], + "with_gopher": [True, False], + "with_mqtt": [True, False], "with_libssh2": [True, False], "with_libidn": [True, False], "with_librtmp": [True, False], @@ -39,16 +55,39 @@ class LibcurlConan(ConanFile): "with_brotli": [True, False], "with_zstd": [True, False], "with_c_ares": [True, False], + "with_threaded_resolver": [True, False], + "with_proxy": [True, False], + "with_crypto_auth": [True, False], + "with_ntlm": [True, False], + "with_ntlm_wb": [True, False], + "with_cookies": [True, False], + "with_ipv6": [True, False], + "with_docs": [True, False], + "with_verbose_debug": [True, False], + "with_symbol_hiding": [True, False], + "with_unix_sockets": [True, False], + "with_verbose_strings": [True, False], + "with_ca_bundle": [False, "auto", "ANY"], + "with_ca_path": [False, "auto", "ANY"], } default_options = { "shared": False, "fPIC": True, "with_ssl": "openssl", - "with_openssl": "deprecated", - "with_wolfssl": "deprecated", - "with_winssl": "deprecated", - "darwin_ssl": "deprecated", + "with_dict": True, + "with_file": True, + "with_ftp": True, + "with_gopher": True, + "with_http": True, + "with_imap": True, "with_ldap": False, + "with_mqtt": True, + "with_pop3": True, + "with_rtsp": True, + "with_smb": True, + "with_smtp": True, + "with_telnet": True, + "with_tftp": True, "with_libssh2": False, "with_libidn": False, "with_librtmp": False, @@ -60,156 +99,158 @@ class LibcurlConan(ConanFile): "with_brotli": False, "with_zstd": False, "with_c_ares": False, + "with_threaded_resolver": True, + "with_proxy": True, + "with_crypto_auth": True, + "with_ntlm": True, + "with_ntlm_wb": True, + "with_cookies": True, + "with_ipv6": True, + "with_docs": False, + "with_verbose_debug": True, + "with_symbol_hiding": False, + "with_unix_sockets": True, + "with_verbose_strings": True, + "with_ca_bundle": "auto", + "with_ca_path": "auto", } - _autotools = None - _autotools_vars = None - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - @property - def _build_subfolder(self): - return "build_subfolder" + def _is_mingw(self): + return self.settings.os == "Windows" and self.settings.compiler == "gcc" @property - def _is_mingw(self): - return self.settings.os == "Windows" and self.settings.compiler != "Visual Studio" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) @property def _is_win_x_android(self): - return self.settings.os == "Android" and tools.os_info.is_windows + return self.settings.os == "Android" and self._settings_build.os == "Windows" @property def _is_using_cmake_build(self): - return self.settings.compiler == "Visual Studio" or self._is_win_x_android + return is_msvc(self) or self._is_win_x_android @property def _has_zstd_option(self): - return tools.Version(self.version) >= "7.72.0" + return Version(self.version) >= "7.72.0" + + @property + def _has_metalink_option(self): + # Support for metalink was removed in version 7.78.0 https://github.com/curl/curl/pull/7176 + return Version(self.version) < "7.78.0" and not self._is_using_cmake_build + + def export_sources(self): + copy(self, "lib_Makefile_add.am", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) def config_options(self): + if Version(self.version) < "7.10.4": + self.license = "MIT" if self.settings.os == "Windows": del self.options.fPIC if not self._has_zstd_option: del self.options.with_zstd + if not self._has_metalink_option: + del self.options.with_libmetalink # Default options - self.options.with_ssl = "darwinssl" if tools.is_apple_os(self.settings.os) else "openssl" + self.options.with_ssl = "darwinssl" if is_apple_os(self) else "openssl" def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - - # Deprecated options - # =============================== - if (any(deprecated_option != "deprecated" for deprecated_option in [self.options.with_openssl, self.options.with_wolfssl, self.options.with_winssl, self.options.darwin_ssl])): - self.output.warn("with_openssl, with_winssl, darwin_ssl and with_wolfssl options are deprecated. Use with_ssl option instead.") - if tools.is_apple_os(self.settings.os) and self.options.with_ssl == "darwinssl": - if self.options.darwin_ssl == True: - self.options.with_ssl = "darwinssl" - elif self.options.with_openssl == True: - self.options.with_ssl = "openssl" - elif self.options.with_wolfssl == True: - self.options.with_ssl = "wolfssl" - else: - self.options.with_ssl = False - if not tools.is_apple_os(self.settings.os) and self.options.with_ssl == "openssl": - if self.settings.os == "Windows" and self.options.with_winssl == True: - self.options.with_ssl = "schannel" - elif self.options.with_openssl == True: - self.options.with_ssl = "openssl" - elif self.options.with_wolfssl == True: - self.options.with_ssl = "wolfssl" - else: - self.options.with_ssl = False - # =============================== - - if self.options.with_ssl == "schannel" and self.settings.os != "Windows": - raise ConanInvalidConfiguration("schannel only suppported on Windows.") - if self.options.with_ssl == "darwinssl" and not tools.is_apple_os(self.settings.os): - raise ConanInvalidConfiguration("darwinssl only suppported on Apple like OS (Macos, iOS, watchOS or tvOS).") - if self.options.with_ssl == "wolfssl" and self._is_using_cmake_build and tools.Version(self.version) < "7.70.0": - raise ConanInvalidConfiguration("Before 7.70.0, libcurl has no wolfssl support for Visual Studio or \"Windows to Android cross compilation\"") + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") # These options are not used in CMake build yet if self._is_using_cmake_build: - del self.options.with_libidn - del self.options.with_librtmp - del self.options.with_libmetalink + if Version(self.version) < "7.75.0": + del self.options.with_libidn del self.options.with_libpsl def requirements(self): if self.options.with_ssl == "openssl": - self.requires("openssl/1.1.1k") + self.requires("openssl/1.1.1s") elif self.options.with_ssl == "wolfssl": - self.requires("wolfssl/4.6.0") + self.requires("wolfssl/5.5.1") if self.options.with_nghttp2: - self.requires("libnghttp2/1.43.0") + self.requires("libnghttp2/1.50.0") if self.options.with_libssh2: - self.requires("libssh2/1.9.0") + self.requires("libssh2/1.10.0") if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.with_brotli: self.requires("brotli/1.0.9") if self.options.get_safe("with_zstd"): - self.requires("zstd/1.4.9") + self.requires("zstd/1.5.2") if self.options.with_c_ares: - self.requires("c-ares/1.17.1") + self.requires("c-ares/1.18.1") - def package_id(self): - # Deprecated options - del self.info.options.with_openssl - del self.info.options.with_winssl - del self.info.options.darwin_ssl - del self.info.options.with_wolfssl + def validate(self): + if self.info.options.with_ssl == "schannel" and self.info.settings.os != "Windows": + raise ConanInvalidConfiguration("schannel only suppported on Windows.") + if self.info.options.with_ssl == "darwinssl" and not is_apple_os(self): + raise ConanInvalidConfiguration("darwinssl only suppported on Apple like OS (Macos, iOS, watchOS or tvOS).") + if self.info.options.with_ssl == "wolfssl" and self._is_using_cmake_build and Version(self.version) < "7.70.0": + raise ConanInvalidConfiguration("Before 7.70.0, libcurl has no wolfssl support for Visual Studio or \"Windows to Android cross compilation\"") + if self.info.options.with_ssl == "openssl": + openssl = self.dependencies["openssl"] + if self.info.options.with_ntlm and openssl.options.no_des: + raise ConanInvalidConfiguration("option with_ntlm=True requires openssl:no_des=False") def build_requirements(self): if self._is_using_cmake_build: if self._is_win_x_android: - self.build_requires("ninja/1.10.2") + self.tool_requires("ninja/1.11.1") + else: + self.tool_requires("libtool/2.4.7") + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/1.9.3") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def layout(self): + if self._is_using_cmake_build: + cmake_layout(self, src_folder="src") else: - self.build_requires("libtool/2.4.6") - self.build_requires("pkgconf/1.7.3") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - tools.download("https://curl.haxx.se/ca/cacert.pem", "cacert.pem", verify=True) - - def imports(self): - # Copy shared libraries for dependencies to fix DYLD_LIBRARY_PATH problems - # - # Configure script creates conftest that cannot execute without shared openssl binaries. - # Ways to solve the problem: - # 1. set *LD_LIBRARY_PATH (works with Linux with RunEnvironment - # but does not work on OS X 10.11 with SIP) - # 2. copying dylib's to the build directory (fortunately works on OS X) - if self.settings.os == "Macos": - self.copy("*.dylib*", dst=self._source_subfolder, keep_path=False) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + download(self, "https://curl.haxx.se/ca/cacert.pem", "cacert.pem", verify=True, sha256="2cff03f9efdaf52626bd1b451d700605dc1ea000c5da56bd0fc59f8f43071040") + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + if self._is_using_cmake_build: + self._generate_with_cmake() + else: + self._generate_with_autotools() def build(self): self._patch_sources() if self._is_using_cmake_build: - self._build_with_cmake() + cmake = CMake(self) + cmake.configure() + cmake.build() else: - self._build_with_autotools() + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() + autotools.make() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) self._patch_misc_files() - self._patch_mingw_files() + self._patch_autotools() self._patch_cmake() def _patch_misc_files(self): if self.options.with_largemaxwritesize: - tools.replace_in_file(os.path.join(self._source_subfolder, "include", "curl", "curl.h"), + replace_in_file(self, os.path.join(self.source_folder, "include", "curl", "curl.h"), "define CURL_MAX_WRITE_SIZE 16384", "define CURL_MAX_WRITE_SIZE 10485760") @@ -217,113 +258,239 @@ def _patch_misc_files(self): # for additional info, see this comment https://github.com/conan-io/conan-center-index/pull/1008#discussion_r386122685 if self.settings.compiler == "apple-clang" and self.settings.compiler.version == "9.1": if self.options.with_ssl == "darwinssl": - tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "vtls", "sectransp.c"), + replace_in_file(self, os.path.join(self.source_folder, "lib", "vtls", "sectransp.c"), "#define CURL_BUILD_MAC_10_13 MAC_OS_X_VERSION_MAX_ALLOWED >= 101300", "#define CURL_BUILD_MAC_10_13 0") - def _patch_mingw_files(self): - if not self._is_mingw: + def _patch_autotools(self): + if self._is_using_cmake_build: return - # patch for zlib naming in mingw + + # Disable curl tool for these reasons: + # - link errors if mingw shared or iOS/tvOS/watchOS + # - it makes recipe consistent with CMake build where we don't build curl tool + top_makefile = os.path.join(self.source_folder, "Makefile.am") + replace_in_file(self, top_makefile, "SUBDIRS = lib src", "SUBDIRS = lib") + replace_in_file(self, top_makefile, "include src/Makefile.inc", "") + + # zlib naming is not always very consistent if self.options.with_zlib: - configure_ac = os.path.join(self._source_subfolder, "configure.ac") - zlib_name = self.deps_cpp_info["zlib"].libs[0] - tools.replace_in_file(configure_ac, + configure_ac = os.path.join(self.source_folder, "configure.ac") + zlib_name = self.dependencies["zlib"].cpp_info.libs[0] + replace_in_file(self, configure_ac, "AC_CHECK_LIB(z,", - "AC_CHECK_LIB({},".format(zlib_name)) - tools.replace_in_file(configure_ac, + f"AC_CHECK_LIB({zlib_name},") + replace_in_file(self, configure_ac, "-lz ", - "-l{} ".format(zlib_name)) + f"-l{zlib_name} ") - if self.options.shared: - # for mingw builds - do not compile curl tool, just library - # linking errors are much harder to fix than to exclude curl tool - top_makefile = os.path.join(self._source_subfolder, "Makefile.am") - tools.replace_in_file(top_makefile, "SUBDIRS = lib src", "SUBDIRS = lib") - tools.replace_in_file(top_makefile, "include src/Makefile.inc", "") + if self._is_mingw and self.options.shared: # patch for shared mingw build - lib_makefile = os.path.join(self._source_subfolder, "lib", "Makefile.am") - tools.replace_in_file(lib_makefile, + lib_makefile = os.path.join(self.source_folder, "lib", "Makefile.am") + replace_in_file(self, lib_makefile, "noinst_LTLIBRARIES = libcurlu.la", "") - tools.replace_in_file(lib_makefile, + replace_in_file(self, lib_makefile, "noinst_LTLIBRARIES =", "") - tools.replace_in_file(lib_makefile, + replace_in_file(self, lib_makefile, "lib_LTLIBRARIES = libcurl.la", "noinst_LTLIBRARIES = libcurl.la") # add directives to build dll # used only for native mingw-make - if not tools.cross_building(self.settings): - added_content = tools.load("lib_Makefile_add.am") - tools.save(lib_makefile, added_content, append=True) + if not cross_building(self): + added_content = load(self, "lib_Makefile_add.am") + save(self, lib_makefile, added_content, append=True) def _patch_cmake(self): if not self._is_using_cmake_build: return + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") # Custom findZstd.cmake file relies on pkg-config file, make sure that it's consumed on all platforms if self._has_zstd_option: - tools.replace_in_file(os.path.join(self._source_subfolder, "CMake", "FindZstd.cmake"), + replace_in_file(self, os.path.join(self.source_folder, "CMake", "FindZstd.cmake"), "if(UNIX)", "if(TRUE)") # TODO: check this patch, it's suspicious - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + replace_in_file(self, cmakelists, "include(CurlSymbolHiding)", "") - def _get_configure_command_args(self): - yes_no = lambda v: "yes" if v else "no" - params = [ - "--with-libidn2={}".format(yes_no(self.options.with_libidn)), - "--with-librtmp={}".format(yes_no(self.options.with_librtmp)), - "--with-libmetalink={}".format(yes_no(self.options.with_libmetalink)), - "--with-libpsl={}".format(yes_no(self.options.with_libpsl)), - "--with-schannel={}".format(yes_no(self.options.with_ssl == "schannel")), - "--with-secure-transport={}".format(yes_no(self.options.with_ssl == "darwinssl")), - "--with-brotli={}".format(yes_no(self.options.with_brotli)), - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), - "--enable-ldap={}".format(yes_no(self.options.with_ldap)), - "--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")), - "--enable-ares={}".format(yes_no(self.options.with_c_ares)), - "--enable-threaded-resolver={}".format(yes_no(self.options.with_c_ares)), - ] + # libnghttp2 + replace_in_file(self, + cmakelists, + "find_package(NGHTTP2 REQUIRED)", + "find_package(libnghttp2 REQUIRED)", + ) + replace_in_file(self, + cmakelists, + "include_directories(${NGHTTP2_INCLUDE_DIRS})", + "", + ) + replace_in_file(self, + cmakelists, + "list(APPEND CURL_LIBS ${NGHTTP2_LIBRARIES})", + "list(APPEND CURL_LIBS libnghttp2::nghttp2)", + ) + + # INTERFACE_LIBRARY (generated by the cmake_find_package generator) targets doesn't have the LOCATION property. + # So skipp the LOCATION check in the CMakeLists.txt + if Version(self.version) >= "7.80.0": + replace_in_file(self, + cmakelists, + 'get_target_property(_lib "${_libname}" LOCATION)', + """get_target_property(_type "${_libname}" TYPE) + if(${_type} STREQUAL "INTERFACE_LIBRARY") + # Reading the INTERFACE_LIBRARY property on non-imported target will error out. + continue() + endif() + get_target_property(_lib "${_libname}" LOCATION)""", + ) + + def _yes_no(self, value): + return "yes" if value else "no" + + def _generate_with_autotools(self): + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") + + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ + f"--with-libidn2={self._yes_no(self.options.with_libidn)}", + f"--with-librtmp={self._yes_no(self.options.with_librtmp)}", + f"--with-libpsl={self._yes_no(self.options.with_libpsl)}", + f"--with-schannel={self._yes_no(self.options.with_ssl == 'schannel')}", + f"--with-secure-transport={self._yes_no(self.options.with_ssl == 'darwinssl')}", + f"--with-brotli={self._yes_no(self.options.with_brotli)}", + f"--enable-shared={self._yes_no(self.options.shared)}", + f"--enable-static={self._yes_no(not self.options.shared)}", + f"--enable-dict={self._yes_no(self.options.with_dict)}", + f"--enable-file={self._yes_no(self.options.with_file)}", + f"--enable-ftp={self._yes_no(self.options.with_ftp)}", + f"--enable-gopher={self._yes_no(self.options.with_gopher)}", + f"--enable-http={self._yes_no(self.options.with_http)}", + f"--enable-imap={self._yes_no(self.options.with_imap)}", + f"--enable-ldap={self._yes_no(self.options.with_ldap)}", + f"--enable-mqtt={self._yes_no(self.options.with_mqtt)}", + f"--enable-pop3={self._yes_no(self.options.with_pop3)}", + f"--enable-rtsp={self._yes_no(self.options.with_rtsp)}", + f"--enable-smb={self._yes_no(self.options.with_smb)}", + f"--enable-smtp={self._yes_no(self.options.with_smtp)}", + f"--enable-telnet={self._yes_no(self.options.with_telnet)}", + f"--enable-tftp={self._yes_no(self.options.with_tftp)}", + f"--enable-debug={self._yes_no(self.settings.build_type == 'Debug')}", + f"--enable-ares={self._yes_no(self.options.with_c_ares)}", + f"--enable-threaded-resolver={self._yes_no(self.options.with_threaded_resolver)}", + f"--enable-cookies={self._yes_no(self.options.with_cookies)}", + f"--enable-ipv6={self._yes_no(self.options.with_ipv6)}", + f"--enable-manual={self._yes_no(self.options.with_docs)}", + f"--enable-verbose={self._yes_no(self.options.with_verbose_debug)}", + f"--enable-symbol-hiding={self._yes_no(self.options.with_symbol_hiding)}", + f"--enable-unix-sockets={self._yes_no(self.options.with_unix_sockets)}", + ]) + + # Since 7.77.0, disabling TLS must be explicitly requested otherwise it fails + if Version(self.version) >= "7.77.0" and not self.options.with_ssl: + tc.configure_args.append("--without-ssl") + + openssl_option = "ssl" if Version(self.version) < "7.77.0" else "openssl" if self.options.with_ssl == "openssl": - params.append("--with-ssl={}".format(tools.unix_path(self.deps_cpp_info["openssl"].rootpath))) + path = unix_path(self, self.dependencies["openssl"].package_folder) + tc.configure_args.append(f"--with-{openssl_option}={path}") else: - params.append("--without-ssl") + tc.configure_args.append(f"--without-{openssl_option}") + if self.options.with_ssl == "wolfssl": - params.append("--with-wolfssl={}".format(tools.unix_path(self.deps_cpp_info["wolfssl"].rootpath))) + path = unix_path(self, self.dependencies["wolfssl"].package_folder) + tc.configure_args.append(f"--with-wolfssl={path}") else: - params.append("--without-wolfssl") + tc.configure_args.append("--without-wolfssl") if self.options.with_libssh2: - params.append("--with-libssh2={}".format(tools.unix_path(self.deps_cpp_info["libssh2"].rootpath))) + path = unix_path(self, self.dependencies["libssh2"].package_folder) + tc.configure_args.append(f"--with-libssh2={path}") else: - params.append("--without-libssh2") + tc.configure_args.append("--without-libssh2") if self.options.with_nghttp2: - params.append("--with-nghttp2={}".format(tools.unix_path(self.deps_cpp_info["libnghttp2"].rootpath))) + path = unix_path(self, self.dependencies["libnghttp2"].package_folder) + tc.configure_args.append(f"--with-nghttp2={path}") else: - params.append("--without-nghttp2") + tc.configure_args.append("--without-nghttp2") if self.options.with_zlib: - params.append("--with-zlib={}".format(tools.unix_path(self.deps_cpp_info["zlib"].rootpath))) + path = unix_path(self, self.dependencies["zlib"].package_folder) + tc.configure_args.append(f"--with-zlib={path}") else: - params.append("--without-zlib") + tc.configure_args.append("--without-zlib") if self._has_zstd_option: - params.append("--with-zstd={}".format(yes_no(self.options.with_zstd))) + tc.configure_args.append(f"--with-zstd={self._yes_no(self.options.with_zstd)}") + + if self._has_metalink_option: + tc.configure_args.append(f"--with-libmetalink={self._yes_no(self.options.with_libmetalink)}") + + if not self.options.with_proxy: + tc.configure_args.append("--disable-proxy") + + if not self.options.with_rtsp: + tc.configure_args.append("--disable-rtsp") + + if not self.options.with_crypto_auth: + tc.configure_args.append("--disable-crypto-auth") # also disables NTLM in versions of curl prior to 7.78.0 + + # ntlm will default to enabled if any SSL options are enabled + if not self.options.with_ntlm: + if Version(self.version) <= "7.77.0": + tc.configure_args.append("--disable-crypto-auth") + else: + tc.configure_args.append("--disable-ntlm") + + if not self.options.with_ntlm_wb: + tc.configure_args.append("--disable-ntlm-wb") + + if not self.options.with_ca_bundle: + tc.configure_args.append("--without-ca-bundle") + elif self.options.with_ca_bundle != "auto": + tc.configure_args.append(f"--with-ca-bundle={str(self.options.with_ca_bundle)}") + + if not self.options.with_ca_path: + tc.configure_args.append("--without-ca-path") + elif self.options.with_ca_path != "auto": + tc.configure_args.append(f"--with-ca-path={str(self.options.with_ca_path)}") # Cross building flags - if tools.cross_building(self.settings): + if cross_building(self): if self.settings.os == "Linux" and "arm" in self.settings.arch: - params.append("--host=%s" % self._get_linux_arm_host()) + tc.configure_args.append(f"--host={self._get_linux_arm_host()}") elif self.settings.os == "iOS": - params.append("--enable-threaded-resolver") - params.append("--disable-verbose") + tc.configure_args.append("--enable-threaded-resolver") + tc.configure_args.append("--disable-verbose") elif self.settings.os == "Android": pass # this just works, conan is great! - return params + # tweaks for mingw + if self._is_mingw: + rcflags = "-O COFF" + if self.settings.arch == "x86": + rcflags += " --target=pe-i386" + elif self.settings.arch == "x86_64": + rcflags += " --target=pe-x86-64" + tc.extra_defines.append("_AMD64_") + env = tc.environment() + env.define("RCFLAGS", rcflags) + + if self.settings.os != "Windows": + tc.fpic = self.options.get_safe("fPIC", True) + + + if cross_building(self) and is_apple_os(self): + tc.extra_defines.extend(['HAVE_SOCKET', 'HAVE_FCNTL_O_NONBLOCK']) + + tc.generate() + tc = PkgConfigDeps(self) + tc.generate() + tc = AutotoolsDeps(self) + tc.generate() def _get_linux_arm_host(self): arch = None @@ -347,137 +514,110 @@ def _arm_version(self, arch): version = int(match.group(1)) return version - def _build_with_autotools(self): - with tools.chdir(self._source_subfolder): - # autoreconf - self.run("{} -fiv".format(tools.get_env("AUTORECONF") or "autoreconf"), win_bash=tools.os_info.is_windows, run_environment=True) - - # fix generated autotools files on alle to have relocateable binaries - if tools.is_apple_os(self.settings.os): - tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name ") - - self.run("chmod +x configure") - - # run configure with *LD_LIBRARY_PATH env vars it allows to pick up shared openssl - with tools.run_environment(self): - autotools, autotools_vars = self._configure_autotools() - autotools.make(vars=autotools_vars) - - def _configure_autotools_vars(self): - autotools_vars = self._autotools.vars - # tweaks for mingw - if self._is_mingw: - autotools_vars["RCFLAGS"] = "-O COFF" - if self.settings.arch == "x86": - autotools_vars["RCFLAGS"] += " --target=pe-i386" - else: - autotools_vars["RCFLAGS"] += " --target=pe-x86-64" - return autotools_vars - - def _configure_autotools(self): - if self._autotools and self._autotools_vars: - return self._autotools, self._autotools_vars - - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - - if self.settings.os != "Windows": - self._autotools.fpic = self.options.get_safe("fPIC", True) - - self._autotools_vars = self._configure_autotools_vars() - - # tweaks for mingw - if self._is_mingw: - self._autotools.defines.append("_AMD64_") - - if tools.cross_building(self) and tools.is_apple_os(self.settings.os): - self._autotools.defines.extend(['HAVE_SOCKET', 'HAVE_FCNTL_O_NONBLOCK']) - - configure_args = self._get_configure_command_args() - - if self.settings.os == "iOS" and self.settings.arch == "x86_64": - # please do not autodetect --build for the iOS simulator, thanks! - self._autotools.configure(vars=self._autotools_vars, args=configure_args, build=False) - else: - self._autotools.configure(vars=self._autotools_vars, args=configure_args) - - return self._autotools, self._autotools_vars - - def _configure_cmake(self): - if self._cmake: - return self._cmake + def _generate_with_cmake(self): if self._is_win_x_android: - self._cmake = CMake(self, generator="Ninja") + tc = CMakeToolchain(self, generator="Ninja") + else: + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.variables["BUILD_CURL_EXE"] = False + tc.variables["CURL_DISABLE_LDAP"] = not self.options.with_ldap + tc.variables["BUILD_SHARED_LIBS"] = self.options.shared + tc.variables["CURL_STATICLIB"] = not self.options.shared + tc.variables["CMAKE_DEBUG_POSTFIX"] = "" + if Version(self.version) >= "7.81.0": + tc.variables["CURL_USE_SCHANNEL"] = self.options.with_ssl == "schannel" + elif Version(self.version) >= "7.72.0": + tc.variables["CMAKE_USE_SCHANNEL"] = self.options.with_ssl == "schannel" else: - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.definitions["BUILD_CURL_EXE"] = False - self._cmake.definitions["CURL_DISABLE_LDAP"] = not self.options.with_ldap - self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["CURL_STATICLIB"] = not self.options.shared - self._cmake.definitions["CMAKE_DEBUG_POSTFIX"] = "" - if tools.Version(self.version) >= "7.72.0": - self._cmake.definitions["CMAKE_USE_SCHANNEL"] = self.options.with_ssl == "schannel" + tc.variables["CMAKE_USE_WINSSL"] = self.options.with_ssl == "schannel" + if Version(self.version) >= "7.81.0": + tc.variables["CURL_USE_OPENSSL"] = self.options.with_ssl == "openssl" else: - self._cmake.definitions["CMAKE_USE_WINSSL"] = self.options.with_ssl == "schannel" - self._cmake.definitions["CMAKE_USE_OPENSSL"] = self.options.with_ssl == "openssl" - if tools.Version(self.version) >= "7.70.0": - self._cmake.definitions["CMAKE_USE_WOLFSSL"] = self.options.with_ssl == "wolfssl" - self._cmake.definitions["USE_NGHTTP2"] = self.options.with_nghttp2 - self._cmake.definitions["CURL_ZLIB"] = self.options.with_zlib - self._cmake.definitions["CURL_BROTLI"] = self.options.with_brotli + tc.variables["CMAKE_USE_OPENSSL"] = self.options.with_ssl == "openssl" + if Version(self.version) >= "7.81.0": + tc.variables["CURL_USE_WOLFSSL"] = self.options.with_ssl == "wolfssl" + elif Version(self.version) >= "7.70.0": + tc.variables["CMAKE_USE_WOLFSSL"] = self.options.with_ssl == "wolfssl" + tc.variables["USE_NGHTTP2"] = self.options.with_nghttp2 + tc.variables["CURL_ZLIB"] = self.options.with_zlib + tc.variables["CURL_BROTLI"] = self.options.with_brotli if self._has_zstd_option: - self._cmake.definitions["CURL_ZSTD"] = self.options.with_zstd - self._cmake.definitions["CMAKE_USE_LIBSSH2"] = self.options.with_libssh2 - self._cmake.definitions["ENABLE_ARES"] = self.options.with_c_ares + tc.variables["CURL_ZSTD"] = self.options.with_zstd + if Version(self.version) >= "7.81.0": + tc.variables["CURL_USE_LIBSSH2"] = self.options.with_libssh2 + else: + tc.variables["CMAKE_USE_LIBSSH2"] = self.options.with_libssh2 + tc.variables["ENABLE_ARES"] = self.options.with_c_ares + if not self.options.with_c_ares: + tc.variables["ENABLE_THREADED_RESOLVER"] = self.options.with_threaded_resolver + tc.variables["CURL_DISABLE_PROXY"] = not self.options.with_proxy + tc.variables["USE_LIBRTMP"] = self.options.with_librtmp + if Version(self.version) >= "7.75.0": + tc.variables["USE_LIBIDN2"] = self.options.with_libidn + tc.variables["CURL_DISABLE_RTSP"] = not self.options.with_rtsp + tc.variables["CURL_DISABLE_CRYPTO_AUTH"] = not self.options.with_crypto_auth + tc.variables["CURL_DISABLE_VERBOSE_STRINGS"] = not self.options.with_verbose_strings + + # Also disables NTLM_WB if set to false + if not self.options.with_ntlm: + if Version(self.version) <= "7.77.0": + tc.variables["CURL_DISABLE_CRYPTO_AUTH"] = True + else: + tc.variables["CURL_DISABLE_NTLM"] = True + tc.variables["NTLM_WB_ENABLED"] = self.options.with_ntlm_wb - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + if self.options.with_ca_bundle: + tc.cache_variables["CURL_CA_BUNDLE"] = str(self.options.with_ca_bundle) + else: + tc.cache_variables["CURL_CA_BUNDLE"] = "none" + + if self.options.with_ca_path: + tc.cache_variables["CURL_CA_PATH"] = str(self.options.with_ca_path) + else: + tc.cache_variables["CURL_CA_PATH"] = "none" - def _build_with_cmake(self): - cmake = self._configure_cmake() - cmake.build() + tc.generate() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - self.copy("cacert.pem", dst="res") + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "cacert.pem", src=self.source_folder, dst=os.path.join(self.package_folder, "res")) if self._is_using_cmake_build: - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) else: - with tools.run_environment(self): - with tools.chdir(self._source_subfolder): - autotools, autotools_vars = self._configure_autotools() - autotools.install(vars=autotools_vars) - tools.rmdir(os.path.join(self.package_folder, "share")) - for la_file in glob.glob(os.path.join(self.package_folder, "lib", "*.la")): - os.remove(la_file) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + fix_apple_shared_install_name(self) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) if self._is_mingw and self.options.shared: # Handle only mingw libs - self.copy(pattern="*.dll", dst="bin", keep_path=False) - self.copy(pattern="*.dll.a", dst="lib", keep_path=False) - self.copy(pattern="*.lib", dst="lib", keep_path=False) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + copy(self, pattern="*.dll", src=self.build_folder, dst="bin", keep_path=False) + copy(self, pattern="*.dll.a", src=self.build_folder, dst="lib", keep_path=False) + copy(self, pattern="*.lib", src=self.build_folder, dst="lib", keep_path=False) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "CURL" - self.cpp_info.names["cmake_find_package_multi"] = "CURL" - self.cpp_info.names["pkg_config"] = "libcurl" - self.cpp_info.components["curl"].names["cmake_find_package"] = "libcurl" - self.cpp_info.components["curl"].names["cmake_find_package_multi"] = "libcurl" - self.cpp_info.components["curl"].names["pkg_config"] = "libcurl" + self.cpp_info.set_property("cmake_file_name", "CURL") + self.cpp_info.set_property("cmake_target_name", "CURL::libcurl") + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("pkg_config_name", "libcurl") - if self.settings.compiler == "Visual Studio": + self.cpp_info.components["curl"].resdirs = ["res"] + if is_msvc(self): self.cpp_info.components["curl"].libs = ["libcurl_imp"] if self.options.shared else ["libcurl"] else: self.cpp_info.components["curl"].libs = ["curl"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: if self.options.with_libidn: self.cpp_info.components["curl"].libs.append("idn") if self.options.with_librtmp: self.cpp_info.components["curl"].libs.append("rtmp") - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["curl"].system_libs = ["rt", "pthread"] elif self.settings.os == "Windows": # used on Windows for VS build, native and cross mingw build @@ -486,11 +626,15 @@ def package_info(self): self.cpp_info.components["curl"].system_libs.append("wldap32") if self.options.with_ssl == "schannel": self.cpp_info.components["curl"].system_libs.append("crypt32") - elif self.settings.os == "Macos": + elif is_apple_os(self): + if Version(self.version) >= "7.78.0" or self.options.with_ssl == "darwinssl": + self.cpp_info.components["curl"].frameworks.append("CoreFoundation") + if Version(self.version) >= "7.77.0": + self.cpp_info.components["curl"].frameworks.append("SystemConfiguration") if self.options.with_ldap: self.cpp_info.components["curl"].system_libs.append("ldap") if self.options.with_ssl == "darwinssl": - self.cpp_info.components["curl"].frameworks.extend(["Cocoa", "Security"]) + self.cpp_info.components["curl"].frameworks.append("Security") if self._is_mingw: # provide pthread for dependent packages @@ -517,3 +661,11 @@ def package_info(self): self.cpp_info.components["curl"].requires.append("zstd::zstd") if self.options.with_c_ares: self.cpp_info.components["curl"].requires.append("c-ares::c-ares") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "CURL" + self.cpp_info.names["cmake_find_package_multi"] = "CURL" + self.cpp_info.components["curl"].names["cmake_find_package"] = "libcurl" + self.cpp_info.components["curl"].names["cmake_find_package_multi"] = "libcurl" + self.cpp_info.components["curl"].set_property("cmake_target_name", "CURL::libcurl") + self.cpp_info.components["curl"].set_property("pkg_config_name", "libcurl") diff --git a/recipes/libcurl/all/patches/001-Update-FindLibSSH2.cmake-add-libssh2-as-possible-nam.patch b/recipes/libcurl/all/patches/001-Update-FindLibSSH2.cmake-add-libssh2-as-possible-nam.patch deleted file mode 100644 index 6d1ed1899bfe5..0000000000000 --- a/recipes/libcurl/all/patches/001-Update-FindLibSSH2.cmake-add-libssh2-as-possible-nam.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/CMake/FindLibSSH2.cmake b/CMake/FindLibSSH2.cmake -index 84822dba7..0d6219425 100644 ---- a/CMake/FindLibSSH2.cmake -+++ b/CMake/FindLibSSH2.cmake -@@ -12,7 +12,7 @@ endif() - find_path(LIBSSH2_INCLUDE_DIR libssh2.h - ) - --find_library(LIBSSH2_LIBRARY NAMES ssh2 -+find_library(LIBSSH2_LIBRARY NAMES ssh2 libssh2 - ) - - if(LIBSSH2_INCLUDE_DIR) --- -2.24.0.windows.2 - diff --git a/recipes/libcurl/all/patches/002-add-missing-file-FindZstd.patch b/recipes/libcurl/all/patches/002-add-missing-file-FindZstd.patch deleted file mode 100644 index b7f407cfcde83..0000000000000 --- a/recipes/libcurl/all/patches/002-add-missing-file-FindZstd.patch +++ /dev/null @@ -1,72 +0,0 @@ ---- /dev/null -+++ b/CMake/FindZstd.cmake -@@ -0,0 +1,69 @@ -+#*************************************************************************** -+# _ _ ____ _ -+# Project ___| | | | _ \| | -+# / __| | | | |_) | | -+# | (__| |_| | _ <| |___ -+# \___|\___/|_| \_\_____| -+# -+# Copyright (C) 1998 - 2020, Daniel Stenberg, , et al. -+# -+# This software is licensed as described in the file COPYING, which -+# you should have received as part of this distribution. The terms -+# are also available at https://curl.haxx.se/docs/copyright.html. -+# -+# You may opt to use, copy, modify, merge, publish, distribute and/or sell -+# copies of the Software, and permit persons to whom the Software is -+# furnished to do so, under the terms of the COPYING file. -+# -+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY -+# KIND, either express or implied. -+# -+########################################################################### -+ -+#[=======================================================================[.rst: -+FindZstd -+---------- -+ -+Find the zstd library -+ -+Result Variables -+^^^^^^^^^^^^^^^^ -+ -+``Zstd_FOUND`` -+ System has zstd -+``Zstd_INCLUDE_DIRS`` -+ The zstd include directories. -+``Zstd_LIBRARIES`` -+ The libraries needed to use zstd -+#]=======================================================================] -+ -+if(UNIX) -+ find_package(PkgConfig QUIET) -+ pkg_search_module(PC_Zstd libzstd) -+endif() -+ -+find_path(Zstd_INCLUDE_DIR zstd.h -+ HINTS -+ ${PC_Zstd_INCLUDEDIR} -+ ${PC_Zstd_INCLUDE_DIRS} -+) -+ -+find_library(Zstd_LIBRARY NAMES zstd -+ HINTS -+ ${PC_Zstd_LIBDIR} -+ ${PC_Zstd_LIBRARY_DIRS} -+) -+ -+include(FindPackageHandleStandardArgs) -+find_package_handle_standard_args(Zstd -+ REQUIRED_VARS -+ Zstd_LIBRARY -+ Zstd_INCLUDE_DIR -+) -+ -+if(Zstd_FOUND) -+ set(Zstd_LIBRARIES ${Zstd_LIBRARY}) -+ set(Zstd_INCLUDE_DIRS ${Zstd_INCLUDE_DIR}) -+endif() -+ -+mark_as_advanced(Zstd_INCLUDE_DIRS Zstd_LIBRARIES) diff --git a/recipes/libcurl/all/patches/004-no-checksrc.patch b/recipes/libcurl/all/patches/004-no-checksrc.patch new file mode 100644 index 0000000000000..7a5cb866faa93 --- /dev/null +++ b/recipes/libcurl/all/patches/004-no-checksrc.patch @@ -0,0 +1,12 @@ +diff -ruN a/lib/Makefile.am b/lib/Makefile.am +--- a/lib/Makefile.am ++++ b/lib/Makefile.am +@@ -138,8 +138,6 @@ + CS_ = $(CS_0) + + checksrc: +- $(CHECKSRC)(@PERL@ $(srcdir)/checksrc.pl -D$(srcdir) -W$(srcdir)/curl_config.h \ +- $(srcdir)/*.[ch] $(srcdir)/vauth/*.[ch] $(srcdir)/vtls/*.[ch] $(srcdir)/vquic/*.[ch] $(srcdir)/vssh/*.[ch]) + + if CURLDEBUG + # for debug builds, we scan the sources on all regular make invokes diff --git a/recipes/libcurl/all/test_package/CMakeLists.txt b/recipes/libcurl/all/test_package/CMakeLists.txt index c1a339c384346..a36a89aea9b2b 100644 --- a/recipes/libcurl/all/test_package/CMakeLists.txt +++ b/recipes/libcurl/all/test_package/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - find_package(CURL REQUIRED) add_executable(${PROJECT_NAME} test_package.c) diff --git a/recipes/libcurl/all/test_package/conanfile.py b/recipes/libcurl/all/test_package/conanfile.py index 2ba91fa8c5901..b0f5c0aed58a5 100644 --- a/recipes/libcurl/all/test_package/conanfile.py +++ b/recipes/libcurl/all/test_package/conanfile.py @@ -1,46 +1,52 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os import subprocess import re class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): - if tools.cross_building(self.settings) and self.settings.os in ["iOS"]: - return # on iOS I do not even need to build, it will just give am a and error about unsigned binaries cmake = CMake(self) cmake.configure() cmake.build() + @property + def _test_executable(self): + return os.path.join(self.cpp.build.bindirs[0], "test_package") + def test(self): - if tools.cross_building(self.settings) and self.settings.os in ["Android", "iOS"]: - return - - if "arm" in self.settings.arch: - self.test_arm() - elif tools.cross_building(self.settings) and self.settings.os == "Windows": - self.test_mingw_cross() - elif not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - - def test_mingw_cross(self): - bin_path = os.path.join("bin", "test_package.exe") - output = subprocess.check_output(["file", bin_path]).decode() - assert re.search(r"PE32.*executable.*Windows", output) - - def test_arm(self): - file_ext = "so" if self.options["libcurl"].shared else "a" - lib_path = os.path.join(self.deps_cpp_info["libcurl"].libdirs[0], "libcurl.%s" % file_ext) - output = subprocess.check_output(["readelf", "-h", lib_path]).decode() - - if "armv8" in self.settings.arch: - if self.settings.arch == "armv8_32": - assert re.search(r"Machine:\s+ARM", output) - else: - assert re.search(r"Machine:\s+AArch64", output) + if can_run(self): + self.run(self._test_executable, env="conanrun") else: - assert re.search(r"Machine:\s+ARM", output) + # We will dump information for the generated executable + if self.settings.os in ["Android", "iOS"]: + # FIXME: Check output for these hosts + return + + output = subprocess.check_output(["file", self._test_executable]).decode() + + if self.settings.os == "Macos" and self.settings.arch == "armv8": + assert "Mach-O 64-bit executable arm64" in output, f"Not found in output: {output}" + + elif self.settings.os == "Linux": + if self.settings.arch == "armv8_32": + assert re.search(r"Machine:\s+ARM", output), f"Not found in output: {output}" + elif "armv8" in self.settings.arch: + assert re.search(r"Machine:\s+AArch64", output), f"Not found in output: {output}" + elif "arm" in self.settings.arch: + assert re.search(r"Machine:\s+ARM", output), f"Not found in output: {output}" + + elif self.settings.os == "Windows": # FIXME: It satisfies not only MinGW + assert re.search(r"PE32.*executable.*Windows", output), f"Not found in output: {output}" diff --git a/recipes/libcurl/all/test_v1_package/CMakeLists.txt b/recipes/libcurl/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..87b6e499b5d8e --- /dev/null +++ b/recipes/libcurl/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CURL REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} CURL::libcurl) diff --git a/recipes/libcurl/all/test_v1_package/conanfile.py b/recipes/libcurl/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..7ebb558a2d5e3 --- /dev/null +++ b/recipes/libcurl/all/test_v1_package/conanfile.py @@ -0,0 +1,43 @@ +from conans import ConanFile, CMake, tools +import os +import subprocess +import re + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + @property + def _test_executable(self): + return os.path.join("bin", "test_package") + + def test(self): + if not tools.cross_building(self): + self.run(self._test_executable, run_environment=True) + else: + # We will dump information for the generated executable + if self.settings.os in ["Android", "iOS"]: + # FIXME: Check output for these hosts + return + + output = subprocess.check_output(["file", self._test_executable]).decode() + + if self.settings.os == "Macos" and self.settings.arch == "armv8": + assert "Mach-O 64-bit executable arm64" in output, f"Not found in output: {output}" + + elif self.settings.os == "Linux": + if self.settings.arch == "armv8_32": + assert re.search(r"Machine:\s+ARM", output), f"Not found in output: {output}" + elif "armv8" in self.settings.arch: + assert re.search(r"Machine:\s+AArch64", output), f"Not found in output: {output}" + elif "arm" in self.settings.arch: + assert re.search(r"Machine:\s+ARM", output), f"Not found in output: {output}" + + elif self.settings.os == "Windows": # FIXME: It satisfies not only MinGW + assert re.search(r"PE32.*executable.*Windows", output), f"Not found in output: {output}" diff --git a/recipes/libcurl/config.yml b/recipes/libcurl/config.yml index 3ea3e23149104..67489a56924a2 100644 --- a/recipes/libcurl/config.yml +++ b/recipes/libcurl/config.yml @@ -1,25 +1,21 @@ versions: - "7.75.0": + "7.86.0": folder: all - "7.74.0": + "7.85.0": folder: all - "7.73.0": + "7.84.0": folder: all - "7.72.0": + "7.83.1": folder: all - "7.71.1": + "7.82.0": folder: all - "7.71.0": + "7.80.0": folder: all - "7.70.0": + "7.79.1": folder: all - "7.69.1": + "7.78.0": folder: all - "7.68.0": + "7.77.0": folder: all - "7.67.0": - folder: all - "7.66.0": - folder: all - "7.64.1": + "7.76.0": folder: all diff --git a/recipes/libdaemon/all/conandata.yml b/recipes/libdaemon/all/conandata.yml new file mode 100644 index 0000000000000..0521f8ab5a13a --- /dev/null +++ b/recipes/libdaemon/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.14": + url: "http://0pointer.de/lennart/projects/libdaemon/libdaemon-0.14.tar.gz" + sha256: "fd23eb5f6f986dcc7e708307355ba3289abe03cc381fc47a80bca4a50aa6b834" diff --git a/recipes/libdaemon/all/conanfile.py b/recipes/libdaemon/all/conanfile.py new file mode 100644 index 0000000000000..92f0ca045e87d --- /dev/null +++ b/recipes/libdaemon/all/conanfile.py @@ -0,0 +1,100 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.build import cross_building +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +import os + +required_conan_version = ">=1.53.0" + + +class LibDaemonConan(ConanFile): + name = "libdaemon" + description = "a lightweight C library that eases the writing of UNIX daemons" + topics = ("daemon") + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://0pointer.de/lennart/projects/libdaemon/" + license = "LGPL-2.1-or-later" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration("Visual Studio not supported") + + def build_requirements(self): + self.tool_requires("gnu-config/cci.20210814") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.configure_args.append("--disable-examples") + if cross_building(self): + tc.configure_args.append("ac_cv_func_setpgrp_void=yes") + tc.generate() + + def _patch_sources(self): + for gnu_config in [ + self.conf.get("user.gnu-config:config_guess", check_type=str), + self.conf.get("user.gnu-config:config_sub", check_type=str), + ]: + if gnu_config: + copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder) + + def build(self): + self._patch_sources() + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "share")) + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libdaemon") + self.cpp_info.libs = ["daemon"] diff --git a/recipes/libdaemon/all/test_package/CMakeLists.txt b/recipes/libdaemon/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..23288e5f6af93 --- /dev/null +++ b/recipes/libdaemon/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libdaemon REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libdaemon::libdaemon) diff --git a/recipes/libdaemon/all/test_package/conanfile.py b/recipes/libdaemon/all/test_package/conanfile.py new file mode 100644 index 0000000000000..c46f4c5ac93f7 --- /dev/null +++ b/recipes/libdaemon/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + self.run(f"{bin_path} -k", env="conanrun") diff --git a/recipes/libdaemon/all/test_package/test_package.c b/recipes/libdaemon/all/test_package/test_package.c new file mode 100644 index 0000000000000..0a230a261b754 --- /dev/null +++ b/recipes/libdaemon/all/test_package/test_package.c @@ -0,0 +1,195 @@ +/*** + This file is part of libdaemon. + + Copyright 2003-2008 Lennart Poettering + + libdaemon is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 2.1 of the + License, or (at your option) any later version. + + libdaemon is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with libdaemon. If not, see + . +***/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +const char *daemon_pid_file_proc_tmp(void) { + return "/tmp/test_package.pid"; +} + +int main(int argc, char *argv[]) { + daemon_pid_file_proc = daemon_pid_file_proc_tmp; + + pid_t pid; + + /* Reset signal handlers */ + if (daemon_reset_sigs(-1) < 0) { + daemon_log(LOG_ERR, "Failed to reset all signal handlers: %s", strerror(errno)); + return 1; + } + + /* Unblock signals */ + if (daemon_unblock_sigs(-1) < 0) { + daemon_log(LOG_ERR, "Failed to unblock all signals: %s", strerror(errno)); + return 1; + } + + /* Set indetification string for the daemon for both syslog and PID file */ + daemon_pid_file_ident = daemon_log_ident = daemon_ident_from_argv0(argv[0]); + + /* Check if we are called with -k parameter */ + if (argc >= 2 && !strcmp(argv[1], "-k")) { + int ret; + + /* Kill daemon with SIGTERM */ + + /* Check if the new function daemon_pid_file_kill_wait() is available, if it is, use it. */ + if ((ret = daemon_pid_file_kill_wait(SIGTERM, 5)) < 0) + daemon_log(LOG_WARNING, "Failed to kill daemon: %s", strerror(errno)); + + return ret < 0 ? 1 : 0; + } + + /* Check that the daemon is not rung twice a the same time */ + if ((pid = daemon_pid_file_is_running()) >= 0) { + daemon_log(LOG_ERR, "Daemon already running on PID file %u", pid); + return 1; + } + + /* Prepare for return value passing from the initialization procedure of the daemon process */ + if (daemon_retval_init() < 0) { + daemon_log(LOG_ERR, "Failed to create pipe."); + return 1; + } + + /* Do the fork */ + if ((pid = daemon_fork()) < 0) { + + /* Exit on error */ + daemon_retval_done(); + return 1; + + } else if (pid) { /* The parent */ + int ret; + + /* Wait for 20 seconds for the return value passed from the daemon process */ + if ((ret = daemon_retval_wait(20)) < 0) { + daemon_log(LOG_ERR, "Could not recieve return value from daemon process: %s", strerror(errno)); + return 255; + } + + daemon_log(ret != 0 ? LOG_ERR : LOG_INFO, "Daemon returned %i as return value.", ret); + return ret; + + } else { /* The daemon */ + int fd, quit = 0; + fd_set fds; + + /* Close FDs */ + if (daemon_close_all(-1) < 0) { + daemon_log(LOG_ERR, "Failed to close all file descriptors: %s", strerror(errno)); + + /* Send the error condition to the parent process */ + daemon_retval_send(1); + goto finish; + } + + /* Create the PID file */ + if (daemon_pid_file_create() < 0) { + daemon_log(LOG_ERR, "Could not create PID file (%s).", strerror(errno)); + daemon_retval_send(2); + goto finish; + } + + /* Initialize signal handling */ + if (daemon_signal_init(SIGINT, SIGTERM, SIGQUIT, SIGHUP, 0) < 0) { + daemon_log(LOG_ERR, "Could not register signal handlers (%s).", strerror(errno)); + daemon_retval_send(3); + goto finish; + } + + /*... do some further init work here */ + + + /* Send OK to parent process */ + daemon_retval_send(0); + + daemon_log(LOG_INFO, "Sucessfully started"); + + /* Prepare for select() on the signal fd */ + FD_ZERO(&fds); + fd = daemon_signal_fd(); + FD_SET(fd, &fds); + + while (!quit) { + fd_set fds2 = fds; + + /* Wait for an incoming signal */ + if (select(FD_SETSIZE, &fds2, 0, 0, 0) < 0) { + + /* If we've been interrupted by an incoming signal, continue */ + if (errno == EINTR) + continue; + + daemon_log(LOG_ERR, "select(): %s", strerror(errno)); + break; + } + + /* Check if a signal has been recieved */ + if (FD_ISSET(fd, &fds2)) { + int sig; + + /* Get signal */ + if ((sig = daemon_signal_next()) <= 0) { + daemon_log(LOG_ERR, "daemon_signal_next() failed: %s", strerror(errno)); + break; + } + + /* Dispatch signal */ + switch (sig) { + + case SIGINT: + case SIGQUIT: + case SIGTERM: + daemon_log(LOG_WARNING, "Got SIGINT, SIGQUIT or SIGTERM."); + quit = 1; + break; + + case SIGHUP: + daemon_log(LOG_INFO, "Got a HUP"); + daemon_exec("/", NULL, "/bin/ls", "ls", (char*) NULL); + break; + + } + } + } + + /* Do a cleanup */ +finish: + daemon_log(LOG_INFO, "Exiting..."); + daemon_retval_send(255); + daemon_signal_done(); + daemon_pid_file_remove(); + + return 0; + } +} diff --git a/recipes/libdaemon/all/test_v1_package/CMakeLists.txt b/recipes/libdaemon/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libdaemon/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libdaemon/all/test_v1_package/conanfile.py b/recipes/libdaemon/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..93fc246e84e20 --- /dev/null +++ b/recipes/libdaemon/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + self.run(f"{bin_path} -k", run_environment=True) diff --git a/recipes/libdaemon/config.yml b/recipes/libdaemon/config.yml new file mode 100644 index 0000000000000..b4e28d5df14d5 --- /dev/null +++ b/recipes/libdaemon/config.yml @@ -0,0 +1,3 @@ +versions: + "0.14": + folder: all diff --git a/recipes/libdb/all/conanfile.py b/recipes/libdb/all/conanfile.py index 259fff0b31199..1fd743e1c3a19 100644 --- a/recipes/libdb/all/conanfile.py +++ b/recipes/libdb/all/conanfile.py @@ -1,18 +1,21 @@ from conans import AutoToolsBuildEnvironment, ConanFile, MSBuild, tools from conans.errors import ConanInvalidConfiguration +import glob import os import shutil +required_conan_version = ">=1.33.0" + class LibdbConan(ConanFile): name = "libdb" description = "Berkeley DB is a family of embedded key-value database libraries providing scalable high-performance data management services to applications" - topics = ("conan", "gdbm", "dbm", "hash", "database") + topics = ("gdbm", "dbm", "hash", "database") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.oracle.com/database/berkeley-db" license = ("BSD-3-Clause") - exports_sources = "patches/**" - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -38,6 +41,18 @@ def _source_subfolder(self): def _mingw_build(self): return self.settings.compiler == "gcc" and self.settings.os == "Windows" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -47,33 +62,54 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC + if not self.options.get_safe("with_cxx", False): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + if self.options.with_tcl: + self.requires("tcl/8.6.10") + + def validate(self): + if self.settings.compiler == "Visual Studio": + # FIXME: it used to work with previous versions of Visual Studio 2019 in CI of CCI. + if tools.Version(self.settings.compiler.version) == "16": + raise ConanInvalidConfiguration("Visual Studio 2019 not supported.") + if self.options.get_safe("with_cxx"): if self.settings.compiler == "clang": - if self.settings.compiler.version <= tools.Version("5"): + if tools.Version(self.settings.compiler.version) <= "5": raise ConanInvalidConfiguration("This compiler version is unsupported") if self.settings.compiler == "apple-clang": - if self.settings.compiler.version < tools.Version("10"): + if tools.Version(self.settings.compiler.version) < "10": raise ConanInvalidConfiguration("This compiler version is unsupported") - def requirements(self): - if self.options.with_tcl: - self.requires("tcl/8.6.10") - def build_requirements(self): if self.settings.compiler != "Visual Studio": - if tools.os_info.is_windows and not "CONAN_BASH_PATH" in os.environ and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") + self.build_requires("gnu-config/cci.20201022") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("db-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _patch_sources(self): - for patch_data in self.conan_data["patches"][self.version]: - tools.patch(**patch_data) + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + if self.settings.compiler != "Visual Studio": + for subdir in [ + "dist", + os.path.join("lang", "sql", "jdbc"), + os.path.join("lang", "sql", "odbc"), + os.path.join("lang", "sql", "sqlite"), + ]: + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, subdir, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, subdir, "config.guess")) - import glob for file in glob.glob(os.path.join(self._source_subfolder, "build_windows", "VS10", "*.vcxproj")): tools.replace_in_file(file, "", @@ -91,6 +127,8 @@ def _configure_autotools(self): if self._autotools: return self._autotools self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + if self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) >= "12": + self._autotools.flags.append("-Wno-error=implicit-function-declaration") conf_args = [ "--enable-debug" if self.settings.build_type == "Debug" else "--disable-debug", "--enable-mingw" if self._mingw_build else "--disable-mingw", @@ -171,8 +209,8 @@ def _lib_to_msvc_lib(lib): msvc_libs = [_lib_to_msvc_lib(lib) for lib in self._libs] for lib, msvc_lib in zip(self._libs, msvc_libs): - os.rename(os.path.join(libdir, "{}.lib".format(msvc_lib)), - os.path.join(libdir, "{}.lib".format(lib))) + tools.rename(os.path.join(libdir, "{}.lib".format(msvc_lib)), + os.path.join(libdir, "{}.lib".format(lib))) else: autotools = self._configure_autotools() autotools.install() @@ -180,7 +218,7 @@ def _lib_to_msvc_lib(lib): if self.settings.os == "Windows": for fn in os.listdir(libdir): if fn.endswith(".dll"): - os.rename(os.path.join(libdir, fn), os.path.join(bindir, fn)) + tools.rename(os.path.join(libdir, fn), os.path.join(bindir, fn)) for fn in os.listdir(bindir): if not fn.endswith(".dll"): binpath = os.path.join(bindir, fn) @@ -196,18 +234,11 @@ def _lib_to_msvc_lib(lib): if not os.listdir(bindir): tools.rmdir(bindir) - for lib in self._libs: - la_file = os.path.join(libdir, "lib{}-{}.la".format(lib, ".".join(self._major_minor_version))) - if os.path.exists(la_file): - os.remove(la_file) - if not self.options.shared: - # autotools installs the static libraries twice as libXXX.a and libXXX-5.3.a ==> remove libXXX-5.3.a - libfn = os.path.join(libdir, "lib{}.a".format(lib)) - lib_version_fn = os.path.join(libdir, "lib{}-{}.a".format(lib, ".".join(self._major_minor_version))) - assert os.path.isfile(libfn) - os.remove(lib_version_fn) - tools.rmdir(os.path.join(self.package_folder, "docs")) + tools.remove_files_by_mask(libdir, "*.la") + if not self.options.shared: + # autotools installs the static libraries twice as libXXX.a and libXXX-5.3.a ==> remove libXXX-5.3.a + tools.remove_files_by_mask(libdir, "*-{}.a".format(".".join(self._major_minor_version))) @property def _major_minor_version(self): @@ -228,9 +259,9 @@ def _libs(self): def package_info(self): self.cpp_info.libs = self._libs - if self.settings.compiler == "Visual Studio"and self.options.shared: + if self.settings.compiler == "Visual Studio" and self.options.shared: self.cpp_info.defines = ["DB_USE_DLL"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["dl", "pthread"]) elif self.settings.os == "Windows" : self.cpp_info.system_libs.append("ws2_32") diff --git a/recipes/libdb/all/test_package/CMakeLists.txt b/recipes/libdb/all/test_package/CMakeLists.txt index 9f4df3da6c783..7b9b613cbb24a 100644 --- a/recipes/libdb/all/test_package/CMakeLists.txt +++ b/recipes/libdb/all/test_package/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.1) project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) diff --git a/recipes/libdb/all/test_package/conanfile.py b/recipes/libdb/all/test_package/conanfile.py index 1511c156191f2..d919133e5c230 100644 --- a/recipes/libdb/all/test_package/conanfile.py +++ b/recipes/libdb/all/test_package/conanfile.py @@ -3,15 +3,14 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake" def build(self): cmake = CMake(self) - cmake.verbose = True cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/libdc1394/all/conanfile.py b/recipes/libdc1394/all/conanfile.py index 078093839909b..f52cb3b808339 100644 --- a/recipes/libdc1394/all/conanfile.py +++ b/recipes/libdc1394/all/conanfile.py @@ -1,70 +1,103 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import chdir, copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +required_conan_version = ">=1.53.0" + class Libdc1394Conan(ConanFile): name = "libdc1394" license = "LGPL-2.1-or-later" url = "https://github.com/conan-io/conan-center-index" - homepage = 'https://damien.douxchamps.net/ieee1394/libdc1394/' + homepage = "https://damien.douxchamps.net/ieee1394/libdc1394/" description = "libdc1394 provides a complete high level API to control IEEE 1394 based cameras" - topics = ("conan", "ieee1394", "camera", "iidc", "dcam") - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _env_build = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - def _configure_autotools(self): - if not self._env_build: - self._env_build = AutoToolsBuildEnvironment(self) - if self.options.shared: - args = ["--disable-static", "--enable-shared"] - else: - args = ["--disable-shared", "--enable-static"] - args.extend(["--disable-examples"]) - self._env_build.configure(args=args) - return self._env_build + topics = ("ieee1394", "camera", "iidc", "dcam") - def configure(self): - if self.options.shared: - del self.options.fPIC - if self.settings.os == "Windows": - raise ConanInvalidConfiguration("Windows is not supported") - if self.settings.compiler == "clang": - raise ConanInvalidConfiguration("Clang doesn't support VLA") - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("libusb/1.0.26") + + def validate(self): + if self.info.settings.os == "Windows": + raise ConanInvalidConfiguration("Windows is not supported yet in this recipe") + if self.info.settings.compiler == "clang": + raise ConanInvalidConfiguration("Clang doesn't support VLA") + + def build_requirements(self): + self.tool_requires("gnu-config/cci.20210814") + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/1.9.3") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libdc1394-%s" % self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.configure_args.append("--disable-examples") + tc.generate() + deps = PkgConfigDeps(self) + deps.generate() + + def _patch_sources(self): + for gnu_config in [ + self.conf.get("user.gnu-config:config_guess", check_type=str), + self.conf.get("user.gnu-config:config_sub", check_type=str), + ]: + if gnu_config: + copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder) def build(self): - with tools.chdir(self._source_subfolder): - env_build = self._configure_autotools() - env_build.make() + self._patch_sources() + with chdir(self, self.source_folder): + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - with tools.chdir(self._source_subfolder): - env_build = self._configure_autotools() - env_build.install() - - self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses") - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + with chdir(self, self.source_folder): + autotools = Autotools(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) def package_info(self): - self.cpp_info.names["pkg_config"] = "libdc1394-{}".format(tools.Version(self.version).major) + self.cpp_info.set_property("pkg_config_name", f"libdc1394-{Version(self.version).major}") self.cpp_info.libs = ["dc1394"] - if tools.is_apple_os(self.settings.os): + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + elif is_apple_os(self): self.cpp_info.frameworks.extend(["CoreFoundation", "CoreServices", "IOKit"]) diff --git a/recipes/libdc1394/all/test_package/CMakeLists.txt b/recipes/libdc1394/all/test_package/CMakeLists.txt index 40d74d212ef72..97fa5a2906309 100644 --- a/recipes/libdc1394/all/test_package/CMakeLists.txt +++ b/recipes/libdc1394/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libdc1394 REQUIRED CONFIG) -add_executable(example test_package.c) -target_link_libraries(example ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libdc1394::libdc1394) diff --git a/recipes/libdc1394/all/test_package/conanfile.py b/recipes/libdc1394/all/test_package/conanfile.py index c1297fa185e7a..0a6bc68712d90 100644 --- a/recipes/libdc1394/all/test_package/conanfile.py +++ b/recipes/libdc1394/all/test_package/conanfile.py @@ -1,11 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" -class Libdc1394TestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -13,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libdc1394/all/test_v1_package/CMakeLists.txt b/recipes/libdc1394/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libdc1394/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libdc1394/all/test_v1_package/conanfile.py b/recipes/libdc1394/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libdc1394/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libdc1394/config.yml b/recipes/libdc1394/config.yml index f43a0fa85d126..02d886e69e974 100644 --- a/recipes/libdc1394/config.yml +++ b/recipes/libdc1394/config.yml @@ -1,3 +1,3 @@ versions: - 2.2.6: - folder: all + "2.2.6": + folder: all diff --git a/recipes/libde265/all/CMakeLists.txt b/recipes/libde265/all/CMakeLists.txt deleted file mode 100644 index 361b35d4c17d9..0000000000000 --- a/recipes/libde265/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/libde265/all/conandata.yml b/recipes/libde265/all/conandata.yml index bf831534bf993..47d525a12ed76 100644 --- a/recipes/libde265/all/conandata.yml +++ b/recipes/libde265/all/conandata.yml @@ -1,8 +1,13 @@ sources: + "1.0.9": + url: "https://github.com/strukturag/libde265/archive/v1.0.9.tar.gz" + sha256: "153554f407718a75f1e0ae197d35b43147ce282118a54f894554dbe27c32163d" "1.0.8": url: "https://github.com/strukturag/libde265/archive/v1.0.8.tar.gz" sha256: "c5ab61185f283f46388c700c43dc08606b0e260cd53f06b967ec0ad7a809ff11" patches: + "1.0.9": + - patch_file: "patches/0002-fix-out-of-source-build.patch" "1.0.8": - - patch_file: "patches/optional-sdl.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-optional-sdl.patch" + - patch_file: "patches/0002-fix-out-of-source-build.patch" diff --git a/recipes/libde265/all/conanfile.py b/recipes/libde265/all/conanfile.py index c7a73feebe5dc..d6051d473a9ba 100644 --- a/recipes/libde265/all/conanfile.py +++ b/recipes/libde265/all/conanfile.py @@ -1,88 +1,125 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file, rmdir, save +from conans import tools as tools_legacy import os +import textwrap + +required_conan_version = ">=1.50.0" class Libde265Conan(ConanFile): name = "libde265" description = "Open h.265 video codec implementation." license = "LGPL-3.0-or-later" - topics = ("conan", "libde265", "codec", "video", "h.265") + topics = ("libde265", "codec", "video", "h.265") homepage = "https://github.com/strukturag/libde265" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "sse": [True, False] + "sse": [True, False], } default_options = { "shared": False, "fPIC": True, - "sse": True + "sse": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.settings.arch not in ["x86", "x86_64"]: + del self.options.sse def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) + tc.variables["ENABLE_SDL"] = False + tc.variables["DISABLE_SSE"] = not self.options.get_safe("sse", False) + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def _patch_sources(self): - for patch_data in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch_data) - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + apply_conandata_patches(self) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True) - self._cmake.definitions["ENABLE_SDL"] = False - self._cmake.definitions["DISABLE_SSE"] = not self.options.sse - self._cmake.configure() - return self._cmake - def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once legacy generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"libde265": "libde265::libde265"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): - # FIXME: imported CMake target shouldn't be namespaced - self.cpp_info.names["cmake_find_package"] = "libde265" - self.cpp_info.names["cmake_find_package_multi"] = "libde265" - self.cpp_info.names["pkg_config"] = "libde265" + self.cpp_info.set_property("cmake_file_name", "libde265") + self.cpp_info.set_property("cmake_target_name", "libde265") + self.cpp_info.set_property("pkg_config_name", "libde265") + self.cpp_info.libs = ["libde265"] if not self.options.shared: self.cpp_info.defines = ["LIBDE265_STATIC_BUILD"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m", "pthread"] - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.system_libs.append(tools.stdcpp_library(self)) + if not self.options.shared: + libcxx = tools_legacy.stdcpp_library(self) + if libcxx: + self.cpp_info.system_libs.append(libcxx) bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/libde265/all/patches/optional-sdl.patch b/recipes/libde265/all/patches/0001-optional-sdl.patch similarity index 100% rename from recipes/libde265/all/patches/optional-sdl.patch rename to recipes/libde265/all/patches/0001-optional-sdl.patch diff --git a/recipes/libde265/all/patches/0002-fix-out-of-source-build.patch b/recipes/libde265/all/patches/0002-fix-out-of-source-build.patch new file mode 100644 index 0000000000000..80209c09038f2 --- /dev/null +++ b/recipes/libde265/all/patches/0002-fix-out-of-source-build.patch @@ -0,0 +1,10 @@ +--- a/libde265/CMakeLists.txt ++++ b/libde265/CMakeLists.txt +@@ -43,7 +43,6 @@ set (libde265_headers + bitstream.h + cabac.h + configparam.h +- de265-version.h + contextmodel.h + de265.h + deblock.h diff --git a/recipes/libde265/all/test_package/CMakeLists.txt b/recipes/libde265/all/test_package/CMakeLists.txt index 8b5c582a6b065..51ad6d4f5df34 100644 --- a/recipes/libde265/all/test_package/CMakeLists.txt +++ b/recipes/libde265/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C) find_package(libde265 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} libde265::libde265) # FIXME: remove namespace when fixed in conanfile +target_link_libraries(${PROJECT_NAME} PRIVATE libde265) diff --git a/recipes/libde265/all/test_package/conanfile.py b/recipes/libde265/all/test_package/conanfile.py index 84ee68733e516..3a8c6c5442b33 100644 --- a/recipes/libde265/all/test_package/conanfile.py +++ b/recipes/libde265/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libde265/all/test_v1_package/CMakeLists.txt b/recipes/libde265/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..8cdef54586d33 --- /dev/null +++ b/recipes/libde265/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libde265 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libde265) diff --git a/recipes/libde265/all/test_v1_package/conanfile.py b/recipes/libde265/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libde265/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libde265/config.yml b/recipes/libde265/config.yml index 28e3ee22ca8ac..1c656ce0b375f 100644 --- a/recipes/libde265/config.yml +++ b/recipes/libde265/config.yml @@ -1,3 +1,5 @@ versions: + "1.0.9": + folder: all "1.0.8": folder: all diff --git a/recipes/libdeflate/all/conandata.yml b/recipes/libdeflate/all/conandata.yml index 1aec7d785c0d7..a438f626651c7 100644 --- a/recipes/libdeflate/all/conandata.yml +++ b/recipes/libdeflate/all/conandata.yml @@ -1,4 +1,44 @@ sources: + "1.14": + url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.14.tar.gz" + sha256: "89e7df898c37c3427b0f39aadcf733731321a278771d20fc553f92da8d4808ac" + "1.12": + url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.12.tar.gz" + sha256: "ba89fb167a5ab6bbdfa6ee3b1a71636e8140fa8471cce8a311697584948e4d06" + "1.10": + url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.10.tar.gz" + sha256: "5c1f75c285cd87202226f4de49985dcb75732f527eefba2b3ddd70a8865f2533" + "1.9": + url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.9.tar.gz" + sha256: "a537ab6125c226b874c02b166488b326aece954930260dbf682d88fc339137e3" + "1.8": + url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.8.tar.gz" + sha256: "50711ad4e9d3862f8dfb11b97eb53631a86ee3ce49c0e68ec2b6d059a9662f61" "1.7": - url: "https://github.com/ebiggers/libdeflate/archive/v1.7.tar.gz" + url: "https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.7.tar.gz" sha256: "a5e6a0a9ab69f40f0f59332106532ca76918977a974e7004977a9498e3f11350" +patches: + "1.14": + - patch_file: "patches/1.14-0001-fix-makefiles.patch" + patch_description: "disable optimization and apply compiler settings on conan recipe" + patch_type: "conan" + "1.12": + - patch_file: "patches/1.12-0001-fix-makefiles.patch" + patch_description: "disable optimization and apply compiler settings on conan recipe" + patch_type: "conan" + "1.10": + - patch_file: "patches/1.9-0001-fix-makefiles.patch" + patch_description: "disable optimization and apply compiler settings on conan recipe" + patch_type: "conan" + "1.9": + - patch_file: "patches/1.9-0001-fix-makefiles.patch" + patch_description: "disable optimization and apply compiler settings on conan recipe" + patch_type: "conan" + "1.8": + - patch_file: "patches/1.7-0001-fix-makefiles.patch" + patch_description: "disable optimization and apply compiler settings on conan recipe" + patch_type: "conan" + "1.7": + - patch_file: "patches/1.7-0001-fix-makefiles.patch" + patch_description: "disable optimization and apply compiler settings on conan recipe" + patch_type: "conan" diff --git a/recipes/libdeflate/all/conanfile.py b/recipes/libdeflate/all/conanfile.py index 043de28c41ebd..47e0d742be3d1 100644 --- a/recipes/libdeflate/all/conanfile.py +++ b/recipes/libdeflate/all/conanfile.py @@ -1,22 +1,41 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment, tools +from conan import ConanFile +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path, VCVars import os +required_conan_version = ">=1.53.0" + class LibdeflateConan(ConanFile): name = "libdeflate" description = "Heavily optimized library for DEFLATE/zlib/gzip compression and decompression." license = "MIT" - topics = ("conan", "libdeflate", "compression", "decompression", "deflate", "zlib", "gzip") - homepage = "https://github.com/ebiggers/libdeflate" url = "https://github.com/conan-io/conan-center-index" - + homepage = "https://github.com/ebiggers/libdeflate" + topics = ("compression", "decompression", "deflate", "zlib", "gzip") settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _is_clangcl(self): + return self.settings.compiler == "clang" and self.settings.os == "Windows" @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -24,64 +43,85 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") def build_requirements(self): - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio" and \ - not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows" and not (is_msvc(self) or self._is_clangcl): + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def _build_msvc(self): - makefile_msc_file = os.path.join(self._source_subfolder, "Makefile.msc") - tools.replace_in_file(makefile_msc_file, "CFLAGS = /MD /O2 -I.", "CFLAGS = /nologo $(CFLAGS) -I.") - tools.replace_in_file(makefile_msc_file, "LDFLAGS =", "") - with tools.chdir(self._source_subfolder): - with tools.vcvars(self.settings): - with tools.environment_append(VisualStudioBuildEnvironment(self).vars): - target = "libdeflate.dll" if self.options.shared else "libdeflatestatic.lib" - self.run("nmake /f Makefile.msc {}".format(target)) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - @property - def _make_program(self): - return tools.unix_path(tools.get_env("CONAN_MAKE_PROGRAM", tools.which("make") or tools.which("mingw32-make"))) + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + if is_msvc(self) or self._is_clangcl: + vc = VCVars(self) + vc.generate() + # FIXME: no conan v2 build helper for NMake yet (see https://github.com/conan-io/conan/issues/12188) + # So populate CL with AutotoolsToolchain cflags + env = Environment() + c_flags = AutotoolsToolchain(self).cflags + if c_flags: + env.define("CL", c_flags) + env.vars(self).save_script("conanbuildenv_nmake") + else: + tc = AutotoolsToolchain(self) + tc.generate() + + def _build_nmake(self): + with chdir(self, self.source_folder): + target = "libdeflate.dll" if self.options.shared else "libdeflatestatic.lib" + self.run(f"nmake /f Makefile.msc {target}") def _build_make(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile"), "-O2", "") - with tools.chdir(self._source_subfolder): - with tools.environment_append(AutoToolsBuildEnvironment(self).vars): - if self.settings.os == "Windows": - suffix = ".dll" if self.options.shared else "static.lib" - elif tools.is_apple_os(self.settings.os): - suffix = ".dylib" if self.options.shared else ".a" - else: - suffix = ".so" if self.options.shared else ".a" - target = "libdeflate{}".format(suffix) - self.run("{0} -f Makefile {1}".format(self._make_program, target), win_bash=tools.os_info.is_windows) + autotools = Autotools(self) + with chdir(self, self.source_folder): + autotools.make() def build(self): - if self.settings.compiler == "Visual Studio": - self._build_msvc() + apply_conandata_patches(self) + if is_msvc(self) or self._is_clangcl: + self._build_nmake() else: self._build_make() + def _package_windows(self): + copy(self, "libdeflate.h", dst=os.path.join(self.package_folder, "include"), src=self.source_folder) + if self.options.shared: + copy(self, "*deflate.lib", dst=os.path.join(self.package_folder, "lib"), src=self.source_folder) + copy(self, "*deflate.dll", dst=os.path.join(self.package_folder, "bin"), src=self.source_folder) + else: + copy(self, "*deflatestatic.lib", dst=os.path.join(self.package_folder, "lib"), src=self.source_folder) + + def _package_make(self): + autotools = Autotools(self) + with chdir(self, self.source_folder): + # Note: not actually an autotools project, is a Makefile project. + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}", "PREFIX=/"]) + rmdir(self, os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.a" if self.options.shared else "*.[so|dylib]*", os.path.join(self.package_folder, "lib") ) + def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - self.copy("libdeflate.h", dst="include", src=self._source_subfolder) - self.copy("*.lib", dst="lib", src=self._source_subfolder) - self.copy("*.dll", dst="bin", src=self._source_subfolder) - self.copy("*.a", dst="lib", src=self._source_subfolder) - self.copy("*.so*", dst="lib", src=self._source_subfolder, symlinks=True) - self.copy("*.dylib", dst="lib", src=self._source_subfolder, symlinks=True) + copy(self, "COPYING", self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if self.settings.os == "Windows": + self._package_windows() + else: + self._package_make() def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libdeflate") prefix = "lib" if self.settings.os == "Windows" else "" suffix = "static" if self.settings.os == "Windows" and not self.options.shared else "" - self.cpp_info.libs = ["{0}deflate{1}".format(prefix, suffix)] + self.cpp_info.libs = [f"{prefix}deflate{suffix}"] if self.settings.os == "Windows" and self.options.shared: self.cpp_info.defines = ["LIBDEFLATE_DLL"] diff --git a/recipes/libdeflate/all/patches/1.12-0001-fix-makefiles.patch b/recipes/libdeflate/all/patches/1.12-0001-fix-makefiles.patch new file mode 100644 index 0000000000000..fec83886e9dc1 --- /dev/null +++ b/recipes/libdeflate/all/patches/1.12-0001-fix-makefiles.patch @@ -0,0 +1,40 @@ +diff --git a/Makefile b/Makefile +index 9e55d0c..917b6db 100644 +--- a/Makefile ++++ b/Makefile +@@ -54,7 +54,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null \ + 1>&2 2>/dev/null; then echo $(1); fi) + + override CFLAGS := \ +- -O2 -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \ ++ -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \ + $(call cc-option,-Wpedantic) \ + $(call cc-option,-Wdeclaration-after-statement) \ + $(call cc-option,-Wmissing-prototypes) \ +@@ -124,7 +124,7 @@ else ifneq ($(findstring -darwin,$(TARGET_MACHINE)),) + SHARED_LIB := libdeflate.$(SOVERSION).dylib + SHARED_LIB_SYMLINK := libdeflate.dylib + SHARED_LIB_CFLAGS := -fPIC +- SHARED_LIB_LDFLAGS := -install_name $(LIBDIR)/$(SHARED_LIB) ++ SHARED_LIB_LDFLAGS := -install_name @rpath/$(SHARED_LIB) + + # Compiling for Android? + else ifneq ($(findstring -android,$(TARGET_MACHINE)),) +diff --git a/Makefile.msc b/Makefile.msc +index 1449618..a61c034 100644 +--- a/Makefile.msc ++++ b/Makefile.msc +@@ -7,11 +7,10 @@ + + .SUFFIXES: .c .obj .dllobj + +-CC = cl ++CC = $(CC) + LD = link + AR = lib +-CFLAGS = /MD /O2 -I. +-LDFLAGS = ++CFLAGS = /nologo $(CFLAGS) -I. + + STATIC_LIB = libdeflatestatic.lib + SHARED_LIB = libdeflate.dll diff --git a/recipes/libdeflate/all/patches/1.14-0001-fix-makefiles.patch b/recipes/libdeflate/all/patches/1.14-0001-fix-makefiles.patch new file mode 100644 index 0000000000000..6f2656728ddc6 --- /dev/null +++ b/recipes/libdeflate/all/patches/1.14-0001-fix-makefiles.patch @@ -0,0 +1,40 @@ +diff --git a/Makefile b/Makefile +index a08c945..36876b5 100644 +--- a/Makefile ++++ b/Makefile +@@ -54,7 +54,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null \ + 1>&2 2>/dev/null; then echo $(1); fi) + + override CFLAGS := \ +- -O2 -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \ ++ -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \ + $(call cc-option,-Wdeclaration-after-statement) \ + $(call cc-option,-Wimplicit-fallthrough) \ + $(call cc-option,-Wmissing-prototypes) \ +@@ -120,7 +120,7 @@ else ifneq ($(findstring -darwin,$(TARGET_MACHINE)),) + SHARED_LIB := libdeflate.$(SOVERSION).dylib + SHARED_LIB_SYMLINK := libdeflate.dylib + SHARED_LIB_CFLAGS := -fPIC +- SHARED_LIB_LDFLAGS := -install_name $(LIBDIR)/$(SHARED_LIB) ++ SHARED_LIB_LDFLAGS := -install_name @rpath/$(SHARED_LIB) + + # Compiling for Android? + else ifneq ($(findstring -android,$(TARGET_MACHINE)),) +diff --git a/Makefile.msc b/Makefile.msc +index 1449618..a61c034 100644 +--- a/Makefile.msc ++++ b/Makefile.msc +@@ -7,11 +7,10 @@ + + .SUFFIXES: .c .obj .dllobj + +-CC = cl ++CC = $(CC) + LD = link + AR = lib +-CFLAGS = /MD /O2 -I. +-LDFLAGS = ++CFLAGS = /nologo $(CFLAGS) -I. + + STATIC_LIB = libdeflatestatic.lib + SHARED_LIB = libdeflate.dll diff --git a/recipes/libdeflate/all/patches/1.7-0001-fix-makefiles.patch b/recipes/libdeflate/all/patches/1.7-0001-fix-makefiles.patch new file mode 100644 index 0000000000000..b5b9679431bb2 --- /dev/null +++ b/recipes/libdeflate/all/patches/1.7-0001-fix-makefiles.patch @@ -0,0 +1,40 @@ +diff --git a/Makefile b/Makefile +index 276d75d..641e726 100644 +--- a/Makefile ++++ b/Makefile +@@ -48,7 +48,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null \ + 1>&2 2>/dev/null; then echo $(1); fi) + + override CFLAGS := \ +- -O2 -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \ ++ -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \ + $(call cc-option,-Wpedantic) \ + $(call cc-option,-Wdeclaration-after-statement) \ + $(call cc-option,-Wmissing-prototypes) \ +@@ -111,7 +111,7 @@ else ifeq ($(shell uname),Darwin) + SHARED_LIB := libdeflate.$(SOVERSION).dylib + SHARED_LIB_SYMLINK := libdeflate.dylib + SHARED_LIB_CFLAGS := -fPIC +- SHARED_LIB_LDFLAGS := -install_name $(SHARED_LIB) ++ SHARED_LIB_LDFLAGS := -install_name @rpath/$(SHARED_LIB) + + # Linux, FreeBSD, etc. + else +diff --git a/Makefile.msc b/Makefile.msc +index 1449618..a61c034 100644 +--- a/Makefile.msc ++++ b/Makefile.msc +@@ -7,11 +7,10 @@ + + .SUFFIXES: .c .obj .dllobj + +-CC = cl ++CC = $(CC) + LD = link + AR = lib +-CFLAGS = /MD /O2 -I. +-LDFLAGS = ++CFLAGS = /nologo $(CFLAGS) -I. + + STATIC_LIB = libdeflatestatic.lib + SHARED_LIB = libdeflate.dll diff --git a/recipes/libdeflate/all/patches/1.9-0001-fix-makefiles.patch b/recipes/libdeflate/all/patches/1.9-0001-fix-makefiles.patch new file mode 100644 index 0000000000000..295b117c5c67f --- /dev/null +++ b/recipes/libdeflate/all/patches/1.9-0001-fix-makefiles.patch @@ -0,0 +1,40 @@ +diff --git a/Makefile b/Makefile +index 0e8b008..d184a4a 100644 +--- a/Makefile ++++ b/Makefile +@@ -54,7 +54,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null \ + 1>&2 2>/dev/null; then echo $(1); fi) + + override CFLAGS := \ +- -O2 -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \ ++ -fomit-frame-pointer -std=c99 -I. -Wall -Wundef \ + $(call cc-option,-Wpedantic) \ + $(call cc-option,-Wdeclaration-after-statement) \ + $(call cc-option,-Wmissing-prototypes) \ +@@ -119,7 +119,7 @@ else ifneq ($(findstring -darwin,$(TARGET_MACHINE)),) + SHARED_LIB := libdeflate.$(SOVERSION).dylib + SHARED_LIB_SYMLINK := libdeflate.dylib + SHARED_LIB_CFLAGS := -fPIC +- SHARED_LIB_LDFLAGS := -install_name $(SHARED_LIB) ++ SHARED_LIB_LDFLAGS := -install_name @rpath/$(SHARED_LIB) + + # Compiling for Android? + else ifneq ($(findstring -android,$(TARGET_MACHINE)),) +diff --git a/Makefile.msc b/Makefile.msc +index 1449618..a61c034 100644 +--- a/Makefile.msc ++++ b/Makefile.msc +@@ -7,11 +7,10 @@ + + .SUFFIXES: .c .obj .dllobj + +-CC = cl ++CC = $(CC) + LD = link + AR = lib +-CFLAGS = /MD /O2 -I. +-LDFLAGS = ++CFLAGS = /nologo $(CFLAGS) -I. + + STATIC_LIB = libdeflatestatic.lib + SHARED_LIB = libdeflate.dll diff --git a/recipes/libdeflate/all/test_package/CMakeLists.txt b/recipes/libdeflate/all/test_package/CMakeLists.txt index 31762006efa77..4fdc2b4814ab3 100644 --- a/recipes/libdeflate/all/test_package/CMakeLists.txt +++ b/recipes/libdeflate/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libdeflate REQUIRED CONFIG) -add_executable(test_package test_package.c) -target_link_libraries(test_package ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libdeflate::libdeflate) diff --git a/recipes/libdeflate/all/test_package/conanfile.py b/recipes/libdeflate/all/test_package/conanfile.py index 5216332f39f5c..e845ae751a301 100644 --- a/recipes/libdeflate/all/test_package/conanfile.py +++ b/recipes/libdeflate/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libdeflate/all/test_v1_package/CMakeLists.txt b/recipes/libdeflate/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/libdeflate/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libdeflate/all/test_v1_package/conanfile.py b/recipes/libdeflate/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libdeflate/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libdeflate/config.yml b/recipes/libdeflate/config.yml index c17e43d16ae03..4a96e3e23227b 100644 --- a/recipes/libdeflate/config.yml +++ b/recipes/libdeflate/config.yml @@ -1,3 +1,13 @@ versions: + "1.14": + folder: all + "1.12": + folder: all + "1.10": + folder: all + "1.9": + folder: all + "1.8": + folder: all "1.7": folder: all diff --git a/recipes/libdisasm/all/conandata.yml b/recipes/libdisasm/all/conandata.yml index af19664fa2f0b..971ffe003e8b2 100644 --- a/recipes/libdisasm/all/conandata.yml +++ b/recipes/libdisasm/all/conandata.yml @@ -5,8 +5,5 @@ sources: patches: "0.23": - patch_file: "patches/0001-fix-size-of-void.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-only-build-libdisasm-by-default.patch" - base_path: "source_subfolder" - patch_file: "patches/0003-libdisasm-no-undefined.patch" - base_path: "source_subfolder" diff --git a/recipes/libdisasm/all/conanfile.py b/recipes/libdisasm/all/conanfile.py index 8b9379a1d2572..8de1232946b5d 100644 --- a/recipes/libdisasm/all/conanfile.py +++ b/recipes/libdisasm/all/conanfile.py @@ -1,6 +1,14 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version import os -from contextlib import contextmanager + +required_conan_version = ">=1.53.0" class LibdisasmConan(ConanFile): @@ -8,30 +16,29 @@ class LibdisasmConan(ConanFile): description = "The libdisasm library provides basic disassembly of Intel x86 instructions from a binary stream." homepage = "http://bastard.sourceforge.net/libdisasm.html" url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "libdisasm", "disassembler", "x86", "asm") + topics = ("disassembler", "x86", "asm") license = "MIT" + settings = "os", "arch", "compiler", "build_type" - generators = "cmake" - exports_sources = "patches/**" options = { "fPIC": [True, False], - "shared": [True, False] + "shared": [True, False], } default_options = { "fPIC": True, - "shared": False + "shared": False, } - _autotools = None + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) @property - def _source_subfolder(self): - return "source_subfolder" + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) - def build_requirements(self): - self.build_requires("libtool/2.4.6") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20190524") + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -39,77 +46,70 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def build_requirements(self): + self.tool_requires("libtool/2.4.7") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = self.name + "-" + self.version - os.rename(extracted_folder, self._source_subfolder) - - @contextmanager - def _build_context(self): - env = {} - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - env.update({ - "CC": "cl -nologo", - "CXX": "cl -nologo", - "CPP": "cl -E -nologo", - "AR": "{} lib".format(self.deps_user_info["automake"].ar_lib.replace("\\", "/")), - "LD": "link -nologo", - "NM": "dumpbin -symbols", - "STRIP": ":", - "RANLIB": ":", - }) - with tools.environment_append(env): - yield - else: - yield - - def _configure_autotools(self): - if self._autotools: - return self._autotools - yes_no = lambda v: "yes" if v else "no" - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.libs = [] - - conf_args = [ - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), - ] - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return self._autotools + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + env = tc.environment() + if is_msvc(self): + ar_wrapper = unix_path(self, self._user_info_build["automake"].ar_lib) + env.define("CC", "cl -nologo") + env.define("CXX", "cl -nologo") + env.define("CPP", "cl -E -nologo") + env.define("LD", "link -nologo") + env.define("AR", f"{ar_wrapper} lib") + env.define("NM", "dumpbin -symbols") + env.define("STRIP", ":") + env.define("RANLIB", ":") + tc.generate(env) def build(self): - for patch in self.conan_data["patches"].get(self.version, []): - tools.patch(**patch) - with tools.chdir(self._source_subfolder): - self.run("autoreconf -fiv", run_environment=True, win_bash=tools.os_info.is_windows) - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() - if self.settings.os != "Windows": - autotools.make(args=["-C", "x86dis"]) + apply_conandata_patches(self) + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() + autotools.make() + if self.settings.os != "Windows": + autotools.make(args=["-C", "x86dis"]) def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() - if self.settings.os != "Windows": - autotools.install(args=["-C", "x86dis"]) - - os.unlink(os.path.join(self.package_folder, "lib", "libdisasm.la")) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + if self.settings.os != "Windows": + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}", "-C", "x86dis"]) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) + if is_msvc(self) and self.options.shared: + dlllib = os.path.join(self.package_folder, "lib", "disasm.dll.lib") + if os.path.exists(dlllib): + rename(self, dlllib, os.path.join(self.package_folder, "lib", "disasm.lib")) def package_info(self): - libname = "disasm" - if self.settings.os == "Windows" and self.options.shared: - libname += ".dll.lib" if self.settings.compiler == "Visual Studio" else ".dll.a" - self.cpp_info.libs = [libname] + self.cpp_info.libs = ["disasm"] if self.settings.os != "Windows": - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/libdisasm/all/test_package/CMakeLists.txt b/recipes/libdisasm/all/test_package/CMakeLists.txt index 34af13462f44f..d243e526c276c 100644 --- a/recipes/libdisasm/all/test_package/CMakeLists.txt +++ b/recipes/libdisasm/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libdisasm REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libdisasm::libdisasm) diff --git a/recipes/libdisasm/all/test_package/conanfile.py b/recipes/libdisasm/all/test_package/conanfile.py index 765177144672d..0a8e988d43472 100644 --- a/recipes/libdisasm/all/test_package/conanfile.py +++ b/recipes/libdisasm/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -class TestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,9 +21,8 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") if self.settings.os != "Windows": - self.run("x86dis -h", run_environment=True) + self.run("x86dis -h", env="conanrun") diff --git a/recipes/libdisasm/all/test_v1_package/CMakeLists.txt b/recipes/libdisasm/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libdisasm/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libdisasm/all/test_v1_package/conanfile.py b/recipes/libdisasm/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..1381fb8880ef2 --- /dev/null +++ b/recipes/libdisasm/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + + if self.settings.os != "Windows": + self.run("x86dis -h", run_environment=True) diff --git a/recipes/libdivide/all/conandata.yml b/recipes/libdivide/all/conandata.yml index b2eda9c3092f3..6b1811615bec8 100644 --- a/recipes/libdivide/all/conandata.yml +++ b/recipes/libdivide/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "5.0": + url: "https://github.com/ridiculousfish/libdivide/archive/refs/tags/5.0.tar.gz" + sha256: "01ffdf90bc475e42170741d381eb9cfb631d9d7ddac7337368bcd80df8c98356" "3.0": url: "https://github.com/ridiculousfish/libdivide/archive/v3.0.tar.gz" sha256: "7c0baed201e78f12f290d3f8c22c974d2fa44aefd9820f8484f7972a431ff264" diff --git a/recipes/libdivide/all/conanfile.py b/recipes/libdivide/all/conanfile.py index c7bf0d29159ba..47e6ad87f66f6 100644 --- a/recipes/libdivide/all/conanfile.py +++ b/recipes/libdivide/all/conanfile.py @@ -1,21 +1,29 @@ from conans import ConanFile, tools -import os +required_conan_version = ">=1.33.0" class LibdivideConan(ConanFile): name = "libdivide" description = "Header-only C/C++ library for optimizing integer division." - topics = ("conan", "libdivide", "division", "integer") + topics = ("libdivide", "division", "integer", ) license = ["Zlib", "BSL-1.0"] homepage = "http://libdivide.com/" url = "https://github.com/conan-io/conan-center-index" settings = "arch", "compiler" no_copy_source = True options = { - "simd_intrinsics": [False, "sse2", "avx2", "avx512"] + "simd_intrinsics": [False, "sse2", "avx2", "avx512"], + "sse2": [True, False], + "avx2": [True, False], + "avx512": [True, False], + "neon": [True, False], } default_options = { - "simd_intrinsics": False + "simd_intrinsics": False, + "sse2": False, + "avx2": False, + "avx512": False, + "neon": False, } @property @@ -23,23 +31,38 @@ def _source_subfolder(self): return "source_subfolder" def config_options(self): - if self.settings.arch not in ["x86", "x86_64"]: + if tools.Version(self.version) < "4.0.0": + del self.options.sse2 + del self.options.avx2 + del self.options.avx512 + del self.options.neon + if self.settings.arch not in ["x86", "x86_64"]: + del self.options.simd_intrinsics + else: del self.options.simd_intrinsics + if self.settings.arch not in ["x86", "x86_64"]: + del self.options.sse2 + del self.options.avx2 + del self.options.avx512 + if not str(self.settings.arch).startswith("arm"): + del self.options.neon def configure(self): - if self.settings.compiler.cppstd: + if tools.Version(self.version) < "4.0.0" and self.settings.compiler.cppstd: tools.check_min_cppstd(self, 11) def package_id(self): self.info.header_only() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def package(self): self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) self.copy("libdivide.h", dst="include", src=self._source_subfolder) + self.copy("constant_fast_div.h", dst="include", src=self._source_subfolder) + self.copy("s16_ldparams.h", dst="include", src=self._source_subfolder) + self.copy("u16_ldparams.h", dst="include", src=self._source_subfolder) def package_info(self): simd = self.options.get_safe("simd_intrinsics", False) @@ -49,3 +72,11 @@ def package_info(self): "avx2": "LIBDIVIDE_AVX2", "avx512": "LIBDIVIDE_AVX512"}[str(simd)] ] + if self.options.get_safe("sse2", False): + self.cpp_info.defines.append("LIBDIVIDE_SSE2") + if self.options.get_safe("avx2", False): + self.cpp_info.defines.append("LIBDIVIDE_AVX2") + if self.options.get_safe("avx512", False): + self.cpp_info.defines.append("LIBDIVIDE_AVX512") + if self.options.get_safe("neon", False): + self.cpp_info.defines.append("LIBDIVIDE_NEON") diff --git a/recipes/libdivide/config.yml b/recipes/libdivide/config.yml index fdd08f532337f..c374cc0645132 100644 --- a/recipes/libdivide/config.yml +++ b/recipes/libdivide/config.yml @@ -1,3 +1,5 @@ versions: + "5.0": + folder: all "3.0": folder: all diff --git a/recipes/libdmtx/all/conandata.yml b/recipes/libdmtx/all/conandata.yml new file mode 100644 index 0000000000000..bf0c94a4bc46b --- /dev/null +++ b/recipes/libdmtx/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "0.7.7": + url: "https://github.com/dmtx/libdmtx/archive/refs/tags/v0.7.7.tar.gz" + sha256: "7aa62adcefdd6e24bdabeb82b3ce41a8d35f4a0c95ab0c4438206aecafd6e1a1" +patches: + "0.7.7": + - patch_file: "patches/0001-0.7.7-fix-version.patch" + patch_description: "update version in CMakeLists.txt" + patch_type: "conan" + - patch_file: "patches/0002-0.7.7-add-install.patch" + patch_description: "add install command to CMakeLists.txt" + patch_type: "conan" diff --git a/recipes/libdmtx/all/conanfile.py b/recipes/libdmtx/all/conanfile.py new file mode 100644 index 0000000000000..3f81f847317dd --- /dev/null +++ b/recipes/libdmtx/all/conanfile.py @@ -0,0 +1,86 @@ +from conan import ConanFile +from conan.tools.files import ( + apply_conandata_patches, + export_conandata_patches, + get, + copy, +) +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +import os + + +required_conan_version = ">=1.53.0" + + +class libdmtxConan(ConanFile): + name = "libdmtx" + description = ( + "software library that enables programs to read" + "and write Data Matrix barcodes of the modern ECC200 variety" + ) + license = "BSD-2-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/dmtx/libdmtx" + topics = ("data matrix", "ECC200", "barcode") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get( + self, + **self.conan_data["sources"][self.version], + destination=self.source_folder, + strip_root=True + ) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy( + self, + pattern="LICENSE", + dst=os.path.join(self.package_folder, "licenses"), + src=self.source_folder, + ) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["dmtx"] + + self.cpp_info.set_property("pkg_config_name", "libdmtx") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/libdmtx/all/patches/0001-0.7.7-fix-version.patch b/recipes/libdmtx/all/patches/0001-0.7.7-fix-version.patch new file mode 100644 index 0000000000000..1e9681706bf43 --- /dev/null +++ b/recipes/libdmtx/all/patches/0001-0.7.7-fix-version.patch @@ -0,0 +1,11 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6420a81..a98e68f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,5 @@ + cmake_minimum_required(VERSION 3.0) +-project(DMTX VERSION 0.7.5 LANGUAGES C) ++project(DMTX VERSION 0.7.7 LANGUAGES C) + + # DMTX library + option(DMTX_SHARED "Build DMTX as shared library" ${BUILD_SHARED_LIBS}) diff --git a/recipes/libdmtx/all/patches/0002-0.7.7-add-install.patch b/recipes/libdmtx/all/patches/0002-0.7.7-add-install.patch new file mode 100644 index 0000000000000..3e2bff94dbde1 --- /dev/null +++ b/recipes/libdmtx/all/patches/0002-0.7.7-add-install.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a98e68f..0531d40 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -19,6 +19,9 @@ else() + target_link_libraries(dmtx PUBLIC -lm) + endif() + ++set_target_properties(dmtx PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/dmtx.h") ++install(TARGETS dmtx LIBRARY ARCHIVE RUNTIME PUBLIC_HEADER) ++ + # Add tests if DMTX is the main project + if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + include(CTest) diff --git a/recipes/libdmtx/all/test_package/CMakeLists.txt b/recipes/libdmtx/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..bfac09c051b74 --- /dev/null +++ b/recipes/libdmtx/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) + +find_package(libdmtx REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libdmtx::libdmtx) diff --git a/recipes/libdmtx/all/test_package/conanfile.py b/recipes/libdmtx/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/libdmtx/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libdmtx/all/test_package/test_package.c b/recipes/libdmtx/all/test_package/test_package.c new file mode 100644 index 0000000000000..76e0814c2514e --- /dev/null +++ b/recipes/libdmtx/all/test_package/test_package.c @@ -0,0 +1,100 @@ +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + size_t width, height, bytesPerPixel; + unsigned char str[] = "30Q324343430794image, DmtxPropWidth); + height = dmtxImageGetProp(enc->image, DmtxPropHeight); + bytesPerPixel = dmtxImageGetProp(enc->image, DmtxPropBytesPerPixel); + + pxl = (unsigned char *)malloc(width * height * bytesPerPixel); + assert(pxl != NULL); + memcpy(pxl, enc->image->pxl, width * height * bytesPerPixel); + + dmtxEncodeDestroy(&enc); + + fprintf(stdout, "width: \"%zd\"\n", width); + fprintf(stdout, "height: \"%zd\"\n", height); + fprintf(stdout, "bpp: \"%zd\"\n", bytesPerPixel); + + for (int i=0; iarraySize : \"%zd\"\n", msg->arraySize ); + fprintf(stdout, "msg->codeSize : \"%zd\"\n", msg->codeSize ); + fprintf(stdout, "msg->outputSize: \"%zd\"\n", msg->outputSize); + int oned = sqrt(msg->arraySize); + for (int i=0; iarraySize; i++){ + fprintf(stdout, " %c.", msg->array[i]); + if (i%oned==oned-1){ + fprintf(stdout, "\n"); + } + } + fprintf(stdout, "\n\n"); + for (int j=0; jcodeSize; j++){ + fprintf(stdout, " %c.", msg->code[j]); + } + fprintf(stdout, "\n\n"); + for (int k=0; koutputSize; k++){ + fprintf(stdout, " %c.", msg->output[k]); + } + fprintf(stdout, "\n\n"); + + if(msg != NULL) { + fputs("output: \"", stdout); + fwrite(msg->output, sizeof(unsigned char), msg->outputIdx, stdout); + fputs("\"\n", stdout); + dmtxMessageDestroy(&msg); + } + dmtxRegionDestroy(®); + } + + dmtxDecodeDestroy(&dec); + dmtxImageDestroy(&img); + free(pxl); + + fprintf(stdout, "%d\n", getSizeIdxFromSymbolDimension(12, 12)); + + exit(0); +} diff --git a/recipes/libdmtx/all/test_v1_package/CMakeLists.txt b/recipes/libdmtx/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..de3b75d9538de --- /dev/null +++ b/recipes/libdmtx/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libdmtx/all/test_v1_package/conanfile.py b/recipes/libdmtx/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/libdmtx/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libdmtx/config.yml b/recipes/libdmtx/config.yml new file mode 100644 index 0000000000000..356debf98276f --- /dev/null +++ b/recipes/libdmtx/config.yml @@ -0,0 +1,3 @@ +versions: + "0.7.7": + folder: all diff --git a/recipes/libdrm/all/conandata.yml b/recipes/libdrm/all/conandata.yml new file mode 100644 index 0000000000000..385cbe1979841 --- /dev/null +++ b/recipes/libdrm/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.4.109": + url: "https://dri.freedesktop.org/libdrm/libdrm-2.4.109.tar.xz" + sha256: "629352e08c1fe84862ca046598d8a08ce14d26ab25ee1f4704f993d074cb7f26" diff --git a/recipes/libdrm/all/conanfile.py b/recipes/libdrm/all/conanfile.py new file mode 100644 index 0000000000000..cbc5ff81fd540 --- /dev/null +++ b/recipes/libdrm/all/conanfile.py @@ -0,0 +1,173 @@ +import os +import re + +from conans import ConanFile, Meson, tools +from conans.errors import ConanInvalidConfiguration + + +class LibdrmConan(ConanFile): + name = "libdrm" + description = "User space library for accessing the Direct Rendering Manager, on operating systems that support the ioctl interface" + topics = ("libdrm", "graphics") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gitlab.freedesktop.org/mesa/drm" + license = "MIT" + generators = "PkgConfigDeps" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "libkms": [True, False], + "intel": [True, False], + "radeon": [True, False], + "amdgpu": [True, False], + "nouveau": [True, False], + "vmwgfx": [True, False], + "omap": [True, False], + "exynos": [True, False], + "freedreno": [True, False], + "tegra": [True, False], + "vc4": [True, False], + "etnaviv": [True, False], + "valgrind": [True, False], + "freedreno-kgsl": [True, False], + "udev": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "libkms": True, + "intel": True, + "radeon": True, + "amdgpu": True, + "nouveau": True, + "vmwgfx": True, + "omap": False, + "exynos": False, + "freedreno": True, + "tegra": False, + "vc4": True, + "etnaviv": False, + "valgrind": False, + "freedreno-kgsl": False, + "udev": False + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def build_requirements(self): + self.build_requires("meson/0.59.0") + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.options.intel: + self.requires("libpciaccess/0.16") + if self.settings.os == "Linux": + self.requires("linux-headers-generic/5.14.9") + + def validate(self): + if self.settings.os not in ["Linux", "FreeBSD"]: + raise ConanInvalidConfiguration("libdrm supports only Linux or FreeBSD") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + def _configure_meson(self): + meson = Meson(self) + + defs={ + "cairo-tests" : "false", + "install-test-programs": "false" + } + for o in ["libkms", "intel", "radeon", "amdgpu","nouveau", "vmwgfx", "omap", "exynos", + "freedreno", "tegra", "vc4", "etnaviv", "valgrind", "freedreno-kgsl", "udev"]: + defs[o] = "true" if getattr(self.options, o) else "false" + + defs["datadir"] = os.path.join(self.package_folder, "res") + defs["mandir"] = os.path.join(self.package_folder, "res", "man") + + meson.configure( + defs = defs, + source_folder=self._source_subfolder, + build_folder=self._build_subfolder) + return meson + + def build(self): + meson = self._configure_meson() + meson.build() + + def package(self): + meson = self._configure_meson() + meson.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.mkdir(os.path.join(self.package_folder, "licenses")) + # Extract the License/s from the header to a file + tmp = tools.load(os.path.join(self._source_subfolder, "include", "drm", "drm.h")) + license_contents = re.search("\*\/.*(\/\*(\*(?!\/)|[^*])*\*\/)", tmp, re.DOTALL)[1] + tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), license_contents) + + def package_info(self): + self.cpp_info.components["libdrm_libdrm"].libs = ["drm"] + self.cpp_info.components["libdrm_libdrm"].includedirs.append(os.path.join('include', 'libdrm')) + self.cpp_info.components["libdrm_libdrm"].set_property("pkg_config_name", "libdrm") + if self.settings.os == "Linux": + self.cpp_info.components["libdrm_libdrm"].requires = ["linux-headers-generic::linux-headers-generic"] + + if self.options.libkms: + self.cpp_info.components["libdrm_libkms"].libs = ["kms"] + self.cpp_info.components["libdrm_libkms"].includedirs.append(os.path.join('include', 'libkms')) + self.cpp_info.components["libdrm_libkms"].requires = ["libdrm_libdrm"] + self.cpp_info.components["libdrm_libkms"].set_property("pkg_config_name", "libkms") + + if self.options.vc4: + self.cpp_info.components["libdrm_vc4"].requires = ["libdrm_libdrm"] + self.cpp_info.components["libdrm_vc4"].set_property("pkg_config_name", "libdrm_vc4") + + if self.options.freedreno: + self.cpp_info.components["libdrm_freedreno"].libs = ["drm_freedreno"] + self.cpp_info.components["libdrm_freedreno"].includedirs.append(os.path.join('include', 'libdrm')) + self.cpp_info.components["libdrm_freedreno"].includedirs.append(os.path.join('include', 'freedreno')) + self.cpp_info.components["libdrm_freedreno"].requires = ["libdrm_libdrm"] + self.cpp_info.components["libdrm_freedreno"].set_property("pkg_config_name", "libdrm_freedreno") + + if self.options.amdgpu: + self.cpp_info.components["libdrm_amdgpu"].libs = ["drm_amdgpu"] + self.cpp_info.components["libdrm_amdgpu"].includedirs.append(os.path.join('include', 'libdrm')) + self.cpp_info.components["libdrm_amdgpu"].requires = ["libdrm_libdrm"] + self.cpp_info.components["libdrm_amdgpu"].set_property("pkg_config_name", "libdrm_amdgpu") + + if self.options.nouveau: + self.cpp_info.components["libdrm_nouveau"].libs = ["drm_nouveau"] + self.cpp_info.components["libdrm_nouveau"].includedirs.append(os.path.join('include', 'libdrm')) + self.cpp_info.components["libdrm_nouveau"].requires = ["libdrm_libdrm"] + self.cpp_info.components["libdrm_nouveau"].set_property("pkg_config_name", "libdrm_nouveau") + + if self.options.intel: + self.cpp_info.components["libdrm_intel"].libs = ["drm_intel"] + self.cpp_info.components["libdrm_intel"].includedirs.append(os.path.join('include', 'libdrm')) + self.cpp_info.components["libdrm_intel"].requires = ["libdrm_libdrm", "libpciaccess::libpciaccess"] + self.cpp_info.components["libdrm_intel"].set_property("pkg_config_name", "libdrm_intel") + + if self.options.radeon: + self.cpp_info.components["libdrm_radeon"].libs = ["drm_radeon"] + self.cpp_info.components["libdrm_radeon"].includedirs.append(os.path.join('include', 'libdrm')) + self.cpp_info.components["libdrm_radeon"].requires = ["libdrm_libdrm"] + self.cpp_info.components["libdrm_radeon"].set_property("pkg_config_name", "libdrm_radeon") + diff --git a/recipes/libdrm/all/test_package/CMakeLists.txt b/recipes/libdrm/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..afa2476357074 --- /dev/null +++ b/recipes/libdrm/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libdrm/all/test_package/conanfile.py b/recipes/libdrm/all/test_package/conanfile.py new file mode 100644 index 0000000000000..8e9e5fdc7aa40 --- /dev/null +++ b/recipes/libdrm/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + diff --git a/recipes/libdrm/all/test_package/test_package.c b/recipes/libdrm/all/test_package/test_package.c new file mode 100644 index 0000000000000..9de39b71a65f1 --- /dev/null +++ b/recipes/libdrm/all/test_package/test_package.c @@ -0,0 +1,11 @@ +#include +#include "xf86drm.h" + +int main() +{ + drmVersionPtr v = drmGetLibVersion(0); + printf("drm version: %d.%d.%d\n", v->version_major, v->version_minor, v->version_patchlevel); + drmFree(v); + printf("drm available: %d\n", drmAvailable()); + return 0; +} diff --git a/recipes/libdrm/config.yml b/recipes/libdrm/config.yml new file mode 100644 index 0000000000000..4beea198f8d48 --- /dev/null +++ b/recipes/libdrm/config.yml @@ -0,0 +1,3 @@ +versions: + "2.4.109": + folder: all diff --git a/recipes/libdwarf/all/CMakeLists.txt b/recipes/libdwarf/all/CMakeLists.txt index 592ca7ee64c2e..d1aa8859c14ba 100644 --- a/recipes/libdwarf/all/CMakeLists.txt +++ b/recipes/libdwarf/all/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4.3) project(conan_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +conan_basic_setup(TARGETS KEEP_RPATHS) if (WIN32 AND BUILD_SHARED_LIBS) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) diff --git a/recipes/libdwarf/all/conanfile.py b/recipes/libdwarf/all/conanfile.py index 27e3c352c39e6..f752998831935 100644 --- a/recipes/libdwarf/all/conanfile.py +++ b/recipes/libdwarf/all/conanfile.py @@ -1,20 +1,29 @@ from conans import ConanFile, CMake, tools +import functools import os +required_conan_version = ">=1.33.0" + class LibdwarfConan(ConanFile): name = "libdwarf" description = "A library and a set of command-line tools for reading and writing DWARF2" - topics = ("conan", "libdwarf", "dwarf2", "debugging", "dwarf") + topics = ("libdwarf", "dwarf2", "debugging", "dwarf") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.prevanders.net/dwarf.html" license = "LGPL-2.1" - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - requires = ("libelf/0.8.13", "zlib/1.2.11") + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "cmake" @property def _source_subfolder(self): @@ -24,32 +33,45 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def requirements(self): + self.requires("libelf/0.8.13") + self.requires("zlib/1.2.12") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + @functools.lru_cache(1) def _configure_cmake(self): cmake = CMake(self) cmake.definitions["BUILD_NON_SHARED"] = not self.options.shared cmake.definitions["BUILD_SHARED"] = self.options.shared cmake.definitions["BUILD_DWARFGEN"] = False cmake.definitions["BUILD_DWARFEXAMPLE"] = False + if tools.cross_building(self): + cmake.definitions["HAVE_UNUSED_ATTRIBUTE_EXITCODE"] = "0" + cmake.definitions["HAVE_UNUSED_ATTRIBUTE_EXITCODE__TRYRUN_OUTPUT"] = "" cmake.configure(build_folder=self._build_subfolder) return cmake def build(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - tools.mkdir(os.path.join(self.build_folder, self._build_subfolder)) cmake = self._configure_cmake() cmake.build() @@ -57,8 +79,6 @@ def package(self): self.copy(pattern="COPYING", dst="licenses", src=os.path.join(self._source_subfolder, "libdwarf")) cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "res")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["dwarf"] diff --git a/recipes/libdwarf/all/test_package/CMakeLists.txt b/recipes/libdwarf/all/test_package/CMakeLists.txt index 34af13462f44f..d46ff25d16814 100644 --- a/recipes/libdwarf/all/test_package/CMakeLists.txt +++ b/recipes/libdwarf/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(libdwarf REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} libdwarf::libdwarf) diff --git a/recipes/libdwarf/all/test_package/conanfile.py b/recipes/libdwarf/all/test_package/conanfile.py index bd7165a553cf4..38f4483872d47 100644 --- a/recipes/libdwarf/all/test_package/conanfile.py +++ b/recipes/libdwarf/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libe57format/all/conandata.yml b/recipes/libe57format/all/conandata.yml new file mode 100644 index 0000000000000..857bfbb53a2a6 --- /dev/null +++ b/recipes/libe57format/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "2.2.0": + sha256: "19df04af07925bf43e1793534b0c77cb1346a2bee7746859d2fe1714a24f1c7d" + url: "https://github.com/asmaloney/libE57Format/archive/refs/tags/v2.2.0.tar.gz" + "2.3.0": + sha256: "124cc8f7dda84e8686ff2bcffc524ee4677eba3183631ec847a5f4a6ea60b254" + url: "https://github.com/asmaloney/libE57Format/archive/refs/tags/v2.3.0.tar.gz" +patches: + "2.2.0": + - patch_file: "patches/0001-fix-pic.patch" + - patch_file: "patches/0002-missing-include.patch" + "2.3.0": + - patch_file: "patches/2.3.0-0001-fix-pic.patch" diff --git a/recipes/libe57format/all/conanfile.py b/recipes/libe57format/all/conanfile.py new file mode 100644 index 0000000000000..479e129d3bbf3 --- /dev/null +++ b/recipes/libe57format/all/conanfile.py @@ -0,0 +1,111 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save +import os +import textwrap + +required_conan_version = ">=1.52.0" + + +class LibE57FormatConan(ConanFile): + name = "libe57format" + license = "BSL-1.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/asmaloney/libE57Format" + description = "Library for reading & writing the E57 file format" + topics = ("e57", "io", "point-cloud") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("xerces-c/3.2.3") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, "11") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["USING_STATIC_XERCES"] = not self.dependencies["xerces-c"].options.shared + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"E57Format": "E57Format::E57Format"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "e57format") + self.cpp_info.set_property("cmake_target_name", "E57Format") + suffix = "-d" if self.settings.build_type == "Debug" else "" + self.cpp_info.libs = [f"E57Format{suffix}"] + if self.settings.os in ["Linux", "FreeBSD"] and not self.options.shared: + self.cpp_info.system_libs.extend(["m", "pthread"]) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.filenames["cmake_find_package"] = "e57format" + self.cpp_info.filenames["cmake_find_package_multi"] = "e57format" + self.cpp_info.names["cmake_find_package"] = "E57Format" + self.cpp_info.names["cmake_find_package_multi"] = "E57Format" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/libe57format/all/patches/0001-fix-pic.patch b/recipes/libe57format/all/patches/0001-fix-pic.patch new file mode 100644 index 0000000000000..76ed8c2509a69 --- /dev/null +++ b/recipes/libe57format/all/patches/0001-fix-pic.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -104,7 +104,6 @@ + CXX_STANDARD_REQUIRED YES + CXX_EXTENSIONS NO + DEBUG_POSTFIX "-d" +- POSITION_INDEPENDENT_CODE ON + ) + + # Target definitions diff --git a/recipes/libe57format/all/patches/0002-missing-include.patch b/recipes/libe57format/all/patches/0002-missing-include.patch new file mode 100644 index 0000000000000..50253b05d6c2a --- /dev/null +++ b/recipes/libe57format/all/patches/0002-missing-include.patch @@ -0,0 +1,11 @@ +--- a/src/E57XmlParser.cpp ++++ b/src/E57XmlParser.cpp +@@ -42,6 +42,8 @@ + #include "StringNodeImpl.h" + #include "VectorNodeImpl.h" + ++#include ++ + using namespace e57; + using namespace XERCES_CPP_NAMESPACE; + diff --git a/recipes/libe57format/all/patches/2.3.0-0001-fix-pic.patch b/recipes/libe57format/all/patches/2.3.0-0001-fix-pic.patch new file mode 100644 index 0000000000000..a2ecc0de60e33 --- /dev/null +++ b/recipes/libe57format/all/patches/2.3.0-0001-fix-pic.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -127,7 +127,6 @@ + CXX_STANDARD_REQUIRED YES + CXX_EXTENSIONS NO + DEBUG_POSTFIX "-d" +- POSITION_INDEPENDENT_CODE ON + ) + + # Target definitions diff --git a/recipes/libe57format/all/test_package/CMakeLists.txt b/recipes/libe57format/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b8de16fa4046c --- /dev/null +++ b/recipes/libe57format/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(e57format REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE E57Format) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libe57format/all/test_package/conanfile.py b/recipes/libe57format/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libe57format/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libe57format/all/test_package/test_package.cpp b/recipes/libe57format/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..25f1f5f3bc705 --- /dev/null +++ b/recipes/libe57format/all/test_package/test_package.cpp @@ -0,0 +1,19 @@ +#include +#include +#include +#include + +int main() { + e57::Writer writer("file.e57"); + e57::Image2D image_header; + std::int64_t index = writer.NewImage2D(image_header); + std::vector image_bytes(100, 1); + std::int64_t n_bytes = writer.WriteImage2DData(index, e57::E57_JPEG_IMAGE, e57::E57_NO_PROJECTION, + image_bytes.data(), 0, image_bytes.size()); + + try { + e57::Reader reader("invalid-file.e57"); + } catch (const e57::E57Exception& e) { } + + return 0; +} diff --git a/recipes/libe57format/all/test_v1_package/CMakeLists.txt b/recipes/libe57format/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2bf6344a5bafd --- /dev/null +++ b/recipes/libe57format/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(e57format REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE E57Format) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libe57format/all/test_v1_package/conanfile.py b/recipes/libe57format/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libe57format/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libe57format/config.yml b/recipes/libe57format/config.yml new file mode 100644 index 0000000000000..137671316c059 --- /dev/null +++ b/recipes/libe57format/config.yml @@ -0,0 +1,5 @@ +versions: + "2.2.0": + folder: all + "2.3.0": + folder: all diff --git a/recipes/libelf/all/CMakeLists.txt b/recipes/libelf/all/CMakeLists.txt index e3e916bf47bb7..272a6d59618a2 100644 --- a/recipes/libelf/all/CMakeLists.txt +++ b/recipes/libelf/all/CMakeLists.txt @@ -1,33 +1,31 @@ cmake_minimum_required(VERSION 3.4) -project(elf C) +project(elf LANGUAGES C) -include(conanbuildinfo.cmake) -conan_basic_setup() - -if(EXISTS "${PROJECT_SOURCE_DIR}/source_subfolder/lib/sys_elf.h.w32") - file(RENAME "${PROJECT_SOURCE_DIR}/source_subfolder/lib/sys_elf.h.w32" "${PROJECT_SOURCE_DIR}/source_subfolder/lib/sys_elf.h") - file(RENAME "${PROJECT_SOURCE_DIR}/source_subfolder/lib/config.h.w32" "${PROJECT_SOURCE_DIR}/source_subfolder/config.h") +if(EXISTS "${LIBELF_SRC_DIR}/lib/sys_elf.h.w32") + file(RENAME "${LIBELF_SRC_DIR}/lib/sys_elf.h.w32" "${LIBELF_SRC_DIR}/lib/sys_elf.h") + file(RENAME "${LIBELF_SRC_DIR}/lib/config.h.w32" "${LIBELF_SRC_DIR}/config.h") endif() -file(GLOB_RECURSE SOURCES "source_subfolder/lib/*.c") -file(GLOB_RECURSE HEADERS "source_subfolder/lib/*.h") +file(GLOB_RECURSE SOURCES "${LIBELF_SRC_DIR}/lib/*.c") +file(GLOB_RECURSE HEADERS "${LIBELF_SRC_DIR}/lib/*.h") add_library(${PROJECT_NAME} ${SOURCES}) -set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${HEADERS}") -target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "source_subfolder/lib") +set_target_properties(${PROJECT_NAME} PROPERTIES + PUBLIC_HEADER "${HEADERS}" + WINDOWS_EXPORT_ALL_SYMBOLS TRUE +) +target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${LIBELF_SRC_DIR}/lib") target_compile_definitions(${PROJECT_NAME} PUBLIC HAVE_MEMCMP=1 HAVE_MEMCPY=1 HAVE_MEMMOVE=1) -if(MSVC AND BUILD_SHARED_LIBS) - set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) -endif() +include(GNUInstallDirs) install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - PUBLIC_HEADER DESTINATION include/libelf + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libelf ) -install(FILES "source_subfolder/lib/libelf.h" DESTINATION include) -install(FILES "source_subfolder/lib/gelf.h" DESTINATION include) -install(FILES "source_subfolder/lib/nlist.h" DESTINATION include) +install(FILES "${LIBELF_SRC_DIR}/lib/libelf.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES "${LIBELF_SRC_DIR}/lib/gelf.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES "${LIBELF_SRC_DIR}/lib/nlist.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/libelf/all/conanfile.py b/recipes/libelf/all/conanfile.py index ed3d59e4f0144..eb3ec50947bff 100644 --- a/recipes/libelf/all/conanfile.py +++ b/recipes/libelf/all/conanfile.py @@ -1,7 +1,14 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, replace_in_file, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import unix_path import os -import shutil + +required_conan_version = ">=1.53.0" class LibelfConan(ConanFile): @@ -10,23 +17,23 @@ class LibelfConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://directory.fsf.org/wiki/Libelf" license = "LGPL-2.0" - topics = ("conan", "elf", "fsf", "libelf", "object-file") - exports_sources = "CMakeLists.txt" - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + topics = ("elf", "fsf", "libelf", "object-file") - _autotools = None - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + exports_sources = "CMakeLists.txt" @property - def _build_subfolder(self): - return "build_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): if self.settings.os == "Windows": @@ -34,89 +41,86 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.options.shared and self.settings.os not in ["Linux", "Windows"]: - raise ConanInvalidConfiguration("libelf can not be built as shared library on non linux or windows platforms") + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + if self.settings.os == "Windows": + cmake_layout(self, src_folder="src") + else: + basic_layout(self, src_folder="src") + + def validate(self): + if self.info.options.shared and self.info.settings.os not in ["Linux", "FreeBSD", "Windows"]: + raise ConanInvalidConfiguration("libelf can not be built as shared library on non linux/FreeBSD/windows platforms") def build_requirements(self): if self.settings.os != "Windows": - self.build_requires("autoconf/2.69") - self.build_requires("gnu-config/cci.20201022") + self.tool_requires("autoconf/2.71") + self.tool_requires("gnu-config/cci.20210814") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def _build_cmake(self): - cmake = self._configure_cmake() - cmake.build() - - def _package_cmake(self): - cmake = self._configure_cmake() - cmake.install() - - def _configure_autotools(self): - if self._autotools: - return self._autotools - with tools.chdir(self._source_subfolder): - self.run("autoreconf -fiv", run_environment=True) - args = ["--enable-shared={}".format("yes" if self.options.shared else "no")] - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.configure(configure_dir=self._source_subfolder, args=args) - return self._autotools - - def _build_autotools(self): - autotools = self._configure_autotools() - autotools.make() - - def _package_autotools(self): - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "locale")) - if self.settings.os == "Linux" and self.options.shared: - os.remove(os.path.join(self.package_folder, "lib", "libelf.a")) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - @property - def _user_info_build(self): - # If using the experimental feature with different context for host and - # build, the 'user_info' attributes of the 'build_requires' packages - # will be located into the 'user_info_build' object. In other cases they - # will be located into the 'deps_user_info' object. - return getattr(self, "user_info_build", None) or self.deps_user_info + def generate(self): + if self.settings.os == "Windows": + tc = CMakeToolchain(self) + tc.variables["LIBELF_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + else: + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ + # it's required, libelf doesnt seem to understand DESTDIR + f"--prefix={unix_path(self, self.package_folder)}", + ]) + tc.generate() def build(self): if self.settings.os == "Windows": - self._build_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() else: - tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "Makefile.in"), + replace_in_file(self, os.path.join(self.source_folder, "lib", "Makefile.in"), "$(LINK_SHLIB)", "$(LINK_SHLIB) $(LDFLAGS)") # libelf sources contains really outdated 'config.sub' and # 'config.guess' files. It not allows to build libelf for armv8 arch. - shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, - os.path.join(self._source_subfolder, "config.sub")) - shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, - os.path.join(self._source_subfolder, "config.guess")) - self._build_autotools() + for gnu_config in [ + self.conf.get("user.gnu-config:config_guess", check_type=str), + self.conf.get("user.gnu-config:config_sub", check_type=str), + ]: + if gnu_config: + copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder) + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() + autotools.make() def package(self): - self.copy(pattern="COPYING.LIB", dst="licenses", src=self._source_subfolder) + copy(self, "COPYING.LIB", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) if self.settings.os == "Windows": - self._package_cmake() + cmake = CMake(self) + cmake.install() else: - self._package_autotools() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "lib", "locale")) + if self.options.shared: + rm(self, "*.a", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("pkg_config_name", "libelf") + self.cpp_info.libs = ["elf"] + self.cpp_info.includedirs.append(os.path.join("include", "libelf")) diff --git a/recipes/libelf/all/test_package/CMakeLists.txt b/recipes/libelf/all/test_package/CMakeLists.txt index 7b9b613cbb24a..715677f6fc466 100644 --- a/recipes/libelf/all/test_package/CMakeLists.txt +++ b/recipes/libelf/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libelf REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libelf::libelf) diff --git a/recipes/libelf/all/test_package/conanfile.py b/recipes/libelf/all/test_package/conanfile.py index bd7165a553cf4..0a6bc68712d90 100644 --- a/recipes/libelf/all/test_package/conanfile.py +++ b/recipes/libelf/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libelf/all/test_package/test_package.c b/recipes/libelf/all/test_package/test_package.c index 1790ff3df6e20..2cf36fdf9b081 100644 --- a/recipes/libelf/all/test_package/test_package.c +++ b/recipes/libelf/all/test_package/test_package.c @@ -34,6 +34,52 @@ int main(int argc , char **argv) { return EXIT_FAILURE; } + if(ELF_C_NULL != 0) + { + printf("ELF_C_NULL has wrong value: %d\n", ELF_C_NULL); + return EXIT_FAILURE; + } + if(ELF_C_READ != 1) + { + printf("ELF_C_READ has wrong value: %d\n", ELF_C_READ); + return EXIT_FAILURE; + } + if(ELF_C_WRITE != 2) + { + printf("ELF_C_WRITE has wrong value: %d\n", ELF_C_WRITE); + return EXIT_FAILURE; + } + if(ELF_C_CLR != 3) + { + printf("ELF_C_CLR has wrong value: %d\n", ELF_C_CLR); + return EXIT_FAILURE; + } + if(ELF_C_SET != 4) + { + printf("ELF_C_SET has wrong value: %d\n", ELF_C_SET); + return EXIT_FAILURE; + } + if(ELF_C_FDDONE != 5) + { + printf("ELF_C_FDDONE has wrong value: %d\n", ELF_C_FDDONE); + return EXIT_FAILURE; + } + if(ELF_C_FDREAD != 6) + { + printf("ELF_C_FDREAD has wrong value: %d\n", ELF_C_FDREAD); + return EXIT_FAILURE; + } + if(ELF_C_RDWR != 7) + { + printf("ELF_C_RDWR has wrong value: %d\n", ELF_C_RDWR); + return EXIT_FAILURE; + } + if(ELF_C_NUM != 8) + { + printf("ELF_C_NUM has wrong value: %d\n", ELF_C_NUM); + return EXIT_FAILURE; + } + if ((e = elf_begin(fd, ELF_C_READ, NULL)) == NULL) { printf("elf_begin () failed: %s.\n", elf_errmsg ( -1)); return EXIT_FAILURE; diff --git a/recipes/libelf/all/test_v1_package/CMakeLists.txt b/recipes/libelf/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libelf/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libelf/all/test_v1_package/conanfile.py b/recipes/libelf/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libelf/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libepoxy/all/conandata.yml b/recipes/libepoxy/all/conandata.yml index 05f3e75981e4a..8af7ed3d62897 100644 --- a/recipes/libepoxy/all/conandata.yml +++ b/recipes/libepoxy/all/conandata.yml @@ -1,10 +1,20 @@ sources: - "1.5.7": - url: "https://github.com/anholt/libepoxy/archive/1.5.7.tar.gz" - sha256: "b9e22ba707d0e723e9665c67a2b2974a86f4c4c27e3009dde24a988d1aadf643" - "1.5.5": - url: "https://github.com/anholt/libepoxy/archive/1.5.5.tar.gz" - sha256: "5d80a43a6524a1ebdd0c9c5d5105295546a0794681853c636a0c70f8f9c658ce" - "1.5.4": - sha256: "0bd2cc681dfeffdef739cb29913f8c3caa47a88a451fd2bc6e606c02997289d2" - url: "https://github.com/anholt/libepoxy/releases/download/1.5.4/libepoxy-1.5.4.tar.xz" + "1.5.10": + url: "https://github.com/anholt/libepoxy/archive/1.5.10.tar.gz" + sha256: "a7ced37f4102b745ac86d6a70a9da399cc139ff168ba6b8002b4d8d43c900c15" + "1.5.9": + url: "https://github.com/anholt/libepoxy/archive/1.5.9.tar.gz" + sha256: "ee8048d20179a2e86156ac842ddb6428732d9cd7a2cfc2eca905165bf24887a2" + "1.5.8": + url: "https://github.com/anholt/libepoxy/archive/1.5.8.tar.gz" + sha256: "0cd80cb040b75cbe77fadd45c48282ebab82d845c597ce11ee5e8cb9c1efeabb" +patches: + "1.5.10": + - patch_file: "patches/0001-fix-for-building-on-non-English-locale.patch" + base_path: "source_subfolder" + "1.5.9": + - patch_file: "patches/0001-fix-for-building-on-non-English-locale.patch" + base_path: "source_subfolder" + "1.5.8": + - patch_file: "patches/0001-fix-for-building-on-non-English-locale.patch" + base_path: "source_subfolder" diff --git a/recipes/libepoxy/all/conanfile.py b/recipes/libepoxy/all/conanfile.py index c3c507a4ab7a1..7ed5cc659089e 100644 --- a/recipes/libepoxy/all/conanfile.py +++ b/recipes/libepoxy/all/conanfile.py @@ -1,13 +1,16 @@ -from conans import ConanFile, Meson, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import files, build +from conans import Meson, tools import os import glob +required_conan_version = ">=1.50.0" class EpoxyConan(ConanFile): name = "libepoxy" description = "libepoxy is a library for handling OpenGL function pointer management" - topics = ("conan", "libepoxy", "opengl") + topics = ("libepoxy", "opengl") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/anholt/libepoxy" license = "MIT" @@ -28,27 +31,33 @@ class EpoxyConan(ConanFile): "egl": True, "x11": True } - - required_conan_version = ">=1.33.0" _meson = None - + @property def _source_subfolder(self): return "source_subfolder" - + @property def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd if self.options.shared: del self.options.fPIC + + def validate(self): if self.settings.os == "Windows": if not self.options.shared: raise ConanInvalidConfiguration("Static builds on Windows are not supported") + if hasattr(self, "settings_build") and build.cross_building(self): + raise ConanInvalidConfiguration("meson build helper cannot cross-compile. It has to be migrated to conan.tools.meson") def config_options(self): if self.settings.os == "Windows": @@ -60,7 +69,7 @@ def config_options(self): del self.options.x11 def build_requirements(self): - self.build_requires("meson/0.57.1") + self.build_requires("meson/0.63.1") def requirements(self): self.requires("opengl/system") @@ -71,7 +80,7 @@ def requirements(self): self.requires("egl/system") def source(self): - tools.get(**self.conan_data["sources"][self.version], + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def _configure_meson(self): @@ -91,6 +100,7 @@ def _configure_meson(self): return self._meson def build(self): + files.apply_conandata_patches(self) with tools.environment_append(tools.RunEnvironment(self).vars): meson = self._configure_meson() meson.build() @@ -99,7 +109,7 @@ def package(self): self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) meson = self._configure_meson() meson.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) for pdb_file in glob.glob(os.path.join(self.package_folder, "bin", "*.pdb")): os.unlink(pdb_file) @@ -108,3 +118,12 @@ def package_info(self): if self.settings.os == "Linux": self.cpp_info.system_libs = ["dl"] self.cpp_info.names["pkg_config"] = "epoxy" + + pkgconfig_variables = { + 'epoxy_has_glx': '1' if self.options.get_safe("glx") else '0', + 'epoxy_has_egl': '1' if self.options.get_safe("egl") else '0', + 'epoxy_has_wgl': '1' if self.settings.os == "Windows" else '0', + } + self.cpp_info.set_property( + "pkg_config_custom_content", + "\n".join(f"{key}={value}" for key,value in pkgconfig_variables.items())) diff --git a/recipes/libepoxy/all/patches/0001-fix-for-building-on-non-English-locale.patch b/recipes/libepoxy/all/patches/0001-fix-for-building-on-non-English-locale.patch new file mode 100644 index 0000000000000..d46502b06b34f --- /dev/null +++ b/recipes/libepoxy/all/patches/0001-fix-for-building-on-non-English-locale.patch @@ -0,0 +1,23 @@ +Revision: a07b9b33832df2261ace6b84e6a041d14e390a75 +Author: Seungha Yang +Date: 2021/10/12 1:41:41 +Message: +meson: Fix for building on non-English locale + +Specify utf-8 encoding to fix building on non-English locale + +diff --git a/meson.build b/meson.build +index e0228d1..182a3c9 100644 +--- a/meson.build ++++ b/meson.build +@@ -95,6 +95,7 @@ if cc.get_id() == 'msvc' + '-we4053', # an expression of type void was used as an operand + '-we4071', # no function prototype given + '-we4819', # the file contains a character that cannot be represented in the current code page ++ '/utf-8', # Set the input and exec encoding to utf-8, like is the default with GCC + ] + elif cc.get_id() == 'gcc' or cc.get_id() == 'clang' + test_cflags = [ +-- +2.35.1.windows.2 + diff --git a/recipes/libepoxy/config.yml b/recipes/libepoxy/config.yml index 8ceff3d333b4d..44f12cc4cf91c 100644 --- a/recipes/libepoxy/config.yml +++ b/recipes/libepoxy/config.yml @@ -1,7 +1,7 @@ versions: - "1.5.7": + "1.5.10": folder: all - "1.5.5": + "1.5.9": folder: all - "1.5.4": + "1.5.8": folder: all diff --git a/recipes/libest/all/conandata.yml b/recipes/libest/all/conandata.yml index 34df9a6566a5e..b9d0db8b23c2b 100644 --- a/recipes/libest/all/conandata.yml +++ b/recipes/libest/all/conandata.yml @@ -1,8 +1,10 @@ sources: "3.2.0": - sha256: 324b3a2b16cd14ea4234d75fa90f08b29509bac9cd3795c44268e22f906ee0ad - url: https://github.com/cisco/libest/archive/r3.2.0.tar.gz + url: "https://github.com/cisco/libest/archive/r3.2.0.tar.gz" + sha256: "324b3a2b16cd14ea4234d75fa90f08b29509bac9cd3795c44268e22f906ee0ad" patches: "3.2.0": - patch_file: "patches/0001-examples-are-broken-don-t-build-them.patch" base_path: "source_subfolder" + - patch_file: "patches/0002-add-extern.patch" + base_path: "source_subfolder" diff --git a/recipes/libest/all/conanfile.py b/recipes/libest/all/conanfile.py index e276706b74086..c3b2b423c3d32 100644 --- a/recipes/libest/all/conanfile.py +++ b/recipes/libest/all/conanfile.py @@ -39,7 +39,7 @@ def configure(self): del self.settings.compiler.cppstd def requirements(self): - self.requires("openssl/1.1.1g") + self.requires("openssl/1.1.1q") def source(self): tools.get(**self.conan_data["sources"][self.version]) diff --git a/recipes/libest/all/patches/0002-add-extern.patch b/recipes/libest/all/patches/0002-add-extern.patch new file mode 100644 index 0000000000000..f33a51e7c7b76 --- /dev/null +++ b/recipes/libest/all/patches/0002-add-extern.patch @@ -0,0 +1,13 @@ +diff --git a/src/est/est_locl.h b/src/est/est_locl.h +index 62dcbea..b16f62d 100644 +--- a/src/est/est_locl.h ++++ b/src/est/est_locl.h +@@ -590,7 +590,7 @@ typedef struct est_oid_list { + /* + * Index used to link the EST Ctx into the SSL structures + */ +-int e_ctx_ssl_exdata_index; ++extern int e_ctx_ssl_exdata_index; + + LIBEST_TEST_API void est_log (EST_LOG_LEVEL lvl, char *format, ...); + LIBEST_TEST_API void est_log_backtrace (void); diff --git a/recipes/libev/all/conanfile.py b/recipes/libev/all/conanfile.py index 877b6ebdf54d8..bb35d60681a03 100644 --- a/recipes/libev/all/conanfile.py +++ b/recipes/libev/all/conanfile.py @@ -1,16 +1,24 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path import os +required_conan_version = ">=1.53.0" + class LibevConan(ConanFile): name = "libev" - description = "A full-featured and high-performance event loop that is loosely modelled after libevent" - topics = ("conan", "event", "libev", "event-loop", "periodic-timer", "notify") + topics = ("event", "event-loop", "periodic-timer", "notify") url = "https://github.com/conan-io/conan-center-index" homepage = "http://software.schmorp.de/pkg/libev.html" license = ["BSD-2-Clause", "GPL-2.0-or-later"] + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -21,61 +29,63 @@ class LibevConan(ConanFile): "fPIC": True, } - _autotools = None - @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("libev is not supported by Visual Studio") - if self.settings.os == "Windows" and self.options.shared: - # libtool: error: can't build i686-pc-mingw32 shared library unless -no-undefined is specified - raise ConanInvalidConfiguration("libev can't be built as shared on Windows") + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "libev-{0}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} is not supported by Visual Studio") + if self.info.settings.os == "Windows" and self.info.options.shared: + # libtool: error: can't build i686-pc-mingw32 shared library unless -no-undefined is specified + raise ConanInvalidConfiguration(f"{self.ref} can't be built as shared on Windows") def build_requirements(self): - if tools.os_info.is_windows and not os.environ.get("CONAN_BASH_PATH"): - self.build_requires("msys2/20190524") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - args = [] - if self.options.shared: - args.extend(['--disable-static', '--enable-shared']) - else: - args.extend(['--disable-shared', '--enable-static']) - self._autotools.configure(configure_dir=self._source_subfolder, args=args) - return self._autotools + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.generate() def build(self): - autotools = self._configure_autotools() + autotools = Autotools(self) + autotools.configure() autotools.make() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - autotools = self._configure_autotools() - autotools.install() - - tools.rmdir(os.path.join(self.package_folder, 'share')) - os.unlink(os.path.join(self.package_folder, "lib", "libev.la")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) def package_info(self): self.cpp_info.libs = ["ev"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") elif self.settings.os == "Windows": self.cpp_info.system_libs.append("ws2_32") diff --git a/recipes/libev/all/test_package/CMakeLists.txt b/recipes/libev/all/test_package/CMakeLists.txt index 34af13462f44f..ace0979b2a703 100644 --- a/recipes/libev/all/test_package/CMakeLists.txt +++ b/recipes/libev/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libev REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libev::libev) diff --git a/recipes/libev/all/test_package/conanfile.py b/recipes/libev/all/test_package/conanfile.py index bd7165a553cf4..0a6bc68712d90 100644 --- a/recipes/libev/all/test_package/conanfile.py +++ b/recipes/libev/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libev/all/test_v1_package/CMakeLists.txt b/recipes/libev/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libev/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libev/all/test_v1_package/conanfile.py b/recipes/libev/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libev/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libevent/all/CMakeLists.txt b/recipes/libevent/all/CMakeLists.txt deleted file mode 100644 index bd3083b512cb9..0000000000000 --- a/recipes/libevent/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/libevent/all/conandata.yml b/recipes/libevent/all/conandata.yml index 2a0e0325744fe..f2a195cfe79c1 100644 --- a/recipes/libevent/all/conandata.yml +++ b/recipes/libevent/all/conandata.yml @@ -1,14 +1,12 @@ sources: - "2.1.11": - url: "https://github.com/libevent/libevent/archive/release-2.1.11-stable.tar.gz" - sha256: "229393ab2bf0dc94694f21836846b424f3532585bac3468738b7bf752c03901e" "2.1.12": url: "https://github.com/libevent/libevent/archive/release-2.1.12-stable.tar.gz" sha256: "7180a979aaa7000e1264da484f712d403fcf7679b1e9212c4e3d09f5c93efc24" -patches: "2.1.11": - - base_path: source_subfolder - patch_file: patches/fix-cmake-2.1.11.patch + url: "https://github.com/libevent/libevent/archive/release-2.1.11-stable.tar.gz" + sha256: "229393ab2bf0dc94694f21836846b424f3532585bac3468738b7bf752c03901e" +patches: "2.1.12": - - base_path: source_subfolder - patch_file: patches/fix-cmake-2.1.12.patch + - patch_file: patches/fix-cmake-2.1.12.patch + "2.1.11": + - patch_file: patches/fix-cmake-2.1.11.patch diff --git a/recipes/libevent/all/conanfile.py b/recipes/libevent/all/conanfile.py index 27b24ba288640..8ae1637de9bc1 100644 --- a/recipes/libevent/all/conanfile.py +++ b/recipes/libevent/all/conanfile.py @@ -1,41 +1,36 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime import os -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.52.0" + class LibeventConan(ConanFile): name = "libevent" description = "libevent - an event notification library" - topics = ("conan", "libevent", "event") + topics = ("event", "notification", "networking", "async") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/libevent/libevent" license = "BSD-3-Clause" - exports_sources = ["CMakeLists.txt", "patches/**"] - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "with_openssl": [True, False], - "disable_threads": [True, False] + "disable_threads": [True, False], } default_options = { "shared": False, "fPIC": True, "with_openssl": True, - "disable_threads": False + "disable_threads": False, } - generators = "cmake", "cmake_find_package" - short_paths = True - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -43,84 +38,105 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): if self.options.with_openssl: - self.requires("openssl/1.1.1j") + self.requires("openssl/1.1.1s") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - # temporary fix due to missing files in dist package for 2.1.11, see upstream bug 863 - # for other versions "libevent-{0}-stable".format(self.version) is enough - extracted_folder = "libevent-release-{0}-stable".format(self.version) - os.rename(extracted_folder, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) if self.options.with_openssl: - self._cmake.definitions["OPENSSL_ROOT_DIR"] = self.deps_cpp_info["openssl"].rootpath - self._cmake.definitions["EVENT__LIBRARY_TYPE"] = "SHARED" if self.options.shared else "STATIC" - self._cmake.definitions["EVENT__DISABLE_DEBUG_MODE"] = self.settings.build_type == "Release" - self._cmake.definitions["EVENT__DISABLE_OPENSSL"] = not self.options.with_openssl - self._cmake.definitions["EVENT__DISABLE_THREAD_SUPPORT"] = self.options.disable_threads - self._cmake.definitions["EVENT__DISABLE_BENCHMARK"] = True - self._cmake.definitions["EVENT__DISABLE_TESTS"] = True - self._cmake.definitions["EVENT__DISABLE_REGRESS"] = True - self._cmake.definitions["EVENT__DISABLE_SAMPLES"] = True + tc.variables["OPENSSL_ROOT_DIR"] = self.dependencies["openssl"].package_folder.replace("\\", "/") + tc.cache_variables["EVENT__LIBRARY_TYPE"] = "SHARED" if self.options.shared else "STATIC" + tc.variables["EVENT__DISABLE_DEBUG_MODE"] = self.settings.build_type == "Release" + tc.variables["EVENT__DISABLE_OPENSSL"] = not self.options.with_openssl + tc.variables["EVENT__DISABLE_THREAD_SUPPORT"] = self.options.disable_threads + tc.variables["EVENT__DISABLE_BENCHMARK"] = True + tc.variables["EVENT__DISABLE_TESTS"] = True + tc.variables["EVENT__DISABLE_REGRESS"] = True + tc.variables["EVENT__DISABLE_SAMPLES"] = True # libevent uses static runtime (MT) for static builds by default - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["EVENT__MSVC_STATIC_RUNTIME"] = str(self.settings.compiler.runtime).startswith("MT") - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + if is_msvc(self): + tc.variables["EVENT__MSVC_STATIC_RUNTIME"] = is_msvc_static_runtime(self) + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # relocatable shared libs on macOS + replace_in_file(self, os.path.join(self.source_folder, "cmake", "AddEventLibrary.cmake"), + "INSTALL_NAME_DIR \"${CMAKE_INSTALL_PREFIX}/lib\"", + "") def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - # drop pc and cmake file - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "cmake")) def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "Libevent" - self.cpp_info.filenames["cmake_find_package_multi"] = "Libevent" - self.cpp_info.names["cmake_find_package"] = "libevent" - self.cpp_info.names["cmake_find_package_multi"] = "libevent" - # libevent - self.cpp_info.components["liblibevent"].names["pkg_config"] = "libevent" - self.cpp_info.components["liblibevent"].requires = ["core", "extra"] + self.cpp_info.set_property("cmake_file_name", "Libevent") + self.cpp_info.set_property("pkg_config_name", "libevent") # exist in libevent for historical reason + # core - self.cpp_info.components["core"].names["pkg_config"] = "libevent_core" + self.cpp_info.components["core"].set_property("cmake_target_name", "libevent::core") + self.cpp_info.components["core"].set_property("pkg_config_name", "libevent_core") self.cpp_info.components["core"].libs = ["event_core"] - if self.settings.os == "Linux" and not self.options.disable_threads: + if self.settings.os in ["Linux", "FreeBSD"] and not self.options.disable_threads: self.cpp_info.components["core"].system_libs = ["pthread"] if self.settings.os == "Windows": self.cpp_info.components["core"].system_libs = ["ws2_32", "advapi32", "iphlpapi"] + # extra - self.cpp_info.components["extra"].names["pkg_config"] = "libevent_extra" + self.cpp_info.components["extra"].set_property("cmake_target_name", "libevent::extra") + self.cpp_info.components["extra"].set_property("pkg_config_name", "libevent_extra") self.cpp_info.components["extra"].libs = ["event_extra"] if self.settings.os == "Windows": self.cpp_info.components["extra"].system_libs = ["shell32"] self.cpp_info.components["extra"].requires = ["core"] + # openssl if self.options.with_openssl: - self.cpp_info.components["openssl"].names["pkg_config"] = "libevent_openssl" + self.cpp_info.components["openssl"].set_property("cmake_target_name", "libevent::openssl") + self.cpp_info.components["openssl"].set_property("pkg_config_name", "libevent_openssl") self.cpp_info.components["openssl"].libs = ["event_openssl"] self.cpp_info.components["openssl"].requires = ["core", "openssl::openssl"] + # pthreads if self.settings.os != "Windows" and not self.options.disable_threads: - self.cpp_info.components["pthreads"].names["pkg_config"] = "libevent_pthreads" + self.cpp_info.components["pthreads"].set_property("cmake_target_name", "libevent::pthreads") + self.cpp_info.components["pthreads"].set_property("pkg_config_name", "libevent_pthreads") self.cpp_info.components["pthreads"].libs = ["event_pthreads"] self.cpp_info.components["pthreads"].requires = ["core"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "Libevent" + self.cpp_info.filenames["cmake_find_package_multi"] = "Libevent" diff --git a/recipes/libevent/all/test_package/CMakeLists.txt b/recipes/libevent/all/test_package/CMakeLists.txt index e64b58eff9290..dc7570c75d1b5 100644 --- a/recipes/libevent/all/test_package/CMakeLists.txt +++ b/recipes/libevent/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C) find_package(Libevent REQUIRED core CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} libevent::core) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libevent::core) diff --git a/recipes/libevent/all/test_package/conanfile.py b/recipes/libevent/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/libevent/all/test_package/conanfile.py +++ b/recipes/libevent/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libevent/all/test_package/test_package.cpp b/recipes/libevent/all/test_package/test_package.c similarity index 100% rename from recipes/libevent/all/test_package/test_package.cpp rename to recipes/libevent/all/test_package/test_package.c diff --git a/recipes/libevent/all/test_v1_package/CMakeLists.txt b/recipes/libevent/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a8d5eec5dd24d --- /dev/null +++ b/recipes/libevent/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Libevent REQUIRED core CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libevent::core) diff --git a/recipes/libevent/all/test_v1_package/conanfile.py b/recipes/libevent/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libevent/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libevent/config.yml b/recipes/libevent/config.yml index 82acda7a9727a..479e85bbe42a5 100644 --- a/recipes/libevent/config.yml +++ b/recipes/libevent/config.yml @@ -1,5 +1,5 @@ versions: - "2.1.11": - folder: all "2.1.12": folder: all + "2.1.11": + folder: all diff --git a/recipes/libexif/all/conandata.yml b/recipes/libexif/all/conandata.yml new file mode 100644 index 0000000000000..ae774e1c9a024 --- /dev/null +++ b/recipes/libexif/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "0.6.24": + url: "https://github.com/libexif/libexif/releases/download/v0.6.23/libexif-0.6.23.tar.gz" + sha256: "9271cf58cb46b00f9e2e9b968c7d81c008a69e5457f7d1a50dbf1786eac61b52" + "0.6.23": + url: "https://github.com/libexif/libexif/releases/download/v0.6.23/libexif-0.6.23.tar.gz" + sha256: "9271cf58cb46b00f9e2e9b968c7d81c008a69e5457f7d1a50dbf1786eac61b52" +patches: + "0.6.24": + - patch_file: patches/replace_ssize_t_windows.diff + "0.6.23": + - patch_file: patches/replace_ssize_t_windows.diff diff --git a/recipes/libexif/all/conanfile.py b/recipes/libexif/all/conanfile.py new file mode 100644 index 0000000000000..8b251e32d1238 --- /dev/null +++ b/recipes/libexif/all/conanfile.py @@ -0,0 +1,115 @@ +from conan import ConanFile +from conan.tools.layout import basic_layout +from conan.tools.files import get, copy, rename, rmdir, rm, export_conandata_patches, apply_conandata_patches +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.env import VirtualBuildEnv +from conan.tools.scm import Version +from conan.tools.microsoft import is_msvc, unix_path +import os + +required_conan_version = ">=1.52.0" + + +class LibexifConan(ConanFile): + name = "libexif" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://libexif.github.io/" + license = "LGPL-2.1" + description = "libexif is a library for parsing, editing, and saving EXIF data." + topics = ("exif", "metadata", "parse", "edit") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def layout(self): + basic_layout(self, src_folder="src") + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def build_requirements(self): + self.tool_requires("gettext/0.21") + self.tool_requires("libtool/2.4.6") + if self._settings_build.os == "Windows": + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + self.tool_requires("msys2/cci.latest") + self.win_bash = True + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = AutotoolsToolchain(self) + yes_no = lambda v: "yes" if v else "no" + tc.configure_args.extend([ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--disable-docs", + "--disable-nls", + "--disable-rpath", + ]) + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + + # env vars + env = tc.environment() + if is_msvc(self): + compile_wrapper = unix_path(self, self._user_info_build["automake"].compile).replace("\\", "/") + ar_wrapper = unix_path(self, self._user_info_build["automake"].ar_lib).replace("\\", "/") + env.define("CC", f"{compile_wrapper} cl -nologo") + env.define("AR", f"{ar_wrapper} lib") + env.define("LD", f"{compile_wrapper} link -nologo") + + tc.generate(env) + + env = VirtualBuildEnv(self) + env.generate() + + def build(self): + apply_conandata_patches(self) + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + if is_msvc(self) and self.options.shared: + rename(self, os.path.join(self.package_folder, "lib", "exif.dll.lib"), + os.path.join(self.package_folder, "lib", "exif.lib")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["exif"] + self.cpp_info.names["pkg_config"] = "libexif" + self.cpp_info.set_property("pkg_config_name", "libexif") + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs = ["m"] diff --git a/recipes/libexif/all/patches/replace_ssize_t_windows.diff b/recipes/libexif/all/patches/replace_ssize_t_windows.diff new file mode 100644 index 0000000000000..874c1abae6654 --- /dev/null +++ b/recipes/libexif/all/patches/replace_ssize_t_windows.diff @@ -0,0 +1,16 @@ +diff --git a/libexif/exif-loader.c b/libexif/exif-loader.c +index bf4f97c..1587121 100644 +--- a/libexif/exif-loader.c ++++ b/libexif/exif-loader.c +@@ -29,6 +29,11 @@ + #include + #include + ++#if defined _MSC_VER ++#include ++typedef SSIZE_T ssize_t; ++#endif ++ + #undef JPEG_MARKER_DCT + #define JPEG_MARKER_DCT 0xc0 + #undef JPEG_MARKER_DHT diff --git a/recipes/libexif/all/test_package/CMakeLists.txt b/recipes/libexif/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2a72bac29499f --- /dev/null +++ b/recipes/libexif/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libexif REQUIRED) + +add_executable(${CMAKE_PROJECT_NAME} test_package.c) +target_link_libraries(${CMAKE_PROJECT_NAME} libexif::libexif) diff --git a/recipes/libexif/all/test_package/conanfile.py b/recipes/libexif/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0156618e96bf6 --- /dev/null +++ b/recipes/libexif/all/test_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.33.0" + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libexif/all/test_package/test_package.c b/recipes/libexif/all/test_package/test_package.c new file mode 100644 index 0000000000000..ecd70802e1db0 --- /dev/null +++ b/recipes/libexif/all/test_package/test_package.c @@ -0,0 +1,7 @@ +#include "libexif/exif-data.h" + +int main() { + ExifData *exif = exif_data_new(); + exif_data_free(exif); + return 0; +} diff --git a/recipes/libexif/config.yml b/recipes/libexif/config.yml new file mode 100644 index 0000000000000..d4a99779aab91 --- /dev/null +++ b/recipes/libexif/config.yml @@ -0,0 +1,5 @@ +versions: + "0.6.24": + folder: all + "0.6.23": + folder: all diff --git a/recipes/libfabric/all/conandata.yml b/recipes/libfabric/all/conandata.yml new file mode 100644 index 0000000000000..1eedb4da16c00 --- /dev/null +++ b/recipes/libfabric/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.12.1": + url: https://github.com/ofiwg/libfabric/releases/download/v1.12.1/libfabric-1.12.1.tar.bz2 + sha256: db3c8e0a495e6e9da6a7436adab905468aedfbd4579ee3da5232a5c111ba642c diff --git a/recipes/libfabric/all/conanfile.py b/recipes/libfabric/all/conanfile.py new file mode 100644 index 0000000000000..96dbea392e3a6 --- /dev/null +++ b/recipes/libfabric/all/conanfile.py @@ -0,0 +1,99 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.35.0" + +class LibfabricConan(ConanFile): + name = "libfabric" + description = "Open Fabric Interfaces" + topics = ("fabric", "communication", "framework", "service") + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://libfabric.org" + license = "BSD-2-Clause", "GPL-2.0-or-later" + settings = "os", "arch", "compiler", "build_type" + _providers = ['gni', 'psm', 'psm2', 'psm3', 'rxm', 'sockets', 'tcp', 'udp', 'usnic', 'verbs', 'bgq'] + options = { + **{ p: "ANY" for p in _providers }, + **{ + "shared": [True, False], + "fPIC": [True, False], + "with_libnl": "ANY", + "with_bgq_progress": [None, "auto", "manual"], + "with_bgq_mr": [None, "basic", "scalable"] + } + } + default_options = { + **{ p: "auto" for p in _providers }, + **{ + "shared": False, + "fPIC": True, + "with_libnl": None, + "with_bgq_progress": None, + "with_bgq_mr": None + } + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + _autotools = None + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def validate(self): + if self.settings.os not in ["Linux", "FreeBSD", "Macos"]: + raise ConanInvalidConfiguration("libfabric only builds on Linux, Macos, and FreeBSD.") + for p in self._providers: + if self.options.get_safe(p) not in ["auto", "yes", "no", "dl"] and not os.path.isdir(str(self.options.get_safe(p))): + raise ConanInvalidConfiguration("Option {} can only be one of 'auto', 'yes', 'no', 'dl' or a directory path") + if self.options.get_safe('with_libnl') and not os.path.isdir(str(self.options.with_libnl)): + raise ConanInvalidConfiguration("Value of with_libnl must be an existing directory") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self) + args = [] + for p in self._providers: + args.append('--enable-{}={}'.format(p, self.options.get_safe(p))) + if self.options.with_libnl: + args.append('--with-libnl={}'.format(self.options.with_libnl)) + if self.options.with_bgq_progress: + args.append('--with-bgq-progress={}'.format(self.options.with_bgq_progress)) + if self.options.with_bgq_mr: + args.append('--with-bgq-mr={}'.format(self.options.with_bgq_mr)) + self._autotools.configure(args=args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + autotools = self._configure_autotools() + autotools.install() + + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + + def package_info(self): + self.cpp_info.names["pkg_config"] = "libfabric" + self.cpp_info.libs = self.collect_libs() + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["pthread", "m"] diff --git a/recipes/libfabric/all/test_package/CMakeLists.txt b/recipes/libfabric/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..196188113685c --- /dev/null +++ b/recipes/libfabric/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/yas/7.x.x/test_package/conanfile.py b/recipes/libfabric/all/test_package/conanfile.py similarity index 100% rename from recipes/yas/7.x.x/test_package/conanfile.py rename to recipes/libfabric/all/test_package/conanfile.py diff --git a/recipes/libfabric/all/test_package/test_package.cpp b/recipes/libfabric/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..c67d1067dcfcd --- /dev/null +++ b/recipes/libfabric/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +/* example was taken from https://www.gnu.org/ghm/2011/paris/slides/andreas-enge-mpc.pdf */ + +#include +#include + +int main () { + const uint32_t version = fi_version(); + std::cout << "hello libfabric version " << FI_MAJOR(version) << "." << FI_MINOR(version) << "\n"; +} diff --git a/recipes/libfabric/config.yml b/recipes/libfabric/config.yml new file mode 100644 index 0000000000000..daa3a213a56fa --- /dev/null +++ b/recipes/libfabric/config.yml @@ -0,0 +1,3 @@ +versions: + "1.12.1": + folder: all diff --git a/recipes/libfdk_aac/all/CMakeLists.txt b/recipes/libfdk_aac/all/CMakeLists.txt new file mode 100644 index 0000000000000..b71c882d9d33f --- /dev/null +++ b/recipes/libfdk_aac/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/libfdk_aac/all/conandata.yml b/recipes/libfdk_aac/all/conandata.yml index be8234d574781..ce7031c0bb8bc 100644 --- a/recipes/libfdk_aac/all/conandata.yml +++ b/recipes/libfdk_aac/all/conandata.yml @@ -1,7 +1,10 @@ sources: - "2.0.0": - url: "https://github.com/mstorsjo/fdk-aac/archive/v2.0.0.tar.gz" - sha256: "6e6c7921713788e31df655911e1d42620b057180b00bf16874f5d630e1d5b9a2" + "2.0.2": + url: "https://github.com/mstorsjo/fdk-aac/archive/refs/tags/v2.0.2.tar.gz" + sha256: "7812b4f0cf66acda0d0fe4302545339517e702af7674dd04e5fe22a5ade16a90" "2.0.1": url: "https://github.com/mstorsjo/fdk-aac/archive/v2.0.1.tar.gz" sha256: "a4142815d8d52d0e798212a5adea54ecf42bcd4eec8092b37a8cb615ace91dc6" + "2.0.0": + url: "https://github.com/mstorsjo/fdk-aac/archive/v2.0.0.tar.gz" + sha256: "6e6c7921713788e31df655911e1d42620b057180b00bf16874f5d630e1d5b9a2" diff --git a/recipes/libfdk_aac/all/conanfile.py b/recipes/libfdk_aac/all/conanfile.py index 56220097bdb02..46645046e433e 100644 --- a/recipes/libfdk_aac/all/conanfile.py +++ b/recipes/libfdk_aac/all/conanfile.py @@ -1,98 +1,173 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans import ConanFile, AutoToolsBuildEnvironment, CMake, VisualStudioBuildEnvironment, tools +import contextlib +import functools import os -import fnmatch +required_conan_version = ">=1.43.0" -class FDKAACConan(ConanFile): + +class LibFDKAACConan(ConanFile): name = "libfdk_aac" url = "https://github.com/conan-io/conan-center-index" description = "A standalone library of the Fraunhofer FDK AAC code from Android" license = "https://github.com/mstorsjo/fdk-aac/blob/master/NOTICE" - settings = "os", "arch", "compiler", "build_type" homepage = "https://sourceforge.net/projects/opencore-amr/" - topics = ("conan", "libfdk_aac", "multimedia", "audio", "fraunhofer", "aac", "decoder", "encoding", "decoding") - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {'shared': False, 'fPIC': True} - _source_subfolder = 'sources' + topics = ("libfdk_aac", "multimedia", "audio", "fraunhofer", "aac", "decoder", "encoding", "decoding") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = "CMakeLists.txt" + generators = "cmake" + + @property + def _source_subfolder(self): + return "source_subfolder" @property - def _use_winbash(self): - return tools.os_info.is_windows and (self.settings.compiler == 'gcc' or tools.cross_building(self.settings)) + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _use_cmake(self): + return tools.Version(self.version) >= "2.0.2" def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: del self.options.fPIC def build_requirements(self): - if self._use_winbash and self.settings.compiler != 'Visual Studio': - if "CONAN_BASH_PATH" not in os.environ and tools.os_info.detect_windows_subsystem() != 'msys2': - self.build_requires("msys2/20190524") + if not self._use_cmake and not self._is_msvc: + self.build_requires("libtool/2.4.6") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "fdk-aac-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) - def _build_vs(self): - with tools.chdir(self._source_subfolder): - with tools.vcvars(self.settings, force=True): - with tools.remove_from_path('mkdir'): - tools.replace_in_file('Makefile.vc', - 'CFLAGS = /nologo /W3 /Ox /MT', - 'CFLAGS = /nologo /W3 /Ox /%s' % str(self.settings.compiler.runtime)) - tools.replace_in_file('Makefile.vc', - 'MKDIR_FLAGS = -p', - 'MKDIR_FLAGS =') - self.run('nmake -f Makefile.vc') - self.run('nmake -f Makefile.vc prefix="%s" install' % os.path.abspath(self.package_folder)) - - def _build_configure(self): + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_PROGRAMS"] = False + cmake.definitions["FDK_AAC_INSTALL_CMAKE_CONFIG_MODULE"] = False + cmake.definitions["FDK_AAC_INSTALL_PKGCONFIG_MODULE"] = False + cmake.configure() + return cmake + + @contextlib.contextmanager + def _msvc_build_environment(self): with tools.chdir(self._source_subfolder): - win_bash = self._use_winbash - prefix = os.path.abspath(self.package_folder) - if self._use_winbash: - prefix = tools.unix_path(prefix, tools.MSYS2) - args = ['--prefix=%s' % prefix] + with tools.vcvars(self): + with tools.environment_append(VisualStudioBuildEnvironment(self).vars): + yield + + def _build_vs(self): + with self._msvc_build_environment(): + # Rely on flags injected by conan + tools.replace_in_file("Makefile.vc", + "CFLAGS = /nologo /W3 /Ox /MT", + "CFLAGS = /nologo") + tools.replace_in_file("Makefile.vc", + "MKDIR_FLAGS = -p", + "MKDIR_FLAGS =") + # Build either shared or static, and don't build utility (it always depends on static lib) + tools.replace_in_file("Makefile.vc", "copy $(PROGS) $(bindir)", "") + tools.replace_in_file("Makefile.vc", "copy $(LIB_DEF) $(libdir)", "") if self.options.shared: - args.extend(['--disable-static', '--enable-shared']) + tools.replace_in_file("Makefile.vc", + "all: $(LIB_DEF) $(STATIC_LIB) $(SHARED_LIB) $(IMP_LIB) $(PROGS)", + "all: $(LIB_DEF) $(SHARED_LIB) $(IMP_LIB)") + tools.replace_in_file("Makefile.vc", "copy $(STATIC_LIB) $(libdir)", "") else: - args.extend(['--disable-shared', '--enable-static']) - env_build = AutoToolsBuildEnvironment(self, win_bash=win_bash) - self.run('autoreconf -fiv', win_bash=win_bash) + tools.replace_in_file("Makefile.vc", + "all: $(LIB_DEF) $(STATIC_LIB) $(SHARED_LIB) $(IMP_LIB) $(PROGS)", + "all: $(STATIC_LIB)") + tools.replace_in_file("Makefile.vc", "copy $(IMP_LIB) $(libdir)", "") + tools.replace_in_file("Makefile.vc", "copy $(SHARED_LIB) $(bindir)", "") + self.run("nmake -f Makefile.vc") + + def _build_autotools(self): + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + # relocatable shared lib on macOS + tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name @rpath/") if self.settings.os == "Android" and tools.os_info.is_windows: # remove escape for quotation marks, to make ndk on windows happy - tools.replace_in_file('configure', + tools.replace_in_file("configure", "s/[ `~#$^&*(){}\\\\|;'\\\''\"<>?]/\\\\&/g", "s/[ `~#$^&*(){}\\\\|;<>?]/\\\\&/g") - env_build.configure(args=args) - env_build.make() - env_build.install() + autotools = self._configure_autotools() + autotools.make() + + @functools.lru_cache(1) + def _configure_autotools(self): + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + ] + autotools.configure(args=args, configure_dir=self._source_subfolder) + return autotools def build(self): - if self.settings.compiler == 'Visual Studio': + if self._use_cmake: + cmake = self._configure_cmake() + cmake.build() + elif self._is_msvc: self._build_vs() else: - self._build_configure() + self._build_autotools() def package(self): - self.copy(pattern="NOTICE", src='sources', dst="licenses") - if self.settings.compiler == 'Visual Studio': + self.copy(pattern="NOTICE", src=self._source_subfolder, dst="licenses") + if self._use_cmake: + cmake = self._configure_cmake() + cmake.install() + elif self._is_msvc: + with self._msvc_build_environment(): + self.run("nmake -f Makefile.vc prefix=\"{}\" install".format(self.package_folder)) if self.options.shared: - exts = ['fdk-aac.lib'] - else: - exts = ['fdk-aac.dll.lib', 'fdk-aac-1.dll'] - for root, _, filenames in os.walk(self.package_folder): - for ext in exts: - for filename in fnmatch.filter(filenames, ext): - os.unlink(os.path.join(root, filename)) - tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) - if os.path.isfile(os.path.join(self.package_folder, "lib", "libfdk-aac.la")): - os.remove(os.path.join(self.package_folder, "lib", "libfdk-aac.la")) + tools.rename(os.path.join(self.package_folder, "lib", "fdk-aac.dll.lib"), + os.path.join(self.package_folder, "lib", "fdk-aac.lib")) + else: + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") def package_info(self): - if self.settings.compiler == 'Visual Studio' and self.options.shared: - self.cpp_info.libs = ['fdk-aac.dll.lib'] - else: - self.cpp_info.libs = ['fdk-aac'] - if self.settings.os == "Linux" or self.settings.os == "Android": - self.cpp_info.system_libs.append("m") - self.cpp_info.names['pkg_config'] = 'fdk-aac' + self.cpp_info.set_property("cmake_file_name", "fdk-aac") + self.cpp_info.set_property("cmake_target_name", "FDK-AAC::fdk-aac") + self.cpp_info.set_property("pkg_config_name", "fdk-aac") + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["fdk-aac"].libs = ["fdk-aac"] + if self.settings.os in ["Linux", "FreeBSD", "Android"]: + self.cpp_info.components["fdk-aac"].system_libs.append("m") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "fdk-aac" + self.cpp_info.filenames["cmake_find_package_multi"] = "fdk-aac" + self.cpp_info.names["cmake_find_package"] = "FDK-AAC" + self.cpp_info.names["cmake_find_package_multi"] = "FDK-AAC" + self.cpp_info.names["pkg_config"] = "fdk-aac" + self.cpp_info.components["fdk-aac"].names["cmake_find_package"] = "fdk-aac" + self.cpp_info.components["fdk-aac"].names["cmake_find_package_multi"] = "fdk-aac" + self.cpp_info.components["fdk-aac"].set_property("cmake_target_name", "FDK-AAC::fdk-aac") diff --git a/recipes/libfdk_aac/all/test_package/CMakeLists.txt b/recipes/libfdk_aac/all/test_package/CMakeLists.txt index b115bbed7256b..da66a6c3ba41f 100644 --- a/recipes/libfdk_aac/all/test_package/CMakeLists.txt +++ b/recipes/libfdk_aac/all/test_package/CMakeLists.txt @@ -1,9 +1,11 @@ - cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(fdk-aac REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} FDK-AAC::fdk-aac) +set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/libfdk_aac/all/test_package/conanfile.py b/recipes/libfdk_aac/all/test_package/conanfile.py index d72642c4343c5..0b5a595cef5e0 100644 --- a/recipes/libfdk_aac/all/test_package/conanfile.py +++ b/recipes/libfdk_aac/all/test_package/conanfile.py @@ -4,7 +4,16 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") def build(self): cmake = CMake(self) @@ -12,7 +21,6 @@ def build(self): cmake.build() def test(self): - if tools.cross_building(self.settings, skip_x64_x86=True): - return - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not tools.cross_building(self, skip_x64_x86=True): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libfdk_aac/all/test_package/test_package.c b/recipes/libfdk_aac/all/test_package/test_package.c new file mode 100644 index 0000000000000..ecb0777f900d9 --- /dev/null +++ b/recipes/libfdk_aac/all/test_package/test_package.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include + +int main() +{ + LIB_INFO info[FDK_MODULE_LAST]; + memset(&info, 0, sizeof(info)); + int ret = aacDecoder_GetLibInfo(info); + if (0 != ret) { + fprintf(stderr, "aacDecoder_GetLibInfo failed with %u\n", ret); + return EXIT_FAILURE; + } + ret = aacEncGetLibInfo(info); + if (0 != ret) { + fprintf(stderr, "aacEncGetLibInfo failed with %u\n", ret); + return EXIT_FAILURE; + } + + for (int i = 0; i < FDK_MODULE_LAST; ++i) { + if (FDK_AACDEC == info[i].module_id || FDK_AACENC == info[i].module_id) { + printf("title: %s\n", info[i].title); + printf("build date: %s\n", info[i].build_date); + printf("build time: %s\n", info[i].build_time); + printf("version: %s\n", info[i].versionStr); + printf("========================================\n"); + } + } + + return EXIT_SUCCESS; +} diff --git a/recipes/libfdk_aac/all/test_package/test_package.cpp b/recipes/libfdk_aac/all/test_package/test_package.cpp deleted file mode 100644 index ec810584478a4..0000000000000 --- a/recipes/libfdk_aac/all/test_package/test_package.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include -#include -#include - -int main() -{ - LIB_INFO info[FDK_MODULE_LAST]; - memset(&info, 0, sizeof(info)); - int ret = aacDecoder_GetLibInfo(info); - if (0 != ret) { - std::cerr << "aacDecoder_GetLibInfo failed with " << ret << std::endl; - return EXIT_FAILURE; - } - ret = aacEncGetLibInfo(info); - if (0 != ret) { - std::cerr << "aacEncGetLibInfo failed with " << ret << std::endl; - return EXIT_FAILURE; - } - - for (int i = 0; i < FDK_MODULE_LAST; ++i) { - if (FDK_AACDEC == info[i].module_id || FDK_AACENC == info[i].module_id) { - std::cout << info[i].title << std::endl; - std::cout << info[i].build_date << std::endl; - std::cout << info[i].build_time << std::endl; - std::cout << info[i].versionStr << std::endl; - } - } - - return EXIT_SUCCESS; -} diff --git a/recipes/libfdk_aac/config.yml b/recipes/libfdk_aac/config.yml index e59e710f5dfad..e850754933d82 100644 --- a/recipes/libfdk_aac/config.yml +++ b/recipes/libfdk_aac/config.yml @@ -1,5 +1,7 @@ versions: - "2.0.0": + "2.0.2": folder: all "2.0.1": folder: all + "2.0.0": + folder: all diff --git a/recipes/libffi/all/conandata.yml b/recipes/libffi/all/conandata.yml index ed4b82642e362..869663acc18e9 100644 --- a/recipes/libffi/all/conandata.yml +++ b/recipes/libffi/all/conandata.yml @@ -1,30 +1,26 @@ sources: - "3.2.1": - url: "https://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz" - sha256: "d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37" + "3.4.3": + url: "https://github.com/libffi/libffi/releases/download/v3.4.3/libffi-3.4.3.tar.gz" + sha256: "4416dd92b6ae8fcb5b10421e711c4d3cb31203d77521a77d85d0102311e6c3b8" + "3.4.2": + url: "https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz" + sha256: "540fb721619a6aba3bdeef7d940d8e9e0e6d2c193595bc243241b77ff9e93620" "3.3": url: "https://github.com/libffi/libffi/releases/download/v3.3/libffi-3.3.tar.gz" sha256: "72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056" patches: - "3.2.1": - - base_path: "source_subfolder" - patch_file: "patches/0001-3.2.1-add-support-windows-dll.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-3.2.1-fix-libtool-path.patch" - - base_path: "source_subfolder" - patch_file: "patches/0003-3.2.1-fix-win64-assembly.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-3.2.1-fix-complex-type-msvc.patch" - - base_path: "source_subfolder" - patch_file: "patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch" - - base_path: "source_subfolder" - patch_file: "patches/0006-3.2.1-library-no-version-suffix.patch" + "3.4.3": + - patch_file: "patches/0002-3.4.3-fix-libtool-path.patch" + - patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch" + - patch_file: "patches/0005-3.4.3-do-not-install-libraries-to-arch-dependent-directories.patch" + - patch_file: "patches/0006-3.4.3-library-no-version-suffix.patch" + "3.4.2": + - patch_file: "patches/0002-3.4.2-fix-libtool-path.patch" + - patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch" + - patch_file: "patches/0005-3.4.2-do-not-install-libraries-to-arch-dependent-directories.patch" + - patch_file: "patches/0006-3.4.2-library-no-version-suffix.patch" "3.3": - - base_path: "source_subfolder" - patch_file: "patches/0002-3.3-fix-libtool-path.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch" - - base_path: "source_subfolder" - patch_file: "patches/0005-3.3-do-not-install-libraries-to-arch-dependent-directories.patch" - - base_path: "source_subfolder" - patch_file: "patches/0006-3.3-library-no-version-suffix.patch" + - patch_file: "patches/0002-3.3-fix-libtool-path.patch" + - patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch" + - patch_file: "patches/0005-3.3-do-not-install-libraries-to-arch-dependent-directories.patch" + - patch_file: "patches/0006-3.3-library-no-version-suffix.patch" diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index e3dd4e29f079a..fca2894b5fa7b 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -1,20 +1,26 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.tools import Version -from contextlib import contextmanager +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, replace_in_file, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, msvc_runtime_flag, unix_path +from conan.tools.scm import Version +import glob import os import shutil -import platform -required_conan_version = ">=1.29" +required_conan_version = ">=1.52.0" + class LibffiConan(ConanFile): name = "libffi" description = "A portable, high level programming interface to various calling conventions" - topics = ("conan", "libffi", "runtime", "foreign-function-interface", "runtime-library") + license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://sourceware.org/libffi/" - license = "MIT" - settings = "os", "compiler", "build_type", "arch" + topics = ("runtime", "foreign-function-interface", "runtime-library") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -23,147 +29,157 @@ class LibffiConan(ConanFile): "shared": False, "fPIC": True, } - exports_sources = "patches/**" @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + # TODO: Remove for Conan v2 + return getattr(self, "settings_build", self.settings) - _autotools = None + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - def build_requirements(self): - if tools.os_info.is_windows and "CONAN_BASH_PATH" not in os.environ: - self.build_requires("msys2/20200517") - self.build_requires("gnu-config/cci.20201022") - def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + basic_layout(self, src_folder="src") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{}-{}".format(self.name, self.version) - os.rename(extracted_dir, self._source_subfolder) + def build_requirements(self): + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): + self.tool_requires("msys2/cci.latest") + if is_msvc(self): + self.tool_requires("automake/1.16.5") - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - configure_path = os.path.join(self._source_subfolder, "configure") - if self.settings.os == "Macos": - tools.replace_in_file(configure_path, r"-install_name \$rpath/", "-install_name ") + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - if Version(self.version) < "3.3": - if self.settings.compiler == "clang" and Version(str(self.settings.compiler.version)) >= 7.0: - # https://android.googlesource.com/platform/external/libffi/+/ca22c3cb49a8cca299828c5ffad6fcfa76fdfa77 - sysv_s_src = os.path.join(self._source_subfolder, "src", "arm", "sysv.S") - tools.replace_in_file(sysv_s_src, "fldmiad", "vldmia") - tools.replace_in_file(sysv_s_src, "fstmiad", "vstmia") - tools.replace_in_file(sysv_s_src, "fstmfdd\tsp!,", "vpush") + def generate(self): + virtual_build_env = VirtualBuildEnv(self) + virtual_build_env.generate() - # https://android.googlesource.com/platform/external/libffi/+/7748bd0e4a8f7d7c67b2867a3afdd92420e95a9f - tools.replace_in_file(sysv_s_src, "stmeqia", "stmiaeq") - - @contextmanager - def _build_context(self): - extra_env_vars = {} - if self.settings.compiler == "Visual Studio": - msvcc = tools.unix_path(os.path.join(self.source_folder, self._source_subfolder, "msvcc.sh")) - msvcc_args = [] - if self.settings.arch == "x86_64": - msvcc_args.append("-m64") - elif self.settings.arch == "x86": - msvcc_args.append("-m32") - if msvcc_args: - msvcc = "{} {}".format(msvcc, " ".join(msvcc_args)) - extra_env_vars.update(tools.vcvars_dict(self.settings)) - extra_env_vars.update({ - "INSTALL": tools.unix_path(os.path.join(self.source_folder, self._source_subfolder, "install-sh")), - "LIBTOOL": tools.unix_path(os.path.join(self.source_folder, self._source_subfolder, "ltmain.sh")), - "CC": msvcc, - "CXX": msvcc, - "LD": "link", - "CPP": "cl -nologo -EP", - "CXXCPP": "cl -nologo -EP", - }) - with tools.environment_append(extra_env_vars): - yield - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) yes_no = lambda v: "yes" if v else "no" - config_args = [ - "--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")), - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), - ] - self._autotools.defines.append("FFI_BUILDING") + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ + f"--enable-debug={yes_no(self.settings.build_type == 'Debug')}", + "--enable-builddir=no", + "--enable-docs=no", + ]) + + if self._settings_build.compiler == "apple-clang": + tc.configure_args.append("--disable-multi-os-directory") + + tc.extra_defines.append("FFI_BUILDING") if self.options.shared: - self._autotools.defines.append("FFI_BUILDING_DLL") - if self.settings.compiler == "Visual Studio": - if "MT" in str(self.settings.compiler.runtime): - self._autotools.defines.append("USE_STATIC_RTL") - if "d" in str(self.settings.compiler.runtime): - self._autotools.defines.append("USE_DEBUG_RTL") - build = None - host = None - if self.settings.compiler == "Visual Studio": + tc.extra_defines.append("FFI_BUILDING_DLL") + + env = tc.environment() + if self._settings_build.os == "Windows" and (is_msvc(self) or self.settings.compiler == "clang"): build = "{}-{}-{}".format( - "x86_64" if "64" in platform.machine() else "i686", - "pc" if self.settings.arch == "x86" else "w64", - "cygwin") + "x86_64" if self._settings_build.arch == "x86_64" else "i686", + "pc" if self._settings_build.arch == "x86" else "win64", + "mingw64") host = "{}-{}-{}".format( "x86_64" if self.settings.arch == "x86_64" else "i686", - "pc" if self.settings.arch == "x86" else "w64", - "cygwin") - else: - if self._autotools.host and "x86-" in self._autotools.host: - self._autotools.host = self._autotools.host.replace("x86", "i686") - self._autotools.configure(args=config_args, configure_dir=self._source_subfolder, build=build, host=host) - return self._autotools + "pc" if self.settings.arch == "x86" else "win64", + "mingw64") + tc.configure_args.extend([ + f"--build={build}", + f"--host={host}", + ]) + + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + + if is_msvc_static_runtime(self): + tc.extra_defines.append("USE_STATIC_RTL") + if "d" in msvc_runtime_flag(self): + tc.extra_defines.append("USE_DEBUG_RTL") + + architecture_flag = "" + if is_msvc(self): + if self.settings.arch == "x86_64": + architecture_flag = "-m64" + elif self.settings.arch == "x86": + architecture_flag = "-m32" + elif self.settings.compiler == "clang": + architecture_flag = "-clang-cl" + + compile_wrapper = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) + if architecture_flag: + compile_wrapper = f"{compile_wrapper} {architecture_flag}" + # FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged + # env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))}") + [version_major, version_minor, _] = self.dependencies.direct_build['automake'].ref.version.split(".", 2) + automake_version = f"{version_major}.{version_minor}" + ar_wrapper = unix_path(self, os.path.join(self.dependencies.direct_build['automake'].cpp_info.resdirs[0], f"automake-{automake_version}", "ar-lib")) + env.define("CC", f"{compile_wrapper}") + env.define("CXX", f"{compile_wrapper}") + env.define("LD", "link -nologo") + env.define("AR", f"{ar_wrapper} \"lib -nologo\"") + env.define("NM", "dumpbin -symbols") + env.define("OBJDUMP", ":") + env.define("RANLIB", ":") + env.define("STRIP", ":") + env.define("CXXCPP", "cl -nologo -EP") + env.define("CPP", "cl -nologo -EP") + env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh"))) + env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) + tc.generate(env=env) + + def _patch_source(self): + apply_conandata_patches(self) + + if Version(self.version) < "3.3": + if self.settings.compiler == "clang" and Version(str(self.settings.compiler.version)) >= 7.0: + # https://android.googlesource.com/platform/external/libffi/+/ca22c3cb49a8cca299828c5ffad6fcfa76fdfa77 + sysv_s_src = os.path.join(self.source_folder, "src", "arm", "sysv.S") + replace_in_file(self, sysv_s_src, "fldmiad", "vldmia") + replace_in_file(self, sysv_s_src, "fstmiad", "vstmia") + replace_in_file(self, sysv_s_src, "fstmfdd\tsp!,", "vpush") + + # https://android.googlesource.com/platform/external/libffi/+/7748bd0e4a8f7d7c67b2867a3afdd92420e95a9f + replace_in_file(self, sysv_s_src, "stmeqia", "stmiaeq") def build(self): - self._patch_sources() - shutil.copy(self.deps_user_info["gnu-config"].CONFIG_SUB, - os.path.join(self._source_subfolder, "config.sub")) - shutil.copy(self.deps_user_info["gnu-config"].CONFIG_GUESS, - os.path.join(self._source_subfolder, "config.guess")) - - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() - if tools.get_env("CONAN_RUN_TESTS", False): - autotools.make(target="check") + self._patch_source() + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - if self.settings.compiler == "Visual Studio": - if self.options.shared: - self.copy("libffi.dll", src=".libs", dst="bin") - self.copy("libffi.lib", src=".libs", dst="lib") - self.copy("*.h", src="include", dst="include") - else: - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() - - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) - - os.unlink(os.path.join(self.package_folder, "lib", "libffi.la")) + autotools = Autotools(self) + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) # Need to specify the `DESTDIR` as a Unix path, aware of the subsystem + fix_apple_shared_install_name(self) + mkdir(self, os.path.join(self.package_folder, "bin")) + for dll in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")): + shutil.move(dll, os.path.join(self.package_folder, "bin")) + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.filenames["pkg_config"] = "libffi" + self.cpp_info.libs = ["{}ffi".format("lib" if is_msvc(self) else "")] + self.cpp_info.set_property("pkg_config_name", "libffi") if not self.options.shared: self.cpp_info.defines = ["FFI_BUILDING"] - libffi = "ffi" - if self.settings.compiler == "Visual Studio": - libffi = "lib" + libffi - self.cpp_info.libs = [libffi] diff --git a/recipes/libffi/all/patches/0001-3.2.1-add-support-windows-dll.patch b/recipes/libffi/all/patches/0001-3.2.1-add-support-windows-dll.patch deleted file mode 100644 index 91b34fdcb090a..0000000000000 --- a/recipes/libffi/all/patches/0001-3.2.1-add-support-windows-dll.patch +++ /dev/null @@ -1,163 +0,0 @@ ---- include/ffi.h.in -+++ include/ffi.h.in -@@ -66,6 +66,18 @@ - - #include - -+#if defined _MSC_VER -+# if defined FFI_BUILDING_DLL /* Building libffi.DLL with msvcc.sh */ -+# define FFI_EXTERN __declspec(dllexport) -+# elif !defined FFI_BUILDING /* Importing libffi.DLL */ -+# define FFI_EXTERN __declspec(dllimport) -+# else -+# define FFI_EXTERN extern -+# endif -+#else -+# define FFI_EXTERN extern -+#endif -+ - #ifndef LIBFFI_ASM - - #if defined(_MSC_VER) && !defined(__clang__) -@@ -166,20 +180,6 @@ - #error "long size not supported" - #endif - --/* Need minimal decorations for DLLs to works on Windows. */ --/* GCC has autoimport and autoexport. Rely on Libtool to */ --/* help MSVC export from a DLL, but always declare data */ --/* to be imported for MSVC clients. This costs an extra */ --/* indirection for MSVC clients using the static version */ --/* of the library, but don't worry about that. Besides, */ --/* as a workaround, they can define FFI_BUILDING if they */ --/* *know* they are going to link with the static library. */ --#if defined _MSC_VER && !defined FFI_BUILDING --#define FFI_EXTERN extern __declspec(dllimport) --#else --#define FFI_EXTERN extern --#endif -- - /* These are defined in types.c */ - FFI_EXTERN ffi_type ffi_type_void; - FFI_EXTERN ffi_type ffi_type_uint8; -@@ -237,7 +237,7 @@ - #endif - - /* Used internally, but overridden by some architectures */ --ffi_status ffi_prep_cif_core(ffi_cif *cif, -+FFI_EXTERN ffi_status ffi_prep_cif_core(ffi_cif *cif, - ffi_abi abi, - unsigned int isvariadic, - unsigned int nfixedargs, -@@ -282,27 +282,27 @@ - #endif - - --void ffi_raw_call (ffi_cif *cif, -+FFI_EXTERN void ffi_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_raw *avalue); - --void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); --void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); --size_t ffi_raw_size (ffi_cif *cif); -+FFI_EXTERN void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); -+FFI_EXTERN void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); -+FFI_EXTERN size_t ffi_raw_size (ffi_cif *cif); - - /* This is analogous to the raw API, except it uses Java parameter */ - /* packing, even on 64-bit machines. I.e. on 64-bit machines */ - /* longs and doubles are followed by an empty 64-bit word. */ - --void ffi_java_raw_call (ffi_cif *cif, -+FFI_EXTERN void ffi_java_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_java_raw *avalue); - --void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); --void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); --size_t ffi_java_raw_size (ffi_cif *cif); -+FFI_EXTERN void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); -+FFI_EXTERN void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); -+FFI_EXTERN size_t ffi_java_raw_size (ffi_cif *cif); - - /* ---- Definitions for closures ----------------------------------------- */ - -@@ -330,16 +330,16 @@ - # endif - #endif - --void *ffi_closure_alloc (size_t size, void **code); --void ffi_closure_free (void *); -+FFI_EXTERN void *ffi_closure_alloc (size_t size, void **code); -+FFI_EXTERN void ffi_closure_free (void *); - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_closure (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data); - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_closure_loc (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), -@@ -400,26 +400,26 @@ - - } ffi_java_raw_closure; - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_raw_closure (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data); - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_raw_closure_loc (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc); - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_java_raw_closure (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data); - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), -@@ -430,20 +430,20 @@ - - /* ---- Public interface definition -------------------------------------- */ - --ffi_status ffi_prep_cif(ffi_cif *cif, -+FFI_EXTERN ffi_status ffi_prep_cif(ffi_cif *cif, - ffi_abi abi, - unsigned int nargs, - ffi_type *rtype, - ffi_type **atypes); - --ffi_status ffi_prep_cif_var(ffi_cif *cif, -+FFI_EXTERN ffi_status ffi_prep_cif_var(ffi_cif *cif, - ffi_abi abi, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, - ffi_type **atypes); - --void ffi_call(ffi_cif *cif, -+FFI_EXTERN void ffi_call(ffi_cif *cif, - void (*fn)(void), - void *rvalue, - void **avalue); diff --git a/recipes/libffi/all/patches/0002-3.2.1-fix-libtool-path.patch b/recipes/libffi/all/patches/0002-3.2.1-fix-libtool-path.patch deleted file mode 100644 index a09551d110a1e..0000000000000 --- a/recipes/libffi/all/patches/0002-3.2.1-fix-libtool-path.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- configure -+++ configure -@@ -8796,7 +8796,7 @@ - LIBTOOL_DEPS="$ltmain" - - # Always use our own libtool. --LIBTOOL='$(SHELL) $(top_builddir)/libtool' -+LIBTOOL='$(SHELL) $(top_builddir)/libtool.sh' - - - -@@ -8889,7 +8889,7 @@ - esac - - # Global variables: --ofile=libtool -+ofile=libtool.sh - can_build_shared=yes - - # All known linkers require a `.a' archive for static linking (except MSVC, diff --git a/recipes/libffi/all/patches/0002-3.4.2-fix-libtool-path.patch b/recipes/libffi/all/patches/0002-3.4.2-fix-libtool-path.patch new file mode 100644 index 0000000000000..fad9e64adff17 --- /dev/null +++ b/recipes/libffi/all/patches/0002-3.4.2-fix-libtool-path.patch @@ -0,0 +1,20 @@ +--- configure ++++ configure +@@ -8979,7 +8979,7 @@ + LIBTOOL_DEPS=$ltmain + + # Always use our own libtool. +-LIBTOOL='$(SHELL) $(top_builddir)/libtool' ++LIBTOOL='$(SHELL) $(top_builddir)/libtool.sh' + + + +@@ -9072,7 +9072,7 @@ + esac + + # Global variables: +-ofile=libtool ++ofile=libtool.sh + can_build_shared=yes + + # All known linkers require a '.a' archive for static linking (except MSVC, diff --git a/recipes/libffi/all/patches/0002-3.4.3-fix-libtool-path.patch b/recipes/libffi/all/patches/0002-3.4.3-fix-libtool-path.patch new file mode 100644 index 0000000000000..f7d0c10680b69 --- /dev/null +++ b/recipes/libffi/all/patches/0002-3.4.3-fix-libtool-path.patch @@ -0,0 +1,20 @@ +--- configure ++++ configure +@@ -9940,7 +9940,7 @@ + LIBTOOL_DEPS=$ltmain + + # Always use our own libtool. +-LIBTOOL='$(SHELL) $(top_builddir)/libtool' ++LIBTOOL='$(SHELL) $(top_builddir)/libtool.sh' + + + +@@ -10032,7 +10032,7 @@ + esac + + # Global variables: +-ofile=libtool ++ofile=libtool.sh + can_build_shared=yes + + # All known linkers require a '.a' archive for static linking (except MSVC and diff --git a/recipes/libffi/all/patches/0003-3.2.1-fix-win64-assembly.patch b/recipes/libffi/all/patches/0003-3.2.1-fix-win64-assembly.patch deleted file mode 100644 index 622ab2065a477..0000000000000 --- a/recipes/libffi/all/patches/0003-3.2.1-fix-win64-assembly.patch +++ /dev/null @@ -1,92 +0,0 @@ ---- src/x86/win64.S -+++ src/x86/win64.S -@@ -170,7 +170,7 @@ - mov rcx, QWORD PTR RVALUE[rbp] - movzx rax, ax - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_sint16$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT16 -@@ -179,7 +179,7 @@ - mov rcx, QWORD PTR RVALUE[rbp] - movsx rax, ax - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_uint32$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT32 -@@ -188,7 +188,7 @@ - mov rcx, QWORD PTR RVALUE[rbp] - mov eax, eax - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_sint32$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT32 -@@ -197,7 +197,7 @@ - mov rcx, QWORD PTR RVALUE[rbp] - cdqe - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_float$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_FLOAT -@@ -205,7 +205,7 @@ - - mov rax, QWORD PTR RVALUE[rbp] - movss DWORD PTR [rax], xmm0 -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_double$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_DOUBLE -@@ -213,7 +213,7 @@ - - mov rax, QWORD PTR RVALUE[rbp] - movlpd QWORD PTR [rax], xmm0 -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_uint64$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT64 -@@ -221,7 +221,7 @@ - - mov rcx, QWORD PTR RVALUE[rbp] - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_sint64$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64 -@@ -229,7 +229,7 @@ - - mov rcx, QWORD PTR RVALUE[rbp] - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_pointer$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_POINTER -@@ -237,7 +237,7 @@ - - mov rcx, QWORD PTR RVALUE[rbp] - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_int$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_INT -@@ -246,7 +246,7 @@ - mov rcx, QWORD PTR RVALUE[rbp] - cdqe - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_void$: - xor rax, rax diff --git a/recipes/libffi/all/patches/0004-3.2.1-fix-complex-type-msvc.patch b/recipes/libffi/all/patches/0004-3.2.1-fix-complex-type-msvc.patch deleted file mode 100644 index 2b35695041bac..0000000000000 --- a/recipes/libffi/all/patches/0004-3.2.1-fix-complex-type-msvc.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- src/types.c -+++ src/types.c -@@ -31,6 +31,8 @@ - #include - #include - -+#include -+ - /* Type definitions */ - - #define FFI_TYPEDEF(name, type, id, maybe_const)\ -@@ -44,16 +46,16 @@ - id, NULL \ - } - --#define FFI_COMPLEX_TYPEDEF(name, type, maybe_const) \ -+#define FFI_COMPLEX_TYPEDEF(name, complex_type, maybe_const) \ - static ffi_type *ffi_elements_complex_##name [2] = { \ - (ffi_type *)(&ffi_type_##name), NULL \ - }; \ - struct struct_align_complex_##name { \ - char c; \ -- _Complex type x; \ -+ complex_type x; \ - }; \ - maybe_const ffi_type ffi_type_complex_##name = { \ -- sizeof(_Complex type), \ -+ sizeof(complex_type), \ - offsetof(struct struct_align_complex_##name, x), \ - FFI_TYPE_COMPLEX, \ - (ffi_type **)ffi_elements_complex_##name \ -@@ -97,10 +99,20 @@ - FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE, FFI_LDBL_CONST); - #endif - -+#ifdef _MSC_VER -+# define FLOAT_COMPLEX _C_float_complex -+# define DOUBLE_COMPLEX _C_double_complex -+# define LDOUBLE_COMPLEX _C_ldouble_complex -+#else -+# define FLOAT_COMPLEX float _Complex -+# define DOUBLE_COMPLEX double _Complex -+# define LDOUBLE_COMPLEX long double _Complex -+#endif -+ - #ifdef FFI_TARGET_HAS_COMPLEX_TYPE --FFI_COMPLEX_TYPEDEF(float, float, const); --FFI_COMPLEX_TYPEDEF(double, double, const); -+FFI_COMPLEX_TYPEDEF(float, FLOAT_COMPLEX, const); -+FFI_COMPLEX_TYPEDEF(double, DOUBLE_COMPLEX, const); - #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE --FFI_COMPLEX_TYPEDEF(longdouble, long double, FFI_LDBL_CONST); -+FFI_COMPLEX_TYPEDEF(longdouble, LDOUBLE_COMPLEX, FFI_LDBL_CONST); - #endif - #endif diff --git a/recipes/libffi/all/patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch b/recipes/libffi/all/patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch deleted file mode 100644 index 4abeffb876872..0000000000000 --- a/recipes/libffi/all/patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- Makefile.in -+++ Makefile.in -@@ -600,7 +600,7 @@ - target_os = @target_os@ - target_vendor = @target_vendor@ - toolexecdir = @toolexecdir@ --toolexeclibdir = @toolexeclibdir@ -+toolexeclibdir = @libdir@ - top_build_prefix = @top_build_prefix@ - top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ - ---- include/Makefile.in -+++ include/Makefile.in -@@ -307,15 +307,15 @@ - target_os = @target_os@ - target_vendor = @target_vendor@ - toolexecdir = @toolexecdir@ --toolexeclibdir = @toolexeclibdir@ -+toolexeclibdir = @libdir@ - top_build_prefix = @top_build_prefix@ - top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ - AUTOMAKE_OPTIONS = foreign - DISTCLEANFILES = ffitarget.h - EXTRA_DIST = ffi.h.in ffi_common.h --includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include -+includesdir = @includedir@ - nodist_includes_HEADERS = ffi.h ffitarget.h - all: all-am - - .SUFFIXES: diff --git a/recipes/libffi/all/patches/0005-3.4.2-do-not-install-libraries-to-arch-dependent-directories.patch b/recipes/libffi/all/patches/0005-3.4.2-do-not-install-libraries-to-arch-dependent-directories.patch new file mode 100644 index 0000000000000..8e14796ab662a --- /dev/null +++ b/recipes/libffi/all/patches/0005-3.4.2-do-not-install-libraries-to-arch-dependent-directories.patch @@ -0,0 +1,11 @@ +--- Makefile.in ++++ Makefile.in +@@ -517,7 +517,7 @@ + target_os = @target_os@ + target_vendor = @target_vendor@ + toolexecdir = @toolexecdir@ +-toolexeclibdir = @toolexeclibdir@ ++toolexeclibdir = @libdir@ + top_build_prefix = @top_build_prefix@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ diff --git a/recipes/libffi/all/patches/0005-3.4.3-do-not-install-libraries-to-arch-dependent-directories.patch b/recipes/libffi/all/patches/0005-3.4.3-do-not-install-libraries-to-arch-dependent-directories.patch new file mode 100644 index 0000000000000..e82abf24a4fb1 --- /dev/null +++ b/recipes/libffi/all/patches/0005-3.4.3-do-not-install-libraries-to-arch-dependent-directories.patch @@ -0,0 +1,11 @@ +--- Makefile.in ++++ Makefile.in +@@ -520,7 +520,7 @@ + target_vendor = @target_vendor@ + tmake_file = @tmake_file@ + toolexecdir = @toolexecdir@ +-toolexeclibdir = @toolexeclibdir@ ++toolexeclibdir = @libdir@ + top_build_prefix = @top_build_prefix@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ diff --git a/recipes/libffi/all/patches/0006-3.2.1-library-no-version-suffix.patch b/recipes/libffi/all/patches/0006-3.2.1-library-no-version-suffix.patch deleted file mode 100644 index 915977c19a4ff..0000000000000 --- a/recipes/libffi/all/patches/0006-3.2.1-library-no-version-suffix.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Makefile.in -+++ Makefile.in -@@ -723,7 +723,7 @@ - nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES) - LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS)) - AM_CFLAGS = $(am__append_41) --libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS) -+libffi_la_LDFLAGS = -no-undefined -avoid-version $(LTLDFLAGS) $(AM_LTLDFLAGS) - AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src - AM_CCASFLAGS = $(AM_CPPFLAGS) - all: fficonfig.h diff --git a/recipes/libffi/all/patches/0006-3.4.2-library-no-version-suffix.patch b/recipes/libffi/all/patches/0006-3.4.2-library-no-version-suffix.patch new file mode 100644 index 0000000000000..80c36df06441e --- /dev/null +++ b/recipes/libffi/all/patches/0006-3.4.2-library-no-version-suffix.patch @@ -0,0 +1,11 @@ +--- Makefile.in ++++ Makefile.in +@@ -610,7 +610,7 @@ + @LIBFFI_BUILD_VERSIONED_SHLIB_FALSE@libffi_version_dep = + @LIBFFI_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map + @LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map-sun +-libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version` ++libffi_version_info = -avoid-version + libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS) + libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep) + AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src diff --git a/recipes/libffi/all/patches/0006-3.4.3-library-no-version-suffix.patch b/recipes/libffi/all/patches/0006-3.4.3-library-no-version-suffix.patch new file mode 100644 index 0000000000000..0ad4d29b1c4ce --- /dev/null +++ b/recipes/libffi/all/patches/0006-3.4.3-library-no-version-suffix.patch @@ -0,0 +1,11 @@ +--- Makefile.in ++++ Makefile.in +@@ -615,7 +615,7 @@ + @LIBFFI_BUILD_VERSIONED_SHLIB_FALSE@libffi_version_dep = + @LIBFFI_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map + @LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map-sun +-libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version` ++libffi_version_info = -avoid-version + libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS) + libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep) + AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src diff --git a/recipes/libffi/all/test_package/CMakeLists.txt b/recipes/libffi/all/test_package/CMakeLists.txt index cd52a6ba7dbe0..80fe7087b6f9f 100644 --- a/recipes/libffi/all/test_package/CMakeLists.txt +++ b/recipes/libffi/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() -if(CONAN_SETTINGS_COMPILER_RUNTIME MATCHES ".*d") - add_compile_definitions(DISABLE_FFI_CALL) -endif() +project(test_package LANGUAGES C) + +find_package(libffi REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libffi::libffi) diff --git a/recipes/libffi/all/test_package/conanfile.py b/recipes/libffi/all/test_package/conanfile.py index a7a94271504b6..2d636399fa711 100644 --- a/recipes/libffi/all/test_package/conanfile.py +++ b/recipes/libffi/all/test_package/conanfile.py @@ -1,10 +1,30 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake, CMakeDeps, CMakeToolchain +from conan.tools.env import VirtualRunEnv +from conan.tools.microsoft import msvc_runtime_flag import os -class TclTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + cmake_deps = CMakeDeps(self) + cmake_deps.generate() + tc = CMakeToolchain(self) + if "d" in msvc_runtime_flag(self): + tc.preprocessor_definitions["DISABLE_FFI_CALL"] = 1 + tc.generate() + virtual_run_env = VirtualRunEnv(self) + virtual_run_env.generate() def build(self): cmake = CMake(self) @@ -12,6 +32,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libffi/all/test_v1_package/CMakeLists.txt b/recipes/libffi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..5b6f863b5bbc1 --- /dev/null +++ b/recipes/libffi/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup() +if(CONAN_SETTINGS_COMPILER_RUNTIME MATCHES ".*d") + add_compile_definitions(DISABLE_FFI_CALL) +endif() + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libffi/all/test_v1_package/conanfile.py b/recipes/libffi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..d4128b0450777 --- /dev/null +++ b/recipes/libffi/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libffi/config.yml b/recipes/libffi/config.yml index 17ab12fb3baf8..7f562b85ed6ac 100644 --- a/recipes/libffi/config.yml +++ b/recipes/libffi/config.yml @@ -1,5 +1,7 @@ versions: - "3.2.1": + "3.4.3": + folder: "all" + "3.4.2": folder: "all" "3.3": folder: "all" diff --git a/recipes/json-schema-validator/all/CMakeLists.txt b/recipes/libfreenect/all/CMakeLists.txt similarity index 100% rename from recipes/json-schema-validator/all/CMakeLists.txt rename to recipes/libfreenect/all/CMakeLists.txt diff --git a/recipes/libfreenect/all/conandata.yml b/recipes/libfreenect/all/conandata.yml new file mode 100644 index 0000000000000..65a8f154a2543 --- /dev/null +++ b/recipes/libfreenect/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "0.6.2": + url: "https://github.com/OpenKinect/libfreenect/archive/refs/tags/v0.6.2.tar.gz" + sha256: "e135f5e60ae290bf1aa403556211f0a62856a9e34f12f12400ec593620a36bfa" +patches: + "0.6.2": + - patch_file: "patches/0.6.2-fix-cmake.patch" + base_path: "source_subfolder" diff --git a/recipes/libfreenect/all/conanfile.py b/recipes/libfreenect/all/conanfile.py new file mode 100644 index 0000000000000..a7a776679854a --- /dev/null +++ b/recipes/libfreenect/all/conanfile.py @@ -0,0 +1,91 @@ +from conans import ConanFile, CMake, tools +import os +import glob +import shutil + + +class LibfreenectConan(ConanFile): + name = "libfreenect" + license = ("Apache-2.0", "GPL-2.0") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/OpenKinect/libfreenect" + description = "Drivers and libraries for the Xbox Kinect device." + topics = ("usb", "camera", "kinect") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake", "cmake_find_package" + exports_sources = ["CMakeLists.txt", "patches/*"] + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + self.requires("libusb/1.0.24") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_REDIST_PACKAGE"] = True + self._cmake.definitions["BUILD_EXAMPLES"] = False + self._cmake.definitions["BUILD_FAKENECT"] = False + self._cmake.definitions["BUILD_C_SYNC"] = False + self._cmake.definitions["BUILD_CPP"] = False + self._cmake.definitions["BUILD_CV"] = False + self._cmake.definitions["BUILD_AS3_SERVER"] = False + self._cmake.definitions["BUILD_PYTHON"] = False + self._cmake.definitions["BUILD_PYTHON2"] = False + self._cmake.definitions["BUILD_PYTHON3"] = False + self._cmake.definitions["BUILD_OPENNI2_DRIVER"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("APACHE20", src=self._source_subfolder, dst="licenses", keep_path=False) + self.copy("GPL", src=self._source_subfolder, dst="licenses", keep_path=False) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.names["pkg_config"] = "libfreenect" + self.cpp_info.libs = ["freenect"] + if self.settings.os == "Linux": + self.cpp_info.system_libs.append("m") diff --git a/recipes/libfreenect/all/patches/0.6.2-fix-cmake.patch b/recipes/libfreenect/all/patches/0.6.2-fix-cmake.patch new file mode 100644 index 0000000000000..bc6cf92f90057 --- /dev/null +++ b/recipes/libfreenect/all/patches/0.6.2-fix-cmake.patch @@ -0,0 +1,60 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 98283aa..c95fd4e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -75,7 +75,7 @@ ENDIF(PROJECT_OS_LINUX) + ###################################################################################### + + # Find packages needed to build library +-find_package(libusb-1.0 REQUIRED) ++find_package(libusb REQUIRED) + + # Check the endianness of the system + include (TestBigEndian) +@@ -106,6 +106,7 @@ endif (MSVC) + + set(C_CXX_FLAGS_DEFAULT "${C_FLAGS_WARNING} -O2") + ++if (0) + # These defaults can be overriden by -DCMAKE_C_FLAGS="" + set(CMAKE_C_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_C_FLAGS}") + # C Configurations +@@ -119,6 +120,7 @@ set(CMAKE_CXX_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -DDEBUG=1") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g") ++endif () + + # Pretty much everyone is going to need the main includes + include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 841873a..08a3bb5 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -21,13 +21,15 @@ ENDIF() + + LIST(APPEND SRC core.c tilt.c cameras.c flags.c usb_libusb10.c registration.c audio.c loader.c) + +-add_library (freenect SHARED ${SRC}) ++add_library (freenect ${SRC}) ++target_link_libraries (freenect libusb::libusb) + set_target_properties ( freenect PROPERTIES + VERSION ${PROJECT_VER} + SOVERSION ${PROJECT_APIVER}) +-install (TARGETS freenect +- DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}") ++install (TARGETS freenect) ++ + ++if (0) + add_library (freenectstatic STATIC ${SRC}) + set_target_properties (freenectstatic PROPERTIES OUTPUT_NAME freenect) + IF(UNIX AND NOT APPLE) +@@ -38,6 +40,7 @@ install (TARGETS freenectstatic + + target_link_libraries (freenect ${LIBUSB_1_LIBRARIES}) + target_link_libraries (freenectstatic ${LIBUSB_1_LIBRARIES}) ++endif () + + # Install the header files + install (FILES "../include/libfreenect.h" "../include/libfreenect_registration.h" "../include/libfreenect_audio.h" diff --git a/recipes/libfreenect/all/test_package/CMakeLists.txt b/recipes/libfreenect/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..172075b9703b7 --- /dev/null +++ b/recipes/libfreenect/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(libfreenect REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libfreenect::libfreenect) diff --git a/recipes/libfreenect/all/test_package/conanfile.py b/recipes/libfreenect/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/libfreenect/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libfreenect/all/test_package/test_package.c b/recipes/libfreenect/all/test_package/test_package.c new file mode 100644 index 0000000000000..00989f9d18c1e --- /dev/null +++ b/recipes/libfreenect/all/test_package/test_package.c @@ -0,0 +1,14 @@ +#include +#include +#include + +int main(int argc, char** argv) +{ + freenect_context* fn_ctx = NULL; + int ret = freenect_init(&fn_ctx, NULL); + if (ret < 0) + return ret; + + freenect_shutdown(fn_ctx); + return 0; +} diff --git a/recipes/libfreenect/config.yml b/recipes/libfreenect/config.yml new file mode 100644 index 0000000000000..a09c617182ab2 --- /dev/null +++ b/recipes/libfreenect/config.yml @@ -0,0 +1,3 @@ +versions: + "0.6.2": + folder: all diff --git a/recipes/openmesh/all/CMakeLists.txt b/recipes/libfreenect2/all/CMakeLists.txt similarity index 100% rename from recipes/openmesh/all/CMakeLists.txt rename to recipes/libfreenect2/all/CMakeLists.txt diff --git a/recipes/libfreenect2/all/conandata.yml b/recipes/libfreenect2/all/conandata.yml new file mode 100644 index 0000000000000..7fab4fd83db66 --- /dev/null +++ b/recipes/libfreenect2/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "0.2.1": + url: "https://github.com/OpenKinect/libfreenect2/archive/refs/tags/v0.2.1.tar.gz" + sha256: "c09e52c97b0e90335f4762ed5363293ad0fc1ea0064e578b879e7d15cc3559df" +patches: + "0.2.1": + - patch_file: "patches/0.2.1-fix-cmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/0.2.1-generate-resources.patch" + base_path: "source_subfolder" diff --git a/recipes/libfreenect2/all/conanfile.py b/recipes/libfreenect2/all/conanfile.py new file mode 100644 index 0000000000000..dbb951cc733d9 --- /dev/null +++ b/recipes/libfreenect2/all/conanfile.py @@ -0,0 +1,110 @@ +from conans import ConanFile, CMake, tools +import os + + +class Libfreenect2Conan(ConanFile): + name = "libfreenect2" + license = ("Apache-2.0", "GPL-2.0") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/OpenKinect/libfreenect2" + description = "Open source drivers for the Kinect for Windows v2 device." + topics = ("usb", "camera", "kinect") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_opencl": [True, False], + "with_opengl": [True, False], + "with_vaapi": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_opencl": True, + "with_opengl": True, + "with_vaapi": True, + } + generators = "cmake", "cmake_find_package" + exports_sources = ["CMakeLists.txt", "patches/*"] + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.os != "Linux": + del self.options.with_vaapi + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("libusb/1.0.24") + self.requires("libjpeg-turbo/2.1.1") + if self.options.with_opencl: + self.requires("opencl-headers/2021.04.29") + self.requires("opencl-icd-loader/2021.04.29") + if self.options.with_opengl: + self.requires("opengl/system") + self.requires("glfw/3.3.4") + if self.options.get_safe("with_vaapi"): + self.requires("vaapi/system") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_EXAMPLES"] = False + self._cmake.definitions["BUILD_OPENNI2_DRIVER"] = False + self._cmake.definitions["ENABLE_CXX11"] = True + self._cmake.definitions["ENABLE_OPENCL"] = self.options.with_opencl + self._cmake.definitions["ENABLE_CUDA"] = False # TODO: CUDA + self._cmake.definitions["ENABLE_OPENGL"] = self.options.with_opengl + self._cmake.definitions["ENABLE_VAAPI"] = self.options.get_safe("with_vaapi", False) + self._cmake.definitions["ENABLE_TEGRAJPEG"] = False # TODO: TegraJPEG + self._cmake.definitions["ENABLE_PROFILING"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("APACHE20", src=self._source_subfolder, dst="licenses", keep_path=False) + self.copy("GPL2", src=self._source_subfolder, dst="licenses", keep_path=False) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "freenect2" + self.cpp_info.names["cmake_find_package_multi"] = "freenect2" + self.cpp_info.names["pkg_config"] = "freenect2" + self.cpp_info.libs = tools.collect_libs(self) + if self.settings.os == "Linux": + self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) + elif self.settings.os == "Macos": + self.cpp_info.frameworks.extend(["VideoToolbox", "CoreFoundation", "CoreMedia", "CoreVideo"]) diff --git a/recipes/libfreenect2/all/patches/0.2.1-fix-cmake.patch b/recipes/libfreenect2/all/patches/0.2.1-fix-cmake.patch new file mode 100644 index 0000000000000..93324460a3d71 --- /dev/null +++ b/recipes/libfreenect2/all/patches/0.2.1-fix-cmake.patch @@ -0,0 +1,203 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d8ef047..a81aa8e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -90,8 +90,7 @@ SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) + SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) + + # dependencies +-FIND_PACKAGE(PkgConfig) # try find PKGConfig as it will be used if found +-FIND_PACKAGE(LibUSB REQUIRED) ++find_package(libusb REQUIRED) + + # Add includes + INCLUDE_DIRECTORIES( +@@ -99,7 +98,7 @@ INCLUDE_DIRECTORIES( + "${MY_DIR}/include/internal" + ${PROJECT_BINARY_DIR} # for generated headers + ${LIBFREENECT2_THREADING_INCLUDE_DIR} +- ${LibUSB_INCLUDE_DIRS} ++ # ${LibUSB_INCLUDE_DIRS} + ) + + SET(RESOURCES_INC_FILE "${PROJECT_BINARY_DIR}/resources.inc.h") +@@ -157,12 +156,12 @@ SET(SOURCES + ) + + SET(LIBRARIES +- ${LibUSB_LIBRARIES} ++ libusb::libusb + ${LIBFREENECT2_THREADING_LIBRARIES} + ) + + SET(LIBFREENECT2_DLLS +- ${LibUSB_DLL} ++ #${LibUSB_DLL} + ) + + SET(HAVE_VideoToolbox "no (Apple only)") +@@ -193,13 +192,14 @@ ENDIF(APPLE) + + SET(HAVE_VAAPI disabled) + IF(ENABLE_VAAPI) +- IF(PKG_CONFIG_FOUND) +- PKG_CHECK_MODULES(VAAPI libva libva-drm) +- ENDIF() +- FIND_PACKAGE(JPEG) ++ # IF(PKG_CONFIG_FOUND) ++ # PKG_CHECK_MODULES(VAAPI libva libva-drm) ++ # ENDIF() ++ find_package(vaapi REQUIRED) ++ find_package(libjpeg-turbo REQUIRED) + + SET(HAVE_VAAPI no) +- IF(VAAPI_FOUND AND JPEG_FOUND) ++ # IF(VAAPI_FOUND AND JPEG_FOUND) + SET(LIBFREENECT2_WITH_VAAPI_SUPPORT 1) + SET(HAVE_VAAPI yes) + +@@ -209,10 +209,10 @@ IF(ENABLE_VAAPI) + src/vaapi_rgb_packet_processor.cpp + ) + LIST(APPEND LIBRARIES +- ${VAAPI_LIBRARIES} +- ${JPEG_LIBRARY} ++ vaapi::vaapi ++ libjpeg-turbo::libjpeg-turbo + ) +- ENDIF() ++ # ENDIF() + ENDIF(ENABLE_VAAPI) + + SET(HAVE_TegraJPEG disabled) +@@ -237,38 +237,38 @@ IF(ENABLE_TEGRAJPEG) + ENDIF() + + IF(LIBFREENECT2_WITH_VT_SUPPORT) +- FIND_PACKAGE(TurboJPEG) ++ find_package(libjpeg-turbo REQUIRED) + ELSE() + # VAAPI can fail to start at runtime. It must have a fallback. +- FIND_PACKAGE(TurboJPEG REQUIRED) ++ find_package(libjpeg-turbo REQUIRED) + ENDIF() + + SET(HAVE_TurboJPEG no) +-IF(TurboJPEG_FOUND) ++IF(libjpeg-turbo_FOUND) + SET(LIBFREENECT2_WITH_TURBOJPEG_SUPPORT 1) + SET(HAVE_TurboJPEG yes) + +- INCLUDE_DIRECTORIES(${TurboJPEG_INCLUDE_DIRS}) ++ #INCLUDE_DIRECTORIES(${TurboJPEG_INCLUDE_DIRS}) + + LIST(APPEND SOURCES + src/turbo_jpeg_rgb_packet_processor.cpp + ) + + LIST(APPEND LIBRARIES +- ${TurboJPEG_LIBRARIES} ++ libjpeg-turbo::libjpeg-turbo + ) + + LIST(APPEND LIBFREENECT2_DLLS +- ${TurboJPEG_DLL} ++ #${TurboJPEG_DLL} + ) + ENDIF() + + SET(HAVE_OpenGL disabled) + IF(ENABLE_OPENGL) +- FIND_PACKAGE(GLFW3) +- FIND_PACKAGE(OpenGL) ++ find_package(glfw3 REQUIRED) ++ find_package(opengl_system REQUIRED) + SET(HAVE_OpenGL no) +- IF(GLFW3_FOUND AND OPENGL_FOUND) ++ # IF(GLFW3_FOUND AND OPENGL_FOUND) + SET(LIBFREENECT2_WITH_OPENGL_SUPPORT 1) + SET(HAVE_OpenGL yes) + +@@ -276,8 +276,8 @@ IF(ENABLE_OPENGL) + + LIST(APPEND LIBFREENECT2_DLLS ${GLFW3_DLL}) + LIST(APPEND LIBRARIES +- ${GLFW3_LIBRARIES} +- ${OPENGL_gl_LIBRARY} ++ glfw::glfw ++ opengl::opengl + ) + LIST(APPEND SOURCES + src/flextGL.cpp +@@ -292,19 +292,19 @@ IF(ENABLE_OPENGL) + src/shader/stage1.fs + src/shader/stage2.fs + ) +- ENDIF() ++ # ENDIF() + ENDIF(ENABLE_OPENGL) + + SET(HAVE_OpenCL disabled) + IF(ENABLE_OPENCL) +- FIND_PACKAGE(OpenCL) ++ find_package(opencl-icd-loader REQUIRED) + + SET(HAVE_OpenCL no) +- IF(OpenCL_FOUND) ++ #IF(OpenCL_FOUND) + SET(LIBFREENECT2_WITH_OPENCL_SUPPORT 1) + SET(HAVE_OpenCL yes) + +- IF(UNIX AND NOT APPLE) ++ IF(0) + INCLUDE(CheckOpenCLICDLoader) + IF(OpenCL_C_WORKS AND NOT OpenCL_CXX_WORKS) + SET(LIBFREENECT2_OPENCL_ICD_LOADER_IS_OLD 1) +@@ -312,7 +312,7 @@ IF(ENABLE_OPENCL) + MESSAGE(WARNING "Your libOpenCL.so is incompatible with CL/cl.h. Install ocl-icd-opencl-dev to update libOpenCL.so?") + ENDIF() + ENDIF() +- INCLUDE_DIRECTORIES(${OpenCL_INCLUDE_DIRS}) ++ #INCLUDE_DIRECTORIES(${OpenCL_INCLUDE_DIRS}) + + LIST(APPEND SOURCES + src/opencl_depth_packet_processor.cpp +@@ -320,7 +320,7 @@ IF(ENABLE_OPENCL) + ) + + LIST(APPEND LIBRARIES +- ${OpenCL_LIBRARIES} ++ opencl-icd-loader::opencl-icd-loader + ) + + LIST(APPEND RESOURCES +@@ -334,7 +334,7 @@ IF(ENABLE_OPENCL) + IF(UNIX AND NOT APPLE) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") + ENDIF() +- ENDIF(OpenCL_FOUND) ++ #ENDIF(OpenCL_FOUND) + ENDIF(ENABLE_OPENCL) + + SET(HAVE_CUDA disabled) +@@ -385,7 +385,7 @@ IF(ENABLE_CUDA) + ENDIF(ENABLE_CUDA) + + # RPATH handling for CUDA 8.0 libOpenCL.so conflict. See #804. +-IF(HAVE_OpenCL STREQUAL yes AND UNIX AND NOT APPLE) ++IF(0) + FILE(GLOB CUDA_ld_so_conf /etc/ld.so.conf.d/cuda*.conf) + IF(CUDA_ld_so_conf) + MESSAGE(WARNING "Your CUDA installation overrides OpenCL system library path.") +@@ -403,9 +403,9 @@ ENDIF() + # Both command line -DCMAKE_INSTALL_RPATH=... and CMake GUI settings are accepted. + # + # Anyway if wrong versions of libusb is used, errors will be reported explicitly. +-IF(NOT DEFINED CMAKE_INSTALL_RPATH AND NOT ${LibUSB_LIBDIR} MATCHES "^/usr/lib") ++IF(0 AND NOT DEFINED CMAKE_INSTALL_RPATH AND NOT ${LibUSB_LIBDIR} MATCHES "^/usr/lib") + SET(CMAKE_INSTALL_RPATH ${LibUSB_LIBDIR} CACHE STRING "Set RPATH for a private libusb") +-ELSEIF(DEFINED CMAKE_INSTALL_RPATH) ++ELSEIF(0 AND DEFINED CMAKE_INSTALL_RPATH) + SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} CACHE STRING "Set RPATH for a private libusb") + ENDIF() + IF(DEFINED CMAKE_INSTALL_RPATH) diff --git a/recipes/libfreenect2/all/patches/0.2.1-generate-resources.patch b/recipes/libfreenect2/all/patches/0.2.1-generate-resources.patch new file mode 100644 index 0000000000000..36258bc3f57ef --- /dev/null +++ b/recipes/libfreenect2/all/patches/0.2.1-generate-resources.patch @@ -0,0 +1,41 @@ +This patch avoids compiling 'generate_resources_tool' to generate C sources of binary resources +and instead uses CMake functionality to generate the files. This patch is necessary to enable +cross-compiling without setting up host compiling environment. @sh0 + +diff --git a/cmake_modules/GenerateResources.cmake b/cmake_modules/GenerateResources.cmake +index 8616e38..6deea9a 100644 +--- a/cmake_modules/GenerateResources.cmake ++++ b/cmake_modules/GenerateResources.cmake +@@ -1,14 +1,23 @@ + FUNCTION(GENERATE_RESOURCES OUTPUT BASE_FOLDER) + +-ADD_EXECUTABLE(generate_resources_tool +- tools/generate_resources.cpp +-) +- +-ADD_CUSTOM_COMMAND( +- OUTPUT ${OUTPUT} +- COMMAND generate_resources_tool ${BASE_FOLDER} ${ARGN} > ${OUTPUT} +- WORKING_DIRECTORY ${BASE_FOLDER} +- DEPENDS generate_resources_tool ${ARGN} ++set(RES_INDEX "0") ++foreach (SRC_ENTRY ${ARGN}) ++ set(SRC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_ENTRY}") ++ get_filename_component(SRC_NAME "${SRC_ENTRY}" NAME) ++ file(SIZE "${SRC_PATH}" DATA_SIZE) ++ file(READ "${SRC_PATH}" DATA_BIN HEX) ++ string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," DATA_HEX ${DATA_BIN}) ++ string(APPEND RES_CONTENT "static unsigned char resource${RES_INDEX}[] = {\n ${DATA_HEX}\n};\n") ++ string(APPEND RES_DESCRIPTOR " { \"${SRC_NAME}\", resource${RES_INDEX}, sizeof(resource${RES_INDEX}) },\n") ++ math(EXPR RES_INDEX "${RES_INDEX} + 1") ++endforeach () ++file(WRITE "${OUTPUT}" ++ "${RES_CONTENT}" ++ "static ResourceDescriptor resource_descriptors[] = {\n" ++ "${RES_DESCRIPTOR}" ++ " {NULL, NULL, 0},\n" ++ "};\n" ++ "static int resource_descriptors_length = ${RES_INDEX};\n" + ) + + ENDFUNCTION(GENERATE_RESOURCES) diff --git a/recipes/libfreenect2/all/test_package/CMakeLists.txt b/recipes/libfreenect2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5742a7e29c0d5 --- /dev/null +++ b/recipes/libfreenect2/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(freenect2 REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ${freenect2_LIBRARIES}) +target_include_directories(${PROJECT_NAME} PRIVATE ${freenect2_INCLUDE_DIRS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/libfreenect2/all/test_package/conanfile.py b/recipes/libfreenect2/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3da371b660e0a --- /dev/null +++ b/recipes/libfreenect2/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libfreenect2/all/test_package/test_package.cpp b/recipes/libfreenect2/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..043111f826b8f --- /dev/null +++ b/recipes/libfreenect2/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + libfreenect2::Freenect2 freenect2; + return EXIT_SUCCESS; +} diff --git a/recipes/libfreenect2/config.yml b/recipes/libfreenect2/config.yml new file mode 100644 index 0000000000000..f975c1e3261f7 --- /dev/null +++ b/recipes/libfreenect2/config.yml @@ -0,0 +1,3 @@ +versions: + "0.2.1": + folder: all diff --git a/recipes/libftdi/1.x/CMakeLists.txt b/recipes/libftdi/1.x/CMakeLists.txt new file mode 100644 index 0000000000000..f4e5078f42228 --- /dev/null +++ b/recipes/libftdi/1.x/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 2.8) +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) +add_subdirectory(source_subfolder) diff --git a/recipes/libftdi/1.x/conandata.yml b/recipes/libftdi/1.x/conandata.yml new file mode 100644 index 0000000000000..db04076175670 --- /dev/null +++ b/recipes/libftdi/1.x/conandata.yml @@ -0,0 +1,9 @@ +sources: + "1.5": + sha256: 7c7091e9c86196148bd41177b4590dccb1510bfe6cea5bf7407ff194482eb049 + url: "https://www.intra2net.com/en/developer/libftdi/download/libftdi1-1.5.tar.bz2" +patches: + "1.5": + - patch_file: "patches/0001-cmake-targets.patch" + base_path: "source_subfolder" + diff --git a/recipes/libftdi/1.x/conanfile.py b/recipes/libftdi/1.x/conanfile.py new file mode 100644 index 0000000000000..951dbaa4f8b8a --- /dev/null +++ b/recipes/libftdi/1.x/conanfile.py @@ -0,0 +1,103 @@ +import os +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + + +class LibFtdiConan(ConanFile): + name = "libftdi" + description = "A library to talk to FTDI chips" + license = "LGPL-2.0-only", "GPLv2-or-later" + topics = ("conan", "libftdi1") + homepage = "https://www.intra2net.com/en/developer/libftdi/" + url = "https://github.com/conan-io/conan-center-index" + exports_sources = ["CMakeLists.txt", "patches/*"] + generators = "cmake", "cmake_find_package", "pkg_config" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared" : [True, False], + "fPIC" : [True, False], + "enable_cpp_wrapper" : [True, False], + "build_eeprom_tool" : [True, False], + "use_streaming" : [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "enable_cpp_wrapper": True, + "build_eeprom_tool" : False, + "use_streaming" : True, + } + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = "libftdi1-" + self.version + os.rename(extracted_dir, self._source_subfolder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.compiler == "Visual Studio": + self.options.use_streaming = False + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def _configure_cmake(self): + if self._cmake: + return self._cmake + + self._cmake = CMake(self) + options = { + "BUILD_TESTS": False, + "EXAMPLES": False, + "FTDI_EEPROM": self.options.build_eeprom_tool, + "FTDIPP" : self.options.enable_cpp_wrapper, + "STATICLIBS": not self.options.shared, + "ENABLE_STREAMING": self.options.use_streaming, + } + self._cmake.definitions.update(options) + self._cmake.configure() + return self._cmake + + def requirements(self): + self.requires("libusb/1.0.24") + self.requires("boost/1.75.0") + + def validate(self): + if self.settings.compiler == "Visual Studio" and self.options.use_streaming: + raise ConanInvalidConfiguration("VS doesn't not compile with enabled option use_streaming") + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + lib_folder = os.path.join(self.package_folder, "lib",) + tools.rmdir(os.path.join(lib_folder, "cmake")) + tools.rmdir(os.path.join(lib_folder, "pkgconfig")) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "LibFTDI1" + self.cpp_info.names["cmake_find_package_multi"] = "LibFTDI1" + self.cpp_info.names["pkgconfig"] = "libftdi1" + + self.cpp_info.components["ftdi"].names["pkg_config"] = "libftdi1" + self.cpp_info.components["ftdi"].libs = ["ftdi1"] + self.cpp_info.components["ftdi"].requires = ["libusb::libusb"] + self.cpp_info.components["ftdi"].includedirs.append(os.path.join("include", "libftdi1")) + + self.cpp_info.components["ftdipp"].names["pkg_config"] = "libftdi1pp" + self.cpp_info.components["ftdipp"].libs = ["ftdipp1"] + self.cpp_info.components["ftdipp"].requires = ["ftdi", "boost::headers"] + self.cpp_info.components["ftdipp"].includedirs.append(os.path.join("include", "libftdipp1")) diff --git a/recipes/libftdi/1.x/patches/0001-cmake-targets.patch b/recipes/libftdi/1.x/patches/0001-cmake-targets.patch new file mode 100644 index 0000000000000..751ff4099d9f0 --- /dev/null +++ b/recipes/libftdi/1.x/patches/0001-cmake-targets.patch @@ -0,0 +1,829 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5aecafc..abb133f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,36 +1,54 @@ +-# Project + project(libftdi1 C) ++ + set(MAJOR_VERSION 1) + set(MINOR_VERSION 5) + set(PACKAGE libftdi1) + set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION}) + set(VERSION ${VERSION_STRING}) +-set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) ++list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +-# CMake + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE RelWithDebInfo) + endif("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_COLOR_MAKEFILE ON) +-cmake_minimum_required(VERSION 2.6 FATAL_ERROR) ++ ++cmake_minimum_required(VERSION 3.0 FATAL_ERROR) ++if(POLICY CMP0057) ++ cmake_policy(SET CMP0057 NEW) ++endif() ++if(POLICY CMP0011) ++ cmake_policy(SET CMP0011 NEW) ++endif() ++if(POLICY CMP0099) ++ cmake_policy(SET CMP0099 NEW) ++endif() + + add_definitions(-Wall) + + include(CMakeOptions.txt) + ++set(as_subproject LibFTDI) ++macro(find_package) ++ if(NOT ${ARGV0} IN_LIST as_subproject) ++ _find_package(${ARGV}) ++ endif() ++endmacro() ++ + # Debug build +-message("-- Build type: ${CMAKE_BUILD_TYPE}") ++message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") + if(${CMAKE_BUILD_TYPE} STREQUAL Debug) + add_definitions(-DDEBUG) + endif(${CMAKE_BUILD_TYPE} STREQUAL Debug) + +-# find libusb +-find_package ( USB1 REQUIRED ) +-include_directories ( ${LIBUSB_INCLUDE_DIR} ) ++find_package (libusb REQUIRED) ++ ++if (FTDIPP) ++ find_package(Boost REQUIRED) ++endif() + +-# Find Boost +-if (FTDIPP OR BUILD_TESTS) +- find_package( Boost REQUIRED ) ++if (APPLE) ++ find_library(APPLE_CF CoreFoundation) ++ find_library(APPLE_IOK IOKit) + endif() + + # Set components +@@ -97,7 +115,7 @@ if ( WIN32 ) + set ( CPACK_NSIS_MODIFY_PATH ON ) + endif () + +-set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE) ++set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) + + set(CPACK_SOURCE_GENERATOR TGZ) + set(CPACK_SOURCE_IGNORE_FILES "\\\\.git;~$;build/") +@@ -136,7 +154,7 @@ endif () + + add_subdirectory(src) + if ( FTDIPP ) +- project(libftdipp1 C CXX) ++ project(libftdi1 C CXX) + add_subdirectory(ftdipp) + endif () + if ( PYTHON_BINDINGS ) +@@ -150,6 +168,9 @@ if ( EXAMPLES ) + endif () + add_subdirectory(packages) + if ( BUILD_TESTS ) ++ project(libftdi1 C CXX) ++ find_package(Boost COMPONENTS unit_test_framework REQUIRED) ++ enable_testing() + add_subdirectory(test) + endif () + +@@ -165,8 +186,8 @@ if(${WIN32}) + set(libdir ${CMAKE_INSTALL_PREFIX}/bin) + endif(${WIN32}) + +-configure_file(${CMAKE_SOURCE_DIR}/libftdi1.pc.in ${CMAKE_BINARY_DIR}/libftdi1.pc @ONLY) +-configure_file(${CMAKE_SOURCE_DIR}/libftdipp1.pc.in ${CMAKE_BINARY_DIR}/libftdipp1.pc @ONLY) ++configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libftdi1.pc.in ${CMAKE_BINARY_DIR}/libftdi1.pc @ONLY) ++configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libftdipp1.pc.in ${CMAKE_BINARY_DIR}/libftdipp1.pc @ONLY) + install(FILES ${CMAKE_BINARY_DIR}/libftdi1.pc ${CMAKE_BINARY_DIR}/libftdipp1.pc + DESTINATION lib${LIB_SUFFIX}/pkgconfig) + +@@ -202,30 +223,25 @@ set ( LIBFTDI_VERSION_MINOR ${MINOR_VERSION} ) + + set ( LIBFTDI_USE_FILE ${CMAKE_INSTALL_PREFIX}/${LIBFTDI_CMAKE_CONFIG_DIR}/UseLibFTDI1.cmake ) + +-if(CMAKE_VERSION VERSION_LESS 2.8.8) +- configure_file ( cmake/LibFTDI1Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake @ONLY ) +- configure_file ( cmake/LibFTDI1ConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1ConfigVersion.cmake @ONLY ) +-else () +- include(CMakePackageConfigHelpers) +- +- configure_package_config_file ( +- cmake/LibFTDI1Config.cmake.in +- ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake +- INSTALL_DESTINATION ${LIBFTDI_CMAKE_CONFIG_DIR} +- PATH_VARS +- LIBFTDI_USE_FILE +- LIBFTDI_ROOT_DIR +- LIBFTDI_INCLUDE_DIR +- LIBFTDI_INCLUDE_DIRS +- LIBFTDI_LIBRARY_DIRS +- NO_CHECK_REQUIRED_COMPONENTS_MACRO +- ) +- write_basic_package_version_file ( +- LibFTDI1ConfigVersion.cmake +- VERSION ${LIBFTDI_VERSION_STRING} +- COMPATIBILITY AnyNewerVersion +- ) +-endif () ++include(CMakePackageConfigHelpers) ++ ++configure_package_config_file ( ++cmake/LibFTDI1Config.cmake.in ++${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake ++INSTALL_DESTINATION ${LIBFTDI_CMAKE_CONFIG_DIR} ++PATH_VARS ++ LIBFTDI_USE_FILE ++ LIBFTDI_ROOT_DIR ++ LIBFTDI_INCLUDE_DIR ++ LIBFTDI_INCLUDE_DIRS ++ LIBFTDI_LIBRARY_DIRS ++NO_CHECK_REQUIRED_COMPONENTS_MACRO ++) ++write_basic_package_version_file ( ++LibFTDI1ConfigVersion.cmake ++VERSION ${LIBFTDI_VERSION_STRING} ++COMPATIBILITY AnyNewerVersion ++) + + + install ( FILES +@@ -240,7 +256,7 @@ include(CPack) + + message (STATUS "Summary of build options: + +- Build static libs: ${STATICLIBS} ++ Build shared libs: ${BUILD_SHARED_LIBS} + Build C++ bindings: ${FTDIPP} + Build Python bindings: ${PYTHON_BINDINGS} + Build ftdi_eeprom: ${FTDI_EEPROM} +diff --git a/CMakeOptions.txt b/CMakeOptions.txt +index 07b5887..1088090 100644 +--- a/CMakeOptions.txt ++++ b/CMakeOptions.txt +@@ -1,4 +1,4 @@ +-option ( STATICLIBS "Build static libraries" ON ) ++option ( BUILD_SHARED_LIBS "Build static libraries" OFF ) + option ( BUILD_TESTS "Build unit tests with Boost Unit Test framework" OFF ) + option ( DOCUMENTATION "Generate API documentation with Doxygen" OFF ) + option ( EXAMPLES "Build example programs" ON ) +@@ -6,3 +6,4 @@ option ( FTDIPP "Build C++ binding library libftdi1++" OFF ) + option ( FTDI_EEPROM "Build ftdi_eeprom" ON ) + option ( PYTHON_BINDINGS "Build python bindings via swig" OFF ) + option ( LINK_PYTHON_LIBRARY "Link against python libraries" OFF ) ++option ( ENABLE_STREAMING "Enable data streaming" OFF ) +\ No newline at end of file +diff --git a/cmake/FindConfuse.cmake b/cmake/FindConfuse.cmake +deleted file mode 100644 +index f6af7d5..0000000 +--- a/cmake/FindConfuse.cmake ++++ /dev/null +@@ -1,74 +0,0 @@ +-# libConfuse is a configuration file parser library +-# available at http://www.nongnu.org/confuse/ +-# +-# The module defines the following variables: +-# CONFUSE_FOUND - the system has Confuse +-# CONFUSE_INCLUDE_DIR - where to find confuse.h +-# CONFUSE_INCLUDE_DIRS - confuse includes +-# CONFUSE_LIBRARY - where to find the Confuse library +-# CONFUSE_LIBRARIES - additional libraries +-# CONFUSE_ROOT_DIR - root dir (ex. /usr/local) +- +-#============================================================================= +-# Copyright 2010-2013, Julien Schueller +-# All rights reserved. +-# +-# Redistribution and use in source and binary forms, with or without +-# modification, are permitted provided that the following conditions are met: +-# +-# 1. Redistributions of source code must retain the above copyright notice, this +-# list of conditions and the following disclaimer. +-# 2. Redistributions in binary form must reproduce the above copyright notice, +-# this list of conditions and the following disclaimer in the documentation +-# and/or other materials provided with the distribution. +-# +-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +-# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +- +-# The views and conclusions contained in the software and documentation are those +-# of the authors and should not be interpreted as representing official policies, +-# either expressed or implied, of the FreeBSD Project. +-#============================================================================= +- +- +-find_path ( CONFUSE_INCLUDE_DIR +- NAMES confuse.h +-) +- +-set ( CONFUSE_INCLUDE_DIRS ${CONFUSE_INCLUDE_DIR} ) +- +-find_library ( CONFUSE_LIBRARY +- NAMES confuse +-) +- +-set ( CONFUSE_LIBRARIES ${CONFUSE_LIBRARY} ) +- +- +-# try to guess root dir from include dir +-if ( CONFUSE_INCLUDE_DIR ) +- string ( REGEX REPLACE "(.*)/include.*" "\\1" CONFUSE_ROOT_DIR ${CONFUSE_INCLUDE_DIR} ) +-# try to guess root dir from library dir +-elseif ( CONFUSE_LIBRARY ) +- string ( REGEX REPLACE "(.*)/lib[/|32|64].*" "\\1" CONFUSE_ROOT_DIR ${CONFUSE_LIBRARY} ) +-endif () +- +- +-# handle the QUIETLY and REQUIRED arguments +-include ( FindPackageHandleStandardArgs ) +-find_package_handle_standard_args( Confuse DEFAULT_MSG CONFUSE_LIBRARY CONFUSE_INCLUDE_DIR ) +- +-mark_as_advanced ( +- CONFUSE_LIBRARY +- CONFUSE_LIBRARIES +- CONFUSE_INCLUDE_DIR +- CONFUSE_INCLUDE_DIRS +- CONFUSE_ROOT_DIR +-) +diff --git a/cmake/FindLibConfuse.cmake b/cmake/FindLibConfuse.cmake +new file mode 100644 +index 0000000..19e63c5 +--- /dev/null ++++ b/cmake/FindLibConfuse.cmake +@@ -0,0 +1,21 @@ ++find_package(PkgConfig) ++pkg_check_modules(PC_LibConfuse libconfuse) ++ ++find_path(LibConfuse_INCLUDE_DIR confuse.h ++ PATHS ${PC_LibConfuse_INCLUDEDIR} ${PC_LibConfuse_INCLUDE_DIRS}) ++ ++find_library(LibConfuse_LIBRARY NAMES confuse ++ PATHS ${PC_LibConfuse_LIBDIR} ${PC_LibConfuse_LIBRARY_DIRS}) ++ ++include(FindPackageHandleStandardArgs) ++find_package_handle_standard_args(LibConfuse DEFAULT_MSG LibConfuse_LIBRARY LibConfuse_INCLUDE_DIR) ++ ++if (LibConfuse_FOUND AND NOT TARGET LibConfuse::LibConfuse) ++ add_library(LibConfuse::LibConfuse INTERFACE IMPORTED) ++ set_target_properties(LibConfuse::LibConfuse PROPERTIES ++ INTERFACE_LINK_LIBRARIES "${LibConfuse_LIBRARY}" ++ INTERFACE_INCLUDE_DIRECTORIES "${LibConfuse_INCLUDE_DIR}" ++ ) ++endif() ++ ++mark_as_advanced(LibConfuse_INCLUDE_DIR LibConfuse_LIBRARY) +diff --git a/cmake/FindLibintl.cmake b/cmake/FindLibintl.cmake +deleted file mode 100644 +index 65ed91c..0000000 +--- a/cmake/FindLibintl.cmake ++++ /dev/null +@@ -1,47 +0,0 @@ +-# Try to find Libintl functionality +-# Once done this will define +-# +-# LIBINTL_FOUND - system has Libintl +-# LIBINTL_INCLUDE_DIR - Libintl include directory +-# LIBINTL_LIBRARIES - Libraries needed to use Libintl +-# +-# TODO: This will enable translations only if Gettext functionality is +-# present in libc. Must have more robust system for release, where Gettext +-# functionality can also reside in standalone Gettext library, or the one +-# embedded within kdelibs (cf. gettext.m4 from Gettext source). +- +-# Copyright (c) 2006, Chusslove Illich, +-# Copyright (c) 2007, Alexander Neundorf, +-# +-# Redistribution and use is allowed according to the terms of the BSD license. +-# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +- +-if(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND) +- set(Libintl_FIND_QUIETLY TRUE) +-endif(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND) +- +-find_path(LIBINTL_INCLUDE_DIR libintl.h) +- +-set(LIBINTL_LIB_FOUND FALSE) +- +-if(LIBINTL_INCLUDE_DIR) +- include(CheckFunctionExists) +- check_function_exists(dgettext LIBINTL_LIBC_HAS_DGETTEXT) +- +- if (LIBINTL_LIBC_HAS_DGETTEXT) +- set(LIBINTL_LIBRARIES) +- set(LIBINTL_LIB_FOUND TRUE) +- else (LIBINTL_LIBC_HAS_DGETTEXT) +- find_library(LIBINTL_LIBRARIES NAMES intl libintl ) +- if(LIBINTL_LIBRARIES) +- set(LIBINTL_LIB_FOUND TRUE) +- endif(LIBINTL_LIBRARIES) +- endif (LIBINTL_LIBC_HAS_DGETTEXT) +- +-endif(LIBINTL_INCLUDE_DIR) +- +-include(FindPackageHandleStandardArgs) +-find_package_handle_standard_args(Libintl DEFAULT_MSG LIBINTL_INCLUDE_DIR LIBINTL_LIB_FOUND) +- +-mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARIES LIBINTL_LIBC_HAS_DGETTEXT LIBINTL_LIB_FOUND) +- +diff --git a/cmake/FindUSB1.cmake b/cmake/FindUSB1.cmake +deleted file mode 100644 +index b90e297..0000000 +--- a/cmake/FindUSB1.cmake ++++ /dev/null +@@ -1,37 +0,0 @@ +-# - Try to find the freetype library +-# Once done this defines +-# +-# LIBUSB_FOUND - system has libusb +-# LIBUSB_INCLUDE_DIR - the libusb include directory +-# LIBUSB_LIBRARIES - Link these to use libusb +- +-# Copyright (c) 2006, 2008 Laurent Montel, +-# +-# Redistribution and use is allowed according to the terms of the BSD license. +-# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +- +- +-if (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) +- +- # in cache already +- set(LIBUSB_FOUND TRUE) +- +-else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) +- # use pkg-config to get the directories and then use these values +- # in the FIND_PATH() and FIND_LIBRARY() calls +- find_package(PkgConfig) +- pkg_check_modules(PC_LIBUSB libusb-1.0) +- +- FIND_PATH(LIBUSB_INCLUDE_DIR libusb.h +- PATH_SUFFIXES libusb-1.0 +- PATHS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS}) +- +- FIND_LIBRARY(LIBUSB_LIBRARIES NAMES usb-1.0 +- PATHS ${PC_LIBUSB_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS}) +- +- include(FindPackageHandleStandardArgs) +- FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIR) +- +- MARK_AS_ADVANCED(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES) +- +-endif (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) +diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt +index 6fc3c09..0d6a6c1 100644 +--- a/examples/CMakeLists.txt ++++ b/examples/CMakeLists.txt +@@ -1,9 +1,3 @@ +-# Includes +-include_directories( ${CMAKE_CURRENT_SOURCE_DIR} +- ${CMAKE_CURRENT_BINARY_DIR} +- ) +- +-# Targets + add_executable(simple simple.c) + add_executable(bitbang bitbang.c) + add_executable(bitbang2 bitbang2.c) +@@ -15,33 +9,28 @@ add_executable(baud_test baud_test.c) + add_executable(stream_test stream_test.c) + add_executable(eeprom eeprom.c) + add_executable(async async.c) +-add_executable(purge_test purge_test.c) ++if(NOT MINGW) ++ add_executable(purge_test purge_test.c) ++endif(NOT MINGW) + +-# Linkage +-target_link_libraries(simple ftdi1) +-target_link_libraries(bitbang ftdi1) +-target_link_libraries(bitbang2 ftdi1) +-target_link_libraries(bitbang_cbus ftdi1) +-target_link_libraries(bitbang_ft2232 ftdi1) +-target_link_libraries(find_all ftdi1) +-target_link_libraries(serial_test ftdi1) +-target_link_libraries(baud_test ftdi1) +-target_link_libraries(stream_test ftdi1) +-target_link_libraries(eeprom ftdi1) +-target_link_libraries(async ftdi1) +-target_link_libraries(purge_test ftdi1) ++find_package(LibFTDI REQUIRED) + +-# libftdi++ examples +-if( FTDIPP ) +- include_directories(BEFORE ${CMAKE_SOURCE_DIR}/ftdipp +- ${Boost_INCLUDE_DIRS}) ++target_link_libraries(simple PRIVATE LibFTDI::ftdi1) ++target_link_libraries(bitbang PRIVATE LibFTDI::ftdi1) ++target_link_libraries(bitbang2 PRIVATE LibFTDI::ftdi1) ++target_link_libraries(bitbang_cbus PRIVATE LibFTDI::ftdi1) ++target_link_libraries(bitbang_ft2232 PRIVATE LibFTDI::ftdi1) ++target_link_libraries(find_all PRIVATE LibFTDI::ftdi1) ++target_link_libraries(serial_test PRIVATE LibFTDI::ftdi1) ++target_link_libraries(baud_test PRIVATE LibFTDI::ftdi1) ++target_link_libraries(stream_test PRIVATE LibFTDI::ftdi1) ++target_link_libraries(eeprom PRIVATE LibFTDI::ftdi1) ++target_link_libraries(async PRIVATE LibFTDI::ftdi1) ++if(NOT MINGW) ++ target_link_libraries(purge_test PRIVATE LibFTDI::ftdi1) ++endif(NOT MINGW) + +- # Target ++if( FTDIPP ) + add_executable(find_all_pp find_all_pp.cpp) +- +- # Linkage +- target_link_libraries(find_all_pp ftdipp1) ++ target_link_libraries(find_all_pp PRIVATE LibFTDI::ftdipp1) + endif( FTDIPP ) +- +-# Source includes +-include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src) +diff --git a/examples/bitbang_cbus.c b/examples/bitbang_cbus.c +index b902b50..359097e 100644 +--- a/examples/bitbang_cbus.c ++++ b/examples/bitbang_cbus.c +@@ -60,8 +60,9 @@ int main(void) + while (1) + { + // Set bitmask from input +- fgets(input, sizeof(input) - 1, stdin); +- if (input[0] == '\n') break; ++ char *s = fgets(input, sizeof(input) - 1, stdin); ++ if (s == NULL || input[0] == '\n') ++ break; + bitmask = strtol(input, NULL, 0); + printf("Using bitmask 0x%02x\n", bitmask); + f = ftdi_set_bitmode(ftdi, bitmask, BITMODE_CBUS); +diff --git a/examples/cmake_example/CMakeLists.txt b/examples/cmake_example/CMakeLists.txt +index fe203ed..99571a0 100644 +--- a/examples/cmake_example/CMakeLists.txt ++++ b/examples/cmake_example/CMakeLists.txt +@@ -1,13 +1,10 @@ +-cmake_minimum_required ( VERSION 2.8 ) +- ++cmake_minimum_required ( VERSION 3.0 ) + project ( example C ) + +-find_package ( LibFTDI1 NO_MODULE REQUIRED ) +-include ( ${LIBFTDI_USE_FILE} ) ++find_package ( LibFTDI NO_MODULE REQUIRED ) + + add_executable ( example main.c ) +-target_link_libraries( example ${LIBFTDI_LIBRARIES} ) ++target_link_libraries( example PRIVATE LibFTDI::ftdi1 ) + +-install ( TARGETS example +- DESTINATION bin ) ++install ( TARGETS example DESTINATION bin ) + +diff --git a/ftdi_eeprom/CMakeLists.txt b/ftdi_eeprom/CMakeLists.txt +index 8737c4b..e83a0fc 100644 +--- a/ftdi_eeprom/CMakeLists.txt ++++ b/ftdi_eeprom/CMakeLists.txt +@@ -1,5 +1,5 @@ +-find_package ( Confuse REQUIRED ) +-find_package ( Libintl ) ++find_package (LibConfuse REQUIRED ) ++find_package (Intl) + + # determine docdir + include(GNUInstallDirs) +@@ -13,32 +13,30 @@ endif(NOT CMAKE_INSTALL_DOCDIR) + + message(STATUS "Building ftdi_eeprom") + +-include_directories ( ${CONFUSE_INCLUDE_DIRS} ) +-list ( APPEND libs ${CONFUSE_LIBRARIES} ) +- +-if ( LIBINTL_FOUND ) +- include_directories ( ${LIBINTL_INCLUDE_DIR} ) +- list ( APPEND libs ${LIBINTL_LIBRARIES} ) +-endif () +- +- + # Version defines + set ( EEPROM_MAJOR_VERSION 0 ) + set ( EEPROM_MINOR_VERSION 17 ) + set ( EEPROM_VERSION_STRING ${EEPROM_MAJOR_VERSION}.${EEPROM_MINOR_VERSION} ) + +-include_directories ( BEFORE ${CMAKE_SOURCE_DIR}/src ) +-include_directories ( BEFORE ${CMAKE_CURRENT_BINARY_DIR} ) +- + configure_file( + ftdi_eeprom_version.h.in + ${CMAKE_CURRENT_BINARY_DIR}/ftdi_eeprom_version.h + ) + + add_executable ( ftdi_eeprom main.c ) +-target_link_libraries ( ftdi_eeprom ftdi1 ${CONFUSE_LIBRARIES} ) +-if ( LIBINTL_FOUND ) +- target_link_libraries ( ftdi_eeprom ${LIBINTL_LIBRARIES} ) ++find_package(Threads) ++target_link_libraries ( ftdi_eeprom ++ PRIVATE ++ LibFTDI::ftdi1 ++ LibConfuse::LibConfuse ++ libusb::libusb ++ ) ++target_include_directories(ftdi_eeprom PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) ++ ++if ( Intl_FOUND ) ++ target_link_libraries ( ftdi_eeprom PRIVATE ${Intl_LIBRARIES} ) ++ target_include_directories ( ftdi_eeprom PRIVATE ${Intl_INCLUDE_DIRS}) + endif () ++ + install ( TARGETS ftdi_eeprom DESTINATION bin ) + install ( FILES example.conf DESTINATION ${CMAKE_INSTALL_DOCDIR} ) +diff --git a/ftdipp/CMakeLists.txt b/ftdipp/CMakeLists.txt +index fac5bcc..cde211b 100644 +--- a/ftdipp/CMakeLists.txt ++++ b/ftdipp/CMakeLists.txt +@@ -4,24 +4,29 @@ + set(cpp_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.cpp CACHE INTERNAL "List of cpp sources" ) + set(cpp_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.hpp CACHE INTERNAL "List of cpp headers" ) + +-# Includes +-include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} +- ${CMAKE_CURRENT_SOURCE_DIR} +- ${CMAKE_SOURCE_DIR}/src) +- +-include_directories(${Boost_INCLUDE_DIRS}) +- + # Shared library +-add_library(ftdipp1 SHARED ${cpp_sources}) ++add_library(ftdipp1 ${cpp_sources}) ++add_library(LibFTDI::ftdipp1 ALIAS ftdipp1) + + math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatibility with previous releases + set_target_properties(ftdipp1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 3) + + # Prevent clobbering each other during the build + set_target_properties(ftdipp1 PROPERTIES CLEAN_DIRECT_OUTPUT 1) ++set_target_properties(ftdipp1 PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + + # Dependencies +-target_link_libraries(ftdipp1 ftdi1 ${LIBUSB_LIBRARIES} ${BOOST_LIBRARIES}) ++target_link_libraries(ftdipp1 ++ PRIVATE ++ libusb::libusb ++ PUBLIC ++ LibFTDI::ftdi1 ++ Boost::headers ++) ++target_include_directories(ftdipp1 PUBLIC ++ $ ++ $ ++ ) + + install ( TARGETS ftdipp1 + RUNTIME DESTINATION bin +@@ -29,18 +34,6 @@ install ( TARGETS ftdipp1 + ARCHIVE DESTINATION lib${LIB_SUFFIX} + ) + +-# Static library +-if ( STATICLIBS ) +- add_library(ftdipp1-static STATIC ${cpp_sources}) +- set_target_properties(ftdipp1-static PROPERTIES OUTPUT_NAME "ftdipp1") +- set_target_properties(ftdipp1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) +- +- install ( TARGETS ftdipp1-static +- ARCHIVE DESTINATION lib${LIB_SUFFIX} +- COMPONENT staticlibs +- ) +-endif () +- + install ( FILES ${cpp_headers} + DESTINATION include/${PROJECT_NAME} + COMPONENT headers +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 17b3617..3148e02 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -1,36 +1,57 @@ +-# Includes +-include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR} +- ${CMAKE_CURRENT_SOURCE_DIR} +- ) + + # Version information + set(SNAPSHOT_VERSION "unknown") + execute_process(COMMAND git describe + OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT + RESULT_VARIABLE GIT_DESCRIBE_RESULT ++ ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(${GIT_DESCRIBE_RESULT} STREQUAL 0) + set(SNAPSHOT_VERSION ${GIT_DESCRIBE_OUTPUT}) +-endif () ++endif() + message(STATUS "Detected git snapshot version: ${SNAPSHOT_VERSION}") + + configure_file(ftdi_version_i.h.in "${CMAKE_CURRENT_BINARY_DIR}/ftdi_version_i.h" @ONLY) + + # Targets +-set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.c ${CMAKE_CURRENT_SOURCE_DIR}/ftdi_stream.c CACHE INTERNAL "List of c sources" ) +-set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/ftdi.h CACHE INTERNAL "List of c headers" ) ++set(c_sources ++ ftdi.c ++) ++if(ENABLE_STREAMING) ++ set(c_sources ++ ftdi_stream.c ++ ${c_sources} ++ ) ++endif() + +-add_library(ftdi1 SHARED ${c_sources}) ++set(c_headers ++ ftdi.h ++ "${CMAKE_CURRENT_BINARY_DIR}/ftdi_version_i.h" ++) ++ ++add_library(ftdi1 ${c_sources} ${c_headers}) ++add_library(LibFTDI::ftdi1 ALIAS ftdi1) ++target_include_directories(ftdi1 PUBLIC ++ $ ++ $ ++ $ ++ ) + + math(EXPR VERSION_FIXUP "${MAJOR_VERSION} + 1") # Compatibility with previous releases + set_target_properties(ftdi1 PROPERTIES VERSION ${VERSION_FIXUP}.${MINOR_VERSION}.0 SOVERSION 2) + # Prevent clobbering each other during the build + set_target_properties ( ftdi1 PROPERTIES CLEAN_DIRECT_OUTPUT 1 ) ++set_target_properties ( ftdi1 PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + ++target_link_libraries(ftdi1 PRIVATE libusb::libusb) ++if (APPLE) ++ target_link_libraries(ftdi1 PRIVATE ${APPLE_CF} ${APPLE_IOK}) ++endif() + +-# Dependencies +-target_link_libraries(ftdi1 ${LIBUSB_LIBRARIES}) ++if(ENABLE_STREAMING) ++target_compile_definitions(ftdi1 PUBLIC ENABLE_STREAMING) ++endif() + + install ( TARGETS ftdi1 + RUNTIME DESTINATION bin +@@ -38,17 +59,6 @@ install ( TARGETS ftdi1 + ARCHIVE DESTINATION lib${LIB_SUFFIX} + ) + +-if ( STATICLIBS ) +- add_library(ftdi1-static STATIC ${c_sources}) +- target_link_libraries(ftdi1-static ${LIBUSB_LIBRARIES}) +- set_target_properties(ftdi1-static PROPERTIES OUTPUT_NAME "ftdi1") +- set_target_properties(ftdi1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) +- install ( TARGETS ftdi1-static +- ARCHIVE DESTINATION lib${LIB_SUFFIX} +- COMPONENT staticlibs +- ) +-endif () +- + install ( FILES ${c_headers} + DESTINATION include/${PROJECT_NAME} + COMPONENT headers +diff --git a/src/ftdi.c b/src/ftdi.c +index f5b7018..03d7b07 100644 +--- a/src/ftdi.c ++++ b/src/ftdi.c +@@ -1328,7 +1328,7 @@ static int ftdi_to_clkbits_AM(int baudrate, unsigned long *encoded_divisor) + AM Type chips have only four fractional subdivisors at value[15:14] + for subdivisors 0, 0.5, 0.25, 0.125 + */ +-static int ftdi_to_clkbits(int baudrate, unsigned int clk, int clk_div, unsigned long *encoded_divisor) ++static int ftdi_to_clkbits(int baudrate, int clk, int clk_div, unsigned long *encoded_divisor) + { + static const char frac_code[8] = {0, 3, 2, 4, 1, 5, 6, 7}; + int best_baud = 0; +@@ -3044,10 +3044,13 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) + case TYPE_2232H: + case TYPE_4232H: + i += 2; ++ /* Fall through*/ + case TYPE_R: + i += 2; ++ /* Fall through*/ + case TYPE_2232C: + i += 2; ++ /* Fall through*/ + case TYPE_AM: + case TYPE_BM: + i += 0x94; +@@ -3438,15 +3441,20 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) + { + case TYPE_230X: + free_start += 2; ++ /* Fall through*/ + case TYPE_232H: + free_start += 6; ++ /* Fall through*/ + case TYPE_2232H: + case TYPE_4232H: + free_start += 2; ++ /* Fall through*/ + case TYPE_R: + free_start += 2; ++ /* Fall through*/ + case TYPE_2232C: + free_start++; ++ /* Fall through*/ + case TYPE_AM: + case TYPE_BM: + free_start += 0x14; +diff --git a/src/ftdi.h b/src/ftdi.h +index fb45008..d2eed07 100644 +--- a/src/ftdi.h ++++ b/src/ftdi.h +@@ -19,6 +19,7 @@ + #define __libftdi_h__ + + #include ++#include + #ifndef _WIN32 + #include + #endif +@@ -475,6 +476,7 @@ enum ftdi_cbusx_func + /** + \brief Progress Info for streaming read + */ ++#ifdef ENABLE_STREAMING + struct size_and_time + { + uint64_t totalBytes; +@@ -483,17 +485,17 @@ struct size_and_time + + typedef struct + { +- struct size_and_time first; +- struct size_and_time prev; +- struct size_and_time current; +- double totalTime; +- double totalRate; +- double currentRate; ++ struct size_and_time first; ++ struct size_and_time prev; ++ struct size_and_time current; ++ double totalTime; ++ double totalRate; ++ double currentRate; + } FTDIProgressInfo; + + typedef int (FTDIStreamCallback)(uint8_t *buffer, int length, + FTDIProgressInfo *progress, void *userdata); +- ++#endif + /** + * Provide libftdi version information + * major: Library major version +@@ -580,8 +582,8 @@ extern "C" + int ftdi_write_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize); + int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize); + +- int ftdi_readstream(struct ftdi_context *ftdi, FTDIStreamCallback *callback, +- void *userdata, int packetsPerTransfer, int numTransfers); ++ //int ftdi_readstream(struct ftdi_context *ftdi, FTDIStreamCallback *callback, ++ // void *userdata, int packetsPerTransfer, int numTransfers); + struct ftdi_transfer_control *ftdi_write_data_submit(struct ftdi_context *ftdi, unsigned char *buf, int size); + + struct ftdi_transfer_control *ftdi_read_data_submit(struct ftdi_context *ftdi, unsigned char *buf, int size); +diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt +index 392c910..6e7ecaa 100644 +--- a/test/CMakeLists.txt ++++ b/test/CMakeLists.txt +@@ -1,13 +1,7 @@ +-find_package(Boost COMPONENTS unit_test_framework REQUIRED) +- +-enable_testing() +- +-INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS}) +- + set(cpp_tests basic.cpp baudrate.cpp) + + add_executable(test_libftdi1 ${cpp_tests}) +-target_link_libraries(test_libftdi1 ftdi1 ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES}) ++target_link_libraries(test_libftdi1 PRIVATE LibFTDI::ftdi1 Boost::unit_test_framework) + + add_test(test_libftdi1 test_libftdi1) + +-- +2.31.0.windows.1 + diff --git a/recipes/libftdi/1.x/test_package/CMakeLists.txt b/recipes/libftdi/1.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..9664d7d8fd845 --- /dev/null +++ b/recipes/libftdi/1.x/test_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.10) + +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(LibFTDI1 REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(test_package + PRIVATE LibFTDI1::ftdipp) + diff --git a/recipes/libftdi/1.x/test_package/conanfile.py b/recipes/libftdi/1.x/test_package/conanfile.py new file mode 100644 index 0000000000000..b64dc73188853 --- /dev/null +++ b/recipes/libftdi/1.x/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libftdi/1.x/test_package/test_package.cpp b/recipes/libftdi/1.x/test_package/test_package.cpp new file mode 100644 index 0000000000000..41ed25029fe83 --- /dev/null +++ b/recipes/libftdi/1.x/test_package/test_package.cpp @@ -0,0 +1,49 @@ +/* final_all_pp.cpp + + Simple libftdi-cpp usage + + This program is distributed under the GPL, version 2 +*/ + +#include + +#include + +int main(int argc, char **argv) +{ + int vid = 0x0403; + int pid = 0x6001; + + // Print whole list + ftdi_version_info version = ftdi_get_library_version(); + std::cout << "FTDI Library Version: " << version.version_str << "\n"; + + Ftdi::Context context; + Ftdi::List *devices = Ftdi::List::find_all(context, vid, pid); + + if (devices->empty()) { + std::cout << "No FTDI devices found" << std::endl; + } + + for (Ftdi::List::iterator it = devices->begin(); it != devices->end(); ++it) { + std::cout << "FTDI (" << &*it << "): " + << it->vendor() << ", " + << it->description() << ", " + << it->serial(); + + // Open test + if(it->open() == 0) { + std::cout << " (Open OK)"; + } + else { + std::cout << " (Open FAILED)"; + } + + it->close(); + + std::cout << "\n"; + } + std::cout << std::endl; + + return EXIT_SUCCESS; +} diff --git a/recipes/libftdi/config.yml b/recipes/libftdi/config.yml index d29fd7e890f3f..f2732cd4daf56 100644 --- a/recipes/libftdi/config.yml +++ b/recipes/libftdi/config.yml @@ -1,3 +1,5 @@ versions: "0.20": folder: 0.x + "1.5": + folder: "1.x" diff --git a/recipes/libfuse/2.x.x/conandata.yml b/recipes/libfuse/2.x.x/conandata.yml new file mode 100644 index 0000000000000..b9d8ff65471e6 --- /dev/null +++ b/recipes/libfuse/2.x.x/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.9.9": + url: "https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/fuse-2.9.9.tar.gz" + sha256: "d0e69d5d608cc22ff4843791ad097f554dd32540ddc9bed7638cc6fea7c1b4b5" diff --git a/recipes/libfuse/2.x.x/conanfile.py b/recipes/libfuse/2.x.x/conanfile.py new file mode 100644 index 0000000000000..9859979728600 --- /dev/null +++ b/recipes/libfuse/2.x.x/conanfile.py @@ -0,0 +1,77 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.53.0" + + +class LibfuseConan(ConanFile): + name = "libfuse" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/libfuse/libfuse" + license = "LGPL-2.1" + description = "The reference implementation of the Linux FUSE interface" + topics = ("fuse", "libfuse", "filesystem", "linux") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def configure(self): + if self.options.shared: + del self.options.fPIC + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.os not in ("Linux", "FreeBSD"): + raise ConanInvalidConfiguration("libfuse supports only Linux and FreeBSD") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ + "--enable-lib", + "--disable-util", + ]) + tc.generate() + + def build(self): + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + # remove ulockmgr stuff lib and header file + rm(self, "*ulockmgr*", self.package_folder, recursive=True) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "fuse") + self.cpp_info.libs = ["fuse"] + self.cpp_info.includedirs = [os.path.join("include", "fuse")] + self.cpp_info.system_libs = ["pthread"] + # libfuse requires this define to compile successfully + self.cpp_info.defines = ["_FILE_OFFSET_BITS=64"] + if self.settings.os == "Linux": + self.cpp_info.system_libs.append("dl") + diff --git a/recipes/libfuse/2.x.x/test_package/CMakeLists.txt b/recipes/libfuse/2.x.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..701d331873021 --- /dev/null +++ b/recipes/libfuse/2.x.x/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libfuse REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libfuse::libfuse) +target_compile_definitions(${PROJECT_NAME} PRIVATE FUSE_USE_VERSION=29) diff --git a/recipes/libfuse/2.x.x/test_package/conanfile.py b/recipes/libfuse/2.x.x/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libfuse/2.x.x/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libfuse/2.x.x/test_package/test_package.c b/recipes/libfuse/2.x.x/test_package/test_package.c new file mode 100644 index 0000000000000..5175057625d5c --- /dev/null +++ b/recipes/libfuse/2.x.x/test_package/test_package.c @@ -0,0 +1,6 @@ +#include + +int main() { + fuse_get_context(); + return 0; +} diff --git a/recipes/libfuse/2.x.x/test_v1_package/CMakeLists.txt b/recipes/libfuse/2.x.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libfuse/2.x.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libfuse/2.x.x/test_v1_package/conanfile.py b/recipes/libfuse/2.x.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libfuse/2.x.x/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libfuse/all/conandata.yml b/recipes/libfuse/all/conandata.yml new file mode 100644 index 0000000000000..c5d2a101abf4a --- /dev/null +++ b/recipes/libfuse/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.10.5": + url: "https://github.com/libfuse/libfuse/releases/download/fuse-3.10.5/fuse-3.10.5.tar.xz" + sha256: "b2e283485d47404ac896dd0bb7f7ba81e1470838e677e45f659804c3a3b69666" diff --git a/recipes/libfuse/all/conanfile.py b/recipes/libfuse/all/conanfile.py new file mode 100644 index 0000000000000..d9c14cd333993 --- /dev/null +++ b/recipes/libfuse/all/conanfile.py @@ -0,0 +1,77 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rmdir +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +import os + +required_conan_version = ">=1.53.0" + + +class LibfuseConan(ConanFile): + name = "libfuse" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/libfuse/libfuse" + license = "LGPL-2.1" + description = "The reference implementation of the Linux FUSE interface" + topics = ("fuse", "libfuse", "filesystem", "linux") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def configure(self): + if self.options.shared: + del self.options.fPIC + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.os not in ("Linux", "FreeBSD"): + raise ConanInvalidConfiguration("libfuse supports only Linux and FreeBSD") + + def build_requirements(self): + self.tool_requires("meson/0.64.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = MesonToolchain(self) + tc.project_options["examples"] = False + tc.project_options["utils"] = False + tc.project_options["tests"] = False + tc.project_options["useroot"] = False + tc.generate() + + def build(self): + meson = Meson(self) + meson.configure() + meson.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + meson = Meson(self) + meson.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "fuse3") + self.cpp_info.libs = ["fuse3"] + self.cpp_info.includedirs = [os.path.join("include", "fuse3")] + self.cpp_info.system_libs = ["pthread"] + if self.settings.os == "Linux": + self.cpp_info.system_libs.extend(["dl", "rt"]) + diff --git a/recipes/libfuse/all/test_package/CMakeLists.txt b/recipes/libfuse/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c8bc174f2164d --- /dev/null +++ b/recipes/libfuse/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libfuse REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libfuse::libfuse) +target_compile_definitions(${PROJECT_NAME} PRIVATE FUSE_USE_VERSION=34) diff --git a/recipes/libfuse/all/test_package/conanfile.py b/recipes/libfuse/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libfuse/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libfuse/all/test_package/test_package.c b/recipes/libfuse/all/test_package/test_package.c new file mode 100644 index 0000000000000..5175057625d5c --- /dev/null +++ b/recipes/libfuse/all/test_package/test_package.c @@ -0,0 +1,6 @@ +#include + +int main() { + fuse_get_context(); + return 0; +} diff --git a/recipes/libfuse/all/test_v1_package/CMakeLists.txt b/recipes/libfuse/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libfuse/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libfuse/all/test_v1_package/conanfile.py b/recipes/libfuse/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libfuse/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libfuse/config.yml b/recipes/libfuse/config.yml new file mode 100644 index 0000000000000..3f5d2920bcb10 --- /dev/null +++ b/recipes/libfuse/config.yml @@ -0,0 +1,5 @@ +versions: + "3.10.5": + folder: all + "2.9.9": + folder: 2.x.x diff --git a/recipes/libgcrypt/all/conandata.yml b/recipes/libgcrypt/all/conandata.yml new file mode 100644 index 0000000000000..ec37a3b999a57 --- /dev/null +++ b/recipes/libgcrypt/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.8.4": + url: "https://gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.8.4.tar.gz" + sha256: "fc3c49cc8611068e6008482c3bbee6c66b9287808bbb4e14a473f4cc347b78ce" diff --git a/recipes/libgcrypt/all/conanfile.py b/recipes/libgcrypt/all/conanfile.py new file mode 100644 index 0000000000000..7ebc509dad85e --- /dev/null +++ b/recipes/libgcrypt/all/conanfile.py @@ -0,0 +1,84 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.env import VirtualRunEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.53.0" + + +class LibgcryptConan(ConanFile): + name = "libgcrypt" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.gnupg.org/download/index.html#libgcrypt" + description = "Libgcrypt is a general purpose cryptographic library originally based on code from GnuPG" + topics = ("gcrypt", "gnupg", "gpg", "crypto", "cryptography") + license = "LGPL-2.1-or-later" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def configure(self): + if self.options.shared: + del self.options.fPIC + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("libcap/2.65") + self.requires("libgpg-error/1.36") + + def validate(self): + if self.info.settings.os != "Linux": + raise ConanInvalidConfiguration("This recipe only support Linux. You can contribute Windows and/or Macos support.") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") + + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ + "--disable-doc", + f"--with-libgpg-error-prefix={self.dependencies['libgpg-error'].package_folder}", + ]) + tc.generate() + + deps = AutotoolsDeps(self) + deps.generate() + + def build(self): + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() + rm(self, "*la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["gcrypt"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["pthread"] + + # TODO: to remove in conan v2 + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/libgcrypt/all/test_package/CMakeLists.txt b/recipes/libgcrypt/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..1a3fbb3bbed04 --- /dev/null +++ b/recipes/libgcrypt/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libgcrypt REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libgcrypt::libgcrypt) diff --git a/recipes/libgcrypt/all/test_package/conanfile.py b/recipes/libgcrypt/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libgcrypt/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libgcrypt/all/test_package/test_package.c b/recipes/libgcrypt/all/test_package/test_package.c new file mode 100644 index 0000000000000..205414b7c95c5 --- /dev/null +++ b/recipes/libgcrypt/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include "gcrypt.h" + +int main() { + gcry_md_hd_t handle; + gcry_error_t result = gcry_md_open(&handle, 0, GCRY_MD_FLAG_HMAC); + if (result) { + return result; + } + return 0; +} diff --git a/recipes/libgcrypt/all/test_v1_package/CMakeLists.txt b/recipes/libgcrypt/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libgcrypt/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libgcrypt/all/test_v1_package/conanfile.py b/recipes/libgcrypt/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libgcrypt/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libgcrypt/config.yml b/recipes/libgcrypt/config.yml new file mode 100644 index 0000000000000..f058837ee5cb1 --- /dev/null +++ b/recipes/libgcrypt/config.yml @@ -0,0 +1,3 @@ +versions: + "1.8.4": + folder: all diff --git a/recipes/libgd/all/conandata.yml b/recipes/libgd/all/conandata.yml index 836bbc8ce8fe6..775ee73a32dbb 100644 --- a/recipes/libgd/all/conandata.yml +++ b/recipes/libgd/all/conandata.yml @@ -1,18 +1,40 @@ sources: - "2.2.5": - url: "https://github.com/libgd/libgd/releases/download/gd-2.2.5/libgd-2.2.5.tar.gz" - sha256: "a66111c9b4a04e818e9e2a37d7ae8d4aae0939a100a36b0ffb52c706a09074b5" + "2.3.2": + url: "https://github.com/libgd/libgd/archive/gd-2.3.2.tar.gz" + sha256: "dcc22244d775f469bee21dce1ea42552adbb72ba0cc423f9fa6a64601b3a1893" + "2.3.1": + url: "https://github.com/libgd/libgd/archive/gd-2.3.1.tar.gz" + sha256: "795978dcec1bf931148ebcdca9ed1e9cdfa9e71acff8bf035a8867dd1f7af6cd" "2.3.0": url: "https://github.com/libgd/libgd/archive/gd-2.3.0.tar.gz" sha256: "a77dfbbf8bfa7f19c935c11f3b939321f8c1059953a91203158cb2dbf27a0f9e" -patches: "2.2.5": - - patch_file: "patches/2.2.5-msvc-static-lib.patch" + url: "https://github.com/libgd/libgd/releases/download/gd-2.2.5/libgd-2.2.5.tar.gz" + sha256: "a66111c9b4a04e818e9e2a37d7ae8d4aae0939a100a36b0ffb52c706a09074b5" +patches: + "2.3.2": + - patch_file: "patches/remove-unistd-h.patch" base_path: "source_subfolder" - - patch_file: "patches/2.2.5-qualify-nondll.patch" + - patch_file: "patches/2.3.2-qualify-nondll.patch" + base_path: "source_subfolder" + - patch_file: "patches/2.3.x-png-msvc.patch" + base_path: "source_subfolder" + "2.3.1": + - patch_file: "patches/remove-unistd-h.patch" + base_path: "source_subfolder" + - patch_file: "patches/qualify-nondll.patch" + base_path: "source_subfolder" + - patch_file: "patches/2.3.x-png-msvc.patch" base_path: "source_subfolder" "2.3.0": - patch_file: "patches/remove-unistd-h.patch" base_path: "source_subfolder" - patch_file: "patches/qualify-nondll.patch" base_path: "source_subfolder" + - patch_file: "patches/2.3.x-png-msvc.patch" + base_path: "source_subfolder" + "2.2.5": + - patch_file: "patches/2.2.5-msvc-static-lib.patch" + base_path: "source_subfolder" + - patch_file: "patches/2.2.5-qualify-nondll.patch" + base_path: "source_subfolder" diff --git a/recipes/libgd/all/conanfile.py b/recipes/libgd/all/conanfile.py index 76d69a4f75b97..b26dbdb4a3014 100644 --- a/recipes/libgd/all/conanfile.py +++ b/recipes/libgd/all/conanfile.py @@ -1,6 +1,11 @@ -import glob +from conan import ConanFile +from conan.tools.microsoft import is_msvc +from conans import CMake +from conan.tools.files import get, patch, replace_in_file, rmdir, collect_libs +from conan.tools.scm import Version import os -from conans import ConanFile, tools, CMake + +required_conan_version = ">=1.47.0" class LibgdConan(ConanFile): @@ -10,15 +15,38 @@ class LibgdConan(ConanFile): description = ("GD is an open source code library for the dynamic " "creation of images by programmers.") topics = ("images", "graphics") - settings = "os", "compiler", "build_type", "arch" homepage = "https://libgd.github.io" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_png": [True, False], + "with_jpeg": [True, False], + "with_tiff": [True, False], + "with_freetype": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_png": False, + "with_jpeg": False, + "with_tiff": False, + "with_freetype": False, + } + exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake" - requires = "zlib/1.2.11" + generators = "cmake", "cmake_find_package" _cmake = None + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -27,32 +55,57 @@ def configure(self): if self.options.shared: del self.options.fPIC - @property - def _source_subfolder(self): - return "source_subfolder" + def requirements(self): + self.requires("zlib/1.2.12") + if self.options.with_png: + self.requires("libpng/1.6.37") + if is_msvc(self): + self.requires("getopt-for-visual-studio/20200201") + if self.options.with_jpeg: + self.requires("libjpeg/9d") + if self.options.with_tiff: + self.requires("libtiff/4.4.0") + if self.options.with_freetype: + self.requires("freetype/2.12.1") - @property - def _build_subfolder(self): - return "build_subfolder" + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _patch(self): + for patch_file in self.conan_data.get("patches", {}).get(self.version, []): + patch(self, **patch_file) cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") - tools.replace_in_file(cmakelists, "${CMAKE_SOURCE_DIR}", "${CMAKE_CURRENT_SOURCE_DIR}") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(glob.glob("libgd-*")[0], self._source_subfolder) + replace_in_file(self, cmakelists, "${CMAKE_SOURCE_DIR}", + "${CMAKE_CURRENT_SOURCE_DIR}") + replace_in_file(self, cmakelists, + "SET(CMAKE_MODULE_PATH \"${GD_SOURCE_DIR}/cmake/modules\")", + "LIST(APPEND CMAKE_MODULE_PATH \"${GD_SOURCE_DIR}/cmake/modules\")") + replace_in_file(self, os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + "RUNTIME DESTINATION bin", + "RUNTIME DESTINATION bin BUNDLE DESTINATION bin") def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - self._cmake.definitions['BUILD_STATIC_LIBS'] = not self.options.shared - zlib_info = self.deps_cpp_info["zlib"] - self._cmake.definitions["ZLIB_LIBRARY"] = zlib_info.libs[0] - self._cmake.definitions["ZLIB_INCLUDE_DIR"] = zlib_info.include_paths[0] + self._cmake.definitions["BUILD_STATIC_LIBS"] = not self.options.shared + if Version(self.version) >= "2.3.0": + self._cmake.definitions["ENABLE_GD_FORMATS"] = True + self._cmake.definitions["ENABLE_PNG"] = self.options.with_png + self._cmake.definitions["ENABLE_LIQ"] = False + self._cmake.definitions["ENABLE_JPEG"] = self.options.with_jpeg + self._cmake.definitions["ENABLE_TIFF"] = self.options.with_tiff + self._cmake.definitions["ENABLE_ICONV"] = False + self._cmake.definitions["ENABLE_XPM"] = False + self._cmake.definitions["ENABLE_FREETYPE"] = self.options.with_freetype + self._cmake.definitions["ENABLE_FONTCONFIG"] = False + self._cmake.definitions["ENABLE_WEBP"] = False + if Version(self.version) >= "2.3.2": + self._cmake.definitions["ENABLE_HEIF"] = False + self._cmake.definitions["ENABLE_AVIF"] = False + if Version(self.version) >= "2.3.0": + self._cmake.definitions["ENABLE_RAQM"] = False self._cmake.configure(build_folder=self._build_subfolder) return self._cmake @@ -62,16 +115,21 @@ def build(self): cmake.build() def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() - self.copy("COPYING", src=self._source_subfolder, dst="licenses", - ignore_case=True, keep_path=False) - tools.rmdir(os.path.join(self.package_folder, 'share')) - tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): self.cpp_info.names["pkg_config"]= "gdlib" - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == 'Windows' and not self.options.shared: - self.cpp_info.defines.append('BGD_NONDLL') - self.cpp_info.defines.append('BGDWIN32') + self.cpp_info.libs = collect_libs(self) + if self.settings.os == "Windows" and not self.options.shared: + self.cpp_info.defines.append("BGD_NONDLL") + self.cpp_info.defines.append("BGDWIN32") + if self.settings.os in ("FreeBSD", "Linux", "Android", "SunOS", "AIX"): + self.cpp_info.system_libs.append("m") + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/libgd/all/patches/2.3.2-qualify-nondll.patch b/recipes/libgd/all/patches/2.3.2-qualify-nondll.patch new file mode 100644 index 0000000000000..0eccaf9b59f38 --- /dev/null +++ b/recipes/libgd/all/patches/2.3.2-qualify-nondll.patch @@ -0,0 +1,34 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 509c422..1d1be42 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -106,7 +106,7 @@ if (WIN32 AND NOT MINGW AND NOT MSYS) + # SET_TARGET_PROPERTIES(${GD_LIB} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:msvcrt.lib") + + if (BUILD_STATIC_LIBS) +- SET_PROPERTY(TARGET ${GD_LIB_STATIC} APPEND PROPERTY COMPILE_DEFINITIONS NONDLL=1) ++ SET_PROPERTY(TARGET ${GD_LIB_STATIC} APPEND PROPERTY COMPILE_DEFINITIONS BGD_NONDLL=1) + endif() + + ENDIF(WIN32 AND NOT MINGW AND NOT MSYS) +diff --git a/src/gd.h b/src/gd.h +index 4302812..e4a1c0b 100644 +--- a/src/gd.h ++++ b/src/gd.h +@@ -40,14 +40,14 @@ extern "C" { + and other languages. This breaks ABI compatibility + with previous DLL revs, but it's necessary. */ + +-/* 2.0.29: WIN32 programmers can declare the NONDLL macro if they ++/* 2.0.29: WIN32 programmers can declare the BGD_NONDLL macro if they + wish to build gd as a static library or by directly including + the gd sources in a project. */ + + /* http://gcc.gnu.org/wiki/Visibility */ + #if defined(_WIN32) || defined(CYGWIN) || defined(_WIN32_WCE) + # ifdef BGDWIN32 +-# ifdef NONDLL ++# ifdef BGD_NONDLL + # define BGD_EXPORT_DATA_PROT + # else + # ifdef __GNUC__ diff --git a/recipes/libgd/all/patches/2.3.x-png-msvc.patch b/recipes/libgd/all/patches/2.3.x-png-msvc.patch new file mode 100644 index 0000000000000..48ec2476a4c9b --- /dev/null +++ b/recipes/libgd/all/patches/2.3.x-png-msvc.patch @@ -0,0 +1,54 @@ +--- src/webpng.c ++++ src/webpng.c +@@ -19,7 +19,7 @@ + + /* Bring in the gd library functions */ + #include "gd.h" +- ++#include + #define KEEP_TRANS (-100) + + static const char argv0[] = "webpng"; +@@ -64,7 +64,7 @@ + FILE *in; + FILE *out; + const char *infile; +- char *tmpfile; ++ char *tmppath; + int i; + int use_stdin_stdout = 0; + +@@ -258,19 +258,24 @@ + size_t len = filelen + 8; + int outfd; + +- tmpfile = malloc(len); +- if (tmpfile == NULL) ++#ifdef _MSC_VER ++ out = tmpfile(); ++ if (out == NULL) ++ err("could not create temporary file"); ++#else ++ tmppath = malloc(len); ++ if (tmppath == NULL) + err("could not create a tempfile"); +- memcpy(tmpfile, infile, filelen); +- strcpy(tmpfile + filelen, ".XXXXXX"); +- +- outfd = mkstemp(tmpfile); ++ memcpy(tmppath, infile, filelen); ++ strcpy(tmppath + filelen, ".XXXXXX"); ++ tmpnam(tmppath); ++ outfd = mkstemp(tmppath); + if (outfd == -1) +- err("could not open %s", tmpfile); +- ++ err("could not open %s", tmppath); + out = fdopen(outfd, "wb"); + if (!out) +- err("could not open %s", tmpfile); ++ err("could not open %s", tmppath); ++#endif + } + + /* Write the new PNG. */ diff --git a/recipes/libgd/all/test_package/CMakeLists.txt b/recipes/libgd/all/test_package/CMakeLists.txt index 0fcc7edcb9ed2..e4f67d2408b0a 100644 --- a/recipes/libgd/all/test_package/CMakeLists.txt +++ b/recipes/libgd/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(libgd_test CXX) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +find_package(libgd CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libgd::libgd) diff --git a/recipes/libgd/all/test_package/conanfile.py b/recipes/libgd/all/test_package/conanfile.py index 44a9e6acd535a..38f4483872d47 100644 --- a/recipes/libgd/all/test_package/conanfile.py +++ b/recipes/libgd/all/test_package/conanfile.py @@ -1,11 +1,10 @@ -import os - from conans import ConanFile, CMake, tools +import os -class LibgdTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -13,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "libgd_test") + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libgd/all/test_package/test_package.cpp b/recipes/libgd/all/test_package/test_package.c similarity index 100% rename from recipes/libgd/all/test_package/test_package.cpp rename to recipes/libgd/all/test_package/test_package.c diff --git a/recipes/libgd/config.yml b/recipes/libgd/config.yml index 667deaf128e00..73437bcaccb05 100644 --- a/recipes/libgd/config.yml +++ b/recipes/libgd/config.yml @@ -1,5 +1,9 @@ versions: - "2.2.5": + "2.3.2": + folder: all + "2.3.1": folder: all "2.3.0": folder: all + "2.2.5": + folder: all diff --git a/recipes/libgeotiff/all/CMakeLists.txt b/recipes/libgeotiff/all/CMakeLists.txt deleted file mode 100644 index b91805f6a269d..0000000000000 --- a/recipes/libgeotiff/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder/libgeotiff") diff --git a/recipes/libgeotiff/all/conandata.yml b/recipes/libgeotiff/all/conandata.yml index 284cb0634bc86..7f1d9af273208 100644 --- a/recipes/libgeotiff/all/conandata.yml +++ b/recipes/libgeotiff/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.7.1": + url: "https://github.com/OSGeo/libgeotiff/archive/refs/tags/1.7.1.tar.gz" + sha256: "09a0cae5352030011b994a60237743a1327ab95ce482318d45bf9fcb5e5f76b5" + "1.7.0": + url: "https://github.com/OSGeo/libgeotiff/archive/refs/tags/1.7.0.tar.gz" + sha256: "4d5a4d309f9b3032501ad85ea8b921461761a76d9881b415246770a6bddcaf54" "1.6.0": url: "https://github.com/OSGeo/libgeotiff/archive/1.6.0.tar.gz" sha256: "312c52687b56893067b35a47442f0d5a670995bd1dddecbe0dc09d6e60fec1d7" @@ -6,9 +12,11 @@ sources: url: "https://github.com/OSGeo/libgeotiff/archive/1.5.1.tar.gz" sha256: "fb04491572afb25ffe60239fdfdcfa2c64e6cf644cad9b0b922b10115ccbd488" patches: + "1.7.1": + - patch_file: "patches/fix-cmake-1.7.1.patch" + "1.7.0": + - patch_file: "patches/fix-cmake-1.6.0.patch" "1.6.0": - patch_file: "patches/fix-cmake-1.6.0.patch" - base_path: "source_subfolder" "1.5.1": - patch_file: "patches/fix-cmake-1.5.1.patch" - base_path: "source_subfolder" diff --git a/recipes/libgeotiff/all/conanfile.py b/recipes/libgeotiff/all/conanfile.py index 4737207022258..cfb2f00d55368 100644 --- a/recipes/libgeotiff/all/conanfile.py +++ b/recipes/libgeotiff/all/conanfile.py @@ -1,8 +1,10 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, rmdir, save import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.52.0" class LibgeotiffConan(ConanFile): @@ -10,24 +12,22 @@ class LibgeotiffConan(ConanFile): description = "Libgeotiff is an open source library normally hosted on top " \ "of libtiff for reading, and writing GeoTIFF information tags." license = ["MIT", "BSD-3-Clause"] - topics = ("conan", "libgeotiff", "geotiff", "tiff") + topics = ("geotiff", "tiff") homepage = "https://github.com/OSGeo/libgeotiff" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - @property - def _build_subfolder(self): - return "build_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -35,54 +35,62 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("libtiff/4.2.0") - self.requires("proj/8.0.0") + self.requires("libtiff/4.4.0") + self.requires("proj/9.0.1") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_UTILITIES"] = False + tc.variables["WITH_TOWGS84"] = True + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "libgeotiff")) cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["WITH_UTILITIES"] = False - self._cmake.definitions["WITH_TOWGS84"] = True - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("LICENSE", dst="licenses", src=os.path.join(self._source_subfolder, "libgeotiff")) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=os.path.join(self.source_folder, "libgeotiff"), dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "cmake")) - tools.rmdir(os.path.join(self.package_folder, "doc")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "doc")) + rmdir(self, os.path.join(self.package_folder, "share")) self._create_cmake_module_variables( - os.path.join(self.package_folder, self._module_subfolder, self._module_vars_file) + os.path.join(self.package_folder, self._module_vars_file) ) self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._module_subfolder, self._module_target_file), + os.path.join(self.package_folder, self._module_target_file), {"geotiff_library": "geotiff::geotiff"} ) - @staticmethod - def _create_cmake_module_variables(module_file): + def _create_cmake_module_variables(self, module_file): content = textwrap.dedent("""\ - if(DEFINED GeoTIFF_FOUND) - set(GEOTIFF_FOUND ${GeoTIFF_FOUND}) - endif() + set(GEOTIFF_FOUND ${GeoTIFF_FOUND}) if(DEFINED GeoTIFF_INCLUDE_DIR) set(GEOTIFF_INCLUDE_DIR ${GeoTIFF_INCLUDE_DIR}) endif() @@ -90,38 +98,39 @@ def _create_cmake_module_variables(module_file): set(GEOTIFF_LIBRARIES ${GeoTIFF_LIBRARIES}) endif() """) - tools.save(module_file, content) + save(self, module_file, content) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + """) + save(self, module_file, content) @property def _module_vars_file(self): - return "conan-official-{}-variables.cmake".format(self.name) + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") @property def _module_target_file(self): - return "conan-official-{}-targets.cmake".format(self.name) + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_module_file_name", "GeoTIFF") + self.cpp_info.set_property("cmake_build_modules", [self._module_vars_file]) + self.cpp_info.set_property("cmake_file_name", "geotiff") + self.cpp_info.set_property("cmake_target_name", "geotiff_library") + self.cpp_info.names["cmake_find_package"] = "GeoTIFF" self.cpp_info.names["cmake_find_package_multi"] = "geotiff" - self.cpp_info.builddirs.append(self._module_subfolder) - self.cpp_info.build_modules["cmake_find_package"] = [os.path.join(self._module_subfolder, self._module_vars_file)] - self.cpp_info.build_modules["cmake_find_package_multi"] = [os.path.join(self._module_subfolder, self._module_target_file)] - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.build_modules["cmake_find_package"] = [self._module_vars_file] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_target_file] + + self.cpp_info.libs = collect_libs(self) + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") diff --git a/recipes/libgeotiff/all/patches/fix-cmake-1.5.1.patch b/recipes/libgeotiff/all/patches/fix-cmake-1.5.1.patch index 8fcd25799ab70..8caed57981342 100644 --- a/recipes/libgeotiff/all/patches/fix-cmake-1.5.1.patch +++ b/recipes/libgeotiff/all/patches/fix-cmake-1.5.1.patch @@ -1,17 +1,43 @@ --- a/libgeotiff/CMakeLists.txt +++ b/libgeotiff/CMakeLists.txt -@@ -80,7 +80,9 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +@@ -5,6 +5,7 @@ + # Author: Mateusz Loskot + # + ############################################################################### ++CMAKE_MINIMUM_REQUIRED(VERSION 3.1) + PROJECT(GeoTIFF) + + SET(GEOTIFF_LIB_NAME geotiff) +@@ -12,7 +13,6 @@ SET(GEOTIFF_LIBRARY_TARGET geotiff_library) + + ############################################################################## + # CMake settings +-CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0) + + SET(CMAKE_COLOR_MAKEFILE ON) + +@@ -54,7 +54,7 @@ IF(CMAKE_BUILD_TYPE MATCHES Debug) + SET(GEOTIFF_BUILD_PEDANTIC TRUE) + ENDIF() + +-if (CMAKE_MAJOR_VERSION GREATER 2) ++if(0) # No ! we want CMP0042 NEW for relocatable shared lib on macOS + cmake_policy(SET CMP0022 OLD) # interface link libraries + cmake_policy(SET CMP0042 OLD) # osx rpath + endif() +@@ -80,8 +80,9 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) IF(WIN32) IF(MSVC) - ADD_DEFINITIONS(-DBUILD_AS_DLL=1) +- ADD_DEFINITIONS(/DW4) + IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_AS_DLL=1) + ENDIF() - ADD_DEFINITIONS(/DW4) if (NOT (MSVC_VERSION VERSION_LESS 1400)) ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) -@@ -92,7 +94,7 @@ IF(WIN32) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) +@@ -92,7 +93,7 @@ IF(WIN32) ENDIF() IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) @@ -20,88 +46,23 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILE_FLAGS} -std=c99") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS} -std=c++98") IF(GEOTIFF_BUILD_PEDANTIC) -@@ -119,80 +121,6 @@ SET(WITH_UTILITIES TRUE CACHE BOOL "Choose if GeoTIFF utilities should be built" - INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) +@@ -120,6 +121,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libxtiff) --# TIFF support - required, default=ON --SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built") -- --FIND_PACKAGE(PROJ NO_MODULE QUIET) --if (NOT PROJ_FOUND) -- FIND_PACKAGE(PROJ) --endif () -- --IF(PROJ_FOUND) -- INCLUDE_DIRECTORIES(${PROJ_INCLUDE_DIR}) --ELSE() -- MESSAGE(FATAL_ERROR "Failed to detect PROJ >= 6") --ENDIF() -- --# Zlib support - optional, default=OFF --SET(WITH_ZLIB FALSE CACHE BOOL "Choose if zlib support should be built") -- --IF(WITH_ZLIB) -- FIND_PACKAGE(ZLIB NO_MODULE QUIET) -- if (NOT ZLIB_FOUND) -- FIND_PACKAGE(ZLIB) -- endif () -- -- IF(ZLIB_FOUND) -- SET(HAVE_ZIP 1) -- INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) -- ADD_DEFINITIONS(-DHAVE_ZIP=${HAVE_ZIP}) -- ENDIF() --ENDIF() -- --# JPEG support - optional, default=OFF --SET(WITH_JPEG FALSE CACHE BOOL "Choose if JPEG support should be built") -- --IF(WITH_JPEG) -- FIND_PACKAGE(JPEG NO_MODULE QUIET) -- if (NOT JPEG_FOUND) -- FIND_PACKAGE(JPEG) -- endif () -- -- IF(JPEG_FOUND) -- SET(HAVE_JPEG 1) -- INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR}) -- ADD_DEFINITIONS(-DHAVE_JPEG=${HAVE_JPEG}) -- ENDIF() --ENDIF() -- --IF(WITH_TIFF) -- FIND_PACKAGE(TIFF NO_MODULE QUIET) -- if (NOT TIFF_FOUND) -- FIND_PACKAGE(TIFF REQUIRED) -- endif () -- -- IF(TIFF_FOUND) -- # Confirm required API is available -- INCLUDE(CheckFunctionExists) -- SET(CMAKE_REQUIRED_LIBRARIES ${TIFF_LIBRARIES}) -- -- CHECK_FUNCTION_EXISTS(TIFFOpen HAVE_TIFFOPEN) -- IF(NOT HAVE_TIFFOPEN) -- SET(TIFF_FOUND) # ReSET to NOT found for TIFF library -- MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFOpen function not found") -- ENDIF() -- -- CHECK_FUNCTION_EXISTS(TIFFMergeFieldInfo HAVE_TIFFMERGEFIELDINFO) -- IF(NOT HAVE_TIFFMERGEFIELDINFO) -- SET(TIFF_FOUND) # ReSET to NOT found for TIFF library -- MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFMergeFieldInfo function not found. libtiff 3.6.0 Beta or later required. Please upgrade or use an older version of libgeotiff") -- ENDIF() -- -- INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR}) -- ADD_DEFINITIONS(-DHAVE_TIFF=1) -- ENDIF(TIFF_FOUND) --ENDIF(WITH_TIFF) -- + # TIFF support - required, default=ON ++if(0) + SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built") + + FIND_PACKAGE(PROJ NO_MODULE QUIET) +@@ -192,6 +194,7 @@ IF(WITH_TIFF) + ADD_DEFINITIONS(-DHAVE_TIFF=1) + ENDIF(TIFF_FOUND) + ENDIF(WITH_TIFF) ++endif() + # Turn off TOWGS84 support SET(WITH_TOWGS84 TRUE CACHE BOOL "Build with TOWGS84 support") - IF (NOT WITH_TOWGS84) -@@ -300,7 +228,6 @@ INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION include) +@@ -300,7 +303,6 @@ INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION include) ############################################################################### # Build libxtiff library @@ -109,7 +70,16 @@ ############################################################################### # Build libgeotiff library -@@ -361,11 +288,7 @@ ENDIF(UNIX) +@@ -345,7 +347,7 @@ IF(UNIX) + VERSION ${LINK_VERSION} + SOVERSION ${LINK_SOVERSION} + CLEAN_DIRECT_OUTPUT 1 ) +- if (APPLE) ++ if (0) # no custom install_name, we want @rpath + set_target_properties( + ${GEOTIFF_LIBRARY_TARGET} + PROPERTIES +@@ -361,11 +363,15 @@ ENDIF(UNIX) SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES OUTPUT_NAME ${GEOTIFF_LIB_NAME}) @@ -118,7 +88,15 @@ - ${PROJ_LIBRARIES} - ${ZLIB_LIBRARIES} - ${JPEG_LIBRARIES}) -+TARGET_LINK_LIBRARIES(${GEOTIFF_LIBRARY_TARGET} ${CONAN_LIBS}) ++find_package(TIFF REQUIRED) ++target_link_libraries(${GEOTIFF_LIBRARY_TARGET} TIFF::TIFF) ++find_package(proj4 QUIET CONFIG) ++if(TARGET PROJ4::proj) ++ target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PROJ4::proj) ++else() ++ find_package(proj REQUIRED CONFIG) ++ target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PROJ::proj) ++endif() # INSTALL(TARGETS ${GEOTIFF_ARCHIVE_TARGET} ${GEOTIFF_LIBRARY_TARGET} # RUNTIME DESTINATION ${GEOTIFF_BIN_DIR} diff --git a/recipes/libgeotiff/all/patches/fix-cmake-1.6.0.patch b/recipes/libgeotiff/all/patches/fix-cmake-1.6.0.patch index 0d5d986ae47df..7558274a78099 100644 --- a/recipes/libgeotiff/all/patches/fix-cmake-1.6.0.patch +++ b/recipes/libgeotiff/all/patches/fix-cmake-1.6.0.patch @@ -1,17 +1,43 @@ --- a/libgeotiff/CMakeLists.txt +++ b/libgeotiff/CMakeLists.txt -@@ -80,7 +80,9 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +@@ -5,6 +5,7 @@ + # Author: Mateusz Loskot + # + ############################################################################### ++CMAKE_MINIMUM_REQUIRED(VERSION 3.1) + PROJECT(GeoTIFF) + + SET(GEOTIFF_LIB_NAME geotiff) +@@ -12,7 +13,6 @@ SET(GEOTIFF_LIBRARY_TARGET geotiff_library) + + ############################################################################## + # CMake settings +-CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0) + + SET(CMAKE_COLOR_MAKEFILE ON) + +@@ -54,7 +54,7 @@ IF(CMAKE_BUILD_TYPE MATCHES Debug) + SET(GEOTIFF_BUILD_PEDANTIC TRUE) + ENDIF() + +-if (CMAKE_MAJOR_VERSION GREATER 2) ++if(0) # No ! we want CMP0042 NEW for relocatable shared lib on macOS + cmake_policy(SET CMP0022 OLD) # interface link libraries + cmake_policy(SET CMP0042 OLD) # osx rpath + endif() +@@ -80,8 +80,9 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) IF(WIN32) IF(MSVC) - ADD_DEFINITIONS(-DBUILD_AS_DLL=1) +- ADD_DEFINITIONS(/DW4) + IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_AS_DLL=1) + ENDIF() - ADD_DEFINITIONS(/DW4) if (NOT (MSVC_VERSION VERSION_LESS 1400)) ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) -@@ -92,7 +94,7 @@ IF(WIN32) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) +@@ -92,7 +93,7 @@ IF(WIN32) ENDIF() IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) @@ -20,88 +46,23 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILE_FLAGS} -std=c99") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS} -std=c++98") IF(GEOTIFF_BUILD_PEDANTIC) -@@ -119,80 +121,6 @@ SET(WITH_UTILITIES TRUE CACHE BOOL "Choose if GeoTIFF utilities should be built" - INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) +@@ -120,6 +121,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libxtiff) --# TIFF support - required, default=ON --SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built") -- --FIND_PACKAGE(PROJ NO_MODULE QUIET) --if (NOT PROJ_FOUND) -- FIND_PACKAGE(PROJ) --endif () -- --IF(PROJ_FOUND) -- INCLUDE_DIRECTORIES(${PROJ_INCLUDE_DIR}) --ELSE() -- MESSAGE(FATAL_ERROR "Failed to detect PROJ >= 6") --ENDIF() -- --# Zlib support - optional, default=OFF --SET(WITH_ZLIB FALSE CACHE BOOL "Choose if zlib support should be built") -- --IF(WITH_ZLIB) -- FIND_PACKAGE(ZLIB NO_MODULE QUIET) -- if (NOT ZLIB_FOUND) -- FIND_PACKAGE(ZLIB) -- endif () -- -- IF(ZLIB_FOUND) -- SET(HAVE_ZIP 1) -- INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) -- ADD_DEFINITIONS(-DHAVE_ZIP=${HAVE_ZIP}) -- ENDIF() --ENDIF() -- --# JPEG support - optional, default=OFF --SET(WITH_JPEG FALSE CACHE BOOL "Choose if JPEG support should be built") -- --IF(WITH_JPEG) -- FIND_PACKAGE(JPEG NO_MODULE QUIET) -- if (NOT JPEG_FOUND) -- FIND_PACKAGE(JPEG) -- endif () -- -- IF(JPEG_FOUND) -- SET(HAVE_JPEG 1) -- INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR}) -- ADD_DEFINITIONS(-DHAVE_JPEG=${HAVE_JPEG}) -- ENDIF() --ENDIF() -- --IF(WITH_TIFF) -- FIND_PACKAGE(TIFF NO_MODULE QUIET) -- if (NOT TIFF_FOUND) -- FIND_PACKAGE(TIFF REQUIRED) -- endif () -- -- IF(TIFF_FOUND) -- # Confirm required API is available -- INCLUDE(CheckFunctionExists) -- SET(CMAKE_REQUIRED_LIBRARIES ${TIFF_LIBRARIES}) -- -- CHECK_FUNCTION_EXISTS(TIFFOpen HAVE_TIFFOPEN) -- IF(NOT HAVE_TIFFOPEN) -- SET(TIFF_FOUND) # ReSET to NOT found for TIFF library -- MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFOpen function not found") -- ENDIF() -- -- CHECK_FUNCTION_EXISTS(TIFFMergeFieldInfo HAVE_TIFFMERGEFIELDINFO) -- IF(NOT HAVE_TIFFMERGEFIELDINFO) -- SET(TIFF_FOUND) # ReSET to NOT found for TIFF library -- MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFMergeFieldInfo function not found. libtiff 3.6.0 Beta or later required. Please upgrade or use an older version of libgeotiff") -- ENDIF() -- -- INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR}) -- ADD_DEFINITIONS(-DHAVE_TIFF=1) -- ENDIF(TIFF_FOUND) --ENDIF(WITH_TIFF) -- + # TIFF support - required, default=ON ++if(0) + SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built") + + FIND_PACKAGE(PROJ NO_MODULE QUIET) +@@ -192,6 +194,7 @@ IF(WITH_TIFF) + ADD_DEFINITIONS(-DHAVE_TIFF=1) + ENDIF(TIFF_FOUND) + ENDIF(WITH_TIFF) ++endif() + # Turn off TOWGS84 support SET(WITH_TOWGS84 TRUE CACHE BOOL "Build with TOWGS84 support") - IF (NOT WITH_TOWGS84) -@@ -301,7 +229,6 @@ INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION include) +@@ -301,7 +304,6 @@ INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION include) ############################################################################### # Build libxtiff library @@ -109,7 +70,16 @@ ############################################################################### # Build libgeotiff library -@@ -362,11 +289,7 @@ ENDIF(UNIX) +@@ -346,7 +348,7 @@ IF(UNIX) + VERSION ${LINK_VERSION} + SOVERSION ${LINK_SOVERSION} + CLEAN_DIRECT_OUTPUT 1 ) +- if (APPLE) ++ if (0) # no custom install_name, we want @rpath + set_target_properties( + ${GEOTIFF_LIBRARY_TARGET} + PROPERTIES +@@ -362,11 +364,15 @@ ENDIF(UNIX) SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES OUTPUT_NAME ${GEOTIFF_LIB_NAME}) @@ -118,7 +88,15 @@ - ${PROJ_LIBRARIES} - ${ZLIB_LIBRARIES} - ${JPEG_LIBRARIES}) -+TARGET_LINK_LIBRARIES(${GEOTIFF_LIBRARY_TARGET} ${CONAN_LIBS}) ++find_package(TIFF REQUIRED) ++target_link_libraries(${GEOTIFF_LIBRARY_TARGET} TIFF::TIFF) ++find_package(proj4 QUIET CONFIG) ++if(TARGET PROJ4::proj) ++ target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PROJ4::proj) ++else() ++ find_package(proj REQUIRED CONFIG) ++ target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PROJ::proj) ++endif() # INSTALL(TARGETS ${GEOTIFF_ARCHIVE_TARGET} ${GEOTIFF_LIBRARY_TARGET} # RUNTIME DESTINATION ${GEOTIFF_BIN_DIR} diff --git a/recipes/libgeotiff/all/patches/fix-cmake-1.7.1.patch b/recipes/libgeotiff/all/patches/fix-cmake-1.7.1.patch new file mode 100644 index 0000000000000..7f0663e5d7198 --- /dev/null +++ b/recipes/libgeotiff/all/patches/fix-cmake-1.7.1.patch @@ -0,0 +1,78 @@ +--- a/libgeotiff/CMakeLists.txt ++++ b/libgeotiff/CMakeLists.txt +@@ -5,6 +5,7 @@ + # Author: Mateusz Loskot + # + ############################################################################### ++CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0) + PROJECT(GeoTIFF) + + SET(GEOTIFF_LIB_NAME geotiff) +@@ -12,7 +13,6 @@ SET(GEOTIFF_LIBRARY_TARGET geotiff_library) + + ############################################################################## + # CMake settings +-CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0) + + SET(CMAKE_COLOR_MAKEFILE ON) + +@@ -88,7 +88,7 @@ IF(WIN32) + ENDIF() + + IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) +- SET(COMPILE_FLAGS "-fPIC -Wall -Wno-long-long") ++ SET(COMPILE_FLAGS "-Wall -Wno-long-long") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILE_FLAGS} -std=c99") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS} -std=c++98") + IF(GEOTIFF_BUILD_PEDANTIC) +@@ -115,15 +115,14 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libxtiff) + # TIFF support - required, default=ON + SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built") + +-FIND_PACKAGE(PROJ NO_MODULE QUIET) +-if (NOT PROJ_FOUND) ++FIND_PACKAGE(proj NO_MODULE QUIET) ++if (0) + FIND_PACKAGE(PROJ) + endif () + + IF(PROJ_FOUND) + INCLUDE_DIRECTORIES(${PROJ_INCLUDE_DIR}) + ELSE() +- MESSAGE(FATAL_ERROR "Failed to detect PROJ >= 6") + ENDIF() + + # Zlib support - optional, default=OFF +@@ -164,6 +163,7 @@ IF(WITH_TIFF) + FIND_PACKAGE(TIFF REQUIRED) + endif () + ++ if(0) + IF(TIFF_FOUND) + # Confirm required API is available + INCLUDE(CheckFunctionExists) +@@ -184,6 +184,7 @@ IF(WITH_TIFF) + INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR}) + ADD_DEFINITIONS(-DHAVE_TIFF=1) + ENDIF(TIFF_FOUND) ++ endif() + ENDIF(WITH_TIFF) + + # Turn off TOWGS84 support +@@ -275,7 +276,6 @@ INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION ${GEOTIFF_INCLUDE_DIR}) + ############################################################################### + # Build libxtiff library + +-ADD_SUBDIRECTORY(libxtiff) + + ############################################################################### + # Build libgeotiff library +@@ -319,7 +319,7 @@ if(UNIX) + VERSION ${LINK_VERSION} + SOVERSION ${LINK_SOVERSION} + CLEAN_DIRECT_OUTPUT 1 ) +- if (APPLE) ++ if (0) # no custom install_name, we want @rpath + set_target_properties( + ${GEOTIFF_LIBRARY_TARGET} + PROPERTIES diff --git a/recipes/libgeotiff/all/test_package/CMakeLists.txt b/recipes/libgeotiff/all/test_package/CMakeLists.txt index 111200b74c106..6f7f6667348cb 100644 --- a/recipes/libgeotiff/all/test_package/CMakeLists.txt +++ b/recipes/libgeotiff/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(geotiff REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} geotiff_library) +target_link_libraries(${PROJECT_NAME} PRIVATE geotiff_library) diff --git a/recipes/libgeotiff/all/test_package/conanfile.py b/recipes/libgeotiff/all/test_package/conanfile.py index 84ee68733e516..0a6bc68712d90 100644 --- a/recipes/libgeotiff/all/test_package/conanfile.py +++ b/recipes/libgeotiff/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libgeotiff/all/test_v1_package/CMakeLists.txt b/recipes/libgeotiff/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b4636735c7425 --- /dev/null +++ b/recipes/libgeotiff/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(geotiff REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE geotiff_library) diff --git a/recipes/libgeotiff/all/test_v1_package/conanfile.py b/recipes/libgeotiff/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libgeotiff/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libgeotiff/config.yml b/recipes/libgeotiff/config.yml index 83427e60742aa..a3f59f2ec73eb 100644 --- a/recipes/libgeotiff/config.yml +++ b/recipes/libgeotiff/config.yml @@ -1,4 +1,8 @@ versions: + "1.7.1": + folder: "all" + "1.7.0": + folder: "all" "1.6.0": folder: "all" "1.5.1": diff --git a/recipes/libgettext/all/DEPRECATED b/recipes/libgettext/all/DEPRECATED deleted file mode 100644 index 73d1d87294ff8..0000000000000 --- a/recipes/libgettext/all/DEPRECATED +++ /dev/null @@ -1 +0,0 @@ -libgettext is DEPRECATED in favor of gettext package. Please, update your current dependencies list. \ No newline at end of file diff --git a/recipes/libgettext/all/conandata.yml b/recipes/libgettext/all/conandata.yml index 7b9f07043ec76..601a709179995 100644 --- a/recipes/libgettext/all/conandata.yml +++ b/recipes/libgettext/all/conandata.yml @@ -1,12 +1,24 @@ sources: + "0.21": + url: "https://ftp.gnu.org/pub/gnu/gettext/gettext-0.21.tar.gz" + sha256: "c77d0da3102aec9c07f43671e60611ebff89a996ef159497ce8e59d075786b12" "0.20.1": - sha256: "66415634c6e8c3fa8b71362879ec7575e27da43da562c798a8a2f223e6e47f5c" + sha256: "66415634c6e8c3fa8b71362879ec7575e27da43da562c798a8a2f223e6e47f5c" url: "https://ftp.gnu.org/pub/gnu/gettext/gettext-0.20.1.tar.gz" patches: + "0.21": + - patch_file: "patches/0002-memmove-is-intrinsic-function-on-MSVC.patch" + patch_description: "memmove is intrinsic function on MSVC" + patch_type: "portability" "0.20.1": - patch_file: "patches/0001-build-Fix-build-errors-with-MSVC.patch" - base_path: "source_subfolder" + patch_description: "Fix build errors with MSVC" + patch_type: "portability" + - patch_file: "patches/0002-memmove-is-intrinsic-function-on-MSVC.patch" - base_path: "source_subfolder" + patch_description: "memmove is intrinsic function on MSVC" + patch_type: "portability" + - patch_file: "patches/0003-Reported-by-Gabor-Z.-Papp-gzp-papp.hu.patch" - base_path: "source_subfolder" + patch_description: "fix preloadable libintl for static build" + patch_type: "portability" diff --git a/recipes/libgettext/all/conanfile.py b/recipes/libgettext/all/conanfile.py index f20db0b80fc11..710d9c34780aa 100644 --- a/recipes/libgettext/all/conanfile.py +++ b/recipes/libgettext/all/conanfile.py @@ -1,134 +1,216 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment, tools import os -import shutil -import glob -required_conan_version = ">=1.28.0" +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv, Environment +from conan.tools.files import ( + apply_conandata_patches, + copy, + export_conandata_patches, + get, + rename +) +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" + class GetTextConan(ConanFile): name = "libgettext" description = "An internationalization and localization system for multilingual programs" - topics = ("conan", "gettext", "intl", "libintl", "i18n") + topics = ("gettext", "intl", "libintl", "i18n") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.gnu.org/software/gettext" license = "GPL-3.0-or-later" - deprecated = "gettext" - settings = "os", "arch", "compiler", "build_type" - exports_sources = ["patches/*.patch"] - options = {"shared": [True, False], "fPIC": [True, False], "threads": ["posix", "solaris", "pth", "windows", "disabled", "auto"]} - default_options = {"shared": False, "fPIC": True, "threads": "auto"} - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "threads": ["posix", "solaris", "pth", "windows", "disabled", "auto"], + } + default_options = { + "shared": False, + "fPIC": True, + "threads": "auto", + } @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + def _is_clang_cl(self): + return (str(self.settings.compiler) in ["clang"] and str(self.settings.os) in ["Windows"]) or \ + self.settings.get_safe("compiler.toolset") == "ClangCL" @property def _gettext_folder(self): return "gettext-tools" - @property - def _make_args(self): - return ["-C", "intl"] + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == 'Windows': - del self.options.fPIC + self.options.rm_safe("fPIC") def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + if (self.options.threads == "auto"): + self.options.threads = {"Solaris": "solaris", "Windows": "windows"}.get(str(self.settings.os), "posix") - if(self.options.threads == "auto"): - self.options.threads = { "Solaris": "solaris", "Windows": "windows" }.get(str(self.settings.os), "posix") + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): - self.requires("libiconv/1.16") + self.requires("libiconv/1.17") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) def build_requirements(self): - if tools.os_info.is_windows: - if "CONAN_BASH_PATH" not in os.environ and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20200517") - if self._is_msvc: - self.build_requires("automake/1.16.2") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): + self.tool_requires("msys2/cci.latest") + if is_msvc(self) or self._is_clang_cl: + self.tool_requires("automake/1.16.5") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "gettext-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + VirtualBuildEnv(self).generate() + + if not cross_building(self): + VirtualRunEnv(self).generate(scope="build") + + tc = AutotoolsToolchain(self) + tc.configure_args += [ + "HELP2MAN=/bin/true", + "EMACS=no", + "--disable-nls", + "--disable-dependency-tracking", + "--enable-relocatable", + "--disable-c++", + "--disable-java", + "--disable-csharp", + "--disable-libasprintf", + "--disable-curses", + "--disable-threads" if self.options.threads == "disabled" else ("--enable-threads=" + str(self.options.threads)), + f"--with-libiconv-prefix={unix_path(self, self.deps_cpp_info['libiconv'].rootpath)}" + ] + if is_msvc(self) or self._is_clang_cl: + target = None + if self.settings.arch == "x86_64": + target = "x86_64-w64-mingw32" + elif self.settings.arch == "x86": + target = "i686-w64-mingw32" + + if target is not None: + tc.configure_args += [f"--host={target}", f"--build={target}"] + + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags += ["-FS"] + + tc.make_args += ["-C", "intl"] + tc.generate() + + deps = AutotoolsDeps(self) + + if is_msvc(self) or self._is_clang_cl: + # This mimics the v1 recipe, on the basis that it works and the defaults do not. + def lib_paths(): + for dep in self.deps_cpp_info.deps: + dep_info = self.deps_cpp_info[dep] + for lib_path in dep_info.lib_paths: + yield unix_path(self, lib_path) + + fixed_cppflags_args = deps.vars().get("CPPFLAGS").replace("/I", "-I") + deps.environment.define("CPPFLAGS", f"$CPPFLAGS {fixed_cppflags_args}") + if self._is_clang_cl: + fixed_ldflags_args = deps.vars().get("LDFLAGS").replace("/LIBPATH:", "-LIBPATH:") + else: + fixed_ldflags_args = deps.vars().get("LDFLAGS").replace("/LIBPATH:", "-L") + deps.environment.define("LDFLAGS", f"$LDFLAGS {fixed_ldflags_args}") + + libs = deps.vars().get("LIBS") + deps.environment.define("_LINK_", libs) + deps.environment.unset("LIBS") + + for lib_path in lib_paths(): + deps.environment.prepend_path("LIB", lib_path) + + deps.generate() + + if is_msvc(self) or self._is_clang_cl: + def programs(): + rc = None + if self.settings.arch == "x86_64": + rc = "windres --target=pe-x86-64" + elif self.settings.arch == "x86": + rc = "windres --target=pe-i386" + if self._is_clang_cl: + return os.environ.get("CC", "clang-cl"), os.environ.get("AR", "llvm-lib"), os.environ.get("LD", "lld-link"), rc + if is_msvc(self): + return "cl -nologo", "lib", "link", rc + + env = Environment() + compile_wrapper = unix_path(self, self._user_info_build["automake"].compile) + ar_wrapper = unix_path(self, self._user_info_build["automake"].ar_lib) + cc, ar, link, rc = programs() + env.define("CC", f"{compile_wrapper} {cc}") + env.define("CXX", f"{compile_wrapper} {cc}") + env.define("LD", link) + env.define("AR", f"{ar_wrapper} {ar}") + env.define("NM", "dumpbin -symbols") + env.define("RANLIB", ":") + env.define("STRIP", ":") + if rc is not None: + env.define("RC", rc) + env.define("WINDRES", rc) + + env.vars(self).save_script("conanbuild_msvc") def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - libiconv_prefix = self.deps_cpp_info["libiconv"].rootpath - libiconv_prefix = tools.unix_path(libiconv_prefix) if tools.os_info.is_windows else libiconv_prefix - args = ["HELP2MAN=/bin/true", - "EMACS=no", - "--disable-nls", - "--disable-dependency-tracking", - "--enable-relocatable", - "--disable-c++", - "--disable-java", - "--disable-csharp", - "--disable-libasprintf", - "--disable-curses", - "--disable-threads" if self.options.threads == "disabled" else ("--enable-threads=" + str(self.options.threads)), - "--with-libiconv-prefix=%s" % libiconv_prefix] - build = None - host = None - rc = None - if self.options.shared: - args.extend(["--disable-static", "--enable-shared"]) - else: - args.extend(["--disable-shared", "--enable-static"]) - if self._is_msvc: - # INSTALL.windows: Native binaries, built using the MS Visual C/C++ tool chain. - build = False - if self.settings.arch == "x86": - host = "i686-w64-mingw32" - rc = "windres --target=pe-i386" - elif self.settings.arch == "x86_64": - host = "x86_64-w64-mingw32" - rc = "windres --target=pe-x86-64" - automake_perldir = tools.unix_path(os.path.join(self.deps_cpp_info['automake'].rootpath, "bin", "share", "automake-1.16")) - args.extend(["CC=%s/compile cl -nologo" % automake_perldir, - "LD=link", - "NM=dumpbin -symbols", - "STRIP=:", - "AR=%s/ar-lib lib" % automake_perldir, - "RANLIB=:"]) - if rc: - args.extend(['RC=%s' % rc, 'WINDRES=%s' % rc]) - with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): - with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): - with tools.chdir(os.path.join(self._source_subfolder, self._gettext_folder)): - env_build = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - if self._is_msvc: - env_build.flags.append("-FS") - env_build.configure(args=args, build=build, host=host) - env_build.make(self._make_args) + apply_conandata_patches(self) + autotools = Autotools(self) + autotools.configure("gettext-tools") + autotools.make() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*.dll", dst="bin", src=self._source_subfolder, keep_path=False, symlinks=True) - self.copy(pattern="*.lib", dst="lib", src=self._source_subfolder, keep_path=False, symlinks=True) - self.copy(pattern="*.a", dst="lib", src=self._source_subfolder, keep_path=False, symlinks=True) - self.copy(pattern="*.so*", dst="lib", src=self._source_subfolder, keep_path=False, symlinks=True) - self.copy(pattern="*.dylib*", dst="lib", src=self._source_subfolder, keep_path=False, symlinks=True) - self.copy(pattern="*libgnuintl.h", dst="include", src=self._source_subfolder, keep_path=False, symlinks=True) - os.rename(os.path.join(self.package_folder, "include", "libgnuintl.h"), - os.path.join(self.package_folder, "include", "libintl.h")) - if self._is_msvc and self.options.shared: - os.rename(os.path.join(self.package_folder, "lib", "gnuintl.dll.lib"), - os.path.join(self.package_folder, "lib", "gnuintl.lib")) + dest_lib_dir = os.path.join(self.package_folder, "lib") + dest_runtime_dir = os.path.join(self.package_folder, "bin") + dest_include_dir = os.path.join(self.package_folder, "include") + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy(self, "*gnuintl*.dll", self.build_folder, dest_runtime_dir, keep_path=False) + copy(self, "*gnuintl*.lib", self.build_folder, dest_lib_dir, keep_path=False) + copy(self, "*gnuintl*.a", self.build_folder, dest_lib_dir, keep_path=False) + copy(self, "*gnuintl*.so*", self.build_folder, dest_lib_dir, keep_path=False) + copy(self, "*gnuintl*.dylib", self.build_folder, dest_lib_dir, keep_path=False) + copy(self, "*libgnuintl.h", self.build_folder, dest_include_dir, keep_path=False) + rename(self, os.path.join(dest_include_dir, "libgnuintl.h"), os.path.join(dest_include_dir, "libintl.h")) + if (is_msvc(self) or self._is_clang_cl) and self.options.shared: + rename(self, os.path.join(dest_lib_dir, "gnuintl.dll.lib"), os.path.join(dest_lib_dir, "gnuintl.lib")) def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "Intl") + self.cpp_info.set_property("cmake_target_name", "Intl::Intl") self.cpp_info.libs = ["gnuintl"] - if self.settings.os == "Macos": - self.cpp_info.frameworks.extend(['CoreFoundation']) + if is_apple_os(self): + self.cpp_info.frameworks.append("CoreFoundation") + + self.cpp_info.names["cmake_find_package"] = "Intl" + self.cpp_info.names["cmake_find_package_multi"] = "Intl" diff --git a/recipes/libgettext/all/test_package/CMakeLists.txt b/recipes/libgettext/all/test_package/CMakeLists.txt index 34af13462f44f..1ef1f4a228330 100644 --- a/recipes/libgettext/all/test_package/CMakeLists.txt +++ b/recipes/libgettext/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(Intl CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE Intl::Intl) diff --git a/recipes/libgettext/all/test_package/conanfile.py b/recipes/libgettext/all/test_package/conanfile.py index 6c46399b6e565..b9667f823f2c1 100644 --- a/recipes/libgettext/all/test_package/conanfile.py +++ b/recipes/libgettext/all/test_package/conanfile.py @@ -1,11 +1,31 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.env import Environment, VirtualRunEnv +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, rename + import os -import shutil class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + CMakeDeps(self).generate() + CMakeToolchain(self).generate() + for locale, lang in [("en", "en_US"), ("ru", "ru_RU"), ("es", "es_ES")]: + env = Environment() + env.define("LANG", lang) + env.vars(self, scope=f"run_{locale}").save_script(f"locale_{locale}") + + VirtualRunEnv(self).generate(scope=f"run_{locale}") def build(self): cmake = CMake(self) @@ -15,13 +35,15 @@ def build(self): directory = os.path.join(self.source_folder, locale, "LC_MESSAGES") if not os.path.isdir(directory): os.makedirs(directory) - shutil.copy(os.path.join(self.source_folder, "po", locale, "conan.mo.workaround_git_ignore"), - os.path.join(self.source_folder, locale, "LC_MESSAGES", "conan.mo")) + po_folder = os.path.join(self.source_folder, "po", locale) + dest_folder = os.path.join(self.source_folder, locale, "LC_MESSAGES") + copy(self, "conan.mo.workaround_git_ignore", po_folder, dest_folder) + mo_file = os.path.join(dest_folder, "conan.mo") + if not os.path.exists(mo_file): + rename(self, os.path.join(dest_folder, "conan.mo.workaround_git_ignore"), mo_file) def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - for locale in ["en_US", "ru_RU", "es_ES"]: - with tools.environment_append({"LANG": locale}): - self.run("%s %s" % (bin_path, os.path.abspath(self.source_folder)), run_environment=True) - + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + for locale in ["en", "ru", "es"]: + self.run(f"{bin_path} {os.path.abspath(self.source_folder)}", env=f"conanrun_{locale}") diff --git a/recipes/libgettext/all/test_v1_package/CMakeLists.txt b/recipes/libgettext/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f9bddeec6f96a --- /dev/null +++ b/recipes/libgettext/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Intl CONFIG REQUIRED) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libgettext/all/test_v1_package/conanfile.py b/recipes/libgettext/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..36bfb4bd5c2c9 --- /dev/null +++ b/recipes/libgettext/all/test_v1_package/conanfile.py @@ -0,0 +1,31 @@ +from conans import ConanFile, CMake, tools +from conan.tools.files import copy, rename +import os +import shutil + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + for locale in ["en", "ru", "es"]: + directory = os.path.join(self.source_folder, locale, "LC_MESSAGES") + if not os.path.isdir(directory): + os.makedirs(directory) + po_folder = os.path.join(self.source_folder, "..", "test_package", "po", locale) + dest_folder = os.path.join(self.source_folder, locale, "LC_MESSAGES") + copy(self, "conan.mo.workaround_git_ignore", po_folder, dest_folder) + mo_file = os.path.join(dest_folder, "conan.mo") + if not os.path.exists(mo_file): + rename(self, os.path.join(dest_folder, "conan.mo.workaround_git_ignore"), mo_file) + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + for locale in ["en_US", "ru_RU", "es_ES"]: + with tools.environment_append({"LANG": locale}): + self.run(f"{bin_path} {os.path.abspath(self.source_folder)}", run_environment=True) diff --git a/recipes/libgettext/config.yml b/recipes/libgettext/config.yml index 4ea7b582de7b7..dc03f51a1d462 100644 --- a/recipes/libgettext/config.yml +++ b/recipes/libgettext/config.yml @@ -1,3 +1,5 @@ versions: + "0.21": + folder: all "0.20.1": folder: all diff --git a/recipes/libgit2/0.27.x/CMakeLists.txt b/recipes/libgit2/0.27.x/CMakeLists.txt index 97030501e5bd7..c502da172e7b8 100644 --- a/recipes/libgit2/0.27.x/CMakeLists.txt +++ b/recipes/libgit2/0.27.x/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper C) include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory(source_subfolder) diff --git a/recipes/libgit2/0.27.x/conandata.yml b/recipes/libgit2/0.27.x/conandata.yml index d18a94e064929..dddcd1d95b8f4 100644 --- a/recipes/libgit2/0.27.x/conandata.yml +++ b/recipes/libgit2/0.27.x/conandata.yml @@ -1,7 +1,4 @@ sources: - "0.27.9": - url: "https://github.com/libgit2/libgit2/archive/v0.27.9.tar.gz" - sha256: "adf17310b590e6e7618f070c742b5ee028aeeed2c60099bc4190c386b5060de1" "0.27.10": url: "https://github.com/libgit2/libgit2/archive/v0.27.10.tar.gz" sha256: "f6fd26378ff71bd7a4b17b576c82c774a2e9c2d6b74b24718a8fb29551e1c4a5" diff --git a/recipes/libgit2/0.27.x/conanfile.py b/recipes/libgit2/0.27.x/conanfile.py index 17d887ee33c11..07e2765904500 100644 --- a/recipes/libgit2/0.27.x/conanfile.py +++ b/recipes/libgit2/0.27.x/conanfile.py @@ -1,18 +1,24 @@ +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conans import ConanFile, tools, CMake from conans.errors import ConanInvalidConfiguration +import functools import os +required_conan_version = ">=1.45.0" + class LibGit2Conan(ConanFile): name = "libgit2" - description = "libgit2 is a portable, pure C implementation of the Git core methods provided as a re-entrant linkable library with a solid API" - topics = ("conan", "libgit2", "git", "scm", ) + description = ( + "libgit2 is a portable, pure C implementation of the Git core methods " + "provided as a re-entrant linkable library with a solid API" + ) + topics = ("libgit2", "git", "scm") url = "https://github.com/conan-io/conan-center-index" homepage = "https://libgit2.org/" - license = ("GPL-2.0-linking-exception",) - exports_sources = "CMakeLists.txt", - generators = "cmake", "cmake_find_package", - settings = "os", "compiler", "build_type", "arch" + license = "GPL-2.0-linking-exception" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -20,7 +26,7 @@ class LibGit2Conan(ConanFile): "with_iconv": [True, False], "with_libssh2": [True, False], "with_https": [False, "openssl", "winhttp", "security"], - "with_sha1": ["collisiondetection", "commoncrypto", "openssl", "generic", "win32"], + "with_sha1": ["collisiondetection", "commoncrypto", "openssl", "generic", "win32"], } default_options = { "shared": False, @@ -32,23 +38,41 @@ class LibGit2Conan(ConanFile): "with_sha1": "collisiondetection", } - _cmake = None + exports_sources = "CMakeLists.txt" + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): return "source_subfolder" def config_options(self): - if self.settings.os == "Windows" or self.options.shared: + if self.settings.os == "Windows": del self.options.fPIC if not tools.is_apple_os(self.settings.os): del self.options.with_iconv def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.cppstd del self.settings.compiler.libcxx + @property + def _need_openssl(self): + return "openssl" in (self.options.with_https, self.options.with_sha1) + + def requirements(self): + self.requires("zlib/1.2.12") + self.requires("http_parser/2.9.4") + if self.options.with_libssh2: + self.requires("libssh2/1.10.0") + if self.settings.os != "Windows": + self.requires("libcurl/7.83.1") + if self._need_openssl: + self.requires("openssl/1.1.1o") + + def validate(self): if self.options.with_https == "security": if not tools.is_apple_os(self.settings.os): raise ConanInvalidConfiguration("security is only valid for Apple products") @@ -60,24 +84,9 @@ def configure(self): if self.settings.os != "Windows": raise ConanInvalidConfiguration("win32 is only valid on Windows") - @property - def _need_openssl(self): - return "openssl" in (self.options.with_https, self.options.with_sha1) - - def requirements(self): - self.requires("zlib/1.2.11") - self.requires("http_parser/2.9.4") - if self.options.with_libssh2: - self.requires("libssh2/1.9.0") - if self.settings.os != "Windows": - self.requires("libcurl/7.75.0") - if self._need_openssl: - self.requires("openssl/1.1.1j") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{}-{}".format(self.name, self.version) - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) _cmake_https = { "openssl": "OpenSSL", @@ -94,30 +103,25 @@ def source(self): "win32": "Win32", } + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["THREADSAFE"] = self.options.threadsafe - self._cmake.definitions["USE_SSH"] = self.options.with_libssh2 - - if tools.is_apple_os(self.settings.os): - self._cmake.definitions["USE_ICONV"] = self.options.with_iconv - else: - self._cmake.definitions["USE_ICONV"] = True + cmake = CMake(self) + cmake.definitions["THREADSAFE"] = self.options.threadsafe + cmake.definitions["USE_SSH"] = self.options.with_libssh2 + cmake.definitions["USE_ICONV"] = self.options.get_safe("with_iconv", False) - self._cmake.definitions["USE_HTTPS"] = self._cmake_https[str(self.options.with_https)] - self._cmake.definitions["SHA1_BACKEND"] = self._cmake_sha1[str(self.options.with_sha1)] + cmake.definitions["USE_HTTPS"] = self._cmake_https[str(self.options.with_https)] + cmake.definitions["SHA1_BACKEND"] = self._cmake_sha1[str(self.options.with_sha1)] - self._cmake.definitions["BUILD_CLAR"] = False - self._cmake.definitions["BUILD_EXAMPLES"] = False + cmake.definitions["BUILD_CLAR"] = False + cmake.definitions["BUILD_EXAMPLES"] = False - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["STATIC_CRT"] = "MT" in str(self.settings.compiler.runtime) + if is_msvc(self): + cmake.definitions["STATIC_CRT"] = is_msvc_static_runtime(self) - self._cmake.configure() - return self._cmake + cmake.configure() + return cmake def _patch_sources(self): tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), @@ -138,14 +142,15 @@ def build(self): cmake.build() def package(self): - self.copy("COPYING", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") + self.copy("COPYING", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libgit2") self.cpp_info.libs = ["git2"] if self.settings.os == "Windows": self.cpp_info.system_libs.extend(["winhttp", "rpcrt4", "crypt32"]) - if self.settings.os == "Linux" and self.options.threadsafe: + if self.settings.os in ["Linux", "FreeBSD"] and self.options.threadsafe: self.cpp_info.system_libs.append("pthread") diff --git a/recipes/libgit2/0.27.x/test_package/CMakeLists.txt b/recipes/libgit2/0.27.x/test_package/CMakeLists.txt index 196188113685c..912bdc647f324 100644 --- a/recipes/libgit2/0.27.x/test_package/CMakeLists.txt +++ b/recipes/libgit2/0.27.x/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +find_package(libgit2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libgit2::libgit2) diff --git a/recipes/libgit2/0.27.x/test_package/conanfile.py b/recipes/libgit2/0.27.x/test_package/conanfile.py index bd7165a553cf4..38f4483872d47 100644 --- a/recipes/libgit2/0.27.x/test_package/conanfile.py +++ b/recipes/libgit2/0.27.x/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libgit2/0.27.x/test_package/test_package.c b/recipes/libgit2/0.27.x/test_package/test_package.c new file mode 100644 index 0000000000000..1ea125101cdc8 --- /dev/null +++ b/recipes/libgit2/0.27.x/test_package/test_package.c @@ -0,0 +1,34 @@ +#include + +#include + +int main() +{ + git_libgit2_init(); + int versionMajor, versionMinor, versionRev; + git_libgit2_version(&versionMajor, &versionMinor, &versionRev); + + printf("libgit2 v%i.%i.%i\n", versionMajor, versionMinor, versionRev); + + printf("Compile Features:\n"); + + int features = git_libgit2_features(); + + if (features & GIT_FEATURE_THREADS) + printf(" - Thread safe\n"); + else + printf(" - Single thread only\n"); + + if (features & GIT_FEATURE_HTTPS) + printf(" - TLS (openssl, winhttp or security)\n"); + else + printf(" - No TLS\n"); + + if (features & GIT_FEATURE_SSH) + printf(" - SSH (libssh2)\n"); + else + printf(" - No SSH support\n"); + + git_libgit2_shutdown(); + return 0; +} diff --git a/recipes/libgit2/0.27.x/test_package/test_package.cpp b/recipes/libgit2/0.27.x/test_package/test_package.cpp deleted file mode 100644 index ab4034d609280..0000000000000 --- a/recipes/libgit2/0.27.x/test_package/test_package.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "git2.h" - -#include -#include - -int main() -{ - git_libgit2_init(); - int versionMajor, versionMinor, versionRev; - git_libgit2_version(&versionMajor, &versionMinor, &versionRev); - - std::cout << "libgit2 v" << versionMajor << "." << versionMinor << "." << versionRev << std::endl; - - std::cout << "Compile Features:" << std::endl; - - int features = git_libgit2_features(); - - if (features & GIT_FEATURE_THREADS) - std::cout << " - Thread safe" << std::endl; - else - std::cout << " - Single thread only" << std::endl; - - if (features & GIT_FEATURE_HTTPS) - std::cout << " - TLS (openssl, winhttp or security)" << std::endl; - else - std::cout << " - No TLS" << std::endl; - - if (features & GIT_FEATURE_SSH) - std::cout << " - SSH (libssh2)" << std::endl; - else - std::cout << " - No SSH support" << std::endl; - - git_libgit2_shutdown(); - return EXIT_SUCCESS; -} diff --git a/recipes/libgit2/0.28.x/CMakeLists.txt b/recipes/libgit2/0.28.x/CMakeLists.txt index 97030501e5bd7..c502da172e7b8 100644 --- a/recipes/libgit2/0.28.x/CMakeLists.txt +++ b/recipes/libgit2/0.28.x/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper C) include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory(source_subfolder) diff --git a/recipes/libgit2/0.28.x/conandata.yml b/recipes/libgit2/0.28.x/conandata.yml index 18a2c3e5df728..25994eed756a3 100644 --- a/recipes/libgit2/0.28.x/conandata.yml +++ b/recipes/libgit2/0.28.x/conandata.yml @@ -2,6 +2,3 @@ sources: "0.28.5": url: "https://github.com/libgit2/libgit2/archive/v0.28.5.tar.gz" sha256: "2b7b68aee6f123bc84cc502a9c12738435b8054e7d628962e091cd2a25be4f42" - "0.28.3": - url: "https://github.com/libgit2/libgit2/archive/v0.28.3.tar.gz" - sha256: "ee5344730fe11ce7c86646e19c2d257757be293f5a567548d398fb3af8b8e53b" diff --git a/recipes/libgit2/0.28.x/conanfile.py b/recipes/libgit2/0.28.x/conanfile.py index db3987cd12dab..7e3da960a3cb2 100644 --- a/recipes/libgit2/0.28.x/conanfile.py +++ b/recipes/libgit2/0.28.x/conanfile.py @@ -1,18 +1,24 @@ +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conans import ConanFile, tools, CMake from conans.errors import ConanInvalidConfiguration +import functools import os +required_conan_version = ">=1.45.0" + class LibGit2Conan(ConanFile): name = "libgit2" - description = "libgit2 is a portable, pure C implementation of the Git core methods provided as a re-entrant linkable library with a solid API" - topics = ("conan", "libgit2", "git", "scm", ) + description = ( + "libgit2 is a portable, pure C implementation of the Git core methods " + "provided as a re-entrant linkable library with a solid API" + ) + topics = ("libgit2", "git", "scm") url = "https://github.com/conan-io/conan-center-index" homepage = "https://libgit2.org/" - license = ("GPL-2.0-linking-exception",) - exports_sources = "CMakeLists.txt", - generators = "cmake", "cmake_find_package", - settings = "os", "compiler", "build_type", "arch" + license = "GPL-2.0-linking-exception" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -32,14 +38,15 @@ class LibGit2Conan(ConanFile): "with_sha1": "collisiondetection", } - _cmake = None + exports_sources = "CMakeLists.txt" + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): return "source_subfolder" def config_options(self): - if self.settings.os == "Windows" or self.options.shared: + if self.settings.os == "Windows": del self.options.fPIC if not tools.is_apple_os(self.settings.os): @@ -51,17 +58,6 @@ def configure(self): del self.settings.compiler.cppstd del self.settings.compiler.libcxx - if self.options.with_https == "security": - if not tools.is_apple_os(self.settings.os): - raise ConanInvalidConfiguration("security is only valid for Apple products") - elif self.options.with_https == "winhttp": - if self.settings.os != "Windows": - raise ConanInvalidConfiguration("winhttp is only valid on Windows") - - if self.options.with_sha1 == "win32": - if self.settings.os != "Windows": - raise ConanInvalidConfiguration("win32 is only valid on Windows") - @property def _need_openssl(self): return "openssl" in (self.options.with_https, self.options.with_sha1) @@ -71,21 +67,32 @@ def _need_mbedtls(self): return "mbedtls" in (self.options.with_https, self.options.with_sha1) def requirements(self): - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.12") self.requires("http_parser/2.9.4") if self.options.with_libssh2: - self.requires("libssh2/1.9.0") + self.requires("libssh2/1.10.0") if self._need_openssl: - self.requires("openssl/1.1.1j") + self.requires("openssl/1.1.1o") if self._need_mbedtls: - self.requires("mbedtls/2.24.0") + self.requires("mbedtls/3.1.0") if tools.is_apple_os(self.settings.os) and self.options.with_iconv: self.requires("libiconv/1.16") + def validate(self): + if self.options.with_https == "security": + if not tools.is_apple_os(self.settings.os): + raise ConanInvalidConfiguration("security is only valid for Apple products") + elif self.options.with_https == "winhttp": + if self.settings.os != "Windows": + raise ConanInvalidConfiguration("winhttp is only valid on Windows") + + if self.options.with_sha1 == "win32": + if self.settings.os != "Windows": + raise ConanInvalidConfiguration("win32 is only valid on Windows") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{}-{}".format(self.name, self.version) - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) _cmake_https = { "openssl": "OpenSSL", @@ -104,29 +111,25 @@ def source(self): "win32": "Win32", } + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["THREADSAFE"] = self.options.threadsafe - self._cmake.definitions["USE_SSH"] = self.options.with_libssh2 + cmake = CMake(self) + cmake.definitions["THREADSAFE"] = self.options.threadsafe + cmake.definitions["USE_SSH"] = self.options.with_libssh2 - if tools.is_apple_os(self.settings.os): - self._cmake.definitions["USE_ICONV"] = self.options.with_iconv - else: - self._cmake.definitions["USE_ICONV"] = False + cmake.definitions["USE_ICONV"] = self.options.get_safe("with_iconv", False) - self._cmake.definitions["USE_HTTPS"] = self._cmake_https[str(self.options.with_https)] - self._cmake.definitions["SHA1_BACKEND"] = self._cmake_sha1[str(self.options.with_sha1)] + cmake.definitions["USE_HTTPS"] = self._cmake_https[str(self.options.with_https)] + cmake.definitions["SHA1_BACKEND"] = self._cmake_sha1[str(self.options.with_sha1)] - self._cmake.definitions["BUILD_CLAR"] = False - self._cmake.definitions["BUILD_EXAMPLES"] = False + cmake.definitions["BUILD_CLAR"] = False + cmake.definitions["BUILD_EXAMPLES"] = False - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["STATIC_CRT"] = "MT" in str(self.settings.compiler.runtime) + if is_msvc(self): + cmake.definitions["STATIC_CRT"] = is_msvc_static_runtime(self) - self._cmake.configure() - return self._cmake + cmake.configure() + return cmake def _patch_sources(self): tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), @@ -139,20 +142,19 @@ def _patch_sources(self): def build(self): self._patch_sources() - cmake = self._configure_cmake() cmake.build() def package(self): - self.copy("COPYING", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") + self.copy("COPYING", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libgit2") self.cpp_info.libs = ["git2"] if self.settings.os == "Windows": self.cpp_info.system_libs.extend(["winhttp", "rpcrt4", "crypt32"]) - if self.settings.os == "Linux" and self.options.threadsafe: + if self.settings.os in ["Linux", "FreeBSD"] and self.options.threadsafe: self.cpp_info.system_libs.append("pthread") diff --git a/recipes/libgit2/0.28.x/test_package/CMakeLists.txt b/recipes/libgit2/0.28.x/test_package/CMakeLists.txt index 196188113685c..912bdc647f324 100644 --- a/recipes/libgit2/0.28.x/test_package/CMakeLists.txt +++ b/recipes/libgit2/0.28.x/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +find_package(libgit2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libgit2::libgit2) diff --git a/recipes/libgit2/0.28.x/test_package/conanfile.py b/recipes/libgit2/0.28.x/test_package/conanfile.py index bd7165a553cf4..38f4483872d47 100644 --- a/recipes/libgit2/0.28.x/test_package/conanfile.py +++ b/recipes/libgit2/0.28.x/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libgit2/0.28.x/test_package/test_package.c b/recipes/libgit2/0.28.x/test_package/test_package.c new file mode 100644 index 0000000000000..96e8eda89c73b --- /dev/null +++ b/recipes/libgit2/0.28.x/test_package/test_package.c @@ -0,0 +1,34 @@ +#include + +#include + +int main() +{ + git_libgit2_init(); + int versionMajor, versionMinor, versionRev; + git_libgit2_version(&versionMajor, &versionMinor, &versionRev); + + printf("libgit2 v%i.%i.%i\n", versionMajor, versionMinor, versionRev); + + printf("Compile Features:\n"); + + int features = git_libgit2_features(); + + if (features & GIT_FEATURE_THREADS) + printf(" - Thread safe\n"); + else + printf(" - Single thread only\n"); + + if (features & GIT_FEATURE_HTTPS) + printf(" - TLS (openssl, mbedtls, winhttp or security)\n"); + else + printf(" - No TLS\n"); + + if (features & GIT_FEATURE_SSH) + printf(" - SSH (libssh2)\n"); + else + printf(" - No SSH support\n"); + + git_libgit2_shutdown(); + return 0; +} diff --git a/recipes/libgit2/0.28.x/test_package/test_package.cpp b/recipes/libgit2/0.28.x/test_package/test_package.cpp deleted file mode 100644 index 8e7504a8338a1..0000000000000 --- a/recipes/libgit2/0.28.x/test_package/test_package.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "git2.h" - -#include -#include - -int main() -{ - git_libgit2_init(); - int versionMajor, versionMinor, versionRev; - git_libgit2_version(&versionMajor, &versionMinor, &versionRev); - - std::cout << "libgit2 v" << versionMajor << "." << versionMinor << "." << versionRev << std::endl; - - std::cout << "Compile Features:" << std::endl; - - int features = git_libgit2_features(); - - if (features & GIT_FEATURE_THREADS) - std::cout << " - Thread safe" << std::endl; - else - std::cout << " - Single thread only" << std::endl; - - if (features & GIT_FEATURE_HTTPS) - std::cout << " - TLS (openssl, mbedtls, winhttp or security)" << std::endl; - else - std::cout << " - No TLS" << std::endl; - - if (features & GIT_FEATURE_SSH) - std::cout << " - SSH (libssh2)" << std::endl; - else - std::cout << " - No SSH support" << std::endl; - - git_libgit2_shutdown(); - return EXIT_SUCCESS; -} diff --git a/recipes/libgit2/all/CMakeLists.txt b/recipes/libgit2/all/CMakeLists.txt index 97030501e5bd7..c502da172e7b8 100644 --- a/recipes/libgit2/all/CMakeLists.txt +++ b/recipes/libgit2/all/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper C) include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory(source_subfolder) diff --git a/recipes/libgit2/all/conandata.yml b/recipes/libgit2/all/conandata.yml index f603f1adc2e33..7725b775b39de 100644 --- a/recipes/libgit2/all/conandata.yml +++ b/recipes/libgit2/all/conandata.yml @@ -1,7 +1,38 @@ sources: - "1.1.0": - url: "https://github.com/libgit2/libgit2/archive/v1.1.0.tar.gz" - sha256: "41a6d5d740fd608674c7db8685685f45535323e73e784062cf000a633d420d1e" + "1.5.0": + url: "https://github.com/libgit2/libgit2/archive/v1.5.0.tar.gz" + sha256: "8de872a0f201b33d9522b817c92e14edb4efad18dae95cf156cf240b2efff93e" + "1.4.3": + url: "https://github.com/libgit2/libgit2/archive/v1.4.3.tar.gz" + sha256: "f48b961e463a9e4e7e7e58b21a0fb5a9b2a1d24d9ba4d15870a0c9b8ad965163" + "1.3.0": + url: "https://github.com/libgit2/libgit2/archive/v1.3.0.tar.gz" + sha256: "192eeff84596ff09efb6b01835a066f2df7cd7985e0991c79595688e6b36444e" + "1.2.0": + url: "https://github.com/libgit2/libgit2/archive/v1.2.0.tar.gz" + sha256: "701a5086a968a46f25e631941b99fc23e4755ca2c56f59371ce1d94b9a0cc643" + "1.1.1": + url: "https://github.com/libgit2/libgit2/archive/v1.1.1.tar.gz" + sha256: "13a525373f64c711a00a058514d890d1512080265f98e0935ab279393f21a620" "1.0.1": url: "https://github.com/libgit2/libgit2/archive/v1.0.1.tar.gz" sha256: "1775427a6098f441ddbaa5bd4e9b8a043c7401e450ed761e69a415530fea81d2" +patches: + "1.5.0": + - patch_file: "patches/1.4.3-0001-fix-cmake.patch" + base_path: "source_subfolder" + "1.4.3": + - patch_file: "patches/1.4.3-0001-fix-cmake.patch" + base_path: "source_subfolder" + "1.3.0": + - patch_file: "patches/1.3.0-0001-fix-cmake.patch" + base_path: "source_subfolder" + "1.2.0": + - patch_file: "patches/1.2.0-0001-fix-cmake.patch" + base_path: "source_subfolder" + "1.1.1": + - patch_file: "patches/1.1.1-0001-fix-cmake.patch" + base_path: "source_subfolder" + "1.0.1": + - patch_file: "patches/1.0.1-0001-fix-cmake.patch" + base_path: "source_subfolder" diff --git a/recipes/libgit2/all/conanfile.py b/recipes/libgit2/all/conanfile.py index 15cc4148e0a52..c042b13f51df6 100644 --- a/recipes/libgit2/all/conanfile.py +++ b/recipes/libgit2/all/conanfile.py @@ -1,18 +1,24 @@ +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conans import ConanFile, tools, CMake from conans.errors import ConanInvalidConfiguration +import functools import os +required_conan_version = ">=1.45.0" + class LibGit2Conan(ConanFile): name = "libgit2" - description = "libgit2 is a portable, pure C implementation of the Git core methods provided as a re-entrant linkable library with a solid API" - topics = ("conan", "libgit2", "git", "scm", ) + description = ( + "libgit2 is a portable, pure C implementation of the Git core methods " + "provided as a re-entrant linkable library with a solid API" + ) + topics = ("libgit2", "git", "scm") url = "https://github.com/conan-io/conan-center-index" homepage = "https://libgit2.org/" - license = ("GPL-2.0-linking-exception",) - exports_sources = "CMakeLists.txt", - generators = "cmake", "cmake_find_package" - settings = "os", "compiler", "build_type", "arch" + license = "GPL-2.0-linking-exception" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -22,7 +28,7 @@ class LibGit2Conan(ConanFile): "with_https": [False, "openssl", "mbedtls", "winhttp", "security"], "with_sha1": ["collisiondetection", "commoncrypto", "openssl", "mbedtls", "generic", "win32"], "with_ntlmclient": [True, False], - "with_regex": ["auto", "builtin", "pcre", "pcre2", "regcomp_l", "regcomp"], + "with_regex": ["builtin", "pcre", "pcre2", "regcomp_l", "regcomp"], } default_options = { "shared": False, @@ -33,15 +39,21 @@ class LibGit2Conan(ConanFile): "with_https": "openssl", "with_sha1": "collisiondetection", "with_ntlmclient": True, - "with_regex": "auto", + "with_regex": "builtin", } + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): return "source_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): - if self.settings.os == "Windows" or self.options.shared: + if self.settings.os == "Windows": del self.options.fPIC if not tools.is_apple_os(self.settings.os): @@ -50,12 +62,40 @@ def config_options(self): if self.settings.os == "Windows": del self.options.with_ntlmclient + if self.settings.os == "Macos": + self.options.with_regex = "regcomp_l" + def configure(self): if self.options.shared: del self.options.fPIC del self.settings.compiler.cppstd del self.settings.compiler.libcxx + def requirements(self): + self.requires("zlib/1.2.12") + self.requires("http_parser/2.9.4") + if self.options.with_libssh2: + self.requires("libssh2/1.10.0") + if self._need_openssl: + self.requires("openssl/1.1.1o") + if self._need_mbedtls: + self.requires("mbedtls/3.1.0") + if self.options.get_safe("with_iconv"): + self.requires("libiconv/1.16") + if self.options.with_regex == "pcre": + self.requires("pcre/8.45") + elif self.options.with_regex == "pcre2": + self.requires("pcre2/10.40") + + @property + def _need_openssl(self): + return "openssl" in (self.options.with_https, self.options.with_sha1) + + @property + def _need_mbedtls(self): + return "mbedtls" in (self.options.with_https, self.options.with_sha1) + + def validate(self): if self.options.with_https == "security": if not tools.is_apple_os(self.settings.os): raise ConanInvalidConfiguration("security is only valid for Apple products") @@ -67,48 +107,16 @@ def configure(self): if self.settings.os != "Windows": raise ConanInvalidConfiguration("win32 is only valid on Windows") - self.options.with_regex = self._with_regex if self.options.with_regex == "regcomp" or self.options.with_regex == "regcomp_l": if self.settings.compiler == "Visual Studio": raise ConanInvalidConfiguration("{} isn't supported by Visual Studio".format(self.options.with_regex)) - @property - def _need_openssl(self): - return "openssl" in (self.options.with_https, self.options.with_sha1) - - @property - def _need_mbedtls(self): - return "mbedtls" in (self.options.with_https, self.options.with_sha1) - - @property - def _with_regex(self): - if self.options.with_regex == "auto": - if tools.is_apple_os(self.settings.os): - return "regcomp_l" - else: - return "builtin" - return self.options.with_regex - - def requirements(self): - self.requires("zlib/1.2.11") - self.requires("http_parser/2.9.4") - if self.options.with_libssh2: - self.requires("libssh2/1.9.0") - if self._need_openssl: - self.requires("openssl/1.1.1j") - if self._need_mbedtls: - self.requires("mbedtls/2.24.0") - if tools.is_apple_os(self.settings.os) and self.options.with_iconv: - self.requires("libiconv/1.16") - if self.options.with_regex == "pcre": - self.requires("pcre/8.44") - elif self.options.with_regex == "pcre2": - self.requires("pcre2/10.36") + if self.settings.os in ["iOS", "tvOS", "watchOS"] and self.options.with_regex == "regcomp_l": + raise ConanInvalidConfiguration("regcomp_l isn't supported on {}".format(self.settings.os)) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{}-{}".format(self.name, self.version) - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) _cmake_https = { "openssl": "OpenSSL", @@ -127,65 +135,47 @@ def source(self): "win32": "Win32", } + @functools.lru_cache(1) def _configure_cmake(self): cmake = CMake(self) cmake.definitions["THREADSAFE"] = self.options.threadsafe cmake.definitions["USE_SSH"] = self.options.with_libssh2 - if tools.is_apple_os(self.settings.os): - cmake.definitions["USE_ICONV"] = self.options.with_iconv - else: - cmake.definitions["USE_ICONV"] = False + cmake.definitions["USE_ICONV"] = self.options.get_safe("with_iconv", False) cmake.definitions["USE_HTTPS"] = self._cmake_https[str(self.options.with_https)] cmake.definitions["USE_SHA1"] = self._cmake_sha1[str(self.options.with_sha1)] + if tools.Version(self.version) >= "1.4.0": + cmake.definitions["BUILD_TESTS"] = False cmake.definitions["BUILD_CLAR"] = False cmake.definitions["BUILD_EXAMPLES"] = False cmake.definitions["USE_HTTP_PARSER"] = "system" cmake.definitions["REGEX_BACKEND"] = self.options.with_regex - if self.settings.compiler == "Visual Studio": - cmake.definitions["STATIC_CRT"] = "MT" in str(self.settings.compiler.runtime) + if is_msvc(self): + cmake.definitions["STATIC_CRT"] = is_msvc_static_runtime(self) cmake.configure() - return cmake - def _patch_sources(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), - "FIND_PKGLIBRARIES(LIBSSH2 libssh2)", - "FIND_PACKAGE(Libssh2 REQUIRED)\n" - "\tSET(LIBSSH2_FOUND ON)\n" - "\tSET(LIBSSH2_INCLUDE_DIRS ${Libssh2_INCLUDE_DIRS})\n" - "\tSET(LIBSSH2_LIBRARIES ${Libssh2_LIBRARIES})\n" - "\tSET(LIBSSH2_LIBRARY_DIRS ${Libssh2_LIB_DIRS})") - - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), - "FIND_PACKAGE(HTTP_Parser)", - "FIND_PACKAGE(http_parser)") - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), - "AND HTTP_PARSER_VERSION_MAJOR EQUAL 2", - "") - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), - "HTTP_PARSER_", - "http_parser_") - def build(self): - self._patch_sources() + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) cmake = self._configure_cmake() cmake.build() def package(self): - self.copy("COPYING", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") + self.copy("COPYING", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libgit2") self.cpp_info.libs = ["git2"] if self.settings.os == "Windows": self.cpp_info.system_libs.extend(["winhttp", "rpcrt4", "crypt32"]) - if self.settings.os == "Linux" and self.options.threadsafe: + if self.settings.os in ["Linux", "FreeBSD"] and self.options.threadsafe: self.cpp_info.system_libs.append("pthread") diff --git a/recipes/libgit2/all/patches/1.0.1-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.0.1-0001-fix-cmake.patch new file mode 100644 index 0000000000000..2f0d05b998d5d --- /dev/null +++ b/recipes/libgit2/all/patches/1.0.1-0001-fix-cmake.patch @@ -0,0 +1,33 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index dff1d94..abd9c45 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -158,11 +158,11 @@ ENDIF() + + # Optional external dependency: http-parser + IF(USE_HTTP_PARSER STREQUAL "system") +- FIND_PACKAGE(HTTP_Parser) ++ FIND_PACKAGE(http_parser) + +- IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) +- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS}) +- LIST(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES}) ++ IF (http_parser_FOUND) ++ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${http_parser_INCLUDE_DIRS}) ++ LIST(APPEND LIBGIT2_LIBS ${http_parser_LIBRARIES}) + LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser") + ADD_FEATURE_INFO(http-parser ON "http-parser support (system)") + ELSE() +@@ -201,7 +201,11 @@ ENDIF() + + # Optional external dependency: libssh2 + IF (USE_SSH) +- FIND_PKGLIBRARIES(LIBSSH2 libssh2) ++ FIND_PACKAGE(Libssh2 REQUIRED) ++ SET(LIBSSH2_FOUND ON) ++ SET(LIBSSH2_INCLUDE_DIRS ${Libssh2_INCLUDE_DIRS}) ++ SET(LIBSSH2_LIBRARIES ${Libssh2_LIBRARIES}) ++ SET(LIBSSH2_LIBRARY_DIRS ${Libssh2_LIB_DIRS}) + ENDIF() + IF (LIBSSH2_FOUND) + SET(GIT_SSH 1) diff --git a/recipes/libgit2/all/patches/1.1.1-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.1.1-0001-fix-cmake.patch new file mode 100644 index 0000000000000..5dc56b1a31b92 --- /dev/null +++ b/recipes/libgit2/all/patches/1.1.1-0001-fix-cmake.patch @@ -0,0 +1,33 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index d01cc64..0941cbd 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -167,11 +167,11 @@ ENDIF() + + # Optional external dependency: http-parser + IF(USE_HTTP_PARSER STREQUAL "system") +- FIND_PACKAGE(HTTP_Parser) ++ FIND_PACKAGE(http_parser) + +- IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) +- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS}) +- LIST(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES}) ++ IF (http_parser_FOUND) ++ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${http_parser_INCLUDE_DIRS}) ++ LIST(APPEND LIBGIT2_LIBS ${http_parser_LIBRARIES}) + LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser") + ADD_FEATURE_INFO(http-parser ON "http-parser support (system)") + ELSE() +@@ -210,7 +210,11 @@ ENDIF() + + # Optional external dependency: libssh2 + IF (USE_SSH) +- FIND_PKGLIBRARIES(LIBSSH2 libssh2) ++ FIND_PACKAGE(Libssh2 REQUIRED) ++ SET(LIBSSH2_FOUND ON) ++ SET(LIBSSH2_INCLUDE_DIRS ${Libssh2_INCLUDE_DIRS}) ++ SET(LIBSSH2_LIBRARIES ${Libssh2_LIBRARIES}) ++ SET(LIBSSH2_LIBRARY_DIRS ${Libssh2_LIB_DIRS}) + ENDIF() + IF (LIBSSH2_FOUND) + SET(GIT_SSH 1) diff --git a/recipes/libgit2/all/patches/1.2.0-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.2.0-0001-fix-cmake.patch new file mode 100644 index 0000000000000..0fbbd568d7b10 --- /dev/null +++ b/recipes/libgit2/all/patches/1.2.0-0001-fix-cmake.patch @@ -0,0 +1,33 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 45dec27..783c657 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -178,11 +178,11 @@ ENDIF() + + # Optional external dependency: http-parser + IF(USE_HTTP_PARSER STREQUAL "system") +- FIND_PACKAGE(HTTP_Parser) ++ FIND_PACKAGE(http_parser) + +- IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) +- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS}) +- LIST(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES}) ++ IF (http_parser_FOUND) ++ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${http_parser_INCLUDE_DIRS}) ++ LIST(APPEND LIBGIT2_LIBS ${http_parser_LIBRARIES}) + LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser") + ADD_FEATURE_INFO(http-parser ON "http-parser support (system)") + ELSE() +@@ -231,7 +231,11 @@ ENDIF() + + # Optional external dependency: libssh2 + IF (USE_SSH) +- FIND_PKGLIBRARIES(LIBSSH2 libssh2) ++ FIND_PACKAGE(Libssh2 REQUIRED) ++ SET(LIBSSH2_FOUND ON) ++ SET(LIBSSH2_INCLUDE_DIRS ${Libssh2_INCLUDE_DIRS}) ++ SET(LIBSSH2_LIBRARIES ${Libssh2_LIBRARIES}) ++ SET(LIBSSH2_LIBRARY_DIRS ${Libssh2_LIB_DIRS}) + ENDIF() + IF (LIBSSH2_FOUND) + SET(GIT_SSH 1) diff --git a/recipes/libgit2/all/patches/1.3.0-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.3.0-0001-fix-cmake.patch new file mode 100644 index 0000000000000..997b6dd7759b0 --- /dev/null +++ b/recipes/libgit2/all/patches/1.3.0-0001-fix-cmake.patch @@ -0,0 +1,40 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index fdb3673..783c657 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -178,11 +178,11 @@ ENDIF() + + # Optional external dependency: http-parser + IF(USE_HTTP_PARSER STREQUAL "system") +- FIND_PACKAGE(HTTP_Parser) ++ FIND_PACKAGE(http_parser) + +- IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) +- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS}) +- LIST(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES}) ++ IF (http_parser_FOUND) ++ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${http_parser_INCLUDE_DIRS}) ++ LIST(APPEND LIBGIT2_LIBS ${http_parser_LIBRARIES}) + LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser") + ADD_FEATURE_INFO(http-parser ON "http-parser support (system)") + ELSE() +@@ -231,14 +231,11 @@ ENDIF() + + # Optional external dependency: libssh2 + IF (USE_SSH) +- FIND_PKGLIBRARIES(LIBSSH2 libssh2) +- IF (NOT LIBSSH2_FOUND) +- FIND_PACKAGE(LibSSH2) +- SET(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR}) +- GET_FILENAME_COMPONENT(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY) +- SET(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY}) +- SET(LIBSSH2_LDFLAGS "-lssh2") +- ENDIF() ++ FIND_PACKAGE(Libssh2 REQUIRED) ++ SET(LIBSSH2_FOUND ON) ++ SET(LIBSSH2_INCLUDE_DIRS ${Libssh2_INCLUDE_DIRS}) ++ SET(LIBSSH2_LIBRARIES ${Libssh2_LIBRARIES}) ++ SET(LIBSSH2_LIBRARY_DIRS ${Libssh2_LIB_DIRS}) + ENDIF() + IF (LIBSSH2_FOUND) + SET(GIT_SSH 1) diff --git a/recipes/libgit2/all/patches/1.4.3-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.4.3-0001-fix-cmake.patch new file mode 100644 index 0000000000000..459414c1a9584 --- /dev/null +++ b/recipes/libgit2/all/patches/1.4.3-0001-fix-cmake.patch @@ -0,0 +1,42 @@ +diff --git a/cmake/SelectHTTPParser.cmake b/cmake/SelectHTTPParser.cmake +index 955aea3..ff94eb8 100644 +--- a/cmake/SelectHTTPParser.cmake ++++ b/cmake/SelectHTTPParser.cmake +@@ -1,10 +1,10 @@ + # Optional external dependency: http-parser + if(USE_HTTP_PARSER STREQUAL "system") +- find_package(HTTPParser) ++ find_package(http_parser) + +- if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) +- list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS}) +- list(APPEND LIBGIT2_SYSTEM_LIBS ${HTTP_PARSER_LIBRARIES}) ++ if(http_parser_FOUND) ++ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${http_parser_INCLUDE_DIRS}) ++ list(APPEND LIBGIT2_SYSTEM_LIBS ${http_parser_LIBRARIES}) + list(APPEND LIBGIT2_PC_LIBS "-lhttp_parser") + add_feature_info(http-parser ON "http-parser support (system)") + else() +diff --git a/cmake/SelectSSH.cmake b/cmake/SelectSSH.cmake +index 23dfc97..a094cc7 100644 +--- a/cmake/SelectSSH.cmake ++++ b/cmake/SelectSSH.cmake +@@ -1,13 +1,10 @@ + # Optional external dependency: libssh2 + if(USE_SSH) +- find_pkglibraries(LIBSSH2 libssh2) +- if(NOT LIBSSH2_FOUND) +- find_package(LibSSH2) +- set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR}) +- get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY) +- set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY}) +- set(LIBSSH2_LDFLAGS "-lssh2") +- endif() ++ FIND_PACKAGE(Libssh2 REQUIRED) ++ SET(LIBSSH2_FOUND ON) ++ SET(LIBSSH2_INCLUDE_DIRS ${Libssh2_INCLUDE_DIRS}) ++ SET(LIBSSH2_LIBRARIES ${Libssh2_LIBRARIES}) ++ SET(LIBSSH2_LIBRARY_DIRS ${Libssh2_LIB_DIRS}) + + if(NOT LIBSSH2_FOUND) + message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.") diff --git a/recipes/libgit2/all/test_package/CMakeLists.txt b/recipes/libgit2/all/test_package/CMakeLists.txt index 196188113685c..912bdc647f324 100644 --- a/recipes/libgit2/all/test_package/CMakeLists.txt +++ b/recipes/libgit2/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +find_package(libgit2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libgit2::libgit2) diff --git a/recipes/libgit2/all/test_package/conanfile.py b/recipes/libgit2/all/test_package/conanfile.py index bd7165a553cf4..38f4483872d47 100644 --- a/recipes/libgit2/all/test_package/conanfile.py +++ b/recipes/libgit2/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libgit2/all/test_package/test_package.c b/recipes/libgit2/all/test_package/test_package.c new file mode 100644 index 0000000000000..96e8eda89c73b --- /dev/null +++ b/recipes/libgit2/all/test_package/test_package.c @@ -0,0 +1,34 @@ +#include + +#include + +int main() +{ + git_libgit2_init(); + int versionMajor, versionMinor, versionRev; + git_libgit2_version(&versionMajor, &versionMinor, &versionRev); + + printf("libgit2 v%i.%i.%i\n", versionMajor, versionMinor, versionRev); + + printf("Compile Features:\n"); + + int features = git_libgit2_features(); + + if (features & GIT_FEATURE_THREADS) + printf(" - Thread safe\n"); + else + printf(" - Single thread only\n"); + + if (features & GIT_FEATURE_HTTPS) + printf(" - TLS (openssl, mbedtls, winhttp or security)\n"); + else + printf(" - No TLS\n"); + + if (features & GIT_FEATURE_SSH) + printf(" - SSH (libssh2)\n"); + else + printf(" - No SSH support\n"); + + git_libgit2_shutdown(); + return 0; +} diff --git a/recipes/libgit2/all/test_package/test_package.cpp b/recipes/libgit2/all/test_package/test_package.cpp deleted file mode 100644 index 8e7504a8338a1..0000000000000 --- a/recipes/libgit2/all/test_package/test_package.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "git2.h" - -#include -#include - -int main() -{ - git_libgit2_init(); - int versionMajor, versionMinor, versionRev; - git_libgit2_version(&versionMajor, &versionMinor, &versionRev); - - std::cout << "libgit2 v" << versionMajor << "." << versionMinor << "." << versionRev << std::endl; - - std::cout << "Compile Features:" << std::endl; - - int features = git_libgit2_features(); - - if (features & GIT_FEATURE_THREADS) - std::cout << " - Thread safe" << std::endl; - else - std::cout << " - Single thread only" << std::endl; - - if (features & GIT_FEATURE_HTTPS) - std::cout << " - TLS (openssl, mbedtls, winhttp or security)" << std::endl; - else - std::cout << " - No TLS" << std::endl; - - if (features & GIT_FEATURE_SSH) - std::cout << " - SSH (libssh2)" << std::endl; - else - std::cout << " - No SSH support" << std::endl; - - git_libgit2_shutdown(); - return EXIT_SUCCESS; -} diff --git a/recipes/libgit2/config.yml b/recipes/libgit2/config.yml index 94f9d4e154744..c472349adb3cc 100644 --- a/recipes/libgit2/config.yml +++ b/recipes/libgit2/config.yml @@ -1,13 +1,17 @@ versions: - "1.1.0": + "1.5.0": + folder: "all" + "1.4.3": + folder: "all" + "1.3.0": + folder: "all" + "1.2.0": + folder: "all" + "1.1.1": folder: "all" "1.0.1": folder: "all" "0.28.5": folder: "0.28.x" - "0.28.3": - folder: "0.28.x" "0.27.10": folder: "0.27.x" - "0.27.9": - folder: "0.27.x" diff --git a/recipes/libglvnd/all/conandata.yml b/recipes/libglvnd/all/conandata.yml new file mode 100644 index 0000000000000..930441157c427 --- /dev/null +++ b/recipes/libglvnd/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.5.0": + url: "https://gitlab.freedesktop.org/glvnd/libglvnd/-/archive/v1.5.0/libglvnd-v1.5.0.tar.gz" + sha256: "8c246d573bdaabbab32874befa79c8b92b12c05d3eb4bbefbe62afa630842793" + "1.4.0": + url: "https://gitlab.freedesktop.org/glvnd/libglvnd/uploads/ca5bf4295beb39bb324f692c481ac8a1/libglvnd-1.4.0.tar.gz" + sha256: "c4a884503d2412dc1fa209613aa8a77193aeb7065b823fe1775dc8b6f3e45211" diff --git a/recipes/libglvnd/all/conanfile.py b/recipes/libglvnd/all/conanfile.py new file mode 100644 index 0000000000000..7d1919c184d04 --- /dev/null +++ b/recipes/libglvnd/all/conanfile.py @@ -0,0 +1,166 @@ +from conan import ConanFile +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.files import get, rmdir, save +from conan.errors import ConanInvalidConfiguration +from conan.tools.layout import basic_layout +import os +import textwrap + +required_conan_version = ">=1.50.0" + +class LibGlvndConan(ConanFile): + name = "libglvnd" + description = "The GL Vendor-Neutral Dispatch library" + license = "LicenseRef-LICENSE" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gitlab.freedesktop.org/glvnd/libglvnd" + topics = ("gl", "vendor-neutral", "dispatch") + settings = "os", "arch", "compiler", "build_type" + options = { + "asm": [True, False], + "x11": [True, False], + "egl": [True, False], + "glx": [True, False], + "gles1": [True, False], + "gles2": [True, False], + "tls": [True, False], + "dispatch_tls": [True, False], + "headers": [True, False], + "entrypoint_patching": [True, False], + } + default_options = { + "asm" : True, + "x11": True, + "egl": True, + "glx": True, + "gles1": True, + "gles2": True, + "tls": True, + "dispatch_tls": True, + "headers": True, + "entrypoint_patching": True, + } + + generators = "PkgConfigDeps" + + # don't use self.settings_build + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + # don't use self.user_info_build + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + if self.options.x11: + self.requires("xorg/system") + if self.options.glx: + self.requires("xorg-proto/2022.2") + + def validate(self): + if self.settings.os not in ['Linux', 'FreeBSD']: + raise ConanInvalidConfiguration("libglvnd is only compatible with Linux and FreeBSD") + + def build_requirements(self): + self.build_requires("meson/0.63.2") + self.build_requires("pkgconf/1.9.3") + + def layout(self): + basic_layout(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + strip_root=True) + + def generate(self): + tc = MesonToolchain(self) + tc.project_options["asm"] = "enabled" if self.options.asm else "disabled" + tc.project_options["x11"] = "enabled" if self.options.x11 else "disabled" + tc.project_options["egl"] = self.options.egl + tc.project_options["glx"] = "enabled" if self.options.glx else "disabled" + tc.project_options["gles1"] = self.options.gles1 + tc.project_options["gles2"] = self.options.gles2 + tc.project_options["tls"] = self.options.tls + tc.project_options["dispatch-tls"] = self.options.dispatch_tls + tc.project_options["headers"] = self.options.headers + tc.project_options["entrypoint-patching"] = "enabled" if self.options.entrypoint_patching else "disabled" + tc.project_options["libdir"] = "lib" + tc.generate() + + def build(self): + meson = Meson(self) + meson.configure() + meson.build() + + def package(self): + meson = Meson(self) + meson.install() + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), textwrap.dedent('''\ + Copyright (c) 2013, NVIDIA CORPORATION. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and/or associated documentation files (the + "Materials"), to deal in the Materials without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Materials, and to + permit persons to whom the Materials are furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + unaltered in all copies or substantial portions of the Materials. + Any additions, deletions, or changes to the original source files + must be clearly indicated in accompanying documentation. + + THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + ''')) + + def package_info(self): + self.cpp_info.components['gldispatch'].libs = ["GLdispatch"] + self.cpp_info.components['gldispatch'].system_libs.extend(["pthread", "dl"]) + + self.cpp_info.components['opengl'].libs = ["OpenGL"] + self.cpp_info.components['opengl'].requires.extend(["gldispatch"]) + self.cpp_info.components['opengl'].set_property("pkg_config_name", "opengl") + + if self.options.egl: + self.cpp_info.components['egl'].libs = ["EGL"] + self.cpp_info.components['egl'].system_libs.extend(["pthread", "dl", "m"]) + self.cpp_info.components['egl'].requires.extend(["xorg::x11", "gldispatch"]) + self.cpp_info.components['egl'].set_property("pkg_config_name", "egl") + + if self.options.glx: + self.cpp_info.components['glx'].libs = ["GLX"] + self.cpp_info.components['glx'].system_libs.extend(["dl"]) + self.cpp_info.components['glx'].requires.extend(["xorg::x11", "xorg-proto::glproto", "gldispatch"]) + self.cpp_info.components['glx'].set_property("pkg_config_name", "glx") + + self.cpp_info.components['gl'].libs = ["GL"] + self.cpp_info.components['gl'].system_libs.extend(["dl"]) + self.cpp_info.components['gl'].requires.extend(["xorg::x11", "glx", "gldispatch"]) + self.cpp_info.components['gl'].set_property("pkg_config_name", "gl") + + if self.options.gles1: + self.cpp_info.components['gles1'].libs = ["GLESv1_CM"] + self.cpp_info.components['gles1'].requires.extend(["gldispatch"]) + self.cpp_info.components['gles1'].set_property("pkg_config_name", "glesv1_cm") + + if self.options.gles2: + self.cpp_info.components['gles2'].libs = ["GLESv2"] + self.cpp_info.components['gles2'].requires.extend(["gldispatch"]) + self.cpp_info.components['gles2'].set_property("pkg_config_name", "glesv2") diff --git a/recipes/libglvnd/all/test_package/CMakeLists.txt b/recipes/libglvnd/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..34af13462f44f --- /dev/null +++ b/recipes/libglvnd/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libglvnd/all/test_package/conanfile.py b/recipes/libglvnd/all/test_package/conanfile.py new file mode 100644 index 0000000000000..8b7f471a280d5 --- /dev/null +++ b/recipes/libglvnd/all/test_package/conanfile.py @@ -0,0 +1,19 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conans import CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libglvnd/all/test_package/test_package.c b/recipes/libglvnd/all/test_package/test_package.c new file mode 100644 index 0000000000000..7da8b927f842e --- /dev/null +++ b/recipes/libglvnd/all/test_package/test_package.c @@ -0,0 +1,17 @@ +#include + +#include + + +int main() +{ + const char * gl_vendor = (const char *) glGetString(GL_VENDOR); + const char * gl_renderer = (const char *) glGetString(GL_RENDERER); + const char * gl_version = (const char *) glGetString(GL_VERSION); + const char * gl_extensions = (const char *) glGetString(GL_EXTENSIONS); + printf( "GL_VENDOR: %s\n", gl_vendor ? gl_vendor : "(null)"); + printf( "GL_RENDERER: %s\n", gl_renderer ? gl_renderer : "(null)"); + printf( "GL_VERSION: %s\n", gl_version ? gl_version : "(null)"); + printf( "GL_EXTENSIONS: %s\n", gl_extensions ? gl_extensions : "(null)"); + return 0; +} diff --git a/recipes/libglvnd/config.yml b/recipes/libglvnd/config.yml new file mode 100644 index 0000000000000..bd6887e2cfe66 --- /dev/null +++ b/recipes/libglvnd/config.yml @@ -0,0 +1,5 @@ +versions: + "1.5.0": + folder: "all" + "1.4.0": + folder: "all" diff --git a/recipes/libgpg-error/all/conandata.yml b/recipes/libgpg-error/all/conandata.yml new file mode 100644 index 0000000000000..0de00e71015c7 --- /dev/null +++ b/recipes/libgpg-error/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.36": + url: "https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.36.tar.gz" + sha256: "493a3a5e0ac0eb4df8501039f351459d8901d213a834d8c5a453a8ed94858ba5" +patches: + "1.36": + - patch_file: "patches/0001-gawk-namespace.patch" + base_path: "source_subfolder" diff --git a/recipes/libgpg-error/all/conanfile.py b/recipes/libgpg-error/all/conanfile.py new file mode 100644 index 0000000000000..4563b0659c508 --- /dev/null +++ b/recipes/libgpg-error/all/conanfile.py @@ -0,0 +1,85 @@ +import os +from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + +class GPGErrorConan(ConanFile): + name = "libgpg-error" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gnupg.org/software/libgpg-error/index.html" + topics = ("gpg", "gnupg", "encrypt", "pgp", "openpgp") + description = "Libgpg-error is a small library that originally defined common error values for all GnuPG " \ + "components." + license = "GPL-2.0-or-later" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + exports_sources = "patches/**" + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("This recipe only support Linux. You can contribute Windows and/or Macos support.") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure(self): + if self._autotools: + return self._autotools + host = None + args = ["--disable-dependency-tracking", + "--disable-nls", + "--disable-languages", + "--disable-doc", + "--disable-tests"] + if self.options.get_safe("fPIC", True): + args.append("--with-pic") + if self.options.shared: + args.extend(["--disable-static", "--enable-shared"]) + else: + args.extend(["--disable-shared", "--enable-static"]) + if self.settings.os == "Linux" and self.settings.arch == "x86": + host = "i686-linux-gnu" + + self._autotools = AutoToolsBuildEnvironment(self) + self._autotools.configure(args=args, host=host, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + env_build = self._configure() + env_build.make() + + def package(self): + env_build = self._configure() + env_build.install() + self.copy(pattern="COPYING*", dst="licenses", src=self._source_subfolder) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*la") + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["gpg-error"] + self.cpp_info.names["pkg_config"] = "gpg-error" + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["pthread"] diff --git a/recipes/libgpg-error/all/patches/0001-gawk-namespace.patch b/recipes/libgpg-error/all/patches/0001-gawk-namespace.patch new file mode 100644 index 0000000000000..a9e25cf6acf3f --- /dev/null +++ b/recipes/libgpg-error/all/patches/0001-gawk-namespace.patch @@ -0,0 +1,53 @@ +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -293,7 +293,7 @@ + + errnos-sym.h: Makefile mkstrtable.awk errnos.in + $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \ +- -v prefix=GPG_ERR_ -v namespace=errnos_ \ ++ -v prefix=GPG_ERR_ -v pkg_namespace=errnos_ \ + $(srcdir)/errnos.in >$@ + + + +--- a/src/Makefile.in ++++ b/src/Makefile.in +@@ -1615,7 +1615,7 @@ + + errnos-sym.h: Makefile mkstrtable.awk errnos.in + $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \ +- -v prefix=GPG_ERR_ -v namespace=errnos_ \ ++ -v prefix=GPG_ERR_ -v pkg_namespace=errnos_ \ + $(srcdir)/errnos.in >$@ + + mkheader$(EXEEXT_FOR_BUILD): mkheader.c Makefile +diff --color -Naur libgpg-error-1.36/src/mkstrtable.awk libgpg-error-1.36.new/src/mkstrtable.awk +--- a/src/mkstrtable.awk ++++ b/src/mkstrtable.awk +@@ -102,7 +102,7 @@ + print "/* The purpose of this complex string table is to produce"; + print " optimal code with a minimum of relocations. */"; + print ""; +- print "static const char " namespace "msgstr[] = "; ++ print "static const char " pkg_namespace "msgstr[] = "; + header = 0; + } + else +@@ -150,7 +150,7 @@ + else + print " gettext_noop (\"" last_msgstr "\");"; + print ""; +- print "static const int " namespace "msgidx[] ="; ++ print "static const int " pkg_namespace "msgidx[] ="; + print " {"; + for (i = 0; i < coded_msgs; i++) + print " " pos[i] ","; +@@ -158,7 +158,7 @@ + print " };"; + print ""; + print "static GPG_ERR_INLINE int"; +- print namespace "msgidxof (int code)"; ++ print pkg_namespace "msgidxof (int code)"; + print "{"; + print " return (0 ? 0"; + diff --git a/recipes/libgpg-error/all/test_package/CMakeLists.txt b/recipes/libgpg-error/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b9b613cbb24a --- /dev/null +++ b/recipes/libgpg-error/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/cpp-peglib/all/test_package/conanfile.py b/recipes/libgpg-error/all/test_package/conanfile.py similarity index 100% rename from recipes/cpp-peglib/all/test_package/conanfile.py rename to recipes/libgpg-error/all/test_package/conanfile.py diff --git a/recipes/libgpg-error/all/test_package/test_package.c b/recipes/libgpg-error/all/test_package/test_package.c new file mode 100644 index 0000000000000..241b49be7ac6d --- /dev/null +++ b/recipes/libgpg-error/all/test_package/test_package.c @@ -0,0 +1,6 @@ +#include "gpg-error.h" + +int main() { + gpgrt_printf(""); + return 0; +} diff --git a/recipes/libgpg-error/config.yml b/recipes/libgpg-error/config.yml new file mode 100644 index 0000000000000..f10713a7746e2 --- /dev/null +++ b/recipes/libgpg-error/config.yml @@ -0,0 +1,3 @@ +versions: + "1.36": + folder: all diff --git a/recipes/libgphoto2/all/conandata.yml b/recipes/libgphoto2/all/conandata.yml new file mode 100644 index 0000000000000..3e782abceeccf --- /dev/null +++ b/recipes/libgphoto2/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "2.5.27": + url: "https://github.com/gphoto/libgphoto2/releases/download/v2.5.27/libgphoto2-2.5.27.tar.xz" + sha256: "a7253bd18c6ef65352150ac36a668f883a5ad2634eb6455b3ca9aa6ac98d0073" +patches: + "2.5.27": + - patch_file: patches/macos_snprintf_patch.diff + base_path: source_subfolder diff --git a/recipes/libgphoto2/all/conanfile.py b/recipes/libgphoto2/all/conanfile.py new file mode 100644 index 0000000000000..7ea125f2cf4d0 --- /dev/null +++ b/recipes/libgphoto2/all/conanfile.py @@ -0,0 +1,134 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conans.errors import ConanInvalidConfiguration +import contextlib +import os + +required_conan_version = ">=1.33.0" + + +class LibGphoto2(ConanFile): + name = "libgphoto2" + url = "https://github.com/conan-io/conan-center-index" + description = "The libgphoto2 camera access and control library." + homepage = "http://www.gphoto.org/" + license = "LGPL-2.1" + topics = ("gphoto2", "libgphoto2", "libgphoto", "photo") + exports_sources = "patches/*" + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_libusb": [True, False], + "with_libcurl": [True, False], + "with_libxml2": [True, False], + "with_libexif": [True, False], + "with_libjpeg": [True, False], + } + default_options = { + "shared": True, + "fPIC": True, + "with_libusb": True, + "with_libcurl": True, + "with_libxml2": True, + "with_libexif": True, + "with_libjpeg": True, + } + generators = "pkg_config" + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def validate(self): + if not self.options.shared: + raise ConanInvalidConfiguration("building libgphoto2 as a static library is not supported") + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("libgphoto2 does not support Windows") + + @contextlib.contextmanager + def _build_context(self): + if self.settings.os == "Linux" and not self.options["libtool"].shared: + env = { + "LIBLTDL": "-lltdl -ldl", + } + with tools.environment_append(env): + yield + else: + yield + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def build_requirements(self): + self.build_requires("pkgconf/1.7.4") + + def requirements(self): + self.requires("libtool/2.4.6") + if self.options.with_libusb: + self.requires("libusb/1.0.26") + if self.options.with_libcurl: + self.requires("libcurl/7.83.1") + if self.options.with_libxml2: + self.requires("libxml2/2.9.14") + if self.options.with_libexif: + self.requires("libexif/0.6.23") + if self.options.with_libjpeg: + self.requires("libjpeg/9d") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self) + self._autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" + auto_no = lambda v: "auto" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--with-libcurl={}".format(auto_no(self.options.with_libcurl)), + "--with-libexif={}".format(auto_no(self.options.with_libexif)), + "--with-libxml-2.0={}".format(auto_no(self.options.with_libxml2)), + "--disable-nls", + "--datadir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), + "udevscriptdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), + "utilsdir={}".format(tools.unix_path(os.path.join(self.package_folder, "bin"))), + ] + if not self.options.with_libjpeg: + args.append("--without-jpeg") + self._autotools.configure(args=args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + self._patch_sources() + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + tools.remove_files_by_mask(self.package_folder, "*.la") + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["gphoto2", "gphoto2_port"] + self.cpp_info.names["pkg_config"] = "libgphoto2" + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["dl"] + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs = ["m"] + diff --git a/recipes/libgphoto2/all/patches/macos_snprintf_patch.diff b/recipes/libgphoto2/all/patches/macos_snprintf_patch.diff new file mode 100644 index 0000000000000..b3dd8d4275c0c --- /dev/null +++ b/recipes/libgphoto2/all/patches/macos_snprintf_patch.diff @@ -0,0 +1,12 @@ +diff --git a/libgphoto2_port/libusb1/libusb1.c b/libgphoto2_port/libusb1/libusb1.c +index d3da30f..1342855 100644 +--- a/libgphoto2_port/libusb1/libusb1.c ++++ b/libgphoto2_port/libusb1/libusb1.c +@@ -20,6 +20,7 @@ + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ ++#define _DARWIN_C_SOURCE + #include "config.h" + #include + diff --git a/recipes/libgphoto2/all/test_package/CMakeLists.txt b/recipes/libgphoto2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..45b8296270d6c --- /dev/null +++ b/recipes/libgphoto2/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libgphoto2 REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libgphoto2::libgphoto2) + diff --git a/recipes/libgphoto2/all/test_package/conanfile.py b/recipes/libgphoto2/all/test_package/conanfile.py new file mode 100644 index 0000000000000..76403a7b181c1 --- /dev/null +++ b/recipes/libgphoto2/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + diff --git a/recipes/libgphoto2/all/test_package/test_package.c b/recipes/libgphoto2/all/test_package/test_package.c new file mode 100644 index 0000000000000..8b5a94ec8ca77 --- /dev/null +++ b/recipes/libgphoto2/all/test_package/test_package.c @@ -0,0 +1,27 @@ +#include +#include + +int main() { + GPContext* context; + CameraAbilitiesList* list; + Camera* camera; + int ret; + + context = gp_context_new(); + ret = gp_abilities_list_new(&list); + if (ret != GP_OK) { + return 1; + } + ret = gp_abilities_list_load(list, context); + if (ret != GP_OK) { + return 1; + } + int count = gp_abilities_list_count(list); + if (count == 0) { + return 1; + } + gp_camera_new(&camera); + gp_camera_free(camera); + gp_abilities_list_free(list); + return 0; +} diff --git a/recipes/libgphoto2/config.yml b/recipes/libgphoto2/config.yml new file mode 100644 index 0000000000000..5139145403d46 --- /dev/null +++ b/recipes/libgphoto2/config.yml @@ -0,0 +1,3 @@ +versions: + "2.5.27": + folder: all diff --git a/recipes/libgpiod/all/conandata.yml b/recipes/libgpiod/all/conandata.yml new file mode 100644 index 0000000000000..851ae98da0f81 --- /dev/null +++ b/recipes/libgpiod/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.6.3": + url: "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-1.6.3.tar.gz" + sha256: "eb446070be1444fd7d32d32bbca53c2f3bbb0a21193db86198cf6050b7a28441" diff --git a/recipes/libgpiod/all/conanfile.py b/recipes/libgpiod/all/conanfile.py new file mode 100644 index 0000000000000..99787ae3af1c0 --- /dev/null +++ b/recipes/libgpiod/all/conanfile.py @@ -0,0 +1,87 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + +class LibgpiodConan(ConanFile): + name = "libgpiod" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/" + license = "LGPL-2.1-or-later" + description = "C library and tools for interacting with the linux GPIO character device" + topics = ("gpio", "libgpiod", "libgpiodcxx", "linux") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "enable_bindings_cxx": [True, False], + "enable_tools": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "enable_bindings_cxx": False, + "enable_tools": False, + } + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("libgpiod supports only Linux") + + def configure(self): + if self.options.shared: + del self.options.fPIC + if not self.options.enable_bindings_cxx: + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def build_requirements(self): + self.build_requires("libtool/2.4.6") + self.build_requires("pkgconf/1.7.4") + self.build_requires("autoconf-archive/2021.02.19") + self.build_requires("linux-headers-generic/5.13.9") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self) + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-bindings-cxx={}".format(yes_no(self.options.enable_bindings_cxx)), + "--enable-tools={}".format(yes_no(self.options.enable_tools)), + ] + self._autotools.configure(args=args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + with tools.chdir(os.path.join(self._source_subfolder)): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), run_environment=True) + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + autotools = self._configure_autotools() + autotools.install() + tools.remove_files_by_mask(self.package_folder, "*.la") + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.components["gpiod"].libs = ["gpiod"] + self.cpp_info.components["gpiod"].names["pkg_config"] = "gpiod" + if self.options.enable_bindings_cxx: + self.cpp_info.components["gpiodcxx"].libs = ["gpiodcxx"] + self.cpp_info.components["gpiodcxx"].names["pkg_config"] = "gpiodcxx" + self.cpp_info.components["gpiodcxx"].requires = ["gpiod"] diff --git a/recipes/libgpiod/all/test_package/CMakeLists.txt b/recipes/libgpiod/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a5ffd526aaea7 --- /dev/null +++ b/recipes/libgpiod/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${CMAKE_PROJECT_NAME} test_package.c) +target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libgpiod/all/test_package/conanfile.py b/recipes/libgpiod/all/test_package/conanfile.py new file mode 100644 index 0000000000000..db57f3bb0d17f --- /dev/null +++ b/recipes/libgpiod/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.33.0" + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libgpiod/all/test_package/test_package.c b/recipes/libgpiod/all/test_package/test_package.c new file mode 100644 index 0000000000000..686dc9682cd7d --- /dev/null +++ b/recipes/libgpiod/all/test_package/test_package.c @@ -0,0 +1,7 @@ +#include "gpiod.h" + +int main(int argc, char *argv[]) { + struct gpiod_chip *chip; + chip = gpiod_chip_open_by_name("gpiochip0"); + return 0; +} diff --git a/recipes/libgpiod/config.yml b/recipes/libgpiod/config.yml new file mode 100644 index 0000000000000..bfd56b0a1b59f --- /dev/null +++ b/recipes/libgpiod/config.yml @@ -0,0 +1,3 @@ +versions: + "1.6.3": + folder: all diff --git a/recipes/libhal/all/conandata.yml b/recipes/libhal/all/conandata.yml new file mode 100644 index 0000000000000..0a5fcff604fbd --- /dev/null +++ b/recipes/libhal/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.0.0": + url: "https://github.com/libhal/libhal/archive/refs/tags/0.0.0.tar.gz" + sha256: "f49d6cee9adfe9d98212ba77aa955c88994693185d4870b86a6e12bad4eb9915" diff --git a/recipes/libhal/all/conanfile.py b/recipes/libhal/all/conanfile.py new file mode 100644 index 0000000000000..c9f4762f7af23 --- /dev/null +++ b/recipes/libhal/all/conanfile.py @@ -0,0 +1,77 @@ +from conan import ConanFile +from conan.tools.files import get, copy +from conan.tools.layout import basic_layout +from conan.tools.build import check_min_cppstd +from conan.errors import ConanInvalidConfiguration +import os + + +required_conan_version = ">=1.50.0" + + +class LibHALConan(ConanFile): + name = "libhal" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://libhal.github.io/libhal" + description = ("A collection of interfaces and abstractions for embedded " + "peripherals and devices using modern C++") + topics = ("peripherals", "hardware", "abstraction", "devices", "hal") + settings = "os", "compiler", "arch", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + @property + def _min_cppstd(self): + return "20" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "11", + "Visual Studio": "17", + "msvc": "193", + "clang": "13", + "apple-clang": "13.1.6" + } + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._min_cppstd) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + compiler = str(self.settings.compiler) + version = str(self.settings.compiler.version) + minimum_version = self._compilers_minimum_version.get(compiler, False) + + if minimum_version and lazy_lt_semver(version, minimum_version): + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler ({compiler}-{version}) does not support") + + def layout(self): + basic_layout(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def package(self): + copy(self, "LICENSE", dst=os.path.join( + self.package_folder, "licenses"), src=self.source_folder) + copy(self, "*.h", dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include")) + copy(self, "*.hpp", dst=os.path.join(self.package_folder, + "include"), src=os.path.join(self.source_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/libhal/all/test_package/CMakeLists.txt b/recipes/libhal/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e2cd1b5424ba3 --- /dev/null +++ b/recipes/libhal/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) + +find_package(libhal REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} main.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF) +target_link_libraries(${PROJECT_NAME} PRIVATE libhal::libhal) diff --git a/recipes/libhal/all/test_package/conanfile.py b/recipes/libhal/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/libhal/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libhal/all/test_package/main.cpp b/recipes/libhal/all/test_package/main.cpp new file mode 100644 index 0000000000000..4fb5e3cdcdfd4 --- /dev/null +++ b/recipes/libhal/all/test_package/main.cpp @@ -0,0 +1,30 @@ +#include + +#include +#include + +class test_pwm : public hal::pwm +{ +private: + hal::status driver_frequency(hal::hertz p_frequency) noexcept override + { + std::printf("frequency = %f Hz\n", p_frequency); + return {}; + } + hal::status driver_duty_cycle(hal::percentage p_position) noexcept override + { + std::printf("duty cycle = %f %%\n", p_position.value()); + return {}; + } +}; + +int main() +{ + test_pwm pwm; + auto rc_servo = hal::rc_servo::create(pwm).value(); + rc_servo.position(0.25).value(); + rc_servo.position(0.50).value(); + rc_servo.position(-0.25).value(); + rc_servo.position(-1.0).value(); + return 0; +} diff --git a/recipes/libhal/all/test_v1_package/CMakeLists.txt b/recipes/libhal/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0c60d16c7a716 --- /dev/null +++ b/recipes/libhal/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libhal REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/main.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF) +target_link_libraries(${PROJECT_NAME} PRIVATE libhal::libhal) diff --git a/recipes/libhal/all/test_v1_package/conanfile.py b/recipes/libhal/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..6adc2a597302e --- /dev/null +++ b/recipes/libhal/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class LibhalTestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = ("cmake", "cmake_find_package_multi") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if cross_building(self): + bin_path = os.path.join(self.build_folder, "bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libhal/config.yml b/recipes/libhal/config.yml new file mode 100644 index 0000000000000..ecbb76a96ea8d --- /dev/null +++ b/recipes/libhal/config.yml @@ -0,0 +1,3 @@ +versions: + "0.0.0": + folder: "all" diff --git a/recipes/libharu/all/CMakeLists.txt b/recipes/libharu/all/CMakeLists.txt deleted file mode 100644 index bd3083b512cb9..0000000000000 --- a/recipes/libharu/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/libharu/all/conandata.yml b/recipes/libharu/all/conandata.yml index cf40383d113bd..29a286d695d61 100644 --- a/recipes/libharu/all/conandata.yml +++ b/recipes/libharu/all/conandata.yml @@ -1,12 +1,18 @@ sources: + "2.4.3": + url: "https://github.com/libharu/libharu/archive/refs/tags/v2.4.3.tar.gz" + sha256: "a2c3ae4261504a0fda25b09e7babe5df02b21803dd1308fdf105588f7589d255" "2.3.0": url: "https://github.com/libharu/libharu/archive/RELEASE_2_3_0.tar.gz" sha256: "8f9e68cc5d5f7d53d1bc61a1ed876add1faf4f91070dbc360d8b259f46d9a4d2" patches: "2.3.0": - - base_path: "source_subfolder" - patch_file: "patches/0001-allow-cmake-subproject.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-linux-add-m-system-library.patch" - - base_path: "source_subfolder" - patch_file: "patches/0003-rename-tiff-symbols.patch" + - patch_file: "patches/0001-allow-cmake-subproject.patch" + patch_type: "conan" + patch_description: "Allow cmake subproject" + - patch_file: "patches/0002-linux-add-m-system-library.patch" + patch_type: "conan" + patch_description: "Linux: add m system library" + - patch_file: "patches/0003-rename-tiff-symbols.patch" + patch_type: "conan" + patch_description: "Rename TIFF symbols" diff --git a/recipes/libharu/all/conanfile.py b/recipes/libharu/all/conanfile.py index 312691483a507..84bfc9b3fd36d 100644 --- a/recipes/libharu/all/conanfile.py +++ b/recipes/libharu/all/conanfile.py @@ -1,18 +1,25 @@ -from conans import CMake, ConanFile, tools +from conan import ConanFile +from conan.tools.microsoft import is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir, load, save +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout import os import re -required_conan_version = ">=1.33.0" + +required_conan_version = ">=1.53.0" + + class LibharuConan(ConanFile): name = "libharu" description = "Haru is a free, cross platform, open-sourced software library for generating PDF." - topics = ("conan", "libharu", "pdf", "generate", "generator") - license = "ZLIB" + topics = "pdf", "generate", "generator" + license = "Zlib" homepage = "http://libharu.org/" url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" - exports_sources = "CMakeLists.txt", "patches/**" options = { "shared": [True, False], "fPIC": [True, False], @@ -21,17 +28,9 @@ class LibharuConan(ConanFile): "shared": False, "fPIC": True, } - generators = "cmake", "cmake_find_package" - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -39,53 +38,68 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + # src_folder must use the same source folder name the project + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("zlib/1.2.11") - self.requires("libpng/1.6.37") + self.requires("zlib/1.2.13") + self.requires("libpng/1.6.38") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["LIBHPDF_SHARED"] = self.options.shared - self._cmake.definitions["LIBHPDF_STATIC"] = not self.options.shared - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBHPDF_SHARED"] = self.options.shared + tc.variables["LIBHPDF_STATIC"] = not self.options.shared + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + tc = CMakeDeps(self) + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _extract_license(self): - readme = tools.load(os.path.join(self._source_subfolder, "README")) + def _v230_extract_license(self): + readme = load(save, os.path.join(self.source_folder, "README")) match = next(re.finditer("\n[^\n]*license[^\n]*\n", readme, flags=re.I | re.A)) return readme[match.span()[1]:].strip("*").strip() def package(self): - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - for fn in ("CHANGES", "INSTALL", "README"): - os.unlink(os.path.join(self.package_folder, fn)) - tools.rmdir(os.path.join(self.package_folder, "if")) - tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license()) + if Version(self.version) == "2.3.0": + rm(self, "CHANGES", os.path.join(self.package_folder)) + rm(self, "INSTALL", os.path.join(self.package_folder)) + rm(self, "README", os.path.join(self.package_folder)) + + rmdir(self, os.path.join(self.package_folder, "if")) + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._v230_extract_license()) + else: + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - libprefix = "lib" if self.settings.compiler == "Visual Studio" else "" - libsuffix = "{}{}".format("" if self.options.shared else "s", - "d" if self.settings.compiler == "Visual Studio" and self.settings.build_type == "Debug" else "") - self.cpp_info.libs = ["{}hpdf{}".format(libprefix, libsuffix)] + libprefix = "" + libsuffix = "" + if Version(self.version) == "2.3.0": + libprefix = "lib" if is_msvc(self) else "" + libsuffix = "{}{}".format( + "" if self.options.shared else "s", + "d" if is_msvc(self) and self.settings.build_type == "Debug" else "", + ) + self.cpp_info.libs = [f"{libprefix}hpdf{libsuffix}"] if self.settings.os == "Windows" and self.options.shared: self.cpp_info.defines = ["HPDF_DLL"] - if self.settings.os == "Linux" and not self.options.shared: + if self.settings.os in ["Linux", "FreeBSD"] and not self.options.shared: self.cpp_info.system_libs = ["m"] diff --git a/recipes/libharu/all/patches/0001-allow-cmake-subproject.patch b/recipes/libharu/all/patches/0001-allow-cmake-subproject.patch index 38b588f111044..2f042378b59fd 100644 --- a/recipes/libharu/all/patches/0001-allow-cmake-subproject.patch +++ b/recipes/libharu/all/patches/0001-allow-cmake-subproject.patch @@ -1,15 +1,25 @@ --- CMakeLists.txt +++ CMakeLists.txt -@@ -35,7 +35,7 @@ - cmake_minimum_required(VERSION 2.4.8 FATAL_ERROR) +@@ -1,3 +1,5 @@ ++cmake_minimum_required(VERSION 3.10) ++ + # CMakeLists.txt + # + # Copyright (C) 2008 Werner Smekal +@@ -31,11 +33,8 @@ + set(LIBHPDF_DESCRIPTION "libHaru is a free, cross platform, open source library for generating PDF files.") + set(LIBHPDF_PACKAGE_NAME "libHaru-${LIBHPDF_VERSION}-${COMPILER_LABEL}") +-# we want cmake version 2.4.8 at least +-cmake_minimum_required(VERSION 2.4.8 FATAL_ERROR) +- # Location where the haru cmake build system first looks for cmake modules -set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules) # set library name, msvc does not append 'lib' automatically if(MSVC) -@@ -110,7 +110,7 @@ endif(PNG_FOUND) +@@ -110,7 +109,7 @@ if(MSVC_VERSION GREATER 1399) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE) endif(MSVC_VERSION GREATER 1399) @@ -18,7 +28,7 @@ # these are options -@@ -149,16 +149,16 @@ endif (NOT ZLIB_FOUND) +@@ -149,16 +148,16 @@ # create hpdf_config.h configure_file( @@ -40,7 +50,7 @@ ) endif(DEVPAK) # ======================================================================= -@@ -203,7 +203,7 @@ set( +@@ -203,7 +202,7 @@ include/hpdf_pdfa.h include/hpdf_3dmeasure.h include/hpdf_exdata.h @@ -49,7 +59,7 @@ ) # install header files -@@ -215,7 +215,7 @@ if(NOT DEVPAK) +@@ -215,7 +214,7 @@ install(DIRECTORY if DESTINATION .) endif(NOT DEVPAK) if(DEVPAK) diff --git a/recipes/libharu/all/patches/0002-linux-add-m-system-library.patch b/recipes/libharu/all/patches/0002-linux-add-m-system-library.patch index 1ee940b47a2f6..d4baac11198b8 100644 --- a/recipes/libharu/all/patches/0002-linux-add-m-system-library.patch +++ b/recipes/libharu/all/patches/0002-linux-add-m-system-library.patch @@ -1,6 +1,15 @@ --- src/CMakeLists.txt +++ src/CMakeLists.txt -@@ -97,4 +97,7 @@ if(LIBHPDF_SHARED) +@@ -87,7 +88,7 @@ + endif(LIBHPDF_STATIC) + if(LIBHPDF_SHARED) + add_library(${LIBHPDF_NAME} SHARED ${LIBHPDF_SRCS}) +- target_link_libraries(${LIBHPDF_NAME} ${ADDITIONAL_LIBRARIES}) ++ target_link_libraries(${LIBHPDF_NAME} PUBLIC ${ADDITIONAL_LIBRARIES}) + if(WIN32 AND NOT CYGWIN) + set_target_properties(${LIBHPDF_NAME} PROPERTIES DEFINE_SYMBOL HPDF_DLL_MAKE) + endif(WIN32 AND NOT CYGWIN) +@@ -97,4 +98,7 @@ LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) diff --git a/recipes/libharu/all/test_package/CMakeLists.txt b/recipes/libharu/all/test_package/CMakeLists.txt index 3a403dc404b41..b0aef7cdad89b 100644 --- a/recipes/libharu/all/test_package/CMakeLists.txt +++ b/recipes/libharu/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) + project(test_package C) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +find_package(libharu REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libharu::libharu) diff --git a/recipes/libharu/all/test_package/conanfile.py b/recipes/libharu/all/test_package/conanfile.py index 779b26ed2b5ab..470ed63c2164f 100644 --- a/recipes/libharu/all/test_package/conanfile.py +++ b/recipes/libharu/all/test_package/conanfile.py @@ -1,11 +1,21 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanException +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +from conan.errors import ConanException import os +# It will become the standard on Conan 2.x class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,8 +23,8 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") if not os.path.isfile("test.pdf"): raise ConanException("test did not create test.pdf") diff --git a/recipes/libharu/all/test_v1_package/CMakeLists.txt b/recipes/libharu/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/libharu/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libharu/all/test_v1_package/conanfile.py b/recipes/libharu/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..4651d31d881e8 --- /dev/null +++ b/recipes/libharu/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanException +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + if not os.path.isfile("test.pdf"): + raise ConanException("test did not create test.pdf") diff --git a/recipes/libharu/config.yml b/recipes/libharu/config.yml index 33ababb05e322..39ca57fe00f3b 100644 --- a/recipes/libharu/config.yml +++ b/recipes/libharu/config.yml @@ -1,3 +1,5 @@ versions: + "2.4.3": + folder: "all" "2.3.0": folder: "all" diff --git a/recipes/libheif/all/CMakeLists.txt b/recipes/libheif/all/CMakeLists.txt deleted file mode 100644 index 68bfd75fb1882..0000000000000 --- a/recipes/libheif/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include("conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libheif/all/conandata.yml b/recipes/libheif/all/conandata.yml index 47198755997ec..c5668b6d3c93a 100644 --- a/recipes/libheif/all/conandata.yml +++ b/recipes/libheif/all/conandata.yml @@ -1,20 +1,22 @@ sources: - "1.9.1": - sha256: 5f65ca2bd2510eed4e13bdca123131c64067e9dd809213d7aef4dc5e37948bca - url: https://github.com/strukturag/libheif/releases/download/v1.9.1/libheif-1.9.1.tar.gz - "1.11.0": - sha256: c550938f56ff6dac83702251a143f87cb3a6c71a50d8723955290832d9960913 - url: https://github.com/strukturag/libheif/releases/download/v1.11.0/libheif-1.11.0.tar.gz + "1.13.0": + url: "https://github.com/strukturag/libheif/releases/download/v1.13.0/libheif-1.13.0.tar.gz" + sha256: "c20ae01bace39e89298f6352f1ff4a54b415b33b9743902da798e8a1e51d7ca1" "1.12.0": - sha256: e1ac2abb354fdc8ccdca71363ebad7503ad731c84022cf460837f0839e171718 - url: https://github.com/strukturag/libheif/releases/download/v1.12.0/libheif-1.12.0.tar.gz -patches: - "1.9.1": - - base_path: "source_subfolder" - patch_file: "patches/0001-cmake.patch" + url: "https://github.com/strukturag/libheif/releases/download/v1.12.0/libheif-1.12.0.tar.gz" + sha256: "e1ac2abb354fdc8ccdca71363ebad7503ad731c84022cf460837f0839e171718" "1.11.0": - - base_path: "source_subfolder" - patch_file: "patches/0001-cmake_1.11.0.patch" + url: "https://github.com/strukturag/libheif/releases/download/v1.11.0/libheif-1.11.0.tar.gz" + sha256: "c550938f56ff6dac83702251a143f87cb3a6c71a50d8723955290832d9960913" + "1.9.1": + url: "https://github.com/strukturag/libheif/releases/download/v1.9.1/libheif-1.9.1.tar.gz" + sha256: "5f65ca2bd2510eed4e13bdca123131c64067e9dd809213d7aef4dc5e37948bca" +patches: + "1.13.0": + - patch_file: "patches/0001-cmake_1.13.0.patch" "1.12.0": - - base_path: "source_subfolder" - patch_file: "patches/0001-cmake_1.11.0.patch" + - patch_file: "patches/0001-cmake_1.12.0.patch" + "1.11.0": + - patch_file: "patches/0001-cmake_1.11.0.patch" + "1.9.1": + - patch_file: "patches/0001-cmake-1.9.1.patch" diff --git a/recipes/libheif/all/conanfile.py b/recipes/libheif/all/conanfile.py index 03f125167fc89..d70912d7df209 100644 --- a/recipes/libheif/all/conanfile.py +++ b/recipes/libheif/all/conanfile.py @@ -1,121 +1,125 @@ -from conans import ConanFile, tools, CMake +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version +from conans import tools as tools_legacy import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" -class Libheif(ConanFile): +class LibheifConan(ConanFile): name = "libheif" description = "libheif is an HEIF and AVIF file format decoder and encoder." - topics = ("conan", "libheif", "heif", "codec", "video") + topics = ("libheif", "heif", "codec", "video") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/strukturag/libheif" license = ("LGPL-3.0-only", "GPL-3.0-or-later", "MIT") - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], + "with_libde265": [True, False], "with_x265": [True, False], - "with_dav1d": [True, False], "with_libaomav1": [True, False], + "with_dav1d": [True, False], } default_options = { "shared": False, "fPIC": True, + "with_libde265": True, "with_x265": False, - "with_dav1d": False, "with_libaomav1": False, + "with_dav1d": False, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if tools.Version(self.version) < "1.11.0": - # dav1d supported since 1.10.0 but usable option `WITH_DAV1D` - # for controlling support exists only since 1.11.0 - del self.options.with_dav1d def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) - - def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) def requirements(self): - self.requires("libde265/1.0.8") + if self.options.with_libde265: + self.requires("libde265/1.0.8") if self.options.with_x265: self.requires("libx265/3.4") - if self.options.get_safe("with_libaomav1"): - self.requires("libaom-av1/2.0.1") - if self.options.get_safe("with_dav1d"): - self.requires("dav1d/0.8.1") - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["WITH_EXAMPLES"] = False - self._cmake.definitions["WITH_RAV1E"] = False - # x265 - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_X265"] = not self.options.with_x265 - self._cmake.definitions["WITH_X265"] = self.options.with_x265 - # aom - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_LibAOM"] = not self.options.get_safe("with_libaomav1", False) - self._cmake.definitions["WITH_AOM"] = self.options.get_safe("with_libaomav1", False) - # dav1d - self._cmake.definitions["WITH_DAV1D"] = self.options.get_safe("with_dav1d", False) - self._cmake.configure() - return self._cmake + if self.options.with_libaomav1: + self.requires("libaom-av1/3.3.0") + if self.options.with_dav1d: + self.requires("dav1d/1.0.0") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_LIBDE265"] = self.options.with_libde265 + tc.variables["WITH_X265"] = self.options.with_x265 + tc.variables["WITH_AOM"] = self.options.with_libaomav1 + tc.variables["WITH_RAV1E"] = False + tc.variables["WITH_DAV1D"] = self.options.with_dav1d + tc.variables["WITH_EXAMPLES"] = False + if Version(self.version) < "1.11.0": + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "libheif" - self.cpp_info.names["cmake_find_package_multi"] = "libheif" - self.cpp_info.names["pkg_config"] = "libheif" - - self.cpp_info.components["heif"].names["cmake_find_package"] = "heif" - self.cpp_info.components["heif"].names["cmake_find_package_multi"] = "heif" - self.cpp_info.components["heif"].names["pkg_config"] = "libheif" - self.cpp_info.components["heif"].requires = ["libde265::libde265"] + self.cpp_info.set_property("cmake_file_name", "libheif") + self.cpp_info.set_property("cmake_target_name", "libheif::heif") + self.cpp_info.set_property("pkg_config_name", "libheif") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["heif"].libs = ["heif"] + if not self.options.shared: + self.cpp_info.components["heif"].defines = ["LIBHEIF_STATIC_BUILD"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["heif"].system_libs.extend(["m", "pthread"]) + if not self.options.shared: + libcxx = tools_legacy.stdcpp_library(self) + if libcxx: + self.cpp_info.components["heif"].system_libs.append(libcxx) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["heif"].set_property("cmake_target_name", "libheif::heif") + self.cpp_info.components["heif"].set_property("pkg_config_name", "libheif") + self.cpp_info.components["heif"].requires = [] + if self.options.with_libde265: + self.cpp_info.components["heif"].requires.append("libde265::libde265") if self.options.with_x265: self.cpp_info.components["heif"].requires.append("libx265::libx265") - if self.options.get_safe("with_libaomav1"): + if self.options.with_libaomav1: self.cpp_info.components["heif"].requires.append("libaom-av1::libaom-av1") - if self.options.get_safe("with_dav1d"): + if self.options.with_dav1d: self.cpp_info.components["heif"].requires.append("dav1d::dav1d") - - self.cpp_info.components["heif"].libs = ["heif"] - - if not self.options.shared: - self.cpp_info.components["heif"].defines = ["LIBHEIF_STATIC_BUILD"] - if self.settings.os == "Linux": - self.cpp_info.components["heif"].system_libs = ["m", "pthread"] - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.components["heif"].system_libs.append(tools.stdcpp_library(self)) diff --git a/recipes/libheif/all/patches/0001-cmake-1.9.1.patch b/recipes/libheif/all/patches/0001-cmake-1.9.1.patch new file mode 100644 index 0000000000000..65b0f3637413f --- /dev/null +++ b/recipes/libheif/all/patches/0001-cmake-1.9.1.patch @@ -0,0 +1,146 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -34,14 +34,10 @@ if(NOT MSVC) + add_definitions(-Wno-error=deprecated-declarations) + endif() + +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_CXX_STANDARD_REQUIRED ON) +-set(CMAKE_CXX_EXTENSIONS OFF) + + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # Create the compile command database for clang by default + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +@@ -55,10 +51,20 @@ if (has_potentially_evaluated_expression) + endif() + + LIST (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") +-find_package(Libde265 REQUIRED) +-find_package(X265) +-find_package(LibAOM) ++if(WITH_LIBDE265) ++find_package(libde265 REQUIRED CONFIG) ++endif() ++if(WITH_X265) ++find_package(libx265 REQUIRED CONFIG) ++endif() ++if(WITH_AOM) ++find_package(libaom-av1 REQUIRED CONFIG) ++endif() ++if(WITH_DAV1D) ++find_package(dav1d REQUIRED CONFIG) ++endif() + ++if(0) + if (LIBDE265_FOUND) + message("HEIF decoder, libde265: found") + else () +@@ -88,6 +94,7 @@ if (USE_LOCAL_DAV1D) + else () + message("AVIF decoder, use local dav1d: no") + endif () ++endif() + + + # Create libheif pkgconfig file +@@ -128,4 +135,3 @@ if(WITH_EXAMPLES) + add_subdirectory (examples) + endif() + add_subdirectory (libheif) +-add_subdirectory (gdk-pixbuf) +--- a/libheif/CMakeLists.txt ++++ b/libheif/CMakeLists.txt +@@ -59,45 +59,36 @@ target_compile_definitions(heif + LIBHEIF_EXPORTS + HAVE_VISIBILITY) + +-if(LIBDE265_FOUND) ++target_compile_features(heif PRIVATE cxx_std_11) ++if(WITH_LIBDE265) + target_compile_definitions(heif PRIVATE HAVE_LIBDE265=1) + target_sources(heif + PRIVATE + heif_decoder_libde265.cc + heif_decoder_libde265.h) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBDE265_CFLAGS}") + +- if (NOT "${LIBDE265_LIBRARY_DIRS}" STREQUAL "") +- set(LIBDE265_LINKDIR "-L${LIBDE265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${LIBDE265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${LIBDE265_LIBRARIES} ${LIBDE265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libde265) + + install(FILES heif_decoder_libde265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(X265_FOUND) ++if(WITH_X265) + target_compile_definitions(heif PRIVATE HAVE_X265=1) + target_sources(heif PRIVATE + heif_encoder_x265.cc + heif_encoder_x265.h + ) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${X265_CFLAGS}") + +- if (NOT "${X265_LIBRARY_DIRS}" STREQUAL "") +- set(X265_LINKDIR "-L${X265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${X265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${X265_LIBRARIES} ${X265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libx265::libx265) + + install(FILES heif_encoder_x265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(AOM_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM=1) + target_sources(heif PRIVATE + heif_decoder_aom.cc +@@ -105,15 +96,9 @@ if(AOM_FOUND) + heif_encoder_aom.cc + heif_encoder_aom.h + ) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AOM_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AOM_CFLAGS}") + +- if (NOT "${AOM_LIBRARY_DIRS}" STREQUAL "") +- set(AOM_LINKDIR "-L${AOM_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${AOM_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${AOM_LIBRARIES} ${AOM_LINKDIR}) ++ target_link_libraries(heif PRIVATE libaom-av1::libaom-av1) + endif() + + if(USE_LOCAL_RAV1E) +@@ -126,18 +111,14 @@ if(USE_LOCAL_RAV1E) + target_link_libraries(heif PRIVATE ${CMAKE_SOURCE_DIR}/third-party/rav1e/target/release/librav1e.a -ldl) + endif() + +-if(USE_LOCAL_DAV1D) ++if(WITH_DAV1D) + target_compile_definitions(heif PRIVATE HAVE_DAV1D=1) + target_sources(heif PRIVATE + heif_decoder_dav1d.cc + heif_decoder_dav1d.h + ) +- target_include_directories(heif PRIVATE ${CMAKE_SOURCE_DIR}/third-party/dav1d/build +- ${CMAKE_SOURCE_DIR}/third-party/dav1d/build/include +- ${CMAKE_SOURCE_DIR}/third-party/dav1d/build/include/dav1d +- ${CMAKE_SOURCE_DIR}/third-party/dav1d/include) + +- target_link_libraries(heif PRIVATE ${CMAKE_SOURCE_DIR}/third-party/dav1d/build/src/libdav1d.a -ldl) ++ target_link_libraries(heif PRIVATE dav1d::dav1d) + endif () + + write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY ExactVersion) diff --git a/recipes/libheif/all/patches/0001-cmake.patch b/recipes/libheif/all/patches/0001-cmake.patch deleted file mode 100644 index 6397180df605d..0000000000000 --- a/recipes/libheif/all/patches/0001-cmake.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 5076fec..71891d5 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -41,8 +41,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) - set(CMAKE_CXX_VISIBILITY_PRESET hidden) - set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) - --set(CMAKE_POSITION_INDEPENDENT_CODE ON) -- - # Create the compile command database for clang by default - set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -@@ -54,7 +52,7 @@ if (has_potentially_evaluated_expression) - add_definitions(-Wno-error=potentially-evaluated-expression) - endif() - --LIST (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") -+LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") - find_package(Libde265 REQUIRED) - find_package(X265) - find_package(LibAOM) -@@ -128,4 +126,3 @@ if(WITH_EXAMPLES) - add_subdirectory (examples) - endif() - add_subdirectory (libheif) --add_subdirectory (gdk-pixbuf) diff --git a/recipes/libheif/all/patches/0001-cmake_1.11.0.patch b/recipes/libheif/all/patches/0001-cmake_1.11.0.patch index 0187ded1585bb..1bf34c06d1da8 100644 --- a/recipes/libheif/all/patches/0001-cmake_1.11.0.patch +++ b/recipes/libheif/all/patches/0001-cmake_1.11.0.patch @@ -1,18 +1,162 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index fabf381..6379d09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -38,8 +38,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) +@@ -31,14 +31,10 @@ if(NOT MSVC) + add_definitions(-Wno-error=deprecated-declarations) + endif() + +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_CXX_STANDARD_REQUIRED ON) +-set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) -- + # Create the compile command database for clang by default set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +@@ -55,17 +51,17 @@ LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") + + option(WITH_LIBDE265 "Build libde265 decoder" ON) + if (WITH_LIBDE265) +- find_package(Libde265) ++ find_package(libde265 REQUIRED CONFIG) + endif () + + option(WITH_X265 "Build x265 encoder" ON) + if (WITH_X265) +- find_package(X265) ++ find_package(libx265 REQUIRED CONFIG) + endif () + + option(WITH_AOM "Build aom encoder/decoder" ON) + if (WITH_AOM) +- find_package(LibAOM) ++ find_package(libaom-av1 REQUIRED CONFIG) + endif() + + option(WITH_RAV1E "Build rav1e encoder" ON) +@@ -75,9 +71,10 @@ endif () + option(WITH_DAV1D "Build dav1e decoder" ON) + if (WITH_DAV1D) +- find_package(Dav1d) ++ find_package(dav1d REQUIRED CONFIG) + endif () + ++if(0) + if (LIBDE265_FOUND) + message("HEIF decoder, libde265: found") + else () +@@ -113,6 +110,7 @@ if (DAV1D_FOUND) + else () + message("AVIF decoder, dav1d: not found") + endif () ++endif() + + + # Create libheif pkgconfig file @@ -165,4 +163,3 @@ if(WITH_EXAMPLES) add_subdirectory (examples) endif() add_subdirectory (libheif) -add_subdirectory (gdk-pixbuf) +--- a/libheif/CMakeLists.txt ++++ b/libheif/CMakeLists.txt +@@ -59,63 +59,48 @@ target_compile_definitions(heif + LIBHEIF_EXPORTS + HAVE_VISIBILITY) + +-if(LIBDE265_FOUND) ++target_compile_features(heif PRIVATE cxx_std_11) ++if(WITH_LIBDE265) + target_compile_definitions(heif PRIVATE HAVE_LIBDE265=1) + target_sources(heif + PRIVATE + heif_decoder_libde265.cc + heif_decoder_libde265.h) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBDE265_CFLAGS}") + +- if (NOT "${LIBDE265_LIBRARY_DIRS}" STREQUAL "") +- set(LIBDE265_LINKDIR "-L${LIBDE265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${LIBDE265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${LIBDE265_LIBRARIES} ${LIBDE265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libde265) + + install(FILES heif_decoder_libde265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(X265_FOUND) ++if(WITH_X265) + target_compile_definitions(heif PRIVATE HAVE_X265=1) + target_sources(heif PRIVATE + heif_encoder_x265.cc + heif_encoder_x265.h + ) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${X265_CFLAGS}") + +- if (NOT "${X265_LIBRARY_DIRS}" STREQUAL "") +- set(X265_LINKDIR "-L${X265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${X265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${X265_LIBRARIES} ${X265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libx265::libx265) + + install(FILES heif_encoder_x265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(AOM_ENCODER_FOUND OR AOM_DECODER_FOUND) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AOM_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AOM_CFLAGS}") ++if(WITH_AOM) + +- if (NOT "${AOM_LIBRARY_DIRS}" STREQUAL "") +- set(AOM_LINKDIR "-L${AOM_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${AOM_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${AOM_LIBRARIES} ${AOM_LINKDIR}) ++ target_link_libraries(heif PRIVATE libaom-av1::libaom-av1) + endif() +-if(AOM_ENCODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_ENCODER=1) + target_sources(heif PRIVATE + heif_encoder_aom.cc + heif_encoder_aom.h + ) + endif() +-if(AOM_DECODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_DECODER=1) + target_sources(heif PRIVATE + heif_decoder_aom.cc +@@ -140,21 +125,15 @@ if(RAV1E_FOUND) + target_link_libraries(heif PRIVATE ${RAV1E_LIBRARIES} ${RAV1E_LINKDIR}) + endif() + +-if(DAV1D_FOUND) ++if(WITH_DAV1D) + target_compile_definitions(heif PRIVATE HAVE_DAV1D=1) + target_sources(heif PRIVATE + heif_decoder_dav1d.cc + heif_decoder_dav1d.h + ) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DAV1D_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DAV1D_CFLAGS}") + +- if (NOT "${DAV1D_LIBRARY_DIRS}" STREQUAL "") +- set(DAV1D_LINKDIR "-L${DAV1D_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${DAV1D_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${DAV1D_LIBRARIES} ${DAV1D_LINKDIR}) ++ target_link_libraries(heif PRIVATE dav1d::dav1d) + endif () + + write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY ExactVersion) diff --git a/recipes/libheif/all/patches/0001-cmake_1.12.0.patch b/recipes/libheif/all/patches/0001-cmake_1.12.0.patch new file mode 100644 index 0000000000000..7504a4c708fcd --- /dev/null +++ b/recipes/libheif/all/patches/0001-cmake_1.12.0.patch @@ -0,0 +1,162 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -31,14 +31,10 @@ if(NOT MSVC) + add_definitions(-Wno-error=deprecated-declarations) + endif() + +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_CXX_STANDARD_REQUIRED ON) +-set(CMAKE_CXX_EXTENSIONS OFF) + + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # Create the compile command database for clang by default + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +@@ -55,17 +51,17 @@ LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") + + option(WITH_LIBDE265 "Build libde265 decoder" ON) + if (WITH_LIBDE265) +- find_package(Libde265) ++ find_package(libde265 REQUIRED CONFIG) + endif () + + option(WITH_X265 "Build x265 encoder" ON) + if (WITH_X265) +- find_package(X265) ++ find_package(libx265 REQUIRED CONFIG) + endif () + + option(WITH_AOM "Build aom encoder/decoder" ON) + if (WITH_AOM) +- find_package(LibAOM) ++ find_package(libaom-av1 REQUIRED CONFIG) + endif() + + option(WITH_RAV1E "Build rav1e encoder" ON) +@@ -75,9 +71,10 @@ endif () + + option(WITH_DAV1D "Build dav1d decoder" ON) + if (WITH_DAV1D) +- find_package(Dav1d) ++ find_package(dav1d REQUIRED CONFIG) + endif () + ++if(0) + if (LIBDE265_FOUND) + message("HEIF decoder, libde265: found") + else () +@@ -113,6 +110,7 @@ if (DAV1D_FOUND) + else () + message("AVIF decoder, dav1d: not found") + endif () ++endif() + + + # Create libheif pkgconfig file +@@ -165,4 +163,3 @@ if(WITH_EXAMPLES) + add_subdirectory (examples) + endif() + add_subdirectory (libheif) +-add_subdirectory (gdk-pixbuf) +--- a/libheif/CMakeLists.txt ++++ b/libheif/CMakeLists.txt +@@ -59,63 +59,48 @@ target_compile_definitions(heif + LIBHEIF_EXPORTS + HAVE_VISIBILITY) + +-if(LIBDE265_FOUND) ++target_compile_features(heif PRIVATE cxx_std_11) ++if(WITH_LIBDE265) + target_compile_definitions(heif PRIVATE HAVE_LIBDE265=1) + target_sources(heif + PRIVATE + heif_decoder_libde265.cc + heif_decoder_libde265.h) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBDE265_CFLAGS}") + +- if (NOT "${LIBDE265_LIBRARY_DIRS}" STREQUAL "") +- set(LIBDE265_LINKDIR "-L${LIBDE265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${LIBDE265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${LIBDE265_LIBRARIES} ${LIBDE265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libde265) + + install(FILES heif_decoder_libde265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(X265_FOUND) ++if(WITH_X265) + target_compile_definitions(heif PRIVATE HAVE_X265=1) + target_sources(heif PRIVATE + heif_encoder_x265.cc + heif_encoder_x265.h + ) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${X265_CFLAGS}") + +- if (NOT "${X265_LIBRARY_DIRS}" STREQUAL "") +- set(X265_LINKDIR "-L${X265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${X265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${X265_LIBRARIES} ${X265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libx265::libx265) + + install(FILES heif_encoder_x265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(AOM_ENCODER_FOUND OR AOM_DECODER_FOUND) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AOM_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AOM_CFLAGS}") ++if(WITH_AOM) + +- if (NOT "${AOM_LIBRARY_DIRS}" STREQUAL "") +- set(AOM_LINKDIR "-L${AOM_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${AOM_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${AOM_LIBRARIES} ${AOM_LINKDIR}) ++ target_link_libraries(heif PRIVATE libaom-av1::libaom-av1) + endif() +-if(AOM_ENCODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_ENCODER=1) + target_sources(heif PRIVATE + heif_encoder_aom.cc + heif_encoder_aom.h + ) + endif() +-if(AOM_DECODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_DECODER=1) + target_sources(heif PRIVATE + heif_decoder_aom.cc +@@ -140,21 +125,15 @@ if(RAV1E_FOUND) + target_link_libraries(heif PRIVATE ${RAV1E_LIBRARIES} ${RAV1E_LINKDIR}) + endif() + +-if(DAV1D_FOUND) ++if(WITH_DAV1D) + target_compile_definitions(heif PRIVATE HAVE_DAV1D=1) + target_sources(heif PRIVATE + heif_decoder_dav1d.cc + heif_decoder_dav1d.h + ) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DAV1D_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DAV1D_CFLAGS}") + +- if (NOT "${DAV1D_LIBRARY_DIRS}" STREQUAL "") +- set(DAV1D_LINKDIR "-L${DAV1D_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${DAV1D_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${DAV1D_LIBRARIES} ${DAV1D_LINKDIR}) ++ target_link_libraries(heif PRIVATE dav1d::dav1d) + endif () + + write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY ExactVersion) diff --git a/recipes/libheif/all/patches/0001-cmake_1.13.0.patch b/recipes/libheif/all/patches/0001-cmake_1.13.0.patch new file mode 100644 index 0000000000000..ce89cda4b5c16 --- /dev/null +++ b/recipes/libheif/all/patches/0001-cmake_1.13.0.patch @@ -0,0 +1,159 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -35,14 +35,10 @@ if(NOT MSVC) + endif () + endif() + +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_CXX_STANDARD_REQUIRED ON) +-set(CMAKE_CXX_EXTENSIONS OFF) + + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # Create the compile command database for clang by default + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +@@ -59,17 +55,17 @@ LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") + + option(WITH_LIBDE265 "Build libde265 decoder" ON) + if (WITH_LIBDE265) +- find_package(Libde265) ++ find_package(libde265 REQUIRED CONFIG) + endif () + + option(WITH_X265 "Build x265 encoder" ON) + if (WITH_X265) +- find_package(X265) ++ find_package(libx265 REQUIRED CONFIG) + endif () + + option(WITH_AOM "Build aom encoder/decoder" ON) + if (WITH_AOM) +- find_package(LibAOM) ++ find_package(libaom-av1 REQUIRED CONFIG) + endif() + + option(WITH_RAV1E "Build rav1e encoder" ON) +@@ -79,9 +75,10 @@ endif () + + option(WITH_DAV1D "Build dav1d decoder" ON) + if (WITH_DAV1D) +- find_package(Dav1d) ++ find_package(dav1d REQUIRED CONFIG) + endif () + ++if(0) + if (LIBDE265_FOUND) + message("HEIF decoder, libde265: found") + else () +@@ -117,6 +114,7 @@ if (DAV1D_FOUND) + else () + message("AVIF decoder, dav1d: not found") + endif () ++endif() + + + # Create libheif pkgconfig file +@@ -169,5 +167,3 @@ if(WITH_EXAMPLES) + add_subdirectory (examples) + endif() + add_subdirectory (libheif) +-add_subdirectory (gdk-pixbuf) +-add_subdirectory (gnome) +--- a/libheif/CMakeLists.txt ++++ b/libheif/CMakeLists.txt +@@ -60,59 +60,44 @@ target_compile_definitions(heif + LIBHEIF_EXPORTS + HAVE_VISIBILITY) + +-if(LIBDE265_FOUND) ++target_compile_features(heif PRIVATE cxx_std_11) ++if(WITH_LIBDE265) + target_compile_definitions(heif PRIVATE HAVE_LIBDE265=1) + target_sources(heif + PRIVATE + heif_decoder_libde265.cc + heif_decoder_libde265.h) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBDE265_CFLAGS}") + +- if (NOT "${LIBDE265_LIBRARY_DIRS}" STREQUAL "") +- set(LIBDE265_LINKDIR "-L${LIBDE265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${LIBDE265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${LIBDE265_LIBRARIES} ${LIBDE265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libde265) + endif() + +-if(X265_FOUND) ++if(WITH_X265) + target_compile_definitions(heif PRIVATE HAVE_X265=1) + target_sources(heif PRIVATE + heif_encoder_x265.cc + heif_encoder_x265.h + ) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${X265_CFLAGS}") + +- if (NOT "${X265_LIBRARY_DIRS}" STREQUAL "") +- set(X265_LINKDIR "-L${X265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${X265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${X265_LIBRARIES} ${X265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libx265::libx265) + endif() + +-if(AOM_ENCODER_FOUND OR AOM_DECODER_FOUND) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AOM_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AOM_CFLAGS}") ++if(WITH_AOM) + +- if (NOT "${AOM_LIBRARY_DIRS}" STREQUAL "") +- set(AOM_LINKDIR "-L${AOM_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${AOM_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${AOM_LIBRARIES} ${AOM_LINKDIR}) ++ target_link_libraries(heif PRIVATE libaom-av1::libaom-av1) + endif() +-if(AOM_ENCODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_ENCODER=1) + target_sources(heif PRIVATE + heif_encoder_aom.cc + heif_encoder_aom.h + ) + endif() +-if(AOM_DECODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_DECODER=1) + target_sources(heif PRIVATE + heif_decoder_aom.cc +@@ -137,21 +122,15 @@ if(RAV1E_FOUND) + target_link_libraries(heif PRIVATE ${RAV1E_LIBRARIES} ${RAV1E_LINKDIR}) + endif() + +-if(DAV1D_FOUND) ++if(WITH_DAV1D) + target_compile_definitions(heif PRIVATE HAVE_DAV1D=1) + target_sources(heif PRIVATE + heif_decoder_dav1d.cc + heif_decoder_dav1d.h + ) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DAV1D_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DAV1D_CFLAGS}") + +- if (NOT "${DAV1D_LIBRARY_DIRS}" STREQUAL "") +- set(DAV1D_LINKDIR "-L${DAV1D_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${DAV1D_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${DAV1D_LIBRARIES} ${DAV1D_LINKDIR}) ++ target_link_libraries(heif PRIVATE dav1d::dav1d) + endif () + + write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY ExactVersion) diff --git a/recipes/libheif/all/test_package/CMakeLists.txt b/recipes/libheif/all/test_package/CMakeLists.txt index 8c009895d93fd..13ebf8fab7134 100644 --- a/recipes/libheif/all/test_package/CMakeLists.txt +++ b/recipes/libheif/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(libheif REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} libheif::heif) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE libheif::heif) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libheif/all/test_package/conanfile.py b/recipes/libheif/all/test_package/conanfile.py index 7e2dfe859bb27..d120a992c06a6 100644 --- a/recipes/libheif/all/test_package/conanfile.py +++ b/recipes/libheif/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libheif/all/test_v1_package/CMakeLists.txt b/recipes/libheif/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..02d32b85a6658 --- /dev/null +++ b/recipes/libheif/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libheif REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libheif::heif) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libheif/all/test_v1_package/conanfile.py b/recipes/libheif/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libheif/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libheif/config.yml b/recipes/libheif/config.yml index f4bb233ecfac5..1b1bac20e2e23 100644 --- a/recipes/libheif/config.yml +++ b/recipes/libheif/config.yml @@ -1,7 +1,9 @@ versions: - "1.9.1": + "1.13.0": + folder: all + "1.12.0": folder: all "1.11.0": folder: all - "1.12.0": + "1.9.1": folder: all diff --git a/recipes/libhydrogen/all/conandata.yml b/recipes/libhydrogen/all/conandata.yml new file mode 100644 index 0000000000000..23536a9b5f306 --- /dev/null +++ b/recipes/libhydrogen/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "cci.20221115": + url: "https://github.com/jedisct1/libhydrogen/archive/580da280c59f72ca67e56333f5122f8ef040c74d.tar.gz" + sha256: "cf52deeb31f83302acfc784e9dab4b93e9c13e77aad3f629cf0761d30cae7e72" +patches: + "cci.20221115": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "CMake: Use C99 or higher, avoid to inject arch specific flags, fix dll install & don't build tests" + patch_type: "portability" diff --git a/recipes/libhydrogen/all/conanfile.py b/recipes/libhydrogen/all/conanfile.py new file mode 100644 index 0000000000000..5b5dc91e28942 --- /dev/null +++ b/recipes/libhydrogen/all/conanfile.py @@ -0,0 +1,71 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +import os + +required_conan_version = ">=1.53.0" + + +class LibhydrogenConan(ConanFile): + name = "libhydrogen" + description = "A lightweight, secure, easy-to-use crypto library suitable for constrained environments." + license = "ISC" + topics = ("cryptography", "crypto", "gimli") + homepage = "https://github.com/jedisct1/libhydrogen" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "hydrogen") + self.cpp_info.set_property("cmake_target_name", "hydrogen::hydrogen") + self.cpp_info.libs = ["hydrogen"] + + # TODO: to remove in conan v2 + self.cpp_info.names["cmake_find_package"] = "hydrogen" + self.cpp_info.names["cmake_find_package_multi"] = "hydrogen" diff --git a/recipes/libhydrogen/all/patches/0001-fix-cmake.patch b/recipes/libhydrogen/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..6fb76a8526ead --- /dev/null +++ b/recipes/libhydrogen/all/patches/0001-fix-cmake.patch @@ -0,0 +1,46 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.1) ++cmake_minimum_required(VERSION 3.8) + + project(hydrogen LANGUAGES C) + +@@ -39,6 +39,7 @@ set(arduino_files "library.properties") + + # Compile options + ++if(0) + get_setting(target_arch STRING "Target system architecture (fed to the compiler's -march=XXX).") + if(NOT target_arch AND NOT CMAKE_CROSSCOMPILING) + set(target_arch native) +@@ -84,6 +85,7 @@ set(compile_options + # unsigned" + /wd4310 # * suppress warning "cast truncates constant value" + >) ++endif() + + # Prefix project files with the project root + +@@ -106,6 +108,7 @@ set(targets_export_name "${PROJECT_NAME}-targets") + + install(TARGETS "${PROJECT_NAME}" + EXPORT "${targets_export_name}" ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") + +@@ -134,6 +137,8 @@ install(FILES "${config_file}" DESTINATION "${install_config_dir}") + + export(EXPORT "${targets_export_name}" FILE "${targets_export_file}" NAMESPACE "${PROJECT_NAME}::") + ++target_compile_features(${PROJECT_NAME} PUBLIC c_std_99) ++if(0) + export(PACKAGE "${PROJECT_NAME}") + + # Tests +@@ -191,3 +196,4 @@ add_custom_command(OUTPUT "${arduino_package_file}" + VERBATIM) + + add_custom_target("${PROJECT_NAME}-arduino-package" DEPENDS "${arduino_package_file}" VERBATIM) ++endif() diff --git a/recipes/libhydrogen/all/test_package/CMakeLists.txt b/recipes/libhydrogen/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2090c80502872 --- /dev/null +++ b/recipes/libhydrogen/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) + +find_package(hydrogen REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE hydrogen::hydrogen) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/libhydrogen/all/test_package/conanfile.py b/recipes/libhydrogen/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libhydrogen/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libhydrogen/all/test_package/test_package.c b/recipes/libhydrogen/all/test_package/test_package.c new file mode 100644 index 0000000000000..2fc97802ccc3e --- /dev/null +++ b/recipes/libhydrogen/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + printf("%lu\n", (unsigned long)hydro_random_u32()); + return 0; +} diff --git a/recipes/libhydrogen/all/test_v1_package/CMakeLists.txt b/recipes/libhydrogen/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libhydrogen/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libhydrogen/all/test_v1_package/conanfile.py b/recipes/libhydrogen/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libhydrogen/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libhydrogen/config.yml b/recipes/libhydrogen/config.yml new file mode 100644 index 0000000000000..7bdf816a5ffbd --- /dev/null +++ b/recipes/libhydrogen/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20221115": + folder: all diff --git a/recipes/libiberty/all/conanfile.py b/recipes/libiberty/all/conanfile.py index 27a92083ad920..3454090fe5df7 100644 --- a/recipes/libiberty/all/conanfile.py +++ b/recipes/libiberty/all/conanfile.py @@ -3,6 +3,9 @@ import os +required_conan_version = ">=1.33.0" + + class LibibertyConan(ConanFile): name = "libiberty" version = "9.1.0" @@ -12,8 +15,13 @@ class LibibertyConan(ConanFile): homepage = "https://gcc.gnu.org/onlinedocs/libiberty" license = "LGPL-2.1" settings = "os", "arch", "compiler", "build_type" - options = {"fPIC": [True, False]} - default_options = {"fPIC": True} + options = { + "fPIC": [True, False], + } + default_options = { + "fPIC": True, + } + _autotools = None @property @@ -25,7 +33,7 @@ def _libiberty_folder(self): return os.path.join(self._source_subfolder, self.name) def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC def configure(self): @@ -35,17 +43,19 @@ def configure(self): del self.settings.compiler.cppstd def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "gcc-" + self.version - os.rename(extracted_dir, self._source_subfolder) - tools.rmdir(os.path.join(self._source_subfolder, 'gcc')) - tools.rmdir(os.path.join(self._source_subfolder, 'libstdc++-v3')) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + tools.rmdir(os.path.join(self._source_subfolder, "gcc")) + tools.rmdir(os.path.join(self._source_subfolder, "libstdc++-v3")) def _configure_autotools(self): - if not self._autotools: - args = ["--enable-install-libiberty"] - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.configure(args=args, configure_dir=self._libiberty_folder) + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + conf_args = [ + "--enable-install-libiberty", + ] + self._autotools.configure(args=conf_args, configure_dir=self._libiberty_folder) return self._autotools def build(self): @@ -56,14 +66,15 @@ def package(self): self.copy(pattern="COPYING.LIB", src=self._libiberty_folder, dst="licenses") autotools = self._configure_autotools() autotools.install() - self._package_x86() + self._package_xx(32) + self._package_xx(64) - def _package_x86(self): - lib32dir = os.path.join(self.package_folder, "lib32") - if os.path.exists(lib32dir): + def _package_xx(self, arch): + lib_arch_dir = os.path.join(self.package_folder, "lib{}".format(arch)) + if os.path.exists(lib_arch_dir): libdir = os.path.join(self.package_folder, "lib") tools.rmdir(libdir) - os.rename(lib32dir, libdir) + tools.rename(lib_arch_dir, libdir) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["iberty"] diff --git a/recipes/libiberty/all/test_package/test_package.c b/recipes/libiberty/all/test_package/test_package.c index fdb2ccff29e4e..0d3850d960d09 100644 --- a/recipes/libiberty/all/test_package/test_package.c +++ b/recipes/libiberty/all/test_package/test_package.c @@ -1,6 +1,6 @@ #include #include -#include +#include "libiberty/libiberty.h" int main(void) { printf("GETPWD: %s\n", getpwd()); diff --git a/recipes/libiconv/all/conandata.yml b/recipes/libiconv/all/conandata.yml index 7e366afa6b516..445cf39835a93 100644 --- a/recipes/libiconv/all/conandata.yml +++ b/recipes/libiconv/all/conandata.yml @@ -1,11 +1,13 @@ sources: - "1.15": - url: "https://ftp.gnu.org/gnu/libiconv/libiconv-1.15.tar.gz" - sha256: "ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178" + "1.17": + url: "https://ftp.gnu.org/gnu/libiconv/libiconv-1.17.tar.gz" + sha256: "8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313" "1.16": url: "https://ftp.gnu.org/gnu/libiconv/libiconv-1.16.tar.gz" sha256: "e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04" + "1.15": + url: "https://ftp.gnu.org/gnu/libiconv/libiconv-1.15.tar.gz" + sha256: "ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178" patches: "1.16": - patch_file: "patches/0001-libcharset-fix-linkage.patch" - base_path: "source_subfolder" diff --git a/recipes/libiconv/all/conanfile.py b/recipes/libiconv/all/conanfile.py index 2767c9f82831c..0c3682db0b91c 100644 --- a/recipes/libiconv/all/conanfile.py +++ b/recipes/libiconv/all/conanfile.py @@ -1,33 +1,58 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from contextlib import contextmanager +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import ( + apply_conandata_patches, + copy, + export_conandata_patches, + get, + rename, + replace_in_file, + rm, + rmdir +) +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version +from conans.tools import get_gnu_triplet import os +required_conan_version = ">=1.53.0" + class LibiconvConan(ConanFile): name = "libiconv" description = "Convert text to and from Unicode" + license = "LGPL-2.1" url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.gnu.org/software/libiconv/" - topics = ("libiconv", "iconv", "text", "encoding", "locale", "unicode", "conversion") - license = "LGPL-2.1" - exports_sources = "patches/**" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _autotools = None + topics = ("iconv", "text", "encoding", "locale", "unicode", "conversion") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } @property - def _source_subfolder(self): - return "source_subfolder" + def _is_clang_cl(self): + return (self.settings.compiler == "clang" and self.settings.os == "Windows") \ + or self.settings.get_safe("compiler.toolset") == "ClangCL" @property - def _use_winbash(self): - return tools.os_info.is_windows and (self.settings.compiler == "gcc" or tools.cross_building(self.settings)) + def _msvc_tools(self): + return ("clang-cl", "llvm-lib", "lld-link") if self._is_clang_cl else ("cl", "lib", "link") @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -35,108 +60,89 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + basic_layout(self, src_folder="src") def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows": + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + self.win_bash = True def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - - @contextmanager - def _build_context(self): - env_vars = {} - if self._is_msvc: - build_aux_path = os.path.join(self.build_folder, self._source_subfolder, "build-aux") - lt_compile = tools.unix_path(os.path.join(build_aux_path, "compile")) - lt_ar = tools.unix_path(os.path.join(build_aux_path, "ar-lib")) - env_vars.update({ - "CC": "{} cl -nologo".format(lt_compile), - "CXX": "{} cl -nologo".format(lt_compile), - "LD": "link", - "STRIP": ":", - "AR": "{} lib".format(lt_ar), - "RANLIB": ":", - "NM": "dumpbin -symbols" - }) - env_vars["win32_target"] = "_WIN32_WINNT_VISTA" - - if not tools.cross_building(self.settings) or self._is_msvc: - rc = None - if self.settings.arch == "x86": - rc = "windres --target=pe-i386" - elif self.settings.arch == "x86_64": - rc = "windres --target=pe-x86-64" - if rc: - env_vars["RC"] = rc - env_vars["WINDRES"] = rc - if self._use_winbash: - env_vars["RANLIB"] = ":" - - with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): - with tools.chdir(self._source_subfolder): - with tools.environment_append(env_vars): - yield - - def _configure_autotools(self): - if self._autotools: - return self._autotools - host = None - build = None - if self._is_msvc: - build = False - if self.settings.arch == "x86": - host = "i686-w64-mingw32" - elif self.settings.arch == "x86_64": - host = "x86_64-w64-mingw32" - - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - - configure_args = [] - if self.options.shared: - configure_args.extend(["--disable-static", "--enable-shared"]) - else: - configure_args.extend(["--enable-static", "--disable-shared"]) - - if self._is_msvc: - self._autotools.flags.append("-FS") - - self._autotools.configure(args=configure_args, host=host, build=build) - return self._autotools + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + if cross_building(self) and is_msvc(self): + # ICU doesn't like GNU triplet of conan for msvc (see https://github.com/conan-io/conan/issues/12546) + host = get_gnu_triplet(str(self.settings.os), str(self.settings.arch), "gcc") + build = get_gnu_triplet(str(self._settings_build.os), str(self._settings_build.arch), "gcc") + tc.configure_args.extend([ + f"--host={host}", + f"--build={build}", + ]) + tc.generate() + + if is_msvc(self) or self._is_clang_cl: + env = Environment() + cc, lib, link = self._msvc_tools + build_aux_path = os.path.join(self.source_folder, "build-aux") + lt_compile = unix_path(self, os.path.join(build_aux_path, "compile")) + lt_ar = unix_path(self, os.path.join(build_aux_path, "ar-lib")) + env.define("CC", f"{lt_compile} {cc} -nologo") + env.define("CXX", f"{lt_compile} {cc} -nologo") + env.define("LD", link) + env.define("STRIP", ":") + env.define("AR", f"{lt_ar} {lib}") + env.define("RANLIB", ":") + env.define("NM", "dumpbin -symbols") + env.define("win32_target", "_WIN32_WINNT_VISTA") + env.vars(self).save_script("conanbuild_libiconv_msvc") def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) + # relocatable shared libs on macOS + for configure in ["configure", os.path.join("libcharset", "configure")]: + replace_in_file(self, os.path.join(self.source_folder, configure), + "-install_name \\$rpath/", "-install_name @rpath/") def build(self): self._patch_sources() - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - self.copy("COPYING.LIB", src=self._source_subfolder, dst="licenses") - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() + copy(self, "COPYING.LIB", self.source_folder, os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) - os.unlink(os.path.join(self.package_folder, "lib", "libcharset.la")) - os.unlink(os.path.join(self.package_folder, "lib", "libiconv.la")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "share")) - if self._is_msvc and self.options.shared: + if (is_msvc(self) or self._is_clang_cl) and self.options.shared: for import_lib in ["iconv", "charset"]: - tools.rename(os.path.join(self.package_folder, "lib", "{}.dll.lib".format(import_lib)), - os.path.join(self.package_folder, "lib", "{}.lib".format(import_lib))) + rename(self, os.path.join(self.package_folder, "lib", f"{import_lib}.dll.lib"), + os.path.join(self.package_folder, "lib", f"{import_lib}.lib")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "Iconv" - self.cpp_info.names["cmake_find_package_multi"] = "Iconv" + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "Iconv") + self.cpp_info.set_property("cmake_target_name", "Iconv::Iconv") self.cpp_info.libs = ["iconv", "charset"] - binpath = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment var: {}".format(binpath)) - self.env_info.path.append(binpath) + # TODO: to remove in conan v2 + self.cpp_info.names["cmake_find_package"] = "Iconv" + self.cpp_info.names["cmake_find_package_multi"] = "Iconv" + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/libiconv/all/patches/0001-libcharset-fix-linkage.patch b/recipes/libiconv/all/patches/0001-libcharset-fix-linkage.patch index 28fb08fabe213..f39e0b72f32e7 100644 --- a/recipes/libiconv/all/patches/0001-libcharset-fix-linkage.patch +++ b/recipes/libiconv/all/patches/0001-libcharset-fix-linkage.patch @@ -1,11 +1,155 @@ ---- a/libcharset/include/libcharset.h.in -+++ b/libcharset/include/libcharset.h.in -@@ -33,7 +33,7 @@ - by the corresponding pathname with the current prefix instead. Both - prefixes should be directory names without trailing slash (i.e. use "" - instead of "/"). */ --extern void libcharset_set_relocation_prefix (const char *orig_prefix, -+extern LIBCHARSET_DLL_EXPORTED void libcharset_set_relocation_prefix (const char *orig_prefix, - const char *curr_prefix); +diff --git a/libcharset/Makefile.in b/libcharset/Makefile.in +index 5f599fe..e6ba91a 100644 +--- a/libcharset/Makefile.in ++++ b/libcharset/Makefile.in +@@ -30,25 +30,22 @@ mkinstalldirs = $(SHELL) @top_srcdir@/build-aux/mkinstalldirs + + SHELL = @SHELL@ + +-all : include/libcharset.h force ++all : force + cd lib && $(MAKE) all + +-include/libcharset.h : +- if [ ! -d include ] ; then mkdir include ; fi +- $(CP) $(srcdir)/include/libcharset.h.in include/libcharset.h +- + # Installs the library and include files only. Typically called with only + # $(libdir) and $(includedir) - don't use $(prefix) and $(exec_prefix) here. + install-lib : all force + cd lib && $(MAKE) install-lib libdir='$(libdir)' includedir='$(includedir)' + $(mkinstalldirs) $(includedir) +- $(INSTALL_DATA) include/libcharset.h $(includedir)/libcharset.h +- $(INSTALL_DATA) include/localcharset.h.inst $(includedir)/localcharset.h ++ $(INSTALL_DATA) include/libcharset.h.inst $(includedir)/libcharset.h ++# Here, use the include file that contains LIBCHARSET_DLL_EXPORTED annotations. ++ $(INSTALL_DATA) include/localcharset.h $(includedir)/localcharset.h + +-install : include/libcharset.h include/localcharset.h force ++install : all force + cd lib && $(MAKE) install prefix='$(prefix)' exec_prefix='$(exec_prefix)' libdir='$(libdir)' + $(mkinstalldirs) $(DESTDIR)$(includedir) +- $(INSTALL_DATA) include/libcharset.h $(DESTDIR)$(includedir)/libcharset.h ++ $(INSTALL_DATA) include/libcharset.h.inst $(DESTDIR)$(includedir)/libcharset.h + $(INSTALL_DATA) include/localcharset.h.inst $(DESTDIR)$(includedir)/localcharset.h + + install-strip : install +@@ -73,12 +70,12 @@ clean : force + + distclean : force + cd lib && if test -f Makefile; then $(MAKE) distclean; fi +- $(RM) include/libcharset.h include/localcharset.h include/localcharset.h.inst ++ $(RM) include/libcharset.h include/libcharset.h.inst include/localcharset.h include/localcharset.h.inst + $(RM) config.status config.log config.cache Makefile config.h libtool + maintainer-clean : force + cd lib && if test -f Makefile; then $(MAKE) maintainer-clean; fi +- $(RM) include/libcharset.h include/localcharset.h include/localcharset.h.inst ++ $(RM) include/libcharset.h include/libcharset.h.inst include/localcharset.h include/localcharset.h.inst + $(RM) config.status config.log config.cache Makefile config.h libtool + # List of source files. +@@ -133,6 +130,7 @@ IMPORTED_FILES = \ + # List of distributed files generated by autotools or Makefile.devel. + GENERATED_FILES = \ + autoconf/aclocal.m4 configure config.h.in \ ++ include/libcharset.h.build.in \ + include/localcharset.h.build.in + # List of distributed files generated by "make". + DISTRIBUTED_BUILT_FILES = +diff --git a/libcharset/configure b/libcharset/configure +index cf4f9d2..8844aca 100755 +--- a/libcharset/configure ++++ b/libcharset/configure +@@ -12346,6 +12346,10 @@ ac_config_files="$ac_config_files Makefile" + + ac_config_files="$ac_config_files lib/Makefile" + ++ac_config_files="$ac_config_files include/libcharset.h:include/libcharset.h.build.in" ++ ++ac_config_files="$ac_config_files include/libcharset.h.inst:include/libcharset.h.in" ++ + ac_config_files="$ac_config_files include/localcharset.h:include/localcharset.h.build.in" + + ac_config_files="$ac_config_files include/localcharset.h.inst:include/localcharset.h.in" +@@ -13346,6 +13350,8 @@ do + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; ++ "include/libcharset.h") CONFIG_FILES="$CONFIG_FILES include/libcharset.h:include/libcharset.h.build.in" ;; ++ "include/libcharset.h.inst") CONFIG_FILES="$CONFIG_FILES include/libcharset.h.inst:include/libcharset.h.in" ;; + "include/localcharset.h") CONFIG_FILES="$CONFIG_FILES include/localcharset.h:include/localcharset.h.build.in" ;; + "include/localcharset.h.inst") CONFIG_FILES="$CONFIG_FILES include/localcharset.h.inst:include/localcharset.h.in" ;; + +diff --git a/libcharset/configure.ac b/libcharset/configure.ac +index 362bde3..a071d25 100644 +--- a/libcharset/configure.ac ++++ b/libcharset/configure.ac +@@ -60,6 +60,8 @@ AC_CHECK_FUNCS([setlocale]) + + AC_CONFIG_FILES([Makefile]) + AC_CONFIG_FILES([lib/Makefile]) ++AC_CONFIG_FILES([include/libcharset.h:include/libcharset.h.build.in]) ++AC_CONFIG_FILES([include/libcharset.h.inst:include/libcharset.h.in]) + AC_CONFIG_FILES([include/localcharset.h:include/localcharset.h.build.in]) + AC_CONFIG_FILES([include/localcharset.h.inst:include/localcharset.h.in]) + AC_OUTPUT +diff --git a/libcharset/include/libcharset.h.build.in b/libcharset/include/libcharset.h.build.in +new file mode 100644 +index 0000000..46e911a +--- /dev/null ++++ b/libcharset/include/libcharset.h.build.in +@@ -0,0 +1,53 @@ ++/* Copyright (C) 2003 Free Software Foundation, Inc. ++ This file is part of the GNU CHARSET Library. ++ ++ The GNU CHARSET Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public License as ++ published by the Free Software Foundation; either version 2 of the ++ License, or (at your option) any later version. ++ ++ The GNU CHARSET Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public License ++ along with the GNU CHARSET Library; see the file COPYING.LIB. If not, ++ see . */ ++ ++#ifndef _LIBCHARSET_H ++#define _LIBCHARSET_H ++ ++#if @HAVE_VISIBILITY@ && BUILDING_LIBCHARSET ++#define LIBCHARSET_DLL_EXPORTED __attribute__((__visibility__("default"))) ++#elif defined _MSC_VER && BUILDING_LIBCHARSET ++#define LIBCHARSET_DLL_EXPORTED __declspec(dllexport) ++#else ++#define LIBCHARSET_DLL_EXPORTED ++#endif ++ ++#include ++ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++ ++/* Support for relocatable packages. */ ++ ++/* Sets the original and the current installation prefix of the package. ++ Relocation simply replaces a pathname starting with the original prefix ++ by the corresponding pathname with the current prefix instead. Both ++ prefixes should be directory names without trailing slash (i.e. use "" ++ instead of "/"). */ ++extern LIBCHARSET_DLL_EXPORTED void libcharset_set_relocation_prefix (const char *orig_prefix, ++ const char *curr_prefix); ++ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++ ++#endif /* _LIBCHARSET_H */ diff --git a/recipes/libiconv/all/test_package/CMakeLists.txt b/recipes/libiconv/all/test_package/CMakeLists.txt index 7099d50465b2c..64fa90dede848 100644 --- a/recipes/libiconv/all/test_package/CMakeLists.txt +++ b/recipes/libiconv/all/test_package/CMakeLists.txt @@ -1,11 +1,7 @@ -cmake_minimum_required(VERSION 3.0.2) -project(test_package) +cmake_minimum_required(VERSION 3.1) +project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(Iconv REQUIRED) -find_package(Iconv) - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} Iconv::Iconv) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE Iconv::Iconv) diff --git a/recipes/libiconv/all/test_package/conanfile.py b/recipes/libiconv/all/test_package/conanfile.py index ec9ea3795547b..12a4269e5efa4 100644 --- a/recipes/libiconv/all/test_package/conanfile.py +++ b/recipes/libiconv/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -from conans import ConanFile, CMake, tools import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +22,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libiconv/all/test_package/test_package.c b/recipes/libiconv/all/test_package/test_package.c new file mode 100644 index 0000000000000..2b5cf12485b6d --- /dev/null +++ b/recipes/libiconv/all/test_package/test_package.c @@ -0,0 +1,50 @@ +#include +#include +#include //for EXIT_FAILURE +#include + +#if _MSC_VER && _MSC_VER < 1600 +typedef unsigned __int32 uint32_t; +#else +#include +#endif + +#include "iconv.h" +#include "libcharset.h" + +int main() +{ + // Test libiconv + char in_bytes[4] = {'c', 'i', 'a', 'o'}; + char *in_buffer = (char *)&in_bytes; + size_t in_bytes_left = sizeof(char) * 4; + uint32_t ou_bytes[4] = {(uint32_t)-1, (uint32_t)-1, (uint32_t)-1, (uint32_t)-1}; + size_t ou_bytes_left = sizeof(uint32_t) * 4; + char *ou_buffer = (char *)&ou_bytes; + iconv_t context; + size_t rv; + + context = iconv_open("UCS-4-INTERNAL", "US-ASCII"); + if ((iconv_t)(-1) == context) + { + fprintf(stderr, "iconv_open failed\n"); + return EXIT_FAILURE; + } + + rv = iconv(context, &in_buffer, &in_bytes_left, &ou_buffer, &ou_bytes_left); + if ((size_t)(-1) == rv) + { + fprintf(stderr, "icon failed\n"); + return EXIT_FAILURE; + } + + printf("retval libiconv: %lu %u %u %u %u\n", rv, ou_bytes[0], ou_bytes[1], ou_bytes[2], ou_bytes[3]); + + iconv_close(context); + + // Test libcharset + setlocale(LC_ALL, ""); + printf("retval libcharset: %s\n", locale_charset()); + + return EXIT_SUCCESS; +} diff --git a/recipes/libiconv/all/test_package/test_package.cpp b/recipes/libiconv/all/test_package/test_package.cpp deleted file mode 100644 index 3dded629091bb..0000000000000 --- a/recipes/libiconv/all/test_package/test_package.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include -#include -#include //for EXIT_FAILURE - -#if _MSC_VER && _MSC_VER<1600 -typedef unsigned __int32 uint32_t; -#else -#include -#endif - -int main() { - iconv_t context = iconv_open("UCS-4-INTERNAL", "US-ASCII"); - if ((iconv_t)(-1) == context) { - std::cerr << "iconv_open failed" << std::endl; - return EXIT_FAILURE; - } - char in_bytes[4] = {'c', 'i', 'a', 'o'}; - char *in_buffer = (char*)&in_bytes; - size_t in_bytes_left = sizeof(char) * 4; - uint32_t ou_bytes[4] = { (uint32_t)-1, (uint32_t)-1, (uint32_t)-1, (uint32_t)-1 }; - size_t ou_bytes_left = sizeof(uint32_t) * 4; - char *ou_buffer = (char*)&ou_bytes; - size_t rv = iconv(context, &in_buffer, &in_bytes_left, &ou_buffer, &ou_bytes_left); - if ((size_t)(-1) == rv) { - std::cerr << "icon failed" << std::endl; - return EXIT_FAILURE; - } - std::cout << "retval " << rv; - std::cout << " " << (unsigned long)ou_bytes[0]; - std::cout << " " << (unsigned long)ou_bytes[1]; - std::cout << " " << (unsigned long)ou_bytes[2]; - std::cout << " " << (unsigned long)ou_bytes[3]; - std::cout << std::endl; - - iconv_close(context); -} diff --git a/recipes/libiconv/all/test_v1_package/CMakeLists.txt b/recipes/libiconv/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libiconv/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libiconv/all/test_v1_package/conanfile.py b/recipes/libiconv/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a831367c532bc --- /dev/null +++ b/recipes/libiconv/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/libiconv/config.yml b/recipes/libiconv/config.yml index 3a1d5b036d2a9..107f427ec4419 100644 --- a/recipes/libiconv/config.yml +++ b/recipes/libiconv/config.yml @@ -1,5 +1,7 @@ versions: - "1.15": + "1.17": folder: all "1.16": folder: all + "1.15": + folder: all diff --git a/recipes/libid3tag/all/conanfile.py b/recipes/libid3tag/all/conanfile.py index 323e562b9b0a8..ec346961d3ce4 100644 --- a/recipes/libid3tag/all/conanfile.py +++ b/recipes/libid3tag/all/conanfile.py @@ -1,6 +1,9 @@ from conans import ConanFile, tools, AutoToolsBuildEnvironment, MSBuild from conans.errors import ConanInvalidConfiguration import os +import shutil + +required_conan_version = ">=1.33.0" class LibId3TagConan(ConanFile): @@ -21,34 +24,43 @@ class LibId3TagConan(ConanFile): def _source_subfolder(self): return "source_subfolder" - @property - def _build_subfolder(self): - return "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd - if self._is_msvc and self.options.shared: - raise ConanInvalidConfiguration("libid3tag does not support shared library for MSVC") def requirements(self): self.requires("zlib/1.2.11") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - @property def _is_msvc(self): return self.settings.compiler == "Visual Studio" or ( self.settings.compiler == "clang" and self.settings.os == "Windows" ) + def validate(self): + if self._is_msvc and self.options.shared: + raise ConanInvalidConfiguration("libid3tag does not support shared library for MSVC") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + if not self._is_msvc: + self.build_requires("gnu-config/cci.20201022") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + def build(self): if self._is_msvc: self._build_msvc() @@ -77,20 +89,26 @@ def _configure_autotools(self): args = ["--disable-static", "--enable-shared"] else: args = ["--disable-shared", "--enable-static"] - self._autotools = AutoToolsBuildEnvironment(self) + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) self._autotools.configure(args=args, configure_dir=self._source_subfolder) return self._autotools + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def _build_autotools(self): + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) autotools = self._configure_autotools() autotools.make() def _install_autotools(self): autotools = self._configure_autotools() autotools.install() - la = os.path.join(self.package_folder, "lib", "libid3tag.la") - if os.path.isfile(la): - os.unlink(la) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") def package(self): self.copy("COPYRIGHT", dst="licenses", src=self._source_subfolder) diff --git a/recipes/libid3tag/all/test_package/CMakeLists.txt b/recipes/libid3tag/all/test_package/CMakeLists.txt index 196188113685c..7b9b613cbb24a 100644 --- a/recipes/libid3tag/all/test_package/CMakeLists.txt +++ b/recipes/libid3tag/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -add_executable(${PROJECT_NAME} test_package.cpp) +add_executable(${PROJECT_NAME} test_package.c) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libid3tag/all/test_package/conanfile.py b/recipes/libid3tag/all/test_package/conanfile.py index bd7165a553cf4..d4128b0450777 100644 --- a/recipes/libid3tag/all/test_package/conanfile.py +++ b/recipes/libid3tag/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libid3tag/all/test_package/test_package.c b/recipes/libid3tag/all/test_package/test_package.c new file mode 100644 index 0000000000000..ef86650029180 --- /dev/null +++ b/recipes/libid3tag/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include + +#include + +int main() +{ + printf("id3tag version: %s\n", id3_version); + printf("id3tag copyright: %s\n", id3_copyright); + printf("id3tag author: %s\n", id3_author); + printf("id3tag build: %s\n", id3_build); + + struct id3_tag tag; + id3_tag_version(&tag); + + return 0; +} diff --git a/recipes/libid3tag/all/test_package/test_package.cpp b/recipes/libid3tag/all/test_package/test_package.cpp deleted file mode 100644 index b2e2c4b098118..0000000000000 --- a/recipes/libid3tag/all/test_package/test_package.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -int main() -{ - std::cout << "id3tag version: " << id3_version << std::endl; - std::cout << "id3tag copyright: " << id3_copyright << std::endl; - std::cout << "id3tag author: " << id3_author << std::endl; - std::cout << "id3tag build: " << id3_build << std::endl; - - id3_tag tag; - id3_tag_version(&tag); - - return 0; -} diff --git a/recipes/libidn/all/conandata.yml b/recipes/libidn/all/conandata.yml index 66be4e4c2682e..8be8baf6f09f3 100644 --- a/recipes/libidn/all/conandata.yml +++ b/recipes/libidn/all/conandata.yml @@ -2,3 +2,7 @@ sources: "1.36": url: "https://ftp.gnu.org/gnu/libidn/libidn-1.36.tar.gz" sha256: "14b67108344d81ba844631640df77c9071d9fb0659b080326ff5424e86b14038" +patches: + "1.36": + - patch_file: "patches/0001-unconditional-system-stdint-h.patch" + base_path: "source_subfolder" diff --git a/recipes/libidn/all/conanfile.py b/recipes/libidn/all/conanfile.py index 6c875850242d4..6305a5795dac0 100644 --- a/recipes/libidn/all/conanfile.py +++ b/recipes/libidn/all/conanfile.py @@ -1,16 +1,20 @@ from conans import AutoToolsBuildEnvironment, ConanFile, tools from conans.errors import ConanInvalidConfiguration -from contextlib import contextmanager +import contextlib +import functools import os +required_conan_version = ">=1.33.0" -class LibIdn(ConanFile): + +class LibIdnConan(ConanFile): name = "libidn" description = "GNU Libidn is a fully documented implementation of the Stringprep, Punycode and IDNA 2003 specifications." homepage = "https://www.gnu.org/software/libidn/" - topics = ("conan", "libidn", "encode", "decode", "internationalized", "domain", "name") + topics = ("libidn", "encode", "decode", "internationalized", "domain", "name") license = "GPL-3.0-or-later" url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -21,14 +25,19 @@ class LibIdn(ConanFile): "fPIC": True, "threads": True, } - settings = "os", "arch", "compiler", "build_type" - - _autotools = None @property def _source_subfolder(self): return "source_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -36,28 +45,30 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("Shared libraries are not supported on Windows due to libtool limitation") del self.settings.compiler.libcxx del self.settings.compiler.cppstd def requirements(self): self.requires("libiconv/1.16") + def validate(self): + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("Shared libraries are not supported on Windows due to libtool limitation") + def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.2") + self.build_requires("automake/1.16.3") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libidn-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) - @contextmanager + @contextlib.contextmanager def _build_context(self): if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): + with tools.vcvars(self): env = { "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), @@ -69,16 +80,16 @@ def _build_context(self): else: yield + @functools.lru_cache(1) def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.libs = [] + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools.libs = [] if not self.options.shared: - self._autotools.defines.append("LIBIDN_STATIC") + autotools.defines.append("LIBIDN_STATIC") if self.settings.compiler == "Visual Studio": - self._autotools.flags.append("-FS") - self._autotools.link_flags.extend("-L{}".format(p.replace("\\", "/")) for p in self.deps_cpp_info.lib_paths) + if tools.Version(self.settings.compiler.version) >= "12": + autotools.flags.append("-FS") + autotools.link_flags.extend("-L{}".format(p.replace("\\", "/")) for p in self.deps_cpp_info.lib_paths) yes_no = lambda v: "yes" if v else "no" conf_args = [ "--enable-shared={}".format(yes_no(self.options.shared)), @@ -88,10 +99,12 @@ def _configure_autotools(self): "--disable-nls", "--disable-rpath", ] - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return self._autotools + autotools.configure(args=conf_args, configure_dir=self._source_subfolder) + return autotools def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) if self.settings.compiler == "Visual Studio": if self.settings.arch in ("x86_64", "armv8", "armv8.3"): ssize = "signed long long int" @@ -109,15 +122,14 @@ def package(self): autotools = self._configure_autotools() autotools.install() - os.unlink(os.path.join(self.package_folder, "lib", "libidn.la")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) tools.rmdir(os.path.join(self.package_folder, "share")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") def package_info(self): self.cpp_info.libs = ["idn"] self.cpp_info.names["pkg_config"] = "libidn" - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: if self.options.threads: self.cpp_info.system_libs = ["pthread"] if self.settings.os == "Windows": @@ -128,4 +140,3 @@ def package_info(self): self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) - diff --git a/recipes/libidn/all/patches/0001-unconditional-system-stdint-h.patch b/recipes/libidn/all/patches/0001-unconditional-system-stdint-h.patch new file mode 100644 index 0000000000000..80c98fc3182d7 --- /dev/null +++ b/recipes/libidn/all/patches/0001-unconditional-system-stdint-h.patch @@ -0,0 +1,19 @@ +--- lib/Makefile.in ++++ lib/Makefile.in +@@ -2000,11 +2000,11 @@ + + + idn-int.h: +- if test -n "$(STDINT_H)"; then \ +- sed -e s/include_next/include/ gl/stdint.h > idn-int.h; \ +- else \ +- echo '#include ' > idn-int.h; \ +- fi ++ # if test -n "$(STDINT_H)"; then \ ++ # sed -e s/include_next/include/ gl/stdint.h > idn-int.h; \ ++ # else ++ echo '#include ' > idn-int.h; ++ # fi + @HAVE_LD_OUTPUT_DEF_TRUE@libidn-$(DLL_VERSION).def: libidn.la + + #nfkc.c: gunibreak.h gunicomp.h gunidecomp.h diff --git a/recipes/libidn/all/test_package/conanfile.py b/recipes/libidn/all/test_package/conanfile.py index 33686ba026b0c..07c965844de9b 100644 --- a/recipes/libidn/all/test_package/conanfile.py +++ b/recipes/libidn/all/test_package/conanfile.py @@ -12,9 +12,8 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run("idn --help", run_environment=True) bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) - diff --git a/recipes/libidn2/all/conanfile.py b/recipes/libidn2/all/conanfile.py index 293e3de3f7057..0a83958ffe3fd 100644 --- a/recipes/libidn2/all/conanfile.py +++ b/recipes/libidn2/all/conanfile.py @@ -3,12 +3,14 @@ from contextlib import contextmanager import os +required_conan_version = ">=1.33.0" + class LibIdn(ConanFile): name = "libidn2" description = "GNU Libidn is a fully documented implementation of the Stringprep, Punycode and IDNA 2003 specifications." homepage = "https://www.gnu.org/software/libidn/" - topics = ("conan", "libidn", "encode", "decode", "internationalized", "domain", "name") + topics = ("libidn", "encode", "decode", "internationalized", "domain", "name") license = "GPL-3.0-or-later" url = "https://github.com/conan-io/conan-center-index" options = { @@ -20,7 +22,6 @@ class LibIdn(ConanFile): "fPIC": True, } settings = "os", "arch", "compiler", "build_type" - exports_sources = "patches/**" _autotools = None @@ -28,6 +29,10 @@ class LibIdn(ConanFile): def _source_subfolder(self): return "source_subfolder" + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -35,23 +40,29 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("Shared libraries are not supported on Windows due to libtool limitation") del self.settings.compiler.libcxx del self.settings.compiler.cppstd def requirements(self): self.requires("libiconv/1.16") + def validate(self): + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("Shared libraries are not supported on Windows due to libtool limitation") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.2") + self.build_requires("automake/1.16.4") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libidn2-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) @contextmanager def _build_context(self): @@ -76,7 +87,8 @@ def _configure_autotools(self): if not self.options.shared: self._autotools.defines.append("IDN2_STATIC") if self.settings.compiler == "Visual Studio": - self._autotools.flags.append("-FS") + if tools.Version(self.settings.compiler.version) >= "12": + self._autotools.flags.append("-FS") self._autotools.link_flags.extend("-L{}".format(p.replace("\\", "/")) for p in self.deps_cpp_info.lib_paths) yes_no = lambda v: "yes" if v else "no" conf_args = [ @@ -108,10 +120,7 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "share")) def package_info(self): - libname = "idn2" - if self.options.shared and self.settings.os == "Windows": - libname += ".dll" + (".lib" if self.settings.compiler == "Visual Studio" else ".a") - self.cpp_info.libs = [libname] + self.cpp_info.libs = ["idn2"] self.cpp_info.names["pkg_config"] = "libidn2" if self.settings.os == "Windows": if not self.options.shared: diff --git a/recipes/libigl/2.x.x/CMakeLists.txt b/recipes/libigl/2.x.x/CMakeLists.txt new file mode 100644 index 0000000000000..64994fe16fd84 --- /dev/null +++ b/recipes/libigl/2.x.x/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.8) +project(conanlibigl) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +find_package(Eigen3 REQUIRED) + +add_subdirectory(source_subfolder) diff --git a/recipes/libigl/2.x.x/conandata.yml b/recipes/libigl/2.x.x/conandata.yml new file mode 100644 index 0000000000000..1ac5bf040c202 --- /dev/null +++ b/recipes/libigl/2.x.x/conandata.yml @@ -0,0 +1,8 @@ +sources: + "2.3.0": + sha256: 5124443c2657023394039fe56fb240d4f7a867723ee4ebba053eaeb881ed7455 + url: https://github.com/libigl/libigl/archive/refs/tags/v2.3.0.zip +patches: + "2.3.0": + - patch_file: "patches/0001-correct-fpic.patch" + base_path: "source_subfolder" diff --git a/recipes/libigl/2.x.x/conanfile.py b/recipes/libigl/2.x.x/conanfile.py new file mode 100644 index 0000000000000..f5ac50b8841ac --- /dev/null +++ b/recipes/libigl/2.x.x/conanfile.py @@ -0,0 +1,140 @@ +import os +from conans import ConanFile, tools, CMake +from conans.errors import ConanInvalidConfiguration + + +class LibiglConan(ConanFile): + name = "libigl" + description = ("Simple C++ geometry processing library") + topics = ("conan", "libigl", "geometry", "matrices", "algorithms") + url = "https://github.com/conan-io/conan-center-index" + exports_sources = ["CMakeLists.txt", "patches/**"] + homepage = "https://libigl.github.io/" + license = "MPL-2.0" + settings = "os", "arch", "compiler", "build_type" + options = {"header_only": [True, False], "fPIC": [True, False]} + default_options = {"header_only": True, "fPIC": True} + generators = "cmake", "cmake_find_package" + requires = ("eigen/3.3.9") + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _minimum_cpp_standard(self): + return 14 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "16", + "gcc": "6", + "clang": "3.4", + "apple-clang": "5.1", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler)) + else: + if tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( + self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) + if self.settings.compiler == "Visual Studio" and "MT" in self.settings.compiler.runtime and not self.options.header_only: + raise ConanInvalidConfiguration("Visual Studio build with MT runtime is not supported") + if "arm" in self.settings.arch or "x86" is self.settings.arch: + raise ConanInvalidConfiguration("Not available for arm. Requested arch: {}".format(self.settings.arch)) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.header_only: + del self.options.fPIC + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _configure_cmake(self): + if not self._cmake: + self._cmake = CMake(self, parallel=False) + self._cmake.definitions["LIBIGL_EXPORT_TARGETS"] = True + self._cmake.definitions["LIBIGL_USE_STATIC_LIBRARY"] = not self.options.header_only + + # All these dependencies are needed to build the examples or the tests + self._cmake.definitions["LIBIGL_BUILD_TUTORIALS"] = "OFF" + self._cmake.definitions["LIBIGL_BUILD_TESTS"] = "OFF" + self._cmake.definitions["LIBIGL_BUILD_PYTHON"] = "OFF" + + self._cmake.definitions["LIBIGL_WITH_CGAL"] = False + self._cmake.definitions["LIBIGL_WITH_COMISO"] = False + self._cmake.definitions["LIBIGL_WITH_CORK"] = False + self._cmake.definitions["LIBIGL_WITH_EMBREE"] = False + self._cmake.definitions["LIBIGL_WITH_MATLAB"] = False + self._cmake.definitions["LIBIGL_WITH_MOSEK"] = False + self._cmake.definitions["LIBIGL_WITH_OPENGL"] = False + self._cmake.definitions["LIBIGL_WITH_OPENGL_GLFW"] = False + self._cmake.definitions["LIBIGL_WITH_OPENGL_GLFW_IMGUI"] = False + self._cmake.definitions["LIBIGL_WITH_PNG"] = False + self._cmake.definitions["LIBIGL_WITH_TETGEN"] = False + self._cmake.definitions["LIBIGL_WITH_TRIANGLE"] = False + self._cmake.definitions["LIBIGL_WITH_XML"] = False + self._cmake.definitions["LIBIGL_WITH_PYTHON"] = "OFF" + self._cmake.definitions["LIBIGL_WITH_PREDICATES"] = False + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.configure() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + self.copy("LICENSE.GPL", dst="licenses", src=self._source_subfolder) + self.copy("LICENSE.MPL2", dst="licenses", src=self._source_subfolder) + + tools.rmdir(os.path.join(self.package_folder, "share")) + if not self.options.header_only: + tools.remove_files_by_mask(self.package_folder, "*.c") + tools.remove_files_by_mask(self.package_folder, "*.cpp") + + def package_id(self): + if self.options.header_only: + self.info.header_only() + + def package_info(self): + self.cpp_info.filenames["cmake_find_package"] = "libigl" + self.cpp_info.filenames["cmake_find_package_multi"] = "libigl" + self.cpp_info.names["cmake_find_package"] = "igl" + self.cpp_info.names["cmake_find_package_multi"] = "igl" + + self.cpp_info.components["igl_common"].names["cmake_find_package"] = "common" + self.cpp_info.components["igl_common"].names["cmake_find_package_multi"] = "common" + self.cpp_info.components["igl_common"].libs = [] + self.cpp_info.components["igl_common"].requires = ["eigen::eigen"] + if self.settings.os == "Linux": + self.cpp_info.components["igl_common"].system_libs = ["pthread"] + + self.cpp_info.components["igl_core"].names["cmake_find_package"] = "core" + self.cpp_info.components["igl_core"].names["cmake_find_package_multi"] = "core" + self.cpp_info.components["igl_core"].requires = ["igl_common"] + if not self.options.header_only: + self.cpp_info.components["igl_core"].libs = ["igl"] + self.cpp_info.components["igl_core"].defines.append("IGL_STATIC_LIBRARY") diff --git a/recipes/libigl/2.x.x/patches/0001-correct-fpic.patch b/recipes/libigl/2.x.x/patches/0001-correct-fpic.patch new file mode 100644 index 0000000000000..6a5a6c38650c0 --- /dev/null +++ b/recipes/libigl/2.x.x/patches/0001-correct-fpic.patch @@ -0,0 +1,17 @@ +diff --git a/cmake/libigl.cmake b/cmake/libigl.cmake +index 6de1b418..0cc75fcd 100644 +--- a/cmake/libigl.cmake ++++ b/cmake/libigl.cmake +@@ -96,11 +96,6 @@ if(BUILD_SHARED_LIBS) + set_target_properties(igl_common PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON) + endif() + +-if(UNIX AND NOT HUNTER_ENABLED) +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +-endif() +- + if(HUNTER_ENABLED) + hunter_add_package(Eigen) + find_package(Eigen3 CONFIG REQUIRED) + diff --git a/recipes/libigl/2.x.x/test_package/CMakeLists.txt b/recipes/libigl/2.x.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..174c1ae49d642 --- /dev/null +++ b/recipes/libigl/2.x.x/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libigl REQUIRED CONFIG) + +add_executable(example example.cpp) +target_link_libraries(example igl::core) +target_compile_features(example PUBLIC cxx_std_11) diff --git a/recipes/libigl/2.x.x/test_package/conanfile.py b/recipes/libigl/2.x.x/test_package/conanfile.py new file mode 100644 index 0000000000000..321eb52ae4077 --- /dev/null +++ b/recipes/libigl/2.x.x/test_package/conanfile.py @@ -0,0 +1,19 @@ +import os + +from conans import ConanFile, CMake, tools + + +class LibiglTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) + diff --git a/recipes/libigl/2.x.x/test_package/example.cpp b/recipes/libigl/2.x.x/test_package/example.cpp new file mode 100644 index 0000000000000..c6ae0f0a33a39 --- /dev/null +++ b/recipes/libigl/2.x.x/test_package/example.cpp @@ -0,0 +1,31 @@ +// This test is not representative of all the library capabilities. +// It is extracted from the example 002[1] of the tutorial +// +// [1] https://github.com/libigl/libigl/blob/master/tutorial/202_GaussianCurvature/main.cpp +#include +#include +#include +#include + +int main() +{ + using namespace Eigen; + MatrixXd V(3, 3); + + V << 0, 0, 0, + 1, 1, 0, + -1, 1, 0; + + MatrixXi F(1, 3); + F << 0, 1, 2; + + // Compute integral of Gaussian curvature + VectorXd K; + igl::gaussian_curvature(V, F, K); + + // Compute mass matrix + SparseMatrix M, Minv; + igl::massmatrix(V, F, igl::MASSMATRIX_TYPE_DEFAULT, M); + + igl::invert_diag(M, Minv); +} diff --git a/recipes/libigl/config.yml b/recipes/libigl/config.yml new file mode 100644 index 0000000000000..58d1203871eb7 --- /dev/null +++ b/recipes/libigl/config.yml @@ -0,0 +1,3 @@ +versions: + "2.3.0": + folder: "2.x.x" diff --git a/recipes/libipt/all/CMakeLists.txt b/recipes/libipt/all/CMakeLists.txt new file mode 100644 index 0000000000000..f62f6ae283c5f --- /dev/null +++ b/recipes/libipt/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.0) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/libipt/all/conandata.yml b/recipes/libipt/all/conandata.yml new file mode 100644 index 0000000000000..91a36f41590f6 --- /dev/null +++ b/recipes/libipt/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.0.5": + url: https://github.com/intel/libipt/archive/refs/tags/v2.0.5.tar.gz + sha256: 95acf499fdf0a0f5ebd07587bb443c702b1fd79f7d869749824234388b9bff80 diff --git a/recipes/libipt/all/conanfile.py b/recipes/libipt/all/conanfile.py new file mode 100644 index 0000000000000..73c8a14fe3622 --- /dev/null +++ b/recipes/libipt/all/conanfile.py @@ -0,0 +1,74 @@ +from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.33.0" + +class LibIptConan(ConanFile): + name = "libipt" + license = "BSD-3-Clause" + homepage = "https://github.com/intel/libipt" + url = "https://github.com/conan-io/conan-center-index" + description = "Intel(R) Processor Trace Decoder Library" + topics = ("profiling", "tracing") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + pass + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure() + return self._cmake + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["libipt"] if self.settings.os == "Windows" else ["ipt"] + self.cpp_info.set_property("cmake_file_name", "libipt") + self.cpp_info.set_property("cmake_target_name", "libipt::libipt") + diff --git a/recipes/libipt/all/test_package/CMakeLists.txt b/recipes/libipt/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..614fc23d88dda --- /dev/null +++ b/recipes/libipt/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libipt REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_compile_features(test_package PRIVATE cxx_std_11 cxx_constexpr) +target_link_libraries(${PROJECT_NAME} libipt::libipt) diff --git a/recipes/libipt/all/test_package/conanfile.py b/recipes/libipt/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a8c92dea63335 --- /dev/null +++ b/recipes/libipt/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libipt/all/test_package/test_package.cpp b/recipes/libipt/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..6b9e18b8eb133 --- /dev/null +++ b/recipes/libipt/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include + +int main(int argc, char **argv) +{ + pt_config cfg; + pt_config_init(&cfg); + + return 0; +} diff --git a/recipes/libipt/config.yml b/recipes/libipt/config.yml new file mode 100644 index 0000000000000..16ab573dd6bd3 --- /dev/null +++ b/recipes/libipt/config.yml @@ -0,0 +1,3 @@ +versions: + "2.0.5": + folder: all diff --git a/recipes/libjpeg-turbo/all/CMakeLists.txt b/recipes/libjpeg-turbo/all/CMakeLists.txt index 761fb2a328ab1..5ab4bc9f0265e 100644 --- a/recipes/libjpeg-turbo/all/CMakeLists.txt +++ b/recipes/libjpeg-turbo/all/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.1) - project(cmake_wrapper) -include(conanbuildinfo.cmake) -conan_basic_setup(NO_OUTPUT_DIRS) +if(NOT CMAKE_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR ${CONAN_LIBJPEG_TURBO_SYSTEM_PROCESSOR}) +endif() -add_subdirectory("source_subfolder") +add_subdirectory("src") diff --git a/recipes/libjpeg-turbo/all/conandata.yml b/recipes/libjpeg-turbo/all/conandata.yml index 3323aa8357276..dd61b3782fc38 100644 --- a/recipes/libjpeg-turbo/all/conandata.yml +++ b/recipes/libjpeg-turbo/all/conandata.yml @@ -1,16 +1,27 @@ sources: - "2.0.2": - url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.2.tar.gz" - sha256: "b45255bd476c19c7c6b198c07c0487e8b8536373b82f2b38346b32b4fa7bb942" - "2.0.4": - url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.4.tar.gz" - sha256: "7777c3c19762940cff42b3ba4d7cd5c52d1671b39a79532050c85efb99079064" - "2.0.5": - url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.5.tar.gz" - sha256: "b3090cd37b5a8b3e4dbd30a1311b3989a894e5d3c668f14cbc6739d77c9402b7" - "2.0.6": - url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.6.tar.gz" - sha256: "005aee2fcdca252cee42271f7f90574dda64ca6505d9f8b86ae61abc2b426371" + "2.1.4": + url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.1.4.tar.gz" + sha256: "a78b05c0d8427a90eb5b4eb08af25309770c8379592bb0b8a863373128e6143f" + "2.1.3": + url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.1.3.tar.gz" + sha256: "dbda0c685942aa3ea908496592491e5ec8160d2cf1ec9d5fd5470e50768e7859" + "2.1.2": + url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.1.2.tar.gz" + sha256: "e7fdc8a255c45bc8fbd9aa11c1a49c23092fcd7379296aeaeb14d3343a3d1bed" + "2.1.1": + url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.1.1.tar.gz" + sha256: "20e9cd3e5f517950dfb7a300ad344543d88719c254407ffb5ad88d891bf701c4" "2.1.0": url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.1.0.tar.gz" sha256: "d6b7790927d658108dfd3bee2f0c66a2924c51ee7f9dc930f62c452f4a638c52" + "2.0.6": + url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.6.tar.gz" + sha256: "005aee2fcdca252cee42271f7f90574dda64ca6505d9f8b86ae61abc2b426371" + "2.0.5": + url: "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.5.tar.gz" + sha256: "b3090cd37b5a8b3e4dbd30a1311b3989a894e5d3c668f14cbc6739d77c9402b7" +patches: + "2.1.4": + - patch_file: "patches/2.1.3-0001-fix-cmake.patch" + "2.1.3": + - patch_file: "patches/2.1.3-0001-fix-cmake.patch" diff --git a/recipes/libjpeg-turbo/all/conanfile.py b/recipes/libjpeg-turbo/all/conanfile.py index c1afccce6bb47..86caf639f776a 100644 --- a/recipes/libjpeg-turbo/all/conanfile.py +++ b/recipes/libjpeg-turbo/all/conanfile.py @@ -1,58 +1,74 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version import os -import glob -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.52.0" class LibjpegTurboConan(ConanFile): name = "libjpeg-turbo" description = "SIMD-accelerated libjpeg-compatible JPEG codec library" - topics = ("conan", "jpeg", "libjpeg", "image", "multimedia", "format", "graphics") + license = "BSD-3-Clause, Zlib" url = "https://github.com/conan-io/conan-center-index" homepage = "https://libjpeg-turbo.org" - license = "BSD-3-Clause, Zlib" + topics = ("jpeg", "libjpeg", "image", "multimedia", "format", "graphics") provides = "libjpeg" - exports_sources = "CMakeLists.txt" - generators = "cmake" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False], - "SIMD": [True, False], - "arithmetic_encoder": [True, False], - "arithmetic_decoder": [True, False], - "libjpeg7_compatibility": [True, False], - "libjpeg8_compatibility": [True, False], - "mem_src_dst": [True, False], - "turbojpeg": [True, False], - "java": [True, False], - "enable12bit": [True, False]} - default_options = {"shared": False, - "fPIC": True, - "SIMD": True, - "arithmetic_encoder": True, - "arithmetic_decoder": True, - "libjpeg7_compatibility": True, - "libjpeg8_compatibility": True, - "mem_src_dst": True, - "turbojpeg": True, - "java": False, - "enable12bit": False} - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + options = { + "shared": [True, False], + "fPIC": [True, False], + "SIMD": [True, False], + "arithmetic_encoder": [True, False], + "arithmetic_decoder": [True, False], + "libjpeg7_compatibility": [True, False], + "libjpeg8_compatibility": [True, False], + "mem_src_dst": [True, False], + "turbojpeg": [True, False], + "java": [True, False], + "enable12bit": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "SIMD": True, + "arithmetic_encoder": True, + "arithmetic_decoder": True, + "libjpeg7_compatibility": True, + "libjpeg8_compatibility": True, + "mem_src_dst": True, + "turbojpeg": True, + "java": False, + "enable12bit": False, + } + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd if self.options.shared: - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass if self.options.enable12bit: del self.options.java @@ -65,12 +81,24 @@ def configure(self): if self.options.libjpeg8_compatibility: del self.options.mem_src_dst - if self.options.enable12bit and (self.options.libjpeg7_compatibility or self.options.libjpeg8_compatibility): + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.options.enable12bit and (self.info.options.libjpeg7_compatibility or self.info.options.libjpeg8_compatibility): raise ConanInvalidConfiguration("12-bit samples is not allowed with libjpeg v7/v8 API/ABI") - if self.options.get_safe("java", False) and not self.options.shared: + if self.info.options.get_safe("java") and not self.info.options.shared: raise ConanInvalidConfiguration("java wrapper requires shared libjpeg-turbo") - if self.settings.compiler == "Visual Studio" and self.options.shared and str(self.settings.compiler.runtime).startswith("MT"): - raise ConanInvalidConfiguration("shared libjpeg-turbo can't be built with MT or MTd") + if self.info.options.shared and is_msvc(self) and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration(f"{self.ref} shared can't be built with static vc runtime") + + def build_requirements(self): + if self.options.get_safe("SIMD") and self.settings.arch in ["x86", "x86_64"]: + self.tool_requires("nasm/2.15.05") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) @property def _is_arithmetic_encoding_enabled(self): @@ -82,77 +110,89 @@ def _is_arithmetic_decoding_enabled(self): return self.options.get_safe("arithmetic_decoder", False) or \ self.options.libjpeg7_compatibility or self.options.libjpeg8_compatibility - def build_requirements(self): - if self.options.get_safe("SIMD"): - self.build_requires("nasm/2.14") - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self, set_cmake_flags=True) - self._cmake.definitions["ENABLE_STATIC"] = not self.options.shared - self._cmake.definitions["ENABLE_SHARED"] = self.options.shared - self._cmake.definitions["WITH_SIMD"] = self.options.get_safe("SIMD", False) - self._cmake.definitions["WITH_ARITH_ENC"] = self._is_arithmetic_encoding_enabled - self._cmake.definitions["WITH_ARITH_DEC"] = self._is_arithmetic_decoding_enabled - self._cmake.definitions["WITH_JPEG7"] = self.options.libjpeg7_compatibility - self._cmake.definitions["WITH_JPEG8"] = self.options.libjpeg8_compatibility - self._cmake.definitions["WITH_MEM_SRCDST"] = self.options.get_safe("mem_src_dst", False) - self._cmake.definitions["WITH_TURBOJPEG"] = self.options.get_safe("turbojpeg", False) - self._cmake.definitions["WITH_JAVA"] = self.options.get_safe("java", False) - self._cmake.definitions["WITH_12BIT"] = self.options.enable12bit - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["WITH_CRT_DLL"] = True # avoid replacing /MD by /MT in compiler flags - self._cmake.configure() - return self._cmake + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = CMakeToolchain(self) + tc.variables["ENABLE_STATIC"] = not self.options.shared + tc.variables["ENABLE_SHARED"] = self.options.shared + tc.variables["WITH_SIMD"] = self.options.get_safe("SIMD", False) + tc.variables["WITH_ARITH_ENC"] = self._is_arithmetic_encoding_enabled + tc.variables["WITH_ARITH_DEC"] = self._is_arithmetic_decoding_enabled + tc.variables["WITH_JPEG7"] = self.options.libjpeg7_compatibility + tc.variables["WITH_JPEG8"] = self.options.libjpeg8_compatibility + tc.variables["WITH_MEM_SRCDST"] = self.options.get_safe("mem_src_dst", False) + tc.variables["WITH_TURBOJPEG"] = self.options.get_safe("turbojpeg", False) + tc.variables["WITH_JAVA"] = self.options.get_safe("java", False) + tc.variables["WITH_12BIT"] = self.options.enable12bit + if is_msvc(self): + tc.variables["WITH_CRT_DLL"] = True # avoid replacing /MD by /MT in compiler flags + if Version(self.version) <= "2.1.0": + tc.variables["CMAKE_MACOSX_BUNDLE"] = False # avoid configuration error if building for iOS/tvOS/watchOS + if cross_building(self): + # TODO: too specific and error prone, should be delegated to a conan helper function + cmake_system_processor = { + "armv8": "aarch64", + "armv8.3": "aarch64", + }.get(str(self.settings.arch), str(self.settings.arch)) + tc.variables["CONAN_LIBJPEG_TURBO_SYSTEM_PROCESSOR"] = cmake_system_processor + tc.generate() def _patch_sources(self): + apply_conandata_patches(self) + # use standard GNUInstallDirs.cmake - custom one is broken - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "include(cmakescripts/GNUInstallDirs.cmake)", "include(GNUInstallDirs)") # do not override /MT by /MD if shared - tools.replace_in_file(os.path.join(self._source_subfolder, "sharedlib", "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "sharedlib", "CMakeLists.txt"), """string(REGEX REPLACE "/MT" "/MD" ${var} "${${var}}")""", "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() # remove unneeded directories - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "doc")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "doc")) # remove binaries and pdb files for pattern_to_remove in ["cjpeg*", "djpeg*", "jpegtran*", "tjbench*", "wrjpgcom*", "rdjpgcom*", "*.pdb"]: - for bin_file in glob.glob(os.path.join(self.package_folder, "bin", pattern_to_remove)): - os.remove(bin_file) + rm(self, pattern_to_remove, os.path.join(self.package_folder, "bin")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "libjpeg-turbo" - self.cpp_info.names["cmake_find_package_multi"] = "libjpeg-turbo" + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_module_file_name", "JPEG") + self.cpp_info.set_property("cmake_file_name", "libjpeg-turbo") cmake_target_suffix = "-static" if not self.options.shared else "" - lib_suffix = "-static" if self.settings.compiler == "Visual Studio" and not self.options.shared else "" + lib_suffix = "-static" if is_msvc(self) and not self.options.shared else "" + + self.cpp_info.components["jpeg"].set_property("cmake_module_target_name", "JPEG::JPEG") + self.cpp_info.components["jpeg"].set_property("cmake_target_name", f"libjpeg-turbo::jpeg{cmake_target_suffix}") + self.cpp_info.components["jpeg"].set_property("pkg_config_name", "libjpeg") + self.cpp_info.components["jpeg"].libs = [f"jpeg{lib_suffix}"] - self.cpp_info.components["jpeg"].names["cmake_find_package"] = "jpeg" + cmake_target_suffix - self.cpp_info.components["jpeg"].names["cmake_find_package_multi"] = "jpeg" + cmake_target_suffix - self.cpp_info.components["jpeg"].names["pkg_config"] = "libjpeg" - self.cpp_info.components["jpeg"].libs = ["jpeg" + lib_suffix] + if self.options.get_safe("turbojpeg"): + self.cpp_info.components["turbojpeg"].set_property("cmake_target_name", f"libjpeg-turbo::turbojpeg{cmake_target_suffix}") + self.cpp_info.components["turbojpeg"].set_property("pkg_config_name", "libturbojpeg") + self.cpp_info.components["turbojpeg"].libs = [f"turbojpeg{lib_suffix}"] + # TODO: to remove in conan v2 + self.cpp_info.names["cmake_find_package"] = "JPEG" + self.cpp_info.names["cmake_find_package_multi"] = "libjpeg-turbo" + self.cpp_info.components["jpeg"].names["cmake_find_package"] = "JPEG" + self.cpp_info.components["jpeg"].names["cmake_find_package_multi"] = f"jpeg{cmake_target_suffix}" if self.options.get_safe("turbojpeg"): - self.cpp_info.components["turbojpeg"].names["cmake_find_package"] = "turbojpeg" + cmake_target_suffix - self.cpp_info.components["turbojpeg"].names["cmake_find_package_multi"] = "turbojpeg" + cmake_target_suffix - self.cpp_info.components["turbojpeg"].names["pkg_config"] = "libturbojpeg" - self.cpp_info.components["turbojpeg"].libs = ["turbojpeg" + lib_suffix] + self.cpp_info.components["turbojpeg"].names["cmake_find_package"] = f"turbojpeg{cmake_target_suffix}" + self.cpp_info.components["turbojpeg"].names["cmake_find_package_multi"] = f"turbojpeg{cmake_target_suffix}" diff --git a/recipes/libjpeg-turbo/all/patches/2.1.3-0001-fix-cmake.patch b/recipes/libjpeg-turbo/all/patches/2.1.3-0001-fix-cmake.patch new file mode 100644 index 0000000000000..cd50a4ec1f210 --- /dev/null +++ b/recipes/libjpeg-turbo/all/patches/2.1.3-0001-fix-cmake.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1198ece..cea737c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -606,7 +606,7 @@ if(WITH_TURBOJPEG) + set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile.jni) + endif() + if(MSVC) +- configure_file(${CMAKE_SOURCE_DIR}/win/turbojpeg.rc.in ++ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win/turbojpeg.rc.in + ${CMAKE_BINARY_DIR}/win/turbojpeg.rc) + set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} + ${CMAKE_BINARY_DIR}/win/turbojpeg.rc) +diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt +index aea0b9d..612be16 100644 +--- a/sharedlib/CMakeLists.txt ++++ b/sharedlib/CMakeLists.txt +@@ -36,7 +36,7 @@ if(WIN32) + endif() + endif() + if(MSVC) +- configure_file(${CMAKE_SOURCE_DIR}/win/jpeg.rc.in ++ configure_file(../win/jpeg.rc.in + ${CMAKE_BINARY_DIR}/win/jpeg.rc) + set(JPEG_SRCS ${JPEG_SRCS} ${CMAKE_BINARY_DIR}/win/jpeg.rc) + endif() diff --git a/recipes/libjpeg-turbo/all/test_package/CMakeLists.txt b/recipes/libjpeg-turbo/all/test_package/CMakeLists.txt index e550e034e7ceb..8715b08bc7f76 100644 --- a/recipes/libjpeg-turbo/all/test_package/CMakeLists.txt +++ b/recipes/libjpeg-turbo/all/test_package/CMakeLists.txt @@ -1,15 +1,12 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) find_package(libjpeg-turbo REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -if (USE_SHARED) - target_link_libraries(${PROJECT_NAME} PRIVATE libjpeg-turbo::jpeg) +if(TARGET libjpeg-turbo::jpeg) + target_link_libraries(${PROJECT_NAME} PRIVATE libjpeg-turbo::jpeg) else() - target_link_libraries(${PROJECT_NAME} PRIVATE libjpeg-turbo::jpeg-static) + target_link_libraries(${PROJECT_NAME} PRIVATE libjpeg-turbo::jpeg-static) endif() -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/libjpeg-turbo/all/test_package/conanfile.py b/recipes/libjpeg-turbo/all/test_package/conanfile.py index 90fa359ae7099..fb5d85902cc52 100644 --- a/recipes/libjpeg-turbo/all/test_package/conanfile.py +++ b/recipes/libjpeg-turbo/all/test_package/conanfile.py @@ -1,19 +1,27 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) - cmake.definitions["USE_SHARED"] = self.options["libjpeg-turbo"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") img_name = os.path.join(self.source_folder, "testimg.jpg") - bin_path = os.path.join("bin", "test_package") - self.run('%s %s' % (bin_path, img_name), run_environment=True) + self.run(f"{bin_path} {img_name}", env="conanrun") diff --git a/recipes/libjpeg-turbo/all/test_package_module/CMakeLists.txt b/recipes/libjpeg-turbo/all/test_package_module/CMakeLists.txt new file mode 100644 index 0000000000000..b78c6fc513d77 --- /dev/null +++ b/recipes/libjpeg-turbo/all/test_package_module/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) + +find_package(JPEG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE JPEG::JPEG) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/libjpeg-turbo/all/test_package_module/conanfile.py b/recipes/libjpeg-turbo/all/test_package_module/conanfile.py new file mode 100644 index 0000000000000..fd19bb1425057 --- /dev/null +++ b/recipes/libjpeg-turbo/all/test_package_module/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + img_name = os.path.join(self.source_folder, os.pardir, "test_package", "testimg.jpg") + self.run(f"{bin_path} {img_name}", env="conanrun") diff --git a/recipes/libjpeg-turbo/all/test_v1_package/CMakeLists.txt b/recipes/libjpeg-turbo/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libjpeg-turbo/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libjpeg-turbo/all/test_v1_package/conanfile.py b/recipes/libjpeg-turbo/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a2b04c499e0ac --- /dev/null +++ b/recipes/libjpeg-turbo/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + img_name = os.path.join(self.source_folder, os.pardir, "test_package", "testimg.jpg") + self.run(f"{bin_path} {img_name}", run_environment=True) diff --git a/recipes/libjpeg-turbo/all/test_v1_package_module/CMakeLists.txt b/recipes/libjpeg-turbo/all/test_v1_package_module/CMakeLists.txt new file mode 100644 index 0000000000000..27f7a57e7a0b3 --- /dev/null +++ b/recipes/libjpeg-turbo/all/test_v1_package_module/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package_module + ${CMAKE_CURRENT_BINARY_DIR}/test_package_module) diff --git a/recipes/libjpeg-turbo/all/test_v1_package_module/conanfile.py b/recipes/libjpeg-turbo/all/test_v1_package_module/conanfile.py new file mode 100644 index 0000000000000..b6600e428515c --- /dev/null +++ b/recipes/libjpeg-turbo/all/test_v1_package_module/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + img_name = os.path.join(self.source_folder, os.pardir, "test_package", "testimg.jpg") + self.run(f"{bin_path} {img_name}", run_environment=True) diff --git a/recipes/libjpeg-turbo/config.yml b/recipes/libjpeg-turbo/config.yml index a1456044f1df2..8b2c022f29e5c 100644 --- a/recipes/libjpeg-turbo/config.yml +++ b/recipes/libjpeg-turbo/config.yml @@ -1,11 +1,15 @@ versions: - "2.0.2": + "2.1.4": folder: all - "2.0.4": + "2.1.3": folder: all - "2.0.5": + "2.1.2": folder: all - "2.0.6": + "2.1.1": folder: all "2.1.0": folder: all + "2.0.6": + folder: all + "2.0.5": + folder: all diff --git a/recipes/libjpeg/all/Win32.Mak b/recipes/libjpeg/all/Win32.Mak index 5a0c65e6b1787..d3345df3a31cf 100644 --- a/recipes/libjpeg/all/Win32.Mak +++ b/recipes/libjpeg/all/Win32.Mak @@ -308,7 +308,7 @@ cdebug = -Gh -Ox -DNDEBUG !ELSE IFDEF TUNE cdebug = -Gh -Ox -DNDEBUG !ELSE -cdebug = -Zi -Od -DDEBUG +cdebug = -Zi -Od -DDEBUG -Fdlibjpeg.pdb !ENDIF !ELSE @@ -316,7 +316,7 @@ cdebug = -Zi -Od -DDEBUG !IFDEF NODEBUG cdebug = -Ox -DNDEBUG !ELSE -cdebug = -Zi -Od -DDEBUG +cdebug = -Zi -Od -DDEBUG -Fdlibjpeg.pdb !ENDIF !ENDIF diff --git a/recipes/libjpeg/all/conandata.yml b/recipes/libjpeg/all/conandata.yml index 46a3f952593cf..772d543a52140 100644 --- a/recipes/libjpeg/all/conandata.yml +++ b/recipes/libjpeg/all/conandata.yml @@ -1,14 +1,17 @@ sources: - "9c": - url: "http://ijg.org/files/jpegsrc.v9c.tar.gz" - sha256: "1e9793e1c6ba66e7e0b6e5fe7fd0f9e935cc697854d5737adec54d93e5b3f730" + "9e": + url: "http://ijg.org/files/jpegsrc.v9e.tar.gz" + sha256: "4077d6a6a75aeb01884f708919d25934c93305e49f7e3f36db9129320e6f4f3d" "9d": url: "http://ijg.org/files/jpegsrc.v9d.tar.gz" - sha256: "6c434a3be59f8f62425b2e3c077e785c9ce30ee5874ea1c270e843f273ba71ee" -patches: + sha256: "2303a6acfb6cc533e0e86e8a9d29f7e6079e118b9de3f96e07a71a11c082fa6a" "9c": - - patch_file: "patches/0001-libjpeg-add-msvc-dll-support.patch" - base_path: "source_subfolder" + url: "http://ijg.org/files/jpegsrc.v9c.tar.gz" + sha256: "682aee469c3ca857c4c38c37a6edadbfca4b04d42e56613b11590ec6aa4a278d" +patches: + "9e": + - patch_file: "patches/0001-9e-libjpeg-add-msvc-dll-support.patch" "9d": - patch_file: "patches/0001-libjpeg-add-msvc-dll-support.patch" - base_path: "source_subfolder" + "9c": + - patch_file: "patches/0001-libjpeg-add-msvc-dll-support.patch" diff --git a/recipes/libjpeg/all/conanfile.py b/recipes/libjpeg/all/conanfile.py index e30cfdb825541..a3daa952b7fe2 100644 --- a/recipes/libjpeg/all/conanfile.py +++ b/recipes/libjpeg/all/conanfile.py @@ -1,26 +1,46 @@ +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, load, replace_in_file, rm, rmdir, save +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, unix_path, VCVars import os import re import shutil -from conans import ConanFile, AutoToolsBuildEnvironment, tools + +required_conan_version = ">=1.53.0" class LibjpegConan(ConanFile): name = "libjpeg" description = "Libjpeg is a widely used C library for reading and writing JPEG image files." url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "image", "format", "jpg", "jpeg", "picture", "multimedia", "graphics") - license = "http://ijg.org/files/README" + topics = ("image", "format", "jpg", "jpeg", "picture", "multimedia", "graphics") + license = "IJG" homepage = "http://ijg.org" - exports_sources = ["Win32.Mak", "patches/**"] + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - _autotools = None + @property + def _is_clang_cl(self): + return self.settings.os == "Windows" and self.settings.compiler == "clang" @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + copy(self, "Win32.Mak", src=self.recipe_folder, dst=self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -28,120 +48,134 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") def build_requirements(self): - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio" and \ - not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows" and not (is_msvc(self) or self. _is_clang_cl): + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + self.win_bash = True def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("jpeg-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + if is_msvc(self) or self._is_clang_cl: + vc = VCVars(self) + vc.generate() + env = Environment() + env.define("PROFILE", None) + env.define("TUNE", None) + env.define("NODEBUG", None) + # FIXME: no conan v2 build helper for NMake yet (see https://github.com/conan-io/conan/issues/12188) + # So populate CL with AutotoolsToolchain cflags + c_flags = AutotoolsToolchain(self).cflags + if c_flags: + env.define("CL", c_flags) + env.vars(self).save_script("conanbuildenv_nmake") + # TODO: there is probably something missing here + # Do we really honor everything from profile (build_type, tools.build:cflags etc)? + else: + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.extra_defines.append("LIBJPEG_BUILDING") + tc.generate() def _build_nmake(self): - shutil.copy("Win32.Mak", os.path.join(self._source_subfolder, "Win32.Mak")) - tools.replace_in_file(os.path.join(self._source_subfolder, "Win32.Mak"), - "\nccommon = -c ", - "\nccommon = -c -DLIBJPEG_BUILDING {}".format("" if self.options.shared else "-DLIBJPEG_STATIC ")) - with tools.chdir(self._source_subfolder): + copy(self, "Win32.Mak", src=os.path.join(self.source_folder, os.pardir), dst=self.source_folder) + with chdir(self, self.source_folder): + # export symbols if shared + replace_in_file( + self, + "Win32.Mak", + "\nccommon = -c ", + "\nccommon = -c -DLIBJPEG_BUILDING {}".format("" if self.options.shared else "-DLIBJPEG_STATIC "), + ) + # clean environment variables that might affect on the build (e.g. if set by Jenkins) shutil.copy("jconfig.vc", "jconfig.h") make_args = [ - "nodebug=1" if self.settings.build_type != 'Debug' else "", + "nodebug=1" if self.settings.build_type != "Debug" else "", ] + if self._is_clang_cl: + cl = os.environ.get("CC", "clang-cl") + link = os.environ.get("LD", "lld-link") + lib = os.environ.get("AR", "llvm-lib") + rc = os.environ.get("RC", "llvm-rc") + replace_in_file(self, "Win32.Mak", "cc = cl", f"cc = {cl}") + replace_in_file(self, "Win32.Mak", "link = link", f"link = {link}") + replace_in_file(self, "Win32.Mak", "implib = lib", f"implib = {lib}") + replace_in_file(self, "Win32.Mak", "rc = Rc", f"rc = {rc}") # set flags directly in makefile.vc # cflags are critical for the library. ldflags and ldlibs are only for binaries - if self.settings.compiler.runtime in ["MD", "MDd"]: - tools.replace_in_file("makefile.vc", "(cvars)", "(cvarsdll)") - tools.replace_in_file("makefile.vc", "(conlibs)", "(conlibsdll)") + if is_msvc_static_runtime(self): + replace_in_file(self, "makefile.vc", "(cvars)", "(cvarsmt)") + replace_in_file(self, "makefile.vc", "(conlibs)", "(conlibsmt)") else: - tools.replace_in_file("makefile.vc", "(cvars)", "(cvarsmt)") - tools.replace_in_file("makefile.vc", "(conlibs)", "(conlibsmt)") - target = "{}/libjpeg.lib".format( "shared" if self.options.shared else "static" ) - with tools.vcvars(self.settings): - self.run("nmake -f makefile.vc {} {}".format(" ".join(make_args), target)) - - def _configure_autotools(self): - """For unix and mingw environments""" - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.defines.append("LIBJPEG_BUILDING") - config_args = [ - "--prefix={}".format(tools.unix_path(self.package_folder)), - ] - if self.options.shared: - config_args.extend(["--enable-shared=yes", "--enable-static=no"]) - else: - config_args.extend(["--enable-shared=no", "--enable-static=yes"]) - - if self.settings.os == "Windows": - mingw_arch = { - "x86_64": "x86_64", - "x86": "i686", - } - build_triplet = host_triplet = "{}-w64-mingw32".format(mingw_arch[str(self.settings.arch)]) - config_args.extend([ - "--build={}".format(build_triplet), - "--host={}".format(host_triplet), - ]) - - self._autotools.configure(configure_dir=self._source_subfolder, args=config_args) - return self._autotools - - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + replace_in_file(self, "makefile.vc", "(cvars)", "(cvarsdll)") + replace_in_file(self, "makefile.vc", "(conlibs)", "(conlibsdll)") + target = "{}/libjpeg.lib".format("shared" if self.options.shared else "static") + self.run("nmake -f makefile.vc {} {}".format(" ".join(make_args), target)) def build(self): - self._patch_sources() - if self.settings.compiler == "Visual Studio": + apply_conandata_patches(self) + if is_msvc(self) or self._is_clang_cl: self._build_nmake() else: - autotools = self._configure_autotools() + autotools = Autotools(self) + autotools.configure() autotools.make() def package(self): - self.copy("README", src=self._source_subfolder, dst="licenses", ignore_case=True, keep_path=False) - if self.settings.compiler == "Visual Studio": + copy(self, "README", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if is_msvc(self) or self._is_clang_cl: for filename in ["jpeglib.h", "jerror.h", "jconfig.h", "jmorecfg.h"]: - self.copy(pattern=filename, dst="include", src=self._source_subfolder, keep_path=False) + copy(self, filename, src=self.source_folder, dst=os.path.join(self.package_folder, "include"), keep_path=False) - self.copy(pattern="*.lib", dst="lib", src=self._source_subfolder, keep_path=False) + copy(self, "*.lib", src=self.source_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) if self.options.shared: - self.copy(pattern="*.dll", dst="bin", src=self._source_subfolder, keep_path=False) + copy(self, "*.dll", src=self.source_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False) else: - autotools = self._configure_autotools() - autotools.install() - os.unlink(os.path.join(self.package_folder, "lib", "libjpeg.la")) - - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) - - bindir = os.path.join(self.package_folder, "bin") - for file in os.listdir(bindir): - if file.endswith(".exe"): - os.unlink(os.path.join(bindir, file)) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + if self.settings.os == "Windows" and self.options.shared: + rm(self, "*[!.dll]", os.path.join(self.package_folder, "bin")) + else: + rmdir(self, os.path.join(self.package_folder, "bin")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + fix_apple_shared_install_name(self) for fn in ("jpegint.h", "transupp.h",): - self.copy(fn, src=self._source_subfolder, dst="include") + copy(self, fn, src=self.source_folder, dst=os.path.join(self.package_folder, "include")) for fn in ("jinclude.h", "transupp.c",): - self.copy(fn, src=self._source_subfolder, dst="res") + copy(self, fn, src=self.source_folder, dst=os.path.join(self.package_folder, "res")) # Remove export decorations of transupp symbols for relpath in os.path.join("include", "transupp.h"), os.path.join("res", "transupp.c"): path = os.path.join(self.package_folder, relpath) - tools.save(path, re.subn(r"(?:EXTERN|GLOBAL)\(([^)]+)\)", r"\1", tools.load(path))[0]) + save(self, path, re.subn(r"(?:EXTERN|GLOBAL)\(([^)]+)\)", r"\1", load(self, path))[0]) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "JPEG" - self.cpp_info.names["cmake_find_package_multi"] = "JPEG" - if self.settings.compiler == "Visual Studio": - self.cpp_info.libs = ["libjpeg"] - else: - self.cpp_info.libs = ["jpeg"] + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "JPEG") + self.cpp_info.set_property("cmake_target_name", "JPEG::JPEG") + self.cpp_info.set_property("pkg_config_name", "libjpeg") + prefix = "lib" if is_msvc(self) or self._is_clang_cl else "" + self.cpp_info.libs = [f"{prefix}jpeg"] + self.cpp_info.resdirs = ["res"] if not self.options.shared: self.cpp_info.defines.append("LIBJPEG_STATIC") + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.names["cmake_find_package"] = "JPEG" + self.cpp_info.names["cmake_find_package_multi"] = "JPEG" diff --git a/recipes/libjpeg/all/patches/0001-9e-libjpeg-add-msvc-dll-support.patch b/recipes/libjpeg/all/patches/0001-9e-libjpeg-add-msvc-dll-support.patch new file mode 100644 index 0000000000000..c3f634ab1ed84 --- /dev/null +++ b/recipes/libjpeg/all/patches/0001-9e-libjpeg-add-msvc-dll-support.patch @@ -0,0 +1,92 @@ +--- jmorecfg.h ++++ jmorecfg.h +@@ -238,14 +238,26 @@ + * or code profilers that require it. + */ + ++#if defined(_MSC_VER) ++#if defined(LIBJPEG_STATIC) ++#define LIBJPEG_EXPORTS ++#elif !defined(LIBJPEG_BUILDING) ++#define LIBJPEG_EXPORTS __declspec(dllimport) ++#else ++#define LIBJPEG_EXPORTS __declspec(dllexport) ++#endif ++#else ++#define LIBJPEG_EXPORTS ++#endif ++ + /* a function called through method pointers: */ + #define METHODDEF(type) static type + /* a function used only in its module: */ + #define LOCAL(type) static type + /* a function referenced thru EXTERNs: */ +-#define GLOBAL(type) type ++#define GLOBAL(type) LIBJPEG_EXPORTS type + /* a reference to a GLOBAL function: */ +-#define EXTERN(type) extern type ++#define EXTERN(type) extern GLOBAL(type) + + + /* This macro is used to declare a "method", that is, a function pointer. + +--- makefile.vc ++++ makefile.vc +@@ -30,6 +30,7 @@ + # miscellaneous OS-dependent stuff + # file deletion command + RM= del ++MKDIR=mkdir + + # End of configurable options. + +@@ -108,20 +109,30 @@ + $(cc) $(CFLAGS) $*.c + + +-all: libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe ++all: shared/libjpeg.lib static/libjpeg.lib cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe + +-libjpeg.lib: $(LIBOBJECTS) +- $(RM) libjpeg.lib +- lib -out:libjpeg.lib $(LIBOBJECTS) ++shared: ++ $(MKDIR) shared ++ ++static: ++ $(MKDIR) static ++ ++static/libjpeg.lib: $(LIBOBJECTS) static ++ $(RM) static\libjpeg.lib ++ lib -out:static/libjpeg.lib $(LIBOBJECTS) ++ ++shared/libjpeg.lib shared/libjpeg-9.dll: $(LIBOBJECTS) shared ++ $(RM) shared\libjpeg.lib shared\libjpeg-9.dll ++ link -DLL -out:shared/libjpeg-9.dll -implib:shared/libjpeg.lib $(LIBOBJECTS) + +-cjpeg.exe: $(COBJECTS) libjpeg.lib +- $(link) $(LDFLAGS) -out:cjpeg.exe $(COBJECTS) libjpeg.lib $(LDLIBS) ++cjpeg.exe: $(COBJECTS) static/libjpeg.lib ++ $(link) $(LDFLAGS) -out:cjpeg.exe $(COBJECTS) static/libjpeg.lib $(LDLIBS) + +-djpeg.exe: $(DOBJECTS) libjpeg.lib +- $(link) $(LDFLAGS) -out:djpeg.exe $(DOBJECTS) libjpeg.lib $(LDLIBS) ++djpeg.exe: $(DOBJECTS) static/libjpeg.lib ++ $(link) $(LDFLAGS) -out:djpeg.exe $(DOBJECTS) static/libjpeg.lib $(LDLIBS) + +-jpegtran.exe: $(TROBJECTS) libjpeg.lib +- $(link) $(LDFLAGS) -out:jpegtran.exe $(TROBJECTS) libjpeg.lib $(LDLIBS) ++jpegtran.exe: $(TROBJECTS) static/libjpeg.lib ++ $(link) $(LDFLAGS) -out:jpegtran.exe $(TROBJECTS) static/libjpeg.lib $(LDLIBS) + + rdjpgcom.exe: rdjpgcom.obj + $(link) $(LDFLAGS) -out:rdjpgcom.exe rdjpgcom.obj $(LDLIBS) +@@ -131,7 +142,7 @@ + + + clean: +- $(RM) *.obj *.exe libjpeg.lib ++ $(RM) *.obj *.exe static\libjpeg.lib shared\libjpeg.lib shared\libjpeg-9.dll + $(RM) testout* + + setup-vc6: diff --git a/recipes/libjpeg/all/test_package/CMakeLists.txt b/recipes/libjpeg/all/test_package/CMakeLists.txt index 6bbc5e332c193..f6e52def00111 100644 --- a/recipes/libjpeg/all/test_package/CMakeLists.txt +++ b/recipes/libjpeg/all/test_package/CMakeLists.txt @@ -1,8 +1,5 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) @@ -11,9 +8,11 @@ endif() find_package(JPEG REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} JPEG::JPEG) -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) +target_link_libraries(${PROJECT_NAME} PRIVATE JPEG::JPEG) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) -add_executable(test_transupp test_transupp.c "${CONAN_LIBJPEG_ROOT}/res/transupp.c") -target_link_libraries(test_transupp JPEG::JPEG) -set_property(TARGET test_transupp PROPERTY C_STANDARD 99) +if(BUILD_TRANSUPP) + add_executable(test_transupp test_transupp.c ${LIBJPEG_RES_DIR}/transupp.c) + target_link_libraries(test_transupp PRIVATE JPEG::JPEG) + target_compile_features(test_transupp PRIVATE c_std_99) +endif() diff --git a/recipes/libjpeg/all/test_package/conanfile.py b/recipes/libjpeg/all/test_package/conanfile.py index ed8048ce54b18..0243933ba22dd 100644 --- a/recipes/libjpeg/all/test_package/conanfile.py +++ b/recipes/libjpeg/all/test_package/conanfile.py @@ -1,15 +1,32 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" @property - def _test_transupp(self): + def _build_transupp(self): # transupp+libjpeg makes use of stdio of the C library. This cannot be used when using a dll libjpeg, built with a static c library. - return not (self.options["libjpeg"].shared and self.settings.compiler == "Visual Studio" and "MT" in self.settings.compiler.runtime) + return not (self.dependencies["libjpeg"].options.shared and is_msvc(self) and is_msvc_static_runtime(self)) + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TRANSUPP"] = self._build_transupp + if self._build_transupp: + tc.variables["LIBJPEG_RES_DIR"] = self.dependencies["libjpeg"].cpp_info.resdirs[0].replace("\\", "/") + tc.generate() def build(self): cmake = CMake(self) @@ -17,10 +34,11 @@ def build(self): cmake.build() def test(self): - if tools.cross_building(self.settings): - return - img_name = os.path.join(self.source_folder, "testimg.jpg") - out_img = os.path.join(self.build_folder, "outimg.jpg") - self.run("%s %s" % (os.path.join("bin", "test_package"), img_name), run_environment=True) - if self._test_transupp: - self.run("%s %s %s" % (os.path.join("bin", "test_transupp"), img_name, out_img), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + img_name = os.path.join(self.source_folder, "testimg.jpg") + self.run(f"{bin_path} {img_name}", env="conanrun") + test_transupp_path = os.path.join(self.cpp.build.bindirs[0], "test_transupp") + if os.path.exists(test_transupp_path): + out_img = os.path.join(self.build_folder, "outimg.jpg") + self.run(f"{test_transupp_path} {img_name} {out_img}", env="conanrun") diff --git a/recipes/libjpeg/all/test_v1_package/CMakeLists.txt b/recipes/libjpeg/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e6eccdbfe8184 --- /dev/null +++ b/recipes/libjpeg/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +if(MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) +endif() + +find_package(JPEG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE JPEG::JPEG) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) + +add_executable(test_transupp ../test_package/test_transupp.c "${CONAN_LIBJPEG_ROOT}/res/transupp.c") +target_link_libraries(test_transupp PRIVATE JPEG::JPEG) +target_compile_features(test_transupp PRIVATE c_std_99) diff --git a/recipes/libjpeg/all/test_v1_package/conanfile.py b/recipes/libjpeg/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..d9893410defb6 --- /dev/null +++ b/recipes/libjpeg/all/test_v1_package/conanfile.py @@ -0,0 +1,28 @@ +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + @property + def _test_transupp(self): + # transupp+libjpeg makes use of stdio of the C library. This cannot be used when using a dll libjpeg, built with a static c library. + return not (self.options["libjpeg"].shared and is_msvc(self) and is_msvc_static_runtime(self)) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + img_name = os.path.join(self.source_folder, os.pardir, "test_package", "testimg.jpg") + self.run(f"{bin_path} {img_name}", run_environment=True) + if self._test_transupp: + test_transupp_path = os.path.join("bin", "test_transupp") + out_img = os.path.join(self.build_folder, "outimg.jpg") + self.run(f"{test_transupp_path} {img_name} {out_img}", run_environment=True) diff --git a/recipes/libjpeg/config.yml b/recipes/libjpeg/config.yml index 6f2a13bf19d78..6c44911f307cd 100644 --- a/recipes/libjpeg/config.yml +++ b/recipes/libjpeg/config.yml @@ -1,5 +1,7 @@ versions: - "9c": - folder: all - "9d": - folder: all + "9e": + folder: all + "9d": + folder: all + "9c": + folder: all diff --git a/recipes/pcre/all/CMakeLists.txt b/recipes/libjxl/all/CMakeLists.txt similarity index 100% rename from recipes/pcre/all/CMakeLists.txt rename to recipes/libjxl/all/CMakeLists.txt diff --git a/recipes/libjxl/all/conandata.yml b/recipes/libjxl/all/conandata.yml new file mode 100644 index 0000000000000..8a3abcae1301c --- /dev/null +++ b/recipes/libjxl/all/conandata.yml @@ -0,0 +1,18 @@ +sources: + "0.5.0": + url: "https://github.com/libjxl/libjxl/archive/v0.5.zip" + sha256: "a208be41542c6f81f10a82c6bb4bc75d3eceb9d4f7ecb6ea0ad2f2d236694c4b" + "0.6.1": + url: "https://github.com/libjxl/libjxl/archive/v0.6.1.zip" + sha256: "3e4877daef07724aa6f490bf80c45ada804f35fe3cce59c27e89c5ae3099535a" +patches: + "0.5.0": + - patch_file: "patches/0001-clean-targets-v0.5.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-fix-dependencies-v0.5.patch" + base_path: "source_subfolder" + "0.6.1": + - patch_file: "patches/0001-clean-targets-v0.6.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-fix-dependencies-v0.6.patch" + base_path: "source_subfolder" diff --git a/recipes/libjxl/all/conanfile.py b/recipes/libjxl/all/conanfile.py new file mode 100644 index 0000000000000..a8d214a9a78ab --- /dev/null +++ b/recipes/libjxl/all/conanfile.py @@ -0,0 +1,127 @@ +from conans import ConanFile, CMake, tools +import os +import shutil +import glob + +required_conan_version = ">=1.33.0" + + +class LibjxlConan(ConanFile): + name = "libjxl" + description = "JPEG XL image format reference implementation" + license = "BSD-3-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/libjxl/libjxl" + topics = ("image", "jpeg-xl", "jxl", "jpeg") + + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + exports_sources = "CMakeLists.txt", "patches/**" + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("brotli/1.0.9") + self.requires("highway/0.12.2") + self.requires("lcms/2.11") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_TESTING"] = False + self._cmake.definitions["JPEGXL_STATIC"] = not self.options.shared + self._cmake.definitions["JPEGXL_ENABLE_BENCHMARK"] = False + self._cmake.definitions["JPEGXL_ENABLE_EXAMPLES"] = False + self._cmake.definitions["JPEGXL_ENABLE_MANPAGES"] = False + self._cmake.definitions["JPEGXL_ENABLE_SJPEG"] = False + self._cmake.definitions["JPEGXL_ENABLE_OPENEXR"] = False + self._cmake.definitions["JPEGXL_ENABLE_SKCMS"] = False + self._cmake.definitions["JPEGXL_ENABLE_TCMALLOC"] = False + if tools.cross_building(self): + self._cmake.definitions["CMAKE_SYSTEM_PROCESSOR"] = \ + str(self.settings.arch) + self._cmake.configure() + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + if self.options.shared: + libs_dir = os.path.join(self.package_folder, "lib") + tools.remove_files_by_mask(libs_dir, "*.a") + tools.remove_files_by_mask(libs_dir, "*-static.lib") + + if self.settings.os == "Windows": + self.copy("jxl_dec.dll", src="bin", dst="bin") + self.copy("jxl_dec.lib", src="lib", dst="lib") + for dll_path in glob.glob(os.path.join(libs_dir, "*.dll")): + shutil.move(dll_path, os.path.join(self.package_folder, + "bin", os.path.basename(dll_path))) + else: + self.copy("libjxl_dec.*", src="lib", dst="lib") + + def _lib_name(self, name): + if not self.options.shared and self.settings.os == "Windows": + return name + "-static" + return name + + def package_info(self): + # jxl + self.cpp_info.components["jxl"].names["pkg_config"] = "libjxl" + self.cpp_info.components["jxl"].libs = [self._lib_name("jxl")] + self.cpp_info.components["jxl"].requires = ["brotli::brotli", + "highway::highway", + "lcms::lcms"] + # jxl_dec + self.cpp_info.components["jxl_dec"].names["pkg_config"] = "libjxl_dec" + self.cpp_info.components["jxl_dec"].libs = [self._lib_name("jxl_dec")] + self.cpp_info.components["jxl_dec"].requires = ["brotli::brotli", + "highway::highway", + "lcms::lcms"] + # jxl_threads + self.cpp_info.components["jxl_threads"].names["pkg_config"] = \ + "libjxl_threads" + self.cpp_info.components["jxl_threads"].libs = \ + [self._lib_name("jxl_threads")] + if self.settings.os == "Linux": + self.cpp_info.components["jxl_threads"].system_libs = ["pthread"] + + if not self.options.shared and tools.stdcpp_library(self): + self.cpp_info.components["jxl"].system_libs.append( + tools.stdcpp_library(self)) + self.cpp_info.components["jxl_dec"].system_libs.append( + tools.stdcpp_library(self)) + self.cpp_info.components["jxl_threads"].system_libs.append( + tools.stdcpp_library(self)) diff --git a/recipes/libjxl/all/patches/0001-clean-targets-v0.5.patch b/recipes/libjxl/all/patches/0001-clean-targets-v0.5.patch new file mode 100644 index 0000000000000..1f47c925782ce --- /dev/null +++ b/recipes/libjxl/all/patches/0001-clean-targets-v0.5.patch @@ -0,0 +1,38 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -150,8 +150,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + if(JPEGXL_STATIC) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) + set(BUILD_SHARED_LIBS 0) +- set(CMAKE_EXE_LINKER_FLAGS +- "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++") + if (MINGW) + # In MINGW libstdc++ uses pthreads directly. When building statically a + # program (regardless of whether the source code uses pthread or not) the +@@ -247,8 +245,6 @@ set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_STANDARD_REQUIRED YES) + +-add_subdirectory(third_party) +- + set(THREADS_PREFER_PTHREAD_FLAG YES) + find_package(Threads REQUIRED) + +@@ -331,6 +327,3 @@ endif () + if (${JPEGXL_ENABLE_PLUGINS}) + add_subdirectory(plugins) + endif () +- +-# Binary tools +-add_subdirectory(tools) + +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -119,7 +119,6 @@ endif() #!MSVC + include(jxl.cmake) + + # Other libraries outside the core jxl library. +-include(jxl_extras.cmake) + include(jxl_threads.cmake) + + # Install all the library headers from the source and the generated ones. There diff --git a/recipes/libjxl/all/patches/0001-clean-targets-v0.6.patch b/recipes/libjxl/all/patches/0001-clean-targets-v0.6.patch new file mode 100644 index 0000000000000..e59af39610354 --- /dev/null +++ b/recipes/libjxl/all/patches/0001-clean-targets-v0.6.patch @@ -0,0 +1,36 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -161,6 +161,4 @@ # ourselves; for real use case we don't care about stdlib, as it is "granted", + # so just linking all other libraries is fine. + if (NOT APPLE) +- set(CMAKE_EXE_LINKER_FLAGS +- "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++") + endif() + endif() # JPEGXL_STATIC +@@ -278,8 +277,6 @@ set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_STANDARD_REQUIRED YES) + +-add_subdirectory(third_party) +- + # Copy the JXL license file to the output build directory. + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" + ${PROJECT_BINARY_DIR}/LICENSE.jpeg-xl COPYONLY) +@@ -380,6 +376,3 @@ # Plugins for third-party software + if (${JPEGXL_ENABLE_PLUGINS}) + add_subdirectory(plugins) + endif () +- +-# Binary tools +-add_subdirectory(tools) + +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -132,7 +132,6 @@ # The jxl library definition. + include(jxl.cmake) + + # Other libraries outside the core jxl library. +-include(jxl_extras.cmake) + include(jxl_threads.cmake) + + # Install all the library headers from the source and the generated ones. There diff --git a/recipes/libjxl/all/patches/0002-fix-dependencies-v0.5.patch b/recipes/libjxl/all/patches/0002-fix-dependencies-v0.5.patch new file mode 100644 index 0000000000000..8ec6fc1cb0d9d --- /dev/null +++ b/recipes/libjxl/all/patches/0002-fix-dependencies-v0.5.patch @@ -0,0 +1,106 @@ +--- a/lib/jxl.cmake ++++ b/lib/jxl.cmake +@@ -328,7 +328,7 @@ if (JPEGXL_ENABLE_SKCMS) + list(APPEND JPEGXL_INTERNAL_FLAGS -DJPEGXL_ENABLE_SKCMS=1) + list(APPEND JPEGXL_INTERNAL_LIBS skcms) + else () +- list(APPEND JPEGXL_INTERNAL_LIBS lcms2) ++ list(APPEND JPEGXL_INTERNAL_LIBS ${CONAN_LIBS_LCMS}) + endif () + + if (NOT JPEGXL_ENABLE_TRANSCODE_JPEG) +@@ -353,8 +353,6 @@ set_property(TARGET jxl_dec-obj PROPERTY POSITION_INDEPENDENT_CODE ON) + target_include_directories(jxl_dec-obj PUBLIC + ${PROJECT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include +- $ +- $ + ) + target_compile_definitions(jxl_dec-obj PUBLIC + ${OBJ_COMPILE_DEFINITIONS} +@@ -371,8 +369,6 @@ set_property(TARGET jxl_enc-obj PROPERTY POSITION_INDEPENDENT_CODE ON) + target_include_directories(jxl_enc-obj PUBLIC + ${PROJECT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include +- $ +- $ + ) + target_compile_definitions(jxl_enc-obj PUBLIC + ${OBJ_COMPILE_DEFINITIONS} +@@ -381,23 +377,6 @@ if (JPEGXL_ENABLE_PROFILER) + target_link_libraries(jxl_enc-obj PUBLIC jxl_profiler) + endif() + +-#TODO(lode): don't depend on CMS for the core library +-if (JPEGXL_ENABLE_SKCMS) +- target_include_directories(jxl_enc-obj PRIVATE +- $ +- ) +- target_include_directories(jxl_dec-obj PRIVATE +- $ +- ) +-else () +- target_include_directories(jxl_enc-obj PRIVATE +- $ +- ) +- target_include_directories(jxl_dec-obj PRIVATE +- $ +- ) +-endif () +- + # Headers for exporting/importing public headers + include(GenerateExportHeader) + # TODO(deymo): Add these visibility properties to the static dependencies of +@@ -416,9 +395,6 @@ set_target_properties(jxl_enc-obj PROPERTIES + VISIBILITY_INLINES_HIDDEN 1 + DEFINE_SYMBOL JXL_INTERNAL_LIBRARY_BUILD + ) +-generate_export_header(jxl_enc-obj +- BASE_NAME JXL +- EXPORT_FILE_NAME include/jxl/jxl_export.h) + target_include_directories(jxl_enc-obj PUBLIC + ${CMAKE_CURRENT_BINARY_DIR}/include) + +@@ -496,9 +472,8 @@ if (((NOT DEFINED "${TARGET_SUPPORTS_SHARED_LIBS}") OR + add_library(jxl SHARED + $ + $) +-strip_static(JPEGXL_INTERNAL_SHARED_LIBS JPEGXL_INTERNAL_LIBS) + target_link_libraries(jxl PUBLIC ${JPEGXL_COVERAGE_FLAGS}) +-target_link_libraries(jxl PRIVATE ${JPEGXL_INTERNAL_SHARED_LIBS}) ++target_link_libraries(jxl PRIVATE ${JPEGXL_INTERNAL_LIBS}) + # Shared library include path contains only the "include/" paths. + target_include_directories(jxl PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/include" +@@ -507,13 +482,13 @@ set_target_properties(jxl PROPERTIES + VERSION ${JPEGXL_LIBRARY_VERSION} + SOVERSION ${JPEGXL_LIBRARY_SOVERSION} + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" +- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") ++ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ++ DEFINE_SYMBOL JXL_INTERNAL_LIBRARY_BUILD) + + # Public shared decoder library. + add_library(jxl_dec SHARED $) +-strip_static(JPEGXL_DEC_INTERNAL_SHARED_LIBS JPEGXL_DEC_INTERNAL_LIBS) + target_link_libraries(jxl_dec PUBLIC ${JPEGXL_COVERAGE_FLAGS}) +-target_link_libraries(jxl_dec PRIVATE ${JPEGXL_DEC_INTERNAL_SHARED_LIBS}) ++target_link_libraries(jxl_dec PRIVATE ${JPEGXL_DEC_INTERNAL_LIBS}) + # Shared library include path contains only the "include/" paths. + target_include_directories(jxl_dec PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/include" +@@ -549,8 +524,14 @@ install(TARGETS jxl + else() + add_library(jxl ALIAS jxl-static) + add_library(jxl_dec ALIAS jxl_dec-static) ++set_target_properties(jxl-static PROPERTIES ++ DEFINE_SYMBOL JXL_INTERNAL_LIBRARY_BUILD) + endif() # TARGET_SUPPORTS_SHARED_LIBS AND NOT JPEGXL_STATIC + ++generate_export_header(jxl ++ BASE_NAME JXL ++ EXPORT_FILE_NAME include/jxl/jxl_export.h) ++ + # Add a pkg-config file for libjxl. + set(JPEGXL_LIBRARY_REQUIRES + "libhwy libbrotlicommon libbrotlienc libbrotlidec") diff --git a/recipes/libjxl/all/patches/0002-fix-dependencies-v0.6.patch b/recipes/libjxl/all/patches/0002-fix-dependencies-v0.6.patch new file mode 100644 index 0000000000000..b4ff403da499f --- /dev/null +++ b/recipes/libjxl/all/patches/0002-fix-dependencies-v0.6.patch @@ -0,0 +1,126 @@ +--- a/lib/jxl.cmake ++++ b/lib/jxl.cmake +@@ -334,7 +334,7 @@ if (JPEGXL_ENABLE_SKCMS) + list(APPEND JPEGXL_INTERNAL_LIBS skcms) + endif () + else () +- list(APPEND JPEGXL_INTERNAL_LIBS lcms2) ++ list(APPEND JPEGXL_INTERNAL_LIBS ${CONAN_LIBS_LCMS}) + endif () + + if (NOT JPEGXL_ENABLE_TRANSCODE_JPEG) +@@ -359,8 +359,6 @@ set_property(TARGET jxl_dec-obj PROPERTY POSITION_INDEPENDENT_CODE ON) + target_include_directories(jxl_dec-obj PUBLIC + ${PROJECT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include +- $ +- $ + ) + target_compile_definitions(jxl_dec-obj PUBLIC + ${OBJ_COMPILE_DEFINITIONS} +@@ -377,8 +375,6 @@ set_property(TARGET jxl_enc-obj PROPERTY POSITION_INDEPENDENT_CODE ON) + target_include_directories(jxl_enc-obj PUBLIC + ${PROJECT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include +- $ +- $ + ) + target_compile_definitions(jxl_enc-obj PUBLIC + ${OBJ_COMPILE_DEFINITIONS} +@@ -387,17 +383,6 @@ if (JPEGXL_ENABLE_PROFILER) + target_link_libraries(jxl_enc-obj PUBLIC jxl_profiler) + endif() + +-#TODO(lode): don't depend on CMS for the core library +-if (JPEGXL_ENABLE_SKCMS) +- target_include_directories(jxl_enc-obj PRIVATE +- $ +- ) +-else () +- target_include_directories(jxl_enc-obj PRIVATE +- $ +- ) +-endif () +- + # Headers for exporting/importing public headers + include(GenerateExportHeader) + set_target_properties(jxl_dec-obj PROPERTIES +@@ -413,9 +398,6 @@ set_target_properties(jxl_enc-obj PROPERTIES + VISIBILITY_INLINES_HIDDEN 1 + DEFINE_SYMBOL JXL_INTERNAL_LIBRARY_BUILD + ) +-generate_export_header(jxl_enc-obj +- BASE_NAME JXL +- EXPORT_FILE_NAME include/jxl/jxl_export.h) + target_include_directories(jxl_enc-obj PUBLIC + ${CMAKE_CURRENT_BINARY_DIR}/include) + +@@ -495,9 +477,8 @@ if (((NOT DEFINED "${TARGET_SUPPORTS_SHARED_LIBS}") OR + + # Public shared library. + add_library(jxl SHARED ${JPEGXL_INTERNAL_OBJECTS}) +-strip_static(JPEGXL_INTERNAL_SHARED_LIBS JPEGXL_INTERNAL_LIBS) + target_link_libraries(jxl PUBLIC ${JPEGXL_COVERAGE_FLAGS}) +-target_link_libraries(jxl PRIVATE ${JPEGXL_INTERNAL_SHARED_LIBS}) ++target_link_libraries(jxl PRIVATE ${JPEGXL_INTERNAL_LIBS}) + # Shared library include path contains only the "include/" paths. + target_include_directories(jxl PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/include" +@@ -506,13 +487,13 @@ set_target_properties(jxl PROPERTIES + VERSION ${JPEGXL_LIBRARY_VERSION} + SOVERSION ${JPEGXL_LIBRARY_SOVERSION} + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" +- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") ++ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" ++ DEFINE_SYMBOL JXL_INTERNAL_LIBRARY_BUILD) + + # Public shared decoder library. + add_library(jxl_dec SHARED $) +-strip_static(JPEGXL_DEC_INTERNAL_SHARED_LIBS JPEGXL_DEC_INTERNAL_LIBS) + target_link_libraries(jxl_dec PUBLIC ${JPEGXL_COVERAGE_FLAGS}) +-target_link_libraries(jxl_dec PRIVATE ${JPEGXL_DEC_INTERNAL_SHARED_LIBS}) ++target_link_libraries(jxl_dec PRIVATE ${JPEGXL_DEC_INTERNAL_LIBS}) + # Shared library include path contains only the "include/" paths. + target_include_directories(jxl_dec PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/include" +@@ -523,6 +504,12 @@ set_target_properties(jxl_dec PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") + ++set(LINKER_EXCLUDE_LIBS_FLAG "-Wl,--exclude-libs=ALL") ++include(CheckCSourceCompiles) ++list(APPEND CMAKE_EXE_LINKER_FLAGS ${LINKER_EXCLUDE_LIBS_FLAG}) ++check_c_source_compiles("int main(){return 0;}" LINKER_SUPPORT_EXCLUDE_LIBS) ++list(REMOVE_ITEM CMAKE_EXE_LINKER_FLAGS ${LINKER_EXCLUDE_LIBS_FLAG}) ++ + # Add a jxl.version file as a version script to tag symbols with the + # appropriate version number. This script is also used to limit what's exposed + # in the shared library from the static dependencies bundled here. +@@ -541,8 +528,10 @@ foreach(target IN ITEMS jxl jxl_dec) + # This hides the default visibility symbols from static libraries bundled into + # the shared library. In particular this prevents exposing symbols from hwy + # and skcms in the shared library. +- set_property(TARGET ${target} APPEND_STRING PROPERTY +- LINK_FLAGS " -Wl,--exclude-libs=ALL") ++ if(${LINKER_SUPPORT_EXCLUDE_LIBS}) ++ set_property(TARGET ${target} APPEND_STRING PROPERTY ++ LINK_FLAGS " ${LINKER_EXCLUDE_LIBS_FLAG}") ++ endif() + endforeach() + + # Only install libjxl shared library. The libjxl_dec is not installed since it +@@ -553,8 +542,14 @@ install(TARGETS jxl + else() + add_library(jxl ALIAS jxl-static) + add_library(jxl_dec ALIAS jxl_dec-static) ++set_target_properties(jxl-static PROPERTIES ++ DEFINE_SYMBOL JXL_INTERNAL_LIBRARY_BUILD) + endif() # TARGET_SUPPORTS_SHARED_LIBS AND NOT JPEGXL_STATIC + ++generate_export_header(jxl ++ BASE_NAME JXL ++ EXPORT_FILE_NAME include/jxl/jxl_export.h) ++ + # Add a pkg-config file for libjxl. + set(JPEGXL_LIBRARY_REQUIRES + "libhwy libbrotlicommon libbrotlienc libbrotlidec") diff --git a/recipes/libjxl/all/test_package/CMakeLists.txt b/recipes/libjxl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b9b613cbb24a --- /dev/null +++ b/recipes/libjxl/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libjxl/all/test_package/conanfile.py b/recipes/libjxl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..138d4f5333429 --- /dev/null +++ b/recipes/libjxl/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + img_path = os.path.join(self.source_folder, "test.jxl") + self.run(bin_path + " " + img_path, run_environment=True) diff --git a/recipes/libjxl/all/test_package/test.jxl b/recipes/libjxl/all/test_package/test.jxl new file mode 100644 index 0000000000000..a0f419a98a426 Binary files /dev/null and b/recipes/libjxl/all/test_package/test.jxl differ diff --git a/recipes/libjxl/all/test_package/test_package.c b/recipes/libjxl/all/test_package/test_package.c new file mode 100644 index 0000000000000..2cb652aa9249a --- /dev/null +++ b/recipes/libjxl/all/test_package/test_package.c @@ -0,0 +1,90 @@ +#include +#include + +#include "jxl/decode.h" +#include "jxl/thread_parallel_runner.h" + +static int ReadFile(const char filename[], uint8_t *data[], size_t *size) +{ + FILE *fp = fopen(filename, "rb"); + if (!fp) + return 0; + + if (fseek(fp, 0, SEEK_END) != 0) { + fclose(fp); + return 0; + } + + *size = ftell(fp); + if (fseek(fp, 0, SEEK_SET) != 0) { + fclose(fp); + return 0; + } + + *data = malloc(*size); + if (!*data) { + fclose(fp); + return 0; + } + + if (fread(*data, sizeof(uint8_t), *size, fp) != *size) { + free(*data); + fclose(fp); + return 0; + } + + if (fclose(fp) != 0) { + free(*data); + return 0; + } + + return 1; +} + +int main(int argc, char *argv[]) +{ + int ret = EXIT_FAILURE; + + if (argc < 2) { + fprintf(stderr, "Need at least one argument\n"); + return ret; + } + + uint8_t *data; + size_t size; + if (!ReadFile(argv[1], &data, &size)) + return ret; + + JxlDecoder *dec = NULL; + void *runner = NULL; + + dec = JxlDecoderCreate(NULL); + if (JxlDecoderSubscribeEvents(dec, JXL_DEC_BASIC_INFO) != JXL_DEC_SUCCESS) + goto Exit; + + runner = JxlThreadParallelRunnerCreate( + NULL, JxlThreadParallelRunnerDefaultNumWorkerThreads()); + if (JxlDecoderSetParallelRunner(dec, JxlThreadParallelRunner, runner) + != JXL_DEC_SUCCESS) + goto Exit; + + if (JxlDecoderSetInput(dec, data, size) != JXL_DEC_SUCCESS) + goto Exit; + + if (JxlDecoderProcessInput(dec) != JXL_DEC_BASIC_INFO) + goto Exit; + + JxlBasicInfo info; + if (JxlDecoderGetBasicInfo(dec, &info) != JXL_DEC_SUCCESS) + goto Exit; + + printf("Image size: %d x %d pixels\n", info.xsize, info.ysize); + + ret = EXIT_SUCCESS; + +Exit: + free(data); + JxlThreadParallelRunnerDestroy(runner); + JxlDecoderDestroy(dec); + return ret; +} diff --git a/recipes/libjxl/config.yml b/recipes/libjxl/config.yml new file mode 100644 index 0000000000000..c79a1af3be31f --- /dev/null +++ b/recipes/libjxl/config.yml @@ -0,0 +1,5 @@ +versions: + "0.5.0": + folder: all + "0.6.1": + folder: all diff --git a/recipes/libkml/all/CMakeLists.txt b/recipes/libkml/all/CMakeLists.txt index 923730fbc4d68..e174fe2ff60d5 100644 --- a/recipes/libkml/all/CMakeLists.txt +++ b/recipes/libkml/all/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4.3) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +conan_basic_setup(TARGETS KEEP_RPATHS) if(WIN32 AND BUILD_SHARED_LIBS) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) diff --git a/recipes/libkml/all/conandata.yml b/recipes/libkml/all/conandata.yml index f47f4c47757c4..8d8c18cdc2663 100644 --- a/recipes/libkml/all/conandata.yml +++ b/recipes/libkml/all/conandata.yml @@ -10,3 +10,5 @@ patches: base_path: "source_subfolder" - patch_file: "patches/export-extern-symbols-for-msvc.patch" base_path: "source_subfolder" + - patch_file: "patches/minizip-no-crypt-header.patch" + base_path: "source_subfolder" diff --git a/recipes/libkml/all/conanfile.py b/recipes/libkml/all/conanfile.py index 3476c065753f4..70ba46ffc23ce 100644 --- a/recipes/libkml/all/conanfile.py +++ b/recipes/libkml/all/conanfile.py @@ -1,24 +1,31 @@ from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import functools import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.43.0" class LibkmlConan(ConanFile): name = "libkml" description = "Reference implementation of OGC KML 2.2" license = "BSD-3-Clause" - topics = ("conan", "libkml", "kml", "ogc", "geospatial") + topics = ("libkml", "kml", "ogc", "geospatial") homepage = "https://github.com/libkml/libkml" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - _cmake = None + generators = "cmake" @property def _source_subfolder(self): @@ -28,6 +35,11 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -37,28 +49,35 @@ def configure(self): del self.options.fPIC def requirements(self): - self.requires("boost/1.75.0") - self.requires("expat/2.2.10") - self.requires("minizip/1.2.11") - self.requires("uriparser/0.9.4") - self.requires("zlib/1.2.11") + self.requires("boost/1.78.0") + self.requires("expat/2.4.8") + self.requires("minizip/1.2.12") + self.requires("uriparser/0.9.6") + self.requires("zlib/1.2.12") + + def validate(self): + if self.options.shared and \ + ((self.settings.compiler == "Visual Studio" and "MT" in self.settings.compiler.runtime) or \ + (self.settings.compiler == "msvc" and self.settings.compiler.runtime == "static")): + raise ConanInvalidConfiguration("libkml shared with Visual Studio and MT runtime is not supported") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) cmake = self._configure_cmake() cmake.build() + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + cmake = CMake(self) + # To install relocatable shared libs on Macos + cmake.definitions["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + cmake.configure(build_folder=self._build_subfolder) + return cmake def package(self): self.copy("COPYING", dst="licenses", src=self._source_subfolder) @@ -101,14 +120,16 @@ def _module_file_rel_path(self): "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "LibKML") + self.cpp_info.set_property("pkg_config_name", "libkml") + self.cpp_info.names["cmake_find_package"] = "LibKML" self.cpp_info.names["cmake_find_package_multi"] = "LibKML" - self.cpp_info.names["pkg_config"] = "libkml" self._register_components({ "kmlbase": { "defines": ["LIBKML_DLL"] if self.settings.os == "Windows" and self.options.shared else [], - "system_libs": ["m"] if self.settings.os == "Linux" else [], + "system_libs": ["m"] if self.settings.os in ["Linux", "FreeBSD"] else [], "requires": ["boost::headers", "expat::expat", "minizip::minizip", "uriparser::uriparser", "zlib::zlib"], }, @@ -119,7 +140,7 @@ def package_info(self): "requires": ["boost::headers", "kmlbase"], }, "kmlengine": { - "system_libs": ["m"] if self.settings.os == "Linux" else [], + "system_libs": ["m"] if self.settings.os in ["Linux", "FreeBSD"] else [], "requires": ["boost::headers", "kmldom", "kmlbase"], }, "kmlconvenience": { @@ -135,6 +156,7 @@ def _register_components(self, components): defines = values.get("defines", []) system_libs = values.get("system_libs", []) requires = values.get("requires", []) + self.cpp_info.components[comp_cmake_lib_name].set_property("cmake_target_name", comp_cmake_lib_name) self.cpp_info.components[comp_cmake_lib_name].names["cmake_find_package"] = comp_cmake_lib_name self.cpp_info.components[comp_cmake_lib_name].names["cmake_find_package_multi"] = comp_cmake_lib_name self.cpp_info.components[comp_cmake_lib_name].builddirs.append(self._module_subfolder) diff --git a/recipes/libkml/all/patches/minizip-no-crypt-header.patch b/recipes/libkml/all/patches/minizip-no-crypt-header.patch new file mode 100644 index 0000000000000..cad69c9937c61 --- /dev/null +++ b/recipes/libkml/all/patches/minizip-no-crypt-header.patch @@ -0,0 +1,16 @@ +Do not include crypt.h from minizip as it is not packaged in minizip recipe +Taken from https://github.com/libkml/libkml/commit/a03adc24bc8cf5ab76a0e65f2756172a72c28b7a + +--- a/src/kml/base/contrib/minizip/unzip.c ++++ b/src/kml/base/contrib/minizip/unzip.c +@@ -42,7 +42,9 @@ woven in by Terry Thorsen 1/2003. + #include //RR + #include "unzip.h" + #include "iomem_simple.h" +-#undef NOUNCRYPT ++#ifndef NOUNCRYPT ++#define NOUNCRYPT ++#endif + + #ifdef STDC + # include diff --git a/recipes/libkml/all/test_package/conanfile.py b/recipes/libkml/all/test_package/conanfile.py index 84ee68733e516..38f4483872d47 100644 --- a/recipes/libkml/all/test_package/conanfile.py +++ b/recipes/libkml/all/test_package/conanfile.py @@ -1,9 +1,9 @@ +from conans import ConanFile, CMake, tools import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/liblsl/all/CMakeLists.txt b/recipes/liblsl/all/CMakeLists.txt new file mode 100644 index 0000000000000..79a17945e58b4 --- /dev/null +++ b/recipes/liblsl/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.2) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory("source_subfolder") diff --git a/recipes/liblsl/all/conandata.yml b/recipes/liblsl/all/conandata.yml new file mode 100644 index 0000000000000..bc0d9ba4438b4 --- /dev/null +++ b/recipes/liblsl/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.16.0": + url: "https://github.com/sccn/liblsl/archive/refs/tags/v1.16.0.tar.gz" + sha256: "57d9ab0451d6d1a2068f45e4609c67d52c9c0c76d06c07e625034bea4bc01720" diff --git a/recipes/liblsl/all/conanfile.py b/recipes/liblsl/all/conanfile.py new file mode 100644 index 0000000000000..556c55442cf44 --- /dev/null +++ b/recipes/liblsl/all/conanfile.py @@ -0,0 +1,130 @@ +from conans import ConanFile, CMake, tools +import os +import textwrap + +required_conan_version = ">=1.33.0" + + +class LiblslConan(ConanFile): + name = "liblsl" + description = "Lab Streaming Layer is a C++ library for multi-modal " \ + "time-synched data transmission over the local network" + license = "MIT" + topics = ("labstreaminglayer", "lsl", "network", "stream", "signal", + "transmission") + homepage = "https://github.com/sccn/liblsl" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = "CMakeLists.txt" + generators = "cmake", "cmake_find_package_multi" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def requirements(self): + self.requires("boost/1.78.0") + self.requires("pugixml/1.11") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + if not self.options.shared: + # Do not force PIC + tools.replace_in_file( + os.path.join(self._source_subfolder, "CMakeLists.txt"), + "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", + "" + ) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["LSL_BUILD_STATIC"] = not self.options.shared + self._cmake.definitions["LSL_BUNDLED_BOOST"] = False + self._cmake.definitions["LSL_BUNDLED_PUGIXML"] = False + self._cmake.definitions["lslgitrevision"] = "v" + self.version + self._cmake.definitions["lslgitbranch"] = "master" + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "lslver*") + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"lsl": "LSL::lsl"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake") + + @property + def _module_file_rel_path(self): + return os.path.join(self._module_subfolder, + "conan-official-{}-targets.cmake".format(self.name)) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "lsl" + self.cpp_info.names["cmake_find_package_multi"] = "lsl" + self.cpp_info.builddirs.append(self._module_subfolder) + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.defines = ["LSLNOAUTOLINK"] + if not self.options.shared: + self.cpp_info.defines.append("LIBLSL_STATIC") + self.cpp_info.libs = ["lsl"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["pthread"] + elif self.settings.os == "Windows": + self.cpp_info.system_libs = ["iphlpapi", "winmm", "mswsock", "ws2_32"] diff --git a/recipes/liblsl/all/test_package/CMakeLists.txt b/recipes/liblsl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..df6f46a77757b --- /dev/null +++ b/recipes/liblsl/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(lsl CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} lsl::lsl) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) diff --git a/recipes/liblsl/all/test_package/conanfile.py b/recipes/liblsl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/liblsl/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/liblsl/all/test_package/test_package.cpp b/recipes/liblsl/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..f4dbc97bfb2c0 --- /dev/null +++ b/recipes/liblsl/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include "lsl_cpp.h" + +#include +#include + +int main() { + std::cout << "Resolving streams..." << std::endl; + std::vector streams = lsl::resolve_streams(); + std::cout << streams.size() << " streams found:" << std::endl; + for (auto &stream : streams) { + std::cout << stream.as_xml() << std::endl; + } + return 0; +} diff --git a/recipes/liblsl/config.yml b/recipes/liblsl/config.yml new file mode 100644 index 0000000000000..c2f3886dc7353 --- /dev/null +++ b/recipes/liblsl/config.yml @@ -0,0 +1,3 @@ +versions: + "1.16.0": + folder: all diff --git a/recipes/libltc/all/conandata.yml b/recipes/libltc/all/conandata.yml new file mode 100644 index 0000000000000..c5fe4d5f5d812 --- /dev/null +++ b/recipes/libltc/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.3.2": + url: "https://github.com/x42/libltc/releases/download/v1.3.2/libltc-1.3.2.tar.gz" + sha256: "0a6d42cd6c21e925a27fa560dc45ac80057d275f23342102825909c02d3b1249" + "1.3.1": + url: "https://github.com/x42/libltc/releases/download/v1.3.1/libltc-1.3.1.tar.gz" + sha256: "50e63eb3b767151bc0159a3cc5d426d03a42fd69029bc9b3b7c346555f4b709c" diff --git a/recipes/libltc/all/conanfile.py b/recipes/libltc/all/conanfile.py new file mode 100644 index 0000000000000..51ff80df61859 --- /dev/null +++ b/recipes/libltc/all/conanfile.py @@ -0,0 +1,111 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, tools +import contextlib +import os + +required_conan_version = ">=1.33.0" + + +class LibltcConan(ConanFile): + name = "libltc" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://x42.github.io/libltc/" + description = "Linear/Logitudinal Time Code (LTC) Library" + topics = ("timecode", "smpte", "ltc") + license = "LGPL-3.0" + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + if self.settings.compiler == "Visual Studio": + self.build_requires("automake/1.16.3") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self): + env = { + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "LD": "{} link -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), + } + with tools.environment_append(env): + yield + else: + yield + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + ] + if self.settings.compiler == "Visual Studio": + self._autotools.cxx_flags.append("-EHsc") + if tools.Version(self.settings.compiler.version) >= "12": + self._autotools.flags.append("-FS") + self._autotools.configure(args=args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + os.unlink(os.path.join(self.package_folder, "lib", "libltc.la")) + if self.settings.compiler == "Visual Studio" and self.options.shared: + tools.rename(os.path.join(self.package_folder, "lib", "ltc.dll.lib"), + os.path.join(self.package_folder, "lib", "ltc.lib")) + + def package_info(self): + self.cpp_info.names["pkg_config"] = "ltc" + self.cpp_info.libs = ["ltc"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["m"] diff --git a/recipes/libltc/all/test_package/CMakeLists.txt b/recipes/libltc/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b9b613cbb24a --- /dev/null +++ b/recipes/libltc/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libltc/all/test_package/conanfile.py b/recipes/libltc/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d4128b0450777 --- /dev/null +++ b/recipes/libltc/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libltc/all/test_package/test_package.c b/recipes/libltc/all/test_package/test_package.c new file mode 100644 index 0000000000000..506b4f1319b1b --- /dev/null +++ b/recipes/libltc/all/test_package/test_package.c @@ -0,0 +1,9 @@ +/* example was taken from https://www.gnu.org/ghm/2011/paris/slides/andreas-enge-mpc.pdf */ + +#include + +int main (void) { + LTCDecoder *decoder = ltc_decoder_create(1920, 1920 * 2); + ltc_decoder_free(decoder); + return 0; +} diff --git a/recipes/libltc/config.yml b/recipes/libltc/config.yml new file mode 100644 index 0000000000000..27e13c88ce850 --- /dev/null +++ b/recipes/libltc/config.yml @@ -0,0 +1,5 @@ +versions: + "1.3.2": + folder: "all" + "1.3.1": + folder: "all" diff --git a/recipes/libmad/all/conanfile.py b/recipes/libmad/all/conanfile.py index 82a3c8bf794d8..fb912e50ed5eb 100644 --- a/recipes/libmad/all/conanfile.py +++ b/recipes/libmad/all/conanfile.py @@ -1,11 +1,14 @@ from conans import ConanFile, tools, AutoToolsBuildEnvironment, MSBuild from conans.errors import ConanInvalidConfiguration import os +import shutil + +required_conan_version = ">=1.33.0" class LibmadConan(ConanFile): name = "libmad" - description = "MAD is a high-quality MPEG audio decoder.format." + description = "MAD is a high-quality MPEG audio decoder." topics = ("conan", "mad", "MPEG", "audio", "decoder") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.underbit.com/products/mad/" @@ -13,33 +16,50 @@ class LibmadConan(ConanFile): settings = "os", "arch", "compiler", "build_type" options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True} - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return self.settings.compiler == "Visual Studio" def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd - if self._is_msvc and self.options.shared: - raise ConanInvalidConfiguration("libmad does not support shared library for MSVC") + if self.options.shared: + del self.options.fPIC - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def validate(self): + if self.options.shared and self._is_msvc: + raise ConanInvalidConfiguration("libmad does not support shared library for MSVC") @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + if not self._is_msvc: + self.build_requires("gnu-config/cci.20201022") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): if self._is_msvc: self._build_msvc() else: - self._build_configure() + self._build_autotools() def _build_msvc(self): with tools.chdir(os.path.join(self._source_subfolder, "msvc++")): @@ -54,19 +74,29 @@ def _build_msvc(self): msbuild = MSBuild(self) msbuild.build(project_file="libmad.vcxproj") - def _build_configure(self): - with tools.chdir(self._source_subfolder): - if self.options.shared: - args = ["--disable-static", "--enable-shared"] - else: - args = ["--disable-shared", "--enable-static"] - env_build = AutoToolsBuildEnvironment(self) - env_build.configure(args=args) - env_build.make() - env_build.install() - la = os.path.join(self.package_folder, "lib", "libmad.la") - if os.path.isfile(la): - os.unlink(la) + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def _build_autotools(self): + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) + autotools = self._configure_autotools() + autotools.make() + + def _configure_autotools(self): + if self._autotools: + return self._autotools + args = [] + if self.options.shared: + args = ["--disable-static", "--enable-shared"] + else: + args = ["--disable-shared", "--enable-static"] + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + self._autotools.configure(configure_dir=self._source_subfolder, args=args) + return self._autotools def package(self): self.copy("COPYRIGHT", dst="licenses", src=self._source_subfolder) @@ -75,6 +105,10 @@ def package(self): if self._is_msvc: self.copy(pattern="*.lib", dst="lib", src=self._source_subfolder, keep_path=False) self.copy(pattern="mad.h", dst="include", src=os.path.join(self._source_subfolder, "msvc++")) + else: + autotools = self._configure_autotools() + autotools.install() + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") def package_info(self): self.cpp_info.libs = ["libmad" if self._is_msvc else "mad"] diff --git a/recipes/libmad/all/test_package/CMakeLists.txt b/recipes/libmad/all/test_package/CMakeLists.txt index 196188113685c..7b9b613cbb24a 100644 --- a/recipes/libmad/all/test_package/CMakeLists.txt +++ b/recipes/libmad/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -add_executable(${PROJECT_NAME} test_package.cpp) +add_executable(${PROJECT_NAME} test_package.c) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libmad/all/test_package/conanfile.py b/recipes/libmad/all/test_package/conanfile.py index bd7165a553cf4..d4128b0450777 100644 --- a/recipes/libmad/all/test_package/conanfile.py +++ b/recipes/libmad/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libmad/all/test_package/test_package.c b/recipes/libmad/all/test_package/test_package.c new file mode 100644 index 0000000000000..2fa0527f145bd --- /dev/null +++ b/recipes/libmad/all/test_package/test_package.c @@ -0,0 +1,12 @@ +#include + +#include + +int main() +{ + printf("mad version: %s\n", mad_version); + printf("mad copyright: %s\n", mad_copyright); + printf("mad author: %s\n", mad_author); + printf("mad build: %s\n", mad_build); + return 0; +} diff --git a/recipes/libmad/all/test_package/test_package.cpp b/recipes/libmad/all/test_package/test_package.cpp deleted file mode 100644 index 97a621eb97f34..0000000000000 --- a/recipes/libmad/all/test_package/test_package.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -int main() -{ - std::cout << "mad version: " << mad_version << std::endl; - std::cout << "mad copyright: " << mad_copyright << std::endl; - std::cout << "mad author: " << mad_author << std::endl; - std::cout << "mad build: " << mad_build << std::endl; - return 0; -} diff --git a/recipes/libmaxminddb/all/conandata.yml b/recipes/libmaxminddb/all/conandata.yml index 39404a5bda073..83c876364326d 100644 --- a/recipes/libmaxminddb/all/conandata.yml +++ b/recipes/libmaxminddb/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.7.1": + url: "https://github.com/maxmind/libmaxminddb/releases/download/1.7.1/libmaxminddb-1.7.1.tar.gz" + sha256: "e8414f0dedcecbc1f6c31cb65cd81650952ab0677a4d8c49cab603b3b8fb083e" "1.6.0": url: "https://github.com/maxmind/libmaxminddb/releases/download/1.6.0/libmaxminddb-1.6.0.tar.gz" sha256: "7620ac187c591ce21bcd7bf352376a3c56a933e684558a1f6bef4bd4f3f98267" +patches: + "1.6.0": + - patch_file: "patches/0001-fix-cmake-bundle.patch" diff --git a/recipes/libmaxminddb/all/conanfile.py b/recipes/libmaxminddb/all/conanfile.py index 364e688195afe..7afd56f70e087 100644 --- a/recipes/libmaxminddb/all/conanfile.py +++ b/recipes/libmaxminddb/all/conanfile.py @@ -1,29 +1,29 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import export_conandata_patches, apply_conandata_patches, copy, get, rmdir import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.52.0" -class libmaxminddbConan(ConanFile): +class LibmaxminddbConan(ConanFile): name = "libmaxminddb" + description = "C library for the MaxMind DB file format" license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" homepage = "http://maxmind.github.io/libmaxminddb/" - description = "C library for the MaxMind DB file format" - topics = ("MaxMind", "GeoIP") - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - - _cmake = None + topics = ("maxmind", "geoip") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -31,40 +31,59 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libmaxminddb-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "maxminddb") + self.cpp_info.set_property("cmake_target_name", "maxminddb::maxminddb") + self.cpp_info.set_property("pkg_config_name", "libmaxminddb") self.cpp_info.libs = ["maxminddb"] - if self.settings.os == "Windows": self.cpp_info.system_libs = ["ws2_32"] - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) + if self.settings.os != "Windows": + bin_path = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH environment variable: {bin_path}") + self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "maxminddb" + self.cpp_info.names["cmake_find_package_multi"] = "maxminddb" diff --git a/recipes/libmaxminddb/all/patches/0001-fix-cmake-bundle.patch b/recipes/libmaxminddb/all/patches/0001-fix-cmake-bundle.patch new file mode 100644 index 0000000000000..f6d788650838f --- /dev/null +++ b/recipes/libmaxminddb/all/patches/0001-fix-cmake-bundle.patch @@ -0,0 +1,10 @@ +--- a/bin/CMakeLists.txt ++++ b/bin/CMakeLists.txt +@@ -8,6 +8,6 @@ if(NOT WIN32) + + install( + TARGETS mmdblookup +- RUNTIME DESTINATION bin ++ DESTINATION bin + ) + endif() diff --git a/recipes/libmaxminddb/all/test_package/CMakeLists.txt b/recipes/libmaxminddb/all/test_package/CMakeLists.txt index 3b74e16cc835e..1d23aba68bcc6 100644 --- a/recipes/libmaxminddb/all/test_package/CMakeLists.txt +++ b/recipes/libmaxminddb/all/test_package/CMakeLists.txt @@ -1,11 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(PkgConfig) -pkg_check_modules(libmaxminddb REQUIRED IMPORTED_TARGET GLOBAL libmaxminddb) +find_package(maxminddb REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} PkgConfig::libmaxminddb) +target_link_libraries(${PROJECT_NAME} PRIVATE maxminddb::maxminddb) diff --git a/recipes/libmaxminddb/all/test_package/conanfile.py b/recipes/libmaxminddb/all/test_package/conanfile.py index 5569cc255a6a7..d120a992c06a6 100644 --- a/recipes/libmaxminddb/all/test_package/conanfile.py +++ b/recipes/libmaxminddb/all/test_package/conanfile.py @@ -1,14 +1,18 @@ -import os.path +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os -from conans import ConanFile, CMake, tools +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" -class libmaxminddbTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "pkg_config" + def requirements(self): + self.requires(self.tested_reference_str) - def build_requirements(self): - self.build_requires("pkgconf/1.7.3") + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -16,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libmaxminddb/all/test_v1_package/CMakeLists.txt b/recipes/libmaxminddb/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f31d3904fb26f --- /dev/null +++ b/recipes/libmaxminddb/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(maxminddb REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE maxminddb::maxminddb) diff --git a/recipes/libmaxminddb/all/test_v1_package/conanfile.py b/recipes/libmaxminddb/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libmaxminddb/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libmaxminddb/config.yml b/recipes/libmaxminddb/config.yml index adb199884dc43..9efd2189b76e9 100644 --- a/recipes/libmaxminddb/config.yml +++ b/recipes/libmaxminddb/config.yml @@ -1,3 +1,5 @@ versions: - "1.6.0": - folder: all + "1.7.1": + folder: all + "1.6.0": + folder: all diff --git a/recipes/libmediainfo/all/CMakeLists.txt b/recipes/libmediainfo/all/CMakeLists.txt index b3d443fa3269e..8f32238b21da5 100644 --- a/recipes/libmediainfo/all/CMakeLists.txt +++ b/recipes/libmediainfo/all/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_definitions(${CONAN_DEFINES}) set(ZenLib_LIBRARY ${CONAN_LIBS_LIBZEN}) diff --git a/recipes/libmediainfo/all/conandata.yml b/recipes/libmediainfo/all/conandata.yml index 6ce904e865638..c54a0606f82a2 100644 --- a/recipes/libmediainfo/all/conandata.yml +++ b/recipes/libmediainfo/all/conandata.yml @@ -1,12 +1,20 @@ sources: + "22.03": + url: "https://mediaarea.net/download/source/libmediainfo/22.03/libmediainfo_22.03.tar.xz" + sha256: "fc50babb628e9cfba655288dae06d5c342b0d7e6941a32d64fbbb113248c80b9" + "21.09": + url: "https://mediaarea.net/download/source/libmediainfo/21.09/libmediainfo_21.09.tar.xz" + sha256: "69be9444f6a03a1bdf56713ee31d56e987c502a7ec18eb54ee70fcc171b7f126" + "21.03": + url: "https://mediaarea.net/download/source/libmediainfo/21.03/libmediainfo_21.03.tar.xz" + sha256: "56b7e9abf80cba48032165cd7a46fd8d43dd63e3af35765f66c3f134caaca4ca" "20.03": url: "https://mediaarea.net/download/source/libmediainfo/20.03/libmediainfo_20.03.tar.xz" sha256: "6848310eb7050efe7f90f18191dacfcc220c924390b8088fdf0d553274917f72" patches: + "22.03": + - patch_file: "patches/0002-cmake-get-property-location.patch" + base_path: "source_subfolder" "20.03": - patch_file: "patches/0001-cmakelists-CMAKE_MODULE_PATH-find_package.patch" base_path: "source_subfolder" - - patch_file: "patches/0002-no-debug-postfix.patch" - base_path: "source_subfolder" - - patch_file: "patches/0003-install-no-pdbs.patch" - base_path: "source_subfolder" diff --git a/recipes/libmediainfo/all/conanfile.py b/recipes/libmediainfo/all/conanfile.py index 24d2c48431ff2..37d62638387b4 100644 --- a/recipes/libmediainfo/all/conanfile.py +++ b/recipes/libmediainfo/all/conanfile.py @@ -1,9 +1,11 @@ +from conan.tools.files import rename from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration +import functools import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.43.0" class LibmediainfoConan(ConanFile): @@ -12,10 +14,9 @@ class LibmediainfoConan(ConanFile): homepage = "https://mediaarea.net/en/MediaInfo" url = "https://github.com/conan-io/conan-center-index" description = "MediaInfo is a convenient unified display of the most relevant technical and tag data for video and audio files" - topics = ("conan", "libmediainfo", "video", "audio", "metadata", "tag") - settings = "os", "arch", "compiler", "build_type" - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake", "cmake_find_package" + topics = ("libmediainfo", "video", "audio", "metadata", "tag") + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -25,12 +26,17 @@ class LibmediainfoConan(ConanFile): "fPIC": True, } - _cmake = None + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): return "source_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -40,35 +46,50 @@ def configure(self): del self.options.fPIC def requirements(self): - self.requires("libcurl/7.75.0") + self.requires("libcurl/7.82.0") self.requires("libzen/0.4.38") - self.requires("tinyxml2/8.0.0") - self.requires("zlib/1.2.11") + self.requires("tinyxml2/9.0.0") + self.requires("zlib/1.2.12") def validate(self): if not self.options["libzen"].enable_unicode: raise ConanInvalidConfiguration("This package requires libzen with unicode support") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("MediaInfoLib", self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_ZENLIB"] = False - self._cmake.definitions["BUILD_ZLIB"] = False - self._cmake.configure() - return self._cmake + cmake = CMake(self) + cmake.definitions["BUILD_ZENLIB"] = False + cmake.definitions["BUILD_ZLIB"] = False + # Generate a relocatable shared lib on Macos + cmake.definitions["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + cmake.configure() + return cmake def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - os.rename("Findtinyxml2.cmake", "FindTinyXML.cmake") + rename(self, "Findtinyxml2.cmake", "FindTinyXML.cmake") tools.replace_in_file("FindTinyXML.cmake", "tinyxml2_LIBRARIES", "TinyXML_LIBRARIES") + # TODO: move this to a patch (see how https://github.com/MediaArea/MediaInfoLib/issues/1408 if addressed by upstream) + postfix = "" + if self.settings.build_type == "Debug": + if self.settings.os == "Windows": + postfix += "d" + elif tools.is_apple_os(self.settings.os): + postfix += "_debug" + tools.replace_in_file(os.path.join(self._source_subfolder, "Source", "MediaInfoDLL", "MediaInfoDLL.h"), + "MediaInfo.dll", + "MediaInfo{}.dll".format(postfix)) + tools.replace_in_file(os.path.join(self._source_subfolder, "Source", "MediaInfoDLL", "MediaInfoDLL.h"), + "libmediainfo.0.dylib", + "libmediainfo{}.0.dylib".format(postfix)) + def build(self): self._patch_sources() cmake = self._configure_cmake() @@ -79,9 +100,12 @@ def package(self): self.copy("License.html", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") tools.rmdir(os.path.join(self.package_folder, "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {"mediainfo": "MediaInfoLib::MediaInfoLib"} @@ -99,22 +123,27 @@ def _create_cmake_module_alias_targets(module_file, targets): """.format(alias=alias, aliased=aliased)) tools.save(module_file, content) - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") - @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): - self.cpp_info.libs = ["mediainfo"] - if self.settings.os == "Linux": + self.cpp_info.set_property("cmake_file_name", "MediaInfoLib") + self.cpp_info.set_property("cmake_target_name", "mediainfo") + self.cpp_info.set_property("pkg_config_name", "libmediainfo") + postfix = "" + if self.settings.build_type == "Debug": + if self.settings.os == "Windows": + postfix += "d" + elif tools.is_apple_os(self.settings.os): + postfix += "_debug" + self.cpp_info.libs = ["mediainfo" + postfix] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["dl", "m", "pthread"]) + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self.cpp_info.names["cmake_find_package"] = "MediaInfoLib" self.cpp_info.names["cmake_find_package_multi"] = "MediaInfoLib" - self.cpp_info.names["pkg_config"] = "libmediainfo" - self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.names["pkg_config"] = "libmediainfo" diff --git a/recipes/libmediainfo/all/patches/0002-cmake-get-property-location.patch b/recipes/libmediainfo/all/patches/0002-cmake-get-property-location.patch new file mode 100644 index 0000000000000..24922cedf1da7 --- /dev/null +++ b/recipes/libmediainfo/all/patches/0002-cmake-get-property-location.patch @@ -0,0 +1,41 @@ +From fad30ccb4e31d66dd196aae0897788ecab02de07 Mon Sep 17 00:00:00 2001 +From: Maxime Gervais +Date: Tue, 5 Apr 2022 15:16:12 +0200 +Subject: [PATCH] CMake: remove use of LOCATION property + +Signed-off-by: Maxime Gervais +--- + Project/CMake/CMakeLists.txt | 12 ++---------- + 1 file changed, 2 insertions(+), 10 deletions(-) + +diff --git a/Project/CMake/CMakeLists.txt b/Project/CMake/CMakeLists.txt +index 5c49030d6..5e061c4a3 100644 +--- a/Project/CMake/CMakeLists.txt ++++ b/Project/CMake/CMakeLists.txt +@@ -56,10 +56,8 @@ if (NOT BUILD_ZLIB) + find_package(ZLIB REQUIRED) + else() + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib) +- get_target_property(ZLIB_LIBRARIES zlibstatic LOCATION) + if(NOT BUILD_SHARED_LIBS) +- get_filename_component(ZLIB_LIBRARIES ${ZLIB_LIBRARIES} NAME) +- set(ZLIB_LIBRARIES "${LIB_INSTALL_DIR}/${ZLIB_LIBRARIES}") ++ set(ZLIB_LIBRARIES "${LIB_INSTALL_DIR}/$") + endif() + if(UNIX AND BUILD_SHARED_LIBS) + target_compile_options(zlibstatic PRIVATE -fPIC) +@@ -405,13 +403,7 @@ endif() + target_link_libraries(mediainfo ${ZenLib_LIBRARY} ${ZLIB_LIBRARIES}) + + if(MSVC AND BUILD_SHARED_LIBS) +- get_target_property(LOCATION mediainfo LOCATION_DEBUG) +- string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}") +- install(FILES ${LOCATION} DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug) +- +- get_target_property(LOCATION mediainfo LOCATION_RELWITHDEBINFO) +- string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}") +- install(FILES ${LOCATION} DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo) ++ install(FILES $ DESTINATION ${BIN_INSTALL_DIR} OPTIONAL) + endif() + + if (APPLE) diff --git a/recipes/libmediainfo/all/patches/0002-no-debug-postfix.patch b/recipes/libmediainfo/all/patches/0002-no-debug-postfix.patch deleted file mode 100644 index 56badbcb3abe3..0000000000000 --- a/recipes/libmediainfo/all/patches/0002-no-debug-postfix.patch +++ /dev/null @@ -1,19 +0,0 @@ -No debug postfix, otherwise these shared libraries cannot be loaded. ---- Project/CMake/CMakeLists.txt -+++ Project/CMake/CMakeLists.txt -@@ -78,10 +78,10 @@ - set(MediaInfoLib_SOURCES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../Source) - - # On Windows debug library should have 'd' postfix. --if(WIN32) -- set(CMAKE_DEBUG_POSTFIX "d") --elseif(APPLE) -- set(CMAKE_DEBUG_POSTFIX "_debug") --endif() -+#if(WIN32) -+# set(CMAKE_DEBUG_POSTFIX "d") -+#elseif(APPLE) -+# set(CMAKE_DEBUG_POSTFIX "_debug") -+#endif() - - # use bundled tinyxml only if no system diff --git a/recipes/libmediainfo/all/patches/0003-install-no-pdbs.patch b/recipes/libmediainfo/all/patches/0003-install-no-pdbs.patch deleted file mode 100644 index f08b3bf0d6677..0000000000000 --- a/recipes/libmediainfo/all/patches/0003-install-no-pdbs.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Project/CMake/CMakeLists.txt -+++ Project/CMake/CMakeLists.txt -@@ -397,7 +397,7 @@ - - target_link_libraries(mediainfo ${ZenLib_LIBRARY} ${ZLIB_LIBRARIES}) - --if(MSVC AND BUILD_SHARED_LIBS) -+if(0) - get_target_property(LOCATION mediainfo LOCATION_DEBUG) - string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}") - install(FILES ${LOCATION} DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug) diff --git a/recipes/libmediainfo/all/test_package/conanfile.py b/recipes/libmediainfo/all/test_package/conanfile.py index 407935960b182..f658082513f60 100644 --- a/recipes/libmediainfo/all/test_package/conanfile.py +++ b/recipes/libmediainfo/all/test_package/conanfile.py @@ -16,7 +16,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") testsrc = os.path.join(self.source_folder, "testsrc.mp4") self.run("{} {}".format(bin_path, testsrc), run_environment=True) diff --git a/recipes/libmediainfo/config.yml b/recipes/libmediainfo/config.yml index 7e04409382d83..b9bb652050b63 100644 --- a/recipes/libmediainfo/config.yml +++ b/recipes/libmediainfo/config.yml @@ -1,3 +1,9 @@ versions: + "22.03": + folder: "all" + "21.09": + folder: "all" + "21.03": + folder: "all" "20.03": folder: "all" diff --git a/recipes/libmetalink/all/conandata.yml b/recipes/libmetalink/all/conandata.yml new file mode 100644 index 0000000000000..abebbdecbec33 --- /dev/null +++ b/recipes/libmetalink/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.1.3": + url: "https://github.com/metalink-dev/libmetalink/releases/download/release-0.1.3/libmetalink-0.1.3.tar.xz" + sha256: "86312620c5b64c694b91f9cc355eabbd358fa92195b3e99517504076bf9fe33a" diff --git a/recipes/libmetalink/all/conanfile.py b/recipes/libmetalink/all/conanfile.py new file mode 100644 index 0000000000000..26b6f8a3d9655 --- /dev/null +++ b/recipes/libmetalink/all/conanfile.py @@ -0,0 +1,119 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +import os + +required_conan_version = ">=1.53.0" + + +class LibmetalinkConan(ConanFile): + name = "libmetalink" + description = ( + "Libmetalink is a library to read Metalink XML download description format. " + "It supports both Metalink version 3 and Metalink version 4 (RFC 5854)." + ) + license = "MIT" + topics = ("metalink", "xml") + homepage = "https://launchpad.net/libmetalink" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "xml_backend": ["expat", "libxml2"], + } + default_options = { + "shared": False, + "fPIC": True, + "xml_backend": "expat", + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + if self.options.xml_backend == "expat": + self.requires("expat/2.4.9") + elif self.options.xml_backend == "libxml2": + self.requires("libxml2/2.9.14") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} does not support Visual Studio yet") + + def build_requirements(self): + self.tool_requires("gnu-config/cci.20210814") + self.tool_requires("pkgconf/1.9.3") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + yes_no = lambda v: "yes" if v else "no" + tc.configure_args.extend([ + f"--with-libexpat={yes_no(self.options.xml_backend == 'expat')}", + f"--with-libxml2={yes_no(self.options.xml_backend == 'libxml2')}", + "ac_cv_func_malloc_0_nonnull=yes", + ]) + tc.generate() + + deps = PkgConfigDeps(self) + deps.generate() + + def _patch_sources(self): + # Support more configurations + for gnu_config in [ + self.conf.get("user.gnu-config:config_guess", check_type=str), + self.conf.get("user.gnu-config:config_sub", check_type=str), + ]: + if gnu_config: + copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder) + + def build(self): + self._patch_sources() + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libmetalink") + self.cpp_info.libs = ["metalink"] diff --git a/recipes/libmetalink/all/test_package/CMakeLists.txt b/recipes/libmetalink/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3327ee2e69390 --- /dev/null +++ b/recipes/libmetalink/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libmetalink REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libmetalink::libmetalink) diff --git a/recipes/libmetalink/all/test_package/conanfile.py b/recipes/libmetalink/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libmetalink/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libmetalink/all/test_package/test_package.c b/recipes/libmetalink/all/test_package/test_package.c new file mode 100644 index 0000000000000..acf1ce262b47b --- /dev/null +++ b/recipes/libmetalink/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include + +#include + +int main(void) { + int major, minor, patch; + metalink_get_version(&major, &minor, &patch); + printf("libmetalink version %i.%i.%i\n", major, minor, patch); + return 0; +} diff --git a/recipes/libmetalink/all/test_v1_package/CMakeLists.txt b/recipes/libmetalink/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libmetalink/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libmetalink/all/test_v1_package/conanfile.py b/recipes/libmetalink/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libmetalink/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libmetalink/config.yml b/recipes/libmetalink/config.yml new file mode 100644 index 0000000000000..b7f57204004e4 --- /dev/null +++ b/recipes/libmetalink/config.yml @@ -0,0 +1,3 @@ +versions: + "0.1.3": + folder: all diff --git a/recipes/libmicrohttpd/all/conandata.yml b/recipes/libmicrohttpd/all/conandata.yml new file mode 100644 index 0000000000000..0276eb4f1e40e --- /dev/null +++ b/recipes/libmicrohttpd/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "0.9.75": + url: "https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.75.tar.gz" + sha256: "9278907a6f571b391aab9644fd646a5108ed97311ec66f6359cebbedb0a4e3bb" +patches: + "0.9.75": + - patch_file: "patches/0.9.75-0001-msbuild-RuntimeLibrary.patch" + patch_description: "Remove RuntimeLibrary from vcxproject + use conantoolchain.props" + patch_type: "conan" + - patch_file: "patches/0.9.75-0002-allow-release-with-debug-runtime.patch" + patch_description: "Remove RuntimeLibrary from vcxproject + use conantoolchain.props" + patch_type: "conan" diff --git a/recipes/libmicrohttpd/all/conanfile.py b/recipes/libmicrohttpd/all/conanfile.py new file mode 100644 index 0000000000000..1811e1503e36c --- /dev/null +++ b/recipes/libmicrohttpd/all/conanfile.py @@ -0,0 +1,205 @@ +from conan import ConanFile, Version +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps +from conan.tools.microsoft import MSBuild, MSBuildToolchain, is_msvc, vs_layout +from conan.tools.layout import basic_layout +from conan.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.52.0" + + +class LibmicrohttpdConan(ConanFile): + name = "libmicrohttpd" + description = "A small C library that is supposed to make it easy to run an HTTP server" + homepage = "https://www.gnu.org/software/libmicrohttpd/" + topics = ("httpd", "server", "service") + license = "LGPL-2.1" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_https": [True, False], + "with_error_messages": [True, False], + "with_postprocessor": [True, False], + "with_digest_authentification": [True, False], + "epoll": [True, False], + "with_zlib": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_https": False, # FIXME: should be True, but gnutls is not yet available in cci + "with_error_messages": True, + "with_postprocessor": True, + "with_digest_authentification": True, + "epoll": True, + "with_zlib": True, + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def config_options(self): + if self.settings.os != "Linux": + try: + del self.options.fPIC + except Exception: + pass + del self.options.epoll + if is_msvc(self): + del self.options.with_https + del self.options.with_error_messages + del self.options.with_postprocessor + del self.options.with_digest_authentification + del self.options.with_zlib + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def validate(self): + if is_msvc(self): + if self.info.settings.arch not in ("x86", "x86_64"): + raise ConanInvalidConfiguration("Unsupported architecture (only x86 and x86_64 are supported)") + if self.info.settings.build_type not in ("Release", "Debug"): + raise ConanInvalidConfiguration("Unsupported build type (only Release and Debug are supported)") + + def requirements(self): + if self.options.get_safe("with_zlib", False): + self.requires("zlib/1.2.13") + if self.options.get_safe("with_https", False): + raise ConanInvalidConfiguration("gnutls is not (yet) available in cci") + + def build_requirements(self): + if self._settings_build.os == "Windows" and not is_msvc(self): + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + if is_msvc(self): + vs_layout(self) + else: + basic_layout(self) + + def generate(self): + if is_msvc(self): + tc = MSBuildToolchain(self) + tc.configuration = self._msvc_configuration + tc.generate() + else: + yes_no = lambda v: "yes" if v else "no" + pkg = PkgConfigDeps(self) + pkg.generate() + autotools = AutotoolsToolchain(self) + autotools.configure_args.extend([ + f"--enable-shared={yes_no(self.options.shared)}", + f"--enable-static={yes_no(not self.options.shared)}", + f"--enable-https={yes_no(self.options.with_https)}", + f"--enable-messages={yes_no(self.options.with_error_messages)}", + f"--enable-postprocessor={yes_no(self.options.with_postprocessor)}", + f"--enable-dauth={yes_no(self.options.with_digest_authentification)}", + f"--enable-epoll={yes_no(self.options.get_safe('epoll'))}", + "--disable-doc", + "--disable-examples", + "--disable-curl", + ]) + if self.settings.os == "Windows": + if self.options.with_zlib: + # This fixes libtool refusing to build a shared library when it sees `-lz` + libdir = self.deps_cpp_info["zlib"].lib_paths[0] + autotools.extra_ldflags.extend([os.path.join(libdir, lib).replace("\\", "/") for lib in os.listdir(libdir)]) + autotools.generate() + + @property + def _msvc_configuration(self): + return f"{self.settings.build_type}-{'dll' if self.options.shared else 'static'}" + + @property + def _msvc_sln_folder(self): + if self.settings.compiler == "Visual Studio": + if Version(self.settings.compiler.version) >= 16: + subdir = "VS-Any-Version" + else: + subdir = "VS2017" + else: + subdir = "VS-Any-Version" + return os.path.join("w32", subdir) + + @property + def _msvc_platform(self): + return { + "x86": "Win32", + "x86_64": "x64", + }[str(self.settings.arch)] + + def _patch_sources(self): + apply_conandata_patches(self) + + def build(self): + self._patch_sources() + if is_msvc(self): + msbuild = MSBuild(self) + msbuild.build_type = self._msvc_configuration + msbuild.platform = self._msvc_platform + msbuild.build(sln=os.path.join(self._msvc_sln_folder, "libmicrohttpd.sln"), targets=["libmicrohttpd"]) + else: + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", os.path.join(self.source_folder), os.path.join(self.package_folder, "licenses")) + if is_msvc(self): + # 32-bit (x86) libraries are stored in the root + output_dir = os.path.join(self.build_folder, self._msvc_sln_folder, "Output") + if self.settings.arch in ("x86_64", ): + # 64-bit (x64) libraries are stored in a subfolder + output_dir = os.path.join(output_dir, self._msvc_platform) + copy(self, "*.lib", output_dir, os.path.join(self.package_folder, "lib")) + copy(self, "*.dll", output_dir, os.path.join(self.package_folder, "bin")) + copy(self, "*.h", output_dir, os.path.join(self.package_folder, "include")) + else: + autotools = Autotools(self) + autotools.install() + + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libmicrohttps") + libname = "microhttpd" + if is_msvc(self): + libname = "libmicrohttpd" + if self.options.shared: + libname += "-dll" + if self.settings.build_type == "Debug": + libname += "_d" + self.cpp_info.libs = [libname] + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs = ["pthread"] + elif self.settings.os == "Windows": + if self.options.shared: + self.cpp_info.defines.append("MHD_W32DLL") + self.cpp_info.system_libs = ["ws2_32"] diff --git a/recipes/libmicrohttpd/all/patches/0.9.75-0001-msbuild-RuntimeLibrary.patch b/recipes/libmicrohttpd/all/patches/0.9.75-0001-msbuild-RuntimeLibrary.patch new file mode 100644 index 0000000000000..b3dc82df26fa9 --- /dev/null +++ b/recipes/libmicrohttpd/all/patches/0.9.75-0001-msbuild-RuntimeLibrary.patch @@ -0,0 +1,35 @@ +--- w32/common/common-build-settings.vcxproj ++++ w32/common/common-build-settings.vcxproj +@@ -5,7 +5,7 @@ + Only 0 and 1 are used currently --> + 0 + 1 +- ++ + + $(SolutionDir);$(MhdW32Common);$(MhdSrc)include;$(IncludePath) + +--- w32/common/libmicrohttpd-build-settings.vcxproj ++++ w32/common/libmicrohttpd-build-settings.vcxproj +@@ -31,8 +31,8 @@ + + + _LIB;MHD_W32LIB;%(PreprocessorDefinitions) +- MultiThreadedDebug +- MultiThreaded ++ + + + Ws2_32.lib +@@ -45,8 +45,8 @@ + + + _USRDLL;MHD_W32DLL;%(PreprocessorDefinitions) +- MultiThreadedDebugDLL +- MultiThreadedDLL ++ + + + Ws2_32.lib;%(AdditionalDependencies) diff --git a/recipes/libmicrohttpd/all/patches/0.9.75-0002-allow-release-with-debug-runtime.patch b/recipes/libmicrohttpd/all/patches/0.9.75-0002-allow-release-with-debug-runtime.patch new file mode 100644 index 0000000000000..c833862d3cee1 --- /dev/null +++ b/recipes/libmicrohttpd/all/patches/0.9.75-0002-allow-release-with-debug-runtime.patch @@ -0,0 +1,12 @@ +This patch allows building libmicrohttpd in Release configuration with a debug runtime (e.g. MTd) +--- src/microhttpd/mhd_assert.h ++++ src/microhttpd/mhd_assert.h +@@ -35,7 +35,7 @@ + #define NDEBUG 1 /* Use NDEBUG by default */ + #endif /* !_DEBUG && !NDEBUG */ + #if defined(_DEBUG) && defined(NDEBUG) +-#error Both _DEBUG and NDEBUG are defined ++//#error Both _DEBUG and NDEBUG are defined + #endif /* _DEBUG && NDEBUG */ + #ifdef NDEBUG + # define mhd_assert(ignore) ((void) 0) diff --git a/recipes/libmicrohttpd/all/test_package/CMakeLists.txt b/recipes/libmicrohttpd/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..534adba0c584f --- /dev/null +++ b/recipes/libmicrohttpd/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libmicrohttpd REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libmicrohttpd::libmicrohttpd) diff --git a/recipes/libmicrohttpd/all/test_package/conanfile.py b/recipes/libmicrohttpd/all/test_package/conanfile.py new file mode 100644 index 0000000000000..f72d1f660e19f --- /dev/null +++ b/recipes/libmicrohttpd/all/test_package/conanfile.py @@ -0,0 +1,30 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libmicrohttpd/all/test_package/test_package.c b/recipes/libmicrohttpd/all/test_package/test_package.c new file mode 100644 index 0000000000000..cb40829c7a43b --- /dev/null +++ b/recipes/libmicrohttpd/all/test_package/test_package.c @@ -0,0 +1,74 @@ +#include +#include +#include +#include + +#define PORT 8888 +#define PAGE \ + "" \ + "" \ + "libmicrohttpd demo" \ + "" \ + "" \ + "libmicrohttpd demo" \ + "" \ + "" + +static enum MHD_Result ahc_echo(void * cls, + struct MHD_Connection *connection, + const char *url, + const char *method, + const char *version, + const char *upload_data, + long unsigned int *upload_data_size, + void **con_cls) { + struct MHD_Response *response; + int ret; + + if (strcmp(method, "GET") != 0) { + /** + * unexpected method + */ + return MHD_NO; + } + if (*con_cls == NULL) { + /** + * The first time only the headers are valid, + * do not respond in the first round. + * But accept the connection. + */ + *con_cls = connection; + return MHD_YES; + } + if (*upload_data_size != 0) { + /** + * upload data in a GET!? + */ + return MHD_NO; + } + response = MHD_create_response_from_buffer(strlen(PAGE), (void*)PAGE, MHD_RESPMEM_PERSISTENT); + ret = MHD_queue_response(connection, MHD_HTTP_OK, response); + MHD_destroy_response(response); + return ret; +} + +int main(int argc, char *argv[]) { + struct MHD_Daemon *daemon; + + // Don't open a port and do not block so CI isn't interrupted. +#if 0 + daemon = MHD_start_daemon(MHD_USE_INTERNAL_POLLING_THREAD, + PORT, NULL, NULL, + &ahc_echo, NULL, MHD_OPTION_END); + if (daemon == NULL) { + return 1; + } + + (void)getchar(); +#else + daemon = NULL; +#endif + + MHD_stop_daemon(daemon); + return 0; +} diff --git a/recipes/libmicrohttpd/all/test_v1_package/CMakeLists.txt b/recipes/libmicrohttpd/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0b95e58322269 --- /dev/null +++ b/recipes/libmicrohttpd/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(libmicrohttpd REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libmicrohttpd::libmicrohttpd) diff --git a/recipes/libmicrohttpd/all/test_v1_package/conanfile.py b/recipes/libmicrohttpd/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libmicrohttpd/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libmicrohttpd/config.yml b/recipes/libmicrohttpd/config.yml new file mode 100644 index 0000000000000..48e6a23d34df6 --- /dev/null +++ b/recipes/libmicrohttpd/config.yml @@ -0,0 +1,3 @@ +versions: + "0.9.75": + folder: all diff --git a/recipes/libmikmod/all/conanfile.py b/recipes/libmikmod/all/conanfile.py index 60b46a37bbc40..1d04522f0806a 100644 --- a/recipes/libmikmod/all/conanfile.py +++ b/recipes/libmikmod/all/conanfile.py @@ -64,9 +64,9 @@ def configure(self): def requirements(self): if self.settings.os == "Linux": if self.options.with_alsa: - self.requires("libalsa/1.2.4") + self.requires("libalsa/1.2.7.2") if self.options.with_pulse: - self.requires("pulseaudio/13.0") + self.requires("pulseaudio/14.2") def source(self): tools.get(**self.conan_data["sources"][self.version]) diff --git a/recipes/libmodbus/all/conandata.yml b/recipes/libmodbus/all/conandata.yml index 53ef0226d6976..176711066e07f 100644 --- a/recipes/libmodbus/all/conandata.yml +++ b/recipes/libmodbus/all/conandata.yml @@ -1,8 +1,12 @@ sources: + "3.1.8": + url: "https://github.com/stephane/libmodbus/releases/download/v3.1.8/libmodbus-3.1.8.tar.gz" + sha256: "b122f2bc29f749702a22c0a760a7ca2182d541f5fa26bf25e3431f907b606f3c" "3.1.6": url: "https://libmodbus.org/releases/libmodbus-3.1.6.tar.gz" sha256: "d7d9fa94a16edb094e5fdf5d87ae17a0dc3f3e3d687fead81835d9572cf87c16" patches: + "3.1.8": + - patch_file: "patches/3.1.8-0001-msvc-fixes.patch" "3.1.6": - - patch_file: "patches/0001-msvc-fixes.patch" - base_path: "source_subfolder" + - patch_file: "patches/3.1.6-0001-msvc-fixes.patch" diff --git a/recipes/libmodbus/all/conanfile.py b/recipes/libmodbus/all/conanfile.py index be5af3a330a9b..6ec4cc6934e03 100644 --- a/recipes/libmodbus/all/conanfile.py +++ b/recipes/libmodbus/all/conanfile.py @@ -1,16 +1,25 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from contextlib import contextmanager +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, replace_in_file, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version import os +required_conan_version = ">=1.52.0" + + class LibmodbusConan(ConanFile): name = "libmodbus" description = "libmodbus is a free software library to send/receive data according to the Modbus protocol" homepage = "https://libmodbus.org/" - topics = ("conan", "libmodbus", "modbus", "protocol", "industry", "automation") + topics = ("modbus", "protocol", "industry", "automation") license = "LGPL-2.1" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "patches/**" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -21,15 +30,16 @@ class LibmodbusConan(ConanFile): "fPIC": True, } - _autotools = None - @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) @property - def _build_subfolder(self): - return "build_subfolder" + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -37,86 +47,90 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libmodbus-{}".format(self.version), self._source_subfolder) + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + basic_layout(self, src_folder="src") def build_requirements(self): - if self.settings.compiler == "Visual Studio": - self.build_requires("automake/1.16.1") - if tools.os_info.is_windows and "CONAN_BASH_PATH" not in os.environ \ - and tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - conf_args = [ - "--disable-tests", - "--without-documentation", - "--prefix={}".format(tools.unix_path(self.package_folder)), - ] - if self.options.shared: - conf_args.extend(["--enable-shared", "--disable-static"]) - else: - conf_args.extend(["--enable-static", "--disable-shared"]) - if self.settings.compiler == "Visual Studio": - if self.settings.build_type in ("Debug", "RelWithDebInfo"): - self._autotools.flags.append("-FS") - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return self._autotools - - @contextmanager - def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - env = { - "CC": "cl -nologo", - "CXX": "cl -nologo", - "LD": "link -nologo", - "AR": "{} \"lib -nologo -verbose\"".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), - "RANLIB": ":", - "STRING": ":", - "NM": "dumpbin -symbols"} - with tools.environment_append(env): - yield - else: - yield + if is_msvc(self): + self.tool_requires("automake/1.16.5") + if self._settings_build.os == "Windows": + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + self.tool_requires("msys2/cci.latest") + self.win_bash = True + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + if Version(self.version) < "3.1.8": + tc.configure_args.append("--without-documentation") + tc.configure_args.append("--disable-tests") + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + tc.generate() + + if is_msvc(self): + env = Environment() + compile_wrapper = unix_path(self, os.path.join(self.source_folder, "build-aux", "compile")) + ar_wrapper = unix_path(self, self._user_info_build["automake"].ar_lib) + env.define("CC", f"{compile_wrapper} cl -nologo") + env.define("CXX", f"{compile_wrapper} cl -nologo") + env.define("LD", "link -nologo") + env.define("AR", f"{ar_wrapper} \"lib -nologo\"") + env.define("NM", "dumpbin -symbols") + env.define("OBJDUMP", ":") + env.define("RANLIB", ":") + env.define("STRIP", ":") + env.vars(self).save_script("conanbuild_libmodbus_msvc") def _patch_sources(self): - for patchdata in self.conan_data["patches"][self.version]: - tools.patch(**patchdata) + apply_conandata_patches(self) if not self.options.shared: for decl in ("__declspec(dllexport)", "__declspec(dllimport)"): - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "modbus.h"), decl, "") + replace_in_file(self, os.path.join(self.source_folder, "src", "modbus.h"), decl, "") def build(self): self._patch_sources() - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - self.copy("COPYING*", src=self._source_subfolder, dst="licenses") - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() - - os.unlink(os.path.join(self.package_folder, "lib", "libmodbus.la")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + copy(self, pattern="COPYING*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # see https://github.com/conan-io/conan/issues/12006 + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + fix_apple_shared_install_name(self) + if is_msvc(self) and self.options.shared: + rename(self, + os.path.join(self.package_folder, "lib", "modbus.dll.lib"), + os.path.join(self.package_folder, "lib", "modbus.lib")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libmodbus") + self.cpp_info.libs = ["modbus"] self.cpp_info.includedirs.append(os.path.join("include", "modbus")) - lib = "modbus" - if self.settings.os == "Windows" and self.options.shared: - lib += ".dll" + (".lib" if self.settings.compiler == "Visual Studio" else ".a") - self.cpp_info.libs = [lib] - if not self.options.shared: - if self.settings.os == "Windows": - self.cpp_info.system_libs = ["wsock32"] + if self.settings.os == "Windows" and not self.options.shared: + self.cpp_info.system_libs = ["ws2_32"] diff --git a/recipes/libmodbus/all/patches/0001-msvc-fixes.patch b/recipes/libmodbus/all/patches/0001-msvc-fixes.patch deleted file mode 100644 index ef34b4f272cf0..0000000000000 --- a/recipes/libmodbus/all/patches/0001-msvc-fixes.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- src/Makefile.in -+++ src/Makefile.in -@@ -327,7 +327,7 @@ - localstatedir = @localstatedir@ - mandir = @mandir@ - mkdir_p = @mkdir_p@ --my_CFLAGS = @my_CFLAGS@ -+my_CFLAGS = - oldincludedir = @oldincludedir@ - pdfdir = @pdfdir@ - prefix = @prefix@ -diff -ur source_original/source_subfolder/src/modbus-private.h source/source_subfolder/src/modbus-private.h ---- src/modbus-private.h -+++ src/modbus-private.h -@@ -13,7 +13,7 @@ - #else - # include "stdint.h" - # include --typedef int ssize_t; -+//typedef int ssize_t; - #endif - #include - #include diff --git a/recipes/libmodbus/all/patches/3.1.6-0001-msvc-fixes.patch b/recipes/libmodbus/all/patches/3.1.6-0001-msvc-fixes.patch new file mode 100644 index 0000000000000..de64a8e50f76f --- /dev/null +++ b/recipes/libmodbus/all/patches/3.1.6-0001-msvc-fixes.patch @@ -0,0 +1,22 @@ +--- src/Makefile.in ++++ src/Makefile.in +@@ -327,7 +327,7 @@ + localstatedir = @localstatedir@ + mandir = @mandir@ + mkdir_p = @mkdir_p@ +-my_CFLAGS = @my_CFLAGS@ ++my_CFLAGS = + oldincludedir = @oldincludedir@ + pdfdir = @pdfdir@ + prefix = @prefix@ +--- src/modbus-private.h ++++ src/modbus-private.h +@@ -13,7 +13,7 @@ + #else + # include "stdint.h" + # include +-typedef int ssize_t; ++//typedef int ssize_t; + #endif + #include + #include diff --git a/recipes/libmodbus/all/patches/3.1.8-0001-msvc-fixes.patch b/recipes/libmodbus/all/patches/3.1.8-0001-msvc-fixes.patch new file mode 100644 index 0000000000000..376a6b3f1ea82 --- /dev/null +++ b/recipes/libmodbus/all/patches/3.1.8-0001-msvc-fixes.patch @@ -0,0 +1,22 @@ +--- src/Makefile.in ++++ src/Makefile.in +@@ -326,7 +326,7 @@ + localstatedir = @localstatedir@ + mandir = @mandir@ + mkdir_p = @mkdir_p@ +-my_CFLAGS = @my_CFLAGS@ ++my_CFLAGS = + oldincludedir = @oldincludedir@ + pdfdir = @pdfdir@ + prefix = @prefix@ +--- src/modbus-private.h ++++ src/modbus-private.h +@@ -13,7 +13,7 @@ + #else + # include "stdint.h" + # include +-typedef int ssize_t; ++//typedef int ssize_t; + #endif + #include + #include diff --git a/recipes/libmodbus/all/test_package/CMakeLists.txt b/recipes/libmodbus/all/test_package/CMakeLists.txt index a384aa820f158..589d598cde656 100644 --- a/recipes/libmodbus/all/test_package/CMakeLists.txt +++ b/recipes/libmodbus/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libmodbus REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libmodbus::libmodbus) diff --git a/recipes/libmodbus/all/test_package/conanfile.py b/recipes/libmodbus/all/test_package/conanfile.py index 965934f873bd7..49ea0c6cecc47 100644 --- a/recipes/libmodbus/all/test_package/conanfile.py +++ b/recipes/libmodbus/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) - + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libmodbus/all/test_package/test_package.c b/recipes/libmodbus/all/test_package/test_package.c new file mode 100644 index 0000000000000..e9bd9b1a77ac6 --- /dev/null +++ b/recipes/libmodbus/all/test_package/test_package.c @@ -0,0 +1,12 @@ +#include + +#include +#include + +int main() { + if (modbus_get_slave(NULL) != -1) { + fprintf(stderr, "modbus_get_slave(NULL) failed\n"); + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/recipes/libmodbus/all/test_package/test_package.cpp b/recipes/libmodbus/all/test_package/test_package.cpp deleted file mode 100644 index c3d2b529852a7..0000000000000 --- a/recipes/libmodbus/all/test_package/test_package.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "modbus/modbus.h" - -#include -#include - -int main() { - if (modbus_get_slave(NULL) != -1) { - std::cerr << "modbus_get_slave(NULL) failed\n"; - return EXIT_FAILURE; - } - return EXIT_SUCCESS; -} diff --git a/recipes/libmodbus/all/test_v1_package/CMakeLists.txt b/recipes/libmodbus/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d03cbd8daf516 --- /dev/null +++ b/recipes/libmodbus/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libmodbus CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libmodbus::libmodbus) diff --git a/recipes/libmodbus/all/test_v1_package/conanfile.py b/recipes/libmodbus/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a691174f8ed16 --- /dev/null +++ b/recipes/libmodbus/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + diff --git a/recipes/libmodbus/config.yml b/recipes/libmodbus/config.yml index 150202a06b911..49c098a9b7d41 100644 --- a/recipes/libmodbus/config.yml +++ b/recipes/libmodbus/config.yml @@ -1,3 +1,5 @@ versions: + "3.1.8": + folder: all "3.1.6": folder: all diff --git a/recipes/libmodplug/all/conandata.yml b/recipes/libmodplug/all/conandata.yml index 72f6a85491fd6..1e46cfd6924a1 100644 --- a/recipes/libmodplug/all/conandata.yml +++ b/recipes/libmodplug/all/conandata.yml @@ -2,3 +2,7 @@ sources: "0.8.9.0": url: "https://github.com/Konstanty/libmodplug/archive/5a39f5913d07ba3e61d8d5afdba00b70165da81d.zip" sha256: "12d12362428ebcefd473e56ff94faa6ee5c066b777e153d2bbca15c1e379d1bc" +patches: + "0.8.9.0": + - patch_file: "patches/0001-cmake-install-dll.patch" + base_path: "source_subfolder" diff --git a/recipes/libmodplug/all/conanfile.py b/recipes/libmodplug/all/conanfile.py index 8e8876581a8f2..572c3a203d05d 100644 --- a/recipes/libmodplug/all/conanfile.py +++ b/recipes/libmodplug/all/conanfile.py @@ -1,6 +1,8 @@ from conans import ConanFile, CMake, tools import os +required_conan_version = ">=1.33.0" + class LibmodplugConan(ConanFile): name = "libmodplug" @@ -10,32 +12,45 @@ class LibmodplugConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "http://modplug-xmms.sourceforge.net" license = "Unlicense" # public domain - exports_sources = ["CMakeLists.txt"] - generators = "cmake" settings = "os", "arch", "compiler", "build_type" options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True} - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + def source(self): - commit = os.path.splitext(os.path.basename(self.conan_data["sources"][self.version]["url"]))[0] - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + commit - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): - cmake = CMake(self) - cmake.configure(build_folder=self._build_subfolder) - return cmake + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) cmake = self._configure_cmake() cmake.build() @@ -43,12 +58,16 @@ def package(self): self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.names["pkg_config"] = "libmodplug" self.cpp_info.libs = ["modplug"] - self.cpp_info.bindirs = ["lib"] self.cpp_info.includedirs.append(os.path.join("include", "libmodplug")) + if self.settings.os == "Linux": + self.cpp_info.system_libs.extend(["m"]) if not self.options.shared: self.cpp_info.defines.append("MODPLUG_STATIC") + stdcpp_library = tools.stdcpp_library(self) + if stdcpp_library: + self.cpp_info.system_libs.extend([stdcpp_library]) diff --git a/recipes/libmodplug/all/patches/0001-cmake-install-dll.patch b/recipes/libmodplug/all/patches/0001-cmake-install-dll.patch new file mode 100644 index 0000000000000..f37402e012f91 --- /dev/null +++ b/recipes/libmodplug/all/patches/0001-cmake-install-dll.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -109,7 +109,7 @@ add_library(modplug ${LIB_TYPE} + ) + + # install the library: +-install(TARGETS modplug DESTINATION lib) ++install(TARGETS modplug RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + + # incstall the headers: + install(FILES diff --git a/recipes/libmodplug/all/test_package/CMakeLists.txt b/recipes/libmodplug/all/test_package/CMakeLists.txt index 196188113685c..f8b971e2db377 100644 --- a/recipes/libmodplug/all/test_package/CMakeLists.txt +++ b/recipes/libmodplug/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -add_executable(${PROJECT_NAME} test_package.cpp) +add_executable(${PROJECT_NAME} test_package.c) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libmodplug/all/test_package/conanfile.py b/recipes/libmodplug/all/test_package/conanfile.py index 95d238976db9e..bd7165a553cf4 100644 --- a/recipes/libmodplug/all/test_package/conanfile.py +++ b/recipes/libmodplug/all/test_package/conanfile.py @@ -13,11 +13,5 @@ def build(self): def test(self): if not tools.cross_building(self.settings): - # Download a public domain xm file; https://modarchive.org/module.php?178293 - tools.download( - "https://api.modarchive.org/downloads.php?moduleid=178293#burbs.xm", - filename="burbs.xm", - sha256="ced080401a2635cddc6d13b9095efa217f260ce7b3a482a29b454f72317b0c4d", - ) bin_path = os.path.join("bin", "test_package") - self.run("%s %s" % (bin_path, "burbs.xm"), run_environment=True) + self.run(bin_path, run_environment=True) diff --git a/recipes/libmodplug/all/test_package/test_package.c b/recipes/libmodplug/all/test_package/test_package.c new file mode 100644 index 0000000000000..6658ff355ef8d --- /dev/null +++ b/recipes/libmodplug/all/test_package/test_package.c @@ -0,0 +1,69 @@ +#include +#include +#include +#include +#include + +/* https://github.com/lclevy/unmo3/blob/master/spec/xm.txt */ + +#pragma pack(push, 1) + +typedef struct xm_t +{ + char id_text[17]; + char module_name[20]; + char nl; + char tracker_name[20]; + uint16_t version; + uint32_t header_size; + uint16_t song_length; + uint16_t restart_position; + uint16_t number_of_channels; + uint16_t number_of_patterns; + uint16_t number_of_instruments; + uint16_t flags; + uint16_t default_tempo; + uint16_t default_bmp; + uint8_t pattern_order_table[256]; +} +xm_t; + +#pragma pack(pop) + +#define SIZE 0x200 + +int main(int argc, char * const argv[]) +{ + unsigned char b[SIZE]; + FILE * f = NULL; + long fsize = 0; + ModPlugFile * m = NULL; + xm_t * xm = (xm_t*) b; + memset(b, 0, SIZE); + + memcpy(xm->id_text, "Extended Module:", 17); + memcpy(xm->module_name, "My Module ", 20); + xm->nl = 0x1A; + memcpy(xm->tracker_name, "FastTracker II ", 20); + xm->version = 0x0103; + xm->header_size = sizeof(xm_t); + xm->song_length = 1; + xm->restart_position = 0; + xm->number_of_channels = 2; + xm->number_of_patterns = 0; + xm->number_of_instruments = 0; + xm->flags = 1; + xm->default_tempo = 1; + xm->default_bmp = 1; + + m = ModPlug_Load(b, SIZE); + if (!m) + { + return -4; + } + printf("name: %s\n", ModPlug_GetName(m)); + printf("length: %d ms\n", (int) ModPlug_GetLength(m)); + + ModPlug_Unload(m); + return 0; +} diff --git a/recipes/libmodplug/all/test_package/test_package.cpp b/recipes/libmodplug/all/test_package/test_package.cpp deleted file mode 100644 index b56301555f0f5..0000000000000 --- a/recipes/libmodplug/all/test_package/test_package.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include -#include - -int main(int argc, char * const argv[]) -{ - if (argc < 2) - return -1; - FILE * f = fopen(argv[1], "rb"); - if (!f) - return -2; - - fseek(f, 0, SEEK_END); - long fsize = ftell(f); - fseek(f, 0, SEEK_SET); - - std::vector b(fsize); - fread(&b[0], fsize, 1, f); - - fclose(f); - - ModPlugFile * m = ModPlug_Load(&b[0], fsize); - if (!m) - return -3; - - std::cout << "name: " << ModPlug_GetName(m) << std::endl; - std::cout << "length: " << ModPlug_GetLength(m) << " ms" << std::endl; - - ModPlug_Unload(m); - return 0; -} diff --git a/recipes/libmorton/all/conandata.yml b/recipes/libmorton/all/conandata.yml index c454b750dda5e..b2711e5d1b695 100644 --- a/recipes/libmorton/all/conandata.yml +++ b/recipes/libmorton/all/conandata.yml @@ -1,4 +1,13 @@ sources: + "0.2.10": + url: "https://github.com/Forceflow/libmorton/archive/refs/tags/v0.2.10.tar.gz" + sha256: "5f4a8dbf350222b0bec35ad1bee6b76fa22e16ea364e1e80ca47d8f5a7210d6f" + "0.2.9": + url: "https://github.com/Forceflow/libmorton/archive/refs/tags/v0.2.9.tar.gz" + sha256: "a3c86360a6cb97bfcad60216d44f30870e9d20c6f62610c4617a74bf678c9cc8" + "0.2.7": + url: "https://github.com/Forceflow/libmorton/archive/refs/tags/v0.2.7.tar.gz" + sha256: "02bf640732750a5db638991b9f63049252f9656ef52a00d30d2a90df542b9ecf" "0.2.6": url: "https://github.com/Forceflow/libmorton/archive/v0.2.6.tar.gz" sha256: "466e31af19b49399426a860107f7fe9336ee784e46e49070959b3ac300f0d90d" @@ -8,4 +17,3 @@ sources: patches: "0.2.5": - patch_file: "patches/missing-includes.patch" - base_path: "source_subfolder" diff --git a/recipes/libmorton/all/conanfile.py b/recipes/libmorton/all/conanfile.py index 78e1cca137250..2d5d75fd6eb1b 100644 --- a/recipes/libmorton/all/conanfile.py +++ b/recipes/libmorton/all/conanfile.py @@ -1,39 +1,57 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +required_conan_version = ">=1.50.0" + class LibmortonConan(ConanFile): name = "libmorton" description = "C++ header-only library with methods to efficiently " \ "encode/decode 64, 32 and 16-bit Morton codes and coordinates, in 2D and 3D." license = "MIT" - topics = ("conan", "libmorton", "morton", "encoding", "decoding") + topics = ("libmorton", "morton", "encoding", "decoding") homepage = "https://github.com/Forceflow/libmorton" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler" - exports_sources = "patches/**" - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "libmorton", "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if Version(self.version) < "0.2.7": + src_hdrs = os.path.join(self.source_folder, "libmorton", "include") + elif Version(self.version) < "0.2.8": + src_hdrs = os.path.join(self.source_folder, "libmorton") + else: + src_hdrs = os.path.join(self.source_folder, "include", "libmorton") + copy(self, "*.h", src=src_hdrs, dst=os.path.join(self.package_folder, "include", "libmorton")) def package_info(self): - if self.settings.compiler == "Visual Studio": - self.cpp_info.defines = ["NOMINMAX"] - if self.settings.os == "Linux": + self.cpp_info.set_property("cmake_file_name", "libmorton") + self.cpp_info.set_property("cmake_target_name", "libmorton::libmorton") + self.cpp_info.set_property("pkg_config_name", "libmorton") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] diff --git a/recipes/libmorton/all/test_package/CMakeLists.txt b/recipes/libmorton/all/test_package/CMakeLists.txt index 196188113685c..375f2c7456c98 100644 --- a/recipes/libmorton/all/test_package/CMakeLists.txt +++ b/recipes/libmorton/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libmorton REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libmorton::libmorton) diff --git a/recipes/libmorton/all/test_package/conanfile.py b/recipes/libmorton/all/test_package/conanfile.py index bd7165a553cf4..d120a992c06a6 100644 --- a/recipes/libmorton/all/test_package/conanfile.py +++ b/recipes/libmorton/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libmorton/all/test_package/test_package.cpp b/recipes/libmorton/all/test_package/test_package.cpp index 77ec1c2deed61..f80ea584ebb2e 100644 --- a/recipes/libmorton/all/test_package/test_package.cpp +++ b/recipes/libmorton/all/test_package/test_package.cpp @@ -1,4 +1,4 @@ -#include +#include #include diff --git a/recipes/libmorton/all/test_v1_package/CMakeLists.txt b/recipes/libmorton/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..eae8e7086d06f --- /dev/null +++ b/recipes/libmorton/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libmorton REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libmorton::libmorton) diff --git a/recipes/libmorton/all/test_v1_package/conanfile.py b/recipes/libmorton/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libmorton/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libmorton/config.yml b/recipes/libmorton/config.yml index fd2946f31c873..a6dfd9ecb4855 100644 --- a/recipes/libmorton/config.yml +++ b/recipes/libmorton/config.yml @@ -1,4 +1,10 @@ versions: + "0.2.10": + folder: all + "0.2.9": + folder: all + "0.2.7": + folder: all "0.2.6": folder: all "0.2.5": diff --git a/recipes/libmount/all/conanfile.py b/recipes/libmount/all/conanfile.py index 57654aba71d0d..8285c441a6f9a 100644 --- a/recipes/libmount/all/conanfile.py +++ b/recipes/libmount/all/conanfile.py @@ -1,62 +1,75 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.53.0" + class LibmountConan(ConanFile): name = "libmount" - description = "The libmount library is used to parse /etc/fstab, /etc/mtab and /proc/self/mountinfo files, manage the mtab file, evaluate mount options, etc" - topics = ("conan", "mount", "libmount", "linux", "util-linux") + description = ( + "The libmount library is used to parse /etc/fstab, /etc/mtab and " + "/proc/self/mountinfo files, manage the mtab file, evaluate mount options, etc" + ) + topics = ("mount", "linux", "util-linux") url = "https://github.com/conan-io/conan-center-index" homepage = "https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git" license = "GPL-2.0-or-later" + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _source_subfolder = "source_subfolder" - _autotools = None + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.settings.os != "Linux": + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.os != "Linux": raise ConanInvalidConfiguration("only Linux is supported") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "util-linux-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_autotools(self): - if not self._autotools: - args = ["--disable-all-programs", "--enable-libmount", "--enable-libblkid"] - if self.options.shared: - args.extend(["--disable-static", "--enable-shared"]) - else: - args.extend(["--disable-shared", "--enable-static"]) - self._autotools = AutoToolsBuildEnvironment(self) - self._autotools.configure(args=args) - return self._autotools + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ + "--disable-all-programs", + "--enable-libmount", + "--enable-libblkid", + ]) + tc.generate() def build(self): - with tools.chdir(self._source_subfolder): - env_build = self._configure_autotools() - env_build.make() + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - with tools.chdir(self._source_subfolder): - env_build = self._configure_autotools() - env_build.install() - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "sbin")) - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - os.remove(os.path.join(self.package_folder, "lib", "libblkid.la")) - os.remove(os.path.join(self.package_folder, "lib", "libmount.la")) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "sbin")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) def package_info(self): self.cpp_info.libs = ["mount", "blkid"] self.cpp_info.includedirs.append(os.path.join("include", "libmount")) - self.cpp_info.names['pkg_config'] = 'mount' + self.cpp_info.set_property("pkg_config_name", "mount") diff --git a/recipes/libmount/all/test_package/CMakeLists.txt b/recipes/libmount/all/test_package/CMakeLists.txt index 07c73ca721730..79b7610d1fb9b 100644 --- a/recipes/libmount/all/test_package/CMakeLists.txt +++ b/recipes/libmount/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libmount REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libmount::libmount) diff --git a/recipes/libmount/all/test_package/conanfile.py b/recipes/libmount/all/test_package/conanfile.py index bd7165a553cf4..0a6bc68712d90 100644 --- a/recipes/libmount/all/test_package/conanfile.py +++ b/recipes/libmount/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libmount/all/test_package/test_package.c b/recipes/libmount/all/test_package/test_package.c new file mode 100644 index 0000000000000..d4e4d653742e8 --- /dev/null +++ b/recipes/libmount/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include + +#include +#include + +int main() +{ + struct libmnt_context *ctx = mnt_new_context(); + if (!ctx) { + printf("failed to initialize libmount\n"); + return EXIT_FAILURE; + } + printf("path to fstab: %s", mnt_get_fstab_path()); + mnt_free_context(ctx); + return EXIT_SUCCESS; +} diff --git a/recipes/libmount/all/test_package/test_package.cpp b/recipes/libmount/all/test_package/test_package.cpp deleted file mode 100644 index ffaa9287dac66..0000000000000 --- a/recipes/libmount/all/test_package/test_package.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include - -int main() -{ - struct libmnt_context *ctx = mnt_new_context(); - if (!ctx) { - std::cerr << "failed to initialize libmount\n"; - return EXIT_FAILURE; - } - std::cout << "path to fstab: " << mnt_get_fstab_path() << std::endl; - mnt_free_context(ctx); - return EXIT_SUCCESS; -} diff --git a/recipes/libmount/all/test_v1_package/CMakeLists.txt b/recipes/libmount/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libmount/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libmount/all/test_v1_package/conanfile.py b/recipes/libmount/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libmount/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libmp3lame/all/conandata.yml b/recipes/libmp3lame/all/conandata.yml index 1ee33b83b9600..ccb693b07c678 100644 --- a/recipes/libmp3lame/all/conandata.yml +++ b/recipes/libmp3lame/all/conandata.yml @@ -2,3 +2,16 @@ sources: "3.100": url: "https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz" sha256: "ddfe36cab873794038ae2c1210557ad34857a4b6bdc515785d1da9e175b1da1e" +patches: + "3.100": + - patch_file: "patches/6410.patch" + patch_type: "backport" + patch_description: "bug tracker item #487: v3.100 breaks Windows compatibility" + patch_source: "https://sourceforge.net/p/lame/svn/commit_browser -- [r6410]" + - patch_file: "patches/6416.patch" + patch_type: "backport" + patch_description: "lame patches ticket #75: Fix for completing svn-r6410" + patch_source: "https://sourceforge.net/p/lame/svn/commit_browser -- [r6410]" + - patch_file: "patches/android.patch" + patch_type: "portability" + patch_description: "Add __ANDROID__ test to one bit" diff --git a/recipes/libmp3lame/all/conanfile.py b/recipes/libmp3lame/all/conanfile.py index b82c59439e083..a7f412633c3e7 100644 --- a/recipes/libmp3lame/all/conanfile.py +++ b/recipes/libmp3lame/all/conanfile.py @@ -1,110 +1,162 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conan import ConanFile +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rename, replace_in_file, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path, VCVars import os import shutil +required_conan_version = ">=1.53.0" + class LibMP3LameConan(ConanFile): name = "libmp3lame" url = "https://github.com/conan-io/conan-center-index" description = "LAME is a high quality MPEG Audio Layer III (MP3) encoder licensed under the LGPL." homepage = "http://lame.sourceforge.net" - topics = ("conan", "libmp3lame", "multimedia", "audio", "mp3", "decoder", "encoding", "decoding") + topics = "multimedia", "audio", "mp3", "decoder", "encoding", "decoding" license = "LGPL-2.0" - exports_sources = ["6410.patch", "6416.patch", "android.patch"] + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _autotools = None + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } @property - def _use_winbash(self): - return tools.os_info.is_windows and (self.settings.compiler == "gcc" or tools.cross_building(self.settings)) + def _is_clang_cl(self): + return str(self.settings.compiler) in ["clang"] and str(self.settings.os) in ['Windows'] @property - def _is_msvc(self): - return self.settings.compiler == 'Visual Studio' + def _settings_build(self): + return getattr(self, "settings_build", self.settings) - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def build_requirements(self): + if not is_msvc(self) and not self._is_clang_cl: + self.tool_requires("gnu-config/cci.20210814") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "lame-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - def _apply_patch(self): - tools.replace_in_file(os.path.join(self._source_subfolder, 'include', 'libmp3lame.sym'), 'lame_init_old\n', '') - for patch in [6410, 6416]: - tools.patch(base_path=self._source_subfolder, patch_file='%s.patch' % patch, strip=3) - tools.patch(base_path=self._source_subfolder, patch_file='android.patch') + def _generate_vs(self): + tc = VCVars(self) + tc.generate() + # FIXME: no conan v2 build helper for NMake yet (see https://github.com/conan-io/conan/issues/12188) + # So populate CL with AutotoolsToolchain cflags + c_flags = AutotoolsToolchain(self).cflags + if c_flags: + env = Environment() + env.define("CL", c_flags) + env.vars(self).save_script("conanbuildenv_nmake") - def _build_vs(self): - with tools.chdir(self._source_subfolder): - shutil.copy('configMS.h', 'config.h') - command = 'nmake -f Makefile.MSVC comp=msvc asm=yes' - if self.settings.arch == 'x86_64': - tools.replace_in_file('Makefile.MSVC', 'MACHINE = /machine:I386', 'MACHINE =/machine:X64') - command += ' MSVCVER=Win64' - if self.options.shared: - command += ' dll' - with tools.vcvars(self.settings, filter_known_paths=False, force=True): - self.run(command) + def _generate_autotools(self): + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.configure_args.append("--disable-frontend") + if self.settings.compiler == "clang" and self.settings.arch in ["x86", "x86_64"]: + tc.extra_cxxflags.extend(["-mmmx", "-msse"]) + tc.generate() - def _configure_autotools(self): - if not self._autotools: - args = [] - if self.options.shared: - args.extend(['--disable-static', '-enable-shared']) + def generate(self): + if is_msvc(self) or self._is_clang_cl: + self._generate_vs() + else: + self._generate_autotools() + + def _build_vs(self): + with chdir(self, self.source_folder): + shutil.copy2("configMS.h", "config.h") + # Honor vc runtime + replace_in_file(self, "Makefile.MSVC", "CC_OPTS = $(CC_OPTS) /MT", "") + # Do not hardcode LTO + replace_in_file(self, "Makefile.MSVC", " /GL", "") + replace_in_file(self, "Makefile.MSVC", " /LTCG", "") + replace_in_file(self, "Makefile.MSVC", "ADDL_OBJ = bufferoverflowU.lib", "") + command = "nmake -f Makefile.MSVC comp=msvc" + if self._is_clang_cl: + cl = os.environ.get("CC", "clang-cl") + link = os.environ.get("LD", "lld-link") + replace_in_file(self, "Makefile.MSVC", "CC = cl", f"CC = {cl}") + replace_in_file(self, "Makefile.MSVC", "LN = link", f"LN = {link}") + # what is /GAy? MSDN doesn't know it + # clang-cl: error: no such file or directory: '/GAy' + # https://docs.microsoft.com/en-us/cpp/build/reference/ga-optimize-for-windows-application?view=msvc-170 + replace_in_file(self, "Makefile.MSVC", "/GAy", "/GA") + if self.settings.arch == "x86_64": + replace_in_file(self, "Makefile.MSVC", "MACHINE = /machine:I386", "MACHINE =/machine:X64") + command += " MSVCVER=Win64 asm=yes" + elif self.settings.arch == "armv8": + replace_in_file(self, "Makefile.MSVC", "MACHINE = /machine:I386", "MACHINE =/machine:ARM64") + command += " MSVCVER=Win64" else: - args.extend(['--disable-shared', '--enable-static']) - if self.settings.build_type == 'Debug': - args.append('--enable-debug') - if self.settings.os != 'Windows' and self.options.fPIC: - args.append('--with-pic') - - self._autotools = AutoToolsBuildEnvironment(self, win_bash=self._use_winbash) - if self.settings.compiler == 'clang' and self.settings.arch in ['x86', 'x86_64']: - self._autotools.flags.extend(['-mmmx', '-msse']) - self._autotools.configure(args=args, configure_dir=self._source_subfolder) - return self._autotools - - def _build_configure(self): - autotools = self._configure_autotools() + command += " asm=yes" + command += " libmp3lame.dll" if self.options.shared else " libmp3lame-static.lib" + self.run(command) + + def _build_autotools(self): + for gnu_config in [ + self.conf.get("user.gnu-config:config_guess", check_type=str), + self.conf.get("user.gnu-config:config_sub", check_type=str), + ]: + if gnu_config: + copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder) + autotools = Autotools(self) + autotools.configure() autotools.make() def build(self): - self._apply_patch() - if self._is_msvc: + apply_conandata_patches(self) + replace_in_file(self, os.path.join(self.source_folder, "include", "libmp3lame.sym"), "lame_init_old\n", "") + + if is_msvc(self) or self._is_clang_cl: self._build_vs() else: - self._build_configure() + self._build_autotools() def package(self): - self.copy(pattern="LICENSE", src=self._source_subfolder, dst="licenses") - if self._is_msvc: - self.copy(pattern='*.h', src=os.path.join(self._source_subfolder, 'include'), dst=os.path.join('include', 'lame')) - self.copy(pattern='*.lib', src=os.path.join(self._source_subfolder, 'output'), dst='lib') - self.copy(pattern='*.exe', src=os.path.join(self._source_subfolder, 'output'), dst='bin') + copy(self, pattern="LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder,"licenses")) + if is_msvc(self) or self._is_clang_cl: + copy(self, pattern="*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder,"include", "lame")) + name = "libmp3lame.lib" if self.options.shared else "libmp3lame-static.lib" + copy(self, name, src=os.path.join(self.source_folder, "output"), dst=os.path.join(self.package_folder,"lib")) if self.options.shared: - self.copy(pattern='*.dll', src=os.path.join(self._source_subfolder, 'output'), dst='bin') - name = 'libmp3lame.lib' if self.options.shared else 'libmp3lame-static.lib' - shutil.move(os.path.join(self.package_folder, 'lib', name), - os.path.join(self.package_folder, 'lib', 'mp3lame.lib')) + copy(self, pattern="*.dll", src=os.path.join(self.source_folder, "output"), dst=os.path.join(self.package_folder,"bin")) + rename(self, os.path.join(self.package_folder, "lib", name), + os.path.join(self.package_folder, "lib", "mp3lame.lib")) else: - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, "bin")) - tools.rmdir(os.path.join(self.package_folder, 'share')) - la_file = os.path.join(self.package_folder, "lib", "libmp3lame.la") - if os.path.isfile(la_file): - os.unlink(la_file) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) def package_info(self): self.cpp_info.libs = ["mp3lame"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] diff --git a/recipes/libmp3lame/all/6410.patch b/recipes/libmp3lame/all/patches/6410.patch similarity index 97% rename from recipes/libmp3lame/all/6410.patch rename to recipes/libmp3lame/all/patches/6410.patch index fafa993b18318..be5b608edd1fb 100644 --- a/recipes/libmp3lame/all/6410.patch +++ b/recipes/libmp3lame/all/patches/6410.patch @@ -1,5 +1,5 @@ ---- a/trunk/lame/frontend/parse.c -+++ b/trunk/lame/frontend/parse.c +--- a/frontend/parse.c ++++ b/frontend/parse.c @@ -70,8 +70,10 @@ #ifdef HAVE_ICONV #include diff --git a/recipes/libmp3lame/all/6416.patch b/recipes/libmp3lame/all/patches/6416.patch similarity index 86% rename from recipes/libmp3lame/all/6416.patch rename to recipes/libmp3lame/all/patches/6416.patch index 020cab35d4861..65ee30e94e510 100644 --- a/recipes/libmp3lame/all/6416.patch +++ b/recipes/libmp3lame/all/patches/6416.patch @@ -1,5 +1,5 @@ ---- a/trunk/lame/configure.in -+++ b/trunk/lame/configure.in +--- a/configure.in ++++ b/configure.in @@ -421,6 +421,7 @@ AC_CHECK_LIB(termcap, initscr, HAVE_TERMCAP="termcap") AC_CHECK_LIB(curses, initscr, HAVE_TERMCAP="curses") @@ -8,8 +8,8 @@ AM_ICONV ---- a/trunk/lame/frontend/parse.c -+++ b/trunk/lame/frontend/parse.c +--- a/frontend/parse.c ++++ b/frontend/parse.c @@ -70,7 +70,7 @@ #ifdef HAVE_ICONV #include diff --git a/recipes/libmp3lame/all/android.patch b/recipes/libmp3lame/all/patches/android.patch similarity index 82% rename from recipes/libmp3lame/all/android.patch rename to recipes/libmp3lame/all/patches/android.patch index 72824ad905a64..6ea069c01c147 100644 --- a/recipes/libmp3lame/all/android.patch +++ b/recipes/libmp3lame/all/patches/android.patch @@ -1,5 +1,5 @@ ---- libmp3lame/util.c -+++ libmp3lame/util.c +--- a/libmp3lame/util.c ++++ b/libmp3lame/util.c @@ -911,7 +911,7 @@ mask &= ~(_EM_OVERFLOW | _EM_ZERODIVIDE | _EM_INVALID); _FPU_SETCW(mask); diff --git a/recipes/libmp3lame/all/test_package/CMakeLists.txt b/recipes/libmp3lame/all/test_package/CMakeLists.txt index 196188113685c..c1f711f1d8871 100644 --- a/recipes/libmp3lame/all/test_package/CMakeLists.txt +++ b/recipes/libmp3lame/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libmp3lame REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libmp3lame::libmp3lame) diff --git a/recipes/libmp3lame/all/test_package/conanfile.py b/recipes/libmp3lame/all/test_package/conanfile.py index d72642c4343c5..48499fa0989d9 100644 --- a/recipes/libmp3lame/all/test_package/conanfile.py +++ b/recipes/libmp3lame/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os +# It will become the standard on Conan 2.x class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,7 +22,6 @@ def build(self): cmake.build() def test(self): - if tools.cross_building(self.settings, skip_x64_x86=True): - return - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libmp3lame/all/test_package/test_package.c b/recipes/libmp3lame/all/test_package/test_package.c new file mode 100644 index 0000000000000..dc25ae51ee161 --- /dev/null +++ b/recipes/libmp3lame/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include + +#include +#include + +int main() +{ + printf("%s\n", get_lame_version()); + return EXIT_SUCCESS; +} diff --git a/recipes/libmp3lame/all/test_package/test_package.cpp b/recipes/libmp3lame/all/test_package/test_package.cpp deleted file mode 100644 index edb054bbcd248..0000000000000 --- a/recipes/libmp3lame/all/test_package/test_package.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include "lame/lame.h" - -int main() -{ - std::cout << get_lame_version() << std::endl; - return EXIT_SUCCESS; -} diff --git a/recipes/libmp3lame/all/test_v1_package/CMakeLists.txt b/recipes/libmp3lame/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libmp3lame/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libmp3lame/all/test_v1_package/conanfile.py b/recipes/libmp3lame/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libmp3lame/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libmysqlclient/all/CMakeLists.txt b/recipes/libmysqlclient/all/CMakeLists.txt index 818be56627fa3..b8a3a9f77e058 100644 --- a/recipes/libmysqlclient/all/CMakeLists.txt +++ b/recipes/libmysqlclient/all/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) - +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) -message(WARNING "Conan libMySQLclient Wrapped CMake") include(../conanbuildinfo.cmake) -conan_basic_setup(NO_OUTPUT_DIRS) +conan_basic_setup(NO_OUTPUT_DIRS KEEP_RPATHS) + include("CMakeListsOriginal.txt") diff --git a/recipes/libmysqlclient/all/conandata.yml b/recipes/libmysqlclient/all/conandata.yml index a3f8111f0343c..3284d28321c06 100644 --- a/recipes/libmysqlclient/all/conandata.yml +++ b/recipes/libmysqlclient/all/conandata.yml @@ -1,14 +1,36 @@ sources: + "8.0.30": + url: + - "https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.30.tar.gz" + - "https://mirrors.huaweicloud.com/mysql/Downloads/MySQL-8.0/mysql-8.0.30.tar.gz" + sha256: "c988d5c6ba9a56692a6cd6e9813465b5fc9368ed4b461df97059a2fc160c8b84" + "8.0.29": + url: + - "https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.29.tar.gz" + - "https://mirrors.huaweicloud.com/mysql/Downloads/MySQL-8.0/mysql-8.0.29.tar.gz" + sha256: "512170fa6f78a694d6f18d197e999d2716ee68dc541d7644dd922a3663407266" + "8.0.25": + url: "https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.25.tar.gz" + sha256: "c16aa9cf621bc028efba2bb11f3c36a323b125fa0d108ff92fab60e46309206e" "8.0.17": - sha256: c6e3f38199a77bfd8a4925ca00b252d3b6159b90e4980c7232f1c58d6ca759d6 url: "https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.17.tar.gz" + sha256: "c6e3f38199a77bfd8a4925ca00b252d3b6159b90e4980c7232f1c58d6ca759d6" patches: + "8.0.30": + - patch_file: "patches/0006-fix-cpp20-build-8.0.29.patch" + base_path: "source_subfolder" + "8.0.29": + - patch_file: "patches/0006-fix-cpp20-build-8.0.29.patch" + base_path: "source_subfolder" + "8.0.25": + - patch_file: "patches/0004-fix-805-cpp17-build.patch" + base_path: "source_subfolder" + - patch_file: "patches/0005-fix-macos-12.0.x-version-detection.patch" + base_path: "source_subfolder" "8.0.17": - - base_path: "source_subfolder" - patch_file: "patches/0001-find-cmake.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-dont-install-static-libraries+fix-mysql-config.patch" - - base_path: "source_subfolder" - patch_file: "patches/0003-msvc-install-no-pdb.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-find-openssl-debug.patch" + - patch_file: "patches/0001-find-cmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-dont-install-static-libraries+fix-mysql-config.patch" + base_path: "source_subfolder" + - patch_file: "patches/0003-msvc-install-no-pdb.patch" + base_path: "source_subfolder" diff --git a/recipes/libmysqlclient/all/conanfile.py b/recipes/libmysqlclient/all/conanfile.py index 8db23d72f11af..5e8d487675d90 100644 --- a/recipes/libmysqlclient/all/conanfile.py +++ b/recipes/libmysqlclient/all/conanfile.py @@ -1,55 +1,66 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -from conans.tools import Version +from conan.tools.microsoft import is_msvc, msvc_runtime_flag +from conan.tools.files import rename, get, apply_conandata_patches, replace_in_file, rmdir, rm +from conan.tools.build import cross_building +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.scm import Version +from conan.tools.apple import is_apple_os +from conans import CMake, tools +import functools import os -import glob + +required_conan_version = ">=1.51.3" class LibMysqlClientCConan(ConanFile): name = "libmysqlclient" - url = "https://github.com/conan-io/conan-center-index" description = "A MySQL client library for C development." - topics = ("conan", "mysql", "sql", "connector", "database") - homepage = "https://dev.mysql.com/downloads/mysql/" license = "GPL-2.0" - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" + url = "https://github.com/conan-io/conan-center-index" + topics = ("mysql", "sql", "connector", "database") + homepage = "https://dev.mysql.com/downloads/mysql/" + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False], "with_ssl": [True, False], "with_zlib": [True, False]} - default_options = {"shared": False, "fPIC": True, "with_ssl": True, "with_zlib": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_ssl": [True, False, "deprecated"], + "with_zlib": [True, False, "deprecated"], + } + default_options = { + "shared": False, + "fPIC": True, + "with_ssl": "deprecated", + "with_zlib": "deprecated", + } - _cmake = None + short_paths = True + generators = "cmake", "pkg_config" @property def _source_subfolder(self): return "source_subfolder" - def requirements(self): - if self.options.with_ssl: - self.requires("openssl/1.1.1j") + @property + def _with_zstd(self): + return Version(self.version) > "8.0.17" - if self.options.with_zlib: - self.requires("zlib/1.2.11") + @property + def _with_lz4(self): + return Version(self.version) > "8.0.17" - def source(self): - archive_name = "mysql-" + self.version - tools.get(**self.conan_data["sources"][self.version]) - os.rename(archive_name, self._source_subfolder) - for lib in ["icu", "libevent", "re2", "rapidjson", "lz4", "protobuf", "libedit"]: - tools.rmdir(os.path.join(self._source_subfolder, "extra", lib)) - for folder in ['client', 'man', 'mysql-test']: - tools.rmdir(os.path.join(self._source_subfolder, folder)) - tools.rmdir(os.path.join(self._source_subfolder, "storage", "ndb")) + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "16" if Version(self.version) > "8.0.17" else "15", + "gcc": "7" if Version(self.version) >= "8.0.27" else "5.3", + "clang": "6", + } - def _patch_files(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - sources_cmake = os.path.join(self._source_subfolder, "CMakeLists.txt") - sources_cmake_orig = os.path.join(self._source_subfolder, "CMakeListsOriginal.txt") - os.rename(sources_cmake, sources_cmake_orig) - os.rename("CMakeLists.txt", sources_cmake) - if self.settings.os == "Macos": - tools.replace_in_file(os.path.join(self._source_subfolder, "libmysql", "CMakeLists.txt"), "COMMAND $", "COMMAND DYLD_LIBRARY_PATH=%s $" % os.path.join(self.build_folder, "library_output_directory")) + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == "Windows": @@ -58,62 +69,217 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler == "Visual Studio": - if Version(self.settings.compiler.version) < "15": - raise ConanInvalidConfiguration("Visual Studio 15 2017 or newer is required") - if self.settings.compiler == "gcc" and Version(self.settings.compiler.version.value) < "5.3": - raise ConanInvalidConfiguration("GCC 5.3 or newer is required") + if self.options.with_ssl != "deprecated": + self.output.warn("with_ssl option is deprecated, do not use anymore. SSL cannot be disabled") + if self.options.with_zlib != "deprecated": + self.output.warn("with_zlib option is deprecated, do not use anymore. Zlib cannot be disabled") + + def package_id(self): + del self.info.options.with_ssl + del self.info.options.with_zlib + + def requirements(self): + self.requires("openssl/1.1.1s") + self.requires("zlib/1.2.13") + if self._with_zstd: + self.requires("zstd/1.5.2") + if self._with_lz4: + self.requires("lz4/1.9.4") + if self.settings.os == "FreeBSD": + self.requires("libunwind/1.6.2") + + def validate(self): + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration(f"{self.name} {self.version} requires {self.settings.compiler} {minimum_version} or newer") + + if hasattr(self, "settings_build") and cross_building(self, skip_x64_x86=True): + raise ConanInvalidConfiguration("Cross compilation not yet supported by the recipe. contributions are welcome.") + + # FIXME: patch libmysqlclient 8.0.17 to support apple-clang >= 12? + # current errors: + # error: expected unqualified-id MYSQL_VERSION_MAJOR=8 + # error: no member named 'ptrdiff_t' in the global namespace + if self.version == "8.0.17" and self.settings.compiler == "apple-clang" and \ + Version(self.settings.compiler.version) >= "12.0": + raise ConanInvalidConfiguration("libmysqlclient 8.0.17 doesn't support apple-clang >= 12.0") + + # mysql>=8.0.17 doesn't support shared library on MacOS. + # https://github.com/mysql/mysql-server/blob/mysql-8.0.17/cmake/libutils.cmake#L333-L335 + if Version(self.version) >= "8.0.17" and self.settings.compiler == "apple-clang" and \ + self.options.shared: + raise ConanInvalidConfiguration(f"{self.name}/{self.version} doesn't support shared library") + + # mysql < 8.0.29 uses `requires` in source code. It is the reserved keyword in C++20. + # https://github.com/mysql/mysql-server/blob/mysql-8.0.0/include/mysql/components/services/dynamic_loader.h#L270 + if self.settings.compiler.get_safe("cppstd") == "20" and Version(self.version) < "8.0.29": + raise ConanInvalidConfiguration(f"{self.name}/{self.version} doesn't support C++20") + + def build_requirements(self): + if Version(self.version) >= "8.0.25" and is_apple_os(self): + # CMake 3.18 or higher is required if Apple, but CI of CCI may run CMake 3.15 + self.build_requires("cmake/3.24.2") + if self.settings.os == "FreeBSD": + self.build_requires("pkgconf/1.9.3") + def source(self): + get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + def _patch_files(self): + apply_conandata_patches(self) + + libs_to_remove = ["icu", "libevent", "re2", "rapidjson", "protobuf", "libedit"] + if not self._with_lz4: + libs_to_remove.append("lz4") + for lib in libs_to_remove: + replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), + f"MYSQL_CHECK_{lib.upper()}()\n", + "", + strict=False) + replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), + f"INCLUDE({lib})\n", + "", + strict=False) + replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), + f"WARN_MISSING_SYSTEM_{lib.upper()}({lib.upper()}_WARN_GIVEN)", + f"# WARN_MISSING_SYSTEM_{lib.upper()}({lib.upper()}_WARN_GIVEN)", + strict=False) + + replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), + f"SET({lib.upper()}_WARN_GIVEN)", + f"# SET({lib.upper()}_WARN_GIVEN)", + strict=False) + + rmdir(self, os.path.join(self._source_subfolder, "extra")) + for folder in ["client", "man", "mysql-test", "libbinlogstandalone"]: + rmdir(self, os.path.join(self._source_subfolder, folder)) + replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), + f"ADD_SUBDIRECTORY({folder})\n", + "", + strict=False) + rmdir(self, os.path.join(self._source_subfolder, "storage", "ndb")) + for t in ["INCLUDE(cmake/boost.cmake)\n", "MYSQL_CHECK_EDITLINE()\n"]: + replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), + t, + "", + strict=False) + if self._with_zstd: + replace_in_file(self, os.path.join(self._source_subfolder, "cmake", "zstd.cmake"), + "NAMES zstd", + "NAMES zstd %s" % self.deps_cpp_info["zstd"].libs[0]) + + replace_in_file(self, os.path.join(self._source_subfolder, "cmake", "ssl.cmake"), + "NAMES ssl", + "NAMES ssl %s" % self.deps_cpp_info["openssl"].components["ssl"].libs[0]) + + replace_in_file(self, os.path.join(self._source_subfolder, "cmake", "ssl.cmake"), + "NAMES crypto", + "NAMES crypto %s" % self.deps_cpp_info["openssl"].components["crypto"].libs[0]) + + replace_in_file(self, os.path.join(self._source_subfolder, "cmake", "ssl.cmake"), + "IF(NOT OPENSSL_APPLINK_C)\n", + "IF(FALSE AND NOT OPENSSL_APPLINK_C)\n", + strict=False) + + # Do not copy shared libs of dependencies to package folder + deps_shared = ["SSL"] + if Version(self.version) > "8.0.17": + deps_shared.extend(["KERBEROS", "SASL", "LDAP", "PROTOBUF", "CURL"]) + for dep in deps_shared: + replace_in_file(self, os.path.join(self._source_subfolder, "CMakeLists.txt"), + f"MYSQL_CHECK_{dep}_DLLS()", + "") + + sources_cmake = os.path.join(self._source_subfolder, "CMakeLists.txt") + sources_cmake_orig = os.path.join(self._source_subfolder, "CMakeListsOriginal.txt") + rename(self, sources_cmake, sources_cmake_orig) + rename(self, "CMakeLists.txt", sources_cmake) + if self.settings.os == "Macos": + replace_in_file(self, os.path.join(self._source_subfolder, "libmysql", "CMakeLists.txt"), + "COMMAND %s" % ("$" if Version(self.version) < "8.0.25" else "libmysql_api_test"), + "COMMAND DYLD_LIBRARY_PATH=%s %s" %(os.path.join(self.build_folder, "library_output_directory"), os.path.join(self.build_folder, "runtime_output_directory", "libmysql_api_test"))) + replace_in_file(self, os.path.join(self._source_subfolder, "cmake", "install_macros.cmake"), + " INSTALL_DEBUG_SYMBOLS(", + " # INSTALL_DEBUG_SYMBOLS(") + + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["DISABLE_SHARED"] = not self.options.shared - self._cmake.definitions["STACK_DIRECTION"] = "-1" # stack grows downwards, on very few platforms stack grows upwards - self._cmake.definitions["WITHOUT_SERVER"] = True - self._cmake.definitions["WITH_UNIT_TESTS"] = False - self._cmake.definitions["ENABLED_PROFILING"] = False - self._cmake.definitions["WIX_DIR"] = False + cmake = CMake(self) + cmake.definitions["DISABLE_SHARED"] = not self.options.shared + cmake.definitions["STACK_DIRECTION"] = "-1" # stack grows downwards, on very few platforms stack grows upwards + cmake.definitions["WITHOUT_SERVER"] = True + cmake.definitions["WITH_UNIT_TESTS"] = False + cmake.definitions["ENABLED_PROFILING"] = False + cmake.definitions["MYSQL_MAINTAINER_MODE"] = False + cmake.definitions["WIX_DIR"] = False + if self._with_lz4: + cmake.definitions["WITH_LZ4"] = "system" - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["WINDOWS_RUNTIME_MD"] = "MD" in str(self.settings.compiler.runtime) + if self._with_zstd: + cmake.definitions["WITH_ZSTD"] = "system" + cmake.definitions["ZSTD_INCLUDE_DIR"] = self.deps_cpp_info["zstd"].include_paths[0] - if self.options.with_ssl: - self._cmake.definitions["WITH_SSL"] = self.deps_cpp_info["openssl"].rootpath + if is_msvc(self): + cmake.definitions["WINDOWS_RUNTIME_MD"] = "MD" in msvc_runtime_flag(self) - if self.options.with_zlib: - self._cmake.definitions["WITH_ZLIB"] = "system" + cmake.definitions["WITH_SSL"] = self.deps_cpp_info["openssl"].rootpath - self._cmake.configure(source_dir=self._source_subfolder) - return self._cmake + cmake.definitions["WITH_ZLIB"] = "system" + cmake.configure(source_dir=self._source_subfolder) + return cmake def build(self): self._patch_files() cmake = self._configure_cmake() - cmake.build() + with tools.run_environment(self): + cmake.build() def package(self): cmake = self._configure_cmake() - cmake.install() + with tools.run_environment(self): + cmake.install() os.mkdir(os.path.join(self.package_folder, "licenses")) - os.rename(os.path.join(self.package_folder, "LICENSE"), os.path.join(self.package_folder, "licenses", "LICENSE")) + rename(self, os.path.join(self.package_folder, "LICENSE"), os.path.join(self.package_folder, "licenses", "LICENSE")) os.remove(os.path.join(self.package_folder, "README")) - for f in glob.glob(os.path.join(self.package_folder, "bin", "*.pdb")): - os.remove(f) - for f in glob.glob(os.path.join(self.package_folder, "lib", "*.pdb")): - os.remove(f) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "docs")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rm(self, "*.pdb", self.package_folder, recursive=True) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "docs")) + rmdir(self, os.path.join(self.package_folder, "share")) + if self.settings.os == "Windows" and self.options.shared: + self.copy("*.dll", "bin", keep_path=False) + if self.options.shared: + rm(self, "*.a", self.package_folder, recursive=True) + else: + rm(self, "*.dll", self.package_folder, recursive=True) + rm(self, "*.dylib", self.package_folder, recursive=True) + rm(self, "*.so*", self.package_folder, recursive=True) def package_info(self): - self.cpp_info.libs = ["libmysql" if self.settings.os == "Windows" and self.options.shared else "mysqlclient"] - self.cpp_info.names["cmake_find_package"] = "MySQL" - self.cpp_info.names["cmake_find_package_multi"] = "MySQL" + self.cpp_info.set_property("pkg_config_name", "mysqlclient") self.cpp_info.names["pkg_config"] = "mysqlclient" + self.cpp_info.libs = ["libmysql" if self.settings.os == "Windows" and self.options.shared else "mysqlclient"] if not self.options.shared: stdcpp_library = tools.stdcpp_library(self) if stdcpp_library: self.cpp_info.system_libs.append(stdcpp_library) - if self.settings.os == "Linux": - self.cpp_info.system_libs.append('m') + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + if self.settings.os in ["Linux", "FreeBSD"]: + if Version(self.version) >= "8.0.25": + self.cpp_info.system_libs.append("resolv") + if self.settings.os == "Windows": + if Version(self.version) >= "8.0.25": + self.cpp_info.system_libs.append("dnsapi") + self.cpp_info.system_libs.append("secur32") + + # TODO: There is no official FindMySQL.cmake, but it's a common Find files in many projects + # do we want to support it in CMakeDeps? + self.cpp_info.names["cmake_find_package"] = "MySQL" + self.cpp_info.names["cmake_find_package_multi"] = "MySQL" diff --git a/recipes/libmysqlclient/all/patches/0001-find-cmake.patch b/recipes/libmysqlclient/all/patches/0001-find-cmake.patch index 5a91a29f7f4ae..6330159ebb12b 100644 --- a/recipes/libmysqlclient/all/patches/0001-find-cmake.patch +++ b/recipes/libmysqlclient/all/patches/0001-find-cmake.patch @@ -1,81 +1,3 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 0b0cc090..04a3b32b 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -463,15 +463,10 @@ INCLUDE(character_sets) - INCLUDE(compile_flags) - INCLUDE(cpu_info) - INCLUDE(zlib) --INCLUDE(lz4) --INCLUDE(re2) --INCLUDE(icu) --INCLUDE(libevent) - INCLUDE(ssl) - INCLUDE(sasl) - INCLUDE(rpc) - INCLUDE(readline) --INCLUDE(protobuf) - INCLUDE(package_name) - INCLUDE(libutils) - INCLUDE(plugin) -@@ -481,7 +476,6 @@ INCLUDE(install_layout) - INCLUDE(mysql_add_executable) - INCLUDE(mysqlgcs) - INCLUDE(curl) --INCLUDE(rapidjson) - - OPTION(WITH_JEMALLOC "Use jemalloc rather than builtin malloc/free etc." OFF) - IF(WITH_JEMALLOC) -@@ -941,7 +935,6 @@ ELSE() - SET(DEFAULT_TMPDIR "\"${TMPDIR}\"") - ENDIF() - --INCLUDE(cmake/boost.cmake) - - IF (LINUX) - OPTION(WITH_SYSTEMD "Enable installation of systemd support files" OFF) -@@ -1115,25 +1108,9 @@ MYSQL_CHECK_SSL() - MYSQL_CHECK_SSL_DLLS() - --# Add system/bundled editline. --MYSQL_CHECK_EDITLINE() --# Add libevent --MYSQL_CHECK_LIBEVENT() --# Add lz4 library --MYSQL_CHECK_LZ4() --# Add re2 library --MYSQL_CHECK_RE2() --# Add icu library --MYSQL_CHECK_ICU() - # Add SASL library - MYSQL_CHECK_SASL() --# Add protoc and libprotobuf --IF(NOT WITHOUT_SERVER) -- MYSQL_CHECK_PROTOBUF() --ENDIF() - # Try and set CURL_LIBRARY - MYSQL_CHECK_CURL() --# Add RapidJSON library. --MYSQL_CHECK_RAPIDJSON() - - MACRO(MY_INCLUDE_SYSTEM_DIRECTORIES LIBRARY) - IF(${WITH_${LIBRARY}} STREQUAL "bundled") -@@ -1248,7 +1225,6 @@ IF(WITH_UNIT_TESTS) - ADD_SUBDIRECTORY(unittest/mytap/t) - ENDIF() - --ADD_SUBDIRECTORY(client) - ADD_SUBDIRECTORY(utilities) - ADD_SUBDIRECTORY(share) - ADD_SUBDIRECTORY(libservices) -@@ -1290,7 +1266,4 @@ IF(NOT WITHOUT_SERVER) - ENDIF() - --IF(UNIX) -- ADD_SUBDIRECTORY(man) --ENDIF() - - IF(NOT WITHOUT_SERVER) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake diff --git a/recipes/libmysqlclient/all/patches/0004-find-openssl-debug.patch b/recipes/libmysqlclient/all/patches/0004-find-openssl-debug.patch deleted file mode 100644 index e0b7b87698c1a..0000000000000 --- a/recipes/libmysqlclient/all/patches/0004-find-openssl-debug.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- cmake/ssl.cmake -+++ cmake/ssl.cmake -@@ -277,11 +277,11 @@ - ENDIF() - - FIND_LIBRARY(OPENSSL_LIBRARY -- NAMES ssl libssl ssleay32 ssleay32MD -+ NAMES ssl libssl ssleay32 ssleay32MD ssld libssld - HINTS ${OPENSSL_ROOT_DIR}/lib) - FIND_LIBRARY(CRYPTO_LIBRARY -- NAMES crypto libcrypto libeay32 -+ NAMES crypto libcrypto libeay32 cryptod libcryptod - HINTS ${OPENSSL_ROOT_DIR}/lib) - - IF(OPENSSL_INCLUDE_DIR) - # Verify version number. Version information looks like: diff --git a/recipes/libmysqlclient/all/patches/0004-fix-805-cpp17-build.patch b/recipes/libmysqlclient/all/patches/0004-fix-805-cpp17-build.patch new file mode 100644 index 0000000000000..883a39e5624ed --- /dev/null +++ b/recipes/libmysqlclient/all/patches/0004-fix-805-cpp17-build.patch @@ -0,0 +1,13 @@ +diff --git a/mysys/my_default.cc b/mysys/my_default.cc +--- a/mysys/my_default.cc ++++ b/mysys/my_default.cc +@@ -1180,7 +1180,7 @@ static mysql_file_getline_ret mysql_file_getline(char *buff, int size, + + /* If the supplied buff/size is enough to store the line, then we return the + * buff itself. In this case, we use this noop deleter */ +- static auto noop_free = [](void *) {}; ++ static auto noop_free = [](void *) noexcept {}; + + if (is_login_file) { + if (mysql_file_ftell(file) == 0) { + diff --git a/recipes/libmysqlclient/all/patches/0005-fix-macos-12.0.x-version-detection.patch b/recipes/libmysqlclient/all/patches/0005-fix-macos-12.0.x-version-detection.patch new file mode 100644 index 0000000000000..ee385c3187fef --- /dev/null +++ b/recipes/libmysqlclient/all/patches/0005-fix-macos-12.0.x-version-detection.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/package_name.cmake b/cmake/package_name.cmake +index 192035dd..dedc59c6 100644 +--- a/cmake/package_name.cmake ++++ b/cmake/package_name.cmake +@@ -94,7 +94,7 @@ MACRO(GET_PACKAGE_FILE_NAME Var) + + STRING(REGEX MATCH + "ProductVersion:[\n\t ]*([0-9]+)\\.([0-9]+)" UNUSED ${SW_VERS_PRODUCTVERSION}) +- IF(NOT CMAKE_MATCH_1 OR NOT CMAKE_MATCH_2) ++ IF(CMAKE_MATCH_1 STREQUAL "" OR CMAKE_MATCH_2 STREQUAL "") + MESSAGE(FATAL_ERROR "Could not run sw_vers") + ENDIF() + diff --git a/recipes/libmysqlclient/all/patches/0006-fix-cpp20-build-8.0.29.patch b/recipes/libmysqlclient/all/patches/0006-fix-cpp20-build-8.0.29.patch new file mode 100644 index 0000000000000..b7c82d910b7ea --- /dev/null +++ b/recipes/libmysqlclient/all/patches/0006-fix-cpp20-build-8.0.29.patch @@ -0,0 +1,17 @@ +diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h +index a03d754..381216d 100644 +--- a/sql/sql_bitmap.h ++++ b/sql/sql_bitmap.h +@@ -138,10 +138,10 @@ class Bitmap<64> { + ulonglong map; + + public: +- Bitmap<64>() { init(); } ++ Bitmap() { init(); } + enum { ALL_BITS = 64 }; + +- explicit Bitmap<64>(uint prefix_to_set) { set_prefix(prefix_to_set); } ++ explicit Bitmap(uint prefix_to_set) { set_prefix(prefix_to_set); } + void init() { clear_all(); } + void init(uint prefix_to_set) { set_prefix(prefix_to_set); } + uint length() const { return 64; } diff --git a/recipes/libmysqlclient/all/test_package/CMakeLists.txt b/recipes/libmysqlclient/all/test_package/CMakeLists.txt index 34af13462f44f..7b9b613cbb24a 100644 --- a/recipes/libmysqlclient/all/test_package/CMakeLists.txt +++ b/recipes/libmysqlclient/all/test_package/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() diff --git a/recipes/libmysqlclient/all/test_package/conanfile.py b/recipes/libmysqlclient/all/test_package/conanfile.py index bd7165a553cf4..6cbf041d5d1b8 100644 --- a/recipes/libmysqlclient/all/test_package/conanfile.py +++ b/recipes/libmysqlclient/all/test_package/conanfile.py @@ -1,9 +1,10 @@ -from conans import ConanFile, CMake, tools +from conans import ConanFile, CMake +from conan.tools.build import cross_building import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake" def build(self): @@ -12,6 +13,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libmysqlclient/config.yml b/recipes/libmysqlclient/config.yml index bb553379bad5e..33b7ea062fadb 100644 --- a/recipes/libmysqlclient/config.yml +++ b/recipes/libmysqlclient/config.yml @@ -1,3 +1,9 @@ versions: + "8.0.30": + folder: all + "8.0.29": + folder: all + "8.0.25": + folder: all "8.0.17": folder: all diff --git a/recipes/libnet/all/conandata.yml b/recipes/libnet/all/conandata.yml new file mode 100644 index 0000000000000..56c7fdd2f75d8 --- /dev/null +++ b/recipes/libnet/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.2": + sha256: caa4868157d9e5f32e9c7eac9461efeff30cb28357f7f6bf07e73933fb4edaa7 + url: https://github.com/libnet/libnet/releases/download/v1.2/libnet-1.2.tar.gz diff --git a/recipes/libnet/all/conanfile.py b/recipes/libnet/all/conanfile.py new file mode 100644 index 0000000000000..94be83e79e721 --- /dev/null +++ b/recipes/libnet/all/conanfile.py @@ -0,0 +1,105 @@ +from conan import ConanFile +from conan.errors import ConanException, ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os +from conan.tools.build import cross_building +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +import os + +required_conan_version = ">=1.53.0" + + +class LibnetConan(ConanFile): + name = "libnet" + description = "Libnet is an API to help with the construction and injection of network packets." + topics = ("network") + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://libnet.sourceforge.net/" + license = ["BSD-2-Clause"] + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration("libnet is not supported by Visual Studio") + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("libnet can't be built as shared on Windows") + + def build_requirements(self): + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.configure_args.append("--disable-doxygen-doc") + if cross_building(self): + if self.settings.os == "Linux": + link_layer = "linux" + elif self.settings.os == "Windows": + link_layer = "win32" + elif is_apple_os(self): + link_layer = "bpf" + else: + raise ConanException( + f"link-layer unknown for {self.settings.os}, feel free to contribute to libnet recipe", + ) + tc.configure_args.append(f"--with-link-layer={link_layer}") + tc.generate() + + def build(self): + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libnet") + self.cpp_info.libs = ["net"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + elif self.settings.os == "Windows": + self.cpp_info.system_libs.append("ws2_32") diff --git a/recipes/libnet/all/test_package/CMakeLists.txt b/recipes/libnet/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..24a3da7a29419 --- /dev/null +++ b/recipes/libnet/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libnet REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libnet::libnet) diff --git a/recipes/libnet/all/test_package/conanfile.py b/recipes/libnet/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libnet/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libnet/all/test_package/test_package.c b/recipes/libnet/all/test_package/test_package.c new file mode 100644 index 0000000000000..46ab2521eef21 --- /dev/null +++ b/recipes/libnet/all/test_package/test_package.c @@ -0,0 +1,19 @@ +#include +#include + +int main() +{ + libnet_t *l = NULL; + unsigned char enet_dst[6] = {0x0d, 0x0e, 0x0a, 0x0d, 0x00, 0x00}; + libnet_ptag_t t = libnet_autobuild_ethernet( + enet_dst, /* ethernet destination */ + ETHERTYPE_ARP, /* protocol type */ + l); /* libnet handle */ + if (t != (-1)) { + fprintf(stderr, "[-] Failed!\n"); + return 1; + } + + fprintf(stderr, "[+] Passed!\n"); + return 0; +} diff --git a/recipes/libnet/all/test_v1_package/CMakeLists.txt b/recipes/libnet/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libnet/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libnet/all/test_v1_package/conanfile.py b/recipes/libnet/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libnet/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libnet/config.yml b/recipes/libnet/config.yml new file mode 100644 index 0000000000000..a0777b5aa931c --- /dev/null +++ b/recipes/libnet/config.yml @@ -0,0 +1,3 @@ +versions: + "1.2": + folder: all diff --git a/recipes/libnfnetlink/all/conandata.yml b/recipes/libnfnetlink/all/conandata.yml index 457c91b844d87..b5ce8a9c9adc1 100644 --- a/recipes/libnfnetlink/all/conandata.yml +++ b/recipes/libnfnetlink/all/conandata.yml @@ -2,3 +2,6 @@ sources: "1.0.1": sha256: f270e19de9127642d2a11589ef2ec97ef90a649a74f56cf9a96306b04817b51a url: https://www.netfilter.org/projects/libnfnetlink/files/libnfnetlink-1.0.1.tar.bz2 + "1.0.2": + sha256: b064c7c3d426efb4786e60a8e6859b82ee2f2c5e49ffeea640cfe4fe33cbc376 + url: https://www.netfilter.org/projects/libnfnetlink/files/libnfnetlink-1.0.2.tar.bz2 diff --git a/recipes/libnfnetlink/all/conanfile.py b/recipes/libnfnetlink/all/conanfile.py index 78ea9aac4ff4b..10540d39fbf9c 100644 --- a/recipes/libnfnetlink/all/conanfile.py +++ b/recipes/libnfnetlink/all/conanfile.py @@ -1,8 +1,9 @@ import os +import functools from conans import ConanFile, tools, AutoToolsBuildEnvironment from conans.errors import ConanInvalidConfiguration -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.43.0" class LibnfnetlinkConan(ConanFile): name = "libnfnetlink" @@ -14,36 +15,35 @@ class LibnfnetlinkConan(ConanFile): settings = "os", "compiler", "build_type", "arch" options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True} - _autotools = None @property def _source_subfolder(self): return "source_subfolder" def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) - def configure(self): + def validate(self): if self.settings.os != "Linux": raise ConanInvalidConfiguration("libnfnetlink is only supported on Linux") + + def configure(self): if self.options.shared: del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + @functools.lru_cache(1) def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self) + autotools = AutoToolsBuildEnvironment(self) conf_args = [] if self.options.shared: conf_args.extend(["--enable-shared", "--disable-static"]) else: conf_args.extend(["--disable-shared", "--enable-static"]) - self._autotools.configure(configure_dir=self._source_subfolder, args=conf_args) - return self._autotools + autotools.configure(configure_dir=self._source_subfolder, args=conf_args) + return autotools def build(self): autotools = self._configure_autotools() @@ -61,4 +61,7 @@ def package(self): def package_info(self): self.cpp_info.libs = ["nfnetlink"] + self.cpp_info.set_property("pkg_config_name", "libnfnetlink") + + # TODO: to remove in conan v2 once pkg_config generator is removed self.cpp_info.names["pkg_config"] = "libnfnetlink" diff --git a/recipes/libnfnetlink/config.yml b/recipes/libnfnetlink/config.yml index 395fa2f83ab2a..94db826314106 100644 --- a/recipes/libnfnetlink/config.yml +++ b/recipes/libnfnetlink/config.yml @@ -1,3 +1,5 @@ versions: 1.0.1: folder: all + 1.0.2: + folder: all diff --git a/recipes/libnfs/all/conandata.yml b/recipes/libnfs/all/conandata.yml new file mode 100644 index 0000000000000..5c9b795165455 --- /dev/null +++ b/recipes/libnfs/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "5.0.1": + url: "https://github.com/sahlberg/libnfs/archive/refs/tags/libnfs-5.0.1.tar.gz" + sha256: "7ef445410b42f36b9bad426608b53ccb9ccca4101e545c383f564c11db672ca8" +patches: + "5.0.1": + - patch_file: "patches/5.0.1-0001-remove-exports.patch" + patch_description: "Fix installation" + patch_type: "conan" + patch_source: "https://github.com/sahlberg/libnfs/pull/377" diff --git a/recipes/libnfs/all/conanfile.py b/recipes/libnfs/all/conanfile.py new file mode 100644 index 0000000000000..3b943c080be1a --- /dev/null +++ b/recipes/libnfs/all/conanfile.py @@ -0,0 +1,71 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +import os + +required_conan_version = ">=1.53.0" + + +class LibnfsConan(ConanFile): + name = "libnfs" + description = "LIBNFS is a client library for accessing NFS shares over a network." + topics = ("async", "nfsv4", "nfs") + license = "LGPL-2.1" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/sahlberg/libnfs" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENCE*.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "libnfs") + self.cpp_info.set_property("cmake_target_name", "libnfs::libnfs") + self.cpp_info.set_property("pkg_config_name", "libnfs") + self.cpp_info.libs = ["nfs"] + if self.settings.os == "Windows": + self.cpp_info.system_libs.append("ws2_32") diff --git a/recipes/libnfs/all/patches/5.0.1-0001-remove-exports.patch b/recipes/libnfs/all/patches/5.0.1-0001-remove-exports.patch new file mode 100644 index 0000000000000..8c95197b65585 --- /dev/null +++ b/recipes/libnfs/all/patches/5.0.1-0001-remove-exports.patch @@ -0,0 +1,17 @@ +diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake +index 257b52d..a44e562 100644 +--- a/cmake/Macros.cmake ++++ b/cmake/Macros.cmake +@@ -12,4 +12,12 @@ function(core_add_library name) + add_library(${name} OBJECT ${SOURCES} ${HEADERS}) + target_include_directories(${name} PUBLIC $) + set(CORE_LIBRARIES "${name};${CORE_LIBRARIES}" CACHE INTERNAL "") ++ ++ # no need to install core libs if we build shared library ++ if(NOT BUILD_SHARED_LIBS) ++ install(TARGETS ${name} EXPORT libnfs ++ RUNTIME DESTINATION bin ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib) ++ endif() + endfunction() diff --git a/recipes/libnfs/all/test_package/CMakeLists.txt b/recipes/libnfs/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c693f64cb2e4c --- /dev/null +++ b/recipes/libnfs/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libnfs REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libnfs::libnfs) diff --git a/recipes/libnfs/all/test_package/conanfile.py b/recipes/libnfs/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libnfs/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libnfs/all/test_package/test_package.c b/recipes/libnfs/all/test_package/test_package.c new file mode 100644 index 0000000000000..0a5f34fd8f626 --- /dev/null +++ b/recipes/libnfs/all/test_package/test_package.c @@ -0,0 +1,17 @@ +#ifdef _MSC_VER +#include +#else +#include +#endif + +#include "nfsc/libnfs.h" + +int main() { + struct nfs_context* nfs = nfs_init_context(); + + if (nfs == NULL) { + return 0; + } + nfs_destroy_context(nfs); + return 0; +} diff --git a/recipes/libnfs/all/test_v1_package/CMakeLists.txt b/recipes/libnfs/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libnfs/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libnfs/all/test_v1_package/conanfile.py b/recipes/libnfs/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libnfs/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libnfs/config.yml b/recipes/libnfs/config.yml new file mode 100644 index 0000000000000..12fc1d264fabb --- /dev/null +++ b/recipes/libnfs/config.yml @@ -0,0 +1,3 @@ +versions: + "5.0.1": + folder: "all" diff --git a/recipes/libnghttp2/all/CMakeLists.txt b/recipes/libnghttp2/all/CMakeLists.txt deleted file mode 100644 index a69305eb3971f..0000000000000 --- a/recipes/libnghttp2/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/libnghttp2/all/conandata.yml b/recipes/libnghttp2/all/conandata.yml index f0e8cf8386bfd..b58b621d4ded7 100644 --- a/recipes/libnghttp2/all/conandata.yml +++ b/recipes/libnghttp2/all/conandata.yml @@ -1,42 +1,63 @@ sources: - "1.39.2": - sha256: 92a23e4522328c8565028ee0c7270e74add7990614fd1148f2a79d873bc2a1d0 - url: https://github.com/nghttp2/nghttp2/releases/download/v1.39.2/nghttp2-1.39.2.tar.bz2 - "1.40.0": - sha256: 82758e13727945f2408d0612762e4655180b039f058d5ff40d055fa1497bd94f - url: https://github.com/nghttp2/nghttp2/releases/download/v1.40.0/nghttp2-1.40.0.tar.bz2 - "1.42.0": - sha256: 10473848c2636fa9de6b469b04d0a0336cf8268486f7a6bde7cb2d0634736624 - url: https://github.com/nghttp2/nghttp2/releases/download/v1.42.0/nghttp2-1.42.0.tar.bz2 + "1.51.0": + url: "https://github.com/nghttp2/nghttp2/archive/v1.51.0.tar.gz" + sha256: "dfcf41e0b093765a79c9f1fc0ba6dc3d524555e94483ea9ba8b87a6d454971ba" + "1.50.0": + url: "https://github.com/nghttp2/nghttp2/archive/v1.50.0.tar.gz" + sha256: "6de469efc8e9d47059327a6736aebe0a7d73f57e5e37ab4c4f838fb1eebd7889" + "1.49.0": + url: "https://github.com/nghttp2/nghttp2/archive/v1.49.0.tar.gz" + sha256: "744f38f8d6e400a424bf62df449c91e3ffacbae11b5fab99e44a480f5c735ab9" + "1.48.0": + url: "https://github.com/nghttp2/nghttp2/archive/v1.48.0.tar.gz" + sha256: "946a8fa490548b67fc6074553cb225279cc6404bae96cf74551f2ad4453be637" + "1.47.0": + url: "https://github.com/nghttp2/nghttp2/archive/v1.47.0.tar.gz" + sha256: "db98735b30f1586edf3212ada57f85feaceff483a1c0f1c1c8285abcf37e3444" + "1.46.0": + url: "https://github.com/nghttp2/nghttp2/archive/v1.46.0.tar.gz" + sha256: "0875a638d319cd28b06dcc410e6dc2add1a52f7cab6f62b26025c448f8ae8f43" + "1.45.1": + url: "https://github.com/nghttp2/nghttp2/archive/v1.45.1.tar.gz" + sha256: "6289eed7e83988428c6b24e46ada52a37fab82f20d4afa257b5627267c2a141b" "1.43.0": url: "https://github.com/nghttp2/nghttp2/archive/v1.43.0.tar.gz" sha256: "f4a9be08d22f5ad9b4bf36c491f1be58e54dc35a1592eaf4e3f79567e4894d0c" -patches: + "1.42.0": + url: "https://github.com/nghttp2/nghttp2/releases/download/v1.42.0/nghttp2-1.42.0.tar.bz2" + sha256: "10473848c2636fa9de6b469b04d0a0336cf8268486f7a6bde7cb2d0634736624" + "1.40.0": + url: "https://github.com/nghttp2/nghttp2/releases/download/v1.40.0/nghttp2-1.40.0.tar.bz2" + sha256: "82758e13727945f2408d0612762e4655180b039f058d5ff40d055fa1497bd94f" "1.39.2": - - patch_file: "patches/fix-addNghttp2IncludesPathCMake.patch" - base_path: "source_subfolder" + url: "https://github.com/nghttp2/nghttp2/releases/download/v1.39.2/nghttp2-1.39.2.tar.bz2" + sha256: "92a23e4522328c8565028ee0c7270e74add7990614fd1148f2a79d873bc2a1d0" +patches: + "1.49.0": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" - "1.40.0": + "1.48.0": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" - - patch_file: "patches/nghttp_static_include_directories.patch" - base_path: "source_subfolder" - "1.42.0": + "1.47.0": + - patch_file: "patches/fix-findJemalloc.cmake" + - patch_file: "patches/fix-findLibevent.cmake" + "1.46.0": + - patch_file: "patches/fix-findJemalloc.cmake" + - patch_file: "patches/fix-findLibevent.cmake" + "1.45.1": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" - - patch_file: "patches/nghttp_static_include_directories_1.42.0.patch" - base_path: "source_subfolder" "1.43.0": - patch_file: "patches/fix-findJemalloc.cmake" - base_path: "source_subfolder" - patch_file: "patches/fix-findLibevent.cmake" - base_path: "source_subfolder" - - patch_file: "patches/nghttp_static_include_directories_1.42.0.patch" - base_path: "source_subfolder" + "1.42.0": + - patch_file: "patches/fix-findJemalloc.cmake" + - patch_file: "patches/fix-findLibevent.cmake" + "1.40.0": + - patch_file: "patches/fix-findJemalloc.cmake" + - patch_file: "patches/fix-findLibevent.cmake" + "1.39.2": + - patch_file: "patches/fix-addNghttp2IncludesPathCMake.patch" + - patch_file: "patches/fix-findJemalloc.cmake" + - patch_file: "patches/fix-findLibevent.cmake" diff --git a/recipes/libnghttp2/all/conanfile.py b/recipes/libnghttp2/all/conanfile.py index d33f377d79d5a..b3b58ce1c61eb 100644 --- a/recipes/libnghttp2/all/conanfile.py +++ b/recipes/libnghttp2/all/conanfile.py @@ -1,32 +1,44 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.gnu import PkgConfigDeps +from conan.tools.scm import Version +from conan.tools.files import export_conandata_patches, apply_conandata_patches, get, save, replace_in_file, rmdir, copy +from conan.tools.microsoft import is_msvc +from conan.tools.apple import is_apple_os +from conan.errors import ConanInvalidConfiguration import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration + + +required_conan_version = ">=1.52.0" class Nghttp2Conan(ConanFile): name = "libnghttp2" description = "HTTP/2 C Library and tools" - topics = ("conan", "http") + topics = ("http", "http2") url = "https://github.com/conan-io/conan-center-index" homepage = "https://nghttp2.org" license = "MIT" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "pkg_config" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False], - "with_app": [True, False], - "with_hpack": [True, False], - "with_jemalloc": [True, False], - "with_asio": [True, False]} - default_options = {"shared": False, - "fPIC": True, - "with_app": True, - "with_hpack": True, - "with_jemalloc": False, - "with_asio": False} - - _source_subfolder = "source_subfolder" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_app": [True, False], + "with_hpack": [True, False], + "with_jemalloc": [True, False], + "with_asio": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_app": False, + "with_hpack": False, + "with_jemalloc": False, + "with_asio": False, + } + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -34,74 +46,89 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - if self.options.with_asio and self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("Build with asio and MSVC is not supported yet, see upstream bug #589") - if self.settings.compiler == "gcc": - v = tools.Version(str(self.settings.compiler.version)) - if v < "6.0": - raise ConanInvalidConfiguration("gcc >= 6.0 required") + try: + del self.options.fPIC + except Exception: + pass + if not (self.options.with_app or self.options.with_hpack or self.options.with_asio): + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + if not self.options.with_app: + del self.options.with_jemalloc + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("zlib/1.2.11") + if self.options.with_app or self.options.with_asio: + self.requires("openssl/1.1.1q") if self.options.with_app: - self.requires("openssl/1.1.1k") - self.requires("c-ares/1.17.1") + self.requires("c-ares/1.18.1") self.requires("libev/4.33") self.requires("libevent/2.1.12") - self.requires("libxml2/2.9.10") + self.requires("libxml2/2.9.14") + self.requires("zlib/1.2.13") + if self.options.with_jemalloc: + self.requires("jemalloc/5.3.0") if self.options.with_hpack: - self.requires("jansson/2.13.1") - if self.options.with_jemalloc: - self.requires("jemalloc/5.2.1") + self.requires("jansson/2.14") if self.options.with_asio: - self.requires("boost/1.75.0") + self.requires("boost/1.80.0") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "nghttp2-{0}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) + def validate(self): + if self.info.options.with_asio and is_msvc(self): + raise ConanInvalidConfiguration("Build with asio and MSVC is not supported yet, see upstream bug #589") + if self.info.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "6": + raise ConanInvalidConfiguration(f"{self.ref} requires GCC >= 6.0") - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["ENABLE_SHARED_LIB"] = "ON" if self.options.shared else "OFF" - cmake.definitions["ENABLE_STATIC_LIB"] = "OFF" if self.options.shared else "ON" - cmake.definitions["ENABLE_HPACK_TOOLS"] = "ON" if self.options.with_hpack else "OFF" - cmake.definitions["ENABLE_APP"] = "ON" if self.options.with_app else "OFF" - cmake.definitions["ENABLE_EXAMPLES"] = "OFF" - cmake.definitions["ENABLE_PYTHON_BINDINGS"] = "OFF" - cmake.definitions["ENABLE_FAILMALLOC"] = "OFF" + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_SHARED_LIB"] = self.options.shared + tc.variables["ENABLE_STATIC_LIB"] = not self.options.shared + tc.variables["ENABLE_HPACK_TOOLS"] = self.options.with_hpack + tc.variables["ENABLE_APP"] = self.options.with_app + tc.variables["ENABLE_EXAMPLES"] = False + tc.variables["ENABLE_PYTHON_BINDINGS"] = False + tc.variables["ENABLE_FAILMALLOC"] = False # disable unneeded auto-picked dependencies - cmake.definitions["WITH_LIBXML2"] = "OFF" - cmake.definitions["WITH_JEMALLOC"] = "ON" if self.options.with_jemalloc else "OFF" - cmake.definitions["WITH_SPDYLAY"] = "OFF" - - cmake.definitions["ENABLE_ASIO_LIB"] = "ON" if self.options.with_asio else "OFF" - - if tools.Version(self.version) >= "1.42.0": + tc.variables["WITH_LIBXML2"] = False + tc.variables["WITH_JEMALLOC"] = self.options.get_safe("with_jemalloc", False) + tc.variables["WITH_SPDYLAY"] = False + tc.variables["ENABLE_ASIO_LIB"] = self.options.with_asio + if Version(self.version) >= "1.42.0": # backward-incompatible change in 1.42.0 - cmake.definitions["STATIC_LIB_SUFFIX"] = "_static" - - if self.options.with_app: - cmake.definitions["OPENSSL_ROOT_DIR"] = self.deps_cpp_info["openssl"].rootpath - if self.options.with_asio: - cmake.definitions["BOOST_ROOT"] = self.deps_cpp_info["boost"].rootpath - cmake.definitions["ZLIB_ROOT"] = self.deps_cpp_info["zlib"].rootpath + tc.variables["STATIC_LIB_SUFFIX"] = "_static" + if is_apple_os(self): + # workaround for: install TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable + tc.cache_variables["CMAKE_MACOSX_BUNDLE"] = False + tc.generate() - cmake.configure() - return cmake + tc = CMakeDeps(self) + tc.generate() + tc = PkgConfigDeps(self) + tc.generate() def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - # tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "CMakeLists.txt"), - # "set_target_properties(nghttp2_static ", - # "target_include_directories(nghttp2_static INTERFACE\n" - # "${CMAKE_CURRENT_BINARY_DIR}/includes\n" - # "${CMAKE_CURRENT_SOURCE_DIR}/includes)\n" - # "set_target_properties(nghttp2_static ") + apply_conandata_patches(self) + if not self.options.shared: + # easier to patch here rather than have patch 'nghttp_static_include_directories' for each version + save(self, os.path.join(self.source_folder, "lib", "CMakeLists.txt"), + "target_include_directories(nghttp2_static INTERFACE\n" + "${CMAKE_CURRENT_BINARY_DIR}/includes\n" + "${CMAKE_CURRENT_SOURCE_DIR}/includes)\n", + append=True) target_libnghttp2 = "nghttp2" if self.options.shared else "nghttp2_static" - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), "\n" "link_libraries(\n" " nghttp2\n", @@ -109,38 +136,61 @@ def _patch_sources(self): "link_libraries(\n" " {} ${{CONAN_LIBS}}\n".format(target_libnghttp2)) if not self.options.shared: - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), "\n" " add_library(nghttp2_asio SHARED\n", "\n" " add_library(nghttp2_asio\n") - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), "\n" " target_link_libraries(nghttp2_asio\n" " nghttp2\n", "\n" " target_link_libraries(nghttp2_asio\n" - " {}\n".format(target_libnghttp2)) + f" {target_libnghttp2}\n") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - cmake.patch_config_paths() - - tools.rmdir(os.path.join(self.package_folder, 'share')) - tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - suffix = "_static" if tools.Version(self.version) > "1.39.2" and not self.options.shared else "" - self.cpp_info.libs = ["nghttp2" + suffix] + self.cpp_info.components["nghttp2"].set_property("pkg_config_name", "libnghttp2") + suffix = "_static" if Version(self.version) > "1.39.2" and not self.options.shared else "" + self.cpp_info.components["nghttp2"].libs = [f"nghttp2{suffix}"] + if is_msvc(self) and not self.options.shared: + self.cpp_info.components["nghttp2"].defines.append("NGHTTP2_STATICLIB") + if self.options.with_asio: - self.cpp_info.libs.insert(0, "nghttp2_asio") - if self.settings.compiler == "Visual Studio": - if not self.options.shared: - self.cpp_info.defines.append("NGHTTP2_STATICLIB") + self.cpp_info.components["nghttp2_asio"].set_property("pkg_config_name", "libnghttp2_asio") + self.cpp_info.components["nghttp2_asio"].libs = ["nghttp2_asio"] + self.cpp_info.components["nghttp2_asio"].requires = [ + "nghttp2", "boost::headers", "openssl::openssl", + ] + + if self.options.with_app: + self.cpp_info.components["nghttp2_app"].requires = [ + "openssl::openssl", "c-ares::c-ares", "libev::libev", + "libevent::libevent", "libxml2::libxml2", "zlib::zlib", + ] + if self.options.with_jemalloc: + self.cpp_info.components["nghttp2_app"].requires.append("jemalloc::jemalloc") + + if self.options.with_hpack: + self.cpp_info.components["nghttp2_hpack"].requires = ["jansson::jansson"] + + if self.options.with_app or self.options.with_hpack: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + + # trick for internal conan usage to pick up in downsteam pc files the pc file including all libs components + self.cpp_info.set_property("pkg_config_name", "libnghttp2_asio" if self.options.with_asio else "libnghttp2") diff --git a/recipes/libnghttp2/all/patches/nghttp_static_include_directories.patch b/recipes/libnghttp2/all/patches/nghttp_static_include_directories.patch deleted file mode 100644 index cab3574959402..0000000000000 --- a/recipes/libnghttp2/all/patches/nghttp_static_include_directories.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- lib/CMakeLists.txt -+++ lib/CMakeLists.txt -@@ -59,7 +59,10 @@ - if(HAVE_CUNIT OR ENABLE_STATIC_LIB) - # Static library (for unittests because of symbol visibility) - add_library(nghttp2_static STATIC ${NGHTTP2_SOURCES}) -+ target_include_directories(nghttp2_static INTERFACE -+ ${CMAKE_CURRENT_BINARY_DIR}/includes -+ ${CMAKE_CURRENT_SOURCE_DIR}/includes) - set_target_properties(nghttp2_static PROPERTIES - COMPILE_FLAGS "${WARNCFLAGS}" - VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION} - ARCHIVE_OUTPUT_NAME nghttp2_static diff --git a/recipes/libnghttp2/all/patches/nghttp_static_include_directories_1.42.0.patch b/recipes/libnghttp2/all/patches/nghttp_static_include_directories_1.42.0.patch deleted file mode 100644 index 452e4533162a3..0000000000000 --- a/recipes/libnghttp2/all/patches/nghttp_static_include_directories_1.42.0.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/lib/CMakeLists.txt -+++ b/lib/CMakeLists.txt -@@ -60,6 +60,9 @@ endif() - if(HAVE_CUNIT OR ENABLE_STATIC_LIB) - # Static library (for unittests because of symbol visibility) - add_library(nghttp2_static STATIC ${NGHTTP2_SOURCES}) -+ target_include_directories(nghttp2_static INTERFACE -+ ${CMAKE_CURRENT_BINARY_DIR}/includes -+ ${CMAKE_CURRENT_SOURCE_DIR}/includes) - set_target_properties(nghttp2_static PROPERTIES - COMPILE_FLAGS "${WARNCFLAGS}" - VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION} diff --git a/recipes/libnghttp2/all/test_package/CMakeLists.txt b/recipes/libnghttp2/all/test_package/CMakeLists.txt index 3300ff7750277..eb7f9cd8b9769 100644 --- a/recipes/libnghttp2/all/test_package/CMakeLists.txt +++ b/recipes/libnghttp2/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libnghttp2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +target_link_libraries(${PROJECT_NAME} PRIVATE libnghttp2::libnghttp2) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/libnghttp2/all/test_package/conanfile.py b/recipes/libnghttp2/all/test_package/conanfile.py index 47369049f8bc8..a9fb96656f203 100644 --- a/recipes/libnghttp2/all/test_package/conanfile.py +++ b/recipes/libnghttp2/all/test_package/conanfile.py @@ -1,12 +1,19 @@ -# -*- coding: utf-8 -*- - -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -14,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libnghttp2/all/test_v1_package/CMakeLists.txt b/recipes/libnghttp2/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a7596ce0a8b97 --- /dev/null +++ b/recipes/libnghttp2/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ ${CMAKE_CURRENT_BINARY_DIR}/binary_dir/) diff --git a/recipes/libnghttp2/all/test_v1_package/conanfile.py b/recipes/libnghttp2/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libnghttp2/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libnghttp2/config.yml b/recipes/libnghttp2/config.yml index be7e4f66e3e71..486aa86ed0090 100644 --- a/recipes/libnghttp2/config.yml +++ b/recipes/libnghttp2/config.yml @@ -1,9 +1,23 @@ versions: - "1.39.2": + "1.51.0": folder: all - "1.40.0": + "1.50.0": folder: all - "1.42.0": + "1.49.0": + folder: all + "1.48.0": + folder: all + "1.47.0": + folder: all + "1.46.0": + folder: all + "1.45.1": folder: all "1.43.0": folder: all + "1.42.0": + folder: all + "1.40.0": + folder: all + "1.39.2": + folder: all diff --git a/recipes/libnl/all/conanfile.py b/recipes/libnl/all/conanfile.py index 1754166600184..1bd02b2f42194 100644 --- a/recipes/libnl/all/conanfile.py +++ b/recipes/libnl/all/conanfile.py @@ -1,18 +1,21 @@ -import os, glob from conans import ConanFile, tools, AutoToolsBuildEnvironment from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + class LibNlConan(ConanFile): name = "libnl" description = "A collection of libraries providing APIs to netlink protocol based Linux kernel interfaces." - topics = "conan", "netlink" + topics = ("netlink") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.infradead.org/~tgr/libnl/" license = "LGPL-2.1-only" settings = "os", "arch", "compiler", "build_type" options = {"fPIC": [True, False], "shared": [True, False]} default_options = {"fPIC": True, "shared": False} - build_requires = ( "flex/2.6.4", "bison/3.5.3" ) + build_requires = ( "flex/2.6.4", "bison/3.7.6" ) _autotools = None @@ -21,18 +24,18 @@ def _source_subfolder(self): return "source_subfolder" def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def configure(self): - if self.settings.os != "Linux": - raise ConanInvalidConfiguration("Libnl is only supported on Linux") if self.options.shared: del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("Libnl is only supported on Linux") + def _configure_autotools(self): if self._autotools: return self._autotools @@ -56,20 +59,19 @@ def package(self): autotools = self._configure_autotools() autotools.install() self.copy("COPYING", dst="licenses", src=self._source_subfolder) - #tools.remove_files_by_mask causes AttributeError: module 'conans.tools' has no attribute 'remove_files_by_mask' - #tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") - la_pattern = os.path.join(self.package_folder, "lib", "**", "*.la") - la_files = glob.glob(la_pattern, recursive=True) - for next_file in la_files: - os.remove(next_file) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") tools.rmdir(os.path.join(self.package_folder, "share")) tools.rmdir(os.path.join(self.package_folder, "etc")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def package_info(self): self.cpp_info.components["nl"].libs = ["nl-3"] self.cpp_info.components["nl"].includedirs = [os.path.join('include', 'libnl3')] - if not tools.os_info.is_windows: + if self._settings_build.os != "Windows": self.cpp_info.components["nl"].system_libs = ["pthread", "m"] self.cpp_info.components["nl-route"].libs = ["nl-route-3"] self.cpp_info.components["nl-route"].requires = ["nl"] diff --git a/recipes/libnoise/all/CMakeLists.txt b/recipes/libnoise/all/CMakeLists.txt new file mode 100644 index 0000000000000..5f314cdfee089 --- /dev/null +++ b/recipes/libnoise/all/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.4) +project(noise LANGUAGES CXX) + +set(NOISE_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/noise/src) + +file(GLOB NOISE_SRC_FILES + ${NOISE_SRC_DIR}/*.cpp + ${NOISE_SRC_DIR}/model/*.cpp + ${NOISE_SRC_DIR}/module/*.cpp +) + +add_library(${PROJECT_NAME} ${NOISE_SRC_FILES}) +set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + +find_library(M_LIB m) +if(M_LIB) + target_link_libraries(${PROJECT_NAME} PUBLIC ${M_LIB}) +endif() + +include(GNUInstallDirs) +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +foreach(SRC_SUBDIR "." "model" "module") + file(GLOB NOISE_HDR_FILES ${NOISE_SRC_DIR}/${SRC_SUBDIR}/*.h) + install(FILES ${NOISE_HDR_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/noise/${SRC_SUBDIR}) +endforeach() diff --git a/recipes/libnoise/all/conandata.yml b/recipes/libnoise/all/conandata.yml new file mode 100644 index 0000000000000..1091f5761161e --- /dev/null +++ b/recipes/libnoise/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.0": + url: "https://sourceforge.net/projects/libnoise/files/libnoise%20sources/1.0.0/libnoisesrc-1.0.0.zip" + sha256: "34ed402f43f30ce5e39812642c9533c11082cd2bc092341c65160f5c743be95b" diff --git a/recipes/libnoise/all/conanfile.py b/recipes/libnoise/all/conanfile.py new file mode 100644 index 0000000000000..41c252698e767 --- /dev/null +++ b/recipes/libnoise/all/conanfile.py @@ -0,0 +1,65 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.46.0" + + +class LibnoiseConan(ConanFile): + name = "libnoise" + description = ( + "A general-purpose library that generates three-dimensional coherent " + "noise. Useful for terrain generation and procedural texture " + "generation. Uses a broad number of techniques (Perlin noise, ridged " + "multifractal, etc.) and combinations of those techniques." + ) + license = "LGPL-2.1-or-later" + topics = ("libnoise", "graphics", "noise-generator") + homepage = "http://libnoise.sourceforge.net" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "COPYING.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["noise"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/libnoise/all/test_package/CMakeLists.txt b/recipes/libnoise/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e018594465e5d --- /dev/null +++ b/recipes/libnoise/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(libnoise REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libnoise::libnoise) diff --git a/recipes/libnoise/all/test_package/conanfile.py b/recipes/libnoise/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/libnoise/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libnoise/all/test_package/test_package.cpp b/recipes/libnoise/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2424339a8248c --- /dev/null +++ b/recipes/libnoise/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include + +#include + +int main() { + std::cout << noise::IntValueNoise3D(4, 2, 5) << std::endl; + return 0; +} diff --git a/recipes/libnoise/all/test_v1_package/CMakeLists.txt b/recipes/libnoise/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..469ae9866ac83 --- /dev/null +++ b/recipes/libnoise/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libnoise REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libnoise::libnoise) diff --git a/recipes/libnoise/all/test_v1_package/conanfile.py b/recipes/libnoise/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/libnoise/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libnoise/config.yml b/recipes/libnoise/config.yml new file mode 100644 index 0000000000000..40341aa3db6cd --- /dev/null +++ b/recipes/libnoise/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.0": + folder: all diff --git a/recipes/libnop/all/conanfile.py b/recipes/libnop/all/conanfile.py index d5fd8f7a7ee39..88ce3b75bc45e 100644 --- a/recipes/libnop/all/conanfile.py +++ b/recipes/libnop/all/conanfile.py @@ -1,8 +1,13 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration -import glob +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +required_conan_version = ">=1.50.0" + class LibnopConan(ConanFile): name = "libnop" @@ -10,36 +15,48 @@ class LibnopConan(ConanFile): "deserializing C++ data types without external code " \ "generators or runtime support libraries." license = "Apache-2.0" - topics = ("conan", "libnop", "header-only", "serializer") + topics = ("libnop", "header-only", "serializer") homepage = "https://github.com/google/libnop" url = "https://github.com/conan-io/conan-center-index" + no_copy_source = True + settings = "os", "arch", "compiler", "build_type" - settings = "compiler" + @property + def _min_cppstd(self): + return "14" @property - def _source_subfolder(self): - return "source_subfolder" + def _compilers_minimum_version(self): + return { + "Visual Studio": "15", + "gcc": "5", + } + + def package_id(self): + self.info.clear() - def configure(self): + def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 14) - compiler = self.settings.compiler - compiler_version = tools.Version(compiler.version) - if (compiler == "gcc" and compiler_version < "5") or \ - (compiler == "Visual Studio" and compiler_version < "15"): - raise ConanInvalidConfiguration("libnop doesn't support {} {}".format(str(compiler), compiler.version)) + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.", + ) - def package_id(self): - self.info.header_only() + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("libnop-*")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): self.cpp_info.libdirs = [] diff --git a/recipes/libnop/all/test_package/CMakeLists.txt b/recipes/libnop/all/test_package/CMakeLists.txt index 3300ff7750277..eb1e148dab4cf 100644 --- a/recipes/libnop/all/test_package/CMakeLists.txt +++ b/recipes/libnop/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libnop REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +target_link_libraries(${PROJECT_NAME} PRIVATE libnop::libnop) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/libnop/all/test_package/conanfile.py b/recipes/libnop/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/libnop/all/test_package/conanfile.py +++ b/recipes/libnop/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libnop/all/test_v1_package/CMakeLists.txt b/recipes/libnop/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a9fc5bd47b8bf --- /dev/null +++ b/recipes/libnop/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libnop REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libnop::libnop) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/libnop/all/test_v1_package/conanfile.py b/recipes/libnop/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libnop/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libnova/all/conandata.yml b/recipes/libnova/all/conandata.yml new file mode 100644 index 0000000000000..ebb1679fa5799 --- /dev/null +++ b/recipes/libnova/all/conandata.yml @@ -0,0 +1,15 @@ +sources: + "0.16.0": + post: + url: "https://sourceforge.net/p/libnova/libnova/ci/v0.16/tarball" + sha256: "not_needed" + archive: + url: "https://sourceforge.net/code-snapshots/git/l/li/libnova/libnova.git/libnova-libnova-edbf65abe27ef1a2520eb9e839daaf58f15a6941.zip" + sha256: "2703497573f949146895dedb6fdf74c8d1f15dbdb831074bbaabc5052bdedc07" +patches: + "0.16.0": + - patch_file: "patches/0001-fix-cmake.patch" + - patch_file: "patches/0002-fix-win32-def.patch" + - patch_file: "patches/0003-no-redefine-nan.patch" + - patch_file: "patches/0004-constellation-syntax-error.patch" + - patch_file: "patches/0005-fix-mingw-w64.patch" diff --git a/recipes/libnova/all/conanfile.py b/recipes/libnova/all/conanfile.py new file mode 100644 index 0000000000000..fceb0ec7133ab --- /dev/null +++ b/recipes/libnova/all/conanfile.py @@ -0,0 +1,95 @@ +from conan import ConanFile +from conan.errors import ConanException +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get +import os +import requests + +required_conan_version = ">=1.46.0" + + +class LibnovaConan(ConanFile): + name = "libnova" + description = ( + "libnova is a general purpose, double precision, celestial mechanics, " + "astrometry and astrodynamics library." + ) + license = "LGPL-2.0-only" + topics = ("libnova", "celestial-mechanics", "astrometry", "astrodynamics") + homepage = "https://sourceforge.net/projects/libnova" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + @staticmethod + def _generate_git_tag_archive_sourceforge(url, timeout=10, retry=2): + def try_post(retry_count): + try: + requests.post(url, timeout=timeout) + except: + if retry_count < retry: + try_post(retry_count + 1) + else: + raise ConanException("All the attempt to generate archive url have failed.") + try_post(0) + + def source(self): + # Generate the archive download link + self._generate_git_tag_archive_sourceforge(self.conan_data["sources"][self.version]["post"]["url"]) + + # Download archive + get(self, **self.conan_data["sources"][self.version]["archive"], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_SHARED_LIBRARY"] = self.options.shared + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + postfix = "d" if self.settings.build_type == "Debug" else "" + self.cpp_info.libs = [f"nova{postfix}"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/libnova/all/patches/0001-fix-cmake.patch b/recipes/libnova/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..e37e50fc6440c --- /dev/null +++ b/recipes/libnova/all/patches/0001-fix-cmake.patch @@ -0,0 +1,103 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,9 +1,9 @@ +-cmake_minimum_required(VERSION 2.6 FATAL_ERROR) ++cmake_minimum_required(VERSION 3.1) + +-project(libnova) ++project(libnova C) + + # define the name of the library +-set(LIBRARY_NAME libnova) ++set(LIBRARY_NAME nova) + + option(BUILD_SHARED_LIBRARY "Set to ON to build libnova as a shared library." ON) + if(BUILD_SHARED_LIBRARY) +@@ -23,10 +23,10 @@ if(WIN32) + endif(WIN32) + + # add more optimization flags to the visual studio release compilation +-if(MSVC) ++if(0) + set(CMAKE_CXX_FLAGS_RELEASE "/MD /Ox /Ob2 /D NDEBUG") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2 /GS-") +-endif(MSVC) ++endif() + + + # set the debug postfix +@@ -69,5 +69,3 @@ include_directories(${libnova_SOURCE_DIR}/src) + + # traverse the sub directories + add_subdirectory(src) +-add_subdirectory(lntest) +-add_subdirectory(examples) +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -1,4 +1,4 @@ +-set(HEADER_PATH ${libnova_SOURCE_DIR}/src/${LIBRARY_NAME}) ++set(HEADER_PATH libnova) + + set(LIBRARY_PUBLIC_HEADERS + ${HEADER_PATH}/julian_day.h +@@ -36,6 +36,7 @@ set(LIBRARY_PUBLIC_HEADERS + ${HEADER_PATH}/parallax.h + ${HEADER_PATH}/airmass.h + ${HEADER_PATH}/heliocentric_time.h ++ ${HEADER_PATH}/constellation.h + ) + + add_library(${LIBRARY_NAME} +@@ -73,15 +74,22 @@ add_library(${LIBRARY_NAME} + parallax.c + airmass.c + heliocentric_time.c ++ constellation.c + ) + +-if(MSVC) ++set_target_properties(${LIBRARY_NAME} PROPERTIES C_STANDARD 99) ++target_compile_definitions(${LIBRARY_NAME} PRIVATE HAVE_ROUND) ++find_library(M_LIB m) ++if(M_LIB) ++ target_link_libraries(${LIBRARY_NAME} PRIVATE ${M_LIB}) ++endif() ++if(0) + if(BUILD_SHARED_LIBRARY) + set_target_properties(${LIBRARY_NAME} PROPERTIES PREFIX "../../bin/" IMPORT_PREFIX "../") + else(BUILD_SHARED_LIBRARY) + set_target_properties(${LIBRARY_NAME} PROPERTIES PREFIX "../") + endif(BUILD_SHARED_LIBRARY) +-endif(MSVC) ++endif() + + + +@@ -93,8 +101,8 @@ if(WIN32) + set(INSTALL_LIBDIR bin) + set(INSTALL_ARCHIVEDIR lib) + else(WIN32) +- set(INSTALL_LIBDIR lib${LIB_POSTFIX}) +- set(INSTALL_ARCHIVEDIR lib${LIB_POSTFIX}) ++ set(INSTALL_LIBDIR lib) ++ set(INSTALL_ARCHIVEDIR lib) + endif(WIN32) + + install( +@@ -106,5 +114,5 @@ install( + + install( + FILES ${LIBRARY_PUBLIC_HEADERS} +- DESTINATION ${INSTALL_INCDIR}/${LIBRARY_NAME} ++ DESTINATION ${INSTALL_INCDIR}/libnova + ) +--- a/src/julian_day.c ++++ b/src/julian_day.c +@@ -27,7 +27,6 @@ + #include + #include + +-#include "config.h" + + #if !defined(__WIN32__) || defined(__MINGW__) + #include diff --git a/recipes/libnova/all/patches/0002-fix-win32-def.patch b/recipes/libnova/all/patches/0002-fix-win32-def.patch new file mode 100644 index 0000000000000..0a59bcb41d6ed --- /dev/null +++ b/recipes/libnova/all/patches/0002-fix-win32-def.patch @@ -0,0 +1,16 @@ +--- a/src/libnova/ln_types.h ++++ b/src/libnova/ln_types.h +@@ -19,9 +19,11 @@ + #ifndef _LN_TYPES_H + #define _LN_TYPES_H + +-#if !defined(__WIN32__) && (defined(__WIN32) || defined(WIN32)) +-#define __WIN32__ ++#if (defined(__WIN32__) || defined(_WIN32) || defined(WIN32)) + #define ALIGN32 ++#if !defined(__WIN32__) ++#define __WIN32__ ++#endif + #else + #define ALIGN32 __attribute__((aligned(32))) + #endif diff --git a/recipes/libnova/all/patches/0003-no-redefine-nan.patch b/recipes/libnova/all/patches/0003-no-redefine-nan.patch new file mode 100644 index 0000000000000..d9d99e1abadc2 --- /dev/null +++ b/recipes/libnova/all/patches/0003-no-redefine-nan.patch @@ -0,0 +1,22 @@ +--- a/src/libnova/utility.h ++++ b/src/libnova/utility.h +@@ -247,7 +247,7 @@ double cbrt(double x); + + #endif /* __C89_SUB__ */ + +-#if defined(__WIN32__) || defined(sun) || defined(__C89_SUB__) ++#if defined(__C89_SUB__) + + /* Not a Number function generator */ + double nan(const char *code); +--- a/src/utility.c ++++ b/src/utility.c +@@ -740,7 +740,7 @@ double cbrt(double x) + + #endif /* __C89_SUB__ */ + +-#if defined(__WIN32__) || defined(sun) || defined(__C89_SUB__) ++#if defined(__C89_SUB__) + + /* Not a Number function generator */ + double nan(const char *code) diff --git a/recipes/libnova/all/patches/0004-constellation-syntax-error.patch b/recipes/libnova/all/patches/0004-constellation-syntax-error.patch new file mode 100644 index 0000000000000..e4a5fcf73a8ce --- /dev/null +++ b/recipes/libnova/all/patches/0004-constellation-syntax-error.patch @@ -0,0 +1,20 @@ +--- a/src/libnova/constellation.h ++++ b/src/libnova/constellation.h +@@ -19,6 +19,8 @@ + #ifndef _LN_CONSTELLATION_H + #define _LN_CONSTELLATION_H + ++#include ++ + #ifdef __cplusplus + extern "C" { + #endif +@@ -31,7 +33,7 @@ extern "C" { + * \ingroup constellations + * \brief Returns name of the constellation at the given position + */ +-const char* LIBNOVA_EXPORT ln_get_constellation(struct ln_equ_posn *position); ++const char LIBNOVA_EXPORT *ln_get_constellation(struct ln_equ_posn *position); + + #ifdef __cplusplus + }; diff --git a/recipes/libnova/all/patches/0005-fix-mingw-w64.patch b/recipes/libnova/all/patches/0005-fix-mingw-w64.patch new file mode 100644 index 0000000000000..a2319ccc96def --- /dev/null +++ b/recipes/libnova/all/patches/0005-fix-mingw-w64.patch @@ -0,0 +1,11 @@ +--- a/src/julian_day.c ++++ b/src/julian_day.c +@@ -16,7 +16,7 @@ + * Copyright (C) 2000 - 2005 Liam Girdwood + */ + +-#if defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__) ++#if defined(__MINGW32__) && !defined(__MINGW64__) + #define _USE_32BIT_TIME_T + #endif //__MINGW__ + diff --git a/recipes/libnova/all/test_package/CMakeLists.txt b/recipes/libnova/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fea9b303f2a63 --- /dev/null +++ b/recipes/libnova/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libnova REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libnova::libnova) diff --git a/recipes/libnova/all/test_package/conanfile.py b/recipes/libnova/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/libnova/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libnova/all/test_package/test_package.c b/recipes/libnova/all/test_package/test_package.c new file mode 100644 index 0000000000000..d69fcbb71b726 --- /dev/null +++ b/recipes/libnova/all/test_package/test_package.c @@ -0,0 +1,21 @@ +#include + +#include + +int main(void) { + struct ln_date date; + date.years = 1987; + date.months = 4; + date.days = 10; + date.hours = 19; + date.minutes = 21; + date.seconds = 0.0; + double julian_day = ln_get_julian_day(&date); + printf("JD %f\n", julian_day); + + struct ln_helio_posn pos; + ln_get_mars_helio_coords(julian_day, &pos); + printf("Mars L %f B %f R %f\n", pos.L, pos.B, pos.R); + + return 0; +} diff --git a/recipes/libnova/all/test_v1_package/CMakeLists.txt b/recipes/libnova/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..171b2322a6708 --- /dev/null +++ b/recipes/libnova/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libnova REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libnova::libnova) diff --git a/recipes/libnova/all/test_v1_package/conanfile.py b/recipes/libnova/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libnova/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libnova/config.yml b/recipes/libnova/config.yml new file mode 100644 index 0000000000000..e5e40881d5003 --- /dev/null +++ b/recipes/libnova/config.yml @@ -0,0 +1,3 @@ +versions: + "0.16.0": + folder: all diff --git a/recipes/libnuma/all/conandata.yml b/recipes/libnuma/all/conandata.yml index 7c99925f01ad9..0c573279e69f1 100644 --- a/recipes/libnuma/all/conandata.yml +++ b/recipes/libnuma/all/conandata.yml @@ -3,6 +3,5 @@ sources: url: "https://github.com/numactl/numactl/releases/download/v2.0.14/numactl-2.0.14.tar.gz" sha256: "826bd148c1b6231e1284e42a4db510207747484b112aee25ed6b1078756bcff6" patches: - "2.0.14": + "2.0.14": - patch_file: "patches/symver.patch" - base_path: "source_subfolder" diff --git a/recipes/libnuma/all/conanfile.py b/recipes/libnuma/all/conanfile.py index 3912d21fbcf80..3234c3cbc8e68 100644 --- a/recipes/libnuma/all/conanfile.py +++ b/recipes/libnuma/all/conanfile.py @@ -1,17 +1,21 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout import os -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.53.0" -required_conan_version = ">=1.29.1" class LibnumaConan(ConanFile): name = "libnuma" description = "NUMA support for Linux." license = "LGPL-2.1-or-later" - topics = ("conan", "numa") + topics = ("numa") homepage = "https://github.com/numactl/numactl" url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -21,60 +25,47 @@ class LibnumaConan(ConanFile): "shared": False, "fPIC": True, } - exports_sources = "patches/**" - - _autotools = None - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def configure(self): - if self.settings.os != "Linux": - raise ConanInvalidConfiguration("{} is only supported on Linux".format(self.name)) - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd if self.options.shared: del self.options.fPIC + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") - def _patch_sources(self): - for patch in self.conan_data.get("patches",{}).get(self.version, []): - tools.patch(**patch) - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("numactl-" + self.version, self._source_subfolder) + def layout(self): + basic_layout(self, src_folder="src") - def _configure_autotools(self): - if self._autotools: - return self._autotools + def validate(self): + if self.info.settings.os != "Linux": + raise ConanInvalidConfiguration("libnuma is only supported on Linux") - self._autotools = AutoToolsBuildEnvironment(self) - - args = [] - if self.options.shared: - args.extend(["--disable-static", "--enable-shared"]) - else: - args.extend(["--disable-shared", "--enable-static"]) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - self._autotools.configure(args=args, configure_dir=self._source_subfolder) - return self._autotools + def generate(self): + tc = AutotoolsToolchain(self) + tc.generate() def build(self): - self._patch_sources() - autotools = self._configure_autotools() + apply_conandata_patches(self) + autotools = Autotools(self) + autotools.configure() autotools.make() def package(self): - self.copy("LICENSE.LGPL2.1", dst="licenses", src=self._source_subfolder) - autotools = self._configure_autotools() + copy(self, "LICENSE.LGPL2.1", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) autotools.install() - tools.rmdir(os.path.join(self.package_folder, "bin")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + rmdir(self, os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "numa") self.cpp_info.libs = ["numa"] - self.cpp_info.names["pkg_config"] = "numa" self.cpp_info.system_libs = ["dl", "pthread"] diff --git a/recipes/libnuma/all/test_package/CMakeLists.txt b/recipes/libnuma/all/test_package/CMakeLists.txt index 34af13462f44f..4a335520f487b 100644 --- a/recipes/libnuma/all/test_package/CMakeLists.txt +++ b/recipes/libnuma/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libnuma REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libnuma::libnuma) diff --git a/recipes/libnuma/all/test_package/conanfile.py b/recipes/libnuma/all/test_package/conanfile.py index 1df900244a291..0a6bc68712d90 100644 --- a/recipes/libnuma/all/test_package/conanfile.py +++ b/recipes/libnuma/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libnuma/all/test_v1_package/CMakeLists.txt b/recipes/libnuma/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libnuma/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libnuma/all/test_v1_package/conanfile.py b/recipes/libnuma/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libnuma/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/liboping/all/conandata.yml b/recipes/liboping/all/conandata.yml new file mode 100644 index 0000000000000..383d4f884713f --- /dev/null +++ b/recipes/liboping/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "1.10.0": + url: "https://noping.cc/files/liboping-1.10.0.tar.gz" + sha256: "c206b05743d0730814be3115b48abd0b00016677525153c78730da307aba0846" +patches: + "1.10.0": + - patch_file: "patches/1.10.0-suppress_truncate.patch" + base_path: "source_subfolder" + diff --git a/recipes/liboping/all/conanfile.py b/recipes/liboping/all/conanfile.py new file mode 100644 index 0000000000000..21125770e672e --- /dev/null +++ b/recipes/liboping/all/conanfile.py @@ -0,0 +1,103 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + + +class LibopingConan(ConanFile): + name = "liboping" + description = "A multi server ping library" + topics = ("oping", "ping", "icmp") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://noping.cc" + license = ["LGPL-2.1", "GPL-2.0"] + settings = "os", "arch", "compiler", "build_type" + exports_sources = ["patches/**"] + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def validate(self): + if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("liboping is not supported by Visual Studio") + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("Liboping could not be built on {} as shared library".format(self.settings.os)) + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Build error - NO Access to a Mac/M1 - please fix when possible - see issue 8634 + raise ConanInvalidConfiguration("Liboping cannot be built on a Mac/M1 at this time") + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--without-ncurses", + "--without-perl-bindings", + ] + self._autotools.configure(args=args, configure_dir=self._source_subfolder) + return self._autotools + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def build(self): + self._patch_sources() + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + autotools = self._configure_autotools() + autotools.install() + + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) + self.cpp_info.libs = ["oping"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + elif self.settings.os == "Windows": + self.cpp_info.system_libs.append("ws2_32") diff --git a/recipes/liboping/all/patches/1.10.0-suppress_truncate.patch b/recipes/liboping/all/patches/1.10.0-suppress_truncate.patch new file mode 100644 index 0000000000000..15fae8ddf0ab4 --- /dev/null +++ b/recipes/liboping/all/patches/1.10.0-suppress_truncate.patch @@ -0,0 +1,18 @@ +--- a/src/liboping.c 2022-01-04 12:15:14.312483115 -0700 ++++ b/src/liboping.c 2022-01-04 12:16:40.031084749 -0700 +@@ -203,8 +203,15 @@ + static void ping_set_error (pingobj_t *obj, const char *function, + const char *message) + { ++#if __GNUC__ >= 7 ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wformat-truncation" ++#endif + snprintf (obj->errmsg, sizeof (obj->errmsg), + "%s: %s", function, message); ++#if __GNUC__ >= 7 ++#pragma GCC diagnostic pop ++#endif + obj->errmsg[sizeof (obj->errmsg) - 1] = 0; + } + diff --git a/recipes/liboping/all/test_package/CMakeLists.txt b/recipes/liboping/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..30961cdb0ded2 --- /dev/null +++ b/recipes/liboping/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(liboping CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} liboping::liboping) diff --git a/recipes/liboping/all/test_package/conanfile.py b/recipes/liboping/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b7bbf79eba926 --- /dev/null +++ b/recipes/liboping/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "arch", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/liboping/all/test_package/test_package.c b/recipes/liboping/all/test_package/test_package.c new file mode 100644 index 0000000000000..775d10557877b --- /dev/null +++ b/recipes/liboping/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include +#include + +int main() { + printf("************* Testing liboping ***************\n"); + pingobj_t *po; + po = ping_construct(); + if (po == NULL) { + printf("\tFAIL\n"); + return 1; + } + ping_destroy(po); + printf("\tOK\n"); + printf("***********************************************\n"); + return 0; +} diff --git a/recipes/liboping/config.yml b/recipes/liboping/config.yml new file mode 100644 index 0000000000000..703aaba144d10 --- /dev/null +++ b/recipes/liboping/config.yml @@ -0,0 +1,3 @@ +versions: + "1.10.0": + folder: all diff --git a/recipes/libpcap/all/CMakeLists.txt b/recipes/libpcap/all/CMakeLists.txt new file mode 100644 index 0000000000000..1632809b71a7a --- /dev/null +++ b/recipes/libpcap/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/libpcap/all/conandata.yml b/recipes/libpcap/all/conandata.yml index 941dc7e139d1d..c909e32c74890 100644 --- a/recipes/libpcap/all/conandata.yml +++ b/recipes/libpcap/all/conandata.yml @@ -1,7 +1,10 @@ sources: - "1.9.1": - sha256: 8ac670de8dd6eff39441580c67f0520f326773422bbf89fdffcd269bd0cfddde - url: https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.9.1.tar.gz + "1.10.1": + url: "https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.10.1.tar.gz" + sha256: "7b650c9e0ce246aa41ba5463fe8e903efc444c914a3ccb986547350bed077ed6" "1.10.0": - sha256: 7d8c18f740c0b630f55699ea22191ffbbba483f48ea60506848f9241d3973763 - url: https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.10.0.tar.gz + url: "https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.10.0.tar.gz" + sha256: "7d8c18f740c0b630f55699ea22191ffbbba483f48ea60506848f9241d3973763" + "1.9.1": + url: "https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.9.1.tar.gz" + sha256: "8ac670de8dd6eff39441580c67f0520f326773422bbf89fdffcd269bd0cfddde" diff --git a/recipes/libpcap/all/conanfile.py b/recipes/libpcap/all/conanfile.py index b412717fed35b..be545689c190c 100644 --- a/recipes/libpcap/all/conanfile.py +++ b/recipes/libpcap/all/conanfile.py @@ -1,6 +1,11 @@ -from conans import AutoToolsBuildEnvironment, tools, ConanFile +from conan.tools.microsoft import msvc_runtime_flag +from conans import AutoToolsBuildEnvironment, tools, ConanFile, CMake from conans.errors import ConanInvalidConfiguration +import glob import os +import shutil + +required_conan_version = ">=1.36.0" class LibPcapConan(ConanFile): @@ -10,19 +15,24 @@ class LibPcapConan(ConanFile): description = "libpcap is an API for capturing network traffic" license = "BSD-3-Clause" topics = ("networking", "pcap", "sniffing", "network-traffic") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "enable_libusb": [True, False], - "enable_universal": [True, False] + "enable_universal": [True, False, "deprecated"], } default_options = { "shared": False, "fPIC": True, "enable_libusb": False, - "enable_universal": True + "enable_universal": "deprecated", } + + exports_sources = "CMakeLists.txt" + generators = "cmake" + _cmake = None _autotools = None # TODO: Add dbus-glib when available @@ -34,61 +44,140 @@ class LibPcapConan(ConanFile): def _source_subfolder(self): return "source_subfolder" - def requirements(self): - if self.options.enable_libusb: - self.requires("libusb/1.0.23") + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] - def build_requirements(self): - if self.settings.os == "Linux": - self.build_requires("bison/3.7.1") - self.build_requires("flex/2.6.4") + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = self.name + "-" + self.name + "-" + self.version - os.rename(extracted_folder, self._source_subfolder) + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.os != "Linux": + del self.options.enable_libusb def configure(self): - if self.settings.os == "Macos" and self.options.shared: - raise ConanInvalidConfiguration("libpcap can not be built as shared on OSX.") - if self.settings.os == "Windows": - raise ConanInvalidConfiguration("libpcap is not supported on Windows.") + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + if self.options.enable_universal != "deprecated": + self.output.warn("enable_universal is a deprecated option. Do not use.") + + def requirements(self): + if self.options.get_safe("enable_libusb"): + self.requires("libusb/1.0.24") + + def validate(self): + if tools.Version(self.version) < "1.10.0" and self.settings.os == "Macos" and self.options.shared: + raise ConanInvalidConfiguration("libpcap {} can not be built as shared on OSX.".format(self.version)) + if hasattr(self, "settings_build") and tools.cross_building(self) and \ + self.options.shared and tools.is_apple_os(self.settings.os): + raise ConanInvalidConfiguration("cross-build of libpcap shared is broken on Apple") + if tools.Version(self.version) < "1.10.1" and self.settings.os == "Windows" and not self.options.shared: + raise ConanInvalidConfiguration("libpcap can not be built static on Windows below version 1.10.1.") + + def package_id(self): + del self.info.options.enable_universal + + def build_requirements(self): + if self._settings_build.os == "Windows": + self.build_requires("winflexbison/2.5.24") + else: + self.build_requires("bison/3.7.6") + self.build_requires("flex/2.6.4") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_autotools(self): - if not self._autotools: - self._autotools = AutoToolsBuildEnvironment(self) - configure_args = ["--enable-shared" if self.options.shared else "--disable-shared"] - configure_args.append("--disable-universal" if not self.options.enable_universal else "") - configure_args.append("--enable-usb" if self.options.enable_libusb else "--disable-usb") - configure_args.extend([ - "--without-libnl", - "--disable-bluetooth", - "--disable-packet-ring", - "--disable-dbus", - "--disable-rdma" - ]) - if tools.cross_building(self.settings): - target_os = "linux" if self.settings.os == "Linux" else "null" - configure_args.append("--with-pcap=%s" % target_os) - elif "arm" in self.settings.arch and self.settings.os == "Linux": - configure_args.append("--host=arm-linux") - self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self) + self._autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" + configure_args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-usb={}".format(yes_no(self.options.get_safe("enable_libusb"))), + "--disable-universal", + "--without-libnl", + "--disable-bluetooth", + "--disable-packet-ring", + "--disable-dbus", + "--disable-rdma", + ] + if tools.cross_building(self): + target_os = "linux" if self.settings.os == "Linux" else "null" + configure_args.append("--with-pcap=%s" % target_os) + elif "arm" in self.settings.arch and self.settings.os == "Linux": + configure_args.append("--host=arm-linux") + self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) + # Relocatable shared lib on macOS + tools.replace_in_file("Makefile", "-install_name $(libdir)/", "-install_name @rpath/") return self._autotools + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + if not self.options.shared: + self._cmake.definitions["ENABLE_REMOTE"] = False + if self._is_msvc: + self._cmake.definitions["USE_STATIC_RT"] = "MT" in msvc_runtime_flag(self) + else: + # Don't force -static-libgcc for MinGW, because conan users expect + # to inject this compilation flag themselves + self._cmake.definitions["USE_STATIC_RT"] = False + self._cmake.configure() + return self._cmake + def build(self): - autotools = self._configure_autotools() - autotools.make() + if self.settings.os == "Windows": + cmake = self._configure_cmake() + cmake.build() + else: + autotools = self._configure_autotools() + autotools.make() def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - if self.options.shared: - os.remove(os.path.join(self.package_folder, "lib", "libpcap.a")) + + if self.settings.os == "Windows": + cmake = self._configure_cmake() + cmake.install() + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + if self.options.shared: + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "pcap_static.lib") + + def flatten_filetree(folder): + for file in glob.glob(folder + "/**/*"): + shutil.move(file, folder + os.sep) + for subdir in [dir[0] for dir in os.walk(folder) if dir[0] != folder]: + os.rmdir(subdir) + + # libpcap installs into a subfolder like x64 or amd64 + with tools.chdir(self.package_folder): + flatten_filetree("bin") + flatten_filetree("lib") + else: + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + if self.options.shared: + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.a") def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("pkg_config_name", "libpcap") + suffix = "_static" if self.settings.os == "Windows" and not self.options.shared else "" + self.cpp_info.libs = ["pcap{}".format(suffix)] + if self.settings.os == "Windows": + self.cpp_info.system_libs = ["ws2_32"] + + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) diff --git a/recipes/libpcap/all/test_package/CMakeLists.txt b/recipes/libpcap/all/test_package/CMakeLists.txt index c286cf27de8ad..f77be2959f6fc 100644 --- a/recipes/libpcap/all/test_package/CMakeLists.txt +++ b/recipes/libpcap/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(test_package list_network.c) -target_link_libraries(test_package ${CONAN_LIBS}) +find_package(libpcap REQUIRED CONFIG) + +add_executable(test_package test_package.c) +target_link_libraries(test_package libpcap::libpcap) diff --git a/recipes/libpcap/all/test_package/conanfile.py b/recipes/libpcap/all/test_package/conanfile.py index b88a6525524a6..38f4483872d47 100644 --- a/recipes/libpcap/all/test_package/conanfile.py +++ b/recipes/libpcap/all/test_package/conanfile.py @@ -1,10 +1,10 @@ -from conans import ConanFile, CMake +from conans import ConanFile, CMake, tools import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,5 +12,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libpcap/all/test_package/list_network.c b/recipes/libpcap/all/test_package/test_package.c similarity index 100% rename from recipes/libpcap/all/test_package/list_network.c rename to recipes/libpcap/all/test_package/test_package.c diff --git a/recipes/libpcap/config.yml b/recipes/libpcap/config.yml index 9c1b99b9b8d90..102e778434a57 100644 --- a/recipes/libpcap/config.yml +++ b/recipes/libpcap/config.yml @@ -1,5 +1,7 @@ versions: - "1.9.1": + "1.10.1": folder: all "1.10.0": folder: all + "1.9.1": + folder: all diff --git a/recipes/libpciaccess/all/conandata.yml b/recipes/libpciaccess/all/conandata.yml new file mode 100644 index 0000000000000..a9f6a4bea0057 --- /dev/null +++ b/recipes/libpciaccess/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.16": + url: "https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/archive/libpciaccess-0.16/libpciaccess-libpciaccess-0.16.tar.gz" + sha256: "983b31ab586e3f2da810bd6bcbbcf9d643f8968d2280c6e573fec95b556e971f" diff --git a/recipes/libpciaccess/all/conanfile.py b/recipes/libpciaccess/all/conanfile.py new file mode 100644 index 0000000000000..8991eccca99f0 --- /dev/null +++ b/recipes/libpciaccess/all/conanfile.py @@ -0,0 +1,88 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +import os + + +required_conan_version = ">=1.50.0" + + +class LibPciAccessConan(ConanFile): + name = "libpciaccess" + description = "Generic PCI access library" + topics = ("pci", "xorg") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gitlab.freedesktop.org/xorg/lib/libpciaccess" + license = "MIT", "X11" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def validate(self): + def is_supported(settings): + if settings.os in ("Linux", "FreeBSD", "SunOS"): + return True + return settings.os == "Windows" and settings.get_safe("os.subsystem") == "cygwin" + if not is_supported(self.settings): + raise ConanInvalidConfiguration("Unsupported architecture.") + + def build_requirements(self): + self.tool_requires("libtool/2.4.6") + self.tool_requires("pkgconf/1.7.4") + self.tool_requires("xorg-macros/1.19.3") + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][str(self.version)], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = AutotoolsToolchain(self) + tc.generate() + ms = VirtualBuildEnv(self) + ms.generate(scope="build") + + def build(self): + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + + def package_info(self): + self.cpp_info.libs = ["pciaccess"] + self.cpp_info.set_property("pkg_config_name", "pciaccess") diff --git a/recipes/libpciaccess/all/test_package/CMakeLists.txt b/recipes/libpciaccess/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e6f3ddc50ab4d --- /dev/null +++ b/recipes/libpciaccess/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libpciaccess REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libpciaccess::libpciaccess) diff --git a/recipes/libpciaccess/all/test_package/conanfile.py b/recipes/libpciaccess/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/libpciaccess/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libpciaccess/all/test_package/test_package.c b/recipes/libpciaccess/all/test_package/test_package.c new file mode 100644 index 0000000000000..08fdca1d2e02f --- /dev/null +++ b/recipes/libpciaccess/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include +#include + +int main(void) { + pci_system_init(); + pci_system_cleanup(); + return EXIT_SUCCESS; +} diff --git a/recipes/libpciaccess/all/test_v1_package/CMakeLists.txt b/recipes/libpciaccess/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e01755e70e68b --- /dev/null +++ b/recipes/libpciaccess/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libpciaccess REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libpciaccess::libpciaccess) diff --git a/recipes/libpciaccess/all/test_v1_package/conanfile.py b/recipes/libpciaccess/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/libpciaccess/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libpciaccess/config.yml b/recipes/libpciaccess/config.yml new file mode 100644 index 0000000000000..95828182e346d --- /dev/null +++ b/recipes/libpciaccess/config.yml @@ -0,0 +1,3 @@ +versions: + "0.16": + folder: all diff --git a/recipes/libpfm4/all/conandata.yml b/recipes/libpfm4/all/conandata.yml new file mode 100644 index 0000000000000..ccfa567e2963b --- /dev/null +++ b/recipes/libpfm4/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "4.12.0": + url: "https://versaweb.dl.sourceforge.net/project/perfmon2/libpfm4/libpfm-4.12.0.tar.gz" + sha256: "4b0c1f53f39a61525b69bebf532c68040c1b984d7544a8ae0844b13cd91e1ee4" diff --git a/recipes/libpfm4/all/conanfile.py b/recipes/libpfm4/all/conanfile.py new file mode 100644 index 0000000000000..89894d3e1796e --- /dev/null +++ b/recipes/libpfm4/all/conanfile.py @@ -0,0 +1,95 @@ +from conan import ConanFile +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.files import get, rmdir, copy, replace_in_file +from conan.errors import ConanInvalidConfiguration +import os + + +class Libpfm4Conan(ConanFile): + name = "libpfm4" + license = "MIT" + homepage = "http://perfmon2.sourceforge.net" + url = "https://github.com/conan-io/conan-center-index" + description = ("A helper library to program the performance monitoring events") + topics = ("perf", "pmu", "benchmark", "microbenchmark") + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + def validate(self): + # The library doesn't really make much sense without perf_events API + # and currently does not compile on modern Mac OS X && Windows + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("This library is Linux only") + + def config_options(self): + # and currently does not compile on modern Mac OS X && Windows + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + + def layout(self): + basic_layout(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self.source_folder) + + def generate(self): + tc = AutotoolsToolchain(self) + tc.generate() + + def _patch_sources(self): + if not self.options.shared: + # honor fPIC option + replace_in_file(self, os.path.join(self.source_folder, "rules.mk"), "-fPIC", "") + replace_in_file(self, os.path.join(self.source_folder, "rules.mk"), "-DPIC", "") + + def build(self): + self._patch_sources() + args = [ + 'DBG=', + 'CONFIG_PFMLIB_SHARED={}'.format("y" if self.options.shared else "n"), + f'-C {self.source_folder}' + ] + autotools = Autotools(self) + autotools.make(args=args) + + def package(self): + copy(self, "COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + args = [ + 'DBG=', + 'LDCONFIG=true', + 'CONFIG_PFMLIB_SHARED={}'.format("y" if self.options.shared else "n"), + f'DESTDIR={self.package_folder}{os.sep}', + f'INCDIR=include{os.sep}', + f'LIBDIR=lib{os.sep}', + f'-C {self.source_folder}' + ] + # due to bug, Mac install phase fails with config shared + if self.settings.os == 'Macos': + args.append('CONFIG_PFMLIB_SHARED=n') + + copy(self, "err.h", dst=os.path.join(self.package_folder, "include", "perfmon"), src=os.path.join(self.source_folder, "include", "perfmon")) + autotools = Autotools(self) + autotools.install(args=args) + rmdir(self, os.path.join(self.package_folder, "usr")) + + def package_info(self): + self.cpp_info.libs = ["pfm"] + if self.settings.os in ("Linux", "FreeBSD"): + self.cpp_info.system_libs = ["pthread", "m"] diff --git a/recipes/libpfm4/all/test_package/CMakeLists.txt b/recipes/libpfm4/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c93d1fbd7ce51 --- /dev/null +++ b/recipes/libpfm4/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +find_package(libpfm4 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libpfm4::libpfm4) diff --git a/recipes/libpfm4/all/test_package/conanfile.py b/recipes/libpfm4/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/libpfm4/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libpfm4/all/test_package/test_package.c b/recipes/libpfm4/all/test_package/test_package.c new file mode 100644 index 0000000000000..22dc57834a15e --- /dev/null +++ b/recipes/libpfm4/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include +#include +#include +#include + + +int main(void) { + int version = 0; + + pfm_initialize(); + version = pfm_get_version(); + printf("PFM VERSION: %d\n", version); + pfm_terminate(); + + return EXIT_SUCCESS; +} diff --git a/recipes/libpfm4/all/test_v1_package/CMakeLists.txt b/recipes/libpfm4/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..92ff6b140a2cc --- /dev/null +++ b/recipes/libpfm4/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libpfm4 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libpfm4::libpfm4) diff --git a/recipes/libpfm4/all/test_v1_package/conanfile.py b/recipes/libpfm4/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2490acfa82ff8 --- /dev/null +++ b/recipes/libpfm4/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libpfm4/config.yml b/recipes/libpfm4/config.yml new file mode 100644 index 0000000000000..b06c46e0f08f9 --- /dev/null +++ b/recipes/libpfm4/config.yml @@ -0,0 +1,3 @@ +versions: + "4.12.0": + folder: all diff --git a/recipes/libpng/all/CMakeLists.txt b/recipes/libpng/all/CMakeLists.txt deleted file mode 100644 index a018c496c3785..0000000000000 --- a/recipes/libpng/all/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.1.2) -project(cmake_wrapper) - -message(STATUS "Conan CMake Wrapper") -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libpng/all/conandata.yml b/recipes/libpng/all/conandata.yml index fec2a70eb9c6c..c3684c2f1a2bc 100644 --- a/recipes/libpng/all/conandata.yml +++ b/recipes/libpng/all/conandata.yml @@ -1,4 +1,24 @@ sources: + "1.6.39": + url: "https://github.com/glennrp/libpng/archive/v1.6.39.tar.gz" + sha256: "a00e9d2f2f664186e4202db9299397f851aea71b36a35e74910b8820e380d441" + "1.6.38": + url: "https://github.com/glennrp/libpng/archive/v1.6.38.tar.gz" + sha256: "d4160037fa5d09fa7cff555037f2a7f2fefc99ca01e21723b19bfcda33015234" "1.6.37": url: "https://github.com/glennrp/libpng/archive/v1.6.37.tar.gz" sha256: "ca74a0dace179a8422187671aee97dd3892b53e168627145271cad5b5ac81307" + "1.5.30": + url: "https://github.com/glennrp/libpng/archive/v1.5.30.tar.gz" + sha256: "738e2eb31abc1140f2d6c914f0f69748b49f2ae7ffc05e7a073abafc08f37441" +patches: + "1.6.37": + - patch_file: "patches/0001-1.6.37-cmakefile-zlib.patch" + patch_description: "Update ZLib include and library paths for conan to provide\ + \ lib. Remove Zlib dll definition." + patch_type: "conan" + "1.5.30": + - patch_file: "patches/0001-1.5.30-cmakefile-zlib.patch" + patch_description: "Update ZLib include and library paths for conan to provide\ + \ lib. Remove Zlib dll definition." + patch_type: "conan" diff --git a/recipes/libpng/all/conanfile.py b/recipes/libpng/all/conanfile.py index 3b6af9b63ae0b..7132f93ea7ab3 100644 --- a/recipes/libpng/all/conanfile.py +++ b/recipes/libpng/all/conanfile.py @@ -1,6 +1,14 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os -from conans import ConanFile, tools, CMake -from conans.errors import ConanException + +required_conan_version = ">=1.53.0" class LibpngConan(ConanFile): @@ -9,96 +17,180 @@ class LibpngConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.libpng.org" license = "libpng-2.0" - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = ["cmake", "cmake_find_package"] + topics = ("png", "graphics", "image") settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False], "api_prefix": "ANY"} - default_options = {'shared': False, 'fPIC': True, "api_prefix": None} - topics = ("conan", "png", "libpng") + options = { + "shared": [True, False], + "fPIC": [True, False], + "neon": [True, "check", False], + "msa": [True, False], + "sse": [True, False], + "vsx": [True, False], + "api_prefix": ["ANY"], + } + default_options = { + "shared": False, + "fPIC": True, + "neon": True, + "msa": True, + "sse": True, + "vsx": True, + "api_prefix": "", + } - _source_subfolder = "source_subfolder" + @property + def _has_neon_support(self): + return "arm" in self.settings.arch - def requirements(self): - self.requires("zlib/1.2.11") + @property + def _has_msa_support(self): + return "mips" in self.settings.arch + + @property + def _has_sse_support(self): + return self.settings.arch in ["x86", "x86_64"] + + @property + def _has_vsx_support(self): + return "ppc" in self.settings.arch + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if not self._has_neon_support: + del self.options.neon + if not self._has_msa_support: + del self.options.msa + if not self._has_sse_support: + del self.options.sse + if not self._has_vsx_support: + del self.options.vsx def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("zlib/1.2.13") + + def validate(self): + if Version(self.version) < "1.6" and self.info.settings.arch == "armv8" and is_apple_os(self): + raise ConanInvalidConfiguration(f"{self.ref} currently does not building for {self.info.settings.os} {self.info.settings.arch}. Contributions are welcomed") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libpng-" + self.version, self._source_subfolder) - - def _patch(self): - tools.patch(base_path=self._source_subfolder, patch_file=os.path.join("patches", "CMakeLists-zlib.patch")) - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "find_library(M_LIBRARY m)", - "set(M_LIBRARY m)") - - if tools.os_info.is_windows: - if self.settings.compiler == "Visual Studio": - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - 'OUTPUT_NAME "${PNG_LIB_NAME}_static', - 'OUTPUT_NAME "${PNG_LIB_NAME}') + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + @property + def _neon_msa_sse_vsx_mapping(self): + return { + "True": "on", + "False": "off", + "check": "check", + } + + @property + def _libpng_cmake_system_processor(self): + # FIXME: too specific and error prone, should be delegated to a conan helper function + # It should satisfy libpng CMakeLists specifically, do not use it naively in an other recipe + if "mips" in self.settings.arch: + return "mipsel" + if "ppc" in self.settings.arch: + return "powerpc" + return str(self.settings.arch) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["PNG_TESTS"] = False + tc.variables["PNG_SHARED"] = self.options.shared + tc.variables["PNG_STATIC"] = not self.options.shared + tc.variables["PNG_DEBUG"] = self.settings.build_type == "Debug" + tc.variables["PNG_PREFIX"] = self.options.api_prefix + if cross_building(self): + system_processor = self.conf.get("tools.cmake.cmaketoolchain:system_processor", + self._libpng_cmake_system_processor, check_type=str) + tc.cache_variables["CMAKE_SYSTEM_PROCESSOR"] = system_processor + if self._has_neon_support: + tc.variables["PNG_ARM_NEON"] = self._neon_msa_sse_vsx_mapping[str(self.options.neon)] + if self._has_msa_support: + tc.variables["PNG_MIPS_MSA"] = self._neon_msa_sse_vsx_mapping[str(self.options.msa)] + if self._has_sse_support: + tc.variables["PNG_INTEL_SSE"] = self._neon_msa_sse_vsx_mapping[str(self.options.sse)] + if self._has_vsx_support: + tc.variables["PNG_POWERPC_VSX"] = self._neon_msa_sse_vsx_mapping[str(self.options.vsx)] + if Version(self.version) >= "1.6.38": + tc.variables["PNG_EXECUTABLES"] = False + + tc.cache_variables["CMAKE_MACOSX_BUNDLE"] = False + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + if self.settings.os == "Windows": + if Version(self.version) <= "1.5.2": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + 'set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)', + 'set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME})') else: - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - 'COMMAND "${CMAKE_COMMAND}" -E copy_if_different $ $/${DEST_FILE}', + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + 'OUTPUT_NAME "${PNG_LIB_NAME}_static', + 'OUTPUT_NAME "${PNG_LIB_NAME}') + if not is_msvc(self): + if Version(self.version) < "1.6.38": + src_text = 'COMMAND "${CMAKE_COMMAND}" -E copy_if_different $ $/${DEST_FILE}' + else: + src_text = '''COMMAND "${CMAKE_COMMAND}" + -E copy_if_different + $ + $/${DEST_FILE}''' + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + src_text, 'COMMAND "${CMAKE_COMMAND}" -E copy_if_different $/$ $/${DEST_FILE}') - if self.settings.build_type == 'Debug': - tools.replace_in_file(os.path.join(self._source_subfolder, 'libpng.pc.in'), - '-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@', - '-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@d') - - def _configure_cmake(self): + def build(self): + self._patch_sources() cmake = CMake(self) - cmake.definitions["PNG_TESTS"] = "OFF" - cmake.definitions["PNG_SHARED"] = self.options.shared - cmake.definitions["PNG_STATIC"] = not self.options.shared - cmake.definitions["PNG_DEBUG"] = "OFF" if self.settings.build_type == "Release" else "ON" - if self.settings.os == "Emscripten": - cmake.definitions["PNG_BUILD_ZLIB"] = "ON" - cmake.definitions["M_LIBRARY"] = "" - cmake.definitions["ZLIB_LIBRARY"] = self.deps_cpp_info["zlib"].libs[0] - cmake.definitions["ZLIB_INCLUDE_DIR"] = self.deps_cpp_info["zlib"].include_paths[0] - if self.settings.os == "Macos": - if 'arm' in self.settings.arch: - cmake.definitions["PNG_ARM_NEON"] = "on" - if self.options.api_prefix: - cmake.definitions["PNG_PREFIX"] = self.options.api_prefix cmake.configure() - return cmake - - def build(self): - self._patch() - cmake = self._configure_cmake() cmake.build() def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses", ignore_case=True, keep_path=False) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, 'share')) - tools.rmdir(os.path.join(self.package_folder, 'lib', 'libpng')) - tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) + if self.options.shared: + rm(self, "*[!.dll]", os.path.join(self.package_folder, "bin")) + else: + rmdir(self, os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "lib", "libpng")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): + major_min_version = f"{Version(self.version).major}{Version(self.version).minor}" + + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "PNG") + self.cpp_info.set_property("cmake_target_name", "PNG::PNG") + self.cpp_info.set_property("pkg_config_name", "libpng") + self.cpp_info.set_property("pkg_config_aliases", [f"libpng{major_min_version}"]) + + prefix = "lib" if is_msvc(self) else "" + suffix = major_min_version if self.settings.os == "Windows" else "" + suffix += "d" if self.settings.os == "Windows" and self.settings.build_type == "Debug" else "" + self.cpp_info.libs = [f"{prefix}png{suffix}"] + if self.settings.os in ["Linux", "Android", "FreeBSD", "SunOS", "AIX"]: + self.cpp_info.system_libs.append("m") + + # TODO: Remove after Conan 2.0 self.cpp_info.names["cmake_find_package"] = "PNG" self.cpp_info.names["cmake_find_package_multi"] = "PNG" - - if self.settings.os == "Windows": - if self.settings.compiler == "gcc": - self.cpp_info.libs = ["png"] - else: - self.cpp_info.libs = ['libpng16'] - else: - self.cpp_info.libs = ["png16"] - if str(self.settings.os) in ["Linux", "Android", "FreeBSD"]: - self.cpp_info.system_libs.append("m") - # use 'd' suffix everywhere except mingw - if self.settings.build_type == "Debug" and not (self.settings.os == "Windows" and self.settings.compiler == "gcc"): - self.cpp_info.libs[0] += "d" diff --git a/recipes/libpng/all/patches/0001-1.5.30-cmakefile-zlib.patch b/recipes/libpng/all/patches/0001-1.5.30-cmakefile-zlib.patch new file mode 100644 index 0000000000000..d78bd326e5e4c --- /dev/null +++ b/recipes/libpng/all/patches/0001-1.5.30-cmakefile-zlib.patch @@ -0,0 +1,49 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b861195..8e3d2ca 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -41,7 +41,7 @@ set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) + + # needed packages + find_package(ZLIB REQUIRED) +-include_directories(${ZLIB_INCLUDE_DIR}) ++include_directories(${ZLIB_INCLUDE_DIRS}) + + if(NOT WIN32) + find_library(M_LIBRARY +@@ -312,7 +312,7 @@ if(PNG_DEBUG) + endif() + + # NOW BUILD OUR TARGET +-include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) ++include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIRS}) + + unset(PNG_LIB_TARGETS) + +@@ -326,7 +326,7 @@ if(PNG_SHARED) + set_target_properties(png PROPERTIES PREFIX "lib") + set_target_properties(png PROPERTIES IMPORT_PREFIX "lib") + endif() +- target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY}) ++ target_link_libraries(png ${ZLIB_LIBRARIES} ${M_LIBRARY}) + + if(UNIX AND AWK) + if(HAVE_LD_VERSION_SCRIPT) +@@ -361,7 +361,7 @@ if(PNG_STATIC) + # msvc does not append 'lib' - do it here to have consistent name + set_target_properties(png_static PROPERTIES PREFIX "lib") + endif() +- target_link_libraries(png_static ${ZLIB_LIBRARY} ${M_LIBRARY}) ++ target_link_libraries(png_static ${ZLIB_LIBRARIES} ${M_LIBRARY}) + endif() + + if(PNG_FRAMEWORK) +@@ -378,7 +378,7 @@ if(PNG_FRAMEWORK) + XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" + PUBLIC_HEADER "${libpng_public_hdrs}" + OUTPUT_NAME png) +- target_link_libraries(png_framework ${ZLIB_LIBRARY} ${M_LIBRARY}) ++ target_link_libraries(png_framework ${ZLIB_LIBRARIES} ${M_LIBRARY}) + endif() + + if(NOT PNG_LIB_TARGETS) diff --git a/recipes/libpng/all/patches/CMakeLists-zlib.patch b/recipes/libpng/all/patches/0001-1.6.37-cmakefile-zlib.patch similarity index 100% rename from recipes/libpng/all/patches/CMakeLists-zlib.patch rename to recipes/libpng/all/patches/0001-1.6.37-cmakefile-zlib.patch diff --git a/recipes/libpng/all/test_package/CMakeLists.txt b/recipes/libpng/all/test_package/CMakeLists.txt index 33ae887aa6aea..59e144e90a535 100644 --- a/recipes/libpng/all/test_package/CMakeLists.txt +++ b/recipes/libpng/all/test_package/CMakeLists.txt @@ -1,9 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(PNG REQUIRED) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE PNG::PNG) diff --git a/recipes/libpng/all/test_package/conanfile.py b/recipes/libpng/all/test_package/conanfile.py index b156f58b096a4..0a6bc68712d90 100644 --- a/recipes/libpng/all/test_package/conanfile.py +++ b/recipes/libpng/all/test_package/conanfile.py @@ -1,14 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -import re -import subprocess -import platform - -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -16,15 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - if "arm" in self.settings.arch and not tools.os_info.is_macos: - self.test_arm() - else: - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - - def test_arm(self): - file_ext = "so" if self.options["libpng"].shared else "a" - lib_path = os.path.join(self.deps_cpp_info["libpng"].libdirs[0], "libpng.%s" % file_ext) - output = subprocess.check_output(["readelf", "-h", lib_path]).decode() - assert re.search(r"Machine:\s+ARM", output) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libpng/all/test_package/test_package.c b/recipes/libpng/all/test_package/test_package.c new file mode 100644 index 0000000000000..1f4c2a28428ab --- /dev/null +++ b/recipes/libpng/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include +#include +#include +#include "png.h" + + +int main(void) { + png_structp png_ptr; + png_infop info_ptr; + + fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + info_ptr = png_create_info_struct(png_ptr); + + return EXIT_SUCCESS; +} diff --git a/recipes/libpng/all/test_package/test_package.cpp b/recipes/libpng/all/test_package/test_package.cpp deleted file mode 100644 index 8c6f9d0114940..0000000000000 --- a/recipes/libpng/all/test_package/test_package.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include "png.h" -#include "zlib.h" - -int main() -{ - fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", - PNG_LIBPNG_VER_STRING, png_libpng_ver); - fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", - ZLIB_VERSION, zlib_version); - - return 0; -} diff --git a/recipes/libpng/all/test_v1_package/CMakeLists.txt b/recipes/libpng/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libpng/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libpng/all/test_v1_package/conanfile.py b/recipes/libpng/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/libpng/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libpng/config.yml b/recipes/libpng/config.yml index 094de74e9c2d0..feabbd00c1919 100644 --- a/recipes/libpng/config.yml +++ b/recipes/libpng/config.yml @@ -1,3 +1,9 @@ versions: + "1.6.39": + folder: all + "1.6.38": + folder: all "1.6.37": folder: all + "1.5.30": + folder: all diff --git a/recipes/libpq/all/conandata.yml b/recipes/libpq/all/conandata.yml index 1a889bc28908c..aee7eccdfda63 100644 --- a/recipes/libpq/all/conandata.yml +++ b/recipes/libpq/all/conandata.yml @@ -1,40 +1,26 @@ sources: - "13.2": - url: "https://ftp.postgresql.org/pub/source/v13.2/postgresql-13.2.tar.gz" - sha256: "3386a40736332aceb055c7c9012ecc665188536d874d967fcc5a33e7992f8080" - "13.1": - url: "https://ftp.postgresql.org/pub/source/v13.1/postgresql-13.1.tar.gz" - sha256: "c474a70fdacb49e5841e989b47f116080c2c21ff743312f73f4d2ca32ff1d7dd" - "13.0": - url: "https://ftp.postgresql.org/pub/source/v13.0/postgresql-13.0.tar.gz" - sha256: "67b09fca40a35360aef82fee43546271e6a04c33276e0093c5fb48653b2f5afa" - "12.6": - url: "https://ftp.postgresql.org/pub/source/v12.6/postgresql-12.6.tar.gz" - sha256: "c22039cb91a61b46c2df26b4ff64c64b95d6cf3d8e25c22a430bd8fe8eb78e7d" - "12.4": - url: "https://ftp.postgresql.org/pub/source/v12.4/postgresql-12.4.tar.gz" - sha256: "9749b891b9d8f984312fe510a7a3613035134cee1e634793dac5568d1e1a5852" - "12.3": - url: "https://ftp.postgresql.org/pub/source/v12.3/postgresql-12.3.tar.gz" - sha256: "708fd5b32a97577679d3c13824c633936f886a733fc55ab5a9240b615a105f50" - "12.2": - url: "https://ftp.postgresql.org/pub/source/v12.2/postgresql-12.2.tar.gz" - sha256: "8808449444ee9b086054a6dcfbfb98029e4f8022372c2edf3de5b6d8f417c8e4" - "11.11": - url: "https://ftp.postgresql.org/pub/source/v11.11/postgresql-11.11.tar.gz" - sha256: "53af5d8c8c314d31d382e3be670f32f0e21197434b90845560519b373a8ea409" - "11.9": - url: "https://ftp.postgresql.org/pub/source/v11.9/postgresql-11.9.tar.gz" - sha256: "e98a8649814e2fa632a5d86bfb91f1ad570d47b108bc5c0d0d854803282abb03" - "11.7": - url: "https://ftp.postgresql.org/pub/source/v11.7/postgresql-11.7.tar.gz" - sha256: "4db579e34f1d61433db9f29971b04934ea1e3318e4c3905b1e6f240e5b853539" - "11.5": - url: "https://ftp.postgresql.org/pub/source/v11.5/postgresql-11.5.tar.gz" - sha256: "f639af0f8c3f1e470e41c8108cbdaea5836b2738cadd422135aa2a0febc8ae78" - "10.14": - url: "https://ftp.postgresql.org/pub/source/v10.14/postgresql-10.14.tar.gz" - sha256: "5a27e8704d6f401f97b8c61716f7e6bf934d0a4fafc1185b37ee0e2764c54ea9" - "9.6.19": - url: "https://ftp.postgresql.org/pub/source/v9.6.19/postgresql-9.6.19.tar.gz" - sha256: "1840c1f84560ed169079c93610c46c42c4c590181352244e0d8966633a88f358" + "14.5": + url: "https://ftp.postgresql.org/pub/source/v14.5/postgresql-14.5.tar.bz2" + sha256: "d4f72cb5fb857c9a9f75ec8cf091a1771272802f2178f0b2e65b7b6ff64f4a30" + "14.2": + url: "https://ftp.postgresql.org/pub/source/v14.2/postgresql-14.2.tar.bz2" + sha256: "2cf78b2e468912f8101d695db5340cf313c2e9f68a612fb71427524e8c9a977a" + "13.6": + url: "https://ftp.postgresql.org/pub/source/v13.6/postgresql-13.6.tar.gz" + sha256: "42dcde620b627d35bf51dfc2c1d0f7f25f44d3dbedd81cc459da2d2c9e859059" + "12.10": + url: "https://ftp.postgresql.org/pub/source/v12.10/postgresql-12.10.tar.gz" + sha256: "987e008699d52d5de4bae0580416f6c75aa28016b11543c42f5fbde5efbdfb56" + "11.15": + url: "https://ftp.postgresql.org/pub/source/v11.15/postgresql-11.15.tar.gz" + sha256: "5f6ef2add1acb93d69012a55c3f276b91f4f0c91aa9a91243d9c5737ed5b5541" + "10.20": + url: "https://ftp.postgresql.org/pub/source/v10.20/postgresql-10.20.tar.gz" + sha256: "403bdad47101f7c0a15824627dd0fa0ad4abf1fa26d2bde77dea8921da25a48e" + "9.6.24": + url: "https://ftp.postgresql.org/pub/source/v9.6.24/postgresql-9.6.24.tar.gz" + sha256: "52947ecc119846eace5164399d173576c0d4a47ec116ae58a46a8fd0c576c7c3" +patches: + "13.3": + - patch_file: "patches/13.3/001-Remove-thread-safety-check.patch" + base_path: "source_subfolder" diff --git a/recipes/libpq/all/conanfile.py b/recipes/libpq/all/conanfile.py index 0aae92c197c1a..bedadf84e5a0c 100644 --- a/recipes/libpq/all/conanfile.py +++ b/recipes/libpq/all/conanfile.py @@ -3,41 +3,41 @@ import os import glob +required_conan_version = ">=1.43.0" + class LibpqConan(ConanFile): name = "libpq" description = "The library used by all the standard PostgreSQL tools." - topics = ("conan", "libpq", "postgresql", "database", "db") + topics = ("libpq", "postgresql", "database", "db") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.postgresql.org/docs/current/static/libpq.html" license = "PostgreSQL" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], - "with_zlib": [True, False], "with_openssl": [True, False], - "disable_rpath": [True, False] + "disable_rpath": [True, False], } default_options = { - 'shared': False, - 'fPIC': True, - 'with_zlib': True, - 'with_openssl': False, - 'disable_rpath': False + "shared": False, + "fPIC": True, + "with_openssl": False, + "disable_rpath": False, } + _autotools = None - def build_requirements(self): - if self.settings.compiler == "Visual Studio": - self.build_requires("strawberryperl/5.30.0.1") - elif tools.os_info.is_windows: - if "CONAN_BASH_PATH" not in os.environ and tools.os_info.detect_windows_subsystem() != 'msys2': - self.build_requires("msys2/20190524") @property def _source_subfolder(self): return "source_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + @property def _is_clang8_x86(self): return self.settings.os == "Linux" and \ @@ -45,37 +45,53 @@ def _is_clang8_x86(self): self.settings.compiler.version == "8" and \ self.settings.arch == "x86" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC del self.options.disable_rpath def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd - if self.settings.compiler != "Visual Studio" and self.settings.os == "Windows": - if self.options.shared: - raise ConanInvalidConfiguration("static mingw build is not possible") def requirements(self): - if self.options.with_zlib: - self.requires("zlib/1.2.11") if self.options.with_openssl: - self.requires("openssl/1.1.1h") + self.requires("openssl/1.1.1q") + + def validate(self): + if self.settings.os == "Windows" and self.settings.compiler == "gcc" and self.options.shared: + raise ConanInvalidConfiguration("static mingw build is not possible") + + def build_requirements(self): + if self._is_msvc: + self.build_requires("strawberryperl/5.30.0.1") + elif self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "postgresql-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], strip_root=True, + destination=self._source_subfolder) def _configure_autotools(self): if not self._autotools: self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) args = ['--without-readline'] - args.append('--with-zlib' if self.options.with_zlib else '--without-zlib') + args.append('--without-zlib') args.append('--with-openssl' if self.options.with_openssl else '--without-openssl') - if tools.cross_building(self.settings) and not self.options.with_openssl: + if tools.cross_building(self) and not self.options.with_openssl: args.append("--disable-strong-random") + if tools.cross_building(self, skip_x64_x86=True): + args.append("USE_DEV_URANDOM=1") if self.settings.os != "Windows" and self.options.disable_rpath: args.append('--disable-rpath') if self._is_clang8_x86: @@ -92,7 +108,10 @@ def _make_args(self): return args def build(self): - if self.settings.compiler == "Visual Studio": + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + if self._is_msvc: # https://www.postgresql.org/docs/8.3/install-win32-libpq.html # https://github.com/postgres/postgres/blob/master/src/tools/msvc/README if not self.options.shared: @@ -103,10 +122,18 @@ def build(self): tools.replace_in_file(os.path.join(self._source_subfolder, "src", "tools", "msvc", "Project.pm"), "libraries => [],", "libraries => [{}],".format(system_libs)) - runtime = {'MT': 'MultiThreaded', - 'MTd': 'MultiThreadedDebug', - 'MD': 'MultiThreadedDLL', - 'MDd': 'MultiThreadedDebugDLL'}.get(str(self.settings.compiler.runtime)) + if self.settings.compiler == "Visual Studio": + runtime = { + "MT": "MultiThreaded", + "MTd": "MultiThreadedDebug", + "MD": "MultiThreadedDLL", + "MDd": "MultiThreadedDebugDLL", + }.get(str(self.settings.compiler.runtime)) + else: + runtime = "MultiThreaded{}{}".format( + "Debug" if self.settings.compiler.runtime_type == "Debug" else "", + "DLL" if self.settings.compiler.runtime == "dynamic" else "", + ) msbuild_project_pm = os.path.join(self._source_subfolder, "src", "tools", "msvc", "MSBuildProject.pm") tools.replace_in_file(msbuild_project_pm, "", """ @@ -116,12 +143,6 @@ def build(self): tools.replace_in_file(msbuild_project_pm, "'MultiThreadedDLL'", "'%s'" % runtime) config_default_pl = os.path.join(self._source_subfolder, "src", "tools", "msvc", "config_default.pl") solution_pm = os.path.join(self._source_subfolder, "src", "tools", "msvc", "Solution.pm") - if self.options.with_zlib: - tools.replace_in_file(solution_pm, - "zdll.lib", "%s.lib" % self.deps_cpp_info["zlib"].libs[0]) - tools.replace_in_file(config_default_pl, - "zlib => undef", - "zlib => '%s'" % self.deps_cpp_info["zlib"].rootpath.replace("\\", "/")) if self.options.with_openssl: for ssl in ["VC\libssl32", "VC\libssl64", "libssl"]: tools.replace_in_file(solution_pm, @@ -142,6 +163,20 @@ def build(self): if not self.options.shared: self.run("perl build.pl libpgport") else: + # relocatable shared lib on macOS + tools.replace_in_file( + os.path.join(self._source_subfolder, "src", "Makefile.shlib"), + "-install_name '$(libdir)/", + "-install_name '@rpath/", + ) + # avoid SIP issues on macOS when dependencies are shared + if tools.is_apple_os(self.settings.os): + libpaths = ":".join(self.deps_cpp_info.lib_paths) + tools.replace_in_file( + os.path.join(self._source_subfolder, "configure"), + "#! /bin/sh\n", + "#! /bin/sh\nexport DYLD_LIBRARY_PATH={}:$DYLD_LIBRARY_PATH\n".format(libpaths), + ) autotools = self._configure_autotools() with tools.chdir(os.path.join(self._source_subfolder, "src", "backend")): autotools.make(args=self._make_args, target="generated-headers") @@ -177,7 +212,7 @@ def _remove_unused_libraries_from_package(self): def package(self): self.copy(pattern="COPYRIGHT", dst="licenses", src=self._source_subfolder) - if self.settings.compiler == "Visual Studio": + if self._is_msvc: self.copy("*postgres_ext.h", src=self._source_subfolder, dst="include", keep_path=False) self.copy("*pg_config.h", src=self._source_subfolder, dst="include", keep_path=False) self.copy("*pg_config_ext.h", src=self._source_subfolder, dst="include", keep_path=False) @@ -215,26 +250,29 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def _construct_library_name(self, name): - if self.settings.compiler == "Visual Studio": + if self._is_msvc: return "lib{}".format(name) return name def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "PostgreSQL") + self.cpp_info.set_property("cmake_target_name", "PostgreSQL::PostgreSQL") + self.cpp_info.set_property("pkg_config_name", "libpq") + self.cpp_info.names["cmake_find_package"] = "PostgreSQL" self.cpp_info.names["cmake_find_package_multi"] = "PostgreSQL" + self.env_info.PostgreSQL_ROOT = self.package_folder self.cpp_info.components["pq"].libs = [self._construct_library_name("pq")] - if self.options.with_zlib: - self.cpp_info.components["pq"].requires.append("zlib::zlib") - if self.options.with_openssl: self.cpp_info.components["pq"].requires.append("openssl::openssl") if not self.options.shared: - if self.settings.compiler == "Visual Studio": - if tools.Version(self.version) < '12': + if self._is_msvc: + if tools.Version(self.version) < "12": self.cpp_info.components["pgport"].libs = ["libpgport"] self.cpp_info.components["pq"].requires.extend(["pgport"]) else: @@ -242,7 +280,7 @@ def package_info(self): self.cpp_info.components["pgport"].libs = ["libpgport"] self.cpp_info.components["pq"].requires.extend(["pgport", "pgcommon"]) else: - if tools.Version(self.version) < '12': + if tools.Version(self.version) < "12": self.cpp_info.components["pgcommon"].libs = ["pgcommon"] self.cpp_info.components["pq"].requires.extend(["pgcommon"]) else: @@ -250,7 +288,7 @@ def package_info(self): self.cpp_info.components["pgport"].libs = ["pgport", "pgport_shlib"] self.cpp_info.components["pq"].requires.extend(["pgport", "pgcommon"]) - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["pq"].system_libs = ["pthread"] elif self.settings.os == "Windows": self.cpp_info.components["pq"].system_libs = ["ws2_32", "secur32", "advapi32", "shell32", "crypt32", "wldap32"] diff --git a/recipes/libpq/all/patches/13.3/001-Remove-thread-safety-check.patch b/recipes/libpq/all/patches/13.3/001-Remove-thread-safety-check.patch new file mode 100644 index 0000000000000..c650bf767f6d5 --- /dev/null +++ b/recipes/libpq/all/patches/13.3/001-Remove-thread-safety-check.patch @@ -0,0 +1,65 @@ +diff --git a/configure b/configure +index cbbaf77..f723154 100755 +--- a/configure ++++ b/configure +@@ -18836,60 +18836,6 @@ fi + fi + fi + +-# Thread testing +- +-# We have to run the thread test near the end so we have all our symbols +-# defined. Cross compiling throws a warning. +-# +-if test "$enable_thread_safety" = yes; then +-if test "$PORTNAME" != "win32" +-then +-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking thread safety of required library functions" >&5 +-$as_echo_n "checking thread safety of required library functions... " >&6; } +- +-_CFLAGS="$CFLAGS" +-_LIBS="$LIBS" +-CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE" +-LIBS="$LIBS $PTHREAD_LIBS" +-if test "$cross_compiling" = yes; then : +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: maybe" >&5 +-$as_echo "maybe" >&6; } +- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: +-*** Skipping thread test program because of cross-compile build. +-*** Run the program in src/test/thread on the target machine. +-" >&5 +-$as_echo "$as_me: WARNING: +-*** Skipping thread test program because of cross-compile build. +-*** Run the program in src/test/thread on the target machine. +-" >&2;} +-else +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-#include "$srcdir/src/test/thread/thread_test.c" +-_ACEOF +-if ac_fn_c_try_run "$LINENO"; then : +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +-$as_echo "yes" >&6; } +-else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +- as_fn_error $? "thread test program failed +-This platform is not thread-safe. Check the file 'config.log' or compile +-and run src/test/thread/thread_test for the exact reason. +-Use --disable-thread-safety to disable thread safety." "$LINENO" 5 +-fi +-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ +- conftest.$ac_objext conftest.beam conftest.$ac_ext +-fi +- +-CFLAGS="$_CFLAGS" +-LIBS="$_LIBS" +-else +-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** skipping thread test on Win32" >&5 +-$as_echo "$as_me: WARNING: *** skipping thread test on Win32" >&2;} +-fi +-fi +- + # If compiler will take -Wl,--as-needed (or various platform-specific + # spellings thereof) then add that to LDFLAGS. This is much easier than + # trying to filter LIBS to the minimum for each executable. diff --git a/recipes/libpq/all/test_package/CMakeLists.txt b/recipes/libpq/all/test_package/CMakeLists.txt index 34af13462f44f..537d802359b5d 100644 --- a/recipes/libpq/all/test_package/CMakeLists.txt +++ b/recipes/libpq/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(PostgreSQL REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PostgreSQL::PostgreSQL) diff --git a/recipes/libpq/all/test_package/conanfile.py b/recipes/libpq/all/test_package/conanfile.py index bd7165a553cf4..8a563eaeb2264 100644 --- a/recipes/libpq/all/test_package/conanfile.py +++ b/recipes/libpq/all/test_package/conanfile.py @@ -3,8 +3,17 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libpq/config.yml b/recipes/libpq/config.yml index 8b6042fb43d2a..a2b649a937afd 100644 --- a/recipes/libpq/config.yml +++ b/recipes/libpq/config.yml @@ -1,27 +1,15 @@ versions: - "13.2": + "14.5": folder: all - "13.1": + "14.2": folder: all - "13.0": + "13.6": folder: all - "12.6": + "12.10": folder: all - "12.4": + "11.15": folder: all - "12.3": + "10.20": folder: all - "12.2": - folder: all - "11.11": - folder: all - "11.9": - folder: all - "11.7": - folder: all - "11.5": - folder: all - "10.14": - folder: all - "9.6.19": + "9.6.24": folder: all diff --git a/recipes/libpqxx/all/CMakeLists.txt b/recipes/libpqxx/all/CMakeLists.txt deleted file mode 100644 index 8b8af47ecdb56..0000000000000 --- a/recipes/libpqxx/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/libpqxx/all/conandata.yml b/recipes/libpqxx/all/conandata.yml index 36897014b2b12..2c06aed5e9bb9 100644 --- a/recipes/libpqxx/all/conandata.yml +++ b/recipes/libpqxx/all/conandata.yml @@ -1,122 +1,75 @@ sources: - "7.0.1": - url: "https://github.com/jtv/libpqxx/archive/7.0.1.tar.gz" - sha256: "8c607ea4142223823ec400a3ff8f9561e8674e5888243cb7c6a610bf548ae0f0" - "7.0.2": - url: "https://github.com/jtv/libpqxx/archive/7.0.2.tar.gz" - sha256: "0e99df348623f2adaee5c79405279fb0e0182b9f4aebedb6bf007d982ab90dff" - "7.0.3": - url: "https://github.com/jtv/libpqxx/archive/7.0.3.tar.gz" - sha256: "7e28ad68cf6563246d97ccdeba5996dd71316c589f39b253f2cb2fbac0c2f7ef" - "7.0.4": - url: "https://github.com/jtv/libpqxx/archive/7.0.4.tar.gz" - sha256: "b56b441eb49755b39f0ba194b81047f7596540ee23c1caa8aa1b963f1bded9f5" - "7.0.5": - url: "https://github.com/jtv/libpqxx/archive/7.0.5.tar.gz" - sha256: "64f60d26a1ebc56fa356b9e3f18bd5b0f2ffbb0f123165ab1a5389ce0a9eeb1e" - "7.0.6": - url: "https://github.com/jtv/libpqxx/archive/7.0.6.tar.gz" - sha256: "8905377a387dfcc950fc03cc3a6c0e02825065207f20f563f0bd2a5ddfdd3bcc" - "7.0.7": - url: "https://github.com/jtv/libpqxx/archive/7.0.7.tar.gz" - sha256: "856fffb76141a236df608a86aa7d63b04f82816c9bbf80d33189705a0b2682eb" - "7.1.1": - url: "https://github.com/jtv/libpqxx/archive/7.1.1.tar.gz" - sha256: "cdf1efdc77de20e65f3affa0d4d9f819891669feb159eff8893696bf7692c00d" - "7.1.2": - url: "https://github.com/jtv/libpqxx/archive/7.1.2.tar.gz" - sha256: "3af7b4cfd572c67275ad24fea31bcf9d9f365ec16a1b7e90d4bde930936707f3" - "7.2.0": - url: "https://github.com/jtv/libpqxx/archive/7.2.0.tar.gz" - sha256: "c482a31c5d08402bc9e8df8291bed3555640ea80b3cb354fca958b1b469870dd" + "7.7.4": + url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.7.4.tar.gz" + sha256: "65b0a06fffd565a19edacedada1dcfa0c1ecd782cead0ee067b19e2464875c36" + "7.7.3": + url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.7.3.tar.gz" + sha256: "11e147bbe2d3024d68d29b38eab5d75899dbb6131e421a2dbf9f88bac9bf4b0d" + "7.7.2": + url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.7.2.tar.gz" + sha256: "4b7a0b67cbd75d1c31e1e8a07c942ffbe9eec4e32c29b15d71cc225dc737e243" + "7.7.0": + url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.7.0.tar.gz" + sha256: "2d99de960aa3016915bc69326b369fcee04425e57fbe9dad48dd3fa6203879fb" + "7.6.1": + url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.6.1.tar.gz" + sha256: "7f4ad37fce20e8c9a61387cd5d6f85cf264f2bc9c0e6b27e8d5751a5429f87d0" + "7.6.0": + url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.6.0.tar.gz" + sha256: "8194ce4eff3fee5325963ccc28d3542cfaa54ba1400833d0df6948de3573c118" + "7.5.3": + url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.5.3.tar.gz" + sha256: "4229ed9205e484a4bafb10edd6ce75b98c12d63c082a98baada0c01766d218e0" + "7.4.2": + url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.4.2.tar.gz" + sha256: "325d50c51a417e890f7d71805f90a8d7949dce659f721b0f15d7f91bf954091d" + "7.3.2": + url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.3.2.tar.gz" + sha256: "493991345de5cbddfed8836917a333add2cd00ecbfd21b1acbc9345ce784225f" "7.2.1": url: "https://github.com/jtv/libpqxx/archive/7.2.1.tar.gz" sha256: "3fd8318d2e421483495bf1a8ea1365fce4105934e9600ca87be0dff470d8c8dc" - "7.3.0": - url: "https://github.com/jtv/libpqxx/archive/7.3.0.tar.gz" - sha256: "55563821727310828cd79737732ca7e14a49dbbaa86bdce7c5829d440dafde59" - "7.3.1": - url: "https://github.com/jtv/libpqxx/archive/7.3.1.tar.gz" - sha256: "c794e7e5c4f1ef078463ecafe747a6508a0272d83b32a8cdcfb84bb37218a78b" - "7.4.0": - url: "https://github.com/jtv/libpqxx/archive/7.4.0.tar.gz" - sha256: "930e95d0c709905f9d842081cd33b5226f5803ed1fc6ef5b6e3b131ddaeddecb" - "7.4.1": - url: "https://github.com/jtv/libpqxx/archive/7.4.1.tar.gz" - sha256: "73b2f0a0af786d6039291b60250bee577bc7ea7c10b7550ec37da448940848b7" - "7.5.0": - url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.5.0.tar.gz" - sha256: "62744ddba939880675f1e76275c98c1653f60b0e725f013299f4a437351bf2b0" - "7.5.1": - url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.5.1.tar.gz" - sha256: "16a3a4097a6772a9824ba584dbe5a1feee163ab954b94497358fe591eb236e3d" - "7.5.2": - url: "https://github.com/jtv/libpqxx/archive/refs/tags/7.5.2.tar.gz" - sha256: "62e140667fb1bc9b61fa01cbf46f8ff73236eba6f3f7fbcf98108ce6bbc18dcd" + "7.1.2": + url: "https://github.com/jtv/libpqxx/archive/7.1.2.tar.gz" + sha256: "3af7b4cfd572c67275ad24fea31bcf9d9f365ec16a1b7e90d4bde930936707f3" + "7.0.7": + url: "https://github.com/jtv/libpqxx/archive/7.0.7.tar.gz" + sha256: "856fffb76141a236df608a86aa7d63b04f82816c9bbf80d33189705a0b2682eb" + "6.4.8": + url: "https://github.com/jtv/libpqxx/archive/6.4.8.tar.gz" + sha256: "3f7aba951822e01f1b9f9f353702954773323dd9f9dc376ffb57cb6bbd9a7a2f" patches: - "7.0.1": + "7.7.4": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix-missing-limits-include.patch" - base_path: "source_subfolder" - "7.0.2": + "7.7.3": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix-missing-limits-include.patch" - base_path: "source_subfolder" - "7.0.3": + "7.7.2": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix-missing-limits-include.patch" - base_path: "source_subfolder" - "7.0.4": + - patch_file: "patches/fix-install-library-symlink-7.7.2.patch" + "7.7.0": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix-missing-limits-include.patch" - base_path: "source_subfolder" - "7.0.5": + - patch_file: "patches/fix-clang-compilation-7.7.0.patch" + "7.6.1": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.0.6": + - patch_file: "patches/fix-inline-constexpr-local-variable-problem-7.6.0.patch" + - patch_file: "patches/fix-remove-unlikely-annotation-before-return-7.6.0_to_7.6.1.patch" + "7.6.0": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.0.7": - - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.1.1": - - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.1.2": - - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.2.0": - - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.2.1": + - patch_file: "patches/fix-inline-constexpr-local-variable-problem-7.6.0.patch" + - patch_file: "patches/fix-remove-unlikely-annotation-before-return-7.6.0_to_7.6.1.patch" + "7.5.3": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.3.0": + "7.4.2": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.3.1": + "7.3.2": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - patch_file: "patches/fix-msvc-compilation-7.3.1.patch" - base_path: "source_subfolder" - "7.4.0": - - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix-apple-clang-compilation-7.4.0.patch" - base_path: "source_subfolder" - "7.4.1": - - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.5.0": + "7.2.1": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.5.1": + "7.1.2": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - "7.5.2": + "7.0.7": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" + - patch_file: "patches/fix-not-declared-dumb_stringstream-7.0.6_to_7.0.7.patch" + "6.4.8": + - patch_file: "patches/0001-cmake-fix-module-6.4.8.patch" diff --git a/recipes/libpqxx/all/conanfile.py b/recipes/libpqxx/all/conanfile.py index 82866caf32c26..ef9bfe326bc0a 100644 --- a/recipes/libpqxx/all/conanfile.py +++ b/recipes/libpqxx/all/conanfile.py @@ -1,31 +1,58 @@ -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration -from conans.tools import Version +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.microsoft import check_min_vs, is_msvc, msvc_runtime_flag +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout import os +required_conan_version = ">=1.53.0" -class LibpqxxRecipe(ConanFile): +class LibpqxxConan(ConanFile): name = "libpqxx" - settings = "os", "compiler", "build_type", "arch" description = "The official C++ client API for PostgreSQL" + license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/jtv/libpqxx" - license = "BSD-3-Clause" - topics = ("conan", "libpqxx", "postgres", "postgresql", "database", "db") - generators = "cmake", "cmake_find_package" - exports_sources = ["CMakeLists.txt", "patches/*"] - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + topics = ("libpqxx", "postgres", "postgresql", "database", "db") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - _cmake = None + @property + def _min_cppstd(self): + return 14 if Version(self.version) < "7.0" else "17" @property - def _source_subfolder(self): - return "source_subfolder" + def _compilers_minimum_version(self): + if Version(self.version) < "7.0": + return { + "gcc": "7", + "clang": "6", + "apple-clang": "10" + } + else: + return { + "gcc": "7" if Version(self.version) < "7.5.0" else "8", + "clang": "6", + "apple-clang": "10" + } @property - def _build_subfolder(self): - return "build_subfolder" + def _mac_os_minimum_required_version(self): + return "10.15" + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -33,66 +60,84 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - - compiler = str(self.settings.compiler) - compiler_version = Version(self.settings.compiler.version.value) - - minimal_version = { - "Visual Studio": "15", - "gcc": "7", - "clang": "6", - "apple-clang": "10" - } - - if compiler in minimal_version and \ - compiler_version < minimal_version[compiler]: - raise ConanInvalidConfiguration("%s requires a compiler that supports" - " at least C++17. %s %s is not" - " supported." % (self.name, compiler, compiler_version)) + self.options.rm_safe("fPIC") - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, "17") + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("libpq/12.2") + self.requires("libpq/14.5") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + if Version(self.version) < "7.0": + check_min_vs(self, 190) + elif Version(self.version) < "7.6": + check_min_vs(self, 191) + else: + check_min_vs(self, 192) + + if is_msvc(self) and self.options.shared and msvc_runtime_flag(self) == "MTd": + raise ConanInvalidConfiguration(f"{self.ref} recipes does not support build shared library with MTd runtime.") + + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + if is_apple_os(self): + os_version = self.settings.get_safe("os.version") + if os_version and Version(os_version) < self._mac_os_minimum_required_version: + raise ConanInvalidConfiguration( + "Macos Mojave (10.14) and earlier cannot to be built because C++ standard library too old.") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["BUILD_DOC"] = False - self._cmake.definitions["BUILD_TEST"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def _patch_files(self): - if self.version in self.conan_data["patches"]: - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - def build(self): - self._patch_files() + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_DOC"] = False + tc.variables["BUILD_TEST"] = False + # Set `-mmacosx-version-min` to enable C++17 standard library support. + tc.variables["CMAKE_OSX_DEPLOYMENT_TARGET"] = self._mac_os_minimum_required_version + tc.generate() + + deps = CMakeDeps(self) + deps.generate() - cmake = self._configure_cmake() + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) + copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "libpqxx") + self.cpp_info.set_property("cmake_target_name", "libpqxx::pqxx") + self.cpp_info.set_property("pkg_config_name", "libpqxx") + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed self.cpp_info.components["pqxx"].libs = ["pqxx"] - self.cpp_info.components["pqxx"].requires = ["libpq::libpq"] if self.settings.os == "Windows": self.cpp_info.components["pqxx"].system_libs = ["wsock32", "ws2_32"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["pqxx"].set_property("cmake_target_name", "libpqxx::pqxx") + self.cpp_info.components["pqxx"].set_property("pkg_config_name", "libpqxx") + self.cpp_info.components["pqxx"].requires = ["libpq::libpq"] diff --git a/recipes/libpqxx/all/patches/0001-cmake-fix-module-6.4.8.patch b/recipes/libpqxx/all/patches/0001-cmake-fix-module-6.4.8.patch new file mode 100644 index 0000000000000..5d0c9b14d2933 --- /dev/null +++ b/recipes/libpqxx/all/patches/0001-cmake-fix-module-6.4.8.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 86ffa24..e35824b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -10,7 +10,8 @@ if(NOT "${CMAKE_CXX_STANDARD}") + endif() + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) ++list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) ++ + + if(NOT SKIP_BUILD_TEST) + option(BUILD_TEST "Build all test cases" ON) diff --git a/recipes/libpqxx/all/patches/fix-clang-compilation-7.7.0.patch b/recipes/libpqxx/all/patches/fix-clang-compilation-7.7.0.patch new file mode 100644 index 0000000000000..ad9d3eeea1da7 --- /dev/null +++ b/recipes/libpqxx/all/patches/fix-clang-compilation-7.7.0.patch @@ -0,0 +1,25 @@ +Fix clang compile error 7.7.0 (https://github.com/jtv/libpqxx/pull/519) +diff --git a/src/strconv.cxx b/src/strconv.cxx +index 36758307..824d0d28 100644 +--- a/src/strconv.cxx ++++ b/src/strconv.cxx +@@ -438,7 +438,8 @@ template + if (pqxx::internal::is_digit(initial)) + { + for (; pqxx::internal::is_digit(data[i]); ++i) +- result = absorb_digit_positive(result, digit_to_number(data[i])); ++ result = absorb_digit_positive( ++ result, pqxx::internal::digit_to_number(data[i])); + } + else if (initial == '-') + { +@@ -452,7 +453,8 @@ template + "Converting string to " + pqxx::type_name + + ", but it contains only a sign."}; + for (; i < std::size(text) and pqxx::internal::is_digit(data[i]); ++i) +- result = absorb_digit_negative(result, digit_to_number(data[i])); ++ result = absorb_digit_negative( ++ result, pqxx::internal::digit_to_number(data[i])); + } + else + { diff --git a/recipes/libpqxx/all/patches/fix-inline-constexpr-local-variable-problem-7.6.0.patch b/recipes/libpqxx/all/patches/fix-inline-constexpr-local-variable-problem-7.6.0.patch new file mode 100644 index 0000000000000..f2f3dcc4c078a --- /dev/null +++ b/recipes/libpqxx/all/patches/fix-inline-constexpr-local-variable-problem-7.6.0.patch @@ -0,0 +1,50 @@ +Fixed a problem that some compilers did not allow `inline constexpr` local +variable declarations (https://github.com/jtv/libpqxx/pull/468). +diff --git a/src/strconv.cxx b/src/strconv.cxx +index 57188dee..0eba014b 100644 +--- a/src/strconv.cxx ++++ b/src/strconv.cxx +@@ -317,6 +317,20 @@ namespace + "Could not convert string to integer: value out of range."}; + } + ++template struct numeric_ten ++{ ++ static inline constexpr T value = 10; ++}; ++ ++template struct numeric_high_threshold ++{ ++ static inline constexpr T value = (std::numeric_limits::max)() / numeric_ten::value; ++}; ++ ++template struct numeric_low_threshold ++{ ++ static inline constexpr T value = (std::numeric_limits::min)() / numeric_ten::value; ++}; + + /// Return 10*n, or throw exception if it overflows. + template +@@ -324,19 +338,16 @@ template + { + using limits = std::numeric_limits; + +- inline constexpr T ten{10}; +- inline constexpr T high_threshold(std::numeric_limits::max() / ten); +- if (n > high_threshold) ++ if (n > numeric_high_threshold::value) + PQXX_UNLIKELY + report_overflow(); + if constexpr (limits::is_signed) + { +- inline constexpr T low_threshold(std::numeric_limits::min() / ten); +- if (low_threshold > n) ++ if (numeric_low_threshold::value > n) + PQXX_UNLIKELY + report_overflow(); + } +- return T(n * ten); ++ return T(n * numeric_ten::value); + } + + diff --git a/recipes/libpqxx/all/patches/fix-install-library-symlink-7.7.2.patch b/recipes/libpqxx/all/patches/fix-install-library-symlink-7.7.2.patch new file mode 100644 index 0000000000000..076ad6cc874e3 --- /dev/null +++ b/recipes/libpqxx/all/patches/fix-install-library-symlink-7.7.2.patch @@ -0,0 +1,14 @@ +Fix install library symlink error 7.7.2 (https://github.com/jtv/libpqxx/pull/552) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 6eafd7b3..1d697ab7 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -58,7 +58,7 @@ macro(library_target_setup tgt) + VERBATIM + COMMAND_EXPAND_LISTS + ) +- install(FILES $/${library_prefix}${name}${library_suffix} ++ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${library_prefix}${name}${library_suffix} + DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + endif() diff --git a/recipes/libpqxx/all/patches/fix-not-declared-dumb_stringstream-7.0.1_to_7.0.5.patch b/recipes/libpqxx/all/patches/fix-not-declared-dumb_stringstream-7.0.1_to_7.0.5.patch new file mode 100644 index 0000000000000..c32258155f947 --- /dev/null +++ b/recipes/libpqxx/all/patches/fix-not-declared-dumb_stringstream-7.0.1_to_7.0.5.patch @@ -0,0 +1,21 @@ +Fix 'dumb_stringstream' was not declared (https://github.com/jtv/libpqxx/commit/0e81d36f522093d7215b3792f1c62dcd06a34ad1) +diff --git a/src/strconv.cxx b/src/strconv.cxx +index 66276802..390192ac 100644 +--- a/src/strconv.cxx ++++ b/src/strconv.cxx +@@ -587,6 +587,7 @@ template char * + float_traits::into_buf(char *, char *, long double const &); + + ++#if !defined(PQXX_HAVE_CHARCONV_FLOAT) + template + inline std::string to_dumb_stringstream(dumb_stringstream &s, F value) + { +@@ -594,6 +595,7 @@ inline std::string to_dumb_stringstream(dumb_stringstream &s, F value) + s << value; + return s.str(); + } ++#endif + + + /// Floating-point implementations for @c pqxx::to_string(). diff --git a/recipes/libpqxx/all/patches/fix-not-declared-dumb_stringstream-7.0.6_to_7.0.7.patch b/recipes/libpqxx/all/patches/fix-not-declared-dumb_stringstream-7.0.6_to_7.0.7.patch new file mode 100644 index 0000000000000..e372b90444861 --- /dev/null +++ b/recipes/libpqxx/all/patches/fix-not-declared-dumb_stringstream-7.0.6_to_7.0.7.patch @@ -0,0 +1,21 @@ +Fix 'dumb_stringstream' was not declared (https://github.com/jtv/libpqxx/commit/0e81d36f522093d7215b3792f1c62dcd06a34ad1) +diff --git a/src/strconv.cxx b/src/strconv.cxx +index 72217455..b34bd394 100644 +--- a/src/strconv.cxx ++++ b/src/strconv.cxx +@@ -591,6 +591,7 @@ template char * + float_traits::into_buf(char *, char *, long double const &); + + ++#if !defined(PQXX_HAVE_CHARCONV_FLOAT) + template + inline std::string to_dumb_stringstream(dumb_stringstream &s, F value) + { +@@ -598,6 +599,7 @@ inline std::string to_dumb_stringstream(dumb_stringstream &s, F value) + s << value; + return s.str(); + } ++#endif + + + /// Floating-point implementations for @c pqxx::to_string(). diff --git a/recipes/libpqxx/all/patches/fix-not-declared-dumb_stringstream-7.1.1.patch b/recipes/libpqxx/all/patches/fix-not-declared-dumb_stringstream-7.1.1.patch new file mode 100644 index 0000000000000..acc981628428c --- /dev/null +++ b/recipes/libpqxx/all/patches/fix-not-declared-dumb_stringstream-7.1.1.patch @@ -0,0 +1,21 @@ +Fix 'dumb_stringstream' was not declared (https://github.com/jtv/libpqxx/commit/0e81d36f522093d7215b3792f1c62dcd06a34ad1) +diff --git a/src/strconv.cxx b/src/strconv.cxx +index 13b0b9ab..c0b7510d 100644 +--- a/src/strconv.cxx ++++ b/src/strconv.cxx +@@ -591,6 +591,7 @@ template char * + float_traits::into_buf(char *, char *, long double const &); + + ++#if !defined(PQXX_HAVE_CHARCONV_FLOAT) + template + inline std::string to_dumb_stringstream(dumb_stringstream &s, F value) + { +@@ -598,6 +599,7 @@ inline std::string to_dumb_stringstream(dumb_stringstream &s, F value) + s << value; + return s.str(); + } ++#endif + + + /// Floating-point implementations for @c pqxx::to_string(). diff --git a/recipes/libpqxx/all/patches/fix-remove-unlikely-annotation-before-return-7.6.0_to_7.6.1.patch b/recipes/libpqxx/all/patches/fix-remove-unlikely-annotation-before-return-7.6.0_to_7.6.1.patch new file mode 100644 index 0000000000000..697450d9e37a2 --- /dev/null +++ b/recipes/libpqxx/all/patches/fix-remove-unlikely-annotation-before-return-7.6.0_to_7.6.1.patch @@ -0,0 +1,13 @@ +fix: Remove `unlikely` annotation before `return` (https://github.com/jtv/libpqxx/pull/476) +diff --git a/src/robusttransaction.cxx b/src/robusttransaction.cxx +index ba110b12..88d8bd32 100644 +--- a/src/robusttransaction.cxx ++++ b/src/robusttransaction.cxx +@@ -64,7 +64,6 @@ constexpr tx_stat parse_status(std::string_view text) noexcept + PQXX_LIKELY return tx_in_progress; + break; + } +- PQXX_UNLIKELY + return tx_unknown; + } + diff --git a/recipes/libpqxx/all/test_package/CMakeLists.txt b/recipes/libpqxx/all/test_package/CMakeLists.txt index aba3a2b30a64b..e27c585fd702f 100644 --- a/recipes/libpqxx/all/test_package/CMakeLists.txt +++ b/recipes/libpqxx/all/test_package/CMakeLists.txt @@ -1,15 +1,17 @@ cmake_minimum_required(VERSION 3.8) -project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +# Set `-mmacosx-version-min` to enable C++17 standard library support. +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") + +project(test_package LANGUAGES CXX) find_package(libpqxx REQUIRED CONFIG) + add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} libpqxx::pqxx) -set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED ON - CXX_EXTENSIONS OFF -) +target_link_libraries(${PROJECT_NAME} PRIVATE libpqxx::pqxx) +if(libpqxx_VERSION VERSION_LESS "7.0") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +endif() diff --git a/recipes/libpqxx/all/test_package/conanfile.py b/recipes/libpqxx/all/test_package/conanfile.py index 7e2dfe859bb27..a9fbb7f543162 100644 --- a/recipes/libpqxx/all/test_package/conanfile.py +++ b/recipes/libpqxx/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os - class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libpqxx/all/test_v1_package/CMakeLists.txt b/recipes/libpqxx/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/libpqxx/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libpqxx/all/test_v1_package/conanfile.py b/recipes/libpqxx/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..20d4d2e28d57e --- /dev/null +++ b/recipes/libpqxx/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libpqxx/config.yml b/recipes/libpqxx/config.yml index 8ca8c687db575..386cd99b2403f 100644 --- a/recipes/libpqxx/config.yml +++ b/recipes/libpqxx/config.yml @@ -1,37 +1,27 @@ versions: - "7.0.1": + "7.7.4": folder: all - "7.0.2": + "7.7.3": folder: all - "7.0.3": + "7.7.2": folder: all - "7.0.4": + "7.7.0": folder: all - "7.0.5": + "7.6.1": folder: all - "7.0.6": + "7.6.0": folder: all - "7.0.7": - folder: all - "7.1.1": + "7.5.3": folder: all - "7.1.2": + "7.4.2": folder: all - "7.2.0": + "7.3.2": folder: all "7.2.1": folder: all - "7.3.0": - folder: all - "7.3.1": - folder: all - "7.4.0": - folder: all - "7.4.1": - folder: all - "7.5.0": + "7.1.2": folder: all - "7.5.1": + "7.0.7": folder: all - "7.5.2": + "6.4.8": folder: all diff --git a/recipes/mongo-c-driver/all/CMakeLists.txt b/recipes/libprotobuf-mutator/all/CMakeLists.txt similarity index 100% rename from recipes/mongo-c-driver/all/CMakeLists.txt rename to recipes/libprotobuf-mutator/all/CMakeLists.txt diff --git a/recipes/libprotobuf-mutator/all/conandata.yml b/recipes/libprotobuf-mutator/all/conandata.yml new file mode 100644 index 0000000000000..813688d3f74a5 --- /dev/null +++ b/recipes/libprotobuf-mutator/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20210831": + url: "https://github.com/google/libprotobuf-mutator/archive/ffd86a32874e5c08a143019aad1aaf0907294c9f.zip" + sha256: "14f595863452808483776ce1964209db00cdac79e649b31eb4d4b06ca72912d8" diff --git a/recipes/libprotobuf-mutator/all/conanfile.py b/recipes/libprotobuf-mutator/all/conanfile.py new file mode 100644 index 0000000000000..f0419a2397845 --- /dev/null +++ b/recipes/libprotobuf-mutator/all/conanfile.py @@ -0,0 +1,88 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + + +class LibProtobufMutatorConan(ConanFile): + name = "libprotobuf-mutator" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/google/libprotobuf-mutator" + description = "A library to randomly mutate protobuffers." + topics = ("test", "fuzzing", "protobuf") + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + exports_sources = ["CMakeLists.txt"] + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def requirements(self): + self.requires("protobuf/3.17.1") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def validate(self): + if self.settings.compiler != "clang": + raise ConanInvalidConfiguration("Only clang allowed") + if self.settings.compiler.libcxx != "libstdc++11": + raise ConanInvalidConfiguration("Requires either compiler.libcxx=libstdc++11") + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, 11) + + def _patch_sources(self): + tools.replace_in_file( + os.path.join(self._source_subfolder, 'CMakeLists.txt'), + """include_directories(${PROTOBUF_INCLUDE_DIRS})""", + """include_directories(${protobuf_INCLUDE_DIRS})""") + tools.replace_in_file( + os.path.join(self._source_subfolder, 'CMakeLists.txt'), + """set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/external)""", + """# (disabled by conan) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/external)""") + tools.replace_in_file( + os.path.join(self._source_subfolder, 'CMakeLists.txt'), + """add_subdirectory(examples EXCLUDE_FROM_ALL)""", + """# (disabled by conan) add_subdirectory(examples EXCLUDE_FROM_ALL)""") + + def _configure_cmake(self): + if self._cmake: + return self._cmake + + self._cmake = CMake(self) + self._cmake.definitions["LIB_PROTO_MUTATOR_TESTING"] = "OFF" + self._cmake.definitions["LIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF"] = "OFF" + self._cmake.definitions["LIB_PROTO_MUTATOR_WITH_ASAN"] = "OFF" + self._cmake.definitions["LIB_PROTO_MUTATOR_FUZZER_LIBRARIES"] = "" + # todo: check option(LIB_PROTO_MUTATOR_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON) + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "OFF")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "libprotobuf-mutator" + self.cpp_info.names["cmake_find_package_multi"] = "libprotobuf-mutator" + + self.cpp_info.libs = ['protobuf-mutator-libfuzzer', 'protobuf-mutator'] + self.cpp_info.includedirs.append(os.path.join("include", "libprotobuf-mutator")) diff --git a/recipes/libprotobuf-mutator/all/test_package/CMakeLists.txt b/recipes/libprotobuf-mutator/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..00520b9489805 --- /dev/null +++ b/recipes/libprotobuf-mutator/all/test_package/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) +find_package(libprotobuf-mutator REQUIRED CONFIG) + + +protobuf_generate_cpp( + MSG_PROTO_SRCS + MSG_PROTO_HDRS + msg.proto +) + + +add_executable(${PROJECT_NAME} ${MSG_PROTO_SRCS} test_package.cpp) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(${PROJECT_NAME} libprotobuf-mutator::libprotobuf-mutator) diff --git a/recipes/libprotobuf-mutator/all/test_package/conanfile.py b/recipes/libprotobuf-mutator/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libprotobuf-mutator/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libprotobuf-mutator/all/test_package/msg.proto b/recipes/libprotobuf-mutator/all/test_package/msg.proto new file mode 100644 index 0000000000000..cb25c9d008352 --- /dev/null +++ b/recipes/libprotobuf-mutator/all/test_package/msg.proto @@ -0,0 +1,11 @@ +syntax = "proto2"; +package libfuzzer_example; + +import "google/protobuf/any.proto"; + +message Msg { + optional float optional_float = 1; + optional uint64 optional_uint64 = 2; + optional string optional_string = 3; + optional google.protobuf.Any any = 4; +} diff --git a/recipes/libprotobuf-mutator/all/test_package/test_package.cpp b/recipes/libprotobuf-mutator/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..c169f66031176 --- /dev/null +++ b/recipes/libprotobuf-mutator/all/test_package/test_package.cpp @@ -0,0 +1,23 @@ +#include +#include + +#include "msg.pb.h" +#include + +DEFINE_PROTO_FUZZER(const libfuzzer_example::Msg& message) { + protobuf_mutator::protobuf::FileDescriptorProto file; + + // Emulate a bug. + if (message.optional_uint64() == std::hash{}(message.optional_string()) && + message.optional_string() == "abcdefghijklmnopqrstuvwxyz" && + !std::isnan(message.optional_float()) && + std::fabs(message.optional_float()) > 1000 && + message.any().UnpackTo(&file) && !file.name().empty()) + { + std::cerr << message.DebugString() << "\n"; + } +} + +int main() { + return 0; +} diff --git a/recipes/libprotobuf-mutator/config.yml b/recipes/libprotobuf-mutator/config.yml new file mode 100644 index 0000000000000..9d5b0e4c50569 --- /dev/null +++ b/recipes/libprotobuf-mutator/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210831": + folder: all diff --git a/recipes/libqrencode/all/CMakeLists.txt b/recipes/libqrencode/all/CMakeLists.txt deleted file mode 100644 index a69305eb3971f..0000000000000 --- a/recipes/libqrencode/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/libqrencode/all/conandata.yml b/recipes/libqrencode/all/conandata.yml index 88c7262ccccf5..7df4f866c6a55 100644 --- a/recipes/libqrencode/all/conandata.yml +++ b/recipes/libqrencode/all/conandata.yml @@ -1,16 +1,13 @@ sources: - "4.0.0": - url: "https://github.com/fukuchi/libqrencode/archive/v4.0.0.tar.gz" - sha256: "c2c8a8110354463a3332cb48abf8581c8d94136af4dc1418f891cc9c7719e3c1" "4.1.1": url: "https://github.com/fukuchi/libqrencode/archive/v4.1.1.tar.gz" sha256: "5385bc1b8c2f20f3b91d258bf8ccc8cf62023935df2d2676b5b67049f31a049c" -patches: "4.0.0": - - base_path: "source_subfolder" - patch_file: "patches/0001-remove-deprecated-attribute.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-cmake-fix-install.patch" + url: "https://github.com/fukuchi/libqrencode/archive/v4.0.0.tar.gz" + sha256: "c2c8a8110354463a3332cb48abf8581c8d94136af4dc1418f891cc9c7719e3c1" +patches: "4.1.1": - - base_path: "source_subfolder" - patch_file: "patches/0003-cmake-fix-install-4.1.1.patch" + - patch_file: "patches/0003-cmake-fix-install-4.1.1.patch" + "4.0.0": + - patch_file: "patches/0001-remove-deprecated-attribute.patch" + - patch_file: "patches/0002-cmake-fix-install.patch" diff --git a/recipes/libqrencode/all/conanfile.py b/recipes/libqrencode/all/conanfile.py index 4c5bc357faaf7..04ae81a7d1841 100644 --- a/recipes/libqrencode/all/conanfile.py +++ b/recipes/libqrencode/all/conanfile.py @@ -1,5 +1,10 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file, rmdir +from conan.tools.microsoft import is_msvc import os -from conans import CMake, ConanFile, tools + +required_conan_version = ">=1.50.0" class LibqrencodeConan(ConanFile): @@ -8,9 +13,8 @@ class LibqrencodeConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/fukuchi/libqrencode" license = "LGPL-2.1-or-later" - topics = ("conan", "graphics") - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake", "cmake_find_package" + topics = ("qr-code", "encoding") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -20,18 +24,10 @@ class LibqrencodeConan(ConanFile): "shared": False, "fPIC": True, } - requires = ( - "libiconv/1.15", - "libpng/1.6.37", - ) - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -40,39 +36,53 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libqrencode-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["WITH_TOOLS"] = False - cmake.definitions["WITH_TESTS"] = False - cmake.configure(build_folder=self._build_subfolder) - return cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_TOOLS"] = False + tc.variables["WITH_TESTS"] = False + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + apply_conandata_patches(self) + # libpng is required by tools only & libiconv is not used at all + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + replace_in_file(self, cmakelists, "find_package(PNG)", "") + replace_in_file(self, cmakelists, "find_package(Iconv)", "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - lib = "qrencode" - if self.settings.compiler == "Visual Studio" and self.settings.build_type == "Debug": - lib += "d" - self.cpp_info.libs = [lib] + self.cpp_info.set_property("pkg_config_name", "libqrencode") + suffix = "d" if is_msvc(self) and self.settings.build_type == "Debug" else "" + self.cpp_info.libs = [f"qrencode{suffix}"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/libqrencode/all/test_package/CMakeLists.txt b/recipes/libqrencode/all/test_package/CMakeLists.txt index 7a6c01e1893ef..dcb9df3c597be 100644 --- a/recipes/libqrencode/all/test_package/CMakeLists.txt +++ b/recipes/libqrencode/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libqrencode REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp genqr.h genqr.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libqrencode::libqrencode) diff --git a/recipes/libqrencode/all/test_package/conanfile.py b/recipes/libqrencode/all/test_package/conanfile.py index bd7165a553cf4..d120a992c06a6 100644 --- a/recipes/libqrencode/all/test_package/conanfile.py +++ b/recipes/libqrencode/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libqrencode/all/test_package/genqr.c b/recipes/libqrencode/all/test_package/genqr.c deleted file mode 100644 index 9eafafa23ad5f..0000000000000 --- a/recipes/libqrencode/all/test_package/genqr.c +++ /dev/null @@ -1,265 +0,0 @@ -#include -#include -#include -#include - -#include "png.h" -#include "qrencode.h" -#include "genqr.h" - -#define INCHES_PER_METER (100.0/2.54) - -enum imageType { - PNG_TYPE, - PNG32_TYPE, -}; - -static int casesensitive = 1; -static int eightbit = 0; -static int version = 0; -static int size = 10; -static int margin = 1; -static int dpi = 96; -static int structured = 0; -static int rle = 0; -static int svg_path = 0; -static int micro = 0; -static QRecLevel level = QR_ECLEVEL_L; -static QRencodeMode hint = QR_MODE_8; -static unsigned char fg_color[4] = { 0, 0, 0, 255 }; -static unsigned char bg_color[4] = { 255, 255, 255, 255 }; - -static int verbose = 0; -static void fillRow(unsigned char *row, int num, const unsigned char color[]) -{ - int i; - - for (i = 0; i < num; i++) { - memcpy(row, color, 4); - row += 4; - } -} - -static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType type) -{ - static FILE *fp; // avoid clobbering by setjmp. - png_structp png_ptr; - png_infop info_ptr; - png_colorp palette = NULL; - png_byte alpha_values[2]; - unsigned char *row, *p, *q; - int x, y, xx, yy, bit; - int realwidth; - - realwidth = (qrcode->width + margin * 2) * size; - if (type == PNG_TYPE) { - row = (unsigned char *)malloc((realwidth + 7) / 8); - } - else if (type == PNG32_TYPE) { - row = (unsigned char *)malloc(realwidth * 4); - } - else { - fprintf(stderr, "Internal error.\n"); - return 1; - } - if (row == NULL) { - fprintf(stderr, "Failed to allocate memory.\n"); - return 1; - } - - if (outfile[0] == '-' && outfile[1] == '\0') { - fp = stdout; - } - else { - fp = fopen(outfile, "wb"); - if (fp == NULL) { - fprintf(stderr, "Failed to create file: %s\n", outfile); - perror(NULL); - return 1; - } - } - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (png_ptr == NULL) { - fprintf(stderr, "Failed to initialize PNG writer.\n"); - return 1; - } - - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) { - fprintf(stderr, "Failed to initialize PNG write.\n"); - return 1; - } - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_write_struct(&png_ptr, &info_ptr); - fprintf(stderr, "Failed to write PNG image.\n"); - return 1; - } - - if (type == PNG_TYPE) { - palette = (png_colorp)malloc(sizeof(png_color) * 2); - if (palette == NULL) { - fprintf(stderr, "Failed to allocate memory.\n"); - return 1; - } - palette[0].red = fg_color[0]; - palette[0].green = fg_color[1]; - palette[0].blue = fg_color[2]; - palette[1].red = bg_color[0]; - palette[1].green = bg_color[1]; - palette[1].blue = bg_color[2]; - alpha_values[0] = fg_color[3]; - alpha_values[1] = bg_color[3]; - png_set_PLTE(png_ptr, info_ptr, palette, 2); - png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL); - } - - png_init_io(png_ptr, fp); - if (type == PNG_TYPE) { - png_set_IHDR(png_ptr, info_ptr, - realwidth, realwidth, - 1, - PNG_COLOR_TYPE_PALETTE, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); - } - else { - png_set_IHDR(png_ptr, info_ptr, - realwidth, realwidth, - 8, - PNG_COLOR_TYPE_RGB_ALPHA, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); - } - png_set_pHYs(png_ptr, info_ptr, - dpi * INCHES_PER_METER, - dpi * INCHES_PER_METER, - PNG_RESOLUTION_METER); - png_write_info(png_ptr, info_ptr); - - if (type == PNG_TYPE) { - /* top margin */ - memset(row, 0xff, (realwidth + 7) / 8); - for (y = 0; y < margin * size; y++) { - png_write_row(png_ptr, row); - } - - /* data */ - p = qrcode->data; - for (y = 0; y < qrcode->width; y++) { - memset(row, 0xff, (realwidth + 7) / 8); - q = row; - q += margin * size / 8; - bit = 7 - (margin * size % 8); - for (x = 0; x < qrcode->width; x++) { - for (xx = 0; xx < size; xx++) { - *q ^= (*p & 1) << bit; - bit--; - if (bit < 0) { - q++; - bit = 7; - } - } - p++; - } - for (yy = 0; yy < size; yy++) { - png_write_row(png_ptr, row); - } - } - /* bottom margin */ - memset(row, 0xff, (realwidth + 7) / 8); - for (y = 0; y < margin * size; y++) { - png_write_row(png_ptr, row); - } - } - else { - /* top margin */ - fillRow(row, realwidth, bg_color); - for (y = 0; y < margin * size; y++) { - png_write_row(png_ptr, row); - } - - /* data */ - p = qrcode->data; - for (y = 0; y < qrcode->width; y++) { - fillRow(row, realwidth, bg_color); - for (x = 0; x < qrcode->width; x++) { - for (xx = 0; xx < size; xx++) { - if (*p & 1) { - memcpy(&row[((margin + x) * size + xx) * 4], fg_color, 4); - } - } - p++; - } - for (yy = 0; yy < size; yy++) { - png_write_row(png_ptr, row); - } - } - /* bottom margin */ - fillRow(row, realwidth, bg_color); - for (y = 0; y < margin * size; y++) { - png_write_row(png_ptr, row); - } - } - - png_write_end(png_ptr, info_ptr); - png_destroy_write_struct(&png_ptr, &info_ptr); - - fclose(fp); - free(row); - free(palette); - - return 0; -} - -static QRcode *encode(const char *intext) -{ - QRcode *code; - - code = QRcode_encodeString(intext, version, level, hint, casesensitive); - - return code; -} - - -static int qrencode(const char *intext, const char *outfile, enum imageType image_type) -{ - int result = 0; - QRcode *qrcode = encode(intext); - - if (qrcode == NULL) { - if (errno == ERANGE) { - fprintf(stderr, "Failed to encode the input data: Input data too large\n"); - } - else { - perror("Failed to encode the input data"); - } - return 1; - } - - if (verbose) { - fprintf(stderr, "File: %s, Version: %d\n", (outfile != NULL) ? outfile : "(stdout)", qrcode->version); - } - - switch (image_type) { - case PNG_TYPE: - case PNG32_TYPE: - result = writePNG(qrcode, outfile, image_type); - break; - default: - fprintf(stderr, "Unknown image type.\n"); - return 1; - } - - QRcode_free(qrcode); - - return result; -} - -int genqr(const char * intext, const char * outfile) -{ - return qrencode(intext, outfile, PNG_TYPE); -} diff --git a/recipes/libqrencode/all/test_package/genqr.h b/recipes/libqrencode/all/test_package/genqr.h deleted file mode 100644 index 5819fcb4ca10a..0000000000000 --- a/recipes/libqrencode/all/test_package/genqr.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#ifdef __cplusplus -extern "C" { -#endif -int genqr(const char* text, const char* file); -#ifdef __cplusplus -} -#endif diff --git a/recipes/libqrencode/all/test_package/test_package.c b/recipes/libqrencode/all/test_package/test_package.c new file mode 100644 index 0000000000000..1d321e8213493 --- /dev/null +++ b/recipes/libqrencode/all/test_package/test_package.c @@ -0,0 +1,7 @@ +#include + +int main() +{ + QRcode *code = QRcode_encodeString("conan-center", 0, QR_ECLEVEL_L, QR_MODE_8, 1); + return 0; +} diff --git a/recipes/libqrencode/all/test_package/test_package.cpp b/recipes/libqrencode/all/test_package/test_package.cpp deleted file mode 100644 index 0af80a648de57..0000000000000 --- a/recipes/libqrencode/all/test_package/test_package.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -#include "genqr.h" - -int main() -{ - std::cout << "Generating QR code for the 'dummy.png' text and store to the dummy.png file\n"; - return genqr("dummy.png", "dummy.png"); -} diff --git a/recipes/libqrencode/all/test_v1_package/CMakeLists.txt b/recipes/libqrencode/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d3795115e353f --- /dev/null +++ b/recipes/libqrencode/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libqrencode REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libqrencode::libqrencode) diff --git a/recipes/libqrencode/all/test_v1_package/conanfile.py b/recipes/libqrencode/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libqrencode/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libqrencode/config.yml b/recipes/libqrencode/config.yml index 19438df103c85..50f2b6c8613f3 100644 --- a/recipes/libqrencode/config.yml +++ b/recipes/libqrencode/config.yml @@ -1,5 +1,5 @@ versions: - "4.0.0": - folder: all "4.1.1": folder: all + "4.0.0": + folder: all diff --git a/recipes/librasterlite/all/conandata.yml b/recipes/librasterlite/all/conandata.yml new file mode 100644 index 0000000000000..8e05bde05f4df --- /dev/null +++ b/recipes/librasterlite/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "1.1g": + url: "https://www.gaia-gis.it/gaia-sins/librasterlite-sources/librasterlite-1.1g.tar.gz" + sha256: "0a8dceb75f8dec2b7bd678266e0ffd5210d7c33e3d01b247e9e92fa730eebcb3" +patches: + "1.1g": + - patch_file: "patches/0001-fix-autotools.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-nmake-honor-flags.patch" + base_path: "source_subfolder" diff --git a/recipes/librasterlite/all/conanfile.py b/recipes/librasterlite/all/conanfile.py new file mode 100644 index 0000000000000..5fbfd045b9808 --- /dev/null +++ b/recipes/librasterlite/all/conanfile.py @@ -0,0 +1,147 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment, tools +import functools +import os + +required_conan_version = ">=1.36.0" + + +class LibrasterliteConan(ConanFile): + name = "librasterlite" + description = ( + "librasterlite is an open source library that stores and retrieves " + "huge raster coverages using a SpatiaLite DBMS." + ) + license = ("MPL-1.1", "GPL-2.0-or-later", "LGPL-2.1-or-later") + topics = ("rasterlite", "raster", "spatialite") + homepage = "https://www.gaia-gis.it/fossil/librasterlite" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "pkg_config" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + self.requires("libgeotiff/1.7.0") + self.requires("libjpeg/9d") + self.requires("libpng/1.6.37") + self.requires("libspatialite/5.0.1") + self.requires("libtiff/4.3.0") + self.requires("sqlite3/3.38.1") + + def build_requirements(self): + if not self._is_msvc: + self.build_requires("libtool/2.4.6") + self.build_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _build_msvc(self): + target = "rasterlite_i.lib" if self.options.shared else "rasterlite.lib" + optflags = ["-D_USE_MATH_DEFINES"] + system_libs = [lib + ".lib" for lib in self.deps_cpp_info.system_libs] + if self.options.shared: + optflags.append("-DDLL_EXPORT") + with tools.chdir(self._source_subfolder): + tools.save(os.path.join("headers", "config.h"), "#define VERSION \"{}\"\n".format(self.version)) + with tools.vcvars(self): + with tools.environment_append(VisualStudioBuildEnvironment(self).vars): + self.run("nmake -f makefile.vc {} OPTFLAGS=\"{}\" SYSTEM_LIBS=\"{}\"".format(target, + " ".join(optflags), + " ".join(system_libs))) + + def _build_autotools(self): + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + # relocatable shared libs on macOS + tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name @rpath/") + # avoid SIP issues on macOS when dependencies are shared + if tools.is_apple_os(self.settings.os): + libpaths = ":".join(self.deps_cpp_info.lib_paths) + tools.replace_in_file( + "configure", + "#! /bin/sh\n", + "#! /bin/sh\nexport DYLD_LIBRARY_PATH={}:$DYLD_LIBRARY_PATH\n".format(libpaths), + ) + with tools.run_environment(self): + autotools = self._configure_autotools() + autotools.make() + + @functools.lru_cache(1) + def _configure_autotools(self): + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-shared={}".format(yes_no(self.options.shared)), + "--disable-gcov", + ] + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools.configure(args=args) + return autotools + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + if self._is_msvc: + self._build_msvc() + else: + self._build_autotools() + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + if self._is_msvc: + self.copy("rasterlite.h", dst="include", src=os.path.join(self._source_subfolder, "headers")) + self.copy("*.lib", dst="lib", src=self._source_subfolder) + self.copy("*.dll", dst="bin", src=self._source_subfolder) + else: + with tools.chdir(self._source_subfolder): + with tools.run_environment(self): + autotools = self._configure_autotools() + autotools.install() + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "rasterlite") + suffix = "_i" if self._is_msvc and self.options.shared else "" + self.cpp_info.libs = ["rasterlite{}".format(suffix)] + + # TODO: to remove in conan v2 once pkg_config generator removed + self.cpp_info.names["pkg_config"] = "rasterlite" diff --git a/recipes/librasterlite/all/patches/0001-fix-autotools.patch b/recipes/librasterlite/all/patches/0001-fix-autotools.patch new file mode 100644 index 0000000000000..296edad0d5ea9 --- /dev/null +++ b/recipes/librasterlite/all/patches/0001-fix-autotools.patch @@ -0,0 +1,27 @@ +Fix autotools: +* Disable test and tools +* Do not check transitive dependencies (zlib and proj) + +--- a/Makefile.am ++++ b/Makefile.am +@@ -1,6 +1,6 @@ + ACLOCAL_AMFLAGS = -I m4 + +-SUBDIRS = headers lib src test ++SUBDIRS = headers lib + + AUTOMAKE_OPTIONS = dist-zip + +--- a/configure.ac ++++ b/configure.ac +@@ -73,10 +73,8 @@ AC_FUNC_STRFTIME + AC_CHECK_FUNCS([memset sqrt strcasecmp strerror strncasecmp strstr fdatasync ftruncate getcwd gettimeofday localtime_r memmove strerror]) + + # Checks for required libraries +-AC_CHECK_LIB(z,inflateInit_,,AC_MSG_ERROR(['libz' is required but it doesn't seem to be installed on this system.]),-lm) + AC_CHECK_LIB(jpeg,jpeg_start_compress,,AC_MSG_ERROR(['libjpeg' is required but it doesn't seem to be installed on this system.]),-lm) + AC_CHECK_LIB(tiff,TIFFClientOpen,,AC_MSG_ERROR(['libtiff' is required but it doesn't seem to be installed on this system.]),-lm) +-AC_CHECK_LIB(proj,pj_init_plus,,AC_MSG_ERROR(['libproj' is required but it doesn't seem to be installed on this system.]),-lm) + AC_CHECK_LIB(geotiff,GTIFSetFromProj4,,AC_MSG_ERROR(['libgeotiff' [>= v.1.2.5] is required but it doesn't seem to be installed on this system.]),-lm) + + PKG_CHECK_MODULES([LIBSPATIALITE], [spatialite], , AC_MSG_ERROR(['libspatialite' is required but it doesn't seem to be installed on this system.])) diff --git a/recipes/librasterlite/all/patches/0002-nmake-honor-flags.patch b/recipes/librasterlite/all/patches/0002-nmake-honor-flags.patch new file mode 100644 index 0000000000000..ff434e3cfd949 --- /dev/null +++ b/recipes/librasterlite/all/patches/0002-nmake-honor-flags.patch @@ -0,0 +1,43 @@ +This patch for msvc build allows to: +* define OPTFLAG ourself from conanfile (allow to honor profile) +* inject a custom SYSTEM_LIBS variable from conanfile (allow robust shared build) +* not hardcode this very specific C:\OSGeo4W environment +* define rasterliteGetVersion() to be compliant with autotools build + +--- a/makefile.vc ++++ b/makefile.vc +@@ -2,7 +2,6 @@ + # + # NMAKE Makefile to build librasterlite on Windows + # +-!INCLUDE nmake.opt + + OBJ_EXT = obj + EXT = $(OBJ_EXT) +@@ -11,10 +10,10 @@ LIBOBJ = lib\rasterlite.$(EXT) lib\rasterlite_gif.$(EXT) \ + lib\rasterlite_png.$(EXT) lib\rasterlite_jpeg.$(EXT) \ + lib\rasterlite_io.$(EXT) lib\rasterlite_image.$(EXT) \ + lib\rasterlite_tiff.$(EXT) lib\rasterlite_aux.$(EXT) \ +- lib\rasterlite_quantize.$(EXT) ++ lib\rasterlite_quantize.$(EXT) lib\rasterlite_version.$(EXT) + RASTERLITE_DLL = rasterlite$(VERSION).dll + +-CFLAGS = /nologo -IC:\OSGeo4W\include -I.\headers $(OPTFLAGS) ++CFLAGS = /nologo -I.\headers $(CFLAGS) $(OPTFLAGS) + + CFLAGS2 = /nologo -IC:\OSGeo4W\include -I.\headers $(OPTFLAGS2) + +@@ -30,11 +29,8 @@ rasterlite.lib: $(LIBOBJ) + $(RASTERLITE_DLL): rasterlite_i.lib + + rasterlite_i.lib: $(LIBOBJ) +- link /debug /dll /out:$(RASTERLITE_DLL) \ +- /implib:rasterlite_i.lib $(LIBOBJ) \ +- C:\OSGeo4W\lib\jpeg_i.lib C:\OSGeo4W\lib\libtiff_i.lib \ +- C:\OSGeo4W\lib\libpng13.lib C:\OSGeo4W\lib\zlib.lib \ +- C:\OSGeo4W\lib\geotiff_i.lib C:\OSGeo4W\lib\spatialite_i.lib ++ link /dll /out:$(RASTERLITE_DLL) \ ++ /implib:rasterlite_i.lib $(LIBOBJ) $(SYSTEM_LIBS) + if exist $(RASTERLITE_DLL).manifest mt -manifest \ + $(RASTERLITE_DLL).manifest -outputresource:$(RASTERLITE_DLL);2 + diff --git a/recipes/librasterlite/all/test_package/CMakeLists.txt b/recipes/librasterlite/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..66ed4461774cf --- /dev/null +++ b/recipes/librasterlite/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(librasterlite REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} librasterlite::librasterlite) diff --git a/recipes/librasterlite/all/test_package/conanfile.py b/recipes/librasterlite/all/test_package/conanfile.py new file mode 100644 index 0000000000000..79178ce11469e --- /dev/null +++ b/recipes/librasterlite/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.3") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/librasterlite/all/test_package/test_package.c b/recipes/librasterlite/all/test_package/test_package.c new file mode 100644 index 0000000000000..0ec59df2a0ee7 --- /dev/null +++ b/recipes/librasterlite/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include +#include + +#include + +int main(void) { + printf("rasterlite %s\n", rasterliteGetVersion()); + return 0; +} diff --git a/recipes/librasterlite/config.yml b/recipes/librasterlite/config.yml new file mode 100644 index 0000000000000..9903cd560d3b4 --- /dev/null +++ b/recipes/librasterlite/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1g": + folder: all diff --git a/recipes/librasterlite2/all/conandata.yml b/recipes/librasterlite2/all/conandata.yml new file mode 100644 index 0000000000000..4b32e30c8e014 --- /dev/null +++ b/recipes/librasterlite2/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.1.0-beta1": + url: "http://www.gaia-gis.it/gaia-sins/librasterlite2-sources/librasterlite2-1.1.0-beta1.tar.gz" + sha256: "f7284cdfc07ad343a314e4878df0300874b0145d9d331b063b096b482e7e44f4" +patches: + "1.1.0-beta1": + - patch_file: "patches/0001-missing-include.patch" + base_path: "source_subfolder" diff --git a/recipes/librasterlite2/all/conanfile.py b/recipes/librasterlite2/all/conanfile.py new file mode 100644 index 0000000000000..f7a1b69c371ae --- /dev/null +++ b/recipes/librasterlite2/all/conanfile.py @@ -0,0 +1,169 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.36.0" + + +class Librasterlite2Conan(ConanFile): + name = "librasterlite2" + description = ( + "librasterlite2 is an open source library that stores and retrieves " + "huge raster coverages using a SpatiaLite DBMS." + ) + license = ("MPL-1.1", "GPL-2.0-or-later", "LGPL-2.1-or-later") + topics = ("rasterlite", "raster", "spatialite") + homepage = "https://www.gaia-gis.it/fossil/librasterlite2" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_openjpeg": [True, False], + "with_webp": [True, False], + "with_lzma": [True, False], + "with_lz4": [True, False], + "with_zstd": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_openjpeg": True, + "with_webp": True, + "with_lzma": True, + "with_lz4": True, + "with_zstd": True, + } + + generators = "pkg_config" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + self.requires("cairo/1.17.4") + self.requires("freetype/2.11.1") + self.requires("giflib/5.2.1") + self.requires("libcurl/7.80.0") + self.requires("libgeotiff/1.7.1") + self.requires("libjpeg/9d") + self.requires("libpng/1.6.37") + self.requires("libspatialite/5.0.1") + self.requires("libtiff/4.3.0") + self.requires("libxml2/2.9.13") + self.requires("sqlite3/3.38.1") + self.requires("zlib/1.2.12") + if self.options.with_openjpeg: + self.requires("openjpeg/2.4.0") + if self.options.with_webp: + self.requires("libwebp/1.2.2") + if self.options.with_lzma: + self.requires("xz_utils/5.2.5") + if self.options.with_lz4: + self.requires("lz4/1.9.3") + if self.options.with_zstd: + self.requires("zstd/1.5.2") + + def validate(self): + if self._is_msvc: + raise ConanInvalidConfiguration("Visual Studio not supported yet") + + def build_requirements(self): + self.build_requires("libtool/2.4.6") + self.build_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + # Disable tests, tools and examples + tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.am"), + "SUBDIRS = headers src test tools examples", + "SUBDIRS = headers src") + # fix MinGW + tools.replace_in_file(os.path.join(self._source_subfolder, "configure.ac"), + "AC_CHECK_LIB(z,", + "AC_CHECK_LIB({},".format(self.deps_cpp_info["zlib"].libs[0])) + + @functools.lru_cache(1) + def _configure_autotools(self): + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-shared={}".format(yes_no(self.options.shared)), + "--disable-gcov", + "--enable-openjpeg={}".format(yes_no(self.options.with_openjpeg)), + "--enable-webp={}".format(yes_no(self.options.with_webp)), + "--enable-lzma={}".format(yes_no(self.options.with_lzma)), + "--enable-lz4={}".format(yes_no(self.options.with_lz4)), + "--enable-zstd={}".format(yes_no(self.options.with_zstd)), + ] + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools.configure(args=args) + return autotools + + def build(self): + self._patch_sources() + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + # relocatable shared libs on macOS + tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name @rpath/") + # avoid SIP issues on macOS when dependencies are shared + if tools.is_apple_os(self.settings.os): + libpaths = ":".join(self.deps_cpp_info.lib_paths) + tools.replace_in_file( + "configure", + "#! /bin/sh\n", + "#! /bin/sh\nexport DYLD_LIBRARY_PATH={}:$DYLD_LIBRARY_PATH\n".format(libpaths), + ) + with tools.run_environment(self): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + with tools.chdir(self._source_subfolder): + with tools.run_environment(self): + autotools = self._configure_autotools() + autotools.install() + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "rasterlite2") + self.cpp_info.libs = ["rasterlite2"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + + # TODO: to remove in conan v2 once pkg_config generator removed + self.cpp_info.names["pkg_config"] = "rasterlite2" diff --git a/recipes/librasterlite2/all/patches/0001-missing-include.patch b/recipes/librasterlite2/all/patches/0001-missing-include.patch new file mode 100644 index 0000000000000..d2ffe4d7482f3 --- /dev/null +++ b/recipes/librasterlite2/all/patches/0001-missing-include.patch @@ -0,0 +1,11 @@ +--- a/headers/rasterlite2_private.h ++++ b/headers/rasterlite2_private.h +@@ -77,6 +77,8 @@ the terms of any one of the MPL, the GPL or the LGPL. + #include + #endif + ++#include ++ + #ifndef DOXYGEN_SHOULD_SKIP_THIS + #ifdef _WIN32 + #ifdef DLL_EXPORT diff --git a/recipes/librasterlite2/all/test_package/CMakeLists.txt b/recipes/librasterlite2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8c3dd28e2bff3 --- /dev/null +++ b/recipes/librasterlite2/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(librasterlite2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} librasterlite2::librasterlite2) diff --git a/recipes/librasterlite2/all/test_package/conanfile.py b/recipes/librasterlite2/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/librasterlite2/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/librasterlite2/all/test_package/test_package.c b/recipes/librasterlite2/all/test_package/test_package.c new file mode 100644 index 0000000000000..dab3d2554330d --- /dev/null +++ b/recipes/librasterlite2/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include + +#include + +int main(void) { + printf("rasterlite2 %s\n", rl2_version()); + printf("-- target cpu: %s\n", rl2_target_cpu()); + return 0; +} diff --git a/recipes/librasterlite2/config.yml b/recipes/librasterlite2/config.yml new file mode 100644 index 0000000000000..063711165754b --- /dev/null +++ b/recipes/librasterlite2/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.0-beta1": + folder: all diff --git a/recipes/libraw/all/CMakeLists.txt b/recipes/libraw/all/CMakeLists.txt index 580e170806b9b..2022d590fa2a2 100644 --- a/recipes/libraw/all/CMakeLists.txt +++ b/recipes/libraw/all/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.1) project(LibRaw) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) file(GLOB_RECURSE headers "source_subfolder/libraw/*.h") @@ -26,13 +26,32 @@ if(WIN32) endif() endif() -add_definitions(-DUSE_JPEG -DUSE_JPEG8 -DUSE_JASPER) +if (TARGET CONAN_PKG::libjpeg OR TARGET CONAN_PKG::libjpeg-turbo) + add_definitions(-DUSE_JPEG -DUSE_JPEG8) +endif () +if (TARGET CONAN_PKG::lcms) + add_definitions(-DUSE_LCMS2) +endif () +if (TARGET CONAN_PKG::jasper) + add_definitions(-DUSE_JASPER) +endif () add_library(raw ${headers} ${sources}) set_property(TARGET raw PROPERTY CXX_STANDARD 11) -target_include_directories(raw PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/" ${CONAN_INCLUDE_DIRS}) -target_link_libraries(raw PUBLIC ${CONAN_LIBS}) +target_include_directories(raw PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/") target_compile_options(raw PUBLIC $<$:/W0>) +if (TARGET CONAN_PKG::libjpeg) + target_link_libraries(raw PUBLIC CONAN_PKG::libjpeg) +endif () +if (TARGET CONAN_PKG::libjpeg-turbo) + target_link_libraries(raw PUBLIC CONAN_PKG::libjpeg-turbo) +endif () +if (TARGET CONAN_PKG::lcms) + target_link_libraries(raw PUBLIC CONAN_PKG::lcms) +endif () +if (TARGET CONAN_PKG::jasper) + target_link_libraries(raw PUBLIC CONAN_PKG::jasper) +endif () install(DIRECTORY "source_subfolder/libraw" DESTINATION include) install(TARGETS raw ARCHIVE DESTINATION lib RUNTIME DESTINATION bin LIBRARY DESTINATION lib) diff --git a/recipes/libraw/all/conanfile.py b/recipes/libraw/all/conanfile.py index dabe3387078c3..47b1f62f9d69b 100644 --- a/recipes/libraw/all/conanfile.py +++ b/recipes/libraw/all/conanfile.py @@ -12,8 +12,20 @@ class LibRawConan(ConanFile): generators = "cmake" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_jpeg": [False, "libjpeg", "libjpeg-turbo"], + "with_lcms": [True, False], + "with_jasper": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "with_jpeg": "libjpeg", + "with_lcms": True, + "with_jasper": True + } _cmake = None @@ -25,10 +37,25 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + def requirements(self): - self.requires("libjpeg/9d") - self.requires("lcms/2.11") - self.requires("jasper/2.0.16") + # TODO: RawSpeed dependency (-DUSE_RAWSPEED) + # TODO: DNG SDK dependency (-DUSE_DNGSDK) + if self.options.with_jpeg == "libjpeg": + self.requires("libjpeg/9d") + elif self.options.with_jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/2.1.1") + if self.options.with_lcms: + self.requires("lcms/2.12") + if self.options.with_jasper: + self.requires("jasper/2.0.33") def source(self): tools.get(**self.conan_data["sources"][self.version]) diff --git a/recipes/librdkafka/all/CMakeLists.txt b/recipes/librdkafka/all/CMakeLists.txt deleted file mode 100644 index ad95cfd8209a3..0000000000000 --- a/recipes/librdkafka/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory("source_subfolder") diff --git a/recipes/librdkafka/all/conandata.yml b/recipes/librdkafka/all/conandata.yml index d751b83df3ddd..9bb10a3ea1457 100644 --- a/recipes/librdkafka/all/conandata.yml +++ b/recipes/librdkafka/all/conandata.yml @@ -1,44 +1,50 @@ sources: - "1.3.0": - url: "https://github.com/edenhill/librdkafka/archive/v1.3.0.tar.gz" - sha256: "465cab533ebc5b9ca8d97c90ab69e0093460665ebaf38623209cf343653c76d2" - "1.4.0": - url: "https://github.com/edenhill/librdkafka/archive/v1.4.0.tar.gz" - sha256: "ae27ea3f3d0d32d29004e7f709efbba2666c5383a107cc45b3a1949486b2eb84" - "1.5.2": - url: "https://github.com/edenhill/librdkafka/archive/v1.5.2.tar.gz" - sha256: "ca3db90d04ef81ca791e55e9eed67e004b547b7adedf11df6c24ac377d4840c6" - "1.5.3": - url: "https://github.com/edenhill/librdkafka/archive/v1.5.3.tar.gz" - sha256: "2105ca01fef5beca10c9f010bc50342b15d5ce6b73b2489b012e6d09a008b7bf" + "1.9.2": + url: "https://github.com/edenhill/librdkafka/archive/refs/tags/v1.9.2.tar.gz" + sha256: "3fba157a9f80a0889c982acdd44608be8a46142270a389008b22d921be1198ad" + "1.9.1": + url: "https://github.com/edenhill/librdkafka/archive/refs/tags/v1.9.1.tar.gz" + sha256: "3a54cf375218977b7af4716ed9738378e37fe400a6c5ddb9d622354ca31fdc79" + "1.8.2": + url: "https://github.com/edenhill/librdkafka/archive/refs/tags/v1.8.2.tar.gz" + sha256: "6a747d293a7a4613bd2897e28e8791476fbe1ae7361f2530a876e0fd483482a6" + "1.8.0": + url: "https://github.com/edenhill/librdkafka/archive/v1.8.0.tar.gz" + sha256: "93b12f554fa1c8393ce49ab52812a5f63e264d9af6a50fd6e6c318c481838b7f" + "1.7.0": + url: "https://github.com/edenhill/librdkafka/archive/v1.7.0.tar.gz" + sha256: "c71b8c5ff419da80c31bb8d3036a408c87ad523e0c7588e7660ee5f3c8973057" + "1.6.1": + url: "https://github.com/edenhill/librdkafka/archive/v1.6.1.tar.gz" + sha256: "689028b5fdfdce026f396fc2f3bfe9e38947210d9bd22be28c3159cc8c41b57e" "1.6.0": url: "https://github.com/edenhill/librdkafka/archive/v1.6.0.tar.gz" sha256: "3130cbd391ef683dc9acf9f83fe82ff93b8730a1a34d0518e93c250929be9f6b" -patches: - "1.3.0": - - patch_file: patches/0001-Remove-cmake-module-path-and-change-library-names.patch - base_path: source_subfolder - - patch_file: patches/0002-Change-library-targets-and-result-variables-1-3-0.patch - base_path: source_subfolder - "1.4.0": - - patch_file: patches/0001-Remove-cmake-module-path-and-change-library-names.patch - base_path: source_subfolder - - patch_file: patches/0002-Change-library-targets-and-result-variables-1-4-0.patch - base_path: source_subfolder - - patch_file: patches/0003-Fix-broken-version-1-4-0-on-windows.patch - base_path: source_subfolder - "1.5.2": - - patch_file: patches/0004-Change-library-names.patch - base_path: source_subfolder - - patch_file: patches/0002-Change-library-targets-and-result-variables-1-5-2.patch - base_path: source_subfolder "1.5.3": - - patch_file: patches/0004-Change-library-names.patch - base_path: source_subfolder - - patch_file: patches/0002-Change-library-targets-and-result-variables-1-5-2.patch - base_path: source_subfolder + url: "https://github.com/edenhill/librdkafka/archive/v1.5.3.tar.gz" + sha256: "2105ca01fef5beca10c9f010bc50342b15d5ce6b73b2489b012e6d09a008b7bf" +patches: + "1.9.2": + - patch_file: patches/0001-Change-library-names-1-9-1.patch + - patch_file: patches/0002-Change-library-targets-and-result-variables-1-9-1.patch + "1.9.1": + - patch_file: patches/0001-Change-library-names-1-9-1.patch + - patch_file: patches/0002-Change-library-targets-and-result-variables-1-9-1.patch + "1.8.2": + - patch_file: patches/0001-Change-library-names-1-7-0.patch + - patch_file: patches/0002-Change-library-targets-and-result-variables-1-7-0.patch + "1.8.0": + - patch_file: patches/0001-Change-library-names-1-7-0.patch + - patch_file: patches/0002-Change-library-targets-and-result-variables-1-7-0.patch + "1.7.0": + - patch_file: patches/0001-Change-library-names-1-7-0.patch + - patch_file: patches/0002-Change-library-targets-and-result-variables-1-7-0.patch + "1.6.1": + - patch_file: patches/0001-Change-library-names-1-5-2.patch + - patch_file: patches/0002-Change-library-targets-and-result-variables-1-6-1.patch "1.6.0": - - patch_file: patches/0004-Change-library-names.patch - base_path: source_subfolder + - patch_file: patches/0001-Change-library-names-1-5-2.patch - patch_file: patches/0002-Change-library-targets-and-result-variables-1-6-0.patch - base_path: source_subfolder + "1.5.3": + - patch_file: patches/0001-Change-library-names-1-5-2.patch + - patch_file: patches/0002-Change-library-targets-and-result-variables-1-5-2.patch diff --git a/recipes/librdkafka/all/conanfile.py b/recipes/librdkafka/all/conanfile.py index 44574c3745803..1497ac09fe62a 100644 --- a/recipes/librdkafka/all/conanfile.py +++ b/recipes/librdkafka/all/conanfile.py @@ -1,17 +1,25 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.gnu import PkgConfigDeps +from conan.tools.scm import Version import os -from conans import CMake, ConanFile, tools +required_conan_version = ">=1.53.0" class LibrdkafkaConan(ConanFile): name = "librdkafka" + description = ( + "Librdkafka is an Apache Kafka C/C++ library designed with message " + "delivery reliability and high performance in mind." + ) license = "BSD-2-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/edenhill/librdkafka" - description = "Librdkafka is an Apache Kafka C/C++ library designed with message delivery reliability and high performance in mind." - - topics = ("kafka", "librdkafka") - settings = "os", "compiler", "build_type", "arch" + topics = ("kafka", "consumer", "producer") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -20,7 +28,7 @@ class LibrdkafkaConan(ConanFile): "plugins": [True, False], "ssl": [True, False], "sasl": [True, False], - "lz4": [True, False, "deprecated"], + "curl": [True, False], } default_options = { "shared": False, @@ -30,96 +38,108 @@ class LibrdkafkaConan(ConanFile): "plugins": False, "ssl": False, "sasl": False, - "lz4": "deprecated", + "curl": False, } - generators = "cmake", "cmake_find_package", "pkg_config" - exports_sources = "CMakeLists.txt", "patches/**" - _cmake = None @property - def _source_subfolder(self): - return "source_subfolder" + def _depends_on_cyrus_sasl(self): + return self.options.sasl and self.settings.os != "Windows" + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if Version(self.version) < "1.9.0": + del self.options.curl def configure(self): if self.options.shared: - del self.options.fPIC - if self.options.lz4 != "deprecated": - self.output.warn("lz4 option is deprecated. Actually, librdkafka always depends on lz4.") + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("lz4/1.9.3") + self.requires("lz4/1.9.4") if self.options.zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.zstd: - self.requires("zstd/1.4.8") + self.requires("zstd/1.5.2") if self.options.ssl: - self.requires("openssl/1.1.1i") - if self.options.sasl and self.settings.os != "Windows": + self.requires("openssl/1.1.1s") + if self._depends_on_cyrus_sasl: self.requires("cyrus-sasl/2.1.27") - - def package_id(self): - del self.info.options.lz4 + if self.options.get_safe("curl", False): + self.requires("libcurl/7.85.0") def build_requirements(self): - if self.options.sasl and self.settings.os != "Windows": - self.build_requires("pkgconf/1.7.3") + if self._depends_on_cyrus_sasl: + self.tool_requires("pkgconf/1.9.3") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - downloaded_folder_name = "{}-{}".format(self.name, self.version) - os.rename(downloaded_folder_name, self._source_subfolder) - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["WITHOUT_OPTIMIZATION"] = self.settings.build_type == "Debug" - self._cmake.definitions["ENABLE_DEVEL"] = self.settings.build_type == "Debug" - self._cmake.definitions["RDKAFKA_BUILD_STATIC"] = not self.options.shared - self._cmake.definitions["RDKAFKA_BUILD_EXAMPLES"] = False - self._cmake.definitions["RDKAFKA_BUILD_TESTS"] = False - self._cmake.definitions["WITHOUT_WIN32_CONFIG"] = True - self._cmake.definitions["WITH_BUNDLED_SSL"] = False - self._cmake.definitions["WITH_ZLIB"] = self.options.zlib - self._cmake.definitions["WITH_ZSTD"] = self.options.zstd - self._cmake.definitions["WITH_PLUGINS"] = self.options.plugins - self._cmake.definitions["WITH_SSL"] = self.options.ssl - self._cmake.definitions["WITH_SASL"] = self.options.sasl - self._cmake.definitions["ENABLE_LZ4_EXT"] = True - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITHOUT_OPTIMIZATION"] = self.settings.build_type == "Debug" + tc.variables["ENABLE_DEVEL"] = self.settings.build_type == "Debug" + tc.variables["RDKAFKA_BUILD_STATIC"] = not self.options.shared + tc.variables["RDKAFKA_BUILD_EXAMPLES"] = False + tc.variables["RDKAFKA_BUILD_TESTS"] = False + tc.variables["WITHOUT_WIN32_CONFIG"] = True + tc.variables["WITH_BUNDLED_SSL"] = False + tc.variables["WITH_ZLIB"] = self.options.zlib + tc.variables["WITH_ZSTD"] = self.options.zstd + tc.variables["WITH_PLUGINS"] = self.options.plugins + tc.variables["WITH_SSL"] = self.options.ssl + tc.variables["WITH_SASL"] = self.options.sasl + tc.variables["ENABLE_LZ4_EXT"] = True + if Version(self.version) >= "1.9.0": + tc.variables["WITH_CURL"] = self.options.curl + tc.generate() + + cd = CMakeDeps(self) + cd.generate() + + if self._depends_on_cyrus_sasl: + pc = PkgConfigDeps(self) + pc.generate() + # inject pkgconf env vars in build context + ms = VirtualBuildEnv(self) + ms.generate(scope="build") + # also need to inject generators folder into PKG_CONFIG_PATH + env = Environment() + env.prepend_path("PKG_CONFIG_PATH", self.generators_folder) + envvars = env.vars(self, scope="build") + envvars.save_script("conanbuildenv_pkg_config_path") def build(self): - self._patch_sources() - with tools.run_environment(self): - cmake = self._configure_cmake() - cmake.build() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - self.copy(pattern="LICENSES.txt", src=self._source_subfolder, dst="licenses") - with tools.run_environment(self): - cmake = self._configure_cmake() - cmake.install() - - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "share")) + copy(self, "LICENSES.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "RdKafka" - self.cpp_info.names["cmake_find_package_multi"] = "RdKafka" + self.cpp_info.set_property("cmake_file_name", "RdKafka") + # Avoid to create undesirables librdkafka::librdkafka target and librdkafka.pc + # it's fine since rdkafka++ component depends on all components + self.cpp_info.set_property("cmake_target_name", "RdKafka::rdkafka++") + self.cpp_info.set_property("pkg_config_name", "rdkafka++") + # rdkafka - self.cpp_info.components["rdkafka"].names["cmake_find_package"] = "rdkafka" - self.cpp_info.components["rdkafka"].names["cmake_find_package_multi"] = "rdkafka" - self.cpp_info.components["rdkafka"].names["pkg_config"] = "rdkafka" + self.cpp_info.components["rdkafka"].set_property("cmake_target_name", "RdKafka::rdkafka") + self.cpp_info.components["rdkafka"].set_property("pkg_config_name", "rdkafka") self.cpp_info.components["rdkafka"].libs = ["rdkafka"] self.cpp_info.components["rdkafka"].requires = ["lz4::lz4"] if self.options.zlib: @@ -128,19 +148,34 @@ def package_info(self): self.cpp_info.components["rdkafka"].requires.append("zstd::zstd") if self.options.ssl: self.cpp_info.components["rdkafka"].requires.append("openssl::openssl") - if self.options.sasl and self.settings.os != "Windows": + if self._depends_on_cyrus_sasl: self.cpp_info.components["rdkafka"].requires.append("cyrus-sasl::cyrus-sasl") + if self.options.get_safe("curl", False): + self.cpp_info.components["rdkafka"].requires.append("libcurl::libcurl") if self.settings.os == "Windows": self.cpp_info.components["rdkafka"].system_libs = ["ws2_32", "secur32"] if self.options.ssl: self.cpp_info.components["rdkafka"].system_libs.append("crypt32") - elif self.settings.os == "Linux": + elif self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["rdkafka"].system_libs.extend(["pthread", "rt", "dl", "m"]) if not self.options.shared: self.cpp_info.components["rdkafka"].defines.append("LIBRDKAFKA_STATICLIB") + # rdkafka++ - self.cpp_info.components["rdkafka++"].names["cmake_find_package"] = "rdkafka++" - self.cpp_info.components["rdkafka++"].names["cmake_find_package_multi"] = "rdkafka++" - self.cpp_info.components["rdkafka++"].names["pkg_config"] = "rdkafka++" + self.cpp_info.components["rdkafka++"].set_property("cmake_target_name", "RdKafka::rdkafka++") + self.cpp_info.components["rdkafka++"].set_property("pkg_config_name", "rdkafka++") self.cpp_info.components["rdkafka++"].libs = ["rdkafka++"] self.cpp_info.components["rdkafka++"].requires = ["rdkafka"] + + # FIXME: remove when Conan 1.50 is used in c3i and update the Conan required version + # from that version components don't have empty libdirs by default + self.cpp_info.components["rdkafka"].includedirs = ["include"] + self.cpp_info.components["rdkafka"].libdirs= ["lib"] + self.cpp_info.components["rdkafka"].bindirs = ["bin"] + self.cpp_info.components["rdkafka++"].includedirs = ["include"] + self.cpp_info.components["rdkafka++"].libdirs = ["lib"] + self.cpp_info.components["rdkafka++"].bindirs = ["bin"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "RdKafka" + self.cpp_info.names["cmake_find_package_multi"] = "RdKafka" diff --git a/recipes/librdkafka/all/patches/0001-Change-library-names-1-5-2.patch b/recipes/librdkafka/all/patches/0001-Change-library-names-1-5-2.patch new file mode 100644 index 0000000000000..63c4787d111f3 --- /dev/null +++ b/recipes/librdkafka/all/patches/0001-Change-library-names-1-5-2.patch @@ -0,0 +1,31 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -54,7 +54,7 @@ endif() + # } + + # ZSTD { +-find_package(ZSTD QUIET) ++find_package(zstd QUIET CONFIG) + if(ZSTD_FOUND) + set(with_zstd_default ON) + else() +@@ -133,6 +133,9 @@ else() + endif() + option(WITH_SASL "With SASL" ${with_sasl_default}) + if(WITH_SASL) ++ if(SASL_FOUND) ++ link_directories(${SASL_LIBRARY_DIRS}) ++ endif() + if(WITH_SSL) + set(WITH_SASL_SCRAM ON) + set(WITH_SASL_OAUTHBEARER ON) +@@ -149,7 +152,8 @@ endif() + option(ENABLE_LZ4_EXT "Enable external LZ4 library support" ON) + set(WITH_LZ4_EXT OFF) + if(ENABLE_LZ4_EXT) +- find_package(LZ4) ++ find_package(lz4 REQUIRED CONFIG) ++ set(LZ4_FOUND ON) + if(LZ4_FOUND) + set(WITH_LZ4_EXT ON) + list(APPEND BUILT_WITH "LZ4_EXT") diff --git a/recipes/librdkafka/all/patches/0001-Change-library-names-1-7-0.patch b/recipes/librdkafka/all/patches/0001-Change-library-names-1-7-0.patch new file mode 100644 index 0000000000000..966ba38247ca4 --- /dev/null +++ b/recipes/librdkafka/all/patches/0001-Change-library-names-1-7-0.patch @@ -0,0 +1,35 @@ +From 07bd30c67a532be3c1f31aa383a1061c832a034d Mon Sep 17 00:00:00 2001 +From: Alejandro Colomar +Date: Sun, 30 May 2021 11:02:57 +0200 +Subject: [PATCH] Change library names + +--- + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d1129bce..14d9e7f0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -54,7 +54,7 @@ endif() + # } + + # ZSTD { +-find_package(ZSTD QUIET) ++find_package(zstd QUIET CONFIG) + if(ZSTD_FOUND) + set(with_zstd_default ON) + else() +@@ -152,7 +152,8 @@ endif() + option(ENABLE_LZ4_EXT "Enable external LZ4 library support" ON) + set(WITH_LZ4_EXT OFF) + if(ENABLE_LZ4_EXT) +- find_package(LZ4) ++ find_package(lz4 REQUIRED CONFIG) ++ set(LZ4_FOUND ON) + if(LZ4_FOUND) + set(WITH_LZ4_EXT ON) + list(APPEND BUILT_WITH "LZ4_EXT") +-- +2.32.0.rc0 + diff --git a/recipes/librdkafka/all/patches/0001-Change-library-names-1-9-1.patch b/recipes/librdkafka/all/patches/0001-Change-library-names-1-9-1.patch new file mode 100644 index 0000000000000..93de57a4d1ee6 --- /dev/null +++ b/recipes/librdkafka/all/patches/0001-Change-library-names-1-9-1.patch @@ -0,0 +1,23 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7f3dd0f..89a21e7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -67,7 +67,7 @@ endif() + # } + + # ZSTD { +-find_package(ZSTD QUIET) ++find_package(zstd QUIET CONFIG) + if(ZSTD_FOUND) + set(with_zstd_default ON) + else() +@@ -169,7 +169,8 @@ endif() + option(ENABLE_LZ4_EXT "Enable external LZ4 library support" ON) + set(WITH_LZ4_EXT OFF) + if(ENABLE_LZ4_EXT) +- find_package(LZ4) ++ find_package(lz4 REQUIRED CONFIG) ++ set(LZ4_FOUND ON) + if(LZ4_FOUND) + set(WITH_LZ4_EXT ON) + list(APPEND BUILT_WITH "LZ4_EXT") diff --git a/recipes/librdkafka/all/patches/0001-Remove-cmake-module-path-and-change-library-names.patch b/recipes/librdkafka/all/patches/0001-Remove-cmake-module-path-and-change-library-names.patch deleted file mode 100644 index 599b4e187e751..0000000000000 --- a/recipes/librdkafka/all/patches/0001-Remove-cmake-module-path-and-change-library-names.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -5,7 +5,6 @@ parseversion("src/rdkafka.h") - - project(RdKafka VERSION ${RDKAFKA_VERSION}) - --set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/packaging/cmake/Modules/") - - # Options. No 'RDKAFKA_' prefix to match old C++ code. { - -@@ -55,7 +54,7 @@ endif() - # } - - # ZSTD { --find_package(Zstd QUIET) -+find_package(zstd QUIET) - if(ZSTD_FOUND) - set(with_zstd_default ON) - else() -@@ -134,6 +133,9 @@ else() - endif() - option(WITH_SASL "With SASL" ${with_sasl_default}) - if(WITH_SASL) -+ if(SASL_FOUND) -+ link_directories(${SASL_LIBRARY_DIRS}) -+ endif() - if(WITH_SSL) - set(WITH_SASL_SCRAM ON) - set(WITH_SASL_OAUTHBEARER ON) -@@ -150,7 +152,7 @@ endif() - option(ENABLE_LZ4_EXT "Enable external LZ4 library support" ON) - set(WITH_LZ4_EXT OFF) - if(ENABLE_LZ4_EXT) -- find_package(LZ4) -+ set(LZ4_FOUND ON) - if(LZ4_FOUND) - set(WITH_LZ4_EXT ON) - list(APPEND BUILT_WITH "LZ4_EXT") diff --git a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-3-0.patch b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-3-0.patch deleted file mode 100644 index deafb5087e069..0000000000000 --- a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-3-0.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -176,9 +176,7 @@ if(WITH_ZLIB) - endif() - - if(WITH_ZSTD) -- target_link_libraries(rdkafka PUBLIC ${ZSTD_LIBRARY}) -- target_include_directories(rdkafka PUBLIC ${ZSTD_INCLUDE_DIR}) -- message(STATUS "Found ZSTD: ${ZSTD_LIBRARY}") -+ target_link_libraries(rdkafka PUBLIC CONAN_PKG::zstd) - endif() - - if(WITH_SSL) -@@ -211,7 +209,7 @@ if(WITH_LIBDL) - endif() - - if(WITH_LZ4_EXT) -- target_link_libraries(rdkafka PUBLIC LZ4::LZ4) -+ target_link_libraries(rdkafka PUBLIC CONAN_PKG::lz4) - endif() - - # Set up path to these sources for other sub-projects (tests, examples) diff --git a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-4-0.patch b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-4-0.patch deleted file mode 100644 index d7094fcaa91f7..0000000000000 --- a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-4-0.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -182,9 +182,7 @@ if(WITH_ZLIB) - endif() - - if(WITH_ZSTD) -- target_link_libraries(rdkafka PUBLIC ${ZSTD_LIBRARY}) -- target_include_directories(rdkafka PUBLIC ${ZSTD_INCLUDE_DIR}) -- message(STATUS "Found ZSTD: ${ZSTD_LIBRARY}") -+ target_link_libraries(rdkafka PUBLIC CONAN_PKG::zstd) - endif() - - if(WITH_SSL) -@@ -219,8 +217,7 @@ if(WITH_LIBDL) - endif() - - if(WITH_LZ4_EXT) -- target_include_directories(rdkafka PUBLIC ${LZ4_INCLUDE_DIRS}) -- target_link_libraries(rdkafka PUBLIC LZ4::LZ4) -+ target_link_libraries(rdkafka PUBLIC CONAN_PKG::lz4) - endif() - - # Set up path to these sources for other sub-projects (tests, examples) diff --git a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-5-2.patch b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-5-2.patch index 07ec1d35832c6..2c6f62c68a478 100644 --- a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-5-2.patch +++ b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-5-2.patch @@ -7,7 +7,7 @@ - target_link_libraries(rdkafka PUBLIC ${ZSTD_LIBRARY}) - target_include_directories(rdkafka PUBLIC ${ZSTD_INCLUDE_DIR}) - message(STATUS "Found ZSTD: ${ZSTD_LIBRARY}") -+ target_link_libraries(rdkafka PUBLIC CONAN_PKG::zstd) ++ target_link_libraries(rdkafka PUBLIC $,zstd::libzstd_shared,zstd::libzstd_static>) endif() if(WITH_SSL) @@ -17,7 +17,7 @@ if(WITH_LZ4_EXT) - target_include_directories(rdkafka PUBLIC ${LZ4_INCLUDE_DIRS}) - target_link_libraries(rdkafka PUBLIC LZ4::LZ4) -+ target_link_libraries(rdkafka PUBLIC CONAN_PKG::lz4) ++ target_link_libraries(rdkafka PUBLIC lz4::lz4) endif() # Set up path to these sources for other sub-projects (tests, examples) diff --git a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-6-0.patch b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-6-0.patch index a1774497ca08f..71155e468786f 100644 --- a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-6-0.patch +++ b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-6-0.patch @@ -7,7 +7,7 @@ - target_link_libraries(rdkafka PUBLIC ${ZSTD_LIBRARY}) - target_include_directories(rdkafka PUBLIC ${ZSTD_INCLUDE_DIR}) - message(STATUS "Found ZSTD: ${ZSTD_LIBRARY}") -+ target_link_libraries(rdkafka PUBLIC CONAN_PKG::zstd) ++ target_link_libraries(rdkafka PUBLIC $,zstd::libzstd_shared,zstd::libzstd_static>) endif() if(WITH_SSL) @@ -17,7 +17,7 @@ if(WITH_LZ4_EXT) - target_include_directories(rdkafka PUBLIC ${LZ4_INCLUDE_DIRS}) - target_link_libraries(rdkafka PUBLIC LZ4::LZ4) -+ target_link_libraries(rdkafka PUBLIC CONAN_PKG::lz4) ++ target_link_libraries(rdkafka PUBLIC lz4::lz4) endif() # Set up path to these sources for other sub-projects (tests, examples) diff --git a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-6-1.patch b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-6-1.patch new file mode 100644 index 0000000000000..0a478997b2373 --- /dev/null +++ b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-6-1.patch @@ -0,0 +1,23 @@ +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -212,9 +212,7 @@ if(WITH_ZLIB) + endif() + + if(WITH_ZSTD) +- target_link_libraries(rdkafka PUBLIC ${ZSTD_LIBRARY}) +- target_include_directories(rdkafka PUBLIC ${ZSTD_INCLUDE_DIR}) +- message(STATUS "Found ZSTD: ${ZSTD_LIBRARY}") ++ target_link_libraries(rdkafka PUBLIC $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + + if(WITH_SSL) +@@ -253,8 +251,7 @@ if(WITH_LIBDL) + endif() + + if(WITH_LZ4_EXT) +- target_include_directories(rdkafka PUBLIC ${LZ4_INCLUDE_DIRS}) +- target_link_libraries(rdkafka PUBLIC LZ4::LZ4) ++ target_link_libraries(rdkafka PUBLIC lz4::lz4) + endif() + + # Set up path to these sources for other sub-projects (tests, examples) diff --git a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-7-0.patch b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-7-0.patch new file mode 100644 index 0000000000000..377bc8af8e437 --- /dev/null +++ b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-7-0.patch @@ -0,0 +1,37 @@ +From 994ad21e1a136e11d1dc5870d991b034e41e6a4c Mon Sep 17 00:00:00 2001 +From: Alejandro Colomar +Date: Sun, 30 May 2021 11:08:36 +0200 +Subject: [PATCH] Change library targets and result variables + +--- + src/CMakeLists.txt | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 6e24a238..4379c060 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -198,9 +198,7 @@ if(WITH_ZLIB) + endif() + + if(WITH_ZSTD) +- target_link_libraries(rdkafka PRIVATE ${ZSTD_LIBRARY}) +- target_include_directories(rdkafka PRIVATE ${ZSTD_INCLUDE_DIR}) +- message(STATUS "Found ZSTD: ${ZSTD_LIBRARY}") ++ target_link_libraries(rdkafka PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + + if(WITH_SSL) +@@ -239,8 +237,7 @@ if(WITH_LIBDL) + endif() + + if(WITH_LZ4_EXT) +- target_include_directories(rdkafka PRIVATE ${LZ4_INCLUDE_DIRS}) +- target_link_libraries(rdkafka PUBLIC LZ4::LZ4) ++ target_link_libraries(rdkafka PUBLIC lz4::lz4) + endif() + + if(WIN32) +-- +2.32.0.rc0 + diff --git a/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-9-1.patch b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-9-1.patch new file mode 100644 index 0000000000000..c3347279b9251 --- /dev/null +++ b/recipes/librdkafka/all/patches/0002-Change-library-targets-and-result-variables-1-9-1.patch @@ -0,0 +1,25 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 33b3ced..93f49b1 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -207,9 +207,7 @@ if(WITH_ZLIB) + endif() + + if(WITH_ZSTD) +- target_link_libraries(rdkafka PRIVATE ${ZSTD_LIBRARY}) +- target_include_directories(rdkafka PRIVATE ${ZSTD_INCLUDE_DIR}) +- message(STATUS "Found ZSTD: ${ZSTD_LIBRARY}") ++ target_link_libraries(rdkafka PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + + if(WITH_SSL) +@@ -248,8 +246,7 @@ if(WITH_LIBDL) + endif() + + if(WITH_LZ4_EXT) +- target_include_directories(rdkafka PRIVATE ${LZ4_INCLUDE_DIRS}) +- target_link_libraries(rdkafka PUBLIC LZ4::LZ4) ++ target_link_libraries(rdkafka PUBLIC lz4::lz4) + endif() + + if(WIN32) diff --git a/recipes/librdkafka/all/patches/0003-Fix-broken-version-1-4-0-on-windows.patch b/recipes/librdkafka/all/patches/0003-Fix-broken-version-1-4-0-on-windows.patch deleted file mode 100644 index 21cc2c8c3fdfb..0000000000000 --- a/recipes/librdkafka/all/patches/0003-Fix-broken-version-1-4-0-on-windows.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -132,7 +132,9 @@ if(WITHOUT_WIN32_CONFIG) - list(APPEND rdkafka_compile_definitions WITH_SASL_OAUTHBEARER) - endif(WITH_SASL_OAUTHBEARER) - if(ENABLE_DEVEL) -- list(APPEND rdkafka_compile_definitions ENABLE_DEVEL) -+ list(APPEND rdkafka_compile_definitions ENABLE_DEVEL=1) -+ else() -+ list(APPEND rdkafka_compile_definitions ENABLE_DEVEL=0) - endif(ENABLE_DEVEL) - if(WITH_PLUGINS) - list(APPEND rdkafka_compile_definitions WITH_PLUGINS) diff --git a/recipes/librdkafka/all/patches/0004-Change-library-names.patch b/recipes/librdkafka/all/patches/0004-Change-library-names.patch deleted file mode 100644 index 4ff46e1a7f124..0000000000000 --- a/recipes/librdkafka/all/patches/0004-Change-library-names.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -54,7 +54,7 @@ endif() - # } - - # ZSTD { --find_package(ZSTD QUIET) -+find_package(zstd QUIET) - if(ZSTD_FOUND) - set(with_zstd_default ON) - else() -@@ -133,6 +133,9 @@ else() - endif() - option(WITH_SASL "With SASL" ${with_sasl_default}) - if(WITH_SASL) -+ if(SASL_FOUND) -+ link_directories(${SASL_LIBRARY_DIRS}) -+ endif() - if(WITH_SSL) - set(WITH_SASL_SCRAM ON) - set(WITH_SASL_OAUTHBEARER ON) -@@ -149,7 +152,7 @@ endif() - option(ENABLE_LZ4_EXT "Enable external LZ4 library support" ON) - set(WITH_LZ4_EXT OFF) - if(ENABLE_LZ4_EXT) -- find_package(LZ4) -+ set(LZ4_FOUND ON) - if(LZ4_FOUND) - set(WITH_LZ4_EXT ON) - list(APPEND BUILT_WITH "LZ4_EXT") diff --git a/recipes/librdkafka/all/test_package/CMakeLists.txt b/recipes/librdkafka/all/test_package/CMakeLists.txt index 2a0ef606af807..636b897b6b9d6 100644 --- a/recipes/librdkafka/all/test_package/CMakeLists.txt +++ b/recipes/librdkafka/all/test_package/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C CXX) find_package(RdKafka REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test.cpp) -target_link_libraries(${PROJECT_NAME} RdKafka::rdkafka) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE RdKafka::rdkafka) + +add_executable(${PROJECT_NAME}_cpp test_package.cpp) +target_link_libraries(${PROJECT_NAME}_cpp PRIVATE RdKafka::rdkafka++) diff --git a/recipes/librdkafka/all/test_package/conanfile.py b/recipes/librdkafka/all/test_package/conanfile.py index 908f1227b2b55..6b68cbd742d30 100644 --- a/recipes/librdkafka/all/test_package/conanfile.py +++ b/recipes/librdkafka/all/test_package/conanfile.py @@ -1,11 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import CMake, ConanFile, tools +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" -class LibrdkafkaTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -13,6 +21,8 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "PackageTest") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package_cpp") + self.run(bin_path, env="conanrun") diff --git a/recipes/librdkafka/all/test_package/test.cpp b/recipes/librdkafka/all/test_package/test.cpp deleted file mode 100644 index 2b68c0545be73..0000000000000 --- a/recipes/librdkafka/all/test_package/test.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -int main(int argc, char const *argv[]) { - rd_kafka_conf_t *conf = rd_kafka_conf_new(); - std::cout << std::endl - << "----------------->Tests are done.<---------------------" << std::endl - << "Using version " << rd_kafka_version_str() << std::endl - << "///////////////////////////////////////////////////////" << std::endl; - return 0; -} diff --git a/recipes/librdkafka/all/test_package/test_package.c b/recipes/librdkafka/all/test_package/test_package.c new file mode 100644 index 0000000000000..9670aa9ff8583 --- /dev/null +++ b/recipes/librdkafka/all/test_package/test_package.c @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char const *argv[]) { + rd_kafka_conf_t *conf = rd_kafka_conf_new(); + + printf("\n"); + printf("----------------->Tests are done.<---------------------\n"); + printf("Using version (from C lib) %s\n", rd_kafka_version_str()); + printf("///////////////////////////////////////////////////////\n"); + return 0; +} diff --git a/recipes/librdkafka/all/test_package/test_package.cpp b/recipes/librdkafka/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..d1ea0762857ed --- /dev/null +++ b/recipes/librdkafka/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char const *argv[]) { + RdKafka::Conf* confpp = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL); + + std::cout << std::endl + << "----------------->Tests are done.<---------------------" << std::endl + << "Using version (from C++ lib) " << RdKafka::version() << std::endl + << "///////////////////////////////////////////////////////" << std::endl; + return 0; +} diff --git a/recipes/librdkafka/all/test_v1_package/CMakeLists.txt b/recipes/librdkafka/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/librdkafka/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/librdkafka/all/test_v1_package/conanfile.py b/recipes/librdkafka/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2be697c561678 --- /dev/null +++ b/recipes/librdkafka/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + bin_path = os.path.join("bin", "test_package_cpp") + self.run(bin_path, run_environment=True) diff --git a/recipes/librdkafka/config.yml b/recipes/librdkafka/config.yml index aa6f0679ec726..6ba7bbcf8c0bf 100644 --- a/recipes/librdkafka/config.yml +++ b/recipes/librdkafka/config.yml @@ -1,11 +1,17 @@ versions: - "1.3.0": + "1.9.2": folder: all - "1.4.0": + "1.9.1": folder: all - "1.5.2": + "1.8.2": folder: all - "1.5.3": + "1.8.0": + folder: all + "1.7.0": + folder: all + "1.6.1": folder: all "1.6.0": folder: all + "1.5.3": + folder: all diff --git a/recipes/librealsense/all/CMakeLists.txt b/recipes/librealsense/all/CMakeLists.txt new file mode 100644 index 0000000000000..c70003c936d89 --- /dev/null +++ b/recipes/librealsense/all/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +find_package(libusb REQUIRED) +set(USB_FOUND TRUE) +add_library(usb INTERFACE IMPORTED GLOBAL) +target_link_libraries(usb INTERFACE libusb::libusb) + +add_subdirectory("source_subfolder") diff --git a/recipes/librealsense/all/conandata.yml b/recipes/librealsense/all/conandata.yml new file mode 100644 index 0000000000000..15076b23713cf --- /dev/null +++ b/recipes/librealsense/all/conandata.yml @@ -0,0 +1,24 @@ +sources: + "2.49.0": + source: + url: "https://github.com/IntelRealSense/librealsense/archive/refs/tags/v2.49.0.tar.gz" + sha256: "2578ea0e75546aeebd908da732f52e0122bf37750d5a45f3adf92945a673aefd" + firmware: + - url: "https://librealsense.intel.com/Releases/RS4xx/FW/D4XX_FW_Image-5.12.15.50.bin" + sha256: "1030c06e0d266fd5a2704ba38d8615c88a86758034750e58e1656b90156a2d16" + - url: "https://librealsense.intel.com/Releases/SR300/FW/SR3XX_FW_Image-3.26.1.0.bin" + sha256: "c4ac2144df13c3a64fca9d16c175595c903e6e45f02f0f238630a223b07c14d1" + - url: "https://librealsense.intel.com/Releases/TM2/FW/target/0.2.0.951/target-0.2.0.951.mvcmd" + sha256: "0265fd111611908b822cdaf4a3fe5b631c50539b2805d2f364c498aa71c007c0" + - url: "https://librealsense.intel.com/Releases/L5xx/FW/L51X_FW_Image-1.5.8.1.bin" + sha256: "87a9a91b613d9d807b2bfc424abe9cac63cad75dfc04718592c44777cb0b4452" + - url: "https://librealsense.intel.com/Releases/L5xx/FW/L53X_FW_Image-3.5.5.1.bin" + sha256: "b837b2cff2b270b89eed3c0b212ab4108389a20b6e07c19dd5957918ff9ce7e0" +patches: + "2.49.0": + - patch_file: "patches/2.49.0-fix-cmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/2.49.0-fix-avx-check.patch" + base_path: "source_subfolder" + - patch_file: "patches/2.49.0-atlstr-removal.patch" + base_path: "source_subfolder" diff --git a/recipes/librealsense/all/conanfile.py b/recipes/librealsense/all/conanfile.py new file mode 100644 index 0000000000000..31f48b1512211 --- /dev/null +++ b/recipes/librealsense/all/conanfile.py @@ -0,0 +1,144 @@ +from conans import ConanFile, CMake, tools +import os +import urllib + + +class LibrealsenseConan(ConanFile): + name = "librealsense" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/IntelRealSense/librealsense" + description = "Intel(R) RealSense(tm) Cross Platform API for accessing Intel RealSense cameras." + topics = ("usb", "camera") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "tools": [True, False], + "rsusb_backend": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "tools": True, + "rsusb_backend": True, # TODO: change to False when CI gets MSVC ATL support + } + short_paths = True + generators = "cmake", "cmake_find_package" + exports_sources = ["CMakeLists.txt", "patches/*"] + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + else: + del self.options.rsusb_backend + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("libusb/1.0.24") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 14) + + def source(self): + sources = self.conan_data["sources"][self.version] + tools.get(**sources["source"], strip_root=True, destination=self._source_subfolder) + for firmware in sources["firmware"]: + filename = os.path.basename(urllib.parse.urlparse(firmware["url"]).path) + tools.download(filename=filename, **firmware) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + + self._cmake.definitions["CHECK_FOR_UPDATES"] = False + self._cmake.definitions["BUILD_WITH_STATIC_CRT"] = False + self._cmake.definitions["BUILD_EASYLOGGINGPP"] = False + self._cmake.definitions["BUILD_TOOLS"] = self.options.tools + self._cmake.definitions["BUILD_EXAMPLES"] = False + self._cmake.definitions["BUILD_GLSL_EXTENSIONS"] = False + self._cmake.definitions["BUILD_GRAPHICAL_EXAMPLES"] = False + self._cmake.definitions["BUILD_INTERNAL_UNIT_TESTS"] = False + self._cmake.definitions["BUILD_NETWORK_DEVICE"] = False + self._cmake.definitions["BUILD_UNIT_TESTS"] = False + self._cmake.definitions["BUILD_WITH_CUDA"] = False + self._cmake.definitions["BUILD_WITH_OPENMP"] = False + self._cmake.definitions["BUILD_WITH_TM2"] = True + self._cmake.definitions["BUILD_PYTHON_BINDINGS"] = False + self._cmake.definitions["BUILD_PYTHON_DOCS"] = False + self._cmake.definitions["BUILD_NODEJS_BINDINGS"] = False + self._cmake.definitions["BUILD_CV_EXAMPLES"] = False + self._cmake.definitions["BUILD_DLIB_EXAMPLES"] = False + self._cmake.definitions["BUILD_OPENVINO_EXAMPLES"] = False + self._cmake.definitions["BUILD_OPEN3D_EXAMPLES"] = False + self._cmake.definitions["BUILD_MATLAB_BINDINGS"] = False + self._cmake.definitions["BUILD_PCL_EXAMPLES"] = False + self._cmake.definitions["BUILD_UNITY_BINDINGS"] = False + self._cmake.definitions["BUILD_CSHARP_BINDINGS"] = False + self._cmake.definitions["BUILD_OPENNI2_BINDINGS"] = False + self._cmake.definitions["BUILD_CV_KINFU_EXAMPLE"] = False + if self.settings.os == "Windows": + self._cmake.definitions["FORCE_RSUSB_BACKEND"] = self.options.rsusb_backend + + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses", keep_path=False) + cmake = self._configure_cmake() + cmake.install() + if self.options.shared: + postfix = "d" if self.settings.compiler == "Visual Studio" and self.settings.build_type == "Debug" else "" + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "libfw{}.*".format(postfix)) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "librealsense-file{}.*".format(postfix)) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + postfix = "d" if self.settings.compiler == "Visual Studio" and self.settings.build_type == "Debug" else "" + + self.cpp_info.names["cmake_find_package"] = "realsense2" + self.cpp_info.names["cmake_find_package_multi"] = "realsense2" + + if not self.options.shared: + self.cpp_info.components["fw"].libs = ["fw" + postfix] + self.cpp_info.components["file"].libs = ["realsense-file" + postfix] + + self.cpp_info.components["realsense2"].libs = ["realsense2" + postfix] + self.cpp_info.components["realsense2"].requires = ["libusb::libusb"] + if not self.options.shared: + self.cpp_info.components["realsense2"].requires.extend(["file", "fw"]) + self.cpp_info.components["realsense2"].names["pkg_config"] = "realsense2" + if self.settings.os == "Linux": + self.cpp_info.components["realsense2"].system_libs.extend(["m", "pthread", "udev"]) + elif self.settings.os == "Windows": + self.cpp_info.components["realsense2"].system_libs.extend([ + "cfgmgr32", "setupapi", + "sensorsapi", "PortableDeviceGuids", + "winusb", + "shlwapi", "mf", "mfplat", "mfreadwrite", "mfuuid" + ]) diff --git a/recipes/librealsense/all/patches/2.49.0-atlstr-removal.patch b/recipes/librealsense/all/patches/2.49.0-atlstr-removal.patch new file mode 100644 index 0000000000000..4017cb83f524b --- /dev/null +++ b/recipes/librealsense/all/patches/2.49.0-atlstr-removal.patch @@ -0,0 +1,127 @@ +Removes Windows ATL libraries usage. Needed if your Visual Studio installation does +not have ATL libraries installed. + +This patch should be removed when Conan CI gets ATL support. @sh0 + +diff --git a/src/win/win-helpers.cpp b/src/win/win-helpers.cpp +index 643211fb6..e3efd7d93 100644 +--- a/src/win/win-helpers.cpp ++++ b/src/win/win-helpers.cpp +@@ -12,7 +12,7 @@ + #include + #include + #include +-#include ++//#include + #include + #include + #include +@@ -817,11 +817,11 @@ namespace librealsense + + create_and_open_status named_mutex::create_named_mutex(const char* camID) + { +- CString lstr; +- CString IDstr(camID); ++ //CString lstr; ++ //CString IDstr(camID); + // IVCAM_DLL string is left in librealsense to allow safe + // interoperability with existing tools like DCM +- lstr.Format(L"Global\\IVCAM_DLL_WINUSB_MUTEX%s", IDstr); ++ std::string lstr = std::string("Global\\IVCAM_DLL_WINUSB_MUTEX") + std::string(camID); + auto pSecDesc = make_allow_all_security_descriptor(); + if (pSecDesc) + { +@@ -830,10 +830,10 @@ namespace librealsense + SecAttr.lpSecurityDescriptor = pSecDesc; + SecAttr.bInheritHandle = FALSE; + +- _winusb_mutex = CreateMutex( ++ _winusb_mutex = CreateMutexA( + &SecAttr, + FALSE, +- lstr); ++ lstr.c_str()); + LocalFree(pSecDesc); + } + //CreateMutex failed +@@ -850,16 +850,16 @@ namespace librealsense + + create_and_open_status named_mutex::open_named_mutex(const char* camID) + { +- CString lstr; +- CString IDstr(camID); ++ //CString lstr; ++ //CString IDstr(camID); + // IVCAM_DLL string is left in librealsense to allow safe + // interoperability with existing tools like DCM +- lstr.Format(L"Global\\IVCAM_DLL_WINUSB_MUTEX%s", IDstr.GetString()); ++ std::string lstr = std::string("Global\\IVCAM_DLL_WINUSB_MUTEX") + std::string(camID); + +- _winusb_mutex = OpenMutex( ++ _winusb_mutex = OpenMutexA( + MUTEX_ALL_ACCESS, // request full access + FALSE, // handle not inheritable +- lstr); // object name ++ lstr.c_str()); // object name + + if (_winusb_mutex == nullptr) + { +diff --git a/src/winusb/device-winusb.cpp b/src/winusb/device-winusb.cpp +index cda8d44c2..92bb62566 100644 +--- a/src/winusb/device-winusb.cpp ++++ b/src/winusb/device-winusb.cpp +@@ -12,7 +12,7 @@ + #include "interface-winusb.h" + #include "types.h" + +-#include ++//#include + #include + #include + #include +diff --git a/src/winusb/device-winusb.h b/src/winusb/device-winusb.h +index dd942375a..a5449282f 100644 +--- a/src/winusb/device-winusb.h ++++ b/src/winusb/device-winusb.h +@@ -11,7 +11,7 @@ + #include "messenger-winusb.h" + + #include +-#include ++//#include + #include + #include + #include +@@ -47,4 +47,4 @@ namespace librealsense + std::vector> query_device_interfaces(const std::wstring& path); + }; + } +-} +\ No newline at end of file ++} +diff --git a/src/winusb/enumerator-winusb.cpp b/src/winusb/enumerator-winusb.cpp +index 4cab92403..051291670 100644 +--- a/src/winusb/enumerator-winusb.cpp ++++ b/src/winusb/enumerator-winusb.cpp +@@ -11,7 +11,7 @@ + #include "win/win-helpers.h" + #include "types.h" + +-#include ++//#include + #include + #include + #include +diff --git a/src/winusb/messenger-winusb.cpp b/src/winusb/messenger-winusb.cpp +index d5fab7c8d..d4ba7c350 100644 +--- a/src/winusb/messenger-winusb.cpp ++++ b/src/winusb/messenger-winusb.cpp +@@ -10,7 +10,7 @@ + #include "usb/usb-enumerator.h" + #include "types.h" + +-#include ++//#include + #include + #include + #include diff --git a/recipes/librealsense/all/patches/2.49.0-fix-avx-check.patch b/recipes/librealsense/all/patches/2.49.0-fix-avx-check.patch new file mode 100644 index 0000000000000..50c3e40f8f32d --- /dev/null +++ b/recipes/librealsense/all/patches/2.49.0-fix-avx-check.patch @@ -0,0 +1,13 @@ +diff --git a/src/proc/color-formats-converter.cpp b/src/proc/color-formats-converter.cpp +index cc0146a04..920b06c31 100644 +--- a/src/proc/color-formats-converter.cpp ++++ b/src/proc/color-formats-converter.cpp +@@ -18,7 +18,7 @@ + #include // For SSSE3 intrinsics + #endif + +-#if defined (ANDROID) || (defined (__linux__) && !defined (__x86_64__)) ++#if defined (ANDROID) || !(defined (_M_IX86) || defined (__i386__)) + + bool has_avx() { return false; } + diff --git a/recipes/librealsense/all/patches/2.49.0-fix-cmake.patch b/recipes/librealsense/all/patches/2.49.0-fix-cmake.patch new file mode 100644 index 0000000000000..a571906e24eca --- /dev/null +++ b/recipes/librealsense/all/patches/2.49.0-fix-cmake.patch @@ -0,0 +1,54 @@ +diff --git a/CMake/install_config.cmake b/CMake/install_config.cmake +index 9f5666611..2ca5625ce 100644 +--- a/CMake/install_config.cmake ++++ b/CMake/install_config.cmake +@@ -48,4 +48,4 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/config/realsense2.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" + ) + +-install(CODE "execute_process(COMMAND ldconfig)") ++# install(CODE "execute_process(COMMAND ldconfig)") +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0c15d9510..2c55dbe7b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.1.0) + project(librealsense2 LANGUAGES CXX C) + + include(CMake/lrs_options.cmake) +-include(CMake/connectivity_check.cmake) ++set(INTERNET_CONNECTION ON) + + #Deprecation message, should be removed in future releases + if(${FORCE_LIBUVC} OR ${FORCE_WINUSB_UVC} OR ${ANDROID_USB_HOST_UVC}) +diff --git a/common/fw/CMakeLists.txt b/common/fw/CMakeLists.txt +index 2772f59d8..8214145fc 100644 +--- a/common/fw/CMakeLists.txt ++++ b/common/fw/CMakeLists.txt +@@ -57,16 +57,16 @@ set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER Resources) + + function(target_binary url version sha1 symbol ext) + set(binary "${CMAKE_CURRENT_BINARY_DIR}/${symbol}-${version}${ext}") +- message(STATUS "${url}/${symbol}-${version}${ext}") +- file(DOWNLOAD "${url}/${symbol}-${version}${ext}" "${binary}" +- EXPECTED_HASH SHA1=${sha1} +- STATUS status) +- list(GET status 0 error_code) +- if (NOT ${error_code} EQUAL 0) +- message(FATAL_ERROR "Download firmwnare (${status}) - ${url}") +- else() +- message(STATUS "Download firmware ${status} for ${symbol}-${version}${ext}") +- endif() ++ # message(STATUS "${url}/${symbol}-${version}${ext}") ++ file(COPY "${CMAKE_SOURCE_DIR}/${symbol}-${version}${ext}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") ++ # EXPECTED_HASH SHA1=${sha1} ++ # STATUS status) ++ # list(GET status 0 error_code) ++ # if (NOT ${error_code} EQUAL 0) ++ # message(FATAL_ERROR "Download firmwnare (${status}) - ${url}") ++ # else() ++ # message(STATUS "Download firmware ${status} for ${symbol}-${version}${ext}") ++ # endif() + string(TOUPPER ${symbol} SYMBOL) + string(REPLACE "." "," version_commas ${version}) + string(REPLACE "\\" "\\\\" binary_escaped "${binary}") diff --git a/recipes/librealsense/all/test_package/CMakeLists.txt b/recipes/librealsense/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3bf9e7c362597 --- /dev/null +++ b/recipes/librealsense/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(realsense2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} realsense2::realsense2) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/librealsense/all/test_package/conanfile.py b/recipes/librealsense/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/librealsense/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/librealsense/all/test_package/test_package.cpp b/recipes/librealsense/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..b30e881e2d57d --- /dev/null +++ b/recipes/librealsense/all/test_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + rs2::context context; + return EXIT_SUCCESS; +} diff --git a/recipes/librealsense/config.yml b/recipes/librealsense/config.yml new file mode 100644 index 0000000000000..3505cc5770e1a --- /dev/null +++ b/recipes/librealsense/config.yml @@ -0,0 +1,3 @@ +versions: + "2.49.0": + folder: all diff --git a/recipes/libressl/all/conandata.yml b/recipes/libressl/all/conandata.yml index f4481681c3c71..8d70158fca32f 100644 --- a/recipes/libressl/all/conandata.yml +++ b/recipes/libressl/all/conandata.yml @@ -1,13 +1,22 @@ sources: - "2.9.2": - url: "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.9.2.tar.gz" - sha256: "c4c78167fae325b47aebd8beb54b6041d6f6a56b3743f4bd5d79b15642f9d5d4" - "3.0.2": - url: "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.0.2.tar.gz" - sha256: "df7b172bf79b957dd27ef36dcaa1fb162562c0e8999e194aa8c1a3df2f15398e" - "3.2.0": - url: "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.2.0.tar.gz" - sha256: "47bd2eb4b4503e47c02efa7e67d2fcd95c7eac6bc9d06b343a1b4705793ed1d5" + "3.5.3": + url: "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.5.3.tar.gz" + sha256: "3ab5e5eaef69ce20c6b170ee64d785b42235f48f2e62b095fca5d7b6672b8b28" + "3.5.2": + url: "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.5.2.tar.gz" + sha256: "56feab8e21c3fa6549f8b7d7511658b8e98518162838a795314732654adf3e5f" + "3.4.3": + url: "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.4.3.tar.gz" + sha256: "ff88bffe354818b3ccf545e3cafe454c5031c7a77217074f533271d63c37f08d" "3.2.1": url: "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.2.1.tar.gz" sha256: "d28db224cfb6d18009b2a7e8cb213cd5c943bbec87550062fef6a38479250315" + "3.2.0": + url: "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.2.0.tar.gz" + sha256: "47bd2eb4b4503e47c02efa7e67d2fcd95c7eac6bc9d06b343a1b4705793ed1d5" + "3.0.2": + url: "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.0.2.tar.gz" + sha256: "df7b172bf79b957dd27ef36dcaa1fb162562c0e8999e194aa8c1a3df2f15398e" + "2.9.2": + url: "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.9.2.tar.gz" + sha256: "c4c78167fae325b47aebd8beb54b6041d6f6a56b3743f4bd5d79b15642f9d5d4" diff --git a/recipes/libressl/all/conanfile.py b/recipes/libressl/all/conanfile.py index 6c23ec012efca..9a8502155e59c 100644 --- a/recipes/libressl/all/conanfile.py +++ b/recipes/libressl/all/conanfile.py @@ -1,30 +1,48 @@ +from conan.tools.microsoft import msvc_runtime_flag from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration import glob import os +required_conan_version = ">=1.43.0" + class LibreSSLConan(ConanFile): name = "libressl" - provides = "openssl" + topics = ("SSL", "TLS", "openssl") + description = ( + "LibreSSL is a version of the TLS/crypto stack forked from OpenSSL in " + "2014, with goals of modernizing the codebase, improving security, and " + "applying best practice development processes." + ) url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.libressl.org/" license = ("OpenSSL", "BSD", "ISC") - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + + provides = "openssl" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + exports_sources = "CMakeLists.txt" generators = "cmake" - topics = ("SSL", "TLS", "openssl") - description = ("LibreSSL is a version of the TLS/crypto stack forked from OpenSSL in 2014, " - "with goals of modernizing the codebase, improving security, and applying " - "best practice development processes.") - _cmake = None @property def _source_subfolder(self): return "source_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -35,10 +53,19 @@ def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def validate(self): + if self.options.shared and self._is_msvc and "MT" in msvc_runtime_flag(self): + raise ConanInvalidConfiguration("Static runtime linked into shared LibreSSL not supported") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + if tools.Version(self.version) >= "3.1.1": + tools.replace_in_file( + os.path.join(self._source_subfolder, "CMakeLists.txt"), + "cmake_minimum_required (VERSION 3.16.4)", + "cmake_minimum_required (VERSION 3.15.6)" + ) def _configure_cmake(self): if self._cmake: @@ -50,7 +77,7 @@ def _configure_cmake(self): self._cmake.definitions["ENABLE_ASM"] = True self._cmake.definitions["ENABLE_EXTRATESTS"] = False self._cmake.definitions["ENABLE_NC"] = False - self._cmake.definitions["OPENSSLDIR"] = "C:/Windows/libressl/ssl" if self.settings.os == "Windows" else "/etc/ssl" + self._cmake.definitions["OPENSSLDIR"] = os.path.join(self.package_folder, "res") self._cmake.configure() return self._cmake @@ -62,41 +89,51 @@ def package(self): self.copy("*COPYING", dst="licenses", keep_path=False) cmake = self._configure_cmake() cmake.install() - for cmake_file in glob.glob(os.path.join(self.package_folder, "include", "*.cmake")): - os.remove(cmake_file) + tools.remove_files_by_mask(os.path.join(self.package_folder, "include"), "*.cmake") tools.rmdir(os.path.join(self.package_folder, "include", "CMakeFiles")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) tools.rmdir(os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "LibreSSL" - self.cpp_info.names["cmake_find_package_multi"] = "LibreSSL" + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "LibreSSL") + self.cpp_info.set_property("pkg_config_name", "openssl") + # Crypto - self.cpp_info.components["crypto"].names["cmake_find_package"] = "Crypto" - self.cpp_info.components["crypto"].names["cmake_find_package_multi"] = "Crypto" - self.cpp_info.components["crypto"].names["pkg_config"] = "libcrypto" + self.cpp_info.components["crypto"].set_property("cmake_target_name", "LibreSSL::Crypto") + self.cpp_info.components["crypto"].set_property("pkg_config_name", "libcrypto") self.cpp_info.components["crypto"].libs = [self._lib_name("crypto")] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["crypto"].system_libs = ["pthread", "rt"] elif self.settings.os == "SunOS": self.cpp_info.components["crypto"].system_libs = ["nsl", "socket"] elif self.settings.os == "Windows": self.cpp_info.components["crypto"].system_libs = ["ws2_32"] + if tools.Version(self.version) >= "3.3.0": + self.cpp_info.components["crypto"].system_libs.append("bcrypt") + # SSL - self.cpp_info.components["ssl"].names["cmake_find_package"] = "SSL" - self.cpp_info.components["ssl"].names["cmake_find_package_multi"] = "SSL" - self.cpp_info.components["ssl"].names["pkg_config"] = "libssl" + self.cpp_info.components["ssl"].set_property("cmake_target_name", "LibreSSL::SSL") + self.cpp_info.components["ssl"].set_property("pkg_config_name", "libssl") self.cpp_info.components["ssl"].libs = [self._lib_name("ssl")] self.cpp_info.components["ssl"].requires = ["crypto"] + # TLS - self.cpp_info.components["tls"].names["cmake_find_package"] = "TLS" - self.cpp_info.components["tls"].names["cmake_find_package_multi"] = "TLS" - self.cpp_info.components["tls"].names["pkg_config"] = "libtls" + self.cpp_info.components["tls"].set_property("cmake_target_name", "LibreSSL::TLS") + self.cpp_info.components["tls"].set_property("pkg_config_name", "libtls") self.cpp_info.components["tls"].libs = [self._lib_name("tls")] self.cpp_info.components["tls"].requires = ["crypto", "ssl"] - # openssl - self.cpp_info.components["openssl"].names["pkg_config"] = "openssl" - self.cpp_info.components["openssl"].requires = ["crypto", "ssl"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "LibreSSL" + self.cpp_info.names["cmake_find_package_multi"] = "LibreSSL" + self.cpp_info.names["pkg_config"] = "openssl" + self.cpp_info.components["crypto"].names["cmake_find_package"] = "Crypto" + self.cpp_info.components["crypto"].names["cmake_find_package_multi"] = "Crypto" + self.cpp_info.components["ssl"].names["cmake_find_package"] = "SSL" + self.cpp_info.components["ssl"].names["cmake_find_package_multi"] = "SSL" + self.cpp_info.components["tls"].names["cmake_find_package"] = "TLS" + self.cpp_info.components["tls"].names["cmake_find_package_multi"] = "TLS" def _lib_name(self, name): libressl_version = tools.Version(self.version) diff --git a/recipes/libressl/all/test_package/CMakeLists.txt b/recipes/libressl/all/test_package/CMakeLists.txt index 44efd546835aa..7bc887201a50d 100644 --- a/recipes/libressl/all/test_package/CMakeLists.txt +++ b/recipes/libressl/all/test_package/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(LibreSSL REQUIRED) diff --git a/recipes/libressl/all/test_package/conanfile.py b/recipes/libressl/all/test_package/conanfile.py index b48d108144758..19e6a0c06e3d8 100644 --- a/recipes/libressl/all/test_package/conanfile.py +++ b/recipes/libressl/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "arch", "build_type" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libressl/config.yml b/recipes/libressl/config.yml index ee5e61e279e70..bfca6d19b58d7 100644 --- a/recipes/libressl/config.yml +++ b/recipes/libressl/config.yml @@ -1,9 +1,15 @@ versions: - "2.9.2": + "3.5.3": folder: all - "3.0.2": + "3.5.2": folder: all - "3.2.0": + "3.4.3": folder: all "3.2.1": folder: all + "3.2.0": + folder: all + "3.0.2": + folder: all + "2.9.2": + folder: all diff --git a/recipes/librhash/all/conandata.yml b/recipes/librhash/all/conandata.yml index 737dc6aa35faf..7551a33f27039 100644 --- a/recipes/librhash/all/conandata.yml +++ b/recipes/librhash/all/conandata.yml @@ -1,4 +1,11 @@ sources: + "1.4.2": + url: "https://downloads.sourceforge.net/project/rhash/rhash/1.4.2/rhash-1.4.2-src.tar.gz" + sha256: "600d00f5f91ef04194d50903d3c79412099328c42f28ff43a0bdb777b00bec62" "1.3.9": - sha256: 42b1006f998adb189b1f316bf1a60e3171da047a85c4aaded2d0d26c1476c9f6 - url: https://downloads.sourceforge.net/project/rhash/rhash/1.3.9/rhash-1.3.9-src.tar.gz + url: "https://downloads.sourceforge.net/project/rhash/rhash/1.3.9/rhash-1.3.9-src.tar.gz" + sha256: "42b1006f998adb189b1f316bf1a60e3171da047a85c4aaded2d0d26c1476c9f6" +patches: + "1.4.2": + - patch_file: "patches/0001-1.4.2-fix-compiler-detection.patch" + base_path: "source_subfolder" diff --git a/recipes/librhash/all/conanfile.py b/recipes/librhash/all/conanfile.py index a06cee6805eaf..5528b9c183b00 100644 --- a/recipes/librhash/all/conanfile.py +++ b/recipes/librhash/all/conanfile.py @@ -1,17 +1,17 @@ -import os from conans import AutoToolsBuildEnvironment, ConanFile, tools from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" class LibRHashConan(ConanFile): name = "librhash" description = "Great utility for computing hash sums" - topics = ("conan", "rhash", "hash", "checksum") + topics = ("rhash", "hash", "checksum") url = "https://github.com/conan-io/conan-center-index" homepage = "http://rhash.sourceforge.net/" license = "MIT" - exports_sources = "CMakeLists.txt", - generators = "cmake", settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -24,59 +24,79 @@ class LibRHashConan(ConanFile): "with_openssl": True, } + exports_sources = "patches/*" _autotools = None + @property def _source_subfolder(self): return "source_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("Visual Studio is not supported") - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx if self.options.shared: del self.options.fPIC - - def build_requirements(self): - if tools.os_info.is_windows and "CONAN_BASH_PATH" not in os.environ: - self.build_requires("msys2/20190524") + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx def requirements(self): if self.options.with_openssl: - self.requires("openssl/1.1.1i") + self.requires("openssl/1.1.1q") + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def validate(self): + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("Visual Studio is not supported") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "RHash-{}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_autotools(self): if self._autotools: return self._autotools self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + if self.settings.compiler in ("apple-clang", ): + if self.settings.arch in ("armv7", ): + self._autotools.link_flags.append("-arch armv7") + elif self.settings.arch in ("armv8", ): + self._autotools.link_flags.append("-arch arm64") + vars = self._autotools.vars conf_args = [ + # librhash's configure script does not understand `--enable-opt1=yes` "--enable-openssl" if self.options.with_openssl else "--disable-openssl", "--disable-gettext", # librhash's configure script is custom and does not understand "--bindir=${prefix}/bin" arguments "--prefix={}".format(tools.unix_path(self.package_folder)), "--bindir={}".format(tools.unix_path(os.path.join(self.package_folder, "bin"))), "--libdir={}".format(tools.unix_path(os.path.join(self.package_folder, "lib"))), - "--extra-cflags={}".format(self._autotools.vars["CPPFLAGS"]), - "--extra-ldflags={}".format(self._autotools.vars["LDFLAGS"]), + # the configure script does not use CPPFLAGS, so add it to CFLAGS/CXXFLAGS + "--extra-cflags={}".format("{} {}".format(vars["CFLAGS"], vars["CPPFLAGS"])), + "--extra-ldflags={}".format(vars["LDFLAGS"]), ] if self.options.shared: conf_args.extend(["--enable-lib-shared", "--disable-lib-static"]) else: conf_args.extend(["--disable-lib-shared", "--enable-lib-static"]) - self._autotools.configure(args=conf_args, use_default_install_dirs=False) + with tools.environment_append({ + "BUILD_TARGET": tools.get_gnu_triplet(str(self.settings.os), str(self.settings.arch), str(self.settings.compiler)), + }): + self._autotools.configure(args=conf_args, use_default_install_dirs=False, build=False, host=False) return self._autotools def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) with tools.chdir(self._source_subfolder): autotools = self._configure_autotools() autotools.make() @@ -97,4 +117,5 @@ def package(self): def package_info(self): self.cpp_info.names["cmake_find_package"] = "LibRHash" self.cpp_info.names["cmake_find_package_multi"] = "LibRHash" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.names["pkg_config"] = "librhash" + self.cpp_info.libs = ["rhash"] diff --git a/recipes/librhash/all/patches/0001-1.4.2-fix-compiler-detection.patch b/recipes/librhash/all/patches/0001-1.4.2-fix-compiler-detection.patch new file mode 100644 index 0000000000000..f6e51246e4dea --- /dev/null +++ b/recipes/librhash/all/patches/0001-1.4.2-fix-compiler-detection.patch @@ -0,0 +1,29 @@ +Revert compiler detection to state of 1.3.9 + +--- configure ++++ configure +@@ -513,14 +513,9 @@ + CC_TMP="$CC" + test -n "$OPT_CC" && OTHER_CC= || OTHER_CC="gcc cc" + for CC in "$CC_TMP" $OTHER_CC; do +- cc_name_tmp= + if run_cmd "$CC -v"; then + cc_name_tmp=$($CC -v 2>&1 | tail -n 1 | cut -d ' ' -f 1) +- elif run_cmd "$CC --version"; then +- cc_name_tmp=$($CC --version 2>&1 | head -n 1 | cut -d ' ' -f 1) +- fi +- if test -n "${cc_name_tmp}"; then +- if echo "$cc_name_tmp" | grep -q "gcc"; then ++ if test "$cc_name_tmp" = "gcc"; then + cc_name=$cc_name_tmp + start_check "$CC version" + cc_vendor=gnu +@@ -544,7 +539,7 @@ + finish_check "$cc_name $cc_version" + break + fi +- if echo "$cc_name_tmp" | grep -q "clang"; then ++ if $CC -v 2>&1 | grep -q "clang"; then + start_check "$CC version" + cc_vendor=clang + cc_version=$($CC -dumpversion 2>&1) diff --git a/recipes/librhash/all/test_package/CMakeLists.txt b/recipes/librhash/all/test_package/CMakeLists.txt index 545cfc887bc7c..80f208bb6a15a 100644 --- a/recipes/librhash/all/test_package/CMakeLists.txt +++ b/recipes/librhash/all/test_package/CMakeLists.txt @@ -1,9 +1,10 @@ cmake_minimum_required(VERSION 3.3) -project(test_package CXX) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() -set(CMAKE_CXX_STANDARD 11) +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} example.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +find_package(LibRHash CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE LibRHash::LibRHash) diff --git a/recipes/librhash/all/test_package/conanfile.py b/recipes/librhash/all/test_package/conanfile.py index d29752a71cea7..2c7657d70d5d9 100644 --- a/recipes/librhash/all/test_package/conanfile.py +++ b/recipes/librhash/all/test_package/conanfile.py @@ -1,10 +1,10 @@ -import os from conans import ConanFile, CMake, tools +import os class SolaceTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,5 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/librhash/all/test_package/example.cpp b/recipes/librhash/all/test_package/example.cpp deleted file mode 100644 index f14d18b12fd50..0000000000000 --- a/recipes/librhash/all/test_package/example.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "rhash.h" - -#include -#include - -#define MSG "hello world" -#define SHA256_REF "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" - -int main() { - rhash_library_init(); - unsigned char rhash_bin_buffer[128]; - char rhash_char_buffer[128]; - rhash_msg(RHASH_SHA256, MSG, strlen(MSG), rhash_bin_buffer); - int nb = rhash_print_bytes(rhash_char_buffer, rhash_bin_buffer, rhash_get_hash_length(RHASH_SHA256), RHPR_HEX); - rhash_char_buffer[rhash_get_hash_length(RHASH_SHA256)] = '\0'; - printf("calculated SHA256 hash= %s\n", rhash_char_buffer); - - printf("reference SHA256 hash= %s\n", SHA256_REF); - return strcmp(rhash_char_buffer, SHA256_REF); -} diff --git a/recipes/librhash/all/test_package/test_package.c b/recipes/librhash/all/test_package/test_package.c new file mode 100644 index 0000000000000..029374c3a9841 --- /dev/null +++ b/recipes/librhash/all/test_package/test_package.c @@ -0,0 +1,20 @@ +#include "rhash.h" + +#include +#include + +#define MSG "hello world" +#define SHA256_REF "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" + +int main() { + rhash_library_init(); + unsigned char rhash_bin_buffer[128]; + char rhash_char_buffer[128]; + rhash_msg(RHASH_SHA256, MSG, strlen(MSG), rhash_bin_buffer); + int nb = rhash_print_bytes(rhash_char_buffer, rhash_bin_buffer, rhash_get_hash_length(RHASH_SHA256), RHPR_HEX); + rhash_char_buffer[rhash_get_hash_length(RHASH_SHA256)] = '\0'; + printf("calculated SHA256 hash= %s\n", rhash_char_buffer); + + printf("reference SHA256 hash= %s\n", SHA256_REF); + return strcmp(rhash_char_buffer, SHA256_REF); +} diff --git a/recipes/librhash/config.yml b/recipes/librhash/config.yml index 5247a10680de4..24eb5d89c9135 100644 --- a/recipes/librhash/config.yml +++ b/recipes/librhash/config.yml @@ -1,3 +1,5 @@ versions: + 1.4.2: + folder: all 1.3.9: folder: all diff --git a/recipes/librttopo/all/CMakeLists.txt b/recipes/librttopo/all/CMakeLists.txt new file mode 100644 index 0000000000000..34ff2e19a69a6 --- /dev/null +++ b/recipes/librttopo/all/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.4) +project(rttopo LANGUAGES C) + +set(RTTOPO_HDR_DIR ${LIBRTTOPO_SRC_DIR}/headers) + +set(SRID_MAX 999999) +set(SRID_USR_MAX 998999) +configure_file(${RTTOPO_HDR_DIR}/librttopo_geom.h.in librttopo_geom.h @ONLY) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/rttopo_config.h "") + +file(GLOB RTTOPO_SRC_FILES ${LIBRTTOPO_SRC_DIR}/src/*.c) +add_library(${PROJECT_NAME} ${RTTOPO_SRC_FILES}) +target_compile_definitions(${PROJECT_NAME} PRIVATE + $<$:_CRT_SECURE_NO_WARNINGS> + RTGEOM_DEBUG_LEVEL=0 + LIBRTGEOM_VERSION="${LIBRTGEOM_VERSION_MAJOR}.${LIBRTGEOM_VERSION_MINOR}.${LIBRTGEOM_VERSION_PATCH}" + RTGEOM_GEOS_VERSION=${RTGEOM_GEOS_VERSION} +) +set_target_properties(${PROJECT_NAME} PROPERTIES + WINDOWS_EXPORT_ALL_SYMBOLS ON + SOVERSION ${LIBRTGEOM_VERSION_MAJOR} +) +target_include_directories(${PROJECT_NAME} PUBLIC ${RTTOPO_HDR_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + +find_package(geos REQUIRED CONFIG) +target_link_libraries(${PROJECT_NAME} PUBLIC GEOS::geos_c) + +find_library(M_LIB m) +if(M_LIB) + target_link_libraries(${PROJECT_NAME} PRIVATE m) +endif() + +include(GNUInstallDirs) +install( + TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +install(FILES ${RTTOPO_HDR_DIR}/librttopo.h ${CMAKE_CURRENT_BINARY_DIR}/librttopo_geom.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/librttopo/all/conandata.yml b/recipes/librttopo/all/conandata.yml new file mode 100644 index 0000000000000..8563feebea0b6 --- /dev/null +++ b/recipes/librttopo/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.1.0": + url: "https://gitlab.com/rttopo/rttopo/-/archive/librttopo-1.1.0/rttopo-librttopo-1.1.0.tar.bz2" + sha256: "4b28732c0322849c8754751a384ee3596d06ab316dfc57fe9bbe757c82a27efe" diff --git a/recipes/librttopo/all/conanfile.py b/recipes/librttopo/all/conanfile.py new file mode 100644 index 0000000000000..542adb14927a1 --- /dev/null +++ b/recipes/librttopo/all/conanfile.py @@ -0,0 +1,87 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" + + +class LibrttopoConan(ConanFile): + name = "librttopo" + description = ( + "The RT Topology Library exposes an API to create and manage " + "standard (ISO 13249 aka SQL/MM) topologies." + ) + license = "GPL-2.0-or-later" + topics = ("librttopo", "topology", "geospatial", "gis") + homepage = "https://git.osgeo.org/gitea/rttopo/librttopo" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def requirements(self): + self.requires("geos/3.11.0") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBRTTOPO_SRC_DIR"] = self.source_folder.replace("\\", "/") + librttopo_version = Version(self.version) + tc.variables["LIBRTGEOM_VERSION_MAJOR"] = librttopo_version.major + tc.variables["LIBRTGEOM_VERSION_MINOR"] = librttopo_version.minor + tc.variables["LIBRTGEOM_VERSION_PATCH"] = librttopo_version.patch + geos_version = Version(self.dependencies["geos"].ref.version) + tc.variables["RTGEOM_GEOS_VERSION"] = f"{geos_version.major}{geos_version.minor}" + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "rttopo") + self.cpp_info.libs = ["rttopo"] + self.cpp_info.requires = ["geos::geos_c"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/librttopo/all/test_package/CMakeLists.txt b/recipes/librttopo/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..5871be92e3e0b --- /dev/null +++ b/recipes/librttopo/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(librttopo REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE librttopo::librttopo) diff --git a/recipes/librttopo/all/test_package/conanfile.py b/recipes/librttopo/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/librttopo/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/librttopo/all/test_package/test_package.c b/recipes/librttopo/all/test_package/test_package.c new file mode 100644 index 0000000000000..655926daf39d7 --- /dev/null +++ b/recipes/librttopo/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include + +#include + +int main(void) { + printf("%s\n", rtgeom_version()); + return 0; +} diff --git a/recipes/librttopo/all/test_v1_package/CMakeLists.txt b/recipes/librttopo/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9f3cc8b4782d6 --- /dev/null +++ b/recipes/librttopo/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(librttopo REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE librttopo::librttopo) diff --git a/recipes/librttopo/all/test_v1_package/conanfile.py b/recipes/librttopo/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/librttopo/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/librttopo/config.yml b/recipes/librttopo/config.yml new file mode 100644 index 0000000000000..b5c0d3cb2d409 --- /dev/null +++ b/recipes/librttopo/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.0": + folder: all diff --git a/recipes/libsafec/all/conanfile.py b/recipes/libsafec/all/conanfile.py index 6a639675781e1..5e2784dc36adc 100644 --- a/recipes/libsafec/all/conanfile.py +++ b/recipes/libsafec/all/conanfile.py @@ -12,23 +12,45 @@ class LibSafeCConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/rurban/safeclib" license = "MIT" - topics = ("conan", "safec", "libc") + topics = ("safec", "libc", "bounds-checking") settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } exports_sources = "patches/*" + _autotools = None @property def _source_subfolder(self): return "source_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def build_requirements(self): + self.build_requires("libtool/2.4.6") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + @property def _supported_compiler(self): compiler = self.settings.compiler @@ -39,20 +61,13 @@ def _supported_compiler(self): return False return True - def configure(self): + def validate(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + raise ConanInvalidConfiguration("This platform is not yet supported by libsafec (os=Macos arch=armv8)") if not self._supported_compiler: raise ConanInvalidConfiguration( "libsafec doesn't support {}/{}".format( self.settings.compiler, self.settings.compiler.version)) - if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - - def build_requirements(self): - self.build_requires("libtool/2.4.6") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") def source(self): tools.get(**self.conan_data["sources"][self.version], @@ -62,14 +77,15 @@ def _configure_autotools(self): if self._autotools: return self._autotools self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - if self.options.shared: - args = ["--enable-shared", "--disable-static"] - else: - args = ["--disable-shared", "--enable-static"] - args.extend(["--disable-doc", "--disable-Werror"]) - if self.settings.build_type in ("Debug", "RelWithDebInfo"): - args.append("--enable-debug") - self._autotools.configure(configure_dir=self._source_subfolder, args=args) + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")), + "--disable-doc", + "--disable-Werror", + ] + self._autotools.configure(args=args, configure_dir=self._source_subfolder) return self._autotools def build(self): diff --git a/recipes/libsafec/all/test_package/conanfile.py b/recipes/libsafec/all/test_package/conanfile.py index 8fc4d845e0a4a..b7cd0e8fa4f62 100644 --- a/recipes/libsafec/all/test_package/conanfile.py +++ b/recipes/libsafec/all/test_package/conanfile.py @@ -1,6 +1,5 @@ -import os - from conans import CMake, ConanFile, tools +import os class TestPackageConan(ConanFile): @@ -13,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libsamplerate/all/conandata.yml b/recipes/libsamplerate/all/conandata.yml new file mode 100644 index 0000000000000..926e264c998d5 --- /dev/null +++ b/recipes/libsamplerate/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "0.2.2": + url: "https://github.com/libsndfile/libsamplerate/archive/0.2.2.tar.gz" + sha256: "16e881487f184250deb4fcb60432d7556ab12cb58caea71ef23960aec6c0405a" + "0.2.1": + url: "https://github.com/libsndfile/libsamplerate/releases/download/0.2.1/libsamplerate-0.2.1.tar.bz2" + sha256: "f6323b5e234753579d70a0af27796dde4ebeddf58aae4be598e39b3cee00c90a" diff --git a/recipes/libsamplerate/all/conanfile.py b/recipes/libsamplerate/all/conanfile.py new file mode 100644 index 0000000000000..55b233bda77e4 --- /dev/null +++ b/recipes/libsamplerate/all/conanfile.py @@ -0,0 +1,105 @@ +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, replace_in_file, rmdir +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.51.3" + + +class LibsamplerateConan(ConanFile): + name = "libsamplerate" + description = ( + "libsamplerate (also known as Secret Rabbit Code) is a library for " + "performing sample rate conversion of audio data." + ) + license = "BSD-2-Clause" + topics = ("libsamplerate", "audio", "resample-audio-files") + homepage = "https://github.com/libsndfile/libsamplerate" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def build_requirements(self): + if is_apple_os(self) and self.options.shared and Version(self.version) >= "0.2.2": + # At least CMake 3.17 (see https://github.com/libsndfile/libsamplerate/blob/0.2.2/src/CMakeLists.txt#L110-L119) + self.tool_requires("cmake/3.24.0") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBSAMPLERATE_EXAMPLES"] = False + tc.variables["LIBSAMPLERATE_INSTALL"] = True + tc.variables["BUILD_TESTING"] = False + tc.generate() + + env = VirtualBuildEnv(self) + env.generate() + + def _patch_sources(self): + # Disable upstream logic about msvc runtime policy, called before conan toolchain resolution + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "cmake_policy(SET CMP0091 OLD)", "") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "SampleRate") + self.cpp_info.set_property("cmake_target_name", "SampleRate::samplerate") + self.cpp_info.set_property("pkg_config_name", "samplerate") + # TODO: back to global scope once cmake_find_package* generators removed + self.cpp_info.components["samplerate"].libs = ["samplerate"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["samplerate"].system_libs.append("m") + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "SampleRate" + self.cpp_info.names["cmake_find_package_multi"] = "SampleRate" + self.cpp_info.names["pkg_config"] = "samplerate" + self.cpp_info.components["samplerate"].names["cmake_find_package"] = "samplerate" + self.cpp_info.components["samplerate"].names["cmake_find_package_multi"] = "samplerate" + self.cpp_info.components["samplerate"].set_property("cmake_target_name", "SampleRate::samplerate") diff --git a/recipes/libsamplerate/all/test_package/CMakeLists.txt b/recipes/libsamplerate/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..cae81ee05d0e0 --- /dev/null +++ b/recipes/libsamplerate/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(SampleRate REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE SampleRate::samplerate) diff --git a/recipes/libsamplerate/all/test_package/conanfile.py b/recipes/libsamplerate/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/libsamplerate/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libsamplerate/all/test_package/test_package.c b/recipes/libsamplerate/all/test_package/test_package.c new file mode 100644 index 0000000000000..68781083a8cc0 --- /dev/null +++ b/recipes/libsamplerate/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include + +#include + +int main(void) { + printf("%s\n", src_get_version()); + return 0; +} diff --git a/recipes/libsamplerate/all/test_v1_package/CMakeLists.txt b/recipes/libsamplerate/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..1fa80ec806e05 --- /dev/null +++ b/recipes/libsamplerate/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(SampleRate REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE SampleRate::samplerate) diff --git a/recipes/libsamplerate/all/test_v1_package/conanfile.py b/recipes/libsamplerate/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libsamplerate/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libsamplerate/config.yml b/recipes/libsamplerate/config.yml new file mode 100644 index 0000000000000..0fc2e4cb164bd --- /dev/null +++ b/recipes/libsamplerate/config.yml @@ -0,0 +1,5 @@ +versions: + "0.2.2": + folder: all + "0.2.1": + folder: all diff --git a/recipes/libsass/all/conandata.yml b/recipes/libsass/all/conandata.yml index f6de4756c1cae..a3583eec521db 100644 --- a/recipes/libsass/all/conandata.yml +++ b/recipes/libsass/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.6.5": + url: "https://github.com/sass/libsass/archive/3.6.5.tar.gz" + sha256: "89d8f2c46ae2b1b826b58ce7dde966a176bac41975b82e84ad46b01a55080582" "3.6.4": sha256: f9484d9a6df60576e791566eab2f757a97fd414fce01dd41fc0a693ea5db2889 url: https://github.com/sass/libsass/archive/3.6.4.tar.gz diff --git a/recipes/libsass/all/conanfile.py b/recipes/libsass/all/conanfile.py index f25db37cb13b1..374c7b2afb2fd 100644 --- a/recipes/libsass/all/conanfile.py +++ b/recipes/libsass/all/conanfile.py @@ -1,8 +1,11 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.files import get, chdir, save, replace_in_file, rmdir, rm +from conan.tools.microsoft import is_msvc +from conans import AutoToolsBuildEnvironment, MSBuild, tools import os +import re -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.52.0" class LibsassConan(ConanFile): @@ -13,8 +16,14 @@ class LibsassConan(ConanFile): description = "A C/C++ implementation of a Sass compiler" topics = ("Sass", "LibSass", "compiler") settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } _autotools = None @@ -33,19 +42,14 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler == "Visual Studio": - # TODO: add Visual Studio support - raise ConanInvalidConfiguration("Visual Studio not yet supported in libsass recipe") def build_requirements(self): if self.settings.os != "Windows": - self.build_requires("autoconf/2.69") - self.build_requires("libtool/2.4.6") + self.tool_requires("libtool/2.4.7") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - tools.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_autotools(self): if self._autotools: @@ -59,8 +63,8 @@ def _configure_autotools(self): return self._autotools def _build_autotools(self): - with tools.chdir(self._source_subfolder): - tools.save(path="VERSION", content="%s" % self.version) + with chdir(self, self._source_subfolder): + save(self, path="VERSION", content=f"{self.version}") self.run("{} -fiv".format(tools.get_env("AUTORECONF"))) autotools = self._configure_autotools() autotools.make() @@ -71,10 +75,10 @@ def _make_program(self): def _build_mingw(self): makefile = os.path.join(self._source_subfolder, "Makefile") - tools.replace_in_file(makefile, "CFLAGS += -O2", "") - tools.replace_in_file(makefile, "CXXFLAGS += -O2", "") - tools.replace_in_file(makefile, "LDFLAGS += -O2", "") - with tools.chdir(self._source_subfolder): + replace_in_file(self, makefile, "CFLAGS += -O2", "") + replace_in_file(self, makefile, "CXXFLAGS += -O2", "") + replace_in_file(self, makefile, "LDFLAGS += -O2", "") + with chdir(self, self._source_subfolder): env_vars = AutoToolsBuildEnvironment(self).vars env_vars.update({ "BUILD": "shared" if self.options.shared else "static", @@ -85,36 +89,58 @@ def _build_mingw(self): "STATIC_LIBSTDCPP": "0", }) with tools.environment_append(env_vars): - self.run("{} -f Makefile".format(self._make_program)) + self.run(f"{self._make_program} -f Makefile") + + def _build_visual_studio(self): + with chdir(self, self._source_subfolder): + properties = { + "LIBSASS_STATIC_LIB": "" if self.options.shared else "true", + "WholeProgramOptimization": "true" if any(re.finditer("(^| )[/-]GL($| )", tools.get_env("CFLAGS", ""))) else "false", + } + platforms = { + "x86": "Win32", + "x86_64": "Win64" + } + msbuild = MSBuild(self) + msbuild.build(os.path.join("win", "libsass.sln"), platforms=platforms, properties=properties) def build(self): if self._is_mingw: self._build_mingw() + elif is_msvc(self): + self._build_visual_studio() else: self._build_autotools() def _install_autotools(self): - with tools.chdir(self._source_subfolder): + with chdir(self, self._source_subfolder): autotools = self._configure_autotools() autotools.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(self.package_folder, "*.la") + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", self.package_folder, recursive=True) def _install_mingw(self): self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) self.copy("*.dll", dst="bin", src=os.path.join(self._source_subfolder, "lib")) self.copy("*.a", dst="lib", src=os.path.join(self._source_subfolder, "lib")) + def _install_visual_studio(self): + self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) + self.copy("*.dll", dst="bin", src=os.path.join(self._source_subfolder, "win", "bin"), keep_path=False) + self.copy("*.lib", dst="lib", src=os.path.join(self._source_subfolder, "win", "bin"), keep_path=False) + def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") if self._is_mingw: self._install_mingw() + elif is_msvc(self): + self._install_visual_studio() else: self._install_autotools() def package_info(self): self.cpp_info.names["pkg_config"] = "libsass" - self.cpp_info.libs = ["sass"] + self.cpp_info.libs = ["libsass" if is_msvc(self) else "sass"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["dl", "m"]) if not self.options.shared and tools.stdcpp_library(self): diff --git a/recipes/libsass/all/test_package/CMakeLists.txt b/recipes/libsass/all/test_package/CMakeLists.txt index 7b9b613cbb24a..2c3751c7f5fee 100644 --- a/recipes/libsass/all/test_package/CMakeLists.txt +++ b/recipes/libsass/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(libsass REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} libsass::libsass) diff --git a/recipes/libsass/all/test_package/conanfile.py b/recipes/libsass/all/test_package/conanfile.py index fcc20e0984e32..814aa7bbb26c7 100644 --- a/recipes/libsass/all/test_package/conanfile.py +++ b/recipes/libsass/all/test_package/conanfile.py @@ -4,7 +4,7 @@ class LibsassTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) diff --git a/recipes/libsass/config.yml b/recipes/libsass/config.yml index 24cababa1cadd..dad090706c27e 100644 --- a/recipes/libsass/config.yml +++ b/recipes/libsass/config.yml @@ -1,3 +1,5 @@ versions: + "3.6.5": + folder: all "3.6.4": folder: all diff --git a/recipes/libschrift/all/CMakeLists.txt b/recipes/libschrift/all/CMakeLists.txt new file mode 100644 index 0000000000000..89baaf56270d3 --- /dev/null +++ b/recipes/libschrift/all/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.8) +project(schrift LANGUAGES C) + +include(GNUInstallDirs) + +add_library(schrift ${LIBSCHRIFT_SRC_DIR}/schrift.c) +set_target_properties(schrift PROPERTIES + PUBLIC_HEADER ${LIBSCHRIFT_SRC_DIR}/schrift.h + WINDOWS_EXPORT_ALL_SYMBOLS ON + C_EXTENSIONS OFF + C_STANDARD 99 +) + +find_library(LIBM m) +target_link_libraries(schrift PRIVATE $<$:${LIBM}>) + +install( + TARGETS schrift + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/libschrift/all/conandata.yml b/recipes/libschrift/all/conandata.yml new file mode 100644 index 0000000000000..f950f67f232f7 --- /dev/null +++ b/recipes/libschrift/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "0.10.2": + url: "https://github.com/tomolt/libschrift/archive/v0.10.2.tar.gz" + sha256: "23e98611f0dfc6e22dcf531f2de987042ca5a81864911b4e917fb3218795fae0" + "0.10.1": + url: "https://github.com/tomolt/libschrift/archive/refs/tags/v0.10.1.tar.gz" + sha256: "3590c1f9d9cf752edbe51908584aa3dc4d8b466c93bdd3771e830880e143f94c" diff --git a/recipes/libschrift/all/conanfile.py b/recipes/libschrift/all/conanfile.py new file mode 100644 index 0000000000000..949296527320a --- /dev/null +++ b/recipes/libschrift/all/conanfile.py @@ -0,0 +1,73 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.46.0" + + +class LibschriftConan(ConanFile): + name = "libschrift" + description = "A lightweight TrueType font rendering library " + topics = ("truetype", "suckless", ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/tomolt/libschrift" + license = "ISC", + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = ["CMakeLists.txt"] + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBSCHRIFT_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["schrift"] + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs = ["m"] diff --git a/recipes/libschrift/all/test_package/CMakeLists.txt b/recipes/libschrift/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..36819133561d5 --- /dev/null +++ b/recipes/libschrift/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libschrift REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libschrift::libschrift) diff --git a/recipes/libschrift/all/test_package/OpenSans-Bold.ttf b/recipes/libschrift/all/test_package/OpenSans-Bold.ttf new file mode 100644 index 0000000000000..fd79d43bea029 Binary files /dev/null and b/recipes/libschrift/all/test_package/OpenSans-Bold.ttf differ diff --git a/recipes/libschrift/all/test_package/conanfile.py b/recipes/libschrift/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d4c18b77de306 --- /dev/null +++ b/recipes/libschrift/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + font_path = os.path.join(self.source_folder, "OpenSans-Bold.ttf") + self.run(f"{bin_path} {font_path}", env="conanrun") diff --git a/recipes/libschrift/all/test_package/test_package.c b/recipes/libschrift/all/test_package/test_package.c new file mode 100644 index 0000000000000..154c09dca4013 --- /dev/null +++ b/recipes/libschrift/all/test_package/test_package.c @@ -0,0 +1,7 @@ +#include "schrift.h" + +int main(int argc, char* argv[]) { + sft_loadfile(argv[1]); + + return 0; +} diff --git a/recipes/libschrift/all/test_v1_package/CMakeLists.txt b/recipes/libschrift/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a36c74cedeb93 --- /dev/null +++ b/recipes/libschrift/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libschrift REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libschrift::libschrift) diff --git a/recipes/libschrift/all/test_v1_package/conanfile.py b/recipes/libschrift/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..da2d908b1d4a7 --- /dev/null +++ b/recipes/libschrift/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + font_path = os.path.join(self.source_folder, os.pardir, "test_package", "OpenSans-Bold.ttf") + self.run(f"{bin_path} {font_path}", run_environment=True) diff --git a/recipes/libschrift/config.yml b/recipes/libschrift/config.yml new file mode 100644 index 0000000000000..3a41bddc4c382 --- /dev/null +++ b/recipes/libschrift/config.yml @@ -0,0 +1,5 @@ +versions: + "0.10.2": + folder: all + "0.10.1": + folder: all diff --git a/recipes/libsecret/all/conandata.yml b/recipes/libsecret/all/conandata.yml index fc7d49aa1a517..55e19d25249c5 100644 --- a/recipes/libsecret/all/conandata.yml +++ b/recipes/libsecret/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "0.20.5": + url: "https://download.gnome.org/sources/libsecret/0.20/libsecret-0.20.5.tar.xz" + sha256: "3fb3ce340fcd7db54d87c893e69bfc2b1f6e4d4b279065ffe66dac9f0fd12b4d" "0.20.4": url: "https://download.gnome.org/sources/libsecret/0.20/libsecret-0.20.4.tar.xz" sha256: "325a4c54db320c406711bf2b55e5cb5b6c29823426aa82596a907595abb39d28" diff --git a/recipes/libsecret/all/conanfile.py b/recipes/libsecret/all/conanfile.py index 8bdc5d20c1e4b..08f938b935f7f 100644 --- a/recipes/libsecret/all/conanfile.py +++ b/recipes/libsecret/all/conanfile.py @@ -2,20 +2,31 @@ from conans.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.33.0" + class LibsecretConan(ConanFile): name = "libsecret" description = "A library for storing and retrieving passwords and other secrets" - topics = ("conan", "libsecret", "gobject", "password", "secret") + topics = ("libsecret", "gobject", "password", "secret") url = "https://github.com/conan-io/conan-center-index" homepage = "https://wiki.gnome.org/Projects/Libsecret" license = "LGPL-2.1-or-later" - generators = "pkg_config" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_libgcrypt": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_libgcrypt": True, + } + + generators = "pkg_config" + _meson = None @property def _source_subfolder(self): @@ -25,15 +36,16 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" - def validate(self): - if self.settings.os == "Windows": - raise ConanInvalidConfiguration( - "libsecret recipe is not yet compatible with Windows." - ) + @property + def _use_gcrypt(self): + return self.options.get_safe("with_libgcrypt", False) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.settings.os != "Linux": + # libgcrypt recipe is currently only available on Linux + del self.options.with_libgcrypt def configure(self): if self.options.shared: @@ -42,39 +54,49 @@ def configure(self): del self.settings.compiler.cppstd def requirements(self): - self.requires("glib/2.67.2") + self.requires("glib/2.70.1") + if self._use_gcrypt: + self.requires("libgcrypt/1.8.4") + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration( + "libsecret recipe is not yet compatible with Windows." + ) def build_requirements(self): - self.build_requires("meson/0.56.2") - self.build_requires("pkgconf/1.7.3") + self.build_requires("meson/0.60.2") + self.build_requires("pkgconf/1.7.4") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_meson(self): - meson = Meson(self) + if self._meson: + return self._meson + self._meson = Meson(self) defs = {} - defs["introspection"] = "false" - defs["manpage"] = "false" - defs["gtk_doc"] = "false" - defs["gcrypt"] = "false" - meson.configure( + defs["introspection"] = False + defs["manpage"] = False + defs["gtk_doc"] = False + defs["gcrypt"] = self._use_gcrypt + self._meson.configure( defs=defs, build_folder=self._build_subfolder, source_folder=self._source_subfolder, pkg_config_paths=[self.install_folder], ) - return meson + return self._meson def build(self): - with tools.environment_append(tools.RunEnvironment(self).vars): + with tools.run_environment(self): meson = self._configure_meson() meson.build() def package(self): self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - with tools.environment_append({"PKG_CONFIG_PATH": self.install_folder}): + with tools.run_environment(self): meson = self._configure_meson() meson.install() tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) @@ -83,5 +105,7 @@ def package(self): def package_info(self): self.cpp_info.names["pkg_config"] = "libsecret-1" self.cpp_info.requires = ["glib::glib-2.0", "glib::gobject-2.0"] + if self._use_gcrypt: + self.cpp_info.requires.append("libgcrypt::libgcrypt") self.cpp_info.includedirs = [os.path.join("include", "libsecret-1")] self.cpp_info.libs = ["secret-1"] diff --git a/recipes/libsecret/all/test_package/conanfile.py b/recipes/libsecret/all/test_package/conanfile.py index bd7165a553cf4..5c09494bc67c0 100644 --- a/recipes/libsecret/all/test_package/conanfile.py +++ b/recipes/libsecret/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libsecret/config.yml b/recipes/libsecret/config.yml index ea127e6d52aec..470f4b110022f 100644 --- a/recipes/libsecret/config.yml +++ b/recipes/libsecret/config.yml @@ -1,3 +1,5 @@ versions: + "0.20.5": + folder: all "0.20.4": folder: all diff --git a/recipes/libselinux/all/conandata.yml b/recipes/libselinux/all/conandata.yml index 1237edf704e36..bc06101ad2d72 100644 --- a/recipes/libselinux/all/conandata.yml +++ b/recipes/libselinux/all/conandata.yml @@ -1,32 +1,37 @@ sources: - "2.9": - - url: "https://github.com/SELinuxProject/selinux/releases/download/20190315/libselinux-2.9.tar.gz" - sha256: "1bccc8873e449587d9a2b2cf253de9b89a8291b9fbc7c59393ca9e5f5f4d2693" - - url: "https://github.com/SELinuxProject/selinux/releases/download/20190315/libsepol-2.9.tar.gz" - sha256: "a34b12b038d121e3e459b1cbaca3c9202e983137819c16baf63658390e3f1d5d" - "3.0": - - url: "https://github.com/SELinuxProject/selinux/releases/download/20191204/libselinux-3.0.tar.gz" - sha256: "2ea2b30f671dae9d6b1391cbe8fb2ce5d36a3ee4fb1cd3c32f0d933c31b82433" - - url: "https://github.com/SELinuxProject/selinux/releases/download/20191204/libsepol-3.0.tar.gz" - sha256: "5b7ae1881909f1048b06f7a0c364c5c8a86ec12e0ec76e740fe9595a6033eb79" - "3.1": - - url: "https://github.com/SELinuxProject/selinux/releases/download/20200710/libselinux-3.1.tar.gz" - sha256: "ea5dcbb4d859e3f999c26a13c630da2f16dff9462e3cc8cb7b458ac157d112e7" - - url: "https://github.com/SELinuxProject/selinux/releases/download/20200710/libsepol-3.1.tar.gz" - sha256: "ae6778d01443fdd38cd30eeee846494e19f4d407b09872580372f4aa4bf8a3cc" + "3.3": + - url: "https://github.com/SELinuxProject/selinux/releases/download/3.3/libselinux-3.3.tar.gz" + sha256: "acfdee27633d2496508c28727c3d41d3748076f66d42fccde2e6b9f3463a7057" + - url: "https://github.com/SELinuxProject/selinux/releases/download/3.3/libsepol-3.3.tar.gz" + sha256: "2d97df3eb8466169b389c3660acbb90c54200ac96e452eca9f41a9639f4f238b" "3.2": - url: "https://github.com/SELinuxProject/selinux/releases/download/3.2/libselinux-3.2.tar.gz" sha256: "df758ef1d9d4811051dd901ea6b029ae334ffd7c671c128beb16bce1e25ac161" - url: "https://github.com/SELinuxProject/selinux/releases/download/3.2/libsepol-3.2.tar.gz" sha256: "dfc7f662af8000116e56a01de6a0394ed79be1b34b999e551346233c5dd19508" -patches: + "3.1": + - url: "https://github.com/SELinuxProject/selinux/releases/download/20200710/libselinux-3.1.tar.gz" + sha256: "ea5dcbb4d859e3f999c26a13c630da2f16dff9462e3cc8cb7b458ac157d112e7" + - url: "https://github.com/SELinuxProject/selinux/releases/download/20200710/libsepol-3.1.tar.gz" + sha256: "ae6778d01443fdd38cd30eeee846494e19f4d407b09872580372f4aa4bf8a3cc" + "3.0": + - url: "https://github.com/SELinuxProject/selinux/releases/download/20191204/libselinux-3.0.tar.gz" + sha256: "2ea2b30f671dae9d6b1391cbe8fb2ce5d36a3ee4fb1cd3c32f0d933c31b82433" + - url: "https://github.com/SELinuxProject/selinux/releases/download/20191204/libsepol-3.0.tar.gz" + sha256: "5b7ae1881909f1048b06f7a0c364c5c8a86ec12e0ec76e740fe9595a6033eb79" "2.9": - - patch_file: patches/0001-fix-fno-common-2.9.patch - base_path: libsepol-2.9 - - patch_file: patches/0002-remove-cil_mem_error_handler.patch - base_path: libsepol-2.9 + - url: "https://github.com/SELinuxProject/selinux/releases/download/20190315/libselinux-2.9.tar.gz" + sha256: "1bccc8873e449587d9a2b2cf253de9b89a8291b9fbc7c59393ca9e5f5f4d2693" + - url: "https://github.com/SELinuxProject/selinux/releases/download/20190315/libsepol-2.9.tar.gz" + sha256: "a34b12b038d121e3e459b1cbaca3c9202e983137819c16baf63658390e3f1d5d" +patches: "3.0": - patch_file: patches/0001-fix-fno-common-3.0.patch base_path: libsepol-3.0 - patch_file: patches/0002-remove-cil_mem_error_handler.patch base_path: libsepol-3.0 + "2.9": + - patch_file: patches/0001-fix-fno-common-2.9.patch + base_path: libsepol-2.9 + - patch_file: patches/0002-remove-cil_mem_error_handler.patch + base_path: libsepol-2.9 diff --git a/recipes/libselinux/all/conanfile.py b/recipes/libselinux/all/conanfile.py index 7ae33ed3a05bf..3583de7934d4e 100644 --- a/recipes/libselinux/all/conanfile.py +++ b/recipes/libselinux/all/conanfile.py @@ -1,83 +1,132 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get +from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.52.0" + class LibSELinuxConan(ConanFile): name = "libselinux" - description = "Security-enhanced Linux is a patch of the Linux kernel and a number of utilities with enhanced security functionality designed to add mandatory access controls to Linux" - topics = ("conan", "selinux", "security-enhanced linux") + description = ( + "Security-enhanced Linux is a patch of the Linux kernel and a number " + "of utilities with enhanced security functionality designed to add " + "mandatory access controls to Linux" + ) + topics = ("selinux", "security-enhanced linux") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/SELinuxProject/selinux" - license = "Unlicense" # This library (libselinux) is public domain software, i.e. not copyrighted + license = "Unlicense" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - exports_sources = "patches/**" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - def _get_subfolders(self): - _sepol_subfolder = "libsepol-%s" % self.version - _selinux_subfolder = "libselinux-%s" % self.version - return _sepol_subfolder, _selinux_subfolder + def export_sources(self): + export_conandata_patches(self) def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.settings.os != "Linux": - raise ConanInvalidConfiguration("Only Linux is supported") + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass def requirements(self): - self.requires("pcre2/10.36") + self.requires("pcre2/10.40") + + def validate(self): + if self.info.settings.os != "Linux": + raise ConanInvalidConfiguration(f"{self.ref} only supports Linux") def build_requirements(self): - self.build_requires("flex/2.6.4") + self.tool_requires("flex/2.6.4") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/1.9.3") + + def layout(self): + basic_layout(self, src_folder="src") def source(self): for download in self.conan_data["sources"][self.version]: - tools.get(**download) + get(self, **download, destination=self.source_folder) @property def _sepol_soversion(self): - return "2" if tools.Version(self.version) >= "3.2" else "1" + return "2" if Version(self.version) >= "3.2" else "1" @property def _selinux_soversion(self): return "1" + @property + def _sepol_library_target(self): + return f"libsepol.so.{self._sepol_soversion}" if self.options.shared else "libsepol.a" + + @property + def _selinux_library_target(self): + return f"libselinux.so.{self._selinux_soversion}" if self.options.shared else "libselinux.a" + + @property + def _sepol_source_folder(self): + return os.path.join(self.source_folder, f"libsepol-{self.version}") + + @property + def _selinux_source_folder(self): + return os.path.join(self.source_folder, f"libselinux-{self.version}") + + def generate(self): + virtual_build_env = VirtualBuildEnv(self) + virtual_build_env.generate() + pkg_config_deps = PkgConfigDeps(self) + pkg_config_deps.generate() + tc = AutotoolsToolchain(self) + sepol_include_folder = os.path.join(self._sepol_source_folder, "include") + tc.extra_cflags.append(f"-I{sepol_include_folder}") + sepol_lib_folder = os.path.join(self._sepol_source_folder, "src") + tc.extra_ldflags.append(f"-L{sepol_lib_folder}") + tc.make_args.append("USE_PCRE2=y") + tc.generate() + def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - _sepol_subfolder, _selinux_subfolder = self._get_subfolders() - pcre_inc = os.path.join(self.deps_cpp_info["pcre2"].rootpath, - self.deps_cpp_info["pcre2"].includedirs[0]) - pcre_libs = ' '.join(["-l%s" % lib for lib in self.deps_cpp_info["pcre2"].libs]) - sepol_inc = os.path.join(self.source_folder, _sepol_subfolder, "include") - with tools.chdir(os.path.join(_sepol_subfolder, "src")): - args = ["libsepol.so.{}".format(self._sepol_soversion) if self.options.shared else "libsepol.a"] - env_build = AutoToolsBuildEnvironment(self) - env_build.make(args=args) - with tools.chdir(os.path.join(_selinux_subfolder, "src")): - args = ["libselinux.so.{}".format(self._selinux_soversion) if self.options.shared else "libselinux.a", - 'PCRE_CFLAGS=-DPCRE2_CODE_UNIT_WIDTH=8 -DUSE_PCRE2=1 -I%s -I%s' % (pcre_inc, sepol_inc), - 'PCRE_LDLIBS=%s' % pcre_libs] - env_build = AutoToolsBuildEnvironment(self) - env_build.make(args=args) + apply_conandata_patches(self) + autotools = Autotools(self) + with chdir(self, os.path.join(self._sepol_source_folder, "src")): + autotools.make(self._sepol_library_target) + with chdir(self, os.path.join(self._selinux_source_folder)): + autotools.make() def package(self): - _sepol_subfolder, _selinux_subfolder = self._get_subfolders() - self.copy(pattern="LICENSE", dst="licenses", src=_selinux_subfolder) - for library in [_sepol_subfolder, _selinux_subfolder]: - self.copy(pattern="*.h", dst="include", src=os.path.join(library, "include"), keep_path=True) - self.copy(pattern="*.so*", dst="lib", src=library, keep_path=False, symlinks=True) - self.copy(pattern="*.a", dst="lib", src=library, keep_path=False) + copy(self, "LICENSE", self._selinux_source_folder, os.path.join(self.package_folder, "licenses")) + for library in [self._sepol_source_folder, self._selinux_source_folder]: + copy(self, "*.h", os.path.join(library, "include"), os.path.join(self.package_folder, "include")) + if self.options.shared: + copy(self, "*.so*", library, os.path.join(self.package_folder, "lib"), keep_path=False) + else: + copy(self, "*.a", library, os.path.join(self.package_folder, "lib"), keep_path=False) def package_info(self): + self.cpp_info.components["selinux"].set_property("pkg_config_name", "libselinux") self.cpp_info.components["selinux"].names["pkg_config"] = "libselinux" self.cpp_info.components["selinux"].libs = ["selinux"] self.cpp_info.components["selinux"].requires = ["sepol", "pcre2::pcre2"] + if self.options.shared: + self.cpp_info.components["selinux"].system_libs = ["dl"] + self.cpp_info.components["sepol"].set_property("pkg_config_name", "libsepol") self.cpp_info.components["sepol"].names["pkg_config"] = "libsepol" self.cpp_info.components["sepol"].libs = ["sepol"] diff --git a/recipes/libselinux/all/test_package/CMakeLists.txt b/recipes/libselinux/all/test_package/CMakeLists.txt index 7b9b613cbb24a..7a316858398f3 100644 --- a/recipes/libselinux/all/test_package/CMakeLists.txt +++ b/recipes/libselinux/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libselinux REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libselinux::libselinux) diff --git a/recipes/libselinux/all/test_package/conanfile.py b/recipes/libselinux/all/test_package/conanfile.py index bd7165a553cf4..a9fb96656f203 100644 --- a/recipes/libselinux/all/test_package/conanfile.py +++ b/recipes/libselinux/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libselinux/all/test_v1_package/CMakeLists.txt b/recipes/libselinux/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/libselinux/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libselinux/all/test_v1_package/conanfile.py b/recipes/libselinux/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libselinux/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libselinux/config.yml b/recipes/libselinux/config.yml index dbaaa5cda845a..3fc66eb377b84 100644 --- a/recipes/libselinux/config.yml +++ b/recipes/libselinux/config.yml @@ -1,9 +1,11 @@ versions: - "2.9": + "3.3": folder: all - "3.0": + "3.2": folder: all "3.1": folder: all - "3.2": + "3.0": + folder: all + "2.9": folder: all diff --git a/recipes/libsgp4/all/CMakeLists.txt b/recipes/libsgp4/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/libsgp4/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libsgp4/all/conandata.yml b/recipes/libsgp4/all/conandata.yml index d542b7be5de08..acdc9ee85a453 100644 --- a/recipes/libsgp4/all/conandata.yml +++ b/recipes/libsgp4/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "20191207": - patch_file: "patches/fix-cmake-files.patch" - base_path: "source_subfolder" diff --git a/recipes/libsgp4/all/conanfile.py b/recipes/libsgp4/all/conanfile.py index 6eaeb2198cd50..f2f49822e5c2a 100644 --- a/recipes/libsgp4/all/conanfile.py +++ b/recipes/libsgp4/all/conanfile.py @@ -1,58 +1,68 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.50.0" + class Libsgp4Conan(ConanFile): name = "libsgp4" description = "C++11 library for SGP4 Simplified perturbations model." license = "Apache-2.0" - topics = ("conan", "libsgp4", "sgp4", "orbit", "satellite", "perturbation") + topics = ("libsgp4", "sgp4", "orbit", "satellite", "perturbation") homepage = "https://github.com/dnwrnr/sgp4" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - url = self.conan_data["sources"][self.version]["url"] - extracted_dir = "sgp4-" + os.path.splitext(os.path.basename(url))[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build(target="sgp4") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - self.cpp_info.includedirs = ["include", os.path.join("include", "SGP4")] + self.cpp_info.libs = ["sgp4s" if self.options.shared else "sgp4"] + self.cpp_info.includedirs.append(os.path.join("include", "SGP4")) diff --git a/recipes/libsgp4/all/patches/fix-cmake-files.patch b/recipes/libsgp4/all/patches/fix-cmake-files.patch index 6b2cb6a34838d..c465c32853439 100644 --- a/recipes/libsgp4/all/patches/fix-cmake-files.patch +++ b/recipes/libsgp4/all/patches/fix-cmake-files.patch @@ -2,7 +2,7 @@ +++ b/CMakeLists.txt @@ -1,16 +1,7 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) -+CMAKE_MINIMUM_REQUIRED(VERSION 3.4.3) ++CMAKE_MINIMUM_REQUIRED(VERSION 3.8) PROJECT(SGP4) -include(CheckCXXCompilerFlag) @@ -35,17 +35,18 @@ -file(COPY SGP4-VER.TLE DESTINATION ${PROJECT_BINARY_DIR}) --- a/libsgp4/CMakeLists.txt +++ b/libsgp4/CMakeLists.txt -@@ -35,7 +35,10 @@ set(SRCS +@@ -35,7 +35,11 @@ set(SRCS Vector.h ) -add_library(sgp4 STATIC ${SRCS} ${INCS}) -add_library(sgp4s SHARED ${SRCS} ${INCS}) -install( TARGETS sgp4s LIBRARY DESTINATION lib ) -+add_library(sgp4 ${SRCS} ${INCS}) -+if(WIN32 AND BUILD_SHARED_LIBS) -+ set_target_properties(sgp4 PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) ++add_library(sgp4 ${SRCS}) ++set_target_properties(sgp4 PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) ++if(BUILD_SHARED_LIBS) ++ set_target_properties(sgp4 PROPERTIES OUTPUT_NAME sgp4s) +endif() -+set_target_properties(sgp4 PROPERTIES CXX_STANDARD 11) ++target_compile_features(sgp4 PRIVATE cxx_std_11) +install( TARGETS sgp4 RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) install( FILES ${INCS} DESTINATION include/SGP4 ) diff --git a/recipes/libsgp4/all/test_package/CMakeLists.txt b/recipes/libsgp4/all/test_package/CMakeLists.txt index 829b5ca81b9ce..97488a3cba806 100644 --- a/recipes/libsgp4/all/test_package/CMakeLists.txt +++ b/recipes/libsgp4/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libsgp4 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE libsgp4::libsgp4) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libsgp4/all/test_package/conanfile.py b/recipes/libsgp4/all/test_package/conanfile.py index 93e2ccdefd139..c861d41a6d58c 100644 --- a/recipes/libsgp4/all/test_package/conanfile.py +++ b/recipes/libsgp4/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") tle_name = os.path.join(self.source_folder, "SGP4-VER.TLE") - bin_path = os.path.join("bin", "test_package") - self.run("{0} {1}".format(bin_path, tle_name), run_environment=True) + self.run(f"{bin_path} {tle_name}", env="conanrun") diff --git a/recipes/libsgp4/all/test_package/test_package.cpp b/recipes/libsgp4/all/test_package/test_package.cpp index bea06f5622b55..8bf8118f5e302 100644 --- a/recipes/libsgp4/all/test_package/test_package.cpp +++ b/recipes/libsgp4/all/test_package/test_package.cpp @@ -15,11 +15,11 @@ */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/recipes/libsgp4/all/test_v1_package/CMakeLists.txt b/recipes/libsgp4/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a84c36978ba7f --- /dev/null +++ b/recipes/libsgp4/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libsgp4 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libsgp4::libsgp4) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libsgp4/all/test_v1_package/conanfile.py b/recipes/libsgp4/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2b79c5abc2774 --- /dev/null +++ b/recipes/libsgp4/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + tle_name = os.path.join(self.source_folder, os.pardir, "test_package", "SGP4-VER.TLE") + self.run(f"{bin_path} {tle_name}", run_environment=True) diff --git a/recipes/libsigcpp/2.x.x/conandata.yml b/recipes/libsigcpp/2.x.x/conandata.yml new file mode 100644 index 0000000000000..604636a369d17 --- /dev/null +++ b/recipes/libsigcpp/2.x.x/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.10.8": + url: "https://ftp2.nluug.nl/windowing/gnome/sources/libsigc++/2.10/libsigc++-2.10.8.tar.xz" + sha256: "235a40bec7346c7b82b6a8caae0456353dc06e71f14bc414bcc858af1838719a" diff --git a/recipes/libsigcpp/2.x.x/conanfile.py b/recipes/libsigcpp/2.x.x/conanfile.py new file mode 100644 index 0000000000000..f3ba237114633 --- /dev/null +++ b/recipes/libsigcpp/2.x.x/conanfile.py @@ -0,0 +1,113 @@ +from conans import ConanFile, Meson, tools +from conan.tools.files import rename +from conans.errors import ConanInvalidConfiguration +import glob +import os +import shutil + +required_conan_version = ">=1.43.0" + + +class LibSigCppConanV2(ConanFile): + name = "libsigcpp" + homepage = "https://github.com/libsigcplusplus/libsigcplusplus" + url = "https://github.com/conan-io/conan-center-index" + license = "LGPL-3.0" + description = "libsigc++ implements a typesafe callback system for standard C++." + topics = ("libsigcpp", "callback") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "pkg_config" + short_paths = True + + def validate(self): + if hasattr(self, "settings_build") and tools.cross_building(self): + raise ConanInvalidConfiguration("Cross-building not implemented") + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def build_requirements(self): + self.build_requires("meson/0.59.1") + self.build_requires("pkgconf/1.7.4") + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + strip_root=True, + destination=self._source_subfolder + ) + + def build(self): + if not self.options.shared: + tools.replace_in_file( + os.path.join(self._source_subfolder, "sigc++config.h.meson"), + "define SIGC_DLL 1", "undef SIGC_DLL") + with tools.environment_append(tools.RunEnvironment(self).vars): + meson = self._configure_meson() + meson.build() + + def _configure_meson(self): + meson = Meson(self) + defs = {} + defs["build-examples"] = "false" + defs["build-documentation"] = "false" + defs["default_library"] = "shared" if self.options.shared else "static" + meson.configure( + defs=defs, + build_folder=self._build_subfolder, + source_folder=self._source_subfolder, + pkg_config_paths=[self.install_folder], + ) + return meson + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + meson = self._configure_meson() + meson.install() + if self.settings.compiler == "Visual Studio": + tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + if not self.options.shared: + rename(self, + os.path.join(self.package_folder, "lib", "libsigc-2.0.a"), + os.path.join(self.package_folder, "lib", "sigc-2.0.lib")) + + for header_file in glob.glob(os.path.join(self.package_folder, "lib", "sigc++-2.0", "include", "*.h")): + shutil.move( + header_file, + os.path.join(self.package_folder, "include", + "sigc++-2.0", os.path.basename(header_file)) + ) + + for dir_to_remove in ["pkgconfig", "sigc++-2.0"]: + tools.rmdir(os.path.join( + self.package_folder, "lib", dir_to_remove)) + + def package_info(self): + self.cpp_info.components["sigc++-2.0"].names["pkg_config"] = "sigc++-2.0" + self.cpp_info.components["sigc++-2.0"].includedirs.append(os.path.join("include", "sigc++-2.0")) + self.cpp_info.components["sigc++-2.0"].libs = ["sigc-2.0"] diff --git a/recipes/libsigcpp/2.x.x/test_package/CMakeLists.txt b/recipes/libsigcpp/2.x.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..21ca4ecbf6eee --- /dev/null +++ b/recipes/libsigcpp/2.x.x/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.6) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGET) + +find_package(PkgConfig REQUIRED) +pkg_search_module(SIGCPP IMPORTED_TARGET REQUIRED sigc++-2.0) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PkgConfig::SIGCPP) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/libsigcpp/2.x.x/test_package/conanfile.py b/recipes/libsigcpp/2.x.x/test_package/conanfile.py new file mode 100644 index 0000000000000..ffedca59f065b --- /dev/null +++ b/recipes/libsigcpp/2.x.x/test_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "pkg_config" + + def build_requirements(self): + self.build_requires("pkgconf/1.7.4") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libsigcpp/2.x.x/test_package/test_package.cpp b/recipes/libsigcpp/2.x.x/test_package/test_package.cpp new file mode 100644 index 0000000000000..ba99b27431500 --- /dev/null +++ b/recipes/libsigcpp/2.x.x/test_package/test_package.cpp @@ -0,0 +1,24 @@ +/* Copyright 2003 - 2016, The libsigc++ Development Team + * + * Assigned to the public domain. Use as you wish without + * restriction. + */ + +#include +#include + +#include +// make sure that sigc++config.h can be included +#include + +void on_print(const std::string &str) { std::cout << str; } + +int main() { + sigc::signal signal_print; + + signal_print.connect(sigc::ptr_fun(&on_print)); + + signal_print.emit("hello world\n"); + + return 0; +} diff --git a/recipes/libsigcpp/3.x.x/conandata.yml b/recipes/libsigcpp/3.x.x/conandata.yml index 476bb51e8d105..22e051100ec2e 100644 --- a/recipes/libsigcpp/3.x.x/conandata.yml +++ b/recipes/libsigcpp/3.x.x/conandata.yml @@ -1,8 +1,14 @@ sources: + "3.0.7": + url: "https://ftp.gnome.org/pub/GNOME/sources/libsigc++/3.0/libsigc++-3.0.7.tar.xz" + sha256: "bfbe91c0d094ea6bbc6cbd3909b7d98c6561eea8b6d9c0c25add906a6e83d733" "3.0.0": url: "https://ftp.gnome.org/pub/GNOME/sources/libsigc++/3.0/libsigc++-3.0.0.tar.xz" sha256: "50a0855c1eb26e6044ffe888dbe061938ab4241f96d8f3754ea7ead38ab8ed06" patches: + "3.0.7": + - patch_file: "patches/3.0.7-0001-libsigcpp.patch" + base_path: "source_subfolder" "3.0.0": - - patch_file: "patches/0001-libsigcpp.patch" + - patch_file: "patches/3.0.0-0001-libsigcpp.patch" base_path: "source_subfolder" diff --git a/recipes/libsigcpp/3.x.x/conanfile.py b/recipes/libsigcpp/3.x.x/conanfile.py index e739cf266a0d3..dbf3fc6323f8c 100644 --- a/recipes/libsigcpp/3.x.x/conanfile.py +++ b/recipes/libsigcpp/3.x.x/conanfile.py @@ -1,23 +1,32 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration import glob import os import shutil +import textwrap -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.43.0" class LibSigCppConan(ConanFile): name = "libsigcpp" - version = "3.0.0" homepage = "https://github.com/libsigcplusplus/libsigcplusplus" url = "https://github.com/conan-io/conan-center-index" license = "LGPL-3.0" description = "libsigc++ implements a typesafe callback system for standard C++." - topics = ("conan", "libsigcpp", "callback") - settings = "os", "compiler", "arch", "build_type" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + topics = ("libsigcpp", "callback") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake" _cmake = None @property @@ -28,24 +37,47 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" - def _has_support_for_cpp17(self): - supported_compilers = [("apple-clang", 10), ("clang", 6), ("gcc", 7), ("Visual Studio", 15.7)] - compiler, version = self.settings.compiler, tools.Version(self.settings.compiler.version) - return any(compiler == sc[0] and version >= sc[1] for sc in supported_compilers) + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC def configure(self): - if self.settings.compiler.cppstd: + if self.options.shared: + del self.options.fPIC + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "15.7", + "gcc": "7", + "clang": "6", + "apple-clang": "10", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, 17) - if not self._has_support_for_cpp17(): - raise ConanInvalidConfiguration("This library requires C++17 or higher support standard." - " {} {} is not supported." - .format(self.settings.compiler, - self.settings.compiler.version)) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._minimum_compilers_version.get(str(self.settings.compiler), False) + if not minimum_version: + self.output.warn("libsigcpp requires C++17. Your compiler is unknown. Assuming it supports C++17.") + elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration("libsigcpp requires C++17, which your compiler does not support.") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "libsigc++-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -55,8 +87,11 @@ def _configure_cmake(self): return self._cmake def build(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) + if not self.options.shared: + tools.replace_in_file(os.path.join(self._source_subfolder, "sigc++config.h.cmake"), + "define SIGC_DLL 1", "undef SIGC_DLL") cmake = self._configure_cmake() cmake.build() @@ -72,14 +107,44 @@ def package(self): for dir_to_remove in ["cmake", "pkgconfig", "sigc++-3.0"]: tools.rmdir(os.path.join(self.package_folder, "lib", dir_to_remove)) + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"sigc-3.0": "sigc++-3::sigc-3.0"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + def package_info(self): - # TODO: CMake imported target shouldn't be namespaced + self.cpp_info.set_property("cmake_file_name", "sigc++-3") + self.cpp_info.set_property("cmake_target_name", "sigc-3.0") + self.cpp_info.set_property("pkg_config_name", "sigc++-3.0") + + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["sigc++"].includedirs = [os.path.join("include", "sigc++-3.0")] + self.cpp_info.components["sigc++"].libs = tools.collect_libs(self) + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.components["sigc++"].system_libs.append("m") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "sigc++-3" self.cpp_info.names["cmake_find_package_multi"] = "sigc++-3" - self.cpp_info.names["pkg_config"] = "sigc++-3.0" self.cpp_info.components["sigc++"].names["cmake_find_package"] = "sigc-3.0" self.cpp_info.components["sigc++"].names["cmake_find_package_multi"] = "sigc-3.0" - self.cpp_info.components["sigc++"].includedirs = [os.path.join("include", "sigc++-3.0")] - self.cpp_info.components["sigc++"].libs = tools.collect_libs(self) - if self.settings.os == "Linux": - self.cpp_info.components["sigc++"].system_libs.append("m") + self.cpp_info.components["sigc++"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["sigc++"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["sigc++"].set_property("pkg_config_name", "sigc++-3.0") diff --git a/recipes/libsigcpp/3.x.x/patches/0001-libsigcpp.patch b/recipes/libsigcpp/3.x.x/patches/0001-libsigcpp.patch deleted file mode 100644 index 09ba152d9cb6f..0000000000000 --- a/recipes/libsigcpp/3.x.x/patches/0001-libsigcpp.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 9ec2b4a..877baa4 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -71,8 +71,6 @@ enable_testing() - - - add_subdirectory (sigc++) --add_subdirectory (examples) --add_subdirectory (tests) - - - set (PROJECT_CMAKE_NAME "${PROJECT_NAME}-3") -diff --git a/sigc++/CMakeLists.txt b/sigc++/CMakeLists.txt -index fa5a91a..a71ee6f 100644 ---- a/sigc++/CMakeLists.txt -+++ b/sigc++/CMakeLists.txt -@@ -42,6 +42,8 @@ set (PROJECT_CMAKE_NAME ${PROJECT_NAME}-3) - install ( - TARGETS ${SIGCPP_LIB_NAME} - EXPORT "${PROJECT_CMAKE_NAME}Targets" -+ ARCHIVE DESTINATION "lib" - LIBRARY DESTINATION "lib" -+ RUNTIME DESTINATION "bin" - INCLUDES DESTINATION "${INCLUDE_INSTALL_DIR}" - ) diff --git a/recipes/libsigcpp/3.x.x/patches/3.0.0-0001-libsigcpp.patch b/recipes/libsigcpp/3.x.x/patches/3.0.0-0001-libsigcpp.patch new file mode 100644 index 0000000000000..938d5b0c7ab4b --- /dev/null +++ b/recipes/libsigcpp/3.x.x/patches/3.0.0-0001-libsigcpp.patch @@ -0,0 +1,31 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -71,8 +71,6 @@ + + + add_subdirectory (sigc++) +-add_subdirectory (examples) +-add_subdirectory (tests) + + + set (PROJECT_CMAKE_NAME "${PROJECT_NAME}-3") +--- sigc++/CMakeLists.txt ++++ sigc++/CMakeLists.txt +@@ -23,7 +23,7 @@ + + set (SIGCPP_LIB_NAME sigc-${SIGCXX_API_VERSION}) + +-add_library(${SIGCPP_LIB_NAME} SHARED ${SOURCE_FILES}) ++add_library(${SIGCPP_LIB_NAME} ${SOURCE_FILES}) + + set_property (TARGET ${SIGCPP_LIB_NAME} PROPERTY VERSION ${PACKAGE_VERSION}) + set_property(TARGET ${SIGCPP_LIB_NAME} PROPERTY SOVERSION ${LIBSIGCPP_SOVERSION}) +@@ -42,6 +42,8 @@ + install ( + TARGETS ${SIGCPP_LIB_NAME} + EXPORT "${PROJECT_CMAKE_NAME}Targets" ++ ARCHIVE DESTINATION "lib" + LIBRARY DESTINATION "lib" ++ RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "${INCLUDE_INSTALL_DIR}" + ) diff --git a/recipes/libsigcpp/3.x.x/patches/3.0.7-0001-libsigcpp.patch b/recipes/libsigcpp/3.x.x/patches/3.0.7-0001-libsigcpp.patch new file mode 100644 index 0000000000000..a0455859fec29 --- /dev/null +++ b/recipes/libsigcpp/3.x.x/patches/3.0.7-0001-libsigcpp.patch @@ -0,0 +1,31 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -89,8 +89,6 @@ + + + add_subdirectory (sigc++) +-add_subdirectory (examples) +-add_subdirectory (tests) + + + set (PROJECT_CMAKE_NAME "${PROJECT_NAME}-3") +--- sigc++/CMakeLists.txt ++++ sigc++/CMakeLists.txt +@@ -23,7 +23,7 @@ + + set (SIGCPP_LIB_NAME sigc-${SIGCXX_API_VERSION}) + +-add_library(${SIGCPP_LIB_NAME} SHARED ${SOURCE_FILES}) ++add_library(${SIGCPP_LIB_NAME} ${SOURCE_FILES}) + + set_property (TARGET ${SIGCPP_LIB_NAME} PROPERTY VERSION ${PACKAGE_VERSION}) + set_property(TARGET ${SIGCPP_LIB_NAME} PROPERTY SOVERSION ${LIBSIGCPP_SOVERSION}) +@@ -42,6 +42,8 @@ + install ( + TARGETS ${SIGCPP_LIB_NAME} + EXPORT "${PROJECT_CMAKE_NAME}Targets" ++ ARCHIVE DESTINATION "lib" + LIBRARY DESTINATION "lib" ++ RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "${INCLUDE_INSTALL_DIR}" + ) diff --git a/recipes/libsigcpp/3.x.x/test_package/CMakeLists.txt b/recipes/libsigcpp/3.x.x/test_package/CMakeLists.txt index b0d8ccb63ae1a..5ed3e9d81f891 100644 --- a/recipes/libsigcpp/3.x.x/test_package/CMakeLists.txt +++ b/recipes/libsigcpp/3.x.x/test_package/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.8) project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(sigc++-3 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} sigc++-3::sigc-3.0) # TODO: remove sigc++-3:: namespace when fixed in cpp_info of recipe +target_link_libraries(${PROJECT_NAME} sigc-3.0) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/libsigcpp/3.x.x/test_package/conanfile.py b/recipes/libsigcpp/3.x.x/test_package/conanfile.py index a0402c7a25207..38f4483872d47 100644 --- a/recipes/libsigcpp/3.x.x/test_package/conanfile.py +++ b/recipes/libsigcpp/3.x.x/test_package/conanfile.py @@ -1,9 +1,9 @@ -import os from conans import ConanFile, CMake, tools +import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "arch", "build_type" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libsigcpp/3.x.x/test_package/test_package.cpp b/recipes/libsigcpp/3.x.x/test_package/test_package.cpp index 481434b0f55d9..35eff123b07bf 100644 --- a/recipes/libsigcpp/3.x.x/test_package/test_package.cpp +++ b/recipes/libsigcpp/3.x.x/test_package/test_package.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include void on_print(const std::string& str) { diff --git a/recipes/libsigcpp/config.yml b/recipes/libsigcpp/config.yml index 1545d27261cc0..9590a7ad0b61a 100644 --- a/recipes/libsigcpp/config.yml +++ b/recipes/libsigcpp/config.yml @@ -1,3 +1,7 @@ versions: + "3.0.7": + folder: "3.x.x" "3.0.0": folder: "3.x.x" + "2.10.8": + folder: "2.x.x" diff --git a/recipes/libsixel/all/conandata.yml b/recipes/libsixel/all/conandata.yml new file mode 100644 index 0000000000000..ba89a550dbc5e --- /dev/null +++ b/recipes/libsixel/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.10.3": + url: "https://github.com/libsixel/libsixel/archive/refs/tags/v1.10.3.tar.gz" + sha256: "028552eb8f2a37c6effda88ee5e8f6d87b5d9601182ddec784a9728865f821e0" diff --git a/recipes/libsixel/all/conanfile.py b/recipes/libsixel/all/conanfile.py new file mode 100644 index 0000000000000..8748a8a951d30 --- /dev/null +++ b/recipes/libsixel/all/conanfile.py @@ -0,0 +1,106 @@ +import os +import functools +from conans import ConanFile, Meson, tools +from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc + +required_conan_version = ">=1.33.0" + +class LibSixelConan(ConanFile): + name = "libsixel" + description = "A SIXEL encoder/decoder implementation derived from kmiya's sixel (https://github.com/saitoha/sixel)." + topics = ("sixel") + license = "MIT" + homepage = "https://github.com/libsixel/libsixel" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_curl": [True, False], + "with_gdk_pixbuf2": [True, False], + "with_gd": [True, False], + "with_jpeg": [True, False], + "with_png": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_curl": True, + "with_gd": False, + "with_gdk_pixbuf2": False, + "with_jpeg": True, + "with_png": True, + } + generators = "cmake", "pkg_config" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def validate(self): + if hasattr(self, "settings_build") and tools.cross_building(self): + raise ConanInvalidConfiguration("Cross-building not implemented") + if is_msvc(self): + raise ConanInvalidConfiguration("{}/{} does not support Visual Studio".format(self.name, self.version)) + + def build_requirements(self): + self.build_requires("meson/0.62.2") + self.build_requires("pkgconf/1.7.4") + + def requirements(self): + if self.options.with_curl: + self.requires("libcurl/7.83.1") + if self.options.with_gd: + self.requires("libgd/2.3.2") + if self.options.with_gdk_pixbuf2: + self.requires("gdk-pixbuf/2.42.6") + if self.options.with_jpeg: + self.requires("libjpeg/9d") + if self.options.with_png: + self.requires("libpng/1.6.37") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_meson(self): + meson = Meson(self) + defs = { + "libcurl": "enabled" if self.options.with_curl else "disabled", + "gd": "enabled" if self.options.with_gd else "disabled", + "gdk-pixbuf2": "enabled" if self.options.with_gdk_pixbuf2 else "disabled", + "img2sixel": "disabled", + "sixel2png": "disabled", + "python2": "disabled", + } + meson.configure( + defs=defs, + source_folder=self._source_subfolder, + ) + return meson + + def build(self): + meson = self._configure_meson() + meson.build() + + def package(self): + self.copy("LICENSE*", dst="licenses", src=self._source_subfolder) + meson = self._configure_meson() + meson.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.libs = ["sixel"] diff --git a/recipes/libsixel/all/test_package/CMakeLists.txt b/recipes/libsixel/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..199ae95ae65fc --- /dev/null +++ b/recipes/libsixel/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libsixel REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c) +target_link_libraries(${PROJECT_NAME} libsixel::libsixel) diff --git a/recipes/libsixel/all/test_package/conanfile.py b/recipes/libsixel/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e556cc050d509 --- /dev/null +++ b/recipes/libsixel/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libsixel/all/test_package/test_package.c b/recipes/libsixel/all/test_package/test_package.c new file mode 100644 index 0000000000000..bb8f32fc3cf31 --- /dev/null +++ b/recipes/libsixel/all/test_package/test_package.c @@ -0,0 +1,19 @@ +#include +#include + +static int sixel_write(char *data, int size, void *priv) +{ + return fwrite(data, 1, size, (FILE *)priv); +} + +int main() { + SIXELSTATUS status = SIXEL_FALSE; + sixel_output_t *output = NULL; + + status = sixel_output_new(&output, sixel_write, stdout, NULL); + if (SIXEL_FAILED(status)) + return 1; + + return 0; +} + diff --git a/recipes/libsixel/config.yml b/recipes/libsixel/config.yml new file mode 100644 index 0000000000000..89d055dd00604 --- /dev/null +++ b/recipes/libsixel/config.yml @@ -0,0 +1,4 @@ +--- +versions: + "1.10.3": + folder: all diff --git a/recipes/libslz/all/CMakeLists.txt b/recipes/libslz/all/CMakeLists.txt new file mode 100644 index 0000000000000..3086b45fa1be2 --- /dev/null +++ b/recipes/libslz/all/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.8) +project(slz LANGUAGES C) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +include(GNUInstallDirs) + +add_library(slz source_subfolder/src/slz.c) +include_directories(source_subfolder/src) +set_target_properties(slz PROPERTIES + PUBLIC_HEADER source_subfolder/src/slz.h + WINDOWS_EXPORT_ALL_SYMBOLS ON + C_STANDARD 11 + C_EXTENSIONS ON +) + +install( + TARGETS slz + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/libslz/all/conandata.yml b/recipes/libslz/all/conandata.yml new file mode 100644 index 0000000000000..8f01e85db189d --- /dev/null +++ b/recipes/libslz/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.2.1": + url: "https://github.com/wtarreau/libslz/archive/v1.2.1.tar.gz" + sha256: "c1fa88556e97541a550e59fd1f0fc8f6b4c02444b14c13eb553c9827123122c5" + "1.2.0": + url: "https://github.com/wtarreau/libslz/archive/refs/tags/v1.2.0.tar.gz" + sha256: "723a8ef648ac5b30e5074c013ff61a5e5f54a5aafc9496f7dab9f6b02030bf24" diff --git a/recipes/libslz/all/conanfile.py b/recipes/libslz/all/conanfile.py new file mode 100644 index 0000000000000..b33407244e1eb --- /dev/null +++ b/recipes/libslz/all/conanfile.py @@ -0,0 +1,67 @@ +import functools +from conans import ConanFile, CMake, tools +from conans.tools import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc + +required_conan_version = ">=1.43.0" + +class LibslzConan(ConanFile): + name = "libslz" + description = "Simple, modern libpng alternative " + topics = ("zlib", "compression",) + license = "X11" + url = "https://github.com/conan-io/conan-center-index" + homepage = "http://www.libslz.org/" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration("{}/{} does not support Visual Studio.".format(self.name, self.version)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure() + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses", ignore_case=True, keep_path=False) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["slz"] diff --git a/recipes/libslz/all/test_package/CMakeLists.txt b/recipes/libslz/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..13e3af8ad2791 --- /dev/null +++ b/recipes/libslz/all/test_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libslz REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libslz::libslz) +set_target_properties(${PROJECT_NAME} PROPERTIES + C_STANDARD 11 + C_EXTENSIONS ON +) diff --git a/recipes/libslz/all/test_package/conanfile.py b/recipes/libslz/all/test_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/libslz/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libslz/all/test_package/test_package.c b/recipes/libslz/all/test_package/test_package.c new file mode 100644 index 0000000000000..afb3084384c50 --- /dev/null +++ b/recipes/libslz/all/test_package/test_package.c @@ -0,0 +1,21 @@ +#include +#include +#include + +#include "slz.h" + +int main(void) { + struct slz_stream strm; + unsigned char *outbuf; + + slz_make_crc_table(); + slz_prepare_dist_table(); + + slz_init(&strm, 3, SLZ_FMT_GZIP); + + outbuf = calloc(1, 1024 * 1024 * 2 + 4096); + + slz_finish(&strm, outbuf); + + return 0; +} diff --git a/recipes/libslz/config.yml b/recipes/libslz/config.yml new file mode 100644 index 0000000000000..9f174d514c33f --- /dev/null +++ b/recipes/libslz/config.yml @@ -0,0 +1,5 @@ +versions: + "1.2.1": + folder: all + "1.2.0": + folder: all diff --git a/recipes/libsmacker/all/conandata.yml b/recipes/libsmacker/all/conandata.yml index 552c15f4cedf9..5b45f961f0cf1 100644 --- a/recipes/libsmacker/all/conandata.yml +++ b/recipes/libsmacker/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "1.1.1r35": - patch_file: "patches/0001-install-header.patch" - base_path: "source_subfolder" diff --git a/recipes/libsmacker/all/conanfile.py b/recipes/libsmacker/all/conanfile.py index 3f0fac28de9ae..9e27911242b4d 100644 --- a/recipes/libsmacker/all/conanfile.py +++ b/recipes/libsmacker/all/conanfile.py @@ -1,17 +1,25 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from contextlib import contextmanager +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, rm +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version import os -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.53.0" class LibsmackerConan(ConanFile): name = "libsmacker" url = "https://github.com/conan-io/conan-center-index" homepage = "http://libsmacker.sourceforge.net" - topics = ("conan", "libsmacker", "decoding ", "smk", "smacker", "video", "file") + topics = ("decoding ", "smk", "smacker", "video", "file") license = "LGPL-2.1-or-later" description = "A C library for decoding .smk Smacker Video files" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -20,13 +28,13 @@ class LibsmackerConan(ConanFile): "shared": False, "fPIC": True, } - settings = "os", "arch", "compiler", "build_type" - exports_sources = "patches/**" - _autotools = None @property - def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -34,68 +42,58 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") def build_requirements(self): - self.build_requires("libtool/2.4.6") - if tools.os_info.is_windows: - self.build_requires("msys2/20200517") + self.tool_requires("libtool/2.4.7") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - v = tools.Version(self.version) - os.rename("libsmacker-{}.{}.{}".format(v.major, v.minor, v.patch), self._source_subfolder) - - @contextmanager - def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - env = { - "CC": "cl -nologo", - "CXX": "cl -nologo", - "LD": "link -nologo", - } - with tools.environment_append(env): - yield - else: - yield - - def _configure_autotools(self): - if self._autotools is not None: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self,win_bash=tools.os_info.is_windows) - self._autotools.libs = [] - yes_no = lambda v: "yes" if v else "no" - if self.settings.compiler == "Visual Studio": - self._autotools.flags.append("-FS") - args = [ - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), - ] - self._autotools.configure(configure_dir=self._source_subfolder, args=args) - return self._autotools + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + tc.generate() + + if is_msvc(self): + env = Environment() + env.define("CC", "cl -nologo") + env.define("CXX", "cl -nologo") + env.define("LD", "link -nologo") + env.vars(self).save_script("conanbuild_libsmacker_msvc") def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - with tools.chdir(self._source_subfolder): - self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() + apply_conandata_patches(self) + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() + autotools.make() def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() - - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") - if self.settings.compiler == "Visual Studio" and self.options.shared: - os.rename(os.path.join(self.package_folder, "lib", "smacker.dll.lib"), - os.path.join(self.package_folder, "lib", "smacker.lib")) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) + if is_msvc(self) and self.options.shared: + rename(self, os.path.join(self.package_folder, "lib", "smacker.dll.lib"), + os.path.join(self.package_folder, "lib", "smacker.lib")) def package_info(self): self.cpp_info.libs = ["smacker"] diff --git a/recipes/libsmacker/all/test_package/CMakeLists.txt b/recipes/libsmacker/all/test_package/CMakeLists.txt index 7b9b613cbb24a..27003d64c4b5a 100644 --- a/recipes/libsmacker/all/test_package/CMakeLists.txt +++ b/recipes/libsmacker/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libsmacker REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libsmacker::libsmacker) diff --git a/recipes/libsmacker/all/test_package/conanfile.py b/recipes/libsmacker/all/test_package/conanfile.py index 1dd7e559edc97..ca4f1763e0de3 100644 --- a/recipes/libsmacker/all/test_package/conanfile.py +++ b/recipes/libsmacker/all/test_package/conanfile.py @@ -1,9 +1,17 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) diff --git a/recipes/libsmacker/all/test_v1_package/CMakeLists.txt b/recipes/libsmacker/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libsmacker/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libsmacker/all/test_v1_package/conanfile.py b/recipes/libsmacker/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..3c3f444e8cad9 --- /dev/null +++ b/recipes/libsmacker/all/test_v1_package/conanfile.py @@ -0,0 +1,15 @@ +from conans import ConanFile, CMake + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + # No free .smk file to test. + pass diff --git a/recipes/libsndfile/1.0.28/conandata.yml b/recipes/libsndfile/1.0.28/conandata.yml deleted file mode 100644 index 964f9b6542206..0000000000000 --- a/recipes/libsndfile/1.0.28/conandata.yml +++ /dev/null @@ -1,4 +0,0 @@ -sources: - "1.0.28": - url: "http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.28.tar.gz" - sha256: "1ff33929f042fa333aed1e8923aa628c3ee9e1eb85512686c55092d1e5a9dfa9" diff --git a/recipes/libsndfile/1.0.28/conanfile.py b/recipes/libsndfile/1.0.28/conanfile.py deleted file mode 100644 index b9842cf5ac1d7..0000000000000 --- a/recipes/libsndfile/1.0.28/conanfile.py +++ /dev/null @@ -1,94 +0,0 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment, RunEnvironment -from conans.errors import ConanInvalidConfiguration -import os -import glob - - -class LibnameConan(ConanFile): - name = "libsndfile" - description = "Libsndfile is a library of C routines for reading and writing files containing sampled audio data." - topics = ("conan", "libsndfile", "sound") - url = "https://github.com/conan-io/conan-center-index" - homepage = "http://www.mega-nerd.com/libsndfile" - license = "LGPL-2.1" - generators = 'pkg_config' - settings = "os", "arch", "compiler", "build_type" - options = { - "shared": [True, False], - "fPIC": [True, False], - "with_alsa": [True, False], - "with_sqlite": [True, False], - "with_external_libs": [True, False]} - default_options = { - "shared": False, - "fPIC": True, - "with_alsa": True, - "with_sqlite": True, - "with_external_libs": True,} - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - def requirements(self): - if self.options.with_alsa: - self.requires("libalsa/1.1.9") - if self.options.with_sqlite: - self.requires("sqlite3/3.29.0") - if self.options.with_external_libs: - self.requires("flac/1.3.3") - self.requires("ogg/1.3.4") - self.requires("vorbis/1.3.7") - - def config_options(self): - if self.settings.os == 'Windows': - del self.options.fPIC - - def configure(self): - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("The project libsndfile can not be built by Visual Studio.") - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_autotools(self): - if not self._autotools: - self._autotools = AutoToolsBuildEnvironment(self) - args = [ - "--without-caps", - "--enable-alsa" if self.options.with_alsa else "--disable-alsa", - "--enable-sqlite" if self.options.with_sqlite else "--disable-sqlite", - "--enable-external-libs" if self.options.with_external_libs else "--disable-external-libs", - ] - if self.options.shared: - args.extend(['--enable-shared=yes', '--enable-static=no']) - else: - args.extend(['--enable-shared=no', '--enable-static=yes']) - self._autotools.configure(args=args, configure_dir=self._source_subfolder) - return self._autotools - - def build(self): - with tools.environment_append(RunEnvironment(self).vars): - autotools = self._configure_autotools() - autotools.make() - - def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - for f in glob.glob(os.path.join(self.package_folder, "lib", "*.la")): - os.remove(f) - - def package_info(self): - self.cpp_info.names['pkg_config'] = 'sndfile' - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["m", "dl", "pthread", "rt"] - diff --git a/recipes/libsndfile/1.0.28/test_package/test_package.c b/recipes/libsndfile/1.0.28/test_package/test_package.c deleted file mode 100644 index 70591e96d0d14..0000000000000 --- a/recipes/libsndfile/1.0.28/test_package/test_package.c +++ /dev/null @@ -1,75 +0,0 @@ -/* -** Copyright (C) 2001-2014 Erik de Castro Lopo -** -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the author nor the names of any contributors may be used -** to endorse or promote products derived from this software without -** specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include - -#include - -int -main (void) -{ SF_FORMAT_INFO info ; - SF_INFO sfinfo ; - int format, major_count, subtype_count, m, s ; - - memset (&sfinfo, 0, sizeof (sfinfo)) ; - printf ("Version : %s\n\n", sf_version_string ()) ; - - sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ; - - sfinfo.channels = 1 ; - for (m = 0 ; m < major_count ; m++) - { info.format = m ; - sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ; - printf ("%s (extension \"%s\")\n", info.name, info.extension) ; - - format = info.format ; - - for (s = 0 ; s < subtype_count ; s++) - { info.format = s ; - sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ; - - format = (format & SF_FORMAT_TYPEMASK) | info.format ; - - sfinfo.format = format ; - if (sf_format_check (&sfinfo)) - printf (" %s\n", info.name) ; - } ; - puts ("") ; - } ; - puts ("") ; - - return 0 ; -} /* main */ diff --git a/recipes/libsndfile/all/CMakeLists.txt b/recipes/libsndfile/all/CMakeLists.txt deleted file mode 100644 index bd3083b512cb9..0000000000000 --- a/recipes/libsndfile/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/libsndfile/all/conandata.yml b/recipes/libsndfile/all/conandata.yml index 7c1dd90225173..9c03d46a973d3 100644 --- a/recipes/libsndfile/all/conandata.yml +++ b/recipes/libsndfile/all/conandata.yml @@ -1,11 +1,15 @@ sources: - "1.0.29": - url: "https://github.com/erikd/libsndfile/archive/v1.0.29.tar.gz" - sha256: "c5541ccfa672b3f461ac21a38cdd37b1fe061cc62a422800b9d53649dee549ee" + "1.0.31": + url: "https://github.com/libsndfile/libsndfile/releases/download/1.0.31/libsndfile-1.0.31.tar.bz2" + sha256: "a8cfb1c09ea6e90eff4ca87322d4168cdbe5035cb48717b40bf77e751cc02163" "1.0.30": - url: "https://github.com/erikd/libsndfile/archive/v1.0.30.tar.gz" - sha256: "5942b963d1db3ed8ab1ffb85708322aa9637df76d9fe84e1dfe49a97a90e8f47" + url: "https://github.com/libsndfile/libsndfile/releases/download/v1.0.30/libsndfile-1.0.30.tar.bz2" + sha256: "9df273302c4fa160567f412e10cc4f76666b66281e7ba48370fb544e87e4611a" + "1.0.29": + url: "https://github.com/libsndfile/libsndfile/releases/download/v1.0.29/libsndfile-1.0.29.tar.bz2" + sha256: "2ba20d44817c8176f097ab25eff44ef0aeec9e00973def5a7174c5ae0764b22f" patches: + "1.0.31": + - patch_file: "patches/1.0.31-0001-fix-msvc-runtime-logic.patch" "1.0.30": - - base_path: source_subfolder - patch_file: patches/0001-disable-static-runtime-logic.patch + - patch_file: "patches/1.0.30-0001-disable-static-libgcc-mingw.patch" diff --git a/recipes/libsndfile/all/conanfile.py b/recipes/libsndfile/all/conanfile.py index b87ba73ac303f..945a12b9aff7b 100644 --- a/recipes/libsndfile/all/conanfile.py +++ b/recipes/libsndfile/all/conanfile.py @@ -1,22 +1,31 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version import os +required_conan_version = ">=1.50.0" + class LibsndfileConan(ConanFile): name = "libsndfile" license = "LGPL-2.1" url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.mega-nerd.com/libsndfile" - description = "Libsndfile is a library of C routines for reading and writing files containing sampled audio data." + description = ( + "Libsndfile is a library of C routines for reading and writing files " + "containing sampled audio data." + ) topics = ("audio") - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "programs": [True, False], "experimental": [True, False], "with_alsa": [True, False], - "with_sqlite": ["deprecated", True, False], "with_external_libs": [True, False], } default_options = { @@ -25,27 +34,12 @@ class LibsndfileConan(ConanFile): "programs": True, "experimental": False, "with_alsa": False, - "with_sqlite": "deprecated", "with_external_libs": True, - } - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" - - def requirements(self): - if self.options.get_safe("with_alsa"): - self.requires("libalsa/1.2.4") - if self.options.with_external_libs: - self.requires("ogg/1.3.4") - self.requires("vorbis/1.3.7") - self.requires("flac/1.3.3") - self.requires("opus/1.3.1") + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -55,71 +49,92 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.options.with_sqlite != "deprecated": - self.output.warn("with_sqlite is a deprecated option. Do not use.") - del self.options.with_sqlite + + def requirements(self): + if self.options.get_safe("with_alsa"): + self.requires("libalsa/1.2.7.2") + if self.options.with_external_libs: + self.requires("ogg/1.3.5") + self.requires("vorbis/1.3.7") + self.requires("flac/1.3.3") + self.requires("opus/1.3.1") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Sndio"] = True # FIXME: missing sndio cci recipe (check whether it is really required) - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Speex"] = True # FIXME: missing sndio cci recipe (check whether it is really required) - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_SQLite3"] = True # only used for regtest - self._cmake.definitions["ENABLE_EXTERNAL_LIBS"] = self.options.with_external_libs + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Sndio"] = True # FIXME: missing sndio cci recipe (check whether it is really required) + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Speex"] = True # FIXME: missing sndio cci recipe (check whether it is really required) + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_SQLite3"] = True # only used for regtest + tc.variables["ENABLE_EXTERNAL_LIBS"] = self.options.with_external_libs if not self.options.with_external_libs: - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Ogg"] = True - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Vorbis"] = True - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_FLAC"] = True - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Opus"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Ogg"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Vorbis"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_FLAC"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Opus"] = True if not self.options.get_safe("with_alsa", False): - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_ALSA"] = True - self._cmake.definitions["BUILD_PROGRAMS"] = self.options.programs - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.definitions["ENABLE_CPACK"] = False - self._cmake.definitions["ENABLE_EXPERIMENTAL"] = self.options.experimental - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["ENABLE_STATIC_RUNTIME"] = "MT" in str(self.settings.compiler.runtime) - self._cmake.definitions["BUILD_REGTEST"] = False - self._cmake.configure() - return self._cmake + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_ALSA"] = True + tc.variables["BUILD_PROGRAMS"] = self.options.programs + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_TESTING"] = False + tc.variables["ENABLE_CPACK"] = False + tc.variables["ENABLE_EXPERIMENTAL"] = self.options.experimental + if is_msvc(self) and Version(self.version) < "1.0.30": + tc.variables["ENABLE_STATIC_RUNTIME"] = is_msvc_static_runtime(self) + tc.variables["BUILD_REGTEST"] = False + # Fix iOS/tvOS/watchOS + tc.variables["CMAKE_MACOSX_BUNDLE"] = False + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "SndFile" - self.cpp_info.names["cmake_find_package"] = "SndFile" - self.cpp_info.names["pkg_config"] = "sndfile" + self.cpp_info.set_property("cmake_file_name", "SndFile") + self.cpp_info.set_property("cmake_target_name", "SndFile::sndfile") + self.cpp_info.set_property("pkg_config_name", "sndfile") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed self.cpp_info.components["sndfile"].libs = ["sndfile"] if self.options.with_external_libs: - self.cpp_info.components["sndfile"].requires.extend(["ogg::ogg", "vorbis::vorbismain", "vorbis::vorbisenc", "flac::flac", "opus::opus"]) + self.cpp_info.components["sndfile"].requires.extend([ + "ogg::ogg", "vorbis::vorbismain", "vorbis::vorbisenc", + "flac::flac", "opus::opus", + ]) + if self.options.get_safe("with_alsa"): + self.cpp_info.components["sndfile"].requires.append("libalsa::libalsa") if not self.options.shared: - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["sndfile"].system_libs = ["m", "dl", "pthread", "rt"] elif self.settings.os == "Windows": self.cpp_info.components["sndfile"].system_libs.append("winmm") - if self.options.get_safe("with_alsa"): - self.cpp_info.components["sndfile"].requires.append("libalsa::libalsa") - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) + if self.options.programs: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "SndFile" + self.cpp_info.names["cmake_find_package_multi"] = "SndFile" + self.cpp_info.components["sndfile"].set_property("cmake_target_name", "SndFile::sndfile") diff --git a/recipes/libsndfile/all/patches/0001-disable-static-runtime-logic.patch b/recipes/libsndfile/all/patches/0001-disable-static-runtime-logic.patch deleted file mode 100644 index 1de3ec58e57ae..0000000000000 --- a/recipes/libsndfile/all/patches/0001-disable-static-runtime-logic.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/cmake/SndFileChecks.cmake b/cmake/SndFileChecks.cmake -index 3528c325..f9e43c91 100644 ---- a/cmake/SndFileChecks.cmake -+++ b/cmake/SndFileChecks.cmake -@@ -213,7 +213,7 @@ if (MSVC) - add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) - endif (MSVC) - --if (MINGW) -+if (FALSE) - if (CMAKE_C_COMPILER_ID STREQUAL GNU) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc") - set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s") -@@ -232,7 +232,7 @@ if (MINGW) - endif () - endif () - --if (DEFINED ENABLE_STATIC_RUNTIME) -+if (FALSE) - if (MSVC) - if (CMAKE_VERSION VERSION_LESS 3.15) - if (ENABLE_STATIC_RUNTIME) diff --git a/recipes/libsndfile/all/patches/1.0.30-0001-disable-static-libgcc-mingw.patch b/recipes/libsndfile/all/patches/1.0.30-0001-disable-static-libgcc-mingw.patch new file mode 100644 index 0000000000000..f7e1a5bf32674 --- /dev/null +++ b/recipes/libsndfile/all/patches/1.0.30-0001-disable-static-libgcc-mingw.patch @@ -0,0 +1,11 @@ +--- a/cmake/SndFileChecks.cmake ++++ b/cmake/SndFileChecks.cmake +@@ -213,7 +213,7 @@ if (MSVC) + add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) + endif (MSVC) + +-if (MINGW) ++if (FALSE) + if (CMAKE_C_COMPILER_ID STREQUAL GNU) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc") + set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s") diff --git a/recipes/libsndfile/all/patches/1.0.31-0001-fix-msvc-runtime-logic.patch b/recipes/libsndfile/all/patches/1.0.31-0001-fix-msvc-runtime-logic.patch new file mode 100644 index 0000000000000..abada26c071ce --- /dev/null +++ b/recipes/libsndfile/all/patches/1.0.31-0001-fix-msvc-runtime-logic.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -8,7 +8,7 @@ if (POLICY CMP0091) + return () + endif () + +- if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) ++ if (1) + cmake_policy (SET CMP0091 NEW) + else () + cmake_policy (SET CMP0091 OLD) diff --git a/recipes/libsndfile/all/test_package/CMakeLists.txt b/recipes/libsndfile/all/test_package/CMakeLists.txt index a9ca2324c4d7e..3fb4ef12f8bc8 100644 --- a/recipes/libsndfile/all/test_package/CMakeLists.txt +++ b/recipes/libsndfile/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(SndFile REQUIRED CONFIG) -find_package(SndFile REQUIRED) - -add_executable(example example.cpp) -target_link_libraries(example PRIVATE SndFile::sndfile) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE SndFile::sndfile) diff --git a/recipes/libsndfile/all/test_package/conanfile.py b/recipes/libsndfile/all/test_package/conanfile.py index 6adfe2d570be6..d120a992c06a6 100644 --- a/recipes/libsndfile/all/test_package/conanfile.py +++ b/recipes/libsndfile/all/test_package/conanfile.py @@ -1,11 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" -class LibsndfileTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libsndfile/all/test_package/example.cpp b/recipes/libsndfile/all/test_package/example.cpp deleted file mode 100644 index f57cb6d29eb41..0000000000000 --- a/recipes/libsndfile/all/test_package/example.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "sndfile.hh" - -int main(int argc, char *argv[]) { - if (argc < 2) { - std::cout << "Usage: example " << std::endl; - } else { - SndfileHandle handle(argv[1]); - std::cout << "Sample rate: " << handle.samplerate() << std::endl; - } - return 0; -} diff --git a/recipes/libsndfile/all/test_package/test_package.cpp b/recipes/libsndfile/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2f577c46055c5 --- /dev/null +++ b/recipes/libsndfile/all/test_package/test_package.cpp @@ -0,0 +1,17 @@ +#include "sndfile.hh" + +#if __cplusplus < 201100 && defined(_MSC_VER) +#undef nullptr +#endif + +#include + +int main(int argc, char *argv[]) { + if (argc < 2) { + std::cout << "Usage: example \n"; + } else { + SndfileHandle handle(argv[1]); + std::cout << "Sample rate: " << handle.samplerate() << "\n"; + } + return 0; +} diff --git a/recipes/libsndfile/all/test_v1_package/CMakeLists.txt b/recipes/libsndfile/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9d5c55d61ca3e --- /dev/null +++ b/recipes/libsndfile/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(SndFile REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE SndFile::sndfile) diff --git a/recipes/libsndfile/all/test_v1_package/conanfile.py b/recipes/libsndfile/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libsndfile/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libsndfile/config.yml b/recipes/libsndfile/config.yml index e8517463de02e..c83c8ed241a58 100644 --- a/recipes/libsndfile/config.yml +++ b/recipes/libsndfile/config.yml @@ -1,7 +1,7 @@ versions: - "1.0.28": - folder: "1.0.28" - "1.0.29": + "1.0.31": folder: "all" "1.0.30": folder: "all" + "1.0.29": + folder: "all" diff --git a/recipes/libsodium/1.0.18/conandata.yml b/recipes/libsodium/1.0.18/conandata.yml deleted file mode 100644 index 922b2f2fc2fc7..0000000000000 --- a/recipes/libsodium/1.0.18/conandata.yml +++ /dev/null @@ -1,8 +0,0 @@ -sources: - "1.0.18": - url: "https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz" - sha256: "6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1" -patches: - "1.0.18": - - patch_file: "patches/msvc_props.patch" - base_path: "source_subfolder" diff --git a/recipes/libsodium/1.0.18/conanfile.py b/recipes/libsodium/1.0.18/conanfile.py deleted file mode 100644 index 8ce70f3d4d8f2..0000000000000 --- a/recipes/libsodium/1.0.18/conanfile.py +++ /dev/null @@ -1,215 +0,0 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools, MSBuild -from conans.errors import ConanInvalidConfiguration -import os - - -class LibsodiumConan(ConanFile): - name = "libsodium" - description = "A modern and easy-to-use crypto library." - license = "ISC" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://download.libsodium.org/doc/" - exports_sources = ["patches/**"] - settings = "os", "compiler", "arch", "build_type" - topics = ("sodium", "libsodium", "encryption", "signature", "hashing") - generators = "cmake" - _source_subfolder = "source_subfolder" - short_paths = True - - options = { - "shared" : [True, False], - "fPIC": [True, False], - "use_soname" : [True, False], - "PIE" : [True, False], - } - - default_options = { - "shared": False, - "fPIC": True, - "use_soname": True, - "PIE": False, - } - - @property - def _android_id_str(self): - return "androideabi" if str(self.settings.arch) in ["armv6", "armv7"] else "android" - - @property - def _is_mingw(self): - return self.settings.os == "Windows" and self.settings.compiler == "gcc" - - @property - def _vs_configuration(self): - configuration = "" - if self.options.shared: - configuration += "Dyn" - else: - configuration += "Static" - build_type = "Debug" if self.settings.build_type == "Debug" else "Release" - configuration += build_type - return configuration - - @property - def _vs_sln_folder(self): - folder = {"14": "vs2015", - "15": "vs2017", - "16": "vs2019"}.get(str(self.settings.compiler.version), None) - if not folder: - raise ConanInvalidConfiguration("Unsupported msvc version: {}".format(self.settings.compiler.version)) - return folder - - def configure(self): - if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - def build_requirements(self): - # There are several unix tools used (bash scripts for Emscripten, autoreconf on MinGW, etc...) - if self.settings.compiler != "Visual Studio" and tools.os_info.is_windows and \ - not "CONAN_BASH_PATH" in os.environ and tools.os_info.detect_windows_subsystem() != "Windows": - self.build_requires("msys2/20190524") - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _build_visual(self): - sln_path = os.path.join(self.build_folder, self._source_subfolder, "builds", "msvc", self._vs_sln_folder, "libsodium.sln") - - msbuild = MSBuild(self) - msbuild.build(sln_path, upgrade_project=False, platforms={"x86": "Win32"}, build_type=self._vs_configuration) - - def _build_autotools_impl(self, configure_args, host_arch=None): - win_bash = False - if self._is_mingw: - win_bash = True - - autotools = AutoToolsBuildEnvironment(self, win_bash=win_bash) - if self._is_mingw: - self.run("autoreconf -i", cwd=self._source_subfolder, win_bash=win_bash) - host = None - if host_arch: - host = False - configure_args.append("--host=%s" % host_arch) - autotools.configure(args=configure_args, configure_dir=self._source_subfolder, host=host) - autotools.make(args=["-j%s" % str(tools.cpu_count())]) - autotools.install() - - def _build_autotools_linux(self, configure_args): - self._build_autotools_impl(configure_args) - - def _build_autotools_emscripten(self, configure_args): - self.run("./dist-build/emscripten.sh --standard", cwd=self._source_subfolder) - - def _build_autotools_android(self, configure_args): - host_arch = "%s-linux-%s" % (tools.to_android_abi(self.settings.arch), self._android_id_str) - self._build_autotools_impl(configure_args, host_arch) - - def _build_autotools_mingw(self, configure_args): - arch = "i686" if self.settings.arch == "x86" else self.settings.arch - host_arch = "%s-w64-mingw32" % arch - self._build_autotools_impl(configure_args, host_arch) - - def _build_autotools_darwin(self, configure_args): - os = "ios" if self.settings.os == "iOS" else "darwin" - host_arch = "%s-apple-%s" % (self.settings.arch, os) - self._build_autotools_impl(configure_args, host_arch) - - def _build_autotools_neutrino(self, configure_args): - neutrino_archs = {"x86_64":"x86_64-pc", "x86":"i586-pc", "armv7":"arm-unknown", "armv8": "aarch64-unknown"} - if self.settings.os.version == "7.0" and str(self.settings.arch) in neutrino_archs: - host_arch = "%s-nto-qnx7.0.0" % neutrino_archs[str(self.settings.arch)] - if self.settings.arch == "armv7": - host_arch += "eabi" - else: - raise ConanInvalidConfiguration("Unsupported arch or Neutrino version for libsodium: {} {}".format(self.settings.os, self.settings.arch)) - self._build_autotools_impl(configure_args, host_arch) - - def _build_autotools(self): - absolute_install_dir = os.path.abspath(os.path.join(".", "install")) - absolute_install_dir = absolute_install_dir.replace("\\", "/") - configure_args = self._get_configure_args(absolute_install_dir) - - if self.settings.os in ["Linux", "FreeBSD"]: - self._build_autotools_linux(configure_args) - elif self.settings.os == "Emscripten": - self._build_autotools_emscripten(configure_args) - elif self.settings.os == "Android": - self._build_autotools_android(configure_args) - elif tools.is_apple_os(self.settings.os): - self._build_autotools_darwin(configure_args) - elif self._is_mingw: - self._build_autotools_mingw(configure_args) - elif self.settings.os == "Neutrino": - self._build_autotools_neutrino(configure_args) - else: - raise ConanInvalidConfiguration("Unsupported os for libsodium: {}".format(self.settings.os)) - - def validate(self): - if self.settings.compiler == "Visual Studio": - if self.options.shared and "MT" in str(self.settings.compiler.runtime): - raise ConanInvalidConfiguration("Cannot build shared libsodium libraries with MT(d) runtime") - - def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - if self.settings.os == "Macos": - tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), r"-install_name \$rpath/", "-install_name ") - if self.settings.compiler != "Visual Studio": - self._build_autotools() - else: - self._build_visual() - - def package(self): - self.copy("*LICENSE", dst="licenses", keep_path=False) - if self.settings.compiler == "Visual Studio": - self._package_visual() - else: - self._package_autotools() - - def package_info(self): - if self.settings.compiler == "Visual Studio": - if not self.options.shared: - self.cpp_info.defines = ["SODIUM_STATIC=1"] - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.system_libs = ["pthread"] - - def _package_autotools(self): - if self.settings.os == "Emscripten": - prefix = "%s/libsodium-js" % self._source_subfolder - else: - prefix = "install" - lib_folder = os.path.join(prefix, "lib") - self.copy("*.h", dst="include", src=os.path.join(prefix, "include")) - self.copy("*.a", dst="lib", src=lib_folder) - self.copy("*.so*", dst="lib", src=lib_folder, symlinks=True) - self.copy("*.dylib", dst="lib", src=lib_folder, symlinks=True) - - def _package_visual(self): - self.copy("*.lib", dst="lib", keep_path=False) - self.copy("*.dll", dst="bin", keep_path=False) - inc_src = os.path.join(self._source_subfolder, "src", self.name, "include") - self.copy("*.h", src=inc_src, dst="include", keep_path=True, excludes=("*/private/*")) - - def _autotools_bool_arg(self, arg_base_name, value): - prefix = "--enable-" if value else "--disable-" - return prefix + arg_base_name - - def _get_configure_args(self, absolute_install_dir): - args = [ - "--prefix=%s" % absolute_install_dir, - self._autotools_bool_arg("shared", self.options.shared), - self._autotools_bool_arg("static", not self.options.shared), - self._autotools_bool_arg("soname-versions", self.options.use_soname), - self._autotools_bool_arg("pie", self.options.PIE) - ] - if self.options.get_safe("fPIC"): - args.append("--with-pic") - return args diff --git a/recipes/libsodium/1.0.18/test_package/CMakeLists.txt b/recipes/libsodium/1.0.18/test_package/CMakeLists.txt deleted file mode 100644 index f2ec50a6f8cc9..0000000000000 --- a/recipes/libsodium/1.0.18/test_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.0) -project(Example CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_executable(example test.cpp) -target_link_libraries(example CONAN_PKG::libsodium) diff --git a/recipes/libsodium/1.0.18/test_package/conanfile.py b/recipes/libsodium/1.0.18/test_package/conanfile.py deleted file mode 100644 index a8b19845b3ba5..0000000000000 --- a/recipes/libsodium/1.0.18/test_package/conanfile.py +++ /dev/null @@ -1,24 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class PackageTest(ConanFile): - settings = "os", "compiler", "arch", "build_type" - generators = "cmake" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if tools.cross_building(self.settings): - if self.settings.os == "Emscripten": - exe_name = "example.js" - elif self.settings.os == "Windows": - exe_name = "example.exe" - else: - exe_name = "example" - assert(os.path.exists(os.path.join("bin", exe_name))) - else: - self.run(os.path.join("bin", "example"), run_environment=True) diff --git a/recipes/libsodium/1.0.18/test_package/test.cpp b/recipes/libsodium/1.0.18/test_package/test.cpp deleted file mode 100644 index d4912d7df8fcc..0000000000000 --- a/recipes/libsodium/1.0.18/test_package/test.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include - -#include - -int main(void){ - - std::cout << "************* Testing libsodium ***************" << std::endl; - - if (sodium_init() == -1) { - return 1; - } - - std::cout << "\tOK" << std::endl; - std::cout << "***********************************************" << std::endl; - - return 0; -} diff --git a/recipes/libsodium/all/conandata.yml b/recipes/libsodium/all/conandata.yml new file mode 100644 index 0000000000000..d0974216f8865 --- /dev/null +++ b/recipes/libsodium/all/conandata.yml @@ -0,0 +1,18 @@ +# To update the version on CCI, add a new cci.date entry from the stable branch: +# https://github.com/jedisct1/libsodium/commits/stable +sources: + "1.0.18": + url: "https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz" + sha256: "6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1" + "cci.20220430": + url: "https://github.com/jedisct1/libsodium/archive/78b6f57493a02a70fca44e5ef3f9d7d1cae9029f.tar.gz" + sha256: "5274b09894c0a7d6676325277cb2e278f45e1e5e077bae4bd8778aba4d6d40da" +patches: + "1.0.18": + - patch_file: "patches/0001-1.0.18-msvc_props.patch" + patch_type: "portability" + patch_description: "Switch MSVC to use PDB" + "cci.20220430": + - patch_file: "patches/0001-1.0.18-msvc_props.patch" + patch_type: "portability" + patch_description: "Switch MSVC to use PDB" diff --git a/recipes/libsodium/all/conanfile.py b/recipes/libsodium/all/conanfile.py new file mode 100644 index 0000000000000..48c328202cd68 --- /dev/null +++ b/recipes/libsodium/all/conanfile.py @@ -0,0 +1,246 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration, ConanException +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import export_conandata_patches, apply_conandata_patches, get, rmdir, copy, rm, replace_in_file +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, MSBuildDeps, MSBuildToolchain, MSBuild, VCVars, unix_path, msvc_runtime_flag, vs_layout +import os + +required_conan_version = ">=1.52.0" + + +class LibsodiumConan(ConanFile): + name = "libsodium" + description = "A modern and easy-to-use crypto library." + license = "ISC" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://doc.libsodium.org/" + topics = "encryption", "signature", "hashing" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "use_soname": [True, False], + "PIE": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "use_soname": True, + "PIE": False, + } + + @property + def _is_mingw(self): + return self.settings.os == "Windows" and self.settings.compiler == "gcc" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + if is_msvc(self): + vs_layout(self) + else: + basic_layout(self, src_folder="src") + + def validate(self): + if self.options.shared and is_msvc(self) and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration("Cannot build shared libsodium libraries with static runtime") + + def build_requirements(self): + if not is_msvc(self): + if self._is_mingw: + self.tool_requires("libtool/2.4.7") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def generate(self): + if is_msvc(self): + tc = MSBuildToolchain(self) + tc.generate() + tc = MSBuildDeps(self) + tc.generate() + tc = VCVars(self) + tc.generate() + else: + tc = AutotoolsToolchain(self) + + yes_no = lambda v: "yes" if v else "no" + tc.configure_args.append("--enable-soname-versions={}".format(yes_no(self.options.use_soname))) + tc.configure_args.append("--enable-pie={}".format(yes_no(self.options.PIE))) + + env = tc.environment() + + # if self._is_mingw: + # add libssp (gcc support library) for some missing symbols (e.g. __strcpy_chk) + # FIXME how do I do this in conan v2? + # autotools.libs.append("ssp") + + if self.settings.os == "Emscripten": + # FIXME: this is an old comment/test, has not been re-tested with conan2 upgrade + self.output.warn("os=Emscripten is not tested/supported by this recipe") + # FIXME: ./dist-build/emscripten.sh does not respect options of this recipe + + tc.generate(env) + + env = VirtualBuildEnv(self) + env.generate() + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + @property + def _msvc_sln_folder(self): + if self.settings.compiler == "Visual Studio": + folder = { + "10": "vs2010", + "11": "vs2012", + "12": "vs2013", + "14": "vs2015", + "15": "vs2017", + "16": "vs2019", + } + elif self.settings.compiler == "msvc": + folder = { + "190": "vs2015", + "191": "vs2017", + "192": "vs2019", + } + else: + raise ConanException("Should not call this function with any other compiler") + + if self.version != "1.0.18": + if self.settings.compiler == "Visual Studio": + folder["17"] = "vs2022" + else: + folder["193"] = "vs2022" + + return folder.get(str(self.settings.compiler.version)) + + @property + def _msvc_platform(self): + return { + "x86": "Win32", + "x86_64": "x64", + }[str(self.settings.arch)] + + # Method copied from xz_utils + def _fix_msvc_platform_toolset(self, vcxproj_file, old_toolset): + platform_toolset = { + "Visual Studio": { + "8": "v80", + "9": "v90", + "10": "v100", + "11": "v110", + "12": "v120", + "14": "v140", + "15": "v141", + "16": "v142", + "17": "v143", + }, + "msvc": { + "170": "v110", + "180": "v120", + "190": "v140", + "191": "v141", + "192": "v142", + "193": "v143", + } + }.get(str(self.settings.compiler), {}).get(str(self.settings.compiler.version)) + if not platform_toolset: + raise ConanException( + f"Unknown platform toolset for {self.settings.compiler} {self.settings.compiler.version}", + ) + replace_in_file( + self, + vcxproj_file, + f"{old_toolset}", + f"{platform_toolset}", + ) + + def _build_msvc(self): + msvc_ver_subfolder = self._msvc_sln_folder or ("vs2022" if self.version != "1.0.18" else "vs2019") + msvc_sln_folder = os.path.join(self.build_folder, self.source_folder, "builds", "msvc", msvc_ver_subfolder) + + msvc_sln_path = os.path.join(msvc_sln_folder, "libsodium.sln") + + # 1.0.18 only supported up to vs2019. Add support for newer toolsets. + if self.version == "1.0.18" and msvc_ver_subfolder == "vs2019": + vcxproj_path = os.path.join(msvc_sln_folder, "libsodium", "libsodium.vcxproj") + self._fix_msvc_platform_toolset(vcxproj_path, "v142") + + build_type = "{}{}".format( + "Dyn" if self.options.shared else "Static", + "Debug" if self.settings.build_type == "Debug" else "Release", + ) + + platform = { + "x86": "Win32", + "x86_64": "x64", + }[str(self.settings.arch)] + + msbuild = MSBuild(self) + msbuild.build_type = build_type + msbuild.platform = platform + msbuild.build(msvc_sln_path) + + + def build(self): + apply_conandata_patches(self) + if is_msvc(self): + self._build_msvc() + else: + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "*LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"), keep_path=False) + if is_msvc(self): + copy(self, "*.lib", src=self.source_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.dll", src=self.source_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False) + inc_src = os.path.join(self.source_folder, "src", self.name, "include") + copy(self, "*.h", src=inc_src, dst=os.path.join(self.package_folder, "include"), keep_path=True, excludes=("*/private/*")) + else: + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libsodium") + self.cpp_info.libs = ["{}sodium".format("lib" if is_msvc(self) else "")] + if not self.options.shared: + self.cpp_info.defines = ["SODIUM_STATIC"] + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs.append("pthread") + if self._is_mingw: + self.cpp_info.system_libs.append("ssp") diff --git a/recipes/libsodium/1.0.18/patches/msvc_props.patch b/recipes/libsodium/all/patches/0001-1.0.18-msvc_props.patch similarity index 100% rename from recipes/libsodium/1.0.18/patches/msvc_props.patch rename to recipes/libsodium/all/patches/0001-1.0.18-msvc_props.patch diff --git a/recipes/libsodium/all/test_package/CMakeLists.txt b/recipes/libsodium/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b1d5e6b147fa4 --- /dev/null +++ b/recipes/libsodium/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +find_package(libsodium REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libsodium::libsodium) diff --git a/recipes/libsodium/all/test_package/conanfile.py b/recipes/libsodium/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e845ae751a301 --- /dev/null +++ b/recipes/libsodium/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libsodium/all/test_package/test_package.c b/recipes/libsodium/all/test_package/test_package.c new file mode 100644 index 0000000000000..3db01e0a3bd07 --- /dev/null +++ b/recipes/libsodium/all/test_package/test_package.c @@ -0,0 +1,13 @@ +#include +#include + +int main() { + printf("************* Testing libsodium ***************\n"); + if (sodium_init() == -1) { + printf("\tFAIL\n"); + return 1; + } + printf("\tOK\n"); + printf("***********************************************\n"); + return 0; +} diff --git a/recipes/libsodium/all/test_v1_package/CMakeLists.txt b/recipes/libsodium/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b8e19e1fbee26 --- /dev/null +++ b/recipes/libsodium/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libsodium/all/test_v1_package/conanfile.py b/recipes/libsodium/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a299b64446c9 --- /dev/null +++ b/recipes/libsodium/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "arch", "build_type" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libsodium/config.yml b/recipes/libsodium/config.yml new file mode 100644 index 0000000000000..819e72ce10826 --- /dev/null +++ b/recipes/libsodium/config.yml @@ -0,0 +1,5 @@ +versions: + "1.0.18": + folder: all + "cci.20220430": + folder: all diff --git a/recipes/libspatialindex/all/CMakeLists.txt b/recipes/libspatialindex/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/libspatialindex/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libspatialindex/all/conandata.yml b/recipes/libspatialindex/all/conandata.yml index a465e365310a1..b2aedf72ba427 100644 --- a/recipes/libspatialindex/all/conandata.yml +++ b/recipes/libspatialindex/all/conandata.yml @@ -4,7 +4,6 @@ sources: sha256: "7b44340a3edc55c11abfc453bb60f148b29f569cef9e1148583e76132e9c7379" patches: "1.9.3": - - patch_file: "patches/fix-static-and-mingw.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix-capi.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-fix-static-and-mingw.patch" + - patch_file: "patches/0002-fix-capi.patch" + - patch_file: "patches/0003-macos-install-name.patch" diff --git a/recipes/libspatialindex/all/conanfile.py b/recipes/libspatialindex/all/conanfile.py index bed67414f7582..29ce2fecc218f 100644 --- a/recipes/libspatialindex/all/conanfile.py +++ b/recipes/libspatialindex/all/conanfile.py @@ -1,29 +1,35 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get +from conan.tools.microsoft import is_msvc +from conans import tools as tools_legacy import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.50.0" + class LibspatialindexConan(ConanFile): name = "libspatialindex" description = "C++ implementation of R*-tree, an MVR-tree and a TPR-tree with C API." license = "MIT" - topics = ("conan", "libspatialindex", "spatial-indexing", "tree") + topics = ("libspatialindex", "spatial-indexing", "tree") homepage = "https://github.com/libspatialindex/libspatialindex" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -32,53 +38,66 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["SIDX_BUILD_TESTS"] = False + tc.variables["SIDX_BIN_SUBDIR"] = "bin" + tc.variables["SIDX_LIB_SUBDIR"] = "lib" + tc.variables["SIDX_INCLUDE_SUBDIR"] = "include" + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["SIDX_BUILD_TESTS"] = False - self._cmake.definitions["SIDX_BIN_SUBDIR"] = "bin" - self._cmake.definitions["SIDX_LIB_SUBDIR"] = "lib" - self._cmake.definitions["SIDX_INCLUDE_SUBDIR"] = "include" - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): + self.cpp_info.set_property("cmake_file_name", "libspatialindex") + self.cpp_info.set_property("pkg_config_name", "libspatialindex") + suffix = self._get_lib_suffix() + + self.cpp_info.components["spatialindex"].set_property("cmake_target_name", "libspatialindex::spatialindex") self.cpp_info.components["spatialindex"].libs = ["spatialindex" + suffix] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["spatialindex"].system_libs.append("m") + if not self.options.shared: + libcxx = tools_legacy.stdcpp_library(self) + if libcxx: + self.cpp_info.components["spatialindex"].system_libs.append(libcxx) + + self.cpp_info.components["spatialindex_c"].set_property("cmake_target_name", "libspatialindex::spatialindex_c") self.cpp_info.components["spatialindex_c"].libs = ["spatialindex_c" + suffix] self.cpp_info.components["spatialindex_c"].requires = ["spatialindex"] - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.components["spatialindex"].system_libs.append(tools.stdcpp_library(self)) - self.cpp_info.components["spatialindex_c"].system_libs.append(tools.stdcpp_library(self)) - if not self.options.shared and self.settings.compiler == "Visual Studio": + + if not self.options.shared and is_msvc(self): self.cpp_info.components["spatialindex"].defines.append("SIDX_STATIC") self.cpp_info.components["spatialindex_c"].defines.append("SIDX_STATIC") def _get_lib_suffix(self): suffix = "" - if self.settings.compiler == "Visual Studio": - libs = tools.collect_libs(self) + if is_msvc(self): + libs = collect_libs(self) for lib in libs: if "spatialindex_c" in lib: suffix = lib.split("spatialindex_c", 1)[1] diff --git a/recipes/libspatialindex/all/patches/fix-static-and-mingw.patch b/recipes/libspatialindex/all/patches/0001-fix-static-and-mingw.patch similarity index 100% rename from recipes/libspatialindex/all/patches/fix-static-and-mingw.patch rename to recipes/libspatialindex/all/patches/0001-fix-static-and-mingw.patch diff --git a/recipes/libspatialindex/all/patches/fix-capi.patch b/recipes/libspatialindex/all/patches/0002-fix-capi.patch similarity index 100% rename from recipes/libspatialindex/all/patches/fix-capi.patch rename to recipes/libspatialindex/all/patches/0002-fix-capi.patch diff --git a/recipes/libspatialindex/all/patches/0003-macos-install-name.patch b/recipes/libspatialindex/all/patches/0003-macos-install-name.patch new file mode 100644 index 0000000000000..ce6a3416ea278 --- /dev/null +++ b/recipes/libspatialindex/all/patches/0003-macos-install-name.patch @@ -0,0 +1,18 @@ +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -246,6 +246,7 @@ endif() + + + ++if(0) + if (APPLE) + set_target_properties( + ${SIDX_LIB_NAME} +@@ -257,6 +258,7 @@ if (APPLE) + PROPERTIES + INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" BUILD_WITH_INSTALL_RPATH OFF) + endif() ++endif() + + ############################################################################### + # Targets installation diff --git a/recipes/libspatialindex/all/test_package/CMakeLists.txt b/recipes/libspatialindex/all/test_package/CMakeLists.txt index 1d6cb95a10497..485d6719dfdb8 100644 --- a/recipes/libspatialindex/all/test_package/CMakeLists.txt +++ b/recipes/libspatialindex/all/test_package/CMakeLists.txt @@ -1,14 +1,11 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(libspatialindex REQUIRED) +find_package(libspatialindex REQUIRED CONFIG) add_executable(test_package_c test_package.c) -target_link_libraries(test_package_c libspatialindex::spatialindex_c) +target_link_libraries(test_package_c PRIVATE libspatialindex::spatialindex_c) add_executable(test_package_cpp test_package.cpp) -target_link_libraries(test_package_cpp libspatialindex::spatialindex) -set_property(TARGET test_package_cpp PROPERTY CXX_STANDARD 11) +target_link_libraries(test_package_cpp PRIVATE libspatialindex::spatialindex) +target_compile_features(test_package_cpp PRIVATE cxx_std_11) diff --git a/recipes/libspatialindex/all/test_package/conanfile.py b/recipes/libspatialindex/all/test_package/conanfile.py index c546f967bdf30..94db9a10dc181 100644 --- a/recipes/libspatialindex/all/test_package/conanfile.py +++ b/recipes/libspatialindex/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,8 +20,8 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path_c = os.path.join("bin", "test_package_c") - self.run(bin_path_c, run_environment=True) - bin_path_cpp = os.path.join("bin", "test_package_cpp") - self.run(bin_path_cpp, run_environment=True) + if not cross_building(self): + bin_path_c = os.path.join(self.cpp.build.bindirs[0], "test_package_c") + self.run(bin_path_c, env="conanrun") + bin_path_cpp = os.path.join(self.cpp.build.bindirs[0], "test_package_cpp") + self.run(bin_path_cpp, env="conanrun") diff --git a/recipes/libspatialindex/all/test_v1_package/CMakeLists.txt b/recipes/libspatialindex/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e225733af6e93 --- /dev/null +++ b/recipes/libspatialindex/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libspatialindex REQUIRED CONFIG) + +add_executable(test_package_c ../test_package/test_package.c) +target_link_libraries(test_package_c PRIVATE libspatialindex::spatialindex_c) + +add_executable(test_package_cpp ../test_package/test_package.cpp) +target_link_libraries(test_package_cpp PRIVATE libspatialindex::spatialindex) +target_compile_features(test_package_cpp PRIVATE cxx_std_11) diff --git a/recipes/libspatialindex/all/test_v1_package/conanfile.py b/recipes/libspatialindex/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..46d74ca8fdf82 --- /dev/null +++ b/recipes/libspatialindex/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path_c = os.path.join("bin", "test_package_c") + self.run(bin_path_c, run_environment=True) + bin_path_cpp = os.path.join("bin", "test_package_cpp") + self.run(bin_path_cpp, run_environment=True) diff --git a/recipes/libspatialite/all/conandata.yml b/recipes/libspatialite/all/conandata.yml new file mode 100644 index 0000000000000..0aae59d1f7126 --- /dev/null +++ b/recipes/libspatialite/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "5.0.1": + url: "https://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-5.0.1.tar.gz" + sha256: "eecbc94311c78012d059ebc0fae86ea5ef6eecb13303e6e82b3753c1b3409e98" +patches: + "5.0.1": + - patch_file: "patches/0001-autotools-no-geos-config.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-nmake-honor-flags.patch" + base_path: "source_subfolder" + - patch_file: "patches/0003-msvc-minizip.patch" + base_path: "source_subfolder" diff --git a/recipes/libspatialite/all/conanfile.py b/recipes/libspatialite/all/conanfile.py new file mode 100644 index 0000000000000..f8d65b6681064 --- /dev/null +++ b/recipes/libspatialite/all/conanfile.py @@ -0,0 +1,249 @@ +from conans import ConanFile, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment, tools +import functools +import os + +required_conan_version = ">=1.36.0" + + +class LibspatialiteConan(ConanFile): + name = "libspatialite" + description = ( + "SpatiaLite is an open source library intended to extend the SQLite " + "core to support fully fledged Spatial SQL capabilities." + ) + license = ("MPL-1.1", "GPL-2.0-or-later", "LGPL-2.1-or-later") + topics = ("spatialite", "database", "sql", "sqlite", "ogc") + homepage = "https://www.gaia-gis.it/fossil/libspatialite" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "mathsql": [True, False], + "geocallbacks": [True, False], + "knn": [True, False], + "epsg": [True, False], + "geopackage": [True, False], + "gcp": [True, False], + "with_proj": [True, False], + "with_iconv": [True, False], + "with_freexl": [True, False], + "with_geos": [True, False], + "with_rttopo": [True, False], + "with_libxml2": [True, False], + "with_minizip": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "mathsql": True, + "geocallbacks": True, + "knn": True, + "epsg": True, + "geopackage": True, + "gcp": True, + "with_proj": True, + "with_iconv": True, + "with_freexl": True, + "with_geos": True, + "with_rttopo": True, + "with_libxml2": True, + "with_minizip": True, + } + + generators = "pkg_config" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if not self.options.with_geos: + del self.options.with_rttopo + del self.options.gcp + + def requirements(self): + self.requires("sqlite3/3.38.1") + self.requires("zlib/1.2.12") + if self.options.with_proj: + self.requires("proj/9.0.0") + if self.options.with_iconv: + self.requires("libiconv/1.16") + if self.options.with_freexl: + self.requires("freexl/1.0.6") + if self.options.with_geos: + self.requires("geos/3.10.2") + if self.options.get_safe("with_rttopo"): + self.requires("librttopo/1.1.0") + if self.options.with_libxml2: + self.requires("libxml2/2.9.13") + if self.options.with_minizip: + self.requires("minizip/1.2.12") + + def build_requirements(self): + if not self._is_msvc: + self.build_requires("libtool/2.4.6") + self.build_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _build_msvc(self): + # Visual Studio build doesn't provide options, we need to manually edit gaiaconfig-msvc.h + gaiaconfig_msvc = os.path.join(self._source_subfolder, "src", "headers", "spatialite", "gaiaconfig-msvc.h") + if not self.options.mathsql: + tools.replace_in_file(gaiaconfig_msvc, "/* #undef OMIT_MATHSQL */", "#define OMIT_MATHSQL 1") + if self.options.geocallbacks: + tools.replace_in_file(gaiaconfig_msvc, "#define OMIT_GEOCALLBACKS 1", "") + if not self.options.knn: + tools.replace_in_file(gaiaconfig_msvc, "/* #undef OMIT_KNN */", "#define OMIT_KNN 1") + if not self.options.epsg: + tools.replace_in_file(gaiaconfig_msvc, "/* #undef OMIT_EPSG */", "#define OMIT_EPSG 1") + if not self.options.geopackage: + tools.replace_in_file(gaiaconfig_msvc, "#define ENABLE_GEOPACKAGE 1", "") + if not self.options.get_safe("gcp", False): + tools.replace_in_file(gaiaconfig_msvc, "#define ENABLE_GCP 1", "") + if not self.options.with_proj: + tools.replace_in_file(gaiaconfig_msvc, "/* #undef OMIT_PROJ */", "#define OMIT_PROJ 1") + if not self.options.with_iconv: + tools.replace_in_file(gaiaconfig_msvc, "/* #undef OMIT_ICONV */", "#define OMIT_ICONV 1") + if not self.options.with_freexl: + tools.replace_in_file(gaiaconfig_msvc, "/* #undef OMIT_FREEXL */", "#define OMIT_FREEXL 1") + if not self.options.with_geos: + tools.replace_in_file(gaiaconfig_msvc, "/* #undef OMIT_GEOS */", "#define OMIT_GEOS 1") + if not self.options.get_safe("with_rttopo", False): + tools.replace_in_file(gaiaconfig_msvc, "#define ENABLE_RTTOPO 1", "") + if not self.options.with_libxml2: + tools.replace_in_file(gaiaconfig_msvc, "#define ENABLE_LIBXML2 1", "") + if not self.options.with_minizip: + tools.replace_in_file(gaiaconfig_msvc, "#define ENABLE_MINIZIP 1", "") + + target = "spatialite_i.lib" if self.options.shared else "spatialite.lib" + optflags = ["-DYY_NO_UNISTD_H"] + system_libs = [lib + ".lib" for lib in self.deps_cpp_info.system_libs] + if self.options.shared: + optflags.append("-DDLL_EXPORT") + with tools.chdir(self._source_subfolder): + with tools.vcvars(self): + with tools.environment_append(VisualStudioBuildEnvironment(self).vars): + self.run("nmake -f makefile.vc {} OPTFLAGS=\"{}\" SYSTEM_LIBS=\"{}\"".format(target, + " ".join(optflags), + " ".join(system_libs))) + + def _build_autotools(self): + # fix MinGW + tools.replace_in_file(os.path.join(self._source_subfolder, "configure.ac"), + "AC_CHECK_LIB(z,", + "AC_CHECK_LIB({},".format(self.deps_cpp_info["zlib"].libs[0])) + # Disable tests + tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.am"), + "SUBDIRS = src test $(EXAMPLES)", + "SUBDIRS = src $(EXAMPLES)") + + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + # relocatable shared libs on macOS + tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name @rpath/") + # avoid SIP issues on macOS when dependencies are shared + if tools.is_apple_os(self.settings.os): + libpaths = ":".join(self.deps_cpp_info.lib_paths) + tools.replace_in_file( + "configure", + "#! /bin/sh\n", + "#! /bin/sh\nexport DYLD_LIBRARY_PATH={}:$DYLD_LIBRARY_PATH\n".format(libpaths), + ) + with tools.run_environment(self): + autotools = self._configure_autotools() + autotools.make() + + @functools.lru_cache(1) + def _configure_autotools(self): + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-static={}".format(yes_no(not self.options.shared)), + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-mathsql={}".format(yes_no(self.options.mathsql)), + "--enable-geocallbacks={}".format(yes_no(self.options.geocallbacks)), + "--enable-knn={}".format(yes_no(self.options.knn)), + "--enable-proj={}".format(yes_no(self.options.with_proj)), + "--enable-iconv={}".format(yes_no(self.options.with_iconv)), + "--enable-freexl={}".format(yes_no(self.options.with_freexl)), + "--enable-epsg={}".format(yes_no(self.options.epsg)), + "--enable-geos={}".format(yes_no(self.options.with_geos)), + "--enable-libxml2={}".format(yes_no(self.options.with_libxml2)), + "--enable-minizip={}".format(yes_no(self.options.with_minizip)), + "--enable-geopackage={}".format(yes_no(self.options.geopackage)), + "--disable-gcov", + "--disable-examples", + "--disable-module-only", + ] + if self.options.with_geos: + args.extend([ + "--enable-gcp={}".format(yes_no(self.options.gcp)), + "--enable-geosadvanced=yes", + "--enable-geosreentrant=yes", + "--enable-geosonlyreentrant=no", + "--enable-geos370=yes", + "--enable-rttopo={}".format(yes_no(self.options.with_rttopo)), + ]) + + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + autotools.configure(args=args) + return autotools + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + if self._is_msvc: + self._build_msvc() + else: + self._build_autotools() + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + if self._is_msvc: + self.copy("spatialite.h", dst="include", src=os.path.join(self._source_subfolder, "src", "headers")) + self.copy("*.h", dst=os.path.join("include", "spatialite"), src=os.path.join(self._source_subfolder, "src", "headers", "spatialite")) + self.copy("*.lib", dst="lib", src=self._source_subfolder) + self.copy("*.dll", dst="bin", src=self._source_subfolder) + else: + with tools.chdir(self._source_subfolder): + with tools.run_environment(self): + autotools = self._configure_autotools() + autotools.install() + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "spatialite") + suffix = "_i" if self._is_msvc and self.options.shared else "" + self.cpp_info.libs = ["spatialite{}".format(suffix)] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["m", "pthread"]) + + # TODO: to remove in conan v2 once pkg_config generator removed + self.cpp_info.names["pkg_config"] = "spatialite" diff --git a/recipes/libspatialite/all/patches/0001-autotools-no-geos-config.patch b/recipes/libspatialite/all/patches/0001-autotools-no-geos-config.patch new file mode 100644 index 0000000000000..0da26fe7f8512 --- /dev/null +++ b/recipes/libspatialite/all/patches/0001-autotools-no-geos-config.patch @@ -0,0 +1,22 @@ +We can't use geos-config file in conan because it's a non-relocatable file, +therefore not packaged by geos recipe of conan-center-index. +Instead we rely on AutoToolsBuildEnvironment helper to inject proper flags. + +--- a/configure.ac ++++ b/configure.ac +@@ -311,6 +311,7 @@ AC_ARG_ENABLE(geos, [AS_HELP_STRING( + [--enable-geos], [enables GEOS inclusion [default=yes]])], + [], [enable_geos=yes]) + if test x"$enable_geos" != "xno"; then ++ if false; then + #----------------------------------------------------------------------- + # --with-geosconfig + # +@@ -352,6 +353,7 @@ if test x"$enable_geos" != "xno"; then + AC_SEARCH_LIBS(GEOSCoveredBy,geos_c,,AC_MSG_ERROR([could not find libgeos_c (or obsolete 'libgeos_c' < v.3.3.0 found) - you may need to specify the directory of a geos-config file using --with-geosconfig])) + LIBS="$LIBS_SAVE" + LIBS="$LIBS $GEOS_LDFLAGS -lgeos_c" ++ fi + + #----------------------------------------------------------------------- + # --enable-controlpoints diff --git a/recipes/libspatialite/all/patches/0002-nmake-honor-flags.patch b/recipes/libspatialite/all/patches/0002-nmake-honor-flags.patch new file mode 100644 index 0000000000000..e58e6153c5dbb --- /dev/null +++ b/recipes/libspatialite/all/patches/0002-nmake-honor-flags.patch @@ -0,0 +1,37 @@ +This patch for msvc build allows to: +* define OPTFLAG ourself from conanfile (allow to honor profile) +* inject a custom SYSTEM_LIBS variable from conanfile (allow robust shared build) +* not hardcode this very specific C:\OSGeo4W environment + +--- a/makefile.vc ++++ b/makefile.vc +@@ -2,7 +2,6 @@ + # + # NMAKE Makefile to build libspatialite on Windows + # +-!INCLUDE nmake.opt + + LIBOBJ = src\gaiaaux\gg_sqlaux.obj src\gaiaaux\gg_utf8.obj \ + src\gaiaexif\gaia_exif.obj src\gaiageo\gg_advanced.obj \ +@@ -93,7 +92,7 @@ LIBOBJ = src\gaiaaux\gg_sqlaux.obj src\gaiaaux\gg_utf8.obj \ + SPATIALITE_DLL = spatialite$(VERSION).dll + + CFLAGS = /nologo -I.\src\headers -I.\src\topology \ +- -I. -IC:\OSGeo4W\include $(OPTFLAGS) ++ -I. $(CFLAGS) $(OPTFLAGS) + + default: all + +@@ -108,11 +107,7 @@ $(SPATIALITE_DLL): spatialite_i.lib + + spatialite_i.lib: $(LIBOBJ) + link /dll /out:$(SPATIALITE_DLL) \ +- /implib:spatialite_i.lib $(LIBOBJ) \ +- C:\OSGeo4W\lib\proj_i.lib C:\OSGeo4W\lib\geos_c.lib \ +- C:\OSGeo4w\lib\freexl_i.lib C:\OSGeo4w\lib\iconv.lib \ +- C:\OSGeo4W\lib\sqlite3_i.lib C:\OSGeo4W\lib\zlib.lib \ +- C:\OSGeo4W\lib\libxml2.lib C:\OSGeo4W\lib\librttopo.lib ++ /implib:spatialite_i.lib $(LIBOBJ) $(SYSTEM_LIBS) + if exist $(SPATIALITE_DLL).manifest mt -manifest \ + $(SPATIALITE_DLL).manifest -outputresource:$(SPATIALITE_DLL);2 + diff --git a/recipes/libspatialite/all/patches/0003-msvc-minizip.patch b/recipes/libspatialite/all/patches/0003-msvc-minizip.patch new file mode 100644 index 0000000000000..82678ede01691 --- /dev/null +++ b/recipes/libspatialite/all/patches/0003-msvc-minizip.patch @@ -0,0 +1,12 @@ +--- a/src/headers/spatialite/gaiaconfig-msvc.h ++++ b/src/headers/spatialite/gaiaconfig-msvc.h +@@ -10,6 +10,9 @@ + /* Should be defined in order to enable LIBXML2 support. */ + #define ENABLE_LIBXML2 1 + ++/* Should be defined in order to enable MiniZIP support. */ ++#define ENABLE_MINIZIP 1 ++ + /* Should be defined in order to enable RTTOPO support. */ + #define ENABLE_RTTOPO 1 + diff --git a/recipes/libspatialite/all/test_package/CMakeLists.txt b/recipes/libspatialite/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3e0f638e21270 --- /dev/null +++ b/recipes/libspatialite/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libspatialite REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libspatialite::libspatialite) diff --git a/recipes/libspatialite/all/test_package/conanfile.py b/recipes/libspatialite/all/test_package/conanfile.py new file mode 100644 index 0000000000000..697dfef261b53 --- /dev/null +++ b/recipes/libspatialite/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libspatialite/all/test_package/test_package.c b/recipes/libspatialite/all/test_package/test_package.c new file mode 100644 index 0000000000000..a61e47b9833c1 --- /dev/null +++ b/recipes/libspatialite/all/test_package/test_package.c @@ -0,0 +1,13 @@ +#include +#include + +#include + +int main(void) { + printf("libspatialite info:\n"); + printf("-- version: %s\n", spatialite_version()); + printf("-- target cpu: %s\n", spatialite_target_cpu()); + spatialite_initialize(); + spatialite_shutdown(); + return 0; +} diff --git a/recipes/libspatialite/config.yml b/recipes/libspatialite/config.yml new file mode 100644 index 0000000000000..5787f28e91cf3 --- /dev/null +++ b/recipes/libspatialite/config.yml @@ -0,0 +1,3 @@ +versions: + "5.0.1": + folder: all diff --git a/recipes/libspng/all/conandata.yml b/recipes/libspng/all/conandata.yml new file mode 100644 index 0000000000000..7ca9b017ec8e0 --- /dev/null +++ b/recipes/libspng/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "0.7.2": + url: "https://github.com/randy408/libspng/archive/refs/tags/v0.7.2.tar.gz" + sha256: "4acf25571d31f540d0b7ee004f5461d68158e0a13182505376805da99f4ccc4e" +patches: + "0.7.2": + - patch_file: "patches/0.7.2-0001-fix-dll-install.patch" + - patch_file: "patches/0.7.2-0002-allow-miniz.patch" diff --git a/recipes/libspng/all/conanfile.py b/recipes/libspng/all/conanfile.py new file mode 100644 index 0000000000000..f75595db03548 --- /dev/null +++ b/recipes/libspng/all/conanfile.py @@ -0,0 +1,82 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +import os + +required_conan_version = ">=1.53.0" + + +class LibspngConan(ConanFile): + name = "libspng" + description = "Simple, modern libpng alternative " + topics = ("png", "libpng", "spng") + license = "BSD-2-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/randy408/libspng/" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_miniz": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_miniz": False, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_miniz: + self.requires("miniz/2.2.0") + else: + self.requires("zlib/1.2.13") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["SPNG_SHARED"] = self.options.shared + tc.variables["SPNG_STATIC"] = not self.options.shared + tc.variables["SPNG_USE_MINIZ"] = self.options.with_miniz + tc.variables["BUILD_EXAMPLES"] = False + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libspng") + if not self.options.shared: + self.cpp_info.defines = ["SPNG_STATIC"] + self.cpp_info.libs = ["spng"] if self.options.shared else ["spng_static"] + if self.settings.os in ["Linux", "Android", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/libspng/all/patches/0.7.2-0001-fix-dll-install.patch b/recipes/libspng/all/patches/0.7.2-0001-fix-dll-install.patch new file mode 100644 index 0000000000000..223612a7c7b6c --- /dev/null +++ b/recipes/libspng/all/patches/0.7.2-0001-fix-dll-install.patch @@ -0,0 +1,16 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -32,7 +32,12 @@ endif() + if(SPNG_SHARED) + add_library(spng SHARED ${spng_SOURCES}) + target_link_libraries(spng ${spng_LIBS}) +- install(TARGETS spng DESTINATION lib) ++ install( ++ TARGETS spng ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ) + + if(BUILD_EXAMPLES) + add_executable(example examples/example.c) diff --git a/recipes/libspng/all/patches/0.7.2-0002-allow-miniz.patch b/recipes/libspng/all/patches/0.7.2-0002-allow-miniz.patch new file mode 100644 index 0000000000000..7393b3d483583 --- /dev/null +++ b/recipes/libspng/all/patches/0.7.2-0002-allow-miniz.patch @@ -0,0 +1,62 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.0) ++cmake_minimum_required(VERSION 3.1) + + project(libspng C) + +@@ -10,19 +10,24 @@ set(SPNG_VERSION ${SPNG_MAJOR}.${SPNG_MINOR}.${SPNG_REVISION}) + option(ENABLE_OPT "Enable architecture-specific optimizations" ON) + option(SPNG_SHARED "Build shared lib" ON) + option(SPNG_STATIC "Build static lib" ON) ++option(SPNG_USE_MINIZ "Use Miniz instead of zlib" OFF) + option(BUILD_EXAMPLES "Build examples" ON) + + include(GNUInstallDirs) + +-find_package(ZLIB REQUIRED) +-include_directories(${ZLIB_INCLUDE_DIRS}) ++if(SPNG_USE_MINIZ) ++ find_package(miniz REQUIRED) ++ set(spng_LIBS miniz::miniz) ++else() ++ find_package(ZLIB REQUIRED) ++ set(spng_LIBS ZLIB::ZLIB) ++endif() + + set(spng_SOURCES spng/spng.c) + +-if(NOT CMAKE_HOST_WIN32) +- set(spng_LIBS -lm ${ZLIB_LIBRARIES}) +-else() +- set(spng_LIBS ${ZLIB_LIBRARIES}) ++find_library(LIBM NAMES m) ++if(LIBM) ++ list(APPEND spng_LIBS ${LIBM}) + endif() + + if(NOT ENABLE_OPT) +@@ -31,7 +36,10 @@ endif() + + if(SPNG_SHARED) + add_library(spng SHARED ${spng_SOURCES}) +- target_link_libraries(spng ${spng_LIBS}) ++ target_link_libraries(spng PRIVATE ${spng_LIBS}) ++ if(SPNG_USE_MINIZ) ++ target_compile_definitions(spng PRIVATE SPNG_USE_MINIZ) ++ endif() + install( + TARGETS spng + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +@@ -48,6 +56,10 @@ endif() + + if(SPNG_STATIC) + add_library(spng_static STATIC ${spng_SOURCES}) ++ target_link_libraries(spng_static PRIVATE ${spng_LIBS}) ++ if(SPNG_USE_MINIZ) ++ target_compile_definitions(spng_static PRIVATE SPNG_USE_MINIZ) ++ endif() + target_compile_definitions(spng_static PUBLIC SPNG_STATIC) + install(TARGETS spng_static DESTINATION lib) + endif() diff --git a/recipes/libspng/all/test_package/CMakeLists.txt b/recipes/libspng/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c8aa2ff46daf5 --- /dev/null +++ b/recipes/libspng/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(libspng REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libspng::libspng) diff --git a/recipes/libspng/all/test_package/conanfile.py b/recipes/libspng/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libspng/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libspng/all/test_package/test_package.c b/recipes/libspng/all/test_package/test_package.c new file mode 100644 index 0000000000000..95b202395f7c0 --- /dev/null +++ b/recipes/libspng/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include +#include + +#include "spng.h" + +int main(void) { + fprintf(stderr, " Compiled with libspng %s.\n", spng_version_string()); + + return 0; +} diff --git a/recipes/libspng/all/test_v1_package/CMakeLists.txt b/recipes/libspng/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libspng/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libspng/all/test_v1_package/conanfile.py b/recipes/libspng/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libspng/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libspng/config.yml b/recipes/libspng/config.yml new file mode 100644 index 0000000000000..eb766ff2f024b --- /dev/null +++ b/recipes/libspng/config.yml @@ -0,0 +1,3 @@ +versions: + "0.7.2": + folder: all diff --git a/recipes/libsquish/all/CMakeLists.txt b/recipes/libsquish/all/CMakeLists.txt deleted file mode 100644 index 041901c43d3aa..0000000000000 --- a/recipes/libsquish/all/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.0.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") - -target_include_directories(squish PUBLIC - $ - $ -) -set_target_properties(squish PROPERTIES CXX_VISIBILITY_PRESET hidden) -include(GenerateExportHeader) -generate_export_header(squish) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squish_export.h DESTINATION include) diff --git a/recipes/libsquish/all/conandata.yml b/recipes/libsquish/all/conandata.yml index 76e58a54ac7cd..bc1d40ba45206 100644 --- a/recipes/libsquish/all/conandata.yml +++ b/recipes/libsquish/all/conandata.yml @@ -4,7 +4,5 @@ sources: sha256: "628796eeba608866183a61d080d46967c9dda6723bc0a3ec52324c85d2147269" patches: "1.15": - - patch_file: "patches/export-symbols.patch" - base_path: "source_subfolder" - - patch_file: "patches/fix-cmake-simd-openmp-install.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-fix-cmake-simd-openmp-install.patch" + - patch_file: "patches/0002-export-symbols.patch" diff --git a/recipes/libsquish/all/conanfile.py b/recipes/libsquish/all/conanfile.py index 161514d309589..712e4727a04db 100644 --- a/recipes/libsquish/all/conanfile.py +++ b/recipes/libsquish/all/conanfile.py @@ -1,43 +1,36 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.46.0" + class LibsquishConan(ConanFile): name = "libsquish" description = "The libSquish library compresses images with the DXT " \ "standard (also known as S3TC)." license = "MIT" - topics = ("conan", "libsquish", "image", "compression", "dxt", "s3tc") + topics = ("libsquish", "image", "compression", "dxt", "s3tc") homepage = "https://sourceforge.net/projects/libsquish" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "openmp": [True, False], "sse2_intrinsics": [True, False], - "altivec_intrinsics": [True, False] + "altivec_intrinsics": [True, False], } default_options = { "shared": False, "fPIC": True, "openmp": False, "sse2_intrinsics": False, - "altivec_intrinsics": False + "altivec_intrinsics": False, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - @property def _sse2_compliant_archs(self): return ["x86", "x86_64"] @@ -46,6 +39,10 @@ def _sse2_compliant_archs(self): def _altivec_compliant_archs(self): return ["ppc32be", "ppc32", "ppc64le", "ppc64"] + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -54,33 +51,36 @@ def config_options(self): if self.settings.arch not in self._altivec_compliant_archs: del self.options.altivec_intrinsics + def configure(self): + if self.options.shared: + del self.options.fPIC + + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_SQUISH_WITH_OPENMP"] = self.options.openmp + tc.variables["BUILD_SQUISH_WITH_SSE2"] = self.options.get_safe("sse2_intrinsics") or False + tc.variables["BUILD_SQUISH_WITH_ALTIVEC"] = self.options.get_safe("altivec_intrinsics") or False + tc.variables["BUILD_SQUISH_EXTRA"] = False + tc.generate() def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_SQUISH_WITH_OPENMP"] = self.options.openmp - self._cmake.definitions["BUILD_SQUISH_WITH_SSE2"] = self.options.get_safe("sse2_intrinsics") or False - self._cmake.definitions["BUILD_SQUISH_WITH_ALTIVEC"] = self.options.get_safe("altivec_intrinsics") or False - self._cmake.definitions["BUILD_SQUISH_EXTRA"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.libs = collect_libs(self) + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") diff --git a/recipes/libsquish/all/patches/0001-fix-cmake-simd-openmp-install.patch b/recipes/libsquish/all/patches/0001-fix-cmake-simd-openmp-install.patch new file mode 100644 index 0000000000000..66ec394efce8b --- /dev/null +++ b/recipes/libsquish/all/patches/0001-fix-cmake-simd-openmp-install.patch @@ -0,0 +1,94 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -9,9 +9,9 @@ + # Unix and VS: SSE2 support is enabled by default + # use BUILD_SQUISH_WITH_SSE2 and BUILD_SQUISH_WITH_ALTIVEC to override + ++CMAKE_MINIMUM_REQUIRED(VERSION 3.13) + PROJECT(squish) + +-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3) + + OPTION(BUILD_SQUISH_WITH_OPENMP "Build with OpenMP." ON) + +@@ -22,25 +22,6 @@ OPTION(BUILD_SHARED_LIBS "Build shared libraries." OFF) + + OPTION(BUILD_SQUISH_EXTRA "Build extra source code." OFF) + +-IF (BUILD_SQUISH_WITH_OPENMP) +- FIND_PACKAGE(OpenMP) +- IF (OPENMP_FOUND) +- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") +- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +- ADD_DEFINITIONS(-DSQUISH_USE_OPENMP) +- ENDIF() +-ENDIF() +- +-IF (CMAKE_GENERATOR STREQUAL "Xcode") +- SET(CMAKE_OSX_ARCHITECTURES "i386;ppc") +-ELSE (CMAKE_GENERATOR STREQUAL "Xcode") +- IF (BUILD_SQUISH_WITH_SSE2 AND NOT WIN32) +- ADD_DEFINITIONS(-DSQUISH_USE_SSE=2 -msse2) +- ENDIF (BUILD_SQUISH_WITH_SSE2 AND NOT WIN32) +- IF (BUILD_SQUISH_WITH_ALTIVEC AND NOT WIN32) +- ADD_DEFINITIONS(-DSQUISH_USE_ALTIVEC=1 -maltivec) +- ENDIF (BUILD_SQUISH_WITH_ALTIVEC AND NOT WIN32) +-ENDIF (CMAKE_GENERATOR STREQUAL "Xcode") + + SET(SQUISH_HDRS + squish.h +@@ -74,6 +55,34 @@ SET(SQUISH_SRCS + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + + ADD_LIBRARY(squish ${SQUISH_SRCS} ${SQUISH_HDRS}) ++IF(BUILD_SQUISH_WITH_OPENMP) ++ IF(NOT TARGET OpenMP::OpenMP_CXX) ++ FIND_PACKAGE(Threads REQUIRED) ++ ADD_LIBRARY(OpenMP::OpenMP_CXX IMPORTED INTERFACE) ++ SET_PROPERTY(TARGET OpenMP::OpenMP_CXX PROPERTY INTERFACE_COMPILE_OPTIONS ${OpenMP_CXX_FLAGS}) ++ SET_PROPERTY(TARGET OpenMP::OpenMP_CXX PROPERTY INTERFACE_LINK_LIBRARIES ${OpenMP_CXX_FLAGS} Threads::Threads) ++ ENDIF() ++ TARGET_LINK_LIBRARIES(squish PRIVATE OpenMP::OpenMP_CXX) ++ TARGET_COMPILE_DEFINITIONS(squish PRIVATE "SQUISH_USE_OPENMP") ++ENDIF() ++ ++IF(BUILD_SQUISH_WITH_SSE2) ++ TARGET_COMPILE_DEFINITIONS(squish PRIVATE "SQUISH_USE_SSE=2") ++ IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR ++ "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR ++ "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") ++ TARGET_COMPILE_OPTIONS(squish PRIVATE -msse2) ++ ENDIF() ++ENDIF() ++ ++IF(BUILD_SQUISH_WITH_ALTIVEC) ++ TARGET_COMPILE_DEFINITIONS(squish PRIVATE "SQUISH_USE_ALTIVEC=1") ++ IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR ++ "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR ++ "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") ++ TARGET_COMPILE_OPTIONS(squish PRIVATE -maltivec) ++ ENDIF() ++ENDIF() + + SET_TARGET_PROPERTIES( + squish PROPERTIES +@@ -81,12 +90,6 @@ SET_TARGET_PROPERTIES( + VERSION 0.0 + SOVERSION 0.0 + DEBUG_POSTFIX "d" +- XCODE_ATTRIBUTE_GCC_PREPROCESSOR_DEFINITIONS "$(SQUISH_CPP_$(CURRENT_ARCH))" +- XCODE_ATTRIBUTE_OTHER_CFLAGS "$(SQUISH_CFLAGS_$(CURRENT_ARCH))" +- XCODE_ATTRIBUTE_SQUISH_CPP_i386 "SQUISH_USE_SSE=2" +- XCODE_ATTRIBUTE_SQUISH_CFLAGS_i386 "" +- XCODE_ATTRIBUTE_SQUISH_CPP_ppc "SQUISH_USE_ALTIVEC=1" +- XCODE_ATTRIBUTE_SQUISH_CFLAGS_ppc "-maltivec" + ) + + IF (BUILD_SQUISH_EXTRA) +@@ -113,5 +116,6 @@ INSTALL( + TARGETS squish + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib ++ RUNTIME DESTINATION bin + PUBLIC_HEADER DESTINATION include + ) diff --git a/recipes/libsquish/all/patches/0002-export-symbols.patch b/recipes/libsquish/all/patches/0002-export-symbols.patch new file mode 100644 index 0000000000000..75e8cf3ad77f2 --- /dev/null +++ b/recipes/libsquish/all/patches/0002-export-symbols.patch @@ -0,0 +1,88 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -119,3 +119,14 @@ INSTALL( + RUNTIME DESTINATION bin + PUBLIC_HEADER DESTINATION include + ) ++target_include_directories(squish PUBLIC ++ $ ++ $ ++) ++set_target_properties(squish PROPERTIES ++ CXX_VISIBILITY_PRESET hidden ++ VISIBILITY_INLINES_HIDDEN TRUE ++) ++include(GenerateExportHeader) ++generate_export_header(squish) ++install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squish_export.h DESTINATION include) +--- a/squish.h ++++ b/squish.h +@@ -26,6 +26,8 @@ + #ifndef SQUISH_H + #define SQUISH_H + ++#include "squish_export.h" ++ + //! All squish API functions live in this namespace. + namespace squish { + +@@ -113,7 +115,7 @@ enum + { 0.2126f, 0.7152f, 0.0722f }. If non-NULL, the metric should point to a + contiguous array of 3 floats. + */ +-void CompressMasked( u8 const* rgba, int mask, void* block, int flags, float* metric = 0 ); ++SQUISH_EXPORT void CompressMasked( u8 const* rgba, int mask, void* block, int flags, float* metric = 0 ); + + // ----------------------------------------------------------------------------- + +@@ -176,7 +178,7 @@ inline void Compress( u8 const* rgba, void* block, int flags, float* metric = 0 + however, DXT1 will be used by default if none is specified. All other flags + are ignored. + */ +-void Decompress( u8* rgba, void const* block, int flags ); ++SQUISH_EXPORT void Decompress( u8* rgba, void const* block, int flags ); + + // ----------------------------------------------------------------------------- + +@@ -194,7 +196,7 @@ void Decompress( u8* rgba, void const* block, int flags ); + function supports arbitrary size images by allowing the outer blocks to + be only partially used. + */ +-int GetStorageRequirements( int width, int height, int flags ); ++SQUISH_EXPORT int GetStorageRequirements( int width, int height, int flags ); + + // ----------------------------------------------------------------------------- + +@@ -249,8 +251,8 @@ int GetStorageRequirements( int width, int height, int flags ); + Windows platform but for other platforms like MacOS X a different + gamma value may be more suitable. + */ +-void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 ); +-void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 ); ++SQUISH_EXPORT void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 ); ++SQUISH_EXPORT void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 ); + + // ----------------------------------------------------------------------------- + +@@ -274,8 +276,8 @@ void CompressImage( u8 const* rgba, int width, int height, void* blocks, int fla + + Internally this function calls squish::Decompress for each block. + */ +-void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags ); +-void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags ); ++SQUISH_EXPORT void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags ); ++SQUISH_EXPORT void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags ); + + // ----------------------------------------------------------------------------- + +@@ -299,8 +301,8 @@ void DecompressImage( u8* rgba, int width, int height, void const* blocks, int f + + Internally this function calls squish::Decompress for each block. + */ +-void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); +-void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); ++SQUISH_EXPORT void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); ++SQUISH_EXPORT void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); + + // ----------------------------------------------------------------------------- + diff --git a/recipes/libsquish/all/patches/export-symbols.patch b/recipes/libsquish/all/patches/export-symbols.patch deleted file mode 100644 index 72c0e96710765..0000000000000 --- a/recipes/libsquish/all/patches/export-symbols.patch +++ /dev/null @@ -1,71 +0,0 @@ ---- a/squish.h -+++ b/squish.h -@@ -26,6 +26,8 @@ - #ifndef SQUISH_H - #define SQUISH_H - -+#include "squish_export.h" -+ - //! All squish API functions live in this namespace. - namespace squish { - -@@ -113,7 +115,7 @@ enum - { 0.2126f, 0.7152f, 0.0722f }. If non-NULL, the metric should point to a - contiguous array of 3 floats. - */ --void CompressMasked( u8 const* rgba, int mask, void* block, int flags, float* metric = 0 ); -+SQUISH_EXPORT void CompressMasked( u8 const* rgba, int mask, void* block, int flags, float* metric = 0 ); - - // ----------------------------------------------------------------------------- - -@@ -176,7 +178,7 @@ inline void Compress( u8 const* rgba, void* block, int flags, float* metric = 0 - however, DXT1 will be used by default if none is specified. All other flags - are ignored. - */ --void Decompress( u8* rgba, void const* block, int flags ); -+SQUISH_EXPORT void Decompress( u8* rgba, void const* block, int flags ); - - // ----------------------------------------------------------------------------- - -@@ -194,7 +196,7 @@ void Decompress( u8* rgba, void const* block, int flags ); - function supports arbitrary size images by allowing the outer blocks to - be only partially used. - */ --int GetStorageRequirements( int width, int height, int flags ); -+SQUISH_EXPORT int GetStorageRequirements( int width, int height, int flags ); - - // ----------------------------------------------------------------------------- - -@@ -249,8 +251,8 @@ int GetStorageRequirements( int width, int height, int flags ); - Windows platform but for other platforms like MacOS X a different - gamma value may be more suitable. - */ --void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 ); --void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 ); -+SQUISH_EXPORT void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 ); -+SQUISH_EXPORT void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 ); - - // ----------------------------------------------------------------------------- - -@@ -274,8 +276,8 @@ void CompressImage( u8 const* rgba, int width, int height, void* blocks, int fla - - Internally this function calls squish::Decompress for each block. - */ --void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags ); --void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags ); -+SQUISH_EXPORT void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags ); -+SQUISH_EXPORT void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags ); - - // ----------------------------------------------------------------------------- - -@@ -299,8 +301,8 @@ void DecompressImage( u8* rgba, int width, int height, void const* blocks, int f - - Internally this function calls squish::Decompress for each block. - */ --void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); --void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); -+SQUISH_EXPORT void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); -+SQUISH_EXPORT void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); - - // ----------------------------------------------------------------------------- - diff --git a/recipes/libsquish/all/patches/fix-cmake-simd-openmp-install.patch b/recipes/libsquish/all/patches/fix-cmake-simd-openmp-install.patch deleted file mode 100644 index 6517db58067e5..0000000000000 --- a/recipes/libsquish/all/patches/fix-cmake-simd-openmp-install.patch +++ /dev/null @@ -1,97 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -8,11 +8,9 @@ - # Xcode: builds universal binaries, uses SSE2 on i386 and Altivec on ppc - # Unix and VS: SSE2 support is enabled by default - # use BUILD_SQUISH_WITH_SSE2 and BUILD_SQUISH_WITH_ALTIVEC to override -- -+CMAKE_MINIMUM_REQUIRED(VERSION 3.1) - PROJECT(squish) - --CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3) -- - OPTION(BUILD_SQUISH_WITH_OPENMP "Build with OpenMP." ON) - - OPTION(BUILD_SQUISH_WITH_SSE2 "Build with SSE2." ON) -@@ -22,26 +20,6 @@ OPTION(BUILD_SHARED_LIBS "Build shared libraries." OFF) - - OPTION(BUILD_SQUISH_EXTRA "Build extra source code." OFF) - --IF (BUILD_SQUISH_WITH_OPENMP) -- FIND_PACKAGE(OpenMP) -- IF (OPENMP_FOUND) -- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") -- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") -- ADD_DEFINITIONS(-DSQUISH_USE_OPENMP) -- ENDIF() --ENDIF() -- --IF (CMAKE_GENERATOR STREQUAL "Xcode") -- SET(CMAKE_OSX_ARCHITECTURES "i386;ppc") --ELSE (CMAKE_GENERATOR STREQUAL "Xcode") -- IF (BUILD_SQUISH_WITH_SSE2 AND NOT WIN32) -- ADD_DEFINITIONS(-DSQUISH_USE_SSE=2 -msse2) -- ENDIF (BUILD_SQUISH_WITH_SSE2 AND NOT WIN32) -- IF (BUILD_SQUISH_WITH_ALTIVEC AND NOT WIN32) -- ADD_DEFINITIONS(-DSQUISH_USE_ALTIVEC=1 -maltivec) -- ENDIF (BUILD_SQUISH_WITH_ALTIVEC AND NOT WIN32) --ENDIF (CMAKE_GENERATOR STREQUAL "Xcode") -- - SET(SQUISH_HDRS - squish.h - ) -@@ -75,18 +53,41 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - - ADD_LIBRARY(squish ${SQUISH_SRCS} ${SQUISH_HDRS}) - -+IF(BUILD_SQUISH_WITH_OPENMP) -+ IF(NOT TARGET OpenMP::OpenMP_CXX) -+ FIND_PACKAGE(Threads REQUIRED) -+ ADD_LIBRARY(OpenMP::OpenMP_CXX IMPORTED INTERFACE) -+ SET_PROPERTY(TARGET OpenMP::OpenMP_CXX PROPERTY INTERFACE_COMPILE_OPTIONS ${OpenMP_CXX_FLAGS}) -+ SET_PROPERTY(TARGET OpenMP::OpenMP_CXX PROPERTY INTERFACE_LINK_LIBRARIES ${OpenMP_CXX_FLAGS} Threads::Threads) -+ ENDIF() -+ TARGET_LINK_LIBRARIES(squish PRIVATE OpenMP::OpenMP_CXX) -+ TARGET_COMPILE_DEFINITIONS(squish PRIVATE "SQUISH_USE_OPENMP") -+ENDIF() -+ -+IF(BUILD_SQUISH_WITH_SSE2) -+ TARGET_COMPILE_DEFINITIONS(squish PRIVATE "SQUISH_USE_SSE=2") -+ IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR -+ "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR -+ "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") -+ TARGET_COMPILE_OPTIONS(squish PRIVATE -msse2) -+ ENDIF() -+ENDIF() -+ -+IF(BUILD_SQUISH_WITH_ALTIVEC) -+ TARGET_COMPILE_DEFINITIONS(squish PRIVATE "SQUISH_USE_ALTIVEC=1") -+ IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR -+ "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR -+ "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") -+ TARGET_COMPILE_OPTIONS(squish PRIVATE -maltivec) -+ ENDIF() -+ENDIF() -+ - SET_TARGET_PROPERTIES( - squish PROPERTIES - PUBLIC_HEADER "${SQUISH_HDRS}" - VERSION 0.0 - SOVERSION 0.0 - DEBUG_POSTFIX "d" -- XCODE_ATTRIBUTE_GCC_PREPROCESSOR_DEFINITIONS "$(SQUISH_CPP_$(CURRENT_ARCH))" -- XCODE_ATTRIBUTE_OTHER_CFLAGS "$(SQUISH_CFLAGS_$(CURRENT_ARCH))" -- XCODE_ATTRIBUTE_SQUISH_CPP_i386 "SQUISH_USE_SSE=2" -- XCODE_ATTRIBUTE_SQUISH_CFLAGS_i386 "" -- XCODE_ATTRIBUTE_SQUISH_CPP_ppc "SQUISH_USE_ALTIVEC=1" -- XCODE_ATTRIBUTE_SQUISH_CFLAGS_ppc "-maltivec" - ) - - IF (BUILD_SQUISH_EXTRA) -@@ -113,5 +114,6 @@ INSTALL( - TARGETS squish - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -+ RUNTIME DESTINATION bin - PUBLIC_HEADER DESTINATION include - ) diff --git a/recipes/libsquish/all/test_package/CMakeLists.txt b/recipes/libsquish/all/test_package/CMakeLists.txt index 196188113685c..a57d2011ccdd9 100644 --- a/recipes/libsquish/all/test_package/CMakeLists.txt +++ b/recipes/libsquish/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libsquish REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libsquish::libsquish) diff --git a/recipes/libsquish/all/test_package/conanfile.py b/recipes/libsquish/all/test_package/conanfile.py index ea57a464900be..3a8c6c5442b33 100644 --- a/recipes/libsquish/all/test_package/conanfile.py +++ b/recipes/libsquish/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libsquish/all/test_v1_package/CMakeLists.txt b/recipes/libsquish/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a8157262ea797 --- /dev/null +++ b/recipes/libsquish/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libsquish REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libsquish::libsquish) diff --git a/recipes/libsquish/all/test_v1_package/conanfile.py b/recipes/libsquish/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/libsquish/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libsrtp/all/conandata.yml b/recipes/libsrtp/all/conandata.yml index 656693d924b12..c81f6d3838710 100644 --- a/recipes/libsrtp/all/conandata.yml +++ b/recipes/libsrtp/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "2.4.2": + url: "https://github.com/cisco/libsrtp/archive/v2.4.2.tar.gz" + sha256: "3b1bcb14ebda572b04b9bdf07574a449c84cb924905414e4d94e62837d22b628" + "2.4.0": + url: "https://github.com/cisco/libsrtp/archive/v2.4.0.tar.gz" + sha256: "713c5c1dc740707422307f39834c0b0fbb76769168d87e92c438a3cca8233d3d" 2.3.0: url: "https://github.com/cisco/libsrtp/archive/v2.3.0.tar.gz" sha256: "94093a5d04c5f4743e8d81182b76938374df6d393b45322f24960d250b0110e8" diff --git a/recipes/libsrtp/all/conanfile.py b/recipes/libsrtp/all/conanfile.py index 644fe815370c0..d1587d82b27e6 100644 --- a/recipes/libsrtp/all/conanfile.py +++ b/recipes/libsrtp/all/conanfile.py @@ -1,5 +1,7 @@ -import os from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.33.0" class ConanRecipe(ConanFile): @@ -13,8 +15,6 @@ class ConanRecipe(ConanFile): homepage = "https://github.com/cisco/libsrtp" url = "https://github.com/conan-io/conan-center-index" license = "BSD-3-Clause" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" settings = "os", "arch", "compiler", "build_type" options = { @@ -28,6 +28,8 @@ class ConanRecipe(ConanFile): "with_openssl": False, } + exports_sources = ["CMakeLists.txt"] + generators = "cmake", "cmake_find_package" _cmake = None @property @@ -46,12 +48,11 @@ def configure(self): def requirements(self): if self.options.with_openssl: - self.requires("openssl/1.1.1i") + self.requires("openssl/1.1.1q") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: diff --git a/recipes/libsrtp/config.yml b/recipes/libsrtp/config.yml index ca139ec1effcb..75f515b1ca5ea 100644 --- a/recipes/libsrtp/config.yml +++ b/recipes/libsrtp/config.yml @@ -1,3 +1,7 @@ versions: + "2.4.2": + folder: all + "2.4.0": + folder: all 2.3.0: folder: all diff --git a/recipes/libssh2/all/CMakeLists.txt b/recipes/libssh2/all/CMakeLists.txt index a69305eb3971f..8315062fd31ee 100644 --- a/recipes/libssh2/all/CMakeLists.txt +++ b/recipes/libssh2/all/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper C) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory(source_subfolder) diff --git a/recipes/libssh2/all/conandata.yml b/recipes/libssh2/all/conandata.yml index 17851ea894366..710cae0e7118d 100644 --- a/recipes/libssh2/all/conandata.yml +++ b/recipes/libssh2/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.10.0": + sha256: 2d64e90f3ded394b91d3a2e774ca203a4179f69aebee03003e5a6fa621e41d51 + url: https://github.com/libssh2/libssh2/releases/download/libssh2-1.10.0/libssh2-1.10.0.tar.gz "1.9.0": sha256: d5fb8bd563305fd1074dda90bd053fb2d29fc4bce048d182f96eaa466dfadafd url: https://github.com/libssh2/libssh2/releases/download/libssh2-1.9.0/libssh2-1.9.0.tar.gz @@ -9,12 +12,15 @@ sources: sha256: 39f34e2f6835f4b992cafe8625073a88e5a28ba78f83e8099610a7b3af4676d4 url: https://github.com/libssh2/libssh2/releases/download/libssh2-1.8.0/libssh2-1.8.0.tar.gz patches: + "1.10.0": + - patch_file: "patches/0001-threads.patch" + base_path: "source_subfolder" "1.9.0": - - patch_file: "patches/0001-pthread.patch" + - patch_file: "patches/0001-threads.patch" base_path: "source_subfolder" "1.8.2": - - patch_file: "patches/0002-pthread.patch" + - patch_file: "patches/0001-threads.patch" base_path: "source_subfolder" "1.8.0": - - patch_file: "patches/0002-pthread.patch" + - patch_file: "patches/0001-threads.patch" base_path: "source_subfolder" diff --git a/recipes/libssh2/all/conanfile.py b/recipes/libssh2/all/conanfile.py index 2b9e6f0446717..bb49ef120e615 100644 --- a/recipes/libssh2/all/conanfile.py +++ b/recipes/libssh2/all/conanfile.py @@ -1,7 +1,8 @@ from conans import ConanFile, CMake, tools +import functools import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.43.0" class Libssh2Conan(ConanFile): @@ -20,6 +21,7 @@ class Libssh2Conan(ConanFile): "enable_crypt_none": [True, False], "enable_mac_none": [True, False], "crypto_backend": ["openssl", "mbedtls"], + "enable_debug_logging": [True, False], } default_options = { "shared": False, @@ -28,16 +30,20 @@ class Libssh2Conan(ConanFile): "enable_crypt_none": False, "enable_mac_none": False, "crypto_backend": "openssl", + "enable_debug_logging": False, } - exports_sources = ["CMakeLists.txt", "patches/*"] generators = "cmake", "cmake_find_package" - _cmake = None @property def _source_subfolder(self): return "source_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -50,10 +56,11 @@ def configure(self): def requirements(self): if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.12") if self.options.crypto_backend == "openssl": - self.requires("openssl/1.1.1k") + self.requires("openssl/1.1.1q") elif self.options.crypto_backend == "mbedtls": + # libssh2/<=1.10.0 doesn't support mbedtls/3.x.x self.requires("mbedtls/2.25.0") def source(self): @@ -67,22 +74,24 @@ def _patch_sources(self): "set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)", "list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)") + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_ZLIB_COMPRESSION"] = self.options.with_zlib - self._cmake.definitions["ENABLE_CRYPT_NONE"] = self.options.enable_crypt_none - self._cmake.definitions["ENABLE_MAC_NONE"] = self.options.enable_mac_none + cmake = CMake(self) + cmake.definitions["ENABLE_ZLIB_COMPRESSION"] = self.options.with_zlib + cmake.definitions["ENABLE_CRYPT_NONE"] = self.options.enable_crypt_none + cmake.definitions["ENABLE_MAC_NONE"] = self.options.enable_mac_none + cmake.definitions["ENABLE_DEBUG_LOGGING"] = self.options.enable_debug_logging if self.options.crypto_backend == "openssl": - self._cmake.definitions["CRYPTO_BACKEND"] = "OpenSSL" - self._cmake.definitions["OPENSSL_ROOT_DIR"] = self.deps_cpp_info["openssl"].rootpath + cmake.definitions["CRYPTO_BACKEND"] = "OpenSSL" + cmake.definitions["OPENSSL_ROOT_DIR"] = self.deps_cpp_info["openssl"].rootpath elif self.options.crypto_backend == "mbedtls": - self._cmake.definitions["CRYPTO_BACKEND"] = "mbedTLS" - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure() - return self._cmake + cmake.definitions["CRYPTO_BACKEND"] = "mbedTLS" + cmake.definitions["BUILD_EXAMPLES"] = False + cmake.definitions["BUILD_TESTING"] = False + # To install relocatable shared lib on Macos by default + cmake.definitions["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + cmake.configure() + return cmake def build(self): self._patch_sources() @@ -98,17 +107,23 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "Libssh2" - self.cpp_info.names["cmake_find_package_multi"] = "Libssh2" - self.cpp_info.names["pkg_config"] = "libssh2" - self.cpp_info.components["_libssh2"].names["cmake_find_package"] = "libssh2" - self.cpp_info.components["_libssh2"].names["cmake_find_package_multi"] = "libssh2" - self.cpp_info.components["_libssh2"].names["pkg_config"] = "libssh2" + self.cpp_info.set_property("cmake_file_name", "Libssh2") + self.cpp_info.set_property("cmake_target_name", "Libssh2::libssh2") + self.cpp_info.set_property("pkg_config_name", "libssh2") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed self.cpp_info.components["_libssh2"].libs = tools.collect_libs(self) if self.settings.os == "Windows": self.cpp_info.components["_libssh2"].system_libs.append("ws2_32") - elif self.settings.os == "Linux": + elif self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["_libssh2"].system_libs.extend(["pthread", "dl"]) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "Libssh2" + self.cpp_info.names["cmake_find_package_multi"] = "Libssh2" + self.cpp_info.components["_libssh2"].names["cmake_find_package"] = "libssh2" + self.cpp_info.components["_libssh2"].names["cmake_find_package_multi"] = "libssh2" + self.cpp_info.components["_libssh2"].set_property("cmake_target_name", "Libssh2::libssh2") + self.cpp_info.components["_libssh2"].set_property("pkg_config_name", "libssh2") if self.options.with_zlib: self.cpp_info.components["_libssh2"].requires.append("zlib::zlib") if self.options.crypto_backend == "openssl": diff --git a/recipes/libssh2/all/patches/0001-pthread.patch b/recipes/libssh2/all/patches/0001-pthread.patch deleted file mode 100644 index 088ef1cfc4cdc..0000000000000 --- a/recipes/libssh2/all/patches/0001-pthread.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 2eaf4cc..1cdac22 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -214,6 +214,11 @@ if(WIN32) - list(APPEND SOURCES ${PROJECT_SOURCE_DIR}/win32/libssh2.rc) - endif() - -+if(UNIX AND NOT APPLE) -+ find_package(Threads REQUIRED) -+ list(APPEND LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) -+endif() -+ - add_library(libssh2 ${SOURCES}) - # we want it to be called libssh2 on all platforms - set_target_properties(libssh2 PROPERTIES PREFIX "") diff --git a/recipes/libssh2/all/patches/0001-threads.patch b/recipes/libssh2/all/patches/0001-threads.patch new file mode 100644 index 0000000000000..05985dac07a46 --- /dev/null +++ b/recipes/libssh2/all/patches/0001-threads.patch @@ -0,0 +1,16 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index eee1a80..3373f2a 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -42,6 +42,11 @@ include(CheckSymbolExists) + include(CheckNonblockingSocketSupport) + include(SocketLibraries) + ++if(UNIX AND NOT APPLE) ++ find_package(Threads REQUIRED) ++ list(APPEND LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) ++endif() ++ + ## Cryptography backend choice + + set(CRYPTO_BACKEND diff --git a/recipes/libssh2/all/patches/0002-pthread.patch b/recipes/libssh2/all/patches/0002-pthread.patch deleted file mode 100644 index e7ed96f7ff17b..0000000000000 --- a/recipes/libssh2/all/patches/0002-pthread.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 6401acf..c2b0c69 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -211,6 +211,11 @@ if(WIN32) - list(APPEND SOURCES ${PROJECT_SOURCE_DIR}/win32/libssh2.rc) - endif() - -+if(UNIX AND NOT APPLE) -+ find_package(Threads REQUIRED) -+ list(APPEND LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) -+endif() -+ - add_library(libssh2 ${SOURCES}) - # we want it to be called libssh2 on all platforms - set_target_properties(libssh2 PROPERTIES PREFIX "") diff --git a/recipes/libssh2/all/test_package/conanfile.py b/recipes/libssh2/all/test_package/conanfile.py index 7e2dfe859bb27..49a3a66ea5bad 100644 --- a/recipes/libssh2/all/test_package/conanfile.py +++ b/recipes/libssh2/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libssh2/config.yml b/recipes/libssh2/config.yml index 4102949bba633..42bce17ced607 100644 --- a/recipes/libssh2/config.yml +++ b/recipes/libssh2/config.yml @@ -1,4 +1,6 @@ versions: + "1.10.0": + folder: all "1.9.0": folder: all "1.8.2": diff --git a/recipes/libstudxml/1.0.x/conandata.yml b/recipes/libstudxml/1.0.x/conandata.yml new file mode 100644 index 0000000000000..66056d9dcd92c --- /dev/null +++ b/recipes/libstudxml/1.0.x/conandata.yml @@ -0,0 +1,10 @@ +sources: + "1.0.1": + url: "https://www.codesynthesis.com/download/libstudxml/1.0/libstudxml-1.0.1.tar.gz" + sha256: "4665e0dbd4849988d61d039b22effc93439caadb92a84ca3aa41048973e284e4" +patches: + "1.0.1": + - patch_file: "patches/configure-ac.patch" + base_path: "source_subfolder" + - patch_file: "patches/makefile-am.patch" + base_path: "source_subfolder" diff --git a/recipes/libstudxml/1.0.x/conanfile.py b/recipes/libstudxml/1.0.x/conanfile.py new file mode 100644 index 0000000000000..f2a8f72a20d39 --- /dev/null +++ b/recipes/libstudxml/1.0.x/conanfile.py @@ -0,0 +1,186 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, chdir, collect_libs, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +from conans import AutoToolsBuildEnvironment, MSBuild, tools +import os + +required_conan_version = ">=1.53.0" + + +class LibStudXmlConan(ConanFile): + name = "libstudxml" + description = "A streaming XML pull parser and streaming XML serializer implementation for modern, standard C++." + topics = ("xml", "xml-parser", "serialization") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.codesynthesis.com/projects/libstudxml/" + license = "MIT" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + pass + + def requirements(self): + self.requires("expat/2.5.0", transitive_headers=True, transitive_libs=True) + + def validate(self): + if self.info.settings.compiler == "Visual Studio" and Version(self.info.settings.compiler.version) < "9": + raise ConanInvalidConfiguration(f"Visual Studio {self.info.settings.compiler.version} is not supported.") + + def build_requirements(self): + if not is_msvc(self): + self.tool_requires("gnu-config/cci.20210814") + self.tool_requires("libtool/2.4.7") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if not self._autotools: + args = ["--with-external-expat"] + if self.options.shared: + args.extend(["--enable-shared", "--disable-static"]) + else: + args.extend(["--disable-shared", "--enable-static"]) + + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + self._autotools.configure(configure_dir=self._source_subfolder, args=args) + return self._autotools + + @property + def _vc_ver(self): + if self.settings.compiler == "Visual Studio": + return str(Version(self.settings.compiler.version).major) + elif self.settings.compiler == "msvc": + return { + "170": "11", + "180": "12", + "190": "14", + "191": "15", + "192": "16", + "193": "17", + }[str(self.settings.compiler.version)] + return None + + def _build_vs(self): + vc_ver = int(self._vc_ver) + sln_path = None + def get_sln_path(): + return os.path.join(self.source_folder, self._source_subfolder, f"libstudxml-vc{vc_ver}.sln") + + sln_path = get_sln_path() + while not os.path.exists(sln_path): + vc_ver -= 1 + sln_path = get_sln_path() + + proj_path = os.path.join(self.source_folder, self._source_subfolder, "xml", f"libstudxml-vc{vc_ver}.vcxproj") + + if not self.options.shared: + replace_in_file(self, proj_path, "DynamicLibrary", "StaticLibrary") + replace_in_file(self, proj_path, "LIBSTUDXML_DYNAMIC_LIB", "LIBSTUDXML_STATIC_LIB") + + msbuild = MSBuild(self) + msbuild.build(sln_path, platforms={"x86": "Win32"}) + + def _build_autotools(self): + for gnu_config in [ + self.conf.get("user.gnu-config:config_guess", check_type=str), + self.conf.get("user.gnu-config:config_sub", check_type=str), + ]: + if gnu_config: + copy( + self, + os.path.basename(gnu_config), + src=os.path.dirname(gnu_config), + dst=os.path.join(self.source_folder, self._source_subfolder, "config"), + ) + + if self.settings.compiler.get_safe("libcxx") == "libc++": + # libc++ includes a file called 'version', and since libstudxml adds source_subfolder as an + # include dir, libc++ ends up including their 'version' file instead, causing a compile error + rm(self, "version", os.path.join(self.source_folder, self._source_subfolder)) + + with chdir(self, os.path.join(self.source_folder, self._source_subfolder)): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) + + autotools = self._configure_autotools() + autotools.make() + + def build(self): + apply_conandata_patches(self) + if is_msvc(self): + self._build_vs() + else: + self._build_autotools() + + def package(self): + copy(self, "LICENSE", src=os.path.join(self.source_folder, self._source_subfolder), dst=os.path.join(self.package_folder, "licenses")) + if is_msvc(self): + self.copy("xml/value-traits", dst="include", src=self._source_subfolder) + self.copy("xml/serializer", dst="include", src=self._source_subfolder) + self.copy("xml/qname", dst="include", src=self._source_subfolder) + self.copy("xml/parser", dst="include", src=self._source_subfolder) + self.copy("xml/forward", dst="include", src=self._source_subfolder) + self.copy("xml/exception", dst="include", src=self._source_subfolder) + self.copy("xml/content", dst="include", src=self._source_subfolder) + self.copy("xml/*.ixx", dst="include", src=self._source_subfolder) + self.copy("xml/*.txx", dst="include", src=self._source_subfolder) + self.copy("xml/*.hxx", dst="include", src=self._source_subfolder) + self.copy("xml/*.h", dst="include", src=self._source_subfolder) + + suffix = "" + if self.settings.arch == "x86_64": + suffix = "64" + if self.options.shared: + self.copy("*.lib", dst="lib", src=os.path.join(self._source_subfolder, "lib" + suffix)) + self.copy("*.dll", dst="bin", src=os.path.join(self._source_subfolder, "bin" + suffix)) + else: + self.copy("*.lib", dst="lib", src=os.path.join(self._source_subfolder, "bin" + suffix)) + else: + autotools = self._configure_autotools() + autotools.install() + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libstudxml") + self.cpp_info.libs = collect_libs(self) + + # If built with makefile, static library mechanism is provided by their buildsystem already + if is_msvc(self) and not self.options.shared: + self.cpp_info.defines = ["LIBSTUDXML_STATIC_LIB=1"] diff --git a/recipes/libstudxml/1.0.x/patches/configure-ac.patch b/recipes/libstudxml/1.0.x/patches/configure-ac.patch new file mode 100644 index 0000000000000..75c6ba9da0956 --- /dev/null +++ b/recipes/libstudxml/1.0.x/patches/configure-ac.patch @@ -0,0 +1,10 @@ +--- configure.ac ++++ configure.ac +@@ -80,6 +80,6 @@ + # Output. + # + AC_CONFIG_HEADERS([xml/config.h xml/details/config.h]) +-AC_CONFIG_FILES([ doc/Makefile examples/hybrid/Makefile examples/inheritance/Makefile examples/Makefile examples/performance/Makefile examples/persistence/Makefile examples/processing/Makefile examples/roundtrip/Makefile libstudxml.pc Makefile tester tests/Makefile tests/parser/Makefile tests/roundtrip/Makefile tests/serializer/Makefile xml/Makefile]) ++AC_CONFIG_FILES([ libstudxml.pc Makefile xml/Makefile]) + AC_CONFIG_COMMANDS([tester-mode], [chmod +x tester]) + AC_OUTPUT diff --git a/recipes/libstudxml/1.0.x/patches/makefile-am.patch b/recipes/libstudxml/1.0.x/patches/makefile-am.patch new file mode 100644 index 0000000000000..50069a032481c --- /dev/null +++ b/recipes/libstudxml/1.0.x/patches/makefile-am.patch @@ -0,0 +1,12 @@ +--- Makefile.am ++++ Makefile.am +@@ -2,7 +2,7 @@ + # copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC + # license : MIT; see accompanying LICENSE file + +-SUBDIRS = xml tests examples doc +-dist_doc_DATA = LICENSE NEWS README INSTALL version ++SUBDIRS = xml ++dist_doc_DATA = LICENSE NEWS README INSTALL + EXTRA_DIST = tester.bat libstudxml-vc9.sln libstudxml-vc10.sln libstudxml-vc11.sln libstudxml-vc12.sln bootstrap tester.in + ACLOCAL_AMFLAGS = -I m4 diff --git a/recipes/libstudxml/1.0.x/test_package/CMakeLists.txt b/recipes/libstudxml/1.0.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e931d3be71851 --- /dev/null +++ b/recipes/libstudxml/1.0.x/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(libstudxml REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libstudxml::libstudxml) diff --git a/recipes/libstudxml/1.0.x/test_package/conanfile.py b/recipes/libstudxml/1.0.x/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libstudxml/1.0.x/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libstudxml/1.0.x/test_package/test_package.cpp b/recipes/libstudxml/1.0.x/test_package/test_package.cpp new file mode 100644 index 0000000000000..7803a10a33e05 --- /dev/null +++ b/recipes/libstudxml/1.0.x/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main() { + std::istringstream is("X"); + xml::parser p(is, "test"); + + bool success = true; + success &= p.next() == xml::parser::start_element; + success &= p.next() == xml::parser::start_element; + success &= p.next() == xml::parser::characters && p.value() == "X"; + + return success ? 0 : -1; +} diff --git a/recipes/libstudxml/1.0.x/test_v1_package/CMakeLists.txt b/recipes/libstudxml/1.0.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libstudxml/1.0.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libstudxml/1.0.x/test_v1_package/conanfile.py b/recipes/libstudxml/1.0.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libstudxml/1.0.x/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libstudxml/1.1.x/CMakeLists.txt b/recipes/libstudxml/1.1.x/CMakeLists.txt new file mode 100644 index 0000000000000..4eaaf23bf2205 --- /dev/null +++ b/recipes/libstudxml/1.1.x/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.1) +project(libstudxml LANGUAGES C CXX) + +find_package(EXPAT REQUIRED MODULE) + +add_library(studxml + ${LIBSTUDXML_SRC_DIR}/libstudxml/parser.cxx + ${LIBSTUDXML_SRC_DIR}/libstudxml/qname.cxx + ${LIBSTUDXML_SRC_DIR}/libstudxml/serializer.cxx + ${LIBSTUDXML_SRC_DIR}/libstudxml/value-traits.cxx + ${LIBSTUDXML_SRC_DIR}/libstudxml/details/genx/char-props.c + ${LIBSTUDXML_SRC_DIR}/libstudxml/details/genx/genx.c +) +target_include_directories(studxml PUBLIC ${LIBSTUDXML_SRC_DIR}) +target_link_libraries(studxml PUBLIC EXPAT::EXPAT) + +if(BUILD_SHARED_LIBS) + target_compile_definitions(studxml + PRIVATE LIBSTUDXML_SHARED_BUILD + INTERFACE LIBSTUDXML_SHARED + ) +else() + target_compile_definitions(studxml + PRIVATE LIBSTUDXML_STATIC_BUILD + INTERFACE LIBSTUDXML_STATIC + ) +endif() + +include(GNUInstallDirs) +install( + TARGETS studxml + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install( + DIRECTORY ${LIBSTUDXML_SRC_DIR}/libstudxml + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING REGEX "(.*).(h|hxx|ixx|txx)$" +) diff --git a/recipes/libstudxml/1.1.x/conandata.yml b/recipes/libstudxml/1.1.x/conandata.yml new file mode 100644 index 0000000000000..2001802fdfa42 --- /dev/null +++ b/recipes/libstudxml/1.1.x/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.1.0-b.10+1": + url: "https://git.codesynthesis.com/cgit/libstudxml/libstudxml/snapshot/v1.1.0-b.10%2b1.tar.xz" + sha256: "6773bb700b0b61fb117f0737f3c754d2be67d70766d63430b8a95bf147cc0368" diff --git a/recipes/libstudxml/1.1.x/conanfile.py b/recipes/libstudxml/1.1.x/conanfile.py new file mode 100644 index 0000000000000..42db9e71046d4 --- /dev/null +++ b/recipes/libstudxml/1.1.x/conanfile.py @@ -0,0 +1,78 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file, rmdir +import os + +required_conan_version = ">=1.53.0" + + +class LibStudXmlConan(ConanFile): + name = "libstudxml" + description = "A streaming XML pull parser and streaming XML serializer implementation for modern, standard C++." + topics = ("xml", "xml-parser", "serialization") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.codesynthesis.com/projects/libstudxml/" + license = "MIT" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("expat/2.5.0", transitive_headers=True, transitive_libs=True) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBSTUDXML_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + # unvendor expat + rmdir(self, os.path.join(self.source_folder, "libstudxml", "details", "expat")) + replace_in_file( + self, + os.path.join(self.source_folder, "libstudxml", "parser.hxx"), + "#ifndef LIBSTUDXML_EXTERNAL_EXPAT", + "#if 0", + ) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libstudxml") + self.cpp_info.libs = ["studxml"] + self.cpp_info.defines = ["LIBSTUDXML_SHARED" if self.options.shared else "LIBSTUDXML_STATIC"] diff --git a/recipes/libstudxml/1.1.x/test_package/CMakeLists.txt b/recipes/libstudxml/1.1.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e931d3be71851 --- /dev/null +++ b/recipes/libstudxml/1.1.x/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(libstudxml REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libstudxml::libstudxml) diff --git a/recipes/libstudxml/1.1.x/test_package/conanfile.py b/recipes/libstudxml/1.1.x/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/libstudxml/1.1.x/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libstudxml/1.1.x/test_package/test_package.cpp b/recipes/libstudxml/1.1.x/test_package/test_package.cpp new file mode 100644 index 0000000000000..9ebd7090dd31e --- /dev/null +++ b/recipes/libstudxml/1.1.x/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main() { + std::istringstream is("X"); + xml::parser p(is, "test"); + + bool success = true; + success &= p.next() == xml::parser::start_element; + success &= p.next() == xml::parser::start_element; + success &= p.next() == xml::parser::characters && p.value() == "X"; + + return success ? 0 : -1; +} diff --git a/recipes/libstudxml/1.1.x/test_v1_package/CMakeLists.txt b/recipes/libstudxml/1.1.x/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libstudxml/1.1.x/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libstudxml/1.1.x/test_v1_package/conanfile.py b/recipes/libstudxml/1.1.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libstudxml/1.1.x/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libstudxml/config.yml b/recipes/libstudxml/config.yml new file mode 100644 index 0000000000000..119e8114fa194 --- /dev/null +++ b/recipes/libstudxml/config.yml @@ -0,0 +1,5 @@ +versions: + "1.1.0-b.10+1": + folder: "1.1.x" + "1.0.1": + folder: "1.0.x" diff --git a/recipes/libsvm/all/CMakeLists.txt b/recipes/libsvm/all/CMakeLists.txt index 08c09211eb731..3c3e2d6052401 100644 --- a/recipes/libsvm/all/CMakeLists.txt +++ b/recipes/libsvm/all/CMakeLists.txt @@ -1,20 +1,27 @@ cmake_minimum_required(VERSION 3.4) project(svm C CXX) -include(${CMAKE_SOURCE_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +include(GNUInstallDirs) -add_library(svm source_subfolder/svm.cpp) -set_target_properties(svm PROPERTIES PUBLIC_HEADER source_subfolder/svm.h) +add_library(svm ${LIBSVM_SRC_DIR}/svm.cpp) +set_property(TARGET svm PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) +set_target_properties(svm PROPERTIES PUBLIC_HEADER ${LIBSVM_SRC_DIR}/svm.h) -add_executable(svm-predict source_subfolder/svm-predict.c) +add_executable(svm-predict ${LIBSVM_SRC_DIR}/svm-predict.c) target_link_libraries(svm-predict svm) -add_executable(svm-train source_subfolder/svm-train.c) +add_executable(svm-train ${LIBSVM_SRC_DIR}/svm-train.c) target_link_libraries(svm-train svm) -add_executable(svm-scale source_subfolder/svm-scale.c) +add_executable(svm-scale ${LIBSVM_SRC_DIR}/svm-scale.c) -install(TARGETS svm svm-predict svm-train svm-scale +install(TARGETS svm + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/svm ) + +install(TARGETS svm-predict svm-train svm-scale + DESTINATION ${CMAKE_INSTALL_BINDIR} + ) diff --git a/recipes/libsvm/all/conandata.yml b/recipes/libsvm/all/conandata.yml index cd869b34d8001..5712311441eb3 100644 --- a/recipes/libsvm/all/conandata.yml +++ b/recipes/libsvm/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "330": + url: "https://github.com/cjlin1/libsvm/archive/v330.tar.gz" + sha256: "e4fe41308c87cc210aec73e4f5f0fb4da14234d90e7a131763fbad3788ca2d80" + "325": + url: "https://github.com/cjlin1/libsvm/archive/v325.tar.gz" + sha256: "1f587ec0df6fd422dfe50f942f8836ac179b0723b768fe9d2fabdfd1601a0963" "324": url: "https://github.com/cjlin1/libsvm/archive/v324.tar.gz" sha256: "3ba1ac74ee08c4dd57d3a9e4a861ffb57dab88c6a33fd53eac472fc84fbb2a8f" diff --git a/recipes/libsvm/all/conanfile.py b/recipes/libsvm/all/conanfile.py index 16ebaa7544561..897e5749def0c 100644 --- a/recipes/libsvm/all/conanfile.py +++ b/recipes/libsvm/all/conanfile.py @@ -1,10 +1,11 @@ -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration -import os - +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import get, copy -required_conan_version = ">=1.32.0" +import os +required_conan_version = ">=1.52.0" class libsvmConan(ConanFile): name = "libsvm" @@ -12,30 +13,25 @@ class libsvmConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.csie.ntu.edu.tw/~cjlin/libsvm/" license = "BSD-3-Clause" - topics = ("conan", "svm", "vector") - exports_sources = ["CMakeLists.txt"] - generators = "cmake" + topics = "svm", "vector" settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio" and self.options.shared: - self._cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True - self._cmake.configure() - return self._cmake + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + def validate(self): if ( self.settings.compiler == "Visual Studio" and @@ -43,27 +39,35 @@ def validate(self): self.options.shared ): raise ConanInvalidConfiguration( - "{} can not be built as shared library + runtime {}.".format( - self.name, - self.settings.compiler.runtime - ) + f"{self.name} can not be built as shared library + runtime {self.settings.compiler.runtime}." ) + def layout(self): + cmake_layout(self, src_folder="src") + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBSVM_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy("COPYRIGHT", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "COPYRIGHT", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - self.cpp_info.names["cmake_find_package"] = "LibSVM" - self.cpp_info.names["cmake_find_package_multi"] = "LibSVM" + self.cpp_info.libs = ["svm"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["m"] diff --git a/recipes/libsvm/all/test_package/CMakeLists.txt b/recipes/libsvm/all/test_package/CMakeLists.txt index 37cb8eb98e622..40fb8732f7ba3 100644 --- a/recipes/libsvm/all/test_package/CMakeLists.txt +++ b/recipes/libsvm/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(PackageTest CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libsvm CONFIG REQUIRED) add_executable(test_package test_package.cpp) -target_link_libraries(test_package ${CONAN_LIBS}) +target_link_libraries(test_package PRIVATE libsvm::libsvm) diff --git a/recipes/libsvm/all/test_package/conanfile.py b/recipes/libsvm/all/test_package/conanfile.py index a59a26a52c8dc..1a65f5a41c626 100644 --- a/recipes/libsvm/all/test_package/conanfile.py +++ b/recipes/libsvm/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libsvm/all/test_v1_package/CMakeLists.txt b/recipes/libsvm/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..053cf33af70e5 --- /dev/null +++ b/recipes/libsvm/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libsvm CONFIG REQUIRED) + +add_executable(test_package ../test_package/test_package.cpp) +target_link_libraries(test_package PRIVATE libsvm::libsvm) diff --git a/recipes/libsvm/all/test_v1_package/conanfile.py b/recipes/libsvm/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c1c8554eae243 --- /dev/null +++ b/recipes/libsvm/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building + +import os + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libsvm/config.yml b/recipes/libsvm/config.yml index 5ddc4248500e9..026fbb9e30356 100644 --- a/recipes/libsvm/config.yml +++ b/recipes/libsvm/config.yml @@ -1,3 +1,7 @@ versions: + "330": + folder: all + "325": + folder: all "324": folder: all diff --git a/recipes/libsystemd/all/conandata.yml b/recipes/libsystemd/all/conandata.yml index 8e448a517aabc..bad16940c7037 100644 --- a/recipes/libsystemd/all/conandata.yml +++ b/recipes/libsystemd/all/conandata.yml @@ -1,10 +1,54 @@ sources: - "246.6": - url: "https://github.com/systemd/systemd-stable/archive/v246.6.tar.gz" - sha256: "e999dbf0cff5b0109c28b307741b7dc315877fe2e1999f25c153548db44bb020" - "247.2": - url: "https://github.com/systemd/systemd-stable/archive/v247.2.tar.gz" - sha256: "e6100f447f67a49f6e019ff7ee317cf8b67a5c491e54dcf8b02975d4307fa468" - "247.3": - url: "https://github.com/systemd/systemd-stable/archive/v247.3.tar.gz" - sha256: "2869986e219a8dfc96cc0dffac66e0c13bb70a89e16b85a3948876c146cfa3e0" + "246.16": + url: "https://github.com/systemd/systemd-stable/archive/v246.16.tar.gz" + sha256: "b69f9940d65870f090269a28f1047a633d4b80d0001e091d53a031dd40a822d2" + "247.11": + url: "https://github.com/systemd/systemd-stable/archive/v247.11.tar.gz" + sha256: "99537ecf15815d5bac2f8f75b4e04635e1f8e95e7c857c711e42483aa2744f7f" + "248.10": + url: "https://github.com/systemd/systemd-stable/archive/v248.10.tar.gz" + sha256: "dab015c2ccd5cb0427b1c3ec85ac0f02974b38ca643de31932f198a8b60de8da" + "249.12": + url: "https://github.com/systemd/systemd-stable/archive/v249.12.tar.gz" + sha256: "cf8851e94cbd82c65a86ab122747f3e0018b04cd991c7daccbacb4a3ef149b68" + "251.4": + url: "https://github.com/systemd/systemd-stable/archive/v251.4.tar.gz" + sha256: "3459239979f52b8c4ace33734d31c2fb69fa13cf81d04b1b982f7d8d4651e015" +patches: + "246.16": + - patch_file: "patches/246.16/0001-Drop-bundled-copy-of-linux-if_arp.h.patch" + patch_description: "fix build error with Linux headers >= 5.14 by removing a bundled copy of it" + patch_type: "backport" + patch_source: "https://github.com/systemd/systemd-stable/commit/06dea04b38ce506c1436cd4fef9bf9919a34f441" + - patch_file: "patches/246.16/0002-meson.build-change-operator-combining-bools-from-to-.patch" + patch_description: "allow to build with meson >= 0.60.0 by fixing syntax error" + patch_type: "backport" + patch_source: "https://github.com/systemd/systemd-stable/commit/3d0666d9091dd097022f02fae79890b5746285c1" + - patch_file: "patches/246.16/0003-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "247.11": + - patch_file: "patches/247.11/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "248.10": + - patch_file: "patches/248.10/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch" + patch_description: "allow to use meson.build with older versions of Python by replacing utf8 message to ascii message in the helper script" + patch_type: "conan" + - patch_file: "patches/247.11/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "249.12": + - patch_file: "patches/248.10/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch" + patch_description: "allow to use meson.build with older versions of Python by replacing utf8 message to ascii message in the helper script" + patch_type: "conan" + - patch_file: "patches/249.12/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" + "251.4": + - patch_file: "patches/248.10/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch" + patch_description: "allow to use meson.build with older versions of Python by replacing utf8 message to ascii message in the helper script" + patch_type: "conan" + - patch_file: "patches/251.4/0001-Remove-dependency-from-coreutils.patch" + patch_description: "allow to build in environments without 'realpath --relative-to' by replacing it with conan-specific build variable" + patch_type: "conan" diff --git a/recipes/libsystemd/all/conanfile.py b/recipes/libsystemd/all/conanfile.py index 6ab7124562e83..6ea4caf383334 100644 --- a/recipes/libsystemd/all/conanfile.py +++ b/recipes/libsystemd/all/conanfile.py @@ -1,8 +1,15 @@ import os import re -from conans import ConanFile, Meson, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, copy, get, \ + replace_in_file +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.scm import Version + +required_conan_version = ">=1.50.2" class LibsystemdConan(ConanFile): @@ -11,7 +18,7 @@ class LibsystemdConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.freedesktop.org/wiki/Software/systemd/" description = "System and Service Manager API library" - topics = ("conan", "systemd", "libsystemd") + topics = ("systemd", "libsystemd", "service", "manager") settings = "os", "compiler", "build_type", "arch" options = { "shared": [True, False], @@ -29,50 +36,52 @@ class LibsystemdConan(ConanFile): "with_xz": True, "with_zstd": True, } - generators = "pkg_config" - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + generators = "PkgConfigDeps", "VirtualBuildEnv" + exports_sources = "patches/**" def configure(self): - if self.settings.os != "Linux": - raise ConanInvalidConfiguration("Only Linux supported") if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def validate(self): + if self.info.settings.os != "Linux": + raise ConanInvalidConfiguration("Only Linux supported") def build_requirements(self): - self.build_requires("meson/0.55.3") - self.build_requires("m4/1.4.18") - self.build_requires("gperf/3.1") - self.build_requires("pkgconf/1.7.3") + self.tool_requires("meson/0.63.1") + self.tool_requires("m4/1.4.19") + self.tool_requires("gperf/3.1") + self.tool_requires("pkgconf/1.7.4") def requirements(self): - self.requires("libcap/2.45") - self.requires("libmount/2.36") + self.requires("libcap/2.65") + self.requires("libmount/2.36.2") if self.options.with_selinux: - self.requires("libselinux/3.1") + self.requires("libselinux/3.3") if self.options.with_lz4: - self.requires("lz4/1.9.2") + self.requires("lz4/1.9.3") if self.options.with_xz: self.requires("xz_utils/5.2.5") if self.options.with_zstd: - self.requires("zstd/1.4.5") + self.requires("zstd/1.5.2") + + def layout(self): + basic_layout(self, src_folder="source") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - src_folder = "systemd-stable-{}".format(self.version) - os.rename(src_folder, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], strip_root=True) @property def _so_version(self): - meson_build = os.path.join(self._source_subfolder, "meson.build") + meson_build = os.path.join(self.source_folder, "meson.build") with open(meson_build, "r") as build_file: for line in build_file: match = re.match(r"^libsystemd_version = '(.*)'$", line) @@ -80,20 +89,22 @@ def _so_version(self): return match.group(1) return "" - def _configure_meson(self): - meson = Meson(self) - defs = dict() - defs["selinux"] = "true" if self.options.with_selinux else "false" - defs["lz4"] = "true" if self.options.with_lz4 else "false" - defs["xz"] = "true" if self.options.with_xz else "false" - defs["zstd"] = "true" if self.options.with_zstd else "false" + def generate(self): + tc = MesonToolchain(self) + tc.project_options["selinux"] = ("true" if self.options.with_selinux + else "false") + tc.project_options["lz4"] = ("true" if self.options.with_lz4 + else "false") + tc.project_options["xz"] = "true" if self.options.with_xz else "false" + tc.project_options["zstd"] = ("true" if self.options.with_zstd + else "false") if self.options.shared: - defs["static-libsystemd"] = "false" + tc.project_options["static-libsystemd"] = "false" elif self.options.fPIC: - defs["static-libsystemd"] = "pic" + tc.project_options["static-libsystemd"] = "pic" else: - defs["static-libsystemd"] = "no-pic" + tc.project_options["static-libsystemd"] = "no-pic" # options unrelated to libsystemd unrelated = [ @@ -113,47 +124,83 @@ def _configure_meson(self): "link-networkd-shared", "link-timesyncd-shared", "kernel-install", "libiptc", "elfutils", "repart", "homed", "importd", "acl", "dns-over-tls", "gnu-efi", "valgrind", "log-trace"] + + if Version(self.version) >= "247.1": + unrelated.append("oomd") + if Version(self.version) >= "248.1": + unrelated.extend(["sysext", "nscd"]) + if Version(self.version) >= "251.1": + unrelated.append("link-boot-shared") + for opt in unrelated: - defs[opt] = "false" + tc.project_options[opt] = "false" - meson.configure(source_folder=self._source_subfolder, - build_folder=self._build_subfolder, defs=defs) - return meson + # 'rootprefix' is unused during libsystemd packaging but systemd > v247 + # build files require 'prefix' to be a subdirectory of 'rootprefix'. + tc.project_options["rootprefix"] = self.package_folder + + # There are a few places in libsystemd where pkgconfig dependencies are + # not used in compile time and only used in link time. And because of + # that it is not enough to use the 'PkgConfigDeps' generator here. It + # is also required to provide a path to the header files directly to + # the compiler. + for dependency in self.dependencies.values(): + for includedir in dependency.cpp_info.includedirs: + tc.c_args.append("-I{}".format(includedir)) + + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + meson_build = os.path.join(self.source_folder, "meson.build") + replace_in_file(self, meson_build, "@CONAN_SRC_REL_PATH@", + "'../{}'".format(os.path.basename(self.source_folder))) def build(self): - meson_build = os.path.join(self._source_subfolder, "meson.build") - tools.replace_in_file( - meson_build, """relative_source_path = run_command('realpath', - '--relative-to=@0@'.format(project_build_root), - project_source_root).stdout().strip()""", - "relative_source_path = '../{}'".format(self._source_subfolder)) - - meson = self._configure_meson() - target = ("libsystemd.so.{}".format(self._so_version) - if self.options.shared else "libsystemd.a") - meson.build(targets=["version.h", target]) + self._patch_sources() + + meson = Meson(self) + meson.configure() + target = ("systemd:shared_library" if self.options.shared + else "systemd:static_library") + meson.build(target="version.h {}".format(target)) def package(self): - self.copy(pattern="LICENSE.LGPL2.1", dst="licenses", - src=self._source_subfolder) - self.copy(pattern="*.h", dst=os.path.join("include", "systemd"), - src=os.path.join(self._source_subfolder, "src", "systemd")) + copy(self, "LICENSE.LGPL2.1", self.source_folder, + os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", os.path.join(self.source_folder, "src", "systemd"), + os.path.join(self.package_folder, "include", "systemd")) if self.options.shared: - self.copy(pattern="libsystemd.so", dst="lib", - src=self._build_subfolder, symlinks=True) - self.copy(pattern="libsystemd.so.{}".format(self._so_version.split('.')), - dst="lib", src=self._build_subfolder, symlinks=True) - self.copy(pattern="libsystemd.so.{}".format(self._so_version), - dst="lib", src=self._build_subfolder, symlinks=True) + copy(self, "libsystemd.so", self.build_folder, + os.path.join(self.package_folder, "lib")) + copy(self, "libsystemd.so.{}".format(self._so_version.split('.')), + self.build_folder, os.path.join(self.package_folder, "lib")) + copy(self, "libsystemd.so.{}".format(self._so_version), + self.build_folder, os.path.join(self.package_folder, "lib")) else: - self.copy(pattern="libsystemd.a", dst="lib", - src=self._build_subfolder) + copy(self, "libsystemd.a", self.build_folder, + os.path.join(self.package_folder, "lib")) def package_info(self): self.cpp_info.libs = ["systemd"] # FIXME: this `.version` should only happen for the `pkg_config` # generator (see https://github.com/conan-io/conan/issues/8202) # systemd uses only major version in its .pc file - self.cpp_info.version = tools.Version(self.version).major + self.cpp_info.version = str(Version(self.version).major) + self.cpp_info.set_property("component_version", + str(Version(self.version).major)) self.cpp_info.system_libs = ["rt", "pthread", "dl"] + + # FIXME: remove this block and set required_conan_version to >=1.51.1 + # (see https://github.com/conan-io/conan/pull/11790) + self.cpp_info.requires = ["libcap::libcap", "libmount::libmount"] + if self.options.with_selinux: + self.cpp_info.requires.append("libselinux::libselinux") + if self.options.with_lz4: + self.cpp_info.requires.append("lz4::lz4") + if self.options.with_xz: + self.cpp_info.requires.append("xz_utils::xz_utils") + if self.options.with_zstd: + self.cpp_info.requires.append("zstd::zstd") diff --git a/recipes/libsystemd/all/patches/246.16/0001-Drop-bundled-copy-of-linux-if_arp.h.patch b/recipes/libsystemd/all/patches/246.16/0001-Drop-bundled-copy-of-linux-if_arp.h.patch new file mode 100644 index 0000000000000..cb77bf0883880 --- /dev/null +++ b/recipes/libsystemd/all/patches/246.16/0001-Drop-bundled-copy-of-linux-if_arp.h.patch @@ -0,0 +1,223 @@ +From 00ff923c28498dad77c1705c3699a21bcc941329 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Wed, 15 Sep 2021 16:33:05 +0200 +Subject: [PATCH 1/2] Drop bundled copy of linux/if_arp.h +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +As far as I can see, we use this to get a list of ARPHRD_* defines (used in +particular for Type= in .link files). If we drop our copy, and build against +old kernel headers, the user will have a shorter list of types available. This +seems OK, and I don't think it's worth carrying our own version of this file +just to have newest possible entries. + +7c5b9952c4f6e2b72f90edbe439982528b7cf223 recently updated this file, but we'd +have to update it every time the kernel adds new entries. But if we look at +the failure carefully: + +src/basic/arphrd-from-name.gperf:65:16: error: ‘ARPHRD_MCTP’ undeclared (first use in this function); did you mean ‘ARPHRD_FCPP’? + 65 | MCTP, ARPHRD_MCTP + | ^~ + | ARPHRD_FCPP + +we see that the list we were generating was from the system headers, so it was +only as good as the system headers anyway, without the newer entries in our +bundled copy, if there were any. So let's make things simpler by always using +system headers. + +And if somebody wants to fix things so that we always have the newest list, +then we should just generate and store the converted list, not the full header. + +(cherry picked from commit e7f46ee3ae1cc66a94b293957721d68dc09d7449) +--- + src/basic/linux/if_arp.h | 164 --------------------------------------- + src/basic/meson.build | 1 - + 2 files changed, 165 deletions(-) + delete mode 100644 src/basic/linux/if_arp.h + +diff --git a/src/basic/linux/if_arp.h b/src/basic/linux/if_arp.h +deleted file mode 100644 +index c3cc5a9e5e..0000000000 +--- a/src/basic/linux/if_arp.h ++++ /dev/null +@@ -1,164 +0,0 @@ +-/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +-/* +- * INET An implementation of the TCP/IP protocol suite for the LINUX +- * operating system. INET is implemented using the BSD Socket +- * interface as the means of communication with the user level. +- * +- * Global definitions for the ARP (RFC 826) protocol. +- * +- * Version: @(#)if_arp.h 1.0.1 04/16/93 +- * +- * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988 +- * Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source. +- * Ross Biro +- * Fred N. van Kempen, +- * Florian La Roche, +- * Jonathan Layes +- * Arnaldo Carvalho de Melo ARPHRD_HWX25 +- * +- * This program is free software; you can redistribute it and/or +- * modify it under the terms of the GNU General Public License +- * as published by the Free Software Foundation; either version +- * 2 of the License, or (at your option) any later version. +- */ +-#ifndef _UAPI_LINUX_IF_ARP_H +-#define _UAPI_LINUX_IF_ARP_H +- +-#include +- +-/* ARP protocol HARDWARE identifiers. */ +-#define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */ +-#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */ +-#define ARPHRD_EETHER 2 /* Experimental Ethernet */ +-#define ARPHRD_AX25 3 /* AX.25 Level 2 */ +-#define ARPHRD_PRONET 4 /* PROnet token ring */ +-#define ARPHRD_CHAOS 5 /* Chaosnet */ +-#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */ +-#define ARPHRD_ARCNET 7 /* ARCnet */ +-#define ARPHRD_APPLETLK 8 /* APPLEtalk */ +-#define ARPHRD_DLCI 15 /* Frame Relay DLCI */ +-#define ARPHRD_ATM 19 /* ATM */ +-#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */ +-#define ARPHRD_IEEE1394 24 /* IEEE 1394 IPv4 - RFC 2734 */ +-#define ARPHRD_EUI64 27 /* EUI-64 */ +-#define ARPHRD_INFINIBAND 32 /* InfiniBand */ +- +-/* Dummy types for non ARP hardware */ +-#define ARPHRD_SLIP 256 +-#define ARPHRD_CSLIP 257 +-#define ARPHRD_SLIP6 258 +-#define ARPHRD_CSLIP6 259 +-#define ARPHRD_RSRVD 260 /* Notional KISS type */ +-#define ARPHRD_ADAPT 264 +-#define ARPHRD_ROSE 270 +-#define ARPHRD_X25 271 /* CCITT X.25 */ +-#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware */ +-#define ARPHRD_CAN 280 /* Controller Area Network */ +-#define ARPHRD_PPP 512 +-#define ARPHRD_CISCO 513 /* Cisco HDLC */ +-#define ARPHRD_HDLC ARPHRD_CISCO +-#define ARPHRD_LAPB 516 /* LAPB */ +-#define ARPHRD_DDCMP 517 /* Digital's DDCMP protocol */ +-#define ARPHRD_RAWHDLC 518 /* Raw HDLC */ +-#define ARPHRD_RAWIP 519 /* Raw IP */ +- +-#define ARPHRD_TUNNEL 768 /* IPIP tunnel */ +-#define ARPHRD_TUNNEL6 769 /* IP6IP6 tunnel */ +-#define ARPHRD_FRAD 770 /* Frame Relay Access Device */ +-#define ARPHRD_SKIP 771 /* SKIP vif */ +-#define ARPHRD_LOOPBACK 772 /* Loopback device */ +-#define ARPHRD_LOCALTLK 773 /* Localtalk device */ +-#define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface */ +-#define ARPHRD_BIF 775 /* AP1000 BIF */ +-#define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4 */ +-#define ARPHRD_IPDDP 777 /* IP over DDP tunneller */ +-#define ARPHRD_IPGRE 778 /* GRE over IP */ +-#define ARPHRD_PIMREG 779 /* PIMSM register interface */ +-#define ARPHRD_HIPPI 780 /* High Performance Parallel Interface */ +-#define ARPHRD_ASH 781 /* Nexus 64Mbps Ash */ +-#define ARPHRD_ECONET 782 /* Acorn Econet */ +-#define ARPHRD_IRDA 783 /* Linux-IrDA */ +-/* ARP works differently on different FC media .. so */ +-#define ARPHRD_FCPP 784 /* Point to point fibrechannel */ +-#define ARPHRD_FCAL 785 /* Fibrechannel arbitrated loop */ +-#define ARPHRD_FCPL 786 /* Fibrechannel public loop */ +-#define ARPHRD_FCFABRIC 787 /* Fibrechannel fabric */ +- /* 787->799 reserved for fibrechannel media types */ +-#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR */ +-#define ARPHRD_IEEE80211 801 /* IEEE 802.11 */ +-#define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header */ +-#define ARPHRD_IEEE80211_RADIOTAP 803 /* IEEE 802.11 + radiotap header */ +-#define ARPHRD_IEEE802154 804 +-#define ARPHRD_IEEE802154_MONITOR 805 /* IEEE 802.15.4 network monitor */ +- +-#define ARPHRD_PHONET 820 /* PhoNet media type */ +-#define ARPHRD_PHONET_PIPE 821 /* PhoNet pipe header */ +-#define ARPHRD_CAIF 822 /* CAIF media type */ +-#define ARPHRD_IP6GRE 823 /* GRE over IPv6 */ +-#define ARPHRD_NETLINK 824 /* Netlink header */ +-#define ARPHRD_6LOWPAN 825 /* IPv6 over LoWPAN */ +-#define ARPHRD_VSOCKMON 826 /* Vsock monitor header */ +- +-#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known */ +-#define ARPHRD_NONE 0xFFFE /* zero header length */ +- +-/* ARP protocol opcodes. */ +-#define ARPOP_REQUEST 1 /* ARP request */ +-#define ARPOP_REPLY 2 /* ARP reply */ +-#define ARPOP_RREQUEST 3 /* RARP request */ +-#define ARPOP_RREPLY 4 /* RARP reply */ +-#define ARPOP_InREQUEST 8 /* InARP request */ +-#define ARPOP_InREPLY 9 /* InARP reply */ +-#define ARPOP_NAK 10 /* (ATM)ARP NAK */ +- +- +-/* ARP ioctl request. */ +-struct arpreq { +- struct sockaddr arp_pa; /* protocol address */ +- struct sockaddr arp_ha; /* hardware address */ +- int arp_flags; /* flags */ +- struct sockaddr arp_netmask; /* netmask (only for proxy arps) */ +- char arp_dev[IFNAMSIZ]; +-}; +- +-struct arpreq_old { +- struct sockaddr arp_pa; /* protocol address */ +- struct sockaddr arp_ha; /* hardware address */ +- int arp_flags; /* flags */ +- struct sockaddr arp_netmask; /* netmask (only for proxy arps) */ +-}; +- +-/* ARP Flag values. */ +-#define ATF_COM 0x02 /* completed entry (ha valid) */ +-#define ATF_PERM 0x04 /* permanent entry */ +-#define ATF_PUBL 0x08 /* publish entry */ +-#define ATF_USETRAILERS 0x10 /* has requested trailers */ +-#define ATF_NETMASK 0x20 /* want to use a netmask (only +- for proxy entries) */ +-#define ATF_DONTPUB 0x40 /* don't answer this addresses */ +- +-/* +- * This structure defines an ethernet arp header. +- */ +- +-struct arphdr { +- __be16 ar_hrd; /* format of hardware address */ +- __be16 ar_pro; /* format of protocol address */ +- unsigned char ar_hln; /* length of hardware address */ +- unsigned char ar_pln; /* length of protocol address */ +- __be16 ar_op; /* ARP opcode (command) */ +- +-#if 0 +- /* +- * Ethernet looks like this : This bit is variable sized however... +- */ +- unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ +- unsigned char ar_sip[4]; /* sender IP address */ +- unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ +- unsigned char ar_tip[4]; /* target IP address */ +-#endif +- +-}; +- +- +-#endif /* _UAPI_LINUX_IF_ARP_H */ +diff --git a/src/basic/meson.build b/src/basic/meson.build +index ae01beaeaa..feb4e75b74 100644 +--- a/src/basic/meson.build ++++ b/src/basic/meson.build +@@ -95,7 +95,6 @@ basic_sources = files(''' + linux/fou.h + linux/if.h + linux/if_addr.h +- linux/if_arp.h + linux/if_bonding.h + linux/if_bridge.h + linux/if_ether.h +-- +2.37.2 + diff --git a/recipes/libsystemd/all/patches/246.16/0002-meson.build-change-operator-combining-bools-from-to-.patch b/recipes/libsystemd/all/patches/246.16/0002-meson.build-change-operator-combining-bools-from-to-.patch new file mode 100644 index 0000000000000..8ad824a0820d5 --- /dev/null +++ b/recipes/libsystemd/all/patches/246.16/0002-meson.build-change-operator-combining-bools-from-to-.patch @@ -0,0 +1,34 @@ +From eda62b3f67ce3ae5d1ddf281034a66bcf6c74933 Mon Sep 17 00:00:00 2001 +From: Dan Streetman +Date: Fri, 3 Sep 2021 12:43:33 -0400 +Subject: [PATCH 2/2] meson.build: change operator combining bools from + to + and + +upstream meson stopped allowing combining boolean with the plus +operator, and now requires using the logical and operator + +reference: +https://github.com/mesonbuild/meson/commit/43302d3296baff6aeaf8e03f5d701b0402e37a6c + +Fixes: #20632 +(cherry picked from commit c29537f39e4f413a6cbfe9669fa121bdd6d8b36f) +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 77da8a4504..3754e89c24 100644 +--- a/meson.build ++++ b/meson.build +@@ -40,7 +40,7 @@ conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) + + want_ossfuzz = get_option('oss-fuzz') + want_libfuzzer = get_option('llvm-fuzz') +-if want_ossfuzz + want_libfuzzer > 1 ++if want_ossfuzz and want_libfuzzer + error('only one of oss-fuzz or llvm-fuzz can be specified') + endif + +-- +2.37.2 + diff --git a/recipes/libsystemd/all/patches/246.16/0003-Remove-dependency-from-coreutils.patch b/recipes/libsystemd/all/patches/246.16/0003-Remove-dependency-from-coreutils.patch new file mode 100644 index 0000000000000..9aa5388102343 --- /dev/null +++ b/recipes/libsystemd/all/patches/246.16/0003-Remove-dependency-from-coreutils.patch @@ -0,0 +1,29 @@ +From 39d419d89e069213ec3bce9390df26de68f41135 Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Thu, 18 Aug 2022 21:51:58 +0300 +Subject: [PATCH] Remove dependency from coreutils + +In a conan recipe we already know the relative path to the source directory. We +can simply replace '@CONAN_SRC_REL_PATH@' with the actual path there. +--- + meson.build | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/meson.build b/meson.build +index 77da8a4504..08560292a1 100644 +--- a/meson.build ++++ b/meson.build +@@ -33,9 +33,7 @@ substs.set('PROJECT_VERSION', meson.project_version(), + # the wrong result when systemd is being built as a meson subproject + project_source_root = meson.current_source_dir() + project_build_root = meson.current_build_dir() +-relative_source_path = run_command('realpath', +- '--relative-to=@0@'.format(project_build_root), +- project_source_root).stdout().strip() ++relative_source_path = @CONAN_SRC_REL_PATH@ + conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) + + want_ossfuzz = get_option('oss-fuzz') +-- +2.37.2 + diff --git a/recipes/libsystemd/all/patches/247.11/0001-Remove-dependency-from-coreutils.patch b/recipes/libsystemd/all/patches/247.11/0001-Remove-dependency-from-coreutils.patch new file mode 100644 index 0000000000000..ef33b45cc2799 --- /dev/null +++ b/recipes/libsystemd/all/patches/247.11/0001-Remove-dependency-from-coreutils.patch @@ -0,0 +1,29 @@ +From 319900054fb800f3f3c57806176a71e5f5cff5bd Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Thu, 18 Aug 2022 21:51:58 +0300 +Subject: [PATCH] Remove dependency from coreutils + +In a conan recipe we already know the relative path to the source directory. We +can simply replace '@CONAN_SRC_REL_PATH@' with the actual path there. +--- + meson.build | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/meson.build b/meson.build +index 177cd4fb66..869c2352f6 100644 +--- a/meson.build ++++ b/meson.build +@@ -33,9 +33,7 @@ substs.set('PROJECT_VERSION', meson.project_version(), + # the wrong result when systemd is being built as a meson subproject + project_source_root = meson.current_source_dir() + project_build_root = meson.current_build_dir() +-relative_source_path = run_command('realpath', +- '--relative-to=@0@'.format(project_build_root), +- project_source_root).stdout().strip() ++relative_source_path = @CONAN_SRC_REL_PATH@ + conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) + + conf.set('BUILD_MODE', 'BUILD_MODE_' + get_option('mode').to_upper(), +-- +2.37.2 + diff --git a/recipes/libsystemd/all/patches/248.10/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch b/recipes/libsystemd/all/patches/248.10/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch new file mode 100644 index 0000000000000..93bb5224d5833 --- /dev/null +++ b/recipes/libsystemd/all/patches/248.10/0001-missing_syscalls.py-Replace-unicode-with-ascii.patch @@ -0,0 +1,30 @@ +From 512223a1ada207304787fb24a6da9e844b381239 Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Wed, 17 Aug 2022 22:31:13 +0300 +Subject: [PATCH] missing_syscalls.py: Replace unicode with ascii + +In some system configurations 'find_program('missing_syscalls.py')' may +fail with error: + 'ascii' codec can't decode byte 0xe2 in position 615: ordinal not in range(128) + Unusable script 'src/basic/missing_syscalls.py' + Program missing_syscalls.py found: NO +--- + src/basic/missing_syscalls.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/basic/missing_syscalls.py b/src/basic/missing_syscalls.py +index 1bfa31ba37..cc353fe723 100644 +--- a/src/basic/missing_syscalls.py ++++ b/src/basic/missing_syscalls.py +@@ -32,7 +32,7 @@ def dictify(f): + + @dictify + def parse_syscall_table(filename): +- print(f'Reading {filename}…') ++ print(f'Reading {filename}...') + for line in open(filename): + items = line.split() + if len(items) >= 2: +-- +2.37.2 + diff --git a/recipes/libsystemd/all/patches/249.12/0001-Remove-dependency-from-coreutils.patch b/recipes/libsystemd/all/patches/249.12/0001-Remove-dependency-from-coreutils.patch new file mode 100644 index 0000000000000..de0ae81a2b1a0 --- /dev/null +++ b/recipes/libsystemd/all/patches/249.12/0001-Remove-dependency-from-coreutils.patch @@ -0,0 +1,29 @@ +From dd758e85278e15db6e66e9802744f120eeb2285c Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Thu, 18 Aug 2022 21:51:58 +0300 +Subject: [PATCH] Remove dependency from coreutils + +In a conan recipe we already know the relative path to the source directory. We +can simply replace '@CONAN_SRC_REL_PATH@' with the actual path there. +--- + meson.build | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/meson.build b/meson.build +index b9b8ebef45..30c5b6efa1 100644 +--- a/meson.build ++++ b/meson.build +@@ -25,9 +25,7 @@ conf.set('PROJECT_VERSION', meson.project_version(), + # the wrong result when systemd is being built as a meson subproject + project_source_root = meson.current_source_dir() + project_build_root = meson.current_build_dir() +-relative_source_path = run_command('realpath', +- '--relative-to=@0@'.format(project_build_root), +- project_source_root).stdout().strip() ++relative_source_path = @CONAN_SRC_REL_PATH@ + conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) + + conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer', +-- +2.37.2 + diff --git a/recipes/libsystemd/all/patches/251.4/0001-Remove-dependency-from-coreutils.patch b/recipes/libsystemd/all/patches/251.4/0001-Remove-dependency-from-coreutils.patch new file mode 100644 index 0000000000000..466e1bb85a6ce --- /dev/null +++ b/recipes/libsystemd/all/patches/251.4/0001-Remove-dependency-from-coreutils.patch @@ -0,0 +1,30 @@ +From 9c20566484b758204215f945dfa8a1242b8bff8c Mon Sep 17 00:00:00 2001 +From: Sergey Bobrenok +Date: Thu, 18 Aug 2022 21:51:58 +0300 +Subject: [PATCH] Remove dependency from coreutils + +In a conan recipe we already know the relative path to the source directory. We +can simply replace '@CONAN_SRC_REL_PATH@' with the actual path there. +--- + meson.build | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/meson.build b/meson.build +index dbba108ad1..035869fb0d 100644 +--- a/meson.build ++++ b/meson.build +@@ -25,10 +25,7 @@ conf.set('PROJECT_VERSION', meson.project_version(), + # the wrong result when systemd is being built as a meson subproject + project_source_root = meson.current_source_dir() + project_build_root = meson.current_build_dir() +-relative_source_path = run_command('realpath', +- '--relative-to=@0@'.format(project_build_root), +- project_source_root, +- check : true).stdout().strip() ++relative_source_path = @CONAN_SRC_REL_PATH@ + conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) + + conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer', +-- +2.37.2 + diff --git a/recipes/libsystemd/all/test_package/CMakeLists.txt b/recipes/libsystemd/all/test_package/CMakeLists.txt index 48b855b8a30aa..16f08025b6a67 100644 --- a/recipes/libsystemd/all/test_package/CMakeLists.txt +++ b/recipes/libsystemd/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(PackageTest C) +cmake_minimum_required(VERSION 3.15) +project(PackageTest LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(PkgConfig REQUIRED) +pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd) add_executable(example example.c) -target_link_libraries(example ${CONAN_LIBS}) +target_link_libraries(example PRIVATE PkgConfig::SYSTEMD) diff --git a/recipes/libsystemd/all/test_package/conanfile.py b/recipes/libsystemd/all/test_package/conanfile.py index a8c448a710802..0aeda735af009 100644 --- a/recipes/libsystemd/all/test_package/conanfile.py +++ b/recipes/libsystemd/all/test_package/conanfile.py @@ -1,11 +1,32 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.env import Environment + +required_conan_version = ">=1.38.0" class LibsystemdTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeToolchain", "PkgConfigDeps", "VirtualBuildEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.tool_requires("pkgconf/1.7.4") + + def layout(self): + cmake_layout(self) + + def generate(self): + env = Environment() + env.prepend_path("PKG_CONFIG_PATH", self.generators_folder) + envvars = env.vars(self) + envvars.save_script("pkg_config") def build(self): cmake = CMake(self) @@ -13,6 +34,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "example") + self.run(bin_path, env="conanrun") diff --git a/recipes/libsystemd/all/test_v1_package/CMakeLists.txt b/recipes/libsystemd/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4729ae06ab8cf --- /dev/null +++ b/recipes/libsystemd/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.15) +project(PackageTest LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd) + +add_executable(example ../test_package/example.c) +target_link_libraries(example PRIVATE PkgConfig::SYSTEMD) diff --git a/recipes/libsystemd/all/test_v1_package/conanfile.py b/recipes/libsystemd/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..1db9d3daee488 --- /dev/null +++ b/recipes/libsystemd/all/test_v1_package/conanfile.py @@ -0,0 +1,23 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run +from conans import CMake + + +class LibsystemdTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "pkg_config" + + def build_requirements(self): + self.tool_requires("pkgconf/1.7.4") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/libsystemd/config.yml b/recipes/libsystemd/config.yml index d6f50cc53a9e1..46dd6c53cbb3c 100644 --- a/recipes/libsystemd/config.yml +++ b/recipes/libsystemd/config.yml @@ -1,7 +1,11 @@ versions: - "246.6": + "246.16": folder: all - "247.2": + "247.11": folder: all - "247.3": + "248.10": + folder: all + "249.12": + folder: all + "251.4": folder: all diff --git a/recipes/libtar/all/conanfile.py b/recipes/libtar/all/conanfile.py index 377827d478586..b6aa8c881a985 100644 --- a/recipes/libtar/all/conanfile.py +++ b/recipes/libtar/all/conanfile.py @@ -1,13 +1,19 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration -import glob +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.env import VirtualRunEnv +from conan.tools.files import copy, get, replace_in_file, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.50.0" + class LibTarConan(ConanFile): name = "libtar" description = "libtar is a library for manipulating tar files from within C programs." - topics = ("conan", "libtar") + topics = ("libtar", "tar") license = "BSD-3-Clause" homepage = "https://repo.or.cz/libtar.git" url = "https://github.com/conan-io/conan-center-index" @@ -23,74 +29,84 @@ class LibTarConan(ConanFile): "with_zlib": True, } - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - def requirements(self): - if self.options.with_zlib: - self.requires("zlib/1.2.11") - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("libtar does not support Visual Studio") if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + if self.options.with_zlib: + self.requires("zlib/1.2.12") + + def validate(self): + if self.info.settings.os == "Windows": + raise ConanInvalidConfiguration("libtar does not support Windows") def build_requirements(self): - self.build_requires("libtool/2.4.6") + self.tool_requires("libtool/2.4.7") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(glob.glob("libtar-*")[0], self._source_subfolder) - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.libs = [] - conf_args = [ + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ "--with-zlib" if self.options.with_zlib else "--without-zlib", - ] - if self.options.shared: - conf_args.extend(["--enable-shared", "--disable-static"]) - else: - conf_args.extend(["--disable-shared", "--enable-static"]) - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return self._autotools + ]) + tc.generate() + deps = AutotoolsDeps(self) + deps.generate() + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") def _patch_sources(self): if self.options.with_zlib: - tools.replace_in_file(os.path.join(self._source_subfolder, "configure.ac"), - "AC_CHECK_LIB([z], [gzread])", - "AC_CHECK_LIB([{}], [gzread])".format(self.deps_cpp_info["zlib"].libs[0])) + replace_in_file( + self, + os.path.join(self.source_folder, "configure.ac"), + "AC_CHECK_LIB([z], [gzread])", + "AC_CHECK_LIB([{}], [gzread])".format(self.dependencies["zlib"].cpp_info.libs[0]), + ) def build(self): self._patch_sources() - with tools.chdir(self._source_subfolder): - self.run("autoreconf -fiv", run_environment=True, win_bash=tools.os_info.is_windows) - autotools = self._configure_autotools() + autotools = Autotools(self) + autotools.autoreconf() + # TODO: use fix_apple_shared_install_name(self) instead, once https://github.com/conan-io/conan/issues/12107 fixed + replace_in_file(self, os.path.join(self.source_folder, "configure"), "-install_name \\$rpath/", "-install_name @rpath/") + autotools.configure() autotools.make() def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - autotools = self._configure_autotools() + copy(self, "COPYRIGHT", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) autotools.install() - - os.unlink(os.path.join(os.path.join(self.package_folder, "lib", "libtar.la"))) - tools.rmdir(os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): self.cpp_info.libs = ["tar"] + # TODO: to remove in conan v2 bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.output.info(f"Appending PATH environment variable: {bin_path}") self.deps_env_info.PATH.append(bin_path) diff --git a/recipes/libtar/all/test_package/CMakeLists.txt b/recipes/libtar/all/test_package/CMakeLists.txt index 3a403dc404b41..be08382306a84 100644 --- a/recipes/libtar/all/test_package/CMakeLists.txt +++ b/recipes/libtar/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +find_package(libtar REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libtar::libtar) diff --git a/recipes/libtar/all/test_package/conanfile.py b/recipes/libtar/all/test_package/conanfile.py index a3f7bada13611..cdb17258fdda1 100644 --- a/recipes/libtar/all/test_package/conanfile.py +++ b/recipes/libtar/all/test_package/conanfile.py @@ -1,12 +1,22 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanException +from conan import ConanFile +from conan.errors import ConanException +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.files import load import os import tarfile class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -14,7 +24,7 @@ def build(self): cmake.build() def test(self): - with tarfile.open("test.tar", "w") as f: + with tarfile.open("test.tar", "w", format=tarfile.GNU_FORMAT) as f: import io bio = io.BytesIO() bio.write(b"secret text\n") @@ -25,15 +35,15 @@ def test(self): bio.seek(0) f.addfile(tarinfo, bio) - if not tools.cross_building(self.settings): + if can_run(self): if os.path.exists("hello_world"): raise ConanException("file extracted by tar archive should not exist yet") - bin_path = os.path.join("bin", "test_package") - self.run("{} {}".format(bin_path, "test.tar"), run_environment=True) + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(f"{bin_path} test.tar", env="conanrun") if not os.path.exists("hello_world"): raise ConanException("file not extracted") - extracted_text = tools.load("hello_world") + extracted_text = load(self, "hello_world") if extracted_text != "secret text\n": - raise ConanException("File not loaded correctly. Got \"{}\"".format(repr(extracted_text))) + raise ConanException(f"File not loaded correctly. Got \"{repr(extracted_text)}\"") self.run("libtar -t test.tar", run_environment=True) diff --git a/recipes/libtar/all/test_v1_package/CMakeLists.txt b/recipes/libtar/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9fcc6db676fb9 --- /dev/null +++ b/recipes/libtar/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libtar REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libtar::libtar) diff --git a/recipes/libtar/all/test_v1_package/conanfile.py b/recipes/libtar/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..ace7da972a9e0 --- /dev/null +++ b/recipes/libtar/all/test_v1_package/conanfile.py @@ -0,0 +1,39 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanException +import os +import tarfile + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + with tarfile.open("test.tar", "w", format=tarfile.GNU_FORMAT) as f: + import io + bio = io.BytesIO() + bio.write(b"secret text\n") + tarinfo = tarfile.TarInfo("hello_world") + tarinfo.size = bio.tell() + import time + tarinfo.mtime = time.time() + bio.seek(0) + f.addfile(tarinfo, bio) + + if not tools.cross_building(self): + if os.path.exists("hello_world"): + raise ConanException("file extracted by tar archive should not exist yet") + bin_path = os.path.join("bin", "test_package") + self.run(f"{bin_path} test.tar", run_environment=True) + if not os.path.exists("hello_world"): + raise ConanException("file not extracted") + extracted_text = tools.load("hello_world") + if extracted_text != "secret text\n": + raise ConanException(f"File not loaded correctly. Got \"{repr(extracted_text)}\"") + + self.run("libtar -t test.tar", run_environment=True) diff --git a/recipes/libtasn1/all/conandata.yml b/recipes/libtasn1/all/conandata.yml index 2cb642694eeb9..4c2bc670569f5 100644 --- a/recipes/libtasn1/all/conandata.yml +++ b/recipes/libtasn1/all/conandata.yml @@ -4,5 +4,4 @@ sources: sha256: "0e0fb0903839117cb6e3b56e68222771bebf22ad7fc2295a0ed7d576e8d4329d" patches: "4.16.0": - - base_path: "source_subfolder" - patch_file: "patches/0001-do-not-add-static-to-functions-meant-to-be-built.patch" + - patch_file: "patches/0001-do-not-add-static-to-functions-meant-to-be-built.patch" diff --git a/recipes/libtasn1/all/conanfile.py b/recipes/libtasn1/all/conanfile.py index 79ae3ba255d37..9ec3d89cded7e 100644 --- a/recipes/libtasn1/all/conanfile.py +++ b/recipes/libtasn1/all/conanfile.py @@ -1,17 +1,24 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path import os +required_conan_version = ">=1.52.0" + class LibTasn1Conan(ConanFile): name = "libtasn1" homepage = "https://www.gnu.org/software/libtasn1/" description = "Libtasn1 is the ASN.1 library used by GnuTLS, p11-kit and some other packages." - topics = ("conan", "libtasn", "ASN.1", "cryptography") + topics = ("libtasn", "ASN.1", "cryptography") url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler", "arch", "build_type" license = "LGPL-2.1-or-later" - exports_sources = "patches/**" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -21,11 +28,12 @@ class LibTasn1Conan(ConanFile): "fPIC": True, } - _autotools = None - @property - def _source_subfolder(self): - return "source_subfolder" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -33,55 +41,78 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("Visual Studio is unsupported by libtasn1") - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} doesn't support Visual Studio") def build_requirements(self): - self.build_requires("bison/3.5.3") + self.tool_requires("bison/3.8.2") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + self.tool_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = os.path.join("libtasn1-" + self.version) - os.rename(extracted_dir, self._source_subfolder) - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - if self.settings.compiler != "Visual Studio": - self._autotools.flags.append("-std=c99") - conf_args = [ - "--disable-doc", - ] - if self.options.shared: - conf_args.extend(["--enable-shared", "--disable-static"]) - else: - conf_args.extend(["--disable-shared", "--enable-static"]) - self._autotools.configure(configure_dir=self._source_subfolder, args=conf_args) - return self._autotools + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + if not is_msvc(self): + tc.extra_cflags.append("-std=c99") + tc.configure_args.append("--disable-doc") + # Workaround against SIP on macOS + if self.settings.os == "Macos" and self.options.shared: + tc.extra_ldflags.append("-Wl,-rpath,@loader_path/../lib") + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # TODO: use fix_apple_shared_install_name(self) instead, once https://github.com/conan-io/conan/issues/12107 fixed + replace_in_file(self, os.path.join(self.source_folder, "configure"), + "-install_name \\$rpath/", + "-install_name @rpath/") def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - autotools = self._configure_autotools() + self._patch_sources() + autotools = Autotools(self) + autotools.configure() autotools.make() def package(self): - self.copy(pattern="LICENSE", src=self._source_subfolder, dst="licenses") - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - os.remove(os.path.join(self.package_folder, "lib", "libtasn1.la")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libtasn1") self.cpp_info.libs = ["tasn1"] if not self.options.shared: self.cpp_info.defines = ["ASN1_STATIC"] - + # TODO: to remove in conan v2 bindir = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.output.info(f"Appending PATH environment variable: {bindir}") self.env_info.PATH.append(bindir) diff --git a/recipes/libtasn1/all/test_package/CMakeLists.txt b/recipes/libtasn1/all/test_package/CMakeLists.txt index f1ebac60ec5a2..7a3bf383182c3 100644 --- a/recipes/libtasn1/all/test_package/CMakeLists.txt +++ b/recipes/libtasn1/all/test_package/CMakeLists.txt @@ -1,12 +1,21 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +find_program(ASN1_PARSER NAMES asn1Parser) +if(NOT ASN1_PARSER) + message(FATAL_ERROR "asn1Parser not found") +endif() +find_package(libtasn1 REQUIRED CONFIG) -add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pkix_asn1_tab.c" - COMMAND asn1Parser -o "${CMAKE_CURRENT_BINARY_DIR}/pkix_asn1_tab.c" "${CMAKE_CURRENT_SOURCE_DIR}/pkix.asn" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/pkix.asn") +set(PKIX_ASN1_TAB_C "${CMAKE_CURRENT_BINARY_DIR}/pkix_asn1_tab.c") +set(PKIX_ASN_IN "${CMAKE_CURRENT_SOURCE_DIR}/pkix.asn") +add_custom_command( + COMMAND ${ASN1_PARSER} -o ${PKIX_ASN1_TAB_C} ${PKIX_ASN_IN} + OUTPUT ${PKIX_ASN1_TAB_C} + DEPENDS ${PKIX_ASN_IN} +) +add_custom_target(pkix_asn DEPENDS ${PKIX_ASN1_TAB_C}) -add_executable(${PROJECT_NAME} test_package.cpp "${CMAKE_CURRENT_BINARY_DIR}/pkix_asn1_tab.c") -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c ${PKIX_ASN1_TAB_C}) +target_link_libraries(${PROJECT_NAME} PRIVATE libtasn1::libtasn1) +add_dependencies(${PROJECT_NAME} pkix_asn) diff --git a/recipes/libtasn1/all/test_package/conanfile.py b/recipes/libtasn1/all/test_package/conanfile.py index 1c41e93c89e0b..8214a95b5bd16 100644 --- a/recipes/libtasn1/all/test_package/conanfile.py +++ b/recipes/libtasn1/all/test_package/conanfile.py @@ -1,10 +1,22 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv", "VirtualBuildEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,7 +24,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") asn = os.path.join(self.source_folder, "pkix.asn") - self.run("{} {}".format(bin_path, asn), run_environment=True) + self.run(f"{bin_path} {asn}", env="conanrun") diff --git a/recipes/libtasn1/all/test_package/test_package.cpp b/recipes/libtasn1/all/test_package/test_package.c similarity index 100% rename from recipes/libtasn1/all/test_package/test_package.cpp rename to recipes/libtasn1/all/test_package/test_package.c diff --git a/recipes/libtasn1/all/test_v1_package/CMakeLists.txt b/recipes/libtasn1/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a27809d08ee69 --- /dev/null +++ b/recipes/libtasn1/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +# Note: See https://github.com/conan-io/conan/issues/12237 +# `NO_CMAKE_PATH` is added to avoid searching in `CMAKE_PREFIX_PATH` +# it should find the correct executable by falling back on the `PATH` +# environment variable defined by Conan during the test_package run. +find_program(ASN1_PARSER NAMES asn1Parser NO_CMAKE_PATH) +if(NOT ASN1_PARSER) + message(FATAL_ERROR "asn1Parser not found") +endif() +find_package(libtasn1 REQUIRED CONFIG) + +set(PKIX_ASN1_TAB_C "${CMAKE_CURRENT_BINARY_DIR}/pkix_asn1_tab.c") +set(PKIX_ASN_IN "${CMAKE_CURRENT_SOURCE_DIR}/../test_package/pkix.asn") +add_custom_command( + COMMAND ${ASN1_PARSER} -o ${PKIX_ASN1_TAB_C} ${PKIX_ASN_IN} + OUTPUT ${PKIX_ASN1_TAB_C} + DEPENDS ${PKIX_ASN_IN} +) +add_custom_target(pkix_asn DEPENDS ${PKIX_ASN1_TAB_C}) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c ${PKIX_ASN1_TAB_C}) +target_link_libraries(${PROJECT_NAME} PRIVATE libtasn1::libtasn1) +add_dependencies(${PROJECT_NAME} pkix_asn) diff --git a/recipes/libtasn1/all/test_v1_package/conanfile.py b/recipes/libtasn1/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..4056b294e223c --- /dev/null +++ b/recipes/libtasn1/all/test_v1_package/conanfile.py @@ -0,0 +1,25 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + asn = os.path.join(self.source_folder, os.pardir, "test_package", "pkix.asn") + self.run(f"{bin_path} {asn}", run_environment=True) diff --git a/recipes/libtiff/all/CMakeLists.txt b/recipes/libtiff/all/CMakeLists.txt deleted file mode 100644 index c921d02a0d877..0000000000000 --- a/recipes/libtiff/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libtiff/all/conandata.yml b/recipes/libtiff/all/conandata.yml index fa81703ced52d..ed109970ab657 100644 --- a/recipes/libtiff/all/conandata.yml +++ b/recipes/libtiff/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "4.4.0": + url: "http://download.osgeo.org/libtiff/tiff-4.4.0.tar.gz" + sha256: "917223b37538959aca3b790d2d73aa6e626b688e02dcda272aec24c2f498abed" + "4.3.0": + url: "http://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz" + sha256: "0e46e5acb087ce7d1ac53cf4f56a09b221537fc86dfc5daaad1c2e89e1b37ac8" "4.2.0": url: "http://download.osgeo.org/libtiff/tiff-4.2.0.tar.gz" sha256: "eb0484e568ead8fa23b513e9b0041df7e327f4ee2d22db5a533929dfc19633cb" @@ -12,15 +18,35 @@ sources: url: "http://download.osgeo.org/libtiff/tiff-4.0.8.tar.gz" sha256: "59d7a5a8ccd92059913f246877db95a2918e6c04fb9d43fd74e5c3390dac2910" patches: + "4.4.0": + - patch_file: "patches/4.4.0-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" + "4.3.0": + - patch_file: "patches/4.3.0-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" "4.2.0": - - patch_file: "patches/4.2.0-0001-cmake-add-libjpeg-turbo.patch" - base_path: "source_subfolder" + - patch_file: "patches/4.2.0-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" "4.1.0": - - patch_file: "patches/4.1.0-0001-cmake-add-libjpeg-turbo.patch" - base_path: "source_subfolder" + - patch_file: "patches/4.1.0-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" + - patch_file: "patches/4.1.0-0002-no-libm-mingw.patch" + patch_source: "https://gitlab.com/libtiff/libtiff/-/merge_requests/73" "4.0.9": - - patch_file: "patches/4.0.8-0001-cmake-add-libjpeg-turbo.patch" - base_path: "source_subfolder" + - patch_file: "patches/4.0.8-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" + - patch_file: "patches/4.0.8-0002-no-libm-mingw.patch" + patch_source: "https://gitlab.com/libtiff/libtiff/-/merge_requests/73" "4.0.8": - - patch_file: "patches/4.0.8-0001-cmake-add-libjpeg-turbo.patch" - base_path: "source_subfolder" + - patch_file: "patches/4.0.8-0001-cmake-dependencies.patch" + patch_description: "CMake: robust handling of dependencies" + patch_type: "conan" + - patch_file: "patches/4.0.8-0002-no-libm-mingw.patch" + patch_source: "https://gitlab.com/libtiff/libtiff/-/merge_requests/73" + - patch_file: "patches/4.0.8-0003-file-offsets-bits-mingw.patch" + patch_source: "https://gitlab.com/libtiff/libtiff/-/commit/f2a3b020402943f90957552a884788e70ece6cd7" diff --git a/recipes/libtiff/all/conanfile.py b/recipes/libtiff/all/conanfile.py index f2d1ff0858108..3ef7d44e84a73 100644 --- a/recipes/libtiff/all/conanfile.py +++ b/recipes/libtiff/all/conanfile.py @@ -1,7 +1,13 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os +required_conan_version = ">=1.53.0" + class LibtiffConan(ConanFile): name = "libtiff" @@ -10,9 +16,8 @@ class LibtiffConan(ConanFile): license = "MIT" homepage = "http://www.simplesystems.org/libtiff" topics = ("tiff", "image", "bigtiff", "tagged-image-file-format") - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake", "cmake_find_package" - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -37,27 +42,21 @@ class LibtiffConan(ConanFile): "webp": True, "cxx": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" @property def _has_webp_option(self): - return tools.Version(self.version) >= "4.0.10" + return Version(self.version) >= "4.0.10" @property def _has_zstd_option(self): - return tools.Version(self.version) >= "4.0.10" + return Version(self.version) >= "4.0.10" @property def _has_libdeflate_option(self): - return tools.Version(self.version) >= "4.2.0" + return Version(self.version) >= "4.2.0" + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -71,97 +70,120 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") if not self.options.cxx: - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.options.get_safe("libdeflate") and not self.options.zlib: - raise ConanInvalidConfiguration("libtiff:libdeflate=True requires libtiff:zlib=True") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): if self.options.zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.get_safe("libdeflate"): - self.requires("libdeflate/1.7") + self.requires("libdeflate/1.12") if self.options.lzma: self.requires("xz_utils/5.2.5") if self.options.jpeg == "libjpeg": - self.requires("libjpeg/9d") + self.requires("libjpeg/9e") if self.options.jpeg == "libjpeg-turbo": - self.requires("libjpeg-turbo/2.0.6") + self.requires("libjpeg-turbo/2.1.4") if self.options.jbig: self.requires("jbig/20160605") if self.options.get_safe("zstd"): - self.requires("zstd/1.4.8") + self.requires("zstd/1.5.2") if self.options.get_safe("webp"): - self.requires("libwebp/1.1.0") + self.requires("libwebp/1.2.4") + + def validate(self): + if self.info.options.get_safe("libdeflate") and not self.info.options.zlib: + raise ConanInvalidConfiguration("libtiff:libdeflate=True requires libtiff:zlib=True") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("tiff-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["lzma"] = self.options.lzma + tc.variables["jpeg"] = bool(self.options.jpeg) + tc.variables["jpeg12"] = False + tc.variables["jbig"] = self.options.jbig + tc.variables["zlib"] = self.options.zlib + if self._has_libdeflate_option: + tc.variables["libdeflate"] = self.options.libdeflate + if self._has_zstd_option: + tc.variables["zstd"] = self.options.zstd + if self._has_webp_option: + tc.variables["webp"] = self.options.webp + if Version(self.version) >= "4.3.0": + tc.variables["lerc"] = False # TODO: add lerc support for libtiff versions >= 4.3.0 + tc.variables["cxx"] = self.options.cxx + # BUILD_SHARED_LIBS must be set in command line because defined upstream before project() + tc.cache_variables["BUILD_SHARED_LIBS"] = bool(self.options.shared) + tc.generate() + deps = CMakeDeps(self) + deps.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - if self.options.shared and self.settings.compiler == "Visual Studio": - # https://github.com/Microsoft/vcpkg/blob/master/ports/tiff/fix-cxx-shared-libs.patch - tools.replace_in_file(os.path.join(self._source_subfolder, "libtiff", "CMakeLists.txt"), - r"set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION})", - r"set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION} " - r"WINDOWS_EXPORT_ALL_SYMBOLS ON)") - cmakefile = os.path.join(self._source_subfolder, "CMakeLists.txt") - if self.settings.os == "Windows" and self.settings.compiler != "Visual Studio": - if tools.Version(self.version) < "4.2.0": - tools.replace_in_file(cmakefile, - "find_library(M_LIBRARY m)", - "if (NOT MINGW)\n find_library(M_LIBRARY m)\nendif()") - if tools.Version(self.version) < "4.0.9": - tools.replace_in_file(cmakefile, "if (UNIX)", "if (UNIX OR MINGW)") - tools.replace_in_file(cmakefile, + apply_conandata_patches(self) + + top_cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + libtiff_cmakelists = os.path.join(self.source_folder, "libtiff", "CMakeLists.txt") + + # Handle libjpeg-turbo + if self.options.jpeg == "libjpeg-turbo": + if Version(self.version) < "4.3.0": + file_find_package_jpeg = top_cmakelists + file_jpeg_target = top_cmakelists + else: + file_find_package_jpeg = os.path.join(self.source_folder, "cmake", "JPEGCodec.cmake") + file_jpeg_target = libtiff_cmakelists + cpp_info_jpeg_turbo = self.dependencies["libjpeg-turbo"].cpp_info + jpeg_config = cpp_info_jpeg_turbo.get_property("cmake_file_name") or "libjpeg-turbo" + jpeg_target = cpp_info_jpeg_turbo.components["jpeg"].get_property("cmake_target_name") or "libjpeg-turbo::jpeg" + replace_in_file(self, file_find_package_jpeg, + "find_package(JPEG)", + f"find_package({jpeg_config} REQUIRED CONFIG)\nset(JPEG_FOUND TRUE)") + replace_in_file(self, file_jpeg_target, "JPEG::JPEG", jpeg_target) + + # Export symbols of tiffxx for msvc shared + replace_in_file(self, libtiff_cmakelists, + "set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION})", + "set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION} WINDOWS_EXPORT_ALL_SYMBOLS ON)") + + # Disable tools, test, contrib, man & html generation + replace_in_file(self, top_cmakelists, "add_subdirectory(tools)\nadd_subdirectory(test)\nadd_subdirectory(contrib)\nadd_subdirectory(build)\n" "add_subdirectory(man)\nadd_subdirectory(html)", "") - tools.replace_in_file(cmakefile, "LIBLZMA_LIBRARIES", "LibLZMA_LIBRARIES") - - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["lzma"] = self.options.lzma - self._cmake.definitions["jpeg"] = self.options.jpeg != False - self._cmake.definitions["jbig"] = self.options.jbig - self._cmake.definitions["zlib"] = self.options.zlib - if self._has_libdeflate_option: - self._cmake.definitions["libdeflate"] = self.options.libdeflate - if self.options.libdeflate: - self._cmake.definitions["DEFLATE_NAMES"] = self.deps_cpp_info["libdeflate"].libs[0] - if self._has_zstd_option: - self._cmake.definitions["zstd"] = self.options.zstd - if self._has_webp_option: - self._cmake.definitions["webp"] = self.options.webp - self._cmake.definitions["cxx"] = self.options.cxx - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYRIGHT", src=self._source_subfolder, dst="licenses", ignore_case=True, keep_path=False) - cmake = self._configure_cmake() + copy(self, "COPYRIGHT", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"), ignore_case=True, keep_path=False) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "TIFF") + self.cpp_info.set_property("cmake_target_name", "TIFF::TIFF") + self.cpp_info.set_property("pkg_config_name", f"libtiff-{Version(self.version).major}") + suffix = "d" if is_msvc(self) and self.settings.build_type == "Debug" else "" if self.options.cxx: - self.cpp_info.libs.append("tiffxx") - self.cpp_info.libs.append("tiff") - if self.settings.os == "Windows" and self.settings.build_type == "Debug" and self.settings.compiler == "Visual Studio": - self.cpp_info.libs = [lib + "d" for lib in self.cpp_info.libs] - if self.options.shared and self.settings.os == "Windows" and self.settings.compiler != "Visual Studio": - self.cpp_info.libs = [lib + ".dll" for lib in self.cpp_info.libs] - if self.settings.os == "Linux": + self.cpp_info.libs.append(f"tiffxx{suffix}") + self.cpp_info.libs.append(f"tiff{suffix}") + if self.settings.os in ["Linux", "Android", "FreeBSD", "SunOS", "AIX"]: self.cpp_info.system_libs.append("m") + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self.cpp_info.names["cmake_find_package"] = "TIFF" self.cpp_info.names["cmake_find_package_multi"] = "TIFF" - self.cpp_info.names["pkg_config"] = "libtiff-4" + self.cpp_info.names["pkg_config"] = f"libtiff-{Version(self.version).major}" diff --git a/recipes/libtiff/all/patches/4.0.8-0001-cmake-add-libjpeg-turbo.patch b/recipes/libtiff/all/patches/4.0.8-0001-cmake-add-libjpeg-turbo.patch deleted file mode 100644 index a8338b086284b..0000000000000 --- a/recipes/libtiff/all/patches/4.0.8-0001-cmake-add-libjpeg-turbo.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -521,14 +521,14 @@ - set(PIXARLOG_SUPPORT TRUE) - endif() - endif() -- - # JPEG - option(jpeg "use libjpeg (required for JPEG compression)" ON) - if (jpeg) - find_package(JPEG) -+ find_package(libjpeg-turbo) - endif() - set(JPEG_SUPPORT FALSE) --if(JPEG_FOUND) -+if(JPEG_FOUND OR libjpeg-turbo_FOUND) - set(JPEG_SUPPORT TRUE) - endif() - -@@ -680,8 +680,8 @@ - if(ZLIB_INCLUDE_DIRS) - list(APPEND TIFF_INCLUDES ${ZLIB_INCLUDE_DIRS}) - endif() --if(JPEG_INCLUDE_DIR) -- list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR}) -+if(JPEG_INCLUDE_DIR OR libjpeg-turbo_INCLUDE_DIRS) -+ list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR} ${libjpeg-turbo_INCLUDE_DIRS}) - endif() - if(JPEG12_INCLUDE_DIR) - list(APPEND TIFF_INCLUDES ${JPEG12_INCLUDE_DIR}) -@@ -701,8 +701,8 @@ - if(ZLIB_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${ZLIB_LIBRARIES}) - endif() --if(JPEG_LIBRARIES) -- list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES}) -+if(JPEG_LIBRARIES OR libjpeg-turbo_LIBRARIES) -+ list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES} ${libjpeg-turbo_LIBRARIES}) - endif() - if(JPEG12_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES}) diff --git a/recipes/libtiff/all/patches/4.0.8-0001-cmake-dependencies.patch b/recipes/libtiff/all/patches/4.0.8-0001-cmake-dependencies.patch new file mode 100644 index 0000000000000..7b7979045b5a1 --- /dev/null +++ b/recipes/libtiff/all/patches/4.0.8-0001-cmake-dependencies.patch @@ -0,0 +1,38 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -544,12 +544,10 @@ endif() + option(jbig "use ISO JBIG compression (requires JBIT-KIT library)" ON) + if (jbig) + set(JBIG_FOUND 0) +- find_path(JBIG_INCLUDE_DIR jbig.h) +- set(JBIG_NAMES ${JBIG_NAMES} jbig libjbig) +- find_library(JBIG_LIBRARY NAMES ${JBIG_NAMES}) +- if (JBIG_INCLUDE_DIR AND JBIG_LIBRARY) ++ find_package(jbig REQUIRED CONFIG) ++ if (1) + set(JBIG_FOUND 1) +- set(JBIG_LIBRARIES ${JBIG_LIBRARY}) ++ set(JBIG_LIBRARIES jbig::jbig) + endif() + endif() + set(JBIG_SUPPORT 0) +@@ -564,7 +562,7 @@ set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARY}) +-check_function_exists(jbg_newlen HAVE_JBG_NEWLEN) ++set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + +@@ -701,8 +699,8 @@ endif() + if(ZLIB_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${ZLIB_LIBRARIES}) + endif() +-if(JPEG_LIBRARIES) +- list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES}) ++if(JPEG_FOUND) ++ list(APPEND TIFF_LIBRARY_DEPS JPEG::JPEG) + endif() + if(JPEG12_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES}) diff --git a/recipes/libtiff/all/patches/4.0.8-0002-no-libm-mingw.patch b/recipes/libtiff/all/patches/4.0.8-0002-no-libm-mingw.patch new file mode 100644 index 0000000000000..216911511380b --- /dev/null +++ b/recipes/libtiff/all/patches/4.0.8-0002-no-libm-mingw.patch @@ -0,0 +1,13 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -206,7 +206,9 @@ else() + endif() + + # Find libm, if available +-find_library(M_LIBRARY m) ++if (NOT MINGW) ++ find_library(M_LIBRARY m) ++endif() + + check_include_file(assert.h HAVE_ASSERT_H) + check_include_file(dlfcn.h HAVE_DLFCN_H) diff --git a/recipes/libtiff/all/patches/4.0.8-0003-file-offsets-bits-mingw.patch b/recipes/libtiff/all/patches/4.0.8-0003-file-offsets-bits-mingw.patch new file mode 100644 index 0000000000000..44a861121db9c --- /dev/null +++ b/recipes/libtiff/all/patches/4.0.8-0003-file-offsets-bits-mingw.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -469,7 +469,7 @@ report_values(CMAKE_HOST_SYSTEM_PROCESSOR HOST_FILLORDER + HOST_BIG_ENDIAN HAVE_IEEEFP) + + # Large file support +-if (UNIX) ++if (UNIX OR MINGW) + # This might not catch every possibility catered for by + # AC_SYS_LARGEFILE. + add_definitions(-D_FILE_OFFSET_BITS=64) diff --git a/recipes/libtiff/all/patches/4.1.0-0001-cmake-add-libjpeg-turbo.patch b/recipes/libtiff/all/patches/4.1.0-0001-cmake-add-libjpeg-turbo.patch deleted file mode 100644 index e6039391033f1..0000000000000 --- a/recipes/libtiff/all/patches/4.1.0-0001-cmake-add-libjpeg-turbo.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -466,14 +466,14 @@ - set(PIXARLOG_SUPPORT TRUE) - endif() - endif() -- - # JPEG - option(jpeg "use libjpeg (required for JPEG compression)" ON) - if (jpeg) - find_package(JPEG) -+ find_package(libjpeg-turbo) - endif() - set(JPEG_SUPPORT FALSE) --if(JPEG_FOUND) -+if(JPEG_FOUND OR libjpeg-turbo_FOUND) - set(JPEG_SUPPORT TRUE) - endif() - -@@ -654,8 +654,8 @@ - if(ZLIB_INCLUDE_DIRS) - list(APPEND TIFF_INCLUDES ${ZLIB_INCLUDE_DIRS}) - endif() --if(JPEG_INCLUDE_DIR) -- list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR}) -+if(JPEG_INCLUDE_DIR OR libjpeg-turbo_INCLUDE_DIRS) -+ list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR} ${libjpeg-turbo_INCLUDE_DIRS}) - endif() - if(JPEG12_INCLUDE_DIR) - list(APPEND TIFF_INCLUDES ${JPEG12_INCLUDE_DIR}) -@@ -681,8 +681,8 @@ - if(ZLIB_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${ZLIB_LIBRARIES}) - endif() --if(JPEG_LIBRARIES) -- list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES}) -+if(JPEG_LIBRARIES OR libjpeg-turbo_LIBRARIES) -+ list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES} ${libjpeg-turbo_LIBRARIES}) - endif() - if(JPEG12_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES}) diff --git a/recipes/libtiff/all/patches/4.1.0-0001-cmake-dependencies.patch b/recipes/libtiff/all/patches/4.1.0-0001-cmake-dependencies.patch new file mode 100644 index 0000000000000..b8a3ec4a4b033 --- /dev/null +++ b/recipes/libtiff/all/patches/4.1.0-0001-cmake-dependencies.patch @@ -0,0 +1,85 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -489,12 +489,10 @@ endif() + option(jbig "use ISO JBIG compression (requires JBIT-KIT library)" ON) + if (jbig) + set(JBIG_FOUND 0) +- find_path(JBIG_INCLUDE_DIR jbig.h) +- set(JBIG_NAMES ${JBIG_NAMES} jbig libjbig) +- find_library(JBIG_LIBRARY NAMES ${JBIG_NAMES}) +- if (JBIG_INCLUDE_DIR AND JBIG_LIBRARY) ++ find_package(jbig REQUIRED CONFIG) ++ if (1) + set(JBIG_FOUND 1) +- set(JBIG_LIBRARIES ${JBIG_LIBRARY}) ++ set(JBIG_LIBRARIES jbig::jbig) + endif() + endif() + set(JBIG_SUPPORT 0) +@@ -507,7 +505,7 @@ endif() + + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIR}) +-check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) ++set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + + # liblzma2 +@@ -523,13 +521,11 @@ endif() + # libzstd + option(zstd "use libzstd (required for ZSTD compression)" ON) + if (zstd) +- find_path(ZSTD_INCLUDE_DIR zstd.h) +- find_library(ZSTD_LIBRARY NAMES zstd) +- if (ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY) +- check_library_exists ("${ZSTD_LIBRARY}" ZSTD_decompressStream "" ZSTD_RECENT_ENOUGH) ++ find_package(zstd REQUIRED CONFIG) ++ if (1) ++ set(ZSTD_RECENT_ENOUGH TRUE) + if (ZSTD_RECENT_ENOUGH) + set(ZSTD_FOUND TRUE) +- set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) + message(STATUS "Found ZSTD library: ${ZSTD_LIBRARY}") + else () + message(WARNING "Found ZSTD library, but not recent enough. Use zstd >= 1.0") +@@ -544,15 +540,13 @@ endif() + # libwebp + option(webp "use libwebp (required for WEBP compression)" ON) + if (webp) +- find_path(WEBP_INCLUDE_DIR /webp/decode.h) +- find_library(WEBP_LIBRARY NAMES webp) ++ find_package(WebP REQUIRED CONFIG) + endif() + set(WEBP_SUPPORT 0) +-set(WEBP_FOUND FALSE) +-if (WEBP_INCLUDE_DIR AND WEBP_LIBRARY) ++if (WebP_FOUND) + set(WEBP_SUPPORT 1) + set(WEBP_FOUND TRUE) +- set(WEBP_LIBRARIES ${WEBP_LIBRARY}) ++ set(WEBP_LIBRARIES WebP::webp) + message(STATUS "Found WEBP library: ${WEBP_LIBRARY}") + endif() + +@@ -681,8 +675,8 @@ endif() + if(ZLIB_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${ZLIB_LIBRARIES}) + endif() +-if(JPEG_LIBRARIES) +- list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES}) ++if(JPEG_FOUND) ++ list(APPEND TIFF_LIBRARY_DEPS JPEG::JPEG) + endif() + if(JPEG12_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES}) +@@ -693,8 +687,8 @@ endif() + if(LIBLZMA_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${LIBLZMA_LIBRARIES}) + endif() +-if(ZSTD_LIBRARIES) +- list(APPEND TIFF_LIBRARY_DEPS ${ZSTD_LIBRARIES}) ++if(ZSTD_FOUND) ++ list(APPEND TIFF_LIBRARY_DEPS $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + if(WEBP_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${WEBP_LIBRARIES}) diff --git a/recipes/libtiff/all/patches/4.1.0-0002-no-libm-mingw.patch b/recipes/libtiff/all/patches/4.1.0-0002-no-libm-mingw.patch new file mode 100644 index 0000000000000..0fcf8f5711810 --- /dev/null +++ b/recipes/libtiff/all/patches/4.1.0-0002-no-libm-mingw.patch @@ -0,0 +1,13 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -207,7 +207,9 @@ else() + endif() + + # Find libm, if available +-find_library(M_LIBRARY m) ++if (NOT MINGW) ++ find_library(M_LIBRARY m) ++endif() + + check_include_file(assert.h HAVE_ASSERT_H) + check_include_file(dlfcn.h HAVE_DLFCN_H) diff --git a/recipes/libtiff/all/patches/4.2.0-0001-cmake-add-libjpeg-turbo.patch b/recipes/libtiff/all/patches/4.2.0-0001-cmake-add-libjpeg-turbo.patch deleted file mode 100644 index df3cb8b0e3e8b..0000000000000 --- a/recipes/libtiff/all/patches/4.2.0-0001-cmake-add-libjpeg-turbo.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -499,9 +499,10 @@ endif() - option(jpeg "use libjpeg (required for JPEG compression)" ON) - if (jpeg) - find_package(JPEG) -+ find_package(libjpeg-turbo) - endif() - set(JPEG_SUPPORT FALSE) --if(JPEG_FOUND) -+if(JPEG_FOUND OR libjpeg-turbo_FOUND) - set(JPEG_SUPPORT TRUE) - endif() - -@@ -685,8 +686,8 @@ endif() - if(DEFLATE_INCLUDE_DIR) - list(APPEND TIFF_INCLUDES ${DEFLATE_INCLUDE_DIR}) - endif() --if(JPEG_INCLUDE_DIR) -- list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR}) -+if(JPEG_INCLUDE_DIR OR libjpeg-turbo_INCLUDE_DIRS) -+ list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR} ${libjpeg-turbo_INCLUDE_DIRS}) - endif() - if(JPEG12_INCLUDE_DIR) - list(APPEND TIFF_INCLUDES ${JPEG12_INCLUDE_DIR}) -@@ -715,8 +716,8 @@ endif() - if(DEFLATE_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${DEFLATE_LIBRARIES}) - endif() --if(JPEG_LIBRARIES) -- list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES}) -+if(JPEG_LIBRARIES OR libjpeg-turbo_LIBRARIES) -+ list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES} ${libjpeg-turbo_LIBRARIES}) - endif() - if(JPEG12_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES}) diff --git a/recipes/libtiff/all/patches/4.2.0-0001-cmake-dependencies.patch b/recipes/libtiff/all/patches/4.2.0-0001-cmake-dependencies.patch new file mode 100644 index 0000000000000..6639e9879408c --- /dev/null +++ b/recipes/libtiff/all/patches/4.2.0-0001-cmake-dependencies.patch @@ -0,0 +1,102 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -463,12 +463,10 @@ set(ZIP_SUPPORT ${ZLIB_SUPPORT}) + option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ON) + if (libdeflate) + set(DEFLATE_FOUND 0) +- find_path(DEFLATE_INCLUDE_DIR libdeflate.h) +- set(DEFLATE_NAMES ${DEFLATE_NAMES} deflate) +- find_library(DEFLATE_LIBRARY NAMES ${DEFLATE_NAMES}) +- if (DEFLATE_INCLUDE_DIR AND DEFLATE_LIBRARY) ++ find_package(libdeflate REQUIRED CONFIG) ++ if (1) + set(DEFLATE_FOUND 1) +- set(DEFLATE_LIBRARIES ${DEFLATE_LIBRARY}) ++ set(DEFLATE_LIBRARIES libdeflate::libdeflate) + endif() + endif() + set(LIBDEFLATE_SUPPORT FALSE) +@@ -517,12 +515,10 @@ endif() + option(jbig "use ISO JBIG compression (requires JBIT-KIT library)" ON) + if (jbig) + set(JBIG_FOUND 0) +- find_path(JBIG_INCLUDE_DIR jbig.h) +- set(JBIG_NAMES ${JBIG_NAMES} jbig libjbig) +- find_library(JBIG_LIBRARY NAMES ${JBIG_NAMES}) +- if (JBIG_INCLUDE_DIR AND JBIG_LIBRARY) ++ find_package(jbig REQUIRED CONFIG) ++ if (1) + set(JBIG_FOUND 1) +- set(JBIG_LIBRARIES ${JBIG_LIBRARY}) ++ set(JBIG_LIBRARIES jbig::jbig) + endif() + endif() + set(JBIG_SUPPORT 0) +@@ -535,7 +531,7 @@ endif() + + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIR}) +-check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) ++set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + + # liblzma2 +@@ -551,14 +547,11 @@ endif() + # libzstd + option(zstd "use libzstd (required for ZSTD compression)" ON) + if (zstd) +- find_path(ZSTD_INCLUDE_DIR zstd.h) +- find_library(ZSTD_LIBRARY NAMES zstd) +- if (ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY) +- check_library_exists ("${ZSTD_LIBRARY}" ZSTD_decompressStream "" ZSTD_RECENT_ENOUGH) ++ find_package(zstd REQUIRED CONFIG) ++ if (1) ++ set(ZSTD_RECENT_ENOUGH TRUE) + if (ZSTD_RECENT_ENOUGH) + set(ZSTD_FOUND TRUE) +- set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) +- message(STATUS "Found ZSTD library: ${ZSTD_LIBRARY}") + else () + message(WARNING "Found ZSTD library, but not recent enough. Use zstd >= 1.0") + endif () +@@ -572,15 +565,13 @@ endif() + # libwebp + option(webp "use libwebp (required for WEBP compression)" ON) + if (webp) +- find_path(WEBP_INCLUDE_DIR /webp/decode.h) +- find_library(WEBP_LIBRARY NAMES webp) ++ find_package(WebP REQUIRED CONFIG) + endif() + set(WEBP_SUPPORT 0) +-set(WEBP_FOUND FALSE) +-if (WEBP_INCLUDE_DIR AND WEBP_LIBRARY) ++if (WebP_FOUND) + set(WEBP_SUPPORT 1) + set(WEBP_FOUND TRUE) +- set(WEBP_LIBRARIES ${WEBP_LIBRARY}) ++ set(WEBP_LIBRARIES WebP::webp) + message(STATUS "Found WEBP library: ${WEBP_LIBRARY}") + endif() + +@@ -715,8 +706,8 @@ endif() + if(DEFLATE_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${DEFLATE_LIBRARIES}) + endif() +-if(JPEG_LIBRARIES) +- list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES}) ++if(JPEG_FOUND) ++ list(APPEND TIFF_LIBRARY_DEPS JPEG::JPEG) + endif() + if(JPEG12_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES}) +@@ -727,8 +718,8 @@ endif() + if(LIBLZMA_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${LIBLZMA_LIBRARIES}) + endif() +-if(ZSTD_LIBRARIES) +- list(APPEND TIFF_LIBRARY_DEPS ${ZSTD_LIBRARIES}) ++if(ZSTD_FOUND) ++ list(APPEND TIFF_LIBRARY_DEPS $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + if(WEBP_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${WEBP_LIBRARIES}) diff --git a/recipes/libtiff/all/patches/4.3.0-0001-cmake-dependencies.patch b/recipes/libtiff/all/patches/4.3.0-0001-cmake-dependencies.patch new file mode 100644 index 0000000000000..a14bbb01635d3 --- /dev/null +++ b/recipes/libtiff/all/patches/4.3.0-0001-cmake-dependencies.patch @@ -0,0 +1,91 @@ +--- a/cmake/DeflateCodec.cmake ++++ b/cmake/DeflateCodec.cmake +@@ -35,7 +35,10 @@ set(ZIP_SUPPORT ${ZLIB_SUPPORT}) + + # libdeflate + set(LIBDEFLATE_SUPPORT FALSE) +-find_package(Deflate) ++find_package(libdeflate CONFIG) ++if(libdeflate_FOUND) ++ set(Deflate_FOUND TRUE) ++endif() + option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND}) + if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT) + set(LIBDEFLATE_SUPPORT TRUE) +--- a/cmake/JBIGCodec.cmake ++++ b/cmake/JBIGCodec.cmake +@@ -27,14 +27,17 @@ + # JBIG-KIT + set(JBIG_SUPPORT FALSE) + +-find_package(JBIG) ++find_package(jbig CONFIG) ++if(jbig_FOUND) ++ set(JBIG_FOUND TRUE) ++endif() + + if(JBIG_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES}) +- check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) ++ set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + endif() +--- a/cmake/ZSTDCodec.cmake ++++ b/cmake/ZSTDCodec.cmake +@@ -28,14 +28,17 @@ + set(ZSTD_SUPPORT FALSE) + set(ZSTD_USABLE FALSE) + +-find_package(ZSTD) ++find_package(zstd CONFIG) ++if(zstd_FOUND) ++ set(ZSTD_FOUND TRUE) ++endif() + + if(ZSTD_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES}) +- check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_RECENT_ENOUGH) ++ set(ZSTD_RECENT_ENOUGH TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + +--- a/libtiff/CMakeLists.txt ++++ b/libtiff/CMakeLists.txt +@@ -110,7 +110,7 @@ if(ZIP_SUPPORT) + target_link_libraries(tiff PRIVATE ZLIB::ZLIB) + endif() + if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) +- target_link_libraries(tiff PRIVATE Deflate::Deflate) ++ target_link_libraries(tiff PRIVATE libdeflate::libdeflate) + endif() + if(JPEG_SUPPORT) + target_link_libraries(tiff PRIVATE JPEG::JPEG) +@@ -120,7 +120,7 @@ if(JPEG_SUPPORT) + endif() + endif() + if(JBIG_SUPPORT) +- target_link_libraries(tiff PRIVATE JBIG::JBIG) ++ target_link_libraries(tiff PRIVATE jbig::jbig) + endif() + if(LERC_SUPPORT) + target_link_libraries(tiff PRIVATE LERC::LERC) +@@ -129,10 +129,10 @@ if(LZMA_SUPPORT) + target_link_libraries(tiff PRIVATE LibLZMA::LibLZMA) + endif() + if(ZSTD_SUPPORT) +- target_link_libraries(tiff PRIVATE ZSTD::ZSTD) ++ target_link_libraries(tiff PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + if(WEBP_SUPPORT) +- target_link_libraries(tiff PRIVATE WebP::WebP) ++ target_link_libraries(tiff PRIVATE WebP::webp) + endif() + target_link_libraries(tiff PRIVATE CMath::CMath) + diff --git a/recipes/libtiff/all/patches/4.4.0-0001-cmake-dependencies.patch b/recipes/libtiff/all/patches/4.4.0-0001-cmake-dependencies.patch new file mode 100644 index 0000000000000..6dcc12574992c --- /dev/null +++ b/recipes/libtiff/all/patches/4.4.0-0001-cmake-dependencies.patch @@ -0,0 +1,92 @@ +--- a/cmake/DeflateCodec.cmake ++++ b/cmake/DeflateCodec.cmake +@@ -35,7 +35,10 @@ set(ZIP_SUPPORT ${ZLIB_SUPPORT}) + + # libdeflate + set(LIBDEFLATE_SUPPORT FALSE) +-find_package(Deflate) ++find_package(libdeflate CONFIG) ++if(libdeflate_FOUND) ++ set(Deflate_FOUND TRUE) ++endif() + option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND}) + if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT) + set(LIBDEFLATE_SUPPORT TRUE) +--- a/cmake/JBIGCodec.cmake ++++ b/cmake/JBIGCodec.cmake +@@ -27,14 +27,17 @@ + # JBIG-KIT + set(JBIG_SUPPORT FALSE) + +-find_package(JBIG) ++find_package(jbig CONFIG) ++if(jbig_FOUND) ++ set(JBIG_FOUND TRUE) ++endif() + + if(JBIG_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES}) +- check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) ++ set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + endif() +--- a/cmake/ZSTDCodec.cmake ++++ b/cmake/ZSTDCodec.cmake +@@ -28,14 +28,17 @@ + set(ZSTD_SUPPORT FALSE) + set(ZSTD_USABLE FALSE) + +-find_package(ZSTD) ++find_package(zstd CONFIG) ++if(zstd_FOUND) ++ set(ZSTD_FOUND TRUE) ++endif() + + if(ZSTD_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES}) +- check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_RECENT_ENOUGH) ++ set(ZSTD_RECENT_ENOUGH TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + +--- a/libtiff/CMakeLists.txt ++++ b/libtiff/CMakeLists.txt +@@ -114,7 +114,7 @@ if(ZIP_SUPPORT) + string(APPEND tiff_requires_private " zlib") + endif() + if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) +- target_link_libraries(tiff PRIVATE Deflate::Deflate) ++ target_link_libraries(tiff PRIVATE libdeflate::libdeflate) + list(APPEND tiff_libs_private_list "${Deflate_LIBRARY}") + endif() + if(JPEG_SUPPORT) +@@ -126,7 +126,7 @@ if(JPEG_SUPPORT) + endif() + endif() + if(JBIG_SUPPORT) +- target_link_libraries(tiff PRIVATE JBIG::JBIG) ++ target_link_libraries(tiff PRIVATE jbig::jbig) + list(APPEND tiff_libs_private_list "${JBIG_LIBRARY}") + endif() + if(LERC_SUPPORT) +@@ -141,11 +141,11 @@ if(LZMA_SUPPORT) + string(APPEND tiff_requires_private " liblzma") + endif() + if(ZSTD_SUPPORT) +- target_link_libraries(tiff PRIVATE ZSTD::ZSTD) ++ target_link_libraries(tiff PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + string(APPEND tiff_requires_private " libzstd") + endif() + if(WEBP_SUPPORT) +- target_link_libraries(tiff PRIVATE WebP::WebP) ++ target_link_libraries(tiff PRIVATE WebP::webp) + string(APPEND tiff_requires_private " libwebp") + endif() + target_link_libraries(tiff PRIVATE CMath::CMath) diff --git a/recipes/libtiff/all/test_package/CMakeLists.txt b/recipes/libtiff/all/test_package/CMakeLists.txt index 9a46669c1de08..cd389da928806 100644 --- a/recipes/libtiff/all/test_package/CMakeLists.txt +++ b/recipes/libtiff/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(TIFF REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} TIFF::TIFF) +target_link_libraries(${PROJECT_NAME} PRIVATE TIFF::TIFF) diff --git a/recipes/libtiff/all/test_package/conanfile.py b/recipes/libtiff/all/test_package/conanfile.py index 1d0bdd3779793..0a6bc68712d90 100644 --- a/recipes/libtiff/all/test_package/conanfile.py +++ b/recipes/libtiff/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libtiff/all/test_package/test_package.c b/recipes/libtiff/all/test_package/test_package.c index 28fc3dc1b9fba..0b73b99d432d5 100644 --- a/recipes/libtiff/all/test_package/test_package.c +++ b/recipes/libtiff/all/test_package/test_package.c @@ -1,6 +1,8 @@ -#include "tiffio.h" +#include + int main() { TIFF* tif = TIFFOpen("foo.tif", "w"); TIFFClose(tif); + return 0; } diff --git a/recipes/libtiff/all/test_v1_package/CMakeLists.txt b/recipes/libtiff/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libtiff/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libtiff/all/test_v1_package/conanfile.py b/recipes/libtiff/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/libtiff/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libtiff/config.yml b/recipes/libtiff/config.yml index ec2cbd362f054..0ca17e7b3017c 100644 --- a/recipes/libtiff/config.yml +++ b/recipes/libtiff/config.yml @@ -1,4 +1,8 @@ versions: + "4.4.0": + folder: all + "4.3.0": + folder: all "4.2.0": folder: all "4.1.0": diff --git a/recipes/libtins/all/CMakeLists.txt b/recipes/libtins/all/CMakeLists.txt index 887cdc7b32cf2..61f3d3b039e2b 100644 --- a/recipes/libtins/all/CMakeLists.txt +++ b/recipes/libtins/all/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 2.8.1) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory("source_subfolder") diff --git a/recipes/libtins/all/conandata.yml b/recipes/libtins/all/conandata.yml index dc85c81dc6606..d565c818eeabe 100644 --- a/recipes/libtins/all/conandata.yml +++ b/recipes/libtins/all/conandata.yml @@ -1,7 +1,10 @@ sources: - "4.2": - sha256: a9fed73e13f06b06a4857d342bb30815fa8c359d00bd69547e567eecbbb4c3a1 - url: https://github.com/mfontanini/libtins/archive/v4.2.tar.gz + "4.4": + url: "https://github.com/mfontanini/libtins/archive/v4.4.tar.gz" + sha256: "ff0121b4ec070407e29720c801b7e1a972042300d37560a62c57abadc9635634" "4.3": - sha256: c70bce5a41a27258bf0e3ad535d8238fb747d909a4b87ea14620f25dd65828fd - url: https://github.com/mfontanini/libtins/archive/v4.3.tar.gz + url: "https://github.com/mfontanini/libtins/archive/v4.3.tar.gz" + sha256: "c70bce5a41a27258bf0e3ad535d8238fb747d909a4b87ea14620f25dd65828fd" + "4.2": + url: "https://github.com/mfontanini/libtins/archive/v4.2.tar.gz" + sha256: "a9fed73e13f06b06a4857d342bb30815fa8c359d00bd69547e567eecbbb4c3a1" diff --git a/recipes/libtins/all/conanfile.py b/recipes/libtins/all/conanfile.py index fe86640d18532..27984b1647f64 100644 --- a/recipes/libtins/all/conanfile.py +++ b/recipes/libtins/all/conanfile.py @@ -1,5 +1,8 @@ from conans import tools, CMake, ConanFile import os +import textwrap + +required_conan_version = ">=1.43.0" class LibTinsConan(ConanFile): @@ -9,8 +12,7 @@ class LibTinsConan(ConanFile): description = "High-level, multiplatform C++ network packet sniffing and crafting library." license = "BSD-2-Clause" topics = ("pcap", "packets", "network", "packet-analyser", "packet-parsing", "libpcap", "sniffing") - exports_sources = ["CMakeLists.txt"] - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -26,6 +28,9 @@ class LibTinsConan(ConanFile): "with_wpa2": True, "with_dot11": True, } + + exports_sources = ["CMakeLists.txt"] + generators = "cmake", "cmake_find_package" _cmake = None @property @@ -40,21 +45,29 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - def requirements(self): - self.requires("libpcap/1.10.0") - if self.options.with_ack_tracker: - self.requires("boost/1.75.0") - if self.options.with_wpa2: - self.requires("openssl/1.1.1j") - def configure(self): if self.options.shared: del self.options.fPIC + def requirements(self): + self.requires("libpcap/1.10.1") + if self.options.with_ack_tracker: + self.requires("boost/1.79.0") + if self.options.with_wpa2: + self.requires("openssl/1.1.1q") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + # Use Findlibpcap.cmake from cmake_find_package + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + "FIND_PACKAGE(PCAP REQUIRED)", + "find_package(libpcap REQUIRED)") + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + "${PCAP_LIBRARY}", + "libpcap::libpcap") def _configure_cmake(self): if self._cmake: @@ -73,6 +86,7 @@ def _configure_cmake(self): return self._cmake def build(self): + self._patch_sources() cmake = self._configure_cmake() cmake.build() @@ -80,14 +94,41 @@ def package(self): self.copy(os.path.join(self._source_subfolder, "LICENSE"), dst="licenses") cmake = self._configure_cmake() cmake.install() + tools.rmdir(os.path.join(self.package_folder, "CMake")) tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"libtins": "libtins::libtins"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + def package_info(self): - # FIXME: official CMake imported target is not namespaced - self.cpp_info.names["cmake_find_package"] = "libtins" - self.cpp_info.names["cmake_find_package_multi"] = "libtins" - self.cpp_info.names["pkg_config"] = "libtins" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "libtins") + self.cpp_info.set_property("cmake_target_name", "libtins") + self.cpp_info.set_property("pkg_config_name", "libtins") + self.cpp_info.libs = ["tins"] if self.settings.os == "Windows" and not self.options.shared: self.cpp_info.defines.append("TINS_STATIC") + self.cpp_info.system_libs.extend(["ws2_32", "iphlpapi"]) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/libtins/all/test_package/CMakeLists.txt b/recipes/libtins/all/test_package/CMakeLists.txt index f1b77a1b4487a..e785b2b7bd437 100644 --- a/recipes/libtins/all/test_package/CMakeLists.txt +++ b/recipes/libtins/all/test_package/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(libtins REQUIRED CONFIG) add_executable(test_package test_package.cpp) -target_link_libraries(test_package ${CONAN_LIBS}) +target_link_libraries(test_package libtins) diff --git a/recipes/libtins/all/test_package/conanfile.py b/recipes/libtins/all/test_package/conanfile.py index 5849d14808adb..a4f1e01b10ec3 100644 --- a/recipes/libtins/all/test_package/conanfile.py +++ b/recipes/libtins/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libtins/config.yml b/recipes/libtins/config.yml index c12e281610e25..ce55c187fafe1 100644 --- a/recipes/libtins/config.yml +++ b/recipes/libtins/config.yml @@ -1,5 +1,7 @@ versions: - "4.2": + "4.4": folder: all "4.3": folder: all + "4.2": + folder: all diff --git a/recipes/libtommath/all/conanfile.py b/recipes/libtommath/all/conanfile.py index d7e6a0cabc383..6bdf6dd129d98 100644 --- a/recipes/libtommath/all/conanfile.py +++ b/recipes/libtommath/all/conanfile.py @@ -1,12 +1,13 @@ from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.33.0" + class LibTomMathConan(ConanFile): name = "libtommath" description = "LibTomMath is a free open source portable number theoretic multiple-precision integer library written entirely in C." - topics = "conan", "libtommath", "math", "multiple", "precision" + topics = "libtommath", "math", "multiple", "precision" license = "Unlicense" homepage = "https://www.libtom.net/" url = "https://github.com/conan-io/conan-center-index" @@ -19,12 +20,17 @@ class LibTomMathConan(ConanFile): "shared": False, "fPIC": True, } - exports_sources = "patches/**" + + exports_sources = "patches/*" @property def _source_subfolder(self): return "source_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -36,14 +42,14 @@ def configure(self): del self.settings.compiler.cppstd def build_requirements(self): - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio": - self.build_requires("make/4.2.1") + if self._settings_build.os == "Windows" and self.settings.compiler != "Visual Studio": + self.build_requires("make/4.3") if self.settings.compiler != "Visual Studio" and self.settings.os != "Windows" and self.options.shared: self.build_requires("libtool/2.4.6") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libtommath-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _run_makefile(self, target=None): target = target or "" @@ -51,6 +57,9 @@ def _run_makefile(self, target=None): autotools.libs = [] if self.settings.os == "Windows" and self.settings.compiler != "Visual Studio": autotools.link_flags.append("-lcrypt32") + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # FIXME: should be handled by helper + autotools.link_flags.append("-arch arm64") args = autotools.vars args.update({ "PREFIX": self.package_folder, @@ -73,7 +82,7 @@ def _run_makefile(self, target=None): target = "tommath.dll" else: target = "tommath.lib" - with tools.vcvars(self.settings): + with tools.vcvars(self): self.run("nmake -f makefile.msvc {} {}".format( target, arg_str, @@ -114,18 +123,15 @@ def package(self): else: self._run_makefile("install") - # FIXME: use tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") - la = os.path.join(self.package_folder, "lib", "libtommath.la") - if os.path.isfile(la): - os.unlink(la) - + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + if self.settings.compiler == "Visual Studio" and self.options.shared: + os.rename(os.path.join(self.package_folder, "lib", "tommath.dll.lib"), + os.path.join(self.package_folder, "lib", "tommath.lib")) + def package_info(self): - suffix = "" - if self.settings.os == "Windows": - suffix = ".dll" if self.options.shared else "" - self.cpp_info.libs = ["tommath" + suffix] + self.cpp_info.libs = ["tommath"] if not self.options.shared: if self.settings.os == "Windows": self.cpp_info.system_libs = ["advapi32", "crypt32"] diff --git a/recipes/libtommath/all/test_package/conanfile.py b/recipes/libtommath/all/test_package/conanfile.py index 4f63db8f060a7..9e09e219fdcb3 100644 --- a/recipes/libtommath/all/test_package/conanfile.py +++ b/recipes/libtommath/all/test_package/conanfile.py @@ -7,15 +7,14 @@ class TestPackageConan(ConanFile): generators = "cmake", "pkg_config" def build_requirements(self): - self.build_requires("pkgconf/1.7.3") + self.build_requires("pkgconf/1.7.4") def build(self): cmake = CMake(self) - cmake.verbose = True cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libtool/all/conandata.yml b/recipes/libtool/all/conandata.yml index 9dc22f5723733..6ebc362b36f40 100644 --- a/recipes/libtool/all/conandata.yml +++ b/recipes/libtool/all/conandata.yml @@ -1,10 +1,16 @@ sources: + "2.4.7": + url: "https://ftp.gnu.org/gnu/libtool/libtool-2.4.7.tar.gz" + sha256: "04e96c2404ea70c590c546eba4202a4e12722c640016c12b9b2f1ce3d481e9a8" "2.4.6": - sha256: "e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3" url: "https://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.gz" + sha256: "e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3" patches: + "2.4.7": + - base_path: "source_subfolder" + patch_file: "patches/2.4.7-0001-libtool-relocatable.patch" "2.4.6": - base_path: "source_subfolder" - patch_file: "patches/0001-libtool-relocatable.patch" + patch_file: "patches/2.4.6-0001-libtool-relocatable.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-libtool-fix-type-libtool.patch" + patch_file: "patches/2.4.6-0002-libtool-fix-type-libtool.patch" diff --git a/recipes/libtool/all/conanfile.py b/recipes/libtool/all/conanfile.py index 9f0ace45a1583..f7fc46aed1514 100644 --- a/recipes/libtool/all/conanfile.py +++ b/recipes/libtool/all/conanfile.py @@ -1,8 +1,9 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +from conans.errors import ConanException from contextlib import contextmanager import os import re -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanException +import shutil required_conan_version = ">=1.33.0" @@ -14,7 +15,6 @@ class LibtoolConan(ConanFile): description = "GNU libtool is a generic library support script. " topics = ("conan", "libtool", "configure", "library", "shared", "static") license = ("GPL-2.0-or-later", "GPL-3.0-or-later") - exports_sources = "patches/**" settings = "os", "arch", "compiler", "build_type" options = { @@ -25,52 +25,66 @@ class LibtoolConan(ConanFile): "shared": False, "fPIC": True, } + + exports_sources = "patches/**" _autotools = None @property def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") + return "source_subfolder" + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd def configure(self): if self.options.shared: del self.options.fPIC - - def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd def requirements(self): - self.requires("automake/1.16.3") + self.requires("automake/1.16.5") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + if hasattr(self, "settings_build"): + self.build_requires("automake/1.16.5") + self.build_requires("gnu-config/cci.20210814") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) @contextmanager def _build_context(self): - with tools.environment_append(self._libtool_relocatable_env): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - with tools.environment_append({"CC": "cl -nologo", "CXX": "cl -nologo",}): - yield - else: - yield + with tools.run_environment(self): + with tools.environment_append(self._libtool_relocatable_env): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self.settings): + with tools.environment_append({"CC": "cl -nologo", "CXX": "cl -nologo",}): + yield + else: + yield @property def _datarootdir(self): - return os.path.join(self.package_folder, "bin", "share") + return os.path.join(self.package_folder, "res") def _configure_autotools(self): if self._autotools: return self._autotools self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - if self.settings.compiler == "Visual Studio": + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) >= "12": self._autotools.flags.append("-FS") conf_args = [ "--datarootdir={}".format(tools.unix_path(self._datarootdir)), @@ -82,9 +96,17 @@ def _configure_autotools(self): self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) return self._autotools + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def _patch_sources(self): for patch in self.conan_data["patches"][self.version]: tools.patch(**patch) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "build-aux", "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "build-aux", "config.guess")) def build(self): self._patch_sources() @@ -169,7 +191,7 @@ def package(self): os.path.join(self.package_folder, "lib", "ltdl.lib")) # allow libtool to link static libs into shared for more platforms - libtool_m4 = os.path.join(self.package_folder, "bin", "share", "aclocal", "libtool.m4") + libtool_m4 = os.path.join(self._datarootdir, "aclocal", "libtool.m4") method_pass_all = "lt_cv_deplibs_check_method=pass_all" tools.replace_in_file(libtool_m4, "lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'", @@ -212,7 +234,7 @@ def package_info(self): self.output.info("Setting {} environment variable to {}".format(key, value)) setattr(self.env_info, key, value) - libtool_aclocal = tools.unix_path(os.path.join(self.package_folder, "bin", "share", "aclocal")) + libtool_aclocal = tools.unix_path(os.path.join(self._datarootdir, "aclocal")) self.output.info("Appending ACLOCAL_PATH env: {}".format(libtool_aclocal)) self.env_info.ACLOCAL_PATH.append(libtool_aclocal) self.output.info("Appending AUTOMAKE_CONAN_INCLUDES environment variable: {}".format(libtool_aclocal)) diff --git a/recipes/libtool/all/patches/0001-libtool-relocatable.patch b/recipes/libtool/all/patches/2.4.6-0001-libtool-relocatable.patch similarity index 100% rename from recipes/libtool/all/patches/0001-libtool-relocatable.patch rename to recipes/libtool/all/patches/2.4.6-0001-libtool-relocatable.patch diff --git a/recipes/libtool/all/patches/0002-libtool-fix-type-libtool.patch b/recipes/libtool/all/patches/2.4.6-0002-libtool-fix-type-libtool.patch similarity index 100% rename from recipes/libtool/all/patches/0002-libtool-fix-type-libtool.patch rename to recipes/libtool/all/patches/2.4.6-0002-libtool-fix-type-libtool.patch diff --git a/recipes/libtool/all/patches/2.4.7-0001-libtool-relocatable.patch b/recipes/libtool/all/patches/2.4.7-0001-libtool-relocatable.patch new file mode 100644 index 0000000000000..09ace4c665841 --- /dev/null +++ b/recipes/libtool/all/patches/2.4.7-0001-libtool-relocatable.patch @@ -0,0 +1,39 @@ +- Do not embed build-machine specific paths in the generated sources. +- Do not regenerate manuals (help2man might not be available on build system) + +--- libtoolize.in ++++ libtoolize.in +@@ -1903,11 +1903,11 @@ + pkgmacro_files="@pkgmacro_files@" + + # Locations for important files: +- prefix="@prefix@" +- datadir="@datadir@" +- pkgauxdir="@pkgauxdir@" +- pkgltdldir="@pkgdatadir@" +- aclocaldir="@aclocaldir@" ++ prefix="$LIBTOOL_PREFIX" ++ datadir="$LIBTOOL_DATADIR" ++ pkgauxdir="$LIBTOOL_PKGAUXDIR" ++ pkgltdldir="$LIBTOOL_PKGLTDLDIR" ++ aclocaldir="$LIBTOOL_ACLOCALDIR" + + # Allow the user to override the master libtoolize repository: + if test -n "$_lt_pkgdatadir"; then +--- Makefile.in ++++ Makefile.in +@@ -2423,10 +2423,10 @@ + # files created in the build tree, so instead we regenerate the + # manual pages if the sources for the build-tree files we want to + # run have changed. +-$(libtool_1): $(ltmain_sh) +- $(AM_V_GEN)$(update_mans) --help-option=--help-all libtool +-$(libtoolize_1): $(libtoolize_in) +- $(AM_V_GEN)$(update_mans) libtoolize ++#$(libtool_1): $(ltmain_sh) ++# $(AM_V_GEN)$(update_mans) --help-option=--help-all libtool ++#$(libtoolize_1): $(libtoolize_in) ++# $(AM_V_GEN)$(update_mans) libtoolize + + install-data-local: $(lt_Makefile_in) install-scripts-local + @$(NORMAL_INSTALL) diff --git a/recipes/libtool/all/test_package/conanfile.py b/recipes/libtool/all/test_package/conanfile.py index 59b0dfac528bd..f71788ff49054 100644 --- a/recipes/libtool/all/test_package/conanfile.py +++ b/recipes/libtool/all/test_package/conanfile.py @@ -8,10 +8,20 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "cmake" + test_type = "explicit" + short_paths = True + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def requirements(self): + self.requires(self.tested_reference_str) def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + self.build_requires(self.tested_reference_str) + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") @contextmanager def _build_context(self): @@ -58,7 +68,7 @@ def _test_autotools(self): assert os.path.isfile(os.path.join(self._package_folder, "include", "lib.h")) assert os.path.isdir(os.path.join(self._package_folder, "lib")) - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run(os.path.join(self._package_folder, "bin", "test_package"), run_environment=True) def _build_ltdl(self): @@ -71,11 +81,12 @@ def _test_ltdl(self): """ Test library using ltdl library""" lib_suffix = { "Linux": "so", + "FreeBSD": "so", "Macos": "dylib", "Windows": "dll", }[str(self.settings.os)] - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") libdir = "bin" if self.settings.os == "Windows" else "lib" lib_path = os.path.join(libdir, "liba.{}".format(lib_suffix)) @@ -85,13 +96,12 @@ def _build_static_lib_in_shared(self): """ Build shared library using libtool (while linking to a static library) """ # Copy static-in-shared directory to build folder - autotools_folder = os.path.join(self.build_folder, "static-in-shared") - shutil.copytree(os.path.join(self.source_folder, "static-in-shared"), autotools_folder) + autotools_folder = os.path.join(self.build_folder, "sis") + shutil.copytree(os.path.join(self.source_folder, "sis"), autotools_folder) install_prefix = os.path.join(autotools_folder, "prefix") # Build static library using CMake - cmake_build_folder = os.path.join(autotools_folder, "cmake_build") cmake = CMake(self) cmake.definitions["CMAKE_INSTALL_PREFIX"] = install_prefix cmake.configure(source_folder=autotools_folder, build_folder=os.path.join(autotools_folder, "cmake_build")) @@ -118,7 +128,7 @@ def _build_static_lib_in_shared(self): def _test_static_lib_in_shared(self): """ Test existence of shared library """ - install_prefix = os.path.join(self.build_folder, "static-in-shared", "prefix") + install_prefix = os.path.join(self.build_folder, "sis", "prefix") with tools.chdir(install_prefix): if self.settings.os == "Windows": @@ -129,11 +139,13 @@ def _test_static_lib_in_shared(self): assert len(list(glob.glob(os.path.join("lib", "*.so")))) > 0 def build(self): - self._build_autotools() self._build_ltdl() - self._build_static_lib_in_shared() + if not tools.cross_building(self): + self._build_autotools() + self._build_static_lib_in_shared() def test(self): - self._test_autotools() self._test_ltdl() - self._test_static_lib_in_shared() + if not tools.cross_building(self): + self._test_autotools() + self._test_static_lib_in_shared() diff --git a/recipes/libtool/all/test_package/static-in-shared/CMakeLists.txt b/recipes/libtool/all/test_package/sis/CMakeLists.txt similarity index 100% rename from recipes/libtool/all/test_package/static-in-shared/CMakeLists.txt rename to recipes/libtool/all/test_package/sis/CMakeLists.txt diff --git a/recipes/libtool/all/test_package/static-in-shared/Makefile.am b/recipes/libtool/all/test_package/sis/Makefile.am similarity index 100% rename from recipes/libtool/all/test_package/static-in-shared/Makefile.am rename to recipes/libtool/all/test_package/sis/Makefile.am diff --git a/recipes/libtool/all/test_package/static-in-shared/configure.ac b/recipes/libtool/all/test_package/sis/configure.ac similarity index 100% rename from recipes/libtool/all/test_package/static-in-shared/configure.ac rename to recipes/libtool/all/test_package/sis/configure.ac diff --git a/recipes/libtool/all/test_package/static-in-shared/shared.sym b/recipes/libtool/all/test_package/sis/shared.sym similarity index 100% rename from recipes/libtool/all/test_package/static-in-shared/shared.sym rename to recipes/libtool/all/test_package/sis/shared.sym diff --git a/recipes/libtool/all/test_package/static-in-shared/shared_lib.c b/recipes/libtool/all/test_package/sis/shared_lib.c similarity index 100% rename from recipes/libtool/all/test_package/static-in-shared/shared_lib.c rename to recipes/libtool/all/test_package/sis/shared_lib.c diff --git a/recipes/libtool/all/test_package/static-in-shared/static_lib.c b/recipes/libtool/all/test_package/sis/static_lib.c similarity index 100% rename from recipes/libtool/all/test_package/static-in-shared/static_lib.c rename to recipes/libtool/all/test_package/sis/static_lib.c diff --git a/recipes/libtool/config.yml b/recipes/libtool/config.yml index 00552f3ce0ab4..f33083be4e783 100644 --- a/recipes/libtool/config.yml +++ b/recipes/libtool/config.yml @@ -1,3 +1,5 @@ versions: + "2.4.7": + folder: all "2.4.6": folder: all diff --git a/recipes/libtorrent/all/CMakeLists.txt b/recipes/libtorrent/all/CMakeLists.txt index a69305eb3971f..b71c882d9d33f 100644 --- a/recipes/libtorrent/all/CMakeLists.txt +++ b/recipes/libtorrent/all/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory(source_subfolder) diff --git a/recipes/libtorrent/all/conanfile.py b/recipes/libtorrent/all/conanfile.py index 44b9180c3fc5d..59a5d38214efb 100644 --- a/recipes/libtorrent/all/conanfile.py +++ b/recipes/libtorrent/all/conanfile.py @@ -1,17 +1,22 @@ +from conan.tools.microsoft import msvc_runtime_flag from conans import CMake, ConanFile, tools from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.43.0" + class LibtorrentConan(ConanFile): name = "libtorrent" - description = "libtorrent is a feature complete C++ bittorrent implementation focusing on efficiency and scalability" - topics = ("conan", "libtorrent", "p2p", "network", "mesh") + description = ( + "libtorrent is a feature complete C++ bittorrent implementation " + "focusing on efficiency and scalability" + ) + topics = ("libtorrent", "p2p", "network", "mesh") url = "https://github.com/conan-io/conan-center-index" homepage = "http://libtorrent.org" - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake" license = ("BSD-3-clause", "ZLIB", "BSL-1.0") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -40,16 +45,30 @@ class LibtorrentConan(ConanFile): "enable_mutable_torrents": True, } + generators = "cmake" _cmake = None @property def _source_subfolder(self): return "source_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + def _check_compiler_supports_cxx14(self): min_compiler_version = { "Visual Studio": "15", @@ -63,23 +82,24 @@ def _check_compiler_supports_cxx14(self): raise ConanInvalidConfiguration("This compiler (version) does not support c++ 14.") return True, None - def configure(self): - if self.options.shared: - del self.options.fPIC + def validate(self): if tools.Version(self.version) < "2.0": - if self.settings.compiler.cppstd: + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, 11) else: self._check_compiler_supports_cxx14() - if self.settings.compiler.cppstd: + if self.settings.compiler.get_safe("cppstd"): tools.check_min_cppstd(self, 14) def requirements(self): - self.requires("boost/1.74.0") + if tools.Version(self.version) < "2.0.0": + self.requires("boost/1.79.0") + else: + self.requires("boost/1.76.0") if self.options.enable_encryption: - self.requires("openssl/1.1.1h") + self.requires("openssl/1.1.1q") if self.options.enable_iconv: - self.requires("libiconv/1.16") + self.requires("libiconv/1.17") def _validate_dependency_graph(self): if tools.Version(self.deps_cpp_info["boost"].version) < "1.69.0" and \ @@ -87,8 +107,8 @@ def _validate_dependency_graph(self): raise ConanInvalidConfiguration("libtorrent requires boost with system, which is non-header only in boost < 1.69.0") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libtorrent-rasterbar-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -107,8 +127,8 @@ def _configure_cmake(self): self._cmake.definitions["build_tools"] = False self._cmake.definitions["python-bindings"] = False self._cmake.definitions["python-bindings"] = False - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["static_runtime"] = "MT" in str(self.settings.compiler.runtime) + if self._is_msvc: + self._cmake.definitions["static_runtime"] = "MT" in msvc_runtime_flag(self) self._cmake.configure() return self._cmake @@ -130,13 +150,6 @@ def _patch_sources(self): tools.replace_in_file(os.path.join(self._source_subfolder, "include", "libtorrent", "file_storage.hpp"), "file_entry& operator=(file_entry&&) & noexcept = default;", "file_entry& operator=(file_entry&&) & = default;") - else: - min_compiler_version = { - "gcc": "5", - }.get(str(self.settings.compiler)) - if min_compiler_version: - if tools.Version(self.settings.compiler.version) < min_compiler_version: - raise ConanInvalidConfiguration("This compiler cannot build libtorrent due to missing features") def build(self): self._validate_dependency_graph() @@ -154,11 +167,11 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["pkg_config"] = "libtorrent-rasterbar" - self.cpp_info.names["cmake_find_package"] = "LibtorrentRasterbar" - self.cpp_info.names["cmake_find_package_multi"] = "LibtorrentRasterbar" - self.cpp_info.components["libtorrent-rasterbar"].names["cmake_find_package"] = "torrent-rasterbar" - self.cpp_info.components["libtorrent-rasterbar"].names["cmake_find_package_multi"] = "torrent-rasterbar" + self.cpp_info.set_property("cmake_file_name", "LibtorrentRasterbar") + self.cpp_info.set_property("cmake_target_name", "LibtorrentRasterbar::torrent-rasterbar") + self.cpp_info.set_property("pkg_config_name", "libtorrent-rasterbar") + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed self.cpp_info.components["libtorrent-rasterbar"].includedirs = ["include", os.path.join("include", "libtorrent")] self.cpp_info.components["libtorrent-rasterbar"].libs = ["torrent-rasterbar"] @@ -168,7 +181,7 @@ def package_info(self): if self.options.enable_iconv: self.cpp_info.components["libtorrent-rasterbar"].requires.append("libiconv::libiconv") - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libtorrent-rasterbar"].system_libs = ["dl", "pthread"] elif self.settings.os == "Windows": self.cpp_info.components["libtorrent-rasterbar"].system_libs = ["wsock32", "ws2_32", "iphlpapi", "dbghelp"] @@ -185,3 +198,11 @@ def package_info(self): self.cpp_info.components["libtorrent-rasterbar"].defines.append("TORRENT_USE_ICONV") if not self.options.enable_dht: self.cpp_info.components["libtorrent-rasterbar"].defines.append("TORRENT_DISABLE_DHT") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "LibtorrentRasterbar" + self.cpp_info.names["cmake_find_package_multi"] = "LibtorrentRasterbar" + self.cpp_info.components["libtorrent-rasterbar"].names["cmake_find_package"] = "torrent-rasterbar" + self.cpp_info.components["libtorrent-rasterbar"].names["cmake_find_package_multi"] = "torrent-rasterbar" + self.cpp_info.components["libtorrent-rasterbar"].set_property("cmake_target_name", "LibtorrentRasterbar::torrent-rasterbar") + self.cpp_info.components["libtorrent-rasterbar"].set_property("pkg_config_name", "libtorrent-rasterbar") diff --git a/recipes/libtorrent/all/test_package/CMakeLists.txt b/recipes/libtorrent/all/test_package/CMakeLists.txt index 4260595d85591..3b0214fde3a62 100644 --- a/recipes/libtorrent/all/test_package/CMakeLists.txt +++ b/recipes/libtorrent/all/test_package/CMakeLists.txt @@ -8,7 +8,7 @@ if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) endif() -find_package(LibtorrentRasterbar REQUIRED) +find_package(LibtorrentRasterbar REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} LibtorrentRasterbar::torrent-rasterbar) diff --git a/recipes/libtorrent/all/test_package/conanfile.py b/recipes/libtorrent/all/test_package/conanfile.py index 1c4f75cb64811..389562b941ae2 100644 --- a/recipes/libtorrent/all/test_package/conanfile.py +++ b/recipes/libtorrent/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,7 +12,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") # from https://en.wikipedia.org/wiki/Magnet_URI_scheme magnet_url = "magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a" diff --git a/recipes/kuba-zip/all/CMakeLists.txt b/recipes/libucl/all/CMakeLists.txt similarity index 100% rename from recipes/kuba-zip/all/CMakeLists.txt rename to recipes/libucl/all/CMakeLists.txt diff --git a/recipes/libucl/all/conandata.yml b/recipes/libucl/all/conandata.yml new file mode 100644 index 0000000000000..b1df39720e7e0 --- /dev/null +++ b/recipes/libucl/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "0.8.1": + url: "https://github.com/vstakhov/libucl/archive/refs/tags/0.8.1.tar.gz" + sha256: "a6397e179672f0e8171a0f9a2cfc37e01432b357fd748b13f4394436689d24ef" +patches: + "0.8.1": + - patch_file: "patches/0001-0.8.1-shared-win32.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-0.8.1-cmake-add-install+use-find_package.patch" + base_path: "source_subfolder" + - patch_file: "patches/0003-no-strings-h.patch" + base_path: "source_subfolder" diff --git a/recipes/libucl/all/conanfile.py b/recipes/libucl/all/conanfile.py new file mode 100644 index 0000000000000..24d2f3383d0bb --- /dev/null +++ b/recipes/libucl/all/conanfile.py @@ -0,0 +1,87 @@ +from conans import CMake, ConanFile, tools +import functools + +required_conan_version = ">=1.33.0" + + +class LibuclConan(ConanFile): + name = "libucl" + description = "Universal configuration library parser" + license = "BSD-2-Clause" + homepage = "https://github.com/vstakhov/libucl" + url = "https://github.com/conan-io/conan-center-index" + topics = ("universal", "configuration", "language", "parser", "ucl") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "enable_url_include": [True, False], + "enable_url_sign": [True, False], + "with_lua": [False, "lua", "luajit"], + } + default_options = { + "shared": False, + "fPIC": True, + "enable_url_include": False, + "enable_url_sign": False, + "with_lua": False, + } + + generators = "cmake", "cmake_find_package_multi" + exports_sources = "CMakeLists.txt", "patches/*" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + if self.options.enable_url_include: + self.requires("libcurl/7.84.0") + if self.options.enable_url_sign: + self.requires("openssl/1.1.1q") + if self.options.with_lua == "lua": + self.requires("lua/5.4.4") + elif self.options.with_lua == "luajit": + self.requires("luajit/2.0.5") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + on_off = lambda v: "ON" if v else "OFF" + cmake.definitions["ENABLE_URL_INCLUDE"] = on_off(self.options.enable_url_include) + cmake.definitions["ENABLE_URL_SIGN"] = on_off(self.options.enable_url_sign) + cmake.definitions["ENABLE_LUA"] = on_off(self.options.with_lua == "lua") + cmake.definitions["ENABLE_LUAJIT"] = on_off(self.options.with_lua == "luajit") + cmake.configure() + return cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses", keep_path=False) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["ucl"] + self.cpp_info.names["pkg_config"] = "libucl" + if self.settings.os == "Windows" and not self.options.shared: + self.cpp_info.defines.append("UCL_STATIC") diff --git a/recipes/libucl/all/patches/0001-0.8.1-shared-win32.patch b/recipes/libucl/all/patches/0001-0.8.1-shared-win32.patch new file mode 100644 index 0000000000000..4308bb8589a0d --- /dev/null +++ b/recipes/libucl/all/patches/0001-0.8.1-shared-win32.patch @@ -0,0 +1,16 @@ +--- include/ucl.h ++++ include/ucl.h +@@ -33,7 +33,12 @@ + #include +- + #ifdef _WIN32 ++#ifdef ucl_EXPORTS + # define UCL_EXTERN __declspec(dllexport) ++#elif !defined(UCL_STATIC) ++# define UCL_EXTERN __declspec(dllimport) + #else + # define UCL_EXTERN ++#endif ++#else ++# define UCL_EXTERN + #endif diff --git a/recipes/libucl/all/patches/0002-0.8.1-cmake-add-install+use-find_package.patch b/recipes/libucl/all/patches/0002-0.8.1-cmake-add-install+use-find_package.patch new file mode 100644 index 0000000000000..29415e0d82768 --- /dev/null +++ b/recipes/libucl/all/patches/0002-0.8.1-cmake-add-install+use-find_package.patch @@ -0,0 +1,147 @@ +- Fixes dll/static cmake builds +- Fixes libcurl +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -4,13 +4,13 @@ + SET(LIBUCL_VERSION_MAJOR 0) + SET(LIBUCL_VERSION_MINOR 5) + SET(LIBUCL_VERSION_PATCH 0) +- +-SET(LIBUCL_VERSION +- "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}") ++SET(LIBUCL_VERSION "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}") +- + INCLUDE(CheckCCompilerFlag) +-INCLUDE(FindOpenSSL) +- ++IF(ENABLE_URL_SIGN) ++ FIND_PACKAGE(OpenSSL REQUIRED) ++ SET(HAVE_OPENSSL 1) ++ ADD_DEFINITIONS(-DHAVE_OPENSSL) ++ENDIF(ENABLE_URL_SIGN) + OPTION(ENABLE_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF) + OPTION(ENABLE_URL_SIGN "Enable signatures check in ucl includes (requires openssl) [default: OFF]" OFF) + OPTION(BUILD_SHARED_LIBS "Build Shared Libraries [default: OFF]" OFF) +@@ -131,31 +131,31 @@ + LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) + ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + +-IF(ENABLE_URL_INCLUDE MATCHES "ON") +- FIND_LIBRARY(LIBFETCH_LIBRARY NAMES fetch PATHS PATH_SUFFIXES lib64 lib +- PATHS +- ~/Library/Frameworks +- /Library/Frameworks +- /usr/local +- /usr +- /sw +- /opt/local +- /opt/csw +- /opt +- DOC "Path where the libfetch library can be found") +- IF(LIBFETCH_LIBRARY) +- FIND_FILE(HAVE_FETCH_H NAMES fetch.h PATHS /usr/include +- /opt/include +- /usr/local/include +- DOC "Path to libfetch header") +- ELSE(LIBFETCH_LIBRARY) +- # Try to find libcurl +- ProcessPackage(CURL libcurl) +- IF(NOT CURL_FOUND) +- MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration") +- ENDIF(NOT CURL_FOUND) +- ENDIF(LIBFETCH_LIBRARY) +-ENDIF(ENABLE_URL_INCLUDE MATCHES "ON") ++IF(ENABLE_URL_INCLUDE) ++ FIND_PACKAGE(CURL REQUIRED) ++ ADD_DEFINITIONS(-DCURL_FOUND) ++ SET(CURL_LIBRARIES CURL::CURL) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ENDIF() + + SET(CMAKE_C_WARN_FLAGS "") + CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL) +@@ -214,4 +214,4 @@ + ENDIF (BUILD_SHARED_LIBS) + ADD_LIBRARY(ucl ${LIB_TYPE} ${UCLSRC}) + SET_TARGET_PROPERTIES(ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR}) +- ++INSTALL(TARGETS ucl RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +@@ -218,29 +218,29 @@ +-IF(ENABLE_LUA MATCHES "ON") ++IF(ENABLE_LUA OR ENABLE_LUAJIT) +- IF(ENABLE_LUAJIT MATCHES "ON") +- FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}") +- IF(NOT LUA_FOUND) +- MESSAGE(FATAL_ERROR "Lua not found, lua support is required") +- ELSE(NOT LUA_FOUND) +- INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}") +- ENDIF(NOT LUA_FOUND) +- ELSE(ENABLE_LUAJIT MATCHES "ON") +- FindLua(VERSION_MAJOR "5" VERSION_MINOR "2" ROOT "${LUA_ROOT}") +- IF(NOT LUA_FOUND) +- FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}") +- ENDIF(NOT LUA_FOUND) +- IF(NOT LUA_FOUND) +- MESSAGE(FATAL_ERROR "Lua not found, lua support is required") +- ELSE(NOT LUA_FOUND) +- INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}") +- ENDIF(NOT LUA_FOUND) +- ENDIF(ENABLE_LUAJIT MATCHES "ON") + SET(UCL_LUA_SRC lua/lua_ucl.c) + ADD_LIBRARY(lua-ucl ${LIB_TYPE} ${UCL_LUA_SRC}) +- IF(ENABLE_LUAJIT MATCHES "ON") +- TARGET_LINK_LIBRARIES(lua-ucl "${LUAJIT_LIBRARY}") +- ELSE(ENABLE_LUAJIT MATCHES "ON") +- TARGET_LINK_LIBRARIES(lua-ucl "${LUA_LIBRARY}") +- ENDIF(ENABLE_LUAJIT MATCHES "ON") + TARGET_LINK_LIBRARIES(lua-ucl ucl) + SET_TARGET_PROPERTIES(lua-ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR}) +-ENDIF() ++ ++ ++ IF(ENABLE_LUA) ++ FIND_PACKAGE(lua REQUIRED CONFIG) ++ TARGET_LINK_LIBRARIES(lua-ucl lua::lua) ++ ++ ELSEIF(ENABLE_LUAJIT) ++ FIND_PACKAGE(luajit REQUIRED CONFIG) ++ TARGET_LINK_LIBRARIES(lua-ucl luajit::luajit) ++ ENDIF() ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ INSTALL(TARGETS lua-ucl RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) ++ INSTALL(FILES include/lua_ucl.h DESTINATION include) ++ENDIF() +@@ -257,3 +257,4 @@ + TARGET_LINK_LIBRARIES(ucl ${OPENSSL_LIBRARIES}) + ENDIF(OPENSSL_FOUND) + ENDIF(ENABLE_URL_SIGN MATCHES "ON") ++INSTALL(FILES include/ucl.h include/ucl++.h DESTINATION include) diff --git a/recipes/libucl/all/patches/0003-no-strings-h.patch b/recipes/libucl/all/patches/0003-no-strings-h.patch new file mode 100644 index 0000000000000..dffd4b0ed1895 --- /dev/null +++ b/recipes/libucl/all/patches/0003-no-strings-h.patch @@ -0,0 +1,11 @@ +--- lua/lua_ucl.c ++++ lua/lua_ucl.c +@@ -28,7 +28,7 @@ + #include "ucl.h" + #include "ucl_internal.h" + #include "lua_ucl.h" +-#include ++#include + + /*** + * @module ucl diff --git a/recipes/libucl/all/test_package/CMakeLists.txt b/recipes/libucl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8d0b348158f02 --- /dev/null +++ b/recipes/libucl/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libucl REQUIRED) + +add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) +target_link_libraries(${CMAKE_PROJECT_NAME} libucl::libucl) +set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CXX_STANDARD 11) diff --git a/recipes/libucl/all/test_package/conanfile.py b/recipes/libucl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..84366eb939ca3 --- /dev/null +++ b/recipes/libucl/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin","test_package") + sample_conf = os.path.join(self.source_folder, "sample.conf") + self.run("{} {}".format(bin_path, sample_conf), run_environment=True) diff --git a/recipes/libucl/all/test_package/sample.conf b/recipes/libucl/all/test_package/sample.conf new file mode 100644 index 0000000000000..762cf3ad052d3 --- /dev/null +++ b/recipes/libucl/all/test_package/sample.conf @@ -0,0 +1,19 @@ +param = value; +section { + param = value; + param1 = value1; + flag = true; + number = 10k; + time = 0.2s; + string = "something"; + subsection { + host = { + host = "hostname"; + port = 900; + } + host = { + host = "hostname"; + port = 901; + } + } +} diff --git a/recipes/libucl/all/test_package/test_package.cpp b/recipes/libucl/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..c36638ce655ec --- /dev/null +++ b/recipes/libucl/all/test_package/test_package.cpp @@ -0,0 +1,34 @@ +#include "ucl++.h" + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + if (argc < 2) { + std::cerr << "Usage: " << argv[0] << " FILE\n"; + return 1; + } + std::string input, err; + + std::ifstream ifs(argv[1]); + input.assign(std::istreambuf_iterator(ifs), std::istreambuf_iterator()); + + auto obj = ucl::Ucl::parse(input, err); + + if (obj) { + std::cout << "input config is:\n"; + std::cout << obj.dump(UCL_EMIT_CONFIG) << std::endl; + std::cout << "======\n"; + + for (const auto &o : obj) { + std::cout << "obj: " << o.dump(UCL_EMIT_CONFIG) << std::endl; + } + } + else { + std::cerr << "error: " << err << std::endl; + return 1; + } + return 0; +} diff --git a/recipes/libucl/config.yml b/recipes/libucl/config.yml new file mode 100644 index 0000000000000..b94f5b45b1bf5 --- /dev/null +++ b/recipes/libucl/config.yml @@ -0,0 +1,3 @@ +versions: + "0.8.1": + folder: all diff --git a/recipes/libudev/all/conanfile.py b/recipes/libudev/all/conanfile.py new file mode 100644 index 0000000000000..bb1bde611d37b --- /dev/null +++ b/recipes/libudev/all/conanfile.py @@ -0,0 +1,65 @@ +from conan import ConanFile +from conan.errors import ConanException, ConanInvalidConfiguration +from conan.tools.system import package_manager +from conans import tools + +required_conan_version = ">=1.47" + + +class LibUDEVConan(ConanFile): + name = "libudev" + version = "system" + description = "API for enumerating and introspecting local devices" + topics = ("udev", "devices", "enumerating") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.freedesktop.org/software/systemd/man/udev.html" + license = "GPL-2.0-or-later", "LGPL-2.1-or-later" + settings = "os", "arch", "compiler", "build_type" + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("libudev is only supported on Linux.") + + def package_id(self): + self.info.header_only() + + def _fill_cppinfo_from_pkgconfig(self, name): + pkg_config = tools.PkgConfig(name) + if not pkg_config.provides: + raise ConanException("libudev development files aren't available, give up") + libs = [lib[2:] for lib in pkg_config.libs_only_l] + lib_dirs = [lib[2:] for lib in pkg_config.libs_only_L] + ldflags = [flag for flag in pkg_config.libs_only_other] + include_dirs = [include[2:] for include in pkg_config.cflags_only_I] + cflags = [flag for flag in pkg_config.cflags_only_other if not flag.startswith("-D")] + defines = [flag[2:] for flag in pkg_config.cflags_only_other if flag.startswith("-D")] + + self.cpp_info.system_libs = libs + self.cpp_info.libdirs = lib_dirs + self.cpp_info.sharedlinkflags = ldflags + self.cpp_info.exelinkflags = ldflags + self.cpp_info.defines = defines + self.cpp_info.includedirs = include_dirs + self.cpp_info.cflags = cflags + self.cpp_info.cxxflags = cflags + + def system_requirements(self): + dnf = package_manager.Dnf(self) + dnf.install(["systemd-devel"], update=True, check=True) + + yum = package_manager.Yum(self) + yum.install(["systemd-devel"], update=True, check=True) + + apt = package_manager.Apt(self) + apt.install(["libudev-dev"], update=True, check=True) + + pacman = package_manager.PacMan(self) + pacman.install(["systemd-libs"], update=True, check=True) + + zypper = package_manager.Zypper(self) + zypper.install(["libudev-devel"], update=True, check=True) + + def package_info(self): + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + self._fill_cppinfo_from_pkgconfig("libudev") diff --git a/recipes/libudev/all/test_package/CMakeLists.txt b/recipes/libudev/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f20128e28a1d5 --- /dev/null +++ b/recipes/libudev/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libudev REQUIRED CONFIG) + + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libudev::libudev) diff --git a/recipes/libudev/all/test_package/conanfile.py b/recipes/libudev/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/libudev/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libudev/all/test_package/test_package.c b/recipes/libudev/all/test_package/test_package.c new file mode 100644 index 0000000000000..05b8913de0a37 --- /dev/null +++ b/recipes/libudev/all/test_package/test_package.c @@ -0,0 +1,25 @@ +#include +#include +#include + + +int main() { + struct udev *udev; + struct udev_enumerate *enumerate; + + udev = udev_new(); + if (!udev) { + fprintf(stderr, "Cannot create udev context.\n"); + return 1; + } + + enumerate = udev_enumerate_new(udev); + if (!enumerate) { + fprintf(stderr, "Cannot create enumerate context.\n"); + } + + udev_enumerate_unref(enumerate); + udev_unref(udev); + + return EXIT_SUCCESS; +} diff --git a/recipes/libudev/config.yml b/recipes/libudev/config.yml new file mode 100644 index 0000000000000..0594dfd676099 --- /dev/null +++ b/recipes/libudev/config.yml @@ -0,0 +1,3 @@ +versions: + "system": + folder: all diff --git a/recipes/libunifex/all/CMakeLists.txt b/recipes/libunifex/all/CMakeLists.txt new file mode 100644 index 0000000000000..4beb13671fe5e --- /dev/null +++ b/recipes/libunifex/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8) +project(cmake_wrapper) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/libunifex/all/conandata.yml b/recipes/libunifex/all/conandata.yml new file mode 100644 index 0000000000000..2eaea0e7a17a7 --- /dev/null +++ b/recipes/libunifex/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20220430": + url: "https://github.com/facebookexperimental/libunifex/archive/c359fd8e7d97d91359cf4a6c1dbef99b0b1767b6.tar.gz" + sha256: "c306891967fa4cc1a22f3401581d35ceea41eb1dbdac3e6157ecf3defaa4b15d" diff --git a/recipes/libunifex/all/conanfile.py b/recipes/libunifex/all/conanfile.py new file mode 100644 index 0000000000000..49d7f959dc539 --- /dev/null +++ b/recipes/libunifex/all/conanfile.py @@ -0,0 +1,110 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.43.0" + + +class LibunifexConan(ConanFile): + name = "libunifex" + license = ("Apache-2.0", "LLVM-exception") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/facebookexperimental/libunifex" + description = "A prototype implementation of the C++ sender/receiver async programming model" + topics = ("async", "cpp") + + settings = "os", "arch", "compiler", "build_type" + + generators = "cmake", "cmake_find_package_multi" + no_copy_source = True + exports_sources = ["CMakeLists.txt"] + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "9", + "Visual Studio": "16", + "clang": "10", + "apple-clang": "11", + } + + @property + def _minimum_standard(self): + return "17" + + # FIXME: Add support for liburing + # def requirements(self): + # TODO: Make an option to opt-out of liburing for old kernel versions + # if self.settings.os == "Linux": + # self.requires("liburing/2.1") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd( + self, self._minimum_standard) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get( + str(self.settings.compiler), False) + if not minimum_version: + self.output.warn( + "{0} {1} requires C++{2}. Your compiler is unknown. Assuming it supports C++{2}." + .format(self.name, self.version, self._minimum_standard)) + elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + "{} {} requires C++{}, which your compiler does not support." + .format(self.name, self.version, self._minimum_standard)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_TESTING"] = "OFF" + cmake.configure() + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "unifex") + self.cpp_info.set_property("cmake_target_name", "unifex::unifex") + self.cpp_info.set_property("pkg_config_name", "unifex") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "unifex" + self.cpp_info.filenames["cmake_find_package_multi"] = "unifex" + self.cpp_info.names["cmake_find_package"] = "unifex" + self.cpp_info.names["cmake_find_package_multi"] = "unifex" + self.cpp_info.names["pkg_config"] = "unifex" + self.cpp_info.components["unifex"].names["cmake_find_package"] = "unifex" + self.cpp_info.components["unifex"].names["cmake_find_package_multi"] = "unifex" + self.cpp_info.components["unifex"].set_property( + "cmake_target_name", "unifex::unifex") + self.cpp_info.components["unifex"].libs = ["unifex"] + + if self.settings.os == "Linux": + self.cpp_info.components["unifex"].system_libs = ["pthread"] + # self.cpp_info.components["unifex"].requires.append( + # "liburing::liburing") diff --git a/recipes/libunifex/all/test_package/CMakeLists.txt b/recipes/libunifex/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a487dfdf2b7ad --- /dev/null +++ b/recipes/libunifex/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(unifex REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE unifex::unifex) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/libunifex/all/test_package/conanfile.py b/recipes/libunifex/all/test_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libunifex/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libunifex/all/test_package/test_package.cpp b/recipes/libunifex/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..d800f29f3a0d9 --- /dev/null +++ b/recipes/libunifex/all/test_package/test_package.cpp @@ -0,0 +1,19 @@ +#include +#include +#include +#include + +#include + +using namespace unifex; +using namespace std::chrono_literals; + +int main() { + timed_single_thread_context context; + auto scheduler = context.get_scheduler(); + + int count = 0; + sync_wait(then(schedule_after(scheduler, 200ms), [&] { ++count; })); + + return !(count == 1); +} diff --git a/recipes/libunifex/config.yml b/recipes/libunifex/config.yml new file mode 100644 index 0000000000000..1bf3ed95d8368 --- /dev/null +++ b/recipes/libunifex/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220430": + folder: "all" diff --git a/recipes/libunistring/all/conanfile.py b/recipes/libunistring/all/conanfile.py index 6aa824c297d7a..472b3ef45ff34 100644 --- a/recipes/libunistring/all/conanfile.py +++ b/recipes/libunistring/all/conanfile.py @@ -1,13 +1,25 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os +from conan.tools.build import cross_building +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path import os +required_conan_version = ">=1.53.0" + class LibUnistringConan(ConanFile): name = "libunistring" - description = "This library provides functions for manipulating Unicode strings and for manipulating C strings according to the Unicode standard." + description = ( + "This library provides functions for manipulating Unicode strings and " + "for manipulating C strings according to the Unicode standard." + ) homepage = "https://www.gnu.org/software/libunistring/" - topics = ("conan", "libunistring", "unicode", "string") + topics = ("unicode", "string") license = "LGPL-3.0-or-later" url = "https://github.com/conan-io/conan-center-index" settings = "os", "arch", "compiler", "build_type" @@ -20,55 +32,66 @@ class LibUnistringConan(ConanFile): "fPIC": True, } - _source_subfolder = "source_subfolder" - _autotools = None + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("Visual Studio is unsupported") - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("Shared build on Windows is not supported") if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libunistring-{}".format(self.version), self._source_subfolder) + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("libiconv/1.17") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration("Visual Studio is unsupported") def build_requirements(self): - if tools.os_info.is_windows and not "CONAN_BASH_PATH" in os.environ: - self.build_requires("msys2/20190524") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - conf_args = [] - if self.options.shared: - conf_args.extend(["--enable-shared", "--disable-static"]) - else: - conf_args.extend(["--disable-shared", "--enable-static"]) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - return self._autotools + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") + tc = AutotoolsToolchain(self) + tc.generate() + deps = AutotoolsDeps(self) + deps.generate() def build(self): - autotools = self._configure_autotools() + autotools = Autotools(self) + autotools.configure() autotools.make() def package(self): - self.copy(pattern="COPYING*", src=self._source_subfolder, dst="licenses") - autotools = self._configure_autotools() - autotools.install() - - os.unlink(os.path.join(self.package_folder, "lib", "libunistring.la")) - tools.rmdir(os.path.join(self.package_folder, "share")) + copy(self, "COPYING*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "share")) + fix_apple_shared_install_name(self) def package_info(self): self.cpp_info.libs = ["unistring"] + if not self.options.shared and is_apple_os(self): + self.cpp_info.frameworks.append("CoreFoundation") diff --git a/recipes/libunistring/all/test_package/CMakeLists.txt b/recipes/libunistring/all/test_package/CMakeLists.txt index 34af13462f44f..07b5ca4d6ab00 100644 --- a/recipes/libunistring/all/test_package/CMakeLists.txt +++ b/recipes/libunistring/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libunistring REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libunistring::libunistring) diff --git a/recipes/libunistring/all/test_package/conanfile.py b/recipes/libunistring/all/test_package/conanfile.py index b88a6525524a6..0a6bc68712d90 100644 --- a/recipes/libunistring/all/test_package/conanfile.py +++ b/recipes/libunistring/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,5 +21,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libunistring/all/test_package/test_package.c b/recipes/libunistring/all/test_package/test_package.c index 625433f7c4c3b..9050fcb1e3494 100644 --- a/recipes/libunistring/all/test_package/test_package.c +++ b/recipes/libunistring/all/test_package/test_package.c @@ -2,6 +2,7 @@ #include #include +#include int main(int argc, char * argv[]) { const char *text = "This is some text"; diff --git a/recipes/libunistring/all/test_v1_package/CMakeLists.txt b/recipes/libunistring/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libunistring/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libunistring/all/test_v1_package/conanfile.py b/recipes/libunistring/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libunistring/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libunistring/config.yml b/recipes/libunistring/config.yml index 0397d03561ba0..b2646e05f90e5 100644 --- a/recipes/libunistring/config.yml +++ b/recipes/libunistring/config.yml @@ -1,3 +1,3 @@ versions: - "0.9.10": - folder: all + "0.9.10": + folder: all diff --git a/recipes/libunwind/all/conandata.yml b/recipes/libunwind/all/conandata.yml index 5678b275922c8..3379c640096e5 100644 --- a/recipes/libunwind/all/conandata.yml +++ b/recipes/libunwind/all/conandata.yml @@ -1,11 +1,13 @@ sources: - "1.3.1": - sha256: "43997a3939b6ccdf2f669b50fdb8a4d3205374728c2923ddc2354c65260214f8" - url: "https://github.com/libunwind/libunwind/releases/download/v1.3.1/libunwind-1.3.1.tar.gz" + "1.6.2": + url: "https://github.com/libunwind/libunwind/releases/download/v1.6.2/libunwind-1.6.2.tar.gz" + sha256: "4a6aec666991fb45d0889c44aede8ad6eb108071c3554fcdff671f9c94794976" "1.5.0": - sha256: "90337653d92d4a13de590781371c604f9031cdb50520366aa1e3a91e1efb1017" url: "https://github.com/libunwind/libunwind/releases/download/v1.5/libunwind-1.5.0.tar.gz" + sha256: "90337653d92d4a13de590781371c604f9031cdb50520366aa1e3a91e1efb1017" + "1.3.1": + url: "https://github.com/libunwind/libunwind/releases/download/v1.3.1/libunwind-1.3.1.tar.gz" + sha256: "43997a3939b6ccdf2f669b50fdb8a4d3205374728c2923ddc2354c65260214f8" patches: "1.3.1": - patch_file: "patches/0001-multiple-definition-gcc10.patch" - base_path: "source_subfolder" diff --git a/recipes/libunwind/all/conanfile.py b/recipes/libunwind/all/conanfile.py index a528d96a2b7a8..ffee26f9f1853 100644 --- a/recipes/libunwind/all/conanfile.py +++ b/recipes/libunwind/all/conanfile.py @@ -1,17 +1,23 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration -import os +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.env import VirtualRunEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps +from conan.tools.layout import basic_layout -required_conan_version = ">=1.33.0" +import os +import shutil +required_conan_version = ">=1.53.0" class LiunwindConan(ConanFile): name = "libunwind" description = "Manipulate the preserved state of each call-frame and resume the execution at any point." - topics = ("conan", "libunwind", "unwind", "debuggers", "exception-handling", "introspection", "setjmp") + license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/libunwind/libunwind" - license = "MIT" + topics = ("unwind", "debuggers", "exception-handling", "introspection", "setjmp") settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -19,6 +25,8 @@ class LiunwindConan(ConanFile): "coredump": [True, False], "ptrace": [True, False], "setjmp": [True, False], + "minidebuginfo": [True, False], + "zlibdebuginfo": [True, False], } default_options = { "shared": False, @@ -26,62 +34,85 @@ class LiunwindConan(ConanFile): "coredump": True, "ptrace": True, "setjmp": True, + "minidebuginfo": True, + "zlibdebuginfo": True, } - exports_sources = "patches/**" - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def configure(self): - if self.settings.os not in ["Linux", "FreeBSD"]: - raise ConanInvalidConfiguration("libunwind is only supported on Linux and FreeBSD") if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): - self.requires("xz_utils/5.2.5") + if self.options.minidebuginfo: + self.requires("xz_utils/5.2.5") + if self.options.zlibdebuginfo: + self.requires("zlib/1.2.13") + + def validate(self): + if self.info.settings.os not in ["Linux", "FreeBSD"]: + raise ConanInvalidConfiguration("libunwind is only supported on Linux and FreeBSD") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def _configure_autotools(self): - if not self._autotools: - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - args = [ - "--enable-shared={}".format("yes" if self.options.shared else "no"), - "--enable-static={}".format("no" if self.options.shared else "yes"), - "--enable-coredump={}".format("yes" if self.options.coredump else "no"), - "--enable-ptrace={}".format("yes" if self.options.ptrace else "no"), - "--enable-setjmp={}".format("yes" if self.options.setjmp else "no"), - "--disable-tests", - "--disable-documentation" - ] - self._autotools.configure(configure_dir=self._source_subfolder, args=args) - return self._autotools + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") + + tc = AutotoolsToolchain(self) + yes_no = lambda v: "yes" if v else "no" + tc.configure_args.extend([ + f"--enable-coredump={yes_no(self.options.coredump)}", + f"--enable-ptrace={yes_no(self.options.ptrace)}", + f"--enable-setjmp={yes_no(self.options.setjmp)}", + f"--enable-minidebuginfo={yes_no(self.options.minidebuginfo)}", + f"--enable-zlibdebuginfo={yes_no(self.options.zlibdebuginfo)}", + "--disable-tests", + "--disable-documentation", + ]) + tc.generate() + + tc = AutotoolsDeps(self) + tc.generate() def build(self): - for patch_data in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch_data) - autotools = self._configure_autotools() + apply_conandata_patches(self) + autotools = Autotools(self) + autotools.configure() autotools.make() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - autotools = self._configure_autotools() + copy(self, pattern="COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) autotools.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + + # In install-exec-hook in Makefile.am, libunwind_generic is linked to libunwind_${arch}. + # As this seems to be unnecessary for the conan package. + # rename the real file to libunwind_generic, + lib_ext = "so" if self.options.shared else "a" + symlink_path = os.path.join(self.package_folder, "lib", f"libunwind-generic.{lib_ext}") + source_path = os.path.realpath(symlink_path) + rm(self, os.path.basename(symlink_path), os.path.dirname(symlink_path)) + shutil.copy(source_path, symlink_path) def package_info(self): self.cpp_info.components["unwind"].names["pkg_config"] = "libunwind" self.cpp_info.components["unwind"].libs = ["unwind"] - self.cpp_info.components["unwind"].requires = ["xz_utils::xz_utils"] + if self.options.minidebuginfo: + self.cpp_info.components["unwind"].requires.append("xz_utils::xz_utils") + if self.options.zlibdebuginfo: + self.cpp_info.components["unwind"].requires.append("zlib::zlib") if self.settings.os == "Linux": self.cpp_info.components["unwind"].system_libs.append("pthread") self.cpp_info.components["generic"].names["pkg_config"] = "libunwind-generic" diff --git a/recipes/libunwind/all/test_package/CMakeLists.txt b/recipes/libunwind/all/test_package/CMakeLists.txt index 0f456c2481f41..e857c1d9df841 100644 --- a/recipes/libunwind/all/test_package/CMakeLists.txt +++ b/recipes/libunwind/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(libunwind CONFIG REQUIRED) +find_package(libunwind REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} libunwind::libunwind) +target_link_libraries(${PROJECT_NAME} PRIVATE libunwind::libunwind) diff --git a/recipes/libunwind/all/test_package/conanfile.py b/recipes/libunwind/all/test_package/conanfile.py index 7e2dfe859bb27..e845ae751a301 100644 --- a/recipes/libunwind/all/test_package/conanfile.py +++ b/recipes/libunwind/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libunwind/all/test_v1_package/CMakeLists.txt b/recipes/libunwind/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..de3b75d9538de --- /dev/null +++ b/recipes/libunwind/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libunwind/all/test_v1_package/conanfile.py b/recipes/libunwind/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/libunwind/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libunwind/config.yml b/recipes/libunwind/config.yml index dff352f3d23e4..26cf6b32aa2bf 100644 --- a/recipes/libunwind/config.yml +++ b/recipes/libunwind/config.yml @@ -1,5 +1,7 @@ versions: - "1.3.1": + "1.6.2": folder: all "1.5.0": folder: all + "1.3.1": + folder: all diff --git a/recipes/liburing/all/conandata.yml b/recipes/liburing/all/conandata.yml index 8f4a6f6d15900..ca85945754398 100644 --- a/recipes/liburing/all/conandata.yml +++ b/recipes/liburing/all/conandata.yml @@ -1,4 +1,18 @@ sources: - "0.7": - url: https://github.com/axboe/liburing/archive/liburing-0.7.tar.gz - sha256: 8e2842cfe947f3a443af301bdd6d034455536c38a455c7a700d0c1ad165a7543 + "2.2": + url: "https://github.com/axboe/liburing/archive/liburing-2.2.tar.gz" + sha256: "e092624af6aa244ade2d52181cc07751ac5caba2f3d63e9240790db9ed130bbc" + "2.1": + url: "https://github.com/axboe/liburing/archive/liburing-2.1.tar.gz" + sha256: "f1e0500cb3934b0b61c5020c3999a973c9c93b618faff1eba75aadc95bb03e07" + "2.0": + url: "https://github.com/axboe/liburing/archive/liburing-2.0.tar.gz" + sha256: "ca069ecc4aa1baf1031bd772e4e97f7e26dfb6bb733d79f70159589b22ab4dc0" + "0.7": + url: "https://github.com/axboe/liburing/archive/liburing-0.7.tar.gz" + sha256: "8e2842cfe947f3a443af301bdd6d034455536c38a455c7a700d0c1ad165a7543" + +patches: + "2.1": + - base_path: "source_subfolder" + patch_file: "patches/0001-liburing-2.1-memfd-create.patch" diff --git a/recipes/liburing/all/conanfile.py b/recipes/liburing/all/conanfile.py index bed05b21f9bba..9035e2b799208 100644 --- a/recipes/liburing/all/conanfile.py +++ b/recipes/liburing/all/conanfile.py @@ -1,8 +1,11 @@ +from conans import AutoToolsBuildEnvironment +from conan import ConanFile +from conan.tools.files import get, patch, chdir, rmdir, copy +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration import os -import platform -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.33.0" class LiburingConan(ConanFile): @@ -10,79 +13,96 @@ class LiburingConan(ConanFile): license = "GPL-2.0-or-later" homepage = "https://github.com/axboe/liburing" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler", "build_type", "arch" - description = """helpers to setup and -teardown io_uring instances, and also a simplified interface for -applications that don't need (or want) to deal with the full kernel -side implementation.""" + description = ("helpers to setup and teardown io_uring instances, and also a simplified interface for " + "applications that don't need (or want) to deal with the full kernel side implementation.") topics = ("asynchronous-io", "async", "kernel") + settings = "os", "arch", "compiler", "build_type" options = { "fPIC": [True, False], "shared": [True, False], + "with_libc": [True, False], } - default_options = { "fPIC": True, "shared": False, + "with_libc": True, } - _autotools = None + exports_sources = ["patches/*"] - def _configure_autotools(self): - if self._autotools: - return self._autotools - - self._autotools = AutoToolsBuildEnvironment(self) - self._autotools.configure(configure_dir=self._source_subfolder) - return self._autotools + _autotools = None @property def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") + return "source_subfolder" - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{0}-{0}-{1}".format(self.name, self.version), - self._source_subfolder) + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if Version(self.version) < "2.2": + del self.options.with_libc def configure(self): + if self.options.shared: + del self.options.fPIC + + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + self.requires("linux-headers-generic/5.13.9") + + def validate(self): + # FIXME: use kernel version of build/host machine. + # kernel version should be encoded in profile if self.settings.os != "Linux": raise ConanInvalidConfiguration( "liburing is supported only on linux") - if tools.Version(platform.release()) < "5.1": - raise ConanInvalidConfiguration( - "This linux kernel version does not support io uring") - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + + self._autotools = AutoToolsBuildEnvironment(self) + args = [] + if self.options.get_safe("with_libc") == False: + args.append("--nolibc") + self._autotools.configure(args=args) + self._autotools.flags.append("-std=gnu99") + return self._autotools + + def _patch_sources(self): + for data in self.conan_data.get("patches", {}).get(self.version, []): + patch(self, **data) def build(self): - with tools.chdir(self._source_subfolder): + self._patch_sources() + with chdir(self, self._source_subfolder): autotools = self._configure_autotools() autotools.make() def package(self): - self.copy("COPYING*", src=self._source_subfolder, dst="licenses") - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + copy(self, "COPYING*", src=self._source_subfolder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "LICENSE", src=self._source_subfolder, dst=os.path.join(self.package_folder, "licenses")) - with tools.chdir(self._source_subfolder): + with chdir(self, self._source_subfolder): autotools = self._configure_autotools() install_args = [ "ENABLE_SHARED={}".format(1 if self.options.shared else 0) ] autotools.install(args=install_args) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "man")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "man")) if self.options.shared: os.remove(os.path.join(self.package_folder, "lib", "liburing.a")) - os.unlink(os.path.join(self.package_folder, "lib", "liburing.so")) - os.unlink(os.path.join(self.package_folder, "lib", "liburing.so.1")) - with tools.chdir(os.path.join(self.package_folder, "lib")): - os.rename("liburing.so.1.{}".format( - self.version), "liburing.so") def package_info(self): + self.cpp_info.names["pkg_config"] = "liburing" self.cpp_info.libs = ["uring"] diff --git a/recipes/liburing/all/patches/0001-liburing-2.1-memfd-create.patch b/recipes/liburing/all/patches/0001-liburing-2.1-memfd-create.patch new file mode 100644 index 0000000000000..6249b5b1c6e01 --- /dev/null +++ b/recipes/liburing/all/patches/0001-liburing-2.1-memfd-create.patch @@ -0,0 +1,71 @@ +diff --git a/configure b/configure +index afccef1..a7caa07 100755 +--- a/configure ++++ b/configure +@@ -338,6 +338,23 @@ if compile_prog "" "" "has_ucontext"; then + fi + print_config "has_ucontext" "$has_ucontext" + ++########################################## ++# check for memfd_create(2) ++has_memfd_create="no" ++cat > $TMPC << EOF ++#define _GNU_SOURCE ++#include ++int main(int argc, char **argv) ++{ ++ int memfd = memfd_create("test", 0); ++ return 0; ++} ++EOF ++if compile_prog "-Werror=implicit-function-declaration" "" "has_memfd_create"; then ++ has_memfd_create="yes" ++fi ++print_config "has_memfd_create" "$has_memfd_create" ++ + + ############################################################################# + +@@ -365,6 +382,9 @@ fi + if test "$array_bounds" = "yes"; then + output_sym "CONFIG_HAVE_ARRAY_BOUNDS" + fi ++if test "$has_memfd_create" = "yes"; then ++ output_sym "CONFIG_HAVE_MEMFD_CREATE" ++fi + + echo "CC=$cc" >> $config_host_mak + print_config "CC" "$cc" +diff --git a/liburing.spec b/liburing.spec +index 0268d23..7eb5731 100644 +--- a/liburing.spec ++++ b/liburing.spec +@@ -1,5 +1,5 @@ + Name: liburing +-Version: 2.0 ++Version: 2.1 + Release: 1%{?dist} + Summary: Linux-native io_uring I/O access library + License: (GPLv2 with exceptions and LGPLv2+) or MIT +diff --git a/test/io_uring_register.c b/test/io_uring_register.c +index da7bc0d..b8a4ea5 100644 +--- a/test/io_uring_register.c ++++ b/test/io_uring_register.c +@@ -31,6 +31,17 @@ static int pagesize; + static rlim_t mlock_limit; + static int devnull; + ++#if !defined(CONFIG_HAVE_MEMFD_CREATE) ++#include ++#include ++ ++static int memfd_create(const char *name, unsigned int flags) ++{ ++ return (int)syscall(SYS_memfd_create, name, flags); ++} ++#endif ++ ++ + int + expect_fail(int fd, unsigned int opcode, void *arg, + unsigned int nr_args, int error) diff --git a/recipes/liburing/all/test_package/CMakeLists.txt b/recipes/liburing/all/test_package/CMakeLists.txt index cca5a1c41908a..b8135611cec52 100644 --- a/recipes/liburing/all/test_package/CMakeLists.txt +++ b/recipes/liburing/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) - project(test_package C) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) -add_executable(test_package test_package.c) -target_link_libraries(test_package PRIVATE CONAN_PKG::liburing) +find_package(liburing REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE liburing::liburing) diff --git a/recipes/liburing/all/test_package/conanfile.py b/recipes/liburing/all/test_package/conanfile.py index 23865f799c25e..6fbb963afebbd 100644 --- a/recipes/liburing/all/test_package/conanfile.py +++ b/recipes/liburing/all/test_package/conanfile.py @@ -1,15 +1,28 @@ -from conans import ConanFile, CMake, tools +from conans import CMake +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.scm import Version +import platform +import re import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) cmake.configure() cmake.build() + @property + def _sufficient_linux_kernel_version(self): + # FIXME: use kernel version of build/host machine. kernel version should be encoded in profile + linux_kernel_version = re.match("([0-9.]+)", platform.release()).group(1) + return Version(linux_kernel_version) >= "5.1" + def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self) and self._sufficient_linux_kernel_version: + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/liburing/config.yml b/recipes/liburing/config.yml index 0536885a53045..7c72c93d4edcd 100644 --- a/recipes/liburing/config.yml +++ b/recipes/liburing/config.yml @@ -1,3 +1,9 @@ versions: + "2.2": + folder: all + "2.1": + folder: all + "2.0": + folder: all "0.7": folder: all diff --git a/recipes/libusb-compat/all/conanfile.py b/recipes/libusb-compat/all/conanfile.py index e7ac0985ab6e7..0319dc88794d1 100644 --- a/recipes/libusb-compat/all/conanfile.py +++ b/recipes/libusb-compat/all/conanfile.py @@ -4,6 +4,9 @@ import os import re import shlex +import shutil + +required_conan_version = ">=1.33.0" class LibUSBCompatConan(ConanFile): @@ -34,10 +37,6 @@ class LibUSBCompatConan(ConanFile): def _source_subfolder(self): return "source_subfolder" - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libusb-compat-{}".format(self.version), self._source_subfolder) - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -49,16 +48,24 @@ def configure(self): del self.settings.compiler.cppstd def requirements(self): - self.requires("libusb/1.0.23") + self.requires("libusb/1.0.24") if self.settings.compiler == "Visual Studio": self.requires("dirent/1.23.2") + @property + def _settings_build(self): + return self.settings_build if hasattr(self, "settings_build") else self.settings + def build_requirements(self): + self.build_requires("gnu-config/cci.20201022") self.build_requires("libtool/2.4.6") - self.build_requires("pkgconf/1.7.3") - if tools.os_info.is_windows and not os.environ.get("CONAN_BASH_PATH") and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") + self.build_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _iterate_lib_paths_win(self, lib): """Return all possible library paths for lib""" @@ -143,8 +150,12 @@ def _extract_autotools_variables(self): return sources, headers def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: + for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) if self.settings.os == "Windows": api = "__declspec(dllexport)" if self.options.shared else "" tools.replace_in_file(os.path.join(self._source_subfolder, "configure.ac"), @@ -155,6 +166,10 @@ def _patch_sources(self): tools.replace_in_file(os.path.join(self._source_subfolder, "ltmain.sh"), "droppeddeps=yes", "droppeddeps=no && func_append newdeplibs \" $a_deplib\"") + @property + def _user_info_build(self): + return getattr(self, "user_info_build", None) or self.deps_user_info + def build(self): self._patch_sources() with self._build_context(): diff --git a/recipes/libusb/all/conandata.yml b/recipes/libusb/all/conandata.yml index 319c02443f1fc..77c9b6023c5e8 100644 --- a/recipes/libusb/all/conandata.yml +++ b/recipes/libusb/all/conandata.yml @@ -5,3 +5,9 @@ sources: "1.0.24": sha256: 7efd2685f7b327326dcfb85cee426d9b871fd70e22caa15bb68d595ce2a2b12a url: https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.tar.bz2 + "1.0.25": + sha256: 8a28ef197a797ebac2702f095e81975e2b02b2eeff2774fa909c78a74ef50849 + url: https://github.com/libusb/libusb/releases/download/v1.0.25/libusb-1.0.25.tar.bz2 + "1.0.26": + sha256: 12ce7a61fc9854d1d2a1ffe095f7b5fac19ddba095c259e6067a46500381b5a5 + url: https://github.com/libusb/libusb/releases/download/v1.0.26/libusb-1.0.26.tar.bz2 diff --git a/recipes/libusb/all/conanfile.py b/recipes/libusb/all/conanfile.py index 3e0800d9ee87f..0c93d90aac203 100644 --- a/recipes/libusb/all/conanfile.py +++ b/recipes/libusb/all/conanfile.py @@ -1,5 +1,14 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, MSBuild, tools +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.microsoft import is_msvc +from conan.tools.files import get, chdir, rmdir, rm, replace_in_file +from conan.tools.scm import Version +from conans import AutoToolsBuildEnvironment, MSBuild, tools import os +import re + +required_conan_version = ">=1.51.3" + class LibUSBConan(ConanFile): name = "libusb" @@ -9,8 +18,16 @@ class LibUSBConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" topics = ("conan", "libusb", "usb", "device") settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "enable_udev": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "enable_udev": True, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + "enable_udev": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "enable_udev": True, + } _autotools = None @property @@ -22,13 +39,17 @@ def _is_mingw(self): return self.settings.os == "Windows" and self.settings.compiler == "gcc" @property - def _is_msvc(self): - return self.settings.os == "Windows" and self.settings.compiler == "Visual Studio" + def _settings_build(self): + return self.settings_build if hasattr(self, "settings_build") else self.settings - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = self.name + "-" + self.version - os.rename(extracted_folder, self._source_subfolder) + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.os not in ["Linux", "Android"]: + del self.options.enable_udev + # FIXME: enable_udev should be True for Android, but libudev recipe is missing + if self.settings.os == "Android": + self.options.enable_udev = False def configure(self): if self.options.shared: @@ -36,42 +57,28 @@ def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd - def config_options(self): - if self.settings.os != "Linux": - del self.options.enable_udev - if self.settings.os == "Windows": - del self.options.fPIC + def layout(self): + pass def build_requirements(self): - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio" and \ - not tools.get_env("CONAN_BASH_PATH") and tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows" and not is_msvc(self) and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") - def system_requirements(self): + def requirements(self): if self.settings.os == "Linux": if self.options.enable_udev: - package_tool = tools.SystemPackageTool(conanfile=self) - libudev_name = "" - os_info = tools.OSInfo() - if os_info.with_apt: - libudev_name = "libudev-dev" - elif os_info.with_yum: - libudev_name = "libudev-devel" - elif os_info.with_zypper: - libudev_name = "libudev-devel" - elif os_info.with_pacman: - libudev_name = "libsystemd systemd" - else: - self.output.warn("Could not install libudev: Undefined package name for current platform.") - return - package_tool.install(packages=libudev_name, update=True) + self.requires("libudev/system") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _build_visual_studio(self): - with tools.chdir(self._source_subfolder): + with chdir(self, self._source_subfolder): # Assume we're using the latest Visual Studio and default to libusb_2019.sln # (or libusb_2017.sln for libusb < 1.0.24). # If we're not using the latest Visual Studio, select an appropriate solution file. - solution_msvc_year = 2019 if tools.Version(self.version) >= "1.0.24" else 2017 + solution_msvc_year = 2019 if Version(self.version) >= "1.0.24" else 2017 solution_msvc_year = { "11": 2012, @@ -82,15 +89,20 @@ def _build_visual_studio(self): solution_file = os.path.join("msvc", "libusb_{}.sln".format(solution_msvc_year)) platforms = {"x86":"Win32"} + properties = { + # Enable LTO when CFLAGS contains -GL + "WholeProgramOptimization": "true" if any(re.finditer("(^| )[/-]GL($| )", tools.get_env("CFLAGS", ""))) else "false", + } msbuild = MSBuild(self) - msbuild.build(solution_file, platforms=platforms, upgrade_project=False) + build_type = "Debug" if self.settings.build_type == "Debug" else "Release" + msbuild.build(solution_file, platforms=platforms, upgrade_project=False, properties=properties, build_type=build_type) def _configure_autotools(self): if not self._autotools: self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) configure_args = ["--enable-shared" if self.options.shared else "--disable-shared"] configure_args.append("--enable-static" if not self.options.shared else "--disable-static") - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "Android"]: configure_args.append("--enable-udev" if self.options.enable_udev else "--disable-udev") elif self._is_mingw: if self.settings.arch == "x86_64": @@ -102,12 +114,12 @@ def _configure_autotools(self): return self._autotools def build(self): - if self._is_msvc: - if tools.Version(self.version) < "1.0.24": + if is_msvc(self): + if Version(self.version) < "1.0.24": for vcxproj in ["fxload_2017", "getopt_2017", "hotplugtest_2017", "libusb_dll_2017", "libusb_static_2017", "listdevs_2017", "stress_2017", "testlibusb_2017", "xusb_2017"]: vcxproj_path = os.path.join(self._source_subfolder, "msvc", "%s.vcxproj" % vcxproj) - tools.replace_in_file(vcxproj_path, "10.0.16299.0", "") + replace_in_file(self, vcxproj_path, "10.0.16299.0", "") self._build_visual_studio() else: autotools = self._configure_autotools() @@ -128,26 +140,23 @@ def _package_visual_studio(self): def package(self): self.copy("COPYING", src=self._source_subfolder, dst="licenses", keep_path=False) - if self._is_msvc: + if is_msvc(self): self._package_visual_studio() else: autotools = self._configure_autotools() autotools.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - la_file = os.path.join(self.package_folder, "lib", "libusb-1.0.la") - if os.path.isfile(la_file): - os.remove(la_file) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) def package_info(self): - self.cpp_info.names["pkg_config"] = "libusb-1.0" + self.cpp_info.set_property("pkg_config_name", "libusb-1.0") self.cpp_info.libs = tools.collect_libs(self) self.cpp_info.includedirs.append(os.path.join("include", "libusb-1.0")) - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("pthread") - if self.options.enable_udev: - self.cpp_info.system_libs.append("udev") elif self.settings.os == "Macos": self.cpp_info.system_libs = ["objc"] - self.cpp_info.frameworks = ["IOKit", "CoreFoundation"] + self.cpp_info.frameworks = ["IOKit", "CoreFoundation", "Security"] elif self.settings.os == "Windows": self.cpp_info.system_libs = ["advapi32"] diff --git a/recipes/libusb/all/test_package/CMakeLists.txt b/recipes/libusb/all/test_package/CMakeLists.txt index 64edb4d64b17a..a5ffd526aaea7 100644 --- a/recipes/libusb/all/test_package/CMakeLists.txt +++ b/recipes/libusb/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) +add_executable(${CMAKE_PROJECT_NAME} test_package.c) target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libusb/all/test_package/conanfile.py b/recipes/libusb/all/test_package/conanfile.py index 4fdc223664bd8..3695635f5e0f5 100644 --- a/recipes/libusb/all/test_package/conanfile.py +++ b/recipes/libusb/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin","test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libusb/all/test_package/test_package.cpp b/recipes/libusb/all/test_package/test_package.c similarity index 100% rename from recipes/libusb/all/test_package/test_package.cpp rename to recipes/libusb/all/test_package/test_package.c diff --git a/recipes/libusb/config.yml b/recipes/libusb/config.yml index 63f91e38b9c2e..8c9d67d1012f2 100644 --- a/recipes/libusb/config.yml +++ b/recipes/libusb/config.yml @@ -4,3 +4,7 @@ versions: folder: all "1.0.24": folder: all + "1.0.25": + folder: all + "1.0.26": + folder: all diff --git a/recipes/libuuid/all/conandata.yml b/recipes/libuuid/all/conandata.yml index 37a31cc5d58bd..65a63e13dcdf9 100644 --- a/recipes/libuuid/all/conandata.yml +++ b/recipes/libuuid/all/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "1.0.3": - patch_file: "patches/0001-check-sys-syscall-h+wrap-includes.patch" - base_path: "source_subfolder" diff --git a/recipes/libuuid/all/conanfile.py b/recipes/libuuid/all/conanfile.py index 403a55c8e1f0e..aa83c7a3c0314 100644 --- a/recipes/libuuid/all/conanfile.py +++ b/recipes/libuuid/all/conanfile.py @@ -1,7 +1,14 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.52.0" + class LibuuidConan(ConanFile): name = "libuuid" @@ -9,65 +16,78 @@ class LibuuidConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://sourceforge.net/projects/libuuid/" license = "BSD-3-Clause" - topics = ("conan", "libuuid", "uuid", "unique-id", "unique-identifier") - settings = "os", "arch", "compiler", "build_type" - exports_sources = "patches/**" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - _source_subfolder = "source_subfolder" - _autotools = None + topics = ("libuuid", "uuid", "unique-id", "unique-identifier") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == 'Windows': del self.options.fPIC def configure(self): - if self.settings.os == "Windows": + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.os == "Windows": raise ConanInvalidConfiguration("libuuid is not supported on Windows") - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd def build_requirements(self): - self.build_requires("libtool/2.4.6") + self.tool_requires("libtool/2.4.7") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self) - yes_no = lambda v: "yes" if v else "no" - configure_args = [ - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), - ] + def generate(self): + tc = AutotoolsToolchain(self) if "x86" in self.settings.arch: - self._autotools.flags.append('-mstackrealign') - self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) - return self._autotools + tc.extra_cflags.append("-mstackrealign") + tc.generate() + env = VirtualBuildEnv(self) + env.generate() def build(self): - self._patch_sources() - with tools.chdir(self._source_subfolder): - self.run("autoreconf -fiv", run_environment=True) - autotools = self._configure_autotools() + apply_conandata_patches(self) + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() autotools.make() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - autotools = self._configure_autotools() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) autotools.install() - la_file = os.path.join(self.package_folder, "lib", "libuuid.la") - if os.path.isfile(la_file): - os.unlink(la_file) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + fix_apple_shared_install_name(self) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("pkg_config_name", "uuid") + self.cpp_info.libs = ["uuid"] self.cpp_info.includedirs.append(os.path.join("include", "uuid")) diff --git a/recipes/libuuid/all/test_package/CMakeLists.txt b/recipes/libuuid/all/test_package/CMakeLists.txt index fd126a732c403..75c717f769900 100644 --- a/recipes/libuuid/all/test_package/CMakeLists.txt +++ b/recipes/libuuid/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libuuid REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) +target_link_libraries(${PROJECT_NAME} PRIVATE libuuid::libuuid) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/libuuid/all/test_package/conanfile.py b/recipes/libuuid/all/test_package/conanfile.py index 9e1a74ce7b837..0a6bc68712d90 100644 --- a/recipes/libuuid/all/test_package/conanfile.py +++ b/recipes/libuuid/all/test_package/conanfile.py @@ -1,12 +1,19 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -from conans import ConanFile, CMake +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -14,5 +21,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libuuid/all/test_v1_package/CMakeLists.txt b/recipes/libuuid/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..40c1a8324330c --- /dev/null +++ b/recipes/libuuid/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libuuid REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libuuid::libuuid) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/libuuid/all/test_v1_package/conanfile.py b/recipes/libuuid/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libuuid/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libuv/all/CMakeLists.txt b/recipes/libuv/all/CMakeLists.txt deleted file mode 100644 index 5c33d80b7d7b4..0000000000000 --- a/recipes/libuv/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.0) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libuv/all/conandata.yml b/recipes/libuv/all/conandata.yml index f0010680ee67b..e251d497e772d 100644 --- a/recipes/libuv/all/conandata.yml +++ b/recipes/libuv/all/conandata.yml @@ -1,32 +1,65 @@ sources: - "1.34.2": - url: "https://github.com/libuv/libuv/archive/v1.34.2.zip" - sha256: "e1a663bcbfbeb18e447f79a39645ca555db47153d29ed81a1cb289373f357035" - "1.38.0": - url: "https://github.com/libuv/libuv/archive/v1.38.0.zip" - sha256: "6502ee75e1007325ba2e15e06d3d7b94ac911704793b2fe6f7bb933e1748db72" - "1.38.1": - url: "https://github.com/libuv/libuv/archive/v1.38.1.zip" - sha256: "0359369492742eb2a36312fffe26f80bcffe4cec981a4fd72d182b061ee14890" - "1.40.0": - url: "https://github.com/libuv/libuv/archive/v1.40.0.zip" - sha256: "61366e30d8484197dc9e4a94dbd98a0ba52fb55cb6c6d991af1f3701b10f322b" + "1.44.2": + url: "https://github.com/libuv/libuv/archive/v1.44.2.tar.gz" + sha256: "e6e2ba8b4c349a4182a33370bb9be5e23c51b32efb9b9e209d0e8556b73a48da" + "1.44.1": + url: "https://github.com/libuv/libuv/archive/v1.44.1.tar.gz" + sha256: "e91614e6dc2dd0bfdd140ceace49438882206b7a6fb00b8750914e67a9ed6d6b" + "1.43.0": + url: "https://github.com/libuv/libuv/archive/v1.43.0.tar.gz" + sha256: "9e27825a55279de69a7c43e42d509fd1337c9bece2547c761e91a1592e91cc4d" + "1.42.0": + url: "https://github.com/libuv/libuv/archive/v1.42.0.tar.gz" + sha256: "371e5419708f6aaeb8656671f89400b92a9bba6443369af1bb70bcd6e4b3c764" + "1.41.1": + url: "https://github.com/libuv/libuv/archive/v1.41.1.tar.gz" + sha256: "62c29d1d76b0478dc8aaed0ed1f874324f6cd2d6ff4cb59a44026c09e818cd53" "1.41.0": url: "https://github.com/libuv/libuv/archive/v1.41.0.zip" sha256: "cb89a8b9f686c5ccf7ed09a9e0ece151a73ebebc17af3813159c335b02181794" -patches: - "1.34.2": - - base_path: "source_subfolder" - patch_file: "patches/1.34.2/fix-cmake.patch" - "1.38.0": - - base_path: "source_subfolder" - patch_file: "patches/1.38.0/fix-cmake.patch" - "1.38.1": - - base_path: "source_subfolder" - patch_file: "patches/1.38.1/fix-cmake.patch" "1.40.0": - - base_path: "source_subfolder" - patch_file: "patches/1.40.0/fix-cmake.patch" + url: "https://github.com/libuv/libuv/archive/v1.40.0.zip" + sha256: "61366e30d8484197dc9e4a94dbd98a0ba52fb55cb6c6d991af1f3701b10f322b" + "1.38.1": + url: "https://github.com/libuv/libuv/archive/v1.38.1.zip" + sha256: "0359369492742eb2a36312fffe26f80bcffe4cec981a4fd72d182b061ee14890" +patches: + "1.44.2": + - patch_file: "patches/1.44.2/fix-cmake.patch" + patch_description: "separate shared and static library build" + patch_type: "conan" + "1.44.1": + - patch_file: "patches/1.44.1/fix-cmake.patch" + patch_description: "separate shared and static library build" + patch_type: "conan" + "1.43.0": + - patch_file: "patches/1.43.0/fix-cmake.patch" + patch_description: "separate shared and static library build" + patch_type: "conan" + "1.42.0": + - patch_file: "patches/1.42.0/fix-cmake.patch" + patch_description: "separate shared and static library build" + patch_type: "conan" + "1.41.1": + - patch_file: "patches/1.41.0/fix-cmake.patch" + patch_description: "separate shared and static library build" + patch_type: "conan" + - patch_file: "patches/1.40.0/fix-ios.patch" "1.41.0": - - base_path: "source_subfolder" - patch_file: "patches/1.41.0/fix-cmake.patch" + - patch_file: "patches/1.41.0/fix-cmake.patch" + patch_description: "separate shared and static library build" + patch_type: "conan" + - patch_file: "patches/1.40.0/fix-ios.patch" + patch_description: "fix dlopen filename" + patch_type: "portability" + "1.40.0": + - patch_file: "patches/1.40.0/fix-cmake.patch" + patch_description: "separate shared and static library build" + patch_type: "conan" + - patch_file: "patches/1.40.0/fix-ios.patch" + patch_description: "fix dlopen filename" + patch_type: "portability" + "1.38.1": + - patch_file: "patches/1.38.1/fix-cmake.patch" + patch_description: "separate shared and static library build" + patch_type: "conan" diff --git a/recipes/libuv/all/conanfile.py b/recipes/libuv/all/conanfile.py index a5305a8f72f9a..a147f0a7124e2 100644 --- a/recipes/libuv/all/conanfile.py +++ b/recipes/libuv/all/conanfile.py @@ -1,38 +1,33 @@ -import glob +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save +from conan.tools.microsoft import is_msvc, check_min_vs import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +import textwrap +required_conan_version = ">=1.52.0" -class libuvConan(ConanFile): + +class LibuvConan(ConanFile): name = "libuv" license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://libuv.org" description = "A multi-platform support library with a focus on asynchronous I/O" - topics = ("libuv", "asynchronous", "io", "networking", "multi-platform", "conan-recipe") + topics = ("libuv", "asynchronous", "io", "networking", "multi-platform") - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], - "fPIC": [True, False] + "fPIC": [True, False], } default_options = { "shared": False, - "fPIC": True + "fPIC": True, } - generators = "cmake" - exports_sources = [ - "CMakeLists.txt", - "patches/*" - ] - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -40,40 +35,88 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx - if self.settings.compiler == "Visual Studio": - if tools.Version(self.settings.compiler.version) < "14": - raise ConanInvalidConfiguration("Visual Studio 2015 or higher required") + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if is_msvc(self): + check_min_vs(self, "190") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libuv-{}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["LIBUV_BUILD_TESTS"] = False - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBUV_BUILD_TESTS"] = False + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + for license_file in ["LICENSE", "LICENSE-docs"]: + copy(self, license_file, src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {self._target_lib_name: "libuv::libuv"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + @property + def _target_lib_name(self): + return "uv" if self.options.shared else "uv_a" def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("cmake_file_name", "libuv") + self.cpp_info.set_property("cmake_target_name", self._target_lib_name) + self.cpp_info.set_property("pkg_config_name", "libuv" if self.options.shared else "libuv-static") + self.cpp_info.libs = [self._target_lib_name] if self.options.shared: self.cpp_info.defines = ["USING_UV_SHARED=1"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["dl", "pthread", "rt"] if self.settings.os == "Windows": self.cpp_info.system_libs = ["iphlpapi", "psapi", "userenv", "ws2_32"] + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["pkg_config"] = "libuv" if self.options.shared else "libuv-static" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/libuv/all/patches/1.34.2/fix-cmake.patch b/recipes/libuv/all/patches/1.34.2/fix-cmake.patch deleted file mode 100644 index f763d9bfd56e9..0000000000000 --- a/recipes/libuv/all/patches/1.34.2/fix-cmake.patch +++ /dev/null @@ -1,87 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 2ab6d17e..9292e6a2 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -365,38 +365,26 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD") - list(APPEND uv_test_libraries util) - endif() - --add_library(uv SHARED ${uv_sources}) -+add_library(uv ${uv_sources}) - target_compile_definitions(uv -- INTERFACE USING_UV_SHARED=1 -- PRIVATE ${uv_defines} BUILDING_UV_SHARED=1) -+ PRIVATE -+ ${uv_defines} -+) -+get_target_property(target_type uv TYPE) -+if (target_type STREQUAL "SHARED_LIBRARY") -+ target_compile_definitions(uv -+ INTERFACE -+ USING_UV_SHARED=1 -+ PRIVATE -+ BUILDING_UV_SHARED=1 -+ ) -+else() -+ set_property(TARGET uv PROPERTY OUTPUT_NAME "uv_a") -+endif() - target_compile_options(uv PRIVATE ${uv_cflags}) - target_include_directories(uv PUBLIC include PRIVATE src) - target_link_libraries(uv ${uv_libraries}) - --add_library(uv_a STATIC ${uv_sources}) --target_compile_definitions(uv_a PRIVATE ${uv_defines}) --target_compile_options(uv_a PRIVATE ${uv_cflags}) --target_include_directories(uv_a PUBLIC include PRIVATE src) --target_link_libraries(uv_a ${uv_libraries}) -- --if(LIBUV_BUILD_TESTS) -- add_executable(uv_run_tests ${uv_test_sources}) -- target_compile_definitions(uv_run_tests -- PRIVATE ${uv_defines} USING_UV_SHARED=1) -- target_compile_options(uv_run_tests PRIVATE ${uv_cflags}) -- target_link_libraries(uv_run_tests uv ${uv_test_libraries}) -- add_test(NAME uv_test -- COMMAND uv_run_tests -- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -- add_executable(uv_run_tests_a ${uv_test_sources}) -- target_compile_definitions(uv_run_tests_a PRIVATE ${uv_defines}) -- target_compile_options(uv_run_tests_a PRIVATE ${uv_cflags}) -- target_link_libraries(uv_run_tests_a uv_a ${uv_test_libraries}) -- add_test(NAME uv_test_a -- COMMAND uv_run_tests_a -- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) --endif() -- - if(UNIX) - # Now for some gibbering horrors from beyond the stars... - foreach(x ${uv_libraries}) -@@ -411,20 +399,18 @@ if(UNIX) - set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) - set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) - set(prefix ${CMAKE_INSTALL_PREFIX}) -- configure_file(libuv.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libuv.pc @ONLY) - - install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -- install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) -- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libuv.pc -- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -- install(TARGETS uv LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) -- install(TARGETS uv_a ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -+ install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/licenses) -+ install(TARGETS uv -+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - - if(WIN32) - install(DIRECTORY include/ DESTINATION include) -- install(FILES LICENSE DESTINATION .) -- install(TARGETS uv uv_a -- RUNTIME DESTINATION lib/$ -- ARCHIVE DESTINATION lib/$) -+ install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/licenses) -+ install(TARGETS uv -+ RUNTIME DESTINATION bin -+ ARCHIVE DESTINATION lib) - endif() diff --git a/recipes/libuv/all/patches/1.38.0/fix-cmake.patch b/recipes/libuv/all/patches/1.38.0/fix-cmake.patch deleted file mode 100644 index 031e64210b090..0000000000000 --- a/recipes/libuv/all/patches/1.38.0/fix-cmake.patch +++ /dev/null @@ -1,80 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 0496d36a..90615d57 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -298,13 +298,19 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD") - list(APPEND uv_test_libraries util) - endif() - --add_library(uv SHARED ${uv_sources}) --target_compile_definitions(uv -- INTERFACE -- USING_UV_SHARED=1 -- PRIVATE -- BUILDING_UV_SHARED=1 -- ${uv_defines}) -+add_library(uv ${uv_sources}) -+get_target_property(target_type uv TYPE) -+if (target_type STREQUAL "SHARED_LIBRARY") -+ target_compile_definitions(uv -+ INTERFACE -+ USING_UV_SHARED=1 -+ PRIVATE -+ BUILDING_UV_SHARED=1 -+ ) -+else() -+ set_property(TARGET uv PROPERTY OUTPUT_NAME "uv_a") -+endif() -+target_compile_definitions(uv PRIVATE ${uv_defines}) - target_compile_options(uv PRIVATE ${uv_cflags}) - target_include_directories(uv - PUBLIC -@@ -314,17 +320,6 @@ target_include_directories(uv - $) - target_link_libraries(uv ${uv_libraries}) - --add_library(uv_a STATIC ${uv_sources}) --target_compile_definitions(uv_a PRIVATE ${uv_defines}) --target_compile_options(uv_a PRIVATE ${uv_cflags}) --target_include_directories(uv_a -- PUBLIC -- $ -- $ -- PRIVATE -- $) --target_link_libraries(uv_a ${uv_libraries}) -- - if(LIBUV_BUILD_TESTS) - # Small hack: use ${uv_test_sources} now to get the runner skeleton, - # before the actual tests are added. -@@ -558,22 +553,20 @@ if(UNIX) - set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) - set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) - set(prefix ${CMAKE_INSTALL_PREFIX}) -- configure_file(libuv.pc.in libuv.pc @ONLY) - - install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -- install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) -- install(FILES ${PROJECT_BINARY_DIR}/libuv.pc -- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -- install(TARGETS uv LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) -- install(TARGETS uv_a ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -+ install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/licenses) -+ install(TARGETS uv -+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - - if(WIN32) - install(DIRECTORY include/ DESTINATION include) -- install(FILES LICENSE DESTINATION .) -- install(TARGETS uv uv_a -- RUNTIME DESTINATION lib/$ -- ARCHIVE DESTINATION lib/$) -+ install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/licenses) -+ install(TARGETS uv -+ RUNTIME DESTINATION bin -+ ARCHIVE DESTINATION lib) - endif() - - message(STATUS "summary of build options: diff --git a/recipes/libuv/all/patches/1.40.0/fix-ios.patch b/recipes/libuv/all/patches/1.40.0/fix-ios.patch new file mode 100644 index 0000000000000..616e7c2083eea --- /dev/null +++ b/recipes/libuv/all/patches/1.40.0/fix-ios.patch @@ -0,0 +1,28 @@ +patch from https://github.com/libuv/libuv/commit/1addf9b88a17bc32d009d377a14d540ccddd06db +fixed in 1.42.0 + +--- a/src/unix/darwin.c ++++ b/src/unix/darwin.c +@@ -33,9 +33,7 @@ + #include + #include /* sysconf */ + +-#if !TARGET_OS_IPHONE + #include "darwin-stub.h" +-#endif + + static uv_once_t once = UV_ONCE_INIT; + static uint64_t (*time_func)(void); +@@ -223,10 +221,10 @@ static int uv__get_cpu_speed(uint64_t* speed) { + err = UV_ENOENT; + core_foundation_handle = dlopen("/System/Library/Frameworks/" + "CoreFoundation.framework/" +- "Versions/A/CoreFoundation", ++ "CoreFoundation", + RTLD_LAZY | RTLD_LOCAL); + iokit_handle = dlopen("/System/Library/Frameworks/IOKit.framework/" +- "Versions/A/IOKit", ++ "IOKit", + RTLD_LAZY | RTLD_LOCAL); + + if (core_foundation_handle == NULL || iokit_handle == NULL) diff --git a/recipes/libuv/all/patches/1.42.0/fix-cmake.patch b/recipes/libuv/all/patches/1.42.0/fix-cmake.patch new file mode 100644 index 0000000000000..e344df35558d4 --- /dev/null +++ b/recipes/libuv/all/patches/1.42.0/fix-cmake.patch @@ -0,0 +1,81 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 148d0e6..da614b3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -359,13 +359,19 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD") + list(APPEND uv_test_libraries util) + endif() + +-add_library(uv SHARED ${uv_sources}) +-target_compile_definitions(uv +- INTERFACE +- USING_UV_SHARED=1 +- PRIVATE +- BUILDING_UV_SHARED=1 +- ${uv_defines}) ++add_library(uv ${uv_sources}) ++get_target_property(target_type uv TYPE) ++if (target_type STREQUAL "SHARED_LIBRARY") ++ target_compile_definitions(uv ++ INTERFACE ++ USING_UV_SHARED=1 ++ PRIVATE ++ BUILDING_UV_SHARED=1 ++ ) ++else() ++ set_property(TARGET uv PROPERTY OUTPUT_NAME "uv_a") ++endif() ++target_compile_definitions(uv PRIVATE ${uv_defines}) + target_compile_options(uv PRIVATE ${uv_cflags}) + target_include_directories(uv + PUBLIC +@@ -379,21 +385,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + endif() + target_link_libraries(uv ${uv_libraries}) + +-add_library(uv_a STATIC ${uv_sources}) +-target_compile_definitions(uv_a PRIVATE ${uv_defines}) +-target_compile_options(uv_a PRIVATE ${uv_cflags}) +-target_include_directories(uv_a +- PUBLIC +- $ +- $ +- PRIVATE +- $) +-if(CMAKE_SYSTEM_NAME STREQUAL "OS390") +- target_include_directories(uv_a PUBLIC $) +- set_target_properties(uv_a PROPERTIES LINKER_LANGUAGE CXX) +-endif() +-target_link_libraries(uv_a ${uv_libraries}) +- + if(LIBUV_BUILD_TESTS) + # Small hack: use ${uv_test_sources} now to get the runner skeleton, + # before the actual tests are added. +@@ -646,19 +637,18 @@ if(UNIX OR MINGW) + configure_file(libuv-static.pc.in libuv-static.pc @ONLY) + + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +- install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) +- install(FILES ${PROJECT_BINARY_DIR}/libuv.pc ${PROJECT_BINARY_DIR}/libuv-static.pc +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +- install(TARGETS uv LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +- install(TARGETS uv_a ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++ install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/licenses) ++ install(TARGETS uv ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() + + if(MSVC) + install(DIRECTORY include/ DESTINATION include) +- install(FILES LICENSE DESTINATION .) +- install(TARGETS uv uv_a +- RUNTIME DESTINATION lib/$ +- ARCHIVE DESTINATION lib/$) ++ install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/licenses) ++ install(TARGETS uv ++ RUNTIME DESTINATION bin ++ ARCHIVE DESTINATION lib) + endif() + + message(STATUS "summary of build options: diff --git a/recipes/libuv/all/patches/1.43.0/fix-cmake.patch b/recipes/libuv/all/patches/1.43.0/fix-cmake.patch new file mode 100644 index 0000000000000..97e97844e2385 --- /dev/null +++ b/recipes/libuv/all/patches/1.43.0/fix-cmake.patch @@ -0,0 +1,50 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -372,13 +372,18 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD") + list(APPEND uv_test_libraries util) + endif() + +-add_library(uv SHARED ${uv_sources}) ++add_library(uv ${uv_sources}) ++if(BUILD_SHARED_LIBS) + target_compile_definitions(uv + INTERFACE + USING_UV_SHARED=1 + PRIVATE + BUILDING_UV_SHARED=1 + ${uv_defines}) ++else() ++ set_property(TARGET uv PROPERTY OUTPUT_NAME "uv_a") ++ target_compile_definitions(uv PRIVATE ${uv_defines}) ++endif() + target_compile_options(uv PRIVATE ${uv_cflags}) + target_include_directories(uv + PUBLIC +@@ -392,6 +397,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + endif() + target_link_libraries(uv ${uv_libraries}) + ++if(0) + add_library(uv_a STATIC ${uv_sources}) + target_compile_definitions(uv_a PRIVATE ${uv_defines}) + target_compile_options(uv_a PRIVATE ${uv_cflags}) +@@ -406,6 +412,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + set_target_properties(uv_a PROPERTIES LINKER_LANGUAGE CXX) + endif() + target_link_libraries(uv_a ${uv_libraries}) ++endif() + + if(LIBUV_BUILD_TESTS) + # Small hack: use ${uv_test_sources} now to get the runner skeleton, +@@ -663,9 +670,9 @@ install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) + install(FILES ${PROJECT_BINARY_DIR}/libuv.pc ${PROJECT_BINARY_DIR}/libuv-static.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(TARGETS uv EXPORT libuvConfig +- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +-install(TARGETS uv_a ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(EXPORT libuvConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libuv) + + if(MSVC) diff --git a/recipes/libuv/all/patches/1.44.1/fix-cmake.patch b/recipes/libuv/all/patches/1.44.1/fix-cmake.patch new file mode 100644 index 0000000000000..1eca678eae5d9 --- /dev/null +++ b/recipes/libuv/all/patches/1.44.1/fix-cmake.patch @@ -0,0 +1,47 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -382,13 +382,18 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD") + list(APPEND uv_test_libraries util) + endif() + +-add_library(uv SHARED ${uv_sources}) ++add_library(uv ${uv_sources}) ++if(BUILD_SHARED_LIBS) + target_compile_definitions(uv + INTERFACE + USING_UV_SHARED=1 + PRIVATE + BUILDING_UV_SHARED=1 + ${uv_defines}) ++else() ++ set_property(TARGET uv PROPERTY OUTPUT_NAME "uv_a") ++ target_compile_definitions(uv PRIVATE ${uv_defines}) ++endif() + target_compile_options(uv PRIVATE ${uv_cflags}) + target_include_directories(uv + PUBLIC +@@ -402,6 +407,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + endif() + target_link_libraries(uv ${uv_libraries}) + ++if(0) + add_library(uv_a STATIC ${uv_sources}) + target_compile_definitions(uv_a PRIVATE ${uv_defines}) + target_compile_options(uv_a PRIVATE ${uv_cflags}) +@@ -416,6 +422,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + set_target_properties(uv_a PROPERTIES LINKER_LANGUAGE CXX) + endif() + target_link_libraries(uv_a ${uv_libraries}) ++endif() + + if(LIBUV_BUILD_TESTS) + # Small hack: use ${uv_test_sources} now to get the runner skeleton, +@@ -677,8 +684,6 @@ install(TARGETS uv EXPORT libuvConfig + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +-install(TARGETS uv_a EXPORT libuvConfig +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(EXPORT libuvConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libuv) + + if(MSVC) diff --git a/recipes/libuv/all/patches/1.44.2/fix-cmake.patch b/recipes/libuv/all/patches/1.44.2/fix-cmake.patch new file mode 100644 index 0000000000000..8bae960541ddc --- /dev/null +++ b/recipes/libuv/all/patches/1.44.2/fix-cmake.patch @@ -0,0 +1,49 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7f46682..3477beb 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -388,13 +388,18 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD") + list(APPEND uv_test_libraries util) + endif() + +-add_library(uv SHARED ${uv_sources}) ++add_library(uv ${uv_sources}) ++if(BUILD_SHARED_LIBS) + target_compile_definitions(uv + INTERFACE + USING_UV_SHARED=1 + PRIVATE + BUILDING_UV_SHARED=1 + ${uv_defines}) ++else() ++ set_property(TARGET uv PROPERTY OUTPUT_NAME "uv_a") ++ target_compile_definitions(uv PRIVATE ${uv_defines}) ++endif() + target_compile_options(uv PRIVATE ${uv_cflags}) + target_include_directories(uv + PUBLIC +@@ -408,6 +413,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + endif() + target_link_libraries(uv ${uv_libraries}) + ++if(0) + add_library(uv_a STATIC ${uv_sources}) + target_compile_definitions(uv_a PRIVATE ${uv_defines}) + target_compile_options(uv_a PRIVATE ${uv_cflags}) +@@ -422,6 +428,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390") + set_target_properties(uv_a PROPERTIES LINKER_LANGUAGE CXX) + endif() + target_link_libraries(uv_a ${uv_libraries}) ++endif() + + if(LIBUV_BUILD_TESTS) + # Small hack: use ${uv_test_sources} now to get the runner skeleton, +@@ -685,8 +692,6 @@ install(TARGETS uv EXPORT libuvConfig + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +-install(TARGETS uv_a EXPORT libuvConfig +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(EXPORT libuvConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libuv) + + if(MSVC) diff --git a/recipes/libuv/all/test_package/CMakeLists.txt b/recipes/libuv/all/test_package/CMakeLists.txt index 7380ab13ac02e..582a892fd9c5b 100644 --- a/recipes/libuv/all/test_package/CMakeLists.txt +++ b/recipes/libuv/all/test_package/CMakeLists.txt @@ -1,9 +1,11 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libuv REQUIRED CONFIG) -add_executable(${PROJECT_NAME} example.c) - -conan_target_link_libraries(${PROJECT_NAME}) +add_executable(${PROJECT_NAME} test_package.c) +if(TARGET uv_a) + target_link_libraries(${PROJECT_NAME} PRIVATE uv_a) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE uv) +endif() diff --git a/recipes/libuv/all/test_package/conanfile.py b/recipes/libuv/all/test_package/conanfile.py index aba172466e849..0a6bc68712d90 100644 --- a/recipes/libuv/all/test_package/conanfile.py +++ b/recipes/libuv/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -class libuvTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libuv/all/test_package/example.c b/recipes/libuv/all/test_package/example.c deleted file mode 100644 index 7e85449e13543..0000000000000 --- a/recipes/libuv/all/test_package/example.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include - -int main() { - #ifdef _WIN32 - // probably bug: - // src/win/winapi.c assumes - // that advapi32.dll has been already loaded, - // so load it before using anything from winapi.c - // for static build - LoadLibrary("advapi32.dll"); - #endif - - uv_loop_t *loop = malloc(sizeof(uv_loop_t)); - uv_loop_init(loop); - - printf("Package test completed successfully\n"); - uv_run(loop, UV_RUN_DEFAULT); - - uv_loop_close(loop); - free(loop); - - return 0; -} diff --git a/recipes/libuv/all/test_package/test_package.c b/recipes/libuv/all/test_package/test_package.c new file mode 100644 index 0000000000000..7f637ecb9d603 --- /dev/null +++ b/recipes/libuv/all/test_package/test_package.c @@ -0,0 +1,25 @@ +#include +#include +#include + +int main() { +#ifdef _WIN32 + // probably bug: + // src/win/winapi.c assumes + // that advapi32.dll has been already loaded, + // so load it before using anything from winapi.c + // for static build + LoadLibrary("advapi32.dll"); +#endif + + uv_loop_t *loop = malloc(sizeof(uv_loop_t)); + uv_loop_init(loop); + + printf("Package test completed successfully\n"); + uv_run(loop, UV_RUN_DEFAULT); + + uv_loop_close(loop); + free(loop); + + return 0; +} diff --git a/recipes/libuv/all/test_v1_package/CMakeLists.txt b/recipes/libuv/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..cc50e3b1333c0 --- /dev/null +++ b/recipes/libuv/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libuv REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +if(TARGET uv_a) + target_link_libraries(${PROJECT_NAME} PRIVATE uv_a) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE uv) +endif() diff --git a/recipes/libuv/all/test_v1_package/conanfile.py b/recipes/libuv/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libuv/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libuv/config.yml b/recipes/libuv/config.yml index 0f0fa91fec26f..cc83d80cfe19b 100644 --- a/recipes/libuv/config.yml +++ b/recipes/libuv/config.yml @@ -1,11 +1,17 @@ versions: - "1.34.2": - folder: all - "1.38.0": - folder: all - "1.38.1": - folder: all - "1.40.0": - folder: all - "1.41.0": - folder: all + "1.44.2": + folder: all + "1.44.1": + folder: all + "1.43.0": + folder: all + "1.42.0": + folder: all + "1.41.1": + folder: all + "1.41.0": + folder: all + "1.40.0": + folder: all + "1.38.1": + folder: all diff --git a/recipes/libuvc/all/conanfile.py b/recipes/libuvc/all/conanfile.py index c517fc95eb500..3dc2f88c2a0c9 100644 --- a/recipes/libuvc/all/conanfile.py +++ b/recipes/libuvc/all/conanfile.py @@ -1,21 +1,31 @@ -import os from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.43.0" -required_conan_version = ">=1.28.0" class LibuvcConan(ConanFile): name = "libuvc" description = "A cross-platform library for USB video devices" - topics = ("conan", "libuvc", "libusb", "usb", "video") + topics = ("libuvc", "libusb", "usb", "video") license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/libuvc/libuvc" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False], "jpeg_turbo": [True, False]} - default_options = {"shared": False, "fPIC": True, "jpeg_turbo": False} + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "jpeg_turbo": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "jpeg_turbo": False, + } + generators = "cmake", "cmake_find_package" - exports_sources = ["CMakeLists.txt", "patches/*"] _cmake = None @property @@ -26,32 +36,42 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.settings.compiler == "Visual Studio": - # Upstream issues, e.g.: - # https://github.com/libuvc/libuvc/issues/100 - # https://github.com/libuvc/libuvc/issues/105 - raise ConanInvalidConfiguration("libuvc is not compatible with Visual Studio.") if self.options.shared: del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd def requirements(self): - self.requires("libusb/1.0.23") + self.requires("libusb/1.0.24") if self.options.jpeg_turbo: - self.requires("libjpeg-turbo/2.0.5") + self.requires("libjpeg-turbo/2.1.2") else: self.requires("libjpeg/9d") + def validate(self): + if self._is_msvc: + # Upstream issues, e.g.: + # https://github.com/libuvc/libuvc/issues/100 + # https://github.com/libuvc/libuvc/issues/105 + raise ConanInvalidConfiguration("libuvc is not compatible with Visual Studio.") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if not self._cmake: @@ -74,16 +94,22 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + cmake_target = "UVCShared" if self.options.shared else "UVCStatic" + self.cpp_info.set_property("cmake_file_name", "libuvc") + self.cpp_info.set_property("cmake_target_name", "LibUVC::{}".format(cmake_target)) + self.cpp_info.set_property("pkg_config_name", "libuvc") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["_libuvc"].libs = tools.collect_libs(self) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.filenames["cmake_find_package"] = "libuvc" self.cpp_info.filenames["cmake_find_package_multi"] = "libuvc" self.cpp_info.names["cmake_find_package"] = "LibUVC" self.cpp_info.names["cmake_find_package_multi"] = "LibUVC" - self.cpp_info.names["pkg_config"] = "libuvc" - cmake_target = "UVCShared" if self.options.shared else "UVCStatic" self.cpp_info.components["_libuvc"].names["cmake_find_package"] = cmake_target self.cpp_info.components["_libuvc"].names["cmake_find_package_multi"] = cmake_target - self.cpp_info.components["_libuvc"].names["pkg_config"] = "libuvc" - self.cpp_info.components["_libuvc"].libs = tools.collect_libs(self) + self.cpp_info.components["_libuvc"].set_property("cmake_target_name", "LibUVC::{}".format(cmake_target)) + self.cpp_info.components["_libuvc"].set_property("pkg_config_name", "libuvc") self.cpp_info.components["_libuvc"].requires = [ "libusb::libusb", "libjpeg-turbo::libjpeg-turbo" if self.options.jpeg_turbo else "libjpeg::libjpeg" diff --git a/recipes/libuvc/all/test_package/CMakeLists.txt b/recipes/libuvc/all/test_package/CMakeLists.txt index 7182c6669bce8..014804b013c2d 100644 --- a/recipes/libuvc/all/test_package/CMakeLists.txt +++ b/recipes/libuvc/all/test_package/CMakeLists.txt @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(libuvc REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -if(LIBUVC_SHARED) +if(TARGET LibUVC::UVCShared) target_link_libraries(${PROJECT_NAME} LibUVC::UVCShared) else() target_link_libraries(${PROJECT_NAME} LibUVC::UVCStatic) diff --git a/recipes/libuvc/all/test_package/conanfile.py b/recipes/libuvc/all/test_package/conanfile.py index 77f6880a79406..38f4483872d47 100644 --- a/recipes/libuvc/all/test_package/conanfile.py +++ b/recipes/libuvc/all/test_package/conanfile.py @@ -3,16 +3,15 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) - cmake.definitions["LIBUVC_SHARED"] = self.options["libuvc"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/assimp/5.0.x/CMakeLists.txt b/recipes/libvault/all/CMakeLists.txt similarity index 100% rename from recipes/assimp/5.0.x/CMakeLists.txt rename to recipes/libvault/all/CMakeLists.txt diff --git a/recipes/libvault/all/conandata.yml b/recipes/libvault/all/conandata.yml new file mode 100644 index 0000000000000..c828fc89b0560 --- /dev/null +++ b/recipes/libvault/all/conandata.yml @@ -0,0 +1,23 @@ +sources: + "0.52.0": + url: "https://github.com/abedra/libvault/archive/refs/tags/0.52.0.zip" + sha256: 49058ac9a1d3d1d08ac165f5f7b50e3a2a2ab0d3f9b8bb8194fa7a8de36edcf8 + "0.51.0": + url: "https://github.com/abedra/libvault/archive/refs/tags/0.51.0.zip" + sha256: 570ccc6451cf8e93b1c585bbf6ab5212ff9290b3a9b477752cf0651414b3d026 + "0.48.0": + url: "https://github.com/abedra/libvault/archive/0.48.0.zip" + sha256: 0a42be282ff0aff77b68cb7238014aa762df5c6b62e4d3561878874ca3760489 +patches: + "0.52.0": + - patch_file: "patches/fix-cmake-0.51.0.patch" + patch_type: "conan" + patch_description: "use libcurl from conan center" + "0.51.0": + - patch_file: "patches/fix-cmake-0.51.0.patch" + patch_type: "conan" + patch_description: "use libcurl from conan center" + "0.48.0": + - patch_file: "patches/fix-cmake-0.48.0.patch" + patch_type: "conan" + patch_description: "use libcurl from conan center" diff --git a/recipes/libvault/all/conanfile.py b/recipes/libvault/all/conanfile.py new file mode 100644 index 0000000000000..659305c5f732b --- /dev/null +++ b/recipes/libvault/all/conanfile.py @@ -0,0 +1,117 @@ +import os + +from conan import ConanFile, Version +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime + +required_conan_version = ">=1.53.0" + + +class LibvaultConan(ConanFile): + name = "libvault" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/abedra/libvault" + description = "A C++ library for Hashicorp Vault" + topics = ("vault", "libvault", "secrets", "passwords") + settings = "os", "arch", "compiler", "build_type" + exports_sources = ["CMakeLists.txt", "patches/**"] + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + @property + def _mac_os_minimum_required_version(self): + return "10.15" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def requirements(self): + self.requires("libcurl/7.86.0") + self.requires("catch2/3.2.0") + + def validate(self): + compiler = str(self.info.settings.compiler) + compiler_version = Version(self.settings.compiler.version.value) + + minimum_compiler_version = { + "Visual Studio": "19", + "gcc": "8", + "clang": "7.0", + "apple-clang": "12", + } + + minimum_cpp_standard = 17 + + if compiler in minimum_compiler_version and \ + compiler_version < minimum_compiler_version[compiler]: + raise ConanInvalidConfiguration( + f"{self.name} requires a compiler that supports at least C++{minimum_cpp_standard}. " + f"{compiler} {compiler_version} is not supported.") + + if compiler == "clang" and self.settings.compiler.libcxx in ["libstdc++", "libstdc++11"] and self.settings.compiler.version == "11": + raise ConanInvalidConfiguration("clang 11 with libstdc++ is not supported due to old libstdc++ missing C++17 support") + + if is_apple_os(self): + os_version = self.info.settings.get_safe("os.version") + if os_version and Version(os_version) < self._mac_os_minimum_required_version: + raise ConanInvalidConfiguration( + "Macos Mojave (10.14) and earlier cannot to be built because C++ standard library too old.") + + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, minimum_cpp_standard) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_TEST"] = "OFF" + tc.variables["ENABLE_INTEGRATION_TEST"] = "OFF" + tc.variables["ENABLE_COVERAGE"] = "OFF" + tc.variables["LINK_CURL"] = "OFF" + tc.variables["CMAKE_OSX_DEPLOYMENT_TARGET"] = self._mac_os_minimum_required_version + if is_msvc(self): + tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + tc = CMakeDeps(self) + tc.generate() + tc = VirtualBuildEnv(self) + tc.generate(scope="build") + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=self.build_folder) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.libs = ["vault"] + self.cpp_info.system_libs = ["m"] + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version).major == "8": + self.cpp_info.system_libs.append("stdc++fs") + # TODO: Remove after Conan 2.0 + self.cpp_info.names["cmake_find_package"] = "libvault" + self.cpp_info.names["cmake_find_package_multi"] = "libvault" + + self.cpp_info.set_property("pkg_config_name", "vault") + self.cpp_info.set_property("cmake_file_name", "libvault") + self.cpp_info.set_property("cmake_target_name", "libvault::libvault") diff --git a/recipes/libvault/all/patches/fix-cmake-0.48.0.patch b/recipes/libvault/all/patches/fix-cmake-0.48.0.patch new file mode 100644 index 0000000000000..510090973c349 --- /dev/null +++ b/recipes/libvault/all/patches/fix-cmake-0.48.0.patch @@ -0,0 +1,63 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,7 +4,6 @@ + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +-set(CMAKE_CXX_FLAGS_DEBUG --coverage) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + + option(ENABLE_TEST "Enable tests?" ON) +@@ -14,13 +13,6 @@ + option(BUILD_SHARED_LIBS "Build vault as a shared library" ON) + option(INSTALL "Run install targets" ON) + +-find_package(CURL) +-if (CURL_FOUND) +- include_directories(${CURL_INCLUDE_DIR}) +-else (CURL_FOUND) +- message(FATAL_ERROR "CURL not found") +-endif (CURL_FOUND) +- + include(GNUInstallDirs) + include_directories("${PROJECT_SOURCE_DIR}/lib") + +@@ -120,11 +112,20 @@ + + target_include_directories(vault PRIVATE src) + ++OPTION(UseCurl "UseCurl" ON) ++IF (UseCurl) ++ FIND_PACKAGE(CURL) ++ IF (CURL_FOUND) ++ target_link_libraries(vault CURL::libcurl) ++ ENDIF() ++ENDIF() ++ + if(LINK_CURL) + target_link_libraries(vault curl) + endif(LINK_CURL) + + if (ENABLE_COVERAGE) ++ set(CMAKE_CXX_FLAGS_DEBUG --coverage) + target_link_libraries(vault gcov) + endif () + +@@ -155,7 +156,7 @@ + "${CMAKE_CURRENT_BINARY_DIR}/libvaultConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/libvault") + +- configure_file(vault.pc.in vault.pc @ONLY) ++ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/vault.pc.in" "${CMAKE_BINARY_DIR}/vault.pc" @ONLY) + install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + endif (INSTALL) +@@ -176,7 +177,7 @@ + target_include_directories(libvault_test PRIVATE include) + + target_link_libraries(libvault_test vault) +- target_link_libraries(libvault_test curl) ++ target_link_libraries(libvault_test CURL::libcurl) + target_link_libraries(libvault_test Catch2::Catch2) + + include(CTest) diff --git a/recipes/libvault/all/patches/fix-cmake-0.51.0.patch b/recipes/libvault/all/patches/fix-cmake-0.51.0.patch new file mode 100644 index 0000000000000..74ce9e72d06db --- /dev/null +++ b/recipes/libvault/all/patches/fix-cmake-0.51.0.patch @@ -0,0 +1,49 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -13,13 +13,6 @@ option(LINK_CURL "Link curl library for vault" OFF) + option(BUILD_SHARED_LIBS "Build vault as a shared library" ON) + option(INSTALL "Run install targets" ON) + +-find_package(CURL) +-if (CURL_FOUND) +- include_directories(${CURL_INCLUDE_DIR}) +-else (CURL_FOUND) +- message(FATAL_ERROR "CURL not found") +-endif (CURL_FOUND) +- + include(GNUInstallDirs) + include_directories("${PROJECT_SOURCE_DIR}/lib") + +@@ -119,6 +112,14 @@ set_target_properties(vault PROPERTIES + + target_include_directories(vault PRIVATE src) + ++OPTION(UseCurl "UseCurl" ON) ++IF (UseCurl) ++ FIND_PACKAGE(CURL) ++ IF (CURL_FOUND) ++ target_link_libraries(vault CURL::libcurl) ++ ENDIF() ++ENDIF() ++ + if(LINK_CURL) + target_link_libraries(vault curl) + endif(LINK_CURL) +@@ -155,7 +156,7 @@ if (INSTALL) + "${CMAKE_CURRENT_BINARY_DIR}/libvaultConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/libvault") + +- configure_file(vault.pc.in vault.pc @ONLY) ++ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/vault.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/vault.pc" @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + endif (INSTALL) +@@ -176,7 +177,7 @@ if (ENABLE_TEST) + target_include_directories(libvault_test PRIVATE include) + + target_link_libraries(libvault_test vault) +- target_link_libraries(libvault_test curl) ++ target_link_libraries(libvault_test CURL::libcurl) + target_link_libraries(libvault_test Catch2::Catch2) + target_link_libraries(libvault_test stdc++fs) + diff --git a/recipes/libvault/all/test_package/CMakeLists.txt b/recipes/libvault/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..265e54ec6a967 --- /dev/null +++ b/recipes/libvault/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +find_package(libvault REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libvault::libvault) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/libvault/all/test_package/conanfile.py b/recipes/libvault/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/libvault/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libvault/all/test_package/test_package.cpp b/recipes/libvault/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..354d2b5a580fe --- /dev/null +++ b/recipes/libvault/all/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main(void) { + Vault::Config config = Vault::ConfigBuilder().build(); + return EXIT_SUCCESS; +} diff --git a/recipes/libvault/all/test_v1_package/CMakeLists.txt b/recipes/libvault/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/libvault/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/libvault/all/test_v1_package/conanfile.py b/recipes/libvault/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/recipes/libvault/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libvault/config.yml b/recipes/libvault/config.yml new file mode 100644 index 0000000000000..327b1962634e5 --- /dev/null +++ b/recipes/libvault/config.yml @@ -0,0 +1,7 @@ +versions: + "0.52.0": + folder: "all" + "0.51.0": + folder: "all" + "0.48.0": + folder: "all" diff --git a/recipes/libverto/all/conandata.yml b/recipes/libverto/all/conandata.yml new file mode 100644 index 0000000000000..9d2dec7091b4a --- /dev/null +++ b/recipes/libverto/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.3.2": + url: "https://github.com/latchset/libverto/releases/download/0.3.2/libverto-0.3.2.tar.gz" + sha256: "8d1756fd704f147549f606cd987050fb94b0b1ff621ea6aa4d6bf0b74450468a" diff --git a/recipes/libverto/all/conanfile.py b/recipes/libverto/all/conanfile.py new file mode 100644 index 0000000000000..8e6ade5b45b3c --- /dev/null +++ b/recipes/libverto/all/conanfile.py @@ -0,0 +1,203 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import contextlib +import os + + +required_conan_version = ">=1.33.0" + + +class LibVertoConan(ConanFile): + name = "libverto" + description = "An async event loop abstraction library." + homepage = "https://github.com/latchset/libverto" + topics = ("libverto", "async", "eventloop") + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + options = { + "shared": [True, False], + "fPIC": [True, False], + "pthread": [True, False], + "with_glib": ["builtin", "external", False], + "with_libev": ["builtin", "external", False], + "with_libevent": ["builtin", "external", False], + "with_tevent": ["external", False], # tevent cannot be a builtin backend + "default": ["glib", "libev", "libevent", "tevent"], + } + default_options = { + "shared": False, + "fPIC": True, + "pthread": True, + "with_glib": False, + "with_libev": False, + "with_libevent": "builtin", + "with_tevent": False, + "default": "libevent", + } + settings = "os", "arch", "compiler", "build_type" + + exports_sources = "patches/*" + generators = "pkg_config" + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _backend_dict(self): + return { + "glib": self.options.with_glib, + "libev": self.options.with_libev, + "libevent": self.options.with_libevent, + "tevent": self.options.with_tevent, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.os != "Linux": + del self.options.pthread + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def validate(self): + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("libverto does not support Visual Studio") + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("Shared libraries are not supported on Windows") + + if not self._backend_dict[str(self.options.default)]: + raise ConanInvalidConfiguration("Default backend({}) must be available".format(self.options.default)) + + count = lambda iterable: sum(1 if it else 0 for it in iterable) + count_builtins = count(str(opt) == "builtin" for opt in self._backend_dict.values()) + count_externals = count(str(opt) == "external" for opt in self._backend_dict.values()) + if count_builtins > 1: + raise ConanInvalidConfiguration("Cannot have more then one builtin backend") + if not self.options.shared: + if count_externals > 0: + raise ConanInvalidConfiguration("Cannot have an external backend when building a static libverto") + if count_builtins > 0 and count_externals > 0: + raise ConanInvalidConfiguration("Cannot combine builtin and external backends") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def requirements(self): + if self.options.with_glib: + self.requires("glib/2.69.2") + if self.options.with_libevent: + self.requires("libevent/2.1.12") + if self.options.with_libev: + self.requires("libev/4.33") + if self.options.with_tevent: + # FIXME: missing tevent recipe + raise ConanInvalidConfiguration("tevent is not (yet) available on conan-center") + + def build_requirements(self): + self.build_requires("pkgconf/1.7.4") + self.build_requires("libtool/2.4.6") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self): + env = { + "CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), + "LD": "{} link -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)), + "AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)), + } + with tools.environment_append(env): + yield + else: + yield + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + self._autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" + yes_no_builtin = lambda v: {"external": "yes", "False": "no", "builtin": "builtin"}[str(v)] + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--with-pthread={}".format(yes_no(self.options.get_safe("pthread", False))), + "--with-glib={}".format(yes_no_builtin(self.options.with_glib)), + "--with-libev={}".format(yes_no_builtin(self.options.with_libev)), + "--with-libevent={}".format(yes_no_builtin(self.options.with_libevent)), + "--with-tevent={}".format(yes_no_builtin(self.options.with_tevent)), + ] + self._autotools.configure(args=args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + with tools.chdir(self._source_subfolder): + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), run_environment=True, win_bash=tools.os_info.is_windows) + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_id(self): + del self.info.options.default + + def package_info(self): + self.cpp_info.components["verto"].libs = ["verto"] + self.cpp_info.components["verto"].names["pkg_config"] = "libverto" + if self.settings.os == "Linux": + self.cpp_info.components["verto"].system_libs.append("dl") + if self.options.pthread: + self.cpp_info.components["verto"].system_libs.append("pthread") + + if self.options.with_glib == "builtin": + self.cpp_info.components["verto"].requires.append("glib::glib") + elif self.options.with_glib: + self.cpp_info.components["verto-glib"].libs = ["verto-glib"] + self.cpp_info.components["verto-glib"].names["pkg_config"] = "libverto-glib" + self.cpp_info.components["verto-glib"].requires = ["verto", "glib::glib"] + + if self.options.with_libev == "builtin": + self.cpp_info.components["verto"].requires.append("libev::libev") + elif self.options.with_libev: + self.cpp_info.components["verto-libev"].libs = ["verto-libev"] + self.cpp_info.components["verto-libev"].names["pkg_config"] = "libverto-libev" + self.cpp_info.components["verto-libev"].requires = ["verto", "libev::libev"] + + if self.options.with_libevent == "builtin": + self.cpp_info.components["verto"].requires.append("libevent::libevent") + elif self.options.with_libevent: + self.cpp_info.components["verto-libevent"].libs = ["verto-libevent"] + self.cpp_info.components["verto-libevent"].names["pkg_config"] = "libverto-libevent" + self.cpp_info.components["verto-libevent"].requires = ["verto", "libevent::libevent"] + + if self.options.with_tevent: + self.cpp_info.components["verto-tevent"].libs = ["verto-tevent"] + self.cpp_info.components["verto-tevent"].names["pkg_config"] = "libverto-tevent" + self.cpp_info.components["verto-tevent"].requires = ["verto", "tevent::tevent"] + + self.user_info.backends = ",".join(tuple(backend for backend, opt in self._backend_dict.items() if opt != False)) diff --git a/recipes/libverto/all/test_package/CMakeLists.txt b/recipes/libverto/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b9b613cbb24a --- /dev/null +++ b/recipes/libverto/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libverto/all/test_package/conanfile.py b/recipes/libverto/all/test_package/conanfile.py new file mode 100644 index 0000000000000..8ceb9511ce02d --- /dev/null +++ b/recipes/libverto/all/test_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + + for impl in self.deps_user_info["libverto"].backends.split(","): + self.run("{} {}".format(bin_path, impl), run_environment=True) + diff --git a/recipes/libverto/all/test_package/test_package.c b/recipes/libverto/all/test_package/test_package.c new file mode 100644 index 0000000000000..1913e927c5213 --- /dev/null +++ b/recipes/libverto/all/test_package/test_package.c @@ -0,0 +1,54 @@ +#include "verto.h" + +#include +#include + +struct timeout_info { + int count; +}; + +static void on_timeout(verto_ctx *ctx, verto_ev *ev) { + struct timeout_info *tinfo = (struct timeout_info *) verto_get_private(ev); + tinfo->count++; + printf("callback called: %d\n", tinfo->count); + fflush(stdout); + if (tinfo->count != 20) { + verto_set_private(ev, NULL, NULL); + verto_ev *ev_new = verto_add_timeout(ctx, VERTO_EV_FLAG_NONE, on_timeout, 50); + verto_set_private(ev_new, tinfo, NULL); + } else { + verto_break(ctx); + } +} + +int main(int argc, char *argv[]) +{ + verto_ctx *ctx; + verto_ev *ev; + + if (argc < 2) { + fprintf(stderr, "Need to pass the backend as an argument\n"); + return 1; + } + + ctx = verto_new(argv[1], VERTO_EV_TYPE_TIMEOUT); + if (ctx == NULL) { + fprintf(stderr, "verto_new failed\n"); + return 1; + } + struct timeout_info *tinfo = (struct timeout_info*) malloc(sizeof(struct timeout_info)); + tinfo->count = 0; + ev = verto_add_timeout(ctx, VERTO_EV_FLAG_NONE, on_timeout, 50); + if (ev == NULL) { + fprintf(stderr, "verto_add_timeout failed\n"); + return 1; + } + verto_set_private(ev, tinfo, NULL); + + verto_run(ctx); + free(tinfo); + + verto_free(ctx); +// verto_cleanup(); // <= munmap_chunk(): invalid pointer here + return 0; +} diff --git a/recipes/libverto/config.yml b/recipes/libverto/config.yml new file mode 100644 index 0000000000000..5597932a8f4a7 --- /dev/null +++ b/recipes/libverto/config.yml @@ -0,0 +1,3 @@ +versions: + "0.3.2": + folder: "all" diff --git a/recipes/libvpx/all/conandata.yml b/recipes/libvpx/all/conandata.yml index 4ca0daf58345c..16a335bc9457b 100644 --- a/recipes/libvpx/all/conandata.yml +++ b/recipes/libvpx/all/conandata.yml @@ -1,8 +1,22 @@ sources: + "1.11.0": + url: "https://github.com/webmproject/libvpx/archive/v1.11.0.tar.gz" + sha256: "965e51c91ad9851e2337aebcc0f517440c637c506f3a03948062e3d5ea129a83" + "1.10.0": + url: "https://github.com/webmproject/libvpx/archive/v1.10.0.tar.gz" + sha256: "85803ccbdbdd7a3b03d930187cb055f1353596969c1f92ebec2db839fa4f834a" "1.9.0": url: "https://github.com/webmproject/libvpx/archive/v1.9.0.tar.gz" sha256: "d279c10e4b9316bf11a570ba16c3d55791e1ad6faa4404c67422eb631782c80a" patches: + "1.11.0": + - patch_file: "patches/0001-extended-support-1.10.0.patch" + base_path: "source_subfolder" + "1.10.0": + - patch_file: "patches/0001-extended-support-1.10.0.patch" + base_path: "source_subfolder" "1.9.0": - - patch_file: "patches/msvc_conan_build.patch" + - patch_file: "patches/0001-extended-support-1.9.0.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-msvc_conan_build.patch" base_path: "source_subfolder" diff --git a/recipes/libvpx/all/conanfile.py b/recipes/libvpx/all/conanfile.py index 24894166f91ba..4c8ca454f41e5 100644 --- a/recipes/libvpx/all/conanfile.py +++ b/recipes/libvpx/all/conanfile.py @@ -1,7 +1,12 @@ +from conan.tools.microsoft import msvc_runtime_flag +from conan.tools.microsoft.visual import msvc_version_to_vs_ide_version from conans import ConanFile, AutoToolsBuildEnvironment, tools from conans.errors import ConanInvalidConfiguration +import functools import os -import shutil +import re + +required_conan_version = ">=1.43.0" class LibVPXConan(ConanFile): @@ -9,25 +14,35 @@ class LibVPXConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.webmproject.org/code" description = "WebM VP8/VP9 Codec SDK" - topics = ("conan", "vpx", "codec", "web", "VP8", "VP9") + topics = ("vpx", "codec", "web", "VP8", "VP9") license = "BSD-3-Clause" - exports_sources = ["CMakeLists.txt", "patches/*.patch"] + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False]} - default_options = {'shared': False, - 'fPIC': True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - _source_subfolder = "source_subfolder" _arch_options = ['mmx', 'sse', 'sse2', 'sse3', 'ssse3', 'sse4_1', 'avx', 'avx2', 'avx512'] options.update({name: [True, False] for name in _arch_options}) default_options.update({name: 'avx' not in name for name in _arch_options}) + @property + def _source_subfolder(self): + return "source_subfolder" - def configure(self): - if self.settings.os == 'Windows' and self.options.shared: - raise ConanInvalidConfiguration('Windows shared builds are not supported') + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == 'Windows': @@ -36,39 +51,69 @@ def config_options(self): for name in self._arch_options: delattr(self.options, name) + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("Windows shared builds are not supported") + if str(self.settings.compiler) not in ["Visual Studio", "msvc", "gcc", "clang", "apple-clang"]: + raise ConanInvalidConfiguration("Unsupported compiler {}.".format(self.settings.compiler)) + if self.settings.os == "Macos" and self.settings.arch == "armv8" and tools.Version(self.version) < "1.10.0": + raise ConanInvalidConfiguration("M1 only supported since 1.10, please upgrade") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def build_requirements(self): - self.build_requires('yasm/1.3.0') - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH") and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires('msys2/20200517') + self.build_requires("yasm/1.3.0") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + # relocatable shared lib on macOS + tools.replace_in_file(os.path.join(self._source_subfolder, "build", "make", "Makefile"), + "-dynamiclib", + "-dynamiclib -install_name @rpath/$$(LIBVPX_SO)") + # Disable LTO for Visual Studio when CFLAGS doesn't contain -GL + if self._is_msvc: + lto = any(re.finditer("(^| )[/-]GL($| )", tools.get_env("CFLAGS", ""))) + if not lto: + tools.replace_in_file( + os.path.join(self._source_subfolder, "build", "make", "gen_msvs_vcxproj.sh"), + "tag_content WholeProgramOptimization true", + "tag_content WholeProgramOptimization false", + ) + + @functools.lru_cache(1) def _configure_autotools(self): - win_bash = tools.os_info.is_windows - prefix = os.path.abspath(self.package_folder) - if win_bash: - prefix = tools.unix_path(prefix) - args = ['--prefix=%s' % prefix, - '--disable-examples', - '--disable-unit-tests', - '--disable-tools', - '--enable-vp9-highbitdepth', - '--as=yasm'] + args = [ + "--prefix={}".format(tools.unix_path(self.package_folder)), + "--disable-examples", + "--disable-unit-tests", + "--disable-tools", + "--disable-docs", + "--enable-vp9-highbitdepth", + "--as=yasm", + ] if self.options.shared: args.extend(['--disable-static', '--enable-shared']) else: args.extend(['--disable-shared', '--enable-static']) - if self.settings.os != 'Windows' and self.options.fPIC: + if self.settings.os != 'Windows' and self.options.get_safe("fPIC", True): args.append('--enable-pic') if self.settings.build_type == "Debug": args.append('--enable-debug') - if self.settings.compiler == 'Visual Studio': - if 'MT' in str(self.settings.compiler.runtime): - args.append('--enable-static-msvcrt') + if self._is_msvc and "MT" in msvc_runtime_flag(self): + args.append('--enable-static-msvcrt') arch = {'x86': 'x86', 'x86_64': 'x86_64', @@ -77,58 +122,79 @@ def _configure_autotools(self): 'mips': 'mips32', 'mips64': 'mips64', 'sparc': 'sparc'}.get(str(self.settings.arch)) - build_compiler = str(self.settings.compiler) - if build_compiler == 'Visual Studio': - compiler = 'vs' + str(self.settings.compiler.version) - elif build_compiler in ['gcc', 'clang', 'apple-clang']: + if self._is_msvc: + if self.settings.compiler == "Visual Studio": + vc_version = self.settings.compiler.version + else: + vc_version = msvc_version_to_vs_ide_version(self.settings.compiler.version) + compiler = "vs{}".format(vc_version) + elif self.settings.compiler in ["gcc", "clang", "apple-clang"]: compiler = 'gcc' - else: - raise ConanInvalidConfiguration("Unsupported compiler '{}'.".format(build_compiler)) - build_os = str(self.settings.os) - if build_os == 'Windows': + host_os = str(self.settings.os) + if host_os == 'Windows': os_name = 'win32' if self.settings.arch == 'x86' else 'win64' - elif build_os in ['Macos', 'iOS', 'watchOS', 'tvOS']: - os_name = 'darwin11' - elif build_os == 'Linux': + elif tools.is_apple_os(host_os): + if self.settings.arch in ["x86", "x86_64"]: + os_name = 'darwin11' + elif self.settings.arch == "armv8" and self.settings.os == "Macos": + os_name = 'darwin20' + else: + # Unrecognized toolchain 'arm64-darwin11-gcc', see list of toolchains in ./configure --help + os_name = 'darwin' + elif host_os == 'Linux': os_name = 'linux' - elif build_os == 'Solaris': + elif host_os == 'Solaris': os_name = 'solaris' - elif build_os == 'Android': + elif host_os == 'Android': os_name = 'android' target = "%s-%s-%s" % (arch, os_name, compiler) - if tools.cross_building(self) or self.settings.compiler == 'Visual Studio': - args.append('--target=%s' % target) + args.append('--target=%s' % target) if str(self.settings.arch) in ["x86", "x86_64"]: for name in self._arch_options: if not self.options.get_safe(name): args.append('--disable-%s' % name) - with tools.vcvars(self.settings) if self.settings.compiler == 'Visual Studio' else tools.no_op(): - env_build = AutoToolsBuildEnvironment(self, win_bash=win_bash) - env_build.configure(args=args, configure_dir=self._source_subfolder, host=False, build=False, target=False) - return env_build + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + if self._is_msvc: + # gen_msvs_vcxproj.sh doesn't like custom flags + autotools.cxxflags = [] + autotools.flags = [] + if tools.is_apple_os(self.settings.os) and self.settings.get_safe("compiler.libcxx") == "libc++": + # special case, as gcc/g++ is hard-coded in makefile, it implicitly assumes -lstdc++ + autotools.link_flags.append("-stdlib=libc++") + autotools.configure(args=args, configure_dir=self._source_subfolder, host=False, build=False, target=False) + return autotools def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - with tools.vcvars(self.settings) if self.settings.compiler == 'Visual Studio' else tools.no_op(): - env_build = self._configure_autotools() - env_build.make() + self._patch_sources() + with tools.vcvars(self) if self._is_msvc else tools.no_op(): + autotools = self._configure_autotools() + autotools.make() def package(self): - with tools.chdir(self.build_folder): - env_build = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - env_build.install() - - self.copy(pattern="LICENSE", src=self._source_subfolder, dst='licenses') - if self.settings.os == 'Windows' and self.settings.compiler == 'Visual Studio': - name = 'vpxmt.lib' if 'MT' in str(self.settings.compiler.runtime) else 'vpxmd.lib' - if self.settings.arch == 'x86_64': - libdir = os.path.join(self.package_folder, 'lib', 'x64') - elif self.settings.arch == 'x86': - libdir = os.path.join(self.package_folder, 'lib', 'Win32') - shutil.move(os.path.join(libdir, name), os.path.join(self.package_folder, 'lib', 'vpx.lib')) - tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) + self.copy(pattern="LICENSE", src=self._source_subfolder, dst="licenses") + with tools.vcvars(self) if self._is_msvc else tools.no_op(): + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + if self._is_msvc: + # don't trust install target + tools.rmdir(os.path.join(self.package_folder, "lib")) + libdir = os.path.join( + "Win32" if self.settings.arch == "x86" else "x64", + "Debug" if self.settings.build_type == "Debug" else "Release", + ) + self.copy("vpx*.lib", src=libdir, dst="lib") def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.set_property("pkg_config_name", "vpx") + suffix = msvc_runtime_flag(self).lower() if self._is_msvc else "" + self.cpp_info.libs = [f"vpx{suffix}"] + if not self.options.shared: + libcxx = tools.stdcpp_library(self) + if libcxx: + self.cpp_info.system_libs.append(libcxx) + + # TODO: to remove in conan v2 once pkg_config generator removed + self.cpp_info.names["pkg_config"] = "vpx" diff --git a/recipes/libvpx/all/patches/0001-extended-support-1.10.0.patch b/recipes/libvpx/all/patches/0001-extended-support-1.10.0.patch new file mode 100644 index 0000000000000..b1eadcaa5a9be --- /dev/null +++ b/recipes/libvpx/all/patches/0001-extended-support-1.10.0.patch @@ -0,0 +1,98 @@ +--- a/build/make/configure.sh ++++ b/build/make/configure.sh +@@ -774,7 +774,7 @@ process_common_toolchain() { + tgt_isa=x86_64 + tgt_os=`echo $gcctarget | sed 's/.*\(darwin1[0-9]\).*/\1/'` + ;; +- *darwin20*) ++ *darwin2[0-1]*) + tgt_isa=`uname -m` + tgt_os=`echo $gcctarget | sed 's/.*\(darwin2[0-9]\).*/\1/'` + ;; +@@ -918,9 +918,9 @@ process_common_toolchain() { + add_cflags "-mmacosx-version-min=10.15" + add_ldflags "-mmacosx-version-min=10.15" + ;; +- *-darwin20-*) +- add_cflags "-mmacosx-version-min=10.16 -arch ${toolchain%%-*}" +- add_ldflags "-mmacosx-version-min=10.16 -arch ${toolchain%%-*}" ++ *-darwin2[0-1]-*) ++ add_cflags "-arch ${toolchain%%-*}" ++ add_ldflags "-arch ${toolchain%%-*}" + ;; + *-iphonesimulator-*) + add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}" +--- a/build/make/gen_msvs_sln.sh ++++ b/build/make/gen_msvs_sln.sh +@@ -219,6 +219,7 @@ for opt in "$@"; do + 14) vs_year=2015 ;; + 15) vs_year=2017 ;; + 16) vs_year=2019 ;; ++ 17) vs_year=2022 ;; + *) die Unrecognized Visual Studio Version in $opt ;; + esac + ;; +@@ -232,7 +233,7 @@ done + outfile=${outfile:-/dev/stdout} + mkoutfile=${mkoutfile:-/dev/stdout} + case "${vs_ver}" in +- 1[4-6]) ++ 1[4-7]) + # VS has used Format Version 12.00 continuously since vs11. + sln_vers="12.00" + sln_vers_str="Visual Studio ${vs_year}" +--- a/build/make/gen_msvs_vcxproj.sh ++++ b/build/make/gen_msvs_vcxproj.sh +@@ -170,7 +170,7 @@ for opt in "$@"; do + --ver=*) + vs_ver="$optval" + case "$optval" in +- 1[4-6]) ++ 1[4-7]) + ;; + *) die Unrecognized Visual Studio Version in $opt + ;; +@@ -344,6 +344,9 @@ generate_vcxproj() { + if [ "$vs_ver" = "16" ]; then + tag_content PlatformToolset v142 + fi ++ if [ "$vs_ver" = "17" ]; then ++ tag_content PlatformToolset v143 ++ fi + tag_content CharacterSet Unicode + if [ "$config" = "Release" ]; then + tag_content WholeProgramOptimization true +--- a/configure ++++ b/configure +@@ -100,6 +100,7 @@ EOF + all_platforms="${all_platforms} arm64-android-gcc" + all_platforms="${all_platforms} arm64-darwin-gcc" + all_platforms="${all_platforms} arm64-darwin20-gcc" ++all_platforms="${all_platforms} arm64-darwin21-gcc" + all_platforms="${all_platforms} arm64-linux-gcc" + all_platforms="${all_platforms} arm64-win64-gcc" + all_platforms="${all_platforms} arm64-win64-vs15" +@@ -139,6 +140,7 @@ all_platforms="${all_platforms} x86-win32-gcc" + all_platforms="${all_platforms} x86-win32-vs14" + all_platforms="${all_platforms} x86-win32-vs15" + all_platforms="${all_platforms} x86-win32-vs16" ++all_platforms="${all_platforms} x86-win32-vs17" + all_platforms="${all_platforms} x86_64-android-gcc" + all_platforms="${all_platforms} x86_64-darwin9-gcc" + all_platforms="${all_platforms} x86_64-darwin10-gcc" +@@ -152,6 +154,7 @@ all_platforms="${all_platforms} x86_64-darwin17-gcc" + all_platforms="${all_platforms} x86_64-darwin18-gcc" + all_platforms="${all_platforms} x86_64-darwin19-gcc" + all_platforms="${all_platforms} x86_64-darwin20-gcc" ++all_platforms="${all_platforms} x86_64-darwin21-gcc" + all_platforms="${all_platforms} x86_64-iphonesimulator-gcc" + all_platforms="${all_platforms} x86_64-linux-gcc" + all_platforms="${all_platforms} x86_64-linux-icc" +@@ -160,6 +163,7 @@ all_platforms="${all_platforms} x86_64-win64-gcc" + all_platforms="${all_platforms} x86_64-win64-vs14" + all_platforms="${all_platforms} x86_64-win64-vs15" + all_platforms="${all_platforms} x86_64-win64-vs16" ++all_platforms="${all_platforms} x86_64-win64-vs17" + all_platforms="${all_platforms} generic-gnu" + + # all_targets is a list of all targets that can be configured diff --git a/recipes/libvpx/all/patches/0001-extended-support-1.9.0.patch b/recipes/libvpx/all/patches/0001-extended-support-1.9.0.patch new file mode 100644 index 0000000000000..7e10a765c149c --- /dev/null +++ b/recipes/libvpx/all/patches/0001-extended-support-1.9.0.patch @@ -0,0 +1,58 @@ +--- a/build/make/gen_msvs_sln.sh ++++ b/build/make/gen_msvs_sln.sh +@@ -219,6 +219,7 @@ for opt in "$@"; do + 14) vs_year=2015 ;; + 15) vs_year=2017 ;; + 16) vs_year=2019 ;; ++ 17) vs_year=2022 ;; + *) die Unrecognized Visual Studio Version in $opt ;; + esac + ;; +@@ -232,7 +233,7 @@ done + outfile=${outfile:-/dev/stdout} + mkoutfile=${mkoutfile:-/dev/stdout} + case "${vs_ver}" in +- 1[4-6]) ++ 1[4-7]) + # VS has used Format Version 12.00 continuously since vs11. + sln_vers="12.00" + sln_vers_str="Visual Studio ${vs_year}" +--- a/build/make/gen_msvs_vcxproj.sh ++++ b/build/make/gen_msvs_vcxproj.sh +@@ -168,7 +168,7 @@ for opt in "$@"; do + --ver=*) + vs_ver="$optval" + case "$optval" in +- 1[4-6]) ++ 1[4-7]) + ;; + *) die Unrecognized Visual Studio Version in $opt + ;; +@@ -342,6 +342,9 @@ generate_vcxproj() { + if [ "$vs_ver" = "16" ]; then + tag_content PlatformToolset v142 + fi ++ if [ "$vs_ver" = "17" ]; then ++ tag_content PlatformToolset v143 ++ fi + tag_content CharacterSet Unicode + if [ "$config" = "Release" ]; then + tag_content WholeProgramOptimization true +--- a/configure ++++ b/configure +@@ -138,6 +138,7 @@ all_platforms="${all_platforms} x86-win32-gcc" + all_platforms="${all_platforms} x86-win32-vs14" + all_platforms="${all_platforms} x86-win32-vs15" + all_platforms="${all_platforms} x86-win32-vs16" ++all_platforms="${all_platforms} x86-win32-vs17" + all_platforms="${all_platforms} x86_64-android-gcc" + all_platforms="${all_platforms} x86_64-darwin9-gcc" + all_platforms="${all_platforms} x86_64-darwin10-gcc" +@@ -158,6 +159,7 @@ all_platforms="${all_platforms} x86_64-win64-gcc" + all_platforms="${all_platforms} x86_64-win64-vs14" + all_platforms="${all_platforms} x86_64-win64-vs15" + all_platforms="${all_platforms} x86_64-win64-vs16" ++all_platforms="${all_platforms} x86_64-win64-vs17" + all_platforms="${all_platforms} generic-gnu" + + # all_targets is a list of all targets that can be configured diff --git a/recipes/libvpx/all/patches/0002-msvc_conan_build.patch b/recipes/libvpx/all/patches/0002-msvc_conan_build.patch new file mode 100644 index 0000000000000..28885c1c83394 --- /dev/null +++ b/recipes/libvpx/all/patches/0002-msvc_conan_build.patch @@ -0,0 +1,13 @@ +diff --git a/build/make/msvs_common.sh b/build/make/msvs_common.sh +index 27ddf7f..da462ec 100644 +--- a/build/make/msvs_common.sh ++++ b/build/make/msvs_common.sh +@@ -9,7 +9,7 @@ + ## be found in the AUTHORS file in the root of the source tree. + ## + +-if [ "$(uname -o 2>/dev/null)" = "Cygwin" ] \ ++if [ "$(uname -o 2>/dev/null)" = "Cygwin" ] || [ "$(uname -o 2>/dev/null)" = "Msys" ]\ + && cygpath --help >/dev/null 2>&1; then + FIXPATH='cygpath -m' + else diff --git a/recipes/libvpx/all/patches/msvc_conan_build.patch b/recipes/libvpx/all/patches/msvc_conan_build.patch deleted file mode 100644 index c21961ceb64a0..0000000000000 --- a/recipes/libvpx/all/patches/msvc_conan_build.patch +++ /dev/null @@ -1,42 +0,0 @@ -diff --git a/build/make/gen_msvs_vcxproj.sh b/build/make/gen_msvs_vcxproj.sh -index bb1c31d..36d1dd2 100755 ---- a/build/make/gen_msvs_vcxproj.sh -+++ b/build/make/gen_msvs_vcxproj.sh -@@ -140,6 +140,15 @@ for opt in "$@"; do - optval="${opt#*=}" - case "$opt" in - --help|-h) show_help -+ ;; -+ -MD*|-MT*) echo "ignoring $opt (this option is already handled)" -+ -+ ;; -+ -Zi) echo "ignoring $opt..." -+ -+ ;; -+ -O*) echo "ignoring $opt..." -+ - ;; - --target=*) target="${optval}" - ;; -@@ -344,7 +353,7 @@ generate_vcxproj() { - fi - tag_content CharacterSet Unicode - if [ "$config" = "Release" ]; then -- tag_content WholeProgramOptimization true -+ tag_content WholeProgramOptimization false - fi - close_tag PropertyGroup - done -diff --git a/build/make/msvs_common.sh b/build/make/msvs_common.sh -index 27ddf7f..da462ec 100644 ---- a/build/make/msvs_common.sh -+++ b/build/make/msvs_common.sh -@@ -9,7 +9,7 @@ - ## be found in the AUTHORS file in the root of the source tree. - ## - --if [ "$(uname -o 2>/dev/null)" = "Cygwin" ] \ -+if [ "$(uname -o 2>/dev/null)" = "Cygwin" ] || [ "$(uname -o 2>/dev/null)" = "Msys" ]\ - && cygpath --help >/dev/null 2>&1; then - FIXPATH='cygpath -m' - else diff --git a/recipes/libvpx/all/test_package/CMakeLists.txt b/recipes/libvpx/all/test_package/CMakeLists.txt index e97ecc6c7a569..657b40cd58a00 100644 --- a/recipes/libvpx/all/test_package/CMakeLists.txt +++ b/recipes/libvpx/all/test_package/CMakeLists.txt @@ -1,9 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) - +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(libvpx REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libvpx::libvpx) diff --git a/recipes/libvpx/all/test_package/conanfile.py b/recipes/libvpx/all/test_package/conanfile.py index d4128b0450777..697dfef261b53 100644 --- a/recipes/libvpx/all/test_package/conanfile.py +++ b/recipes/libvpx/all/test_package/conanfile.py @@ -3,8 +3,17 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") def build(self): cmake = CMake(self) diff --git a/recipes/libvpx/all/test_package/test_package.c b/recipes/libvpx/all/test_package/test_package.c new file mode 100644 index 0000000000000..8c17317989095 --- /dev/null +++ b/recipes/libvpx/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include + +#include + +int main() +{ + printf("vpx version %s\n", vpx_codec_version_str()); + return 0; +} diff --git a/recipes/libvpx/all/test_package/test_package.cpp b/recipes/libvpx/all/test_package/test_package.cpp deleted file mode 100644 index 90ea00fdc8586..0000000000000 --- a/recipes/libvpx/all/test_package/test_package.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include - -#include -#include - -int main() -{ - std::cout << "vpx version " << vpx_codec_version_str() << std::endl; - return EXIT_SUCCESS; -} diff --git a/recipes/libvpx/config.yml b/recipes/libvpx/config.yml index 81634fc799e56..460cf69bd04b2 100644 --- a/recipes/libvpx/config.yml +++ b/recipes/libvpx/config.yml @@ -1,3 +1,7 @@ versions: + "1.11.0": + folder: all + "1.10.0": + folder: all "1.9.0": folder: all diff --git a/recipes/libwebp/all/CMakeLists.txt b/recipes/libwebp/all/CMakeLists.txt deleted file mode 100644 index f63dba95b5b60..0000000000000 --- a/recipes/libwebp/all/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -if (BUILD_SHARED_LIBS AND MSVC) - # Building a dll - add_definitions(-DWEBP_DLL) -endif() - -add_subdirectory("source_subfolder") diff --git a/recipes/libwebp/all/conandata.yml b/recipes/libwebp/all/conandata.yml index e1dde8f65c711..73b2540022f74 100644 --- a/recipes/libwebp/all/conandata.yml +++ b/recipes/libwebp/all/conandata.yml @@ -1,22 +1,41 @@ sources: - "1.0.3": - url: "https://github.com/webmproject/libwebp/archive/v1.0.3.tar.gz" - sha256: "082d114bcb18a0e2aafc3148d43367c39304f86bf18ba0b2e766447e111a4a91" - "1.1.0": - url: "https://github.com/webmproject/libwebp/archive/v1.1.0.tar.gz" - sha256: "424faab60a14cb92c2a062733b6977b4cc1e875a6398887c5911b3a1a6c56c51" + "1.2.4": + url: "https://github.com/webmproject/libwebp/archive/v1.2.4.tar.gz" + sha256: "dfe7bff3390cd4958da11e760b65318f0a48c32913e4d5bc5e8d55abaaa2d32e" + "1.2.3": + url: "https://github.com/webmproject/libwebp/archive/v1.2.3.tar.gz" + sha256: "021169407825d7ad918ff4554c6af885e7cf116d9b641cfd7f04c1173ffb9eb0" + "1.2.2": + url: "https://github.com/webmproject/libwebp/archive/v1.2.2.tar.gz" + sha256: "51e9297aadb7d9eb99129fe0050f53a11fcce38a0848fb2b0389e385ad93695e" + "1.2.1": + url: "https://github.com/webmproject/libwebp/archive/refs/tags/v1.2.1.tar.gz" + sha256: "01bcde6a40a602294994050b81df379d71c40b7e39c819c024d079b3c56307f4" "1.2.0": url: "https://github.com/webmproject/libwebp/archive/v1.2.0.tar.gz" sha256: "d60608c45682fa1e5d41c3c26c199be5d0184084cd8a971a6fc54035f76487d3" -patches: + "1.1.0": + url: "https://github.com/webmproject/libwebp/archive/v1.1.0.tar.gz" + sha256: "424faab60a14cb92c2a062733b6977b4cc1e875a6398887c5911b3a1a6c56c51" "1.0.3": + url: "https://github.com/webmproject/libwebp/archive/v1.0.3.tar.gz" + sha256: "082d114bcb18a0e2aafc3148d43367c39304f86bf18ba0b2e766447e111a4a91" +patches: + "1.2.4": + - patch_file: "patches/0001-fix-dll-export.patch" + "1.2.3": + - patch_file: "patches/0001-fix-dll-export.patch" + "1.2.2": - patch_file: "patches/0001-fix-dll-export.patch" - base_path: "source_subfolder" + "1.2.1": + - patch_file: "patches/0001-fix-dll-export.patch" + "1.2.0": + - patch_file: "patches/0001-fix-dll-export.patch" + - patch_file: "patches/0003-build-libwebpmux-1.2.0.patch" "1.1.0": - patch_file: "patches/0001-fix-dll-export.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-qnx.patch" - base_path: "source_subfolder" - "1.2.0": + - patch_file: "patches/0003-build-libwebpmux-1.1.0.patch" + "1.0.3": - patch_file: "patches/0001-fix-dll-export.patch" - base_path: "source_subfolder" + - patch_file: "patches/0003-build-libwebpmux-1.0.3.patch" diff --git a/recipes/libwebp/all/conanfile.py b/recipes/libwebp/all/conanfile.py index 2faab9edbc2f6..ad6abd49e96eb 100644 --- a/recipes/libwebp/all/conanfile.py +++ b/recipes/libwebp/all/conanfile.py @@ -1,5 +1,11 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.53.0" class LibwebpConan(ConanFile): @@ -9,21 +15,25 @@ class LibwebpConan(ConanFile): homepage = "https://github.com/webmproject/libwebp" topics = ("image", "libwebp", "webp", "decoding", "encoding") license = "BSD-3-Clause" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False], - "with_simd": [True, False], "near_lossless": [True, False], - "swap_16bit_csp": [True, False]} - default_options = {"shared": False, "fPIC": True, - "with_simd": True, "near_lossless": True, - "swap_16bit_csp": False} - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_simd": [True, False], + "near_lossless": [True, False], + "swap_16bit_csp": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_simd": True, + "near_lossless": True, + "swap_16bit_csp": False, + } + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -31,99 +41,95 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - @property - def _version_components(self): - return [int(x) for x in self.version.split(".")] - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) # should be an option but it doesn't work yet - self._cmake.definitions["WEBP_ENABLE_SIMD"] = self.options.with_simd - if self._version_components[0] >= 1: - self._cmake.definitions["WEBP_NEAR_LOSSLESS"] = self.options.near_lossless + tc.variables["WEBP_ENABLE_SIMD"] = self.options.with_simd + if Version(self.version) >= "1.0.0": + tc.variables["WEBP_NEAR_LOSSLESS"] = self.options.near_lossless else: - self._cmake.definitions["WEBP_ENABLE_NEAR_LOSSLESS"] = self.options.near_lossless - self._cmake.definitions["WEBP_ENABLE_SWAP_16BIT_CSP"] = self.options.swap_16bit_csp + tc.variables["WEBP_ENABLE_NEAR_LOSSLESS"] = self.options.near_lossless + tc.variables["WEBP_ENABLE_SWAP_16BIT_CSP"] = self.options.swap_16bit_csp # avoid finding system libs - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_GIF"] = True - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_PNG"] = True - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_TIFF"] = True - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_JPEG"] = True - self._cmake.definitions["WEBP_BUILD_ANIM_UTILS"] = False - self._cmake.definitions["WEBP_BUILD_CWEBP"] = False - self._cmake.definitions["WEBP_BUILD_DWEBP"] = False - self._cmake.definitions["WEBP_BUILD_IMG2WEBP"] = False - self._cmake.definitions["WEBP_BUILD_GIF2WEBP"] = False - self._cmake.definitions["WEBP_BUILD_VWEBP"] = False - self._cmake.definitions["WEBP_BUILD_EXTRAS"] = False - self._cmake.definitions["WEBP_BUILD_WEBPINFO"] = False - self._cmake.definitions["WEBP_BUILD_WEBPMUX"] = False - - self._cmake.configure() - - return self._cmake + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_GIF"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_PNG"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_TIFF"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_JPEG"] = True + tc.variables["WEBP_BUILD_ANIM_UTILS"] = False + tc.variables["WEBP_BUILD_CWEBP"] = False + tc.variables["WEBP_BUILD_DWEBP"] = False + tc.variables["WEBP_BUILD_IMG2WEBP"] = False + tc.variables["WEBP_BUILD_GIF2WEBP"] = False + tc.variables["WEBP_BUILD_VWEBP"] = False + tc.variables["WEBP_BUILD_EXTRAS"] = False + tc.variables["WEBP_BUILD_WEBPINFO"] = False + if Version(self.version) >= "1.2.1": + tc.variables["WEBP_BUILD_LIBWEBPMUX"] = True + tc.variables["WEBP_BUILD_WEBPMUX"] = False + if self.options.shared and is_msvc(self): + # Building a dll (see fix-dll-export patch) + tc.preprocessor_definitions["WEBP_DLL"] = 1 + tc.generate() def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - # build libwebpmux (not in patch file to avoid one patch per version) - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "if(WEBP_BUILD_GIF2WEBP OR WEBP_BUILD_IMG2WEBP)", - "if(TRUE)") - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "WebP" - self.cpp_info.names["cmake_find_package_multi"] = "WebP" + self.cpp_info.set_property("cmake_file_name", "WebP") + self.cpp_info.set_property("pkg_config_name", "libwebp-all-do-not-use") + # webpdecoder - self.cpp_info.components["webpdecoder"].names["cmake_find_package"] = "webpdecoder" - self.cpp_info.components["webpdecoder"].names["cmake_find_package_multi"] = "webpdecoder" - self.cpp_info.components["webpdecoder"].names["pkg_config"] = "libwebpdecoder" - self.cpp_info.components["webpdecoder"].libs = [self._lib_name("webpdecoder")] - if self.settings.os == "Linux": + self.cpp_info.components["webpdecoder"].set_property("cmake_target_name", "WebP::webpdecoder") + self.cpp_info.components["webpdecoder"].set_property("pkg_config_name", "libwebpdecoder") + self.cpp_info.components["webpdecoder"].libs = ["webpdecoder"] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["webpdecoder"].system_libs = ["pthread"] + # webp - self.cpp_info.components["webp"].names["cmake_find_package"] = "webp" - self.cpp_info.components["webp"].names["cmake_find_package_multi"] = "webp" - self.cpp_info.components["webp"].names["pkg_config"] = "libwebp" - self.cpp_info.components["webp"].libs = [self._lib_name("webp")] - if self.settings.os == "Linux": + self.cpp_info.components["webp"].set_property("cmake_target_name", "WebP::webp") + self.cpp_info.components["webp"].set_property("pkg_config_name", "libwebp") + self.cpp_info.components["webp"].libs = ["webp"] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["webp"].system_libs = ["m", "pthread"] + # webpdemux - self.cpp_info.components["webpdemux"].names["cmake_find_package"] = "webpdemux" - self.cpp_info.components["webpdemux"].names["cmake_find_package_multi"] = "webpdemux" - self.cpp_info.components["webpdemux"].names["pkg_config"] = "libwebpdemux" - self.cpp_info.components["webpdemux"].libs = [self._lib_name("webpdemux")] + self.cpp_info.components["webpdemux"].set_property("cmake_target_name", "WebP::webpdemux") + self.cpp_info.components["webpdemux"].set_property("pkg_config_name", "libwebpdemux") + self.cpp_info.components["webpdemux"].libs = ["webpdemux"] self.cpp_info.components["webpdemux"].requires = ["webp"] + # webpmux - self.cpp_info.components["webpmux"].names["cmake_find_package"] = "libwebpmux" - self.cpp_info.components["webpmux"].names["cmake_find_package_multi"] = "libwebpmux" - self.cpp_info.components["webpmux"].names["pkg_config"] = "libwebpmux" - self.cpp_info.components["webpmux"].libs = [self._lib_name("webpmux")] + self.cpp_info.components["webpmux"].set_property("cmake_target_name", "WebP::libwebpmux") + self.cpp_info.components["webpmux"].set_property("pkg_config_name", "libwebpmux") + self.cpp_info.components["webpmux"].libs = ["webpmux"] self.cpp_info.components["webpmux"].requires = ["webp"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["webpmux"].system_libs = ["m"] - def _lib_name(self, name): - if self.options.shared and self.settings.os == "Windows" and self.settings.compiler != "Visual Studio": - return name + ".dll" - return name + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "WebP" + self.cpp_info.names["cmake_find_package_multi"] = "WebP" + self.cpp_info.names["pkg_config"] = "libwebp-all-do-not-use" + self.cpp_info.components["webpmux"].names["cmake_find_package"] = "libwebpmux" + self.cpp_info.components["webpmux"].names["cmake_find_package_multi"] = "libwebpmux" diff --git a/recipes/libwebp/all/patches/0003-build-libwebpmux-1.0.3.patch b/recipes/libwebp/all/patches/0003-build-libwebpmux-1.0.3.patch new file mode 100644 index 0000000000000..0892ee3bdacd9 --- /dev/null +++ b/recipes/libwebp/all/patches/0003-build-libwebpmux-1.0.3.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -401,7 +401,7 @@ if(WEBP_BUILD_CWEBP) + install(TARGETS cwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() + +-if(WEBP_BUILD_GIF2WEBP OR WEBP_BUILD_IMG2WEBP) ++if(1) + parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/src/mux "WEBP_MUX_SRCS" "") + add_library(libwebpmux ${WEBP_MUX_SRCS}) + target_link_libraries(libwebpmux webp) diff --git a/recipes/libwebp/all/patches/0003-build-libwebpmux-1.1.0.patch b/recipes/libwebp/all/patches/0003-build-libwebpmux-1.1.0.patch new file mode 100644 index 0000000000000..a6ef960dc695c --- /dev/null +++ b/recipes/libwebp/all/patches/0003-build-libwebpmux-1.1.0.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -402,7 +402,7 @@ if(WEBP_BUILD_CWEBP) + install(TARGETS cwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() + +-if(WEBP_BUILD_GIF2WEBP OR WEBP_BUILD_IMG2WEBP) ++if(1) + parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/src/mux "WEBP_MUX_SRCS" "") + add_library(libwebpmux ${WEBP_MUX_SRCS}) + target_link_libraries(libwebpmux webp) diff --git a/recipes/libwebp/all/patches/0003-build-libwebpmux-1.2.0.patch b/recipes/libwebp/all/patches/0003-build-libwebpmux-1.2.0.patch new file mode 100644 index 0000000000000..5f228670d57c8 --- /dev/null +++ b/recipes/libwebp/all/patches/0003-build-libwebpmux-1.2.0.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -449,7 +449,7 @@ if(WEBP_BUILD_CWEBP) + install(TARGETS cwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() + +-if(WEBP_BUILD_GIF2WEBP OR WEBP_BUILD_IMG2WEBP) ++if(1) + parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/src/mux "WEBP_MUX_SRCS" "") + add_library(libwebpmux ${WEBP_MUX_SRCS}) + target_link_libraries(libwebpmux webp) diff --git a/recipes/libwebp/all/test_package/CMakeLists.txt b/recipes/libwebp/all/test_package/CMakeLists.txt index 85ee8f5da8128..5c4f1c676a652 100644 --- a/recipes/libwebp/all/test_package/CMakeLists.txt +++ b/recipes/libwebp/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(WebP REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} WebP::webp) +target_link_libraries(${PROJECT_NAME} PRIVATE WebP::webp) diff --git a/recipes/libwebp/all/test_package/conanfile.py b/recipes/libwebp/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/libwebp/all/test_package/conanfile.py +++ b/recipes/libwebp/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libwebp/all/test_v1_package/CMakeLists.txt b/recipes/libwebp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libwebp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libwebp/all/test_v1_package/conanfile.py b/recipes/libwebp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libwebp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libwebp/config.yml b/recipes/libwebp/config.yml index 6c1a86ff50796..2a1d6bc5117bc 100644 --- a/recipes/libwebp/config.yml +++ b/recipes/libwebp/config.yml @@ -1,7 +1,15 @@ versions: - "1.0.3": + "1.2.4": folder: all - "1.1.0": + "1.2.3": + folder: all + "1.2.2": + folder: all + "1.2.1": folder: all "1.2.0": folder: all + "1.1.0": + folder: all + "1.0.3": + folder: all diff --git a/recipes/libwebsockets/all/CMakeLists.txt b/recipes/libwebsockets/all/CMakeLists.txt index 8392b085458a4..f3c9da822bfbd 100644 --- a/recipes/libwebsockets/all/CMakeLists.txt +++ b/recipes/libwebsockets/all/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.4) - project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory("source_subfolder") diff --git a/recipes/libwebsockets/all/conandata.yml b/recipes/libwebsockets/all/conandata.yml index eff9e4b135448..119725ef837be 100644 --- a/recipes/libwebsockets/all/conandata.yml +++ b/recipes/libwebsockets/all/conandata.yml @@ -1,13 +1,22 @@ sources: - "4.0.15": - sha256: adce8152c3e802b8fe71b26d7252944944c49954ba6b5ba9fbb7fa5c4aad93dc - url: https://github.com/warmcat/libwebsockets/archive/v4.0.15.tar.gz - "4.1.4": - sha256: 00da77b4b89db3e0b1a2778f756f08d55d7f6b1632e18d981fc399c412866147 - url: https://github.com/warmcat/libwebsockets/archive/v4.1.4.tar.gz - "4.1.6": - url: "https://github.com/warmcat/libwebsockets/archive/v4.1.6.tar.gz" - sha256: "402e9a8df553c9cd2aff5d7a9758e9e5285bf3070c82539082864633db3deb83" + "4.3.2": + url: "https://github.com/warmcat/libwebsockets/archive/v4.3.2.tar.gz" + sha256: "6a85a1bccf25acc7e8e5383e4934c9b32a102880d1e4c37c70b27ae2a42406e1" + "4.3.0": + url: "https://github.com/warmcat/libwebsockets/archive/v4.3.0.tar.gz" + sha256: "ceef46e3bffb368efe4959202f128fd93d74e10cd2e6c3ac289a33b075645c3b" + "4.2.1": + url: "https://github.com/warmcat/libwebsockets/archive/v4.2.1.tar.gz" + sha256: "842da21f73ccba2be59e680de10a8cce7928313048750eb6ad73b6fa50763c51" "4.2.0": url: "https://github.com/warmcat/libwebsockets/archive/v4.2.0.tar.gz" sha256: "a57e9a4765dbcd4d880feba8089b43ed69995eaf10d5d61a07981d9ddd975f40" + "4.1.6": + url: "https://github.com/warmcat/libwebsockets/archive/v4.1.6.tar.gz" + sha256: "402e9a8df553c9cd2aff5d7a9758e9e5285bf3070c82539082864633db3deb83" + "4.1.4": + url: "https://github.com/warmcat/libwebsockets/archive/v4.1.4.tar.gz" + sha256: "00da77b4b89db3e0b1a2778f756f08d55d7f6b1632e18d981fc399c412866147" + "4.0.15": + url: "https://github.com/warmcat/libwebsockets/archive/v4.0.15.tar.gz" + sha256: "adce8152c3e802b8fe71b26d7252944944c49954ba6b5ba9fbb7fa5c4aad93dc" diff --git a/recipes/libwebsockets/all/conanfile.py b/recipes/libwebsockets/all/conanfile.py index 8f7be7aa58b75..c2dfe332c1332 100644 --- a/recipes/libwebsockets/all/conanfile.py +++ b/recipes/libwebsockets/all/conanfile.py @@ -1,6 +1,10 @@ -import os from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conans.errors import ConanException, ConanInvalidConfiguration +import os +import textwrap + +required_conan_version = ">=1.43.0" + class LibwebsocketsConan(ConanFile): name = "libwebsockets" @@ -8,17 +12,16 @@ class LibwebsocketsConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/warmcat/libwebsockets" license = "MIT" - topics = ("conan", "libwebsockets", "websocket") - exports_sources = "CMakeLists.txt" + topics = ("libwebsockets", "websocket") + settings = "os", "arch", "compiler", "build_type" - generators = "cmake" options = { "shared": [True, False], "fPIC": [True, False], "with_libuv": [True, False], "with_libevent": [False, "libevent", "libev"], "with_zlib": [False, "zlib", "miniz", "bundled"], - "with_ssl": [False, "openssl", "mbedtls-apache", "mbedtls-gpl", "wolfssl"], + "with_ssl": [False, "openssl", "mbedtls", "wolfssl"], "with_sqlite3": [True, False], "with_libmount": [True, False], "with_hubbub": [True, False], @@ -182,12 +185,18 @@ class LibwebsocketsConan(ConanFile): "enable_spawn": False } + exports_sources = "CMakeLists.txt" + generators = "cmake" _cmake = None @property def _source_subfolder(self): return "source_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -197,17 +206,10 @@ def configure(self): del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd - - def validate(self): - if self.options.shared and self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5": - # https://github.com/conan-io/conan-center-index/pull/5321#issuecomment-826367276 - raise ConanInvalidConfiguration("{}/{} shared=True with gcc<5 does not build. Please submit a PR with a fix.".format(self.name, self.version)) - if tools.Version(self.version) <= "4.0.15" and self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) >= "12": - raise ConanInvalidConfiguration("{}/{} with apple-clang>=12 does not build. Please submit a PR with a fix.".format(self.name, self.version)) def requirements(self): if self.options.with_libuv: - self.requires("libuv/1.40.0") + self.requires("libuv/1.44.1") if self.options.with_libevent == "libevent": self.requires("libevent/2.1.12") @@ -215,41 +217,44 @@ def requirements(self): self.requires("libev/4.33") if self.options.with_zlib == "zlib": - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.12") elif self.options.with_zlib == "miniz": - self.requires("miniz/2.1.0") + self.requires("miniz/2.2.0") if self.options.with_libmount: - self.requires("libmount/2.36") + self.requires("libmount/2.36.2") if self.options.with_sqlite3: - self.requires("sqlite3/3.34.0") + self.requires("sqlite3/3.37.2") if self.options.with_ssl == "openssl": - self.requires("openssl/1.1.1k") - - if self.options.with_ssl == "mbedtls-apache": - self.requires("mbedtls/2.16.3-apache") - - if self.options.with_ssl == "mbedtls-gpl": - self.requires("mbedtls/2.16.3-gpl") + self.requires("openssl/1.1.1o") + elif self.options.with_ssl == "mbedtls": + self.requires("mbedtls/2.25.0") + elif self.options.with_ssl == "wolfssl": + self.requires("wolfssl/4.8.1") - if self.options.with_ssl == "wolfssl": - self.requires("wolfssl/4.5.0") + def validate(self): + if self.options.shared and self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5": + # https://github.com/conan-io/conan-center-index/pull/5321#issuecomment-826367276 + raise ConanInvalidConfiguration("{}/{} shared=True with gcc<5 does not build. Please submit a PR with a fix.".format(self.name, self.version)) + if tools.Version(self.version) <= "4.0.15" and self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) >= "12": + raise ConanInvalidConfiguration("{}/{} with apple-clang>=12 does not build. Please submit a PR with a fix.".format(self.name, self.version)) + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < 16 and tools.Version(self.version) >= "4.3.2": + raise ConanInvalidConfiguration ("{}/{} requires at least Visual Studio 2019".format(self.name, self.version)) if self.options.with_hubbub: raise ConanInvalidConfiguration("Library hubbub not implemented (yet) in CCI") # TODO - Add hubbub package when available. def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{}-{}".format(self.name, self.version) - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _get_library_extension(self, dep): if self.options[dep].shared: if self.settings.os == "Windows" : - if self.settings.compiler == "Visual Studio": + if self._is_msvc: return ".lib" else: return ".dll.a" @@ -258,7 +263,7 @@ def _get_library_extension(self, dep): else: return ".so" else: - if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio": + if self.settings.os == "Windows" and self._is_msvc: return ".lib" else: return ".a" @@ -279,7 +284,7 @@ def _find_library(self, libname, dep): print("Test : " + str(lib_fullpath)) if os.path.isfile(lib_fullpath): return lib_fullpath - raise ConanInvalidConfiguration("Library {} not found".format(lib_fullpath)) + raise ConanException("Library {} not found".format(lib_fullpath)) def _find_libraries(self, dep): return [self._find_library(lib, dep) for lib in self.deps_cpp_info[dep].libs] @@ -298,13 +303,12 @@ def _configure_cmake(self): self._cmake.definitions["LWS_LINK_TESTAPPS_DYNAMIC"] = True self._cmake.definitions["LWS_WITH_SHARED"] = self.options.shared self._cmake.definitions["LWS_WITH_STATIC"] = not self.options.shared - self._cmake.definitions["LWS_WITH_SSL"] = self.options.with_ssl - + self._cmake.definitions["LWS_WITH_SSL"] = bool(self.options.with_ssl) if self.options.with_ssl == "openssl": self._cmake.definitions["LWS_OPENSSL_LIBRARIES"] = self._cmakify_path_list(self._find_libraries("openssl")) self._cmake.definitions["LWS_OPENSSL_INCLUDE_DIRS"] = self._cmakify_path_list(self.deps_cpp_info["openssl"].include_paths) - elif self.options.with_ssl == "mbedtls-apache" or self.options.with_ssl == "mbedtls-gpl": + elif self.options.with_ssl == "mbedtls": self._cmake.definitions["LWS_WITH_MBEDTLS"] = True self._cmake.definitions["LWS_MBEDTLS_LIBRARIES"] = self._cmakify_path_list(self._find_libraries("mbedtls")) self._cmake.definitions["LWS_MBEDTLS_INCLUDE_DIRS"] = self._cmakify_path_list(self.deps_cpp_info["mbedtls"].include_paths) @@ -325,7 +329,6 @@ def _configure_cmake(self): self._cmake.definitions["LWS_LIBUV_LIBRARIES"] = self._cmakify_path_list(self._find_libraries("libuv")) self._cmake.definitions["LWS_LIBUV_INCLUDE_DIRS"] = self._cmakify_path_list(self.deps_cpp_info["libuv"].include_paths) - self._cmake.definitions["LWS_WITH_LIBEVENT"] = self.options.with_libevent == "libevent" if self.options.with_libevent == "libevent": self._cmake.definitions["LWS_LIBEVENT_LIBRARIES"] = self._cmakify_path_list(self._find_libraries("libevent")) @@ -341,7 +344,6 @@ def _configure_cmake(self): self._cmake.definitions["MINIZ_LIBRARIES"] = self._cmakify_path_list(self._find_libraries("miniz")) self._cmake.definitions["MINIZ_INCLUDE_DIRS"] = self._cmakify_path_list(self.deps_cpp_info["miniz"].include_paths) - self._cmake.definitions["LWS_WITH_SQLITE3"] = self.options.with_sqlite3 if self.options.with_sqlite3: self._cmake.definitions["LWS_SQLITE3_LIBRARIES"] = self._cmakify_path_list(self._find_libraries("sqlite3")) @@ -426,17 +428,33 @@ def _configure_cmake(self): if tools.Version(self.version) >= "4.1.0": self._cmake.definitions["LWS_WITH_SYS_SMD"] = self.settings.os != "Windows" + self._cmake.definitions["DISABLE_WERROR"] = True + + # Temporary override Windows 10 SDK for Visual Studio 2019, see issue #4450 + # CCI worker has 10.0.17763.0 SDK installed alongside with 10.0.20348 but only 20348 can be used with Visual Studio 2019 + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) == 16: + self._cmake.definitions["CMAKE_SYSTEM_VERSION"] = "10.0.20348" self._cmake.configure() return self._cmake def _patch_sources(self): + cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") + tools.replace_in_file( + cmakelists, + "SET(CMAKE_INSTALL_NAME_DIR \"${CMAKE_INSTALL_PREFIX}/${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}\")", + "", + ) if tools.Version(self.version) == "4.0.15" and self.options.with_ssl: tools.replace_in_file( - os.path.join(self._source_subfolder, "CMakeLists.txt"), + cmakelists, "list(APPEND LIB_LIST ws2_32.lib userenv.lib psapi.lib iphlpapi.lib)", "list(APPEND LIB_LIST ws2_32.lib userenv.lib psapi.lib iphlpapi.lib crypt32.lib)" ) + if tools.Version(self.version) < "4.1.0": + tools.replace_in_file(cmakelists, "-Werror", "") + if tools.Version(self.version) >= "4.1.4": + tools.replace_in_file(cmakelists, "add_compile_options(/W3 /WX)", "add_compile_options(/W3)") def build(self): self._patch_sources() @@ -452,21 +470,55 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {self._cmake_target: "Libwebsockets::{}".format(self._cmake_target)} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + + @property + def _cmake_target(self): + return "websockets_shared" if self.options.shared else "websockets" + def package_info(self): - # TODO: CMake imported target shouldn't be namespaced - cmake_target = "websockets_shared" if self.options.shared else "websockets" + self.cpp_info.set_property("cmake_file_name", "Libwebsockets") + self.cpp_info.set_property("cmake_target_name", self._cmake_target) pkgconfig_name = "libwebsockets" if self.options.shared else "libwebsockets_static" - self.cpp_info.names["cmake_find_package"] = "Libwebsockets" - self.cpp_info.names["cmake_find_package_multi"] = "Libwebsockets" - self.cpp_info.names["pkg_config"] = pkgconfig_name - self.cpp_info.components["_libwebsockets"].names["cmake_find_package"] = cmake_target - self.cpp_info.components["_libwebsockets"].names["cmake_find_package_multi"] = cmake_target - self.cpp_info.components["_libwebsockets"].names["pkgconfig_name"] = pkgconfig_name + self.cpp_info.set_property("pkg_config_name", pkgconfig_name) + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed self.cpp_info.components["_libwebsockets"].libs = tools.collect_libs(self) if self.settings.os == "Windows": self.cpp_info.components["_libwebsockets"].system_libs.extend(["ws2_32", "crypt32"]) - elif self.settings.os == "Linux": + elif self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["_libwebsockets"].system_libs.extend(["dl", "m"]) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "Libwebsockets" + self.cpp_info.names["cmake_find_package_multi"] = "Libwebsockets" + self.cpp_info.names["pkg_config"] = pkgconfig_name + self.cpp_info.components["_libwebsockets"].names["cmake_find_package"] = self._cmake_target + self.cpp_info.components["_libwebsockets"].names["cmake_find_package_multi"] = self._cmake_target + self.cpp_info.components["_libwebsockets"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["_libwebsockets"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.components["_libwebsockets"].builddirs.append(os.path.join("lib", "cmake")) + self.cpp_info.components["_libwebsockets"].set_property("cmake_target_name", self._cmake_target) + self.cpp_info.components["_libwebsockets"].set_property("pkg_config_name", pkgconfig_name) if self.options.with_libuv: self.cpp_info.components["_libwebsockets"].requires.append("libuv::libuv") if self.options.with_libevent == "libevent": @@ -483,7 +535,7 @@ def package_info(self): self.cpp_info.components["_libwebsockets"].requires.append("sqlite3::sqlite3") if self.options.with_ssl == "openssl": self.cpp_info.components["_libwebsockets"].requires.append("openssl::openssl") - elif self.options.with_ssl in ["mbedtls-apache", "mbedtls-gpl"]: + elif self.options.with_ssl == "mbedtls": self.cpp_info.components["_libwebsockets"].requires.append("mbedtls::mbedtls") elif self.options.with_ssl == "wolfssl": self.cpp_info.components["_libwebsockets"].requires.append("wolfssl::wolfssl") diff --git a/recipes/libwebsockets/all/test_package/CMakeLists.txt b/recipes/libwebsockets/all/test_package/CMakeLists.txt index a72e92905b97d..7ca319a6f6da7 100644 --- a/recipes/libwebsockets/all/test_package/CMakeLists.txt +++ b/recipes/libwebsockets/all/test_package/CMakeLists.txt @@ -2,15 +2,14 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(Libwebsockets REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -# TODO: remove Libwebsockets:: namespace when fixed in cpp_info of recipe -if(LIBWEBSOCKETS_SHARED) - target_link_libraries(${PROJECT_NAME} Libwebsockets::websockets_shared) +if(TARGET websockets_shared) + target_link_libraries(${PROJECT_NAME} websockets_shared) else() - target_link_libraries(${PROJECT_NAME} Libwebsockets::websockets) + target_link_libraries(${PROJECT_NAME} websockets) endif() set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/libwebsockets/all/test_package/conanfile.py b/recipes/libwebsockets/all/test_package/conanfile.py index fc6ac5f95bbb4..9b63bd176646b 100644 --- a/recipes/libwebsockets/all/test_package/conanfile.py +++ b/recipes/libwebsockets/all/test_package/conanfile.py @@ -3,15 +3,14 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) - cmake.definitions["LIBWEBSOCKETS_SHARED"] = self.options["libwebsockets"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/libwebsockets/config.yml b/recipes/libwebsockets/config.yml index bf17f90c1d229..76fbd6a7ba025 100644 --- a/recipes/libwebsockets/config.yml +++ b/recipes/libwebsockets/config.yml @@ -1,9 +1,15 @@ versions: - "4.0.15": + "4.3.2": folder: all - "4.1.4": + "4.3.0": folder: all - "4.1.6": + "4.2.1": folder: all "4.2.0": folder: all + "4.1.6": + folder: all + "4.1.4": + folder: all + "4.0.15": + folder: all diff --git a/recipes/libx264/all/conandata.yml b/recipes/libx264/all/conandata.yml index 36547b1dd5b5f..394a54354a73d 100644 --- a/recipes/libx264/all/conandata.yml +++ b/recipes/libx264/all/conandata.yml @@ -1,7 +1,10 @@ sources: - "20190605": - url: "http://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20190605-2245.tar.bz2" - sha256: "c75203ef4759e4d7bc38e686b156c54c43b78edc73123c0b25db5224758bd1fc" + "cci.20220602": + url: "https://code.videolan.org/videolan/x264/-/archive/baee400fa9ced6f5481a728138fed6e867b0ff7f/x264-baee400fa9ced6f5481a728138fed6e867b0ff7f.tar.bz2" + sha256: "ce6623b8b289765daee04a297c2fd1a293cb2565a1749c76d66c8d72c7ddc1ab" "20191217": url: "https://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20191217-2245.tar.bz2" sha256: "0bb67d095513391e637b3b47e8efc3ba4603c3844f1b4c2690f4d36da7763055" + "20190605": + url: "http://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20190605-2245.tar.bz2" + sha256: "c75203ef4759e4d7bc38e686b156c54c43b78edc73123c0b25db5224758bd1fc" diff --git a/recipes/libx264/all/conanfile.py b/recipes/libx264/all/conanfile.py index a81768e9cd34c..fcaf19f43215d 100644 --- a/recipes/libx264/all/conanfile.py +++ b/recipes/libx264/all/conanfile.py @@ -1,6 +1,13 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building +from conan.tools.files import get, rename, rmdir +from conans import tools, AutoToolsBuildEnvironment +import contextlib import os +required_conan_version = ">=1.51.3" + class LibX264Conan(ConanFile): name = "libx264" @@ -8,43 +15,64 @@ class LibX264Conan(ConanFile): homepage = "https://www.videolan.org/developers/x264.html" description = "x264 is a free software library and application for encoding video streams into the " \ "H.264/MPEG-4 AVC compression format" - topics = ("conan", "libx264", "video", "encoding") + topics = ("libx264", "video", "encoding") license = "GPL-2.0" + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False], "bit_depth": [8, 10, "all"]} - default_options = {'shared': False, 'fPIC': True, 'bit_depth': 'all'} - _override_env = {} - _autotools = None + options = { + "shared": [True, False], + "fPIC": [True, False], + "bit_depth": [8, 10, "all"], + } + default_options = { + "shared": False, + "fPIC": True, + "bit_depth": "all", + } - @property - def _is_mingw(self): - return self.settings.os == "Windows" and self.settings.compiler == 'gcc' + _autotools = None + _override_env = {} @property def _is_msvc(self): - return self.settings.compiler == 'Visual Studio' + return str(self.settings.compiler) in ["Visual Studio", "msvc"] @property def _source_subfolder(self): return "source_subfolder" - def build_requirements(self): - self.build_requires("nasm/2.15.05") - if "CONAN_BASH_PATH" not in os.environ and tools.os_info.is_windows: - self.build_requires("msys2/20200517") + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd + @property + def _with_nasm(self): + return self.settings.arch in ("x86", "x86_64") + + def build_requirements(self): + if self._with_nasm: + self.build_requires("nasm/2.15.05") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = 'x264-snapshot-%s-2245' % self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @contextlib.contextmanager + def _build_context(self): + with tools.vcvars(self) if self._is_msvc else tools.no_op(): + yield @property def env(self): @@ -53,72 +81,109 @@ def env(self): return ret def _configure_autotools(self): - if not self._autotools: - prefix = tools.unix_path(self.package_folder) - args = ['--disable-cli', '--prefix={}'.format(prefix)] - if self.options.shared: - args.append('--enable-shared') - else: - args.append('--enable-static') - if self.settings.os != 'Windows' and self.options.fPIC: - args.append('--enable-pic') - if self.settings.build_type == 'Debug': - args.append('--enable-debug') - args.append('--bit-depth=%s' % str(self.options.bit_depth)) - - if tools.cross_building(self.settings): - if self.settings.os == "Android": - # the as of ndk does not work well for building libx264 - self._override_env["AS"] = os.environ["CC"] - ndk_root = tools.unix_path(os.environ["NDK_ROOT"]) - arch = {'armv7': 'arm', - 'armv8': 'aarch64', - 'x86': 'i686', - 'x86_64': 'x86_64'}.get(str(self.settings.arch)) - abi = 'androideabi' if self.settings.arch == 'armv7' else 'android' - cross_prefix = "%s/bin/%s-linux-%s-" % (ndk_root, arch, abi) - args.append('--cross-prefix=%s' % cross_prefix) - - if self._is_msvc: - self._override_env['CC'] = 'cl' - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - if self._is_msvc: - self._autotools.flags.append('-%s' % str(self.settings.compiler.runtime)) - # cannot open program database ... if multiple CL.EXE write to the same .PDB file, please use /FS - self._autotools.flags.append('-FS') - build_canonical_name = None - host_canonical_name = None - if self.settings.compiler == "Visual Studio": - # autotools does not know about the msvc canonical name(s) - build_canonical_name = False - host_canonical_name = False - self._autotools.configure(args=args, vars=self._override_env, configure_dir=self._source_subfolder, build=build_canonical_name, host=host_canonical_name) - + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + self._autotools.libs = [] + extra_asflags = [] + extra_cflags = [] + extra_ldflags = [] + args = [ + "--bit-depth=%s" % str(self.options.bit_depth), + "--disable-cli", + "--prefix={}".format(tools.unix_path(self.package_folder)), + ] + if self.options.shared: + args.append("--enable-shared") + else: + args.append("--enable-static") + if self.options.get_safe("fPIC", self.settings.os != "Windows"): + args.append("--enable-pic") + if self.settings.build_type == "Debug": + args.append("--enable-debug") + if is_apple_os(self) and self.settings.arch == "armv8": + # bitstream-a.S:29:18: error: unknown token in expression + extra_asflags.append("-arch arm64") + extra_ldflags.append("-arch arm64") + args.append("--host=aarch64-apple-darwin") + if self.settings.os != "Macos": + deployment_target_flag = tools.apple_deployment_target_flag( + self.settings.os, + self.settings.get_safe("os.version"), + self.settings.get_safe("os.sdk"), + self.settings.get_safe("os.subsystem"), + self.settings.get_safe("arch") + ) + platform_flags = ["-isysroot", tools.XCRun(self.settings).sdk_path, deployment_target_flag] + extra_asflags.extend(platform_flags) + extra_cflags.extend(platform_flags) + extra_ldflags.extend(platform_flags) + + if self._with_nasm: + # FIXME: get using user_build_info + self._override_env["AS"] = os.path.join(self.dependencies.build["nasm"].package_folder, "bin", "nasm{}".format(".exe" if tools.os_info.is_windows else "")).replace("\\", "/") + if cross_building(self): + if self.settings.os == "Android": + # the as of ndk does not work well for building libx264 + self._override_env["AS"] = os.environ["CC"] + ndk_root = tools.unix_path(os.environ["NDK_ROOT"]) + arch = { + "armv7": "arm", + "armv8": "aarch64", + "x86": "i686", + "x86_64": "x86_64", + }.get(str(self.settings.arch)) + abi = "androideabi" if self.settings.arch == "armv7" else "android" + args.append("--cross-prefix={}".format("{}/bin/{}-linux-{}-".format(ndk_root, arch, abi))) + if self._is_msvc: + self._override_env["CC"] = "cl -nologo" + extra_cflags.extend(self._autotools.flags) + if not (self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < "12"): + extra_cflags.append("-FS") + build_canonical_name = None + host_canonical_name = None + if self._is_msvc or self.settings.os in ["iOS", "watchOS", "tvOS"]: + # autotools does not know about the msvc and Apple embedded OS canonical name(s) + build_canonical_name = False + host_canonical_name = False + if extra_asflags: + args.append("--extra-asflags={}".format(" ".join(extra_asflags))) + if extra_cflags: + args.append("--extra-cflags={}".format(" ".join(extra_cflags))) + if extra_ldflags: + args.append("--extra-ldflags={}".format(" ".join(extra_ldflags))) + self._autotools.configure(args=args, vars=self._override_env, configure_dir=self._source_subfolder, build=build_canonical_name, host=host_canonical_name) return self._autotools def build(self): - with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): + with self._build_context(): + # relocatable shared lib on macOS + tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), + "-install_name \\$(DESTDIR)\\$(libdir)/", + "-install_name @rpath/") autotools = self._configure_autotools() autotools.make() def package(self): - with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): + self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses") + with self._build_context(): autotools = self._configure_autotools() autotools.install() - self.copy(pattern="COPYING", src=self._source_subfolder, dst='licenses') - tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig')) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + if self._is_msvc: + ext = ".dll.lib" if self.options.shared else ".lib" + rename(self, os.path.join(self.package_folder, "lib", "libx264{}".format(ext)), + os.path.join(self.package_folder, "lib", "x264.lib")) def package_info(self): - if self._is_msvc: - self.cpp_info.libs = ['libx264.dll.lib' if self.options.shared else 'libx264'] - if self.options.shared: - self.cpp_info.defines.append("X264_API_IMPORTS") - elif self._is_mingw: - self.cpp_info.libs = ['x264.dll' if self.options.shared else 'x264'] - else: - self.cpp_info.libs = ['x264'] - if self.settings.os == "Linux": - self.cpp_info.system_libs.extend(['dl', 'pthread', 'm']) + self.cpp_info.set_property("pkg_config_name", "x264") + self.cpp_info.libs = ["x264"] + if self._is_msvc and self.options.shared: + self.cpp_info.defines.append("X264_API_IMPORTS") + if self.settings.os in ("FreeBSD", "Linux"): + self.cpp_info.system_libs.extend(["dl", "pthread", "m"]) elif self.settings.os == "Android": - self.cpp_info.system_libs.extend(['dl', 'm']) - self.cpp_info.names['pkg_config'] = 'x264' + self.cpp_info.system_libs.extend(["dl", "m"]) + + # TODO: to remove in conan v2 once pkg_config generator removed + self.cpp_info.names["pkg_config"] = "x264" diff --git a/recipes/libx264/all/test_package/CMakeLists.txt b/recipes/libx264/all/test_package/CMakeLists.txt index 196188113685c..a98d4c1157e7e 100644 --- a/recipes/libx264/all/test_package/CMakeLists.txt +++ b/recipes/libx264/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +find_package(libx264 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libx264::libx264) diff --git a/recipes/libx264/all/test_package/conanfile.py b/recipes/libx264/all/test_package/conanfile.py index d72642c4343c5..697dfef261b53 100644 --- a/recipes/libx264/all/test_package/conanfile.py +++ b/recipes/libx264/all/test_package/conanfile.py @@ -3,8 +3,17 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") def build(self): cmake = CMake(self) @@ -12,7 +21,6 @@ def build(self): cmake.build() def test(self): - if tools.cross_building(self.settings, skip_x64_x86=True): - return - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libx264/all/test_package/test_package.c b/recipes/libx264/all/test_package/test_package.c new file mode 100644 index 0000000000000..c4d50fb7babad --- /dev/null +++ b/recipes/libx264/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include +#include "x264.h" + +#include + +int main() +{ + x264_param_t preset; + x264_t *encoder; + x264_param_default_preset(&preset, "ultrafast", "zerolatency"); + preset.i_width = 640; + preset.i_height = 480; + encoder = x264_encoder_open(&preset); + x264_encoder_close(encoder); + return EXIT_SUCCESS; +} diff --git a/recipes/libx264/all/test_package/test_package.cpp b/recipes/libx264/all/test_package/test_package.cpp deleted file mode 100644 index c71613213cbe0..0000000000000 --- a/recipes/libx264/all/test_package/test_package.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include -#include -#include "x264.h" - -int main() -{ - x264_param_t preset; - x264_param_default_preset(&preset, "ultrafast", "zerolatency"); - preset.i_width = 640; - preset.i_height = 480; - x264_t * encoder = x264_encoder_open(&preset); - x264_encoder_close(encoder); - return EXIT_SUCCESS; -} diff --git a/recipes/libx264/config.yml b/recipes/libx264/config.yml index c7cec35fe1627..be7607c4d1266 100644 --- a/recipes/libx264/config.yml +++ b/recipes/libx264/config.yml @@ -1,5 +1,7 @@ versions: - "20190605": + "cci.20220602": folder: all "20191217": folder: all + "20190605": + folder: all diff --git a/recipes/libx265/all/CMakeLists.txt b/recipes/libx265/all/CMakeLists.txt index 949e187e94d37..4a7467ebe3dd1 100644 --- a/recipes/libx265/all/CMakeLists.txt +++ b/recipes/libx265/all/CMakeLists.txt @@ -1,7 +1,11 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) + +if(NOT CMAKE_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR ${CONAN_LIBX265_SYSTEM_PROCESSOR}) +endif() add_subdirectory(source_subfolder/source) diff --git a/recipes/libx265/all/conandata.yml b/recipes/libx265/all/conandata.yml index 6d2bbe7a027cf..359a25270e5ee 100644 --- a/recipes/libx265/all/conandata.yml +++ b/recipes/libx265/all/conandata.yml @@ -1,16 +1,16 @@ sources: - "3.2.1": - url: "https://github.com/videolan/x265/archive/3.2.1.tar.gz" - sha256: "b5ee7ea796a664d6e2763f9c0ae281fac5d25892fc2cb134698547103466a06a" "3.4": url: "https://github.com/videolan/x265/archive/3.4.tar.gz" sha256: "544d147bf146f8994a7bf8521ed878c93067ea1c7c6e93ab602389be3117eaaf" -patches: "3.2.1": - - patch_file: "patches/0001-remove_register_classifier.patch" - base_path: "source_subfolder" + url: "https://github.com/videolan/x265/archive/3.2.1.tar.gz" + sha256: "b5ee7ea796a664d6e2763f9c0ae281fac5d25892fc2cb134698547103466a06a" +patches: "3.4": - patch_file: "patches/0001-remove_register_classifier.patch" base_path: "source_subfolder" - patch_file: "patches/0002-numa.patch" base_path: "source_subfolder" + "3.2.1": + - patch_file: "patches/0001-remove_register_classifier.patch" + base_path: "source_subfolder" diff --git a/recipes/libx265/all/conanfile.py b/recipes/libx265/all/conanfile.py index b77342c037597..7da8c688857c1 100644 --- a/recipes/libx265/all/conanfile.py +++ b/recipes/libx265/all/conanfile.py @@ -1,17 +1,20 @@ +from conan.tools.microsoft import msvc_runtime_flag from conans import CMake, ConanFile, tools +from conans.errors import ConanInvalidConfiguration import os import shutil +required_conan_version = ">=1.36.0" + class Libx265Conan(ConanFile): name = "libx265" description = "x265 is the leading H.265 / HEVC encoder software library" - topics = ("conan", "libx265", "codec", "video", "H.265") + topics = ("libx265", "codec", "video", "H.265") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.videolan.org/developers/x265.html" - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake", "cmake_find_package" license = ("GPL-2.0-only", "commercial") # https://bitbucket.org/multicoreware/x265/src/default/COPYING + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -20,7 +23,7 @@ class Libx265Conan(ConanFile): "bit_depth": [8, 10, 12], "HDR10": [True, False], "SVG_HEVC_encoder": [True, False], - "with_numa": [True, False] + "with_numa": [True, False], } default_options = { "shared": False, @@ -29,9 +32,10 @@ class Libx265Conan(ConanFile): "bit_depth": 8, "HDR10": False, "SVG_HEVC_encoder": False, - "with_numa": False + "with_numa": False, } + generators = "cmake", "cmake_find_package" _cmake = None @property @@ -42,27 +46,44 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC if self.settings.os != "Linux": del self.options.with_numa + # FIXME: Disable assembly by default if host is arm and compiler apple-clang for the moment. + # Indeed, apple-clang is not able to understand some asm instructions of libx265 + if self.settings.compiler == "apple-clang" and "arm" in self.settings.arch: + self.options.assembly = False def configure(self): if self.options.shared: del self.options.fPIC - def build_requirements(self): - if self.options.assembly: - self.build_requires("nasm/2.14") - def requirements(self): if self.options.get_safe("with_numa", False): self.requires("libnuma/2.0.14") + def validate(self): + if self._is_msvc and self.options.shared and "MT" in msvc_runtime_flag(self): + raise ConanInvalidConfiguration("shared not supported with static runtime") + + def build_requirements(self): + if self.options.assembly: + if self.settings.arch in ["x86", "x86_64"]: + self.build_requires("nasm/2.15.05") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("x265-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -78,10 +99,19 @@ def _configure_cmake(self): self._cmake.definitions["MAIN12"] = self.options.bit_depth == 12 self._cmake.definitions["ENABLE_HDR10_PLUS"] = self.options.HDR10 self._cmake.definitions["ENABLE_SVT_HEVC"] = self.options.SVG_HEVC_encoder - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["STATIC_LINK_CRT"] = "T" in str(self.settings.compiler.runtime) + if self._is_msvc: + self._cmake.definitions["STATIC_LINK_CRT"] = "MT" in msvc_runtime_flag(self) if self.settings.os == "Linux": self._cmake.definitions["PLATFORM_LIBS"] = "dl" + if tools.cross_building(self.settings): + # FIXME: too specific and error prone, should be delegated to CMake helper + cmake_system_processor = { + "armv8": "aarch64", + "armv8.3": "aarch64", + }.get(str(self.settings.arch), str(self.settings.arch)) + self._cmake.definitions["CONAN_LIBX265_SYSTEM_PROCESSOR"] = cmake_system_processor + if "arm" in self.settings.arch: + self._cmake.definitions["CROSS_COMPILE_ARM"] = tools.cross_building(self.settings) self._cmake.configure(build_folder=self._build_subfolder) return self._cmake @@ -109,13 +139,13 @@ def package(self): cmake.install() if self.options.shared: - if self.settings.compiler == "Visual Studio": + if self._is_msvc: static_lib = "x265-static.lib" else: static_lib = "libx265.a" os.unlink(os.path.join(self.package_folder, "lib", static_lib)) - if self.settings.compiler == "Visual Studio": + if self._is_msvc: name = "libx265.lib" if self.options.shared else "x265-static.lib" shutil.move(os.path.join(self.package_folder, "lib", name), os.path.join(self.package_folder, "lib", "x265.lib")) @@ -129,18 +159,21 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["pkg_config"] = "x265" + self.cpp_info.set_property("pkg_config_name", "x265") self.cpp_info.libs = ["x265"] if self.settings.os == "Windows": if self.options.shared: self.cpp_info.defines.append("X265_API_IMPORTS") - elif self.settings.os == "Linux": + elif self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["dl", "pthread", "m"]) if not self.options.shared: - if self.settings.compiler != "Visual Studio": + if not self._is_msvc: self.cpp_info.sharedlinkflags = ["-Wl,-Bsymbolic,-znoexecstack"] elif self.settings.os == "Android": self.cpp_info.libs.extend(["dl", "m"]) libcxx = tools.stdcpp_library(self) if libcxx: self.cpp_info.system_libs.append(libcxx) + + # TODO: to remove in conan v2 once pkg_config generator removed + self.cpp_info.names["pkg_config"] = "x265" diff --git a/recipes/libx265/all/test_package/CMakeLists.txt b/recipes/libx265/all/test_package/CMakeLists.txt index ff36635faa6a1..9e59bba65386c 100644 --- a/recipes/libx265/all/test_package/CMakeLists.txt +++ b/recipes/libx265/all/test_package/CMakeLists.txt @@ -1,19 +1,21 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(libx265 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libx265::libx265) option(TEST_LIBRARY "Build test library") if(TEST_LIBRARY) # Test building a shared library. # a static libx265.a on Linux requires linker flags to avoid PIC related relocation errors. add_library(test_library SHARED test_library.c) - target_link_libraries(test_library ${CONAN_LIBS}) + target_link_libraries(test_library PRIVATE libx265::libx265) target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_LIB) - target_link_libraries(${PROJECT_NAME} test_library) + target_link_libraries(${PROJECT_NAME} PRIVATE test_library) endif() diff --git a/recipes/libx265/all/test_package/conanfile.py b/recipes/libx265/all/test_package/conanfile.py index 61ae7bc4cd344..be66599572010 100644 --- a/recipes/libx265/all/test_package/conanfile.py +++ b/recipes/libx265/all/test_package/conanfile.py @@ -6,8 +6,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" @property def _test_shared_library(self): @@ -32,6 +32,6 @@ def test(self): for fn in glob.glob(os.path.join("lib", "*")): shutil.copy(src=fn, dst="bin") shutil.copy(src=fn, dst=".") - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libx265/config.yml b/recipes/libx265/config.yml index 9de84514fb134..76ea1c6fa9b73 100644 --- a/recipes/libx265/config.yml +++ b/recipes/libx265/config.yml @@ -1,5 +1,5 @@ versions: - "3.2.1": - folder: "all" "3.4": folder: "all" + "3.2.1": + folder: "all" diff --git a/recipes/libxcrypt/all/conandata.yml b/recipes/libxcrypt/all/conandata.yml index 430f79090fa48..df7c72ca12c22 100644 --- a/recipes/libxcrypt/all/conandata.yml +++ b/recipes/libxcrypt/all/conandata.yml @@ -1,4 +1,22 @@ sources: + "4.4.28": + url: "https://github.com/besser82/libxcrypt/archive/v4.4.28.tar.gz" + sha256: "db7e37901969cb1d1e8020cb73a991ef81e48e31ea5b76a101862c806426b457" + "4.4.27": + url: "https://github.com/besser82/libxcrypt/archive/v4.4.27.tar.gz" + sha256: "e4ff47b7fa5370fa08e27258f8a0de5cb7e9b09c297ec7ab56a8a82e229a1c84" + "4.4.26": + url: "https://github.com/besser82/libxcrypt/archive/v4.4.26.tar.gz" + sha256: "e8a544dd19171c1e6191a6044c96cc31496d781ba08b5a00f53310d001d58114" + "4.4.25": + url: "https://github.com/besser82/libxcrypt/archive/v4.4.25.tar.gz" + sha256: "caea3d032a46c4855ff818637884c7f5719ad228b79387b62ee023c8fbef17b4" + "4.4.23": + url: "https://github.com/besser82/libxcrypt/archive/v4.4.23.tar.gz" + sha256: "9cbbcb795ed5d121a1613eb0e40c77173b53e15a746796fc7cd7bd71cfd64533" + "4.4.22": + url: "https://github.com/besser82/libxcrypt/archive/v4.4.22.tar.gz" + sha256: "8d67c33837b8e5e930ca878c88f1856913b749cc95844fb11e7f1b4c8aab4f8e" "4.4.18": url: "https://github.com/besser82/libxcrypt/archive/v4.4.18.tar.gz" sha256: "3801f0263a8596b15ec466343fc1fdc4ad4ec7416c51e038a3528fd47f3be01a" @@ -6,5 +24,5 @@ sources: url: "https://github.com/besser82/libxcrypt/archive/v4.4.17.tar.gz" sha256: "7665168d0409574a03f7b484682e68334764c29c21ca5df438955a381384ca07" "4.4.16": - sha256: "a98f65b8baffa2b5ba68ee53c10c0a328166ef4116bce3baece190c8ce01f375" url: "https://github.com/besser82/libxcrypt/archive/v4.4.16.tar.gz" + sha256: "a98f65b8baffa2b5ba68ee53c10c0a328166ef4116bce3baece190c8ce01f375" diff --git a/recipes/libxcrypt/all/conanfile.py b/recipes/libxcrypt/all/conanfile.py index 50cfa75ea904f..7f1e95bcfd907 100644 --- a/recipes/libxcrypt/all/conanfile.py +++ b/recipes/libxcrypt/all/conanfile.py @@ -1,6 +1,14 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, replace_in_file, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path import os -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.53.0" class LibxcryptConan(ConanFile): @@ -8,7 +16,7 @@ class LibxcryptConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/besser82/libxcrypt" description = "Extended crypt library for descrypt, md5crypt, bcrypt, and others" - topics = ("conan", "libxcypt", "hash", "password", "one-way", "bcrypt", "md5", "sha256", "sha512") + topics = ("hash", "password", "one-way", "bcrypt", "md5", "sha256", "sha512") license = ("LGPL-2.1-or-later", ) settings = "os", "arch", "compiler", "build_type" options = { @@ -20,64 +28,68 @@ class LibxcryptConan(ConanFile): "fPIC": True, } - _autotools = None - @property - def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd def configure(self): - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("libxcrypt does not support Visual Studio") if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + def layout(self): + basic_layout(self, src_folder="src") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} does not support Visual Studio") def build_requirements(self): - self.build_requires("libtool/2.4.6") + self.tool_requires("libtool/2.4.7") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.libs = [] - conf_args = [ - "--disable-werror", - ] - if self.options.shared: - conf_args.extend(["--enable-shared", "--disable-static"]) - else: - conf_args.extend(["--disable-shared", "--enable-static"]) - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) - if self.settings.os == "Windows": - tools.replace_in_file("libtool", "-DPIC", "") - return self._autotools + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def build(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.am"), + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) + tc.configure_args.append("--disable-werror") + tc.generate() + + def _patch_sources(self): + replace_in_file(self, os.path.join(self.source_folder, "Makefile.am"), "\nlibcrypt_la_LDFLAGS = ", "\nlibcrypt_la_LDFLAGS = -no-undefined ") - with tools.chdir(self._source_subfolder): - self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows) - autotools = self._configure_autotools() + + def build(self): + self._patch_sources() + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() + if self.settings.os == "Windows": + replace_in_file(self, os.path.join(self.build_folder, "libtool"), "-DPIC", "") autotools.make() def package(self): - self.copy("COPYING.LIB", src=self._source_subfolder, dst="licenses") - autotools = self._configure_autotools() - autotools.install() - - os.unlink(os.path.join(self.package_folder, "lib", "libcrypt.la")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + copy(self, "COPYING.LIB", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + fix_apple_shared_install_name(self) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "libxcrypt") self.cpp_info.libs = ["crypt"] diff --git a/recipes/libxcrypt/all/test_package/CMakeLists.txt b/recipes/libxcrypt/all/test_package/CMakeLists.txt index 34af13462f44f..af52be8acede9 100644 --- a/recipes/libxcrypt/all/test_package/CMakeLists.txt +++ b/recipes/libxcrypt/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libxcrypt REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE libxcrypt::libxcrypt) diff --git a/recipes/libxcrypt/all/test_package/conanfile.py b/recipes/libxcrypt/all/test_package/conanfile.py index b88a6525524a6..0a6bc68712d90 100644 --- a/recipes/libxcrypt/all/test_package/conanfile.py +++ b/recipes/libxcrypt/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,5 +21,6 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libxcrypt/all/test_v1_package/CMakeLists.txt b/recipes/libxcrypt/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libxcrypt/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libxcrypt/all/test_v1_package/conanfile.py b/recipes/libxcrypt/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libxcrypt/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libxcrypt/config.yml b/recipes/libxcrypt/config.yml index 8d16a8e281af6..5f226d94e67a1 100644 --- a/recipes/libxcrypt/config.yml +++ b/recipes/libxcrypt/config.yml @@ -1,4 +1,16 @@ versions: + "4.4.28": + folder: all + "4.4.27": + folder: all + "4.4.26": + folder: all + "4.4.25": + folder: all + "4.4.23": + folder: all + "4.4.22": + folder: all "4.4.18": folder: all "4.4.17": diff --git a/recipes/libxft/all/conandata.yml b/recipes/libxft/all/conandata.yml new file mode 100644 index 0000000000000..e56e888b5fdb6 --- /dev/null +++ b/recipes/libxft/all/conandata.yml @@ -0,0 +1,14 @@ +sources: + "2.3.6": + url: "https://www.x.org/archive/individual/lib/libXft-2.3.6.tar.gz" + sha256: "b7e59f69e0bbabe9438088775f7e5a7c16a572e58b11f9722519385d38192df5" + "2.3.4": + url: "https://www.x.org/archive/individual/lib/libXft-2.3.4.tar.gz" + sha256: "1eca71bec9cb483165ce1ab94f5cd3036269f5268651df6a2d99c4a7ab644d79" +patches: + "2.3.6": + - patch_file: "patches/0001-fix-gcc-5-and-11.patch" + patch_description: "fix gcc 5 and gcc 11 compilation" + patch_type: "portability" + patch_source: "https://gitlab.freedesktop.org/xorg/lib/libxft/-/merge_requests/17" + base_path: "source_subfolder" diff --git a/recipes/libxft/all/conanfile.py b/recipes/libxft/all/conanfile.py new file mode 100644 index 0000000000000..5bb077b0fdb7a --- /dev/null +++ b/recipes/libxft/all/conanfile.py @@ -0,0 +1,78 @@ +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, chdir, rm, rmdir +from conans import AutoToolsBuildEnvironment +import functools + +required_conan_version = ">=1.52.0" + +class libxftConan(ConanFile): + name = "libxft" + description = 'X FreeType library' + topics = ("libxft", "x11", "xorg") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.x.org/wiki/" + license = "X11" + + settings = "os", "arch", "compiler", "build_type" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + generators = "pkg_config" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + export_conandata_patches(self) + + def requirements(self): + self.requires("xorg/system") + self.requires("freetype/2.12.1") + self.requires("fontconfig/2.13.93") + + def build_requirements(self): + self.build_requires("pkgconf/1.7.4") + self.build_requires("xorg-macros/1.19.3") + self.build_requires("libtool/2.4.7") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + + @functools.lru_cache(1) + def _configure_autotools(self): + args = ["--disable-dependency-tracking"] + if self.options.shared: + args.extend(["--disable-static", "--enable-shared"]) + else: + args.extend(["--disable-shared", "--enable-static"]) + autotools = AutoToolsBuildEnvironment(self) + autotools.configure(args=args, pkg_config_paths=self.build_folder) + return autotools + + def build(self): + apply_conandata_patches(self) + with chdir(self, self._source_subfolder): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + with chdir(self, self._source_subfolder): + autotools = self._configure_autotools() + autotools.install(args=["-j1"]) + rm(self, "*.la", f"{self.package_folder}/lib", recursive=True) + rmdir(self, f"{self.package_folder}/lib/pkgconfig") + rmdir(self, f"{self.package_folder}/share") + + def package_info(self): + self.cpp_info.names['pkg_config'] = "Xft" + self.cpp_info.set_property("pkg_config_name", "xft") + self.cpp_info.libs = ["Xft"] diff --git a/recipes/libxft/all/patches/0001-fix-gcc-5-and-11.patch b/recipes/libxft/all/patches/0001-fix-gcc-5-and-11.patch new file mode 100644 index 0000000000000..c7b72d5585aa0 --- /dev/null +++ b/recipes/libxft/all/patches/0001-fix-gcc-5-and-11.patch @@ -0,0 +1,24 @@ +From 84310d83bf4c057dd0866e7116779c9c2f043007 Mon Sep 17 00:00:00 2001 +From: ericLemanissier +Date: Fri, 23 Sep 2022 07:59:55 +0000 +Subject: [PATCH] fix compilation with gcc 5 and gcc 11 + +stdint.h header is needed for SIZE_MAX +--- + src/xftrender.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/xftrender.c b/src/xftrender.c +index 3021d56..c15237e 100644 +--- a/src/xftrender.c ++++ b/src/xftrender.c +@@ -21,6 +21,7 @@ + */ + + #include "xftint.h" ++#include + + #define NUM_LOCAL 1024 + #define NUM_ELT_LOCAL 128 +-- +GitLab diff --git a/recipes/libxft/all/test_package/CMakeLists.txt b/recipes/libxft/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e55ad61e844f5 --- /dev/null +++ b/recipes/libxft/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libxft REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libxft::libxft) diff --git a/recipes/libxft/all/test_package/conanfile.py b/recipes/libxft/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/libxft/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libxft/all/test_package/test_package.c b/recipes/libxft/all/test_package/test_package.c new file mode 100644 index 0000000000000..4dd1da9eb81e7 --- /dev/null +++ b/recipes/libxft/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include "X11/Xft/Xft.h" + +#include +int main() +{ + if(!XftInit("")) + printf("Could not init Xft\n"); + printf("Xft version: %d\n", XftGetVersion()); + return 0; +} diff --git a/recipes/libxft/config.yml b/recipes/libxft/config.yml new file mode 100644 index 0000000000000..6caf25620b5dc --- /dev/null +++ b/recipes/libxft/config.yml @@ -0,0 +1,5 @@ +versions: + "2.3.6": + folder: all + "2.3.4": + folder: all diff --git a/recipes/libxlsxwriter/all/CMakeLists.txt b/recipes/libxlsxwriter/all/CMakeLists.txt deleted file mode 100644 index 30c065f03128e..0000000000000 --- a/recipes/libxlsxwriter/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(source_subfolder) diff --git a/recipes/libxlsxwriter/all/conandata.yml b/recipes/libxlsxwriter/all/conandata.yml index 4afb6db8e581e..b6ef8ccb7684d 100644 --- a/recipes/libxlsxwriter/all/conandata.yml +++ b/recipes/libxlsxwriter/all/conandata.yml @@ -1,8 +1,26 @@ sources: + "1.1.4": + url: "https://github.com/jmcnamara/libxlsxwriter/archive/RELEASE_1.1.4.tar.gz" + sha256: "b379eb35fdd9c653ebe72485b9c992f612c7ea66f732784457997d6e782f619b" + "1.1.3": + url: "https://github.com/jmcnamara/libxlsxwriter/archive/RELEASE_1.1.3.tar.gz" + sha256: "bd7a3d38c6a8ef5e31d07a61fded23ac00d29d758417ca42db89da60bf796d78" "1.0.0": url: "https://github.com/jmcnamara/libxlsxwriter/archive/RELEASE_1.0.0.tar.gz" sha256: "8b353379333c323d14a9d265cd2491d3a6c0032c8d6ec2141f10b82ab66a087c" patches: + "1.1.4": + - patch_file: "patches/1.1.3-0001-fix-cmake.patch" + patch_description: "Fix CMake: robust dependencies discovery & avoid some hardcoded flags" + patch_type: "conan" + sha256: "54bf92c1f9423d9c7b3820122ff806679e254392d66ae72696f58e7d36e4b16f" + "1.1.3": + - patch_file: "patches/1.1.3-0001-fix-cmake.patch" + patch_description: "Fix CMake: robust dependencies discovery & avoid some hardcoded flags" + patch_type: "conan" + sha256: "54bf92c1f9423d9c7b3820122ff806679e254392d66ae72696f58e7d36e4b16f" "1.0.0": - - base_path: "source_subfolder" - patch_file: "patches/001-patch-cmake-conan-targets.patch" + - patch_file: "patches/1.0.0-0001-fix-cmake.patch" + patch_description: "Fix CMake: robust dependencies discovery & avoid some hardcoded flags" + patch_type: "conan" + sha256: "d310313e55f4819db7401e1dc27795481b4a3b258fbba19f9eb5211141b09972" diff --git a/recipes/libxlsxwriter/all/conanfile.py b/recipes/libxlsxwriter/all/conanfile.py index 846c2ea6e9069..467437938757a 100644 --- a/recipes/libxlsxwriter/all/conanfile.py +++ b/recipes/libxlsxwriter/all/conanfile.py @@ -1,5 +1,12 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.52.0" class LibxlsxwriterConan(ConanFile): @@ -7,72 +14,97 @@ class LibxlsxwriterConan(ConanFile): license = "BSD-2-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/jmcnamara/libxlsxwriter" - topics = ("conan", "Excel", "XLSX") + topics = ("excel", "xlsx") description = "A C library for creating Excel XLSX files" - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], - "fPIC": [True, False] + "fPIC": [True, False], + "tmpfile": [True, False], + "md5": [False, "openwall", "openssl"], + "fmemopen": [True, False], + "dtoa": [True, False], } default_options = { - "shared": False, - "fPIC": True + "shared": False, + "fPIC": True, + "tmpfile": False, + "md5": "openwall", + "fmemopen": False, + "dtoa": False, } - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.settings.os != "Linux": + del self.options.fmemopen def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("minizip/1.2.11") - self.requires("zlib/1.2.11") - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libxlsxwriter-RELEASE_{}".format(self.version), self._source_subfolder) + self.requires("minizip/1.2.13") + self.requires("zlib/1.2.13") + if self.options.md5 == "openssl": + self.requires("openssl/1.1.1s") - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def validate(self): + if Version(self.version) < "1.0.6" and self.info.options.md5 == "openssl": + raise ConanInvalidConfiguration(f"{self.name}:md5=openssl is not suppported in {self.ref}") - def _configure_cmake(self): - if self._cmake: - return self._cmake - - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["USE_STATIC_MSVC_RUNTIME"] = (self.settings.os == "Windows" and "MT" in str(self.settings.compiler.runtime)) - self._cmake.definitions["USE_SYSTEM_MINIZIP"] = True - - self._cmake.configure() - return self._cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTS"] = False + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["USE_SYSTEM_MINIZIP"] = True + tc.variables["USE_STANDARD_TMPFILE"] = self.options.tmpfile + tc.variables["USE_NO_MD5"] = not bool(self.options.md5) + if Version(self.version) >= "1.0.6": + tc.variables["USE_OPENSSL_MD5"] = self.options.md5 == "openssl" + tc.variables["USE_FMEMOPEN"] = self.options.get_safe("fmemopen", False) + tc.variables["USE_DTOA_LIBRARY"] = self.options.dtoa + if is_msvc(self): + tc.variables["USE_STATIC_MSVC_RUNTIME"] = is_msvc_static_runtime(self) + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "License.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy("License.txt", src=self._source_subfolder, dst="licenses") - + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "xlsxwriter") self.cpp_info.libs = ["xlsxwriter"] - diff --git a/recipes/libxlsxwriter/all/patches/001-patch-cmake-conan-targets.patch b/recipes/libxlsxwriter/all/patches/001-patch-cmake-conan-targets.patch deleted file mode 100644 index 974e55ba8f8d5..0000000000000 --- a/recipes/libxlsxwriter/all/patches/001-patch-cmake-conan-targets.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 2359933..955563c 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -180,16 +180,16 @@ endif() - # INCLUDES - # -------- - enable_language(CXX) --list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -+#list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - - # ZLIB --find_package(ZLIB REQUIRED "1.0") -+#find_package(ZLIB REQUIRED "1.0") - list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS}) - message("zlib version: " ${ZLIB_VERSION}) - - # MINIZIP - if (USE_SYSTEM_MINIZIP) -- find_package(MINIZIP REQUIRED "1.0") -+ #find_package(MINIZIP REQUIRED "1.0") - list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS}) - endif() - -@@ -237,7 +237,7 @@ target_sources(${PROJECT_NAME} - PRIVATE ${LXW_SOURCES} - PUBLIC ${LXW_HEADERS} - ) --target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES}) -+target_link_libraries(${PROJECT_NAME} LINK_PUBLIC CONAN_PKG::zlib CONAN_PKG::minizip) - target_compile_definitions(${PROJECT_NAME} PRIVATE ${LXW_PRIVATE_COMPILE_DEFINITIONS}) - - # /utf-8 needs VS2015 Update 2 or above. diff --git a/recipes/libxlsxwriter/all/patches/1.0.0-0001-fix-cmake.patch b/recipes/libxlsxwriter/all/patches/1.0.0-0001-fix-cmake.patch new file mode 100644 index 0000000000000..ea03f6ee126ba --- /dev/null +++ b/recipes/libxlsxwriter/all/patches/1.0.0-0001-fix-cmake.patch @@ -0,0 +1,38 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -153,9 +153,8 @@ endif() + + if(NOT BUILD_SHARED_LIBS) + if(UNIX) +- set(CMAKE_POSITION_INDEPENDENT_CODE ON) + elseif(MINGW OR MSYS) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -static-libgcc -Wno-char-subscripts -Wno-long-long") ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-char-subscripts -Wno-long-long") + list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_FILE32API) + elseif(MSVC) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\"") +@@ -183,13 +182,13 @@ enable_language(CXX) + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + + # ZLIB +-find_package(ZLIB REQUIRED "1.0") ++find_package(ZLIB REQUIRED) + list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS}) + message("zlib version: " ${ZLIB_VERSION}) + + # MINIZIP + if (USE_SYSTEM_MINIZIP) +- find_package(MINIZIP REQUIRED "1.0") ++ find_package(minizip REQUIRED CONFIG) + list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS}) + endif() + +@@ -237,7 +236,7 @@ target_sources(${PROJECT_NAME} + PRIVATE ${LXW_SOURCES} + PUBLIC ${LXW_HEADERS} + ) +-target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES}) ++target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB minizip::minizip) + target_compile_definitions(${PROJECT_NAME} PRIVATE ${LXW_PRIVATE_COMPILE_DEFINITIONS}) + + # /utf-8 needs VS2015 Update 2 or above. diff --git a/recipes/libxlsxwriter/all/patches/1.1.3-0001-fix-cmake.patch b/recipes/libxlsxwriter/all/patches/1.1.3-0001-fix-cmake.patch new file mode 100644 index 0000000000000..473fc10337147 --- /dev/null +++ b/recipes/libxlsxwriter/all/patches/1.1.3-0001-fix-cmake.patch @@ -0,0 +1,41 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -175,9 +175,8 @@ endif() + + if(NOT BUILD_SHARED_LIBS) + if(UNIX) +- set(CMAKE_POSITION_INDEPENDENT_CODE ON) + elseif(MINGW OR MSYS) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -static-libgcc -Wno-char-subscripts -Wno-long-long") ++ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-char-subscripts -Wno-long-long") + list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_FILE32API) + elseif(MSVC) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\"") +@@ -216,13 +215,13 @@ enable_language(CXX) + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + + # ZLIB +-find_package(ZLIB REQUIRED "1.0") ++find_package(ZLIB REQUIRED) + list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS}) + message("zlib version: " ${ZLIB_VERSION}) + + # MINIZIP + if (USE_SYSTEM_MINIZIP) +- find_package(MINIZIP REQUIRED "1.0") ++ find_package(minizip REQUIRED CONFIG) + list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS}) + endif() + +@@ -278,7 +277,10 @@ target_sources(${PROJECT_NAME} + PRIVATE ${LXW_SOURCES} + PUBLIC ${LXW_HEADERS} + ) +-target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES} ${LIB_CRYPTO} ${OPENSSL_CRYPTO_LIBRARY}) ++target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB minizip::minizip) ++if(USE_OPENSSL_MD5) ++ target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::Crypto) ++endif() + target_compile_definitions(${PROJECT_NAME} PRIVATE ${LXW_PRIVATE_COMPILE_DEFINITIONS}) + + # /utf-8 needs VS2015 Update 2 or above. diff --git a/recipes/libxlsxwriter/all/test_package/CMakeLists.txt b/recipes/libxlsxwriter/all/test_package/CMakeLists.txt index 37195b5e1f903..267b50e398033 100644 --- a/recipes/libxlsxwriter/all/test_package/CMakeLists.txt +++ b/recipes/libxlsxwriter/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(PackageTest C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +find_package(libxlsxwriter REQUIRED CONFIG) -add_executable(example example.c) -target_link_libraries(example CONAN_PKG::libxlsxwriter) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libxlsxwriter::libxlsxwriter) diff --git a/recipes/libxlsxwriter/all/test_package/conanfile.py b/recipes/libxlsxwriter/all/test_package/conanfile.py index 5a6b132236463..0a6bc68712d90 100644 --- a/recipes/libxlsxwriter/all/test_package/conanfile.py +++ b/recipes/libxlsxwriter/all/test_package/conanfile.py @@ -1,9 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -class LibxlsxwriterTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -11,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libxlsxwriter/all/test_package/example.c b/recipes/libxlsxwriter/all/test_package/test_package.c similarity index 100% rename from recipes/libxlsxwriter/all/test_package/example.c rename to recipes/libxlsxwriter/all/test_package/test_package.c diff --git a/recipes/libxlsxwriter/all/test_v1_package/CMakeLists.txt b/recipes/libxlsxwriter/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libxlsxwriter/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libxlsxwriter/all/test_v1_package/conanfile.py b/recipes/libxlsxwriter/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libxlsxwriter/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libxlsxwriter/config.yml b/recipes/libxlsxwriter/config.yml index c7f13630776fb..3e62b328f7fc7 100644 --- a/recipes/libxlsxwriter/config.yml +++ b/recipes/libxlsxwriter/config.yml @@ -1,3 +1,7 @@ versions: + "1.1.4": + folder: "all" + "1.1.3": + folder: "all" "1.0.0": folder: "all" diff --git a/recipes/libxml2/all/conandata.yml b/recipes/libxml2/all/conandata.yml index e933ccd2f0d53..bf398536e5842 100644 --- a/recipes/libxml2/all/conandata.yml +++ b/recipes/libxml2/all/conandata.yml @@ -1,7 +1,19 @@ sources: - "2.9.9": - sha256: 94fb70890143e3c6549f265cee93ec064c80a84c42ad0f23e85ee1fd6540a871 - url: http://xmlsoft.org/sources/libxml2-2.9.9.tar.gz + "2.10.3": + url: "https://download.gnome.org/sources/libxml2/2.10/libxml2-2.10.3.tar.xz" + sha256: "5d2cc3d78bec3dbe212a9d7fa629ada25a7da928af432c93060ff5c17ee28a9c" + "2.9.14": + url: "https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.14.tar.xz" + sha256: "60d74a257d1ccec0475e749cba2f21559e48139efba6ff28224357c7c798dfee" + "2.9.13": + url: "https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.13.tar.xz" + sha256: "276130602d12fe484ecc03447ee5e759d0465558fbc9d6bd144e3745306ebf0e" + "2.9.12": + url: "https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.12.tar.xz" + sha256: "28a92f6ab1f311acf5e478564c49088ef0ac77090d9c719bbc5d518f1fe62eb9" "2.9.10": - sha256: aafee193ffb8fe0c82d4afef6ef91972cbaf5feea100edc2f262750611b4be1f - url: http://xmlsoft.org/sources/libxml2-2.9.10.tar.gz + url: "https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.10.tar.xz" + sha256: "593b7b751dd18c2d6abcd0c4bcb29efc203d0b4373a6df98e3a455ea74ae2813" + "2.9.9": + url: "https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.9.tar.xz" + sha256: "58a5c05a2951f8b47656b676ce1017921a29f6b1419c45e3baed0d6435ba03f5" diff --git a/recipes/libxml2/all/conanfile.py b/recipes/libxml2/all/conanfile.py index 8db095eb55034..c183f8d0d6e08 100644 --- a/recipes/libxml2/all/conanfile.py +++ b/recipes/libxml2/all/conanfile.py @@ -1,18 +1,25 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment -from contextlib import contextmanager -import glob +from conan import ConanFile +from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv +from conan.tools.scm import Version +from conan.tools.build import cross_building, build_jobs +from conan.tools.files import copy, get, rename, rm, rmdir, replace_in_file, save, chdir, mkdir +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path, VCVars import os + +import itertools import textwrap -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.53.0" class Libxml2Conan(ConanFile): name = "libxml2" url = "https://github.com/conan-io/conan-center-index" description = "libxml2 is a software library for parsing XML documents" - topics = ("XML", "parser", "validation") - homepage = "https://xmlsoft.org" + topics = "xml", "parser", "validation" + homepage = "https://gitlab.gnome.org/GNOME/libxml2/-/wikis/" license = "MIT" settings = "os", "arch", "compiler", "build_type" @@ -23,7 +30,7 @@ class Libxml2Conan(ConanFile): "include_utils": True, "c14n": True, "catalog": True, - "docbook": True, + "docbook": True, # dropped after 2.10.3 "ftp": True, "http": True, "html": True, @@ -54,75 +61,115 @@ class Libxml2Conan(ConanFile): } options = {name: [True, False] for name in default_options.keys()} - _option_names = [name for name in default_options.keys() if name not in ["shared", "fPIC", "include_utils"]] - - generators = "pkg_config" - _autotools = None @property - def _source_subfolder(self): - return "source_subfolder" + def _option_names(self): + return [name for name in self.info.options.keys() if name not in ["shared", "fPIC", "include_utils"]] @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) @property - def _is_mingw(self): - return self.settings.compiler == "gcc" and self.settings.os == "Windows" + def _is_mingw_windows(self): + return self.settings.compiler == "gcc" and self.settings.os == "Windows" and self._settings_build.os == "Windows" def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if Version(self.version) >= "2.10.3": + del self.options.docbook def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): if self.options.zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.lzma: self.requires("xz_utils/5.2.5") if self.options.iconv: - self.requires("libiconv/1.16") + self.requires("libiconv/1.17") if self.options.icu: - self.requires("icu/68.2") + self.requires("icu/72.1") def build_requirements(self): - if not self._is_msvc: + if not (is_msvc(self) or self._is_mingw_windows): if self.options.zlib or self.options.lzma or self.options.icu: - self.build_requires("pkgconf/1.7.3") - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + self.tool_requires("pkgconf/1.9.3") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libxml2-{0}".format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + if is_msvc(self): + tc = VCVars(self) + tc.generate() + env = Environment() + # TODO: no conan v2 build helper for NMake yet (see https://github.com/conan-io/conan/issues/12188) + # So populate CL with AutotoolsToolchain cflags + c_flags = AutotoolsToolchain(self).cflags + if c_flags: + env.define("CL", c_flags) + env.vars(self).save_script("conanbuildenv_nmake") + elif self._is_mingw_windows: + pass # nothing to do for mingw? it calls mingw-make directly + else: + env = VirtualBuildEnv(self) + env.generate() + + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") + + tc = AutotoolsToolchain(self) + + yes_no = lambda v: "yes" if v else "no" + tc.configure_args.extend([ + f"--enable-shared={yes_no(self.options.shared)}", + f"--enable-static={yes_no(not self.options.shared)}", + ]) + for option_name in self._option_names: + option_value = getattr(self.options, option_name) + tc.configure_args.append(f"--with-{option_name}={yes_no(option_value)}") - @contextmanager - def _msvc_build_environment(self): - with tools.chdir(os.path.join(self._source_subfolder, 'win32')): - with tools.vcvars(self.settings): - with tools.environment_append(VisualStudioBuildEnvironment(self).vars): - yield + tc.generate() + + tc = PkgConfigDeps(self) + tc.generate() + + tc = AutotoolsDeps(self) + tc.generate() def _build_msvc(self): - with self._msvc_build_environment(): + with chdir(self, os.path.join(self.source_folder, 'win32')): debug = "yes" if self.settings.build_type == "Debug" else "no" static = "no" if self.options.shared else "yes" - args = ["cscript", - "configure.js", - "compiler=msvc", - "prefix=%s" % self.package_folder, - "cruntime=/%s" % self.settings.compiler.runtime, - "debug=%s" % debug, - "static=%s" % static, - 'include="%s"' % ";".join(self.deps_cpp_info.include_paths), - 'lib="%s"' % ";".join(self.deps_cpp_info.lib_paths)] + args = [ + "cscript", + "configure.js", + "compiler=msvc", + f"prefix={self.package_folder}", + f"cruntime=/{msvc_runtime_flag(self)}", + f"debug={debug}", + f"static={static}", + ] + + incdirs = [incdir for dep in self.dependencies.values() for incdir in dep.cpp_info.includedirs] + libdirs = [libdir for dep in self.dependencies.values() for libdir in dep.cpp_info.libdirs] + args.append(f"include=\"{';'.join(incdirs)}\"") + args.append(f"lib=\"{';'.join(libdirs)}\"") for name in self._option_names: cname = {"mem-debug": "mem_debug", @@ -130,7 +177,7 @@ def _build_msvc(self): "docbook": "docb"}.get(name, name) value = getattr(self.options, name) value = "yes" if value else "no" - args.append("%s=%s" % (cname, value)) + args.append(f"{cname}={value}") configure_command = ' '.join(args) self.output.info(configure_command) @@ -140,17 +187,17 @@ def _build_msvc(self): def fix_library(option, package, old_libname): if option: libs = [] - for lib in self.deps_cpp_info[package].libs: + for lib in itertools.chain(self.dependencies[package].cpp_info.libs, self.dependencies[package].cpp_info.system_libs): libname = lib if not libname.endswith('.lib'): libname += '.lib' libs.append(libname) - tools.replace_in_file("Makefile.msvc", - "LIBS = $(LIBS) %s" % old_libname, - "LIBS = $(LIBS) %s" % ' '.join(libs)) + replace_in_file(self, "Makefile.msvc", + f"LIBS = $(LIBS) {old_libname}", + f"LIBS = $(LIBS) {' '.join(libs)}") fix_library(self.options.zlib, 'zlib', 'zlib.lib') - fix_library(self.options.lzma, 'lzma', 'liblzma.lib') + fix_library(self.options.lzma, "xz_utils", "liblzma.lib") fix_library(self.options.iconv, 'libiconv', 'iconv.lib') fix_library(self.options.icu, 'icu', 'advapi32.lib sicuuc.lib sicuin.lib sicudt.lib') fix_library(self.options.icu, 'icu', 'icuuc.lib icuin.lib icudt.lib') @@ -160,143 +207,205 @@ def fix_library(option, package, old_libname): if self.options.include_utils: self.run("nmake /f Makefile.msvc utils") - def _package_msvc(self): - with self._msvc_build_environment(): + with chdir(self, os.path.join(self.source_folder, 'win32')): self.run("nmake /f Makefile.msvc install-libs") if self.options.include_utils: self.run("nmake /f Makefile.msvc install-dist") - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - self._autotools.libs = [] - full_install_subfolder = tools.unix_path(self.package_folder) if tools.os_info.is_windows else self.package_folder - configure_args = ['--prefix=%s' % full_install_subfolder] - configure_args.append("--with-pic" if self.options.get_safe("fPIC", True) else "--without-pic") - if self.options.shared: - configure_args.extend(['--enable-shared', '--disable-static']) - else: - configure_args.extend(['--enable-static', '--disable-shared']) + def _build_mingw(self): + with chdir(self, os.path.join(self.source_folder, "win32")): + # configuration + yes_no = lambda v: "yes" if v else "no" + args = [ + "cscript", + "configure.js", + "compiler=mingw", + f"prefix={self.package_folder}", + f"debug={yes_no(self.settings.build_type == 'Debug')}", + f"static={yes_no(not self.options.shared)}", + ] + + incdirs = [incdir for dep in self.dependencies.values() for incdir in dep.cpp_info.includedirs] + libdirs = [libdir for dep in self.dependencies.values() for libdir in dep.cpp_info.libdirs] + args.append(f"include=\"{' -I'.join(incdirs)}\"") + args.append(f"lib=\"{' -L'.join(libdirs)}\"") - for name in self._option_names: - value = getattr(self.options, name) - value = ("--with-%s" % name) if value else ("--without-%s" % name) - configure_args.append(value) + for name in self._option_names: + cname = { + "mem-debug": "mem_debug", + "run-debug": "run_debug", + "docbook": "docb", + }.get(name, name) + args.append(f"{cname}={yes_no(getattr(self.options, name))}") + configure_command = " ".join(args) + self.output.info(configure_command) + self.run(configure_command) + + # build + def fix_library(option, package, old_libname): + if option: + replace_in_file(self, + "Makefile.mingw", + f"LIBS += -l{old_libname}", + f"LIBS += -l{' -l'.join(self.dependencies[package].cpp_info.libs)}", + ) + + fix_library(self.options.iconv, "libiconv", "iconv") + fix_library(self.options.zlib, "zlib", "z") + fix_library(self.options.lzma, "xz_utils", "lzma") + + self.run(f"mingw32-make -j{build_jobs(self)} -f Makefile.mingw libxml libxmla") + if self.options.include_utils: + self.run(f"mingw32-make -j{build_jobs(self)} -f Makefile.mingw utils") - self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) - return self._autotools + def _package_mingw(self): + with chdir(self, os.path.join(self.source_folder, "win32")): + mkdir(self, os.path.join(self.package_folder, "include", "libxml2")) + self.run("mingw32-make -f Makefile.mingw install-libs") + if self.options.include_utils: + self.run("mingw32-make -f Makefile.mingw install-dist") def _patch_sources(self): # Break dependency of install on build for makefile in ("Makefile.mingw", "Makefile.msvc"): - tools.replace_in_file(os.path.join(self._source_subfolder, "win32", makefile), + replace_in_file(self, os.path.join(self.source_folder, "win32", makefile), "install-libs : all", "install-libs :") - # fix rpath - if self.settings.os == "Macos": - tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), r"-install_name \$rpath/", "-install_name ") + # relocatable shared lib on macOS + replace_in_file(self, os.path.join(self.source_folder, "configure"), + "-install_name \\$rpath/", + "-install_name @rpath/") def build(self): self._patch_sources() - if self._is_msvc: + if is_msvc(self): self._build_msvc() + elif self._is_mingw_windows: + self._build_mingw() else: - autotools = self._configure_autotools() - autotools.make(["libxml2.la"]) + autotools = Autotools(self) + autotools.configure() + autotools.make("libxml2.la") if self.options.include_utils: - autotools.make(["xmllint", "xmlcatalog", "xml2-config"]) + for target in ["xmllint", "xmlcatalog", "xml2-config"]: + autotools.make(target) def package(self): - # copy package license - self.copy("COPYING", src=self._source_subfolder, dst="licenses", ignore_case=True, keep_path=False) - if self._is_msvc: + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"), ignore_case=True, keep_path=False) + copy(self, "Copyright", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"), ignore_case=True, keep_path=False) + if is_msvc(self): self._package_msvc() # remove redundant libraries to avoid confusion if not self.options.shared: - os.remove(os.path.join(self.package_folder, "bin", "libxml2.dll")) - os.remove(os.path.join(self.package_folder, "lib", "libxml2_a_dll.lib")) - os.remove(os.path.join(self.package_folder, "lib", "libxml2_a.lib" if self.options.shared else "libxml2.lib")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + rm(self, "libxml2.dll", os.path.join(self.package_folder, "bin")) + rm(self, "libxml2_a_dll.lib", os.path.join(self.package_folder, "lib")) + rm(self, "libxml2_a.lib" if self.options.shared else "libxml2.lib", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + elif self._is_mingw_windows: + self._package_mingw() + if self.options.shared: + rm(self, "libxml2.a", os.path.join(self.package_folder, "lib")) + rename(self, os.path.join(self.package_folder, "lib", "libxml2.lib"), + os.path.join(self.package_folder, "lib", "libxml2.dll.a")) + else: + rm(self, "libxml2.dll", os.path.join(self.package_folder, "bin")) + rm(self, "libxml2.lib", os.path.join(self.package_folder, "lib")) else: - autotools = self._configure_autotools() - autotools.make(["install-libLTLIBRARIES", "install-data"]) + autotools = Autotools(self) + + for target in ["install-libLTLIBRARIES", "install-data"]: + autotools.make(target=target, args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) if self.options.include_utils: - autotools.make(["install", "xmllint", "xmlcatalog", "xml2-config"]) + autotools.install() - os.remove(os.path.join(self.package_folder, "lib", "libxml2.la")) - for prefix in ["run", "test"]: - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), prefix + "*") - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rm(self, "*.sh", os.path.join(self.package_folder, "lib")) + rm(self, "run*", os.path.join(self.package_folder, "bin")) + rm(self, "test*", os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) for header in ["win32config.h", "wsockcompat.h"]: - self.copy(pattern=header, src=os.path.join(self._source_subfolder, "include"), - dst=os.path.join("include", "libxml2"), keep_path=False) + copy(self, pattern=header, src=os.path.join(self.source_folder, "include"), + dst=os.path.join(self.package_folder, "include", "libxml2"), keep_path=False) self._create_cmake_module_variables( - os.path.join(self.package_folder, self._module_subfolder, self._module_file) + os.path.join(self.package_folder, self._module_file_rel_path) ) - @staticmethod - def _create_cmake_module_variables(module_file): + def _create_cmake_module_variables(self, module_file): # FIXME: also define LIBXML2_XMLLINT_EXECUTABLE variable content = textwrap.dedent("""\ - if(DEFINED LibXml2_FOUND) - set(LIBXML2_FOUND ${LibXml2_FOUND}) - endif() - if(DEFINED LibXml2_INCLUDE_DIR) - set(LIBXML2_INCLUDE_DIR ${LibXml2_INCLUDE_DIR}) - set(LIBXML2_INCLUDE_DIRS ${LibXml2_INCLUDE_DIR}) + set(LibXml2_FOUND TRUE) + set(LIBXML2_FOUND TRUE) + if(DEFINED LibXml2_INCLUDE_DIRS) + set(LIBXML2_INCLUDE_DIR ${LibXml2_INCLUDE_DIRS}) + set(LIBXML2_INCLUDE_DIRS ${LibXml2_INCLUDE_DIRS}) + elseif(DEFINED libxml2_INCLUDE_DIRS) + set(LIBXML2_LIBRARIES ${libxml2_INCLUDE_DIRS}) + set(LIBXML2_LIBRARY ${libxml2_INCLUDE_DIRS}) endif() if(DEFINED LibXml2_LIBRARIES) set(LIBXML2_LIBRARIES ${LibXml2_LIBRARIES}) set(LIBXML2_LIBRARY ${LibXml2_LIBRARIES}) + elseif(DEFINED libxml2_LIBRARIES) + set(LIBXML2_LIBRARIES ${libxml2_LIBRARIES}) + set(LIBXML2_LIBRARY ${libxml2_LIBRARIES}) endif() if(DEFINED LibXml2_DEFINITIONS) set(LIBXML2_DEFINITIONS ${LibXml2_DEFINITIONS}) + elseif(DEFINED libxml2_DEFINITIONS) + set(LIBXML2_DEFINITIONS ${libxml2_DEFINITIONS}) endif() if(DEFINED LibXml2_VERSION) set(LIBXML2_VERSION_STRING ${LibXml2_VERSION}) + elseif(DEFINED libxml2_VERSION) + set(LIBXML2_VERSION_STRING ${libxml2_VERSION}) endif() """) - tools.save(module_file, content) + save(self, module_file, content) @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") - - @property - def _module_file(self): - return "conan-official-{}-variables.cmake".format(self.name) + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") def package_info(self): - if self._is_msvc: - self.cpp_info.libs = ['libxml2' if self.options.shared else 'libxml2_a'] - else: - self.cpp_info.libs = ['xml2'] + # FIXME: Provide LibXml2::xmllint & LibXml2::xmlcatalog imported target for executables + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_module_file_name", "LibXml2") + self.cpp_info.set_property("cmake_file_name", "libxml2") + self.cpp_info.set_property("cmake_target_name", "LibXml2::LibXml2") + self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) + self.cpp_info.set_property("pkg_config_name", "libxml-2.0") + prefix = "lib" if is_msvc(self) else "" + suffix = "_a" if is_msvc(self) and not self.options.shared else "" + self.cpp_info.libs = [f"{prefix}xml2{suffix}"] self.cpp_info.includedirs.append(os.path.join("include", "libxml2")) if not self.options.shared: self.cpp_info.defines = ["LIBXML_STATIC"] if self.options.include_utils: bindir = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.output.info(f"Appending PATH environment variable: {bindir}") self.env_info.PATH.append(bindir) if self.settings.os in ["Linux", "FreeBSD", "Android"]: self.cpp_info.system_libs.append("m") if self.options.threads and self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("pthread") + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("dl") elif self.settings.os == "Windows": if self.options.ftp or self.options.http: self.cpp_info.system_libs.extend(["ws2_32", "wsock32"]) - # FIXME: cmake creates LibXml2::xmllint imported target for the xmllint executable + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.filenames["cmake_find_package"] = "LibXml2" + self.cpp_info.filenames["cmake_find_package_multi"] = "libxml2" self.cpp_info.names["cmake_find_package"] = "LibXml2" self.cpp_info.names["cmake_find_package_multi"] = "LibXml2" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.names["pkg_config"] = "libxml-2.0" - self.cpp_info.builddirs.append(self._module_subfolder) - self.cpp_info.build_modules = [os.path.join(self._module_subfolder, self._module_file)] diff --git a/recipes/libxml2/all/test_module_package/CMakeLists.txt b/recipes/libxml2/all/test_module_package/CMakeLists.txt new file mode 100644 index 0000000000000..90d37ee9afb23 --- /dev/null +++ b/recipes/libxml2/all/test_module_package/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.12) +project(test_package LANGUAGES C) + +find_package(LibXml2 REQUIRED MODULE) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE LibXml2::LibXml2) + +# Test whether variables from https://cmake.org/cmake/help/latest/module/FindLibXml2.html +# are properly defined in conan generators +set(_custom_vars + LibXml2_FOUND # since CMake 3.14 + LIBXML2_FOUND # until CMake 3.14 + LIBXML2_INCLUDE_DIR + LIBXML2_INCLUDE_DIRS + LIBXML2_LIBRARIES + LIBXML2_DEFINITIONS + LIBXML2_VERSION_STRING +) +foreach(_custom_var ${_custom_vars}) + if(DEFINED _custom_var) + message(STATUS "${_custom_var}: ${${_custom_var}}") + else() + message(FATAL_ERROR "${_custom_var} not defined") + endif() +endforeach() diff --git a/recipes/libxml2/all/test_module_package/conanfile.py b/recipes/libxml2/all/test_module_package/conanfile.py new file mode 100644 index 0000000000000..20481a742d614 --- /dev/null +++ b/recipes/libxml2/all/test_module_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + xml_path = os.path.join(self.source_folder, os.pardir, "test_package", "books.xml") + self.run(f"{bin_path} {xml_path}", env="conanrun") diff --git a/recipes/libxml2/all/test_package/CMakeLists.txt b/recipes/libxml2/all/test_package/CMakeLists.txt index ef5697dfd1bf3..9d8bc300051af 100644 --- a/recipes/libxml2/all/test_package/CMakeLists.txt +++ b/recipes/libxml2/all/test_package/CMakeLists.txt @@ -1,17 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(LibXml2 REQUIRED) -message("LIBXML2_FOUND: ${LIBXML2_FOUND}") -message("LIBXML2_INCLUDE_DIR: ${LIBXML2_INCLUDE_DIR}") -message("LIBXML2_INCLUDE_DIRS: ${LIBXML2_INCLUDE_DIRS}") -message("LIBXML2_LIBRARIES: ${LIBXML2_LIBRARIES}") -message("LIBXML2_LIBRARY: ${LIBXML2_LIBRARY}") -message("LIBXML2_DEFINITIONS: ${LIBXML2_DEFINITIONS}") -message("LIBXML2_VERSION_STRING: ${LIBXML2_VERSION_STRING}") +find_package(libxml2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} LibXml2::LibXml2) +target_link_libraries(${PROJECT_NAME} PRIVATE LibXml2::LibXml2) diff --git a/recipes/libxml2/all/test_package/conanfile.py b/recipes/libxml2/all/test_package/conanfile.py index ad6928e48cb28..dc536a85d6547 100644 --- a/recipes/libxml2/all/test_package/conanfile.py +++ b/recipes/libxml2/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,7 +21,7 @@ def build(self): cmake.build() def test(self): - bin_path = os.path.join("bin", "test_package") - xml_path = os.path.join(self.source_folder, "books.xml") - bin_arg_path = "%s %s" % (bin_path, xml_path) - self.run(bin_arg_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + xml_path = os.path.join(self.source_folder, "books.xml") + self.run(f"{bin_path} {xml_path}", env="conanrun") diff --git a/recipes/libxml2/all/test_v1_module_package/CMakeLists.txt b/recipes/libxml2/all/test_v1_module_package/CMakeLists.txt new file mode 100644 index 0000000000000..75233d23b3349 --- /dev/null +++ b/recipes/libxml2/all/test_v1_module_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_module_package + ${CMAKE_CURRENT_BINARY_DIR}/test_module_package) diff --git a/recipes/libxml2/all/test_v1_module_package/conanfile.py b/recipes/libxml2/all/test_v1_module_package/conanfile.py new file mode 100644 index 0000000000000..ca3b4e232a4f3 --- /dev/null +++ b/recipes/libxml2/all/test_v1_module_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + xml_path = os.path.join(self.source_folder, os.pardir, "test_package", "books.xml") + self.run(f"{bin_path} {xml_path}", run_environment=True) diff --git a/recipes/libxml2/all/test_v1_package/CMakeLists.txt b/recipes/libxml2/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libxml2/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libxml2/all/test_v1_package/conanfile.py b/recipes/libxml2/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..ae0f76f08489b --- /dev/null +++ b/recipes/libxml2/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + xml_path = os.path.join(self.source_folder, os.pardir, "test_package", "books.xml") + self.run(f"{bin_path} {xml_path}", run_environment=True) diff --git a/recipes/libxml2/config.yml b/recipes/libxml2/config.yml index 1b7f57c0a7e6b..6e02d8e0c9b1d 100644 --- a/recipes/libxml2/config.yml +++ b/recipes/libxml2/config.yml @@ -1,5 +1,13 @@ versions: - "2.9.9": + "2.10.3": + folder: all + "2.9.14": + folder: all + "2.9.13": + folder: all + "2.9.12": folder: all "2.9.10": folder: all + "2.9.9": + folder: all diff --git a/recipes/libxmlpp/2.x.x/conandata.yml b/recipes/libxmlpp/2.x.x/conandata.yml new file mode 100644 index 0000000000000..c28f5a99de926 --- /dev/null +++ b/recipes/libxmlpp/2.x.x/conandata.yml @@ -0,0 +1,15 @@ +sources: + "5.0.1": + url: "https://github.com/libxmlplusplus/libxmlplusplus/releases/download/5.0.1/libxml++-5.0.1.tar.xz" + sha256: "15c38307a964fa6199f4da6683a599eb7e63cc89198545b36349b87cf9aa0098" + "2.42.1": + url: "https://github.com/libxmlplusplus/libxmlplusplus/releases/download/2.42.1/libxml++-2.42.1.tar.xz" + sha256: "9b59059abe5545d28ceb388a55e341095f197bd219c73e6623aeb6d801e00be8" + +patches: + "5.0.1": + - patch_file: "patches/5.0.1-0001-enable_static_builds_on_msvc.patch" + base_path: "source_subfolder" + "2.42.1": + - patch_file: "patches/2.42.1-0001-enable_static_builds_on_msvc.patch" + base_path: "source_subfolder" diff --git a/recipes/libxmlpp/2.x.x/conanfile.py b/recipes/libxmlpp/2.x.x/conanfile.py new file mode 100644 index 0000000000000..1297a686c1b40 --- /dev/null +++ b/recipes/libxmlpp/2.x.x/conanfile.py @@ -0,0 +1,155 @@ +from conans import ConanFile, Meson, tools +from conan.tools.files import rename +from conans.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc +import shutil +import os +import functools + +required_conan_version = ">=1.45.0" + +class LibXMLPlusPlus(ConanFile): + # FIXME: naming the library "libxml++" causes conan not to add it to the + # environment path on windows + name = "libxmlpp" + description = "libxml++ (a.k.a. libxmlplusplus) provides a C++ interface to XML files" + license = "LGPL-2.1" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/libxmlplusplus/libxmlplusplus" + topics = ["xml", "parser", "wrapper"] + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "pkg_config" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("libxml2/2.9.14") + if tools.Version(self.version) <= "2.42.1": + self.requires("glibmm/2.66.4") + else: + self.requires("glibmm/2.72.1") + + def validate(self): + if hasattr(self, "settings_build") and tools.cross_building(self): + raise ConanInvalidConfiguration("Cross-building not implemented") + + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + def build_requirements(self): + self.build_requires("meson/0.63.0") + self.build_requires("pkgconf/1.7.4") + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + strip_root=True, + destination=self._source_subfolder, + ) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + if is_msvc(self): + # when using cpp_std=c++NM the /permissive- flag is added which + # attempts enforcing standard conformant c++ code. the problem is + # that older versions of the Windows SDK isn't standard conformant! + # see: + # https://developercommunity.visualstudio.com/t/error-c2760-in-combaseapih-with-windows-sdk-81-and/185399 + tools.replace_in_file( + os.path.join(self._source_subfolder, "meson.build"), + "cpp_std=c++", "cpp_std=vc++") + + @functools.lru_cache(1) + def _configure_meson(self): + meson = Meson(self) + defs = { + "build-examples": "false", + "build-tests": "false", + "build-documentation": "false", + "msvc14x-parallel-installable": "false", + "default_library": "shared" if self.options.shared else "static", + } + meson.configure( + defs=defs, + build_folder=self._build_subfolder, + source_folder=self._source_subfolder, + pkg_config_paths=[self.install_folder], + ) + return meson + + def build(self): + self._patch_sources() + with tools.environment_append(tools.RunEnvironment(self).vars): + meson = self._configure_meson() + meson.build() + + def package(self): + lib_version = "2.6" if tools.Version(self.version) <= "2.42.1" else "5.0" + + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + meson = self._configure_meson() + meson.install() + + shutil.move( + os.path.join(self.package_folder, "lib", f"libxml++-{lib_version}", "include", "libxml++config.h"), + os.path.join(self.package_folder, "include", f"libxml++-{lib_version}", "libxml++config.h")) + + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", f"libxml++-{lib_version}")) + + if is_msvc(self): + tools.remove_files_by_mask( + os.path.join(self.package_folder, "bin"), "*.pdb") + if not self.options.shared: + rename( + self, + os.path.join(self.package_folder, "lib", f"libxml++-{lib_version}.a"), + os.path.join(self.package_folder, "lib", f"xml++-{lib_version}.lib")) + + def package_info(self): + lib_version = "2.6" if tools.Version(self.version) <= "2.42.1" else "5.0" + + self.cpp_info.set_property("cmake_module_file_name", "libxml++") + self.cpp_info.set_property("cmake_module_target_name", "libxml++::libxml++") + self.cpp_info.set_property("pkg_config_name", "libxml++") + self.cpp_info.components[f"libxml++-{lib_version}"].set_property("pkg_config_name", f"libxml++-{lib_version}") + self.cpp_info.components[f"libxml++-{lib_version}"].libs = [f"xml++-{lib_version}"] + self.cpp_info.components[f"libxml++-{lib_version}"].includedirs = [ + os.path.join("include", f"libxml++-{lib_version}") + ] + self.cpp_info.components[f"libxml++-{lib_version}"].requires = [ + "glibmm::glibmm", "libxml2::libxml2" + ] + + self.cpp_info.names["cmake_find_package"] = "libxml++" + self.cpp_info.names["cmake_find_package_multi"] = "libxml++" + self.cpp_info.names["pkg_config"] = "libxml++" + self.cpp_info.components[f"libxml++-{lib_version}"].names["pkg_config"] = f"libxml++-{lib_version}" diff --git a/recipes/libxmlpp/2.x.x/patches/2.42.1-0001-enable_static_builds_on_msvc.patch b/recipes/libxmlpp/2.x.x/patches/2.42.1-0001-enable_static_builds_on_msvc.patch new file mode 100644 index 0000000000000..32d4ca9bbdc42 --- /dev/null +++ b/recipes/libxmlpp/2.x.x/patches/2.42.1-0001-enable_static_builds_on_msvc.patch @@ -0,0 +1,47 @@ +diff --git a/libxml++config.h.meson b/libxml++config.h.meson +index fdae143..5d853c2 100755 +--- a/libxml++config.h.meson ++++ b/libxml++config.h.meson +@@ -21,9 +21,16 @@ + /* Micro version number of libxml++. */ + #mesondefine LIBXMLXX_MICRO_VERSION + +-#if defined (GLIBMM_DLL) && !defined (LIBXMLXX_STATIC) ++/* Defined if libxml++ is built as a static library. */ ++#mesondefine LIBXMLXX_STATIC ++ ++#if !defined (LIBXMLXX_STATIC) + #ifdef LIBXMLPP_BUILD +- #define LIBXMLPP_API __declspec(dllexport) ++ #ifdef __GNUC__ ++ #define LIBXMLPP_API __attribute__((visibility("default"))) ++ #else ++ #define LIBXMLPP_API __declspec(dllexport) ++ #endif + #elif !defined (__GNUC__) + #define LIBXMLPP_API __declspec(dllimport) + #else /* don't dllimport classes/methods on GCC/MinGW */ +diff --git a/meson.build b/meson.build +index e89f2c6..20d66ed 100644 +--- a/meson.build ++++ b/meson.build +@@ -292,15 +292,13 @@ endif + # Always set for backwards compatibility. + pkg_conf_data.set('LIBXMLCPP_EXCEPTIONS_ENABLED', 1) + ++if get_option('default_library') == 'static' ++ pkg_conf_data.set('LIBXMLXX_STATIC', 1) ++endif ++ + # Static library? + library_build_type = get_option('default_library') + +-if cpp_compiler.get_argument_syntax() == 'msvc' +- if library_build_type == 'static' or library_build_type == 'both' +- error('Static builds are not supported by MSVC-style builds') +- endif +-endif +- + configure_file( + input: 'libxml++-2.6.pc.in', + output: '@BASENAME@', diff --git a/recipes/libxmlpp/2.x.x/patches/5.0.1-0001-enable_static_builds_on_msvc.patch b/recipes/libxmlpp/2.x.x/patches/5.0.1-0001-enable_static_builds_on_msvc.patch new file mode 100644 index 0000000000000..135415955e944 --- /dev/null +++ b/recipes/libxmlpp/2.x.x/patches/5.0.1-0001-enable_static_builds_on_msvc.patch @@ -0,0 +1,38 @@ +diff --git a/libxml++config.h.meson b/libxml++config.h.meson +index 2f0264f..11e0c2c 100755 +--- a/libxml++config.h.meson ++++ b/libxml++config.h.meson +@@ -16,6 +16,9 @@ + /* Micro version number of libxml++. */ + #mesondefine LIBXMLXX_MICRO_VERSION + ++/* Defined if libxml++ is built as a static library. */ ++#mesondefine LIBXMLXX_STATIC ++ + // Enable DLL-specific stuff only when not building a static library + #if !defined(__CYGWIN__) && (defined(__MINGW32__) || defined(_MSC_VER)) && !defined(LIBXMLXX_STATIC) + # define LIBXMLPP_DLL 1 +diff --git a/meson.build b/meson.build +index 6e86ca3..8557846 100644 +--- a/meson.build ++++ b/meson.build +@@ -274,15 +274,13 @@ if cpp_compiler.compiles(files('tools' / 'conf_tests' / 'have_exception_ptr.cc') + pkg_conf_data.set('LIBXMLXX_HAVE_EXCEPTION_PTR', 1) + endif + ++if get_option('default_library') == 'static' ++ pkg_conf_data.set('LIBXMLXX_STATIC', 1) ++endif ++ + # Static library? + library_build_type = get_option('default_library') + +-if cpp_compiler.get_argument_syntax() == 'msvc' +- if library_build_type == 'static' or library_build_type == 'both' +- error('Static builds are not supported by MSVC-style builds') +- endif +-endif +- + configure_file( + input: 'libxml++.pc.in', + output: xmlxx_pcname + '.pc', diff --git a/recipes/libxmlpp/2.x.x/test_package/CMakeLists.txt b/recipes/libxmlpp/2.x.x/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..acd4c1ac2441b --- /dev/null +++ b/recipes/libxmlpp/2.x.x/test_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libxml++ REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +if(TARGET libxml++::libxml++-2.6) + target_link_libraries(${PROJECT_NAME} libxml++::libxml++-2.6) +else() + target_link_libraries(${PROJECT_NAME} libxml++::libxml++-5.0) +endif() diff --git a/recipes/libxmlpp/2.x.x/test_package/conanfile.py b/recipes/libxmlpp/2.x.x/test_package/conanfile.py new file mode 100644 index 0000000000000..8aaecaac427e8 --- /dev/null +++ b/recipes/libxmlpp/2.x.x/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = f'{os.path.join("bin", "test_package")} \ + {os.path.join(self.source_folder, "example.xml")}' + self.run(bin_path, run_environment=True) diff --git a/recipes/libxmlpp/2.x.x/test_package/example.xml b/recipes/libxmlpp/2.x.x/test_package/example.xml new file mode 100644 index 0000000000000..a7a9ee8349141 --- /dev/null +++ b/recipes/libxmlpp/2.x.x/test_package/example.xml @@ -0,0 +1,11 @@ + + + + + + + + + Some content :-) + + diff --git a/recipes/libxmlpp/2.x.x/test_package/test_package.cpp b/recipes/libxmlpp/2.x.x/test_package/test_package.cpp new file mode 100644 index 0000000000000..028b0bb3d0bac --- /dev/null +++ b/recipes/libxmlpp/2.x.x/test_package/test_package.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2002 The libxml++ development team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include + +#include +#include + +struct indent { + int depth_; + explicit indent(int depth): depth_(depth) {}; +}; + +std::ostream & operator<<(std::ostream & o, indent const & in) +{ + for(int i = 0; i != in.depth_; ++i) + { + o << " "; + } + return o; +} + +int main(int argc, char** argv) +{ + if (argc == 1) { + std::cerr << "Expected an xml file as a command line argument!\n"; + return EXIT_FAILURE; + } + + try + { + xmlpp::TextReader reader(argv[1]); + + while(reader.read()) + { + int depth = reader.get_depth(); + std::cout << indent(depth) << "--- node ---" << std::endl; + std::cout << indent(depth) << "name: " << reader.get_name() << std::endl; + std::cout << indent(depth) << "depth: " << reader.get_depth() << std::endl; + + if(reader.has_attributes()) + { + std::cout << indent(depth) << "attributes: " << std::endl; + reader.move_to_first_attribute(); + do + { + std::cout << indent(depth) << " " << reader.get_name() << ": " << reader.get_value() << std::endl; + } while(reader.move_to_next_attribute()); + reader.move_to_element(); + } + else + { + std::cout << indent(depth) << "no attributes" << std::endl; + } + + if(reader.has_value()) + std::cout << indent(depth) << "value: '" << reader.get_value() << "'" << std::endl; + else + std::cout << indent(depth) << "novalue" << std::endl; + + } + } + catch(const std::exception& e) + { + std::cerr << "Exception caught: " << e.what() << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} + diff --git a/recipes/libxmlpp/config.yml b/recipes/libxmlpp/config.yml new file mode 100644 index 0000000000000..4976ee096e564 --- /dev/null +++ b/recipes/libxmlpp/config.yml @@ -0,0 +1,5 @@ +versions: + "5.0.1": + folder: "2.x.x" + "2.42.1": + folder: "2.x.x" diff --git a/recipes/libxpm/all/CMakeLists.txt b/recipes/libxpm/all/CMakeLists.txt new file mode 100644 index 0000000000000..77475adeda3d9 --- /dev/null +++ b/recipes/libxpm/all/CMakeLists.txt @@ -0,0 +1,95 @@ +cmake_minimum_required(VERSION 3.1) + +project(libXpm VERSION "${CONAN_libXpm_VERSION}" LANGUAGES C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +# ---- X11 dependency ---- + +if(NOT WIN32) + find_path(X11_INCLUDE_DIR X11/Xlib.h) + find_library(X11_LIBRARY X11) + foreach(var X11_INCLUDE_DIR X11_LIBRARY) + if(NOT ${var}) + message(FATAL_ERROR "${var} is required. (Value: ${${var}})") + endif() + endforeach() +endif() + +# ---- Library ---- + +add_library( + Xpm + src/Attrib.c + src/CrBufFrI.c + src/CrDatFrI.c + src/create.c + src/CrIFrBuf.c + src/CrIFrDat.c + src/data.c + src/hashtab.c + src/Image.c + src/Info.c + src/misc.c + src/parse.c + src/RdFToBuf.c + src/RdFToDat.c + src/RdFToI.c + src/rgb.c + src/scan.c + src/simx.c + src/WrFFrBuf.c + src/WrFFrDat.c + src/WrFFrI.c +) + +if(WIN32) + target_sources(Xpm PRIVATE windows/libXpm.def) + target_compile_definitions(Xpm PRIVATE FOR_MSW) +else() + target_sources( + Xpm PRIVATE + src/CrBufFrP.c + src/CrDatFrP.c + src/CrIFrP.c + src/RdFToP.c + src/WrFFrP.c + ) + target_include_directories(Xpm PRIVATE "${X11_INCLUDE_DIR}") + target_link_libraries(Xpm PRIVATE "${X11_LIBRARY}") +endif() + +if(MSVC) + target_compile_definitions( + Xpm PRIVATE + _CRT_SECURE_NO_WARNINGS + _CRT_NONSTDC_NO_DEPRECATE + ) + target_compile_options(Xpm PRIVATE /wd4267 /wd4244 /wd4018) +endif() + +target_include_directories(Xpm PRIVATE include/X11) + +set_target_properties( + Xpm PROPERTIES + VERSION "${PROJECT_VERSION}" + SOVERSION "${PROJECT_VERSION_MAJOR}" +) + +# ---- Install ---- + +include(GNUInstallDirs) + +install( + TARGETS Xpm + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +install(DIRECTORY include/X11 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + +if(WIN32) + install(FILES src/simx.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/X11") +endif() diff --git a/recipes/libxpm/all/conandata.yml b/recipes/libxpm/all/conandata.yml new file mode 100644 index 0000000000000..3db82178c2eeb --- /dev/null +++ b/recipes/libxpm/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.5.13": + sha256: "516fcb7a3cc5b491ca2b95df29018b1643c40649d72473d3c62379d8fdc472ff" + url: https://gitlab.freedesktop.org/xorg/lib/libxpm/-/archive/libXpm-3.5.13/libxpm-libXpm-3.5.13.tar.gz diff --git a/recipes/libxpm/all/conanfile.py b/recipes/libxpm/all/conanfile.py new file mode 100644 index 0000000000000..63d51162a71f7 --- /dev/null +++ b/recipes/libxpm/all/conanfile.py @@ -0,0 +1,71 @@ +import functools +import os + +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.43.0" + + +class LibXpmConan(ConanFile): + name = "libxpm" + description = "X Pixmap (XPM) image file format library" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gitlab.freedesktop.org/xorg/lib/libxpm" + topics = "xpm" + license = "MIT-open-group" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake" + exports_sources = "CMakeLists.txt", "windows/*" + no_copy_source = True + + def validate(self): + if self.settings.os not in ("Windows", "Linux", "FreeBSD"): + raise ConanInvalidConfiguration( + "libXpm is supported only on Windows, Linux and FreeBSD" + ) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + if self.settings.os != "Windows": + self.requires("xorg/system") + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["CONAN_libXpm_VERSION"] = self.version + cmake.configure() + return cmake + + def build(self): + self._configure_cmake().build() + + def package(self): + self.copy("COPYING", "licenses") + self.copy("COPYRIGHT", "licenses") + self._configure_cmake().install() + + def package_info(self): + self.cpp_info.libs = ["Xpm"] + if self.settings.os == "Windows": + self.cpp_info.defines = ["FOR_MSW"] diff --git a/recipes/libxpm/all/test_package/CMakeLists.txt b/recipes/libxpm/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..0ea6d5bc37b28 --- /dev/null +++ b/recipes/libxpm/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(libxpm REQUIRED CONFIG) + +add_executable(test_package test_package.c) +target_link_libraries(test_package PRIVATE libxpm::libxpm) diff --git a/recipes/libxpm/all/test_package/conanfile.py b/recipes/libxpm/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a8c92dea63335 --- /dev/null +++ b/recipes/libxpm/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libxpm/all/test_package/test_package.c b/recipes/libxpm/all/test_package/test_package.c new file mode 100644 index 0000000000000..ed1efad8c383c --- /dev/null +++ b/recipes/libxpm/all/test_package/test_package.c @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char const* argv[]) +{ + (void)argc; + (void)argv; + + XpmFree(NULL); + + return 0; +} diff --git a/recipes/libxpm/all/windows/libXpm.def b/recipes/libxpm/all/windows/libXpm.def new file mode 100644 index 0000000000000..5381386ee75ee --- /dev/null +++ b/recipes/libxpm/all/windows/libXpm.def @@ -0,0 +1,29 @@ +EXPORTS + +XpmCreateImageFromData +XpmCreateDataFromImage +XpmReadFileToImage +XpmWriteFileFromImage +XpmCreateImageFromBuffer +XpmReadFileToBuffer +XpmWriteFileFromBuffer +XpmReadFileToData +XpmWriteFileFromData +XpmAttributesSize +XpmFreeAttributes +XpmFreeExtensions +XpmFreeXpmImage +XpmFreeXpmInfo +XpmGetErrorString +XpmLibraryVersion + +XpmReadFileToXpmImage +XpmWriteFileFromXpmImage +XpmCreateImageFromXpmImage +XpmCreateXpmImageFromImage +XpmCreateDataFromXpmImage +XpmCreateXpmImageFromData +XpmCreateXpmImageFromBuffer +XpmCreateBufferFromXpmImage + +XpmFree diff --git a/recipes/libxpm/config.yml b/recipes/libxpm/config.yml new file mode 100644 index 0000000000000..96f25a4bd1d23 --- /dev/null +++ b/recipes/libxpm/config.yml @@ -0,0 +1,3 @@ +versions: + "3.5.13": + folder: all diff --git a/recipes/libxshmfence/all/conandata.yml b/recipes/libxshmfence/all/conandata.yml new file mode 100644 index 0000000000000..8c16f251fa486 --- /dev/null +++ b/recipes/libxshmfence/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.3": + url: "https://www.x.org/archive//individual/lib/libxshmfence-1.3.tar.gz" + sha256: "7eb3d46ad91bab444f121d475b11b39273142d090f7e9ac43e6a87f4ff5f902c" diff --git a/recipes/libxshmfence/all/conanfile.py b/recipes/libxshmfence/all/conanfile.py new file mode 100644 index 0000000000000..a4136cd3cae48 --- /dev/null +++ b/recipes/libxshmfence/all/conanfile.py @@ -0,0 +1,110 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conans.errors import ConanInvalidConfiguration +import contextlib +import os + +required_conan_version = ">=1.33.0" + +class LibxshmfenceConan(ConanFile): + name = "libxshmfence" + license = "X11" + homepage = "https://gitlab.freedesktop.org/xorg/lib/libxshmfence" + url = "https://github.com/conan-io/conan-center-index" + description = "Shared memory 'SyncFence' synchronization primitive" + topics = ("shared", "memory", "syncfence", "synchronization", "interprocess") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "pkg_config" + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("Windows is not supported by libxshmfence recipe. Contributions are welcome") + + def build_requirements(self): + self.build_requires("automake/1.16.4") + self.build_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def requirements(self): + self.requires("xorg-proto/2021.4") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self): + env = { + "CC": "{} cl -nologo".format(self._user_info_build["automake"].compile).replace("\\", "/"), + } + with tools.environment_append(env): + yield + else: + yield + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=self._settings_build.os == "Windows") + self._autotools.libs = [] + yes_no = lambda v: "yes" if v else "no" + configure_args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + ] + self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + + def package_info(self): + self.cpp_info.libs = ["xshmfence"] + self.cpp_info.names["pkg_config"] = "xshmfence" diff --git a/recipes/libxshmfence/all/test_package/CMakeLists.txt b/recipes/libxshmfence/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b08d77d4e4328 --- /dev/null +++ b/recipes/libxshmfence/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libxshmfence REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} libxshmfence::libxshmfence) diff --git a/recipes/libxshmfence/all/test_package/conanfile.py b/recipes/libxshmfence/all/test_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/libxshmfence/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libxshmfence/all/test_package/test_package.c b/recipes/libxshmfence/all/test_package/test_package.c new file mode 100644 index 0000000000000..2dc0779250663 --- /dev/null +++ b/recipes/libxshmfence/all/test_package/test_package.c @@ -0,0 +1,21 @@ +#include "X11/xshmfence.h" + +int main() { + int fd; + struct xshmfence *x; + + fd = xshmfence_alloc_shm(); + if (fd < 0) { + return 1; + } + + + x = xshmfence_map_shm(fd); + if (!x) { + return 1; + } + + xshmfence_unmap_shm(x); + + return 0; +} diff --git a/recipes/libxshmfence/config.yml b/recipes/libxshmfence/config.yml new file mode 100644 index 0000000000000..d2eb4ed4a511f --- /dev/null +++ b/recipes/libxshmfence/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3": + folder: all diff --git a/recipes/libxslt/all/conandata.yml b/recipes/libxslt/all/conandata.yml index 8ece81ad59f90..e1f22d6ae5d44 100644 --- a/recipes/libxslt/all/conandata.yml +++ b/recipes/libxslt/all/conandata.yml @@ -1,8 +1,10 @@ sources: "1.1.34": - sha256: "98b1bd46d6792925ad2dfe9a87452ea2adebf69dcb9919ffd55bf926a7f93f7f" - url: "http://xmlsoft.org/sources/libxslt-1.1.34.tar.gz" + sha256: "28c47db33ab4daefa6232f31ccb3c65260c825151ec86ec461355247f3f56824" + url: "https://download.gnome.org/sources/libxslt/1.1/libxslt-1.1.34.tar.xz" patches: "1.1.34": - - patch_file: "patches/0001-Add-configuration-for-profiler.diff" + - patch_file: "patches/0001-allow-xsltproc-link-shared-mt.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-Add-configuration-for-profiler.patch" base_path: "source_subfolder" diff --git a/recipes/libxslt/all/conanfile.py b/recipes/libxslt/all/conanfile.py index 74e0ff0bc06a8..5dce7dca31dee 100644 --- a/recipes/libxslt/all/conanfile.py +++ b/recipes/libxslt/all/conanfile.py @@ -1,6 +1,10 @@ -import glob -import os +from conan.tools.microsoft import is_msvc, msvc_runtime_flag from conans import ConanFile, tools, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment +from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.45.0" class LibxsltConan(ConanFile): @@ -10,70 +14,101 @@ class LibxsltConan(ConanFile): topics = ("XSLT", "processor") homepage = "https://xmlsoft.org" license = "MIT" - settings = "os", "arch", "compiler", "build_type" - default_options = {'shared': False, - 'fPIC': True, - "debugger": False, - "crypto": False, - "profiler": False, - "plugins": False} - options = {name: [True, False] for name in default_options.keys()} - _option_names = [name for name in default_options.keys() if name not in ["shared", "fPIC"]] - _source_subfolder = "source_subfolder" - exports_sources = "patches/**" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "debugger": [True, False], + "crypto": [True, False], + "profiler": [True, False], + "plugins": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "debugger": False, + "crypto": False, + "profiler": False, + "plugins": False, + } - def requirements(self): - self.requires("libxml2/2.9.10") + @property + def _source_subfolder(self): + return "source_subfolder" @property - def _is_msvc(self): - return self.settings.compiler == 'Visual Studio' + def _settings_build(self): + return getattr(self, "settings_build", self.settings) @property - def _full_source_subfolder(self): - return os.path.join(self.source_folder, self._source_subfolder) + def _option_names(self): + return [name for name in self.default_options.keys() if name not in ["shared", "fPIC"]] - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("libxslt-{0}".format(self.version), self._source_subfolder) + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def requirements(self): + self.requires("libxml2/2.9.14") + + def validate(self): + if self.options.plugins and not self.options.shared: + raise ConanInvalidConfiguration("plugins require shared") + + def build_requirements(self): + if self._settings_build.os == "Windows" and not is_msvc(self) and \ + not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): - self._patch_sources() - if self._is_msvc: - self._build_windows() + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + if is_msvc(self): + self._build_msvc() else: - self._build_with_configure() - - def _build_windows(self): - with tools.chdir(os.path.join(self._full_source_subfolder, 'win32')): + # Relocatable shared libs on macOS + tools.replace_in_file( + os.path.join(self._source_subfolder, "configure"), + "-install_name \\$rpath/", + "-install_name @rpath/" + ) + autotools = self._configure_autotools() + autotools.make() + + def _build_msvc(self): + with tools.chdir(os.path.join(self._source_subfolder, "win32")): debug = "yes" if self.settings.build_type == "Debug" else "no" static = "no" if self.options.shared else "yes" - with tools.vcvars(self.settings): - args = ["cscript", - "configure.js", - "compiler=msvc", - "prefix=%s" % self.package_folder, - "cruntime=/%s" % self.settings.compiler.runtime, - "debug=%s" % debug, - "static=%s" % static, - 'include="%s"' % ";".join(self.deps_cpp_info.include_paths), - 'lib="%s"' % ";".join(self.deps_cpp_info.lib_paths), - 'iconv=no', - 'xslt_debug=no'] + with tools.vcvars(self): + args = [ + "cscript", + "configure.js", + "compiler=msvc", + "prefix={}".format(self.package_folder), + "cruntime=/{}".format(msvc_runtime_flag(self)), + "debug={}".format(debug), + "static={}".format(static), + "include=\"{}\"".format(";".join(self.deps_cpp_info.include_paths)), + "lib=\"{}\"".format(";".join(self.deps_cpp_info.lib_paths)), + "iconv=no", + "xslt_debug=no", + ] for name in self._option_names: cname = {"plugins": "modules"}.get(name, name) value = getattr(self.options, name) @@ -110,70 +145,93 @@ def fix_library(option, package, old_libname): tools.replace_in_file("Makefile.msvc", "libxml2.lib", format_libs("libxml2")) tools.replace_in_file("Makefile.msvc", "libxml2_a.lib", format_libs("libxml2")) - with tools.environment_append(VisualStudioBuildEnvironment(self).vars): - self.run("nmake /f Makefile.msvc install") - - def _build_with_configure(self): - env_build = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - full_install_subfolder = tools.unix_path(self.package_folder) - # fix rpath - if self.settings.os == "Macos": - tools.replace_in_file(os.path.join(self._full_source_subfolder, "configure"), r"-install_name \$rpath/", "-install_name ") - configure_args = ['--with-python=no', '--prefix=%s' % full_install_subfolder] - if self.options.shared: - configure_args.extend(['--enable-shared', '--disable-static']) - else: - configure_args.extend(['--enable-static', '--disable-shared']) - - libxml_src = "--with-libxml-src=" + tools.unix_path(self.deps_cpp_info["libxml2"].rootpath) - configure_args.append(libxml_src) + # Avoid to indirectly build both static & shared when we build utils + tools.replace_in_file( + "Makefile.msvc", + "$(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxslt libxslta libexslt libexslta", + "$(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxslt{0} libexslt{0}".format("" if self.options.shared else "a"), + ) + with tools.environment_append(VisualStudioBuildEnvironment(self).vars): + targets = "libxslt{0} libexslt{0} utils".format("" if self.options.shared else "a") + self.run("nmake /f Makefile.msvc {}".format(targets)) + + @functools.lru_cache(1) + def _configure_autotools(self): + autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + yes_no = lambda v: "yes" if v else "no" + args = [ + "--enable-shared={}".format(yes_no(self.options.shared)), + "--enable-static={}".format(yes_no(not self.options.shared)), + "--with-python=no", + "--with-libxml-src={}".format(tools.unix_path(self.deps_cpp_info["libxml2"].rootpath)), + ] for name in self._option_names: value = getattr(self.options, name) - value = ("--with-%s" % name) if value else ("--without-%s" % name) - configure_args.append(value) - - env_build.configure(args=configure_args, configure_dir=self._full_source_subfolder) - env_build.make(args=["install", "V=1"]) + args.append("--with-{}={}".format(name, yes_no(value))) + autotools.configure(args=args, configure_dir=self._source_subfolder) + return autotools def package(self): - self.copy("COPYING", src=self._full_source_subfolder, dst="licenses", ignore_case=True, keep_path=False) - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - if self.settings.os == "Windows": - # There is no way to avoid building the tests, but at least we don't want them in the package - for prefix in ["run", "test"]: - for test in glob.glob("%s/bin/%s*" % (self.package_folder, prefix)): - os.remove(test) - if self.settings.compiler == "Visual Studio": - if self.settings.build_type == "Debug": - os.unlink(os.path.join(self.package_folder, "bin", "libexslt.pdb")) - os.unlink(os.path.join(self.package_folder, "bin", "libxslt.pdb")) - os.unlink(os.path.join(self.package_folder, "bin", "xsltproc.pdb")) + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + if is_msvc(self): + self.copy("*.h", src=os.path.join(self._source_subfolder, "libxslt"), + dst=os.path.join("include", "libxslt")) + self.copy("*.h", src=os.path.join(self._source_subfolder, "libexslt"), + dst=os.path.join("include", "libexslt")) + build_dir = os.path.join(self._source_subfolder, "win32", "bin.msvc") + self.copy("*.exe", src=build_dir, dst="bin") if self.options.shared: - os.unlink(os.path.join(self.package_folder, "lib", "libxslt_a.lib")) - os.unlink(os.path.join(self.package_folder, "lib", "libexslt_a.lib")) + self.copy("*xslt.lib", src=build_dir, dst="lib") + self.copy("*xslt.dll", src=build_dir, dst="bin") else: - os.unlink(os.path.join(self.package_folder, "lib", "libxslt.lib")) - os.unlink(os.path.join(self.package_folder, "lib", "libexslt.lib")) - os.unlink(os.path.join(self.package_folder, "bin", "libxslt.dll")) - os.unlink(os.path.join(self.package_folder, "bin", "libexslt.dll")) - for f in "libxslt.la", "libexslt.la": - la = os.path.join(self.package_folder, 'lib', f) - if os.path.isfile(la): - os.unlink(la) + self.copy("*xslt_a.lib", src=build_dir, dst="lib") + else: + autotools = self._configure_autotools() + autotools.install() + os.remove(os.path.join(self.package_folder, "bin", "xslt-config")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.sh") + tools.rmdir(os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.libs = ['exslt', 'xslt'] - if self._is_msvc: - if self.options.shared: - self.cpp_info.libs = ['lib%s' % l for l in self.cpp_info.libs] - else: - self.cpp_info.libs = ['lib%s_a' % l for l in self.cpp_info.libs] - self.cpp_info.includedirs.append(os.path.join("include", "libxslt")) + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "LibXslt") + self.cpp_info.set_property("pkg_config_name", "libxslt_full_package") # unofficial, avoid conflicts in conan generators + + prefix = "lib" if is_msvc(self) else "" + suffix = "_a" if is_msvc(self) and not self.options.shared else "" + + # xslt + self.cpp_info.components["xslt"].set_property("cmake_target_name", "LibXslt::LibXslt") + self.cpp_info.components["xslt"].set_property("pkg_config_name", "libxslt") + self.cpp_info.components["xslt"].libs = ["{}xslt{}".format(prefix, suffix)] if not self.options.shared: - self.cpp_info.defines = ["LIBXSLT_STATIC"] - if self.settings.os in ["Linux", "Macos", "FreeBSD", "Android"]: - self.cpp_info.system_libs.append('m') - if self.settings.os == "Windows": - self.cpp_info.system_libs.append('ws2_32') + self.cpp_info.components["xslt"].defines = ["LIBXSLT_STATIC"] + if self.settings.os in ["Linux", "FreeBSD", "Android"]: + self.cpp_info.components["xslt"].system_libs.append("m") + elif self.settings.os == "Windows": + self.cpp_info.components["xslt"].system_libs.append("ws2_32") + self.cpp_info.components["xslt"].requires = ["libxml2::libxml2"] + + # exslt + self.cpp_info.components["exslt"].set_property("cmake_target_name", "LibXslt::LibExslt") + self.cpp_info.components["exslt"].set_property("pkg_config_name", "libexslt") + self.cpp_info.components["exslt"].libs = ["{}exslt{}".format(prefix, suffix)] + self.cpp_info.components["exslt"].requires = ["xslt"] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "LibXslt" + self.cpp_info.names["cmake_find_package_multi"] = "LibXslt" + self.cpp_info.names["pkg_config"] = "libxslt_full_package" + self.cpp_info.components["xslt"].names["cmake_find_package"] = "LibXslt" + self.cpp_info.components["xslt"].names["cmake_find_package_multi"] = "LibXslt" + self.cpp_info.components["xslt"].names["pkg_config"] = "libxslt" + self.cpp_info.components["exslt"].names["cmake_find_package"] = "LibExslt" + self.cpp_info.components["exslt"].names["cmake_find_package_multi"] = "LibExslt" + self.cpp_info.components["exslt"].names["pkg_config"] = "libexslt" diff --git a/recipes/libxslt/all/patches/0001-allow-xsltproc-link-shared-mt.patch b/recipes/libxslt/all/patches/0001-allow-xsltproc-link-shared-mt.patch new file mode 100644 index 0000000000000..ea8fa8f72e635 --- /dev/null +++ b/recipes/libxslt/all/patches/0001-allow-xsltproc-link-shared-mt.patch @@ -0,0 +1,11 @@ +--- a/win32/configure.js ++++ b/win32/configure.js +@@ -394,7 +394,7 @@ if (error != 0) { + // with /MT and friends, then we need to enable static linking for xsltproc + if (cruntime == "/MT" || cruntime == "/MTd" || + cruntime == "/ML" || cruntime == "/MLd") { +- buildStatic = 1; ++ // buildStatic = 1; + } + + if (buildStatic == 1 && withModules == 1) { diff --git a/recipes/libxslt/all/patches/0001-Add-configuration-for-profiler.diff b/recipes/libxslt/all/patches/0002-Add-configuration-for-profiler.patch similarity index 100% rename from recipes/libxslt/all/patches/0001-Add-configuration-for-profiler.diff rename to recipes/libxslt/all/patches/0002-Add-configuration-for-profiler.patch diff --git a/recipes/libxslt/all/test_package/CMakeLists.txt b/recipes/libxslt/all/test_package/CMakeLists.txt index 23f16f00e42fe..fac7ef3b53790 100644 --- a/recipes/libxslt/all/test_package/CMakeLists.txt +++ b/recipes/libxslt/all/test_package/CMakeLists.txt @@ -1,8 +1,10 @@ cmake_minimum_required(VERSION 3.1) -project(libxslt_tutorial) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(LibXslt REQUIRED) add_executable(${PROJECT_NAME} libxslt_tutorial.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} LibXslt::LibXslt) diff --git a/recipes/libxslt/all/test_package/conanfile.py b/recipes/libxslt/all/test_package/conanfile.py index bd18716247da8..d46fa057e427f 100644 --- a/recipes/libxslt/all/test_package/conanfile.py +++ b/recipes/libxslt/all/test_package/conanfile.py @@ -3,8 +3,8 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" def build(self): cmake = CMake(self) @@ -12,9 +12,10 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "libxslt_tutorial") + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") xml_path = os.path.join(self.source_folder, "example.xml") xsl_path = os.path.join(self.source_folder, "example.xsl") cmd = "%s %s %s" % (bin_path, xsl_path, xml_path) self.run(cmd, run_environment=True) + self.run("xsltproc -V", run_environment=True) diff --git a/recipes/libyaml/all/CMakeLists.txt b/recipes/libyaml/all/CMakeLists.txt deleted file mode 100644 index 68bfd75fb1882..0000000000000 --- a/recipes/libyaml/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include("conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libyaml/all/conanfile.py b/recipes/libyaml/all/conanfile.py index ac5355417a49d..2a57f8a141776 100644 --- a/recipes/libyaml/all/conanfile.py +++ b/recipes/libyaml/all/conanfile.py @@ -1,25 +1,30 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir, save +from conan.tools.microsoft import is_msvc import os +import textwrap + +required_conan_version = ">=1.47.0" class LibYAMLConan(ConanFile): name = "libyaml" description = "LibYAML is a YAML parser and emitter library." - topics = ("conan", "libyaml", "yaml", "parser", "emitter") + topics = ("libyaml", "yaml", "parser", "emitter") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/yaml/libyaml" license = "MIT" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } def config_options(self): if self.settings.os == 'Windows': @@ -28,41 +33,76 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = '{}-{}'.format(self.name, self.version) - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["INSTALL_CMAKE_DIR"] = 'lib/cmake/libyaml' - self._cmake.definitions["YAML_STATIC_LIB_NAME"] = "yaml" - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["INSTALL_CMAKE_DIR"] = 'lib/cmake/libyaml' + tc.variables["YAML_STATIC_LIB_NAME"] = "yaml" + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): # 0.2.2 has LICENSE, 0.2.5 has License, so ignore case - self.copy(pattern="License", dst="licenses", - src=self._source_subfolder, ignore_case=True) - cmake = self._configure_cmake() + copy(self, pattern="License", src=self.source_folder, + dst=os.path.join(self.package_folder, "licenses"), ignore_case=True) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"yaml": "yaml::yaml"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - self.cpp_info.components["yaml"].libs = ["yaml"] - if self.settings.compiler == "Visual Studio": - self.cpp_info.components["yaml"].defines = [ + self.cpp_info.set_property("cmake_file_name", "yaml") + self.cpp_info.set_property("cmake_target_name", "yaml") + self.cpp_info.libs = ["yaml"] + if is_msvc(self): + self.cpp_info.defines = [ "YAML_DECLARE_EXPORT" if self.options.shared else "YAML_DECLARE_STATIC" ] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "yaml" self.cpp_info.names["cmake_find_package_multi"] = "yaml" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/libyaml/all/test_package/CMakeLists.txt b/recipes/libyaml/all/test_package/CMakeLists.txt index 952c86e8df7f7..ebfddbde01104 100644 --- a/recipes/libyaml/all/test_package/CMakeLists.txt +++ b/recipes/libyaml/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(yaml REQUIRED) +find_package(yaml REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} yaml::yaml) +target_link_libraries(${PROJECT_NAME} PRIVATE yaml) diff --git a/recipes/libyaml/all/test_package/conanfile.py b/recipes/libyaml/all/test_package/conanfile.py index 1d0bdd3779793..3a8c6c5442b33 100644 --- a/recipes/libyaml/all/test_package/conanfile.py +++ b/recipes/libyaml/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libyaml/all/test_v1_package/CMakeLists.txt b/recipes/libyaml/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a18efb3f96156 --- /dev/null +++ b/recipes/libyaml/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(yaml REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE yaml) diff --git a/recipes/libyaml/all/test_v1_package/conanfile.py b/recipes/libyaml/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libyaml/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libyuv/all/CMakeLists.txt b/recipes/libyuv/all/CMakeLists.txt deleted file mode 100644 index 0feb437e18418..0000000000000 --- a/recipes/libyuv/all/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.4.0) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -if(WIN32 AND BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - -add_subdirectory(source_subfolder) diff --git a/recipes/libyuv/all/conandata.yml b/recipes/libyuv/all/conandata.yml index 263cd3d833101..0096cb0d06e2f 100644 --- a/recipes/libyuv/all/conandata.yml +++ b/recipes/libyuv/all/conandata.yml @@ -1,8 +1,22 @@ +# Versions from LIBYUV_VERSION definition in include/libyuv/version.h +# Pay attention to package commits incrementing this definition sources: - "cci.20201106": - url: "https://chromium.googlesource.com/libyuv/libyuv/+archive/2664f649bc0a32e05f5bc3ff4d12134e41aa08c4.tar.gz" - + "1845": + url: "https://chromium.googlesource.com/libyuv/libyuv/+archive/b9adaef1133ee835efc8970d1dcdcf23a5b68eba.tar.gz" + "1841": + url: "https://chromium.googlesource.com/libyuv/libyuv/+archive/f71c83552d373f0ff41833b17e2880632d8561d7.tar.gz" + "1768": + url: "https://chromium.googlesource.com/libyuv/libyuv/+archive/dfaf7534e0e536f7e5ef8ddd7326797bd09b8622.tar.gz" patches: - "cci.20201106": - - patch_file: "patches/001-cmake.patch" - base_path: "source_subfolder" + "1845": + - patch_file: "patches/0001-fix-cmake-1841.patch" + patch_description: "Fix CMake to be more robust & predictable" + patch_type: "compatibility" + "1841": + - patch_file: "patches/0001-fix-cmake-1841.patch" + patch_description: "Fix CMake to be more robust & predictable" + patch_type: "compatibility" + "1768": + - patch_file: "patches/0001-fix-cmake-1768.patch" + patch_description: "Fix CMake to be more robust & predictable" + patch_type: "compatibility" diff --git a/recipes/libyuv/all/conanfile.py b/recipes/libyuv/all/conanfile.py index eb9cd551985b4..3c7a9857e98ba 100644 --- a/recipes/libyuv/all/conanfile.py +++ b/recipes/libyuv/all/conanfile.py @@ -1,7 +1,11 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get import os +required_conan_version = ">=1.52.0" + class LibyuvConan(ConanFile): name = "libyuv" @@ -10,21 +14,21 @@ class LibyuvConan(ConanFile): description = "libyuv is an open source project that includes YUV scaling and conversion functionality." topics = ["YUV", "libyuv", "google", "chromium"] license = "BSD-3-Clause" - settings = "os", "compiler", "arch", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False], - "with_jpeg": [False, "libjpeg", "libjpeg-turbo"]} - default_options = {"shared": False, - "fPIC": True, - "with_jpeg": "libjpeg"} - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_jpeg": [False, "libjpeg", "libjpeg-turbo"], + } + default_options = { + "shared": False, + "fPIC": True, + "with_jpeg": "libjpeg", + } + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -32,42 +36,52 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - if str(self.options.with_jpeg) == "libjpeg-turbo": - raise ConanInvalidConfiguration( - "libjpeg-turbo is an invalid option right now, as it is not supported by the cmake script.") + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): if self.options.with_jpeg == "libjpeg": - self.requires("libjpeg/9d") + self.requires("libjpeg/9e") elif self.options.with_jpeg == "libjpeg-turbo": self.requires("libjpeg-turbo/2.0.5") - def source(self): - tools.get(**self.conan_data["sources"] - [self.version], destination=self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) + def validate(self): + if self.info.options.with_jpeg == "libjpeg-turbo": + raise ConanInvalidConfiguration( + "libjpeg-turbo is an invalid option right now, as it is not supported by the cmake script.", + ) - if not self.options.with_jpeg: - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_JPEG"] = True + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder) - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["TEST"] = False + tc.variables["LIBYUV_WITH_JPEG"] = bool(self.options.with_jpeg) + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): self.cpp_info.libs = ["yuv"] + + # TODO: to remove in conan v2 + bin_path = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH environment variable: {bin_path}") + self.env_info.PATH.append(bin_path) diff --git a/recipes/libyuv/all/patches/0001-fix-cmake-1768.patch b/recipes/libyuv/all/patches/0001-fix-cmake-1768.patch new file mode 100644 index 0000000000000..c5cf6a86be66a --- /dev/null +++ b/recipes/libyuv/all/patches/0001-fix-cmake-1768.patch @@ -0,0 +1,59 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -2,8 +2,8 @@ + # Originally created for "roxlu build system" to compile libyuv on windows + # Run with -DTEST=ON to build unit tests + ++CMAKE_MINIMUM_REQUIRED( VERSION 3.8 ) + PROJECT ( YUV C CXX ) # "C" is required even for C++ projects +-CMAKE_MINIMUM_REQUIRED( VERSION 2.8 ) + OPTION( TEST "Built unit tests" OFF ) + + SET ( ly_base_dir ${PROJECT_SOURCE_DIR} ) +@@ -23,23 +23,23 @@ LIST ( SORT ly_unittest_sources ) + INCLUDE_DIRECTORIES( BEFORE ${ly_inc_dir} ) + + # this creates the static library (.a) +-ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} ) ++ADD_LIBRARY ( ${ly_lib_static} ${ly_source_files} ) ++target_compile_features(${ly_lib_static} PUBLIC cxx_std_11) ++set_target_properties(${ly_lib_static} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + + # this creates the shared library (.so) +-ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} ) +-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" ) +-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" ) + + # this creates the conversion tool + ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc ) + TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} ) + + +-INCLUDE ( FindJPEG ) +-if (JPEG_FOUND) +- include_directories( ${JPEG_INCLUDE_DIR} ) +- target_link_libraries( yuvconvert ${JPEG_LIBRARY} ) +- add_definitions( -DHAVE_JPEG ) ++option(LIBYUV_WITH_JPEG "Build libyuv with jpeg" ON) ++if (LIBYUV_WITH_JPEG) ++ find_package(JPEG REQUIRED) ++ target_link_libraries(${ly_lib_static} JPEG::JPEG ) ++ target_compile_definitions(${ly_lib_static} PRIVATE HAVE_JPEG) ++ target_compile_definitions(yuvconvert PRIVATE HAVE_JPEG) + endif() + + if(TEST) +@@ -81,11 +81,9 @@ endif() + + + # install the conversion tool, .so, .a, and all the header files +-INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin ) +-INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib ) +-INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) ++INSTALL ( TARGETS yuvconvert DESTINATION bin) ++INSTALL ( TARGETS ${ly_lib_static} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) + INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include ) + + # create the .deb and .rpm packages using cpack +-INCLUDE ( CM_linux_packages.cmake ) + diff --git a/recipes/libyuv/all/patches/0001-fix-cmake-1841.patch b/recipes/libyuv/all/patches/0001-fix-cmake-1841.patch new file mode 100644 index 0000000000000..aa4506b3d1cac --- /dev/null +++ b/recipes/libyuv/all/patches/0001-fix-cmake-1841.patch @@ -0,0 +1,62 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -2,8 +2,8 @@ + # Originally created for "roxlu build system" to compile libyuv on windows + # Run with -DTEST=ON to build unit tests + ++CMAKE_MINIMUM_REQUIRED( VERSION 3.8 ) + PROJECT ( YUV C CXX ) # "C" is required even for C++ projects +-CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 ) + OPTION( TEST "Built unit tests" OFF ) + + SET ( ly_base_dir ${PROJECT_SOURCE_DIR} ) +@@ -27,26 +27,23 @@ if(MSVC) + endif() + + # this creates the static library (.a) +-ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} ) ++ADD_LIBRARY ( ${ly_lib_static} ${ly_source_files} ) ++target_compile_features(${ly_lib_static} PUBLIC cxx_std_11) ++set_target_properties(${ly_lib_static} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + + # this creates the shared library (.so) +-ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} ) +-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" ) +-SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" ) +-if(WIN32) +- SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" ) +-endif() + + # this creates the conversion tool + ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc ) + TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} ) + + +-INCLUDE ( FindJPEG ) +-if (JPEG_FOUND) +- include_directories( ${JPEG_INCLUDE_DIR} ) +- target_link_libraries( yuvconvert ${JPEG_LIBRARY} ) +- add_definitions( -DHAVE_JPEG ) ++option(LIBYUV_WITH_JPEG "Build libyuv with jpeg" ON) ++if (LIBYUV_WITH_JPEG) ++ find_package(JPEG REQUIRED) ++ target_link_libraries(${ly_lib_static} JPEG::JPEG ) ++ target_compile_definitions(${ly_lib_static} PRIVATE HAVE_JPEG) ++ target_compile_definitions(yuvconvert PRIVATE HAVE_JPEG) + endif() + + if(TEST) +@@ -82,11 +79,9 @@ endif() + + + # install the conversion tool, .so, .a, and all the header files +-INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin ) +-INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib ) +-INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) ++INSTALL ( TARGETS yuvconvert DESTINATION bin) ++INSTALL ( TARGETS ${ly_lib_static} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) + INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include ) + + # create the .deb and .rpm packages using cpack +-INCLUDE ( CM_linux_packages.cmake ) + diff --git a/recipes/libyuv/all/patches/001-cmake.patch b/recipes/libyuv/all/patches/001-cmake.patch deleted file mode 100644 index 592839d0d2872..0000000000000 --- a/recipes/libyuv/all/patches/001-cmake.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -23,19 +23,21 @@ - INCLUDE_DIRECTORIES( BEFORE ${ly_inc_dir} ) - - # this creates the static library (.a) --ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} ) -+ADD_LIBRARY ( ${ly_lib_static} ${ly_source_files} ) -+set_property(TARGET ${ly_lib_static} PROPERTY CXX_STANDARD 11) -+target_link_libraries(${ly_lib_static} ${CONAN_LIBS}) - - # this creates the shared library (.so) --ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} ) --SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" ) --SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" ) -+#ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} ) -+#SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" ) -+#SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" ) - - # this creates the conversion tool - ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc ) - TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} ) - - --INCLUDE ( FindJPEG ) -+find_package(JPEG) - if (JPEG_FOUND) - include_directories( ${JPEG_INCLUDE_DIR} ) - target_link_libraries( yuvconvert ${JPEG_LIBRARY} ) -@@ -81,11 +83,17 @@ - - - # install the conversion tool, .so, .a, and all the header files --INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin ) --INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib ) --INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) -+#INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin ) -+#INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib ) -+#INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) - INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include ) - -+INSTALL(TARGETS ${ly_lib_static} -+ RUNTIME DESTINATION bin -+ LIBRARY DESTINATION lib -+ ARCHIVE DESTINATION lib -+) -+ - # create the .deb and .rpm packages using cpack - INCLUDE ( CM_linux_packages.cmake ) - diff --git a/recipes/libyuv/all/test_package/CMakeLists.txt b/recipes/libyuv/all/test_package/CMakeLists.txt index 9c43a46da45b0..639163e3b7c5c 100644 --- a/recipes/libyuv/all/test_package/CMakeLists.txt +++ b/recipes/libyuv/all/test_package/CMakeLists.txt @@ -1,10 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(libyuv REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) - -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE libyuv::libyuv) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libyuv/all/test_package/conanfile.py b/recipes/libyuv/all/test_package/conanfile.py index 1d0bdd3779793..0a6bc68712d90 100644 --- a/recipes/libyuv/all/test_package/conanfile.py +++ b/recipes/libyuv/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libyuv/all/test_v1_package/CMakeLists.txt b/recipes/libyuv/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a044d49d31fde --- /dev/null +++ b/recipes/libyuv/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libyuv REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libyuv::libyuv) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libyuv/all/test_v1_package/conanfile.py b/recipes/libyuv/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libyuv/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libyuv/config.yml b/recipes/libyuv/config.yml index 9e8967e0f82ea..336e0262a0b45 100644 --- a/recipes/libyuv/config.yml +++ b/recipes/libyuv/config.yml @@ -1,3 +1,7 @@ versions: - "cci.20201106": + "1845": + folder: all + "1841": + folder: all + "1768": folder: all diff --git a/recipes/libzen/all/CMakeLists.txt b/recipes/libzen/all/CMakeLists.txt deleted file mode 100644 index 104041877438d..0000000000000 --- a/recipes/libzen/all/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -if(WIN32 AND BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - -add_subdirectory(source_subfolder/Project/CMake) diff --git a/recipes/libzen/all/conandata.yml b/recipes/libzen/all/conandata.yml index 40a3c7bd86016..c0b761db1ccf7 100644 --- a/recipes/libzen/all/conandata.yml +++ b/recipes/libzen/all/conandata.yml @@ -5,6 +5,4 @@ sources: patches: "0.4.38": - patch_file: "patches/0001-enable-WIN32-shared-libraries.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-export-data-in-windows-dlls.patch" - base_path: "source_subfolder" diff --git a/recipes/libzen/all/conanfile.py b/recipes/libzen/all/conanfile.py index fa93d94fc4ab2..1a994b7d1e470 100644 --- a/recipes/libzen/all/conanfile.py +++ b/recipes/libzen/all/conanfile.py @@ -1,5 +1,11 @@ +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save import os -from conans import ConanFile, CMake, tools +import textwrap + +required_conan_version = ">=1.52.0" class LibzenConan(ConanFile): @@ -8,10 +14,9 @@ class LibzenConan(ConanFile): homepage = "https://github.com/MediaArea/ZenLib" url = "https://github.com/conan-io/conan-center-index" description = "Small C++ derivate classes to have an easier life" - topics = ("conan", "libzen", "c++", "helper", "util") - settings = "os", "arch", "compiler", "build_type" - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake" + topics = ("c++", "helper", "util") + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -25,11 +30,8 @@ class LibzenConan(ConanFile): "enable_large_files": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -37,51 +39,85 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("ZenLib", self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_UNICODE"] = self.options.enable_unicode - self._cmake.definitions["LARGE_FILES"] = self.options.enable_large_files - self._cmake.configure() - return self._cmake - - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_UNICODE"] = self.options.enable_unicode + tc.variables["LARGE_FILES"] = self.options.enable_large_files + # Export symbols for msvc shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + # To install relocatable shared libs on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "Project", "CMake")) cmake.build() def package(self): - self.copy("License.txt", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "License.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"zen": "ZenLib::ZenLib"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): + self.cpp_info.set_property("cmake_file_name", "ZenLib") + self.cpp_info.set_property("cmake_target_name", "zen") + self.cpp_info.set_property("pkg_config_name", "libzen") suffix = "" if self.settings.build_type == "Debug": if self.settings.os == "Windows": suffix = "d" - elif tools.is_apple_os(self.settings.os): + elif is_apple_os(self): suffix = "_debug" - self.cpp_info.libs = ["zen{}".format(suffix)] - if self.settings.os == "Linux": + self.cpp_info.libs = [f"zen{suffix}"] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["m", "pthread"]) if self.options.enable_unicode: self.cpp_info.defines.extend(["UNICODE", "_UNICODE"]) if self.options.shared: self.cpp_info.defines.append("LIBZEN_SHARED") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "ZenLib" self.cpp_info.names["cmake_find_package_multi"] = "ZenLib" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/libzen/all/test_package/CMakeLists.txt b/recipes/libzen/all/test_package/CMakeLists.txt index 33ae887aa6aea..761c4f457a6d2 100644 --- a/recipes/libzen/all/test_package/CMakeLists.txt +++ b/recipes/libzen/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(ZenLib REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE zen) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libzen/all/test_package/conanfile.py b/recipes/libzen/all/test_package/conanfile.py index bd7165a553cf4..0a6bc68712d90 100644 --- a/recipes/libzen/all/test_package/conanfile.py +++ b/recipes/libzen/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libzen/all/test_v1_package/CMakeLists.txt b/recipes/libzen/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libzen/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libzen/all/test_v1_package/conanfile.py b/recipes/libzen/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libzen/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libzip/all/conandata.yml b/recipes/libzip/all/conandata.yml index 33e149da15435..52747d3db1060 100644 --- a/recipes/libzip/all/conandata.yml +++ b/recipes/libzip/all/conandata.yml @@ -1,4 +1,18 @@ sources: + "1.8.0": + url: [ + "https://libzip.org/download/libzip-1.8.0.tar.gz", + "https://github.com/nih-at/libzip/releases/download/v1.8.0/libzip-1.8.0.tar.gz", + ] + sha256: "30ee55868c0a698d3c600492f2bea4eb62c53849bcf696d21af5eb65f3f3839e" "1.7.3": - url: "https://libzip.org/download/libzip-1.7.3.tar.gz" + url: [ + "https://libzip.org/download/libzip-1.7.3.tar.gz", + "https://github.com/nih-at/libzip/releases/download/v1.7.3/libzip-1.7.3.tar.gz", + ] sha256: "0e2276c550c5a310d4ebf3a2c3dfc43fb3b4602a072ff625842ad4f3238cb9cc" +patches: + "1.8.0": + - patch_file: "patches/0001-cmake-install-bundle.patch" + "1.7.3": + - patch_file: "patches/0001-cmake-install-bundle.patch" diff --git a/recipes/libzip/all/conanfile.py b/recipes/libzip/all/conanfile.py index 4071d266e4db4..751e5721f786d 100644 --- a/recipes/libzip/all/conanfile.py +++ b/recipes/libzip/all/conanfile.py @@ -1,7 +1,12 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir +from conan.tools.scm import Version import os +required_conan_version = ">=1.53.0" + class LibZipConan(ConanFile): name = "libzip" @@ -9,17 +14,17 @@ class LibZipConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/nih-at/libzip" license = "BSD-3-Clause" - topics = ("conan", "zip", "libzip", "zip-archives", "zip-editing") - exports_sources = ["CMakeLists.txt"] - generators = "cmake", "cmake_find_package" - settings = "os", "compiler", "build_type", "arch" + topics = ("zip", "zip-archives", "zip-editing") + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "with_bzip2": [True, False], "with_lzma": [True, False], "with_zstd": [True, False], - "crypto": [False, "win32", "openssl", "mbedtls", "auto"] + "crypto": [False, "win32", "openssl", "mbedtls"], + "tools": [True, False], } default_options = { "shared": False, @@ -27,34 +32,37 @@ class LibZipConan(ConanFile): "with_bzip2": True, "with_lzma": True, "with_zstd": True, - "crypto": "auto" + "crypto": "openssl", + "tools": True, } - _cmake = None @property - def _source_subfolder(self): - return "source_subfolder" + def _has_zstd_support(self): + return Version(self.version) >= "1.8.0" - @property - def _crypto(self): - if self.options.crypto == "auto": - return "win32" if self.settings.os == "Windows" else "openssl" - return self.options.crypto + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if not self._has_zstd_support: + del self.options.zstd + # Default crypto backend on windows + if self.settings.os == "Windows": + self.options.crypto = "win32" def configure(self): - if self._crypto == "win32" and self.settings.os != "Windows": - raise ConanInvalidConfiguration("Windows is required to use win32 crypto libraries") - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.with_bzip2: self.requires("bzip2/1.0.8") @@ -62,79 +70,115 @@ def requirements(self): if self.options.with_lzma: self.requires("xz_utils/5.2.5") - if self.options.with_zstd: - self.requires("zstd/1.4.9") + if self.options.get_safe("with_zstd"): + self.requires("zstd/1.5.2") - if self._crypto == "openssl": - self.requires("openssl/1.1.1k") - elif self._crypto == "mbedtls": - self.requires("mbedtls/2.25") + if self.options.crypto == "openssl": + self.requires("openssl/1.1.1s") + elif self.options.crypto == "mbedtls": + self.requires("mbedtls/3.2.1") - def package_id(self): - self.info.options.crypto = self._crypto + def validate(self): + if self.info.options.crypto == "win32" and self.info.settings.os != "Windows": + raise ConanInvalidConfiguration("Windows is required to use win32 crypto libraries") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_REGRESS"] = False - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["BUILD_DOC"] = False - - self._cmake.definitions["ENABLE_LZMA"] = self.options.with_lzma - self._cmake.definitions["ENABLE_BZIP2"] = self.options.with_bzip2 - self._cmake.definitions["ENABLE_ZSTD"] = self.options.with_zstd - - self._cmake.definitions["ENABLE_COMMONCRYPTO"] = False # TODO: We need CommonCrypto package - self._cmake.definitions["ENABLE_GNUTLS"] = False # TODO: We need GnuTLS package - - self._cmake.definitions["ENABLE_MBEDTLS"] = self._crypto == "mbedtls" - self._cmake.definitions["ENABLE_OPENSSL"] = self._crypto == "openssl" - self._cmake.definitions["ENABLE_WINDOWS_CRYPTO"] = self._crypto == "win32" - - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TOOLS"] = self.options.tools + tc.variables["BUILD_REGRESS"] = False + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_DOC"] = False + tc.variables["ENABLE_LZMA"] = self.options.with_lzma + tc.variables["ENABLE_BZIP2"] = self.options.with_bzip2 + if self._has_zstd_support: + tc.variables["ENABLE_ZSTD"] = self.options.with_zstd + tc.variables["ENABLE_COMMONCRYPTO"] = False # TODO: We need CommonCrypto package + tc.variables["ENABLE_GNUTLS"] = False # TODO: We need GnuTLS package + tc.variables["ENABLE_MBEDTLS"] = self.options.crypto == "mbedtls" + tc.variables["ENABLE_OPENSSL"] = self.options.crypto == "openssl" + tc.variables["ENABLE_WINDOWS_CRYPTO"] = self.options.crypto == "win32" + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + top_cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + # Honor zstd enabled + if self._has_zstd_support: + lib_cmakelists = os.path.join(self.source_folder, "lib", "CMakeLists.txt") + replace_in_file(self, top_cmakelists, "find_package(Zstd)", "find_package(zstd)") + replace_in_file(self, top_cmakelists, "Zstd_FOUND", "zstd_FOUND") + replace_in_file( + self, + lib_cmakelists, + "Zstd::Zstd", + "$,zstd::libzstd_shared,zstd::libzstd_static>", + ) + # Do not pollute rpath of installed binaries + replace_in_file( + self, + top_cmakelists, + "set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})", + "", + ) + replace_in_file( + self, + top_cmakelists, + "set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)", + "", + ) def build(self): - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "libzip" - self.cpp_info.names["cmake_find_package_multi"] = "libzip" - self.cpp_info.names["pkg_config"] = "libzip" - self.cpp_info.components["_libzip"].names["cmake_find_package"] = "zip" - self.cpp_info.components["_libzip"].names["cmake_find_package_multi"] = "zip" - self.cpp_info.components["_libzip"].names["pkg_config"] = "libzip" + self.cpp_info.set_property("cmake_file_name", "libzip") + self.cpp_info.set_property("cmake_target_name", "libzip::zip") + self.cpp_info.set_property("pkg_config_name", "libzip") + + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed self.cpp_info.components["_libzip"].libs = ["zip"] if self.settings.os == "Windows": self.cpp_info.components["_libzip"].system_libs = ["advapi32"] - if self._crypto == "win32": + if self.options.crypto == "win32": self.cpp_info.components["_libzip"].system_libs.append("bcrypt") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "libzip" + self.cpp_info.names["cmake_find_package_multi"] = "libzip" + self.cpp_info.components["_libzip"].names["cmake_find_package"] = "zip" + self.cpp_info.components["_libzip"].names["cmake_find_package_multi"] = "zip" + self.cpp_info.components["_libzip"].set_property("cmake_target_name", "libzip::zip") + self.cpp_info.components["_libzip"].set_property("pkg_config_name", "libzip") self.cpp_info.components["_libzip"].requires = ["zlib::zlib"] if self.options.with_bzip2: self.cpp_info.components["_libzip"].requires.append("bzip2::bzip2") if self.options.with_lzma: self.cpp_info.components["_libzip"].requires.append("xz_utils::xz_utils") - if self.options.with_zstd: + if self.options.get_safe("with_zstd"): self.cpp_info.components["_libzip"].requires.append("zstd::zstd") - if self._crypto == "openssl": - self.cpp_info.components["_libzip"].requires.append("openssl::openssl") - elif self._crypto == "mbedtls": + if self.options.crypto == "openssl": + self.cpp_info.components["_libzip"].requires.append("openssl::crypto") + elif self.options.crypto == "mbedtls": self.cpp_info.components["_libzip"].requires.append("mbedtls::mbedtls") - - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) + if self.options.tools: + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/libzip/all/patches/0001-cmake-install-bundle.patch b/recipes/libzip/all/patches/0001-cmake-install-bundle.patch new file mode 100644 index 0000000000000..ef45169f8e52a --- /dev/null +++ b/recipes/libzip/all/patches/0001-cmake-install-bundle.patch @@ -0,0 +1,11 @@ +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -4,7 +4,7 @@ foreach(PROGRAM zipcmp zipmerge ziptool) + target_link_libraries(${PROGRAM} zip) + target_include_directories(${PROGRAM} PRIVATE BEFORE ${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}) + if(LIBZIP_DO_INSTALL) +- install(TARGETS ${PROGRAM} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin) ++ install(TARGETS ${PROGRAM} EXPORT ${PROJECT_NAME}-targets DESTINATION bin) + endif() + if(NOT HAVE_GETOPT) + target_sources(${PROGRAM} PRIVATE getopt.c) diff --git a/recipes/libzip/all/test_package/CMakeLists.txt b/recipes/libzip/all/test_package/CMakeLists.txt index 6654a3a296286..c95ee806189e5 100644 --- a/recipes/libzip/all/test_package/CMakeLists.txt +++ b/recipes/libzip/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(libzip REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} libzip::zip) +target_link_libraries(${PROJECT_NAME} PRIVATE libzip::zip) diff --git a/recipes/libzip/all/test_package/conanfile.py b/recipes/libzip/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/libzip/all/test_package/conanfile.py +++ b/recipes/libzip/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libzip/all/test_v1_package/CMakeLists.txt b/recipes/libzip/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/libzip/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/libzip/all/test_v1_package/conanfile.py b/recipes/libzip/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/libzip/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libzip/config.yml b/recipes/libzip/config.yml index fef745720141f..46f6fe51385c7 100644 --- a/recipes/libzip/config.yml +++ b/recipes/libzip/config.yml @@ -1,3 +1,5 @@ versions: + "1.8.0": + folder: all "1.7.3": folder: all diff --git a/recipes/libzippp/all/conandata.yml b/recipes/libzippp/all/conandata.yml index a7f3ed704300d..49a240e225faf 100644 --- a/recipes/libzippp/all/conandata.yml +++ b/recipes/libzippp/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "5.0-1.8.0": + url: "https://github.com/ctabin/libzippp/archive/libzippp-v5.0-1.8.0.tar.gz" + sha256: "b70f2d0f64eb68b00a16290bac40ac1a3fd3d2896cfddc93e370a7fa28c591c5" "4.0": url: "https://github.com/ctabin/libzippp/archive/libzippp-v4.0-1.7.3.tar.gz" sha256: "7560c2d8bbace39245ba6e89c5454b8bc5eb753bb13451bca2c7b5810c0a2f2d" diff --git a/recipes/libzippp/all/conanfile.py b/recipes/libzippp/all/conanfile.py index 39d8828387e05..fa1cfae1a117c 100644 --- a/recipes/libzippp/all/conanfile.py +++ b/recipes/libzippp/all/conanfile.py @@ -1,6 +1,7 @@ from conans import ConanFile, CMake, tools import os +required_conan_version = ">=1.36.0" class LibZipppConan(ConanFile): name = "libzippp" @@ -8,7 +9,7 @@ class LibZipppConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/ctabin/libzippp" license = "BSD-3-Clause" - topics = ("conan", "zip", "libzippp", "zip-archives", "zip-editing") + topics = ("zip", "libzippp", "zip-archives", "zip-editing") exports_sources = ["CMakeLists.txt"] generators = "cmake", "cmake_find_package_multi" settings = "os", "compiler", "build_type", "arch" @@ -36,15 +37,22 @@ def configure(self): if self.options.shared: del self.options.fPIC + def validate(self): + libzippp_version = str(self.version) + if libzippp_version != "4.0" and len(libzippp_version.split("-")) != 2: + raise tools.ConanInvalidConfiguration("{}: version number must include '-'. (ex. '5.0-1.8.0')".format(self.name)) + def requirements(self): - self.requires("libzip/1.7.3") + self.requires("zlib/1.2.11") + if tools.Version(self.version) == "4.0": + self.requires("libzip/1.7.3") + else: + libzip_version = str(self.version).split("-")[1] + self.requires("libzip/{}".format(libzip_version)) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - # eg. 'libzippp-libzippp-v4.0-1.7.3' - extracted_dir = self.name + "-" + self.name + "-v" + self.version + \ - "-" + self.deps_cpp_info["libzip"].version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -77,5 +85,6 @@ def package_info(self): self.cpp_info.libs = tools.collect_libs(self) self.cpp_info.names["cmake_find_package"] = "libzippp" self.cpp_info.names["cmake_find_package_multi"] = "libzippp" + self.cpp_info.set_property("cmake_file_name", "libzippp") if self.options.with_encryption: self.cpp_info.defines.append("LIBZIPPP_WITH_ENCRYPTION") diff --git a/recipes/libzippp/all/test_package/CMakeLists.txt b/recipes/libzippp/all/test_package/CMakeLists.txt index 3eadbd451e64d..148357d043ba6 100644 --- a/recipes/libzippp/all/test_package/CMakeLists.txt +++ b/recipes/libzippp/all/test_package/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(libzippp REQUIRED) diff --git a/recipes/libzippp/all/test_package/conanfile.py b/recipes/libzippp/all/test_package/conanfile.py index 1d0bdd3779793..3da371b660e0a 100644 --- a/recipes/libzippp/all/test_package/conanfile.py +++ b/recipes/libzippp/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/libzippp/config.yml b/recipes/libzippp/config.yml index 2e78700e71475..a529e567c0975 100644 --- a/recipes/libzippp/config.yml +++ b/recipes/libzippp/config.yml @@ -1,3 +1,5 @@ versions: + "5.0-1.8.0": + folder: all "4.0": folder: all diff --git a/recipes/lief/all/CMakeLists.txt b/recipes/lief/all/CMakeLists.txt deleted file mode 100644 index 30c065f03128e..0000000000000 --- a/recipes/lief/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(source_subfolder) diff --git a/recipes/lief/all/conandata.yml b/recipes/lief/all/conandata.yml index 783cb3b5db868..322361c8a5bce 100644 --- a/recipes/lief/all/conandata.yml +++ b/recipes/lief/all/conandata.yml @@ -1,18 +1,46 @@ sources: + "0.12.3": + url: "https://github.com/lief-project/LIEF/archive/0.12.3.tar.gz" + sha256: "762925ad2eed642a6e7ef2cc899bcd3e93a40a2ce1dd2391d9b9ecadfe6438cf" + "0.12.2": + url: "https://github.com/lief-project/LIEF/archive/0.12.2.tar.gz" + sha256: "d779c802ba1f80d0e93765e038e0a198fb5ffe4662afe467e33102cb44a06e99" "0.10.1": url: "https://github.com/lief-project/LIEF/archive/0.10.1.tar.gz" sha256: "6f30c98a559f137e08b25bcbb376c0259914b33c307b8b901e01ca952241d00a" patches: + "0.12.3": + - patch_file: "patches/0.12.3-001_link_to_conan.patch" + patch_description: "find conan package and link these" + patch_type: "conan" + - patch_file: "patches/0.12.2-002_support_older_gcc.patch" + patch_description: "fix name look up issue" + patch_type: "portability" + patch_source: "https://github.com/lief-project/LIEF/pull/815" + "0.12.2": + - patch_file: "patches/0.12.2-001_link_to_conan.patch" + patch_description: "find conan package and link these" + patch_type: "conan" + - patch_file: "patches/0.12.2-002_support_older_gcc.patch" + patch_description: "fix name look up issue" + patch_type: "portability" + patch_source: "https://github.com/lief-project/LIEF/pull/815" "0.10.1": - patch_file: "patches/001_link_to_conan.patch" - base_path: "source_subfolder" + patch_description: "find conan package and link these" + patch_type: "conan" - patch_file: "patches/002_fix_resources_manager.patch" - base_path: "source_subfolder" + patch_description: "use rang for colorizing" + patch_type: "backport" - patch_file: "patches/003_fix_json_include_path.patch" - base_path: "source_subfolder" + patch_description: "fix include path for conan package" + patch_type: "conan" - patch_file: "patches/004_fix_elf_parser.patch" - base_path: "source_subfolder" + patch_description: "remove LIEF_API" + patch_type: "backport" - patch_file: "patches/005_fix_compiler_detection.patch" - base_path: "source_subfolder" + patch_description: "fix check logic for compiler C++17 support" + patch_type: "backport" - patch_file: "patches/006_fix_binary_cpp.patch" - base_path: "source_subfolder" + patch_description: "include cctype" + patch_type: "backport" diff --git a/recipes/lief/all/conanfile.py b/recipes/lief/all/conanfile.py index 94959a4ba4b2a..eed55b5ff591b 100644 --- a/recipes/lief/all/conanfile.py +++ b/recipes/lief/all/conanfile.py @@ -1,18 +1,23 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + import os -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.52.0" class LiefConan(ConanFile): name = "lief" description = "Library to Instrument Executable Formats" - topics = ("conan", "lief", "executable", "elf") + license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/lief-project/LIEF" - license = "Apache-2.0" - exports_sources = "CMakeLists.txt", "patches/*" - generators = "cmake", - settings = "os", "compiler", "build_type", "arch" + topics = ("executable", "elf", "pe", "mach-o") + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -42,80 +47,127 @@ class LiefConan(ConanFile): "with_vdex": True, } - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + def _minimum_cpp_standard(self): + return 11 - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version.value) <= 14 and self.options.shared: - raise ConanInvalidConfiguration("{} {} does not support Visual Studio <= 14 with shared:True".format(self.name, self.version)) + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + + if ((self.info.settings.compiler == "Visual Studio" and Version(self.info.settings.compiler.version) <= "14") + or + (self.info.settings.compiler == "msvc" and Version(self.info.settings.compiler.version) <= "190")) \ + and self.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} does not support Visual Studio <= 14 with shared:True") + + if self.info.settings.compiler.get_safe("libcxx") == "libstdc++": + raise ConanInvalidConfiguration(f"{self.ref} does not support libstdc++") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("rang/3.1.0") - self.requires("mbedtls/2.16.3-apache") + self.requires("rang/3.2") + self.requires("mbedtls/3.2.1") + if self.options.with_json: + self.requires("nlohmann_json/3.11.2") + if self.options.with_frozen: + self.requires("frozen/1.1.1") + + if Version(self.version) < "0.12.2": + self.requires("rang/3.2") + self.requires("mbedtls/3.2.1") if self.options.with_json: - self.requires("nlohmann_json/3.9.1") + self.requires("nlohmann_json/3.11.2") if self.options.with_frozen: - self.requires("frozen/1.0.0") + self.requires("frozen/1.1.1") + if Version(self.version) >= "0.12.2": + self.requires("utfcpp/3.2.1") + self.requires("spdlog/1.10.0") + self.requires("boost/1.80.0") + self.requires("tcb-span/cci.20220616") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "LIEF-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["LIEF_ART"] = self.options.with_art - self._cmake.definitions["LIEF_DEX"] = self.options.with_dex - self._cmake.definitions["LIEF_ELF"] = self.options.with_elf - self._cmake.definitions["LIEF_OAT"] = self.options.with_oat - self._cmake.definitions["LIEF_PE"] = self.options.with_pe - self._cmake.definitions["LIEF_VDEX"] = self.options.with_vdex - self._cmake.definitions["LIEF_MACHO"] = self.options.with_macho - self._cmake.definitions["LIEF_ENABLE_JSON"] = self.options.with_json - self._cmake.definitions["LIEF_DISABLE_FROZEN"] = not self.options.with_frozen - self._cmake.definitions["LIEF_C_API"] = self.options.with_c_api - self._cmake.definitions["LIEF_EXAMPLES"] = False - self._cmake.definitions["LIEF_TESTS"] = False - self._cmake.definitions["LIEF_DOC"] = False - self._cmake.definitions["LIEF_LOGGING"] = False - self._cmake.definitions["LIEF_PYTHON_API"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIEF_ART"] = self.options.with_art + tc.variables["LIEF_DEX"] = self.options.with_dex + tc.variables["LIEF_ELF"] = self.options.with_elf + tc.variables["LIEF_OAT"] = self.options.with_oat + tc.variables["LIEF_PE"] = self.options.with_pe + tc.variables["LIEF_VDEX"] = self.options.with_vdex + tc.variables["LIEF_MACHO"] = self.options.with_macho + tc.variables["LIEF_ENABLE_JSON"] = self.options.with_json + tc.variables["LIEF_DISABLE_FROZEN"] = not self.options.with_frozen + tc.variables["LIEF_C_API"] = self.options.with_c_api + tc.variables["LIEF_EXAMPLES"] = False + tc.variables["LIEF_TESTS"] = False + tc.variables["LIEF_DOC"] = False + tc.variables["LIEF_LOGGING"] = False + tc.variables["LIEF_PYTHON_API"] = False + if Version(self.version) >= "0.12.2": + tc.variables["LIEF_USE_CCACHE"] = False + tc.variables["LIEF_OPT_MBEDTLS_EXTERNAL"] = True + tc.variables["LIEF_OPT_NLOHMANN_JSON_EXTERNAL"] = True + tc.variables["LIEF_OPT_FROZEN_EXTERNAL"] = True + tc.variables["LIEF_OPT_UTFCPP_EXTERNAL"] = True + tc.variables["LIEF_EXTERNAL_SPDLOG"] = True + tc.variables["LIEF_OPT_EXTERNAL_LEAF"] = True + tc.variables["LIEF_OPT_EXTERNAL_SPAN"] = True + tc.generate() + + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["pkg_config"] = "lief" - self.cpp_info.names["cmake_find_package"] = "LIEF" - self.cpp_info.names["cmake_find_package_multi"] = "LIEF" - self.cpp_info.libs = tools.collect_libs(self) - self.cpp_info.defines = ["_GLIBCXX_USE_CXX11_ABI=1"] + self.cpp_info.libs = ["LIEF"] + + self.cpp_info.set_property("cmake_file_name", "LIEF") + self.cpp_info.set_property("cmake_target_name", "LIEF::LIEF") + self.cpp_info.set_property("pkg_config_name", "LIEF") + if self.options.shared: self.cpp_info.defines.append("LIEF_IMPORT") - if self.settings.compiler == "Visual Studio": + if is_msvc(self): self.cpp_info.cxxflags += ["/FIiso646.h"] if self.settings.os == "Windows" and self.options.shared: self.cpp_info.system_libs = ["ws2_32"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "LIEF" + self.cpp_info.filenames["cmake_find_package_multi"] = "LIEF" + self.cpp_info.names["cmake_find_package"] = "LIEF" + self.cpp_info.names["cmake_find_package_multi"] = "LIEF" + self.cpp_info.names["pkg_config"] = "LIEF" diff --git a/recipes/lief/all/patches/0.12.2-001_link_to_conan.patch b/recipes/lief/all/patches/0.12.2-001_link_to_conan.patch new file mode 100644 index 0000000000000..f5fad544a589a --- /dev/null +++ b/recipes/lief/all/patches/0.12.2-001_link_to_conan.patch @@ -0,0 +1,96 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7d59f14..9fdfe43 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -12,7 +12,6 @@ endif() + + + if(WIN32 OR ${IS_WIN_CROSS_COMPILE}) +- include(ChooseMSVCCRT) + endif() + include(CheckCXXCompilerFlag) + include(CheckCCompilerFlag) +@@ -70,7 +69,6 @@ endif() + + # Dependencies + # ============ +-set(THIRD_PARTY_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/third-party/") + include(LIEFDependencies) + + # iOS specific config +@@ -376,12 +374,14 @@ endif() + # Leaf + # ======================================= + if(LIEF_EXTERNAL_LEAF) ++ find_package(Boost REQUIRED CONFIG) + message(STATUS "Using external LEAF version") + if(LIEF_EXTERNAL_LEAF_DIR) + message(STATUS "External LEAF include dir: ${LIEF_EXTERNAL_LEAF_DIR}") + target_include_directories(LIB_LIEF SYSTEM PUBLIC + "$") + endif() ++ target_link_libraries(LIB_LIEF PRIVATE Boost::headers) + else() + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/leaf.hpp + COMMAND +@@ -425,6 +425,8 @@ if(LIEF_EXTERNAL_SPAN) + target_include_directories(LIB_LIEF SYSTEM PUBLIC + "$") + endif() ++ find_package(tcb-span REQUIRED CONFIG) ++ target_link_libraries(LIB_LIEF PRIVATE tcb-span::tcb-span) + else() + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/span.hpp + COMMAND +@@ -439,7 +441,6 @@ else() + endif() + + +- + target_link_libraries(LIB_LIEF PRIVATE lief_spdlog) + + # Flags definition +@@ -448,8 +449,7 @@ target_link_libraries(LIB_LIEF PRIVATE lief_spdlog) + # cmake-format: off + set_target_properties( + LIB_LIEF +- PROPERTIES POSITION_INDEPENDENT_CODE ON +- CXX_STANDARD 11 ++ PROPERTIES CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + CXX_VISIBILITY_PRESET hidden + C_VISIBILITY_PRESET hidden) +@@ -667,8 +667,9 @@ endif() + # Installation + # ====================== + ++include(GNUInstallDirs) ++if(0) + if(UNIX) +- include(GNUInstallDirs) + set(CMAKE_INSTALL_LIBDIR "lib") + else() + if(WIN32) +@@ -682,13 +683,14 @@ else() + message(FATAL_ERROR "System not UNIX nor WIN32 - not implemented yet") + endif() + endif() ++endif() + + install( + TARGETS LIB_LIEF lief_spdlog + EXPORT LIEFExport + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + install( +@@ -727,6 +729,3 @@ export( + NAMESPACE LIEF:: + FILE LIEFExport-${lib_type}.cmake) + +-# Package +-# ====================== +-add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/package") diff --git a/recipes/lief/all/patches/0.12.2-002_support_older_gcc.patch b/recipes/lief/all/patches/0.12.2-002_support_older_gcc.patch new file mode 100644 index 0000000000000..2ab323a4fbd5c --- /dev/null +++ b/recipes/lief/all/patches/0.12.2-002_support_older_gcc.patch @@ -0,0 +1,13 @@ +diff --git a/src/PE/Binary.cpp b/src/PE/Binary.cpp +index 0e032c3..d2eaae9 100644 +--- a/src/PE/Binary.cpp ++++ b/src/PE/Binary.cpp +@@ -1732,7 +1732,7 @@ std::ostream& Binary::print(std::ostream& os) const { + if (has_debug()) { + os << "Debug" << std::endl; + os << "=====" << std::endl; +- for (const Debug& debug : debug()) { ++ for (const Debug& debug : this->debug()) { + os << debug << std::endl; + } + os << std::endl; diff --git a/recipes/lief/all/patches/0.12.3-001_link_to_conan.patch b/recipes/lief/all/patches/0.12.3-001_link_to_conan.patch new file mode 100644 index 0000000000000..b614ea503a68c --- /dev/null +++ b/recipes/lief/all/patches/0.12.3-001_link_to_conan.patch @@ -0,0 +1,89 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index eadac9a..5ad254c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -17,7 +17,6 @@ endif() + + + if(WIN32 OR ${IS_WIN_CROSS_COMPILE}) +- include(ChooseMSVCCRT) + endif() + include(CheckCXXCompilerFlag) + include(CheckCCompilerFlag) +@@ -75,7 +74,6 @@ endif() + + # Dependencies + # ============ +-set(THIRD_PARTY_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/third-party/") + include(LIEFDependencies) + + # iOS specific config +@@ -381,12 +379,14 @@ endif() + # Leaf + # ======================================= + if(LIEF_EXTERNAL_LEAF) ++ find_package(Boost REQUIRED CONFIG) + message(STATUS "Using external LEAF version") + if(LIEF_EXTERNAL_LEAF_DIR) + message(STATUS "External LEAF include dir: ${LIEF_EXTERNAL_LEAF_DIR}") + target_include_directories(LIB_LIEF SYSTEM PUBLIC + "$") + endif() ++ target_link_libraries(LIB_LIEF PRIVATE Boost::headers) + else() + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/leaf.hpp + COMMAND +@@ -430,6 +430,8 @@ if(LIEF_EXTERNAL_SPAN) + target_include_directories(LIB_LIEF SYSTEM PUBLIC + "$") + endif() ++ find_package(tcb-span REQUIRED CONFIG) ++ target_link_libraries(LIB_LIEF PRIVATE tcb-span::tcb-span) + else() + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/span.hpp + COMMAND +@@ -453,8 +455,7 @@ target_link_libraries(LIB_LIEF PRIVATE lief_spdlog) + # cmake-format: off + set_target_properties( + LIB_LIEF +- PROPERTIES POSITION_INDEPENDENT_CODE ON +- CXX_STANDARD 11 ++ PROPERTIES CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + CXX_VISIBILITY_PRESET hidden + C_VISIBILITY_PRESET hidden) +@@ -672,8 +673,9 @@ endif() + # Installation + # ====================== + ++include(GNUInstallDirs) ++if(0) + if(UNIX) +- include(GNUInstallDirs) + set(CMAKE_INSTALL_LIBDIR "lib") + else() + if(WIN32) +@@ -687,13 +689,14 @@ else() + message(FATAL_ERROR "System not UNIX nor WIN32 - not implemented yet") + endif() + endif() ++endif() + + install( + TARGETS LIB_LIEF lief_spdlog + EXPORT LIEFExport + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + install( +@@ -731,7 +734,3 @@ export( + EXPORT LIEFExport + NAMESPACE LIEF:: + FILE LIEFExport-${lib_type}.cmake) +- +-# Package +-# ====================== +-add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/package") diff --git a/recipes/lief/all/patches/001_link_to_conan.patch b/recipes/lief/all/patches/001_link_to_conan.patch index c70b6f9ecad22..e999cd3dd9317 100644 --- a/recipes/lief/all/patches/001_link_to_conan.patch +++ b/recipes/lief/all/patches/001_link_to_conan.patch @@ -1,6 +1,8 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -5,7 +5,6 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9b168d9..243bbc2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,7 +5,6 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") if (WIN32) @@ -8,8 +10,8 @@ endif() include(CheckCXXCompilerFlag) include(CheckCCompilerFlag) -@@ -49,14 +48,14 @@ - +@@ -49,14 +48,14 @@ endif() + # Dependencies # ============ -set(THIRD_PARTY_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/third-party/") @@ -19,17 +21,17 @@ + message(STATUS "Enable Frozen (C++14 support)") + set(LIEF_FROZEN_ENABLED 1) +endif() - + # LIEF Source definition # ====================== -set_source_files_properties(${mbedtls_src_crypto} PROPERTIES GENERATED TRUE) -set_source_files_properties(${mbedtls_src_x509} PROPERTIES GENERATED TRUE) -set_source_files_properties(${mbedtls_src_tls} PROPERTIES GENERATED TRUE) - + if (LIEF_LOGGING) set_source_files_properties(${ELG_SOURCE_DIR}/easylogging++.cc PROPERTIES GENERATED TRUE) -@@ -73,9 +72,6 @@ - +@@ -73,9 +72,6 @@ set(LIEF_PRIVATE_INCLUDE_FILES) + set(LIBLIEF_SOURCE_FILES "${ELG_CC_PATH}" - "${mbedtls_src_crypto}" @@ -38,31 +40,31 @@ "${LIBFUZZER_SRC_FILES}" "${CMAKE_CURRENT_SOURCE_DIR}/src/logging.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/exception.cpp" -@@ -126,13 +122,11 @@ +@@ -126,13 +122,11 @@ set(LIEF_INCLUDE_FILES set(LIEF_JSON_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/visitors/json.cpp") set(LIEF_JSON_HDR "${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/json.hpp" - "${LIBJSON_SOURCE_DIR}/json.hpp" ) - + if (LIEF_ENABLE_JSON) list(APPEND LIBLIEF_SOURCE_FILES "${LIEF_JSON_SRC}") list(APPEND LIEF_INC_FILES "${LIEF_JSON_HDR}") - list(APPEND LIEF_PUBLIC_INCLUDE_DIR "${LIBJSON_SOURCE_DIR}/") endif() - + source_group("Header Files" FILES ${LIEF_INC_FILES}) -@@ -224,9 +218,6 @@ - +@@ -224,9 +218,6 @@ endif() + # Frozen Configuration # ==================== -if (LIEF_FROZEN_ENABLED) - list(APPEND LIEF_PRIVATE_INCLUDE_DIR "${FROZEN_INCLUDE_DIR}") -endif() - + # OAT part # ======== -@@ -292,19 +283,15 @@ +@@ -292,19 +283,15 @@ list(APPEND LIEF_PUBLIC_INCLUDE_DIR list(APPEND LIEF_PRIVATE_INCLUDE_DIR "${LIEF_PUBLIC_INCLUDE_DIR}" "${LIEF_PUBLIC_INCLUDE_DIR}" @@ -73,8 +75,8 @@ "${ELG_SOURCE_DIR}" - "${MBEDTLS_INCLUDE_DIRS}" ) - - + + # Grouping external projects # ========================== -source_group("mbedtls\\crypto" FILES ${mbedtls_src_crypto}) @@ -83,38 +85,42 @@ if (LIEF_LOGGING) source_group("easylogging" FILES ${ELG_SOURCE_DIR}/easylogging++.cc) endif() -@@ -316,7 +303,7 @@ +@@ -316,7 +303,8 @@ target_include_directories(LIB_LIEF PRIVATE "${LIEF_PRIVATE_INCLUDE_DIR}") - + if (LIEF_ENABLE_JSON) - add_dependencies(LIB_LIEF lief_libjson) -+ target_link_libraries(LIB_LIEF CONAN_PKG::nlohmann_json) ++ find_package(nlohmann_json REQUIRED CONFIG) ++ target_link_libraries(LIB_LIEF nlohmann_json::nlohmann_json) endif() - + if (LIEF_LOGGING) -@@ -324,18 +311,17 @@ +@@ -324,18 +312,20 @@ if (LIEF_LOGGING) endif() - + if (LIEF_FROZEN_ENABLED) - add_dependencies(LIB_LIEF lief_frozen) -+ target_link_libraries(LIB_LIEF CONAN_PKG::frozen) ++ find_package(frozen REQUIRED CONFIG) ++ target_link_libraries(LIB_LIEF frozen::frozen) endif() - + -add_dependencies(LIB_LIEF lief_rang_cpp_color) -+target_link_libraries(LIB_LIEF CONAN_PKG::rang) - ++find_package(rang REQUIRED CONFIG) ++target_link_libraries(LIB_LIEF rang::rang) + -add_dependencies(LIB_LIEF lief_mbed_tls) -+target_link_libraries(LIB_LIEF CONAN_PKG::mbedtls) - ++find_package(MbedTLS REQUIRED CONFIG) ++target_link_libraries(LIB_LIEF MbedTLS::mbedtls) + # Flags definition # ---------------- set_property(TARGET LIB_LIEF PROPERTY CXX_STANDARD 11) set_property(TARGET LIB_LIEF PROPERTY CXX_STANDARD_REQUIRED ON) -set_property(TARGET LIB_LIEF PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET LIB_LIEF PROPERTY CXX_VISIBILITY_PRESET hidden) - + target_compile_definitions(LIB_LIEF PUBLIC -D_GLIBCXX_USE_CXX11_ABI=1) -@@ -345,11 +331,6 @@ +@@ -345,11 +335,6 @@ target_compile_definitions(LIB_LIEF PUBLIC -D_GLIBCXX_USE_CXX11_ABI=1) # with the SpcSpAgencyInfo Critical Extension, which mbed TLS doesn't # support, so set MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION to # have it skip this extension. @@ -123,11 +129,11 @@ - -DMBEDTLS_MD4_C - -DMBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION -) - - + + # ASAN - LSAN - TSAN - USAN -@@ -512,16 +493,16 @@ - +@@ -512,16 +497,16 @@ endif() + install(TARGETS LIB_LIEF ARCHIVE - DESTINATION lib @@ -139,7 +145,7 @@ - DESTINATION lib + DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries) - + install( DIRECTORY ${LIEF_PUBLIC_INCLUDE_DIR} - DESTINATION include diff --git a/recipes/lief/all/test_package/CMakeLists.txt b/recipes/lief/all/test_package/CMakeLists.txt index 2c5505ca7220d..21ece2b1f32cb 100644 --- a/recipes/lief/all/test_package/CMakeLists.txt +++ b/recipes/lief/all/test_package/CMakeLists.txt @@ -1,9 +1,11 @@ -cmake_minimum_required(VERSION 3.0) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(LIEF REQUIRED CONFIG) -add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) -target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE LIEF::LIEF) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +# It is required for gcc 5 +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/lief/all/test_package/conanfile.py b/recipes/lief/all/test_package/conanfile.py index f98baa955fbcd..5bef6136fec8e 100644 --- a/recipes/lief/all/test_package/conanfile.py +++ b/recipes/lief/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,9 +21,9 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") arg_path = bin_path if self.settings.os == "Windows": arg_path += ".exe" - self.run("{0} {1}".format(bin_path, arg_path), run_environment=True) + self.run(f"{bin_path} {arg_path}", env="conanrun") diff --git a/recipes/lief/all/test_v1_package/CMakeLists.txt b/recipes/lief/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6b1097615e03a --- /dev/null +++ b/recipes/lief/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(LIEF REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE LIEF::LIEF) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +# It is required for gcc 5 +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/lief/all/test_v1_package/conanfile.py b/recipes/lief/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..326a291210aff --- /dev/null +++ b/recipes/lief/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + arg_path = bin_path + if self.settings.os == "Windows": + arg_path += ".exe" + self.run(f"{bin_path} {arg_path}", run_environment=True) diff --git a/recipes/lief/config.yml b/recipes/lief/config.yml index c1d72c1a28d68..f24eac175f18c 100644 --- a/recipes/lief/config.yml +++ b/recipes/lief/config.yml @@ -1,3 +1,7 @@ versions: + "0.12.3": + folder: "all" + "0.12.2": + folder: "all" "0.10.1": folder: "all" diff --git a/recipes/lightgbm/all/CMakeLists.txt b/recipes/lightgbm/all/CMakeLists.txt new file mode 100644 index 0000000000000..61f3d3b039e2b --- /dev/null +++ b/recipes/lightgbm/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory("source_subfolder") diff --git a/recipes/lightgbm/all/conandata.yml b/recipes/lightgbm/all/conandata.yml new file mode 100644 index 0000000000000..bd0b8937e4a98 --- /dev/null +++ b/recipes/lightgbm/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "3.3.2": + url: "https://github.com/microsoft/LightGBM/archive/refs/tags/v3.3.2.tar.gz" + sha256: "d7c0f842e94165578d5a0c046ca942838d1574149f98c84400ce511239d17b9f" +patches: + "3.3.2": + - patch_file: "patches/0001-fix-includes.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-fix-openmp-clang.patch" + base_path: "source_subfolder" diff --git a/recipes/lightgbm/all/conanfile.py b/recipes/lightgbm/all/conanfile.py new file mode 100644 index 0000000000000..d00e21c352364 --- /dev/null +++ b/recipes/lightgbm/all/conanfile.py @@ -0,0 +1,105 @@ +from conans import CMake, ConanFile, tools +from conan.tools.microsoft import is_msvc +import functools + +required_conan_version = ">=1.33.0" + + +class LightGBMConan(ConanFile): + name = "lightgbm" + description = "A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks." + topics = ("machine-learning", "boosting") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/microsoft/LightGBM" + license = "MIT" + + settings = "os", "arch", "compiler", "build_type" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake", "cmake_find_package" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_openmp": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "with_openmp": True + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("eigen/3.4.0") + self.requires("fast_double_parser/0.6.0") + self.requires("fmt/9.0.0") + if self.options.with_openmp and self.settings.compiler in ("clang", "apple-clang"): + self.requires("llvm-openmp/11.1.0") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_STATIC_LIB"] = not self.options.shared + cmake.definitions["USE_DEBUG"] = self.settings.build_type == "Debug" + cmake.definitions["USE_OPENMP"] = self.options.with_openmp + if self.settings.os == "Macos": + cmake.definitions["APPLE_OUTPUT_DYLIB"] = True + cmake.configure() + return cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "LightGBM") + self.cpp_info.set_property("cmake_target_name", "LightGBM::LightGBM") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "LightGBM" + self.cpp_info.names["cmake_find_package_multi"] = "LightGBM" + + self.cpp_info.libs = ["lib_lightgbm"] if is_msvc(self) else ["_lightgbm"] + if self.settings.os == "Windows": + self.cpp_info.system_libs.extend(["ws2_32", "iphlpapi"]) + elif self.settings.os == "Linux": + self.cpp_info.system_libs.append("pthread") + if not self.options.shared and self.options.with_openmp: + if is_msvc(self): + openmp_flags = ["-openmp"] + elif self.settings.compiler == "gcc": + openmp_flags = ["-fopenmp"] + elif self.settings.compiler in ("clang", "apple-clang"): + openmp_flags = ["-Xpreprocessor", "-fopenmp"] + else: + openmp_flags = [] + self.cpp_info.exelinkflags.extend(openmp_flags) + self.cpp_info.sharedlinkflags.extend(openmp_flags) diff --git a/recipes/lightgbm/all/patches/0001-fix-includes.patch b/recipes/lightgbm/all/patches/0001-fix-includes.patch new file mode 100644 index 0000000000000..13fa0fe43a998 --- /dev/null +++ b/recipes/lightgbm/all/patches/0001-fix-includes.patch @@ -0,0 +1,16 @@ +diff --git a/include/LightGBM/utils/common.h b/include/LightGBM/utils/common.h +index af981062..097f20d4 100644 +--- a/include/LightGBM/utils/common.h ++++ b/include/LightGBM/utils/common.h +@@ -33,9 +33,9 @@ + + #if (!((defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__)))) + #define FMT_HEADER_ONLY +-#include "../../../external_libs/fmt/include/fmt/format.h" ++#include + #endif +-#include "../../../external_libs/fast_double_parser/include/fast_double_parser.h" ++#include + + #ifdef _MSC_VER + #include diff --git a/recipes/lightgbm/all/patches/0002-fix-openmp-clang.patch b/recipes/lightgbm/all/patches/0002-fix-openmp-clang.patch new file mode 100644 index 0000000000000..092e8d05ac946 --- /dev/null +++ b/recipes/lightgbm/all/patches/0002-fix-openmp-clang.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 109a252d..e5d46bce 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -415,7 +415,7 @@ if(USE_MPI) + endif(USE_MPI) + + if(USE_OPENMP) +- if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") ++ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang") + TARGET_LINK_LIBRARIES(lightgbm OpenMP::OpenMP_CXX) + TARGET_LINK_LIBRARIES(_lightgbm OpenMP::OpenMP_CXX) + endif() diff --git a/recipes/lightgbm/all/test_package/CMakeLists.txt b/recipes/lightgbm/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..12b8a397ff5d3 --- /dev/null +++ b/recipes/lightgbm/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(LightGBM CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} LightGBM::LightGBM) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/lightgbm/all/test_package/conanfile.py b/recipes/lightgbm/all/test_package/conanfile.py new file mode 100644 index 0000000000000..746d011e4501a --- /dev/null +++ b/recipes/lightgbm/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class LightGBMTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lightgbm/all/test_package/test_package.cpp b/recipes/lightgbm/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..760df80d7067b --- /dev/null +++ b/recipes/lightgbm/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include + +int main() { + float mat[] = {1, 2, 3, 4, 5, 6}; + DatasetHandle datasetHandle = nullptr; + LGBM_DatasetCreateFromMat(mat, C_API_DTYPE_FLOAT32, 1, 6, 0, "", nullptr, &datasetHandle); + BoosterHandle boosterHandle = nullptr; + LGBM_BoosterCreate(datasetHandle, "", &boosterHandle); + LGBM_BoosterFree(boosterHandle); + LGBM_DatasetFree(datasetHandle); + return 0; +} diff --git a/recipes/lightgbm/config.yml b/recipes/lightgbm/config.yml new file mode 100644 index 0000000000000..82ecde9973a8b --- /dev/null +++ b/recipes/lightgbm/config.yml @@ -0,0 +1,3 @@ +versions: + "3.3.2": + folder: all diff --git a/recipes/lightpcapng/all/CMakeLists.txt b/recipes/lightpcapng/all/CMakeLists.txt new file mode 100644 index 0000000000000..5cfb924ad4de7 --- /dev/null +++ b/recipes/lightpcapng/all/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) + diff --git a/recipes/lightpcapng/all/conandata.yml b/recipes/lightpcapng/all/conandata.yml new file mode 100644 index 0000000000000..7ce2c4d401088 --- /dev/null +++ b/recipes/lightpcapng/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20211005": + url: "https://github.com/Technica-Engineering/LightPcapNg/archive/58b8dd687bd462aba9d6e6d8a46209f0d1236213.zip" + sha256: 3634a2840f7bf43ebb293a9fbdfe0619ab7f233f9f774aac54b058dd5ab1320b diff --git a/recipes/lightpcapng/all/conanfile.py b/recipes/lightpcapng/all/conanfile.py new file mode 100644 index 0000000000000..ea6e74e5ca99f --- /dev/null +++ b/recipes/lightpcapng/all/conanfile.py @@ -0,0 +1,82 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.33.0" + +class LightPcapNgConan(ConanFile): + name = "lightpcapng" + homepage = "https://github.com/Technica-Engineering/LightPcapNg" + description = "Library for general-purpose tracing based on PCAPNG file format" + topics = ("pcapng", "pcap") + url = "https://github.com/conan-io/conan-center-index" + license = "MIT" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_zstd": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_zstd": True, + } + generators = "cmake", "cmake_paths", "cmake_find_package" + exports_sources = "CMakeLists.txt" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.with_zstd: + self.options["zstd"].shared = self.options.shared + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.options.with_zstd: + self.requires("zstd/1.4.5") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["LIGHT_USE_ZSTD"] = self.options.with_zstd + self._cmake.definitions["BUILD_TESTING"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "light_pcapng" + self.cpp_info.names["cmake_find_package_multi"] = "light_pcapng" + self.cpp_info.components["liblight_pcapng"].names["cmake_find_package"] = "light_pcapng" + self.cpp_info.components["liblight_pcapng"].names["cmake_find_package_multi"] = "light_pcapng" + self.cpp_info.components["liblight_pcapng"].libs = ["light_pcapng"] + + if self.options.with_zstd: + self.cpp_info.components["liblight_pcapng"].requires = ["zstd::zstd"] + diff --git a/recipes/lightpcapng/all/test_package/CMakeLists.txt b/recipes/lightpcapng/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8927c32d3f4ef --- /dev/null +++ b/recipes/lightpcapng/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(light_pcapng REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} light_pcapng::light_pcapng) diff --git a/recipes/lightpcapng/all/test_package/conanfile.py b/recipes/lightpcapng/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3da371b660e0a --- /dev/null +++ b/recipes/lightpcapng/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lightpcapng/all/test_package/test_package.c b/recipes/lightpcapng/all/test_package/test_package.c new file mode 100644 index 0000000000000..5a7fa763b3c1f --- /dev/null +++ b/recipes/lightpcapng/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include +#include "light_pcapng_ext.h" + +int main(void) { + const char* outfile = "conan_test.pcapng"; + light_pcapng writer = light_pcapng_open(outfile, "wb"); + light_pcapng_close(writer); + return EXIT_SUCCESS; +} + diff --git a/recipes/lightpcapng/config.yml b/recipes/lightpcapng/config.yml new file mode 100644 index 0000000000000..627e5733a23f8 --- /dev/null +++ b/recipes/lightpcapng/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20211005": + folder: "all" diff --git a/recipes/linux-headers-generic/all/conandata.yml b/recipes/linux-headers-generic/all/conandata.yml new file mode 100644 index 0000000000000..ecc5fdb03690f --- /dev/null +++ b/recipes/linux-headers-generic/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "5.14.9": + url: "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.14.9.tar.gz" + sha256: "b5cd37e6d193c8f6a98e41ce6f9d97260d178e0a3cfc43d7ff684f67c6c25f29" + "5.13.9": + url: "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.13.9.tar.gz" + sha256: "cc82e4461d5f759c820b74079164450d1f1ad09def9f3356a58814abd0268787" diff --git a/recipes/linux-headers-generic/all/conanfile.py b/recipes/linux-headers-generic/all/conanfile.py new file mode 100644 index 0000000000000..32a14abb318da --- /dev/null +++ b/recipes/linux-headers-generic/all/conanfile.py @@ -0,0 +1,43 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + + +class LinuxHeadersGenericConan(ConanFile): + name = "linux-headers-generic" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.kernel.org/" + license = "GPL-2.0-only" + description = "Generic Linux kernel headers" + topics = ("linux", "headers", "generic") + settings = "os", "arch", "build_type", "compiler" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def package_id(self): + del self.info.settings.os + del self.info.settings.build_type + del self.info.settings.compiler + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration("linux-headers-generic supports only Linux") + if hasattr(self, "settings_build") and tools.cross_building(self): + raise ConanInvalidConfiguration("linux-headers-generic can not be cross-compiled") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def build(self): + with tools.chdir(os.path.join(self._source_subfolder)): + autotools = AutoToolsBuildEnvironment(self) + autotools.make(target="headers") + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + self.copy("include/*.h", src=os.path.join(self._source_subfolder, "usr")) diff --git a/recipes/linux-headers-generic/all/test_package/CMakeLists.txt b/recipes/linux-headers-generic/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..34af13462f44f --- /dev/null +++ b/recipes/linux-headers-generic/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/linux-headers-generic/all/test_package/conanfile.py b/recipes/linux-headers-generic/all/test_package/conanfile.py new file mode 100644 index 0000000000000..92074169bcc74 --- /dev/null +++ b/recipes/linux-headers-generic/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.33.0" + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/linux-headers-generic/all/test_package/test_package.c b/recipes/linux-headers-generic/all/test_package/test_package.c new file mode 100644 index 0000000000000..91fa42aac7003 --- /dev/null +++ b/recipes/linux-headers-generic/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include "linux/gpio.h" +#include "linux/fs.h" +#include "linux/dma-buf.h" +#include "linux/io_uring.h" + +int main() { + return 0; +} diff --git a/recipes/linux-headers-generic/config.yml b/recipes/linux-headers-generic/config.yml new file mode 100644 index 0000000000000..a8d9d5e7bbfa8 --- /dev/null +++ b/recipes/linux-headers-generic/config.yml @@ -0,0 +1,5 @@ +versions: + "5.14.9": + folder: all + "5.13.9": + folder: all diff --git a/recipes/liquid-dsp/all/conandata.yml b/recipes/liquid-dsp/all/conandata.yml new file mode 100644 index 0000000000000..23e1bf444316a --- /dev/null +++ b/recipes/liquid-dsp/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.3.2": + url: "https://github.com/jgaeddert/liquid-dsp/archive/refs/tags/v1.3.2.tar.gz" + sha256: "85093624EF9CB90EAD64C836D2F42690197EDACE1A86257D6524C4E4DC870483" +patches: + "1.3.2": + - patch_file: "patches/1.3.2/0001-Remove-headers-check.patch" + base_path: "source_subfolder" diff --git a/recipes/liquid-dsp/all/conanfile.py b/recipes/liquid-dsp/all/conanfile.py new file mode 100644 index 0000000000000..26e149f068f7a --- /dev/null +++ b/recipes/liquid-dsp/all/conanfile.py @@ -0,0 +1,186 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +from contextlib import contextmanager +import os + +required_conan_version = ">=1.33.0" + +class LiquidDspConan(ConanFile): + name = "liquid-dsp" + description = ( + "Digital signal processing library for software-defined radios (and more)" + ) + topics = ("dsp", "sdr", "liquid-dsp") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/jgaeddert/liquid-dsp" + license = ("MIT",) + settings = "os", "arch", "build_type", "compiler" + exports_sources = ["generate_link_library.bat"] + options = { + "shared": [True, False], + "simdoverride": [True, False], + } + default_options = { + "shared": False, + "simdoverride": False, + } + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _libname(self): + if self.settings.os == "Windows": + return "libliquid" + return "liquid" + + @property + def _target_name(self): + if self.settings.os == "Macos": + if not self.options.shared: + return "libliquid.ar" + return "libliquid.dylib" + if not self.options.shared: + return "libliquid.a" + return "libliquid.so" + + @property + def _lib_pattern(self): + if self.settings.os == "Macos" and not self.options.shared: + return "libliquid.a" + if self.settings.os != "Windows": + return self._target_name + return "libliquid.lib" + + def configure(self): + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + if self.settings.compiler == "Visual Studio": + self.build_requires("mingw-w64/8.1") + self.build_requires("automake/1.16.4") + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def validate(self): + if hasattr(self, "settings_build") and tools.cross_building(self): + raise ConanInvalidConfiguration("Cross building is not yet supported. Contributions are welcome") + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + destination=self._source_subfolder, + strip_root=True, + ) + + def _patch_sources(self): + if self.settings.os == "Windows": + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + + def _gen_link_library(self): + if self.settings.compiler != "Visual Studio" or (not self.options.shared): + return + self.run("cmd /c generate_link_library.bat") + with tools.chdir(self._source_subfolder): + self.run( + "{} /def:libliquid.def /out:libliquid.lib /machine:{}".format( + os.getenv("AR"), "X86" if self.settings.arch == "x86" else "X64" + ), + win_bash=tools.os_info.is_windows, + ) + + def _rename_libraries(self): + with tools.chdir(self._source_subfolder): + if self.settings.os == "Windows" and self.options.shared: + tools.rename("libliquid.so", "libliquid.dll") + elif self.settings.os == "Windows" and not self.options.shared: + tools.rename("libliquid.a", "libliquid.lib") + elif self.settings.os == "Macos" and not self.options.shared: + tools.rename("libliquid.ar", "libliquid.a") + + @contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + env = { + "CC": "gcc", + "CXX": "g++", + "LD": "ld", + "AR": "ar", + } + with tools.environment_append(env): + yield + else: + yield + + @contextmanager + def _msvc_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self.settings): + env = { + "CC": "cl -nologo", + "CXX": "cl -nologo", + "AR": "lib", + "LD": "link", + } + with tools.environment_append(env): + yield + else: + yield + + def build(self): + self._patch_sources() + ncpus = tools.cpu_count() + configure_args = [] + cflags = ["-static-libgcc"] + if self.settings.build_type == "Debug": + configure_args.append("--enable-debug-messages") + cflags.extend(["-g", "-O0"]) + else: + cflags.extend(["-s", "-O2", "-DNDEBUG"]) + if self.options.simdoverride: + configure_args.append("--enable-simdoverride") + if self.settings.compiler == "Visual Studio": + configure_args.append("CFLAGS='{}'".format(" ".join(cflags))) + configure_args_str = " ".join(configure_args) + with self._build_context(): + with tools.chdir(self._source_subfolder): + self.run("./bootstrap.sh", win_bash=tools.os_info.is_windows) + self.run( + "./configure {}".format(configure_args_str), + win_bash=tools.os_info.is_windows, + ) + self.run( + "make {} -j{}".format(self._target_name, ncpus), + win_bash=tools.os_info.is_windows, + ) + self._rename_libraries() + with self._msvc_context(): + self._gen_link_library() + + def package(self): + self.copy(pattern="LICENSE", src=self._source_subfolder, dst="licenses") + self.copy( + pattern="liquid.h", + dst=os.path.join("include", "liquid"), + src=os.path.join(self._source_subfolder, "include"), + ) + self.copy(pattern="libliquid.dll", dst="bin", src=self._source_subfolder) + self.copy(pattern=self._lib_pattern, dst="lib", src=self._source_subfolder) + + def package_info(self): + self.cpp_info.libs = [self._libname] + if self.settings.os == "Linux": + self.cpp_info.system_libs.append("m") diff --git a/recipes/liquid-dsp/all/generate_link_library.bat b/recipes/liquid-dsp/all/generate_link_library.bat new file mode 100644 index 0000000000000..fb20541a4c46c --- /dev/null +++ b/recipes/liquid-dsp/all/generate_link_library.bat @@ -0,0 +1,4 @@ +@echo off +echo Generating link library for MSVC... +echo EXPORTS >> source_subfolder\libliquid.def +for /f "skip=19 tokens=4" %%A in ('%LD% /dump /EXPORTS source_subfolder\libliquid.dll') do echo %%A >> source_subfolder\libliquid.def diff --git a/recipes/liquid-dsp/all/patches/1.3.2/0001-Remove-headers-check.patch b/recipes/liquid-dsp/all/patches/1.3.2/0001-Remove-headers-check.patch new file mode 100644 index 0000000000000..ad10a374ed0d9 --- /dev/null +++ b/recipes/liquid-dsp/all/patches/1.3.2/0001-Remove-headers-check.patch @@ -0,0 +1,37 @@ +From 8a99b1c6853193c1f518bc81b705d7094225e114 Mon Sep 17 00:00:00 2001 +From: Rui Oliveira +Date: Fri, 18 Jun 2021 09:37:46 +0100 +Subject: [PATCH] Remove headers check + +--- + configure.ac | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/configure.ac b/configure.ac +index e6bc297e..5b591c87 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -81,20 +81,12 @@ AC_FUNC_ERROR_AT_LINE + AC_FUNC_MALLOC + AC_FUNC_REALLOC + +-# AC_CHECK_LIB (library, function, [action-if-found], [action-if-not-found], [other-libraries]) +-AC_CHECK_LIB([c],[main],[],[AC_MSG_ERROR(Could not use standard C library)], []) +-AC_CHECK_LIB([m],[main],[],[AC_MSG_ERROR(Could not use standard math library)],[]) +- + # AC_CHECK_FUNC(function, [action-if-found], [action-if-not-found]) + AC_CHECK_FUNCS([malloc realloc free memset memmove],[], + [AC_MSG_ERROR(Could not use memory allocation functions)]) + AC_CHECK_FUNCS([sinf cosf expf cargf cexpf crealf cimagf sqrtf],[], + [AC_MSG_ERROR(Could not use special math functions)],) + +-# Check for necessary header files +-AC_CHECK_HEADERS([stdio.h stdlib.h complex.h string.h getopt.h sys/resource.h float.h inttypes.h limits.h stdlib.h string.h unistd.h],[], +- [AC_MSG_ERROR(Could not use standard headers)]) +- + # Check for optional header files, libraries, programs + AC_CHECK_HEADERS(fec.h fftw3.h) + AC_CHECK_LIB([fftw3f], [fftwf_plan_dft_1d], [], +-- +2.32.0.windows.1 + diff --git a/recipes/liquid-dsp/all/test_package/CMakeLists.txt b/recipes/liquid-dsp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2859677acfc5b --- /dev/null +++ b/recipes/liquid-dsp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.0) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) +target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/liquid-dsp/all/test_package/conanfile.py b/recipes/liquid-dsp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..bd7165a553cf4 --- /dev/null +++ b/recipes/liquid-dsp/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/liquid-dsp/all/test_package/test_package.cpp b/recipes/liquid-dsp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4df4fdf1a1f16 --- /dev/null +++ b/recipes/liquid-dsp/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include "liquid/liquid.h" + +#include + +int main(int argc, char **argv) +{ + std::cout << liquid_libversion(); + return 0; +} diff --git a/recipes/liquid-dsp/config.yml b/recipes/liquid-dsp/config.yml new file mode 100644 index 0000000000000..906e859d7afd8 --- /dev/null +++ b/recipes/liquid-dsp/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3.2": + folder: "all" diff --git a/recipes/litehtml/all/conandata.yml b/recipes/litehtml/all/conandata.yml new file mode 100644 index 0000000000000..db5e01516c1d0 --- /dev/null +++ b/recipes/litehtml/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "cci.20211028": + url: "https://github.com/litehtml/litehtml/archive/b095539f8dc5a723c2226b353e6815423b36e0c8.tar.gz" + sha256: "c3795594fabeb060e21b9128ff22051986b393bd0b4e6000a5e171c71cabe224" +patches: + "cci.20211028": + - patch_file: "patches/0001-icu.patch" diff --git a/recipes/litehtml/all/conanfile.py b/recipes/litehtml/all/conanfile.py new file mode 100644 index 0000000000000..c3158edb62025 --- /dev/null +++ b/recipes/litehtml/all/conanfile.py @@ -0,0 +1,141 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save +from conan.tools.microsoft import is_msvc +import os +import textwrap + +required_conan_version = ">=1.53.0" + + +class LitehtmlConan(ConanFile): + name = "litehtml" + description = "litehtml is the lightweight HTML rendering engine with CSS2/CSS3 support." + license = "BSD-3-Clause" + topics = ("render engine", "html", "parser") + homepage = "https://github.com/litehtml/litehtml" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "utf8": [True, False], + "with_icu": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "utf8": False, + "with_icu": False, + } + + @property + def _with_xxd(self): + # FIXME: create conan recipe for xxd, and use it unconditionally (returning False means cross build doesn't work) + return self.settings.os != "Windows" + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + # FIXME: add gumbo requirement (it is vendored right now) + if self.options.with_icu: + self.requires("icu/72.1") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.info.options.shared and is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} shared not supported with Visual Studio") + + def build_requirements(self): + # FIXME: add unconditional xxd build requirement + pass + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = False + tc.variables["LITEHTML_UTF8"] = self.options.utf8 + tc.variables["USE_ICU"] = self.options.with_icu + tc.variables["EXTERNAL_GUMBO"] = False # FIXME: add cci recipe, and use it unconditionally (option value should be True) + tc.variables["EXTERNAL_XXD"] = self._with_xxd # FIXME: should be True unconditionally + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + { + "litehtml": "litehtml::litehtml", + "gumbo": "litehtml::gumbo", + } + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "litehtml") + self.cpp_info.set_property("cmake_target_name", "litehtml") + + self.cpp_info.components["litehtml_litehtml"].set_property("cmake_target_name", "litehtml") + self.cpp_info.components["litehtml_litehtml"].libs = ["litehtml"] + self.cpp_info.components["litehtml_litehtml"].requires = ["gumbo"] + if self.options.with_icu: + self.cpp_info.components["litehtml_litehtml"].requires.append("icu::icu") + + if True: # FIXME: remove once we use a vendored gumbo library + self.cpp_info.components["gumbo"].set_property("cmake_target_name", "gumbo") + self.cpp_info.components["gumbo"].libs = ["gumbo"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["litehtml_litehtml"].names["cmake_find_package"] = "litehtml" + self.cpp_info.components["litehtml_litehtml"].names["cmake_find_package_multi"] = "litehtml" + self.cpp_info.components["litehtml_litehtml"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["litehtml_litehtml"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + if True: + self.cpp_info.components["gumbo"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["gumbo"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/litehtml/all/patches/0001-icu.patch b/recipes/litehtml/all/patches/0001-icu.patch new file mode 100644 index 0000000000000..1e3ee0090b33d --- /dev/null +++ b/recipes/litehtml/all/patches/0001-icu.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 20bd474232d734ca30f3e690de6d94fc498bbbc0..9c56fd35d3d332915a5adef83626e5a5a41df1a9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -159,8 +159,9 @@ endif() + # ICU + option(USE_ICU "Use ICU to locate word boundaries in text elements" OFF) + if (USE_ICU) ++ find_package(ICU COMPONENTS i18n uc data) + target_compile_definitions(${PROJECT_NAME} PUBLIC USE_ICU) +- target_link_libraries(${PROJECT_NAME} PUBLIC icui18n icuuc icudata) ++ target_link_libraries(${PROJECT_NAME} PUBLIC ICU::i18n ICU::uc ICU::data) + endif() + + # Gumbo diff --git a/recipes/litehtml/all/test_package/CMakeLists.txt b/recipes/litehtml/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..01d00c41e24f2 --- /dev/null +++ b/recipes/litehtml/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(litehtml REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE litehtml) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/litehtml/all/test_package/conanfile.py b/recipes/litehtml/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/litehtml/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/litehtml/all/test_package/test_package.cpp b/recipes/litehtml/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..cce35fe42eaa9 --- /dev/null +++ b/recipes/litehtml/all/test_package/test_package.cpp @@ -0,0 +1,17 @@ +#include "litehtml/litehtml.h" +#include "litehtml/tstring_view.h" + +#include + +int main() { + constexpr size_t offset = 5; + constexpr size_t length = 10; + + litehtml::tstring string = _t("the quick brown fox jumps over the lazy dog"); + litehtml::tstring_view view(string.data() + offset, length); + + for (auto c : view) { + std::cout << c << std::endl; + } + return 0; +} diff --git a/recipes/litehtml/all/test_v1_package/CMakeLists.txt b/recipes/litehtml/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/litehtml/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/litehtml/all/test_v1_package/conanfile.py b/recipes/litehtml/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/litehtml/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/litehtml/config.yml b/recipes/litehtml/config.yml new file mode 100644 index 0000000000000..6a05e08e87321 --- /dev/null +++ b/recipes/litehtml/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20211028": + folder: all diff --git a/recipes/tinyobjloader/all/CMakeLists.txt b/recipes/llhttp/all/CMakeLists.txt similarity index 100% rename from recipes/tinyobjloader/all/CMakeLists.txt rename to recipes/llhttp/all/CMakeLists.txt diff --git a/recipes/llhttp/all/conandata.yml b/recipes/llhttp/all/conandata.yml new file mode 100644 index 0000000000000..c2671d44c5a50 --- /dev/null +++ b/recipes/llhttp/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "6.0.6": + url: https://github.com/nodejs/llhttp/archive/refs/tags/release/v6.0.6.tar.gz + sha256: "14023d0efce07a996a197d3b6b15020b26526605277e521f5aa10dacc3af67ad" +patches: + "6.0.6": + - patch_file: "patches/cmake_install_dirs.patch" + base_path: "source_subfolder" diff --git a/recipes/llhttp/all/conanfile.py b/recipes/llhttp/all/conanfile.py new file mode 100644 index 0000000000000..df6177221446b --- /dev/null +++ b/recipes/llhttp/all/conanfile.py @@ -0,0 +1,87 @@ +from conans import ConanFile, tools, CMake +from conan.tools.files import patch +import os + +required_conan_version = ">=1.43.0" + + +class LlhttpParserConan(ConanFile): + name = "llhttp" + description = "http request/response parser for c " + topics = ("http", "parser") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/nodejs/llhttp" + license = ("MIT",) + generators = ("cmake",) + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + exports_sources = "CMakeLists.txt", "patches/*" + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def _configure_cmake(self): + if self._cmake: + return self._cmake + + self._cmake = CMake(self) + self._cmake.configure() + return self._cmake + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + destination=self._source_subfolder, + strip_root=True, + ) + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy( + "LICENSE-MIT", + src=os.path.join(self.source_folder, self._source_subfolder), + dst="licenses", + ) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "llhttp") + self.cpp_info.set_property("cmake_target_name", "llhttp::llhttp") + self.cpp_info.set_property("pkg_config_name", "libllhttp") + self.cpp_info.libs = ["llhttp"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "llhttp" + self.cpp_info.names["cmake_find_package_multi"] = "llhttp" + self.cpp_info.names["pkg_config"] = "libllhttp" diff --git a/recipes/llhttp/all/patches/cmake_install_dirs.patch b/recipes/llhttp/all/patches/cmake_install_dirs.patch new file mode 100644 index 0000000000000..6119c7509e39e --- /dev/null +++ b/recipes/llhttp/all/patches/cmake_install_dirs.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -43,6 +40,8 @@ set_target_properties(llhttp PROPERTIES PUBLIC_HEADER ${LLHTTP_HEADERS}) + install(TARGETS llhttp + EXPORT llhttp + ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib ++ RUNTIME DESTINATION bin + PUBLIC_HEADER DESTINATION include/ + ) + diff --git a/recipes/llhttp/all/test_package/CMakeLists.txt b/recipes/llhttp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e55d928fc7b95 --- /dev/null +++ b/recipes/llhttp/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(llhttp REQUIRED CONFIG) + + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} llhttp::llhttp) diff --git a/recipes/llhttp/all/test_package/conanfile.py b/recipes/llhttp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/llhttp/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/llhttp/all/test_package/test_package.c b/recipes/llhttp/all/test_package/test_package.c new file mode 100644 index 0000000000000..4d16a6691ce5e --- /dev/null +++ b/recipes/llhttp/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include + +#include + +int main() +{ + unsigned major = LLHTTP_VERSION_MAJOR; + unsigned minor = LLHTTP_VERSION_MINOR; + unsigned patch = LLHTTP_VERSION_PATCH; + printf("llhttp v%u.%u.%u\n", major, minor, patch); + printf("Sample function call: " + "llhttp_method_name(llhttp_method::HTTP_GET) = \"%s\"...\n", + llhttp_method_name(HTTP_GET) ); + + return 0; +} diff --git a/recipes/llhttp/config.yml b/recipes/llhttp/config.yml new file mode 100644 index 0000000000000..158212133c56d --- /dev/null +++ b/recipes/llhttp/config.yml @@ -0,0 +1,3 @@ +versions: + "6.0.6": + folder: all diff --git a/recipes/llvm-core/all/CMakeLists.txt b/recipes/llvm-core/all/CMakeLists.txt index abb97809bb4ec..22006c4e48420 100644 --- a/recipes/llvm-core/all/CMakeLists.txt +++ b/recipes/llvm-core/all/CMakeLists.txt @@ -2,6 +2,22 @@ cmake_minimum_required(VERSION 3.13.4) project(conanllvm) include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) + +if(LLVM_ENABLE_ZLIB) + find_package(ZLIB QUIET) + + # The FindZLIB find module provided by CMake behaves differently than the FindZLIB.cmake script generated by CONAN. + # So the following two lines fill in the needed properties. + list(GET ZLIB_LIBRARIES 0 ZLIB_LIBRARY) + set_property(TARGET ZLIB::ZLIB PROPERTY LOCATION "${ZLIB_LIBRARY}") + + if(UNIX) + # Additionally LLVM 11.1.0 requires the zlib lib dir to be in the library path. + # This is not needed for later versions and can be removed once + # LLVM-12 becomes the oldest supported version. + set(ENV{LIBRARY_PATH} "${CONAN_LIB_DIRS_ZLIB}:$ENV{LIBRARY_PATH}") + endif() +endif() add_subdirectory("source") diff --git a/recipes/llvm-core/all/conandata.yml b/recipes/llvm-core/all/conandata.yml index e827098115aa1..331f5f3a1903f 100644 --- a/recipes/llvm-core/all/conandata.yml +++ b/recipes/llvm-core/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "13.0.0": + url: https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/llvm-13.0.0.src.tar.xz + sha256: 408d11708643ea826f519ff79761fcdfc12d641a2510229eec459e72f8163020 + "12.0.0": + url: https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/llvm-12.0.0.src.tar.xz + sha256: 49dc47c8697a1a0abd4ee51629a696d7bfe803662f2a7252a3b16fc75f3a8b50 "11.1.0": url: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/llvm-11.1.0.src.tar.xz sha256: ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5 @@ -6,8 +12,16 @@ sources: patches: "11.1.0": - base_path: "source" - patch_file: "patches/11.1.0-vs2019.patch" + patch_file: "patches/11x/11.1.0-cmake.patch" - base_path: "source" - patch_file: "patches/11.1.0-cmake.patch" + patch_file: "patches/11x/11.1.0-native.patch" + "12.0.0": - base_path: "source" - patch_file: "patches/11.1.0-native.patch" + patch_file: "patches/12x/12.0.0-cmake.patch" + - base_path: "source" + patch_file: "patches/12x/12.0.0-native.patch" + "13.0.0": + - base_path: "source" + patch_file: "patches/13x/13.0.0-cmake.patch" + - base_path: "source" + patch_file: "patches/13x/13.0.0-native.patch" diff --git a/recipes/llvm-core/all/conanfile.py b/recipes/llvm-core/all/conanfile.py index bff27b412fc65..4e58bd0cf9c4d 100644 --- a/recipes/llvm-core/all/conanfile.py +++ b/recipes/llvm-core/all/conanfile.py @@ -1,11 +1,17 @@ -from conans.errors import ConanInvalidConfiguration -from conans import ConanFile, CMake, tools - +from conan.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.files import apply_conandata_patches, chdir, collect_libs, get, load, rename, replace_in_file, rm, rmdir, save +from conan.tools.scm import Version +from conans import CMake from collections import defaultdict import json import re import os.path import os +import textwrap + +required_conan_version = ">=1.50.2" # Due to conan.tools.scm.Version class LLVMCoreConan(ConanFile): @@ -15,8 +21,8 @@ class LLVMCoreConan(ConanFile): 'optimizers, and runtime environments.' ) license = 'Apache-2.0 WITH LLVM-exception' - topics = ('conan', 'llvm') - homepage = 'https://github.com/llvm/llvm-project/tree/master/llvm' + topics = ('llvm', 'compiler') + homepage = 'https://llvm.org' url = 'https://github.com/conan-io/conan-center-index' settings = ('os', 'arch', 'compiler', 'build_type') @@ -45,7 +51,8 @@ class LLVMCoreConan(ConanFile): ], 'with_ffi': [True, False], 'with_zlib': [True, False], - 'with_xml2': [True, False] + 'with_xml2': [True, False], + 'use_llvm_cmake_files': [True, False], } default_options = { 'shared': False, @@ -63,12 +70,19 @@ class LLVMCoreConan(ConanFile): 'use_sanitizer': 'None', 'with_ffi': False, 'with_zlib': True, - 'with_xml2': True + 'with_xml2': True, + 'use_llvm_cmake_files': False, } - exports_sources = ['CMakeLists.txt', 'patches/*'] - generators = ['cmake', 'cmake_find_package'] + # Older cmake versions may have issues generating the graphviz output used + # to model the components + build_requires = [ + 'cmake/3.20.5' + ] + + generators = 'cmake', 'cmake_find_package' no_copy_source = True + short_paths = True @property def _source_subfolder(self): @@ -76,8 +90,8 @@ def _source_subfolder(self): def _supports_compiler(self): compiler = self.settings.compiler.value - version = tools.Version(self.settings.compiler.version) - major_rev, minor_rev = int(version.major), int(version.minor) + version = Version(self.settings.compiler.version) + major_rev, minor_rev = version.major, (version.minor or 0) unsupported_combinations = [ [compiler == 'gcc', major_rev == 5, minor_rev < 1], @@ -91,12 +105,11 @@ def _supports_compiler(self): raise ConanInvalidConfiguration(message.format(compiler, version)) def _patch_sources(self): - for patch in self.conan_data.get('patches', {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) def _patch_build(self): if os.path.exists('FindIconv.cmake'): - tools.replace_in_file('FindIconv.cmake', 'iconv charset', 'iconv') + replace_in_file(self, 'FindIconv.cmake', 'iconv charset', 'iconv') def _configure_cmake(self): cmake = CMake(self) @@ -116,6 +129,11 @@ def _configure_cmake(self): cmake.definitions['LLVM_ENABLE_PIC'] = \ self.options.get_safe('fPIC', default=False) + if self.settings.compiler == 'Visual Studio': + build_type = str(self.settings.build_type).upper() + cmake.definitions['LLVM_USE_CRT_{}'.format(build_type)] = \ + self.settings.compiler.runtime + cmake.definitions['LLVM_ABI_BREAKING_CHECKS'] = 'WITH_ASSERTS' cmake.definitions['LLVM_ENABLE_WARNINGS'] = True cmake.definitions['LLVM_ENABLE_PEDANTIC'] = True @@ -136,6 +154,7 @@ def _configure_cmake(self): cmake.definitions['LLVM_APPEND_VC_REV'] = False cmake.definitions['LLVM_BUILD_DOCS'] = False cmake.definitions['LLVM_ENABLE_IDE'] = False + cmake.definitions['LLVM_ENABLE_TERMINFO'] = False cmake.definitions['LLVM_ENABLE_EH'] = self.options.exceptions cmake.definitions['LLVM_ENABLE_RTTI'] = self.options.rtti @@ -163,12 +182,17 @@ def _configure_cmake(self): cmake.definitions['LLVM_ENABLE_LIBPFM'] = False cmake.definitions['LLVM_ENABLE_LIBEDIT'] = False cmake.definitions['LLVM_ENABLE_FFI'] = self.options.with_ffi - cmake.definitions['LLVM_ENABLE_ZLIB'] = \ - self.options.get_safe('with_zlib', False) + cmake.definitions['LLVM_ENABLE_ZLIB'] = "FORCE_ON" if \ + self.options.get_safe('with_zlib', False) else False cmake.definitions['LLVM_ENABLE_LIBXML2'] = \ self.options.get_safe('with_xml2', False) return cmake + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == 'Windows': del self.options.fPIC @@ -179,11 +203,14 @@ def requirements(self): if self.options.with_ffi: self.requires('libffi/3.3') if self.options.get_safe('with_zlib', False): - self.requires('zlib/1.2.11') + self.requires('zlib/1.2.12') if self.options.get_safe('with_xml2', False): self.requires('libxml2/2.9.10') - def configure(self): + def package_id(self): + del self.info.options.use_llvm_cmake_files + + def validate(self): if self.options.shared: # Shared builds disabled just due to the CI message = 'Shared builds not currently supported' raise ConanInvalidConfiguration(message) @@ -195,10 +222,12 @@ def configure(self): message = 'Cannot enable exceptions without rtti support' raise ConanInvalidConfiguration(message) self._supports_compiler() + if cross_building(self, skip_x64_x86=True): + raise ConanInvalidConfiguration('Cross-building not implemented') def source(self): - tools.get(**self.conan_data['sources'][self.version]) - os.rename('llvm-{}.src'.format(self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], strip_root=True, + destination=self._source_subfolder) self._patch_sources() def build(self): @@ -207,6 +236,29 @@ def build(self): cmake.configure() cmake.build() + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake", "llvm") + + @property + def _alias_module_file_rel_path(self): + return os.path.join(self._module_subfolder, "conan-official-{}-targets.cmake".format(self.name)) + + @property + def _old_alias_module_file_rel_path(self): + return os.path.join(self._module_subfolder, "conan-official-{}-old-targets.cmake".format(self.name)) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + save(self, module_file, content) + def package(self): self.copy('LICENSE.TXT', dst='licenses', src=self._source_subfolder) lib_path = os.path.join(self.package_folder, 'lib') @@ -216,12 +268,14 @@ def package(self): if not self.options.shared: for ext in ['.a', '.lib']: + lib = '**/lib/*LLVMTableGenGlobalISel{}'.format(ext) + self.copy(lib, dst='lib', keep_path=False) lib = '*LLVMTableGenGlobalISel{}'.format(ext) self.copy(lib, dst='lib', src='lib') - self.run('cmake --graphviz=graph/llvm.dot .') - with tools.chdir('graph'): - dot_text = tools.load('llvm.dot').replace('\r\n', '\n') + CMake(self).configure(args=['--graphviz=graph/llvm.dot'], source_dir='.', build_dir='.') + with chdir(self, 'graph'): + dot_text = load(self, 'llvm.dot').replace('\r\n', '\n') dep_regex = re.compile(r'//\s(.+)\s->\s(.+)$', re.MULTILINE) deps = re.findall(dep_regex, dot_text) @@ -259,15 +313,50 @@ def package(self): else: components[lib].append(dep) - tools.rmdir(os.path.join(self.package_folder, 'bin')) - tools.rmdir(os.path.join(self.package_folder, 'lib', 'cmake')) - tools.rmdir(os.path.join(self.package_folder, 'share')) + alias_targets = {} + old_alias_targets = {} + for component, _ in components.items(): + alias_targets[component] = "LLVM::{}".format(component) + old_alias_targets["llvm-core::{}".format(component[4:].replace('LLVM', '').lower())] = "LLVM::{}".format(component) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._alias_module_file_rel_path), + alias_targets + ) + + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._old_alias_module_file_rel_path), + old_alias_targets + ) + + rmdir(self, os.path.join(self.package_folder, 'share')) + + rm(self, "LLVMExports*.cmake", self.package_folder, recursive=True) + rename(self, os.path.join(self.package_folder, self._module_subfolder, 'LLVM-Config.cmake'), + os.path.join(self.package_folder, self._module_subfolder, 'LLVM-ConfigInternal.cmake')) + rename(self, os.path.join(self.package_folder, self._module_subfolder, 'LLVMConfig.cmake'), + os.path.join(self.package_folder, self._module_subfolder, 'LLVMConfigInternal.cmake')) + + replace_in_file(self, os.path.join(self.package_folder, self._module_subfolder, 'AddLLVM.cmake'), + "include(LLVM-Config)", + "include(LLVM-ConfigInternal)") + replace_in_file(self, os.path.join(self.package_folder, self._module_subfolder, 'LLVMConfigInternal.cmake'), + "LLVM-Config.cmake", + "LLVM-ConfigInternal.cmake") + + for mask in ["Find*.cmake", "*Config.cmake", "*-config.cmake"]: + rm(self, mask, self.package_folder, recursive=True) for name in os.listdir(lib_path): - if 'LLVM' not in name: - os.remove(os.path.join(lib_path, name)) + fullname = os.path.join(lib_path, name) + if 'LLVM' not in name and os.path.isfile(fullname): + os.remove(fullname) if not self.options.shared: + if self.options.get_safe('with_zlib', False): + if not 'z' in components['LLVMSupport']: + components['LLVMSupport'].append('z') components_path = \ os.path.join(self.package_folder, 'lib', 'components.json') with open(components_path, 'w') as components_file: @@ -279,13 +368,14 @@ def package(self): os.remove(os.path.join(lib_path, name)) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "LLVM") + if self.options.shared: - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = collect_libs(self) if self.settings.os == 'Linux': - self.cpp_info.system_libs = ['tinfo', 'pthread'] - self.cpp_info.system_libs.extend(['rt', 'dl', 'm']) + self.cpp_info.system_libs = ['pthread', 'rt', 'dl', 'm'] elif self.settings.os == 'Macos': - self.cpp_info.system_libs = ['curses', 'm'] + self.cpp_info.system_libs = ['m'] return components_path = \ @@ -300,15 +390,10 @@ def package_info(self): 'xml2': 'libxml2::libxml2' } - for lib, deps in components.items(): - component = lib[4:].replace('LLVM', '').lower() - - self.cpp_info.components[component].libs = [lib] + for component, deps in components.items(): + self.cpp_info.components[component].libs = [component] + self.cpp_info.components[component].requires.extend(dep for dep in deps if dep.startswith('LLVM')) - self.cpp_info.components[component].requires = [ - dep[4:].replace('LLVM', '').lower() - for dep in deps if dep.startswith('LLVM') - ] for lib, target in targets.items(): if lib in deps: self.cpp_info.components[component].requires.append(target) @@ -317,3 +402,29 @@ def package_info(self): dep for dep in deps if not dep.startswith('LLVM') and dep not in dependencies ] + + self.cpp_info.components[component].set_property("cmake_target_name", component) + self.cpp_info.components[component].builddirs.append(self._module_subfolder) + + self.cpp_info.components[component].names["cmake_find_package"] = component + self.cpp_info.components[component].names["cmake_find_package_multi"] = component + self.cpp_info.components[component].build_modules["cmake_find_package"].extend([ + self._alias_module_file_rel_path, + self._old_alias_module_file_rel_path, + ]) + self.cpp_info.components[component].build_modules["cmake_find_package_multi"].extend([ + self._alias_module_file_rel_path, + self._old_alias_module_file_rel_path, + ]) + + if self.options.use_llvm_cmake_files: + self.cpp_info.components[component].build_modules["cmake_find_package"].append( + os.path.join(self._module_subfolder, "LLVMConfigInternal.cmake") + ) + self.cpp_info.components[component].build_modules["cmake_find_package_multi"].append( + os.path.join(self._module_subfolder, "LLVMConfigInternal.cmake") + ) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "LLVM" + self.cpp_info.names["cmake_find_package_multi"] = "LLVM" diff --git a/recipes/llvm-core/all/patches/11.1.0-vs2019.patch b/recipes/llvm-core/all/patches/11.1.0-vs2019.patch deleted file mode 100644 index 509261ff3794d..0000000000000 --- a/recipes/llvm-core/all/patches/11.1.0-vs2019.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- include/llvm/Support/type_traits.h -+++ include/llvm/Support/type_traits.h -@@ -176,7 +176,7 @@ - (has_deleted_copy_assign || has_trivial_copy_assign) && - (has_deleted_copy_constructor || has_trivial_copy_constructor); - --#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE -+#if 0 - static_assert(value == std::is_trivially_copyable::value, - "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); - #endif diff --git a/recipes/llvm-core/all/patches/11.1.0-cmake.patch b/recipes/llvm-core/all/patches/11x/11.1.0-cmake.patch similarity index 100% rename from recipes/llvm-core/all/patches/11.1.0-cmake.patch rename to recipes/llvm-core/all/patches/11x/11.1.0-cmake.patch diff --git a/recipes/llvm-core/all/patches/11.1.0-native.patch b/recipes/llvm-core/all/patches/11x/11.1.0-native.patch similarity index 100% rename from recipes/llvm-core/all/patches/11.1.0-native.patch rename to recipes/llvm-core/all/patches/11x/11.1.0-native.patch diff --git a/recipes/llvm-core/all/patches/12x/12.0.0-cmake.patch b/recipes/llvm-core/all/patches/12x/12.0.0-cmake.patch new file mode 100644 index 0000000000000..8d3f7dbf7cf98 --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/12.0.0-cmake.patch @@ -0,0 +1,55 @@ +--- cmake/config-ix.cmake ++++ cmake/config-ix.cmake +@@ -143,6 +143,9 @@ + elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + find_package(LibXml2) + endif() ++ set(LIBXML2_FOUND 1) ++ list(GET LibXml2_INCLUDE_DIRS -1 LIBXML2_INCLUDE_DIR) ++ set(LIBXML2_LIBRARIES ${LibXml2_LIBRARIES}) + if(LibXml2_FOUND) + # Check if libxml2 we found is usable; for example, we may have found a 32-bit + # library on a 64-bit system which would result in a link-time failure. +@@ -335,7 +335,7 @@ + message(FATAL_ERROR "libffi includes are not found.") + endif() + +- find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR}) ++ find_library(FFI_LIBRARY_PATH NAMES ffi libffi PATHS ${FFI_LIBRARY_DIR}) + if( NOT FFI_LIBRARY_PATH ) + message(FATAL_ERROR "libffi is not found.") + endif() +--- cmake/modules/TableGen.cmake ++++ cmake/modules/TableGen.cmake +@@ -132,12 +132,7 @@ + macro(add_tablegen target project) + set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS}) + set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen) +- +- # CMake doesn't let compilation units depend on their dependent libraries on some generators. +- if(NOT CMAKE_GENERATOR STREQUAL "Ninja" AND NOT XCODE) +- # FIXME: It leaks to user, callee of add_tablegen. +- set(LLVM_ENABLE_OBJLIB ON) +- endif() ++ set(LLVM_ENABLE_OBJLIB OFF) + + add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN}) + set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) +--- lib/WindowsManifest/CMakeLists.txt ++++ lib/WindowsManifest/CMakeLists.txt +@@ -21,14 +21,5 @@ + # This block is only needed for llvm-config. When we deprecate llvm-config and + # move to using CMake export, this block can be removed. + if(LLVM_ENABLE_LIBXML2) +- # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. +- if(CMAKE_BUILD_TYPE) +- string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) +- endif() +- if(NOT zlib_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) +- endif() +- get_library_name(${libxml2_library} libxml2_library) +- set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) ++ set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${LIBXML2_LIBRARIES}) + endif() diff --git a/recipes/llvm-core/all/patches/12x/12.0.0-native.patch b/recipes/llvm-core/all/patches/12x/12.0.0-native.patch new file mode 100644 index 0000000000000..f5c6d542fab8f --- /dev/null +++ b/recipes/llvm-core/all/patches/12x/12.0.0-native.patch @@ -0,0 +1,81 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -891,10 +891,6 @@ + include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}) + + # when crosscompiling import the executable targets from a file +-if(LLVM_USE_HOST_TOOLS) +- include(CrossCompile) +- llvm_create_cross_target(LLVM NATIVE "" Release) +-endif(LLVM_USE_HOST_TOOLS) + if(LLVM_TARGET_IS_CROSSCOMPILE_HOST) + # Dummy use to avoid CMake Warning: Manually-specified variables were not used + # (this is a variable that CrossCompile sets on recursive invocations) +--- cmake/modules/TableGen.cmake ++++ cmake/modules/TableGen.cmake +@@ -144,33 +144,6 @@ + set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN} PARENT_SCOPE) + set(${project}_TABLEGEN_TARGET ${${project}_TABLEGEN} PARENT_SCOPE) + +- if(LLVM_USE_HOST_TOOLS) +- if( ${${project}_TABLEGEN} STREQUAL "${target}" ) +- # The NATIVE tablegen executable *must* depend on the current target one +- # otherwise the native one won't get rebuilt when the tablgen sources +- # change, and we end up with incorrect builds. +- build_native_tool(${target} ${project}_TABLEGEN_EXE DEPENDS ${target}) +- set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN_EXE} PARENT_SCOPE) +- +- add_custom_target(${project}-tablegen-host DEPENDS ${${project}_TABLEGEN_EXE}) +- set(${project}_TABLEGEN_TARGET ${project}-tablegen-host PARENT_SCOPE) +- +- # Create an artificial dependency between tablegen projects, because they +- # compile the same dependencies, thus using the same build folders. +- # FIXME: A proper fix requires sequentially chaining tablegens. +- if (NOT ${project} STREQUAL LLVM AND TARGET ${project}-tablegen-host AND +- TARGET LLVM-tablegen-host) +- add_dependencies(${project}-tablegen-host LLVM-tablegen-host) +- endif() +- +- # If we're using the host tablegen, and utils were not requested, we have no +- # need to build this tablegen. +- if ( NOT LLVM_BUILD_UTILS ) +- set_target_properties(${target} PROPERTIES EXCLUDE_FROM_ALL ON) +- endif() +- endif() +- endif() +- + if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS) + set(export_to_llvmexports) + if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR +--- tools/llvm-config/CMakeLists.txt ++++ tools/llvm-config/CMakeLists.txt +@@ -75,11 +75,3 @@ + + # Add the dependency on the generation step. + add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp ${BUILDVARIABLES_OBJPATH}) +- +-if(CMAKE_CROSSCOMPILING AND NOT LLVM_CONFIG_PATH) +- build_native_tool(llvm-config LLVM_CONFIG_PATH) +- set(LLVM_CONFIG_PATH "${LLVM_CONFIG_PATH}" CACHE STRING "") +- +- add_custom_target(NativeLLVMConfig DEPENDS ${LLVM_CONFIG_PATH}) +- add_dependencies(llvm-config NativeLLVMConfig) +-endif() +--- tools/llvm-shlib/CMakeLists.txt ++++ tools/llvm-shlib/CMakeLists.txt +@@ -155,13 +155,8 @@ + + set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.exports) + if(NOT LLVM_NM) +- if(CMAKE_CROSSCOMPILING) +- build_native_tool(llvm-nm llvm_nm) +- set(llvm_nm_target "${llvm_nm}") +- else() +- set(llvm_nm $) +- set(llvm_nm_target llvm-nm) +- endif() ++ set(llvm_nm $) ++ set(llvm_nm_target llvm-nm) + else() + set(llvm_nm ${LLVM_NM}) + set(llvm_nm_target "") diff --git a/recipes/llvm-core/all/patches/13x/13.0.0-cmake.patch b/recipes/llvm-core/all/patches/13x/13.0.0-cmake.patch new file mode 100644 index 0000000000000..981f067a21505 --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/13.0.0-cmake.patch @@ -0,0 +1,54 @@ +--- cmake/config-ix.cmake ++++ cmake/config-ix.cmake +@@ -143,6 +143,9 @@ if(LLVM_ENABLE_LIBXML2) + elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + find_package(LibXml2) + endif() ++ set(LIBXML2_FOUND 1) ++ list(GET LibXml2_INCLUDE_DIRS -1 LIBXML2_INCLUDE_DIR) ++ set(LIBXML2_LIBRARIES ${LibXml2_LIBRARIES}) + if(LibXml2_FOUND) + # Check if libxml2 we found is usable; for example, we may have found a 32-bit + # library on a 64-bit system which would result in a link-time failure. +@@ -343,7 +346,7 @@ if( LLVM_ENABLE_FFI ) + message(FATAL_ERROR "libffi includes are not found.") + endif() + +- find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR}) ++ find_library(FFI_LIBRARY_PATH NAMES ffi libffi PATHS ${FFI_LIBRARY_DIR}) + if( NOT FFI_LIBRARY_PATH ) + message(FATAL_ERROR "libffi is not found.") + endif() +--- cmake/modules/TableGen.cmake ++++ cmake/modules/TableGen.cmake +@@ -135,11 +135,7 @@ macro(add_tablegen target project) + set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS}) + set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen) + +- # CMake doesn't let compilation units depend on their dependent libraries on some generators. +- if(NOT CMAKE_GENERATOR STREQUAL "Ninja" AND NOT XCODE) +- # FIXME: It leaks to user, callee of add_tablegen. +- set(LLVM_ENABLE_OBJLIB ON) +- endif() ++ set(LLVM_ENABLE_OBJLIB OFF) + + add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN}) + set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) +--- lib/WindowsManifest/CMakeLists.txt ++++ lib/WindowsManifest/CMakeLists.txt +@@ -21,14 +21,5 @@ add_llvm_component_library(LLVMWindowsManifest + # This block is only needed for llvm-config. When we deprecate llvm-config and + # move to using CMake export, this block can be removed. + if(LLVM_ENABLE_LIBXML2) +- # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. +- if(CMAKE_BUILD_TYPE) +- string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION_${build_type}) +- endif() +- if(NOT zlib_library) +- get_property(libxml2_library TARGET LibXml2::LibXml2 PROPERTY LOCATION) +- endif() +- get_library_name(${libxml2_library} libxml2_library) +- set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${libxml2_library}) ++ set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS ${LIBXML2_LIBRARIES}) + endif() diff --git a/recipes/llvm-core/all/patches/13x/13.0.0-native.patch b/recipes/llvm-core/all/patches/13x/13.0.0-native.patch new file mode 100644 index 0000000000000..fa8482ce0493b --- /dev/null +++ b/recipes/llvm-core/all/patches/13x/13.0.0-native.patch @@ -0,0 +1,78 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -931,10 +931,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) + include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}) + + # when crosscompiling import the executable targets from a file +-if(LLVM_USE_HOST_TOOLS) +- include(CrossCompile) +- llvm_create_cross_target(LLVM NATIVE "" Release) +-endif(LLVM_USE_HOST_TOOLS) + if(LLVM_TARGET_IS_CROSSCOMPILE_HOST) + # Dummy use to avoid CMake Warning: Manually-specified variables were not used + # (this is a variable that CrossCompile sets on recursive invocations) +--- cmake/modules/TableGen.cmake ++++ cmake/modules/TableGen.cmake +@@ -147,32 +147,6 @@ macro(add_tablegen target project) + set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN} PARENT_SCOPE) + set(${project}_TABLEGEN_TARGET ${${project}_TABLEGEN} PARENT_SCOPE) + +- if(LLVM_USE_HOST_TOOLS) +- if( ${${project}_TABLEGEN} STREQUAL "${target}" ) +- # The NATIVE tablegen executable *must* depend on the current target one +- # otherwise the native one won't get rebuilt when the tablgen sources +- # change, and we end up with incorrect builds. +- build_native_tool(${target} ${project}_TABLEGEN_EXE DEPENDS ${target}) +- set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN_EXE} PARENT_SCOPE) +- +- add_custom_target(${project}-tablegen-host DEPENDS ${${project}_TABLEGEN_EXE}) +- set(${project}_TABLEGEN_TARGET ${project}-tablegen-host PARENT_SCOPE) +- +- # Create an artificial dependency between tablegen projects, because they +- # compile the same dependencies, thus using the same build folders. +- # FIXME: A proper fix requires sequentially chaining tablegens. +- if (NOT ${project} STREQUAL LLVM AND TARGET ${project}-tablegen-host AND +- TARGET LLVM-tablegen-host) +- add_dependencies(${project}-tablegen-host LLVM-tablegen-host) +- endif() +- +- # If we're using the host tablegen, and utils were not requested, we have no +- # need to build this tablegen. +- if ( NOT LLVM_BUILD_UTILS ) +- set_target_properties(${target} PROPERTIES EXCLUDE_FROM_ALL ON) +- endif() +- endif() +- endif() + + if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS) + set(export_to_llvmexports) +--- tools/llvm-config/CMakeLists.txt ++++ tools/llvm-config/CMakeLists.txt +@@ -75,11 +75,3 @@ endif() + + # Add the dependency on the generation step. + add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp ${BUILDVARIABLES_OBJPATH}) +- +-if(CMAKE_CROSSCOMPILING AND NOT LLVM_CONFIG_PATH) +- build_native_tool(llvm-config LLVM_CONFIG_PATH) +- set(LLVM_CONFIG_PATH "${LLVM_CONFIG_PATH}" CACHE STRING "") +- +- add_custom_target(NativeLLVMConfig DEPENDS ${LLVM_CONFIG_PATH}) +- add_dependencies(llvm-config NativeLLVMConfig) +-endif() +--- tools/llvm-shlib/CMakeLists.txt ++++ tools/llvm-shlib/CMakeLists.txt +@@ -162,13 +162,6 @@ if(LLVM_BUILD_LLVM_C_DYLIB AND MSVC) + + set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllvm-c.exports) + if(NOT LLVM_NM) +- if(CMAKE_CROSSCOMPILING) +- build_native_tool(llvm-nm llvm_nm) +- set(llvm_nm_target "${llvm_nm}") +- else() +- set(llvm_nm $) +- set(llvm_nm_target llvm-nm) +- endif() + else() + set(llvm_nm ${LLVM_NM}) + set(llvm_nm_target "") diff --git a/recipes/llvm-core/all/test_package/CMakeLists.txt b/recipes/llvm-core/all/test_package/CMakeLists.txt index d2d3b1ff641d9..726aa5975f221 100644 --- a/recipes/llvm-core/all/test_package/CMakeLists.txt +++ b/recipes/llvm-core/all/test_package/CMakeLists.txt @@ -4,17 +4,17 @@ project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -find_package(llvm-core) +find_package(LLVM REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) -if(TARGET llvm-core::interpreter) # static libraries +if(TARGET LLVMInterpreter) # static libraries target_link_libraries(${PROJECT_NAME} PRIVATE - llvm-core::interpreter - llvm-core::irreader - llvm-core::x86codegen + LLVMInterpreter + LLVMIRReader + LLVMX86CodeGen ) else() # shared library - target_link_libraries(${PROJECT_NAME} llvm-core::llvm-core) + target_link_libraries(${PROJECT_NAME} LLVM) endif() diff --git a/recipes/llvm-core/config.yml b/recipes/llvm-core/config.yml index 051c4cad1e3eb..bc979f696a102 100644 --- a/recipes/llvm-core/config.yml +++ b/recipes/llvm-core/config.yml @@ -1,3 +1,7 @@ versions: + "13.0.0": + folder: all + "12.0.0": + folder: all "11.1.0": folder: all diff --git a/recipes/llvm-openmp/all/CMakeLists.txt b/recipes/llvm-openmp/all/CMakeLists.txt index 07ec7f05275cb..61f3d3b039e2b 100644 --- a/recipes/llvm-openmp/all/CMakeLists.txt +++ b/recipes/llvm-openmp/all/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory("source_subfolder") diff --git a/recipes/llvm-openmp/all/conandata.yml b/recipes/llvm-openmp/all/conandata.yml index 14ea921ffaed7..499e8f40e5c34 100644 --- a/recipes/llvm-openmp/all/conandata.yml +++ b/recipes/llvm-openmp/all/conandata.yml @@ -1,25 +1,36 @@ sources: + "12.0.1": + url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.1/openmp-12.0.1.src.tar.xz" + sha256: "60fe79440eaa9ebf583a6ea7f81501310388c02754dbe7dc210776014d06b091" + "11.1.0": + url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/openmp-11.1.0.src.tar.xz" + sha256: "d187483b75b39acb3ff8ea1b7d98524d95322e3cb148842957e9b0fbb866052e" "10.0.0": - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/openmp-10.0.0.src.tar.xz - sha256: 3b9ff29a45d0509a1e9667a0feb43538ef402ea8cfc7df3758a01f20df08adfa - + url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/openmp-10.0.0.src.tar.xz" + sha256: "3b9ff29a45d0509a1e9667a0feb43538ef402ea8cfc7df3758a01f20df08adfa" "9.0.1": - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-9.0.1/openmp-9.0.1.src.tar.xz - sha256: 5c94060f846f965698574d9ce22975c0e9f04c9b14088c3af5f03870af75cace - + url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-9.0.1/openmp-9.0.1.src.tar.xz" + sha256: "5c94060f846f965698574d9ce22975c0e9f04c9b14088c3af5f03870af75cace" "8.0.1": - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/openmp-8.0.1.src.tar.xz - sha256: 3e85dd3cad41117b7c89a41de72f2e6aa756ea7b4ef63bb10dcddf8561a7722c - + url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/openmp-8.0.1.src.tar.xz" + sha256: "3e85dd3cad41117b7c89a41de72f2e6aa756ea7b4ef63bb10dcddf8561a7722c" patches: + "12.0.1": + - patch_file: "patches/0001-disable-build-testing_12.0.1.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-disable-omp-target_12.0.1.patch" + base_path: "source_subfolder" + "11.1.0": + - patch_file: "patches/0001-disable-build-testing_11.1.0.patch" + base_path: "source_subfolder" + - patch_file: "patches/0003-fix-armv8-build_11.1.0.patch" + base_path: "source_subfolder" "10.0.0": - - base_path: "source_subfolder" - patch_file: "patches/0001-disable-build-testing_10.0.0.patch" - + - patch_file: "patches/0001-disable-build-testing_10.0.0.patch" + base_path: "source_subfolder" "9.0.1": - - base_path: "source_subfolder" - patch_file: "patches/0001-disable-build-testing.patch" - + - patch_file: "patches/0001-disable-build-testing.patch" + base_path: "source_subfolder" "8.0.1": - - base_path: "source_subfolder" - patch_file: "patches/0001-disable-build-testing.patch" + - patch_file: "patches/0001-disable-build-testing.patch" + base_path: "source_subfolder" diff --git a/recipes/llvm-openmp/all/conanfile.py b/recipes/llvm-openmp/all/conanfile.py index fb970dbd39010..4f1ee354a647e 100644 --- a/recipes/llvm-openmp/all/conanfile.py +++ b/recipes/llvm-openmp/all/conanfile.py @@ -1,6 +1,10 @@ -import os from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration +import os +import functools +import textwrap + +required_conan_version = ">=1.43.0" class LLVMOpenMpConan(ConanFile): @@ -15,19 +19,22 @@ class LLVMOpenMpConan(ConanFile): topics = ("conan", "llvm", "openmp", "parallelism") homepage = "https://github.com/llvm/llvm-project/tree/master/openmp" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, - "fPIC": False} - exports_sources = "CMakeLists.txt", "patches/**" + "fPIC": True} generators = "cmake" - _cmake = None @property def _source_subfolder(self): return "source_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -41,30 +48,38 @@ def _supports_compiler(self): return the_compiler in supported_compilers_by_os.get(the_os, []) def configure(self): + if self.options.shared: + del self.options.fPIC if not self._supports_compiler(): raise ConanInvalidConfiguration("llvm-openmp doesn't support compiler: {} on OS: {}.". format(self.settings.compiler, self.settings.os)) + def validate(self): + if ( + tools.Version(self.version) <= "10.0.0" + and self.settings.os == "Macos" + and self.settings.arch == "armv8" + ): + raise ConanInvalidConfiguration("ARM v8 not supported") + def source(self): tools.get(**self.conan_data["sources"][self.version]) extracted_dir = "openmp-{}.src".format(self.version) os.rename(extracted_dir, self._source_subfolder) def _patch_sources(self): - if self.version in self.conan_data["patches"]: - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["OPENMP_STANDALONE_BUILD"] = True - self._cmake.definitions["LIBOMP_ENABLE_SHARED"] = self.options.shared + cmake = CMake(self) + cmake.definitions["OPENMP_STANDALONE_BUILD"] = True + cmake.definitions["LIBOMP_ENABLE_SHARED"] = self.options.shared if self.settings.os == "Linux": - self._cmake.definitions["OPENMP_ENABLE_LIBOMPTARGET"] = self.options.shared - self._cmake.configure() - return self._cmake + cmake.definitions["OPENMP_ENABLE_LIBOMPTARGET"] = self.options.shared + cmake.configure() + return cmake def build(self): self._patch_sources() @@ -78,8 +93,44 @@ def package(self): cmake = self._configure_cmake() cmake.install() + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + { + "OpenMP::OpenMP_C": "OpenMP::OpenMP", + "OpenMP::OpenMP_CXX": "OpenMP::OpenMP" + } + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + def package_info(self): - if self.settings.compiler == "clang" or self.settings.compiler == "apple-clang": + self.cpp_info.set_property("cmake_file_name", "OpenMP") + self.cpp_info.set_property("cmake_target_name", "OpenMP::OpenMP") + self.cpp_info.set_property("cmake_target_aliases", ["OpenMP::OpenMP_C", "OpenMP::OpenMP_CXX"]) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "OpenMP" + self.cpp_info.names["cmake_find_package_multi"] = "OpenMP" + self.cpp_info.builddirs.append(os.path.join(self.package_folder, 'lib', 'cmake')) + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + + if self.settings.compiler in ("clang", "apple-clang"): self.cpp_info.cxxflags = ["-Xpreprocessor", "-fopenmp"] elif self.settings.compiler == 'gcc': self.cpp_info.cxxflags = ["-fopenmp"] @@ -87,4 +138,4 @@ def package_info(self): self.cpp_info.cxxflags = ["/Qopenmp"] if self.settings.os == 'Windows' else ["-Qopenmp"] self.cpp_info.libs = tools.collect_libs(self) if self.settings.os == "Linux": - self.cpp_info.system_libs = ["dl", "m", "pthread"] + self.cpp_info.system_libs = ["dl", "m", "pthread", "rt"] diff --git a/recipes/llvm-openmp/all/patches/0001-disable-build-testing_11.1.0.patch b/recipes/llvm-openmp/all/patches/0001-disable-build-testing_11.1.0.patch new file mode 100644 index 0000000000000..910ab03dc90e1 --- /dev/null +++ b/recipes/llvm-openmp/all/patches/0001-disable-build-testing_11.1.0.patch @@ -0,0 +1,52 @@ +diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt +index 6f0d9e728002..cf7bd7590f43 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -21,12 +21,6 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S + # Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR. + set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}") + +- # Group test settings. +- set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING +- "C compiler to use for testing OpenMP runtime libraries.") +- set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING +- "C++ compiler to use for testing OpenMP runtime libraries.") +- set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.") + else() + set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR}) + # If building in tree, we honor the same install suffix LLVM uses. +@@ -45,15 +39,6 @@ endif() + include(config-ix) + include(HandleOpenMPOptions) + +-# Set up testing infrastructure. +-include(OpenMPTesting) +- +-set(OPENMP_TEST_FLAGS "" CACHE STRING +- "Extra compiler flags to send to the test compiler.") +-set(OPENMP_TEST_OPENMP_FLAGS ${OPENMP_TEST_COMPILER_OPENMP_FLAGS} CACHE STRING +- "OpenMP compiler flag to use for testing OpenMP runtime libraries.") +- +- + # Build host runtime library. + add_subdirectory(runtime) + +@@ -78,18 +63,3 @@ if (OPENMP_ENABLE_LIBOMPTARGET) + + add_subdirectory(libomptarget) + endif() +- +-set(ENABLE_OMPT_TOOLS ON) +-# Currently tools are not tested well on Windows or MacOS X. +-if (APPLE OR WIN32) +- set(ENABLE_OMPT_TOOLS OFF) +-endif() +- +-option(OPENMP_ENABLE_OMPT_TOOLS "Enable building ompt based tools for OpenMP." +- ${ENABLE_OMPT_TOOLS}) +-if (OPENMP_ENABLE_OMPT_TOOLS) +- add_subdirectory(tools) +-endif() +- +-# Now that we have seen all testsuites, create the check-openmp target. +-construct_check_openmp_target() diff --git a/recipes/llvm-openmp/all/patches/0001-disable-build-testing_12.0.1.patch b/recipes/llvm-openmp/all/patches/0001-disable-build-testing_12.0.1.patch new file mode 100644 index 0000000000000..a1716382cf4d8 --- /dev/null +++ b/recipes/llvm-openmp/all/patches/0001-disable-build-testing_12.0.1.patch @@ -0,0 +1,55 @@ +diff --git a/CMakeLists_orig.txt b/CMakeLists.txt +index b8a2822..7950dde 100644 +--- a/CMakeLists_orig.txt ++++ b/CMakeLists.txt +@@ -21,12 +21,6 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S + # Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR. + set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}") + +- # Group test settings. +- set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING +- "C compiler to use for testing OpenMP runtime libraries.") +- set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING +- "C++ compiler to use for testing OpenMP runtime libraries.") +- set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.") + else() + set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR}) + # If building in tree, we honor the same install suffix LLVM uses. +@@ -47,14 +41,6 @@ endif() + include(config-ix) + include(HandleOpenMPOptions) + +-# Set up testing infrastructure. +-include(OpenMPTesting) +- +-set(OPENMP_TEST_FLAGS "" CACHE STRING +- "Extra compiler flags to send to the test compiler.") +-set(OPENMP_TEST_OPENMP_FLAGS ${OPENMP_TEST_COMPILER_OPENMP_FLAGS} CACHE STRING +- "OpenMP compiler flag to use for testing OpenMP runtime libraries.") +- + set(ENABLE_LIBOMPTARGET ON) + # Currently libomptarget cannot be compiled on Windows or MacOS X. + # Since the device plugins are only supported on Linux anyway, +@@ -97,22 +83,3 @@ if (OPENMP_ENABLE_LIBOMPTARGET) + + add_subdirectory(libomptarget) + endif() +- +-set(ENABLE_OMPT_TOOLS ON) +-# Currently tools are not tested well on Windows or MacOS X. +-if (APPLE OR WIN32) +- set(ENABLE_OMPT_TOOLS OFF) +-endif() +- +-option(OPENMP_ENABLE_OMPT_TOOLS "Enable building ompt based tools for OpenMP." +- ${ENABLE_OMPT_TOOLS}) +-if (OPENMP_ENABLE_OMPT_TOOLS) +- add_subdirectory(tools) +-endif() +- +- +-# Build documentation +-add_subdirectory(docs) +- +-# Now that we have seen all testsuites, create the check-openmp target. +-construct_check_openmp_target() diff --git a/recipes/llvm-openmp/all/patches/0002-disable-omp-target_12.0.1.patch b/recipes/llvm-openmp/all/patches/0002-disable-omp-target_12.0.1.patch new file mode 100644 index 0000000000000..cd1c4ba9b8096 --- /dev/null +++ b/recipes/llvm-openmp/all/patches/0002-disable-omp-target_12.0.1.patch @@ -0,0 +1,15 @@ +diff --git a/libomptarget/CMakeLists.txt b/libomptarget/CMakeLists.txt +index 6c90ced..629e20a 100644 +--- a/libomptarget/CMakeLists.txt ++++ b/libomptarget/CMakeLists.txt +@@ -30,10 +30,6 @@ include(LibomptargetUtils) + # Get dependencies for the different components of the project. + include(LibomptargetGetDependencies) + +-# LLVM source tree is required at build time for libomptarget +-if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS) +- message(FATAL_ERROR "Missing definition for LIBOMPTARGET_LLVM_INCLUDE_DIRS") +-endif() + + # This is a list of all the targets that are supported/tested right now. + set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} aarch64-unknown-linux-gnu") diff --git a/recipes/llvm-openmp/all/patches/0003-fix-armv8-build_11.1.0.patch b/recipes/llvm-openmp/all/patches/0003-fix-armv8-build_11.1.0.patch new file mode 100644 index 0000000000000..a0ff6484f924e --- /dev/null +++ b/recipes/llvm-openmp/all/patches/0003-fix-armv8-build_11.1.0.patch @@ -0,0 +1,19 @@ +diff --git a/openmp/runtime/src/z_Linux_asm.S b/openmp/runtime/src/z_Linux_asm.S +index 8090ff759fe1..d50019c299fc 100644 +--- a/runtime/src/z_Linux_asm.S ++++ b/runtime/src/z_Linux_asm.S +@@ -1746,10 +1746,12 @@ __kmp_unnamed_critical_addr: + .comm .gomp_critical_user_,32,8 + .data + .align 8 +- .global __kmp_unnamed_critical_addr +-__kmp_unnamed_critical_addr: ++ .global KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr) ++KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr): + .8byte .gomp_critical_user_ ++#ifdef __ELF__ + .size __kmp_unnamed_critical_addr,8 ++#endif + #endif /* KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || + KMP_ARCH_RISCV64 */ + diff --git a/recipes/llvm-openmp/all/test_package/CMakeLists.txt b/recipes/llvm-openmp/all/test_package/CMakeLists.txt index 37cb8eb98e622..2d9a8574cc4d4 100644 --- a/recipes/llvm-openmp/all/test_package/CMakeLists.txt +++ b/recipes/llvm-openmp/all/test_package/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.1) project(PackageTest CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(OpenMP CONFIG REQUIRED) add_executable(test_package test_package.cpp) -target_link_libraries(test_package ${CONAN_LIBS}) +target_link_libraries(test_package OpenMP::OpenMP_CXX) diff --git a/recipes/llvm-openmp/all/test_package/conanfile.py b/recipes/llvm-openmp/all/test_package/conanfile.py index 1fc5de3c5e8b0..5ac3af772bdc0 100644 --- a/recipes/llvm-openmp/all/test_package/conanfile.py +++ b/recipes/llvm-openmp/all/test_package/conanfile.py @@ -1,10 +1,10 @@ -import os from conans import ConanFile, CMake, tools +import os class LLVMOpenMpTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/llvm-openmp/all/test_package/test_package.cpp b/recipes/llvm-openmp/all/test_package/test_package.cpp index 246d740566041..f6316471238aa 100644 --- a/recipes/llvm-openmp/all/test_package/test_package.cpp +++ b/recipes/llvm-openmp/all/test_package/test_package.cpp @@ -1,20 +1,20 @@ #include #include -#define THREAD_NUM 4 - int main() { - omp_set_num_threads(THREAD_NUM); + int num_threads = std::max(5, omp_get_num_procs()); + omp_set_num_threads(num_threads); int actual_number; #pragma omp parallel { - if(omp_get_thread_num() == 0){ - actual_number = omp_get_num_threads(); - } + #pragma omp single + { + actual_number = omp_get_num_threads(); + } } - if(actual_number != THREAD_NUM){ - std::cout << "Something went wrong. Expecting " << THREAD_NUM << " threads but found " << actual_number << ".\n"; + if(actual_number != num_threads){ + std::cout << "Something went wrong. Expecting " << num_threads << " threads but found " << actual_number << ".\n"; std::cout << "There are probably missing compiler flags.\n" ; return 1; } diff --git a/recipes/llvm-openmp/config.yml b/recipes/llvm-openmp/config.yml index 03b99b3cd3734..5f6a2e2df9402 100644 --- a/recipes/llvm-openmp/config.yml +++ b/recipes/llvm-openmp/config.yml @@ -1,9 +1,11 @@ versions: + "12.0.1": + folder: all + "11.1.0": + folder: all "10.0.0": folder: all - "9.0.1": folder: all - "8.0.1": folder: all diff --git a/recipes/lmdb/all/CMakeLists.txt b/recipes/lmdb/all/CMakeLists.txt index 9bf843edc7776..888afb35a88e0 100644 --- a/recipes/lmdb/all/CMakeLists.txt +++ b/recipes/lmdb/all/CMakeLists.txt @@ -1,34 +1,43 @@ cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) +project(lmdb LANGUAGES C) -include(conanbuildinfo.cmake) -conan_basic_setup() +include(GNUInstallDirs) # LMDB library: add_library(lmdb - source_subfolder/lmdb.h - source_subfolder/mdb.c - source_subfolder/midl.c - source_subfolder/midl.h + ${LMDB_SRC_DIR}/lmdb.h + ${LMDB_SRC_DIR}/mdb.c + ${LMDB_SRC_DIR}/midl.c + ${LMDB_SRC_DIR}/midl.h ) set_target_properties(lmdb PROPERTIES - PUBLIC_HEADER source_subfolder/lmdb.h + PUBLIC_HEADER ${LMDB_SRC_DIR}/lmdb.h WINDOWS_EXPORT_ALL_SYMBOLS ON ) -include(FindThreads) -target_link_libraries(lmdb PUBLIC ${CMAKE_THREAD_LIBS_INIT}) +find_package(Threads REQUIRED) +target_link_libraries(lmdb PUBLIC Threads::Threads) -install(TARGETS lmdb) +install(TARGETS lmdb + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +if (LMDB_ENABLE_ROBUST_MUTEX) + target_compile_definitions(lmdb PUBLIC MDB_USE_ROBUST=1) +else (LMDB_ENABLE_ROBUST_MUTEX) + target_compile_definitions(lmdb PUBLIC MDB_USE_ROBUST=0) +endif (LMDB_ENABLE_ROBUST_MUTEX) # LMDB utilities: if(NOT WIN32) foreach(TOOL mdb_stat mdb_copy mdb_dump mdb_load) - add_executable(${TOOL} source_subfolder/${TOOL}.c) + add_executable(${TOOL} ${LMDB_SRC_DIR}/${TOOL}.c) target_link_libraries(${TOOL} lmdb) - install(TARGETS ${TOOL}) + install(TARGETS ${TOOL} DESTINATION ${CMAKE_INSTALL_BINDIR}) endforeach() endif() diff --git a/recipes/lmdb/all/conanfile.py b/recipes/lmdb/all/conanfile.py index 50ec2b0e019ea..7700c885b181c 100644 --- a/recipes/lmdb/all/conanfile.py +++ b/recipes/lmdb/all/conanfile.py @@ -1,5 +1,9 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.46.0" class lmdbConan(ConanFile): @@ -8,64 +12,75 @@ class lmdbConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://symas.com/lmdb/" description = "Fast and compat memory-mapped key-value database" - topics = ("LMDB", "database", "key-value", "memory-mapped") - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - exports_sources = ["CMakeLists.txt"] - generators = "cmake" + topics = ("database", "key-value", "memory-mapped") - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "enable_robust_mutex": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "enable_robust_mutex": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + exports_sources = ["CMakeLists.txt"] def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.settings.os in ("Linux", "FreeBSD"): + self.options.enable_robust_mutex = True + else: + self.options.enable_robust_mutex = False def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - root = "openldap-LMDB_{}".format(self.version) - tools.rename(os.path.join(root, "libraries", "liblmdb"), self._source_subfolder) - tools.rmdir(root) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LMDB_SRC_DIR"] = os.path.join(self.source_folder, "libraries", "liblmdb").replace("\\", "/") + tc.variables["LMDB_ENABLE_ROBUST_MUTEX"] = self.options.enable_robust_mutex + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=os.path.join(self.source_folder, "libraries", "liblmdb"), dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): + self.cpp_info.set_property("pkg_config_name", "lmdb") self.cpp_info.libs = ["lmdb"] - self.cpp_info.names["cmake_find_package"] = "LMDB" - self.cpp_info.names["cmake_find_package_multi"] = "LMDB" - self.cpp_info.names["pkg_config"] = "lmdb" - if self.settings.os != "Windows": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["pthread"] bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.output.info(f"Appending PATH environment variable: {bin_path}") self.env_info.PATH.append(bin_path) diff --git a/recipes/lmdb/all/test_package/CMakeLists.txt b/recipes/lmdb/all/test_package/CMakeLists.txt index 4741d098c6b89..3342cb59e0fea 100644 --- a/recipes/lmdb/all/test_package/CMakeLists.txt +++ b/recipes/lmdb/all/test_package/CMakeLists.txt @@ -1,11 +1,7 @@ -cmake_minimum_required(VERSION 3.4) -project(test_package C) +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -find_package(PkgConfig) -pkg_check_modules(LMDB REQUIRED IMPORTED_TARGET GLOBAL lmdb) +find_package(lmdb REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} PkgConfig::LMDB) +target_link_libraries(${PROJECT_NAME} PRIVATE lmdb::lmdb) diff --git a/recipes/lmdb/all/test_package/conanfile.py b/recipes/lmdb/all/test_package/conanfile.py index bc48a2a20d588..0a6bc68712d90 100644 --- a/recipes/lmdb/all/test_package/conanfile.py +++ b/recipes/lmdb/all/test_package/conanfile.py @@ -1,14 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" -class LmdbTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "pkg_config" + def layout(self): + cmake_layout(self) - def build_requirements(self): - self.build_requires("pkgconf/1.7.3") + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -16,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/lmdb/all/test_v1_package/CMakeLists.txt b/recipes/lmdb/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..20645081348a3 --- /dev/null +++ b/recipes/lmdb/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(lmdb REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE lmdb::lmdb) diff --git a/recipes/lmdb/all/test_v1_package/conanfile.py b/recipes/lmdb/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/lmdb/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lodepng/all/CMakeLists.txt b/recipes/lodepng/all/CMakeLists.txt index 9add81f923732..151ff6e29fe1c 100644 --- a/recipes/lodepng/all/CMakeLists.txt +++ b/recipes/lodepng/all/CMakeLists.txt @@ -1,18 +1,12 @@ cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) +project(lodepng LANGUAGES CXX) -include(conanbuildinfo.cmake) -conan_basic_setup() - -if(BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - -add_library(lodepng "source_subfolder/lodepng.h" "source_subfolder/lodepng.cpp") +add_library(lodepng ${LODEPNG_SRC_DIR}/lodepng.cpp) +set_target_properties(lodepng PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) include(GNUInstallDirs) install(TARGETS lodepng RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") -install(FILES "source_subfolder/lodepng.h" DESTINATION include) +install(FILES ${LODEPNG_SRC_DIR}/lodepng.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/lodepng/all/conanfile.py b/recipes/lodepng/all/conanfile.py index fcc32dae65225..46fefaf886180 100644 --- a/recipes/lodepng/all/conanfile.py +++ b/recipes/lodepng/all/conanfile.py @@ -1,17 +1,21 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime import os -import glob -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.47.0" class LodepngConan(ConanFile): name = "lodepng" description = "PNG encoder and decoder in C and C++, without dependencies." license = "Zlib" - topics = ("conan", "png", "encoder", "decoder") + topics = ("png", "encoder", "decoder") homepage = "https://github.com/lvandeve/lodepng" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -22,44 +26,41 @@ class LodepngConan(ConanFile): "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + exports_sources = "CMakeLists.txt" def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC def configure(self): if self.options.shared: del self.options.fPIC + def validate(self): + if self.options.shared and is_msvc(self) and is_msvc_static_runtime(self): + raise ConanInvalidConfiguration("lodepng shared doesn't support Visual Studio with static runtime") + + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob('lodepng-*/')[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LODEPNG_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) def package_info(self): self.cpp_info.libs = ["lodepng"] diff --git a/recipes/lodepng/all/test_package/CMakeLists.txt b/recipes/lodepng/all/test_package/CMakeLists.txt index aede60e3b1e4a..3b1ba39df32d9 100644 --- a/recipes/lodepng/all/test_package/CMakeLists.txt +++ b/recipes/lodepng/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(lodepng REQUIRED CONFIG) -add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) -target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 11) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE lodepng::lodepng) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/lodepng/all/test_package/conanfile.py b/recipes/lodepng/all/test_package/conanfile.py index 7d734aa2efdfb..ad9ad50d2e692 100644 --- a/recipes/lodepng/all/test_package/conanfile.py +++ b/recipes/lodepng/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") bees = os.path.join(self.source_folder, "bees.png") - self.run("{} {}".format(bin_path, bees), run_environment=True) + self.run(f"{bin_path} {bees}", env="conanrun") diff --git a/recipes/lodepng/all/test_v1_package/CMakeLists.txt b/recipes/lodepng/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..54224af3ae67e --- /dev/null +++ b/recipes/lodepng/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(lodepng REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE lodepng::lodepng) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/lodepng/all/test_v1_package/conanfile.py b/recipes/lodepng/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..4441530a937ba --- /dev/null +++ b/recipes/lodepng/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + bees = os.path.join(self.source_folder, os.pardir, "test_package", "bees.png") + self.run(f"{bin_path} {bees}", run_environment=True) diff --git a/recipes/log.c/all/CMakeLists.txt b/recipes/log.c/all/CMakeLists.txt index 435630ff46f47..50b38ff756d4d 100644 --- a/recipes/log.c/all/CMakeLists.txt +++ b/recipes/log.c/all/CMakeLists.txt @@ -1,43 +1,21 @@ -cmake_minimum_required(VERSION 3.4) +cmake_minimum_required(VERSION 3.8) +project(log.c LANGUAGES C) -project(log.c - VERSION 0.1.0 - LANGUAGES C - ) +option(LOGC_USE_COLOR "Use Color" ON) -# Init Conan stuff -include(conanbuildinfo.cmake) -conan_basic_setup() +add_library(log.c ${LOGC_SRC_FOLDER}/src/log.c) +set_target_properties(log.c PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) +target_compile_features(log.c PRIVATE c_std_99) -# Defines the CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR and many other useful macros. -# See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html -include(GNUInstallDirs) - -set(SRC_FOLDER "source_subfolder") - -# To build shared libraries in Windows, we set CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS to TRUE. -# See https://cmake.org/cmake/help/v3.4/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS.html -# See https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/ -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - -# Library files SHARED or STATIC set by Conan with BUILD_SHARED_LIBS -add_library(${PROJECT_NAME} ${SRC_FOLDER}/src/log.c ${SRC_FOLDER}/src/log.h) - -target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}) - -# Library info -set_target_properties(${PROJECT_NAME} PROPERTIES - VERSION ${PROJECT_VERSION} - C_STANDARD 99) - -# Conan options -if (COLOR) - TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE LOG_USE_COLOR) +if(LOGC_USE_COLOR) + target_compile_definitions(log.c PRIVATE LOG_USE_COLOR) endif() -install(FILES ${SRC_FOLDER}/src/log.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(FILES ${SRC_FOLDER}/LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/licenses) -install(TARGETS ${PROJECT_NAME} -LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} -RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +include(GNUInstallDirs) +install(FILES ${LOGC_SRC_FOLDER}/src/log.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install( + TARGETS log.c + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/recipes/log.c/all/conandata.yml b/recipes/log.c/all/conandata.yml index 5ebc9981f11b4..e090a26f937d9 100644 --- a/recipes/log.c/all/conandata.yml +++ b/recipes/log.c/all/conandata.yml @@ -1,4 +1,4 @@ sources: "cci.20200620": url: "https://github.com/rxi/log.c/archive/f9ea34994bd58ed342d2245cd4110bb5c6790153.zip" - sha256: "402E2C64A9D659B76E7AE3B211061EEA0D6683ECECD7D8BB8B399E6795574A87" + sha256: "402e2c64a9d659b76e7ae3b211061eea0d6683ececd7d8bb8b399e6795574a87" diff --git a/recipes/log.c/all/conanfile.py b/recipes/log.c/all/conanfile.py index 63b526356d185..498417347ac71 100644 --- a/recipes/log.c/all/conanfile.py +++ b/recipes/log.c/all/conanfile.py @@ -1,65 +1,71 @@ -from conans import ConanFile, CMake, tools -import glob +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os +required_conan_version = ">=1.46.0" -class logcConan(ConanFile): + +class LogcConan(ConanFile): name = "log.c" license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/rxi/log.c" description = "A simple logging library implemented in C99" - topics = ("logging", "log", "logging-library", "conan", "logc", "purec", "c99") - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], - "fPIC": [True, False], - "color": [True, False]} - default_options = {"shared": False, - "fPIC": True, - "color": True} - generators = "cmake" - exports_sources = ["CMakeLists.txt", - "patches/*"] + topics = ("logging", "log", "logging-library", "logc", "purec", "c99") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "color": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "color": True, + } - _cmake = None + exports_sources = "CMakeLists.txt" - @property - def _source_subfolder(self): - return "source_subfolder" + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass - @property - def _build_subfolder(self): - return "build_subfolder" + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - tools.rename(glob.glob(self.name + "-*/")[0], self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["COLOR"] = self.options.color - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LOGC_SRC_FOLDER"] = self.source_folder.replace("\\", "/") + tc.variables["LOGC_USE_COLOR"] = self.options.color + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - def configure(self): - if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx - + self.cpp_info.libs = ["log.c"] diff --git a/recipes/log.c/all/test_package/CMakeLists.txt b/recipes/log.c/all/test_package/CMakeLists.txt index d8b7434906ab9..90cb2b629055b 100644 --- a/recipes/log.c/all/test_package/CMakeLists.txt +++ b/recipes/log.c/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_executable(${PROJECT_NAME} example.c) - -conan_target_link_libraries(${PROJECT_NAME}) +find_package(log.c REQUIRED CONFIG) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE log.c::log.c) diff --git a/recipes/log.c/all/test_package/conanfile.py b/recipes/log.c/all/test_package/conanfile.py index 4ed0c15a7b490..3a8c6c5442b33 100644 --- a/recipes/log.c/all/test_package/conanfile.py +++ b/recipes/log.c/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -class LogCTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/log.c/all/test_package/example.c b/recipes/log.c/all/test_package/example.c deleted file mode 100644 index be6a2ce57b5a6..0000000000000 --- a/recipes/log.c/all/test_package/example.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main() { - log_trace("Hello %s", "world"); - log_trace(log_level_string(0)); -} diff --git a/recipes/log.c/all/test_package/test_package.c b/recipes/log.c/all/test_package/test_package.c new file mode 100644 index 0000000000000..689ad5dd75b23 --- /dev/null +++ b/recipes/log.c/all/test_package/test_package.c @@ -0,0 +1,7 @@ +#include + +int main() { + log_trace("Hello %s", "world"); + log_trace(log_level_string(0)); + return 0; +} diff --git a/recipes/log.c/all/test_v1_package/CMakeLists.txt b/recipes/log.c/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..89149a107c10c --- /dev/null +++ b/recipes/log.c/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(log.c REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE log.c::log.c) diff --git a/recipes/log.c/all/test_v1_package/conanfile.py b/recipes/log.c/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/log.c/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/log4cplus/all/conandata.yml b/recipes/log4cplus/all/conandata.yml index 61ca319d9f160..38211284d2331 100644 --- a/recipes/log4cplus/all/conandata.yml +++ b/recipes/log4cplus/all/conandata.yml @@ -5,3 +5,9 @@ sources: "2.0.5": url: "https://github.com/log4cplus/log4cplus/releases/download/REL_2_0_5/log4cplus-2.0.5.tar.bz2" sha256: "b38dbfc68ef6d771e4de7de0be3544bc51bd3f7d5b75c5f6500d10e23203eb15" + "2.0.6": + url: "https://github.com/log4cplus/log4cplus/releases/download/REL_2_0_6/log4cplus-2.0.6.tar.bz2" + sha256: "1a963afd0f883d62de946b18927d238051fd47936e415eabeffe2b1397f16eca" + "2.0.7": + url: "https://github.com/log4cplus/log4cplus/releases/download/REL_2_0_7/log4cplus-2.0.7.tar.bz2" + sha256: "8fadbafee2ba4e558a0f78842613c9fb239c775d83f23340d091084c0e1b12ab" diff --git a/recipes/log4cplus/all/conanfile.py b/recipes/log4cplus/all/conanfile.py index a696aa65c1acc..aa98e3e12c8fe 100644 --- a/recipes/log4cplus/all/conanfile.py +++ b/recipes/log4cplus/all/conanfile.py @@ -1,13 +1,16 @@ import os +from conan.tools import files from conans import ConanFile, CMake, tools +required_conan_version = ">=1.35.0" + class Log4cplusConan(ConanFile): name = "log4cplus" description = "simple to use C++ logging API, modelled after the Java log4j API" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/log4cplus/log4cplus" - topics = ("conan", "log4cplus", "logging", "log", "logging-library") + topics = ("log4cplus", "logging", "log", "logging-library") license = ("BSD-2-Clause, Apache-2.0") exports_sources = ["CMakeLists.txt"] generators = "cmake" @@ -20,7 +23,8 @@ class Log4cplusConan(ConanFile): "working_locale": [True, False], "working_c_locale": [True, False], "decorated_name": [True, False], - "unicode": [True, False]} + "unicode": [True, False], + "thread_pool": [True, False]} default_options = {"shared": False, "fPIC": True, "single_threaded": False, @@ -29,7 +33,8 @@ class Log4cplusConan(ConanFile): "working_locale": False, "working_c_locale": False, "decorated_name": False, - "unicode": True} + "unicode": True, + "thread_pool": True} short_paths = True _cmake = None @@ -57,14 +62,14 @@ def requirements(self): self.requires("libiconv/1.16") def source(self): - archive_name = self.name + "-" + self.version - tools.get(**self.conan_data["sources"][self.version]) - os.rename(archive_name, self._source_subfolder) + files.get(self, **self.conan_data["sources"][self.version], strip_root=True, + destination=self._source_subfolder) def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) + self._cmake.definitions["LOG4CPLUS_ENABLE_THREAD_POOL"] = self.options.thread_pool self._cmake.definitions["UNICODE"] = self.options.unicode self._cmake.definitions["LOG4CPLUS_BUILD_TESTING"] = False self._cmake.definitions["WITH_UNIT_TESTS"] = False @@ -93,15 +98,15 @@ def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + files.rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): self.cpp_info.libs = tools.collect_libs(self) if self.options.unicode: self.cpp_info.defines = ["UNICODE", "_UNICODE"] if self.settings.os == "Linux": - self.cpp_info.system_libs = ["dl"] + self.cpp_info.system_libs = ["dl", "m", "rt", "nsl"] if not self.options.single_threaded: self.cpp_info.system_libs.append("pthread") elif self.settings.os == "Windows": - self.cpp_info.system_libs = ["advapi32", "Ws2_32"] + self.cpp_info.system_libs = ["advapi32", "ws2_32"] diff --git a/recipes/log4cplus/config.yml b/recipes/log4cplus/config.yml index ca82c02d2fda5..53f3c9cf0f166 100644 --- a/recipes/log4cplus/config.yml +++ b/recipes/log4cplus/config.yml @@ -3,3 +3,7 @@ versions: folder: all "2.0.5": folder: all + "2.0.6": + folder: all + "2.0.7": + folder: all diff --git a/recipes/log4cxx/all/CMakeLists.txt b/recipes/log4cxx/all/CMakeLists.txt new file mode 100644 index 0000000000000..b83949de59dc5 --- /dev/null +++ b/recipes/log4cxx/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.13) +project(cmake_wrapper CXX) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/log4cxx/all/conandata.yml b/recipes/log4cxx/all/conandata.yml new file mode 100644 index 0000000000000..4d9c222f7d839 --- /dev/null +++ b/recipes/log4cxx/all/conandata.yml @@ -0,0 +1,14 @@ +sources: + "0.12.1": + url: "https://archive.apache.org/dist/logging/log4cxx/0.12.1/apache-log4cxx-0.12.1.tar.gz" + sha256: "7bea5cb477f0e31c838f0e1f4f498cc3b30c2eae74703ddda923e7e8c2268d22" + "0.12.0": + url: "https://archive.apache.org/dist/logging/log4cxx/0.12.0/apache-log4cxx-0.12.0.tar.gz" + sha256: "bd5b5009ca914c8fa7944b92ea6b4ca6fb7d146f65d526f21bf8b3c6a0520e44" +patches: + "0.12.1": + - base_path: "source_subfolder" + patch_file: "patches/0001-find-apr.patch" + "0.12.0": + - base_path: "source_subfolder" + patch_file: "patches/0001-find-apr.patch" diff --git a/recipes/log4cxx/all/conanfile.py b/recipes/log4cxx/all/conanfile.py new file mode 100644 index 0000000000000..ac48eb45fc460 --- /dev/null +++ b/recipes/log4cxx/all/conanfile.py @@ -0,0 +1,149 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os +import textwrap + +required_conan_version = ">=1.43.0" + + +class Log4cxxConan(ConanFile): + name = "log4cxx" + description = "Logging framework for C++ patterned after Apache log4j" + url = "https://github.com/conan-io/conan-center-index" + license = "Apache-2.0" + homepage = "https://logging.apache.org/log4cxx" + topics = ("logging", "log") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "cmake", "cmake_find_package", "pkg_config" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("apr/1.7.0") + self.requires("apr-util/1.6.1") + self.requires("expat/2.4.2") + if self.settings.os != "Windows": + self.requires("odbc/2.3.9") + + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "15", + "clang": "5", + "apple-clang": "10", + } + + def validate(self): + # TODO: if compiler doesn't support C++17, boost can be used instead + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "17") + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if not minimum_version: + self.output.warn("log4cxx requires C++17. Your compiler is unknown. Assuming it supports C++17.") + elif tools.Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration("log4cxx requires a compiler that supports at least C++17") + + def build_requirements(self): + if self.settings.os != "Windows": + self.build_requires("pkgconf/1.7.4") + + def source(self): + #OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: + #'source_subfolder\\src\\test\\resources\\output\\xyz\\:' + pattern = "*[!:]" + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True, + pattern=pattern) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def _configure_cmake(self): + if not self._cmake: + self._cmake = CMake(self) + self._cmake.definitions["BUILD_TESTING"] = False + if self.settings.os == "Windows": + self._cmake.definitions["LOG4CXX_INSTALL_PDB"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + self.copy("NOTICE", src=self._source_subfolder, dst="licenses") + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"log4cxx": "log4cxx::log4cxx"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "log4cxx") + self.cpp_info.set_property("cmake_target_name", "log4cxx") + self.cpp_info.set_property("pkg_config_name", "liblog4cxx") + if not self.options.shared: + self.cpp_info.defines = ["LOG4CXX_STATIC"] + self.cpp_info.libs = ["log4cxx"] + if self.settings.os == "Windows": + self.cpp_info.system_libs = ["odbc32"] + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.names["pkg_config"] = "liblog4cxx" diff --git a/recipes/log4cxx/all/patches/0001-find-apr.patch b/recipes/log4cxx/all/patches/0001-find-apr.patch new file mode 100644 index 0000000000000..11635d23e734f --- /dev/null +++ b/recipes/log4cxx/all/patches/0001-find-apr.patch @@ -0,0 +1,17 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -25,10 +25,12 @@ if(NOT BUILD_SHARED_LIBS) + endif() + + # Find Apache Runtime +-find_package(APR REQUIRED) ++find_package(apr REQUIRED) ++set(APR_LIBRARIES apr::apr) + + # Find Apache Runtime Utilities +-find_package(APR-Util REQUIRED) ++find_package(apr-util REQUIRED) ++set(APR_UTIL_LIBRARIES apr-util::apr-util) + + find_package( Threads REQUIRED ) + diff --git a/recipes/log4cxx/all/test_package/CMakeLists.txt b/recipes/log4cxx/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..4b7ef0dd16dbb --- /dev/null +++ b/recipes/log4cxx/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(log4cxx REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} log4cxx) +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) diff --git a/recipes/log4cxx/all/test_package/conanfile.py b/recipes/log4cxx/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0aa45c8d4db18 --- /dev/null +++ b/recipes/log4cxx/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + config_xml_name = os.path.join(self.source_folder, "log4cxx_config.xml") + bin_path = os.path.join("bin", "test_package") + self.run("{} {}".format(bin_path, config_xml_name), run_environment=True) diff --git a/recipes/log4cxx/all/test_package/log4cxx_config.xml b/recipes/log4cxx/all/test_package/log4cxx_config.xml new file mode 100644 index 0000000000000..4269f78dd989e --- /dev/null +++ b/recipes/log4cxx/all/test_package/log4cxx_config.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/recipes/log4cxx/all/test_package/test_package.cpp b/recipes/log4cxx/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4e52b04611957 --- /dev/null +++ b/recipes/log4cxx/all/test_package/test_package.cpp @@ -0,0 +1,20 @@ +#include "log4cxx/logger.h" +#include "log4cxx/xml/domconfigurator.h" + +#include + +using namespace log4cxx; +using namespace log4cxx::xml; + +int main(int argc, const char* argv[]) +{ + LoggerPtr logger(Logger::getLogger("TEST")); + if (argc < 2) { + std::cerr << "Expected path to config xml\n"; + return -1; + } + DOMConfigurator::configure(argv[1]); + LOG4CXX_INFO(logger, "App started!"); + LOG4CXX_ERROR(logger, "Some error!"); + return 0; +} diff --git a/recipes/log4cxx/config.yml b/recipes/log4cxx/config.yml new file mode 100644 index 0000000000000..f5578f6ffba14 --- /dev/null +++ b/recipes/log4cxx/config.yml @@ -0,0 +1,5 @@ +versions: + "0.12.1": + folder: all + "0.12.0": + folder: all diff --git a/recipes/logr/all/conandata.yml b/recipes/logr/all/conandata.yml index 745bf730a1f28..9076e1decadad 100644 --- a/recipes/logr/all/conandata.yml +++ b/recipes/logr/all/conandata.yml @@ -2,3 +2,15 @@ sources: "0.2.0": url: "https://github.com/ngrodzitski/logr/archive/v0.2.0.tar.gz" sha256: "4e1707f9450f12b0752d8ef4d72a3f38a2e6be0014ca7edde049f22e9b9119a4" + "0.2.1": + url: "https://github.com/ngrodzitski/logr/archive/v0.2.1.tar.gz" + sha256: "411282bb03d678d7266951b979102392dbf7e5e14b629bccfb2c4e74cfa758c6" + "0.3.0": + url: "https://github.com/ngrodzitski/logr/archive/v0.3.0.tar.gz" + sha256: "21eea6cce32e3ccf3769f66211143b17f8b36891e79ec3ef5209f849d9e79ad7" + "0.4.0": + url: "https://github.com/ngrodzitski/logr/archive/v0.4.0.tar.gz" + sha256: "c355aa455d0a9c6d1d3bc168a2db0cd7f3c9706b382088e96948ec3a4cf1286f" + "0.5.1": + url: "https://github.com/ngrodzitski/logr/archive/v0.5.1.tar.gz" + sha256: "674be6a53d5b3f40273b1b5710ac9e32d870827032b5008c41621db47f4b3b0e" diff --git a/recipes/logr/all/conanfile.py b/recipes/logr/all/conanfile.py index bc8af8cf4851e..ee7363a51c446 100644 --- a/recipes/logr/all/conanfile.py +++ b/recipes/logr/all/conanfile.py @@ -2,19 +2,23 @@ from conans.errors import ConanInvalidConfiguration import os + class LogrConan(ConanFile): name = "logr" license = "BSD-3-Clause" homepage = "https://github.com/ngrodzitski/logr" url = "https://github.com/conan-io/conan-center-index" - description = "Logger frontend substitution for spdlog, glog, etc for server/desktop applications" + description = ( + "Logger frontend substitution for spdlog, glog, etc " + "for server/desktop applications" + ) topics = ("logger", "development", "util", "utils") generators = "cmake" settings = "os", "compiler", "build_type", "arch" no_copy_source = True - options = { "backend": ["spdlog", "glog", "log4cplus", None] } - default_options = { "backend": "spdlog"} + options = {"backend": ["spdlog", "glog", "log4cplus", "boostlog", None]} + default_options = {"backend": "spdlog"} _cmake = None @@ -27,14 +31,16 @@ def _build_subfolder(self): return "build_subfolder" def requirements(self): - self.requires("fmt/7.1.2") + self.requires("fmt/8.1.1") if self.options.backend == "spdlog": - self.requires("spdlog/1.8.2") + self.requires("spdlog/1.9.2") elif self.options.backend == "glog": - self.requires("glog/0.4.0") + self.requires("glog/0.5.0") elif self.options.backend == "log4cplus": self.requires("log4cplus/2.0.5") + elif self.options.backend == "boostlog": + self.requires("boost/1.77.0") def configure(self): minimal_cpp_standard = "17" @@ -44,29 +50,47 @@ def configure(self): "gcc": "7", "clang": "7", "apple-clang": "10", - "Visual Studio": "16" + "Visual Studio": "16", } compiler = str(self.settings.compiler) if compiler not in minimal_version: self.output.warn( - "%s recipe lacks information about the %s compiler standard version support" % (self.name, compiler)) + ( + "%s recipe lacks information about the %s compiler " + "standard version support" + ) + % (self.name, compiler) + ) self.output.warn( - "%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) + "%s requires a compiler that supports at least C++%s" + % (self.name, minimal_cpp_standard) + ) return version = tools.Version(self.settings.compiler.version) if version < minimal_version[compiler]: - raise ConanInvalidConfiguration("%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) - + raise ConanInvalidConfiguration( + "%s requires a compiler that supports at least C++%s" + % (self.name, minimal_cpp_standard) + ) def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - self._cmake.definitions["LOGR_WITH_SPDLOG_BACKEND"] = self.options.backend == "spdlog" - self._cmake.definitions["LOGR_WITH_GLOG_BACKEND"] = self.options.backend == "glog" - self._cmake.definitions["LOGR_WITH_LOG4CPLUS_BACKEND"] = self.options.backend == "log4cplus" + self._cmake.definitions["LOGR_WITH_SPDLOG_BACKEND"] = ( + self.options.backend == "spdlog" + ) + self._cmake.definitions["LOGR_WITH_GLOG_BACKEND"] = ( + self.options.backend == "glog" + ) + self._cmake.definitions["LOGR_WITH_LOG4CPLUS_BACKEND"] = ( + self.options.backend == "log4cplus" + ) + self._cmake.definitions["LOGR_WITH_BOOSTLOG_BACKEND"] = ( + self.options.backend == "boostlog" + ) self._cmake.definitions["LOGR_INSTALL"] = True self._cmake.definitions["LOGR_CONAN_PACKAGING"] = True @@ -95,3 +119,31 @@ def package_id(self): def package_info(self): self.cpp_info.names["cmake_find_package"] = "logr" self.cpp_info.names["cmake_find_package_multi"] = "logr" + + self.cpp_info.components["logr_base"].includedirs = ["include"] + self.cpp_info.components["logr_base"].requires = ["fmt::fmt"] + + if self.options.backend == "spdlog": + self.cpp_info.components["logr_spdlog"].includedirs = [] + self.cpp_info.components["logr_spdlog"].requires = [ + "logr_base", + "spdlog::spdlog", + ] + elif self.options.backend == "glog": + self.cpp_info.components["logr_glog"].includedirs = [] + self.cpp_info.components["logr_glog"].requires = [ + "logr_base", + "glog::glog", + ] + elif self.options.backend == "log4cplus": + self.cpp_info.components["logr_log4cplus"].includedirs = [] + self.cpp_info.components["logr_log4cplus"].requires = [ + "logr_base", + "log4cplus::log4cplus", + ] + elif self.options.backend == "boostlog": + self.cpp_info.components["logr_boostlog"].includedirs = [] + self.cpp_info.components["logr_boostlog"].requires = [ + "logr_base", + "boost::log", + ] diff --git a/recipes/logr/config.yml b/recipes/logr/config.yml index 022c65dafb315..c1a11eb732221 100644 --- a/recipes/logr/config.yml +++ b/recipes/logr/config.yml @@ -3,3 +3,11 @@ versions: folder: 0.1.0 "0.2.0": folder: all + "0.2.1": + folder: all + "0.3.0": + folder: all + "0.4.0": + folder: all + "0.5.1": + folder: all diff --git a/recipes/lua/all/conandata.yml b/recipes/lua/all/conandata.yml index ff96b08396f44..b67859f85a77d 100644 --- a/recipes/lua/all/conandata.yml +++ b/recipes/lua/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "5.4.4": + url: "https://www.lua.org/ftp/lua-5.4.4.tar.gz" + sha256: "164c7849653b80ae67bec4b7473b884bf5cc8d2dca05653475ec2ed27b9ebf61" + "5.4.3": + url: "https://www.lua.org/ftp/lua-5.4.3.tar.gz" + sha256: "f8612276169e3bfcbcfb8f226195bfc6e466fe13042f1076cbde92b7ec96bbfb" "5.4.1": url: "https://www.lua.org/ftp/lua-5.4.1.tar.gz" sha256: "4ba786c3705eb9db6567af29c91a01b81f1c0ac3124fdbf6cd94bdd9e53cca7d" diff --git a/recipes/lua/all/conanfile.py b/recipes/lua/all/conanfile.py index b14aa873c801d..0d101409713b8 100644 --- a/recipes/lua/all/conanfile.py +++ b/recipes/lua/all/conanfile.py @@ -1,16 +1,17 @@ from conans import ConanFile, CMake, tools import os +required_conan_version = ">=1.33.0" + class LuaConan(ConanFile): name = "lua" description = "Lua is a powerful, efficient, lightweight, embeddable scripting language." url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.lua.org/" - topics = ("conan", "lua", "scripting") + topics = ("lua", "scripting") license = "MIT" generators = "cmake" settings = "os", "compiler", "arch", "build_type" - exports_sources = ["CMakeLists.txt", "patches/**"] options = {"shared": [False, True], "fPIC": [True, False], "compile_as_cpp": [True, False]} default_options = {"shared": False, "fPIC": True, "compile_as_cpp": False} @@ -20,6 +21,11 @@ class LuaConan(ConanFile): def _source_subfolder(self): return "source_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -32,9 +38,8 @@ def configure(self): del self.settings.compiler.cppstd def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "lua-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -62,9 +67,9 @@ def package(self): def package_info(self): self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["dl", "m"] - if self.settings.os in ["Linux", "Macos"]: + if self.settings.os in ["Linux", "FreeBSD", "Macos"]: self.cpp_info.defines.extend(["LUA_USE_DLOPEN", "LUA_USE_POSIX"]) elif self.settings.os == "Windows" and self.options.shared: self.cpp_info.defines.append("LUA_BUILD_AS_DLL") diff --git a/recipes/lua/all/test_package/CMakeLists.txt b/recipes/lua/all/test_package/CMakeLists.txt index 448636b3b2435..1b7dae43e2bfc 100644 --- a/recipes/lua/all/test_package/CMakeLists.txt +++ b/recipes/lua/all/test_package/CMakeLists.txt @@ -2,10 +2,12 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(lua REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} lua::lua) if(COMPILE_AS_CPP) target_compile_definitions(${PROJECT_NAME} PRIVATE COMPILE_AS_CPP) endif() diff --git a/recipes/lua/all/test_package/conanfile.py b/recipes/lua/all/test_package/conanfile.py index 57b4c8e06aac9..df7c8083a43c2 100644 --- a/recipes/lua/all/test_package/conanfile.py +++ b/recipes/lua/all/test_package/conanfile.py @@ -4,7 +4,7 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -15,6 +15,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/lua/config.yml b/recipes/lua/config.yml index a30115781628c..9070b63a4816a 100644 --- a/recipes/lua/config.yml +++ b/recipes/lua/config.yml @@ -1,4 +1,8 @@ versions: + "5.4.4": + folder: all + "5.4.3": + folder: all "5.4.1": folder: all "5.3.5": diff --git a/recipes/luau/all/CMakeLists.txt b/recipes/luau/all/CMakeLists.txt new file mode 100644 index 0000000000000..b7e55166bfcf9 --- /dev/null +++ b/recipes/luau/all/CMakeLists.txt @@ -0,0 +1,96 @@ +cmake_minimum_required(VERSION 3.8) +project(conan_wrapper LANGUAGES CXX) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + +add_subdirectory(${LUAU_SRC_DIR}) + +## installer +include(GNUInstallDirs) + +install( + TARGETS Luau.Ast + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install(DIRECTORY "${LUAU_SRC_DIR}/Ast/include/Luau" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + +install( + TARGETS Luau.Compiler + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) +install(DIRECTORY "${LUAU_SRC_DIR}/Compiler/include/Luau" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") +install(FILES + "${LUAU_SRC_DIR}/Compiler/include/luacode.h" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + +install( + TARGETS Luau.CodeGen + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install(DIRECTORY "${LUAU_SRC_DIR}/CodeGen/include/Luau" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + + +install( + TARGETS Luau.Analysis + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) +install(DIRECTORY "${LUAU_SRC_DIR}/Analysis/include/Luau" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + +install( + TARGETS Luau.VM + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) +install(FILES + "${LUAU_SRC_DIR}/VM/include/lua.h" + "${LUAU_SRC_DIR}/VM/include/luaconf.h" + "${LUAU_SRC_DIR}/VM/include/lualib.h" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + +if(LUAU_BUILD_CLI) + install( + TARGETS Luau.Repl.CLI + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) + + install( + TARGETS Luau.Analyze.CLI + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) + + install( + TARGETS Luau.Ast.CLI + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) +endif() + +if(LUAU_BUILD_WEB) + install( + TARGETS Luau.Web + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) +endif() diff --git a/recipes/luau/all/conandata.yml b/recipes/luau/all/conandata.yml new file mode 100644 index 0000000000000..4afd6c2c668c4 --- /dev/null +++ b/recipes/luau/all/conandata.yml @@ -0,0 +1,93 @@ +sources: + "0.556": + url: "https://github.com/Roblox/luau/archive/0.556.tar.gz" + sha256: "dc72f91f4e866a2b25f7608e062c91c84e92a2e5611026e9789f127c3caf39f6" + "0.552": + url: "https://github.com/Roblox/luau/archive/0.552.tar.gz" + sha256: "c638aee88010197d7e6f22e592fa12360e38a69f54ed91980b11ac0f89676db5" + "0.548": + url: "https://github.com/Roblox/luau/archive/0.548.tar.gz" + sha256: "1ec0aa919955aaa2d88dbef115801681d3b4dbfa7a276435a03d20230918659c" + "0.544": + url: "https://github.com/Roblox/luau/archive/0.544.tar.gz" + sha256: "c1e2d4e04fe6f191192d1570bd83f96531804fc484a0bc0e00b53248a01d7dee" + "0.541": + url: "https://github.com/Roblox/luau/archive/0.541.tar.gz" + sha256: "02d50b8c0396a353ed641a61959851d6858607d535ed7373478b8fbc2a508eba" + "0.540": + url: "https://github.com/Roblox/luau/archive/0.540.tar.gz" + sha256: "84b3e52b3b0ccf4d5bc0e0c04055f3a9b2f045c1281e203a858335a6fe76b0ff" + "0.539": + url: "https://github.com/Roblox/luau/archive/0.539.tar.gz" + sha256: "d0a33bbafc88d6d89f23e43229e523b117cd761f1fdbd86977800b5725cc647f" + "0.538": + url: "https://github.com/Roblox/luau/archive/0.538.tar.gz" + sha256: "8a1240e02a7daacf1e5cff249040a3298c013157fc496c66adce6dcb21cc30be" + "0.537": + url: "https://github.com/Roblox/luau/archive/0.537.tar.gz" + sha256: "24122d3192083b2133de47d8039fb744b8007c6667fc1b6f254a2a8d72e15d53" + +patches: + "0.556": + - patch_file: "patches/0.552-0001-fix-cmake.patch" + patch_description: "enable shared build" + patch_type: "portability" + - patch_file: "patches/0.536-0002-rename-lerp.patch" + patch_description: "rename lerp function to avoid name conflict" + patch_type: "portability" + "0.552": + - patch_file: "patches/0.552-0001-fix-cmake.patch" + patch_description: "enable shared build" + patch_type: "portability" + - patch_file: "patches/0.536-0002-rename-lerp.patch" + patch_description: "rename lerp function to avoid name conflict" + patch_type: "portability" + "0.548": + - patch_file: "patches/0.536-0001-fix-cmake.patch" + patch_description: "enable shared build" + patch_type: "portability" + - patch_file: "patches/0.536-0002-rename-lerp.patch" + patch_description: "rename lerp function to avoid name conflict" + patch_type: "portability" + "0.544": + - patch_file: "patches/0.536-0001-fix-cmake.patch" + patch_description: "enable shared build" + patch_type: "portability" + - patch_file: "patches/0.536-0002-rename-lerp.patch" + patch_description: "rename lerp function to avoid name conflict" + patch_type: "portability" + "0.541": + - patch_file: "patches/0.536-0001-fix-cmake.patch" + patch_description: "enable shared build" + patch_type: "portability" + - patch_file: "patches/0.536-0002-rename-lerp.patch" + patch_description: "rename lerp function to avoid name conflict" + patch_type: "portability" + "0.540": + - patch_file: "patches/0.536-0001-fix-cmake.patch" + patch_description: "enable shared build" + patch_type: "portability" + - patch_file: "patches/0.536-0002-rename-lerp.patch" + patch_description: "rename lerp function to avoid name conflict" + patch_type: "portability" + "0.539": + - patch_file: "patches/0.536-0001-fix-cmake.patch" + patch_description: "enable shared build" + patch_type: "portability" + - patch_file: "patches/0.536-0002-rename-lerp.patch" + patch_description: "rename lerp function to avoid name conflict" + patch_type: "portability" + "0.538": + - patch_file: "patches/0.536-0001-fix-cmake.patch" + patch_description: "enable shared build" + patch_type: "portability" + - patch_file: "patches/0.536-0002-rename-lerp.patch" + patch_description: "rename lerp function to avoid name conflict" + patch_type: "portability" + "0.537": + - patch_file: "patches/0.536-0001-fix-cmake.patch" + patch_description: "enable shared build" + patch_type: "portability" + - patch_file: "patches/0.536-0002-rename-lerp.patch" + patch_description: "rename lerp function to avoid name conflict" + patch_type: "portability" diff --git a/recipes/luau/all/conanfile.py b/recipes/luau/all/conanfile.py new file mode 100644 index 0000000000000..6545f6caa610f --- /dev/null +++ b/recipes/luau/all/conanfile.py @@ -0,0 +1,154 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, replace_in_file +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.52.0" + +class LuauConan(ConanFile): + name = "luau" + description = "A fast, small, safe, gradually typed embeddable scripting language derived from Lua" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://luau-lang.org/" + topics = ("lua", "scripting", "typed", "embed") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [False, True], + "fPIC": [True, False], + "with_cli": [True, False], + "with_web": [True, False], + "native_code_gen": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_cli": False, + "with_web": False, + "native_code_gen": False, + } + + @property + def _minimum_cpp_standard(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8" if Version(self.version) < "0.549" else "9", + "clang": "7", + "apple-clang": "12", + } + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + if Version(self.version) < "0.549": + del self.options.native_code_gen + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + check_min_vs(self, 191) + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support." + ) + + if is_msvc(self) and self.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} does not support shared build in MSVC") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LUAU_BUILD_CLI"] = self.options.with_cli + tc.variables["LUAU_BUILD_TESTS"] = False + tc.variables["LUAU_BUILD_WEB"] = self.options.with_web + tc.variables["LUAU_WERROR"] = False + tc.variables["LUAU_STATIC_CRT"] = False + if Version(self.version) >= "0.549": + tc.variables["LUAU_NATIVE"] = self.options.native_code_gen + tc.variables["LUAU_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + if Version(self.version) >= "0.548" and self.options.shared: + replace_in_file(self, os.path.join(self.source_folder, "VM", "include", "luaconf.h"), + "#define LUAI_FUNC __attribute__((visibility(\"hidden\"))) extern", + "#define LUAI_FUNC extern") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "lua_LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Luau") + self.cpp_info.set_property("cmake_target_name", "Luau::Luau") + + self.cpp_info.filenames["cmake_find_package"] = "Luau" + self.cpp_info.filenames["cmake_find_package_multi"] = "Luau" + self.cpp_info.names["cmake_find_package_multi"] = "Luau" + self.cpp_info.names["cmake_find_package"] = "Luau" + + self.cpp_info.components["Ast"].libs = ["Luau.Ast"] + self.cpp_info.components["Ast"].set_property("cmake_target_name", "Luau::Ast") + + self.cpp_info.components["VM"].libs = ["Luau.VM"] + self.cpp_info.components["VM"].set_property("cmake_target_name", "Luau::VM") + self.cpp_info.components["VM"].requires = ["Ast"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["VM"].system_libs = ["m"] + + self.cpp_info.components["Analysis"].libs = ["Luau.Analysis"] + self.cpp_info.components["Analysis"].set_property("cmake_target_name", "Luau::Analysis") + self.cpp_info.components["Analysis"].requires = ["Ast"] + + self.cpp_info.components["Compiler"].libs = ["Luau.Compiler"] + self.cpp_info.components["Compiler"].set_property("cmake_target_name", "Luau::Compiler") + self.cpp_info.components["Compiler"].requires = ["Ast"] + + self.cpp_info.components["CodeGen"].libs = ["Luau.CodeGen"] + self.cpp_info.components["CodeGen"].set_property("cmake_target_name", "Luau::CodeGen") + self.cpp_info.components["CodeGen"].requires = ["Ast"] + if Version(self.version) >= "0.548": + self.cpp_info.components["CodeGen"].requires.append("VM") + + if self.options.with_cli: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH environment variable: {bin_path}") + self.env_info.PATH.append(bin_path) + + if self.options.with_web: + self.cpp_info.components["Web"].libs = ["Luau.Web"] + self.cpp_info.components["Web"].set_property("cmake_target_name", "Luau::Web") + self.cpp_info.components["Web"].requires = ["Compiler", "VM"] diff --git a/recipes/luau/all/patches/0.536-0001-fix-cmake.patch b/recipes/luau/all/patches/0.536-0001-fix-cmake.patch new file mode 100644 index 0000000000000..00dcf66617205 --- /dev/null +++ b/recipes/luau/all/patches/0.536-0001-fix-cmake.patch @@ -0,0 +1,23 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9200634..c1cca12 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -21,12 +21,12 @@ endif() + + project(Luau LANGUAGES CXX C) + add_library(Luau.Common INTERFACE) +-add_library(Luau.Ast STATIC) +-add_library(Luau.Compiler STATIC) +-add_library(Luau.Analysis STATIC) +-add_library(Luau.CodeGen STATIC) +-add_library(Luau.VM STATIC) +-add_library(isocline STATIC) ++add_library(Luau.Ast) ++add_library(Luau.Compiler) ++add_library(Luau.Analysis) ++add_library(Luau.CodeGen) ++add_library(Luau.VM) ++add_library(isocline) + + if(LUAU_BUILD_CLI) + add_executable(Luau.Repl.CLI) diff --git a/recipes/luau/all/patches/0.536-0002-rename-lerp.patch b/recipes/luau/all/patches/0.536-0002-rename-lerp.patch new file mode 100644 index 0000000000000..324b7d737bf16 --- /dev/null +++ b/recipes/luau/all/patches/0.536-0002-rename-lerp.patch @@ -0,0 +1,28 @@ +diff --git a/VM/src/lmathlib.cpp b/VM/src/lmathlib.cpp +index a6e7b49..7c3e3c6 100644 +--- a/VM/src/lmathlib.cpp ++++ b/VM/src/lmathlib.cpp +@@ -300,7 +300,7 @@ static float fade(float t) + return t * t * t * (t * (t * 6 - 15) + 10); + } + +-static float lerp(float t, float a, float b) ++static float lerp_l(float t, float a, float b) + { + return a + t * (b - a); + } +@@ -342,10 +342,10 @@ static float perlin(float x, float y, float z) + int ba = p[b] + zi; + int bb = p[b + 1] + zi; + +- return lerp(w, +- lerp(v, lerp(u, grad(p[aa], xf, yf, zf), grad(p[ba], xf - 1, yf, zf)), lerp(u, grad(p[ab], xf, yf - 1, zf), grad(p[bb], xf - 1, yf - 1, zf))), +- lerp(v, lerp(u, grad(p[aa + 1], xf, yf, zf - 1), grad(p[ba + 1], xf - 1, yf, zf - 1)), +- lerp(u, grad(p[ab + 1], xf, yf - 1, zf - 1), grad(p[bb + 1], xf - 1, yf - 1, zf - 1)))); ++ return lerp_l(w, ++ lerp_l(v, lerp_l(u, grad(p[aa], xf, yf, zf), grad(p[ba], xf - 1, yf, zf)), lerp_l(u, grad(p[ab], xf, yf - 1, zf), grad(p[bb], xf - 1, yf - 1, zf))), ++ lerp_l(v, lerp_l(u, grad(p[aa + 1], xf, yf, zf - 1), grad(p[ba + 1], xf - 1, yf, zf - 1)), ++ lerp_l(u, grad(p[ab + 1], xf, yf - 1, zf - 1), grad(p[bb + 1], xf - 1, yf - 1, zf - 1)))); + } + + static int math_noise(lua_State* L) diff --git a/recipes/luau/all/patches/0.552-0001-fix-cmake.patch b/recipes/luau/all/patches/0.552-0001-fix-cmake.patch new file mode 100644 index 0000000000000..aaff66adb45b9 --- /dev/null +++ b/recipes/luau/all/patches/0.552-0001-fix-cmake.patch @@ -0,0 +1,23 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 05d701e..4c73783 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -22,12 +22,12 @@ endif() + + project(Luau LANGUAGES CXX C) + add_library(Luau.Common INTERFACE) +-add_library(Luau.Ast STATIC) +-add_library(Luau.Compiler STATIC) +-add_library(Luau.Analysis STATIC) +-add_library(Luau.CodeGen STATIC) +-add_library(Luau.VM STATIC) +-add_library(isocline STATIC) ++add_library(Luau.Ast) ++add_library(Luau.Compiler) ++add_library(Luau.Analysis) ++add_library(Luau.CodeGen) ++add_library(Luau.VM) ++add_library(isocline) + + if(LUAU_BUILD_CLI) + add_executable(Luau.Repl.CLI) diff --git a/recipes/luau/all/test_package/CMakeLists.txt b/recipes/luau/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6f927f5fc234f --- /dev/null +++ b/recipes/luau/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(Luau REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Luau::Luau) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/luau/all/test_package/conanfile.py b/recipes/luau/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fbb7f543162 --- /dev/null +++ b/recipes/luau/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/luau/all/test_package/test_package.cpp b/recipes/luau/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7211862f8ded9 --- /dev/null +++ b/recipes/luau/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include "lua.h" +#include "lualib.h" + +#include + +int main(int argc, char* argv[]) { + lua_State* L = luaL_newstate(); + lua_close(L); + return 0; +} diff --git a/recipes/luau/all/test_v1_package/CMakeLists.txt b/recipes/luau/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..cbcc5c4d88390 --- /dev/null +++ b/recipes/luau/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Luau REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Luau::Luau) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/luau/all/test_v1_package/conanfile.py b/recipes/luau/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..81a08015e01f1 --- /dev/null +++ b/recipes/luau/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/luau/config.yml b/recipes/luau/config.yml new file mode 100644 index 0000000000000..2aa48d7676634 --- /dev/null +++ b/recipes/luau/config.yml @@ -0,0 +1,19 @@ +versions: + "0.556": + folder: all + "0.552": + folder: all + "0.548": + folder: all + "0.544": + folder: all + "0.541": + folder: all + "0.540": + folder: all + "0.539": + folder: all + "0.538": + folder: all + "0.537": + folder: all diff --git a/recipes/lunasvg/all/conandata.yml b/recipes/lunasvg/all/conandata.yml new file mode 100644 index 0000000000000..e504366930815 --- /dev/null +++ b/recipes/lunasvg/all/conandata.yml @@ -0,0 +1,31 @@ +sources: + "2.3.5": + url: "https://github.com/sammycage/lunasvg/archive/v2.3.5.tar.gz" + sha256: "350ff56aa1acdedefe2ad8a4241a9fb8f9b232868adc7bd36dfb3dbdd57e2e93" + "2.3.4": + url: "https://github.com/sammycage/lunasvg/archive/v2.3.4.tar.gz" + sha256: "1933bf3fcdec81a1c17702b3c6efb00b9e3380e3fcea508f4ee4b11b0d2e45c0" + "2.3.2": + url: "https://github.com/sammycage/lunasvg/archive/v2.3.2.tar.gz" + sha256: "12abe6865dd030adfac70c30592eaa25c4e34fa81379e5149b0186282721f40c" + "2.3.1": + url: "https://github.com/sammycage/lunasvg/archive/refs/tags/v2.3.1.tar.gz" + sha256: "6492bf0f51982f5382f83f1a42f247bb1bbcbaef4a15963bbd53073cd4944a25" + +patches: + "2.3.5": + - patch_file: "patches/2.3.5-0001-fix-cmake.patch" + patch_description: "use external plutovg and fix installation path for conan" + patch_type: "conan" + "2.3.4": + - patch_file: "patches/2.3.1-0001-fix-cmake.patch" + patch_description: "use external plutovg and fix installation path for conan" + patch_type: "conan" + "2.3.2": + - patch_file: "patches/2.3.1-0001-fix-cmake.patch" + patch_description: "use external plutovg and fix installation path for conan" + patch_type: "conan" + "2.3.1": + - patch_file: "patches/2.3.1-0001-fix-cmake.patch" + patch_description: "use external plutovg and fix installation path for conan" + patch_type: "conan" diff --git a/recipes/lunasvg/all/conanfile.py b/recipes/lunasvg/all/conanfile.py new file mode 100644 index 0000000000000..faebad4a7c975 --- /dev/null +++ b/recipes/lunasvg/all/conanfile.py @@ -0,0 +1,115 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.52.0" + +class LunaSVGConan(ConanFile): + name = "lunasvg" + description = "lunasvg is a standalone SVG rendering library in C++." + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/sammycage/lunasvg" + topics = ("svg", "renderer", ) + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _minimum_cpp_standard(self): + if Version(self.version) <= "2.3.2": + return 14 + else: + return 17 + + @property + def _compilers_minimum_version(self): + if Version(self.version) <= "2.3.2": + return { + "gcc": "5", + "clang": "3.5", + "apple-clang": "10" + } + else: + return { + "gcc": "7.1", + "clang": "7", + "apple-clang": "12.0" + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if Version(self.version) < "2.3.5": + self.requires("plutovg/cci.20220103") + else: + self.requires("plutovg/cci.20221030") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + if Version(self.version) <= "2.3.2": + check_min_vs(self, 191) + else: + check_min_vs(self, 192) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support." + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_SHARED_LIBS"] = self.options.shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.generate() + + tc = CMakeDeps(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["lunasvg"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["m"] diff --git a/recipes/lunasvg/all/patches/2.3.1-0001-fix-cmake.patch b/recipes/lunasvg/all/patches/2.3.1-0001-fix-cmake.patch new file mode 100644 index 0000000000000..3ad95c303fab0 --- /dev/null +++ b/recipes/lunasvg/all/patches/2.3.1-0001-fix-cmake.patch @@ -0,0 +1,36 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9916c67..6433f13 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -13,7 +13,9 @@ add_library(lunasvg) + add_subdirectory(include) + add_subdirectory(source) + add_subdirectory(3rdparty/software) +-add_subdirectory(3rdparty/plutovg) ++ ++find_package(plutovg CONFIG REQUIRED) ++target_link_libraries(lunasvg plutovg::plutovg) + + if(BUILD_SHARED_LIBS) + target_compile_definitions(lunasvg PUBLIC LUNASVG_SHARED) +@@ -24,16 +26,13 @@ if(LUNASVG_BUILD_EXAMPLES) + add_subdirectory(example) + endif() + +-set(LUNASVG_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib) +-set(LUNASVG_INCDIR ${CMAKE_INSTALL_PREFIX}/include) +- + install(FILES + include/lunasvg.h +- DESTINATION ${LUNASVG_INCDIR} ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) + + install(TARGETS lunasvg +- LIBRARY DESTINATION ${LUNASVG_LIBDIR} +- ARCHIVE DESTINATION ${LUNASVG_LIBDIR} +- INCLUDES DESTINATION ${LUNASVG_INCDIR} ++ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) diff --git a/recipes/lunasvg/all/patches/2.3.5-0001-fix-cmake.patch b/recipes/lunasvg/all/patches/2.3.5-0001-fix-cmake.patch new file mode 100644 index 0000000000000..4b6e4b7f0ffef --- /dev/null +++ b/recipes/lunasvg/all/patches/2.3.5-0001-fix-cmake.patch @@ -0,0 +1,36 @@ +diff --git a/a/CMakeLists.txt b/b/CMakeLists.txt +index b2f07dc..3c40ad5 100644 +--- a/a/CMakeLists.txt ++++ b/b/CMakeLists.txt +@@ -12,7 +12,9 @@ add_library(lunasvg) + + add_subdirectory(include) + add_subdirectory(source) +-add_subdirectory(3rdparty/plutovg) ++ ++find_package(plutovg CONFIG REQUIRED) ++target_link_libraries(lunasvg plutovg::plutovg) + + if(BUILD_SHARED_LIBS) + target_compile_definitions(lunasvg PUBLIC LUNASVG_SHARED) +@@ -23,16 +25,13 @@ if(LUNASVG_BUILD_EXAMPLES) + add_subdirectory(example) + endif() + +-set(LUNASVG_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib) +-set(LUNASVG_INCDIR ${CMAKE_INSTALL_PREFIX}/include) +- + install(FILES + include/lunasvg.h +- DESTINATION ${LUNASVG_INCDIR} ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) + + install(TARGETS lunasvg +- LIBRARY DESTINATION ${LUNASVG_LIBDIR} +- ARCHIVE DESTINATION ${LUNASVG_LIBDIR} +- INCLUDES DESTINATION ${LUNASVG_INCDIR} ++ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) diff --git a/recipes/lunasvg/all/test_package/CMakeLists.txt b/recipes/lunasvg/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..1c8a5ea6697c7 --- /dev/null +++ b/recipes/lunasvg/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(lunasvg REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE lunasvg::lunasvg) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/lunasvg/all/test_package/conanfile.py b/recipes/lunasvg/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/lunasvg/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/lunasvg/all/test_package/test_package.cpp b/recipes/lunasvg/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..1e47dd43f1e9a --- /dev/null +++ b/recipes/lunasvg/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include "lunasvg.h" +#include + +int main() { + auto mat = lunasvg::Matrix(); + + std::cout << mat.a << " " << mat.b << " " << mat.c << " " << mat.d << " " << mat.e << " " << mat.f << std::endl; + + return 0; +} diff --git a/recipes/lunasvg/all/test_v1_package/CMakeLists.txt b/recipes/lunasvg/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..596ce1fb31ebb --- /dev/null +++ b/recipes/lunasvg/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(lunasvg REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE lunasvg::lunasvg) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/lunasvg/all/test_v1_package/conanfile.py b/recipes/lunasvg/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..81a08015e01f1 --- /dev/null +++ b/recipes/lunasvg/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lunasvg/config.yml b/recipes/lunasvg/config.yml new file mode 100644 index 0000000000000..d8c968c29bee6 --- /dev/null +++ b/recipes/lunasvg/config.yml @@ -0,0 +1,9 @@ +versions: + "2.3.5": + folder: all + "2.3.4": + folder: all + "2.3.2": + folder: all + "2.3.1": + folder: all diff --git a/recipes/luple/all/conanfile.py b/recipes/luple/all/conanfile.py index e4f4a3acdd2e6..9334773f3ff8a 100644 --- a/recipes/luple/all/conanfile.py +++ b/recipes/luple/all/conanfile.py @@ -1,8 +1,12 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, download, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" + class LupleConan(ConanFile): name = "luple" @@ -10,41 +14,58 @@ class LupleConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/alexpolt/luple" description = "Home to luple, nuple, C++ String Interning, Struct Reader and C++ Type Loophole" - topics = ("conan", "loophole", "luple", "nuple", "struct", "intern") - settings = "compiler" + topics = ("loophole", "luple", "nuple", "struct", "intern") + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - def validate(self): - minimal_cpp_standard = "14" - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, minimal_cpp_standard) - minimal_version = { + @property + def _min_cppstd(self): + return "14" + + @property + def _compilers_minimum_version(self): + return { "gcc": "5", "clang": "3.4", "apple-clang": "10", - "Visual Studio": "14" + "Visual Studio": "14", + "msvc": "190", } - compiler = str(self.settings.compiler) - if compiler not in minimal_version: - self.output.warn( - "%s recipe lacks information about the %s compiler standard version support" % (self.name, compiler)) - self.output.warn( - "%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) - return - version = tools.Version(self.settings.compiler.version) - if version < minimal_version[compiler]: - raise ConanInvalidConfiguration("%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.", + ) def source(self): - tools.get(**self.conan_data["sources"][self.version][0], strip_root=True) - tools.download(filename="LICENSE", **self.conan_data["sources"][self.version][1]) + get(self, **self.conan_data["sources"][self.version][0], + destination=self.source_folder, strip_root=True) + download(self, filename="LICENSE", **self.conan_data["sources"][self.version][1]) - def package(self): - self.copy("LICENSE", dst="licenses") - self.copy("*.h", dst="include") + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.bindirs = [] self.cpp_info.libdirs = [] diff --git a/recipes/luple/all/test_package/CMakeLists.txt b/recipes/luple/all/test_package/CMakeLists.txt index 3300ff7750277..b556daffe2a12 100644 --- a/recipes/luple/all/test_package/CMakeLists.txt +++ b/recipes/luple/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(luple REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +target_link_libraries(${PROJECT_NAME} PRIVATE luple::luple) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/luple/all/test_package/conanfile.py b/recipes/luple/all/test_package/conanfile.py index 1d0bdd3779793..0a6bc68712d90 100644 --- a/recipes/luple/all/test_package/conanfile.py +++ b/recipes/luple/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/luple/all/test_v1_package/CMakeLists.txt b/recipes/luple/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/luple/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/luple/all/test_v1_package/conanfile.py b/recipes/luple/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/luple/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lurlparser/all/CMakeLists.txt b/recipes/lurlparser/all/CMakeLists.txt new file mode 100644 index 0000000000000..e0daa695ec3ad --- /dev/null +++ b/recipes/lurlparser/all/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.8) +project(LUrlParser LANGUAGES CXX) + +add_library(lurlparser ${LURLPARSER_SRC_DIR}/LUrlParser.cpp) +target_include_directories(lurlparser PRIVATE ${LURLPARSER_SRC_DIR}) +target_compile_features(lurlparser PRIVATE cxx_std_11) +set_target_properties(lurlparser PROPERTIES + PUBLIC_HEADER ${LURLPARSER_SRC_DIR}/LUrlParser.h + CMAKE_CXX_STANDARD_REQUIRED ON + CMAKE_CXX_EXTENSIONS OFF + WINDOWS_EXPORT_ALL_SYMBOLS ON +) + +include(GNUInstallDirs) +install( + TARGETS lurlparser + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/lurlparser/all/conandata.yml b/recipes/lurlparser/all/conandata.yml new file mode 100644 index 0000000000000..5f5dd28919386 --- /dev/null +++ b/recipes/lurlparser/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.1": + url: "https://github.com/corporateshark/LUrlParser/archive/refs/tags/release-1.1.tar.gz" + sha256: "f697bf9151c78b5e54682ff8f1ff759b15c3cbe73b179576a921b526cdf9ff22" diff --git a/recipes/lurlparser/all/conanfile.py b/recipes/lurlparser/all/conanfile.py new file mode 100644 index 0000000000000..6469f5166a747 --- /dev/null +++ b/recipes/lurlparser/all/conanfile.py @@ -0,0 +1,73 @@ +from conan import ConanFile +from conan.tools.files import get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +import os + +required_conan_version = ">=1.50.0" + +class PackageConan(ConanFile): + name = "lurlparser" + description = "Lightweight URL & URI parser (RFC 1738, RFC 3986)" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/corporateshark/LUrlParser/" + topics = ("url", "uri", "parser") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _minimum_cpp_standard(self): + return 11 + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._minimum_cpp_standard) + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LURLPARSER_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, pattern="License.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["lurlparser"] + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/lurlparser/all/test_package/CMakeLists.txt b/recipes/lurlparser/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2160e23166fc3 --- /dev/null +++ b/recipes/lurlparser/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(lurlparser REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE lurlparser::lurlparser) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/lurlparser/all/test_package/conanfile.py b/recipes/lurlparser/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/lurlparser/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/lurlparser/all/test_package/test_package.cpp b/recipes/lurlparser/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..ef4db579b3178 --- /dev/null +++ b/recipes/lurlparser/all/test_package/test_package.cpp @@ -0,0 +1,20 @@ +#include + +#include "LUrlParser.h" + +int main() { + const auto URL = LUrlParser::ParseURL::parseURL("https://John:Dow@github.com:80/corporateshark/LUrlParser"); + + if (URL.isValid()) { + std::cout << "Scheme : " << URL.scheme_ << std::endl; + std::cout << "Host : " << URL.host_ << std::endl; + std::cout << "Port : " << URL.port_ << std::endl; + std::cout << "Path : " << URL.path_ << std::endl; + std::cout << "Query : " << URL.query_ << std::endl; + std::cout << "Fragment : " << URL.fragment_ << std::endl; + std::cout << "User name : " << URL.userName_ << std::endl; + std::cout << "Password : " << URL.password_ << std::endl; + } + + return 0; +} diff --git a/recipes/lurlparser/all/test_v1_package/CMakeLists.txt b/recipes/lurlparser/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..44cd3222ce1e5 --- /dev/null +++ b/recipes/lurlparser/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(lurlparser REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE lurlparser::lurlparser) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/lurlparser/all/test_v1_package/conanfile.py b/recipes/lurlparser/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/lurlparser/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lurlparser/config.yml b/recipes/lurlparser/config.yml new file mode 100644 index 0000000000000..3f8a45fae5832 --- /dev/null +++ b/recipes/lurlparser/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1": + folder: all diff --git a/recipes/lyra/all/conandata.yml b/recipes/lyra/all/conandata.yml index d9ca2367ecb62..f6627e78699fe 100644 --- a/recipes/lyra/all/conandata.yml +++ b/recipes/lyra/all/conandata.yml @@ -20,3 +20,9 @@ sources: "1.5.1": sha256: 11ccdfc6f776b9a2ebe987d9b4e492981f88f3642546fd1c2e1115741863cae0 url: https://github.com/bfgroup/Lyra/archive/1.5.1.tar.gz + "1.6.0": + sha256: 919e92a9c02fea3f365a3a7bdccd8b306311a28a7f2044dac8e7651106d7b644 + url: https://github.com/bfgroup/Lyra/archive/1.6.tar.gz + "1.6.1": + sha256: a93f247ed89eba11ca36eb24c4f8ba7be636bf24e74aaaa8e1066e0954bec7e3 + url: https://github.com/bfgroup/Lyra/archive/1.6.1.tar.gz diff --git a/recipes/lyra/all/conanfile.py b/recipes/lyra/all/conanfile.py index 457967987ada7..184573a6e3fe9 100644 --- a/recipes/lyra/all/conanfile.py +++ b/recipes/lyra/all/conanfile.py @@ -1,41 +1,56 @@ -from conans import ConanFile, tools import os +from conan import ConanFile +import conan.tools.files +import conan.tools.layout +import conan.tools.build + +required_conan_version = ">=1.50.0" -required_conan_version = ">=1.28.0" class LyraConan(ConanFile): name = "lyra" homepage = "https://bfgroup.github.io/Lyra/" description = "A simple to use, composing, header only, command line arguments parser for C++ 11 and beyond." - topics = ("conan", "cli", "c++11") + topics = ("cli", "cli-parser", "argparse", "commandline", + "flags", "header-only", "no-dependencies", "c++11") no_copy_source = True settings = "compiler" url = "https://github.com/conan-io/conan-center-index" license = "MIT" - @property - def _source_subfolder(self): - return "source_subfolder" - - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + conan.tools.build.check_min_cppstd(self, 11) def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + conan.tools.layout.basic_layout(self, src_folder="root") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "Lyra-" + \ - os.path.basename(self.conan_data["sources"][self.version]['url']).replace( - ".tar.gz", "") - os.rename(extracted_dir, self._source_subfolder) + conan.tools.files.get( + self, + **self.conan_data["sources"][self.version], + strip_root=True) def package(self): - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) - self.copy("*.h*", dst="include", src=os.path.join(self._source_subfolder, "include")) + conan.tools.files.copy( + self, "LICENSE.txt", + dst=os.path.join(self.package_folder, "licenses"), + src=self.source_folder) + conan.tools.files.copy( + self, "*.h*", + dst=os.path.join(self.package_folder, "include"), + src=os.path.join(self.source_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "lyra") + self.cpp_info.set_property("cmake_target_name", "bfg::lyra") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.components["_lyra"].set_property( + "cmake_target_name", "bfg::lyra") self.cpp_info.filenames["cmake_find_package"] = "lyra" self.cpp_info.filenames["cmake_find_package_multi"] = "lyra" self.cpp_info.names["cmake_find_package"] = "bfg" diff --git a/recipes/lyra/all/test_package/CMakeLists.txt b/recipes/lyra/all/test_package/CMakeLists.txt index b200e21129c40..294a9afb37677 100644 --- a/recipes/lyra/all/test_package/CMakeLists.txt +++ b/recipes/lyra/all/test_package/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.1) project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - find_package(lyra REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) diff --git a/recipes/lyra/all/test_package/conanfile.py b/recipes/lyra/all/test_package/conanfile.py index 7e2dfe859bb27..0b275b10a2f3c 100644 --- a/recipes/lyra/all/test_package/conanfile.py +++ b/recipes/lyra/all/test_package/conanfile.py @@ -1,17 +1,26 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +import conan.tools.build +import conan.tools.cmake import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + conan.tools.cmake.cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): - cmake = CMake(self) + cmake = conan.tools.cmake.CMake(self) cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if conan.tools.build.can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/lyra/all/test_v1_package/CMakeLists.txt b/recipes/lyra/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b200e21129c40 --- /dev/null +++ b/recipes/lyra/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(lyra REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} bfg::lyra) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/lyra/all/test_v1_package/conanfile.py b/recipes/lyra/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..49a3a66ea5bad --- /dev/null +++ b/recipes/lyra/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lyra/all/test_v1_package/test_package.cpp b/recipes/lyra/all/test_v1_package/test_package.cpp new file mode 100644 index 0000000000000..5298875e31c6a --- /dev/null +++ b/recipes/lyra/all/test_v1_package/test_package.cpp @@ -0,0 +1,6 @@ +#include + +int main(int argc, const char** argv) +{ + auto cli = lyra::cli_parser(); +} diff --git a/recipes/lyra/config.yml b/recipes/lyra/config.yml index 8ddd1b37638d6..425271e9a388e 100644 --- a/recipes/lyra/config.yml +++ b/recipes/lyra/config.yml @@ -13,3 +13,7 @@ versions: folder: all "1.5.1": folder: all + "1.6.0": + folder: all + "1.6.1": + folder: all diff --git a/recipes/lz4/all/CMakeLists.txt b/recipes/lz4/all/CMakeLists.txt deleted file mode 100644 index 1e409b84a1364..0000000000000 --- a/recipes/lz4/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(${CONAN_LZ4_CMAKELISTS_SUBFOLDER}) diff --git a/recipes/lz4/all/conandata.yml b/recipes/lz4/all/conandata.yml index 30cdbb5651b11..b795699823646 100644 --- a/recipes/lz4/all/conandata.yml +++ b/recipes/lz4/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.9.4": + sha256: 0b0e3aa07c8c063ddf40b082bdf7e37a1562bda40a0ff5272957f3e987e0e54b + url: https://github.com/lz4/lz4/archive/v1.9.4.tar.gz "1.9.3": sha256: 030644df4611007ff7dc962d981f390361e6c97a34e5cbc393ddfbe019ffe2c1 url: https://github.com/lz4/lz4/archive/v1.9.3.tar.gz @@ -6,8 +9,9 @@ sources: sha256: 658ba6191fa44c92280d4aa2c271b0f4fbc0e34d249578dd05e50e76d0e5efcc url: https://github.com/lz4/lz4/archive/v1.9.2.tar.gz patches: + "1.9.3": + - patch_file: "patches/0003-cmake-minimum-required-first-1.9.3.patch" "1.9.2": - patch_file: "patches/0001-cmake-add-shared-DEFINE_SYMBOL.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-cmake-optional-cli.patch" - base_path: "source_subfolder" + - patch_file: "patches/0003-cmake-minimum-required-first-1.9.2.patch" diff --git a/recipes/lz4/all/conanfile.py b/recipes/lz4/all/conanfile.py index 7248146a47b33..0f12071b01ef2 100644 --- a/recipes/lz4/all/conanfile.py +++ b/recipes/lz4/all/conanfile.py @@ -1,5 +1,12 @@ -from conans import CMake, ConanFile, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir, save +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os +import textwrap + +required_conan_version = ">=1.50.0" class LZ4Conan(ConanFile): @@ -8,18 +15,21 @@ class LZ4Conan(ConanFile): license = ("BSD-2-Clause", "BSD-3-Clause") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/lz4/lz4" - topics = ("conan", "lz4", "compression") - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + topics = ("lz4", "compression") - _cmake = None + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -28,50 +38,92 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "{0}-{1}".format(self.name, self.version) - os.rename(extracted_folder, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LZ4_BUILD_CLI"] = False + tc.variables["LZ4_BUILD_LEGACY_LZ4C"] = False + tc.variables["LZ4_BUNDLED_MODE"] = False + tc.variables["LZ4_POSITION_INDEPENDENT_LIB"] = self.options.get_safe("fPIC", True) + # Generate a relocatable shared lib on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + # Honor BUILD_SHARED_LIBS (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() @property - def _cmakelists_subfolder(self): - if tools.Version(self.version) < "1.9.3": + def _cmakelists_folder(self): + if Version(self.version) < "1.9.3": subfolder = os.path.join("contrib", "cmake_unofficial") else: subfolder = os.path.join("build", "cmake") - return os.path.join(self._source_subfolder, subfolder).replace("\\", "/") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CONAN_LZ4_CMAKELISTS_SUBFOLDER"] = self._cmakelists_subfolder - self._cmake.definitions["LZ4_BUILD_CLI"] = False - self._cmake.definitions["LZ4_BUILD_LEGACY_LZ4C"] = False - self._cmake.definitions["LZ4_BUNDLED_MODE"] = False - self._cmake.definitions["LZ4_POSITION_INDEPENDENT_LIB"] = self.options.get_safe("fPIC", True) - self._cmake.configure() - return self._cmake + return os.path.join(self.source_folder, subfolder) def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=self._cmakelists_folder) cmake.build() + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() + if Version(self.version) >= "1.9.4": + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + # TODO: to remove in conan v2 once legacy generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {self._lz4_target: "lz4::lz4"}, + ) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + @property + def _lz4_target(self): + return f"LZ4::{'lz4_shared' if self.options.shared else 'lz4_static'}" def package_info(self): - self.cpp_info.names["pkg_config"] = "liblz4" + self.cpp_info.set_property("cmake_file_name", "lz4") + self.cpp_info.set_property("cmake_target_name", self._lz4_target) + self.cpp_info.set_property("cmake_target_aliases", ["lz4::lz4"]) # old unofficial target in CCI for lz4, kept for the moment to not break consumers + self.cpp_info.set_property("pkg_config_name", "liblz4") self.cpp_info.libs = ["lz4"] - if self.settings.compiler == "Visual Studio" and self.options.shared: + if is_msvc(self) and self.options.shared: self.cpp_info.defines.append("LZ4_DLL_IMPORT=1") + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.names["pkg_config"] = "liblz4" diff --git a/recipes/lz4/all/patches/0003-cmake-minimum-required-first-1.9.2.patch b/recipes/lz4/all/patches/0003-cmake-minimum-required-first-1.9.2.patch new file mode 100644 index 0000000000000..2333a27871ed9 --- /dev/null +++ b/recipes/lz4/all/patches/0003-cmake-minimum-required-first-1.9.2.patch @@ -0,0 +1,25 @@ +--- a/contrib/cmake_unofficial/CMakeLists.txt ++++ b/contrib/cmake_unofficial/CMakeLists.txt +@@ -9,11 +9,10 @@ + # + # LZ4's CMake support is maintained by Evan Nemerson; when filing + # bugs please mention @nemequ to make sure I see it. ++cmake_minimum_required (VERSION 2.8.6) + + set(LZ4_TOP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..") + +-option(LZ4_BUILD_CLI "Build lz4 program" ON) +-option(LZ4_BUILD_LEGACY_LZ4C "Build lz4c progam with legacy argument support" ON) + + # Parse version information + file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_MAJOR REGEX "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$") +@@ -34,7 +33,8 @@ else() + LANGUAGES C) + endif() + +-cmake_minimum_required (VERSION 2.8.6) ++option(LZ4_BUILD_CLI "Build lz4 program" ON) ++option(LZ4_BUILD_LEGACY_LZ4C "Build lz4c progam with legacy argument support" ON) + + # If LZ4 is being bundled in another project, we don't want to + # install anything. However, we want to let people override this, so diff --git a/recipes/lz4/all/patches/0003-cmake-minimum-required-first-1.9.3.patch b/recipes/lz4/all/patches/0003-cmake-minimum-required-first-1.9.3.patch new file mode 100644 index 0000000000000..16c6011122a07 --- /dev/null +++ b/recipes/lz4/all/patches/0003-cmake-minimum-required-first-1.9.3.patch @@ -0,0 +1,25 @@ +--- a/build/cmake/CMakeLists.txt ++++ b/build/cmake/CMakeLists.txt +@@ -9,11 +9,10 @@ + # + # LZ4's CMake support is maintained by Evan Nemerson; when filing + # bugs please mention @nemequ to make sure I see it. ++cmake_minimum_required (VERSION 2.8.6) + + set(LZ4_TOP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..") + +-option(LZ4_BUILD_CLI "Build lz4 program" ON) +-option(LZ4_BUILD_LEGACY_LZ4C "Build lz4c progam with legacy argument support" ON) + + # Parse version information + file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" LZ4_VERSION_MAJOR REGEX "^#define LZ4_VERSION_MAJOR +([0-9]+) +.*$") +@@ -34,7 +33,8 @@ else() + LANGUAGES C) + endif() + +-cmake_minimum_required (VERSION 2.8.6) ++option(LZ4_BUILD_CLI "Build lz4 program" ON) ++option(LZ4_BUILD_LEGACY_LZ4C "Build lz4c progam with legacy argument support" ON) + + # If LZ4 is being bundled in another project, we don't want to + # install anything. However, we want to let people override this, so diff --git a/recipes/lz4/all/test_package/CMakeLists.txt b/recipes/lz4/all/test_package/CMakeLists.txt index 1b899abd8d05b..14b12b7977c2c 100644 --- a/recipes/lz4/all/test_package/CMakeLists.txt +++ b/recipes/lz4/all/test_package/CMakeLists.txt @@ -1,14 +1,21 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(lz4 REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(${PROJECT_NAME} test_package.c) +if(TARGET LZ4::lz4_static) + target_link_libraries(${PROJECT_NAME} PRIVATE LZ4::lz4_static) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE LZ4::lz4_shared) +endif() option(TEST_SHARED_LIB "Use package in a shared library") if(TEST_AS_SHARED_LIB) - add_library(${PROJECT_NAME}2 SHARED lib.cpp) - target_link_libraries(${PROJECT_NAME}2 ${CONAN_LIBS}) + add_library(${PROJECT_NAME}2 SHARED lib.c) + if(TARGET LZ4::lz4_static) + target_link_libraries(${PROJECT_NAME}2 PRIVATE LZ4::lz4_static) + else() + target_link_libraries(${PROJECT_NAME}2 PRIVATE LZ4::lz4_shared) + endif() endif() diff --git a/recipes/lz4/all/test_package/conanfile.py b/recipes/lz4/all/test_package/conanfile.py index 32a1c9a957b21..e1a1aff777023 100644 --- a/recipes/lz4/all/test_package/conanfile.py +++ b/recipes/lz4/all/test_package/conanfile.py @@ -1,18 +1,32 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + lz4 = self.dependencies["lz4"] + tc = CMakeToolchain(self) + tc.variables["TEST_SHARED_LIB"] = lz4.options.get_safe("fPIC", True) + tc.generate() def build(self): cmake = CMake(self) - cmake.definitions["TEST_SHARED_LIB"] = dict(self.options["lz4"].items()).get("fPIC", True) cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/lz4/all/test_package/lib.cpp b/recipes/lz4/all/test_package/lib.c similarity index 100% rename from recipes/lz4/all/test_package/lib.cpp rename to recipes/lz4/all/test_package/lib.c diff --git a/recipes/lz4/all/test_package/test_package.cpp b/recipes/lz4/all/test_package/test_package.c similarity index 100% rename from recipes/lz4/all/test_package/test_package.cpp rename to recipes/lz4/all/test_package/test_package.c diff --git a/recipes/lz4/all/test_v1_package/CMakeLists.txt b/recipes/lz4/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f9324f7603fe8 --- /dev/null +++ b/recipes/lz4/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(lz4 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +if(TARGET LZ4::lz4_static) + target_link_libraries(${PROJECT_NAME} PRIVATE LZ4::lz4_static) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE LZ4::lz4_shared) +endif() + +option(TEST_SHARED_LIB "Use package in a shared library") +if(TEST_AS_SHARED_LIB) + add_library(${PROJECT_NAME}2 SHARED ../test_package/lib.c) + if(TARGET LZ4::lz4_static) + target_link_libraries(${PROJECT_NAME}2 PRIVATE LZ4::lz4_static) + else() + target_link_libraries(${PROJECT_NAME}2 PRIVATE LZ4::lz4_shared) + endif() +endif() diff --git a/recipes/lz4/all/test_v1_package/conanfile.py b/recipes/lz4/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a2c12d9cb383d --- /dev/null +++ b/recipes/lz4/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +# pylint: skip-file +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["TEST_SHARED_LIB"] = dict(self.options["lz4"].items()).get("fPIC", True) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lz4/config.yml b/recipes/lz4/config.yml index 98c762cbdd16c..f96920e268df8 100644 --- a/recipes/lz4/config.yml +++ b/recipes/lz4/config.yml @@ -1,5 +1,6 @@ ---- versions: + "1.9.4": + folder: all "1.9.3": folder: all "1.9.2": diff --git a/recipes/lzfse/all/CMakeLists.txt b/recipes/lzfse/all/CMakeLists.txt deleted file mode 100644 index 217b9530b904d..0000000000000 --- a/recipes/lzfse/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/lzfse/all/conandata.yml b/recipes/lzfse/all/conandata.yml index cf6d11bdad78d..54cf5d7412ca3 100644 --- a/recipes/lzfse/all/conandata.yml +++ b/recipes/lzfse/all/conandata.yml @@ -2,3 +2,6 @@ sources: "1.0": url: "https://github.com/lzfse/lzfse/archive/lzfse-1.0.tar.gz" sha256: "cf85f373f09e9177c0b21dbfbb427efaedc02d035d2aade65eb58a3cbf9ad267" +patches: + "1.0": + - patch_file: "patches/0001-fix-cmake.patch" diff --git a/recipes/lzfse/all/conanfile.py b/recipes/lzfse/all/conanfile.py index aba4cc284bacb..530adaa40f1f9 100644 --- a/recipes/lzfse/all/conanfile.py +++ b/recipes/lzfse/all/conanfile.py @@ -1,64 +1,80 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get import os -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.50.0" + class LzfseConan(ConanFile): name = "lzfse" description = "Lempel-Ziv style data compression algorithm using Finite State Entropy coding." license = "BSD-3-Clause" - topics = ("conan", "lzfse", "compression", "decompression") + topics = ("lzfse", "compression", "decompression") homepage = "https://github.com/lzfse/lzfse" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "CMakeLists.txt" - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{0}-{0}-{1}".format(self.name, self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LZFSE_BUNDLE_MODE"] = False + tc.variables["LZFSE_DISABLE_TESTS"] = False + # Relocatable shared lib on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() def build(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "POSITION_INDEPENDENT_CODE TRUE", "") - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["LZFSE_BUNDLE_MODE"] = False - self._cmake.definitions["LZFSE_DISABLE_TESTS"] = True - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["lzfse"] + if self.settings.os == "Windows" and self.options.shared: + self.cpp_info.defines.append("LZFSE_DLL") + bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bin_path)) self.env_info.PATH.append(bin_path) diff --git a/recipes/lzfse/all/patches/0001-fix-cmake.patch b/recipes/lzfse/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..c364b0b0083c4 --- /dev/null +++ b/recipes/lzfse/all/patches/0001-fix-cmake.patch @@ -0,0 +1,33 @@ +* cmake_minimum_required() must be before project() +* Do not force PIC +* Do not force IPO +* fix cross-compilation to iOS/tvOS/watchOS + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,5 @@ +-project(lzfse C) + cmake_minimum_required(VERSION 2.8.6) ++project(lzfse C) + + include(CheckCCompilerFlag) + +@@ -82,9 +82,7 @@ else() + endif() + + set_target_properties(lzfse PROPERTIES +- POSITION_INDEPENDENT_CODE TRUE +- C_VISIBILITY_PRESET hidden +- INTERPROCEDURAL_OPTIMIZATION TRUE) ++ C_VISIBILITY_PRESET hidden) + + if(BUILD_SHARED_LIBS) + set_property(TARGET lzfse APPEND PROPERTY COMPILE_DEFINITIONS LZFSE_DLL LZFSE_DLL_EXPORTS) +@@ -97,6 +95,7 @@ if(NOT LZFSE_BUNDLE_MODE) + + install(TARGETS lzfse lzfse_cli + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") + install(FILES src/lzfse.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") diff --git a/recipes/lzfse/all/test_package/CMakeLists.txt b/recipes/lzfse/all/test_package/CMakeLists.txt index fd126a732c403..9e7bf97eca042 100644 --- a/recipes/lzfse/all/test_package/CMakeLists.txt +++ b/recipes/lzfse/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(lzfse REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE lzfse::lzfse) set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/lzfse/all/test_package/conanfile.py b/recipes/lzfse/all/test_package/conanfile.py index b79bac5be5fef..feb43a8fb1857 100644 --- a/recipes/lzfse/all/test_package/conanfile.py +++ b/recipes/lzfse/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - txt_name = os.path.join(self.source_folder, "test.txt") - bin_path = os.path.join("bin", "test_package") - self.run("{0} -encode -i {1}".format(bin_path, txt_name), run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + txt_path = os.path.join(self.source_folder, "test.txt") + self.run(f"{bin_path} -encode -i {txt_path}", env="conanrun") diff --git a/recipes/lzfse/all/test_v1_package/CMakeLists.txt b/recipes/lzfse/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..92018de27c3ec --- /dev/null +++ b/recipes/lzfse/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGET) + +find_package(lzfse REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE lzfse::lzfse) +set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/lzfse/all/test_v1_package/conanfile.py b/recipes/lzfse/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..6f91d1323474b --- /dev/null +++ b/recipes/lzfse/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + txt_path = os.path.join(self.source_folder, os.pardir, "test_package", "test.txt") + self.run(f"{bin_path} -encode -i {txt_path}", run_environment=True) diff --git a/recipes/lzip/all/conandata.yml b/recipes/lzip/all/conandata.yml index a724a2397846f..2b81d53f9b8e1 100644 --- a/recipes/lzip/all/conandata.yml +++ b/recipes/lzip/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.22": + url: [ + "http://download.savannah.gnu.org/releases/lzip/lzip-1.22.tar.gz", + "https://download-mirror.savannah.gnu.org/releases/lzip/lzip-1.22.tar.gz", + ] + sha256: "c3342d42e67139c165b8b128d033b5c96893a13ac5f25933190315214e87a948" "1.21": url: [ "http://download.savannah.gnu.org/releases/lzip/lzip-1.21.tar.gz", @@ -6,6 +12,9 @@ sources: ] sha256: "e48b5039d3164d670791f9c5dbaa832bf2df080cb1fbb4f33aa7b3300b670d8b" patches: + "1.22": + - base_path: "source_subfolder" + patch_file: "patches/1.22-0001-any-compiler.patch" "1.21": - base_path: "source_subfolder" - patch_file: "patches/0001-any-compiler.patch" + patch_file: "patches/1.21-0001-any-compiler.patch" diff --git a/recipes/lzip/all/conanfile.py b/recipes/lzip/all/conanfile.py index 394555012b452..96c8fbac3cb58 100644 --- a/recipes/lzip/all/conanfile.py +++ b/recipes/lzip/all/conanfile.py @@ -1,33 +1,43 @@ from conans import AutoToolsBuildEnvironment, CMake, ConanFile, tools from conans.errors import ConanInvalidConfiguration -from contextlib import contextmanager +import contextlib import os import textwrap +required_conan_version = ">=1.33.0" + class LzipConan(ConanFile): name = "lzip" description = "Lzip is a lossless data compressor with a user interface similar to the one of gzip or bzip2" - topics = ("conan", "lzip", "compressor", "lzma") + topics = ("lzip", "compressor", "lzma") license = "GPL-v2-or-later" homepage = "https://www.nongnu.org/lzip/" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "patches/**" settings = "os", "arch", "compiler", "build_type" + exports_sources = "patches/**" + _autotools = None @property def _source_subfolder(self): return "source_subfolder" - def config_options(self): + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def validate(self): if self.settings.compiler == "Visual Studio": raise ConanInvalidConfiguration("Visual Studio is not supported") - def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + def package_id(self): + del self.info.settings.compiler def _detect_compilers(self): tools.rmdir("detectdir") @@ -46,16 +56,11 @@ def _detect_compilers(self): cxx = tools.load("cxx.txt").strip() return cc, cxx - def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH") and \ - tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20190524") - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) - @contextmanager + @contextlib.contextmanager def _build_context(self): env = {} cc, cxx = self._detect_compilers() diff --git a/recipes/lzip/all/patches/0001-any-compiler.patch b/recipes/lzip/all/patches/1.21-0001-any-compiler.patch similarity index 100% rename from recipes/lzip/all/patches/0001-any-compiler.patch rename to recipes/lzip/all/patches/1.21-0001-any-compiler.patch diff --git a/recipes/lzip/all/patches/1.22-0001-any-compiler.patch b/recipes/lzip/all/patches/1.22-0001-any-compiler.patch new file mode 100644 index 0000000000000..50311f5627b8c --- /dev/null +++ b/recipes/lzip/all/patches/1.22-0001-any-compiler.patch @@ -0,0 +1,18 @@ +--- configure ++++ configure +@@ -24,7 +24,7 @@ + check=no + installdir= +-CXX=g++ +-CPPFLAGS= +-CXXFLAGS='-Wall -W -O2' +-LDFLAGS= ++#CXX=g++ ++#CPPFLAGS= ++#CXXFLAGS='-Wall -W -O2' ++#LDFLAGS= + +@@ -31,2 +31,2 @@ + # checking whether we are using GNU C++. +-/bin/sh -c "${CXX} --version" > /dev/null 2>&1 || { CXX=c++ ; CXXFLAGS=-O2 ; } ++# /bin/sh -c "${CXX} --version" > /dev/null 2>&1 || { CXX=c++ ; CXXFLAGS=-O2 ; } diff --git a/recipes/lzip/all/test_package/conanfile.py b/recipes/lzip/all/test_package/conanfile.py index add3056b3756f..84ae9d8826de5 100644 --- a/recipes/lzip/all/test_package/conanfile.py +++ b/recipes/lzip/all/test_package/conanfile.py @@ -1,14 +1,14 @@ -from conans import ConanFile, CMake, tools +from conans import ConanFile, tools from conans.errors import ConanException import os import shutil class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" def test(self): - if not tools.cross_building(self.settings, skip_x64_x86=True): + if not tools.cross_building(self, skip_x64_x86=True): lzip = os.path.join(self.deps_cpp_info["lzip"].bin_paths[0], "lzip") self.run("{} --version".format(lzip)) diff --git a/recipes/lzip/config.yml b/recipes/lzip/config.yml index 055ce47d96ee4..e027a6bc18156 100644 --- a/recipes/lzip/config.yml +++ b/recipes/lzip/config.yml @@ -1,3 +1,5 @@ versions: + "1.22": + folder: "all" "1.21": folder: "all" diff --git a/recipes/lzma_sdk/9.20/conanfile.py b/recipes/lzma_sdk/9.20/conanfile.py index 12ce60efe785c..66f4dfa40693b 100644 --- a/recipes/lzma_sdk/9.20/conanfile.py +++ b/recipes/lzma_sdk/9.20/conanfile.py @@ -1,5 +1,9 @@ +from conan import ConanFile +from conan.tools.files import get, chdir, replace_in_file, rm +from conans import tools, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment import os -from conans import ConanFile, tools, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment + +required_conan_version = ">=1.50.0" """ This older lzma release is used to build 7zip (to extract its sources). @@ -14,86 +18,100 @@ """ -class PackageLzmaSdk(ConanFile): +class LzmaSdkConan(ConanFile): name = "lzma_sdk" - version = "9.20" url = "https://github.com/conan-io/conan-center-index" description = "LZMA provides a high compression ratio and fast decompression, so it is very suitable for embedded applications." license = ("LZMA-exception",) homepage = "https://www.7-zip.org/sdk.html" - topics = ("conan", "lzma", "zip", "compression", "decompression") + topics = ("lzma", "zip", "compression", "decompression") settings = "os", "arch", "compiler" + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def build_requirements(self): - if self.settings.compiler != "Visual Studio" and tools.os_info.is_windows and os.environ.get("CONAN_BASH_PATH", None) is None: - self.build_requires("msys2/20190524") + if self.settings.compiler != "Visual Studio" and self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def package_id(self): + del self.info.settings.compiler def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.unlink(os.path.join(self.source_folder, "7zr.exe")) - os.unlink(os.path.join(self.source_folder, "lzma.exe")) + get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder) + rm(self, "7zr.exe", self._source_subfolder) + rm(self, "lzma.exe", self._source_subfolder) @property def _msvc_build_dirs(self): return ( - [os.path.join("C","Util","7z"), [["7zDec.exe"], []]], - [os.path.join("C","Util","Lzma"), [["LZMAc.exe"], []]], - [os.path.join("CPP","7zip","UI","Console"), [["7z.exe"], []]], - [os.path.join("CPP","7zip","Bundles","Alone7z"), [["7zr.exe"], []]], - [os.path.join("CPP","7zip","Bundles","LzmaCon"), [["lzma.exe"], []]], + (os.path.join(self._source_subfolder, "C", "Util", "7z"), "7zDec.exe"), + (os.path.join(self._source_subfolder, "C", "Util", "Lzma"), "LZMAc.exe"), + (os.path.join(self._source_subfolder, "CPP", "7zip", "UI", "Console"), "7z.exe"), + (os.path.join(self._source_subfolder, "CPP", "7zip","Bundles", "Alone7z"), "7zr.exe"), + (os.path.join(self._source_subfolder, "CPP", "7zip", "Bundles", "LzmaCon"), "lzma.exe"), ) @property def _msvc_cpu(self): return { - 'x86_64': 'AMD64', - 'x86': 'x86', + "x86_64": "AMD64", + "x86": "x86", }[str(self.settings.arch)] @property def _autotools_build_dirs(self): es = ".exe" if self.settings.os == "Windows" else "" return ( - [os.path.join("C","Util","7z"), [["7zDec{}".format(es)], []]], - [os.path.join("CPP","7zip","Bundles","LzmaCon"), [["lzma{}".format(es)],[]]] + (os.path.join(self._source_subfolder, "C", "Util", "7z"), f"7zDec{es}"), + (os.path.join(self._source_subfolder, "CPP", "7zip", "Bundles", "LzmaCon"), f"lzma{es}"), ) def _build_msvc(self): for make_dir, _ in self._msvc_build_dirs: - with tools.vcvars(self.settings): - with tools.chdir(make_dir): - self.run("nmake /f makefile NEW_COMPILER=1 CPU=%s" % self._msvc_cpu) + with tools.vcvars(self): + with tools.environment_append(VisualStudioBuildEnvironment(self).vars): + with tools.chdir(make_dir): + self.run(f"nmake /f makefile NEW_COMPILER=1 CPU={self._msvc_cpu} NO_BUFFEROVERFLOWU=1") def _build_autotools(self): env_build = AutoToolsBuildEnvironment(self) with tools.environment_append(env_build.vars): for make_dir, _ in self._autotools_build_dirs: - with tools.chdir(make_dir): - extra_args = "" + with chdir(self, make_dir): + args = [ + "-f", "makefile.gcc", + ] if self.settings.os == "Windows": - extra_args += " IS_MINGW=1" - self.run("make -f makefile.gcc all%s" % extra_args) + args.append("IS_MINGW=1") + autotools = AutoToolsBuildEnvironment(self) + autotools.make(args=args) def _patch_sources(self): if self.settings.compiler == "Visual Studio": - tools.replace_in_file(os.path.join(self.build_folder, "CPP", "Build.mak"), + replace_in_file(self, os.path.join(self._source_subfolder, "CPP", "Build.mak"), "-MT\r", "-" + str(self.settings.compiler.runtime)) - tools.replace_in_file(os.path.join(self.build_folder, "CPP", "Build.mak"), + replace_in_file(self, os.path.join(self._source_subfolder, "CPP", "Build.mak"), "-MD\r", "-" + str(self.settings.compiler.runtime)) - tools.replace_in_file(os.path.join(self.build_folder, "CPP", "Build.mak"), + replace_in_file(self, os.path.join(self._source_subfolder, "CPP", "Build.mak"), " -WX ", " ") # Patches for other build systems - tools.replace_in_file(os.path.join(self.build_folder, "C", "Util", "7z", "makefile.gcc"), + replace_in_file(self, os.path.join(self._source_subfolder, "C", "Util", "7z", "makefile.gcc"), "CFLAGS = ", "CFLAGS = -fpermissive ") - tools.replace_in_file(os.path.join(self.build_folder, "C", "Util", "7z", "makefile.gcc"), + replace_in_file(self, os.path.join(self._source_subfolder, "C", "Util", "7z", "makefile.gcc"), ": 7zAlloc.c", ": ../../7zAlloc.c") - tools.replace_in_file(os.path.join(self.build_folder, "C", "Util", "Lzma", "makefile.gcc"), + replace_in_file(self, os.path.join(self._source_subfolder, "C", "Util", "Lzma", "makefile.gcc"), "CFLAGS = ", "CFLAGS = -fpermissive ") - tools.replace_in_file(os.path.join(self.build_folder, "CPP", "Common", "MyString.h"), + replace_in_file(self, os.path.join(self._source_subfolder, "CPP", "Common", "MyString.h"), "#ifdef _WIN32\r\n", "#ifdef _WIN32\r\n#ifndef UNDER_CE\r\n#include \r\n#endif\r\n") @@ -105,27 +123,18 @@ def build(self): self._build_autotools() def package(self): - self.copy("lzma.txt", src=self.source_folder, dst="licenses") - self.copy("7zC.txt", src=self.source_folder, dst="licenses") + self.copy("lzma.txt", src=self._source_subfolder, dst="licenses") + self.copy("7zC.txt", src=self._source_subfolder, dst="licenses") if self.settings.compiler == "Visual Studio": - for make_dir, [exes, libs] in self._msvc_build_dirs: - for exe in exes: - self.copy(exe, src=os.path.join(make_dir, self._msvc_cpu), dst="bin", keep_path=False) - for lib in libs: - self.copy(lib, src=os.path.join(make_dir, self._msvc_cpu), dst="lib", keep_path=False) + for make_dir, exe in self._msvc_build_dirs: + self.copy(exe, src=os.path.join(make_dir, self._msvc_cpu), dst="bin", keep_path=False) else: - for make_dir, [exes, libs] in self._autotools_build_dirs: - for exe in exes: - self.copy(exe, src=os.path.join(make_dir), dst="bin", keep_path=False) - for lib in libs: - self.copy(lib, src=os.path.join(make_dir), dst="lib", keep_path=False) - - def package_id(self): - self.info.include_build_settings() - del self.info.settings.compiler + for make_dir, exe in self._autotools_build_dirs: + self.copy(exe, src=os.path.join(make_dir), dst="bin", keep_path=False) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] bin_path = os.path.join(self.package_folder, "bin") - self.output.info('Appending PATH environment variable: %s' % bin_path) + self.output.info(f"Appending PATH environment variable: {bin_path}") self.env_info.path.append(bin_path) diff --git a/recipes/lzma_sdk/9.20/test_package/conanfile.py b/recipes/lzma_sdk/9.20/test_package/conanfile.py index fb7ba4697d074..d956ede854042 100644 --- a/recipes/lzma_sdk/9.20/test_package/conanfile.py +++ b/recipes/lzma_sdk/9.20/test_package/conanfile.py @@ -1,10 +1,10 @@ from conans import ConanFile, tools -class TestPackage(ConanFile): +class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run("7zDec", run_environment=True) self.run("lzma", run_environment=True) diff --git a/recipes/lzma_sdk/config.yml b/recipes/lzma_sdk/config.yml new file mode 100644 index 0000000000000..8d82196257bd6 --- /dev/null +++ b/recipes/lzma_sdk/config.yml @@ -0,0 +1,3 @@ +versions: + "9.20": + folder: "9.20" diff --git a/recipes/lzo/all/conanfile.py b/recipes/lzo/all/conanfile.py index 7731b8b1ce508..1babfd0e8f2d7 100644 --- a/recipes/lzo/all/conanfile.py +++ b/recipes/lzo/all/conanfile.py @@ -1,6 +1,10 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir import os +required_conan_version = ">=1.47.0" + class LZOConan(ConanFile): name = "lzo" @@ -8,57 +12,61 @@ class LZOConan(ConanFile): license = "GPL-v2.0" url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.oberhumer.com/opensource/lzo/" - topics = ("conan", "lzo", "compression") - exports_sources = "CMakeLists.txt" - generators = "cmake" - no_copy_source = True - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - _cmake = None + topics = ("lzo", "compression") - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd if self.options.shared: del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "{0}-{1}".format(self.name, self.version) - os.rename(extracted_folder, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_STATIC"] = not self.options.shared - self._cmake.definitions["ENABLE_SHARED"] = self.options.shared - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_STATIC"] = not self.options.shared + tc.variables["ENABLE_SHARED"] = self.options.shared + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "bin", "lzo")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "bin", "lzo")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["pkg_config"] ="lzo2" + self.cpp_info.set_property("pkg_config_name", "lzo2") self.cpp_info.includedirs.append(os.path.join("include", "lzo")) - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["lzo2"] diff --git a/recipes/lzo/all/test_package/CMakeLists.txt b/recipes/lzo/all/test_package/CMakeLists.txt index 7b9b613cbb24a..aae70901bbdc7 100644 --- a/recipes/lzo/all/test_package/CMakeLists.txt +++ b/recipes/lzo/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(lzo REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE lzo::lzo) diff --git a/recipes/lzo/all/test_package/conanfile.py b/recipes/lzo/all/test_package/conanfile.py index bd7165a553cf4..3a8c6c5442b33 100644 --- a/recipes/lzo/all/test_package/conanfile.py +++ b/recipes/lzo/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/lzo/all/test_v1_package/CMakeLists.txt b/recipes/lzo/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4217d911bdc88 --- /dev/null +++ b/recipes/lzo/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(lzo REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE lzo::lzo) diff --git a/recipes/lzo/all/test_v1_package/conanfile.py b/recipes/lzo/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..ad9be58bc8e99 --- /dev/null +++ b/recipes/lzo/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/lzo/all/test_v1_package/test_package.c b/recipes/lzo/all/test_v1_package/test_package.c new file mode 100644 index 0000000000000..82d98c1e92179 --- /dev/null +++ b/recipes/lzo/all/test_v1_package/test_package.c @@ -0,0 +1,47 @@ +#include "lzo1f.h" +#include +#include + +const char *text = "This is a string that lzo should compress to less bytes then before if it is working fine.\n" +"This compression algorithm appears to only compress bigger inputs so put a lot of text here.\n"; + + +int main() +{ + if (lzo_init() != LZO_E_OK) + { + printf("internal error - lzo_init() failed !!!\n"); + printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n"); + return 1; + } + + char compressed[2048]; + size_t compressed_len = sizeof(compressed); + { + char workMemory[LZO1F_MEM_COMPRESS+1]; + int r = lzo1f_1_compress((unsigned char*)text, strlen(text), (unsigned char*)compressed, &compressed_len, workMemory); + if (r != LZO_E_OK) { + printf("internal error - compression failed: %d\n", r); + return 1; + } + } + printf("Size before compression: %zu bytes\n", strlen(text)); + printf("Size after compression: %zu bytes\n", compressed_len); + + + char decompressed[2048]; + size_t decompressed_len = sizeof(decompressed); + { + char workMemory[LZO1F_MEM_DECOMPRESS+1]; + int r = lzo1f_decompress((unsigned char*)compressed, compressed_len, (unsigned char*)decompressed, &decompressed_len, workMemory); + if (r != LZO_E_OK) { + printf("internal error - decompression failed: %d\n", r); + return 1; + } + } + + int ok = (strlen(text) == decompressed_len) && (strncmp(text, decompressed, decompressed_len) == 0); + printf("Decompression: %s\n", ok ? "Success" : "Failure"); + + return ok ? 0 : 1; +} diff --git a/recipes/m4/all/conandata.yml b/recipes/m4/all/conandata.yml index f64aa2b96cf48..3b25f4d23294d 100644 --- a/recipes/m4/all/conandata.yml +++ b/recipes/m4/all/conandata.yml @@ -1,22 +1,27 @@ sources: + "1.4.19": + url: + - "https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.gz" + - "https://ftpmirror.gnu.org/gnu/m4/m4-1.4.19.tar.gz" + sha256: "3be4a26d825ffdfda52a56fc43246456989a3630093cced3fbddf4771ee58a70" "1.4.18": - url: "https://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.bz2" - sha256: "6640d76b043bc658139c8903e293d5978309bf0f408107146505eca701e67cf6" + url: + - "https://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.gz" + - "https://ftpmirror.gnu.org/gnu/m4/m4-1.4.18.tar.gz" + sha256: "ab2633921a5cd38e48797bf5521ad259bdc4b979078034a3b790d7fec5493fab" patches: + "1.4.19": + - patch_file: "patches/1.4.19-0001-open-files-in-binary-mode.patch" + - patch_file: "patches/1.4.19-0002-ar-lib.patch" + - patch_file: "patches/1.4.19-0003-msvc-debug-assertion.patch" + - patch_file: "patches/1.4.19-0004-disable-hardening-in-source.patch" "1.4.18": - - patch_file: "patches/0001-fflush-adjust-to-glibc-2.28-libio.h-removal.patch" - base_path: "source_subfolder" - - patch_file: "patches/0002-fflush-be-more-paranoid-about-libio.h-change.patch" - base_path: "source_subfolder" - - patch_file: "patches/0004-fix-checks.patch" - base_path: "source_subfolder" - - patch_file: "patches/0005-vasnprintf-Fix-for-MSVC-14.patch" - base_path: "source_subfolder" - - patch_file: "patches/0006-manywarnings-update-for-gcc-7.patch" - base_path: "source_subfolder" - - patch_file: "patches/0007-vasnprintf-port-to-macos-10.13.patch" - base_path: "source_subfolder" - - patch_file: "patches/0008-open-files-in-binary-mode.patch" - base_path: "source_subfolder" - - patch_file: "patches/0009-disable-hardening-in-source.patch" - base_path: "source_subfolder" + - patch_file: "patches/1.4.18-0001-fflush-adjust-to-glibc-2.28-libio.h-removal.patch" + - patch_file: "patches/1.4.18-0002-fflush-be-more-paranoid-about-libio.h-change.patch" + - patch_file: "patches/1.4.18-0004-fix-checks.patch" + - patch_file: "patches/1.4.18-0005-vasnprintf-Fix-for-MSVC-14.patch" + - patch_file: "patches/1.4.18-0006-manywarnings-update-for-gcc-7.patch" + - patch_file: "patches/1.4.18-0007-vasnprintf-port-to-macos-10.13.patch" + - patch_file: "patches/1.4.18-0008-open-files-in-binary-mode.patch" + - patch_file: "patches/1.4.18-0009-disable-hardening-in-source.patch" + - patch_file: "patches/1.4.18-0010-c-stack-stop-using-SIGSTKSZ.patch" diff --git a/recipes/m4/all/conanfile.py b/recipes/m4/all/conanfile.py index b3760779bbb9a..ceb7e83548ca8 100644 --- a/recipes/m4/all/conanfile.py +++ b/recipes/m4/all/conanfile.py @@ -1,117 +1,123 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from contextlib import contextmanager +from conan import ConanFile +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.scm import Version import os +required_conan_version = ">=1.52.0" + class M4Conan(ConanFile): name = "m4" description = "GNU M4 is an implementation of the traditional Unix macro processor" - topics = ("conan", "m4", "macro", "macro processor") - url = "https://github.com/conan-io/conan-center-index" + topics = ("macro", "preprocessor") homepage = "https://www.gnu.org/software/m4/" + url = "https://github.com/conan-io/conan-center-index" license = "GPL-3.0-only" - exports_sources = ["patches/*.patch"] settings = "os", "arch", "compiler", "build_type" - _autotools = None - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" - @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + def _settings_build(self): + return getattr(self, "settings_build", self.settings) - @property - def _is_clang(self): - return str(self.settings.compiler).endswith("clang") + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + del self.info.settings.compiler def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows": + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + self.tool_requires("msys2/cci.latest") + self.win_bash = True def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("m4-" + self.version, self._source_subfolder) - - def _configure_autotools(self): - if self._autotools: - return self._autotools - conf_args = [] - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - build_canonical_name = None - host_canonical_name = None - if self.settings.compiler == "Visual Studio": - # The somewhat older configure script of m4 does not understand the canonical names of Visual Studio - build_canonical_name = False - host_canonical_name = False - self._autotools.flags.append("-FS") + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = AutotoolsToolchain(self) + if is_msvc(self): + tc.extra_cflags.append("-FS") # Avoid a `Assertion Failed Dialog Box` during configure with build_type=Debug # Visual Studio does not support the %n format flag: # https://docs.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions # Because the %n format is inherently insecure, it is disabled by default. If %n is encountered in a format string, # the invalid parameter handler is invoked, as described in Parameter Validation. To enable %n support, see _set_printf_count_output. - conf_args.extend(["gl_cv_func_printf_directive_n=no", "gl_cv_func_snprintf_directive_n=no", "gl_cv_func_snprintf_directive_n=no"]) + tc.configure_args.extend([ + "gl_cv_func_printf_directive_n=no", + "gl_cv_func_snprintf_directive_n=no", + "gl_cv_func_snprintf_directive_n=no", + ]) if self.settings.build_type in ("Debug", "RelWithDebInfo"): - self._autotools.link_flags.append("-PDB") - self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder, build=build_canonical_name, host=host_canonical_name) - return self._autotools - - @contextmanager - def _build_context(self): - env = {} - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - env.update({ - "AR": "{}/build-aux/ar-lib lib".format(tools.unix_path(self._source_subfolder)), - "CC": "cl -nologo", - "CXX": "cl -nologo", - "LD": "link", - "NM": "dumpbin -symbols", - "OBJDUMP": ":", - "RANLIB": ":", - "STRIP": ":", - }) - with tools.environment_append(env): - yield - else: - if self._is_clang: - env["CFLAGS"] = "-rtlib=compiler-rt" - with tools.environment_append(env): - yield + tc.extra_ldflags.append("-PDB") + elif self.settings.compiler == "clang": + if Version(self.version) < "1.4.19": + tc.extra_cflags.extend([ + "-rtlib=compiler-rt", + "-Wno-unused-command-line-argument", + ]) + if self.settings.os == "Windows": + tc.configure_args.append("ac_cv_func__set_invalid_parameter_handler=yes") + env = tc.environment() + # help2man trick + env.prepend_path("PATH", self.source_folder) + # handle msvc + if is_msvc(self): + ar_wrapper = unix_path(self, os.path.join(self.source_folder, "build-aux", "ar-lib")) + env.define("CC", "cl -nologo") + env.define("CXX", "cl -nologo") + env.define("AR", f"{ar_wrapper} lib") + env.define("LD", "link") + env.define("NM", "dumpbin -symbols") + env.define("OBJDUMP", ":") + env.define("RANLIB", ":") + env.define("STRIP", ":") + tc.generate(env) def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + apply_conandata_patches(self) + # dummy file for configure + help2man = os.path.join(self.source_folder, "help2man") + save(self, help2man, "#!/usr/bin/env bash\n:") + if os.name == "posix": + os.chmod(help2man, os.stat(help2man).st_mode | 0o111) def build(self): self._patch_sources() - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() - if bool(os.environ.get("CONAN_RUN_TESTS", "")): - self.output.info("Running m4 checks...") - with tools.chdir("tests"): - autotools.make(target="check") + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - - def package_id(self): - self.info.include_build_settings() - del self.info.settings.compiler + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) + self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] + # M4 environment variable is used by a lot of scripts as a way to override a hard-coded embedded m4 path bin_ext = ".exe" if self.settings.os == "Windows" else "" - m4_bin = os.path.join(self.package_folder, "bin", "m4{}".format(bin_ext)).replace("\\", "/") + m4_bin = os.path.join(self.package_folder, "bin", f"m4{bin_ext}").replace("\\", "/") + self.runenv_info.define_path("M4", m4_bin) + self.buildenv_info.define_path("M4", m4_bin) - # M4 environment variable is used by a lot of scripts as a way to override a hard-coded embedded m4 path - self.output.info("Setting M4 environment variable: {}".format(m4_bin)) + # TODO: to remove in conan v2 + bin_path = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH environment variable: {bin_path}") + self.env_info.PATH.append(bin_path) self.env_info.M4 = m4_bin diff --git a/recipes/m4/all/patches/0001-fflush-adjust-to-glibc-2.28-libio.h-removal.patch b/recipes/m4/all/patches/1.4.18-0001-fflush-adjust-to-glibc-2.28-libio.h-removal.patch similarity index 100% rename from recipes/m4/all/patches/0001-fflush-adjust-to-glibc-2.28-libio.h-removal.patch rename to recipes/m4/all/patches/1.4.18-0001-fflush-adjust-to-glibc-2.28-libio.h-removal.patch diff --git a/recipes/m4/all/patches/0002-fflush-be-more-paranoid-about-libio.h-change.patch b/recipes/m4/all/patches/1.4.18-0002-fflush-be-more-paranoid-about-libio.h-change.patch similarity index 100% rename from recipes/m4/all/patches/0002-fflush-be-more-paranoid-about-libio.h-change.patch rename to recipes/m4/all/patches/1.4.18-0002-fflush-be-more-paranoid-about-libio.h-change.patch diff --git a/recipes/m4/all/patches/0003-secure_snprintf.patch b/recipes/m4/all/patches/1.4.18-0003-secure_snprintf.patch similarity index 100% rename from recipes/m4/all/patches/0003-secure_snprintf.patch rename to recipes/m4/all/patches/1.4.18-0003-secure_snprintf.patch diff --git a/recipes/m4/all/patches/0004-fix-checks.patch b/recipes/m4/all/patches/1.4.18-0004-fix-checks.patch similarity index 100% rename from recipes/m4/all/patches/0004-fix-checks.patch rename to recipes/m4/all/patches/1.4.18-0004-fix-checks.patch diff --git a/recipes/m4/all/patches/0005-vasnprintf-Fix-for-MSVC-14.patch b/recipes/m4/all/patches/1.4.18-0005-vasnprintf-Fix-for-MSVC-14.patch similarity index 100% rename from recipes/m4/all/patches/0005-vasnprintf-Fix-for-MSVC-14.patch rename to recipes/m4/all/patches/1.4.18-0005-vasnprintf-Fix-for-MSVC-14.patch diff --git a/recipes/m4/all/patches/0006-manywarnings-update-for-gcc-7.patch b/recipes/m4/all/patches/1.4.18-0006-manywarnings-update-for-gcc-7.patch similarity index 100% rename from recipes/m4/all/patches/0006-manywarnings-update-for-gcc-7.patch rename to recipes/m4/all/patches/1.4.18-0006-manywarnings-update-for-gcc-7.patch diff --git a/recipes/m4/all/patches/0007-vasnprintf-port-to-macos-10.13.patch b/recipes/m4/all/patches/1.4.18-0007-vasnprintf-port-to-macos-10.13.patch similarity index 100% rename from recipes/m4/all/patches/0007-vasnprintf-port-to-macos-10.13.patch rename to recipes/m4/all/patches/1.4.18-0007-vasnprintf-port-to-macos-10.13.patch diff --git a/recipes/m4/all/patches/0008-open-files-in-binary-mode.patch b/recipes/m4/all/patches/1.4.18-0008-open-files-in-binary-mode.patch similarity index 100% rename from recipes/m4/all/patches/0008-open-files-in-binary-mode.patch rename to recipes/m4/all/patches/1.4.18-0008-open-files-in-binary-mode.patch diff --git a/recipes/m4/all/patches/0009-disable-hardening-in-source.patch b/recipes/m4/all/patches/1.4.18-0009-disable-hardening-in-source.patch similarity index 100% rename from recipes/m4/all/patches/0009-disable-hardening-in-source.patch rename to recipes/m4/all/patches/1.4.18-0009-disable-hardening-in-source.patch diff --git a/recipes/m4/all/patches/1.4.18-0010-c-stack-stop-using-SIGSTKSZ.patch b/recipes/m4/all/patches/1.4.18-0010-c-stack-stop-using-SIGSTKSZ.patch new file mode 100644 index 0000000000000..5d5a404937e9d --- /dev/null +++ b/recipes/m4/all/patches/1.4.18-0010-c-stack-stop-using-SIGSTKSZ.patch @@ -0,0 +1,106 @@ +c-stack: stop using SIGSTKSZ + +It’s been proposed to stop making SIGSTKSZ an integer constant: +https://sourceware.org/pipermail/libc-alpha/2020-September/118028.html +Also, using SIGSTKSZ in #if did not conform to current POSIX. +Also, avoiding SIGSTKSZ makes the code simpler and easier to grok. +* lib/c-stack.c (SIGSTKSZ): Remove. +(alternate_signal_stack): Now a 64 KiB array, for simplicity. +All uses changed. + +[Retrieved (and backported) from: +https://git.savannah.gnu.org/cgit/gnulib.git/patch/?id=f9e2b20a12a230efa30f1d479563ae07d276a94b] +Signed-off-by: Fabrice Fontaine + +diff -Nura lib/c-stack.c lib/c-stack.c +--- lib/c-stack.c 2021-04-11 19:12:14.086494029 +0200 ++++ lib/c-stack.c 2021-04-11 19:48:46.316862760 +0200 +@@ -50,15 +50,16 @@ + #if ! HAVE_STACK_T && ! defined stack_t + typedef struct sigaltstack stack_t; + #endif +-#ifndef SIGSTKSZ +-# define SIGSTKSZ 16384 +-#elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384 +-/* libsigsegv 2.6 through 2.8 have a bug where some architectures use +- more than the Linux default of an 8k alternate stack when deciding +- if a fault was caused by stack overflow. */ +-# undef SIGSTKSZ +-# define SIGSTKSZ 16384 +-#endif ++ ++/* Storage for the alternate signal stack. ++ 64 KiB is not too large for Gnulib-using apps, and is large enough ++ for all known platforms. Smaller sizes may run into trouble. ++ For example, libsigsegv 2.6 through 2.8 have a bug where some ++ architectures use more than the Linux default of an 8 KiB alternate ++ stack when deciding if a fault was caused by stack overflow. */ ++static max_align_t alternate_signal_stack[(64 * 1024 ++ + sizeof (max_align_t) - 1) ++ / sizeof (max_align_t)]; + + #include + #include +@@ -128,19 +129,6 @@ + #if (HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK \ + && HAVE_STACK_OVERFLOW_HANDLING) || HAVE_LIBSIGSEGV + +-/* Storage for the alternate signal stack. */ +-static union +-{ +- char buffer[SIGSTKSZ]; +- +- /* These other members are for proper alignment. There's no +- standard way to guarantee stack alignment, but this seems enough +- in practice. */ +- long double ld; +- long l; +- void *p; +-} alternate_signal_stack; +- + static void + null_action (int signo __attribute__ ((unused))) + { +@@ -205,8 +193,8 @@ + + /* Always install the overflow handler. */ + if (stackoverflow_install_handler (overflow_handler, +- alternate_signal_stack.buffer, +- sizeof alternate_signal_stack.buffer)) ++ alternate_signal_stack, ++ sizeof alternate_signal_stack)) + { + errno = ENOTSUP; + return -1; +@@ -279,14 +267,14 @@ + stack_t st; + struct sigaction act; + st.ss_flags = 0; ++ st.ss_sp = alternate_signal_stack; ++ st.ss_size = sizeof alternate_signal_stack; + # if SIGALTSTACK_SS_REVERSED + /* Irix mistakenly treats ss_sp as the upper bound, rather than + lower bound, of the alternate stack. */ +- st.ss_sp = alternate_signal_stack.buffer + SIGSTKSZ - sizeof (void *); +- st.ss_size = sizeof alternate_signal_stack.buffer - sizeof (void *); +-# else +- st.ss_sp = alternate_signal_stack.buffer; +- st.ss_size = sizeof alternate_signal_stack.buffer; ++ st.ss_size -= sizeof (void *); ++ char *ss_sp = st.ss_sp; ++ st.ss_sp = ss_sp + st.ss_size; + # endif + r = sigaltstack (&st, NULL); + if (r != 0) +diff -Nura lib/c-stack.h lib/c-stack.h +--- lib/c-stack.h 2021-04-11 19:12:14.098494042 +0200 ++++ lib/c-stack.h 2021-04-11 19:17:42.138848378 +0200 +@@ -34,7 +34,7 @@ + A null ACTION acts like an action that does nothing. + + ACTION must be async-signal-safe. ACTION together with its callees +- must not require more than SIGSTKSZ bytes of stack space. Also, ++ must not require more than 64 KiB bytes of stack space. Also, + ACTION should not call longjmp, because this implementation does + not guarantee that it is safe to return to the original stack. + diff --git a/recipes/m4/all/patches/1.4.19-0001-open-files-in-binary-mode.patch b/recipes/m4/all/patches/1.4.19-0001-open-files-in-binary-mode.patch new file mode 100644 index 0000000000000..91f68e00cc80f --- /dev/null +++ b/recipes/m4/all/patches/1.4.19-0001-open-files-in-binary-mode.patch @@ -0,0 +1,15 @@ +This will open all files in binary mode. +files may contain binary data. +This fixes e.g. autoconf, of whose frozen file, contains all characters from 0x00 to 0xff. + +--- src/path.c ++++ src/path.c +@@ -110,7 +110,7 @@ + static FILE * + m4_fopen (const char *file) + { +- FILE *fp = fopen (file, "re"); ++ FILE *fp = fopen (file, "reb"); + if (fp) + { + struct stat st; diff --git a/recipes/m4/all/patches/1.4.19-0002-ar-lib.patch b/recipes/m4/all/patches/1.4.19-0002-ar-lib.patch new file mode 100644 index 0000000000000..22f7abe8bb873 --- /dev/null +++ b/recipes/m4/all/patches/1.4.19-0002-ar-lib.patch @@ -0,0 +1,276 @@ +ar-lib is needed for building m4 with Visual Studio. +Re-use the one from m4/1.4.18. +We can't use automake here to avoid a build cycle (m4 -> automake -> autoconf -> m4) +--- /dev/null ++++ build-aux/ar-lib +@@ -0,0 +1,270 @@ ++#! /bin/sh ++# Wrapper for Microsoft lib.exe ++ ++me=ar-lib ++scriptversion=2012-03-01.08; # UTC ++ ++# Copyright (C) 2010-2014 Free Software Foundation, Inc. ++# Written by Peter Rosin . ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2, or (at your option) ++# any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# As a special exception to the GNU General Public License, if you ++# distribute this file as part of a program that contains a ++# configuration script generated by Autoconf, you may include it under ++# the same distribution terms that you use for the rest of that program. ++ ++# This file is maintained in Automake, please report ++# bugs to or send patches to ++# . ++ ++ ++# func_error message ++func_error () ++{ ++ echo "$me: $1" 1>&2 ++ exit 1 ++} ++ ++file_conv= ++ ++# func_file_conv build_file ++# Convert a $build file to $host form and store it in $file ++# Currently only supports Windows hosts. ++func_file_conv () ++{ ++ file=$1 ++ case $file in ++ / | /[!/]*) # absolute file, and not a UNC file ++ if test -z "$file_conv"; then ++ # lazily determine how to convert abs files ++ case `uname -s` in ++ MINGW*) ++ file_conv=mingw ++ ;; ++ CYGWIN*) ++ file_conv=cygwin ++ ;; ++ *) ++ file_conv=wine ++ ;; ++ esac ++ fi ++ case $file_conv in ++ mingw) ++ file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ++ ;; ++ cygwin) ++ file=`cygpath -m "$file" || echo "$file"` ++ ;; ++ wine) ++ file=`winepath -w "$file" || echo "$file"` ++ ;; ++ esac ++ ;; ++ esac ++} ++ ++# func_at_file at_file operation archive ++# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE ++# for each of them. ++# When interpreting the content of the @FILE, do NOT use func_file_conv, ++# since the user would need to supply preconverted file names to ++# binutils ar, at least for MinGW. ++func_at_file () ++{ ++ operation=$2 ++ archive=$3 ++ at_file_contents=`cat "$1"` ++ eval set x "$at_file_contents" ++ shift ++ ++ for member ++ do ++ $AR -NOLOGO $operation:"$member" "$archive" || exit $? ++ done ++} ++ ++case $1 in ++ '') ++ func_error "no command. Try '$0 --help' for more information." ++ ;; ++ -h | --h*) ++ cat < ++#endif ++ + /* TRANSLATORS: This is a non-ASCII name: The first name is (with + Unicode escapes) "Ren\u00e9" or (with HTML entities) "René". */ + #define AUTHORS proper_name_utf8 ("Rene' Seindal", "Ren\xC3\xA9 Seindal") +@@ -423,6 +427,15 @@ main (int argc, char *const *argv) + textdomain (PACKAGE); + atexit (close_stdin); + ++#ifdef _WIN32 ++ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); ++ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); ++ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); ++ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); ++ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); ++ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); ++#endif ++ + include_init (); + debug_init (); + diff --git a/recipes/m4/all/patches/1.4.19-0004-disable-hardening-in-source.patch b/recipes/m4/all/patches/1.4.19-0004-disable-hardening-in-source.patch new file mode 100644 index 0000000000000..9386ee55aedce --- /dev/null +++ b/recipes/m4/all/patches/1.4.19-0004-disable-hardening-in-source.patch @@ -0,0 +1,16 @@ +This requires linking to ssp on some systems, which might not always present. +If this is really desired: +* add `-lssp` to LDFLAGS, and +* add `-D_FORTIFY_SOURCE=2` to CPPFLAGS/CFLAGS + +--- a/lib/config.hin ++++ b/lib/config.hin +@@ -198,7 +198,7 @@ + /* Enable compile-time and run-time bounds-checking, and some warnings, + without upsetting newer glibc. */ + #if defined __OPTIMIZE__ && __OPTIMIZE__ +- # define _FORTIFY_SOURCE 2 ++ //# define _FORTIFY_SOURCE 2 + #endif + + diff --git a/recipes/m4/all/test_package/conanfile.py b/recipes/m4/all/test_package/conanfile.py index b6441b4953131..22e16b15f8118 100644 --- a/recipes/m4/all/test_package/conanfile.py +++ b/recipes/m4/all/test_package/conanfile.py @@ -1,43 +1,36 @@ -from conans import ConanFile, tools -from conans.errors import ConanException +from conan import ConanFile +from conan.tools.files import save from io import StringIO import os - - -M4_CONTENTS = """\ -m4_define(NAME1, `Harry, Jr.') -m4_define(NAME2, `Sally') -m4_define(MET, `$1 met $2') -MET(`NAME1', `NAME2') -""" +import textwrap class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" @property def _m4_input_path(self): return os.path.join(self.build_folder, "input.m4") def build_requirements(self): - if tools.os_info.is_windows: - self.build_requires("msys2/20200517") + self.tool_requires(self.tested_reference_str) def build(self): - tools.save(self._m4_input_path, M4_CONTENTS) + save(self, self._m4_input_path, textwrap.dedent("""\ + m4_define(NAME1, `Harry, Jr.') + m4_define(NAME2, `Sally') + m4_define(MET, `$1 met $2') + MET(`NAME1', `NAME2') + """)) def test(self): - m4_bin = tools.get_env("M4") - if m4_bin is None or not m4_bin.startswith(self.deps_cpp_info["m4"].rootpath): - raise ConanException("M4 environment variable not set") - - if not tools.cross_building(self.settings): - self.run("{} --version".format(m4_bin), run_environment=True) - self.run("{} -P {}".format(m4_bin, self._m4_input_path)) - - self.run("m4 -R {0}/frozen.m4f {0}/test.m4".format(self.source_folder), run_environment=True) + self.run("m4 --version") + self.run(f"m4 -P {self._m4_input_path}") - output = StringIO() - self.run("{} -P {}".format(m4_bin, self._m4_input_path), output=output) + self.run(f"m4 -R {self.source_folder}/frozen.m4f {self.source_folder}/test.m4") - assert "Harry, Jr. met Sally" in output.getvalue() + output = StringIO() + self.run(f"m4 -P {self._m4_input_path}", output=output) + assert "Harry, Jr. met Sally" in output.getvalue() diff --git a/recipes/m4/all/test_v1_package/conanfile.py b/recipes/m4/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..23409570c2d3d --- /dev/null +++ b/recipes/m4/all/test_v1_package/conanfile.py @@ -0,0 +1,41 @@ +from conans import ConanFile, tools +from conans.errors import ConanException +from io import StringIO +import os +import textwrap + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + @property + def _m4_input_path(self): + return os.path.join(self.build_folder, "input.m4") + + def build(self): + tools.save(self._m4_input_path, textwrap.dedent("""\ + m4_define(NAME1, `Harry, Jr.') + m4_define(NAME2, `Sally') + m4_define(MET, `$1 met $2') + MET(`NAME1', `NAME2') + """)) + + def test(self): + if hasattr(self, "settings_build"): + exe_suffix = ".exe" if self.settings.os == "Windows" else "" + m4_bin = os.path.join(self.deps_cpp_info["m4"].rootpath, "bin", "m4" + exe_suffix) + else: + m4_bin = tools.get_env("M4") + if m4_bin is None or not m4_bin.startswith(self.deps_cpp_info["m4"].rootpath): + raise ConanException("M4 environment variable not set") + + if not tools.cross_building(self, skip_x64_x86=True): + self.run("{} --version".format(m4_bin), run_environment=True) + self.run("{} -P {}".format(m4_bin, self._m4_input_path)) + + self.run("m4 -R {0}/frozen.m4f {0}/test.m4".format(os.path.join(self.source_folder, os.pardir, "test_package"), run_environment=True)) + + output = StringIO() + self.run("{} -P {}".format(m4_bin, self._m4_input_path), output=output) + + assert "Harry, Jr. met Sally" in output.getvalue() diff --git a/recipes/m4/config.yml b/recipes/m4/config.yml index 76bddfaab892d..d9912c96a2093 100644 --- a/recipes/m4/config.yml +++ b/recipes/m4/config.yml @@ -1,3 +1,5 @@ versions: + "1.4.19": + folder: all "1.4.18": folder: all diff --git a/recipes/maddy/all/conandata.yml b/recipes/maddy/all/conandata.yml new file mode 100644 index 0000000000000..91359378f2072 --- /dev/null +++ b/recipes/maddy/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.1.2": + sha256: ce66e1ee63bda3a6ab9c814edc0ed818abecca1c2218307ff87fb9ec1fc970fc + url: https://github.com/progsource/maddy/archive/refs/tags/1.1.2.tar.gz diff --git a/recipes/maddy/all/conanfile.py b/recipes/maddy/all/conanfile.py new file mode 100644 index 0000000000000..7bcdd1cec24d5 --- /dev/null +++ b/recipes/maddy/all/conanfile.py @@ -0,0 +1,47 @@ +from conans import ConanFile, tools +import os + +required_conan_version = ">=1.33.0" + + +class MaddyConan(ConanFile): + name = "maddy" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/progsource/maddy" + description = ( + "open-source, maddy is a C++ Markdown to HTML header-only parser library." + ) + topics = ("maddy", "markdown", "header-only") + license = "MIT" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 14) + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + destination=self._source_subfolder, + strip_root=True + ) + + def package_id(self): + self.info.header_only() + + def package(self): + self.copy( + "LICENSE", + src=os.path.join(self.source_folder, self._source_subfolder), + dst="licenses", + ) + self.copy( + pattern="maddy/*.h", + src=os.path.join(self.source_folder, self._source_subfolder, "include"), + dst="include", + ) diff --git a/recipes/maddy/all/test_package/CMakeLists.txt b/recipes/maddy/all/test_package/CMakeLists.txt new file mode 100755 index 0000000000000..b85bbd5581573 --- /dev/null +++ b/recipes/maddy/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.5) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(maddy REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} example.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE maddy::maddy) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14 CXX_STANDARD_REQUIRED + ON) diff --git a/recipes/maddy/all/test_package/conanfile.py b/recipes/maddy/all/test_package/conanfile.py new file mode 100755 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/maddy/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/maddy/all/test_package/example.cpp b/recipes/maddy/all/test_package/example.cpp new file mode 100755 index 0000000000000..9e6b905aef89e --- /dev/null +++ b/recipes/maddy/all/test_package/example.cpp @@ -0,0 +1,31 @@ +/* + * This example was copied from + * https://github.com/progsource/maddy/blob/master/README.md + */ + +#include +#include +#include +#include + +#include + +int main() { + std::stringstream markdownInput( + "# Hello world from maddy!\nVisit " + "[conan-center-index](https://github.com/conan-io/conan-center-index)\n"); + + // config is optional + std::shared_ptr config = + std::make_shared(); + config->isEmphasizedParserEnabled = true; // default + config->isHTMLWrappedInParagraph = true; // default + + std::shared_ptr parser = + std::make_shared(config); + std::string htmlOutput = parser->Parse(markdownInput); + + std::cout << "html:\n" << htmlOutput << "\n"; + + return EXIT_SUCCESS; +} diff --git a/recipes/maddy/config.yml b/recipes/maddy/config.yml new file mode 100644 index 0000000000000..8d13aefb6b4fb --- /dev/null +++ b/recipes/maddy/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.2": + folder: all diff --git a/recipes/magic_enum/all/conandata.yml b/recipes/magic_enum/all/conandata.yml index 48cbb96ef18b4..f1eb6c3e30073 100644 --- a/recipes/magic_enum/all/conandata.yml +++ b/recipes/magic_enum/all/conandata.yml @@ -14,3 +14,15 @@ sources: "0.7.2": url: "https://github.com/Neargye/magic_enum/archive/v0.7.2.tar.gz" sha256: "a77895ebc684f7a4dd2e4e06529b22e9ae694037f6dee0753d3ce0bbcd5b3e38" + "0.7.3": + url: "https://github.com/Neargye/magic_enum/archive/v0.7.3.tar.gz" + sha256: "b8d0cd848546fee136dc1fa4bb021a1e4dc8fe98e44d8c119faa3ef387636bf7" + "0.8.0": + url: "https://github.com/Neargye/magic_enum/archive/v0.8.0.tar.gz" + sha256: "5e7680e877dd4cf68d9d0c0e3c2a683b432a9ba84fc1993c4da3de70db894c3c" + "0.8.1": + url: "https://github.com/Neargye/magic_enum/archive/v0.8.1.tar.gz" + sha256: "6b948d1680f02542d651fc82154a9e136b341ce55c5bf300736b157e23f9df11" + "0.8.2": + url: "https://github.com/Neargye/magic_enum/archive/v0.8.2.tar.gz" + sha256: "62bd7034bbbfc3d7806001767d5775ab42f3ff33bb38366e1ceb21102f0dff9a" diff --git a/recipes/magic_enum/all/conanfile.py b/recipes/magic_enum/all/conanfile.py index 7a7a588bc110f..ad2dd7598a2f6 100644 --- a/recipes/magic_enum/all/conanfile.py +++ b/recipes/magic_enum/all/conanfile.py @@ -1,29 +1,31 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +required_conan_version = ">=1.50.0" + + class MagicEnumConan(ConanFile): name = "magic_enum" - description = "Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code." - topics = ( - "conan", - "cplusplus", - "enum-to-string", - "string-to-enum" - "serialization", - "reflection", - "header-only", - "compile-time" + description = ( + "Header-only C++17 library provides static reflection for enums, work " + "with any enum type without any macro or boilerplate code." ) - url = "https://github.com/conan-io/conan-center-index " + topics = ("cplusplus", "enum-to-string", "string-to-enum", "serialization", + "reflection", "header-only", "compile-time") + url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/Neargye/magic_enum" license = "MIT" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True @property - def _source_subfolder(self): - return "source_subfolder" + def _min_cppstd(self): + return "17" @property def _compilers_minimum_version(self): @@ -34,25 +36,36 @@ def _compilers_minimum_version(self): "apple-clang": "10", } - def configure(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "17") - minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if not minimum_version: - self.output.warn("magic_enum requires C++17. Your compiler is unknown. Assuming it supports C++17.") - elif tools.Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration("magic_enum: Unsupported compiler: {}-{} " - "(https://github.com/Neargye/magic_enum#compiler-compatibility)." - .format(self.settings.compiler, self.settings.compiler.version)) + def layout(self): + basic_layout(self, src_folder="src") def package_id(self): - self.info.header_only() + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.", + ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) - self.copy("LICENSE", dst="licenses" , src=self._source_subfolder) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "magic_enum") + self.cpp_info.set_property("cmake_target_name", "magic_enum::magic_enum") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/magic_enum/all/test_package/CMakeLists.txt b/recipes/magic_enum/all/test_package/CMakeLists.txt index 60591d4de621c..c185d76435a4f 100644 --- a/recipes/magic_enum/all/test_package/CMakeLists.txt +++ b/recipes/magic_enum/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ cmake_minimum_required(VERSION 3.8) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(magic_enum REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) -target_link_libraries(${PROJECT_NAME} magic_enum::magic_enum) +target_link_libraries(${PROJECT_NAME} PRIVATE magic_enum::magic_enum) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/magic_enum/all/test_package/conanfile.py b/recipes/magic_enum/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/magic_enum/all/test_package/conanfile.py +++ b/recipes/magic_enum/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/magic_enum/all/test_v1_package/CMakeLists.txt b/recipes/magic_enum/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..de886ea1bc291 --- /dev/null +++ b/recipes/magic_enum/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(magic_enum REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE magic_enum::magic_enum) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/magic_enum/all/test_v1_package/conanfile.py b/recipes/magic_enum/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/magic_enum/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/magic_enum/config.yml b/recipes/magic_enum/config.yml index 6979a6866d432..affbfa65ae445 100644 --- a/recipes/magic_enum/config.yml +++ b/recipes/magic_enum/config.yml @@ -9,3 +9,11 @@ versions: folder: all "0.7.2": folder: all + "0.7.3": + folder: all + "0.8.0": + folder: all + "0.8.1": + folder: all + "0.8.2": + folder: all diff --git a/recipes/magnum-extras/all/CMakeLists.txt b/recipes/magnum-extras/all/CMakeLists.txt new file mode 100644 index 0000000000000..08c7bbc0b05a4 --- /dev/null +++ b/recipes/magnum-extras/all/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/Magnum) +#set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/MagnumExternal) + +add_subdirectory("source_subfolder") diff --git a/recipes/magnum-extras/all/conandata.yml b/recipes/magnum-extras/all/conandata.yml new file mode 100644 index 0000000000000..beb3ab34a0599 --- /dev/null +++ b/recipes/magnum-extras/all/conandata.yml @@ -0,0 +1,11 @@ +sources: + "2020.06": + url: "https://github.com/mosra/magnum-extras/archive/refs/tags/v2020.06.tar.gz" + sha256: "a8d7babc50ac070984d39f6cc15c3ce2af7b41fe980fe81b0405da6f5ba3c36d" +patches: + "2020.06": + - base_path: "source_subfolder" + patch_file: "patches/2020.06/0001-emscripten-toolchain.patch" + # patch_type: "portability" + # description: "Remove unnecessary dependency on UseEmscripten" + # source: "https://github.com/mosra/magnum/issues/490" diff --git a/recipes/magnum-extras/all/conanfile.py b/recipes/magnum-extras/all/conanfile.py new file mode 100644 index 0000000000000..939aef0b5e69a --- /dev/null +++ b/recipes/magnum-extras/all/conanfile.py @@ -0,0 +1,144 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import functools +import os + +required_conan_version = ">=1.43.0" + + +class MagnumExtrasConan(ConanFile): + name = "magnum-extras" + description = "Extras for the Magnum C++11/C++14 graphics engine" + license = "MIT" + topics = ("magnum", "graphics", "rendering", "3d", "2d", "opengl") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://magnum.graphics" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "player": [True, False], + "ui": [True, False], + "ui_gallery": [True, False], + "application": ["android", "emscripten", "glfw", "glx", "sdl2", "xegl"], + } + default_options = { + "shared": False, + "fPIC": True, + "player": True, + "ui": True, + "ui_gallery": True, + "application": "sdl2", + } + + short_paths = True + generators = "cmake", "cmake_find_package" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + if self.settings.os == "Android": + self.options.application = "android" + if self.settings.os == "Emscripten": + self.options.application = "emscripten" + # FIXME: Requires 'magnum:basis_importer=True' + self.options.player = False + # FIXME: Fails to compile + self.options.ui_gallery = False + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("magnum/{}".format(self.version)) + self.requires("corrade/{}".format(self.version)) + if self.settings.os in ["iOS", "Emscripten", "Android"] and self.options.ui_gallery: + self.requires("magnum-plugins/{}".format(self.version)) + + def validate(self): + opt_name = "{}_application".format(self.options.application) + if not getattr(self.options["magnum"], opt_name): + raise ConanInvalidConfiguration("Magnum needs option '{opt}=True'".format(opt=opt_name)) + if self.settings.os == "Emscripten" and self.options["magnum"].target_gl == "gles2": + raise ConanInvalidConfiguration("OpenGL ES 3 required, use option 'magnum:target_gl=gles3'") + + def build_requirements(self): + self.build_requires("corrade/{}".format(self.version)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_STATIC"] = not self.options.shared + cmake.definitions["BUILD_STATIC_PIC"] = self.options.get_safe("fPIC", False) + cmake.definitions["BUILD_TESTS"] = False + cmake.definitions["BUILD_GL_TESTS"] = False + + cmake.definitions["WITH_PLAYER"] = self.options.player + cmake.definitions["WITH_UI"] = self.options.ui + cmake.definitions["WITH_UI_GALLERY"] = self.options.ui_gallery + + cmake.configure() + return cmake + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + 'set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})', + "") + + cmakelists = [os.path.join("src", "Magnum", "Ui", "CMakeLists.txt"), + os.path.join("src", "player","CMakeLists.txt")] + app_name = "{}Application".format("XEgl" if self.options.application == "xegl" else str(self.options.application).capitalize()) + for cmakelist in cmakelists: + tools.replace_in_file(os.path.join(self._source_subfolder, cmakelist), + "Magnum::Application", + "Magnum::{}".format(app_name)) + + def build(self): + self._patch_sources() + + cm = self._configure_cmake() + cm.build() + + def package(self): + cm = self._configure_cmake() + cm.install() + + tools.rmdir(os.path.join(self.package_folder, "share")) + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "MagnumExtras") + self.cpp_info.names["cmake_find_package"] = "MagnumExtras" + self.cpp_info.names["cmake_find_package_multi"] = "MagnumExtras" + + lib_suffix = "-d" if self.settings.build_type == "Debug" else "" + if self.options.ui: + self.cpp_info.components["ui"].set_property("cmake_target_name", "MagnumExtras::Ui") + self.cpp_info.components["ui"].names["cmake_find_package"] = "Ui" + self.cpp_info.components["ui"].names["cmake_find_package_multi"] = "Ui" + self.cpp_info.components["ui"].libs = ["MagnumUi{}".format(lib_suffix)] + self.cpp_info.components["ui"].requires = ["corrade::interconnect", "magnum::magnum_main", "magnum::gl", "magnum::text"] + + if self.options.player or self.options.ui_gallery: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info('Appending PATH environment variable: %s' % bin_path) + self.env_info.path.append(bin_path) diff --git a/recipes/magnum-extras/all/patches/2020.06/0001-emscripten-toolchain.patch b/recipes/magnum-extras/all/patches/2020.06/0001-emscripten-toolchain.patch new file mode 100644 index 0000000000000..8fab49087628a --- /dev/null +++ b/recipes/magnum-extras/all/patches/2020.06/0001-emscripten-toolchain.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e0e0eb7..65083df 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -58,10 +58,6 @@ if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) + set(BUILD_STATIC ON) + endif() + +-if(CORRADE_TARGET_EMSCRIPTEN) +- include(UseEmscripten) +-endif() +- + if(BUILD_TESTS) + find_package(Corrade REQUIRED TestSuite) + if(CORRADE_TARGET_IOS) diff --git a/recipes/magnum-extras/all/test_package/CMakeLists.txt b/recipes/magnum-extras/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..976323cbac9ea --- /dev/null +++ b/recipes/magnum-extras/all/test_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(MagnumExtras REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE MagnumExtras::Ui) +set_target_properties(${PROJECT_NAME} + PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) diff --git a/recipes/magnum-extras/all/test_package/conanfile.py b/recipes/magnum-extras/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b79eb4c726ded --- /dev/null +++ b/recipes/magnum-extras/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + if self.options["magnum-extras"].ui: + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + executable_ext = ".exe" if self.settings.os == "Windows" else "" + if self.options["magnum-extras"].player: + assert os.path.exists(os.path.join(self.deps_cpp_info["magnum-extras"].rootpath, "bin", "magnum-player{}".format(executable_ext))) + # (Cannot run in headless mode) self.run("magnum-player --help") + if self.options["magnum-extras"].ui_gallery: + assert os.path.exists(os.path.join(self.deps_cpp_info["magnum-extras"].rootpath, "bin", "magnum-ui-gallery{}".format(executable_ext))) + # (Cannot run in headless mode) self.run("magnum-ui-gallery --help") + if self.options["magnum-extras"].ui: + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/magnum-extras/all/test_package/test_package.cpp b/recipes/magnum-extras/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..299d3b5cdc511 --- /dev/null +++ b/recipes/magnum-extras/all/test_package/test_package.cpp @@ -0,0 +1,25 @@ +#include + +#include "Magnum/Ui/Anchor.h" +#include "Magnum/Ui/BasicPlane.hpp" +#include "Magnum/Ui/BasicUserInterface.hpp" + + +struct UserInterface: Magnum::Ui::BasicUserInterface<> { + using BasicUserInterface::BasicUserInterface; +}; + +struct Plane: Magnum::Ui::BasicPlane<> { + using BasicPlane::BasicPlane; +}; + + +int main() { + std::cout << "magnum-extras\n"; + + UserInterface ui{{800, 600}, {1600, 900}}; + Plane plane{ui, {Magnum::Ui::Snap::Left|Magnum::Ui::Snap::Top, {400.0f, 300.0f}}, {{10.0f, 25.0f}, {-15.0f, -5.0f}}, {7.0f, 3.0f}}; + + auto padding = plane.padding(); + Magnum::Debug{&std::cout} << padding; +} diff --git a/recipes/magnum-extras/config.yml b/recipes/magnum-extras/config.yml new file mode 100644 index 0000000000000..93230781a72ea --- /dev/null +++ b/recipes/magnum-extras/config.yml @@ -0,0 +1,3 @@ +versions: + "2020.06": + folder: all diff --git a/recipes/magnum-integration/all/CMakeLists.txt b/recipes/magnum-integration/all/CMakeLists.txt new file mode 100644 index 0000000000000..e0949ec4127c9 --- /dev/null +++ b/recipes/magnum-integration/all/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/Magnum) +set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/MagnumExternal) + +add_subdirectory("source_subfolder") diff --git a/recipes/magnum-integration/all/conandata.yml b/recipes/magnum-integration/all/conandata.yml new file mode 100644 index 0000000000000..4634cb503f8ce --- /dev/null +++ b/recipes/magnum-integration/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2020.06": + url: "https://github.com/mosra/magnum-integration/archive/refs/tags/v2020.06.tar.gz" + sha256: "4eb461e0a38d7be69a52b8faf7664493da4e4cabc2c4fa86bd672d2e8f0a9311" diff --git a/recipes/magnum-integration/all/conanfile.py b/recipes/magnum-integration/all/conanfile.py new file mode 100644 index 0000000000000..9bc11fde53f72 --- /dev/null +++ b/recipes/magnum-integration/all/conanfile.py @@ -0,0 +1,171 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration, ConanException +import functools +import os + +required_conan_version = ">=1.43.0" + + +class MagnumIntegrationConan(ConanFile): + name = "magnum-integration" + description = "Integration libraries for the Magnum C++11/C++14 graphics engine" + license = "MIT" + topics = ("magnum", "graphics", "rendering", "3d", "2d", "opengl") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://magnum.graphics" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_bullet": [True, False], + "with_dart": [True, False], + "with_eigen": [True, False], + "with_glm": [True, False], + "with_imgui": [True, False], + "with_ovr": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_bullet": True, + "with_dart": False, + "with_eigen": True, + "with_glm": True, + "with_imgui": True, + "with_ovr": False, + } + + exports_sources = "CMakeLists.txt" + generators = "cmake", "cmake_find_package" + short_paths = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("magnum/{}".format(self.version)) + if self.options.with_bullet: + self.requires("bullet3/3.22a") + if self.options.with_eigen: + self.requires("eigen/3.4.0") + if self.options.with_glm: + self.requires("glm/0.9.9.8") + if self.options.with_imgui: + self.requires("imgui/1.87") + + def validate(self): + if self.options.with_dart: + # FIXME: Add 'dart' requirement + raise ConanInvalidConfiguration("DART library is not available in ConanCenter (yet)") + if self.options.with_ovr: + # FIXME: Add 'ovr' requirement + raise ConanInvalidConfiguration("OVR library is not available in ConanCenter (yet)") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_STATIC"] = not self.options.shared + cmake.definitions["BUILD_STATIC_PIC"] = self.options.get_safe("fPIC", True) + cmake.definitions["BUILD_TESTS"] = False + cmake.definitions["BUILD_GL_TESTS"] = False + + cmake.definitions["WITH_BULLET"] = self.options.with_bullet + cmake.definitions["WITH_DART"] = self.options.with_dart + cmake.definitions["WITH_EIGEN"] = self.options.with_eigen + cmake.definitions["WITH_GLM"] = self.options.with_glm + cmake.definitions["WITH_IMGUI"] = self.options.with_imgui + cmake.definitions["WITH_OVR"] = self.options.with_ovr + + cmake.configure() + return cmake + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + 'set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})', + "") + # Casing + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "GlmIntegration", "CMakeLists.txt"), + "find_package(GLM REQUIRED)", + "find_package(glm REQUIRED)") + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "GlmIntegration", "CMakeLists.txt"), + "GLM::GLM", + "glm::glm") + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "ImGuiIntegration", "CMakeLists.txt"), + "find_package(ImGui REQUIRED Sources)", + "find_package(imgui REQUIRED Sources)") + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "ImGuiIntegration", "CMakeLists.txt"), + "ImGui::ImGui", + "imgui::imgui") + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "ImGuiIntegration", "CMakeLists.txt"), + "ImGui::Sources", + "") + + def build(self): + self._patch_sources() + + cm = self._configure_cmake() + cm.build() + + def package(self): + cm = self._configure_cmake() + cm.install() + + tools.rmdir(os.path.join(self.package_folder, "share")) + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "MagnumIntegration") + self.cpp_info.names["cmake_find_package"] = "MagnumIntegration" + self.cpp_info.names["cmake_find_package_multi"] = "MagnumIntegration" + + lib_suffix = "-d" if self.settings.build_type == "Debug" else "" + + if self.options.with_bullet: + self.cpp_info.components["bullet"].set_property("cmake_target_name", "MagnumIntegration::Bullet") + self.cpp_info.components["bullet"].names["cmake_find_package"] = "Bullet" + self.cpp_info.components["bullet"].names["cmake_find_package_multi"] = "Bullet" + self.cpp_info.components["bullet"].libs = ["MagnumBulletIntegration{}".format(lib_suffix)] + self.cpp_info.components["bullet"].requires = ["magnum::magnum_main", "magnum::gl", "magnum::shaders", "bullet3::bullet3"] + + if self.options.with_dart: + raise ConanException("Recipe doesn't define this component 'dart'. Please contribute it") + + if self.options.with_eigen: + self.cpp_info.components["eigen"].set_property("cmake_target_name", "MagnumIntegration::Eigen") + self.cpp_info.components["eigen"].names["cmake_find_package"] = "Eigen" + self.cpp_info.components["eigen"].names["cmake_find_package_multi"] = "Eigen" + self.cpp_info.components["eigen"].requires = ["magnum::magnum_main", "eigen::eigen"] + + if self.options.with_glm: + self.cpp_info.components["glm"].set_property("cmake_target_name", "MagnumIntegration::Glm") + self.cpp_info.components["glm"].names["cmake_find_package"] = "Glm" + self.cpp_info.components["glm"].names["cmake_find_package_multi"] = "Glm" + self.cpp_info.components["glm"].libs = ["MagnumGlmIntegration{}".format(lib_suffix)] + self.cpp_info.components["glm"].requires = ["magnum::magnum_main", "glm::glm"] + + if self.options.with_imgui: + self.cpp_info.components["imgui"].set_property("cmake_target_name", "MagnumIntegration::ImGui") + self.cpp_info.components["imgui"].names["cmake_find_package"] = "ImGui" + self.cpp_info.components["imgui"].names["cmake_find_package_multi"] = "ImGui" + self.cpp_info.components["imgui"].libs = ["MagnumImGuiIntegration{}".format(lib_suffix)] + self.cpp_info.components["imgui"].requires = ["magnum::magnum_main", "magnum::gl", "magnum::shaders", "imgui::imgui"] + + if self.options.with_ovr: + raise ConanException("Recipe doesn't define this component 'ovr'. Please contribute it") diff --git a/recipes/magnum-integration/all/test_package/CMakeLists.txt b/recipes/magnum-integration/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2f483ffbe1392 --- /dev/null +++ b/recipes/magnum-integration/all/test_package/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.11) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(MagnumIntegration REQUIRED) +set(CMAKE_CXX_STANDARD 11) + +add_executable(${PROJECT_NAME} test_package.cpp) +if(WITH_BULLET) + target_link_libraries(${PROJECT_NAME} PRIVATE MagnumIntegration::Bullet) + target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_BULLET) +endif() +if(WITH_DART) + message(FATAL_ERROR "Please, add test with DART") + target_link_libraries(${PROJECT_NAME} PRIVATE MagnumIntegration::Dart) + target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_DART) +endif() +if(WITH_EIGEN) + target_link_libraries(${PROJECT_NAME} PRIVATE MagnumIntegration::Eigen) + target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_EIGEN) +endif() +if(WITH_GLM) + target_link_libraries(${PROJECT_NAME} PRIVATE MagnumIntegration::Glm) + target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_GLM) +endif() +if(WITH_IMGUI) + target_link_libraries(${PROJECT_NAME} PRIVATE MagnumIntegration::ImGui) + target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_IMGUI) +endif() +if(WITH_OVR) + message(FATAL_ERROR "Please, add test with OVR") + target_link_libraries(${PROJECT_NAME} PRIVATE MagnumIntegration::Ovr) + target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_OVR) +endif() diff --git a/recipes/magnum-integration/all/test_package/conanfile.py b/recipes/magnum-integration/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1d2d6f7e65f70 --- /dev/null +++ b/recipes/magnum-integration/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +import os +from conans import ConanFile, CMake, tools + +class TestPackage(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.definitions["WITH_BULLET"] = self.options["magnum-integration"].with_bullet + cmake.definitions["WITH_DART"] = self.options["magnum-integration"].with_dart + cmake.definitions["WITH_EIGEN"] = self.options["magnum-integration"].with_eigen + cmake.definitions["WITH_GLM"] = self.options["magnum-integration"].with_glm + cmake.definitions["WITH_IMGUI"] = self.options["magnum-integration"].with_imgui + cmake.definitions["WITH_OVR"] = self.options["magnum-integration"].with_ovr + cmake.configure() + cmake.build() + + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + + if self.settings.os == "Emscripten": + bin_path = os.path.join("bin", "test_package.js") + self.run("node {}".format(bin_path), run_environment=True) diff --git a/recipes/magnum-integration/all/test_package/test_package.cpp b/recipes/magnum-integration/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..afd2f2d68e6f6 --- /dev/null +++ b/recipes/magnum-integration/all/test_package/test_package.cpp @@ -0,0 +1,72 @@ + +#include +#include + +#ifdef WITH_BULLET + #include "Magnum/BulletIntegration/Integration.h" + + void with_bullet() { + std::cout << "With Bullet\n"; + Magnum::Math::Vector3 a{btScalar(1.0), btScalar(2.0), btScalar(3.0)}; + btVector3 b{btScalar(1.0), btScalar(2.0), btScalar(3.0)}; + assert(Magnum::Math::Vector3{b} == a); + } +#endif + +#ifdef WITH_EIGEN + #include + #include "Magnum/EigenIntegration/Integration.h" + + void with_eigen() { + std::cout << "With Eigen\n"; + Magnum::Math::Quaternion q{}; + Eigen::Quaternion eq{q.scalar(), q.vector().x(), q.vector().y(), q.vector().z()}; + } +#endif + +#ifdef WITH_GLM + #include "Magnum/Magnum.h" + #include "Magnum/Math/Matrix3.h" + #include "Magnum/Math/Matrix4.h" + #include "Magnum/GlmIntegration/Integration.h" + + void with_glm() { + std::cout << "With GLM\n"; + Magnum::Math::BoolVector<2> a{0x6}; + glm::bvec2 b{false, true}; + assert(glm::bvec2(a) == b); + } +#endif + +#ifdef WITH_IMGUI + #include + #include + #include "Magnum/ImGuiIntegration/Integration.h" + + void with_imgui() { + std::cout << "With ImGui\n"; + ImVec2 imVec2{1.1f, 1.2f}; + Magnum::Vector2 vec2(1.1f, 1.2f); + assert(Magnum::Vector2{imVec2} == vec2); + } +#endif + +int main() { + #ifdef WITH_BULLET + with_bullet(); + #endif + + #ifdef WITH_EIGEN + with_eigen(); + #endif + + #ifdef WITH_GLM + with_glm(); + #endif + + #ifdef WITH_IMGUI + with_imgui(); + #endif + + return 0; +} diff --git a/recipes/magnum-integration/config.yml b/recipes/magnum-integration/config.yml new file mode 100644 index 0000000000000..93230781a72ea --- /dev/null +++ b/recipes/magnum-integration/config.yml @@ -0,0 +1,3 @@ +versions: + "2020.06": + folder: all diff --git a/recipes/magnum-plugins/all/CMakeLists.txt b/recipes/magnum-plugins/all/CMakeLists.txt new file mode 100644 index 0000000000000..315c0afaf5005 --- /dev/null +++ b/recipes/magnum-plugins/all/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +set(CONAN_CMAKE_SILENT_OUTPUT 1) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +# The original project uses the path to the 'magnum' package, in Conan we cannot modify existing package +set(MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/magnum-d) +set(MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/magnum-d) +set(MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/magnum) +set(MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/magnum) +set(MAGNUM_PLUGINS_FONT_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/fonts) +set(MAGNUM_PLUGINS_FONT_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/fonts) +set(MAGNUM_PLUGINS_FONT_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/fonts) +set(MAGNUM_PLUGINS_FONT_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/fonts) +set(MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/fontconverters) +set(MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/fontconverters) +set(MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/imageconverters) +set(MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/imageconverters) +set(MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/imageconverters) +set(MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/imageconverters) +set(MAGNUM_PLUGINS_IMPORTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/importers) +set(MAGNUM_PLUGINS_IMPORTER_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/importers) +set(MAGNUM_PLUGINS_IMPORTER_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/importers) +set(MAGNUM_PLUGINS_IMPORTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/importers) +set(MAGNUM_PLUGINS_SCENECONVERTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/sceneconverters) +set(MAGNUM_PLUGINS_SCENECONVERTER_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/sceneconverters) +set(MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/sceneconverters) +set(MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/sceneconverters) +set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/audioimporters) +set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/audioimporters) +set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/audioimporters) +set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/audioimporters) + +set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/Magnum) +set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/MagnumExternal) +set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/MagnumPlugins) + +add_subdirectory("source_subfolder") diff --git a/recipes/magnum-plugins/all/cmake/conan-bugfix-global-target.cmake b/recipes/magnum-plugins/all/cmake/conan-bugfix-global-target.cmake new file mode 100644 index 0000000000000..c0510f74c3f8b --- /dev/null +++ b/recipes/magnum-plugins/all/cmake/conan-bugfix-global-target.cmake @@ -0,0 +1,24 @@ +# If using 'cmake_find_package', all the components are being added to the global +# target unconditionally. See generated FindMagnumPlugins.cmake file: +# +# if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0") +# if(NOT TARGET MagnumPlugins::MagnumPlugins) +# add_library(MagnumPlugins::MagnumPlugins INTERFACE IMPORTED) +# endif() +# set_property(TARGET MagnumPlugins::MagnumPlugins APPEND PROPERTY +# INTERFACE_LINK_LIBRARIES "${MagnumPlugins_COMPONENTS}") +# endif() +# +# but it doesn't add the library directories and the linker will fail. +# +# Here we fix this bug (breaking change) for this recipe, we just override +# the list of targets again. +# + + +if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0") + if(TARGET MagnumPlugins::MagnumPlugins) + set_target_properties(MagnumPlugins::MagnumPlugins PROPERTIES INTERFACE_LINK_LIBRARIES + "${MagnumPlugins_MagnumPlugins_LINK_LIBS};${MagnumPlugins_MagnumPlugins_LINKER_FLAGS_LIST}") + endif() +endif() diff --git a/recipes/magnum-plugins/all/conandata.yml b/recipes/magnum-plugins/all/conandata.yml new file mode 100644 index 0000000000000..1d75399fc10a4 --- /dev/null +++ b/recipes/magnum-plugins/all/conandata.yml @@ -0,0 +1,11 @@ +sources: + "2020.06": + url: "https://github.com/mosra/magnum-plugins/archive/refs/tags/v2020.06.tar.gz" + sha256: "8650cab43570c826d2557d5b42459150d253316f7f734af8b3e7d0883510b40a" +patches: + "2020.06": + - base_path: "source_subfolder" + patch_file: "patches/2020.06/0001-emscripten-toolchain.patch" + # patch_type: "portability" + # description: "Remove unnecessary dependency on UseEmscripten" + # source: "https://github.com/mosra/magnum/issues/490" diff --git a/recipes/magnum-plugins/all/conanfile.py b/recipes/magnum-plugins/all/conanfile.py new file mode 100644 index 0000000000000..e321f11942dac --- /dev/null +++ b/recipes/magnum-plugins/all/conanfile.py @@ -0,0 +1,323 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration, ConanException +import os +import textwrap + +required_conan_version = ">=1.33.0" + + +class MagnumConan(ConanFile): + name = "magnum-plugins" + description = "Plugins for the Magnum C++11/C++14 graphics engine" + license = "MIT" + topics = ("magnum", "graphics", "rendering", "3d", "2d", "opengl") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://magnum.graphics" + + settings = "os", "compiler", "build_type", "arch" + + options = { + "shared": [True, False], + "fPIC": [True, False], + "shared_plugins": [True, False], + + "assimp_importer": [True, False], + "basis_imageconverter": [True, False], + "basis_importer": [True, False], + "dds_importer": [True, False], + "devil_imageimporter": [True, False], + "drflac_audioimporter": [True, False], + "drmp3_audioimporter": [True, False], + "drwav_audioimporter": [True, False], + "faad2_audioimporter": [True, False], + "freetype_font": [True, False], + "harfbuzz_font": [True, False], + "ico_importer": [True, False], + "jpeg_imageconverter": [True, False], + "jpeg_importer": [True, False], + "meshoptimizer_sceneconverter": [True, False], + "miniexr_imageconverter": [True, False], + "opengex_importer": [True, False], + "png_imageconverter": [True, False], + "png_importer": [True, False], + "primitive_importer": [True, False], + "stanford_importer": [True, False], + "stanford_sceneconverter": [True, False], + "stb_imageconverter": [True, False], + "stb_imageimporter": [True, False], + "stbtruetype_font": [True, False], + "stbvorbis_audioimporter": [True, False], + "stl_importer": [True, False], + "tinygltf_importer": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "shared_plugins": True, + + "assimp_importer": True, + "basis_imageconverter": False, + "basis_importer": False, + "dds_importer": True, + "devil_imageimporter": False, + "drflac_audioimporter": True, + "drmp3_audioimporter": True, + "drwav_audioimporter": True, + "faad2_audioimporter": False, + "freetype_font": True, + "harfbuzz_font": True, + "ico_importer": True, + "jpeg_imageconverter": True, + "jpeg_importer": True, + "meshoptimizer_sceneconverter": True, + "miniexr_imageconverter": True, + "opengex_importer": True, + "png_imageconverter": True, + "png_importer": True, + "primitive_importer": True, + "stanford_importer": True, + "stanford_sceneconverter": True, + "stb_imageconverter": True, + "stb_imageimporter": True, + "stbtruetype_font": True, + "stbvorbis_audioimporter": True, + "stl_importer": True, + "tinygltf_importer": True, + } + generators = "cmake", "cmake_find_package", "cmake_find_package_multi" + exports_sources = ["CMakeLists.txt", "cmake/*", "patches/*"] + + _cmake = None + short_paths = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + 'set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})', + "") + assimp_importer_cmake_file = os.path.join(self._source_subfolder, "src", "MagnumPlugins", "AssimpImporter", "CMakeLists.txt") + tools.replace_in_file(assimp_importer_cmake_file, + "find_package(Assimp REQUIRED)", + "find_package(assimp REQUIRED)") + tools.replace_in_file(assimp_importer_cmake_file, + "Assimp::Assimp", + "assimp::assimp") + + harfbuzz_cmake_file = os.path.join(self._source_subfolder, "src", "MagnumPlugins", "HarfBuzzFont", "CMakeLists.txt") + tools.replace_in_file(harfbuzz_cmake_file, + "find_package(HarfBuzz REQUIRED)", + "find_package(harfbuzz REQUIRED)") + tools.replace_in_file(harfbuzz_cmake_file, + "HarfBuzz::HarfBuzz", + "harfbuzz::harfbuzz") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + if self.settings.os == "Emscripten": + self.options.shared_plugins = False + # FIXME: Transitive dep 'glib' is not prepared for Emscripten (https://github.com/emscripten-core/emscripten/issues/11066) + self.options.harfbuzz_font = False + # Audio is not provided by Magnum + self.options.drflac_audioimporter = False + self.options.drmp3_audioimporter = False + self.options.drwav_audioimporter = False + self.options.faad2_audioimporter = False + self.options.stbvorbis_audioimporter = False + # FIXME: Conan package fails for 'brotli' + self.options.freetype_font = False + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("magnum/{}".format(self.version)) + if self.options.assimp_importer: + self.requires("assimp/5.0.1") + if self.options.harfbuzz_font: + self.requires("harfbuzz/2.8.2") + if self.options.freetype_font: + self.requires("freetype/2.11.0") + if self.options.jpeg_importer or self.options.jpeg_imageconverter: + self.requires("libjpeg/9d") + if self.options.meshoptimizer_sceneconverter: + self.requires("meshoptimizer/0.15") + if self.options.png_imageconverter: + self.requires("libpng/1.6.37") + if self.options.basis_imageconverter or self.options.basis_importer: + raise ConanInvalidConfiguration("Requires 'basisuniversal', not available in ConanCenter yet") + if self.options.devil_imageimporter: + raise ConanInvalidConfiguration("Requires 'DevIL', not available in ConanCenter yet") + if self.options.faad2_audioimporter: + raise ConanInvalidConfiguration("Requires 'faad2', not available in ConanCenter yet") + + def build_requirements(self): + self.build_requires("corrade/{}".format(self.version)) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + if not self.options["magnum"].trade: + raise ConanInvalidConfiguration("Magnum Trade is required") + + # TODO: There are lot of things to check here: 'magnum::audio' required for audio plugins... + + def _configure_cmake(self): + if self._cmake: + return self._cmake + + self._cmake = CMake(self) + self._cmake.definitions["BUILD_STATIC"] = not self.options.shared + self._cmake.definitions["BUILD_STATIC_PIC"] = self.options.get_safe("fPIC", False) + self._cmake.definitions["BUILD_PLUGINS_STATIC"] = not self.options.shared_plugins + self._cmake.definitions["LIB_SUFFIX"] = "" + self._cmake.definitions["BUILD_TESTS"] = False + + self._cmake.definitions["WITH_ASSIMPIMPORTER"] = self.options.assimp_importer + self._cmake.definitions["WITH_BASISIMAGECONVERTER"] = self.options.basis_imageconverter + self._cmake.definitions["WITH_BASISIMPORTER"] = self.options.basis_importer + self._cmake.definitions["WITH_DDSIMPORTER"] = self.options.dds_importer + self._cmake.definitions["WITH_DEVILIMAGEIMPORTER"] = self.options.devil_imageimporter + self._cmake.definitions["WITH_DRFLACAUDIOIMPORTER"] = self.options.drflac_audioimporter + self._cmake.definitions["WITH_DRMP3AUDIOIMPORTER"] = self.options.drmp3_audioimporter + self._cmake.definitions["WITH_DRWAVAUDIOIMPORTER"] = self.options.drwav_audioimporter + self._cmake.definitions["WITH_FAAD2AUDIOIMPORTER"] = self.options.faad2_audioimporter + self._cmake.definitions["WITH_FREETYPEFONT"] = self.options.freetype_font + self._cmake.definitions["WITH_HARFBUZZFONT"] = self.options.harfbuzz_font + self._cmake.definitions["WITH_ICOIMPORTER"] = self.options.ico_importer + self._cmake.definitions["WITH_JPEGIMAGECONVERTER"] = self.options.jpeg_imageconverter + self._cmake.definitions["WITH_JPEGIMPORTER"] = self.options.jpeg_importer + self._cmake.definitions["WITH_MESHOPTIMIZERSCENECONVERTER"] = self.options.meshoptimizer_sceneconverter + self._cmake.definitions["WITH_MINIEXRIMAGECONVERTER"] = self.options.miniexr_imageconverter + self._cmake.definitions["WITH_OPENGEXIMPORTER"] = self.options.opengex_importer + self._cmake.definitions["WITH_PNGIMAGECONVERTER"] = self.options.png_imageconverter + self._cmake.definitions["WITH_PNGIMPORTER"] = self.options.png_importer + self._cmake.definitions["WITH_PRIMITIVEIMPORTER"] = self.options.primitive_importer + self._cmake.definitions["WITH_STANFORDIMPORTER"] = self.options.stanford_importer + self._cmake.definitions["WITH_STANFORDSCENECONVERTER"] = self.options.stanford_sceneconverter + self._cmake.definitions["WITH_STBIMAGECONVERTER"] = self.options.stb_imageconverter + self._cmake.definitions["WITH_STBIMAGEIMPORTER"] = self.options.stb_imageimporter + self._cmake.definitions["WITH_STBTRUETYPEFONT"] = self.options.stbtruetype_font + self._cmake.definitions["WITH_STBVORBISAUDIOIMPORTER"] = self.options.stbvorbis_audioimporter + self._cmake.definitions["WITH_STLIMPORTER"] = self.options.stl_importer + self._cmake.definitions["WITH_TINYGLTFIMPORTER"] = self.options.tinygltf_importer + + self._cmake.configure() + return self._cmake + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def build(self): + self._patch_sources() + + cm = self._configure_cmake() + cm.build() + + def package(self): + cm = self._configure_cmake() + cm.install() + + if not self.options.shared_plugins: + build_modules_folder = os.path.join(self.package_folder, "lib", "cmake") + os.makedirs(build_modules_folder) + for component, target, library, folder, deps in self._plugins: + build_module_path = os.path.join(build_modules_folder, "conan-magnum-plugins-{}.cmake".format(component)) + with open(build_module_path, "w+") as f: + f.write(textwrap.dedent("""\ + if(NOT ${{CMAKE_VERSION}} VERSION_LESS "3.0") + if(TARGET MagnumPlugins::{target}) + set_target_properties(MagnumPlugins::{target} PROPERTIES INTERFACE_SOURCES + "${{CMAKE_CURRENT_LIST_DIR}}/../../include/MagnumPlugins/{library}/importStaticPlugin.cpp") + endif() + endif() + """.format(target=target, library=library))) + + tools.rmdir(os.path.join(self.package_folder, "share")) + self.copy("*.cmake", src=os.path.join(self.source_folder, "cmake"), dst=os.path.join("lib", "cmake")) + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "MagnumPlugins" + self.cpp_info.names["cmake_find_package_multi"] = "MagnumPlugins" + + magnum_plugin_libdir = "magnum-d" if self.settings.build_type == "Debug" and self.options.shared_plugins else "magnum" + plugin_lib_suffix = "-d" if self.settings.build_type == "Debug" and not self.options.shared_plugins else "" + lib_suffix = "-d" if self.settings.build_type == "Debug" else "" + + self.cpp_info.components["magnumopenddl"].names["cmake_find_package"] = "MagnumOpenDdl" + self.cpp_info.components["magnumopenddl"].names["cmake_find_package_multi"] = "MagnumOpenDdl" + self.cpp_info.components["magnumopenddl"].libs = ["MagnumOpenDdl{}".format(lib_suffix)] + self.cpp_info.components["magnumopenddl"].requires = ["magnum::magnum"] + + # Plugins + if self.options.basis_imageconverter: + raise ConanException("Component not defined, please contribute it to the Conan recipe") + + if self.options.basis_importer: + raise ConanException("Component not defined, please contribute it to the Conan recipe") + + if self.options.devil_imageimporter: + raise ConanException("Component not defined, please contribute it to the Conan recipe") + + if self.options.faad2_audioimporter: + raise ConanException("Component not defined, please contribute it to the Conan recipe") + + # The global target doesn't provide anything in this package. Null it. + self.cpp_info.components["_global_target"].names["cmake_find_package"] = "MagnumPlugins" + self.cpp_info.components["_global_target"].names["cmake_find_package_multi"] = "MagnumPlugins" + self.cpp_info.components["_global_target"].build_modules["cmake_find_package"].append(os.path.join("lib", "cmake", "conan-bugfix-global-target.cmake")) + + # Add all the plugins + for component, target, library, folder, deps in self._plugins: + self.cpp_info.components[component].names["cmake_find_package"] = target + self.cpp_info.components[component].names["cmake_find_package_multi"] = target + self.cpp_info.components[component].libs = ["{}{}".format(library, plugin_lib_suffix)] + self.cpp_info.components[component].libdirs = [os.path.join(self.package_folder, "lib", magnum_plugin_libdir, folder)] + self.cpp_info.components[component].requires = deps + if not self.options.shared_plugins: + self.cpp_info.components[component].build_modules.append(os.path.join("lib", "cmake", "conan-magnum-plugins-{}.cmake".format(component))) + plugin_dir = "bin" if self.settings.os == "Windows" else "lib" + self.user_info.plugins_basepath = os.path.join(self.package_folder, plugin_dir, magnum_plugin_libdir) + + @property + def _plugins(self): + # (opt_name, (component, target, library, folder, deps)) + all_plugins = ( + ("assimp_importer", ("assimp_importer", "AssimpImporter", "AssimpImporter", "importers", ["magnum::trade", "assimp::assimp"])), + ("basis_imageconverter", ("basis_imageconverter", "--", "--", "--", [])), + ("basis_importer", ("basis_importer", "--", "--", "--", [])), + ("dds_importer", ("dds_importer", "DdsImporter", "DdsImporter", "importers", ["magnum::trade"])), + ("devil_imageimporter", ("devil_imageimporter", "--", "--", "--", [])), + ("drflac_audioimporter", ("drflac_audioimporter", "DrFlacAudioImporter", "DrFlacAudioImporter", "audioimporters", ["magnum::audio"])), + ("drmp3_audioimporter", ("drmp3_audioimporter", "DrMp3AudioImporter", "DrMp3AudioImporter", "audioimporters", ["magnum::audio"])), + ("drwav_audioimporter", ("drwav_audioimporter", "DrWavAudioImporter", "DrWavAudioImporter", "audioimporters", ["magnum::audio"])), + ("faad2_audioimporter", ("faad2_audioimporter", "--", "--", "--", [])), + ("freetype_font", ("freetype_font", "FreeTypeFont", "FreeTypeFont", "fonts", ["magnum::text", "freetype::freetype"])), + ("harfbuzz_font", ("harfbuzz_font", "HarfBuzzFont", "HarfBuzzFont", "fonts", ["magnum::text", "harfbuzz::harfbuzz"])), + ("jpeg_imageconverter", ("jpeg_imageconverter", "JpegImageConverter", "JpegImageConverter", "imageconverters", ["magnum::trade", "libjpeg::libjpeg"])), + ("jpeg_importer", ("jpeg_importer", "JpegImporter", "JpegImporter", "importers", ["magnum::trade", "libjpeg::libjpeg"])), + ("meshoptimizer_sceneconverter", ("meshoptimizer_sceneconverter", "MeshOptimizerSceneConverter", "MeshOptimizerSceneConverter", "sceneconverters", ["magnum::trade", "magnum::mesh_tools", "meshoptimizer::meshoptimizer"])), + ("miniexr_imageconverter", ("miniexr_imageconverter", "MiniExrImageConverter", "MiniExrImageConverter", "imageconverters", ["magnum::trade"])), + ("opengex_importer", ("opengex_importer", "OpenGexImporter", "OpenGexImporter", "importers", ["magnum::trade", "magnumopenddl", "magnum::any_image_importer"])), + ("png_importer", ("png_importer", "PngImporter", "PngImporter", "importers", ["magnum::trade", "libpng::libpng"])), + ("png_imageconverter", ("png_imageconverter", "PngImageConverter", "PngImageConverter", "imageconverters", ["magnum::trade"])), + ("primitive_importer", ("primitive_importer", "PrimitiveImporter", "PrimitiveImporter", "importers", ["magnum::primitives", "magnum::trade"])), + ("stanford_importer", ("stanford_importer", "StanfordImporter", "StanfordImporter", "importers", ["magnum::mesh_tools", "magnum::trade"])), + ("stanford_sceneconverter", ("stanford_sceneconverter", "StanfordSceneConverter", "StanfordSceneConverter", "sceneconverters", ["magnum::mesh_tools", "magnum::trade"])), + ("stb_imageconverter", ("stb_imageconverter", "StbImageConverter", "StbImageConverter", "imageconverters", ["magnum::trade"])), + ("stb_imageimporter", ("stb_imageimporter", "StbImageImporter", "StbImageImporter", "importers", ["magnum::trade"])), + ("stbtruetype_font", ("stbtruetype_font", "StbTrueTypeFont", "StbTrueTypeFont", "fonts", ["magnum::text"])), + ("stbvorbis_audioimporter", ("stbvorbis_audioimporter", "StbVorbisAudioImporter", "StbVorbisAudioImporter", "audioimporters", ["magnum::audio"])), + ("tinygltf_importer", ("tinygltf_importer", "TinyGltfImporter", "TinyGltfImporter", "importers", ["magnum::trade", "magnum::any_image_importer"])), + ("stl_importer", ("stl_importer", "StlImporter", "StlImporter", "importers", ["magnum::mesh_tools", "magnum::trade"])), + ) + return [plugin for opt_name, plugin in all_plugins if self.options.get_safe(opt_name)] diff --git a/recipes/magnum-plugins/all/patches/2020.06/0001-emscripten-toolchain.patch b/recipes/magnum-plugins/all/patches/2020.06/0001-emscripten-toolchain.patch new file mode 100644 index 0000000000000..8f3c18b38cd2e --- /dev/null +++ b/recipes/magnum-plugins/all/patches/2020.06/0001-emscripten-toolchain.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c85f70c..217427f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -91,10 +91,6 @@ elseif(CORRADE_TARGET_IOS OR CORRADE_TARGET_WINDOWS_RT) + set(BUILD_PLUGINS_STATIC ON) + endif() + +-if(CORRADE_TARGET_EMSCRIPTEN) +- include(UseEmscripten) +-endif() +- + if(BUILD_TESTS) + find_package(Corrade REQUIRED TestSuite) + if(CORRADE_TARGET_IOS) diff --git a/recipes/magnum-plugins/all/test_package/CMakeLists.txt b/recipes/magnum-plugins/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3ae91f1bb266f --- /dev/null +++ b/recipes/magnum-plugins/all/test_package/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.11) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +if(SHARED_PLUGINS) + find_package(MagnumPlugins REQUIRED) +else() + find_package(MagnumPlugins REQUIRED StlImporter) +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.in + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + +add_executable(${PROJECT_NAME} test_package.cpp) +# Intentionally linking with the global 'MagnumPlugins::MagnumPlugins' target, I want to check it is a valid target (although it might be empty) +target_link_libraries(${PROJECT_NAME} PRIVATE Magnum::Trade MagnumPlugins::MagnumPlugins) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +if(NOT SHARED_PLUGINS) + target_link_libraries(${PROJECT_NAME} PRIVATE MagnumPlugins::StlImporter) +endif() +set_target_properties(${PROJECT_NAME} + PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) + +if(TARGET_EMSCRIPTEN) + message("Embed OBJ file") + set_target_properties(${PROJECT_NAME} + PROPERTIES + LINK_FLAGS "--embed-file ${CONAN_STL_FILE}@${CONAN_STL_FILE}" + ) +endif() diff --git a/recipes/magnum-plugins/all/test_package/conan.stl b/recipes/magnum-plugins/all/test_package/conan.stl new file mode 100644 index 0000000000000..2c3b057418d79 Binary files /dev/null and b/recipes/magnum-plugins/all/test_package/conan.stl differ diff --git a/recipes/magnum-plugins/all/test_package/conanfile.py b/recipes/magnum-plugins/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0f32ed1a04aad --- /dev/null +++ b/recipes/magnum-plugins/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +import os +from conans import ConanFile, CMake, tools + +class TestPackage(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.definitions["IMPORTER_PLUGINS_FOLDER"] = os.path.join(self.deps_user_info["magnum-plugins"].plugins_basepath, "importers").replace("\\", "/") + # STL file taken from https://www.thingiverse.com/thing:2798332 + cmake.definitions["CONAN_STL_FILE"] = os.path.join(self.source_folder, "conan.stl").replace("\\", "/") + cmake.definitions["SHARED_PLUGINS"] = self.options["magnum-plugins"].shared_plugins + cmake.definitions["TARGET_EMSCRIPTEN"] = bool(self.settings.os == "Emscripten") + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + + if self.settings.os == "Emscripten": + bin_path = os.path.join("bin", "test_package.js") + self.run("node {}".format(bin_path), run_environment=True) diff --git a/recipes/magnum-plugins/all/test_package/configure.h.in b/recipes/magnum-plugins/all/test_package/configure.h.in new file mode 100644 index 0000000000000..b1e33dc1f4f4c --- /dev/null +++ b/recipes/magnum-plugins/all/test_package/configure.h.in @@ -0,0 +1,4 @@ + + +#cmakedefine IMPORTER_PLUGINS_FOLDER "${IMPORTER_PLUGINS_FOLDER}" +#cmakedefine CONAN_STL_FILE "${CONAN_STL_FILE}" diff --git a/recipes/magnum-plugins/all/test_package/test_package.cpp b/recipes/magnum-plugins/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..65c01dcb6da3c --- /dev/null +++ b/recipes/magnum-plugins/all/test_package/test_package.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +#include "configure.h" + +int main() { + Corrade::PluginManager::Manager manager{IMPORTER_PLUGINS_FOLDER}; + manager.load("StlImporter"); + auto importer = manager.instantiate("StlImporter"); + + if(!importer) Magnum::Fatal{} << "Cannot load the StlImporter plugin"; + + importer->openFile(CONAN_STL_FILE); + std::cout << "Mesh count: " << importer->meshCount() << "\n"; + return 0; +} diff --git a/recipes/magnum-plugins/config.yml b/recipes/magnum-plugins/config.yml new file mode 100644 index 0000000000000..93230781a72ea --- /dev/null +++ b/recipes/magnum-plugins/config.yml @@ -0,0 +1,3 @@ +versions: + "2020.06": + folder: all diff --git a/recipes/magnum/all/CMakeLists.txt b/recipes/magnum/all/CMakeLists.txt new file mode 100644 index 0000000000000..61f3d3b039e2b --- /dev/null +++ b/recipes/magnum/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory("source_subfolder") diff --git a/recipes/magnum/all/cmake/conan-bugfix-global-target.cmake b/recipes/magnum/all/cmake/conan-bugfix-global-target.cmake new file mode 100644 index 0000000000000..b102d8e6d518b --- /dev/null +++ b/recipes/magnum/all/cmake/conan-bugfix-global-target.cmake @@ -0,0 +1,24 @@ +# If using 'cmake_find_package', all the components are being added to the global +# target unconditionally. See generated FindMagnum.cmake file: +# +# if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0") +# if(NOT TARGET Magnum::Magnum) +# add_library(Magnum::Magnum INTERFACE IMPORTED) +# endif() +# set_property(TARGET Magnum::Magnum APPEND PROPERTY +# INTERFACE_LINK_LIBRARIES "${Magnum_COMPONENTS}") +# endif() +# +# but it doesn't add the library directories and the linker will fail. +# +# Here we fix this bug (breaking change) for this recipe, we just override +# the list of targets again. +# + + +if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0") + if(TARGET Magnum::Magnum) + set_target_properties(Magnum::Magnum PROPERTIES INTERFACE_LINK_LIBRARIES + "${Magnum_Magnum_LINK_LIBS};${Magnum_Magnum_LINKER_FLAGS_LIST}") + endif() +endif() diff --git a/recipes/magnum/all/cmake/conan-magnum-vars.cmake b/recipes/magnum/all/cmake/conan-magnum-vars.cmake new file mode 100644 index 0000000000000..4364855e99fa4 --- /dev/null +++ b/recipes/magnum/all/cmake/conan-magnum-vars.cmake @@ -0,0 +1,25 @@ + +# Here we are reproducing the variables and call performed by the FindMagnum.cmake provided by the library + +# Read flags from configuration +file(READ "${CMAKE_CURRENT_LIST_DIR}/../../include/Magnum/configure.h" _magnumConfigure) +string(REGEX REPLACE ";" "\\\\;" _magnumConfigure "${_magnumConfigure}") +string(REGEX REPLACE "\n" ";" _magnumConfigure "${_magnumConfigure}") +set(_magnumFlags + BUILD_DEPRECATED + BUILD_STATIC + BUILD_STATIC_UNIQUE_GLOBALS + TARGET_GL + TARGET_GLES + TARGET_GLES2 + TARGET_GLES3 + TARGET_DESKTOP_GLES + TARGET_WEBGL + TARGET_HEADLESS + TARGET_VK) +foreach(_magnumFlag ${_magnumFlags}) + list(FIND _magnumConfigure "#define MAGNUM_${_magnumFlag}" _magnum_${_magnumFlag}) + if(NOT _magnum_${_magnumFlag} EQUAL -1) + set(MAGNUM_${_magnumFlag} 1) + endif() +endforeach() diff --git a/recipes/magnum/all/conandata.yml b/recipes/magnum/all/conandata.yml new file mode 100644 index 0000000000000..65803e3bd15c6 --- /dev/null +++ b/recipes/magnum/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2020.06": + url: "https://github.com/mosra/magnum/archive/refs/tags/v2020.06.tar.gz" + sha256: "98dfe802e56614e4e6bf750d9b693de46a5ed0c6eb479b0268f1a20bf34268bf" diff --git a/recipes/magnum/all/conanfile.py b/recipes/magnum/all/conanfile.py new file mode 100644 index 0000000000000..5ce18b70232f6 --- /dev/null +++ b/recipes/magnum/all/conanfile.py @@ -0,0 +1,708 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import functools +import os +import re +import textwrap + +required_conan_version = ">=1.43.0" + + +class MagnumConan(ConanFile): + name = "magnum" + description = "Lightweight and modular C++11/C++14 graphics middleware for games and data visualization" + license = "MIT" + topics = ("magnum", "graphics", "middleware", "graphics", "rendering", "gamedev", "opengl", "3d", "2d", "opengl", "game-engine") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://magnum.graphics" + + settings = "os", "compiler", "build_type", "arch" + + options = { + "shared": [True, False], + "fPIC": [True, False], + "shared_plugins": [True, False], + + # Follow documented build-options in https://doc.magnum.graphics/magnum/building.html#building-features + # Options like `with_xxxx` have been renamed to `xxxx` + # Options related to GL are being refactored into a choice option: gles2, gles3 or desktop_gl + # Some documented options are not available in sources: with_shaderstools, vk_info, with_shaderconverter and with_anyshaderconverter + # Option names are converted to snake_case + + "target_gl": ["gles2", "gles3", "desktop_gl", False], + "target_headless": [True, False], + "target_vk": [True, False], + + "audio": [True, False], + "debug_tools": [True, False], + "gl": [True, False], + "mesh_tools": [True, False], + "primitives": [True, False], + "scene_graph": [True, False], + "shaders": [True, False], + "text": [True, False], + "texture_tools": [True, False], + "trade": [True, False], + "vk": [True, False], + + "android_application": [True, False], + "emscripten_application": [True, False], + "glfw_application": [True, False], + "glx_application": [True, False], + "sdl2_application": [True, False], + "xegl_application": [True, False], + "windowless_cgl_application": [True, False], + "windowless_egl_application": [True, False], + "windowless_glx_application": [True, False], + "windowless_ios_application": [True, False], + "windowless_wgl_application": [True, False], + "windowless_windows_egl_application": [True, False], + + "cgl_context": [True, False], + "egl_context": [True, False], + "glx_context": [True, False], + "wgl_context": [True, False], + + "gl_info": [True, False], + "al_info": [True, False], + "distance_field_converter": [True, False], + "font_converter": [True, False], + "image_converter": [True, False], + "scene_converter": [True, False], + + # Plugins + "any_audio_importer": [True, False], + "any_image_converter": [True, False], + "any_image_importer": [True, False], + "any_scene_converter": [True, False], + "any_scene_importer": [True, False], + "magnum_font": [True, False], + "magnum_font_converter": [True, False], + "obj_importer": [True, False], + "tga_importer": [True, False], + "tga_image_converter": [True, False], + "wav_audio_importer": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "shared_plugins": True, + + "target_gl": "desktop_gl", + "target_headless": True, + "target_vk": True, + + "audio": True, + "debug_tools": True, + "gl": True, + "mesh_tools": True, + "primitives": True, + "scene_graph": True, + "shaders": True, + "text": True, + "texture_tools": True, + "trade": True, + "vk": True, + + "android_application": True, + "emscripten_application": True, + "glfw_application": True, + "glx_application": True, + "sdl2_application": True, + "xegl_application": True, + "windowless_cgl_application": True, + "windowless_egl_application": True, + "windowless_glx_application": True, + "windowless_ios_application": True, + "windowless_wgl_application": True, + "windowless_windows_egl_application": True, + + "cgl_context": True, + "egl_context": True, + "glx_context": True, + "wgl_context": True, + + "gl_info": True, + "al_info": True, + "distance_field_converter": True, + "font_converter": True, + "image_converter": True, + "scene_converter": True, + + # Plugins + "any_audio_importer": True, + "any_image_converter": True, + "any_image_importer": True, + "any_scene_converter": True, + "any_scene_importer": True, + "magnum_font": True, + "magnum_font_converter": True, + "obj_importer": True, + "tga_importer": True, + "tga_image_converter": True, + "wav_audio_importer": True, + } + + short_paths = True + generators = "cmake", "cmake_find_package" + exports_sources = ["CMakeLists.txt", "cmake/*"] + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + # Doc says that 'distance_field_converter' is only available with "desktop GL" (the same is said for 'font_converter', but it builds) + # TODO: Here we probably have a CHOICE OPTION + if self.options.target_gl in ["gles2", "gles3"]: + del self.options.distance_field_converter + + if self.settings.os == "Windows": + del self.options.fPIC + del self.options.egl_context + del self.options.xegl_application + del self.options.windowless_egl_application + del self.options.windowless_ios_application + del self.options.windowless_glx_application + del self.options.windowless_windows_egl_application # requires ANGLE + del self.options.target_headless # Requires EGL (when used gl_info) + del self.options.glx_application + del self.options.cgl_context + del self.options.windowless_cgl_application + + if self.settings.os == "Linux": + del self.options.cgl_context + del self.options.windowless_cgl_application + del self.options.wgl_context + del self.options.windowless_wgl_application + del self.options.windowless_windows_egl_application + + if self.settings.os == "Macos": + del self.options.egl_context + del self.options.glx_application # Requires GL/glx.h (maybe XQuartz project) + del self.options.xegl_application + del self.options.windowless_egl_application + del self.options.windowless_glx_application # Requires GL/glx.h (maybe XQuartz project) + del self.options.windowless_wgl_application + del self.options.windowless_windows_egl_application + del self.options.target_headless # Requires EGL (when used gl_info) + + if self.settings.os != "Android": + del self.options.android_application + + if self.settings.os != "Emscripten": + del self.options.emscripten_application + + if self.settings.os != "iOS": + del self.options.windowless_ios_application + + @property + def _executables(self): + # (executable, option name) + all_execs = (("gl-info", "gl_info"), + ("al-info", "al_info"), + ("distancefieldconverter", "distance_field_converter"), + ("fontconverter", "font_converter"), + ("imageconverter", "image_converter"), + ("sceneconverter", "scene_converter")) + return [executable for executable, opt_name in all_execs if self.options.get_safe(opt_name)] + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("corrade/{}".format(self.version)) + if self.options.audio: + self.requires("openal/1.21.1") + if self.options.gl: + self.requires("opengl/system") + if self.options.vk: + self.requires("vulkan-loader/1.3.211.0") + + if self.options.get_safe("egl_context", False) or \ + self.options.get_safe("xegl_application", False) or \ + self.options.get_safe("windowless_egl_application", False) or \ + self.options.get_safe("windowless_ios_application") or \ + self.options.get_safe("windowless_windows_egl_application", False) or \ + self.options.get_safe("target_headless", False): + self.requires("egl/system") + + if self.options.glfw_application: + self.requires("glfw/3.3.7") + + if self.options.sdl2_application: + self.requires("sdl/2.0.20") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5.0": + raise ConanInvalidConfiguration("GCC older than 5 is not supported (missing C++11 features)") + + if self.options.shared and not self.options["corrade"].shared: + # To fix issue with resource management, see here: https://github.com/mosra/magnum/issues/304#issuecomment-451768389 + raise ConanInvalidConfiguration("If using 'shared=True', corrade should be shared as well") + + if not self.options.gl and (self.options.target_gl or self.options.get_safe("target_headless", False)): + raise ConanInvalidConfiguration("Option 'gl=True' is required") + + if self.options.target_gl in ["gles2", "gles3"] and self.settings.os == "Macos": + raise ConanInvalidConfiguration("OpenGL ES is not supported in Macos") + + if self.options.target_gl in ["gles2", "gles3"] and self.settings.os == "Windows": + raise ConanInvalidConfiguration("OpenGL ES is not supported in Windows") + + if not self.options.vk and self.options.target_vk: + raise ConanInvalidConfiguration("Option 'vk=True' is required") + + if self.options.get_safe("cgl_context", False) and not self.options.target_gl: + raise ConanInvalidConfiguration("Option 'cgl_context' requires some 'target_gl'") + + if self.options.get_safe("windowless_cgl_application", False) and not self.options.target_gl: + raise ConanInvalidConfiguration("Option 'windowless_cgl_application' requires some 'target_gl'") + + if self.options.al_info and not self.options.audio: + raise ConanInvalidConfiguration("Option 'al_info' requires 'audio=True'") + + if self.options.magnum_font_converter and not self.options.tga_image_converter: + raise ConanInvalidConfiguration("magnum_font_converter requires tga_image_converter") + + def build_requirements(self): + self.build_requires("corrade/{}".format(self.version)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_DEPRECATED"] = False + cmake.definitions["BUILD_STATIC"] = not self.options.shared + cmake.definitions["BUILD_STATIC_PIC"] = self.options.get_safe("fPIC", False) + # cmake.definitions["BUILD_STATIC_UNIQUE_GLOBALS"] + cmake.definitions["BUILD_PLUGINS_STATIC"] = not self.options.shared_plugins + cmake.definitions["LIB_SUFFIX"] = "" + cmake.definitions["BUILD_TESTS"] = False + cmake.definitions["BUILD_GL_TESTS"] = False + cmake.definitions["BUILD_AL_TESTS"] = False + cmake.definitions["WITH_OPENGLTESTER"] = False + cmake.definitions["WITH_VULKANTESTER"] = False + + cmake.definitions["TARGET_GL"] = bool(self.options.target_gl) + cmake.definitions["TARGET_GLES"] = self.options.target_gl == "gles3" + cmake.definitions["TARGET_GLES2"] = self.options.target_gl == "gles2" + cmake.definitions["TARGET_DESKTOP_GLES"] = self.options.target_gl == "desktop_gl" + cmake.definitions["TARGET_HEADLESS"] = self.options.get_safe("target_headless", False) + cmake.definitions["TARGET_VK"] = self.options.target_vk + + cmake.definitions["WITH_AUDIO"] = self.options.audio + cmake.definitions["WITH_DEBUGTOOLS"] = self.options.debug_tools + cmake.definitions["WITH_GL"] = self.options.gl + cmake.definitions["WITH_MESHTOOLS"] = self.options.mesh_tools + cmake.definitions["WITH_PRIMITIVES"] = self.options.primitives + cmake.definitions["WITH_SCENEGRAPH"] = self.options.scene_graph + cmake.definitions["WITH_SHADERS"] = self.options.shaders + cmake.definitions["WITH_TEXT"] = self.options.text + cmake.definitions["WITH_TEXTURETOOLS"] = self.options.texture_tools + cmake.definitions["WITH_TRADE"] = self.options.trade + cmake.definitions["WITH_VK"] = self.options.vk + + cmake.definitions["WITH_ANDROIDAPPLICATION"] = self.options.get_safe("android_application", False) + cmake.definitions["WITH_EMSCRIPTENAPPLICATION"] = self.options.get_safe("emscripten_application", False) + cmake.definitions["WITH_GLFWAPPLICATION"] = self.options.glfw_application + cmake.definitions["WITH_GLXAPPLICATION"] = self.options.get_safe("glx_application", False) + cmake.definitions["WITH_SDL2APPLICATION"] = self.options.sdl2_application + cmake.definitions["WITH_XEGLAPPLICATION"] = self.options.get_safe("xegl_application", False) + cmake.definitions["WITH_WINDOWLESSCGLAPPLICATION"] = self.options.get_safe("windowless_cgl_application", False) + cmake.definitions["WITH_WINDOWLESSEGLAPPLICATION"] = self.options.get_safe("windowless_egl_application", False) + cmake.definitions["WITH_WINDOWLESSGLXAPPLICATION"] = self.options.get_safe("windowless_glx_application", False) + cmake.definitions["WITH_WINDOWLESSIOSAPPLICATION"] = self.options.get_safe("windowless_ios_application", False) + cmake.definitions["WITH_WINDOWLESSWGLAPPLICATION"] = self.options.get_safe("windowless_wgl_application", False) + cmake.definitions["WITH_WINDOWLESSWINDOWSEGLAPPLICATION"] = self.options.get_safe("windowless_windows_egl_application", False) + + cmake.definitions["WITH_CGLCONTEXT"] = self.options.get_safe("cgl_context", False) + cmake.definitions["WITH_EGLCONTEXT"] = self.options.get_safe("egl_context", False) + cmake.definitions["WITH_GLXCONTEXT"] = self.options.glx_context + cmake.definitions["WITH_WGLCONTEXT"] = self.options.get_safe("wgl_context", False) + + ##### Plugins related ##### + cmake.definitions["WITH_ANYAUDIOIMPORTER"] = self.options.any_audio_importer + cmake.definitions["WITH_ANYIMAGECONVERTER"] = self.options.any_image_converter + cmake.definitions["WITH_ANYIMAGEIMPORTER"] = self.options.any_image_importer + cmake.definitions["WITH_ANYSCENECONVERTER"] = self.options.any_scene_converter + cmake.definitions["WITH_ANYSCENEIMPORTER"] = self.options.any_scene_importer + cmake.definitions["WITH_MAGNUMFONT"] = self.options.magnum_font + cmake.definitions["WITH_MAGNUMFONTCONVERTER"] = self.options.magnum_font_converter + cmake.definitions["WITH_OBJIMPORTER"] = self.options.obj_importer + cmake.definitions["WITH_TGAIMPORTER"] = self.options.tga_importer + cmake.definitions["WITH_TGAIMAGECONVERTER"] = self.options.tga_image_converter + cmake.definitions["WITH_WAVAUDIOIMPORTER"] = self.options.wav_audio_importer + + #### Command line utilities #### + cmake.definitions["WITH_GL_INFO"] = self.options.gl_info + cmake.definitions["WITH_AL_INFO"] = self.options.al_info + cmake.definitions["WITH_DISTANCEFIELDCONVERTER"] = self.options.get_safe("distance_field_converter", False) + cmake.definitions["WITH_FONTCONVERTER"] = self.options.font_converter + cmake.definitions["WITH_IMAGECONVERTER"] = self.options.image_converter + cmake.definitions["WITH_SCENECONVERTER"] = self.options.scene_converter + + cmake.configure() + return cmake + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + 'set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})', + "") + # Get rid of cmake_dependent_option, it can activate features when we try to disable them, + # let the Conan user decide what to use and what not. + with open(os.path.join(self._source_subfolder, "CMakeLists.txt"), 'r+', encoding="utf-8") as f: + text = f.read() + text = re.sub(r'cmake_dependent_option(([0-9A-Z_]+) .*)', r'option(\1 "Option \1 disabled by Conan" OFF)', text) + f.seek(0) + f.write(text) + f.truncate() + + # GLFW naming + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), + "find_package(GLFW)", + "find_package(glfw3)") + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), + "GLFW_FOUND", + "glfw3_FOUND") + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), + "GLFW::GLFW", + "glfw") + + # EGL naming + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), + "find_package(EGL)", + "find_package(egl_system)") + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), + "EGL_FOUND", + "egl_system_FOUND") + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), + "EGL::EGL", + "egl::egl") + + def build(self): + self._patch_sources() + + cm = self._configure_cmake() + cm.build() + + def package(self): + cm = self._configure_cmake() + cm.install() + + build_modules_folder = os.path.join(self.package_folder, "lib", "cmake") + os.makedirs(build_modules_folder) + for executable in self._executables: + build_module_path = os.path.join(build_modules_folder, "conan-magnum-{}.cmake".format(executable)) + with open(build_module_path, "w+", encoding="utf-8") as f: + f.write(textwrap.dedent("""\ + if(NOT TARGET Magnum::{exec}) + if(CMAKE_CROSSCOMPILING) + find_program(MAGNUM_EXEC_PROGRAM magnum-{exec} PATHS ENV PATH NO_DEFAULT_PATH) + endif() + if(NOT MAGNUM_EXEC_PROGRAM) + set(MAGNUM_EXEC_PROGRAM "${{CMAKE_CURRENT_LIST_DIR}}/../../bin/magnum-{exec}") + endif() + get_filename_component(MAGNUM_EXEC_PROGRAM "${{MAGNUM_EXEC_PROGRAM}}" ABSOLUTE) + add_executable(Magnum::{exec} IMPORTED) + set_property(TARGET Magnum::{exec} PROPERTY IMPORTED_LOCATION ${{MAGNUM_EXEC_PROGRAM}}) + endif() + """.format(exec=executable))) + + if not self.options.shared_plugins: + for component, target, library, _, _ in self._plugins: + build_module_path = os.path.join(build_modules_folder, "conan-magnum-plugins-{}.cmake".format(component)) + with open(build_module_path, "w+", encoding="utf-8") as f: + f.write(textwrap.dedent("""\ + if(NOT ${{CMAKE_VERSION}} VERSION_LESS "3.0") + if(TARGET Magnum::{target}) + set_target_properties(Magnum::{target} PROPERTIES INTERFACE_SOURCES + "${{CMAKE_CURRENT_LIST_DIR}}/../../include/MagnumPlugins/{library}/importStaticPlugin.cpp") + endif() + endif() + """.format(target=target, library=library))) + + tools.rmdir(os.path.join(self.package_folder, "share")) + self.copy("*.cmake", src=os.path.join(self.source_folder, "cmake"), dst=os.path.join("lib", "cmake")) + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Magnum") + self.cpp_info.names["cmake_find_package"] = "Magnum" + self.cpp_info.names["cmake_find_package_multi"] = "Magnum" + + magnum_plugin_libdir = "magnum-d" if self.settings.build_type == "Debug" and self.options.shared_plugins else "magnum" + plugin_lib_suffix = "-d" if self.settings.build_type == "Debug" and not self.options.shared_plugins else "" + lib_suffix = "-d" if self.settings.build_type == "Debug" else "" + + build_modules = [] + + # The FindMagnum.cmake file provided by the library populates some extra stuff + build_modules.append(os.path.join("lib", "cmake", "conan-magnum-vars.cmake")) + self.cpp_info.components["_magnum"].build_modules.append(os.path.join("lib", "cmake", "conan-magnum-vars.cmake")) + + # Magnum contains just the main library + self.cpp_info.components["magnum_main"].set_property("cmake_target_name", "Magnum::Magnum") + self.cpp_info.components["magnum_main"].names["cmake_find_package"] = "Magnum" + self.cpp_info.components["magnum_main"].names["cmake_find_package_multi"] = "Magnum" + self.cpp_info.components["magnum_main"].libs = ["Magnum{}".format(lib_suffix)] + self.cpp_info.components["magnum_main"].requires = ["_magnum", "corrade::utility"] + build_modules.append(os.path.join("lib", "cmake", "conan-bugfix-global-target.cmake")) + self.cpp_info.components["magnum_main"].build_modules["cmake_find_package"].append(os.path.join("lib", "cmake", "conan-bugfix-global-target.cmake")) + + # Audio + if self.options.audio: + self.cpp_info.components["audio"].set_property("cmake_target_name", "Magnum::Audio") + self.cpp_info.components["audio"].names["cmake_find_package"] = "Audio" + self.cpp_info.components["audio"].names["cmake_find_package_multi"] = "Audio" + self.cpp_info.components["audio"].libs = ["MagnumAudio{}".format(lib_suffix)] + self.cpp_info.components["audio"].requires = ["magnum_main", "corrade::plugin_manager", "openal::openal"] + if self.options.scene_graph: + self.cpp_info.components["audio"].requires += ["scene_graph"] + + # DebugTools + if self.options.debug_tools: + self.cpp_info.components["debug_tools"].set_property("cmake_target_name", "Magnum::DebugTools") + self.cpp_info.components["debug_tools"].names["cmake_find_package"] = "DebugTools" + self.cpp_info.components["debug_tools"].names["cmake_find_package_multi"] = "DebugTools" + self.cpp_info.components["debug_tools"].libs = ["MagnumDebugTools{}".format(lib_suffix)] + self.cpp_info.components["debug_tools"].requires = ["magnum_main"] + if self.options["corrade"].with_testsuite and self.options.trade: + self.cpp_info.components["debug_tools"].requires += ["corrade::test_suite", "trade"] + + # GL + if self.options.gl: + self.cpp_info.components["gl"].set_property("cmake_target_name", "Magnum::GL") + self.cpp_info.components["gl"].names["cmake_find_package"] = "GL" + self.cpp_info.components["gl"].names["cmake_find_package_multi"] = "GL" + self.cpp_info.components["gl"].libs = ["MagnumGL{}".format(lib_suffix)] + self.cpp_info.components["gl"].requires = ["magnum_main", "opengl::opengl"] + + # MeshTools + if self.options.mesh_tools: + self.cpp_info.components["mesh_tools"].set_property("cmake_target_name", "Magnum::MeshTools") + self.cpp_info.components["mesh_tools"].names["cmake_find_package"] = "MeshTools" + self.cpp_info.components["mesh_tools"].names["cmake_find_package_multi"] = "MeshTools" + self.cpp_info.components["mesh_tools"].libs = ["MagnumMeshTools{}".format(lib_suffix)] + self.cpp_info.components["mesh_tools"].requires = ["magnum_main", "trade", "gl"] + + # Primitives + if self.options.primitives: + self.cpp_info.components["primitives"].set_property("cmake_target_name", "Magnum::Primitives") + self.cpp_info.components["primitives"].names["cmake_find_package"] = "Primitives" + self.cpp_info.components["primitives"].names["cmake_find_package_multi"] = "Primitives" + self.cpp_info.components["primitives"].libs = ["MagnumPrimitives{}".format(lib_suffix)] + self.cpp_info.components["primitives"].requires = ["magnum_main", "mesh_tools", "trade"] + + # SceneGraph + if self.options.scene_graph: + self.cpp_info.components["scene_graph"].set_property("cmake_target_name", "Magnum::SceneGraph") + self.cpp_info.components["scene_graph"].names["cmake_find_package"] = "SceneGraph" + self.cpp_info.components["scene_graph"].names["cmake_find_package_multi"] = "SceneGraph" + self.cpp_info.components["scene_graph"].libs = ["MagnumSceneGraph{}".format(lib_suffix)] + self.cpp_info.components["scene_graph"].requires = ["magnum_main"] + + # Shaders + if self.options.shaders: + self.cpp_info.components["shaders"].set_property("cmake_target_name", "Magnum::Shaders") + self.cpp_info.components["shaders"].names["cmake_find_package"] = "Shaders" + self.cpp_info.components["shaders"].names["cmake_find_package_multi"] = "Shaders" + self.cpp_info.components["shaders"].libs = ["MagnumShaders{}".format(lib_suffix)] + self.cpp_info.components["shaders"].requires = ["magnum_main", "gl"] + + # Text + if self.options.text: + self.cpp_info.components["text"].set_property("cmake_target_name", "Magnum::Text") + self.cpp_info.components["text"].names["cmake_find_package"] = "Text" + self.cpp_info.components["text"].names["cmake_find_package_multi"] = "Text" + self.cpp_info.components["text"].libs = ["MagnumText{}".format(lib_suffix)] + self.cpp_info.components["text"].requires = ["magnum_main", "texture_tools", "corrade::plugin_manager", "gl"] + + # TextureTools + if self.options.texture_tools: + self.cpp_info.components["texture_tools"].set_property("cmake_target_name", "Magnum::TextureTools") + self.cpp_info.components["texture_tools"].names["cmake_find_package"] = "TextureTools" + self.cpp_info.components["texture_tools"].names["cmake_find_package_multi"] = "TextureTools" + self.cpp_info.components["texture_tools"].libs = ["MagnumTextureTools{}".format(lib_suffix)] + self.cpp_info.components["texture_tools"].requires = ["magnum_main"] + if self.options.gl: + self.cpp_info.components["texture_tools"].requires += ["gl"] + + # Trade + if self.options.trade: + self.cpp_info.components["trade"].set_property("cmake_target_name", "Magnum::Trade") + self.cpp_info.components["trade"].names["cmake_find_package"] = "Trade" + self.cpp_info.components["trade"].names["cmake_find_package_multi"] = "Trade" + self.cpp_info.components["trade"].libs = ["MagnumTrade{}".format(lib_suffix)] + self.cpp_info.components["trade"].requires = ["magnum_main", "corrade::plugin_manager"] + + # VK + if self.options.vk: + self.cpp_info.components["vk"].set_property("cmake_target_name", "Magnum::Vk") + self.cpp_info.components["vk"].names["cmake_find_package"] = "Vk" + self.cpp_info.components["vk"].names["cmake_find_package_multi"] = "Vk" + self.cpp_info.components["vk"].libs = ["MagnumVk{}".format(lib_suffix)] + self.cpp_info.components["vk"].requires = ["magnum_main", "vulkan-loader::vulkan-loader"] + + + #### APPLICATIONS #### + if self.options.get_safe("android_application", False): + raise Exception("Recipe doesn't define this component") + + if self.options.get_safe("emscripten_application", False): + raise Exception("Recipe doesn't define this component") + + if self.options.get_safe("windowless_ios_application", False): + raise Exception("Recipe doesn't define this component") + + if self.options.get_safe("glx_application", False): + self.cpp_info.components["glx_application"].set_property("cmake_target_name", "Magnum::GlxApplication") + self.cpp_info.components["glx_application"].names["cmake_find_package"] = "GlxApplication" + self.cpp_info.components["glx_application"].names["cmake_find_package_multi"] = "GlxApplication" + self.cpp_info.components["glx_application"].libs = ["MagnumGlxApplication{}".format(lib_suffix)] + self.cpp_info.components["glx_application"].requires = ["gl"] # TODO: Add x11 + + if self.options.glfw_application: + self.cpp_info.components["glfw_application"].set_property("cmake_target_name", "Magnum::GlfwApplication") + self.cpp_info.components["glfw_application"].names["cmake_find_package"] = "GlfwApplication" + self.cpp_info.components["glfw_application"].names["cmake_find_package_multi"] = "GlfwApplication" + self.cpp_info.components["glfw_application"].libs = ["MagnumGlfwApplication{}".format(lib_suffix)] + self.cpp_info.components["glfw_application"].requires = ["magnum_main", "glfw::glfw"] + if self.options.target_gl: + self.cpp_info.components["glfw_application"].requires.append("gl") + + if self.options.sdl2_application: + self.cpp_info.components["sdl2_application"].set_property("cmake_target_name", "Magnum::Sdl2Application") + self.cpp_info.components["sdl2_application"].names["cmake_find_package"] = "Sdl2Application" + self.cpp_info.components["sdl2_application"].names["cmake_find_package_multi"] = "Sdl2Application" + self.cpp_info.components["sdl2_application"].libs = ["MagnumSdl2Application{}".format(lib_suffix)] + self.cpp_info.components["sdl2_application"].requires = ["magnum_main", "sdl::sdl"] + if self.options.target_gl: + self.cpp_info.components["sdl2_application"].requires += ["gl"] + + if self.options.get_safe("xegl_application", False): + self.cpp_info.components["xegl_application"].set_property("cmake_target_name", "Magnum::XEglApplication") + self.cpp_info.components["xegl_application"].names["cmake_find_package"] = "XEglApplication" + self.cpp_info.components["xegl_application"].names["cmake_find_package_multi"] = "XEglApplication" + self.cpp_info.components["xegl_application"].libs = ["MagnumXEglApplication{}".format(lib_suffix)] + self.cpp_info.components["xegl_application"].requires = ["gl", "egl::egl"] # TODO: Add x11 + + if self.options.get_safe("windowless_cgl_application", False): + self.cpp_info.components["windowless_cgl_application"].set_property("cmake_target_name", "Magnum::WindowlessCglApplication") + self.cpp_info.components["windowless_cgl_application"].names["cmake_find_package"] = "WindowlessCglApplication" + self.cpp_info.components["windowless_cgl_application"].names["cmake_find_package_multi"] = "WindowlessCglApplication" + self.cpp_info.components["windowless_cgl_application"].libs = ["MagnumWindowlessCglApplication{}".format(lib_suffix)] + self.cpp_info.components["windowless_cgl_application"].requires = ["gl"] + + if self.options.get_safe("windowless_egl_application", False): + self.cpp_info.components["windowless_egl_application"].set_property("cmake_target_name", "Magnum::WindowlessEglApplication") + self.cpp_info.components["windowless_egl_application"].names["cmake_find_package"] = "WindowlessEglApplication" + self.cpp_info.components["windowless_egl_application"].names["cmake_find_package_multi"] = "WindowlessEglApplication" + self.cpp_info.components["windowless_egl_application"].libs = ["MagnumWindowlessEglApplication{}".format(lib_suffix)] + self.cpp_info.components["windowless_egl_application"].requires = ["gl", "egl::egl"] + + if self.options.get_safe("windowless_glx_application", False): + self.cpp_info.components["windowless_glx_application"].set_property("cmake_target_name", "Magnum::WindowlessGlxApplication") + self.cpp_info.components["windowless_glx_application"].names["cmake_find_package"] = "WindowlessGlxApplication" + self.cpp_info.components["windowless_glx_application"].names["cmake_find_package_multi"] = "WindowlessGlxApplication" + self.cpp_info.components["windowless_glx_application"].libs = ["MagnumWindowlessGlxApplication{}".format(lib_suffix)] + self.cpp_info.components["windowless_glx_application"].requires = ["gl"] # TODO: Add x11 + + if self.options.get_safe("windowless_wgl_application", False): + self.cpp_info.components["windowless_wgl_application"].set_property("cmake_target_name", "Magnum::WindowlessWglApplication") + self.cpp_info.components["windowless_wgl_application"].names["cmake_find_package"] = "WindowlessWglApplication" + self.cpp_info.components["windowless_wgl_application"].names["cmake_find_package_multi"] = "WindowlessWglApplication" + self.cpp_info.components["windowless_wgl_application"].libs = ["MagnumWindowlessWglApplication{}".format(lib_suffix)] + self.cpp_info.components["windowless_wgl_application"].requires = ["gl"] + + if self.options.get_safe("windowless_windows_egl_application", False): + raise Exception("Recipe doesn't define this component") + + # # If there is only one application, here it is an alias + # self.cpp_info.components["application"].names["cmake_find_package"] = "Application" + # self.cpp_info.components["application"].names["cmake_find_package_multi"] = "Application" + # self.cpp_info.components["application"].requires = ["sdl2_application"] + + #### CONTEXTS #### + if self.options.get_safe("cgl_context", False): + self.cpp_info.components["cgl_context"].set_property("cmake_target_name", "Magnum::CglContext") + self.cpp_info.components["cgl_context"].names["cmake_find_package"] = "CglContext" + self.cpp_info.components["cgl_context"].names["cmake_find_package_multi"] = "CglContext" + self.cpp_info.components["cgl_context"].libs = ["MagnumCglContext{}".format(lib_suffix)] + self.cpp_info.components["cgl_context"].requires = ["gl"] + + if self.options.get_safe("egl_context", False): + self.cpp_info.components["egl_context"].set_property("cmake_target_name", "Magnum::EglContext") + self.cpp_info.components["egl_context"].names["cmake_find_package"] = "EglContext" + self.cpp_info.components["egl_context"].names["cmake_find_package_multi"] = "EglContext" + self.cpp_info.components["egl_context"].libs = ["MagnumEglContext{}".format(lib_suffix)] + self.cpp_info.components["egl_context"].requires = ["gl", "egl::egl"] + + if self.options.glx_context: + self.cpp_info.components["glx_context"].set_property("cmake_target_name", "Magnum::GlxContext") + self.cpp_info.components["glx_context"].names["cmake_find_package"] = "GlxContext" + self.cpp_info.components["glx_context"].names["cmake_find_package_multi"] = "GlxContext" + self.cpp_info.components["glx_context"].libs = ["MagnumGlxContext{}".format(lib_suffix)] + self.cpp_info.components["glx_context"].requires = ["gl"] + + if self.options.get_safe("wgl_context", False): + self.cpp_info.components["wgl_context"].set_property("cmake_target_name", "Magnum::WglContext") + self.cpp_info.components["wgl_context"].names["cmake_find_package"] = "WglContext" + self.cpp_info.components["wgl_context"].names["cmake_find_package_multi"] = "WglContext" + self.cpp_info.components["wgl_context"].libs = ["MagnumWglContext{}".format(lib_suffix)] + self.cpp_info.components["wgl_context"].requires = ["gl"] + + + ######## PLUGINS ######## + for component, target, library, folder, deps in self._plugins: + self.cpp_info.components[component].set_property("cmake_target_name", f"Magnum::{target}") + self.cpp_info.components[component].names["cmake_find_package"] = target + self.cpp_info.components[component].names["cmake_find_package_multi"] = target + self.cpp_info.components[component].libs = ["{}{}".format(library, plugin_lib_suffix)] + self.cpp_info.components[component].libdirs = [os.path.join(self.package_folder, "lib", magnum_plugin_libdir, folder)] + self.cpp_info.components[component].requires = deps + if not self.options.shared_plugins: + build_modules.append(os.path.join("lib", "cmake", "conan-magnum-plugins-{}.cmake".format(component))) + self.cpp_info.components[component].build_modules.append(os.path.join("lib", "cmake", "conan-magnum-plugins-{}.cmake".format(component))) + plugin_dir = "bin" if self.settings.os == "Windows" else "lib" + self.user_info.plugins_basepath = os.path.join(self.package_folder, plugin_dir, magnum_plugin_libdir) + + #### EXECUTABLES #### + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) + + for executable in self._executables: + build_modules.append(os.path.join("lib", "cmake", "conan-magnum-{}.cmake".format(executable))) + self.cpp_info.components["_magnum"].build_modules.append(os.path.join("lib", "cmake", "conan-magnum-{}.cmake".format(executable))) + + # build modules for CMakeDeps + self.cpp_info.set_property("cmake_build_modules", build_modules) + + @property + def _plugins(self): + # (opt_name, (component, target, library, folder, deps)) + all_plugins = ( + ("any_audio_importer", ("any_audio_importer", "AnyAudioImporter", "AnyAudioImporter", "audioimporters", ["magnum_main", "audio"])), + ("any_image_converter", ("any_image_converter", "AnyImageConverter", "AnyImageConverter", "imageconverters", ["trade"])), + ("any_image_importer", ("any_image_importer", "AnyImageImporter", "AnyImageImporter", "importers", ["trade"])), + ("any_scene_converter", ("any_scene_converter", "AnySceneConverter", "AnySceneConverter", "sceneconverters", ["trade"])), + ("any_scene_importer", ("any_scene_importer", "AnySceneImporter", "AnySceneImporter", "importers", ["trade"])), + ("magnum_font", ("magnum_font", "MagnumFont", "MagnumFont", "fonts", ["magnum_main", "trade", "text"])), + ("magnum_font_converter", ("magnum_font_converter", "MagnumFontConverter", "MagnumFontConverter", "fontconverters", ["magnum_main", "trade", "text", "tga_image_converter"])), + ("obj_importer", ("obj_importer", "ObjImporter", "ObjImporter", "importers", ["trade", "mesh_tools"])), + ("tga_importer", ("tga_importer", "TgaImporter", "TgaImporter", "importers", ["trade"])), + ("tga_image_converter", ("tga_image_converter", "TgaImageConverter", "TgaImageConverter", "imageconverters", ["trade"])), + ("wav_audio_importer", ("wav_audio_importer", "WavAudioImporter", "WavAudioImporter", "audioimporters", ["magnum_main", "audio"])), + ) + return [plugin for opt_name, plugin in all_plugins if self.options.get_safe(opt_name)] diff --git a/recipes/magnum/all/test_package/CMakeLists.txt b/recipes/magnum/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..217f5102eb39f --- /dev/null +++ b/recipes/magnum/all/test_package/CMakeLists.txt @@ -0,0 +1,83 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +if(SHARED_PLUGINS) + find_package(Magnum REQUIRED CONFIG) +else() + find_package(Magnum REQUIRED ObjImporter CONFIG) +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.in + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Magnum::Magnum Magnum::Trade) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +if(NOT SHARED_PLUGINS) + target_link_libraries(${PROJECT_NAME} PRIVATE Magnum::ObjImporter) +endif() +set_target_properties(${PROJECT_NAME} + PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) + + +# Run some executables (we can only be sure they exist if native build) +if (EXEC_GL_INFO AND NOT CMAKE_CROSSCOMPILING) + add_custom_command( + TARGET ${PROJECT_NAME} PRE_BUILD + COMMAND Magnum::gl-info + ARGS "--help" + COMMENT "Running magnum-gl-info" + ) +endif() + +if (EXEC_AL_INFO AND NOT CMAKE_CROSSCOMPILING) + add_custom_command( + TARGET ${PROJECT_NAME} PRE_BUILD + COMMAND Magnum::al-info + ARGS "--help" + COMMENT "Running magnum-al-info" + ) +endif() + +if (EXEC_DISTANCEFIELDCONVERTER_INFO AND NOT CMAKE_CROSSCOMPILING) + add_custom_command( + TARGET ${PROJECT_NAME} PRE_BUILD + COMMAND Magnum::distancefieldconverter + ARGS "--help" + COMMENT "Running magnum-distancefieldconverter" + ) +endif() + +if (EXEC_FONTCONVERTER_INFO AND NOT CMAKE_CROSSCOMPILING) + add_custom_command( + TARGET ${PROJECT_NAME} PRE_BUILD + COMMAND Magnum::fontconverter + ARGS "--help" + COMMENT "Running magnum-fontconverter" + ) +endif() + +if (EXEC_IMAGECONVERTER_INFO AND NOT CMAKE_CROSSCOMPILING) + add_custom_command( + TARGET ${PROJECT_NAME} PRE_BUILD + COMMAND Magnum::imageconverter + ARGS "--help" + COMMENT "Running magnum-imageconverter" + ) +endif() + +if (EXEC_SCENECONVERTER_INFO AND NOT CMAKE_CROSSCOMPILING) + add_custom_command( + TARGET ${PROJECT_NAME} PRE_BUILD + COMMAND Magnum::sceneconverter + ARGS "--help" + COMMENT "Running magnum-sceneconverter" + ) +endif() diff --git a/recipes/magnum/all/test_package/conanfile.py b/recipes/magnum/all/test_package/conanfile.py new file mode 100644 index 0000000000000..efbab832e396c --- /dev/null +++ b/recipes/magnum/all/test_package/conanfile.py @@ -0,0 +1,44 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanException +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + @property + def _executables(self): + available = [] + # (executable, option name) + all_execs = (("gl-info", "gl_info"), + ("al-info", "al_info"), + ("distancefieldconverter", "distance_field_converter"), + ("fontconverter", "font_converter"), + ("imageconverter", "image_converter"), + ("sceneconverter", "scene_converter")) + for executable, opt_name in all_execs: + try: + if getattr(self.options["magnum"], opt_name): + available.append(executable) + except ConanException: + pass + return available + + def build(self): + cmake = CMake(self) + for exec in self._executables: + cmake.definitions["EXEC_{}".format(exec.replace("-", "_")).upper()] = True + cmake.definitions["IMPORTER_PLUGINS_FOLDER"] = os.path.join(self.deps_user_info["magnum"].plugins_basepath, "importers").replace("\\", "/") + cmake.definitions["OBJ_FILE"] = os.path.join(self.source_folder, "triangleMesh.obj").replace("\\", "/") + cmake.definitions["SHARED_PLUGINS"] = self.options["magnum"].shared_plugins + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + for exec in self._executables: + self.run("magnum-{} --help".format(exec), run_environment=True) + + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/magnum/all/test_package/configure.h.in b/recipes/magnum/all/test_package/configure.h.in new file mode 100644 index 0000000000000..d722887f3f7c2 --- /dev/null +++ b/recipes/magnum/all/test_package/configure.h.in @@ -0,0 +1,3 @@ + +#cmakedefine IMPORTER_PLUGINS_FOLDER "${IMPORTER_PLUGINS_FOLDER}" +#cmakedefine OBJ_FILE "${OBJ_FILE}" diff --git a/recipes/magnum/all/test_package/test_package.cpp b/recipes/magnum/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..1c48671c928f5 --- /dev/null +++ b/recipes/magnum/all/test_package/test_package.cpp @@ -0,0 +1,37 @@ +#include +#include "Magnum/Math/Vector.h" +#include "Magnum/Math/StrictWeakOrdering.h" +#include +#include + +#include "configure.h" + +/* + I would like to use some windowless application to test, like + https://github.com/mosra/magnum-bootstrap/tree/windowless + but it doesn't work in CI, it complains about EGL_NOT_INITIALIZED + (headless machine?) +*/ + +int main() { + // Test some basic Magnum + const Magnum::Math::Vector<2, Magnum::Float> v2a{1.0f, 2.0f}; + const Magnum::Math::Vector<2, Magnum::Float> v2b{2.0f, 3.0f}; + const Magnum::Math::Vector<2, Magnum::Float> v2c{1.0f, 3.0f}; + + Magnum::Math::StrictWeakOrdering o; + if (o(v2a, v2b)) { + std::cout << "Basic Magnum working\n"; + } + + // Test some plugin + Corrade::PluginManager::Manager manager{IMPORTER_PLUGINS_FOLDER}; + manager.load("ObjImporter"); + auto importer = manager.instantiate("ObjImporter"); + + if(!importer) Magnum::Fatal{} << "Cannot load the ObjImporter plugin"; + + importer->openFile(OBJ_FILE); + std::cout << "Mesh count: " << importer->meshCount() << "\n"; + return 0; +} diff --git a/recipes/magnum/all/test_package/triangleMesh.obj b/recipes/magnum/all/test_package/triangleMesh.obj new file mode 100644 index 0000000000000..32fb5196bfd6c --- /dev/null +++ b/recipes/magnum/all/test_package/triangleMesh.obj @@ -0,0 +1,9 @@ +# Positions +v 0.5 2 3 +v 0 1.5 1 +v 2 3 5.0 +v 2.5 0 1 + +# Triangles +f 1 2 3 +f 4 2 1 diff --git a/recipes/magnum/config.yml b/recipes/magnum/config.yml new file mode 100644 index 0000000000000..93230781a72ea --- /dev/null +++ b/recipes/magnum/config.yml @@ -0,0 +1,3 @@ +versions: + "2020.06": + folder: all diff --git a/recipes/mailio/all/CMakeLists.txt b/recipes/mailio/all/CMakeLists.txt index 361b35d4c17d9..8977c3f43d6f8 100644 --- a/recipes/mailio/all/CMakeLists.txt +++ b/recipes/mailio/all/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 2.8.11) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory(source_subfolder) diff --git a/recipes/mailio/all/conandata.yml b/recipes/mailio/all/conandata.yml index 7003da2585786..a365e3a29f7a8 100644 --- a/recipes/mailio/all/conandata.yml +++ b/recipes/mailio/all/conandata.yml @@ -1,8 +1,14 @@ sources: + "0.21.0": + url: "https://github.com/karastojko/mailio/archive/refs/tags/0.21.0.tar.gz" + sha256: "8f58dfc8bcbe01224c788f22c544c27611e3c411ed5a2097488fbb32a3c0fb3d" "0.20.0": - url: "https://github.com/karastojko/mailio/archive/version_0-20-0.tar.gz" - sha256: "2ecf57ec467aa8c5d1d2c51a6cc44476c53e890466b7a240304106eeab993245" + url: "https://github.com/karastojko/mailio/archive/refs/tags/0.20.0.tar.gz" + sha256: "073d6b1ff891444b54a01c2a3f17074fd612f9e2e14d9ebd61863c70737b1882" patches: + "0.21.0": + - patch_file: "patches/0.21.0-adapt-cmakelists.patch" + base_path: "source_subfolder" "0.20.0": - - patch_file: "patches/adapt-cmakelists.patch" + - patch_file: "patches/0.20.0-adapt-cmakelists.patch" base_path: "source_subfolder" diff --git a/recipes/mailio/all/conanfile.py b/recipes/mailio/all/conanfile.py index 91bf962b32d5d..a0a2c6874d4a7 100644 --- a/recipes/mailio/all/conanfile.py +++ b/recipes/mailio/all/conanfile.py @@ -1,9 +1,8 @@ from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration -import glob import os -required_conan_version = ">=1.30.0" +required_conan_version = ">=1.33.0" class mailioConan(ConanFile): name = "mailio" @@ -11,7 +10,7 @@ class mailioConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/karastojko/mailio" description = "mailio is a cross platform C++ library for MIME format and SMTP, POP3 and IMAP protocols." - topics = ("conan", "smtp", "imap", "email", "mail", "libraries", "cpp") + topics = ("smtp", "imap", "email", "mail", "libraries", "cpp") settings = "os", "compiler", "build_type", "arch" options = { "fPIC": [True, False], @@ -21,14 +20,12 @@ class mailioConan(ConanFile): "fPIC": True, "shared": False } - requires = ["boost/1.75.0", "openssl/1.1.1j"] generators = "cmake", "cmake_find_package" - exports_sources = ["CMakeLists.txt", "patches/**"] short_paths = True _cmake = None _compiler_required_cpp17 = { - "gcc": "7", + "gcc": "8.3", "clang": "6", "Visual Studio": "15", "apple-clang": "10", @@ -51,10 +48,10 @@ def _configure_cmake(self): self._cmake.configure(build_folder=self._build_subfolder) return self._cmake - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("mailio-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == "Windows": @@ -64,6 +61,11 @@ def configure(self): if self.options.shared: del self.options.fPIC + def requirements(self): + self.requires("boost/1.79.0") + self.requires("openssl/1.1.1q") + + def validate(self): if self.settings.get_safe("compiler.cppstd"): tools.check_min_cppstd(self, "17") try: @@ -73,6 +75,14 @@ def configure(self): except KeyError: self.output.warn("This recipe has no support for the current compiler. Please consider adding it.") + def build_requirements(self): + # mailio requires cmake >= 3.16.3 + self.build_requires("cmake/3.23.2") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) @@ -86,5 +96,5 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["mailio"] self.cpp_info.requires = ["boost::system", "boost::date_time", "boost::regex", "openssl::openssl"] diff --git a/recipes/mailio/all/patches/adapt-cmakelists.patch b/recipes/mailio/all/patches/0.20.0-adapt-cmakelists.patch similarity index 100% rename from recipes/mailio/all/patches/adapt-cmakelists.patch rename to recipes/mailio/all/patches/0.20.0-adapt-cmakelists.patch diff --git a/recipes/mailio/all/patches/0.21.0-adapt-cmakelists.patch b/recipes/mailio/all/patches/0.21.0-adapt-cmakelists.patch new file mode 100644 index 0000000000000..8f2e693447e31 --- /dev/null +++ b/recipes/mailio/all/patches/0.21.0-adapt-cmakelists.patch @@ -0,0 +1,32 @@ +diff --git a/a/CMakeLists.txt b/b/CMakeLists.txt +index 5c9cc6d..86d24fa 100644 +--- a/a/CMakeLists.txt ++++ b/b/CMakeLists.txt +@@ -137,7 +137,7 @@ configure_file(mailio.pc.in ${CMAKE_BINARY_DIR}/mailio.pc IMMEDIATE @ONLY) + install(FILES ${CMAKE_BINARY_DIR}/mailio.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) + + configure_file(${PROJECT_SOURCE_DIR}/include/version.hpp.in version.hpp) +-install(FILES ${CMAKE_BINARY_DIR}/version.hpp DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}) ++install(FILES ${PROJECT_BINARY_DIR}/version.hpp DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}) + + # generate the export header for exporting symbols + # this is needed to generate a shared library. +@@ -167,15 +167,15 @@ endif(MINGW) + install(DIRECTORY include/mailio DESTINATION ${INCLUDE_INSTALL_DIR}) + + install(TARGETS ${PROJECT_NAME} +- EXPORT ${PROJECT_NAME}Config ++ # EXPORT ${PROJECT_NAME}Config + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} + RUNTIME DESTINATION ${BIN_INSTALL_DIR} + ) + +-export(TARGETS ${PROJECT_NAME} FILE ${PROJECT_NAME}Config.cmake) ++# export(TARGETS ${PROJECT_NAME} FILE ${PROJECT_NAME}Config.cmake) + +-install(EXPORT ${PROJECT_NAME}Config DESTINATION share/${PROJECT_NAME}/cmake) ++# install(EXPORT ${PROJECT_NAME}Config DESTINATION share/${PROJECT_NAME}/cmake) + + # optionally build examples + if(${MAILIO_BUILD_EXAMPLES}) diff --git a/recipes/mailio/all/test_package/CMakeLists.txt b/recipes/mailio/all/test_package/CMakeLists.txt index cda7161ae5091..6a193e3e9907d 100644 --- a/recipes/mailio/all/test_package/CMakeLists.txt +++ b/recipes/mailio/all/test_package/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required(VERSION 3.1) project(test_package CXX) -set(CMAKE_CXX_STANDARD 17) - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(mailio REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} mailio::mailio) +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) diff --git a/recipes/mailio/all/test_package/conanfile.py b/recipes/mailio/all/test_package/conanfile.py index bc42555749050..0d81e955db7e7 100644 --- a/recipes/mailio/all/test_package/conanfile.py +++ b/recipes/mailio/all/test_package/conanfile.py @@ -5,13 +5,23 @@ class mailioTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) cmake.configure() cmake.build() + def build_requirements(self): + if hasattr(self, "settings_build") and tools.cross_building(self) and \ + self.settings.os == "Macos" and self.settings.arch == "armv8": + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") + def test(self): if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") diff --git a/recipes/mailio/config.yml b/recipes/mailio/config.yml index c2ba3a0b31418..ad2748292fb8c 100644 --- a/recipes/mailio/config.yml +++ b/recipes/mailio/config.yml @@ -1,3 +1,5 @@ versions: + "0.21.0": + folder: all "0.20.0": folder: all diff --git a/recipes/make/all/conandata.yml b/recipes/make/all/conandata.yml index 7a9b132704ae1..fb6e6264363e7 100644 --- a/recipes/make/all/conandata.yml +++ b/recipes/make/all/conandata.yml @@ -1,8 +1,12 @@ sources: + "4.3": + url: "http://ftpmirror.gnu.org/gnu/make/make-4.3.tar.gz" + sha256: "e05fdde47c5f7ca45cb697e973894ff4f5d79e13b750ed57d7b66d8defc78e19" "4.2.1": url: "http://ftpmirror.gnu.org/gnu/make/make-4.2.1.tar.bz2" sha256: "d6e262bf3601b42d2b1e4ef8310029e1dcf20083c5446b4b7aa67081fdffc589" patches: + "4.3": + - patch_file: "patches/4.3-0001-clang.patch" "4.2.1": - - patch_file: "patches/0001-clang.patch" - base_path: "source_subfolder" + - patch_file: "patches/4.2.1-0001-clang.patch" diff --git a/recipes/make/all/conanfile.py b/recipes/make/all/conanfile.py index 00dd9db8128bf..ca2bde5638e0a 100644 --- a/recipes/make/all/conanfile.py +++ b/recipes/make/all/conanfile.py @@ -1,55 +1,82 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, VCVars import os +required_conan_version = ">=1.53.0" + class MakeConan(ConanFile): name = "make" - description = "GNU Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files" - topics = ("conan", "make", "build", "makefile") - url = "https://github.com/conan-io/conan-center-index" + description = ( + "GNU Make is a tool which controls the generation of executables and " + "other non-source files of a program from the program's source files" + ) + topics = ("make", "build", "makefile") homepage = "https://www.gnu.org/software/make/" + url = "https://github.com/conan-io/conan-center-index" license = "GPL-3.0-or-later" settings = "os", "arch", "compiler", "build_type" - exports_sources = ["patches/*"] - _source_subfolder = "source_subfolder" - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "make-" + self.version - os.rename(extracted_dir, self._source_subfolder) + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def export_sources(self): + export_conandata_patches(self) def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") def package_id(self): del self.info.settings.compiler - def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + if is_msvc(self): + vcvars = VCVars(self) + vcvars.generate() + if self._settings_build.os != "Windows": + tc = AutotoolsToolchain(self) + tc.generate() - with tools.chdir(self._source_subfolder): + def build(self): + apply_conandata_patches(self) + with chdir(self, self.source_folder): # README.W32 - if tools.os_info.is_windows: - if self.settings.compiler == "Visual Studio": + if self._settings_build.os == "Windows": + if is_msvc(self): command = "build_w32.bat --without-guile" else: command = "build_w32.bat --without-guile gcc" else: - env_build = AutoToolsBuildEnvironment(self) - env_build.configure() + autotools = Autotools(self) + autotools.configure() command = "./build.sh" - with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op(): - self.run(command) + self.run(command) def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - self.copy(pattern="make", dst="bin", src=self._source_subfolder, keep_path=False) - self.copy(pattern="*gnumake.exe", dst="bin", src=self._source_subfolder, keep_path=False) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + for make_exe in ("make", "*gnumake.exe"): + copy(self, make_exe, src=self.source_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False) def package_info(self): - make = "gnumake.exe" if self.settings.os == "Windows" else "make" - make = os.path.join(self.package_folder, "bin", make) - self.output.info('Creating CONAN_MAKE_PROGRAM environment variable: %s' % make) + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + + make = os.path.join(self.package_folder, "bin", "gnumake.exe" if self.settings.os == "Windows" else "make") + self.conf_info.define("tools.gnu:make_program", make) + + # TODO: to remove in conan v2 + self.user_info.make = make self.env_info.CONAN_MAKE_PROGRAM = make + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/make/all/patches/0001-clang.patch b/recipes/make/all/patches/0001-clang.patch deleted file mode 100644 index 3f202c048be62..0000000000000 --- a/recipes/make/all/patches/0001-clang.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/glob/glob.c b/glob/glob.c -index f3911bc..8ec8511 100644 ---- a/glob/glob.c -+++ b/glob/glob.c -@@ -208,7 +208,7 @@ my_realloc (p, n) - #endif /* __GNU_LIBRARY__ || __DJGPP__ */ - - --#if !defined __alloca && !defined __GNU_LIBRARY__ -+#if (!defined __alloca && defined __GNU_LIBRARY__ && __linux__) || (!defined __alloca && !defined __GNU_LIBRARY__) - - # ifdef __GNUC__ - # undef alloca diff --git a/recipes/make/all/patches/4.2.1-0001-clang.patch b/recipes/make/all/patches/4.2.1-0001-clang.patch new file mode 100644 index 0000000000000..e1f8b63b75a0e --- /dev/null +++ b/recipes/make/all/patches/4.2.1-0001-clang.patch @@ -0,0 +1,11 @@ +--- glob/glob.c ++++ glob/glob.c +@@ -208,7 +208,7 @@ + #endif /* __GNU_LIBRARY__ || __DJGPP__ */ + + +-#if !defined __alloca && !defined __GNU_LIBRARY__ ++#if (!defined __alloca && defined __GNU_LIBRARY__ && __linux__) || (!defined __alloca && !defined __GNU_LIBRARY__) + + # ifdef __GNUC__ + # undef alloca diff --git a/recipes/make/all/patches/4.3-0001-clang.patch b/recipes/make/all/patches/4.3-0001-clang.patch new file mode 100644 index 0000000000000..6903a4923e64f --- /dev/null +++ b/recipes/make/all/patches/4.3-0001-clang.patch @@ -0,0 +1,11 @@ +--- lib/glob.c ++++ lib/glob.c +@@ -208,7 +208,7 @@ + #endif /* __GNU_LIBRARY__ || __DJGPP__ */ + + +-#if !defined __alloca && !defined __GNU_LIBRARY__ ++#if (!defined __alloca && defined __GNU_LIBRARY__ && __linux__) || (!defined __alloca && !defined __GNU_LIBRARY__) + + # ifdef __GNUC__ + # undef alloca diff --git a/recipes/make/all/test_package/.gitattributes b/recipes/make/all/test_package/.gitattributes deleted file mode 100644 index 9c5165597b05b..0000000000000 --- a/recipes/make/all/test_package/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -* text=auto -Makefile* text eol=lf diff --git a/recipes/make/all/test_package/conanfile.py b/recipes/make/all/test_package/conanfile.py index ad0c8f7958d64..7533b4eedc4fc 100644 --- a/recipes/make/all/test_package/conanfile.py +++ b/recipes/make/all/test_package/conanfile.py @@ -1,11 +1,14 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -import os +from conan import ConanFile class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) def test(self): - with tools.chdir(self.source_folder), tools.remove_from_path("make"): - env_build = AutoToolsBuildEnvironment(self) - env_build.make(args=["love"]) + make = self.conf.get("tools.gnu:make_program", check_type=str) + self.run(f"{make} -C {self.source_folder} love") diff --git a/recipes/make/all/test_v1_package/conanfile.py b/recipes/make/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2348d97eef993 --- /dev/null +++ b/recipes/make/all/test_v1_package/conanfile.py @@ -0,0 +1,13 @@ +from conans import ConanFile, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def test(self): + if not tools.cross_building(self): + with tools.run_environment(self): + make = self.deps_user_info["make"].make + makefile_dir = os.path.join(self.source_folder, os.pardir, "test_package") + self.run(f"{make} -C {makefile_dir} love") diff --git a/recipes/make/config.yml b/recipes/make/config.yml index 4c2c1cafe05c7..0260fd9e5313f 100644 --- a/recipes/make/config.yml +++ b/recipes/make/config.yml @@ -1,3 +1,5 @@ versions: + "4.3": + folder: all "4.2.1": folder: all diff --git a/recipes/mapbox-geometry/all/conandata.yml b/recipes/mapbox-geometry/all/conandata.yml new file mode 100644 index 0000000000000..2c995609ac711 --- /dev/null +++ b/recipes/mapbox-geometry/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.0.3": + url: "https://github.com/mapbox/geometry.hpp/archive/refs/tags/v2.0.3.tar.gz" + sha256: "9d750d34576069bcc4f39677af08cde2862fbe4b8c0d9af504877c2fae2ae273" diff --git a/recipes/mapbox-geometry/all/conanfile.py b/recipes/mapbox-geometry/all/conanfile.py new file mode 100644 index 0000000000000..9edf42d2b8db1 --- /dev/null +++ b/recipes/mapbox-geometry/all/conanfile.py @@ -0,0 +1,49 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.52.0" + + +class MapboxGeometryConan(ConanFile): + name = "mapbox-geometry" + description = ( + "Provides header-only, generic C++ interfaces for geometry types, " + "geometry collections, and features." + ) + topics = ("geometry") + license = "ISC" + homepage = "https://github.com/mapbox/geometry.hpp" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("mapbox-variant/1.2.0", transitive_headers=True) + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 14) + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/mapbox-geometry/all/test_package/CMakeLists.txt b/recipes/mapbox-geometry/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..9bad4b5d60471 --- /dev/null +++ b/recipes/mapbox-geometry/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(mapbox-geometry REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mapbox-geometry::mapbox-geometry) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/mapbox-geometry/all/test_package/conanfile.py b/recipes/mapbox-geometry/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/mapbox-geometry/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mapbox-geometry/all/test_package/test_package.cpp b/recipes/mapbox-geometry/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..a716f17372aad --- /dev/null +++ b/recipes/mapbox-geometry/all/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include + +#include + +int main() { + mapbox::geometry::point pt(1.0, 0.0); + std::cout << "x: " << pt.x << " y: " << pt.y << std::endl; + return 0; +} diff --git a/recipes/mapbox-geometry/all/test_v1_package/CMakeLists.txt b/recipes/mapbox-geometry/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e4046b86f9232 --- /dev/null +++ b/recipes/mapbox-geometry/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(mapbox-geometry REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mapbox-geometry::mapbox-geometry) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/mapbox-geometry/all/test_v1_package/conanfile.py b/recipes/mapbox-geometry/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mapbox-geometry/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mapbox-geometry/config.yml b/recipes/mapbox-geometry/config.yml new file mode 100644 index 0000000000000..7f57148a20478 --- /dev/null +++ b/recipes/mapbox-geometry/config.yml @@ -0,0 +1,3 @@ +versions: + "2.0.3": + folder: all diff --git a/recipes/mapbox-variant/all/conandata.yml b/recipes/mapbox-variant/all/conandata.yml new file mode 100644 index 0000000000000..5473c388e5c2d --- /dev/null +++ b/recipes/mapbox-variant/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.2.0": + url: "https://github.com/mapbox/variant/archive/refs/tags/v1.2.0.tar.gz" + sha256: "7059f4420d504c4bc96f8a462a0f6d029c5be914ba55cc030a0a773366dd7bc8" diff --git a/recipes/mapbox-variant/all/conanfile.py b/recipes/mapbox-variant/all/conanfile.py new file mode 100644 index 0000000000000..dd51a969a8f23 --- /dev/null +++ b/recipes/mapbox-variant/all/conanfile.py @@ -0,0 +1,45 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class MapboxVariantConan(ConanFile): + name = "mapbox-variant" + description = "An header-only alternative to boost::variant for C++11 and C++14" + topics = ("variant") + license = "BSD-3-Clause" + homepage = "https://github.com/mapbox/variant" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/mapbox-variant/all/test_package/CMakeLists.txt b/recipes/mapbox-variant/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d72d3227f01d3 --- /dev/null +++ b/recipes/mapbox-variant/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(mapbox-variant REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mapbox-variant::mapbox-variant) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/mapbox-variant/all/test_package/conanfile.py b/recipes/mapbox-variant/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/mapbox-variant/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mapbox-variant/all/test_package/test_package.cpp b/recipes/mapbox-variant/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..969f9efcb56c0 --- /dev/null +++ b/recipes/mapbox-variant/all/test_package/test_package.cpp @@ -0,0 +1,13 @@ +#include +#include + +#include +#include + +int main() { + typedef mapbox::util::variant variant_type; + variant_type v0(3.14159); + variant_type v1(std::string("3.14159")); + std::cout << "v0: " << v0 << " v1: " << v1 << std::endl; + return 0; +} diff --git a/recipes/mapbox-variant/all/test_v1_package/CMakeLists.txt b/recipes/mapbox-variant/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..5f12dfeb0954a --- /dev/null +++ b/recipes/mapbox-variant/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(mapbox-variant REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mapbox-variant::mapbox-variant) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/mapbox-variant/all/test_v1_package/conanfile.py b/recipes/mapbox-variant/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mapbox-variant/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mapbox-variant/config.yml b/recipes/mapbox-variant/config.yml new file mode 100644 index 0000000000000..7ed1f1b6fc695 --- /dev/null +++ b/recipes/mapbox-variant/config.yml @@ -0,0 +1,3 @@ +versions: + "1.2.0": + folder: all diff --git a/recipes/mariadb-connector-c/all/CMakeLists.txt b/recipes/mariadb-connector-c/all/CMakeLists.txt deleted file mode 100644 index 361b35d4c17d9..0000000000000 --- a/recipes/mariadb-connector-c/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/mariadb-connector-c/all/conandata.yml b/recipes/mariadb-connector-c/all/conandata.yml index cf5cbd99d1eab..a74dc266f2982 100644 --- a/recipes/mariadb-connector-c/all/conandata.yml +++ b/recipes/mariadb-connector-c/all/conandata.yml @@ -8,23 +8,13 @@ sources: patches: "3.1.12": - patch_file: "patches/0001-fix-install-and-static-or-shared.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-msvc-no-override-md-zi.patch" - base_path: "source_subfolder" - patch_file: "patches/0003-include-order-windows-winsock2.patch" - base_path: "source_subfolder" - patch_file: "patches/0004-include-mysqld_error-header.patch" - base_path: "source_subfolder" - patch_file: "patches/0005-fix-cmake-connectorname.patch" - base_path: "source_subfolder" "3.1.11": - patch_file: "patches/0001-fix-install-and-static-or-shared.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-msvc-no-override-md-zi.patch" - base_path: "source_subfolder" - patch_file: "patches/0003-include-order-windows-winsock2.patch" - base_path: "source_subfolder" - patch_file: "patches/0004-include-mysqld_error-header.patch" - base_path: "source_subfolder" - patch_file: "patches/0005-fix-cmake-connectorname.patch" - base_path: "source_subfolder" diff --git a/recipes/mariadb-connector-c/all/conanfile.py b/recipes/mariadb-connector-c/all/conanfile.py index 58ce4ad86cac8..c754d56ff28d9 100644 --- a/recipes/mariadb-connector-c/all/conanfile.py +++ b/recipes/mariadb-connector-c/all/conanfile.py @@ -1,8 +1,10 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, replace_in_file, rm, rmdir import os -required_conan_version = ">=1.29.1" +required_conan_version = ">=1.53.0" class MariadbConnectorcConan(ConanFile): @@ -10,11 +12,10 @@ class MariadbConnectorcConan(ConanFile): description = "MariaDB Connector/C is used to connect applications " \ "developed in C/C++ to MariaDB and MySQL databases." license = "LGPL-2.1-or-later" - topics = ("conan", "mariadb-connector-c", "mariadb", "mysql", "database") + topics = ("mariadb", "mysql", "database") homepage = "https://mariadb.com/kb/en/mariadb-connector-c" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -22,7 +23,7 @@ class MariadbConnectorcConan(ConanFile): "dyncol": [True, False], "with_iconv": [True, False], "with_curl": [True, False], - "with_ssl": [False, "openssl", "gnutls", "schannel"] + "with_ssl": [False, "openssl", "gnutls", "schannel"], } default_options = { "shared": False, @@ -30,14 +31,11 @@ class MariadbConnectorcConan(ConanFile): "dyncol": True, "with_iconv": False, "with_curl": True, - "with_ssl": "openssl" + "with_ssl": "openssl", } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -47,80 +45,88 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - if self.settings.os != "Windows" and self.options.with_ssl == "schannel": - raise ConanInvalidConfiguration("schannel only supported on Windows") + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.get_safe("with_iconv"): - self.requires("libiconv/1.16") + self.requires("libiconv/1.17") if self.options.with_curl: - self.requires("libcurl/7.75.0") + self.requires("libcurl/7.85.0") if self.options.with_ssl == "openssl": - self.requires("openssl/1.1.1k") - elif self.options.with_ssl == "gnutls": + self.requires("openssl/1.1.1s") + + def validate(self): + if self.info.settings.os != "Windows" and self.info.options.with_ssl == "schannel": + raise ConanInvalidConfiguration("schannel only supported on Windows") + if self.info.options.with_ssl == "gnutls": raise ConanInvalidConfiguration("gnutls not yet available in CCI") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "mariadb-connector-c-{}-src".format(self.version) - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if self.settings.os == "Windows": + tc.variables["WITH_MSI"] = False + tc.variables["WITH_SIGNCODE"] = False + tc.variables["WITH_RTC"] = False + else: + tc.variables["WITH_MYSQLCOMPAT"] = False + tc.variables["WITH_ICONV"] = self.options.with_iconv + tc.variables["WITH_UNIT_TESTS"] = False + tc.variables["WITH_DYNCOL"] = self.options.dyncol + tc.variables["WITH_EXTERNAL_ZLIB"] = True + tc.variables["WITH_CURL"] = self.options.with_curl + tc.variables["WITH_SSL"] = self.options.with_ssl + tc.variables["INSTALL_BINDIR"] = "bin" + tc.variables["INSTALL_LIBDIR"] = "lib" + tc.variables["INSTALL_PLUGINDIR"] = os.path.join("lib", "plugin").replace("\\", "/") + # To install relocatable shared libs on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() + deps = CMakeDeps(self) + deps.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) - root_cmake = os.path.join(self._source_subfolder, "CMakeLists.txt") - tools.replace_in_file(root_cmake, "${ZLIB_LIBRARY}", "${ZLIB_LIBRARIES}") - tools.replace_in_file( + root_cmake = os.path.join(self.source_folder, "CMakeLists.txt") + replace_in_file(self, root_cmake, "${ZLIB_LIBRARY}", "${ZLIB_LIBRARIES}") + replace_in_file(self, root_cmake, "SET(SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})", - "SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})" + "SET(SSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)" ) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - if self.settings.os == "Windows": - self._cmake.definitions["WITH_MSI"] = False - self._cmake.definitions["WITH_SIGNCODE"] = False - self._cmake.definitions["WITH_RTC"] = False - else: - self._cmake.definitions["WITH_MYSQLCOMPAT"] = False - self._cmake.definitions["WITH_ICONV"] = self.options.with_iconv - self._cmake.definitions["WITH_UNIT_TESTS"] = False - self._cmake.definitions["WITH_DYNCOL"] = self.options.dyncol - self._cmake.definitions["WITH_EXTERNAL_ZLIB"] = True - self._cmake.definitions["WITH_CURL"] = self.options.with_curl - self._cmake.definitions["WITH_SSL"] = self.options.with_ssl - self._cmake.definitions["INSTALL_BINDIR"] = os.path.join(self.package_folder, "bin").replace("\\", "/") - self._cmake.definitions["INSTALL_LIBDIR"] = os.path.join(self.package_folder, "lib").replace("\\", "/") - self._cmake.definitions["INSTALL_PLUGINDIR"] = os.path.join(self.package_folder, "lib", "plugin").replace("\\", "/") - self._cmake.configure() - return self._cmake + replace_in_file(self, root_cmake, "${CURL_LIBRARIES}", "CURL::libcurl") + plugins_io_cmake = os.path.join(self.source_folder, "plugins", "io", "CMakeLists.txt") + replace_in_file(self, plugins_io_cmake, "${CURL_LIBRARIES}", "CURL::libcurl") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING.LIB", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING.LIB", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "symbols")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.pdb") + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "symbols")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) def package_info(self): - self.cpp_info.names["pkg_config"] = "libmariadb" + self.cpp_info.set_property("pkg_config_name", "libmariadb") self.cpp_info.includedirs.append(os.path.join("include", "mariadb")) - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.libs = collect_libs(self) + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["dl", "m", "pthread"] elif self.settings.os == "Windows": self.cpp_info.system_libs = ["ws2_32", "shlwapi"] @@ -128,5 +134,9 @@ def package_info(self): self.cpp_info.system_libs.append("secur32") plugin_dir = os.path.join(self.package_folder, "lib", "plugin").replace("\\", "/") - self.output.info("Creating MARIADB_PLUGIN_DIR environment variable: {}".format(plugin_dir)) - self.env_info.MARIADB_PLUGIN_DIR = plugin_dir + self.output.info("Prepending to MARIADB_PLUGIN_DIR runtime environment variable: {}".format(plugin_dir)) + self.runenv_info.prepend_path("MARIADB_PLUGIN_DIR", plugin_dir) + + # TODO: to remove in conan v2? + self.cpp_info.names["pkg_config"] = "libmariadb" + self.env_info.MARIADB_PLUGIN_DIR.append(plugin_dir) diff --git a/recipes/mariadb-connector-c/all/test_package/CMakeLists.txt b/recipes/mariadb-connector-c/all/test_package/CMakeLists.txt index 7b9b613cbb24a..d314b6a18b20d 100644 --- a/recipes/mariadb-connector-c/all/test_package/CMakeLists.txt +++ b/recipes/mariadb-connector-c/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(mariadb-connector-c REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE mariadb-connector-c::mariadb-connector-c) diff --git a/recipes/mariadb-connector-c/all/test_package/conanfile.py b/recipes/mariadb-connector-c/all/test_package/conanfile.py index 5216332f39f5c..0a6bc68712d90 100644 --- a/recipes/mariadb-connector-c/all/test_package/conanfile.py +++ b/recipes/mariadb-connector-c/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mariadb-connector-c/all/test_package/test_package.c b/recipes/mariadb-connector-c/all/test_package/test_package.c index e013f84dd333f..1bb304f845467 100644 --- a/recipes/mariadb-connector-c/all/test_package/test_package.c +++ b/recipes/mariadb-connector-c/all/test_package/test_package.c @@ -7,5 +7,7 @@ int main(int argc, char **argv) { printf("MySQL client version: %s\n", mysql_get_client_info()); + printf("MARIADB_PLUGINDIR: %s\n", MARIADB_PLUGINDIR); + return 0; } diff --git a/recipes/mariadb-connector-c/all/test_v1_package/CMakeLists.txt b/recipes/mariadb-connector-c/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/mariadb-connector-c/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/mariadb-connector-c/all/test_v1_package/conanfile.py b/recipes/mariadb-connector-c/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..f5c483de856db --- /dev/null +++ b/recipes/mariadb-connector-c/all/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/marisa/all/CMakeLists.txt b/recipes/marisa/all/CMakeLists.txt new file mode 100644 index 0000000000000..84887fbda2ddf --- /dev/null +++ b/recipes/marisa/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.8) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/marisa/all/conandata.yml b/recipes/marisa/all/conandata.yml new file mode 100644 index 0000000000000..087e45138b499 --- /dev/null +++ b/recipes/marisa/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "0.2.6": + url: "https://github.com/s-yata/marisa-trie/archive/refs/tags/v0.2.6.tar.gz" + sha256: "1063a27c789e75afa2ee6f1716cc6a5486631dcfcb7f4d56d6485d2462e566de" +patches: + "0.2.6": + - patch_file: "patches/0001-add-cmake.patch" + base_path: "source_subfolder" diff --git a/recipes/marisa/all/conanfile.py b/recipes/marisa/all/conanfile.py new file mode 100644 index 0000000000000..13b534d613bd9 --- /dev/null +++ b/recipes/marisa/all/conanfile.py @@ -0,0 +1,87 @@ +import os +from conan import ConanFile, tools +from conan.tools.files import apply_conandata_patches +from conans import CMake + +required_conan_version = ">=1.45.0" + + +class MarisaConan(ConanFile): + name = "marisa" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/s-yata/marisa-trie" + description = "Matching Algorithm with Recursively Implemented StorAge " + license = ("BSD-2-Clause", "LGPL-2.1") + topics = ("algorithm", "dictionary", "marisa") + exports_sources = "patches/**", "CMakeLists.txt" + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "tools": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "tools": True, + } + + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.files.get(**self.conan_data["sources"][self.version], + conanfile=self, destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + + self._cmake.definitions["BUILD_TOOLS"] = self.options.tools + + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + apply_conandata_patches(self) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="COPYING.md", dst="licenses", + src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.files.rmdir(self, os.path.join( + self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "marisa" + self.cpp_info.names["cmake_find_package_multi"] = "marisa" + self.cpp_info.names["pkgconfig"] = "marisa" + self.cpp_info.libs = ["marisa"] + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["m"] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH env var with : '{bin_path}'") + self.env_info.PATH.append(bin_path) diff --git a/recipes/marisa/all/patches/0001-add-cmake.patch b/recipes/marisa/all/patches/0001-add-cmake.patch new file mode 100644 index 0000000000000..4635c52208c27 --- /dev/null +++ b/recipes/marisa/all/patches/0001-add-cmake.patch @@ -0,0 +1,120 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +new file mode 100644 +index 0000000..c7e4c0e +--- /dev/null ++++ b/CMakeLists.txt +@@ -0,0 +1,114 @@ ++cmake_minimum_required(VERSION 3.1) ++project(marisa CXX) ++ ++include(GNUInstallDirs) ++ ++option(BUILD_SHARED_LIBS "Build as shared library" OFF) ++option(BUILD_TOOLS "Build tools" ON) ++option(ENABLE_TESTS "Build and run tests" ON) ++ ++if(BUILD_SHARED_LIBS) ++ set(MARISA_LIBRARY_TYPE SHARED) ++else() ++ set(MARISA_LIBRARY_TYPE STATIC) ++endif(BUILD_SHARED_LIBS) ++ ++set(CMAKE_CXX_STANDARD 11) ++ ++if(NOT CMAKE_BUILD_TYPE) ++ set(CMAKE_BUILD_TYPE Debug) ++endif() ++ ++set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") ++ ++if(NOT MSVC) ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++ -Wextra -Wconversion") ++endif() ++ ++if(BUILD_SHARED_LIBS AND MSVC) ++ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) ++endif() ++ ++include_directories("${PROJECT_SOURCE_DIR}/include") ++include_directories("${PROJECT_SOURCE_DIR}/lib") ++ ++set(HDR_COMPAT ++ include/marisa.h) ++ ++set(HDR_PUBLIC ++ include/marisa/agent.h ++ include/marisa/base.h ++ include/marisa/exception.h ++ include/marisa/iostream.h ++ include/marisa/key.h ++ include/marisa/keyset.h ++ include/marisa/query.h ++ include/marisa/scoped-array.h ++ include/marisa/scoped-ptr.h ++ include/marisa/stdio.h ++ include/marisa/trie.h) ++add_library(marisa ${MARISA_LIBRARY_TYPE} ++ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/io/mapper.cc" ++ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/io/reader.cc" ++ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/io/writer.cc" ++ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/trie/tail.cc" ++ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/trie/louds-trie.cc" ++ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/vector/bit-vector.cc" ++ "${PROJECT_SOURCE_DIR}/lib/marisa/keyset.cc" ++ "${PROJECT_SOURCE_DIR}/lib/marisa/trie.cc" ++ "${PROJECT_SOURCE_DIR}/lib/marisa/agent.cc") ++ ++install(TARGETS marisa ++ RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ++ ++if(BUILD_TOOLS) ++ add_library(cmdopt OBJECT "${PROJECT_SOURCE_DIR}/tools/cmdopt.cc") ++ set(TOOLS ++ marisa-benchmark ++ marisa-build ++ marisa-common-prefix-search ++ marisa-dump ++ marisa-lookup ++ marisa-predictive-search ++ marisa-reverse-lookup ++ ) ++ ++ foreach(TOOL ${TOOLS}) ++ add_executable(${TOOL} "${PROJECT_SOURCE_DIR}/tools/${TOOL}.cc") ++ target_link_libraries(${TOOL} PRIVATE marisa cmdopt) ++ install(TARGETS ${TOOL} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) ++ endforeach(TOOL) ++endif() ++ ++if(ENABLE_TESTS) ++ enable_testing() ++ set(TESTS ++ base-test ++ io-test ++ trie-test ++ vector-test ++ marisa-test ++ ) ++ ++ foreach(TEST ${TESTS}) ++ add_executable(${TEST} "${PROJECT_SOURCE_DIR}/tests/${TEST}.cc") ++ target_link_libraries(${TEST} PRIVATE marisa) ++ add_test(${TEST} ${TEST}) ++ endforeach(TEST) ++endif() ++ ++configure_file( ++ ${PROJECT_SOURCE_DIR}/marisa.pc.in ++ ${PROJECT_BINARY_DIR}/marisa.pc ++ @ONLY) ++install(FILES ${PROJECT_BINARY_DIR}/marisa.pc ++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) ++ ++install(FILES ${HDR_COMPAT} ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ++ ++install(FILES ${HDR_PUBLIC} ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/marisa) diff --git a/recipes/marisa/all/test_package/CMakeLists.txt b/recipes/marisa/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..9bae1c0958b76 --- /dev/null +++ b/recipes/marisa/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(marisa REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} marisa::marisa) diff --git a/recipes/marisa/all/test_package/conanfile.py b/recipes/marisa/all/test_package/conanfile.py new file mode 100644 index 0000000000000..251bf8ae3e3dd --- /dev/null +++ b/recipes/marisa/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os +from conans import CMake, ConanFile, tools +from conan.tools.build import cross_building + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/marisa/all/test_package/test_package.cpp b/recipes/marisa/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..ba90951dd5e1b --- /dev/null +++ b/recipes/marisa/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include +#include "marisa.h" + + +int main() { + int x = 100; + int y = 200; + + marisa::swap(x, y); + + return EXIT_SUCCESS; +} diff --git a/recipes/marisa/config.yml b/recipes/marisa/config.yml new file mode 100644 index 0000000000000..070a32463b25e --- /dev/null +++ b/recipes/marisa/config.yml @@ -0,0 +1,3 @@ +versions: + "0.2.6": + folder: all diff --git a/recipes/matchit/all/conandata.yml b/recipes/matchit/all/conandata.yml new file mode 100644 index 0000000000000..b7a9f8241291b --- /dev/null +++ b/recipes/matchit/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.1": + sha256: 2860cb85febf37220f75cef5b499148bafc9f5541fe1298e11b0c169bb3f31ac + url: https://github.com/BowenFu/matchit.cpp/archive/v1.0.1.tar.gz diff --git a/recipes/matchit/all/conanfile.py b/recipes/matchit/all/conanfile.py new file mode 100644 index 0000000000000..95876b752dd5b --- /dev/null +++ b/recipes/matchit/all/conanfile.py @@ -0,0 +1,70 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.0" + + +class MatchitConan(ConanFile): + name = "matchit" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/BowenFu/matchit.cpp" + license = "Apache-2.0" + description = ("match(it): A lightweight header-only pattern-matching" + " library for C++17 with macro-free APIs.") + topics = ("lightweight", "cpp17", "header-only", "pattern-matching") + no_copy_source = True + settings = "arch", "build_type", "compiler", "os" + + _compiler_required_cpp17 = { + "Visual Studio": "16", + "gcc": "8", + "clang": "7", + "apple-clang": "12.0", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, "17") + + minimum_version = self._compiler_required_cpp17.get( + str(self.settings.compiler), False) + if minimum_version: + if Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + "{} requires C++17, which your compiler does not support.".format(self.name)) + else: + self.output.warn( + "{0} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name)) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, + destination=self.source_folder) + + def build(self): + pass + + def layout(self): + basic_layout(self, src_folder="src") + + def package(self): + copy(self, "LICENSE", src=self.source_folder, + dst=os.path.join(self.package_folder, "licenses")) + copy(self, "matchit.h", + src=os.path.join(self.source_folder, "include"), + dst=os.path.join(self.package_folder, "include")) + + def package_id(self): + self.info.clear() + + def package_info(self): + # TODO: Remove after Conan 2.0 + self.cpp_info.names["cmake_find_package"] = "matchit" + self.cpp_info.names["cmake_find_package_multi"] = "matchit" + + self.cpp_info.set_property("cmake_target_name", "matchit::matchit") + self.cpp_info.set_property("cmake_file_name", "matchit") diff --git a/recipes/matchit/all/test_package/CMakeLists.txt b/recipes/matchit/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fd89193f305ec --- /dev/null +++ b/recipes/matchit/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(matchit REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE matchit::matchit) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/matchit/all/test_package/conanfile.py b/recipes/matchit/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/matchit/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/matchit/all/test_package/test_package.cpp b/recipes/matchit/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2f8099775fd66 --- /dev/null +++ b/recipes/matchit/all/test_package/test_package.cpp @@ -0,0 +1,23 @@ +#include +#include +#include + +int32_t main() { + using namespace matchit; + auto &strm = std::cout; + constexpr auto v = std::variant{4}; + Id i; + Id f; + match(v)( + // clang-format off + pattern | as(i) = [&]{ + strm << "got int: " << *i; + }, + pattern | as(f) = [&]{ + strm << "got float: " << *f; + } + // clang-format on + ); + + return 0; +} diff --git a/recipes/matchit/all/test_v1_package/CMakeLists.txt b/recipes/matchit/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0645f6d856074 --- /dev/null +++ b/recipes/matchit/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(matchit REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE matchit::matchit) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/matchit/all/test_v1_package/conanfile.py b/recipes/matchit/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/recipes/matchit/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/matchit/config.yml b/recipes/matchit/config.yml new file mode 100644 index 0000000000000..67af1aea3aa55 --- /dev/null +++ b/recipes/matchit/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.1": + folder: "all" diff --git a/recipes/mathfu/all/conanfile.py b/recipes/mathfu/all/conanfile.py index f683a695f0807..1b35d3c154c77 100644 --- a/recipes/mathfu/all/conanfile.py +++ b/recipes/mathfu/all/conanfile.py @@ -1,35 +1,43 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.52.0" + class MathfuConan(ConanFile): name = "mathfu" description = "C++ math library developed primarily for games focused on simplicity and efficiency." - topics = ("conan", "mathfu", "math", "geometry") + topics = ("math", "geometry") license = "Apache-2.0" homepage = "https://github.com/google/mathfu" url = "https://github.com/conan-io/conan-center-index" - settings = "os" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): - self.requires("vectorial/cci.20190628") + self.requires("vectorial/cci.20190628", transitive_headers=True, transitive_libs=True) def package_id(self): - self.info.header_only() + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): - if self.settings.os == "Linux": + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] diff --git a/recipes/mathfu/all/test_package/CMakeLists.txt b/recipes/mathfu/all/test_package/CMakeLists.txt index 196188113685c..71adac698445b 100644 --- a/recipes/mathfu/all/test_package/CMakeLists.txt +++ b/recipes/mathfu/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(mathfu REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE mathfu::mathfu) diff --git a/recipes/mathfu/all/test_package/conanfile.py b/recipes/mathfu/all/test_package/conanfile.py index 5216332f39f5c..0a6bc68712d90 100644 --- a/recipes/mathfu/all/test_package/conanfile.py +++ b/recipes/mathfu/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mathfu/all/test_v1_package/CMakeLists.txt b/recipes/mathfu/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/mathfu/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/mathfu/all/test_v1_package/conanfile.py b/recipes/mathfu/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mathfu/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/matio/all/conandata.yml b/recipes/matio/all/conandata.yml index 712a732ee6c5d..8a659653f91f9 100644 --- a/recipes/matio/all/conandata.yml +++ b/recipes/matio/all/conandata.yml @@ -8,6 +8,9 @@ sources: "1.5.21": url: "https://downloads.sourceforge.net/project/matio/matio/1.5.21/matio-1.5.21.tar.gz" sha256: "21809177e55839e7c94dada744ee55c1dea7d757ddaab89605776d50122fb065" + "1.5.23": + url: "https://downloads.sourceforge.net/project/matio/matio/1.5.23/matio-1.5.23.tar.gz" + sha256: "9f91eae661df46ea53c311a1b2dcff72051095b023c612d7cbfc09406c9f4d6e" patches: "1.5.18": - patch_file: "patches/require-cmake-3.10.patch" @@ -16,13 +19,24 @@ patches: base_path: "source_subfolder" - patch_file: "patches/patch-apple-no-undefined.patch" base_path: "source_subfolder" + - patch_file: "patches/cmake-install-bundle.patch" + base_path: "source_subfolder" "1.5.19": - patch_file: "patches/require-cmake-3.10.patch" base_path: "source_subfolder" - patch_file: "patches/patch-apple-no-undefined.patch" base_path: "source_subfolder" + - patch_file: "patches/cmake-install-bundle.patch" + base_path: "source_subfolder" "1.5.21": - patch_file: "patches/require-cmake-3.10.patch" base_path: "source_subfolder" - patch_file: "patches/patch-apple-no-undefined.patch" base_path: "source_subfolder" + - patch_file: "patches/cmake-install-bundle.patch" + base_path: "source_subfolder" + "1.5.23": + - patch_file: "patches/require-cmake-3.10.patch" + base_path: "source_subfolder" + - patch_file: "patches/cmake-install-bundle.patch" + base_path: "source_subfolder" diff --git a/recipes/matio/all/conanfile.py b/recipes/matio/all/conanfile.py index 1d705ecd2404e..213dcdf0eba5b 100644 --- a/recipes/matio/all/conanfile.py +++ b/recipes/matio/all/conanfile.py @@ -2,6 +2,8 @@ from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.33.0" + class MatioConan(ConanFile): name = "matio" @@ -36,20 +38,6 @@ class MatioConan(ConanFile): def _source_subfolder(self): return "source_subfolder" - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def requirements(self): - if self.options.with_hdf5: - self.requires("hdf5/1.12.0") - if self.options.with_zlib: - self.requires("zlib/1.2.11") - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -57,11 +45,27 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if not self.options.with_hdf5 and self.options.mat73: - raise ConanInvalidConfiguration("Support of version 7.3 MAT files requires HDF5") del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def requirements(self): + if self.options.with_hdf5: + self.requires("hdf5/1.12.1") + if self.options.with_zlib: + self.requires("zlib/1.2.12") + + def validate(self): + if not self.options.with_hdf5 and self.options.mat73: + raise ConanInvalidConfiguration("Support of version 7.3 MAT files requires HDF5") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + def _configure_cmake(self): if self._cmake: return self._cmake @@ -92,7 +96,7 @@ def package_info(self): self.cpp_info.libs = ["libmatio"] else: self.cpp_info.libs = ["matio"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] bin_path = os.path.join(self.package_folder, "bin") diff --git a/recipes/matio/all/patches/cmake-install-bundle.patch b/recipes/matio/all/patches/cmake-install-bundle.patch new file mode 100644 index 0000000000000..b7f261e01500c --- /dev/null +++ b/recipes/matio/all/patches/cmake-install-bundle.patch @@ -0,0 +1,14 @@ +Fix CMake configuration errors while cross-building to iOS/tvOS/watchOS + +--- a/cmake/tools.cmake ++++ b/cmake/tools.cmake +@@ -5,8 +5,5 @@ if(NOT HAVE_GETOPT) + endif() + + install(TARGETS matdump +- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ DESTINATION ${CMAKE_INSTALL_BINDIR} + ) diff --git a/recipes/matio/config.yml b/recipes/matio/config.yml index 4c816c7292ab1..5ec8ba010e8ec 100644 --- a/recipes/matio/config.yml +++ b/recipes/matio/config.yml @@ -5,3 +5,5 @@ versions: folder: all "1.5.21": folder: all + "1.5.23": + folder: all diff --git a/recipes/mattiasgustavsson-libs/all/conanfile.py b/recipes/mattiasgustavsson-libs/all/conanfile.py index 3a88dbdc6f851..bfba3abb27bab 100644 --- a/recipes/mattiasgustavsson-libs/all/conanfile.py +++ b/recipes/mattiasgustavsson-libs/all/conanfile.py @@ -1,6 +1,4 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -from conans.tools import Version +from conans import ConanFile, tools import os.path import glob diff --git a/recipes/mbedtls/all/CMakeLists.txt b/recipes/mbedtls/all/CMakeLists.txt index b7308b0148d17..3d32ee21cb1d7 100644 --- a/recipes/mbedtls/all/CMakeLists.txt +++ b/recipes/mbedtls/all/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.4) project(cmake_wrapper) -include(conanbuildinfo.cmake) -conan_basic_setup() - if(MSVC) if(MSVC_VERSION LESS 1900) add_definitions(-DMBEDTLS_PLATFORM_SNPRINTF_MACRO=MBEDTLS_PLATFORM_STD_SNPRINTF) @@ -16,4 +13,4 @@ if(MSVC) endif() endif() -add_subdirectory(source_subfolder) +add_subdirectory(src) diff --git a/recipes/mbedtls/all/conandata.yml b/recipes/mbedtls/all/conandata.yml index ab2c7404c4f83..2e2a89aefe311 100644 --- a/recipes/mbedtls/all/conandata.yml +++ b/recipes/mbedtls/all/conandata.yml @@ -1,23 +1,19 @@ sources: - "2.16.3-apache": - url: "https://tls.mbed.org/download/mbedtls-2.16.3-apache.tgz" - sha256: "ec1bee6d82090ed6ea2690784ea4b294ab576a65d428da9fe8750f932d2da661" - "2.16.3-gpl": - url: "https://tls.mbed.org/download/mbedtls-2.16.3-gpl.tgz" - sha256: "fd01fe4b289116df7781d05e1ef712b6c98823c5334f4a27404f13a8d066ef6a" - "2.23.0": - url: "https://github.com/ARMmbed/mbedtls/archive/mbedtls-2.23.0.tar.gz" - sha256: "5c8998217402aa1fc734f4afaeac38fad2421470fac4b3abc112bd46391054fe" - "2.24.0": - url: "https://github.com/ARMmbed/mbedtls/archive/mbedtls-2.24.0.tar.gz" - sha256: "b5a779b5f36d5fc4cba55faa410685f89128702423ad07b36c5665441a06a5f3" + "3.2.1": + url: "https://github.com/ARMmbed/mbedtls/archive/mbedtls-3.2.1.tar.gz" + sha256: "5850089672560eeaca03dc36678ee8573bb48ef6e38c94f5ce349af60c16da33" + "3.1.0": + url: "https://github.com/ARMmbed/mbedtls/archive/mbedtls-3.1.0.tar.gz" + sha256: "64d01a3b22b91cf3a25630257f268f11bc7bfa37981ae6d397802dd4ccec4690" + "3.0.0": + url: "https://github.com/ARMmbed/mbedtls/archive/mbedtls-3.0.0.tar.gz" + sha256: "377d376919be19f07c7e7adeeded088a525be40353f6d938a78e4f986bce2ae0" "2.25.0": url: "https://github.com/ARMmbed/mbedtls/archive/mbedtls-2.25.0.tar.gz" sha256: "ea2049c2dd4868693998d5a9780e198194be5aea1706ff4a9d4f882f18c0a101" -patches: - "2.16.3-apache": - - patch_file: "patches/0001-visual-studio-shared-apache.patch" - base_path: "source_subfolder" - "2.16.3-gpl": - - patch_file: "patches/0001-visual-studio-shared-gpl.patch" - base_path: "source_subfolder" + "2.24.0": + url: "https://github.com/ARMmbed/mbedtls/archive/mbedtls-2.24.0.tar.gz" + sha256: "b5a779b5f36d5fc4cba55faa410685f89128702423ad07b36c5665441a06a5f3" + "2.23.0": + url: "https://github.com/ARMmbed/mbedtls/archive/mbedtls-2.23.0.tar.gz" + sha256: "5c8998217402aa1fc734f4afaeac38fad2421470fac4b3abc112bd46391054fe" diff --git a/recipes/mbedtls/all/conanfile.py b/recipes/mbedtls/all/conanfile.py index 5cada340d4514..78c7bf30e76ae 100644 --- a/recipes/mbedtls/all/conanfile.py +++ b/recipes/mbedtls/all/conanfile.py @@ -1,98 +1,118 @@ -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.scm import Version import os +required_conan_version = ">=1.53.0" + class MBedTLSConan(ConanFile): name = "mbedtls" - description = "mbed TLS makes it trivially easy for developers to include cryptographic and SSL/TLS capabilities in their (embedded) products" - topics = ("conan", "mbedtls", "polarssl", "tls", "security") + description = ( + "mbed TLS makes it trivially easy for developers to include " + "cryptographic and SSL/TLS capabilities in their (embedded) products" + ) + topics = ("polarssl", "tls", "security") url = "https://github.com/conan-io/conan-center-index" homepage = "https://tls.mbed.org" - license = ("GPL-2.0", "Apache-2.0",) - exports_sources = "CMakeLists.txt", "patches/**" - generators = "cmake" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False], "with_zlib": [True, False]} - default_options = {"shared": False, "fPIC": True, "with_zlib": True} - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _version(self): - return self.version.rsplit("-", 1)[0] - - @property - def _license(self): - return self.version.rsplit("-", 1)[1] + license = "Apache-2.0" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_zlib": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_zlib": True, + } + + exports_sources = "CMakeLists.txt" def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if Version(self.version) >= "3.0.0": + # ZLIB support has been ditched on version 3.0.0 + del self.options.with_zlib def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx - if tools.Version(self.version) >= "2.23.0": - self.license = "Apache-2.0" - - if tools.Version(self.version) >= "2.23.0" \ - and self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration( - "{}/{} does not support shared build on Windows".format(self.name, self.version)) + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") - if tools.Version(self.version) >= "2.23.0" \ - and self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5": - # The command line flags set are not supported on older versions of gcc - raise ConanInvalidConfiguration("{}-{} is not supported by this recipe".format(self.settings.compiler, self.settings.compiler.version)) + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - if self.options.with_zlib: - self.requires("zlib/1.2.11") + if self.options.get_safe("with_zlib"): + self.requires("zlib/1.2.13") + + def validate(self): + if self.info.settings.os == "Windows" and self.info.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} does not support shared build on Windows") + + if self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) < "5": + # The command line flags set are not supported on older versions of gcc + raise ConanInvalidConfiguration( + f"{self.ref} does not support {self.info.settings.compiler}-{self.info.settings.compiler.version}" + ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{}-{}".format(self.name, self._version) - if tools.Version(self.version) >= "2.23.0": # went to mbedtls-mbedtls-X.X.X - extracted_dir = "{}-{}".format(self.name, extracted_dir) - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["USE_SHARED_MBEDTLS_LIBRARY"] = self.options.shared - self._cmake.definitions["USE_STATIC_MBEDTLS_LIBRARY"] = not self.options.shared - self._cmake.definitions["ENABLE_ZLIB_SUPPORT"] = self.options.with_zlib - self._cmake.definitions["ENABLE_PROGRAMS"] = False - self._cmake.definitions["ENABLE_TESTING"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root = True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["USE_SHARED_MBEDTLS_LIBRARY"] = self.options.shared + tc.variables["USE_STATIC_MBEDTLS_LIBRARY"] = not self.options.shared + if Version(self.version) < "3.0.0": + tc.variables["ENABLE_ZLIB_SUPPORT"] = self.options.with_zlib + tc.variables["ENABLE_PROGRAMS"] = False + tc.variables["MBEDTLS_FATAL_WARNINGS"] = False + tc.variables["ENABLE_TESTING"] = False + if Version(self.version) < "3.0.0": + # relocatable shared libs on macOS + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") - if tools.Version(self.version) < "2.23.0": # less then 2.23 is multi-licensed - if self._license == "gpl": - self.copy("gpl-2.0.txt", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") - else: - self.copy("apache-2.0.txt", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "cmake")) def package_info(self): - # https://gitlab.kitware.com/cmake/cmake/blob/de7c21d677db1ddaeece03c19e13e448f4031511/CMakeLists.txt#L380 + self.cpp_info.set_property("cmake_file_name", "MbedTLS") + self.cpp_info.set_property("cmake_target_name", "MbedTLS::mbedtls") + + self.cpp_info.components["mbedcrypto"].set_property("cmake_target_name", "MbedTLS::mbedcrypto") + self.cpp_info.components["mbedcrypto"].libs = ["mbedcrypto"] + + self.cpp_info.components["mbedx509"].set_property("cmake_target_name", "MbedTLS::mbedx509") + self.cpp_info.components["mbedx509"].libs = ["mbedx509"] + self.cpp_info.components["mbedx509"].requires = ["mbedcrypto"] + + self.cpp_info.components["libembedtls"].set_property("cmake_target_name", "MbedTLS::mbedtls") + self.cpp_info.components["libembedtls"].libs = ["mbedtls"] + self.cpp_info.components["libembedtls"].requires = ["mbedx509"] + + if self.options.get_safe("with_zlib"): + for component in self.cpp_info.components: + self.cpp_info.components[component].requires.append("zlib::zlib") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.names["cmake_find_package"] = "MbedTLS" self.cpp_info.names["cmake_find_package_multi"] = "MbedTLS" - self.cpp_info.libs = ["mbedtls", "mbedx509", "mbedcrypto"] + self.cpp_info.components["libembedtls"].names["cmake_find_package"] = "mbedtls" + self.cpp_info.components["libembedtls"].names["cmake_find_package_multi"] = "mbedtls" diff --git a/recipes/mbedtls/all/patches/0001-visual-studio-shared-apache.patch b/recipes/mbedtls/all/patches/0001-visual-studio-shared-apache.patch deleted file mode 100644 index b26ae19ed4de9..0000000000000 --- a/recipes/mbedtls/all/patches/0001-visual-studio-shared-apache.patch +++ /dev/null @@ -1,71 +0,0 @@ ---- include/mbedtls/bn_mul.h 2019-09-06 16:33:55.000000000 +0200 -+++ include/mbedtls/bn_mul.h 2019-11-04 16:42:16.682670628 +0100 -@@ -62,7 +62,7 @@ - * This is done as the number of registers used in the assembly code doesn't - * work with the -O0 option. - */ --#if defined(__i386__) && defined(__OPTIMIZE__) -+#if defined(__i386__) && defined(__OPTIMIZE__) && !defined(__PIC__) - - #define MULADDC_INIT \ - asm( \ ---- include/mbedtls/x509_crt.h 2019-09-06 16:33:55.000000000 +0200 -+++ include/mbedtls/x509_crt.h 2019-11-04 16:42:16.681670623 +0100 -@@ -201,22 +201,34 @@ - #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ - - #if defined(MBEDTLS_X509_CRT_PARSE_C) -+#ifdef _MSC_VER -+ #if defined(X509_USE_SHARED) -+ #define X509_EXPORT __declspec(dllimport) -+ #elif defined(X509_BUILD_SHARED) -+ #define X509_EXPORT __declspec(dllexport) -+ #else -+ #define X509_EXPORT extern -+ #endif -+#else -+ #define X509_EXPORT extern -+#endif -+ - /** - * Default security profile. Should provide a good balance between security - * and compatibility with current deployments. - */ --extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default; -+X509_EXPORT const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default; - - /** - * Expected next default profile. Recommended for new deployments. - * Currently targets a 128-bit security level, except for RSA-2048. - */ --extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_next; -+X509_EXPORT const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_next; - - /** - * NSA Suite B profile. - */ --extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb; -+X509_EXPORT const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb; - - /** - * \brief Parse a single DER formatted certificate and add it ---- library/CMakeLists.txt 2019-09-06 14:35:30.000000000 +0200 -+++ library/CMakeLists.txt 2019-11-04 16:42:16.681670623 +0100 -@@ -159,7 +159,7 @@ - target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target}) - - install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target} -- DESTINATION ${LIB_INSTALL_DIR} -+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR} RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - endif(USE_STATIC_MBEDTLS_LIBRARY) - -@@ -177,7 +177,7 @@ - target_link_libraries(mbedtls ${libs} mbedx509) - - install(TARGETS mbedtls mbedx509 mbedcrypto -- DESTINATION ${LIB_INSTALL_DIR} -+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR} RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - endif(USE_SHARED_MBEDTLS_LIBRARY) - diff --git a/recipes/mbedtls/all/patches/0001-visual-studio-shared-gpl.patch b/recipes/mbedtls/all/patches/0001-visual-studio-shared-gpl.patch deleted file mode 100644 index ae06c9bdd796b..0000000000000 --- a/recipes/mbedtls/all/patches/0001-visual-studio-shared-gpl.patch +++ /dev/null @@ -1,71 +0,0 @@ ---- include/mbedtls/bn_mul.h 2019-09-06 16:33:55.000000000 +0200 -+++ include/mbedtls/bn_mul.h 2019-11-04 16:42:16.682670628 +0100 -@@ -64,7 +64,7 @@ - * This is done as the number of registers used in the assembly code doesn't - * work with the -O0 option. - */ --#if defined(__i386__) && defined(__OPTIMIZE__) -+#if defined(__i386__) && defined(__OPTIMIZE__) && !defined(__PIC__) - - #define MULADDC_INIT \ - asm( \ ---- include/mbedtls/x509_crt.h 2019-09-06 16:33:55.000000000 +0200 -+++ include/mbedtls/x509_crt.h 2019-11-04 16:42:16.681670623 +0100 -@@ -203,22 +203,34 @@ - #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ - - #if defined(MBEDTLS_X509_CRT_PARSE_C) -+#ifdef _MSC_VER -+ #if defined(X509_USE_SHARED) -+ #define X509_EXPORT __declspec(dllimport) -+ #elif defined(X509_BUILD_SHARED) -+ #define X509_EXPORT __declspec(dllexport) -+ #else -+ #define X509_EXPORT extern -+ #endif -+#else -+ #define X509_EXPORT extern -+#endif -+ - /** - * Default security profile. Should provide a good balance between security - * and compatibility with current deployments. - */ --extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default; -+X509_EXPORT const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default; - - /** - * Expected next default profile. Recommended for new deployments. - * Currently targets a 128-bit security level, except for RSA-2048. - */ --extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_next; -+X509_EXPORT const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_next; - - /** - * NSA Suite B profile. - */ --extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb; -+X509_EXPORT const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb; - - /** - * \brief Parse a single DER formatted certificate and add it ---- library/CMakeLists.txt 2019-09-06 14:35:30.000000000 +0200 -+++ library/CMakeLists.txt 2019-11-04 16:42:16.681670623 +0100 -@@ -159,7 +159,7 @@ - target_link_libraries(${mbedtls_static_target} ${libs} ${mbedx509_static_target}) - - install(TARGETS ${mbedtls_static_target} ${mbedx509_static_target} ${mbedcrypto_static_target} -- DESTINATION ${LIB_INSTALL_DIR} -+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR} RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - endif(USE_STATIC_MBEDTLS_LIBRARY) - -@@ -177,7 +177,7 @@ - target_link_libraries(mbedtls ${libs} mbedx509) - - install(TARGETS mbedtls mbedx509 mbedcrypto -- DESTINATION ${LIB_INSTALL_DIR} -+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR} RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - endif(USE_SHARED_MBEDTLS_LIBRARY) - diff --git a/recipes/mbedtls/all/test_package/CMakeLists.txt b/recipes/mbedtls/all/test_package/CMakeLists.txt index 377df40820919..708448e53f170 100644 --- a/recipes/mbedtls/all/test_package/CMakeLists.txt +++ b/recipes/mbedtls/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(MbedTLS REQUIRED CONFIG) -find_package(MbedTLS REQUIRED) - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} MbedTLS::MbedTLS) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE MbedTLS::mbedtls) diff --git a/recipes/mbedtls/all/test_package/conanfile.py b/recipes/mbedtls/all/test_package/conanfile.py index 1d0bdd3779793..0a6bc68712d90 100644 --- a/recipes/mbedtls/all/test_package/conanfile.py +++ b/recipes/mbedtls/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mbedtls/all/test_package/test_package.c b/recipes/mbedtls/all/test_package/test_package.c new file mode 100644 index 0000000000000..a0acf231eeaa6 --- /dev/null +++ b/recipes/mbedtls/all/test_package/test_package.c @@ -0,0 +1,12 @@ +#include "mbedtls/version.h" + +#include + +int main() +{ + char mbedtls_version[18]; + mbedtls_version_get_string_full(mbedtls_version); + printf("version: %s\n", mbedtls_version); + + return 0; +} diff --git a/recipes/mbedtls/all/test_package/test_package.cpp b/recipes/mbedtls/all/test_package/test_package.cpp deleted file mode 100644 index 913b453a6893a..0000000000000 --- a/recipes/mbedtls/all/test_package/test_package.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "mbedtls/version.h" - -#include -#include - -int main() -{ - char mbedtls_version[18]; - mbedtls_version_get_string_full(mbedtls_version); - printf("version: %s\n", mbedtls_version); - - return EXIT_SUCCESS; -} diff --git a/recipes/mbedtls/all/test_v1_package/CMakeLists.txt b/recipes/mbedtls/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/mbedtls/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/mbedtls/all/test_v1_package/conanfile.py b/recipes/mbedtls/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mbedtls/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mbedtls/config.yml b/recipes/mbedtls/config.yml index e105f3390bf48..114a3e62d619d 100644 --- a/recipes/mbedtls/config.yml +++ b/recipes/mbedtls/config.yml @@ -1,11 +1,13 @@ versions: - "2.16.3-apache": + "3.2.1": folder: all - "2.16.3-gpl": + "3.1.0": folder: all - "2.23.0": + "3.0.0": + folder: all + "2.25.0": folder: all "2.24.0": folder: all - "2.25.0": + "2.23.0": folder: all diff --git a/recipes/mcap/all/conandata.yml b/recipes/mcap/all/conandata.yml new file mode 100644 index 0000000000000..2c7f690cbdc21 --- /dev/null +++ b/recipes/mcap/all/conandata.yml @@ -0,0 +1,19 @@ +sources: + 0.1.0: + url: https://github.com/foxglove/mcap/archive/refs/tags/releases/cpp/v0.1.0/main.tar.gz + sha256: a936abb1493b0d189d7909a79c45bdc6703b6016801e10b5cd129ba39642d2b2 + 0.1.1: + url: https://github.com/foxglove/mcap/archive/refs/tags/releases/cpp/v0.1.1/main.tar.gz + sha256: a9ea899315851bfacdb234b7acc917b1a9c67593f0d68e1920321a8f6fa2cfbf + 0.1.2: + url: https://github.com/foxglove/mcap/archive/refs/tags/releases/cpp/v0.1.2/main.tar.gz + sha256: 0f456d6c53730445c3dbf57afd285493cf748c66a02f77d6e48c075128fd0896 + 0.3.0: + url: https://github.com/foxglove/mcap/archive/refs/tags/releases/cpp/v0.3.0/main.tar.gz + sha256: ef29ea4c09520b8aaa2d78ce5e79cbbcd87511ed14d6abf3c4b249ae67a4153b + 0.4.0: + url: https://github.com/foxglove/mcap/archive/refs/tags/releases/cpp/v0.4.0/main.tar.gz + sha256: c0ab99e51005fa8b74fe9ca1ed23b205cf532b8b0723eedd243f35a28d7b466b + 0.5.0: + url: https://github.com/foxglove/mcap/archive/refs/tags/releases/cpp/v0.5.0/main.tar.gz + sha256: 408e255a6c6419b16de38a9ecbdd9729d60adc657767b2d52a234d1da1185349 diff --git a/recipes/mcap/all/conanfile.py b/recipes/mcap/all/conanfile.py new file mode 100644 index 0000000000000..52080826200a5 --- /dev/null +++ b/recipes/mcap/all/conanfile.py @@ -0,0 +1,60 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import files +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.47.0" + + +class McapConan(ConanFile): + name = "mcap" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/foxglove/mcap" + description = "A C++ implementation of the MCAP file format" + license = "MIT" + topics = ("mcap", "serialization", "deserialization", "recording") + + settings = ("os", "compiler", "build_type", "arch") + generators = ("cmake", "cmake_find_package") + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _source_package_path(self): + return os.path.join(self._source_subfolder, "cpp", "mcap") + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def requirements(self): + self.requires("lz4/1.9.3") + self.requires("zstd/1.5.2") + if Version(self.version) < "0.1.1": + self.requires("fmt/8.1.1") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, "17") + if self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) <= "11": + raise ConanInvalidConfiguration("Compiler version is not supported, c++17 support is required") + if (self.settings.compiler in ("gcc", "clang")) and Version(self.settings.compiler.version) <= "8": + raise ConanInvalidConfiguration("Compiler version is not supported, c++17 support is required") + if Version(self.version) < "0.1.1" and self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("Visual Studio compiler support is added in 0.1.1") + if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) < "16": + raise ConanInvalidConfiguration("Compiler version is not supported, c++17 support is required") + + def configure(self): + if Version(self.version) < "0.3.0": + self.license = "Apache-2.0" + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_package_path) + self.copy("include/*", src=self._source_package_path) + + def package_id(self): + self.info.header_only() diff --git a/recipes/mcap/all/test_package/CMakeLists.txt b/recipes/mcap/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..9d5e985915dd3 --- /dev/null +++ b/recipes/mcap/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +find_package(mcap REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mcap::mcap) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/mcap/all/test_package/conanfile.py b/recipes/mcap/all/test_package/conanfile.py new file mode 100644 index 0000000000000..14c16cdc02a92 --- /dev/null +++ b/recipes/mcap/all/test_package/conanfile.py @@ -0,0 +1,22 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = ("os", "arch", "compiler", "build_type") + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mcap/all/test_package/test_package.cpp b/recipes/mcap/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4227377b8d5de --- /dev/null +++ b/recipes/mcap/all/test_package/test_package.cpp @@ -0,0 +1,101 @@ +#define MCAP_IMPLEMENTATION +#include +#include + +#include +#include + +struct Buffer : mcap::IReadable, mcap::IWritable { + std::vector buffer; + + virtual uint64_t size() const { + return buffer.size(); + } + + // IWritable + virtual void end() {} + virtual void handleWrite(const std::byte* data, uint64_t size) { + buffer.insert(buffer.end(), data, data + size); + } + + // IReadable + virtual uint64_t read(std::byte** output, uint64_t offset, uint64_t size) { + if (offset + size > buffer.size()) { + return 0; + } + *output = buffer.data() + offset; + return size; + } +}; + +void assertOk(const mcap::Status& status) { + if (!status.ok()) { + throw std::runtime_error(status.message); + } +} + +void expect(bool condition, const std::string& message) { + if (!condition) { + throw std::runtime_error(message); + } +} + +int main() { + Buffer buffer; + mcap::McapWriter writer; + + auto options = mcap::McapWriterOptions("example"); + options.compression = mcap::Compression::Zstd; + + writer.open(buffer, options); + + mcap::Schema schema("Example", "jsonschema", + R"({ "type": "object", "properties": { "foo": { "type": "string" } } })"); + writer.addSchema(schema); + + mcap::Channel channel("example", "json", schema.id); + writer.addChannel(channel); + + auto now = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); + + std::string payload = R"({"foo": "bar"})"; + mcap::Message msg; + msg.channelId = channel.id; + msg.sequence = 0; + msg.publishTime = now; + msg.logTime = msg.publishTime; + msg.data = reinterpret_cast(payload.data()); + msg.dataSize = payload.size(); + assertOk(writer.write(msg)); + + writer.close(); + + mcap::McapReader reader; + assertOk(reader.open(buffer)); + assertOk(reader.readSummary(mcap::ReadSummaryMethod::NoFallbackScan, assertOk)); + expect(reader.statistics().value().schemaCount == 1, "incorrect schemaCount"); + expect(reader.statistics().value().channelCount == 1, "incorrect channelCount"); + expect(reader.statistics().value().messageCount == 1, "incorrect messageCount"); + expect(reader.statistics().value().chunkCount == 1, "incorrect chunkCount"); + for (const auto& msgView : reader.readMessages()) { + expect(msgView.channel->id == channel.id, "incorrect channel id"); + expect(msgView.channel->topic == channel.topic, "incorrect channel topic"); + expect(msgView.channel->messageEncoding == channel.messageEncoding, + "incorrect channel messageEncoding"); + expect(msgView.schema->id == schema.id, "incorrect schema id"); + expect(msgView.schema->name == schema.name, "incorrect schema name"); + expect(msgView.schema->encoding == schema.encoding, "incorrect schema encoding"); + expect(msgView.message.sequence == msg.sequence, "incorrect message sequence"); + expect(msgView.message.logTime == msg.logTime, "incorrect message logTime"); + expect(msgView.message.publishTime == msg.publishTime, "incorrect message publishTime"); + expect(msgView.message.dataSize == msg.dataSize, "incorrect message dataSize"); + expect(msgView.message.data != msg.data, "data should be copied"); + expect(std::equal(msgView.message.data, msgView.message.data + msgView.message.dataSize, + msg.data, msg.data + msg.dataSize), + "incorrect data"); + } + std::cout << "MCAP " << mcap::LibraryVersion << " roundtrip succeeded!" << std::endl; + return 0; +} diff --git a/recipes/mcap/all/test_v1_package/CMakeLists.txt b/recipes/mcap/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f9cbae78f78b9 --- /dev/null +++ b/recipes/mcap/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(mcap REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mcap::mcap) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/mcap/all/test_v1_package/conanfile.py b/recipes/mcap/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/recipes/mcap/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mcap/config.yml b/recipes/mcap/config.yml new file mode 100644 index 0000000000000..af633986f7d13 --- /dev/null +++ b/recipes/mcap/config.yml @@ -0,0 +1,13 @@ +versions: + 0.1.0: + folder: all + 0.1.1: + folder: all + 0.1.2: + folder: all + 0.3.0: + folder: all + 0.4.0: + folder: all + 0.5.0: + folder: all diff --git a/recipes/md4c/all/conandata.yml b/recipes/md4c/all/conandata.yml new file mode 100644 index 0000000000000..013088e384ddf --- /dev/null +++ b/recipes/md4c/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "0.4.8": + url: "https://github.com/mity/md4c/archive/refs/tags/release-0.4.8.tar.gz" + sha256: "4a457df853425b6bb6e3457aa1d1a13bccec587a04c38c622b1013a0da41439f" +patches: + "0.4.8": + - patch_file: "patches/0001-honor-vc-runtime.patch" + patch_description: "Honor msvc runtime from profile" diff --git a/recipes/md4c/all/conanfile.py b/recipes/md4c/all/conanfile.py new file mode 100644 index 0000000000000..4b5bb25a31a26 --- /dev/null +++ b/recipes/md4c/all/conanfile.py @@ -0,0 +1,125 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir + +import os + +required_conan_version = ">=1.52.0" + + +class Md4cConan(ConanFile): + name = "md4c" + description = "C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification." + license = "MIT" + topics = ("markdown-parser", "markdown") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/mity/md4c" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "encoding": ["utf-8", "utf-16", "ascii"], + } + default_options = { + "shared": False, + "fPIC": True, + "encoding": "utf-8", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.os != "Windows" and self.info.options.encoding == "utf-16": + raise ConanInvalidConfiguration(f"{self.ref} doesn't support utf-16 options on non-Windows platforms") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if self.options.encoding == "utf-8": + tc.preprocessor_definitions["MD4C_USE_UTF8"] = "1" + elif self.options.encoding == "utf-16": + tc.preprocessor_definitions["MD4C_USE_UTF16"] = "1" + elif self.options.encoding == "ascii": + tc.preprocessor_definitions["MD4C_USE_ASCII"] = "1" + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # Honor encoding option + replace_in_file( + self, + os.path.join(self.source_folder, "src", "CMakeLists.txt"), + "COMPILE_FLAGS \"-DMD4C_USE_UTF8\"", + "", + ) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE.md", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "md4c") + + self.cpp_info.components["_md4c"].set_property("cmake_target_name", "md4c::md4c") + self.cpp_info.components["_md4c"].set_property("pkg_config_name", "md4c") + self.cpp_info.components["_md4c"].libs = ["md4c"] + if self.settings.os == "Windows" and self.options.encoding == "utf-16": + self.cpp_info.components["_md4c"].defines.append("MD4C_USE_UTF16") + + self.cpp_info.components["md4c_html"].set_property("cmake_target_name", "md4c::md4c-html") + self.cpp_info.components["md4c_html"].set_property("pkg_config_name", "md4c-html") + self.cpp_info.components["md4c_html"].libs = ["md4c-html"] + self.cpp_info.components["md4c_html"].requires = ["_md4c"] + + # workaround so that global target & pkgconfig file have all components while avoiding + # to create unofficial target or pkgconfig file + self.cpp_info.set_property("cmake_target_name", "md4c::md4c-html") + self.cpp_info.set_property("pkg_config_name", "md4c-html") + + # TODO: to remove in conan v2 + self.cpp_info.components["_md4c"].names["cmake_find_package"] = "md4c" + self.cpp_info.components["_md4c"].names["cmake_find_package_multi"] = "md4c" + self.cpp_info.components["md4c_html"].names["cmake_find_package"] = "md4c-html" + self.cpp_info.components["md4c_html"].names["cmake_find_package_multi"] = "md4c-html" + bin_path = os.path.join(self.package_folder, "bin") + self.output.info(f"Appending PATH environment variable: {bin_path}") + self.env_info.PATH.append(bin_path) diff --git a/recipes/md4c/all/patches/0001-honor-vc-runtime.patch b/recipes/md4c/all/patches/0001-honor-vc-runtime.patch new file mode 100644 index 0000000000000..a20b07a134764 --- /dev/null +++ b/recipes/md4c/all/patches/0001-honor-vc-runtime.patch @@ -0,0 +1,18 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -42,15 +42,6 @@ elseif(MSVC) + # Disable warnings about the so-called unsecured functions: + add_definitions(/D_CRT_SECURE_NO_WARNINGS) + +- # Specify proper C runtime library: +- string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") +- string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") +- string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_RELWITHDEBINFO "{$CMAKE_C_FLAGS_RELWITHDEBINFO}") +- string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") +- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") +- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") +- set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} /MT") +- set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELEASE} /MT") + endif() + + include(GNUInstallDirs) diff --git a/recipes/md4c/all/test_package/CMakeLists.txt b/recipes/md4c/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..dd82268d730c4 --- /dev/null +++ b/recipes/md4c/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) + +find_package(md4c CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(test_package PRIVATE md4c::md4c) diff --git a/recipes/md4c/all/test_package/conanfile.py b/recipes/md4c/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fb96656f203 --- /dev/null +++ b/recipes/md4c/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/md4c/all/test_package/test_package.c b/recipes/md4c/all/test_package/test_package.c new file mode 100644 index 0000000000000..0bea1fda7770a --- /dev/null +++ b/recipes/md4c/all/test_package/test_package.c @@ -0,0 +1,57 @@ +#include "md4c.h" + +#include +#include + +int enter_block(MD_BLOCKTYPE type, void* detail, void* userdata) { + printf("enter block\n"); + return 0; +} + +int leave_block(MD_BLOCKTYPE type, void* detail, void* userdata) { + printf("leave block\n"); + return 0; +} + +int enter_span(MD_SPANTYPE type, void* detail, void* userdata) { + printf("enter span\n"); + return 0; +} + +int leave_span(MD_SPANTYPE type, void* detail, void* userdata) { + printf("leave span\n"); + return 0; +} + +int text_block(MD_TEXTTYPE type, const MD_CHAR* text, MD_SIZE size, void* usrdata) { + printf("text block\n"); + return 0; +} + +int main() { + const char DATA[] = + "# title\n" + "\n" + "example1\n" + "`example2`\n" + "\n" + "> example3\n" + "\n" + ; + + printf("%s\n", DATA); + + MD_PARSER parser; + + parser.abi_version = 0; + parser.flags = MD_FLAG_TABLES; + parser.enter_block = enter_block; + parser.leave_block = leave_block; + parser.enter_span = enter_span; + parser.leave_span = leave_span; + parser.text = text_block; + + md_parse(DATA, strlen(DATA), &parser, NULL); + + return 0; +} diff --git a/recipes/md4c/all/test_v1_package/CMakeLists.txt b/recipes/md4c/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a7e30d5cc2c2d --- /dev/null +++ b/recipes/md4c/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(md4c CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE md4c::md4c) diff --git a/recipes/md4c/all/test_v1_package/conanfile.py b/recipes/md4c/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/md4c/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/md4c/config.yml b/recipes/md4c/config.yml new file mode 100644 index 0000000000000..e89d9145fbd26 --- /dev/null +++ b/recipes/md4c/config.yml @@ -0,0 +1,3 @@ +versions: + "0.4.8": + folder: all diff --git a/recipes/md4qt/all/conandata.yml b/recipes/md4qt/all/conandata.yml new file mode 100644 index 0000000000000..3e89e46b3e63a --- /dev/null +++ b/recipes/md4qt/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "2.0.3": + url: "https://github.com/igormironchik/md4qt/archive/refs/tags/2.0.3.tar.gz" + sha256: "374bfc74aa6ebb1ea7d2332b96f8b2f6001118793bbe4e55109a13d0ffe7ce55" + "2.0.2": + url: "https://github.com/igormironchik/md4qt/archive/refs/tags/2.0.2.tar.gz" + sha256: "721c7e5f8676dba1023931b9e2fd0d22cbc643bc9864c1d1163df3c5615e7e96" + "2.0.1": + url: "https://github.com/igormironchik/md4qt/archive/refs/tags/2.0.1.tar.gz" + sha256: "879f069cd12db44f2fcc33590ded1f9d778f4c854be14a7ad72fb2ff4acdb3d2" + "2.0.0": + url: "https://github.com/igormironchik/md4qt/archive/refs/tags/2.0.0.tar.gz" + sha256: "3c834c4d832208658f042bd85a821c297fafd0f2eedda9d6ddddced7b724f61a" diff --git a/recipes/md4qt/all/conanfile.py b/recipes/md4qt/all/conanfile.py new file mode 100644 index 0000000000000..ce75e30212e5e --- /dev/null +++ b/recipes/md4qt/all/conanfile.py @@ -0,0 +1,72 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.0" + + +class Md4QtConan(ConanFile): + name = "md4qt" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/igormironchik/md4qt" + license = "MIT" + description = "Header-only C++ library for parsing Markdown." + topics = ("markdown", "gfm", "parser", "icu", "ast", "commonmark", "md", "qt6", "stl", "cpp17") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _min_cppstd(self): + return "17" + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "16", + "msvc": "191", + "gcc": "9", + "clang": "12", + "apple-clang": "14", + } + + def package_id(self): + self.info.clear() + + def requirements(self): + self.requires("icu/72.1") + self.requires("uriparser/0.9.7") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.", + ) + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "md4qt"), dst=os.path.join(self.package_folder, "include", "md4qt")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "md4qt") + self.cpp_info.set_property("cmake_target_name", "md4qt::md4qt") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/md4qt/all/test_package/CMakeLists.txt b/recipes/md4qt/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3c95a973f47fa --- /dev/null +++ b/recipes/md4qt/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(md4qt REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE md4qt::md4qt) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/md4qt/all/test_package/conanfile.py b/recipes/md4qt/all/test_package/conanfile.py new file mode 100644 index 0000000000000..c78095722f7aa --- /dev/null +++ b/recipes/md4qt/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + md_path = os.path.join(self.source_folder, "test.md") + self.run("{} \"{}\"".format(bin_path, md_path), env="conanrun") diff --git a/recipes/md4qt/all/test_package/test.md b/recipes/md4qt/all/test_package/test.md new file mode 100644 index 0000000000000..3de705a41ff24 --- /dev/null +++ b/recipes/md4qt/all/test_package/test.md @@ -0,0 +1 @@ +Text diff --git a/recipes/md4qt/all/test_package/test_package.cpp b/recipes/md4qt/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..e1265d68ef6a6 --- /dev/null +++ b/recipes/md4qt/all/test_package/test_package.cpp @@ -0,0 +1,30 @@ +#define MD4QT_ICU_STL_SUPPORT +#include + +#include +#include +#include +#include +#include + +int main(int argc, char ** argv) +{ + if (argc < 2) { + std::cerr << "Need an argument\n"; + return 1; + } + + MD::Parser< MD::UnicodeStringTrait > parser; + + const auto doc = parser.parse(MD::UnicodeString(argv[1])); + + auto path = std::filesystem::canonical(std::filesystem::path(argv[1], + std::filesystem::path::generic_format)).u8string(); + std::replace( path.begin(), path.end(), '\\', '/' ); + + if(std::static_pointer_cast>(doc->items().at(0))->label() == + MD::UnicodeString(path)) + return 0; + else + return 1; +} diff --git a/recipes/md4qt/all/test_v1_package/CMakeLists.txt b/recipes/md4qt/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b24e1b03fbf83 --- /dev/null +++ b/recipes/md4qt/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(md4qt REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE md4qt::md4qt) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/md4qt/all/test_v1_package/conanfile.py b/recipes/md4qt/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..df702b6f48d7c --- /dev/null +++ b/recipes/md4qt/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + md_path = os.path.join(self.source_folder, os.pardir, "test_package", "test.md") + self.run("{} \"{}\"".format(bin_path, md_path), run_environment=True) diff --git a/recipes/md4qt/config.yml b/recipes/md4qt/config.yml new file mode 100644 index 0000000000000..7529da0511999 --- /dev/null +++ b/recipes/md4qt/config.yml @@ -0,0 +1,9 @@ +versions: + "2.0.3": + folder: all + "2.0.2": + folder: all + "2.0.1": + folder: all + "2.0.0": + folder: all diff --git a/recipes/mdns/all/conandata.yml b/recipes/mdns/all/conandata.yml index 8f8a341d2073d..ef0896308dfb2 100644 --- a/recipes/mdns/all/conandata.yml +++ b/recipes/mdns/all/conandata.yml @@ -1,13 +1,4 @@ sources: - "20200130": - sha256: 5f327b56d932ed5c1a28b7b1b1f528ddfbf69cb45bc4a8d38301ab85116e4b0e - url: https://github.com/mjansson/mdns/archive/0f75def961433102dc4848564c1a865f473dfaed.zip - "20200331": - sha256: 98861150179942cd6975b207048939a491ab4bb6c7291a3a34dedc80082b3ba9 - url: https://github.com/mjansson/mdns/archive/4f7f7942bd10eb3d67af48b5233cb84283d9639c.zip - "20200424": - sha256: 505aac658feb45bea65b2ab00a6abf1b14c2aaaa971456d6e3ba58b75a543d47 - url: https://github.com/mjansson/mdns/archive/0b9a4de6c5132679364e47c0f9a7a37af9d2ce47.zip "1.0": sha256: e06ed954b4705f0e48f3e6bd44b75c115ee03f745c62394ee615f466e44e9373 url: https://github.com/mjansson/mdns/archive/1.0.tar.gz @@ -20,3 +11,12 @@ sources: "1.3": url: "https://github.com/mjansson/mdns/archive/1.3.tar.gz" sha256: "d3bfd684ef07beadca71c426586be88a10a92026fe6fe5355609d9e805ff5f85" + "1.4": + url: "https://github.com/mjansson/mdns/archive/1.4.tar.gz" + sha256: "413af72a6ce655dc96d35584dd0134f4ba87534ff78471b5b578e175b9f58dd5" + "1.4.1": + url: "https://github.com/mjansson/mdns/archive/1.4.1.tar.gz" + sha256: "decaf007376c62389712dda67c0eaa8ffb682e7be32ece816b1646119f061be3" + "1.4.2": + url: "https://github.com/mjansson/mdns/archive/1.4.2.tar.gz" + sha256: "c69cfdebe28a489c85f33744f7811c40572a9769a81cd57ecc09ef95802347f2" diff --git a/recipes/mdns/all/conanfile.py b/recipes/mdns/all/conanfile.py index 4e0727d4186fd..aa012f43092fc 100644 --- a/recipes/mdns/all/conanfile.py +++ b/recipes/mdns/all/conanfile.py @@ -1,6 +1,7 @@ -import os, glob +import os from conans import CMake, ConanFile, tools +required_conan_version = ">=1.43.0" class MdnsConan(ConanFile): name = "mdns" @@ -8,18 +9,20 @@ class MdnsConan(ConanFile): homepage = "https://github.com/mjansson/mdns" url = "https://github.com/conan-io/conan-center-index" description = "Public domain mDNS/DNS-SD library in C" - topics = ("conan", "mdns", "dns", "dns-sd") - settings = "os" + topics = ("mdns", "dns", "dns-sd", "multicast discovery", "discovery") + settings = "os", "compiler", "build_type", "arch" no_copy_source = True @property def _source_subfolder(self): return "source_subfolder" + def package_id(self): + self.info.header_only() + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob('mdns-*/')[0] - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) @@ -31,5 +34,5 @@ def package_info(self): if str(self.settings.os) in ["Linux", "Android"]: self.cpp_info.system_libs.append('pthread') - def package_id(self): - self.info.header_only() + self.cpp_info.set_property("cmake_file_name", "mdns") + self.cpp_info.set_property("cmake_target_name", "mdns::mdns") diff --git a/recipes/mdns/config.yml b/recipes/mdns/config.yml index 5ebacdc944eb0..cdb4b7bded43e 100644 --- a/recipes/mdns/config.yml +++ b/recipes/mdns/config.yml @@ -1,10 +1,4 @@ versions: - "20200130": - folder: "all" - "20200331": - folder: "all" - "20200424": - folder: "all" "1.0": folder: "all" "1.1": @@ -13,3 +7,9 @@ versions: folder: "all" "1.3": folder: "all" + "1.4": + folder: "all" + "1.4.1": + folder: "all" + "1.4.2": + folder: "all" diff --git a/recipes/mdnsresponder/all/conandata.yml b/recipes/mdnsresponder/all/conandata.yml new file mode 100644 index 0000000000000..cadda75d51e61 --- /dev/null +++ b/recipes/mdnsresponder/all/conandata.yml @@ -0,0 +1,27 @@ +sources: + "878.200.35": + url: "https://github.com/apple-oss-distributions/mDNSResponder/archive/mDNSResponder-878.200.35.tar.gz" + sha256: "71769924286328a3c405700856c9897c5277360b2f9fd0f450440304d315f6c1" + "1310.140.1": + url: "https://github.com/apple-oss-distributions/mDNSResponder/archive/mDNSResponder-1310.140.1.tar.gz" + sha256: "ecb0043ffc5a3cbf4f43da0298e351d787654d980b291d1cb567c6ddee9dc983" +patches: + "878.200.35": + - base_path: "source_subfolder" + patch_file: "patches/878.200.35/DLLStub.c.patch" + - base_path: "source_subfolder" + patch_file: "patches/878.200.35/mDNSResponder.sln.patch" + - base_path: "source_subfolder" + patch_file: "patches/878.200.35/mDNSWin32.c.patch" + - base_path: "source_subfolder" + patch_file: "patches/878.200.35/Service.c.patch" + "878.200.35-opt": + - base_path: "source_subfolder" + patch_file: "patches/878.200.35/opt/permit-over-long-service-types.patch" + - base_path: "source_subfolder" + patch_file: "patches/878.200.35/opt/poll-rather-than-select.patch" + - base_path: "source_subfolder" + patch_file: "patches/878.200.35/opt/unicast.patch" + "1310.140.1": + - base_path: "source_subfolder" + patch_file: "patches/1310.140.1/dns_sd.c.patch" diff --git a/recipes/mdnsresponder/all/conanfile.py b/recipes/mdnsresponder/all/conanfile.py new file mode 100644 index 0000000000000..5e0b8a3e6f765 --- /dev/null +++ b/recipes/mdnsresponder/all/conanfile.py @@ -0,0 +1,188 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment, MSBuild +from conans.errors import ConanInvalidConfiguration +from conan.tools.files.symlinks import absolute_to_relative_symlinks +import os + +required_conan_version = ">=1.33.0" + + +class MdnsResponderConan(ConanFile): + name = "mdnsresponder" + description = "Conan package for Apple's mDNSResponder" + topics = ("Bonjour", "DNS-SD", "mDNS") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://opensource.apple.com/tarballs/mDNSResponder/" + license = "Apache-2.0", "BSD-3-Clause" + settings = "os", "arch", "compiler", "build_type" + options = { + "with_opt_patches": [True, False], + } + default_options = { + "with_opt_patches": False, + } + exports_sources = ["patches/**"] + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def validate(self): + if self.settings.os not in ["Linux", "Windows"]: + raise ConanInvalidConfiguration("Only Linux and Windows are supported for this package.") + if tools.Version(self.version) >= "1096.0.2": + # recent tarballs (since 1096.0.2) are missing mDNSWindows, so for now, Linux only + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("Windows is not supported for version {}.".format(self.version)) + # TCP_NOTSENT_LOWAT is causing build failures for packages built with gcc 4.9 + # the best check would probably be for Linux kernel v3.12, but for now... + if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5": + raise ConanInvalidConfiguration("Only gcc 5 or higher is supported for this package.") + # __has_c_attribute is not available in Clang 5 + if self.settings.compiler == "clang" and tools.Version(self.settings.compiler.version) < "6": + raise ConanInvalidConfiguration("Only Clang 6 or higher is supported for this package.") + # FIXME: Migration of the project files fails with VS 2017 on c3i (conan-center-index's infrastructure) + # though works OK with VS 2015 and VS 2019, and works with VS 2017 in my local environment + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) == "15": + raise ConanInvalidConfiguration("Visual Studio 2017 is not supported in CCI (yet).") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @property + def _posix_folder(self): + return os.path.join(self._source_subfolder, "mDNSPosix") + + @property + def _make_build_args(self): + # the Makefile does not support parallel builds + return [ + "os=linux", + "-j1", + ] + + @property + def _make_build_targets(self): + return " ".join(["setup", "Daemon", "libdns_sd", "Clients"]) + + @property + def _make_install_args(self): + return self._make_build_args + [ + "INSTBASE={}".format(self.package_folder), + "STARTUPSCRIPTDIR={}/bin".format(self.package_folder), + "RUNLEVELSCRIPTSDIR=", + ] + + @property + def _make_install_targets(self): + # not installing man pages, NSS plugin + return " ".join(["setup", "InstalledDaemon", "InstalledLib", "InstalledClients"]) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self) + # fix for error: 'for' loop initial declarations are only allowed in C99 or C11 mode + self._autotools.flags.append("-std=gnu99") + return self._autotools + + def _build_make(self): + with tools.chdir(self._posix_folder): + autotools = self._configure_autotools() + autotools.make(args=self._make_build_args, target=self._make_build_targets) + + @property + def _msvc_targets(self): + return ["mDNSResponder", "DLL", "DLLStub", "dns-sd"] + + @property + def _msvc_definitions(self): + return {"_WINSOCK_DEPRECATED_NO_WARNINGS": None} + + @property + def _msvc_platforms(self): + return {"x86": "Win32", "x86_64": "x64"} + + @property + def _msvc_platform(self): + return self._msvc_platforms[str(self.settings.arch)] + + def _build_msvc(self): + sln = os.path.join(self._source_subfolder, "mDNSResponder.sln") + if "MD" in self.settings.compiler.runtime: + # could use glob and replace_in_file(strict=False, ...) + dll_vcxproj = os.path.join(self._source_subfolder, "mDNSWindows", "DLL", "dnssd.vcxproj") + dllstub_vcxproj = os.path.join(self._source_subfolder, "mDNSWindows", "DLLStub", "DLLStub.vcxproj") + dns_sd_vcxproj = os.path.join(self._source_subfolder, "Clients", "DNS-SD.VisualStudio", "dns-sd.vcxproj") + for vcxproj in [dll_vcxproj, dllstub_vcxproj, dns_sd_vcxproj]: + tools.replace_in_file(vcxproj, "MultiThreaded", "MultiThreadedDLL") + tools.replace_in_file(vcxproj, "MultiThreadedDebug", "MultiThreadedDebugDLL") + + # could use glob and replace_in_file(strict=False, ...) + dll_rc = os.path.join(self._source_subfolder, "mDNSWindows", "DLL", "dll.rc") + dns_sd_rc = os.path.join(self._source_subfolder, "Clients", "DNS-SD.VisualStudio", "dns-sd.rc") + for rc in [dll_rc, dns_sd_rc]: + tools.replace_in_file(rc, "afxres.h", "winres.h") + + msbuild = MSBuild(self) + msbuild.build(sln, targets=self._msvc_targets, platforms=self._msvc_platforms, definitions=self._msvc_definitions) + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + if self.options.with_opt_patches: + for patch in self.conan_data.get("patches", {}).get("{}-opt".format(self.version), []): + tools.patch(**patch) + if self.settings.os == "Linux": + self._build_make() + elif self.settings.os == "Windows": + self._build_msvc() + + def _install_make(self): + for dir in ["bin", "include", "lib", "sbin"]: + tools.mkdir(os.path.join(self.package_folder, dir)) + with tools.chdir(self._posix_folder): + autotools = self._configure_autotools() + autotools.make(args=self._make_install_args, target=self._make_install_targets) + # package the daemon in bin too + tools.rename(os.path.join(self.package_folder, "sbin", "mdnsd"), + os.path.join(self.package_folder, "bin", "mdnsd")) + tools.rmdir(os.path.join(self.package_folder, "sbin")) + absolute_to_relative_symlinks(self, self.package_folder) + + def _msvc_build_folder(self, *argv): + return os.path.join(self._source_subfolder, *argv, self._msvc_platform, str(self.settings.build_type)) + + def _install_msvc(self): + self.copy("mDNSResponder.exe", dst="bin", src=self._msvc_build_folder("mDNSWindows", "SystemService")) + self.copy("dns_sd.h", dst="include", src=os.path.join(self._source_subfolder, "mDNSShared")) + self.copy("dnssd.dll", dst="bin", src=self._msvc_build_folder("mDNSWindows", "DLL")) + self.copy("dnssdStatic.lib", dst="lib", src=self._msvc_build_folder("mDNSWindows", "DLLStub")) + # rename consistently with Bonjour SDK + tools.rename(src=os.path.join(self.package_folder, "lib", "dnssdStatic.lib"), + dst=os.path.join(self.package_folder, "lib", "dnssd.lib")) + self.copy("dns-sd.exe", dst="bin", src=self._msvc_build_folder("Clients", "DNS-SD.VisualStudio")) + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + if self.settings.os == "Linux": + self._install_make() + elif self.settings.os == "Windows": + self._install_msvc() + + def package_info(self): + # although not one of the find-modules in the CMake distribution, FindDNSSD.cmake is commonly used for this package + self.cpp_info.names["cmake_find_package"] = "DNSSD" + self.cpp_info.names["cmake_find_package_multi"] = "DNSSD" + + if self.settings.os == "Linux": + self.cpp_info.libs = ["dns_sd"] + elif self.settings.os == "Windows": + self.cpp_info.libs = ["dnssd"] + + # add path for daemon (mdnsd, mDNSResponder) and client (dns-sd) + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/mdnsresponder/all/patches/1310.140.1/dns_sd.c.patch b/recipes/mdnsresponder/all/patches/1310.140.1/dns_sd.c.patch new file mode 100644 index 0000000000000..466a24eae2b74 --- /dev/null +++ b/recipes/mdnsresponder/all/patches/1310.140.1/dns_sd.c.patch @@ -0,0 +1,19 @@ +--- Clients/dns-sd.c ++++ Clients/dns-sd.c +@@ -58,6 +58,7 @@ + //#define TEST_NEW_CLIENTSTUB 1 + + #include ++#include // For va_list, va_start, va_end + #include // For stdout, stderr + #include // For exit() + #include // For strlen(), strcpy() +@@ -943,7 +944,7 @@ + va_end(ptr); + if (result > 0 && size > 0) + { +- length = MIN((size_t)result, size-1); ++ length = ((((size_t)result)<(size-1))?((size_t)result):(size-1)); + } + return length; + } diff --git a/recipes/mdnsresponder/all/patches/878.200.35/DLLStub.c.patch b/recipes/mdnsresponder/all/patches/878.200.35/DLLStub.c.patch new file mode 100644 index 0000000000000..67185c78d1cdb --- /dev/null +++ b/recipes/mdnsresponder/all/patches/878.200.35/DLLStub.c.patch @@ -0,0 +1,32 @@ +--- mDNSWindows/DLLStub/DLLStub.cpp ++++ mDNSWindows/DLLStub/DLLStub.cpp +@@ -83,9 +83,9 @@ + dnssd_sock_t DNSSD_API + DNSServiceRefSockFD(DNSServiceRef sdRef) + { +- typedef int (DNSSD_API * Func)(DNSServiceRef sdRef); ++ typedef dnssd_sock_t (DNSSD_API * Func)(DNSServiceRef sdRef); + static Func func = NULL; +- int ret = INVALID_SOCKET; ++ dnssd_sock_t ret = INVALID_SOCKET; + + if ( DLLStub::GetProcAddress( ( FARPROC* ) &func, __FUNCTION__ ) ) + { +@@ -354,7 +354,7 @@ + void *context /* may be NULL */ + ) + { +- typedef DNSServiceErrorType (DNSSD_API * Func)(DNSServiceRef, DNSRecordRef*, DNSServiceFlags, uint32_t, const char*, uint16_t, uint16_t, uint16_t, const void*, uint16_t, DNSServiceRegisterRecordReply, void* ); ++ typedef DNSServiceErrorType (DNSSD_API * Func)(DNSServiceRef, DNSRecordRef*, DNSServiceFlags, uint32_t, const char*, uint16_t, uint16_t, uint16_t, const void*, uint32_t, DNSServiceRegisterRecordReply, void* ); + static Func func = NULL; + DNSServiceErrorType ret = g_defaultErrorCode; + +@@ -432,7 +432,7 @@ + void *context /* may be NULL */ + ) + { +- typedef DNSServiceErrorType (DNSSD_API * Func)(DNSServiceRef*, DNSServiceFlags, uint32_t, DNSServiceProtocol, uint16_t, uint16_t, uint16_t, DNSServiceNATPortMappingReply, void* ); ++ typedef DNSServiceErrorType (DNSSD_API * Func)(DNSServiceRef*, DNSServiceFlags, uint32_t, DNSServiceProtocol, uint16_t, uint16_t, uint32_t, DNSServiceNATPortMappingReply, void* ); + static Func func = NULL; + DNSServiceErrorType ret = g_defaultErrorCode; + diff --git a/recipes/mdnsresponder/all/patches/878.200.35/Service.c.patch b/recipes/mdnsresponder/all/patches/878.200.35/Service.c.patch new file mode 100644 index 0000000000000..a07e42f9c45af --- /dev/null +++ b/recipes/mdnsresponder/all/patches/878.200.35/Service.c.patch @@ -0,0 +1,42 @@ +--- mDNSWindows/SystemService/Service.c ++++ mDNSWindows/SystemService/Service.c +@@ -1075,9 +1075,6 @@ + BOOL initialized; + BOOL ok; + +- DEBUG_UNUSED( argc ); +- DEBUG_UNUSED( argv ); +- + initialized = FALSE; + + // Make the service as running before we call ServiceSpecificInitialize. We've +@@ -1197,9 +1194,6 @@ + { + OSStatus err; + +- DEBUG_UNUSED( argc ); +- DEBUG_UNUSED( argv ); +- + mDNSPlatformMemZero( &gMDNSRecord, sizeof gMDNSRecord); + mDNSPlatformMemZero( &gPlatformStorage, sizeof gPlatformStorage); + +@@ -2127,9 +2121,8 @@ + } + + +-mDNSexport void RecordUpdatedNiceLabel(mDNS *const m, mDNSs32 delay) ++mDNSexport void RecordUpdatedNiceLabel(mDNSs32 delay) + { +- (void)m; + (void)delay; + // No-op, for now + } +@@ -2340,8 +2333,6 @@ + { + OSStatus err = kNoErr; + +- DEBUG_UNUSED( inMDNS ); +- + // + // Don't call SetLLRoute on loopback + // Default route on Windows 7 breaks network connectivity diff --git a/recipes/mdnsresponder/all/patches/878.200.35/mDNSResponder.sln.patch b/recipes/mdnsresponder/all/patches/878.200.35/mDNSResponder.sln.patch new file mode 100644 index 0000000000000..b824a508aa80f --- /dev/null +++ b/recipes/mdnsresponder/all/patches/878.200.35/mDNSResponder.sln.patch @@ -0,0 +1,333 @@ +--- mDNSResponder.sln ++++ mDNSResponder.sln +@@ -4,67 +4,13 @@ + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mDNSResponder", "mDNSWindows\SystemService\Service.vcxproj", "{C1D98254-BA27-4427-A3BE-A68CA2CC5F69}" + EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NSPTool", "mDNSWindows\NSPTool\NSPTool.vcxproj", "{208B3A9F-1CA0-4D1D-9D6C-C61616F94705}" +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mdnsNSP", "mDNSWindows\mdnsNSP\mdnsNSP.vcxproj", "{F4F15529-F0EB-402F-8662-73C5797EE557}" +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExplorerPlugin", "Clients\ExplorerPlugin\ExplorerPlugin.vcxproj", "{BB8AC1B5-6587-4163-BDC6-788B157705CA}" +- ProjectSection(ProjectDependencies) = postProject +- {1643427B-F226-4AD6-B413-97DA64D5C6B4} = {1643427B-F226-4AD6-B413-97DA64D5C6B4} +- EndProjectSection +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PrinterSetupWizard", "Clients\PrinterSetupWizard\PrinterSetupWizard.vcxproj", "{B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}" +- ProjectSection(ProjectDependencies) = postProject +- {967F5375-0176-43D3-ADA3-22EE25551C37} = {967F5375-0176-43D3-ADA3-22EE25551C37} +- EndProjectSection +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PrinterSetupWizardLocRes", "Clients\PrinterSetupWizard\PrinterSetupWizardLocRes.vcxproj", "{967F5375-0176-43D3-ADA3-22EE25551C37}" +- ProjectSection(ProjectDependencies) = postProject +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52} = {CFCCB176-6CAA-472B-B0A2-90511C8E2E52} +- EndProjectSection +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PrinterSetupWizardRes", "Clients\PrinterSetupWizard\PrinterSetupWizardRes.vcxproj", "{CFCCB176-6CAA-472B-B0A2-90511C8E2E52}" +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExplorerPluginLocRes", "Clients\ExplorerPlugin\ExplorerPluginLocRes.vcxproj", "{1643427B-F226-4AD6-B413-97DA64D5C6B4}" +- ProjectSection(ProjectDependencies) = postProject +- {871B1492-B4A4-4B57-9237-FA798484D7D7} = {871B1492-B4A4-4B57-9237-FA798484D7D7} +- EndProjectSection +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExplorerPluginRes", "Clients\ExplorerPlugin\ExplorerPluginRes.vcxproj", "{871B1492-B4A4-4B57-9237-FA798484D7D7}" +-EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dns-sd", "Clients\DNS-SD.VisualStudio\dns-sd.vcxproj", "{AA230639-E115-4A44-AA5A-44A61235BA50}" + ProjectSection(ProjectDependencies) = postProject + {AB581101-18F0-46F6-B56A-83A6B1EA657E} = {AB581101-18F0-46F6-B56A-83A6B1EA657E} + EndProjectSection + EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Java", "mDNSWindows\Java\Java.vcxproj", "{9CE2568A-3170-41C6-9F20-A0188A9EC114}" +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JavaSamples", "Clients\Java\JavaSamples.vcxproj", "{A987A0C1-344F-475C-869C-F082EB11EEBA}" +-EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DLLStub", "mDNSWindows\DLLStub\DLLStub.vcxproj", "{3A2B6325-3053-4236-84BD-AA9BE2E323E5}" + EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DLLX", "mDNSWindows\DLLX\DLLX.vcxproj", "{78FBFCC5-2873-4AE2-9114-A08082F71124}" +-EndProject +-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DNSServiceBrowser.NET", "Clients\DNSServiceBrowser.NET\DNSServiceBrowser.NET.csproj", "{DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}" +-EndProject +-Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DNSServiceBrowser.VB", "Clients\DNSServiceBrowser.VB\DNSServiceBrowser.VB.vbproj", "{FB79E297-5703-435C-A829-51AA51CD71C2}" +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mDNSNetMonitor", "Clients\mDNSNetMonitor.VisualStudio\mDNSNetMonitor.vcxproj", "{AF35C285-528D-46A1-8A0E-47B0733DC718}" +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ControlPanelLocRes", "mDNSWindows\ControlPanel\ControlPanelLocRes.vcxproj", "{4490229E-025A-478F-A2CF-51154DA83E39}" +- ProjectSection(ProjectDependencies) = postProject +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215} = {5254AA9C-3D2E-4539-86D9-5EB0F4151215} +- EndProjectSection +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ControlPanelRes", "mDNSWindows\ControlPanel\ControlPanelRes.vcxproj", "{5254AA9C-3D2E-4539-86D9-5EB0F4151215}" +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ControlPanel", "mDNSWindows\ControlPanel\ControlPanel.vcxproj", "{0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}" +- ProjectSection(ProjectDependencies) = postProject +- {4490229E-025A-478F-A2CF-51154DA83E39} = {4490229E-025A-478F-A2CF-51154DA83E39} +- EndProjectSection +-EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FirefoxExtension", "Clients\FirefoxExtension\FirefoxExtension.vcxproj", "{7826EA27-D4CC-4FAA-AD23-DF813823227B}" +-EndProject + Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU +@@ -105,118 +51,6 @@ + {C1D98254-BA27-4427-A3BE-A68CA2CC5F69}.Release|Win32.Build.0 = Release|Win32 + {C1D98254-BA27-4427-A3BE-A68CA2CC5F69}.Release|x64.ActiveCfg = Release|x64 + {C1D98254-BA27-4427-A3BE-A68CA2CC5F69}.Release|x64.Build.0 = Release|x64 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Debug|Win32.ActiveCfg = Debug|Win32 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Debug|Win32.Build.0 = Debug|Win32 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Debug|x64.ActiveCfg = Debug|x64 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Debug|x64.Build.0 = Debug|x64 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Release|Any CPU.ActiveCfg = Release|x64 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Release|Mixed Platforms.Build.0 = Release|x64 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Release|Win32.ActiveCfg = Release|Win32 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Release|Win32.Build.0 = Release|Win32 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Release|x64.ActiveCfg = Release|x64 +- {208B3A9F-1CA0-4D1D-9D6C-C61616F94705}.Release|x64.Build.0 = Release|x64 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Debug|Win32.ActiveCfg = Debug|Win32 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Debug|Win32.Build.0 = Debug|Win32 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Debug|x64.ActiveCfg = Debug|x64 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Debug|x64.Build.0 = Debug|x64 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Release|Any CPU.ActiveCfg = Release|x64 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Release|Mixed Platforms.Build.0 = Release|x64 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Release|Win32.ActiveCfg = Release|Win32 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Release|Win32.Build.0 = Release|Win32 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Release|x64.ActiveCfg = Release|x64 +- {F4F15529-F0EB-402F-8662-73C5797EE557}.Release|x64.Build.0 = Release|x64 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Debug|Win32.ActiveCfg = Debug|Win32 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Debug|Win32.Build.0 = Debug|Win32 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Debug|x64.ActiveCfg = Debug|x64 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Debug|x64.Build.0 = Debug|x64 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Release|Any CPU.ActiveCfg = Release|x64 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Release|Mixed Platforms.Build.0 = Release|x64 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Release|Win32.ActiveCfg = Release|Win32 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Release|Win32.Build.0 = Release|Win32 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Release|x64.ActiveCfg = Release|x64 +- {BB8AC1B5-6587-4163-BDC6-788B157705CA}.Release|x64.Build.0 = Release|x64 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Debug|Win32.ActiveCfg = Debug|Win32 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Debug|Win32.Build.0 = Debug|Win32 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Debug|x64.ActiveCfg = Debug|x64 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Debug|x64.Build.0 = Debug|x64 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Release|Any CPU.ActiveCfg = Release|x64 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Release|Mixed Platforms.Build.0 = Release|x64 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Release|Win32.ActiveCfg = Release|Win32 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Release|Win32.Build.0 = Release|Win32 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Release|x64.ActiveCfg = Release|x64 +- {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.Release|x64.Build.0 = Release|x64 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Debug|Win32.ActiveCfg = Debug|Win32 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Debug|Win32.Build.0 = Debug|Win32 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Debug|x64.ActiveCfg = Debug|x64 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Debug|x64.Build.0 = Debug|x64 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Release|Any CPU.ActiveCfg = Release|x64 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Release|Mixed Platforms.Build.0 = Release|x64 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Release|Win32.ActiveCfg = Release|Win32 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Release|Win32.Build.0 = Release|Win32 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Release|x64.ActiveCfg = Release|x64 +- {967F5375-0176-43D3-ADA3-22EE25551C37}.Release|x64.Build.0 = Release|x64 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Debug|Win32.ActiveCfg = Debug|Win32 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Debug|Win32.Build.0 = Debug|Win32 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Debug|x64.ActiveCfg = Debug|x64 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Debug|x64.Build.0 = Debug|x64 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Release|Any CPU.ActiveCfg = Release|x64 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Release|Mixed Platforms.Build.0 = Release|x64 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Release|Win32.ActiveCfg = Release|Win32 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Release|Win32.Build.0 = Release|Win32 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Release|x64.ActiveCfg = Release|x64 +- {CFCCB176-6CAA-472B-B0A2-90511C8E2E52}.Release|x64.Build.0 = Release|x64 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Debug|Win32.ActiveCfg = Debug|Win32 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Debug|Win32.Build.0 = Debug|Win32 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Debug|x64.ActiveCfg = Debug|x64 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Debug|x64.Build.0 = Debug|x64 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Release|Any CPU.ActiveCfg = Release|x64 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Release|Mixed Platforms.Build.0 = Release|x64 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Release|Win32.ActiveCfg = Release|Win32 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Release|Win32.Build.0 = Release|Win32 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Release|x64.ActiveCfg = Release|x64 +- {1643427B-F226-4AD6-B413-97DA64D5C6B4}.Release|x64.Build.0 = Release|x64 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Debug|Win32.ActiveCfg = Debug|Win32 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Debug|Win32.Build.0 = Debug|Win32 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Debug|x64.ActiveCfg = Debug|x64 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Debug|x64.Build.0 = Debug|x64 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Release|Any CPU.ActiveCfg = Release|x64 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Release|Mixed Platforms.Build.0 = Release|x64 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Release|Win32.ActiveCfg = Release|Win32 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Release|Win32.Build.0 = Release|Win32 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Release|x64.ActiveCfg = Release|x64 +- {871B1492-B4A4-4B57-9237-FA798484D7D7}.Release|x64.Build.0 = Release|x64 + {AA230639-E115-4A44-AA5A-44A61235BA50}.Debug|Any CPU.ActiveCfg = Debug|x64 + {AA230639-E115-4A44-AA5A-44A61235BA50}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 + {AA230639-E115-4A44-AA5A-44A61235BA50}.Debug|Mixed Platforms.Build.0 = Debug|x64 +@@ -231,32 +65,6 @@ + {AA230639-E115-4A44-AA5A-44A61235BA50}.Release|Win32.Build.0 = Release|Win32 + {AA230639-E115-4A44-AA5A-44A61235BA50}.Release|x64.ActiveCfg = Release|x64 + {AA230639-E115-4A44-AA5A-44A61235BA50}.Release|x64.Build.0 = Release|x64 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Debug|Win32.ActiveCfg = Debug|Win32 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Debug|Win32.Build.0 = Debug|Win32 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Debug|x64.ActiveCfg = Debug|x64 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Debug|x64.Build.0 = Debug|x64 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Release|Any CPU.ActiveCfg = Release|x64 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Release|Mixed Platforms.Build.0 = Release|x64 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Release|Win32.ActiveCfg = Release|Win32 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Release|Win32.Build.0 = Release|Win32 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Release|x64.ActiveCfg = Release|x64 +- {9CE2568A-3170-41C6-9F20-A0188A9EC114}.Release|x64.Build.0 = Release|x64 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Debug|Win32.ActiveCfg = Debug|Win32 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Debug|Win32.Build.0 = Debug|Win32 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Debug|x64.ActiveCfg = Debug|x64 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Release|Any CPU.ActiveCfg = Release|x64 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Release|Mixed Platforms.Build.0 = Release|x64 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Release|Win32.ActiveCfg = Release|Win32 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Release|Win32.Build.0 = Release|Win32 +- {A987A0C1-344F-475C-869C-F082EB11EEBA}.Release|x64.ActiveCfg = Release|x64 + {3A2B6325-3053-4236-84BD-AA9BE2E323E5}.Debug|Any CPU.ActiveCfg = Debug|x64 + {3A2B6325-3053-4236-84BD-AA9BE2E323E5}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 + {3A2B6325-3053-4236-84BD-AA9BE2E323E5}.Debug|Mixed Platforms.Build.0 = Debug|x64 +@@ -271,110 +79,6 @@ + {3A2B6325-3053-4236-84BD-AA9BE2E323E5}.Release|Win32.Build.0 = Release|Win32 + {3A2B6325-3053-4236-84BD-AA9BE2E323E5}.Release|x64.ActiveCfg = Release|x64 + {3A2B6325-3053-4236-84BD-AA9BE2E323E5}.Release|x64.Build.0 = Release|x64 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Debug|Win32.ActiveCfg = Debug|Win32 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Debug|Win32.Build.0 = Debug|Win32 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Debug|x64.ActiveCfg = Debug|x64 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Debug|x64.Build.0 = Debug|x64 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Release|Any CPU.ActiveCfg = Release|x64 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Release|Mixed Platforms.Build.0 = Release|x64 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Release|Win32.ActiveCfg = Release|Win32 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Release|Win32.Build.0 = Release|Win32 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Release|x64.ActiveCfg = Release|x64 +- {78FBFCC5-2873-4AE2-9114-A08082F71124}.Release|x64.Build.0 = Release|x64 +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Debug|Any CPU.Build.0 = Debug|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Debug|Win32.ActiveCfg = Debug|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Debug|x64.ActiveCfg = Debug|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Release|Any CPU.ActiveCfg = Release|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Release|Any CPU.Build.0 = Release|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Release|Win32.ActiveCfg = Release|Any CPU +- {DE8DB97E-37A3-43ED-9A5E-CCC5F6DE9CB4}.Release|x64.ActiveCfg = Release|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Debug|Any CPU.Build.0 = Debug|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Debug|Win32.ActiveCfg = Debug|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Debug|x64.ActiveCfg = Debug|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Release|Any CPU.ActiveCfg = Release|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Release|Any CPU.Build.0 = Release|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Release|Mixed Platforms.Build.0 = Release|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Release|Win32.ActiveCfg = Release|Any CPU +- {FB79E297-5703-435C-A829-51AA51CD71C2}.Release|x64.ActiveCfg = Release|Any CPU +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Debug|Any CPU.ActiveCfg = Debug|Win32 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Debug|Mixed Platforms.Build.0 = Debug|Win32 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Debug|Win32.ActiveCfg = Debug|Win32 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Debug|Win32.Build.0 = Debug|Win32 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Debug|x64.ActiveCfg = Debug|x64 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Release|Any CPU.ActiveCfg = Release|Win32 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Release|Mixed Platforms.ActiveCfg = Release|Win32 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Release|Mixed Platforms.Build.0 = Release|Win32 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Release|Win32.ActiveCfg = Release|Win32 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Release|Win32.Build.0 = Release|Win32 +- {AF35C285-528D-46A1-8A0E-47B0733DC718}.Release|x64.ActiveCfg = Release|Win32 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Debug|Win32.ActiveCfg = Debug|Win32 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Debug|Win32.Build.0 = Debug|Win32 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Debug|x64.ActiveCfg = Debug|x64 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Debug|x64.Build.0 = Debug|x64 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Release|Any CPU.ActiveCfg = Release|x64 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Release|Mixed Platforms.Build.0 = Release|x64 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Release|Win32.ActiveCfg = Release|Win32 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Release|Win32.Build.0 = Release|Win32 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Release|x64.ActiveCfg = Release|x64 +- {4490229E-025A-478F-A2CF-51154DA83E39}.Release|x64.Build.0 = Release|x64 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Debug|Win32.ActiveCfg = Debug|Win32 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Debug|Win32.Build.0 = Debug|Win32 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Debug|x64.ActiveCfg = Debug|x64 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Debug|x64.Build.0 = Debug|x64 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Release|Any CPU.ActiveCfg = Release|x64 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Release|Mixed Platforms.Build.0 = Release|x64 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Release|Win32.ActiveCfg = Release|Win32 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Release|Win32.Build.0 = Release|Win32 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Release|x64.ActiveCfg = Release|x64 +- {5254AA9C-3D2E-4539-86D9-5EB0F4151215}.Release|x64.Build.0 = Release|x64 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Debug|Any CPU.ActiveCfg = Debug|x64 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Debug|Mixed Platforms.Build.0 = Debug|x64 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Debug|Win32.ActiveCfg = Debug|Win32 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Debug|Win32.Build.0 = Debug|Win32 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Debug|x64.ActiveCfg = Debug|x64 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Debug|x64.Build.0 = Debug|x64 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Release|Any CPU.ActiveCfg = Release|x64 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Release|Mixed Platforms.ActiveCfg = Release|x64 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Release|Mixed Platforms.Build.0 = Release|x64 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Release|Win32.ActiveCfg = Release|Win32 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Release|Win32.Build.0 = Release|Win32 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Release|x64.ActiveCfg = Release|x64 +- {0DF09484-B4C2-4AB4-9FC0-7B091ADEAFEB}.Release|x64.Build.0 = Release|x64 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Debug|Any CPU.ActiveCfg = Debug|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Debug|Mixed Platforms.Build.0 = Debug|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Debug|Win32.ActiveCfg = Debug|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Debug|Win32.Build.0 = Debug|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Debug|x64.ActiveCfg = Debug|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Release|Any CPU.ActiveCfg = Release|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Release|Mixed Platforms.ActiveCfg = Release|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Release|Mixed Platforms.Build.0 = Release|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Release|Win32.ActiveCfg = Release|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Release|Win32.Build.0 = Release|Win32 +- {7826EA27-D4CC-4FAA-AD23-DF813823227B}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE diff --git a/recipes/mdnsresponder/all/patches/878.200.35/mDNSWin32.c.patch b/recipes/mdnsresponder/all/patches/878.200.35/mDNSWin32.c.patch new file mode 100644 index 0000000000000..2807abe1ea42f --- /dev/null +++ b/recipes/mdnsresponder/all/patches/878.200.35/mDNSWin32.c.patch @@ -0,0 +1,218 @@ +--- mDNSWindows/mDNSWin32.c ++++ mDNSWindows/mDNSWin32.c +@@ -55,6 +55,8 @@ + #include "dnssec.h" + #include "nsec.h" + ++extern mDNS mDNSStorage; ++ + #if 0 + #pragma mark == Constants == + #endif +@@ -718,16 +720,14 @@ + return ptr; + } + +-mDNSexport void DNSProxyInit(mDNS *const m, mDNSu32 IpIfArr[], mDNSu32 OpIf) ++mDNSexport void DNSProxyInit(mDNSu32 IpIfArr[], mDNSu32 OpIf) + { +- (void) m; + (void) IpIfArr; + (void) OpIf; + } + +-mDNSexport void DNSProxyTerminate(mDNS *const m) ++mDNSexport void DNSProxyTerminate(void) + { +- (void) m; + } + + //=========================================================================================================================== +@@ -972,7 +972,6 @@ + TCPSocket * + mDNSPlatformTCPSocket + ( +- mDNS * const m, + TCPSocketFlags flags, + mDNSIPPort * port, + mDNSBool useBackgroundTrafficClass +@@ -984,7 +983,6 @@ + int len; + mStatus err = mStatus_NoError; + +- DEBUG_UNUSED( m ); + DEBUG_UNUSED( useBackgroundTrafficClass ); + + require_action( flags == 0, exit, err = mStatus_UnsupportedErr ); +@@ -996,7 +994,7 @@ + mDNSPlatformMemZero( sock, sizeof( TCPSocket ) ); + sock->fd = INVALID_SOCKET; + sock->flags = flags; +- sock->m = m; ++ sock->m = &mDNSStorage; + + mDNSPlatformMemZero(&saddr, sizeof(saddr)); + saddr.sin_family = AF_INET; +@@ -1269,7 +1267,7 @@ + // mDNSPlatformUDPSocket + //=========================================================================================================================== + +-mDNSexport UDPSocket* mDNSPlatformUDPSocket(mDNS *const m, const mDNSIPPort requestedport) ++mDNSexport UDPSocket* mDNSPlatformUDPSocket(const mDNSIPPort requestedport) + { + UDPSocket* sock = NULL; + mDNSIPPort port = requestedport; +@@ -1285,10 +1283,10 @@ + // Create the socket + + sock->fd = INVALID_SOCKET; +- sock->recvMsgPtr = m->p->unicastSock4.recvMsgPtr; +- sock->addr = m->p->unicastSock4.addr; ++ sock->recvMsgPtr = mDNSStorage.p->unicastSock4.recvMsgPtr; ++ sock->addr = mDNSStorage.p->unicastSock4.addr; + sock->ifd = NULL; +- sock->m = m; ++ sock->m = &mDNSStorage; + + // Try at most 10000 times to get a unique random port + +@@ -1309,7 +1307,7 @@ + + saddr.sin_port = port.NotAnInteger; + +- err = SetupSocket(m, ( struct sockaddr* ) &saddr, port, &sock->fd ); ++ err = SetupSocket(sock->m, ( struct sockaddr* ) &saddr, port, &sock->fd ); + if (!err) break; + } + +@@ -1398,8 +1396,7 @@ + struct sockaddr_storage addr; + int n; + +- DEBUG_USE_ONLY( inMDNS ); +- DEBUG_USE_ONLY( useBackgroundTrafficClass ); ++ DEBUG_UNUSED( useBackgroundTrafficClass ); + + n = (int)( inMsgEnd - ( (const mDNSu8 * const) inMsg ) ); + check( inMDNS ); +@@ -1464,15 +1461,13 @@ + return( err ); + } + +-mDNSexport void mDNSPlatformUpdateProxyList(mDNS *const m, const mDNSInterfaceID InterfaceID) ++mDNSexport void mDNSPlatformUpdateProxyList(const mDNSInterfaceID InterfaceID) + { +- DEBUG_UNUSED( m ); + DEBUG_UNUSED( InterfaceID ); + } + +-mDNSexport void mDNSPlatformSetAllowSleep(mDNS *const m, mDNSBool allowSleep, const char *reason) ++mDNSexport void mDNSPlatformSetAllowSleep(mDNSBool allowSleep, const char *reason) + { +- DEBUG_UNUSED( m ); + DEBUG_UNUSED( allowSleep ); + DEBUG_UNUSED( reason ); + } +@@ -1481,7 +1476,7 @@ + // mDNSPlatformSendRawPacket + //=========================================================================================================================== + +-mDNSexport void mDNSPlatformSendWakeupPacket(mDNS *const m, mDNSInterfaceID InterfaceID, char *ethaddr, char *ipaddr, int iteration) ++mDNSexport void mDNSPlatformSendWakeupPacket(mDNSInterfaceID InterfaceID, char *ethaddr, char *ipaddr, int iteration) + { + unsigned char mac[ 6 ]; + unsigned char buf[ 102 ]; +@@ -1518,7 +1513,7 @@ + + info = ( MulticastWakeupStruct* ) malloc( sizeof( MulticastWakeupStruct ) ); + require_action( info, exit, err = mStatus_NoMemoryErr ); +- info->inMDNS = m; ++ info->inMDNS = &mDNSStorage; + memset( &info->addr, 0, sizeof( info->addr ) ); + info->addr.sin_family = AF_INET; + info->addr.sin_addr.s_addr = AllDNSLinkGroup_v4.ip.v4.NotAnInteger; +@@ -1566,9 +1561,8 @@ + if (bufsize) buf[0] = 0; + } + +-mDNSexport void mDNSPlatformSetLocalAddressCacheEntry(mDNS *const m, const mDNSAddr *const tpa, const mDNSEthAddr *const tha, mDNSInterfaceID InterfaceID) ++mDNSexport void mDNSPlatformSetLocalAddressCacheEntry(const mDNSAddr *const tpa, const mDNSEthAddr *const tha, mDNSInterfaceID InterfaceID) + { +- DEBUG_UNUSED( m ); + DEBUG_UNUSED( tpa ); + DEBUG_UNUSED( tha ); + DEBUG_UNUSED( InterfaceID ); +@@ -1595,7 +1589,6 @@ + + mDNSexport void mDNSPlatformWriteLogMsg( const char * ident, const char * msg, mDNSLogLevel_t loglevel ) + { +- extern mDNS mDNSStorage; + int type; + + DEBUG_UNUSED( ident ); +@@ -1650,11 +1643,11 @@ + mDNSlocal void SetDNSServers( mDNS *const m ); + mDNSlocal void SetSearchDomainList( void ); + +-mDNSexport mDNSBool mDNSPlatformSetDNSConfig(mDNS *const m, mDNSBool setservers, mDNSBool setsearch, domainname *const fqdn, DNameListElem **regDomains, DNameListElem **browseDomains, mDNSBool ackConfig) ++mDNSexport mDNSBool mDNSPlatformSetDNSConfig(mDNSBool setservers, mDNSBool setsearch, domainname *const fqdn, DNameListElem **regDomains, DNameListElem **browseDomains, mDNSBool ackConfig) + { + (void) ackConfig; + +- if (setservers) SetDNSServers(m); ++ if (setservers) SetDNSServers(&mDNSStorage); + if (setsearch) SetSearchDomainList(); + + if ( fqdn ) +@@ -2033,7 +2026,7 @@ + //=========================================================================================================================== + + mDNSexport mStatus +-mDNSPlatformGetPrimaryInterface( mDNS * const m, mDNSAddr * v4, mDNSAddr * v6, mDNSAddr * router ) ++mDNSPlatformGetPrimaryInterface( mDNSAddr * v4, mDNSAddr * v6, mDNSAddr * router ) + { + IP_ADAPTER_INFO * pAdapterInfo; + IP_ADAPTER_INFO * pAdapter; +@@ -2043,8 +2036,6 @@ + DWORD index; + mStatus err = mStatus_NoError; + +- DEBUG_UNUSED( m ); +- + *v6 = zeroAddr; + + pAdapterInfo = NULL; +@@ -2080,9 +2071,9 @@ + { + // Found one that will work + +- if ( pAdapter->AddressLength == sizeof( m->PrimaryMAC ) ) ++ if ( pAdapter->AddressLength == sizeof( mDNSStorage.PrimaryMAC ) ) + { +- memcpy( &m->PrimaryMAC, pAdapter->Address, pAdapter->AddressLength ); ++ memcpy( &mDNSStorage.PrimaryMAC, pAdapter->Address, pAdapter->AddressLength ); + } + + found = TRUE; +@@ -2111,9 +2102,8 @@ + (void) win; // Unused + } + +-mDNSexport mStatus mDNSPlatformGetRemoteMacAddr(mDNS *const m, mDNSAddr *raddr) ++mDNSexport mStatus mDNSPlatformGetRemoteMacAddr(mDNSAddr *raddr) + { +- (void) m; // Unused + (void) raddr; // Unused + + return mStatus_UnsupportedErr; +@@ -2140,9 +2130,8 @@ + return mStatus_UnsupportedErr; + } + +-mDNSexport mStatus mDNSPlatformRetrieveTCPInfo(mDNS *const m, mDNSAddr *laddr, mDNSIPPort *lport, mDNSAddr *raddr, mDNSIPPort *rport, mDNSTCPInfo *mti) ++mDNSexport mStatus mDNSPlatformRetrieveTCPInfo(mDNSAddr *laddr, mDNSIPPort *lport, mDNSAddr *raddr, mDNSIPPort *rport, mDNSTCPInfo *mti) + { +- (void) m; // Unused + (void) laddr; // Unused + (void) raddr; // Unused + (void) lport; // Unused diff --git a/recipes/mdnsresponder/all/patches/878.200.35/opt/permit-over-long-service-types.patch b/recipes/mdnsresponder/all/patches/878.200.35/opt/permit-over-long-service-types.patch new file mode 100644 index 0000000000000..5a8e85f7ff091 --- /dev/null +++ b/recipes/mdnsresponder/all/patches/878.200.35/opt/permit-over-long-service-types.patch @@ -0,0 +1,11 @@ +--- a/mDNSCore/DNSCommon.c ++++ b/mDNSCore/DNSCommon.c +@@ -1039,7 +1039,7 @@ + LogMsg("Bad service type in %#s.%##s%##s Application protocol name must be underscore plus 1-15 characters. " + "See ", name->c, type->c, domain->c); + } +- if (len < 2 || len >= 0x40 || (len > 16 && !SameDomainName(domain, &localdomain))) return(mDNSNULL); ++ if (len < 2 || len >= 0x40) return(mDNSNULL); + if (src[1] != '_') { errormsg = "Application protocol name must begin with underscore"; goto fail; } + for (i=2; i<=len; i++) + { diff --git a/recipes/mdnsresponder/all/patches/878.200.35/opt/poll-rather-than-select.patch b/recipes/mdnsresponder/all/patches/878.200.35/opt/poll-rather-than-select.patch new file mode 100644 index 0000000000000..c1edd65a7baca --- /dev/null +++ b/recipes/mdnsresponder/all/patches/878.200.35/opt/poll-rather-than-select.patch @@ -0,0 +1,121 @@ +From a1b3c1faa53c8c51aa52361bf7035d6fc91b747d Mon Sep 17 00:00:00 2001 +From: garethsb-sony +Date: Mon, 26 Feb 2018 12:58:27 +0000 +Subject: [PATCH] On Linux, use poll rather than select to wait on the socket + +--- + .../mDNSShared/dnssd_clientstub.c | 77 ++++++++-------------- + 1 file changed, 30 insertions(+), 47 deletions(-) + +diff --git a/mDNSShared/dnssd_clientstub.c b/mDNSShared/dnssd_clientstub.c +index 27e90ee..d0bfcd3 100644 +--- a/mDNSShared/dnssd_clientstub.c ++++ b/mDNSShared/dnssd_clientstub.c +@@ -80,6 +80,7 @@ static void syslog( int priority, const char * message, ...) + } + #else + ++ #include + #include // For O_RDWR etc. + #include + #include +@@ -283,46 +284,23 @@ static int read_all(dnssd_sock_t sd, char *buf, int len) + // Returns 1 if more bytes remain to be read on socket descriptor sd, 0 otherwise + static int more_bytes(dnssd_sock_t sd) + { +- struct timeval tv = { 0, 0 }; +- fd_set readfds; +- fd_set *fs; + int ret; + + #if defined(_WIN32) +- fs = &readfds; +- FD_ZERO(fs); +- FD_SET(sd, fs); +- ret = select((int)sd+1, fs, (fd_set*)NULL, (fd_set*)NULL, &tv); ++ struct timeval tv = { 0, 0 }; ++ fd_set readfds; ++ FD_ZERO(&readfds); ++ FD_SET(sd, &readfds); ++ ret = select((int)sd+1, &readfds, (fd_set*)NULL, (fd_set*)NULL, &tv); + #else +- if (sd < FD_SETSIZE) +- { +- fs = &readfds; +- FD_ZERO(fs); +- } +- else +- { +- // Compute the number of integers needed for storing "sd". Internally fd_set is stored +- // as an array of ints with one bit for each fd and hence we need to compute +- // the number of ints needed rather than the number of bytes. If "sd" is 32, we need +- // two ints and not just one. +- int nfdbits = sizeof (int) * 8; +- int nints = (sd/nfdbits) + 1; +- fs = (fd_set *)calloc(nints, (size_t)sizeof(int)); +- if (fs == NULL) +- { +- syslog(LOG_WARNING, "dnssd_clientstub more_bytes: malloc failed"); +- return 0; +- } +- } +- FD_SET(sd, fs); +- ret = select((int)sd+1, fs, (fd_set*)NULL, (fd_set*)NULL, &tv); +- if (fs != &readfds) +- free(fs); ++ // Use poll in order to be able to wait for a file descriptor larger than FD_SETSIZE ++ struct pollfd pfd_read = { sd, POLLIN, 0 }; ++ ret = poll(&pfd_read, 1, 0); + #endif + return (ret > 0); + } + +-// set_waitlimit() implements a timeout using select. It is called from deliver_request() before recv() OR accept() ++// set_waitlimit() implements a timeout using select or poll. It is called from deliver_request() before recv() OR accept() + // to ensure the UDS clients are not blocked in these system calls indefinitely. + // Note: Ideally one should never be blocked here, because it indicates either mDNSResponder daemon is not yet up/hung/ + // superbusy/crashed or some other OS bug. For eg: On Windows which suffers from 3rd party software +@@ -331,23 +309,28 @@ static int more_bytes(dnssd_sock_t sd) + static int set_waitlimit(dnssd_sock_t sock, int timeout) + { + int gDaemonErr = kDNSServiceErr_NoError; ++ int ret; + +- // To prevent stack corruption since select does not work with timeout if fds > FD_SETSIZE(1024) +- if (!gDaemonErr && sock < FD_SETSIZE) +- { +- struct timeval tv; +- fd_set set; ++#if defined(_WIN32) ++ struct timeval tv; ++ fd_set set; ++ ++ FD_ZERO(&set); ++ FD_SET(sock, &set); ++ tv.tv_sec = timeout; ++ tv.tv_usec = 0; ++ ret = select((int)(sock + 1), &set, NULL, NULL, &tv); ++#else ++ // Use poll in order to be able to wait for a file descriptor larger than FD_SETSIZE ++ struct pollfd pfd_read = { sock, POLLIN, 0 }; ++ ret = poll(&pfd_read, 1, timeout * 1000); ++#endif + +- FD_ZERO(&set); +- FD_SET(sock, &set); +- tv.tv_sec = timeout; +- tv.tv_usec = 0; +- if (!select((int)(sock + 1), &set, NULL, NULL, &tv)) +- { +- // Ideally one should never hit this case: See comments before set_waitlimit() +- syslog(LOG_WARNING, "dnssd_clientstub set_waitlimit:_daemon timed out (%d secs) without any response: Socket %d", timeout, sock); +- gDaemonErr = kDNSServiceErr_Timeout; +- } ++ if (!(ret > 0)) ++ { ++ // Ideally one should never hit this case: See comments before set_waitlimit() ++ syslog(LOG_WARNING, "dnssd_clientstub set_waitlimit:_daemon timed out (%d secs) without any response: Socket %d", timeout, sock); ++ gDaemonErr = kDNSServiceErr_Timeout; + } + return gDaemonErr; + } diff --git a/recipes/mdnsresponder/all/patches/878.200.35/opt/unicast.patch b/recipes/mdnsresponder/all/patches/878.200.35/opt/unicast.patch new file mode 100644 index 0000000000000..3990e7008591c --- /dev/null +++ b/recipes/mdnsresponder/all/patches/878.200.35/opt/unicast.patch @@ -0,0 +1,538 @@ +--- a/mDNSPosix/Identify.c ++++ b/mDNSPosix/Identify.c +@@ -22,8 +22,10 @@ + // We want to use the functionality provided by "mDNS.c", + // except we'll sneak a peek at the packets before forwarding them to the normal mDNSCoreReceive() routine + #define mDNSCoreReceive __MDNS__mDNSCoreReceive ++#define UDPSocket_struct __UDPSocket_struct + #include "mDNS.c" + #undef mDNSCoreReceive ++#undef UDPSocket_struct + + //************************************************************************************************************* + // Headers +--- a/mDNSPosix/NetMonitor.c ++++ b/mDNSPosix/NetMonitor.c +@@ -22,8 +22,10 @@ + // We want to use much of the functionality provided by "mDNS.c", + // except we'll steal the packets that would be sent to normal mDNSCoreReceive() routine + #define mDNSCoreReceive __NOT__mDNSCoreReceive__NOT__ ++#define UDPSocket_struct __UDPSocket_struct + #include "../mDNSCore/mDNS.c" + #undef mDNSCoreReceive ++#undef UDPSocket_struct + + //************************************************************************************************************* + // Headers +--- a/mDNSPosix/mDNSPosix.c ++++ b/mDNSPosix/mDNSPosix.c +@@ -75,6 +75,13 @@ + }; + typedef struct IfChangeRec IfChangeRec; + ++// Platform-dependent low-level networking stuff ++ ++mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interfaceIndex, int *sktPtr, mDNSIPPort* outport, ++ mDNSBool joinMC); ++ ++static struct UDPSocket_struct* PlatformUDPSockets = NULL; ++ + // Note that static data is initialized to zero in (modern) C. + static fd_set gEventFDs; + static int gMaxFD; // largest fd in gEventFDs +@@ -147,7 +154,6 @@ + PosixNetworkInterface * thisIntf = (PosixNetworkInterface *)(InterfaceID); + int sendingsocket = -1; + +- (void)src; // Will need to use this parameter once we implement mDNSPlatformUDPSocket/mDNSPlatformUDPClose + (void) useBackgroundTrafficClass; + + assert(m != NULL); +@@ -169,7 +175,7 @@ + sin->sin_family = AF_INET; + sin->sin_port = dstPort.NotAnInteger; + sin->sin_addr.s_addr = dst->ip.v4.NotAnInteger; +- sendingsocket = thisIntf ? thisIntf->multicastSocket4 : m->p->unicastSocket4; ++ sendingsocket = (src) ? (src->sktv4) : (thisIntf ? thisIntf->multicastSocket4 : m->p->unicastSocket4); + } + + #if HAVE_IPV6 +@@ -183,7 +189,7 @@ + sin6->sin6_family = AF_INET6; + sin6->sin6_port = dstPort.NotAnInteger; + sin6->sin6_addr = *(struct in6_addr*)&dst->ip.v6; +- sendingsocket = thisIntf ? thisIntf->multicastSocket6 : m->p->unicastSocket6; ++ sendingsocket = (src) ? (src->sktv6) : (thisIntf ? thisIntf->multicastSocket6 : m->p->unicastSocket6); + } + #endif + +@@ -213,7 +219,7 @@ + } + + // This routine is called when the main loop detects that data is available on a socket. +-mDNSlocal void SocketDataReady(mDNS *const m, PosixNetworkInterface *intf, int skt) ++mDNSlocal void SocketDataReady(mDNS *const m, PosixNetworkInterface *intf, int skt, mDNSIPPort localPort) + { + mDNSAddr senderAddr, destAddr; + mDNSIPPort senderPort; +@@ -309,7 +315,7 @@ + + if (packetLen >= 0) + mDNSCoreReceive(m, &packet, (mDNSu8 *)&packet + packetLen, +- &senderAddr, senderPort, &destAddr, MulticastDNSPort, InterfaceID); ++ &senderAddr, senderPort, &destAddr, mDNSIPPortIsZero(localPort) ? MulticastDNSPort : localPort, InterfaceID); + } + + mDNSexport TCPSocket *mDNSPlatformTCPSocket(TCPSocketFlags flags, mDNSIPPort * port, mDNSBool useBackgroundTrafficClass) +@@ -317,6 +323,7 @@ + (void)flags; // Unused + (void)port; // Unused + (void)useBackgroundTrafficClass; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + return NULL; + } + +@@ -324,12 +331,14 @@ + { + (void)flags; // Unused + (void)sd; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + return NULL; + } + + mDNSexport int mDNSPlatformTCPGetFD(TCPSocket *sock) + { + (void)sock; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + return -1; + } + +@@ -343,12 +352,14 @@ + (void)InterfaceID; // Unused + (void)callback; // Unused + (void)context; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + return(mStatus_UnsupportedErr); + } + + mDNSexport void mDNSPlatformTCPCloseConnection(TCPSocket *sock) + { + (void)sock; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + } + + mDNSexport long mDNSPlatformReadTCP(TCPSocket *sock, void *buf, unsigned long buflen, mDNSBool * closed) +@@ -357,6 +368,7 @@ + (void)buf; // Unused + (void)buflen; // Unused + (void)closed; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + return 0; + } + +@@ -365,23 +377,88 @@ + (void)sock; // Unused + (void)msg; // Unused + (void)len; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + return 0; + } + +-mDNSexport UDPSocket *mDNSPlatformUDPSocket(mDNSIPPort port) ++mDNSexport UDPSocket *mDNSPlatformUDPSocket(mDNSIPPort requestedPort) + { +- (void)port; // Unused +- return NULL; ++ mStatus err; ++ mDNSIPPort port = requestedPort; ++ mDNSBool randomizePort = mDNSIPPortIsZero(requestedPort); ++ struct sockaddr sa; ++ int i = 1000; // Try at most 1000 times to get a unique random port ++ UDPSocket *p = mallocL("UDPSocket", sizeof(UDPSocket)); ++ if (!p) { LogMsg("mDNSPlatformUDPSocket: memory exhausted"); return(mDNSNULL); } ++ mDNSPlatformMemZero(p, sizeof(UDPSocket)); ++ p->port = zeroIPPort; ++ p->sktv4 = -1; ++ p->sktv6 = -1; ++ ++ do { ++ // The kernel doesn't do cryptographically strong random port allocation, so we do it ourselves here ++ if (randomizePort) port = mDNSOpaque16fromIntVal(0xC000 + mDNSRandom(0x3FFF)); ++ mDNSPlatformMemZero(&sa, sizeof(struct sockaddr)); ++ sa.sa_family = AF_INET; ++ err = SetupSocket(&sa, port, 0, &p->sktv4, &p->port, mDNSSameIPPort(requestedPort, NATPMPAnnouncementPort)); ++ /* TODO: make me work! ++ if (!err) ++ { ++ mDNSPlatformMemZero(&sa, sizeof(struct sockaddr)); ++ sa.sa_family = AF_INET6; ++ err = SetupSocket(&sa, port, 0, &p->sktv6, &p->port, 0); ++ if (err) { close(p->sktv4); p->sktv4 = -1; } ++ }*/ ++ i--; ++ } while (err == EADDRINUSE && randomizePort && i); ++ ++ if (err) { ++ // In customer builds we don't want to log failures with port 5351, because this is a known issue ++ // of failing to bind to this port when Internet Sharing has already bound to it ++ // We also don't want to log about port 5350, due to a known bug when some other ++ // process is bound to it. ++ if (mDNSSameIPPort(requestedPort, NATPMPPort) || mDNSSameIPPort(requestedPort, NATPMPAnnouncementPort)) ++ LogInfo("mDNSPlatformUDPSocket: SetupSocket %d failed error %d errno %d (%s)", mDNSVal16(requestedPort), err, errno, strerror(errno)); ++ else LogMsg("mDNSPlatformUDPSocket: SetupSocket %d failed error %d errno %d (%s)", mDNSVal16(requestedPort), err, errno, strerror(errno)); ++ freeL("UDPSocket", p); ++ return(mDNSNULL); ++ } ++ ++ p->prev = NULL; ++ p->next = PlatformUDPSockets; ++ if (p->next) ++ p->next->prev = p; ++ PlatformUDPSockets = p; ++ ++ return(p); + } + +-mDNSexport void mDNSPlatformUDPClose(UDPSocket *sock) ++mDNSexport void mDNSPlatformUDPClose(UDPSocket *sock) + { +- (void)sock; // Unused ++ if (sock->sktv4 > -1) { ++ close(sock->sktv4); ++ sock->sktv4 = -1; ++ } ++ if (sock->sktv6 > -1) { ++ close(sock->sktv6); ++ sock->sktv6 = -1; ++ } ++ ++ if (sock->prev) ++ sock->prev->next = sock->next; ++ else ++ PlatformUDPSockets = sock->next; ++ ++ if (sock->next) ++ sock->next->prev = sock->prev; ++ ++ freeL("UDPSocket", sock); + } + + mDNSexport void mDNSPlatformUpdateProxyList(const mDNSInterfaceID InterfaceID) + { + (void)InterfaceID; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + } + + mDNSexport void mDNSPlatformSendRawPacket(const void *const msg, const mDNSu8 *const end, mDNSInterfaceID InterfaceID) +@@ -389,6 +466,7 @@ + (void)msg; // Unused + (void)end; // Unused + (void)InterfaceID; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + } + + mDNSexport void mDNSPlatformSetLocalAddressCacheEntry(const mDNSAddr *const tpa, const mDNSEthAddr *const tha, mDNSInterfaceID InterfaceID) +@@ -396,21 +474,33 @@ + (void)tpa; // Unused + (void)tha; // Unused + (void)InterfaceID; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); ++} ++ ++mDNSexport void mDNSPlatformSetLocalARP(const mDNSv4Addr *const tpa, const mDNSEthAddr *const tha, mDNSInterfaceID InterfaceID) ++{ ++ (void)tpa; // Unused ++ (void)tha; // Unused ++ (void)InterfaceID; // Unused ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + } + + mDNSexport mStatus mDNSPlatformTLSSetupCerts(void) + { ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + return(mStatus_UnsupportedErr); + } + + mDNSexport void mDNSPlatformTLSTearDownCerts(void) + { ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + } + + mDNSexport void mDNSPlatformSetAllowSleep(mDNSBool allowSleep, const char *reason) + { + (void) allowSleep; + (void) reason; ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + } + + #if COMPILER_LIKES_PRAGMA_MARK +@@ -443,19 +533,104 @@ + return mDNStrue; + } + ++#ifdef TARGET_OS_LINUX ++#include ++#endif ++ + mDNSexport mStatus mDNSPlatformGetPrimaryInterface(mDNSAddr * v4, mDNSAddr * v6, mDNSAddr * router) ++#ifdef TARGET_OS_LINUX + { ++ unsigned long d, g; ++ char buf[256]; ++ int line = 0; ++ FILE * f; ++ char * p; ++ ++ // TODO: where/how to get ipv6 address? ++ if (v6) ++ *v6 = zeroAddr; ++ ++ f = fopen("/proc/net/route", "r"); ++ ++ if (!f) ++ return mStatus_UnknownErr; ++ ++ while(fgets(buf, sizeof(buf), f)) { ++ if(line > 0) { /* skip the first line */ ++ p = buf; ++ ++ /* skip the interface name */ ++ while(*p && !isspace(*p)) ++ p++; ++ ++ *p++ = '\0'; ++ ++ while(*p && isspace(*p)) ++ p++; ++ ++ if(sscanf(p, "%lx%lx", &d, &g)==2) { ++ if(d == 0 && g != 0) { ++ if (router) { ++ router->type = mDNSAddrType_IPv4; ++ router->ip.v4.NotAnInteger = g; ++ } ++ fclose(f); ++ ++ int sock = socket(AF_INET, SOCK_DGRAM, 0); ++ if (sock > -1) { ++ struct sockaddr_in sin; ++ socklen_t socklen = sizeof(struct sockaddr_in); ++ ++ mDNSPlatformMemZero(&sin, socklen); ++ sin.sin_port = htons(3000); ++ sin.sin_addr.s_addr = INADDR_ANY; ++ sin.sin_family = AF_INET; ++ ++ ++ if (connect(sock, (struct sockaddr*)&sin, socklen) >= 0 && ++ getsockname(sock, (struct sockaddr*)&sin, &socklen) >= 0) { ++ ++ if (v4) { ++ v4->type = mDNSAddrType_IPv4; ++ v4->ip.v4.NotAnInteger = sin.sin_addr.s_addr; ++ } ++ ++ return mStatus_NoError; ++ } ++ ++ close(sock); ++ } ++ ++ return mStatus_UnknownErr; ++ } ++ } ++ } ++ ++ line++; ++ } ++ ++ /* default route not found ! */ ++ if (f) ++ fclose(f); ++ ++ return mStatus_UnknownErr; ++} ++#else ++{ ++ (void) m; + (void) v4; + (void) v6; + (void) router; + + return mStatus_UnsupportedErr; + } ++#endif + + mDNSexport void mDNSPlatformDynDNSHostNameStatusChanged(const domainname *const dname, const mStatus status) + { + (void) dname; + (void) status; ++ LogMsg("%s:%s(): NOT IMPLEMENTED!", __FILE__, __FUNCTION__); + } + + #if COMPILER_LIKES_PRAGMA_MARK +@@ -502,8 +677,9 @@ + mDNS_AddDNSServer(m, NULL, mDNSInterface_Any, 0, &DNSAddr, UnicastDNSPort, kScopeNone, 0, mDNSfalse, mDNSfalse, 0, mDNStrue, mDNStrue, mDNSfalse); + numOfServers++; + } ++ keyword[0] = nameserver[0] = 0; + } +- fclose(fp); ++ fclose(fp); + return (numOfServers > 0) ? 0 : -1; + } + +@@ -611,13 +787,14 @@ + // Sets up a send/receive socket. + // If mDNSIPPort port is non-zero, then it's a multicast socket on the specified interface + // If mDNSIPPort port is zero, then it's a randomly assigned port number, used for sending unicast queries +-mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interfaceIndex, int *sktPtr) ++mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interfaceIndex, int *sktPtr, mDNSIPPort* outport, mDNSBool joinMC) + { + int err = 0; + static const int kOn = 1; + static const int kIntTwoFiveFive = 255; + static const unsigned char kByteTwoFiveFive = 255; +- const mDNSBool JoinMulticastGroup = (port.NotAnInteger != 0); ++ const mDNSBool JoinMulticastGroup = joinMC; ++ const mDNSBool isNATPMPAnnouncePort = mDNSSameIPPort(port, NATPMPAnnouncementPort); + + (void) interfaceIndex; // This parameter unused on plaforms that don't have IPv6 + assert(intfAddr != NULL); +@@ -703,7 +880,7 @@ + // Add multicast group membership on this interface + if (err == 0 && JoinMulticastGroup) + { +- imr.imr_multiaddr.s_addr = AllDNSLinkGroup_v4.ip.v4.NotAnInteger; ++ imr.imr_multiaddr.s_addr = isNATPMPAnnouncePort ? AllHosts_v4.NotAnInteger : AllDNSLinkGroup_v4.ip.v4.NotAnInteger; + imr.imr_interface = ((struct sockaddr_in*)intfAddr)->sin_addr; + err = setsockopt(*sktPtr, IPPROTO_IP, IP_ADD_MEMBERSHIP, &imr, sizeof(imr)); + if (err < 0) { err = errno; perror("setsockopt - IP_ADD_MEMBERSHIP"); } +@@ -738,9 +915,10 @@ + { + bindAddr.sin_family = AF_INET; + bindAddr.sin_port = port.NotAnInteger; +- bindAddr.sin_addr.s_addr = INADDR_ANY; // Want to receive multicasts AND unicasts on this socket ++ bindAddr.sin_addr.s_addr = isNATPMPAnnouncePort ? AllHosts_v4.NotAnInteger : INADDR_ANY; + err = bind(*sktPtr, (struct sockaddr *) &bindAddr, sizeof(bindAddr)); + if (err < 0) { err = errno; perror("bind"); fflush(stderr); } ++ if (outport) outport->NotAnInteger = bindAddr.sin_port; + } + } // endif (intfAddr->sa_family == AF_INET) + +@@ -911,10 +1089,10 @@ + if (err == 0) + { + if (alias->multicastSocket4 == -1 && intfAddr->sa_family == AF_INET) +- err = SetupSocket(intfAddr, MulticastDNSPort, intf->index, &alias->multicastSocket4); ++ err = SetupSocket(intfAddr, MulticastDNSPort, intf->index, &alias->multicastSocket4, NULL, 1); + #if HAVE_IPV6 + else if (alias->multicastSocket6 == -1 && intfAddr->sa_family == AF_INET6) +- err = SetupSocket(intfAddr, MulticastDNSPort, intf->index, &alias->multicastSocket6); ++ err = SetupSocket(intfAddr, MulticastDNSPort, intf->index, &alias->multicastSocket6, NULL, 1); + #endif + } + +@@ -1292,11 +1470,11 @@ + + sa.sa_family = AF_INET; + m->p->unicastSocket4 = -1; +- if (err == mStatus_NoError) err = SetupSocket(&sa, zeroIPPort, 0, &m->p->unicastSocket4); ++ if (err == mStatus_NoError) err = SetupSocket(&sa, zeroIPPort, 0, &m->p->unicastSocket4, NULL, 0); + #if HAVE_IPV6 + sa.sa_family = AF_INET6; + m->p->unicastSocket6 = -1; +- if (err == mStatus_NoError) err = SetupSocket(&sa, zeroIPPort, 0, &m->p->unicastSocket6); ++ if (err == mStatus_NoError) err = SetupSocket(&sa, zeroIPPort, 0, &m->p->unicastSocket6, NULL, 0); + #endif + + // Tell mDNS core about the network interfaces on this machine. +@@ -1685,6 +1863,16 @@ + info = (PosixNetworkInterface *)(info->coreIntf.next); + } + ++ UDPSocket* socks = PlatformUDPSockets; ++ while (socks) { ++ if (socks->sktv4 > -1) mDNSPosixAddToFDSet(nfds, readfds, socks->sktv4); ++#if HAVE_IPV6 ++ if (socks->sktv6 > -1) mDNSPosixAddToFDSet(nfds, readfds, socks->sktv6); ++#endif ++ ++ socks = socks->next; ++ } ++ + // 3. Calculate the time remaining to the next scheduled event (in struct timeval format) + ticks = nextevent - mDNS_TimeNow(m); + if (ticks < 1) ticks = 1; +@@ -1707,13 +1895,13 @@ + if (m->p->unicastSocket4 != -1 && FD_ISSET(m->p->unicastSocket4, readfds)) + { + FD_CLR(m->p->unicastSocket4, readfds); +- SocketDataReady(m, NULL, m->p->unicastSocket4); ++ SocketDataReady(m, NULL, m->p->unicastSocket4, zeroIPPort); + } + #if HAVE_IPV6 + if (m->p->unicastSocket6 != -1 && FD_ISSET(m->p->unicastSocket6, readfds)) + { + FD_CLR(m->p->unicastSocket6, readfds); +- SocketDataReady(m, NULL, m->p->unicastSocket6); ++ SocketDataReady(m, NULL, m->p->unicastSocket6, zeroIPPort); + } + #endif + +@@ -1722,17 +1910,33 @@ + if (info->multicastSocket4 != -1 && FD_ISSET(info->multicastSocket4, readfds)) + { + FD_CLR(info->multicastSocket4, readfds); +- SocketDataReady(m, info, info->multicastSocket4); ++ SocketDataReady(m, info, info->multicastSocket4, zeroIPPort); + } + #if HAVE_IPV6 + if (info->multicastSocket6 != -1 && FD_ISSET(info->multicastSocket6, readfds)) + { + FD_CLR(info->multicastSocket6, readfds); +- SocketDataReady(m, info, info->multicastSocket6); ++ SocketDataReady(m, info, info->multicastSocket6, zeroIPPort); + } + #endif + info = (PosixNetworkInterface *)(info->coreIntf.next); + } ++ ++ UDPSocket* socks = PlatformUDPSockets; ++ while (socks) { ++ if (socks->sktv4 > -1 && FD_ISSET(socks->sktv4, readfds)) { ++ FD_CLR(socks->sktv4, readfds); ++ SocketDataReady(m, NULL, socks->sktv4, socks->port); ++ } ++#if HAVE_IPV6 ++ if (socks->sktv6 > -1 && FD_ISSET(socks->sktv6, readfds)) { ++ FD_CLR(socks->sktv6, readfds); ++ SocketDataReady(m, NULL, socks->sktv6, socks->port); ++ } ++#endif ++ ++ socks = socks->next; ++ } + } + + // update gMaxFD +--- a/mDNSPosix/mDNSPosix.h ++++ b/mDNSPosix/mDNSPosix.h +@@ -57,6 +57,17 @@ + #endif + }; + ++// Platform-specific low-level networking code ++ ++struct UDPSocket_struct { ++ mDNSIPPort port; ++ int sktv4; ++ int sktv6; ++ ++ struct UDPSocket_struct* next; ++ struct UDPSocket_struct* prev; ++}; ++ + #define uDNS_SERVERS_FILE "/etc/resolv.conf" + extern int ParseDNSServers(mDNS *m, const char *filePath); + extern mStatus mDNSPlatformPosixRefreshInterfaceList(mDNS *const m); diff --git a/recipes/mdnsresponder/all/test_package/CMakeLists.txt b/recipes/mdnsresponder/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..34af13462f44f --- /dev/null +++ b/recipes/mdnsresponder/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/mdnsresponder/all/test_package/conanfile.py b/recipes/mdnsresponder/all/test_package/conanfile.py new file mode 100644 index 0000000000000..fdb9f346a1da9 --- /dev/null +++ b/recipes/mdnsresponder/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mdnsresponder/all/test_package/test_package.c b/recipes/mdnsresponder/all/test_package/test_package.c new file mode 100644 index 0000000000000..bae1467c7d687 --- /dev/null +++ b/recipes/mdnsresponder/all/test_package/test_package.c @@ -0,0 +1,18 @@ +#include +#include + +int main() +{ + DNSServiceRef sdRef; + DNSServiceErrorType err = DNSServiceBrowse(&sdRef, 0, 0, "_example._tcp", NULL, NULL, NULL); + if (err == kDNSServiceErr_NoError) + { + printf("DNSServiceBrowse succeeded\n"); + DNSServiceRefDeallocate(sdRef); + } + else + { + printf("DNSServiceBrowse failed: %d\n", err); + } + return 0; +} diff --git a/recipes/mdnsresponder/config.yml b/recipes/mdnsresponder/config.yml new file mode 100644 index 0000000000000..a8ca75314b5a1 --- /dev/null +++ b/recipes/mdnsresponder/config.yml @@ -0,0 +1,5 @@ +versions: + "878.200.35": + folder: all + "1310.140.1": + folder: all diff --git a/recipes/meshoptimizer/all/CMakeLists.txt b/recipes/meshoptimizer/all/CMakeLists.txt deleted file mode 100644 index a60992e8dd75d..0000000000000 --- a/recipes/meshoptimizer/all/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include("conanbuildinfo.cmake") - -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/meshoptimizer/all/conandata.yml b/recipes/meshoptimizer/all/conandata.yml index 2a202fcd1bb21..1132907df3841 100644 --- a/recipes/meshoptimizer/all/conandata.yml +++ b/recipes/meshoptimizer/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "0.17": + url: "https://github.com/zeux/meshoptimizer/archive/refs/tags/v0.17.tar.gz" + sha256: "50f134da6739702d4398f2a3c614acb1d80afb73afed27ac68bc55c9edae64e2" "0.16": url: "https://github.com/zeux/meshoptimizer/archive/v0.16.tar.gz" sha256: "f2bb6518b7a33b20aaa984a72d0094809b971e6aebb62b627cd8108afb3f6937" @@ -10,5 +13,4 @@ sources: sha256: "5a6e429ecf72325131b439a46297a690f0cab833c7563efdadab26c0a6cf8490" patches: "0.14": - - patch_file: "patches/0.14/001_Fix build_on_old_AppleClang_versions.patch" - base_path: "source_subfolder" + - patch_file: "patches/0.14/0001-fix-build-on-old-AppleClang-versions.patch" diff --git a/recipes/meshoptimizer/all/conanfile.py b/recipes/meshoptimizer/all/conanfile.py index 6be0f8f0d97a4..174a3955a5f63 100644 --- a/recipes/meshoptimizer/all/conanfile.py +++ b/recipes/meshoptimizer/all/conanfile.py @@ -1,17 +1,20 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conans import tools as tools_legacy import os -import glob -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.52.0" class MeshOptimizerConan(ConanFile): name = "meshoptimizer" - description = " Mesh optimization library that makes meshes smaller and faster to render" - topics = ("conan", "mesh", "optimizer", "3d") + description = "Mesh optimization library that makes meshes smaller and faster to render" + topics = ("mesh", "optimizer", "3d") homepage = "https://github.com/zeux/meshoptimizer" url = "https://github.com/conan-io/conan-center-index" license = "MIT" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -22,61 +25,59 @@ class MeshOptimizerConan(ConanFile): "fPIC": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC def configure(self): if self.options.shared: - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def layout(self): + cmake_layout(self, src_folder="src") - def _configure_cmake(self): - if self._cmake: - return self._cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - self._cmake = CMake(self) - self._cmake.definitions["MESHOPT_BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MESHOPT_BUILD_SHARED_LIBS"] = self.options.shared + tc.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - # Don't override warning levels for msvc - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "add_compile_options(/W4 /WX)", "") + apply_conandata_patches(self) + # No warnings as errors + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + replace_in_file(self, cmakelists, "add_compile_options(/W4 /WX)", "") + replace_in_file(self, cmakelists, "-Werror", "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE.md", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - for f in glob.glob(os.path.join(self.package_folder, "bin", "*.pdb")): - os.remove(f) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.system_libs.append(tools.stdcpp_library(self)) + self.cpp_info.set_property("cmake_file_name", "meshoptimizer") + self.cpp_info.set_property("cmake_target_name", "meshoptimizer::meshoptimizer") + self.cpp_info.libs = ["meshoptimizer"] + if not self.options.shared: + libcxx = tools_legacy.stdcpp_library(self) + if libcxx: + self.cpp_info.system_libs.append(libcxx) if self.options.shared and self.settings.os == "Windows": self.cpp_info.defines = ["MESHOPTIMIZER_API=__declspec(dllimport)"] diff --git a/recipes/meshoptimizer/all/patches/0.14/001_Fix build_on_old_AppleClang_versions.patch b/recipes/meshoptimizer/all/patches/0.14/0001-fix-build-on-old-AppleClang-versions.patch similarity index 100% rename from recipes/meshoptimizer/all/patches/0.14/001_Fix build_on_old_AppleClang_versions.patch rename to recipes/meshoptimizer/all/patches/0.14/0001-fix-build-on-old-AppleClang-versions.patch diff --git a/recipes/meshoptimizer/all/test_package/CMakeLists.txt b/recipes/meshoptimizer/all/test_package/CMakeLists.txt index 7c5477a7e96a3..034ae19a0ca08 100644 --- a/recipes/meshoptimizer/all/test_package/CMakeLists.txt +++ b/recipes/meshoptimizer/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C) find_package(meshoptimizer REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} meshoptimizer::meshoptimizer) +target_link_libraries(${PROJECT_NAME} PRIVATE meshoptimizer::meshoptimizer) diff --git a/recipes/meshoptimizer/all/test_package/conanfile.py b/recipes/meshoptimizer/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/meshoptimizer/all/test_package/conanfile.py +++ b/recipes/meshoptimizer/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/meshoptimizer/all/test_v1_package/CMakeLists.txt b/recipes/meshoptimizer/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b49461acc50ec --- /dev/null +++ b/recipes/meshoptimizer/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(meshoptimizer REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE meshoptimizer::meshoptimizer) diff --git a/recipes/meshoptimizer/all/test_v1_package/conanfile.py b/recipes/meshoptimizer/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/meshoptimizer/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/meshoptimizer/config.yml b/recipes/meshoptimizer/config.yml index 1e4023fe84046..301a8d09f5b3a 100644 --- a/recipes/meshoptimizer/config.yml +++ b/recipes/meshoptimizer/config.yml @@ -1,4 +1,6 @@ versions: + "0.17": + folder: all "0.16": folder: all "0.15": diff --git a/recipes/meson/all/conandata.yml b/recipes/meson/all/conandata.yml index cdede311b34d2..0195431f99164 100644 --- a/recipes/meson/all/conandata.yml +++ b/recipes/meson/all/conandata.yml @@ -1,67 +1,49 @@ sources: - "0.51.0": - url: "https://github.com/mesonbuild/meson/archive/0.51.0.tar.gz" - sha256: "ec1e3942215a858d82c3d2e095d18adcf1ede94a34144662643d88db4dcb5263" - "0.51.2": - url: "https://github.com/mesonbuild/meson/archive/0.51.2.tar.gz" - sha256: "96871cf62c9cf2b212e2f38aa3e543323403b1314fd3835e14120ef837c00f01" - "0.52.0": - url: "https://github.com/mesonbuild/meson/archive/0.52.0.tar.gz" - sha256: "0f426ed1362c38bcc5b9027ec6aec3445d6db88e8d7249ed992e9af88a42d0e0" - "0.52.1": - url: "https://github.com/mesonbuild/meson/archive/0.52.1.tar.gz" - sha256: "ad8dbad61d4c22cb7d768cb1f8a212b4abf0f3fbc17c298d816140ecd9f5d1df" - "0.53.0": - url: "https://github.com/mesonbuild/meson/archive/0.53.0.tar.gz" - sha256: "cc15f416d0b538fb079c15a59ee2cd106895ca115fa5d654731a695c85c992fc" - "0.53.1": - url: "https://github.com/mesonbuild/meson/archive/0.53.1.tar.gz" - sha256: "f69ff8ce6cb52cbfb9bcc844086fade76920a292a017e68201317eeacd3ab943" - "0.53.2": - url: "https://github.com/mesonbuild/meson/archive/0.53.2.tar.gz" - sha256: "eab4f5d5dde12d002b7ddd958a9a0658589b63622b6cea2715e0235b95917888" - "0.54.0": - url: "https://github.com/mesonbuild/meson/archive/0.54.0.tar.gz" - sha256: "95efdbaa7cb3e915ab9a7b26b1412475398fdc3e834842a780f1646c7764f2d9" - "0.54.1": - url: "https://github.com/mesonbuild/meson/archive/0.54.1.tar.gz" - sha256: "854e8b94ab36e5aece813d2b2aee8a639bd52201dfea50890722ac9128e2f59e" - "0.54.2": - url: "https://github.com/mesonbuild/meson/archive/0.54.2.tar.gz" - sha256: "85cafdc70ae7d1d9d506e7356b917c649c4df2077bd6a0382db37648aa4ecbdb" - "0.54.3": - url: "https://github.com/mesonbuild/meson/archive/0.54.3.tar.gz" - sha256: "c25caff342b5368bfe33fab6108f454fcf12e2f2cef70817205872ddef669e8b" - "0.55.0": - url: "https://github.com/mesonbuild/meson/archive/0.55.0.tar.gz" - sha256: "9034c943c8cf4d734c0e18e5ba038dd762fcdcc614c45b41703305da8382e90c" - "0.55.1": - url: "https://github.com/mesonbuild/meson/archive/0.55.1.tar.gz" - sha256: "c7ebf2fff5934a974c7edd1aebb5fc9c3e1da5ae3184a29581fde917638eea39" - "0.55.2": - url: "https://github.com/mesonbuild/meson/archive/0.55.2.tar.gz" - sha256: "56244896e56c2b619f819d047b6de412ecc5250975ee8717f1e329113d178e06" - "0.55.3": - url: "https://github.com/mesonbuild/meson/archive/0.55.3.tar.gz" - sha256: "2b276df50c5b13ccdbfb14d3333141e9e7985aca31b60400b3f3e0be2ee6897e" - "0.56.0": - url: "https://github.com/mesonbuild/meson/archive/0.56.0.tar.gz" - sha256: "a9ca7adf66dc69fbb7e583f7c7aef16b9fe56ec2874a3d58747e69a3affdf300" - "0.56.1": - url: "https://github.com/mesonbuild/meson/archive/0.56.1.tar.gz" - sha256: "db3545231bb8f3ae3186a1a0f49f0acd239724af91781b783e843b80400f10ec" - "0.56.2": - url: "https://github.com/mesonbuild/meson/archive/0.56.2.tar.gz" - sha256: "aaae961c3413033789248ffe6762589e80b6cf487c334d0b808e31a32c48f35f" - "0.57.0": - url: "https://github.com/mesonbuild/meson/archive/0.57.0.tar.gz" - sha256: "fd26a27c1a509240c668ebd29d280649d9239cf8684ead51d5cb499d1e1188bd" - "0.57.1": - url: "https://github.com/mesonbuild/meson/archive/0.57.1.tar.gz" - sha256: "0c043c9b5350e9087cd4f6becf6c0d10b1d618ca3f919e0dcca2cdf342360d5d" + "0.64.1": + url: "https://github.com/mesonbuild/meson/archive/0.64.1.tar.gz" + sha256: "1d12a4bc1cf3ab18946d12cf0b6452e5254ada1ad50aacc97f87e2cccd7da315" + "0.64.0": + url: "https://github.com/mesonbuild/meson/archive/0.64.0.tar.gz" + sha256: "6477993d781b6efea93091616a6d6a0766c0e026076dbeb11249bf1c9b49a347" + "0.63.3": + url: "https://github.com/mesonbuild/meson/archive/0.63.3.tar.gz" + sha256: "7c516c2099b762203e8a0a22412aa465b7396e6f9b1ab728bad6e6db44dc2659" + "0.63.2": + url: "https://github.com/mesonbuild/meson/archive/0.63.2.tar.gz" + sha256: "023a3f7c74e68991154c3205a6975705861eedbf8130e013d15faa1df1af216e" + "0.63.1": + url: "https://github.com/mesonbuild/meson/archive/0.63.1.tar.gz" + sha256: "f355829f0e8c714423f03a06604c04c216d4cbe3586f3154cb2181076b19207a" + "0.63.0": + url: "https://github.com/mesonbuild/meson/archive/0.63.0.tar.gz" + sha256: "77808d47fa05875c2553d66cb6c6140c2f687b46256dc537eeb8a63889e0bea2" + "0.62.2": + url: "https://github.com/mesonbuild/meson/archive/0.62.2.tar.gz" + sha256: "97108f4d9bb16bc758c44749bd25ec7d42c6a762961efbed8b7589a2a3551ea6" + "0.62.1": + url: "https://github.com/mesonbuild/meson/archive/0.62.1.tar.gz" + sha256: "9fb52e66dbc613479a5f70e46cc2e8faf5aa65e09313f2c71fa63b8afd018107" + "0.62.0": + url: "https://github.com/mesonbuild/meson/archive/0.62.0.tar.gz" + sha256: "72ac3bab701dfd597604de29cc74baaa1cc0ad8ca26ae23d5288de26abfe1c80" + "0.61.2": + url: "https://github.com/mesonbuild/meson/archive/0.61.2.tar.gz" + sha256: "33cd555314a94d52acfbb3f6f44d4e61c4ad0bfec7acf4301be7e40bb969b3a8" + "0.60.2": + url: "https://github.com/mesonbuild/meson/archive/0.60.2.tar.gz" + sha256: "fc7c2f315b5b63fee0414b0b94b5a7d0e9c71c8c9bb8487314eb5a9a33984b8d" + "0.59.3": + url: "https://github.com/mesonbuild/meson/archive/0.59.3.tar.gz" + sha256: "b2c5bfd5032189a66cf6a32d98ba82d94d7d314577d8efe4d9dc159c4073f282" + "0.58.1": + url: "https://github.com/mesonbuild/meson/archive/0.58.1.tar.gz" + sha256: "78e0f553dd3bc632d5f96ab943b1bbccb599c2c84ff27c5fb7f7fff9c8a3f6b4" "0.57.2": url: "https://github.com/mesonbuild/meson/archive/0.57.2.tar.gz" sha256: "cd3773625253df4fd1c380faf03ffae3d02198d6301e7c8bc7bba6c66af66096" - "0.58.0": - url: "https://github.com/mesonbuild/meson/archive/0.58.0.tar.gz" - sha256: "991b882bfe4d37acc23c064a29ca209458764a580d52f044f3d50055a132bed4" + "0.56.2": + url: "https://github.com/mesonbuild/meson/archive/0.56.2.tar.gz" + sha256: "aaae961c3413033789248ffe6762589e80b6cf487c334d0b808e31a32c48f35f" + "0.55.3": + url: "https://github.com/mesonbuild/meson/archive/0.55.3.tar.gz" + sha256: "2b276df50c5b13ccdbfb14d3333141e9e7985aca31b60400b3f3e0be2ee6897e" diff --git a/recipes/meson/all/conanfile.py b/recipes/meson/all/conanfile.py index 9aa308a3b5315..8168d4afa4b4f 100644 --- a/recipes/meson/all/conanfile.py +++ b/recipes/meson/all/conanfile.py @@ -1,58 +1,92 @@ -from conans import ConanFile, tools +from conan import ConanFile, conan_version +from conan.tools.files import copy, get, rmdir, save +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +import textwrap +required_conan_version = ">=1.52.0" -class MesonInstallerConan(ConanFile): + +class MesonConan(ConanFile): name = "meson" description = "Meson is a project to create the best possible next-generation build system" - topics = ("conan", "meson", "mesonbuild", "build-system") + topics = ("meson", "mesonbuild", "build-system") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/mesonbuild/meson" license = "Apache-2.0" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - _source_subfolder = "source_subfolder" - _meson_cmd = """@echo off -CALL python %~dp0/meson.py %* -""" - _meson_sh = """#!/usr/bin/env bash -meson_dir=$(dirname "$0") -exec "$meson_dir/meson.py" "$@" -""" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): - self.requires("ninja/1.10.2") + if self.conf.get("tools.meson.mesontoolchain:backend", default=False, check_type=str) in (False, "ninja"): + self.requires("ninja/1.11.1") def package_id(self): - self.info.header_only() + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "meson-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + # FIXME: https://github.com/conan-io/conan/issues/10726 + def _fix_symlinks(root, files): + if not self._settings_build.os == "Windows": + return + for filename in files: + filename = os.path.join(root, filename) + if os.path.islink(filename): + target = os.readlink(filename) + if "/" in target: + self.output.info(f"fixing broken link {target}") + target = target.replace("/", "\\") + os.unlink(filename) + os.symlink(target, filename) + + for root, dirs, files in os.walk(self.source_folder): + _fix_symlinks(root, dirs) + _fix_symlinks(root, files) + + def build(self): + pass + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=self.source_folder, dst=os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "bin", "test cases")) # create wrapper scripts - with open(os.path.join(self._source_subfolder, "meson.cmd"), "w") as f: - f.write(self._meson_cmd) - with open(os.path.join(self._source_subfolder, "meson"), "w") as f: - f.write(self._meson_sh) + save(self, os.path.join(self.package_folder, "bin", "meson.cmd"), textwrap.dedent("""\ + @echo off + CALL python %~dp0/meson.py %* + """)) + save(self, os.path.join(self.package_folder, "bin", "meson"), textwrap.dedent("""\ + #!/usr/bin/env bash + meson_dir=$(dirname "$0") + exec "$meson_dir/meson.py" "$@" + """)) @staticmethod def _chmod_plus_x(filename): - if os.name == 'posix': + if os.name == "posix": os.chmod(filename, os.stat(filename).st_mode | 0o111) - def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*", dst="bin", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "bin", "test cases")) - def package_info(self): meson_root = os.path.join(self.package_folder, "bin") - self.output.info('Appending PATH environment variable: %s' % meson_root) - self.env_info.PATH.append(meson_root) - self._chmod_plus_x(os.path.join(meson_root, "meson")) self._chmod_plus_x(os.path.join(meson_root, "meson.py")) self.cpp_info.builddirs = [os.path.join("bin", "mesonbuild", "cmake", "data")] + + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + + if Version(conan_version).major < 2: + self.env_info.PATH.append(meson_root) diff --git a/recipes/meson/all/test_package/conanfile.py b/recipes/meson/all/test_package/conanfile.py index c51a45b095425..946c63a8024cb 100644 --- a/recipes/meson/all/test_package/conanfile.py +++ b/recipes/meson/all/test_package/conanfile.py @@ -1,19 +1,28 @@ -from conans import ConanFile, Meson, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "pkg_config" + settings = "os", "arch", "compiler", "build_type" + generators = "MesonToolchain", "VirtualBuildEnv", "VirtualRunEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def layout(self): + basic_layout(self) def build(self): meson = Meson(self) - meson.configure(build_folder="build") + meson.configure() meson.build() def test(self): - bin_path = os.path.join("build", "test_package") - self.run(bin_path, run_environment=True) - self.run("meson --version") - + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/meson/all/test_v1_package/conanfile.py b/recipes/meson/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c8624c6f85f40 --- /dev/null +++ b/recipes/meson/all/test_v1_package/conanfile.py @@ -0,0 +1,22 @@ +from conans import ConanFile, Meson, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + + def build(self): + if not tools.cross_building(self): + meson = Meson(self) + meson.configure(build_folder="build") + meson.build() + + def test(self): + self.run("meson --version") + if not tools.cross_building(self): + bin_path = os.path.join("build", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/meson/all/test_v1_package/meson.build b/recipes/meson/all/test_v1_package/meson.build new file mode 100644 index 0000000000000..e67dd979af3c4 --- /dev/null +++ b/recipes/meson/all/test_v1_package/meson.build @@ -0,0 +1,2 @@ +project('test_package', 'cpp') +executable('test_package', '../test_package/test_package.cpp') diff --git a/recipes/meson/config.yml b/recipes/meson/config.yml index e6fd8e00deb06..3c331d990af96 100644 --- a/recipes/meson/config.yml +++ b/recipes/meson/config.yml @@ -1,45 +1,33 @@ versions: - "0.51.0": + "0.64.1": folder: all - "0.51.2": + "0.64.0": folder: all - "0.52.0": + "0.63.3": folder: all - "0.52.1": + "0.63.2": folder: all - "0.53.0": + "0.63.1": folder: all - "0.53.1": + "0.63.0": folder: all - "0.53.2": + "0.62.2": folder: all - "0.54.0": + "0.62.1": folder: all - "0.54.1": + "0.62.0": folder: all - "0.54.2": + "0.61.2": folder: all - "0.54.3": + "0.60.2": folder: all - "0.55.0": + "0.59.3": folder: all - "0.55.1": + "0.58.1": folder: all - "0.55.2": - folder: all - "0.55.3": - folder: all - "0.56.0": - folder: all - "0.56.1": + "0.57.2": folder: all "0.56.2": folder: all - "0.57.0": - folder: all - "0.57.1": - folder: all - "0.57.2": - folder: all - "0.58.0": + "0.55.3": folder: all diff --git a/recipes/metall/all/conandata.yml b/recipes/metall/all/conandata.yml new file mode 100644 index 0000000000000..788ef5da15507 --- /dev/null +++ b/recipes/metall/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "0.21": + url: "https://github.com/LLNL/metall/archive/refs/tags/v0.21.tar.gz" + sha256: "feaff7a935f98d3cc1e2b21f6eae40edc674a5bd0133306afd3851148aaed026" + "0.20": + url: "https://github.com/LLNL/metall/archive/refs/tags/v0.20.tar.gz" + sha256: "cafe54c682004a66a059f54e2d7128ea7622e9941ea492297d04c260675e9af4" + "0.23.1": + url: "https://github.com/LLNL/metall/archive/refs/tags/v0.23.1.tar.gz" + sha256: "25e8fbc424e66d09e0faf60029288e4612685675bfd947cc142bd9d6d0645ac4" diff --git a/recipes/metall/all/conanfile.py b/recipes/metall/all/conanfile.py new file mode 100644 index 0000000000000..957ba5421027f --- /dev/null +++ b/recipes/metall/all/conanfile.py @@ -0,0 +1,89 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.0" + + +class MetallConan(ConanFile): + name = "metall" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/LLNL/metall" + description = "Meta allocator for persistent memory" + license = "MIT", "Apache-2.0" + topics = "cpp", "allocator", "memory-allocator", "persistent-memory", "ecp", "exascale-computing" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _compilers_minimum_version(self): + return { + "gcc": "8.3", + "clang": "9", + } + + def requirements(self): + self.requires("boost/1.79.0") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 17) + + if self.settings.os not in ["Linux", "Macos"]: + raise ConanInvalidConfiguration( + "Metall requires some POSIX functionalities like mmap.") + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get( + str(self.settings.compiler), False) + if minimum_version and lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + "{} {} requires C++17, which your compiler does not support.".format(self.name, self.version)) + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "COPYRIGHT", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Metall") + self.cpp_info.set_property("cmake_target_name", "Metall::Metall") + + self.cpp_info.names["cmake_find_package"] = "Metall" + self.cpp_info.names["cmake_find_package_multi"] = "Metall" + + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") + + if self.settings.compiler == "gcc" or (self.settings.os == "Linux" and self.settings.compiler == "clang"): + if Version(self.settings.compiler.version) < "9": + self.cpp_info.system_libs += ["stdc++fs"] + + self.cpp_info.requires = ["boost::headers"] diff --git a/recipes/metall/all/test_package/CMakeLists.txt b/recipes/metall/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e4433c83b857b --- /dev/null +++ b/recipes/metall/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(Metall REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Metall::Metall) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/metall/all/test_package/conanfile.py b/recipes/metall/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a8c6c5442b33 --- /dev/null +++ b/recipes/metall/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/metall/all/test_package/test_package.cpp b/recipes/metall/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..5e419e0f81b4a --- /dev/null +++ b/recipes/metall/all/test_package/test_package.cpp @@ -0,0 +1,51 @@ +// Copyright 2019 Lawrence Livermore National Security, LLC and other Metall Project Developers. +// See the top-level COPYRIGHT file for details. +// +// SPDX-License-Identifier: (Apache-2.0 OR MIT) + +#include +#include + +#include // Only one header file is required to be included + +// Type alias +// This is a standard way to give a custom allocator to a container +using vector_t = boost::container::vector>; + +int main() { + + { + // Construct a manager object + // A process can allocate multiple manager objects + metall::manager manager(metall::create_only, // Create a new one + "/tmp/dir"); // The directory to store backing datastore + + // Allocate and construct a vector object in the persistent memory with a name "vec" + auto pvec = manager.construct // Allocate and construct an object of vector_t + ("vec") // Name of the allocated object + (manager.get_allocator()); // Arguments passed to vector_t's constructor + + pvec->push_back(5); // Can use containers normally + + } // Implicitly sync with backing files, i.e., sync() is called in metall::manager's destructor + + // ---------- Assume exit and restart the program at this point ---------- // + + { + // Reattach the manager object + metall::manager manager(metall::open_only, "/tmp/dir"); + + // Find the previously constructed object + // Please do not forget to use ".first" at the end + auto pvec = manager.find("vec").first; + + pvec->push_back(10); // Can restart to use containers normally + + std::cout << (*pvec)[0] << std::endl; // Will print "5" + std::cout << (*pvec)[1] << std::endl; // Will print "10" + + manager.destroy("vec"); // Destroy the object + } + + return 0; +} diff --git a/recipes/metall/all/test_v1_package/CMakeLists.txt b/recipes/metall/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..90ab90a88d549 --- /dev/null +++ b/recipes/metall/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Metall REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Metall::Metall) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/metall/all/test_v1_package/conanfile.py b/recipes/metall/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/metall/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/metall/config.yml b/recipes/metall/config.yml new file mode 100644 index 0000000000000..e3fb6e5067c49 --- /dev/null +++ b/recipes/metall/config.yml @@ -0,0 +1,7 @@ +versions: + "0.21": + folder: all + "0.20": + folder: all + "0.23.1": + folder: all diff --git a/recipes/metis/all/CMakeLists.txt b/recipes/metis/all/CMakeLists.txt new file mode 100644 index 0000000000000..15cbde395086d --- /dev/null +++ b/recipes/metis/all/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.4) +project(cmake_wrapper LANGUAGES C) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +set(GKLIB_PATH "${CMAKE_CURRENT_LIST_DIR}/source_subfolder/GKlib" CACHE PATH "") + +add_subdirectory(source_subfolder) diff --git a/recipes/metis/all/conandata.yml b/recipes/metis/all/conandata.yml new file mode 100644 index 0000000000000..396a06387b94f --- /dev/null +++ b/recipes/metis/all/conandata.yml @@ -0,0 +1,16 @@ +sources: + "5.1.1": + url: "https://github.com/KarypisLab/METIS/archive/refs/tags/v5.1.1-DistDGL-v0.5.tar.gz" + sha256: "cedf0b32d32a8496bac7eb078b2b8260fb00ddb8d50c27e4082968a01bc33331" +patches: + "5.1.1": + - patch_file: "patches/001-add-gklib-system-cmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/002-support-pure-cmake.patch" + base_path: "source_subfolder" + - patch_file: "patches/003-remove-programs.patch" + base_path: "source_subfolder" + - patch_file: "patches/004-use-conan-gklib.patch" + base_path: "source_subfolder" + - patch_file: "patches/005-fix-install.patch" + base_path: "source_subfolder" diff --git a/recipes/metis/all/conanfile.py b/recipes/metis/all/conanfile.py new file mode 100644 index 0000000000000..7e077e7ea6112 --- /dev/null +++ b/recipes/metis/all/conanfile.py @@ -0,0 +1,101 @@ +from conans import ConanFile, CMake, tools +from conan.tools.files import apply_conandata_patches +import os + +required_conan_version = ">=1.43.0" + + +class METISConan(ConanFile): + name = "metis" + license = "Apache-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/KarypisLab/METIS" + description = "set of serial programs for partitioning graphs," \ + " partitioning finite element meshes, and producing" \ + " fill reducing orderings for sparse matrices" + topics = ("karypislab", "graph", "partitioning-algorithms") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + generators = "cmake", "cmake_find_package" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _is_mingw(self): + return self.settings.os == "Windows" and self.settings.compiler == "gcc" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def requirements(self): + self.requires("gklib/5.1.1") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + apply_conandata_patches(self) + + def _configure_cmake(self): + if not self._cmake: + self._cmake = CMake(self) + self._cmake.definitions["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + self._cmake.definitions["SHARED"] = self.options.shared + self._cmake.definitions["METIS_INSTALL"] = True + self._cmake.definitions["ASSERT"] = self.settings.build_type == "Debug" + self._cmake.definitions["ASSERT2"] = self.settings.build_type == "Debug" + self._cmake.definitions["METIS_IDX64"] = True + self._cmake.definitions["METIS_REAL64"] = True + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + + def package_info(self): + self.cpp_info.libs = ["metis"] + self.cpp_info.requires.append("gklib::gklib") + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + if self._is_msvc or self._is_mingw: + self.cpp_info.defines.append("USE_GKREGEX") + if self._is_msvc: + self.cpp_info.defines.append("__thread=__declspec(thread)") diff --git a/recipes/metis/all/patches/001-add-gklib-system-cmake.patch b/recipes/metis/all/patches/001-add-gklib-system-cmake.patch new file mode 100644 index 0000000000000..2c6798304339e --- /dev/null +++ b/recipes/metis/all/patches/001-add-gklib-system-cmake.patch @@ -0,0 +1,151 @@ +Add gklib system cmake +--- /dev/null ++++ b/GKlib/GKlibSystem.cmake +@@ -0,0 +1,133 @@ ++# Helper modules. ++include(CheckFunctionExists) ++include(CheckIncludeFile) ++ ++# Setup options. ++option(GDB "enable use of GDB" OFF) ++option(ASSERT "turn asserts on" OFF) ++option(ASSERT2 "additional assertions" OFF) ++option(DEBUG "add debugging support" OFF) ++option(GPROF "add gprof support" OFF) ++option(OPENMP "enable OpenMP support" OFF) ++option(PCRE "enable PCRE support" OFF) ++option(GKREGEX "enable GKREGEX support" OFF) ++option(GKRAND "enable GKRAND support" OFF) ++ ++ ++# Add compiler flags. ++if(MSVC) ++ set(GKlib_COPTS "/Ox") ++ set(GKlib_COPTIONS "-DWIN32 -DMSC -D_CRT_SECURE_NO_DEPRECATE -DUSE_GKREGEX") ++elseif(MINGW) ++ set(GKlib_COPTS "-DUSE_GKREGEX") ++else() ++ set(GKlib_COPTIONS "-DLINUX -D_FILE_OFFSET_BITS=64") ++endif(MSVC) ++if(CYGWIN) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -DCYGWIN") ++endif(CYGWIN) ++if(CMAKE_COMPILER_IS_GNUCC) ++# GCC opts. ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -std=c99 -fno-strict-aliasing") ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -march=native") ++ if(NOT MINGW) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -fPIC") ++ endif(NOT MINGW) ++# GCC warnings. ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -Werror -Wall -pedantic -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-label") ++elseif(${CMAKE_C_COMPILER_ID} MATCHES "Sun") ++# Sun insists on -xc99. ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -xc99") ++endif(CMAKE_COMPILER_IS_GNUCC) ++ ++# Intel compiler ++if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -xHost -std=c99") ++endif() ++ ++# Find OpenMP if it is requested. ++if(OPENMP) ++ include(FindOpenMP) ++ if(OPENMP_FOUND) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -D__OPENMP__ ${OpenMP_C_FLAGS}") ++ else() ++ message(WARNING "OpenMP was requested but support was not found") ++ endif(OPENMP_FOUND) ++endif(OPENMP) ++ ++ ++# Add various definitions. ++if(GDB) ++ set(GKlib_COPTS "${GKlib_COPTS} -g") ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -Werror") ++else() ++ set(GKlib_COPTS "-O3") ++endif(GDB) ++ ++ ++if(DEBUG) ++ set(GKlib_COPTS "-g") ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -DDEBUG") ++endif(DEBUG) ++ ++if(GPROF) ++ set(GKlib_COPTS "-pg") ++endif(GPROF) ++ ++if(NOT ASSERT) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -DNDEBUG") ++endif(NOT ASSERT) ++ ++if(NOT ASSERT2) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -DNDEBUG2") ++endif(NOT ASSERT2) ++ ++ ++# Add various options ++if(PCRE) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -D__WITHPCRE__") ++endif(PCRE) ++ ++if(GKREGEX) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -DUSE_GKREGEX") ++endif(GKREGEX) ++ ++if(GKRAND) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -DUSE_GKRAND") ++endif(GKRAND) ++ ++ ++# Check for features. ++check_include_file(execinfo.h HAVE_EXECINFO_H) ++if(HAVE_EXECINFO_H) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -DHAVE_EXECINFO_H") ++endif(HAVE_EXECINFO_H) ++ ++check_function_exists(getline HAVE_GETLINE) ++if(HAVE_GETLINE) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -DHAVE_GETLINE") ++endif(HAVE_GETLINE) ++ ++ ++# Custom check for TLS. ++if(MSVC) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -D__thread=__declspec(thread)") ++ ++ # This if checks if that value is cached or not. ++ if("${HAVE_THREADLOCALSTORAGE}" MATCHES "^${HAVE_THREADLOCALSTORAGE}$") ++ try_compile(HAVE_THREADLOCALSTORAGE ++ ${CMAKE_BINARY_DIR} ++ ${GKLIB_PATH}/conf/check_thread_storage.c) ++ if(HAVE_THREADLOCALSTORAGE) ++ message(STATUS "checking for thread-local storage - found") ++ else() ++ message(STATUS "checking for thread-local storage - not found") ++ endif() ++ endif() ++ if(NOT HAVE_THREADLOCALSTORAGE) ++ set(GKlib_COPTIONS "${GKlib_COPTIONS} -D__thread=") ++ endif() ++endif() ++ ++# Finally set the official C flags. ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GKlib_COPTIONS} ${GKlib_COPTS}") +diff --git a/GKlib/conf/check_thread_storage.c b/GKlib/conf/check_thread_storage.c +new file mode 100644 +index 0000000..e6e1e98 +--- /dev/null ++++ b/GKlib/conf/check_thread_storage.c +@@ -0,0 +1,5 @@ ++extern __thread int x; ++ ++int main(int argc, char **argv) { ++ return 0; ++} +-- +2.33.1.windows.1 + diff --git a/recipes/metis/all/patches/002-support-pure-cmake.patch b/recipes/metis/all/patches/002-support-pure-cmake.patch new file mode 100644 index 0000000000000..7fc0e8b45ccb7 --- /dev/null +++ b/recipes/metis/all/patches/002-support-pure-cmake.patch @@ -0,0 +1,771 @@ +Generate metis.h based on CMake options +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -20,26 +20,28 @@ endif(SHARED) + include(${GKLIB_PATH}/GKlibSystem.cmake) + + # METIS' custom options +-#option(IDX64 "enable 64 bit ints" OFF) +-#option(REAL64 "enable 64 bit floats (i.e., double)" OFF) +-#if(IDX64) +-# set(METIS_COPTIONS "${METIS_COPTIONS} -DIDXTYPEWIDTH=64") +-#else() +-# set(METIS_COPTIONS "${METIS_COPTIONS} -DIDXTYPEWIDTH=32") +-#endif(IDX64) +-#if(REAL64) +-# set(METIS_COPTIONS "${METIS_COPTIONS} -DREALTYPEWIDTH=64") +-#else() +-# set(METIS_COPTIONS "${METIS_COPTIONS} -DREALTYPEWIDTH=32") +-#endif(REAL64) +-# +-#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${METIS_COPTIONS}") +- ++option(METIS_IDX64 "enable 64 bit ints" OFF) ++option(METIS_REAL64 "enable 64 bit floats (i.e., double)" OFF) ++if (METIS_IDX64) ++ set(METIS_IDXTYPEWIDTH 64) ++else () ++ set(METIS_IDXTYPEWIDTH 32) ++endif () ++if (METIS_REAL64) ++ set(METIS_REALTYPEWIDTH 64) ++else () ++ set(METIS_REALTYPEWIDTH 32) ++endif () + + # Add include directories. + include_directories(${GKLIB_PATH}) +-include_directories(build/xinclude) ++configure_file(${PROJECT_SOURCE_DIR}/include/metis.h.in ++ ${PROJECT_BINARY_DIR}/include/metis.h) ++include_directories(${PROJECT_BINARY_DIR}/include) ++if (METIS_INSTALL) ++ install(FILES ${PROJECT_BINARY_DIR}/include/metis.h DESTINATION include) ++endif () ++ + # Recursively look for CMakeLists.txt in subdirs. +-add_subdirectory("build/xinclude") + add_subdirectory("libmetis") + add_subdirectory("programs") +--- a/include/metis.h ++++ /dev/null +@@ -1,358 +0,0 @@ +-/*! +-\file metis.h +-\brief This file contains function prototypes and constant definitions for METIS +- * +-\author George +-\date Started 8/9/02 +-\version\verbatim $Id$\endverbatim +-*/ +- +-#ifndef _METIS_H_ +-#define _METIS_H_ +- +-/**************************************************************************** +-* A set of defines that can be modified by the user +-*****************************************************************************/ +- +-/*-------------------------------------------------------------------------- +- Specifies the width of the elementary data type that will hold information +- about vertices and their adjacency lists. +- +- Possible values: +- 32 : Use 32 bit signed integers +- 64 : Use 64 bit signed integers +- +- A width of 64 should be specified if the number of vertices or the total +- number of edges in the graph exceed the limits of a 32 bit signed integer +- i.e., 2^31-1. +- Proper use of 64 bit integers requires that the c99 standard datatypes +- int32_t and int64_t are supported by the compiler. +- GCC does provides these definitions in stdint.h, but it may require some +- modifications on other architectures. +---------------------------------------------------------------------------*/ +-//#define IDXTYPEWIDTH 32 +- +- +-/*-------------------------------------------------------------------------- +- Specifies the data type that will hold floating-point style information. +- +- Possible values: +- 32 : single precission floating point (float) +- 64 : double precission floating point (double) +---------------------------------------------------------------------------*/ +-//#define REALTYPEWIDTH 32 +- +- +- +-/**************************************************************************** +-* In principle, nothing needs to be changed beyond this point, unless the +-* int32_t and int64_t cannot be found in the normal places. +-*****************************************************************************/ +- +-/* Uniform definitions for various compilers */ +-#if defined(_MSC_VER) +- #define COMPILER_MSC +-#endif +-#if defined(__ICC) +- #define COMPILER_ICC +-#endif +-#if defined(__GNUC__) +- #define COMPILER_GCC +-#endif +- +-/* Include c99 int definitions and need constants. When building the library, +- * these are already defined by GKlib; hence the test for _GKLIB_H_ */ +-#ifndef _GKLIB_H_ +-#ifdef COMPILER_MSC +-#include +- +-typedef __int32 int32_t; +-typedef __int64 int64_t; +-#define PRId32 "I32d" +-#define PRId64 "I64d" +-#define SCNd32 "ld" +-#define SCNd64 "I64d" +-#define INT32_MIN ((int32_t)_I32_MIN) +-#define INT32_MAX _I32_MAX +-#define INT64_MIN ((int64_t)_I64_MIN) +-#define INT64_MAX _I64_MAX +-#else +-#include +-#endif +-#endif +- +- +-/*------------------------------------------------------------------------ +-* Setup the basic datatypes +-*-------------------------------------------------------------------------*/ +-#if IDXTYPEWIDTH == 32 +- typedef int32_t idx_t; +- +- #define IDX_MAX INT32_MAX +- #define IDX_MIN INT32_MIN +- +- #define SCIDX SCNd32 +- #define PRIDX PRId32 +- +- #define strtoidx strtol +- #define iabs abs +-#elif IDXTYPEWIDTH == 64 +- typedef int64_t idx_t; +- +- #define IDX_MAX INT64_MAX +- #define IDX_MIN INT64_MIN +- +- #define SCIDX SCNd64 +- #define PRIDX PRId64 +- +-#ifdef COMPILER_MSC +- #define strtoidx _strtoi64 +-#else +- #define strtoidx strtoll +-#endif +- #define iabs labs +-#else +- #error "Incorrect user-supplied value fo IDXTYPEWIDTH" +-#endif +- +- +-#if REALTYPEWIDTH == 32 +- typedef float real_t; +- +- #define SCREAL "f" +- #define PRREAL "f" +- #define REAL_MAX FLT_MAX +- #define REAL_MIN FLT_MIN +- #define REAL_EPSILON FLT_EPSILON +- +- #define rabs fabsf +- #define REALEQ(x,y) ((rabs((x)-(y)) <= FLT_EPSILON)) +- +-#ifdef COMPILER_MSC +- #define strtoreal (float)strtod +-#else +- #define strtoreal strtof +-#endif +-#elif REALTYPEWIDTH == 64 +- typedef double real_t; +- +- #define SCREAL "lf" +- #define PRREAL "lf" +- #define REAL_MAX DBL_MAX +- #define REAL_MIN DBL_MIN +- #define REAL_EPSILON DBL_EPSILON +- +- #define rabs fabs +- #define REALEQ(x,y) ((rabs((x)-(y)) <= DBL_EPSILON)) +- +- #define strtoreal strtod +-#else +- #error "Incorrect user-supplied value for REALTYPEWIDTH" +-#endif +- +- +-/*------------------------------------------------------------------------ +-* Constant definitions +-*-------------------------------------------------------------------------*/ +-/* Metis's version number */ +-#define METIS_VER_MAJOR 5 +-#define METIS_VER_MINOR 1 +-#define METIS_VER_SUBMINOR 0 +- +-/* The maximum length of the options[] array */ +-#define METIS_NOPTIONS 40 +- +- +- +-/*------------------------------------------------------------------------ +-* Function prototypes +-*-------------------------------------------------------------------------*/ +- +-#ifdef _WINDLL +-#define METIS_API(type) __declspec(dllexport) type __cdecl +-#elif defined(__cdecl) +-#define METIS_API(type) type __cdecl +-#else +-#define METIS_API(type) type +-#endif +- +- +- +-#ifdef __cplusplus +-extern "C" { +-#endif +- +-METIS_API(int) METIS_PartGraphRecursive(idx_t *nvtxs, idx_t *ncon, idx_t *xadj, +- idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt, +- idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options, +- idx_t *edgecut, idx_t *part); +- +-METIS_API(int) METIS_PartGraphKway(idx_t *nvtxs, idx_t *ncon, idx_t *xadj, +- idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt, +- idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options, +- idx_t *edgecut, idx_t *part); +- +-METIS_API(int) METIS_MeshToDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, +- idx_t *ncommon, idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy); +- +-METIS_API(int) METIS_MeshToNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, +- idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy); +- +-METIS_API(int) METIS_PartMeshNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, +- idx_t *vwgt, idx_t *vsize, idx_t *nparts, real_t *tpwgts, +- idx_t *options, idx_t *objval, idx_t *epart, idx_t *npart); +- +-METIS_API(int) METIS_PartMeshDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, +- idx_t *vwgt, idx_t *vsize, idx_t *ncommon, idx_t *nparts, +- real_t *tpwgts, idx_t *options, idx_t *objval, idx_t *epart, +- idx_t *npart); +- +-METIS_API(int) METIS_NodeND(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, +- idx_t *options, idx_t *perm, idx_t *iperm); +- +-METIS_API(int) METIS_Free(void *ptr); +- +-METIS_API(int) METIS_SetDefaultOptions(idx_t *options); +- +- +-/* These functions are used by ParMETIS */ +- +-METIS_API(int) METIS_NodeNDP(idx_t nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, +- idx_t npes, idx_t *options, idx_t *perm, idx_t *iperm, +- idx_t *sizes); +- +-METIS_API(int) METIS_ComputeVertexSeparator(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, +- idx_t *vwgt, idx_t *options, idx_t *sepsize, idx_t *part); +- +-METIS_API(int) METIS_NodeRefine(idx_t nvtxs, idx_t *xadj, idx_t *vwgt, idx_t *adjncy, +- idx_t *where, idx_t *hmarker, real_t ubfactor); +- +- +-/* These functions are used by DGL */ +- +-METIS_API(int) METIS_CacheFriendlyReordering(idx_t nvtxs, idx_t *xadj, idx_t *adjncy, +- idx_t *part, idx_t *old2new); +- +-#ifdef __cplusplus +-} +-#endif +- +- +- +-/*------------------------------------------------------------------------ +-* Enum type definitions +-*-------------------------------------------------------------------------*/ +-/*! Return codes */ +-typedef enum { +- METIS_OK = 1, /*!< Returned normally */ +- METIS_ERROR_INPUT = -2, /*!< Returned due to erroneous inputs and/or options */ +- METIS_ERROR_MEMORY = -3, /*!< Returned due to insufficient memory */ +- METIS_ERROR = -4 /*!< Some other errors */ +-} rstatus_et; +- +- +-/*! Operation type codes */ +-typedef enum { +- METIS_OP_PMETIS, +- METIS_OP_KMETIS, +- METIS_OP_OMETIS +-} moptype_et; +- +- +-/*! Options codes (i.e., options[]) */ +-typedef enum { +- METIS_OPTION_PTYPE, +- METIS_OPTION_OBJTYPE, +- METIS_OPTION_CTYPE, +- METIS_OPTION_IPTYPE, +- METIS_OPTION_RTYPE, +- METIS_OPTION_DBGLVL, +- METIS_OPTION_NIPARTS, +- METIS_OPTION_NITER, +- METIS_OPTION_NCUTS, +- METIS_OPTION_SEED, +- METIS_OPTION_NO2HOP, +- METIS_OPTION_ONDISK, +- METIS_OPTION_MINCONN, +- METIS_OPTION_CONTIG, +- METIS_OPTION_COMPRESS, +- METIS_OPTION_CCORDER, +- METIS_OPTION_PFACTOR, +- METIS_OPTION_NSEPS, +- METIS_OPTION_UFACTOR, +- METIS_OPTION_NUMBERING, +- METIS_OPTION_DROPEDGES, +- +- /* Used for command-line parameter purposes */ +- METIS_OPTION_HELP, +- METIS_OPTION_TPWGTS, +- METIS_OPTION_NCOMMON, +- METIS_OPTION_NOOUTPUT, +- METIS_OPTION_BALANCE, +- METIS_OPTION_GTYPE, +- METIS_OPTION_UBVEC +-} moptions_et; +- +- +-/*! Partitioning Schemes */ +-typedef enum { +- METIS_PTYPE_RB, +- METIS_PTYPE_KWAY +-} mptype_et; +- +-/*! Graph types for meshes */ +-typedef enum { +- METIS_GTYPE_DUAL, +- METIS_GTYPE_NODAL +-} mgtype_et; +- +-/*! Coarsening Schemes */ +-typedef enum { +- METIS_CTYPE_RM, +- METIS_CTYPE_SHEM +-} mctype_et; +- +-/*! Initial partitioning schemes */ +-typedef enum { +- METIS_IPTYPE_GROW, +- METIS_IPTYPE_RANDOM, +- METIS_IPTYPE_EDGE, +- METIS_IPTYPE_NODE, +- METIS_IPTYPE_METISRB +-} miptype_et; +- +- +-/*! Refinement schemes */ +-typedef enum { +- METIS_RTYPE_FM, +- METIS_RTYPE_GREEDY, +- METIS_RTYPE_SEP2SIDED, +- METIS_RTYPE_SEP1SIDED +-} mrtype_et; +- +- +-/*! Debug Levels */ +-typedef enum { +- METIS_DBG_INFO = 1, /*!< Shows various diagnostic messages */ +- METIS_DBG_TIME = 2, /*!< Perform timing analysis */ +- METIS_DBG_COARSEN = 4, /*!< Show the coarsening progress */ +- METIS_DBG_REFINE = 8, /*!< Show the refinement progress */ +- METIS_DBG_IPART = 16, /*!< Show info on initial partitioning */ +- METIS_DBG_MOVEINFO = 32, /*!< Show info on vertex moves during refinement */ +- METIS_DBG_SEPINFO = 64, /*!< Show info on vertex moves during sep refinement */ +- METIS_DBG_CONNINFO = 128, /*!< Show info on minimization of subdomain connectivity */ +- METIS_DBG_CONTIGINFO = 256, /*!< Show info on elimination of connected components */ +- METIS_DBG_MEMORY = 2048, /*!< Show info related to wspace allocation */ +-} mdbglvl_et; +- +- +-/* Types of objectives */ +-typedef enum { +- METIS_OBJTYPE_CUT, +- METIS_OBJTYPE_VOL, +- METIS_OBJTYPE_NODE +-} mobjtype_et; +- +- +- +-#endif /* _METIS_H_ */ +--- /dev/null ++++ b/include/metis.h.in +@@ -0,0 +1,358 @@ ++/*! ++\file metis.h ++\brief This file contains function prototypes and constant definitions for METIS ++ * ++\author George ++\date Started 8/9/02 ++\version\verbatim $Id$\endverbatim ++*/ ++ ++#ifndef _METIS_H_ ++#define _METIS_H_ ++ ++/**************************************************************************** ++* A set of defines that can be modified by the user ++*****************************************************************************/ ++ ++/*-------------------------------------------------------------------------- ++ Specifies the width of the elementary data type that will hold information ++ about vertices and their adjacency lists. ++ ++ Possible values: ++ 32 : Use 32 bit signed integers ++ 64 : Use 64 bit signed integers ++ ++ A width of 64 should be specified if the number of vertices or the total ++ number of edges in the graph exceed the limits of a 32 bit signed integer ++ i.e., 2^31-1. ++ Proper use of 64 bit integers requires that the c99 standard datatypes ++ int32_t and int64_t are supported by the compiler. ++ GCC does provides these definitions in stdint.h, but it may require some ++ modifications on other architectures. ++--------------------------------------------------------------------------*/ ++#define IDXTYPEWIDTH @METIS_IDXTYPEWIDTH@ ++ ++ ++/*-------------------------------------------------------------------------- ++ Specifies the data type that will hold floating-point style information. ++ ++ Possible values: ++ 32 : single precission floating point (float) ++ 64 : double precission floating point (double) ++--------------------------------------------------------------------------*/ ++#define REALTYPEWIDTH @METIS_REALTYPEWIDTH@ ++ ++ ++ ++/**************************************************************************** ++* In principle, nothing needs to be changed beyond this point, unless the ++* int32_t and int64_t cannot be found in the normal places. ++*****************************************************************************/ ++ ++/* Uniform definitions for various compilers */ ++#if defined(_MSC_VER) ++ #define COMPILER_MSC ++#endif ++#if defined(__ICC) ++ #define COMPILER_ICC ++#endif ++#if defined(__GNUC__) ++ #define COMPILER_GCC ++#endif ++ ++/* Include c99 int definitions and need constants. When building the library, ++ * these are already defined by GKlib; hence the test for _GKLIB_H_ */ ++#ifndef _GKLIB_H_ ++#ifdef COMPILER_MSC ++#include ++ ++typedef __int32 int32_t; ++typedef __int64 int64_t; ++#define PRId32 "I32d" ++#define PRId64 "I64d" ++#define SCNd32 "ld" ++#define SCNd64 "I64d" ++#define INT32_MIN ((int32_t)_I32_MIN) ++#define INT32_MAX _I32_MAX ++#define INT64_MIN ((int64_t)_I64_MIN) ++#define INT64_MAX _I64_MAX ++#else ++#include ++#endif ++#endif ++ ++ ++/*------------------------------------------------------------------------ ++* Setup the basic datatypes ++*-------------------------------------------------------------------------*/ ++#if IDXTYPEWIDTH == 32 ++ typedef int32_t idx_t; ++ ++ #define IDX_MAX INT32_MAX ++ #define IDX_MIN INT32_MIN ++ ++ #define SCIDX SCNd32 ++ #define PRIDX PRId32 ++ ++ #define strtoidx strtol ++ #define iabs abs ++#elif IDXTYPEWIDTH == 64 ++ typedef int64_t idx_t; ++ ++ #define IDX_MAX INT64_MAX ++ #define IDX_MIN INT64_MIN ++ ++ #define SCIDX SCNd64 ++ #define PRIDX PRId64 ++ ++#ifdef COMPILER_MSC ++ #define strtoidx _strtoi64 ++#else ++ #define strtoidx strtoll ++#endif ++ #define iabs labs ++#else ++ #error "Incorrect user-supplied value fo IDXTYPEWIDTH" ++#endif ++ ++ ++#if REALTYPEWIDTH == 32 ++ typedef float real_t; ++ ++ #define SCREAL "f" ++ #define PRREAL "f" ++ #define REAL_MAX FLT_MAX ++ #define REAL_MIN FLT_MIN ++ #define REAL_EPSILON FLT_EPSILON ++ ++ #define rabs fabsf ++ #define REALEQ(x,y) ((rabs((x)-(y)) <= FLT_EPSILON)) ++ ++#ifdef COMPILER_MSC ++ #define strtoreal (float)strtod ++#else ++ #define strtoreal strtof ++#endif ++#elif REALTYPEWIDTH == 64 ++ typedef double real_t; ++ ++ #define SCREAL "lf" ++ #define PRREAL "lf" ++ #define REAL_MAX DBL_MAX ++ #define REAL_MIN DBL_MIN ++ #define REAL_EPSILON DBL_EPSILON ++ ++ #define rabs fabs ++ #define REALEQ(x,y) ((rabs((x)-(y)) <= DBL_EPSILON)) ++ ++ #define strtoreal strtod ++#else ++ #error "Incorrect user-supplied value for REALTYPEWIDTH" ++#endif ++ ++ ++/*------------------------------------------------------------------------ ++* Constant definitions ++*-------------------------------------------------------------------------*/ ++/* Metis's version number */ ++#define METIS_VER_MAJOR 5 ++#define METIS_VER_MINOR 1 ++#define METIS_VER_SUBMINOR 0 ++ ++/* The maximum length of the options[] array */ ++#define METIS_NOPTIONS 40 ++ ++ ++ ++/*------------------------------------------------------------------------ ++* Function prototypes ++*-------------------------------------------------------------------------*/ ++ ++#ifdef _WINDLL ++#define METIS_API(type) __declspec(dllexport) type __cdecl ++#elif defined(__cdecl) ++#define METIS_API(type) type __cdecl ++#else ++#define METIS_API(type) type ++#endif ++ ++ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++METIS_API(int) METIS_PartGraphRecursive(idx_t *nvtxs, idx_t *ncon, idx_t *xadj, ++ idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt, ++ idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options, ++ idx_t *edgecut, idx_t *part); ++ ++METIS_API(int) METIS_PartGraphKway(idx_t *nvtxs, idx_t *ncon, idx_t *xadj, ++ idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt, ++ idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options, ++ idx_t *edgecut, idx_t *part); ++ ++METIS_API(int) METIS_MeshToDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, ++ idx_t *ncommon, idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy); ++ ++METIS_API(int) METIS_MeshToNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, ++ idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy); ++ ++METIS_API(int) METIS_PartMeshNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, ++ idx_t *vwgt, idx_t *vsize, idx_t *nparts, real_t *tpwgts, ++ idx_t *options, idx_t *objval, idx_t *epart, idx_t *npart); ++ ++METIS_API(int) METIS_PartMeshDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, ++ idx_t *vwgt, idx_t *vsize, idx_t *ncommon, idx_t *nparts, ++ real_t *tpwgts, idx_t *options, idx_t *objval, idx_t *epart, ++ idx_t *npart); ++ ++METIS_API(int) METIS_NodeND(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, ++ idx_t *options, idx_t *perm, idx_t *iperm); ++ ++METIS_API(int) METIS_Free(void *ptr); ++ ++METIS_API(int) METIS_SetDefaultOptions(idx_t *options); ++ ++ ++/* These functions are used by ParMETIS */ ++ ++METIS_API(int) METIS_NodeNDP(idx_t nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, ++ idx_t npes, idx_t *options, idx_t *perm, idx_t *iperm, ++ idx_t *sizes); ++ ++METIS_API(int) METIS_ComputeVertexSeparator(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, ++ idx_t *vwgt, idx_t *options, idx_t *sepsize, idx_t *part); ++ ++METIS_API(int) METIS_NodeRefine(idx_t nvtxs, idx_t *xadj, idx_t *vwgt, idx_t *adjncy, ++ idx_t *where, idx_t *hmarker, real_t ubfactor); ++ ++ ++/* These functions are used by DGL */ ++ ++METIS_API(int) METIS_CacheFriendlyReordering(idx_t nvtxs, idx_t *xadj, idx_t *adjncy, ++ idx_t *part, idx_t *old2new); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++ ++ ++/*------------------------------------------------------------------------ ++* Enum type definitions ++*-------------------------------------------------------------------------*/ ++/*! Return codes */ ++typedef enum { ++ METIS_OK = 1, /*!< Returned normally */ ++ METIS_ERROR_INPUT = -2, /*!< Returned due to erroneous inputs and/or options */ ++ METIS_ERROR_MEMORY = -3, /*!< Returned due to insufficient memory */ ++ METIS_ERROR = -4 /*!< Some other errors */ ++} rstatus_et; ++ ++ ++/*! Operation type codes */ ++typedef enum { ++ METIS_OP_PMETIS, ++ METIS_OP_KMETIS, ++ METIS_OP_OMETIS ++} moptype_et; ++ ++ ++/*! Options codes (i.e., options[]) */ ++typedef enum { ++ METIS_OPTION_PTYPE, ++ METIS_OPTION_OBJTYPE, ++ METIS_OPTION_CTYPE, ++ METIS_OPTION_IPTYPE, ++ METIS_OPTION_RTYPE, ++ METIS_OPTION_DBGLVL, ++ METIS_OPTION_NIPARTS, ++ METIS_OPTION_NITER, ++ METIS_OPTION_NCUTS, ++ METIS_OPTION_SEED, ++ METIS_OPTION_NO2HOP, ++ METIS_OPTION_ONDISK, ++ METIS_OPTION_MINCONN, ++ METIS_OPTION_CONTIG, ++ METIS_OPTION_COMPRESS, ++ METIS_OPTION_CCORDER, ++ METIS_OPTION_PFACTOR, ++ METIS_OPTION_NSEPS, ++ METIS_OPTION_UFACTOR, ++ METIS_OPTION_NUMBERING, ++ METIS_OPTION_DROPEDGES, ++ ++ /* Used for command-line parameter purposes */ ++ METIS_OPTION_HELP, ++ METIS_OPTION_TPWGTS, ++ METIS_OPTION_NCOMMON, ++ METIS_OPTION_NOOUTPUT, ++ METIS_OPTION_BALANCE, ++ METIS_OPTION_GTYPE, ++ METIS_OPTION_UBVEC ++} moptions_et; ++ ++ ++/*! Partitioning Schemes */ ++typedef enum { ++ METIS_PTYPE_RB, ++ METIS_PTYPE_KWAY ++} mptype_et; ++ ++/*! Graph types for meshes */ ++typedef enum { ++ METIS_GTYPE_DUAL, ++ METIS_GTYPE_NODAL ++} mgtype_et; ++ ++/*! Coarsening Schemes */ ++typedef enum { ++ METIS_CTYPE_RM, ++ METIS_CTYPE_SHEM ++} mctype_et; ++ ++/*! Initial partitioning schemes */ ++typedef enum { ++ METIS_IPTYPE_GROW, ++ METIS_IPTYPE_RANDOM, ++ METIS_IPTYPE_EDGE, ++ METIS_IPTYPE_NODE, ++ METIS_IPTYPE_METISRB ++} miptype_et; ++ ++ ++/*! Refinement schemes */ ++typedef enum { ++ METIS_RTYPE_FM, ++ METIS_RTYPE_GREEDY, ++ METIS_RTYPE_SEP2SIDED, ++ METIS_RTYPE_SEP1SIDED ++} mrtype_et; ++ ++ ++/*! Debug Levels */ ++typedef enum { ++ METIS_DBG_INFO = 1, /*!< Shows various diagnostic messages */ ++ METIS_DBG_TIME = 2, /*!< Perform timing analysis */ ++ METIS_DBG_COARSEN = 4, /*!< Show the coarsening progress */ ++ METIS_DBG_REFINE = 8, /*!< Show the refinement progress */ ++ METIS_DBG_IPART = 16, /*!< Show info on initial partitioning */ ++ METIS_DBG_MOVEINFO = 32, /*!< Show info on vertex moves during refinement */ ++ METIS_DBG_SEPINFO = 64, /*!< Show info on vertex moves during sep refinement */ ++ METIS_DBG_CONNINFO = 128, /*!< Show info on minimization of subdomain connectivity */ ++ METIS_DBG_CONTIGINFO = 256, /*!< Show info on elimination of connected components */ ++ METIS_DBG_MEMORY = 2048, /*!< Show info related to wspace allocation */ ++} mdbglvl_et; ++ ++ ++/* Types of objectives */ ++typedef enum { ++ METIS_OBJTYPE_CUT, ++ METIS_OBJTYPE_VOL, ++ METIS_OBJTYPE_NODE ++} mobjtype_et; ++ ++ ++ ++#endif /* _METIS_H_ */ diff --git a/recipes/metis/all/patches/003-remove-programs.patch b/recipes/metis/all/patches/003-remove-programs.patch new file mode 100644 index 0000000000000..73a59f03ddbac --- /dev/null +++ b/recipes/metis/all/patches/003-remove-programs.patch @@ -0,0 +1,8 @@ +Do not build programs +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -44,4 +44,3 @@ endif () + + # Recursively look for CMakeLists.txt in subdirs. + add_subdirectory("libmetis") +-add_subdirectory("programs") diff --git a/recipes/metis/all/patches/004-use-conan-gklib.patch b/recipes/metis/all/patches/004-use-conan-gklib.patch new file mode 100644 index 0000000000000..60a824f3c58d1 --- /dev/null +++ b/recipes/metis/all/patches/004-use-conan-gklib.patch @@ -0,0 +1,17 @@ +find gklib from conan +--- a/libmetis/CMakeLists.txt ++++ b/libmetis/CMakeLists.txt +@@ -3,9 +3,11 @@ include_directories(.) + # Find sources. + file(GLOB metis_sources *.c) + # Build libmetis. +-add_library(metis ${METIS_LIBRARY_TYPE} ${GKlib_sources} ${metis_sources}) ++add_library(metis ${METIS_LIBRARY_TYPE} ${metis_sources}) ++find_package(gklib REQUIRED) ++target_link_libraries(metis PRIVATE gklib::gklib) + if(UNIX) +- target_link_libraries(metis m) ++ target_link_libraries(metis PRIVATE m) + endif() + + if(METIS_INSTALL) diff --git a/recipes/metis/all/patches/005-fix-install.patch b/recipes/metis/all/patches/005-fix-install.patch new file mode 100644 index 0000000000000..0ddb28f482535 --- /dev/null +++ b/recipes/metis/all/patches/005-fix-install.patch @@ -0,0 +1,28 @@ +Always install and fix runtime destination +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,11 +4,7 @@ project(METIS C) + set(GKLIB_PATH "${CMAKE_SOURCE_DIR}/GKlib" CACHE PATH "path to GKlib") + set(SHARED FALSE CACHE BOOL "build a shared library") + +-if(MSVC) +- set(METIS_INSTALL FALSE) +-else() +- set(METIS_INSTALL TRUE) +-endif() ++set(METIS_INSTALL TRUE) + + # Configure libmetis library. + if(SHARED) +diff --git a/libmetis/CMakeLists.txt b/libmetis/CMakeLists.txt +index b577360..e9c7825 100644 +--- a/libmetis/CMakeLists.txt ++++ b/libmetis/CMakeLists.txt +@@ -13,6 +13,6 @@ endif() + if(METIS_INSTALL) + install(TARGETS metis + LIBRARY DESTINATION lib +- RUNTIME DESTINATION lib ++ RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib) + endif() diff --git a/recipes/metis/all/test_package/CMakeLists.txt b/recipes/metis/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..04b6e4c9401dc --- /dev/null +++ b/recipes/metis/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(metis REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test.cpp) +target_link_libraries(${PROJECT_NAME} metis::metis) diff --git a/recipes/metis/all/test_package/conanfile.py b/recipes/metis/all/test_package/conanfile.py new file mode 100644 index 0000000000000..46d71712aba54 --- /dev/null +++ b/recipes/metis/all/test_package/conanfile.py @@ -0,0 +1,24 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build_requirements(self): + if self.settings.os == "Macos" and self.settings.arch == "armv8": + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + self.build_requires("cmake/3.20.1") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/metis/all/test_package/test.cpp b/recipes/metis/all/test_package/test.cpp new file mode 100644 index 0000000000000..df955f7eb7be3 --- /dev/null +++ b/recipes/metis/all/test_package/test.cpp @@ -0,0 +1,37 @@ +#include + +#include +#include + +int main(){ + + idx_t nVertices = 6; + idx_t nEdges = 7; + idx_t nWeights = 1; + idx_t nParts = 2; + + idx_t objval; + idx_t part[6]; + + // Indexes of starting points in adjacent array + idx_t xadj[6+1] = {0,2,5,7,9,12,14}; + + // Adjacent vertices in consecutive index order + idx_t adjncy[2 * 7] = {1,3,0,4,2,1,5,0,4,3,1,5,4,2}; + + // Weights of vertices + // if all weights are equal then can be set to NULL + idx_t vwgt[6 * 1]; + + int ret = METIS_PartGraphKway(&nVertices,& nWeights, xadj, adjncy, + NULL, NULL, NULL, &nParts, NULL, + NULL, NULL, &objval, part); + + std::cout << ret << std::endl; + + for(unsigned part_i = 0; part_i < nVertices; part_i++){ + std::cout << part_i << " " << part[part_i] << std::endl; + } + + return 0; +} diff --git a/recipes/metis/config.yml b/recipes/metis/config.yml new file mode 100644 index 0000000000000..e7148244c2a2f --- /dev/null +++ b/recipes/metis/config.yml @@ -0,0 +1,3 @@ +versions: + "5.1.1": + folder: all diff --git a/recipes/mfast/all/conandata.yml b/recipes/mfast/all/conandata.yml index bd9c56769c9c3..6864deb0bd015 100644 --- a/recipes/mfast/all/conandata.yml +++ b/recipes/mfast/all/conandata.yml @@ -1,24 +1,18 @@ sources: + "1.2.2": + url: "https://github.com/objectcomputing/mFAST/archive/refs/tags/v1.2.2.tar.gz" + sha256: "a7686c4d2e3121d7c8dd7f43b70424b55d4a1f6843179a6b0709658be27f39cb" "1.2.1": url: "https://github.com/objectcomputing/mFAST/archive/v1.2.1.tar.gz" sha256: "e6ed19e629a33068b7ab5ebdbd860831f2f2b44b3b361068fbbbe975202a4851" - "cci.20200824": - url: "https://github.com/objectcomputing/mFAST/archive/4546f9b2f26cc7801fa63c05a7354ecbcb04410a.zip" - sha256: "ec2e34b0943066313db0a9cf2035ab8d5b28f9d46f0adfbb3ef9aa2a25280a4e" patches: - "1.2.1": - - patch_file: "patches/00001-adapt-cmakelists.patch" - base_path: "source_subfolder" - - patch_file: "patches/00002-add-conan-libs-to-targets.patch" - base_path: "source_subfolder" - - patch_file: "patches/00003-remove-deprecated-boost-detail-endian.patch" + "1.2.2": + - patch_file: "patches/0001-fix-cmake-1.2.2.patch" base_path: "source_subfolder" - "cci.20200824": - - patch_file: "patches/00001-adapt-cmakelists.cci.20200824.patch" - base_path: "source_subfolder" - - patch_file: "patches/00002-add-conan-libs-to-targets.cci.20200824.patch" + "1.2.1": + - patch_file: "patches/0001-fix-cmake-1.2.1.patch" base_path: "source_subfolder" - - patch_file: "patches/00003-remove-deprecated-boost-detail-endian.cci.20200824.patch" + - patch_file: "patches/0002-remove-deprecated-boost-detail-endian.patch" base_path: "source_subfolder" - - patch_file: "patches/00004-remove-cxx-std.cci.20200824.patch" + - patch_file: "patches/0003-mfast-sqlite3.patch" base_path: "source_subfolder" diff --git a/recipes/mfast/all/conanfile.py b/recipes/mfast/all/conanfile.py index 2a480c2fbdc71..c23447275579e 100644 --- a/recipes/mfast/all/conanfile.py +++ b/recipes/mfast/all/conanfile.py @@ -1,10 +1,10 @@ from conans import ConanFile, CMake, tools -import glob +from conans.errors import ConanInvalidConfiguration import os import shutil import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.43.0" class mFASTConan(ConanFile): @@ -12,25 +12,27 @@ class mFASTConan(ConanFile): license = "LGPL-3.0" url = "https://github.com/conan-io/conan-center-index" homepage = "https://objectcomputing.com/" - description = "mFAST is a high performance C++ encoding/decoding library for FAST (FIX Adapted for STreaming)"\ - " protocol" - topics = ("conan", "mFAST", "FAST", "FIX", "Fix Adapted for STreaming", "Financial Information Exchange", - "libraries", "cpp") + description = ( + "mFAST is a high performance C++ encoding/decoding library for FAST " + "(FIX Adapted for STreaming) protocol" + ) + topics = ("mfast", "fast", "fix", "fix-adapted-for-streaming", + "financial-information-exchange", "libraries", "cpp") settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], + "with_sqlite3": [True, False], } default_options = { "shared": False, "fPIC": True, + "with_sqlite3": False, } short_paths = True - - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" + generators = "cmake", "cmake_find_package", "cmake_find_package_multi" _cmake = None @property @@ -41,6 +43,20 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _compilers_minimum_version(self): + return { + "gcc": "6", + "Visual Studio": "14", + "clang": "3.4", + "apple-clang": "5.1", + } + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -51,12 +67,30 @@ def configure(self): def requirements(self): self.requires("boost/1.75.0") - self.requires("tinyxml2/8.0.0") + self.requires("tinyxml2/9.0.0") + if self.options.with_sqlite3: + self.requires("sqlite3/3.37.2") + + def validate(self): + if tools.Version(self.version) >= "1.2.2": + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 14) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + "mfast {} requires C++14, which your compiler does not support.".format(self.version) + ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("mFAST-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if not self._cmake: @@ -64,11 +98,9 @@ def _configure_cmake(self): self._cmake.definitions["BUILD_TESTS"] = False self._cmake.definitions["BUILD_EXAMPLES"] = False self._cmake.definitions["BUILD_PACKAGES"] = False - if self.version != "1.2.1": - if not self.settings.compiler.cppstd: - self._cmake.definitions["CMAKE_CXX_STANDARD"] = 14 - else: - tools.check_min_cppstd(self, 14) + self._cmake.definitions["BUILD_SQLITE3"] = self.options.with_sqlite3 + if tools.Version(self.version) >= "1.2.2" and not tools.valid_min_cppstd(self, 14): + self._cmake.definitions["CMAKE_CXX_STANDARD"] = 14 self._cmake.configure(build_folder=self._build_subfolder) return self._cmake @@ -102,6 +134,8 @@ def package(self): # [ ] MFAST__LIBRARY - particular component library # [x] MFAST_EXECUTABLE - the fast_type_gen executable => done in _prepend_exec_target_in_fasttypegentarget() self._prepend_exec_target_in_fasttypegentarget() + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._lib_targets_module_file), {values["target"]:"mFAST::{}".format(values["target"]) for values in self._mfast_lib_components.values()} @@ -120,7 +154,7 @@ def _fast_type_gen_target_file(self): return os.path.join(self._new_mfast_config_dir, "FastTypeGenTarget.cmake") def _extract_fasttypegentarget_macro(self): - if self.version == "1.2.1": + if tools.Version(self.version) < "1.2.2": config_file_content = tools.load(os.path.join(self.package_folder, self._old_mfast_config_dir, "mFASTConfig.cmake")) begin = config_file_content.find("macro(FASTTYPEGEN_TARGET Name)") end = config_file_content.find("endmacro()", begin) + len("endmacro()") @@ -139,7 +173,12 @@ def _prepend_exec_target_in_fasttypegentarget(self): fast_type_rel_path = "{}bin/{}".format("".join(["../"] * module_folder_depth), fast_type_filename) exec_target_content = textwrap.dedent("""\ if(NOT TARGET fast_type_gen) - get_filename_component(MFAST_EXECUTABLE "${{CMAKE_CURRENT_LIST_DIR}}/{fast_type_rel_path}" ABSOLUTE) + if(CMAKE_CROSSCOMPILING) + find_program(MFAST_EXECUTABLE fast_type_gen PATHS ENV PATH NO_DEFAULT_PATH) + endif() + if(NOT MFAST_EXECUTABLE) + get_filename_component(MFAST_EXECUTABLE "${{CMAKE_CURRENT_LIST_DIR}}/{fast_type_rel_path}" ABSOLUTE) + endif() add_executable(fast_type_gen IMPORTED) set_property(TARGET fast_type_gen PROPERTY IMPORTED_LOCATION ${{MFAST_EXECUTABLE}}) endif() @@ -168,63 +207,70 @@ def _lib_targets_module_file(self): @property def _mfast_lib_components(self): - # TODO: improve accuracy of external requirements of each component target_suffix = "_static" if not self.options.shared else "" lib_suffix = "_static" if self.settings.os == "Windows" and not self.options.shared else "" - return { + components = { "libmfast": { "comp": "mfast", "target": "mfast" + target_suffix, "lib": "mfast" + lib_suffix, - "requires": ["boost::headers"] + "requires": ["boost::headers"], }, "mfast_coder": { "comp": "mfast_coder", "target": "mfast_coder" + target_suffix, "lib": "mfast_coder" + lib_suffix, - "requires": ["libmfast", "boost::headers"] + "requires": ["libmfast", "boost::headers"], }, "mfast_xml_parser": { "comp": "mfast_xml_parser", "target": "mfast_xml_parser" + target_suffix, "lib": "mfast_xml_parser" + lib_suffix, - "requires": ["libmfast", "boost::headers", "tinyxml2::tinyxml2"] + "requires": ["libmfast", "boost::headers", "tinyxml2::tinyxml2"], }, "mfast_json": { "comp": "mfast_json", "target": "mfast_json" + target_suffix, "lib": "mfast_json" + lib_suffix, - "requires": ["libmfast", "boost::headers"] - } + "requires": ["libmfast", "boost::headers"], + }, } + if self.options.with_sqlite3: + components.update({ + "mfast_sqlite3": { + "comp": "mfast_sqlite3", + "target": "mfast_sqlite3" + target_suffix, + "lib": "mfast_sqlite3" + lib_suffix, + "requires": ["libmfast", "boost::headers", "sqlite3::sqlite3"], + }, + }) + return components def package_info(self): - self.cpp_info.names["cmake_find_package"] = "mFAST" - self.cpp_info.names["cmake_find_package_multi"] = "mFAST" + self.cpp_info.set_property("cmake_file_name", "mFAST") + self.cpp_info.set_property("cmake_build_modules", [self._fast_type_gen_target_file]) for conan_comp, values in self._mfast_lib_components.items(): target = values["target"] + comp = values["comp"] lib = values["lib"] requires = values["requires"] - self.cpp_info.components[conan_comp].names["cmake_find_package"] = target - self.cpp_info.components[conan_comp].names["cmake_find_package_multi"] = target - self.cpp_info.components[conan_comp].builddirs.append(self._new_mfast_config_dir) - self.cpp_info.components[conan_comp].build_modules["cmake"] = [self._fast_type_gen_target_file] - self.cpp_info.components[conan_comp].build_modules["cmake_find_package"] = [ - self._lib_targets_module_file, - self._fast_type_gen_target_file - ] - self.cpp_info.components[conan_comp].build_modules["cmake_find_package_multi"] = [ - self._lib_targets_module_file, - self._fast_type_gen_target_file - ] + self.cpp_info.components[conan_comp].set_property("cmake_file_name", target) + if comp != target: + # Also provide alias component for find_package(mFAST COMPONENTS ...) if static + self.cpp_info.components[conan_comp].set_property("cmake_target_aliases", [comp]) self.cpp_info.components[conan_comp].libs = [lib] self.cpp_info.components[conan_comp].requires = requires if self.options.shared: self.cpp_info.components[conan_comp].defines = ["MFAST_DYN_LINK"] - # Also provide alias component for find_package(mFAST COMPONENTS ...) if static: - comp = values["comp"] + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.components[conan_comp].names["cmake_find_package"] = target + self.cpp_info.components[conan_comp].names["cmake_find_package_multi"] = target + self.cpp_info.components[conan_comp].build_modules["cmake"] = [self._fast_type_gen_target_file] + build_modules = [self._lib_targets_module_file, self._fast_type_gen_target_file] + self.cpp_info.components[conan_comp].build_modules["cmake_find_package"] = build_modules + self.cpp_info.components[conan_comp].build_modules["cmake_find_package_multi"] = build_modules if comp != target: conan_comp_alias = conan_comp + "_alias" self.cpp_info.components[conan_comp_alias].names["cmake_find_package"] = comp @@ -235,3 +281,7 @@ def package_info(self): self.cpp_info.components[conan_comp_alias].resdirs = [] self.cpp_info.components[conan_comp_alias].bindirs = [] self.cpp_info.components[conan_comp_alias].frameworkdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "mFAST" + self.cpp_info.names["cmake_find_package_multi"] = "mFAST" diff --git a/recipes/mfast/all/patches/00001-adapt-cmakelists.cci.20200824.patch b/recipes/mfast/all/patches/00001-adapt-cmakelists.cci.20200824.patch deleted file mode 100644 index 063ce1d770b8a..0000000000000 --- a/recipes/mfast/all/patches/00001-adapt-cmakelists.cci.20200824.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index ed51adc..b9427b8 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -60,8 +63,6 @@ if(BUILD_PACKAGES) - - endif(BUILD_PACKAGES) - --find_package(Boost 1.56.0 REQUIRED) --include_directories(${Boost_INCLUDE_DIR}) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tinyxml2) - include_directories ("${PROJECT_SOURCE_DIR}/src") - diff --git a/recipes/mfast/all/patches/00001-adapt-cmakelists.patch b/recipes/mfast/all/patches/00001-adapt-cmakelists.patch deleted file mode 100644 index 5e5803eb98ffa..0000000000000 --- a/recipes/mfast/all/patches/00001-adapt-cmakelists.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 3721f76..847f587 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -69,9 +72,6 @@ include_directories ("${PROJECT_BINARY_DIR}" - ## Setting up Boost Library - ################################ - --find_package( Boost 1.53.0 REQUIRED unit_test_framework system filesystem) --include_directories(${Boost_INCLUDE_DIR}) --link_directories(${Boost_LIBRARY_DIRS}) - - ################################################################################ - -@@ -174,9 +174,6 @@ endmacro() - # Recurse into the "src" and "unit-tests" subdirectories. This does not actually - # cause another cmake executable to run. The same process will walk through - # the project's entire directory structure. --enable_testing() -- --add_subdirectory (tests) - - if (BUILD_SHARED_LIBS) - set(MFAST_LIBRARIES mfast_coder mfast_xml_parser mfast) -@@ -185,8 +182,6 @@ else() - set(MFAST_LIBRARIES mfast_coder_static mfast_xml_parser_static mfast_static) - endif() - --add_subdirectory (examples) -- - - # Setting up dist target - # =============================== diff --git a/recipes/mfast/all/patches/00002-add-conan-libs-to-targets.cci.20200824.patch b/recipes/mfast/all/patches/00002-add-conan-libs-to-targets.cci.20200824.patch deleted file mode 100644 index e018e33f36b49..0000000000000 --- a/recipes/mfast/all/patches/00002-add-conan-libs-to-targets.cci.20200824.patch +++ /dev/null @@ -1,115 +0,0 @@ ---- a/src/mfast/CMakeLists.txt -+++ b/src/mfast/CMakeLists.txt -@@ -11,6 +11,7 @@ set(mfast_SRCS ${sources} ${instruction_sources} ${headers} ${instruction_heade - - add_library(mfast_static STATIC ${mfast_SRCS}) - target_include_directories(mfast_static PUBLIC $) -+target_link_libraries(mfast_static ${CONAN_LIBS}) - - if (UNIX) - set_target_properties(mfast_static PROPERTIES OUTPUT_NAME mfast) -@@ -27,6 +28,7 @@ set(MFAST_STATIC_LIBRARIES ${MFAST_STATIC_LIBRARIES} mfast_static CACHE INTERNAL - - if (BUILD_SHARED_LIBS) - add_library(mfast SHARED ${mfast_SRCS}) -+ target_link_libraries(mfast ${CONAN_LIBS}) - - if (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.12") - target_compile_definitions(mfast INTERFACE "-DMFAST_DYN_LINK") -@@ -42,6 +44,7 @@ if (BUILD_SHARED_LIBS) - install(TARGETS mfast - EXPORT mFASTTargets - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) - - set(MFAST_SHARED_LIBRARIES ${MFAST_SHARED_LIBRARIES} mfast CACHE INTERNAL "") ---- a/src/mfast/coder/CMakeLists.txt -+++ b/src/mfast/coder/CMakeLists.txt -@@ -18,7 +18,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - set(mfast_coder_SRCS ${sources} ${headers}) - - add_library(mfast_coder_static STATIC ${mfast_coder_SRCS}) --target_link_libraries(mfast_coder_static mfast_static) -+target_link_libraries(mfast_coder_static mfast_static ${CONAN_LIBS}) - - if (UNIX) - set_target_properties(mfast_coder_static PROPERTIES OUTPUT_NAME mfast_coder) -@@ -44,7 +44,7 @@ if (BUILD_SHARED_LIBS) - if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) - set_target_properties(mfast_coder PROPERTIES COMPILE_FLAGS -fvisibility=hidden) - endif() -- target_link_libraries(mfast_coder mfast) -+ target_link_libraries(mfast_coder mfast ${CONAN_LIBS}) - set_target_properties(mfast_coder PROPERTIES - VERSION "${MFAST_VERSION}" - SOVERSION "${MFAST_SOVERSION}") -@@ -55,6 +55,7 @@ if (BUILD_SHARED_LIBS) - install(TARGETS mfast_coder - EXPORT mFASTTargets - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) - - set(MFAST_SHARED_LIBRARIES ${MFAST_SHARED_LIBRARIES} mfast_coder CACHE INTERNAL "") ---- a/src/mfast/json/CMakeLists.txt -+++ b/src/mfast/json/CMakeLists.txt -@@ -9,7 +9,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - set(mfast_json_SRCS ${sources} ${headers}) - - add_library(mfast_json_static STATIC ${mfast_json_SRCS}) --target_link_libraries(mfast_json_static mfast_static) -+target_link_libraries(mfast_json_static mfast_static ${CONAN_LIBS}) - - if (UNIX) - set_target_properties(mfast_json_static PROPERTIES OUTPUT_NAME mfast_json) -@@ -35,7 +35,7 @@ if (BUILD_SHARED_LIBS) - if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) - set_target_properties(mfast_json PROPERTIES COMPILE_FLAGS -fvisibility=hidden) - endif() -- target_link_libraries(mfast_json mfast) -+ target_link_libraries(mfast_json mfast ${CONAN_LIBS}) - set_target_properties(mfast_json PROPERTIES - VERSION "${MFAST_VERSION}" - SOVERSION "${MFAST_SOVERSION}") -@@ -46,6 +46,7 @@ if (BUILD_SHARED_LIBS) - install(TARGETS mfast_json - EXPORT mFASTTargets - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) - - set(MFAST_SHARED_LIBRARIES ${MFAST_SHARED_LIBRARIES} mfast_json CACHE INTERNAL "") ---- a/src/mfast/xml_parser/CMakeLists.txt -+++ b/src/mfast/xml_parser/CMakeLists.txt -@@ -6,12 +6,11 @@ file (GLOB_RECURSE sources "*.cpp") ## retrieve all source files in current - - set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - --include_directories("${CMAKE_SOURCE_DIR}/tinyxml2") - --set(mfast_xml_parser_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../../../tinyxml2/tinyxml2.cpp ${sources} ${headers}) -+set(mfast_xml_parser_SRCS ${sources} ${headers}) - - add_library(mfast_xml_parser_static STATIC ${mfast_xml_parser_SRCS}) --target_link_libraries(mfast_xml_parser_static mfast_static) -+target_link_libraries(mfast_xml_parser_static mfast_static ${CONAN_LIBS}) - - if (UNIX) - set_target_properties(mfast_xml_parser_static PROPERTIES OUTPUT_NAME mfast_xml_parser) -@@ -30,6 +29,7 @@ set(MFAST_STATIC_COMPONENTS ${MFAST_STATIC_COMPONENTS} xml_parser_static CACHE I - - if (BUILD_SHARED_LIBS) - add_library(mfast_xml_parser SHARED ${mfast_xml_parser_SRCS}) -+ target_link_libraries(mfast_xml_parser mfast ${CONAN_LIBS}) - - if (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.12") - target_compile_definitions(mfast_xml_parser INTERFACE "-DMFAST_DYN_LINK") -@@ -51,6 +51,7 @@ if (BUILD_SHARED_LIBS) - install(TARGETS mfast_xml_parser - EXPORT mFASTTargets - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) - - set(MFAST_SHARED_LIBRARIES ${MFAST_SHARED_LIBRARIES} mfast_xml_parser CACHE INTERNAL "") diff --git a/recipes/mfast/all/patches/00002-add-conan-libs-to-targets.patch b/recipes/mfast/all/patches/00002-add-conan-libs-to-targets.patch deleted file mode 100644 index 06213c5cff39a..0000000000000 --- a/recipes/mfast/all/patches/00002-add-conan-libs-to-targets.patch +++ /dev/null @@ -1,122 +0,0 @@ ---- a/src/fast_type_gen/CMakeLists.txt -+++ b/src/fast_type_gen/CMakeLists.txt -@@ -11,8 +11,7 @@ add_executable (fast_type_gen - target_link_libraries (fast_type_gen - mfast_xml_parser_static - mfast_static -- ${Boost_SYSTEM_LIBRARY} -- ${Boost_FILESYSTEM_LIBRARY}) -+ ${CONAN_LIBS}) - - install(TARGETS fast_type_gen - EXPORT mFASTTargets ---- a/src/mfast/CMakeLists.txt -+++ b/src/mfast/CMakeLists.txt -@@ -11,6 +11,7 @@ set(mfast_SRCS ${sources} ${instruction_sources} ${headers} ${instruction_heade - - add_library(mfast_static STATIC ${mfast_SRCS}) - -+target_link_libraries(mfast_static ${CONAN_LIBS}) - - if (UNIX) - set_target_properties(mfast_static PROPERTIES OUTPUT_NAME mfast) -@@ -30,6 +31,7 @@ if (BUILD_SHARED_LIBS) - # would be deleted when the static library is built. For CMake 2.8.x, there - # is no such problem. - add_dependencies(mfast mfast_static) -+ target_link_libraries(mfast ${CONAN_LIBS}) - - if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) - set_target_properties(mfast PROPERTIES COMPILE_FLAGS -fvisibility=hidden) -@@ -38,6 +40,7 @@ if (BUILD_SHARED_LIBS) - install(TARGETS mfast - EXPORT mFASTTargets - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) - - SET(MFAST_LIBRARY mfast CACHE INTERNAL "mFast Library name") ---- a/src/mfast/coder/CMakeLists.txt -+++ b/src/mfast/coder/CMakeLists.txt -@@ -9,6 +9,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - set(mfast_coder_SRCS ${sources} ${headers}) - - add_library(mfast_coder_static STATIC ${mfast_coder_SRCS}) -+target_link_libraries(mfast_coder_static ${CONAN_LIBS}) - - if (UNIX) - set_target_properties(mfast_coder_static PROPERTIES OUTPUT_NAME mfast_coder) -@@ -28,6 +29,7 @@ if (BUILD_SHARED_LIBS) - # would be deleted when the static library is built. For CMake 2.8.x, there - # is no such problem. - add_dependencies(mfast_coder mfast_coder_static) -+ target_link_libraries(mfast_coder ${CONAN_LIBS}) - - if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) - set_target_properties(mfast_coder PROPERTIES COMPILE_FLAGS -fvisibility=hidden) -@@ -39,6 +41,7 @@ if (BUILD_SHARED_LIBS) - install(TARGETS mfast_coder - EXPORT mFASTTargets - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) - - SET(MFAST_DYNAMIC_COMPONENTS ${MFAST_DYNAMIC_COMPONENTS} coder CACHE INTERNAL "") ---- a/src/mfast/json/CMakeLists.txt -+++ b/src/mfast/json/CMakeLists.txt -@@ -9,6 +9,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - set(mfast_json_SRCS ${sources} ${headers}) - - add_library(mfast_json_static STATIC ${mfast_json_SRCS}) -+target_link_libraries(mfast_json_static ${CONAN_LIBS}) - - if (UNIX) - set_target_properties(mfast_json_static PROPERTIES OUTPUT_NAME mfast_json) -@@ -28,6 +29,7 @@ if (BUILD_SHARED_LIBS) - # would be deleted when the static library is built. For CMake 2.8.x, there - # is no such problem. - add_dependencies(mfast_json mfast_json_static) -+ target_link_libraries(mfast_json ${CONAN_LIBS}) - - if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) - set_target_properties(mfast_json PROPERTIES COMPILE_FLAGS -fvisibility=hidden) -@@ -38,6 +40,7 @@ if (BUILD_SHARED_LIBS) - install(TARGETS mfast_json - EXPORT mFASTTargets - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) - - SET(MFAST_DYNAMIC_COMPONENTS ${MFAST_DYNAMIC_COMPONENTS} json CACHE INTERNAL "") ---- a/src/mfast/xml_parser/CMakeLists.txt -+++ b/src/mfast/xml_parser/CMakeLists.txt -@@ -6,11 +6,11 @@ file (GLOB_RECURSE sources "*.cpp") ## retrieve all source files in current - - SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - --include_directories("${CMAKE_SOURCE_DIR}/tinyxml2") - --set(mfast_xml_parser_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../../../tinyxml2/tinyxml2.cpp ${sources} ${headers}) -+set(mfast_xml_parser_SRCS ${sources} ${headers}) - - add_library(mfast_xml_parser_static STATIC ${mfast_xml_parser_SRCS}) -+target_link_libraries(mfast_xml_parser_static ${CONAN_LIBS} ) - - if (UNIX) - set_target_properties(mfast_xml_parser_static PROPERTIES OUTPUT_NAME mfast_xml_parser) -@@ -30,6 +30,7 @@ if (BUILD_SHARED_LIBS) - # would be deleted when the static library is built. For CMake 2.8.x, there - # is no such problem. - add_dependencies(mfast_xml_parser mfast_xml_parser_static) -+ target_link_libraries(mfast_xml_parser ${CONAN_LIBS} ) - - if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) - set_target_properties(mfast_xml_parser PROPERTIES COMPILE_FLAGS -fvisibility=hidden) -@@ -41,6 +42,7 @@ if (BUILD_SHARED_LIBS) - install(TARGETS mfast_xml_parser - EXPORT mFASTTargets - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin -+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) - - SET(MFAST_DYNAMIC_COMPONENTS ${MFAST_DYNAMIC_COMPONENTS} coder CACHE INTERNAL "") diff --git a/recipes/mfast/all/patches/00003-remove-deprecated-boost-detail-endian.cci.20200824.patch b/recipes/mfast/all/patches/00003-remove-deprecated-boost-detail-endian.cci.20200824.patch deleted file mode 100644 index 89ae271746709..0000000000000 --- a/recipes/mfast/all/patches/00003-remove-deprecated-boost-detail-endian.cci.20200824.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/src/mfast/coder/encoder/encoder_presence_map.h b/src/mfast/coder/encoder/encoder_presence_map.h -index ab8be89..a66fd8d 100644 ---- a/src/mfast/coder/encoder/encoder_presence_map.h -+++ b/src/mfast/coder/encoder/encoder_presence_map.h -@@ -56,7 +56,7 @@ inline void encoder_presence_map::reset() { - } - - inline void encoder_presence_map::commit() { --#ifdef BOOST_BIG_ENDIAN -+#if BOOST_ENDIAN_BIG_BYTE - const std::size_t stop_bit_mask = (init_mask >> (nbytes_ * 8)); - #else - const std::size_t stop_bit_mask = (init_mask << (nbytes_ * 8)); -@@ -74,7 +74,7 @@ inline void encoder_presence_map::set_next_bit(bool v) { - const std::size_t next_bit_mask = get_next_bit_mask(sizeof(std::size_t)); - - if ((mask_ & next_bit_mask) != 0) { --#ifdef BOOST_BIG_ENDIAN -+#if BOOST_ENDIAN_BIG_BYTE - mask_ >>= 2; - #else - mask_ <<= 14; diff --git a/recipes/mfast/all/patches/00004-remove-cxx-std.cci.20200824.patch b/recipes/mfast/all/patches/00004-remove-cxx-std.cci.20200824.patch deleted file mode 100644 index 2bf752492bca7..0000000000000 --- a/recipes/mfast/all/patches/00004-remove-cxx-std.cci.20200824.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/cmake/SetCXXStandard.cmake b/cmake/SetCXXStandard.cmake -index a0402ee..e69de29 100644 ---- a/cmake/SetCXXStandard.cmake -+++ b/cmake/SetCXXStandard.cmake -@@ -1,14 +0,0 @@ -- --find_package(Boost 1.59.0 REQUIRED) --if(Boost_VERSION VERSION_LESS "1.72.0") -- set(CMAKE_CXX_STANDARD 11 CACHE INTERNAL "specifies the C++ standard whose features are requested to build this target") --else() -- set(CMAKE_CXX_STANDARD 14 CACHE INTERNAL "specifies the C++ standard whose features are requested to build this target") --endif() -- --set(CMAKE_CXX_STANDARD_REQUIRED ON) --if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") -- ### Even though CMAKE_CXX_STANDARD_REQUIRED is supported since CMake 3.1, it doesn't work for Emscripten em++ together with -- ### Cmake 3.6. -- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}") --endif() -\ No newline at end of file diff --git a/recipes/mfast/all/patches/0001-fix-cmake-1.2.1.patch b/recipes/mfast/all/patches/0001-fix-cmake-1.2.1.patch new file mode 100644 index 0000000000000..0d5ca77fffb24 --- /dev/null +++ b/recipes/mfast/all/patches/0001-fix-cmake-1.2.1.patch @@ -0,0 +1,196 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -69,9 +69,11 @@ include_directories ("${PROJECT_BINARY_DIR}" + ## Setting up Boost Library + ################################ + +-find_package( Boost 1.53.0 REQUIRED unit_test_framework system filesystem) +-include_directories(${Boost_INCLUDE_DIR}) +-link_directories(${Boost_LIBRARY_DIRS}) ++find_package(Boost REQUIRED system filesystem) ++find_package(tinyxml2 REQUIRED CONFIG) ++if(BUILD_SQLITE3) ++ find_package(SQLite3 REQUIRED) ++endif() + + ################################################################################ + +@@ -95,7 +97,6 @@ set(MFAST_LIBRARY CACHE INTERNAL "") + + # add the automatically determined parts of the RPATH + # which point to directories outside the build tree to the install RPATH +-SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + + + ############################################################################ +@@ -174,9 +175,7 @@ endmacro() + # Recurse into the "src" and "unit-tests" subdirectories. This does not actually + # cause another cmake executable to run. The same process will walk through + # the project's entire directory structure. +-enable_testing() + +-add_subdirectory (tests) + + if (BUILD_SHARED_LIBS) + set(MFAST_LIBRARIES mfast_coder mfast_xml_parser mfast) +@@ -185,7 +184,6 @@ else() + set(MFAST_LIBRARIES mfast_coder_static mfast_xml_parser_static mfast_static) + endif() + +-add_subdirectory (examples) + + + # Setting up dist target +--- a/src/fast_type_gen/CMakeLists.txt ++++ b/src/fast_type_gen/CMakeLists.txt +@@ -11,9 +11,10 @@ add_executable (fast_type_gen + target_link_libraries (fast_type_gen + mfast_xml_parser_static + mfast_static +- ${Boost_SYSTEM_LIBRARY} +- ${Boost_FILESYSTEM_LIBRARY}) ++ Boost::headers ++ Boost::system ++ Boost::filesystem) + + install(TARGETS fast_type_gen + EXPORT mFASTTargets +- RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin) +\ No newline at end of file ++ DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin) +\ No newline at end of file +--- a/src/mfast/CMakeLists.txt ++++ b/src/mfast/CMakeLists.txt +@@ -10,6 +10,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + set(mfast_SRCS ${sources} ${instruction_sources} ${headers} ${instruction_headers}) + + add_library(mfast_static STATIC ${mfast_SRCS}) ++target_link_libraries(mfast_static Boost::headers) + + + if (UNIX) +@@ -25,6 +26,7 @@ install(TARGETS mfast_static + + if (BUILD_SHARED_LIBS) + add_library(mfast SHARED ${mfast_SRCS}) ++ target_link_libraries(mfast Boost::headers) + # the add_dependencies is necessary for CMake 2.6.4. Otherwise, the shared + # library would be built before the static library, and the shared library + # would be deleted when the static library is built. For CMake 2.8.x, there +@@ -38,6 +40,7 @@ if (BUILD_SHARED_LIBS) + install(TARGETS mfast + EXPORT mFASTTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) + + SET(MFAST_LIBRARY mfast CACHE INTERNAL "mFast Library name") +--- a/src/mfast/coder/CMakeLists.txt ++++ b/src/mfast/coder/CMakeLists.txt +@@ -9,6 +9,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + set(mfast_coder_SRCS ${sources} ${headers}) + + add_library(mfast_coder_static STATIC ${mfast_coder_SRCS}) ++target_link_libraries(mfast_coder_static mfast_static Boost::headers) + + if (UNIX) + set_target_properties(mfast_coder_static PROPERTIES OUTPUT_NAME mfast_coder) +@@ -32,13 +33,14 @@ if (BUILD_SHARED_LIBS) + if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) + set_target_properties(mfast_coder PROPERTIES COMPILE_FLAGS -fvisibility=hidden) + endif() +- target_link_libraries(mfast_coder mfast) ++ target_link_libraries(mfast_coder mfast Boost::headers) + set_target_properties(mfast_coder PROPERTIES COMPILE_FLAGS -DMFAST_DYN_LINK) + + + install(TARGETS mfast_coder + EXPORT mFASTTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) + + SET(MFAST_DYNAMIC_COMPONENTS ${MFAST_DYNAMIC_COMPONENTS} coder CACHE INTERNAL "") +--- a/src/mfast/json/CMakeLists.txt ++++ b/src/mfast/json/CMakeLists.txt +@@ -9,6 +9,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + set(mfast_json_SRCS ${sources} ${headers}) + + add_library(mfast_json_static STATIC ${mfast_json_SRCS}) ++target_link_libraries(mfast_json_static mfast_static Boost::headers) + + if (UNIX) + set_target_properties(mfast_json_static PROPERTIES OUTPUT_NAME mfast_json) +@@ -32,12 +33,13 @@ if (BUILD_SHARED_LIBS) + if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) + set_target_properties(mfast_json PROPERTIES COMPILE_FLAGS -fvisibility=hidden) + endif() +- target_link_libraries(mfast_json mfast) ++ target_link_libraries(mfast_json mfast Boost::headers) + set_target_properties(mfast_json PROPERTIES COMPILE_FLAGS -DMFAST_DYN_LINK) + + install(TARGETS mfast_json + EXPORT mFASTTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) + + SET(MFAST_DYNAMIC_COMPONENTS ${MFAST_DYNAMIC_COMPONENTS} json CACHE INTERNAL "") +--- a/src/mfast/sqlite3/CMakeLists.txt ++++ b/src/mfast/sqlite3/CMakeLists.txt +@@ -6,6 +6,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + set(mfast_sqlite3_SRCS ${sources} ${headers}) + + add_library(mfast_sqlite3_static STATIC ${mfast_sqlite3_SRCS}) ++target_link_libraries(mfast_sqlite3_static mfast_static Boost::headers SQLite::SQLite3) + + if (UNIX) + set_target_properties(mfast_sqlite3_static PROPERTIES OUTPUT_NAME mfast_sqlite3) +@@ -30,13 +31,14 @@ if (BUILD_SHARED_LIBS) + if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) + set_target_properties(mfast_sqlite3 PROPERTIES COMPILE_FLAGS -fvisibility=hidden) + endif() +- target_link_libraries(mfast_sqlite3 mfast sqlite3) ++ target_link_libraries(mfast_sqlite3 mfast Boost::headers SQLite::SQLite3) + set_target_properties(mfast_sqlite3 PROPERTIES COMPILE_FLAGS -DMFAST_DYN_LINK) + + + install(TARGETS mfast_sqlite3 + EXPORT mFASTTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + OPTIONAL) + +--- a/src/mfast/xml_parser/CMakeLists.txt ++++ b/src/mfast/xml_parser/CMakeLists.txt +@@ -6,11 +6,11 @@ file (GLOB_RECURSE sources "*.cpp") ## retrieve all source files in current + + SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + +-include_directories("${CMAKE_SOURCE_DIR}/tinyxml2") + +-set(mfast_xml_parser_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../../../tinyxml2/tinyxml2.cpp ${sources} ${headers}) ++set(mfast_xml_parser_SRCS ${sources} ${headers}) + + add_library(mfast_xml_parser_static STATIC ${mfast_xml_parser_SRCS}) ++target_link_libraries(mfast_xml_parser_static mfast_static Boost::headers tinyxml2::tinyxml2) + + if (UNIX) + set_target_properties(mfast_xml_parser_static PROPERTIES OUTPUT_NAME mfast_xml_parser) +@@ -34,13 +34,14 @@ if (BUILD_SHARED_LIBS) + if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) + set_target_properties(mfast_xml_parser PROPERTIES COMPILE_FLAGS -fvisibility=hidden) + endif() +- target_link_libraries(mfast_xml_parser mfast) ++ target_link_libraries(mfast_xml_parser mfast Boost::headers tinyxml2::tinyxml2) + set_target_properties(mfast_xml_parser PROPERTIES COMPILE_FLAGS -DMFAST_DYN_LINK) + + + install(TARGETS mfast_xml_parser + EXPORT mFASTTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) + + SET(MFAST_DYNAMIC_COMPONENTS ${MFAST_DYNAMIC_COMPONENTS} coder CACHE INTERNAL "") diff --git a/recipes/mfast/all/patches/0001-fix-cmake-1.2.2.patch b/recipes/mfast/all/patches/0001-fix-cmake-1.2.2.patch new file mode 100644 index 0000000000000..5a64dc0bef36a --- /dev/null +++ b/recipes/mfast/all/patches/0001-fix-cmake-1.2.2.patch @@ -0,0 +1,194 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -60,9 +60,11 @@ if(BUILD_PACKAGES) + + endif(BUILD_PACKAGES) + +-find_package(Boost 1.56.0 REQUIRED) +-include_directories(${Boost_INCLUDE_DIR}) +-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tinyxml2) ++find_package(Boost REQUIRED) ++find_package(tinyxml2 REQUIRED CONFIG) ++if(BUILD_SQLITE3) ++ find_package(SQLite3 REQUIRED) ++endif() + include_directories ("${PROJECT_SOURCE_DIR}/src") + + add_definitions(-DSIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}) +@@ -73,7 +75,6 @@ set(MFAST_STATIC_LIBRARIES CACHE INTERNAL "") + set(MFAST_DYNAMIC_COMPONENTS CACHE INTERNAL "") + set(MFAST_STATIC_COMPONENTS CACHE INTERNAL "") + +-set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + + add_subdirectory (src) + include(FastTypeGenTarget) +--- a/src/fast_type_gen/CMakeLists.txt ++++ b/src/fast_type_gen/CMakeLists.txt +@@ -1,5 +1,5 @@ + +-if (NOT CMAKE_CROSSCOMPILING) ++if (1) + set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + add_executable (fast_type_gen + fast_type_gen.cpp +@@ -11,13 +11,14 @@ if (NOT CMAKE_CROSSCOMPILING) + target_link_libraries (fast_type_gen + mfast_xml_parser_static + mfast_static ++ Boost::headers + mfast_coder_static) + + set_target_properties(fast_type_gen PROPERTIES VERSION "${MFAST_VERSION}") + + install(TARGETS fast_type_gen + EXPORT mFASTTargets +- RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin) ++ DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin) + add_custom_target(install.fast_type_gen + COMMAND ${CMAKE_COMMAND} -DBUILD_TYPE=${CMAKE_BUILD_TYPE} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake + DEPENDS fast_type_gen) +--- a/src/mfast/CMakeLists.txt ++++ b/src/mfast/CMakeLists.txt +@@ -11,6 +11,7 @@ set(mfast_SRCS ${sources} ${instruction_sources} ${headers} ${instruction_heade + + add_library(mfast_static STATIC ${mfast_SRCS}) + target_include_directories(mfast_static PUBLIC $) ++target_link_libraries(mfast_static Boost::headers) + + if (UNIX) + set_target_properties(mfast_static PROPERTIES OUTPUT_NAME mfast) +@@ -27,6 +28,7 @@ set(MFAST_STATIC_LIBRARIES ${MFAST_STATIC_LIBRARIES} mfast_static CACHE INTERNAL + + if (BUILD_SHARED_LIBS) + add_library(mfast SHARED ${mfast_SRCS}) ++ target_link_libraries(mfast Boost::headers) + + if (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.12") + target_compile_definitions(mfast INTERFACE "-DMFAST_DYN_LINK") +@@ -42,6 +44,7 @@ if (BUILD_SHARED_LIBS) + install(TARGETS mfast + EXPORT mFASTTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) + + set(MFAST_SHARED_LIBRARIES ${MFAST_SHARED_LIBRARIES} mfast CACHE INTERNAL "") +--- a/src/mfast/coder/CMakeLists.txt ++++ b/src/mfast/coder/CMakeLists.txt +@@ -18,7 +18,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + set(mfast_coder_SRCS ${sources} ${headers}) + + add_library(mfast_coder_static STATIC ${mfast_coder_SRCS}) +-target_link_libraries(mfast_coder_static mfast_static) ++target_link_libraries(mfast_coder_static mfast_static Boost::headers) + + if (UNIX) + set_target_properties(mfast_coder_static PROPERTIES OUTPUT_NAME mfast_coder) +@@ -44,7 +44,7 @@ if (BUILD_SHARED_LIBS) + if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) + set_target_properties(mfast_coder PROPERTIES COMPILE_FLAGS -fvisibility=hidden) + endif() +- target_link_libraries(mfast_coder mfast) ++ target_link_libraries(mfast_coder mfast Boost::headers) + set_target_properties(mfast_coder PROPERTIES + VERSION "${MFAST_VERSION}" + SOVERSION "${MFAST_SOVERSION}") +@@ -55,6 +55,7 @@ if (BUILD_SHARED_LIBS) + install(TARGETS mfast_coder + EXPORT mFASTTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) + + set(MFAST_SHARED_LIBRARIES ${MFAST_SHARED_LIBRARIES} mfast_coder CACHE INTERNAL "") +--- a/src/mfast/json/CMakeLists.txt ++++ b/src/mfast/json/CMakeLists.txt +@@ -9,7 +9,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + set(mfast_json_SRCS ${sources} ${headers}) + + add_library(mfast_json_static STATIC ${mfast_json_SRCS}) +-target_link_libraries(mfast_json_static mfast_static) ++target_link_libraries(mfast_json_static mfast_static Boost::headers) + + if (UNIX) + set_target_properties(mfast_json_static PROPERTIES OUTPUT_NAME mfast_json) +@@ -35,7 +35,7 @@ if (BUILD_SHARED_LIBS) + if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) + set_target_properties(mfast_json PROPERTIES COMPILE_FLAGS -fvisibility=hidden) + endif() +- target_link_libraries(mfast_json mfast) ++ target_link_libraries(mfast_json mfast Boost::headers) + set_target_properties(mfast_json PROPERTIES + VERSION "${MFAST_VERSION}" + SOVERSION "${MFAST_SOVERSION}") +@@ -46,6 +46,7 @@ if (BUILD_SHARED_LIBS) + install(TARGETS mfast_json + EXPORT mFASTTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) + + set(MFAST_SHARED_LIBRARIES ${MFAST_SHARED_LIBRARIES} mfast_json CACHE INTERNAL "") +--- a/src/mfast/sqlite3/CMakeLists.txt ++++ b/src/mfast/sqlite3/CMakeLists.txt +@@ -6,7 +6,7 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + set(mfast_sqlite3_SRCS ${sources} ${headers}) + + add_library(mfast_sqlite3_static STATIC ${mfast_sqlite3_SRCS}) +-target_link_libraries(mfast_sqlite3_static mfast_static) ++target_link_libraries(mfast_sqlite3_static mfast_static Boost::headers SQLite::SQLite3) + + if (UNIX) + set_target_properties(mfast_sqlite3_static PROPERTIES OUTPUT_NAME mfast_sqlite3) +@@ -33,7 +33,7 @@ if (BUILD_SHARED_LIBS) + if (CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) + set_target_properties(mfast_sqlite3 PROPERTIES COMPILE_FLAGS -fvisibility=hidden) + endif() +- target_link_libraries(mfast_sqlite3 mfast sqlite3) ++ target_link_libraries(mfast_sqlite3 mfast Boost::headers SQLite::SQLite3) + set_target_properties(mfast_sqlite3 PROPERTIES + VERSION "${MFAST_VERSION}" + SOVERSION "${MFAST_SOVERSION}") +@@ -44,6 +44,7 @@ if (BUILD_SHARED_LIBS) + install(TARGETS mfast_sqlite3 + EXPORT mFASTTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + OPTIONAL) + +--- a/src/mfast/xml_parser/CMakeLists.txt ++++ b/src/mfast/xml_parser/CMakeLists.txt +@@ -6,12 +6,11 @@ file (GLOB_RECURSE sources "*.cpp") ## retrieve all source files in current + + set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + +-include_directories("${CMAKE_SOURCE_DIR}/tinyxml2") + +-set(mfast_xml_parser_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../../../tinyxml2/tinyxml2.cpp ${sources} ${headers}) ++set(mfast_xml_parser_SRCS ${sources} ${headers}) + + add_library(mfast_xml_parser_static STATIC ${mfast_xml_parser_SRCS}) +-target_link_libraries(mfast_xml_parser_static mfast_static) ++target_link_libraries(mfast_xml_parser_static mfast_static Boost::headers tinyxml2::tinyxml2) + + if (UNIX) + set_target_properties(mfast_xml_parser_static PROPERTIES OUTPUT_NAME mfast_xml_parser) +@@ -39,7 +38,7 @@ if (BUILD_SHARED_LIBS) + set_target_properties(mfast_xml_parser PROPERTIES COMPILE_FLAGS -fvisibility=hidden) + endif() + +- target_link_libraries(mfast_xml_parser mfast) ++ target_link_libraries(mfast_xml_parser mfast Boost::headers tinyxml2::tinyxml2) + set_target_properties(mfast_xml_parser PROPERTIES + LINKER_LANGUAGE CXX + VERSION "${MFAST_VERSION}" +@@ -51,6 +50,7 @@ if (BUILD_SHARED_LIBS) + install(TARGETS mfast_xml_parser + EXPORT mFASTTargets + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin ++ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib) + + set(MFAST_SHARED_LIBRARIES ${MFAST_SHARED_LIBRARIES} mfast_xml_parser CACHE INTERNAL "") diff --git a/recipes/mfast/all/patches/00003-remove-deprecated-boost-detail-endian.patch b/recipes/mfast/all/patches/0002-remove-deprecated-boost-detail-endian.patch similarity index 100% rename from recipes/mfast/all/patches/00003-remove-deprecated-boost-detail-endian.patch rename to recipes/mfast/all/patches/0002-remove-deprecated-boost-detail-endian.patch diff --git a/recipes/mfast/all/patches/0003-mfast-sqlite3.patch b/recipes/mfast/all/patches/0003-mfast-sqlite3.patch new file mode 100644 index 0000000000000..3b18dcad401c7 --- /dev/null +++ b/recipes/mfast/all/patches/0003-mfast-sqlite3.patch @@ -0,0 +1,22 @@ +--- a/src/mfast/sqlite3/aggregate_inserter.cpp ++++ b/src/mfast/sqlite3/aggregate_inserter.cpp +@@ -35,7 +35,7 @@ namespace mfast + if (primary_key.present()) + return primary_key; + else { +- static const int64_field_instruction rowid_instruction(0,operator_none,presence_optional,0,"","",0, int_value_storage()); ++ static const int64_field_instruction rowid_instruction(operator_none,presence_optional,0,"","",0, int_value_storage()); + field_cref rowid_cref(&this->storage_, &rowid_instruction); + this->storage_.set(rowid); + this->storage_.present(true); +--- a/src/mfast/sqlite3/third_pass_visitor.cpp ++++ b/src/mfast/sqlite3/third_pass_visitor.cpp +@@ -12,7 +12,7 @@ namespace mfast + + if (primary_key_.absent()) { + // the table has no primary key, use the last rowid instead +- static const int64_field_instruction rowid_instruction(0,operator_none,presence_optional,0,"","",0, int_value_storage()); ++ static const int64_field_instruction rowid_instruction(operator_none,presence_optional,0,"","",0, int_value_storage()); + + field_cref rowid_cref(&this->key_storage_, &rowid_instruction); + this->key_storage_.set(rowid); diff --git a/recipes/mfast/all/test_package/CMakeLists.txt b/recipes/mfast/all/test_package/CMakeLists.txt index 34db22d731bcf..d997066619922 100644 --- a/recipes/mfast/all/test_package/CMakeLists.txt +++ b/recipes/mfast/all/test_package/CMakeLists.txt @@ -9,8 +9,8 @@ find_package(mFAST REQUIRED mfast_xml_parser CONFIG) FASTTYPEGEN_TARGET(Test Test.xml) add_executable(${PROJECT_NAME} ${FASTTYPEGEN_Test_OUTPUTS} message_printer.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) -if(MFAST_SHARED) - target_link_libraries(${PROJECT_NAME} mfast_xml_parser) -else() +if(TARGET mfast_xml_parser_static) target_link_libraries(${PROJECT_NAME} mfast_xml_parser_static) +else() + target_link_libraries(${PROJECT_NAME} mfast_xml_parser) endif() diff --git a/recipes/mfast/all/test_package/conanfile.py b/recipes/mfast/all/test_package/conanfile.py index ebc15a90a34d5..3aa69bfc84c8f 100644 --- a/recipes/mfast/all/test_package/conanfile.py +++ b/recipes/mfast/all/test_package/conanfile.py @@ -1,15 +1,17 @@ -import os - from conans import ConanFile, CMake, tools +import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" + def build_requirements(self): + if hasattr(self, "settings_build") and tools.cross_building(self): + self.build_requires(str(self.requires["mfast"])) + def build(self): cmake = CMake(self) - cmake.definitions["MFAST_SHARED"] = self.options["mfast"].shared cmake.configure() cmake.build() diff --git a/recipes/mfast/config.yml b/recipes/mfast/config.yml index 9a3926fc95b9e..af216ac4b02b7 100644 --- a/recipes/mfast/config.yml +++ b/recipes/mfast/config.yml @@ -1,5 +1,5 @@ versions: - "1.2.1": + "1.2.2": folder: all - "cci.20200824": + "1.2.1": folder: all diff --git a/recipes/mgs/all/conandata.yml b/recipes/mgs/all/conandata.yml index 34942aeea4642..c3099b0d8bf72 100644 --- a/recipes/mgs/all/conandata.yml +++ b/recipes/mgs/all/conandata.yml @@ -2,3 +2,12 @@ sources: 0.1.2: url: https://github.com/theodelrieu/mgs/releases/download/v0.1.2/mgs.zip sha256: aba95870eafad95147c969c167a0e7c09b2c749ccafadbdd477de815e3e5bfd3 + 0.1.4: + url: https://github.com/theodelrieu/mgs/releases/download/v0.1.4/mgs.zip + sha256: e247976860a0c8d237caaf62a918627f59d4f8a5b5bb811ab01e7cbecf31d4ce + 0.1.5: + url: https://github.com/theodelrieu/mgs/releases/download/v0.1.5/mgs.zip + sha256: ca00e5d26be18beac9874270c17bddbc4f96cad6d92aab685c9eb4be0e6d7fc7 + 0.2.0: + url: https://github.com/theodelrieu/mgs/releases/download/v0.2.0/mgs.zip + sha256: aa057a4096da9451bef1950a3e784350df590f09f6bad0c0ca59ed1874df4a36 diff --git a/recipes/mgs/config.yml b/recipes/mgs/config.yml index b3c71bd313abc..f61776783a322 100644 --- a/recipes/mgs/config.yml +++ b/recipes/mgs/config.yml @@ -1,3 +1,9 @@ versions: "0.1.2": folder: all + "0.1.4": + folder: all + "0.1.5": + folder: all + "0.2.0": + folder: all diff --git a/recipes/microprofile/all/CMakeLists.txt b/recipes/microprofile/all/CMakeLists.txt new file mode 100644 index 0000000000000..ff45b79a8420c --- /dev/null +++ b/recipes/microprofile/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.10) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory("source_subfolder") diff --git a/recipes/microprofile/all/conandata.yml b/recipes/microprofile/all/conandata.yml new file mode 100644 index 0000000000000..6715d7fabbe05 --- /dev/null +++ b/recipes/microprofile/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "3.1": + - url: "https://github.com/jonasmr/microprofile/archive/refs/tags/v3.1.tar.gz" + sha256: "300e1d0d21e4c13ad1de72c5309ba02fbdb3bcbbe26e5ad9ff8b798380781527" + - url: "https://unlicense.org/UNLICENSE" + sha256: "7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c" +patches: + "3.1": + - patch_file: "patches/sources_fix.patch" + base_path: "source_subfolder" + - patch_file: "patches/cmake.patch" + base_path: "source_subfolder" diff --git a/recipes/microprofile/all/conanfile.py b/recipes/microprofile/all/conanfile.py new file mode 100644 index 0000000000000..9f23e3872db58 --- /dev/null +++ b/recipes/microprofile/all/conanfile.py @@ -0,0 +1,203 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + + +class MicroprofileConan(ConanFile): + name = "microprofile" + license = "Unlicense" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/jonasmr/microprofile" + description = "Microprofile is a embeddable profiler in a few files, written in C++" + topics = ("profiler", "embedded", "timer") + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake" + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "microprofile_enabled": [True, False], + "with_miniz": [True, False], + "thread_buffer_size": "ANY", + "thread_gpu_buffer_size": "ANY", + "max_frame_history": "ANY", + "webserver_port": "ANY", + "webserver_maxframes": "ANY", + "webserver_socket_buffer_size": "ANY", + "gpu_frame_delay": "ANY", + "name_max_length": "ANY", + "max_timers": "ANY", + "max_threads": "ANY", + "max_string_length": "ANY", + "timeline_max_tokens": "ANY", + "thread_log_frames_reuse": "ANY", + "max_groups": "ANY", + "use_big_endian": [True, False], + "enable_gpu_timer_callbacks": [True, False], + "enable_timer": [None, "gl", "d3d11", "d3d12", "vulkan"] + } + default_options = { + "shared": False, + "fPIC": True, + "microprofile_enabled": True, + "with_miniz": False, + "thread_buffer_size": 2048 << 10, + "thread_gpu_buffer_size": 128 << 10, + "max_frame_history": 512, + "webserver_port": 1338, + "webserver_maxframes": 30, + "webserver_socket_buffer_size": 16 << 10, + "gpu_frame_delay": 5, + "name_max_length": 64, + "max_timers": 1024, + "max_threads": 32, + "max_string_length": 128, + "timeline_max_tokens": 64, + "thread_log_frames_reuse": 200, + "max_groups": 128, + "use_big_endian": False, + "enable_gpu_timer_callbacks": False, + "enable_timer": None + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def _validate_int_options(self): + positive_int_options = [ + "thread_buffer_size", + "thread_gpu_buffer_size", + "max_frame_history", + "webserver_port", + "webserver_maxframes", + "webserver_socket_buffer_size", + "gpu_frame_delay", + "name_max_length", + "max_timers", + "max_threads", + "max_string_length", + "timeline_max_tokens", + "thread_log_frames_reuse", + "max_groups" + ] + for opt in positive_int_options: + try: + value = int(getattr(self.options, opt)) + if value < 0: + raise ValueError + except ValueError: + raise ConanInvalidConfiguration("microprofile:{} must be a positive integer".format(opt)) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + if self.settings.os != "Windows" and self.options.enable_timer in ["d3d11", "d3d12"]: + raise ConanInvalidConfiguration("DirectX timers can only be used in Windows.") + if self.options.enable_timer and self.options.enable_gpu_timer_callbacks: + raise ConanInvalidConfiguration("Cannot mix GPU callbacks and GPU timers.") + + self._validate_int_options() + + if int(self.options.max_groups) % 32 != 0: + raise ConanInvalidConfiguration("microprofile:max_groups must be multiple of 32.") + if int(self.options.webserver_port) > 2 ** 16 - 1: + raise ConanInvalidConfiguration("microprofile:webserver_port must be between 0 and 65535.") + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.options.with_miniz: + self.requires("miniz/2.2.0") + if self.options.enable_timer == "gl": + self.requires("opengl/system") + if self.options.enable_timer == "vulkan": + self.requires("vulkan-loader/1.2.182") + + def source(self): + tools.get(**self.conan_data["sources"][self.version][0], strip_root=True, destination=self._source_subfolder) + tools.download(filename="LICENSE", **self.conan_data["sources"][self.version][1]) + + def build(self): + self._create_defines_file(os.path.join(self._source_subfolder, "microprofile.config.h")) + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["MP_MINIZ"] = self.options.with_miniz + self._cmake.definitions["MP_GPU_TIMERS_VULKAN"] = self.options.enable_timer == "vulkan" + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE", dst="licenses") + cmake = self._configure_cmake() + cmake.install() + + def _create_defines(self): + return [ + "MICROPROFILE_EXPORT", + ("MICROPROFILE_ENABLED", ("1" if self.options.microprofile_enabled else "0")), + ("MICROPROFILE_DEBUG", ("1" if self.settings.build_type == "Debug" else "0")), + ("MICROPROFILE_MINIZ", ("1" if self.options.with_miniz else "0")), + ("MICROPROFILE_BIG_ENDIAN", ("1" if self.options.use_big_endian else "0")), + ("MICROPROFILE_GPU_TIMERS", ("1" if self.options.enable_timer else "0")), + ("MICROPROFILE_GPU_TIMER_CALLBACKS", ("1" if self.options.enable_gpu_timer_callbacks else "0")), + ("MICROPROFILE_GPU_TIMERS_GL", ("1" if self.options.enable_timer == "gl" else "0")), + ("MICROPROFILE_GPU_TIMERS_D3D11", ("1" if self.options.enable_timer == "d3d11" else "0")), + ("MICROPROFILE_GPU_TIMERS_D3D12", ("1" if self.options.enable_timer == "d3d12" else "0")), + ("MICROPROFILE_GPU_TIMERS_VULKAN", ("1" if self.options.enable_timer == "vulkan" else "0")), + ("MICROPROFILE_PER_THREAD_BUFFER_SIZE", str(self.options.thread_buffer_size)), + ("MICROPROFILE_PER_THREAD_GPU_BUFFER_SIZE", str(self.options.thread_gpu_buffer_size)), + ("MICROPROFILE_MAX_FRAME_HISTORY", str(self.options.max_frame_history)), + ("MICROPROFILE_WEBSERVER_PORT", str(self.options.webserver_port)), + ("MICROPROFILE_WEBSERVER_MAXFRAMES", str(self.options.webserver_maxframes)), + ("MICROPROFILE_WEBSERVER_SOCKET_BUFFER_SIZE", str(self.options.webserver_socket_buffer_size)), + ("MICROPROFILE_GPU_FRAME_DELAY", str(self.options.gpu_frame_delay)), + ("MICROPROFILE_NAME_MAX_LEN", str(self.options.name_max_length)), + ("MICROPROFILE_MAX_TIMERS", str(self.options.max_timers)), + ("MICROPROFILE_MAX_THREADS", str(self.options.max_threads)), + ("MICROPROFILE_MAX_STRING", str(self.options.max_string_length)), + ("MICROPROFILE_TIMELINE_MAX_TOKENS", str(self.options.timeline_max_tokens)), + ("MICROPROFILE_THREAD_LOG_FRAMES_REUSE", str(self.options.thread_log_frames_reuse)), + ("MICROPROFILE_MAX_GROUPS", str(self.options.max_groups)) + ] + + def _create_defines_file(self, filename): + defines = self._create_defines() + defines_list = ["#pragma once\n"] + for define in defines: + if isinstance(define, tuple) or isinstance(define, list): + defines_list.append("#define {} {}\n".format(define[0], define[1])) + else: + defines_list.append("#define {}\n".format(define)) + tools.save(filename, "".join(defines_list)) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.names["cmake_find_package"] = self.name + self.cpp_info.names["cmake_find_package_multi"] = self.name + if self.settings.os == "Windows": + self.cpp_info.system_libs = ["ws2_32"] + elif self.settings.os == "Linux": + self.cpp_info.system_libs = ["pthread"] + self.cpp_info.defines.append("MICROPROFILE_USE_CONFIG") diff --git a/recipes/microprofile/all/patches/cmake.patch b/recipes/microprofile/all/patches/cmake.patch new file mode 100644 index 0000000000000..b92ba025b0a43 --- /dev/null +++ b/recipes/microprofile/all/patches/cmake.patch @@ -0,0 +1,67 @@ +--- /dev/null ++++ b/CMakeLists.txt +@@ -0,0 +1,64 @@ ++cmake_minimum_required(VERSION 3.4) ++project(microprofile) ++ ++option(MICROPROFILE_USE_CONFIG_FILE "Use user provided configuration in microprofile.config.h file." ON) ++ ++set(MICROPROFILE_EXPORT_FILENAME microprofile.export.h) ++set(MICROPROFILE_CONFIG_HEADER ${PROJECT_SOURCE_DIR}/microprofile.config.h) ++set(MICROPROFILE_PUBLIC_HEADERS ++ ${PROJECT_SOURCE_DIR}/microprofile.h ++ ${CMAKE_CURRENT_BINARY_DIR}/${MICROPROFILE_EXPORT_FILENAME} ++) ++ ++set(THREADS_PREFER_PTHREAD_FLAG ON) ++find_package(Threads REQUIRED) ++ ++add_library(${PROJECT_NAME} microprofile.h microprofile.cpp) ++ ++include(GenerateExportHeader) ++generate_export_header(${PROJECT_NAME} ++ EXPORT_MACRO_NAME MICROPROFILE_API ++ EXPORT_FILE_NAME ${MICROPROFILE_EXPORT_FILENAME} ++) ++ ++target_include_directories(${PROJECT_NAME} PUBLIC ++ $ ++ $ ++ $ ++) ++ ++if (MICROPROFILE_USE_CONFIG_FILE) ++ target_compile_definitions(${PROJECT_NAME} PUBLIC MICROPROFILE_USE_CONFIG) ++endif() ++ ++target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) ++ ++target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) ++ ++if (WIN32) ++ target_link_libraries(${PROJECT_NAME} PRIVATE ws2_32) ++endif() ++ ++if (MP_MINIZ) ++ target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::miniz) ++endif() ++ ++if (MP_GPU_TIMERS_VULKAN) ++ target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::vulkan-loader) ++endif() ++ ++set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${MICROPROFILE_PUBLIC_HEADERS}") ++ ++include(GNUInstallDirs) ++install(TARGETS ${PROJECT_NAME} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} ++) ++if (MICROPROFILE_USE_CONFIG_FILE) ++ install(FILES ${MICROPROFILE_CONFIG_HEADER} ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} ++ PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ ++ ) ++endif() diff --git a/recipes/microprofile/all/patches/sources_fix.patch b/recipes/microprofile/all/patches/sources_fix.patch new file mode 100644 index 0000000000000..bf1a3fd85fae4 --- /dev/null +++ b/recipes/microprofile/all/patches/sources_fix.patch @@ -0,0 +1,135 @@ +--- a/microprofile.h ++++ b/microprofile.h +@@ -179,6 +179,7 @@ + #define MicroProfileGpuInitD3D11(pDevice,pDeviceContext) do{}while(0) + #define MicroProfileGpuShutdown() do{}while(0) + #define MicroProfileGpuInitGL() do{}while(0) ++#define MicroProfileInitGLCallbacks(cbs) do{}while(0) + #define MicroProfileSetCurrentNodeD3D12(nNode) do{}while(0) + #define MicroProfilePlatformMarkersGetEnabled() 0 + #define MicroProfilePlatformMarkersSetEnabled(bEnabled) do{}while(0) +@@ -192,9 +193,13 @@ + + #include + ++#ifdef MICROPROFILE_EXPORT ++#include "microprofile.export.h" ++#else + #ifndef MICROPROFILE_API + #define MICROPROFILE_API + #endif ++#endif + + #ifdef MICROPROFILE_PS4 + #include "microprofile_ps4.h" +@@ -481,6 +486,7 @@ + struct MicroProfile; + struct MicroProfileThreadLogGpu; + struct MicroProfileScopeStateC; ++struct MicroProfileGLCallbacks; + + #ifdef __cplusplus + extern "C" { +@@ -682,6 +688,7 @@ + #if MICROPROFILE_GPU_TIMERS_GL + #define MICROPROFILE_GL_MAX_QUERIES (8<<10) + MICROPROFILE_API void MicroProfileGpuInitGL(); ++MICROPROFILE_API void MicroProfileInitGLCallbacks(const MicroProfileGLCallbacks* cbs); + #endif + + +@@ -752,6 +759,16 @@ + } + } + }; ++ ++#include ++struct MicroProfileGLCallbacks ++{ ++ std::function genQueriesCb; ++ std::function deleteQueriesCb; ++ std::function queryCounterCb; ++ std::function getQueryObject64Cb; ++ std::function getInteger64Cb; ++}; + #endif //__cplusplus + #endif //enabled + +--- a/microprofile.cpp ++++ b/microprofile.cpp +@@ -952,6 +952,7 @@ + int GpuQueue; + MicroProfileThreadLogGpu* pGpuGlobal; + MicroProfileGpuTimerState* pGPU; ++ MicroProfileGLCallbacks glCallbacks; + + }; + +@@ -4835,6 +4836,7 @@ + } + + #if MICROPROFILE_MINIZ ++#include + #ifndef MICROPROFILE_COMPRESS_BUFFER_SIZE + #define MICROPROFILE_COMPRESS_BUFFER_SIZE (256<<10) + #endif +@@ -8711,29 +8713,37 @@ + vkQueueSubmit(S.pGPU->Queues[nGpu], 1, &SubmitInfo, Fence); + vkWaitForFences(Device, 1, &Fence, 1, (uint64_t)-1); + *pOutGpu = 0; +- vkGetQueryPoolResults(Device, S.pGPU->QueryPool[nGpu], MICROPROFILE_VULKAN_MAX_QUERIES, 1, 8, pOutGpu, 8, VK_QUERY_RESULT_64_BIT); ++ vkGetQueryPoolResults(Device, S.pGPU->QueryPool[nGpu], MICROPROFILE_VULKAN_MAX_QUERIES, 1, 8, pOutGpu, 8, VK_QUERY_RESULT_64_BIT); + *pOutCPU = MP_TICK(); + return 1; + } + #elif MICROPROFILE_GPU_TIMERS_GL ++#define GL_TIMESTAMP 0x8E28 ++#define GL_QUERY_RESULT 0x8866 ++ ++void MicroProfileInitGLCallbacks(const MicroProfileGLCallbacks* cbs) ++{ ++ S.glCallbacks = *cbs; ++} ++ + void MicroProfileGpuInitGL() + { + S.pGPU = MP_ALLOC_OBJECT(MicroProfileGpuTimerState); + S.pGPU->GLTimerPos = 0; +- glGenQueries(MICROPROFILE_GL_MAX_QUERIES, &S.pGPU->GLTimers[0]); ++ S.glCallbacks.genQueriesCb(MICROPROFILE_GL_MAX_QUERIES, &S.pGPU->GLTimers[0]); + } + + uint32_t MicroProfileGpuInsertTimeStamp(void* pContext) + { + uint32_t nIndex = (S.pGPU->GLTimerPos+1)%MICROPROFILE_GL_MAX_QUERIES; +- glQueryCounter(S.pGPU->GLTimers[nIndex], GL_TIMESTAMP); ++ S.glCallbacks.queryCounterCb(S.pGPU->GLTimers[nIndex], GL_TIMESTAMP); + S.pGPU->GLTimerPos = nIndex; + return nIndex; + } + uint64_t MicroProfileGpuGetTimeStamp(uint32_t nKey) + { + uint64_t result; +- glGetQueryObjectui64v(S.pGPU->GLTimers[nKey], GL_QUERY_RESULT, &result); ++ S.glCallbacks.getQueryObject64Cb(S.pGPU->GLTimers[nKey], GL_QUERY_RESULT, &result); + return result; + } + +@@ -8745,7 +8755,7 @@ + int MicroProfileGetGpuTickReference(int64_t* pOutCpu, int64_t* pOutGpu) + { + int64_t nGpuTimeStamp; +- glGetInteger64v(GL_TIMESTAMP, &nGpuTimeStamp); ++ S.glCallbacks.getInteger64Cb(GL_TIMESTAMP, &nGpuTimeStamp); + if(nGpuTimeStamp) + { + *pOutCpu = MP_TICK(); +@@ -8785,7 +8795,7 @@ + + void MicroProfileGpuShutdown() + { +- glDeleteQueries(MICROPROFILE_GL_MAX_QUERIES, &S.pGPU->GLTimers[0]); ++ S.glCallbacks.deleteQueriesCb(MICROPROFILE_GL_MAX_QUERIES, &S.pGPU->GLTimers[0]); + MP_FREE(S.pGPU); + } + diff --git a/recipes/microprofile/all/test_package/CMakeLists.txt b/recipes/microprofile/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ed091dc6c1aee --- /dev/null +++ b/recipes/microprofile/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.10) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(microprofile REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} microprofile::microprofile) + +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/microprofile/all/test_package/conanfile.py b/recipes/microprofile/all/test_package/conanfile.py new file mode 100644 index 0000000000000..30f8c8cfb0975 --- /dev/null +++ b/recipes/microprofile/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +class MicroprofileTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/microprofile/all/test_package/test_package.cpp b/recipes/microprofile/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2a13e33f9ca1d --- /dev/null +++ b/recipes/microprofile/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include + +#include + +int main() { +#if MICROPROFILE_ENABLED + MicroProfileInit(); + std::cout << "Microprofile successfully initialized." << std::endl; +#endif + std::cout << "Tick = " << MicroProfileTick() << std::endl; + return 0; +} diff --git a/recipes/microprofile/config.yml b/recipes/microprofile/config.yml new file mode 100644 index 0000000000000..992d10eb37c11 --- /dev/null +++ b/recipes/microprofile/config.yml @@ -0,0 +1,3 @@ +versions: + "3.1": + folder: all diff --git a/recipes/microtar/all/CMakeLists.txt b/recipes/microtar/all/CMakeLists.txt new file mode 100644 index 0000000000000..ab2ce85f21a44 --- /dev/null +++ b/recipes/microtar/all/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.4) +project(microtar LANGUAGES C) + +include(GNUInstallDirs) + +add_library(microtar ${MICROTAR_SRC_DIR}/src/microtar.c) +set_target_properties(microtar PROPERTIES + PUBLIC_HEADER "${MICROTAR_SRC_DIR}/src/microtar.h" + WINDOWS_EXPORT_ALL_SYMBOLS ON +) + +install( + TARGETS microtar + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) diff --git a/recipes/microtar/all/conandata.yml b/recipes/microtar/all/conandata.yml new file mode 100644 index 0000000000000..1661e9ce105e7 --- /dev/null +++ b/recipes/microtar/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.1.0": + url: "https://github.com/rxi/microtar/archive/refs/tags/v0.1.0.tar.gz" + sha256: "eb30a906d714c6547841d67f8d49739c56dd8a506fda4c61dd7d6f4da0a9d9aa" diff --git a/recipes/microtar/all/conanfile.py b/recipes/microtar/all/conanfile.py new file mode 100644 index 0000000000000..0cac3914af1fe --- /dev/null +++ b/recipes/microtar/all/conanfile.py @@ -0,0 +1,62 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.53.0" + + +class MicrotarConan(ConanFile): + name = "microtar" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/rxi/microtar" + description = "A lightweight tar library written in ANSI C" + topics = ("tar", "archive") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MICROTAR_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["microtar"] diff --git a/recipes/microtar/all/test_package/CMakeLists.txt b/recipes/microtar/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b1c35c594fadb --- /dev/null +++ b/recipes/microtar/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(microtar REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE microtar::microtar) diff --git a/recipes/microtar/all/test_package/conanfile.py b/recipes/microtar/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/microtar/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/microtar/all/test_package/test_package.c b/recipes/microtar/all/test_package/test_package.c new file mode 100644 index 0000000000000..769145bab7171 --- /dev/null +++ b/recipes/microtar/all/test_package/test_package.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +int main() +{ + mtar_t tar; + const char *str1 = "Hello world"; + const char *str2 = "Goodbye world"; + + /* Open archive for writing */ + mtar_open(&tar, "test.tar", "w"); + + /* Write strings to files `test1.txt` and `test2.txt` */ + mtar_write_file_header(&tar, "test1.txt", strlen(str1)); + mtar_write_data(&tar, str1, strlen(str1)); + mtar_write_file_header(&tar, "test2.txt", strlen(str2)); + mtar_write_data(&tar, str2, strlen(str2)); + + /* Finalize -- this needs to be the last thing done before closing */ + mtar_finalize(&tar); + + /* Close archive */ + mtar_close(&tar); +} diff --git a/recipes/microtar/all/test_v1_package/CMakeLists.txt b/recipes/microtar/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/microtar/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/microtar/all/test_v1_package/conanfile.py b/recipes/microtar/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/microtar/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/microtar/config.yml b/recipes/microtar/config.yml new file mode 100644 index 0000000000000..5e5e3d8a61814 --- /dev/null +++ b/recipes/microtar/config.yml @@ -0,0 +1,3 @@ +versions: + "0.1.0": + folder: "all" diff --git a/recipes/mikktspace/all/CMakeLists.txt b/recipes/mikktspace/all/CMakeLists.txt index 3eb15462a684a..d8848832b7e30 100644 --- a/recipes/mikktspace/all/CMakeLists.txt +++ b/recipes/mikktspace/all/CMakeLists.txt @@ -1,22 +1,20 @@ cmake_minimum_required(VERSION 3.4) -project(mikktspace) +project(mikktspace LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +add_library(mikktspace ${MIKKTSPACE_SRC_DIR}/mikktspace.c) +target_include_directories(mikktspace PUBLIC ${MIKKTSPACE_SRC_DIR}) +set_target_properties(mikktspace PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) -if(WIN32 AND BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - -add_library(mikktspace ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/mikktspace.c) -target_include_directories(mikktspace PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) -if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") +include(CheckFunctionExists) +check_function_exists(pow HAVE_MATH_SYSTEM) +if(NOT HAVE_MATH_SYSTEM) target_link_libraries(mikktspace PRIVATE m) endif() +include(GNUInstallDirs) install(TARGETS mikktspace RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/mikktspace.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${MIKKTSPACE_SRC_DIR}/mikktspace.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/mikktspace/all/conanfile.py b/recipes/mikktspace/all/conanfile.py index 13838e6596dd4..ebe053f1cb1f9 100644 --- a/recipes/mikktspace/all/conanfile.py +++ b/recipes/mikktspace/all/conanfile.py @@ -1,6 +1,9 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import get, save import os -import glob -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.53.0" class MikkTSpaceConan(ConanFile): @@ -9,31 +12,19 @@ class MikkTSpaceConan(ConanFile): homepage = "https://github.com/mmikk/MikkTSpace" url = "https://github.com/conan-io/conan-center-index" license = "Zlib" - topics = ("conan", "tangent", "space", "normal") + topics = ("tangent", "space", "normal") settings = "os", "arch", "compiler", "build_type" options = { - "fPIC": [True, False], "shared": [True, False], + "fPIC": [True, False], } default_options = { + "shared": False, "fPIC": True, - "shared": False } - generators = "cmake" - exports_sources = ['CMakeLists.txt'] - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob('MikkTSpace-*/')[0] - os.rename(extracted_dir, self._source_subfolder) + exports_sources = "CMakeLists.txt" def config_options(self): if self.settings.os == "Windows": @@ -41,35 +32,41 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MIKKTSPACE_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() @property def _extracted_license(self): - content_lines = open(os.path.join(self.source_folder, self._source_subfolder, "mikktspace.h")).readlines() + content_lines = open(os.path.join(self.source_folder, "mikktspace.h")).readlines() license_content = [] for i in range(4, 21): license_content.append(content_lines[i][4:-1]) return "\n".join(license_content) def package(self): - tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), self._extracted_license) - cmake = self._configure_cmake() + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._extracted_license) + cmake = CMake(self) cmake.install() def package_info(self): self.cpp_info.libs = ["mikktspace"] - if self.settings.os == "Linux": + if not self.options.shared and self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] diff --git a/recipes/mikktspace/all/test_package/CMakeLists.txt b/recipes/mikktspace/all/test_package/CMakeLists.txt index bbb1d4b048d19..e098a7e87ec40 100644 --- a/recipes/mikktspace/all/test_package/CMakeLists.txt +++ b/recipes/mikktspace/all/test_package/CMakeLists.txt @@ -1,9 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) -target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) +find_package(mikktspace REQUIRED CONFIG) +add_executable(${CMAKE_PROJECT_NAME} test_package.c) +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE mikktspace::mikktspace) diff --git a/recipes/mikktspace/all/test_package/conanfile.py b/recipes/mikktspace/all/test_package/conanfile.py index ffc9be1e577c3..0a6bc68712d90 100644 --- a/recipes/mikktspace/all/test_package/conanfile.py +++ b/recipes/mikktspace/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package", "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,5 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mikktspace/all/test_package/test_package.c b/recipes/mikktspace/all/test_package/test_package.c new file mode 100644 index 0000000000000..b1fe82cf21c2a --- /dev/null +++ b/recipes/mikktspace/all/test_package/test_package.c @@ -0,0 +1,20 @@ +#include +#include + +static int GetNumFaces(const SMikkTSpaceContext *pContext) +{ + return 0; +} + +int main() +{ + SMikkTSpaceInterface sInterface = {NULL}; + sInterface.m_getNumFaces = GetNumFaces; + + SMikkTSpaceContext sContext = {NULL}; + sContext.m_pInterface = &sInterface; + + genTangSpaceDefault(&sContext); + + return 0; +} diff --git a/recipes/mikktspace/all/test_package/test_package.cpp b/recipes/mikktspace/all/test_package/test_package.cpp deleted file mode 100644 index 8e159e04557a6..0000000000000 --- a/recipes/mikktspace/all/test_package/test_package.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include - -static int GetNumFaces(const SMikkTSpaceContext *pContext) -{ - return 0; -} - -int main() -{ - SMikkTSpaceInterface sInterface = {NULL}; - sInterface.m_getNumFaces = GetNumFaces; - - SMikkTSpaceContext sContext = {NULL}; - sContext.m_pInterface = &sInterface; - - genTangSpaceDefault(&sContext); - - return 0; -} diff --git a/recipes/mikktspace/all/test_v1_package/CMakeLists.txt b/recipes/mikktspace/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/mikktspace/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/mikktspace/all/test_v1_package/conanfile.py b/recipes/mikktspace/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mikktspace/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mimalloc/all/CMakeLists.txt b/recipes/mimalloc/all/CMakeLists.txt deleted file mode 100644 index 1848ca5a77c35..0000000000000 --- a/recipes/mimalloc/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/mimalloc/all/conandata.yml b/recipes/mimalloc/all/conandata.yml index 1619d58115717..a4ff4095992ef 100644 --- a/recipes/mimalloc/all/conandata.yml +++ b/recipes/mimalloc/all/conandata.yml @@ -1,10 +1,71 @@ sources: + "2.0.7": + url: "https://github.com/microsoft/mimalloc/archive/v2.0.7.tar.gz" + sha256: "f23aac6c73594e417af50cb38f1efed88ef1dc14a490f0eff07c7f7b079810a4" + "2.0.6": + url: "https://github.com/microsoft/mimalloc/archive/v2.0.6.tar.gz" + sha256: "9f05c94cc2b017ed13698834ac2a3567b6339a8bde27640df5a1581d49d05ce5" + "2.0.5": + url: "https://github.com/microsoft/mimalloc/archive/v2.0.5.tar.gz" + sha256: "fb000a017c289ddc0df749f16fef854e033e496276d8426bdd066b59c476f6cf" + "2.0.3": + url: "https://github.com/microsoft/mimalloc/archive/v2.0.3.tar.gz" + sha256: "5af497f360879bf9d07a5146961d275a25f4177fbe21ee6c437db604422acd60" + "2.0.2": + url: "https://github.com/microsoft/mimalloc/archive/v2.0.2.tar.gz" + sha256: "c81a5f443f72373e3105172d6a935e29b0dabd13ba387c080bc444586cbe3021" + "1.7.7": + url: "https://github.com/microsoft/mimalloc/archive/v1.7.7.tar.gz" + sha256: "0f6663be1e1764851bf9563fcf7a6b3330e23b933eb4737dd07e3289b87895fe" + "1.7.6": + url: "https://github.com/microsoft/mimalloc/archive/v1.7.6.tar.gz" + sha256: "d74f86ada2329016068bc5a243268f1f555edd620b6a7d6ce89295e7d6cf18da" + "1.7.5": + url: "https://github.com/microsoft/mimalloc/archive/v1.7.5.tar.gz" + sha256: "4f9ed087fc1804a8a77c4225ffc3337468f18d6c4f060c4d44f3a3eff85bc5b6" "1.6.7": url: "https://github.com/microsoft/mimalloc/archive/v1.6.7.tar.gz" sha256: "111b718b496f297f128d842880e72e90e33953cf00b45ba0ccd2167e7340ed17" patches: + "2.0.7": + - patch_file: "patches/2.0.7-0001-change-install-paths.patch" + patch_description: "fix install paths" + patch_type: "conan" + "2.0.6": + - patch_file: "patches/2.0.6-0001-change-install-paths.patch" + patch_description: "fix install paths" + patch_type: "conan" + "2.0.5": + - patch_file: "patches/2.0.6-0001-change-install-paths.patch" + patch_description: "fix install paths" + patch_type: "conan" + "2.0.3": + - patch_file: "patches/2.0.3-0001-change-install-paths-avoid-symlink.patch" + patch_description: "fix install paths, disable creating symlink" + patch_type: "conan" + "2.0.2": + - patch_file: "patches/2.0.2-0001-change-install-paths-avoid-symlink.patch" + patch_description: "fix install paths, disable creating symlink" + patch_type: "conan" + - patch_file: "patches/2.0.2-0002-include-cstddef-to-get-std-size-t.patch" + patch_description: "include stddef" + patch_type: "portability" + "1.7.7": + - patch_file: "patches/1.7.7-0001-change-install-paths.patch" + patch_description: "fix install paths" + patch_type: "conan" + "1.7.6": + - patch_file: "patches/1.7.5-0001-change-install-paths.patch" + patch_description: "fix install paths" + patch_type: "conan" + "1.7.5": + - patch_file: "patches/1.7.5-0001-change-install-paths.patch" + patch_description: "fix install paths" + patch_type: "conan" "1.6.7": - - patch_file: "patches/0001-change-install-paths-avoid-symlink.patch" - base_path: "source_subfolder" - - patch_file: "patches/0002-include-cstddef-to-get-std-size-t.patch" - base_path: "source_subfolder" + - patch_file: "patches/1.6.7-0001-change-install-paths-avoid-symlink.patch" + patch_description: "fix install paths, disable creating symlink" + patch_type: "conan" + - patch_file: "patches/1.6.7-0002-include-cstddef-to-get-std-size-t.patch" + patch_description: "include stddef" + patch_type: "portability" diff --git a/recipes/mimalloc/all/conanfile.py b/recipes/mimalloc/all/conanfile.py index 9ec175525bca6..47efa6d568998 100644 --- a/recipes/mimalloc/all/conanfile.py +++ b/recipes/mimalloc/all/conanfile.py @@ -1,7 +1,15 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc, msvc_runtime_flag, VCVars +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir, replace_in_file, save, collect_libs +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import os import shutil +import textwrap + +required_conan_version = ">=1.53.0" class MimallocConan(ConanFile): @@ -10,15 +18,16 @@ class MimallocConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/microsoft/mimalloc" description = "mimalloc is a compact general purpose allocator with excellent performance." - topics = ("conan", "mimalloc", "allocator", "performance", "microsoft") - settings = "os", "compiler", "build_type", "arch" + topics = ("mimalloc", "allocator", "performance", "microsoft") + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "secure": [True, False], "override": [True, False], "inject": [True, False], - "single_object": [True, False] + "single_object": [True, False], } default_options = { "shared": False, @@ -26,20 +35,13 @@ class MimallocConan(ConanFile): "secure": False, "override": False, "inject": False, - "single_object": False + "single_object": False, } - generators = "cmake" - exports_sources = "CMakeLists.txt", "patches/*" - _cmake = None @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def _min_cppstd(self): + return 17 @property def _compilers_minimum_version(self): @@ -50,100 +52,113 @@ def _compilers_minimum_version(self): "apple-clang": "10", } + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + # single_object and inject are options + # only when overriding on Unix-like platforms: + if is_msvc(self): + del self.options.single_object + del self.options.inject + def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") # single_object is valid only for static # override: - if self.options.get_safe("single_object"): - del self.options.single_object + self.options.rm_safe("single_object") # inject is valid only for Unix-like dynamic override: - if not self.options.shared and self.options.get_safe("inject"): - del self.options.inject + if not self.options.shared: + self.options.rm_safe("inject") # single_object and inject are valid only when # overriding on Unix-like platforms: if not self.options.override: - if self.options.get_safe("single_object"): - del self.options.single_object - if self.options.get_safe("inject"): - del self.options.inject + self.options.rm_safe("single_object") + self.options.rm_safe("inject") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + # Currently, mimalloc some version do not work properly with shared MD builds. + # https://github.com/conan-io/conan-center-index/pull/10333#issuecomment-1114110046 + if self.version in ["1.7.6", "1.7.7", "2.0.6", "2.0.7"] and \ + self.options.shared and \ + is_msvc(self) and \ + "MD" in msvc_runtime_flag(self): + raise ConanInvalidConfiguration( + f"Currently, {self.ref} doesn't work properly with shared MD builds in CCI. Contributions welcomed") # Shared overriding requires dynamic runtime for MSVC: - if self.options.override and \ - self.options.shared and \ - self.settings.compiler == "Visual Studio" and \ - "MT" in str(self.settings.compiler.runtime): + if self.info.options.override and \ + self.info.options.shared and \ + is_msvc(self) and \ + "MT" in msvc_runtime_flag(self): raise ConanInvalidConfiguration( "Dynamic runtime (MD/MDd) is required when using mimalloc as a shared library for override") if self.options.override and \ self.options.get_safe("single_object") and \ self.options.get_safe("inject"): - raise ConanInvalidConfiguration("Single object is incompatible with library injection"); - - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "17") - - minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + raise ConanInvalidConfiguration("Single object is incompatible with library injection") - if not minimum_version: - self.output.warn("mimalloc requires C++17. Your compiler is unknown. Assuming it supports C++17.") - elif tools.Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration("mimalloc requires a compiler that supports at least C++17") + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + check_min_vs(self, 191) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("mimalloc-" + self.version, self._source_subfolder) - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - # single_object and inject are options - # only when overriding on Unix-like platforms: - if self.settings.compiler == "Visual Studio": - del self.options.single_object - del self.options.inject + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MI_BUILD_TESTS"] = "OFF" + tc.variables["MI_BUILD_SHARED"] = self.options.shared + tc.variables["MI_BUILD_STATIC"] = not self.options.shared + tc.variables["MI_BUILD_OBJECT"] = self.options.get_safe("single_object", False) + tc.variables["MI_OVERRIDE"] = "ON" if self.options.override else "OFF" + tc.variables["MI_SECURE"] = "ON" if self.options.secure else "OFF" + if Version(self.version) >= "1.7.0": + tc.variables["MI_INSTALL_TOPLEVEL"] = "ON" + tc.generate() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - if self._cmake.is_multi_configuration: - self._cmake.definitions["CMAKE_BUILD_TYPE"] = self.settings.build_type - self._cmake.definitions["MI_BUILD_TESTS"] = "OFF" - self._cmake.definitions["MI_BUILD_SHARED"] = self.options.shared - self._cmake.definitions["MI_BUILD_STATIC"] = not self.options.shared - self._cmake.definitions["MI_BUILD_OBJECT"] = self.options.get_safe("single_object", False) - self._cmake.definitions["MI_OVERRIDE"] = "ON" if self.options.override else "OFF" - self._cmake.definitions["MI_SECURE"] = "ON" if self.options.secure else "OFF" - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + if is_msvc(self): + vcvars = VCVars(self) + vcvars.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - if self.settings.compiler == "Visual Studio" and self.settings.arch == "x86": - tools.replace_path_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "mimalloc-redirect.lib", "mimalloc-redirect32.lib") - with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op(): - cmake = self._configure_cmake() - cmake.build() + apply_conandata_patches(self) + if is_msvc(self) and self.settings.arch == "x86": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "mimalloc-redirect.lib", + "mimalloc-redirect32.lib") + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op(): - cmake = self._configure_cmake() - cmake.install() + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() - tools.rmdir(os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) if self.options.get_safe("single_object"): - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), - "*.a") + rm(self, "*.a", os.path.join(self.package_folder, "lib")) shutil.move(os.path.join(self.package_folder, self._obj_name + ".o"), os.path.join(self.package_folder, "lib")) shutil.copy(os.path.join(self.package_folder, "lib", self._obj_name + ".o"), @@ -151,11 +166,41 @@ def package(self): if self.settings.os == "Windows" and self.options.shared: if self.settings.arch == "x86_64": - self.copy("mimalloc-redirect.dll", src=os.path.join(self._source_subfolder, "bin"), - dst="bin") + copy(self, "mimalloc-redirect.dll", + src=os.path.join(self.source_folder, "bin"), + dst=os.path.join(self.package_folder, "bin")) elif self.settings.arch == "x86": - self.copy("mimalloc-redirect32.dll", src=os.path.join(self._source_subfolder, "bin"), - dst="bin") + copy(self, "mimalloc-redirect32.dll", + src=os.path.join(self.source_folder, "bin"), + dst=os.path.join(self.package_folder, "bin")) + + rmdir(self, os.path.join(self.package_folder, "share")) + + cmake_target = "mimalloc" if self.options.shared else "mimalloc-static" + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {cmake_target: "mimalloc::mimalloc"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + save(self, module_file, content) + + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake") + + @property + def _module_file_rel_path(self): + return os.path.join(self._module_subfolder, + "conan-official-{}-targets.cmake".format(self.name)) @property def _obj_name(self): @@ -179,6 +224,15 @@ def _lib_name(self): return name def package_info(self): + self.cpp_info.set_property("cmake_file_name", "mimalloc") + self.cpp_info.set_property("cmake_target_name", "mimalloc" if self.options.shared else "mimalloc-static") + + self.cpp_info.names["cmake_find_package"] = "mimalloc" + self.cpp_info.names["cmake_find_package_multi"] = "mimalloc" + self.cpp_info.builddirs.append(self._module_subfolder) + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + if self.options.get_safe("inject"): self.cpp_info.includedirs = [] self.cpp_info.libdirs = [] @@ -194,7 +248,7 @@ def package_info(self): self.cpp_info.libdirs = [] self.cpp_info.bindirs = [] else: - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = collect_libs(self) if self.settings.os == "Linux": self.cpp_info.system_libs.append("pthread") diff --git a/recipes/mimalloc/all/patches/0001-change-install-paths-avoid-symlink.patch b/recipes/mimalloc/all/patches/1.6.7-0001-change-install-paths-avoid-symlink.patch similarity index 100% rename from recipes/mimalloc/all/patches/0001-change-install-paths-avoid-symlink.patch rename to recipes/mimalloc/all/patches/1.6.7-0001-change-install-paths-avoid-symlink.patch diff --git a/recipes/mimalloc/all/patches/0002-include-cstddef-to-get-std-size-t.patch b/recipes/mimalloc/all/patches/1.6.7-0002-include-cstddef-to-get-std-size-t.patch similarity index 100% rename from recipes/mimalloc/all/patches/0002-include-cstddef-to-get-std-size-t.patch rename to recipes/mimalloc/all/patches/1.6.7-0002-include-cstddef-to-get-std-size-t.patch diff --git a/recipes/mimalloc/all/patches/1.7.5-0001-change-install-paths.patch b/recipes/mimalloc/all/patches/1.7.5-0001-change-install-paths.patch new file mode 100644 index 0000000000000..e4bbfaf36f313 --- /dev/null +++ b/recipes/mimalloc/all/patches/1.7.5-0001-change-install-paths.patch @@ -0,0 +1,22 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d1207bb..feeecb6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -319,7 +319,7 @@ if(MI_BUILD_SHARED) + install(FILES "$/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll" DESTINATION ${mi_install_libdir}) + endif() + +- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY) ++ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir}) + endif() + +@@ -343,7 +343,7 @@ if (MI_BUILD_STATIC) + set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename}) + endif() + +- install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY) ++ install(TARGETS mimalloc-static EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir}) + endif() + diff --git a/recipes/mimalloc/all/patches/1.7.7-0001-change-install-paths.patch b/recipes/mimalloc/all/patches/1.7.7-0001-change-install-paths.patch new file mode 100644 index 0000000000000..108558a1f1922 --- /dev/null +++ b/recipes/mimalloc/all/patches/1.7.7-0001-change-install-paths.patch @@ -0,0 +1,22 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2bc0f76..f40e272 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -360,7 +360,7 @@ if(MI_BUILD_SHARED) + install(FILES "$/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll" DESTINATION ${mi_install_libdir}) + endif() + +- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY) ++ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir}) + endif() + +@@ -384,7 +384,7 @@ if (MI_BUILD_STATIC) + set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename}) + endif() + +- install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY) ++ install(TARGETS mimalloc-static EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir}) + endif() + diff --git a/recipes/mimalloc/all/patches/2.0.2-0001-change-install-paths-avoid-symlink.patch b/recipes/mimalloc/all/patches/2.0.2-0001-change-install-paths-avoid-symlink.patch new file mode 100644 index 0000000000000..ffbc799da2d8e --- /dev/null +++ b/recipes/mimalloc/all/patches/2.0.2-0001-change-install-paths-avoid-symlink.patch @@ -0,0 +1,30 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt 2021-06-18 00:05:40.000000000 -0300 ++++ b/CMakeLists.txt 2021-07-14 18:02:10.941935678 -0300 +@@ -281,7 +281,7 @@ + COMMENT "Copy mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll to output directory") + endif() + +- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY) ++ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir}) + endif() + +@@ -305,7 +305,7 @@ + set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename}) + endif() + +- install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY) ++ install(TARGETS mimalloc-static EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + endif() + + # install include files +@@ -315,7 +315,7 @@ + install(FILES cmake/mimalloc-config.cmake DESTINATION ${mi_install_cmakedir}) + install(FILES cmake/mimalloc-config-version.cmake DESTINATION ${mi_install_cmakedir}) + +-if(NOT WIN32 AND MI_BUILD_SHARED AND NOT MI_INSTALL_TOPLEVEL) ++if(FALSE) + # install a symlink in the /usr/local/lib to the versioned library + # note: use delayed prefix expansion as \${CMAKE_INSTALL_PREFIX} + set(mi_symlink "${CMAKE_SHARED_MODULE_PREFIX}${mi_basename}${CMAKE_SHARED_LIBRARY_SUFFIX}") diff --git a/recipes/mimalloc/all/patches/2.0.2-0002-include-cstddef-to-get-std-size-t.patch b/recipes/mimalloc/all/patches/2.0.2-0002-include-cstddef-to-get-std-size-t.patch new file mode 100644 index 0000000000000..fc8068130bf11 --- /dev/null +++ b/recipes/mimalloc/all/patches/2.0.2-0002-include-cstddef-to-get-std-size-t.patch @@ -0,0 +1,12 @@ +diff --git a/include/mimalloc.h b/include/mimalloc.h +index 254a7d9..3c3142b 100644 +--- a/include/mimalloc.h ++++ b/include/mimalloc.h +@@ -387,6 +387,7 @@ mi_decl_nodiscard mi_decl_export void* mi_new_reallocn(void* p, size_t newcount, + #ifdef __cplusplus + + #include // PTRDIFF_MAX ++#include // std::size_t + #if (__cplusplus >= 201103L) || (_MSC_VER > 1900) // C++11 + #include // std::true_type + #include // std::forward diff --git a/recipes/mimalloc/all/patches/2.0.3-0001-change-install-paths-avoid-symlink.patch b/recipes/mimalloc/all/patches/2.0.3-0001-change-install-paths-avoid-symlink.patch new file mode 100644 index 0000000000000..00b059ccae3db --- /dev/null +++ b/recipes/mimalloc/all/patches/2.0.3-0001-change-install-paths-avoid-symlink.patch @@ -0,0 +1,31 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 580e38c..19fce47 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -305,7 +305,7 @@ if(MI_BUILD_SHARED) + COMMENT "Copy mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll to output directory") + endif() + +- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY) ++ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir}) + endif() + +@@ -329,7 +329,7 @@ if (MI_BUILD_STATIC) + set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename}) + endif() + +- install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY) ++ install(TARGETS mimalloc-static EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + endif() + + # install include files +@@ -339,7 +339,7 @@ install(FILES include/mimalloc-new-delete.h DESTINATION ${mi_install_incdir}) + install(FILES cmake/mimalloc-config.cmake DESTINATION ${mi_install_cmakedir}) + install(FILES cmake/mimalloc-config-version.cmake DESTINATION ${mi_install_cmakedir}) + +-if(NOT WIN32 AND MI_BUILD_SHARED AND NOT MI_INSTALL_TOPLEVEL) ++if(FALSE) + # install a symlink in the /usr/local/lib to the versioned library + # note: use delayed prefix expansion as \${CMAKE_INSTALL_PREFIX} + set(mi_symlink "${CMAKE_SHARED_MODULE_PREFIX}${mi_basename}${CMAKE_SHARED_LIBRARY_SUFFIX}") diff --git a/recipes/mimalloc/all/patches/2.0.6-0001-change-install-paths.patch b/recipes/mimalloc/all/patches/2.0.6-0001-change-install-paths.patch new file mode 100644 index 0000000000000..bb266a46ce3f6 --- /dev/null +++ b/recipes/mimalloc/all/patches/2.0.6-0001-change-install-paths.patch @@ -0,0 +1,22 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8127e09..af459af 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -319,7 +319,7 @@ if(MI_BUILD_SHARED) + install(FILES "$/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll" DESTINATION ${mi_install_libdir}) + endif() + +- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY) ++ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir}) + endif() + +@@ -343,7 +343,7 @@ if (MI_BUILD_STATIC) + set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename}) + endif() + +- install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY) ++ install(TARGETS mimalloc-static EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir}) + endif() + diff --git a/recipes/mimalloc/all/patches/2.0.7-0001-change-install-paths.patch b/recipes/mimalloc/all/patches/2.0.7-0001-change-install-paths.patch new file mode 100644 index 0000000000000..adf1e00f9607c --- /dev/null +++ b/recipes/mimalloc/all/patches/2.0.7-0001-change-install-paths.patch @@ -0,0 +1,22 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2550f0d..da42112 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -360,7 +360,7 @@ if(MI_BUILD_SHARED) + install(FILES "$/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.dll" DESTINATION ${mi_install_libdir}) + endif() + +- install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_libdir} LIBRARY) ++ install(TARGETS mimalloc EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir}) + endif() + +@@ -384,7 +384,7 @@ if (MI_BUILD_STATIC) + set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename}) + endif() + +- install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_objdir} LIBRARY) ++ install(TARGETS mimalloc-static EXPORT mimalloc RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + install(EXPORT mimalloc DESTINATION ${mi_install_cmakedir}) + endif() + diff --git a/recipes/mimalloc/all/test_package/CMakeLists.txt b/recipes/mimalloc/all/test_package/CMakeLists.txt index 65ad416bcb919..f0ee34e277443 100644 --- a/recipes/mimalloc/all/test_package/CMakeLists.txt +++ b/recipes/mimalloc/all/test_package/CMakeLists.txt @@ -1,39 +1,43 @@ -cmake_minimum_required(VERSION 3.1) -project(PackageTest C CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(PackageTest LANGUAGES C CXX) option(BUILD_NO_CHANGES "Build no_changes sources" ON) option(BUILD_INCLUDE_OVERRIDE "Build include_override sources" ON) option(BUILD_MI_API "Build mi_api sources" ON) +find_package(mimalloc REQUIRED CONFIG) +if(TARGET mimalloc-static) + set(MIMALLOC_LIBS mimalloc-static) +else() + set(MIMALLOC_LIBS mimalloc) +endif() + if (BUILD_NO_CHANGES) add_executable(no_changes no_changes.c) - target_link_libraries(no_changes ${CONAN_LIBS}) + target_link_libraries(no_changes ${MIMALLOC_LIBS}) target_compile_features(no_changes PUBLIC c_std_11) add_executable(no_changes_cpp no_changes.cpp) - target_link_libraries(no_changes_cpp ${CONAN_LIBS}) + target_link_libraries(no_changes_cpp ${MIMALLOC_LIBS}) target_compile_features(no_changes_cpp PUBLIC cxx_std_17) endif (BUILD_NO_CHANGES) if (BUILD_INCLUDE_OVERRIDE) add_executable(include_override include_override.c) - target_link_libraries(include_override ${CONAN_LIBS}) + target_link_libraries(include_override ${MIMALLOC_LIBS}) target_compile_features(include_override PUBLIC c_std_11) add_executable(include_override_cpp include_override.cpp) - target_link_libraries(include_override_cpp ${CONAN_LIBS}) + target_link_libraries(include_override_cpp ${MIMALLOC_LIBS}) target_compile_features(include_override_cpp PUBLIC cxx_std_17) endif (BUILD_INCLUDE_OVERRIDE) if (BUILD_MI_API) add_executable(mi_api mi_api.c) - target_link_libraries(mi_api ${CONAN_LIBS}) + target_link_libraries(mi_api ${MIMALLOC_LIBS}) target_compile_features(mi_api PUBLIC c_std_11) add_executable(mi_api_cpp mi_api.cpp) - target_link_libraries(mi_api_cpp ${CONAN_LIBS}) + target_link_libraries(mi_api_cpp ${MIMALLOC_LIBS}) target_compile_features(mi_api_cpp PUBLIC cxx_std_17) endif (BUILD_MI_API) diff --git a/recipes/mimalloc/all/test_package/conanfile.py b/recipes/mimalloc/all/test_package/conanfile.py index 70fee1337adfb..9e32697b3c0e4 100644 --- a/recipes/mimalloc/all/test_package/conanfile.py +++ b/recipes/mimalloc/all/test_package/conanfile.py @@ -1,44 +1,85 @@ -from conans import ConanFile, CMake, RunEnvironment, tools -import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv, Environment +import os +import functools class MimallocTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + @functools.lru_cache(1) + def _test_files(self): + test_files = [] - def build(self): # No override: if not self.options["mimalloc"].override: - self._test_files = ["mi_api"] + test_files = ["mi_api"] # Visual Studio overriding: elif self.settings.compiler == "Visual Studio" and self.options["mimalloc"].shared: - self._test_files = ["include_override", "mi_api"] + test_files = ["include_override", "mi_api"] elif self.settings.compiler == "Visual Studio" and not self.options["mimalloc"].shared: - self._test_files = ["include_override", "mi_api"] + test_files = ["include_override", "mi_api"] # Non Macos injected override: elif self.settings.os != "Macos" and \ self.options["mimalloc"].override and \ self.options["mimalloc"].shared and \ self.options["mimalloc"].inject: - self._test_files = ["no_changes"] + test_files = ["no_changes"] # Could not simulate Macos preload, so just ignore it: elif self.settings.os == "Macos" and \ self.options["mimalloc"].override and \ self.options["mimalloc"].shared and \ self.options["mimalloc"].inject: - self._test_files = [] + test_files = [] # Unix-like non injected override: else: - self._test_files = ["include_override", "mi_api"] + test_files = ["include_override", "mi_api"] + + return test_files + + def generate(self): + test_files = self._test_files() + + tc = CMakeToolchain(self) + tc.variables["BUILD_NO_CHANGES"] = "no_changes" in test_files + tc.variables["BUILD_INCLUDE_OVERRIDE"] = "include_override" in test_files + tc.variables["BUILD_MI_API"] = "mi_api" in test_files + tc.generate() + + env = Environment() + env.define("MIMALLOC_VERBOSE", "1") + + if self.settings.os == "Linux": + env.define("LD_PRELOAD", f"{self._lib_name}.so") + elif self.settings.os == "Macos": + env.define("DYLD_FORCE_FLAT_NAMESPACE", "1") + insert_library = os.path.join(self.deps_cpp_info["mimalloc"].libdirs[0], self._lib_name +".dylib") + env.define("DYLD_INSERT_LIBRARIES", insert_library) + envvars = env.vars(self, scope="run") + envvars.save_script("mimalloc_env_file") + + deps = CMakeDeps(self) + deps.generate() + + vbe = VirtualBuildEnv(self) + vbe.generate(scope="build") + + def build(self): cmake = CMake(self) - cmake.definitions["BUILD_NO_CHANGES"] = "no_changes" in self._test_files - cmake.definitions["BUILD_INCLUDE_OVERRIDE"] = "include_override" in self._test_files - cmake.definitions["BUILD_MI_API"] = "mi_api" in self._test_files cmake.configure() cmake.build() @@ -53,39 +94,16 @@ def _lib_name(self): name += "-{}".format(str(self.settings.build_type).lower()) return name - @property - def _environment(self): - environment = {"MIMALLOC_VERBOSE": "1"} - - if self.settings.compiler == "Visual Studio" or \ - not self.options["mimalloc"].shared or \ - not self.options["mimalloc"].override or \ - not self.options["mimalloc"].inject: - return environment - - if self.settings.os == "Linux": - environment["LD_PRELOAD"] = self._lib_name + ".so" - elif self.settings.os == "Macos": - env_build = RunEnvironment(self) - insert_library = os.path.join(env_build.vars["DYLD_LIBRARY_PATH"][0], self._lib_name +".dylib") - - environment["DYLD_FORCE_FLAT_NAMESPACE"] = "1" - environment["DYLD_INSERT_LIBRARIES"] = insert_library - - return environment - def test(self): - if tools.cross_building(self.settings): + if not can_run(self): return - self.output.info("Environment append: {}".format(self._environment)) - - with tools.environment_append(self._environment): - for file in self._test_files: - test_package = os.path.join("bin", file) - self.output.info("test: {}".format(test_package)) - self.run(test_package, run_environment=True) + test_files = self._test_files() + for file in test_files: + test_package = os.path.join(self.cpp.build.bindirs[0], file) + self.output.info("test: {}".format(test_package)) + self.run(test_package, run_environment=True) - test_package_cpp = os.path.join("bin", file + "_cpp") - self.output.info("test: {}".format(test_package_cpp)) - self.run(test_package_cpp, run_environment=True) + test_package_cpp = os.path.join(self.cpp.build.bindirs[0], f"{file}_cpp") + self.output.info("test: {}".format(test_package_cpp)) + self.run(test_package_cpp, run_environment=True) diff --git a/recipes/mimalloc/all/test_v1_package/CMakeLists.txt b/recipes/mimalloc/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..be00a8c7f57c7 --- /dev/null +++ b/recipes/mimalloc/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/mimalloc/all/test_v1_package/conanfile.py b/recipes/mimalloc/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..4702c7a3df51b --- /dev/null +++ b/recipes/mimalloc/all/test_v1_package/conanfile.py @@ -0,0 +1,91 @@ +from conans import ConanFile, CMake, RunEnvironment, tools +import os + + +class MimallocTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + # No override: + if not self.options["mimalloc"].override: + self._test_files = ["mi_api"] + + # Visual Studio overriding: + elif self.settings.compiler == "Visual Studio" and self.options["mimalloc"].shared: + self._test_files = ["include_override", "mi_api"] + elif self.settings.compiler == "Visual Studio" and not self.options["mimalloc"].shared: + self._test_files = ["include_override", "mi_api"] + + # Non Macos injected override: + elif self.settings.os != "Macos" and \ + self.options["mimalloc"].override and \ + self.options["mimalloc"].shared and \ + self.options["mimalloc"].inject: + self._test_files = ["no_changes"] + + # Could not simulate Macos preload, so just ignore it: + elif self.settings.os == "Macos" and \ + self.options["mimalloc"].override and \ + self.options["mimalloc"].shared and \ + self.options["mimalloc"].inject: + self._test_files = [] + + # Unix-like non injected override: + else: + self._test_files = ["include_override", "mi_api"] + + cmake = CMake(self) + cmake.definitions["BUILD_NO_CHANGES"] = "no_changes" in self._test_files + cmake.definitions["BUILD_INCLUDE_OVERRIDE"] = "include_override" in self._test_files + cmake.definitions["BUILD_MI_API"] = "mi_api" in self._test_files + cmake.configure() + cmake.build() + + @property + def _lib_name(self): + name = "mimalloc" if self.settings.os == "Windows" else "libmimalloc" + if self.settings.os == "Windows" and not self.options["mimalloc"].shared: + name += "-static" + if self.options["mimalloc"].secure: + name += "-secure" + if self.settings.build_type not in ("Release", "RelWithDebInfo", "MinSizeRel"): + name += "-{}".format(str(self.settings.build_type).lower()) + return name + + @property + def _environment(self): + environment = {"MIMALLOC_VERBOSE": "1"} + + if self.settings.compiler == "Visual Studio" or \ + not self.options["mimalloc"].shared or \ + not self.options["mimalloc"].override or \ + not self.options["mimalloc"].inject: + return environment + + if self.settings.os == "Linux": + environment["LD_PRELOAD"] = self._lib_name + ".so" + elif self.settings.os == "Macos": + env_build = RunEnvironment(self) + insert_library = os.path.join(env_build.vars["DYLD_LIBRARY_PATH"][0], self._lib_name +".dylib") + + environment["DYLD_FORCE_FLAT_NAMESPACE"] = "1" + environment["DYLD_INSERT_LIBRARIES"] = insert_library + + return environment + + def test(self): + if tools.cross_building(self): + return + + self.output.info("Environment append: {}".format(self._environment)) + + with tools.environment_append(self._environment): + for file in self._test_files: + test_package = os.path.join("bin", file) + self.output.info("test: {}".format(test_package)) + self.run(test_package, run_environment=True) + + test_package_cpp = os.path.join("bin", file + "_cpp") + self.output.info("test: {}".format(test_package_cpp)) + self.run(test_package_cpp, run_environment=True) diff --git a/recipes/mimalloc/config.yml b/recipes/mimalloc/config.yml index 2fe756083fb76..81997d06f09a4 100644 --- a/recipes/mimalloc/config.yml +++ b/recipes/mimalloc/config.yml @@ -1,3 +1,19 @@ versions: + "2.0.7": + folder: all + "2.0.6": + folder: all + "2.0.5": + folder: all + "2.0.3": + folder: all + "2.0.2": + folder: all + "1.7.7": + folder: all + "1.7.6": + folder: all + "1.7.5": + folder: all "1.6.7": folder: all diff --git a/recipes/mingw-builds/all/conandata.yml b/recipes/mingw-builds/all/conandata.yml new file mode 100644 index 0000000000000..6703f0f20681d --- /dev/null +++ b/recipes/mingw-builds/all/conandata.yml @@ -0,0 +1,55 @@ +sources: + "12.2.0": + posix: + seh: + url: "https://github.com/niXman/mingw-builds-binaries/releases/download/12.2.0-rt_v10-rev1/x86_64-12.2.0-release-posix-seh-rt_v10-rev1.7z" + sha256: "077e1857ad2ea5e29d57127b0b9137d01bbae31b5bc65e18a7b98f4b866fd09d" + win32: + seh: + url: "https://github.com/niXman/mingw-builds-binaries/releases/download/12.2.0-rt_v10-rev1/x86_64-12.2.0-release-win32-seh-rt_v10-rev1.7z" + sha256: "774916c4403c5219f8af3a3ee3012de6c017c034895c2c92bc4de99895c2c924" + "12.1.0": + posix: + seh: + url: "https://github.com/niXman/mingw-builds-binaries/releases/download/12.1.0-rt_v10-rev3/x86_64-12.1.0-release-posix-seh-rt_v10-rev3.7z" + sha256: "6b605b990ed868a2b0fd92cf1df2d1964b06155a40a64afe52ca3bc1a7ffa3c6" + sjlj: + url: "https://github.com/niXman/mingw-builds-binaries/releases/download/12.1.0-rt_v10-rev3/x86_64-12.1.0-release-posix-sjlj-rt_v10-rev3.7z" + sha256: "fd744f5f09cd76dc98ae6abce88cd83c044191c2e6f2769936b901bd20171bc9" + win32: + seh: + url: "https://github.com/niXman/mingw-builds-binaries/releases/download/12.1.0-rt_v10-rev3/x86_64-12.1.0-release-win32-seh-rt_v10-rev3.7z" + sha256: "f82c6c881074deb4da4da4197ed7c8a58f0ef8866552519d90a24c8022334300" + sjlj: + url: "https://github.com/niXman/mingw-builds-binaries/releases/download/12.1.0-rt_v10-rev3/x86_64-12.1.0-release-win32-sjlj-rt_v10-rev3.7z" + sha256: "2cd98e9fe93b3fcb1613a9dd20c6ca71acc78817bc38de12159db0552c872e82" + "11.2.0": + posix: + seh: + url: "https://github.com/niXman/mingw-builds-binaries/releases/download/11.2.0-rt_v9-rev1/x86_64-11.2.0-release-posix-seh-rt_v9-rev1.7z" + sha256: "2c943b1a9231ce09f227b0c8fc6cabc61da3581f4ef2f7682f9393f5a1d70ae8" + sjlj: + url: "https://github.com/niXman/mingw-builds-binaries/releases/download/11.2.0-rt_v9-rev1/x86_64-11.2.0-release-posix-sjlj-rt_v9-rev1.7z" + sha256: "b943ae149c727d0dc91c4671d4e83585c087dca60b19752c9abd4b6ff7917b74" + win32: + seh: + url: "https://github.com/niXman/mingw-builds-binaries/releases/download/11.2.0-rt_v9-rev1/x86_64-11.2.0-release-win32-seh-rt_v9-rev1.7z" + sha256: "becaf3c2d036ae1cdfb50b1b807ecc4ae8c70a78f411cf3e1ccc3b7d4f6bb9d8" + sjlj: + url: "https://github.com/niXman/mingw-builds-binaries/releases/download/11.2.0-rt_v9-rev1/x86_64-11.2.0-release-win32-sjlj-rt_v9-rev1.7z" + sha256: "25a2ef169342219717e0fab794170ee58eb62879cd05f3bd8eb466bb9be59ed1" + "8.1": + posix: + seh: + url: "http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z" + sha256: "853970527b5de4a55ec8ca4d3fd732c00ae1c69974cc930c82604396d43e79f8" + sjlj: + url: "http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/sjlj/x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0.7z" + sha256: "0e994b33dc92576ba92377e2c18c0f96a04c684fa2d7a3546890819964275a1f" + win32: + seh: + url: "http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/seh/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z" + sha256: "73797b9a1d0b007dbdd6f010e6064dc0aa4df835b042f6947f73a3bf9cc348c5" + sjlj: + url: "https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/sjlj/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0.7z" + sha256: "e8c65ddc655534b0330f66f7b480565621e8617cda9937d76ba141a22bf3b2fa" diff --git a/recipes/mingw-builds/all/conanfile.py b/recipes/mingw-builds/all/conanfile.py new file mode 100644 index 0000000000000..74c63e1305ee9 --- /dev/null +++ b/recipes/mingw-builds/all/conanfile.py @@ -0,0 +1,108 @@ +import os +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration + + +class MingwConan(ConanFile): + name = "mingw-builds" + description = "MinGW is a contraction of Minimalist GNU for Windows" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/ericLemanissier/mingw-builds" + license = "ZPL-2.1", "MIT", "GPL-2.0-or-later" + topics = ("gcc", "gnu", "unix", "mingw32", "binutils") + settings = "os", "arch" + options = {"threads": ["posix", "win32"], "exception": ["seh", "sjlj"]} + default_options = {"threads": "posix", "exception": "seh"} + + provides = "mingw-w64" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def validate(self): + valid_os = ["Windows"] + if str(self.settings.os) not in valid_os: + raise ConanInvalidConfiguration("MinGW {} is only supported for the following operating systems: {}" + .format(self.version, valid_os)) + valid_arch = ["x86_64"] + if str(self.settings.arch) not in valid_arch: + raise ConanInvalidConfiguration("MinGW {} is only supported for the following architectures on {}: {}" + .format(self.version, str(self.settings.os), valid_arch)) + + if getattr(self, "settings_target", None): + if str(self.settings_target.os) not in valid_os: + raise ConanInvalidConfiguration("MinGW {} is only supported for the following operating systems: {}" + .format(self.version, valid_os)) + valid_arch = ["x86_64"] + if str(self.settings_target.arch) not in valid_arch: + raise ConanInvalidConfiguration("MinGW {} is only supported for the following architectures on {}: {}" + .format(self.version, str(self.settings.os), valid_arch)) + if self.settings_target.compiler != "gcc": + raise ConanInvalidConfiguration("Only GCC is allowed as compiler.") + if str(self.settings_target.compiler.threads) != str(self.options.threads): + raise ConanInvalidConfiguration("Build requires 'mingw' provides binaries for gcc " + "with threads={}, your profile:host declares " + "threads={}, please use the same value for both." + .format(self.options.threads, + self.settings_target.compiler.threads)) + if str(self.settings_target.compiler.exception) != str(self.options.exception): + raise ConanInvalidConfiguration("Build requires 'mingw' provides binaries for gcc " + "with exception={}, your profile:host declares " + "exception={}, please use the same value for both." + .format(self.options.exception, + self.settings_target.compiler.exception)) + + def build_requirements(self): + self.build_requires("7zip/19.00") + + def build(self): + # Source should be downloaded in the build step since it depends on specific options + url = self.conan_data["sources"][self.version][str(self.options.threads)][str(self.options.exception)] + self.output.info("Downloading: %s" % url["url"]) + tools.download(url["url"], "file.7z", sha256=url["sha256"]) + self.run("7z x file.7z") + os.remove('file.7z') + + + def package(self): + target = "mingw64" if self.settings.arch == "x86_64" else "mingw32" + self.copy("*", dst="", src=target) + tools.rmdir(target) + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "opt", "lib", "cmake")) + + def package_info(self): + if getattr(self, "settings_target", None): + if self.settings_target.compiler != "gcc": + raise ConanInvalidConfiguration("Only GCC is allowed as compiler.") + if str(self.settings_target.compiler.threads) != str(self.options.threads): + raise ConanInvalidConfiguration("Build requires 'mingw' provides binaries for gcc " + "with threads={}, your profile:host declares " + "threads={}, please use the same value for both." + .format(self.options.threads, + self.settings_target.compiler.threads)) + if str(self.settings_target.compiler.exception) != str(self.options.exception): + raise ConanInvalidConfiguration("Build requires 'mingw' provides binaries for gcc " + "with exception={}, your profile:host declares " + "exception={}, please use the same value for both." + .format(self.options.exception, + self.settings_target.compiler.exception)) + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH env var with : {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + self.env_info.MINGW_HOME = str(self.package_folder) + + self.env_info.CONAN_CMAKE_GENERATOR = "MinGW Makefiles" + self.env_info.CXX = os.path.join(self.package_folder, "bin", "g++.exe").replace("\\", "/") + self.env_info.CC = os.path.join(self.package_folder, "bin", "gcc.exe").replace("\\", "/") + self.env_info.LD = os.path.join(self.package_folder, "bin", "ld.exe").replace("\\", "/") + self.env_info.NM = os.path.join(self.package_folder, "bin", "nm.exe").replace("\\", "/") + self.env_info.AR = os.path.join(self.package_folder, "bin", "ar.exe").replace("\\", "/") + self.env_info.AS = os.path.join(self.package_folder, "bin", "as.exe").replace("\\", "/") + self.env_info.STRIP = os.path.join(self.package_folder, "bin", "strip.exe").replace("\\", "/") + self.env_info.RANLIB = os.path.join(self.package_folder, "bin", "ranlib.exe").replace("\\", "/") + self.env_info.STRINGS = os.path.join(self.package_folder, "bin", "strings.exe").replace("\\", "/") + self.env_info.OBJDUMP = os.path.join(self.package_folder, "bin", "objdump.exe").replace("\\", "/") + self.env_info.GCOV = os.path.join(self.package_folder, "bin", "gcov.exe").replace("\\", "/") diff --git a/recipes/mingw-builds/all/test_package/conanfile.py b/recipes/mingw-builds/all/test_package/conanfile.py new file mode 100644 index 0000000000000..fde2fbd35a165 --- /dev/null +++ b/recipes/mingw-builds/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, tools + + +class MinGWTestConan(ConanFile): + generators = "gcc" + settings = "os", "arch", "compiler", "build_type" + + def build(self): + source_file = os.path.join(self.source_folder, "main.cpp") + self.run("gcc.exe {} @conanbuildinfo.gcc -lstdc++ -o main".format(source_file), run_environment=True) + + def test(self): + if not tools.cross_building(self): + self.run("gcc.exe --version", run_environment=True) + self.run("main") diff --git a/recipes/mingw-w64/all/test_package/main.cpp b/recipes/mingw-builds/all/test_package/main.cpp similarity index 100% rename from recipes/mingw-w64/all/test_package/main.cpp rename to recipes/mingw-builds/all/test_package/main.cpp diff --git a/recipes/mingw-builds/config.yml b/recipes/mingw-builds/config.yml new file mode 100644 index 0000000000000..6ceaf5fe4c164 --- /dev/null +++ b/recipes/mingw-builds/config.yml @@ -0,0 +1,9 @@ +versions: + "12.2.0": + folder: "all" + "12.1.0": + folder: "all" + "11.2.0": + folder: "all" + "8.1": + folder: "all" diff --git a/recipes/mingw-w64/all/conandata.yml b/recipes/mingw-w64/all/conandata.yml deleted file mode 100644 index 74d3de5a03295..0000000000000 --- a/recipes/mingw-w64/all/conandata.yml +++ /dev/null @@ -1,18 +0,0 @@ -sources: - "8.1": - url: - x86_64: - posix: - seh: - url: "http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z" - sha256: "853970527b5de4a55ec8ca4d3fd732c00ae1c69974cc930c82604396d43e79f8" - sjlj: - url: "http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/sjlj/x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0.7z" - sha256: "0e994b33dc92576ba92377e2c18c0f96a04c684fa2d7a3546890819964275a1f" - win32: - seh: - url: "http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/seh/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z" - sha256: "73797b9a1d0b007dbdd6f010e6064dc0aa4df835b042f6947f73a3bf9cc348c5" - sjlj: - url: "https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/sjlj/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0.7z" - sha256: "e8c65ddc655534b0330f66f7b480565621e8617cda9937d76ba141a22bf3b2fa" diff --git a/recipes/mingw-w64/all/conanfile.py b/recipes/mingw-w64/all/conanfile.py deleted file mode 100644 index c6e67ec2e6100..0000000000000 --- a/recipes/mingw-w64/all/conanfile.py +++ /dev/null @@ -1,73 +0,0 @@ -import os -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration - - -class MingwConan(ConanFile): - name = "mingw-w64" - description = "MinGW is a contraction of Minimalist GNU for Windows" - url = "https://github.com/conan-io/conan-center-index" - homepage = "http://mingw-w64.org/doku.php" - license = "ZPL-2.1", "MIT", "GPL-2.0-or-later" - topics = ("gcc", "gnu", "unix", "mingw32", "binutils") - settings = "os", "arch", "compiler" - options = {"threads": ["posix", "win32"], "exception": ["seh", "sjlj"]} - default_options = {"threads": "posix", "exception": "seh"} - build_requires = "7zip/19.00" - no_copy_source = True - - def validate(self): - if self.settings.os != "Windows": - raise ConanInvalidConfiguration("MinGW is only supported by Windows.") - - def source(self): - url = self.conan_data["sources"][self.version]["url"][str(self.settings.arch)] \ - [str(self.options.threads)][str(self.options.exception)] - self.output.info("Downloading: %s" % url["url"]) - tools.download(url["url"], "file.7z", sha256=url["sha256"]) - self.run("7z x file.7z") - os.remove('file.7z') - - def package(self): - target = "mingw64" if self.settings.arch == "x86_64" else "mingw32" - self.copy("*", dst="", src=target) - tools.rmdir(target) - tools.rmdir(os.path.join(self.package_folder, "share")) - - def package_id(self): - del self.info.settings.compiler - - def package_info(self): - if getattr(self, "settings_target", None): - if self.settings_target.compiler != "gcc": - raise ConanInvalidConfiguration("Only GCC is allowed as compiler.") - if str(self.settings_target.compiler.threads) != str(self.options.threads): - raise ConanInvalidConfiguration("Build requires 'mingw' provides binaries for gcc " - "with threads={}, your profile:host declares " - "threads={}, please use the same value for both." - .format(self.options.threads, - self.settings_target.compiler.threads)) - if str(self.settings_target.compiler.exception) != str(self.options.exception): - raise ConanInvalidConfiguration("Build requires 'mingw' provides binaries for gcc " - "with exception={}, your profile:host declares " - "exception={}, please use the same value for both." - .format(self.options.exception, - self.settings_target.compiler.exception)) - - - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH env var with : {}".format(bin_path)) - self.env_info.PATH.append(bin_path) - self.env_info.MINGW_HOME = str(self.package_folder) - self.env_info.CONAN_CMAKE_GENERATOR = "MinGW Makefiles" - self.env_info.CXX = os.path.join(self.package_folder, "bin", "g++.exe").replace("\\", "/") - self.env_info.CC = os.path.join(self.package_folder, "bin", "gcc.exe").replace("\\", "/") - self.env_info.LD = os.path.join(self.package_folder, "bin", "ld.exe").replace("\\", "/") - self.env_info.NM = os.path.join(self.package_folder, "bin", "nm.exe").replace("\\", "/") - self.env_info.AR = os.path.join(self.package_folder, "bin", "ar.exe").replace("\\", "/") - self.env_info.AS = os.path.join(self.package_folder, "bin", "as.exe").replace("\\", "/") - self.env_info.STRIP = os.path.join(self.package_folder, "bin", "strip.exe").replace("\\", "/") - self.env_info.RANLIB = os.path.join(self.package_folder, "bin", "ranlib.exe").replace("\\", "/") - self.env_info.STRINGS = os.path.join(self.package_folder, "bin", "strings.exe").replace("\\", "/") - self.env_info.OBJDUMP = os.path.join(self.package_folder, "bin", "objdump.exe").replace("\\", "/") - self.env_info.GCOV = os.path.join(self.package_folder, "bin", "gcov.exe").replace("\\", "/") diff --git a/recipes/mingw-w64/all/test_package/conanfile.py b/recipes/mingw-w64/all/test_package/conanfile.py deleted file mode 100644 index 6f2cfa8712389..0000000000000 --- a/recipes/mingw-w64/all/test_package/conanfile.py +++ /dev/null @@ -1,16 +0,0 @@ -import os -from conans import ConanFile, tools - - -class MinGWTestConan(ConanFile): - generators = "gcc" - settings = "os", "arch", "compiler", "build_type" - - def build(self): - source_file = os.path.join(self.source_folder, "main.cpp") - self.run("gcc.exe {} @conanbuildinfo.gcc -lstdc++ -o main".format(source_file), run_environment=True) - - def test(self): - if not tools.cross_building(self.settings): - self.run("gcc.exe --version", run_environment=True) - self.run("main") diff --git a/recipes/mingw-w64/config.yml b/recipes/mingw-w64/config.yml index 400f042218b12..ccd4069ab51d6 100644 --- a/recipes/mingw-w64/config.yml +++ b/recipes/mingw-w64/config.yml @@ -1,3 +1,3 @@ versions: - "8.1": - folder: "all" + "8.0.2": + folder: "linux" diff --git a/recipes/mingw-w64/linux/conandata.yml b/recipes/mingw-w64/linux/conandata.yml new file mode 100644 index 0000000000000..4c165fd2e4f36 --- /dev/null +++ b/recipes/mingw-w64/linux/conandata.yml @@ -0,0 +1,12 @@ +sources: + "8.0.2": + mingw-w64: + url: "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v8.0.2.tar.bz2" + sha256: "f00cf50951867a356d3dc0dcc7a9a9b422972302e23d54a33fc05ee7f73eee4d" + binutils: + url: "http://ftp.gnu.org/gnu/binutils/binutils-2.35.2.tar.bz2" + sha256: "cfa7644dbecf4591e136eb407c1c1da16578bd2b03f0c2e8acdceba194bb9d61" + gcc: + "10.3.0": + url: "http://ftp.gnu.org/gnu/gcc/gcc-10.3.0/gcc-10.3.0.tar.xz" + sha256: "64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344" diff --git a/recipes/mingw-w64/linux/conanfile.py b/recipes/mingw-w64/linux/conanfile.py new file mode 100644 index 0000000000000..1e781d08b3204 --- /dev/null +++ b/recipes/mingw-w64/linux/conanfile.py @@ -0,0 +1,286 @@ +import os +from conan import ConanFile +from conan.tools.files import get, mkdir, chdir, rm, rmdir +from conan.errors import ConanInvalidConfiguration +from conans import tools, AutoToolsBuildEnvironment + + +required_conan_version = ">=1.50.0" + + +class MingwConan(ConanFile): + name = "mingw-w64" + description = "MinGW is a contraction of Minimalist GNU for Windows" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.mingw-w64.org/" + license = "ZPL-2.1", "MIT", "GPL-2.0-or-later" + topics = ("gcc", "gnu", "unix", "mingw32", "binutils") + settings = "os", "arch", "build_type", "compiler" + options = {"threads": ["posix", "win32"], "exception": ["seh", "sjlj"], "gcc": ["10.3.0"]} + default_options = {"threads": "posix", "exception": "seh", "gcc": "10.3.0"} + no_copy_source = True + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def validate(self): + valid_os = ["Linux"] + if str(self.settings.os) not in valid_os: + raise ConanInvalidConfiguration("MinGW {} is only supported for the following operating systems: {}" + .format(self.version, valid_os)) + valid_arch = ["x86_64"] + if str(self.settings.arch) not in valid_arch: + raise ConanInvalidConfiguration("MinGW {} is only supported for the following architectures on {}: {}" + .format(self.version, str(self.settings.os), valid_arch)) + + if "gcc" in self.conan_data["sources"][self.version]: + valid_gcc = self.conan_data["sources"][self.version]["gcc"].keys() + if str(self.options.gcc) not in valid_gcc: + raise ConanInvalidConfiguration("gcc version {} is not in the list of valid versions: {}" + .format(str(self.options.gcc), valid_gcc)) + + def build_requirements(self): + self.build_requires("m4/1.4.19") + self.build_requires("gmp/6.2.1") + self.build_requires("mpfr/4.1.0") + self.build_requires("mpc/1.2.0") + + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type + + def _download_source(self): + arch_data = self.conan_data["sources"][self.version] + + for package in arch_data: + if package == "gcc": + continue + self.output.info("Downloading {} from {}".format(package, arch_data[package]['url'])) + get(self, **arch_data[package], strip_root=True, destination=os.path.join(self.build_folder, "sources", package)) + # Download gcc version + gcc_data = arch_data["gcc"][str(self.options.gcc)] + get(self, **gcc_data, strip_root=True, destination=os.path.join(self.build_folder, "sources", "gcc")) + + @property + def _target_tag(self): + return "x86_64-w64-mingw32" + + def build(self): + # Source should be downloaded in the build step since it depends on specific options + self._download_source() + + target_tag = self._target_tag + host_tag = "x86_64-linux-gnu" + + # We currently cannot build with multilib and threads=posix. Otherwise we get the gcc compile error: + # checking for ld that supports -Wl,--gc-sections... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES. + # Makefile:11275: recipe for target 'configure-target-libstdc++-v3' failed + build_multilib = False + + # Instructions see: + # https://sourceforge.net/p/mingw-w64/code/HEAD/tree/trunk/mingw-w64-doc/howto-build/mingw-w64-howto-build.txt + # and + # https://sourceforge.net/p/mingw-w64/code/HEAD/tree/trunk/mingw-w64-doc/howto-build/mingw-w64-howto-build-adv.txt + # also good to see specific commands: + # https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/+/lollipop-dev/build-mingw64-toolchain.sh + + # add binutils to path. Required for gcc build + env = {"PATH": os.environ["PATH"] + ":" + os.path.join(self.package_folder, "bin")} + + with tools.environment_append(env): + with_gmp_mpfc_mpc = [ + "--with-gmp={}".format(self.deps_cpp_info["gmp"].rootpath.replace("\\", "/")), + "--with-mpfr={}".format(self.deps_cpp_info["mpfr"].rootpath.replace("\\", "/")), + "--with-mpc={}".format(self.deps_cpp_info["mpc"].rootpath.replace("\\", "/")) + ] + + self.output.info("Building binutils ...") + mkdir(self, os.path.join(self.build_folder, "binutils")) + with chdir(self, os.path.join(self.build_folder, "binutils")): + autotools = AutoToolsBuildEnvironment(self) + conf_args = [ + "--enable-silent-rules", + "--with-sysroot={}".format(self.package_folder), + "--disable-nls", + "--disable-shared" + ] + if build_multilib: + conf_args.append("--enable-targets=x86_64-w64-mingw32,i686-w64-mingw32") + conf_args.extend(with_gmp_mpfc_mpc) + autotools.configure(configure_dir=os.path.join(self.build_folder, "sources", "binutils"), + args=conf_args, target=target_tag, host=False, build=False) + autotools.make() + autotools.install() + + self.output.info("Building mingw-w64-tools ...") + mkdir(self, os.path.join(self.build_folder, "mingw-w64-tools")) + with chdir(self, os.path.join(self.build_folder, "mingw-w64-tools")): + autotools = AutoToolsBuildEnvironment(self) + conf_args = [] + autotools.configure(configure_dir=os.path.join(self.build_folder, "sources", "mingw-w64", "mingw-w64-tools", "widl"), + args=conf_args, target=target_tag, host=False, build=False) + autotools.make() + autotools.install() + + self.output.info("Building mingw-w64-headers ...") + mkdir(self, os.path.join(self.build_folder, "mingw-w64-headers")) + with chdir(self, os.path.join(self.build_folder, "mingw-w64-headers")): + autotools = AutoToolsBuildEnvironment(self) + conf_args = [ + "--enable-silent-rules", + "--with-widl={}".format(os.path.join(self.package_folder, "bin")), + "--enable-sdk=all", + "--prefix={}".format(os.path.join(self.package_folder, target_tag)) + ] + autotools.configure(configure_dir=os.path.join(self.build_folder, "sources", "mingw-w64", "mingw-w64-headers"), + args=conf_args, target=False, host=target_tag, build=host_tag) + autotools.make() + autotools.install() + # Step 3) GCC requires the x86_64-w64-mingw32 directory be mirrored as a + # directory 'mingw' in the same root. So, if using configure default + # /usr/local, type: + # ln -s /usr/local/x86_64-w64-mingw32 /usr/local/mingw + # or, for sysroot, type: + # ln -s /mypath/x86_64-w64-mingw32 /mypath/mingw + self.run("ln -s {} {}".format(os.path.join(self.package_folder, target_tag), + os.path.join(self.package_folder, 'mingw'))) + # Step 5) Symlink x86_64-w64-mingw32/lib directory as x86_64-w64-mingw32/lib64: + # ln -s /usr/local/x86_64-w64-mingw32/lib /usr/local/x86_64-w64-mingw32/lib64 + # or, for sysroot: + # ln -s /mypath/x86_64-w64-mingw32/lib /mypath/x86_64-w64-mingw32/lib64 + self.run("ln -s {} {}".format(os.path.join(self.package_folder, target_tag, 'lib'), + os.path.join(self.package_folder, target_tag, 'lib64'))) + + self.output.info("Building core gcc ...") + mkdir(self, os.path.join(self.build_folder, "gcc")) + with chdir(self, os.path.join(self.build_folder, "gcc")): + autotools_gcc = AutoToolsBuildEnvironment(self) + conf_args = [ + "--enable-silent-rules", + "--enable-languages=c,c++", + "--with-sysroot={}".format(self.package_folder), + "--disable-shared" + ] + if build_multilib: + conf_args.append("--enable-targets=all") + conf_args.append("--enable-multilib") + else: + conf_args.append("--disable-multilib") + conf_args.extend(with_gmp_mpfc_mpc) + if self.options.exception == "sjlj": + conf_args.append("--enable-sjlj-exceptions") + if self.options.threads == "posix": + # Some specific options which need to be set for posix thread. Otherwise it fails compiling. + conf_args.extend([ + "--enable-silent-rules", + "--enable-threads=posix", + # Not 100% sure why, but the following options are required, otherwise + # gcc fails to build with posix threads + ]) + autotools_gcc.libs = [] + autotools_gcc.configure(configure_dir=os.path.join(self.build_folder, "sources", "gcc"), + args=conf_args, target=target_tag, host=False, build=False) + autotools_gcc.make(target="all-gcc") + autotools_gcc.make(target="install-gcc") + + env_compiler = dict(env) + # The CC and CXX compiler must be set to the mingw compiler. Conan already sets CC and CXX, therefore we need to overwrite it. + # If the wrong compiler is used for mingw-w64-crt, then you will get the error + # configure: Please check if the mingw-w64 header set and the build/host option are set properly. + env_compiler["CC"] = target_tag + "-gcc" + env_compiler["CXX"] = target_tag + "-g++" + with tools.environment_append(env_compiler): + self.output.info("Building mingw-w64-crt ...") + mkdir(self, os.path.join(self.build_folder, "mingw-w64-crt")) + with chdir(self, os.path.join(self.build_folder, "mingw-w64-crt")): + autotools = AutoToolsBuildEnvironment(self) + conf_args = [ + "--enable-silent-rules", + "--prefix={}".format(os.path.join(self.package_folder, target_tag)), + "--with-sysroot={}".format(self.package_folder) + ] + if build_multilib: + conf_args.append("--enable-lib32") + autotools.configure(configure_dir=os.path.join(self.build_folder, "sources", "mingw-w64", "mingw-w64-crt"), + args=conf_args, target=False, host=target_tag, build=False, + use_default_install_dirs=False) + autotools.make() + autotools.install() + + if self.options.threads == "posix": + self.output.info("Building mingw-w64-libraries-winpthreads ...") + mkdir(self, os.path.join(self.build_folder, "mingw-w64-libraries-winpthreads")) + with chdir(self, os.path.join(self.build_folder, "mingw-w64-libraries-winpthreads")): + autotools = AutoToolsBuildEnvironment(self) + conf_args = [ + "--enable-silent-rules", + "--disable-shared", + "--prefix={}".format(os.path.join(self.package_folder, target_tag)) + ] + autotools.configure(configure_dir=os.path.join(self.build_folder, "sources", "mingw-w64", "mingw-w64-libraries", "winpthreads"), + args=conf_args, target=False, host=target_tag, build=False) + autotools.make() + autotools.install() + + self.output.info("Building libgcc ...") + with chdir(self, os.path.join(self.build_folder, "gcc")): + autotools_gcc.make() + autotools_gcc.install() + + self.output.info("Building done!") + + def package(self): + self.copy("COPYING", src=os.path.join(self.build_folder, "sources", "mingw-w64"), dst="licenses") + rm(self, "*.la", self.package_folder, recursive=True) + rmdir(self, os.path.join(self.package_folder, "share", "man")) + rmdir(self, os.path.join(self.package_folder, "share", "doc")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + # replace with relative symlinks so they'll resolve correctly on consumer's machine + os.unlink(os.path.join(self.package_folder, 'mingw')) + os.unlink(os.path.join(self.package_folder, self._target_tag, 'lib64')) + self.run("ln -s {} {}".format(os.path.join(os.curdir, self._target_tag), + os.path.join(self.package_folder, 'mingw'))) + self.run("ln -s {} {}".format(os.path.join(os.curdir, 'lib'), + os.path.join(self.package_folder, self._target_tag, 'lib64'))) + + def package_info(self): + if getattr(self, "settings_target", None): + if self.settings_target.compiler != "gcc": + raise ConanInvalidConfiguration("Only GCC is allowed as compiler.") + if str(self.settings_target.compiler.threads) != str(self.options.threads): + raise ConanInvalidConfiguration("Build requires 'mingw' provides binaries for gcc " + "with threads={}, your profile:host declares " + "threads={}, please use the same value for both." + .format(self.options.threads, + self.settings_target.compiler.threads)) + if str(self.settings_target.compiler.exception) != str(self.options.exception): + raise ConanInvalidConfiguration("Build requires 'mingw' provides binaries for gcc " + "with exception={}, your profile:host declares " + "exception={}, please use the same value for both." + .format(self.options.exception, + self.settings_target.compiler.exception)) + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH env var with : {}".format(bin_path)) + self.env_info.PATH.append(bin_path) + self.env_info.MINGW_HOME = str(self.package_folder) + + prefix = os.path.join(self.package_folder, "bin", self._target_tag + "-") + self.env_info.CC = prefix + "gcc" + self.env_info.CXX = prefix + "g++" + self.env_info.CPP = prefix + "cpp" + self.env_info.AR = prefix + "ar" + self.env_info.AS = prefix + "as" + self.env_info.GDB = prefix + "gdb" + self.env_info.LD = prefix + "ld" + self.env_info.NM = prefix + "nm" + self.env_info.OBJCOPY = prefix + "objcopy" + self.env_info.OBJDUMP = prefix + "objdump" + self.env_info.RANLIB = prefix + "ranlib" + self.env_info.SIZE = prefix + "size" + self.env_info.STRINGS = prefix + "strings" + self.env_info.STRIP = prefix + "strip" + self.env_info.GCOV = prefix + "gcov" + self.env_info.RC = prefix + "windres" + self.env_info.DLLTOOL = prefix + "dlltool" diff --git a/recipes/mingw-w64/linux/test_package/conanfile.py b/recipes/mingw-w64/linux/test_package/conanfile.py new file mode 100644 index 0000000000000..b6ef323de8d96 --- /dev/null +++ b/recipes/mingw-w64/linux/test_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conan import ConanFile +from conan.tools.build import cross_building + + +class MinGWTestConan(ConanFile): + generators = "gcc" + settings = "os", "arch", "compiler", "build_type" + + def build(self): + source_file = os.path.join(self.source_folder, "main.cpp") + self.run("x86_64-w64-mingw32-g++ {} @conanbuildinfo.gcc -lstdc++ -o main".format(source_file), run_environment=True) + + def test(self): + if not cross_building(self): + self.run("x86_64-w64-mingw32-g++ --version", run_environment=True) diff --git a/recipes/mingw-w64/linux/test_package/main.cpp b/recipes/mingw-w64/linux/test_package/main.cpp new file mode 100644 index 0000000000000..a9fc162357f9c --- /dev/null +++ b/recipes/mingw-w64/linux/test_package/main.cpp @@ -0,0 +1,9 @@ +#if !defined(_WIN32) +# error "_WIN32 not defined" +#endif + +#include + +int main() { + printf("hello world\n"); +} diff --git a/recipes/miniaudio/all/CMakeLists.txt b/recipes/miniaudio/all/CMakeLists.txt new file mode 100644 index 0000000000000..8e18371d5a460 --- /dev/null +++ b/recipes/miniaudio/all/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.4) +project(miniaudio LANGUAGES C) + +include(GNUInstallDirs) + +set(SOURCE_SUBFOLDER ${MINIAUDIO_SRC_DIR}/extras/miniaudio_split/) +add_library(miniaudio ${SOURCE_SUBFOLDER}/miniaudio.c) +target_include_directories(miniaudio PRIVATE ${SOURCE_SUBFOLDER}) + +if (BUILD_SHARED_LIBS) + target_compile_definitions(miniaudio PRIVATE MA_DLL MINIAUDIO_IMPLEMENTATION) +endif() + +set_target_properties(miniaudio + PROPERTIES + VERSION ${MINIAUDIO_VERSION_STRING} + PUBLIC_HEADER ${SOURCE_SUBFOLDER}/miniaudio.h) + +install(TARGETS miniaudio + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/recipes/miniaudio/all/conandata.yml b/recipes/miniaudio/all/conandata.yml index ad3dfad931ba1..49cc53a5d3381 100644 --- a/recipes/miniaudio/all/conandata.yml +++ b/recipes/miniaudio/all/conandata.yml @@ -1,10 +1,25 @@ sources: - "0.10.32": - url: https://github.com/mackron/miniaudio/archive/d06d4983d3ff512690eb37f5edd25bf96f8f3764.tar.gz - sha256: 1FB7784AA6BC1C8138376C966BBDB444FF51CE04EF4289067BC59FB163CF38EA - "0.10.33": - url: https://github.com/mackron/miniaudio/archive/fca829edefd8389380f8e3ee26cc4b8c426dd742.tar.gz - sha256: DF1B4E36211112FDC35AF92F2288DAFDEB07290F4010E7C5E2505AFFA880E0EE - "0.10.35": - url: https://github.com/mackron/miniaudio/archive/199d6a7875b4288af6a7b615367c8fdc2019b03c.tar.gz - sha256: 3D9C5FCB112E24E9C038F7520C93D52882CECE6C93DF259FD33A389B7DEB7C40 + "0.11.11": + url: "https://github.com/mackron/miniaudio/archive/a0dc1037f99a643ff5fad7272cd3d6461f2d63fa.tar.gz" + sha256: "4821e2f796d95b772fd4ef1274181d5302854bfe55680125a5cd9b24b8542dcf" + "0.11.9": + url: "https://github.com/mackron/miniaudio/archive/4dfe7c4c31df46e78d9a1cc0d2d6f1aef5a5d58c.tar.gz" + sha256: "76c154a60e320ae2054ac0e93480f2dffc12a5129bdb2ed4a62e0cce8d345c36" + "0.11.8": + url: "https://github.com/mackron/miniaudio/archive/82e70f4cbe6e613c8edc0ac7b97ff3dd00f2ca27.tar.gz" + sha256: "a18540062e46f6308c962068125c9560a1a51abeb4fa8dc26a91ea55fc043c6b" + "0.11.7": + url: "https://github.com/mackron/miniaudio/archive/073b7bbbba3a27adcf44fd62bd055ccee67e1973.tar.gz" + sha256: "c3cabab7ce9564ffbe136e5111d2569d224051af95d76d85b4354c65d8ede85e" + "0.11.6": + url: "https://github.com/mackron/miniaudio/archive/c3a9ab9b900b1ac316f7e2cb5e05e5cc27179f19.tar.gz" + sha256: "3b0a23ae745592dae19e777cf46784285705b16fba582cbad2534a61d75595d1" + "0.11.2": + url: "https://github.com/mackron/miniaudio/archive/42abbbea4602af80d1ccb4a22cdc35813aceee7a.tar.gz" + sha256: "7d54fbe5c7dae30e30ca6b3ffecaed81c61637752d56a8434a0a66895e36352a" + "0.10.40": + url: "https://github.com/mackron/miniaudio/archive/37fe1343f04f6fd9bd82229ca50a48b77ecce564.tar.gz" + sha256: "363478247C144F94A09B62A6BD27E11FEA7334FE2247B666C0D8891607D3C39C" + "0.10.39": + url: "https://github.com/mackron/miniaudio/archive/8bf157f10e278302f8a6c1c9cd1065f2bea26dd2.tar.gz" + sha256: "573C511F1FD1C64BD331160E357DE611A144E5BDBAF1CD872195B8D535FA557E" diff --git a/recipes/miniaudio/all/conanfile.py b/recipes/miniaudio/all/conanfile.py index cbca076749524..599f3c0195bdc 100644 --- a/recipes/miniaudio/all/conanfile.py +++ b/recipes/miniaudio/all/conanfile.py @@ -1,59 +1,100 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import get, copy +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.layout import basic_layout import os -import glob +required_conan_version = ">=1.53.0" class MiniaudioConan(ConanFile): name = "miniaudio" description = "A single file audio playback and capture library." - topics = ("conan", "miniaudio", "header-only", "sound") - homepage = "https://github.com/mackron/miniaudio" - url = "https://github.com/conan-io/conan-center-index" license = ["Unlicense", "MIT-0"] - settings = "os", "compiler", "build_type", "arch" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/mackron/miniaudio" + topics = ("audio", "header-only", "sound") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "header_only": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "header_only": True, + } + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) - no_copy_source = True + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC - @property - def _source_subfolder(self): - return "source_subfolder" + def configure(self): + if self.options.header_only or self.options.shared: + self.options.rm_safe("fPIC") + if self.options.header_only: + del self.options.shared + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + if self.options.header_only: + basic_layout(self, src_folder="src") + else: + cmake_layout(self, src_folder="src") + + def package_id(self): + if self.options.header_only: + self.info.clear() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob(self.name + "-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + if self.options.header_only: + return + + tc = CMakeToolchain(self) + tc.variables["MINIAUDIO_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["MINIAUDIO_VERSION_STRING"] = self.version + tc.generate() + + def build(self): + if self.options.header_only: + return + + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="miniaudio.h", dst="include", src=self._source_subfolder) - self.copy( - pattern="stb_vorbis.c", - dst="include/extras", - src=os.path.join(self._source_subfolder, "extras"), - ) - self.copy( - pattern="dr_*.h", - dst="include/extras", - src=os.path.join(self._source_subfolder, "extras"), - ) - self.copy( - pattern="ma_speex_resampler.h", - dst="include/extras/speex_resampler/", - src=os.path.join(self._source_subfolder, "extras/speex_resampler/"), - ) - self.copy( - pattern="*.*", - dst="include/extras/speex_resampler/thirdparty", - src=os.path.join( - self._source_subfolder, "extras/speex_resampler/thirdparty" - ), - ) - self.copy( - pattern="miniaudio.*", - dst="include/extras/miniaudio_split", - src=os.path.join(self._source_subfolder, "extras/miniaudio_split"), + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy( + self, + pattern="**", + dst=os.path.join(self.package_folder, "include", "extras"), + src=os.path.join(self.source_folder, "extras"), ) + if self.options.header_only: + copy( + self, + pattern="miniaudio.h", + dst=os.path.join(self.package_folder, "include"), + src=self.source_folder) + copy( + self, + pattern="miniaudio.*", + dst=os.path.join(self.package_folder, "include", "extras", "miniaudio_split"), + src=os.path.join(self.source_folder, "extras", "miniaudio_split"), + ) + else: + cmake = CMake(self) + cmake.install() + def package_info(self): if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["m", "pthread"]) @@ -65,5 +106,11 @@ def package_info(self): ) self.cpp_info.defines.append("MA_NO_RUNTIME_LINKING=1") - def package_id(self): - self.info.header_only() + if self.options.header_only: + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + else: + self.cpp_info.libs = ["miniaudio"] + if self.options.shared: + self.cpp_info.defines.append("MA_DLL") + diff --git a/recipes/miniaudio/all/test_package/CMakeLists.txt b/recipes/miniaudio/all/test_package/CMakeLists.txt index e1743800664dd..b334a63d0191a 100644 --- a/recipes/miniaudio/all/test_package/CMakeLists.txt +++ b/recipes/miniaudio/all/test_package/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) find_package(miniaudio REQUIRED) -add_executable(test_package example.c) -target_link_libraries(test_package miniaudio::miniaudio) +add_executable(${PROJECT_NAME} example.c) +target_link_libraries(${PROJECT_NAME} miniaudio::miniaudio) diff --git a/recipes/miniaudio/all/test_package/conanfile.py b/recipes/miniaudio/all/test_package/conanfile.py index 4e5cabef40600..e140654a3db4e 100644 --- a/recipes/miniaudio/all/test_package/conanfile.py +++ b/recipes/miniaudio/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os - class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,5 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run("test_package", run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") + diff --git a/recipes/miniaudio/all/test_package/example.c b/recipes/miniaudio/all/test_package/example.c index ccfcf8aa8bfa1..b2cf198c183eb 100644 --- a/recipes/miniaudio/all/test_package/example.c +++ b/recipes/miniaudio/all/test_package/example.c @@ -6,6 +6,11 @@ many devices to one context. If you use device enumeration, you should explicitly specify the same context you used for enumeration in the call to `ma_device_init()` when you initialize your devices. */ + +// With the package in header-only mode, this will embed the implementation of +// miniaudio in this file. +// In lib mode, this will be ignored because we use the stripped version of +// miniaudio.h that only contains definitions. #define MINIAUDIO_IMPLEMENTATION #include diff --git a/recipes/miniaudio/all/test_v1_package/CMakeLists.txt b/recipes/miniaudio/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/miniaudio/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/miniaudio/all/test_v1_package/conanfile.py b/recipes/miniaudio/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/miniaudio/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/miniaudio/config.yml b/recipes/miniaudio/config.yml index 24481c8cbe5b0..52824dc107878 100644 --- a/recipes/miniaudio/config.yml +++ b/recipes/miniaudio/config.yml @@ -1,7 +1,17 @@ versions: - "0.10.32": + "0.11.11": folder: all - "0.10.33": + "0.11.9": folder: all - "0.10.35": + "0.11.8": + folder: all + "0.11.7": + folder: all + "0.11.6": + folder: all + "0.11.2": + folder: all + "0.10.40": + folder: all + "0.10.39": folder: all diff --git a/recipes/minimp3/all/conanfile.py b/recipes/minimp3/all/conanfile.py index 00c849aad8802..6886956b3c461 100644 --- a/recipes/minimp3/all/conanfile.py +++ b/recipes/minimp3/all/conanfile.py @@ -1,29 +1,40 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools +required_conan_version = ">=1.50.0" + class Minimp3Conan(ConanFile): name = "minimp3" description = "Minimalistic MP3 decoder single header library." license = "CC0-1.0" - topics = ("conan", "minimp3", "decoder", "mp3", "header-only") + topics = ("minimp3", "decoder", "mp3", "header-only") homepage = "https://github.com/lieff/minimp3" url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - url = self.conan_data["sources"][self.version]["url"] - extracted_dir = "minimp3-" + os.path.splitext(os.path.basename(url))[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="minimp3*.h", dst="include", src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "minimp3*.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/minimp3/all/test_package/CMakeLists.txt b/recipes/minimp3/all/test_package/CMakeLists.txt index 7b9b613cbb24a..685b8a96689cb 100644 --- a/recipes/minimp3/all/test_package/CMakeLists.txt +++ b/recipes/minimp3/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(minimp3 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE minimp3::minimp3) diff --git a/recipes/minimp3/all/test_package/conanfile.py b/recipes/minimp3/all/test_package/conanfile.py index ea57a464900be..d120a992c06a6 100644 --- a/recipes/minimp3/all/test_package/conanfile.py +++ b/recipes/minimp3/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/minimp3/all/test_v1_package/CMakeLists.txt b/recipes/minimp3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..659f9200bc193 --- /dev/null +++ b/recipes/minimp3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGET) + +find_package(minimp3 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE minimp3::minimp3) diff --git a/recipes/minimp3/all/test_v1_package/conanfile.py b/recipes/minimp3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/minimp3/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/minitrace/all/conandata.yml b/recipes/minitrace/all/conandata.yml new file mode 100644 index 0000000000000..f0c32e1045bb8 --- /dev/null +++ b/recipes/minitrace/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "cci.20210321": + url: "https://github.com/hrydgard/minitrace/archive/020f42b189e8d6ad50e4d8f45d69edee0a6b3f23.tar.gz" + sha256: "314bcab4dc069c61f2eb813c9bd649efb2bd1fd75f91205a269a4c5abcd3d66b" +patches: + "cci.20210321": + - patch_file: "patches/0001-fix-cmake.patch" diff --git a/recipes/minitrace/all/conanfile.py b/recipes/minitrace/all/conanfile.py new file mode 100644 index 0000000000000..1c39ada6eb865 --- /dev/null +++ b/recipes/minitrace/all/conanfile.py @@ -0,0 +1,71 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get +import os + +required_conan_version = ">=1.46.0" + + +class MinitraceConan(ConanFile): + name = "minitrace" + description = "Simple C/C++ library for producing JSON traces suitable for Chrome's built-in trace viewer (about:tracing)." + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/hrydgard/minitrace" + topics = ("trace", "chrome", "about:tracing",) + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + "shared": [True, False], + } + default_options = { + "fPIC": True, + "shared": False, + } + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def generate(self): + toolchain = CMakeToolchain(self) + toolchain.generate() + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["minitrace"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/minitrace/all/patches/0001-fix-cmake.patch b/recipes/minitrace/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..3ab4a600e5e60 --- /dev/null +++ b/recipes/minitrace/all/patches/0001-fix-cmake.patch @@ -0,0 +1,41 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 06320bb..52c948c 100644 +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -1,11 +1,18 @@ + cmake_minimum_required(VERSION 3.10) + project(minitrace) + +-add_library(${PROJECT_NAME} STATIC minitrace.c) ++add_library(${PROJECT_NAME} minitrace.c) + add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + + target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) + ++set_target_properties(${PROJECT_NAME} PROPERTIES ++ PUBLIC_HEADER minitrace.h ++ WINDOWS_EXPORT_ALL_SYMBOLS ON ++ C_EXTENSIONS OFF ++ C_STANDARD 99 ++) ++ + option(MTR_ENABLED "Enable minitrace" ON) + if(MTR_ENABLED) + target_compile_definitions(${PROJECT_NAME} PUBLIC MTR_ENABLED) +@@ -19,4 +26,14 @@ if(MTR_BUILD_TEST) + find_package(Threads) + add_executable(minitrace_test_mt minitrace_test_mt.cpp) + target_link_libraries(minitrace_test_mt ${PROJECT_NAME} Threads::Threads) +-endif() +\ No newline at end of file ++endif() ++ ++include(GNUInstallDirs) ++ ++install( ++ TARGETS ${PROJECT_NAME} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ++) diff --git a/recipes/minitrace/all/test_package/CMakeLists.txt b/recipes/minitrace/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a6a13090703c1 --- /dev/null +++ b/recipes/minitrace/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) + +project(test_package C) + +find_package(minitrace REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} minitrace::minitrace) diff --git a/recipes/minitrace/all/test_package/conanfile.py b/recipes/minitrace/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a18b32874e404 --- /dev/null +++ b/recipes/minitrace/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/minitrace/all/test_package/test_package.c b/recipes/minitrace/all/test_package/test_package.c new file mode 100644 index 0000000000000..522ac8ef4d331 --- /dev/null +++ b/recipes/minitrace/all/test_package/test_package.c @@ -0,0 +1,70 @@ +#include "minitrace.h" + +#ifdef _WIN32 +#include +#define usleep(x) Sleep(x/1000) +#else +#include +#endif + +void c() { + MTR_SCOPE("c++", "c()"); + usleep(10000); +} + +void b() { + MTR_SCOPE("c++", "b()"); + usleep(20000); + c(); + usleep(10000); +} + +void a() { + MTR_SCOPE("c++", "a()"); + usleep(20000); + b(); + usleep(10000); +} + +int main() { + int i; + mtr_init("trace.json"); + mtr_register_sigint_handler(); + + MTR_META_PROCESS_NAME("minitrace_test"); + MTR_META_THREAD_NAME("main thread"); + + int long_running_thing_1; + int long_running_thing_2; + + MTR_START("background", "long_running", &long_running_thing_1); + MTR_START("background", "long_running", &long_running_thing_2); + + MTR_COUNTER("main", "greebles", 3); + MTR_BEGIN("main", "outer"); + usleep(80000); + for (i = 0; i < 3; i++) { + MTR_BEGIN("main", "inner"); + usleep(40000); + MTR_END("main", "inner"); + usleep(10000); + MTR_COUNTER("main", "greebles", 3 * i + 10); + } + MTR_STEP("background", "long_running", &long_running_thing_1, "middle step"); + usleep(80000); + MTR_END("main", "outer"); + MTR_COUNTER("main", "greebles", 0); + + usleep(10000); + a(); + + usleep(50000); + MTR_INSTANT("main", "the end"); + usleep(10000); + MTR_FINISH("background", "long_running", &long_running_thing_1); + MTR_FINISH("background", "long_running", &long_running_thing_2); + + mtr_flush(); + mtr_shutdown(); + return 0; +} diff --git a/recipes/minitrace/all/test_v1_package/CMakeLists.txt b/recipes/minitrace/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..a96803edb197f --- /dev/null +++ b/recipes/minitrace/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(minitrace REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE minitrace::minitrace) diff --git a/recipes/minitrace/all/test_v1_package/conanfile.py b/recipes/minitrace/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..75c0cd81d2d2f --- /dev/null +++ b/recipes/minitrace/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +# pylint: skip-file +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/minitrace/config.yml b/recipes/minitrace/config.yml new file mode 100644 index 0000000000000..384492f581d34 --- /dev/null +++ b/recipes/minitrace/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210321": + folder: all diff --git a/recipes/miniupnpc/all/conandata.yml b/recipes/miniupnpc/all/conandata.yml new file mode 100644 index 0000000000000..c414f1ae3f3a4 --- /dev/null +++ b/recipes/miniupnpc/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "2.2.2": + url: "https://github.com/miniupnp/miniupnp/archive/refs/tags/miniupnpc_2_2_2.tar.gz" + sha256: "a598890cad635170dfce6281d71fc3052dee5c8220da0109281542156267c762" +patches: + "2.2.2": + - patch_file: "patches/0001-fix-cross-build-ios.patch" diff --git a/recipes/miniupnpc/all/conanfile.py b/recipes/miniupnpc/all/conanfile.py new file mode 100644 index 0000000000000..23ce55638aada --- /dev/null +++ b/recipes/miniupnpc/all/conanfile.py @@ -0,0 +1,87 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir +import os + +required_conan_version = ">=1.53.0" + + +class MiniupnpcConan(ConanFile): + name = "miniupnpc" + description = "UPnP client library/tool to access Internet Gateway Devices." + license = "BSD-3-Clause" + topics = ("upnp", "networking", "internet-gateway") + homepage = "https://github.com/miniupnp/miniupnp" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["UPNPC_BUILD_STATIC"] = not self.options.shared + tc.variables["UPNPC_BUILD_SHARED"] = self.options.shared + tc.variables["UPNPC_BUILD_TESTS"] = False + tc.variables["UPNPC_BUILD_SAMPLE"] = False + tc.variables["NO_GETADDRINFO"] = False + tc.variables["UPNPC_NO_INSTALL"] = False + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # Do not force PIC + replace_in_file(self, os.path.join(self.source_folder, "miniupnpc", "CMakeLists.txt"), + "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "miniupnpc")) + cmake.build() + + def package(self): + copy(self, "LICENSE", src=os.path.join(self.source_folder, "miniupnpc"), + dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "miniupnpc") + self.cpp_info.set_property("cmake_target_name", "miniupnpc::miniupnpc") + self.cpp_info.set_property("pkg_config_name", "miniupnpc") + prefix = "lib" if self.settings.os == "Windows" and not self.options.shared else "" + self.cpp_info.libs = [f"{prefix}miniupnpc"] + if not self.options.shared: + self.cpp_info.defines.append("MINIUPNP_STATICLIB") + if self.settings.os == "Windows": + self.cpp_info.system_libs = ["iphlpapi", "ws2_32"] + elif self.settings.os == "SunOS": + self.cpp_info.system_libs = ["socket", "nsl", "resolv"] diff --git a/recipes/miniupnpc/all/patches/0001-fix-cross-build-ios.patch b/recipes/miniupnpc/all/patches/0001-fix-cross-build-ios.patch new file mode 100644 index 0000000000000..d9b251737e11f --- /dev/null +++ b/recipes/miniupnpc/all/patches/0001-fix-cross-build-ios.patch @@ -0,0 +1,20 @@ +--- a/miniupnpc/CMakeLists.txt ++++ b/miniupnpc/CMakeLists.txt +@@ -29,7 +29,7 @@ if (NOT WIN32) + target_compile_definitions(miniupnpc-private INTERFACE + MINIUPNPC_SET_SOCKET_TIMEOUT + _BSD_SOURCE _DEFAULT_SOURCE) +- if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS") ++ if (NOT APPLE AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS") + # add_definitions (-D_POSIX_C_SOURCE=200112L) + target_compile_definitions(miniupnpc-private INTERFACE _XOPEN_SOURCE=600) + endif () +@@ -37,7 +37,7 @@ else () + target_compile_definitions(miniupnpc-private INTERFACE _WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends + endif () + +-if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") ++if (APPLE) + target_compile_definitions(miniupnpc-private INTERFACE _DARWIN_C_SOURCE) + endif () + diff --git a/recipes/miniupnpc/all/test_package/CMakeLists.txt b/recipes/miniupnpc/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..772ac228b58ae --- /dev/null +++ b/recipes/miniupnpc/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(miniupnpc REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE miniupnpc::miniupnpc) diff --git a/recipes/miniupnpc/all/test_package/conanfile.py b/recipes/miniupnpc/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/miniupnpc/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/miniupnpc/all/test_package/test_package.c b/recipes/miniupnpc/all/test_package/test_package.c new file mode 100644 index 0000000000000..b7ba38ffbf1f2 --- /dev/null +++ b/recipes/miniupnpc/all/test_package/test_package.c @@ -0,0 +1,12 @@ +#include + +int main(void) { + const char * multicastif = 0; + const char * minissdpdpath = 0; + int localport = UPNP_LOCAL_PORT_ANY; + int ipv6 = 0; + unsigned char ttl = 2; + int error = 0; + struct UPNPDev *devlist = upnpDiscover(2000, multicastif, minissdpdpath, localport, ipv6, ttl, &error); + return 0; +} diff --git a/recipes/miniupnpc/all/test_v1_package/CMakeLists.txt b/recipes/miniupnpc/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/miniupnpc/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/miniupnpc/all/test_v1_package/conanfile.py b/recipes/miniupnpc/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/miniupnpc/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/miniupnpc/config.yml b/recipes/miniupnpc/config.yml new file mode 100644 index 0000000000000..6d6cfc66eae07 --- /dev/null +++ b/recipes/miniupnpc/config.yml @@ -0,0 +1,3 @@ +versions: + "2.2.2": + folder: all diff --git a/recipes/miniz/all/CMakeLists.txt b/recipes/miniz/all/CMakeLists.txt deleted file mode 100644 index dc5a63385505d..0000000000000 --- a/recipes/miniz/all/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -if(WIN32 AND BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif(WIN32 AND BUILD_SHARED_LIBS) - -add_subdirectory("source_subfolder") diff --git a/recipes/miniz/all/conandata.yml b/recipes/miniz/all/conandata.yml index 506c690a6ccb7..809f38f903343 100644 --- a/recipes/miniz/all/conandata.yml +++ b/recipes/miniz/all/conandata.yml @@ -1,9 +1,15 @@ sources: + "3.0.1": + url: "https://github.com/richgel999/miniz/archive/refs/tags/3.0.1.tar.gz" + sha256: "53c29ed75bf1a9dd838349982ec8890f95269c422b17399d3880fd2d0f703af8" + "2.2.0": + url: "https://github.com/richgel999/miniz/archive/refs/tags/2.2.0.tar.gz" + sha256: "bd1136d0a1554520dcb527a239655777148d90fd2d51cf02c36540afc552e6ec" "2.1.0": url: "https://github.com/richgel999/miniz/archive/2.1.0.tar.gz" sha256: "95f9b23c92219ad2670389a23a4ed5723b7329c82c3d933b7047673ecdfc1fea" - patches: "2.1.0": - patch_file: "patches/2.1.0/001-remove-examples.patch" - base_path: "source_subfolder" + - patch_file: "patches/2.1.0/002-fix-shared-windows.patch" + - patch_file: "patches/2.1.0/003-include-miniz_zip.patch" diff --git a/recipes/miniz/all/conanfile.py b/recipes/miniz/all/conanfile.py index 012f4e9275caf..a90739b0d0d4e 100644 --- a/recipes/miniz/all/conanfile.py +++ b/recipes/miniz/all/conanfile.py @@ -1,5 +1,11 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import export_conandata_patches, apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.53.0" + class MinizConan(ConanFile): name = "miniz" @@ -7,56 +13,68 @@ class MinizConan(ConanFile): "implements the zlib (RFC 1950) and Deflate (RFC 1951) " \ "compressed data format specification standards" license = "MIT" - topics = ("conan", "miniz", "compression", "lossless") - homepage = "https://github.com/richgel999/miniz" url = "https://github.com/conan-io/conan-center-index" - exports_sources = "CMakeLists.txt", "patches/*" - generators = "cmake" + homepage = "https://github.com/richgel999/miniz" + topics = ("zlib", "compression", "lossless") settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) >= "2.2.0": + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_FUZZERS"] = False + tc.variables["AMALGAMATE_SOURCES"] = False + tc.variables["BUILD_HEADER_ONLY"] = False + tc.variables["INSTALL_PROJECT"] = True + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - self.copy(pattern="*.dll", dst="bin", src=os.path.join(self._build_subfolder, "bin"), keep_path=False) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - self.cpp_info.includedirs = ["include", os.path.join("include", "miniz")] + self.cpp_info.set_property("cmake_file_name", "miniz") + self.cpp_info.set_property("cmake_target_name", "miniz::miniz") + self.cpp_info.set_property("pkg_config_name", "miniz") + self.cpp_info.libs = ["miniz"] + self.cpp_info.includedirs.append(os.path.join("include", "miniz")) diff --git a/recipes/miniz/all/patches/2.1.0/001-remove-examples.patch b/recipes/miniz/all/patches/2.1.0/001-remove-examples.patch index a5e2401b6d2e3..8f9cfd0ef7b77 100644 --- a/recipes/miniz/all/patches/2.1.0/001-remove-examples.patch +++ b/recipes/miniz/all/patches/2.1.0/001-remove-examples.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index f3e453a..65ca6de 100644 +index f3e453a..4d8d385 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,31 +15,6 @@ set(miniz_SOURCE miniz.c miniz_zip.c miniz_tinfl.c miniz_tdef.c) @@ -34,10 +34,3 @@ index f3e453a..65ca6de 100644 # add_executable(miniz_tester ${MINIZ_TESTER_SRC_LIST}) # target_link_libraries(miniz_tester miniz) -@@ -49,4 +24,4 @@ install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets - LIBRARY DESTINATION lib - ) - file(GLOB INSTALL_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h) --install(FILES ${INSTALL_HEADERS} DESTINATION include/${PROJECT_NAME}) -\ No newline at end of file -+install(FILES ${INSTALL_HEADERS} DESTINATION include/${PROJECT_NAME}) diff --git a/recipes/miniz/all/patches/2.1.0/002-fix-shared-windows.patch b/recipes/miniz/all/patches/2.1.0/002-fix-shared-windows.patch new file mode 100644 index 0000000000000..dba1eeea002c2 --- /dev/null +++ b/recipes/miniz/all/patches/2.1.0/002-fix-shared-windows.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4d8d385..7db30dc 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,5 @@ ++cmake_minimum_required(VERSION 3.4) + PROJECT(miniz C) +-cmake_minimum_required(VERSION 2.8) + if(CMAKE_BUILD_TYPE STREQUAL "") + # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up + # differentiation between debug and release builds. +@@ -14,12 +14,14 @@ set(miniz_SOURCE miniz.c miniz_zip.c miniz_tinfl.c miniz_tdef.c) + + add_library(miniz ${miniz_SOURCE}) + target_include_directories(miniz PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") ++set_property(TARGET miniz PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) + + + # add_executable(miniz_tester ${MINIZ_TESTER_SRC_LIST}) + # target_link_libraries(miniz_tester miniz) + + install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets ++ RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + ) diff --git a/recipes/miniz/all/patches/2.1.0/003-include-miniz_zip.patch b/recipes/miniz/all/patches/2.1.0/003-include-miniz_zip.patch new file mode 100644 index 0000000000000..89caafe29a84c --- /dev/null +++ b/recipes/miniz/all/patches/2.1.0/003-include-miniz_zip.patch @@ -0,0 +1,8 @@ +--- a/miniz.h ++++ b/miniz.h +@@ -475,3 +475,5 @@ typedef void *const voidpc; + #ifdef __cplusplus + } + #endif ++ ++#include "miniz_zip.h" diff --git a/recipes/miniz/all/test_package/CMakeLists.txt b/recipes/miniz/all/test_package/CMakeLists.txt index 7b9b613cbb24a..90738d68add27 100644 --- a/recipes/miniz/all/test_package/CMakeLists.txt +++ b/recipes/miniz/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(miniz REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE miniz::miniz) diff --git a/recipes/miniz/all/test_package/conanfile.py b/recipes/miniz/all/test_package/conanfile.py index bd7165a553cf4..3a8c6c5442b33 100644 --- a/recipes/miniz/all/test_package/conanfile.py +++ b/recipes/miniz/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/miniz/all/test_v1_package/CMakeLists.txt b/recipes/miniz/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..63f78425e4d0b --- /dev/null +++ b/recipes/miniz/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(miniz REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE miniz::miniz) diff --git a/recipes/miniz/all/test_v1_package/conanfile.py b/recipes/miniz/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/miniz/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/miniz/config.yml b/recipes/miniz/config.yml index dfff490f9a9b6..0ccfce284e89c 100644 --- a/recipes/miniz/config.yml +++ b/recipes/miniz/config.yml @@ -1,3 +1,7 @@ versions: + "3.0.1": + folder: all + "2.2.0": + folder: all "2.1.0": folder: all diff --git a/recipes/minizip-ng/all/conandata.yml b/recipes/minizip-ng/all/conandata.yml index a4d915b5d5676..3c2038ac4c087 100644 --- a/recipes/minizip-ng/all/conandata.yml +++ b/recipes/minizip-ng/all/conandata.yml @@ -1,4 +1,77 @@ sources: + "3.0.7": + url: "https://github.com/zlib-ng/minizip-ng/archive/3.0.7.tar.gz" + sha256: "39981a0db1bb6da504909bce63d7493286c5e50825c056564544c990d15c55cf" + "3.0.6": + url: "https://github.com/zlib-ng/minizip-ng/archive/3.0.6.tar.gz" + sha256: "383fa1bdc28c482828a8a8db53f758dbd44291b641182724fda5df5b59cce543" + "3.0.5": + url: "https://github.com/zlib-ng/minizip-ng/archive/3.0.5.tar.gz" + sha256: "1a248c378fdf4ef6c517024bb65577603d5146cffaebe81900bec9c0a5035d4d" + "3.0.4": + url: "https://github.com/zlib-ng/minizip-ng/archive/3.0.4.tar.gz" + sha256: "2ab219f651901a337a7d3c268128711b80330a99ea36bdc528c76b591a624c3c" + "3.0.3": + url: "https://github.com/zlib-ng/minizip-ng/archive/3.0.3.tar.gz" + sha256: "5f1dd0d38adbe9785cb9c4e6e47738c109d73a0afa86e58c4025ce3e2cc504ed" + "3.0.2": + url: "https://github.com/zlib-ng/minizip-ng/archive/3.0.2.tar.gz" + sha256: "6ba4b6629c107c27ab526e517bdb105612232f0965a6747f60150e5a04c2fe5a" "3.0.1": url: "https://github.com/zlib-ng/minizip-ng/archive/3.0.1.tar.gz" sha256: "96c95b274dd535984ce0e87691691388f2b976106e8cf8d527b15da552ac94e4" +patches: + "3.0.7": + - patch_file: "patches/3.0.7-0001-fix-cmake-project.patch" + patch_description: "CMake: declare project() sooner" + patch_type: "conan" + - patch_file: "patches/3.0.6-0002-fix-lzma-libdir.patch" + patch_description: "CMake: inject libdir of lzma" + patch_type: "conan" + patch_source: "https://github.com/zlib-ng/minizip-ng/pull/658" + "3.0.6": + - patch_file: "patches/3.0.6-0001-fix-cmake-project.patch" + patch_description: "CMake: declare project() sooner" + patch_type: "conan" + - patch_file: "patches/3.0.6-0002-fix-lzma-libdir.patch" + patch_description: "CMake: inject libdir of lzma" + patch_type: "conan" + patch_source: "https://github.com/zlib-ng/minizip-ng/pull/658" + "3.0.5": + - patch_file: "patches/3.0.5-0001-fix-cmake-project.patch" + patch_description: "CMake: declare project() sooner" + patch_type: "conan" + - patch_file: "patches/3.0.5-0002-fix-lzma-libdir.patch" + patch_description: "CMake: inject libdir of lzma" + patch_type: "conan" + patch_source: "https://github.com/zlib-ng/minizip-ng/pull/658" + "3.0.4": + - patch_file: "patches/3.0.4-0001-fix-cmake-project.patch" + - patch_file: "patches/3.0.1-0002-fix-lzma-libdir.patch" + patch_description: "CMake: inject libdir of lzma" + patch_type: "conan" + patch_source: "https://github.com/zlib-ng/minizip-ng/pull/658" + "3.0.3": + - patch_file: "patches/3.0.3-0001-fix-cmake-project.patch" + patch_description: "CMake: declare project() sooner" + patch_type: "conan" + - patch_file: "patches/3.0.1-0002-fix-lzma-libdir.patch" + patch_description: "CMake: inject libdir of lzma" + patch_type: "conan" + patch_source: "https://github.com/zlib-ng/minizip-ng/pull/658" + "3.0.2": + - patch_file: "patches/3.0.2-0001-fix-cmake-project.patch" + patch_description: "CMake: declare project() sooner" + patch_type: "conan" + - patch_file: "patches/3.0.1-0002-fix-lzma-libdir.patch" + patch_description: "CMake: inject libdir of lzma" + patch_type: "conan" + patch_source: "https://github.com/zlib-ng/minizip-ng/pull/658" + "3.0.1": + - patch_file: "patches/3.0.1-0001-fix-cmake-project.patch" + patch_description: "CMake: declare project() sooner" + patch_type: "conan" + - patch_file: "patches/3.0.1-0002-fix-lzma-libdir.patch" + patch_description: "CMake: inject libdir of lzma" + patch_type: "conan" + patch_source: "https://github.com/zlib-ng/minizip-ng/pull/658" diff --git a/recipes/minizip-ng/all/conanfile.py b/recipes/minizip-ng/all/conanfile.py index 8c1edbe4e30cb..5b4369c3f4103 100644 --- a/recipes/minizip-ng/all/conanfile.py +++ b/recipes/minizip-ng/all/conanfile.py @@ -1,17 +1,25 @@ +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir +from conan.tools.gnu import PkgConfigDeps +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os -from conans import ConanFile, tools, CMake + +required_conan_version = ">=1.53.0" class MinizipNgConan(ConanFile): name = "minizip-ng" description = "Fork of the popular zip manipulation library found in the zlib distribution." - topics = ("conan", "compression", "zip") + topics = ("compression", "zip") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/zlib-ng/minizip-ng" license = "Zlib" - exports_sources = "CMakeLists.txt" - generators = "cmake", "cmake_find_package", "pkg_config" - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -39,102 +47,136 @@ class MinizipNgConan(ConanFile): "with_libcomp": True, } - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + def _is_clang_cl(self): + return self.settings.os == "Windows" and self.settings.compiler == "clang" @property - def _build_subfolder(self): - return "build_subfolder" + def _needs_pkg_config(self): + return self.options.with_lzma or self.options.with_zstd or self.options.with_openssl + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC del self.options.with_iconv del self.options.with_libbsd - if not tools.is_apple_os(self.settings.os): + if not is_apple_os(self): del self.options.with_libcomp - def build_requirements(self): - self.build_requires('pkgconf/1.7.3') - def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") if self.options.mz_compatibility: self.provides = "minizip" if self.options.get_safe("with_libcomp"): del self.options.with_zlib + def layout(self): + cmake_layout(self, src_folder="src") + def requirements(self): if self.options.get_safe("with_zlib"): - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.with_bzip2: self.requires("bzip2/1.0.8") if self.options.with_lzma: self.requires("xz_utils/5.2.5") if self.options.with_zstd: - self.requires("zstd/1.4.8") + self.requires("zstd/1.5.2") if self.options.with_openssl: - self.requires("openssl/1.1.1k") + self.requires("openssl/1.1.1s") if self.settings.os != "Windows": if self.options.get_safe("with_iconv"): - self.requires("libiconv/1.16") + self.requires("libiconv/1.17") - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["MZ_FETCH_LIBS"] = False - self._cmake.definitions["MZ_COMPAT"] = self.options.mz_compatibility - self._cmake.definitions["MZ_ZLIB"] = self.options.get_safe("with_zlib", False) - self._cmake.definitions["MZ_BZIP2"] = self.options.with_bzip2 - self._cmake.definitions["MZ_LZMA"] = self.options.with_lzma - self._cmake.definitions["MZ_ZSTD"] = self.options.with_zstd - self._cmake.definitions["MZ_OPENSSL"] = self.options.with_openssl - self._cmake.definitions["MZ_LIBCOMP"] = self.options.get_safe("with_libcomp", False) + def build_requirements(self): + if self._needs_pkg_config: + self.tool_requires("pkgconf/1.9.3") + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + if self._needs_pkg_config: + env = VirtualBuildEnv(self) + env.generate() + + tc = CMakeToolchain(self) + tc.cache_variables["MZ_FETCH_LIBS"] = False + tc.cache_variables["MZ_COMPAT"] = self.options.mz_compatibility + tc.cache_variables["MZ_ZLIB"] = self.options.get_safe("with_zlib", False) + tc.cache_variables["MZ_BZIP2"] = self.options.with_bzip2 + tc.cache_variables["MZ_LZMA"] = self.options.with_lzma + tc.cache_variables["MZ_ZSTD"] = self.options.with_zstd + tc.cache_variables["MZ_OPENSSL"] = self.options.with_openssl + tc.cache_variables["MZ_LIBCOMP"] = self.options.get_safe("with_libcomp", False) if self.settings.os != "Windows": - self._cmake.definitions["MZ_ICONV"] = self.options.with_iconv - self._cmake.definitions["MZ_LIBBSD"] = self.options.with_libbsd - - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + tc.cache_variables["MZ_ICONV"] = self.options.with_iconv + tc.cache_variables["MZ_LIBBSD"] = self.options.with_libbsd + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + if self._needs_pkg_config: + deps = PkgConfigDeps(self) + deps.generate() + # TODO: to remove when properly handled by conan (see https://github.com/conan-io/conan/issues/11962) + env = Environment() + env.prepend_path("PKG_CONFIG_PATH", self.generators_folder) + env.vars(self).save_script("conanbuild_pkg_config_path") def _patch_sources(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + apply_conandata_patches(self) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1)", "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "minizip") + self.cpp_info.set_property("cmake_target_name", "MINIZIP::minizip") + self.cpp_info.set_property("pkg_config_name", "minizip") + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + prefix = "lib" if is_msvc(self) or self._is_clang_cl else "" + suffix = "" if Version(self.version) < "3.0.5" or self.options.mz_compatibility else "-ng" + self.cpp_info.components["minizip"].libs = [f"{prefix}minizip{suffix}"] + if self.options.with_lzma: + self.cpp_info.components["minizip"].defines.append("HAVE_LZMA") + if is_apple_os(self) and self.options.get_safe("with_libcomp"): + self.cpp_info.components["minizip"].defines.append("HAVE_LIBCOMP") + if self.options.with_bzip2: + self.cpp_info.components["minizip"].defines.append("HAVE_BZIP2") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.filenames["cmake_find_package"] = "minizip" self.cpp_info.filenames["cmake_find_package_multi"] = "minizip" self.cpp_info.names["cmake_find_package"] = "MINIZIP" self.cpp_info.names["cmake_find_package_multi"] = "MINIZIP" - self.cpp_info.names["pkg_config"] = "minizip" self.cpp_info.components["minizip"].names["cmake_find_package"] = "minizip" self.cpp_info.components["minizip"].names["cmake_find_package_multi"] = "minizip" - self.cpp_info.components["minizip"].libs = tools.collect_libs(self) - + self.cpp_info.components["minizip"].set_property("cmake_target_name", "MINIZIP::minizip") + self.cpp_info.components["minizip"].set_property("pkg_config_name", "minizip") if self.options.get_safe("with_zlib"): self.cpp_info.components["minizip"].requires.append("zlib::zlib") if self.options.with_bzip2: @@ -147,10 +189,3 @@ def package_info(self): self.cpp_info.components["minizip"].requires.append("openssl::openssl") if self.settings.os != "Windows" and self.options.with_iconv: self.cpp_info.components["minizip"].requires.append("libiconv::libiconv") - - if self.options.with_lzma: - self.cpp_info.components["minizip"].defines.append('HAVE_LZMA') - if tools.is_apple_os(self.settings.os) and self.options.get_safe("with_libcomp"): - self.cpp_info.components["minizip"].defines.append('HAVE_LIBCOMP') - if self.options.with_bzip2: - self.cpp_info.components["minizip"].defines.append('HAVE_BZIP2') diff --git a/recipes/minizip-ng/all/patches/3.0.1-0001-fix-cmake-project.patch b/recipes/minizip-ng/all/patches/3.0.1-0001-fix-cmake-project.patch new file mode 100644 index 0000000000000..c44b1784ce620 --- /dev/null +++ b/recipes/minizip-ng/all/patches/3.0.1-0001-fix-cmake-project.patch @@ -0,0 +1,22 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -63,10 +63,10 @@ endif() + # BZIP2_ROOT - Parent directory of BZip2 installation + # OPENSSL_ROOT - Parent directory of OpenSSL installation + +-enable_language(C) + + # Library version + set(VERSION "3.0.1") ++project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION} LANGUAGES C) + + # API version + set(SOVERSION "3.0") +@@ -677,7 +677,6 @@ endif() + list(APPEND MINIZIP_INC ${CMAKE_CURRENT_SOURCE_DIR}) + + # Create minizip library +-project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION}) + + if(NOT ${MZ_PROJECT_SUFFIX} STREQUAL "") + message(STATUS "Project configured as ${PROJECT_NAME}") diff --git a/recipes/minizip-ng/all/patches/3.0.1-0002-fix-lzma-libdir.patch b/recipes/minizip-ng/all/patches/3.0.1-0002-fix-lzma-libdir.patch new file mode 100644 index 0000000000000..cb1ecba6e8149 --- /dev/null +++ b/recipes/minizip-ng/all/patches/3.0.1-0002-fix-lzma-libdir.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -312,6 +312,7 @@ if(MZ_LZMA) + + list(APPEND MINIZIP_INC ${LIBLZMA_INCLUDE_DIRS}) + list(APPEND MINIZIP_LIB ${LIBLZMA_LIBRARIES}) ++ list(APPEND MINIZIP_LBD ${LIBLZMA_LIBRARY_DIRS}) + + set(PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -lliblzma") + elseif(MZ_FETCH_LIBS) diff --git a/recipes/minizip-ng/all/patches/3.0.2-0001-fix-cmake-project.patch b/recipes/minizip-ng/all/patches/3.0.2-0001-fix-cmake-project.patch new file mode 100644 index 0000000000000..8cfa267f8cff7 --- /dev/null +++ b/recipes/minizip-ng/all/patches/3.0.2-0001-fix-cmake-project.patch @@ -0,0 +1,22 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -63,10 +63,10 @@ endif() + # BZIP2_ROOT - Parent directory of BZip2 installation + # OPENSSL_ROOT - Parent directory of OpenSSL installation + +-enable_language(C) + + # Library version + set(VERSION "3.0.2") ++project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION} LANGUAGES C) + + # API version + set(SOVERSION "3.0") +@@ -681,7 +681,6 @@ endif() + list(APPEND MINIZIP_INC ${CMAKE_CURRENT_SOURCE_DIR}) + + # Create minizip library +-project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION}) + + if(NOT ${MZ_PROJECT_SUFFIX} STREQUAL "") + message(STATUS "Project configured as ${PROJECT_NAME}") diff --git a/recipes/minizip-ng/all/patches/3.0.3-0001-fix-cmake-project.patch b/recipes/minizip-ng/all/patches/3.0.3-0001-fix-cmake-project.patch new file mode 100644 index 0000000000000..484eb23a91671 --- /dev/null +++ b/recipes/minizip-ng/all/patches/3.0.3-0001-fix-cmake-project.patch @@ -0,0 +1,22 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -63,10 +63,10 @@ endif() + # BZIP2_ROOT - Parent directory of BZip2 installation + # OPENSSL_ROOT - Parent directory of OpenSSL installation + +-enable_language(C) + + # Library version + set(VERSION "3.0.3") ++project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION} LANGUAGES C) + + # API version + set(SOVERSION "3") +@@ -681,7 +681,6 @@ endif() + list(APPEND MINIZIP_INC ${CMAKE_CURRENT_SOURCE_DIR}) + + # Create minizip library +-project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION}) + + if(NOT ${MZ_PROJECT_SUFFIX} STREQUAL "") + message(STATUS "Project configured as ${PROJECT_NAME}") diff --git a/recipes/minizip-ng/all/patches/3.0.4-0001-fix-cmake-project.patch b/recipes/minizip-ng/all/patches/3.0.4-0001-fix-cmake-project.patch new file mode 100644 index 0000000000000..5ae134194c263 --- /dev/null +++ b/recipes/minizip-ng/all/patches/3.0.4-0001-fix-cmake-project.patch @@ -0,0 +1,22 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -63,10 +63,10 @@ endif() + # BZIP2_ROOT - Parent directory of BZip2 installation + # OPENSSL_ROOT - Parent directory of OpenSSL installation + +-enable_language(C) + + # Library version + set(VERSION "3.0.4") ++project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION} LANGUAGES C) + + # API version + set(SOVERSION "3") +@@ -681,7 +681,6 @@ endif() + list(APPEND MINIZIP_INC ${CMAKE_CURRENT_SOURCE_DIR}) + + # Create minizip library +-project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION}) + + if(NOT ${MZ_PROJECT_SUFFIX} STREQUAL "") + message(STATUS "Project configured as ${PROJECT_NAME}") diff --git a/recipes/minizip-ng/all/patches/3.0.5-0001-fix-cmake-project.patch b/recipes/minizip-ng/all/patches/3.0.5-0001-fix-cmake-project.patch new file mode 100644 index 0000000000000..bc28f8055105e --- /dev/null +++ b/recipes/minizip-ng/all/patches/3.0.5-0001-fix-cmake-project.patch @@ -0,0 +1,22 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -66,10 +66,10 @@ endif() + # BZIP2_ROOT - Parent directory of BZip2 installation + # OPENSSL_ROOT - Parent directory of OpenSSL installation + +-enable_language(C) + + # Library version + set(VERSION "3.0.5") ++project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION} LANGUAGES C) + + # API version + set(SOVERSION "3") +@@ -661,7 +661,6 @@ endif() + list(APPEND MINIZIP_INC ${CMAKE_CURRENT_SOURCE_DIR}) + + # Create minizip library +-project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION}) + + if(NOT ${MZ_PROJECT_SUFFIX} STREQUAL "") + message(STATUS "Project configured as ${PROJECT_NAME}") diff --git a/recipes/minizip-ng/all/patches/3.0.5-0002-fix-lzma-libdir.patch b/recipes/minizip-ng/all/patches/3.0.5-0002-fix-lzma-libdir.patch new file mode 100644 index 0000000000000..0e4b01050297b --- /dev/null +++ b/recipes/minizip-ng/all/patches/3.0.5-0002-fix-lzma-libdir.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -303,6 +303,7 @@ if(MZ_LZMA) + + list(APPEND MINIZIP_INC ${LIBLZMA_INCLUDE_DIRS}) + list(APPEND MINIZIP_LIB ${LIBLZMA_LIBRARIES}) ++ list(APPEND MINIZIP_LBD ${LIBLZMA_LIBRARY_DIRS}) + + set(PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -lliblzma") + elseif(MZ_FETCH_LIBS) diff --git a/recipes/minizip-ng/all/patches/3.0.6-0001-fix-cmake-project.patch b/recipes/minizip-ng/all/patches/3.0.6-0001-fix-cmake-project.patch new file mode 100644 index 0000000000000..e08990e93540e --- /dev/null +++ b/recipes/minizip-ng/all/patches/3.0.6-0001-fix-cmake-project.patch @@ -0,0 +1,18 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -70,6 +70,7 @@ enable_language(C) + + # Library version + set(VERSION "3.0.6") ++project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION} LANGUAGES C) + + # API version + set(SOVERSION "3") +@@ -663,7 +664,6 @@ endif() + list(APPEND MINIZIP_INC ${CMAKE_CURRENT_SOURCE_DIR}) + + # Create minizip library +-project(minizip${MZ_PROJECT_SUFFIX} LANGUAGES C VERSION ${VERSION}) + + if(NOT ${MZ_PROJECT_SUFFIX} STREQUAL "") + message(STATUS "Project configured as ${PROJECT_NAME}") diff --git a/recipes/minizip-ng/all/patches/3.0.6-0002-fix-lzma-libdir.patch b/recipes/minizip-ng/all/patches/3.0.6-0002-fix-lzma-libdir.patch new file mode 100644 index 0000000000000..5e74ea2fc0802 --- /dev/null +++ b/recipes/minizip-ng/all/patches/3.0.6-0002-fix-lzma-libdir.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -304,6 +304,7 @@ if(MZ_LZMA) + + list(APPEND MINIZIP_INC ${LIBLZMA_INCLUDE_DIRS}) + list(APPEND MINIZIP_LIB ${LIBLZMA_LIBRARIES}) ++ list(APPEND MINIZIP_LBD ${LIBLZMA_LIBRARY_DIRS}) + + set(PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -lliblzma") + elseif(MZ_FETCH_LIBS) diff --git a/recipes/minizip-ng/all/patches/3.0.7-0001-fix-cmake-project.patch b/recipes/minizip-ng/all/patches/3.0.7-0001-fix-cmake-project.patch new file mode 100644 index 0000000000000..5f9e5f69169bc --- /dev/null +++ b/recipes/minizip-ng/all/patches/3.0.7-0001-fix-cmake-project.patch @@ -0,0 +1,18 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -70,6 +70,7 @@ enable_language(C) + + # Library version + set(VERSION "3.0.7") ++project(minizip${MZ_PROJECT_SUFFIX} VERSION ${VERSION} LANGUAGES C) + + # API version + set(SOVERSION "3") +@@ -670,7 +671,6 @@ endif() + list(APPEND MINIZIP_INC ${CMAKE_CURRENT_SOURCE_DIR}) + + # Create minizip library +-project(minizip${MZ_PROJECT_SUFFIX} LANGUAGES C VERSION ${VERSION}) + + if(NOT ${MZ_PROJECT_SUFFIX} STREQUAL "") + message(STATUS "Project configured as ${PROJECT_NAME}") diff --git a/recipes/minizip-ng/all/test_package/CMakeLists.txt b/recipes/minizip-ng/all/test_package/CMakeLists.txt index 1ed43d2c4ed8d..db0b9a15e540e 100644 --- a/recipes/minizip-ng/all/test_package/CMakeLists.txt +++ b/recipes/minizip-ng/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(minizip CONFIG REQUIRED) +find_package(minizip REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} MINIZIP::minizip) -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) +target_link_libraries(${PROJECT_NAME} PRIVATE MINIZIP::minizip) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) diff --git a/recipes/minizip-ng/all/test_package/conanfile.py b/recipes/minizip-ng/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/minizip-ng/all/test_package/conanfile.py +++ b/recipes/minizip-ng/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/minizip-ng/all/test_v1_package/CMakeLists.txt b/recipes/minizip-ng/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/minizip-ng/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/minizip-ng/all/test_v1_package/conanfile.py b/recipes/minizip-ng/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/minizip-ng/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/minizip-ng/config.yml b/recipes/minizip-ng/config.yml index f1eca9cdf76de..60ae0e8c451f8 100644 --- a/recipes/minizip-ng/config.yml +++ b/recipes/minizip-ng/config.yml @@ -1,3 +1,15 @@ versions: + "3.0.7": + folder: all + "3.0.6": + folder: all + "3.0.5": + folder: all + "3.0.4": + folder: all + "3.0.3": + folder: all + "3.0.2": + folder: all "3.0.1": folder: all diff --git a/recipes/minizip/1.2.11/CMakeLists.txt b/recipes/minizip/1.2.11/CMakeLists.txt deleted file mode 100644 index 73e32af77da35..0000000000000 --- a/recipes/minizip/1.2.11/CMakeLists.txt +++ /dev/null @@ -1,82 +0,0 @@ -# This CMake file has been extracted from VCPKG and is under MIT license: -# https://github.com/microsoft/vcpkg/blob/master/ports/minizip/CMakeLists.txt -cmake_minimum_required(VERSION 3.8) -project(minizip C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -set(PROJECT_VERSION 1.2.11) -set(PROJECT_VERSION_MAJOR 1) -set(PROJECT_VERSION_MINOR 2) -set(PROJECT_VERSION_PATCH 11) - -option(USE_BZIP2 "Build minizip with bzip2 support" ON) -option(BUILD_TOOLS "Build minizip tool" OFF) - -if (MSVC AND WIN32 AND BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - -set(MIN_SRC "${CMAKE_CURRENT_SOURCE_DIR}/contrib/minizip") -include_directories(${MIN_SRC} ${ZLIB_INCLUDE_DIRS}) - -set(SOURCE_FILES - ${MIN_SRC}/ioapi.c - ${MIN_SRC}/unzip.c - ${MIN_SRC}/zip.c - ${MIN_SRC}/mztools.c -) -if(WIN32) - list(APPEND SOURCE_FILES ${MIN_SRC}/iowin32.c) -endif() - -set(HEADER_FILES - ${MIN_SRC}/crypt.h - ${MIN_SRC}/ioapi.h - ${MIN_SRC}/unzip.h - ${MIN_SRC}/zip.h - ${MIN_SRC}/mztools.h -) -if(WIN32) - list(APPEND HEADER_FILES ${MIN_SRC}/iowin32.h) -endif() - -add_library(minizip ${SOURCE_FILES} ${HEADER_FILES}) -target_link_libraries(minizip PUBLIC ${CONAN_LIBS}) -target_compile_definitions(minizip PRIVATE -D_ZLIB_H) - -if(ENABLE_BZIP2) - target_compile_definitions(minizip PRIVATE -DHAVE_BZIP2=1) -endif() -if(MSVC) - target_compile_options(minizip PUBLIC /W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS) -endif() - -if (BUILD_TOOLS) - add_executable(minizip_bin ${MIN_SRC}/minizip.c) - add_executable(miniunz_bin ${MIN_SRC}/miniunz.c) - - target_link_libraries(minizip_bin minizip ${CONAN_LIBS}) - target_link_libraries(miniunz_bin minizip ${CONAN_LIBS}) - - set_target_properties(minizip_bin PROPERTIES OUTPUT_NAME minizip) - set_target_properties(miniunz_bin PROPERTIES OUTPUT_NAME miniunz) - - if(MSVC) - target_compile_options(minizip_bin PUBLIC /W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS) - target_compile_options(miniunz_bin PUBLIC /W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS) - endif() - - install (TARGETS minizip_bin miniunz_bin - RUNTIME DESTINATION bin) -endif() - -install( - TARGETS minizip - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) - -install(FILES ${HEADER_FILES} DESTINATION include/minizip) diff --git a/recipes/minizip/1.2.11/conandata.yml b/recipes/minizip/1.2.11/conandata.yml deleted file mode 100644 index b78fc6385ddd8..0000000000000 --- a/recipes/minizip/1.2.11/conandata.yml +++ /dev/null @@ -1,4 +0,0 @@ -sources: - "1.2.11": - sha256: 629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff - url: https://github.com/madler/zlib/archive/v1.2.11.tar.gz diff --git a/recipes/minizip/1.2.11/conanfile.py b/recipes/minizip/1.2.11/conanfile.py deleted file mode 100644 index 023eda52718ce..0000000000000 --- a/recipes/minizip/1.2.11/conanfile.py +++ /dev/null @@ -1,70 +0,0 @@ -import os -import shutil -from conans import ConanFile, tools, CMake - - -class MinizipConan(ConanFile): - name = "minizip" - version = "1.2.11" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://zlib.net" - license = "Zlib" - description = "An experimental package to read and write files in .zip format, written on top of zlib" - topics = ("zip", "compression", "inflate") - settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "fPIC": [True, False], "bzip2": [True, False], "tools": [True, False]} - default_options = {"shared": False, "fPIC": True, "bzip2": True, "tools": False} - exports_sources = ["CMakeLists.txt", "*.patch"] - generators = "cmake", "cmake_find_package" - - @property - def _source_subfolder(self): - return "source_subfolder" - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd - - def requirements(self): - self.requires("zlib/1.2.11") - if self.options.bzip2: - self.requires("bzip2/1.0.8") - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("zlib-{}".format(self.version), self._source_subfolder) - - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["ENABLE_BZIP2"] = self.options.bzip2 - cmake.definitions["BUILD_TOOLS"] = self.options.tools - cmake.configure(source_folder=self._source_subfolder) - return cmake - - def build(self): - tools.patch(patch_file="minizip.patch", base_path=self._source_subfolder) - shutil.move("CMakeLists.txt", os.path.join(self._source_subfolder, 'CMakeLists.txt')) - cmake = self._configure_cmake() - cmake.build() - - def _extract_license(self): - with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)): - tmp = tools.load("zlib.h") - license_contents = tmp[2:tmp.find("*/", 1)] - tools.save("LICENSE", license_contents) - - def package(self): - self._extract_license() - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() - cmake.install() - - def package_info(self): - self.cpp_info.libs = ["minizip"] - self.cpp_info.includedirs = ["include", os.path.join("include", "minizip")] - if self.options.bzip2: - self.cpp_info.defines.append('HAVE_BZIP2') diff --git a/recipes/minizip/1.2.11/test_package/CMakeLists.txt b/recipes/minizip/1.2.11/test_package/CMakeLists.txt deleted file mode 100644 index 09de6a3c30cba..0000000000000 --- a/recipes/minizip/1.2.11/test_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.0) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_executable(test_package test_package.c) -target_link_libraries(test_package ${CONAN_LIBS}) diff --git a/recipes/minizip/1.2.11/test_package/conanfile.py b/recipes/minizip/1.2.11/test_package/conanfile.py deleted file mode 100644 index 4d75291c652bc..0000000000000 --- a/recipes/minizip/1.2.11/test_package/conanfile.py +++ /dev/null @@ -1,18 +0,0 @@ -import os -from conans import ConanFile, CMake, tools - - -class TestZlibConan(ConanFile): - settings = "os", "compiler", "arch", "build_type" - generators = "cmake" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - diff --git a/recipes/minizip/1.2.11/test_package/test_package.c b/recipes/minizip/1.2.11/test_package/test_package.c deleted file mode 100644 index 4660d0af60925..0000000000000 --- a/recipes/minizip/1.2.11/test_package/test_package.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include - -#include -#include -#ifdef _WIN32 - #include -#endif - -#include -#include - -const char text[] = "Conveying or northward offending admitting perfectly my."; -const char* zip_fname = "test_minizip.zip"; - -int main(int argc, char** argv) { - zipFile zf = zipOpen64(zip_fname, APPEND_STATUS_CREATE); - if (zf == NULL) { - printf("Error in zipOpen64, fname: %s\n", zip_fname); - exit(EXIT_FAILURE); - } - - int res; - zip_fileinfo zfi = {0}; - res = zipOpenNewFileInZip64(zf, "fname.bin", &zfi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_BEST_COMPRESSION, 0); - if (res != ZIP_OK) { - printf("Error in zipOpenNewFileInZip64, code: %d\n", res); - exit(EXIT_FAILURE); - } - - res = zipWriteInFileInZip(zf, text, sizeof(text)); - if (res != ZIP_OK) { - printf("Error in zipWriteInFileInZip, code: %d\n", res); - exit(EXIT_FAILURE); - } - - res = zipCloseFileInZip(zf); - if (res != ZIP_OK) { - printf("Error in zipCloseFileInZip, code: %d\n", res); - exit(EXIT_FAILURE); - } - - res = zipClose(zf, "Test MiniZip"); - if(res != ZIP_OK) { - printf("Error in zipClose, code: %d\n", res); - exit(EXIT_FAILURE); - } - - printf("ZIP file created, name: %s\n", zip_fname); - - return EXIT_SUCCESS; -} - diff --git a/recipes/minizip/all/CMakeLists.txt b/recipes/minizip/all/CMakeLists.txt new file mode 100644 index 0000000000000..c17b5f7dd7466 --- /dev/null +++ b/recipes/minizip/all/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 3.4) +project(minizip LANGUAGES C) + +option(MINIZIP_ENABLE_BZIP2 "Build minizip with bzip2 support" ON) +option(MINIZIP_BUILD_TOOLS "Build minizip tool" OFF) + +include(GNUInstallDirs) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") + +find_package(ZLIB REQUIRED) +if(MINIZIP_ENABLE_BZIP2) + find_package(BZip2 REQUIRED) +endif() + +set(SOURCE_FILES + ${MINIZIP_SRC_DIR}/ioapi.c + ${MINIZIP_SRC_DIR}/unzip.c + ${MINIZIP_SRC_DIR}/zip.c + ${MINIZIP_SRC_DIR}/mztools.c +) +if(WIN32) + list(APPEND SOURCE_FILES ${MINIZIP_SRC_DIR}/iowin32.c) +endif() + +set(HEADER_FILES + ${MINIZIP_SRC_DIR}/ioapi.h + ${MINIZIP_SRC_DIR}/unzip.h + ${MINIZIP_SRC_DIR}/zip.h + ${MINIZIP_SRC_DIR}/mztools.h +) +if(WIN32) + list(APPEND HEADER_FILES ${MINIZIP_SRC_DIR}/iowin32.h) +endif() + +add_library(minizip ${SOURCE_FILES}) +target_link_libraries(minizip PUBLIC ZLIB::ZLIB) +target_compile_definitions(minizip PRIVATE -D_ZLIB_H) +target_include_directories(minizip PUBLIC ${MINIZIP_SRC_DIR}) +set_target_properties(minizip PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + +if(MINIZIP_ENABLE_BZIP2) + target_compile_definitions(minizip PUBLIC HAVE_BZIP2=1) + target_link_libraries(minizip PUBLIC BZip2::BZip2) +endif() +if(MSVC) + target_compile_options(minizip PRIVATE /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS) +endif() + +install( + TARGETS minizip + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/minizip) + +if(MINIZIP_BUILD_TOOLS) + add_executable(minizip_bin ${MINIZIP_SRC_DIR}/minizip.c) + add_executable(miniunz_bin ${MINIZIP_SRC_DIR}/miniunz.c) + + target_link_libraries(minizip_bin PRIVATE minizip) + target_link_libraries(miniunz_bin PRIVATE minizip) + + set_target_properties(minizip_bin PROPERTIES OUTPUT_NAME minizip) + set_target_properties(miniunz_bin PROPERTIES OUTPUT_NAME miniunz) + + if(MSVC) + target_compile_options(minizip_bin PRIVATE /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS) + target_compile_options(miniunz_bin PRIVATE /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS) + endif() + + install(TARGETS minizip_bin miniunz_bin DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/recipes/minizip/all/conandata.yml b/recipes/minizip/all/conandata.yml new file mode 100644 index 0000000000000..9a323696f005f --- /dev/null +++ b/recipes/minizip/all/conandata.yml @@ -0,0 +1,19 @@ +sources: + "1.2.13": + url: "https://github.com/madler/zlib/archive/refs/tags/v1.2.13.tar.gz" + sha256: "1525952a0a567581792613a9723333d7f8cc20b87a81f920fb8bc7e3f2251428" + "1.2.12": + url: "https://github.com/madler/zlib/archive/refs/tags/v1.2.12.tar.gz" + sha256: "d8688496ea40fb61787500e863cc63c9afcbc524468cedeb478068924eb54932" + "1.2.11": + url: "https://github.com/madler/zlib/archive/v1.2.11.tar.gz" + sha256: "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff" +patches: + "1.2.13": + - patch_file: "patches/minizip.patch" + "1.2.12": + - patch_file: "patches/minizip.patch" + - patch_file: "patches/ioapi.patch" + "1.2.11": + - patch_file: "patches/minizip.patch" + - patch_file: "patches/miniunz.patch" diff --git a/recipes/minizip/all/conanfile.py b/recipes/minizip/all/conanfile.py new file mode 100644 index 0000000000000..8786a7f6a46e7 --- /dev/null +++ b/recipes/minizip/all/conanfile.py @@ -0,0 +1,97 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, load, save +import os + +required_conan_version = ">=1.52.0" + + +class MinizipConan(ConanFile): + name = "minizip" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://zlib.net" + license = "Zlib" + description = "An experimental package to read and write files in .zip format, written on top of zlib" + topics = ("zip", "compression", "inflate") + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "bzip2": [True, False], + "tools": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "bzip2": True, + "tools": False, + } + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("zlib/1.2.13") + if self.options.bzip2: + self.requires("bzip2/1.0.8") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MINIZIP_SRC_DIR"] = os.path.join(self.source_folder, "contrib", "minizip").replace("\\", "/") + tc.variables["MINIZIP_ENABLE_BZIP2"] = self.options.bzip2 + tc.variables["MINIZIP_BUILD_TOOLS"] = self.options.tools + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def _extract_license(self): + zlib_h = load(self, os.path.join(self.source_folder, "zlib.h")) + return zlib_h[2:zlib_h.find("*/", 1)] + + def package(self): + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license()) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["minizip"] + self.cpp_info.includedirs.append(os.path.join("include", "minizip")) + if self.options.bzip2: + self.cpp_info.defines.append("HAVE_BZIP2") + + if self.options.tools: + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/minizip/all/patches/ioapi.patch b/recipes/minizip/all/patches/ioapi.patch new file mode 100644 index 0000000000000..8ab56b08bf0aa --- /dev/null +++ b/recipes/minizip/all/patches/ioapi.patch @@ -0,0 +1,102 @@ +--- a/contrib/minizip/ioapi.c ++++ b/contrib/minizip/ioapi.c +@@ -94,9 +94,9 @@ static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); + + static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) + { +- (void)opaque; + FILE* file = NULL; + const char* mode_fopen = NULL; ++ (void)opaque; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = "rb"; + else +@@ -113,9 +113,9 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in + + static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) + { +- (void)opaque; + FILE* file = NULL; + const char* mode_fopen = NULL; ++ (void)opaque; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = "rb"; + else +@@ -133,24 +133,24 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, + + static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) + { +- (void)opaque; + uLong ret; ++ (void)opaque; + ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); + return ret; + } + + static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) + { +- (void)opaque; + uLong ret; ++ (void)opaque; + ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); + return ret; + } + + static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) + { +- (void)opaque; + long ret; ++ (void)opaque; + ret = ftell((FILE *)stream); + return ret; + } +@@ -158,17 +158,17 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) + + static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) + { +- (void)opaque; + ZPOS64_T ret; ++ (void)opaque; + ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream); + return ret; + } + + static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) + { +- (void)opaque; + int fseek_origin=0; + long ret; ++ (void)opaque; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : +@@ -190,9 +190,9 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs + + static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) + { +- (void)opaque; + int fseek_origin=0; + long ret; ++ (void)opaque; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : +@@ -217,16 +217,16 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T + + static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) + { +- (void)opaque; + int ret; ++ (void)opaque; + ret = fclose((FILE *)stream); + return ret; + } + + static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) + { +- (void)opaque; + int ret; ++ (void)opaque; + ret = ferror((FILE *)stream); + return ret; + } diff --git a/recipes/minizip/all/patches/miniunz.patch b/recipes/minizip/all/patches/miniunz.patch new file mode 100644 index 0000000000000..a9b42551ba7c7 --- /dev/null +++ b/recipes/minizip/all/patches/miniunz.patch @@ -0,0 +1,11 @@ +--- a/contrib/minizip/miniunz.c ++++ b/contrib/minizip/miniunz.c +@@ -52,6 +52,8 @@ + #else + # include + # include ++#include ++#include + #endif + + diff --git a/recipes/minizip/1.2.11/minizip.patch b/recipes/minizip/all/patches/minizip.patch similarity index 100% rename from recipes/minizip/1.2.11/minizip.patch rename to recipes/minizip/all/patches/minizip.patch diff --git a/recipes/minizip/all/test_package/CMakeLists.txt b/recipes/minizip/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b56bb073cf606 --- /dev/null +++ b/recipes/minizip/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(minizip REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE minizip::minizip) diff --git a/recipes/minizip/all/test_package/conanfile.py b/recipes/minizip/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/minizip/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/minizip/all/test_package/test_package.c b/recipes/minizip/all/test_package/test_package.c new file mode 100644 index 0000000000000..46d12fc8ea16c --- /dev/null +++ b/recipes/minizip/all/test_package/test_package.c @@ -0,0 +1,52 @@ +#include +#include +#include + +#include +#include +#ifdef _WIN32 + #include +#endif + +#include + +const char text[] = "Conveying or northward offending admitting perfectly my."; +const char* zip_fname = "test_minizip.zip"; + +int main(int argc, char** argv) { + zipFile zf = zipOpen64(zip_fname, APPEND_STATUS_CREATE); + if (zf == NULL) { + printf("Error in zipOpen64, fname: %s\n", zip_fname); + exit(EXIT_FAILURE); + } + + int res; + zip_fileinfo zfi = {0}; + res = zipOpenNewFileInZip64(zf, "fname.bin", &zfi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_BEST_COMPRESSION, 0); + if (res != ZIP_OK) { + printf("Error in zipOpenNewFileInZip64, code: %d\n", res); + exit(EXIT_FAILURE); + } + + res = zipWriteInFileInZip(zf, text, sizeof(text)); + if (res != ZIP_OK) { + printf("Error in zipWriteInFileInZip, code: %d\n", res); + exit(EXIT_FAILURE); + } + + res = zipCloseFileInZip(zf); + if (res != ZIP_OK) { + printf("Error in zipCloseFileInZip, code: %d\n", res); + exit(EXIT_FAILURE); + } + + res = zipClose(zf, "Test MiniZip"); + if(res != ZIP_OK) { + printf("Error in zipClose, code: %d\n", res); + exit(EXIT_FAILURE); + } + + printf("ZIP file created, name: %s\n", zip_fname); + + return EXIT_SUCCESS; +} diff --git a/recipes/minizip/all/test_v1_package/CMakeLists.txt b/recipes/minizip/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/minizip/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/minizip/all/test_v1_package/conanfile.py b/recipes/minizip/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/minizip/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/minizip/config.yml b/recipes/minizip/config.yml new file mode 100644 index 0000000000000..351c06f68201f --- /dev/null +++ b/recipes/minizip/config.yml @@ -0,0 +1,7 @@ +versions: + "1.2.13": + folder: all + "1.2.12": + folder: all + "1.2.11": + folder: all diff --git a/recipes/mio/all/conandata.yml b/recipes/mio/all/conandata.yml new file mode 100644 index 0000000000000..397893683b684 --- /dev/null +++ b/recipes/mio/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "cci.20201220": + url: "https://github.com/mandreyel/mio/archive/3f86a95c0784d73ce6815237ec33ed25f233b643.tar.gz" + sha256: "056ae59d63c5d7f34dd90510adf2996ef1c4c17ec2b26ba9c9cb9974025b2c2c" +patches: + "cci.20201220": + - patch_file: "patches/0001-fix-include-windows.patch" + patch_source: "https://github.com/mandreyel/mio/pull/73" diff --git a/recipes/mio/all/conanfile.py b/recipes/mio/all/conanfile.py new file mode 100644 index 0000000000000..469a34156ae79 --- /dev/null +++ b/recipes/mio/all/conanfile.py @@ -0,0 +1,70 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.50.0" + + +class MioConan(ConanFile): + name = "mio" + description = "Cross-platform C++11 header-only library for memory mapped file IO." + license = "MIT" + topics = ("mio", "mmap", "memory-mapping", "fileviewer") + homepage = "https://github.com/mandreyel/mio" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + apply_conandata_patches(self) + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*pp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "mio") + self.cpp_info.set_property("cmake_target_name", "mio::mio") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + self.cpp_info.components["mio-headers"].set_property("cmake_target_name", "mio::mio-headers") + self.cpp_info.components["mio-headers"].bindirs = [] + self.cpp_info.components["mio-headers"].frameworkdirs = [] + self.cpp_info.components["mio-headers"].libdirs = [] + self.cpp_info.components["mio-headers"].resdirs = [] + + if self.settings.os == "Windows": + self.cpp_info.components["mio_full_winapi"].set_property("cmake_target_name", "mio::mio_full_winapi") + self.cpp_info.components["mio_full_winapi"].bindirs = [] + self.cpp_info.components["mio_full_winapi"].frameworkdirs = [] + self.cpp_info.components["mio_full_winapi"].libdirs = [] + self.cpp_info.components["mio_full_winapi"].resdirs = [] + + self.cpp_info.components["mio_min_winapi"].set_property("cmake_target_name", "mio::mio_min_winapi") + self.cpp_info.components["mio_min_winapi"].defines = ["WIN32_LEAN_AND_MEAN", "NOMINMAX"] + self.cpp_info.components["mio_min_winapi"].bindirs = [] + self.cpp_info.components["mio_min_winapi"].frameworkdirs = [] + self.cpp_info.components["mio_min_winapi"].libdirs = [] + self.cpp_info.components["mio_min_winapi"].resdirs = [] diff --git a/recipes/mio/all/patches/0001-fix-include-windows.patch b/recipes/mio/all/patches/0001-fix-include-windows.patch new file mode 100644 index 0000000000000..d28f9c1bfe1bd --- /dev/null +++ b/recipes/mio/all/patches/0001-fix-include-windows.patch @@ -0,0 +1,13 @@ +--- a/include/mio/detail/mmap.ipp ++++ b/include/mio/detail/mmap.ipp +@@ -27,7 +27,9 @@ + + #include + +-#ifndef _WIN32 ++#ifdef _WIN32 ++# include ++#else + # include + # include + # include diff --git a/recipes/mio/all/test_package/CMakeLists.txt b/recipes/mio/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..dd4a0cd1a355b --- /dev/null +++ b/recipes/mio/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(mio REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mio::mio) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/mio/all/test_package/conanfile.py b/recipes/mio/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/mio/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mio/all/test_package/test_package.cpp b/recipes/mio/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..aeb37b6519b6f --- /dev/null +++ b/recipes/mio/all/test_package/test_package.cpp @@ -0,0 +1,51 @@ +#include + +#include +#include +#include +#include +#include + +int handle_error(const std::error_code &error) { + const auto &errmsg = error.message(); + std::printf("error mapping file: %s, exiting...\n", errmsg.c_str()); + return error.value(); +} + +void allocate_file(const std::string &path, const int size) { + std::ofstream file(path); + std::string s(size, '0'); + file << s; +} + +int main() { + const auto path = "file.txt"; + allocate_file(path, 155); + + std::error_code error; + mio::mmap_sink rw_mmap = mio::make_mmap_sink(path, 0, mio::map_entire_file, error); + if (error) { return handle_error(error); } + + std::fill(rw_mmap.begin(), rw_mmap.end(), 'a'); + + for (auto &b : rw_mmap) { + b += 10; + } + + const int answer_index = rw_mmap.size() / 2; + rw_mmap[answer_index] = 42; + + rw_mmap.sync(error); + if (error) { return handle_error(error); } + + rw_mmap.unmap(); + + mio::mmap_source ro_mmap; + ro_mmap.map(path, error); + if (error) { return handle_error(error); } + + const int the_answer_to_everything = ro_mmap[answer_index]; + assert(the_answer_to_everything == 42); + + return 0; +} diff --git a/recipes/mio/all/test_v1_package/CMakeLists.txt b/recipes/mio/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..84deeaa812c31 --- /dev/null +++ b/recipes/mio/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(mio REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mio::mio) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/mio/all/test_v1_package/conanfile.py b/recipes/mio/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mio/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mio/config.yml b/recipes/mio/config.yml new file mode 100644 index 0000000000000..98dc4e2902c05 --- /dev/null +++ b/recipes/mio/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20201220": + folder: all diff --git a/recipes/modern-cpp-kafka/all/conandata.yml b/recipes/modern-cpp-kafka/all/conandata.yml new file mode 100644 index 0000000000000..6dcb3eaf368bc --- /dev/null +++ b/recipes/modern-cpp-kafka/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "2022.10.12": + url: "https://github.com/morganstanley/modern-cpp-kafka/archive/v2022.10.12.tar.gz" + sha256: "f60c6d6328e64a8ae0c3233921078160fc4e42a3484eb823d9918895f5f1b39f" + "2022.08.01": + url: "https://github.com/morganstanley/modern-cpp-kafka/archive/v2022.08.01.tar.gz" + sha256: "77998caf50ffcc55c77713571d9ce04a37020ccff7b713d14abad9eb8ceb05b3" + "2022.06.15": + url: https://github.com/morganstanley/modern-cpp-kafka/archive/refs/tags/v2022.06.15.tar.gz + sha256: 478fcf560057b7cf7b4be851838ebf0520806d057b172de23261606fce088d27 diff --git a/recipes/modern-cpp-kafka/all/conanfile.py b/recipes/modern-cpp-kafka/all/conanfile.py new file mode 100644 index 0000000000000..eebf2c5395b60 --- /dev/null +++ b/recipes/modern-cpp-kafka/all/conanfile.py @@ -0,0 +1,45 @@ +from conans import ConanFile, tools +import os + +required_conan_version = ">=1.33.0" + + +class ModernCppKafkaConan(ConanFile): + name = "modern-cpp-kafka" + description = "A C++ API for Kafka clients (i.e. KafkaProducer, KafkaConsumer, AdminClient)" + license = "Apache-2.0" + topics = ("kafka", "librdkafka", "kafkaproducer", "kafkaconsumer") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/morganstanley/modern-cpp-kafka" + settings = "arch", "build_type", "compiler", "os" + no_copy_source = True + + def requirements(self): + self.requires("librdkafka/1.8.2") + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 17) + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + self.copy(pattern="*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) + + def package_id(self): + self.info.header_only() + + def package_info(self): + self.cpp_info.set_property("cmake_target_name", "ModernCppKafka::ModernCppKafka") + + self.cpp_info.names["cmake_find_package"] = "ModernCppKafka" + self.cpp_info.names["cmake_find_package_multi"] = "ModernCppKafka" + + if self.settings.os in ["Linux", "Macos"]: + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt b/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d36924d633da --- /dev/null +++ b/recipes/modern-cpp-kafka/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +set(CMAKE_CXX_STANDARD 17) + +find_package(ModernCppKafka REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ModernCppKafka::ModernCppKafka) diff --git a/recipes/modern-cpp-kafka/all/test_package/conanfile.py b/recipes/modern-cpp-kafka/all/test_package/conanfile.py new file mode 100644 index 0000000000000..81a08015e01f1 --- /dev/null +++ b/recipes/modern-cpp-kafka/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/modern-cpp-kafka/all/test_package/test_package.cpp b/recipes/modern-cpp-kafka/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..b9fb4f0bea6d8 --- /dev/null +++ b/recipes/modern-cpp-kafka/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include "kafka/Utility.h" + +#include + +int main() +{ + std::cout << "librdkafka version: " << kafka::utility::getLibRdKafkaVersion() << std::endl; +} diff --git a/recipes/modern-cpp-kafka/config.yml b/recipes/modern-cpp-kafka/config.yml new file mode 100644 index 0000000000000..7826a4cd0db75 --- /dev/null +++ b/recipes/modern-cpp-kafka/config.yml @@ -0,0 +1,7 @@ +versions: + "2022.10.12": + folder: all + "2022.08.01": + folder: all + "2022.06.15": + folder: all diff --git a/recipes/mold/1.3.1/conandata.yml b/recipes/mold/1.3.1/conandata.yml new file mode 100644 index 0000000000000..5d89f31c243f2 --- /dev/null +++ b/recipes/mold/1.3.1/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.3.1": + url: "https://github.com/rui314/mold/archive/refs/tags/v1.3.1.tar.gz" + sha256: "d436e2d4c1619a97aca0e28f26c4e79c0242d10ce24e829c1b43cfbdd196fd77" diff --git a/recipes/mold/1.3.1/conanfile.py b/recipes/mold/1.3.1/conanfile.py new file mode 100644 index 0000000000000..132186858b019 --- /dev/null +++ b/recipes/mold/1.3.1/conanfile.py @@ -0,0 +1,104 @@ +from conan import ConanFile +from conan.tools.scm import Version +from conan.tools import files +from conan.tools.files import copy +from conan.errors import ConanInvalidConfiguration +from conans import AutoToolsBuildEnvironment +import os + +required_conan_version = ">=1.47.0" + +class MoldConan(ConanFile): + name = "mold" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/rui314/mold/" + license = "AGPL-3.0" + description = ("mold is a faster drop-in replacement for existing Unix linkers. It is several times faster than the LLVM lld linker") + topics = ("mold", "ld", "linkage", "compilation") + + settings = "os", "arch", "compiler", "build_type" + + generators = "make" + + def validate(self): + if self.settings.build_type == "Debug": + raise ConanInvalidConfiguration('Mold is a build tool, specify mold:build_type=Release in your build profile, see https://github.com/conan-io/conan-center-index/pull/11536#issuecomment-1195607330') + if self.settings.compiler in ["gcc", "clang", "intel-cc"] and self.settings.compiler.libcxx != "libstdc++11": + raise ConanInvalidConfiguration('Mold can only be built with libstdc++11; specify mold:compiler.libcxx=libstdc++11 in your build profile') + if self.settings.os == "Windows": + raise ConanInvalidConfiguration(f'{self.name} can not be built on {self.settings.os}.') + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "10": + raise ConanInvalidConfiguration("GCC version 10 or higher required") + if (self.settings.compiler == "clang" or self.settings.compiler == "apple-clang") and Version(self.settings.compiler.version) < "12": + raise ConanInvalidConfiguration("Clang version 12 or higher required") + if self.settings.compiler == "apple-clang" and "armv8" == self.settings.arch : + raise ConanInvalidConfiguration(f'{self.name} is still not supported by Mac M1.') + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def _get_include_path(self, dependency): + include_path = self.deps_cpp_info[dependency].rootpath + include_path = os.path.join(include_path, "include") + return include_path + + def _patch_sources(self): + if self.settings.compiler == "apple-clang" or (self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "11"): + files.replace_in_file(self, "source_subfolder/Makefile", "-std=c++20", "-std=c++2a") + + files.replace_in_file(self, "source_subfolder/Makefile", "-Ithird-party/xxhash ", "-I{} -I{} -I{} -I{} -I{}".format( + self._get_include_path("zlib"), + self._get_include_path("openssl"), + self._get_include_path("xxhash"), + self._get_include_path("mimalloc"), + self._get_include_path("onetbb") + )) + + files.replace_in_file(self, "source_subfolder/Makefile", "MOLD_LDFLAGS += -ltbb", "MOLD_LDFLAGS += -L{} -ltbb".format( + self.deps_cpp_info["onetbb"].lib_paths[0])) + + files.replace_in_file(self, "source_subfolder/Makefile", "MOLD_LDFLAGS += -lmimalloc", "MOLD_LDFLAGS += -L{} -lmimalloc".format( + self.deps_cpp_info["mimalloc"].lib_paths[0])) + + def requirements(self): + self.requires("zlib/1.2.12") + self.requires("openssl/1.1.1q") + self.requires("xxhash/0.8.1") + self.requires("onetbb/2021.3.0") + self.requires("mimalloc/2.0.6") + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def build(self): + self._patch_sources() + with files.chdir(self, self._source_subfolder): + autotools = AutoToolsBuildEnvironment(self) + autotools.make(target="mold", args=['SYSTEM_TBB=1', 'SYSTEM_MIMALLOC=1']) + + def package(self): + copy(self, "LICENSE", src=self._source_subfolder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "mold", src="bin", dst=os.path.join(self.package_folder, "bin"), keep_path=False) + copy(self, "mold", src=self._source_subfolder, dst=os.path.join(self.package_folder, "bin"), keep_path=False) + + def package_id(self): + del self.info.settings.compiler + + def package_info(self): + bindir = os.path.join(self.package_folder, "bin") + mold_location = os.path.join(bindir, "bindir") + + self.output.info('Appending PATH environment variable: {}'.format(bindir)) + self.env_info.PATH.append(bindir) + self.env_info.LD = mold_location + self.buildenv_info.prepend_path("MOLD_ROOT", bindir) + self.cpp_info.includedirs = [] + + if self.settings.os == "Linux": + self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) diff --git a/recipes/mold/1.3.1/test_package/conanfile.py b/recipes/mold/1.3.1/test_package/conanfile.py new file mode 100644 index 0000000000000..f4c00d1c189e7 --- /dev/null +++ b/recipes/mold/1.3.1/test_package/conanfile.py @@ -0,0 +1,9 @@ +from conan import ConanFile +from conan.tools.build import cross_building + +class TestPackageConan(ConanFile): + settings = "os", "arch", "build_type", "compiler" + + def test(self): + if not cross_building(self): + self.run("mold -v", run_environment=True) diff --git a/recipes/mold/all/conandata.yml b/recipes/mold/all/conandata.yml new file mode 100644 index 0000000000000..b90f73007307f --- /dev/null +++ b/recipes/mold/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.4.2": + url: "https://github.com/rui314/mold/archive/refs/tags/v1.4.2.tar.gz" + sha256: "47e6c48d20f49e5b47dfb8197dd9ffcb11a8833d614f7a03bd29741c658a69cd" + "1.5.1": + url: "https://github.com/rui314/mold/archive/refs/tags/v1.5.1.tar.gz" + sha256: "ec94aa74758f1bc199a732af95c6304ec98292b87f2f4548ce8436a7c5b054a1" diff --git a/recipes/mold/all/conanfile.py b/recipes/mold/all/conanfile.py new file mode 100644 index 0000000000000..fde5b3dec3293 --- /dev/null +++ b/recipes/mold/all/conanfile.py @@ -0,0 +1,99 @@ +import os +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.files import copy, get, rmdir +from conan.errors import ConanInvalidConfiguration +from conan.tools.scm import Version +from conan.tools.env import VirtualBuildEnv + +class MoldConan(ConanFile): + name = "mold" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/rui314/mold/" + license = "AGPL-3.0" + description = ("mold is a faster drop-in replacement for existing Unix linkers. It is several times faster than the LLVM lld linker") + topics = ("mold", "ld", "linkage", "compilation") + + settings = "os", "arch", "compiler", "build_type" + options = { + "with_mimalloc": [True, False], + } + default_options = { + "with_mimalloc": False, + } + + def validate(self): + if self.settings.build_type == "Debug": + raise ConanInvalidConfiguration('Mold is a build tool, specify mold:build_type=Release in your build profile, see https://github.com/conan-io/conan-center-index/pull/11536#issuecomment-1195607330') + if self.settings.compiler in ["gcc", "clang", "intel-cc"] and self.settings.compiler.libcxx != "libstdc++11": + raise ConanInvalidConfiguration('Mold can only be built with libstdc++11; specify mold:compiler.libcxx=libstdc++11 in your build profile') + if self.settings.os == "Windows": + raise ConanInvalidConfiguration(f'{self.name} can not be built on {self.settings.os}.') + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "10": + raise ConanInvalidConfiguration("GCC version 10 or higher required") + if self.settings.compiler in ('clang', 'apple-clang') and Version(self.settings.compiler.version) < "12": + raise ConanInvalidConfiguration("Clang version 12 or higher required") + if self.settings.compiler == "apple-clang" and "armv8" == self.settings.arch : + raise ConanInvalidConfiguration(f'{self.name} is still not supported by Mac M1.') + + def layout(self): + cmake_layout(self, src_folder="src") + + def package_id(self): + del self.info.settings.compiler + + def build_requirements(self): + self.tool_requires("cmake/3.24.1") + + def requirements(self): + self.requires("zlib/1.2.12") + self.requires("openssl/1.1.1q") + self.requires("xxhash/0.8.1") + self.requires("onetbb/2021.3.0") + if self.options.with_mimalloc: + self.requires("mimalloc/2.0.6") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MOLD_USE_MIMALLOC"] = self.options.with_mimalloc + tc.variables["MOLD_USE_SYSTEM_MIMALLOC"] = True + tc.variables["MOLD_USE_SYSTEM_TBB"] = True + tc.generate() + + cd = CMakeDeps(self) + cd.generate() + tc = VirtualBuildEnv(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + bindir = os.path.join(self.package_folder, "bin") + mold_location = os.path.join(bindir, "bindir") + + self.output.info('Appending PATH environment variable: {}'.format(bindir)) + self.env_info.PATH.append(bindir) + self.env_info.LD = mold_location + self.buildenv_info.prepend_path("MOLD_ROOT", bindir) + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.resdirs = [] + + if self.settings.os == "Linux": + self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) diff --git a/recipes/mold/all/test_package/conanfile.py b/recipes/mold/all/test_package/conanfile.py new file mode 100644 index 0000000000000..60e9ac3ecf6ee --- /dev/null +++ b/recipes/mold/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +from conan import ConanFile +from conan.tools.build import can_run + + +class MoldTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def test(self): + if can_run(self): + self.run("mold -v") + diff --git a/recipes/mold/all/test_v1_package/conanfile.py b/recipes/mold/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..ce72e1030b169 --- /dev/null +++ b/recipes/mold/all/test_v1_package/conanfile.py @@ -0,0 +1,10 @@ +import os +from conans import ConanFile, tools +from conan.tools.build import cross_building + +class TestPackageConan(ConanFile): + settings = "os", "arch", "build_type", "compiler" + + def test(self): + if not cross_building(self): + self.run("mold -v", run_environment=True) diff --git a/recipes/mold/config.yml b/recipes/mold/config.yml new file mode 100644 index 0000000000000..73995b17f00b1 --- /dev/null +++ b/recipes/mold/config.yml @@ -0,0 +1,7 @@ +versions: + "1.3.1": + folder: 1.3.1 + "1.4.2": + folder: all + "1.5.1": + folder: all diff --git a/recipes/moltenvk/all/CMakeLists.txt b/recipes/moltenvk/all/CMakeLists.txt index 6fe0a5ebea271..0b453780ee747 100644 --- a/recipes/moltenvk/all/CMakeLists.txt +++ b/recipes/moltenvk/all/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.12) project(MoltenVK) -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "tvOS")) @@ -12,19 +9,30 @@ endif() option(MVK_WITH_SPIRV_TOOLS "Build MoltenVK without the MVK_EXCLUDE_SPIRV_TOOLS build setting" ON) option(MVK_BUILD_SHADERCONVERTER_TOOL "Build MoltenVKShaderConverter" ON) - -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 11) +if(MVK_VERSION VERSION_GREATER_EQUAL "1.1.7" AND BUILD_SHARED_LIBS) + option(MVK_HIDE_VULKAN_SYMBOLS "Hide Vulkan symbols" OFF) endif() -set(MVK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) +set(MVK_COMMON_DIR ${MVK_SRC_DIR}/common) +set(MVK_SC_DIR ${MVK_SRC_DIR}/MoltenVKShaderConverter) +set(MVK_LIB_DIR ${MVK_SRC_DIR}/MoltenVK) set(MVK_INSTALL_TARGETS "") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) + # PIC required for objects targets linked into shared MoltenVK if(BUILD_SHARED_LIBS) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +find_package(cereal REQUIRED CONFIG) +find_package(glslang REQUIRED glslang SPIRV CONFIG) +find_package(spirv-cross REQUIRED CONFIG) +find_package(VulkanHeaders REQUIRED CONFIG) +if(MVK_WITH_SPIRV_TOOLS) + find_package(SPIRV-Tools REQUIRED CONFIG) +endif() + # Find mandatory Apple Frameworks function(find_library_required foundVar framework) find_library(${foundVar} ${framework}) @@ -35,93 +43,116 @@ endfunction() find_library_required(METAL_FRAMEWORK Metal) find_library_required(FOUNDATION_FRAMEWORK Foundation) -find_library_required(QUARTZ_CORE_FRAMEWORK QuartzCore) -find_library_required(APPKIT_FRAMEWORK AppKit) +find_library_required(QUARTZCORE_FRAMEWORK QuartzCore) find_library_required(IOSURFACE_FRAMEWORK IOSurface) +find_library_required(COREGRAPHICS_FRAMEWORK CoreGraphics) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - find_library_required(IO_OR_UI_KIT_FRAMEWORK IOKit) + find_library_required(APPKIT_FRAMEWORK AppKit) + find_library_required(IOKIT_FRAMEWORK IOKit) else() - find_library_required(IO_OR_UI_KIT_FRAMEWORK UIKit) + find_library_required(UIKIT_FRAMEWORK UIKit) endif() +add_compile_options( + -Wno-unguarded-availability-new + -Wno-deprecated-declarations + -Wno-nonportable-include-path + -Wno-tautological-pointer-compare + -Wno-non-c-typedef-for-linkage + -Wno-switch +) + # MoltenVKCommon -# * direct dependencies: -# - external: None -# - internal: None -# - frameworks: Foundation -file(GLOB MVK_COMMON_SOURCES ${MVK_DIR}/common/*.mm) +file(GLOB MVK_COMMON_SOURCES ${MVK_COMMON_DIR}/*.mm) add_library(MoltenVKCommon OBJECT ${MVK_COMMON_SOURCES}) -target_include_directories(MoltenVKCommon PUBLIC ${MVK_DIR}/common) +target_include_directories(MoltenVKCommon PUBLIC ${MVK_COMMON_DIR}) target_compile_definitions(MoltenVKCommon PRIVATE $<$:DEBUG=1>) target_link_libraries(MoltenVKCommon PRIVATE ${FOUNDATION_FRAMEWORK}) +if(BUILD_SHARED_LIBS) + set_target_properties(MoltenVKCommon PROPERTIES + C_VISIBILITY_PRESET hidden + OBJC_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + OBJCXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + ) +endif() # MoltenVKShaderConverter -# * direct dependencies: -# - external: spirv-cross, glslang, and spirv-tools (optional) -# - internal: MoltenVKCommon -# - frameworks: Foundation -file(GLOB MVK_SC_COMMON_SOURCES ${MVK_DIR}/MoltenVKShaderConverter/common/*.cpp) if(MVK_VERSION VERSION_LESS "1.1.0") - file(GLOB MVK_SC_CONVERTERS_SOURCES - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKGLSLToSPIRVConverter/*.cpp - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKGLSLToSPIRVConverter/*.mm - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter/*.cpp - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter/*.mm + file(GLOB MVK_SC_SOURCES + ${MVK_SC_DIR}/MoltenVKGLSLToSPIRVConverter/*.cpp + ${MVK_SC_DIR}/MoltenVKGLSLToSPIRVConverter/*.mm + ${MVK_SC_DIR}/MoltenVKSPIRVToMSLConverter/*.cpp + ${MVK_SC_DIR}/MoltenVKSPIRVToMSLConverter/*.mm ) else() - file(GLOB MVK_SC_CONVERTERS_SOURCES - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverter/*.cpp - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverter/*.mm + file(GLOB MVK_SC_SOURCES + ${MVK_SC_DIR}/MoltenVKShaderConverter/*.cpp + ${MVK_SC_DIR}/MoltenVKShaderConverter/*.mm ) endif() -add_library(MoltenVKShaderConverter OBJECT ${MVK_SC_COMMON_SOURCES} ${MVK_SC_CONVERTERS_SOURCES}) +if(MVK_VERSION VERSION_LESS "1.1.4") + file(GLOB MVK_SC_COMMON_SOURCES ${MVK_SC_DIR}/common/*.cpp) + list(APPEND MVK_SC_SOURCES ${MVK_SC_COMMON_SOURCES}) +endif() +add_library(MoltenVKShaderConverter OBJECT ${MVK_SC_SOURCES}) +if(MVK_VERSION VERSION_LESS "1.1.9") + target_compile_features(MoltenVKShaderConverter PUBLIC cxx_std_11) +else() + target_compile_features(MoltenVKShaderConverter PUBLIC cxx_std_17) +endif() target_include_directories(MoltenVKShaderConverter - PRIVATE ${MVK_DIR}/MoltenVKShaderConverter/common - INTERFACE ${MVK_DIR}/MoltenVKShaderConverter + PRIVATE + $<$:${MVK_SC_DIR}/MoltenVKSPIRVToMSLConverter> + $<$:${MVK_SC_DIR}/common> + INTERFACE + ${MVK_SC_DIR} ) -if(MVK_VERSION VERSION_LESS "1.1.0") - target_include_directories(MoltenVKShaderConverter PRIVATE - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter - ) -endif() target_link_libraries(MoltenVKShaderConverter PRIVATE - CONAN_PKG::glslang + glslang::glslang + glslang::SPIRV MoltenVKCommon + $<$:SPIRV-Tools> ${FOUNDATION_FRAMEWORK} PUBLIC - CONAN_PKG::spirv-cross + spirv-cross-core + spirv-cross-msl + spirv-cross-reflect +) +target_compile_definitions(MoltenVKShaderConverter PRIVATE + $<$>:MVK_EXCLUDE_SPIRV_TOOLS> ) -if(NOT MVK_WITH_SPIRV_TOOLS) - target_compile_definitions(MoltenVKShaderConverter PRIVATE MVK_EXCLUDE_SPIRV_TOOLS) - target_link_libraries(MoltenVKShaderConverter PRIVATE CONAN_PKG::spirv-tools) +if(BUILD_SHARED_LIBS) + set_target_properties(MoltenVKShaderConverter PROPERTIES + C_VISIBILITY_PRESET hidden + OBJC_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + OBJCXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + ) endif() # MoltenVKShaderConverterTool -# * direct dependencies: -# - external: None -# - internal: MoltenVKShaderConverter and MoltenVKCommon -# - frameworks: Metal and Foundation if(MVK_BUILD_SHADERCONVERTER_TOOL) file(GLOB MVK_SCT_SOURCES - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverterTool/*.cpp - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverterTool/*.mm + ${MVK_SC_DIR}/MoltenVKShaderConverterTool/*.cpp + ${MVK_SC_DIR}/MoltenVKShaderConverterTool/*.mm ) add_executable(MoltenVKShaderConverterTool ${MVK_SCT_SOURCES}) + if(MVK_VERSION VERSION_LESS "1.1.9") + target_compile_features(MoltenVKShaderConverterTool PUBLIC cxx_std_11) + else() + target_compile_features(MoltenVKShaderConverterTool PUBLIC cxx_std_17) + endif() set_property(TARGET MoltenVKShaderConverterTool PROPERTY OUTPUT_NAME "MoltenVKShaderConverter") target_include_directories(MoltenVKShaderConverterTool PRIVATE - ${MVK_DIR}/MoltenVKShaderConverter/common + $<$:${MVK_SC_DIR}/MoltenVKGLSLToSPIRVConverter> + $<$:${MVK_SC_DIR}/MoltenVKSPIRVToMSLConverter> + $<$:${MVK_SC_DIR}/common> + $<$:${MVK_SC_DIR}/MoltenVKShaderConverter> ) - if(MVK_VERSION VERSION_LESS "1.1.0") - target_include_directories(MoltenVKShaderConverterTool PRIVATE - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKGLSLToSPIRVConverter - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter - ) - else() - target_include_directories(MoltenVKShaderConverterTool PRIVATE - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverter - ) - endif() target_link_libraries(MoltenVKShaderConverterTool PRIVATE MoltenVKCommon MoltenVKShaderConverter @@ -132,57 +163,63 @@ if(MVK_BUILD_SHADERCONVERTER_TOOL) endif() # MoltenVK -# * direct dependencies: -# - external: cereal, spirv-cross and vulkan-headers (+ vulkan-portability if moltenvk < 1.1.0) -# - internal: MoltenVKShaderConverter and MoltenVKCommon -# - frameworks: Foundation, Metal, QuartzCore, AppKit, IOSurface + IOKit (Macos) or UIKit (iOS/tvOS) file(GLOB_RECURSE MVK_SOURCES - ${MVK_DIR}/MoltenVK/*.m - ${MVK_DIR}/MoltenVK/*.mm - ${MVK_DIR}/MoltenVK/*.cpp + ${MVK_LIB_DIR}/MoltenVK/*.m + ${MVK_LIB_DIR}/MoltenVK/*.mm + ${MVK_LIB_DIR}/MoltenVK/*.cpp ) add_library(MoltenVK ${MVK_SOURCES}) +if(MVK_VERSION VERSION_LESS "1.1.9") + target_compile_features(MoltenVK PUBLIC cxx_std_11) +else() + target_compile_features(MoltenVK PUBLIC cxx_std_17) +endif() target_include_directories(MoltenVK PRIVATE - ${MVK_DIR}/MoltenVK/MoltenVK/API - ${MVK_DIR}/MoltenVK/MoltenVK/Commands - ${MVK_DIR}/MoltenVK/MoltenVK/GPUObjects - ${MVK_DIR}/MoltenVK/MoltenVK/Layers - ${MVK_DIR}/MoltenVK/MoltenVK/OS - ${MVK_DIR}/MoltenVK/MoltenVK/Utility - ${MVK_DIR}/MoltenVK/MoltenVK/Vulkan + ${MVK_LIB_DIR}/MoltenVK/API + ${MVK_LIB_DIR}/MoltenVK/Commands + ${MVK_LIB_DIR}/MoltenVK/GPUObjects + ${MVK_LIB_DIR}/MoltenVK/Layers + ${MVK_LIB_DIR}/MoltenVK/OS + ${MVK_LIB_DIR}/MoltenVK/Utility + ${MVK_LIB_DIR}/MoltenVK/Vulkan ) target_link_libraries(MoltenVK PRIVATE - CONAN_PKG::cereal - CONAN_PKG::spirv-cross + cereal MoltenVKCommon MoltenVKShaderConverter ${FOUNDATION_FRAMEWORK} - ${QUARTZ_CORE_FRAMEWORK} - ${APPKIT_FRAMEWORK} - ${IO_OR_UI_KIT_FRAMEWORK} + ${QUARTZCORE_FRAMEWORK} + $<$:${APPKIT_FRAMEWORK}> + $<$:${IOKIT_FRAMEWORK}> + $<$>:${UIKIT_FRAMEWORK}> PUBLIC - CONAN_PKG::vulkan-headers + Vulkan::Headers ${METAL_FRAMEWORK} ${IOSURFACE_FRAMEWORK} + ${COREGRAPHICS_FRAMEWORK} ) -if(MVK_VERSION VERSION_LESS "1.1.0") - target_link_libraries(MoltenVK PUBLIC CONAN_PKG::vulkan-portability) +if(BUILD_SHARED_LIBS) + set_target_properties(MoltenVK PROPERTIES + C_VISIBILITY_PRESET hidden + OBJC_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + OBJCXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON + ) + if(MVK_VERSION VERSION_GREATER_EQUAL "1.1.7" AND MVK_HIDE_VULKAN_SYMBOLS) + target_compile_definitions(MoltenVK PRIVATE MVK_HIDE_VULKAN_SYMBOLS) + endif() endif() -target_compile_options(MoltenVK PRIVATE - -Wno-unguarded-availability-new - -Wno-deprecated-declarations - -Wno-nonportable-include-path -) list(APPEND MVK_INSTALL_TARGETS MoltenVK) # Custom Target to generate internal header file required by MoltenVK target. # This header should contain: -# - if moltenvk < 1.44 : spirv-cross commit hash in spirvCrossRevisionString variable -# - if moltenvk >= 1.44: moltenvk commit hash in mvkRevString variable (but we still +# - if moltenvk < 1.0.44 : spirv-cross commit hash in spirvCrossRevisionString variable +# - if moltenvk >= 1.0.44: moltenvk commit hash in mvkRevString variable (but we still # use spirv-cross commit hash, since MoltenVK hash is not available in this context, # and hash value is no really important) -set(MVK_REV_FILE ${MVK_DIR}/ExternalRevisions/SPIRV-Cross_repo_revision) +set(MVK_REV_FILE ${MVK_SRC_DIR}/ExternalRevisions/SPIRV-Cross_repo_revision) set(MVK_REV_HEADER_DIR ${CMAKE_CURRENT_BINARY_DIR}/mvk_hash_generated) if(MVK_VERSION VERSION_LESS "1.0.44") set(MVK_REV_HEADER ${MVK_REV_HEADER_DIR}/SPIRV-Cross/mvkSpirvCrossRevisionDerived.h) @@ -219,12 +256,12 @@ install( if(BUILD_SHARED_LIBS) install( - FILES ${MVK_DIR}/MoltenVK/icd/MoltenVK_icd.json + FILES ${MVK_LIB_DIR}/icd/MoltenVK_icd.json DESTINATION ${CMAKE_INSTALL_LIBDIR} ) endif() -file(GLOB MVK_PUBLIC_HEADERS ${MVK_DIR}/MoltenVK/MoltenVK/API/*.h) +file(GLOB MVK_PUBLIC_HEADERS ${MVK_LIB_DIR}/MoltenVK/API/*.h) install( FILES ${MVK_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/MoltenVK @@ -232,15 +269,15 @@ install( if(MVK_VERSION VERSION_LESS "1.1.0") file(GLOB MVK_SC_PUBLIC_HEADERS - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKGLSLToSPIRVConverter/*Conversion.h - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKGLSLToSPIRVConverter/*Converter.h - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter/*Conversion.h - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter/*Converter.h + ${MVK_SC_DIR}/MoltenVKGLSLToSPIRVConverter/*Conversion.h + ${MVK_SC_DIR}/MoltenVKGLSLToSPIRVConverter/*Converter.h + ${MVK_SC_DIR}/MoltenVKSPIRVToMSLConverter/*Conversion.h + ${MVK_SC_DIR}/MoltenVKSPIRVToMSLConverter/*Converter.h ) else() file(GLOB MVK_SC_PUBLIC_HEADERS - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverter/*Conversion.h - ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverter/*Converter.h + ${MVK_SC_DIR}/MoltenVKShaderConverter/*Conversion.h + ${MVK_SC_DIR}/MoltenVKShaderConverter/*Converter.h ) endif() install( diff --git a/recipes/moltenvk/all/conandata.yml b/recipes/moltenvk/all/conandata.yml index 994d62484dd52..2f8e73cdf6613 100644 --- a/recipes/moltenvk/all/conandata.yml +++ b/recipes/moltenvk/all/conandata.yml @@ -1,4 +1,28 @@ sources: + "1.2.0": + url: "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v1.2.0.tar.gz" + sha256: "6e7af2dad0530b2b404480dbe437ca4670c6615cc2ec6cf6a20ed04d9d75e0bd" + "1.1.11": + url: "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v1.1.11.tar.gz" + sha256: "938ea0ba13c6538b0ee505ab391a3020f206ab9d29c869f20dd19318a4ee8997" + "1.1.10": + url: "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v1.1.10.tar.gz" + sha256: "fac11c2501195c9ce042103685c7778e35484562e6c084963a22072dd0a602e0" + "1.1.9": + url: "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v1.1.9.tar.gz" + sha256: "ea455a14decb85ec4bc66ffd2b963492afa7b53297b7064a11ca47ca8d2464ea" + "1.1.8": + url: "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v1.1.8.tar.gz" + sha256: "f316c814d0cb6d60a0e8ad164d8cafa64010dee9dd41748b038b6b67fa40f08a" + "1.1.6": + url: "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v1.1.6.tar.gz" + sha256: "b60df3ac93b943eb14377019445533b5c451fffd6b1df86187b1b9ac7d6dba6b" + "1.1.5": + url: "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v1.1.5.tar.gz" + sha256: "2cdcb8dbf2acdcd8cbe70b109dadc05a901038c84970afbe4863e5e23f33deae" + "1.1.4": + url: "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v1.1.4.tar.gz" + sha256: "f9bba6d3bf3648e7685c247cb6d126d62508af614bc549cedd5859a7da64967e" "1.1.1": url: "https://github.com/KhronosGroup/MoltenVK/archive/v1.1.1.tar.gz" sha256: "cd1712c571d4155f4143c435c8551a5cb8cbb311ad7fff03595322ab971682c0" @@ -6,9 +30,44 @@ sources: url: "https://github.com/KhronosGroup/MoltenVK/archive/v1.1.0.tar.gz" sha256: "0538fa1c23ddae495c7f82ccd0db90790a90b7017a258ca7575fbae8021f3058" patches: + "1.2.0": + - patch_file: "patches/1.2.0-0001-fix-version-number-icd-json.patch" + patch_description: "Fix api_version in MoltenVK_icd.json" + patch_type: "backport" + patch_source: "https://github.com/KhronosGroup/MoltenVK/pull/1747" + sha256: "80387a47d24c12b538bdcb60d6aa7c402af0800519ce55385abdfbf3d304ee07" + "1.1.11": + - patch_file: "patches/1.1.11-0001-vulkan-alias-private-extern.patch" + patch_description: "Fix vulkan alias symbols when vulkan symbols are hidden" + patch_type: "portability" + "1.1.10": + - patch_file: "patches/1.1.8-0002-vulkan-alias-private-extern.patch" + patch_description: "Fix vulkan alias symbols when vulkan symbols are hidden" + patch_type: "portability" + "1.1.9": + - patch_file: "patches/1.1.8-0002-vulkan-alias-private-extern.patch" + patch_description: "Fix vulkan alias symbols when vulkan symbols are hidden" + patch_type: "portability" + "1.1.8": + - patch_file: "patches/1.1.8-0001-allow-c++11-std.patch" + patch_description: "Allow to compile with C++11" + patch_type: "portability" + - patch_file: "patches/1.1.8-0002-vulkan-alias-private-extern.patch" + patch_description: "Fix vulkan alias symbols when vulkan symbols are hidden" + patch_type: "portability" + "1.1.6": + - patch_file: "patches/1.1.6-0001-allow-c++11-std.patch" + patch_description: "Allow to compile with C++11" + patch_type: "portability" + "1.1.5": + - patch_file: "patches/1.1.5-0001-allow-c++11-std.patch" + patch_description: "Allow to compile with C++11" + patch_type: "portability" "1.1.1": - - patch_file: "patches/0001-fix-spirv-cross-includes-1.1.x.patch" - base_path: "source_subfolder" + - patch_file: "patches/1.1.0-0001-fix-spirv-cross-includes.patch" + patch_description: "Use spirv-cross include convention" + patch_type: "conan" "1.1.0": - - patch_file: "patches/0001-fix-spirv-cross-includes-1.1.x.patch" - base_path: "source_subfolder" + - patch_file: "patches/1.1.0-0001-fix-spirv-cross-includes.patch" + patch_description: "Use spirv-cross include convention" + patch_type: "conan" diff --git a/recipes/moltenvk/all/conanfile.py b/recipes/moltenvk/all/conanfile.py index d984aa0349e06..1bdfb7c033f01 100644 --- a/recipes/moltenvk/all/conanfile.py +++ b/recipes/moltenvk/all/conanfile.py @@ -1,8 +1,14 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanException, ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get +from conan.tools.scm import Version +import functools import os +import yaml -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.53.0" class MoltenVKConan(ConanFile): @@ -13,7 +19,7 @@ class MoltenVKConan(ConanFile): "graphics framework, enabling Vulkan applications to run " \ "on iOS and macOS." license = "Apache-2.0" - topics = ("conan", "moltenvk", "khronos", "vulkan", "metal") + topics = ("moltenvk", "khronos", "vulkan", "metal") homepage = "https://github.com/KhronosGroup/MoltenVK" url = "https://github.com/conan-io/conan-center-index" @@ -21,141 +27,144 @@ class MoltenVKConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "hide_vulkan_symbols": [True, False], "with_spirv_tools": [True, False], - "tools": [True, False] + "tools": [True, False], } default_options = { - "shared": False, + "shared": True, "fPIC": True, + "hide_vulkan_symbols": False, "with_spirv_tools": True, - "tools": True + "tools": True, } - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - _cmake = None + @property + def _dependencies_filename(self): + return f"dependencies-{self.version}.yml" + + @property + @functools.lru_cache(1) + def _dependencies_versions(self): + dependencies_filepath = os.path.join(self.recipe_folder, "dependencies", self._dependencies_filename) + if not os.path.isfile(dependencies_filepath): + raise ConanException(f"Cannot find {dependencies_filepath}") + cached_dependencies = yaml.safe_load(open(dependencies_filepath)) + return cached_dependencies + + @property + def _min_cppstd(self): + return 11 if Version(self.version) < "1.1.9" else 17 @property - def _source_subfolder(self): - return "source_subfolder" + def _has_hide_vulkan_symbols_option(self): + return Version(self.version) >= "1.1.7" + + def export(self): + copy(self, f"dependencies/{self._dependencies_filename}", self.recipe_folder, self.export_folder) + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) + + def config_options(self): + if not self._has_hide_vulkan_symbols_option: + del self.options.hide_vulkan_symbols def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) - if self.settings.os not in ["Macos", "iOS", "tvOS"]: - raise ConanInvalidConfiguration("MoltenVK only supported on MacOS, iOS and tvOS") - if self.settings.compiler != "apple-clang": - raise ConanInvalidConfiguration("MoltenVK requires apple-clang") + elif self._has_hide_vulkan_symbols_option: + self.options.rm_safe("hide_vulkan_symbols") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("cereal/1.3.0") - self.requires("glslang/8.13.3559") - self.requires("spirv-cross/{}".format(self._spirv_cross_version)) - self.requires("vulkan-headers/{}".format(self._vulkan_headers_version)) + self.requires("cereal/1.3.2") + self.requires(self._require("glslang")) + self.requires(self._require("spirv-cross")) + self.requires(self._require("vulkan-headers")) if self.options.with_spirv_tools: - self.requires("spirv-tools/2020.5") - if tools.Version(self.version) < "1.1.0": - raise ConanInvalidConfiguration("MoltenVK < 1.1.0 requires vulkan-portability, not yet available in CCI") - self.requires("vulkan-portability/0.2") - - @property - def _spirv_cross_version(self): - return { - "1.1.1": "20210115", # can't compile with spirv-cross < 20210115 - "1.1.0": "20200917", # compiles only with spirv-cross 20200917 - "1.0.44": "20200917", # compiles only with spirv-cross 20200917 - "1.0.43": "20200519", # compiles only with spirv-cross 20200519 - "1.0.42": "20200519", # compiles only with spirv-cross 20200519 - "1.0.41": "20200519", # compiles only with spirv-cross 20200403 or 20200519 - "1.0.40": "20200519", # compiles only with spirv-cross 20200403 or 20200519 - "1.0.39": "20200519", # compiles only with spirv-cross 20200403 or 20200519 - }[self.version] + self.requires(self._require("spirv-tools")) - @property - def _vulkan_headers_version(self): - return { - "1.1.1": "1.2.162.0", - "1.1.0": "1.2.154.0", - "1.0.44": "1.2.148.0", - "1.0.43": "1.2.141.0", - "1.0.42": "1.2.141.0", - "1.0.41": "1.2.135.0", - "1.0.40": "1.2.131.1", - "1.0.39": "1.1.130.0", - "1.0.38": "1.1.126.0", - "1.0.37": "1.1.121.0", - "1.0.36": "1.1.114.0", - "1.0.35": "1.1.108.0", - "1.0.34": "1.1.106.0", - "1.0.33": "1.1.101.0", - "1.0.32": "1.1.97.0", - "1.0.31": "1.1.97.0", - "1.0.30": "1.1.92.0", - "1.0.29": "1.1.92.0", - "1.0.28": "1.1.92.0", - "1.0.27": "1.1.92.0", - "1.0.26": "1.1.85.0", - "1.0.25": "1.1.85.0", - "1.0.24": "1.1.85.0", - "1.0.23": "1.1.85.0", - "1.0.22": "1.1.82.0", - "1.0.21": "1.1.82.0", - "1.0.20": "1.1.82.0", - "1.0.19": "1.1.82.0", - "1.0.18": "1.1.82.0", - "1.0.17": "1.1.82.0", - }[self.version] + def _require(self, recipe_name): + if recipe_name not in self._dependencies_versions: + raise ConanException(f"{recipe_name} is missing in {self._dependencies_filename}") + return f"{recipe_name}/{self._dependencies_versions[recipe_name]}" def package_id(self): # MoltenVK >=1.O.42 requires at least XCode 12.0 (11.4 actually) at build - # time but can be consumed by older compiler versions - if tools.Version(self.version) >= "1.0.42": - if tools.Version(self.settings.compiler.version) < "12.0": + # time but can be consumed by older compiler versions if shared + if Version(self.version) >= "1.0.42" and self.options.shared: + if Version(self.settings.compiler.version) < "12.0": compatible_pkg = self.info.clone() compatible_pkg.settings.compiler.version = "12.0" self.compatible_packages.append(compatible_pkg) def validate(self): - if tools.Version(self.version) >= "1.0.42": - if tools.Version(self.settings.compiler.version) < "12.0": - raise ConanInvalidConfiguration("MoltenVK {} requires XCode 12.0 or higher at build time".format(self.version)) + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + if self.info.settings.os not in ["Macos", "iOS", "tvOS"]: + raise ConanInvalidConfiguration(f"{self.ref} only supported on MacOS, iOS and tvOS") + if self.info.settings.compiler != "apple-clang": + raise ConanInvalidConfiguration(f"{self.ref} requires apple-clang") + if Version(self.version) >= "1.0.42": + if Version(self.info.settings.compiler.version) < "12.0": + raise ConanInvalidConfiguration(f"{self.ref} requires XCode 12.0 or higher at build time") + + def validate_build(self): + spirv_cross = self.dependencies["spirv-cross"] + if spirv_cross.options.shared or not spirv_cross.options.msl or not spirv_cross.options.reflect: + raise ConanInvalidConfiguration(f"{self.ref} requires spirv-cross static with msl & reflect enabled") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("MoltenVK-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["MVK_VERSION"] = self.version - self._cmake.definitions["MVK_WITH_SPIRV_TOOLS"] = self.options.with_spirv_tools - self._cmake.definitions["MVK_BUILD_SHADERCONVERTER_TOOL"] = self.options.tools - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MVK_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["MVK_VERSION"] = self.version + tc.variables["MVK_WITH_SPIRV_TOOLS"] = self.options.with_spirv_tools + tc.variables["MVK_BUILD_SHADERCONVERTER_TOOL"] = self.options.tools + if self._has_hide_vulkan_symbols_option and self.options.shared: + tc.variables["MVK_HIDE_VULKAN_SYMBOLS"] = self.options.hide_vulkan_symbols + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): self.cpp_info.libs = ["MoltenVK"] - self.cpp_info.frameworks = ["Metal", "Foundation", "QuartzCore", "AppKit", "IOSurface"] + self.cpp_info.frameworks = ["Metal", "Foundation", "CoreFoundation", "QuartzCore", "IOSurface", "CoreGraphics"] if self.settings.os == "Macos": - self.cpp_info.frameworks.append("IOKit") + self.cpp_info.frameworks.extend(["AppKit", "IOKit"]) elif self.settings.os in ["iOS", "tvOS"]: self.cpp_info.frameworks.append("UIKit") + self.cpp_info.requires = [ + "cereal::cereal", "glslang::glslang-core", "glslang::spirv", "spirv-cross::spirv-cross-core", + "spirv-cross::spirv-cross-msl", "spirv-cross::spirv-cross-reflect", "vulkan-headers::vulkan-headers", + ] + if self.options.with_spirv_tools: + self.cpp_info.requires.append("spirv-tools::spirv-tools-core") + + if self.options.shared: + moltenvk_icd_path = os.path.join(self.package_folder, "lib", "MoltenVK_icd.json") + self.runenv_info.prepend_path("VK_ICD_FILENAMES", moltenvk_icd_path) + # TODO: to remove after conan v2, it allows to not break consumers still relying on virtualenv generator + self.env_info.VK_ICD_FILENAMES.append(moltenvk_icd_path) + if self.options.tools: - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/moltenvk/all/dependencies/dependencies-1.1.0.yml b/recipes/moltenvk/all/dependencies/dependencies-1.1.0.yml new file mode 100644 index 0000000000000..d8c73818a1f7e --- /dev/null +++ b/recipes/moltenvk/all/dependencies/dependencies-1.1.0.yml @@ -0,0 +1,4 @@ +glslang: "8.13.3559" +spirv-cross: "20200917" +spirv-tools: "2020.5" +vulkan-headers: "1.2.154.0" diff --git a/recipes/moltenvk/all/dependencies/dependencies-1.1.1.yml b/recipes/moltenvk/all/dependencies/dependencies-1.1.1.yml new file mode 100644 index 0000000000000..3dd4ee92f5875 --- /dev/null +++ b/recipes/moltenvk/all/dependencies/dependencies-1.1.1.yml @@ -0,0 +1,4 @@ +glslang: "8.13.3559" +spirv-cross: "20210115" +spirv-tools: "2020.5" +vulkan-headers: "1.2.162.0" diff --git a/recipes/moltenvk/all/dependencies/dependencies-1.1.10.yml b/recipes/moltenvk/all/dependencies/dependencies-1.1.10.yml new file mode 100644 index 0000000000000..056b9e003fb57 --- /dev/null +++ b/recipes/moltenvk/all/dependencies/dependencies-1.1.10.yml @@ -0,0 +1,4 @@ +glslang: "1.3.216.0" +spirv-cross: "1.3.216.0" +spirv-tools: "1.3.216.0" +vulkan-headers: "1.3.216.0" diff --git a/recipes/moltenvk/all/dependencies/dependencies-1.1.11.yml b/recipes/moltenvk/all/dependencies/dependencies-1.1.11.yml new file mode 100644 index 0000000000000..1a11b23c8e3ad --- /dev/null +++ b/recipes/moltenvk/all/dependencies/dependencies-1.1.11.yml @@ -0,0 +1,4 @@ +glslang: "1.3.224.0" +spirv-cross: "1.3.224.0" +spirv-tools: "1.3.224.0" +vulkan-headers: "1.3.224.0" diff --git a/recipes/moltenvk/all/dependencies/dependencies-1.1.4.yml b/recipes/moltenvk/all/dependencies/dependencies-1.1.4.yml new file mode 100644 index 0000000000000..b1f4555c6b74e --- /dev/null +++ b/recipes/moltenvk/all/dependencies/dependencies-1.1.4.yml @@ -0,0 +1,4 @@ +glslang: "11.5.0" +spirv-cross: "cci.20210621" +spirv-tools: "2021.2" +vulkan-headers: "1.2.182" diff --git a/recipes/moltenvk/all/dependencies/dependencies-1.1.5.yml b/recipes/moltenvk/all/dependencies/dependencies-1.1.5.yml new file mode 100644 index 0000000000000..f358857867637 --- /dev/null +++ b/recipes/moltenvk/all/dependencies/dependencies-1.1.5.yml @@ -0,0 +1,4 @@ +glslang: "11.6.0" +spirv-cross: "cci.20210823" +spirv-tools: "2021.3" +vulkan-headers: "1.2.189" diff --git a/recipes/moltenvk/all/dependencies/dependencies-1.1.6.yml b/recipes/moltenvk/all/dependencies/dependencies-1.1.6.yml new file mode 100644 index 0000000000000..50da3fc9cd75d --- /dev/null +++ b/recipes/moltenvk/all/dependencies/dependencies-1.1.6.yml @@ -0,0 +1,4 @@ +glslang: "11.7.0" +spirv-cross: "cci.20211113" +spirv-tools: "2021.4" +vulkan-headers: "1.2.198.0" diff --git a/recipes/moltenvk/all/dependencies/dependencies-1.1.8.yml b/recipes/moltenvk/all/dependencies/dependencies-1.1.8.yml new file mode 100644 index 0000000000000..a215ca2513dd4 --- /dev/null +++ b/recipes/moltenvk/all/dependencies/dependencies-1.1.8.yml @@ -0,0 +1,4 @@ +glslang: "1.3.204.0" +spirv-cross: "1.3.204.0" +spirv-tools: "1.3.204.0" +vulkan-headers: "1.3.204.1" diff --git a/recipes/moltenvk/all/dependencies/dependencies-1.1.9.yml b/recipes/moltenvk/all/dependencies/dependencies-1.1.9.yml new file mode 100644 index 0000000000000..d62197eb0b30f --- /dev/null +++ b/recipes/moltenvk/all/dependencies/dependencies-1.1.9.yml @@ -0,0 +1,4 @@ +glslang: "1.3.211.0" +spirv-cross: "1.3.211.0" +spirv-tools: "1.3.211.0" +vulkan-headers: "1.3.211.0" diff --git a/recipes/moltenvk/all/dependencies/dependencies-1.2.0.yml b/recipes/moltenvk/all/dependencies/dependencies-1.2.0.yml new file mode 100644 index 0000000000000..33e0cb279be8b --- /dev/null +++ b/recipes/moltenvk/all/dependencies/dependencies-1.2.0.yml @@ -0,0 +1,4 @@ +glslang: "1.3.231.1" +spirv-cross: "1.3.231.1" +spirv-tools: "1.3.231.1" +vulkan-headers: "1.3.231.1" diff --git a/recipes/moltenvk/all/patches/0001-fix-spirv-cross-includes-1.1.x.patch b/recipes/moltenvk/all/patches/1.1.0-0001-fix-spirv-cross-includes.patch similarity index 100% rename from recipes/moltenvk/all/patches/0001-fix-spirv-cross-includes-1.1.x.patch rename to recipes/moltenvk/all/patches/1.1.0-0001-fix-spirv-cross-includes.patch diff --git a/recipes/moltenvk/all/patches/1.1.11-0001-vulkan-alias-private-extern.patch b/recipes/moltenvk/all/patches/1.1.11-0001-vulkan-alias-private-extern.patch new file mode 100644 index 0000000000000..32ae960f5a370 --- /dev/null +++ b/recipes/moltenvk/all/patches/1.1.11-0001-vulkan-alias-private-extern.patch @@ -0,0 +1,21 @@ +--- a/Common/MVKCommonEnvironment.h ++++ b/Common/MVKCommonEnvironment.h +@@ -108,6 +108,9 @@ extern "C" { + /** Directive to make a public alias of another symbol. */ + #define MVK_PUBLIC_ALIAS(ALIAS, TARGET) asm(".globl _" #ALIAS "\n\t_" #ALIAS " = _" #TARGET) + ++/** Directive to make a private extern alias of another symbol. */ ++#define MVK_PRIVATE_EXTERN_ALIAS(ALIAS, TARGET) asm(".private_extern _" #ALIAS "\n\t_" #ALIAS " = _" #TARGET) ++ + /** + * Directives to hide public symbols from the Vulkan API, to avoid library linking + * conflicts when bound to a Vulkan Loader that also exports identical symbols. +@@ -117,7 +120,7 @@ extern "C" { + #endif + #if MVK_HIDE_VULKAN_SYMBOLS + # define MVK_PUBLIC_VULKAN_SYMBOL +-# define MVK_PUBLIC_VULKAN_ALIAS(ALIAS, TARGET) ++# define MVK_PUBLIC_VULKAN_ALIAS(ALIAS, TARGET) MVK_PRIVATE_EXTERN_ALIAS(ALIAS, TARGET) + #else + # define MVK_PUBLIC_VULKAN_SYMBOL MVK_PUBLIC_SYMBOL + # define MVK_PUBLIC_VULKAN_ALIAS(ALIAS, TARGET) MVK_PUBLIC_ALIAS(ALIAS, TARGET) diff --git a/recipes/moltenvk/all/patches/1.1.5-0001-allow-c++11-std.patch b/recipes/moltenvk/all/patches/1.1.5-0001-allow-c++11-std.patch new file mode 100644 index 0000000000000..283e7edc667aa --- /dev/null +++ b/recipes/moltenvk/all/patches/1.1.5-0001-allow-c++11-std.patch @@ -0,0 +1,16 @@ +upstream issue: https://github.com/KhronosGroup/MoltenVK/issues/1474 + +--- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm ++++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm +@@ -769,7 +769,10 @@ void MVKCommandEncoder::markTimestamp(MVKTimestampQueryPool* pQueryPool, uint32_ + if (sampPts) { + for (uint32_t qOfst = 0; qOfst < queryCount; qOfst++) { + if (mvkIsAnyFlagEnabled(sampPts, MVK_COUNTER_SAMPLING_AT_PIPELINE_STAGE)) { +- _timestampStageCounterQueries.push_back({ pQueryPool, query + qOfst }); ++ GPUCounterQuery timestampCounterQuery = {}; ++ timestampCounterQuery.queryPool = pQueryPool; ++ timestampCounterQuery.query = query + qOfst; ++ _timestampStageCounterQueries.push_back(timestampCounterQuery); + } else { + encodeGPUCounterSample(pQueryPool, query + qOfst, sampPts); + } diff --git a/recipes/moltenvk/all/patches/1.1.6-0001-allow-c++11-std.patch b/recipes/moltenvk/all/patches/1.1.6-0001-allow-c++11-std.patch new file mode 100644 index 0000000000000..65bfadc2ebffe --- /dev/null +++ b/recipes/moltenvk/all/patches/1.1.6-0001-allow-c++11-std.patch @@ -0,0 +1,16 @@ +upstream issue: https://github.com/KhronosGroup/MoltenVK/issues/1474 + +--- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm ++++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm +@@ -772,7 +772,10 @@ void MVKCommandEncoder::markTimestamp(MVKTimestampQueryPool* pQueryPool, uint32_ + MVKCounterSamplingFlags sampPts = _device->_pMetalFeatures->counterSamplingPoints; + for (uint32_t qOfst = 0; qOfst < queryCount; qOfst++) { + if (mvkIsAnyFlagEnabled(sampPts, MVK_COUNTER_SAMPLING_AT_PIPELINE_STAGE)) { +- _timestampStageCounterQueries.push_back({ pQueryPool, query + qOfst }); ++ GPUCounterQuery timestampCounterQuery = {}; ++ timestampCounterQuery.queryPool = pQueryPool; ++ timestampCounterQuery.query = query + qOfst; ++ _timestampStageCounterQueries.push_back(timestampCounterQuery); + } else { + encodeGPUCounterSample(pQueryPool, query + qOfst, sampPts); + } diff --git a/recipes/moltenvk/all/patches/1.1.8-0001-allow-c++11-std.patch b/recipes/moltenvk/all/patches/1.1.8-0001-allow-c++11-std.patch new file mode 100644 index 0000000000000..420e890ccf5f4 --- /dev/null +++ b/recipes/moltenvk/all/patches/1.1.8-0001-allow-c++11-std.patch @@ -0,0 +1,14 @@ +--- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm ++++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm +@@ -774,7 +774,10 @@ void MVKCommandEncoder::markTimestamp(MVKTimestampQueryPool* pQueryPool, uint32_ + MVKCounterSamplingFlags sampPts = _device->_pMetalFeatures->counterSamplingPoints; + for (uint32_t qOfst = 0; qOfst < queryCount; qOfst++) { + if (mvkIsAnyFlagEnabled(sampPts, MVK_COUNTER_SAMPLING_AT_PIPELINE_STAGE)) { +- _timestampStageCounterQueries.push_back({ pQueryPool, query + qOfst }); ++ GPUCounterQuery timestampCounterQuery = {}; ++ timestampCounterQuery.queryPool = pQueryPool; ++ timestampCounterQuery.query = query + qOfst; ++ _timestampStageCounterQueries.push_back(timestampCounterQuery); + } else { + encodeGPUCounterSample(pQueryPool, query + qOfst, sampPts); + } diff --git a/recipes/moltenvk/all/patches/1.1.8-0002-vulkan-alias-private-extern.patch b/recipes/moltenvk/all/patches/1.1.8-0002-vulkan-alias-private-extern.patch new file mode 100644 index 0000000000000..e488faca8335a --- /dev/null +++ b/recipes/moltenvk/all/patches/1.1.8-0002-vulkan-alias-private-extern.patch @@ -0,0 +1,21 @@ +--- a/Common/MVKCommonEnvironment.h ++++ b/Common/MVKCommonEnvironment.h +@@ -104,6 +104,9 @@ extern "C" { + /** Directive to make a public alias of another symbol. */ + #define MVK_PUBLIC_ALIAS(ALIAS, TARGET) asm(".globl _" #ALIAS "\n\t_" #ALIAS " = _" #TARGET) + ++/** Directive to make a private extern alias of another symbol. */ ++#define MVK_PRIVATE_EXTERN_ALIAS(ALIAS, TARGET) asm(".private_extern _" #ALIAS "\n\t_" #ALIAS " = _" #TARGET) ++ + /** + * Directives to hide public symbols from the Vulkan API, to avoid library linking + * conflicts when bound to a Vulkan Loader that also exports identical symbols. +@@ -113,7 +116,7 @@ extern "C" { + #endif + #if MVK_HIDE_VULKAN_SYMBOLS + # define MVK_PUBLIC_VULKAN_SYMBOL +-# define MVK_PUBLIC_VULKAN_ALIAS(ALIAS, TARGET) ++# define MVK_PUBLIC_VULKAN_ALIAS(ALIAS, TARGET) MVK_PRIVATE_EXTERN_ALIAS(ALIAS, TARGET) + #else + # define MVK_PUBLIC_VULKAN_SYMBOL MVK_PUBLIC_SYMBOL + # define MVK_PUBLIC_VULKAN_ALIAS(ALIAS, TARGET) MVK_PUBLIC_ALIAS(ALIAS, TARGET) diff --git a/recipes/moltenvk/all/patches/1.2.0-0001-fix-version-number-icd-json.patch b/recipes/moltenvk/all/patches/1.2.0-0001-fix-version-number-icd-json.patch new file mode 100644 index 0000000000000..6f8bf87465fe2 --- /dev/null +++ b/recipes/moltenvk/all/patches/1.2.0-0001-fix-version-number-icd-json.patch @@ -0,0 +1,11 @@ +--- a/MoltenVK/icd/MoltenVK_icd.json ++++ b/MoltenVK/icd/MoltenVK_icd.json +@@ -2,7 +2,7 @@ + "file_format_version" : "1.0.0", + "ICD": { + "library_path": "./libMoltenVK.dylib", +- "api_version" : "1.1.0", ++ "api_version" : "1.2.0", + "is_portability_driver" : true + } + } diff --git a/recipes/moltenvk/all/test_package/CMakeLists.txt b/recipes/moltenvk/all/test_package/CMakeLists.txt index 33ae887aa6aea..a5c97f937b4f7 100644 --- a/recipes/moltenvk/all/test_package/CMakeLists.txt +++ b/recipes/moltenvk/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(moltenvk REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE moltenvk::moltenvk) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/moltenvk/all/test_package/conanfile.py b/recipes/moltenvk/all/test_package/conanfile.py index 5216332f39f5c..0a6bc68712d90 100644 --- a/recipes/moltenvk/all/test_package/conanfile.py +++ b/recipes/moltenvk/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/moltenvk/all/test_v1_package/CMakeLists.txt b/recipes/moltenvk/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/moltenvk/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/moltenvk/all/test_v1_package/conanfile.py b/recipes/moltenvk/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/moltenvk/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/moltenvk/config.yml b/recipes/moltenvk/config.yml index f9d1ffa27feeb..df5b0f8614cc4 100644 --- a/recipes/moltenvk/config.yml +++ b/recipes/moltenvk/config.yml @@ -1,4 +1,20 @@ versions: + "1.2.0": + folder: all + "1.1.11": + folder: all + "1.1.10": + folder: all + "1.1.9": + folder: all + "1.1.8": + folder: all + "1.1.6": + folder: all + "1.1.5": + folder: all + "1.1.4": + folder: all "1.1.1": folder: all "1.1.0": diff --git a/recipes/mongo-c-driver/all/conandata.yml b/recipes/mongo-c-driver/all/conandata.yml index 6be5eafd51668..2546c26f4700e 100644 --- a/recipes/mongo-c-driver/all/conandata.yml +++ b/recipes/mongo-c-driver/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "1.22.0": + url: "https://github.com/mongodb/mongo-c-driver/releases/download/1.22.0/mongo-c-driver-1.22.0.tar.gz" + sha256: "272067f75e7e57c98f90a6f0c42500ef818b4b085539343676b6ce6831655eaf" + "1.17.6": + url: "https://github.com/mongodb/mongo-c-driver/releases/download/1.17.6/mongo-c-driver-1.17.6.tar.gz" + sha256: "8644deec7ae585e8d12566978f2017181e883f303a028b5b3ccb83c91248b150" "1.17.4": url: "https://github.com/mongodb/mongo-c-driver/releases/download/1.17.4/mongo-c-driver-1.17.4.tar.gz" sha256: "9ec8fe7fb54d636886fa823460658ccf660e3d82520d10810fb7c9d302ac974f" @@ -9,12 +15,15 @@ sources: url: "https://github.com/mongodb/mongo-c-driver/releases/download/1.17.2/mongo-c-driver-1.17.2.tar.gz" sha256: "bc53d5f72ab628a1ae549db6888325d6dc34db3ca31c5e16e550c1bb4266d864" patches: + "1.22.0": + - patch_file: "patches/1.22.0-0001-disable-shared-when-static.patch" + - patch_file: "patches/1.22.0-0002-fix-uninitialized-warning.patch" + - patch_file: "patches/1.22.0-0003-disable-warning-errors.patch" + "1.17.6": + - patch_file: "patches/1.17.6-0001-disable-shared-when-static.patch" "1.17.4": - - patch_file: "patches/disable-shared-when-static.patch" - base_path: "source_subfolder" + - patch_file: "patches/1.17.2-0001-disable-shared-when-static.patch" "1.17.3": - - patch_file: "patches/disable-shared-when-static.patch" - base_path: "source_subfolder" + - patch_file: "patches/1.17.2-0001-disable-shared-when-static.patch" "1.17.2": - - patch_file: "patches/disable-shared-when-static.patch" - base_path: "source_subfolder" + - patch_file: "patches/1.17.2-0001-disable-shared-when-static.patch" diff --git a/recipes/mongo-c-driver/all/conanfile.py b/recipes/mongo-c-driver/all/conanfile.py index 8c96dcded4f8a..e77d7e3ce949c 100644 --- a/recipes/mongo-c-driver/all/conanfile.py +++ b/recipes/mongo-c-driver/all/conanfile.py @@ -1,21 +1,26 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir +from conan.tools.gnu import PkgConfigDeps +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.53.0" class MongoCDriverConan(ConanFile): name = "mongo-c-driver" + description = "A Cross Platform MongoDB Client Library for C" license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" homepage = "https://mongoc.org/" - description = "A Cross Platform MongoDB Client Library for C" - topics = ("conan", "libbson", "libmongoc", "mongo", "mongodb", "database", "db") - settings = "os", "compiler", "build_type", "arch" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package", "pkg_config" - short_paths = True + topics = ("libbson", "libmongoc", "mongo", "mongodb", "database", "db") + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -25,9 +30,8 @@ class MongoCDriverConan(ConanFile): "with_zlib": [True, False], "with_zstd": [True, False], "with_icu": [True, False], - "srv": [True, False] + "srv": [True, False], } - default_options = { "shared": False, "fPIC": True, @@ -37,18 +41,13 @@ class MongoCDriverConan(ConanFile): "with_zlib": True, "with_zstd": True, "with_icu": True, - "srv": True + "srv": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + short_paths = True - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -56,56 +55,46 @@ def config_options(self): self.options.with_sasl = "sspi" def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd if self.options.shared: - del self.options.fPIC - if self.options.with_ssl == "darwin" and not tools.is_apple_os(self.settings.os): - raise ConanInvalidConfiguration("with_ssl=darwin only allowed on Apple os family") - if self.options.with_ssl == "windows" and self.settings.os != "Windows": - raise ConanInvalidConfiguration("with_ssl=windows only allowed on Windows") - if self.options.with_sasl == "sspi" and self.settings.os != "Windows": - raise ConanInvalidConfiguration("with_sasl=sspi only allowed on Windows") + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): if self.options.with_ssl == "openssl": - self.requires("openssl/1.1.1j") + self.requires("openssl/1.1.1s") elif self.options.with_ssl == "libressl": - self.requires("libressl/3.2.1") + self.requires("libressl/3.5.3") if self.options.with_sasl == "cyrus": self.requires("cyrus-sasl/2.1.27") if self.options.with_snappy: - self.requires("snappy/1.1.8") + self.requires("snappy/1.1.9") if self.options.with_zlib: - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.13") if self.options.with_zstd: - self.requires("zstd/1.4.8") + self.requires("zstd/1.5.2") if self.options.with_icu: - self.requires("icu/68.2") + self.requires("icu/71.1") + + def validate(self): + if self.info.options.with_ssl == "darwin" and not is_apple_os(self.settings.os): + raise ConanInvalidConfiguration("with_ssl=darwin only allowed on Apple os family") + if self.info.options.with_ssl == "windows" and self.info.settings.os != "Windows": + raise ConanInvalidConfiguration("with_ssl=windows only allowed on Windows") + if self.info.options.with_sasl == "sspi" and self.info.settings.os != "Windows": + raise ConanInvalidConfiguration("with_sasl=sspi only allowed on Windows") def build_requirements(self): if self.options.with_ssl == "libressl" or self.options.with_zstd: - self.build_requires("pkgconf/1.7.3") + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/1.9.3") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - to_replace_old_new = [ - # Fix Snappy - {"old": "include (FindSnappy)\nif (SNAPPY_INCLUDE_DIRS)", - "new": "if(ENABLE_SNAPPY MATCHES \"ON\")\n find_package(Snappy REQUIRED)"}, - {"old": "SNAPPY_LIBRARIES", "new": "Snappy_LIBRARIES"}, - {"old": "SNAPPY_INCLUDE_DIRS", "new": "Snappy_INCLUDE_DIRS"}, - # Fix LibreSSL - {"old": "set (SSL_LIBRARIES -ltls -lcrypto)", "new": ""}, - ] - for old_new in to_replace_old_new: - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "libmongoc", "CMakeLists.txt"), - old_new["old"], old_new["new"]) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) @property def _ssl_cmake_value(self): @@ -123,71 +112,115 @@ def _sasl_cmake_value(self): "cyrus": "CYRUS", }.get(str(self.options.with_sasl), "OFF") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP"] = "TRUE" - self._cmake.definitions["ENABLE_SSL"] = self._ssl_cmake_value - self._cmake.definitions["ENABLE_SASL"] = self._sasl_cmake_value - self._cmake.definitions["ENABLE_STATIC"] = "OFF" if self.options.shared else "ON" - self._cmake.definitions["ENABLE_TESTS"] = "OFF" - self._cmake.definitions["ENABLE_EXAMPLES"] = "OFF" - self._cmake.definitions["ENABLE_SRV"] = "ON" if self.options.srv else "OFF" - self._cmake.definitions["ENABLE_MAINTAINER_FLAGS"] = "OFF" - self._cmake.definitions["ENABLE_AUTOMATIC_INIT_AND_CLEANUP"] = "ON" - self._cmake.definitions["ENABLE_CRYPTO_SYSTEM_PROFILE"] = "OFF" - self._cmake.definitions["ENABLE_TRACING"] = "OFF" - self._cmake.definitions["ENABLE_COVERAGE"] = "OFF" - self._cmake.definitions["ENABLE_SHM_COUNTERS"] = "OFF" - self._cmake.definitions["ENABLE_MONGOC"] = "ON" - self._cmake.definitions["ENABLE_BSON"] = "ON" - self._cmake.definitions["ENABLE_SNAPPY"] = "ON" if self.options.with_snappy else "OFF" - self._cmake.definitions["ENABLE_ZLIB"] = "SYSTEM" if self.options.with_zlib else "OFF" - self._cmake.definitions["ENABLE_ZSTD"] = "ON" if self.options.with_zstd else "OFF" - self._cmake.definitions["ENABLE_MAN_PAGES"] = False - self._cmake.definitions["ENABLE_HTML_DOCS"] = False - self._cmake.definitions["ENABLE_EXTRA_ALIGNMENT"] = True - self._cmake.definitions["ENABLE_RDTSCP"] = False - self._cmake.definitions["ENABLE_APPLE_FRAMEWORK"] = False - self._cmake.definitions["ENABLE_ICU"] = "ON" if self.options.with_icu else "OFF" - self._cmake.definitions["ENABLE_UNINSTALL"] = False - self._cmake.definitions["ENABLE_CLIENT_SIDE_ENCRYPTION"] = "OFF" # libmongocrypt recipe not yet in CCI - self._cmake.definitions["ENABLE_MONGODB_AWS_AUTH"] = "AUTO" - self._cmake.definitions["ENABLE_PIC"] = self.options.get_safe("fPIC", True) + def generate(self): + tc = CMakeToolchain(self) + # All these variables are option() declared before project() in upstream CMakeLists + # therefore it defeats conan_toolchain variables, but it works fine with cache_variables + tc.cache_variables["ENABLE_SSL"] = self._ssl_cmake_value + tc.cache_variables["ENABLE_SASL"] = self._sasl_cmake_value + tc.cache_variables["ENABLE_STATIC"] = "OFF" if self.options.shared else "ON" + tc.cache_variables["ENABLE_TESTS"] = "OFF" + tc.cache_variables["ENABLE_EXAMPLES"] = "OFF" + tc.cache_variables["ENABLE_SRV"] = "ON" if self.options.srv else "OFF" + tc.cache_variables["ENABLE_MAINTAINER_FLAGS"] = "OFF" + tc.cache_variables["ENABLE_AUTOMATIC_INIT_AND_CLEANUP"] = "ON" + tc.cache_variables["ENABLE_CRYPTO_SYSTEM_PROFILE"] = "OFF" + tc.cache_variables["ENABLE_TRACING"] = "OFF" + tc.cache_variables["ENABLE_COVERAGE"] = "OFF" + tc.cache_variables["ENABLE_SHM_COUNTERS"] = "OFF" + tc.cache_variables["ENABLE_MONGOC"] = "ON" + tc.cache_variables["ENABLE_BSON"] = "ON" + tc.cache_variables["ENABLE_SNAPPY"] = "ON" if self.options.with_snappy else "OFF" + tc.cache_variables["ENABLE_ZLIB"] = "SYSTEM" if self.options.with_zlib else "OFF" + tc.cache_variables["ENABLE_ZSTD"] = "ON" if self.options.with_zstd else "OFF" + tc.cache_variables["ENABLE_MAN_PAGES"] = "OFF" + tc.cache_variables["ENABLE_HTML_DOCS"] = "OFF" + tc.cache_variables["ENABLE_EXTRA_ALIGNMENT"] = "ON" + tc.cache_variables["ENABLE_RDTSCP"] = "OFF" + tc.cache_variables["ENABLE_APPLE_FRAMEWORK"] = "OFF" + tc.cache_variables["ENABLE_ICU"] = "ON" if self.options.with_icu else "OFF" + tc.cache_variables["ENABLE_UNINSTALL"] = "OFF" + tc.cache_variables["ENABLE_CLIENT_SIDE_ENCRYPTION"] = "OFF" # libmongocrypt recipe not yet in CCI + tc.cache_variables["ENABLE_MONGODB_AWS_AUTH"] = "AUTO" + tc.cache_variables["ENABLE_PIC"] = "ON" if self.options.get_safe("fPIC", True) else "OFF" + # Avoid to install vc runtime stuff + tc.variables["CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP"] = "TRUE" if self.options.with_ssl == "openssl": - self._cmake.definitions["OPENSSL_ROOT_DIR"] = self.deps_cpp_info["openssl"].rootpath + tc.variables["OPENSSL_ROOT_DIR"] = self.dependencies["openssl"].package_folder.replace("\\", "/") + if Version(self.version) >= "1.20.0": + tc.variables["MONGO_USE_CCACHE"] = False + if is_msvc(self): + # Should be added because of + # https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initonceexecuteonce + tc.preprocessor_definitions["_WIN32_WINNT"] = "0x0600" + tc.generate() - self._cmake.configure(build_folder=self._build_subfolder) + deps = CMakeDeps(self) + deps.generate() - return self._cmake + if self.options.with_ssl == "libressl" or self.options.with_zstd: + deps = PkgConfigDeps(self) + deps.generate() + env = VirtualBuildEnv(self) + env.generate() + # TODO: to remove when properly handled by conan (see https://github.com/conan-io/conan/issues/11962) + env = Environment() + env.prepend_path("PKG_CONFIG_PATH", self.generators_folder) + envvars = env.vars(self) + envvars.save_script("conanbuildenv_pkg_config_path") + + def _patch_sources(self): + apply_conandata_patches(self) + to_replace_old_new = [ + # Fix Snappy + {"old": "include (FindSnappy)\nif (SNAPPY_INCLUDE_DIRS)", + "new": "if(ENABLE_SNAPPY MATCHES \"ON\")\n find_package(Snappy REQUIRED)"}, + {"old": "SNAPPY_LIBRARIES", "new": "Snappy_LIBRARIES"}, + {"old": "SNAPPY_INCLUDE_DIRS", "new": "Snappy_INCLUDE_DIRS"}, + # Fix LibreSSL + {"old": "set (SSL_LIBRARIES -ltls -lcrypto)", "new": ""}, + ] + for old_new in to_replace_old_new: + replace_in_file(self, os.path.join(self.source_folder, "src", "libmongoc", "CMakeLists.txt"), + old_new["old"], old_new["new"]) + # cleanup rpath + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)", "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - self.copy(pattern="THIRD_PARTY_NOTICES", dst="licenses", src=self._source_subfolder) - - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "THIRD_PARTY_NOTICES", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): # FIXME: two CMake module/config files should be generated (mongoc-1.0-config.cmake and bson-1.0-config.cmake), # but it can't be modeled right now. + mongoc_target = "mongoc_shared" if self.options.shared else "mongoc_static" + self.cpp_info.set_property("cmake_file_name", "mongoc-1.0") + self.cpp_info.set_property("cmake_target_name", f"mongo::{mongoc_target}") + self.cpp_info.filenames["cmake_find_package"] = "mongoc-1.0" self.cpp_info.filenames["cmake_find_package_multi"] = "mongoc-1.0" self.cpp_info.names["cmake_find_package"] = "mongo" self.cpp_info.names["cmake_find_package_multi"] = "mongo" + # mongoc - self.cpp_info.components["mongoc"].names["cmake_find_package"] = "mongoc_shared" if self.options.shared else "mongoc_static" - self.cpp_info.components["mongoc"].names["cmake_find_package_multi"] = "mongoc_shared" if self.options.shared else "mongoc_static" - self.cpp_info.components["mongoc"].names["pkg_config"] = "libmongoc-1.0" if self.options.shared else "libmongoc-static-1.0" + self.cpp_info.components["mongoc"].set_property("cmake_target_name", f"mongo::{mongoc_target}") + self.cpp_info.components["mongoc"].set_property("pkg_config_name", "libmongoc-1.0" if self.options.shared else "libmongoc-static-1.0") + + self.cpp_info.components["mongoc"].names["cmake_find_package"] = mongoc_target + self.cpp_info.components["mongoc"].names["cmake_find_package_multi"] = mongoc_target + self.cpp_info.components["mongoc"].includedirs = [os.path.join("include", "libmongoc-1.0")] self.cpp_info.components["mongoc"].libs = ["mongoc-1.0" if self.options.shared else "mongoc-static-1.0"] if not self.options.shared: @@ -217,15 +250,20 @@ def package_info(self): self.cpp_info.components["mongoc"].requires.append("icu::icu") if self.options.srv: self.cpp_info.components["mongoc"].system_libs.append("dnsapi" if self.settings.os == "Windows" else "resolv") + # bson - self.cpp_info.components["bson"].names["cmake_find_package"] = "bson_shared" if self.options.shared else "bson_static" - self.cpp_info.components["bson"].names["cmake_find_package_multi"] = "bson_shared" if self.options.shared else "bson_static" - self.cpp_info.components["bson"].names["pkg_config"] = "libbson-1.0" if self.options.shared else "libbson-static-1.0" + bson_target = "bson_shared" if self.options.shared else "bson_static" + self.cpp_info.components["bson"].set_property("cmake_target_name", f"mongo::{bson_target}") + self.cpp_info.components["bson"].set_property("pkg_config_name", "libbson-1.0" if self.options.shared else "libbson-static-1.0") + + self.cpp_info.components["bson"].names["cmake_find_package"] = bson_target + self.cpp_info.components["bson"].names["cmake_find_package_multi"] = bson_target + self.cpp_info.components["bson"].includedirs = [os.path.join("include", "libbson-1.0")] self.cpp_info.components["bson"].libs = ["bson-1.0" if self.options.shared else "bson-static-1.0"] if not self.options.shared: self.cpp_info.components["bson"].defines = ["BSON_STATIC"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["bson"].system_libs = ["m", "pthread", "rt"] elif self.settings.os == "Windows": self.cpp_info.components["bson"].system_libs = ["ws2_32"] diff --git a/recipes/mongo-c-driver/all/patches/disable-shared-when-static.patch b/recipes/mongo-c-driver/all/patches/1.17.2-0001-disable-shared-when-static.patch similarity index 100% rename from recipes/mongo-c-driver/all/patches/disable-shared-when-static.patch rename to recipes/mongo-c-driver/all/patches/1.17.2-0001-disable-shared-when-static.patch diff --git a/recipes/mongo-c-driver/all/patches/1.17.6-0001-disable-shared-when-static.patch b/recipes/mongo-c-driver/all/patches/1.17.6-0001-disable-shared-when-static.patch new file mode 100644 index 0000000000000..dad7659403d2b --- /dev/null +++ b/recipes/mongo-c-driver/all/patches/1.17.6-0001-disable-shared-when-static.patch @@ -0,0 +1,77 @@ +--- a/src/libbson/CMakeLists.txt ++++ b/src/libbson/CMakeLists.txt +@@ -230,6 +230,7 @@ set (HEADERS_FORWARDING + ${PROJECT_SOURCE_DIR}/src/bson/forwarding/bson.h + ) + ++if (NOT MONGOC_ENABLE_STATIC_BUILD) + add_library (bson_shared SHARED ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) + set (CMAKE_CXX_VISIBILITY_PRESET hidden) + target_compile_definitions (bson_shared PRIVATE BSON_COMPILATION JSONSL_PARSE_NAN) +@@ -279,6 +280,7 @@ if (WIN32) + # must be handled specially since we can't resolve them + set (BSON_SYSTEM_LIBRARIES ${BSON_SYSTEM_LIBRARIES} ws2_32) + endif () ++endif() + + if (MONGOC_ENABLE_STATIC_BUILD) + add_library (bson_static STATIC ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) +@@ -337,7 +339,7 @@ set (BSON_HEADER_INSTALL_DIR + ) + + if (MONGOC_ENABLE_STATIC_INSTALL) +- set (TARGETS_TO_INSTALL bson_shared bson_static) ++ set (TARGETS_TO_INSTALL bson_static) + else () + set (TARGETS_TO_INSTALL bson_shared) + endif () +--- a/src/libmongoc/CMakeLists.txt ++++ b/src/libmongoc/CMakeLists.txt +@@ -725,6 +725,7 @@ if (MONGOC_ENABLE_MONGODB_AWS_AUTH) + endif() + endif () + ++if (NOT MONGOC_ENABLE_STATIC_BUILD) + add_library (mongoc_shared SHARED ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) + set_target_properties (mongoc_shared PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidden) + target_link_libraries (mongoc_shared PRIVATE ${LIBRARIES} PUBLIC ${BSON_LIBRARIES}) +@@ -744,6 +745,7 @@ target_compile_definitions (mongoc_shared PRIVATE MONGOC_COMPILATION ${KMS_MSG_D + + set_target_properties (mongoc_shared PROPERTIES VERSION 0.0.0 SOVERSION 0) + set_target_properties (mongoc_shared PROPERTIES OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}-${MONGOC_API_VERSION}") ++endif() + + if (MONGOC_ENABLE_STATIC_BUILD) + add_library (mongoc_static STATIC ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) +@@ -766,6 +768,7 @@ if (MONGOC_ENABLE_STATIC_BUILD) + set_target_properties (mongoc_static PROPERTIES OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}-static-${MONGOC_API_VERSION}") + endif () + ++if (NOT MONGOC_ENABLE_STATIC_BUILD) + if (ENABLE_APPLE_FRAMEWORK) + set_target_properties (mongoc_shared PROPERTIES + FRAMEWORK TRUE +@@ -776,9 +779,14 @@ if (ENABLE_APPLE_FRAMEWORK) + PUBLIC_HEADER "${HEADERS}" + ) + endif () ++endif() + + add_executable (mongoc-stat ${PROJECT_SOURCE_DIR}/../../src/tools/mongoc-stat.c) ++if (NOT MONGOC_ENABLE_STATIC_BUILD) + target_link_libraries (mongoc-stat mongoc_shared ${LIBRARIES}) ++else () ++target_link_libraries (mongoc-stat mongoc_static ${STATIC_LIBRARIES}) ++endif () + + # mongoc-stat works if shared memory performance counters are enabled. + if (ENABLE_SHM_COUNTERS STREQUAL "ON") +@@ -1040,7 +1048,7 @@ file (COPY ${PROJECT_SOURCE_DIR}/tests/x509gen DESTINATION ${PROJECT_BINARY_DIR} + file (COPY ${PROJECT_SOURCE_DIR}/tests/release_files DESTINATION ${PROJECT_BINARY_DIR}/tests) + + if (MONGOC_ENABLE_STATIC_INSTALL) +- set (TARGETS_TO_INSTALL mongoc_shared mongoc_static) ++ set (TARGETS_TO_INSTALL mongoc_static) + else () + set (TARGETS_TO_INSTALL mongoc_shared) + endif () diff --git a/recipes/mongo-c-driver/all/patches/1.22.0-0001-disable-shared-when-static.patch b/recipes/mongo-c-driver/all/patches/1.22.0-0001-disable-shared-when-static.patch new file mode 100644 index 0000000000000..23d005b89467b --- /dev/null +++ b/recipes/mongo-c-driver/all/patches/1.22.0-0001-disable-shared-when-static.patch @@ -0,0 +1,77 @@ +--- a/src/libbson/CMakeLists.txt ++++ b/src/libbson/CMakeLists.txt +@@ -209,6 +209,7 @@ set (HEADERS_FORWARDING + ${PROJECT_SOURCE_DIR}/src/bson/forwarding/bson.h + ) + ++if (NOT MONGOC_ENABLE_STATIC_BUILD) + add_library (bson_shared SHARED ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) + set (CMAKE_CXX_VISIBILITY_PRESET hidden) + target_compile_definitions (bson_shared +@@ -275,6 +276,7 @@ if (WIN32) + # must be handled specially since we can't resolve them + set (BSON_SYSTEM_LIBRARIES ${BSON_SYSTEM_LIBRARIES} ws2_32) + endif () ++endif() + + if (MONGOC_ENABLE_STATIC_BUILD) + add_library (bson_static STATIC ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) +@@ -349,7 +351,7 @@ set (BSON_HEADER_INSTALL_DIR + ) + + if (MONGOC_ENABLE_STATIC_INSTALL) +- set (TARGETS_TO_INSTALL bson_shared bson_static) ++ set (TARGETS_TO_INSTALL bson_static) + else () + set (TARGETS_TO_INSTALL bson_shared) + endif () +--- a/src/libmongoc/CMakeLists.txt ++++ b/src/libmongoc/CMakeLists.txt +@@ -758,6 +758,7 @@ if (MONGOC_ENABLE_MONGODB_AWS_AUTH) + endif() + endif () + ++if (NOT MONGOC_ENABLE_STATIC_BUILD) + add_library (mongoc_shared SHARED ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) + set_target_properties (mongoc_shared PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidden) + target_link_libraries (mongoc_shared PRIVATE ${LIBRARIES} PUBLIC ${BSON_LIBRARIES}) +@@ -795,6 +796,7 @@ target_include_directories ( + + set_target_properties (mongoc_shared PROPERTIES VERSION 0.0.0 SOVERSION 0) + set_target_properties (mongoc_shared PROPERTIES OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}-${MONGOC_API_VERSION}") ++endif() + + if (MONGOC_ENABLE_STATIC_BUILD) + add_library (mongoc_static STATIC ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) +@@ -835,6 +837,7 @@ if (MONGOC_ENABLE_STATIC_BUILD) + set_target_properties (mongoc_static PROPERTIES OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}-static-${MONGOC_API_VERSION}") + endif () + ++if (NOT MONGOC_ENABLE_STATIC_BUILD) + if (ENABLE_APPLE_FRAMEWORK) + set_target_properties (mongoc_shared PROPERTIES + FRAMEWORK TRUE +@@ -845,9 +848,14 @@ if (ENABLE_APPLE_FRAMEWORK) + PUBLIC_HEADER "${HEADERS}" + ) + endif () ++endif() + + add_executable (mongoc-stat ${PROJECT_SOURCE_DIR}/../../src/tools/mongoc-stat.c) ++if (NOT MONGOC_ENABLE_STATIC_BUILD) + target_link_libraries (mongoc-stat mongoc_shared ${LIBRARIES}) ++else () ++target_link_libraries (mongoc-stat mongoc_static ${STATIC_LIBRARIES}) ++endif () + + # mongoc-stat works if shared memory performance counters are enabled. + if (ENABLE_SHM_COUNTERS STREQUAL "ON") +@@ -1161,7 +1169,7 @@ file (COPY ${PROJECT_SOURCE_DIR}/tests/x509gen DESTINATION ${PROJECT_BINARY_DIR} + file (COPY ${PROJECT_SOURCE_DIR}/tests/release_files DESTINATION ${PROJECT_BINARY_DIR}/tests) + + if (MONGOC_ENABLE_STATIC_INSTALL) +- set (TARGETS_TO_INSTALL mongoc_shared mongoc_static) ++ set (TARGETS_TO_INSTALL mongoc_static) + else () + set (TARGETS_TO_INSTALL mongoc_shared) + endif () diff --git a/recipes/mongo-c-driver/all/patches/1.22.0-0002-fix-uninitialized-warning.patch b/recipes/mongo-c-driver/all/patches/1.22.0-0002-fix-uninitialized-warning.patch new file mode 100644 index 0000000000000..3c24ab717c0d5 --- /dev/null +++ b/recipes/mongo-c-driver/all/patches/1.22.0-0002-fix-uninitialized-warning.patch @@ -0,0 +1,13 @@ +diff --git a/src/libbson/src/bson/bson-iter.c b/src/libbson/src/bson/bson-iter.c +index 7b4630f..ee70f12 100644 +--- a/src/libbson/src/bson/bson-iter.c ++++ b/src/libbson/src/bson/bson-iter.c +@@ -2141,7 +2141,7 @@ bson_iter_visit_all (bson_iter_t *iter, /* INOUT */ + + if (iter->err_off) { + if (unsupported && visitor->visit_unsupported_type && +- bson_utf8_validate (key, strlen (key), false)) { ++ key != NULL && bson_utf8_validate (key, strlen (key), false)) { + visitor->visit_unsupported_type (iter, key, bson_type, data); + return false; + } diff --git a/recipes/mongo-c-driver/all/patches/1.22.0-0003-disable-warning-errors.patch b/recipes/mongo-c-driver/all/patches/1.22.0-0003-disable-warning-errors.patch new file mode 100644 index 0000000000000..2ade48e877823 --- /dev/null +++ b/recipes/mongo-c-driver/all/patches/1.22.0-0003-disable-warning-errors.patch @@ -0,0 +1,15 @@ +diff --git a/build/cmake/MongoC-Warnings.cmake b/build/cmake/MongoC-Warnings.cmake +index 4784c93..99745c3 100644 +--- a/build/cmake/MongoC-Warnings.cmake ++++ b/build/cmake/MongoC-Warnings.cmake +@@ -58,10 +58,6 @@ mongoc_add_platform_compile_options ( + gnu-like:$<${is_c_lang}:-Werror=implicit> msvc:/we4013 msvc:/we4431 + # Missing return types/statements + gnu-like:-Werror=return-type msvc:/we4716 +- # Incompatible pointer types +- gnu-like:$<$:-Werror=incompatible-pointer-types> msvc:/we4113 +- # Integral/pointer conversions +- gnu-like:$<$:-Werror=int-conversion> msvc:/we4047 + # Discarding qualifiers + gnu:$<$:-Werror=discarded-qualifiers> + clang:$<${is_c_lang}:-Werror=ignored-qualifiers> diff --git a/recipes/mongo-c-driver/all/test_package/CMakeLists.txt b/recipes/mongo-c-driver/all/test_package/CMakeLists.txt index 651492dd1a608..9ed8451d03a20 100644 --- a/recipes/mongo-c-driver/all/test_package/CMakeLists.txt +++ b/recipes/mongo-c-driver/all/test_package/CMakeLists.txt @@ -1,14 +1,11 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +project(test_package LANGUAGES C) find_package(mongoc-1.0 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -if(MONGO-C-DRIVER_SHARED) - target_link_libraries(${PROJECT_NAME} mongo::mongoc_shared mongo::bson_shared) +if(TARGET mongo::mongoc_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongoc_shared mongo::bson_shared) else() - target_link_libraries(${PROJECT_NAME} mongo::mongoc_static mongo::bson_static) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongoc_static mongo::bson_static) endif() diff --git a/recipes/mongo-c-driver/all/test_package/conanfile.py b/recipes/mongo-c-driver/all/test_package/conanfile.py index 59bc31b38dea1..0a6bc68712d90 100644 --- a/recipes/mongo-c-driver/all/test_package/conanfile.py +++ b/recipes/mongo-c-driver/all/test_package/conanfile.py @@ -1,18 +1,26 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) - cmake.definitions["MONGO-C-DRIVER_SHARED"] = self.options["mongo-c-driver"].shared cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mongo-c-driver/all/test_v1_package/CMakeLists.txt b/recipes/mongo-c-driver/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/mongo-c-driver/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/mongo-c-driver/all/test_v1_package/conanfile.py b/recipes/mongo-c-driver/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mongo-c-driver/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mongo-c-driver/config.yml b/recipes/mongo-c-driver/config.yml index 5b43d57ddf803..59ca0a1a54b12 100644 --- a/recipes/mongo-c-driver/config.yml +++ b/recipes/mongo-c-driver/config.yml @@ -1,4 +1,8 @@ versions: + "1.22.0": + folder: all + "1.17.6": + folder: all "1.17.4": folder: all "1.17.3": diff --git a/recipes/mongo-cxx-driver/all/CMakeLists.txt b/recipes/mongo-cxx-driver/all/CMakeLists.txt deleted file mode 100644 index ad95cfd8209a3..0000000000000 --- a/recipes/mongo-cxx-driver/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory("source_subfolder") diff --git a/recipes/mongo-cxx-driver/all/conandata.yml b/recipes/mongo-cxx-driver/all/conandata.yml index cda74d8b9e1f7..9c36439157a9b 100644 --- a/recipes/mongo-cxx-driver/all/conandata.yml +++ b/recipes/mongo-cxx-driver/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "3.6.7": + url: "https://github.com/mongodb/mongo-cxx-driver/archive/debian/3.6.7-1.tar.gz" + sha256: "62a0a16e4a35289e1692f60cf07a7f6957485446b7bc1d82306b731ad6763fb9" + "3.6.6": + url: "https://github.com/mongodb/mongo-cxx-driver/archive/r3.6.6.tar.gz" + sha256: "f989c371800458ae45ef69f6d9566e010f9420435a01bf5eb14db77fc024662e" "3.6.2": url: "https://github.com/mongodb/mongo-cxx-driver/archive/r3.6.2.tar.gz" sha256: "f50a1acb98a473f0850e2766dc7e84c05415dc63b1a2f851b77b12629ac14d62" @@ -6,17 +12,15 @@ sources: url: https://github.com/mongodb/mongo-cxx-driver/archive/r3.6.1.tar.gz sha256: c6d1b307f7b074d178c4a815d8739195fb4d7870701064bdad6f1f2360ae0af9 patches: + "3.6.7": + - patch_file: "patches/dirs_and_tests.patch" + - patch_file: "patches/poly_use_std_define.patch" + "3.6.6": + - patch_file: "patches/dirs_and_tests.patch" + - patch_file: "patches/poly_use_std_define.patch" "3.6.2": - patch_file: "patches/dirs_and_tests.patch" - base_path: "source_subfolder" - - patch_file: "patches/link_conan_boost.patch" - base_path: "source_subfolder" - patch_file: "patches/poly_use_std_define.patch" - base_path: "source_subfolder" "3.6.1": - patch_file: "patches/dirs_and_tests.patch" - base_path: "source_subfolder" - - patch_file: "patches/link_conan_boost.patch" - base_path: "source_subfolder" - patch_file: "patches/poly_use_std_define.patch" - base_path: "source_subfolder" diff --git a/recipes/mongo-cxx-driver/all/conanfile.py b/recipes/mongo-cxx-driver/all/conanfile.py index b67fe29f687f5..0325bf551fe00 100644 --- a/recipes/mongo-cxx-driver/all/conanfile.py +++ b/recipes/mongo-cxx-driver/all/conanfile.py @@ -1,11 +1,13 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanException, ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd, valid_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rm, rmdir +from conan.tools.scm import Version import os -import glob import shutil - -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.51.1" class MongoCxxConan(ConanFile): @@ -14,37 +16,39 @@ class MongoCxxConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "http://mongocxx.org" description = "C++ Driver for MongoDB" - topics = ("conan", "libbsoncxx", "libmongocxx", "mongo", "mongodb", "database", "db") - settings = "os", "compiler", "arch", "build_type" - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = ("cmake", "cmake_find_package") + topics = ("libbsoncxx", "libmongocxx", "mongo", "mongodb", "database", "db") + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "polyfill": ["std", "boost", "mnmlstc", "experimental"], - "with_ssl": [True, False] + "with_ssl": [True, False], } default_options = { "shared": False, "fPIC": True, "polyfill": "boost", - "with_ssl": True + "with_ssl": True, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("mongo-c-driver/1.22.0") + if self.options.polyfill == "boost": + self.requires("boost/1.79.0") + @property def _minimal_std_version(self): return { @@ -56,7 +60,7 @@ def _minimal_std_version(self): @property def _compilers_minimum_version(self): - if self.options.polyfill == "std": + if self.info.options.polyfill == "std": # C++17 return { "Visual Studio": "15", @@ -64,7 +68,7 @@ def _compilers_minimum_version(self): "clang": "5", "apple-clang": "10" } - elif self.options.polyfill == "experimental": + elif self.info.options.polyfill == "experimental": # C++14 return { "Visual Studio": "15", @@ -72,7 +76,7 @@ def _compilers_minimum_version(self): "clang": "3.5", "apple-clang": "10" } - elif self.options.polyfill == "boost": + elif self.info.options.polyfill == "boost": # C++11 return { "Visual Studio": "14", @@ -81,124 +85,118 @@ def _compilers_minimum_version(self): "apple-clang": "9" } else: - raise ConanInvalidConfiguration( - "please, specify _compilers_minimum_version for {} polyfill".format(self.options.polyfill) + raise ConanException( + f"please, specify _compilers_minimum_version for {self.options.polyfill} polyfill" ) - def configure(self): - if self.options.shared: - del self.options.fPIC - - def requirements(self): - self.requires("mongo-c-driver/1.17.3") - if self.options.polyfill == "boost": - self.requires("boost/1.75.0") - def validate(self): - if self.options.with_ssl and not bool(self.options["mongo-c-driver"].with_ssl): + if self.info.options.with_ssl and not bool(self.dependencies["mongo-c-driver"].options.with_ssl): raise ConanInvalidConfiguration("mongo-cxx-driver with_ssl=True requires mongo-c-driver with a ssl implementation") - if self.options.polyfill == "mnmlstc": + if self.info.options.polyfill == "mnmlstc": # TODO: add mnmlstc polyfill support # Cannot model mnmlstc (not packaged, is pulled dynamically) polyfill dependencies raise ConanInvalidConfiguration("mnmlstc polyfill is not yet supported") - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._minimal_std_version) + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._minimal_std_version) - compiler = str(self.settings.compiler) - if self.options.polyfill == "experimental" and compiler == "apple-clang": + compiler = str(self.info.settings.compiler) + if self.info.options.polyfill == "experimental" and compiler == "apple-clang": raise ConanInvalidConfiguration("experimental polyfill is not supported for apple-clang") - if compiler not in self._compilers_minimum_version: - self.output.warn("Unknown compiler, assuming it supports at least C++{}".format(self._minimal_std_version)) - return - - version = tools.Version(self.settings.compiler.version) - if version < self._compilers_minimum_version[compiler]: + version = Version(self.info.settings.compiler.version) + if compiler in self._compilers_minimum_version and version < self._compilers_minimum_version[compiler]: raise ConanInvalidConfiguration( - "{} requires a compiler that supports at least C++{}".format( - self.name, - self._minimal_std_version - ) + f"{self.name} {self.version} requires a compiler that supports at least C++{self._minimal_std_version}", ) + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-r" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - - self._cmake = CMake(self) - self._cmake.definitions["BSONCXX_POLY_USE_MNMLSTC"] = self.options.polyfill == "mnmlstc" - self._cmake.definitions["BSONCXX_POLY_USE_STD"] = self.options.polyfill == "std" - self._cmake.definitions["BSONCXX_POLY_USE_STD_EXPERIMENTAL"] = self.options.polyfill == "experimental" - self._cmake.definitions["BSONCXX_POLY_USE_BOOST"] = self.options.polyfill == "boost" - self._cmake.definitions["BUILD_VERSION"] = self.version - self._cmake.definitions["BSONCXX_LINK_WITH_STATIC_MONGOC"] = not self.options["mongo-c-driver"].shared - self._cmake.definitions["MONGOCXX_LINK_WITH_STATIC_MONGOC"] = not self.options["mongo-c-driver"].shared - self._cmake.definitions["MONGOCXX_ENABLE_SSL"] = self.options.with_ssl - if self.settings.compiler.get_safe("cppstd") is None: - self.output.warn("The recipe will force the cppstd to {}".format(self._minimal_std_version)) - self._cmake.definitions["CMAKE_CXX_STANDARD"] = self._minimal_std_version + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BSONCXX_POLY_USE_MNMLSTC"] = self.options.polyfill == "mnmlstc" + tc.variables["BSONCXX_POLY_USE_STD"] = self.options.polyfill == "std" + tc.variables["BSONCXX_POLY_USE_STD_EXPERIMENTAL"] = self.options.polyfill == "experimental" + tc.variables["BSONCXX_POLY_USE_BOOST"] = self.options.polyfill == "boost" + tc.cache_variables["BUILD_VERSION"] = self.version + tc.cache_variables["BSONCXX_LINK_WITH_STATIC_MONGOC"] = "OFF" if self.dependencies["mongo-c-driver"].options.shared else "ON" + tc.cache_variables["MONGOCXX_LINK_WITH_STATIC_MONGOC"] = "OFF" if self.dependencies["mongo-c-driver"].options.shared else "ON" + tc.variables["MONGOCXX_ENABLE_SSL"] = self.options.with_ssl + if not valid_min_cppstd(self, self._minimal_std_version): + tc.variables["CMAKE_CXX_STANDARD"] = self._minimal_std_version + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + deps = CMakeDeps(self) + deps.generate() # FIXME: two CMake module/config files should be generated (mongoc-1.0-config.cmake and bson-1.0-config.cmake), # but it can't be modeled right now. # Fix should happen in mongo-c-driver recipe - if not os.path.exists("Findbson-1.0.cmake"): + mongoc_config_file = os.path.join(self.generators_folder, "mongoc-1.0-config.cmake") + bson_config_file = os.path.join(self.generators_folder, "bson-1.0-config.cmake") + if not os.path.exists(bson_config_file): self.output.info("Copying mongoc config file to bson") - shutil.copy("Findmongoc-1.0.cmake", "Findbson-1.0.cmake") - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + shutil.copy(src=mongoc_config_file, dst=bson_config_file) def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="THIRD-PARTY-NOTICES", dst="licenses", src=self._source_subfolder) - - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "THIRD-PARTY-NOTICES", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - if self.settings.os == "Windows": - for dll_file in glob.glob(os.path.join(self.package_folder, "bin", "*.dll")): - if os.path.basename(dll_file).startswith(("concrt", "msvcp", "vcruntime")): - os.remove(dll_file) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + for vc_file in ("concrt", "msvcp", "vcruntime"): + rm(self, f"{vc_file}*.dll", os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): # FIXME: two CMake module/config files should be generated (mongocxx-config.cmake and bsoncxx-config.cmake), # but it can't be modeled right now. + mongocxx_target = "mongocxx_shared" if self.options.shared else "mongocxx_static" + self.cpp_info.set_property("cmake_file_name", "mongocxx") + self.cpp_info.set_property("cmake_target_name", f"mongo::{mongocxx_target}") + self.cpp_info.filenames["cmake_find_package"] = "mongocxx" self.cpp_info.filenames["cmake_find_package_multi"] = "mongocxx" self.cpp_info.names["cmake_find_package"] = "mongo" self.cpp_info.names["cmake_find_package_multi"] = "mongo" # mongocxx - self.cpp_info.components["mongocxx"].names["cmake_find_package"] = "mongocxx_shared" if self.options.shared else "mongocxx_static" - self.cpp_info.components["mongocxx"].names["cmake_find_package_multi"] = "mongocxx_shared" if self.options.shared else "mongocxx_static" - self.cpp_info.components["mongocxx"].names["pkg_config"] = "libmongocxx" + self.cpp_info.components["mongocxx"].set_property("cmake_target_name", f"mongo::{mongocxx_target}") + self.cpp_info.components["mongocxx"].set_property("pkg_config_name", "libmongocxx" if self.options.shared else "libmongocxx-static") + + self.cpp_info.components["mongocxx"].names["cmake_find_package"] = mongocxx_target + self.cpp_info.components["mongocxx"].names["cmake_find_package_multi"] = mongocxx_target + self.cpp_info.components["mongocxx"].libs = ["mongocxx" if self.options.shared else "mongocxx-static"] if not self.options.shared: self.cpp_info.components["mongocxx"].defines.append("MONGOCXX_STATIC") self.cpp_info.components["mongocxx"].requires = ["mongo-c-driver::mongoc", "bsoncxx"] # bsoncxx - self.cpp_info.components["bsoncxx"].names["cmake_find_package"] = "bsoncxx_shared" if self.options.shared else "bsoncxx_static" - self.cpp_info.components["bsoncxx"].names["cmake_find_package_multi"] = "bsoncxx_shared" if self.options.shared else "bsoncxx_static" - self.cpp_info.components["bsoncxx"].names["pkg_config"] = "libbsoncxx" if self.options.shared else "libbsoncxx-static" + bsoncxx_target = "bsoncxx_shared" if self.options.shared else "bsoncxx_static" + self.cpp_info.components["bsoncxx"].set_property("cmake_target_name", f"mongo::{bsoncxx_target}") + self.cpp_info.components["bsoncxx"].set_property("pkg_config_name", "libbsoncxx" if self.options.shared else "libbsoncxx-static") + + self.cpp_info.components["bsoncxx"].names["cmake_find_package"] = bsoncxx_target + self.cpp_info.components["bsoncxx"].names["cmake_find_package_multi"] = bsoncxx_target + self.cpp_info.components["bsoncxx"].libs = ["bsoncxx" if self.options.shared else "bsoncxx-static"] if not self.options.shared: self.cpp_info.components["bsoncxx"].defines = ["BSONCXX_STATIC"] self.cpp_info.components["bsoncxx"].requires = ["mongo-c-driver::bson"] if self.options.polyfill == "boost": - self.cpp_info.components["bsoncxx"].requires.append("boost::boost") + self.cpp_info.components["bsoncxx"].requires.append("boost::headers") diff --git a/recipes/mongo-cxx-driver/all/patches/dirs_and_tests.patch b/recipes/mongo-cxx-driver/all/patches/dirs_and_tests.patch index 9febde050e8c8..f1fed9501d06a 100644 --- a/recipes/mongo-cxx-driver/all/patches/dirs_and_tests.patch +++ b/recipes/mongo-cxx-driver/all/patches/dirs_and_tests.patch @@ -61,7 +61,7 @@ index 7c79f45..0fcb305 100644 # Attempt to find libbson by new package name (without lib). -find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} QUIET) -+find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED) ++find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED) +set(bson-${LIBBSON_REQUIRED_ABI_VERSION}_FOUND TRUE) if(bson-${LIBBSON_REQUIRED_ABI_VERSION}_FOUND) diff --git a/recipes/mongo-cxx-driver/all/patches/link_conan_boost.patch b/recipes/mongo-cxx-driver/all/patches/link_conan_boost.patch deleted file mode 100644 index 759e014c4dce7..0000000000000 --- a/recipes/mongo-cxx-driver/all/patches/link_conan_boost.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake -index b38f9af..7ec9d72 100644 ---- a/cmake/BsoncxxUtil.cmake -+++ b/cmake/BsoncxxUtil.cmake -@@ -36,7 +36,7 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) - if (CMAKE_VERSION VERSION_LESS 3.15.0) - target_include_directories(${TARGET} PUBLIC ${Boost_INCLUDE_DIRS}) - else() -- target_link_libraries(${TARGET} PUBLIC Boost::boost) -+ target_link_libraries(${TARGET} PUBLIC CONAN_PKG::boost) - endif() - endif() - diff --git a/recipes/mongo-cxx-driver/all/test_package/CMakeLists.txt b/recipes/mongo-cxx-driver/all/test_package/CMakeLists.txt index d613abff648bb..3d606dc3359ce 100644 --- a/recipes/mongo-cxx-driver/all/test_package/CMakeLists.txt +++ b/recipes/mongo-cxx-driver/all/test_package/CMakeLists.txt @@ -1,23 +1,20 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(mongocxx REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) if(${MONGO-CXX-DRIVER_POLYFILL} STREQUAL "std") - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) elseif(${MONGO-CXX-DRIVER_POLYFILL} STREQUAL "experimental") - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) else() - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) endif() -if(MONGO-CXX-DRIVER_SHARED) - target_link_libraries(${PROJECT_NAME} mongo::mongocxx_shared mongo::bsoncxx_shared) +if(TARGET mongo::mongocxx_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongocxx_shared mongo::bsoncxx_shared) else() - target_link_libraries(${PROJECT_NAME} mongo::mongocxx_static mongo::bsoncxx_static) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongocxx_static mongo::bsoncxx_static) endif() diff --git a/recipes/mongo-cxx-driver/all/test_package/conanfile.py b/recipes/mongo-cxx-driver/all/test_package/conanfile.py index 33be9554b32c5..a650aa79a9355 100644 --- a/recipes/mongo-cxx-driver/all/test_package/conanfile.py +++ b/recipes/mongo-cxx-driver/all/test_package/conanfile.py @@ -1,18 +1,30 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MONGO-CXX-DRIVER_POLYFILL"] = self.dependencies["mongo-cxx-driver"].options.polyfill + tc.generate() def build(self): cmake = CMake(self) - cmake.definitions["MONGO-CXX-DRIVER_SHARED"] = self.options["mongo-cxx-driver"].shared - cmake.definitions["MONGO-CXX-DRIVER_POLYFILL"] = self.options["mongo-cxx-driver"].polyfill cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mongo-cxx-driver/all/test_v1_package/CMakeLists.txt b/recipes/mongo-cxx-driver/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..20e6aa5c91caf --- /dev/null +++ b/recipes/mongo-cxx-driver/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(mongocxx REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) + +if(${MONGO-CXX-DRIVER_POLYFILL} STREQUAL "std") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +elseif(${MONGO-CXX-DRIVER_POLYFILL} STREQUAL "experimental") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +endif() + +if(TARGET mongo::mongocxx_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongocxx_shared mongo::bsoncxx_shared) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongocxx_static mongo::bsoncxx_static) +endif() diff --git a/recipes/mongo-cxx-driver/all/test_v1_package/conanfile.py b/recipes/mongo-cxx-driver/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..51b7ca5da9cc7 --- /dev/null +++ b/recipes/mongo-cxx-driver/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["MONGO-CXX-DRIVER_POLYFILL"] = self.options["mongo-cxx-driver"].polyfill + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/mongo-cxx-driver/config.yml b/recipes/mongo-cxx-driver/config.yml index bfe5b909d834d..f7b7e026a30f6 100644 --- a/recipes/mongo-cxx-driver/config.yml +++ b/recipes/mongo-cxx-driver/config.yml @@ -1,4 +1,8 @@ versions: + "3.6.7": + folder: all + "3.6.6": + folder: all "3.6.2": folder: all "3.6.1": diff --git a/recipes/morton-nd/all/conandata.yml b/recipes/morton-nd/all/conandata.yml index f5e8df0c9a525..41b2951c67096 100644 --- a/recipes/morton-nd/all/conandata.yml +++ b/recipes/morton-nd/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "4.0.0": + url: "https://github.com/kevinhartman/morton-nd/archive/refs/tags/v4.0.0.tar.gz" + sha256: "29337c7f7afb6361dd483ca4fe2111aad9d590f3b9d3fe519856a5bdf450e059" "3.0.0": url: "https://github.com/kevinhartman/morton-nd/archive/v3.0.0.tar.gz" sha256: "ba57df04a2e1e73709f55fd3fee71082750013c5792de3c6eb84a8c87d40d781" diff --git a/recipes/morton-nd/all/conanfile.py b/recipes/morton-nd/all/conanfile.py index 03e6c5435091e..5e3263ed60dd4 100644 --- a/recipes/morton-nd/all/conanfile.py +++ b/recipes/morton-nd/all/conanfile.py @@ -1,54 +1,80 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +required_conan_version = ">=1.50.0" + class MortonndConan(ConanFile): name = "morton-nd" description = "A header-only Morton encode/decode library (C++14) capable " \ "of encoding from and decoding to N-dimensional space." license = "MIT" - topics = ("conan", "morton-nd", "morton", "encoding", "decoding", "n-dimensional") + topics = ("morton-nd", "morton", "encoding", "decoding", "n-dimensional") homepage = "https://github.com/kevinhartman/morton-nd" url = "https://github.com/conan-io/conan-center-index" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True @property - def _source_subfolder(self): - return "source_subfolder" + def _min_cppstd(self): + return "14" @property def _compilers_minimum_version(self): return { "gcc": "5", "Visual Studio": "14", + "msvc": "190", "clang": "3.4", "apple-clang": "5.1", } - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 14) + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if not minimum_version: - self.output.warn("morton-nd requires C++14. Your compiler is unknown. Assuming it supports C++14.") - elif tools.Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration("morton-nd requires C++14, which your compiler does not support.") + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.", + ) - def package_id(self): - self.info.header_only() + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "morton-nd") + self.cpp_info.set_property("cmake_target_name", "morton-nd::MortonND") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once legacy generators removed self.cpp_info.names["cmake_find_package"] = "morton-nd" self.cpp_info.names["cmake_find_package_multi"] = "morton-nd" self.cpp_info.components["mortonnd"].names["cmake_find_package"] = "MortonND" self.cpp_info.components["mortonnd"].names["cmake_find_package_multi"] = "MortonND" + self.cpp_info.components["mortonnd"].set_property("cmake_target_name", "morton-nd::MortonND") + self.cpp_info.components["mortonnd"].bindirs = [] + self.cpp_info.components["mortonnd"].frameworkdirs = [] + self.cpp_info.components["mortonnd"].libdirs = [] + self.cpp_info.components["mortonnd"].resdirs = [] diff --git a/recipes/morton-nd/all/test_package/CMakeLists.txt b/recipes/morton-nd/all/test_package/CMakeLists.txt index d8e2ac07a0ac7..3d6da2fa9a946 100644 --- a/recipes/morton-nd/all/test_package/CMakeLists.txt +++ b/recipes/morton-nd/all/test_package/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(morton-nd REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} morton-nd::MortonND) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +target_link_libraries(${PROJECT_NAME} PRIVATE morton-nd::MortonND) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +if(morton-nd_VERSION VERSION_LESS "4.0.0") + target_compile_definitions(${PROJECT_NAME} PRIVATE "MORTONND_LESS_4_0_0") +endif() diff --git a/recipes/morton-nd/all/test_package/conanfile.py b/recipes/morton-nd/all/test_package/conanfile.py index 7e2dfe859bb27..d120a992c06a6 100644 --- a/recipes/morton-nd/all/test_package/conanfile.py +++ b/recipes/morton-nd/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/morton-nd/all/test_package/test_package.cpp b/recipes/morton-nd/all/test_package/test_package.cpp index 1640b0f2989d9..20216f26365e9 100644 --- a/recipes/morton-nd/all/test_package/test_package.cpp +++ b/recipes/morton-nd/all/test_package/test_package.cpp @@ -1,4 +1,8 @@ +#ifdef MORTONND_LESS_4_0_0 #include +#else +#include +#endif int main() { constexpr auto MortonND_3D_64 = mortonnd::MortonNDLutEncoder<5, 12, 4>(); diff --git a/recipes/morton-nd/all/test_v1_package/CMakeLists.txt b/recipes/morton-nd/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..07fa1c30a5235 --- /dev/null +++ b/recipes/morton-nd/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(morton-nd REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE morton-nd::MortonND) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +if(morton-nd_VERSION VERSION_LESS "4.0.0") + target_compile_definitions(${PROJECT_NAME} PRIVATE "MORTONND_LESS_4_0_0") +endif() diff --git a/recipes/morton-nd/all/test_v1_package/conanfile.py b/recipes/morton-nd/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/morton-nd/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/morton-nd/config.yml b/recipes/morton-nd/config.yml index c6ac749e0b234..b1681bacb18ae 100644 --- a/recipes/morton-nd/config.yml +++ b/recipes/morton-nd/config.yml @@ -1,3 +1,5 @@ versions: + "4.0.0": + folder: all "3.0.0": folder: all diff --git a/recipes/mosquitto/2.x/conandata.yml b/recipes/mosquitto/2.x/conandata.yml index fa041dfeb78ac..622f72a77af8b 100644 --- a/recipes/mosquitto/2.x/conandata.yml +++ b/recipes/mosquitto/2.x/conandata.yml @@ -1,4 +1,16 @@ sources: + "2.0.15": + url: "https://github.com/eclipse/mosquitto/archive/v2.0.15.tar.gz" + sha256: "26dc3f1758b00c1725a0e4dd32f40c61f374375717f09b6af2bac62c5b44f1eb" + "2.0.14": + url: "https://github.com/eclipse/mosquitto/archive/v2.0.14.tar.gz" + sha256: "c0ce97b1911d1769ccfd65da237e919fd7eaa60209fd190c113d63fbd0c40347" + "2.0.12": + url: "https://github.com/eclipse/mosquitto/archive/v2.0.12.tar.gz" + sha256: "b4995d1505f5643d98ff9a921e0399437fc95c4f0c92693cfe28401baf1fed21" + "2.0.11": + url: "https://github.com/eclipse/mosquitto/archive/v2.0.11.tar.gz" + sha256: "0d46f0cbfa98c353ea9562a9e1219f60b9530463ae98b68fbe9bc828fcf9dbbc" "2.0.10": url: "https://github.com/eclipse/mosquitto/archive/v2.0.10.tar.gz" sha256: "448e7cf4b422501c0ce7cb33caa8f31ac350118ce9fc5101db852c1f49a7d096" diff --git a/recipes/mosquitto/2.x/conanfile.py b/recipes/mosquitto/2.x/conanfile.py index 8df125e546e87..a2b39f2d1e5d0 100644 --- a/recipes/mosquitto/2.x/conanfile.py +++ b/recipes/mosquitto/2.x/conanfile.py @@ -1,8 +1,11 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.files import get, replace_in_file, rmdir, rm +from conan.tools.scm import Version +from conans import CMake -required_conan_version = ">=1.31.0" +required_conan_version = ">=1.47.0" class Mosquitto(ConanFile): @@ -13,23 +16,29 @@ class Mosquitto(ConanFile): description = """Eclipse Mosquitto MQTT library, broker and more""" topics = ("MQTT", "IoT", "eclipse") settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "ssl": [True, False], - "clients": [True, False], - "broker": [True, False], - "apps": [True, False], - "cjson": [True, False], - "build_cpp": [True, False], - "websockets": [True, False], - } - default_options = {"shared": False, - "ssl": True, - "clients": False, - "broker": False, - "apps": False, - "cjson": True, # https://github.com/eclipse/mosquitto/commit/bbe0afbfbe7bb392361de41e275759ee4ef06b1c - "build_cpp": True, - "websockets": False, + options = { + "shared": [True, False], + "fPIC": [True, False], + "ssl": [True, False], + "clients": [True, False], + "broker": [True, False], + "apps": [True, False], + "cjson": [True, False], + "build_cpp": [True, False], + "websockets": [True, False], + "threading": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "ssl": True, + "clients": False, + "broker": False, + "apps": False, + "cjson": True, # https://github.com/eclipse/mosquitto/commit/bbe0afbfbe7bb392361de41e275759ee4ef06b1c + "build_cpp": True, + "websockets": False, + "threading": True, } exports_sources = ["CMakeLists.txt"] generators = "cmake", "cmake_find_package" @@ -60,16 +69,15 @@ def configure(self): def requirements(self): if self.options.ssl: - self.requires("openssl/1.1.1i") + self.requires("openssl/1.1.1q") if self.options.get_safe("cjson"): self.requires("cjson/1.7.14") if self.options.get_safe("websockets"): - self.requires("libwebsockets/4.1.6") + self.requires("libwebsockets/4.2.0") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name.replace("-", ".") + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_cmake(self): if self._cmake: @@ -79,7 +87,7 @@ def _configure_cmake(self): self._cmake.definitions["WITH_PIC"] = self.options.get_safe("fPIC", False) self._cmake.definitions["WITH_TLS"] = self.options.ssl self._cmake.definitions["WITH_CLIENTS"] = self.options.clients - if tools.Version(self.version) < "2.0.6": + if Version(self.version) < "2.0.6": self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_cJSON"] = not self.options.get_safe("cjson") else: self._cmake.definitions["WITH_CJSON"] = self.options.get_safe("cjson") @@ -87,7 +95,7 @@ def _configure_cmake(self): self._cmake.definitions["WITH_APPS"] = self.options.apps self._cmake.definitions["WITH_PLUGINS"] = False self._cmake.definitions["WITH_LIB_CPP"] = self.options.build_cpp - self._cmake.definitions["WITH_THREADING"] = self.settings.compiler != "Visual Studio" + self._cmake.definitions["WITH_THREADING"] = self.settings.compiler != "Visual Studio" and self.options.threading self._cmake.definitions["WITH_WEBSOCKETS"] = self.options.get_safe("websockets", False) self._cmake.definitions["STATIC_WEBSOCKETS"] = self.options.get_safe("websockets", False) and not self.options["libwebsockets"].shared self._cmake.definitions["DOCUMENTATION"] = False @@ -96,22 +104,22 @@ def _configure_cmake(self): return self._cmake def _patch_sources(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "client", "CMakeLists.txt"), "static)", "static ${CONAN_LIBS})") - tools.replace_in_file(os.path.join(self._source_subfolder, "client", "CMakeLists.txt"), "quitto)", "quitto ${CONAN_LIBS})") - tools.replace_in_file(os.path.join(self._source_subfolder, "apps", "mosquitto_ctrl", "CMakeLists.txt"), "static)", "static ${CONAN_LIBS})") - tools.replace_in_file(os.path.join(self._source_subfolder, "apps", "mosquitto_ctrl", "CMakeLists.txt"), "quitto)", "quitto ${CONAN_LIBS})") - tools.replace_in_file(os.path.join(self._source_subfolder, "apps", "mosquitto_passwd", "CMakeLists.txt"), "OPENSSL_LIBRARIES", "CONAN_LIBS") - tools.replace_in_file(os.path.join(self._source_subfolder, "apps", "mosquitto_ctrl", "CMakeLists.txt"), "OPENSSL_LIBRARIES", "CONAN_LIBS") - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), "OPENSSL_LIBRARIES", "CONAN_LIBS") - tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "CMakeLists.txt"), "OPENSSL_LIBRARIES", "CONAN_LIBS") - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), "MOSQ_LIBS", "CONAN_LIBS") - tools.replace_in_file(os.path.join(self._source_subfolder, "include", "mosquitto.h"), "__declspec(dllimport)", "") - tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "cpp", "mosquittopp.h"), "__declspec(dllimport)", "") + replace_in_file(self, os.path.join(self._source_subfolder, "client", "CMakeLists.txt"), "static)", "static ${CONAN_LIBS})") + replace_in_file(self, os.path.join(self._source_subfolder, "client", "CMakeLists.txt"), "quitto)", "quitto ${CONAN_LIBS})") + replace_in_file(self, os.path.join(self._source_subfolder, "apps", "mosquitto_ctrl", "CMakeLists.txt"), "static)", "static ${CONAN_LIBS})") + replace_in_file(self, os.path.join(self._source_subfolder, "apps", "mosquitto_ctrl", "CMakeLists.txt"), "quitto)", "quitto ${CONAN_LIBS})") + replace_in_file(self, os.path.join(self._source_subfolder, "apps", "mosquitto_passwd", "CMakeLists.txt"), "OPENSSL_LIBRARIES", "CONAN_LIBS") + replace_in_file(self, os.path.join(self._source_subfolder, "apps", "mosquitto_ctrl", "CMakeLists.txt"), "OPENSSL_LIBRARIES", "CONAN_LIBS") + replace_in_file(self, os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), "OPENSSL_LIBRARIES", "CONAN_LIBS") + replace_in_file(self, os.path.join(self._source_subfolder, "lib", "CMakeLists.txt"), "OPENSSL_LIBRARIES", "CONAN_LIBS") + replace_in_file(self, os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), "MOSQ_LIBS", "CONAN_LIBS") + replace_in_file(self, os.path.join(self._source_subfolder, "include", "mosquitto.h"), "__declspec(dllimport)", "") + replace_in_file(self, os.path.join(self._source_subfolder, "lib", "cpp", "mosquittopp.h"), "__declspec(dllimport)", "") # dynlibs for apple mobile want code signatures and that will not work here # this would actually be the right patch for static builds also, but this would have other side effects, so if(self.settings.os in ["iOS", "watchOS", "tvOS"]): - tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "CMakeLists.txt"), "SHARED", "") - tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "cpp", "CMakeLists.txt"), "SHARED", "") + replace_in_file(self, os.path.join(self._source_subfolder, "lib", "CMakeLists.txt"), "SHARED", "") + replace_in_file(self, os.path.join(self._source_subfolder, "lib", "cpp", "CMakeLists.txt"), "SHARED", "") def build(self): self._patch_sources() @@ -124,12 +132,12 @@ def package(self): self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "res"), "*.example") + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.example", os.path.join(self.package_folder, "res")) if not self.options.shared: - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.so*") - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.dylib") - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.dll") + rm(self, "*.so*", os.path.join(self.package_folder, "lib")) + rm(self, "*.dylib", os.path.join(self.package_folder, "lib")) + rm(self, "*.dll", os.path.join(self.package_folder, "bin")) elif self.options.shared and self.settings.compiler == "Visual Studio": self.copy("mosquitto.lib", src=os.path.join(self._build_subfolder, "lib"), dst="lib") if self.options.build_cpp: @@ -155,26 +163,26 @@ def package_info(self): elif self.settings.os == "Windows": self.cpp_info.components["libmosquittopp"].system_libs = ["ws2_32"] - if self.options.broker: - self.cpp_info.components["broker"].libdirs = [] - self.cpp_info.components["broker"].include_dirs = [] + if self.options.broker or self.options.get_safe("apps") or self.options.get_safe("clients"): bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH env var with : {}".format(bin_path)) self.env_info.PATH.append(bin_path) + + if self.options.broker: + self.cpp_info.components["mosquitto_broker"].libdirs = [] + self.cpp_info.components["mosquitto_broker"].include_dirs = [] if self.options.websockets: - self.cpp_info.components["broker"].requires.append("libwebsockets::libwebsockets") + self.cpp_info.components["mosquitto_broker"].requires.append("libwebsockets::libwebsockets") if self.settings.os in ("FreeBSD", "Linux"): - self.cpp_info.components["broker"].system_libs = ["pthread", "m"] + self.cpp_info.components["mosquitto_broker"].system_libs = ["pthread", "m"] elif self.settings.os == "Windows": - self.cpp_info.components["broker"].system_libs = ["ws2_32"] + self.cpp_info.components["mosquitto_broker"].system_libs = ["ws2_32"] for option in ["apps", "clients"]: if self.options.get_safe(option): - self.cpp_info.components[option].libdirs = [] - self.cpp_info.components[option].include_dirs = [] - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH env var with : {}".format(bin_path)) - self.env_info.PATH.append(bin_path) - self.cpp_info.components[option].requires = ["openssl::openssl", "libmosquitto"] + option_comp_name = "mosquitto_{}".format(option) + self.cpp_info.components[option_comp_name].libdirs = [] + self.cpp_info.components[option_comp_name].include_dirs = [] + self.cpp_info.components[option_comp_name].requires = ["openssl::openssl", "libmosquitto"] if self.options.cjson: - self.cpp_info.components[option].requires.append("cjson::cjson") + self.cpp_info.components[option_comp_name].requires.append("cjson::cjson") diff --git a/recipes/mosquitto/2.x/test_package/conanfile.py b/recipes/mosquitto/2.x/test_package/conanfile.py index 6c9d5dba712c7..9963f7a997273 100644 --- a/recipes/mosquitto/2.x/test_package/conanfile.py +++ b/recipes/mosquitto/2.x/test_package/conanfile.py @@ -1,4 +1,6 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import cross_building +from conans import CMake import os class TestPackageConan(ConanFile): @@ -11,6 +13,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/mosquitto/config.yml b/recipes/mosquitto/config.yml index 334573e047365..7627743e2625f 100644 --- a/recipes/mosquitto/config.yml +++ b/recipes/mosquitto/config.yml @@ -1,4 +1,12 @@ versions: + "2.0.15": + folder: "2.x" + "2.0.14": + folder: "2.x" + "2.0.12": + folder: "2.x" + "2.0.11": + folder: "2.x" "2.0.10": folder: "2.x" "2.0.7": diff --git a/recipes/mozilla-build/all/conandata.yml b/recipes/mozilla-build/all/conandata.yml index 9dd7b2887732b..5311816d69140 100644 --- a/recipes/mozilla-build/all/conandata.yml +++ b/recipes/mozilla-build/all/conandata.yml @@ -1,4 +1,6 @@ sources: "3.3": - sha256: ac86e5794c6a99c25dee0b60720c7cfd9833ec64785c74838723179830749c9c - url: https://ftp.mozilla.org/pub/mozilla/libraries/win32/MozillaBuildSetup-3.3.exe + - url: "https://ftp.mozilla.org/pub/mozilla/libraries/win32/MozillaBuildSetup-3.3.exe" + sha256: "ac86e5794c6a99c25dee0b60720c7cfd9833ec64785c74838723179830749c9c" + - url: "https://www.mozilla.org/media/MPL/2.0/index.815ca599c9df.txt" + sha256: "fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85" diff --git a/recipes/mozilla-build/all/conanfile.py b/recipes/mozilla-build/all/conanfile.py index 17a86dec17ab5..c13282cd3e215 100644 --- a/recipes/mozilla-build/all/conanfile.py +++ b/recipes/mozilla-build/all/conanfile.py @@ -1,37 +1,43 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.files import download +from conan.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.52.0" class MozillaBuildConan(ConanFile): name = "mozilla-build" homepage = "https://wiki.mozilla.org/MozillaBuild" description = "Mozilla build requirements on Windows" - topics = ("conan", "mozilla", "build") + topics = ("mozilla", "build") url = "https://github.com/conan-io/conan-center-index" - settings = "os_build", "arch_build" + settings = "arch", "build_type", "compiler", "os" license = "MPL-2.0" - def configure(self): - if self.settings.os_build != "Windows": + def validate(self): + if self.settings.os != "Windows": raise ConanInvalidConfiguration("Only Windows supported") def build_requirements(self): self.build_requires("7zip/19.00") def build(self): - url = self.conan_data["sources"][self.version]["url"] - tools.download(url, "mozilla-build.exe") - tools.check_sha256("mozilla-build.exe", self.conan_data["sources"][self.version]["sha256"]) - self.run("7z x mozilla-build.exe") - os.unlink("mozilla-build.exe") - tools.download("https://www.mozilla.org/media/MPL/2.0/index.815ca599c9df.txt", "LICENSE") + filename = "mozilla-build.exe" + download(self, **self.conan_data["sources"][self.version][0], filename=filename) + download(self, **self.conan_data["sources"][self.version][1], filename="LICENSE") + self.run(f"7z x {filename}", run_environment=True) + def package(self): self.copy("LICENSE", dst="licenses") self.copy("nsinstall.exe", src="bin", dst="bin") + def package_id(self): + del self.info.settings.build_type + del self.info.settings.compiler + def package_info(self): + self.cpp_info.includedirs = [] binpath = os.path.join(self.package_folder, "bin") - self.output.info("Adding to PATH: {}".format(binpath)) + self.output.info(f"Adding to PATH: {binpath}") self.env_info.PATH.append(binpath) diff --git a/recipes/mozjpeg/all/CMakeLists.txt b/recipes/mozjpeg/all/CMakeLists.txt deleted file mode 100644 index 6d4e2abf9a485..0000000000000 --- a/recipes/mozjpeg/all/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -include(GNUInstallDirs) - -add_subdirectory(source_subfolder) diff --git a/recipes/mozjpeg/all/conandata.yml b/recipes/mozjpeg/all/conandata.yml index 49a83576b27b3..b3cb941ad21eb 100644 --- a/recipes/mozjpeg/all/conandata.yml +++ b/recipes/mozjpeg/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "4.1.1": + url: "https://github.com/mozilla/mozjpeg/archive/v4.1.1.tar.gz" + sha256: "66b1b8d6b55d263f35f27f55acaaa3234df2a401232de99b6d099e2bb0a9d196" "4.0.0": url: "https://github.com/mozilla/mozjpeg/archive/v4.0.0.tar.gz" sha256: "961e14e73d06a015e9b23b8af416f010187cc0bec95f6e3b0fcb28cc7e2cbdd4" @@ -6,9 +9,15 @@ sources: url: "https://github.com/mozilla/mozjpeg/archive/v3.3.1.tar.gz" sha256: "aebbea60ea038a84a2d1ed3de38fdbca34027e2e54ee2b7d08a97578be72599d" patches: + "4.1.1": + - patch_file: "patches/4.1.1-0001-cmake-fixes.patch" + patch_description: "fix install folder and disable /NODEFAULT in MSVC" + patch_type: "conan" "4.0.0": - - base_path: "source_subfolder" - patch_file: "patches/4.0.0-0001-cmake-fixes.patch" + - patch_file: "patches/4.0.0-0001-cmake-fixes.patch" + patch_description: "fix install folder" + patch_type: "conan" "3.3.1": - - base_path: "source_subfolder" - patch_file: "patches/3.3.1-0001-cmake-fixes.patch" + - patch_file: "patches/3.3.1-0001-cmake-fixes.patch" + patch_description: "fix install folder" + patch_type: "conan" diff --git a/recipes/mozjpeg/all/conanfile.py b/recipes/mozjpeg/all/conanfile.py index db6e6ae8d60d2..691c801f8bb8c 100644 --- a/recipes/mozjpeg/all/conanfile.py +++ b/recipes/mozjpeg/all/conanfile.py @@ -1,20 +1,24 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, CMake, tools -import os -import glob - +from conan import ConanFile +from conan.tools.microsoft import is_msvc_static_runtime, is_msvc +from conan.tools.files import apply_conandata_patches, get, copy, rm, rmdir, export_conandata_patches +from conan.tools.build import cross_building +from conan.tools.scm import Version +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps +from conan.tools.env import VirtualBuildEnv +from conan.tools.layout import basic_layout -required_conan_version = ">=1.29.1" +import os +required_conan_version = ">=1.52.0" class MozjpegConan(ConanFile): name = "mozjpeg" description = "MozJPEG is an improved JPEG encoder" - url = "https://github.com/conan-io/conan-center-index" - topics = ("conan", "image", "format", "mozjpeg", "jpg", "jpeg", "picture", "multimedia", "graphics") license = ("BSD", "BSD-3-Clause", "ZLIB") + url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/mozilla/mozjpeg" - exports_sources = ("CMakeLists.txt", "patches/*") - generators = "cmake" + topics = ("conan", "image", "format", "mozjpeg", "jpg", "jpeg", "picture", "multimedia", "graphics") settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -43,120 +47,148 @@ class MozjpegConan(ConanFile): "enable12bit": False, } - _autotools = None - _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" + def _has_simd_support(self): + return self.settings.arch in ["x86", "x86_64"] - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if not self._has_simd_support: + del self.options.SIMD def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass self.provides = ["libjpeg", "libjpeg-turbo"] if self.options.turbojpeg else "libjpeg" @property def _use_cmake(self): - return self.settings.os == "Windows" or tools.Version(self.version) >= "4.0.0" + return self.settings.os == "Windows" or Version(self.version) >= "4.0.0" + + def layout(self): + if self._use_cmake: + cmake_layout(self, src_folder="src") + else: + basic_layout(self, src_folder='src') def build_requirements(self): - if not self._use_cmake: - if self.settings.os != "Windows": - self.build_requires("libtool/2.4.6") - self.build_requires("pkgconf/1.7.3") - if self.options.SIMD: - self.build_requires("nasm/2.14") + if not self._use_cmake and self.settings.os != "Windows": + self.tool_requires("libtool/2.4.7") + self.tool_requires("pkgconf/1.7.4") + if self.options.get_safe("SIMD"): + self.tool_requires("nasm/2.15.05") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_TESTING"] = False - self._cmake.definitions["ENABLE_STATIC"] = not self.options.shared - self._cmake.definitions["ENABLE_SHARED"] = self.options.shared - self._cmake.definitions["WITH_SIMD"] = self.options.SIMD - self._cmake.definitions["WITH_ARITH_ENC"] = self.options.arithmetic_encoder - self._cmake.definitions["WITH_ARITH_DEC"] = self.options.arithmetic_decoder - self._cmake.definitions["WITH_JPEG7"] = self.options.libjpeg7_compatibility - self._cmake.definitions["WITH_JPEG8"] = self.options.libjpeg8_compatibility - self._cmake.definitions["WITH_MEM_SRCDST"] = self.options.mem_src_dst - self._cmake.definitions["WITH_TURBOJPEG"] = self.options.turbojpeg - self._cmake.definitions["WITH_JAVA"] = self.options.java - self._cmake.definitions["WITH_12BIT"] = self.options.enable12bit - self._cmake.definitions["CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT"] = False - self._cmake.definitions["PNG_SUPPORTED"] = False # PNG and zlib are only required for executables (and static libraries) - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["WITH_CRT_DLL"] = "MD" in str(self.settings.compiler.runtime) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def _configure_autotools(self): - if not self._autotools: - with tools.chdir(self._source_subfolder): - self.run("autoreconf -fiv") - self._autotools = AutoToolsBuildEnvironment(self) - yes_no = lambda v: "yes" if v else "no" - args = [ - "--with-pic={}".format(yes_no(self.options.get_safe("fPIC", True))), - "--with-simd={}".format(yes_no(self.options.SIMD)), - "--with-arith-enc={}".format(yes_no(self.options.arithmetic_encoder)), - "--with-arith-dec={}".format(yes_no(self.options.arithmetic_decoder)), - "--with-jpeg7={}".format(yes_no(self.options.libjpeg7_compatibility)), - "--with-jpeg8={}".format(yes_no(self.options.libjpeg8_compatibility)), - "--with-mem-srcdst={}".format(yes_no(self.options.mem_src_dst)), - "--with-turbojpeg={}".format(yes_no(self.options.turbojpeg)), - "--with-java={}".format(yes_no(self.options.java)), - "--with-12bit={}".format(yes_no(self.options.enable12bit)), - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), - ] - self._autotools.configure(configure_dir=self._source_subfolder, args=args) - return self._autotools + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate_cmake(self): + tc = CMakeToolchain(self) + if cross_building(self): + # FIXME: too specific and error prone, should be delegated to CMake helper + cmake_system_processor = { + "armv8": "aarch64", + "armv8.3": "aarch64", + }.get(str(self.settings.arch), str(self.settings.arch)) + tc.variables["CMAKE_SYSTEM_PROCESSOR"] = cmake_system_processor + tc.variables["ENABLE_SHARED"] = self.options.shared + tc.variables["ENABLE_STATIC"] = not self.options.shared + tc.variables["ENABLE_TESTING"] = False + tc.variables["REQUIRE_SIMD"] = bool(self.options.get_safe("SIMD", False)) + tc.variables["WITH_SIMD"] = bool(self.options.get_safe("SIMD", False)) + tc.variables["WITH_ARITH_ENC"] = bool(self.options.arithmetic_encoder) + tc.variables["WITH_ARITH_DEC"] = bool(self.options.arithmetic_decoder) + tc.variables["WITH_JPEG7"] = bool(self.options.libjpeg7_compatibility) + tc.variables["WITH_JPEG8"] = bool(self.options.libjpeg8_compatibility) + tc.variables["WITH_MEM_SRCDST"] = bool(self.options.mem_src_dst) + tc.variables["WITH_TURBOJPEG"] = bool(self.options.turbojpeg) + tc.variables["WITH_JAVA"] = bool(self.options.java) + tc.variables["WITH_12BIT"] = bool(self.options.enable12bit) + tc.variables["CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT"] = False + tc.variables["PNG_SUPPORTED"] = False # PNG and zlib are only required for executables (and static libraries) + if is_msvc(self): + tc.variables["WITH_CRT_DLL"] = not is_msvc_static_runtime(self) + tc.generate() + + tc = CMakeDeps(self) + tc.generate() + + def generate_autotools(self): + toolchain = AutotoolsToolchain(self) + yes_no = lambda v: "yes" if v else "no" + toolchain.configure_args.append("--with-pic={}".format(yes_no(self.options.get_safe("fPIC", True)))) + toolchain.configure_args.append("--with-simd={}".format(yes_no(self.options.get_safe("SIMD", False)))) + toolchain.configure_args.append("--with-arith-enc={}".format(yes_no(self.options.arithmetic_encoder))) + toolchain.configure_args.append("--with-arith-dec={}".format(yes_no(self.options.arithmetic_decoder))) + toolchain.configure_args.append("--with-jpeg7={}".format(yes_no(self.options.libjpeg7_compatibility))) + toolchain.configure_args.append("--with-jpeg8={}".format(yes_no(self.options.libjpeg8_compatibility))) + toolchain.configure_args.append("--with-mem-srcdst={}".format(yes_no(self.options.mem_src_dst))) + toolchain.configure_args.append("--with-turbojpeg={}".format(yes_no(self.options.turbojpeg))) + toolchain.configure_args.append("--with-java={}".format(yes_no(self.options.java))) + toolchain.configure_args.append("--with-12bit={}".format(yes_no(self.options.enable12bit))) + toolchain.generate() + + deps = AutotoolsDeps(self) + deps.generate() + + def generate(self): + if self._use_cmake: + self.generate_cmake() + else: + self.generate_autotools() + + tc = VirtualBuildEnv(self) + tc.generate(scope="build") def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) if self._use_cmake: - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() else: - autotools = self._configure_autotools() + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() autotools.make() def package(self): - self.copy(pattern="LICENSE.md", dst="licenses", src=self._source_subfolder) + copy(self, pattern="LICENSE.md", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) if self._use_cmake: - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "doc")) + rmdir(self, os.path.join(self.package_folder, "doc")) else: - autotools = self._configure_autotools() + autotools = Autotools(self) autotools.install() - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + rm(self, pattern="*.la", folder=os.path.join(self.package_folder, "lib")) - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + copy(self, pattern="*.a", dst=os.path.join(self.package_folder, "lib"), src=os.path.join(self.package_folder, "lib64")) + rmdir(self, os.path.join(self.package_folder, "lib64")) # remove binaries and pdb files for bin_pattern_to_remove in ["cjpeg*", "djpeg*", "jpegtran*", "tjbench*", "wrjpgcom*", "rdjpgcom*", "*.pdb"]: - for bin_file in glob.glob(os.path.join(self.package_folder, "bin", bin_pattern_to_remove)): - os.remove(bin_file) + rm(self, pattern=bin_pattern_to_remove, folder=os.path.join(self.package_folder, "bin")) def _lib_name(self, name): - if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio" and not self.options.shared: + if is_msvc(self) and not self.options.shared: return name + "-static" return name @@ -164,11 +196,11 @@ def package_info(self): # libjpeg self.cpp_info.components["libjpeg"].names["pkg_config"] = "libjpeg" self.cpp_info.components["libjpeg"].libs = [self._lib_name("jpeg")] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libjpeg"].system_libs.append("m") # libturbojpeg if self.options.turbojpeg: self.cpp_info.components["libturbojpeg"].names["pkg_config"] = "libturbojpeg" self.cpp_info.components["libturbojpeg"].libs = [self._lib_name("turbojpeg")] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libturbojpeg"].system_libs.append("m") diff --git a/recipes/mozjpeg/all/patches/3.3.1-0001-cmake-fixes.patch b/recipes/mozjpeg/all/patches/3.3.1-0001-cmake-fixes.patch index b126195864e79..de72859433e6a 100644 --- a/recipes/mozjpeg/all/patches/3.3.1-0001-cmake-fixes.patch +++ b/recipes/mozjpeg/all/patches/3.3.1-0001-cmake-fixes.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 743a243..b5d41a1 100644 +index 743a243..eb787c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,7 +168,7 @@ message(STATUS "Install directory = ${CMAKE_INSTALL_PREFIX}") @@ -34,7 +34,7 @@ index 743a243..b5d41a1 100644 install(TARGETS turbojpeg-static ARCHIVE DESTINATION lib) if(NOT ENABLE_SHARED) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/tjbench-static.exe -+ install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tjbench-static.exe ++ install(PROGRAMS $ DESTINATION bin RENAME tjbench.exe) endif() endif() @@ -46,13 +46,13 @@ index 743a243..b5d41a1 100644 install(TARGETS jpeg-static ARCHIVE DESTINATION lib) if(NOT ENABLE_SHARED) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cjpeg-static.exe -+ install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cjpeg-static.exe ++ install(PROGRAMS $ DESTINATION bin RENAME cjpeg.exe) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/djpeg-static.exe -+ install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/djpeg-static.exe ++ install(PROGRAMS $ DESTINATION bin RENAME djpeg.exe) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jpegtran-static.exe -+ install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/jpegtran-static.exe ++ install(PROGRAMS $ DESTINATION bin RENAME jpegtran.exe) endif() endif() diff --git a/recipes/mozjpeg/all/patches/4.0.0-0001-cmake-fixes.patch b/recipes/mozjpeg/all/patches/4.0.0-0001-cmake-fixes.patch index dcd183f0d0a7a..f6fad20598e0b 100644 --- a/recipes/mozjpeg/all/patches/4.0.0-0001-cmake-fixes.patch +++ b/recipes/mozjpeg/all/patches/4.0.0-0001-cmake-fixes.patch @@ -1,6 +1,6 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -1433,7 +1433,7 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1433,7 +1433,7 @@ if(WITH_TURBOJPEG) else() set(DIR ${CMAKE_CURRENT_BINARY_DIR}) endif() @@ -9,7 +9,7 @@ DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE}) endif() endif() -@@ -1449,11 +1449,11 @@ +@@ -1449,16 +1449,16 @@ if(ENABLE_STATIC) else() set(DIR ${CMAKE_CURRENT_BINARY_DIR}) endif() @@ -24,3 +24,9 @@ DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE}) endif() endif() + +-install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++install(TARGETS rdjpgcom wrjpgcom DESTINATION ${CMAKE_INSTALL_BINDIR}) + + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg + ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt diff --git a/recipes/mozjpeg/all/patches/4.1.1-0001-cmake-fixes.patch b/recipes/mozjpeg/all/patches/4.1.1-0001-cmake-fixes.patch new file mode 100644 index 0000000000000..0d6ad37fc19fd --- /dev/null +++ b/recipes/mozjpeg/all/patches/4.1.1-0001-cmake-fixes.patch @@ -0,0 +1,34 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8d295c6..b30dacb 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1461,7 +1461,7 @@ if(WITH_TURBOJPEG) + else() + set(DIR ${CMAKE_CURRENT_BINARY_DIR}) + endif() +- install(PROGRAMS ${DIR}/tjbench-static${EXE} ++ install(PROGRAMS $ + DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE}) + endif() + endif() +@@ -1479,16 +1479,16 @@ if(ENABLE_STATIC) + else() + set(DIR ${CMAKE_CURRENT_BINARY_DIR}) + endif() +- install(PROGRAMS ${DIR}/cjpeg-static${EXE} ++ install(PROGRAMS $ + DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME cjpeg${EXE}) +- install(PROGRAMS ${DIR}/djpeg-static${EXE} ++ install(PROGRAMS $ + DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE}) +- install(PROGRAMS ${DIR}/jpegtran-static${EXE} ++ install(PROGRAMS $ + DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE}) + endif() + endif() + +-install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++install(TARGETS rdjpgcom wrjpgcom DESTINATION ${CMAKE_INSTALL_BINDIR}) + + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg + ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt diff --git a/recipes/mozjpeg/all/test_package/CMakeLists.txt b/recipes/mozjpeg/all/test_package/CMakeLists.txt index 7b9b613cbb24a..9d43e05ca2a27 100644 --- a/recipes/mozjpeg/all/test_package/CMakeLists.txt +++ b/recipes/mozjpeg/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) + project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(mozjpeg REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE mozjpeg::libjpeg) diff --git a/recipes/mozjpeg/all/test_package/conanfile.py b/recipes/mozjpeg/all/test_package/conanfile.py index 3ae27388e5a6d..eb44b6270b92d 100644 --- a/recipes/mozjpeg/all/test_package/conanfile.py +++ b/recipes/mozjpeg/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os - class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") img_name = os.path.join(self.source_folder, "testimg.jpg") - self.run("%s %s" % (bin_path, img_name), run_environment=True) + self.run(f"{bin_path} {img_name}", env="conanrun") diff --git a/recipes/mozjpeg/all/test_v1_package/CMakeLists.txt b/recipes/mozjpeg/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f4df079837a44 --- /dev/null +++ b/recipes/mozjpeg/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(mozjpeg REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE mozjpeg::libjpeg) diff --git a/recipes/mozjpeg/all/test_v1_package/conanfile.py b/recipes/mozjpeg/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..cf6e3a0371de5 --- /dev/null +++ b/recipes/mozjpeg/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + img_name = os.path.join(self.source_folder, os.pardir, "test_package", "testimg.jpg") + self.run(f"{bin_path} {img_name}", run_environment=True) diff --git a/recipes/mozjpeg/config.yml b/recipes/mozjpeg/config.yml index 7bdb507696897..c5a4dbb215dd3 100644 --- a/recipes/mozjpeg/config.yml +++ b/recipes/mozjpeg/config.yml @@ -1,5 +1,7 @@ versions: - "3.3.1": + "4.1.1": folder: all "4.0.0": folder: all + "3.3.1": + folder: all diff --git a/recipes/mpark-variant/all/conanfile.py b/recipes/mpark-variant/all/conanfile.py index 07b300cbf739a..e015db951bf2d 100644 --- a/recipes/mpark-variant/all/conanfile.py +++ b/recipes/mpark-variant/all/conanfile.py @@ -1,37 +1,73 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get, save +from conan.tools.layout import basic_layout import os +import textwrap +required_conan_version = ">=1.50.0" -class VariantConan(ConanFile): + +class MparkVariantConan(ConanFile): name = "mpark-variant" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/mpark/variant" description = "C++17 std::variant for C++11/14/17" license = "BSL-1.0" - topics = ("conan", "variant", "mpark-variant") - settings = "compiler" - - @property - def _source_subfolder(self): - return "source_subfolder" + topics = ("variant", "mpark-variant") + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, "11") + def layout(self): + basic_layout(self, src_folder="src") def package_id(self): - self.info.header_only() + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, "11") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "variant-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy(pattern="LICENSE.md", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"mpark_variant": "mpark_variant::mpark_variant"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): - # TODO: CMake imported target shouldn't be namespaced (waiting https://github.com/conan-io/conan/issues/7615 to be implemented) + self.cpp_info.set_property("cmake_file_name", "mpark_variant") + self.cpp_info.set_property("cmake_target_name", "mpark_variant") + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.names["cmake_find_package"] = "mpark_variant" self.cpp_info.names["cmake_find_package_multi"] = "mpark_variant" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/mpark-variant/all/test_package/CMakeLists.txt b/recipes/mpark-variant/all/test_package/CMakeLists.txt index 87dd4a28521ac..1d878b6a4c4f5 100644 --- a/recipes/mpark-variant/all/test_package/CMakeLists.txt +++ b/recipes/mpark-variant/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(mpark_variant REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} mpark_variant::mpark_variant) # TODO: Remove mpark_variant:: namespace when fixed in conanfile -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE mpark_variant) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/mpark-variant/all/test_package/conanfile.py b/recipes/mpark-variant/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/mpark-variant/all/test_package/conanfile.py +++ b/recipes/mpark-variant/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mpark-variant/all/test_v1_package/CMakeLists.txt b/recipes/mpark-variant/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/mpark-variant/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/mpark-variant/all/test_v1_package/conanfile.py b/recipes/mpark-variant/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mpark-variant/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 02124a3798aa9..0d3ae8cad33a5 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -2,6 +2,7 @@ from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.33.0" class MpcConan(ConanFile): name = "mpc" @@ -15,35 +16,45 @@ class MpcConan(ConanFile): options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True} exports_sources = "patches/**" + _autotools = None @property def _source_subfolder(self): return "source_subfolder" - _autotools = None - def config_options(self): if self.settings.os == 'Windows': del self.options.fPIC + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + def requirements(self): self.requires("mpfr/4.1.0") - def configure(self): + def validate(self): + # FIXME: add Visual Studio support, upstream has a makefile.vc if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("The mpc package cannot be built on Visual Studio.") - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + raise ConanInvalidConfiguration("mpc can be built with Visual Studio, but it's not supported yet in this recipe.") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def _configure_autotools(self): if self._autotools: return self._autotools - self._autotools = AutoToolsBuildEnvironment(self) + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) args = [] if self.options.shared: args.extend(["--disable-static", "--enable-shared"]) @@ -63,7 +74,7 @@ def package(self): autotools = self._configure_autotools() autotools.install() tools.rmdir(os.path.join(self.package_folder, "share")) - os.unlink(os.path.join(self.package_folder, "lib", "libmpc.la")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") def package_info(self): self.cpp_info.libs = ["mpc"] diff --git a/recipes/mpc/all/test_package/CMakeLists.txt b/recipes/mpc/all/test_package/CMakeLists.txt index 196188113685c..7b9b613cbb24a 100644 --- a/recipes/mpc/all/test_package/CMakeLists.txt +++ b/recipes/mpc/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -add_executable(${PROJECT_NAME} test_package.cpp) +add_executable(${PROJECT_NAME} test_package.c) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/mpc/all/test_package/test_package.c b/recipes/mpc/all/test_package/test_package.c new file mode 100644 index 0000000000000..c2c46b86453e1 --- /dev/null +++ b/recipes/mpc/all/test_package/test_package.c @@ -0,0 +1,16 @@ +/* example was taken from https://www.gnu.org/ghm/2011/paris/slides/andreas-enge-mpc.pdf */ + +#include +#include + +int main (void) { + mpc_t z; + int inex; + mpc_init2 (z, 123); + mpc_set_ui_ui (z, 0, 2, MPC_RNDNN); + inex = mpc_asin (z, z, MPC_RNDNN); + mpc_out_str (stdout, 10, 0, z, MPC_RNDNN); + printf ("\n%i %i\n", MPC_INEX_RE (inex), MPC_INEX_IM (inex)); + mpc_clear (z); + return 0; +} diff --git a/recipes/mpc/all/test_package/test_package.cpp b/recipes/mpc/all/test_package/test_package.cpp deleted file mode 100644 index 1d9915442f634..0000000000000 --- a/recipes/mpc/all/test_package/test_package.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* example was taken from https://www.gnu.org/ghm/2011/paris/slides/andreas-enge-mpc.pdf */ - -#include -#include - -int main (void) { - mpc_t z; - int inex; - mpc_init2 (z, 123); - mpc_set_ui_ui (z, 0, 2, MPC_RNDNN); - inex = mpc_asin (z, z, MPC_RNDNN); - mpc_out_str (stdout, 10, 0, z, MPC_RNDNN); - printf ("\n%i %i\n", MPC_INEX_RE (inex), MPC_INEX_IM (inex)); - mpc_clear (z); -} diff --git a/recipes/mpdecimal/2.4.2/conanfile.py b/recipes/mpdecimal/2.4.2/conanfile.py index b5cc04c7adcdc..e0edbd2d2f318 100644 --- a/recipes/mpdecimal/2.4.2/conanfile.py +++ b/recipes/mpdecimal/2.4.2/conanfile.py @@ -9,7 +9,7 @@ class MpdecimalConan(ConanFile): version = "2.4.2" description = "mpdecimal is a package for correctly-rounded arbitrary precision decimal floating point arithmetic." license = "BSD-2-Clause" - topics = ("conan", "mpdecimal", "multiprecision", "library") + topics = ("mpdecimal", "multiprecision", "library") url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.bytereef.org/mpdecimal" settings = "os", "compiler", "build_type", "arch" @@ -23,25 +23,31 @@ class MpdecimalConan(ConanFile): "fPIC": True, } + _autotools = None + @property def _source_subfolder(self): return "source_subfolder" - _autotools = None + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] def configure(self): - if self.settings.arch not in ("x86", "x86_64"): + if self._is_msvc and self.settings.arch not in ("x86", "x86_64"): raise ConanInvalidConfiguration("Arch is unsupported") del self.settings.compiler.libcxx del self.settings.compiler.cppstd + if self.options.shared: + del self.options.fPIC def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("mpdecimal-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) _shared_ext_mapping = { "Linux": ".so", @@ -52,7 +58,7 @@ def source(self): def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - if self.settings.compiler != "Visual Studio": + if not self._is_msvc: """ Using autotools: - Build only shared libraries when shared == True @@ -161,12 +167,14 @@ def _configure_autotools(self): if self._autotools: return self._autotools self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + if self.settings.os == "Macos" and self.settings.arch == "armv8": + self._autotools.link_flags.append("-arch arm64") self._autotools .configure() return self._autotools def build(self): self._patch_sources() - if self.settings.compiler == "Visual Studio": + if self._is_msvc: self._build_msvc() else: with tools.chdir(self._source_subfolder): @@ -175,7 +183,7 @@ def build(self): def package(self): self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses") - if self.settings.compiler == "Visual Studio": + if self._is_msvc: distfolder = os.path.join(self.build_folder, self._source_subfolder, "vcbuild", "dist{}".format(32 if self.settings.arch == "x86" else 64)) self.copy("vc*.h", src=os.path.join(self.build_folder, self._source_subfolder, "libmpdec"), dst="include") self.copy("*.h", src=distfolder, dst="include") @@ -188,13 +196,13 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "share")) def package_info(self): - if self.settings.compiler == "Visual Studio": + if self._is_msvc: self.cpp_info.libs = ["libmpdec-{}".format(self.version)] else: self.cpp_info.libs = ["mpdec"] if self.options.shared: - if self.settings.compiler == "Visual Studio": + if self._is_msvc: self.cpp_info.defines = ["USE_DLL"] else: - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] diff --git a/recipes/mpdecimal/2.5.x/conanfile.py b/recipes/mpdecimal/2.5.x/conanfile.py index a10c3c3b4bd11..a1cb1a8ead8ec 100644 --- a/recipes/mpdecimal/2.5.x/conanfile.py +++ b/recipes/mpdecimal/2.5.x/conanfile.py @@ -3,12 +3,14 @@ import os import shutil +required_conan_version = ">=1.33.0" + class MpdecimalConan(ConanFile): name = "mpdecimal" description = "mpdecimal is a package for correctly-rounded arbitrary precision decimal floating point arithmetic." license = "BSD-2-Clause" - topics = ("conan", "mpdecimal", "multiprecision", "library") + topics = ("mpdecimal", "multiprecision", "library") url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.bytereef.org/mpdecimal" settings = "os", "compiler", "build_type", "arch" @@ -22,13 +24,24 @@ class MpdecimalConan(ConanFile): "fPIC": True, "cxx": True, } - exports_sources = "patches/**" + + _autotools = None @property def _source_subfolder(self): return "source_subfolder" - _autotools = None + @property + def _settings_build(self): + return getattr(self, "setings_build", self.settings) + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == "Windows": @@ -37,24 +50,26 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.arch not in ("x86", "x86_64"): - raise ConanInvalidConfiguration("Arch is unsupported") - if self.options.cxx: - if self.options.shared and self.settings.os == "Windows": - raise ConanInvalidConfiguration("A shared libmpdec++ is not possible on Windows (due to non-exportable thread local storage)") - else: + if not self.options.cxx: del self.settings.compiler.libcxx del self.settings.compiler.cppstd def build_requirements(self): - if self.settings.compiler != "Visual Studio": - self.build_requires("automake/1.16.3") - if tools.os_info.is_windows: - self.build_requires("msys2/20200517") + if self._is_msvc: + self.build_requires("automake/1.16.4") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + + def validate(self): + if self._is_msvc and self.settings.arch not in ("x86", "x86_64"): + raise ConanInvalidConfiguration("Arch is unsupported") + if self.options.cxx: + if self.options.shared and self.settings.os == "Windows": + raise ConanInvalidConfiguration("A shared libmpdec++ is not possible on Windows (due to non-exportable thread local storage)") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("mpdecimal-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): @@ -84,12 +99,12 @@ def _build_msvc(self): builds = [[libmpdec_folder, mpdec_target, mpdec_extra_flags] ] if self.options.cxx: builds.append([libmpdecpp_folder, mpdecpp_target, mpdecxx_extra_flags]) - with tools.vcvars(self.settings): + with tools.vcvars(self): for build_dir, target, extra_flags in builds: with tools.chdir(build_dir): self.run("""nmake /nologo /f Makefile.vc {target} MACHINE={machine} DEBUG={debug} DLL={dll} CONAN_CFLAGS="{cflags}" CONAN_CXXFLAGS="{cxxflags}" CONAN_LDFLAGS="{ldflags}" """.format( target=target, - machine={"x86": "pro", "x86_64": "x64"}[str(self.settings.arch)], # FIXME: else, use ansi32 and ansi64 + machine={"x86": "ppro", "x86_64": "x64"}[str(self.settings.arch)], # FIXME: else, use ansi32 and ansi64 debug="1" if self.settings.build_type == "Debug" else "0", dll="1" if self.options.shared else "0", cflags=" ".join(autotools.flags + extra_flags), @@ -114,10 +129,14 @@ def _configure_autotools(self): if self._autotools: return self._autotools self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + conf_vars = self._autotools.vars + if self.settings.os == "Macos" and self.settings.arch == "armv8": + conf_vars["LDFLAGS"] += " -arch arm64" + conf_vars["LDXXFLAGS"] = "-arch arm64" conf_args = [ "--enable-cxx" if self.options.cxx else "--disable-cxx" ] - self._autotools.configure(args=conf_args) + self._autotools.configure(args=conf_args, vars=conf_vars) return self._autotools @property @@ -137,7 +156,7 @@ def _target_names(self): def build(self): self._patch_sources() - if self.settings.compiler == "Visual Studio": + if self._is_msvc: self._build_msvc() else: with tools.chdir(self._source_subfolder): @@ -153,7 +172,7 @@ def build(self): def package(self): self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses") - if self.settings.compiler == "Visual Studio": + if self._is_msvc: distfolder = os.path.join(self.build_folder, self._source_subfolder, "vcbuild", "dist{}".format(32 if self.settings.arch == "x86" else 64)) self.copy("vc*.h", src=os.path.join(self.build_folder, self._source_subfolder, "libmpdec"), dst="include") self.copy("*.h", src=distfolder, dst="include") @@ -179,7 +198,7 @@ def package(self): def package_info(self): lib_pre_suf = ("", "") - if self.settings.compiler == "Visual Studio": + if self._is_msvc: lib_pre_suf = ("lib", "-{}".format(self.version)) elif self.settings.os == "Windows": if self.options.shared: @@ -187,13 +206,13 @@ def package_info(self): self.cpp_info.components["libmpdecimal"].libs = ["{}mpdec{}".format(*lib_pre_suf)] if self.options.shared: - if self.settings.compiler == "Visual Studio": + if self._is_msvc: if tools.Version(self.version) >= "2.5.1": self.cpp_info.components["libmpdecimal"].defines = ["MPDECIMAL_DLL"] else: self.cpp_info.components["libmpdecimal"].defines = ["USE_DLL"] else: - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libmpdecimal"].system_libs = ["m"] if self.options.cxx: diff --git a/recipes/mpdecimal/2.5.x/test_package/CMakeLists.txt b/recipes/mpdecimal/2.5.x/test_package/CMakeLists.txt index 2310131723886..f452aa64e4430 100644 --- a/recipes/mpdecimal/2.5.x/test_package/CMakeLists.txt +++ b/recipes/mpdecimal/2.5.x/test_package/CMakeLists.txt @@ -4,6 +4,12 @@ project(test_package) include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup(TARGETS) +# Workaround for -rpath on arm64: https://cmake.org/cmake/help/latest/release/3.20.html#id2 +if(CMAKE_VERSION VERSION_LESS "3.20.1" AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64") + set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") +endif() + +# This is a non-official mpdecimal module! find_package(mpdecimal REQUIRED) add_executable(${PROJECT_NAME} test_package.c) diff --git a/recipes/mpdecimal/2.5.x/test_package/conanfile.py b/recipes/mpdecimal/2.5.x/test_package/conanfile.py index 5b6c748c46310..9cdba214e6fb9 100644 --- a/recipes/mpdecimal/2.5.x/test_package/conanfile.py +++ b/recipes/mpdecimal/2.5.x/test_package/conanfile.py @@ -13,8 +13,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): self.run("{} 13 100".format(os.path.join("bin", "test_package")), run_environment=True) if self.options["mpdecimal"].cxx: self.run("{} 13 100".format(os.path.join("bin", "test_package_cpp")), run_environment=True) - diff --git a/recipes/mpfr/all/conanfile.py b/recipes/mpfr/all/conanfile.py index 4d86f36bae078..ebf83bf0baf23 100644 --- a/recipes/mpfr/all/conanfile.py +++ b/recipes/mpfr/all/conanfile.py @@ -1,16 +1,18 @@ from conans import ConanFile, AutoToolsBuildEnvironment, CMake, tools from conans.errors import ConanException -from contextlib import contextmanager +import contextlib import os import re import shlex +required_conan_version = ">=1.33.0" + class MpfrConan(ConanFile): name = "mpfr" description = "The MPFR library is a C library for multiple-precision floating-point computations with " \ "correct rounding" - topics = ("conan", "mpfr", "multiprecision", "math", "mathematics") + topics = ("mpfr", "multiprecision", "math", "mathematics") url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.mpfr.org/" license = "LGPL-3.0-or-later" @@ -25,6 +27,7 @@ class MpfrConan(ConanFile): "fPIC": True, "exact_int": "gmp", } + exports_sources = "CMakeLists.txt.in", "patches/**" generators = "cmake" @@ -35,11 +38,17 @@ class MpfrConan(ConanFile): def _source_subfolder(self): return "source_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd @@ -50,13 +59,12 @@ def requirements(self): self.requires("mpir/3.0.0") def build_requirements(self): - if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PAH"): - self.build_requires("msys2/20200517") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def _configure_autotools(self): if self._autotools: @@ -107,12 +115,11 @@ def _extract_mpfr_autotools_variables(self): defs = self._extract_makefile_variable(makefile, "DEFS") return sources, headers, defs - @contextmanager + @contextlib.contextmanager def _build_context(self): - env = {} if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - env.update({ + with tools.vcvars(self): + env = { "AR": "lib", "CC": "cl -nologo", "CXX": "cl -nologo", @@ -121,7 +128,7 @@ def _build_context(self): "OBJDUMP": ":", "RANLIB": ":", "STRIP": ":", - }) + } with tools.environment_append(env): yield else: diff --git a/recipes/mpfr/all/test_package/conanfile.py b/recipes/mpfr/all/test_package/conanfile.py index bd7165a553cf4..d4128b0450777 100644 --- a/recipes/mpfr/all/test_package/conanfile.py +++ b/recipes/mpfr/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/mpg123/all/CMakeLists.txt b/recipes/mpg123/all/CMakeLists.txt index 26e1f5a3a0f18..8c39621ac3881 100644 --- a/recipes/mpg123/all/CMakeLists.txt +++ b/recipes/mpg123/all/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.4) project(cmake_wrapper) include(conanbuildinfo.cmake) diff --git a/recipes/mpg123/all/conandata.yml b/recipes/mpg123/all/conandata.yml index 9c06c61f804a7..b41c8b1f2db34 100644 --- a/recipes/mpg123/all/conandata.yml +++ b/recipes/mpg123/all/conandata.yml @@ -2,3 +2,15 @@ sources: "1.26.4": url: "https://sourceforge.net/projects/mpg123/files/mpg123/1.26.4/mpg123-1.26.4.tar.bz2" sha256: "081991540df7a666b29049ad870f293cfa28863b36488ab4d58ceaa7b5846454" + "1.29.3": + url: "https://sourceforge.net/projects/mpg123/files/mpg123/1.29.3/mpg123-1.29.3.tar.bz2" + sha256: "963885d8cc77262f28b77187c7d189e32195e64244de2530b798ddf32183e847" +patches: + "1.26.4": + - patch_file: "patches/0001-msvc-export-symbols.patch" + base_path: "source_subfolder" + "1.29.3": + - patch_file: "patches/0001-msvc-export-symbols.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-cmake-read_api_version-fix.patch" + base_path: "source_subfolder" diff --git a/recipes/mpg123/all/conanfile.py b/recipes/mpg123/all/conanfile.py index 0c01fbb3fb305..c5a4ec0ca9d4a 100644 --- a/recipes/mpg123/all/conanfile.py +++ b/recipes/mpg123/all/conanfile.py @@ -2,6 +2,8 @@ from conans.errors import ConanInvalidConfiguration import os +required_conan_version = ">=1.33.0" + class Mpg123Conan(ConanFile): name = "mpg123" @@ -60,29 +62,37 @@ def configure(self): del self.settings.compiler.cppstd if self.options.shared: del self.options.fPIC + + def requirements(self): + if self.options.module == "libalsa": + self.requires("libalsa/1.2.4") + if self.options.module == "tinyalsa": + self.requires("tinyalsa/1.1.1") + + def validate(self): try: int(self.options.seektable) except ValueError: raise ConanInvalidConfiguration("seektable must be an integer") if self.settings.os != "Windows": - if self.options == "win32": + if self.options.module == "win32": raise ConanInvalidConfiguration("win32 is an invalid module for non-Windows os'es") - def requirements(self): - if self.options.module == "libalsa": - self.requires("libalsa/1.2.4") - if self.options.module == "tinyalsa": - self.requires("tinyalsa/1.1.1") + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def build_requirements(self): - self.build_requires("pkgconf/1.7.3") - self.build_requires("yasm/1.3.0") - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio" and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/20200517") + self.build_requires("pkgconf/1.7.4") + if self.settings.arch in ["x86", "x86_64"]: + self.build_requires("yasm/1.3.0") + if self._settings_build.os == "Windows" and self.settings.compiler != "Visual Studio" and \ + not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("mpg123-{}".format(self.version), self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) @property def _audio_module(self): @@ -106,6 +116,7 @@ def _configure_autotools(self): "--enable-layer2={}".format(yes_no(self.options.layer2)), "--enable-layer3={}".format(yes_no(self.options.layer3)), "--with-audio={}".format(self._audio_module), + "--with-default-audio={}".format(self._audio_module), "--with-seektable={}".format(self.options.seektable), "--enable-modules=no", "--enable-shared={}".format(yes_no(self.options.shared)), @@ -150,12 +161,11 @@ def package(self): if self.settings.compiler == "Visual Studio": cmake = self._configure_cmake() cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) else: autotools = self._configure_autotools() autotools.install() - - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) tools.rmdir(os.path.join(self.package_folder, "share")) @@ -189,3 +199,7 @@ def package_info(self): self.cpp_info.components["libout123"].requires.append("tinyalsa::tinyalsa") if self.options.module == "win32": self.cpp_info.components["libout123"].system_libs.append("winmm") + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/mpg123/all/patches/0001-msvc-export-symbols.patch b/recipes/mpg123/all/patches/0001-msvc-export-symbols.patch new file mode 100644 index 0000000000000..75a32b2884251 --- /dev/null +++ b/recipes/mpg123/all/patches/0001-msvc-export-symbols.patch @@ -0,0 +1,22 @@ +--- a/ports/cmake/src/libout123/CMakeLists.txt ++++ b/ports/cmake/src/libout123/CMakeLists.txt +@@ -18,7 +18,7 @@ add_library(${TARGET} + $ + $<$:$>) + +-set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME out123) ++set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME out123 WINDOWS_EXPORT_ALL_SYMBOLS ON) + + target_link_libraries(${TARGET} PRIVATE + $ +--- a/ports/cmake/src/libsyn123/CMakeLists.txt ++++ b/ports/cmake/src/libsyn123/CMakeLists.txt +@@ -15,7 +15,7 @@ add_library(${TARGET} + "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/sampleconv.c" + $) + +-set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME syn123) ++set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME syn123 WINDOWS_EXPORT_ALL_SYMBOLS ON) + + target_include_directories(${TARGET} INTERFACE + "$" diff --git a/recipes/mpg123/all/patches/0002-cmake-read_api_version-fix.patch b/recipes/mpg123/all/patches/0002-cmake-read_api_version-fix.patch new file mode 100644 index 0000000000000..934fa5ad4579e --- /dev/null +++ b/recipes/mpg123/all/patches/0002-cmake-read_api_version-fix.patch @@ -0,0 +1,10 @@ +--- a/ports/cmake/cmake/read_api_version.cmake ++++ b/ports/cmake/cmake/read_api_version.cmake +@@ -1,6 +1,6 @@ + function(read_api_version project_version api_version outapi_version synapi_version ) + +- file( READ "${CMAKE_SOURCE_DIR}/../../configure.ac" configure_ac ) ++ file( READ "${CMAKE_CURRENT_SOURCE_DIR}/../../configure.ac" configure_ac ) + + string( REGEX MATCH "AC_INIT\\(\\[mpg123\\], \\[([0-9\\.]+)" result ${configure_ac} ) + set( ${project_version} ${CMAKE_MATCH_1} PARENT_SCOPE ) diff --git a/recipes/mpg123/all/test_package/CMakeLists.txt b/recipes/mpg123/all/test_package/CMakeLists.txt index 9928afc9ae82d..151a7eb5be518 100644 --- a/recipes/mpg123/all/test_package/CMakeLists.txt +++ b/recipes/mpg123/all/test_package/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) diff --git a/recipes/mpg123/config.yml b/recipes/mpg123/config.yml index 911273670c0ff..bf527ae59b5fa 100644 --- a/recipes/mpg123/config.yml +++ b/recipes/mpg123/config.yml @@ -1,3 +1,5 @@ versions: "1.26.4": folder: "all" + "1.29.3": + folder: "all" diff --git a/recipes/mpir/all/conanfile.py b/recipes/mpir/all/conanfile.py index afab3e688dfac..3c6c16a085f0b 100644 --- a/recipes/mpir/all/conanfile.py +++ b/recipes/mpir/all/conanfile.py @@ -1,27 +1,38 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment, MSBuild +from conan import ConanFile +from conan.tools.microsoft import msvc_runtime_flag, is_msvc +from conan.tools.build import cross_building +from conan.tools.files import get, copy, replace_in_file, chdir, rmdir, rm +from conan.tools.scm import Version +from conans import tools, AutoToolsBuildEnvironment, MSBuild +from conan.errors import ConanInvalidConfiguration +import contextlib import os -import glob + +required_conan_version = ">=1.50.0" class MpirConan(ConanFile): name = "mpir" description = "MPIR is a highly optimised library for bignum arithmetic" \ "forked from the GMP bignum library." - topics = ("conan", "mpir", "multiprecision", "math", "mathematics") + topics = ("mpir", "multiprecision", "math", "mathematics") url = "https://github.com/conan-io/conan-center-index" homepage = "http://mpir.org/" license = "LGPL-3.0-or-later" - settings = "os", "compiler", "arch", "build_type" + + provides = [] + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "enable_cxx": [True, False], - "enable_gmpcompat": [True, False] + "enable_gmpcompat": [True, False], } default_options = { "shared": False, "fPIC": True, "enable_cxx": True, - "enable_gmpcompat": True + "enable_gmpcompat": True, } _autotools = None @@ -30,6 +41,10 @@ class MpirConan(ConanFile): def _source_subfolder(self): return "source_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -37,24 +52,28 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler == "Visual Studio" and self.options.shared: + if is_msvc(self) and self.options.shared: del self.options.enable_cxx if not self.options.get_safe("enable_cxx", False): del self.settings.compiler.libcxx del self.settings.compiler.cppstd + if self.options.enable_gmpcompat: + self.provides.append("gmp") + + def validate(self): + if hasattr(self, "settings_build") and cross_building(self, skip_x64_x86=True): + raise ConanInvalidConfiguration("Cross-building doesn't work (yet)") def build_requirements(self): - if self.settings.compiler != "Visual Studio": - self.build_requires("m4/1.4.18") - self.build_requires("yasm/1.3.0") - if tools.os_info.is_windows and self.settings.compiler != "Visual Studio" and \ - "CONAN_BASH_PATH" not in os.environ and tools.os_info.detect_windows_subsystem() != "msys2": - self.build_requires("msys2/20200517") + self.tool_requires("yasm/1.3.0") + if not is_msvc(self): + self.tool_requires("m4/1.4.19") + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.tool_requires("msys2/cci.latest") def source(self): - tools.get(keep_permissions=True, **self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, keep_permissions=True, **self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) @property def _platforms(self): @@ -66,7 +85,7 @@ def _dll_or_lib(self): @property def _vcxproj_paths(self): - compiler_version = self.settings.compiler.version if tools.Version(self.settings.compiler.version) < "16" else "15" + compiler_version = self.settings.compiler.version if Version(self.settings.compiler.version) <= "17" else "17" build_subdir = "build.vc{}".format(compiler_version) vcxproj_paths = [ os.path.join(self._source_subfolder, build_subdir, @@ -79,19 +98,38 @@ def _vcxproj_paths(self): return vcxproj_paths def _build_visual_studio(self): - if "MD" in self.settings.compiler.runtime and not self.options.shared: # RuntimeLibrary only defined in lib props files - props_path = os.path.join(self._source_subfolder, "build.vc", - "mpir_{}_{}.props".format(str(self.settings.build_type).lower(), self._dll_or_lib)) - if self.settings.build_type == "Debug": - tools.replace_in_file(props_path, "MultiThreadedDebug", - "MultiThreadedDebugDLL") - else: - tools.replace_in_file(props_path, "MultiThreaded", - "MultiThreadedDLL") + if not self.options.shared: # RuntimeLibrary only defined in lib props files + build_type = "debug" if self.settings.build_type == "Debug" else "release" + props_path = os.path.join(self._source_subfolder, "build.vc", + "mpir_{}_lib.props".format(build_type)) + old_runtime = "MultiThreaded{}".format( + "Debug" if build_type == "debug" else "", + ) + new_runtime = "MultiThreaded{}{}".format( + "Debug" if "d" in msvc_runtime_flag(self) else "", + "DLL" if "MD" in msvc_runtime_flag(self) else "", + ) + replace_in_file(self, props_path, old_runtime, new_runtime) msbuild = MSBuild(self) for vcxproj_path in self._vcxproj_paths: msbuild.build(vcxproj_path, platforms=self._platforms, upgrade_project=False) + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "apple-clang": + env_build = {"CC": tools.XCRun(self.settings).cc, + "CXX": tools.XCRun(self.settings).cxx} + if hasattr(self, "settings_build"): + # there is no CFLAGS_FOR_BUILD/CXXFLAGS_FOR_BUILD + xcrun = tools.XCRun(self.settings_build) + flags = " -Wno-implicit-function-declaration -isysroot {} -arch {}".format(xcrun.sdk_path, tools.to_apple_arch(self.settings_build.arch)) + env_build["CC_FOR_BUILD"] = xcrun.cc + flags + env_build["CXX_FOR_BUILD"] = xcrun.cxx + flags + with tools.environment_append(env_build): + yield + else: + yield + def _configure_autotools(self): if not self._autotools: self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) @@ -111,43 +149,67 @@ def _configure_autotools(self): self._autotools.configure(args=args) return self._autotools + def _patch_new_msvc_version(self, ver, toolset): + new_dir = os.path.join(self._source_subfolder, f'build.vc{ver}') + copy(self, pattern="*", src=os.path.join(self._source_subfolder, 'build.vc15'), dst=new_dir) + + for root, _, files in os.walk(new_dir): + for file in files: + full_file = os.path.join(root, file) + replace_in_file(self, full_file, "v141", f"{toolset}", strict=False) + replace_in_file(self, full_file, "prebuild skylake\\avx x64 15", f"prebuild skylake\\avx x64 {ver}", strict=False) + replace_in_file(self, full_file, "prebuild p3 Win32 15", f"prebuild p3 Win32 {ver}", strict=False) + replace_in_file(self, full_file, "prebuild gc Win32 15", f"prebuild gc Win32 {ver}", strict=False) + replace_in_file(self, full_file, "prebuild gc x64 15", f"prebuild gc x64 {ver}", strict=False) + replace_in_file(self, full_file, "prebuild haswell\\avx x64 15", f"prebuild haswell\\avx x64 {ver}", strict=False) + replace_in_file(self, full_file, "prebuild core2 x64 15", f"prebuild core2 x64 {ver}", strict=False) + replace_in_file(self, full_file, 'postbuild "$(TargetPath)" 15', f'postbuild "$(TargetPath)" {ver}', strict=False) + replace_in_file(self, full_file, 'check_config $(Platform) $(Configuration) 15', f'check_config $(Platform) $(Configuration) {ver}', strict=False) + + def _patch_sources(self): + if is_msvc(self): + self._patch_new_msvc_version(16, "v142") + self._patch_new_msvc_version(17, "v143") + def build(self): - if self.settings.compiler == "Visual Studio": + self._patch_sources() + if is_msvc(self): self._build_visual_studio() else: - with tools.chdir(self._source_subfolder): + with chdir(self, self._source_subfolder), self._build_context(): + # relocatable shared lib on macOS + replace_in_file(self, "configure", "-install_name \\$rpath/", "-install_name @rpath/") autotools = self._configure_autotools() autotools.make() def package(self): - self.copy("COPYING*", dst="licenses", src=self._source_subfolder) - if self.settings.compiler == "Visual Studio": - lib_folder = os.path.join(self._source_subfolder, self._dll_or_lib, + copy(self, "COPYING*", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, self._source_subfolder)) + if is_msvc(self): + lib_folder = os.path.join(self.build_folder, self._source_subfolder, self._dll_or_lib, self._platforms.get(str(self.settings.arch)), str(self.settings.build_type)) - self.copy("mpir.h", dst="include", src=lib_folder, keep_path=True) + include_folder = os.path.join(self.package_folder, "include") + copy(self, "mpir.h", dst=include_folder, src=lib_folder, keep_path=True) if self.options.enable_gmpcompat: - self.copy("gmp.h", dst="include", src=lib_folder, keep_path=True) + copy(self, "gmp.h", dst=include_folder, src=lib_folder, keep_path=True) if self.options.get_safe("enable_cxx"): - self.copy("mpirxx.h", dst="include", src=lib_folder, keep_path=True) + copy(self, "mpirxx.h", dst=include_folder, src=lib_folder, keep_path=True) if self.options.enable_gmpcompat: - self.copy("gmpxx.h", dst="include", src=lib_folder, keep_path=True) - self.copy(pattern="*.dll*", dst="bin", src=lib_folder, keep_path=False) - self.copy(pattern="*.lib", dst="lib", src=lib_folder, keep_path=False) + copy(self, "gmpxx.h", dst=include_folder, src=lib_folder, keep_path=True) + copy(self, pattern="*.dll*", dst=os.path.join(self.package_folder, "bin"), src=lib_folder, keep_path=False) + copy(self, pattern="*.lib", dst=os.path.join(self.package_folder, "lib"), src=lib_folder, keep_path=False) else: - with tools.chdir(self._source_subfolder): + with chdir(self, self._source_subfolder), self._build_context(): autotools = self._configure_autotools() autotools.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - with tools.chdir(os.path.join(self.package_folder, "lib")): - for filename in glob.glob("*.la"): - os.unlink(filename) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) def package_info(self): if self.options.get_safe("enable_cxx"): self.cpp_info.libs.append("mpirxx") self.cpp_info.libs.append("mpir") - if self.options.enable_gmpcompat and self.settings.compiler != "Visual Studio": + if self.options.enable_gmpcompat and not is_msvc(self): if self.options.get_safe("enable_cxx"): self.cpp_info.libs.append("gmpxx") self.cpp_info.libs.append("gmp") diff --git a/recipes/mpir/all/test_package/CMakeLists.txt b/recipes/mpir/all/test_package/CMakeLists.txt index 196188113685c..d64654ce1f75a 100644 --- a/recipes/mpir/all/test_package/CMakeLists.txt +++ b/recipes/mpir/all/test_package/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) + +find_package(mpir CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} mpir::mpir) diff --git a/recipes/mpir/all/test_package/conanfile.py b/recipes/mpir/all/test_package/conanfile.py index bd7165a553cf4..2490acfa82ff8 100644 --- a/recipes/mpir/all/test_package/conanfile.py +++ b/recipes/mpir/all/test_package/conanfile.py @@ -1,10 +1,11 @@ -from conans import ConanFile, CMake, tools +from conans import ConanFile, CMake +from conan.tools.build import cross_building import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -12,6 +13,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/mpmcqueue/all/conandata.yml b/recipes/mpmcqueue/all/conandata.yml new file mode 100644 index 0000000000000..d3dfe57bc07e6 --- /dev/null +++ b/recipes/mpmcqueue/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0": + url: "https://github.com/rigtorp/MPMCQueue/archive/refs/tags/v1.0.tar.gz" + sha256: "f009ef10b66f2b8bc6e3a4f50577efbdfea0c163464cd7de368378f173007b75" diff --git a/recipes/mpmcqueue/all/conanfile.py b/recipes/mpmcqueue/all/conanfile.py new file mode 100644 index 0000000000000..f31d795bc0cc2 --- /dev/null +++ b/recipes/mpmcqueue/all/conanfile.py @@ -0,0 +1,55 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.50.0" + + +class MpmcqueueConan(ConanFile): + name = "mpmcqueue" + description = "A bounded multi-producer multi-consumer concurrent queue written in C++11." + license = "MIT" + topics = ("mpmcqueue", "queue", "concurrency") + homepage = "https://github.com/rigtorp/MPMCQueue" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "5": + raise ConanInvalidConfiguration("gcc < 5 not supported") + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "MPMCQueue") + self.cpp_info.set_property("cmake_target_name", "MPMCQueue::MPMCQueue") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "MPMCQueue" + self.cpp_info.names["cmake_find_package_multi"] = "MPMCQueue" diff --git a/recipes/mpmcqueue/all/test_package/CMakeLists.txt b/recipes/mpmcqueue/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a914eaad36ece --- /dev/null +++ b/recipes/mpmcqueue/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(MPMCQueue REQUIRED CONFIG) +find_package(Threads REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE MPMCQueue::MPMCQueue Threads::Threads) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/mpmcqueue/all/test_package/conanfile.py b/recipes/mpmcqueue/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/mpmcqueue/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mpmcqueue/all/test_package/test_package.cpp b/recipes/mpmcqueue/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..e3c8d12a9996f --- /dev/null +++ b/recipes/mpmcqueue/all/test_package/test_package.cpp @@ -0,0 +1,24 @@ +#include + +#include +#include + +int main() { + rigtorp::MPMCQueue q(10); + auto t1 = std::thread([&] { + int v; + q.pop(v); + std::cout << "t1 " << v << "\n"; + }); + auto t2 = std::thread([&] { + int v; + q.pop(v); + std::cout << "t2 " << v << "\n"; + }); + q.push(1); + q.push(2); + t1.join(); + t2.join(); + + return 0; +} diff --git a/recipes/mpmcqueue/all/test_v1_package/CMakeLists.txt b/recipes/mpmcqueue/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e299736630b60 --- /dev/null +++ b/recipes/mpmcqueue/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(MPMCQueue REQUIRED CONFIG) +find_package(Threads REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE MPMCQueue::MPMCQueue Threads::Threads) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/mpmcqueue/all/test_v1_package/conanfile.py b/recipes/mpmcqueue/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mpmcqueue/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mpmcqueue/config.yml b/recipes/mpmcqueue/config.yml new file mode 100644 index 0000000000000..edab1ee152d36 --- /dev/null +++ b/recipes/mpmcqueue/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0": + folder: all diff --git a/recipes/mppp/all/conandata.yml b/recipes/mppp/all/conandata.yml new file mode 100644 index 0000000000000..9e4f3e0e2fcbe --- /dev/null +++ b/recipes/mppp/all/conandata.yml @@ -0,0 +1,17 @@ +sources: + "0.27": + url: "https://github.com/bluescarni/mppp/archive/v0.27.tar.gz" + sha256: "a1e04f6605b3242d4361742159cf5ab273162fd7c105c2743a9bebcf44c846c3" + "0.26": + url: "https://github.com/bluescarni/mppp/archive/v0.26.tar.gz" + sha256: "4dbfa68802d9a1365eda884f085418afc147d01b7a928e8333e4dcc1c3b3ce9e" + +patches: + "0.27": + - patch_file: "patches/0.27-0001-disable-warning-error.patch" + patch_description: "disable the flag for treats warning as errors" + patch_type: "portability" + "0.26": + - patch_file: "patches/0.26-0001-disable-warning-error.patch" + patch_description: "disable the flag for treats warning as errors" + patch_type: "portability" diff --git a/recipes/mppp/all/conanfile.py b/recipes/mppp/all/conanfile.py new file mode 100644 index 0000000000000..b81c5b84c795c --- /dev/null +++ b/recipes/mppp/all/conanfile.py @@ -0,0 +1,122 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc_static_runtime +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +import os + +required_conan_version = ">=1.52.0" + +class MpppConan(ConanFile): + name = "mppp" + description = "Multiprecision for modern C++ Topics" + license = "MPL-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/bluescarni/mppp/" + topics = ("multiprecision", "gmp", "math-bignum", "computer-algebra") + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_mpfr": [True, False], + "with_arb": [True, False], + "with_mpc": [True, False], + "with_quadmath": [True, False], + "with_boost": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_mpfr": False, + "with_arb": False, + "with_mpc": False, + "with_quadmath": False, + "with_boost": False, + } + + @property + def _minimum_cpp_standard(self): + return 11 + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("gmp/6.2.1") + if self.options.with_mpfr == True: + self.requires("mpfr/4.1.0") + if self.options.with_mpc == True: + self.requires("mpc/1.2.0") + if self.options.with_boost == True: + self.requires("boost/1.80.0") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + if self.options.with_arb: + raise ConanInvalidConfiguration(f"{self.ref}:with_arb=True is not supported because `fredrik-johansson/arb` is not packaged in CCI. (yet)") + if self.options.with_quadmath: + raise ConanInvalidConfiguration(f"{self.ref}:with_quadmath=True is not supported because `libquadmath` is not available from CCI. (yet)") + if self.options.with_boost and self.options["boost"].without_serialization: + raise ConanInvalidConfiguration(f"{self.name}:with_boost=True requires boost::without_serialization=False") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + tc.variables["MPPP_BUILD_STATIC_LIBRARY"] = not self.options.shared + tc.variables["MPPP_WITH_MPFR"] = self.options.with_mpfr + tc.variables["MPPP_WITH_ARB"] = self.options.with_arb + tc.variables["MPPP_WITH_MPC"] = self.options.with_mpc + tc.variables["MPPP_WITH_QUADMATH"] = self.options.with_quadmath + tc.variables["MPPP_WITH_BOOST_S11N"] = self.options.with_boost + if not self.options.shared: + tc.variables["MPPP_BUILD_STATIC_LIBRARY_WITH_DYNAMIC_MSVC_RUNTIME"] = not is_msvc_static_runtime(self) + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.libs = ["mp++"] + self.cpp_info.set_property("cmake_file_name", "mp++") + self.cpp_info.set_property("cmake_target_name", "mp++::mp++") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.filenames["cmake_find_package"] = "mp++" + self.cpp_info.filenames["cmake_find_package_multi"] = "mp++" + self.cpp_info.names["cmake_find_package"] = "mp++" + self.cpp_info.names["cmake_find_package_multi"] = "mp++" diff --git a/recipes/mppp/all/patches/0.26-0001-disable-warning-error.patch b/recipes/mppp/all/patches/0.26-0001-disable-warning-error.patch new file mode 100644 index 0000000000000..1f43796c81faa --- /dev/null +++ b/recipes/mppp/all/patches/0.26-0001-disable-warning-error.patch @@ -0,0 +1,22 @@ +diff --git a/cmake/yacma/YACMACompilerLinkerSettings.cmake b/cmake/yacma/YACMACompilerLinkerSettings.cmake +index 7d7aa1b..aaff75f 100644 +--- a/cmake/yacma/YACMACompilerLinkerSettings.cmake ++++ b/cmake/yacma/YACMACompilerLinkerSettings.cmake +@@ -95,7 +95,7 @@ if(NOT _YACMACompilerLinkerSettingsRun) + # NOTE: enable unconditionally, as it seems like the CMake + # machinery for detecting this fails. Perhaps the source code + # used for checking the flag emits warnings? +- list(APPEND _YACMA_CXX_FLAGS_DEBUG "-Werror") ++ # list(APPEND _YACMA_CXX_FLAGS_DEBUG "-Werror") + # New warnings in clang 8. + # NOTE: a few issues with macros here, let's disable for now. + # _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wextra-semi-stmt) +@@ -180,7 +180,7 @@ if(NOT _YACMACompilerLinkerSettingsRun) + # Enable higher warning level than usual. + _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/W4) + # Treat warnings as errors. +- _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/WX) ++ # _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/WX) + endif() + + # Set the cache variables. diff --git a/recipes/mppp/all/patches/0.27-0001-disable-warning-error.patch b/recipes/mppp/all/patches/0.27-0001-disable-warning-error.patch new file mode 100644 index 0000000000000..8906bc4799f22 --- /dev/null +++ b/recipes/mppp/all/patches/0.27-0001-disable-warning-error.patch @@ -0,0 +1,25 @@ +diff --git a/cmake/yacma/YACMACompilerLinkerSettings.cmake b/cmake/yacma/YACMACompilerLinkerSettings.cmake +index edafe6d..10f40ed 100644 +--- a/cmake/yacma/YACMACompilerLinkerSettings.cmake ++++ b/cmake/yacma/YACMACompilerLinkerSettings.cmake +@@ -91,11 +91,6 @@ if(NOT _YACMACompilerLinkerSettingsRun) + # For now it seems like -Wshadow from clang behaves better than GCC's, just enable it here + # for the time being. + _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wshadow) +- # Clang is better at this flag than GCC. +- # NOTE: enable unconditionally, as it seems like the CMake +- # machinery for detecting this fails. Perhaps the source code +- # used for checking the flag emits warnings? +- list(APPEND _YACMA_CXX_FLAGS_DEBUG "-Werror") + # New warnings in clang 8. + # NOTE: a few issues with macros here, let's disable for now. + # _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wextra-semi-stmt) +@@ -190,8 +185,6 @@ if(NOT _YACMACompilerLinkerSettingsRun) + if(YACMA_COMPILER_IS_MSVC AND NOT YACMA_COMPILER_IS_CLANGXX) + # Enable higher warning level than usual. + _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/W4) +- # Treat warnings as errors. +- _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/WX) + endif() + + # Set the cache variables. diff --git a/recipes/mppp/all/test_package/CMakeLists.txt b/recipes/mppp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..320edf00b9406 --- /dev/null +++ b/recipes/mppp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(mp++ REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE mp++::mp++) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/mppp/all/test_package/conanfile.py b/recipes/mppp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..a9fbb7f543162 --- /dev/null +++ b/recipes/mppp/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mppp/all/test_package/test_package.cpp b/recipes/mppp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..316ebf8a4ca8c --- /dev/null +++ b/recipes/mppp/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include + +#include "mp++/integer.hpp" +#include "mp++/rational.hpp" + +int main() { + auto integer = mppp::integer<2>{4}; + std::cout << integer << std::endl; + + auto rational = mppp::rational<2>{4}; + std::cout << rational << std::endl; + + return 0; +} diff --git a/recipes/mppp/all/test_v1_package/CMakeLists.txt b/recipes/mppp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9d54a092e0a67 --- /dev/null +++ b/recipes/mppp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/mppp/all/test_v1_package/conanfile.py b/recipes/mppp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..5a05af3c2dfd2 --- /dev/null +++ b/recipes/mppp/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mppp/config.yml b/recipes/mppp/config.yml new file mode 100644 index 0000000000000..d4d8ae20a50d8 --- /dev/null +++ b/recipes/mppp/config.yml @@ -0,0 +1,5 @@ +versions: + "0.27": + folder: all + "0.26": + folder: all diff --git a/recipes/ms-gsl/all/conandata.yml b/recipes/ms-gsl/all/conandata.yml index 845976604f804..00aab19c60dba 100644 --- a/recipes/ms-gsl/all/conandata.yml +++ b/recipes/ms-gsl/all/conandata.yml @@ -1,13 +1,16 @@ sources: - "2.0.0": - url: https://github.com/microsoft/GSL/archive/v2.0.0.tar.gz - sha256: "6cce6fb16b651e62711a4f58e484931013c33979b795d1b1f7646f640cfa9c8e" - "2.1.0": - url: https://github.com/microsoft/GSL/archive/v2.1.0.tar.gz - sha256: "ef73814657b073e1be86c8f7353718771bf4149b482b6cb54f99e79b23ff899d" - "3.0.1": - url: "https://github.com/microsoft/GSL/archive/v3.0.1.tar.gz" - sha256: "7ceba191e046e5347357c6b605f53e6bed069c974aeda851254cb6962a233572" + "4.0.0": + url: "https://github.com/microsoft/GSL/archive/v4.0.0.tar.gz" + sha256: "f0e32cb10654fea91ad56bde89170d78cfbf4363ee0b01d8f097de2ba49f6ce9" "3.1.0": url: "https://github.com/microsoft/GSL/archive/v3.1.0.tar.gz" sha256: "d3234d7f94cea4389e3ca70619b82e8fb4c2f33bb3a070799f1e18eef500a083" + "3.0.1": + url: "https://github.com/microsoft/GSL/archive/v3.0.1.tar.gz" + sha256: "7ceba191e046e5347357c6b605f53e6bed069c974aeda851254cb6962a233572" + "2.1.0": + url: https://github.com/microsoft/GSL/archive/v2.1.0.tar.gz + sha256: "ef73814657b073e1be86c8f7353718771bf4149b482b6cb54f99e79b23ff899d" + "2.0.0": + url: https://github.com/microsoft/GSL/archive/v2.0.0.tar.gz + sha256: "6cce6fb16b651e62711a4f58e484931013c33979b795d1b1f7646f640cfa9c8e" diff --git a/recipes/ms-gsl/all/conanfile.py b/recipes/ms-gsl/all/conanfile.py index 9c748397feef5..1f2447a4480af 100644 --- a/recipes/ms-gsl/all/conanfile.py +++ b/recipes/ms-gsl/all/conanfile.py @@ -1,16 +1,25 @@ import os -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.scm import Version + +required_conan_version = ">=1.50.0" + class MicrosoftGslConan(ConanFile): name = "ms-gsl" - description = "Microsoft implementation of the Guidelines Support Library" + description = "Microsoft's implementation of the Guidelines Support Library" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/microsoft/GSL" license = "MIT" topics = ("gsl", "guidelines", "core", "span") no_copy_source = True - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" options = { "on_contract_violation": ["terminate", "throw", "unenforced"] } @@ -18,6 +27,10 @@ class MicrosoftGslConan(ConanFile): "on_contract_violation": "terminate" } + @property + def _minimum_cpp_standard(self): + return 14 + @property def _contract_map(self): return { @@ -26,51 +39,67 @@ def _contract_map(self): "unenforced": "GSL_UNENFORCED_ON_CONTRACT_VIOLATION", } - @property - def _source_subfolder(self): - return "source_subfolder" - @property def _compilers_minimum_version(self): return { "gcc": "5", - "Visual Studio": "14", "clang": "3.4", "apple-clang": "3.4", } def config_options(self): - if tools.Version(self.version) >= "3.0.0": + if Version(self.version) >= "3.0.0": del self.options.on_contract_violation - def configure(self): + def package_id(self): + self.info.clear() + + def validate(self): if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 14) - minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if minimum_version: - if tools.Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration("ms-gsl requires C++14, which your compiler does not fully support.") - else: - self.output.warn("ms-gsl requires C++14. Your compiler is unknown. Assuming it supports C++14.") + check_min_cppstd(self, self._minimum_cpp_standard) - def package_id(self): - self.info.header_only() + check_min_vs(self, "190") + + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version: + if Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not fully support.") + else: + self.output.warn(f"{self.ref} requires C++{self._minimum_cpp_standard}. " + "Your compiler is unknown. Assuming it supports C++{self._minimum_cpp_standard}.") + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "GSL-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + pass + + def build(self): + pass def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy(self, "*", os.path.join(self.source_folder, "include"), os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "Microsoft.GSL") + self.cpp_info.set_property("cmake_target_name", "Microsoft.GSL::GSL") + + self.cpp_info.filenames["cmake_find_package"] = "Microsoft.GSL" + self.cpp_info.filenames["cmake_find_package_multi"] = "Microsoft.GSL" self.cpp_info.names["cmake_find_package"] = "Microsoft.GSL" self.cpp_info.names["cmake_find_package_multi"] = "Microsoft.GSL" + self.cpp_info.components["_ms-gsl"].names["cmake_find_package"] = "GSL" self.cpp_info.components["_ms-gsl"].names["cmake_find_package_multi"] = "GSL" - if tools.Version(self.version) < "3.0.0": + + if Version(self.version) < "3.0.0": self.cpp_info.components["_ms-gsl"].defines = [ self._contract_map[str(self.options.on_contract_violation)] ] diff --git a/recipes/ms-gsl/all/test_package/CMakeLists.txt b/recipes/ms-gsl/all/test_package/CMakeLists.txt index d0355a6caf98c..81fc0751a73bb 100644 --- a/recipes/ms-gsl/all/test_package/CMakeLists.txt +++ b/recipes/ms-gsl/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(Microsoft.GSL REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} Microsoft.GSL::GSL) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +add_executable(test_package test_package.cpp) +target_link_libraries(test_package PRIVATE Microsoft.GSL::GSL) +target_compile_features(test_package PRIVATE cxx_std_14) diff --git a/recipes/ms-gsl/all/test_package/conanfile.py b/recipes/ms-gsl/all/test_package/conanfile.py index 54e4743603cf3..074627225806d 100644 --- a/recipes/ms-gsl/all/test_package/conanfile.py +++ b/recipes/ms-gsl/all/test_package/conanfile.py @@ -1,10 +1,20 @@ import os -from conans import ConanFile, CMake, tools + +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout class TestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +22,5 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun") diff --git a/recipes/ms-gsl/all/test_package/test_package.cpp b/recipes/ms-gsl/all/test_package/test_package.cpp index 574484165ae13..5999d447df927 100644 --- a/recipes/ms-gsl/all/test_package/test_package.cpp +++ b/recipes/ms-gsl/all/test_package/test_package.cpp @@ -1,8 +1,12 @@ +#include #include int main() { - char stack_string[] = "Hello"; - gsl::string_span<> v = gsl::ensure_z(stack_string); + std::array data{{1, 2, 3, 4, 5}}; + gsl::span span(data); + if (span.size() != 5) { + return 1; + } return 0; } diff --git a/recipes/ms-gsl/all/test_v1_package/CMakeLists.txt b/recipes/ms-gsl/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/ms-gsl/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/ms-gsl/all/test_v1_package/conanfile.py b/recipes/ms-gsl/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..6314fb1c24e96 --- /dev/null +++ b/recipes/ms-gsl/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +import os + +from conan.tools.build import cross_building +from conans import ConanFile, CMake + + +class TestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ms-gsl/config.yml b/recipes/ms-gsl/config.yml index a3250af7130bf..b00b1020b4e16 100644 --- a/recipes/ms-gsl/config.yml +++ b/recipes/ms-gsl/config.yml @@ -1,9 +1,11 @@ versions: - "2.0.0": + "4.0.0": folder: all - "2.1.0": + "3.1.0": folder: all "3.0.1": folder: all - "3.1.0": + "2.1.0": + folder: all + "2.0.0": folder: all diff --git a/recipes/msdf-atlas-gen/all/CMakeLists.txt b/recipes/msdf-atlas-gen/all/CMakeLists.txt new file mode 100644 index 0000000000000..39b22c5320bd6 --- /dev/null +++ b/recipes/msdf-atlas-gen/all/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +find_package(msdfgen REQUIRED) + +add_subdirectory(source_subfolder) + diff --git a/recipes/msdf-atlas-gen/all/conandata.yml b/recipes/msdf-atlas-gen/all/conandata.yml new file mode 100644 index 0000000000000..20e043a17e6cd --- /dev/null +++ b/recipes/msdf-atlas-gen/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.2.2": + url: "https://github.com/Chlumsky/msdf-atlas-gen/archive/refs/tags/v1.2.2.tar.gz" + sha256: "7D2EA46F66E21AB9A205BF7703D520F209B9A035EE13CBB266A3B8322F62FA28" diff --git a/recipes/msdf-atlas-gen/all/conanfile.py b/recipes/msdf-atlas-gen/all/conanfile.py new file mode 100644 index 0000000000000..a6c7d8b9a0b2a --- /dev/null +++ b/recipes/msdf-atlas-gen/all/conanfile.py @@ -0,0 +1,71 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.33.0" + + +class MsdfAtlasGenConan(ConanFile): + name = "msdf-atlas-gen" + license = "MIT" + homepage = "https://github.com/Chlumsky/msdf-atlas-gen" + url = "https://github.com/conan-io/conan-center-index" + description = "MSDF font atlas generator" + topics = ("msdf-atlas-gen", "msdf", "font", "atlas") + settings = "os", "arch", "compiler", "build_type" + + generators = "cmake", "cmake_find_package_multi" + exports_sources = ["CMakeLists.txt"] + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def requirements(self): + self.requires("artery-font-format/1.0") + self.requires("msdfgen/1.9.1") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + def package_id(self): + del self.info.settings.compiler + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + def _patch_sources(self): + cmakelists = os.path.join( + self._source_subfolder, "CMakeLists.txt") + + tools.replace_in_file(cmakelists, + "add_subdirectory(msdfgen)", "") + tools.save_append(cmakelists, + "install(TARGETS msdf-atlas-gen-standalone DESTINATION bin)") + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["MSDF_ATLAS_GEN_BUILD_STANDALONE"] = True + self._cmake.configure() + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libdirs = [] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/msdf-atlas-gen/all/test_package/Sacramento-Regular.ttf b/recipes/msdf-atlas-gen/all/test_package/Sacramento-Regular.ttf new file mode 100644 index 0000000000000..cfd2eabc8699f Binary files /dev/null and b/recipes/msdf-atlas-gen/all/test_package/Sacramento-Regular.ttf differ diff --git a/recipes/msdf-atlas-gen/all/test_package/conanfile.py b/recipes/msdf-atlas-gen/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0e314c3e127bb --- /dev/null +++ b/recipes/msdf-atlas-gen/all/test_package/conanfile.py @@ -0,0 +1,28 @@ +from conans import ConanFile, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + @property + def _atlas_texture_file(self): + return os.path.join(self.build_folder, "atlas_texture.png") + + @property + def _atlas_desc_file(self): + return os.path.join(self.build_folder, "atlas_desc.json") + + def test(self): + if not tools.cross_building(self): + ttf_path = os.path.join( + self.source_folder, "Sacramento-Regular.ttf") + charset_path = os.path.join( + self.source_folder, "uppercase_charset") + + ret_code = self.run( + "msdf-atlas-gen -font {} -charset {} -imageout {} -json {}".format(ttf_path, charset_path, self._atlas_texture_file, self._atlas_desc_file), run_environment=True) + + assert ret_code == 0 + assert os.path.isfile(self._atlas_texture_file) + assert os.path.isfile(self._atlas_desc_file) diff --git a/recipes/msdf-atlas-gen/all/test_package/uppercase_charset b/recipes/msdf-atlas-gen/all/test_package/uppercase_charset new file mode 100644 index 0000000000000..c3c76b7e894ab --- /dev/null +++ b/recipes/msdf-atlas-gen/all/test_package/uppercase_charset @@ -0,0 +1 @@ +['A', 'Z'] diff --git a/recipes/msdf-atlas-gen/config.yml b/recipes/msdf-atlas-gen/config.yml new file mode 100644 index 0000000000000..af40d9653a378 --- /dev/null +++ b/recipes/msdf-atlas-gen/config.yml @@ -0,0 +1,3 @@ +versions: + "1.2.2": + folder: all diff --git a/recipes/bacnet-stack/all/CMakeLists.txt b/recipes/msdfgen/all/CMakeLists.txt similarity index 100% rename from recipes/bacnet-stack/all/CMakeLists.txt rename to recipes/msdfgen/all/CMakeLists.txt diff --git a/recipes/msdfgen/all/conandata.yml b/recipes/msdfgen/all/conandata.yml new file mode 100644 index 0000000000000..68280085d13a4 --- /dev/null +++ b/recipes/msdfgen/all/conandata.yml @@ -0,0 +1,11 @@ +sources: + "1.9.1": + url: "https://github.com/Chlumsky/msdfgen/archive/refs/tags/v1.9.1.tar.gz" + sha256: "0d2cf3113eea97776731888c711ff836b2be7ff35966a2aa86f3dc57103d0740" + "1.9": + url: "https://github.com/Chlumsky/msdfgen/archive/refs/tags/v1.9.tar.gz" + sha256: "909eb88c71268dc00cdda244a1fa40a0feefae45f68a779fbfddd5463559fa40" +patches: + "1.9": + - patch_file: "patches/0001-fix-install-bundle.patch" + base_path: "source_subfolder" diff --git a/recipes/msdfgen/all/conanfile.py b/recipes/msdfgen/all/conanfile.py new file mode 100644 index 0000000000000..039af25baae11 --- /dev/null +++ b/recipes/msdfgen/all/conanfile.py @@ -0,0 +1,144 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.43.0" + + +class MsdfgenConan(ConanFile): + name = "msdfgen" + description = "Multi-channel signed distance field generator" + license = "MIT" + topics = ("msdfgen", "msdf", "shape", "glyph", "font") + homepage = "https://github.com/Chlumsky/msdfgen" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_openmp": [True, False], + "with_skia": [True, False], + "utility": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_openmp": False, + "with_skia": False, + "utility": True, + } + + generators = "cmake", "cmake_find_package" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("freetype/2.11.1") + self.requires("lodepng/cci.20200615") + self.requires("tinyxml2/9.0.0") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + if self._is_msvc and self.options.shared: + raise ConanInvalidConfiguration("msdfgen shared not supported by Visual Studio") + if self.options.with_skia: + raise ConanInvalidConfiguration("skia recipe not available yet in CCI") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") + # unvendor lodepng & tinyxml2 + tools.rmdir(os.path.join(self._source_subfolder, "lib")) + tools.replace_in_file(cmakelists, "\"lib/*.cpp\"", "") + tools.replace_in_file(cmakelists, + "target_link_libraries(msdfgen-ext PUBLIC msdfgen::msdfgen Freetype::Freetype)", + "target_link_libraries(msdfgen-ext PUBLIC msdfgen::msdfgen ${CONAN_LIBS})") + # very weird but required for Visual Studio when libs are unvendored (at least for Ninja generator) + if self._is_msvc: + tools.replace_in_file(cmakelists, + "set_target_properties(msdfgen-standalone PROPERTIES ARCHIVE_OUTPUT_DIRECTORY archive OUTPUT_NAME msdfgen)", + "set_target_properties(msdfgen-standalone PROPERTIES OUTPUT_NAME msdfgen IMPORT_PREFIX foo)") + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["MSDFGEN_BUILD_MSDFGEN_STANDALONE"] = self.options.utility + self._cmake.definitions["MSDFGEN_USE_OPENMP"] = self.options.with_openmp + self._cmake.definitions["MSDFGEN_USE_CPP11"] = True + self._cmake.definitions["MSDFGEN_USE_SKIA"] = self.options.with_skia + self._cmake.definitions["MSDFGEN_INSTALL"] = True + self._cmake.configure() + return self._cmake + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "msdfgen") + # Required to avoid some side effect in CMakeDeps generator of downstream recipes + self.cpp_info.set_property("cmake_target_name", "msdfgen::msdgen-all-unofficial") + + self.cpp_info.names["cmake_find_package"] = "msdfgen" + self.cpp_info.names["cmake_find_package_multi"] = "msdfgen" + + includedir = os.path.join("include", "msdfgen") + + self.cpp_info.components["_msdfgen"].set_property("cmake_target_name", "msdfgen::msdfgen") + self.cpp_info.components["_msdfgen"].names["cmake_find_package"] = "msdfgen" + self.cpp_info.components["_msdfgen"].names["cmake_find_package_multi"] = "msdfgen" + self.cpp_info.components["_msdfgen"].includedirs.append(includedir) + self.cpp_info.components["_msdfgen"].libs = ["msdfgen"] + self.cpp_info.components["_msdfgen"].defines = ["MSDFGEN_USE_CPP11"] + + self.cpp_info.components["msdfgen-ext"].set_property("cmake_target_name", "msdfgen::msdfgen-ext") + self.cpp_info.components["msdfgen-ext"].names["cmake_find_package"] = "msdfgen-ext" + self.cpp_info.components["msdfgen-ext"].names["cmake_find_package_multi"] = "msdfgen-ext" + self.cpp_info.components["msdfgen-ext"].includedirs.append(includedir) + self.cpp_info.components["msdfgen-ext"].libs = ["msdfgen-ext"] + self.cpp_info.components["msdfgen-ext"].requires = [ + "_msdfgen", "freetype::freetype", + "lodepng::lodepng", "tinyxml2::tinyxml2", + ] + if self.options.with_skia: + self.cpp_info.components["msdfgen-ext"].defines.append("MSDFGEN_USE_SKIA") + + if self.options.utility: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/msdfgen/all/patches/0001-fix-install-bundle.patch b/recipes/msdfgen/all/patches/0001-fix-install-bundle.patch new file mode 100644 index 0000000000000..195cb3e50f2fe --- /dev/null +++ b/recipes/msdfgen/all/patches/0001-fix-install-bundle.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -170,7 +170,7 @@ if(MSDFGEN_INSTALL) + ) + + if(MSDFGEN_BUILD_MSDFGEN_STANDALONE) +- install(TARGETS msdfgen-standalone EXPORT msdfgenTargets RUNTIME DESTINATION bin) ++ install(TARGETS msdfgen-standalone EXPORT msdfgenTargets DESTINATION bin) + endif() + + install( diff --git a/recipes/msdfgen/all/test_package/CMakeLists.txt b/recipes/msdfgen/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..21c326b4889f2 --- /dev/null +++ b/recipes/msdfgen/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(msdfgen REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} msdfgen::msdfgen msdfgen::msdfgen-ext) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/msdfgen/all/test_package/OpenSans-Bold.ttf b/recipes/msdfgen/all/test_package/OpenSans-Bold.ttf new file mode 100644 index 0000000000000..fd79d43bea029 Binary files /dev/null and b/recipes/msdfgen/all/test_package/OpenSans-Bold.ttf differ diff --git a/recipes/msdfgen/all/test_package/conanfile.py b/recipes/msdfgen/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5a0706c8f6c9c --- /dev/null +++ b/recipes/msdfgen/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + ttf_path = os.path.join(self.source_folder, "OpenSans-Bold.ttf") + bin_path = os.path.join("bin", "test_package") + self.run("{0} {1}".format(bin_path, ttf_path), run_environment=True) diff --git a/recipes/msdfgen/all/test_package/test_package.cpp b/recipes/msdfgen/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..d169064c206c2 --- /dev/null +++ b/recipes/msdfgen/all/test_package/test_package.cpp @@ -0,0 +1,29 @@ +#include +#include + +#include + +int main(int argc, char **argv) { + if (argc < 2) { + std::cerr << "Need at least one argument\n"; + return 1; + } + + msdfgen::FreetypeHandle *ft = msdfgen::initializeFreetype(); + if (ft) { + msdfgen::FontHandle *font = msdfgen::loadFont(ft, argv[1]); + if (font) { + msdfgen::Shape shape; + if (msdfgen::loadGlyph(shape, font, 'A')) { + shape.normalize(); + msdfgen::edgeColoringSimple(shape, 3.0); + msdfgen::Bitmap msdf(32, 32); + msdfgen::generateMSDF(msdf, shape, 4.0, 1.0, msdfgen::Vector2(4.0, 4.0)); + msdfgen::savePng(msdf, "output.png"); + } + msdfgen::destroyFont(font); + } + msdfgen::deinitializeFreetype(ft); + } + return 0; +} diff --git a/recipes/msdfgen/config.yml b/recipes/msdfgen/config.yml new file mode 100644 index 0000000000000..9843a08c19d0c --- /dev/null +++ b/recipes/msdfgen/config.yml @@ -0,0 +1,5 @@ +versions: + "1.9.1": + folder: all + "1.9": + folder: all diff --git a/recipes/msgpack-c/all/CMakeLists.txt b/recipes/msgpack-c/all/CMakeLists.txt new file mode 100644 index 0000000000000..11573c481bf89 --- /dev/null +++ b/recipes/msgpack-c/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.0) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/msgpack-c/all/conandata.yml b/recipes/msgpack-c/all/conandata.yml new file mode 100644 index 0000000000000..c4ec3f12fd71c --- /dev/null +++ b/recipes/msgpack-c/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "4.0.0": + url: "https://github.com/msgpack/msgpack-c/releases/download/c-4.0.0/msgpack-c-4.0.0.tar.gz" + sha256: "420fe35e7572f2a168d17e660ef981a589c9cbe77faa25eb34a520e1fcc032c8" diff --git a/recipes/msgpack-c/all/conanfile.py b/recipes/msgpack-c/all/conanfile.py new file mode 100644 index 0000000000000..b46a9fad94eec --- /dev/null +++ b/recipes/msgpack-c/all/conanfile.py @@ -0,0 +1,106 @@ +from conans import ConanFile, CMake, tools +import os +import textwrap + +required_conan_version = ">=1.43.0" + + +class MsgpackCConan(ConanFile): + name = "msgpack-c" + description = "MessagePack implementation for C" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/msgpack/msgpack-c" + topics = ("msgpack", "message-pack", "serialization") + license = "BSL-1.0" + exports_sources = "CMakeLists.txt" + generators = "cmake" + settings = "os", "arch", "build_type", "compiler" + options = { + "fPIC": [True, False], + "shared": [True, False], + } + default_options = { + "fPIC": True, + "shared": False, + } + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["MSGPACK_ENABLE_SHARED"] = self.options.shared + self._cmake.definitions["MSGPACK_ENABLE_STATIC"] = not self.options.shared + self._cmake.definitions["MSGPACK_32BIT"] = self.settings.arch == "x86" + self._cmake.definitions["MSGPACK_BUILD_EXAMPLES"] = False + self._cmake.definitions["MSGPACK_BUILD_TESTS"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE_1_0.txt", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"msgpackc": "msgpack::msgpack"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "msgpack") + self.cpp_info.set_property("cmake_target_name", "msgpackc") + self.cpp_info.set_property("pkg_config_name", "msgpack") + self.cpp_info.libs = ["msgpackc"] + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "msgpack" + self.cpp_info.names["cmake_find_package_multi"] = "msgpack" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + self.cpp_info.names["pkg_config"] = "msgpack" diff --git a/recipes/msgpack-c/all/test_package/CMakeLists.txt b/recipes/msgpack-c/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..03402926ba00c --- /dev/null +++ b/recipes/msgpack-c/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(msgpack REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} msgpackc) diff --git a/recipes/msgpack-c/all/test_package/conanfile.py b/recipes/msgpack-c/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ae98db96b89a1 --- /dev/null +++ b/recipes/msgpack-c/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_c_path = os.path.join("bin", "test_package") + self.run(bin_c_path, run_environment=True) diff --git a/recipes/msgpack-c/all/test_package/test_package.c b/recipes/msgpack-c/all/test_package/test_package.c new file mode 100644 index 0000000000000..17422b5a0a3d2 --- /dev/null +++ b/recipes/msgpack-c/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include + +#include + +int main() { + printf("msgpack version %s\n", msgpack_version()); + return 0; +} diff --git a/recipes/msgpack-c/config.yml b/recipes/msgpack-c/config.yml new file mode 100644 index 0000000000000..d2be8f453d7c0 --- /dev/null +++ b/recipes/msgpack-c/config.yml @@ -0,0 +1,3 @@ +versions: + "4.0.0": + folder: all diff --git a/recipes/msgpack-cxx/all/conandata.yml b/recipes/msgpack-cxx/all/conandata.yml new file mode 100644 index 0000000000000..a29da06b01237 --- /dev/null +++ b/recipes/msgpack-cxx/all/conandata.yml @@ -0,0 +1,16 @@ +sources: + "4.1.3": + url: "https://github.com/msgpack/msgpack-c/archive/cpp-4.1.3.tar.gz" + sha256: "fd0a685656f11b8aa09ed33bcbdcad3105d25d0034ca3dba9fe957623a42d253" + "4.1.2": + url: "https://github.com/msgpack/msgpack-c/archive/cpp-4.1.2.tar.gz" + sha256: "7460ad43552c9d9b56a75f20e1f4fedf18fff1c48715d6cfa91d779b26ca3795" + "4.1.1": + url: "https://github.com/msgpack/msgpack-c/archive/cpp-4.1.1.tar.gz" + sha256: "221cc539e77f5ca02f4f0bbb1edafa9ca8c08de7ba8072d7baf2139930d99182" + "4.1.0": + url: "https://github.com/msgpack/msgpack-c/archive/cpp-4.1.0.tar.gz" + sha256: "634762502a192026bd5db773f9e18d900ad04cfc312b52faee350a5c76e5ccfb" + "4.0.3": + url: "https://github.com/msgpack/msgpack-c/archive/cpp-4.0.3.tar.gz" + sha256: "23d737b1e959dfb6ca420564563f098e758adacc0b18003c56abf1b945bd1d4a" diff --git a/recipes/msgpack-cxx/all/conanfile.py b/recipes/msgpack-cxx/all/conanfile.py new file mode 100644 index 0000000000000..bffb037fb91b7 --- /dev/null +++ b/recipes/msgpack-cxx/all/conanfile.py @@ -0,0 +1,94 @@ +from conans import ConanFile, tools +from conans.errors import ConanInvalidConfiguration +import os +import textwrap + +required_conan_version = ">=1.43.0" + + +class MsgpackCXXConan(ConanFile): + name = "msgpack-cxx" + description = "The official C++ library for MessagePack" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/msgpack/msgpack-c" + topics = ("msgpack", "message-pack", "serialization") + license = "BSL-1.0" + no_copy_source = True + + settings = "os", "compiler", "build_type", "arch" + options = { + "use_boost": [True, False], + } + default_options = { + "use_boost": True + } + + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def configure_options(self): + # No boost was added in 4.1.0 + if tools.Version(self.version) < "4.1.0": + del self.options.use_boost + + def requirements(self): + if self.options.get_safe("use_boost", True): + self.requires("boost/1.78.0") + + def package_id(self): + self.info.header_only() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def package(self): + self.copy("LICENSE_1_0.txt", dst="licenses", src=self._source_subfolder) + self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) + self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"msgpackc-cxx": "msgpackc-cxx::msgpackc-cxx"} + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_subfolder(self): + return os.path.join("lib", "cmake") + + @property + def _module_file_rel_path(self): + return os.path.join(self._module_subfolder, + "conan-official-{}-targets.cmake".format(self.name)) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "msgpack") + self.cpp_info.set_property("cmake_target_name", "msgpackc-cxx") + + self.cpp_info.filenames["cmake_find_package"] = "msgpack" + self.cpp_info.filenames["cmake_find_package_multi"] = "msgpack" + self.cpp_info.names["cmake_find_package"] = "msgpackc-cxx" + self.cpp_info.names["cmake_find_package_multi"] = "msgpackc-cxx" + self.cpp_info.builddirs.append(self._module_subfolder) + self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + + if tools.Version(self.version) >= "4.1.0" and not self.options.use_boost: + self.cpp_info.defines.append("MSGPACK_NO_BOOST") diff --git a/recipes/msgpack-cxx/all/test_package/CMakeLists.txt b/recipes/msgpack-cxx/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..26b4c63518e05 --- /dev/null +++ b/recipes/msgpack-cxx/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(msgpack REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} msgpackc-cxx) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/msgpack-cxx/all/test_package/conanfile.py b/recipes/msgpack-cxx/all/test_package/conanfile.py new file mode 100644 index 0000000000000..89b74736462b2 --- /dev/null +++ b/recipes/msgpack-cxx/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_cpp_path = os.path.join("bin", "test_package") + self.run(bin_cpp_path, run_environment=True) diff --git a/recipes/msgpack-cxx/all/test_package/test_package.cpp b/recipes/msgpack-cxx/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..291dd422b88be --- /dev/null +++ b/recipes/msgpack-cxx/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include +#include + +#include + +int main() { + msgpack::object obj(123); + std::cout << obj << "\n"; + return 0; +} diff --git a/recipes/msgpack-cxx/config.yml b/recipes/msgpack-cxx/config.yml new file mode 100644 index 0000000000000..c71b61d3f47b2 --- /dev/null +++ b/recipes/msgpack-cxx/config.yml @@ -0,0 +1,11 @@ +versions: + "4.1.3": + folder: all + "4.1.2": + folder: all + "4.1.1": + folder: all + "4.1.0": + folder: all + "4.0.3": + folder: all diff --git a/recipes/msgpack/all/conanfile.py b/recipes/msgpack/all/conanfile.py index 270fe17cd8e89..c99fb76c55aa2 100644 --- a/recipes/msgpack/all/conanfile.py +++ b/recipes/msgpack/all/conanfile.py @@ -29,6 +29,7 @@ class MsgpackConan(ConanFile): "with_boost": False, "header_only": False } + deprecated = "msgpack-c or msgpack-cxx" _cmake = None diff --git a/recipes/msix/all/CMakeLists.txt b/recipes/msix/all/CMakeLists.txt new file mode 100644 index 0000000000000..c477e0c1e565e --- /dev/null +++ b/recipes/msix/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.0) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory("source_subfolder") diff --git a/recipes/msix/all/conandata.yml b/recipes/msix/all/conandata.yml new file mode 100644 index 0000000000000..ef22231170ffe --- /dev/null +++ b/recipes/msix/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "1.7": + url: "https://github.com/microsoft/msix-packaging/archive/refs/tags/v1.7.zip" + sha256: "23179d577d0b9d34e93374ae38284ab9f1247ff6cc9175851983fb114ab00087" +patches: + "1.7": + - base_path: "source_subfolder" + patch_file: "patches/1.7/cmake.patch" + - base_path: "source_subfolder" + patch_file: "patches/1.7/signaturevalidator.patch" diff --git a/recipes/msix/all/conanfile.py b/recipes/msix/all/conanfile.py new file mode 100644 index 0000000000000..0c62a718f8c29 --- /dev/null +++ b/recipes/msix/all/conanfile.py @@ -0,0 +1,157 @@ +from conans import CMake, ConanFile, tools +from conans.errors import ConanInvalidConfiguration + + +required_conan_version = ">=1.33.0" + + +class MsixConan(ConanFile): + name = "msix" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/microsoft/msix-packaging" + description = "An SDK for creating MSIX packages" + topics = ("msix", "sdk", "packaging", "conan-recipe") + + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "crypto_lib": ["crypt32", "openssl"], + "pack": [True, False], + "skip_bundles": [True, False], + "use_external_zlib": [True, False], + "use_validation_parser": [True, False], + "xml_parser": ["applexml", "javaxml", "msxml6", "xerces"] + } + default_options = { + "shared": False, + "fPIC": True, + "crypto_lib": "openssl", + "pack": False, + "skip_bundles": False, + "use_external_zlib": True, + "use_validation_parser": False, + "xml_parser": "msxml6" + } + + generators = "cmake" + exports_sources = "CMakeLists.txt", "patches/**" + + _cmake = None + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "15" + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + if self.settings.os == "Android": + self._cmake.definitions["AOSP"] = True + if self.settings.os == "Linux": + self._cmake.definitions["LINUX"] = True + if self.settings.os == "Macos": + self._cmake.definitions["MACOS"] = True + self._cmake.definitions["CRYPTO_LIB"] = self.options.crypto_lib + self._cmake.definitions["MSIX_PACK"] = self.options.pack + self._cmake.definitions["MSIX_SAMPLES"] = False + self._cmake.definitions["MSIX_TESTS"] = False + self._cmake.definitions["SKIP_BUNDLES"] = self.options.skip_bundles + self._cmake.definitions["USE_MSIX_SDK_ZLIB"] = self.options.use_external_zlib + self._cmake.definitions["USE_SHARED_ZLIB"] = self.options["zlib"].shared + self._cmake.definitions["USE_VALIDATION_PARSER"] = self.options.use_validation_parser + self._cmake.definitions["XML_PARSER"] = self.options.xml_parser + self._cmake.definitions["CALCULATE_VERSION"] = False + self._cmake.definitions["ENABLE_NUGET_PACKAGING"] = False + self._cmake.configure() + return self._cmake + + def _validate_compiler_settings(self): + compiler = self.settings.compiler + if compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "17") + + min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if not min_version: + self.output.warn("{} recipe lacks information about the {} compiler support.".format( + self.name, self.settings.compiler)) + elif tools.Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration("{} requires C++17 support. The current compiler {} {} does not support it.".format( + self.name, self.settings.compiler, self.settings.compiler.version)) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + self.options.crypto_lib = "crypt32" + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + if self.settings.os == "Linux" and not self.options.skip_bundles: + self.requires("icu/71.1") + if self.options.crypto_lib == "openssl": + self.requires("openssl/1.1.1q") + if self.options.use_external_zlib: + self.requires("zlib/1.2.12") + if self.options.xml_parser == "xerces": + self.requires("xerces-c/3.2.3") + + def validate(self): + if self.settings.os != "Android" and self.options.xml_parser == "javaxml": + raise ConanInvalidConfiguration("javaxml is supported only for Android") + if self.settings.os == "Linux" and self.settings.compiler != "clang": + raise ConanInvalidConfiguration("Only clang is supported on Linux") + if self.settings.os != "Macos" and self.options.xml_parser == "applexml": + raise ConanInvalidConfiguration("applexml is supported only for MacOS") + if self.settings.os != "Windows" and self.options.crypto_lib == "crypt32": + raise ConanInvalidConfiguration("crypt32 is supported only for Windows") + if self.settings.os != "Windows" and self.options.xml_parser == "msxml6": + raise ConanInvalidConfiguration("msxml6 is supported only for Windows") + if self.options.pack: + if self.settings.os == "Macos": + if not self.options.use_external_zlib: + raise ConanInvalidConfiguration("Using libCompression APIs and packaging features is not supported") + if self.options.xml_parser != "xerces": + raise ConanInvalidConfiguration("Xerces is the only supported parser for MacOS pack") + if not self.options.use_validation_parser: + raise ConanInvalidConfiguration("Packaging requires validation parser") + if (self.options.xml_parser == "xerces" and + self.options["xerces-c"].char_type != "char16_t"): + raise ConanInvalidConfiguration("Only char16_t is supported for xerces-c") + + self._validate_compiler_settings() + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + if self.settings.os == "Windows": + self.cpp_info.system_libs = ["runtimeobject"] + if self.settings.compiler == "Visual Studio": + self.cpp_info.system_libs.append("delayimp") + if self.options.crypto_lib == "crypt32": + self.cpp_info.system_libs.extend(["bcrypt", "crypt32", "wintrust"]) + if self.options.xml_parser == "msxml6": + self.cpp_info.system_libs.append("msxml6") diff --git a/recipes/msix/all/patches/1.7/cmake.patch b/recipes/msix/all/patches/1.7/cmake.patch new file mode 100644 index 0000000000000..b64f3d1cd79c0 --- /dev/null +++ b/recipes/msix/all/patches/1.7/cmake.patch @@ -0,0 +1,233 @@ + CMakeLists.txt | 18 +++++++----- + src/CMakeLists.txt | 1 - + src/makemsix/CMakeLists.txt | 3 ++ + src/msix/CMakeLists.txt | 67 ++++++++++++++++----------------------------- + 4 files changed, 37 insertions(+), 52 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index dc5908cd..b2e857a5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -21,11 +21,13 @@ if(POLICY CMP0077) + cmake_policy(SET CMP0077 NEW) + endif() + ++if(CALCULATE_VERSION) + # Default version is 0.0.0 + set(VERSION_MAJOR "0") + set(VERSION_MINOR "0") + set(VERSION_PATCH "0") + set(GIT_BRANCH_NAME "master") ++endif() + + # CMake useful variables + set(MSIX_PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) +@@ -35,6 +37,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") + ++if(CALCULATE_VERSION) + ## Git (and its revision) + find_package(Git) # QUIET) # if we don't find git or FindGit.cmake is not on the system we ignore it. + +@@ -77,15 +80,22 @@ if(GIT_FOUND) + else() + message("git not found.") + endif() ++endif() + ++if(CALCULATE_VERSION) + # Set the version number of your project here (format is MAJOR.MINOR.PATCHLEVEL - e.g. 1.0.0) + set(MSIX_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) + message(STATUS "MSIX Packaging SDK version ${MSIX_VERSION}") + message(STATUS "MSIX Packaging SDK branch name ${GIT_BRANCH_NAME}") + add_definitions(-DSDK_VERSION="${MSIX_VERSION}") ++else() ++message(STATUS "MSIX Packaging SDK version ${PROJECT_VERSION}") ++add_definitions(-DSDK_VERSION="${PROJECT_VERSION}") ++endif() + # Validates CMake options. + include(msix_options) + ++if(ENABLE_NUGET_PACKAGING) + # Configure Package.nuspec + if(WIN32) + set(MSIX_NUGET_NAME "Microsoft.MSIX.Packaging.Windows") +@@ -103,6 +113,7 @@ configure_file(${MSIX_PROJECT_ROOT}/Package.nuspec.cmakein ${MSIX_BINARY_ROOT}/P + configure_file(${MSIX_PROJECT_ROOT}/Microsoft.MSIX.Packaging.targets ${MSIX_BINARY_ROOT}/build/native/${MSIX_NUGET_NAME}.targets) + message(STATUS "Package.Nuspec created") + message(STATUS "--------------------------------") ++endif() + + # Configure license txt + configure_file(${MSIX_PROJECT_ROOT}/LICENSE ${MSIX_BINARY_ROOT}/build/LICENSE) +@@ -170,9 +181,6 @@ if((MACOS) OR (IOS)) + message(FATAL_ERROR "Unsupported iOS version: ${IOS_DEPLOYMENT_TARGET}, this project requires at least iOS version 10.0") + endif() + endif() +-elseif(AOSP OR LINUX) +- # Static libraries must be position independent to be linked with a shared object. +- set(CMAKE_POSITION_INDEPENDENT_CODE ON) + endif() + + # Mac needed variables +@@ -183,10 +191,6 @@ set(CMAKE_MACOSX_RPATH ON) + #set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + #set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +-add_subdirectory(lib) +-message(STATUS "libs processed") + add_subdirectory(src) + message(STATUS "src processed") +-add_subdirectory(sample) +-message(STATUS "sample processed") + message(STATUS "DONE!") +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index a2655a7b..5d224b64 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -6,4 +6,3 @@ cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR) + + add_subdirectory(msix) + add_subdirectory(makemsix) +-add_subdirectory(test) +diff --git a/src/makemsix/CMakeLists.txt b/src/makemsix/CMakeLists.txt +index 92b082e6..ebae9789 100644 +--- a/src/makemsix/CMakeLists.txt ++++ b/src/makemsix/CMakeLists.txt +@@ -24,3 +24,6 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${MSIX_BINARY_ROOT}/src/msix) + + add_dependencies(${PROJECT_NAME} msix) + target_link_libraries(${PROJECT_NAME} msix) ++ ++# define installing rules for target files ++install(TARGETS ${PROJECT_NAME}) +diff --git a/src/msix/CMakeLists.txt b/src/msix/CMakeLists.txt +index 75d3afdf..e1fb2984 100644 +--- a/src/msix/CMakeLists.txt ++++ b/src/msix/CMakeLists.txt +@@ -6,6 +6,11 @@ cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR) + + project(msix) + ++# Define the library ++add_library(${PROJECT_NAME} ++ msix.cpp ++) ++ + # Handle exports and flags we need to set + list(APPEND MSIX_UNPACK_EXPORTS + "UnpackPackage" +@@ -144,7 +149,7 @@ if(NOT SKIP_BUNDLES) + if (WIN32) + list(APPEND MsixSrc PAL/Applicability/Win32/Applicability.cpp) + elseif(LINUX) +- find_package(ICU REQUIRED COMPONENTS uc) ++ target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::icu) + list(APPEND MsixSrc PAL/Applicability/Linux/Applicability.cpp) + elseif(AOSP) + list(APPEND MsixSrc PAL/Applicability/AOSP/Applicability.cpp) +@@ -195,14 +200,16 @@ if(CRYPTO_LIB MATCHES crypt32) + PAL/Signature/Win32/SignatureValidator.cpp + ) + elseif(CRYPTO_LIB MATCHES openssl) +- if(OpenSSL_FOUND) +- list(APPEND MsixSrc +- PAL/Crypto/OpenSSL/Crypto.cpp +- PAL/Signature/OpenSSL/SignatureValidator.cpp +- ) ++ list(APPEND MsixSrc ++ PAL/Crypto/OpenSSL/Crypto.cpp ++ PAL/Signature/OpenSSL/SignatureValidator.cpp ++ ) ++ if((IOS) OR (MACOS)) ++ target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::openssl -Wl,-dead_strip) ++ elseif(NOT MSVC) ++ target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::openssl -Wl,--gc-sections) + else() +- # ... and were done here... :/ +- message(FATAL_ERROR "OpenSSL NOT FOUND!") ++ target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::openssl) + endif() + endif() + +@@ -220,14 +227,7 @@ foreach(FILE ${MsixSrc}) + message(STATUS "\t${FILE}") + endforeach() + +-# Define the library +-add_library(${PROJECT_NAME} SHARED +- msix.cpp +- ${MsixSrc} +-) +- +-# Adding dependency to the third party libs directory +-add_dependencies(${PROJECT_NAME} LIBS) ++target_sources(${PROJECT_NAME} PRIVATE ${MsixSrc}) + + # Copy out public headers to /src/unpack + configure_file(../inc/MSIXWindows.hpp ${CMAKE_CURRENT_BINARY_DIR}/MSIXWindows.hpp ) +@@ -260,7 +260,7 @@ if(WIN32) + "/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll") + string(REPLACE ";" " " DELAYFLAGS "${DELAYFLAGS}") + set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS "${DELAYFLAGS} /LTCG") +- set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " /DEF:windowsexports.def") ++ set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " /DEF:${CMAKE_CURRENT_BINARY_DIR}/windowsexports.def") + if(USE_STATIC_MSVC) + if(CMAKE_BUILD_TYPE MATCHES Debug) + set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " /NODEFAULTLIB:MSVCRTD") +@@ -285,29 +285,20 @@ if(((IOS) OR (MACOS)) AND (NOT USE_MSIX_SDK_ZLIB)) + target_link_libraries(${PROJECT_NAME} PRIVATE libcompression.dylib) + elseif((AOSP) AND (NOT USE_MSIX_SDK_ZLIB)) + # for AOSP, use the libz.so from the android ndk. +- find_package(ZLIB REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE -lz) +-else() # WIN32 or USE_MSIX_SDK_ZLIB +- target_include_directories(${PROJECT_NAME} PRIVATE +- ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/zlib +- ${MSIX_PROJECT_ROOT}/lib/zlib +- ) ++else() + if(USE_SHARED_ZLIB) + message(STATUS "MSIX takes a dynamic dependency on zlib") +- target_link_libraries(${PROJECT_NAME} PRIVATE zlib) ++ target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::zlib) + else() + message(STATUS "MSIX takes a static dependency on zlib") +- target_link_libraries(${PROJECT_NAME} PRIVATE zlibstatic) ++ target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::zlib) + endif() + endif() + + # Parser + if(XML_PARSER MATCHES xerces) +- target_include_directories(${PROJECT_NAME} PRIVATE +- ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/xerces/src +- ${MSIX_PROJECT_ROOT}/lib/xerces/src +- ) +- target_link_libraries(${PROJECT_NAME} PRIVATE xerces-c) ++ target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::xerces-c) + endif() + + if(XML_PARSER MATCHES applexml) +@@ -363,18 +354,6 @@ endif() + if((IOS) OR (MACOS)) + target_link_libraries(${PROJECT_NAME} PRIVATE ${COREFOUNDATION_LIBRARY} ${FOUNDATION_LIBRARY}) + endif() +-if(LINUX) +- target_link_libraries(${PROJECT_NAME} PRIVATE ${ICU_LIBRARIES}) +-endif() + +-if(OpenSSL_FOUND) +- # include the libraries needed to use OpenSSL +- target_include_directories(${PROJECT_NAME} PRIVATE ${OpenSSL_INCLUDE_PATH}) +- if((IOS) OR (MACOS)) +- target_link_libraries(${PROJECT_NAME} PRIVATE crypto -Wl,-dead_strip) +- elseif(NOT MSVC) +- target_link_libraries(${PROJECT_NAME} PRIVATE crypto -Wl,--gc-sections) +- else() +- target_link_libraries(${PROJECT_NAME} PRIVATE crypto) +- endif() +-endif() ++# define installing rules for target files ++install(TARGETS ${PROJECT_NAME}) diff --git a/recipes/msix/all/patches/1.7/signaturevalidator.patch b/recipes/msix/all/patches/1.7/signaturevalidator.patch new file mode 100644 index 0000000000000..bc8cdf9e699db --- /dev/null +++ b/recipes/msix/all/patches/1.7/signaturevalidator.patch @@ -0,0 +1,39 @@ +diff --git a/src/msix/PAL/Signature/OpenSSL/SignatureValidator.cpp b/src/msix/PAL/Signature/OpenSSL/SignatureValidator.cpp +index 1cc34b20..ccbf68dc 100644 +--- a/src/msix/PAL/Signature/OpenSSL/SignatureValidator.cpp ++++ b/src/msix/PAL/Signature/OpenSSL/SignatureValidator.cpp +@@ -94,11 +94,10 @@ namespace MSIX + STACK_OF(X509) *certStack = p7.get()->d.sign->cert; + for (int i = 0; i < sk_X509_num(certStack); i++) + { +- X509* cert = sk_X509_value(certStack, i); +- STACK_OF(X509_EXTENSION) *exts = cert->cert_info->extensions; +- for (int i = 0; i < sk_X509_EXTENSION_num(exts); i++) ++ X509* cert = sk_X509_value(certStack, i); ++ for (int i = 0; i < X509_get_ext_count(cert); i++) + { +- X509_EXTENSION *ext = sk_X509_EXTENSION_value(exts, i); ++ X509_EXTENSION *ext = X509_get_ext(cert, i); + if (ext) + { + if (X509_EXTENSION_get_object(ext)) +@@ -106,7 +105,7 @@ namespace MSIX + unique_BIO extbio(BIO_new(BIO_s_mem())); + if (!X509V3_EXT_print(extbio.get(), ext, 0, 0)) + { +- M_ASN1_OCTET_STRING_print(extbio.get(), ext->value); ++ M_ASN1_OCTET_STRING_print(extbio.get(), X509_EXTENSION_get_data(ext)); + } + // null terminate the string. + BIO_write(extbio.get(), "", 1); +@@ -207,8 +206,8 @@ namespace MSIX + // If we encounter an expired cert error (which is fine) or a critical extension (most MS + // certs contain MS-specific extensions that OpenSSL doesn't know how to evaluate), + // just return success +- if (!ok && (ctx->error == X509_V_ERR_CERT_HAS_EXPIRED || +- ctx->error == X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION)) ++ if (!ok && (X509_STORE_CTX_get_error(ctx) == X509_V_ERR_CERT_HAS_EXPIRED || ++ X509_STORE_CTX_get_error(ctx) == X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION)) + { + ok = static_cast(true); + } diff --git a/recipes/msix/all/test_package/CMakeLists.txt b/recipes/msix/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e28b2e2b66dd9 --- /dev/null +++ b/recipes/msix/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_executable(${PROJECT_NAME} example.cpp) + +conan_target_link_libraries(${PROJECT_NAME}) diff --git a/recipes/msix/all/test_package/conanfile.py b/recipes/msix/all/test_package/conanfile.py new file mode 100644 index 0000000000000..bee328a3e1aa7 --- /dev/null +++ b/recipes/msix/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class MsixTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/msix/all/test_package/example.cpp b/recipes/msix/all/test_package/example.cpp new file mode 100644 index 0000000000000..292160c8862d6 --- /dev/null +++ b/recipes/msix/all/test_package/example.cpp @@ -0,0 +1,26 @@ +#include + +LPVOID STDMETHODCALLTYPE MyAllocate(SIZE_T cb) { + return std::malloc(cb); +} + +void STDMETHODCALLTYPE MyFree(LPVOID pv) { + std::free(pv); +} + +int main() { + IAppxFactory* appxFactory; + + HRESULT creationResult = CoCreateAppxFactoryWithHeap( + MyAllocate, + MyFree, + MSIX_VALIDATION_OPTION::MSIX_VALIDATION_OPTION_FULL, + &appxFactory + ); + + if (FAILED(creationResult)) { + return creationResult; + } + + return 0; +} diff --git a/recipes/msix/config.yml b/recipes/msix/config.yml new file mode 100644 index 0000000000000..a03e932e1cf87 --- /dev/null +++ b/recipes/msix/config.yml @@ -0,0 +1,3 @@ +versions: + "1.7": + folder: "all" diff --git a/recipes/msys2/all/conandata.yml b/recipes/msys2/all/conandata.yml index 202279f04e838..01aa597548f23 100644 --- a/recipes/msys2/all/conandata.yml +++ b/recipes/msys2/all/conandata.yml @@ -1,7 +1,8 @@ sources: "cci.latest": url: [ - "http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20210419.tar.xz", - "https://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-base-x86_64-20210419.tar.xz", + "https://github.com/msys2/msys2-installer/releases/download/2022-01-18/msys2-base-x86_64-20220118.tar.xz", + "http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20220118.tar.xz", + "https://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-base-x86_64-20220118.tar.xz", ] - sha256: "3d014d6f5ae519ea5de5b586bff505309c1f42fd8148996d63ba132b24146c85" + sha256: "2ec6fe9c3e01ecba10b9ffa708ea13bf1f8c9739e5ce9da853b77f1f3e270034" diff --git a/recipes/msys2/all/conanfile.py b/recipes/msys2/all/conanfile.py index 58633ffa0e8a8..335f7da9b6296 100644 --- a/recipes/msys2/all/conanfile.py +++ b/recipes/msys2/all/conanfile.py @@ -1,18 +1,22 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration, ConanException +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration, ConanException +from conan.tools.files import chdir, get, replace_in_file import fnmatch import os import shutil import subprocess +import errno try: import ctypes - from ctypes import wintypes except ImportError: pass except ValueError: pass +required_conan_version = ">=1.47.0" + + class lock: def __init__(self): self.handle = ctypes.windll.kernel32.CreateMutexA(None, 0, "Global\\ConanMSYS2".encode()) @@ -41,31 +45,39 @@ class MSYS2Conan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.msys2.org" license = "MSYS license" - topics = ("conan", "msys", "unix", "subsystem") - short_paths = True + topics = ("msys", "unix", "subsystem") + + settings = "os", "arch", "compiler", "build_type" # "exclude_files" "packages" "additional_packages" values are a comma separated list options = { - "exclude_files": "ANY", - "packages": "ANY", - "additional_packages": "ANY" + "exclude_files": ["ANY"], + "packages": ["ANY"], + "additional_packages": ["ANY"], } default_options = { "exclude_files": "*/link.exe", "packages": "base-devel,binutils,gcc", - "additional_packages": None + "additional_packages": None, } - settings = "os", "arch" + short_paths = True + + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type def validate(self): - if self.settings.os != "Windows": + if self.info.settings.os != "Windows": raise ConanInvalidConfiguration("Only Windows supported") - if self.settings.arch != "x86_64": + if self.info.settings.arch != "x86_64": raise ConanInvalidConfiguration("Only Windows x64 supported") + def source(self): + # sources are different per configuration - do download in build + pass def _update_pacman(self): - with tools.chdir(os.path.join(self._msys_dir, "usr", "bin")): + with chdir(self, os.path.join(self._msys_dir, "usr", "bin")): try: self._kill_pacman() @@ -90,14 +102,16 @@ def _kill_pacman(self): out = subprocess.PIPE err = subprocess.STDOUT else: - out = file(os.devnull, 'w') + out = open(os.devnull, 'w') err = subprocess.PIPE if os.path.exists(taskkill_exe): - taskkill_cmds = [taskkill_exe + " /f /t /im pacman.exe", - taskkill_exe + " /f /im gpg-agent.exe", - taskkill_exe + " /f /im dirmngr.exe", - taskkill_exe + ' /fi "MODULES eq msys-2.0.dll"'] + taskkill_cmds = [ + f"{taskkill_exe} /f /t /im pacman.exe", + f"{taskkill_exe} /f /im gpg-agent.exe", + f"{taskkill_exe} /f /im dirmngr.exe", + f'{taskkill_exe} /fi "MODULES eq msys-2.0.dll"', + ] for taskkill_cmd in taskkill_cmds: try: proc = subprocess.Popen(taskkill_cmd, stdout=out, stderr=err, bufsize=1) @@ -111,13 +125,9 @@ def _msys_dir(self): subdir = "msys64" return os.path.join(self.package_folder, "bin", subdir) - def source(self): - # sources are different per configuration - do download in build - pass - def build(self): - tools.get(**self.conan_data["sources"][self.version], - destination=os.path.join(self.package_folder, "bin")) + get(self, **self.conan_data["sources"][self.version], + destination=os.path.join(self.package_folder, "bin")) with lock(): self._do_build() @@ -130,11 +140,11 @@ def _do_build(self): self._update_pacman() - with tools.chdir(os.path.join(self._msys_dir, "usr", "bin")): + with chdir(self, os.path.join(self._msys_dir, "usr", "bin")): for package in packages: - self.run('bash -l -c "pacman -S %s --noconfirm"' % package) + self.run(f'bash -l -c "pacman -S {package} --noconfirm"') for package in ['pkgconf']: - self.run('bash -l -c "pacman -Rs $(pacman -Qsq %s) --noconfirm"' % package) + self.run(f'bash -l -c "pacman -Rs -d -d $(pacman -Qsq {package}) --noconfirm"') self._kill_pacman() @@ -148,7 +158,7 @@ def _do_build(self): os.utime(tmp_name, None) # Prepend the PKG_CONFIG_PATH environment variable with an eventual PKG_CONFIG_PATH environment variable - tools.replace_in_file(os.path.join(self._msys_dir, "etc", "profile"), + replace_in_file(self, os.path.join(self._msys_dir, "etc", "profile"), 'PKG_CONFIG_PATH="', 'PKG_CONFIG_PATH="$PKG_CONFIG_PATH:') def package(self): @@ -167,15 +177,24 @@ def package(self): def package_info(self): self.cpp_info.libdirs = [] + self.cpp_info.includedirs = [] + self.cpp_info.resdirs = [] msys_root = self._msys_dir msys_bin = os.path.join(msys_root, "usr", "bin") + self.cpp_info.bindirs.append(msys_bin) - self.output.info("Creating MSYS_ROOT env var : %s" % msys_root) - self.env_info.MSYS_ROOT = msys_root + self.output.info(f"Creating MSYS_ROOT env var : {msys_root}") + self.buildenv_info.define_path("MSYS_ROOT", msys_root) - self.output.info("Creating MSYS_BIN env var : %s" % msys_bin) - self.env_info.MSYS_BIN = msys_bin + self.output.info(f"Creating MSYS_BIN env var : {msys_bin}") + self.buildenv_info.define_path("MSYS_BIN", msys_bin) + + self.conf_info.define("tools.microsoft.bash:subsystem", "msys2") + self.conf_info.define("tools.microsoft.bash:path", os.path.join(msys_bin, "bash.exe")) - self.output.info("Appending PATH env var with : " + msys_bin) + # conan v1 specific stuff + self.env_info.MSYS_ROOT = msys_root + self.env_info.MSYS_BIN = msys_bin + self.output.info(f"Appending PATH env var with : {msys_bin}") self.env_info.path.append(msys_bin) diff --git a/recipes/msys2/all/test_package/conanfile.py b/recipes/msys2/all/test_package/conanfile.py index eb3a4a0152e23..93ee00629e591 100644 --- a/recipes/msys2/all/test_package/conanfile.py +++ b/recipes/msys2/all/test_package/conanfile.py @@ -1,27 +1,35 @@ -from conans import ConanFile, tools -from conans.errors import ConanException +from conan import ConanFile +from conan.tools.env import Environment from io import StringIO -class TestPackage(ConanFile): - + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + @property + def _secret_value(self): + return "SECRET_CONAN_PKG_VARIABLE" + + def generate(self): + env = Environment() + env.define("PKG_CONFIG_PATH", self._secret_value) + envvars = env.vars(self) + envvars.save_script("conanbuildenv_pkg_config_path") + def build(self): pass # nothing to do, skip hook warning def test(self): - bash = tools.which("bash.exe") - - if bash: - self.output.info("using bash.exe from: " + bash) - else: - raise ConanException("No instance of bash.exe could be found on %PATH%") - self.run('bash.exe -c ^"make --version^"') self.run('bash.exe -c ^"! test -f /bin/link^"') self.run('bash.exe -c ^"! test -f /usr/bin/link^"') - secret_value = "SECRET_CONAN_PKG_VARIABLE" - with tools.environment_append({"PKG_CONFIG_PATH": secret_value}): - output = StringIO() - self.run('bash.exe -c "echo $PKG_CONFIG_PATH"', output=output) - print(output.getvalue()) - assert secret_value in output.getvalue() + output = StringIO() + self.run('bash.exe -c "echo $PKG_CONFIG_PATH"', output=output) + print(output.getvalue()) + assert self._secret_value in output.getvalue() diff --git a/recipes/msys2/all/test_v1_package/conanfile.py b/recipes/msys2/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..9278b74eeb27b --- /dev/null +++ b/recipes/msys2/all/test_v1_package/conanfile.py @@ -0,0 +1,29 @@ +from conans import ConanFile, tools +from conans.errors import ConanException +from io import StringIO + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def build(self): + pass # nothing to do, skip hook warning + + def test(self): + bash = tools.which("bash.exe") + + if bash: + self.output.info("using bash.exe from: " + bash) + else: + raise ConanException("No instance of bash.exe could be found on %PATH%") + + self.run('bash.exe -c ^"make --version^"') + self.run('bash.exe -c ^"! test -f /bin/link^"') + self.run('bash.exe -c ^"! test -f /usr/bin/link^"') + + secret_value = "SECRET_CONAN_PKG_VARIABLE" + with tools.environment_append({"PKG_CONFIG_PATH": secret_value}): + output = StringIO() + self.run('bash.exe -c "echo $PKG_CONFIG_PATH"', output=output) + print(output.getvalue()) + assert secret_value in output.getvalue() diff --git a/recipes/mujs/all/CMakeLists.txt b/recipes/mujs/all/CMakeLists.txt new file mode 100644 index 0000000000000..8ee1eff93fdb3 --- /dev/null +++ b/recipes/mujs/all/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.4) +project(mujs LANGUAGES C) + +file(GLOB MUJS_SRC ${MUJS_SRC_DIR}/js*.c ${MUJS_SRC_DIR}/utf*.c ${MUJS_SRC_DIR}/regexp.c) + +add_library(${PROJECT_NAME} ${MUJS_SRC}) +set_property(TARGET ${PROJECT_NAME} PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + +find_library(M_LIB m) +if(M_LIB) + target_link_libraries(${PROJECT_NAME} PRIVATE ${M_LIB}) +endif() + +include(GNUInstallDirs) +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install(FILES ${MUJS_SRC_DIR}/mujs.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/mujs/all/conandata.yml b/recipes/mujs/all/conandata.yml new file mode 100644 index 0000000000000..8b8c95eb04cf4 --- /dev/null +++ b/recipes/mujs/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.1.2": + url: "https://mujs.com/downloads/mujs-1.1.2.tar.xz" + sha256: "719e882bb7d98640efa163381e9b68ef1ce35c87a422e2aa4190c9e40225875d" diff --git a/recipes/mujs/all/conanfile.py b/recipes/mujs/all/conanfile.py new file mode 100644 index 0000000000000..b9be736a9eeb6 --- /dev/null +++ b/recipes/mujs/all/conanfile.py @@ -0,0 +1,72 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os + +required_conan_version = ">=1.46.0" + + +class MujsConan(ConanFile): + name = "mujs" + description = "MuJS is a lightweight Javascript interpreter designed for " \ + "embedding in other software to extend them with scripting capabilities." + license = "ISC" + topics = ("mujs", "interpreter", "javascript") + homepage = "https://mujs.com" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + exports_sources = "CMakeLists.txt" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MUJS_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "mujs") + self.cpp_info.libs = ["mujs"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/mujs/all/test_package/CMakeLists.txt b/recipes/mujs/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d5111bdead218 --- /dev/null +++ b/recipes/mujs/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(mujs REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE mujs::mujs) diff --git a/recipes/mujs/all/test_package/conanfile.py b/recipes/mujs/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/mujs/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mujs/all/test_package/test_package.c b/recipes/mujs/all/test_package/test_package.c new file mode 100644 index 0000000000000..459444b482f7f --- /dev/null +++ b/recipes/mujs/all/test_package/test_package.c @@ -0,0 +1,24 @@ +#include + +#include + +static void hello(js_State *J) +{ + const char *name = js_tostring(J, 1); + printf("Hello, %s!\n", name); + js_pushundefined(J); +} + +int main(void) +{ + js_State *J = js_newstate(NULL, NULL, JS_STRICT); + + js_newcfunction(J, hello, "hello", 1); + js_setglobal(J, "hello"); + + js_dostring(J, "hello('world');"); + + js_freestate(J); + + return 0; +} diff --git a/recipes/mujs/all/test_v1_package/CMakeLists.txt b/recipes/mujs/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9b3aa7909e4a0 --- /dev/null +++ b/recipes/mujs/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(mujs REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE mujs::mujs) diff --git a/recipes/mujs/all/test_v1_package/conanfile.py b/recipes/mujs/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mujs/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mujs/config.yml b/recipes/mujs/config.yml new file mode 100644 index 0000000000000..8d13aefb6b4fb --- /dev/null +++ b/recipes/mujs/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.2": + folder: all diff --git a/recipes/muparser/all/CMakeLists.txt b/recipes/muparser/all/CMakeLists.txt deleted file mode 100644 index a69305eb3971f..0000000000000 --- a/recipes/muparser/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/muparser/all/conandata.yml b/recipes/muparser/all/conandata.yml index 1f691e6dfbdf4..cd86d2cd3c232 100644 --- a/recipes/muparser/all/conandata.yml +++ b/recipes/muparser/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "2.3.4": + url: "https://github.com/beltoforion/muparser/archive/refs/tags/v2.3.4.tar.gz" + sha256: "0c3fa54a3ebf36dda0ed3e7cd5451c964afbb15102bdbcba08aafb359a290121" "2.3.2": url: "https://github.com/beltoforion/muparser/archive/v2.3.2.tar.gz" sha256: "b35fc84e3667d432e3414c8667d5764dfa450ed24a99eeef7ee3f6647d44f301" diff --git a/recipes/muparser/all/conanfile.py b/recipes/muparser/all/conanfile.py index 917968db52c18..e0e300577d42b 100644 --- a/recipes/muparser/all/conanfile.py +++ b/recipes/muparser/all/conanfile.py @@ -1,5 +1,12 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.scm import Version +from conans import tools as tools_legacy import os -from conans import ConanFile, CMake, tools + +required_conan_version = ">=1.53.0" class MuParserConan(ConanFile): @@ -9,9 +16,8 @@ class MuParserConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" topics = ("math", "parser",) description = "Fast Math Parser Library" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" - settings = "os", "compiler", "build_type", "arch" + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -23,59 +29,55 @@ class MuParserConan(ConanFile): "with_openmp": False, } - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): if self.options.shared: - del self.options.fPIC - if self.options.with_openmp: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + if self.info.options.with_openmp: self.output.warn("Conan package for OpenMP is not available, this package will be used from system.") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "{}-{}".format(self.name, self.version) - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ENABLE_SAMPLES"] = False - self._cmake.definitions["ENABLE_OPENMP"] = self.options.with_openmp - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_SAMPLES"] = False + tc.variables["ENABLE_OPENMP"] = self.options.with_openmp + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("License.txt", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + license_file = "License.txt" if Version(self.version) < "2.3.3" else "LICENSE" + copy(self, license_file, src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "muparser" - self.cpp_info.names["cmake_find_package_multi"] = "muparser" - self.cpp_info.names["pkg_config"] = "muparser" + self.cpp_info.set_property("cmake_file_name", "muparser") + self.cpp_info.set_property("cmake_target_name", "muparser::muparser") + self.cpp_info.set_property("pkg_config_name", "muparser") self.cpp_info.libs = ["muparser"] if not self.options.shared: self.cpp_info.defines = ["MUPARSER_STATIC=1"] - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.system_libs.append(tools.stdcpp_library(self)) + libcxx = tools_legacy.stdcpp_library(self) + if libcxx: + self.cpp_info.system_libs.append(libcxx) diff --git a/recipes/muparser/all/test_package/CMakeLists.txt b/recipes/muparser/all/test_package/CMakeLists.txt index 7c11c72e38970..9cc92e84977a5 100644 --- a/recipes/muparser/all/test_package/CMakeLists.txt +++ b/recipes/muparser/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(muparser CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} muparser::muparser) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE muparser::muparser) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/muparser/all/test_package/conanfile.py b/recipes/muparser/all/test_package/conanfile.py index 7e2dfe859bb27..0a6bc68712d90 100644 --- a/recipes/muparser/all/test_package/conanfile.py +++ b/recipes/muparser/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/muparser/all/test_v1_package/CMakeLists.txt b/recipes/muparser/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/muparser/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/muparser/all/test_v1_package/conanfile.py b/recipes/muparser/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/muparser/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/muparser/config.yml b/recipes/muparser/config.yml index aee8de619ec30..d7f66fca815a8 100644 --- a/recipes/muparser/config.yml +++ b/recipes/muparser/config.yml @@ -1,3 +1,5 @@ versions: + "2.3.4": + folder: all "2.3.2": folder: all diff --git a/recipes/muparserx/all/CMakeLists.txt b/recipes/muparserx/all/CMakeLists.txt deleted file mode 100644 index e4e575f4e6b8f..0000000000000 --- a/recipes/muparserx/all/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") - diff --git a/recipes/muparserx/all/conandata.yml b/recipes/muparserx/all/conandata.yml index c44bf79ffc14b..9f14a4951a1b8 100644 --- a/recipes/muparserx/all/conandata.yml +++ b/recipes/muparserx/all/conandata.yml @@ -1,5 +1,4 @@ sources: "4.0.8": - url: https://github.com/beltoforion/muparserx/archive/v4.0.8.tar.gz - sha256: 5913e0a4ca29a097baad1b78a4674963bc7a06e39ff63df3c73fbad6fadb34e1 - + url: "https://github.com/beltoforion/muparserx/archive/v4.0.8.tar.gz" + sha256: "5913e0a4ca29a097baad1b78a4674963bc7a06e39ff63df3c73fbad6fadb34e1" diff --git a/recipes/muparserx/all/conanfile.py b/recipes/muparserx/all/conanfile.py index 38f85bfdbf6da..565601842d1b8 100644 --- a/recipes/muparserx/all/conanfile.py +++ b/recipes/muparserx/all/conanfile.py @@ -1,62 +1,77 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file, rmdir import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.53.0" + class MuparserxConan(ConanFile): name = "muparserx" description = "A C++ Library for Parsing Expressions with Strings, Complex Numbers, Vectors, Matrices and more" license = "BSD-2-Clause" - topics = ("conan", "muparserx", "math", "parser") + topics = ("math", "parser") homepage = "https://beltoforion.de/article.php?a=muparserx" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], - "fPIC": [True, False]} - default_options = {"shared": False, - "fPIC": True} - exports_sources = "CMakeLists.txt" - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("Muparserx does not support windows dll library!") + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_EXAMPLES"] = False + # Export symbols for msvc shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + # Relocatable shared libs on macOS + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() + + def _patch_sources(self): + replace_in_file( + self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set_property(TARGET muparserx PROPERTY POSITION_INDEPENDENT_CODE TRUE)", + "", + ) def build(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), "set_property(TARGET muparserx PROPERTY POSITION_INDEPENDENT_CODE TRUE)", "") - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="License.txt", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "License.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "cmake")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) - if self.settings.os == "Linux": + self.cpp_info.set_property("cmake_file_name", "muparserx") + self.cpp_info.set_property("pkg_config_name", "muparserx") + self.cpp_info.libs = ["muparserx"] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] diff --git a/recipes/muparserx/all/test_package/CMakeLists.txt b/recipes/muparserx/all/test_package/CMakeLists.txt index 33adbf4def465..5e16107e1d831 100644 --- a/recipes/muparserx/all/test_package/CMakeLists.txt +++ b/recipes/muparserx/all/test_package/CMakeLists.txt @@ -1,10 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(PackageTest CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -add_executable(test_package test_package.cpp) -target_link_libraries(test_package ${CONAN_LIBS}) -set_target_properties(test_package PROPERTIES CXX_STANDARD 11) +find_package(muparserx REQUIRED CONFIG) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE muparserx::muparserx) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/muparserx/all/test_package/conanfile.py b/recipes/muparserx/all/test_package/conanfile.py index 7c6dc51a06bcb..0a6bc68712d90 100644 --- a/recipes/muparserx/all/test_package/conanfile.py +++ b/recipes/muparserx/all/test_package/conanfile.py @@ -1,10 +1,19 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools -class MuparserxTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/muparserx/all/test_v1_package/CMakeLists.txt b/recipes/muparserx/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/muparserx/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/muparserx/all/test_v1_package/conanfile.py b/recipes/muparserx/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/muparserx/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/muparserx/config.yml b/recipes/muparserx/config.yml index 2b106ffcc80aa..5bcadc3524910 100644 --- a/recipes/muparserx/config.yml +++ b/recipes/muparserx/config.yml @@ -1,5 +1,3 @@ ---- versions: "4.0.8": folder: all - diff --git a/recipes/mysql-connector-c/all/conandata.yml b/recipes/mysql-connector-c/all/conandata.yml index d2188137e64a2..41e3b18a983f4 100644 --- a/recipes/mysql-connector-c/all/conandata.yml +++ b/recipes/mysql-connector-c/all/conandata.yml @@ -10,3 +10,5 @@ patches: base_path: "source_subfolder" - patch_file: "patches/003-cmake-install-standard-locations.patch" base_path: "source_subfolder" + - patch_file: "patches/004-cmake-install-typo.patch" + base_path: "source_subfolder" diff --git a/recipes/mysql-connector-c/all/conanfile.py b/recipes/mysql-connector-c/all/conanfile.py index bd749747da9c0..6d7ea21e58004 100644 --- a/recipes/mysql-connector-c/all/conanfile.py +++ b/recipes/mysql-connector-c/all/conanfile.py @@ -1,13 +1,13 @@ from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration import os -import glob class MysqlConnectorCConan(ConanFile): name = "mysql-connector-c" url = "https://github.com/conan-io/conan-center-index" description = "A MySQL client library for C development." - topics = ("conan", "mysql", "sql", "connector", "database") + topics = ("mysql", "sql", "connector", "database") homepage = "https://dev.mysql.com/downloads/connector/c/" license = "GPL-2.0" exports_sources = ["CMakeLists.txt", "patches/*.patch"] @@ -15,6 +15,8 @@ class MysqlConnectorCConan(ConanFile): settings = "os", "arch", "compiler", "build_type" options = {"shared": [True, False], "with_ssl": [True, False], "with_zlib": [True, False]} default_options = {'shared': False, 'with_ssl': True, 'with_zlib': True} + + deprecated = "libmysqlclient" _cmake = None @@ -29,10 +31,13 @@ def requirements(self): if self.options.with_zlib: self.requires("zlib/1.2.11") + def validate(self): + if hasattr(self, "settings_build") and tools.cross_building(self, skip_x64_x86=True): + raise ConanInvalidConfiguration("Cross compilation not yet supported by the recipe. contributions are welcome.") + def source(self): - archive_name = self.name + "-" + self.version + "-src" - tools.get(**self.conan_data["sources"][self.version]) - os.rename(archive_name, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) def _configure_cmake(self): if self._cmake: @@ -61,8 +66,8 @@ def _patch_sources(self): sources_cmake = os.path.join(self._source_subfolder, "CMakeLists.txt") sources_cmake_orig = os.path.join(self._source_subfolder, "CMakeListsOriginal.txt") - os.rename(sources_cmake, sources_cmake_orig) - os.rename("CMakeLists.txt", sources_cmake) + tools.rename(sources_cmake, sources_cmake_orig) + tools.rename("CMakeLists.txt", sources_cmake) for patch in self.conan_data["patches"][self.version]: tools.patch(**patch) @@ -75,15 +80,11 @@ def build(self): def package(self): cmake = self._configure_cmake() cmake.install() - os.mkdir(os.path.join(self.package_folder, "licenses")) - os.rename(os.path.join(self.package_folder, "COPYING"), os.path.join(self.package_folder, "licenses", "COPYING")) - os.rename(os.path.join(self.package_folder, "COPYING-debug"), os.path.join(self.package_folder, "licenses", "COPYING-debug")) - os.remove(os.path.join(self.package_folder, "README")) - os.remove(os.path.join(self.package_folder, "README-debug")) - for f in glob.glob(os.path.join(self.package_folder, "bin", "*.pdb")): - os.remove(f) - for f in glob.glob(os.path.join(self.package_folder, "lib", "*.pdb")): - os.remove(f) + tools.mkdir(os.path.join(self.package_folder, "licenses")) + tools.rename(os.path.join(self.package_folder, "COPYING"), os.path.join(self.package_folder, "licenses", "COPYING")) + tools.rename(os.path.join(self.package_folder, "COPYING-debug"), os.path.join(self.package_folder, "licenses", "COPYING-debug")) + tools.remove_files_by_mask(self.package_folder, "README*") + tools.remove_files_by_mask(self.package_folder, "*.pdb") tools.rmdir(os.path.join(self.package_folder, "docs")) def package_info(self): @@ -92,5 +93,5 @@ def package_info(self): stdcpp_library = tools.stdcpp_library(self) if stdcpp_library: self.cpp_info.system_libs.append(stdcpp_library) - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append('m') diff --git a/recipes/mysql-connector-c/all/patches/004-cmake-install-typo.patch b/recipes/mysql-connector-c/all/patches/004-cmake-install-typo.patch new file mode 100644 index 0000000000000..35d2bee366601 --- /dev/null +++ b/recipes/mysql-connector-c/all/patches/004-cmake-install-typo.patch @@ -0,0 +1,15 @@ +--- cmake/install_macros.cmake ++++ cmake/install_macros.cmake +@@ -359,10 +359,10 @@ + INSTALL(FILES ${_target_location} + DESTINATION ${_destination} + ${_rename_param} + CONFIGURATIONS Release RelWithDebInfo + COMPONENT ${ARG_COMPONENT} + OPTIONAL) +- ENDIF() +- ENDFOREACH() ++ ENDFOREACH() ++ ENDIF() + + ENDFUNCTION() diff --git a/recipes/mysql-connector-c/all/test_package/conanfile.py b/recipes/mysql-connector-c/all/test_package/conanfile.py index bd7165a553cf4..d4128b0450777 100644 --- a/recipes/mysql-connector-c/all/test_package/conanfile.py +++ b/recipes/mysql-connector-c/all/test_package/conanfile.py @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/nameof/all/conandata.yml b/recipes/nameof/all/conandata.yml index cdb714291b7f8..c80396081f89b 100644 --- a/recipes/nameof/all/conandata.yml +++ b/recipes/nameof/all/conandata.yml @@ -5,3 +5,9 @@ sources: "0.10.0": sha256: 9c4eaaa795ebbdb5d87952b5280d9eb0ca2d1eaab3bac98a296cb1b74f8e673c url: https://github.com/Neargye/nameof/archive/v0.10.0.tar.gz + "0.10.1": + url: "https://github.com/Neargye/nameof/archive/v0.10.1.tar.gz" + sha256: "000a55de58fb57cd77043ab9e91a3c91dbea5947b2cb0034cddf869ecf16e86d" + "0.10.2": + url: "https://github.com/Neargye/nameof/archive/v0.10.2.tar.gz" + sha256: "b596fd0804c61781bc8d87d9b8e448e2450debddb52c70ed3e89bf02c6c16f4f" diff --git a/recipes/nameof/config.yml b/recipes/nameof/config.yml index 3610f98485b6d..da915b86fd4a9 100644 --- a/recipes/nameof/config.yml +++ b/recipes/nameof/config.yml @@ -3,3 +3,7 @@ versions: folder: "all" "0.10.0": folder: "all" + "0.10.1": + folder: "all" + "0.10.2": + folder: "all" diff --git a/recipes/nanobench/all/conandata.yml b/recipes/nanobench/all/conandata.yml index 948955842437b..b2980ea2da211 100644 --- a/recipes/nanobench/all/conandata.yml +++ b/recipes/nanobench/all/conandata.yml @@ -5,3 +5,12 @@ sources: "4.3.0": url: "https://github.com/martinus/nanobench/archive/v4.3.0.tar.gz" sha256: 6cf97e940eca42394f64d4e9d341e72804c92575247269695beb24f7e2539e82 + "4.3.5": + url: "https://github.com/martinus/nanobench/archive/v4.3.5.tar.gz" + sha256: "205e6cf0ea901f64af971335bfe8011c1f6bd66f6ae678c616da0eddfbe70437" + "4.3.6": + url: "https://github.com/martinus/nanobench/archive/v4.3.6.tar.gz" + sha256: "cfa223fefca8752c0c96416f3440a9b02219f4695a8307db7e8c7054aaed7f01" + "4.3.7": + url: "https://github.com/martinus/nanobench/archive/v4.3.7.tar.gz" + sha256: "6a2dadb8230370c7fb7a9362be1c3677e44d8e06193a4ecb489a4748ef9483d7" diff --git a/recipes/nanobench/config.yml b/recipes/nanobench/config.yml index ede8d6bdb3251..a48eba85edbb2 100644 --- a/recipes/nanobench/config.yml +++ b/recipes/nanobench/config.yml @@ -3,3 +3,9 @@ versions: folder: "all" "4.3.0": folder: "all" + "4.3.5": + folder: "all" + "4.3.6": + folder: "all" + "4.3.7": + folder: "all" diff --git a/recipes/nanodbc/all/conandata.yml b/recipes/nanodbc/all/conandata.yml index b3f66edbef8da..60ad84e0835de 100644 --- a/recipes/nanodbc/all/conandata.yml +++ b/recipes/nanodbc/all/conandata.yml @@ -2,9 +2,25 @@ sources: "cci.20200807": url: "https://github.com/nanodbc/nanodbc/archive/ab8d176262f92d5f75aa2d441bfce27041032201.zip" sha256: "9de057ae6e8d0b9192df1d16ccc70ce7525ca9fe52e56fa8d13cfae9206f8286" + "2.13.0": + url: "https://github.com/nanodbc/nanodbc/archive/v2.13.0.zip" + sha256: "1287869b6ca82728cb6cc53c54f836c72cde15370c16f32d81c9ef6c257f7e43" + "2.14.0": + url: "https://github.com/nanodbc/nanodbc/archive/v2.14.0.tar.gz" + sha256: "56228372042b689beccd96b0ac3476643ea85b3f57b3f23fb11ca4314e68b9a5" patches: "cci.20200807": - patch_file: "patches/0001-odbc-from-cci.patch" base_path: "source_subfolder" - patch_file: "patches/0002-allow-windows-shared.patch" base_path: "source_subfolder" + "2.13.0": + - patch_file: "patches/0001-odbc-from-cci.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-allow-windows-shared.patch" + base_path: "source_subfolder" + "2.14.0": + - patch_file: "patches/0001-odbc-from-cci.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-allow-windows-shared.patch" + base_path: "source_subfolder" diff --git a/recipes/nanodbc/all/conanfile.py b/recipes/nanodbc/all/conanfile.py index 4a87ea45e8c71..44cbf934e3a4d 100644 --- a/recipes/nanodbc/all/conanfile.py +++ b/recipes/nanodbc/all/conanfile.py @@ -60,9 +60,9 @@ def configure(self): def requirements(self): if self.options.with_boost: - self.requires("boost/1.73.0") + self.requires("boost/1.76.0") if self.settings.os != "Windows": - self.requires("odbc/2.3.7") + self.requires("odbc/2.3.9") def source(self): tools.get(**self.conan_data["sources"][self.version]) diff --git a/recipes/nanodbc/config.yml b/recipes/nanodbc/config.yml index 18c1ded4c1843..35d045402c05f 100644 --- a/recipes/nanodbc/config.yml +++ b/recipes/nanodbc/config.yml @@ -1,3 +1,7 @@ versions: "cci.20200807": folder: "all" + "2.13.0": + folder: "all" + "2.14.0": + folder: "all" diff --git a/recipes/nanoflann/all/conandata.yml b/recipes/nanoflann/all/conandata.yml index 133076e7f4f90..c3fd08f9f02f0 100644 --- a/recipes/nanoflann/all/conandata.yml +++ b/recipes/nanoflann/all/conandata.yml @@ -1,7 +1,13 @@ sources: + "1.4.3": + url: "https://github.com/jlblancoc/nanoflann/archive/v1.4.3.tar.gz" + sha256: "cbcecf22bec528a8673a113ee9b0e134f91f1f96be57e913fa1f74e98e4449fa" + "1.4.2": + url: "https://github.com/jlblancoc/nanoflann/archive/refs/tags/v1.4.2.tar.gz" + sha256: "97fce650eb644a359a767af526cab9ba31842e53790a7279887e1ae2fffe7319" "1.3.2": url: "https://github.com/jlblancoc/nanoflann/archive/v1.3.2.tar.gz" - sha256: e100b5fc8d72e9426a80312d852a62c05ddefd23f17cbb22ccd8b458b11d0bea + sha256: "e100b5fc8d72e9426a80312d852a62c05ddefd23f17cbb22ccd8b458b11d0bea" "1.3.1": url: "https://github.com/jlblancoc/nanoflann/archive/v1.3.1.tar.gz" - sha256: b1b1ac9bf6c3bac284014b326480388ad469bdeca78bd27a34ba2ae1da1a03ff + sha256: "b1b1ac9bf6c3bac284014b326480388ad469bdeca78bd27a34ba2ae1da1a03ff" diff --git a/recipes/nanoflann/all/conanfile.py b/recipes/nanoflann/all/conanfile.py index aa1ae8f1f1a15..5e499d9aae48d 100644 --- a/recipes/nanoflann/all/conanfile.py +++ b/recipes/nanoflann/all/conanfile.py @@ -1,5 +1,10 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools + +required_conan_version = ">=1.50.0" class NanoflannConan(ConanFile): @@ -8,30 +13,40 @@ class NanoflannConan(ConanFile): of datasets with different topologies: R2, R3 (point clouds), SO(2) and SO(3) (2D and 3D rotation groups). """ - topics = ("conan", "nanoflann", "nearest-neighbor", "kd-trees") + topics = ("nanoflann", "nearest-neighbor", "kd-trees") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/jlblancoc/nanoflann" license = "BSD-2-Clause" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) - def configure(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - include_folder = os.path.join(self._source_subfolder, "include") - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*", dst="include", src=include_folder) + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + include_folder = os.path.join(self.source_folder, "include") + copy(self, "*", src=include_folder, dst=os.path.join(self.package_folder, "include")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "nanoflann") + self.cpp_info.set_property("cmake_target_name", "nanoflann::nanoflann") + self.cpp_info.set_property("pkg_config_name", "nanoflann") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/nanoflann/all/test_package/CMakeLists.txt b/recipes/nanoflann/all/test_package/CMakeLists.txt index 829b5ca81b9ce..f45dd0b28e293 100644 --- a/recipes/nanoflann/all/test_package/CMakeLists.txt +++ b/recipes/nanoflann/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(nanoflann REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE nanoflann::nanoflann) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/nanoflann/all/test_package/conanfile.py b/recipes/nanoflann/all/test_package/conanfile.py index bd7165a553cf4..d120a992c06a6 100644 --- a/recipes/nanoflann/all/test_package/conanfile.py +++ b/recipes/nanoflann/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/nanoflann/all/test_v1_package/CMakeLists.txt b/recipes/nanoflann/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..8e9967d816e1b --- /dev/null +++ b/recipes/nanoflann/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(nanoflann REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE nanoflann::nanoflann) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/nanoflann/all/test_v1_package/conanfile.py b/recipes/nanoflann/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/nanoflann/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/nanoflann/config.yml b/recipes/nanoflann/config.yml index 27e13c88ce850..abdc53043545d 100644 --- a/recipes/nanoflann/config.yml +++ b/recipes/nanoflann/config.yml @@ -1,4 +1,8 @@ versions: + "1.4.3": + folder: "all" + "1.4.2": + folder: "all" "1.3.2": folder: "all" "1.3.1": diff --git a/recipes/nanosvg/all/conandata.yml b/recipes/nanosvg/all/conandata.yml index 55e47437360d5..8191482a0d600 100644 --- a/recipes/nanosvg/all/conandata.yml +++ b/recipes/nanosvg/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "cci.20210904": + url: "https://github.com/memononen/nanosvg/archive/ccdb1995134d340a93fb20e3a3d323ccb3838dd0.zip" + sha256: "d45fb75b9652f45f3ab4e23e76d77c4a4db02939702d36def6fcd244fb0a44c6" "20190405": url: "https://github.com/memononen/nanosvg/archive/3e2a632c29c294e83e773cbb53f8af25d2bee15a.zip" sha256: "aba32b6de5123480a80ae84dbbb3c08a68bac787e647fd1e1dd5786c3087808a" diff --git a/recipes/nanosvg/all/conanfile.py b/recipes/nanosvg/all/conanfile.py index 3d2a6cad54c43..907d8771861b8 100644 --- a/recipes/nanosvg/all/conanfile.py +++ b/recipes/nanosvg/all/conanfile.py @@ -1,35 +1,43 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools +required_conan_version = ">=1.50.0" + class NanosvgConan(ConanFile): name = "nanosvg" description = "NanoSVG is a simple stupid single-header-file SVG parser." license = "Zlib" - topics = ("conan", "nanosvg", "svg", "parser", "header-only") + topics = ("nanosvg", "svg", "parser", "header-only") homepage = "https://github.com/memononen/nanosvg" url = "https://github.com/conan-io/conan-center-index" - settings = "os" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - url = self.conan_data["sources"][self.version]["url"] - extracted_dir = self.name + "-" + os.path.splitext(os.path.basename(url))[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) - self.copy("*.h", dst=os.path.join("include", "nanosvg"), src=os.path.join(self._source_subfolder, "src")) + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder, "include", "nanosvg")) def package_info(self): self.cpp_info.includedirs.append(os.path.join("include", "nanosvg")) - if self.settings.os == "Linux": + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") diff --git a/recipes/nanosvg/all/test_package/CMakeLists.txt b/recipes/nanosvg/all/test_package/CMakeLists.txt index 7b9b613cbb24a..581e05411c02f 100644 --- a/recipes/nanosvg/all/test_package/CMakeLists.txt +++ b/recipes/nanosvg/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(nanosvg REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE nanosvg::nanosvg) diff --git a/recipes/nanosvg/all/test_package/conanfile.py b/recipes/nanosvg/all/test_package/conanfile.py index 857c3bd448280..621a8ff8e6daf 100644 --- a/recipes/nanosvg/all/test_package/conanfile.py +++ b/recipes/nanosvg/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") svg_name = os.path.join(self.source_folder, "nano.svg") - bin_path = os.path.join("bin", "test_package") - self.run("{0} {1}".format(bin_path, svg_name), run_environment=True) + self.run(f"{bin_path} {svg_name}", env="conanrun") diff --git a/recipes/nanosvg/all/test_v1_package/CMakeLists.txt b/recipes/nanosvg/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..8f69e251c10a7 --- /dev/null +++ b/recipes/nanosvg/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(nanosvg REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE nanosvg::nanosvg) diff --git a/recipes/nanosvg/all/test_v1_package/conanfile.py b/recipes/nanosvg/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e5fed27a4959a --- /dev/null +++ b/recipes/nanosvg/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + svg_name = os.path.join(self.source_folder, os.pardir, "test_package", "nano.svg") + self.run(f"{bin_path} {svg_name}", run_environment=True) diff --git a/recipes/nanosvg/config.yml b/recipes/nanosvg/config.yml index 5d1e96c8fd256..4cfe8bfdf0bc4 100644 --- a/recipes/nanosvg/config.yml +++ b/recipes/nanosvg/config.yml @@ -1,3 +1,5 @@ versions: + "cci.20210904": + folder: all "20190405": folder: all diff --git a/recipes/nas/all/conandata.yml b/recipes/nas/all/conandata.yml new file mode 100644 index 0000000000000..8a174de309503 --- /dev/null +++ b/recipes/nas/all/conandata.yml @@ -0,0 +1,6 @@ +sources: + "1.9.4": + - url: "https://downloads.sourceforge.net/nas/nas-1.9.4.src.tar.gz" + sha256: "cf36ea63751ce86cfd3b76c1659ce0d6a361a2e7cb34069854e156532703b39d" + - url: "https://unlicense.org/UNLICENSE" + sha256: "7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c" diff --git a/recipes/nas/all/conanfile.py b/recipes/nas/all/conanfile.py new file mode 100644 index 0000000000000..b0ef8613914c6 --- /dev/null +++ b/recipes/nas/all/conanfile.py @@ -0,0 +1,117 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + + +class NasRecipe(ConanFile): + name = "nas" + description = "The Network Audio System is a network transparent, client/server audio transport system." + topics = ("audio", "sound") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.radscan.com/nas.html" + license = "Unlicense" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def validate(self): + if self.settings.os not in ("FreeBSD", "Linux"): + raise ConanInvalidConfiguration("Recipe supports Linux only") + + def requirements(self): + self.requires("xorg/system") + + def build_requirements(self): + self.build_requires("bison/3.7.1") + self.build_requires("flex/2.6.4") + self.build_requires("imake/1.0.8") + self.build_requires("xorg-cf-files/1.0.7") + self.build_requires("xorg-makedepend/1.0.6") + self.build_requires("xorg-gccmakedep/1.0.3") + + def source(self): + tools.get(**self.conan_data["sources"][self.version][0], destination=self._source_subfolder, strip_root=True) + tools.download(filename="LICENSE", **self.conan_data["sources"][self.version][1]) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + def _configure_autotools(self): + autotools = AutoToolsBuildEnvironment(self) + autotools.libs = [] + return autotools + + @property + def _imake_irulesrc(self): + return self._user_info_build["xorg-cf-files"].CONFIG_PATH + + @property + def _imake_defines(self): + return "-DUsrLibDir={}".format(os.path.join(self.package_folder, "lib")) + + @property + def _imake_make_args(self): + return ["IRULESRC={}".format(self._imake_irulesrc), "IMAKE_DEFINES={}".format(self._imake_defines)] + + def build(self): + tools.replace_in_file(os.path.join(self._source_subfolder, "server", "dia", "main.c"), + "\nFILE *yyin", "\nextern FILE *yyin") + with tools.chdir(self._source_subfolder): + self.run("imake -DUseInstalled -I{} {}".format(self._imake_irulesrc, self._imake_defines), run_environment=True) + autotools = self._configure_autotools() + autotools.make(target="World",args=["-j1"] + self._imake_make_args) + + def package(self): + self.copy("LICENSE", dst="licenses") + + with tools.chdir(self._source_subfolder): + autotools = self._configure_autotools() + tmp_install = os.path.join(self.build_folder, "prefix") + install_args = [ + "DESTDIR={}".format(tmp_install), + "INCDIR=/include", + "ETCDIR=/etc", + "USRLIBDIR=/lib", + "BINDIR=/bin", + ] + self._imake_make_args + autotools.install(args=["-j1"] + install_args) + + self.copy("*", src=os.path.join(tmp_install, "bin"), dst="bin") + self.copy("*", src=os.path.join(tmp_install, "include"), dst=os.path.join("include", "audio")) + self.copy("*", src=os.path.join(tmp_install, "lib"), dst="lib") + + if self.options.shared: + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.a") + else: + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.so*") + + def package_info(self): + self.cpp_info.libs = ["audio"] + self.cpp_info.requires = ["xorg::xau"] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.path.append(bin_path) diff --git a/recipes/nas/all/test_package/CMakeLists.txt b/recipes/nas/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b9b613cbb24a --- /dev/null +++ b/recipes/nas/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/nas/all/test_package/conanfile.py b/recipes/nas/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e745e8cbe21e6 --- /dev/null +++ b/recipes/nas/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, CMake, tools + +class NasTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/nas/all/test_package/test_package.c b/recipes/nas/all/test_package/test_package.c new file mode 100644 index 0000000000000..836c0d10e54e5 --- /dev/null +++ b/recipes/nas/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include